xref: /freebsd/crypto/heimdal/lib/roken/socket_wrapper.h (revision 6a068746777241722b2b32c5d0bc443a2a64d80b)
1c19800e8SDoug Rabson /*
2c19800e8SDoug Rabson  * Copyright (C) Jelmer Vernooij 2005 <jelmer@samba.org>
3c19800e8SDoug Rabson  * Copyright (C) Stefan Metzmacher 2006 <metze@samba.org>
4c19800e8SDoug Rabson  *
5c19800e8SDoug Rabson  * All rights reserved.
6c19800e8SDoug Rabson  *
7c19800e8SDoug Rabson  * Redistribution and use in source and binary forms, with or without
8c19800e8SDoug Rabson  * modification, are permitted provided that the following conditions
9c19800e8SDoug Rabson  * are met:
10c19800e8SDoug Rabson  *
11c19800e8SDoug Rabson  * 1. Redistributions of source code must retain the above copyright
12c19800e8SDoug Rabson  *    notice, this list of conditions and the following disclaimer.
13c19800e8SDoug Rabson  *
14c19800e8SDoug Rabson  * 2. Redistributions in binary form must reproduce the above copyright
15c19800e8SDoug Rabson  *    notice, this list of conditions and the following disclaimer in the
16c19800e8SDoug Rabson  *    documentation and/or other materials provided with the distribution.
17c19800e8SDoug Rabson  *
18c19800e8SDoug Rabson  * 3. Neither the name of the author nor the names of its contributors
19c19800e8SDoug Rabson  *    may be used to endorse or promote products derived from this software
20c19800e8SDoug Rabson  *    without specific prior written permission.
21c19800e8SDoug Rabson  *
22c19800e8SDoug Rabson  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23c19800e8SDoug Rabson  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24c19800e8SDoug Rabson  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25c19800e8SDoug Rabson  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
26c19800e8SDoug Rabson  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27c19800e8SDoug Rabson  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28c19800e8SDoug Rabson  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29c19800e8SDoug Rabson  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30c19800e8SDoug Rabson  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31c19800e8SDoug Rabson  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32c19800e8SDoug Rabson  * SUCH DAMAGE.
33c19800e8SDoug Rabson  *
34c19800e8SDoug Rabson  */
35c19800e8SDoug Rabson 
36c19800e8SDoug Rabson #ifndef __SOCKET_WRAPPER_H__
37c19800e8SDoug Rabson #define __SOCKET_WRAPPER_H__
38c19800e8SDoug Rabson 
39c19800e8SDoug Rabson int swrap_socket(int family, int type, int protocol);
40c19800e8SDoug Rabson int swrap_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
41c19800e8SDoug Rabson int swrap_connect(int s, const struct sockaddr *serv_addr, socklen_t addrlen);
42c19800e8SDoug Rabson int swrap_bind(int s, const struct sockaddr *myaddr, socklen_t addrlen);
43c19800e8SDoug Rabson int swrap_listen(int s, int backlog);
44c19800e8SDoug Rabson int swrap_getpeername(int s, struct sockaddr *name, socklen_t *addrlen);
45c19800e8SDoug Rabson int swrap_getsockname(int s, struct sockaddr *name, socklen_t *addrlen);
46c19800e8SDoug Rabson int swrap_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen);
47c19800e8SDoug Rabson int swrap_setsockopt(int s, int  level,  int  optname,  const  void  *optval, socklen_t optlen);
48c19800e8SDoug Rabson ssize_t swrap_recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen);
49c19800e8SDoug Rabson ssize_t swrap_sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen);
50c19800e8SDoug Rabson int swrap_ioctl(int s, int req, void *ptr);
51c19800e8SDoug Rabson ssize_t swrap_recv(int s, void *buf, size_t len, int flags);
52c19800e8SDoug Rabson ssize_t swrap_send(int s, const void *buf, size_t len, int flags);
53c19800e8SDoug Rabson int swrap_close(int);
54c19800e8SDoug Rabson int swrap_dup(int);
55c19800e8SDoug Rabson int swrap_dup2(int, int);
56c19800e8SDoug Rabson 
57c19800e8SDoug Rabson #ifdef SOCKET_WRAPPER_REPLACE
58c19800e8SDoug Rabson 
59c19800e8SDoug Rabson #ifdef accept
60c19800e8SDoug Rabson #undef accept
61c19800e8SDoug Rabson #endif
62c19800e8SDoug Rabson #define accept(s,addr,addrlen)		swrap_accept(s,addr,addrlen)
63c19800e8SDoug Rabson 
64c19800e8SDoug Rabson #ifdef connect
65c19800e8SDoug Rabson #undef connect
66c19800e8SDoug Rabson #endif
67c19800e8SDoug Rabson #define connect(s,serv_addr,addrlen)	swrap_connect(s,serv_addr,addrlen)
68c19800e8SDoug Rabson 
69c19800e8SDoug Rabson #ifdef bind
70c19800e8SDoug Rabson #undef bind
71c19800e8SDoug Rabson #endif
72c19800e8SDoug Rabson #define bind(s,myaddr,addrlen)		swrap_bind(s,myaddr,addrlen)
73c19800e8SDoug Rabson 
74c19800e8SDoug Rabson #ifdef listen
75c19800e8SDoug Rabson #undef listen
76c19800e8SDoug Rabson #endif
77c19800e8SDoug Rabson #define listen(s,blog)			swrap_listen(s,blog)
78c19800e8SDoug Rabson 
79c19800e8SDoug Rabson #ifdef getpeername
80c19800e8SDoug Rabson #undef getpeername
81c19800e8SDoug Rabson #endif
82c19800e8SDoug Rabson #define getpeername(s,name,addrlen)	swrap_getpeername(s,name,addrlen)
83c19800e8SDoug Rabson 
84c19800e8SDoug Rabson #ifdef getsockname
85c19800e8SDoug Rabson #undef getsockname
86c19800e8SDoug Rabson #endif
87c19800e8SDoug Rabson #define getsockname(s,name,addrlen)	swrap_getsockname(s,name,addrlen)
88c19800e8SDoug Rabson 
89c19800e8SDoug Rabson #ifdef getsockopt
90c19800e8SDoug Rabson #undef getsockopt
91c19800e8SDoug Rabson #endif
92c19800e8SDoug Rabson #define getsockopt(s,level,optname,optval,optlen) swrap_getsockopt(s,level,optname,optval,optlen)
93c19800e8SDoug Rabson 
94c19800e8SDoug Rabson #ifdef setsockopt
95c19800e8SDoug Rabson #undef setsockopt
96c19800e8SDoug Rabson #endif
97c19800e8SDoug Rabson #define setsockopt(s,level,optname,optval,optlen) swrap_setsockopt(s,level,optname,optval,optlen)
98c19800e8SDoug Rabson 
99c19800e8SDoug Rabson #ifdef recvfrom
100c19800e8SDoug Rabson #undef recvfrom
101c19800e8SDoug Rabson #endif
102c19800e8SDoug Rabson #define recvfrom(s,buf,len,flags,from,fromlen) 	  swrap_recvfrom(s,buf,len,flags,from,fromlen)
103c19800e8SDoug Rabson 
104c19800e8SDoug Rabson #ifdef sendto
105c19800e8SDoug Rabson #undef sendto
106c19800e8SDoug Rabson #endif
107c19800e8SDoug Rabson #define sendto(s,buf,len,flags,to,tolen)          swrap_sendto(s,buf,len,flags,to,tolen)
108c19800e8SDoug Rabson 
109c19800e8SDoug Rabson #ifdef ioctl
110c19800e8SDoug Rabson #undef ioctl
111c19800e8SDoug Rabson #endif
112c19800e8SDoug Rabson #define ioctl(s,req,ptr)		swrap_ioctl(s,req,ptr)
113c19800e8SDoug Rabson 
114c19800e8SDoug Rabson #ifdef recv
115c19800e8SDoug Rabson #undef recv
116c19800e8SDoug Rabson #endif
117c19800e8SDoug Rabson #define recv(s,buf,len,flags)		swrap_recv(s,buf,len,flags)
118c19800e8SDoug Rabson 
119c19800e8SDoug Rabson #ifdef send
120c19800e8SDoug Rabson #undef send
121c19800e8SDoug Rabson #endif
122c19800e8SDoug Rabson #define send(s,buf,len,flags)		swrap_send(s,buf,len,flags)
123c19800e8SDoug Rabson 
124c19800e8SDoug Rabson #ifdef socket
125c19800e8SDoug Rabson #undef socket
126c19800e8SDoug Rabson #endif
127c19800e8SDoug Rabson #define socket(domain,type,protocol)	swrap_socket(domain,type,protocol)
128c19800e8SDoug Rabson 
129c19800e8SDoug Rabson #ifdef close
130c19800e8SDoug Rabson #undef close
131c19800e8SDoug Rabson #endif
132c19800e8SDoug Rabson #define close(s)			swrap_close(s)
133c19800e8SDoug Rabson 
134c19800e8SDoug Rabson #ifdef dup
135c19800e8SDoug Rabson #undef dup
136c19800e8SDoug Rabson #endif
137c19800e8SDoug Rabson #define dup(oldd)			swrap_dup(oldd)
138c19800e8SDoug Rabson 
139c19800e8SDoug Rabson #ifdef dup2
140c19800e8SDoug Rabson #undef dup2
141c19800e8SDoug Rabson #endif
142c19800e8SDoug Rabson #define dup2(oldd, newd)		swrap_dup2(oldd, newd)
143c19800e8SDoug Rabson 
144c19800e8SDoug Rabson #endif
145c19800e8SDoug Rabson 
146c19800e8SDoug Rabson #endif /* __SOCKET_WRAPPER_H__ */
147