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

1.123.4.1! pgoyette    1: /*     $NetBSD: socket.h,v 1.124 2018/04/19 21:19:07 christos 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>
1.100     christos  100: #include <sys/sigtypes.h>
1.63      kleink    101:
1.42      kleink    102: /*
                    103:  * Socket types.
1.1       cgd       104:  */
                    105: #define        SOCK_STREAM     1               /* stream socket */
                    106: #define        SOCK_DGRAM      2               /* datagram socket */
                    107: #define        SOCK_RAW        3               /* raw-protocol interface */
                    108: #define        SOCK_RDM        4               /* reliably-delivered message */
                    109: #define        SOCK_SEQPACKET  5               /* sequenced packet stream */
1.116     rjs       110: #define        SOCK_CONN_DGRAM 6               /* connection-orientated datagram */
                    111: #define        SOCK_DCCP       SOCK_CONN_DGRAM
1.1       cgd       112:
1.100     christos  113: #define        SOCK_CLOEXEC    0x10000000      /* set close on exec on socket */
                    114: #define        SOCK_NONBLOCK   0x20000000      /* set non blocking i/o socket */
1.105     christos  115: #define        SOCK_NOSIGPIPE  0x40000000      /* don't send sigpipe */
1.100     christos  116: #define        SOCK_FLAGS_MASK 0xf0000000      /* flags mask */
                    117:
1.1       cgd       118: /*
                    119:  * Option flags per-socket.
                    120:  */
                    121: #define        SO_DEBUG        0x0001          /* turn on debugging info recording */
                    122: #define        SO_ACCEPTCONN   0x0002          /* socket has had listen() */
                    123: #define        SO_REUSEADDR    0x0004          /* allow local address reuse */
                    124: #define        SO_KEEPALIVE    0x0008          /* keep connections alive */
                    125: #define        SO_DONTROUTE    0x0010          /* just use interface addresses */
                    126: #define        SO_BROADCAST    0x0020          /* permit sending of broadcast msgs */
                    127: #define        SO_USELOOPBACK  0x0040          /* bypass hardware when possible */
                    128: #define        SO_LINGER       0x0080          /* linger on close if data present */
                    129: #define        SO_OOBINLINE    0x0100          /* leave received OOB data in line */
1.8       mycroft   130: #define        SO_REUSEPORT    0x0200          /* allow local address & port reuse */
1.94      christos  131: /*     SO_OTIMESTAMP   0x0400          */
1.105     christos  132: #define        SO_NOSIGPIPE    0x0800          /* no SIGPIPE from EPIPE */
1.91      tls       133: #define        SO_ACCEPTFILTER 0x1000          /* there is an accept filter */
1.94      christos  134: #define        SO_TIMESTAMP    0x2000          /* timestamp received dgram traffic */
1.1       cgd       135:
1.79      christos  136:
1.1       cgd       137: /*
                    138:  * Additional options, not kept in so_options.
                    139:  */
                    140: #define SO_SNDBUF      0x1001          /* send buffer size */
                    141: #define SO_RCVBUF      0x1002          /* receive buffer size */
                    142: #define SO_SNDLOWAT    0x1003          /* send low-water mark */
                    143: #define SO_RCVLOWAT    0x1004          /* receive low-water mark */
1.93      christos  144: /* SO_OSNDTIMEO                0x1005 */
                    145: /* SO_ORCVTIMEO                0x1006 */
1.1       cgd       146: #define        SO_ERROR        0x1007          /* get error status and clear */
                    147: #define        SO_TYPE         0x1008          /* get socket type */
1.69      darrenr   148: #define        SO_OVERFLOWED   0x1009          /* datagrams: return packets dropped */
1.1       cgd       149:
1.89      dyoung    150: #define        SO_NOHEADER     0x100a          /* user supplies no header to kernel;
                    151:                                         * kernel removes header and supplies
                    152:                                         * payload
                    153:                                         */
1.93      christos  154: #define SO_SNDTIMEO    0x100b          /* send timeout */
                    155: #define SO_RCVTIMEO    0x100c          /* receive timeout */
1.1       cgd       156: /*
                    157:  * Structure used for manipulating linger option.
                    158:  */
                    159: struct linger {
                    160:        int     l_onoff;                /* option on/off */
1.28      fvdl      161:        int     l_linger;               /* linger time in seconds */
1.1       cgd       162: };
                    163:
1.91      tls       164: struct accept_filter_arg {
                    165:        char    af_name[16];
                    166:        char    af_arg[256-16];
                    167: };
                    168:
