os/ossrv/genericopenlibs/openenvcore/include/sys/socket.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
sl@0
     2
sl@0
     3
/*-
sl@0
     4
 * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994
sl@0
     5
 *	The Regents of the University of California.  All rights reserved.
sl@0
     6
 * Redistribution and use in source and binary forms, with or without
sl@0
     7
 * modification, are permitted provided that the following conditions
sl@0
     8
 * are met:
sl@0
     9
 * 1. Redistributions of source code must retain the above copyright
sl@0
    10
 *    notice, this list of conditions and the following disclaimer.
sl@0
    11
 * 2. Redistributions in binary form must reproduce the above copyright
sl@0
    12
 *    notice, this list of conditions and the following disclaimer in the
sl@0
    13
 *    documentation and/or other materials provided with the distribution.
sl@0
    14
 * 4. Neither the name of the University nor the names of its contributors
sl@0
    15
 *    may be used to endorse or promote products derived from this software
sl@0
    16
 *    without specific prior written permission.
sl@0
    17
 *
sl@0
    18
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
sl@0
    19
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
sl@0
    20
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
sl@0
    21
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
sl@0
    22
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
sl@0
    23
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
sl@0
    24
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
sl@0
    25
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
sl@0
    26
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
sl@0
    27
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
sl@0
    28
 * SUCH DAMAGE.
sl@0
    29
 * Portions Copyright (c) 2006-2007  Nokia Corporation and/or its subsidiary(-ies).  All rights reserved.
sl@0
    30
 *	@(#)socket.h	8.4 (Berkeley) 2/21/94
sl@0
    31
 * $FreeBSD: src/sys/sys/socket.h,v 1.88.2.1 2005/09/27 21:14:10 rwatson Exp $
sl@0
    32
 */
sl@0
    33
sl@0
    34
#ifndef _SYS_SOCKET_H_
sl@0
    35
#define	_SYS_SOCKET_H_
sl@0
    36
sl@0
    37
#include <sys/cdefs.h>
sl@0
    38
#include <sys/types.h>
sl@0
    39
#include <sys/_types.h>
sl@0
    40
#include <sys/_iovec.h>
sl@0
    41
#define _NO_NAMESPACE_POLLUTION
sl@0
    42
#include <stdapis/machine/param.h>
sl@0
    43
#undef _NO_NAMESPACE_POLLUTION
sl@0
    44
sl@0
    45
/*
sl@0
    46
 * Definitions related to sockets: types, address families, options.
sl@0
    47
 */
sl@0
    48
sl@0
    49
/*
sl@0
    50
 * Data types.
sl@0
    51
 */
sl@0
    52
#if __BSD_VISIBLE
sl@0
    53
#ifndef _GID_T_DECLARED
sl@0
    54
typedef	__gid_t		gid_t;
sl@0
    55
#define	_GID_T_DECLARED
sl@0
    56
#endif
sl@0
    57
sl@0
    58
#ifndef _OFF_T_DECLARED
sl@0
    59
typedef	__off_t		off_t;
sl@0
    60
#define	_OFF_T_DECLARED
sl@0
    61
#endif
sl@0
    62
sl@0
    63
#ifndef _PID_T_DECLARED
sl@0
    64
typedef	__pid_t		pid_t;
sl@0
    65
#define	_PID_T_DECLARED
sl@0
    66
#endif
sl@0
    67
#endif
sl@0
    68
sl@0
    69
#ifndef _SA_FAMILY_T_DECLARED
sl@0
    70
typedef	__sa_family_t	sa_family_t;
sl@0
    71
#define	_SA_FAMILY_T_DECLARED
sl@0
    72
#endif
sl@0
    73
sl@0
    74
#ifndef _SOCKLEN_T_DECLARED
sl@0
    75
typedef	__socklen_t	socklen_t;
sl@0
    76
#define	_SOCKLEN_T_DECLARED
sl@0
    77
#endif
sl@0
    78
 
sl@0
    79
#ifndef _SSIZE_T_DECLARED
sl@0
    80
typedef	__ssize_t	ssize_t;
sl@0
    81
#define	_SSIZE_T_DECLARED
sl@0
    82
#endif
sl@0
    83
sl@0
    84
#if __BSD_VISIBLE 
sl@0
    85
#ifndef _UID_T_DECLARED
sl@0
    86
typedef	__uid_t		uid_t;
sl@0
    87
#define	_UID_T_DECLARED
sl@0
    88
#endif
sl@0
    89
#endif
sl@0
    90
sl@0
    91
/*
sl@0
    92
 * Types
sl@0
    93
 */
sl@0
    94
#define	SOCK_STREAM	1		/* stream socket */
sl@0
    95
#define	SOCK_DGRAM	2		/* datagram socket */
sl@0
    96
#ifdef __SYMBIAN32__
sl@0
    97
#define	SOCK_RAW	4		/* raw-protocol interface */
sl@0
    98
#else
sl@0
    99
#define	SOCK_RAW	3		/* raw-protocol interface */
sl@0
   100
#endif	// __SYMBIAN32__
sl@0
   101
#if __BSD_VISIBLE
sl@0
   102
#define	SOCK_RDM	4		/* reliably-delivered message */
sl@0
   103
#endif
sl@0
   104
