STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
sockets.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25  * OF SUCH DAMAGE.
26  *
27  * This file is part of the lwIP TCP/IP stack.
28  *
29  * Author: Adam Dunkels <adam@sics.se>
30  *
31  */
32 
33 
34 #ifndef LWIP_HDR_SOCKETS_H
35 #define LWIP_HDR_SOCKETS_H
36 
37 #include "lwip/opt.h"
38 
39 #if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */
40 
41 #include <stddef.h> /* for size_t */
42 
43 #include "lwip/ip_addr.h"
44 #include "lwip/err.h"
45 #include "lwip/inet.h"
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 /* If your port already typedef's sa_family_t, define SA_FAMILY_T_DEFINED
52  to prevent this code from redefining it. */
53 #if !defined(sa_family_t) && !defined(SA_FAMILY_T_DEFINED)
54 typedef u8_t sa_family_t;
55 #endif
56 /* If your port already typedef's in_port_t, define IN_PORT_T_DEFINED
57  to prevent this code from redefining it. */
58 #if !defined(in_port_t) && !defined(IN_PORT_T_DEFINED)
59 typedef u16_t in_port_t;
60 #endif
61 
62 #if LWIP_IPV4
63 /* members are in network byte order */
64 struct sockaddr_in {
65  u8_t sin_len;
66  sa_family_t sin_family;
67  in_port_t sin_port;
68  struct in_addr sin_addr;
69 #define SIN_ZERO_LEN 8
70  char sin_zero[SIN_ZERO_LEN];
71 };
72 #endif /* LWIP_IPV4 */
73 
74 #if LWIP_IPV6
75 struct sockaddr_in6 {
76  u8_t sin6_len; /* length of this structure */
77  sa_family_t sin6_family; /* AF_INET6 */
78  in_port_t sin6_port; /* Transport layer port # */
79  u32_t sin6_flowinfo; /* IPv6 flow information */
80  struct in6_addr sin6_addr; /* IPv6 address */
81  u32_t sin6_scope_id; /* Set of interfaces for scope */
82 };
83 #endif /* LWIP_IPV6 */
84 
85 struct sockaddr {
86  u8_t sa_len;
87  sa_family_t sa_family;
88  char sa_data[14];
89 };
90 
91 struct sockaddr_storage {
92  u8_t s2_len;
93  sa_family_t ss_family;
94  char s2_data1[2];
95  u32_t s2_data2[3];
96 #if LWIP_IPV6
97  u32_t s2_data3[3];
98 #endif /* LWIP_IPV6 */
99 };
100 
101 /* If your port already typedef's socklen_t, define SOCKLEN_T_DEFINED
102  to prevent this code from redefining it. */
103 #if !defined(socklen_t) && !defined(SOCKLEN_T_DEFINED)
104 typedef u32_t socklen_t;
105 #endif
106 
107 struct lwip_sock;
108 
109 #if !LWIP_TCPIP_CORE_LOCKING
110 
111 #define LWIP_SETGETSOCKOPT_MAXOPTLEN 16
112 
115 struct lwip_setgetsockopt_data {
117  int s;
119  int level;
121  int optname;
124 #if LWIP_MPU_COMPATIBLE
125  u8_t optval[LWIP_SETGETSOCKOPT_MAXOPTLEN];
126 #else
127  union {
128  void *p;
129  const void *pc;
130  } optval;
131 #endif
132 
133  socklen_t optlen;
135  err_t err;
137  void* completed_sem;
138 };
139 #endif /* !LWIP_TCPIP_CORE_LOCKING */
140 
141 #if !defined(iovec)
142 struct iovec {
143  void *iov_base;
144  size_t iov_len;
145 };
146 #endif
147 
148 struct msghdr {
149  void *msg_name;
150  socklen_t msg_namelen;
151  struct iovec *msg_iov;
152  int msg_iovlen;
153  void *msg_control;
154  socklen_t msg_controllen;
155  int msg_flags;
156 };
157 
158 /* Socket protocol types (TCP/UDP/RAW) */
159 #define SOCK_STREAM 1
160 #define SOCK_DGRAM 2
161 #define SOCK_RAW 3
162 
163 /*
164  * Option flags per-socket. These must match the SOF_ flags in ip.h (checked in init.c)
165  */
166 #define SO_REUSEADDR 0x0004 /* Allow local address reuse */
167 #define SO_KEEPALIVE 0x0008 /* keep connections alive */
168 #define SO_BROADCAST 0x0020 /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */
169 
170 
171 /*
172  * Additional options, not kept in so_options.
173  */
174 #define SO_DEBUG 0x0001 /* Unimplemented: turn on debugging info recording */
175 #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
176 #define SO_DONTROUTE 0x0010 /* Unimplemented: just use interface addresses */
177 #define SO_USELOOPBACK 0x0040 /* Unimplemented: bypass hardware when possible */
178 #define SO_LINGER 0x0080 /* linger on close if data present */
179 #define SO_DONTLINGER ((int)(~SO_LINGER))
180 #define SO_OOBINLINE 0x0100 /* Unimplemented: leave received OOB data in line */
181 #define SO_REUSEPORT 0x0200 /* Unimplemented: allow local address & port reuse */
182 #define SO_SNDBUF 0x1001 /* Unimplemented: send buffer size */
183 #define SO_RCVBUF 0x1002 /* receive buffer size */
184 #define SO_SNDLOWAT 0x1003 /* Unimplemented: send low-water mark */
185 #define SO_RCVLOWAT 0x1004 /* Unimplemented: receive low-water mark */
186 #define SO_SNDTIMEO 0x1005 /* send timeout */
187 #define SO_RCVTIMEO 0x1006 /* receive timeout */
188 #define SO_ERROR 0x1007 /* get error status and clear */
189 #define SO_TYPE 0x1008 /* get socket type */
190 #define SO_CONTIMEO 0x1009 /* Unimplemented: connect timeout */
191 #define SO_NO_CHECK 0x100a /* don't create UDP checksum */
192 
193 
194 /*
195  * Structure used for manipulating linger option.
196  */
197 struct linger {
198  int l_onoff; /* option on/off */
199  int l_linger; /* linger time in seconds */
200 };
201 
202 /*
203  * Level number for (get/set)sockopt() to apply to socket itself.
204  */
205 #define SOL_SOCKET 0xfff /* options for socket level */
206 
207 
208 #define AF_UNSPEC 0
209 #define AF_INET 2
210 #if LWIP_IPV6
211 #define AF_INET6 10
212 #else /* LWIP_IPV6 */
213 #define AF_INET6 AF_UNSPEC
214 #endif /* LWIP_IPV6 */
215 #define PF_INET AF_INET
216 #define PF_INET6 AF_INET6
217 #define PF_UNSPEC AF_UNSPEC
218 
219 #define IPPROTO_IP 0
220 #define IPPROTO_ICMP 1
221 #define IPPROTO_TCP 6
222 #define IPPROTO_UDP 17
223 #if LWIP_IPV6
224 #define IPPROTO_IPV6 41
225 #define IPPROTO_ICMPV6 58
226 #endif /* LWIP_IPV6 */
227 #define IPPROTO_UDPLITE 136
228 #define IPPROTO_RAW 255
229 
230 /* Flags we can use with send and recv. */
231 #define MSG_PEEK 0x01 /* Peeks at an incoming message */
232 #define MSG_WAITALL 0x02 /* Unimplemented: Requests that the function block until the full amount of data requested can be returned */
233 #define MSG_OOB 0x04 /* Unimplemented: Requests out-of-band data. The significance and semantics of out-of-band data are protocol-specific */
234 #define MSG_DONTWAIT 0x08 /* Nonblocking i/o for this operation only */
235 #define MSG_MORE 0x10 /* Sender will send more */
236 
237 
238 /*
239  * Options for level IPPROTO_IP
240  */
241 #define IP_TOS 1
242 #define IP_TTL 2
243 
244 #if LWIP_TCP
245 /*
246  * Options for level IPPROTO_TCP
247  */
248 #define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */
249 #define TCP_KEEPALIVE 0x02 /* send KEEPALIVE probes when idle for pcb->keep_idle milliseconds */
250 #define TCP_KEEPIDLE 0x03 /* set pcb->keep_idle - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt */
251 #define TCP_KEEPINTVL 0x04 /* set pcb->keep_intvl - Use seconds for get/setsockopt */
252 #define TCP_KEEPCNT 0x05 /* set pcb->keep_cnt - Use number of probes sent for get/setsockopt */
253 #endif /* LWIP_TCP */
254 
255 #if LWIP_IPV6
256 /*
257  * Options for level IPPROTO_IPV6
258  */
259 #define IPV6_CHECKSUM 7 /* RFC3542: calculate and insert the ICMPv6 checksum for raw sockets. */
260 #define IPV6_V6ONLY 27 /* RFC3493: boolean control to restrict AF_INET6 sockets to IPv6 communications only. */
261 #endif /* LWIP_IPV6 */
262 
263 #if LWIP_UDP && LWIP_UDPLITE
264 /*
265  * Options for level IPPROTO_UDPLITE
266  */
267 #define UDPLITE_SEND_CSCOV 0x01 /* sender checksum coverage */
268 #define UDPLITE_RECV_CSCOV 0x02 /* minimal receiver checksum coverage */
269 #endif /* LWIP_UDP && LWIP_UDPLITE*/
270 
271 
272 #if LWIP_MULTICAST_TX_OPTIONS
273 /*
274  * Options and types for UDP multicast traffic handling
275  */
276 #define IP_MULTICAST_TTL 5
277 #define IP_MULTICAST_IF 6
278 #define IP_MULTICAST_LOOP 7
279 #endif /* LWIP_MULTICAST_TX_OPTIONS */
280 
281 #if LWIP_IGMP
282 /*
283  * Options and types related to multicast membership
284  */
285 #define IP_ADD_MEMBERSHIP 3
286 #define IP_DROP_MEMBERSHIP 4
287 
288 typedef struct ip_mreq {
289  struct in_addr imr_multiaddr; /* IP multicast address of group */
290  struct in_addr imr_interface; /* local IP address of interface */
291 } ip_mreq;
292 #endif /* LWIP_IGMP */
293 
294 /*
295  * The Type of Service provides an indication of the abstract
296  * parameters of the quality of service desired. These parameters are
297  * to be used to guide the selection of the actual service parameters
298  * when transmitting a datagram through a particular network. Several
299  * networks offer service precedence, which somehow treats high
300  * precedence traffic as more important than other traffic (generally
301  * by accepting only traffic above a certain precedence at time of high
302  * load). The major choice is a three way tradeoff between low-delay,
303  * high-reliability, and high-throughput.
304  * The use of the Delay, Throughput, and Reliability indications may
305  * increase the cost (in some sense) of the service. In many networks
306  * better performance for one of these parameters is coupled with worse
307  * performance on another. Except for very unusual cases at most two
308  * of these three indications should be set.
309  */
310 #define IPTOS_TOS_MASK 0x1E
311 #define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
312 #define IPTOS_LOWDELAY 0x10
313 #define IPTOS_THROUGHPUT 0x08
314 #define IPTOS_RELIABILITY 0x04
315 #define IPTOS_LOWCOST 0x02
316 #define IPTOS_MINCOST IPTOS_LOWCOST
317 
318 /*
319  * The Network Control precedence designation is intended to be used
320  * within a network only. The actual use and control of that
321  * designation is up to each network. The Internetwork Control
322  * designation is intended for use by gateway control originators only.
323  * If the actual use of these precedence designations is of concern to
324  * a particular network, it is the responsibility of that network to
325  * control the access to, and use of, those precedence designations.
326  */
327 #define IPTOS_PREC_MASK 0xe0
328 #define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK)
329 #define IPTOS_PREC_NETCONTROL 0xe0
330 #define IPTOS_PREC_INTERNETCONTROL 0xc0
331 #define IPTOS_PREC_CRITIC_ECP 0xa0
332 #define IPTOS_PREC_FLASHOVERRIDE 0x80
333 #define IPTOS_PREC_FLASH 0x60
334 #define IPTOS_PREC_IMMEDIATE 0x40
335 #define IPTOS_PREC_PRIORITY 0x20
336 #define IPTOS_PREC_ROUTINE 0x00
337 
338 
339 /*
340  * Commands for ioctlsocket(), taken from the BSD file fcntl.h.
341  * lwip_ioctl only supports FIONREAD and FIONBIO, for now
342  *
343  * Ioctl's have the command encoded in the lower word,
344  * and the size of any in or out parameters in the upper
345  * word. The high 2 bits of the upper word are used
346  * to encode the in/out status of the parameter; for now
347  * we restrict parameters to at most 128 bytes.
348  */
349 #if !defined(FIONREAD) || !defined(FIONBIO)
350 #define IOCPARM_MASK 0x7fU /* parameters must be < 128 bytes */
351 #define IOC_VOID 0x20000000UL /* no parameters */
352 #define IOC_OUT 0x40000000UL /* copy out parameters */
353 #define IOC_IN 0x80000000UL /* copy in parameters */
354 #define IOC_INOUT (IOC_IN|IOC_OUT)
355  /* 0x20000000 distinguishes new &
356  old ioctl's */
357 #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
358 
359 #define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
360 
361 #define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
362 #endif /* !defined(FIONREAD) || !defined(FIONBIO) */
363 
364 #ifndef FIONREAD
365 #define FIONREAD _IOR('f', 127, unsigned long) /* get # bytes to read */
366 #endif
367 #ifndef FIONBIO
368 #define FIONBIO _IOW('f', 126, unsigned long) /* set/clear non-blocking i/o */
369 #endif
370 
371 /* Socket I/O Controls: unimplemented */
372 #ifndef SIOCSHIWAT
373 #define SIOCSHIWAT _IOW('s', 0, unsigned long) /* set high watermark */
374 #define SIOCGHIWAT _IOR('s', 1, unsigned long) /* get high watermark */
375 #define SIOCSLOWAT _IOW('s', 2, unsigned long) /* set low watermark */
376 #define SIOCGLOWAT _IOR('s', 3, unsigned long) /* get low watermark */
377 #define SIOCATMARK _IOR('s', 7, unsigned long) /* at oob mark? */
378 #endif
379 
380 /* commands for fnctl */
381 #ifndef F_GETFL
382 #define F_GETFL 3
383 #endif
384 #ifndef F_SETFL
385 #define F_SETFL 4
386 #endif
387 
388 /* File status flags and file access modes for fnctl,
389  these are bits in an int. */
390 #ifndef O_NONBLOCK
391 #define O_NONBLOCK 1 /* nonblocking I/O */
392 #endif
393 #ifndef O_NDELAY
394 #define O_NDELAY 1 /* same as O_NONBLOCK, for compatibility */
395 #endif
396 
397 #ifndef SHUT_RD
398  #define SHUT_RD 0
399  #define SHUT_WR 1
400  #define SHUT_RDWR 2
401 #endif
402 
403 /* FD_SET used for lwip_select */
404 #ifndef FD_SET
405 #undef FD_SETSIZE
406 /* Make FD_SETSIZE match NUM_SOCKETS in socket.c */
407 #define FD_SETSIZE MEMP_NUM_NETCONN
408 #define FDSETSAFESET(n, code) do { \
409  if (((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0)) { \
410  code; }} while(0)
411 #define FDSETSAFEGET(n, code) (((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0) ?\
412  (code) : 0)
413 #define FD_SET(n, p) FDSETSAFESET(n, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] |= (1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
414 #define FD_CLR(n, p) FDSETSAFESET(n, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] &= ~(1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
415 #define FD_ISSET(n,p) FDSETSAFEGET(n, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] & (1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
416 #define FD_ZERO(p) memset((void*)(p), 0, sizeof(*(p)))
417 
418 typedef struct fd_set
419 {
420  unsigned char fd_bits [(FD_SETSIZE+7)/8];
421 } fd_set;
422 
423 #elif LWIP_SOCKET_OFFSET
424 #error LWIP_SOCKET_OFFSET does not work with external FD_SET!
425 #endif /* FD_SET */
426 
429 #ifndef LWIP_TIMEVAL_PRIVATE
430 #define LWIP_TIMEVAL_PRIVATE 1
431 #endif
432 
433 #if LWIP_TIMEVAL_PRIVATE
434 struct timeval {
435  long tv_sec; /* seconds */
436  long tv_usec; /* and microseconds */
437 };
438 #endif /* LWIP_TIMEVAL_PRIVATE */
439 
440 #define lwip_socket_init() /* Compatibility define, no init needed. */
441 void lwip_socket_thread_init(void); /* LWIP_NETCONN_SEM_PER_THREAD==1: initialize thread-local semaphore */
442 void lwip_socket_thread_cleanup(void); /* LWIP_NETCONN_SEM_PER_THREAD==1: destroy thread-local semaphore */
443 
444 #if LWIP_COMPAT_SOCKETS == 2
445 /* This helps code parsers/code completion by not having the COMPAT functions as defines */
446 #define lwip_accept accept
447 #define lwip_bind bind
448 #define lwip_shutdown shutdown
449 #define lwip_getpeername getpeername
450 #define lwip_getsockname getsockname
451 #define lwip_setsockopt setsockopt
452 #define lwip_getsockopt getsockopt
453 #define lwip_close closesocket
454 #define lwip_connect connect
455 #define lwip_listen listen
456 #define lwip_recv recv
457 #define lwip_recvfrom recvfrom
458 #define lwip_send send
459 #define lwip_sendmsg sendmsg
460 #define lwip_sendto sendto
461 #define lwip_socket socket
462 #define lwip_select select
463 #define lwip_ioctlsocket ioctl
464 
465 #if LWIP_POSIX_SOCKETS_IO_NAMES
466 #define lwip_read read
467 #define lwip_write write
468 #define lwip_writev writev
469 #undef lwip_close
470 #define lwip_close close
471 #define closesocket(s) close(s)
472 #define lwip_fcntl fcntl
473 #define lwip_ioctl ioctl
474 #endif /* LWIP_POSIX_SOCKETS_IO_NAMES */
475 #endif /* LWIP_COMPAT_SOCKETS == 2 */
476 
477 int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
478 int lwip_bind(int s, const struct sockaddr *name, socklen_t namelen);
479 int lwip_shutdown(int s, int how);
480 int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen);
481 int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen);
482 int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen);
483 int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen);
484 int lwip_close(int s);
485 int lwip_connect(int s, const struct sockaddr *name, socklen_t namelen);
486 int lwip_listen(int s, int backlog);
487 int lwip_recv(int s, void *mem, size_t len, int flags);
488 int lwip_read(int s, void *mem, size_t len);
489 int lwip_recvfrom(int s, void *mem, size_t len, int flags,
490  struct sockaddr *from, socklen_t *fromlen);
491 int lwip_send(int s, const void *dataptr, size_t size, int flags);
492 int lwip_sendmsg(int s, const struct msghdr *message, int flags);
493 int lwip_sendto(int s, const void *dataptr, size_t size, int flags,
494  const struct sockaddr *to, socklen_t tolen);
495 int lwip_socket(int domain, int type, int protocol);
496 int lwip_write(int s, const void *dataptr, size_t size);
497 int lwip_writev(int s, const struct iovec *iov, int iovcnt);
498 int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
499  struct timeval *timeout);
500 int lwip_ioctl(int s, long cmd, void *argp);
501 int lwip_fcntl(int s, int cmd, int val);
502 
503 #if LWIP_COMPAT_SOCKETS
504 #if LWIP_COMPAT_SOCKETS != 2
505 #define accept(s,addr,addrlen) lwip_accept(s,addr,addrlen)
506 #define bind(s,name,namelen) lwip_bind(s,name,namelen)
507 #define shutdown(s,how) lwip_shutdown(s,how)
508 #define getpeername(s,name,namelen) lwip_getpeername(s,name,namelen)
509 #define getsockname(s,name,namelen) lwip_getsockname(s,name,namelen)
510 #define setsockopt(s,level,optname,opval,optlen) lwip_setsockopt(s,level,optname,opval,optlen)
511 #define getsockopt(s,level,optname,opval,optlen) lwip_getsockopt(s,level,optname,opval,optlen)
512 #define closesocket(s) lwip_close(s)
513 #define connect(s,name,namelen) lwip_connect(s,name,namelen)
514 #define listen(s,backlog) lwip_listen(s,backlog)
515 #define recv(s,mem,len,flags) lwip_recv(s,mem,len,flags)
516 #define recvfrom(s,mem,len,flags,from,fromlen) lwip_recvfrom(s,mem,len,flags,from,fromlen)
517 #define send(s,dataptr,size,flags) lwip_send(s,dataptr,size,flags)
518 #define sendmsg(s,message,flags) lwip_sendmsg(s,message,flags)
519 #define sendto(s,dataptr,size,flags,to,tolen) lwip_sendto(s,dataptr,size,flags,to,tolen)
520 #define socket(domain,type,protocol) lwip_socket(domain,type,protocol)
521 #define select(maxfdp1,readset,writeset,exceptset,timeout) lwip_select(maxfdp1,readset,writeset,exceptset,timeout)
522 #define ioctlsocket(s,cmd,argp) lwip_ioctl(s,cmd,argp)
523 
524 #if LWIP_POSIX_SOCKETS_IO_NAMES
525 #define read(s,mem,len) lwip_read(s,mem,len)
526 #define write(s,dataptr,len) lwip_write(s,dataptr,len)
527 #define writev(s,iov,iovcnt) lwip_writev(s,iov,iovcnt)
528 #define close(s) lwip_close(s)
529 #define fcntl(s,cmd,val) lwip_fcntl(s,cmd,val)
530 #define ioctl(s,cmd,argp) lwip_ioctl(s,cmd,argp)
531 #endif /* LWIP_POSIX_SOCKETS_IO_NAMES */
532 #endif /* LWIP_COMPAT_SOCKETS != 2 */
533 
534 #if LWIP_IPV4 && LWIP_IPV6
535 #define inet_ntop(af,src,dst,size) \
536  (((af) == AF_INET6) ? ip6addr_ntoa_r((const ip6_addr_t*)(src),(dst),(size)) \
537  : (((af) == AF_INET) ? ip4addr_ntoa_r((const ip4_addr_t*)(src),(dst),(size)) : NULL))
538 #define inet_pton(af,src,dst) \
539  (((af) == AF_INET6) ? ip6addr_aton((src),(ip6_addr_t*)(dst)) \
540  : (((af) == AF_INET) ? ip4addr_aton((src),(ip4_addr_t*)(dst)) : 0))
541 #elif LWIP_IPV4 /* LWIP_IPV4 && LWIP_IPV6 */
542 #define inet_ntop(af,src,dst,size) \
543  (((af) == AF_INET) ? ip4addr_ntoa_r((const ip4_addr_t*)(src),(dst),(size)) : NULL)
544 #define inet_pton(af,src,dst) \
545  (((af) == AF_INET) ? ip4addr_aton((src),(ip4_addr_t*)(dst)) : 0)
546 #else /* LWIP_IPV4 && LWIP_IPV6 */
547 #define inet_ntop(af,src,dst,size) \
548  (((af) == AF_INET6) ? ip6addr_ntoa_r((const ip6_addr_t*)(src),(dst),(size)) : NULL)
549 #define inet_pton(af,src,dst) \
550  (((af) == AF_INET6) ? ip6addr_aton((src),(ip6_addr_t*)(dst)) : 0)
551 #endif /* LWIP_IPV4 && LWIP_IPV6 */
552 
553 #endif /* LWIP_COMPAT_SOCKETS */
554 
555 #ifdef __cplusplus
556 }
557 #endif
558 
559 #endif /* LWIP_SOCKET */
560 
561 #endif /* LWIP_HDR_SOCKETS_H */
562 
unsigned long u32_t
Definition: cc.h:42
Definition: inet.h:62
s8_t err_t
Definition: err.h:47
Definition: inet.h:58
unsigned char u8_t
Definition: cc.h:38
Definition: mem.c:179
unsigned short u16_t
Definition: cc.h:40