[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.75

1.75    ! tron        1: /*     $NetBSD: socket.h,v 1.74 2005/03/09 18:53:57 tron Exp $ */
1.44      itojun      2:
                      3: /*
                      4:  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
                      5:  * All rights reserved.
1.71      perry       6:  *
1.44      itojun      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.
1.71      perry      18:  *
1.44      itojun     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.
1.68      agc        44:  * 3. Neither the name of the University nor the names of its contributors
1.1       cgd        45:  *    may be used to endorse or promote products derived from this software
                     46:  *    without specific prior written permission.
                     47:  *
                     48:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     49:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     50:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     51:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     52:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     53:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     54:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     55:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     56:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     57:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     58:  * SUCH DAMAGE.
                     59:  *
1.28      fvdl       60:  *     @(#)socket.h    8.6 (Berkeley) 5/3/95
1.1       cgd        61:  */
                     62:
1.2       mycroft    63: #ifndef _SYS_SOCKET_H_
1.8       mycroft    64: #define        _SYS_SOCKET_H_
1.2       mycroft    65:
1.67      bjh21      66: #include <sys/featuretest.h>
                     67:
1.1       cgd        68: /*
                     69:  * Definitions related to sockets: types, address families, options.
                     70:  */
                     71:
                     72: /*
1.42      kleink     73:  * Data types.
                     74:  */
1.55      itojun     75: #include <sys/ansi.h>
1.56      kleink     76:
                     77: #ifndef sa_family_t
                     78: typedef __sa_family_t  sa_family_t;
1.58      kleink     79: #define sa_family_t    __sa_family_t
1.56      kleink     80: #endif
                     81:
1.55      itojun     82: #ifndef socklen_t
                     83: typedef __socklen_t    socklen_t;
1.58      kleink     84: #define socklen_t      __socklen_t
1.55      itojun     85: #endif
1.42      kleink     86:
1.63      kleink     87: #include <machine/ansi.h>
                     88:
                     89: #ifdef _BSD_SIZE_T_
                     90: typedef        _BSD_SIZE_T_    size_t;
                     91: #undef _BSD_SIZE_T_
                     92: #endif
                     93:
                     94: #ifdef _BSD_SSIZE_T_
                     95: typedef        _BSD_SSIZE_T_   ssize_t;
                     96: #undef _BSD_SSIZE_T_
                     97: #endif
                     98:
                     99: #include <sys/uio.h>
                    100:
1.42      kleink    101: /*
                    102:  * Socket types.
1.1       cgd       103:  */
                    104: #define        SOCK_STREAM     1               /* stream socket */
                    105: #define        SOCK_DGRAM      2               /* datagram socket */
                    106: #define        SOCK_RAW        3               /* raw-protocol interface */
                    107: #define        SOCK_RDM        4               /* reliably-delivered message */
                    108: #define        SOCK_SEQPACKET  5               /* sequenced packet stream */
                    109:
                    110: /*
                    111:  * Option flags per-socket.
                    112:  */
                    113: #define        SO_DEBUG        0x0001          /* turn on debugging info recording */
                    114: #define        SO_ACCEPTCONN   0x0002          /* socket has had listen() */
                    115: #define        SO_REUSEADDR    0x0004          /* allow local address reuse */
                    116: #define        SO_KEEPALIVE    0x0008          /* keep connections alive */
                    117: #define        SO_DONTROUTE    0x0010          /* just use interface addresses */
                    118: #define        SO_BROADCAST    0x0020          /* permit sending of broadcast msgs */
                    119: #define        SO_USELOOPBACK  0x0040          /* bypass hardware when possible */
                    120: #define        SO_LINGER       0x0080          /* linger on close if data present */
                    121: #define        SO_OOBINLINE    0x0100          /* leave received OOB data in line */
1.8       mycroft   122: #define        SO_REUSEPORT    0x0200          /* allow local address & port reuse */
1.18      thorpej   123: #define        SO_TIMESTAMP    0x0400          /* timestamp received dgram traffic */
1.1       cgd       124:
                    125: /*
                    126:  * Additional options, not kept in so_options.
                    127:  */
                    128: #define SO_SNDBUF      0x1001          /* send buffer size */
                    129: #define SO_RCVBUF      0x1002          /* receive buffer size */
                    130: #define SO_SNDLOWAT    0x1003          /* send low-water mark */
                    131: #define SO_RCVLOWAT    0x1004          /* receive low-water mark */
                    132: #define SO_SNDTIMEO    0x1005          /* send timeout */
                    133: #define SO_RCVTIMEO    0x1006          /* receive timeout */
                    134: #define        SO_ERROR        0x1007          /* get error status and clear */
                    135: #define        SO_TYPE         0x1008          /* get socket type */
1.69      darrenr   136: #define        SO_OVERFLOWED   0x1009          /* datagrams: return packets dropped */
1.1       cgd       137:
                    138: /*
                    139:  * Structure used for manipulating linger option.
                    140:  */
                    141: struct linger {
                    142:        int     l_onoff;                /* option on/off */
1.28      fvdl      143:        int     l_linger;               /* linger time in seconds */
1.1       cgd       144: };
                    145:
                    146: /*
                    147:  * Level number for (get/set)sockopt() to apply to socket itself.
                    148:  */
                    149: #define        SOL_SOCKET      0xffff          /* options for socket level */
                    150:
                    151: /*
                    152:  * Address families.
                    153:  */
                    154: #define        AF_UNSPEC       0               /* unspecified */
1.8       mycroft   155: #define        AF_LOCAL        1               /* local to host (pipes, portals) */
                    156: #define        AF_UNIX         AF_LOCAL        /* backward compatibility */
1.1       cgd       157: #define        AF_INET         2               /* internetwork: UDP, TCP, etc. */
                    158: #define        AF_IMPLINK      3               /* arpanet imp addresses */
                    159: #define        AF_PUP          4               /* pup protocols: e.g. BSP */
                    160: #define        AF_CHAOS        5               /* mit CHAOS protocols */
                    161: #define        AF_NS           6               /* XEROX NS protocols */
                    162: #define        AF_ISO          7               /* ISO protocols */
                    163: #define        AF_OSI          AF_ISO
                    164: #define        AF_ECMA         8               /* european computer manufacturers */
                    165: #define        AF_DATAKIT      9               /* datakit protocols */
                    166: #define        AF_CCITT        10              /* CCITT protocols, X.25 etc */
                    167: #define        AF_SNA          11              /* IBM SNA */
                    168: #define AF_DECnet      12              /* DECnet */
                    169: #define AF_DLI         13              /* DEC Direct data link interface */
                    170: #define AF_LAT         14              /* LAT */
                    171: #define        AF_HYLINK       15              /* NSC Hyperchannel */
                    172: #define        AF_APPLETALK    16              /* Apple Talk */
                    173: #define        AF_ROUTE        17              /* Internal Routing Protocol */
                    174: #define        AF_LINK         18              /* Link layer interface */
1.67      bjh21     175: #if defined(_NETBSD_SOURCE)
1.1       cgd       176: #define        pseudo_AF_XTP   19              /* eXpress Transfer Protocol (no AF) */
1.42      kleink    177: #endif
1.8       mycroft   178: #define        AF_COIP         20              /* connection-oriented IP, aka ST II */
                    179: #define        AF_CNT          21              /* Computer Network Technology */
1.67      bjh21     180: #if defined(_NETBSD_SOURCE)
1.8       mycroft   181: #define pseudo_AF_RTIP 22              /* Help Identify RTIP packets */
1.42      kleink    182: #endif
1.8       mycroft   183: #define        AF_IPX          23              /* Novell Internet Protocol */
1.21      sommerfe  184: #define        AF_INET6        24              /* IP version 6 */
1.67      bjh21     185: #if defined(_NETBSD_SOURCE)
1.8       mycroft   186: #define pseudo_AF_PIP  25              /* Help Identify PIP packets */
1.42      kleink    187: #endif
1.17      chuck     188: #define AF_ISDN                26              /* Integrated Services Digital Network*/
                    189: #define AF_E164                AF_ISDN         /* CCITT E.164 recommendation */
                    190: #define AF_NATM                27              /* native ATM access */
1.19      is        191: #define AF_ARP         28              /* (rev.) addr. res. prot. (RFC 826) */
1.67      bjh21     192: #if defined(_NETBSD_SOURCE)
1.21      sommerfe  193: #define pseudo_AF_KEY  29              /* Internal key management protocol  */
1.31      thorpej   194: #define        pseudo_AF_HDRCMPLT 30           /* Used by BPF to not rewrite hdrs
                    195:                                           in interface output routine */
1.42      kleink    196: #endif
1.1       cgd       197:
1.31      thorpej   198: #define        AF_MAX          31
1.1       cgd       199:
                    200: /*
1.26      thorpej   201:  * Structure used by kernel to store most
                    202:  * addresses.
1.1       cgd       203:  */
                    204: struct sockaddr {
1.63      kleink    205:        __uint8_t       sa_len;         /* total length */
1.56      kleink    206:        sa_family_t     sa_family;      /* address family */
                    207:        char            sa_data[14];    /* actually longer; address value */
1.26      thorpej   208: };
1.1       cgd       209:
1.42      kleink    210: #if defined(_KERNEL)
1.1       cgd       211: /*
                    212:  * Structure used by kernel to pass protocol
                    213:  * information in raw sockets.
                    214:  */
                    215: struct sockproto {
                    216:        u_short sp_family;              /* address family */
                    217:        u_short sp_protocol;            /* protocol */
                    218: };
1.42      kleink    219: #endif /* _KERNEL */
1.1       cgd       220:
1.44      itojun    221: #if 1
                    222: /*
                    223:  * RFC 2553: protocol-independent placeholder for socket addresses
                    224:  */
                    225: #define _SS_MAXSIZE    128
1.63      kleink    226: #define _SS_ALIGNSIZE  (sizeof(__int64_t))
1.60      kleink    227: #define _SS_PAD1SIZE   (_SS_ALIGNSIZE - 2)
                    228: #define _SS_PAD2SIZE   (_SS_MAXSIZE - 2 - \
1.44      itojun    229:                                _SS_PAD1SIZE - _SS_ALIGNSIZE)
                    230:
