1*4a5d661aSToomas Soome /*- 2*4a5d661aSToomas Soome * Copyright (c) 1982, 1986, 1990, 1993 3*4a5d661aSToomas Soome * The Regents of the University of California. All rights reserved. 4*4a5d661aSToomas Soome * 5*4a5d661aSToomas Soome * Redistribution and use in source and binary forms, with or without 6*4a5d661aSToomas Soome * modification, are permitted provided that the following conditions 7*4a5d661aSToomas Soome * are met: 8*4a5d661aSToomas Soome * 1. Redistributions of source code must retain the above copyright 9*4a5d661aSToomas Soome * notice, this list of conditions and the following disclaimer. 10*4a5d661aSToomas Soome * 2. Redistributions in binary form must reproduce the above copyright 11*4a5d661aSToomas Soome * notice, this list of conditions and the following disclaimer in the 12*4a5d661aSToomas Soome * documentation and/or other materials provided with the distribution. 13*4a5d661aSToomas Soome * 4. Neither the name of the University nor the names of its contributors 14*4a5d661aSToomas Soome * may be used to endorse or promote products derived from this software 15*4a5d661aSToomas Soome * without specific prior written permission. 16*4a5d661aSToomas Soome * 17*4a5d661aSToomas Soome * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18*4a5d661aSToomas Soome * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19*4a5d661aSToomas Soome * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20*4a5d661aSToomas Soome * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21*4a5d661aSToomas Soome * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22*4a5d661aSToomas Soome * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23*4a5d661aSToomas Soome * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24*4a5d661aSToomas Soome * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25*4a5d661aSToomas Soome * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26*4a5d661aSToomas Soome * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27*4a5d661aSToomas Soome * SUCH DAMAGE. 28*4a5d661aSToomas Soome * 29*4a5d661aSToomas Soome * @(#)in.h 8.3 (Berkeley) 1/3/94 30*4a5d661aSToomas Soome * $FreeBSD$ 31*4a5d661aSToomas Soome */ 32*4a5d661aSToomas Soome 33*4a5d661aSToomas Soome #ifndef _NETINET_IN_H_ 34*4a5d661aSToomas Soome #define _NETINET_IN_H_ 35*4a5d661aSToomas Soome 36*4a5d661aSToomas Soome #include <sys/cdefs.h> 37*4a5d661aSToomas Soome #include <sys/_types.h> 38*4a5d661aSToomas Soome #include <machine/endian.h> 39*4a5d661aSToomas Soome 40*4a5d661aSToomas Soome /* Protocols common to RFC 1700, POSIX, and X/Open. */ 41*4a5d661aSToomas Soome #define IPPROTO_IP 0 /* dummy for IP */ 42*4a5d661aSToomas Soome #define IPPROTO_ICMP 1 /* control message protocol */ 43*4a5d661aSToomas Soome #define IPPROTO_TCP 6 /* tcp */ 44*4a5d661aSToomas Soome #define IPPROTO_UDP 17 /* user datagram protocol */ 45*4a5d661aSToomas Soome 46*4a5d661aSToomas Soome #define INADDR_ANY ((in_addr_t)0x00000000) 47*4a5d661aSToomas Soome #define INADDR_BROADCAST ((in_addr_t)0xffffffff) /* must be masked */ 48*4a5d661aSToomas Soome 49*4a5d661aSToomas Soome #ifndef _UINT8_T_DECLARED 50*4a5d661aSToomas Soome typedef __uint8_t uint8_t; 51*4a5d661aSToomas Soome #define _UINT8_T_DECLARED 52*4a5d661aSToomas Soome #endif 53*4a5d661aSToomas Soome 54*4a5d661aSToomas Soome #ifndef _UINT16_T_DECLARED 55*4a5d661aSToomas Soome typedef __uint16_t uint16_t; 56*4a5d661aSToomas Soome #define _UINT16_T_DECLARED 57*4a5d661aSToomas Soome #endif 58*4a5d661aSToomas Soome 59*4a5d661aSToomas Soome #ifndef _UINT32_T_DECLARED 60*4a5d661aSToomas Soome typedef __uint32_t uint32_t; 61*4a5d661aSToomas Soome #define _UINT32_T_DECLARED 62*4a5d661aSToomas Soome #endif 63*4a5d661aSToomas Soome 64*4a5d661aSToomas Soome #ifndef _IN_ADDR_T_DECLARED 65*4a5d661aSToomas Soome typedef uint32_t in_addr_t; 66*4a5d661aSToomas Soome #define _IN_ADDR_T_DECLARED 67*4a5d661aSToomas Soome #endif 68*4a5d661aSToomas Soome 69*4a5d661aSToomas Soome #ifndef _IN_PORT_T_DECLARED 70*4a5d661aSToomas Soome typedef uint16_t in_port_t; 71*4a5d661aSToomas Soome #define _IN_PORT_T_DECLARED 72*4a5d661aSToomas Soome #endif 73*4a5d661aSToomas Soome 74*4a5d661aSToomas Soome #ifndef _SA_FAMILY_T_DECLARED 75*4a5d661aSToomas Soome typedef __sa_family_t sa_family_t; 76*4a5d661aSToomas Soome #define _SA_FAMILY_T_DECLARED 77*4a5d661aSToomas Soome #endif 78*4a5d661aSToomas Soome 79*4a5d661aSToomas Soome /* Internet address (a structure for historical reasons). */ 80*4a5d661aSToomas Soome #ifndef _STRUCT_IN_ADDR_DECLARED 81*4a5d661aSToomas Soome struct in_addr { 82*4a5d661aSToomas Soome in_addr_t s_addr; 83*4a5d661aSToomas Soome }; 84*4a5d661aSToomas Soome #define _STRUCT_IN_ADDR_DECLARED 85*4a5d661aSToomas Soome #endif 86*4a5d661aSToomas Soome 87*4a5d661aSToomas Soome #ifndef _SOCKLEN_T_DECLARED 88*4a5d661aSToomas Soome typedef __socklen_t socklen_t; 89*4a5d661aSToomas Soome #define _SOCKLEN_T_DECLARED 90*4a5d661aSToomas Soome #endif 91*4a5d661aSToomas Soome 92*4a5d661aSToomas Soome #include <sys/_sockaddr_storage.h> 93*4a5d661aSToomas Soome 94*4a5d661aSToomas Soome /* Socket address, internet style. */ 95*4a5d661aSToomas Soome struct sockaddr_in { 96*4a5d661aSToomas Soome uint8_t sin_len; 97*4a5d661aSToomas Soome sa_family_t sin_family; 98*4a5d661aSToomas Soome in_port_t sin_port; 99*4a5d661aSToomas Soome struct in_addr sin_addr; 100*4a5d661aSToomas Soome char sin_zero[8]; 101*4a5d661aSToomas Soome }; 102*4a5d661aSToomas Soome 103*4a5d661aSToomas Soome #if !defined(_KERNEL) && __POSIX_VISIBLE >= 200112 104*4a5d661aSToomas Soome 105*4a5d661aSToomas Soome #ifndef _BYTEORDER_PROTOTYPED 106*4a5d661aSToomas Soome #define _BYTEORDER_PROTOTYPED 107*4a5d661aSToomas Soome __BEGIN_DECLS 108*4a5d661aSToomas Soome uint32_t htonl(uint32_t); 109*4a5d661aSToomas Soome uint16_t htons(uint16_t); 110*4a5d661aSToomas Soome uint32_t ntohl(uint32_t); 111*4a5d661aSToomas Soome uint16_t ntohs(uint16_t); 112*4a5d661aSToomas Soome __END_DECLS 113*4a5d661aSToomas Soome #endif 114*4a5d661aSToomas Soome 115*4a5d661aSToomas Soome #ifndef _BYTEORDER_FUNC_DEFINED 116*4a5d661aSToomas Soome #define _BYTEORDER_FUNC_DEFINED 117*4a5d661aSToomas Soome #define htonl(x) __htonl(x) 118*4a5d661aSToomas Soome #define htons(x) __htons(x) 119*4a5d661aSToomas Soome #define ntohl(x) __ntohl(x) 120*4a5d661aSToomas Soome #define ntohs(x) __ntohs(x) 121*4a5d661aSToomas Soome #endif 122*4a5d661aSToomas Soome 123*4a5d661aSToomas Soome #endif /* !_KERNEL && __POSIX_VISIBLE >= 200112 */ 124*4a5d661aSToomas Soome 125*4a5d661aSToomas Soome #if __POSIX_VISIBLE >= 200112 126*4a5d661aSToomas Soome #define IPPROTO_IPV6 41 /* IP6 header */ 127*4a5d661aSToomas Soome #define IPPROTO_RAW 255 /* raw IP packet */ 128*4a5d661aSToomas Soome #define INET_ADDRSTRLEN 16 129*4a5d661aSToomas Soome #endif 130*4a5d661aSToomas Soome 131*4a5d661aSToomas Soome #if __BSD_VISIBLE 132*4a5d661aSToomas Soome /* 133*4a5d661aSToomas Soome * Constants and structures defined by the internet system, 134*4a5d661aSToomas Soome * Per RFC 790, September 1981, and numerous additions. 135*4a5d661aSToomas Soome */ 136*4a5d661aSToomas Soome 137*4a5d661aSToomas Soome /* 138*4a5d661aSToomas Soome * Protocols (RFC 1700) 139*4a5d661aSToomas Soome */ 140*4a5d661aSToomas Soome #define IPPROTO_HOPOPTS 0 /* IP6 hop-by-hop options */ 141*4a5d661aSToomas Soome #define IPPROTO_IGMP 2 /* group mgmt protocol */ 142*4a5d661aSToomas Soome #define IPPROTO_GGP 3 /* gateway^2 (deprecated) */ 143*4a5d661aSToomas Soome #define IPPROTO_IPV4 4 /* IPv4 encapsulation */ 144*4a5d661aSToomas Soome #define IPPROTO_IPIP IPPROTO_IPV4 /* for compatibility */ 145*4a5d661aSToomas Soome #define IPPROTO_ST 7 /* Stream protocol II */ 146*4a5d661aSToomas Soome #define IPPROTO_EGP 8 /* exterior gateway protocol */ 147*4a5d661aSToomas Soome #define IPPROTO_PIGP 9 /* private interior gateway */ 148*4a5d661aSToomas Soome #define IPPROTO_RCCMON 10 /* BBN RCC Monitoring */ 149*4a5d661aSToomas Soome #define IPPROTO_NVPII 11 /* network voice protocol*/ 150*4a5d661aSToomas Soome #define IPPROTO_PUP 12 /* pup */ 151*4a5d661aSToomas Soome #define IPPROTO_ARGUS 13 /* Argus */ 152*4a5d661aSToomas Soome #define IPPROTO_EMCON 14 /* EMCON */ 153*4a5d661aSToomas Soome #define IPPROTO_XNET 15 /* Cross Net Debugger */ 154*4a5d661aSToomas Soome #define IPPROTO_CHAOS 16 /* Chaos*/ 155*4a5d661aSToomas Soome #define IPPROTO_MUX 18 /* Multiplexing */ 156*4a5d661aSToomas Soome #define IPPROTO_MEAS 19 /* DCN Measurement Subsystems */ 157*4a5d661aSToomas Soome #define IPPROTO_HMP 20 /* Host Monitoring */ 158*4a5d661aSToomas Soome #define IPPROTO_PRM 21 /* Packet Radio Measurement */ 159*4a5d661aSToomas Soome #define IPPROTO_IDP 22 /* xns idp */ 160*4a5d661aSToomas Soome #define IPPROTO_TRUNK1 23 /* Trunk-1 */ 161*4a5d661aSToomas Soome #define IPPROTO_TRUNK2 24 /* Trunk-2 */ 162*4a5d661aSToomas Soome #define IPPROTO_LEAF1 25 /* Leaf-1 */ 163*4a5d661aSToomas Soome #define IPPROTO_LEAF2 26 /* Leaf-2 */ 164*4a5d661aSToomas Soome #define IPPROTO_RDP 27 /* Reliable Data */ 165*4a5d661aSToomas Soome #define IPPROTO_IRTP 28 /* Reliable Transaction */ 166*4a5d661aSToomas Soome #define IPPROTO_TP 29 /* tp-4 w/ class negotiation */ 167*4a5d661aSToomas Soome #define IPPROTO_BLT 30 /* Bulk Data Transfer */ 168*4a5d661aSToomas Soome #define IPPROTO_NSP 31 /* Network Services */ 169*4a5d661aSToomas Soome #define IPPROTO_INP 32 /* Merit Internodal */ 170*4a5d661aSToomas Soome #define IPPROTO_SEP 33 /* Sequential Exchange */ 171*4a5d661aSToomas Soome #define IPPROTO_3PC 34 /* Third Party Connect */ 172*4a5d661aSToomas Soome #define IPPROTO_IDPR 35 /* InterDomain Policy Routing */ 173*4a5d661aSToomas Soome #define IPPROTO_XTP 36 /* XTP */ 174*4a5d661aSToomas Soome #define IPPROTO_DDP 37 /* Datagram Delivery */ 175*4a5d661aSToomas Soome #define IPPROTO_CMTP 38 /* Control Message Transport */ 176*4a5d661aSToomas Soome #define IPPROTO_TPXX 39 /* TP++ Transport */ 177*4a5d661aSToomas Soome #define IPPROTO_IL 40 /* IL transport protocol */ 178*4a5d661aSToomas Soome #define IPPROTO_SDRP 42 /* Source Demand Routing */ 179*4a5d661aSToomas Soome #define IPPROTO_ROUTING 43 /* IP6 routing header */ 180*4a5d661aSToomas Soome #define IPPROTO_FRAGMENT 44 /* IP6 fragmentation header */ 181*4a5d661aSToomas Soome #define IPPROTO_IDRP 45 /* InterDomain Routing*/ 182*4a5d661aSToomas Soome #define IPPROTO_RSVP 46 /* resource reservation */ 183*4a5d661aSToomas Soome #define IPPROTO_GRE 47 /* General Routing Encap. */ 184*4a5d661aSToomas Soome #define IPPROTO_MHRP 48 /* Mobile Host Routing */ 185*4a5d661aSToomas Soome #define IPPROTO_BHA 49 /* BHA */ 186*4a5d661aSToomas Soome #define IPPROTO_ESP 50 /* IP6 Encap Sec. Payload */ 187*4a5d661aSToomas Soome #define IPPROTO_AH 51 /* IP6 Auth Header */ 188*4a5d661aSToomas Soome #define IPPROTO_INLSP 52 /* Integ. Net Layer Security */ 189*4a5d661aSToomas Soome #define IPPROTO_SWIPE 53 /* IP with encryption */ 190*4a5d661aSToomas Soome #define IPPROTO_NHRP 54 /* Next Hop Resolution */ 191*4a5d661aSToomas Soome #define IPPROTO_MOBILE 55 /* IP Mobility */ 192*4a5d661aSToomas Soome #define IPPROTO_TLSP 56 /* Transport Layer Security */ 193*4a5d661aSToomas Soome #define IPPROTO_SKIP 57 /* SKIP */ 194*4a5d661aSToomas Soome #define IPPROTO_ICMPV6 58 /* ICMP6 */ 195*4a5d661aSToomas Soome #define IPPROTO_NONE 59 /* IP6 no next header */ 196*4a5d661aSToomas Soome #define IPPROTO_DSTOPTS 60 /* IP6 destination option */ 197*4a5d661aSToomas Soome #define IPPROTO_AHIP 61 /* any host internal protocol */ 198*4a5d661aSToomas Soome #define IPPROTO_CFTP 62 /* CFTP */ 199*4a5d661aSToomas Soome #define IPPROTO_HELLO 63 /* "hello" routing protocol */ 200*4a5d661aSToomas Soome #define IPPROTO_SATEXPAK 64 /* SATNET/Backroom EXPAK */ 201*4a5d661aSToomas Soome #define IPPROTO_KRYPTOLAN 65 /* Kryptolan */ 202*4a5d661aSToomas Soome #define IPPROTO_RVD 66 /* Remote Virtual Disk */ 203*4a5d661aSToomas Soome #define IPPROTO_IPPC 67 /* Pluribus Packet Core */ 204*4a5d661aSToomas Soome #define IPPROTO_ADFS 68 /* Any distributed FS */ 205*4a5d661aSToomas Soome #define IPPROTO_SATMON 69 /* Satnet Monitoring */ 206*4a5d661aSToomas Soome #define IPPROTO_VISA 70 /* VISA Protocol */ 207*4a5d661aSToomas Soome #define IPPROTO_IPCV 71 /* Packet Core Utility */ 208*4a5d661aSToomas Soome #define IPPROTO_CPNX 72 /* Comp. Prot. Net. Executive */ 209*4a5d661aSToomas Soome #define IPPROTO_CPHB 73 /* Comp. Prot. HeartBeat */ 210*4a5d661aSToomas Soome #define IPPROTO_WSN 74 /* Wang Span Network */ 211*4a5d661aSToomas Soome #define IPPROTO_PVP 75 /* Packet Video Protocol */ 212*4a5d661aSToomas Soome #define IPPROTO_BRSATMON 76 /* BackRoom SATNET Monitoring */ 213*4a5d661aSToomas Soome #define IPPROTO_ND 77 /* Sun net disk proto (temp.) */ 214*4a5d661aSToomas Soome #define IPPROTO_WBMON 78 /* WIDEBAND Monitoring */ 215*4a5d661aSToomas Soome #define IPPROTO_WBEXPAK 79 /* WIDEBAND EXPAK */ 216*4a5d661aSToomas Soome #define IPPROTO_EON 80 /* ISO cnlp */ 217*4a5d661aSToomas Soome #define IPPROTO_VMTP 81 /* VMTP */ 218*4a5d661aSToomas Soome #define IPPROTO_SVMTP 82 /* Secure VMTP */ 219*4a5d661aSToomas Soome #define IPPROTO_VINES 83 /* Banyon VINES */ 220*4a5d661aSToomas Soome #define IPPROTO_TTP 84 /* TTP */ 221*4a5d661aSToomas Soome #define IPPROTO_IGP 85 /* NSFNET-IGP */ 222*4a5d661aSToomas Soome #define IPPROTO_DGP 86 /* dissimilar gateway prot. */ 223*4a5d661aSToomas Soome #define IPPROTO_TCF 87 /* TCF */ 224*4a5d661aSToomas Soome #define IPPROTO_IGRP 88 /* Cisco/GXS IGRP */ 225*4a5d661aSToomas Soome #define IPPROTO_OSPFIGP 89 /* OSPFIGP */ 226*4a5d661aSToomas Soome #define IPPROTO_SRPC 90 /* Strite RPC protocol */ 227*4a5d661aSToomas Soome #define IPPROTO_LARP 91 /* Locus Address Resoloution */ 228*4a5d661aSToomas Soome #define IPPROTO_MTP 92 /* Multicast Transport */ 229*4a5d661aSToomas Soome #define IPPROTO_AX25 93 /* AX.25 Frames */ 230*4a5d661aSToomas Soome #define IPPROTO_IPEIP 94 /* IP encapsulated in IP */ 231*4a5d661aSToomas Soome #define IPPROTO_MICP 95 /* Mobile Int.ing control */ 232*4a5d661aSToomas Soome #define IPPROTO_SCCSP 96 /* Semaphore Comm. security */ 233*4a5d661aSToomas Soome #define IPPROTO_ETHERIP 97 /* Ethernet IP encapsulation */ 234*4a5d661aSToomas Soome #define IPPROTO_ENCAP 98 /* encapsulation header */ 235*4a5d661aSToomas Soome #define IPPROTO_APES 99 /* any private encr. scheme */ 236*4a5d661aSToomas Soome #define IPPROTO_GMTP 100 /* GMTP*/ 237*4a5d661aSToomas Soome #define IPPROTO_IPCOMP 108 /* payload compression (IPComp) */ 238*4a5d661aSToomas Soome #define IPPROTO_SCTP 132 /* SCTP */ 239*4a5d661aSToomas Soome #define IPPROTO_MH 135 /* IPv6 Mobility Header */ 240*4a5d661aSToomas Soome #define IPPROTO_UDPLITE 136 /* UDP-Lite */ 241*4a5d661aSToomas Soome #define IPPROTO_HIP 139 /* IP6 Host Identity Protocol */ 242*4a5d661aSToomas Soome #define IPPROTO_SHIM6 140 /* IP6 Shim6 Protocol */ 243*4a5d661aSToomas Soome /* 101-254: Partly Unassigned */ 244*4a5d661aSToomas Soome #define IPPROTO_PIM 103 /* Protocol Independent Mcast */ 245*4a5d661aSToomas Soome #define IPPROTO_CARP 112 /* CARP */ 246*4a5d661aSToomas Soome #define IPPROTO_PGM 113 /* PGM */ 247*4a5d661aSToomas Soome #define IPPROTO_MPLS 137 /* MPLS-in-IP */ 248*4a5d661aSToomas Soome #define IPPROTO_PFSYNC 240 /* PFSYNC */ 249*4a5d661aSToomas Soome #define IPPROTO_RESERVED_253 253 /* Reserved */ 250*4a5d661aSToomas Soome #define IPPROTO_RESERVED_254 254 /* Reserved */ 251*4a5d661aSToomas Soome /* 255: Reserved */ 252*4a5d661aSToomas Soome /* BSD Private, local use, namespace incursion, no longer used */ 253*4a5d661aSToomas Soome #define IPPROTO_OLD_DIVERT 254 /* OLD divert pseudo-proto */ 254*4a5d661aSToomas Soome #define IPPROTO_MAX 256 255*4a5d661aSToomas Soome 256*4a5d661aSToomas Soome /* last return value of *_input(), meaning "all job for this pkt is done". */ 257*4a5d661aSToomas Soome #define IPPROTO_DONE 257 258*4a5d661aSToomas Soome 259*4a5d661aSToomas Soome /* Only used internally, so can be outside the range of valid IP protocols. */ 260*4a5d661aSToomas Soome #define IPPROTO_DIVERT 258 /* divert pseudo-protocol */ 261*4a5d661aSToomas Soome #define IPPROTO_SEND 259 /* SeND pseudo-protocol */ 262*4a5d661aSToomas Soome 263*4a5d661aSToomas Soome /* 264*4a5d661aSToomas Soome * Defined to avoid confusion. The master value is defined by 265*4a5d661aSToomas Soome * PROTO_SPACER in sys/protosw.h. 266*4a5d661aSToomas Soome */ 267*4a5d661aSToomas Soome #define IPPROTO_SPACER 32767 /* spacer for loadable protos */ 268*4a5d661aSToomas Soome 269*4a5d661aSToomas Soome /* 270*4a5d661aSToomas Soome * Local port number conventions: 271*4a5d661aSToomas Soome * 272*4a5d661aSToomas Soome * When a user does a bind(2) or connect(2) with a port number of zero, 273*4a5d661aSToomas Soome * a non-conflicting local port address is chosen. 274*4a5d661aSToomas Soome * The default range is IPPORT_HIFIRSTAUTO through 275*4a5d661aSToomas Soome * IPPORT_HILASTAUTO, although that is settable by sysctl. 276*4a5d661aSToomas Soome * 277*4a5d661aSToomas Soome * A user may set the IPPROTO_IP option IP_PORTRANGE to change this 278*4a5d661aSToomas Soome * default assignment range. 279*4a5d661aSToomas Soome * 280*4a5d661aSToomas Soome * The value IP_PORTRANGE_DEFAULT causes the default behavior. 281*4a5d661aSToomas Soome * 282*4a5d661aSToomas Soome * The value IP_PORTRANGE_HIGH changes the range of candidate port numbers 283*4a5d661aSToomas Soome * into the "high" range. These are reserved for client outbound connections 284*4a5d661aSToomas Soome * which do not want to be filtered by any firewalls. 285*4a5d661aSToomas Soome * 286*4a5d661aSToomas Soome * The value IP_PORTRANGE_LOW changes the range to the "low" are 287*4a5d661aSToomas Soome * that is (by convention) restricted to privileged processes. This 288*4a5d661aSToomas Soome * convention is based on "vouchsafe" principles only. It is only secure 289*4a5d661aSToomas Soome * if you trust the remote host to restrict these ports. 290*4a5d661aSToomas Soome * 291*4a5d661aSToomas Soome * The default range of ports and the high range can be changed by 292*4a5d661aSToomas Soome * sysctl(3). (net.inet.ip.port{hi,low}{first,last}_auto) 293*4a5d661aSToomas Soome * 294*4a5d661aSToomas Soome * Changing those values has bad security implications if you are 295*4a5d661aSToomas Soome * using a stateless firewall that is allowing packets outside of that 296*4a5d661aSToomas Soome * range in order to allow transparent outgoing connections. 297*4a5d661aSToomas Soome * 298*4a5d661aSToomas Soome * Such a firewall configuration will generally depend on the use of these 299*4a5d661aSToomas Soome * default values. If you change them, you may find your Security 300*4a5d661aSToomas Soome * Administrator looking for you with a heavy object. 301*4a5d661aSToomas Soome * 302*4a5d661aSToomas Soome * For a slightly more orthodox text view on this: 303*4a5d661aSToomas Soome * 304*4a5d661aSToomas Soome * ftp://ftp.isi.edu/in-notes/iana/assignments/port-numbers 305*4a5d661aSToomas Soome * 306*4a5d661aSToomas Soome * port numbers are divided into three ranges: 307*4a5d661aSToomas Soome * 308*4a5d661aSToomas Soome * 0 - 1023 Well Known Ports 309*4a5d661aSToomas Soome * 1024 - 49151 Registered Ports 310*4a5d661aSToomas Soome * 49152 - 65535 Dynamic and/or Private Ports 311*4a5d661aSToomas Soome * 312*4a5d661aSToomas Soome */ 313*4a5d661aSToomas Soome 314*4a5d661aSToomas Soome /* 315*4a5d661aSToomas Soome * Ports < IPPORT_RESERVED are reserved for 316*4a5d661aSToomas Soome * privileged processes (e.g. root). (IP_PORTRANGE_LOW) 317*4a5d661aSToomas Soome */ 318*4a5d661aSToomas Soome #define IPPORT_RESERVED 1024 319*4a5d661aSToomas Soome 320*4a5d661aSToomas Soome /* 321*4a5d661aSToomas Soome * Default local port range, used by IP_PORTRANGE_DEFAULT 322*4a5d661aSToomas Soome */ 323*4a5d661aSToomas Soome #define IPPORT_EPHEMERALFIRST 10000 324*4a5d661aSToomas Soome #define IPPORT_EPHEMERALLAST 65535 325*4a5d661aSToomas Soome 326*4a5d661aSToomas Soome /* 327*4a5d661aSToomas Soome * Dynamic port range, used by IP_PORTRANGE_HIGH. 328*4a5d661aSToomas Soome */ 329*4a5d661aSToomas Soome #define IPPORT_HIFIRSTAUTO 49152 330*4a5d661aSToomas Soome #define IPPORT_HILASTAUTO 65535 331*4a5d661aSToomas Soome 332*4a5d661aSToomas Soome /* 333*4a5d661aSToomas Soome * Scanning for a free reserved port return a value below IPPORT_RESERVED, 334*4a5d661aSToomas Soome * but higher than IPPORT_RESERVEDSTART. Traditionally the start value was 335*4a5d661aSToomas Soome * 512, but that conflicts with some well-known-services that firewalls may 336*4a5d661aSToomas Soome * have a fit if we use. 337*4a5d661aSToomas Soome */ 338*4a5d661aSToomas Soome #define IPPORT_RESERVEDSTART 600 339*4a5d661aSToomas Soome 340*4a5d661aSToomas Soome #define IPPORT_MAX 65535 341*4a5d661aSToomas Soome 342*4a5d661aSToomas Soome /* 343*4a5d661aSToomas Soome * Definitions of bits in internet address integers. 344*4a5d661aSToomas Soome * On subnets, the decomposition of addresses to host and net parts 345*4a5d661aSToomas Soome * is done according to subnet mask, not the masks here. 346*4a5d661aSToomas Soome */ 347*4a5d661aSToomas Soome #define IN_CLASSA(i) (((in_addr_t)(i) & 0x80000000) == 0) 348*4a5d661aSToomas Soome #define IN_CLASSA_NET 0xff000000 349*4a5d661aSToomas Soome #define IN_CLASSA_NSHIFT 24 350*4a5d661aSToomas Soome #define IN_CLASSA_HOST 0x00ffffff 351*4a5d661aSToomas Soome #define IN_CLASSA_MAX 128 352*4a5d661aSToomas Soome 353*4a5d661aSToomas Soome #define IN_CLASSB(i) (((in_addr_t)(i) & 0xc0000000) == 0x80000000) 354*4a5d661aSToomas Soome #define IN_CLASSB_NET 0xffff0000 355*4a5d661aSToomas Soome #define IN_CLASSB_NSHIFT 16 356*4a5d661aSToomas Soome #define IN_CLASSB_HOST 0x0000ffff 357*4a5d661aSToomas Soome #define IN_CLASSB_MAX 65536 358*4a5d661aSToomas Soome 359*4a5d661aSToomas Soome #define IN_CLASSC(i) (((in_addr_t)(i) & 0xe0000000) == 0xc0000000) 360*4a5d661aSToomas Soome #define IN_CLASSC_NET 0xffffff00 361*4a5d661aSToomas Soome #define IN_CLASSC_NSHIFT 8 362*4a5d661aSToomas Soome #define IN_CLASSC_HOST 0x000000ff 363*4a5d661aSToomas Soome 364*4a5d661aSToomas Soome #define IN_CLASSD(i) (((in_addr_t)(i) & 0xf0000000) == 0xe0000000) 365*4a5d661aSToomas Soome #define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */ 366*4a5d661aSToomas Soome #define IN_CLASSD_NSHIFT 28 /* net and host fields, but */ 367*4a5d661aSToomas Soome #define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */ 368*4a5d661aSToomas Soome #define IN_MULTICAST(i) IN_CLASSD(i) 369*4a5d661aSToomas Soome 370*4a5d661aSToomas Soome #define IN_EXPERIMENTAL(i) (((in_addr_t)(i) & 0xf0000000) == 0xf0000000) 371*4a5d661aSToomas Soome #define IN_BADCLASS(i) (((in_addr_t)(i) & 0xf0000000) == 0xf0000000) 372*4a5d661aSToomas Soome 373*4a5d661aSToomas Soome #define IN_LINKLOCAL(i) (((in_addr_t)(i) & 0xffff0000) == 0xa9fe0000) 374*4a5d661aSToomas Soome #define IN_LOOPBACK(i) (((in_addr_t)(i) & 0xff000000) == 0x7f000000) 375*4a5d661aSToomas Soome #define IN_ZERONET(i) (((in_addr_t)(i) & 0xff000000) == 0) 376*4a5d661aSToomas Soome 377*4a5d661aSToomas Soome #define IN_PRIVATE(i) ((((in_addr_t)(i) & 0xff000000) == 0x0a000000) || \ 378*4a5d661aSToomas Soome (((in_addr_t)(i) & 0xfff00000) == 0xac100000) || \ 379*4a5d661aSToomas Soome (((in_addr_t)(i) & 0xffff0000) == 0xc0a80000)) 380*4a5d661aSToomas Soome 381*4a5d661aSToomas Soome #define IN_LOCAL_GROUP(i) (((in_addr_t)(i) & 0xffffff00) == 0xe0000000) 382*4a5d661aSToomas Soome 383*4a5d661aSToomas Soome #define IN_ANY_LOCAL(i) (IN_LINKLOCAL(i) || IN_LOCAL_GROUP(i)) 384*4a5d661aSToomas Soome 385*4a5d661aSToomas Soome #define INADDR_LOOPBACK ((in_addr_t)0x7f000001) 386*4a5d661aSToomas Soome #ifndef _KERNEL 387*4a5d661aSToomas Soome #define INADDR_NONE ((in_addr_t)0xffffffff) /* -1 return */ 388*4a5d661aSToomas Soome #endif 389*4a5d661aSToomas Soome 390*4a5d661aSToomas Soome #define INADDR_UNSPEC_GROUP ((in_addr_t)0xe0000000) /* 224.0.0.0 */ 391*4a5d661aSToomas Soome #define INADDR_ALLHOSTS_GROUP ((in_addr_t)0xe0000001) /* 224.0.0.1 */ 392*4a5d661aSToomas Soome #define INADDR_ALLRTRS_GROUP ((in_addr_t)0xe0000002) /* 224.0.0.2 */ 393*4a5d661aSToomas Soome #define INADDR_ALLRPTS_GROUP ((in_addr_t)0xe0000016) /* 224.0.0.22, IGMPv3 */ 394*4a5d661aSToomas Soome #define INADDR_CARP_GROUP ((in_addr_t)0xe0000012) /* 224.0.0.18 */ 395*4a5d661aSToomas Soome #define INADDR_PFSYNC_GROUP ((in_addr_t)0xe00000f0) /* 224.0.0.240 */ 396*4a5d661aSToomas Soome #define INADDR_ALLMDNS_GROUP ((in_addr_t)0xe00000fb) /* 224.0.0.251 */ 397*4a5d661aSToomas Soome #define INADDR_MAX_LOCAL_GROUP ((in_addr_t)0xe00000ff) /* 224.0.0.255 */ 398*4a5d661aSToomas Soome 399*4a5d661aSToomas Soome #define IN_LOOPBACKNET 127 /* official! */ 400*4a5d661aSToomas Soome 401*4a5d661aSToomas Soome #define IN_RFC3021_MASK ((in_addr_t)0xfffffffe) 402*4a5d661aSToomas Soome 403*4a5d661aSToomas Soome /* 404*4a5d661aSToomas Soome * Options for use with [gs]etsockopt at the IP level. 405*4a5d661aSToomas Soome * First word of comment is data type; bool is stored in int. 406*4a5d661aSToomas Soome */ 407*4a5d661aSToomas Soome #define IP_OPTIONS 1 /* buf/ip_opts; set/get IP options */ 408*4a5d661aSToomas Soome #define IP_HDRINCL 2 /* int; header is included with data */ 409*4a5d661aSToomas Soome #define IP_TOS 3 /* int; IP type of service and preced. */ 410*4a5d661aSToomas Soome #define IP_TTL 4 /* int; IP time to live */ 411*4a5d661aSToomas Soome #define IP_RECVOPTS 5 /* bool; receive all IP opts w/dgram */ 412*4a5d661aSToomas Soome #define IP_RECVRETOPTS 6 /* bool; receive IP opts for response */ 413*4a5d661aSToomas Soome #define IP_RECVDSTADDR 7 /* bool; receive IP dst addr w/dgram */ 414*4a5d661aSToomas Soome #define IP_SENDSRCADDR IP_RECVDSTADDR /* cmsg_type to set src addr */ 415*4a5d661aSToomas Soome #define IP_RETOPTS 8 /* ip_opts; set/get IP options */ 416*4a5d661aSToomas Soome #define IP_MULTICAST_IF 9 /* struct in_addr *or* struct ip_mreqn; 417*4a5d661aSToomas Soome * set/get IP multicast i/f */ 418*4a5d661aSToomas Soome #define IP_MULTICAST_TTL 10 /* u_char; set/get IP multicast ttl */ 419*4a5d661aSToomas Soome #define IP_MULTICAST_LOOP 11 /* u_char; set/get IP multicast loopback */ 420*4a5d661aSToomas Soome #define IP_ADD_MEMBERSHIP 12 /* ip_mreq; add an IP group membership */ 421*4a5d661aSToomas Soome #define IP_DROP_MEMBERSHIP 13 /* ip_mreq; drop an IP group membership */ 422*4a5d661aSToomas Soome #define IP_MULTICAST_VIF 14 /* set/get IP mcast virt. iface */ 423*4a5d661aSToomas Soome #define IP_RSVP_ON 15 /* enable RSVP in kernel */ 424*4a5d661aSToomas Soome #define IP_RSVP_OFF 16 /* disable RSVP in kernel */ 425*4a5d661aSToomas Soome #define IP_RSVP_VIF_ON 17 /* set RSVP per-vif socket */ 426*4a5d661aSToomas Soome #define IP_RSVP_VIF_OFF 18 /* unset RSVP per-vif socket */ 427*4a5d661aSToomas Soome #define IP_PORTRANGE 19 /* int; range to choose for unspec port */ 428*4a5d661aSToomas Soome #define IP_RECVIF 20 /* bool; receive reception if w/dgram */ 429*4a5d661aSToomas Soome /* for IPSEC */ 430*4a5d661aSToomas Soome #define IP_IPSEC_POLICY 21 /* int; set/get security policy */ 431*4a5d661aSToomas Soome /* unused; was IP_FAITH */ 432*4a5d661aSToomas Soome #define IP_ONESBCAST 23 /* bool: send all-ones broadcast */ 433*4a5d661aSToomas Soome #define IP_BINDANY 24 /* bool: allow bind to any address */ 434*4a5d661aSToomas Soome #define IP_BINDMULTI 25 /* bool: allow multiple listeners on a tuple */ 435*4a5d661aSToomas Soome #define IP_RSS_LISTEN_BUCKET 26 /* int; set RSS listen bucket */ 436*4a5d661aSToomas Soome 437*4a5d661aSToomas Soome /* 438*4a5d661aSToomas Soome * Options for controlling the firewall and dummynet. 439*4a5d661aSToomas Soome * Historical options (from 40 to 64) will eventually be 440*4a5d661aSToomas Soome * replaced by only two options, IP_FW3 and IP_DUMMYNET3. 441*4a5d661aSToomas Soome */ 442*4a5d661aSToomas Soome #define IP_FW_TABLE_ADD 40 /* add entry */ 443*4a5d661aSToomas Soome #define IP_FW_TABLE_DEL 41 /* delete entry */ 444*4a5d661aSToomas Soome #define IP_FW_TABLE_FLUSH 42 /* flush table */ 445*4a5d661aSToomas Soome #define IP_FW_TABLE_GETSIZE 43 /* get table size */ 446*4a5d661aSToomas Soome #define IP_FW_TABLE_LIST 44 /* list table contents */ 447*4a5d661aSToomas Soome 448*4a5d661aSToomas Soome #define IP_FW3 48 /* generic ipfw v.3 sockopts */ 449*4a5d661aSToomas Soome #define IP_DUMMYNET3 49 /* generic dummynet v.3 sockopts */ 450*4a5d661aSToomas Soome 451*4a5d661aSToomas Soome #define IP_FW_ADD 50 /* add a firewall rule to chain */ 452*4a5d661aSToomas Soome #define IP_FW_DEL 51 /* delete a firewall rule from chain */ 453*4a5d661aSToomas Soome #define IP_FW_FLUSH 52 /* flush firewall rule chain */ 454*4a5d661aSToomas Soome #define IP_FW_ZERO 53 /* clear single/all firewall counter(s) */ 455*4a5d661aSToomas Soome #define IP_FW_GET 54 /* get entire firewall rule chain */ 456*4a5d661aSToomas Soome #define IP_FW_RESETLOG 55 /* reset logging counters */ 457*4a5d661aSToomas Soome 458*4a5d661aSToomas Soome #define IP_FW_NAT_CFG 56 /* add/config a nat rule */ 459*4a5d661aSToomas Soome #define IP_FW_NAT_DEL 57 /* delete a nat rule */ 460*4a5d661aSToomas Soome #define IP_FW_NAT_GET_CONFIG 58 /* get configuration of a nat rule */ 461*4a5d661aSToomas Soome #define IP_FW_NAT_GET_LOG 59 /* get log of a nat rule */ 462*4a5d661aSToomas Soome 463*4a5d661aSToomas Soome #define IP_DUMMYNET_CONFIGURE 60 /* add/configure a dummynet pipe */ 464*4a5d661aSToomas Soome #define IP_DUMMYNET_DEL 61 /* delete a dummynet pipe from chain */ 465*4a5d661aSToomas Soome #define IP_DUMMYNET_FLUSH 62 /* flush dummynet */ 466*4a5d661aSToomas Soome #define IP_DUMMYNET_GET 64 /* get entire dummynet pipes */ 467*4a5d661aSToomas Soome 468*4a5d661aSToomas Soome #define IP_RECVTTL 65 /* bool; receive IP TTL w/dgram */ 469*4a5d661aSToomas Soome #define IP_MINTTL 66 /* minimum TTL for packet or drop */ 470*4a5d661aSToomas Soome #define IP_DONTFRAG 67 /* don't fragment packet */ 471*4a5d661aSToomas Soome #define IP_RECVTOS 68 /* bool; receive IP TOS w/dgram */ 472*4a5d661aSToomas Soome 473*4a5d661aSToomas Soome /* IPv4 Source Filter Multicast API [RFC3678] */ 474*4a5d661aSToomas Soome #define IP_ADD_SOURCE_MEMBERSHIP 70 /* join a source-specific group */ 475*4a5d661aSToomas Soome #define IP_DROP_SOURCE_MEMBERSHIP 71 /* drop a single source */ 476*4a5d661aSToomas Soome #define IP_BLOCK_SOURCE 72 /* block a source */ 477*4a5d661aSToomas Soome #define IP_UNBLOCK_SOURCE 73 /* unblock a source */ 478*4a5d661aSToomas Soome 479*4a5d661aSToomas Soome /* The following option is private; do not use it from user applications. */ 480*4a5d661aSToomas Soome #define IP_MSFILTER 74 /* set/get filter list */ 481*4a5d661aSToomas Soome 482*4a5d661aSToomas Soome /* Protocol Independent Multicast API [RFC3678] */ 483*4a5d661aSToomas Soome #define MCAST_JOIN_GROUP 80 /* join an any-source group */ 484*4a5d661aSToomas Soome #define MCAST_LEAVE_GROUP 81 /* leave all sources for group */ 485*4a5d661aSToomas Soome #define MCAST_JOIN_SOURCE_GROUP 82 /* join a source-specific group */ 486*4a5d661aSToomas Soome #define MCAST_LEAVE_SOURCE_GROUP 83 /* leave a single source */ 487*4a5d661aSToomas Soome #define MCAST_BLOCK_SOURCE 84 /* block a source */ 488*4a5d661aSToomas Soome #define MCAST_UNBLOCK_SOURCE 85 /* unblock a source */ 489*4a5d661aSToomas Soome 490*4a5d661aSToomas Soome /* Flow and RSS definitions */ 491*4a5d661aSToomas Soome #define IP_FLOWID 90 /* get flow id for the given socket/inp */ 492*4a5d661aSToomas Soome #define IP_FLOWTYPE 91 /* get flow type (M_HASHTYPE) */ 493*4a5d661aSToomas Soome #define IP_RSSBUCKETID 92 /* get RSS flowid -> bucket mapping */ 494*4a5d661aSToomas Soome #define IP_RECVFLOWID 93 /* bool; receive IP flowid/flowtype w/ datagram */ 495*4a5d661aSToomas Soome #define IP_RECVRSSBUCKETID 94 /* bool; receive IP RSS bucket id w/ datagram */ 496*4a5d661aSToomas Soome 497*4a5d661aSToomas Soome /* 498*4a5d661aSToomas Soome * Defaults and limits for options 499*4a5d661aSToomas Soome */ 500*4a5d661aSToomas Soome #define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */ 501*4a5d661aSToomas Soome #define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */ 502*4a5d661aSToomas Soome 503*4a5d661aSToomas Soome /* 504*4a5d661aSToomas Soome * The imo_membership vector for each socket is now dynamically allocated at 505*4a5d661aSToomas Soome * run-time, bounded by USHRT_MAX, and is reallocated when needed, sized 506*4a5d661aSToomas Soome * according to a power-of-two increment. 507*4a5d661aSToomas Soome */ 508*4a5d661aSToomas Soome #define IP_MIN_MEMBERSHIPS 31 509*4a5d661aSToomas Soome #define IP_MAX_MEMBERSHIPS 4095 510*4a5d661aSToomas Soome #define IP_MAX_SOURCE_FILTER 1024 /* XXX to be unused */ 511*4a5d661aSToomas Soome 512*4a5d661aSToomas Soome /* 513*4a5d661aSToomas Soome * Default resource limits for IPv4 multicast source filtering. 514*4a5d661aSToomas Soome * These may be modified by sysctl. 515*4a5d661aSToomas Soome */ 516*4a5d661aSToomas Soome #define IP_MAX_GROUP_SRC_FILTER 512 /* sources per group */ 517*4a5d661aSToomas Soome #define IP_MAX_SOCK_SRC_FILTER 128 /* sources per socket/group */ 518*4a5d661aSToomas Soome #define IP_MAX_SOCK_MUTE_FILTER 128 /* XXX no longer used */ 519*4a5d661aSToomas Soome 520*4a5d661aSToomas Soome /* 521*4a5d661aSToomas Soome * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. 522*4a5d661aSToomas Soome */ 523*4a5d661aSToomas Soome struct ip_mreq { 524*4a5d661aSToomas Soome struct in_addr imr_multiaddr; /* IP multicast address of group */ 525*4a5d661aSToomas Soome struct in_addr imr_interface; /* local IP address of interface */ 526*4a5d661aSToomas Soome }; 527*4a5d661aSToomas Soome 528*4a5d661aSToomas Soome /* 529*4a5d661aSToomas Soome * Modified argument structure for IP_MULTICAST_IF, obtained from Linux. 530*4a5d661aSToomas Soome * This is used to specify an interface index for multicast sends, as 531*4a5d661aSToomas Soome * the IPv4 legacy APIs do not support this (unless IP_SENDIF is available). 532*4a5d661aSToomas Soome */ 533*4a5d661aSToomas Soome struct ip_mreqn { 534*4a5d661aSToomas Soome struct in_addr imr_multiaddr; /* IP multicast address of group */ 535*4a5d661aSToomas Soome struct in_addr imr_address; /* local IP address of interface */ 536*4a5d661aSToomas Soome int imr_ifindex; /* Interface index; cast to uint32_t */ 537*4a5d661aSToomas Soome }; 538*4a5d661aSToomas Soome 539*4a5d661aSToomas Soome /* 540*4a5d661aSToomas Soome * Argument structure for IPv4 Multicast Source Filter APIs. [RFC3678] 541*4a5d661aSToomas Soome */ 542*4a5d661aSToomas Soome struct ip_mreq_source { 543*4a5d661aSToomas Soome struct in_addr imr_multiaddr; /* IP multicast address of group */ 544*4a5d661aSToomas Soome struct in_addr imr_sourceaddr; /* IP address of source */ 545*4a5d661aSToomas Soome struct in_addr imr_interface; /* local IP address of interface */ 546*4a5d661aSToomas Soome }; 547*4a5d661aSToomas Soome 548*4a5d661aSToomas Soome /* 549*4a5d661aSToomas Soome * Argument structures for Protocol-Independent Multicast Source 550*4a5d661aSToomas Soome * Filter APIs. [RFC3678] 551*4a5d661aSToomas Soome */ 552*4a5d661aSToomas Soome struct group_req { 553*4a5d661aSToomas Soome uint32_t gr_interface; /* interface index */ 554*4a5d661aSToomas Soome struct sockaddr_storage gr_group; /* group address */ 555*4a5d661aSToomas Soome }; 556*4a5d661aSToomas Soome 557*4a5d661aSToomas Soome struct group_source_req { 558*4a5d661aSToomas Soome uint32_t gsr_interface; /* interface index */ 559*4a5d661aSToomas Soome struct sockaddr_storage gsr_group; /* group address */ 560*4a5d661aSToomas Soome struct sockaddr_storage gsr_source; /* source address */ 561*4a5d661aSToomas Soome }; 562*4a5d661aSToomas Soome 563*4a5d661aSToomas Soome #ifndef __MSFILTERREQ_DEFINED 564*4a5d661aSToomas Soome #define __MSFILTERREQ_DEFINED 565*4a5d661aSToomas Soome /* 566*4a5d661aSToomas Soome * The following structure is private; do not use it from user applications. 567*4a5d661aSToomas Soome * It is used to communicate IP_MSFILTER/IPV6_MSFILTER information between 568*4a5d661aSToomas Soome * the RFC 3678 libc functions and the kernel. 569*4a5d661aSToomas Soome */ 570*4a5d661aSToomas Soome struct __msfilterreq { 571*4a5d661aSToomas Soome uint32_t msfr_ifindex; /* interface index */ 572*4a5d661aSToomas Soome uint32_t msfr_fmode; /* filter mode for group */ 573*4a5d661aSToomas Soome uint32_t msfr_nsrcs; /* # of sources in msfr_srcs */ 574*4a5d661aSToomas Soome struct sockaddr_storage msfr_group; /* group address */ 575*4a5d661aSToomas Soome struct sockaddr_storage *msfr_srcs; /* pointer to the first member 576*4a5d661aSToomas Soome * of a contiguous array of 577*4a5d661aSToomas Soome * sources to filter in full. 578*4a5d661aSToomas Soome */ 579*4a5d661aSToomas Soome }; 580*4a5d661aSToomas Soome #endif 581*4a5d661aSToomas Soome 582*4a5d661aSToomas Soome struct sockaddr; 583*4a5d661aSToomas Soome 584*4a5d661aSToomas Soome /* 585*4a5d661aSToomas Soome * Advanced (Full-state) APIs [RFC3678] 586*4a5d661aSToomas Soome * The RFC specifies uint_t for the 6th argument to [sg]etsourcefilter(). 587*4a5d661aSToomas Soome * We use uint32_t here to be consistent. 588*4a5d661aSToomas Soome */ 589*4a5d661aSToomas Soome int setipv4sourcefilter(int, struct in_addr, struct in_addr, uint32_t, 590*4a5d661aSToomas Soome uint32_t, struct in_addr *); 591*4a5d661aSToomas Soome int getipv4sourcefilter(int, struct in_addr, struct in_addr, uint32_t *, 592*4a5d661aSToomas Soome uint32_t *, struct in_addr *); 593*4a5d661aSToomas Soome int setsourcefilter(int, uint32_t, struct sockaddr *, socklen_t, 594*4a5d661aSToomas Soome uint32_t, uint32_t, struct sockaddr_storage *); 595*4a5d661aSToomas Soome int getsourcefilter(int, uint32_t, struct sockaddr *, socklen_t, 596*4a5d661aSToomas Soome uint32_t *, uint32_t *, struct sockaddr_storage *); 597*4a5d661aSToomas Soome 598*4a5d661aSToomas Soome /* 599*4a5d661aSToomas Soome * Filter modes; also used to represent per-socket filter mode internally. 600*4a5d661aSToomas Soome */ 601*4a5d661aSToomas Soome #define MCAST_UNDEFINED 0 /* fmode: not yet defined */ 602*4a5d661aSToomas Soome #define MCAST_INCLUDE 1 /* fmode: include these source(s) */ 603*4a5d661aSToomas Soome #define MCAST_EXCLUDE 2 /* fmode: exclude these source(s) */ 604*4a5d661aSToomas Soome 605*4a5d661aSToomas Soome /* 606*4a5d661aSToomas Soome * Argument for IP_PORTRANGE: 607*4a5d661aSToomas Soome * - which range to search when port is unspecified at bind() or connect() 608*4a5d661aSToomas Soome */ 609*4a5d661aSToomas Soome #define IP_PORTRANGE_DEFAULT 0 /* default range */ 610*4a5d661aSToomas Soome #define IP_PORTRANGE_HIGH 1 /* "high" - request firewall bypass */ 611*4a5d661aSToomas Soome #define IP_PORTRANGE_LOW 2 /* "low" - vouchsafe security */ 612*4a5d661aSToomas Soome 613*4a5d661aSToomas Soome /* 614*4a5d661aSToomas Soome * Identifiers for IP sysctl nodes 615*4a5d661aSToomas Soome */ 616*4a5d661aSToomas Soome #define IPCTL_FORWARDING 1 /* act as router */ 617*4a5d661aSToomas Soome #define IPCTL_SENDREDIRECTS 2 /* may send redirects when forwarding */ 618*4a5d661aSToomas Soome #define IPCTL_DEFTTL 3 /* default TTL */ 619*4a5d661aSToomas Soome #ifdef notyet 620*4a5d661aSToomas Soome #define IPCTL_DEFMTU 4 /* default MTU */ 621*4a5d661aSToomas Soome #endif 622*4a5d661aSToomas Soome /* IPCTL_RTEXPIRE 5 deprecated */ 623*4a5d661aSToomas Soome /* IPCTL_RTMINEXPIRE 6 deprecated */ 624*4a5d661aSToomas Soome /* IPCTL_RTMAXCACHE 7 deprecated */ 625*4a5d661aSToomas Soome #define IPCTL_SOURCEROUTE 8 /* may perform source routes */ 626*4a5d661aSToomas Soome #define IPCTL_DIRECTEDBROADCAST 9 /* may re-broadcast received packets */ 627*4a5d661aSToomas Soome #define IPCTL_INTRQMAXLEN 10 /* max length of netisr queue */ 628*4a5d661aSToomas Soome #define IPCTL_INTRQDROPS 11 /* number of netisr q drops */ 629*4a5d661aSToomas Soome #define IPCTL_STATS 12 /* ipstat structure */ 630*4a5d661aSToomas Soome #define IPCTL_ACCEPTSOURCEROUTE 13 /* may accept source routed packets */ 631*4a5d661aSToomas Soome #define IPCTL_FASTFORWARDING 14 /* use fast IP forwarding code */ 632*4a5d661aSToomas Soome /* 15, unused, was: IPCTL_KEEPFAITH */ 633*4a5d661aSToomas Soome #define IPCTL_GIF_TTL 16 /* default TTL for gif encap packet */ 634*4a5d661aSToomas Soome 635*4a5d661aSToomas Soome #endif /* __BSD_VISIBLE */ 636*4a5d661aSToomas Soome 637*4a5d661aSToomas Soome #ifdef _KERNEL 638*4a5d661aSToomas Soome 639*4a5d661aSToomas Soome struct ifnet; struct mbuf; /* forward declarations for Standard C */ 640*4a5d661aSToomas Soome 641*4a5d661aSToomas Soome int in_broadcast(struct in_addr, struct ifnet *); 642*4a5d661aSToomas Soome int in_canforward(struct in_addr); 643*4a5d661aSToomas Soome int in_localaddr(struct in_addr); 644*4a5d661aSToomas Soome int in_localip(struct in_addr); 645*4a5d661aSToomas Soome int in_ifhasaddr(struct ifnet *, struct in_addr); 646*4a5d661aSToomas Soome int inet_aton(const char *, struct in_addr *); /* in libkern */ 647*4a5d661aSToomas Soome char *inet_ntoa(struct in_addr); /* in libkern */ 648*4a5d661aSToomas Soome char *inet_ntoa_r(struct in_addr ina, char *buf); /* in libkern */ 649*4a5d661aSToomas Soome char *inet_ntop(int, const void *, char *, socklen_t); /* in libkern */ 650*4a5d661aSToomas Soome int inet_pton(int af, const char *, void *); /* in libkern */ 651*4a5d661aSToomas Soome void in_ifdetach(struct ifnet *); 652*4a5d661aSToomas Soome 653*4a5d661aSToomas Soome #define in_hosteq(s, t) ((s).s_addr == (t).s_addr) 654*4a5d661aSToomas Soome #define in_nullhost(x) ((x).s_addr == INADDR_ANY) 655*4a5d661aSToomas Soome #define in_allhosts(x) ((x).s_addr == htonl(INADDR_ALLHOSTS_GROUP)) 656*4a5d661aSToomas Soome 657*4a5d661aSToomas Soome #define satosin(sa) ((struct sockaddr_in *)(sa)) 658*4a5d661aSToomas Soome #define sintosa(sin) ((struct sockaddr *)(sin)) 659*4a5d661aSToomas Soome #define ifatoia(ifa) ((struct in_ifaddr *)(ifa)) 660*4a5d661aSToomas Soome #endif /* _KERNEL */ 661*4a5d661aSToomas Soome 662*4a5d661aSToomas Soome /* INET6 stuff */ 663*4a5d661aSToomas Soome #if __POSIX_VISIBLE >= 200112 664*4a5d661aSToomas Soome #define __KAME_NETINET_IN_H_INCLUDED_ 665*4a5d661aSToomas Soome #include <netinet6/in6.h> 666*4a5d661aSToomas Soome #undef __KAME_NETINET_IN_H_INCLUDED_ 667*4a5d661aSToomas Soome #endif 668*4a5d661aSToomas Soome 669*4a5d661aSToomas Soome #endif /* !_NETINET_IN_H_*/ 670