xref: /freebsd/sys/netinet/in.h (revision 58631bbe0e21c2320db31dfdd0bdd9ce4cd875a5)
1df8bae1dSRodney W. Grimes /*
2df8bae1dSRodney W. Grimes  * Copyright (c) 1982, 1986, 1990, 1993
3df8bae1dSRodney W. Grimes  *	The Regents of the University of California.  All rights reserved.
4df8bae1dSRodney W. Grimes  *
5df8bae1dSRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
6df8bae1dSRodney W. Grimes  * modification, are permitted provided that the following conditions
7df8bae1dSRodney W. Grimes  * are met:
8df8bae1dSRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
9df8bae1dSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
10df8bae1dSRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
11df8bae1dSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
12df8bae1dSRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
13df8bae1dSRodney W. Grimes  * 3. All advertising materials mentioning features or use of this software
14df8bae1dSRodney W. Grimes  *    must display the following acknowledgement:
15df8bae1dSRodney W. Grimes  *	This product includes software developed by the University of
16df8bae1dSRodney W. Grimes  *	California, Berkeley and its contributors.
17df8bae1dSRodney W. Grimes  * 4. Neither the name of the University nor the names of its contributors
18df8bae1dSRodney W. Grimes  *    may be used to endorse or promote products derived from this software
19df8bae1dSRodney W. Grimes  *    without specific prior written permission.
20df8bae1dSRodney W. Grimes  *
21df8bae1dSRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22df8bae1dSRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23df8bae1dSRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24df8bae1dSRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25df8bae1dSRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26df8bae1dSRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27df8bae1dSRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28df8bae1dSRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29df8bae1dSRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30df8bae1dSRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31df8bae1dSRodney W. Grimes  * SUCH DAMAGE.
32df8bae1dSRodney W. Grimes  *
33df8bae1dSRodney W. Grimes  *	@(#)in.h	8.3 (Berkeley) 1/3/94
34c3aac50fSPeter Wemm  * $FreeBSD$
35df8bae1dSRodney W. Grimes  */
36df8bae1dSRodney W. Grimes 
37707f139eSPaul Richards #ifndef _NETINET_IN_H_
38707f139eSPaul Richards #define _NETINET_IN_H_
39707f139eSPaul Richards 
4058631bbeSMike Barcroft #include <sys/cdefs.h>
418822d3fbSMike Barcroft #include <sys/_types.h>
4258631bbeSMike Barcroft #include <machine/endian.h>
438822d3fbSMike Barcroft 
4458631bbeSMike Barcroft /* Protocols common to RFC 1700, POSIX, and X/Open. */
4558631bbeSMike Barcroft #define	IPPROTO_IP		0		/* dummy for IP */
4658631bbeSMike Barcroft #define	IPPROTO_ICMP		1		/* control message protocol */
4758631bbeSMike Barcroft #define	IPPROTO_TCP		6		/* tcp */
4858631bbeSMike Barcroft #define	IPPROTO_UDP		17		/* user datagram protocol */
4958631bbeSMike Barcroft 
5058631bbeSMike Barcroft #define	INADDR_ANY		(u_int32_t)0x00000000
5158631bbeSMike Barcroft #define	INADDR_BROADCAST	(u_int32_t)0xffffffff	/* must be masked */
5258631bbeSMike Barcroft 
5358631bbeSMike Barcroft #ifndef _UINT8_T_DECLARED
5458631bbeSMike Barcroft typedef	__uint8_t		uint8_t;
5558631bbeSMike Barcroft #define	_UINT8_T_DECLARED
5658631bbeSMike Barcroft #endif
5758631bbeSMike Barcroft 
5858631bbeSMike Barcroft #ifndef _UINT16_T_DECLARED
5958631bbeSMike Barcroft typedef	__uint16_t		uint16_t;
6058631bbeSMike Barcroft #define	_UINT16_T_DECLARED
6158631bbeSMike Barcroft #endif
6258631bbeSMike Barcroft 
6358631bbeSMike Barcroft #ifndef _UINT32_T_DECLARED
6458631bbeSMike Barcroft typedef	__uint32_t		uint32_t;
6558631bbeSMike Barcroft #define	_UINT32_T_DECLARED
6658631bbeSMike Barcroft #endif
6758631bbeSMike Barcroft 
6858631bbeSMike Barcroft #ifndef _IN_ADDR_T_DECLARED
6958631bbeSMike Barcroft typedef	uint32_t		in_addr_t;
7058631bbeSMike Barcroft #define	_IN_ADDR_T_DECLARED
7158631bbeSMike Barcroft #endif
7258631bbeSMike Barcroft 
7358631bbeSMike Barcroft #ifndef _IN_PORT_T_DECLARED
7458631bbeSMike Barcroft typedef	uint16_t		in_port_t;
7558631bbeSMike Barcroft #define	_IN_PORT_T_DECLARED
7658631bbeSMike Barcroft #endif
7758631bbeSMike Barcroft 
7858631bbeSMike Barcroft #ifdef _BSD_SA_FAMILY_T_
7958631bbeSMike Barcroft typedef	_BSD_SA_FAMILY_T_	sa_family_t;
8058631bbeSMike Barcroft #undef _BSD_SA_FAMILY_T_
8158631bbeSMike Barcroft #endif
8258631bbeSMike Barcroft 
8358631bbeSMike Barcroft /* Internet address (a structure for historical reasons). */
8458631bbeSMike Barcroft #ifndef	_STRUCT_IN_ADDR_DECLARED
8558631bbeSMike Barcroft struct in_addr {
8658631bbeSMike Barcroft 	in_addr_t s_addr;
8758631bbeSMike Barcroft };
8858631bbeSMike Barcroft #define	_STRUCT_IN_ADDR_DECLARED
8958631bbeSMike Barcroft #endif
9058631bbeSMike Barcroft 
9158631bbeSMike Barcroft /* Socket address, internet style. */
9258631bbeSMike Barcroft struct sockaddr_in {
9358631bbeSMike Barcroft 	uint8_t	sin_len;
9458631bbeSMike Barcroft 	sa_family_t	sin_family;
9558631bbeSMike Barcroft 	in_port_t	sin_port;
9658631bbeSMike Barcroft 	struct	in_addr sin_addr;
9758631bbeSMike Barcroft 	char	sin_zero[8];
9858631bbeSMike Barcroft };
9958631bbeSMike Barcroft 
10058631bbeSMike Barcroft #ifndef _KERNEL
10158631bbeSMike Barcroft 
10258631bbeSMike Barcroft #ifndef _BYTEORDER_PROTOTYPED
10358631bbeSMike Barcroft #define	_BYTEORDER_PROTOTYPED
10458631bbeSMike Barcroft __BEGIN_DECLS
10558631bbeSMike Barcroft uint32_t	htonl(uint32_t);
10658631bbeSMike Barcroft uint16_t	htons(uint16_t);
10758631bbeSMike Barcroft uint32_t	ntohl(uint32_t);
10858631bbeSMike Barcroft uint16_t	ntohs(uint16_t);
10958631bbeSMike Barcroft __END_DECLS
11058631bbeSMike Barcroft #endif
11158631bbeSMike Barcroft 
11258631bbeSMike Barcroft #ifndef _BYTEORDER_FUNC_DEFINED
11358631bbeSMike Barcroft #define	_BYTEORDER_FUNC_DEFINED
11458631bbeSMike Barcroft #define	htonl(x)	__htonl(x)
11558631bbeSMike Barcroft #define	htons(x)	__htons(x)
11658631bbeSMike Barcroft #define	ntohl(x)	__ntohl(x)
11758631bbeSMike Barcroft #define	ntohs(x)	__ntohs(x)
11858631bbeSMike Barcroft #endif
11958631bbeSMike Barcroft 
12058631bbeSMike Barcroft #endif /* !_KERNEL */
12158631bbeSMike Barcroft 
12258631bbeSMike Barcroft #if __POSIX_VISIBLE >= 200112
12358631bbeSMike Barcroft #define	IPPROTO_RAW		255		/* raw IP packet */
12458631bbeSMike Barcroft #define	INET_ADDRSTRLEN		16
12558631bbeSMike Barcroft #endif
12658631bbeSMike Barcroft 
12758631bbeSMike Barcroft #if __BSD_VISIBLE
128df8bae1dSRodney W. Grimes /*
129df8bae1dSRodney W. Grimes  * Constants and structures defined by the internet system,
130df8bae1dSRodney W. Grimes  * Per RFC 790, September 1981, and numerous additions.
131df8bae1dSRodney W. Grimes  */
132df8bae1dSRodney W. Grimes 
133df8bae1dSRodney W. Grimes /*
134cfaa93b2SJulian Elischer  * Protocols (RFC 1700)
135df8bae1dSRodney W. Grimes  */
13676429de4SYoshinobu Inoue #define	IPPROTO_HOPOPTS		0		/* IP6 hop-by-hop options */
137df8bae1dSRodney W. Grimes #define	IPPROTO_IGMP		2		/* group mgmt protocol */
138df8bae1dSRodney W. Grimes #define	IPPROTO_GGP		3		/* gateway^2 (deprecated) */
13976429de4SYoshinobu Inoue #define IPPROTO_IPV4		4 		/* IPv4 encapsulation */
14076429de4SYoshinobu Inoue #define IPPROTO_IPIP		IPPROTO_IPV4	/* for compatibility */
141cfaa93b2SJulian Elischer #define	IPPROTO_ST		7		/* Stream protocol II */
142df8bae1dSRodney W. Grimes #define	IPPROTO_EGP		8		/* exterior gateway protocol */
143cfaa93b2SJulian Elischer #define	IPPROTO_PIGP		9		/* private interior gateway */
144cfaa93b2SJulian Elischer #define	IPPROTO_RCCMON		10		/* BBN RCC Monitoring */
145cfaa93b2SJulian Elischer #define	IPPROTO_NVPII		11		/* network voice protocol*/
146df8bae1dSRodney W. Grimes #define	IPPROTO_PUP		12		/* pup */
147cfaa93b2SJulian Elischer #define	IPPROTO_ARGUS		13		/* Argus */
148cfaa93b2SJulian Elischer #define	IPPROTO_EMCON		14		/* EMCON */
149cfaa93b2SJulian Elischer #define	IPPROTO_XNET		15		/* Cross Net Debugger */
150cfaa93b2SJulian Elischer #define	IPPROTO_CHAOS		16		/* Chaos*/
151cfaa93b2SJulian Elischer #define	IPPROTO_MUX		18		/* Multiplexing */
152cfaa93b2SJulian Elischer #define	IPPROTO_MEAS		19		/* DCN Measurement Subsystems */
153cfaa93b2SJulian Elischer #define	IPPROTO_HMP		20		/* Host Monitoring */
154cfaa93b2SJulian Elischer #define	IPPROTO_PRM		21		/* Packet Radio Measurement */
155df8bae1dSRodney W. Grimes #define	IPPROTO_IDP		22		/* xns idp */
156cfaa93b2SJulian Elischer #define	IPPROTO_TRUNK1		23		/* Trunk-1 */
157cfaa93b2SJulian Elischer #define	IPPROTO_TRUNK2		24		/* Trunk-2 */
158cfaa93b2SJulian Elischer #define	IPPROTO_LEAF1		25		/* Leaf-1 */
159cfaa93b2SJulian Elischer #define	IPPROTO_LEAF2		26		/* Leaf-2 */
160cfaa93b2SJulian Elischer #define	IPPROTO_RDP		27		/* Reliable Data */
161cfaa93b2SJulian Elischer #define	IPPROTO_IRTP		28		/* Reliable Transaction */
162df8bae1dSRodney W. Grimes #define	IPPROTO_TP		29 		/* tp-4 w/ class negotiation */
163cfaa93b2SJulian Elischer #define	IPPROTO_BLT		30		/* Bulk Data Transfer */
164cfaa93b2SJulian Elischer #define	IPPROTO_NSP		31		/* Network Services */
165cfaa93b2SJulian Elischer #define	IPPROTO_INP		32		/* Merit Internodal */
166cfaa93b2SJulian Elischer #define	IPPROTO_SEP		33		/* Sequential Exchange */
167cfaa93b2SJulian Elischer #define	IPPROTO_3PC		34		/* Third Party Connect */
168cfaa93b2SJulian Elischer #define	IPPROTO_IDPR		35		/* InterDomain Policy Routing */
169cfaa93b2SJulian Elischer #define	IPPROTO_XTP		36		/* XTP */
170cfaa93b2SJulian Elischer #define	IPPROTO_DDP		37		/* Datagram Delivery */
171cfaa93b2SJulian Elischer #define	IPPROTO_CMTP		38		/* Control Message Transport */
172cfaa93b2SJulian Elischer #define	IPPROTO_TPXX		39		/* TP++ Transport */
173cfaa93b2SJulian Elischer #define	IPPROTO_IL		40		/* IL transport protocol */
17476429de4SYoshinobu Inoue #define	IPPROTO_IPV6		41		/* IP6 header */
175cfaa93b2SJulian Elischer #define	IPPROTO_SDRP		42		/* Source Demand Routing */
17676429de4SYoshinobu Inoue #define	IPPROTO_ROUTING		43		/* IP6 routing header */
17776429de4SYoshinobu Inoue #define	IPPROTO_FRAGMENT	44		/* IP6 fragmentation header */
178cfaa93b2SJulian Elischer #define	IPPROTO_IDRP		45		/* InterDomain Routing*/
179f0068c4aSGarrett Wollman #define	IPPROTO_RSVP		46 		/* resource reservation */
180cfaa93b2SJulian Elischer #define	IPPROTO_GRE		47		/* General Routing Encap. */
181cfaa93b2SJulian Elischer #define	IPPROTO_MHRP		48		/* Mobile Host Routing */
182cfaa93b2SJulian Elischer #define	IPPROTO_BHA		49		/* BHA */
18376429de4SYoshinobu Inoue #define	IPPROTO_ESP		50		/* IP6 Encap Sec. Payload */
18476429de4SYoshinobu Inoue #define	IPPROTO_AH		51		/* IP6 Auth Header */
185cfaa93b2SJulian Elischer #define	IPPROTO_INLSP		52		/* Integ. Net Layer Security */
186cfaa93b2SJulian Elischer #define	IPPROTO_SWIPE		53		/* IP with encryption */
187cfaa93b2SJulian Elischer #define	IPPROTO_NHRP		54		/* Next Hop Resolution */
188e61c4bedSJeroen Ruigrok van der Werven #define IPPROTO_MOBILE		55		/* IP Mobility */
189e61c4bedSJeroen Ruigrok van der Werven #define IPPROTO_TLSP		56		/* Transport Layer Security */
190e61c4bedSJeroen Ruigrok van der Werven #define IPPROTO_SKIP		57		/* SKIP */
19176429de4SYoshinobu Inoue #define	IPPROTO_ICMPV6		58		/* ICMP6 */
19276429de4SYoshinobu Inoue #define	IPPROTO_NONE		59		/* IP6 no next header */
19376429de4SYoshinobu Inoue #define	IPPROTO_DSTOPTS		60		/* IP6 destination option */
194cfaa93b2SJulian Elischer #define	IPPROTO_AHIP		61		/* any host internal protocol */
195cfaa93b2SJulian Elischer #define	IPPROTO_CFTP		62		/* CFTP */
196cfaa93b2SJulian Elischer #define	IPPROTO_HELLO		63		/* "hello" routing protocol */
197cfaa93b2SJulian Elischer #define	IPPROTO_SATEXPAK	64		/* SATNET/Backroom EXPAK */
198cfaa93b2SJulian Elischer #define	IPPROTO_KRYPTOLAN	65		/* Kryptolan */
199cfaa93b2SJulian Elischer #define	IPPROTO_RVD		66		/* Remote Virtual Disk */
200cfaa93b2SJulian Elischer #define	IPPROTO_IPPC		67		/* Pluribus Packet Core */
201cfaa93b2SJulian Elischer #define	IPPROTO_ADFS		68		/* Any distributed FS */
202cfaa93b2SJulian Elischer #define	IPPROTO_SATMON		69		/* Satnet Monitoring */
203cfaa93b2SJulian Elischer #define	IPPROTO_VISA		70		/* VISA Protocol */
204cfaa93b2SJulian Elischer #define	IPPROTO_IPCV		71		/* Packet Core Utility */
205cfaa93b2SJulian Elischer #define	IPPROTO_CPNX		72		/* Comp. Prot. Net. Executive */
206cfaa93b2SJulian Elischer #define	IPPROTO_CPHB		73		/* Comp. Prot. HeartBeat */
207cfaa93b2SJulian Elischer #define	IPPROTO_WSN		74		/* Wang Span Network */
208cfaa93b2SJulian Elischer #define	IPPROTO_PVP		75		/* Packet Video Protocol */
209cfaa93b2SJulian Elischer #define	IPPROTO_BRSATMON	76		/* BackRoom SATNET Monitoring */
210cfaa93b2SJulian Elischer #define	IPPROTO_ND		77		/* Sun net disk proto (temp.) */
211cfaa93b2SJulian Elischer #define	IPPROTO_WBMON		78		/* WIDEBAND Monitoring */
212cfaa93b2SJulian Elischer #define	IPPROTO_WBEXPAK		79		/* WIDEBAND EXPAK */
213df8bae1dSRodney W. Grimes #define	IPPROTO_EON		80		/* ISO cnlp */
214cfaa93b2SJulian Elischer #define	IPPROTO_VMTP		81		/* VMTP */
215cfaa93b2SJulian Elischer #define	IPPROTO_SVMTP		82		/* Secure VMTP */
216cfaa93b2SJulian Elischer #define	IPPROTO_VINES		83		/* Banyon VINES */
217cfaa93b2SJulian Elischer #define	IPPROTO_TTP		84		/* TTP */
218cfaa93b2SJulian Elischer #define	IPPROTO_IGP		85		/* NSFNET-IGP */
219cfaa93b2SJulian Elischer #define	IPPROTO_DGP		86		/* dissimilar gateway prot. */
22047f049d7SJulian Elischer #define	IPPROTO_TCF		87		/* TCF */
221cfaa93b2SJulian Elischer #define	IPPROTO_IGRP		88		/* Cisco/GXS IGRP */
222cfaa93b2SJulian Elischer #define	IPPROTO_OSPFIGP		89		/* OSPFIGP */
223cfaa93b2SJulian Elischer #define	IPPROTO_SRPC		90		/* Strite RPC protocol */
224cfaa93b2SJulian Elischer #define	IPPROTO_LARP		91		/* Locus Address Resoloution */
225cfaa93b2SJulian Elischer #define	IPPROTO_MTP		92		/* Multicast Transport */
226cfaa93b2SJulian Elischer #define	IPPROTO_AX25		93		/* AX.25 Frames */
227cfaa93b2SJulian Elischer #define	IPPROTO_IPEIP		94		/* IP encapsulated in IP */
228cfaa93b2SJulian Elischer #define	IPPROTO_MICP		95		/* Mobile Int.ing control */
229cfaa93b2SJulian Elischer #define	IPPROTO_SCCSP		96		/* Semaphore Comm. security */
230cfaa93b2SJulian Elischer #define	IPPROTO_ETHERIP		97		/* Ethernet IP encapsulation */
231df8bae1dSRodney W. Grimes #define	IPPROTO_ENCAP		98		/* encapsulation header */
232cfaa93b2SJulian Elischer #define	IPPROTO_APES		99		/* any private encr. scheme */
233cfaa93b2SJulian Elischer #define	IPPROTO_GMTP		100		/* GMTP*/
23476429de4SYoshinobu Inoue #define	IPPROTO_IPCOMP		108		/* payload compression (IPComp) */
235eaa726beSLuigi Rizzo /* 101-254: Partly Unassigned */
23676429de4SYoshinobu Inoue #define	IPPROTO_PIM		103		/* Protocol Independent Mcast */
237eaa726beSLuigi Rizzo #define	IPPROTO_PGM		113		/* PGM */
238cfaa93b2SJulian Elischer /* 255: Reserved */
239cfaa93b2SJulian Elischer /* BSD Private, local use, namespace incursion */
24093e0e116SJulian Elischer #define	IPPROTO_DIVERT		254		/* divert pseudo-protocol */
241df8bae1dSRodney W. Grimes #define	IPPROTO_MAX		256
242df8bae1dSRodney W. Grimes 
24376429de4SYoshinobu Inoue /* last return value of *_input(), meaning "all job for this pkt is done".  */
24476429de4SYoshinobu Inoue #define	IPPROTO_DONE		257
245df8bae1dSRodney W. Grimes 
246df8bae1dSRodney W. Grimes /*
247df8bae1dSRodney W. Grimes  * Local port number conventions:
24833b3ac06SPeter Wemm  *
24933b3ac06SPeter Wemm  * When a user does a bind(2) or connect(2) with a port number of zero,
25033b3ac06SPeter Wemm  * a non-conflicting local port address is chosen.
251c3b2fe55SMike Silbersack  * The default range is IPPORT_HIFIRSTAUTO through
252c3b2fe55SMike Silbersack  * IPPORT_HILASTAUTO, although that is settable by sysctl.
25333b3ac06SPeter Wemm  *
25433b3ac06SPeter Wemm  * A user may set the IPPROTO_IP option IP_PORTRANGE to change this
25533b3ac06SPeter Wemm  * default assignment range.
25633b3ac06SPeter Wemm  *
25733b3ac06SPeter Wemm  * The value IP_PORTRANGE_DEFAULT causes the default behavior.
25833b3ac06SPeter Wemm  *
25933b3ac06SPeter Wemm  * The value IP_PORTRANGE_HIGH changes the range of candidate port numbers
26033b3ac06SPeter Wemm  * into the "high" range.  These are reserved for client outbound connections
261c3b2fe55SMike Silbersack  * which do not want to be filtered by any firewalls.  Note that by default
262c3b2fe55SMike Silbersack  * this is the same as IP_PORTRANGE_DEFAULT.
26333b3ac06SPeter Wemm  *
26433b3ac06SPeter Wemm  * The value IP_PORTRANGE_LOW changes the range to the "low" are
26533b3ac06SPeter Wemm  * that is (by convention) restricted to privileged processes.  This
26633b3ac06SPeter Wemm  * convention is based on "vouchsafe" principles only.  It is only secure
26733b3ac06SPeter Wemm  * if you trust the remote host to restrict these ports.
26833b3ac06SPeter Wemm  *
26933b3ac06SPeter Wemm  * The default range of ports and the high range can be changed by
270bbd42ad0SPeter Wemm  * sysctl(3).  (net.inet.ip.port{hi,low}{first,last}_auto)
27133b3ac06SPeter Wemm  *
27233b3ac06SPeter Wemm  * Changing those values has bad security implications if you are
27333b3ac06SPeter Wemm  * using a a stateless firewall that is allowing packets outside of that
27433b3ac06SPeter Wemm  * range in order to allow transparent outgoing connections.
27533b3ac06SPeter Wemm  *
27633b3ac06SPeter Wemm  * Such a firewall configuration will generally depend on the use of these
27733b3ac06SPeter Wemm  * default values.  If you change them, you may find your Security
27833b3ac06SPeter Wemm  * Administrator looking for you with a heavy object.
2794565cbeaSPoul-Henning Kamp  *
2804565cbeaSPoul-Henning Kamp  * For a slightly more orthodox text view on this:
2814565cbeaSPoul-Henning Kamp  *
2824565cbeaSPoul-Henning Kamp  *            ftp://ftp.isi.edu/in-notes/iana/assignments/port-numbers
2834565cbeaSPoul-Henning Kamp  *
2844565cbeaSPoul-Henning Kamp  *    port numbers are divided into three ranges:
2854565cbeaSPoul-Henning Kamp  *
2864565cbeaSPoul-Henning Kamp  *                0 -  1023 Well Known Ports
2874565cbeaSPoul-Henning Kamp  *             1024 - 49151 Registered Ports
2884565cbeaSPoul-Henning Kamp  *            49152 - 65535 Dynamic and/or Private Ports
2894565cbeaSPoul-Henning Kamp  *
29033b3ac06SPeter Wemm  */
29133b3ac06SPeter Wemm 
29233b3ac06SPeter Wemm /*
293df8bae1dSRodney W. Grimes  * Ports < IPPORT_RESERVED are reserved for
29433b3ac06SPeter Wemm  * privileged processes (e.g. root).         (IP_PORTRANGE_LOW)
295df8bae1dSRodney W. Grimes  */
296df8bae1dSRodney W. Grimes #define	IPPORT_RESERVED		1024
297df8bae1dSRodney W. Grimes 
298df8bae1dSRodney W. Grimes /*
299f2697d4dSMike Silbersack  * Default local port range, used by both IP_PORTRANGE_DEFAULT
300f2697d4dSMike Silbersack  * and IP_PORTRANGE_HIGH.
301101f9fc8SPeter Wemm  */
3024565cbeaSPoul-Henning Kamp #define	IPPORT_HIFIRSTAUTO	49152
3034565cbeaSPoul-Henning Kamp #define	IPPORT_HILASTAUTO	65535
304101f9fc8SPeter Wemm 
305101f9fc8SPeter Wemm /*
306bbd42ad0SPeter Wemm  * Scanning for a free reserved port return a value below IPPORT_RESERVED,
307bbd42ad0SPeter Wemm  * but higher than IPPORT_RESERVEDSTART.  Traditionally the start value was
308bbd42ad0SPeter Wemm  * 512, but that conflicts with some well-known-services that firewalls may
309bbd42ad0SPeter Wemm  * have a fit if we use.
310bbd42ad0SPeter Wemm  */
311bbd42ad0SPeter Wemm #define IPPORT_RESERVEDSTART	600
312bbd42ad0SPeter Wemm 
313de2656d0SMike Barcroft #define	IPPORT_MAX		65535
314de2656d0SMike Barcroft 
3158822d3fbSMike Barcroft #ifndef _UINT8_T_DECLARED
3168822d3fbSMike Barcroft typedef	__uint8_t		uint8_t;
3178822d3fbSMike Barcroft #define	_UINT8_T_DECLARED
318de2656d0SMike Barcroft #endif
319de2656d0SMike Barcroft 
3208822d3fbSMike Barcroft #ifndef _UINT16_T_DECLARED
3218822d3fbSMike Barcroft typedef	__uint16_t		uint16_t;
3228822d3fbSMike Barcroft #define	_UINT16_T_DECLARED
3238822d3fbSMike Barcroft #endif
3248822d3fbSMike Barcroft 
3258822d3fbSMike Barcroft #ifndef _UINT32_T_DECLARED
3268822d3fbSMike Barcroft typedef	__uint32_t		uint32_t;
3278822d3fbSMike Barcroft #define	_UINT32_T_DECLARED
3288822d3fbSMike Barcroft #endif
3298822d3fbSMike Barcroft 
3308822d3fbSMike Barcroft #ifndef _IN_ADDR_T_DECLARED
3318822d3fbSMike Barcroft typedef	uint32_t		in_addr_t;
3328822d3fbSMike Barcroft #define	_IN_ADDR_T_DECLARED
3338822d3fbSMike Barcroft #endif
3348822d3fbSMike Barcroft 
3358822d3fbSMike Barcroft #ifndef _IN_PORT_T_DECLARED
3368822d3fbSMike Barcroft typedef	uint16_t		in_port_t;
3378822d3fbSMike Barcroft #define	_IN_PORT_T_DECLARED
338de2656d0SMike Barcroft #endif
339de2656d0SMike Barcroft 
340c6e43821SMike Barcroft #ifdef _BSD_SA_FAMILY_T_
341c6e43821SMike Barcroft typedef	_BSD_SA_FAMILY_T_	sa_family_t;
342c6e43821SMike Barcroft #undef _BSD_SA_FAMILY_T_
343c6e43821SMike Barcroft #endif
344c6e43821SMike Barcroft 
345bbd42ad0SPeter Wemm /*
346df8bae1dSRodney W. Grimes  * Internet address (a structure for historical reasons)
347df8bae1dSRodney W. Grimes  */
348de2656d0SMike Barcroft #ifndef	_STRUCT_IN_ADDR_DECLARED
349df8bae1dSRodney W. Grimes struct in_addr {
3502da24fa6SHajimu UMEMOTO 	in_addr_t s_addr;
351df8bae1dSRodney W. Grimes };
352de2656d0SMike Barcroft #define	_STRUCT_IN_ADDR_DECLARED
353de2656d0SMike Barcroft #endif
354df8bae1dSRodney W. Grimes 
355df8bae1dSRodney W. Grimes /*
356df8bae1dSRodney W. Grimes  * Definitions of bits in internet address integers.
357df8bae1dSRodney W. Grimes  * On subnets, the decomposition of addresses to host and net parts
358df8bae1dSRodney W. Grimes  * is done according to subnet mask, not the masks here.
359df8bae1dSRodney W. Grimes  */
360fac6d93bSJohn Birrell #define	IN_CLASSA(i)		(((u_int32_t)(i) & 0x80000000) == 0)
361df8bae1dSRodney W. Grimes #define	IN_CLASSA_NET		0xff000000
362df8bae1dSRodney W. Grimes #define	IN_CLASSA_NSHIFT	24
363df8bae1dSRodney W. Grimes #define	IN_CLASSA_HOST		0x00ffffff
364df8bae1dSRodney W. Grimes #define	IN_CLASSA_MAX		128
365df8bae1dSRodney W. Grimes 
366fac6d93bSJohn Birrell #define	IN_CLASSB(i)		(((u_int32_t)(i) & 0xc0000000) == 0x80000000)
367df8bae1dSRodney W. Grimes #define	IN_CLASSB_NET		0xffff0000
368df8bae1dSRodney W. Grimes #define	IN_CLASSB_NSHIFT	16
369df8bae1dSRodney W. Grimes #define	IN_CLASSB_HOST		0x0000ffff
370df8bae1dSRodney W. Grimes #define	IN_CLASSB_MAX		65536
371df8bae1dSRodney W. Grimes 
372fac6d93bSJohn Birrell #define	IN_CLASSC(i)		(((u_int32_t)(i) & 0xe0000000) == 0xc0000000)
373df8bae1dSRodney W. Grimes #define	IN_CLASSC_NET		0xffffff00
374df8bae1dSRodney W. Grimes #define	IN_CLASSC_NSHIFT	8
375df8bae1dSRodney W. Grimes #define	IN_CLASSC_HOST		0x000000ff
376df8bae1dSRodney W. Grimes 
377fac6d93bSJohn Birrell #define	IN_CLASSD(i)		(((u_int32_t)(i) & 0xf0000000) == 0xe0000000)
378df8bae1dSRodney W. Grimes #define	IN_CLASSD_NET		0xf0000000	/* These ones aren't really */
379df8bae1dSRodney W. Grimes #define	IN_CLASSD_NSHIFT	28		/* net and host fields, but */
380df8bae1dSRodney W. Grimes #define	IN_CLASSD_HOST		0x0fffffff	/* routing needn't know.    */
381df8bae1dSRodney W. Grimes #define	IN_MULTICAST(i)		IN_CLASSD(i)
382df8bae1dSRodney W. Grimes 
383fac6d93bSJohn Birrell #define	IN_EXPERIMENTAL(i)	(((u_int32_t)(i) & 0xf0000000) == 0xf0000000)
384fac6d93bSJohn Birrell #define	IN_BADCLASS(i)		(((u_int32_t)(i) & 0xf0000000) == 0xf0000000)
385df8bae1dSRodney W. Grimes 
386fac6d93bSJohn Birrell #define	INADDR_LOOPBACK		(u_int32_t)0x7f000001
387664a31e4SPeter Wemm #ifndef _KERNEL
388df8bae1dSRodney W. Grimes #define	INADDR_NONE		0xffffffff		/* -1 return */
389df8bae1dSRodney W. Grimes #endif
390df8bae1dSRodney W. Grimes 
391fac6d93bSJohn Birrell #define	INADDR_UNSPEC_GROUP	(u_int32_t)0xe0000000	/* 224.0.0.0 */
392fac6d93bSJohn Birrell #define	INADDR_ALLHOSTS_GROUP	(u_int32_t)0xe0000001	/* 224.0.0.1 */
393fac6d93bSJohn Birrell #define	INADDR_ALLRTRS_GROUP	(u_int32_t)0xe0000002	/* 224.0.0.2 */
394fac6d93bSJohn Birrell #define	INADDR_MAX_LOCAL_GROUP	(u_int32_t)0xe00000ff	/* 224.0.0.255 */
395df8bae1dSRodney W. Grimes 
396df8bae1dSRodney W. Grimes #define	IN_LOOPBACKNET		127			/* official! */
397df8bae1dSRodney W. Grimes 
398df8bae1dSRodney W. Grimes /*
399df8bae1dSRodney W. Grimes  * Options for use with [gs]etsockopt at the IP level.
400df8bae1dSRodney W. Grimes  * First word of comment is data type; bool is stored in int.
401df8bae1dSRodney W. Grimes  */
402df8bae1dSRodney W. Grimes #define	IP_OPTIONS		1    /* buf/ip_opts; set/get IP options */
403df8bae1dSRodney W. Grimes #define	IP_HDRINCL		2    /* int; header is included with data */
404df8bae1dSRodney W. Grimes #define	IP_TOS			3    /* int; IP type of service and preced. */
405df8bae1dSRodney W. Grimes #define	IP_TTL			4    /* int; IP time to live */
406df8bae1dSRodney W. Grimes #define	IP_RECVOPTS		5    /* bool; receive all IP opts w/dgram */
407df8bae1dSRodney W. Grimes #define	IP_RECVRETOPTS		6    /* bool; receive IP opts for response */
408df8bae1dSRodney W. Grimes #define	IP_RECVDSTADDR		7    /* bool; receive IP dst addr w/dgram */
409df8bae1dSRodney W. Grimes #define	IP_RETOPTS		8    /* ip_opts; set/get IP options */
410df8bae1dSRodney W. Grimes #define	IP_MULTICAST_IF		9    /* u_char; set/get IP multicast i/f  */
411df8bae1dSRodney W. Grimes #define	IP_MULTICAST_TTL	10   /* u_char; set/get IP multicast ttl */
412df8bae1dSRodney W. Grimes #define	IP_MULTICAST_LOOP	11   /* u_char; set/get IP multicast loopback */
413df8bae1dSRodney W. Grimes #define	IP_ADD_MEMBERSHIP	12   /* ip_mreq; add an IP group membership */
414df8bae1dSRodney W. Grimes #define	IP_DROP_MEMBERSHIP	13   /* ip_mreq; drop an IP group membership */
415f0068c4aSGarrett Wollman #define IP_MULTICAST_VIF	14   /* set/get IP mcast virt. iface */
416f0068c4aSGarrett Wollman #define IP_RSVP_ON		15   /* enable RSVP in kernel */
417f0068c4aSGarrett Wollman #define IP_RSVP_OFF		16   /* disable RSVP in kernel */
4181c5de19aSGarrett Wollman #define IP_RSVP_VIF_ON		17   /* set RSVP per-vif socket */
4191c5de19aSGarrett Wollman #define IP_RSVP_VIF_OFF		18   /* unset RSVP per-vif socket */
42033b3ac06SPeter Wemm #define IP_PORTRANGE		19   /* int; range to choose for unspec port */
42182c23ebaSBill Fenner #define	IP_RECVIF		20   /* bool; receive reception if w/dgram */
42276429de4SYoshinobu Inoue /* for IPSEC */
42376429de4SYoshinobu Inoue #define	IP_IPSEC_POLICY		21   /* int; set/get security policy */
42476429de4SYoshinobu Inoue #define	IP_FAITH		22   /* bool; accept FAITH'ed connections */
425df8bae1dSRodney W. Grimes 
426fed1c7e9SSøren Schmidt #define	IP_FW_ADD     		50   /* add a firewall rule to chain */
427fed1c7e9SSøren Schmidt #define	IP_FW_DEL    		51   /* delete a firewall rule from chain */
428fed1c7e9SSøren Schmidt #define	IP_FW_FLUSH   		52   /* flush firewall rule chain */
429af44ef0aSAlexander Langer #define	IP_FW_ZERO    		53   /* clear single/all firewall counter(s) */
430fed1c7e9SSøren Schmidt #define	IP_FW_GET     		54   /* get entire firewall rule chain */
4310b6c1a83SBrian Feldman #define	IP_FW_RESETLOG		55   /* reset logging counters */
432fed1c7e9SSøren Schmidt 
433b715f178SLuigi Rizzo #define	IP_DUMMYNET_CONFIGURE	60   /* add/configure a dummynet pipe */
434b715f178SLuigi Rizzo #define	IP_DUMMYNET_DEL		61   /* delete a dummynet pipe from chain */
435b715f178SLuigi Rizzo #define	IP_DUMMYNET_FLUSH	62   /* flush dummynet */
436b715f178SLuigi Rizzo #define	IP_DUMMYNET_GET		64   /* get entire dummynet pipes */
437b715f178SLuigi Rizzo 
438df8bae1dSRodney W. Grimes /*
439df8bae1dSRodney W. Grimes  * Defaults and limits for options
440df8bae1dSRodney W. Grimes  */
441df8bae1dSRodney W. Grimes #define	IP_DEFAULT_MULTICAST_TTL  1	/* normally limit m'casts to 1 hop  */
442df8bae1dSRodney W. Grimes #define	IP_DEFAULT_MULTICAST_LOOP 1	/* normally hear sends if a member  */
4431c5de19aSGarrett Wollman #define	IP_MAX_MEMBERSHIPS	20	/* per socket */
444df8bae1dSRodney W. Grimes 
445df8bae1dSRodney W. Grimes /*
446df8bae1dSRodney W. Grimes  * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
447df8bae1dSRodney W. Grimes  */
448df8bae1dSRodney W. Grimes struct ip_mreq {
449df8bae1dSRodney W. Grimes 	struct	in_addr imr_multiaddr;	/* IP multicast address of group */
450df8bae1dSRodney W. Grimes 	struct	in_addr imr_interface;	/* local IP address of interface */
451df8bae1dSRodney W. Grimes };
452df8bae1dSRodney W. Grimes 
453df8bae1dSRodney W. Grimes /*
45433b3ac06SPeter Wemm  * Argument for IP_PORTRANGE:
45533b3ac06SPeter Wemm  * - which range to search when port is unspecified at bind() or connect()
45633b3ac06SPeter Wemm  */
45733b3ac06SPeter Wemm #define	IP_PORTRANGE_DEFAULT	0	/* default range */
45833b3ac06SPeter Wemm #define	IP_PORTRANGE_HIGH	1	/* "high" - request firewall bypass */
45933b3ac06SPeter Wemm #define	IP_PORTRANGE_LOW	2	/* "low" - vouchsafe security */
46033b3ac06SPeter Wemm 
46133b3ac06SPeter Wemm /*
462df8bae1dSRodney W. Grimes  * Definitions for inet sysctl operations.
463df8bae1dSRodney W. Grimes  *
464df8bae1dSRodney W. Grimes  * Third level is protocol number.
465df8bae1dSRodney W. Grimes  * Fourth level is desired variable within that protocol.
466df8bae1dSRodney W. Grimes  */
467686cdd19SJun-ichiro itojun Hagino #define	IPPROTO_MAXID	(IPPROTO_AH + 1)	/* don't list to IPPROTO_MAX */
468df8bae1dSRodney W. Grimes 
469df8bae1dSRodney W. Grimes #define	CTL_IPPROTO_NAMES { \
470df8bae1dSRodney W. Grimes 	{ "ip", CTLTYPE_NODE }, \
471df8bae1dSRodney W. Grimes 	{ "icmp", CTLTYPE_NODE }, \
472df8bae1dSRodney W. Grimes 	{ "igmp", CTLTYPE_NODE }, \
473df8bae1dSRodney W. Grimes 	{ "ggp", CTLTYPE_NODE }, \
474df8bae1dSRodney W. Grimes 	{ 0, 0 }, \
475df8bae1dSRodney W. Grimes 	{ 0, 0 }, \
476df8bae1dSRodney W. Grimes 	{ "tcp", CTLTYPE_NODE }, \
477df8bae1dSRodney W. Grimes 	{ 0, 0 }, \
478df8bae1dSRodney W. Grimes 	{ "egp", CTLTYPE_NODE }, \
479df8bae1dSRodney W. Grimes 	{ 0, 0 }, \
480df8bae1dSRodney W. Grimes 	{ 0, 0 }, \
481df8bae1dSRodney W. Grimes 	{ 0, 0 }, \
482df8bae1dSRodney W. Grimes 	{ "pup", CTLTYPE_NODE }, \
483df8bae1dSRodney W. Grimes 	{ 0, 0 }, \
484df8bae1dSRodney W. Grimes 	{ 0, 0 }, \
485df8bae1dSRodney W. Grimes 	{ 0, 0 }, \
486df8bae1dSRodney W. Grimes 	{ 0, 0 }, \
487df8bae1dSRodney W. Grimes 	{ "udp", CTLTYPE_NODE }, \
488df8bae1dSRodney W. Grimes 	{ 0, 0 }, \
489df8bae1dSRodney W. Grimes 	{ 0, 0 }, \
490df8bae1dSRodney W. Grimes 	{ 0, 0 }, \
491df8bae1dSRodney W. Grimes 	{ 0, 0 }, \
492df8bae1dSRodney W. Grimes 	{ "idp", CTLTYPE_NODE }, \
493686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
494686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
495686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
496686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
497686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
498686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
499686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
500686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
501686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
502686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
503686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
504686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
505686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
506686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
507686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
508686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
509686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
510686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
511686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
512686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
513686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
514686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
515686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
516686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
517686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
518686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
519686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
520686cdd19SJun-ichiro itojun Hagino 	{ 0, 0 }, \
521686cdd19SJun-ichiro itojun Hagino 	{ "ipsec", CTLTYPE_NODE }, \
522df8bae1dSRodney W. Grimes }
523df8bae1dSRodney W. Grimes 
524df8bae1dSRodney W. Grimes /*
525df8bae1dSRodney W. Grimes  * Names for IP sysctl objects
526df8bae1dSRodney W. Grimes  */
527df8bae1dSRodney W. Grimes #define	IPCTL_FORWARDING	1	/* act as router */
528df8bae1dSRodney W. Grimes #define	IPCTL_SENDREDIRECTS	2	/* may send redirects when forwarding */
529df8bae1dSRodney W. Grimes #define	IPCTL_DEFTTL		3	/* default TTL */
530df8bae1dSRodney W. Grimes #ifdef notyet
531df8bae1dSRodney W. Grimes #define	IPCTL_DEFMTU		4	/* default MTU */
532df8bae1dSRodney W. Grimes #endif
5335be2baf8SGarrett Wollman #define IPCTL_RTEXPIRE		5	/* cloned route expiration time */
534ea80aed1SGarrett Wollman #define IPCTL_RTMINEXPIRE	6	/* min value for expiration time */
535ea80aed1SGarrett Wollman #define IPCTL_RTMAXCACHE	7	/* trigger level for dynamic expire */
5361025071fSGarrett Wollman #define	IPCTL_SOURCEROUTE	8	/* may perform source routes */
53742c03a52SPeter Wemm #define	IPCTL_DIRECTEDBROADCAST	9	/* may re-broadcast received packets */
538054ef370SGarrett Wollman #define IPCTL_INTRQMAXLEN	10	/* max length of netisr queue */
539054ef370SGarrett Wollman #define	IPCTL_INTRQDROPS	11	/* number of netisr q drops */
5406fce01c9SGarrett Wollman #define	IPCTL_STATS		12	/* ipstat structure */
5414fce5804SGuido van Rooij #define	IPCTL_ACCEPTSOURCEROUTE	13	/* may accept source routed packets */
5421f91d8c5SDavid Greenman #define	IPCTL_FASTFORWARDING	14	/* use fast IP forwarding code */
5436a800098SYoshinobu Inoue #define	IPCTL_KEEPFAITH		15	/* FAITH IPv4->IPv6 translater ctl */
54476429de4SYoshinobu Inoue #define	IPCTL_GIF_TTL		16	/* default TTL for gif encap packet */
54576429de4SYoshinobu Inoue #define	IPCTL_MAXID		17
546df8bae1dSRodney W. Grimes 
547df8bae1dSRodney W. Grimes #define	IPCTL_NAMES { \
548df8bae1dSRodney W. Grimes 	{ 0, 0 }, \
549df8bae1dSRodney W. Grimes 	{ "forwarding", CTLTYPE_INT }, \
550df8bae1dSRodney W. Grimes 	{ "redirect", CTLTYPE_INT }, \
551df8bae1dSRodney W. Grimes 	{ "ttl", CTLTYPE_INT }, \
552df8bae1dSRodney W. Grimes 	{ "mtu", CTLTYPE_INT }, \
5535be2baf8SGarrett Wollman 	{ "rtexpire", CTLTYPE_INT }, \
554ea80aed1SGarrett Wollman 	{ "rtminexpire", CTLTYPE_INT }, \
555ea80aed1SGarrett Wollman 	{ "rtmaxcache", CTLTYPE_INT }, \
5561025071fSGarrett Wollman 	{ "sourceroute", CTLTYPE_INT }, \
55742c03a52SPeter Wemm  	{ "directed-broadcast", CTLTYPE_INT }, \
558054ef370SGarrett Wollman 	{ "intr-queue-maxlen", CTLTYPE_INT }, \
559054ef370SGarrett Wollman 	{ "intr-queue-drops", CTLTYPE_INT }, \
5606fce01c9SGarrett Wollman 	{ "stats", CTLTYPE_STRUCT }, \
5614fce5804SGuido van Rooij 	{ "accept_sourceroute", CTLTYPE_INT }, \
5621f91d8c5SDavid Greenman 	{ "fastforwarding", CTLTYPE_INT }, \
563df8bae1dSRodney W. Grimes }
564df8bae1dSRodney W. Grimes 
56558631bbeSMike Barcroft #endif /* __BSD_VISIBLE */
56658631bbeSMike Barcroft 
567215db137SPeter Wemm #ifdef _KERNEL
56858631bbeSMike Barcroft 
569215db137SPeter Wemm struct ifnet; struct mbuf;	/* forward declarations for Standard C */
570ef0cdf33SGarrett Wollman 
5714d77a549SAlfred Perlstein int	 in_broadcast(struct in_addr, struct ifnet *);
5724d77a549SAlfred Perlstein int	 in_canforward(struct in_addr);
5734d77a549SAlfred Perlstein int	 in_localaddr(struct in_addr);
5744d77a549SAlfred Perlstein char 	*inet_ntoa(struct in_addr); /* in libkern */
5754d77a549SAlfred Perlstein char	*inet_ntoa_r(struct in_addr ina, char *buf); /* in libkern */
57623bf9953SPoul-Henning Kamp 
5779a10980eSJonathan Lemon #define satosin(sa)	((struct sockaddr_in *)(sa))
5789a10980eSJonathan Lemon #define sintosa(sin)	((struct sockaddr *)(sin))
5799a10980eSJonathan Lemon #define ifatoia(ifa)	((struct in_ifaddr *)(ifa))
5809a10980eSJonathan Lemon 
581fd8e4ebcSMike Barcroft #endif /* _KERNEL */
582fd8e4ebcSMike Barcroft 
58358631bbeSMike Barcroft /* INET6 stuff */
58458631bbeSMike Barcroft #if __POSIX_VISIBLE >= 200112
58558631bbeSMike Barcroft #define	__KAME_NETINET_IN_H_INCLUDED_
58658631bbeSMike Barcroft #include <netinet6/in6.h>
58758631bbeSMike Barcroft #undef __KAME_NETINET_IN_H_INCLUDED_
588707f139eSPaul Richards #endif
58958631bbeSMike Barcroft 
59058631bbeSMike Barcroft #endif /* !_NETINET_IN_H_*/
591