1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/openenvcore/include/sys/socket.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,679 @@
1.4 +
1.5 +
1.6 +/*-
1.7 + * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994
1.8 + * The Regents of the University of California. All rights reserved.
1.9 + * Redistribution and use in source and binary forms, with or without
1.10 + * modification, are permitted provided that the following conditions
1.11 + * are met:
1.12 + * 1. Redistributions of source code must retain the above copyright
1.13 + * notice, this list of conditions and the following disclaimer.
1.14 + * 2. Redistributions in binary form must reproduce the above copyright
1.15 + * notice, this list of conditions and the following disclaimer in the
1.16 + * documentation and/or other materials provided with the distribution.
1.17 + * 4. Neither the name of the University nor the names of its contributors
1.18 + * may be used to endorse or promote products derived from this software
1.19 + * without specific prior written permission.
1.20 + *
1.21 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1.22 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1.23 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1.24 + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1.25 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1.26 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1.27 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1.28 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1.29 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1.30 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1.31 + * SUCH DAMAGE.
1.32 + * Portions Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
1.33 + * @(#)socket.h 8.4 (Berkeley) 2/21/94
1.34 + * $FreeBSD: src/sys/sys/socket.h,v 1.88.2.1 2005/09/27 21:14:10 rwatson Exp $
1.35 + */
1.36 +
1.37 +#ifndef _SYS_SOCKET_H_
1.38 +#define _SYS_SOCKET_H_
1.39 +
1.40 +#include <sys/cdefs.h>
1.41 +#include <sys/types.h>
1.42 +#include <sys/_types.h>
1.43 +#include <sys/_iovec.h>
1.44 +#define _NO_NAMESPACE_POLLUTION
1.45 +#include <stdapis/machine/param.h>
1.46 +#undef _NO_NAMESPACE_POLLUTION
1.47 +
1.48 +/*
1.49 + * Definitions related to sockets: types, address families, options.
1.50 + */
1.51 +
1.52 +/*
1.53 + * Data types.
1.54 + */
1.55 +#if __BSD_VISIBLE
1.56 +#ifndef _GID_T_DECLARED
1.57 +typedef __gid_t gid_t;
1.58 +#define _GID_T_DECLARED
1.59 +#endif
1.60 +
1.61 +#ifndef _OFF_T_DECLARED
1.62 +typedef __off_t off_t;
1.63 +#define _OFF_T_DECLARED
1.64 +#endif
1.65 +
1.66 +#ifndef _PID_T_DECLARED
1.67 +typedef __pid_t pid_t;
1.68 +#define _PID_T_DECLARED
1.69 +#endif
1.70 +#endif
1.71 +
1.72 +#ifndef _SA_FAMILY_T_DECLARED
1.73 +typedef __sa_family_t sa_family_t;
1.74 +#define _SA_FAMILY_T_DECLARED
1.75 +#endif
1.76 +
1.77 +#ifndef _SOCKLEN_T_DECLARED
1.78 +typedef __socklen_t socklen_t;
1.79 +#define _SOCKLEN_T_DECLARED
1.80 +#endif
1.81 +
1.82 +#ifndef _SSIZE_T_DECLARED
1.83 +typedef __ssize_t ssize_t;
1.84 +#define _SSIZE_T_DECLARED
1.85 +#endif
1.86 +
1.87 +#if __BSD_VISIBLE
1.88 +#ifndef _UID_T_DECLARED
1.89 +typedef __uid_t uid_t;
1.90 +#define _UID_T_DECLARED
1.91 +#endif
1.92 +#endif
1.93 +
1.94 +/*
1.95 + * Types
1.96 + */
1.97 +#define SOCK_STREAM 1 /* stream socket */
1.98 +#define SOCK_DGRAM 2 /* datagram socket */
1.99 +#ifdef __SYMBIAN32__
1.100 +#define SOCK_RAW 4 /* raw-protocol interface */
1.101 +#else
1.102 +#define SOCK_RAW 3 /* raw-protocol interface */
1.103 +#endif // __SYMBIAN32__
1.104 +#if __BSD_VISIBLE
1.105 +#define SOCK_RDM 4 /* reliably-delivered message */
1.106 +#endif
1.107 +#ifdef __SYMBIAN32__
1.108 +#define SOCK_SEQPACKET 3 /* sequenced packet stream */
1.109 +#else
1.110 +#define SOCK_SEQPACKET 5 /* sequenced packet stream */
1.111 +#endif // __SYMBIAN32__
1.112 +
1.113 +/*
1.114 + * Option flags per-socket.
1.115 + */
1.116 +#define SO_DEBUG 0x0001 /* turn on debugging info recording KSODebug */
1.117 +#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
1.118 +#ifdef __SYMBIAN32__
1.119 +#define SO_REUSEADDR 0x406 /* allow local address reuse */
1.120 +#else
1.121 +#define SO_REUSEADDR 0x0004 /* allow local address reuse */
1.122 +#endif // __SYMBIAN32__
1.123 +#ifdef __SYMBIAN32__
1.124 +#define SO_KEEPALIVE 0x305 /* keep connections alive KSoTcpKeepAlive */
1.125 +#else
1.126 +#define SO_KEEPALIVE 0x0008 /* keep connections alive */
1.127 +#endif // __SYMBIAN32__
1.128 +#define SO_DONTROUTE 0x0010 /* just use interface addresses */
1.129 +#ifdef __SYMBIAN32__
1.130 +#define SO_BROADCAST -1 /* permit sending of broadcast msgs */
1.131 +#else
1.132 +#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
1.133 +#endif // __SYMBIAN32__
1.134 +#if __BSD_VISIBLE
1.135 +#ifdef __SYMBIAN32__
1.136 +#define SO_USELOOPBACK -2 /* bypass hardware when possible */
1.137 +#else
1.138 +#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
1.139 +#endif // __SYMBIAN32__
1.140 +#endif
1.141 +#ifdef __SYMBIAN32__
1.142 +#define SO_LINGER -3 /* linger on close if data present */
1.143 +#else
1.144 +#define SO_LINGER 0x0080 /* linger on close if data present */
1.145 +#endif // __SYMBIAN32__
1.146 +#ifdef __SYMBIAN32__
1.147 +#define SO_OOBINLINE 0x315 /* leave received OOB data in line KSoTcpOobInline */
1.148 +#else
1.149 +#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
1.150 +#endif // __SYMBIAN32__
1.151 +#if __BSD_VISIBLE
1.152 +#define SO_REUSEPORT 0x0200 /* allow local address & port reuse */
1.153 +#define SO_TIMESTAMP 0x0400 /* timestamp received dgram traffic */
1.154 +#define SO_NOSIGPIPE 0x0800 /* no SIGPIPE from EPIPE */
1.155 +#define SO_ACCEPTFILTER 0x1000 /* there is an accept filter */
1.156 +#define SO_BINTIME 0x2000 /* timestamp received dgram traffic */
1.157 +#endif
1.158 +
1.159 +/*
1.160 + * Additional options, not kept in so_options.
1.161 + */
1.162 +#ifdef __SYMBIAN32__
1.163 +#define SO_SNDBUF 3 /* send buffer size KSOSendBuf */
1.164 +#else
1.165 +#define SO_SNDBUF 0x1001 /* send buffer size */
1.166 +#endif // __SYMBIAN32__
1.167 +#ifdef __SYMBIAN32__
1.168 +#define SO_RCVBUF 2 /* receive buffer size KSORecvBuf */
1.169 +#else
1.170 +#define SO_RCVBUF 0x1002 /* receive buffer size */
1.171 +#endif // __SYMBIAN32__
1.172 +#define SO_SNDLOWAT 0x1003 /* send low-water mark */
1.173 +#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
1.174 +#define SO_SNDTIMEO 0x1005 /* send timeout */
1.175 +#define SO_RCVTIMEO 0x1006 /* receive timeout */
1.176 +#ifdef __SYMBIAN32__
1.177 +#define SO_ERROR 9 /* get error status and clear */
1.178 +#else
1.179 +#define SO_ERROR 0x1007 /* get error status and clear */
1.180 +#endif // __SYMBIAN32__
1.181 +#define SO_TYPE 0x1008 /* get socket type */
1.182 +#if __BSD_VISIBLE
1.183 +#define SO_LABEL 0x1009 /* socket's MAC label */
1.184 +#define SO_PEERLABEL 0x1010 /* socket's peer's MAC label */
1.185 +#define SO_LISTENQLIMIT 0x1011 /* socket's backlog limit */
1.186 +#define SO_LISTENQLEN 0x1012 /* socket's complete queue length */
1.187 +#define SO_LISTENINCQLEN 0x1013 /* socket's incomplete queue length */
1.188 +#endif
1.189 +
1.190 +/*
1.191 + * Structure used for manipulating linger option.
1.192 + */
1.193 +struct linger {
1.194 + int l_onoff; /* option on/off */
1.195 + int l_linger; /* linger time */
1.196 +};
1.197 +
1.198 +#if __BSD_VISIBLE
1.199 +struct accept_filter_arg {
1.200 + char af_name[16];
1.201 + char af_arg[256-16];
1.202 +};
1.203 +#endif
1.204 +
1.205 +/*
1.206 + * Level number for (get/set)sockopt() to apply to socket itself.
1.207 + */
1.208 +#ifdef __SYMBIAN32__
1.209 +#define SOL_SOCKET 1 /* options for socket level KSOLSocket */
1.210 +#else
1.211 +#define SOL_SOCKET 0xffff /* options for socket level */
1.212 +#endif // __SYMBIAN32__
1.213 +/*
1.214 + * Address families.
1.215 + */
1.216 +#define AF_UNSPEC 0 /* unspecified */
1.217 +#if __BSD_VISIBLE
1.218 +#ifdef __SYMBIAN32__
1.219 +#define AF_LOCAL 0x666 /* local to host (pipes, portals) */
1.220 +#else
1.221 +#define AF_LOCAL AF_UNIX /* local to host (pipes, portals) */
1.222 +#endif // __SYMBIAN32__
1.223 +#endif
1.224 +#define AF_UNIX 1 /* standardized name for AF_LOCAL */
1.225 +#ifdef __SYMBIAN32__
1.226 +#define AF_INET 0x0800 /* internetwork: UDP, TCP, etc. */
1.227 +#else
1.228 +#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
1.229 +#endif // __SYMBIAN32__
1.230 +#if __BSD_VISIBLE
1.231 +#define AF_IMPLINK 3 /* arpanet imp addresses */
1.232 +#define AF_PUP 4 /* pup protocols: e.g. BSP */
1.233 +#define AF_CHAOS 5 /* mit CHAOS protocols */
1.234 +#define AF_NETBIOS 6 /* SMB protocols */
1.235 +#define AF_ISO 7 /* ISO protocols */
1.236 +#define AF_OSI AF_ISO
1.237 +#define AF_ECMA 8 /* European computer manufacturers */
1.238 +#define AF_DATAKIT 9 /* datakit protocols */
1.239 +#define AF_CCITT 10 /* CCITT protocols, X.25 etc */
1.240 +#define AF_SNA 11 /* IBM SNA */
1.241 +#define AF_DECnet 12 /* DECnet */
1.242 +#define AF_DLI 13 /* DEC Direct data link interface */
1.243 +#define AF_LAT 14 /* LAT */
1.244 +#define AF_HYLINK 15 /* NSC Hyperchannel */
1.245 +#define AF_APPLETALK 16 /* Apple Talk */
1.246 +#define AF_ROUTE 17 /* Internal Routing Protocol */
1.247 +#define AF_LINK 18 /* Link layer interface */
1.248 +#define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */
1.249 +#define AF_COIP 20 /* connection-oriented IP, aka ST II */
1.250 +#define AF_CNT 21 /* Computer Network Technology */
1.251 +#define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */
1.252 +#define AF_IPX 23 /* Novell Internet Protocol */
1.253 +#define AF_SIP 24 /* Simple Internet Protocol */
1.254 +#define pseudo_AF_PIP 25 /* Help Identify PIP packets */
1.255 +#define AF_ISDN 26 /* Integrated Services Digital Network*/
1.256 +#define AF_E164 AF_ISDN /* CCITT E.164 recommendation */
1.257 +#define pseudo_AF_KEY 27 /* Internal key-management function */
1.258 +#endif
1.259 +#ifdef __SYMBIAN32__
1.260 +#define AF_INET6 0x0806 /* IPv6 */
1.261 +#else
1.262 +#define AF_INET6 28 /* IPv6 */
1.263 +#endif
1.264 +#if __BSD_VISIBLE
1.265 +#define AF_NATM 29 /* native ATM access */
1.266 +#define AF_ATM 30 /* ATM */
1.267 +#define pseudo_AF_HDRCMPLT 31 /* Used by BPF to not rewrite headers
1.268 + * in interface output routine
1.269 + */
1.270 +#define AF_NETGRAPH 32 /* Netgraph sockets */
1.271 +#define AF_SLOW 33 /* 802.3ad slow protocol */
1.272 +#define AF_SCLUSTER 34 /* Sitara cluster protocol */
1.273 +#define AF_ARP 35
1.274 +#define AF_BLUETOOTH 36 /* Bluetooth sockets */
1.275 +#define AF_MAX 37
1.276 +#endif
1.277 +#ifdef __SYMBIAN32__
1.278 +#define AF_IRDA 0x0100 /* IrDA */
1.279 +#define AF_PLP 273 /* Symbian link protocol */
1.280 +#endif // __SYMBIAN32__
1.281 +
1.282 +#ifndef __SYMBIAN32__
1.283 +/*
1.284 + * Structure used by kernel to store most
1.285 + * addresses.
1.286 + */
1.287 +struct sockaddr {
1.288 + unsigned char sa_len; /* total length */
1.289 + sa_family_t sa_family; /* address family */
1.290 + char sa_data[14]; /* actually longer; address value */
1.291 +};
1.292 +#else
1.293 +/**
1.294 +Structure used by EPOC32 to store most addresses.
1.295 +NB. EPOC32 uses 32-bit family and port numbers internally, but they have been
1.296 +left as shorts here for compatibility with code that uses htons()/ntohs() explicitly.
1.297 +*/
1.298 +struct sockaddr {
1.299 + u_short sa_family; /* address family */
1.300 + u_short sa_port; /* port number - a common feature of most protocols */
1.301 + char sa_data[24]; /* up to 24 bytes of direct address */
1.302 + unsigned char sa_len;
1.303 +};
1.304 +#endif //__SYMBIAN32__
1.305 +
1.306 +#if __BSD_VISIBLE
1.307 +#define SOCK_MAXADDRLEN 255 /* longest possible addresses */
1.308 +
1.309 +/*
1.310 + * Structure used by kernel to pass protocol
1.311 + * information in raw sockets.
1.312 + */
1.313 +struct sockproto {
1.314 + unsigned short sp_family; /* address family */
1.315 + unsigned short sp_protocol; /* protocol */
1.316 +};
1.317 +#endif
1.318 +
1.319 +/*
1.320 + * RFC 2553: protocol-independent placeholder for socket addresses
1.321 + */
1.322 +#ifndef __SYMBIAN32__
1.323 +#define _SS_MAXSIZE 128U
1.324 +#define _SS_ALIGNSIZE (sizeof(__int64_t))
1.325 +#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) - \
1.326 + sizeof(sa_family_t))
1.327 +#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) - \
1.328 + sizeof(sa_family_t) - _SS_PAD1SIZE - _SS_ALIGNSIZE)
1.329 +
1.330 +struct sockaddr_storage {
1.331 + unsigned char ss_len; /* address length */
1.332 + sa_family_t ss_family; /* address family */
1.333 + char __ss_pad1[_SS_PAD1SIZE];
1.334 + __int64_t __ss_align; /* force desired struct alignment */
1.335 + char __ss_pad2[_SS_PAD2SIZE];
1.336 +};
1.337 +#else
1.338 +#define _SS_MAXSIZE 128U
1.339 +#define _SS_ALIGNSIZE (sizeof(__int64_t))
1.340 +#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(u_short))
1.341 +#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(u_short) - _SS_PAD1SIZE - _SS_ALIGNSIZE)
1.342 +
1.343 +struct sockaddr_storage {
1.344 + u_short ss_family; /* address family */
1.345 + char __ss_pad1[_SS_PAD1SIZE];
1.346 + __int64_t __ss_align; /* force desired struct alignment */
1.347 + char __ss_pad2[_SS_PAD2SIZE];
1.348 +};
1.349 +#endif
1.350 +#if __BSD_VISIBLE
1.351 +/*
1.352 + * Protocol families, same as address families for now.
1.353 + */
1.354 +#define PF_UNSPEC AF_UNSPEC
1.355 +#define PF_LOCAL AF_LOCAL
1.356 +#define PF_UNIX PF_LOCAL /* backward compatibility */
1.357 +#define PF_INET AF_INET
1.358 +#define PF_IMPLINK AF_IMPLINK
1.359 +#define PF_PUP AF_PUP
1.360 +#define PF_CHAOS AF_CHAOS
1.361 +#define PF_NETBIOS AF_NETBIOS
1.362 +#define PF_ISO AF_ISO
1.363 +#define PF_OSI AF_ISO
1.364 +#define PF_ECMA AF_ECMA
1.365 +#define PF_DATAKIT AF_DATAKIT
1.366 +#define PF_CCITT AF_CCITT
1.367 +#define PF_SNA AF_SNA
1.368 +#define PF_DECnet AF_DECnet
1.369 +#define PF_DLI AF_DLI
1.370 +#define PF_LAT AF_LAT
1.371 +#define PF_HYLINK AF_HYLINK
1.372 +#define PF_APPLETALK AF_APPLETALK
1.373 +#define PF_ROUTE AF_ROUTE
1.374 +#define PF_LINK AF_LINK
1.375 +#define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */
1.376 +#define PF_COIP AF_COIP
1.377 +#define PF_CNT AF_CNT
1.378 +#define PF_SIP AF_SIP
1.379 +#define PF_IPX AF_IPX
1.380 +#define PF_RTIP pseudo_AF_RTIP /* same format as AF_INET */
1.381 +#define PF_PIP pseudo_AF_PIP
1.382 +#define PF_ISDN AF_ISDN
1.383 +#define PF_KEY pseudo_AF_KEY
1.384 +#define PF_INET6 AF_INET6
1.385 +#define PF_NATM AF_NATM
1.386 +#define PF_ATM AF_ATM
1.387 +#define PF_NETGRAPH AF_NETGRAPH
1.388 +#define PF_SLOW AF_SLOW
1.389 +#define PF_SCLUSTER AF_SCLUSTER
1.390 +#define PF_ARP AF_ARP
1.391 +#define PF_BLUETOOTH AF_BLUETOOTH
1.392 +
1.393 +#define PF_MAX AF_MAX
1.394 +
1.395 +#ifdef __SYMBIAN32__
1.396 +#define PF_IRDA AF_IRDA
1.397 +#define PF_PLP AF_PLP
1.398 +#endif // __SYMBIAN32__
1.399 +/*
1.400 + * Definitions for network related sysctl, CTL_NET.
1.401 + *
1.402 + * Second level is protocol family.
1.403 + * Third level is protocol number.
1.404 + *
1.405 + * Further levels are defined by the individual families below.
1.406 + */
1.407 +#define NET_MAXID AF_MAX
1.408 +
1.409 +#define CTL_NET_NAMES { \
1.410 + { 0, 0 }, \
1.411 + { "unix", CTLTYPE_NODE }, \
1.412 + { "inet", CTLTYPE_NODE }, \
1.413 + { "implink", CTLTYPE_NODE }, \
1.414 + { "pup", CTLTYPE_NODE }, \
1.415 + { "chaos", CTLTYPE_NODE }, \
1.416 + { "xerox_ns", CTLTYPE_NODE }, \
1.417 + { "iso", CTLTYPE_NODE }, \
1.418 + { "emca", CTLTYPE_NODE }, \
1.419 + { "datakit", CTLTYPE_NODE }, \
1.420 + { "ccitt", CTLTYPE_NODE }, \
1.421 + { "ibm_sna", CTLTYPE_NODE }, \
1.422 + { "decnet", CTLTYPE_NODE }, \
1.423 + { "dec_dli", CTLTYPE_NODE }, \
1.424 + { "lat", CTLTYPE_NODE }, \
1.425 + { "hylink", CTLTYPE_NODE }, \
1.426 + { "appletalk", CTLTYPE_NODE }, \
1.427 + { "route", CTLTYPE_NODE }, \
1.428 + { "link_layer", CTLTYPE_NODE }, \
1.429 + { "xtp", CTLTYPE_NODE }, \
1.430 + { "coip", CTLTYPE_NODE }, \
1.431 + { "cnt", CTLTYPE_NODE }, \
1.432 + { "rtip", CTLTYPE_NODE }, \
1.433 + { "ipx", CTLTYPE_NODE }, \
1.434 + { "sip", CTLTYPE_NODE }, \
1.435 + { "pip", CTLTYPE_NODE }, \
1.436 + { "isdn", CTLTYPE_NODE }, \
1.437 + { "key", CTLTYPE_NODE }, \
1.438 + { "inet6", CTLTYPE_NODE }, \
1.439 + { "natm", CTLTYPE_NODE }, \
1.440 + { "atm", CTLTYPE_NODE }, \
1.441 + { "hdrcomplete", CTLTYPE_NODE }, \
1.442 + { "netgraph", CTLTYPE_NODE }, \
1.443 + { "snp", CTLTYPE_NODE }, \
1.444 + { "scp", CTLTYPE_NODE }, \
1.445 +}
1.446 +
1.447 +/*
1.448 + * PF_ROUTE - Routing table
1.449 + *
1.450 + * Three additional levels are defined:
1.451 + * Fourth: address family, 0 is wildcard
1.452 + * Fifth: type of info, defined below
1.453 + * Sixth: flag(s) to mask with for NET_RT_FLAGS
1.454 + */
1.455 +#define NET_RT_DUMP 1 /* dump; may limit to a.f. */
1.456 +#define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */
1.457 +#define NET_RT_IFLIST 3 /* survey interface list */
1.458 +#define NET_RT_IFMALIST 4 /* return multicast address list */
1.459 +#define NET_RT_MAXID 5
1.460 +
1.461 +#define CTL_NET_RT_NAMES { \
1.462 + { 0, 0 }, \
1.463 + { "dump", CTLTYPE_STRUCT }, \
1.464 + { "flags", CTLTYPE_STRUCT }, \
1.465 + { "iflist", CTLTYPE_STRUCT }, \
1.466 + { "ifmalist", CTLTYPE_STRUCT }, \
1.467 +}
1.468 +#endif /* __BSD_VISIBLE */
1.469 +
1.470 +/*
1.471 + * Maximum queue length specifiable by listen.
1.472 + */
1.473 +#ifdef __SYMBIAN32__
1.474 +#define SOMAXCONN 5
1.475 +#else
1.476 +#define SOMAXCONN 128
1.477 +#endif // __SYMBIAN32__
1.478 +
1.479 +/*
1.480 + * Message header for recvmsg and sendmsg calls.
1.481 + * Used value-result for recvmsg, value only for sendmsg.
1.482 + */
1.483 +struct msghdr {
1.484 + void *msg_name; /* optional address */
1.485 + socklen_t msg_namelen; /* size of address */
1.486 + struct iovec *msg_iov; /* scatter/gather array */
1.487 + int msg_iovlen; /* # elements in msg_iov */
1.488 + void *msg_control; /* ancillary data, see below */
1.489 + socklen_t msg_controllen; /* ancillary data buffer len */
1.490 + int msg_flags; /* flags on received message */
1.491 +};
1.492 +
1.493 +#define MSG_OOB 0x1 /* process out-of-band data */
1.494 +#define MSG_PEEK 0x2 /* peek at incoming message */
1.495 +#define MSG_DONTROUTE 0x4 /* send without using routing tables */
1.496 +#define MSG_EOR 0x8 /* data completes record */
1.497 +#define MSG_TRUNC 0x10 /* data discarded before delivery */
1.498 +#define MSG_CTRUNC 0x20 /* control data lost before delivery */
1.499 +#define MSG_WAITALL 0x40 /* wait for full request or error */
1.500 +#if __BSD_VISIBLE
1.501 +#define MSG_DONTWAIT 0x80 /* this message should be nonblocking */
1.502 +#define MSG_EOF 0x100 /* data completes connection */
1.503 +#define MSG_NBIO 0x4000 /* FIONBIO mode, used by fifofs */
1.504 +#define MSG_COMPAT 0x8000 /* used in sendit() */
1.505 +#endif
1.506 +#ifdef _KERNEL
1.507 +#define MSG_SOCALLBCK 0x10000 /* for use by socket callbacks - soreceive (TCP) */
1.508 +#endif
1.509 +#if __BSD_VISIBLE
1.510 +#define MSG_NOSIGNAL 0x20000 /* do not generate SIGPIPE on EOF */
1.511 +#endif
1.512 +
1.513 +/*
1.514 + * Header for ancillary data objects in msg_control buffer.
1.515 + * Used for additional information with/about a datagram
1.516 + * not expressible by flags. The format is a sequence
1.517 + * of message elements headed by cmsghdr structures.
1.518 + */
1.519 +struct cmsghdr {
1.520 + socklen_t cmsg_len; /* data byte count, including hdr */
1.521 + int cmsg_level; /* originating protocol */
1.522 + int cmsg_type; /* protocol-specific type */
1.523 +/* followed by u_char cmsg_data[]; */
1.524 +};
1.525 +
1.526 +#if __BSD_VISIBLE
1.527 +/*
1.528 + * While we may have more groups than this, the cmsgcred struct must
1.529 + * be able to fit in an mbuf, and NGROUPS_MAX is too large to allow
1.530 + * this.
1.531 +*/
1.532 +#define CMGROUP_MAX 16
1.533 +
1.534 +/*
1.535 + * Credentials structure, used to verify the identity of a peer
1.536 + * process that has sent us a message. This is allocated by the
1.537 + * peer process but filled in by the kernel. This prevents the
1.538 + * peer from lying about its identity. (Note that cmcred_groups[0]
1.539 + * is the effective GID.)
1.540 + */
1.541 +struct cmsgcred {
1.542 + pid_t cmcred_pid; /* PID of sending process */
1.543 + uid_t cmcred_uid; /* real UID of sending process */
1.544 + uid_t cmcred_euid; /* effective UID of sending process */
1.545 + gid_t cmcred_gid; /* real GID of sending process */
1.546 + short cmcred_ngroups; /* number or groups */
1.547 + gid_t cmcred_groups[CMGROUP_MAX]; /* groups */
1.548 +};
1.549 +
1.550 +/*
1.551 + * Socket credentials.
1.552 + */
1.553 +struct sockcred {
1.554 + uid_t sc_uid; /* real user id */
1.555 + uid_t sc_euid; /* effective user id */
1.556 + gid_t sc_gid; /* real group id */
1.557 + gid_t sc_egid; /* effective group id */
1.558 + int sc_ngroups; /* number of supplemental groups */
1.559 + gid_t sc_groups[1]; /* variable length */
1.560 +};
1.561 +
1.562 +/*
1.563 + * Compute size of a sockcred structure with groups.
1.564 + */
1.565 +#define SOCKCREDSIZE(ngrps) \
1.566 + (sizeof(struct sockcred) + (sizeof(gid_t) * ((ngrps) - 1)))
1.567 +
1.568 +#endif /* __BSD_VISIBLE */
1.569 +
1.570 +/* given pointer to struct cmsghdr, return pointer to data */
1.571 +#define CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \
1.572 + _ALIGN(sizeof(struct cmsghdr)))
1.573 +
1.574 +/* given pointer to struct cmsghdr, return pointer to next cmsghdr */
1.575 +#define CMSG_NXTHDR(mhdr, cmsg) \
1.576 + (((char *)(cmsg) + _ALIGN((cmsg)->cmsg_len) + \
1.577 + _ALIGN(sizeof(struct cmsghdr)) > \
1.578 + (char *)(mhdr)->msg_control + (mhdr)->msg_controllen) ? \
1.579 + (struct cmsghdr *)0 : \
1.580 + (struct cmsghdr *)((char *)(cmsg) + _ALIGN((cmsg)->cmsg_len)))
1.581 +
1.582 +/*
1.583 + * RFC 2292 requires to check msg_controllen, in case that the kernel returns
1.584 + * an empty list for some reasons.
1.585 + */
1.586 +#define CMSG_FIRSTHDR(mhdr) \
1.587 + ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
1.588 + (struct cmsghdr *)(mhdr)->msg_control : \
1.589 + (struct cmsghdr *)NULL)
1.590 +
1.591 +#if __BSD_VISIBLE
1.592 +/* RFC 2292 additions */
1.593 +#define CMSG_SPACE(l) (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(l))
1.594 +#define CMSG_LEN(l) (_ALIGN(sizeof(struct cmsghdr)) + (l))
1.595 +#endif
1.596 +
1.597 +#ifdef _KERNEL
1.598 +#define CMSG_ALIGN(n) _ALIGN(n)
1.599 +#endif
1.600 +
1.601 +/* "Socket"-level control message types: */
1.602 +#define SCM_RIGHTS 0x01 /* access rights (array of int) */
1.603 +#if __BSD_VISIBLE
1.604 +#define SCM_TIMESTAMP 0x02 /* timestamp (struct timeval) */
1.605 +#define SCM_CREDS 0x03 /* process creds (struct cmsgcred) */
1.606 +#define SCM_BINTIME 0x04 /* timestamp (struct bintime) */
1.607 +#endif
1.608 +
1.609 +#if __BSD_VISIBLE
1.610 +/*
1.611 + * 4.3 compat sockaddr, move to compat file later
1.612 + */
1.613 +struct osockaddr {
1.614 + unsigned short sa_family; /* address family */
1.615 + char sa_data[14]; /* up to 14 bytes of direct address */
1.616 +};
1.617 +
1.618 +/*
1.619 + * 4.3-compat message header (move to compat file later).
1.620 + */
1.621 +struct omsghdr {
1.622 + char *msg_name; /* optional address */
1.623 + int msg_namelen; /* size of address */
1.624 + struct iovec *msg_iov; /* scatter/gather array */
1.625 + int msg_iovlen; /* # elements in msg_iov */
1.626 + char *msg_accrights; /* access rights sent/received */
1.627 + int msg_accrightslen;
1.628 +};
1.629 +#endif
1.630 +
1.631 +/*
1.632 + * howto arguments for shutdown(2), specified by Posix.1g.
1.633 + */
1.634 +#define SHUT_RD 0 /* shut down the reading side */
1.635 +#define SHUT_WR 1 /* shut down the writing side */
1.636 +#define SHUT_RDWR 2 /* shut down both sides */
1.637 +
1.638 +#if __BSD_VISIBLE
1.639 +/*
1.640 + * sendfile(2) header/trailer struct
1.641 + */
1.642 +struct sf_hdtr {
1.643 + struct iovec *headers; /* pointer to an array of header struct iovec's */
1.644 + int hdr_cnt; /* number of header iovec's */
1.645 + struct iovec *trailers; /* pointer to an array of trailer struct iovec's */
1.646 + int trl_cnt; /* number of trailer iovec's */
1.647 +};
1.648 +
1.649 +/*
1.650 + * Sendfile-specific flag(s)
1.651 + */
1.652 +#define SF_NODISKIO 0x00000001
1.653 +#endif
1.654 +
1.655 +#ifndef _KERNEL
1.656 +
1.657 +#include <sys/cdefs.h>
1.658 +
1.659 +__BEGIN_DECLS
1.660 +IMPORT_C int accept(int, struct sockaddr * __restrict, socklen_t * __restrict);
1.661 +IMPORT_C int bind(int, const struct sockaddr *, socklen_t);
1.662 +IMPORT_C int connect(int, const struct sockaddr *, socklen_t);
1.663 +IMPORT_C int getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict);
1.664 +IMPORT_C int getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict);
1.665 +IMPORT_C int getsockopt(int, int, int, void * __restrict, socklen_t * __restrict);
1.666 +IMPORT_C int listen(int, int);
1.667 +IMPORT_C ssize_t recv(int, void *, size_t, int);
1.668 +IMPORT_C ssize_t recvfrom(int, void *, size_t, int, struct sockaddr * __restrict, socklen_t * __restrict);
1.669 +IMPORT_C ssize_t recvmsg(int, struct msghdr *, int);
1.670 +IMPORT_C ssize_t send(int, const void *, size_t, int);
1.671 +IMPORT_C ssize_t sendto(int, const void *,
1.672 + size_t, int, const struct sockaddr *, socklen_t);
1.673 +IMPORT_C ssize_t sendmsg(int, const struct msghdr *, int);
1.674 +IMPORT_C int setsockopt(int, int, int, const void *, socklen_t);
1.675 +IMPORT_C int shutdown(int, int);
1.676 +IMPORT_C int sockatmark(int);
1.677 +IMPORT_C int socket(int, int, int);
1.678 +__END_DECLS
1.679 +
1.680 +#endif /* !_KERNEL */
1.681 +
1.682 +#endif /* !_SYS_SOCKET_H_ */