b32306254fe016a4239a3e7af3575f2734218066
[musl] / include / bits / socket.h
1 struct msghdr
2 {
3         void *msg_name;
4         socklen_t msg_namelen;
5         struct iovec *msg_iov;
6         int msg_iovlen;
7         void *msg_control;
8         socklen_t msg_controllen;
9         int msg_flags;
10 };
11
12 struct cmsghdr
13 {
14         socklen_t cmsg_len;
15         int cmsg_level;
16         int cmsg_type;
17 };
18
19 struct ucred
20 {
21         pid_t pid;
22         uid_t uid;
23         gid_t gid;
24 };
25
26 struct linger
27 {
28         int l_onoff;
29         int l_linger;
30 };
31
32 #define SHUT_RD 0
33 #define SHUT_WD 1
34 #define SHUT_RDWR 2
35
36 #define SOCK_STREAM    1
37 #define SOCK_DGRAM     2
38 #define SOCK_RAW       3
39 #define SOCK_RDM       4
40 #define SOCK_SEQPACKET 5
41 #define SOCK_DCCP      6
42 #define SOCK_PACKET    10
43
44 /* linux extensions */
45 #define SOCK_CLOEXEC   02000000
46 #define SOCK_NONBLOCK  04000
47
48 #define PF_UNSPEC       0
49 #define PF_LOCAL        1
50 #define PF_UNIX         PF_LOCAL
51 #define PF_FILE         PF_LOCAL
52 #define PF_INET         2
53 #define PF_AX25         3
54 #define PF_IPX          4
55 #define PF_APPLETALK    5
56 #define PF_NETROM       6
57 #define PF_BRIDGE       7
58 #define PF_ATMPVC       8
59 #define PF_X25          9
60 #define PF_INET6        10
61 #define PF_ROSE         11
62 #define PF_DECnet       12
63 #define PF_NETBEUI      13
64 #define PF_SECURITY     14
65 #define PF_KEY          15
66 #define PF_NETLINK      16
67 #define PF_ROUTE        PF_NETLINK
68 #define PF_PACKET       17
69 #define PF_ASH          18
70 #define PF_ECONET       19
71 #define PF_ATMSVC       20
72 #define PF_SNA          22
73 #define PF_IRDA         23
74 #define PF_PPPOX        24
75 #define PF_WANPIPE      25
76 #define PF_BLUETOOTH    31
77 #define PF_IUCV         32
78 #define PF_RXRPC        33
79 #define PF_ISDN         34
80 #define PF_PHONET       35
81 #define PF_IEEE802154   36
82 #define PF_CAIF         37
83 #define PF_ALG          38
84 #define PF_MAX          39
85
86 #define AF_UNSPEC       PF_UNSPEC
87 #define AF_LOCAL        PF_LOCAL
88 #define AF_UNIX         AF_LOCAL
89 #define AF_FILE         AF_LOCAL
90 #define AF_INET         PF_INET
91 #define AF_AX25         PF_AX25
92 #define AF_IPX          PF_IPX
93 #define AF_APPLETALK    PF_APPLETALK
94 #define AF_NETROM       PF_NETROM
95 #define AF_BRIDGE       PF_BRIDGE
96 #define AF_ATMPVC       PF_ATMPVC
97 #define AF_X25          PF_X25
98 #define AF_INET6        PF_INET6
99 #define AF_ROSE         PF_ROSE
100 #define AF_DECnet       PF_DECnet
101 #define AF_NETBEUI      PF_NETBEUI
102 #define AF_SECURITY     PF_SECURITY
103 #define AF_KEY          PF_KEY
104 #define AF_NETLINK      PF_NETLINK
105 #define AF_ROUTE        AF_NETLINK
106 #define AF_PACKET       PF_PACKET
107 #define AF_ASH          PF_ASH
108 #define AF_ECONET       PF_ECONET
109 #define AF_ATMSVC       PF_ATMSVC
110 #define AF_SNA          PF_SNA
111 #define AF_IRDA         PF_IRDA
112 #define AF_PPPOX        PF_PPPOX
113 #define AF_WANPIPE      PF_WANPIPE
114 #define AF_BLUETOOTH    PF_BLUETOOTH
115 #define AF_IUCV         PF_IUCV
116 #define AF_RXRPC        PF_RXRPC
117 #define AF_ISDN         PF_ISDN
118 #define AF_PHONET       PF_PHONET
119 #define AF_IEEE802154   PF_IEEE802154
120 #define AF_CAIF         PF_CAIF
121 #define AF_ALG          PF_ALG
122 #define AF_MAX          PF_MAX
123
124 #define SO_DEBUG        1
125 #define SO_REUSEADDR    2
126 #define SO_TYPE         3
127 #define SO_ERROR        4
128 #define SO_DONTROUTE    5
129 #define SO_BROADCAST    6
130 #define SO_SNDBUF       7
131 #define SO_RCVBUF       8
132 #define SO_KEEPALIVE    9
133 #define SO_OOBINLINE    10
134 #define SO_NO_CHECK     11
135 #define SO_PRIORITY     12
136 #define SO_LINGER       13
137 #define SO_BSDCOMPAT    14
138 #define SO_REUSEPORT    15
139 #define SO_PASSCRED     16
140 #define SO_PEERCRED     17
141 #define SO_RCVLOWAT     18
142 #define SO_SNDLOWAT     19
143 #define SO_RCVTIMEO     20
144 #define SO_SNDTIMEO     21
145
146 #define SO_SECURITY_AUTHENTICATION              22
147 #define SO_SECURITY_ENCRYPTION_TRANSPORT        23
148 #define SO_SECURITY_ENCRYPTION_NETWORK          24
149
150 #define SO_BINDTODEVICE 25
151
152 #define SO_ATTACH_FILTER        26
153 #define SO_DETACH_FILTER        27
154
155 #define SO_PEERNAME             28
156 #define SO_TIMESTAMP            29
157 #define SCM_TIMESTAMP           SO_TIMESTAMP
158
159 #define SO_ACCEPTCONN           30
160
161 #define SOL_SOCKET      1
162
163 /* ??? */
164 #define SOL_RAW         255
165 #define SOL_DECNET      261
166 #define SOL_X25         262
167 #define SOL_PACKET      263
168 #define SOL_ATM         264
169 #define SOL_AAL         265
170 #define SOL_IRDA        266
171
172 #define SOMAXCONN       128
173
174 #define MSG_OOB       0x0001
175 #define MSG_PEEK      0x0002
176 #define MSG_DONTROUTE 0x0004
177 #define MSG_CTRUNC    0x0008
178 #define MSG_PROXY     0x0010
179 #define MSG_TRUNC     0x0020
180 #define MSG_DONTWAIT  0x0040
181 #define MSG_EOR       0x0080
182 #define MSG_WAITALL   0x0100
183 #define MSG_FIN       0x0200
184 #define MSD_SYN       0x0400
185 #define MSG_CONFIRM   0x0800
186 #define MSG_RST       0x1000
187 #define MSG_ERRQUEUE  0x2000
188 #define MSG_NOSIGNAL  0x4000
189 #define MSG_MORE      0x8000
190 #define MSG_WAITFORONE 0x10000
191 #define MSG_CMSG_CLOEXEC 0x40000000
192
193 /* Internal use only!! to make CMSG_NXTHDR definition readable by mortals */
194 #define __CMSG_LEN(cmsg) (((cmsg)->cmsg_len + sizeof(long) - 1) & ~(long)(sizeof(long) - 1))
195 #define __CMSG_NEXT(cmsg) ((unsigned char *)(cmsg) + __CMSG_LEN(cmsg))
196 #define __MHDR_END(mhdr) ((unsigned char *)(mhdr)->msg_control + (mhdr)->msg_controllen)
197
198 #define CMSG_DATA(cmsg) ((unsigned char *) (((struct cmsghdr *)(cmsg)) + 1))
199 #define CMSG_NXTHDR(mhdr, cmsg) ((cmsg)->cmsg_len < sizeof (struct cmsghdr) ? (struct cmsghdr *)0 : \
200         (__CMSG_NEXT(cmsg) + sizeof (struct cmsghdr) >= __MHDR_END(mhdr) ? (struct cmsghdr *)0 : \
201         ((struct cmsghdr *)__CMSG_NEXT(cmsg))))
202 #define CMSG_FIRSTHDR(mhdr) ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0)
203
204 /* Are these valid? */
205 #define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1))
206 #define CMSG_SPACE(len) (CMSG_ALIGN (len) + CMSG_ALIGN (sizeof (struct cmsghdr)))
207 #define CMSG_LEN(len)   (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
208
209 #define SCM_RIGHTS      0x01
210 #define SCM_CREDENTIALS 0x02