1.1       cgd       169: /*
                    170:  * Level number for (get/set)sockopt() to apply to socket itself.
                    171:  */
                    172: #define        SOL_SOCKET      0xffff          /* options for socket level */
                    173:
                    174: /*
                    175:  * Address families.
                    176:  */
                    177: #define        AF_UNSPEC       0               /* unspecified */
1.97      pooka     178: #define        AF_LOCAL        1               /* local to host */
1.8       mycroft   179: #define        AF_UNIX         AF_LOCAL        /* backward compatibility */
1.1       cgd       180: #define        AF_INET         2               /* internetwork: UDP, TCP, etc. */
                    181: #define        AF_IMPLINK      3               /* arpanet imp addresses */
                    182: #define        AF_PUP          4               /* pup protocols: e.g. BSP */
                    183: #define        AF_CHAOS        5               /* mit CHAOS protocols */
                    184: #define        AF_NS           6               /* XEROX NS protocols */
                    185: #define        AF_ISO          7               /* ISO protocols */
                    186: #define        AF_OSI          AF_ISO
                    187: #define        AF_ECMA         8               /* european computer manufacturers */
                    188: #define        AF_DATAKIT      9               /* datakit protocols */
                    189: #define        AF_CCITT        10              /* CCITT protocols, X.25 etc */
                    190: #define        AF_SNA          11              /* IBM SNA */
                    191: #define AF_DECnet      12              /* DECnet */
                    192: #define AF_DLI         13              /* DEC Direct data link interface */
                    193: #define AF_LAT         14              /* LAT */
                    194: #define        AF_HYLINK       15              /* NSC Hyperchannel */
                    195: #define        AF_APPLETALK    16              /* Apple Talk */
1.99      matt      196: #define        AF_OROUTE       17              /* Internal Routing Protocol */
1.1       cgd       197: #define        AF_LINK         18              /* Link layer interface */
1.67      bjh21     198: #if defined(_NETBSD_SOURCE)
1.1       cgd       199: #define        pseudo_AF_XTP   19              /* eXpress Transfer Protocol (no AF) */
1.42      kleink    200: #endif
1.8       mycroft   201: #define        AF_COIP         20              /* connection-oriented IP, aka ST II */
                    202: #define        AF_CNT          21              /* Computer Network Technology */
1.67      bjh21     203: #if defined(_NETBSD_SOURCE)
1.8       mycroft   204: #define pseudo_AF_RTIP 22              /* Help Identify RTIP packets */
1.42      kleink    205: #endif
1.8       mycroft   206: #define        AF_IPX          23              /* Novell Internet Protocol */
1.21      sommerfe  207: #define        AF_INET6        24              /* IP version 6 */
1.67      bjh21     208: #if defined(_NETBSD_SOURCE)
1.8       mycroft   209: #define pseudo_AF_PIP  25              /* Help Identify PIP packets */
1.42      kleink    210: #endif
1.17      chuck     211: #define AF_ISDN                26              /* Integrated Services Digital Network*/
                    212: #define AF_E164                AF_ISDN         /* CCITT E.164 recommendation */
                    213: #define AF_NATM                27              /* native ATM access */
1.19      is        214: #define AF_ARP         28              /* (rev.) addr. res. prot. (RFC 826) */
1.67      bjh21     215: #if defined(_NETBSD_SOURCE)
1.21      sommerfe  216: #define pseudo_AF_KEY  29              /* Internal key management protocol  */
1.31      thorpej   217: #define        pseudo_AF_HDRCMPLT 30           /* Used by BPF to not rewrite hdrs
                    218:                                           in interface output routine */
1.42      kleink    219: #endif
1.83      plunky    220: #define AF_BLUETOOTH   31              /* Bluetooth: HCI, SCO, L2CAP, RFCOMM */
1.90      christos  221: #define        AF_IEEE80211    32              /* IEEE80211 */
1.98      kefren    222: #define        AF_MPLS         33              /* MultiProtocol Label Switching */
1.99      matt      223: #define        AF_ROUTE        34              /* Internal Routing Protocol */
1.122     bouyer    224: #define        AF_CAN          35
                    225: #define        AF_MAX          36
