[BACK]Return to socket.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / sys

Annotation of src/sys/sys/socket.h, Revision 1.44

1.44    ! itojun      1: /*     $NetBSD: socket.h,v 1.43 1999/02/11 20:33:26 cjs Exp $  */
        !             2:
        !             3: /*
        !             4:  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
        !             5:  * All rights reserved.
        !             6:  *
        !             7:  * Redistribution and use in source and binary forms, with or without
        !             8:  * modification, are permitted provided that the following conditions
        !             9:  * are met:
        !            10:  * 1. Redistributions of source code must retain the above copyright
        !            11:  *    notice, this list of conditions and the following disclaimer.
        !            12:  * 2. Redistributions in binary form must reproduce the above copyright
        !            13:  *    notice, this list of conditions and the following disclaimer in the
        !            14:  *    documentation and/or other materials provided with the distribution.
        !            15:  * 3. Neither the name of the project nor the names of its contributors
        !            16:  *    may be used to endorse or promote products derived from this software
        !            17:  *    without specific prior written permission.
        !            18:  *
        !            19:  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
        !            20:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            21:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            22:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
        !            23:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            24:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            25:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            26:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            27:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            28:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            29:  * SUCH DAMAGE.
        !            30:  */
1.10      cgd        31:
1.1       cgd        32: /*
1.8       mycroft    33:  * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994
                     34:  *     The Regents of the University of California.  All rights reserved.
1.1       cgd        35:  *
                     36:  * Redistribution and use in source and binary forms, with or without
                     37:  * modification, are permitted provided that the following conditions
                     38:  * are met:
                     39:  * 1. Redistributions of source code must retain the above copyright
                     40:  *    notice, this list of conditions and the following disclaimer.
                     41:  * 2. Redistributions in binary form must reproduce the above copyright
                     42:  *    notice, this list of conditions and the following disclaimer in the
                     43:  *    documentation and/or other materials provided with the distribution.
                     44:  * 3. All advertising materials mentioning features or use of this software
                     45:  *    must display the following acknowledgement:
                     46:  *     This product includes software developed by the University of
                     47:  *     California, Berkeley and its contributors.
                     48:  * 4. Neither the name of the University nor the names of its contributors
                     49:  *    may be used to endorse or promote products derived from this software
                     50:  *    without specific prior written permission.
                     51:  *
                     52:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     53:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     54:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     55:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     56:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     57:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     58:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     59:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     60:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     61:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     62:  * SUCH DAMAGE.
                     63:  *
1.28      fvdl       64:  *     @(#)socket.h    8.6 (Berkeley) 5/3/95
1.1       cgd        65:  */
                     66:
1.2       mycroft    67: #ifndef _SYS_SOCKET_H_
1.8       mycroft    68: #define        _SYS_SOCKET_H_
1.2       mycroft    69:
1.1       cgd        70: /*
                     71:  * Definitions related to sockets: types, address families, options.
                     72:  */
                     73:
                     74: /*
1.42      kleink     75:  * Data types.
                     76:  */
                     77: typedef        unsigned int    socklen_t;
                     78:
                     79: /*
                     80:  * Socket types.
1.1       cgd        81:  */
                     82: #define        SOCK_STREAM     1               /* stream socket */
                     83: #define        SOCK_DGRAM      2               /* datagram socket */
                     84: #define        SOCK_RAW        3               /* raw-protocol interface */
                     85: #define        SOCK_RDM        4               /* reliably-delivered message */
                     86: #define        SOCK_SEQPACKET  5               /* sequenced packet stream */
                     87:
                     88: /*
                     89:  * Option flags per-socket.
                     90:  */
                     91: #define        SO_DEBUG        0x0001          /* turn on debugging info recording */
                     92: #define        SO_ACCEPTCONN   0x0002          /* socket has had listen() */
                     93: #define        SO_REUSEADDR    0x0004          /* allow local address reuse */
                     94: #define        SO_KEEPALIVE    0x0008          /* keep connections alive */
                     95: #define        SO_DONTROUTE    0x0010          /* just use interface addresses */
                     96: #define        SO_BROADCAST    0x0020          /* permit sending of broadcast msgs */
                     97: #define        SO_USELOOPBACK  0x0040          /* bypass hardware when possible */
                     98: #define        SO_LINGER       0x0080          /* linger on close if data present */
                     99: #define        SO_OOBINLINE    0x0100          /* leave received OOB data in line */