1.67      bjh21     231: #if (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
1.44      itojun    232: struct sockaddr_storage {
1.63      kleink    233:        __uint8_t       ss_len;         /* address length */
1.56      kleink    234:        sa_family_t     ss_family;      /* address family */
                    235:        char            __ss_pad1[_SS_PAD1SIZE];
1.63      kleink    236:        __int64_t     __ss_align;/* force desired structure storage alignment */
1.56      kleink    237:        char            __ss_pad2[_SS_PAD2SIZE];
1.44      itojun    238: };
1.67      bjh21     239: #endif /* _XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */
1.46      kleink    240: #endif /* 1 */
1.44      itojun    241:
1.1       cgd       242: /*
                    243:  * Protocol families, same as address families for now.
                    244:  */
                    245: #define        PF_UNSPEC       AF_UNSPEC
1.8       mycroft   246: #define        PF_LOCAL        AF_LOCAL
                    247: #define        PF_UNIX         PF_LOCAL        /* backward compatibility */
1.1       cgd       248: #define        PF_INET         AF_INET
                    249: #define        PF_IMPLINK      AF_IMPLINK
                    250: #define        PF_PUP          AF_PUP
                    251: #define        PF_CHAOS        AF_CHAOS
                    252: #define        PF_NS           AF_NS
                    253: #define        PF_ISO          AF_ISO
                    254: #define        PF_OSI          AF_ISO
                    255: #define        PF_ECMA         AF_ECMA
                    256: #define        PF_DATAKIT      AF_DATAKIT
                    257: #define        PF_CCITT        AF_CCITT
                    258: #define        PF_SNA          AF_SNA
                    259: #define PF_DECnet      AF_DECnet
                    260: #define PF_DLI         AF_DLI
                    261: #define PF_LAT         AF_LAT
                    262: #define        PF_HYLINK       AF_HYLINK
                    263: #define        PF_APPLETALK    AF_APPLETALK
                    264: #define        PF_ROUTE        AF_ROUTE
                    265: #define        PF_LINK         AF_LINK