#ifdef __SYMBIAN32__
sl@0
   105
#define	SOCK_SEQPACKET	3		/* sequenced packet stream */
sl@0
   106
#else
sl@0
   107
#define	SOCK_SEQPACKET	5		/* sequenced packet stream */
sl@0
   108
#endif	// __SYMBIAN32__
sl@0
   109
sl@0
   110
/*
sl@0
   111
 * Option flags per-socket.
sl@0
   112
 */
sl@0
   113
#define	SO_DEBUG	0x0001		/* turn on debugging info recording KSODebug */
sl@0
   114
#define	SO_ACCEPTCONN	0x0002		/* socket has had listen() */
sl@0
   115
#ifdef __SYMBIAN32__
sl@0
   116
#define	SO_REUSEADDR	0x406		/* allow local address reuse */
sl@0
   117
#else
sl@0
   118
#define	SO_REUSEADDR	0x0004		/* allow local address reuse */
sl@0
   119
#endif	// __SYMBIAN32__
sl@0
   120
#ifdef __SYMBIAN32__
sl@0
   121
#define	SO_KEEPALIVE	0x305		/* keep connections alive KSoTcpKeepAlive */
sl@0
   122
#else
sl@0
   123
#define	SO_KEEPALIVE	0x0008		/* keep connections alive */
sl@0
   124
#endif	// __SYMBIAN32__
sl@0
   125
#define	SO_DONTROUTE	0x0010		/* just use interface addresses */
sl@0
   126
#ifdef __SYMBIAN32__
sl@0
   127
#define	SO_BROADCAST	-1			/* permit sending of broadcast msgs */
sl@0
   128
#else
sl@0
   129
#define	SO_BROADCAST	0x0020		/* permit sending of broadcast msgs */
sl@0
   130
#endif	// __SYMBIAN32__
sl@0
   131
#if __BSD_VISIBLE
sl@0
   132
#ifdef __SYMBIAN32__
sl@0
   133
#define	SO_USELOOPBACK	-2 		/* bypass hardware when possible */
sl@0
   134
#else
sl@0
   135
#define	SO_USELOOPBACK	0x0040		/* bypass hardware when possible */
sl@0
   136
#endif	// __SYMBIAN32__
sl@0
   137
#endif
sl@0
   138
#ifdef __SYMBIAN32__
sl@0
   139
#define	SO_LINGER	-3			/* linger on close if data present */
sl@0
   140
#else
sl@0
   141
#define	SO_LINGER	0x0080		/* linger on close if data present */
sl@0
   142
#endif	// __SYMBIAN32__
sl@0
   143
#ifdef __SYMBIAN32__
sl@0
   144
#define	SO_OOBINLINE	0x315		/* leave received OOB data in line KSoTcpOobInline */
sl@0
   145
#else
sl@0
   146
#define	SO_OOBINLINE	0x0100		/* leave received OOB data in line */
sl@0
   147
#endif	// __SYMBIAN32__
sl@0
   148
#if __BSD_VISIBLE
sl@0
   149
#define	SO_REUSEPORT	0x0200		/* allow local address & port reuse */
sl@0
   150
#define	SO_TIMESTAMP	0x0400		/* timestamp received dgram traffic */
sl@0
   151
#define	SO_NOSIGPIPE	0x0800		/* no SIGPIPE from EPIPE */
sl@0
   152
#define	SO_ACCEPTFILTER	0x1000		/* there is an accept filter */
sl@0
   153
#define	SO_BINTIME	0x2000		/* timestamp received dgram traffic */
sl@0
   154
#endif
sl@0
   155
sl@0
   156
/*
sl@0
   157
 * Additional options, not kept in so_options.
sl@0
   158
 */
sl@0
   159
#ifdef __SYMBIAN32__
sl@0
   160
#define	SO_SNDBUF	3			/* send buffer size KSOSendBuf */
sl@0
   161
#else
sl@0
   162
#define	SO_SNDBUF	0x1001		/* send buffer size */
sl@0
   163
#endif	// __SYMBIAN32__
sl@0
   164
#ifdef __SYMBIAN32__
sl@0
   165
#define	SO_RCVBUF	2			/* receive buffer size KSORecvBuf */
sl@0
   166
#else
sl@0
   167
#define	SO_RCVBUF	0x1002		/* receive buffer size */
sl@0
   168
#endif	// __SYMBIAN32__
sl@0
   169
#define	SO_SNDLOWAT	0x1003		/* send low-water mark */
sl@0
   170
#define	SO_RCVLOWAT	0x1004		/* receive low-water mark */
sl@0
   171
#define	SO_SNDTIMEO	0x1005		/* send timeout */
sl@0
   172
#define	SO_RCVTIMEO	0x1006		/* receive timeout */
sl@0
   173
#ifdef __SYMBIAN32__
sl@0
   174
#define	SO_ERROR	9		/* get error status and clear */
sl@0
   175
#else
sl@0
   176
#define	SO_ERROR	0x1007		/* get error status and clear */
sl@0
   177
#endif	// __SYMBIAN32__
sl@0
   178
#define	SO_TYPE		0x1008		/* get socket type */
sl@0
   179
#if __BSD_VISIBLE
sl@0
   180
