STM32F7 Ethernet interface for nucleo STM32F767

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