58 #ifndef LWIP_HDR_SOCKETS_H 59 #define LWIP_HDR_SOCKETS_H 76 #if !defined(sa_family_t) && !defined(SA_FAMILY_T_DEFINED) 77 typedef u8_t sa_family_t;
81 #if !defined(in_port_t) && !defined(IN_PORT_T_DEFINED) 82 typedef u16_t in_port_t;
89 sa_family_t sin_family;
92 #define SIN_ZERO_LEN 8 93 char sin_zero[SIN_ZERO_LEN];
100 sa_family_t sin6_family;
110 sa_family_t sa_family;
114 struct sockaddr_storage {
116 sa_family_t ss_family;
126 #if !defined(socklen_t) && !defined(SOCKLEN_T_DEFINED) 127 typedef u32_t socklen_t;
132 #if !LWIP_TCPIP_CORE_LOCKING 134 #define LWIP_SETGETSOCKOPT_MAXOPTLEN 16 138 struct lwip_setgetsockopt_data {
147 #if LWIP_MPU_COMPATIBLE 148 u8_t optval[LWIP_SETGETSOCKOPT_MAXOPTLEN];
173 socklen_t msg_namelen;
174 struct iovec *msg_iov;
177 socklen_t msg_controllen;
182 #define SOCK_STREAM 1 189 #define SO_REUSEADDR 0x0004 190 #define SO_KEEPALIVE 0x0008 191 #define SO_BROADCAST 0x0020 197 #define SO_DEBUG 0x0001 198 #define SO_ACCEPTCONN 0x0002 199 #define SO_DONTROUTE 0x0010 200 #define SO_USELOOPBACK 0x0040 201 #define SO_LINGER 0x0080 202 #define SO_DONTLINGER ((int)(~SO_LINGER)) 203 #define SO_OOBINLINE 0x0100 204 #define SO_REUSEPORT 0x0200 205 #define SO_SNDBUF 0x1001 206 #define SO_RCVBUF 0x1002 207 #define SO_SNDLOWAT 0x1003 208 #define SO_RCVLOWAT 0x1004 209 #define SO_SNDTIMEO 0x1005 210 #define SO_RCVTIMEO 0x1006 211 #define SO_ERROR 0x1007 212 #define SO_TYPE 0x1008 213 #define SO_CONTIMEO 0x1009 214 #define SO_NO_CHECK 0x100a 228 #define SOL_SOCKET 0xfff 236 #define AF_INET6 AF_UNSPEC 238 #define PF_INET AF_INET 239 #define PF_INET6 AF_INET6 240 #define PF_UNSPEC AF_UNSPEC 243 #define IPPROTO_ICMP 1 244 #define IPPROTO_TCP 6 245 #define IPPROTO_UDP 17 247 #define IPPROTO_IPV6 41 248 #define IPPROTO_ICMPV6 58 250 #define IPPROTO_UDPLITE 136 251 #define IPPROTO_RAW 255 254 #define MSG_PEEK 0x01 255 #define MSG_WAITALL 0x02 257 #define MSG_DONTWAIT 0x08 258 #define MSG_MORE 0x10 271 #define TCP_NODELAY 0x01 272 #define TCP_KEEPALIVE 0x02 273 #define TCP_KEEPIDLE 0x03 274 #define TCP_KEEPINTVL 0x04 275 #define TCP_KEEPCNT 0x05 282 #define IPV6_CHECKSUM 7 283 #define IPV6_V6ONLY 27 286 #if LWIP_UDP && LWIP_UDPLITE 290 #define UDPLITE_SEND_CSCOV 0x01 291 #define UDPLITE_RECV_CSCOV 0x02 295 #if LWIP_MULTICAST_TX_OPTIONS 299 #define IP_MULTICAST_TTL 5 300 #define IP_MULTICAST_IF 6 301 #define IP_MULTICAST_LOOP 7 308 #define IP_ADD_MEMBERSHIP 3 309 #define IP_DROP_MEMBERSHIP 4 311 typedef struct ip_mreq {
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 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 372 #if !defined(FIONREAD) || !defined(FIONBIO) 373 #define IOCPARM_MASK 0x7fU 374 #define IOC_VOID 0x20000000UL 375 #define IOC_OUT 0x40000000UL 376 #define IOC_IN 0x80000000UL 377 #define IOC_INOUT (IOC_IN|IOC_OUT) 380 #define _IO(x,y) (IOC_VOID|((x)<<8)|(y)) 382 #define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)) 384 #define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)) 388 #define FIONREAD _IOR('f', 127, unsigned long) 391 #define FIONBIO _IOW('f', 126, unsigned long) 396 #define SIOCSHIWAT _IOW('s', 0, unsigned long) 397 #define SIOCGHIWAT _IOR('s', 1, unsigned long) 398 #define SIOCSLOWAT _IOW('s', 2, unsigned long) 399 #define SIOCGLOWAT _IOR('s', 3, unsigned long) 400 #define SIOCATMARK _IOR('s', 7, unsigned long) 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)) { \ 434 #define FDSETSAFEGET(n, code) (((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 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))) 441 typedef struct fd_set
443 unsigned char fd_bits [(FD_SETSIZE+7)/8];
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" 454 #ifndef LWIP_TIMEVAL_PRIVATE 455 #define LWIP_TIMEVAL_PRIVATE 1 458 #if LWIP_TIMEVAL_PRIVATE 465 #define lwip_socket_init() 466 void lwip_socket_thread_init(
void);
467 void lwip_socket_thread_cleanup(
void);
469 #if LWIP_COMPAT_SOCKETS == 2 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 490 #if LWIP_POSIX_SOCKETS_IO_NAMES 491 #define lwip_read read 492 #define lwip_write write 493 #define lwip_writev writev 495 #define lwip_close close 496 #define closesocket(s) close(s) 497 #define lwip_fcntl fcntl 498 #define lwip_ioctl ioctl 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);
528 #if LWIP_COMPAT_SOCKETS 529 #if LWIP_COMPAT_SOCKETS != 2 531 #define accept(s,addr,addrlen) lwip_accept(s,addr,addrlen) 533 #define bind(s,name,namelen) lwip_bind(s,name,namelen) 535 #define shutdown(s,how) lwip_shutdown(s,how) 537 #define getpeername(s,name,namelen) lwip_getpeername(s,name,namelen) 539 #define getsockname(s,name,namelen) lwip_getsockname(s,name,namelen) 541 #define setsockopt(s,level,optname,opval,optlen) lwip_setsockopt(s,level,optname,opval,optlen) 543 #define getsockopt(s,level,optname,opval,optlen) lwip_getsockopt(s,level,optname,opval,optlen) 545 #define closesocket(s) lwip_close(s) 547 #define connect(s,name,namelen) lwip_connect(s,name,namelen) 549 #define listen(s,backlog) lwip_listen(s,backlog) 551 #define recv(s,mem,len,flags) lwip_recv(s,mem,len,flags) 553 #define recvfrom(s,mem,len,flags,from,fromlen) lwip_recvfrom(s,mem,len,flags,from,fromlen) 555 #define send(s,dataptr,size,flags) lwip_send(s,dataptr,size,flags) 557 #define sendmsg(s,message,flags) lwip_sendmsg(s,message,flags) 559 #define sendto(s,dataptr,size,flags,to,tolen) lwip_sendto(s,dataptr,size,flags,to,tolen) 561 #define socket(domain,type,protocol) lwip_socket(domain,type,protocol) 563 #define select(maxfdp1,readset,writeset,exceptset,timeout) lwip_select(maxfdp1,readset,writeset,exceptset,timeout) 565 #define ioctlsocket(s,cmd,argp) lwip_ioctl(s,cmd,argp) 567 #if LWIP_POSIX_SOCKETS_IO_NAMES 569 #define read(s,mem,len) lwip_read(s,mem,len) 571 #define write(s,dataptr,len) lwip_write(s,dataptr,len) 573 #define writev(s,iov,iovcnt) lwip_writev(s,iov,iovcnt) 575 #define close(s) lwip_close(s) 577 #define fcntl(s,cmd,val) lwip_fcntl(s,cmd,val) 579 #define ioctl(s,cmd,argp) lwip_ioctl(s,cmd,argp) 583 #if LWIP_IPV4 && LWIP_IPV6 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)) 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)) 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) 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)