The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/bsd/sys/socket.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
    3  *
    4  * @APPLE_LICENSE_HEADER_START@
    5  * 
    6  * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
    7  * 
    8  * This file contains Original Code and/or Modifications of Original Code
    9  * as defined in and that are subject to the Apple Public Source License
   10  * Version 2.0 (the 'License'). You may not use this file except in
   11  * compliance with the License. Please obtain a copy of the License at
   12  * http://www.opensource.apple.com/apsl/ and read it before using this
   13  * file.
   14  * 
   15  * The Original Code and all software distributed under the License are
   16  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
   17  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
   18  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
   19  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
   20  * Please see the License for the specific language governing rights and
   21  * limitations under the License.
   22  * 
   23  * @APPLE_LICENSE_HEADER_END@
   24  */
   25 /* Copyright (c) 1998, 1999 Apple Computer, Inc. All Rights Reserved */
   26 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
   27 /*
   28  * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994
   29  *      The Regents of the University of California.  All rights reserved.
   30  *
   31  * Redistribution and use in source and binary forms, with or without
   32  * modification, are permitted provided that the following conditions
   33  * are met:
   34  * 1. Redistributions of source code must retain the above copyright
   35  *    notice, this list of conditions and the following disclaimer.
   36  * 2. Redistributions in binary form must reproduce the above copyright
   37  *    notice, this list of conditions and the following disclaimer in the
   38  *    documentation and/or other materials provided with the distribution.
   39  * 3. All advertising materials mentioning features or use of this software
   40  *    must display the following acknowledgement:
   41  *      This product includes software developed by the University of
   42  *      California, Berkeley and its contributors.
   43  * 4. Neither the name of the University nor the names of its contributors
   44  *    may be used to endorse or promote products derived from this software
   45  *    without specific prior written permission.
   46  *
   47  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   48  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   49  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   50  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   51  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   52  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   53  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   54  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   55  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   56  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   57  * SUCH DAMAGE.
   58  *
   59  *      @(#)socket.h    8.4 (Berkeley) 2/21/94
   60  * $FreeBSD: src/sys/sys/socket.h,v 1.39.2.7 2001/07/03 11:02:01 ume Exp $
   61  */
   62 
   63 #ifndef _SYS_SOCKET_H_
   64 #define _SYS_SOCKET_H_
   65 
   66 #ifndef __APPLE__
   67 #include <machine/ansi.h>
   68 #endif
   69 #define _NO_NAMESPACE_POLLUTION
   70 #include <machine/param.h>
   71 #undef _NO_NAMESPACE_POLLUTION
   72 
   73 /*
   74  * Definitions related to sockets: types, address families, options.
   75  */
   76 
   77 /*
   78  * Data types.
   79  */
   80 typedef u_char          sa_family_t;
   81 #ifdef  _BSD_SOCKLEN_T_
   82 typedef _BSD_SOCKLEN_T_ socklen_t;
   83 #undef  _BSD_SOCKLEN_T_
   84 #endif
   85  
   86 /*
   87  * Types
   88  */
   89 #define SOCK_STREAM     1               /* stream socket */
   90 #define SOCK_DGRAM      2               /* datagram socket */
   91 #define SOCK_RAW        3               /* raw-protocol interface */
   92 #define SOCK_RDM        4               /* reliably-delivered message */
   93 #define SOCK_SEQPACKET  5               /* sequenced packet stream */
   94 
   95 /*
   96  * Option flags per-socket.
   97  */
   98 #define SO_DEBUG        0x0001          /* turn on debugging info recording */
   99 #define SO_ACCEPTCONN   0x0002          /* socket has had listen() */
  100 #define SO_REUSEADDR    0x0004          /* allow local address reuse */
  101 #define SO_KEEPALIVE    0x0008          /* keep connections alive */
  102 #define SO_DONTROUTE    0x0010          /* just use interface addresses */
  103 #define SO_BROADCAST    0x0020          /* permit sending of broadcast msgs */
  104 #define SO_USELOOPBACK  0x0040          /* bypass hardware when possible */
  105 #define SO_LINGER       0x0080          /* linger on close if data present */
  106 #define SO_OOBINLINE    0x0100          /* leave received OOB data in line */
  107 #define SO_REUSEPORT    0x0200          /* allow local address & port reuse */
  108 #define SO_TIMESTAMP    0x0400          /* timestamp received dgram traffic */
  109 #ifndef __APPLE__
  110 #define SO_ACCEPTFILTER 0x1000          /* there is an accept filter */
  111 #else
  112 #define SO_DONTTRUNC    0x2000          /* APPLE: Retain unread data */
  113                                         /*  (ATOMIC proto) */
  114 #define SO_WANTMORE             0x4000          /* APPLE: Give hint when more data ready */
  115 #define SO_WANTOOBFLAG  0x8000          /* APPLE: Want OOB in MSG_FLAG on receive */
  116 #endif
  117 
  118 /*
  119  * Additional options, not kept in so_options.
  120  */
  121 #define SO_SNDBUF       0x1001          /* send buffer size */
  122 #define SO_RCVBUF       0x1002          /* receive buffer size */
  123 #define SO_SNDLOWAT     0x1003          /* send low-water mark */
  124 #define SO_RCVLOWAT     0x1004          /* receive low-water mark */
  125 #define SO_SNDTIMEO     0x1005          /* send timeout */
  126 #define SO_RCVTIMEO     0x1006          /* receive timeout */
  127 #define SO_ERROR        0x1007          /* get error status and clear */
  128 #define SO_TYPE         0x1008          /* get socket type */
  129 /*efine SO_PRIVSTATE    0x1009             get/deny privileged state */
  130 #ifdef __APPLE__
  131 #define SO_NREAD        0x1020          /* APPLE: get 1st-packet byte count */
  132 #define SO_NKE          0x1021          /* APPLE: Install socket-level NKE */
  133 #define SO_NOSIGPIPE    0x1022          /* APPLE: No SIGPIPE on EPIPE */
  134 #define SO_NOADDRERR    0x1023          /* APPLE: Returns EADDRNOTAVAIL when src is not available anymore */
  135 #endif
  136 /*
  137  * Structure used for manipulating linger option.
  138  */
  139 struct  linger {
  140         int     l_onoff;                /* option on/off */
  141         int     l_linger;               /* linger time */
  142 };
  143 
  144 #ifndef __APPLE__
  145 struct  accept_filter_arg {
  146         char    af_name[16];
  147         char    af_arg[256-16];
  148 };
  149 #endif
  150 
  151 /*
  152  * Level number for (get/set)sockopt() to apply to socket itself.
  153  */
  154 #define SOL_SOCKET      0xffff          /* options for socket level */
  155 
  156 /*
  157  * Address families.
  158  */
  159 #define AF_UNSPEC       0               /* unspecified */
  160 #define AF_LOCAL        1               /* local to host (pipes) */
  161 #define AF_UNIX         AF_LOCAL        /* backward compatibility */
  162 #define AF_INET         2               /* internetwork: UDP, TCP, etc. */
  163 #define AF_IMPLINK      3               /* arpanet imp addresses */
  164 #define AF_PUP          4               /* pup protocols: e.g. BSP */
  165 #define AF_CHAOS        5               /* mit CHAOS protocols */
  166 #define AF_NS           6               /* XEROX NS protocols */
  167 #define AF_ISO          7               /* ISO protocols */
  168 #define AF_OSI          AF_ISO
  169 #define AF_ECMA         8               /* European computer manufacturers */
  170 #define AF_DATAKIT      9               /* datakit protocols */
  171 #define AF_CCITT        10              /* CCITT protocols, X.25 etc */
  172 #define AF_SNA          11              /* IBM SNA */
  173 #define AF_DECnet       12              /* DECnet */
  174 #define AF_DLI          13              /* DEC Direct data link interface */
  175 #define AF_LAT          14              /* LAT */
  176 #define AF_HYLINK       15              /* NSC Hyperchannel */
  177 #define AF_APPLETALK    16              /* Apple Talk */
  178 #define AF_ROUTE        17              /* Internal Routing Protocol */
  179 #define AF_LINK         18              /* Link layer interface */
  180 #define pseudo_AF_XTP   19              /* eXpress Transfer Protocol (no AF) */
  181 #define AF_COIP         20              /* connection-oriented IP, aka ST II */
  182 #define AF_CNT          21              /* Computer Network Technology */
  183 #define pseudo_AF_RTIP  22              /* Help Identify RTIP packets */
  184 #define AF_IPX          23              /* Novell Internet Protocol */
  185 #define AF_SIP          24              /* Simple Internet Protocol */
  186 #define pseudo_AF_PIP   25              /* Help Identify PIP packets */
  187 #ifdef __APPLE__
  188 /*define pseudo_AF_BLUE 26         Identify packets for Blue Box - Not used */
  189 #define AF_NDRV         27              /* Network Driver 'raw' access */
  190 #endif
  191 #define AF_ISDN         28              /* Integrated Services Digital Network*/
  192 #define AF_E164         AF_ISDN         /* CCITT E.164 recommendation */
  193 #define pseudo_AF_KEY   29              /* Internal key-management function */
  194 #define AF_INET6        30              /* IPv6 */
  195 #define AF_NATM         31              /* native ATM access */
  196 #ifdef __APPLE__
  197 #define AF_SYSTEM       32              /* Kernel event messages */
  198 #define AF_NETBIOS      33              /* NetBIOS */
  199 #define AF_PPP          34              /* PPP communication protocol */
  200 #else
  201 #define AF_ATM          30              /* ATM */
  202 #endif
  203 #define pseudo_AF_HDRCMPLT 35           /* Used by BPF to not rewrite headers
  204                                          * in interface output routine
  205                                          */
  206 #ifndef __APPLE__
  207 #define AF_NETGRAPH     32              /* Netgraph sockets */
  208 #endif
  209 #define AF_MAX          36
  210 
  211 /*
  212  * Structure used by kernel to store most
  213  * addresses.
  214  */
  215 struct sockaddr {
  216         u_char  sa_len;                 /* total length */
  217         u_char  sa_family;              /* address family */
  218         char            sa_data[14];            /* actually longer; address value */
  219 };
  220 #define SOCK_MAXADDRLEN 255             /* longest possible addresses */
  221 
  222 /*
  223  * Structure used by kernel to pass protocol
  224  * information in raw sockets.
  225  */
  226 struct sockproto {
  227         u_short sp_family;              /* address family */
  228         u_short sp_protocol;            /* protocol */
  229 };
  230 
  231 /*
  232  * RFC 2553: protocol-independent placeholder for socket addresses
  233  */
  234 #define _SS_MAXSIZE     128
  235 #define _SS_ALIGNSIZE   (sizeof(int64_t))
  236 #define _SS_PAD1SIZE    (_SS_ALIGNSIZE - sizeof(u_char) - sizeof(sa_family_t))
  237 #define _SS_PAD2SIZE    (_SS_MAXSIZE - sizeof(u_char) - sizeof(sa_family_t) - \
  238                                 _SS_PAD1SIZE - _SS_ALIGNSIZE)
  239 
  240 struct sockaddr_storage {
  241         u_char          ss_len;         /* address length */
  242         sa_family_t     ss_family;      /* address family */
  243         char                    __ss_pad1[_SS_PAD1SIZE];
  244         int64_t         __ss_align;     /* force desired structure storage alignment */
  245         char                    __ss_pad2[_SS_PAD2SIZE];
  246 };
  247 
  248 /*
  249  * Protocol families, same as address families for now.
  250  */
  251 #define PF_UNSPEC       AF_UNSPEC
  252 #define PF_LOCAL        AF_LOCAL
  253 #define PF_UNIX         PF_LOCAL        /* backward compatibility */
  254 #define PF_INET         AF_INET
  255 #define PF_IMPLINK      AF_IMPLINK
  256 #define PF_PUP          AF_PUP
  257 #define PF_CHAOS        AF_CHAOS
  258 #define PF_NS           AF_NS
  259 #define PF_ISO          AF_ISO
  260 #define PF_OSI          AF_ISO
  261 #define PF_ECMA         AF_ECMA
  262 #define PF_DATAKIT      AF_DATAKIT
  263 #define PF_CCITT        AF_CCITT
  264 #define PF_SNA          AF_SNA
  265 #define PF_DECnet       AF_DECnet
  266 #define PF_DLI          AF_DLI
  267 #define PF_LAT          AF_LAT
  268 #define PF_HYLINK       AF_HYLINK
  269 #define PF_APPLETALK    AF_APPLETALK
  270 #define PF_ROUTE        AF_ROUTE
  271 #define PF_LINK         AF_LINK
  272 #define PF_XTP          pseudo_AF_XTP   /* really just proto family, no AF */
  273 #define PF_COIP         AF_COIP
  274 #define PF_CNT          AF_CNT
  275 #define PF_SIP          AF_SIP
  276 #define PF_IPX          AF_IPX          /* same format as AF_NS */
  277 #define PF_RTIP         pseudo_AF_RTIP  /* same format as AF_INET */
  278 #define PF_PIP          pseudo_AF_PIP
  279 #ifdef __APPLE__
  280 #define PF_NDRV         AF_NDRV
  281 #endif
  282 #define PF_ISDN         AF_ISDN
  283 #define PF_KEY          pseudo_AF_KEY
  284 #define PF_INET6        AF_INET6
  285 #define PF_NATM         AF_NATM
  286 #ifdef __APPLE__
  287 #define PF_SYSTEM       AF_SYSTEM
  288 #define PF_NETBIOS      AF_NETBIOS
  289 #define PF_PPP          AF_PPP
  290 #else
  291 #define PF_ATM          AF_ATM
  292 #define PF_NETGRAPH     AF_NETGRAPH
  293 #endif
  294 
  295 #define PF_MAX          AF_MAX
  296 
  297 /*
  298  * Definitions for network related sysctl, CTL_NET.
  299  *
  300  * Second level is protocol family.
  301  * Third level is protocol number.
  302  *
  303  * Further levels are defined by the individual families below.
  304  */
  305 #define NET_MAXID       AF_MAX
  306 
  307 #define CTL_NET_NAMES { \
  308         { 0, 0 }, \
  309         { "local", CTLTYPE_NODE }, \
  310         { "inet", CTLTYPE_NODE }, \
  311         { "implink", CTLTYPE_NODE }, \
  312         { "pup", CTLTYPE_NODE }, \
  313         { "chaos", CTLTYPE_NODE }, \
  314         { "xerox_ns", CTLTYPE_NODE }, \
  315         { "iso", CTLTYPE_NODE }, \
  316         { "emca", CTLTYPE_NODE }, \
  317         { "datakit", CTLTYPE_NODE }, \
  318         { "ccitt", CTLTYPE_NODE }, \
  319         { "ibm_sna", CTLTYPE_NODE }, \
  320         { "decnet", CTLTYPE_NODE }, \
  321         { "dec_dli", CTLTYPE_NODE }, \
  322         { "lat", CTLTYPE_NODE }, \
  323         { "hylink", CTLTYPE_NODE }, \
  324         { "appletalk", CTLTYPE_NODE }, \
  325         { "route", CTLTYPE_NODE }, \
  326         { "link_layer", CTLTYPE_NODE }, \
  327         { "xtp", CTLTYPE_NODE }, \
  328         { "coip", CTLTYPE_NODE }, \
  329         { "cnt", CTLTYPE_NODE }, \
  330         { "rtip", CTLTYPE_NODE }, \
  331         { "ipx", CTLTYPE_NODE }, \
  332         { "sip", CTLTYPE_NODE }, \
  333         { "pip", CTLTYPE_NODE }, \
  334         { 0, 0 }, \
  335         { "ndrv", CTLTYPE_NODE }, \
  336         { "isdn", CTLTYPE_NODE }, \
  337         { "key", CTLTYPE_NODE }, \
  338         { "inet6", CTLTYPE_NODE }, \
  339         { "natm", CTLTYPE_NODE }, \
  340         { "sys", CTLTYPE_NODE }, \
  341         { "netbios", CTLTYPE_NODE }, \
  342         { "ppp", CTLTYPE_NODE }, \
  343         { "hdrcomplete", CTLTYPE_NODE }, \
  344 }
  345 
  346 /*
  347  * PF_ROUTE - Routing table
  348  *
  349  * Three additional levels are defined:
  350  *      Fourth: address family, 0 is wildcard
  351  *      Fifth: type of info, defined below
  352  *      Sixth: flag(s) to mask with for NET_RT_FLAGS
  353  */
  354 #define NET_RT_DUMP     1               /* dump; may limit to a.f. */
  355 #define NET_RT_FLAGS    2               /* by flags, e.g. RESOLVING */
  356 #define NET_RT_IFLIST   3               /* survey interface list */
  357 #define NET_RT_MAXID    4
  358 
  359 #define CTL_NET_RT_NAMES { \
  360         { 0, 0 }, \
  361         { "dump", CTLTYPE_STRUCT }, \
  362         { "flags", CTLTYPE_STRUCT }, \
  363         { "iflist", CTLTYPE_STRUCT }, \
  364 }
  365 
  366 /*
  367  * Maximum queue length specifiable by listen.
  368  */
  369 #define SOMAXCONN       128
  370 
  371 /*
  372  * Message header for recvmsg and sendmsg calls.
  373  * Used value-result for recvmsg, value only for sendmsg.
  374  */
  375 struct msghdr {
  376         caddr_t         msg_name;               /* optional address */
  377         socklen_t       msg_namelen;            /* size of address */
  378         struct          iovec *msg_iov;         /* scatter/gather array */
  379         u_int           msg_iovlen;             /* # elements in msg_iov */
  380         caddr_t         msg_control;            /* ancillary data, see below */
  381         socklen_t       msg_controllen;         /* ancillary data buffer len */
  382         int             msg_flags;              /* flags on received message */
  383 };
  384 
  385 #define MSG_OOB         0x1             /* process out-of-band data */
  386 #define MSG_PEEK        0x2             /* peek at incoming message */
  387 #define MSG_DONTROUTE   0x4             /* send without using routing tables */
  388 #define MSG_EOR         0x8             /* data completes record */
  389 #define MSG_TRUNC       0x10            /* data discarded before delivery */
  390 #define MSG_CTRUNC      0x20            /* control data lost before delivery */
  391 #define MSG_WAITALL     0x40            /* wait for full request or error */
  392 #define MSG_DONTWAIT    0x80            /* this message should be nonblocking */
  393 #define MSG_EOF         0x100           /* data completes connection */
  394 #ifdef __APPLE__
  395 #define MSG_WAITSTREAM  0x200           /* wait up to full request.. may return partial */
  396 #define MSG_FLUSH       0x400           /* Start of 'hold' seq; dump so_temp */
  397 #define MSG_HOLD        0x800           /* Hold frag in so_temp */
  398 #define MSG_SEND        0x1000          /* Send the packet in so_temp */
  399 #define MSG_HAVEMORE    0x2000          /* Data ready to be read */
  400 #define MSG_RCVMORE     0x4000          /* Data remains in current pkt */
  401 #endif
  402 #define MSG_COMPAT      0x8000          /* used in sendit() */
  403 
  404 /*
  405  * Header for ancillary data objects in msg_control buffer.
  406  * Used for additional information with/about a datagram
  407  * not expressible by flags.  The format is a sequence
  408  * of message elements headed by cmsghdr structures.
  409  */
  410 struct cmsghdr {
  411         socklen_t       cmsg_len;               /* data byte count, including hdr */
  412         int             cmsg_level;             /* originating protocol */
  413         int             cmsg_type;              /* protocol-specific type */
  414 /* followed by  u_char  cmsg_data[]; */
  415 };
  416 
  417 #ifndef __APPLE__
  418 /*
  419  * While we may have more groups than this, the cmsgcred struct must
  420  * be able to fit in an mbuf, and NGROUPS_MAX is too large to allow
  421  * this.
  422 */
  423 #define CMGROUP_MAX 16
  424 
  425 /*
  426  * Credentials structure, used to verify the identity of a peer
  427  * process that has sent us a message. This is allocated by the
  428  * peer process but filled in by the kernel. This prevents the
  429  * peer from lying about its identity. (Note that cmcred_groups[0]
  430  * is the effective GID.)
  431  */
  432 struct cmsgcred {
  433         pid_t   cmcred_pid;             /* PID of sending process */
  434         uid_t   cmcred_uid;             /* real UID of sending process */
  435         uid_t   cmcred_euid;            /* effective UID of sending process */
  436         gid_t   cmcred_gid;             /* real GID of sending process */
  437         short   cmcred_ngroups;         /* number or groups */
  438         gid_t   cmcred_groups[CMGROUP_MAX];     /* groups */
  439 };
  440 #endif
  441 
  442 /* given pointer to struct cmsghdr, return pointer to data */
  443 #define CMSG_DATA(cmsg)         ((u_char *)(cmsg) + \
  444                                  ALIGN(sizeof(struct cmsghdr)))
  445 
  446 /* given pointer to struct cmsghdr, return pointer to next cmsghdr */
  447 #define CMSG_NXTHDR(mhdr, cmsg) \
  448         (((caddr_t)(cmsg) + ALIGN((cmsg)->cmsg_len) + \
  449           ALIGN(sizeof(struct cmsghdr)) > \
  450             (caddr_t)(mhdr)->msg_control + (mhdr)->msg_controllen) ? \
  451             (struct cmsghdr *)NULL : \
  452             (struct cmsghdr *)((caddr_t)(cmsg) + ALIGN((cmsg)->cmsg_len)))
  453 
  454 #define CMSG_FIRSTHDR(mhdr)     ((struct cmsghdr *)(mhdr)->msg_control)
  455 
  456 /* RFC 2292 additions */
  457         
  458 #define CMSG_SPACE(l)           (ALIGN(sizeof(struct cmsghdr)) + ALIGN(l))
  459 #define CMSG_LEN(l)             (ALIGN(sizeof(struct cmsghdr)) + (l))
  460 
  461 #ifdef KERNEL
  462 #define CMSG_ALIGN(n)   ALIGN(n)
  463 #endif
  464 
  465 /* "Socket"-level control message types: */
  466 #define SCM_RIGHTS      0x01            /* access rights (array of int) */
  467 #define SCM_TIMESTAMP   0x02            /* timestamp (struct timeval) */
  468 #define SCM_CREDS       0x03            /* process creds (struct cmsgcred) */
  469 
  470 /*
  471  * 4.3 compat sockaddr, move to compat file later
  472  */
  473 struct osockaddr {
  474         u_short sa_family;              /* address family */
  475         char    sa_data[14];            /* up to 14 bytes of direct address */
  476 };
  477 
  478 /*
  479  * 4.3-compat message header (move to compat file later).
  480  */
  481 struct omsghdr {
  482         caddr_t msg_name;               /* optional address */
  483         int     msg_namelen;            /* size of address */
  484         struct  iovec *msg_iov;         /* scatter/gather array */
  485         int     msg_iovlen;             /* # elements in msg_iov */
  486         caddr_t msg_accrights;          /* access rights sent/received */
  487         int     msg_accrightslen;
  488 };
  489 
  490 /*
  491  * howto arguments for shutdown(2), specified by Posix.1g.
  492  */
  493 #define SHUT_RD         0               /* shut down the reading side */
  494 #define SHUT_WR         1               /* shut down the writing side */
  495 #define SHUT_RDWR       2               /* shut down both sides */
  496 
  497 #if SENDFILE
  498 /*
  499  * sendfile(2) header/trailer struct
  500  */
  501 struct sf_hdtr {
  502         struct iovec *headers;  /* pointer to an array of header struct iovec's */
  503         int hdr_cnt;            /* number of header iovec's */
  504         struct iovec *trailers; /* pointer to an array of trailer struct iovec's */
  505         int trl_cnt;            /* number of trailer iovec's */
  506 };
  507 #endif
  508 
  509 #ifndef KERNEL
  510 
  511 #include <sys/cdefs.h>
  512 
  513 __BEGIN_DECLS
  514 int     accept __P((int, struct sockaddr *, socklen_t *));
  515 int     bind __P((int, const struct sockaddr *, socklen_t));
  516 int     connect __P((int, const struct sockaddr *, socklen_t));
  517 int     getpeername __P((int, struct sockaddr *, socklen_t *));
  518 int     getsockname __P((int, struct sockaddr *, socklen_t *));
  519 int     getsockopt __P((int, int, int, void *, int *));
  520 int     listen __P((int, int));
  521 ssize_t recv __P((int, void *, size_t, int));
  522 ssize_t recvfrom __P((int, void *, size_t, int, struct sockaddr *, socklen_t *));
  523 ssize_t recvmsg __P((int, struct msghdr *, int));
  524 ssize_t send __P((int, const void *, size_t, int));
  525 ssize_t sendto __P((int, const void *,
  526             size_t, int, const struct sockaddr *, socklen_t));
  527 ssize_t sendmsg __P((int, const struct msghdr *, int));
  528 #if SENDFILE
  529 int     sendfile __P((int, int, off_t, size_t, struct sf_hdtr *, off_t *, int));
  530 #endif
  531 int     setsockopt __P((int, int, int, const void *, socklen_t));
  532 int     shutdown __P((int, int));
  533 int     socket __P((int, int, int));
  534 int     socketpair __P((int, int, int, int *));
  535 
  536 void    pfctlinput __P((int, struct sockaddr *));
  537 __END_DECLS
  538 
  539 #endif /* !KERNEL */
  540 
  541 #endif /* !_SYS_SOCKET_H_ */

Cache object: 13e61839be54807e439d69a29578d4c5


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.