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