socket.h revision 78137
1180740Sdes/* 2255670Sdes * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994 3180740Sdes * The Regents of the University of California. All rights reserved. 4225825Sdes * 5180740Sdes * Redistribution and use in source and binary forms, with or without 6180740Sdes * modification, are permitted provided that the following conditions 7180740Sdes * are met: 8225825Sdes * 1. Redistributions of source code must retain the above copyright 9180740Sdes * notice, this list of conditions and the following disclaimer. 10225825Sdes * 2. Redistributions in binary form must reproduce the above copyright 11225825Sdes * notice, this list of conditions and the following disclaimer in the 12225825Sdes * documentation and/or other materials provided with the distribution. 13225825Sdes * 3. All advertising materials mentioning features or use of this software 14180740Sdes * must display the following acknowledgement: 15180740Sdes * This product includes software developed by the University of 16225825Sdes * California, Berkeley and its contributors. 17225825Sdes * 4. Neither the name of the University nor the names of its contributors 18225825Sdes * may be used to endorse or promote products derived from this software 19180740Sdes * without specific prior written permission. 20180740Sdes * 21180740Sdes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22225825Sdes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23180740Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24180740Sdes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25225825Sdes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26180740Sdes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27180740Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28180740Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29180740Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30225825Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31225825Sdes * SUCH DAMAGE. 32225825Sdes * 33225825Sdes * @(#)socket.h 8.4 (Berkeley) 2/21/94 34225825Sdes * $FreeBSD: head/sys/sys/socket.h 78137 2001-06-12 11:12:23Z ume $ 35180740Sdes */ 36180740Sdes 37180740Sdes#ifndef _SYS_SOCKET_H_ 38180740Sdes#define _SYS_SOCKET_H_ 39225825Sdes 40225825Sdes#include <machine/ansi.h> 41225825Sdes#define _NO_NAMESPACE_POLLUTION 42225825Sdes#include <machine/param.h> 43225825Sdes#undef _NO_NAMESPACE_POLLUTION 44225825Sdes 45225825Sdes/* 46225825Sdes * Definitions related to sockets: types, address families, options. 47225825Sdes */ 48225825Sdes 49225825Sdes/* 50225825Sdes * Data types. 51225825Sdes */ 52225825Sdestypedef u_char sa_family_t; 53225825Sdes#ifdef _BSD_SOCKLEN_T_ 54225825Sdestypedef _BSD_SOCKLEN_T_ socklen_t; 55225825Sdes#undef _BSD_SOCKLEN_T_ 56225825Sdes#endif 57225825Sdes 58225825Sdes/* 59180740Sdes * Types 60225825Sdes */ 61225825Sdes#define SOCK_STREAM 1 /* stream socket */ 62225825Sdes#define SOCK_DGRAM 2 /* datagram socket */ 63225825Sdes#define SOCK_RAW 3 /* raw-protocol interface */ 64225825Sdes#define SOCK_RDM 4 /* reliably-delivered message */ 65225825Sdes#define SOCK_SEQPACKET 5 /* sequenced packet stream */ 66225825Sdes 67225825Sdes/* 68225825Sdes * Option flags per-socket. 69225825Sdes */ 70225825Sdes#define SO_DEBUG 0x0001 /* turn on debugging info recording */ 71225825Sdes#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ 72180740Sdes#define SO_REUSEADDR 0x0004 /* allow local address reuse */ 73225825Sdes#define SO_KEEPALIVE 0x0008 /* keep connections alive */ 74225825Sdes#define SO_DONTROUTE 0x0010 /* just use interface addresses */ 75180740Sdes#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ 76180740Sdes#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ 77225825Sdes#define SO_LINGER 0x0080 /* linger on close if data present */ 78225825Sdes#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ 79225825Sdes#define SO_REUSEPORT 0x0200 /* allow local address & port reuse */ 80225825Sdes#define SO_TIMESTAMP 0x0400 /* timestamp received dgram traffic */ 81225825Sdes#define SO_ACCEPTFILTER 0x1000 /* there is an accept filter */ 82225825Sdes 83225825Sdes/* 84180740Sdes * Additional options, not kept in so_options. 85180740Sdes */ 86180740Sdes#define SO_SNDBUF 0x1001 /* send buffer size */ 87180740Sdes#define SO_RCVBUF 0x1002 /* receive buffer size */ 88180740Sdes#define SO_SNDLOWAT 0x1003 /* send low-water mark */ 89180740Sdes#define SO_RCVLOWAT 0x1004 /* receive low-water mark */ 90180740Sdes#define SO_SNDTIMEO 0x1005 /* send timeout */ 91180740Sdes#define SO_RCVTIMEO 0x1006 /* receive timeout */ 92180740Sdes#define SO_ERROR 0x1007 /* get error status and clear */ 93180740Sdes#define SO_TYPE 0x1008 /* get socket type */ 94180740Sdes/*efine SO_PRIVSTATE 0x1009 get/deny privileged state */ 95225825Sdes 96225825Sdes/* 97180740Sdes * Structure used for manipulating linger option. 98180740Sdes */ 99180740Sdesstruct linger { 100180740Sdes int l_onoff; /* option on/off */ 101180740Sdes int l_linger; /* linger time */ 102180740Sdes}; 103225825Sdes 104225825Sdesstruct accept_filter_arg { 105180740Sdes char af_name[16]; 106180740Sdes char af_arg[256-16]; 107180740Sdes}; 108180740Sdes 109180740Sdes/* 110180740Sdes * Level number for (get/set)sockopt() to apply to socket itself. 111180740Sdes */ 112180740Sdes#define SOL_SOCKET 0xffff /* options for socket level */ 113180740Sdes 114180740Sdes/* 115225825Sdes * Address families. 116225825Sdes */ 117180740Sdes#define AF_UNSPEC 0 /* unspecified */ 118180740Sdes#define AF_LOCAL 1 /* local to host (pipes, portals) */ 119225825Sdes#define AF_UNIX AF_LOCAL /* backward compatibility */ 120225825Sdes#define AF_INET 2 /* internetwork: UDP, TCP, etc. */ 121225825Sdes#define AF_IMPLINK 3 /* arpanet imp addresses */ 122225825Sdes#define AF_PUP 4 /* pup protocols: e.g. BSP */ 123225825Sdes#define AF_CHAOS 5 /* mit CHAOS protocols */ 124225825Sdes#define AF_NS 6 /* XEROX NS protocols */ 125225825Sdes#define AF_ISO 7 /* ISO protocols */ 126180740Sdes#define AF_OSI AF_ISO 127180740Sdes#define AF_ECMA 8 /* European computer manufacturers */ 128180740Sdes#define AF_DATAKIT 9 /* datakit protocols */ 129180740Sdes#define AF_CCITT 10 /* CCITT protocols, X.25 etc */ 130180740Sdes#define AF_SNA 11 /* IBM SNA */ 131180740Sdes#define AF_DECnet 12 /* DECnet */ 132225825Sdes#define AF_DLI 13 /* DEC Direct data link interface */ 133225825Sdes#define AF_LAT 14 /* LAT */ 134225825Sdes#define AF_HYLINK 15 /* NSC Hyperchannel */ 135225825Sdes#define AF_APPLETALK 16 /* Apple Talk */ 136180740Sdes#define AF_ROUTE 17 /* Internal Routing Protocol */ 137180740Sdes#define AF_LINK 18 /* Link layer interface */ 138225825Sdes#define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */ 139180740Sdes#define AF_COIP 20 /* connection-oriented IP, aka ST II */ 140180740Sdes#define AF_CNT 21 /* Computer Network Technology */ 141225825Sdes#define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */ 142225825Sdes#define AF_IPX 23 /* Novell Internet Protocol */ 143225825Sdes#define AF_SIP 24 /* Simple Internet Protocol */ 144225825Sdes#define pseudo_AF_PIP 25 /* Help Identify PIP packets */ 145225825Sdes#define AF_ISDN 26 /* Integrated Services Digital Network*/ 146225825Sdes#define AF_E164 AF_ISDN /* CCITT E.164 recommendation */ 147225825Sdes#define pseudo_AF_KEY 27 /* Internal key-management function */ 148180740Sdes#define AF_INET6 28 /* IPv6 */ 149225825Sdes#define AF_NATM 29 /* native ATM access */ 150225825Sdes#define AF_ATM 30 /* ATM */ 151225825Sdes#define pseudo_AF_HDRCMPLT 31 /* Used by BPF to not rewrite headers 152225825Sdes * in interface output routine 153225825Sdes */ 154225825Sdes#define AF_NETGRAPH 32 /* Netgraph sockets */ 155180740Sdes#define AF_SLOW 33 /* 802.3ad slow protocol */ 156225825Sdes#define AF_SCLUSTER 34 /* Sitara cluster protocol */ 157225825Sdes#define AF_MAX 35 158225825Sdes 159225825Sdes/* 160225825Sdes * Structure used by kernel to store most 161225825Sdes * addresses. 162180740Sdes */ 163180740Sdesstruct sockaddr { 164225825Sdes u_char sa_len; /* total length */ 165225825Sdes sa_family_t sa_family; /* address family */ 166225825Sdes char sa_data[14]; /* actually longer; address value */ 167225825Sdes}; 168225825Sdes#define SOCK_MAXADDRLEN 255 /* longest possible addresses */ 169180740Sdes 170180740Sdes/* 171225825Sdes * Structure used by kernel to pass protocol 172180740Sdes * information in raw sockets. 173225825Sdes */ 174225825Sdesstruct sockproto { 175225825Sdes u_short sp_family; /* address family */ 176225825Sdes u_short sp_protocol; /* protocol */ 177225825Sdes}; 178225825Sdes 179225825Sdes/* 180225825Sdes * RFC 2553: protocol-independent placeholder for socket addresses 181180740Sdes */ 182225825Sdes#define _SS_MAXSIZE 128 183180740Sdes#define _SS_ALIGNSIZE (sizeof(int64_t)) 184225825Sdes#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(u_char) - sizeof(sa_family_t)) 185180740Sdes#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(u_char) - sizeof(sa_family_t) - \ 186180740Sdes _SS_PAD1SIZE - _SS_ALIGNSIZE) 187225825Sdes 188225825Sdesstruct sockaddr_storage { 189180740Sdes u_char ss_len; /* address length */ 190180740Sdes sa_family_t ss_family; /* address family */ 191180740Sdes char __ss_pad1[_SS_PAD1SIZE]; 192180740Sdes int64_t __ss_align; /* force desired structure storage alignment */ 193225825Sdes char __ss_pad2[_SS_PAD2SIZE]; 194225825Sdes}; 195180740Sdes 196180740Sdes/* 197225825Sdes * Protocol families, same as address families for now. 198225825Sdes */ 199225825Sdes#define PF_UNSPEC AF_UNSPEC 200225825Sdes#define PF_LOCAL AF_LOCAL 201225825Sdes#define PF_UNIX PF_LOCAL /* backward compatibility */ 202225825Sdes#define PF_INET AF_INET 203225825Sdes#define PF_IMPLINK AF_IMPLINK 204225825Sdes#define PF_PUP AF_PUP 205225825Sdes#define PF_CHAOS AF_CHAOS 206180740Sdes#define PF_NS AF_NS 207180740Sdes#define PF_ISO AF_ISO 208225825Sdes#define PF_OSI AF_ISO 209180740Sdes#define PF_ECMA AF_ECMA 210225825Sdes#define PF_DATAKIT AF_DATAKIT 211225825Sdes#define PF_CCITT AF_CCITT 212225825Sdes#define PF_SNA AF_SNA 213225825Sdes#define PF_DECnet AF_DECnet 214180740Sdes#define PF_DLI AF_DLI 215180740Sdes#define PF_LAT AF_LAT 216180740Sdes#define PF_HYLINK AF_HYLINK 217225825Sdes#define PF_APPLETALK AF_APPLETALK 218225825Sdes#define PF_ROUTE AF_ROUTE 219225825Sdes#define PF_LINK AF_LINK 220225825Sdes#define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */ 221225825Sdes#define PF_COIP AF_COIP 222225825Sdes#define PF_CNT AF_CNT 223225825Sdes#define PF_SIP AF_SIP 224225825Sdes#define PF_IPX AF_IPX /* same format as AF_NS */ 225225825Sdes#define PF_RTIP pseudo_AF_RTIP /* same format as AF_INET */ 226225825Sdes#define PF_PIP pseudo_AF_PIP 227225825Sdes#define PF_ISDN AF_ISDN 228225825Sdes#define PF_KEY pseudo_AF_KEY 229225825Sdes#define PF_INET6 AF_INET6 230225825Sdes#define PF_NATM AF_NATM 231225825Sdes#define PF_ATM AF_ATM 232225825Sdes#define PF_NETGRAPH AF_NETGRAPH 233180740Sdes#define PF_SLOW AF_SLOW 234180740Sdes#define PF_SCLUSTER AF_SCLUSTER 235225825Sdes 236225825Sdes#define PF_MAX AF_MAX 237225825Sdes 238225825Sdes/* 239225825Sdes * Definitions for network related sysctl, CTL_NET. 240225825Sdes * 241225825Sdes * Second level is protocol family. 242225825Sdes * Third level is protocol number. 243225825Sdes * 244225825Sdes * Further levels are defined by the individual families below. 245225825Sdes */ 246225825Sdes#define NET_MAXID AF_MAX 247225825Sdes 248225825Sdes#define CTL_NET_NAMES { \ 249180740Sdes { 0, 0 }, \ 250180740Sdes { "unix", CTLTYPE_NODE }, \ 251180740Sdes { "inet", CTLTYPE_NODE }, \ 252225825Sdes { "implink", CTLTYPE_NODE }, \ 253225825Sdes { "pup", CTLTYPE_NODE }, \ 254225825Sdes { "chaos", CTLTYPE_NODE }, \ 255225825Sdes { "xerox_ns", CTLTYPE_NODE }, \ 256225825Sdes { "iso", CTLTYPE_NODE }, \ 257180740Sdes { "emca", CTLTYPE_NODE }, \ 258225825Sdes { "datakit", CTLTYPE_NODE }, \ 259225825Sdes { "ccitt", CTLTYPE_NODE }, \ 260225825Sdes { "ibm_sna", CTLTYPE_NODE }, \ 261225825Sdes { "decnet", CTLTYPE_NODE }, \ 262225825Sdes { "dec_dli", CTLTYPE_NODE }, \ 263225825Sdes { "lat", CTLTYPE_NODE }, \ 264225825Sdes { "hylink", CTLTYPE_NODE }, \ 265225825Sdes { "appletalk", CTLTYPE_NODE }, \ 266225825Sdes { "route", CTLTYPE_NODE }, \ 267225825Sdes { "link_layer", CTLTYPE_NODE }, \ 268225825Sdes { "xtp", CTLTYPE_NODE }, \ 269180740Sdes { "coip", CTLTYPE_NODE }, \ 270225825Sdes { "cnt", CTLTYPE_NODE }, \ 271225825Sdes { "rtip", CTLTYPE_NODE }, \ 272225825Sdes { "ipx", CTLTYPE_NODE }, \ 273225825Sdes { "sip", CTLTYPE_NODE }, \ 274225825Sdes { "pip", CTLTYPE_NODE }, \ 275225825Sdes { "isdn", CTLTYPE_NODE }, \ 276225825Sdes { "key", CTLTYPE_NODE }, \ 277180740Sdes { "inet6", CTLTYPE_NODE }, \ 278225825Sdes { "natm", CTLTYPE_NODE }, \ 279225825Sdes { "atm", CTLTYPE_NODE }, \ 280225825Sdes { "hdrcomplete", CTLTYPE_NODE }, \ 281225825Sdes { "netgraph", CTLTYPE_NODE }, \ 282225825Sdes { "snp", CTLTYPE_NODE }, \ 283225825Sdes { "scp", CTLTYPE_NODE }, \ 284225825Sdes} 285225825Sdes 286225825Sdes/* 287180740Sdes * PF_ROUTE - Routing table 288225825Sdes * 289225825Sdes * Three additional levels are defined: 290225825Sdes * Fourth: address family, 0 is wildcard 291225825Sdes * Fifth: type of info, defined below 292225825Sdes * Sixth: flag(s) to mask with for NET_RT_FLAGS 293180740Sdes */ 294225825Sdes#define NET_RT_DUMP 1 /* dump; may limit to a.f. */ 295225825Sdes#define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */ 296225825Sdes#define NET_RT_IFLIST 3 /* survey interface list */ 297225825Sdes#define NET_RT_MAXID 4 298225825Sdes 299225825Sdes#define CTL_NET_RT_NAMES { \ 300225825Sdes { 0, 0 }, \ 301225825Sdes { "dump", CTLTYPE_STRUCT }, \ 302225825Sdes { "flags", CTLTYPE_STRUCT }, \ 303225825Sdes { "iflist", CTLTYPE_STRUCT }, \ 304225825Sdes} 305225825Sdes 306225825Sdes/* 307225825Sdes * Maximum queue length specifiable by listen. 308225825Sdes */ 309225825Sdes#ifndef SOMAXCONN 310225825Sdes#define SOMAXCONN 128 311225825Sdes#endif 312225825Sdes 313225825Sdes/* 314225825Sdes * Message header for recvmsg and sendmsg calls. 315225825Sdes * Used value-result for recvmsg, value only for sendmsg. 316225825Sdes */ 317225825Sdesstruct msghdr { 318225825Sdes void *msg_name; /* optional address */ 319225825Sdes socklen_t msg_namelen; /* size of address */ 320225825Sdes struct iovec *msg_iov; /* scatter/gather array */ 321225825Sdes int msg_iovlen; /* # elements in msg_iov */ 322225825Sdes void *msg_control; /* ancillary data, see below */ 323225825Sdes socklen_t msg_controllen; /* ancillary data buffer len */ 324225825Sdes int msg_flags; /* flags on received message */ 325225825Sdes}; 326225825Sdes 327225825Sdes#define MSG_OOB 0x1 /* process out-of-band data */ 328225825Sdes#define MSG_PEEK 0x2 /* peek at incoming message */ 329225825Sdes#define MSG_DONTROUTE 0x4 /* send without using routing tables */ 330225825Sdes#define MSG_EOR 0x8 /* data completes record */ 331225825Sdes#define MSG_TRUNC 0x10 /* data discarded before delivery */ 332180740Sdes#define MSG_CTRUNC 0x20 /* control data lost before delivery */ 333180740Sdes#define MSG_WAITALL 0x40 /* wait for full request or error */ 334225825Sdes#define MSG_DONTWAIT 0x80 /* this message should be nonblocking */ 335225825Sdes#define MSG_EOF 0x100 /* data completes connection */ 336225825Sdes#define MSG_COMPAT 0x8000 /* used in sendit() */ 337225825Sdes 338225825Sdes/* 339225825Sdes * Header for ancillary data objects in msg_control buffer. 340225825Sdes * Used for additional information with/about a datagram 341225825Sdes * not expressible by flags. The format is a sequence 342225825Sdes * of message elements headed by cmsghdr structures. 343225825Sdes */ 344225825Sdesstruct cmsghdr { 345225825Sdes socklen_t cmsg_len; /* data byte count, including hdr */ 346225825Sdes int cmsg_level; /* originating protocol */ 347225825Sdes int cmsg_type; /* protocol-specific type */ 348225825Sdes/* followed by u_char cmsg_data[]; */ 349225825Sdes}; 350225825Sdes 351225825Sdes/* 352180740Sdes * While we may have more groups than this, the cmsgcred struct must 353225825Sdes * be able to fit in an mbuf, and NGROUPS_MAX is too large to allow 354225825Sdes * this. 355225825Sdes*/ 356225825Sdes#define CMGROUP_MAX 16 357225825Sdes 358225825Sdes/* 359225825Sdes * Credentials structure, used to verify the identity of a peer 360225825Sdes * process that has sent us a message. This is allocated by the 361225825Sdes * peer process but filled in by the kernel. This prevents the 362225825Sdes * peer from lying about its identity. (Note that cmcred_groups[0] 363225825Sdes * is the effective GID.) 364225825Sdes */ 365225825Sdesstruct cmsgcred { 366225825Sdes pid_t cmcred_pid; /* PID of sending process */ 367225825Sdes uid_t cmcred_uid; /* real UID of sending process */ 368225825Sdes uid_t cmcred_euid; /* effective UID of sending process */ 369180740Sdes gid_t cmcred_gid; /* real GID of sending process */ 370180740Sdes short cmcred_ngroups; /* number or groups */ 371225825Sdes gid_t cmcred_groups[CMGROUP_MAX]; /* groups */ 372225825Sdes}; 373225825Sdes 374225825Sdes/* given pointer to struct cmsghdr, return pointer to data */ 375225825Sdes#define CMSG_DATA(cmsg) ((u_char *)(cmsg) + \ 376225825Sdes _ALIGN(sizeof(struct cmsghdr))) 377225825Sdes 378225825Sdes/* given pointer to struct cmsghdr, return pointer to next cmsghdr */ 379225825Sdes#define CMSG_NXTHDR(mhdr, cmsg) \ 380225825Sdes (((caddr_t)(cmsg) + _ALIGN((cmsg)->cmsg_len) + \ 381225825Sdes _ALIGN(sizeof(struct cmsghdr)) > \ 382225825Sdes (caddr_t)(mhdr)->msg_control + (mhdr)->msg_controllen) ? \ 383225825Sdes (struct cmsghdr *)NULL : \ 384225825Sdes (struct cmsghdr *)((caddr_t)(cmsg) + _ALIGN((cmsg)->cmsg_len))) 385225825Sdes 386180740Sdes#define CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control) 387225825Sdes 388225825Sdes/* RFC 2292 additions */ 389225825Sdes 390180740Sdes#define CMSG_SPACE(l) (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(l)) 391225825Sdes#define CMSG_LEN(l) (_ALIGN(sizeof(struct cmsghdr)) + (l)) 392180740Sdes 393180740Sdes#ifdef _KERNEL 394225825Sdes#define CMSG_ALIGN(n) _ALIGN(n) 395225825Sdes#endif 396180740Sdes 397225825Sdes/* "Socket"-level control message types: */ 398180740Sdes#define SCM_RIGHTS 0x01 /* access rights (array of int) */ 399180740Sdes#define SCM_TIMESTAMP 0x02 /* timestamp (struct timeval) */ 400225825Sdes#define SCM_CREDS 0x03 /* process creds (struct cmsgcred) */ 401225825Sdes 402180740Sdes/* 403225825Sdes * 4.3 compat sockaddr, move to compat file later 404180740Sdes */ 405180740Sdesstruct osockaddr { 406225825Sdes u_short sa_family; /* address family */ 407225825Sdes char sa_data[14]; /* up to 14 bytes of direct address */ 408225825Sdes}; 409225825Sdes 410225825Sdes/* 411225825Sdes * 4.3-compat message header (move to compat file later). 412225825Sdes */ 413225825Sdesstruct omsghdr { 414225825Sdes caddr_t msg_name; /* optional address */ 415225825Sdes int msg_namelen; /* size of address */ 416225825Sdes struct iovec *msg_iov; /* scatter/gather array */ 417225825Sdes int msg_iovlen; /* # elements in msg_iov */ 418225825Sdes caddr_t msg_accrights; /* access rights sent/received */ 419225825Sdes int msg_accrightslen; 420225825Sdes}; 421225825Sdes 422225825Sdes/* 423225825Sdes * howto arguments for shutdown(2), specified by Posix.1g. 424180740Sdes */ 425225825Sdes#define SHUT_RD 0 /* shut down the reading side */ 426225825Sdes#define SHUT_WR 1 /* shut down the writing side */ 427225825Sdes#define SHUT_RDWR 2 /* shut down both sides */ 428225825Sdes 429225825Sdes/* 430225825Sdes * sendfile(2) header/trailer struct 431180740Sdes */ 432180740Sdesstruct sf_hdtr { 433225825Sdes struct iovec *headers; /* pointer to an array of header struct iovec's */ 434225825Sdes int hdr_cnt; /* number of header iovec's */ 435225825Sdes struct iovec *trailers; /* pointer to an array of trailer struct iovec's */ 436225825Sdes int trl_cnt; /* number of trailer iovec's */ 437225825Sdes}; 438180740Sdes 439180740Sdes#ifndef _KERNEL 440180740Sdes 441180740Sdes#include <sys/cdefs.h> 442180740Sdes 443180740Sdes__BEGIN_DECLS 444180740Sdesint accept __P((int, struct sockaddr *, socklen_t *)); 445180740Sdesint bind __P((int, const struct sockaddr *, socklen_t)); 446180740Sdesint connect __P((int, const struct sockaddr *, socklen_t)); 447180740Sdesint getpeername __P((int, struct sockaddr *, socklen_t *)); 448180740Sdesint getsockname __P((int, struct sockaddr *, socklen_t *)); 449180740Sdesint getsockopt __P((int, int, int, void *, socklen_t *)); 450180740Sdesint listen __P((int, int)); 451180740Sdesssize_t recv __P((int, void *, size_t, int)); 452180740Sdesssize_t recvfrom __P((int, void *, size_t, int, struct sockaddr *, socklen_t *)); 453180740Sdesssize_t recvmsg __P((int, struct msghdr *, int)); 454225825Sdesssize_t send __P((int, const void *, size_t, int)); 455180740Sdesssize_t sendto __P((int, const void *, 456180740Sdes size_t, int, const struct sockaddr *, socklen_t)); 457180740Sdesssize_t sendmsg __P((int, const struct msghdr *, int)); 458180740Sdesint sendfile __P((int, int, off_t, size_t, struct sf_hdtr *, off_t *, int)); 459180740Sdesint setsockopt __P((int, int, int, const void *, socklen_t)); 460180740Sdesint shutdown __P((int, int)); 461180740Sdesint socket __P((int, int, int)); 462180740Sdesint socketpair __P((int, int, int, int *)); 463180740Sdes__END_DECLS 464180740Sdes 465225825Sdes#endif /* !_KERNEL */ 466180740Sdes 467225825Sdes#endif /* !_SYS_SOCKET_H_ */ 468180740Sdes