39#ifndef LWIP_HDR_SOCKETS_H
40#define LWIP_HDR_SOCKETS_H
46#if LWIP_SOCKET_EXTERNAL_HEADERS
47#include LWIP_SOCKET_EXTERNAL_HEADER_SOCKETS_H
63#define LWIP_SOCKET_HAVE_SA_LEN 1
67#if !defined(sa_family_t) && !defined(SA_FAMILY_T_DEFINED)
68typedef u8_t sa_family_t;
72#if !defined(in_port_t) && !defined(IN_PORT_T_DEFINED)
73typedef u16_t in_port_t;
117#if !defined(socklen_t) && !defined(SOCKLEN_T_DEFINED)
122#define IOV_MAX 0xFFFF
123#elif IOV_MAX > 0xFFFF
124#error "IOV_MAX larger than supported by LwIP"
134typedef int msg_iovlen_t;
147#define MSG_TRUNC 0x04
148#define MSG_CTRUNC 0x08
164#define ALIGN_H(size) (((size) + sizeof(long) - 1U) & ~(sizeof(long)-1U))
165#define ALIGN_D(size) ALIGN_H(size)
167#define CMSG_FIRSTHDR(mhdr) \
168 ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
169 (struct cmsghdr *)(mhdr)->msg_control : \
170 (struct cmsghdr *)NULL)
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)))))
181#define CMSG_DATA(cmsg) ((void*)((u8_t *)(cmsg) + \
182 ALIGN_D(sizeof(struct cmsghdr))))
184#define CMSG_SPACE(length) (ALIGN_D(sizeof(struct cmsghdr)) + \
187#define CMSG_LEN(length) (ALIGN_D(sizeof(struct cmsghdr)) + \
191#define IFNAMSIZ NETIF_NAMESIZE
204#define SO_REUSEADDR 0x0004
205#define SO_KEEPALIVE 0x0008
206#define SO_BROADCAST 0x0020
212#define SO_DEBUG 0x0001
213#define SO_ACCEPTCONN 0x0002
214#define SO_DONTROUTE 0x0010
215#define SO_USELOOPBACK 0x0040
216#define SO_LINGER 0x0080
217#define SO_DONTLINGER ((int)(~SO_LINGER))
218#define SO_OOBINLINE 0x0100
219#define SO_REUSEPORT 0x0200
220#define SO_SNDBUF 0x1001
221#define SO_RCVBUF 0x1002
222#define SO_SNDLOWAT 0x1003
223#define SO_RCVLOWAT 0x1004
224#define SO_SNDTIMEO 0x1005
225#define SO_RCVTIMEO 0x1006
226#define SO_ERROR 0x1007
227#define SO_TYPE 0x1008
228#define SO_CONTIMEO 0x1009
229#define SO_NO_CHECK 0x100a
230#define SO_BINDTODEVICE 0x100b
243#define SOL_SOCKET 0xfff
251#define AF_INET6 AF_UNSPEC
253#define PF_INET AF_INET
254#define PF_INET6 AF_INET6
255#define PF_UNSPEC AF_UNSPEC
258#define IPPROTO_ICMP 1
260#define IPPROTO_UDP 17
262#define IPPROTO_IPV6 41
263#define IPPROTO_ICMPV6 58
265#define IPPROTO_UDPLITE 136
266#define IPPROTO_RAW 255
270#define MSG_WAITALL 0x02
272#define MSG_DONTWAIT 0x08
274#define MSG_NOSIGNAL 0x20
288#define TCP_NODELAY 0x01
289#define TCP_KEEPALIVE 0x02
290#define TCP_KEEPIDLE 0x03
291#define TCP_KEEPINTVL 0x04
292#define TCP_KEEPCNT 0x05
299#define IPV6_CHECKSUM 7
300#define IPV6_V6ONLY 27
303#if LWIP_UDP && LWIP_UDPLITE
307#define UDPLITE_SEND_CSCOV 0x01
308#define UDPLITE_RECV_CSCOV 0x02
312#if LWIP_MULTICAST_TX_OPTIONS
316#define IP_MULTICAST_TTL 5
317#define IP_MULTICAST_IF 6
318#define IP_MULTICAST_LOOP 7
325#define IP_ADD_MEMBERSHIP 3
326#define IP_DROP_MEMBERSHIP 4
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
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
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
411#if !defined(FIONREAD) || !defined(FIONBIO)
412#define IOCPARM_MASK 0x7fUL
413#define IOC_VOID 0x20000000UL
414#define IOC_OUT 0x40000000UL
415#define IOC_IN 0x80000000UL
416#define IOC_INOUT (IOC_IN|IOC_OUT)
419#define _IO(x,y) ((long)(IOC_VOID|((x)<<8)|(y)))
421#define _IOR(x,y,t) ((long)(IOC_OUT|((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)))
423#define _IOW(x,y,t) ((long)(IOC_IN|((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)))
427#define FIONREAD _IOR('f', 127, unsigned long)
430#define FIONBIO _IOW('f', 126, unsigned long)
435#define SIOCSHIWAT _IOW('s', 0, unsigned long)
436#define SIOCGHIWAT _IOR('s', 1, unsigned long)
437#define SIOCSLOWAT _IOW('s', 2, unsigned long)
438#define SIOCGLOWAT _IOR('s', 3, unsigned long)
439#define SIOCATMARK _IOR('s', 7, unsigned long)
456#define O_NDELAY O_NONBLOCK
465#define O_RDWR (O_RDONLY|O_WRONLY)
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)) { \
483#define FDSETSAFEGET(n, code) (((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 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)))
495#elif FD_SETSIZE < (LWIP_SOCKET_OFFSET + MEMP_NUM_NETCONN)
496#error "external FD_SETSIZE too small for number of sockets"
498#define LWIP_SELECT_MAXNFDS FD_SETSIZE
503#if !defined(POLLIN) && !defined(POLLOUT)
509#define POLLRDNORM 0x10
510#define POLLRDBAND 0x20
512#define POLLWRNORM 0x80
513#define POLLWRBAND 0x100
515typedef unsigned int nfds_t;
526#ifndef LWIP_TIMEVAL_PRIVATE
527#define LWIP_TIMEVAL_PRIVATE 1
530#if LWIP_TIMEVAL_PRIVATE
547#define lwip_socket_init()
548void lwip_socket_thread_init(
void);
549void lwip_socket_thread_cleanup(
void);
551#if LWIP_COMPAT_SOCKETS == 2
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
574#define lwip_poll poll
576#define lwip_ioctl ioctlsocket
577#define lwip_inet_ntop inet_ntop
578#define lwip_inet_pton inet_pton
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
586#define lwip_close close
587#define closesocket(s) close(s)
588int fcntl(
int s,
int cmd, ...);
590#define lwip_ioctl ioctl
591#define ioctlsocket ioctl
597int lwip_shutdown(
int s,
int how);
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);
604int lwip_listen(
int s,
int backlog);
607ssize_t lwip_readv(
int s,
const struct iovec *iov,
int iovcnt);
617ssize_t lwip_writev(
int s,
const struct iovec *iov,
int iovcnt);
618#if LWIP_SOCKET_SELECT
625int lwip_ioctl(
int s,
long cmd,
void *argp);
626int lwip_fcntl(
int s,
int cmd,
int val);
628int lwip_inet_pton(
int af,
const char *
src,
void *
dst);
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)
672#define poll(fds,nfds,timeout) lwip_poll(fds,nfds,timeout)
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)
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)
GLuint GLuint GLsizei GLenum type
GLenum const GLvoid * addr
int const JOCTET * dataptr
struct in_addr imr_interface
struct in_addr imr_multiaddr
IN6_ADDR ipv6mr_multiaddr
__kernel_size_t msg_controllen
__kernel_size_t msg_iovlen
ADDRESS_FAMILY sin6_family