os/ossrv/genericopenlibs/openenvcore/include/netinet/in.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// © Portions copyright (c) 2006 Nokia Corporation.  All rights reserved.
sl@0
     2
sl@0
     3
/*-
sl@0
     4
 * Copyright (c) 1982, 1986, 1990, 1993
sl@0
     5
 *	The Regents of the University of California.  All rights reserved.
sl@0
     6
 *
sl@0
     7
 * Redistribution and use in source and binary forms, with or without
sl@0
     8
 * modification, are permitted provided that the following conditions
sl@0
     9
 * are met:
sl@0
    10
 * 1. Redistributions of source code must retain the above copyright
sl@0
    11
 *    notice, this list of conditions and the following disclaimer.
sl@0
    12
 * 2. Redistributions in binary form must reproduce the above copyright
sl@0
    13
 *    notice, this list of conditions and the following disclaimer in the
sl@0
    14
 *    documentation and/or other materials provided with the distribution.
sl@0
    15
 * 4. Neither the name of the University nor the names of its contributors
sl@0
    16
 *    may be used to endorse or promote products derived from this software
sl@0
    17
 *    without specific prior written permission.
sl@0
    18
 *
sl@0
    19
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
sl@0
    20
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
sl@0
    21
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
sl@0
    22
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
sl@0
    23
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
sl@0
    24
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
sl@0
    25
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
sl@0
    26
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
sl@0
    27
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
sl@0
    28
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
sl@0
    29
 * SUCH DAMAGE.
sl@0
    30
 *
sl@0
    31
 *	@(#)in.h	8.3 (Berkeley) 1/3/94
sl@0
    32
 * $FreeBSD: src/sys/netinet/in.h,v 1.90.2.3 2005/10/02 15:45:47 andre Exp $
sl@0
    33
 */
sl@0
    34
sl@0
    35
#ifndef _NETINET_IN_H_
sl@0
    36
#define	_NETINET_IN_H_
sl@0
    37
sl@0
    38
#include <sys/cdefs.h>
sl@0
    39
#include <sys/_types.h>
sl@0
    40
#include <stdapis/machine/endian.h>
sl@0
    41
sl@0
    42
/* Protocols common to RFC 1700, POSIX, and X/Open. */
sl@0
    43
#ifdef __SYMBIAN32__
sl@0
    44
#define	IPPROTO_IP		0x100	/* KProtocolInetIp */
sl@0
    45
#else
sl@0
    46
#define	IPPROTO_IP		0		/* dummy for IP */
sl@0
    47
#endif	// __SYMBIAN32__
sl@0
    48
#define	IPPROTO_ICMP		1		/* control message protocol KProtocolInetIcmp */
sl@0
    49
#define	IPPROTO_TCP		6		/* tcp  KProtocolInetTcp */
sl@0
    50
#define	IPPROTO_UDP		17		/* user datagram protocol KProtocolInetUdp */
sl@0
    51
sl@0
    52
#define	INADDR_ANY		(u_int32_t)0x00000000
sl@0
    53
#define	INADDR_BROADCAST	(u_int32_t)0xffffffff	/* must be masked */
sl@0
    54
sl@0
    55
#ifndef _UINT8_T_DECLARED
sl@0
    56
typedef	__uint8_t		uint8_t;
sl@0
    57
#define	_UINT8_T_DECLARED
sl@0
    58
#endif
sl@0
    59
sl@0
    60
#ifndef _UINT16_T_DECLARED
sl@0
    61
typedef	__uint16_t		uint16_t;
sl@0
    62
#define	_UINT16_T_DECLARED
sl@0
    63
#endif
sl@0
    64
sl@0
    65
#ifndef _UINT32_T_DECLARED
sl@0
    66
typedef	__uint32_t		uint32_t;
sl@0
    67
#define	_UINT32_T_DECLARED
sl@0
    68
#endif
sl@0
    69
sl@0
    70
#ifndef _IN_ADDR_T_DECLARED
sl@0
    71
typedef	uint32_t		in_addr_t;
sl@0
    72
#define	_IN_ADDR_T_DECLARED
sl@0
    73
#endif
sl@0
    74
sl@0
    75
#ifndef _IN_PORT_T_DECLARED
sl@0
    76
typedef	uint16_t		in_port_t;
sl@0
    77
#define	_IN_PORT_T_DECLARED
sl@0
    78
#endif
sl@0
    79
sl@0
    80
#ifndef _SA_FAMILY_T_DECLARED
sl@0
    81
typedef	__sa_family_t		sa_family_t;
sl@0
    82
#define	_SA_FAMILY_T_DECLARED
sl@0
    83
#endif
sl@0
    84
sl@0
    85
/* Internet address (a structure for historical reasons). */
sl@0
    86
#ifndef	_STRUCT_IN_ADDR_DECLARED
sl@0
    87
struct in_addr {
sl@0
    88
	in_addr_t s_addr;
sl@0
    89
};
sl@0
    90
#define	_STRUCT_IN_ADDR_DECLARED
sl@0
    91
#endif
sl@0
    92
sl@0
    93
/* Socket address, internet style. */
sl@0
    94
#ifdef __SYMBIAN32__
sl@0
    95
struct sockaddr_in {
sl@0
    96
	u_short	sin_family;
sl@0
    97
	u_short	sin_port;
sl@0
    98
	struct	in_addr sin_addr;
sl@0
    99
	char	sin_zero[20];
sl@0
   100
};
sl@0
   101
#else
sl@0
   102
struct sockaddr_in {
sl@0
   103
	uint8_t	sin_len;
sl@0
   104
	sa_family_t	sin_family;
sl@0
   105
	in_port_t	sin_port;
sl@0
   106
	struct	in_addr sin_addr;
sl@0
   107
	char	sin_zero[8];
sl@0
   108
};
sl@0
   109
