move dlinfo out of dynlink.c
[musl] / include / sys / socket.h
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 #ifdef _GNU_SOURCE
23 struct ucred
24 {
25         pid_t pid;
26         uid_t uid;
27         gid_t gid;
28 };
29
30 struct mmsghdr
31 {
32         struct msghdr msg_hdr;
33         unsigned int  msg_len;
34 };
35
36 struct timespec;
37
38 int sendmmsg (int, struct mmsghdr *, unsigned int, unsigned int);
39 int recvmmsg (int, struct mmsghdr *, unsigned int, unsigned int, struct timespec *);
40 #endif
41
42 struct linger
43 {
44         int l_onoff;
45         int l_linger;
46 };
47
48 #define SHUT_RD 0
49 #define SHUT_WR 1
50 #define SHUT_RDWR 2
51
52 #ifndef SOCK_STREAM
53 #define SOCK_STREAM    1
54 #define SOCK_DGRAM     2
55 #endif
56
57 #define SOCK_RAW       3
58 #define SOCK_RDM       4
59 #define SOCK_SEQPACKET 5
60 #define SOCK_DCCP      6
61 #define SOCK_PACKET    10
62
63 #ifndef SOCK_CLOEXEC
64 #define SOCK_CLOEXEC   02000000
65 #define SOCK_NONBLOCK  04000
66 #endif
67
68 #define PF_UNSPEC       0
69 #define PF_LOCAL        1
70 #define PF_UNIX         PF_LOCAL
71 #define PF_FILE         PF_LOCAL
72 #define PF_INET         2
73 #define PF_AX25         3
74 #define PF_IPX          4
75 #define PF_APPLETALK    5
76 #define PF_NETROM       6
77 #define PF_BRIDGE       7
78 #define PF_ATMPVC       8
79 #define PF_X25          9
80 #define PF_INET6        10
81 #define PF_ROSE         11
82 #define PF_DECnet       12
83 #define PF_NETBEUI      13
84 #define PF_SECURITY     14
85 #define PF_KEY          15
86 #define PF_NETLINK      16
87 #define PF_ROUTE        PF_NETLINK
88 #define PF_PACKET       17
89 #define PF_ASH          18
90 #define PF_ECONET       19
91 #define PF_ATMSVC       20
92 #define PF_RDS          21
93 #define PF_SNA          22
94 #define PF_IRDA         23
95 #define PF_PPPOX        24
96 #define PF_WANPIPE      25
97 #define PF_LLC          26
98 #define PF_IB           27
99 #define PF_MPLS         28
100 #define PF_CAN          29
101 #define PF_TIPC         30
102 #define PF_BLUETOOTH    31
103 #define PF_IUCV         32
104 #define PF_RXRPC        33
105 #define PF_ISDN         34
106 #define PF_PHONET       35
107 #define PF_IEEE802154   36
108 #define PF_CAIF         37
109 #define PF_ALG          38
110 #define PF_NFC          39
111 #define PF_VSOCK        40
112 #define PF_MAX          41
113
114 #define AF_UNSPEC       PF_UNSPEC
115 #define AF_LOCAL        PF_LOCAL
116 #define AF_UNIX         AF_LOCAL
117 #define AF_FILE         AF_LOCAL
118 #define AF_INET         PF_INET
119 #define AF_AX25         PF_AX25
120 #define AF_IPX          PF_IPX
121 #define AF_APPLETALK    PF_APPLETALK
122 #define AF_NETROM       PF_NETROM
123 #define AF_BRIDGE       PF_BRIDGE
124 #define AF_ATMPVC       PF_ATMPVC
125 #define AF_X25          PF_X25
126 #define AF_INET6        PF_INET6
127 #define AF_ROSE         PF_ROSE
128 #define AF_DECnet       PF_DECnet
129 #define AF_NETBEUI      PF_NETBEUI
130 #define AF_SECURITY     PF_SECURITY
131 #define AF_KEY          PF_KEY
132 #define AF_NETLINK      PF_NETLINK
133 #define AF_ROUTE        PF_ROUTE
134 #define AF_PACKET       PF_PACKET
135 #define AF_ASH          PF_ASH
136 #define AF_ECONET       PF_ECONET
137 #define AF_ATMSVC       PF_ATMSVC
138 #define AF_RDS          PF_RDS
139 #define AF_SNA          PF_SNA
140 #define AF_IRDA         PF_IRDA
141 #define AF_PPPOX        PF_PPPOX
142 #define AF_WANPIPE      PF_WANPIPE
143 #define AF_LLC          PF_LLC
144 #define AF_IB           PF_IB
145 #define AF_MPLS         PF_MPLS
146 #define AF_CAN          PF_CAN
147 #define AF_TIPC         PF_TIPC
148 #define AF_BLUETOOTH    PF_BLUETOOTH
149 #define AF_IUCV         PF_IUCV
150 #define AF_RXRPC        PF_RXRPC
151 #define AF_ISDN         PF_ISDN
152 #define AF_PHONET       PF_PHONET
153 #define AF_IEEE802154   PF_IEEE802154
154 #define AF_CAIF         PF_CAIF
155 #define AF_ALG          PF_ALG
156 #define AF_NFC          PF_NFC
157 #define AF_VSOCK        PF_VSOCK
158 #define AF_MAX          PF_MAX
159
160 #ifndef SO_DEBUG
161 #define SO_DEBUG        1
162 #define SO_REUSEADDR    2
163 #define SO_TYPE         3
164 #define SO_ERROR        4
165 #define SO_DONTROUTE    5
166 #define SO_BROADCAST    6
167 #define SO_SNDBUF       7
168 #define SO_RCVBUF       8
169 #define SO_KEEPALIVE    9
170 #define SO_OOBINLINE    10
171 #define SO_NO_CHECK     11
172 #define SO_PRIORITY     12
173 #define SO_LINGER       13
174 #define SO_BSDCOMPAT    14
175 #define SO_REUSEPORT    15
176 #define SO_PASSCRED     16
177 #define SO_PEERCRED     17
178 #define SO_RCVLOWAT     18
179 #define SO_SNDLOWAT     19
180 #define SO_RCVTIMEO     20
181 #define SO_SNDTIMEO     21
182 #define SO_ACCEPTCONN   30
183 #define SO_SNDBUFFORCE  32
184 #define SO_RCVBUFFORCE  33
185 #define SO_PROTOCOL     38
186 #define SO_DOMAIN       39
187 #endif
188
189 #define SO_SECURITY_AUTHENTICATION              22
190 #define SO_SECURITY_ENCRYPTION_TRANSPORT        23
191 #define SO_SECURITY_ENCRYPTION_NETWORK          24
192
193 #define SO_BINDTODEVICE 25
194
195 #define SO_ATTACH_FILTER        26
196 #define SO_DETACH_FILTER        27
197 #define SO_GET_FILTER           SO_ATTACH_FILTER
198
199 #define SO_PEERNAME             28
200 #define SO_TIMESTAMP            29
201 #define SCM_TIMESTAMP           SO_TIMESTAMP
202
203 #define SO_PEERSEC              31
204 #define SO_PASSSEC              34
205 #define SO_TIMESTAMPNS          35
206 #define SCM_TIMESTAMPNS         SO_TIMESTAMPNS
207 #define SO_MARK                 36
208 #define SO_TIMESTAMPING         37
209 #define SCM_TIMESTAMPING        SO_TIMESTAMPING
210 #define SO_RXQ_OVFL             40
211 #define SO_WIFI_STATUS          41
212 #define SCM_WIFI_STATUS         SO_WIFI_STATUS
213 #define SO_PEEK_OFF             42
214 #define SO_NOFCS                43
215 #define SO_LOCK_FILTER          44
216 #define SO_SELECT_ERR_QUEUE     45
217 #define SO_BUSY_POLL            46
218 #define SO_MAX_PACING_RATE      47
219 #define SO_BPF_EXTENSIONS       48
220 #define SO_INCOMING_CPU         49
221 #define SO_ATTACH_BPF           50
222 #define SO_DETACH_BPF           SO_DETACH_FILTER
223
224
225 #ifndef SOL_SOCKET
226 #define SOL_SOCKET      1
227 #endif
228
229 #define SOL_IP          0
230 #define SOL_IPV6        41
231 #define SOL_ICMPV6      58
232
233 #define SOL_RAW         255
234 #define SOL_DECNET      261
235 #define SOL_X25         262
236 #define SOL_PACKET      263
237 #define SOL_ATM         264
238 #define SOL_AAL         265
239 #define SOL_IRDA        266
240
241 #define SOMAXCONN       128
242
243 #define MSG_OOB       0x0001
244 #define MSG_PEEK      0x0002
245 #define MSG_DONTROUTE 0x0004
246 #define MSG_CTRUNC    0x0008
247 #define MSG_PROXY     0x0010
248 #define MSG_TRUNC     0x0020
249 #define MSG_DONTWAIT  0x0040
250 #define MSG_EOR       0x0080
251 #define MSG_WAITALL   0x0100
252 #define MSG_FIN       0x0200
253 #define MSG_SYN       0x0400
254 #define MSG_CONFIRM   0x0800
255 #define MSG_RST       0x1000
256 #define MSG_ERRQUEUE  0x2000
257 #define MSG_NOSIGNAL  0x4000
258 #define MSG_MORE      0x8000
259 #define MSG_WAITFORONE 0x10000
260 #define MSG_FASTOPEN  0x20000000
261 #define MSG_CMSG_CLOEXEC 0x40000000
262
263 #define __CMSG_LEN(cmsg) (((cmsg)->cmsg_len + sizeof(long) - 1) & ~(long)(sizeof(long) - 1))
264 #define __CMSG_NEXT(cmsg) ((unsigned char *)(cmsg) + __CMSG_LEN(cmsg))
265 #define __MHDR_END(mhdr) ((unsigned char *)(mhdr)->msg_control + (mhdr)->msg_controllen)
266
267 #define CMSG_DATA(cmsg) ((unsigned char *) (((struct cmsghdr *)(cmsg)) + 1))
268 #define CMSG_NXTHDR(mhdr, cmsg) ((cmsg)->cmsg_len < sizeof (struct cmsghdr) ? (struct cmsghdr *)0 : \
269         (__CMSG_NEXT(cmsg) + sizeof (struct cmsghdr) >= __MHDR_END(mhdr) ? (struct cmsghdr *)0 : \
270         ((struct cmsghdr *)__CMSG_NEXT(cmsg))))
271 #define CMSG_FIRSTHDR(mhdr) ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0)
272
273 #define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1))
274 #define CMSG_SPACE(len) (CMSG_ALIGN (len) + CMSG_ALIGN (sizeof (struct cmsghdr)))
275 #define CMSG_LEN(len)   (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
276
277 #define SCM_RIGHTS      0x01
278 #define SCM_CREDENTIALS 0x02
279
280 struct sockaddr
281 {
282         sa_family_t sa_family;
283         char sa_data[14];
284 };
285
286 struct sockaddr_storage
287 {
288         sa_family_t ss_family;
289         unsigned long __ss_align;
290         char __ss_padding[128-2*sizeof(unsigned long)];
291 };
292
293 int socket (int, int, int);
294 int socketpair (int, int, int, int [2]);
295
296 int shutdown (int, int);
297
298 int bind (int, const struct sockaddr *, socklen_t);
299 int connect (int, const struct sockaddr *, socklen_t);
300 int listen (int, int);
301 int accept (int, struct sockaddr *__restrict, socklen_t *__restrict);
302 int accept4(int, struct sockaddr *__restrict, socklen_t *__restrict, int);
303
304 int getsockname (int, struct sockaddr *__restrict, socklen_t *__restrict);
305 int getpeername (int, struct sockaddr *__restrict, socklen_t *__restrict);
306
307 ssize_t send (int, const void *, size_t, int);
308 ssize_t recv (int, void *, size_t, int);
309 ssize_t sendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t);
310 ssize_t recvfrom (int, void *__restrict, size_t, int, struct sockaddr *__restrict, socklen_t *__restrict);
311 ssize_t sendmsg (int, const struct msghdr *, int);
312 ssize_t recvmsg (int, struct msghdr *, int);
313
314 int getsockopt (int, int, int, void *__restrict, socklen_t *__restrict);
315 int setsockopt (int, int, int, const void *, socklen_t);
316
317 int sockatmark (int);
318
319 #ifdef __cplusplus
320 }
321 #endif
322 #endif