123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335 |
- #ifndef __BITS_SOCKET_H
- #define __BITS_SOCKET_H
- #if !defined _SYS_SOCKET_H && !defined _NETINET_IN_H
- # error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
- #endif
- #define __need_size_t
- #define __need_NULL
- #include <stddef.h>
- #include <limits.h>
- #include <sys/types.h>
- #ifndef __socklen_t_defined
- typedef __socklen_t socklen_t;
- # define __socklen_t_defined
- #endif
- enum __socket_type
- {
- SOCK_DGRAM = 1,
- #define SOCK_DGRAM SOCK_DGRAM
- SOCK_STREAM = 2,
- #define SOCK_STREAM SOCK_STREAM
- SOCK_RAW = 3,
- #define SOCK_RAW SOCK_RAW
- SOCK_RDM = 4,
- #define SOCK_RDM SOCK_RDM
- SOCK_SEQPACKET = 5,
- #define SOCK_SEQPACKET SOCK_SEQPACKET
- SOCK_PACKET = 10
- #define SOCK_PACKET SOCK_PACKET
- };
- #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
- #define PF_SNA 22
- #define PF_IRDA 23
- #define PF_PPPOX 24
- #define PF_WANPIPE 25
- #define PF_BLUETOOTH 31
- #define PF_MAX 32
- #define AF_UNSPEC PF_UNSPEC
- #define AF_LOCAL PF_LOCAL
- #define AF_UNIX PF_UNIX
- #define AF_FILE PF_FILE
- #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
- #define AF_SNA PF_SNA
- #define AF_IRDA PF_IRDA
- #define AF_PPPOX PF_PPPOX
- #define AF_WANPIPE PF_WANPIPE
- #define AF_BLUETOOTH PF_BLUETOOTH
- #define AF_MAX PF_MAX
- #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
- #define SOMAXCONN 128
- #include <bits/sockaddr.h>
- struct sockaddr
- {
- __SOCKADDR_COMMON (sa_);
- char sa_data[14];
- };
- #if ULONG_MAX > 0xffffffff
- # define __ss_aligntype __uint64_t
- #else
- # define __ss_aligntype __uint32_t
- #endif
- #define _SS_SIZE 128
- #define _SS_PADSIZE (_SS_SIZE - (2 * sizeof (__ss_aligntype)))
- struct sockaddr_storage
- {
- __SOCKADDR_COMMON (ss_);
- __ss_aligntype __ss_align;
- char __ss_padding[_SS_PADSIZE];
- };
- enum
- {
- MSG_OOB = 0x01,
- #define MSG_OOB MSG_OOB
- MSG_PEEK = 0x02,
- #define MSG_PEEK MSG_PEEK
- MSG_DONTROUTE = 0x04,
- #define MSG_DONTROUTE MSG_DONTROUTE
- #ifdef __USE_GNU
-
- MSG_TRYHARD = MSG_DONTROUTE,
- # define MSG_TRYHARD MSG_DONTROUTE
- #endif
- MSG_CTRUNC = 0x08,
- #define MSG_CTRUNC MSG_CTRUNC
- MSG_PROXY = 0x10,
- #define MSG_PROXY MSG_PROXY
- MSG_TRUNC = 0x20,
- #define MSG_TRUNC MSG_TRUNC
- MSG_DONTWAIT = 0x40,
- #define MSG_DONTWAIT MSG_DONTWAIT
- MSG_EOR = 0x80,
- #define MSG_EOR MSG_EOR
- MSG_WAITALL = 0x100,
- #define MSG_WAITALL MSG_WAITALL
- MSG_FIN = 0x200,
- #define MSG_FIN MSG_FIN
- MSG_SYN = 0x400,
- #define MSG_SYN MSG_SYN
- MSG_CONFIRM = 0x800,
- #define MSG_CONFIRM MSG_CONFIRM
- MSG_RST = 0x1000,
- #define MSG_RST MSG_RST
- MSG_ERRQUEUE = 0x2000,
- #define MSG_ERRQUEUE MSG_ERRQUEUE
- MSG_NOSIGNAL = 0x4000,
- #define MSG_NOSIGNAL MSG_NOSIGNAL
- MSG_MORE = 0x8000
- #define MSG_MORE MSG_MORE
- };
- struct msghdr
- {
- void *msg_name;
- socklen_t msg_namelen;
- struct iovec *msg_iov;
- #if __WORDSIZE == 32
- int msg_iovlen;
- #else
- size_t msg_iovlen;
- #endif
- void *msg_control;
- #if __WORDSIZE == 32
- socklen_t msg_controllen;
- #else
- size_t msg_controllen;
- #endif
- int msg_flags;
- };
- struct cmsghdr
- {
- size_t cmsg_len;
- int cmsg_level;
- int cmsg_type;
- #if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L
- __extension__ unsigned char __cmsg_data __flexarr;
- #endif
- };
- #if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L
- # define CMSG_DATA(cmsg) ((cmsg)->__cmsg_data)
- #else
- # define CMSG_DATA(cmsg) ((unsigned char *) ((struct cmsghdr *) (cmsg) + 1))
- #endif
- #define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg)
- #define CMSG_FIRSTHDR(mhdr) \
- ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) \
- ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) NULL)
- #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))
- extern struct cmsghdr *__cmsg_nxthdr (struct msghdr *__mhdr,
- struct cmsghdr *__cmsg) __THROW;
- libc_hidden_proto(__cmsg_nxthdr)
- #ifdef __USE_EXTERN_INLINES
- # ifndef _EXTERN_INLINE
- # define _EXTERN_INLINE extern __inline
- # endif
- _EXTERN_INLINE struct cmsghdr *
- __NTH (__cmsg_nxthdr (struct msghdr *__mhdr, struct cmsghdr *__cmsg))
- {
- if ((size_t) __cmsg->cmsg_len < sizeof (struct cmsghdr))
-
- return 0;
- __cmsg = (struct cmsghdr *) ((unsigned char *) __cmsg
- + CMSG_ALIGN (__cmsg->cmsg_len));
- if ((unsigned char *) (__cmsg + 1) > ((unsigned char *) __mhdr->msg_control
- + __mhdr->msg_controllen)
- || ((unsigned char *) __cmsg + CMSG_ALIGN (__cmsg->cmsg_len)
- > ((unsigned char *) __mhdr->msg_control + __mhdr->msg_controllen)))
-
- return 0;
- return __cmsg;
- }
- #endif
- enum
- {
- SCM_RIGHTS = 0x01
- #define SCM_RIGHTS SCM_RIGHTS
- #ifdef __USE_BSD
- , SCM_CREDENTIALS = 0x02
- # define SCM_CREDENTIALS SCM_CREDENTIALS
- #endif
- };
- struct ucred
- {
- pid_t pid;
- uid_t uid;
- gid_t gid;
- };
- #ifndef __GLIBC__
- #define __GLIBC__ 2
- #include <asm/socket.h>
- #undef __GLIBC__
- #else
- #include <asm/socket.h>
- #endif
- struct linger
- {
- int l_onoff;
- int l_linger;
- };
- #endif
|