#define	SO_LABEL	0x1009		/* socket's MAC label */
sl@0
   181
#define	SO_PEERLABEL	0x1010		/* socket's peer's MAC label */
sl@0
   182
#define	SO_LISTENQLIMIT	0x1011		/* socket's backlog limit */
sl@0
   183
#define	SO_LISTENQLEN	0x1012		/* socket's complete queue length */
sl@0
   184
#define	SO_LISTENINCQLEN	0x1013	/* socket's incomplete queue length */
sl@0
   185
#endif
sl@0
   186
sl@0
   187
/*
sl@0
   188
 * Structure used for manipulating linger option.
sl@0
   189
 */
sl@0
   190
struct linger {
sl@0
   191
	int	l_onoff;		/* option on/off */
sl@0
   192
	int	l_linger;		/* linger time */
sl@0
   193
};
sl@0
   194
sl@0
   195
#if __BSD_VISIBLE
sl@0
   196
struct accept_filter_arg {
sl@0
   197
	char	af_name[16];
sl@0
   198
	char	af_arg[256-16];
sl@0
   199
};
sl@0
   200
#endif
sl@0
   201
sl@0
   202
/*
sl@0
   203
 * Level number for (get/set)sockopt() to apply to socket itself.
sl@0
   204
 */
sl@0
   205
#ifdef __SYMBIAN32__
sl@0
   206
#define	SOL_SOCKET	1			/* options for socket level KSOLSocket */
sl@0
   207
#else
sl@0
   208
#define	SOL_SOCKET	0xffff		/* options for socket level */
sl@0
   209
#endif	// __SYMBIAN32__
sl@0
   210
/*
sl@0
   211
 * Address families.
sl@0
   212
 */
sl@0
   213
#define	AF_UNSPEC	0		/* unspecified */
sl@0
   214
#if __BSD_VISIBLE
sl@0
   215
#ifdef __SYMBIAN32__
sl@0
   216
#define	AF_LOCAL	0x666		/* local to host (pipes, portals) */
sl@0
   217
#else
sl@0
   218
#define	AF_LOCAL	AF_UNIX		/* local to host (pipes, portals) */
sl@0
   219
#endif	// __SYMBIAN32__
sl@0
   220
#endif
sl@0
   221
#define	AF_UNIX		1		/* standardized name for AF_LOCAL */
sl@0
   222
#ifdef __SYMBIAN32__
sl@0
   223
#define	AF_INET		0x0800		/* internetwork: UDP, TCP, etc. */
sl@0
   224
#else
sl@0
   225
#define	AF_INET		2		/* internetwork: UDP, TCP, etc. */
sl@0
   226
#endif	// __SYMBIAN32__
sl@0
   227
#if __BSD_VISIBLE
sl@0
   228
#define	AF_IMPLINK	3		/* arpanet imp addresses */
sl@0
   229
#define	AF_PUP		4		/* pup protocols: e.g. BSP */
sl@0
   230
#define	AF_CHAOS	5		/* mit CHAOS protocols */
sl@0
   231
#define	AF_NETBIOS	6		/* SMB protocols */
sl@0
   232
#define	AF_ISO		7		/* ISO protocols */
sl@0
   233
#define	AF_OSI		AF_ISO
sl@0
   234
#define	AF_ECMA		8		/* European computer manufacturers */
sl@0
   235
#define	AF_DATAKIT	9		/* datakit protocols */
sl@0
   236
#define	AF_CCITT	10		/* CCITT protocols, X.25 etc */
sl@0
   237
#define	AF_SNA		11		/* IBM SNA */
sl@0
   238
#define AF_DECnet	12		/* DECnet */
sl@0
   239
#define AF_DLI		13		/* DEC Direct data link interface */
sl@0
   240
#define AF_LAT		14		/* LAT */
sl@0
   241
#define	AF_HYLINK	15		/* NSC Hyperchannel */
sl@0
   242
#define	AF_APPLETALK	16		/* Apple Talk */
sl@0
   243
#define	AF_ROUTE	17		/* Internal Routing Protocol */
sl@0
   244
#define	AF_LINK		18		/* Link layer interface */
sl@0
   245
#define	pseudo_AF_XTP	19		/* eXpress Transfer Protocol (no AF) */
sl@0
   246
#define	AF_COIP		20		/* connection-oriented IP, aka ST II */
sl@0
   247
#define	AF_CNT		21		/* Computer Network Technology */
sl@0
   248
#define pseudo_AF_RTIP	22		/* Help Identify RTIP packets */
sl@0
   249
#define	AF_IPX		23		/* Novell Internet Protocol */
sl@0
   250
#define	AF_SIP		24		/* Simple Internet Protocol */
sl@0
   251
#define	pseudo_AF_PIP	25		/* Help Identify PIP packets */
sl@0
   252
#define	AF_ISDN		26		/* Integrated Services Digital Network*/
sl@0
   253
#define	AF_E164		AF_ISDN		/* CCITT E.164 recommendation */
sl@0
   254
#define	pseudo_AF_KEY	27		/* Internal key-management function */
sl@0
   255
#endif
sl@0
   256
#ifdef __SYMBIAN32__
sl@0
   257
#define	AF_INET6	0x0806		/* IPv6 */
sl@0
   258
#else
sl@0
   259