1.1       cgd       226:
                    227: /*
1.26      thorpej   228:  * Structure used by kernel to store most
                    229:  * addresses.
1.1       cgd       230:  */
                    231: struct sockaddr {
1.63      kleink    232:        __uint8_t       sa_len;         /* total length */
1.56      kleink    233:        sa_family_t     sa_family;      /* address family */
                    234:        char            sa_data[14];    /* actually longer; address value */
1.26      thorpej   235: };
1.1       cgd       236:
1.42      kleink    237: #if defined(_KERNEL)
1.1       cgd       238: /*
                    239:  * Structure used by kernel to pass protocol
                    240:  * information in raw sockets.
                    241:  */
                    242: struct sockproto {
                    243:        u_short sp_family;              /* address family */
                    244:        u_short sp_protocol;            /* protocol */
                    245: };
1.117     rtr       246:
                    247: /*
                    248:  * we make the entire struct at least UCHAR_MAX + 1 in size since existing
                    249:  * use of sockaddr_un permits a path up to 253 bytes + '\0'.
                    250:  * sizeof(sb_len) + sizeof(sb_family) + 253 + '\0'
                    251:  */
                    252: #define _SB_DATASIZE   254
                    253: struct sockaddr_big {
                    254:     union {
                    255:        struct {
                    256:            __uint8_t   sb_len;
                    257:            sa_family_t sb_family;
                    258:            char        sb_data[_SB_DATASIZE];
                    259:        };
                    260:        uint64_t dummy; /* solicit natural alignment */
                    261:     };
                    262: };
                    263:
1.42      kleink    264: #endif /* _KERNEL */
1.1       cgd       265:
1.44      itojun    266: #if 1
                    267: /*
                    268:  * RFC 2553: protocol-independent placeholder for socket addresses
                    269:  */
                    270: #define _SS_MAXSIZE    128
1.63      kleink    271: #define _SS_ALIGNSIZE  (sizeof(__int64_t))
1.60      kleink    272: #define _SS_PAD1SIZE   (_SS_ALIGNSIZE - 2)
                    273: #define _SS_PAD2SIZE   (_SS_MAXSIZE - 2 - \
1.44      itojun    274:                                _SS_PAD1SIZE - _SS_ALIGNSIZE)
                    275:
1.67      bjh21     276: #if (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
1.44      itojun    277: struct sockaddr_storage {
1.63      kleink    278:        __uint8_t       ss_len;         /* address length */
1.56      kleink    279:        sa_family_t     ss_family;      /* address family */
                    280:        char            __ss_pad1[_SS_PAD1SIZE];
1.63      kleink    281:        __int64_t     __ss_align;/* force desired structure storage alignment */
1.56      kleink    282:        char            __ss_pad2[_SS_PAD2SIZE];
1.44      itojun    283: };
1.89      dyoung    284: #define        sstosa(__ss)    ((struct sockaddr *)(__ss))
                    285: #define        sstocsa(__ss)   ((const struct sockaddr *)(__ss))
1.67      bjh21     286: #endif /* _XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */
1.46      kleink    287: #endif /* 1 */
1.44      itojun    288:
1.1       cgd       289: /*
                    290:  * Protocol families, same as address families for now.
                    291:  */
                    292: #define        PF_UNSPEC       AF_UNSPEC
1.8       mycroft   293: #define        PF_LOCAL        AF_LOCAL
                    294: #define        PF_UNIX         PF_LOCAL        /* backward compatibility */
1.1       cgd       295: #define        PF_INET         AF_INET
                    296: #define        PF_IMPLINK      AF_IMPLINK
                    297: #define        PF_PUP          AF_PUP
                    298: #define        PF_CHAOS        AF_CHAOS
                    299: #define        PF_NS           AF_NS
                    300: #define        PF_ISO          AF_ISO
                    301: #define        PF_OSI          AF_ISO
                    302: #define        PF_ECMA         AF_ECMA
                    303: #define        PF_DATAKIT      AF_DATAKIT
                    304: #define        PF_CCITT        AF_CCITT
                    305: #define        PF_SNA          AF_SNA
                    306: #define PF_DECnet      AF_DECnet
                    307: #define PF_DLI         AF_DLI
                    308: #define PF_LAT         AF_LAT
                    309: #define        PF_HYLINK       AF_HYLINK
                    310: #define        PF_APPLETALK    AF_APPLETALK
1.99      matt      311: #define        PF_OROUTE       AF_OROUTE
1.1       cgd       312: #define        PF_LINK         AF_LINK
1.67      bjh21     313: #if defined(_NETBSD_SOURCE)
1.1       cgd       314: #define        PF_XTP          pseudo_AF_XTP   /* really just proto family, no AF */
1.42      kleink    315: #endif
1.8       mycroft   316: #define        PF_COIP         AF_COIP
                    317: #define        PF_CNT          AF_CNT