#endif	// __SYMBIAN32__
sl@0
   110
sl@0
   111
#ifdef __SYMBIAN32__
sl@0
   112
#define SOL_IP		0x100	/* options for IP level KSolInetIp */
sl@0
   113
#define SOL_TCP		0x106	/* options for TCP level KSolInetTcp */
sl@0
   114
sl@0
   115
/*
sl@0
   116
 * User-settable options (used with setsockopt).
sl@0
   117
 */
sl@0
   118
#define	TCP_NODELAY	0x304	/* don't delay send to coalesce packets KSoTcpNoDelay */
sl@0
   119
#define	TCP_MAXSEG	0x303	/* set maximum segment size KSoTcpMaxSegSize */
sl@0
   120
sl@0
   121
#endif //__SYMBIAN32__
sl@0
   122
sl@0
   123
#ifndef _KERNEL
sl@0
   124
sl@0
   125
#ifndef _BYTEORDER_PROTOTYPED
sl@0
   126
#define	_BYTEORDER_PROTOTYPED
sl@0
   127
__BEGIN_DECLS
sl@0
   128
IMPORT_C uint32_t	htonl(uint32_t);
sl@0
   129
IMPORT_C uint16_t	htons(uint16_t);
sl@0
   130
uint32_t	ntohl(uint32_t);
sl@0
   131
uint16_t	ntohs(uint16_t);
sl@0
   132
__END_DECLS
sl@0
   133
#endif
sl@0
   134
sl@0
   135
#ifndef _BYTEORDER_FUNC_DEFINED
sl@0
   136
#define	_BYTEORDER_FUNC_DEFINED
sl@0
   137
#define	htonl(x)	__htonl(x)
sl@0
   138
#define	htons(x)	__htons(x)
sl@0
   139
#define	ntohl(x)	__ntohl(x)
sl@0
   140
#define	ntohs(x)	__ntohs(x)
sl@0
   141
#endif
sl@0
   142
sl@0
   143
#endif /* !_KERNEL */
sl@0
   144
sl@0
   145
#if __POSIX_VISIBLE >= 200112
sl@0
   146
#define	IPPROTO_RAW		255		/* raw IP packet */
sl@0
   147
#define	INET_ADDRSTRLEN		16
sl@0
   148
#endif
sl@0
   149
sl@0
   150
#if __BSD_VISIBLE
sl@0
   151
/*
sl@0
   152
 * Constants and structures defined by the internet system,
sl@0
   153
 * Per RFC 790, September 1981, and numerous additions.
sl@0
   154
 */
sl@0
   155
sl@0
   156
/*
sl@0
   157
 * Protocols (RFC 1700)
sl@0
   158
 */
sl@0
   159
#define	IPPROTO_HOPOPTS		0		/* IP6 hop-by-hop options */
sl@0
   160
#define	IPPROTO_IGMP		2		/* group mgmt protocol */
sl@0
   161
#define	IPPROTO_GGP		3		/* gateway^2 (deprecated) */
sl@0
   162
#define	IPPROTO_IPV4		4		/* IPv4 encapsulation */
sl@0
   163
#define	IPPROTO_IPIP		IPPROTO_IPV4	/* for compatibility */
sl@0
   164
#define	IPPROTO_ST		7		/* Stream protocol II */
sl@0
   165
#define	IPPROTO_EGP		8		/* exterior gateway protocol */
sl@0
   166
#define	IPPROTO_PIGP		9		/* private interior gateway */
sl@0
   167
#define	IPPROTO_RCCMON		10		/* BBN RCC Monitoring */
sl@0
   168
#define	IPPROTO_NVPII		11		/* network voice protocol*/
sl@0
   169
#define	IPPROTO_PUP		12		/* pup */
sl@0
   170
#define	IPPROTO_ARGUS		13		/* Argus */
sl@0
   171
#define	IPPROTO_EMCON		14		/* EMCON */
sl@0
   172
#define	IPPROTO_XNET		15		/* Cross Net Debugger */
sl@0
   173
#define	IPPROTO_CHAOS		16		/* Chaos*/
sl@0
   174
#define	IPPROTO_MUX		18		/* Multiplexing */
sl@0
   175
#define	IPPROTO_MEAS		19		/* DCN Measurement Subsystems */
sl@0
   176
#define	IPPROTO_HMP		20		/* Host Monitoring */
sl@0
   177
#define	IPPROTO_PRM		21		/* Packet Radio Measurement */
sl@0
   178
#define	IPPROTO_IDP		22		/* xns idp */
sl@0
   179
#define	IPPROTO_TRUNK1		23		/* Trunk-1 */
sl@0
   180
#define	IPPROTO_TRUNK2		24		/* Trunk-2 */
sl@0
   181
#define	IPPROTO_LEAF1		25		/* Leaf-1 */
sl@0
   182
#define	IPPROTO_LEAF2		26		/* Leaf-2 */
sl@0
   183
#define	IPPROTO_RDP		27		/* Reliable Data */
sl@0
   184
#define	IPPROTO_IRTP		28		/* Reliable Transaction */
sl@0
   185
#define	IPPROTO_TP		29		/* tp-4 w/ class negotiation */
sl@0
   186
#define	IPPROTO_BLT		30		/* Bulk Data Transfer */
sl@0
   187
#define	IPPROTO_NSP		31		/* Network Services */
sl@0
   188
#define	IPPROTO_INP		32		/* Merit Internodal */
sl@0
   189
#define	IPPROTO_SEP		33		/* Sequential Exchange */
sl@0
   190
#define	IPPROTO_3PC		34		/* Third Party Connect */
sl@0
   191
