in.h revision 35919
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
3435919Sjb * $Id: in.h,v 1.31 1998/04/19 17:22:27 phk Exp $
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*/
14333804Sjulian/* 101-254: Unassigned */
14433804Sjulian/* 255: Reserved */
14533804Sjulian/* BSD Private, local use, namespace incursion */
14617072Sjulian#define	IPPROTO_DIVERT		254		/* divert pseudo-protocol */
1471541Srgrimes#define	IPPROTO_RAW		255		/* raw IP packet */
1481541Srgrimes#define	IPPROTO_MAX		256
1491541Srgrimes
1501541Srgrimes
1511541Srgrimes/*
1521541Srgrimes * Local port number conventions:
15314195Speter *
15414195Speter * When a user does a bind(2) or connect(2) with a port number of zero,
15514195Speter * a non-conflicting local port address is chosen.
15614195Speter * The default range is IPPORT_RESERVED through
15714195Speter * IPPORT_USERRESERVED, although that is settable by sysctl.
15814195Speter *
15914195Speter * A user may set the IPPROTO_IP option IP_PORTRANGE to change this
16014195Speter * default assignment range.
16114195Speter *
16214195Speter * The value IP_PORTRANGE_DEFAULT causes the default behavior.
16314195Speter *
16414195Speter * The value IP_PORTRANGE_HIGH changes the range of candidate port numbers
16514195Speter * into the "high" range.  These are reserved for client outbound connections
16614195Speter * which do not want to be filtered by any firewalls.
16714195Speter *
16814195Speter * The value IP_PORTRANGE_LOW changes the range to the "low" are
16914195Speter * that is (by convention) restricted to privileged processes.  This
17014195Speter * convention is based on "vouchsafe" principles only.  It is only secure
17114195Speter * if you trust the remote host to restrict these ports.
17214195Speter *
17314195Speter * The default range of ports and the high range can be changed by
17417541Speter * sysctl(3).  (net.inet.ip.port{hi,low}{first,last}_auto)
17514195Speter *
17614195Speter * Changing those values has bad security implications if you are
17714195Speter * using a a stateless firewall that is allowing packets outside of that
17814195Speter * range in order to allow transparent outgoing connections.
17914195Speter *
18014195Speter * Such a firewall configuration will generally depend on the use of these
18114195Speter * default values.  If you change them, you may find your Security
18214195Speter * Administrator looking for you with a heavy object.
18335304Sphk *
18435304Sphk * For a slightly more orthodox text view on this:
18535304Sphk *
18635304Sphk *            ftp://ftp.isi.edu/in-notes/iana/assignments/port-numbers
18735304Sphk *
18835304Sphk *    port numbers are divided into three ranges:
18935304Sphk *
19035304Sphk *                0 -  1023 Well Known Ports
19135304Sphk *             1024 - 49151 Registered Ports
19235304Sphk *            49152 - 65535 Dynamic and/or Private Ports
19335304Sphk *
19414195Speter */
19514195Speter
19614195Speter/*
1971541Srgrimes * Ports < IPPORT_RESERVED are reserved for
19814195Speter * privileged processes (e.g. root).         (IP_PORTRANGE_LOW)
1991541Srgrimes * Ports > IPPORT_USERRESERVED are reserved
20014195Speter * for servers, not necessarily privileged.  (IP_PORTRANGE_DEFAULT)
2011541Srgrimes */
2021541Srgrimes#define	IPPORT_RESERVED		1024
2031541Srgrimes#define	IPPORT_USERRESERVED	5000
2041541Srgrimes
2051541Srgrimes/*
20614195Speter * Default local port range to use by setting IP_PORTRANGE_HIGH
20713491Speter */
20835304Sphk#define	IPPORT_HIFIRSTAUTO	49152
20935304Sphk#define	IPPORT_HILASTAUTO	65535
21013491Speter
21113491Speter/*
21217541Speter * Scanning for a free reserved port return a value below IPPORT_RESERVED,
21317541Speter * but higher than IPPORT_RESERVEDSTART.  Traditionally the start value was
21417541Speter * 512, but that conflicts with some well-known-services that firewalls may
21517541Speter * have a fit if we use.
21617541Speter */
21717541Speter#define IPPORT_RESERVEDSTART	600
21817541Speter
21917541Speter/*
2201541Srgrimes * Internet address (a structure for historical reasons)
2211541Srgrimes */
2221541Srgrimesstruct in_addr {
22335919Sjb	u_int32_t s_addr;
2241541Srgrimes};
2251541Srgrimes
2261541Srgrimes/*
2271541Srgrimes * Definitions of bits in internet address integers.
2281541Srgrimes * On subnets, the decomposition of addresses to host and net parts
2291541Srgrimes * is done according to subnet mask, not the masks here.
2301541Srgrimes */
23135919Sjb#define	IN_CLASSA(i)		(((u_int32_t)(i) & 0x80000000) == 0)
2321541Srgrimes#define	IN_CLASSA_NET		0xff000000
2331541Srgrimes#define	IN_CLASSA_NSHIFT	24
2341541Srgrimes#define	IN_CLASSA_HOST		0x00ffffff
2351541Srgrimes#define	IN_CLASSA_MAX		128
2361541Srgrimes
23735919Sjb#define	IN_CLASSB(i)		(((u_int32_t)(i) & 0xc0000000) == 0x80000000)
2381541Srgrimes#define	IN_CLASSB_NET		0xffff0000
2391541Srgrimes#define	IN_CLASSB_NSHIFT	16
2401541Srgrimes#define	IN_CLASSB_HOST		0x0000ffff
2411541Srgrimes#define	IN_CLASSB_MAX		65536
2421541Srgrimes
24335919Sjb#define	IN_CLASSC(i)		(((u_int32_t)(i) & 0xe0000000) == 0xc0000000)
2441541Srgrimes#define	IN_CLASSC_NET		0xffffff00
2451541Srgrimes#define	IN_CLASSC_NSHIFT	8
2461541Srgrimes#define	IN_CLASSC_HOST		0x000000ff
2471541Srgrimes
24835919Sjb#define	IN_CLASSD(i)		(((u_int32_t)(i) & 0xf0000000) == 0xe0000000)
2491541Srgrimes#define	IN_CLASSD_NET		0xf0000000	/* These ones aren't really */
2501541Srgrimes#define	IN_CLASSD_NSHIFT	28		/* net and host fields, but */
2511541Srgrimes#define	IN_CLASSD_HOST		0x0fffffff	/* routing needn't know.    */
2521541Srgrimes#define	IN_MULTICAST(i)		IN_CLASSD(i)
2531541Srgrimes
25435919Sjb#define	IN_EXPERIMENTAL(i)	(((u_int32_t)(i) & 0xf0000000) == 0xf0000000)
25535919Sjb#define	IN_BADCLASS(i)		(((u_int32_t)(i) & 0xf0000000) == 0xf0000000)
2561541Srgrimes
25735919Sjb#define	INADDR_ANY		(u_int32_t)0x00000000
25835919Sjb#define	INADDR_LOOPBACK		(u_int32_t)0x7f000001
25935919Sjb#define	INADDR_BROADCAST	(u_int32_t)0xffffffff	/* must be masked */
2601541Srgrimes#ifndef KERNEL
2611541Srgrimes#define	INADDR_NONE		0xffffffff		/* -1 return */
2621541Srgrimes#endif
2631541Srgrimes
26435919Sjb#define	INADDR_UNSPEC_GROUP	(u_int32_t)0xe0000000	/* 224.0.0.0 */
26535919Sjb#define	INADDR_ALLHOSTS_GROUP	(u_int32_t)0xe0000001	/* 224.0.0.1 */
26635919Sjb#define	INADDR_ALLRTRS_GROUP	(u_int32_t)0xe0000002	/* 224.0.0.2 */
26735919Sjb#define	INADDR_MAX_LOCAL_GROUP	(u_int32_t)0xe00000ff	/* 224.0.0.255 */
2681541Srgrimes
2691541Srgrimes#define	IN_LOOPBACKNET		127			/* official! */
2701541Srgrimes
2711541Srgrimes/*
2721541Srgrimes * Socket address, internet style.
2731541Srgrimes */
2741541Srgrimesstruct sockaddr_in {
2751541Srgrimes	u_char	sin_len;
2761541Srgrimes	u_char	sin_family;
2771541Srgrimes	u_short	sin_port;
2781541Srgrimes	struct	in_addr sin_addr;
2791541Srgrimes	char	sin_zero[8];
2801541Srgrimes};
2811541Srgrimes
2821541Srgrimes/*
2831541Srgrimes * Structure used to describe IP options.
2841541Srgrimes * Used to store options internally, to pass them to a process,
2851541Srgrimes * or to restore options retrieved earlier.
2861541Srgrimes * The ip_dst is used for the first-hop gateway when using a source route
2871541Srgrimes * (this gets put into the header proper).
2881541Srgrimes */
2891541Srgrimesstruct ip_opts {
2901541Srgrimes	struct	in_addr ip_dst;		/* first hop, 0 w/o src rt */
2911541Srgrimes	char	ip_opts[40];		/* actually variable in size */
2921541Srgrimes};
2931541Srgrimes
2941541Srgrimes/*
2951541Srgrimes * Options for use with [gs]etsockopt at the IP level.
2961541Srgrimes * First word of comment is data type; bool is stored in int.
2971541Srgrimes */
2981541Srgrimes#define	IP_OPTIONS		1    /* buf/ip_opts; set/get IP options */
2991541Srgrimes#define	IP_HDRINCL		2    /* int; header is included with data */
3001541Srgrimes#define	IP_TOS			3    /* int; IP type of service and preced. */
3011541Srgrimes#define	IP_TTL			4    /* int; IP time to live */
3021541Srgrimes#define	IP_RECVOPTS		5    /* bool; receive all IP opts w/dgram */
3031541Srgrimes#define	IP_RECVRETOPTS		6    /* bool; receive IP opts for response */
3041541Srgrimes#define	IP_RECVDSTADDR		7    /* bool; receive IP dst addr w/dgram */
3051541Srgrimes#define	IP_RETOPTS		8    /* ip_opts; set/get IP options */
3061541Srgrimes#define	IP_MULTICAST_IF		9    /* u_char; set/get IP multicast i/f  */
3071541Srgrimes#define	IP_MULTICAST_TTL	10   /* u_char; set/get IP multicast ttl */
3081541Srgrimes#define	IP_MULTICAST_LOOP	11   /* u_char; set/get IP multicast loopback */
3091541Srgrimes#define	IP_ADD_MEMBERSHIP	12   /* ip_mreq; add an IP group membership */
3101541Srgrimes#define	IP_DROP_MEMBERSHIP	13   /* ip_mreq; drop an IP group membership */
3112531Swollman#define IP_MULTICAST_VIF	14   /* set/get IP mcast virt. iface */
3122531Swollman#define IP_RSVP_ON		15   /* enable RSVP in kernel */
3132531Swollman#define IP_RSVP_OFF		16   /* disable RSVP in kernel */
3149209Swollman#define IP_RSVP_VIF_ON		17   /* set RSVP per-vif socket */
3159209Swollman#define IP_RSVP_VIF_OFF		18   /* unset RSVP per-vif socket */
31614195Speter#define IP_PORTRANGE		19   /* int; range to choose for unspec port */
31719622Sfenner#define	IP_RECVIF		20   /* bool; receive reception if w/dgram */
3181541Srgrimes
31917758Ssos#define IP_FW_ADD     		50   /* add a firewall rule to chain */
32017758Ssos#define IP_FW_DEL    		51   /* delete a firewall rule from chain */
32117758Ssos#define IP_FW_FLUSH   		52   /* flush firewall rule chain */
32219035Salex#define IP_FW_ZERO    		53   /* clear single/all firewall counter(s) */
32317758Ssos#define IP_FW_GET     		54   /* get entire firewall rule chain */
32417758Ssos#define IP_NAT			55   /* set/get NAT opts */
32517758Ssos
3261541Srgrimes/*
3271541Srgrimes * Defaults and limits for options
3281541Srgrimes */
3291541Srgrimes#define	IP_DEFAULT_MULTICAST_TTL  1	/* normally limit m'casts to 1 hop  */
3301541Srgrimes#define	IP_DEFAULT_MULTICAST_LOOP 1	/* normally hear sends if a member  */
3319209Swollman#define	IP_MAX_MEMBERSHIPS	20	/* per socket */
3321541Srgrimes
3331541Srgrimes/*
3341541Srgrimes * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
3351541Srgrimes */
3361541Srgrimesstruct ip_mreq {
3371541Srgrimes	struct	in_addr imr_multiaddr;	/* IP multicast address of group */
3381541Srgrimes	struct	in_addr imr_interface;	/* local IP address of interface */
3391541Srgrimes};
3401541Srgrimes
3411541Srgrimes/*
34214195Speter * Argument for IP_PORTRANGE:
34314195Speter * - which range to search when port is unspecified at bind() or connect()
34414195Speter */
34514195Speter#define	IP_PORTRANGE_DEFAULT	0	/* default range */
34614195Speter#define	IP_PORTRANGE_HIGH	1	/* "high" - request firewall bypass */
34714195Speter#define	IP_PORTRANGE_LOW	2	/* "low" - vouchsafe security */
34814195Speter
34914195Speter/*
3501541Srgrimes * Definitions for inet sysctl operations.
3511541Srgrimes *
3521541Srgrimes * Third level is protocol number.
3531541Srgrimes * Fourth level is desired variable within that protocol.
3541541Srgrimes */
3551541Srgrimes#define	IPPROTO_MAXID	(IPPROTO_IDP + 1)	/* don't list to IPPROTO_MAX */
3561541Srgrimes
3571541Srgrimes#define	CTL_IPPROTO_NAMES { \
3581541Srgrimes	{ "ip", CTLTYPE_NODE }, \
3591541Srgrimes	{ "icmp", CTLTYPE_NODE }, \
3601541Srgrimes	{ "igmp", CTLTYPE_NODE }, \
3611541Srgrimes	{ "ggp", CTLTYPE_NODE }, \
3621541Srgrimes	{ 0, 0 }, \
3631541Srgrimes	{ 0, 0 }, \
3641541Srgrimes	{ "tcp", CTLTYPE_NODE }, \
3651541Srgrimes	{ 0, 0 }, \
3661541Srgrimes	{ "egp", CTLTYPE_NODE }, \
3671541Srgrimes	{ 0, 0 }, \
3681541Srgrimes	{ 0, 0 }, \
3691541Srgrimes	{ 0, 0 }, \
3701541Srgrimes	{ "pup", CTLTYPE_NODE }, \
3711541Srgrimes	{ 0, 0 }, \
3721541Srgrimes	{ 0, 0 }, \
3731541Srgrimes	{ 0, 0 }, \
3741541Srgrimes	{ 0, 0 }, \
3751541Srgrimes	{ "udp", CTLTYPE_NODE }, \
3761541Srgrimes	{ 0, 0 }, \
3771541Srgrimes	{ 0, 0 }, \
3781541Srgrimes	{ 0, 0 }, \
3791541Srgrimes	{ 0, 0 }, \
3801541Srgrimes	{ "idp", CTLTYPE_NODE }, \
3811541Srgrimes}
3821541Srgrimes
3831541Srgrimes/*
3841541Srgrimes * Names for IP sysctl objects
3851541Srgrimes */
3861541Srgrimes#define	IPCTL_FORWARDING	1	/* act as router */
3871541Srgrimes#define	IPCTL_SENDREDIRECTS	2	/* may send redirects when forwarding */
3881541Srgrimes#define	IPCTL_DEFTTL		3	/* default TTL */
3891541Srgrimes#ifdef notyet
3901541Srgrimes#define	IPCTL_DEFMTU		4	/* default MTU */
3911541Srgrimes#endif
3925109Swollman#define IPCTL_RTEXPIRE		5	/* cloned route expiration time */
3936399Swollman#define IPCTL_RTMINEXPIRE	6	/* min value for expiration time */
3946399Swollman#define IPCTL_RTMAXCACHE	7	/* trigger level for dynamic expire */
3957091Swollman#define	IPCTL_SOURCEROUTE	8	/* may perform source routes */
3969575Speter#define	IPCTL_DIRECTEDBROADCAST	9	/* may re-broadcast received packets */
39712003Swollman#define IPCTL_INTRQMAXLEN	10	/* max length of netisr queue */
39812003Swollman#define IPCTL_INTRQDROPS	11	/* number of netisr q drops */
39929838Swollman#define	IPCTL_STATS		12	/* ipstat structure */
40033440Sguido#define	IPCTL_ACCEPTSOURCEROUTE	13	/* may accept source routed packets */
40133440Sguido#define	IPCTL_MAXID		14
4021541Srgrimes
4031541Srgrimes#define	IPCTL_NAMES { \
4041541Srgrimes	{ 0, 0 }, \
4051541Srgrimes	{ "forwarding", CTLTYPE_INT }, \
4061541Srgrimes	{ "redirect", CTLTYPE_INT }, \
4071541Srgrimes	{ "ttl", CTLTYPE_INT }, \
4081541Srgrimes	{ "mtu", CTLTYPE_INT }, \
4095109Swollman	{ "rtexpire", CTLTYPE_INT }, \
4106399Swollman	{ "rtminexpire", CTLTYPE_INT }, \
4116399Swollman	{ "rtmaxcache", CTLTYPE_INT }, \
4127091Swollman	{ "sourceroute", CTLTYPE_INT }, \
4139575Speter 	{ "directed-broadcast", CTLTYPE_INT }, \
41412003Swollman	{ "intr-queue-maxlen", CTLTYPE_INT }, \
41512003Swollman	{ "intr-queue-drops", CTLTYPE_INT }, \
41629838Swollman	{ "stats", CTLTYPE_STRUCT }, \
41733440Sguido	{ "accept_sourceroute", CTLTYPE_INT }, \
4181541Srgrimes}
4191541Srgrimes
4201541Srgrimes
4211541Srgrimes#ifdef KERNEL
4227088Swollmanstruct ifnet; struct mbuf;	/* forward declarations for Standard C */
4237088Swollman
4241541Srgrimesint	 in_broadcast __P((struct in_addr, struct ifnet *));
4251541Srgrimesint	 in_canforward __P((struct in_addr));
4261541Srgrimesint	 in_cksum __P((struct mbuf *, int));
4271541Srgrimesint	 in_localaddr __P((struct in_addr));
4287088Swollmanchar 	*inet_ntoa __P((struct in_addr)); /* in libkern */
4292169Spaul
43015026Sphk/* Firewall hooks */
43115026Sphkstruct ip;
43217758Ssostypedef	int ip_fw_chk_t __P((struct ip**, int, struct ifnet*, int, struct mbuf**));
43317758Ssostypedef	int ip_fw_ctl_t __P((int, struct mbuf**));
43417758Ssosextern	ip_fw_chk_t *ip_fw_chk_ptr;
43517758Ssosextern	ip_fw_ctl_t *ip_fw_ctl_ptr;
43617758Ssos
43719035Salex/* IP NAT hooks */
43819113Ssostypedef	int ip_nat_t __P((struct ip**, struct mbuf**, struct ifnet*, int));
43917758Ssostypedef	int ip_nat_ctl_t __P((int, struct mbuf**));
44017758Ssosextern	ip_nat_t *ip_nat_ptr;
44117758Ssosextern	ip_nat_ctl_t *ip_nat_ctl_ptr;
44217758Ssos#define	IP_NAT_IN	0x00000001
44317758Ssos#define	IP_NAT_OUT	0x00000002
44417758Ssos
44515026Sphk#endif /* KERNEL */
44615026Sphk
4472169Spaul#endif
448