1.21      sommerfe  318: #define        PF_INET6        AF_INET6
1.8       mycroft   319: #define        PF_IPX          AF_IPX          /* same format as AF_NS */
1.67      bjh21     320: #if defined(_NETBSD_SOURCE)
1.72      kleink    321: #define PF_RTIP                pseudo_AF_RTIP  /* same format as AF_INET */
1.8       mycroft   322: #define PF_PIP         pseudo_AF_PIP
1.42      kleink    323: #endif
1.20      is        324: #define PF_ISDN                AF_ISDN         /* same as E164 */
                    325: #define PF_E164                AF_E164
1.17      chuck     326: #define PF_NATM                AF_NATM
1.19      is        327: #define PF_ARP         AF_ARP
1.67      bjh21     328: #if defined(_NETBSD_SOURCE)
1.21      sommerfe  329: #define PF_KEY                 pseudo_AF_KEY   /* like PF_ROUTE, only for key mgmt */
1.42      kleink    330: #endif
1.80      gdamore   331: #define PF_BLUETOOTH   AF_BLUETOOTH
1.98      kefren    332: #define        PF_MPLS         AF_MPLS
1.99      matt      333: #define        PF_ROUTE        AF_ROUTE
1.122     bouyer    334: #define        PF_CAN          AF_CAN
1.1       cgd       335:
                    336: #define        PF_MAX          AF_MAX
                    337:
1.67      bjh21     338: #if defined(_NETBSD_SOURCE)
1.63      kleink    339:
1.119     roy       340: #ifndef pid_t
                    341: typedef __pid_t                pid_t;          /* process id */
                    342: #define pid_t          __pid_t
                    343: #endif
                    344:
1.63      kleink    345: #ifndef        gid_t
                    346: typedef        __gid_t         gid_t;          /* group id */
                    347: #define        gid_t           __gid_t
                    348: #endif
                    349:
                    350: #ifndef        uid_t
                    351: typedef        __uid_t         uid_t;          /* user id */
                    352: #define        uid_t           __uid_t
                    353: #endif
                    354:
1.1       cgd       355: /*
1.27      thorpej   356:  * Socket credentials.
                    357:  */
                    358: struct sockcred {
1.119     roy       359:        pid_t   sc_pid;                 /* process id */
1.27      thorpej   360:        uid_t   sc_uid;                 /* real user id */
                    361:        uid_t   sc_euid;                /* effective user id */
                    362:        gid_t   sc_gid;                 /* real group id */
                    363:        gid_t   sc_egid;                /* effective group id */
                    364:        int     sc_ngroups;             /* number of supplemental groups */
                    365:        gid_t   sc_groups[1];           /* variable length */
                    366: };
                    367:
                    368: /*
                    369:  * Compute size of a sockcred structure with groups.
                    370:  */
                    371: #define        SOCKCREDSIZE(ngrps) \
1.112     christos  372:        (/*CONSTCOND*/sizeof(struct sockcred) + (sizeof(gid_t) * \
1.110     christos  373:            ((ngrps) ? ((ngrps) - 1) : 0)))
1.67      bjh21     374: #endif /* _NETBSD_SOURCE */
1.27      thorpej   375:
1.38      kleink    376:
1.67      bjh21     377: #if defined(_NETBSD_SOURCE)
1.27      thorpej   378: /*
1.8       mycroft   379:  * Definitions for network related sysctl, CTL_NET.
                    380:  *
                    381:  * Second level is protocol family.
                    382:  * Third level is protocol number.
                    383:  *
                    384:  * Further levels are defined by the individual families below.
                    385:  */
                    386: #define NET_MAXID      AF_MAX
                    387:
                    388: #define CTL_NET_NAMES { \
                    389:        { 0, 0 }, \
1.28      fvdl      390:        { "local", CTLTYPE_NODE }, \
1.8       mycroft   391:        { "inet", CTLTYPE_NODE }, \
                    392:        { "implink", CTLTYPE_NODE }, \
                    393:        { "pup", CTLTYPE_NODE }, \
                    394:        { "chaos", CTLTYPE_NODE }, \
                    395:        { "xerox_ns", CTLTYPE_NODE }, \
                    396:        { "iso", CTLTYPE_NODE }, \
                    397:        { "emca", CTLTYPE_NODE }, \
                    398:        { "datakit", CTLTYPE_NODE }, \
                    399:        { "ccitt", CTLTYPE_NODE }, \
                    400:        { "ibm_sna", CTLTYPE_NODE }, \
                    401:        { "decnet", CTLTYPE_NODE }, \
                    402:        { "dec_dli", CTLTYPE_NODE }, \
                    403:        { "lat", CTLTYPE_NODE }, \
                    404:        { "hylink", CTLTYPE_NODE }, \
                    405:        { "appletalk", CTLTYPE_NODE }, \