#define	AF_INET6	28		/* IPv6 */
sl@0
   260
#endif
sl@0
   261
#if __BSD_VISIBLE
sl@0
   262
#define	AF_NATM		29		/* native ATM access */
sl@0
   263
#define	AF_ATM		30		/* ATM */
sl@0
   264
#define pseudo_AF_HDRCMPLT 31		/* Used by BPF to not rewrite headers
sl@0
   265
					 * in interface output routine
sl@0
   266
					 */
sl@0
   267
#define	AF_NETGRAPH	32		/* Netgraph sockets */
sl@0
   268
#define	AF_SLOW		33		/* 802.3ad slow protocol */
sl@0
   269
#define	AF_SCLUSTER	34		/* Sitara cluster protocol */
sl@0
   270
#define	AF_ARP		35
sl@0
   271
#define	AF_BLUETOOTH	36		/* Bluetooth sockets */
sl@0
   272
#define	AF_MAX		37
sl@0
   273
#endif
sl@0
   274
#ifdef __SYMBIAN32__
sl@0
   275
#define	AF_IRDA		0x0100		/* IrDA */
sl@0
   276
#define AF_PLP		273		/* Symbian link protocol */
sl@0
   277
#endif	// __SYMBIAN32__
sl@0
   278
sl@0
   279
#ifndef __SYMBIAN32__
sl@0
   280
/*
sl@0
   281
 * Structure used by kernel to store most
sl@0
   282
 * addresses.
sl@0
   283
 */
sl@0
   284
struct sockaddr {
sl@0
   285
	unsigned char	sa_len;		/* total length */
sl@0
   286
	sa_family_t	sa_family;	/* address family */
sl@0
   287
	char		sa_data[14];	/* actually longer; address value */
sl@0
   288
};
sl@0
   289
#else 
sl@0
   290
/**
sl@0
   291
Structure used by EPOC32 to store most addresses.
sl@0
   292
NB. EPOC32 uses 32-bit family and port numbers internally, but they have been
sl@0
   293
left as shorts here for compatibility with code that uses htons()/ntohs() explicitly.
sl@0
   294
*/
sl@0
   295
struct sockaddr {
sl@0
   296
	u_short	sa_family;		/* address family */
sl@0
   297
	u_short sa_port;		/* port number - a common feature of most protocols */
sl@0
   298
	char	sa_data[24];		/* up to 24 bytes of direct address */
sl@0
   299
      unsigned char	sa_len;	
sl@0
   300
};
sl@0
   301
#endif //__SYMBIAN32__
sl@0
   302
sl@0
   303
#if __BSD_VISIBLE
sl@0
   304
#define	SOCK_MAXADDRLEN	255		/* longest possible addresses */
sl@0
   305
sl@0
   306
/*
sl@0
   307
 * Structure used by kernel to pass protocol
sl@0
   308
 * information in raw sockets.
sl@0
   309
 */
sl@0
   310
struct sockproto {
sl@0
   311
	unsigned short	sp_family;		/* address family */
sl@0
   312
	unsigned short	sp_protocol;		/* protocol */
sl@0
   313
};
sl@0
   314
#endif
sl@0
   315
sl@0
   316
/*
sl@0
   317
 * RFC 2553: protocol-independent placeholder for socket addresses
sl@0
   318
 */
sl@0
   319
#ifndef __SYMBIAN32__
sl@0
   320
#define	_SS_MAXSIZE	128U
sl@0
   321
#define	_SS_ALIGNSIZE	(sizeof(__int64_t))
sl@0
   322
#define	_SS_PAD1SIZE	(_SS_ALIGNSIZE - sizeof(unsigned char) - \
sl@0
   323
			    sizeof(sa_family_t))
sl@0
   324
#define	_SS_PAD2SIZE	(_SS_MAXSIZE - sizeof(unsigned char) - \
sl@0
   325
			    sizeof(sa_family_t) - _SS_PAD1SIZE - _SS_ALIGNSIZE)
sl@0
   326
sl@0
   327
struct sockaddr_storage {
sl@0
   328
	unsigned char	ss_len;		/* address length */
sl@0
   329
	sa_family_t	ss_family;	/* address family */
sl@0
   330
	char		__ss_pad1[_SS_PAD1SIZE];
sl@0
   331
	__int64_t	__ss_align;	/* force desired struct alignment */
sl@0
   332
	char		__ss_pad2[_SS_PAD2SIZE];
sl@0
   333
};
sl@0
   334
#else
sl@0
   335
#define _SS_MAXSIZE 128U
sl@0
   336
#define _SS_ALIGNSIZE   (sizeof(__int64_t))
sl@0
   337
#define _SS_PAD1SIZE    (_SS_ALIGNSIZE - sizeof(u_short))
sl@0
   338
#define _SS_PAD2SIZE    (_SS_MAXSIZE -  sizeof(u_short) - _SS_PAD1SIZE - _SS_ALIGNSIZE)
sl@0
   339
sl@0
   340
struct sockaddr_storage {
sl@0
   341
    u_short ss_family;  /* address family */
sl@0
   342
    char        __ss_pad1[_SS_PAD1SIZE];
sl@0
   343
    __int64_t   __ss_align; /* force desired struct alignment */
sl@0
   344
    char        __ss_pad2[_SS_PAD2SIZE];
sl@0
   345
};
sl@0
   346