1.8       mycroft   100: #define        SO_REUSEPORT    0x0200          /* allow local address & port reuse */
1.18      thorpej   101: #define        SO_TIMESTAMP    0x0400          /* timestamp received dgram traffic */
1.1       cgd       102:
                    103: /*
                    104:  * Additional options, not kept in so_options.
                    105:  */
                    106: #define SO_SNDBUF      0x1001          /* send buffer size */
                    107: #define SO_RCVBUF      0x1002          /* receive buffer size */
                    108: #define SO_SNDLOWAT    0x1003          /* send low-water mark */
                    109: #define SO_RCVLOWAT    0x1004          /* receive low-water mark */
                    110: #define SO_SNDTIMEO    0x1005          /* send timeout */
                    111: #define SO_RCVTIMEO    0x1006          /* receive timeout */
                    112: #define        SO_ERROR        0x1007          /* get error status and clear */
                    113: #define        SO_TYPE         0x1008          /* get socket type */
                    114:
                    115: /*
                    116:  * Structure used for manipulating linger option.
                    117:  */
                    118: struct linger {
                    119:        int     l_onoff;                /* option on/off */
1.28      fvdl      120:        int     l_linger;               /* linger time in seconds */
1.1       cgd       121: };
                    122:
                    123: /*
                    124:  * Level number for (get/set)sockopt() to apply to socket itself.
                    125:  */
                    126: #define        SOL_SOCKET      0xffff          /* options for socket level */
                    127:
                    128: /*
                    129:  * Address families.
                    130:  */
                    131: #define        AF_UNSPEC       0               /* unspecified */
1.8       mycroft   132: #define        AF_LOCAL        1               /* local to host (pipes, portals) */
                    133: #define        AF_UNIX         AF_LOCAL        /* backward compatibility */
1.1       cgd       134: #define        AF_INET         2               /* internetwork: UDP, TCP, etc. */
                    135: #define        AF_IMPLINK      3               /* arpanet imp addresses */
                    136: #define        AF_PUP          4               /* pup protocols: e.g. BSP */
                    137: #define        AF_CHAOS        5               /* mit CHAOS protocols */
                    138: #define        AF_NS           6               /* XEROX NS protocols */
                    139: #define        AF_ISO          7               /* ISO protocols */
                    140: #define        AF_OSI          AF_ISO
                    141: #define        AF_ECMA         8               /* european computer manufacturers */
                    142: #define        AF_DATAKIT      9               /* datakit protocols */
                    143: #define        AF_CCITT        10              /* CCITT protocols, X.25 etc */
                    144: #define        AF_SNA          11              /* IBM SNA */
                    145: #define AF_DECnet      12              /* DECnet */
                    146: #define AF_DLI         13              /* DEC Direct data link interface */
                    147: #define AF_LAT         14              /* LAT */
                    148: #define        AF_HYLINK       15              /* NSC Hyperchannel */
                    149: #define        AF_APPLETALK    16              /* Apple Talk */
                    150: #define        AF_ROUTE        17              /* Internal Routing Protocol */
                    151: #define        AF_LINK         18              /* Link layer interface */
1.42      kleink    152: #if !defined(_XOPEN_SOURCE)
1.1       cgd       153: #define        pseudo_AF_XTP   19              /* eXpress Transfer Protocol (no AF) */
1.42      kleink    154: #endif
1.8       mycroft   155: #define        AF_COIP         20              /* connection-oriented IP, aka ST II */
                    156: #define        AF_CNT          21              /* Computer Network Technology */