#define	IPPROTO_IDPR		35		/* InterDomain Policy Routing */
sl@0
   192
#define	IPPROTO_XTP		36		/* XTP */
sl@0
   193
#define	IPPROTO_DDP		37		/* Datagram Delivery */
sl@0
   194
#define	IPPROTO_CMTP		38		/* Control Message Transport */
sl@0
   195
#define	IPPROTO_TPXX		39		/* TP++ Transport */
sl@0
   196
#define	IPPROTO_IL		40		/* IL transport protocol */
sl@0
   197
#define	IPPROTO_IPV6		41		/* IP6 header */
sl@0
   198
#define	IPPROTO_SDRP		42		/* Source Demand Routing */
sl@0
   199
#define	IPPROTO_ROUTING		43		/* IP6 routing header */
sl@0
   200
#define	IPPROTO_FRAGMENT	44		/* IP6 fragmentation header */
sl@0
   201
#define	IPPROTO_IDRP		45		/* InterDomain Routing*/
sl@0
   202
#define	IPPROTO_RSVP		46		/* resource reservation */
sl@0
   203
#define	IPPROTO_GRE		47		/* General Routing Encap. */
sl@0
   204
#define	IPPROTO_MHRP		48		/* Mobile Host Routing */
sl@0
   205
#define	IPPROTO_BHA		49		/* BHA */
sl@0
   206
#define	IPPROTO_ESP		50		/* IP6 Encap Sec. Payload */
sl@0
   207
#define	IPPROTO_AH		51		/* IP6 Auth Header */
sl@0
   208
#define	IPPROTO_INLSP		52		/* Integ. Net Layer Security */
sl@0
   209
#define	IPPROTO_SWIPE		53		/* IP with encryption */
sl@0
   210
#define	IPPROTO_NHRP		54		/* Next Hop Resolution */
sl@0
   211
#define	IPPROTO_MOBILE		55		/* IP Mobility */
sl@0
   212
#define	IPPROTO_TLSP		56		/* Transport Layer Security */
sl@0
   213
#define	IPPROTO_SKIP		57		/* SKIP */
sl@0
   214
#define	IPPROTO_ICMPV6		58		/* ICMP6 */
sl@0
   215
#define	IPPROTO_NONE		59		/* IP6 no next header */
sl@0
   216
#define	IPPROTO_DSTOPTS		60		/* IP6 destination option */
sl@0
   217
#define	IPPROTO_AHIP		61		/* any host internal protocol */
sl@0
   218
#define	IPPROTO_CFTP		62		/* CFTP */
sl@0
   219
#define	IPPROTO_HELLO		63		/* "hello" routing protocol */
sl@0
   220
#define	IPPROTO_SATEXPAK	64		/* SATNET/Backroom EXPAK */
sl@0
   221
#define	IPPROTO_KRYPTOLAN	65		/* Kryptolan */
sl@0
   222
#define	IPPROTO_RVD		66		/* Remote Virtual Disk */
sl@0
   223
#define	IPPROTO_IPPC		67		/* Pluribus Packet Core */
sl@0
   224
#define	IPPROTO_ADFS		68		/* Any distributed FS */
sl@0
   225
#define	IPPROTO_SATMON		69		/* Satnet Monitoring */
sl@0
   226
#define	IPPROTO_VISA		70		/* VISA Protocol */
sl@0
   227
#define	IPPROTO_IPCV		71		/* Packet Core Utility */
sl@0
   228
#define	IPPROTO_CPNX		72		/* Comp. Prot. Net. Executive */
sl@0
   229
#define	IPPROTO_CPHB		73		/* Comp. Prot. HeartBeat */
sl@0
   230
#define	IPPROTO_WSN		74		/* Wang Span Network */
sl@0
   231
#define	IPPROTO_PVP		75		/* Packet Video Protocol */
sl@0
   232
#define	IPPROTO_BRSATMON	76		/* BackRoom SATNET Monitoring */
sl@0
   233
#define	IPPROTO_ND		77		/* Sun net disk proto (temp.) */
sl@0
   234
#define	IPPROTO_WBMON		78		/* WIDEBAND Monitoring */
sl@0
   235
#define	IPPROTO_WBEXPAK		79		/* WIDEBAND EXPAK */
sl@0
   236
#define	IPPROTO_EON		80		/* ISO cnlp */
sl@0
   237
#define	IPPROTO_VMTP		81		/* VMTP */
sl@0
   238
#define	IPPROTO_SVMTP		82		/* Secure VMTP */
sl@0
   239
#define	IPPROTO_VINES		83		/* Banyon VINES */
sl@0
   240
#define	IPPROTO_TTP		84		/* TTP */
sl@0
   241
#define	IPPROTO_IGP		85		/* NSFNET-IGP */
sl@0
   242
#define	IPPROTO_DGP		86		/* dissimilar gateway prot. */
sl@0
   243
#define	IPPROTO_TCF		87		/* TCF */
sl@0
   244
#define	IPPROTO_IGRP		88		/* Cisco/GXS IGRP */
sl@0
   245
#define	IPPROTO_OSPFIGP		89		/* OSPFIGP */
sl@0
   246
#define	IPPROTO_SRPC		90		/* Strite RPC protocol */
sl@0
   247
#define	IPPROTO_LARP		91		/* Locus Address Resoloution */
sl@0
   248
#define	IPPROTO_MTP		92		/* Multicast Transport */
sl@0
   249
#define	IPPROTO_AX25		93		/* AX.25 Frames */
sl@0
   250
#define	IPPROTO_IPEIP		94		/* IP encapsulated in IP */
sl@0
   251
#define	IPPROTO_MICP		95		/* Mobile Int.ing control */
sl@0
   252
