Annotation of kernel/bsd/sys/socket.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
                      7:  * Reserved.  This file contains Original Code and/or Modifications of
                      8:  * Original Code as defined in and that are subject to the Apple Public
                      9:  * Source License Version 1.1 (the "License").  You may not use this file
                     10:  * except in compliance with the License.  Please obtain a copy of the
                     11:  * License at http://www.apple.com/publicsource and read it before using
                     12:  * this file.
                     13:  * 
                     14:  * The Original Code and all software distributed under the License are
                     15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     19:  * License for the specific language governing rights and limitations
                     20:  * under the License.
                     21:  * 
                     22:  * @APPLE_LICENSE_HEADER_END@
                     23:  */
                     24: 
                     25: /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
                     26: /*
                     27:  * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994
                     28:  *     The Regents of the University of California.  All rights reserved.
                     29:  *
                     30:  * Redistribution and use in source and binary forms, with or without
                     31:  * modification, are permitted provided that the following conditions
                     32:  * are met:
                     33:  * 1. Redistributions of source code must retain the above copyright
                     34:  *    notice, this list of conditions and the following disclaimer.
                     35:  * 2. Redistributions in binary form must reproduce the above copyright
                     36:  *    notice, this list of conditions and the following disclaimer in the
                     37:  *    documentation and/or other materials provided with the distribution.
                     38:  * 3. All advertising materials mentioning features or use of this software
                     39:  *    must display the following acknowledgement:
                     40:  *     This product includes software developed by the University of
                     41:  *     California, Berkeley and its contributors.
                     42:  * 4. Neither the name of the University nor the names of its contributors
                     43:  *    may be used to endorse or promote products derived from this software
                     44:  *    without specific prior written permission.
                     45:  *
                     46:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     47:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     48:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     49:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     50:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     51:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     52:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     53:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     54:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     55:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     56:  * SUCH DAMAGE.
                     57:  *
                     58:  *     @(#)socket.h    8.6 (Berkeley) 5/3/95
                     59:  */
                     60: 
                     61: #ifndef _SYS_SOCKET_H_
                     62: #define        _SYS_SOCKET_H_
                     63: 
                     64: /*
                     65:  * Definitions related to sockets: types, address families, options.
                     66:  */
                     67: 
                     68: /*
                     69:  * Types
                     70:  */
                     71: #define        SOCK_STREAM     1               /* stream socket */
                     72: #define        SOCK_DGRAM      2               /* datagram socket */
                     73: #define        SOCK_RAW        3               /* raw-protocol interface */
                     74: #define        SOCK_RDM        4               /* reliably-delivered message */
                     75: #define        SOCK_SEQPACKET  5               /* sequenced packet stream */
                     76: 
                     77: /*
                     78:  * Option flags per-socket.
                     79:  */
                     80: #define        SO_DEBUG        0x0001          /* turn on debugging info recording */
                     81: #define        SO_ACCEPTCONN   0x0002          /* socket has had listen() */
                     82: #define        SO_REUSEADDR    0x0004          /* allow local address reuse */
                     83: #define        SO_KEEPALIVE    0x0008          /* keep connections alive */
                     84: #define        SO_DONTROUTE    0x0010          /* just use interface addresses */
                     85: #define        SO_BROADCAST    0x0020          /* permit sending of broadcast msgs */
                     86: #define        SO_USELOOPBACK  0x0040          /* bypass hardware when possible */
                     87: #define        SO_LINGER       0x0080          /* linger on close if data present */
                     88: #define        SO_OOBINLINE    0x0100          /* leave received OOB data in line */
                     89: #define        SO_REUSEPORT    0x0200          /* allow local address & port reuse */
                     90: 
                     91: #define SO_RCVIF       0x8000          /* enable receive if control msgs */
                     92: 
                     93: /*
                     94:  * Additional options, not kept in so_options.
                     95:  */
                     96: #define SO_SNDBUF      0x1001          /* send buffer size */
                     97: #define SO_RCVBUF      0x1002          /* receive buffer size */
                     98: #define SO_SNDLOWAT    0x1003          /* send low-water mark */
                     99: #define SO_RCVLOWAT    0x1004          /* receive low-water mark */
                    100: #define SO_SNDTIMEO    0x1005          /* send timeout */
                    101: #define SO_RCVTIMEO    0x1006          /* receive timeout */
                    102: #define        SO_ERROR        0x1007          /* get error status and clear */
                    103: #define        SO_TYPE         0x1008          /* get socket type */
                    104: 
                    105: /*
                    106:  * Structure used for manipulating linger option.
                    107:  */
                    108: struct linger {
                    109:        int     l_onoff;                /* option on/off */
                    110:        int     l_linger;               /* linger time */
                    111: };
                    112: 
                    113: /*
                    114:  * Level number for (get/set)sockopt() to apply to socket itself.
                    115:  */
                    116: #define        SOL_SOCKET      0xffff          /* options for socket level */
                    117: 
                    118: /*
                    119:  * Address families.
                    120:  */
                    121: #define        AF_UNSPEC       0               /* unspecified */
                    122: #define        AF_LOCAL        1               /* local to host (pipes, portals) */
                    123: #define        AF_UNIX         AF_LOCAL        /* backward compatibility */
                    124: #define        AF_INET         2               /* internetwork: UDP, TCP, etc. */
                    125: #define        AF_IMPLINK      3               /* arpanet imp addresses */
                    126: #define        AF_PUP          4               /* pup protocols: e.g. BSP */
                    127: #define        AF_CHAOS        5               /* mit CHAOS protocols */
                    128: #define        AF_NS           6               /* XEROX NS protocols */
                    129: #define        AF_ISO          7               /* ISO protocols */
                    130: #define        AF_OSI          AF_ISO
                    131: #define        AF_ECMA         8               /* european computer manufacturers */
                    132: #define        AF_DATAKIT      9               /* datakit protocols */
                    133: #define        AF_CCITT        10              /* CCITT protocols, X.25 etc */
                    134: #define        AF_SNA          11              /* IBM SNA */
                    135: #define AF_DECnet      12              /* DECnet */
                    136: #define AF_DLI         13              /* DEC Direct data link interface */
                    137: #define AF_LAT         14              /* LAT */
                    138: #define        AF_HYLINK       15              /* NSC Hyperchannel */
                    139: #define        AF_APPLETALK    16              /* Apple Talk */
                    140: #define        AF_ROUTE        17              /* Internal Routing Protocol */
                    141: #define        AF_LINK         18              /* Link layer interface */
                    142: #define        pseudo_AF_XTP   19              /* eXpress Transfer Protocol (no AF) */
                    143: #define        AF_COIP         20              /* connection-oriented IP, aka ST II */
                    144: #define        AF_CNT          21              /* Computer Network Technology */
                    145: #define pseudo_AF_RTIP 22              /* Help Identify RTIP packets */
                    146: #define        AF_IPX          23              /* Novell Internet Protocol */
                    147: #define        AF_SIP          24              /* Simple Internet Protocol */
                    148: #define pseudo_AF_PIP  25              /* Help Identify PIP packets */
                    149: #if defined(ppc)
                    150: #define pseudo_AF_BLUE 26              /* Identify packets for Blue Box */
                    151: #define AF_NDRV                27              /* Network Driver 'raw' access */
                    152: 
                    153: #define        AF_MAX          28
                    154: #else
                    155: #define        AF_MAX          26
                    156: #endif /* ppc */
                    157: 
                    158: /*
                    159:  * Structure used by kernel to store most
                    160:  * addresses.
                    161:  */
                    162: struct sockaddr {
                    163:        u_char  sa_len;                 /* total length */
                    164:        u_char  sa_family;              /* address family */
                    165:        char    sa_data[14];            /* actually longer; address value */
                    166: };
                    167: 
                    168: /*
                    169:  * Structure used by kernel to pass protocol
                    170:  * information in raw sockets.
                    171:  */
                    172: struct sockproto {
                    173:        u_short sp_family;              /* address family */
                    174:        u_short sp_protocol;            /* protocol */
                    175: };
                    176: 
                    177: /*
                    178:  * Protocol families, same as address families for now.
                    179:  */
                    180: #define        PF_UNSPEC       AF_UNSPEC
                    181: #define        PF_LOCAL        AF_LOCAL
                    182: #define        PF_UNIX         PF_LOCAL        /* backward compatibility */
                    183: #define        PF_INET         AF_INET
                    184: #define        PF_IMPLINK      AF_IMPLINK
                    185: #define        PF_PUP          AF_PUP
                    186: #define        PF_CHAOS        AF_CHAOS
                    187: #define        PF_NS           AF_NS
                    188: #define        PF_ISO          AF_ISO
                    189: #define        PF_OSI          AF_ISO
                    190: #define        PF_ECMA         AF_ECMA
                    191: #define        PF_DATAKIT      AF_DATAKIT
                    192: #define        PF_CCITT        AF_CCITT
                    193: #define        PF_SNA          AF_SNA
                    194: #define PF_DECnet      AF_DECnet
                    195: #define PF_DLI         AF_DLI
                    196: #define PF_LAT         AF_LAT
                    197: #define        PF_HYLINK       AF_HYLINK
                    198: #define        PF_APPLETALK    AF_APPLETALK
                    199: #define        PF_ROUTE        AF_ROUTE
                    200: #define        PF_LINK         AF_LINK
                    201: #define        PF_XTP          pseudo_AF_XTP   /* really just proto family, no AF */
                    202: #define        PF_COIP         AF_COIP
                    203: #define        PF_CNT          AF_CNT
                    204: #define        PF_SIP          AF_SIP
                    205: #define        PF_IPX          AF_IPX          /* same format as AF_NS */
                    206: #define PF_RTIP                pseudo_AF_FTIP  /* same format as AF_INET */
                    207: #define PF_PIP         pseudo_AF_PIP
                    208: 
                    209: #define        PF_MAX          AF_MAX
                    210: 
                    211: /*
                    212:  * Definitions for network related sysctl, CTL_NET.
                    213:  *
                    214:  * Second level is protocol family.
                    215:  * Third level is protocol number.
                    216:  *
                    217:  * Further levels are defined by the individual families below.
                    218:  */
                    219: #define NET_MAXID      AF_MAX
                    220: 
                    221: #define CTL_NET_NAMES { \
                    222:        { 0, 0 }, \
                    223:        { "local", CTLTYPE_NODE }, \
                    224:        { "inet", CTLTYPE_NODE }, \
                    225:        { "implink", CTLTYPE_NODE }, \
                    226:        { "pup", CTLTYPE_NODE }, \
                    227:        { "chaos", CTLTYPE_NODE }, \
                    228:        { "xerox_ns", CTLTYPE_NODE }, \
                    229:        { "iso", CTLTYPE_NODE }, \
                    230:        { "emca", CTLTYPE_NODE }, \
                    231:        { "datakit", CTLTYPE_NODE }, \
                    232:        { "ccitt", CTLTYPE_NODE }, \
                    233:        { "ibm_sna", CTLTYPE_NODE }, \
                    234:        { "decnet", CTLTYPE_NODE }, \
                    235:        { "dec_dli", CTLTYPE_NODE }, \
                    236:        { "lat", CTLTYPE_NODE }, \
                    237:        { "hylink", CTLTYPE_NODE }, \
                    238:        { "appletalk", CTLTYPE_NODE }, \
                    239:        { "route", CTLTYPE_NODE }, \
                    240:        { "link_layer", CTLTYPE_NODE }, \
                    241:        { "xtp", CTLTYPE_NODE }, \
                    242:        { "coip", CTLTYPE_NODE }, \
                    243:        { "cnt", CTLTYPE_NODE }, \
                    244:        { "rtip", CTLTYPE_NODE }, \
                    245:        { "ipx", CTLTYPE_NODE }, \
                    246:        { "sip", CTLTYPE_NODE }, \
                    247:        { "pip", CTLTYPE_NODE }, \
                    248: }
                    249: 
                    250: /*
                    251:  * PF_ROUTE - Routing table
                    252:  *
                    253:  * Three additional levels are defined:
                    254:  *     Fourth: address family, 0 is wildcard
                    255:  *     Fifth: type of info, defined below
                    256:  *     Sixth: flag(s) to mask with for NET_RT_FLAGS
                    257:  */
                    258: #define NET_RT_DUMP    1               /* dump; may limit to a.f. */
                    259: #define NET_RT_FLAGS   2               /* by flags, e.g. RESOLVING */
                    260: #define NET_RT_IFLIST  3               /* survey interface list */
                    261: #define        NET_RT_MAXID    4
                    262: 
                    263: #define CTL_NET_RT_NAMES { \
                    264:        { 0, 0 }, \
                    265:        { "dump", CTLTYPE_STRUCT }, \
                    266:        { "flags", CTLTYPE_STRUCT }, \
                    267:        { "iflist", CTLTYPE_STRUCT }, \
                    268: }
                    269: 
                    270: /*
                    271:  * Maximum queue length specifiable by listen.
                    272:  */
                    273: #define        SOMAXCONN       128
                    274: 
                    275: /*
                    276:  * Message header for recvmsg and sendmsg calls.
                    277:  * Used value-result for recvmsg, value only for sendmsg.
                    278:  */
                    279: struct msghdr {
                    280:        caddr_t msg_name;               /* optional address */
                    281:        u_int   msg_namelen;            /* size of address */
                    282:        struct  iovec *msg_iov;         /* scatter/gather array */
                    283:        u_int   msg_iovlen;             /* # elements in msg_iov */
                    284:        caddr_t msg_control;            /* ancillary data, see below */
                    285:        u_int   msg_controllen;         /* ancillary data buffer len */
                    286:        int     msg_flags;              /* flags on received message */
                    287: };
                    288: 
                    289: #define        MSG_OOB         0x1             /* process out-of-band data */
                    290: #define        MSG_PEEK        0x2             /* peek at incoming message */
                    291: #define        MSG_DONTROUTE   0x4             /* send without using routing tables */
                    292: #define        MSG_EOR         0x8             /* data completes record */
                    293: #define        MSG_TRUNC       0x10            /* data discarded before delivery */
                    294: #define        MSG_CTRUNC      0x20            /* control data lost before delivery */
                    295: #define        MSG_WAITALL     0x40            /* wait for full request or error */
                    296: #define        MSG_DONTWAIT    0x80            /* this message should be nonblocking */
                    297: 
                    298: /*
                    299:  * Header for ancillary data objects in msg_control buffer.
                    300:  * Used for additional information with/about a datagram
                    301:  * not expressible by flags.  The format is a sequence
                    302:  * of message elements headed by cmsghdr structures.
                    303:  */
                    304: struct cmsghdr {
                    305:        u_int   cmsg_len;               /* data byte count, including hdr */
                    306:        int     cmsg_level;             /* originating protocol */
                    307:        int     cmsg_type;              /* protocol-specific type */
                    308: /* followed by u_char  cmsg_data[]; */
                    309: };
                    310: 
                    311: /* given pointer to struct cmsghdr, return pointer to data */
                    312: #define        CMSG_DATA(cmsg)         ((u_char *)((cmsg) + 1))
                    313: 
                    314: /* given pointer to struct cmsghdr, return pointer to next cmsghdr */
                    315: #define        CMSG_NXTHDR(mhdr, cmsg) \
                    316:        (((caddr_t)(cmsg) + (cmsg)->cmsg_len + sizeof(struct cmsghdr) > \
                    317:            (mhdr)->msg_control + (mhdr)->msg_controllen) ? \
                    318:            (struct cmsghdr *)NULL : \
                    319:            (struct cmsghdr *)((caddr_t)(cmsg) + ALIGN((cmsg)->cmsg_len)))
                    320: 
                    321: #define        CMSG_FIRSTHDR(mhdr)     ((struct cmsghdr *)(mhdr)->msg_control)
                    322: 
                    323: /* "Socket"-level control message types: */
                    324: #define        SCM_RIGHTS      0x01            /* access rights (array of int) */
                    325: 
                    326: /*
                    327:  * 4.3 compat sockaddr, move to compat file later
                    328:  */
                    329: struct osockaddr {
                    330:        u_short sa_family;              /* address family */
                    331:        char    sa_data[14];            /* up to 14 bytes of direct address */
                    332: };
                    333: 
                    334: /*
                    335:  * 4.3-compat message header (move to compat file later).
                    336:  */
                    337: struct omsghdr {
                    338:        caddr_t msg_name;               /* optional address */
                    339:        int     msg_namelen;            /* size of address */
                    340:        struct  iovec *msg_iov;         /* scatter/gather array */
                    341:        int     msg_iovlen;             /* # elements in msg_iov */
                    342:        caddr_t msg_accrights;          /* access rights sent/received */
                    343:        int     msg_accrightslen;
                    344: };
                    345: 
                    346: #ifndef        _KERNEL
                    347: 
                    348: #include <sys/cdefs.h>
                    349: 
                    350: __BEGIN_DECLS
                    351: int    accept __P((int, struct sockaddr *, int *));
                    352: int    bind __P((int, const struct sockaddr *, int));
                    353: int    connect __P((int, const struct sockaddr *, int));
                    354: int    getpeername __P((int, struct sockaddr *, int *));
                    355: int    getsockname __P((int, struct sockaddr *, int *));
                    356: int    getsockopt __P((int, int, int, void *, int *));
                    357: int    listen __P((int, int));
                    358: ssize_t        recv __P((int, void *, size_t, int));
                    359: ssize_t        recvfrom __P((int, void *, size_t, int, struct sockaddr *, int *));
                    360: ssize_t        recvmsg __P((int, struct msghdr *, int));
                    361: ssize_t        send __P((int, const void *, size_t, int));
                    362: ssize_t        sendto __P((int, const void *,
                    363:            size_t, int, const struct sockaddr *, int));
                    364: ssize_t        sendmsg __P((int, const struct msghdr *, int));
                    365: int    setsockopt __P((int, int, int, const void *, int));
                    366: int    shutdown __P((int, int));
                    367: int    socket __P((int, int, int));
                    368: int    socketpair __P((int, int, int, int *));
                    369: __END_DECLS
                    370: 
                    371: #endif /* !_KERNEL */
                    372: #endif /* !_SYS_SOCKET_H_ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.