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 40df8bae1dSRodney W. Grimes /* 41df8bae1dSRodney W. Grimes * Constants and structures defined by the internet system, 42df8bae1dSRodney W. Grimes * Per RFC 790, September 1981, and numerous additions. 43df8bae1dSRodney W. Grimes */ 44df8bae1dSRodney W. Grimes 45df8bae1dSRodney W. Grimes /* 46cfaa93b2SJulian Elischer * Protocols (RFC 1700) 47df8bae1dSRodney W. Grimes */ 48df8bae1dSRodney W. Grimes #define IPPROTO_IP 0 /* dummy for IP */ 4976429de4SYoshinobu Inoue #define IPPROTO_HOPOPTS 0 /* IP6 hop-by-hop options */ 50df8bae1dSRodney W. Grimes #define IPPROTO_ICMP 1 /* control message protocol */ 51df8bae1dSRodney W. Grimes #define IPPROTO_IGMP 2 /* group mgmt protocol */ 52df8bae1dSRodney W. Grimes #define IPPROTO_GGP 3 /* gateway^2 (deprecated) */ 5376429de4SYoshinobu Inoue #define IPPROTO_IPV4 4 /* IPv4 encapsulation */ 5476429de4SYoshinobu Inoue #define IPPROTO_IPIP IPPROTO_IPV4 /* for compatibility */ 55df8bae1dSRodney W. Grimes #define IPPROTO_TCP 6 /* tcp */ 56cfaa93b2SJulian Elischer #define IPPROTO_ST 7 /* Stream protocol II */ 57df8bae1dSRodney W. Grimes #define IPPROTO_EGP 8 /* exterior gateway protocol */ 58cfaa93b2SJulian Elischer #define IPPROTO_PIGP 9 /* private interior gateway */ 59cfaa93b2SJulian Elischer #define IPPROTO_RCCMON 10 /* BBN RCC Monitoring */ 60cfaa93b2SJulian Elischer #define IPPROTO_NVPII 11 /* network voice protocol*/ 61df8bae1dSRodney W. Grimes #define IPPROTO_PUP 12 /* pup */ 62cfaa93b2SJulian Elischer #define IPPROTO_ARGUS 13 /* Argus */ 63cfaa93b2SJulian Elischer #define IPPROTO_EMCON 14 /* EMCON */ 64cfaa93b2SJulian Elischer #define IPPROTO_XNET 15 /* Cross Net Debugger */ 65cfaa93b2SJulian Elischer #define IPPROTO_CHAOS 16 /* Chaos*/ 66df8bae1dSRodney W. Grimes #define IPPROTO_UDP 17 /* user datagram protocol */ 67cfaa93b2SJulian Elischer #define IPPROTO_MUX 18 /* Multiplexing */ 68cfaa93b2SJulian Elischer #define IPPROTO_MEAS 19 /* DCN Measurement Subsystems */ 69cfaa93b2SJulian Elischer #define IPPROTO_HMP 20 /* Host Monitoring */ 70cfaa93b2SJulian Elischer #define IPPROTO_PRM 21 /* Packet Radio Measurement */ 71df8bae1dSRodney W. Grimes #define IPPROTO_IDP 22 /* xns idp */ 72cfaa93b2SJulian Elischer #define IPPROTO_TRUNK1 23 /* Trunk-1 */ 73cfaa93b2SJulian Elischer #define IPPROTO_TRUNK2 24 /* Trunk-2 */ 74cfaa93b2SJulian Elischer #define IPPROTO_LEAF1 25 /* Leaf-1 */ 75cfaa93b2SJulian Elischer #define IPPROTO_LEAF2 26 /* Leaf-2 */ 76cfaa93b2SJulian Elischer #define IPPROTO_RDP 27 /* Reliable Data */ 77cfaa93b2SJulian Elischer #define IPPROTO_IRTP 28 /* Reliable Transaction */ 78df8bae1dSRodney W. Grimes #define IPPROTO_TP 29 /* tp-4 w/ class negotiation */ 79cfaa93b2SJulian Elischer #define IPPROTO_BLT 30 /* Bulk Data Transfer */ 80cfaa93b2SJulian Elischer #define IPPROTO_NSP 31 /* Network Services */ 81cfaa93b2SJulian Elischer #define IPPROTO_INP 32 /* Merit Internodal */ 82cfaa93b2SJulian Elischer #define IPPROTO_SEP 33 /* Sequential Exchange */ 83cfaa93b2SJulian Elischer #define IPPROTO_3PC 34 /* Third Party Connect */ 84cfaa93b2SJulian Elischer #define IPPROTO_IDPR 35 /* InterDomain Policy Routing */ 85cfaa93b2SJulian Elischer #define IPPROTO_XTP 36 /* XTP */ 86cfaa93b2SJulian Elischer #define IPPROTO_DDP 37 /* Datagram Delivery */ 87cfaa93b2SJulian Elischer #define IPPROTO_CMTP 38 /* Control Message Transport */ 88cfaa93b2SJulian Elischer #define IPPROTO_TPXX 39 /* TP++ Transport */ 89cfaa93b2SJulian Elischer #define IPPROTO_IL 40 /* IL transport protocol */ 9076429de4SYoshinobu Inoue #define IPPROTO_IPV6 41 /* IP6 header */ 91cfaa93b2SJulian Elischer #define IPPROTO_SDRP 42 /* Source Demand Routing */ 9276429de4SYoshinobu Inoue #define IPPROTO_ROUTING 43 /* IP6 routing header */ 9376429de4SYoshinobu Inoue #define IPPROTO_FRAGMENT 44 /* IP6 fragmentation header */ 94cfaa93b2SJulian Elischer #define IPPROTO_IDRP 45 /* InterDomain Routing*/ 95f0068c4aSGarrett Wollman #define IPPROTO_RSVP 46 /* resource reservation */ 96cfaa93b2SJulian Elischer #define IPPROTO_GRE 47 /* General Routing Encap. */ 97cfaa93b2SJulian Elischer #define IPPROTO_MHRP 48 /* Mobile Host Routing */ 98cfaa93b2SJulian Elischer #define IPPROTO_BHA 49 /* BHA */ 9976429de4SYoshinobu Inoue #define IPPROTO_ESP 50 /* IP6 Encap Sec. Payload */ 10076429de4SYoshinobu Inoue #define IPPROTO_AH 51 /* IP6 Auth Header */ 101cfaa93b2SJulian Elischer #define IPPROTO_INLSP 52 /* Integ. Net Layer Security */ 102cfaa93b2SJulian Elischer #define IPPROTO_SWIPE 53 /* IP with encryption */ 103cfaa93b2SJulian Elischer #define IPPROTO_NHRP 54 /* Next Hop Resolution */ 104e61c4bedSJeroen Ruigrok van der Werven #define IPPROTO_MOBILE 55 /* IP Mobility */ 105e61c4bedSJeroen Ruigrok van der Werven #define IPPROTO_TLSP 56 /* Transport Layer Security */ 106e61c4bedSJeroen Ruigrok van der Werven #define IPPROTO_SKIP 57 /* SKIP */ 10776429de4SYoshinobu Inoue #define IPPROTO_ICMPV6 58 /* ICMP6 */ 10876429de4SYoshinobu Inoue #define IPPROTO_NONE 59 /* IP6 no next header */ 10976429de4SYoshinobu Inoue #define IPPROTO_DSTOPTS 60 /* IP6 destination option */ 110cfaa93b2SJulian Elischer #define IPPROTO_AHIP 61 /* any host internal protocol */ 111cfaa93b2SJulian Elischer #define IPPROTO_CFTP 62 /* CFTP */ 112cfaa93b2SJulian Elischer #define IPPROTO_HELLO 63 /* "hello" routing protocol */ 113cfaa93b2SJulian Elischer #define IPPROTO_SATEXPAK 64 /* SATNET/Backroom EXPAK */ 114cfaa93b2SJulian Elischer #define IPPROTO_KRYPTOLAN 65 /* Kryptolan */ 115cfaa93b2SJulian Elischer #define IPPROTO_RVD 66 /* Remote Virtual Disk */ 116cfaa93b2SJulian Elischer #define IPPROTO_IPPC 67 /* Pluribus Packet Core */ 117cfaa93b2SJulian Elischer #define IPPROTO_ADFS 68 /* Any distributed FS */ 118cfaa93b2SJulian Elischer #define IPPROTO_SATMON 69 /* Satnet Monitoring */ 119cfaa93b2SJulian Elischer #define IPPROTO_VISA 70 /* VISA Protocol */ 120cfaa93b2SJulian Elischer #define IPPROTO_IPCV 71 /* Packet Core Utility */ 121cfaa93b2SJulian Elischer #define IPPROTO_CPNX 72 /* Comp. Prot. Net. Executive */ 122cfaa93b2SJulian Elischer #define IPPROTO_CPHB 73 /* Comp. Prot. HeartBeat */ 123cfaa93b2SJulian Elischer #define IPPROTO_WSN 74 /* Wang Span Network */ 124cfaa93b2SJulian Elischer #define IPPROTO_PVP 75 /* Packet Video Protocol */ 125cfaa93b2SJulian Elischer #define IPPROTO_BRSATMON 76 /* BackRoom SATNET Monitoring */ 126cfaa93b2SJulian Elischer #define IPPROTO_ND 77 /* Sun net disk proto (temp.) */ 127cfaa93b2SJulian Elischer #define IPPROTO_WBMON 78 /* WIDEBAND Monitoring */ 128cfaa93b2SJulian Elischer #define IPPROTO_WBEXPAK 79 /* WIDEBAND EXPAK */ 129df8bae1dSRodney W. Grimes #define IPPROTO_EON 80 /* ISO cnlp */ 130cfaa93b2SJulian Elischer #define IPPROTO_VMTP 81 /* VMTP */ 131cfaa93b2SJulian Elischer #define IPPROTO_SVMTP 82 /* Secure VMTP */ 132cfaa93b2SJulian Elischer #define IPPROTO_VINES 83 /* Banyon VINES */ 133cfaa93b2SJulian Elischer #define IPPROTO_TTP 84 /* TTP */ 134cfaa93b2SJulian Elischer #define IPPROTO_IGP 85 /* NSFNET-IGP */ 135cfaa93b2SJulian Elischer #define IPPROTO_DGP 86 /* dissimilar gateway prot. */ 13647f049d7SJulian Elischer #define IPPROTO_TCF 87 /* TCF */ 137cfaa93b2SJulian Elischer #define IPPROTO_IGRP 88 /* Cisco/GXS IGRP */ 138cfaa93b2SJulian Elischer #define IPPROTO_OSPFIGP 89 /* OSPFIGP */ 139cfaa93b2SJulian Elischer #define IPPROTO_SRPC 90 /* Strite RPC protocol */ 140cfaa93b2SJulian Elischer #define IPPROTO_LARP 91 /* Locus Address Resoloution */ 141cfaa93b2SJulian Elischer #define IPPROTO_MTP 92 /* Multicast Transport */ 142cfaa93b2SJulian Elischer #define IPPROTO_AX25 93 /* AX.25 Frames */ 143cfaa93b2SJulian Elischer #define IPPROTO_IPEIP 94 /* IP encapsulated in IP */ 144cfaa93b2SJulian Elischer #define IPPROTO_MICP 95 /* Mobile Int.ing control */ 145cfaa93b2SJulian Elischer #define IPPROTO_SCCSP 96 /* Semaphore Comm. security */ 146cfaa93b2SJulian Elischer #define IPPROTO_ETHERIP 97 /* Ethernet IP encapsulation */ 147df8bae1dSRodney W. Grimes #define IPPROTO_ENCAP 98 /* encapsulation header */ 148cfaa93b2SJulian Elischer #define IPPROTO_APES 99 /* any private encr. scheme */ 149cfaa93b2SJulian Elischer #define IPPROTO_GMTP 100 /* GMTP*/ 15076429de4SYoshinobu Inoue #define IPPROTO_IPCOMP 108 /* payload compression (IPComp) */ 151eaa726beSLuigi Rizzo /* 101-254: Partly Unassigned */ 15276429de4SYoshinobu Inoue #define IPPROTO_PIM 103 /* Protocol Independent Mcast */ 153eaa726beSLuigi Rizzo #define IPPROTO_PGM 113 /* PGM */ 154cfaa93b2SJulian Elischer /* 255: Reserved */ 155cfaa93b2SJulian Elischer /* BSD Private, local use, namespace incursion */ 15693e0e116SJulian Elischer #define IPPROTO_DIVERT 254 /* divert pseudo-protocol */ 157df8bae1dSRodney W. Grimes #define IPPROTO_RAW 255 /* raw IP packet */ 158df8bae1dSRodney W. Grimes #define IPPROTO_MAX 256 159df8bae1dSRodney W. Grimes 16076429de4SYoshinobu Inoue /* last return value of *_input(), meaning "all job for this pkt is done". */ 16176429de4SYoshinobu Inoue #define IPPROTO_DONE 257 162df8bae1dSRodney W. Grimes 163df8bae1dSRodney W. Grimes /* 164df8bae1dSRodney W. Grimes * Local port number conventions: 16533b3ac06SPeter Wemm * 16633b3ac06SPeter Wemm * When a user does a bind(2) or connect(2) with a port number of zero, 16733b3ac06SPeter Wemm * a non-conflicting local port address is chosen. 16833b3ac06SPeter Wemm * The default range is IPPORT_RESERVED through 16933b3ac06SPeter Wemm * IPPORT_USERRESERVED, although that is settable by sysctl. 17033b3ac06SPeter Wemm * 17133b3ac06SPeter Wemm * A user may set the IPPROTO_IP option IP_PORTRANGE to change this 17233b3ac06SPeter Wemm * default assignment range. 17333b3ac06SPeter Wemm * 17433b3ac06SPeter Wemm * The value IP_PORTRANGE_DEFAULT causes the default behavior. 17533b3ac06SPeter Wemm * 17633b3ac06SPeter Wemm * The value IP_PORTRANGE_HIGH changes the range of candidate port numbers 17733b3ac06SPeter Wemm * into the "high" range. These are reserved for client outbound connections 17833b3ac06SPeter Wemm * which do not want to be filtered by any firewalls. 17933b3ac06SPeter Wemm * 18033b3ac06SPeter Wemm * The value IP_PORTRANGE_LOW changes the range to the "low" are 18133b3ac06SPeter Wemm * that is (by convention) restricted to privileged processes. This 18233b3ac06SPeter Wemm * convention is based on "vouchsafe" principles only. It is only secure 18333b3ac06SPeter Wemm * if you trust the remote host to restrict these ports. 18433b3ac06SPeter Wemm * 18533b3ac06SPeter Wemm * The default range of ports and the high range can be changed by 186bbd42ad0SPeter Wemm * sysctl(3). (net.inet.ip.port{hi,low}{first,last}_auto) 18733b3ac06SPeter Wemm * 18833b3ac06SPeter Wemm * Changing those values has bad security implications if you are 18933b3ac06SPeter Wemm * using a a stateless firewall that is allowing packets outside of that 19033b3ac06SPeter Wemm * range in order to allow transparent outgoing connections. 19133b3ac06SPeter Wemm * 19233b3ac06SPeter Wemm * Such a firewall configuration will generally depend on the use of these 19333b3ac06SPeter Wemm * default values. If you change them, you may find your Security 19433b3ac06SPeter Wemm * Administrator looking for you with a heavy object. 1954565cbeaSPoul-Henning Kamp * 1964565cbeaSPoul-Henning Kamp * For a slightly more orthodox text view on this: 1974565cbeaSPoul-Henning Kamp * 1984565cbeaSPoul-Henning Kamp * ftp://ftp.isi.edu/in-notes/iana/assignments/port-numbers 1994565cbeaSPoul-Henning Kamp * 2004565cbeaSPoul-Henning Kamp * port numbers are divided into three ranges: 2014565cbeaSPoul-Henning Kamp * 2024565cbeaSPoul-Henning Kamp * 0 - 1023 Well Known Ports 2034565cbeaSPoul-Henning Kamp * 1024 - 49151 Registered Ports 2044565cbeaSPoul-Henning Kamp * 49152 - 65535 Dynamic and/or Private Ports 2054565cbeaSPoul-Henning Kamp * 20633b3ac06SPeter Wemm */ 20733b3ac06SPeter Wemm 20833b3ac06SPeter Wemm /* 209df8bae1dSRodney W. Grimes * Ports < IPPORT_RESERVED are reserved for 21033b3ac06SPeter Wemm * privileged processes (e.g. root). (IP_PORTRANGE_LOW) 211df8bae1dSRodney W. Grimes * Ports > IPPORT_USERRESERVED are reserved 21233b3ac06SPeter Wemm * for servers, not necessarily privileged. (IP_PORTRANGE_DEFAULT) 213df8bae1dSRodney W. Grimes */ 214df8bae1dSRodney W. Grimes #define IPPORT_RESERVED 1024 215df8bae1dSRodney W. Grimes #define IPPORT_USERRESERVED 5000 216df8bae1dSRodney W. Grimes 217df8bae1dSRodney W. Grimes /* 21833b3ac06SPeter Wemm * Default local port range to use by setting IP_PORTRANGE_HIGH 219101f9fc8SPeter Wemm */ 2204565cbeaSPoul-Henning Kamp #define IPPORT_HIFIRSTAUTO 49152 2214565cbeaSPoul-Henning Kamp #define IPPORT_HILASTAUTO 65535 222101f9fc8SPeter Wemm 223101f9fc8SPeter Wemm /* 224bbd42ad0SPeter Wemm * Scanning for a free reserved port return a value below IPPORT_RESERVED, 225bbd42ad0SPeter Wemm * but higher than IPPORT_RESERVEDSTART. Traditionally the start value was 226bbd42ad0SPeter Wemm * 512, but that conflicts with some well-known-services that firewalls may 227bbd42ad0SPeter Wemm * have a fit if we use. 228bbd42ad0SPeter Wemm */ 229bbd42ad0SPeter Wemm #define IPPORT_RESERVEDSTART 600 230bbd42ad0SPeter Wemm 231bbd42ad0SPeter Wemm /* 232df8bae1dSRodney W. Grimes * Internet address (a structure for historical reasons) 233df8bae1dSRodney W. Grimes */ 234df8bae1dSRodney W. Grimes struct in_addr { 235fac6d93bSJohn Birrell u_int32_t s_addr; 236df8bae1dSRodney W. Grimes }; 237df8bae1dSRodney W. Grimes 238df8bae1dSRodney W. Grimes /* 239df8bae1dSRodney W. Grimes * Definitions of bits in internet address integers. 240df8bae1dSRodney W. Grimes * On subnets, the decomposition of addresses to host and net parts 241df8bae1dSRodney W. Grimes * is done according to subnet mask, not the masks here. 242df8bae1dSRodney W. Grimes */ 243fac6d93bSJohn Birrell #define IN_CLASSA(i) (((u_int32_t)(i) & 0x80000000) == 0) 244df8bae1dSRodney W. Grimes #define IN_CLASSA_NET 0xff000000 245df8bae1dSRodney W. Grimes #define IN_CLASSA_NSHIFT 24 246df8bae1dSRodney W. Grimes #define IN_CLASSA_HOST 0x00ffffff 247df8bae1dSRodney W. Grimes #define IN_CLASSA_MAX 128 248df8bae1dSRodney W. Grimes 249fac6d93bSJohn Birrell #define IN_CLASSB(i) (((u_int32_t)(i) & 0xc0000000) == 0x80000000) 250df8bae1dSRodney W. Grimes #define IN_CLASSB_NET 0xffff0000 251df8bae1dSRodney W. Grimes #define IN_CLASSB_NSHIFT 16 252df8bae1dSRodney W. Grimes #define IN_CLASSB_HOST 0x0000ffff 253df8bae1dSRodney W. Grimes #define IN_CLASSB_MAX 65536 254df8bae1dSRodney W. Grimes 255fac6d93bSJohn Birrell #define IN_CLASSC(i) (((u_int32_t)(i) & 0xe0000000) == 0xc0000000) 256df8bae1dSRodney W. Grimes #define IN_CLASSC_NET 0xffffff00 257df8bae1dSRodney W. Grimes #define IN_CLASSC_NSHIFT 8 258df8bae1dSRodney W. Grimes #define IN_CLASSC_HOST 0x000000ff 259df8bae1dSRodney W. Grimes 260fac6d93bSJohn Birrell #define IN_CLASSD(i) (((u_int32_t)(i) & 0xf0000000) == 0xe0000000) 261df8bae1dSRodney W. Grimes #define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */ 262df8bae1dSRodney W. Grimes #define IN_CLASSD_NSHIFT 28 /* net and host fields, but */ 263df8bae1dSRodney W. Grimes #define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */ 264df8bae1dSRodney W. Grimes #define IN_MULTICAST(i) IN_CLASSD(i) 265df8bae1dSRodney W. Grimes 266fac6d93bSJohn Birrell #define IN_EXPERIMENTAL(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000) 267fac6d93bSJohn Birrell #define IN_BADCLASS(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000) 268df8bae1dSRodney W. Grimes 269fac6d93bSJohn Birrell #define INADDR_ANY (u_int32_t)0x00000000 270fac6d93bSJohn Birrell #define INADDR_LOOPBACK (u_int32_t)0x7f000001 271fac6d93bSJohn Birrell #define INADDR_BROADCAST (u_int32_t)0xffffffff /* must be masked */ 272664a31e4SPeter Wemm #ifndef _KERNEL 273df8bae1dSRodney W. Grimes #define INADDR_NONE 0xffffffff /* -1 return */ 274df8bae1dSRodney W. Grimes #endif 275df8bae1dSRodney W. Grimes 276fac6d93bSJohn Birrell #define INADDR_UNSPEC_GROUP (u_int32_t)0xe0000000 /* 224.0.0.0 */ 277fac6d93bSJohn Birrell #define INADDR_ALLHOSTS_GROUP (u_int32_t)0xe0000001 /* 224.0.0.1 */ 278fac6d93bSJohn Birrell #define INADDR_ALLRTRS_GROUP (u_int32_t)0xe0000002 /* 224.0.0.2 */ 279fac6d93bSJohn Birrell #define INADDR_MAX_LOCAL_GROUP (u_int32_t)0xe00000ff /* 224.0.0.255 */ 280df8bae1dSRodney W. Grimes 281df8bae1dSRodney W. Grimes #define IN_LOOPBACKNET 127 /* official! */ 282df8bae1dSRodney W. Grimes 283df8bae1dSRodney W. Grimes /* 284df8bae1dSRodney W. Grimes * Socket address, internet style. 285df8bae1dSRodney W. Grimes */ 286df8bae1dSRodney W. Grimes struct sockaddr_in { 287df8bae1dSRodney W. Grimes u_char sin_len; 288df8bae1dSRodney W. Grimes u_char sin_family; 289df8bae1dSRodney W. Grimes u_short sin_port; 290df8bae1dSRodney W. Grimes struct in_addr sin_addr; 291df8bae1dSRodney W. Grimes char sin_zero[8]; 292df8bae1dSRodney W. Grimes }; 293df8bae1dSRodney W. Grimes 29476429de4SYoshinobu Inoue #define INET_ADDRSTRLEN 16 29576429de4SYoshinobu Inoue 296df8bae1dSRodney W. Grimes /* 297df8bae1dSRodney W. Grimes * Structure used to describe IP options. 298df8bae1dSRodney W. Grimes * Used to store options internally, to pass them to a process, 299df8bae1dSRodney W. Grimes * or to restore options retrieved earlier. 300df8bae1dSRodney W. Grimes * The ip_dst is used for the first-hop gateway when using a source route 301df8bae1dSRodney W. Grimes * (this gets put into the header proper). 302df8bae1dSRodney W. Grimes */ 303df8bae1dSRodney W. Grimes struct ip_opts { 304df8bae1dSRodney W. Grimes struct in_addr ip_dst; /* first hop, 0 w/o src rt */ 305df8bae1dSRodney W. Grimes char ip_opts[40]; /* actually variable in size */ 306df8bae1dSRodney W. Grimes }; 307df8bae1dSRodney W. Grimes 308df8bae1dSRodney W. Grimes /* 309df8bae1dSRodney W. Grimes * Options for use with [gs]etsockopt at the IP level. 310df8bae1dSRodney W. Grimes * First word of comment is data type; bool is stored in int. 311df8bae1dSRodney W. Grimes */ 312df8bae1dSRodney W. Grimes #define IP_OPTIONS 1 /* buf/ip_opts; set/get IP options */ 313df8bae1dSRodney W. Grimes #define IP_HDRINCL 2 /* int; header is included with data */ 314df8bae1dSRodney W. Grimes #define IP_TOS 3 /* int; IP type of service and preced. */ 315df8bae1dSRodney W. Grimes #define IP_TTL 4 /* int; IP time to live */ 316df8bae1dSRodney W. Grimes #define IP_RECVOPTS 5 /* bool; receive all IP opts w/dgram */ 317df8bae1dSRodney W. Grimes #define IP_RECVRETOPTS 6 /* bool; receive IP opts for response */ 318df8bae1dSRodney W. Grimes #define IP_RECVDSTADDR 7 /* bool; receive IP dst addr w/dgram */ 319df8bae1dSRodney W. Grimes #define IP_RETOPTS 8 /* ip_opts; set/get IP options */ 320df8bae1dSRodney W. Grimes #define IP_MULTICAST_IF 9 /* u_char; set/get IP multicast i/f */ 321df8bae1dSRodney W. Grimes #define IP_MULTICAST_TTL 10 /* u_char; set/get IP multicast ttl */ 322df8bae1dSRodney W. Grimes #define IP_MULTICAST_LOOP 11 /* u_char; set/get IP multicast loopback */ 323df8bae1dSRodney W. Grimes #define IP_ADD_MEMBERSHIP 12 /* ip_mreq; add an IP group membership */ 324df8bae1dSRodney W. Grimes #define IP_DROP_MEMBERSHIP 13 /* ip_mreq; drop an IP group membership */ 325f0068c4aSGarrett Wollman #define IP_MULTICAST_VIF 14 /* set/get IP mcast virt. iface */ 326f0068c4aSGarrett Wollman #define IP_RSVP_ON 15 /* enable RSVP in kernel */ 327f0068c4aSGarrett Wollman #define IP_RSVP_OFF 16 /* disable RSVP in kernel */ 3281c5de19aSGarrett Wollman #define IP_RSVP_VIF_ON 17 /* set RSVP per-vif socket */ 3291c5de19aSGarrett Wollman #define IP_RSVP_VIF_OFF 18 /* unset RSVP per-vif socket */ 33033b3ac06SPeter Wemm #define IP_PORTRANGE 19 /* int; range to choose for unspec port */ 33182c23ebaSBill Fenner #define IP_RECVIF 20 /* bool; receive reception if w/dgram */ 33276429de4SYoshinobu Inoue /* for IPSEC */ 33376429de4SYoshinobu Inoue #define IP_IPSEC_POLICY 21 /* int; set/get security policy */ 33476429de4SYoshinobu Inoue #define IP_FAITH 22 /* bool; accept FAITH'ed connections */ 335df8bae1dSRodney W. Grimes 336fed1c7e9SSøren Schmidt #define IP_FW_ADD 50 /* add a firewall rule to chain */ 337fed1c7e9SSøren Schmidt #define IP_FW_DEL 51 /* delete a firewall rule from chain */ 338fed1c7e9SSøren Schmidt #define IP_FW_FLUSH 52 /* flush firewall rule chain */ 339af44ef0aSAlexander Langer #define IP_FW_ZERO 53 /* clear single/all firewall counter(s) */ 340fed1c7e9SSøren Schmidt #define IP_FW_GET 54 /* get entire firewall rule chain */ 3410b6c1a83SBrian Feldman #define IP_FW_RESETLOG 55 /* reset logging counters */ 342fed1c7e9SSøren Schmidt 343b715f178SLuigi Rizzo #define IP_DUMMYNET_CONFIGURE 60 /* add/configure a dummynet pipe */ 344b715f178SLuigi Rizzo #define IP_DUMMYNET_DEL 61 /* delete a dummynet pipe from chain */ 345b715f178SLuigi Rizzo #define IP_DUMMYNET_FLUSH 62 /* flush dummynet */ 346b715f178SLuigi Rizzo #define IP_DUMMYNET_GET 64 /* get entire dummynet pipes */ 347b715f178SLuigi Rizzo 348df8bae1dSRodney W. Grimes /* 349df8bae1dSRodney W. Grimes * Defaults and limits for options 350df8bae1dSRodney W. Grimes */ 351df8bae1dSRodney W. Grimes #define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */ 352df8bae1dSRodney W. Grimes #define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */ 3531c5de19aSGarrett Wollman #define IP_MAX_MEMBERSHIPS 20 /* per socket */ 354df8bae1dSRodney W. Grimes 355df8bae1dSRodney W. Grimes /* 356df8bae1dSRodney W. Grimes * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. 357df8bae1dSRodney W. Grimes */ 358df8bae1dSRodney W. Grimes struct ip_mreq { 359df8bae1dSRodney W. Grimes struct in_addr imr_multiaddr; /* IP multicast address of group */ 360df8bae1dSRodney W. Grimes struct in_addr imr_interface; /* local IP address of interface */ 361df8bae1dSRodney W. Grimes }; 362df8bae1dSRodney W. Grimes 363df8bae1dSRodney W. Grimes /* 36433b3ac06SPeter Wemm * Argument for IP_PORTRANGE: 36533b3ac06SPeter Wemm * - which range to search when port is unspecified at bind() or connect() 36633b3ac06SPeter Wemm */ 36733b3ac06SPeter Wemm #define IP_PORTRANGE_DEFAULT 0 /* default range */ 36833b3ac06SPeter Wemm #define IP_PORTRANGE_HIGH 1 /* "high" - request firewall bypass */ 36933b3ac06SPeter Wemm #define IP_PORTRANGE_LOW 2 /* "low" - vouchsafe security */ 37033b3ac06SPeter Wemm 37133b3ac06SPeter Wemm /* 372df8bae1dSRodney W. Grimes * Definitions for inet sysctl operations. 373df8bae1dSRodney W. Grimes * 374df8bae1dSRodney W. Grimes * Third level is protocol number. 375df8bae1dSRodney W. Grimes * Fourth level is desired variable within that protocol. 376df8bae1dSRodney W. Grimes */ 377686cdd19SJun-ichiro itojun Hagino #define IPPROTO_MAXID (IPPROTO_AH + 1) /* don't list to IPPROTO_MAX */ 378df8bae1dSRodney W. Grimes 379df8bae1dSRodney W. Grimes #define CTL_IPPROTO_NAMES { \ 380df8bae1dSRodney W. Grimes { "ip", CTLTYPE_NODE }, \ 381df8bae1dSRodney W. Grimes { "icmp", CTLTYPE_NODE }, \ 382df8bae1dSRodney W. Grimes { "igmp", CTLTYPE_NODE }, \ 383df8bae1dSRodney W. Grimes { "ggp", CTLTYPE_NODE }, \ 384df8bae1dSRodney W. Grimes { 0, 0 }, \ 385df8bae1dSRodney W. Grimes { 0, 0 }, \ 386df8bae1dSRodney W. Grimes { "tcp", CTLTYPE_NODE }, \ 387df8bae1dSRodney W. Grimes { 0, 0 }, \ 388df8bae1dSRodney W. Grimes { "egp", CTLTYPE_NODE }, \ 389df8bae1dSRodney W. Grimes { 0, 0 }, \ 390df8bae1dSRodney W. Grimes { 0, 0 }, \ 391df8bae1dSRodney W. Grimes { 0, 0 }, \ 392df8bae1dSRodney W. Grimes { "pup", CTLTYPE_NODE }, \ 393df8bae1dSRodney W. Grimes { 0, 0 }, \ 394df8bae1dSRodney W. Grimes { 0, 0 }, \ 395df8bae1dSRodney W. Grimes { 0, 0 }, \ 396df8bae1dSRodney W. Grimes { 0, 0 }, \ 397df8bae1dSRodney W. Grimes { "udp", CTLTYPE_NODE }, \ 398df8bae1dSRodney W. Grimes { 0, 0 }, \ 399df8bae1dSRodney W. Grimes { 0, 0 }, \ 400df8bae1dSRodney W. Grimes { 0, 0 }, \ 401df8bae1dSRodney W. Grimes { 0, 0 }, \ 402df8bae1dSRodney W. Grimes { "idp", CTLTYPE_NODE }, \ 403686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 404686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 405686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 406686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 407686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 408686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 409686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 410686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 411686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 412686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 413686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 414686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 415686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 416686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 417686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 418686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 419686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 420686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 421686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 422686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 423686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 424686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 425686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 426686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 427686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 428686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 429686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 430686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 431686cdd19SJun-ichiro itojun Hagino { "ipsec", CTLTYPE_NODE }, \ 432df8bae1dSRodney W. Grimes } 433df8bae1dSRodney W. Grimes 434df8bae1dSRodney W. Grimes /* 435df8bae1dSRodney W. Grimes * Names for IP sysctl objects 436df8bae1dSRodney W. Grimes */ 437df8bae1dSRodney W. Grimes #define IPCTL_FORWARDING 1 /* act as router */ 438df8bae1dSRodney W. Grimes #define IPCTL_SENDREDIRECTS 2 /* may send redirects when forwarding */ 439df8bae1dSRodney W. Grimes #define IPCTL_DEFTTL 3 /* default TTL */ 440df8bae1dSRodney W. Grimes #ifdef notyet 441df8bae1dSRodney W. Grimes #define IPCTL_DEFMTU 4 /* default MTU */ 442df8bae1dSRodney W. Grimes #endif 4435be2baf8SGarrett Wollman #define IPCTL_RTEXPIRE 5 /* cloned route expiration time */ 444ea80aed1SGarrett Wollman #define IPCTL_RTMINEXPIRE 6 /* min value for expiration time */ 445ea80aed1SGarrett Wollman #define IPCTL_RTMAXCACHE 7 /* trigger level for dynamic expire */ 4461025071fSGarrett Wollman #define IPCTL_SOURCEROUTE 8 /* may perform source routes */ 44742c03a52SPeter Wemm #define IPCTL_DIRECTEDBROADCAST 9 /* may re-broadcast received packets */ 448054ef370SGarrett Wollman #define IPCTL_INTRQMAXLEN 10 /* max length of netisr queue */ 449054ef370SGarrett Wollman #define IPCTL_INTRQDROPS 11 /* number of netisr q drops */ 4506fce01c9SGarrett Wollman #define IPCTL_STATS 12 /* ipstat structure */ 4514fce5804SGuido van Rooij #define IPCTL_ACCEPTSOURCEROUTE 13 /* may accept source routed packets */ 4521f91d8c5SDavid Greenman #define IPCTL_FASTFORWARDING 14 /* use fast IP forwarding code */ 4536a800098SYoshinobu Inoue #define IPCTL_KEEPFAITH 15 /* FAITH IPv4->IPv6 translater ctl */ 45476429de4SYoshinobu Inoue #define IPCTL_GIF_TTL 16 /* default TTL for gif encap packet */ 45576429de4SYoshinobu Inoue #define IPCTL_MAXID 17 456df8bae1dSRodney W. Grimes 457df8bae1dSRodney W. Grimes #define IPCTL_NAMES { \ 458df8bae1dSRodney W. Grimes { 0, 0 }, \ 459df8bae1dSRodney W. Grimes { "forwarding", CTLTYPE_INT }, \ 460df8bae1dSRodney W. Grimes { "redirect", CTLTYPE_INT }, \ 461df8bae1dSRodney W. Grimes { "ttl", CTLTYPE_INT }, \ 462df8bae1dSRodney W. Grimes { "mtu", CTLTYPE_INT }, \ 4635be2baf8SGarrett Wollman { "rtexpire", CTLTYPE_INT }, \ 464ea80aed1SGarrett Wollman { "rtminexpire", CTLTYPE_INT }, \ 465ea80aed1SGarrett Wollman { "rtmaxcache", CTLTYPE_INT }, \ 4661025071fSGarrett Wollman { "sourceroute", CTLTYPE_INT }, \ 46742c03a52SPeter Wemm { "directed-broadcast", CTLTYPE_INT }, \ 468054ef370SGarrett Wollman { "intr-queue-maxlen", CTLTYPE_INT }, \ 469054ef370SGarrett Wollman { "intr-queue-drops", CTLTYPE_INT }, \ 4706fce01c9SGarrett Wollman { "stats", CTLTYPE_STRUCT }, \ 4714fce5804SGuido van Rooij { "accept_sourceroute", CTLTYPE_INT }, \ 4721f91d8c5SDavid Greenman { "fastforwarding", CTLTYPE_INT }, \ 473df8bae1dSRodney W. Grimes } 474df8bae1dSRodney W. Grimes 47576429de4SYoshinobu Inoue /* INET6 stuff */ 4761aa540ebSYoshinobu Inoue #define __KAME_NETINET_IN_H_INCLUDED_ 47776429de4SYoshinobu Inoue #include <netinet6/in6.h> 4781aa540ebSYoshinobu Inoue #undef __KAME_NETINET_IN_H_INCLUDED_ 479df8bae1dSRodney W. Grimes 480664a31e4SPeter Wemm #ifdef _KERNEL 481ef0cdf33SGarrett Wollman struct ifnet; struct mbuf; /* forward declarations for Standard C */ 482ecbc643aSPeter Wemm struct proc; 483ef0cdf33SGarrett Wollman 484df8bae1dSRodney W. Grimes int in_broadcast __P((struct in_addr, struct ifnet *)); 485df8bae1dSRodney W. Grimes int in_canforward __P((struct in_addr)); 486df8bae1dSRodney W. Grimes int in_localaddr __P((struct in_addr)); 487ef0cdf33SGarrett Wollman char *inet_ntoa __P((struct in_addr)); /* in libkern */ 488987efc76SBosko Milekic char *inet_ntoa_r __P((struct in_addr ina, char *buf)); /* in libkern */ 48923bf9953SPoul-Henning Kamp 49075c13541SPoul-Henning Kamp int prison_ip __P((struct proc *p, int flag, u_int32_t *ip)); 49175c13541SPoul-Henning Kamp void prison_remote_ip __P((struct proc *p, int flag, u_int32_t *ip)); 49275c13541SPoul-Henning Kamp 493664a31e4SPeter Wemm #endif 494707f139eSPaul Richards 495707f139eSPaul Richards #endif 496