1.99      matt      406:        { "oroute", CTLTYPE_NODE }, \
1.8       mycroft   407:        { "link_layer", CTLTYPE_NODE }, \
                    408:        { "xtp", CTLTYPE_NODE }, \
                    409:        { "coip", CTLTYPE_NODE }, \
                    410:        { "cnt", CTLTYPE_NODE }, \
                    411:        { "rtip", CTLTYPE_NODE }, \
                    412:        { "ipx", CTLTYPE_NODE }, \
1.21      sommerfe  413:        { "inet6", CTLTYPE_NODE }, \
1.8       mycroft   414:        { "pip", CTLTYPE_NODE }, \
1.20      is        415:        { "isdn", CTLTYPE_NODE }, \
1.17      chuck     416:        { "natm", CTLTYPE_NODE }, \
1.20      is        417:        { "arp", CTLTYPE_NODE }, \
1.21      sommerfe  418:        { "key", CTLTYPE_NODE }, \
1.99      matt      419:        { "ieee80211", CTLTYPE_NODE }, \
                    420:        { "mlps", CTLTYPE_NODE }, \
                    421:        { "route", CTLTYPE_NODE }, \
1.8       mycroft   422: }
1.73      atatat    423:
                    424: struct kinfo_pcb {
1.75      tron      425:        __uint64_t      ki_pcbaddr;     /* PTR: pcb addr */
                    426:        __uint64_t      ki_ppcbaddr;    /* PTR: ppcb addr */
                    427:        __uint64_t      ki_sockaddr;    /* PTR: socket addr */
                    428:
                    429:        __uint32_t      ki_family;      /* INT: protocol family */
                    430:        __uint32_t      ki_type;        /* INT: socket type */
                    431:        __uint32_t      ki_protocol;    /* INT: protocol */
                    432:        __uint32_t      ki_pflags;      /* INT: generic protocol flags */
                    433:
                    434:        __uint32_t      ki_sostate;     /* INT: socket state */
                    435:        __uint32_t      ki_prstate;     /* INT: protocol state */
                    436:        __int32_t       ki_tstate;      /* INT: tcp state */
                    437:        __uint32_t      ki_tflags;      /* INT: tcp flags */
1.73      atatat    438:
1.75      tron      439:        __uint64_t      ki_rcvq;        /* U_LONG: receive queue len */
                    440:        __uint64_t      ki_sndq;        /* U_LONG: send queue len */
1.73      atatat    441:
                    442:        union {
                    443:                struct sockaddr _kis_src; /* STRUCT: local address */
                    444:                char _kis_pad[256 + 8];         /* pad to max addr length */
                    445:        } ki_s;
                    446:        union {
                    447:                struct sockaddr _kid_dst; /* STRUCT: remote address */
                    448:                char _kid_pad[256 + 8];         /* pad to max addr length */
                    449:        } ki_d;
                    450:
1.75      tron      451:        __uint64_t      ki_inode;       /* INO_T: fake inode number */
                    452:        __uint64_t      ki_vnode;       /* PTR: if associated with file */
                    453:        __uint64_t      ki_conn;        /* PTR: control block of peer */
                    454:        __uint64_t      ki_refs;        /* PTR: referencing socket */
                    455:        __uint64_t      ki_nextref;     /* PTR: link in refs list */
1.73      atatat    456: };
                    457:
                    458: #define ki_src ki_s._kis_src
                    459: #define ki_dst ki_d._kid_dst
1.109     christos  460: #define ki_spad ki_s._kis_pad
                    461: #define ki_dpad ki_d._kid_pad
1.73      atatat    462:
                    463: #define PCB_SLOP               20
                    464: #define PCB_ALL                        0
                    465:
1.67      bjh21     466: #endif /* _NETBSD_SOURCE */
1.8       mycroft   467:
1.67      bjh21     468: #if defined(_NETBSD_SOURCE)
1.8       mycroft   469: /*
                    470:  * PF_ROUTE - Routing table
                    471:  *
                    472:  * Three additional levels are defined:
                    473:  *     Fourth: address family, 0 is wildcard
                    474:  *     Fifth: type of info, defined below
                    475:  *     Sixth: flag(s) to mask with for NET_RT_FLAGS
                    476:  */