1.42      kleink    157: #if !defined(_XOPEN_SOURCE)
1.8       mycroft   158: #define pseudo_AF_RTIP 22              /* Help Identify RTIP packets */
1.42      kleink    159: #endif
1.8       mycroft   160: #define        AF_IPX          23              /* Novell Internet Protocol */
1.21      sommerfe  161: #define        AF_INET6        24              /* IP version 6 */
1.42      kleink    162: #if !defined(_XOPEN_SOURCE)
1.8       mycroft   163: #define pseudo_AF_PIP  25              /* Help Identify PIP packets */
1.42      kleink    164: #endif
1.17      chuck     165: #define AF_ISDN                26              /* Integrated Services Digital Network*/
                    166: #define AF_E164                AF_ISDN         /* CCITT E.164 recommendation */
                    167: #define AF_NATM                27              /* native ATM access */
1.19      is        168: #define AF_ARP         28              /* (rev.) addr. res. prot. (RFC 826) */
1.42      kleink    169: #if !defined(_XOPEN_SOURCE)
1.21      sommerfe  170: #define pseudo_AF_KEY  29              /* Internal key management protocol  */
1.31      thorpej   171: #define        pseudo_AF_HDRCMPLT 30           /* Used by BPF to not rewrite hdrs
                    172:                                           in interface output routine */
1.42      kleink    173: #endif
1.1       cgd       174:
1.31      thorpej   175: #define        AF_MAX          31
1.1       cgd       176:
                    177: /*
1.26      thorpej   178:  * Structure used by kernel to store most
                    179:  * addresses.
1.1       cgd       180:  */
                    181: struct sockaddr {
                    182:        u_char  sa_len;                 /* total length */
                    183:        u_char  sa_family;              /* address family */
                    184:        char    sa_data[14];            /* actually longer; address value */
1.26      thorpej   185: };
1.1       cgd       186:
1.42      kleink    187: #if defined(_KERNEL)
1.1       cgd       188: /*
                    189:  * Structure used by kernel to pass protocol
                    190:  * information in raw sockets.
                    191:  */
                    192: struct sockproto {
                    193:        u_short sp_family;              /* address family */
                    194:        u_short sp_protocol;            /* protocol */
                    195: };
1.42      kleink    196: #endif /* _KERNEL */
1.1       cgd       197:
1.44    ! itojun    198: #if 1
        !           199: /*
        !           200:  * RFC 2553: protocol-independent placeholder for socket addresses
        !           201:  */
        !           202: #define _SS_MAXSIZE    128
        !           203: #define _SS_ALIGNSIZE  (sizeof(int64_t))
        !           204: #define _SS_PAD1SIZE   (_SS_ALIGNSIZE - sizeof(u_char) * 2)
        !           205: #define _SS_PAD2SIZE   (_SS_MAXSIZE - sizeof(u_char) * 2 - \
        !           206:                                _SS_PAD1SIZE - _SS_ALIGNSIZE)
        !           207:
        !           208: struct sockaddr_storage {
        !           209:        u_char  __ss_len;       /* address length */
        !           210:        u_char  __ss_family;    /* address family */
        !           211:        char    __ss_pad1[_SS_PAD1SIZE];
        !           212:        int64_t __ss_align;     /* force desired structure storage alignment */
        !           213:        char    __ss_pad2[_SS_PAD2SIZE];
        !           214: };
        !           215: #endif
        !           216:
1.1       cgd       217: /*
                    218:  * Protocol families, same as address families for now.
                    219:  */
                    220: #define        PF_UNSPEC       AF_UNSPEC
1.8       mycroft   221: #define        PF_LOCAL        AF_LOCAL
                    222: #define        PF_UNIX         PF_LOCAL        /* backward compatibility */