#endif
sl@0
   347
#if __BSD_VISIBLE
sl@0
   348
/*
sl@0
   349
 * Protocol families, same as address families for now.
sl@0
   350
 */
sl@0
   351
#define	PF_UNSPEC	AF_UNSPEC
sl@0
   352
#define	PF_LOCAL	AF_LOCAL
sl@0
   353
#define	PF_UNIX		PF_LOCAL	/* backward compatibility */
sl@0
   354
#define	PF_INET		AF_INET
sl@0
   355
#define	PF_IMPLINK	AF_IMPLINK
sl@0
   356
#define	PF_PUP		AF_PUP
sl@0
   357
#define	PF_CHAOS	AF_CHAOS
sl@0
   358
#define	PF_NETBIOS	AF_NETBIOS
sl@0
   359
#define	PF_ISO		AF_ISO
sl@0
   360
#define	PF_OSI		AF_ISO
sl@0
   361
#define	PF_ECMA		AF_ECMA
sl@0
   362
#define	PF_DATAKIT	AF_DATAKIT
sl@0
   363
#define	PF_CCITT	AF_CCITT
sl@0
   364
#define	PF_SNA		AF_SNA
sl@0
   365
#define PF_DECnet	AF_DECnet
sl@0
   366
#define PF_DLI		AF_DLI
sl@0
   367
#define PF_LAT		AF_LAT
sl@0
   368
#define	PF_HYLINK	AF_HYLINK
sl@0
   369
#define	PF_APPLETALK	AF_APPLETALK
sl@0
   370
#define	PF_ROUTE	AF_ROUTE
sl@0
   371
#define	PF_LINK		AF_LINK
sl@0
   372
#define	PF_XTP		pseudo_AF_XTP	/* really just proto family, no AF */
sl@0
   373
#define	PF_COIP		AF_COIP
sl@0
   374
#define	PF_CNT		AF_CNT
sl@0
   375
#define	PF_SIP		AF_SIP
sl@0
   376
#define	PF_IPX		AF_IPX
sl@0
   377
#define PF_RTIP		pseudo_AF_RTIP	/* same format as AF_INET */
sl@0
   378
#define PF_PIP		pseudo_AF_PIP
sl@0
   379
#define	PF_ISDN		AF_ISDN
sl@0
   380
#define	PF_KEY		pseudo_AF_KEY
sl@0
   381
#define	PF_INET6	AF_INET6
sl@0
   382
#define	PF_NATM		AF_NATM
sl@0
   383
#define	PF_ATM		AF_ATM
sl@0
   384
#define	PF_NETGRAPH	AF_NETGRAPH
sl@0
   385
#define	PF_SLOW		AF_SLOW
sl@0
   386
#define PF_SCLUSTER	AF_SCLUSTER
sl@0
   387
#define	PF_ARP		AF_ARP
sl@0
   388
#define	PF_BLUETOOTH	AF_BLUETOOTH
sl@0
   389
sl@0
   390
#define	PF_MAX		AF_MAX
sl@0
   391
sl@0
   392
#ifdef __SYMBIAN32__
sl@0
   393
#define	PF_IRDA		AF_IRDA
sl@0
   394
#define PF_PLP		AF_PLP
sl@0
   395
#endif	// __SYMBIAN32__
sl@0
   396
/*
sl@0
   397
 * Definitions for network related sysctl, CTL_NET.
sl@0
   398
 *
sl@0
   399
 * Second level is protocol family.
sl@0
   400
 * Third level is protocol number.
sl@0
   401
 *
sl@0
   402
 * Further levels are defined by the individual families below.
sl@0
   403
 */
sl@0
   404
#define NET_MAXID	AF_MAX
sl@0
   405
sl@0
   406
#define CTL_NET_NAMES { \
sl@0
   407
	{ 0, 0 }, \
sl@0
   408
	{ "unix", CTLTYPE_NODE }, \
sl@0
   409
	{ "inet", CTLTYPE_NODE }, \
sl@0
   410
	{ "implink", CTLTYPE_NODE }, \
sl@0
   411
	{ "pup", CTLTYPE_NODE }, \
sl@0
   412
	{ "chaos", CTLTYPE_NODE }, \
sl@0
   413
	{ "xerox_ns", CTLTYPE_NODE }, \
sl@0
   414
	{ "iso", CTLTYPE_NODE }, \
sl@0
   415
	{ "emca", CTLTYPE_NODE }, \
sl@0
   416
	{ "datakit", CTLTYPE_NODE }, \
sl@0
   417
	{ "ccitt", CTLTYPE_NODE }, \
sl@0
   418
	{ "ibm_sna", CTLTYPE_NODE }, \
sl@0
   419
	{ "decnet", CTLTYPE_NODE }, \
sl@0
   420
	{ "dec_dli", CTLTYPE_NODE }, \
sl@0
   421
	{ "lat", CTLTYPE_NODE }, \
sl@0
   422
	{ "hylink", CTLTYPE_NODE }, \
sl@0
   423
	{ "appletalk", CTLTYPE_NODE }, \
sl@0
   424
	{ "route", CTLTYPE_NODE }, \
