socket.h
001:
002:
003:
004:
005:
006:
007:
008:
009:
010:
011:
012:
013:
014:
015:
016:
017:
018:
019:
020:
021: #ifndef __BITS_SOCKET_H
022: #define __BITS_SOCKET_H
023:
024: #ifndef _SYS_SOCKET_H
025: # error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
026: #endif
027:
028: #define __need_size_t
029: #include <stddef.h>
030:
031: #include <sys/types.h>
032:
033:
034: #ifndef __socklen_t_defined
035: typedef __socklen_t socklen_t;
036: # define __socklen_t_defined
037: #endif
038:
039:
040: enum __socket_type
041: {
042: SOCK_STREAM = 1,
043:
044: #define SOCK_STREAM SOCK_STREAM
045: SOCK_DGRAM = 2,
046:
047: #define SOCK_DGRAM SOCK_DGRAM
048: SOCK_RAW = 3,
049: #define SOCK_RAW SOCK_RAW
050: SOCK_RDM = 4,
051: #define SOCK_RDM SOCK_RDM
052: SOCK_SEQPACKET = 5,
053:
054: #define SOCK_SEQPACKET SOCK_SEQPACKET
055: SOCK_DCCP = 6,
056: #define SOCK_DCCP SOCK_DCCP
057: SOCK_PACKET = 10,
058:
059:
060: #define SOCK_PACKET SOCK_PACKET
061:
062:
063:
064:
065: SOCK_CLOEXEC = 02000000,
066:
067: #define SOCK_CLOEXEC SOCK_CLOEXEC
068: SOCK_NONBLOCK = 04000
069:
070: #define SOCK_NONBLOCK SOCK_NONBLOCK
071: };
072:
073:
074: #define PF_UNSPEC 0
075: #define PF_LOCAL 1
076: #define PF_UNIX PF_LOCAL
077: #define PF_FILE PF_LOCAL
078: #define PF_INET 2
079: #define PF_AX25 3
080: #define PF_IPX 4
081: #define PF_APPLETALK 5
082: #define PF_NETROM 6
083: #define PF_BRIDGE 7
084: #define PF_ATMPVC 8
085: #define PF_X25 9
086: #define PF_INET6 10
087: #define PF_ROSE 11
088: #define PF_DECnet 12
089: #define PF_NETBEUI 13
090: #define PF_SECURITY 14
091: #define PF_KEY 15
092: #define PF_NETLINK 16
093: #define PF_ROUTE PF_NETLINK
094: #define PF_PACKET 17
095: #define PF_ASH 18
096: #define PF_ECONET 19
097: #define PF_ATMSVC 20
098: #define PF_RDS 21
099: #define PF_SNA 22
100: #define PF_IRDA 23
101: #define PF_PPPOX 24
102: #define PF_WANPIPE 25
103: #define PF_LLC 26
104: #define PF_CAN 29
105: #define PF_TIPC 30
106: #define PF_BLUETOOTH 31
107: #define PF_IUCV 32
108: #define PF_RXRPC 33
109: #define PF_ISDN 34
110: #define PF_PHONET 35
111: #define PF_IEEE802154 36
112: #define PF_CAIF 37
113: #define PF_ALG 38
114: #define PF_NFC 39
115: #define PF_MAX 40
116:
117:
118: #define AF_UNSPEC PF_UNSPEC
119: #define AF_LOCAL PF_LOCAL
120: #define AF_UNIX PF_UNIX
121: #define AF_FILE PF_FILE
122: #define AF_INET PF_INET
123: #define AF_AX25 PF_AX25
124: #define AF_IPX PF_IPX
125: #define AF_APPLETALK PF_APPLETALK
126: #define AF_NETROM PF_NETROM
127: #define AF_BRIDGE PF_BRIDGE
128: #define AF_ATMPVC PF_ATMPVC
129: #define AF_X25 PF_X25
130: #define AF_INET6 PF_INET6
131: #define AF_ROSE PF_ROSE
132: #define AF_DECnet PF_DECnet
133: #define AF_NETBEUI PF_NETBEUI
134: #define AF_SECURITY PF_SECURITY
135: #define AF_KEY PF_KEY
136: #define AF_NETLINK PF_NETLINK
137: #define AF_ROUTE PF_ROUTE
138: #define AF_PACKET PF_PACKET
139: #define AF_ASH PF_ASH
140: #define AF_ECONET PF_ECONET
141: #define AF_ATMSVC PF_ATMSVC
142: #define AF_RDS PF_RDS
143: #define AF_SNA PF_SNA
144: #define AF_IRDA PF_IRDA
145: #define AF_PPPOX PF_PPPOX
146: #define AF_WANPIPE PF_WANPIPE
147: #define AF_LLC PF_LLC
148: #define AF_CAN PF_CAN
149: #define AF_TIPC PF_TIPC
150: #define AF_BLUETOOTH PF_BLUETOOTH
151: #define AF_IUCV PF_IUCV
152: #define AF_RXRPC PF_RXRPC
153: #define AF_ISDN PF_ISDN
154: #define AF_PHONET PF_PHONET
155: #define AF_IEEE802154 PF_IEEE802154
156: #define AF_CAIF PF_CAIF
157: #define AF_ALG PF_ALG
158: #define AF_NFC PF_NFC
159: #define AF_MAX PF_MAX
160:
161:
162:
163:
164:
165: #define SOL_RAW 255
166: #define SOL_DECNET 261
167: #define SOL_X25 262
168: #define SOL_PACKET 263
169: #define SOL_ATM 264
170: #define SOL_AAL 265
171: #define SOL_IRDA 266
172:
173:
174: #define SOMAXCONN 128
175:
176:
177: #include <bits/sockaddr.h>
178:
179:
180: struct sockaddr
181: {
182: __SOCKADDR_COMMON (sa_);
183: char sa_data[14];
184: };
185:
186:
187:
188:
189: #define __ss_aligntype unsigned long int
190: #define _SS_SIZE 128
191: #define _SS_PADSIZE (_SS_SIZE - (2 * sizeof (__ss_aligntype)))
192:
193: struct sockaddr_storage
194: {
195: __SOCKADDR_COMMON (ss_);
196: __ss_aligntype __ss_align;
197: char __ss_padding[_SS_PADSIZE];
198: };
199:
200:
201:
202: enum
203: {
204: MSG_OOB = 0x01,
205: #define MSG_OOB MSG_OOB
206: MSG_PEEK = 0x02,
207: #define MSG_PEEK MSG_PEEK
208: MSG_DONTROUTE = 0x04,
209: #define MSG_DONTROUTE MSG_DONTROUTE
210: #ifdef __USE_GNU
211:
212: MSG_TRYHARD = MSG_DONTROUTE,
213: # define MSG_TRYHARD MSG_DONTROUTE
214: #endif
215: MSG_CTRUNC = 0x08,
216: #define MSG_CTRUNC MSG_CTRUNC
217: MSG_PROXY = 0x10,
218: #define MSG_PROXY MSG_PROXY
219: MSG_TRUNC = 0x20,
220: #define MSG_TRUNC MSG_TRUNC
221: MSG_DONTWAIT = 0x40,
222: #define MSG_DONTWAIT MSG_DONTWAIT
223: MSG_EOR = 0x80,
224: #define MSG_EOR MSG_EOR
225: MSG_WAITALL = 0x100,
226: #define MSG_WAITALL MSG_WAITALL
227: MSG_FIN = 0x200,
228: #define MSG_FIN MSG_FIN
229: MSG_SYN = 0x400,
230: #define MSG_SYN MSG_SYN
231: MSG_CONFIRM = 0x800,
232: #define MSG_CONFIRM MSG_CONFIRM
233: MSG_RST = 0x1000,
234: #define MSG_RST MSG_RST
235: MSG_ERRQUEUE = 0x2000,
236: #define MSG_ERRQUEUE MSG_ERRQUEUE
237: MSG_NOSIGNAL = 0x4000,
238: #define MSG_NOSIGNAL MSG_NOSIGNAL
239: MSG_MORE = 0x8000,
240: #define MSG_MORE MSG_MORE
241: MSG_WAITFORONE = 0x10000,
242: #define MSG_WAITFORONE MSG_WAITFORONE
243:
244: MSG_CMSG_CLOEXEC = 0x40000000
245:
246:
247: #define MSG_CMSG_CLOEXEC MSG_CMSG_CLOEXEC
248: };
249:
250:
251:
252:
253: struct msghdr
254: {
255: void *msg_name;
256: socklen_t msg_namelen;
257:
258: struct iovec *msg_iov;
259: size_t msg_iovlen;
260:
261: void *msg_control;
262: size_t msg_controllen;
263:
264:
265:
266:
267: int msg_flags;
268: };
269:
270: #ifdef __USE_GNU
271:
272: struct mmsghdr
273: {
274: struct msghdr msg_hdr;
275: unsigned int msg_len;
276: };
277: #endif
278:
279:
280: struct cmsghdr
281: {
282: size_t cmsg_len;
283:
284:
285:
286:
287: int cmsg_level;
288: int cmsg_type;
289: #if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L
290: __extension__ unsigned char __cmsg_data __flexarr;
291: #endif
292: };
293:
294:
295: #if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L
296: # define CMSG_DATA(cmsg) ((cmsg)->__cmsg_data)
297: #else
298: # define CMSG_DATA(cmsg) ((unsigned char *) ((struct cmsghdr *) (cmsg) + 1))
299: #endif
300: #define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg)
301: #define CMSG_FIRSTHDR(mhdr) \
302: ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) \
303: ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0)
304: #define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) \
305: & (size_t) ~(sizeof (size_t) - 1))
306: #define CMSG_SPACE(len) (CMSG_ALIGN (len) \
307: + CMSG_ALIGN (sizeof (struct cmsghdr)))
308: #define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
309:
310: extern struct cmsghdr *__cmsg_nxthdr (struct msghdr *__mhdr,
311: struct cmsghdr *__cmsg) __THROW;
312: #ifdef __USE_EXTERN_INLINES
313: # ifndef _EXTERN_INLINE
314: # define _EXTERN_INLINE __extern_inline
315: # endif
316: _EXTERN_INLINE struct cmsghdr *
317: __NTH (__cmsg_nxthdr (struct msghdr *__mhdr, struct cmsghdr *__cmsg))
318: {
319: if ((size_t) __cmsg->cmsg_len < sizeof (struct cmsghdr))
320:
321: return (struct cmsghdr *) 0;
322:
323: __cmsg = (struct cmsghdr *) ((unsigned char *) __cmsg
324: + CMSG_ALIGN (__cmsg->cmsg_len));
325: if ((unsigned char *) (__cmsg + 1) > ((unsigned char *) __mhdr->msg_control
326: + __mhdr->msg_controllen)
327: || ((unsigned char *) __cmsg + CMSG_ALIGN (__cmsg->cmsg_len)
328: > ((unsigned char *) __mhdr->msg_control + __mhdr->msg_controllen)))
329:
330: return (struct cmsghdr *) 0;
331: return __cmsg;
332: }
333: #endif
334:
335:
336:
337: enum
338: {
339: SCM_RIGHTS = 0x01
340: #define SCM_RIGHTS SCM_RIGHTS
341: #ifdef __USE_GNU
342: , SCM_CREDENTIALS = 0x02
343: # define SCM_CREDENTIALS SCM_CREDENTIALS
344: #endif
345: };
346:
347: #ifdef __USE_GNU
348:
349: struct ucred
350: {
351: pid_t pid;
352: uid_t uid;
353: gid_t gid;
354: };
355: #endif
356:
357:
358: #if !defined __USE_MISC && !defined __USE_GNU
359: # ifndef FIOGETOWN
360: # define __SYS_SOCKET_H_undef_FIOGETOWN
361: # endif
362: # ifndef FIOSETOWN
363: # define __SYS_SOCKET_H_undef_FIOSETOWN
364: # endif
365: # ifndef SIOCATMARK
366: # define __SYS_SOCKET_H_undef_SIOCATMARK
367: # endif
368: # ifndef SIOCGPGRP
369: # define __SYS_SOCKET_H_undef_SIOCGPGRP
370: # endif
371: # ifndef SIOCGSTAMP
372: # define __SYS_SOCKET_H_undef_SIOCGSTAMP
373: # endif
374: # ifndef SIOCGSTAMPNS
375: # define __SYS_SOCKET_H_undef_SIOCGSTAMPNS
376: # endif
377: # ifndef SIOCSPGRP
378: # define __SYS_SOCKET_H_undef_SIOCSPGRP
379: # endif
380: #endif
381:
382:
383: #include <asm/socket.h>
384:
385: #if !defined __USE_MISC && !defined __USE_GNU
386: # ifdef __SYS_SOCKET_H_undef_FIOGETOWN
387: # undef __SYS_SOCKET_H_undef_FIOGETOWN
388: # undef FIOGETOWN
389: # endif
390: # ifdef __SYS_SOCKET_H_undef_FIOSETOWN
391: # undef __SYS_SOCKET_H_undef_FIOSETOWN
392: # undef FIOSETOWN
393: # endif
394: # ifdef __SYS_SOCKET_H_undef_SIOCATMARK
395: # undef __SYS_SOCKET_H_undef_SIOCATMARK
396: # undef SIOCATMARK
397: # endif
398: # ifdef __SYS_SOCKET_H_undef_SIOCGPGRP
399: # undef __SYS_SOCKET_H_undef_SIOCGPGRP
400: # undef SIOCGPGRP
401: # endif
402: # ifdef __SYS_SOCKET_H_undef_SIOCGSTAMP
403: # undef __SYS_SOCKET_H_undef_SIOCGSTAMP
404: # undef SIOCGSTAMP
405: # endif
406: # ifdef __SYS_SOCKET_H_undef_SIOCGSTAMPNS
407: # undef __SYS_SOCKET_H_undef_SIOCGSTAMPNS
408: # undef SIOCGSTAMPNS
409: # endif
410: # ifdef __SYS_SOCKET_H_undef_SIOCSPGRP
411: # undef __SYS_SOCKET_H_undef_SIOCSPGRP
412: # undef SIOCSPGRP
413: # endif
414: #endif
415:
416:
417: struct linger
418: {
419: int l_onoff;
420: int l_linger;
421: };
422:
423:
424: __BEGIN_DECLS
425:
426:
427:
428:
429:
430:
431: extern int recvmmsg (int __fd, struct mmsghdr *__vmessages,
432: unsigned int __vlen, int __flags,
433: __const struct timespec *__tmo);
434:
435:
436:
437:
438:
439: extern int sendmmsg (int __fd, struct mmsghdr *__vmessages,
440: unsigned int __vlen, int __flags);
441:
442: __END_DECLS
443:
444: #endif
445:
© Andrew Scott 2006 -
2025,
All Rights Reserved