sl@0: sl@0: sl@0: /*- sl@0: * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994 sl@0: * The Regents of the University of California. All rights reserved. sl@0: * Redistribution and use in source and binary forms, with or without sl@0: * modification, are permitted provided that the following conditions sl@0: * are met: sl@0: * 1. Redistributions of source code must retain the above copyright sl@0: * notice, this list of conditions and the following disclaimer. sl@0: * 2. Redistributions in binary form must reproduce the above copyright sl@0: * notice, this list of conditions and the following disclaimer in the sl@0: * documentation and/or other materials provided with the distribution. sl@0: * 4. Neither the name of the University nor the names of its contributors sl@0: * may be used to endorse or promote products derived from this software sl@0: * without specific prior written permission. sl@0: * sl@0: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND sl@0: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE sl@0: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE sl@0: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE sl@0: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL sl@0: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS sl@0: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) sl@0: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT sl@0: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY sl@0: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF sl@0: * SUCH DAMAGE. sl@0: * Portions Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. sl@0: * @(#)socket.h 8.4 (Berkeley) 2/21/94 sl@0: * $FreeBSD: src/sys/sys/socket.h,v 1.88.2.1 2005/09/27 21:14:10 rwatson Exp $ sl@0: */ sl@0: sl@0: #ifndef _SYS_SOCKET_H_ sl@0: #define _SYS_SOCKET_H_ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #define _NO_NAMESPACE_POLLUTION sl@0: #include sl@0: #undef _NO_NAMESPACE_POLLUTION sl@0: sl@0: /* sl@0: * Definitions related to sockets: types, address families, options. sl@0: */ sl@0: sl@0: /* sl@0: * Data types. sl@0: */ sl@0: #if __BSD_VISIBLE sl@0: #ifndef _GID_T_DECLARED sl@0: typedef __gid_t gid_t; sl@0: #define _GID_T_DECLARED sl@0: #endif sl@0: sl@0: #ifndef _OFF_T_DECLARED sl@0: typedef __off_t off_t; sl@0: #define _OFF_T_DECLARED sl@0: #endif sl@0: sl@0: #ifndef _PID_T_DECLARED sl@0: typedef __pid_t pid_t; sl@0: #define _PID_T_DECLARED sl@0: #endif sl@0: #endif sl@0: sl@0: #ifndef _SA_FAMILY_T_DECLARED sl@0: typedef __sa_family_t sa_family_t; sl@0: #define _SA_FAMILY_T_DECLARED sl@0: #endif sl@0: sl@0: #ifndef _SOCKLEN_T_DECLARED sl@0: typedef __socklen_t socklen_t; sl@0: #define _SOCKLEN_T_DECLARED sl@0: #endif sl@0: sl@0: #ifndef _SSIZE_T_DECLARED sl@0: typedef __ssize_t ssize_t; sl@0: #define _SSIZE_T_DECLARED sl@0: #endif sl@0: sl@0: #if __BSD_VISIBLE sl@0: #ifndef _UID_T_DECLARED sl@0: typedef __uid_t uid_t; sl@0: #define _UID_T_DECLARED sl@0: #endif sl@0: #endif sl@0: sl@0: /* sl@0: * Types sl@0: */ sl@0: #define SOCK_STREAM 1 /* stream socket */ sl@0: #define SOCK_DGRAM 2 /* datagram socket */ sl@0: #ifdef __SYMBIAN32__ sl@0: #define SOCK_RAW 4 /* raw-protocol interface */ sl@0: #else sl@0: #define SOCK_RAW 3 /* raw-protocol interface */ sl@0: #endif // __SYMBIAN32__ sl@0: #if __BSD_VISIBLE sl@0: #define SOCK_RDM 4 /* reliably-delivered message */ sl@0: #endif sl@0: #ifdef __SYMBIAN32__ sl@0: #define SOCK_SEQPACKET 3 /* sequenced packet stream */ sl@0: #else sl@0: #define SOCK_SEQPACKET 5 /* sequenced packet stream */ sl@0: #endif // __SYMBIAN32__ sl@0: sl@0: /* sl@0: * Option flags per-socket. sl@0: */ sl@0: #define SO_DEBUG 0x0001 /* turn on debugging info recording KSODebug */ sl@0: #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ sl@0: #ifdef __SYMBIAN32__ sl@0: #define SO_REUSEADDR 0x406 /* allow local address reuse */ sl@0: #else sl@0: #define SO_REUSEADDR 0x0004 /* allow local address reuse */ sl@0: #endif // __SYMBIAN32__ sl@0: #ifdef __SYMBIAN32__ sl@0: #define SO_KEEPALIVE 0x305 /* keep connections alive KSoTcpKeepAlive */ sl@0: #else sl@0: #define SO_KEEPALIVE 0x0008 /* keep connections alive */ sl@0: #endif // __SYMBIAN32__ sl@0: #define SO_DONTROUTE 0x0010 /* just use interface addresses */ sl@0: #ifdef __SYMBIAN32__ sl@0: #define SO_BROADCAST -1 /* permit sending of broadcast msgs */ sl@0: #else sl@0: #define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ sl@0: #endif // __SYMBIAN32__ sl@0: #if __BSD_VISIBLE sl@0: #ifdef __SYMBIAN32__ sl@0: #define SO_USELOOPBACK -2 /* bypass hardware when possible */ sl@0: #else sl@0: #define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ sl@0: #endif // __SYMBIAN32__ sl@0: #endif sl@0: #ifdef __SYMBIAN32__ sl@0: #define SO_LINGER -3 /* linger on close if data present */ sl@0: #else sl@0: #define SO_LINGER 0x0080 /* linger on close if data present */ sl@0: #endif // __SYMBIAN32__ sl@0: #ifdef __SYMBIAN32__ sl@0: #define SO_OOBINLINE 0x315 /* leave received OOB data in line KSoTcpOobInline */ sl@0: #else sl@0: #define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ sl@0: #endif // __SYMBIAN32__ sl@0: #if __BSD_VISIBLE sl@0: #define SO_REUSEPORT 0x0200 /* allow local address & port reuse */ sl@0: #define SO_TIMESTAMP 0x0400 /* timestamp received dgram traffic */ sl@0: #define SO_NOSIGPIPE 0x0800 /* no SIGPIPE from EPIPE */ sl@0: #define SO_ACCEPTFILTER 0x1000 /* there is an accept filter */ sl@0: #define SO_BINTIME 0x2000 /* timestamp received dgram traffic */ sl@0: #endif sl@0: sl@0: /* sl@0: * Additional options, not kept in so_options. sl@0: */ sl@0: #ifdef __SYMBIAN32__ sl@0: #define SO_SNDBUF 3 /* send buffer size KSOSendBuf */ sl@0: #else sl@0: #define SO_SNDBUF 0x1001 /* send buffer size */ sl@0: #endif // __SYMBIAN32__ sl@0: #ifdef __SYMBIAN32__ sl@0: #define SO_RCVBUF 2 /* receive buffer size KSORecvBuf */ sl@0: #else sl@0: #define SO_RCVBUF 0x1002 /* receive buffer size */ sl@0: #endif // __SYMBIAN32__ sl@0: #define SO_SNDLOWAT 0x1003 /* send low-water mark */ sl@0: #define SO_RCVLOWAT 0x1004 /* receive low-water mark */ sl@0: #define SO_SNDTIMEO 0x1005 /* send timeout */ sl@0: #define SO_RCVTIMEO 0x1006 /* receive timeout */ sl@0: #ifdef __SYMBIAN32__ sl@0: #define SO_ERROR 9 /* get error status and clear */ sl@0: #else sl@0: #define SO_ERROR 0x1007 /* get error status and clear */ sl@0: #endif // __SYMBIAN32__ sl@0: #define SO_TYPE 0x1008 /* get socket type */ sl@0: #if __BSD_VISIBLE sl@0: #define SO_LABEL 0x1009 /* socket's MAC label */ sl@0: #define SO_PEERLABEL 0x1010 /* socket's peer's MAC label */ sl@0: #define SO_LISTENQLIMIT 0x1011 /* socket's backlog limit */ sl@0: #define SO_LISTENQLEN 0x1012 /* socket's complete queue length */ sl@0: #define SO_LISTENINCQLEN 0x1013 /* socket's incomplete queue length */ sl@0: #endif sl@0: sl@0: /* sl@0: * Structure used for manipulating linger option. sl@0: */ sl@0: struct linger { sl@0: int l_onoff; /* option on/off */ sl@0: int l_linger; /* linger time */ sl@0: }; sl@0: sl@0: #if __BSD_VISIBLE sl@0: struct accept_filter_arg { sl@0: char af_name[16]; sl@0: char af_arg[256-16]; sl@0: }; sl@0: #endif sl@0: sl@0: /* sl@0: * Level number for (get/set)sockopt() to apply to socket itself. sl@0: */ sl@0: #ifdef __SYMBIAN32__ sl@0: #define SOL_SOCKET 1 /* options for socket level KSOLSocket */ sl@0: #else sl@0: #define SOL_SOCKET 0xffff /* options for socket level */ sl@0: #endif // __SYMBIAN32__ sl@0: /* sl@0: * Address families. sl@0: */ sl@0: #define AF_UNSPEC 0 /* unspecified */ sl@0: #if __BSD_VISIBLE sl@0: #ifdef __SYMBIAN32__ sl@0: #define AF_LOCAL 0x666 /* local to host (pipes, portals) */ sl@0: #else sl@0: #define AF_LOCAL AF_UNIX /* local to host (pipes, portals) */ sl@0: #endif // __SYMBIAN32__ sl@0: #endif sl@0: #define AF_UNIX 1 /* standardized name for AF_LOCAL */ sl@0: #ifdef __SYMBIAN32__ sl@0: #define AF_INET 0x0800 /* internetwork: UDP, TCP, etc. */ sl@0: #else sl@0: #define AF_INET 2 /* internetwork: UDP, TCP, etc. */ sl@0: #endif // __SYMBIAN32__ sl@0: #if __BSD_VISIBLE sl@0: #define AF_IMPLINK 3 /* arpanet imp addresses */ sl@0: #define AF_PUP 4 /* pup protocols: e.g. BSP */ sl@0: #define AF_CHAOS 5 /* mit CHAOS protocols */ sl@0: #define AF_NETBIOS 6 /* SMB protocols */ sl@0: #define AF_ISO 7 /* ISO protocols */ sl@0: #define AF_OSI AF_ISO sl@0: #define AF_ECMA 8 /* European computer manufacturers */ sl@0: #define AF_DATAKIT 9 /* datakit protocols */ sl@0: #define AF_CCITT 10 /* CCITT protocols, X.25 etc */ sl@0: #define AF_SNA 11 /* IBM SNA */ sl@0: #define AF_DECnet 12 /* DECnet */ sl@0: #define AF_DLI 13 /* DEC Direct data link interface */ sl@0: #define AF_LAT 14 /* LAT */ sl@0: #define AF_HYLINK 15 /* NSC Hyperchannel */ sl@0: #define AF_APPLETALK 16 /* Apple Talk */ sl@0: #define AF_ROUTE 17 /* Internal Routing Protocol */ sl@0: #define AF_LINK 18 /* Link layer interface */ sl@0: #define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */ sl@0: #define AF_COIP 20 /* connection-oriented IP, aka ST II */ sl@0: #define AF_CNT 21 /* Computer Network Technology */ sl@0: #define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */ sl@0: #define AF_IPX 23 /* Novell Internet Protocol */ sl@0: #define AF_SIP 24 /* Simple Internet Protocol */ sl@0: #define pseudo_AF_PIP 25 /* Help Identify PIP packets */ sl@0: #define AF_ISDN 26 /* Integrated Services Digital Network*/ sl@0: #define AF_E164 AF_ISDN /* CCITT E.164 recommendation */ sl@0: #define pseudo_AF_KEY 27 /* Internal key-management function */ sl@0: #endif sl@0: #ifdef __SYMBIAN32__ sl@0: #define AF_INET6 0x0806 /* IPv6 */ sl@0: #else sl@0: #define AF_INET6 28 /* IPv6 */ sl@0: #endif sl@0: #if __BSD_VISIBLE sl@0: #define AF_NATM 29 /* native ATM access */ sl@0: #define AF_ATM 30 /* ATM */ sl@0: #define pseudo_AF_HDRCMPLT 31 /* Used by BPF to not rewrite headers sl@0: * in interface output routine sl@0: */ sl@0: #define AF_NETGRAPH 32 /* Netgraph sockets */ sl@0: #define AF_SLOW 33 /* 802.3ad slow protocol */ sl@0: #define AF_SCLUSTER 34 /* Sitara cluster protocol */ sl@0: #define AF_ARP 35 sl@0: #define AF_BLUETOOTH 36 /* Bluetooth sockets */ sl@0: #define AF_MAX 37 sl@0: #endif sl@0: #ifdef __SYMBIAN32__ sl@0: #define AF_IRDA 0x0100 /* IrDA */ sl@0: #define AF_PLP 273 /* Symbian link protocol */ sl@0: #endif // __SYMBIAN32__ sl@0: sl@0: #ifndef __SYMBIAN32__ sl@0: /* sl@0: * Structure used by kernel to store most sl@0: * addresses. sl@0: */ sl@0: struct sockaddr { sl@0: unsigned char sa_len; /* total length */ sl@0: sa_family_t sa_family; /* address family */ sl@0: char sa_data[14]; /* actually longer; address value */ sl@0: }; sl@0: #else sl@0: /** sl@0: Structure used by EPOC32 to store most addresses. sl@0: NB. EPOC32 uses 32-bit family and port numbers internally, but they have been sl@0: left as shorts here for compatibility with code that uses htons()/ntohs() explicitly. sl@0: */ sl@0: struct sockaddr { sl@0: u_short sa_family; /* address family */ sl@0: u_short sa_port; /* port number - a common feature of most protocols */ sl@0: char sa_data[24]; /* up to 24 bytes of direct address */ sl@0: unsigned char sa_len; sl@0: }; sl@0: #endif //__SYMBIAN32__ sl@0: sl@0: #if __BSD_VISIBLE sl@0: #define SOCK_MAXADDRLEN 255 /* longest possible addresses */ sl@0: sl@0: /* sl@0: * Structure used by kernel to pass protocol sl@0: * information in raw sockets. sl@0: */ sl@0: struct sockproto { sl@0: unsigned short sp_family; /* address family */ sl@0: unsigned short sp_protocol; /* protocol */ sl@0: }; sl@0: #endif sl@0: sl@0: /* sl@0: * RFC 2553: protocol-independent placeholder for socket addresses sl@0: */ sl@0: #ifndef __SYMBIAN32__ sl@0: #define _SS_MAXSIZE 128U sl@0: #define _SS_ALIGNSIZE (sizeof(__int64_t)) sl@0: #define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) - \ sl@0: sizeof(sa_family_t)) sl@0: #define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) - \ sl@0: sizeof(sa_family_t) - _SS_PAD1SIZE - _SS_ALIGNSIZE) sl@0: sl@0: struct sockaddr_storage { sl@0: unsigned char ss_len; /* address length */ sl@0: sa_family_t ss_family; /* address family */ sl@0: char __ss_pad1[_SS_PAD1SIZE]; sl@0: __int64_t __ss_align; /* force desired struct alignment */ sl@0: char __ss_pad2[_SS_PAD2SIZE]; sl@0: }; sl@0: #else sl@0: #define _SS_MAXSIZE 128U sl@0: #define _SS_ALIGNSIZE (sizeof(__int64_t)) sl@0: #define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(u_short)) sl@0: #define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(u_short) - _SS_PAD1SIZE - _SS_ALIGNSIZE) sl@0: sl@0: struct sockaddr_storage { sl@0: u_short ss_family; /* address family */ sl@0: char __ss_pad1[_SS_PAD1SIZE]; sl@0: __int64_t __ss_align; /* force desired struct alignment */ sl@0: char __ss_pad2[_SS_PAD2SIZE]; sl@0: }; sl@0: #endif sl@0: #if __BSD_VISIBLE sl@0: /* sl@0: * Protocol families, same as address families for now. sl@0: */ sl@0: #define PF_UNSPEC AF_UNSPEC sl@0: #define PF_LOCAL AF_LOCAL sl@0: #define PF_UNIX PF_LOCAL /* backward compatibility */ sl@0: #define PF_INET AF_INET sl@0: #define PF_IMPLINK AF_IMPLINK sl@0: #define PF_PUP AF_PUP sl@0: #define PF_CHAOS AF_CHAOS sl@0: #define PF_NETBIOS AF_NETBIOS sl@0: #define PF_ISO AF_ISO sl@0: #define PF_OSI AF_ISO sl@0: #define PF_ECMA AF_ECMA sl@0: #define PF_DATAKIT AF_DATAKIT sl@0: #define PF_CCITT AF_CCITT sl@0: #define PF_SNA AF_SNA sl@0: #define PF_DECnet AF_DECnet sl@0: #define PF_DLI AF_DLI sl@0: #define PF_LAT AF_LAT sl@0: #define PF_HYLINK AF_HYLINK sl@0: #define PF_APPLETALK AF_APPLETALK sl@0: #define PF_ROUTE AF_ROUTE sl@0: #define PF_LINK AF_LINK sl@0: #define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */ sl@0: #define PF_COIP AF_COIP sl@0: #define PF_CNT AF_CNT sl@0: #define PF_SIP AF_SIP sl@0: #define PF_IPX AF_IPX sl@0: #define PF_RTIP pseudo_AF_RTIP /* same format as AF_INET */ sl@0: #define PF_PIP pseudo_AF_PIP sl@0: #define PF_ISDN AF_ISDN sl@0: #define PF_KEY pseudo_AF_KEY sl@0: #define PF_INET6 AF_INET6 sl@0: #define PF_NATM AF_NATM sl@0: #define PF_ATM AF_ATM sl@0: #define PF_NETGRAPH AF_NETGRAPH sl@0: #define PF_SLOW AF_SLOW sl@0: #define PF_SCLUSTER AF_SCLUSTER sl@0: #define PF_ARP AF_ARP sl@0: #define PF_BLUETOOTH AF_BLUETOOTH sl@0: sl@0: #define PF_MAX AF_MAX sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: #define PF_IRDA AF_IRDA sl@0: #define PF_PLP AF_PLP sl@0: #endif // __SYMBIAN32__ sl@0: /* sl@0: * Definitions for network related sysctl, CTL_NET. sl@0: * sl@0: * Second level is protocol family. sl@0: * Third level is protocol number. sl@0: * sl@0: * Further levels are defined by the individual families below. sl@0: */ sl@0: #define NET_MAXID AF_MAX sl@0: sl@0: #define CTL_NET_NAMES { \ sl@0: { 0, 0 }, \ sl@0: { "unix", CTLTYPE_NODE }, \ sl@0: { "inet", CTLTYPE_NODE }, \ sl@0: { "implink", CTLTYPE_NODE }, \ sl@0: { "pup", CTLTYPE_NODE }, \ sl@0: { "chaos", CTLTYPE_NODE }, \ sl@0: { "xerox_ns", CTLTYPE_NODE }, \ sl@0: { "iso", CTLTYPE_NODE }, \ sl@0: { "emca", CTLTYPE_NODE }, \ sl@0: { "datakit", CTLTYPE_NODE }, \ sl@0: { "ccitt", CTLTYPE_NODE }, \ sl@0: { "ibm_sna", CTLTYPE_NODE }, \ sl@0: { "decnet", CTLTYPE_NODE }, \ sl@0: { "dec_dli", CTLTYPE_NODE }, \ sl@0: { "lat", CTLTYPE_NODE }, \ sl@0: { "hylink", CTLTYPE_NODE }, \ sl@0: { "appletalk", CTLTYPE_NODE }, \ sl@0: { "route", CTLTYPE_NODE }, \ sl@0: { "link_layer", CTLTYPE_NODE }, \ sl@0: { "xtp", CTLTYPE_NODE }, \ sl@0: { "coip", CTLTYPE_NODE }, \ sl@0: { "cnt", CTLTYPE_NODE }, \ sl@0: { "rtip", CTLTYPE_NODE }, \ sl@0: { "ipx", CTLTYPE_NODE }, \ sl@0: { "sip", CTLTYPE_NODE }, \ sl@0: { "pip", CTLTYPE_NODE }, \ sl@0: { "isdn", CTLTYPE_NODE }, \ sl@0: { "key", CTLTYPE_NODE }, \ sl@0: { "inet6", CTLTYPE_NODE }, \ sl@0: { "natm", CTLTYPE_NODE }, \ sl@0: { "atm", CTLTYPE_NODE }, \ sl@0: { "hdrcomplete", CTLTYPE_NODE }, \ sl@0: { "netgraph", CTLTYPE_NODE }, \ sl@0: { "snp", CTLTYPE_NODE }, \ sl@0: { "scp", CTLTYPE_NODE }, \ sl@0: } sl@0: sl@0: /* sl@0: * PF_ROUTE - Routing table sl@0: * sl@0: * Three additional levels are defined: sl@0: * Fourth: address family, 0 is wildcard sl@0: * Fifth: type of info, defined below sl@0: * Sixth: flag(s) to mask with for NET_RT_FLAGS sl@0: */ sl@0: #define NET_RT_DUMP 1 /* dump; may limit to a.f. */ sl@0: #define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */ sl@0: #define NET_RT_IFLIST 3 /* survey interface list */ sl@0: #define NET_RT_IFMALIST 4 /* return multicast address list */ sl@0: #define NET_RT_MAXID 5 sl@0: sl@0: #define CTL_NET_RT_NAMES { \ sl@0: { 0, 0 }, \ sl@0: { "dump", CTLTYPE_STRUCT }, \ sl@0: { "flags", CTLTYPE_STRUCT }, \ sl@0: { "iflist", CTLTYPE_STRUCT }, \ sl@0: { "ifmalist", CTLTYPE_STRUCT }, \ sl@0: } sl@0: #endif /* __BSD_VISIBLE */ sl@0: sl@0: /* sl@0: * Maximum queue length specifiable by listen. sl@0: */ sl@0: #ifdef __SYMBIAN32__ sl@0: #define SOMAXCONN 5 sl@0: #else sl@0: #define SOMAXCONN 128 sl@0: #endif // __SYMBIAN32__ sl@0: sl@0: /* sl@0: * Message header for recvmsg and sendmsg calls. sl@0: * Used value-result for recvmsg, value only for sendmsg. sl@0: */ sl@0: struct msghdr { sl@0: void *msg_name; /* optional address */ sl@0: socklen_t msg_namelen; /* size of address */ sl@0: struct iovec *msg_iov; /* scatter/gather array */ sl@0: int msg_iovlen; /* # elements in msg_iov */ sl@0: void *msg_control; /* ancillary data, see below */ sl@0: socklen_t msg_controllen; /* ancillary data buffer len */ sl@0: int msg_flags; /* flags on received message */ sl@0: }; sl@0: sl@0: #define MSG_OOB 0x1 /* process out-of-band data */ sl@0: #define MSG_PEEK 0x2 /* peek at incoming message */ sl@0: #define MSG_DONTROUTE 0x4 /* send without using routing tables */ sl@0: #define MSG_EOR 0x8 /* data completes record */ sl@0: #define MSG_TRUNC 0x10 /* data discarded before delivery */ sl@0: #define MSG_CTRUNC 0x20 /* control data lost before delivery */ sl@0: #define MSG_WAITALL 0x40 /* wait for full request or error */ sl@0: #if __BSD_VISIBLE sl@0: #define MSG_DONTWAIT 0x80 /* this message should be nonblocking */ sl@0: #define MSG_EOF 0x100 /* data completes connection */ sl@0: #define MSG_NBIO 0x4000 /* FIONBIO mode, used by fifofs */ sl@0: #define MSG_COMPAT 0x8000 /* used in sendit() */ sl@0: #endif sl@0: #ifdef _KERNEL sl@0: #define MSG_SOCALLBCK 0x10000 /* for use by socket callbacks - soreceive (TCP) */ sl@0: #endif sl@0: #if __BSD_VISIBLE sl@0: #define MSG_NOSIGNAL 0x20000 /* do not generate SIGPIPE on EOF */ sl@0: #endif sl@0: sl@0: /* sl@0: * Header for ancillary data objects in msg_control buffer. sl@0: * Used for additional information with/about a datagram sl@0: * not expressible by flags. The format is a sequence sl@0: * of message elements headed by cmsghdr structures. sl@0: */ sl@0: struct cmsghdr { sl@0: socklen_t cmsg_len; /* data byte count, including hdr */ sl@0: int cmsg_level; /* originating protocol */ sl@0: int cmsg_type; /* protocol-specific type */ sl@0: /* followed by u_char cmsg_data[]; */ sl@0: }; sl@0: sl@0: #if __BSD_VISIBLE sl@0: /* sl@0: * While we may have more groups than this, the cmsgcred struct must sl@0: * be able to fit in an mbuf, and NGROUPS_MAX is too large to allow sl@0: * this. sl@0: */ sl@0: #define CMGROUP_MAX 16 sl@0: sl@0: /* sl@0: * Credentials structure, used to verify the identity of a peer sl@0: * process that has sent us a message. This is allocated by the sl@0: * peer process but filled in by the kernel. This prevents the sl@0: * peer from lying about its identity. (Note that cmcred_groups[0] sl@0: * is the effective GID.) sl@0: */ sl@0: struct cmsgcred { sl@0: pid_t cmcred_pid; /* PID of sending process */ sl@0: uid_t cmcred_uid; /* real UID of sending process */ sl@0: uid_t cmcred_euid; /* effective UID of sending process */ sl@0: gid_t cmcred_gid; /* real GID of sending process */ sl@0: short cmcred_ngroups; /* number or groups */ sl@0: gid_t cmcred_groups[CMGROUP_MAX]; /* groups */ sl@0: }; sl@0: sl@0: /* sl@0: * Socket credentials. sl@0: */ sl@0: struct sockcred { sl@0: uid_t sc_uid; /* real user id */ sl@0: uid_t sc_euid; /* effective user id */ sl@0: gid_t sc_gid; /* real group id */ sl@0: gid_t sc_egid; /* effective group id */ sl@0: int sc_ngroups; /* number of supplemental groups */ sl@0: gid_t sc_groups[1]; /* variable length */ sl@0: }; sl@0: sl@0: /* sl@0: * Compute size of a sockcred structure with groups. sl@0: */ sl@0: #define SOCKCREDSIZE(ngrps) \ sl@0: (sizeof(struct sockcred) + (sizeof(gid_t) * ((ngrps) - 1))) sl@0: sl@0: #endif /* __BSD_VISIBLE */ sl@0: sl@0: /* given pointer to struct cmsghdr, return pointer to data */ sl@0: #define CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \ sl@0: _ALIGN(sizeof(struct cmsghdr))) sl@0: sl@0: /* given pointer to struct cmsghdr, return pointer to next cmsghdr */ sl@0: #define CMSG_NXTHDR(mhdr, cmsg) \ sl@0: (((char *)(cmsg) + _ALIGN((cmsg)->cmsg_len) + \ sl@0: _ALIGN(sizeof(struct cmsghdr)) > \ sl@0: (char *)(mhdr)->msg_control + (mhdr)->msg_controllen) ? \ sl@0: (struct cmsghdr *)0 : \ sl@0: (struct cmsghdr *)((char *)(cmsg) + _ALIGN((cmsg)->cmsg_len))) sl@0: sl@0: /* sl@0: * RFC 2292 requires to check msg_controllen, in case that the kernel returns sl@0: * an empty list for some reasons. sl@0: */ sl@0: #define CMSG_FIRSTHDR(mhdr) \ sl@0: ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \ sl@0: (struct cmsghdr *)(mhdr)->msg_control : \ sl@0: (struct cmsghdr *)NULL) sl@0: sl@0: #if __BSD_VISIBLE sl@0: /* RFC 2292 additions */ sl@0: #define CMSG_SPACE(l) (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(l)) sl@0: #define CMSG_LEN(l) (_ALIGN(sizeof(struct cmsghdr)) + (l)) sl@0: #endif sl@0: sl@0: #ifdef _KERNEL sl@0: #define CMSG_ALIGN(n) _ALIGN(n) sl@0: #endif sl@0: sl@0: /* "Socket"-level control message types: */ sl@0: #define SCM_RIGHTS 0x01 /* access rights (array of int) */ sl@0: #if __BSD_VISIBLE sl@0: #define SCM_TIMESTAMP 0x02 /* timestamp (struct timeval) */ sl@0: #define SCM_CREDS 0x03 /* process creds (struct cmsgcred) */ sl@0: #define SCM_BINTIME 0x04 /* timestamp (struct bintime) */ sl@0: #endif sl@0: sl@0: #if __BSD_VISIBLE sl@0: /* sl@0: * 4.3 compat sockaddr, move to compat file later sl@0: */ sl@0: struct osockaddr { sl@0: unsigned short sa_family; /* address family */ sl@0: char sa_data[14]; /* up to 14 bytes of direct address */ sl@0: }; sl@0: sl@0: /* sl@0: * 4.3-compat message header (move to compat file later). sl@0: */ sl@0: struct omsghdr { sl@0: char *msg_name; /* optional address */ sl@0: int msg_namelen; /* size of address */ sl@0: struct iovec *msg_iov; /* scatter/gather array */ sl@0: int msg_iovlen; /* # elements in msg_iov */ sl@0: char *msg_accrights; /* access rights sent/received */ sl@0: int msg_accrightslen; sl@0: }; sl@0: #endif sl@0: sl@0: /* sl@0: * howto arguments for shutdown(2), specified by Posix.1g. sl@0: */ sl@0: #define SHUT_RD 0 /* shut down the reading side */ sl@0: #define SHUT_WR 1 /* shut down the writing side */ sl@0: #define SHUT_RDWR 2 /* shut down both sides */ sl@0: sl@0: #if __BSD_VISIBLE sl@0: /* sl@0: * sendfile(2) header/trailer struct sl@0: */ sl@0: struct sf_hdtr { sl@0: struct iovec *headers; /* pointer to an array of header struct iovec's */ sl@0: int hdr_cnt; /* number of header iovec's */ sl@0: struct iovec *trailers; /* pointer to an array of trailer struct iovec's */ sl@0: int trl_cnt; /* number of trailer iovec's */ sl@0: }; sl@0: sl@0: /* sl@0: * Sendfile-specific flag(s) sl@0: */ sl@0: #define SF_NODISKIO 0x00000001 sl@0: #endif sl@0: sl@0: #ifndef _KERNEL sl@0: sl@0: #include sl@0: sl@0: __BEGIN_DECLS sl@0: IMPORT_C int accept(int, struct sockaddr * __restrict, socklen_t * __restrict); sl@0: IMPORT_C int bind(int, const struct sockaddr *, socklen_t); sl@0: IMPORT_C int connect(int, const struct sockaddr *, socklen_t); sl@0: IMPORT_C int getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict); sl@0: IMPORT_C int getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict); sl@0: IMPORT_C int getsockopt(int, int, int, void * __restrict, socklen_t * __restrict); sl@0: IMPORT_C int listen(int, int); sl@0: IMPORT_C ssize_t recv(int, void *, size_t, int); sl@0: IMPORT_C ssize_t recvfrom(int, void *, size_t, int, struct sockaddr * __restrict, socklen_t * __restrict); sl@0: IMPORT_C ssize_t recvmsg(int, struct msghdr *, int); sl@0: IMPORT_C ssize_t send(int, const void *, size_t, int); sl@0: IMPORT_C ssize_t sendto(int, const void *, sl@0: size_t, int, const struct sockaddr *, socklen_t); sl@0: IMPORT_C ssize_t sendmsg(int, const struct msghdr *, int); sl@0: IMPORT_C int setsockopt(int, int, int, const void *, socklen_t); sl@0: IMPORT_C int shutdown(int, int); sl@0: IMPORT_C int sockatmark(int); sl@0: IMPORT_C int socket(int, int, int); sl@0: __END_DECLS sl@0: sl@0: #endif /* !_KERNEL */ sl@0: sl@0: #endif /* !_SYS_SOCKET_H_ */