sl@0
   425
	{ "link_layer", CTLTYPE_NODE }, \
sl@0
   426
	{ "xtp", CTLTYPE_NODE }, \
sl@0
   427
	{ "coip", CTLTYPE_NODE }, \
sl@0
   428
	{ "cnt", CTLTYPE_NODE }, \
sl@0
   429
	{ "rtip", CTLTYPE_NODE }, \
sl@0
   430
	{ "ipx", CTLTYPE_NODE }, \
sl@0
   431
	{ "sip", CTLTYPE_NODE }, \
sl@0
   432
	{ "pip", CTLTYPE_NODE }, \
sl@0
   433
	{ "isdn", CTLTYPE_NODE }, \
sl@0
   434
	{ "key", CTLTYPE_NODE }, \
sl@0
   435
	{ "inet6", CTLTYPE_NODE }, \
sl@0
   436
	{ "natm", CTLTYPE_NODE }, \
sl@0
   437
	{ "atm", CTLTYPE_NODE }, \
sl@0
   438
	{ "hdrcomplete", CTLTYPE_NODE }, \
sl@0
   439
	{ "netgraph", CTLTYPE_NODE }, \
sl@0
   440
	{ "snp", CTLTYPE_NODE }, \
sl@0
   441
	{ "scp", CTLTYPE_NODE }, \
sl@0
   442
}
sl@0
   443
sl@0
   444
/*
sl@0
   445
 * PF_ROUTE - Routing table
sl@0
   446
 *
sl@0
   447
 * Three additional levels are defined:
sl@0
   448
 *	Fourth: address family, 0 is wildcard
sl@0
   449
 *	Fifth: type of info, defined below
sl@0
   450
 *	Sixth: flag(s) to mask with for NET_RT_FLAGS
sl@0
   451
 */
sl@0
   452
#define NET_RT_DUMP	1		/* dump; may limit to a.f. */
sl@0
   453
#define NET_RT_FLAGS	2		/* by flags, e.g. RESOLVING */
sl@0
   454
#define NET_RT_IFLIST	3		/* survey interface list */
sl@0
   455
#define	NET_RT_IFMALIST	4		/* return multicast address list */
sl@0
   456
#define	NET_RT_MAXID	5
sl@0
   457
sl@0
   458
#define CTL_NET_RT_NAMES { \
sl@0
   459
	{ 0, 0 }, \
sl@0
   460
	{ "dump", CTLTYPE_STRUCT }, \
sl@0
   461
	{ "flags", CTLTYPE_STRUCT }, \
sl@0
   462
	{ "iflist", CTLTYPE_STRUCT }, \
sl@0
   463
	{ "ifmalist", CTLTYPE_STRUCT }, \
sl@0
   464
}
sl@0
   465
#endif /* __BSD_VISIBLE */
sl@0
   466
sl@0
   467
/*
sl@0
   468
 * Maximum queue length specifiable by listen.
sl@0
   469
 */
sl@0
   470
#ifdef __SYMBIAN32__
sl@0
   471
#define	SOMAXCONN	5
sl@0
   472
#else
sl@0
   473
#define	SOMAXCONN	128
sl@0
   474
#endif	// __SYMBIAN32__
sl@0
   475
sl@0
   476
/*
sl@0
   477
 * Message header for recvmsg and sendmsg calls.
sl@0
   478
 * Used value-result for recvmsg, value only for sendmsg.
sl@0
   479
 */
sl@0
   480
struct msghdr {
sl@0
   481
	void		*msg_name;		/* optional address */
sl@0
   482
	socklen_t	 msg_namelen;		/* size of address */
sl@0
   483
	struct iovec	*msg_iov;		/* scatter/gather array */
sl@0
   484
	int		 msg_iovlen;		/* # elements in msg_iov */
sl@0
   485
	void		*msg_control;		/* ancillary data, see below */
sl@0
   486
	socklen_t	 msg_controllen;	/* ancillary data buffer len */
sl@0
   487
	int		 msg_flags;		/* flags on received message */
sl@0
   488
};
sl@0
   489
sl@0
   490
#define	MSG_OOB		0x1		/* process out-of-band data */
sl@0
   491
#define	MSG_PEEK	0x2		/* peek at incoming message */
sl@0
   492
#define	MSG_DONTROUTE	0x4		/* send without using routing tables */
sl@0
   493
#define	MSG_EOR		0x8		/* data completes record */
sl@0
   494
#define	MSG_TRUNC	0x10		/* data discarded before delivery */
sl@0
   495
#define	MSG_CTRUNC	0x20		/* control data lost before delivery */
sl@0
   496
#define	MSG_WAITALL	0x40		/* wait for full request or error */
sl@0
   497
#if __BSD_VISIBLE
sl@0
   498
#define	MSG_DONTWAIT	0x80		/* this message should be nonblocking */
sl@0
   499
#define	MSG_EOF		0x100		/* data completes connection */
sl@0
   500
#define	MSG_NBIO	0x4000		/* FIONBIO mode, used by fifofs */
sl@0
   501
#define	MSG_COMPAT      0x8000		/* used in sendit() */
sl@0
   502
#endif
sl@0
   503
#ifdef _KERNEL
sl@0
   504