#define	IPPROTO_SCCSP		96		/* Semaphore Comm. security */
sl@0
   253
#define	IPPROTO_ETHERIP		97		/* Ethernet IP encapsulation */
sl@0
   254
#ifdef __SYMBIAN32__
sl@0
   255
#define	IPPROTO_ENCAP		4		/* IP in IP encapsulation */
sl@0
   256
#else
sl@0
   257
#define	IPPROTO_ENCAP		98		/* encapsulation header */
sl@0
   258
#endif	// __SYMBIAN32__
sl@0
   259
#define	IPPROTO_APES		99		/* any private encr. scheme */
sl@0
   260
#define	IPPROTO_GMTP		100		/* GMTP*/
sl@0
   261
#define	IPPROTO_IPCOMP		108		/* payload compression (IPComp) */
sl@0
   262
/* 101-254: Partly Unassigned */
sl@0
   263
#define	IPPROTO_PIM		103		/* Protocol Independent Mcast */
sl@0
   264
#define	IPPROTO_CARP		112		/* CARP */
sl@0
   265
#define	IPPROTO_PGM		113		/* PGM */
sl@0
   266
#define	IPPROTO_PFSYNC		240		/* PFSYNC */
sl@0
   267
/* 255: Reserved */
sl@0
   268
/* BSD Private, local use, namespace incursion, no longer used */
sl@0
   269
#define	IPPROTO_OLD_DIVERT	254		/* OLD divert pseudo-proto */
sl@0
   270
#ifdef __SYMBIAN32__
sl@0
   271
#define	IPPROTO_MAX		0x101
sl@0
   272
#else
sl@0
   273
#define	IPPROTO_MAX		256
sl@0
   274
#endif	// __SYMBIAN32__
sl@0
   275
sl@0
   276
/* last return value of *_input(), meaning "all job for this pkt is done".  */
sl@0
   277
#define	IPPROTO_DONE		257
sl@0
   278
sl@0
   279
/* Only used internally, so can be outside the range of valid IP protocols. */
sl@0
   280
#define	IPPROTO_DIVERT		258		/* divert pseudo-protocol */
sl@0
   281
sl@0
   282
/*
sl@0
   283
 * Defined to avoid confusion.  The master value is defined by
sl@0
   284
 * PROTO_SPACER in sys/protosw.h.
sl@0
   285
 */
sl@0
   286
#define	IPPROTO_SPACER		32767		/* spacer for loadable protos */
sl@0
   287
sl@0
   288
/*
sl@0
   289
 * Local port number conventions:
sl@0
   290
 *
sl@0
   291
 * When a user does a bind(2) or connect(2) with a port number of zero,
sl@0
   292
 * a non-conflicting local port address is chosen.
sl@0
   293
 * The default range is IPPORT_HIFIRSTAUTO through
sl@0
   294
 * IPPORT_HILASTAUTO, although that is settable by sysctl.
sl@0
   295
 *
sl@0
   296
 * A user may set the IPPROTO_IP option IP_PORTRANGE to change this
sl@0
   297
 * default assignment range.
sl@0
   298
 *
sl@0
   299
 * The value IP_PORTRANGE_DEFAULT causes the default behavior.
sl@0
   300
 *
sl@0
   301
 * The value IP_PORTRANGE_HIGH changes the range of candidate port numbers
sl@0
   302
 * into the "high" range.  These are reserved for client outbound connections
sl@0
   303
 * which do not want to be filtered by any firewalls.  Note that by default
sl@0
   304
 * this is the same as IP_PORTRANGE_DEFAULT.
sl@0
   305
 *
sl@0
   306
 * The value IP_PORTRANGE_LOW changes the range to the "low" are
sl@0
   307
 * that is (by convention) restricted to privileged processes.  This
sl@0
   308
 * convention is based on "vouchsafe" principles only.  It is only secure
sl@0
   309
 * if you trust the remote host to restrict these ports.
sl@0
   310
 *
sl@0
   311
 * The default range of ports and the high range can be changed by
sl@0
   312
 * sysctl(3).  (net.inet.ip.port{hi,low}{first,last}_auto)
sl@0
   313
 *
sl@0
   314
 * Changing those values has bad security implications if you are
sl@0
   315
 * using a stateless firewall that is allowing packets outside of that
sl@0
   316
 * range in order to allow transparent outgoing connections.
sl@0
   317
 *
sl@0
   318
 * Such a firewall configuration will generally depend on the use of these
sl@0
   319
 * default values.  If you change them, you may find your Security
sl@0
   320
 * Administrator looking for you with a heavy object.
sl@0
   321
 *
sl@0
   322
 * For a slightly more orthodox text view on this:
sl@0
   323
 *
sl@0
   324
 *            ftp://ftp.isi.edu/in-notes/iana/assignments/port-numbers
sl@0
   325
 *
sl@0
   326
 *    port numbers are divided into three ranges:
sl@0
   327
 *
sl@0
   328
 *                0 -  1023 Well Known Ports
sl@0
   329
 *             1024 - 49151 Registered Ports
sl@0
   330
 *            49152 - 65535 Dynamic and/or Private Ports
sl@0
   331
 *
sl@0
   332
 */
sl@0
   333
sl@0
   334
/*
sl@0
   335
 * Ports < IPPORT_RESERVED are reserved for
sl@0
   336
 * privileged processes (e.g. root).         (IP_PORTRANGE_LOW)
sl@0
   337
 */
sl@0
   338
#define	IPPORT_RESERVED		1024
sl@0
   339
sl@0
   340
/*
sl@0
   341
 * Default local port range, used by both IP_PORTRANGE_DEFAULT
sl@0
   342
 * and IP_PORTRANGE_HIGH.
sl@0
   343
 */
sl@0
   344