1.1       cgd       223: #define        PF_INET         AF_INET
1.44    ! itojun    224: #define        PF_INET6        AF_INET6
1.1       cgd       225: #define        PF_IMPLINK      AF_IMPLINK
                    226: #define        PF_PUP          AF_PUP
                    227: #define        PF_CHAOS        AF_CHAOS
                    228: #define        PF_NS           AF_NS
                    229: #define        PF_ISO          AF_ISO
                    230: #define        PF_OSI          AF_ISO
                    231: #define        PF_ECMA         AF_ECMA
                    232: #define        PF_DATAKIT      AF_DATAKIT
                    233: #define        PF_CCITT        AF_CCITT
                    234: #define        PF_SNA          AF_SNA
                    235: #define PF_DECnet      AF_DECnet
                    236: #define PF_DLI         AF_DLI
                    237: #define PF_LAT         AF_LAT
                    238: #define        PF_HYLINK       AF_HYLINK
                    239: #define        PF_APPLETALK    AF_APPLETALK
                    240: #define        PF_ROUTE        AF_ROUTE
                    241: #define        PF_LINK         AF_LINK
1.42      kleink    242: #if !defined(_XOPEN_SOURCE)
1.1       cgd       243: #define        PF_XTP          pseudo_AF_XTP   /* really just proto family, no AF */
1.42      kleink    244: #endif
1.8       mycroft   245: #define        PF_COIP         AF_COIP
                    246: #define        PF_CNT          AF_CNT
1.21      sommerfe  247: #define        PF_INET6        AF_INET6
1.8       mycroft   248: #define        PF_IPX          AF_IPX          /* same format as AF_NS */
1.42      kleink    249: #if !defined(_XOPEN_SOURCE)
1.8       mycroft   250: #define PF_RTIP                pseudo_AF_FTIP  /* same format as AF_INET */
                    251: #define PF_PIP         pseudo_AF_PIP
1.42      kleink    252: #endif
1.20      is        253: #define PF_ISDN                AF_ISDN         /* same as E164 */
                    254: #define PF_E164                AF_E164
1.17      chuck     255: #define PF_NATM                AF_NATM
1.19      is        256: #define PF_ARP         AF_ARP
1.42      kleink    257: #if !defined(_XOPEN_SOURCE)
1.21      sommerfe  258: #define PF_KEY                 pseudo_AF_KEY   /* like PF_ROUTE, only for key mgmt */
1.42      kleink    259: #endif
1.1       cgd       260:
                    261: #define        PF_MAX          AF_MAX
                    262:
1.42      kleink    263: #if !defined(_XOPEN_SOURCE)
1.1       cgd       264: /*
1.27      thorpej   265:  * Socket credentials.
                    266:  */
                    267: struct sockcred {
                    268:        uid_t   sc_uid;                 /* real user id */
                    269:        uid_t   sc_euid;                /* effective user id */
                    270:        gid_t   sc_gid;                 /* real group id */
                    271:        gid_t   sc_egid;                /* effective group id */
                    272:        int     sc_ngroups;             /* number of supplemental groups */
                    273:        gid_t   sc_groups[1];           /* variable length */
                    274: };
                    275:
                    276: /*
                    277:  * Compute size of a sockcred structure with groups.
                    278:  */
                    279: #define        SOCKCREDSIZE(ngrps) \
                    280:        (sizeof(struct sockcred) + (sizeof(gid_t) * ((ngrps) - 1)))
1.42      kleink    281: #endif /* !_XOPEN_SOURCE */
1.27      thorpej   282:
1.38      kleink    283:
                    284: #if !defined(_XOPEN_SOURCE)
1.27      thorpej   285: /*
1.8       mycroft   286:  * Definitions for network related sysctl, CTL_NET.
                    287:  *
                    288:  * Second level is protocol family.
                    289:  * Third level is protocol number.
                    290:  *
                    291:  * Further levels are defined by the individual families below.
                    292:  */
                    293: #define NET_MAXID      AF_MAX
                    294:
                    295: #define CTL_NET_NAMES { \
                    296:        { 0, 0 }, \
