34 #ifndef __LWIP_SOCKETS_H__
35 #define __LWIP_SOCKETS_H__
43 #include "lwip/ip_addr.h"
44 #include "lwip/inet.h"
66 # define socklen_t u32_t
77 #define SO_DEBUG 0x0001
78 #define SO_ACCEPTCONN 0x0002
79 #define SO_REUSEADDR 0x0004
80 #define SO_KEEPALIVE 0x0008
81 #define SO_DONTROUTE 0x0010
82 #define SO_BROADCAST 0x0020
83 #define SO_USELOOPBACK 0x0040
84 #define SO_LINGER 0x0080
85 #define SO_OOBINLINE 0x0100
86 #define SO_REUSEPORT 0x0200
88 #define SO_DONTLINGER ((int)(~SO_LINGER))
93 #define SO_SNDBUF 0x1001
94 #define SO_RCVBUF 0x1002
95 #define SO_SNDLOWAT 0x1003
96 #define SO_RCVLOWAT 0x1004
97 #define SO_SNDTIMEO 0x1005
98 #define SO_RCVTIMEO 0x1006
99 #define SO_ERROR 0x1007
100 #define SO_TYPE 0x1008
101 #define SO_CONTIMEO 0x1009
102 #define SO_NO_CHECK 0x100a
116 #define SOL_SOCKET 0xfff
121 #define PF_INET AF_INET
122 #define PF_UNSPEC AF_UNSPEC
125 #define IPPROTO_TCP 6
126 #define IPPROTO_UDP 17
127 #define IPPROTO_UDPLITE 136
130 #define MSG_PEEK 0x01
131 #define MSG_WAITALL 0x02
133 #define MSG_DONTWAIT 0x08
134 #define MSG_MORE 0x10
147 #define TCP_NODELAY 0x01
148 #define TCP_KEEPALIVE 0x02
149 #define TCP_KEEPIDLE 0x03
150 #define TCP_KEEPINTVL 0x04
151 #define TCP_KEEPCNT 0x05
154 #if LWIP_UDP && LWIP_UDPLITE
158 #define UDPLITE_SEND_CSCOV 0x01
159 #define UDPLITE_RECV_CSCOV 0x02
167 #define IP_ADD_MEMBERSHIP 3
168 #define IP_DROP_MEMBERSHIP 4
169 #define IP_MULTICAST_TTL 5
170 #define IP_MULTICAST_IF 6
171 #define IP_MULTICAST_LOOP 7
173 typedef struct ip_mreq {
195 #define IPTOS_TOS_MASK 0x1E
196 #define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
197 #define IPTOS_LOWDELAY 0x10
198 #define IPTOS_THROUGHPUT 0x08
199 #define IPTOS_RELIABILITY 0x04
200 #define IPTOS_LOWCOST 0x02
201 #define IPTOS_MINCOST IPTOS_LOWCOST
212 #define IPTOS_PREC_MASK 0xe0
213 #define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK)
214 #define IPTOS_PREC_NETCONTROL 0xe0
215 #define IPTOS_PREC_INTERNETCONTROL 0xc0
216 #define IPTOS_PREC_CRITIC_ECP 0xa0
217 #define IPTOS_PREC_FLASHOVERRIDE 0x80
218 #define IPTOS_PREC_FLASH 0x60
219 #define IPTOS_PREC_IMMEDIATE 0x40
220 #define IPTOS_PREC_PRIORITY 0x20
221 #define IPTOS_PREC_ROUTINE 0x00
234 #if !defined(FIONREAD) || !defined(FIONBIO)
235 #define IOCPARM_MASK 0x7fU
236 #define IOC_VOID 0x20000000UL
237 #define IOC_OUT 0x40000000UL
238 #define IOC_IN 0x80000000UL
239 #define IOC_INOUT (IOC_IN|IOC_OUT)
242 #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
244 #define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
246 #define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
250 #define FIONREAD _IOR('f', 127, unsigned long)
253 #define FIONBIO _IOW('f', 126, unsigned long)
258 #define SIOCSHIWAT _IOW('s', 0, unsigned long)
259 #define SIOCGHIWAT _IOR('s', 1, unsigned long)
260 #define SIOCSLOWAT _IOW('s', 2, unsigned long)
261 #define SIOCGLOWAT _IOR('s', 3, unsigned long)
262 #define SIOCATMARK _IOR('s', 7, unsigned long)
292 #define FD_SETSIZE MEMP_NUM_NETCONN
293 #define FD_SET(n, p) ((p)->fd_bits[(n)/8] |= (1 << ((n) & 7)))
294 #define FD_CLR(n, p) ((p)->fd_bits[(n)/8] &= ~(1 << ((n) & 7)))
295 #define FD_ISSET(n,p) ((p)->fd_bits[(n)/8] & (1 << ((n) & 7)))
296 #define FD_ZERO(p) memset((void*)(p),0,sizeof(*(p)))
298 typedef struct fd_set {
299 unsigned char fd_bits [(FD_SETSIZE+7)/8];
306 #ifndef LWIP_TIMEVAL_PRIVATE
307 #define LWIP_TIMEVAL_PRIVATE 1
310 #if LWIP_TIMEVAL_PRIVATE
317 void lwip_socket_init(
void);
319 int lwip_accept(
int s,
struct sockaddr *addr, socklen_t *addrlen);
320 int lwip_bind(
int s,
const struct sockaddr *name, socklen_t namelen);
321 int lwip_shutdown(
int s,
int how);
322 int lwip_getpeername (
int s,
struct sockaddr *name, socklen_t *namelen);
323 int lwip_getsockname (
int s,
struct sockaddr *name, socklen_t *namelen);
324 int lwip_getsockopt (
int s,
int level,
int optname,
void *optval, socklen_t *optlen);
325 int lwip_setsockopt (
int s,
int level,
int optname,
const void *optval, socklen_t optlen);
326 int lwip_close(
int s);
327 int lwip_connect(
int s,
const struct sockaddr *name, socklen_t namelen);
328 int lwip_listen(
int s,
int backlog);
329 int lwip_recv(
int s,
void *mem,
size_t len,
int flags);
330 int lwip_read(
int s,
void *mem,
size_t len);
331 int lwip_recvfrom(
int s,
void *mem,
size_t len,
int flags,
332 struct sockaddr *from, socklen_t *fromlen);
333 int lwip_send(
int s,
const void *dataptr,
size_t size,
int flags);
334 int lwip_sendto(
int s,
const void *dataptr,
size_t size,
int flags,
335 const struct sockaddr *to, socklen_t tolen);
336 int lwip_socket(
int domain,
int type,
int protocol);
337 int lwip_write(
int s,
const void *dataptr,
size_t size);
338 int lwip_select(
int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
340 int lwip_ioctl(
int s,
long cmd,
void *argp);
341 int lwip_fcntl(
int s,
int cmd,
int val);
343 #if LWIP_COMPAT_SOCKETS
344 #define accept(a,b,c) lwip_accept(a,b,c)
345 #define bind(a,b,c) lwip_bind(a,b,c)
346 #define shutdown(a,b) lwip_shutdown(a,b)
347 #define closesocket(s) lwip_close(s)
348 #define connect(a,b,c) lwip_connect(a,b,c)
349 #define getsockname(a,b,c) lwip_getsockname(a,b,c)
350 #define getpeername(a,b,c) lwip_getpeername(a,b,c)
351 #define setsockopt(a,b,c,d,e) lwip_setsockopt(a,b,c,d,e)
352 #define getsockopt(a,b,c,d,e) lwip_getsockopt(a,b,c,d,e)
353 #define listen(a,b) lwip_listen(a,b)
354 #define recv(a,b,c,d) lwip_recv(a,b,c,d)
355 #define recvfrom(a,b,c,d,e,f) lwip_recvfrom(a,b,c,d,e,f)
356 #define send(a,b,c,d) lwip_send(a,b,c,d)
357 #define sendto(a,b,c,d,e,f) lwip_sendto(a,b,c,d,e,f)
358 #define socket(a,b,c) lwip_socket(a,b,c)
359 #define select(a,b,c,d,e) lwip_select(a,b,c,d,e)
360 #define ioctlsocket(a,b,c) lwip_ioctl(a,b,c)
362 #if LWIP_POSIX_SOCKETS_IO_NAMES
363 #define read(a,b,c) lwip_read(a,b,c)
364 #define write(a,b,c) lwip_write(a,b,c)
365 #define close(s) lwip_close(s)
time_t tv_sec
Definition: time.c:26
suseconds_t tv_usec
Definition: time.c:27