#define	IPPORT_HIFIRSTAUTO	49152
sl@0
   345
#define	IPPORT_HILASTAUTO	65535
sl@0
   346
sl@0
   347
/*
sl@0
   348
 * Scanning for a free reserved port return a value below IPPORT_RESERVED,
sl@0
   349
 * but higher than IPPORT_RESERVEDSTART.  Traditionally the start value was
sl@0
   350
 * 512, but that conflicts with some well-known-services that firewalls may
sl@0
   351
 * have a fit if we use.
sl@0
   352
 */
sl@0
   353
#define	IPPORT_RESERVEDSTART	600
sl@0
   354
sl@0
   355
#define	IPPORT_MAX		65535
sl@0
   356
sl@0
   357
/*
sl@0
   358
 * Definitions of bits in internet address integers.
sl@0
   359
 * On subnets, the decomposition of addresses to host and net parts
sl@0
   360
 * is done according to subnet mask, not the masks here.
sl@0
   361
 */
sl@0
   362
#define	IN_CLASSA(i)		(((u_int32_t)(i) & 0x80000000) == 0)
sl@0
   363
#define	IN_CLASSA_NET		0xff000000
sl@0
   364
#define	IN_CLASSA_NSHIFT	24
sl@0
   365
#define	IN_CLASSA_HOST		0x00ffffff
sl@0
   366
#define	IN_CLASSA_MAX		128
sl@0
   367
sl@0
   368
#define	IN_CLASSB(i)		(((u_int32_t)(i) & 0xc0000000) == 0x80000000)
sl@0
   369
#define	IN_CLASSB_NET		0xffff0000
sl@0
   370
#define	IN_CLASSB_NSHIFT	16
sl@0
   371
#define	IN_CLASSB_HOST		0x0000ffff
sl@0
   372
#define	IN_CLASSB_MAX		65536
sl@0
   373
sl@0
   374
#define	IN_CLASSC(i)		(((u_int32_t)(i) & 0xe0000000) == 0xc0000000)
sl@0
   375
#define	IN_CLASSC_NET		0xffffff00
sl@0
   376
#define	IN_CLASSC_NSHIFT	8
sl@0
   377
#define	IN_CLASSC_HOST		0x000000ff
sl@0
   378
sl@0
   379
#define	IN_CLASSD(i)		(((u_int32_t)(i) & 0xf0000000) == 0xe0000000)
sl@0
   380
#define	IN_CLASSD_NET		0xf0000000	/* These ones aren't really */
sl@0
   381
#define	IN_CLASSD_NSHIFT	28		/* net and host fields, but */
sl@0
   382
#define	IN_CLASSD_HOST		0x0fffffff	/* routing needn't know.    */
sl@0
   383
#define	IN_MULTICAST(i)		IN_CLASSD(i)
sl@0
   384
sl@0
   385
#define	IN_EXPERIMENTAL(i)	(((u_int32_t)(i) & 0xf0000000) == 0xf0000000)
sl@0
   386
#define	IN_BADCLASS(i)		(((u_int32_t)(i) & 0xf0000000) == 0xf0000000)
sl@0
   387
sl@0
   388
#define	INADDR_LOOPBACK		(u_int32_t)0x7f000001
sl@0
   389
#ifndef _KERNEL
sl@0
   390
#define	INADDR_NONE		0xffffffff		/* -1 return */
sl@0
   391
#endif
sl@0
   392
sl@0
   393
#define	INADDR_UNSPEC_GROUP	(u_int32_t)0xe0000000	/* 224.0.0.0 */
sl@0
   394
#define	INADDR_ALLHOSTS_GROUP	(u_int32_t)0xe0000001	/* 224.0.0.1 */
sl@0
   395
#define	INADDR_ALLRTRS_GROUP	(u_int32_t)0xe0000002	/* 224.0.0.2 */
sl@0
   396
#define	INADDR_CARP_GROUP	(u_int32_t)0xe0000012	/* 224.0.0.18 */
sl@0
   397
#define	INADDR_PFSYNC_GROUP	(u_int32_t)0xe00000f0	/* 224.0.0.240 */
sl@0
   398
#define	INADDR_ALLMDNS_GROUP	(u_int32_t)0xe00000fb	/* 224.0.0.251 */
sl@0
   399
#define	INADDR_MAX_LOCAL_GROUP	(u_int32_t)0xe00000ff	/* 224.0.0.255 */
sl@0
   400
sl@0
   401
#define	IN_LOOPBACKNET		127			/* official! */
sl@0
   402
sl@0
   403
/*
sl@0
   404
 * Options for use with [gs]etsockopt at the IP level.
sl@0
   405
 * First word of comment is data type; bool is stored in int.
sl@0
   406
 */
sl@0
   407
#ifdef __SYMBIAN32__
sl@0
   408
#define	IP_OPTIONS		0x306   /* buf/ip_opts; set/get IP options */
sl@0
   409
#else
sl@0
   410
#define	IP_OPTIONS		1		/* buf/ip_opts; set/get IP options */
sl@0
   411
#endif	// __SYMBIAN32__
sl@0
   412
#ifdef __SYMBIAN32__
sl@0
   413
#define	IP_HDRINCL		0x308	/* int; header is included with data */
sl@0
   414
#else
sl@0
   415
#define	IP_HDRINCL		2		/* int; header is included with data */
sl@0
   416
#endif	// __SYMBIAN32__
sl@0
   417
#ifdef __SYMBIAN32__
sl@0
   418
#define	IP_TOS			0x309	/* int; IP type of service and preced. */
sl@0
   419
#else
sl@0
   420
#define	IP_TOS			3		/* int; IP type of service and preced. */
sl@0
   421
#endif	// __SYMBIAN32__
sl@0
   422
