3 * Socket API (to be used from non-TCPIP threads)
7 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
10 * Redistribution and use in source and binary forms, with or without modification,
11 * are permitted provided that the following conditions are met:
13 * 1. Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * 3. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
22 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
24 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
26 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
32 * This file is part of the lwIP TCP/IP stack.
34 * Author: Adam Dunkels <adam@sics.se>
39 #ifndef LWIP_HDR_SOCKETS_H
40 #define LWIP_HDR_SOCKETS_H
44 #if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */
46 #include "lwip/ip_addr.h"
48 #include "lwip/inet.h"
49 #include "lwip/errno.h"
55 /* If your port already typedef's sa_family_t, define SA_FAMILY_T_DEFINED
56 to prevent this code from redefining it. */
57 #if !defined(sa_family_t) && !defined(SA_FAMILY_T_DEFINED)
58 typedef u8_t sa_family_t;
60 /* If your port already typedef's in_port_t, define IN_PORT_T_DEFINED
61 to prevent this code from redefining it. */
62 #if !defined(in_port_t) && !defined(IN_PORT_T_DEFINED)
63 typedef u16_t in_port_t;
67 /* members are in network byte order */
70 sa_family_t sin_family;
72 struct in_addr sin_addr;
73 #define SIN_ZERO_LEN 8
74 char sin_zero[SIN_ZERO_LEN];
76 #endif /* LWIP_IPV4 */
80 u8_t sin6_len; /* length of this structure */
81 sa_family_t sin6_family; /* AF_INET6 */
82 in_port_t sin6_port; /* Transport layer port # */
83 u32_t sin6_flowinfo; /* IPv6 flow information */
84 struct in6_addr sin6_addr; /* IPv6 address */
85 u32_t sin6_scope_id; /* Set of interfaces for scope */
87 #endif /* LWIP_IPV6 */
91 sa_family_t sa_family;
95 struct sockaddr_storage {
97 sa_family_t ss_family;
102 #endif /* LWIP_IPV6 */
105 /* If your port already typedef's socklen_t, define SOCKLEN_T_DEFINED
106 to prevent this code from redefining it. */
107 #if !defined(socklen_t) && !defined(SOCKLEN_T_DEFINED)
108 typedef u32_t socklen_t;
113 #if !LWIP_TCPIP_CORE_LOCKING
114 /** Maximum optlen used by setsockopt/getsockopt */
115 #define LWIP_SETGETSOCKOPT_MAXOPTLEN 16
117 /** This struct is used to pass data to the set/getsockopt_internal
118 * functions running in tcpip_thread context (only a void* is allowed) */
119 struct lwip_setgetsockopt_data {
120 /** socket index for which to change options */
122 /** level of the option to process */
124 /** name of the option to process */
126 /** set: value to set the option to
127 * get: value of the option is stored here */
128 #if LWIP_MPU_COMPATIBLE
129 u8_t optval[LWIP_SETGETSOCKOPT_MAXOPTLEN];
136 /** size of *optval */
138 /** if an error occurs, it is temporarily stored here */
140 /** semaphore to wake up the calling task */
143 #endif /* !LWIP_TCPIP_CORE_LOCKING */
154 socklen_t msg_namelen;
155 struct iovec *msg_iov;
158 socklen_t msg_controllen;
162 /* Socket protocol types (TCP/UDP/RAW) */
163 #define SOCK_STREAM 1
168 * Option flags per-socket. These must match the SOF_ flags in ip.h (checked in init.c)
170 #define SO_REUSEADDR 0x0004 /* Allow local address reuse */
171 #define SO_KEEPALIVE 0x0008 /* keep connections alive */
172 #define SO_BROADCAST 0x0020 /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */
176 * Additional options, not kept in so_options.
178 #define SO_DEBUG 0x0001 /* Unimplemented: turn on debugging info recording */
179 #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
180 #define SO_DONTROUTE 0x0010 /* Unimplemented: just use interface addresses */
181 #define SO_USELOOPBACK 0x0040 /* Unimplemented: bypass hardware when possible */
182 #define SO_LINGER 0x0080 /* linger on close if data present */
183 #define SO_DONTLINGER ((int)(~SO_LINGER))
184 #define SO_OOBINLINE 0x0100 /* Unimplemented: leave received OOB data in line */
185 #define SO_REUSEPORT 0x0200 /* Unimplemented: allow local address & port reuse */
186 #define SO_SNDBUF 0x1001 /* Unimplemented: send buffer size */
187 #define SO_RCVBUF 0x1002 /* receive buffer size */
188 #define SO_SNDLOWAT 0x1003 /* Unimplemented: send low-water mark */
189 #define SO_RCVLOWAT 0x1004 /* Unimplemented: receive low-water mark */
190 #define SO_SNDTIMEO 0x1005 /* send timeout */
191 #define SO_RCVTIMEO 0x1006 /* receive timeout */
192 #define SO_ERROR 0x1007 /* get error status and clear */
193 #define SO_TYPE 0x1008 /* get socket type */
194 #define SO_CONTIMEO 0x1009 /* Unimplemented: connect timeout */
195 #define SO_NO_CHECK 0x100a /* don't create UDP checksum */
199 * Structure used for manipulating linger option.
202 int l_onoff; /* option on/off */
203 int l_linger; /* linger time in seconds */
207 * Level number for (get/set)sockopt() to apply to socket itself.
209 #define SOL_SOCKET 0xfff /* options for socket level */
216 #else /* LWIP_IPV6 */
217 #define AF_INET6 AF_UNSPEC
218 #endif /* LWIP_IPV6 */
219 #define PF_INET AF_INET
220 #define PF_INET6 AF_INET6
221 #define PF_UNSPEC AF_UNSPEC
224 #define IPPROTO_ICMP 1
225 #define IPPROTO_TCP 6
226 #define IPPROTO_UDP 17
228 #define IPPROTO_IPV6 41
229 #define IPPROTO_ICMPV6 58
230 #endif /* LWIP_IPV6 */
231 #define IPPROTO_UDPLITE 136
232 #define IPPROTO_RAW 255
234 /* Flags we can use with send and recv. */
235 #define MSG_PEEK 0x01 /* Peeks at an incoming message */
236 #define MSG_WAITALL 0x02 /* Unimplemented: Requests that the function block until the full amount of data requested can be returned */
237 #define MSG_OOB 0x04 /* Unimplemented: Requests out-of-band data. The significance and semantics of out-of-band data are protocol-specific */
238 #define MSG_DONTWAIT 0x08 /* Nonblocking i/o for this operation only */
239 #define MSG_MORE 0x10 /* Sender will send more */
243 * Options for level IPPROTO_IP
250 * Options for level IPPROTO_TCP
252 #define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */
253 #define TCP_KEEPALIVE 0x02 /* send KEEPALIVE probes when idle for pcb->keep_idle milliseconds */
254 #define TCP_KEEPIDLE 0x03 /* set pcb->keep_idle - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt */
255 #define TCP_KEEPINTVL 0x04 /* set pcb->keep_intvl - Use seconds for get/setsockopt */
256 #define TCP_KEEPCNT 0x05 /* set pcb->keep_cnt - Use number of probes sent for get/setsockopt */
257 #endif /* LWIP_TCP */
261 * Options for level IPPROTO_IPV6
263 #define IPV6_CHECKSUM 7 /* RFC3542: calculate and insert the ICMPv6 checksum for raw sockets. */
264 #define IPV6_V6ONLY 27 /* RFC3493: boolean control to restrict AF_INET6 sockets to IPv6 communications only. */
265 #endif /* LWIP_IPV6 */
267 #if LWIP_UDP && LWIP_UDPLITE
269 * Options for level IPPROTO_UDPLITE
271 #define UDPLITE_SEND_CSCOV 0x01 /* sender checksum coverage */
272 #define UDPLITE_RECV_CSCOV 0x02 /* minimal receiver checksum coverage */
273 #endif /* LWIP_UDP && LWIP_UDPLITE*/
276 #if LWIP_MULTICAST_TX_OPTIONS
278 * Options and types for UDP multicast traffic handling
280 #define IP_MULTICAST_TTL 5
281 #define IP_MULTICAST_IF 6
282 #define IP_MULTICAST_LOOP 7
283 #endif /* LWIP_MULTICAST_TX_OPTIONS */
287 * Options and types related to multicast membership
289 #define IP_ADD_MEMBERSHIP 3
290 #define IP_DROP_MEMBERSHIP 4
292 typedef struct ip_mreq {
293 struct in_addr imr_multiaddr; /* IP multicast address of group */
294 struct in_addr imr_interface; /* local IP address of interface */
296 #endif /* LWIP_IGMP */
299 * The Type of Service provides an indication of the abstract
300 * parameters of the quality of service desired. These parameters are
301 * to be used to guide the selection of the actual service parameters
302 * when transmitting a datagram through a particular network. Several
303 * networks offer service precedence, which somehow treats high
304 * precedence traffic as more important than other traffic (generally
305 * by accepting only traffic above a certain precedence at time of high
306 * load). The major choice is a three way tradeoff between low-delay,
307 * high-reliability, and high-throughput.
308 * The use of the Delay, Throughput, and Reliability indications may
309 * increase the cost (in some sense) of the service. In many networks
310 * better performance for one of these parameters is coupled with worse
311 * performance on another. Except for very unusual cases at most two
312 * of these three indications should be set.
314 #define IPTOS_TOS_MASK 0x1E
315 #define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
316 #define IPTOS_LOWDELAY 0x10
317 #define IPTOS_THROUGHPUT 0x08
318 #define IPTOS_RELIABILITY 0x04
319 #define IPTOS_LOWCOST 0x02
320 #define IPTOS_MINCOST IPTOS_LOWCOST
323 * The Network Control precedence designation is intended to be used
324 * within a network only. The actual use and control of that
325 * designation is up to each network. The Internetwork Control
326 * designation is intended for use by gateway control originators only.
327 * If the actual use of these precedence designations is of concern to
328 * a particular network, it is the responsibility of that network to
329 * control the access to, and use of, those precedence designations.
331 #define IPTOS_PREC_MASK 0xe0
332 #define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK)
333 #define IPTOS_PREC_NETCONTROL 0xe0
334 #define IPTOS_PREC_INTERNETCONTROL 0xc0
335 #define IPTOS_PREC_CRITIC_ECP 0xa0
336 #define IPTOS_PREC_FLASHOVERRIDE 0x80
337 #define IPTOS_PREC_FLASH 0x60
338 #define IPTOS_PREC_IMMEDIATE 0x40
339 #define IPTOS_PREC_PRIORITY 0x20
340 #define IPTOS_PREC_ROUTINE 0x00
344 * Commands for ioctlsocket(), taken from the BSD file fcntl.h.
345 * lwip_ioctl only supports FIONREAD and FIONBIO, for now
347 * Ioctl's have the command encoded in the lower word,
348 * and the size of any in or out parameters in the upper
349 * word. The high 2 bits of the upper word are used
350 * to encode the in/out status of the parameter; for now
351 * we restrict parameters to at most 128 bytes.
353 #if !defined(FIONREAD) || !defined(FIONBIO)
354 #define IOCPARM_MASK 0x7fU /* parameters must be < 128 bytes */
355 #define IOC_VOID 0x20000000UL /* no parameters */
356 #define IOC_OUT 0x40000000UL /* copy out parameters */
357 #define IOC_IN 0x80000000UL /* copy in parameters */
358 #define IOC_INOUT (IOC_IN|IOC_OUT)
359 /* 0x20000000 distinguishes new &
361 #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
363 #define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
365 #define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
366 #endif /* !defined(FIONREAD) || !defined(FIONBIO) */
369 #define FIONREAD _IOR('f', 127, unsigned long) /* get # bytes to read */
372 #define FIONBIO _IOW('f', 126, unsigned long) /* set/clear non-blocking i/o */
375 /* Socket I/O Controls: unimplemented */
377 #define SIOCSHIWAT _IOW('s', 0, unsigned long) /* set high watermark */
378 #define SIOCGHIWAT _IOR('s', 1, unsigned long) /* get high watermark */
379 #define SIOCSLOWAT _IOW('s', 2, unsigned long) /* set low watermark */
380 #define SIOCGLOWAT _IOR('s', 3, unsigned long) /* get low watermark */
381 #define SIOCATMARK _IOR('s', 7, unsigned long) /* at oob mark? */
384 /* commands for fnctl */
392 /* File status flags and file access modes for fnctl,
393 these are bits in an int. */
395 #define O_NONBLOCK 1 /* nonblocking I/O */
398 #define O_NDELAY 1 /* same as O_NONBLOCK, for compatibility */
407 /* FD_SET used for lwip_select */
410 /* Make FD_SETSIZE match NUM_SOCKETS in socket.c */
411 #define FD_SETSIZE MEMP_NUM_NETCONN
412 #define FDSETSAFESET(n, code) do { \
413 if (((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0)) { \
415 #define FDSETSAFEGET(n, code) (((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0) ?\
417 #define FD_SET(n, p) FDSETSAFESET(n, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] |= (1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
418 #define FD_CLR(n, p) FDSETSAFESET(n, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] &= ~(1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
419 #define FD_ISSET(n,p) FDSETSAFEGET(n, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] & (1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
420 #define FD_ZERO(p) memset((void*)(p), 0, sizeof(*(p)))
422 typedef struct fd_set
424 unsigned char fd_bits [(FD_SETSIZE+7)/8];
427 #elif LWIP_SOCKET_OFFSET
428 #error LWIP_SOCKET_OFFSET does not work with external FD_SET!
429 #elif FD_SETSIZE < MEMP_NUM_NETCONN
430 #error "external FD_SETSIZE too small for number of sockets"
433 /** LWIP_TIMEVAL_PRIVATE: if you want to use the struct timeval provided
434 * by your system, set this to 0 and include <sys/time.h> in cc.h */
435 #ifndef LWIP_TIMEVAL_PRIVATE
436 #define LWIP_TIMEVAL_PRIVATE 1
439 #if LWIP_TIMEVAL_PRIVATE
441 long tv_sec; /* seconds */
442 long tv_usec; /* and microseconds */
444 #endif /* LWIP_TIMEVAL_PRIVATE */
446 #define lwip_socket_init() /* Compatibility define, no init needed. */
447 void lwip_socket_thread_init(void); /* LWIP_NETCONN_SEM_PER_THREAD==1: initialize thread-local semaphore */
448 void lwip_socket_thread_cleanup(void); /* LWIP_NETCONN_SEM_PER_THREAD==1: destroy thread-local semaphore */
450 #if LWIP_COMPAT_SOCKETS == 2
451 /* This helps code parsers/code completion by not having the COMPAT functions as defines */
452 #define lwip_accept accept
453 #define lwip_bind bind
454 #define lwip_shutdown shutdown
455 #define lwip_getpeername getpeername
456 #define lwip_getsockname getsockname
457 #define lwip_setsockopt setsockopt
458 #define lwip_getsockopt getsockopt
459 #define lwip_close closesocket
460 #define lwip_connect connect
461 #define lwip_listen listen
462 #define lwip_recv recv
463 #define lwip_recvfrom recvfrom
464 #define lwip_send send
465 #define lwip_sendmsg sendmsg
466 #define lwip_sendto sendto
467 #define lwip_socket socket
468 #define lwip_select select
469 #define lwip_ioctlsocket ioctl
471 #if LWIP_POSIX_SOCKETS_IO_NAMES
472 #define lwip_read read
473 #define lwip_write write
474 #define lwip_writev writev
476 #define lwip_close close
477 #define closesocket(s) close(s)
478 #define lwip_fcntl fcntl
479 #define lwip_ioctl ioctl
480 #endif /* LWIP_POSIX_SOCKETS_IO_NAMES */
481 #endif /* LWIP_COMPAT_SOCKETS == 2 */
483 int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
484 int lwip_bind(int s, const struct sockaddr *name, socklen_t namelen);
485 int lwip_shutdown(int s, int how);
486 int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen);
487 int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen);
488 int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen);
489 int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen);
490 int lwip_close(int s);
491 int lwip_connect(int s, const struct sockaddr *name, socklen_t namelen);
492 int lwip_listen(int s, int backlog);
493 int lwip_recv(int s, void *mem, size_t len, int flags);
494 int lwip_read(int s, void *mem, size_t len);
495 int lwip_recvfrom(int s, void *mem, size_t len, int flags,
496 struct sockaddr *from, socklen_t *fromlen);
497 int lwip_send(int s, const void *dataptr, size_t size, int flags);
498 int lwip_sendmsg(int s, const struct msghdr *message, int flags);
499 int lwip_sendto(int s, const void *dataptr, size_t size, int flags,
500 const struct sockaddr *to, socklen_t tolen);
501 int lwip_socket(int domain, int type, int protocol);
502 int lwip_write(int s, const void *dataptr, size_t size);
503 int lwip_writev(int s, const struct iovec *iov, int iovcnt);
504 int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
505 struct timeval *timeout);
506 int lwip_ioctl(int s, long cmd, void *argp);
507 int lwip_fcntl(int s, int cmd, int val);
509 #if LWIP_COMPAT_SOCKETS
510 #if LWIP_COMPAT_SOCKETS != 2
511 /** @ingroup socket */
512 #define accept(s,addr,addrlen) lwip_accept(s,addr,addrlen)
513 /** @ingroup socket */
514 #define bind(s,name,namelen) lwip_bind(s,name,namelen)
515 /** @ingroup socket */
516 #define shutdown(s,how) lwip_shutdown(s,how)
517 /** @ingroup socket */
518 #define getpeername(s,name,namelen) lwip_getpeername(s,name,namelen)
519 /** @ingroup socket */
520 #define getsockname(s,name,namelen) lwip_getsockname(s,name,namelen)
521 /** @ingroup socket */
522 #define setsockopt(s,level,optname,opval,optlen) lwip_setsockopt(s,level,optname,opval,optlen)
523 /** @ingroup socket */
524 #define getsockopt(s,level,optname,opval,optlen) lwip_getsockopt(s,level,optname,opval,optlen)
525 /** @ingroup socket */
526 #define closesocket(s) lwip_close(s)
527 /** @ingroup socket */
528 #define connect(s,name,namelen) lwip_connect(s,name,namelen)
529 /** @ingroup socket */
530 #define listen(s,backlog) lwip_listen(s,backlog)
531 /** @ingroup socket */
532 #define recv(s,mem,len,flags) lwip_recv(s,mem,len,flags)
533 /** @ingroup socket */
534 #define recvfrom(s,mem,len,flags,from,fromlen) lwip_recvfrom(s,mem,len,flags,from,fromlen)
535 /** @ingroup socket */
536 #define send(s,dataptr,size,flags) lwip_send(s,dataptr,size,flags)
537 /** @ingroup socket */
538 #define sendmsg(s,message,flags) lwip_sendmsg(s,message,flags)
539 /** @ingroup socket */
540 #define sendto(s,dataptr,size,flags,to,tolen) lwip_sendto(s,dataptr,size,flags,to,tolen)
541 /** @ingroup socket */
542 #define socket(domain,type,protocol) lwip_socket(domain,type,protocol)
543 /** @ingroup socket */
544 #define select(maxfdp1,readset,writeset,exceptset,timeout) lwip_select(maxfdp1,readset,writeset,exceptset,timeout)
545 /** @ingroup socket */
546 #define ioctlsocket(s,cmd,argp) lwip_ioctl(s,cmd,argp)
548 #if LWIP_POSIX_SOCKETS_IO_NAMES
549 /** @ingroup socket */
550 #define read(s,mem,len) lwip_read(s,mem,len)
551 /** @ingroup socket */
552 #define write(s,dataptr,len) lwip_write(s,dataptr,len)
553 /** @ingroup socket */
554 #define writev(s,iov,iovcnt) lwip_writev(s,iov,iovcnt)
555 /** @ingroup socket */
556 #define close(s) lwip_close(s)
557 /** @ingroup socket */
558 #define fcntl(s,cmd,val) lwip_fcntl(s,cmd,val)
559 /** @ingroup socket */
560 #define ioctl(s,cmd,argp) lwip_ioctl(s,cmd,argp)
561 #endif /* LWIP_POSIX_SOCKETS_IO_NAMES */
562 #endif /* LWIP_COMPAT_SOCKETS != 2 */
564 #if LWIP_IPV4 && LWIP_IPV6
565 /** @ingroup socket */
566 #define inet_ntop(af,src,dst,size) \
567 (((af) == AF_INET6) ? ip6addr_ntoa_r((const ip6_addr_t*)(src),(dst),(size)) \
568 : (((af) == AF_INET) ? ip4addr_ntoa_r((const ip4_addr_t*)(src),(dst),(size)) : NULL))
569 /** @ingroup socket */
570 #define inet_pton(af,src,dst) \
571 (((af) == AF_INET6) ? ip6addr_aton((src),(ip6_addr_t*)(dst)) \
572 : (((af) == AF_INET) ? ip4addr_aton((src),(ip4_addr_t*)(dst)) : 0))
573 #elif LWIP_IPV4 /* LWIP_IPV4 && LWIP_IPV6 */
574 #define inet_ntop(af,src,dst,size) \
575 (((af) == AF_INET) ? ip4addr_ntoa_r((const ip4_addr_t*)(src),(dst),(size)) : NULL)
576 #define inet_pton(af,src,dst) \
577 (((af) == AF_INET) ? ip4addr_aton((src),(ip4_addr_t*)(dst)) : 0)
578 #else /* LWIP_IPV4 && LWIP_IPV6 */
579 #define inet_ntop(af,src,dst,size) \
580 (((af) == AF_INET6) ? ip6addr_ntoa_r((const ip6_addr_t*)(src),(dst),(size)) : NULL)
581 #define inet_pton(af,src,dst) \
582 (((af) == AF_INET6) ? ip6addr_aton((src),(ip6_addr_t*)(dst)) : 0)
583 #endif /* LWIP_IPV4 && LWIP_IPV6 */
585 #endif /* LWIP_COMPAT_SOCKETS */
591 #endif /* LWIP_SOCKET */
593 #endif /* LWIP_HDR_SOCKETS_H */