1.28      fvdl      297:        { "local", CTLTYPE_NODE }, \
1.8       mycroft   298:        { "inet", CTLTYPE_NODE }, \
                    299:        { "implink", CTLTYPE_NODE }, \
                    300:        { "pup", CTLTYPE_NODE }, \
                    301:        { "chaos", CTLTYPE_NODE }, \
                    302:        { "xerox_ns", CTLTYPE_NODE }, \
                    303:        { "iso", CTLTYPE_NODE }, \
                    304:        { "emca", CTLTYPE_NODE }, \
                    305:        { "datakit", CTLTYPE_NODE }, \
                    306:        { "ccitt", CTLTYPE_NODE }, \
                    307:        { "ibm_sna", CTLTYPE_NODE }, \
                    308:        { "decnet", CTLTYPE_NODE }, \
                    309:        { "dec_dli", CTLTYPE_NODE }, \
                    310:        { "lat", CTLTYPE_NODE }, \
                    311:        { "hylink", CTLTYPE_NODE }, \
                    312:        { "appletalk", CTLTYPE_NODE }, \
                    313:        { "route", CTLTYPE_NODE }, \
                    314:        { "link_layer", CTLTYPE_NODE }, \
                    315:        { "xtp", CTLTYPE_NODE }, \
                    316:        { "coip", CTLTYPE_NODE }, \
                    317:        { "cnt", CTLTYPE_NODE }, \
                    318:        { "rtip", CTLTYPE_NODE }, \
                    319:        { "ipx", CTLTYPE_NODE }, \
1.21      sommerfe  320:        { "inet6", CTLTYPE_NODE }, \
1.8       mycroft   321:        { "pip", CTLTYPE_NODE }, \
1.20      is        322:        { "isdn", CTLTYPE_NODE }, \
1.17      chuck     323:        { "natm", CTLTYPE_NODE }, \
1.20      is        324:        { "arp", CTLTYPE_NODE }, \
1.21      sommerfe  325:        { "key", CTLTYPE_NODE }, \
1.8       mycroft   326: }
1.38      kleink    327: #endif /* !_XOPEN_SOURCE */
1.8       mycroft   328:
1.38      kleink    329: #if !defined(_XOPEN_SOURCE)
1.8       mycroft   330: /*
                    331:  * PF_ROUTE - Routing table
                    332:  *
                    333:  * Three additional levels are defined:
                    334:  *     Fourth: address family, 0 is wildcard
                    335:  *     Fifth: type of info, defined below
                    336:  *     Sixth: flag(s) to mask with for NET_RT_FLAGS
                    337:  */
                    338: #define NET_RT_DUMP    1               /* dump; may limit to a.f. */
                    339: #define NET_RT_FLAGS   2               /* by flags, e.g. RESOLVING */
                    340: #define NET_RT_IFLIST  3               /* survey interface list */
                    341: #define        NET_RT_MAXID    4
                    342:
                    343: #define CTL_NET_RT_NAMES { \
                    344:        { 0, 0 }, \
                    345:        { "dump", CTLTYPE_STRUCT }, \
                    346:        { "flags", CTLTYPE_STRUCT }, \
                    347:        { "iflist", CTLTYPE_STRUCT }, \
                    348: }
