1 #ifndef _SYS_SOCKET_H 2 #define _SYS_SOCKET_H 3 #ifdef __cplusplus 4 extern "C" { 5 #endif 6 7 #include <features.h> 8 9 #define __NEED_socklen_t 10 #define __NEED_sa_family_t 11 #define __NEED_size_t 12 #define __NEED_ssize_t 13 #define __NEED_uid_t 14 #define __NEED_pid_t 15 #define __NEED_gid_t 16 #define __NEED_struct_iovec 17 18 #include <bits/alltypes.h> 19 20 #include <bits/socket.h> 21 22 struct msghdr { 23 void *msg_name; 24 socklen_t msg_namelen; 25 struct iovec *msg_iov; 26 #if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN 27 int __pad1; 28 #endif 29 int msg_iovlen; 30 #if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN 31 int __pad1; 32 #endif 33 void *msg_control; 34 #if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN 35 int __pad2; 36 #endif 37 socklen_t msg_controllen; 38 #if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN 39 int __pad2; 40 #endif 41 int msg_flags; 42 }; 43 44 struct cmsghdr { 45 #if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN 46 int __pad1; 47 #endif 48 socklen_t cmsg_len; 49 #if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN 50 int __pad1; 51 #endif 52 int cmsg_level; 53 int cmsg_type; 54 }; 55 56 #ifdef _GNU_SOURCE 57 struct ucred { 58 pid_t pid; 59 uid_t uid; 60 gid_t gid; 61 }; 62 63 struct mmsghdr { 64 struct msghdr msg_hdr; 65 unsigned int msg_len; 66 }; 67 68 struct timespec; 69 70 int sendmmsg (int, struct mmsghdr *, unsigned int, unsigned int); 71 int recvmmsg (int, struct mmsghdr *, unsigned int, unsigned int, struct timespec *); 72 #endif 73 74 struct linger { 75 int l_onoff; 76 int l_linger; 77 }; 78 79 #define SHUT_RD 0 80 #define SHUT_WR 1 81 #define SHUT_RDWR 2 82 83 #ifndef SOCK_STREAM 84 #define SOCK_STREAM 1 85 #define SOCK_DGRAM 2 86 #endif 87 88 #define SOCK_RAW 3 89 #define SOCK_RDM 4 90 #define SOCK_SEQPACKET 5 91 #define SOCK_DCCP 6 92 #define SOCK_PACKET 10 93 94 #ifndef SOCK_CLOEXEC 95 #define SOCK_CLOEXEC 02000000 96 #define SOCK_NONBLOCK 04000 97 #endif 98 99 #define PF_UNSPEC 0 100 #define PF_LOCAL 1 101 #define PF_UNIX PF_LOCAL 102 #define PF_FILE PF_LOCAL 103 #define PF_INET 2 104 #define PF_AX25 3 105 #define PF_IPX 4 106 #define PF_APPLETALK 5 107 #define PF_NETROM 6 108 #define PF_BRIDGE 7 109 #define PF_ATMPVC 8 110 #define PF_X25 9 111 #define PF_INET6 10 112 #define PF_ROSE 11 113 #define PF_DECnet 12 114 #define PF_NETBEUI 13 115 #define PF_SECURITY 14 116 #define PF_KEY 15 117 #define PF_NETLINK 16 118 #define PF_ROUTE PF_NETLINK 119 #define PF_PACKET 17 120 #define PF_ASH 18 121 #define PF_ECONET 19 122 #define PF_ATMSVC 20 123 #define PF_RDS 21 124 #define PF_SNA 22 125 #define PF_IRDA 23 126 #define PF_PPPOX 24 127 #define PF_WANPIPE 25 128 #define PF_LLC 26 129 #define PF_IB 27 130 #define PF_MPLS 28 131 #define PF_CAN 29 132 #define PF_TIPC 30 133 #define PF_BLUETOOTH 31 134 #define PF_IUCV 32 135 #define PF_RXRPC 33 136 #define PF_ISDN 34 137 #define PF_PHONET 35 138 #define PF_IEEE802154 36 139 #define PF_CAIF 37 140 #define PF_ALG 38 141 #define PF_NFC 39 142 #define PF_VSOCK 40 143 #define PF_KCM 41 144 #define PF_QIPCRTR 42 145 #define PF_SMC 43 146 #define PF_XDP 44 147 #define PF_MAX 45 148 149 #define AF_UNSPEC PF_UNSPEC 150 #define AF_LOCAL PF_LOCAL 151 #define AF_UNIX AF_LOCAL 152 #define AF_FILE AF_LOCAL 153 #define AF_INET PF_INET 154 #define AF_AX25 PF_AX25 155 #define AF_IPX PF_IPX 156 #define AF_APPLETALK PF_APPLETALK 157 #define AF_NETROM PF_NETROM 158 #define AF_BRIDGE PF_BRIDGE 159 #define AF_ATMPVC PF_ATMPVC 160 #define AF_X25 PF_X25 161 #define AF_INET6 PF_INET6 162 #define AF_ROSE PF_ROSE 163 #define AF_DECnet PF_DECnet 164 #define AF_NETBEUI PF_NETBEUI 165 #define AF_SECURITY PF_SECURITY 166 #define AF_KEY PF_KEY 167 #define AF_NETLINK PF_NETLINK 168 #define AF_ROUTE PF_ROUTE 169 #define AF_PACKET PF_PACKET 170 #define AF_ASH PF_ASH 171 #define AF_ECONET PF_ECONET 172 #define AF_ATMSVC PF_ATMSVC 173 #define AF_RDS PF_RDS 174 #define AF_SNA PF_SNA 175 #define AF_IRDA PF_IRDA 176 #define AF_PPPOX PF_PPPOX 177 #define AF_WANPIPE PF_WANPIPE 178 #define AF_LLC PF_LLC 179 #define AF_IB PF_IB 180 #define AF_MPLS PF_MPLS 181 #define AF_CAN PF_CAN 182 #define AF_TIPC PF_TIPC 183 #define AF_BLUETOOTH PF_BLUETOOTH 184 #define AF_IUCV PF_IUCV 185 #define AF_RXRPC PF_RXRPC 186 #define AF_ISDN PF_ISDN 187 #define AF_PHONET PF_PHONET 188 #define AF_IEEE802154 PF_IEEE802154 189 #define AF_CAIF PF_CAIF 190 #define AF_ALG PF_ALG 191 #define AF_NFC PF_NFC 192 #define AF_VSOCK PF_VSOCK 193 #define AF_KCM PF_KCM 194 #define AF_QIPCRTR PF_QIPCRTR 195 #define AF_SMC PF_SMC 196 #define AF_XDP PF_XDP 197 #define AF_MAX PF_MAX 198 199 #ifndef SO_DEBUG 200 #define SO_DEBUG 1 201 #define SO_REUSEADDR 2 202 #define SO_TYPE 3 203 #define SO_ERROR 4 204 #define SO_DONTROUTE 5 205 #define SO_BROADCAST 6 206 #define SO_SNDBUF 7 207 #define SO_RCVBUF 8 208 #define SO_KEEPALIVE 9 209 #define SO_OOBINLINE 10 210 #define SO_NO_CHECK 11 211 #define SO_PRIORITY 12 212 #define SO_LINGER 13 213 #define SO_BSDCOMPAT 14 214 #define SO_REUSEPORT 15 215 #define SO_PASSCRED 16 216 #define SO_PEERCRED 17 217 #define SO_RCVLOWAT 18 218 #define SO_SNDLOWAT 19 219 #define SO_ACCEPTCONN 30 220 #define SO_PEERSEC 31 221 #define SO_SNDBUFFORCE 32 222 #define SO_RCVBUFFORCE 33 223 #define SO_PROTOCOL 38 224 #define SO_DOMAIN 39 225 #endif 226 227 #ifndef SO_RCVTIMEO 228 #if __LONG_MAX == 0x7fffffff 229 #define SO_RCVTIMEO 66 230 #define SO_SNDTIMEO 67 231 #else 232 #define SO_RCVTIMEO 20 233 #define SO_SNDTIMEO 21 234 #endif 235 #endif 236 237 #ifndef SO_TIMESTAMP 238 #if __LONG_MAX == 0x7fffffff 239 #define SO_TIMESTAMP 63 240 #define SO_TIMESTAMPNS 64 241 #define SO_TIMESTAMPING 65 242 #else 243 #define SO_TIMESTAMP 29 244 #define SO_TIMESTAMPNS 35 245 #define SO_TIMESTAMPING 37 246 #endif 247 #endif 248 249 #define SO_SECURITY_AUTHENTICATION 22 250 #define SO_SECURITY_ENCRYPTION_TRANSPORT 23 251 #define SO_SECURITY_ENCRYPTION_NETWORK 24 252 253 #define SO_BINDTODEVICE 25 254 255 #define SO_ATTACH_FILTER 26 256 #define SO_DETACH_FILTER 27 257 #define SO_GET_FILTER SO_ATTACH_FILTER 258 259 #define SO_PEERNAME 28 260 #define SCM_TIMESTAMP SO_TIMESTAMP 261 #define SO_PASSSEC 34 262 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS 263 #define SO_MARK 36 264 #define SCM_TIMESTAMPING SO_TIMESTAMPING 265 #define SO_RXQ_OVFL 40 266 #define SO_WIFI_STATUS 41 267 #define SCM_WIFI_STATUS SO_WIFI_STATUS 268 #define SO_PEEK_OFF 42 269 #define SO_NOFCS 43 270 #define SO_LOCK_FILTER 44 271 #define SO_SELECT_ERR_QUEUE 45 272 #define SO_BUSY_POLL 46 273 #define SO_MAX_PACING_RATE 47 274 #define SO_BPF_EXTENSIONS 48 275 #define SO_INCOMING_CPU 49 276 #define SO_ATTACH_BPF 50 277 #define SO_DETACH_BPF SO_DETACH_FILTER 278 #define SO_ATTACH_REUSEPORT_CBPF 51 279 #define SO_ATTACH_REUSEPORT_EBPF 52 280 #define SO_CNX_ADVICE 53 281 #define SCM_TIMESTAMPING_OPT_STATS 54 282 #define SO_MEMINFO 55 283 #define SO_INCOMING_NAPI_ID 56 284 #define SO_COOKIE 57 285 #define SCM_TIMESTAMPING_PKTINFO 58 286 #define SO_PEERGROUPS 59 287 #define SO_ZEROCOPY 60 288 #define SO_TXTIME 61 289 #define SCM_TXTIME SO_TXTIME 290 #define SO_BINDTOIFINDEX 62 291 #define SO_DETACH_REUSEPORT_BPF 68 292 293 #ifndef SOL_SOCKET 294 #define SOL_SOCKET 1 295 #endif 296 297 #define SOL_IP 0 298 #define SOL_IPV6 41 299 #define SOL_ICMPV6 58 300 301 #define SOL_RAW 255 302 #define SOL_DECNET 261 303 #define SOL_X25 262 304 #define SOL_PACKET 263 305 #define SOL_ATM 264 306 #define SOL_AAL 265 307 #define SOL_IRDA 266 308 #define SOL_NETBEUI 267 309 #define SOL_LLC 268 310 #define SOL_DCCP 269 311 #define SOL_NETLINK 270 312 #define SOL_TIPC 271 313 #define SOL_RXRPC 272 314 #define SOL_PPPOL2TP 273 315 #define SOL_BLUETOOTH 274 316 #define SOL_PNPIPE 275 317 #define SOL_RDS 276 318 #define SOL_IUCV 277 319 #define SOL_CAIF 278 320 #define SOL_ALG 279 321 #define SOL_NFC 280 322 #define SOL_KCM 281 323 #define SOL_TLS 282 324 #define SOL_XDP 283 325 326 #define SOMAXCONN 128 327 328 #define MSG_OOB 0x0001 329 #define MSG_PEEK 0x0002 330 #define MSG_DONTROUTE 0x0004 331 #define MSG_CTRUNC 0x0008 332 #define MSG_PROXY 0x0010 333 #define MSG_TRUNC 0x0020 334 #define MSG_DONTWAIT 0x0040 335 #define MSG_EOR 0x0080 336 #define MSG_WAITALL 0x0100 337 #define MSG_FIN 0x0200 338 #define MSG_SYN 0x0400 339 #define MSG_CONFIRM 0x0800 340 #define MSG_RST 0x1000 341 #define MSG_ERRQUEUE 0x2000 342 #define MSG_NOSIGNAL 0x4000 343 #define MSG_MORE 0x8000 344 #define MSG_WAITFORONE 0x10000 345 #define MSG_BATCH 0x40000 346 #define MSG_ZEROCOPY 0x4000000 347 #define MSG_FASTOPEN 0x20000000 348 #define MSG_CMSG_CLOEXEC 0x40000000 349 350 #define __CMSG_LEN(cmsg) (((cmsg)->cmsg_len + sizeof(long) - 1) & ~(long)(sizeof(long) - 1)) 351 #define __CMSG_NEXT(cmsg) ((unsigned char *)(cmsg) + __CMSG_LEN(cmsg)) 352 #define __MHDR_END(mhdr) ((unsigned char *)(mhdr)->msg_control + (mhdr)->msg_controllen) 353 354 #define CMSG_DATA(cmsg) ((unsigned char *) (((struct cmsghdr *)(cmsg)) + 1)) 355 #define CMSG_NXTHDR(mhdr, cmsg) ((cmsg)->cmsg_len < sizeof (struct cmsghdr) || \ 356 __CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) - (unsigned char *)(cmsg) \ 357 ? 0 : (struct cmsghdr *)__CMSG_NEXT(cmsg)) 358 #define CMSG_FIRSTHDR(mhdr) ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0) 359 360 #define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1)) 361 #define CMSG_SPACE(len) (CMSG_ALIGN (len) + CMSG_ALIGN (sizeof (struct cmsghdr))) 362 #define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len)) 363 364 #define SCM_RIGHTS 0x01 365 #define SCM_CREDENTIALS 0x02 366 367 struct sockaddr { 368 sa_family_t sa_family; 369 char sa_data[14]; 370 }; 371 372 struct sockaddr_storage { 373 sa_family_t ss_family; 374 char __ss_padding[128-sizeof(long)-sizeof(sa_family_t)]; 375 unsigned long __ss_align; 376 }; 377 378 int socket (int, int, int); 379 int socketpair (int, int, int, int [2]); 380 381 int shutdown (int, int); 382 383 int bind (int, const struct sockaddr *, socklen_t); 384 int connect (int, const struct sockaddr *, socklen_t); 385 int listen (int, int); 386 int accept (int, struct sockaddr *__restrict, socklen_t *__restrict); 387 int accept4(int, struct sockaddr *__restrict, socklen_t *__restrict, int); 388 389 int getsockname (int, struct sockaddr *__restrict, socklen_t *__restrict); 390 int getpeername (int, struct sockaddr *__restrict, socklen_t *__restrict); 391 392 ssize_t send (int, const void *, size_t, int); 393 ssize_t recv (int, void *, size_t, int); 394 ssize_t sendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t); 395 ssize_t recvfrom (int, void *__restrict, size_t, int, struct sockaddr *__restrict, socklen_t *__restrict); 396 ssize_t sendmsg (int, const struct msghdr *, int); 397 ssize_t recvmsg (int, struct msghdr *, int); 398 399 int getsockopt (int, int, int, void *__restrict, socklen_t *__restrict); 400 int setsockopt (int, int, int, const void *, socklen_t); 401 402 int sockatmark (int); 403 404 #if _REDIR_TIME64 405 #ifdef _GNU_SOURCE 406 __REDIR(recvmmsg, __recvmmsg_time64); 407 #endif 408 #endif 409 410 #ifdef __cplusplus 411 } 412 #endif 413 #endif 414