in.h revision 50477
11541Srgrimes/*
21541Srgrimes * Copyright (c) 1982, 1986, 1990, 1993
31541Srgrimes *	The Regents of the University of California.  All rights reserved.
41541Srgrimes *
51541Srgrimes * Redistribution and use in source and binary forms, with or without
61541Srgrimes * modification, are permitted provided that the following conditions
71541Srgrimes * are met:
81541Srgrimes * 1. Redistributions of source code must retain the above copyright
91541Srgrimes *    notice, this list of conditions and the following disclaimer.
101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111541Srgrimes *    notice, this list of conditions and the following disclaimer in the
121541Srgrimes *    documentation and/or other materials provided with the distribution.
131541Srgrimes * 3. All advertising materials mentioning features or use of this software
141541Srgrimes *    must display the following acknowledgement:
151541Srgrimes *	This product includes software developed by the University of
161541Srgrimes *	California, Berkeley and its contributors.
171541Srgrimes * 4. Neither the name of the University nor the names of its contributors
181541Srgrimes *    may be used to endorse or promote products derived from this software
191541Srgrimes *    without specific prior written permission.
201541Srgrimes *
211541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
221541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
251541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
261541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
271541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
281541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
301541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311541Srgrimes * SUCH DAMAGE.
321541Srgrimes *
331541Srgrimes *	@(#)in.h	8.3 (Berkeley) 1/3/94
3450477Speter * $FreeBSD: head/sys/netinet/in.h 50477 1999-08-28 01:08:13Z peter $
351541Srgrimes */
361541Srgrimes
372169Spaul#ifndef _NETINET_IN_H_
382169Spaul#define _NETINET_IN_H_
392169Spaul
401541Srgrimes/*
411541Srgrimes * Constants and structures defined by the internet system,
421541Srgrimes * Per RFC 790, September 1981, and numerous additions.
431541Srgrimes */
441541Srgrimes
451541Srgrimes/*
4633804Sjulian * Protocols (RFC 1700)
471541Srgrimes */
481541Srgrimes#define	IPPROTO_IP		0		/* dummy for IP */
491541Srgrimes#define	IPPROTO_ICMP		1		/* control message protocol */
501541Srgrimes#define	IPPROTO_IGMP		2		/* group mgmt protocol */
511541Srgrimes#define	IPPROTO_GGP		3		/* gateway^2 (deprecated) */
529209Swollman#define IPPROTO_IPIP		4 		/* IP encapsulation in IP */
531541Srgrimes#define	IPPROTO_TCP		6		/* tcp */
5433804Sjulian#define	IPPROTO_ST		7		/* Stream protocol II */
551541Srgrimes#define	IPPROTO_EGP		8		/* exterior gateway protocol */
5633804Sjulian#define	IPPROTO_PIGP		9		/* private interior gateway */
5733804Sjulian#define	IPPROTO_RCCMON		10		/* BBN RCC Monitoring */
5833804Sjulian#define	IPPROTO_NVPII		11		/* network voice protocol*/
591541Srgrimes#define	IPPROTO_PUP		12		/* pup */
6033804Sjulian#define	IPPROTO_ARGUS		13		/* Argus */
6133804Sjulian#define	IPPROTO_EMCON		14		/* EMCON */
6233804Sjulian#define	IPPROTO_XNET		15		/* Cross Net Debugger */
6333804Sjulian#define	IPPROTO_CHAOS		16		/* Chaos*/
641541Srgrimes#define	IPPROTO_UDP		17		/* user datagram protocol */
6533804Sjulian#define	IPPROTO_MUX		18		/* Multiplexing */
6633804Sjulian#define	IPPROTO_MEAS		19		/* DCN Measurement Subsystems */
6733804Sjulian#define	IPPROTO_HMP		20		/* Host Monitoring */
6833804Sjulian#define	IPPROTO_PRM		21		/* Packet Radio Measurement */
691541Srgrimes#define	IPPROTO_IDP		22		/* xns idp */
7033804Sjulian#define	IPPROTO_TRUNK1		23		/* Trunk-1 */
7133804Sjulian#define	IPPROTO_TRUNK2		24		/* Trunk-2 */
7233804Sjulian#define	IPPROTO_LEAF1		25		/* Leaf-1 */
7333804Sjulian#define	IPPROTO_LEAF2		26		/* Leaf-2 */
7433804Sjulian#define	IPPROTO_RDP		27		/* Reliable Data */
7533804Sjulian#define	IPPROTO_IRTP		28		/* Reliable Transaction */
761541Srgrimes#define	IPPROTO_TP		29 		/* tp-4 w/ class negotiation */
7733804Sjulian#define	IPPROTO_BLT		30		/* Bulk Data Transfer */
7833804Sjulian#define	IPPROTO_NSP		31		/* Network Services */
7933804Sjulian#define	IPPROTO_INP		32		/* Merit Internodal */
8033804Sjulian#define	IPPROTO_SEP		33		/* Sequential Exchange */
8133804Sjulian#define	IPPROTO_3PC		34		/* Third Party Connect */
8233804Sjulian#define	IPPROTO_IDPR		35		/* InterDomain Policy Routing */
8333804Sjulian#define	IPPROTO_XTP		36		/* XTP */
8433804Sjulian#define	IPPROTO_DDP		37		/* Datagram Delivery */
8533804Sjulian#define	IPPROTO_CMTP		38		/* Control Message Transport */
8633804Sjulian#define	IPPROTO_TPXX		39		/* TP++ Transport */
8733804Sjulian#define	IPPROTO_IL		40		/* IL transport protocol */
8833804Sjulian#define	IPPROTO_SIP		41		/* Simple Internet Protocol */
8933804Sjulian#define	IPPROTO_SDRP		42		/* Source Demand Routing */
9033804Sjulian#define	IPPROTO_SIPSR		43		/* SIP Source Route */
9133804Sjulian#define	IPPROTO_SIPFRAG		44		/* SIP Fragment */
9233804Sjulian#define	IPPROTO_IDRP		45		/* InterDomain Routing*/
932531Swollman#define IPPROTO_RSVP		46 		/* resource reservation */
9433804Sjulian#define	IPPROTO_GRE		47		/* General Routing Encap. */
9533804Sjulian#define	IPPROTO_MHRP		48		/* Mobile Host Routing */
9633804Sjulian#define	IPPROTO_BHA		49		/* BHA */
9733804Sjulian#define	IPPROTO_ESP		50		/* SIPP Encap Sec. Payload */
9833804Sjulian#define	IPPROTO_AH		51		/* SIPP Auth Header */
9933804Sjulian#define	IPPROTO_INLSP		52		/* Integ. Net Layer Security */
10033804Sjulian#define	IPPROTO_SWIPE		53		/* IP with encryption */
10133804Sjulian#define	IPPROTO_NHRP		54		/* Next Hop Resolution */
10233804Sjulian/* 55-60: Unassigned */
10333804Sjulian#define	IPPROTO_AHIP		61		/* any host internal protocol */
10433804Sjulian#define	IPPROTO_CFTP		62		/* CFTP */
10533804Sjulian#define	IPPROTO_HELLO		63		/* "hello" routing protocol */
10633804Sjulian#define	IPPROTO_SATEXPAK	64		/* SATNET/Backroom EXPAK */
10733804Sjulian#define	IPPROTO_KRYPTOLAN	65		/* Kryptolan */
10833804Sjulian#define	IPPROTO_RVD		66		/* Remote Virtual Disk */
10933804Sjulian#define	IPPROTO_IPPC		67		/* Pluribus Packet Core */
11033804Sjulian#define	IPPROTO_ADFS		68		/* Any distributed FS */
11133804Sjulian#define	IPPROTO_SATMON		69		/* Satnet Monitoring */
11233804Sjulian#define	IPPROTO_VISA		70		/* VISA Protocol */
11333804Sjulian#define	IPPROTO_IPCV		71		/* Packet Core Utility */
11433804Sjulian#define	IPPROTO_CPNX		72		/* Comp. Prot. Net. Executive */
11533804Sjulian#define	IPPROTO_CPHB		73		/* Comp. Prot. HeartBeat */
11633804Sjulian#define	IPPROTO_WSN		74		/* Wang Span Network */
11733804Sjulian#define	IPPROTO_PVP		75		/* Packet Video Protocol */
11833804Sjulian#define	IPPROTO_BRSATMON	76		/* BackRoom SATNET Monitoring */
11933804Sjulian#define	IPPROTO_ND		77		/* Sun net disk proto (temp.) */
12033804Sjulian#define	IPPROTO_WBMON		78		/* WIDEBAND Monitoring */
12133804Sjulian#define	IPPROTO_WBEXPAK		79		/* WIDEBAND EXPAK */
1221541Srgrimes#define	IPPROTO_EON		80		/* ISO cnlp */
12333804Sjulian#define	IPPROTO_VMTP		81		/* VMTP */
12433804Sjulian#define	IPPROTO_SVMTP		82		/* Secure VMTP */
12533804Sjulian#define	IPPROTO_VINES		83		/* Banyon VINES */
12633804Sjulian#define	IPPROTO_TTP		84		/* TTP */
12733804Sjulian#define	IPPROTO_IGP		85		/* NSFNET-IGP */
12833804Sjulian#define	IPPROTO_DGP		86		/* dissimilar gateway prot. */
12933814Sjulian#define	IPPROTO_TCF		87		/* TCF */
13033804Sjulian#define	IPPROTO_IGRP		88		/* Cisco/GXS IGRP */
13133804Sjulian#define	IPPROTO_OSPFIGP		89		/* OSPFIGP */
13233804Sjulian#define	IPPROTO_SRPC		90		/* Strite RPC protocol */
13333804Sjulian#define	IPPROTO_LARP		91		/* Locus Address Resoloution */
13433804Sjulian#define	IPPROTO_MTP		92		/* Multicast Transport */
13533804Sjulian#define	IPPROTO_AX25		93		/* AX.25 Frames */
13633804Sjulian#define	IPPROTO_IPEIP		94		/* IP encapsulated in IP */
13733804Sjulian#define	IPPROTO_MICP		95		/* Mobile Int.ing control */
13833804Sjulian#define	IPPROTO_SCCSP		96		/* Semaphore Comm. security */
13933804Sjulian#define	IPPROTO_ETHERIP		97		/* Ethernet IP encapsulation */
1401541Srgrimes#define	IPPROTO_ENCAP		98		/* encapsulation header */
14133804Sjulian#define	IPPROTO_APES		99		/* any private encr. scheme */
14233804Sjulian#define	IPPROTO_GMTP		100		/* GMTP*/
14346420Sluigi/* 101-254: Partly Unassigned */
14446420Sluigi#define	IPPROTO_PGM		113		/* PGM */
14533804Sjulian/* 255: Reserved */
14633804Sjulian/* BSD Private, local use, namespace incursion */
14717072Sjulian#define	IPPROTO_DIVERT		254		/* divert pseudo-protocol */
1481541Srgrimes#define	IPPROTO_RAW		255		/* raw IP packet */
1491541Srgrimes#define	IPPROTO_MAX		256
1501541Srgrimes
1511541Srgrimes
1521541Srgrimes/*
1531541Srgrimes * Local port number conventions:
15414195Speter *
15514195Speter * When a user does a bind(2) or connect(2) with a port number of zero,
15614195Speter * a non-conflicting local port address is chosen.
15714195Speter * The default range is IPPORT_RESERVED through
15814195Speter * IPPORT_USERRESERVED, although that is settable by sysctl.
15914195Speter *
16014195Speter * A user may set the IPPROTO_IP option IP_PORTRANGE to change this
16114195Speter * default assignment range.
16214195Speter *
16314195Speter * The value IP_PORTRANGE_DEFAULT causes the default behavior.
16414195Speter *
16514195Speter * The value IP_PORTRANGE_HIGH changes the range of candidate port numbers
16614195Speter * into the "high" range.  These are reserved for client outbound connections
16714195Speter * which do not want to be filtered by any firewalls.
16814195Speter *
16914195Speter * The value IP_PORTRANGE_LOW changes the range to the "low" are
17014195Speter * that is (by convention) restricted to privileged processes.  This
17114195Speter * convention is based on "vouchsafe" principles only.  It is only secure
17214195Speter * if you trust the remote host to restrict these ports.
17314195Speter *
17414195Speter * The default range of ports and the high range can be changed by
17517541Speter * sysctl(3).  (net.inet.ip.port{hi,low}{first,last}_auto)
17614195Speter *
17714195Speter * Changing those values has bad security implications if you are
17814195Speter * using a a stateless firewall that is allowing packets outside of that
17914195Speter * range in order to allow transparent outgoing connections.
18014195Speter *
18114195Speter * Such a firewall configuration will generally depend on the use of these
18214195Speter * default values.  If you change them, you may find your Security
18314195Speter * Administrator looking for you with a heavy object.
18435304Sphk *
18535304Sphk * For a slightly more orthodox text view on this:
18635304Sphk *
18735304Sphk *            ftp://ftp.isi.edu/in-notes/iana/assignments/port-numbers
18835304Sphk *
18935304Sphk *    port numbers are divided into three ranges:
19035304Sphk *
19135304Sphk *                0 -  1023 Well Known Ports
19235304Sphk *             1024 - 49151 Registered Ports
19335304Sphk *            49152 - 65535 Dynamic and/or Private Ports
19435304Sphk *
19514195Speter */
19614195Speter
19714195Speter/*
1981541Srgrimes * Ports < IPPORT_RESERVED are reserved for
19914195Speter * privileged processes (e.g. root).         (IP_PORTRANGE_LOW)
2001541Srgrimes * Ports > IPPORT_USERRESERVED are reserved
20114195Speter * for servers, not necessarily privileged.  (IP_PORTRANGE_DEFAULT)
2021541Srgrimes */
2031541Srgrimes#define	IPPORT_RESERVED		1024
2041541Srgrimes#define	IPPORT_USERRESERVED	5000
2051541Srgrimes
2061541Srgrimes/*
20714195Speter * Default local port range to use by setting IP_PORTRANGE_HIGH
20813491Speter */
20935304Sphk#define	IPPORT_HIFIRSTAUTO	49152
21035304Sphk#define	IPPORT_HILASTAUTO	65535
21113491Speter
21213491Speter/*
21317541Speter * Scanning for a free reserved port return a value below IPPORT_RESERVED,
21417541Speter * but higher than IPPORT_RESERVEDSTART.  Traditionally the start value was
21517541Speter * 512, but that conflicts with some well-known-services that firewalls may
21617541Speter * have a fit if we use.
21717541Speter */
21817541Speter#define IPPORT_RESERVEDSTART	600
21917541Speter
22017541Speter/*
2211541Srgrimes * Internet address (a structure for historical reasons)
2221541Srgrimes */
2231541Srgrimesstruct in_addr {
22435919Sjb	u_int32_t s_addr;
2251541Srgrimes};
2261541Srgrimes
2271541Srgrimes/*
2281541Srgrimes * Definitions of bits in internet address integers.
2291541Srgrimes * On subnets, the decomposition of addresses to host and net parts
2301541Srgrimes * is done according to subnet mask, not the masks here.
2311541Srgrimes */
23235919Sjb#define	IN_CLASSA(i)		(((u_int32_t)(i) & 0x80000000) == 0)
2331541Srgrimes#define	IN_CLASSA_NET		0xff000000
2341541Srgrimes#define	IN_CLASSA_NSHIFT	24
2351541Srgrimes#define	IN_CLASSA_HOST		0x00ffffff
2361541Srgrimes#define	IN_CLASSA_MAX		128
2371541Srgrimes
23835919Sjb#define	IN_CLASSB(i)		(((u_int32_t)(i) & 0xc0000000) == 0x80000000)
2391541Srgrimes#define	IN_CLASSB_NET		0xffff0000
2401541Srgrimes#define	IN_CLASSB_NSHIFT	16
2411541Srgrimes#define	IN_CLASSB_HOST		0x0000ffff
2421541Srgrimes#define	IN_CLASSB_MAX		65536
2431541Srgrimes
24435919Sjb#define	IN_CLASSC(i)		(((u_int32_t)(i) & 0xe0000000) == 0xc0000000)
2451541Srgrimes#define	IN_CLASSC_NET		0xffffff00
2461541Srgrimes#define	IN_CLASSC_NSHIFT	8
2471541Srgrimes#define	IN_CLASSC_HOST		0x000000ff
2481541Srgrimes
24935919Sjb#define	IN_CLASSD(i)		(((u_int32_t)(i) & 0xf0000000) == 0xe0000000)
2501541Srgrimes#define	IN_CLASSD_NET		0xf0000000	/* These ones aren't really */
2511541Srgrimes#define	IN_CLASSD_NSHIFT	28		/* net and host fields, but */
2521541Srgrimes#define	IN_CLASSD_HOST		0x0fffffff	/* routing needn't know.    */
2531541Srgrimes#define	IN_MULTICAST(i)		IN_CLASSD(i)
2541541Srgrimes
25535919Sjb#define	IN_EXPERIMENTAL(i)	(((u_int32_t)(i) & 0xf0000000) == 0xf0000000)
25635919Sjb#define	IN_BADCLASS(i)		(((u_int32_t)(i) & 0xf0000000) == 0xf0000000)
2571541Srgrimes
25835919Sjb#define	INADDR_ANY		(u_int32_t)0x00000000
25935919Sjb#define	INADDR_LOOPBACK		(u_int32_t)0x7f000001
26035919Sjb#define	INADDR_BROADCAST	(u_int32_t)0xffffffff	/* must be masked */
2611541Srgrimes#ifndef KERNEL
2621541Srgrimes#define	INADDR_NONE		0xffffffff		/* -1 return */
2631541Srgrimes#endif
2641541Srgrimes
26535919Sjb#define	INADDR_UNSPEC_GROUP	(u_int32_t)0xe0000000	/* 224.0.0.0 */
26635919Sjb#define	INADDR_ALLHOSTS_GROUP	(u_int32_t)0xe0000001	/* 224.0.0.1 */
26735919Sjb#define	INADDR_ALLRTRS_GROUP	(u_int32_t)0xe0000002	/* 224.0.0.2 */
26835919Sjb#define	INADDR_MAX_LOCAL_GROUP	(u_int32_t)0xe00000ff	/* 224.0.0.255 */
2691541Srgrimes
2701541Srgrimes#define	IN_LOOPBACKNET		127			/* official! */
2711541Srgrimes
2721541Srgrimes/*
2731541Srgrimes * Socket address, internet style.
2741541Srgrimes */
2751541Srgrimesstruct sockaddr_in {
2761541Srgrimes	u_char	sin_len;
2771541Srgrimes	u_char	sin_family;
2781541Srgrimes	u_short	sin_port;
2791541Srgrimes	struct	in_addr sin_addr;
2801541Srgrimes	char	sin_zero[8];
2811541Srgrimes};
2821541Srgrimes
2831541Srgrimes/*
2841541Srgrimes * Structure used to describe IP options.
2851541Srgrimes * Used to store options internally, to pass them to a process,
2861541Srgrimes * or to restore options retrieved earlier.
2871541Srgrimes * The ip_dst is used for the first-hop gateway when using a source route
2881541Srgrimes * (this gets put into the header proper).
2891541Srgrimes */
2901541Srgrimesstruct ip_opts {
2911541Srgrimes	struct	in_addr ip_dst;		/* first hop, 0 w/o src rt */
2921541Srgrimes	char	ip_opts[40];		/* actually variable in size */
2931541Srgrimes};
2941541Srgrimes
2951541Srgrimes/*
2961541Srgrimes * Options for use with [gs]etsockopt at the IP level.
2971541Srgrimes * First word of comment is data type; bool is stored in int.
2981541Srgrimes */
2991541Srgrimes#define	IP_OPTIONS		1    /* buf/ip_opts; set/get IP options */
3001541Srgrimes#define	IP_HDRINCL		2    /* int; header is included with data */
3011541Srgrimes#define	IP_TOS			3    /* int; IP type of service and preced. */
3021541Srgrimes#define	IP_TTL			4    /* int; IP time to live */
3031541Srgrimes#define	IP_RECVOPTS		5    /* bool; receive all IP opts w/dgram */
3041541Srgrimes#define	IP_RECVRETOPTS		6    /* bool; receive IP opts for response */
3051541Srgrimes#define	IP_RECVDSTADDR		7    /* bool; receive IP dst addr w/dgram */
3061541Srgrimes#define	IP_RETOPTS		8    /* ip_opts; set/get IP options */
3071541Srgrimes#define	IP_MULTICAST_IF		9    /* u_char; set/get IP multicast i/f  */
3081541Srgrimes#define	IP_MULTICAST_TTL	10   /* u_char; set/get IP multicast ttl */
3091541Srgrimes#define	IP_MULTICAST_LOOP	11   /* u_char; set/get IP multicast loopback */
3101541Srgrimes#define	IP_ADD_MEMBERSHIP	12   /* ip_mreq; add an IP group membership */
3111541Srgrimes#define	IP_DROP_MEMBERSHIP	13   /* ip_mreq; drop an IP group membership */
3122531Swollman#define IP_MULTICAST_VIF	14   /* set/get IP mcast virt. iface */
3132531Swollman#define IP_RSVP_ON		15   /* enable RSVP in kernel */
3142531Swollman#define IP_RSVP_OFF		16   /* disable RSVP in kernel */
3159209Swollman#define IP_RSVP_VIF_ON		17   /* set RSVP per-vif socket */
3169209Swollman#define IP_RSVP_VIF_OFF		18   /* unset RSVP per-vif socket */
31714195Speter#define IP_PORTRANGE		19   /* int; range to choose for unspec port */
31819622Sfenner#define	IP_RECVIF		20   /* bool; receive reception if w/dgram */
3191541Srgrimes
32017758Ssos#define IP_FW_ADD     		50   /* add a firewall rule to chain */
32117758Ssos#define IP_FW_DEL    		51   /* delete a firewall rule from chain */
32217758Ssos#define IP_FW_FLUSH   		52   /* flush firewall rule chain */
32319035Salex#define IP_FW_ZERO    		53   /* clear single/all firewall counter(s) */
32417758Ssos#define IP_FW_GET     		54   /* get entire firewall rule chain */
32549350Sgreen#define IP_FW_RESETLOG		55   /* reset logging counters */
32617758Ssos
32741793Sluigi#define	IP_DUMMYNET_CONFIGURE	60   /* add/configure a dummynet pipe */
32841793Sluigi#define	IP_DUMMYNET_DEL		61   /* delete a dummynet pipe from chain */
32941793Sluigi#define	IP_DUMMYNET_FLUSH	62   /* flush dummynet */
33041793Sluigi#define	IP_DUMMYNET_GET		64   /* get entire dummynet pipes */
33141793Sluigi
3321541Srgrimes/*
3331541Srgrimes * Defaults and limits for options
3341541Srgrimes */
3351541Srgrimes#define	IP_DEFAULT_MULTICAST_TTL  1	/* normally limit m'casts to 1 hop  */
3361541Srgrimes#define	IP_DEFAULT_MULTICAST_LOOP 1	/* normally hear sends if a member  */
3379209Swollman#define	IP_MAX_MEMBERSHIPS	20	/* per socket */
3381541Srgrimes
3391541Srgrimes/*
3401541Srgrimes * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
3411541Srgrimes */
3421541Srgrimesstruct ip_mreq {
3431541Srgrimes	struct	in_addr imr_multiaddr;	/* IP multicast address of group */
3441541Srgrimes	struct	in_addr imr_interface;	/* local IP address of interface */
3451541Srgrimes};
3461541Srgrimes
3471541Srgrimes/*
34814195Speter * Argument for IP_PORTRANGE:
34914195Speter * - which range to search when port is unspecified at bind() or connect()
35014195Speter */
35114195Speter#define	IP_PORTRANGE_DEFAULT	0	/* default range */
35214195Speter#define	IP_PORTRANGE_HIGH	1	/* "high" - request firewall bypass */
35314195Speter#define	IP_PORTRANGE_LOW	2	/* "low" - vouchsafe security */
35414195Speter
35514195Speter/*
3561541Srgrimes * Definitions for inet sysctl operations.
3571541Srgrimes *
3581541Srgrimes * Third level is protocol number.
3591541Srgrimes * Fourth level is desired variable within that protocol.
3601541Srgrimes */
3611541Srgrimes#define	IPPROTO_MAXID	(IPPROTO_IDP + 1)	/* don't list to IPPROTO_MAX */
3621541Srgrimes
3631541Srgrimes#define	CTL_IPPROTO_NAMES { \
3641541Srgrimes	{ "ip", CTLTYPE_NODE }, \
3651541Srgrimes	{ "icmp", CTLTYPE_NODE }, \
3661541Srgrimes	{ "igmp", CTLTYPE_NODE }, \
3671541Srgrimes	{ "ggp", CTLTYPE_NODE }, \
3681541Srgrimes	{ 0, 0 }, \
3691541Srgrimes	{ 0, 0 }, \
3701541Srgrimes	{ "tcp", CTLTYPE_NODE }, \
3711541Srgrimes	{ 0, 0 }, \
3721541Srgrimes	{ "egp", CTLTYPE_NODE }, \
3731541Srgrimes	{ 0, 0 }, \
3741541Srgrimes	{ 0, 0 }, \
3751541Srgrimes	{ 0, 0 }, \
3761541Srgrimes	{ "pup", CTLTYPE_NODE }, \
3771541Srgrimes	{ 0, 0 }, \
3781541Srgrimes	{ 0, 0 }, \
3791541Srgrimes	{ 0, 0 }, \
3801541Srgrimes	{ 0, 0 }, \
3811541Srgrimes	{ "udp", CTLTYPE_NODE }, \
3821541Srgrimes	{ 0, 0 }, \
3831541Srgrimes	{ 0, 0 }, \
3841541Srgrimes	{ 0, 0 }, \
3851541Srgrimes	{ 0, 0 }, \
3861541Srgrimes	{ "idp", CTLTYPE_NODE }, \
3871541Srgrimes}
3881541Srgrimes
3891541Srgrimes/*
3901541Srgrimes * Names for IP sysctl objects
3911541Srgrimes */
3921541Srgrimes#define	IPCTL_FORWARDING	1	/* act as router */
3931541Srgrimes#define	IPCTL_SENDREDIRECTS	2	/* may send redirects when forwarding */
3941541Srgrimes#define	IPCTL_DEFTTL		3	/* default TTL */
3951541Srgrimes#ifdef notyet
3961541Srgrimes#define	IPCTL_DEFMTU		4	/* default MTU */
3971541Srgrimes#endif
3985109Swollman#define IPCTL_RTEXPIRE		5	/* cloned route expiration time */
3996399Swollman#define IPCTL_RTMINEXPIRE	6	/* min value for expiration time */
4006399Swollman#define IPCTL_RTMAXCACHE	7	/* trigger level for dynamic expire */
4017091Swollman#define	IPCTL_SOURCEROUTE	8	/* may perform source routes */
4029575Speter#define	IPCTL_DIRECTEDBROADCAST	9	/* may re-broadcast received packets */
40312003Swollman#define IPCTL_INTRQMAXLEN	10	/* max length of netisr queue */
40412003Swollman#define IPCTL_INTRQDROPS	11	/* number of netisr q drops */
40529838Swollman#define	IPCTL_STATS		12	/* ipstat structure */
40633440Sguido#define	IPCTL_ACCEPTSOURCEROUTE	13	/* may accept source routed packets */
40736192Sdg#define IPCTL_FASTFORWARDING	14	/* use fast IP forwarding code */
40836192Sdg#define	IPCTL_MAXID		15
4091541Srgrimes
4101541Srgrimes#define	IPCTL_NAMES { \
4111541Srgrimes	{ 0, 0 }, \
4121541Srgrimes	{ "forwarding", CTLTYPE_INT }, \
4131541Srgrimes	{ "redirect", CTLTYPE_INT }, \
4141541Srgrimes	{ "ttl", CTLTYPE_INT }, \
4151541Srgrimes	{ "mtu", CTLTYPE_INT }, \
4165109Swollman	{ "rtexpire", CTLTYPE_INT }, \
4176399Swollman	{ "rtminexpire", CTLTYPE_INT }, \
4186399Swollman	{ "rtmaxcache", CTLTYPE_INT }, \
4197091Swollman	{ "sourceroute", CTLTYPE_INT }, \
4209575Speter 	{ "directed-broadcast", CTLTYPE_INT }, \
42112003Swollman	{ "intr-queue-maxlen", CTLTYPE_INT }, \
42212003Swollman	{ "intr-queue-drops", CTLTYPE_INT }, \
42329838Swollman	{ "stats", CTLTYPE_STRUCT }, \
42433440Sguido	{ "accept_sourceroute", CTLTYPE_INT }, \
42536192Sdg	{ "fastforwarding", CTLTYPE_INT }, \
4261541Srgrimes}
4271541Srgrimes
4281541Srgrimes
4291541Srgrimes#ifdef KERNEL
4307088Swollmanstruct ifnet; struct mbuf;	/* forward declarations for Standard C */
43146696Speterstruct proc;
4327088Swollman
4331541Srgrimesint	 in_broadcast __P((struct in_addr, struct ifnet *));
4341541Srgrimesint	 in_canforward __P((struct in_addr));
4351541Srgrimesint	 in_cksum __P((struct mbuf *, int));
4361541Srgrimesint	 in_localaddr __P((struct in_addr));
4377088Swollmanchar 	*inet_ntoa __P((struct in_addr)); /* in libkern */
4382169Spaul
43946155Sphkint	prison_ip __P((struct proc *p, int flag, u_int32_t *ip));
44046155Sphkvoid	prison_remote_ip __P((struct proc *p, int flag, u_int32_t *ip));
44146155Sphk
44215026Sphk#endif /* KERNEL */
44315026Sphk
4442169Spaul#endif
445