1.38      kleink    349: #endif /* !_XOPEN_SOURCE */
1.8       mycroft   350:
                    351: /*
1.13      mycroft   352:  * Maximum queue length specifiable by listen(2).
1.1       cgd       353:  */
1.16      neil      354:
1.13      mycroft   355: #define        SOMAXCONN       128
1.16      neil      356:
1.1       cgd       357: /*
                    358:  * Message header for recvmsg and sendmsg calls.
                    359:  * Used value-result for recvmsg, value only for sendmsg.
                    360:  */
                    361: struct msghdr {
1.42      kleink    362:        void            *msg_name;      /* optional address */
                    363:        socklen_t       msg_namelen;    /* size of address */
                    364:        struct iovec    *msg_iov;       /* scatter/gather array */
                    365:        int             msg_iovlen;     /* # elements in msg_iov */
                    366:        void            *msg_control;   /* ancillary data, see below */
                    367:        socklen_t       msg_controllen; /* ancillary data buffer len */
                    368:        int             msg_flags;      /* flags on received message */
1.1       cgd       369: };
                    370:
                    371: #define        MSG_OOB         0x1             /* process out-of-band data */
                    372: #define        MSG_PEEK        0x2             /* peek at incoming message */
                    373: #define        MSG_DONTROUTE   0x4             /* send without using routing tables */
                    374: #define        MSG_EOR         0x8             /* data completes record */
                    375: #define        MSG_TRUNC       0x10            /* data discarded before delivery */
                    376: #define        MSG_CTRUNC      0x20            /* control data lost before delivery */
                    377: #define        MSG_WAITALL     0x40            /* wait for full request or error */
1.8       mycroft   378: #define        MSG_DONTWAIT    0x80            /* this message should be nonblocking */
1.30      matt      379: #define        MSG_BCAST       0x100           /* this message was rcvd using link-level brdcst */
                    380: #define        MSG_MCAST       0x200           /* this message was rcvd using link-level mcast */
1.1       cgd       381:
                    382: /*
                    383:  * Header for ancillary data objects in msg_control buffer.
                    384:  * Used for additional information with/about a datagram
                    385:  * not expressible by flags.  The format is a sequence
                    386:  * of message elements headed by cmsghdr structures.
                    387:  */
                    388: struct cmsghdr {
1.42      kleink    389:        socklen_t       cmsg_len;       /* data byte count, including hdr */
                    390:        int             cmsg_level;     /* originating protocol */
                    391:        int             cmsg_type;      /* protocol-specific type */
1.1       cgd       392: /* followed by u_char  cmsg_data[]; */
                    393: };
                    394:
1.8       mycroft   395: /* given pointer to struct cmsghdr, return pointer to data */
1.1       cgd       396: #define        CMSG_DATA(cmsg)         ((u_char *)((cmsg) + 1))
                    397:
1.44    ! itojun    398: /*
        !           399:  * Alignment requirement for CMSG struct manipulation.
        !           400:  * This is different from ALIGN() defined in ARCH/include/param.h.
        !           401:  * XXX think again carefully about architecture dependencies.
        !           402:  */
        !           403: #define CMSG_ALIGN(n)          (((n) + 3) & ~3)
        !           404:
1.8       mycroft   405: /* given pointer to struct cmsghdr, return pointer to next cmsghdr */
1.1       cgd       406: #define        CMSG_NXTHDR(mhdr, cmsg) \
                    407:        (((caddr_t)(cmsg) + (cmsg)->cmsg_len + sizeof(struct cmsghdr) > \
1.43      cjs       408:            (caddr_t) ((mhdr)->msg_control + (mhdr)->msg_controllen)) ? \
1.1       cgd       409:            (struct cmsghdr *)NULL : \
1.44    ! itojun    410:            (struct cmsghdr *)((caddr_t)(cmsg) + CMSG_ALIGN((cmsg)->cmsg_len)))
1.1       cgd       411:
                    412: #define        CMSG_FIRSTHDR(mhdr)     ((struct cmsghdr *)(mhdr)->msg_control)
                    413:
1.44    ! itojun    414: #define CMSG_SPACE(l)  (CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(l))
        !           415: #define CMSG_LEN(l)    (CMSG_ALIGN(sizeof(struct cmsghdr)) + (l))
        !           416:
1.1       cgd       417: /* "Socket"-level control message types: */
                    418: #define        SCM_RIGHTS      0x01            /* access rights (array of int) */
