Home | History | Annotate | Download | only in include
      1 /*
      2  * Copyright (c) 2016 Cyril Hrubis <chrubis (at) suse.cz>
      3  * Copyright (c) 2015 Fujitsu Ltd.
      4  *
      5  * This program is free software: you can redistribute it and/or modify
      6  * it under the terms of the GNU General Public License as published by
      7  * the Free Software Foundation, either version 2 of the License, or
      8  * (at your option) any later version.
      9  *
     10  * This program is distributed in the hope that it will be useful,
     11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13  * GNU General Public License for more details.
     14  *
     15  * You should have received a copy of the GNU General Public License
     16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
     17  */
     18 
     19 #ifndef SAFE_NET_FN_H__
     20 #define SAFE_NET_FN_H__
     21 
     22 #include <sys/types.h>
     23 #include <sys/socket.h>
     24 #include <netinet/in.h>
     25 #include <arpa/inet.h>
     26 #include <sys/un.h>
     27 
     28 char *tst_sock_addr(const struct sockaddr *sa, socklen_t salen, char *res,
     29 		    size_t len);
     30 
     31 int safe_socket(const char *file, const int lineno, void (cleanup_fn)(void),
     32 		int domain, int type, int protocol);
     33 
     34 int safe_bind(const char *file, const int lineno, void (cleanup_fn)(void),
     35 	      int socket, const struct sockaddr *address,
     36 	      socklen_t address_len);
     37 
     38 int safe_listen(const char *file, const int lineno, void (cleanup_fn)(void),
     39 		int socket, int backlog);
     40 
     41 int safe_connect(const char *file, const int lineno, void (cleanup_fn)(void),
     42 		 int sockfd, const struct sockaddr *addr, socklen_t addrlen);
     43 
     44 int safe_getsockname(const char *file, const int lineno,
     45 		     void (cleanup_fn)(void), int sockfd, struct sockaddr *addr,
     46 		     socklen_t *addrlen);
     47 
     48 #endif /* SAFE_NET_FN_H__ */
     49