1.67      bjh21     266: #if defined(_NETBSD_SOURCE)
1.1       cgd       267: #define        PF_XTP          pseudo_AF_XTP   /* really just proto family, no AF */
1.42      kleink    268: #endif
1.8       mycroft   269: #define        PF_COIP         AF_COIP
                    270: #define        PF_CNT          AF_CNT
1.21      sommerfe  271: #define        PF_INET6        AF_INET6
1.8       mycroft   272: #define        PF_IPX          AF_IPX          /* same format as AF_NS */
1.67      bjh21     273: #if defined(_NETBSD_SOURCE)
1.72      kleink    274: #define PF_RTIP                pseudo_AF_RTIP  /* same format as AF_INET */
1.8       mycroft   275: #define PF_PIP         pseudo_AF_PIP
1.42      kleink    276: #endif
1.20      is        277: #define PF_ISDN                AF_ISDN         /* same as E164 */
                    278: #define PF_E164                AF_E164
1.17      chuck     279: #define PF_NATM                AF_NATM
1.19      is        280: #define PF_ARP         AF_ARP
1.67      bjh21     281: #if defined(_NETBSD_SOURCE)
1.21      sommerfe  282: #define PF_KEY                 pseudo_AF_KEY   /* like PF_ROUTE, only for key mgmt */
1.42      kleink    283: #endif
1.1       cgd       284:
                    285: #define        PF_MAX          AF_MAX
                    286:
1.67      bjh21     287: #if defined(_NETBSD_SOURCE)
1.63      kleink    288:
                    289: #ifndef        gid_t
                    290: typedef        __gid_t         gid_t;          /* group id */
                    291: #define        gid_t           __gid_t
                    292: #endif
                    293:
                    294: #ifndef        uid_t
                    295: typedef        __uid_t         uid_t;          /* user id */
                    296: #define        uid_t           __uid_t
                    297: #endif
                    298:
1.1       cgd       299: /*
1.27      thorpej   300:  * Socket credentials.
                    301:  */
                    302: struct sockcred {
                    303:        uid_t   sc_uid;                 /* real user id */
                    304:        uid_t   sc_euid;                /* effective user id */
                    305:        gid_t   sc_gid;                 /* real group id */
                    306:        gid_t   sc_egid;                /* effective group id */
                    307:        int     sc_ngroups;             /* number of supplemental groups */
                    308:        gid_t   sc_groups[1];           /* variable length */
                    309: };
                    310:
                    311: /*
                    312:  * Compute size of a sockcred structure with groups.
                    313:  */
                    314: #define        SOCKCREDSIZE(ngrps) \
                    315:        (sizeof(struct sockcred) + (sizeof(gid_t) * ((ngrps) - 1)))
1.67      bjh21     316: #endif /* _NETBSD_SOURCE */
1.27      thorpej   317:
1.38      kleink    318:
1.67      bjh21     319: #if defined(_NETBSD_SOURCE)
1.27      thorpej   320: /*
1.8       mycroft   321:  * Definitions for network related sysctl, CTL_NET.
                    322:  *
                    323:  * Second level is protocol family.
                    324:  * Third level is protocol number.
                    325:  *
                    326:  * Further levels are defined by the individual families below.
                    327:  */
                    328: #define NET_MAXID      AF_MAX
                    329:
                    330: #define CTL_NET_NAMES { \
                    331:        { 0, 0 }, \