1.42      kleink    419: #if !defined(_XOPEN_SOURCE)
1.18      thorpej   420: #define        SCM_TIMESTAMP   0x02            /* timestamp (struct timeval) */
1.42      kleink    421: #define        SCM_CREDS       0x04            /* credentials (struct sockcred) */
                    422: #endif
1.29      kleink    423:
                    424: /*
                    425:  * Types of socket shutdown(2).
                    426:  */
                    427: #define        SHUT_RD         0               /* Disallow further receives. */
                    428: #define        SHUT_WR         1               /* Disallow further sends. */
                    429: #define        SHUT_RDWR       2               /* Disallow further sends/receives. */
1.1       cgd       430:
1.42      kleink    431: #if !defined(_XOPEN_SOURCE)
1.1       cgd       432: /*
                    433:  * 4.3 compat sockaddr, move to compat file later
                    434:  */
                    435: struct osockaddr {
                    436:        u_short sa_family;              /* address family */
                    437:        char    sa_data[14];            /* up to 14 bytes of direct address */
                    438: };
                    439:
                    440: /*
                    441:  * 4.3-compat message header (move to compat file later).
                    442:  */
                    443: struct omsghdr {
                    444:        caddr_t msg_name;               /* optional address */
                    445:        int     msg_namelen;            /* size of address */
                    446:        struct  iovec *msg_iov;         /* scatter/gather array */
                    447:        int     msg_iovlen;             /* # elements in msg_iov */
                    448:        caddr_t msg_accrights;          /* access rights sent/received */
                    449:        int     msg_accrightslen;
                    450: };
1.42      kleink    451: #endif
1.1       cgd       452:
1.12      briggs    453: #ifndef        _KERNEL
1.1       cgd       454:
                    455: #include <sys/cdefs.h>
                    456:
                    457: __BEGIN_DECLS
1.42      kleink    458: int    accept __P((int, struct sockaddr *, socklen_t *));
                    459: int    bind __P((int, const struct sockaddr *, socklen_t));
                    460: int    connect __P((int, const struct sockaddr *, socklen_t));
                    461: int    getpeername __P((int, struct sockaddr *, socklen_t *));
                    462: int    getsockname __P((int, struct sockaddr *, socklen_t *));
                    463: int    getsockopt __P((int, int, int, void *, socklen_t *));
1.1       cgd       464: int    listen __P((int, int));
1.8       mycroft   465: ssize_t        recv __P((int, void *, size_t, int));
1.42      kleink    466: ssize_t        recvfrom __P((int, void *, size_t, int, struct sockaddr *,
                    467:            socklen_t *));
1.8       mycroft   468: ssize_t        recvmsg __P((int, struct msghdr *, int));
                    469: ssize_t        send __P((int, const void *, size_t, int));
                    470: ssize_t        sendto __P((int, const void *,
1.42      kleink    471:            size_t, int, const struct sockaddr *, socklen_t));
1.8       mycroft   472: ssize_t        sendmsg __P((int, const struct msghdr *, int));
1.42      kleink    473: int    setsockopt __P((int, int, int, const void *, socklen_t));
1.1       cgd       474: int    shutdown __P((int, int));
                    475: int    socket __P((int, int, int));
                    476: int    socketpair __P((int, int, int, int *));
                    477: __END_DECLS
1.14      christos  478: #else
1.41      drochner  479: #ifdef COMPAT_OLDSOCK
                    480: #define MSG_COMPAT     0x8000
                    481: #endif
1.44    ! itojun    482:
        !           483: #include <sys/cdefs.h>
        !           484:
        !           485: __BEGIN_DECLS
        !           486: void   pfctlinput __P((int, struct sockaddr *));
        !           487: __END_DECLS
1.14      christos  488: #endif /* !_KERNEL */
1.1       cgd       489:
1.2       mycroft   490: #endif /* !_SYS_SOCKET_H_ */

CVSweb <webmaster@jp.NetBSD.org>