#ifdef __SYMBIAN32__
sl@0
   423
#define	IP_TTL			0x310	/* int; IP time to live */
sl@0
   424
#else
sl@0
   425
#define	IP_TTL			4    /* int; IP time to live */
sl@0
   426
#endif	// __SYMBIAN32__
sl@0
   427
#ifdef __SYMBIAN32__
sl@0
   428
#define	IP_RECVOPTS		-1    /* bool; receive all IP opts w/dgram */
sl@0
   429
#else
sl@0
   430
#define	IP_RECVOPTS		5    /* bool; receive all IP opts w/dgram */
sl@0
   431
#endif
sl@0
   432
#ifdef __SYMBIAN32__
sl@0
   433
#define	IP_RECVRETOPTS		-2    /* bool; receive IP opts for response */
sl@0
   434
#else
sl@0
   435
#define	IP_RECVRETOPTS		6    /* bool; receive IP opts for response */
sl@0
   436
#endif
sl@0
   437
#ifdef __SYMBIAN32__
sl@0
   438
#define	IP_RECVDSTADDR		-3    /* bool; receive IP dst addr w/dgram */
sl@0
   439
#else
sl@0
   440
#define	IP_RECVDSTADDR		7    /* bool; receive IP dst addr w/dgram */
sl@0
   441
#endif
sl@0
   442
#define	IP_SENDSRCADDR		IP_RECVDSTADDR /* cmsg_type to set src addr */
sl@0
   443
#ifdef __SYMBIAN32__
sl@0
   444
#define	IP_RETOPTS		-4    /* ip_opts; set/get IP options */
sl@0
   445
#else
sl@0
   446
#define	IP_RETOPTS		8    /* ip_opts; set/get IP options */
sl@0
   447
#endif	// __SYMBIAN32__
sl@0
   448
#ifdef __SYMBIAN32__
sl@0
   449
#define	IP_MULTICAST_IF		-5	/* set/get IP multicast interface  */
sl@0
   450
#else
sl@0
   451
#define	IP_MULTICAST_IF		9    /* u_char; set/get IP multicast i/f  */
sl@0
   452
#endif	// __SYMBIAN32__
sl@0
   453
#ifdef __SYMBIAN32__
sl@0
   454
#define	IP_MULTICAST_TTL	-6	/* set/get IP multicast timetolive */
sl@0
   455
#else
sl@0
   456
#define	IP_MULTICAST_TTL	10   /* u_char; set/get IP multicast ttl */
sl@0
   457
#endif	// __SYMBIAN32__
sl@0
   458
#ifdef __SYMBIAN32__
sl@0
   459
#define	IP_MULTICAST_LOOP	-7   /* u_char; set/get IP multicast loopback */
sl@0
   460
#else
sl@0
   461
#define	IP_MULTICAST_LOOP	11   /* u_char; set/get IP multicast loopback */
sl@0
   462
#endif	// __SYMBIAN32__
sl@0
   463
#ifdef __SYMBIAN32__
sl@0
   464
#define	IP_ADD_MEMBERSHIP	0x46d   /* ip_mreq; add an IP group membership */
sl@0
   465
#else
sl@0
   466
#define	IP_ADD_MEMBERSHIP	12   /* ip_mreq; add an IP group membership */
sl@0
   467
#endif	// __SYMBIAN32__
sl@0
   468
#ifdef __SYMBIAN32__
sl@0
   469
#define	IP_DROP_MEMBERSHIP	0x46e   /* ip_mreq; drop an IP group membership */
sl@0
   470
#else
sl@0
   471
#define	IP_DROP_MEMBERSHIP	13   /* ip_mreq; drop an IP group membership */
sl@0
   472
#endif	// __SYMBIAN32__
sl@0
   473
#define	IP_MULTICAST_VIF	14   /* set/get IP mcast virt. iface */
sl@0
   474
#define	IP_RSVP_ON		15   /* enable RSVP in kernel */
sl@0
   475
#define	IP_RSVP_OFF		16   /* disable RSVP in kernel */
sl@0
   476
#define	IP_RSVP_VIF_ON		17   /* set RSVP per-vif socket */
sl@0
   477
#define	IP_RSVP_VIF_OFF		18   /* unset RSVP per-vif socket */
sl@0
   478
#define	IP_PORTRANGE		19   /* int; range to choose for unspec port */
sl@0
   479
#define	IP_RECVIF		20   /* bool; receive reception if w/dgram */
sl@0
   480
/* for IPSEC */
sl@0
   481
#define	IP_IPSEC_POLICY		21   /* int; set/get security policy */
sl@0
   482
#define	IP_FAITH		22   /* bool; accept FAITH'ed connections */
sl@0
   483
sl@0
   484
#define	IP_ONESBCAST		23   /* bool: send all-ones broadcast */
sl@0
   485
sl@0
   486
#define	IP_FW_TABLE_ADD		40   /* add entry */
sl@0
   487
#define	IP_FW_TABLE_DEL		41   /* delete entry */
sl@0
   488
#define	IP_FW_TABLE_FLUSH	42   /* flush table */
sl@0
   489
#define	IP_FW_TABLE_GETSIZE	43   /* get table size */
sl@0
   490
#define	IP_FW_TABLE_LIST	44   /* list table contents */
sl@0
   491
sl@0
   492
#define	IP_FW_ADD		50   /* add a firewall rule to chain */
sl@0
   493
#define	IP_FW_DEL		51   /* delete a firewall rule from chain */
sl@0
   494
#define	IP_FW_FLUSH		52   /* flush firewall rule chain */
sl@0
   495
#define	IP_FW_ZERO		53   /* clear single/all firewall counter(s) */
sl@0
   496
#define	IP_FW_GET		54   /* get entire firewall rule chain */
sl@0
   497
