• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2016 Cyril Hrubis <chrubis@suse.cz>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef TST_SAFE_NET_H__
19 #define TST_SAFE_NET_H__
20 
21 #include <sys/types.h>
22 #include <sys/socket.h>
23 #include <netinet/in.h>
24 #include <arpa/inet.h>
25 #include <sys/un.h>
26 
27 #include "safe_net_fn.h"
28 
29 #define SAFE_SOCKET(domain, type, protocol) \
30 	safe_socket(__FILE__, __LINE__, NULL, domain, type, protocol)
31 
32 #define SAFE_SETSOCKOPT(fd, level, optname, optval, optlen) \
33 	safe_setsockopt(__FILE__, __LINE__, fd, level, optname, optval, optlen)
34 
35 #define SAFE_SEND(strict, sockfd, buf, len, flags) \
36 	safe_send(__FILE__, __LINE__, strict, sockfd, buf, len, flags)
37 
38 #define SAFE_SENDTO(strict, fd, buf, len, flags, dest_addr, addrlen) \
39 	safe_sendto(__FILE__, __LINE__, strict, fd, buf, len, flags, \
40 		    dest_addr, addrlen)
41 
42 #define SAFE_BIND(socket, address, address_len) \
43 	safe_bind(__FILE__, __LINE__, NULL, socket, address, \
44 		  address_len)
45 
46 #define SAFE_LISTEN(socket, backlog) \
47 	safe_listen(__FILE__, __LINE__, NULL, socket, backlog)
48 
49 #define SAFE_CONNECT(sockfd, addr, addrlen) \
50 	safe_connect(__FILE__, __LINE__, NULL, sockfd, addr, addrlen)
51 
52 #define SAFE_GETSOCKNAME(sockfd, addr, addrlen) \
53 	safe_getsockname(__FILE__, __LINE__, NULL, sockfd, addr, \
54 			 addrlen)
55 
56 #define SAFE_GETHOSTNAME(name, size) \
57 	safe_gethostname(__FILE__, __LINE__, name, size)
58 
59 #endif /* TST_SAFE_NET_H__ */
60