socket.h revision 55917
11541Srgrimes/* 21541Srgrimes * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994 31541Srgrimes * The Regents of the University of California. All rights reserved. 41541Srgrimes * 51541Srgrimes * Redistribution and use in source and binary forms, with or without 61541Srgrimes * modification, are permitted provided that the following conditions 71541Srgrimes * are met: 81541Srgrimes * 1. Redistributions of source code must retain the above copyright 91541Srgrimes * notice, this list of conditions and the following disclaimer. 101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111541Srgrimes * notice, this list of conditions and the following disclaimer in the 121541Srgrimes * documentation and/or other materials provided with the distribution. 131541Srgrimes * 3. All advertising materials mentioning features or use of this software 141541Srgrimes * must display the following acknowledgement: 151541Srgrimes * This product includes software developed by the University of 161541Srgrimes * California, Berkeley and its contributors. 171541Srgrimes * 4. Neither the name of the University nor the names of its contributors 181541Srgrimes * may be used to endorse or promote products derived from this software 191541Srgrimes * without specific prior written permission. 201541Srgrimes * 211541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 221541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 231541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 241541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 251541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 261541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 271541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 281541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 291541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 301541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 311541Srgrimes * SUCH DAMAGE. 321541Srgrimes * 331541Srgrimes * @(#)socket.h 8.4 (Berkeley) 2/21/94 3450477Speter * $FreeBSD: head/sys/sys/socket.h 55917 2000-01-13 14:52:53Z shin $ 351541Srgrimes */ 361541Srgrimes 371541Srgrimes#ifndef _SYS_SOCKET_H_ 381541Srgrimes#define _SYS_SOCKET_H_ 391541Srgrimes 401541Srgrimes/* 411541Srgrimes * Definitions related to sockets: types, address families, options. 421541Srgrimes */ 431541Srgrimes 441541Srgrimes/* 4553678Sphk * Data types. 4653678Sphk */ 4753678Sphktypedef u_char sa_family_t; 4853678Sphktypedef u_int32_t socklen_t; 4953678Sphk 5053678Sphk/* 511541Srgrimes * Types 521541Srgrimes */ 531541Srgrimes#define SOCK_STREAM 1 /* stream socket */ 541541Srgrimes#define SOCK_DGRAM 2 /* datagram socket */ 551541Srgrimes#define SOCK_RAW 3 /* raw-protocol interface */ 561541Srgrimes#define SOCK_RDM 4 /* reliably-delivered message */ 571541Srgrimes#define SOCK_SEQPACKET 5 /* sequenced packet stream */ 581541Srgrimes 591541Srgrimes/* 601541Srgrimes * Option flags per-socket. 611541Srgrimes */ 621541Srgrimes#define SO_DEBUG 0x0001 /* turn on debugging info recording */ 631541Srgrimes#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ 641541Srgrimes#define SO_REUSEADDR 0x0004 /* allow local address reuse */ 651541Srgrimes#define SO_KEEPALIVE 0x0008 /* keep connections alive */ 661541Srgrimes#define SO_DONTROUTE 0x0010 /* just use interface addresses */ 671541Srgrimes#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ 681541Srgrimes#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ 691541Srgrimes#define SO_LINGER 0x0080 /* linger on close if data present */ 701541Srgrimes#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ 711541Srgrimes#define SO_REUSEPORT 0x0200 /* allow local address & port reuse */ 7215701Swollman#define SO_TIMESTAMP 0x0400 /* timestamp received dgram traffic */ 731541Srgrimes 741541Srgrimes/* 751541Srgrimes * Additional options, not kept in so_options. 761541Srgrimes */ 771541Srgrimes#define SO_SNDBUF 0x1001 /* send buffer size */ 781541Srgrimes#define SO_RCVBUF 0x1002 /* receive buffer size */ 791541Srgrimes#define SO_SNDLOWAT 0x1003 /* send low-water mark */ 801541Srgrimes#define SO_RCVLOWAT 0x1004 /* receive low-water mark */ 811541Srgrimes#define SO_SNDTIMEO 0x1005 /* send timeout */ 821541Srgrimes#define SO_RCVTIMEO 0x1006 /* receive timeout */ 831541Srgrimes#define SO_ERROR 0x1007 /* get error status and clear */ 841541Srgrimes#define SO_TYPE 0x1008 /* get socket type */ 8525311Swollman/*efine SO_PRIVSTATE 0x1009 get/deny privileged state */ 861541Srgrimes 871541Srgrimes/* 881541Srgrimes * Structure used for manipulating linger option. 891541Srgrimes */ 901541Srgrimesstruct linger { 911541Srgrimes int l_onoff; /* option on/off */ 921541Srgrimes int l_linger; /* linger time */ 931541Srgrimes}; 941541Srgrimes 951541Srgrimes/* 961541Srgrimes * Level number for (get/set)sockopt() to apply to socket itself. 971541Srgrimes */ 981541Srgrimes#define SOL_SOCKET 0xffff /* options for socket level */ 991541Srgrimes 1001541Srgrimes/* 1011541Srgrimes * Address families. 1021541Srgrimes */ 1031541Srgrimes#define AF_UNSPEC 0 /* unspecified */ 1041541Srgrimes#define AF_LOCAL 1 /* local to host (pipes, portals) */ 1051541Srgrimes#define AF_UNIX AF_LOCAL /* backward compatibility */ 1061541Srgrimes#define AF_INET 2 /* internetwork: UDP, TCP, etc. */ 1071541Srgrimes#define AF_IMPLINK 3 /* arpanet imp addresses */ 1081541Srgrimes#define AF_PUP 4 /* pup protocols: e.g. BSP */ 1091541Srgrimes#define AF_CHAOS 5 /* mit CHAOS protocols */ 1101541Srgrimes#define AF_NS 6 /* XEROX NS protocols */ 1111541Srgrimes#define AF_ISO 7 /* ISO protocols */ 1121541Srgrimes#define AF_OSI AF_ISO 11313765Smpp#define AF_ECMA 8 /* European computer manufacturers */ 1141541Srgrimes#define AF_DATAKIT 9 /* datakit protocols */ 1151541Srgrimes#define AF_CCITT 10 /* CCITT protocols, X.25 etc */ 1161541Srgrimes#define AF_SNA 11 /* IBM SNA */ 1171541Srgrimes#define AF_DECnet 12 /* DECnet */ 1181541Srgrimes#define AF_DLI 13 /* DEC Direct data link interface */ 1191541Srgrimes#define AF_LAT 14 /* LAT */ 1201541Srgrimes#define AF_HYLINK 15 /* NSC Hyperchannel */ 1211541Srgrimes#define AF_APPLETALK 16 /* Apple Talk */ 1221541Srgrimes#define AF_ROUTE 17 /* Internal Routing Protocol */ 1231541Srgrimes#define AF_LINK 18 /* Link layer interface */ 1241541Srgrimes#define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */ 1251541Srgrimes#define AF_COIP 20 /* connection-oriented IP, aka ST II */ 1261541Srgrimes#define AF_CNT 21 /* Computer Network Technology */ 1271541Srgrimes#define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */ 1281541Srgrimes#define AF_IPX 23 /* Novell Internet Protocol */ 1291541Srgrimes#define AF_SIP 24 /* Simple Internet Protocol */ 1305413Sse#define pseudo_AF_PIP 25 /* Help Identify PIP packets */ 1315413Sse#define AF_ISDN 26 /* Integrated Services Digital Network*/ 1325413Sse#define AF_E164 AF_ISDN /* CCITT E.164 recommendation */ 13316368Swollman#define pseudo_AF_KEY 27 /* Internal key-management function */ 13417938Speter#define AF_INET6 28 /* IPv6 */ 13525609Skjc#define AF_NATM 29 /* native ATM access */ 13639271Sphk#define AF_ATM 30 /* ATM */ 13752248Smsmith#define pseudo_AF_HDRCMPLT 31 /* Used by BPF to not rewrite headers 13852248Smsmith * in interface output routine 13952248Smsmith */ 14052424Sjulian#define AF_NETGRAPH 32 /* Netgraph sockets */ 1411541Srgrimes 14252424Sjulian#define AF_MAX 33 1431541Srgrimes 1441541Srgrimes/* 1451541Srgrimes * Structure used by kernel to store most 1461541Srgrimes * addresses. 1471541Srgrimes */ 1481541Srgrimesstruct sockaddr { 14953678Sphk u_char sa_len; /* total length */ 15053678Sphk sa_family_t sa_family; /* address family */ 15153678Sphk char sa_data[14]; /* actually longer; address value */ 1521541Srgrimes}; 15328270Swollman#define SOCK_MAXADDRLEN 255 /* longest possible addresses */ 1541541Srgrimes 1551541Srgrimes/* 1561541Srgrimes * Structure used by kernel to pass protocol 1571541Srgrimes * information in raw sockets. 1581541Srgrimes */ 1591541Srgrimesstruct sockproto { 1601541Srgrimes u_short sp_family; /* address family */ 1611541Srgrimes u_short sp_protocol; /* protocol */ 1621541Srgrimes}; 1631541Srgrimes 1641541Srgrimes/* 16552904Sshin * bsd-api-new-02a: protocol-independent placeholder for socket addresses 16652904Sshin */ 16752904Sshin#define _SS_MAXSIZE 128 16852904Sshin#define _SS_ALIGNSIZE (sizeof(int64_t)) 16952904Sshin#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(u_char) * 2) 17052904Sshin#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(u_char) * 2 - \ 17152904Sshin _SS_PAD1SIZE - _SS_ALIGNSIZE) 17252904Sshin 17352904Sshinstruct sockaddr_storage { 17455917Sshin u_char ss_len; /* address length */ 17555917Sshin sa_family_t ss_family; /* address family */ 17653678Sphk char __ss_pad1[_SS_PAD1SIZE]; 17753678Sphk int64_t __ss_align; /* force desired structure storage alignment */ 17853678Sphk char __ss_pad2[_SS_PAD2SIZE]; 17952904Sshin}; 18052904Sshin 18152904Sshin/* 1821541Srgrimes * Protocol families, same as address families for now. 1831541Srgrimes */ 1841541Srgrimes#define PF_UNSPEC AF_UNSPEC 1851541Srgrimes#define PF_LOCAL AF_LOCAL 1861541Srgrimes#define PF_UNIX PF_LOCAL /* backward compatibility */ 1871541Srgrimes#define PF_INET AF_INET 1881541Srgrimes#define PF_IMPLINK AF_IMPLINK 1891541Srgrimes#define PF_PUP AF_PUP 1901541Srgrimes#define PF_CHAOS AF_CHAOS 1911541Srgrimes#define PF_NS AF_NS 1921541Srgrimes#define PF_ISO AF_ISO 1931541Srgrimes#define PF_OSI AF_ISO 1941541Srgrimes#define PF_ECMA AF_ECMA 1951541Srgrimes#define PF_DATAKIT AF_DATAKIT 1961541Srgrimes#define PF_CCITT AF_CCITT 1971541Srgrimes#define PF_SNA AF_SNA 1981541Srgrimes#define PF_DECnet AF_DECnet 1991541Srgrimes#define PF_DLI AF_DLI 2001541Srgrimes#define PF_LAT AF_LAT 2011541Srgrimes#define PF_HYLINK AF_HYLINK 2021541Srgrimes#define PF_APPLETALK AF_APPLETALK 2031541Srgrimes#define PF_ROUTE AF_ROUTE 2041541Srgrimes#define PF_LINK AF_LINK 2051541Srgrimes#define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */ 2061541Srgrimes#define PF_COIP AF_COIP 2071541Srgrimes#define PF_CNT AF_CNT 2081541Srgrimes#define PF_SIP AF_SIP 2091541Srgrimes#define PF_IPX AF_IPX /* same format as AF_NS */ 21017603Sjdp#define PF_RTIP pseudo_AF_RTIP /* same format as AF_INET */ 2111541Srgrimes#define PF_PIP pseudo_AF_PIP 2125413Sse#define PF_ISDN AF_ISDN 21316480Swollman#define PF_KEY pseudo_AF_KEY 21417938Speter#define PF_INET6 AF_INET6 21525609Skjc#define PF_NATM AF_NATM 21639271Sphk#define PF_ATM AF_ATM 21752419Sjulian#define PF_NETGRAPH AF_NETGRAPH 2181541Srgrimes 2191541Srgrimes#define PF_MAX AF_MAX 2201541Srgrimes 2211541Srgrimes/* 2221541Srgrimes * Definitions for network related sysctl, CTL_NET. 2231541Srgrimes * 2241541Srgrimes * Second level is protocol family. 2251541Srgrimes * Third level is protocol number. 2261541Srgrimes * 2271541Srgrimes * Further levels are defined by the individual families below. 2281541Srgrimes */ 2291541Srgrimes#define NET_MAXID AF_MAX 2301541Srgrimes 2311541Srgrimes#define CTL_NET_NAMES { \ 2321541Srgrimes { 0, 0 }, \ 2331541Srgrimes { "unix", CTLTYPE_NODE }, \ 2341541Srgrimes { "inet", CTLTYPE_NODE }, \ 2351541Srgrimes { "implink", CTLTYPE_NODE }, \ 2361541Srgrimes { "pup", CTLTYPE_NODE }, \ 2371541Srgrimes { "chaos", CTLTYPE_NODE }, \ 2381541Srgrimes { "xerox_ns", CTLTYPE_NODE }, \ 2391541Srgrimes { "iso", CTLTYPE_NODE }, \ 2401541Srgrimes { "emca", CTLTYPE_NODE }, \ 2411541Srgrimes { "datakit", CTLTYPE_NODE }, \ 2421541Srgrimes { "ccitt", CTLTYPE_NODE }, \ 2431541Srgrimes { "ibm_sna", CTLTYPE_NODE }, \ 2441541Srgrimes { "decnet", CTLTYPE_NODE }, \ 2451541Srgrimes { "dec_dli", CTLTYPE_NODE }, \ 2461541Srgrimes { "lat", CTLTYPE_NODE }, \ 2471541Srgrimes { "hylink", CTLTYPE_NODE }, \ 2481541Srgrimes { "appletalk", CTLTYPE_NODE }, \ 2491541Srgrimes { "route", CTLTYPE_NODE }, \ 2501541Srgrimes { "link_layer", CTLTYPE_NODE }, \ 2511541Srgrimes { "xtp", CTLTYPE_NODE }, \ 2521541Srgrimes { "coip", CTLTYPE_NODE }, \ 2531541Srgrimes { "cnt", CTLTYPE_NODE }, \ 2541541Srgrimes { "rtip", CTLTYPE_NODE }, \ 2551541Srgrimes { "ipx", CTLTYPE_NODE }, \ 2561541Srgrimes { "sip", CTLTYPE_NODE }, \ 2571541Srgrimes { "pip", CTLTYPE_NODE }, \ 25816368Swollman { "isdn", CTLTYPE_NODE }, \ 25916368Swollman { "key", CTLTYPE_NODE }, \ 26033006Salex { "inet6", CTLTYPE_NODE }, \ 26125609Skjc { "natm", CTLTYPE_NODE }, \ 26252435Sjulian { "atm", CTLTYPE_NODE }, \ 26352435Sjulian { "hdrcomplete", CTLTYPE_NODE }, \ 26452419Sjulian { "netgraph", CTLTYPE_NODE }, \ 2651541Srgrimes} 2661541Srgrimes 2671541Srgrimes/* 2681541Srgrimes * PF_ROUTE - Routing table 2691541Srgrimes * 2701541Srgrimes * Three additional levels are defined: 2711541Srgrimes * Fourth: address family, 0 is wildcard 2721541Srgrimes * Fifth: type of info, defined below 2731541Srgrimes * Sixth: flag(s) to mask with for NET_RT_FLAGS 2741541Srgrimes */ 2751541Srgrimes#define NET_RT_DUMP 1 /* dump; may limit to a.f. */ 2761541Srgrimes#define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */ 2771541Srgrimes#define NET_RT_IFLIST 3 /* survey interface list */ 2781541Srgrimes#define NET_RT_MAXID 4 2791541Srgrimes 2801541Srgrimes#define CTL_NET_RT_NAMES { \ 2811541Srgrimes { 0, 0 }, \ 2821541Srgrimes { "dump", CTLTYPE_STRUCT }, \ 2831541Srgrimes { "flags", CTLTYPE_STRUCT }, \ 2841541Srgrimes { "iflist", CTLTYPE_STRUCT }, \ 2851541Srgrimes} 2861541Srgrimes 2871541Srgrimes/* 2881541Srgrimes * Maximum queue length specifiable by listen. 2891541Srgrimes */ 29013258Sdg#define SOMAXCONN 128 2911541Srgrimes 2921541Srgrimes/* 2931541Srgrimes * Message header for recvmsg and sendmsg calls. 2941541Srgrimes * Used value-result for recvmsg, value only for sendmsg. 2951541Srgrimes */ 2961541Srgrimesstruct msghdr { 29753678Sphk void *msg_name; /* optional address */ 29853678Sphk socklen_t msg_namelen; /* size of address */ 29953678Sphk struct iovec *msg_iov; /* scatter/gather array */ 30053678Sphk int msg_iovlen; /* # elements in msg_iov */ 30153678Sphk void *msg_control; /* ancillary data, see below */ 30253678Sphk socklen_t msg_controllen; /* ancillary data buffer len */ 30353678Sphk int msg_flags; /* flags on received message */ 3041541Srgrimes}; 3051541Srgrimes 3061541Srgrimes#define MSG_OOB 0x1 /* process out-of-band data */ 3071541Srgrimes#define MSG_PEEK 0x2 /* peek at incoming message */ 3081541Srgrimes#define MSG_DONTROUTE 0x4 /* send without using routing tables */ 3091541Srgrimes#define MSG_EOR 0x8 /* data completes record */ 3101541Srgrimes#define MSG_TRUNC 0x10 /* data discarded before delivery */ 3111541Srgrimes#define MSG_CTRUNC 0x20 /* control data lost before delivery */ 3121541Srgrimes#define MSG_WAITALL 0x40 /* wait for full request or error */ 3131541Srgrimes#define MSG_DONTWAIT 0x80 /* this message should be nonblocking */ 3146223Swollman#define MSG_EOF 0x100 /* data completes connection */ 3153304Sphk#define MSG_COMPAT 0x8000 /* used in sendit() */ 3161541Srgrimes 3171541Srgrimes/* 3181541Srgrimes * Header for ancillary data objects in msg_control buffer. 3191541Srgrimes * Used for additional information with/about a datagram 3201541Srgrimes * not expressible by flags. The format is a sequence 3211541Srgrimes * of message elements headed by cmsghdr structures. 3221541Srgrimes */ 3231541Srgrimesstruct cmsghdr { 32453678Sphk socklen_t cmsg_len; /* data byte count, including hdr */ 32553678Sphk int cmsg_level; /* originating protocol */ 32653678Sphk int cmsg_type; /* protocol-specific type */ 3271541Srgrimes/* followed by u_char cmsg_data[]; */ 3281541Srgrimes}; 3291541Srgrimes 33024083Swpaul/* 33124083Swpaul * While we may have more groups than this, the cmsgcred struct must 33224083Swpaul * be able to fit in an mbuf, and NGROUPS_MAX is too large to allow 33324083Swpaul * this. 33424083Swpaul*/ 33524083Swpaul#define CMGROUP_MAX 16 33624083Swpaul 33724083Swpaul/* 33824083Swpaul * Credentials structure, used to verify the identity of a peer 33924083Swpaul * process that has sent us a message. This is allocated by the 34024083Swpaul * peer process but filled in by the kernel. This prevents the 34124083Swpaul * peer from lying about its identity. (Note that cmcred_groups[0] 34224083Swpaul * is the effective GID.) 34324083Swpaul */ 34424083Swpaulstruct cmsgcred { 34524083Swpaul pid_t cmcred_pid; /* PID of sending process */ 34624083Swpaul uid_t cmcred_uid; /* real UID of sending process */ 34724083Swpaul uid_t cmcred_euid; /* effective UID of sending process */ 34824083Swpaul gid_t cmcred_gid; /* real GID of sending process */ 34924083Swpaul short cmcred_ngroups; /* number or groups */ 35024083Swpaul gid_t cmcred_groups[CMGROUP_MAX]; /* groups */ 35124083Swpaul}; 35224083Swpaul 3531541Srgrimes/* given pointer to struct cmsghdr, return pointer to data */ 3541541Srgrimes#define CMSG_DATA(cmsg) ((u_char *)((cmsg) + 1)) 3551541Srgrimes 35652904Sshin/* 35752904Sshin * Alignment requirement for CMSG struct manipulation. 35852904Sshin * This is different from ALIGN() defined in ARCH/include/param.h. 35952904Sshin * XXX think again carefully about architecture dependencies. 36052904Sshin */ 36152904Sshin#define CMSG_ALIGN(n) (((n) + 3) & ~3) 36252904Sshin 3631541Srgrimes/* given pointer to struct cmsghdr, return pointer to next cmsghdr */ 3641541Srgrimes#define CMSG_NXTHDR(mhdr, cmsg) \ 3651541Srgrimes (((caddr_t)(cmsg) + (cmsg)->cmsg_len + sizeof(struct cmsghdr) > \ 36655009Sshin (caddr_t)(mhdr)->msg_control + (mhdr)->msg_controllen) ? \ 3671541Srgrimes (struct cmsghdr *)NULL : \ 36852904Sshin (struct cmsghdr *)((caddr_t)(cmsg) + CMSG_ALIGN((cmsg)->cmsg_len))) 3691541Srgrimes 3701541Srgrimes#define CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control) 3711541Srgrimes 37252904Sshin#define CMSG_SPACE(l) (CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(l)) 37352904Sshin#define CMSG_LEN(l) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (l)) 37452904Sshin 3751541Srgrimes/* "Socket"-level control message types: */ 3761541Srgrimes#define SCM_RIGHTS 0x01 /* access rights (array of int) */ 37715701Swollman#define SCM_TIMESTAMP 0x02 /* timestamp (struct timeval) */ 37824083Swpaul#define SCM_CREDS 0x03 /* process creds (struct cmsgcred) */ 3791541Srgrimes 3801541Srgrimes/* 3811541Srgrimes * 4.3 compat sockaddr, move to compat file later 3821541Srgrimes */ 3831541Srgrimesstruct osockaddr { 3841541Srgrimes u_short sa_family; /* address family */ 3851541Srgrimes char sa_data[14]; /* up to 14 bytes of direct address */ 3861541Srgrimes}; 3871541Srgrimes 3881541Srgrimes/* 3891541Srgrimes * 4.3-compat message header (move to compat file later). 3901541Srgrimes */ 3911541Srgrimesstruct omsghdr { 3921541Srgrimes caddr_t msg_name; /* optional address */ 3931541Srgrimes int msg_namelen; /* size of address */ 3941541Srgrimes struct iovec *msg_iov; /* scatter/gather array */ 3951541Srgrimes int msg_iovlen; /* # elements in msg_iov */ 3961541Srgrimes caddr_t msg_accrights; /* access rights sent/received */ 3971541Srgrimes int msg_accrightslen; 3981541Srgrimes}; 3991541Srgrimes 40039114Swollman/* 40139114Swollman * howto arguments for shutdown(2), specified by Posix.1g. 40239114Swollman */ 40339114Swollman#define SHUT_RD 0 /* shut down the reading side */ 40439114Swollman#define SHUT_WR 1 /* shut down the writing side */ 40539114Swollman#define SHUT_RDWR 2 /* shut down both sides */ 40639114Swollman 40740931Sdg/* 40840931Sdg * sendfile(2) header/trailer struct 40940931Sdg */ 41040931Sdgstruct sf_hdtr { 41140931Sdg struct iovec *headers; /* pointer to an array of header struct iovec's */ 41240931Sdg int hdr_cnt; /* number of header iovec's */ 41340931Sdg struct iovec *trailers; /* pointer to an array of trailer struct iovec's */ 41440931Sdg int trl_cnt; /* number of trailer iovec's */ 41540931Sdg}; 41640931Sdg 41755205Speter#ifndef _KERNEL 4181541Srgrimes 4191541Srgrimes#include <sys/cdefs.h> 4201541Srgrimes 4211541Srgrimes__BEGIN_DECLS 42253678Sphkint accept __P((int, struct sockaddr *, socklen_t *)); 42353678Sphkint bind __P((int, const struct sockaddr *, socklen_t)); 42453678Sphkint connect __P((int, const struct sockaddr *, socklen_t)); 42553678Sphkint getpeername __P((int, struct sockaddr *, socklen_t *)); 42653678Sphkint getsockname __P((int, struct sockaddr *, socklen_t *)); 42753678Sphkint getsockopt __P((int, int, int, void *, socklen_t *)); 4281541Srgrimesint listen __P((int, int)); 4291541Srgrimesssize_t recv __P((int, void *, size_t, int)); 43053678Sphkssize_t recvfrom __P((int, void *, size_t, int, struct sockaddr *, socklen_t *)); 4311541Srgrimesssize_t recvmsg __P((int, struct msghdr *, int)); 4321541Srgrimesssize_t send __P((int, const void *, size_t, int)); 4331541Srgrimesssize_t sendto __P((int, const void *, 43453678Sphk size_t, int, const struct sockaddr *, socklen_t)); 4351541Srgrimesssize_t sendmsg __P((int, const struct msghdr *, int)); 43640931Sdgint sendfile __P((int, int, off_t, size_t, struct sf_hdtr *, off_t *, int)); 43753678Sphkint setsockopt __P((int, int, int, const void *, socklen_t)); 4381541Srgrimesint shutdown __P((int, int)); 4391541Srgrimesint socket __P((int, int, int)); 4401541Srgrimesint socketpair __P((int, int, int, int *)); 44152904Sshin 44252904Sshinvoid pfctlinput __P((int, struct sockaddr *)); 4431541Srgrimes__END_DECLS 4441541Srgrimes 44555205Speter#endif /* !_KERNEL */ 44631927Sbde 4471541Srgrimes#endif /* !_SYS_SOCKET_H_ */ 448