#define	MSG_SOCALLBCK   0x10000		/* for use by socket callbacks - soreceive (TCP) */
sl@0
   505
#endif
sl@0
   506
#if __BSD_VISIBLE
sl@0
   507
#define	MSG_NOSIGNAL	0x20000		/* do not generate SIGPIPE on EOF */
sl@0
   508
#endif
sl@0
   509
sl@0
   510
/*
sl@0
   511
 * Header for ancillary data objects in msg_control buffer.
sl@0
   512
 * Used for additional information with/about a datagram
sl@0
   513
 * not expressible by flags.  The format is a sequence
sl@0
   514
 * of message elements headed by cmsghdr structures.
sl@0
   515
 */
sl@0
   516
struct cmsghdr {
sl@0
   517
	socklen_t	cmsg_len;		/* data byte count, including hdr */
sl@0
   518
	int		cmsg_level;		/* originating protocol */
sl@0
   519
	int		cmsg_type;		/* protocol-specific type */
sl@0
   520
/* followed by	u_char  cmsg_data[]; */
sl@0
   521
};
sl@0
   522
sl@0
   523
#if __BSD_VISIBLE
sl@0
   524
/*
sl@0
   525
 * While we may have more groups than this, the cmsgcred struct must
sl@0
   526
 * be able to fit in an mbuf, and NGROUPS_MAX is too large to allow
sl@0
   527
 * this.
sl@0
   528
*/
sl@0
   529
#define CMGROUP_MAX 16
sl@0
   530
sl@0
   531
/*
sl@0
   532
 * Credentials structure, used to verify the identity of a peer
sl@0
   533
 * process that has sent us a message. This is allocated by the
sl@0
   534
 * peer process but filled in by the kernel. This prevents the
sl@0
   535
 * peer from lying about its identity. (Note that cmcred_groups[0]
sl@0
   536
 * is the effective GID.)
sl@0
   537
 */
sl@0
   538
struct cmsgcred {
sl@0
   539
	pid_t	cmcred_pid;		/* PID of sending process */
sl@0
   540
	uid_t	cmcred_uid;		/* real UID of sending process */
sl@0
   541
	uid_t	cmcred_euid;		/* effective UID of sending process */
sl@0
   542
	gid_t	cmcred_gid;		/* real GID of sending process */
sl@0
   543
	short	cmcred_ngroups;		/* number or groups */
sl@0
   544
	gid_t	cmcred_groups[CMGROUP_MAX];	/* groups */
sl@0
   545
};
sl@0
   546
sl@0
   547
/*
sl@0
   548
 * Socket credentials.
sl@0
   549
 */
sl@0
   550
struct sockcred {
sl@0
   551
	uid_t	sc_uid;			/* real user id */
sl@0
   552
	uid_t	sc_euid;		/* effective user id */
sl@0
   553
	gid_t	sc_gid;			/* real group id */
sl@0
   554
	gid_t	sc_egid;		/* effective group id */
sl@0
   555
	int	sc_ngroups;		/* number of supplemental groups */
sl@0
   556
	gid_t	sc_groups[1];		/* variable length */
sl@0
   557
};
sl@0
   558
sl@0
   559
/*
sl@0
   560
 * Compute size of a sockcred structure with groups.
sl@0
   561
 */
sl@0
   562
#define	SOCKCREDSIZE(ngrps) \
sl@0
   563
	(sizeof(struct sockcred) + (sizeof(gid_t) * ((ngrps) - 1)))
sl@0
   564
sl@0
   565
#endif /* __BSD_VISIBLE */
sl@0
   566
sl@0
   567
/* given pointer to struct cmsghdr, return pointer to data */
sl@0
   568
#define	CMSG_DATA(cmsg)		((unsigned char *)(cmsg) + \
sl@0
   569
				 _ALIGN(sizeof(struct cmsghdr)))
sl@0
   570
sl@0
   571
/* given pointer to struct cmsghdr, return pointer to next cmsghdr */
sl@0
   572
#define	CMSG_NXTHDR(mhdr, cmsg)	\
sl@0
   573
	(((char *)(cmsg) + _ALIGN((cmsg)->cmsg_len) + \
sl@0
   574
	  _ALIGN(sizeof(struct cmsghdr)) > \
sl@0
   575
	    (char *)(mhdr)->msg_control + (mhdr)->msg_controllen) ? \
sl@0
   576
	    (struct cmsghdr *)0 : \
sl@0
   577
	    (struct cmsghdr *)((char *)(cmsg) + _ALIGN((cmsg)->cmsg_len)))
sl@0
   578
sl@0
   579
/*
sl@0
   580
 * RFC 2292 requires to check msg_controllen, in case that the kernel returns
sl@0
   581
 * an empty list for some reasons.
sl@0
   582
 */
sl@0
   583
