Simon Cooksey / mbed-os
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers sockets.h Source File

sockets.h

Go to the documentation of this file.
00001 /**
00002  * @file
00003  * Socket API (to be used from non-TCPIP threads)
00004  */
00005 
00006 /*
00007  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
00008  * All rights reserved.
00009  *
00010  * Redistribution and use in source and binary forms, with or without modification,
00011  * are permitted provided that the following conditions are met:
00012  *
00013  * 1. Redistributions of source code must retain the above copyright notice,
00014  *    this list of conditions and the following disclaimer.
00015  * 2. Redistributions in binary form must reproduce the above copyright notice,
00016  *    this list of conditions and the following disclaimer in the documentation
00017  *    and/or other materials provided with the distribution.
00018  * 3. The name of the author may not be used to endorse or promote products
00019  *    derived from this software without specific prior written permission.
00020  *
00021  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
00022  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00023  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
00024  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00025  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
00026  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00027  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00028  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
00029  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
00030  * OF SUCH DAMAGE.
00031  *
00032  * This file is part of the lwIP TCP/IP stack.
00033  *
00034  * Author: Adam Dunkels <adam@sics.se>
00035  *
00036  */
00037 
00038 
00039 #ifndef LWIP_HDR_SOCKETS_H
00040 #define LWIP_HDR_SOCKETS_H
00041 
00042 #include "lwip/opt.h"
00043 
00044 #if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */
00045 
00046 #include <stddef.h> /* for size_t */
00047 
00048 #include "lwip/ip_addr.h"
00049 #include "lwip/err.h"
00050 #include "lwip/inet.h"
00051 
00052 #ifdef __cplusplus
00053 extern "C" {
00054 #endif
00055 
00056 /* If your port already typedef's sa_family_t, define SA_FAMILY_T_DEFINED
00057    to prevent this code from redefining it. */
00058 #if !defined(sa_family_t) && !defined(SA_FAMILY_T_DEFINED)
00059 typedef u8_t sa_family_t;
00060 #endif
00061 /* If your port already typedef's in_port_t, define IN_PORT_T_DEFINED
00062    to prevent this code from redefining it. */
00063 #if !defined(in_port_t) && !defined(IN_PORT_T_DEFINED)
00064 typedef u16_t in_port_t;
00065 #endif
00066 
00067 #if LWIP_IPV4
00068 /* members are in network byte order */
00069 struct sockaddr_in {
00070   u8_t            sin_len;
00071   sa_family_t     sin_family;
00072   in_port_t       sin_port;
00073   struct in_addr  sin_addr;
00074 #define SIN_ZERO_LEN 8
00075   char            sin_zero[SIN_ZERO_LEN];
00076 };
00077 #endif /* LWIP_IPV4 */
00078 
00079 #if LWIP_IPV6
00080 struct sockaddr_in6 {
00081   u8_t            sin6_len;      /* length of this structure    */
00082   sa_family_t     sin6_family;   /* AF_INET6                    */
00083   in_port_t       sin6_port;     /* Transport layer port #      */
00084   u32_t           sin6_flowinfo; /* IPv6 flow information       */
00085   struct in6_addr sin6_addr;     /* IPv6 address                */
00086   u32_t           sin6_scope_id; /* Set of interfaces for scope */
00087 };
00088 #endif /* LWIP_IPV6 */
00089 
00090 struct sockaddr {
00091   u8_t        sa_len;
00092   sa_family_t sa_family;
00093   char        sa_data[14];
00094 };
00095 
00096 struct sockaddr_storage {
00097   u8_t        s2_len;
00098   sa_family_t ss_family;
00099   char        s2_data1[2];
00100   u32_t       s2_data2[3];
00101 #if LWIP_IPV6
00102   u32_t       s2_data3[3];
00103 #endif /* LWIP_IPV6 */
00104 };
00105 
00106 /* If your port already typedef's socklen_t, define SOCKLEN_T_DEFINED
00107    to prevent this code from redefining it. */
00108 #if !defined(socklen_t) && !defined(SOCKLEN_T_DEFINED)
00109 typedef u32_t socklen_t;
00110 #endif
00111 
00112 struct lwip_sock;
00113 
00114 #if !LWIP_TCPIP_CORE_LOCKING
00115 /** Maximum optlen used by setsockopt/getsockopt */
00116 #define LWIP_SETGETSOCKOPT_MAXOPTLEN 16
00117 
00118 /** This struct is used to pass data to the set/getsockopt_internal
00119  * functions running in tcpip_thread context (only a void* is allowed) */
00120 struct lwip_setgetsockopt_data {
00121   /** socket index for which to change options */
00122   int s;
00123   /** level of the option to process */
00124   int level;
00125   /** name of the option to process */
00126   int optname;
00127   /** set: value to set the option to
00128     * get: value of the option is stored here */
00129 #if LWIP_MPU_COMPATIBLE
00130   u8_t optval[LWIP_SETGETSOCKOPT_MAXOPTLEN];
00131 #else
00132   union {
00133      void *p;
00134      const void *pc;
00135   } optval;
00136 #endif
00137   /** size of *optval */
00138   socklen_t optlen;
00139   /** if an error occurs, it is temporarily stored here */
00140   err_t err;
00141   /** semaphore to wake up the calling task */
00142   void* completed_sem;
00143 };
00144 #endif /* !LWIP_TCPIP_CORE_LOCKING */
00145 
00146 #if !defined(iovec)
00147 struct iovec {
00148   void  *iov_base;
00149   size_t iov_len;
00150 };
00151 #endif
00152 
00153 struct msghdr {
00154   void         *msg_name;
00155   socklen_t     msg_namelen;
00156   struct iovec *msg_iov;
00157   int           msg_iovlen;
00158   void         *msg_control;
00159   socklen_t     msg_controllen;
00160   int           msg_flags;
00161 };
00162 
00163 /* Socket protocol types (TCP/UDP/RAW) */
00164 #define SOCK_STREAM     1
00165 #define SOCK_DGRAM      2
00166 #define SOCK_RAW        3
00167 
00168 /*
00169  * Option flags per-socket. These must match the SOF_ flags in ip.h (checked in init.c)
00170  */
00171 #define SO_REUSEADDR   0x0004 /* Allow local address reuse */
00172 #define SO_KEEPALIVE   0x0008 /* keep connections alive */
00173 #define SO_BROADCAST   0x0020 /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */
00174 
00175 
00176 /*
00177  * Additional options, not kept in so_options.
00178  */
00179 #define SO_DEBUG       0x0001 /* Unimplemented: turn on debugging info recording */
00180 #define SO_ACCEPTCONN  0x0002 /* socket has had listen() */
00181 #define SO_DONTROUTE   0x0010 /* Unimplemented: just use interface addresses */
00182 #define SO_USELOOPBACK 0x0040 /* Unimplemented: bypass hardware when possible */
00183 #define SO_LINGER      0x0080 /* linger on close if data present */
00184 #define SO_DONTLINGER  ((int)(~SO_LINGER))
00185 #define SO_OOBINLINE   0x0100 /* Unimplemented: leave received OOB data in line */
00186 #define SO_REUSEPORT   0x0200 /* Unimplemented: allow local address & port reuse */
00187 #define SO_SNDBUF      0x1001 /* Unimplemented: send buffer size */
00188 #define SO_RCVBUF      0x1002 /* receive buffer size */
00189 #define SO_SNDLOWAT    0x1003 /* Unimplemented: send low-water mark */
00190 #define SO_RCVLOWAT    0x1004 /* Unimplemented: receive low-water mark */
00191 #define SO_SNDTIMEO    0x1005 /* send timeout */
00192 #define SO_RCVTIMEO    0x1006 /* receive timeout */
00193 #define SO_ERROR       0x1007 /* get error status and clear */
00194 #define SO_TYPE        0x1008 /* get socket type */
00195 #define SO_CONTIMEO    0x1009 /* Unimplemented: connect timeout */
00196 #define SO_NO_CHECK    0x100a /* don't create UDP checksum */
00197 
00198 
00199 /*
00200  * Structure used for manipulating linger option.
00201  */
00202 struct linger {
00203        int l_onoff;                /* option on/off */
00204        int l_linger;               /* linger time in seconds */
00205 };
00206 
00207 /*
00208  * Level number for (get/set)sockopt() to apply to socket itself.
00209  */
00210 #define  SOL_SOCKET  0xfff    /* options for socket level */
00211 
00212 
00213 #define AF_UNSPEC       0
00214 #define AF_INET         2
00215 #if LWIP_IPV6
00216 #define AF_INET6        10
00217 #else /* LWIP_IPV6 */
00218 #define AF_INET6        AF_UNSPEC
00219 #endif /* LWIP_IPV6 */
00220 #define PF_INET         AF_INET
00221 #define PF_INET6        AF_INET6
00222 #define PF_UNSPEC       AF_UNSPEC
00223 
00224 #define IPPROTO_IP      0
00225 #define IPPROTO_ICMP    1
00226 #define IPPROTO_TCP     6
00227 #define IPPROTO_UDP     17
00228 #if LWIP_IPV6
00229 #define IPPROTO_IPV6    41
00230 #define IPPROTO_ICMPV6  58
00231 #endif /* LWIP_IPV6 */
00232 #define IPPROTO_UDPLITE 136
00233 #define IPPROTO_RAW     255
00234 
00235 /* Flags we can use with send and recv. */
00236 #define MSG_PEEK       0x01    /* Peeks at an incoming message */
00237 #define MSG_WAITALL    0x02    /* Unimplemented: Requests that the function block until the full amount of data requested can be returned */
00238 #define MSG_OOB        0x04    /* Unimplemented: Requests out-of-band data. The significance and semantics of out-of-band data are protocol-specific */
00239 #define MSG_DONTWAIT   0x08    /* Nonblocking i/o for this operation only */
00240 #define MSG_MORE       0x10    /* Sender will send more */
00241 
00242 
00243 /*
00244  * Options for level IPPROTO_IP
00245  */
00246 #define IP_TOS             1
00247 #define IP_TTL             2
00248 
00249 #if LWIP_TCP
00250 /*
00251  * Options for level IPPROTO_TCP
00252  */
00253 #define TCP_NODELAY    0x01    /* don't delay send to coalesce packets */
00254 #define TCP_KEEPALIVE  0x02    /* send KEEPALIVE probes when idle for pcb->keep_idle milliseconds */
00255 #define TCP_KEEPIDLE   0x03    /* set pcb->keep_idle  - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt */
00256 #define TCP_KEEPINTVL  0x04    /* set pcb->keep_intvl - Use seconds for get/setsockopt */
00257 #define TCP_KEEPCNT    0x05    /* set pcb->keep_cnt   - Use number of probes sent for get/setsockopt */
00258 #endif /* LWIP_TCP */
00259 
00260 #if LWIP_IPV6
00261 /*
00262  * Options for level IPPROTO_IPV6
00263  */
00264 #define IPV6_CHECKSUM       7  /* RFC3542: calculate and insert the ICMPv6 checksum for raw sockets. */
00265 #define IPV6_V6ONLY         27 /* RFC3493: boolean control to restrict AF_INET6 sockets to IPv6 communications only. */
00266 #endif /* LWIP_IPV6 */
00267 
00268 #if LWIP_UDP && LWIP_UDPLITE
00269 /*
00270  * Options for level IPPROTO_UDPLITE
00271  */
00272 #define UDPLITE_SEND_CSCOV 0x01 /* sender checksum coverage */
00273 #define UDPLITE_RECV_CSCOV 0x02 /* minimal receiver checksum coverage */
00274 #endif /* LWIP_UDP && LWIP_UDPLITE*/
00275 
00276 
00277 #if LWIP_MULTICAST_TX_OPTIONS
00278 /*
00279  * Options and types for UDP multicast traffic handling
00280  */
00281 #define IP_MULTICAST_TTL   5
00282 #define IP_MULTICAST_IF    6
00283 #define IP_MULTICAST_LOOP  7
00284 #endif /* LWIP_MULTICAST_TX_OPTIONS */
00285 
00286 #if LWIP_IGMP
00287 /*
00288  * Options and types related to multicast membership
00289  */
00290 #define IP_ADD_MEMBERSHIP  3
00291 #define IP_DROP_MEMBERSHIP 4
00292 
00293 typedef struct ip_mreq {
00294     struct in_addr imr_multiaddr; /* IP multicast address of group */
00295     struct in_addr imr_interface; /* local IP address of interface */
00296 } ip_mreq;
00297 #endif /* LWIP_IGMP */
00298 
00299 /*
00300  * The Type of Service provides an indication of the abstract
00301  * parameters of the quality of service desired.  These parameters are
00302  * to be used to guide the selection of the actual service parameters
00303  * when transmitting a datagram through a particular network.  Several
00304  * networks offer service precedence, which somehow treats high
00305  * precedence traffic as more important than other traffic (generally
00306  * by accepting only traffic above a certain precedence at time of high
00307  * load).  The major choice is a three way tradeoff between low-delay,
00308  * high-reliability, and high-throughput.
00309  * The use of the Delay, Throughput, and Reliability indications may
00310  * increase the cost (in some sense) of the service.  In many networks
00311  * better performance for one of these parameters is coupled with worse
00312  * performance on another.  Except for very unusual cases at most two
00313  * of these three indications should be set.
00314  */
00315 #define IPTOS_TOS_MASK          0x1E
00316 #define IPTOS_TOS(tos)          ((tos) & IPTOS_TOS_MASK)
00317 #define IPTOS_LOWDELAY          0x10
00318 #define IPTOS_THROUGHPUT        0x08
00319 #define IPTOS_RELIABILITY       0x04
00320 #define IPTOS_LOWCOST           0x02
00321 #define IPTOS_MINCOST           IPTOS_LOWCOST
00322 
00323 /*
00324  * The Network Control precedence designation is intended to be used
00325  * within a network only.  The actual use and control of that
00326  * designation is up to each network. The Internetwork Control
00327  * designation is intended for use by gateway control originators only.
00328  * If the actual use of these precedence designations is of concern to
00329  * a particular network, it is the responsibility of that network to
00330  * control the access to, and use of, those precedence designations.
00331  */
00332 #define IPTOS_PREC_MASK                 0xe0
00333 #define IPTOS_PREC(tos)                ((tos) & IPTOS_PREC_MASK)
00334 #define IPTOS_PREC_NETCONTROL           0xe0
00335 #define IPTOS_PREC_INTERNETCONTROL      0xc0
00336 #define IPTOS_PREC_CRITIC_ECP           0xa0
00337 #define IPTOS_PREC_FLASHOVERRIDE        0x80
00338 #define IPTOS_PREC_FLASH                0x60
00339 #define IPTOS_PREC_IMMEDIATE            0x40
00340 #define IPTOS_PREC_PRIORITY             0x20
00341 #define IPTOS_PREC_ROUTINE              0x00
00342 
00343 
00344 /*
00345  * Commands for ioctlsocket(),  taken from the BSD file fcntl.h.
00346  * lwip_ioctl only supports FIONREAD and FIONBIO, for now
00347  *
00348  * Ioctl's have the command encoded in the lower word,
00349  * and the size of any in or out parameters in the upper
00350  * word.  The high 2 bits of the upper word are used
00351  * to encode the in/out status of the parameter; for now
00352  * we restrict parameters to at most 128 bytes.
00353  */
00354 #if !defined(FIONREAD) || !defined(FIONBIO)
00355 #define IOCPARM_MASK    0x7fU           /* parameters must be < 128 bytes */
00356 #define IOC_VOID        0x20000000UL    /* no parameters */
00357 #define IOC_OUT         0x40000000UL    /* copy out parameters */
00358 #define IOC_IN          0x80000000UL    /* copy in parameters */
00359 #define IOC_INOUT       (IOC_IN|IOC_OUT)
00360                                         /* 0x20000000 distinguishes new &
00361                                            old ioctl's */
00362 #define _IO(x,y)        (IOC_VOID|((x)<<8)|(y))
00363 
00364 #define _IOR(x,y,t)     (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
00365 
00366 #define _IOW(x,y,t)     (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
00367 #endif /* !defined(FIONREAD) || !defined(FIONBIO) */
00368 
00369 #ifndef FIONREAD
00370 #define FIONREAD    _IOR('f', 127, unsigned long) /* get # bytes to read */
00371 #endif
00372 #ifndef FIONBIO
00373 #define FIONBIO     _IOW('f', 126, unsigned long) /* set/clear non-blocking i/o */
00374 #endif
00375 
00376 /* Socket I/O Controls: unimplemented */
00377 #ifndef SIOCSHIWAT
00378 #define SIOCSHIWAT  _IOW('s',  0, unsigned long)  /* set high watermark */
00379 #define SIOCGHIWAT  _IOR('s',  1, unsigned long)  /* get high watermark */
00380 #define SIOCSLOWAT  _IOW('s',  2, unsigned long)  /* set low watermark */
00381 #define SIOCGLOWAT  _IOR('s',  3, unsigned long)  /* get low watermark */
00382 #define SIOCATMARK  _IOR('s',  7, unsigned long)  /* at oob mark? */
00383 #endif
00384 
00385 /* commands for fnctl */
00386 #ifndef F_GETFL
00387 #define F_GETFL 3
00388 #endif
00389 #ifndef F_SETFL
00390 #define F_SETFL 4
00391 #endif
00392 
00393 /* File status flags and file access modes for fnctl,
00394    these are bits in an int. */
00395 #ifndef O_NONBLOCK
00396 #define O_NONBLOCK  1 /* nonblocking I/O */
00397 #endif
00398 #ifndef O_NDELAY
00399 #define O_NDELAY    1 /* same as O_NONBLOCK, for compatibility */
00400 #endif
00401 
00402 #ifndef SHUT_RD
00403   #define SHUT_RD   0
00404   #define SHUT_WR   1
00405   #define SHUT_RDWR 2
00406 #endif
00407 
00408 /* FD_SET used for lwip_select */
00409 #ifndef FD_SET
00410 #undef  FD_SETSIZE
00411 /* Make FD_SETSIZE match NUM_SOCKETS in socket.c */
00412 #define FD_SETSIZE    MEMP_NUM_NETCONN
00413 #define FDSETSAFESET(n, code) do { \
00414   if (((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0)) { \
00415   code; }} while(0)
00416 #define FDSETSAFEGET(n, code) (((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0) ?\
00417   (code) : 0)
00418 #define FD_SET(n, p)  FDSETSAFESET(n, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] |=  (1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
00419 #define FD_CLR(n, p)  FDSETSAFESET(n, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] &= ~(1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
00420 #define FD_ISSET(n,p) FDSETSAFEGET(n, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] &   (1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
00421 #define FD_ZERO(p)    memset((void*)(p), 0, sizeof(*(p)))
00422 
00423 typedef struct fd_set
00424 {
00425   unsigned char fd_bits [(FD_SETSIZE+7)/8];
00426 } fd_set;
00427 
00428 #elif LWIP_SOCKET_OFFSET
00429 #error LWIP_SOCKET_OFFSET does not work with external FD_SET!
00430 #endif /* FD_SET */
00431 
00432 /** LWIP_TIMEVAL_PRIVATE: if you want to use the struct timeval provided
00433  * by your system, set this to 0 and include <sys/time.h> in cc.h */
00434 #ifndef LWIP_TIMEVAL_PRIVATE
00435 #define LWIP_TIMEVAL_PRIVATE 1
00436 #endif
00437 
00438 #if LWIP_TIMEVAL_PRIVATE
00439 struct timeval {
00440   long    tv_sec;         /* seconds */
00441   long    tv_usec;        /* and microseconds */
00442 };
00443 #endif /* LWIP_TIMEVAL_PRIVATE */
00444 
00445 #define lwip_socket_init() /* Compatibility define, no init needed. */
00446 void lwip_socket_thread_init(void); /* LWIP_NETCONN_SEM_PER_THREAD==1: initialize thread-local semaphore */
00447 void lwip_socket_thread_cleanup(void); /* LWIP_NETCONN_SEM_PER_THREAD==1: destroy thread-local semaphore */
00448 
00449 #if LWIP_COMPAT_SOCKETS == 2
00450 /* This helps code parsers/code completion by not having the COMPAT functions as defines */
00451 #define lwip_accept       accept
00452 #define lwip_bind         bind
00453 #define lwip_shutdown     shutdown
00454 #define lwip_getpeername  getpeername
00455 #define lwip_getsockname  getsockname
00456 #define lwip_setsockopt   setsockopt
00457 #define lwip_getsockopt   getsockopt
00458 #define lwip_close        closesocket
00459 #define lwip_connect      connect
00460 #define lwip_listen       listen
00461 #define lwip_recv         recv
00462 #define lwip_recvfrom     recvfrom
00463 #define lwip_send         send
00464 #define lwip_sendmsg      sendmsg
00465 #define lwip_sendto       sendto
00466 #define lwip_socket       socket
00467 #define lwip_select       select
00468 #define lwip_ioctlsocket  ioctl
00469 
00470 #if LWIP_POSIX_SOCKETS_IO_NAMES
00471 #define lwip_read         read
00472 #define lwip_write        write
00473 #define lwip_writev       writev
00474 #undef lwip_close
00475 #define lwip_close        close
00476 #define closesocket(s)    close(s)
00477 #define lwip_fcntl        fcntl
00478 #define lwip_ioctl        ioctl
00479 #endif /* LWIP_POSIX_SOCKETS_IO_NAMES */
00480 #endif /* LWIP_COMPAT_SOCKETS == 2 */
00481 
00482 int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
00483 int lwip_bind(int s, const struct sockaddr *name, socklen_t namelen);
00484 int lwip_shutdown(int s, int how);
00485 int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen);
00486 int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen);
00487 int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen);
00488 int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen);
00489 int lwip_close(int s);
00490 int lwip_connect(int s, const struct sockaddr *name, socklen_t namelen);
00491 int lwip_listen(int s, int backlog);
00492 int lwip_recv(int s, void *mem, size_t len, int flags);
00493 int lwip_read(int s, void *mem, size_t len);
00494 int lwip_recvfrom(int s, void *mem, size_t len, int flags,
00495       struct sockaddr *from, socklen_t *fromlen);
00496 int lwip_send(int s, const void *dataptr, size_t size, int flags);
00497 int lwip_sendmsg(int s, const struct msghdr *message, int flags);
00498 int lwip_sendto(int s, const void *dataptr, size_t size, int flags,
00499     const struct sockaddr *to, socklen_t tolen);
00500 int lwip_socket(int domain, int type, int protocol);
00501 int lwip_write(int s, const void *dataptr, size_t size);
00502 int lwip_writev(int s, const struct iovec *iov, int iovcnt);
00503 int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
00504                 struct timeval *timeout);
00505 int lwip_ioctl(int s, long cmd, void *argp);
00506 int lwip_fcntl(int s, int cmd, int val);
00507 
00508 #if LWIP_COMPAT_SOCKETS
00509 #if LWIP_COMPAT_SOCKETS != 2
00510 /** @ingroup socket */
00511 #define accept(s,addr,addrlen)                    lwip_accept(s,addr,addrlen)
00512 /** @ingroup socket */
00513 #define bind(s,name,namelen)                      lwip_bind(s,name,namelen)
00514 /** @ingroup socket */
00515 #define shutdown(s,how)                           lwip_shutdown(s,how)
00516 /** @ingroup socket */
00517 #define getpeername(s,name,namelen)               lwip_getpeername(s,name,namelen)
00518 /** @ingroup socket */
00519 #define getsockname(s,name,namelen)               lwip_getsockname(s,name,namelen)
00520 /** @ingroup socket */
00521 #define setsockopt(s,level,optname,opval,optlen)  lwip_setsockopt(s,level,optname,opval,optlen)
00522 /** @ingroup socket */
00523 #define getsockopt(s,level,optname,opval,optlen)  lwip_getsockopt(s,level,optname,opval,optlen)
00524 /** @ingroup socket */
00525 #define closesocket(s)                            lwip_close(s)
00526 /** @ingroup socket */
00527 #define connect(s,name,namelen)                   lwip_connect(s,name,namelen)
00528 /** @ingroup socket */
00529 #define listen(s,backlog)                         lwip_listen(s,backlog)
00530 /** @ingroup socket */
00531 #define recv(s,mem,len,flags)                     lwip_recv(s,mem,len,flags)
00532 /** @ingroup socket */
00533 #define recvfrom(s,mem,len,flags,from,fromlen)    lwip_recvfrom(s,mem,len,flags,from,fromlen)
00534 /** @ingroup socket */
00535 #define send(s,dataptr,size,flags)                lwip_send(s,dataptr,size,flags)
00536 /** @ingroup socket */
00537 #define sendmsg(s,message,flags)                  lwip_sendmsg(s,message,flags)
00538 /** @ingroup socket */
00539 #define sendto(s,dataptr,size,flags,to,tolen)     lwip_sendto(s,dataptr,size,flags,to,tolen)
00540 /** @ingroup socket */
00541 #define socket(domain,type,protocol)              lwip_socket(domain,type,protocol)
00542 /** @ingroup socket */
00543 #define select(maxfdp1,readset,writeset,exceptset,timeout)     lwip_select(maxfdp1,readset,writeset,exceptset,timeout)
00544 /** @ingroup socket */
00545 #define ioctlsocket(s,cmd,argp)                   lwip_ioctl(s,cmd,argp)
00546 
00547 #if LWIP_POSIX_SOCKETS_IO_NAMES
00548 /** @ingroup socket */
00549 #define read(s,mem,len)                           lwip_read(s,mem,len)
00550 /** @ingroup socket */
00551 #define write(s,dataptr,len)                      lwip_write(s,dataptr,len)
00552 /** @ingroup socket */
00553 #define writev(s,iov,iovcnt)                      lwip_writev(s,iov,iovcnt)
00554 /** @ingroup socket */
00555 #define close(s)                                  lwip_close(s)
00556 /** @ingroup socket */
00557 #define fcntl(s,cmd,val)                          lwip_fcntl(s,cmd,val)
00558 /** @ingroup socket */
00559 #define ioctl(s,cmd,argp)                         lwip_ioctl(s,cmd,argp)
00560 #endif /* LWIP_POSIX_SOCKETS_IO_NAMES */
00561 #endif /* LWIP_COMPAT_SOCKETS != 2 */
00562 
00563 #if LWIP_IPV4 && LWIP_IPV6
00564 /** @ingroup socket */
00565 #define inet_ntop(af,src,dst,size) \
00566     (((af) == AF_INET6) ? ip6addr_ntoa_r((const ip6_addr_t*)(src),(dst),(size)) \
00567      : (((af) == AF_INET) ? ip4addr_ntoa_r((const ip4_addr_t*)(src),(dst),(size)) : NULL))
00568 /** @ingroup socket */
00569 #define inet_pton(af,src,dst) \
00570     (((af) == AF_INET6) ? ip6addr_aton((src),(ip6_addr_t*)(dst)) \
00571      : (((af) == AF_INET) ? ip4addr_aton((src),(ip4_addr_t*)(dst)) : 0))
00572 #elif LWIP_IPV4 /* LWIP_IPV4 && LWIP_IPV6 */
00573 #define inet_ntop(af,src,dst,size) \
00574     (((af) == AF_INET) ? ip4addr_ntoa_r((const ip4_addr_t*)(src),(dst),(size)) : NULL)
00575 #define inet_pton(af,src,dst) \
00576     (((af) == AF_INET) ? ip4addr_aton((src),(ip4_addr_t*)(dst)) : 0)
00577 #else /* LWIP_IPV4 && LWIP_IPV6 */
00578 #define inet_ntop(af,src,dst,size) \
00579     (((af) == AF_INET6) ? ip6addr_ntoa_r((const ip6_addr_t*)(src),(dst),(size)) : NULL)
00580 #define inet_pton(af,src,dst) \
00581     (((af) == AF_INET6) ? ip6addr_aton((src),(ip6_addr_t*)(dst)) : 0)
00582 #endif /* LWIP_IPV4 && LWIP_IPV6 */
00583 
00584 #endif /* LWIP_COMPAT_SOCKETS */
00585 
00586 #ifdef __cplusplus
00587 }
00588 #endif
00589 
00590 #endif /* LWIP_SOCKET */
00591 
00592 #endif /* LWIP_HDR_SOCKETS_H */