source: azure_iot_hub_f767zi/trunk/asp_baseplatform/lwip/lwip-2.1.2/src/include/lwip/sockets.h

Last change on this file was 457, checked in by coas-nagasima, 4 years ago

ファイルを追加

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