| 1 |
/* |
|---|
| 2 |
******************************* |
|---|
| 3 |
* |
|---|
| 4 |
* sys/uio.d |
|---|
| 5 |
* |
|---|
| 6 |
******************************* |
|---|
| 7 |
*/ |
|---|
| 8 |
|
|---|
| 9 |
struct iovec |
|---|
| 10 |
{ |
|---|
| 11 |
void * iov_base; /* [XSI] Base address of I/O memory region */ |
|---|
| 12 |
size_t iov_len; /* [XSI] Size of region iov_base points to */ |
|---|
| 13 |
} |
|---|
| 14 |
|
|---|
| 15 |
ssize_t readv(int, const struct iovec *, int); |
|---|
| 16 |
ssize_t writev(int, const struct iovec *, int); |
|---|
| 17 |
|
|---|
| 18 |
/* |
|---|
| 19 |
********************************* |
|---|
| 20 |
* |
|---|
| 21 |
* sys/socket.d |
|---|
| 22 |
* |
|---|
| 23 |
********************************* |
|---|
| 24 |
*/ |
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
alias __uint32_t socklen_t; |
|---|
| 28 |
alias __uint8_t sa_family_t; |
|---|
| 29 |
|
|---|
| 30 |
struct sockaddr |
|---|
| 31 |
{ |
|---|
| 32 |
__uint8_t sa_len; |
|---|
| 33 |
sa_family_t sa_family; |
|---|
| 34 |
char sa_data[14]; |
|---|
| 35 |
}; |
|---|
| 36 |
|
|---|
| 37 |
struct sockaddr_storage |
|---|
| 38 |
{ |
|---|
| 39 |
__uint8_t ss_len; |
|---|
| 40 |
sa_family_t ss_family; |
|---|
| 41 |
char __ss_pad1[((sizeof(__int64_t)) - sizeof(__uint8_t) - sizeof(sa_family_t))]; |
|---|
| 42 |
__int64_t __ss_align; |
|---|
| 43 |
char __ss_pad2[(128 - sizeof(__uint8_t) - \ |
|---|
| 44 |
sizeof(sa_family_t) - ((sizeof(__int64_t)) - sizeof(__uint8_t) - \ |
|---|
| 45 |
sizeof(sa_family_t)) - (sizeof(__int64_t)))]; |
|---|
| 46 |
} |
|---|
| 47 |
|
|---|
| 48 |
struct msghdr |
|---|
| 49 |
{ |
|---|
| 50 |
void *msg_name; |
|---|
| 51 |
socklen_t msg_namelen; |
|---|
| 52 |
struct iovec *msg_iov; |
|---|
| 53 |
int msg_iovlen; |
|---|
| 54 |
void *msg_control; |
|---|
| 55 |
socklen_t msg_controllen; |
|---|
| 56 |
int msg_flags; |
|---|
| 57 |
} |
|---|
| 58 |
|
|---|
| 59 |
struct cmsghdr |
|---|
| 60 |
{ |
|---|
| 61 |
socklen_t cmsg_len; |
|---|
| 62 |
int cmsg_level; |
|---|
| 63 |
int cmsg_type; |
|---|
| 64 |
} |
|---|
| 65 |
|
|---|
| 66 |
SCM_RIGHTS 0x01 |
|---|
| 67 |
|
|---|
| 68 |
CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \ |
|---|
| 69 |
ALIGN(sizeof(struct cmsghdr))) |
|---|
| 70 |
CMSG_NXTHDR(mhdr, cmsg) \ |
|---|
| 71 |
(((unsigned char *)(cmsg) + ALIGN((cmsg)->cmsg_len) + \ |
|---|
| 72 |
ALIGN(sizeof(struct cmsghdr)) > \ |
|---|
| 73 |
(unsigned char *)(mhdr)->msg_control +(mhdr)->msg_controllen) ? \ |
|---|
| 74 |
(struct cmsghdr *)0 /* NULL */ : \ |
|---|
| 75 |
(struct cmsghdr *)((unsigned char *)(cmsg) + ALIGN((cmsg)->cmsg_len))) |
|---|
| 76 |
CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control) |
|---|
| 77 |
|
|---|
| 78 |
struct linger |
|---|
| 79 |
{ |
|---|
| 80 |
int l_onoff; |
|---|
| 81 |
int l_linger; |
|---|
| 82 |
}; |
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
SOCK_DGRAM 2 |
|---|
| 86 |
SOCK_SEQPACKET 5 |
|---|
| 87 |
SOCK_STREAM 1 |
|---|
| 88 |
|
|---|
| 89 |
SOL_SOCKET 0xffff |
|---|
| 90 |
|
|---|
| 91 |
SO_ACCEPTCONN 0x0002 /* socket has had listen() */ |
|---|
| 92 |
SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ |
|---|
| 93 |
SO_DEBUG 0x0001 /* turn on debugging info recording */ |
|---|
| 94 |
SO_DONTROUTE 0x0010 /* just use interface addresses */ |
|---|
| 95 |
SO_ERROR 0x1007 /* get error status and clear */ |
|---|
| 96 |
SO_KEEPALIVE 0x0008 /* keep connections alive */ |
|---|
| 97 |
SO_LINGER #ifndef _POSIX_C_SOURCE |
|---|
| 98 |
#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ |
|---|
| 99 |
#define SO_LINGER 0x0080 /* linger on close if data present (in ticks) */ |
|---|
| 100 |
#else |
|---|
| 101 |
#define SO_LINGER 0x1080 /* linger on close if data present (in seconds) */ |
|---|
| 102 |
#endif /* !_POSIX_C_SOURCE */ |
|---|
| 103 |
SO_OOBINLINE 0x0100 /* leave received OOB data in line */ |
|---|
| 104 |
SO_RCVBUF 0x1002 /* receive buffer size */ |
|---|
| 105 |
SO_RCVLOWAT 0x1004 /* receive low-water mark */ |
|---|
| 106 |
SO_RCVTIMEO 0x1006 /* receive timeout */ |
|---|
| 107 |
SO_REUSEADDR 0x0004 /* allow local address reuse */ |
|---|
| 108 |
SO_SNDBUF 0x1001 /* send buffer size */ |
|---|
| 109 |
SO_SNDLOWAT 0x1003 /* send low-water mark */ |
|---|
| 110 |
SO_SNDTIMEO 0x1005 /* send timeout */ |
|---|
| 111 |
SO_TYPE 0x1008 /* get socket type */ |
|---|
| 112 |
|
|---|
| 113 |
SOMAXCONN 128 |
|---|
| 114 |
|
|---|
| 115 |
MSG_CTRUNC 0x20 /* control data lost before delivery */ |
|---|
| 116 |
MSG_DONTROUTE 0x4 /* send without using routing tables */ |
|---|
| 117 |
MSG_EOR 0x8 /* data completes record */ |
|---|
| 118 |
MSG_OOB 0x1 /* process out-of-band data */ |
|---|
| 119 |
MSG_PEEK 0x2 /* peek at incoming message */ |
|---|
| 120 |
MSG_TRUNC 0x10 /* data discarded before delivery */ |
|---|
| 121 |
MSG_WAITALL 0x40 /* wait for full request or error */ |
|---|
| 122 |
|
|---|
| 123 |
AF_INET 2 /* internetwork: UDP, TCP, etc. */ |
|---|
| 124 |
AF_UNIX 1 /* local to host (pipes) */ |
|---|
| 125 |
AF_UNSPEC 0 /* unspecified */ |
|---|
| 126 |
|
|---|
| 127 |
SHUT_RD 0 /* shut down the reading side */ |
|---|
| 128 |
SHUT_RDWR 2 /* shut down both sides */ |
|---|
| 129 |
SHUT_WR 1 /* shut down the writing side */ |
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 |
int accept(int, struct sockaddr * , socklen_t * ); |
|---|
| 133 |
int bind(int, const struct sockaddr *, socklen_t) ; |
|---|
| 134 |
int connect(int, const struct sockaddr *, socklen_t) ; |
|---|
| 135 |
int getpeername(int, struct sockaddr * , socklen_t * ); |
|---|
| 136 |
int getsockname(int, struct sockaddr * , socklen_t * ); |
|---|
| 137 |
int getsockopt(int, int, int, void * , socklen_t * ); |
|---|
| 138 |
int listen(int, int) ; |
|---|
| 139 |
ssize_t recv(int, void *, size_t, int) ; |
|---|
| 140 |
ssize_t recvfrom(int, void *, size_t, int, struct sockaddr * , socklen_t* ) ; |
|---|
| 141 |
ssize_t recvmsg(int, struct msghdr *, int) ; |
|---|
| 142 |
ssize_t send(int, const void *, size_t, int) ; |
|---|
| 143 |
ssize_t sendmsg(int, const struct msghdr *, int) ; |
|---|
| 144 |
ssize_t sendto(int, const void *, size_t, int, const struct sockaddr *,socklen_t) ; |
|---|
| 145 |
int setsockopt(int, int, int, const void *, socklen_t); |
|---|
| 146 |
int shutdown(int, int); |
|---|
| 147 |
int socket(int, int, int); |
|---|
| 148 |
int socketpair(int, int, int, int *) ; |
|---|
| 149 |
|
|---|
| 150 |
AF_INET6 30 /* IPv6 */ |
|---|
| 151 |
|
|---|
| 152 |
SOCK_RAW 3 /* raw-protocol interface */ |
|---|
| 153 |
|
|---|
| 154 |
/* |
|---|
| 155 |
********************************* |
|---|
| 156 |
* |
|---|
| 157 |
* net/if_.d |
|---|
| 158 |
* |
|---|
| 159 |
********************************* |
|---|
| 160 |
*/ |
|---|
| 161 |
|
|---|
| 162 |
struct if_nameindex |
|---|
| 163 |
{ |
|---|
| 164 |
unsigned int if_index; /* 1, 2, ... */ |
|---|
| 165 |
char *if_name; /* null terminated name: "le0", ... */ |
|---|
| 166 |
} |
|---|
| 167 |
|
|---|
| 168 |
IF_NAMESIZE 16 |
|---|
| 169 |
|
|---|
| 170 |
unsigned int if_nametoindex(const char *); |
|---|
| 171 |
char *if_indextoname(unsigned int, char *); |
|---|
| 172 |
struct if_nameindex *if_nameindex(void); |
|---|
| 173 |
void if_freenameindex(struct if_nameindex *); |
|---|
| 174 |
|
|---|
| 175 |
/* |
|---|
| 176 |
********************************* |
|---|
| 177 |
* |
|---|
| 178 |
* arpa/inet.d |
|---|
| 179 |
* |
|---|
| 180 |
********************************* |
|---|
| 181 |
*/ |
|---|
| 182 |
|
|---|
| 183 |
uint16_t ntohs(uint16_t); |
|---|
| 184 |
uint16_t htons(uint16_t); |
|---|
| 185 |
uint32_t ntohl(uint32_t); |
|---|
| 186 |
uint32_t htonl(uint32_t); |
|---|
| 187 |
|
|---|
| 188 |
in_addr_t inet_addr(const char *); |
|---|
| 189 |
char *inet_ntoa(struct in_addr); |
|---|
| 190 |
const char *inet_ntop(int, const void *, char *, size_t); |
|---|
| 191 |
int inet_pton(int, const char *, void *); |
|---|
| 192 |
|
|---|
| 193 |
INET_ADDRSTRLEN 16 |
|---|
| 194 |
|
|---|
| 195 |
INET6_ADDRSTRLEN 46 |
|---|
| 196 |
|
|---|
| 197 |
|
|---|
| 198 |
/* |
|---|
| 199 |
********************************* |
|---|
| 200 |
* |
|---|
| 201 |
* netinet/tcp.d |
|---|
| 202 |
* |
|---|
| 203 |
********************************* |
|---|
| 204 |
*/ |
|---|
| 205 |
|
|---|
| 206 |
TCP_NODELAY 0x01 /* don't delay send to coalesce packets */ |
|---|
| 207 |
|
|---|
| 208 |
|
|---|
| 209 |
/* |
|---|
| 210 |
********************************* |
|---|
| 211 |
* |
|---|
| 212 |
* netinet/in_.d |
|---|
| 213 |
* |
|---|
| 214 |
********************************* |
|---|
| 215 |
*/ |
|---|
| 216 |
|
|---|
| 217 |
struct sockaddr_in |
|---|
| 218 |
{ |
|---|
| 219 |
__uint8_t sin_len; |
|---|
| 220 |
sa_family_t sin_family; |
|---|
| 221 |
in_port_t sin_port; |
|---|
| 222 |
struct in_addr sin_addr; |
|---|
| 223 |
char sin_zero[8]; /* XXX bwg2001-004 */ |
|---|
| 224 |
} |
|---|
| 225 |
|
|---|
| 226 |
struct in_addr |
|---|
| 227 |
{ |
|---|
| 228 |
in_addr_t s_addr; |
|---|
| 229 |
} |
|---|
| 230 |
|
|---|
| 231 |
IPPROTO_IP 0 /* dummy for IP */ |
|---|
| 232 |
IPPROTO_ICMP 1 /* control message protocol */ |
|---|
| 233 |
IPPROTO_TCP 6 /* tcp */ |
|---|
| 234 |
IPPROTO_UDP 17 /* user datagram protocol */ |
|---|
| 235 |
|
|---|
| 236 |
INADDR_ANY (u_int32_t)0x00000000 |
|---|
| 237 |
INADDR_BROADCAST (u_int32_t)0xffffffff /* must be masked */ |
|---|
| 238 |
|
|---|
| 239 |
INET_ADDRSTRLEN 16 |
|---|
| 240 |
|
|---|
| 241 |
struct sockaddr_in6 |
|---|
| 242 |
{ |
|---|
| 243 |
__uint8_t sin6_len; /* length of this struct(sa_family_t)*/ |
|---|
| 244 |
sa_family_t sin6_family; /* AF_INET6 (sa_family_t) */ |
|---|
| 245 |
in_port_t sin6_port; /* Transport layer port # (in_port_t)*/ |
|---|
| 246 |
__uint32_t sin6_flowinfo; /* IP6 flow information */ |
|---|
| 247 |
struct in6_addr sin6_addr; /* IP6 address */ |
|---|
| 248 |
__uint32_t sin6_scope_id; /* scope zone index */ |
|---|
| 249 |
}; |
|---|