1.120     roy       477: #define        NET_RT_DUMP             1       /* dump; may limit to a.f. */
                    478: #define        NET_RT_FLAGS            2       /* by flags, e.g. RESOLVING */
                    479: #define        NET_RT_OOOIFLIST        3       /* old NET_RT_IFLIST (pre 1.5) */
                    480: #define        NET_RT_OOIFLIST         4       /* old NET_RT_IFLIST (pre-64bit time) */
                    481: #define        NET_RT_OIFLIST          5       /* old NET_RT_IFLIST (pre 8.0) */
                    482: #define        NET_RT_IFLIST           6       /* survey interface list */
                    483: #define        NET_RT_MAXID            7
1.8       mycroft   484:
                    485: #define CTL_NET_RT_NAMES { \
                    486:        { 0, 0 }, \
                    487:        { "dump", CTLTYPE_STRUCT }, \
                    488:        { "flags", CTLTYPE_STRUCT }, \
1.47      bouyer    489:        { 0, 0 }, \
1.92      christos  490:        { 0, 0 }, \
1.8       mycroft   491:        { "iflist", CTLTYPE_STRUCT }, \
                    492: }
1.67      bjh21     493: #endif /* _NETBSD_SOURCE */
1.8       mycroft   494:
                    495: /*
1.13      mycroft   496:  * Maximum queue length specifiable by listen(2).
1.1       cgd       497:  */
1.66      christos  498: #ifndef SOMAXCONN
1.13      mycroft   499: #define        SOMAXCONN       128
1.66      christos  500: #endif
1.16      neil      501:
1.115     christos  502: #include <sys/cdefs.h>
                    503:
1.1       cgd       504: /*
                    505:  * Message header for recvmsg and sendmsg calls.
                    506:  * Used value-result for recvmsg, value only for sendmsg.
                    507:  */
                    508: struct msghdr {
1.42      kleink    509:        void            *msg_name;      /* optional address */
                    510:        socklen_t       msg_namelen;    /* size of address */
                    511:        struct iovec    *msg_iov;       /* scatter/gather array */
                    512:        int             msg_iovlen;     /* # elements in msg_iov */
                    513:        void            *msg_control;   /* ancillary data, see below */
                    514:        socklen_t       msg_controllen; /* ancillary data buffer len */
                    515:        int             msg_flags;      /* flags on received message */
1.1       cgd       516: };
                    517:
1.79      christos  518: #define        MSG_OOB         0x0001          /* process out-of-band data */
                    519: #define        MSG_PEEK        0x0002          /* peek at incoming message */
                    520: #define        MSG_DONTROUTE   0x0004          /* send without using routing tables */
                    521: #define        MSG_EOR         0x0008          /* data completes record */
                    522: #define        MSG_TRUNC       0x0010          /* data discarded before delivery */
                    523: #define        MSG_CTRUNC      0x0020          /* control data lost before delivery */
                    524: #define        MSG_WAITALL     0x0040          /* wait for full request or error */
                    525: #define        MSG_DONTWAIT    0x0080          /* this message should be nonblocking */
                    526: #define        MSG_BCAST       0x0100          /* this message was rcvd using link-level brdcst */
                    527: #define        MSG_MCAST       0x0200          /* this message was rcvd using link-level mcast */
                    528: #define        MSG_NOSIGNAL    0x0400          /* do not generate SIGPIPE on EOF */
1.100     christos  529: #if defined(_NETBSD_SOURCE)
                    530: #define        MSG_CMSG_CLOEXEC 0x0800         /* close on exec receiving fd */
1.101     christos  531: #define        MSG_NBIO        0x1000          /* use non-blocking I/O */
1.107     christos  532: #define        MSG_WAITFORONE  0x2000          /* recvmmsg() wait for one message */
1.118     rjs       533: #define        MSG_NOTIFICATION 0x4000         /* SCTP notification */
1.107     christos  534:
                    535: struct mmsghdr {
                    536:        struct msghdr msg_hdr;
                    537:        unsigned int msg_len;
                    538: };
1.100     christos  539: #endif
1.1       cgd       540:
1.86      dsl       541: /* Extra flags used internally only */
                    542: #define        MSG_USERFLAGS   0x0ffffff
                    543: #define MSG_NAMEMBUF   0x1000000       /* msg_name is an mbuf */
                    544: #define MSG_CONTROLMBUF        0x2000000       /* msg_control is an mbuf */
                    545: #define MSG_IOVUSRSPACE        0x4000000       /* msg_iov is in user space */
