OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994 | 2 * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994 |
3 * The Regents of the University of California. All rights reserved. | 3 * The Regents of the University of California. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 */ | 52 */ |
53 #ifdef _BSD_SA_FAMILY_T_ | 53 #ifdef _BSD_SA_FAMILY_T_ |
54 typedef _BSD_SA_FAMILY_T_ sa_family_t; | 54 typedef _BSD_SA_FAMILY_T_ sa_family_t; |
55 #undef _BSD_SA_FAMILY_T_ | 55 #undef _BSD_SA_FAMILY_T_ |
56 #endif | 56 #endif |
57 | 57 |
58 #ifdef _BSD_SOCKLEN_T_ | 58 #ifdef _BSD_SOCKLEN_T_ |
59 typedef _BSD_SOCKLEN_T_ socklen_t; | 59 typedef _BSD_SOCKLEN_T_ socklen_t; |
60 #undef _BSD_SOCKLEN_T_ | 60 #undef _BSD_SOCKLEN_T_ |
61 #endif | 61 #endif |
62 | 62 |
63 /* | 63 /* |
64 * Types | 64 * Types |
65 */ | 65 */ |
66 #define SOCK_STREAM 1 /* stream socket */ | 66 #define SOCK_STREAM 1 /* stream socket */ |
67 #define SOCK_DGRAM 2 /* datagram socket */ | 67 #define SOCK_DGRAM 2 /* datagram socket */ |
68 #define SOCK_RAW 3 /* raw-protocol interface */ | 68 #define SOCK_RAW 3 /* raw-protocol interface */ |
69 #define SOCK_RDM 4 /* reliably-delivered message */ | 69 #define SOCK_RDM 4 /* reliably-delivered message */ |
70 #define SOCK_SEQPACKET 5 /* sequenced packet stream */ | 70 #define SOCK_SEQPACKET 5 /* sequenced packet stream */ |
71 | 71 |
72 /* Socket type flags that can be or'd with the above types */ | 72 /* Socket type flags that can be or'd with the above types */ |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 */ | 348 */ |
349 struct cmsgcred { | 349 struct cmsgcred { |
350 pid_t cmcred_pid; /* PID of sending process */ | 350 pid_t cmcred_pid; /* PID of sending process */ |
351 uid_t cmcred_uid; /* real UID of sending process */ | 351 uid_t cmcred_uid; /* real UID of sending process */ |
352 uid_t cmcred_euid; /* effective UID of sending process */ | 352 uid_t cmcred_euid; /* effective UID of sending process */ |
353 gid_t cmcred_gid; /* real GID of sending process */ | 353 gid_t cmcred_gid; /* real GID of sending process */ |
354 short cmcred_ngroups; /* number or groups */ | 354 short cmcred_ngroups; /* number or groups */ |
355 gid_t cmcred_groups[CMGROUP_MAX]; /* groups */ | 355 gid_t cmcred_groups[CMGROUP_MAX]; /* groups */ |
356 }; | 356 }; |
357 | 357 |
| 358 /* |
| 359 * Round p (pointer or byte index) up to a correctly-aligned value |
| 360 * for all data types (int, long, ...). The result is unsigned int |
| 361 * and must be cast to any desired pointer type. |
| 362 */ |
| 363 #ifndef _ALIGNBYTES |
| 364 #define _ALIGNBYTES (sizeof(int) - 1) |
| 365 #endif |
| 366 #ifndef _ALIGN |
| 367 #define _ALIGN(p) (((unsigned)(p) + _ALIGNBYTES) & ~_ALIGNBYTES) |
| 368 #endif |
| 369 |
358 /* given pointer to struct cmsghdr, return pointer to data */ | 370 /* given pointer to struct cmsghdr, return pointer to data */ |
359 #define CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \ | 371 #define CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \ |
360 _ALIGN(sizeof(struct cmsghdr))) | 372 _ALIGN(sizeof(struct cmsghdr))) |
361 | 373 |
362 /* given pointer to struct cmsghdr, return pointer to next cmsghdr */ | 374 /* given pointer to struct cmsghdr, return pointer to next cmsghdr */ |
363 #define CMSG_NXTHDR(mhdr, cmsg) \ | 375 #define CMSG_NXTHDR(mhdr, cmsg) \ |
364 (((caddr_t)(cmsg) + _ALIGN((cmsg)->cmsg_len) + \ | 376 (((caddr_t)(cmsg) + _ALIGN((cmsg)->cmsg_len) + \ |
365 _ALIGN(sizeof(struct cmsghdr)) > \ | 377 _ALIGN(sizeof(struct cmsghdr)) > \ |
366 (caddr_t)(mhdr)->msg_control + (mhdr)->msg_controllen) ? \ | 378 (caddr_t)(mhdr)->msg_control + (mhdr)->msg_controllen) ? \ |
367 (struct cmsghdr *)NULL : \ | 379 (struct cmsghdr *)NULL : \ |
368 (struct cmsghdr *)((caddr_t)(cmsg) + _ALIGN((cmsg)->cmsg_len))) | 380 (struct cmsghdr *)((caddr_t)(cmsg) + _ALIGN((cmsg)->cmsg_len))) |
369 | 381 |
370 #define CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control) | 382 #define CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control) |
371 | 383 |
372 /* RFC 2292 additions */ | 384 /* RFC 2292 additions */ |
373 » | 385 |
374 #define CMSG_SPACE(l) (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(l)) | 386 #define CMSG_SPACE(l) (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(l)) |
375 #define CMSG_LEN(l) (_ALIGN(sizeof(struct cmsghdr)) + (l)) | 387 #define CMSG_LEN(l) (_ALIGN(sizeof(struct cmsghdr)) + (l)) |
376 | 388 |
377 #ifdef _KERNEL | 389 #ifdef _KERNEL |
378 #define CMSG_ALIGN(n) _ALIGN(n) | 390 #define CMSG_ALIGN(n) _ALIGN(n) |
379 #endif | 391 #endif |
380 | 392 |
381 /* "Socket"-level control message types: */ | 393 /* "Socket"-level control message types: */ |
382 #define SCM_RIGHTS 0x01 /* access rights (array of int) */ | 394 #define SCM_RIGHTS 0x01 /* access rights (array of int) */ |
383 #define SCM_TIMESTAMP 0x02 /* timestamp (struct timeval) */ | 395 #define SCM_TIMESTAMP 0x02 /* timestamp (struct timeval) */ |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 size_t, int, const struct sockaddr *, socklen_t); | 450 size_t, int, const struct sockaddr *, socklen_t); |
439 ssize_t sendmsg(int, const struct msghdr *, int); | 451 ssize_t sendmsg(int, const struct msghdr *, int); |
440 int sendfile(int, int, off_t, size_t, struct sf_hdtr *, off_t *, int); | 452 int sendfile(int, int, off_t, size_t, struct sf_hdtr *, off_t *, int); |
441 int setsockopt(int, int, int, const void *, socklen_t); | 453 int setsockopt(int, int, int, const void *, socklen_t); |
442 int shutdown(int, int); | 454 int shutdown(int, int); |
443 int socket(int, int, int); | 455 int socket(int, int, int); |
444 int socketpair(int, int, int, int *); | 456 int socketpair(int, int, int, int *); |
445 __END_DECLS | 457 __END_DECLS |
446 | 458 |
447 #endif /* !_SYS_SOCKET_H_ */ | 459 #endif /* !_SYS_SOCKET_H_ */ |
OLD | NEW |