ReactOS 0.4.16-dev-297-gc569aee
sockets.h
Go to the documentation of this file.
1
6/*
7 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without modification,
11 * are permitted provided that the following conditions are met:
12 *
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.
20 *
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
30 * OF SUCH DAMAGE.
31 *
32 * This file is part of the lwIP TCP/IP stack.
33 *
34 * Author: Adam Dunkels <adam@sics.se>
35 *
36 */
37
38
39#ifndef LWIP_HDR_SOCKETS_H
40#define LWIP_HDR_SOCKETS_H
41
42#include "lwip/opt.h"
43
44#if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */
45
46#if LWIP_SOCKET_EXTERNAL_HEADERS
47#include LWIP_SOCKET_EXTERNAL_HEADER_SOCKETS_H
48#else /* LWIP_SOCKET_EXTERNAL_HEADERS */
49
50#include "lwip/ip_addr.h"
51#include "lwip/netif.h"
52#include "lwip/err.h"
53#include "lwip/inet.h"
54#include "lwip/errno.h"
55
56#include <string.h>
57
58#ifdef __cplusplus
59extern "C" {
60#endif
61
62/* sockaddr and pals include length fields */
63#define LWIP_SOCKET_HAVE_SA_LEN 1
64
65/* If your port already typedef's sa_family_t, define SA_FAMILY_T_DEFINED
66 to prevent this code from redefining it. */
67#if !defined(sa_family_t) && !defined(SA_FAMILY_T_DEFINED)
68typedef u8_t sa_family_t;
69#endif
70/* If your port already typedef's in_port_t, define IN_PORT_T_DEFINED
71 to prevent this code from redefining it. */
72#if !defined(in_port_t) && !defined(IN_PORT_T_DEFINED)
73typedef u16_t in_port_t;
74#endif
75
76#if LWIP_IPV4
77/* members are in network byte order */
78struct sockaddr_in {
79 u8_t sin_len;
80 sa_family_t sin_family;
81 in_port_t sin_port;
82 struct in_addr sin_addr;
83#define SIN_ZERO_LEN 8
84 char sin_zero[SIN_ZERO_LEN];
85};
86#endif /* LWIP_IPV4 */
87
88#if LWIP_IPV6
89struct sockaddr_in6 {
90 u8_t sin6_len; /* length of this structure */
91 sa_family_t sin6_family; /* AF_INET6 */
92 in_port_t sin6_port; /* Transport layer port # */
93 u32_t sin6_flowinfo; /* IPv6 flow information */
94 struct in6_addr sin6_addr; /* IPv6 address */
95 u32_t sin6_scope_id; /* Set of interfaces for scope */
96};
97#endif /* LWIP_IPV6 */
98
99struct sockaddr {
100 u8_t sa_len;
101 sa_family_t sa_family;
102 char sa_data[14];
103};
104
105struct sockaddr_storage {
106 u8_t s2_len;
107 sa_family_t ss_family;
108 char s2_data1[2];
109 u32_t s2_data2[3];
110#if LWIP_IPV6
111 u32_t s2_data3[3];
112#endif /* LWIP_IPV6 */
113};
114
115/* If your port already typedef's socklen_t, define SOCKLEN_T_DEFINED
116 to prevent this code from redefining it. */
117#if !defined(socklen_t) && !defined(SOCKLEN_T_DEFINED)
118typedef u32_t socklen_t;
119#endif
120
121#if !defined IOV_MAX
122#define IOV_MAX 0xFFFF
123#elif IOV_MAX > 0xFFFF
124#error "IOV_MAX larger than supported by LwIP"
125#endif /* IOV_MAX */
126
127#if !defined(iovec)
128struct iovec {
129 void *iov_base;
130 size_t iov_len;
131};
132#endif
133
134typedef int msg_iovlen_t;
135
136struct msghdr {
137 void *msg_name;
139 struct iovec *msg_iov;
140 msg_iovlen_t msg_iovlen;
141 void *msg_control;
143 int msg_flags;
144};
145
146/* struct msghdr->msg_flags bit field values */
147#define MSG_TRUNC 0x04
148#define MSG_CTRUNC 0x08
149
150/* RFC 3542, Section 20: Ancillary Data */
151struct cmsghdr {
152 socklen_t cmsg_len; /* number of bytes, including header */
153 int cmsg_level; /* originating protocol */
154 int cmsg_type; /* protocol-specific type */
155};
156/* Data section follows header and possible padding, typically referred to as
157 unsigned char cmsg_data[]; */
158
159/* cmsg header/data alignment. NOTE: we align to native word size (double word
160size on 16-bit arch) so structures are not placed at an unaligned address.
16116-bit arch needs double word to ensure 32-bit alignment because socklen_t
162could be 32 bits. If we ever have cmsg data with a 64-bit variable, alignment
163will need to increase long long */
164#define ALIGN_H(size) (((size) + sizeof(long) - 1U) & ~(sizeof(long)-1U))
165#define ALIGN_D(size) ALIGN_H(size)
166
167#define CMSG_FIRSTHDR(mhdr) \
168 ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
169 (struct cmsghdr *)(mhdr)->msg_control : \
170 (struct cmsghdr *)NULL)
171
172#define CMSG_NXTHDR(mhdr, cmsg) \
173 (((cmsg) == NULL) ? CMSG_FIRSTHDR(mhdr) : \
174 (((u8_t *)(cmsg) + ALIGN_H((cmsg)->cmsg_len) \
175 + ALIGN_D(sizeof(struct cmsghdr)) > \
176 (u8_t *)((mhdr)->msg_control) + (mhdr)->msg_controllen) ? \
177 (struct cmsghdr *)NULL : \
178 (struct cmsghdr *)((void*)((u8_t *)(cmsg) + \
179 ALIGN_H((cmsg)->cmsg_len)))))
180
181#define CMSG_DATA(cmsg) ((void*)((u8_t *)(cmsg) + \
182 ALIGN_D(sizeof(struct cmsghdr))))
183
184#define CMSG_SPACE(length) (ALIGN_D(sizeof(struct cmsghdr)) + \
185 ALIGN_H(length))
186
187#define CMSG_LEN(length) (ALIGN_D(sizeof(struct cmsghdr)) + \
188 length)
189
190/* Set socket options argument */
191#define IFNAMSIZ NETIF_NAMESIZE
192struct ifreq {
193 char ifr_name[IFNAMSIZ]; /* Interface name */
194};
195
196/* Socket protocol types (TCP/UDP/RAW) */
197#define SOCK_STREAM 1
198#define SOCK_DGRAM 2
199#define SOCK_RAW 3
200
201/*
202 * Option flags per-socket. These must match the SOF_ flags in ip.h (checked in init.c)
203 */
204#define SO_REUSEADDR 0x0004 /* Allow local address reuse */
205#define SO_KEEPALIVE 0x0008 /* keep connections alive */
206#define SO_BROADCAST 0x0020 /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */
207
208
209/*
210 * Additional options, not kept in so_options.
211 */
212#define SO_DEBUG 0x0001 /* Unimplemented: turn on debugging info recording */
213#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
214#define SO_DONTROUTE 0x0010 /* Unimplemented: just use interface addresses */
215#define SO_USELOOPBACK 0x0040 /* Unimplemented: bypass hardware when possible */
216#define SO_LINGER 0x0080 /* linger on close if data present */
217#define SO_DONTLINGER ((int)(~SO_LINGER))
218#define SO_OOBINLINE 0x0100 /* Unimplemented: leave received OOB data in line */
219#define SO_REUSEPORT 0x0200 /* Unimplemented: allow local address & port reuse */
220#define SO_SNDBUF 0x1001 /* Unimplemented: send buffer size */
221#define SO_RCVBUF 0x1002 /* receive buffer size */
222#define SO_SNDLOWAT 0x1003 /* Unimplemented: send low-water mark */
223#define SO_RCVLOWAT 0x1004 /* Unimplemented: receive low-water mark */
224#define SO_SNDTIMEO 0x1005 /* send timeout */
225#define SO_RCVTIMEO 0x1006 /* receive timeout */
226#define SO_ERROR 0x1007 /* get error status and clear */
227#define SO_TYPE 0x1008 /* get socket type */
228#define SO_CONTIMEO 0x1009 /* Unimplemented: connect timeout */
229#define SO_NO_CHECK 0x100a /* don't create UDP checksum */
230#define SO_BINDTODEVICE 0x100b /* bind to device */
231
232/*
233 * Structure used for manipulating linger option.
234 */
235struct linger {
236 int l_onoff; /* option on/off */
237 int l_linger; /* linger time in seconds */
238};
239
240/*
241 * Level number for (get/set)sockopt() to apply to socket itself.
242 */
243#define SOL_SOCKET 0xfff /* options for socket level */
244
245
246#define AF_UNSPEC 0
247#define AF_INET 2
248#if LWIP_IPV6
249#define AF_INET6 10
250#else /* LWIP_IPV6 */
251#define AF_INET6 AF_UNSPEC
252#endif /* LWIP_IPV6 */
253#define PF_INET AF_INET
254#define PF_INET6 AF_INET6
255#define PF_UNSPEC AF_UNSPEC
256
257#define IPPROTO_IP 0
258#define IPPROTO_ICMP 1
259#define IPPROTO_TCP 6
260#define IPPROTO_UDP 17
261#if LWIP_IPV6
262#define IPPROTO_IPV6 41
263#define IPPROTO_ICMPV6 58
264#endif /* LWIP_IPV6 */
265#define IPPROTO_UDPLITE 136
266#define IPPROTO_RAW 255
267
268/* Flags we can use with send and recv. */
269#define MSG_PEEK 0x01 /* Peeks at an incoming message */
270#define MSG_WAITALL 0x02 /* Unimplemented: Requests that the function block until the full amount of data requested can be returned */
271#define MSG_OOB 0x04 /* Unimplemented: Requests out-of-band data. The significance and semantics of out-of-band data are protocol-specific */
272#define MSG_DONTWAIT 0x08 /* Nonblocking i/o for this operation only */
273#define MSG_MORE 0x10 /* Sender will send more */
274#define MSG_NOSIGNAL 0x20 /* Uninmplemented: Requests not to send the SIGPIPE signal if an attempt to send is made on a stream-oriented socket that is no longer connected. */
275
276
277/*
278 * Options for level IPPROTO_IP
279 */
280#define IP_TOS 1
281#define IP_TTL 2
282#define IP_PKTINFO 8
283
284#if LWIP_TCP
285/*
286 * Options for level IPPROTO_TCP
287 */
288#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */
289#define TCP_KEEPALIVE 0x02 /* send KEEPALIVE probes when idle for pcb->keep_idle milliseconds */
290#define TCP_KEEPIDLE 0x03 /* set pcb->keep_idle - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt */
291#define TCP_KEEPINTVL 0x04 /* set pcb->keep_intvl - Use seconds for get/setsockopt */
292#define TCP_KEEPCNT 0x05 /* set pcb->keep_cnt - Use number of probes sent for get/setsockopt */
293#endif /* LWIP_TCP */
294
295#if LWIP_IPV6
296/*
297 * Options for level IPPROTO_IPV6
298 */
299#define IPV6_CHECKSUM 7 /* RFC3542: calculate and insert the ICMPv6 checksum for raw sockets. */
300#define IPV6_V6ONLY 27 /* RFC3493: boolean control to restrict AF_INET6 sockets to IPv6 communications only. */
301#endif /* LWIP_IPV6 */
302
303#if LWIP_UDP && LWIP_UDPLITE
304/*
305 * Options for level IPPROTO_UDPLITE
306 */
307#define UDPLITE_SEND_CSCOV 0x01 /* sender checksum coverage */
308#define UDPLITE_RECV_CSCOV 0x02 /* minimal receiver checksum coverage */
309#endif /* LWIP_UDP && LWIP_UDPLITE*/
310
311
312#if LWIP_MULTICAST_TX_OPTIONS
313/*
314 * Options and types for UDP multicast traffic handling
315 */
316#define IP_MULTICAST_TTL 5
317#define IP_MULTICAST_IF 6
318#define IP_MULTICAST_LOOP 7
319#endif /* LWIP_MULTICAST_TX_OPTIONS */
320
321#if LWIP_IGMP
322/*
323 * Options and types related to multicast membership
324 */
325#define IP_ADD_MEMBERSHIP 3
326#define IP_DROP_MEMBERSHIP 4
327
328typedef struct ip_mreq {
329 struct in_addr imr_multiaddr; /* IP multicast address of group */
330 struct in_addr imr_interface; /* local IP address of interface */
331} ip_mreq;
332#endif /* LWIP_IGMP */
333
334#if LWIP_IPV4
335struct in_pktinfo {
336 unsigned int ipi_ifindex; /* Interface index */
337 struct in_addr ipi_addr; /* Destination (from header) address */
338};
339#endif /* LWIP_IPV4 */
340
341#if LWIP_IPV6_MLD
342/*
343 * Options and types related to IPv6 multicast membership
344 */
345#define IPV6_JOIN_GROUP 12
346#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
347#define IPV6_LEAVE_GROUP 13
348#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
349
350typedef struct ipv6_mreq {
351 struct in6_addr ipv6mr_multiaddr; /* IPv6 multicast addr */
352 unsigned int ipv6mr_interface; /* interface index, or 0 */
353} ipv6_mreq;
354#endif /* LWIP_IPV6_MLD */
355
356/*
357 * The Type of Service provides an indication of the abstract
358 * parameters of the quality of service desired. These parameters are
359 * to be used to guide the selection of the actual service parameters
360 * when transmitting a datagram through a particular network. Several
361 * networks offer service precedence, which somehow treats high
362 * precedence traffic as more important than other traffic (generally
363 * by accepting only traffic above a certain precedence at time of high
364 * load). The major choice is a three way tradeoff between low-delay,
365 * high-reliability, and high-throughput.
366 * The use of the Delay, Throughput, and Reliability indications may
367 * increase the cost (in some sense) of the service. In many networks
368 * better performance for one of these parameters is coupled with worse
369 * performance on another. Except for very unusual cases at most two
370 * of these three indications should be set.
371 */
372#define IPTOS_TOS_MASK 0x1E
373#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
374#define IPTOS_LOWDELAY 0x10
375#define IPTOS_THROUGHPUT 0x08
376#define IPTOS_RELIABILITY 0x04
377#define IPTOS_LOWCOST 0x02
378#define IPTOS_MINCOST IPTOS_LOWCOST
379
380/*
381 * The Network Control precedence designation is intended to be used
382 * within a network only. The actual use and control of that
383 * designation is up to each network. The Internetwork Control
384 * designation is intended for use by gateway control originators only.
385 * If the actual use of these precedence designations is of concern to
386 * a particular network, it is the responsibility of that network to
387 * control the access to, and use of, those precedence designations.
388 */
389#define IPTOS_PREC_MASK 0xe0
390#define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK)
391#define IPTOS_PREC_NETCONTROL 0xe0
392#define IPTOS_PREC_INTERNETCONTROL 0xc0
393#define IPTOS_PREC_CRITIC_ECP 0xa0
394#define IPTOS_PREC_FLASHOVERRIDE 0x80
395#define IPTOS_PREC_FLASH 0x60
396#define IPTOS_PREC_IMMEDIATE 0x40
397#define IPTOS_PREC_PRIORITY 0x20
398#define IPTOS_PREC_ROUTINE 0x00
399
400
401/*
402 * Commands for ioctlsocket(), taken from the BSD file fcntl.h.
403 * lwip_ioctl only supports FIONREAD and FIONBIO, for now
404 *
405 * Ioctl's have the command encoded in the lower word,
406 * and the size of any in or out parameters in the upper
407 * word. The high 2 bits of the upper word are used
408 * to encode the in/out status of the parameter; for now
409 * we restrict parameters to at most 128 bytes.
410 */
411#if !defined(FIONREAD) || !defined(FIONBIO)
412#define IOCPARM_MASK 0x7fUL /* parameters must be < 128 bytes */
413#define IOC_VOID 0x20000000UL /* no parameters */
414#define IOC_OUT 0x40000000UL /* copy out parameters */
415#define IOC_IN 0x80000000UL /* copy in parameters */
416#define IOC_INOUT (IOC_IN|IOC_OUT)
417 /* 0x20000000 distinguishes new &
418 old ioctl's */
419#define _IO(x,y) ((long)(IOC_VOID|((x)<<8)|(y)))
420
421#define _IOR(x,y,t) ((long)(IOC_OUT|((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)))
422
423#define _IOW(x,y,t) ((long)(IOC_IN|((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)))
424#endif /* !defined(FIONREAD) || !defined(FIONBIO) */
425
426#ifndef FIONREAD
427#define FIONREAD _IOR('f', 127, unsigned long) /* get # bytes to read */
428#endif
429#ifndef FIONBIO
430#define FIONBIO _IOW('f', 126, unsigned long) /* set/clear non-blocking i/o */
431#endif
432
433/* Socket I/O Controls: unimplemented */
434#ifndef SIOCSHIWAT
435#define SIOCSHIWAT _IOW('s', 0, unsigned long) /* set high watermark */
436#define SIOCGHIWAT _IOR('s', 1, unsigned long) /* get high watermark */
437#define SIOCSLOWAT _IOW('s', 2, unsigned long) /* set low watermark */
438#define SIOCGLOWAT _IOR('s', 3, unsigned long) /* get low watermark */
439#define SIOCATMARK _IOR('s', 7, unsigned long) /* at oob mark? */
440#endif
441
442/* commands for fnctl */
443#ifndef F_GETFL
444#define F_GETFL 3
445#endif
446#ifndef F_SETFL
447#define F_SETFL 4
448#endif
449
450/* File status flags and file access modes for fnctl,
451 these are bits in an int. */
452#ifndef O_NONBLOCK
453#define O_NONBLOCK 1 /* nonblocking I/O */
454#endif
455#ifndef O_NDELAY
456#define O_NDELAY O_NONBLOCK /* same as O_NONBLOCK, for compatibility */
457#endif
458#ifndef O_RDONLY
459#define O_RDONLY 2
460#endif
461#ifndef O_WRONLY
462#define O_WRONLY 4
463#endif
464#ifndef O_RDWR
465#define O_RDWR (O_RDONLY|O_WRONLY)
466#endif
467
468#ifndef SHUT_RD
469 #define SHUT_RD 0
470 #define SHUT_WR 1
471 #define SHUT_RDWR 2
472#endif
473
474/* FD_SET used for lwip_select */
475#ifndef FD_SET
476#undef FD_SETSIZE
477/* Make FD_SETSIZE match NUM_SOCKETS in socket.c */
478#define FD_SETSIZE MEMP_NUM_NETCONN
479#define LWIP_SELECT_MAXNFDS (FD_SETSIZE + LWIP_SOCKET_OFFSET)
480#define FDSETSAFESET(n, code) do { \
481 if (((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0)) { \
482 code; }} while(0)
483#define FDSETSAFEGET(n, code) (((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0) ?\
484 (code) : 0)
485#define FD_SET(n, p) FDSETSAFESET(n, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] = (u8_t)((p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] | (1 << (((n)-LWIP_SOCKET_OFFSET) & 7))))
486#define FD_CLR(n, p) FDSETSAFESET(n, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] = (u8_t)((p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] & ~(1 << (((n)-LWIP_SOCKET_OFFSET) & 7))))
487#define FD_ISSET(n,p) FDSETSAFEGET(n, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] & (1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
488#define FD_ZERO(p) memset((void*)(p), 0, sizeof(*(p)))
489
490typedef struct fd_set
491{
492 unsigned char fd_bits [(FD_SETSIZE+7)/8];
493} fd_set;
494
495#elif FD_SETSIZE < (LWIP_SOCKET_OFFSET + MEMP_NUM_NETCONN)
496#error "external FD_SETSIZE too small for number of sockets"
497#else
498#define LWIP_SELECT_MAXNFDS FD_SETSIZE
499#endif /* FD_SET */
500
501/* poll-related defines and types */
502/* @todo: find a better way to guard the definition of these defines and types if already defined */
503#if !defined(POLLIN) && !defined(POLLOUT)
504#define POLLIN 0x1
505#define POLLOUT 0x2
506#define POLLERR 0x4
507#define POLLNVAL 0x8
508/* Below values are unimplemented */
509#define POLLRDNORM 0x10
510#define POLLRDBAND 0x20
511#define POLLPRI 0x40
512#define POLLWRNORM 0x80
513#define POLLWRBAND 0x100
514#define POLLHUP 0x200
515typedef unsigned int nfds_t;
516struct pollfd
517{
518 int fd;
519 short events;
520 short revents;
521};
522#endif
523
526#ifndef LWIP_TIMEVAL_PRIVATE
527#define LWIP_TIMEVAL_PRIVATE 1
528#endif
529
530#if LWIP_TIMEVAL_PRIVATE
531struct timeval {
532 long tv_sec; /* seconds */
533 long tv_usec; /* and microseconds */
534};
535#endif /* LWIP_TIMEVAL_PRIVATE */
536
537#ifdef __cplusplus
538}
539#endif
540
541#endif /* LWIP_SOCKET_EXTERNAL_HEADERS */
542
543#ifdef __cplusplus
544extern "C" {
545#endif
546
547#define lwip_socket_init() /* Compatibility define, no init needed. */
548void lwip_socket_thread_init(void); /* LWIP_NETCONN_SEM_PER_THREAD==1: initialize thread-local semaphore */
549void lwip_socket_thread_cleanup(void); /* LWIP_NETCONN_SEM_PER_THREAD==1: destroy thread-local semaphore */
550
551#if LWIP_COMPAT_SOCKETS == 2
552/* This helps code parsers/code completion by not having the COMPAT functions as defines */
553#define lwip_accept accept
554#define lwip_bind bind
555#define lwip_shutdown shutdown
556#define lwip_getpeername getpeername
557#define lwip_getsockname getsockname
558#define lwip_setsockopt setsockopt
559#define lwip_getsockopt getsockopt
560#define lwip_close closesocket
561#define lwip_connect connect
562#define lwip_listen listen
563#define lwip_recv recv
564#define lwip_recvmsg recvmsg
565#define lwip_recvfrom recvfrom
566#define lwip_send send
567#define lwip_sendmsg sendmsg
568#define lwip_sendto sendto
569#define lwip_socket socket
570#if LWIP_SOCKET_SELECT
571#define lwip_select select
572#endif
573#if LWIP_SOCKET_POLL
574#define lwip_poll poll
575#endif
576#define lwip_ioctl ioctlsocket
577#define lwip_inet_ntop inet_ntop
578#define lwip_inet_pton inet_pton
579
580#if LWIP_POSIX_SOCKETS_IO_NAMES
581#define lwip_read read
582#define lwip_readv readv
583#define lwip_write write
584#define lwip_writev writev
585#undef lwip_close
586#define lwip_close close
587#define closesocket(s) close(s)
588int fcntl(int s, int cmd, ...);
589#undef lwip_ioctl
590#define lwip_ioctl ioctl
591#define ioctlsocket ioctl
592#endif /* LWIP_POSIX_SOCKETS_IO_NAMES */
593#endif /* LWIP_COMPAT_SOCKETS == 2 */
594
595int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
596int lwip_bind(int s, const struct sockaddr *name, socklen_t namelen);
597int lwip_shutdown(int s, int how);
598int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen);
599int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen);
600int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen);
601int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen);
602 int lwip_close(int s);
603int lwip_connect(int s, const struct sockaddr *name, socklen_t namelen);
604int lwip_listen(int s, int backlog);
605ssize_t lwip_recv(int s, void *mem, size_t len, int flags);
606ssize_t lwip_read(int s, void *mem, size_t len);
607ssize_t lwip_readv(int s, const struct iovec *iov, int iovcnt);
608ssize_t lwip_recvfrom(int s, void *mem, size_t len, int flags,
609 struct sockaddr *from, socklen_t *fromlen);
610ssize_t lwip_recvmsg(int s, struct msghdr *message, int flags);
611ssize_t lwip_send(int s, const void *dataptr, size_t size, int flags);
612ssize_t lwip_sendmsg(int s, const struct msghdr *message, int flags);
613ssize_t lwip_sendto(int s, const void *dataptr, size_t size, int flags,
614 const struct sockaddr *to, socklen_t tolen);
615int lwip_socket(int domain, int type, int protocol);
616ssize_t lwip_write(int s, const void *dataptr, size_t size);
617ssize_t lwip_writev(int s, const struct iovec *iov, int iovcnt);
618#if LWIP_SOCKET_SELECT
619int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
620 struct timeval *timeout);
621#endif
622#if LWIP_SOCKET_POLL
623int lwip_poll(struct pollfd *fds, nfds_t nfds, int timeout);
624#endif
625int lwip_ioctl(int s, long cmd, void *argp);
626int lwip_fcntl(int s, int cmd, int val);
627const char *lwip_inet_ntop(int af, const void *src, char *dst, socklen_t size);
628int lwip_inet_pton(int af, const char *src, void *dst);
629
630#if LWIP_COMPAT_SOCKETS
631#if LWIP_COMPAT_SOCKETS != 2
633#define accept(s,addr,addrlen) lwip_accept(s,addr,addrlen)
635#define bind(s,name,namelen) lwip_bind(s,name,namelen)
637#define shutdown(s,how) lwip_shutdown(s,how)
639#define getpeername(s,name,namelen) lwip_getpeername(s,name,namelen)
641#define getsockname(s,name,namelen) lwip_getsockname(s,name,namelen)
643#define setsockopt(s,level,optname,opval,optlen) lwip_setsockopt(s,level,optname,opval,optlen)
645#define getsockopt(s,level,optname,opval,optlen) lwip_getsockopt(s,level,optname,opval,optlen)
647#define closesocket(s) lwip_close(s)
649#define connect(s,name,namelen) lwip_connect(s,name,namelen)
651#define listen(s,backlog) lwip_listen(s,backlog)
653#define recv(s,mem,len,flags) lwip_recv(s,mem,len,flags)
655#define recvmsg(s,message,flags) lwip_recvmsg(s,message,flags)
657#define recvfrom(s,mem,len,flags,from,fromlen) lwip_recvfrom(s,mem,len,flags,from,fromlen)
659#define send(s,dataptr,size,flags) lwip_send(s,dataptr,size,flags)
661#define sendmsg(s,message,flags) lwip_sendmsg(s,message,flags)
663#define sendto(s,dataptr,size,flags,to,tolen) lwip_sendto(s,dataptr,size,flags,to,tolen)
665#define socket(domain,type,protocol) lwip_socket(domain,type,protocol)
666#if LWIP_SOCKET_SELECT
668#define select(maxfdp1,readset,writeset,exceptset,timeout) lwip_select(maxfdp1,readset,writeset,exceptset,timeout)
669#endif
670#if LWIP_SOCKET_POLL
672#define poll(fds,nfds,timeout) lwip_poll(fds,nfds,timeout)
673#endif
675#define ioctlsocket(s,cmd,argp) lwip_ioctl(s,cmd,argp)
677#define inet_ntop(af,src,dst,size) lwip_inet_ntop(af,src,dst,size)
679#define inet_pton(af,src,dst) lwip_inet_pton(af,src,dst)
680
681#if LWIP_POSIX_SOCKETS_IO_NAMES
683#define read(s,mem,len) lwip_read(s,mem,len)
685#define readv(s,iov,iovcnt) lwip_readv(s,iov,iovcnt)
687#define write(s,dataptr,len) lwip_write(s,dataptr,len)
689#define writev(s,iov,iovcnt) lwip_writev(s,iov,iovcnt)
691#define close(s) lwip_close(s)
693#define fcntl(s,cmd,val) lwip_fcntl(s,cmd,val)
695#define ioctl(s,cmd,argp) lwip_ioctl(s,cmd,argp)
696#endif /* LWIP_POSIX_SOCKETS_IO_NAMES */
697#endif /* LWIP_COMPAT_SOCKETS != 2 */
698
699#endif /* LWIP_COMPAT_SOCKETS */
700
701#ifdef __cplusplus
702}
703#endif
704
705#endif /* LWIP_SOCKET */
706
707#endif /* LWIP_HDR_SOCKETS_H */
#define IFNAMSIZ
Definition: dhcpd.h:48
GLint level
Definition: gl.h:1546
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
GLsizeiptr size
Definition: glext.h:5919
GLenum src
Definition: glext.h:6340
GLint namelen
Definition: glext.h:7232
GLenum GLenum dst
Definition: glext.h:6340
GLbitfield flags
Definition: glext.h:7161
GLenum const GLvoid * addr
Definition: glext.h:9621
GLuint GLfloat * val
Definition: glext.h:7180
GLenum GLsizei len
Definition: glext.h:6722
uint32_t u32_t
Definition: arch.h:129
uint8_t u8_t
Definition: arch.h:125
uint16_t u16_t
Definition: arch.h:127
int const JOCTET * dataptr
Definition: jpeglib.h:1031
int socklen_t
Definition: tcp.c:35
int ssize_t
Definition: rosdhcp.h:48
CardRegion * from
Definition: spigame.cpp:19
Definition: ftp_var.h:139
Definition: cookie.c:42
Definition: winsock.h:66
Definition: inet.h:67
Definition: tcpip.h:126
ULONG ipi_ifindex
Definition: ws2ipdef.h:579
IN_ADDR ipi_addr
Definition: ws2ipdef.h:578
Definition: linux.h:1700
void * iov_base
Definition: linux.h:1701
__kernel_size_t iov_len
Definition: linux.h:1702
struct in_addr imr_interface
Definition: winsock.h:536
struct in_addr imr_multiaddr
Definition: winsock.h:535
ULONG ipv6mr_interface
Definition: ws2ipdef.h:547
IN6_ADDR ipv6mr_multiaddr
Definition: ws2ipdef.h:546
u_short l_onoff
Definition: winsock.h:142
u_short l_linger
Definition: winsock.h:143
Definition: mem.c:349
Definition: tftpd.h:60
struct iovec * msg_iov
Definition: tcpcore.h:1197
void * msg_name
Definition: tcpcore.h:1195
__kernel_size_t msg_controllen
Definition: tcpcore.h:1200
int msg_namelen
Definition: tcpcore.h:1196
unsigned msg_flags
Definition: tcpcore.h:1201
__kernel_size_t msg_iovlen
Definition: tcpcore.h:1198
void * msg_control
Definition: tcpcore.h:1199
Definition: name.c:39
Definition: linux.h:1867
int fd
Definition: linux.h:1868
short revents
Definition: linux.h:1870
short events
Definition: linux.h:1869
ULONG sin6_flowinfo
Definition: ws2ipdef.h:181
ULONG sin6_scope_id
Definition: ws2ipdef.h:184
ADDRESS_FAMILY sin6_family
Definition: ws2ipdef.h:179
IN6_ADDR sin6_addr
Definition: ws2ipdef.h:182
USHORT sin6_port
Definition: ws2ipdef.h:180
char sin_zero[8]
Definition: winsock.h:513
struct in_addr sin_addr
Definition: winsock.h:512
short sin_family
Definition: winsock.h:510
u_short sin_port
Definition: winsock.h:511
ADDRESS_FAMILY ss_family
Definition: ws2def.h:400
u_short sa_family
Definition: winsock.h:217
char sa_data[14]
Definition: winsock.h:218
Definition: dhcpd.h:245
unsigned long tv_sec
Definition: linux.h:1738
unsigned long tv_usec
Definition: linux.h:1739
#define FD_SETSIZE
Definition: winsock2.h:75