1.28      fvdl      332:        { "local", CTLTYPE_NODE }, \
1.8       mycroft   333:        { "inet", CTLTYPE_NODE }, \
                    334:        { "implink", CTLTYPE_NODE }, \
                    335:        { "pup", CTLTYPE_NODE }, \
                    336:        { "chaos", CTLTYPE_NODE }, \
                    337:        { "xerox_ns", CTLTYPE_NODE }, \
                    338:        { "iso", CTLTYPE_NODE }, \
                    339:        { "emca", CTLTYPE_NODE }, \
                    340:        { "datakit", CTLTYPE_NODE }, \
                    341:        { "ccitt", CTLTYPE_NODE }, \
                    342:        { "ibm_sna", CTLTYPE_NODE }, \
                    343:        { "decnet", CTLTYPE_NODE }, \
                    344:        { "dec_dli", CTLTYPE_NODE }, \
                    345:        { "lat", CTLTYPE_NODE }, \
                    346:        { "hylink", CTLTYPE_NODE }, \
                    347:        { "appletalk", CTLTYPE_NODE }, \
                    348:        { "route", CTLTYPE_NODE }, \
                    349:        { "link_layer", CTLTYPE_NODE }, \
                    350:        { "xtp", CTLTYPE_NODE }, \
                    351:        { "coip", CTLTYPE_NODE }, \
                    352:        { "cnt", CTLTYPE_NODE }, \
                    353:        { "rtip", CTLTYPE_NODE }, \
                    354:        { "ipx", CTLTYPE_NODE }, \
1.21      sommerfe  355:        { "inet6", CTLTYPE_NODE }, \
1.8       mycroft   356:        { "pip", CTLTYPE_NODE }, \
1.20      is        357:        { "isdn", CTLTYPE_NODE }, \
1.17      chuck     358:        { "natm", CTLTYPE_NODE }, \
1.20      is        359:        { "arp", CTLTYPE_NODE }, \
1.21      sommerfe  360:        { "key", CTLTYPE_NODE }, \
1.8       mycroft   361: }
1.73      atatat    362:
                    363: struct kinfo_pcb {
1.75    ! tron      364:        __uint64_t      ki_pcbaddr;     /* PTR: pcb addr */
        !           365:        __uint64_t      ki_ppcbaddr;    /* PTR: ppcb addr */
        !           366:        __uint64_t      ki_sockaddr;    /* PTR: socket addr */
        !           367:
        !           368:        __uint32_t      ki_family;      /* INT: protocol family */
        !           369:        __uint32_t      ki_type;        /* INT: socket type */
        !           370:        __uint32_t      ki_protocol;    /* INT: protocol */
        !           371:        __uint32_t      ki_pflags;      /* INT: generic protocol flags */
        !           372:
        !           373:        __uint32_t      ki_sostate;     /* INT: socket state */
        !           374:        __uint32_t      ki_prstate;     /* INT: protocol state */
        !           375:        __int32_t       ki_tstate;      /* INT: tcp state */
        !           376:        __uint32_t      ki_tflags;      /* INT: tcp flags */
1.73      atatat    377:
1.75    ! tron      378:        __uint64_t      ki_rcvq;        /* U_LONG: receive queue len */
        !           379:        __uint64_t      ki_sndq;        /* U_LONG: send queue len */
1.73      atatat    380:
                    381:        union {
                    382:                struct sockaddr _kis_src; /* STRUCT: local address */
                    383:                char _kis_pad[256 + 8];         /* pad to max addr length */
                    384:        } ki_s;
                    385:        union {
                    386:                struct sockaddr _kid_dst; /* STRUCT: remote address */
                    387:                char _kid_pad[256 + 8];         /* pad to max addr length */
                    388:        } ki_d;
                    389:
1.75    ! tron      390:        __uint64_t      ki_inode;       /* INO_T: fake inode number */
        !           391:        __uint64_t      ki_vnode;       /* PTR: if associated with file */
        !           392:        __uint64_t      ki_conn;        /* PTR: control block of peer */
        !           393:        __uint64_t      ki_refs;        /* PTR: referencing socket */
        !           394:        __uint64_t      ki_nextref;     /* PTR: link in refs list */
1.73      atatat    395: };
                    396:
                    397: #define ki_src ki_s._kis_src
                    398: #define ki_dst ki_d._kid_dst
                    399:
                    400: #define PCB_SLOP               20
                    401: #define PCB_ALL                        0
                    402:
1.67      bjh21     403: #endif /* _NETBSD_SOURCE */
1.8       mycroft   404:
1.67      bjh21     405: #if defined(_NETBSD_SOURCE)
1.8       mycroft   406: /*
                    407:  * PF_ROUTE - Routing table
                    408:  *
                    409:  * Three additional levels are defined:
                    410:  *     Fourth: address family, 0 is wildcard
                    411:  *     Fifth: type of info, defined below
                    412:  *     Sixth: flag(s) to mask with for NET_RT_FLAGS
                    413:  */
                    414: #define NET_RT_DUMP    1               /* dump; may limit to a.f. */
                    415: #define NET_RT_FLAGS   2               /* by flags, e.g. RESOLVING */
1.47      bouyer    416: #define NET_RT_OIFLIST 3               /* old NET_RT_IFLIST (pre 1.5) */
                    417: #define NET_RT_IFLIST  4               /* survey interface list */
                    418: #define        NET_RT_MAXID    5
1.8       mycroft   419:
                    420: #define CTL_NET_RT_NAMES { \
                    421:        { 0, 0 }, \
                    422:        { "dump", CTLTYPE_STRUCT }, \
                    423:        { "flags", CTLTYPE_STRUCT }, \
1.47      bouyer    424:        { 0, 0 }, \
1.8       mycroft   425:        { "iflist", CTLTYPE_STRUCT }, \
                    426: }
1.67      bjh21     427: #endif /* _NETBSD_SOURCE */
1.8       mycroft   428:
                    429: /*
1.13      mycroft   430:  * Maximum queue length specifiable by listen(2).
1.1       cgd       431:  */
1.66      christos  432: #ifndef SOMAXCONN
1.13      mycroft   433: #define        SOMAXCONN       128
1.66      christos  434: #endif
1.16      neil      435:
1.1       cgd       436: /*
                    437:  * Message header for recvmsg and sendmsg calls.
                    438:  * Used value-result for recvmsg, value only for sendmsg.
                    439:  */
                    440: struct msghdr {
1.42      kleink    441:        void            *msg_name;      /* optional address */
                    442:        socklen_t       msg_namelen;    /* size of address */
                    443:        struct iovec    *msg_iov;       /* scatter/gather array */
                    444:        int             msg_iovlen;     /* # elements in msg_iov */
                    445:        void            *msg_control;   /* ancillary data, see below */
                    446:        socklen_t       msg_controllen; /* ancillary data buffer len */
                    447:        int             msg_flags;      /* flags on received message */
1.1       cgd       448: };
                    449:
                    450: #define        MSG_OOB         0x1             /* process out-of-band data */
                    451: #define        MSG_PEEK        0x2             /* peek at incoming message */
                    452: #define        MSG_DONTROUTE   0x4             /* send without using routing tables */
                    453: #define        MSG_EOR         0x8             /* data completes record */
                    454: #define        MSG_TRUNC       0x10            /* data discarded before delivery */
                    455: #define        MSG_CTRUNC      0x20            /* control data lost before delivery */
                    456: #define        MSG_WAITALL     0x40            /* wait for full request or error */