#define	CMSG_FIRSTHDR(mhdr) \
sl@0
   584
	((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
sl@0
   585
	 (struct cmsghdr *)(mhdr)->msg_control : \
sl@0
   586
	 (struct cmsghdr *)NULL)
sl@0
   587
sl@0
   588
#if __BSD_VISIBLE
sl@0
   589
/* RFC 2292 additions */
sl@0
   590
#define	CMSG_SPACE(l)		(_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(l))
sl@0
   591
#define	CMSG_LEN(l)		(_ALIGN(sizeof(struct cmsghdr)) + (l))
sl@0
   592
#endif
sl@0
   593
sl@0
   594
#ifdef _KERNEL
sl@0
   595
#define	CMSG_ALIGN(n)	_ALIGN(n)
sl@0
   596
#endif
sl@0
   597
sl@0
   598
/* "Socket"-level control message types: */
sl@0
   599
#define	SCM_RIGHTS	0x01		/* access rights (array of int) */
sl@0
   600
#if __BSD_VISIBLE
sl@0
   601
#define	SCM_TIMESTAMP	0x02		/* timestamp (struct timeval) */
sl@0
   602
#define	SCM_CREDS	0x03		/* process creds (struct cmsgcred) */
sl@0
   603
#define	SCM_BINTIME	0x04		/* timestamp (struct bintime) */
sl@0
   604
#endif
sl@0
   605
sl@0
   606
#if __BSD_VISIBLE
sl@0
   607
/*
sl@0
   608
 * 4.3 compat sockaddr, move to compat file later
sl@0
   609
 */
sl@0
   610
struct osockaddr {
sl@0
   611
	unsigned short sa_family;	/* address family */
sl@0
   612
	char	sa_data[14];		/* up to 14 bytes of direct address */
sl@0
   613
};
sl@0
   614
sl@0
   615
/*
sl@0
   616
 * 4.3-compat message header (move to compat file later).
sl@0
   617
 */
sl@0
   618
struct omsghdr {
sl@0
   619
	char	*msg_name;		/* optional address */
sl@0
   620
	int	msg_namelen;		/* size of address */
sl@0
   621
	struct	iovec *msg_iov;		/* scatter/gather array */
sl@0
   622
	int	msg_iovlen;		/* # elements in msg_iov */
sl@0
   623
	char	*msg_accrights;		/* access rights sent/received */
sl@0
   624
	int	msg_accrightslen;
sl@0
   625
};
sl@0
   626
#endif
sl@0
   627
sl@0
   628
/*
sl@0
   629
 * howto arguments for shutdown(2), specified by Posix.1g.
sl@0
   630
 */
sl@0
   631
#define	SHUT_RD		0		/* shut down the reading side */
sl@0
   632
#define	SHUT_WR		1		/* shut down the writing side */
sl@0
   633
#define	SHUT_RDWR	2		/* shut down both sides */
sl@0
   634
sl@0
   635
#if __BSD_VISIBLE
sl@0
   636
/*
sl@0
   637
 * sendfile(2) header/trailer struct
sl@0
   638
 */
sl@0
   639
struct sf_hdtr {
sl@0
   640
	struct iovec *headers;	/* pointer to an array of header struct iovec's */
sl@0
   641
	int hdr_cnt;		/* number of header iovec's */
sl@0
   642
	struct iovec *trailers;	/* pointer to an array of trailer struct iovec's */
sl@0
   643
	int trl_cnt;		/* number of trailer iovec's */
sl@0
   644
};
sl@0
   645
sl@0
   646
/*
sl@0
   647
 * Sendfile-specific flag(s)
sl@0
   648
 */
sl@0
   649
#define        SF_NODISKIO     0x00000001
sl@0
   650
#endif
sl@0
   651
sl@0
   652
#ifndef	_KERNEL
sl@0
   653
sl@0
   654
#include <sys/cdefs.h>
sl@0
   655
sl@0
   656
__BEGIN_DECLS
sl@0
   657
IMPORT_C int	accept(int, struct sockaddr * __restrict, socklen_t * __restrict);
sl@0
   658
IMPORT_C int	bind(int, const struct sockaddr *, socklen_t);
sl@0
   659
IMPORT_C int	connect(int, const struct sockaddr *, socklen_t);
sl@0
   660
IMPORT_C int	getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict);
sl@0
   661
IMPORT_C int	getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict);
sl@0
   662
IMPORT_C int	getsockopt(int, int, int, void * __restrict, socklen_t * __restrict);
sl@0
   663
IMPORT_C int	listen(int, int);
sl@0
   664
IMPORT_C ssize_t	recv(int, void *, size_t, int);
sl@0
   665
IMPORT_C ssize_t	recvfrom(int, void *, size_t, int, struct sockaddr * __restrict, socklen_t * __restrict);
sl@0
   666
IMPORT_C ssize_t	recvmsg(int, struct msghdr *, int);
sl@0
   667
IMPORT_C ssize_t	send(int, const void *, size_t, int);
sl@0
   668
IMPORT_C ssize_t	sendto(int, const void *,
sl@0
   669
	    size_t, int, const struct sockaddr *, socklen_t);
sl@0
   670
IMPORT_C ssize_t	sendmsg(int, const struct msghdr *, int);
sl@0
   671
IMPORT_C int	setsockopt(int, int, int, const void *, socklen_t);
sl@0
   672
IMPORT_C int	shutdown(int, int);
sl@0
   673
IMPORT_C int	sockatmark(int);
sl@0
   674
IMPORT_C int	socket(int, int, int);
sl@0
   675
__END_DECLS
sl@0
   676
sl@0
   677
#endif /* !_KERNEL */
sl@0
   678
sl@0
   679
#endif /* !_SYS_SOCKET_H_ */