#define	IP_FW_RESETLOG		55   /* reset logging counters */
sl@0
   498
sl@0
   499
#define	IP_DUMMYNET_CONFIGURE	60   /* add/configure a dummynet pipe */
sl@0
   500
#define	IP_DUMMYNET_DEL		61   /* delete a dummynet pipe from chain */
sl@0
   501
#define	IP_DUMMYNET_FLUSH	62   /* flush dummynet */
sl@0
   502
#define	IP_DUMMYNET_GET		64   /* get entire dummynet pipes */
sl@0
   503
sl@0
   504
#define	IP_RECVTTL		65   /* bool; receive IP TTL w/dgram */
sl@0
   505
#define	IP_MINTTL		66   /* minimum TTL for packet or drop */
sl@0
   506
#define	IP_DONTFRAG		67   /* don't fragment packet */
sl@0
   507
sl@0
   508
/*
sl@0
   509
 * Defaults and limits for options
sl@0
   510
 */
sl@0
   511
#define	IP_DEFAULT_MULTICAST_TTL  1	/* normally limit m'casts to 1 hop  */
sl@0
   512
#define	IP_DEFAULT_MULTICAST_LOOP 1	/* normally hear sends if a member  */
sl@0
   513
#define	IP_MAX_MEMBERSHIPS	20	/* per socket */
sl@0
   514
sl@0
   515
/*
sl@0
   516
 * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
sl@0
   517
 */
sl@0
   518
struct ip_mreq {
sl@0
   519
	struct	in_addr imr_multiaddr;	/* IP multicast address of group */
sl@0
   520
	struct	in_addr imr_interface;	/* local IP address of interface */
sl@0
   521
};
sl@0
   522
sl@0
   523
/*
sl@0
   524
 * Argument for IP_PORTRANGE:
sl@0
   525
 * - which range to search when port is unspecified at bind() or connect()
sl@0
   526
 */
sl@0
   527
#define	IP_PORTRANGE_DEFAULT	0	/* default range */
sl@0
   528
#define	IP_PORTRANGE_HIGH	1	/* "high" - request firewall bypass */
sl@0
   529
#define	IP_PORTRANGE_LOW	2	/* "low" - vouchsafe security */
sl@0
   530
sl@0
   531
/*
sl@0
   532
 * Definitions for inet sysctl operations.
sl@0
   533
 *
sl@0
   534
 * Third level is protocol number.
sl@0
   535
 * Fourth level is desired variable within that protocol.
sl@0
   536
 */
sl@0
   537
#define	IPPROTO_MAXID	(IPPROTO_AH + 1)	/* don't list to IPPROTO_MAX */
sl@0
   538
sl@0
   539
#define	CTL_IPPROTO_NAMES { \
sl@0
   540
	{ "ip", CTLTYPE_NODE }, \
sl@0
   541
	{ "icmp", CTLTYPE_NODE }, \
sl@0
   542
	{ "igmp", CTLTYPE_NODE }, \
sl@0
   543
	{ "ggp", CTLTYPE_NODE }, \
sl@0
   544
	{ 0, 0 }, \
sl@0
   545
	{ 0, 0 }, \
sl@0
   546
	{ "tcp", CTLTYPE_NODE }, \
sl@0
   547
	{ 0, 0 }, \
sl@0
   548
	{ "egp", CTLTYPE_NODE }, \
sl@0
   549
	{ 0, 0 }, \
sl@0
   550
	{ 0, 0 }, \
sl@0
   551
	{ 0, 0 }, \
sl@0
   552
	{ "pup", CTLTYPE_NODE }, \
sl@0
   553
	{ 0, 0 }, \
sl@0
   554
	{ 0, 0 }, \
sl@0
   555
	{ 0, 0 }, \
sl@0
   556
	{ 0, 0 }, \
sl@0
   557
	{ "udp", CTLTYPE_NODE }, \
sl@0
   558
	{ 0, 0 }, \
sl@0
   559
	{ 0, 0 }, \
sl@0
   560
	{ 0, 0 }, \
sl@0
   561
	{ 0, 0 }, \
sl@0
   562
	{ "idp", CTLTYPE_NODE }, \
sl@0
   563
	{ 0, 0 }, \
sl@0
   564
	{ 0, 0 }, \
sl@0
   565
	{ 0, 0 }, \
sl@0
   566
	{ 0, 0 }, \
sl@0
   567
	{ 0, 0 }, \
sl@0
   568
	{ 0, 0 }, \
sl@0
   569
	{ 0, 0 }, \
sl@0
   570
	{ 0, 0 }, \
sl@0
   571
	{ 0, 0 }, \
sl@0
   572
	{ 0, 0 }, \
sl@0
   573
	{ 0, 0 }, \
sl@0
   574
	{ 0, 0 }, \
sl@0
   575
	{ 0, 0 }, \
sl@0
   576
	{ 0, 0 }, \
sl@0
   577
	{ 0, 0 }, \
sl@0
   578
	{ 0, 0 }, \
sl@0
   579
	{ 0, 0 }, \
sl@0
   580
	{ 0, 0 }, \
sl@0
   581
	{ 0, 0 }, \
sl@0
   582
	{ 0, 0 }, \
sl@0
   583
	{ 0, 0 }, \
sl@0
   584
	{ 0, 0 }, \
sl@0
   585
	{ 0, 0 }, \
sl@0
   586
	{ 0, 0 }, \
sl@0
   587
	{ 0, 0 }, \
sl@0
   588
	{ 0, 0 }, \
sl@0
   589
	{ 0, 0 }, \
sl@0
   590
	{ 0, 0 }, \
sl@0
   591
	{ "ipsec", CTLTYPE_NODE }, \
