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