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