2011-02-12 05:22:29 +00:00
|
|
|
#ifndef _SYS_SOCKET_H
|
|
|
|
#define _SYS_SOCKET_H
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2012-09-08 21:14:52 +00:00
|
|
|
#include <features.h>
|
2012-09-07 02:44:55 +00:00
|
|
|
|
2011-02-12 05:22:29 +00:00
|
|
|
#define __NEED_socklen_t
|
|
|
|
#define __NEED_sa_family_t
|
|
|
|
#define __NEED_size_t
|
|
|
|
#define __NEED_ssize_t
|
|
|
|
#define __NEED_uid_t
|
|
|
|
#define __NEED_pid_t
|
|
|
|
#define __NEED_gid_t
|
2011-02-14 23:41:25 +00:00
|
|
|
#define __NEED_struct_iovec
|
2011-02-12 05:22:29 +00:00
|
|
|
|
|
|
|
#include <bits/alltypes.h>
|
|
|
|
|
|
|
|
#include <bits/socket.h>
|
|
|
|
|
2013-12-04 21:39:52 +00:00
|
|
|
#ifdef _GNU_SOURCE
|
2016-07-03 18:40:11 +00:00
|
|
|
struct ucred {
|
2011-09-18 20:34:13 +00:00
|
|
|
pid_t pid;
|
|
|
|
uid_t uid;
|
|
|
|
gid_t gid;
|
|
|
|
};
|
2014-06-20 03:01:15 +00:00
|
|
|
|
2016-07-03 18:40:11 +00:00
|
|
|
struct mmsghdr {
|
2014-06-20 03:01:15 +00:00
|
|
|
struct msghdr msg_hdr;
|
|
|
|
unsigned int msg_len;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct timespec;
|
|
|
|
|
|
|
|
int sendmmsg (int, struct mmsghdr *, unsigned int, unsigned int);
|
|
|
|
int recvmmsg (int, struct mmsghdr *, unsigned int, unsigned int, struct timespec *);
|
2013-12-04 21:39:52 +00:00
|
|
|
#endif
|
2011-09-18 20:34:13 +00:00
|
|
|
|
2016-07-03 18:40:11 +00:00
|
|
|
struct linger {
|
2011-09-18 20:34:13 +00:00
|
|
|
int l_onoff;
|
|
|
|
int l_linger;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define SHUT_RD 0
|
2013-12-04 21:38:32 +00:00
|
|
|
#define SHUT_WR 1
|
2011-09-18 20:34:13 +00:00
|
|
|
#define SHUT_RDWR 2
|
|
|
|
|
2012-08-05 18:23:40 +00:00
|
|
|
#ifndef SOCK_STREAM
|
2011-09-18 20:34:13 +00:00
|
|
|
#define SOCK_STREAM 1
|
|
|
|
#define SOCK_DGRAM 2
|
2012-08-05 18:23:40 +00:00
|
|
|
#endif
|
|
|
|
|
2011-09-18 20:34:13 +00:00
|
|
|
#define SOCK_RAW 3
|
|
|
|
#define SOCK_RDM 4
|
|
|
|
#define SOCK_SEQPACKET 5
|
|
|
|
#define SOCK_DCCP 6
|
|
|
|
#define SOCK_PACKET 10
|
|
|
|
|
2012-11-05 19:29:04 +00:00
|
|
|
#ifndef SOCK_CLOEXEC
|
2011-09-18 20:34:13 +00:00
|
|
|
#define SOCK_CLOEXEC 02000000
|
|
|
|
#define SOCK_NONBLOCK 04000
|
2012-11-05 19:29:04 +00:00
|
|
|
#endif
|
2011-09-18 20:34:13 +00:00
|
|
|
|
|
|
|
#define PF_UNSPEC 0
|
|
|
|
#define PF_LOCAL 1
|
|
|
|
#define PF_UNIX PF_LOCAL
|
|
|
|
#define PF_FILE PF_LOCAL
|
|
|
|
#define PF_INET 2
|
|
|
|
#define PF_AX25 3
|
|
|
|
#define PF_IPX 4
|
|
|
|
#define PF_APPLETALK 5
|
|
|
|
#define PF_NETROM 6
|
|
|
|
#define PF_BRIDGE 7
|
|
|
|
#define PF_ATMPVC 8
|
|
|
|
#define PF_X25 9
|
|
|
|
#define PF_INET6 10
|
|
|
|
#define PF_ROSE 11
|
|
|
|
#define PF_DECnet 12
|
|
|
|
#define PF_NETBEUI 13
|
|
|
|
#define PF_SECURITY 14
|
|
|
|
#define PF_KEY 15
|
|
|
|
#define PF_NETLINK 16
|
|
|
|
#define PF_ROUTE PF_NETLINK
|
|
|
|
#define PF_PACKET 17
|
|
|
|
#define PF_ASH 18
|
|
|
|
#define PF_ECONET 19
|
|
|
|
#define PF_ATMSVC 20
|
2013-01-11 00:46:09 +00:00
|
|
|
#define PF_RDS 21
|
2011-09-18 20:34:13 +00:00
|
|
|
#define PF_SNA 22
|
|
|
|
#define PF_IRDA 23
|
|
|
|
#define PF_PPPOX 24
|
|
|
|
#define PF_WANPIPE 25
|
2013-01-11 00:46:09 +00:00
|
|
|
#define PF_LLC 26
|
2013-07-25 00:22:05 +00:00
|
|
|
#define PF_IB 27
|
2015-06-26 20:32:24 +00:00
|
|
|
#define PF_MPLS 28
|
2013-01-11 00:46:09 +00:00
|
|
|
#define PF_CAN 29
|
|
|
|
#define PF_TIPC 30
|
2011-09-18 20:34:13 +00:00
|
|
|
#define PF_BLUETOOTH 31
|
|
|
|
#define PF_IUCV 32
|
|
|
|
#define PF_RXRPC 33
|
|
|
|
#define PF_ISDN 34
|
|
|
|
#define PF_PHONET 35
|
|
|
|
#define PF_IEEE802154 36
|
|
|
|
#define PF_CAIF 37
|
|
|
|
#define PF_ALG 38
|
2013-01-11 00:46:09 +00:00
|
|
|
#define PF_NFC 39
|
2013-07-25 00:22:05 +00:00
|
|
|
#define PF_VSOCK 40
|
2016-05-26 20:07:32 +00:00
|
|
|
#define PF_KCM 41
|
|
|
|
#define PF_MAX 42
|
2011-09-18 20:34:13 +00:00
|
|
|
|
|
|
|
#define AF_UNSPEC PF_UNSPEC
|
|
|
|
#define AF_LOCAL PF_LOCAL
|
|
|
|
#define AF_UNIX AF_LOCAL
|
|
|
|
#define AF_FILE AF_LOCAL
|
|
|
|
#define AF_INET PF_INET
|
|
|
|
#define AF_AX25 PF_AX25
|
|
|
|
#define AF_IPX PF_IPX
|
|
|
|
#define AF_APPLETALK PF_APPLETALK
|
|
|
|
#define AF_NETROM PF_NETROM
|
|
|
|
#define AF_BRIDGE PF_BRIDGE
|
|
|
|
#define AF_ATMPVC PF_ATMPVC
|
|
|
|
#define AF_X25 PF_X25
|
|
|
|
#define AF_INET6 PF_INET6
|
|
|
|
#define AF_ROSE PF_ROSE
|
|
|
|
#define AF_DECnet PF_DECnet
|
|
|
|
#define AF_NETBEUI PF_NETBEUI
|
|
|
|
#define AF_SECURITY PF_SECURITY
|
|
|
|
#define AF_KEY PF_KEY
|
|
|
|
#define AF_NETLINK PF_NETLINK
|
|
|
|
#define AF_ROUTE PF_ROUTE
|
|
|
|
#define AF_PACKET PF_PACKET
|
|
|
|
#define AF_ASH PF_ASH
|
|
|
|
#define AF_ECONET PF_ECONET
|
|
|
|
#define AF_ATMSVC PF_ATMSVC
|
2013-01-11 00:46:09 +00:00
|
|
|
#define AF_RDS PF_RDS
|
2011-09-18 20:34:13 +00:00
|
|
|
#define AF_SNA PF_SNA
|
|
|
|
#define AF_IRDA PF_IRDA
|
|
|
|
#define AF_PPPOX PF_PPPOX
|
|
|
|
#define AF_WANPIPE PF_WANPIPE
|
2013-01-11 00:46:09 +00:00
|
|
|
#define AF_LLC PF_LLC
|
2013-07-25 00:22:05 +00:00
|
|
|
#define AF_IB PF_IB
|
2015-06-26 20:32:24 +00:00
|
|
|
#define AF_MPLS PF_MPLS
|
2013-01-11 00:46:09 +00:00
|
|
|
#define AF_CAN PF_CAN
|
|
|
|
#define AF_TIPC PF_TIPC
|
2011-09-18 20:34:13 +00:00
|
|
|
#define AF_BLUETOOTH PF_BLUETOOTH
|
|
|
|
#define AF_IUCV PF_IUCV
|
|
|
|
#define AF_RXRPC PF_RXRPC
|
|
|
|
#define AF_ISDN PF_ISDN
|
|
|
|
#define AF_PHONET PF_PHONET
|
|
|
|
#define AF_IEEE802154 PF_IEEE802154
|
|
|
|
#define AF_CAIF PF_CAIF
|
|
|
|
#define AF_ALG PF_ALG
|
2013-01-11 00:46:09 +00:00
|
|
|
#define AF_NFC PF_NFC
|
2013-07-25 00:22:05 +00:00
|
|
|
#define AF_VSOCK PF_VSOCK
|
2016-05-26 20:07:32 +00:00
|
|
|
#define AF_KCM PF_KCM
|
2011-09-18 20:34:13 +00:00
|
|
|
#define AF_MAX PF_MAX
|
|
|
|
|
2012-11-05 19:29:04 +00:00
|
|
|
#ifndef SO_DEBUG
|
2011-09-18 20:34:13 +00:00
|
|
|
#define SO_DEBUG 1
|
|
|
|
#define SO_REUSEADDR 2
|
|
|
|
#define SO_TYPE 3
|
|
|
|
#define SO_ERROR 4
|
|
|
|
#define SO_DONTROUTE 5
|
|
|
|
#define SO_BROADCAST 6
|
|
|
|
#define SO_SNDBUF 7
|
|
|
|
#define SO_RCVBUF 8
|
|
|
|
#define SO_KEEPALIVE 9
|
|
|
|
#define SO_OOBINLINE 10
|
|
|
|
#define SO_NO_CHECK 11
|
|
|
|
#define SO_PRIORITY 12
|
|
|
|
#define SO_LINGER 13
|
|
|
|
#define SO_BSDCOMPAT 14
|
2013-03-23 19:58:33 +00:00
|
|
|
#define SO_REUSEPORT 15
|
2011-09-18 20:34:13 +00:00
|
|
|
#define SO_PASSCRED 16
|
|
|
|
#define SO_PEERCRED 17
|
|
|
|
#define SO_RCVLOWAT 18
|
|
|
|
#define SO_SNDLOWAT 19
|
|
|
|
#define SO_RCVTIMEO 20
|
|
|
|
#define SO_SNDTIMEO 21
|
2015-07-02 09:28:41 +00:00
|
|
|
#define SO_ACCEPTCONN 30
|
2012-12-19 18:02:22 +00:00
|
|
|
#define SO_SNDBUFFORCE 32
|
|
|
|
#define SO_RCVBUFFORCE 33
|
2015-07-02 09:28:41 +00:00
|
|
|
#define SO_PROTOCOL 38
|
|
|
|
#define SO_DOMAIN 39
|
2012-11-05 19:29:04 +00:00
|
|
|
#endif
|
|
|
|
|
2011-09-18 20:34:13 +00:00
|
|
|
#define SO_SECURITY_AUTHENTICATION 22
|
|
|
|
#define SO_SECURITY_ENCRYPTION_TRANSPORT 23
|
|
|
|
#define SO_SECURITY_ENCRYPTION_NETWORK 24
|
|
|
|
|
|
|
|
#define SO_BINDTODEVICE 25
|
|
|
|
|
|
|
|
#define SO_ATTACH_FILTER 26
|
|
|
|
#define SO_DETACH_FILTER 27
|
2013-03-23 19:58:33 +00:00
|
|
|
#define SO_GET_FILTER SO_ATTACH_FILTER
|
2011-09-18 20:34:13 +00:00
|
|
|
|
|
|
|
#define SO_PEERNAME 28
|
|
|
|
#define SO_TIMESTAMP 29
|
|
|
|
#define SCM_TIMESTAMP SO_TIMESTAMP
|
|
|
|
|
2013-03-23 19:58:33 +00:00
|
|
|
#define SO_PEERSEC 31
|
|
|
|
#define SO_PASSSEC 34
|
|
|
|
#define SO_TIMESTAMPNS 35
|
|
|
|
#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
|
|
|
|
#define SO_MARK 36
|
|
|
|
#define SO_TIMESTAMPING 37
|
|
|
|
#define SCM_TIMESTAMPING SO_TIMESTAMPING
|
|
|
|
#define SO_RXQ_OVFL 40
|
|
|
|
#define SO_WIFI_STATUS 41
|
|
|
|
#define SCM_WIFI_STATUS SO_WIFI_STATUS
|
|
|
|
#define SO_PEEK_OFF 42
|
|
|
|
#define SO_NOFCS 43
|
|
|
|
#define SO_LOCK_FILTER 44
|
2013-07-24 20:52:30 +00:00
|
|
|
#define SO_SELECT_ERR_QUEUE 45
|
2013-09-15 04:54:19 +00:00
|
|
|
#define SO_BUSY_POLL 46
|
2014-02-24 23:22:04 +00:00
|
|
|
#define SO_MAX_PACING_RATE 47
|
2014-05-30 12:07:59 +00:00
|
|
|
#define SO_BPF_EXTENSIONS 48
|
2015-02-09 21:22:13 +00:00
|
|
|
#define SO_INCOMING_CPU 49
|
|
|
|
#define SO_ATTACH_BPF 50
|
|
|
|
#define SO_DETACH_BPF SO_DETACH_FILTER
|
2016-03-19 12:36:42 +00:00
|
|
|
#define SO_ATTACH_REUSEPORT_CBPF 51
|
|
|
|
#define SO_ATTACH_REUSEPORT_EBPF 52
|
2016-05-26 20:05:25 +00:00
|
|
|
#define SO_CNX_ADVICE 53
|
2011-09-18 20:34:13 +00:00
|
|
|
|
2012-11-05 19:29:04 +00:00
|
|
|
#ifndef SOL_SOCKET
|
2011-09-18 20:34:13 +00:00
|
|
|
#define SOL_SOCKET 1
|
2012-11-05 19:29:04 +00:00
|
|
|
#endif
|
2011-09-18 20:34:13 +00:00
|
|
|
|
fix remaining known namespace violations for netinet/in.h
the imr_, imsf_, ip6_, ip6m_, ipi_, ipi6_, SCM_, and SOL_ prefixes are
not in the reserved namespace for this header. thus the constants and
structures using them need to be protected under appropriate feature
test macros.
this also affects some headers which are permitted to include
netinet/in.h, particularly netdb.h and arpa/inet.h.
the SOL_ macros are moved to sys/socket.h where they are in the
reserved namespace (SO*). they are still accessible via netinet/in.h
since it includes sys/socket.h implicitly (which is permitted).
the SCM_SRCRT macro is simply removed, since the definition used for
it, IPV6_RXSRCRT is not defined anywhere. it could be re-added, this
time in sys/socket.h, if the appropriate value can be determined;
however, given that the erroneous definition was not caught, it is
unlikely that any software actually attempts to use SCM_SRCRT.
2014-01-08 23:54:33 +00:00
|
|
|
#define SOL_IP 0
|
|
|
|
#define SOL_IPV6 41
|
|
|
|
#define SOL_ICMPV6 58
|
|
|
|
|
2011-09-18 20:34:13 +00:00
|
|
|
#define SOL_RAW 255
|
|
|
|
#define SOL_DECNET 261
|
|
|
|
#define SOL_X25 262
|
|
|
|
#define SOL_PACKET 263
|
|
|
|
#define SOL_ATM 264
|
|
|
|
#define SOL_AAL 265
|
|
|
|
#define SOL_IRDA 266
|
2016-05-26 20:07:32 +00:00
|
|
|
#define SOL_NETBEUI 267
|
|
|
|
#define SOL_LLC 268
|
|
|
|
#define SOL_DCCP 269
|
|
|
|
#define SOL_NETLINK 270
|
|
|
|
#define SOL_TIPC 271
|
|
|
|
#define SOL_RXRPC 272
|
|
|
|
#define SOL_PPPOL2TP 273
|
|
|
|
#define SOL_BLUETOOTH 274
|
|
|
|
#define SOL_PNPIPE 275
|
|
|
|
#define SOL_RDS 276
|
|
|
|
#define SOL_IUCV 277
|
|
|
|
#define SOL_CAIF 278
|
|
|
|
#define SOL_ALG 279
|
|
|
|
#define SOL_NFC 280
|
|
|
|
#define SOL_KCM 281
|
2011-09-18 20:34:13 +00:00
|
|
|
|
|
|
|
#define SOMAXCONN 128
|
|
|
|
|
|
|
|
#define MSG_OOB 0x0001
|
|
|
|
#define MSG_PEEK 0x0002
|
|
|
|
#define MSG_DONTROUTE 0x0004
|
|
|
|
#define MSG_CTRUNC 0x0008
|
|
|
|
#define MSG_PROXY 0x0010
|
|
|
|
#define MSG_TRUNC 0x0020
|
|
|
|
#define MSG_DONTWAIT 0x0040
|
|
|
|
#define MSG_EOR 0x0080
|
|
|
|
#define MSG_WAITALL 0x0100
|
|
|
|
#define MSG_FIN 0x0200
|
2013-10-18 15:19:49 +00:00
|
|
|
#define MSG_SYN 0x0400
|
2011-09-18 20:34:13 +00:00
|
|
|
#define MSG_CONFIRM 0x0800
|
|
|
|
#define MSG_RST 0x1000
|
|
|
|
#define MSG_ERRQUEUE 0x2000
|
|
|
|
#define MSG_NOSIGNAL 0x4000
|
|
|
|
#define MSG_MORE 0x8000
|
|
|
|
#define MSG_WAITFORONE 0x10000
|
2016-05-26 20:07:32 +00:00
|
|
|
#define MSG_BATCH 0x40000
|
2015-06-26 20:27:37 +00:00
|
|
|
#define MSG_FASTOPEN 0x20000000
|
2011-09-18 20:34:13 +00:00
|
|
|
#define MSG_CMSG_CLOEXEC 0x40000000
|
|
|
|
|
|
|
|
#define __CMSG_LEN(cmsg) (((cmsg)->cmsg_len + sizeof(long) - 1) & ~(long)(sizeof(long) - 1))
|
|
|
|
#define __CMSG_NEXT(cmsg) ((unsigned char *)(cmsg) + __CMSG_LEN(cmsg))
|
|
|
|
#define __MHDR_END(mhdr) ((unsigned char *)(mhdr)->msg_control + (mhdr)->msg_controllen)
|
|
|
|
|
|
|
|
#define CMSG_DATA(cmsg) ((unsigned char *) (((struct cmsghdr *)(cmsg)) + 1))
|
2016-05-22 22:49:59 +00:00
|
|
|
#define CMSG_NXTHDR(mhdr, cmsg) ((cmsg)->cmsg_len < sizeof (struct cmsghdr) || \
|
|
|
|
__CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) - (unsigned char *)(cmsg) \
|
|
|
|
? 0 : (struct cmsghdr *)__CMSG_NEXT(cmsg))
|
2011-09-18 20:34:13 +00:00
|
|
|
#define CMSG_FIRSTHDR(mhdr) ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0)
|
|
|
|
|
|
|
|
#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1))
|
|
|
|
#define CMSG_SPACE(len) (CMSG_ALIGN (len) + CMSG_ALIGN (sizeof (struct cmsghdr)))
|
|
|
|
#define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
|
|
|
|
|
|
|
|
#define SCM_RIGHTS 0x01
|
|
|
|
#define SCM_CREDENTIALS 0x02
|
|
|
|
|
2016-07-03 18:40:11 +00:00
|
|
|
struct sockaddr {
|
2011-02-12 05:22:29 +00:00
|
|
|
sa_family_t sa_family;
|
|
|
|
char sa_data[14];
|
|
|
|
};
|
|
|
|
|
2016-07-03 18:40:11 +00:00
|
|
|
struct sockaddr_storage {
|
2011-02-12 05:22:29 +00:00
|
|
|
sa_family_t ss_family;
|
2016-06-09 17:42:06 +00:00
|
|
|
char __ss_padding[128-sizeof(long)-sizeof(sa_family_t)];
|
2013-03-04 22:05:45 +00:00
|
|
|
unsigned long __ss_align;
|
2011-02-12 05:22:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int socket (int, int, int);
|
|
|
|
int socketpair (int, int, int, int [2]);
|
|
|
|
|
|
|
|
int shutdown (int, int);
|
|
|
|
|
|
|
|
int bind (int, const struct sockaddr *, socklen_t);
|
|
|
|
int connect (int, const struct sockaddr *, socklen_t);
|
|
|
|
int listen (int, int);
|
2012-09-07 02:44:55 +00:00
|
|
|
int accept (int, struct sockaddr *__restrict, socklen_t *__restrict);
|
2012-09-29 21:44:33 +00:00
|
|
|
int accept4(int, struct sockaddr *__restrict, socklen_t *__restrict, int);
|
2011-02-12 05:22:29 +00:00
|
|
|
|
2012-09-07 02:44:55 +00:00
|
|
|
int getsockname (int, struct sockaddr *__restrict, socklen_t *__restrict);
|
|
|
|
int getpeername (int, struct sockaddr *__restrict, socklen_t *__restrict);
|
2011-02-12 05:22:29 +00:00
|
|
|
|
|
|
|
ssize_t send (int, const void *, size_t, int);
|
|
|
|
ssize_t recv (int, void *, size_t, int);
|
|
|
|
ssize_t sendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t);
|
2012-09-07 02:44:55 +00:00
|
|
|
ssize_t recvfrom (int, void *__restrict, size_t, int, struct sockaddr *__restrict, socklen_t *__restrict);
|
2011-02-12 05:22:29 +00:00
|
|
|
ssize_t sendmsg (int, const struct msghdr *, int);
|
|
|
|
ssize_t recvmsg (int, struct msghdr *, int);
|
|
|
|
|
2012-09-07 02:44:55 +00:00
|
|
|
int getsockopt (int, int, int, void *__restrict, socklen_t *__restrict);
|
2011-02-12 05:22:29 +00:00
|
|
|
int setsockopt (int, int, int, const void *, socklen_t);
|
|
|
|
|
|
|
|
int sockatmark (int);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|