1.8       mycroft   457: #define        MSG_DONTWAIT    0x80            /* this message should be nonblocking */
1.30      matt      458: #define        MSG_BCAST       0x100           /* this message was rcvd using link-level brdcst */
                    459: #define        MSG_MCAST       0x200           /* this message was rcvd using link-level mcast */
1.1       cgd       460:
                    461: /*
                    462:  * Header for ancillary data objects in msg_control buffer.
                    463:  * Used for additional information with/about a datagram
                    464:  * not expressible by flags.  The format is a sequence
                    465:  * of message elements headed by cmsghdr structures.
                    466:  */
                    467: struct cmsghdr {
1.42      kleink    468:        socklen_t       cmsg_len;       /* data byte count, including hdr */
                    469:        int             cmsg_level;     /* originating protocol */
                    470:        int             cmsg_type;      /* protocol-specific type */
1.1       cgd       471: /* followed by u_char  cmsg_data[]; */
                    472: };
                    473:
1.8       mycroft   474: /* given pointer to struct cmsghdr, return pointer to data */
1.50      itojun    475: #define        CMSG_DATA(cmsg) \
1.57      christos  476:        ((u_char *)(void *)(cmsg) + __CMSG_ALIGN(sizeof(struct cmsghdr)))
1.1       cgd       477:
1.44      itojun    478: /*
                    479:  * Alignment requirement for CMSG struct manipulation.
1.51      itojun    480:  * This basically behaves the same as ALIGN() ARCH/include/param.h.
                    481:  * We declare it separately for two reasons:
                    482:  * (1) avoid dependency between machine/param.h, and (2) to sync with kernel's
                    483:  * idea of ALIGNBYTES at runtime.
                    484:  * without (2), we can't guarantee binary compatibility in case of future
                    485:  * changes in ALIGNBYTES.
1.44      itojun    486:  */
1.53      itojun    487: #define __CMSG_ALIGN(n)        (((n) + __cmsg_alignbytes()) & ~__cmsg_alignbytes())
                    488: #ifdef _KERNEL
1.54      augustss  489: #define CMSG_ALIGN(n)  __CMSG_ALIGN(n)
1.53      itojun    490: #endif
1.44      itojun    491:
1.8       mycroft   492: /* given pointer to struct cmsghdr, return pointer to next cmsghdr */
1.1       cgd       493: #define        CMSG_NXTHDR(mhdr, cmsg) \
1.63      kleink    494:        (((__caddr_t)(cmsg) + __CMSG_ALIGN((cmsg)->cmsg_len) + \
1.53      itojun    495:                            __CMSG_ALIGN(sizeof(struct cmsghdr)) > \
1.63      kleink    496:            (((__caddr_t)(mhdr)->msg_control) + (mhdr)->msg_controllen)) ? \
1.1       cgd       497:            (struct cmsghdr *)NULL : \
1.63      kleink    498:            (struct cmsghdr *)((__caddr_t)(cmsg) + \
                    499:                __CMSG_ALIGN((cmsg)->cmsg_len)))
1.1       cgd       500:
1.62      itojun    501: /*
                    502:  * RFC 2292 requires to check msg_controllen, in case that the kernel returns
                    503:  * an empty list for some reasons.
                    504:  */
                    505: #define        CMSG_FIRSTHDR(mhdr) \
                    506:        ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
                    507:         (struct cmsghdr *)(mhdr)->msg_control : \
                    508:         (struct cmsghdr *)NULL)
1.1       cgd       509:
1.53      itojun    510: #define CMSG_SPACE(l)  (__CMSG_ALIGN(sizeof(struct cmsghdr)) + __CMSG_ALIGN(l))
                    511: #define CMSG_LEN(l)    (__CMSG_ALIGN(sizeof(struct cmsghdr)) + (l))
