]>
Commit | Line | Data |
---|---|---|
df4ef2ab | 1 | /* System-specific socket constants and types. Linux version. |
568035b7 | 2 | Copyright (C) 1991-2013 Free Software Foundation, Inc. |
df4ef2ab UD |
3 | This file is part of the GNU C Library. |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
df4ef2ab UD |
9 | |
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
df4ef2ab | 14 | |
41bdb6e2 | 15 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
16 | License along with the GNU C Library; if not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
df4ef2ab | 18 | |
4bca4c17 UD |
19 | #ifndef __BITS_SOCKET_H |
20 | #define __BITS_SOCKET_H | |
21 | ||
d0b5557d | 22 | #ifndef _SYS_SOCKET_H |
f4017d20 | 23 | # error "Never include <bits/socket.h> directly; use <sys/socket.h> instead." |
5107cf1d UD |
24 | #endif |
25 | ||
df4ef2ab UD |
26 | #define __need_size_t |
27 | #include <stddef.h> | |
28 | ||
3996f34b | 29 | #include <sys/types.h> |
df4ef2ab | 30 | |
55c14926 | 31 | /* Type for length arguments in socket calls. */ |
750f9af6 UD |
32 | #ifndef __socklen_t_defined |
33 | typedef __socklen_t socklen_t; | |
34 | # define __socklen_t_defined | |
35 | #endif | |
55c14926 | 36 | |
02a6f887 JM |
37 | /* Get the architecture-dependent definition of enum __socket_type. */ |
38 | #include <bits/socket_type.h> | |
df4ef2ab UD |
39 | |
40 | /* Protocol families. */ | |
41 | #define PF_UNSPEC 0 /* Unspecified. */ | |
42 | #define PF_LOCAL 1 /* Local to host (pipes and file-domain). */ | |
d0b283a8 | 43 | #define PF_UNIX PF_LOCAL /* POSIX name for PF_LOCAL. */ |
71bedb76 | 44 | #define PF_FILE PF_LOCAL /* Another non-standard name for PF_LOCAL. */ |
df4ef2ab UD |
45 | #define PF_INET 2 /* IP protocol family. */ |
46 | #define PF_AX25 3 /* Amateur Radio AX.25. */ | |
47 | #define PF_IPX 4 /* Novell Internet Protocol. */ | |
bc38f31f | 48 | #define PF_APPLETALK 5 /* Appletalk DDP. */ |
df4ef2ab UD |
49 | #define PF_NETROM 6 /* Amateur radio NetROM. */ |
50 | #define PF_BRIDGE 7 /* Multiprotocol bridge. */ | |
bc38f31f | 51 | #define PF_ATMPVC 8 /* ATM PVCs. */ |
df4ef2ab UD |
52 | #define PF_X25 9 /* Reserved for X.25 project. */ |
53 | #define PF_INET6 10 /* IP version 6. */ | |
31161268 UD |
54 | #define PF_ROSE 11 /* Amateur Radio X.25 PLP. */ |
55 | #define PF_DECnet 12 /* Reserved for DECnet project. */ | |
56 | #define PF_NETBEUI 13 /* Reserved for 802.2LLC project. */ | |
57 | #define PF_SECURITY 14 /* Security callback pseudo AF. */ | |
58 | #define PF_KEY 15 /* PF_KEY key management API. */ | |
61952351 | 59 | #define PF_NETLINK 16 |
31161268 UD |
60 | #define PF_ROUTE PF_NETLINK /* Alias to emulate 4.4BSD. */ |
61 | #define PF_PACKET 17 /* Packet family. */ | |
62 | #define PF_ASH 18 /* Ash. */ | |
bc38f31f UD |
63 | #define PF_ECONET 19 /* Acorn Econet. */ |
64 | #define PF_ATMSVC 20 /* ATM SVCs. */ | |
a065c007 | 65 | #define PF_RDS 21 /* RDS sockets. */ |
b17277cf | 66 | #define PF_SNA 22 /* Linux SNA Project */ |
99356b9b AJ |
67 | #define PF_IRDA 23 /* IRDA sockets. */ |
68 | #define PF_PPPOX 24 /* PPPoX sockets. */ | |
d37286c1 | 69 | #define PF_WANPIPE 25 /* Wanpipe API sockets. */ |
a065c007 UD |
70 | #define PF_LLC 26 /* Linux LLC. */ |
71 | #define PF_CAN 29 /* Controller Area Network. */ | |
72 | #define PF_TIPC 30 /* TIPC sockets. */ | |
b3339de1 | 73 | #define PF_BLUETOOTH 31 /* Bluetooth sockets. */ |
34e0bbaf UD |
74 | #define PF_IUCV 32 /* IUCV sockets. */ |
75 | #define PF_RXRPC 33 /* RxRPC sockets. */ | |
11ed3eae | 76 | #define PF_ISDN 34 /* mISDN sockets. */ |
a065c007 | 77 | #define PF_PHONET 35 /* Phonet sockets. */ |
d0a2af71 | 78 | #define PF_IEEE802154 36 /* IEEE 802.15.4 sockets. */ |
a77e8cbc UD |
79 | #define PF_CAIF 37 /* CAIF sockets. */ |
80 | #define PF_ALG 38 /* Algorithm sockets. */ | |
8accd4dc UD |
81 | #define PF_NFC 39 /* NFC sockets. */ |
82 | #define PF_MAX 40 /* For now.. */ | |
df4ef2ab UD |
83 | |
84 | /* Address families. */ | |
85 | #define AF_UNSPEC PF_UNSPEC | |
86 | #define AF_LOCAL PF_LOCAL | |
87 | #define AF_UNIX PF_UNIX | |
f166d865 | 88 | #define AF_FILE PF_FILE |
df4ef2ab UD |
89 | #define AF_INET PF_INET |
90 | #define AF_AX25 PF_AX25 | |
91 | #define AF_IPX PF_IPX | |
92 | #define AF_APPLETALK PF_APPLETALK | |
93 | #define AF_NETROM PF_NETROM | |
94 | #define AF_BRIDGE PF_BRIDGE | |
bc38f31f | 95 | #define AF_ATMPVC PF_ATMPVC |
df4ef2ab UD |
96 | #define AF_X25 PF_X25 |
97 | #define AF_INET6 PF_INET6 | |
61952351 UD |
98 | #define AF_ROSE PF_ROSE |
99 | #define AF_DECnet PF_DECnet | |
100 | #define AF_NETBEUI PF_NETBEUI | |
101 | #define AF_SECURITY PF_SECURITY | |
d01d6319 | 102 | #define AF_KEY PF_KEY |
61952351 UD |
103 | #define AF_NETLINK PF_NETLINK |
104 | #define AF_ROUTE PF_ROUTE | |
105 | #define AF_PACKET PF_PACKET | |
7559b943 | 106 | #define AF_ASH PF_ASH |
bc38f31f UD |
107 | #define AF_ECONET PF_ECONET |
108 | #define AF_ATMSVC PF_ATMSVC | |
a065c007 | 109 | #define AF_RDS PF_RDS |
b17277cf | 110 | #define AF_SNA PF_SNA |
99356b9b AJ |
111 | #define AF_IRDA PF_IRDA |
112 | #define AF_PPPOX PF_PPPOX | |
d37286c1 | 113 | #define AF_WANPIPE PF_WANPIPE |
a065c007 UD |
114 | #define AF_LLC PF_LLC |
115 | #define AF_CAN PF_CAN | |
116 | #define AF_TIPC PF_TIPC | |
b3339de1 | 117 | #define AF_BLUETOOTH PF_BLUETOOTH |
34e0bbaf UD |
118 | #define AF_IUCV PF_IUCV |
119 | #define AF_RXRPC PF_RXRPC | |
11ed3eae | 120 | #define AF_ISDN PF_ISDN |
a065c007 | 121 | #define AF_PHONET PF_PHONET |
d0a2af71 | 122 | #define AF_IEEE802154 PF_IEEE802154 |
a77e8cbc UD |
123 | #define AF_CAIF PF_CAIF |
124 | #define AF_ALG PF_ALG | |
8accd4dc | 125 | #define AF_NFC PF_NFC |
df4ef2ab UD |
126 | #define AF_MAX PF_MAX |
127 | ||
c57abfa7 UD |
128 | /* Socket level values. Others are defined in the appropriate headers. |
129 | ||
130 | XXX These definitions also should go into the appropriate headers as | |
131 | far as they are available. */ | |
bdf289b2 | 132 | #define SOL_RAW 255 |
81e9dad6 UD |
133 | #define SOL_DECNET 261 |
134 | #define SOL_X25 262 | |
17c7887b UD |
135 | #define SOL_PACKET 263 |
136 | #define SOL_ATM 264 /* ATM layer (cell level). */ | |
137 | #define SOL_AAL 265 /* ATM Adaption Layer (packet level). */ | |
138 | #define SOL_IRDA 266 | |
df4ef2ab UD |
139 | |
140 | /* Maximum queue length specifiable by listen. */ | |
141 | #define SOMAXCONN 128 | |
142 | ||
143 | /* Get the definition of the macro to define the common sockaddr members. */ | |
5107cf1d | 144 | #include <bits/sockaddr.h> |
df4ef2ab UD |
145 | |
146 | /* Structure describing a generic socket address. */ | |
147 | struct sockaddr | |
148 | { | |
149 | __SOCKADDR_COMMON (sa_); /* Common data: address family and length. */ | |
150 | char sa_data[14]; /* Address data. */ | |
151 | }; | |
152 | ||
153 | ||
12b5b6b7 UD |
154 | /* Structure large enough to hold any socket address (with the historical |
155 | exception of AF_UNIX). We reserve 128 bytes. */ | |
a53d3f82 | 156 | #define __ss_aligntype unsigned long int |
12b5b6b7 UD |
157 | #define _SS_SIZE 128 |
158 | #define _SS_PADSIZE (_SS_SIZE - (2 * sizeof (__ss_aligntype))) | |
159 | ||
160 | struct sockaddr_storage | |
161 | { | |
6f0ea379 | 162 | __SOCKADDR_COMMON (ss_); /* Address family, etc. */ |
12b5b6b7 UD |
163 | __ss_aligntype __ss_align; /* Force desired alignment. */ |
164 | char __ss_padding[_SS_PADSIZE]; | |
165 | }; | |
166 | ||
167 | ||
df4ef2ab UD |
168 | /* Bits in the FLAGS argument to `send', `recv', et al. */ |
169 | enum | |
170 | { | |
171 | MSG_OOB = 0x01, /* Process out-of-band data. */ | |
12bf4b4a | 172 | #define MSG_OOB MSG_OOB |
df4ef2ab | 173 | MSG_PEEK = 0x02, /* Peek at incoming messages. */ |
12bf4b4a | 174 | #define MSG_PEEK MSG_PEEK |
df4ef2ab | 175 | MSG_DONTROUTE = 0x04, /* Don't use local routing. */ |
12bf4b4a | 176 | #define MSG_DONTROUTE MSG_DONTROUTE |
c5b0e13e UD |
177 | #ifdef __USE_GNU |
178 | /* DECnet uses a different name. */ | |
179 | MSG_TRYHARD = MSG_DONTROUTE, | |
180 | # define MSG_TRYHARD MSG_DONTROUTE | |
181 | #endif | |
df4ef2ab | 182 | MSG_CTRUNC = 0x08, /* Control data lost before delivery. */ |
12bf4b4a | 183 | #define MSG_CTRUNC MSG_CTRUNC |
fc370352 | 184 | MSG_PROXY = 0x10, /* Supply or ask second address. */ |
12bf4b4a | 185 | #define MSG_PROXY MSG_PROXY |
fc370352 UD |
186 | MSG_TRUNC = 0x20, |
187 | #define MSG_TRUNC MSG_TRUNC | |
188 | MSG_DONTWAIT = 0x40, /* Nonblocking IO. */ | |
7aa6d208 | 189 | #define MSG_DONTWAIT MSG_DONTWAIT |
fc370352 UD |
190 | MSG_EOR = 0x80, /* End of record. */ |
191 | #define MSG_EOR MSG_EOR | |
192 | MSG_WAITALL = 0x100, /* Wait for a full request. */ | |
193 | #define MSG_WAITALL MSG_WAITALL | |
194 | MSG_FIN = 0x200, | |
195 | #define MSG_FIN MSG_FIN | |
196 | MSG_SYN = 0x400, | |
197 | #define MSG_SYN MSG_SYN | |
64c81855 AJ |
198 | MSG_CONFIRM = 0x800, /* Confirm path validity. */ |
199 | #define MSG_CONFIRM MSG_CONFIRM | |
fc370352 UD |
200 | MSG_RST = 0x1000, |
201 | #define MSG_RST MSG_RST | |
d01d6319 | 202 | MSG_ERRQUEUE = 0x2000, /* Fetch message from error queue. */ |
fc370352 | 203 | #define MSG_ERRQUEUE MSG_ERRQUEUE |
d37286c1 | 204 | MSG_NOSIGNAL = 0x4000, /* Do not generate SIGPIPE. */ |
fc370352 | 205 | #define MSG_NOSIGNAL MSG_NOSIGNAL |
2c896315 | 206 | MSG_MORE = 0x8000, /* Sender will send more. */ |
d37286c1 | 207 | #define MSG_MORE MSG_MORE |
6d28d423 UD |
208 | MSG_WAITFORONE = 0x10000, /* Wait for at least one packet to return.*/ |
209 | #define MSG_WAITFORONE MSG_WAITFORONE | |
2c896315 UD |
210 | |
211 | MSG_CMSG_CLOEXEC = 0x40000000 /* Set close_on_exit for file | |
ee1a7fab UD |
212 | descriptor received through |
213 | SCM_RIGHTS. */ | |
2c896315 | 214 | #define MSG_CMSG_CLOEXEC MSG_CMSG_CLOEXEC |
df4ef2ab UD |
215 | }; |
216 | ||
217 | ||
218 | /* Structure describing messages sent by | |
219 | `sendmsg' and received by `recvmsg'. */ | |
220 | struct msghdr | |
221 | { | |
a73b0d84 | 222 | void *msg_name; /* Address to send to/receive from. */ |
55c14926 | 223 | socklen_t msg_namelen; /* Length of address data. */ |
df4ef2ab UD |
224 | |
225 | struct iovec *msg_iov; /* Vector of data to send/receive into. */ | |
c55dca8d | 226 | size_t msg_iovlen; /* Number of elements in the vector. */ |
df4ef2ab | 227 | |
a73b0d84 | 228 | void *msg_control; /* Ancillary data (eg BSD filedesc passing). */ |
6c7a5753 UD |
229 | size_t msg_controllen; /* Ancillary data buffer length. |
230 | !! The type should be socklen_t but the | |
231 | definition of the kernel is incompatible | |
232 | with this. */ | |
55c14926 | 233 | |
df4ef2ab UD |
234 | int msg_flags; /* Flags on received message. */ |
235 | }; | |
236 | ||
c0e45674 UD |
237 | /* Structure used for storage of ancillary data object information. */ |
238 | struct cmsghdr | |
239 | { | |
af6f3906 | 240 | size_t cmsg_len; /* Length of data in cmsg_data plus length |
6c7a5753 UD |
241 | of cmsghdr structure. |
242 | !! The type should be socklen_t but the | |
243 | definition of the kernel is incompatible | |
244 | with this. */ | |
c0e45674 UD |
245 | int cmsg_level; /* Originating protocol. */ |
246 | int cmsg_type; /* Protocol specific type. */ | |
23ac6e3a | 247 | #if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L |
cdb914c0 | 248 | __extension__ unsigned char __cmsg_data __flexarr; /* Ancillary data. */ |
23ac6e3a | 249 | #endif |
c0e45674 UD |
250 | }; |
251 | ||
252 | /* Ancillary data object manipulation macros. */ | |
23ac6e3a | 253 | #if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L |
7cc27f44 UD |
254 | # define CMSG_DATA(cmsg) ((cmsg)->__cmsg_data) |
255 | #else | |
256 | # define CMSG_DATA(cmsg) ((unsigned char *) ((struct cmsghdr *) (cmsg) + 1)) | |
257 | #endif | |
c0e45674 | 258 | #define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg) |
7cc27f44 | 259 | #define CMSG_FIRSTHDR(mhdr) \ |
bfbc5754 | 260 | ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) \ |
a53d3f82 | 261 | ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0) |
bfbc5754 | 262 | #define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) \ |
7c4c1a09 | 263 | & (size_t) ~(sizeof (size_t) - 1)) |
bfbc5754 UD |
264 | #define CMSG_SPACE(len) (CMSG_ALIGN (len) \ |
265 | + CMSG_ALIGN (sizeof (struct cmsghdr))) | |
266 | #define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len)) | |
c0e45674 | 267 | |
4d3a563f UD |
268 | extern struct cmsghdr *__cmsg_nxthdr (struct msghdr *__mhdr, |
269 | struct cmsghdr *__cmsg) __THROW; | |
dfd2464b UD |
270 | #ifdef __USE_EXTERN_INLINES |
271 | # ifndef _EXTERN_INLINE | |
b037a293 | 272 | # define _EXTERN_INLINE __extern_inline |
dfd2464b | 273 | # endif |
c0e45674 | 274 | _EXTERN_INLINE struct cmsghdr * |
f377d022 | 275 | __NTH (__cmsg_nxthdr (struct msghdr *__mhdr, struct cmsghdr *__cmsg)) |
c0e45674 | 276 | { |
c0e45674 UD |
277 | if ((size_t) __cmsg->cmsg_len < sizeof (struct cmsghdr)) |
278 | /* The kernel header does this so there may be a reason. */ | |
a7c8e6a1 | 279 | return (struct cmsghdr *) 0; |
c0e45674 | 280 | |
6ff5bc68 UD |
281 | __cmsg = (struct cmsghdr *) ((unsigned char *) __cmsg |
282 | + CMSG_ALIGN (__cmsg->cmsg_len)); | |
ad71126b UD |
283 | if ((unsigned char *) (__cmsg + 1) > ((unsigned char *) __mhdr->msg_control |
284 | + __mhdr->msg_controllen) | |
6ff5bc68 | 285 | || ((unsigned char *) __cmsg + CMSG_ALIGN (__cmsg->cmsg_len) |
d1646309 | 286 | > ((unsigned char *) __mhdr->msg_control + __mhdr->msg_controllen))) |
c0e45674 | 287 | /* No more entries. */ |
a7c8e6a1 | 288 | return (struct cmsghdr *) 0; |
6ff5bc68 | 289 | return __cmsg; |
c0e45674 | 290 | } |
dfd2464b | 291 | #endif /* Use `extern inline'. */ |
c0e45674 | 292 | |
af6f3906 UD |
293 | /* Socket level message types. This must match the definitions in |
294 | <linux/socket.h>. */ | |
295 | enum | |
296 | { | |
b639d0c9 | 297 | SCM_RIGHTS = 0x01 /* Transfer file descriptors. */ |
af6f3906 | 298 | #define SCM_RIGHTS SCM_RIGHTS |
135460f4 | 299 | #ifdef __USE_GNU |
b639d0c9 | 300 | , SCM_CREDENTIALS = 0x02 /* Credentials passing. */ |
7ce241a0 | 301 | # define SCM_CREDENTIALS SCM_CREDENTIALS |
ba9234d9 | 302 | #endif |
af6f3906 UD |
303 | }; |
304 | ||
a53d3f82 | 305 | #ifdef __USE_GNU |
7ce241a0 | 306 | /* User visible structure for SCM_CREDENTIALS message */ |
7ce241a0 | 307 | struct ucred |
ba9234d9 | 308 | { |
7ce241a0 UD |
309 | pid_t pid; /* PID of sending process. */ |
310 | uid_t uid; /* UID of sending process. */ | |
311 | gid_t gid; /* GID of sending process. */ | |
ba9234d9 | 312 | }; |
a53d3f82 UD |
313 | #endif |
314 | ||
315 | /* Ugly workaround for unclean kernel headers. */ | |
316 | #if !defined __USE_MISC && !defined __USE_GNU | |
317 | # ifndef FIOGETOWN | |
318 | # define __SYS_SOCKET_H_undef_FIOGETOWN | |
319 | # endif | |
320 | # ifndef FIOSETOWN | |
321 | # define __SYS_SOCKET_H_undef_FIOSETOWN | |
322 | # endif | |
323 | # ifndef SIOCATMARK | |
324 | # define __SYS_SOCKET_H_undef_SIOCATMARK | |
325 | # endif | |
326 | # ifndef SIOCGPGRP | |
327 | # define __SYS_SOCKET_H_undef_SIOCGPGRP | |
328 | # endif | |
329 | # ifndef SIOCGSTAMP | |
330 | # define __SYS_SOCKET_H_undef_SIOCGSTAMP | |
331 | # endif | |
332 | # ifndef SIOCGSTAMPNS | |
333 | # define __SYS_SOCKET_H_undef_SIOCGSTAMPNS | |
334 | # endif | |
335 | # ifndef SIOCSPGRP | |
336 | # define __SYS_SOCKET_H_undef_SIOCSPGRP | |
337 | # endif | |
338 | #endif | |
df4ef2ab UD |
339 | |
340 | /* Get socket manipulation related informations from kernel headers. */ | |
341 | #include <asm/socket.h> | |
342 | ||
a53d3f82 UD |
343 | #if !defined __USE_MISC && !defined __USE_GNU |
344 | # ifdef __SYS_SOCKET_H_undef_FIOGETOWN | |
345 | # undef __SYS_SOCKET_H_undef_FIOGETOWN | |
346 | # undef FIOGETOWN | |
347 | # endif | |
348 | # ifdef __SYS_SOCKET_H_undef_FIOSETOWN | |
349 | # undef __SYS_SOCKET_H_undef_FIOSETOWN | |
350 | # undef FIOSETOWN | |
351 | # endif | |
352 | # ifdef __SYS_SOCKET_H_undef_SIOCATMARK | |
353 | # undef __SYS_SOCKET_H_undef_SIOCATMARK | |
354 | # undef SIOCATMARK | |
355 | # endif | |
356 | # ifdef __SYS_SOCKET_H_undef_SIOCGPGRP | |
357 | # undef __SYS_SOCKET_H_undef_SIOCGPGRP | |
358 | # undef SIOCGPGRP | |
359 | # endif | |
360 | # ifdef __SYS_SOCKET_H_undef_SIOCGSTAMP | |
361 | # undef __SYS_SOCKET_H_undef_SIOCGSTAMP | |
362 | # undef SIOCGSTAMP | |
363 | # endif | |
364 | # ifdef __SYS_SOCKET_H_undef_SIOCGSTAMPNS | |
365 | # undef __SYS_SOCKET_H_undef_SIOCGSTAMPNS | |
366 | # undef SIOCGSTAMPNS | |
367 | # endif | |
368 | # ifdef __SYS_SOCKET_H_undef_SIOCSPGRP | |
369 | # undef __SYS_SOCKET_H_undef_SIOCSPGRP | |
370 | # undef SIOCSPGRP | |
371 | # endif | |
372 | #endif | |
df4ef2ab UD |
373 | |
374 | /* Structure used to manipulate the SO_LINGER option. */ | |
375 | struct linger | |
376 | { | |
377 | int l_onoff; /* Nonzero to linger on close. */ | |
378 | int l_linger; /* Time to linger. */ | |
379 | }; | |
4bca4c17 UD |
380 | |
381 | #endif /* bits/socket.h */ |