1 #ifndef __ip_h
2 #define __ip_h
3 
4 #include <sys/socket.h>
5 #include <fcntl.h>
6 
7 #ifndef O_NONBLOCK
8 #define O_NONBLOCK O_NDELAY
9 #endif
ndelay_off(int fd)10 static int inline ndelay_off(int fd)
11 {
12 	return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~O_NONBLOCK);
13 }
ndelay_on(int fd)14 static int inline ndelay_on(int fd)
15 {
16 	return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK);
17 }
socket_listen(int fd)18 static void inline socket_listen(int fd)
19 {
20 	if (listen(fd, 128) < 0)
21 		cfatal("listen: %s");
22 }
socket_tryreservein(int fd,int size)23 static void inline socket_tryreservein(int fd, int size)
24 {
25 	while (size >= 1024) {
26 		if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)) == 0)
27 			return;
28 		size -= (size >> 5);
29 	}
30 }
31 
32 
33 #ifdef HAVE_IPV6
34 #include "ip6.h"
35 #endif
36 
37 #include "ip4.h"
38 
39 #endif
40