1.87      dsl       546: #define MSG_LENUSRSPACE        0x8000000       /* address length is in user space */
1.86      dsl       547:
1.1       cgd       548: /*
                    549:  * Header for ancillary data objects in msg_control buffer.
                    550:  * Used for additional information with/about a datagram
                    551:  * not expressible by flags.  The format is a sequence
                    552:  * of message elements headed by cmsghdr structures.
                    553:  */
                    554: struct cmsghdr {
1.42      kleink    555:        socklen_t       cmsg_len;       /* data byte count, including hdr */
                    556:        int             cmsg_level;     /* originating protocol */
                    557:        int             cmsg_type;      /* protocol-specific type */
1.1       cgd       558: /* followed by u_char  cmsg_data[]; */
                    559: };
                    560:
1.44      itojun    561: /*
                    562:  * Alignment requirement for CMSG struct manipulation.
1.51      itojun    563:  * This basically behaves the same as ALIGN() ARCH/include/param.h.
                    564:  * We declare it separately for two reasons:
                    565:  * (1) avoid dependency between machine/param.h, and (2) to sync with kernel's
                    566:  * idea of ALIGNBYTES at runtime.
                    567:  * without (2), we can't guarantee binary compatibility in case of future
                    568:  * changes in ALIGNBYTES.
1.44      itojun    569:  */
1.104     joerg     570: #define __CMSG_ALIGN(n)        (((n) + __ALIGNBYTES) & ~__ALIGNBYTES)
1.115     christos  571:
1.102     joerg     572: #ifdef _KERNEL
                    573: #define CMSG_ALIGN(n)  __CMSG_ALIGN(n)
1.53      itojun    574: #endif
1.44      itojun    575:
1.115     christos  576: #define __CMSG_ASIZE   __CMSG_ALIGN(sizeof(struct cmsghdr))
                    577: #define __CMSG_MSGNEXT(cmsg) \
                    578:     (__CASTV(char *, cmsg) + __CMSG_ALIGN((cmsg)->cmsg_len))
                    579: #define __CMSG_MSGEND(mhdr) \
                    580:     (__CASTV(char *, (mhdr)->msg_control) + (mhdr)->msg_controllen)
                    581:
                    582: /* given pointer to struct cmsghdr, return pointer to data */
                    583: #define        CMSG_DATA(cmsg) (__CASTV(u_char *, cmsg) + __CMSG_ASIZE)
                    584: #define        CCMSG_DATA(cmsg) (__CASTCV(const u_char *, cmsg) + __CMSG_ASIZE)
                    585:
1.8       mycroft   586: /* given pointer to struct cmsghdr, return pointer to next cmsghdr */
1.1       cgd       587: #define        CMSG_NXTHDR(mhdr, cmsg) \
1.115     christos  588:     __CASTV(struct cmsghdr *,  \
                    589:        __CMSG_MSGNEXT(cmsg) + __CMSG_ASIZE > __CMSG_MSGEND(mhdr) ? 0 : \
                    590:        __CMSG_MSGNEXT(cmsg))
1.1       cgd       591:
1.62      itojun    592: /*
                    593:  * RFC 2292 requires to check msg_controllen, in case that the kernel returns
                    594:  * an empty list for some reasons.
                    595:  */
                    596: #define        CMSG_FIRSTHDR(mhdr) \
1.115     christos  597:     __CASTV(struct cmsghdr *, \
                    598:        (mhdr)->msg_controllen < sizeof(struct cmsghdr) ? 0 : \
                    599:        (mhdr)->msg_control)
1.1       cgd       600:
1.115     christos  601: #define CMSG_SPACE(l)  (__CMSG_ASIZE + __CMSG_ALIGN(l))
                    602: #define CMSG_LEN(l)    (__CMSG_ASIZE + (l))
1.44      itojun    603:
1.1       cgd       604: /* "Socket"-level control message types: */
                    605: #define        SCM_RIGHTS      0x01            /* access rights (array of int) */
1.67      bjh21     606: #if defined(_NETBSD_SOURCE)
1.119     roy       607: /*                     0x02               timestamp (struct timeval50) */
                    608: /*                     0x04               credentials (struct sockcred70) */
1.94      christos  609: #define        SCM_TIMESTAMP   0x08            /* timestamp (struct timeval) */
1.119     roy       610: #define        SCM_CREDS       0x10            /* credentials (struct sockcred) */
1.42      kleink    611: #endif
1.29      kleink    612:
                    613: /*
                    614:  * Types of socket shutdown(2).
                    615:  */
                    616: #define        SHUT_RD         0               /* Disallow further receives. */
                    617: #define        SHUT_WR         1               /* Disallow further sends. */
                    618: #define        SHUT_RDWR       2               /* Disallow further sends/receives. */