sl@0
   592
	{ 0, 0 }, \
sl@0
   593
	{ 0, 0 }, \
sl@0
   594
	{ 0, 0 }, \
sl@0
   595
	{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
sl@0
   596
	{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
sl@0
   597
	{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
sl@0
   598
	{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
sl@0
   599
	{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
sl@0
   600
	{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
sl@0
   601
	{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
sl@0
   602
	{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
sl@0
   603
	{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
sl@0
   604
	{ 0, 0 }, \
sl@0
   605
	{ 0, 0 }, \
sl@0
   606
	{ 0, 0 }, \
sl@0
   607
	{ "pim", CTLTYPE_NODE }, \
sl@0
   608
}
sl@0
   609
sl@0
   610
/*
sl@0
   611
 * Names for IP sysctl objects
sl@0
   612
 */
sl@0
   613
#define	IPCTL_FORWARDING	1	/* act as router */
sl@0
   614
#define	IPCTL_SENDREDIRECTS	2	/* may send redirects when forwarding */
sl@0
   615
#define	IPCTL_DEFTTL		3	/* default TTL */
sl@0
   616
#ifdef notyet
sl@0
   617
#define	IPCTL_DEFMTU		4	/* default MTU */
sl@0
   618
#endif
sl@0
   619
#define	IPCTL_RTEXPIRE		5	/* cloned route expiration time */
sl@0
   620
#define	IPCTL_RTMINEXPIRE	6	/* min value for expiration time */
sl@0
   621
#define	IPCTL_RTMAXCACHE	7	/* trigger level for dynamic expire */
sl@0
   622
#define	IPCTL_SOURCEROUTE	8	/* may perform source routes */
sl@0
   623
#define	IPCTL_DIRECTEDBROADCAST	9	/* may re-broadcast received packets */
sl@0
   624
#define	IPCTL_INTRQMAXLEN	10	/* max length of netisr queue */
sl@0
   625
#define	IPCTL_INTRQDROPS	11	/* number of netisr q drops */
sl@0
   626
#define	IPCTL_STATS		12	/* ipstat structure */
sl@0
   627
#define	IPCTL_ACCEPTSOURCEROUTE	13	/* may accept source routed packets */
sl@0
   628
#define	IPCTL_FASTFORWARDING	14	/* use fast IP forwarding code */
sl@0
   629
#define	IPCTL_KEEPFAITH		15	/* FAITH IPv4->IPv6 translater ctl */
sl@0
   630
#define	IPCTL_GIF_TTL		16	/* default TTL for gif encap packet */
sl@0
   631
#define	IPCTL_MAXID		17
sl@0
   632
sl@0
   633
#define	IPCTL_NAMES { \
sl@0
   634
	{ 0, 0 }, \
sl@0
   635
	{ "forwarding", CTLTYPE_INT }, \
sl@0
   636
	{ "redirect", CTLTYPE_INT }, \
sl@0
   637
	{ "ttl", CTLTYPE_INT }, \
sl@0
   638
	{ "mtu", CTLTYPE_INT }, \
sl@0
   639
	{ "rtexpire", CTLTYPE_INT }, \
sl@0
   640
	{ "rtminexpire", CTLTYPE_INT }, \
sl@0
   641
	{ "rtmaxcache", CTLTYPE_INT }, \
sl@0
   642
	{ "sourceroute", CTLTYPE_INT }, \
sl@0
   643
	{ "directed-broadcast", CTLTYPE_INT }, \
sl@0
   644
	{ "intr-queue-maxlen", CTLTYPE_INT }, \
sl@0
   645
	{ "intr-queue-drops", CTLTYPE_INT }, \
sl@0
   646
	{ "stats", CTLTYPE_STRUCT }, \
sl@0
   647
	{ "accept_sourceroute", CTLTYPE_INT }, \
sl@0
   648
	{ "fastforwarding", CTLTYPE_INT }, \
sl@0
   649
}
sl@0
   650
sl@0
   651
#endif /* __BSD_VISIBLE */
sl@0
   652
sl@0
   653
#ifdef _KERNEL
sl@0
   654
sl@0
   655
struct ifnet; struct mbuf;	/* forward declarations for Standard C */
sl@0
   656
sl@0
   657
char	*inet_ntoa(struct in_addr); /* in libkern */
sl@0
   658
sl@0
   659
#define	in_hosteq(s, t)	((s).s_addr == (t).s_addr)
sl@0
   660
#define	in_nullhost(x)	((x).s_addr == INADDR_ANY)
sl@0
   661
sl@0
   662
#define	satosin(sa)	((struct sockaddr_in *)(sa))
sl@0
   663
#define	sintosa(sin)	((struct sockaddr *)(sin))
sl@0
   664
#define	ifatoia(ifa)	((struct in_ifaddr *)(ifa))
sl@0
   665
sl@0
   666
#endif /* _KERNEL */
sl@0
   667
sl@0
   668
/* INET6 stuff */
sl@0
   669
#if __POSIX_VISIBLE >= 200112
sl@0
   670
#define	__KAME_NETINET_IN_H_INCLUDED_
sl@0
   671
#include <stdapis/netinet6/in6.h>
sl@0
   672
#undef __KAME_NETINET_IN_H_INCLUDED_
sl@0
   673
#endif
sl@0
   674
sl@0
   675
#ifndef _KERNEL
sl@0
   676
sl@0
   677
__BEGIN_DECLS
sl@0
   678
IMPORT_C int bindresvport (int __sockfd, struct sockaddr_in *__sock_in);
sl@0
   679
__END_DECLS
sl@0
   680
sl@0
   681
#endif /* _KERNEL */
sl@0
   682
sl@0
   683
#endif /* !_NETINET_IN_H_*/