1c398230bSWarner Losh /*- 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 * 4. Neither the name of the University nor the names of its contributors 14df8bae1dSRodney W. Grimes * may be used to endorse or promote products derived from this software 15df8bae1dSRodney W. Grimes * without specific prior written permission. 16df8bae1dSRodney W. Grimes * 17df8bae1dSRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18df8bae1dSRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19df8bae1dSRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20df8bae1dSRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21df8bae1dSRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22df8bae1dSRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23df8bae1dSRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24df8bae1dSRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25df8bae1dSRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26df8bae1dSRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27df8bae1dSRodney W. Grimes * SUCH DAMAGE. 28df8bae1dSRodney W. Grimes * 29df8bae1dSRodney W. Grimes * @(#)in.h 8.3 (Berkeley) 1/3/94 30c3aac50fSPeter Wemm * $FreeBSD$ 31df8bae1dSRodney W. Grimes */ 32df8bae1dSRodney W. Grimes 33707f139eSPaul Richards #ifndef _NETINET_IN_H_ 34707f139eSPaul Richards #define _NETINET_IN_H_ 35707f139eSPaul Richards 3658631bbeSMike Barcroft #include <sys/cdefs.h> 378822d3fbSMike Barcroft #include <sys/_types.h> 3858631bbeSMike Barcroft #include <machine/endian.h> 398822d3fbSMike Barcroft 4058631bbeSMike Barcroft /* Protocols common to RFC 1700, POSIX, and X/Open. */ 4158631bbeSMike Barcroft #define IPPROTO_IP 0 /* dummy for IP */ 4258631bbeSMike Barcroft #define IPPROTO_ICMP 1 /* control message protocol */ 4358631bbeSMike Barcroft #define IPPROTO_TCP 6 /* tcp */ 4458631bbeSMike Barcroft #define IPPROTO_UDP 17 /* user datagram protocol */ 4558631bbeSMike Barcroft 4658631bbeSMike Barcroft #define INADDR_ANY (u_int32_t)0x00000000 4758631bbeSMike Barcroft #define INADDR_BROADCAST (u_int32_t)0xffffffff /* must be masked */ 4858631bbeSMike Barcroft 4958631bbeSMike Barcroft #ifndef _UINT8_T_DECLARED 5058631bbeSMike Barcroft typedef __uint8_t uint8_t; 5158631bbeSMike Barcroft #define _UINT8_T_DECLARED 5258631bbeSMike Barcroft #endif 5358631bbeSMike Barcroft 5458631bbeSMike Barcroft #ifndef _UINT16_T_DECLARED 5558631bbeSMike Barcroft typedef __uint16_t uint16_t; 5658631bbeSMike Barcroft #define _UINT16_T_DECLARED 5758631bbeSMike Barcroft #endif 5858631bbeSMike Barcroft 5958631bbeSMike Barcroft #ifndef _UINT32_T_DECLARED 6058631bbeSMike Barcroft typedef __uint32_t uint32_t; 6158631bbeSMike Barcroft #define _UINT32_T_DECLARED 6258631bbeSMike Barcroft #endif 6358631bbeSMike Barcroft 6458631bbeSMike Barcroft #ifndef _IN_ADDR_T_DECLARED 6558631bbeSMike Barcroft typedef uint32_t in_addr_t; 6658631bbeSMike Barcroft #define _IN_ADDR_T_DECLARED 6758631bbeSMike Barcroft #endif 6858631bbeSMike Barcroft 6958631bbeSMike Barcroft #ifndef _IN_PORT_T_DECLARED 7058631bbeSMike Barcroft typedef uint16_t in_port_t; 7158631bbeSMike Barcroft #define _IN_PORT_T_DECLARED 7258631bbeSMike Barcroft #endif 7358631bbeSMike Barcroft 74abbd8902SMike Barcroft #ifndef _SA_FAMILY_T_DECLARED 75abbd8902SMike Barcroft typedef __sa_family_t sa_family_t; 76abbd8902SMike Barcroft #define _SA_FAMILY_T_DECLARED 7758631bbeSMike Barcroft #endif 7858631bbeSMike Barcroft 7958631bbeSMike Barcroft /* Internet address (a structure for historical reasons). */ 8058631bbeSMike Barcroft #ifndef _STRUCT_IN_ADDR_DECLARED 8158631bbeSMike Barcroft struct in_addr { 8258631bbeSMike Barcroft in_addr_t s_addr; 8358631bbeSMike Barcroft }; 8458631bbeSMike Barcroft #define _STRUCT_IN_ADDR_DECLARED 8558631bbeSMike Barcroft #endif 8658631bbeSMike Barcroft 8771498f30SBruce M Simpson #ifndef _SOCKLEN_T_DECLARED 8871498f30SBruce M Simpson typedef __socklen_t socklen_t; 8971498f30SBruce M Simpson #define _SOCKLEN_T_DECLARED 9071498f30SBruce M Simpson #endif 9171498f30SBruce M Simpson 922ac047d1SPoul-Henning Kamp #include <sys/_sockaddr_storage.h> 9371498f30SBruce M Simpson 9458631bbeSMike Barcroft /* Socket address, internet style. */ 9558631bbeSMike Barcroft struct sockaddr_in { 9658631bbeSMike Barcroft uint8_t sin_len; 9758631bbeSMike Barcroft sa_family_t sin_family; 9858631bbeSMike Barcroft in_port_t sin_port; 9958631bbeSMike Barcroft struct in_addr sin_addr; 10058631bbeSMike Barcroft char sin_zero[8]; 10158631bbeSMike Barcroft }; 10258631bbeSMike Barcroft 103b3c11b5bSDavid Schultz #if !defined(_KERNEL) && __BSD_VISIBLE 10458631bbeSMike Barcroft 10558631bbeSMike Barcroft #ifndef _BYTEORDER_PROTOTYPED 10658631bbeSMike Barcroft #define _BYTEORDER_PROTOTYPED 10758631bbeSMike Barcroft __BEGIN_DECLS 10858631bbeSMike Barcroft uint32_t htonl(uint32_t); 10958631bbeSMike Barcroft uint16_t htons(uint16_t); 11058631bbeSMike Barcroft uint32_t ntohl(uint32_t); 11158631bbeSMike Barcroft uint16_t ntohs(uint16_t); 11258631bbeSMike Barcroft __END_DECLS 11358631bbeSMike Barcroft #endif 11458631bbeSMike Barcroft 11558631bbeSMike Barcroft #ifndef _BYTEORDER_FUNC_DEFINED 11658631bbeSMike Barcroft #define _BYTEORDER_FUNC_DEFINED 11758631bbeSMike Barcroft #define htonl(x) __htonl(x) 11858631bbeSMike Barcroft #define htons(x) __htons(x) 11958631bbeSMike Barcroft #define ntohl(x) __ntohl(x) 12058631bbeSMike Barcroft #define ntohs(x) __ntohs(x) 12158631bbeSMike Barcroft #endif 12258631bbeSMike Barcroft 123b3c11b5bSDavid Schultz #endif /* !_KERNEL && __BSD_VISIBLE */ 12458631bbeSMike Barcroft 12558631bbeSMike Barcroft #if __POSIX_VISIBLE >= 200112 12658631bbeSMike Barcroft #define IPPROTO_RAW 255 /* raw IP packet */ 12758631bbeSMike Barcroft #define INET_ADDRSTRLEN 16 12858631bbeSMike Barcroft #endif 12958631bbeSMike Barcroft 13058631bbeSMike Barcroft #if __BSD_VISIBLE 131df8bae1dSRodney W. Grimes /* 132df8bae1dSRodney W. Grimes * Constants and structures defined by the internet system, 133df8bae1dSRodney W. Grimes * Per RFC 790, September 1981, and numerous additions. 134df8bae1dSRodney W. Grimes */ 135df8bae1dSRodney W. Grimes 136df8bae1dSRodney W. Grimes /* 137cfaa93b2SJulian Elischer * Protocols (RFC 1700) 138df8bae1dSRodney W. Grimes */ 13976429de4SYoshinobu Inoue #define IPPROTO_HOPOPTS 0 /* IP6 hop-by-hop options */ 140df8bae1dSRodney W. Grimes #define IPPROTO_IGMP 2 /* group mgmt protocol */ 141df8bae1dSRodney W. Grimes #define IPPROTO_GGP 3 /* gateway^2 (deprecated) */ 14276429de4SYoshinobu Inoue #define IPPROTO_IPV4 4 /* IPv4 encapsulation */ 14376429de4SYoshinobu Inoue #define IPPROTO_IPIP IPPROTO_IPV4 /* for compatibility */ 144cfaa93b2SJulian Elischer #define IPPROTO_ST 7 /* Stream protocol II */ 145df8bae1dSRodney W. Grimes #define IPPROTO_EGP 8 /* exterior gateway protocol */ 146cfaa93b2SJulian Elischer #define IPPROTO_PIGP 9 /* private interior gateway */ 147cfaa93b2SJulian Elischer #define IPPROTO_RCCMON 10 /* BBN RCC Monitoring */ 148cfaa93b2SJulian Elischer #define IPPROTO_NVPII 11 /* network voice protocol*/ 149df8bae1dSRodney W. Grimes #define IPPROTO_PUP 12 /* pup */ 150cfaa93b2SJulian Elischer #define IPPROTO_ARGUS 13 /* Argus */ 151cfaa93b2SJulian Elischer #define IPPROTO_EMCON 14 /* EMCON */ 152cfaa93b2SJulian Elischer #define IPPROTO_XNET 15 /* Cross Net Debugger */ 153cfaa93b2SJulian Elischer #define IPPROTO_CHAOS 16 /* Chaos*/ 154cfaa93b2SJulian Elischer #define IPPROTO_MUX 18 /* Multiplexing */ 155cfaa93b2SJulian Elischer #define IPPROTO_MEAS 19 /* DCN Measurement Subsystems */ 156cfaa93b2SJulian Elischer #define IPPROTO_HMP 20 /* Host Monitoring */ 157cfaa93b2SJulian Elischer #define IPPROTO_PRM 21 /* Packet Radio Measurement */ 158df8bae1dSRodney W. Grimes #define IPPROTO_IDP 22 /* xns idp */ 159cfaa93b2SJulian Elischer #define IPPROTO_TRUNK1 23 /* Trunk-1 */ 160cfaa93b2SJulian Elischer #define IPPROTO_TRUNK2 24 /* Trunk-2 */ 161cfaa93b2SJulian Elischer #define IPPROTO_LEAF1 25 /* Leaf-1 */ 162cfaa93b2SJulian Elischer #define IPPROTO_LEAF2 26 /* Leaf-2 */ 163cfaa93b2SJulian Elischer #define IPPROTO_RDP 27 /* Reliable Data */ 164cfaa93b2SJulian Elischer #define IPPROTO_IRTP 28 /* Reliable Transaction */ 165df8bae1dSRodney W. Grimes #define IPPROTO_TP 29 /* tp-4 w/ class negotiation */ 166cfaa93b2SJulian Elischer #define IPPROTO_BLT 30 /* Bulk Data Transfer */ 167cfaa93b2SJulian Elischer #define IPPROTO_NSP 31 /* Network Services */ 168cfaa93b2SJulian Elischer #define IPPROTO_INP 32 /* Merit Internodal */ 169cfaa93b2SJulian Elischer #define IPPROTO_SEP 33 /* Sequential Exchange */ 170cfaa93b2SJulian Elischer #define IPPROTO_3PC 34 /* Third Party Connect */ 171cfaa93b2SJulian Elischer #define IPPROTO_IDPR 35 /* InterDomain Policy Routing */ 172cfaa93b2SJulian Elischer #define IPPROTO_XTP 36 /* XTP */ 173cfaa93b2SJulian Elischer #define IPPROTO_DDP 37 /* Datagram Delivery */ 174cfaa93b2SJulian Elischer #define IPPROTO_CMTP 38 /* Control Message Transport */ 175cfaa93b2SJulian Elischer #define IPPROTO_TPXX 39 /* TP++ Transport */ 176cfaa93b2SJulian Elischer #define IPPROTO_IL 40 /* IL transport protocol */ 17776429de4SYoshinobu Inoue #define IPPROTO_IPV6 41 /* IP6 header */ 178cfaa93b2SJulian Elischer #define IPPROTO_SDRP 42 /* Source Demand Routing */ 17976429de4SYoshinobu Inoue #define IPPROTO_ROUTING 43 /* IP6 routing header */ 18076429de4SYoshinobu Inoue #define IPPROTO_FRAGMENT 44 /* IP6 fragmentation header */ 181cfaa93b2SJulian Elischer #define IPPROTO_IDRP 45 /* InterDomain Routing*/ 182f0068c4aSGarrett Wollman #define IPPROTO_RSVP 46 /* resource reservation */ 183cfaa93b2SJulian Elischer #define IPPROTO_GRE 47 /* General Routing Encap. */ 184cfaa93b2SJulian Elischer #define IPPROTO_MHRP 48 /* Mobile Host Routing */ 185cfaa93b2SJulian Elischer #define IPPROTO_BHA 49 /* BHA */ 18676429de4SYoshinobu Inoue #define IPPROTO_ESP 50 /* IP6 Encap Sec. Payload */ 18776429de4SYoshinobu Inoue #define IPPROTO_AH 51 /* IP6 Auth Header */ 188cfaa93b2SJulian Elischer #define IPPROTO_INLSP 52 /* Integ. Net Layer Security */ 189cfaa93b2SJulian Elischer #define IPPROTO_SWIPE 53 /* IP with encryption */ 190cfaa93b2SJulian Elischer #define IPPROTO_NHRP 54 /* Next Hop Resolution */ 191e61c4bedSJeroen Ruigrok van der Werven #define IPPROTO_MOBILE 55 /* IP Mobility */ 192e61c4bedSJeroen Ruigrok van der Werven #define IPPROTO_TLSP 56 /* Transport Layer Security */ 193e61c4bedSJeroen Ruigrok van der Werven #define IPPROTO_SKIP 57 /* SKIP */ 19476429de4SYoshinobu Inoue #define IPPROTO_ICMPV6 58 /* ICMP6 */ 19576429de4SYoshinobu Inoue #define IPPROTO_NONE 59 /* IP6 no next header */ 19676429de4SYoshinobu Inoue #define IPPROTO_DSTOPTS 60 /* IP6 destination option */ 197cfaa93b2SJulian Elischer #define IPPROTO_AHIP 61 /* any host internal protocol */ 198cfaa93b2SJulian Elischer #define IPPROTO_CFTP 62 /* CFTP */ 199cfaa93b2SJulian Elischer #define IPPROTO_HELLO 63 /* "hello" routing protocol */ 200cfaa93b2SJulian Elischer #define IPPROTO_SATEXPAK 64 /* SATNET/Backroom EXPAK */ 201cfaa93b2SJulian Elischer #define IPPROTO_KRYPTOLAN 65 /* Kryptolan */ 202cfaa93b2SJulian Elischer #define IPPROTO_RVD 66 /* Remote Virtual Disk */ 203cfaa93b2SJulian Elischer #define IPPROTO_IPPC 67 /* Pluribus Packet Core */ 204cfaa93b2SJulian Elischer #define IPPROTO_ADFS 68 /* Any distributed FS */ 205cfaa93b2SJulian Elischer #define IPPROTO_SATMON 69 /* Satnet Monitoring */ 206cfaa93b2SJulian Elischer #define IPPROTO_VISA 70 /* VISA Protocol */ 207cfaa93b2SJulian Elischer #define IPPROTO_IPCV 71 /* Packet Core Utility */ 208cfaa93b2SJulian Elischer #define IPPROTO_CPNX 72 /* Comp. Prot. Net. Executive */ 209cfaa93b2SJulian Elischer #define IPPROTO_CPHB 73 /* Comp. Prot. HeartBeat */ 210cfaa93b2SJulian Elischer #define IPPROTO_WSN 74 /* Wang Span Network */ 211cfaa93b2SJulian Elischer #define IPPROTO_PVP 75 /* Packet Video Protocol */ 212cfaa93b2SJulian Elischer #define IPPROTO_BRSATMON 76 /* BackRoom SATNET Monitoring */ 213cfaa93b2SJulian Elischer #define IPPROTO_ND 77 /* Sun net disk proto (temp.) */ 214cfaa93b2SJulian Elischer #define IPPROTO_WBMON 78 /* WIDEBAND Monitoring */ 215cfaa93b2SJulian Elischer #define IPPROTO_WBEXPAK 79 /* WIDEBAND EXPAK */ 216df8bae1dSRodney W. Grimes #define IPPROTO_EON 80 /* ISO cnlp */ 217cfaa93b2SJulian Elischer #define IPPROTO_VMTP 81 /* VMTP */ 218cfaa93b2SJulian Elischer #define IPPROTO_SVMTP 82 /* Secure VMTP */ 219cfaa93b2SJulian Elischer #define IPPROTO_VINES 83 /* Banyon VINES */ 220cfaa93b2SJulian Elischer #define IPPROTO_TTP 84 /* TTP */ 221cfaa93b2SJulian Elischer #define IPPROTO_IGP 85 /* NSFNET-IGP */ 222cfaa93b2SJulian Elischer #define IPPROTO_DGP 86 /* dissimilar gateway prot. */ 22347f049d7SJulian Elischer #define IPPROTO_TCF 87 /* TCF */ 224cfaa93b2SJulian Elischer #define IPPROTO_IGRP 88 /* Cisco/GXS IGRP */ 225cfaa93b2SJulian Elischer #define IPPROTO_OSPFIGP 89 /* OSPFIGP */ 226cfaa93b2SJulian Elischer #define IPPROTO_SRPC 90 /* Strite RPC protocol */ 227cfaa93b2SJulian Elischer #define IPPROTO_LARP 91 /* Locus Address Resoloution */ 228cfaa93b2SJulian Elischer #define IPPROTO_MTP 92 /* Multicast Transport */ 229cfaa93b2SJulian Elischer #define IPPROTO_AX25 93 /* AX.25 Frames */ 230cfaa93b2SJulian Elischer #define IPPROTO_IPEIP 94 /* IP encapsulated in IP */ 231cfaa93b2SJulian Elischer #define IPPROTO_MICP 95 /* Mobile Int.ing control */ 232cfaa93b2SJulian Elischer #define IPPROTO_SCCSP 96 /* Semaphore Comm. security */ 233cfaa93b2SJulian Elischer #define IPPROTO_ETHERIP 97 /* Ethernet IP encapsulation */ 234df8bae1dSRodney W. Grimes #define IPPROTO_ENCAP 98 /* encapsulation header */ 235cfaa93b2SJulian Elischer #define IPPROTO_APES 99 /* any private encr. scheme */ 236cfaa93b2SJulian Elischer #define IPPROTO_GMTP 100 /* GMTP*/ 23776429de4SYoshinobu Inoue #define IPPROTO_IPCOMP 108 /* payload compression (IPComp) */ 238496f9fc5SGeorge V. Neville-Neil #define IPPROTO_SCTP 132 /* SCTP */ 239eaa726beSLuigi Rizzo /* 101-254: Partly Unassigned */ 24076429de4SYoshinobu Inoue #define IPPROTO_PIM 103 /* Protocol Independent Mcast */ 241a9771948SGleb Smirnoff #define IPPROTO_CARP 112 /* CARP */ 242eaa726beSLuigi Rizzo #define IPPROTO_PGM 113 /* PGM */ 243a306c902SMax Laier #define IPPROTO_PFSYNC 240 /* PFSYNC */ 244cfaa93b2SJulian Elischer /* 255: Reserved */ 2454d3ffc98SBill Fenner /* BSD Private, local use, namespace incursion, no longer used */ 2464d3ffc98SBill Fenner #define IPPROTO_OLD_DIVERT 254 /* OLD divert pseudo-proto */ 247df8bae1dSRodney W. Grimes #define IPPROTO_MAX 256 248df8bae1dSRodney W. Grimes 24976429de4SYoshinobu Inoue /* last return value of *_input(), meaning "all job for this pkt is done". */ 25076429de4SYoshinobu Inoue #define IPPROTO_DONE 257 251df8bae1dSRodney W. Grimes 2524d3ffc98SBill Fenner /* Only used internally, so can be outside the range of valid IP protocols. */ 2534d3ffc98SBill Fenner #define IPPROTO_DIVERT 258 /* divert pseudo-protocol */ 2544d3ffc98SBill Fenner 255df8bae1dSRodney W. Grimes /* 256539be79aSAndre Oppermann * Defined to avoid confusion. The master value is defined by 257539be79aSAndre Oppermann * PROTO_SPACER in sys/protosw.h. 258539be79aSAndre Oppermann */ 259539be79aSAndre Oppermann #define IPPROTO_SPACER 32767 /* spacer for loadable protos */ 260539be79aSAndre Oppermann 261539be79aSAndre Oppermann /* 262df8bae1dSRodney W. Grimes * Local port number conventions: 26333b3ac06SPeter Wemm * 26433b3ac06SPeter Wemm * When a user does a bind(2) or connect(2) with a port number of zero, 26533b3ac06SPeter Wemm * a non-conflicting local port address is chosen. 266c3b2fe55SMike Silbersack * The default range is IPPORT_HIFIRSTAUTO through 267c3b2fe55SMike Silbersack * IPPORT_HILASTAUTO, although that is settable by sysctl. 26833b3ac06SPeter Wemm * 26933b3ac06SPeter Wemm * A user may set the IPPROTO_IP option IP_PORTRANGE to change this 27033b3ac06SPeter Wemm * default assignment range. 27133b3ac06SPeter Wemm * 27233b3ac06SPeter Wemm * The value IP_PORTRANGE_DEFAULT causes the default behavior. 27333b3ac06SPeter Wemm * 27433b3ac06SPeter Wemm * The value IP_PORTRANGE_HIGH changes the range of candidate port numbers 27533b3ac06SPeter Wemm * into the "high" range. These are reserved for client outbound connections 2761cf6e4f5SRui Paulo * which do not want to be filtered by any firewalls. 27733b3ac06SPeter Wemm * 27833b3ac06SPeter Wemm * The value IP_PORTRANGE_LOW changes the range to the "low" are 27933b3ac06SPeter Wemm * that is (by convention) restricted to privileged processes. This 28033b3ac06SPeter Wemm * convention is based on "vouchsafe" principles only. It is only secure 28133b3ac06SPeter Wemm * if you trust the remote host to restrict these ports. 28233b3ac06SPeter Wemm * 28333b3ac06SPeter Wemm * The default range of ports and the high range can be changed by 284bbd42ad0SPeter Wemm * sysctl(3). (net.inet.ip.port{hi,low}{first,last}_auto) 28533b3ac06SPeter Wemm * 28633b3ac06SPeter Wemm * Changing those values has bad security implications if you are 2879d5abbddSJens Schweikhardt * using a stateless firewall that is allowing packets outside of that 28833b3ac06SPeter Wemm * range in order to allow transparent outgoing connections. 28933b3ac06SPeter Wemm * 29033b3ac06SPeter Wemm * Such a firewall configuration will generally depend on the use of these 29133b3ac06SPeter Wemm * default values. If you change them, you may find your Security 29233b3ac06SPeter Wemm * Administrator looking for you with a heavy object. 2934565cbeaSPoul-Henning Kamp * 2944565cbeaSPoul-Henning Kamp * For a slightly more orthodox text view on this: 2954565cbeaSPoul-Henning Kamp * 2964565cbeaSPoul-Henning Kamp * ftp://ftp.isi.edu/in-notes/iana/assignments/port-numbers 2974565cbeaSPoul-Henning Kamp * 2984565cbeaSPoul-Henning Kamp * port numbers are divided into three ranges: 2994565cbeaSPoul-Henning Kamp * 3004565cbeaSPoul-Henning Kamp * 0 - 1023 Well Known Ports 3014565cbeaSPoul-Henning Kamp * 1024 - 49151 Registered Ports 3024565cbeaSPoul-Henning Kamp * 49152 - 65535 Dynamic and/or Private Ports 3034565cbeaSPoul-Henning Kamp * 30433b3ac06SPeter Wemm */ 30533b3ac06SPeter Wemm 30633b3ac06SPeter Wemm /* 307df8bae1dSRodney W. Grimes * Ports < IPPORT_RESERVED are reserved for 30833b3ac06SPeter Wemm * privileged processes (e.g. root). (IP_PORTRANGE_LOW) 309df8bae1dSRodney W. Grimes */ 310df8bae1dSRodney W. Grimes #define IPPORT_RESERVED 1024 311df8bae1dSRodney W. Grimes 312df8bae1dSRodney W. Grimes /* 3131cf6e4f5SRui Paulo * Default local port range, used by IP_PORTRANGE_DEFAULT 3141cf6e4f5SRui Paulo */ 3151cf6e4f5SRui Paulo #define IPPORT_EPHEMERALFIRST 10000 3161cf6e4f5SRui Paulo #define IPPORT_EPHEMERALLAST 65535 3171cf6e4f5SRui Paulo 3181cf6e4f5SRui Paulo /* 3191cf6e4f5SRui Paulo * Dynamic port range, used by IP_PORTRANGE_HIGH. 320101f9fc8SPeter Wemm */ 3214565cbeaSPoul-Henning Kamp #define IPPORT_HIFIRSTAUTO 49152 3224565cbeaSPoul-Henning Kamp #define IPPORT_HILASTAUTO 65535 323101f9fc8SPeter Wemm 324101f9fc8SPeter Wemm /* 325bbd42ad0SPeter Wemm * Scanning for a free reserved port return a value below IPPORT_RESERVED, 326bbd42ad0SPeter Wemm * but higher than IPPORT_RESERVEDSTART. Traditionally the start value was 327bbd42ad0SPeter Wemm * 512, but that conflicts with some well-known-services that firewalls may 328bbd42ad0SPeter Wemm * have a fit if we use. 329bbd42ad0SPeter Wemm */ 330bbd42ad0SPeter Wemm #define IPPORT_RESERVEDSTART 600 331bbd42ad0SPeter Wemm 332de2656d0SMike Barcroft #define IPPORT_MAX 65535 333de2656d0SMike Barcroft 334df8bae1dSRodney W. Grimes /* 335df8bae1dSRodney W. Grimes * Definitions of bits in internet address integers. 336df8bae1dSRodney W. Grimes * On subnets, the decomposition of addresses to host and net parts 337df8bae1dSRodney W. Grimes * is done according to subnet mask, not the masks here. 338df8bae1dSRodney W. Grimes */ 339fac6d93bSJohn Birrell #define IN_CLASSA(i) (((u_int32_t)(i) & 0x80000000) == 0) 340df8bae1dSRodney W. Grimes #define IN_CLASSA_NET 0xff000000 341df8bae1dSRodney W. Grimes #define IN_CLASSA_NSHIFT 24 342df8bae1dSRodney W. Grimes #define IN_CLASSA_HOST 0x00ffffff 343df8bae1dSRodney W. Grimes #define IN_CLASSA_MAX 128 344df8bae1dSRodney W. Grimes 345fac6d93bSJohn Birrell #define IN_CLASSB(i) (((u_int32_t)(i) & 0xc0000000) == 0x80000000) 346df8bae1dSRodney W. Grimes #define IN_CLASSB_NET 0xffff0000 347df8bae1dSRodney W. Grimes #define IN_CLASSB_NSHIFT 16 348df8bae1dSRodney W. Grimes #define IN_CLASSB_HOST 0x0000ffff 349df8bae1dSRodney W. Grimes #define IN_CLASSB_MAX 65536 350df8bae1dSRodney W. Grimes 351fac6d93bSJohn Birrell #define IN_CLASSC(i) (((u_int32_t)(i) & 0xe0000000) == 0xc0000000) 352df8bae1dSRodney W. Grimes #define IN_CLASSC_NET 0xffffff00 353df8bae1dSRodney W. Grimes #define IN_CLASSC_NSHIFT 8 354df8bae1dSRodney W. Grimes #define IN_CLASSC_HOST 0x000000ff 355df8bae1dSRodney W. Grimes 356fac6d93bSJohn Birrell #define IN_CLASSD(i) (((u_int32_t)(i) & 0xf0000000) == 0xe0000000) 357df8bae1dSRodney W. Grimes #define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */ 358df8bae1dSRodney W. Grimes #define IN_CLASSD_NSHIFT 28 /* net and host fields, but */ 359df8bae1dSRodney W. Grimes #define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */ 360df8bae1dSRodney W. Grimes #define IN_MULTICAST(i) IN_CLASSD(i) 361df8bae1dSRodney W. Grimes 362fac6d93bSJohn Birrell #define IN_EXPERIMENTAL(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000) 363fac6d93bSJohn Birrell #define IN_BADCLASS(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000) 364df8bae1dSRodney W. Grimes 3651976bc4aSBruce M Simpson #define IN_LINKLOCAL(i) (((u_int32_t)(i) & 0xffff0000) == 0xa9fe0000) 3666b9ff6b7SGeorge V. Neville-Neil #define IN_LOOPBACK(i) (((u_int32_t)(i) & 0xff000000) == 0x7f000000) 3676b9ff6b7SGeorge V. Neville-Neil #define IN_ZERONET(i) (((u_int32_t)(i) & 0xff000000) == 0) 3681976bc4aSBruce M Simpson 3691976bc4aSBruce M Simpson #define IN_PRIVATE(i) ((((u_int32_t)(i) & 0xff000000) == 0x0a000000) || \ 3701976bc4aSBruce M Simpson (((u_int32_t)(i) & 0xfff00000) == 0xac100000) || \ 3711976bc4aSBruce M Simpson (((u_int32_t)(i) & 0xffff0000) == 0xc0a80000)) 3721976bc4aSBruce M Simpson 3731976bc4aSBruce M Simpson #define IN_LOCAL_GROUP(i) (((u_int32_t)(i) & 0xffffff00) == 0xe0000000) 3741976bc4aSBruce M Simpson 3751976bc4aSBruce M Simpson #define IN_ANY_LOCAL(i) (IN_LINKLOCAL(i) || IN_LOCAL_GROUP(i)) 3761976bc4aSBruce M Simpson 377fac6d93bSJohn Birrell #define INADDR_LOOPBACK (u_int32_t)0x7f000001 378664a31e4SPeter Wemm #ifndef _KERNEL 379df8bae1dSRodney W. Grimes #define INADDR_NONE 0xffffffff /* -1 return */ 380df8bae1dSRodney W. Grimes #endif 381df8bae1dSRodney W. Grimes 382fac6d93bSJohn Birrell #define INADDR_UNSPEC_GROUP (u_int32_t)0xe0000000 /* 224.0.0.0 */ 383fac6d93bSJohn Birrell #define INADDR_ALLHOSTS_GROUP (u_int32_t)0xe0000001 /* 224.0.0.1 */ 384fac6d93bSJohn Birrell #define INADDR_ALLRTRS_GROUP (u_int32_t)0xe0000002 /* 224.0.0.2 */ 385ad3b9f70SBruce M Simpson #define INADDR_ALLRPTS_GROUP (u_int32_t)0xe0000016 /* 224.0.0.22, IGMPv3 */ 386a9771948SGleb Smirnoff #define INADDR_CARP_GROUP (u_int32_t)0xe0000012 /* 224.0.0.18 */ 387a306c902SMax Laier #define INADDR_PFSYNC_GROUP (u_int32_t)0xe00000f0 /* 224.0.0.240 */ 388e97c58c8SMatthew N. Dodd #define INADDR_ALLMDNS_GROUP (u_int32_t)0xe00000fb /* 224.0.0.251 */ 389fac6d93bSJohn Birrell #define INADDR_MAX_LOCAL_GROUP (u_int32_t)0xe00000ff /* 224.0.0.255 */ 390df8bae1dSRodney W. Grimes 391df8bae1dSRodney W. Grimes #define IN_LOOPBACKNET 127 /* official! */ 392df8bae1dSRodney W. Grimes 393df8bae1dSRodney W. Grimes /* 394df8bae1dSRodney W. Grimes * Options for use with [gs]etsockopt at the IP level. 395df8bae1dSRodney W. Grimes * First word of comment is data type; bool is stored in int. 396df8bae1dSRodney W. Grimes */ 397df8bae1dSRodney W. Grimes #define IP_OPTIONS 1 /* buf/ip_opts; set/get IP options */ 398df8bae1dSRodney W. Grimes #define IP_HDRINCL 2 /* int; header is included with data */ 399df8bae1dSRodney W. Grimes #define IP_TOS 3 /* int; IP type of service and preced. */ 400df8bae1dSRodney W. Grimes #define IP_TTL 4 /* int; IP time to live */ 401df8bae1dSRodney W. Grimes #define IP_RECVOPTS 5 /* bool; receive all IP opts w/dgram */ 402df8bae1dSRodney W. Grimes #define IP_RECVRETOPTS 6 /* bool; receive IP opts for response */ 403df8bae1dSRodney W. Grimes #define IP_RECVDSTADDR 7 /* bool; receive IP dst addr w/dgram */ 404c557ae16SIan Dowse #define IP_SENDSRCADDR IP_RECVDSTADDR /* cmsg_type to set src addr */ 405df8bae1dSRodney W. Grimes #define IP_RETOPTS 8 /* ip_opts; set/get IP options */ 40671498f30SBruce M Simpson #define IP_MULTICAST_IF 9 /* struct in_addr *or* struct ip_mreqn; 40771498f30SBruce M Simpson * set/get IP multicast i/f */ 408df8bae1dSRodney W. Grimes #define IP_MULTICAST_TTL 10 /* u_char; set/get IP multicast ttl */ 409df8bae1dSRodney W. Grimes #define IP_MULTICAST_LOOP 11 /* u_char; set/get IP multicast loopback */ 410df8bae1dSRodney W. Grimes #define IP_ADD_MEMBERSHIP 12 /* ip_mreq; add an IP group membership */ 411df8bae1dSRodney W. Grimes #define IP_DROP_MEMBERSHIP 13 /* ip_mreq; drop an IP group membership */ 412f0068c4aSGarrett Wollman #define IP_MULTICAST_VIF 14 /* set/get IP mcast virt. iface */ 413f0068c4aSGarrett Wollman #define IP_RSVP_ON 15 /* enable RSVP in kernel */ 414f0068c4aSGarrett Wollman #define IP_RSVP_OFF 16 /* disable RSVP in kernel */ 4151c5de19aSGarrett Wollman #define IP_RSVP_VIF_ON 17 /* set RSVP per-vif socket */ 4161c5de19aSGarrett Wollman #define IP_RSVP_VIF_OFF 18 /* unset RSVP per-vif socket */ 41733b3ac06SPeter Wemm #define IP_PORTRANGE 19 /* int; range to choose for unspec port */ 41882c23ebaSBill Fenner #define IP_RECVIF 20 /* bool; receive reception if w/dgram */ 41976429de4SYoshinobu Inoue /* for IPSEC */ 42076429de4SYoshinobu Inoue #define IP_IPSEC_POLICY 21 /* int; set/get security policy */ 42176429de4SYoshinobu Inoue #define IP_FAITH 22 /* bool; accept FAITH'ed connections */ 422df8bae1dSRodney W. Grimes 4238afa2304SBruce M Simpson #define IP_ONESBCAST 23 /* bool: send all-ones broadcast */ 424f44270e7SPawel Jakub Dawidek #define IP_BINDANY 24 /* bool: allow bind to any address */ 4258afa2304SBruce M Simpson 426de9fc6bcSLuigi Rizzo /* 427de9fc6bcSLuigi Rizzo * Options for controlling the firewall and dummynet. 428de9fc6bcSLuigi Rizzo * Historical options (from 40 to 64) will eventually be 429de9fc6bcSLuigi Rizzo * replaced by only two options, IP_FW3 and IP_DUMMYNET3. 430de9fc6bcSLuigi Rizzo */ 431cd8b5ae0SRuslan Ermilov #define IP_FW_TABLE_ADD 40 /* add entry */ 432cd8b5ae0SRuslan Ermilov #define IP_FW_TABLE_DEL 41 /* delete entry */ 433cd8b5ae0SRuslan Ermilov #define IP_FW_TABLE_FLUSH 42 /* flush table */ 434cd8b5ae0SRuslan Ermilov #define IP_FW_TABLE_GETSIZE 43 /* get table size */ 435cd8b5ae0SRuslan Ermilov #define IP_FW_TABLE_LIST 44 /* list table contents */ 436cd8b5ae0SRuslan Ermilov 437de9fc6bcSLuigi Rizzo #define IP_FW3 48 /* generic ipfw v.3 sockopts */ 438de9fc6bcSLuigi Rizzo #define IP_DUMMYNET3 49 /* generic dummynet v.3 sockopts */ 439de9fc6bcSLuigi Rizzo 440fed1c7e9SSøren Schmidt #define IP_FW_ADD 50 /* add a firewall rule to chain */ 441fed1c7e9SSøren Schmidt #define IP_FW_DEL 51 /* delete a firewall rule from chain */ 442fed1c7e9SSøren Schmidt #define IP_FW_FLUSH 52 /* flush firewall rule chain */ 443af44ef0aSAlexander Langer #define IP_FW_ZERO 53 /* clear single/all firewall counter(s) */ 444fed1c7e9SSøren Schmidt #define IP_FW_GET 54 /* get entire firewall rule chain */ 4450b6c1a83SBrian Feldman #define IP_FW_RESETLOG 55 /* reset logging counters */ 446fed1c7e9SSøren Schmidt 447ff2f6fe8SPaolo Pisati #define IP_FW_NAT_CFG 56 /* add/config a nat rule */ 448ff2f6fe8SPaolo Pisati #define IP_FW_NAT_DEL 57 /* delete a nat rule */ 449ff2f6fe8SPaolo Pisati #define IP_FW_NAT_GET_CONFIG 58 /* get configuration of a nat rule */ 450ff2f6fe8SPaolo Pisati #define IP_FW_NAT_GET_LOG 59 /* get log of a nat rule */ 451ff2f6fe8SPaolo Pisati 452b715f178SLuigi Rizzo #define IP_DUMMYNET_CONFIGURE 60 /* add/configure a dummynet pipe */ 453b715f178SLuigi Rizzo #define IP_DUMMYNET_DEL 61 /* delete a dummynet pipe from chain */ 454b715f178SLuigi Rizzo #define IP_DUMMYNET_FLUSH 62 /* flush dummynet */ 455b715f178SLuigi Rizzo #define IP_DUMMYNET_GET 64 /* get entire dummynet pipes */ 456b715f178SLuigi Rizzo 4574957466bSMatthew N. Dodd #define IP_RECVTTL 65 /* bool; receive IP TTL w/dgram */ 458936cd18dSAndre Oppermann #define IP_MINTTL 66 /* minimum TTL for packet or drop */ 459b2828ad2SAndre Oppermann #define IP_DONTFRAG 67 /* don't fragment packet */ 4604957466bSMatthew N. Dodd 46171498f30SBruce M Simpson /* IPv4 Source Filter Multicast API [RFC3678] */ 46271498f30SBruce M Simpson #define IP_ADD_SOURCE_MEMBERSHIP 70 /* join a source-specific group */ 46371498f30SBruce M Simpson #define IP_DROP_SOURCE_MEMBERSHIP 71 /* drop a single source */ 46471498f30SBruce M Simpson #define IP_BLOCK_SOURCE 72 /* block a source */ 46571498f30SBruce M Simpson #define IP_UNBLOCK_SOURCE 73 /* unblock a source */ 46671498f30SBruce M Simpson 46771498f30SBruce M Simpson /* The following option is private; do not use it from user applications. */ 46871498f30SBruce M Simpson #define IP_MSFILTER 74 /* set/get filter list */ 46971498f30SBruce M Simpson 47071498f30SBruce M Simpson /* Protocol Independent Multicast API [RFC3678] */ 47171498f30SBruce M Simpson #define MCAST_JOIN_GROUP 80 /* join an any-source group */ 47271498f30SBruce M Simpson #define MCAST_LEAVE_GROUP 81 /* leave all sources for group */ 47371498f30SBruce M Simpson #define MCAST_JOIN_SOURCE_GROUP 82 /* join a source-specific group */ 47471498f30SBruce M Simpson #define MCAST_LEAVE_SOURCE_GROUP 83 /* leave a single source */ 47571498f30SBruce M Simpson #define MCAST_BLOCK_SOURCE 84 /* block a source */ 47671498f30SBruce M Simpson #define MCAST_UNBLOCK_SOURCE 85 /* unblock a source */ 47771498f30SBruce M Simpson 478df8bae1dSRodney W. Grimes /* 479df8bae1dSRodney W. Grimes * Defaults and limits for options 480df8bae1dSRodney W. Grimes */ 481df8bae1dSRodney W. Grimes #define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */ 482df8bae1dSRodney W. Grimes #define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */ 4833548bfc9SBruce M Simpson 4843548bfc9SBruce M Simpson /* 4853548bfc9SBruce M Simpson * The imo_membership vector for each socket is now dynamically allocated at 4863548bfc9SBruce M Simpson * run-time, bounded by USHRT_MAX, and is reallocated when needed, sized 4873548bfc9SBruce M Simpson * according to a power-of-two increment. 4883548bfc9SBruce M Simpson */ 4893548bfc9SBruce M Simpson #define IP_MIN_MEMBERSHIPS 31 4903548bfc9SBruce M Simpson #define IP_MAX_MEMBERSHIPS 4095 491b554b6caSBruce M Simpson #define IP_MAX_SOURCE_FILTER 1024 /* XXX to be unused */ 492b554b6caSBruce M Simpson 493b554b6caSBruce M Simpson /* 494b554b6caSBruce M Simpson * Default resource limits for IPv4 multicast source filtering. 495b554b6caSBruce M Simpson * These may be modified by sysctl. 496b554b6caSBruce M Simpson */ 497b554b6caSBruce M Simpson #define IP_MAX_GROUP_SRC_FILTER 512 /* sources per group */ 498b554b6caSBruce M Simpson #define IP_MAX_SOCK_SRC_FILTER 128 /* sources per socket/group */ 499d10910e6SBruce M Simpson #define IP_MAX_SOCK_MUTE_FILTER 128 /* XXX no longer used */ 500df8bae1dSRodney W. Grimes 501df8bae1dSRodney W. Grimes /* 502df8bae1dSRodney W. Grimes * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. 503df8bae1dSRodney W. Grimes */ 504df8bae1dSRodney W. Grimes struct ip_mreq { 505df8bae1dSRodney W. Grimes struct in_addr imr_multiaddr; /* IP multicast address of group */ 506df8bae1dSRodney W. Grimes struct in_addr imr_interface; /* local IP address of interface */ 507df8bae1dSRodney W. Grimes }; 508df8bae1dSRodney W. Grimes 509df8bae1dSRodney W. Grimes /* 51071498f30SBruce M Simpson * Modified argument structure for IP_MULTICAST_IF, obtained from Linux. 51171498f30SBruce M Simpson * This is used to specify an interface index for multicast sends, as 51271498f30SBruce M Simpson * the IPv4 legacy APIs do not support this (unless IP_SENDIF is available). 51371498f30SBruce M Simpson */ 51471498f30SBruce M Simpson struct ip_mreqn { 51571498f30SBruce M Simpson struct in_addr imr_multiaddr; /* IP multicast address of group */ 51671498f30SBruce M Simpson struct in_addr imr_address; /* local IP address of interface */ 51771498f30SBruce M Simpson int imr_ifindex; /* Interface index; cast to uint32_t */ 51871498f30SBruce M Simpson }; 51971498f30SBruce M Simpson 52071498f30SBruce M Simpson /* 52171498f30SBruce M Simpson * Argument structure for IPv4 Multicast Source Filter APIs. [RFC3678] 52271498f30SBruce M Simpson */ 52371498f30SBruce M Simpson struct ip_mreq_source { 52471498f30SBruce M Simpson struct in_addr imr_multiaddr; /* IP multicast address of group */ 52571498f30SBruce M Simpson struct in_addr imr_sourceaddr; /* IP address of source */ 52671498f30SBruce M Simpson struct in_addr imr_interface; /* local IP address of interface */ 52771498f30SBruce M Simpson }; 52871498f30SBruce M Simpson 52971498f30SBruce M Simpson /* 53071498f30SBruce M Simpson * Argument structures for Protocol-Independent Multicast Source 53171498f30SBruce M Simpson * Filter APIs. [RFC3678] 53271498f30SBruce M Simpson */ 53371498f30SBruce M Simpson struct group_req { 53471498f30SBruce M Simpson uint32_t gr_interface; /* interface index */ 53571498f30SBruce M Simpson struct sockaddr_storage gr_group; /* group address */ 53671498f30SBruce M Simpson }; 53771498f30SBruce M Simpson 53871498f30SBruce M Simpson struct group_source_req { 53971498f30SBruce M Simpson uint32_t gsr_interface; /* interface index */ 54071498f30SBruce M Simpson struct sockaddr_storage gsr_group; /* group address */ 54171498f30SBruce M Simpson struct sockaddr_storage gsr_source; /* source address */ 54271498f30SBruce M Simpson }; 54371498f30SBruce M Simpson 54471498f30SBruce M Simpson #ifndef __MSFILTERREQ_DEFINED 54571498f30SBruce M Simpson #define __MSFILTERREQ_DEFINED 54671498f30SBruce M Simpson /* 54771498f30SBruce M Simpson * The following structure is private; do not use it from user applications. 54871498f30SBruce M Simpson * It is used to communicate IP_MSFILTER/IPV6_MSFILTER information between 54971498f30SBruce M Simpson * the RFC 3678 libc functions and the kernel. 55071498f30SBruce M Simpson */ 55171498f30SBruce M Simpson struct __msfilterreq { 55271498f30SBruce M Simpson uint32_t msfr_ifindex; /* interface index */ 55371498f30SBruce M Simpson uint32_t msfr_fmode; /* filter mode for group */ 55471498f30SBruce M Simpson uint32_t msfr_nsrcs; /* # of sources in msfr_srcs */ 55571498f30SBruce M Simpson struct sockaddr_storage msfr_group; /* group address */ 55671498f30SBruce M Simpson struct sockaddr_storage *msfr_srcs; /* pointer to the first member 55771498f30SBruce M Simpson * of a contiguous array of 55871498f30SBruce M Simpson * sources to filter in full. 55971498f30SBruce M Simpson */ 56071498f30SBruce M Simpson }; 56171498f30SBruce M Simpson #endif 56271498f30SBruce M Simpson 56371498f30SBruce M Simpson struct sockaddr; 56471498f30SBruce M Simpson 56571498f30SBruce M Simpson /* 56671498f30SBruce M Simpson * Advanced (Full-state) APIs [RFC3678] 56771498f30SBruce M Simpson * The RFC specifies uint_t for the 6th argument to [sg]etsourcefilter(). 56871498f30SBruce M Simpson * We use uint32_t here to be consistent. 56971498f30SBruce M Simpson */ 57071498f30SBruce M Simpson int setipv4sourcefilter(int, struct in_addr, struct in_addr, uint32_t, 57171498f30SBruce M Simpson uint32_t, struct in_addr *); 57271498f30SBruce M Simpson int getipv4sourcefilter(int, struct in_addr, struct in_addr, uint32_t *, 57371498f30SBruce M Simpson uint32_t *, struct in_addr *); 57471498f30SBruce M Simpson int setsourcefilter(int, uint32_t, struct sockaddr *, socklen_t, 57571498f30SBruce M Simpson uint32_t, uint32_t, struct sockaddr_storage *); 57671498f30SBruce M Simpson int getsourcefilter(int, uint32_t, struct sockaddr *, socklen_t, 57771498f30SBruce M Simpson uint32_t *, uint32_t *, struct sockaddr_storage *); 57871498f30SBruce M Simpson 57971498f30SBruce M Simpson /* 58071498f30SBruce M Simpson * Filter modes; also used to represent per-socket filter mode internally. 58171498f30SBruce M Simpson */ 582b554b6caSBruce M Simpson #define MCAST_UNDEFINED 0 /* fmode: not yet defined */ 58371498f30SBruce M Simpson #define MCAST_INCLUDE 1 /* fmode: include these source(s) */ 58471498f30SBruce M Simpson #define MCAST_EXCLUDE 2 /* fmode: exclude these source(s) */ 58571498f30SBruce M Simpson 58671498f30SBruce M Simpson /* 58733b3ac06SPeter Wemm * Argument for IP_PORTRANGE: 58833b3ac06SPeter Wemm * - which range to search when port is unspecified at bind() or connect() 58933b3ac06SPeter Wemm */ 59033b3ac06SPeter Wemm #define IP_PORTRANGE_DEFAULT 0 /* default range */ 59133b3ac06SPeter Wemm #define IP_PORTRANGE_HIGH 1 /* "high" - request firewall bypass */ 59233b3ac06SPeter Wemm #define IP_PORTRANGE_LOW 2 /* "low" - vouchsafe security */ 59333b3ac06SPeter Wemm 59433b3ac06SPeter Wemm /* 595df8bae1dSRodney W. Grimes * Definitions for inet sysctl operations. 596df8bae1dSRodney W. Grimes * 597df8bae1dSRodney W. Grimes * Third level is protocol number. 598df8bae1dSRodney W. Grimes * Fourth level is desired variable within that protocol. 599df8bae1dSRodney W. Grimes */ 600686cdd19SJun-ichiro itojun Hagino #define IPPROTO_MAXID (IPPROTO_AH + 1) /* don't list to IPPROTO_MAX */ 601df8bae1dSRodney W. Grimes 602df8bae1dSRodney W. Grimes #define CTL_IPPROTO_NAMES { \ 603df8bae1dSRodney W. Grimes { "ip", CTLTYPE_NODE }, \ 604df8bae1dSRodney W. Grimes { "icmp", CTLTYPE_NODE }, \ 605df8bae1dSRodney W. Grimes { "igmp", CTLTYPE_NODE }, \ 606df8bae1dSRodney W. Grimes { "ggp", CTLTYPE_NODE }, \ 607df8bae1dSRodney W. Grimes { 0, 0 }, \ 608df8bae1dSRodney W. Grimes { 0, 0 }, \ 609df8bae1dSRodney W. Grimes { "tcp", CTLTYPE_NODE }, \ 610df8bae1dSRodney W. Grimes { 0, 0 }, \ 611df8bae1dSRodney W. Grimes { "egp", CTLTYPE_NODE }, \ 612df8bae1dSRodney W. Grimes { 0, 0 }, \ 613df8bae1dSRodney W. Grimes { 0, 0 }, \ 614df8bae1dSRodney W. Grimes { 0, 0 }, \ 615df8bae1dSRodney W. Grimes { "pup", CTLTYPE_NODE }, \ 616df8bae1dSRodney W. Grimes { 0, 0 }, \ 617df8bae1dSRodney W. Grimes { 0, 0 }, \ 618df8bae1dSRodney W. Grimes { 0, 0 }, \ 619df8bae1dSRodney W. Grimes { 0, 0 }, \ 620df8bae1dSRodney W. Grimes { "udp", CTLTYPE_NODE }, \ 621df8bae1dSRodney W. Grimes { 0, 0 }, \ 622df8bae1dSRodney W. Grimes { 0, 0 }, \ 623df8bae1dSRodney W. Grimes { 0, 0 }, \ 624df8bae1dSRodney W. Grimes { 0, 0 }, \ 625df8bae1dSRodney W. Grimes { "idp", CTLTYPE_NODE }, \ 626686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 627686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 628686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 629686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 630686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 631686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 632686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 633686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 634686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 635686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 636686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 637686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 638686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 639686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 640686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 641686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 642686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 643686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 644686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 645686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 646686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 647686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 648686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 649686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 650686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 651686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 652686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 653686cdd19SJun-ichiro itojun Hagino { 0, 0 }, \ 654686cdd19SJun-ichiro itojun Hagino { "ipsec", CTLTYPE_NODE }, \ 6551e78ac21SJeffrey Hsu { 0, 0 }, \ 6561e78ac21SJeffrey Hsu { 0, 0 }, \ 6571e78ac21SJeffrey Hsu { 0, 0 }, \ 6581e78ac21SJeffrey Hsu { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ 6591e78ac21SJeffrey Hsu { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ 6601e78ac21SJeffrey Hsu { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ 6611e78ac21SJeffrey Hsu { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ 6621e78ac21SJeffrey Hsu { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ 6631e78ac21SJeffrey Hsu { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ 6641e78ac21SJeffrey Hsu { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ 6651e78ac21SJeffrey Hsu { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ 6661e78ac21SJeffrey Hsu { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ 6671e78ac21SJeffrey Hsu { 0, 0 }, \ 6681e78ac21SJeffrey Hsu { 0, 0 }, \ 6691e78ac21SJeffrey Hsu { 0, 0 }, \ 6701e78ac21SJeffrey Hsu { "pim", CTLTYPE_NODE }, \ 671df8bae1dSRodney W. Grimes } 672df8bae1dSRodney W. Grimes 673df8bae1dSRodney W. Grimes /* 674df8bae1dSRodney W. Grimes * Names for IP sysctl objects 675df8bae1dSRodney W. Grimes */ 676df8bae1dSRodney W. Grimes #define IPCTL_FORWARDING 1 /* act as router */ 677df8bae1dSRodney W. Grimes #define IPCTL_SENDREDIRECTS 2 /* may send redirects when forwarding */ 678df8bae1dSRodney W. Grimes #define IPCTL_DEFTTL 3 /* default TTL */ 679df8bae1dSRodney W. Grimes #ifdef notyet 680df8bae1dSRodney W. Grimes #define IPCTL_DEFMTU 4 /* default MTU */ 681df8bae1dSRodney W. Grimes #endif 6825be2baf8SGarrett Wollman #define IPCTL_RTEXPIRE 5 /* cloned route expiration time */ 683ea80aed1SGarrett Wollman #define IPCTL_RTMINEXPIRE 6 /* min value for expiration time */ 684ea80aed1SGarrett Wollman #define IPCTL_RTMAXCACHE 7 /* trigger level for dynamic expire */ 6851025071fSGarrett Wollman #define IPCTL_SOURCEROUTE 8 /* may perform source routes */ 68642c03a52SPeter Wemm #define IPCTL_DIRECTEDBROADCAST 9 /* may re-broadcast received packets */ 687054ef370SGarrett Wollman #define IPCTL_INTRQMAXLEN 10 /* max length of netisr queue */ 688054ef370SGarrett Wollman #define IPCTL_INTRQDROPS 11 /* number of netisr q drops */ 6896fce01c9SGarrett Wollman #define IPCTL_STATS 12 /* ipstat structure */ 6904fce5804SGuido van Rooij #define IPCTL_ACCEPTSOURCEROUTE 13 /* may accept source routed packets */ 6911f91d8c5SDavid Greenman #define IPCTL_FASTFORWARDING 14 /* use fast IP forwarding code */ 6926a800098SYoshinobu Inoue #define IPCTL_KEEPFAITH 15 /* FAITH IPv4->IPv6 translater ctl */ 69376429de4SYoshinobu Inoue #define IPCTL_GIF_TTL 16 /* default TTL for gif encap packet */ 69476429de4SYoshinobu Inoue #define IPCTL_MAXID 17 695df8bae1dSRodney W. Grimes 696df8bae1dSRodney W. Grimes #define IPCTL_NAMES { \ 697df8bae1dSRodney W. Grimes { 0, 0 }, \ 698df8bae1dSRodney W. Grimes { "forwarding", CTLTYPE_INT }, \ 699df8bae1dSRodney W. Grimes { "redirect", CTLTYPE_INT }, \ 700df8bae1dSRodney W. Grimes { "ttl", CTLTYPE_INT }, \ 701df8bae1dSRodney W. Grimes { "mtu", CTLTYPE_INT }, \ 7025be2baf8SGarrett Wollman { "rtexpire", CTLTYPE_INT }, \ 703ea80aed1SGarrett Wollman { "rtminexpire", CTLTYPE_INT }, \ 704ea80aed1SGarrett Wollman { "rtmaxcache", CTLTYPE_INT }, \ 7051025071fSGarrett Wollman { "sourceroute", CTLTYPE_INT }, \ 70642c03a52SPeter Wemm { "directed-broadcast", CTLTYPE_INT }, \ 707054ef370SGarrett Wollman { "intr-queue-maxlen", CTLTYPE_INT }, \ 708054ef370SGarrett Wollman { "intr-queue-drops", CTLTYPE_INT }, \ 7096fce01c9SGarrett Wollman { "stats", CTLTYPE_STRUCT }, \ 7104fce5804SGuido van Rooij { "accept_sourceroute", CTLTYPE_INT }, \ 7111f91d8c5SDavid Greenman { "fastforwarding", CTLTYPE_INT }, \ 712df8bae1dSRodney W. Grimes } 713df8bae1dSRodney W. Grimes 71458631bbeSMike Barcroft #endif /* __BSD_VISIBLE */ 71558631bbeSMike Barcroft 716215db137SPeter Wemm #ifdef _KERNEL 71758631bbeSMike Barcroft 718215db137SPeter Wemm struct ifnet; struct mbuf; /* forward declarations for Standard C */ 719ef0cdf33SGarrett Wollman 7204d77a549SAlfred Perlstein int in_broadcast(struct in_addr, struct ifnet *); 7214d77a549SAlfred Perlstein int in_canforward(struct in_addr); 7224d77a549SAlfred Perlstein int in_localaddr(struct in_addr); 7232eccc90bSAndre Oppermann int in_localip(struct in_addr); 72475880123SAttilio Rao int inet_aton(const char *, struct in_addr *); /* in libkern */ 7254d77a549SAlfred Perlstein char *inet_ntoa(struct in_addr); /* in libkern */ 7264d77a549SAlfred Perlstein char *inet_ntoa_r(struct in_addr ina, char *buf); /* in libkern */ 727b1c53bc9SRobert Watson void in_ifdetach(struct ifnet *); 72823bf9953SPoul-Henning Kamp 729386fefa3SMaxim Sobolev #define in_hosteq(s, t) ((s).s_addr == (t).s_addr) 730386fefa3SMaxim Sobolev #define in_nullhost(x) ((x).s_addr == INADDR_ANY) 731b554b6caSBruce M Simpson #define in_allhosts(x) ((x).s_addr == htonl(INADDR_ALLHOSTS_GROUP)) 732386fefa3SMaxim Sobolev 7339a10980eSJonathan Lemon #define satosin(sa) ((struct sockaddr_in *)(sa)) 7349a10980eSJonathan Lemon #define sintosa(sin) ((struct sockaddr *)(sin)) 7359a10980eSJonathan Lemon #define ifatoia(ifa) ((struct in_ifaddr *)(ifa)) 7369a10980eSJonathan Lemon 737fd8e4ebcSMike Barcroft #endif /* _KERNEL */ 738fd8e4ebcSMike Barcroft 73958631bbeSMike Barcroft /* INET6 stuff */ 74058631bbeSMike Barcroft #if __POSIX_VISIBLE >= 200112 74158631bbeSMike Barcroft #define __KAME_NETINET_IN_H_INCLUDED_ 74258631bbeSMike Barcroft #include <netinet6/in6.h> 74358631bbeSMike Barcroft #undef __KAME_NETINET_IN_H_INCLUDED_ 744707f139eSPaul Richards #endif 74558631bbeSMike Barcroft 74658631bbeSMike Barcroft #endif /* !_NETINET_IN_H_*/ 747