1.1       cgd       619:
1.85      dyoung    620: #ifdef _KERNEL
1.123.4.1! pgoyette  621: static __inline socklen_t
1.89      dyoung    622: sockaddr_getlen(const struct sockaddr *sa)
                    623: {
                    624:        return sa->sa_len;
                    625: }
                    626:
1.85      dyoung    627: __BEGIN_DECLS
1.123     christos  628: socklen_t sockaddr_getsize_by_family(sa_family_t);
1.88      dyoung    629: struct sockaddr *sockaddr_copy(struct sockaddr *, socklen_t,
                    630:     const struct sockaddr *);
1.96      dyoung    631: struct sockaddr *sockaddr_externalize(struct sockaddr *, socklen_t,
                    632:     const struct sockaddr *);
1.88      dyoung    633: struct sockaddr *sockaddr_alloc(sa_family_t, socklen_t, int);
1.89      dyoung    634: const void *sockaddr_const_addr(const struct sockaddr *, socklen_t *);
                    635: void *sockaddr_addr(struct sockaddr *, socklen_t *);
                    636: const struct sockaddr *sockaddr_any(const struct sockaddr *);
1.123     christos  637: const struct sockaddr *sockaddr_any_by_family(sa_family_t);
1.89      dyoung    638: const void *sockaddr_anyaddr(const struct sockaddr *, socklen_t *);
1.85      dyoung    639: int sockaddr_cmp(const struct sockaddr *, const struct sockaddr *);
                    640: struct sockaddr *sockaddr_dup(const struct sockaddr *, int);
1.111     christos  641: int sockaddr_format(const struct sockaddr *, char *, size_t);
1.85      dyoung    642: void sockaddr_free(struct sockaddr *);
                    643: __END_DECLS
                    644: #endif /* _KERNEL */
                    645:
1.12      briggs    646: #ifndef        _KERNEL
1.1       cgd       647:
                    648: __BEGIN_DECLS
1.70      perry     649: int    accept(int, struct sockaddr * __restrict, socklen_t * __restrict);
1.121     maya      650: int    accept4(int, struct sockaddr * __restrict, socklen_t * __restrict, int);
1.70      perry     651: int    bind(int, const struct sockaddr *, socklen_t);
                    652: int    connect(int, const struct sockaddr *, socklen_t);
                    653: int    getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict);
                    654: int    getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict);
1.84      christos  655: int    getsockopt(int, int, int, void *__restrict, socklen_t * __restrict);
1.70      perry     656: int    listen(int, int);
1.100     christos  657: int    paccept(int, struct sockaddr * __restrict, socklen_t * __restrict,
                    658:        const sigset_t * __restrict, int);
1.70      perry     659: ssize_t        recv(int, void *, size_t, int);
1.84      christos  660: ssize_t        recvfrom(int, void *__restrict, size_t, int,
1.70      perry     661:            struct sockaddr * __restrict, socklen_t * __restrict);
                    662: ssize_t        recvmsg(int, struct msghdr *, int);
                    663: ssize_t        send(int, const void *, size_t, int);
                    664: ssize_t        sendto(int, const void *,
                    665:            size_t, int, const struct sockaddr *, socklen_t);
                    666: ssize_t        sendmsg(int, const struct msghdr *, int);
                    667: int    setsockopt(int, int, int, const void *, socklen_t);
                    668: int    shutdown(int, int);
                    669: int    sockatmark(int);
1.81      mrg       670: int    socket(int, int, int)
1.82      mrg       671: #if !defined(__LIBC12_SOURCE__) && !defined(_STANDALONE)
1.81      mrg       672: __RENAME(__socket30)
                    673: #endif
                    674:                             ;
1.70      perry     675: int    socketpair(int, int, int, int *);
1.107     christos  676:
                    677: #if defined(_NETBSD_SOURCE)
                    678: int    sendmmsg(int, struct mmsghdr *, unsigned int, unsigned int);
                    679: struct timespec;
                    680: int    recvmmsg(int, struct mmsghdr *, unsigned int, unsigned int,
                    681:     struct timespec *);
                    682: #endif
1.1       cgd       683: __END_DECLS
1.14      christos  684: #endif /* !_KERNEL */
1.1       cgd       685:
1.2       mycroft   686: #endif /* !_SYS_SOCKET_H_ */

CVSweb <webmaster@jp.NetBSD.org>