1.44      itojun    512:
1.1       cgd       513: /* "Socket"-level control message types: */
                    514: #define        SCM_RIGHTS      0x01            /* access rights (array of int) */
1.67      bjh21     515: #if defined(_NETBSD_SOURCE)
1.18      thorpej   516: #define        SCM_TIMESTAMP   0x02            /* timestamp (struct timeval) */
1.42      kleink    517: #define        SCM_CREDS       0x04            /* credentials (struct sockcred) */
                    518: #endif
1.29      kleink    519:
                    520: /*
                    521:  * Types of socket shutdown(2).
                    522:  */
                    523: #define        SHUT_RD         0               /* Disallow further receives. */
                    524: #define        SHUT_WR         1               /* Disallow further sends. */
                    525: #define        SHUT_RDWR       2               /* Disallow further sends/receives. */
1.1       cgd       526:
1.67      bjh21     527: #if defined(_NETBSD_SOURCE)
1.1       cgd       528: /*
                    529:  * 4.3 compat sockaddr, move to compat file later
                    530:  */
                    531: struct osockaddr {
1.63      kleink    532:        __uint16_t      sa_family;      /* address family */
1.60      kleink    533:        char            sa_data[14];    /* up to 14 bytes of direct address */
1.1       cgd       534: };
                    535:
                    536: /*
                    537:  * 4.3-compat message header (move to compat file later).
                    538:  */
                    539: struct omsghdr {
1.63      kleink    540:        __caddr_t       msg_name;       /* optional address */
                    541:        int             msg_namelen;    /* size of address */
                    542:        struct iovec    *msg_iov;       /* scatter/gather array */
                    543:        int             msg_iovlen;     /* # elements in msg_iov */
                    544:        __caddr_t       msg_accrights;  /* access rights sent/received */
                    545:        int             msg_accrightslen;
1.1       cgd       546: };
1.42      kleink    547: #endif
1.51      itojun    548:
1.59      toshii    549: #include <sys/cdefs.h>
                    550:
                    551: __BEGIN_DECLS
1.70      perry     552: int    __cmsg_alignbytes(void);
1.59      toshii    553: __END_DECLS
1.1       cgd       554:
1.12      briggs    555: #ifndef        _KERNEL
1.1       cgd       556:
                    557: __BEGIN_DECLS
1.70      perry     558: int    accept(int, struct sockaddr * __restrict, socklen_t * __restrict);
                    559: int    bind(int, const struct sockaddr *, socklen_t);
                    560: int    connect(int, const struct sockaddr *, socklen_t);
                    561: int    getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict);
                    562: int    getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict);
                    563: int    getsockopt(int, int, int, void * __restrict, socklen_t * __restrict);
                    564: int    listen(int, int);
                    565: ssize_t        recv(int, void *, size_t, int);
                    566: ssize_t        recvfrom(int, void * __restrict, size_t, int,
                    567:            struct sockaddr * __restrict, socklen_t * __restrict);
                    568: ssize_t        recvmsg(int, struct msghdr *, int);
                    569: ssize_t        send(int, const void *, size_t, int);
                    570: ssize_t        sendto(int, const void *,
                    571:            size_t, int, const struct sockaddr *, socklen_t);
                    572: ssize_t        sendmsg(int, const struct msghdr *, int);
                    573: int    setsockopt(int, int, int, const void *, socklen_t);
                    574: int    shutdown(int, int);
                    575: int    sockatmark(int);
                    576: int    socket(int, int, int);
                    577: int    socketpair(int, int, int, int *);
1.1       cgd       578: __END_DECLS
1.14      christos  579: #endif /* !_KERNEL */
1.1       cgd       580:
1.2       mycroft   581: #endif /* !_SYS_SOCKET_H_ */

CVSweb <webmaster@jp.NetBSD.org>