1*5c2921b0SApple OSS Distributions /* 2*5c2921b0SApple OSS Distributions * Copyright (c) 2000-2018 Apple Inc. All rights reserved. 3*5c2921b0SApple OSS Distributions * 4*5c2921b0SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5*5c2921b0SApple OSS Distributions * 6*5c2921b0SApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code 7*5c2921b0SApple OSS Distributions * as defined in and that are subject to the Apple Public Source License 8*5c2921b0SApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in 9*5c2921b0SApple OSS Distributions * compliance with the License. The rights granted to you under the License 10*5c2921b0SApple OSS Distributions * may not be used to create, or enable the creation or redistribution of, 11*5c2921b0SApple OSS Distributions * unlawful or unlicensed copies of an Apple operating system, or to 12*5c2921b0SApple OSS Distributions * circumvent, violate, or enable the circumvention or violation of, any 13*5c2921b0SApple OSS Distributions * terms of an Apple operating system software license agreement. 14*5c2921b0SApple OSS Distributions * 15*5c2921b0SApple OSS Distributions * Please obtain a copy of the License at 16*5c2921b0SApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this file. 17*5c2921b0SApple OSS Distributions * 18*5c2921b0SApple OSS Distributions * The Original Code and all software distributed under the License are 19*5c2921b0SApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20*5c2921b0SApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21*5c2921b0SApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22*5c2921b0SApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23*5c2921b0SApple OSS Distributions * Please see the License for the specific language governing rights and 24*5c2921b0SApple OSS Distributions * limitations under the License. 25*5c2921b0SApple OSS Distributions * 26*5c2921b0SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27*5c2921b0SApple OSS Distributions */ 28*5c2921b0SApple OSS Distributions /* 29*5c2921b0SApple OSS Distributions * Copyright (c) 1982, 1986, 1990, 1993 30*5c2921b0SApple OSS Distributions * The Regents of the University of California. All rights reserved. 31*5c2921b0SApple OSS Distributions * 32*5c2921b0SApple OSS Distributions * Redistribution and use in source and binary forms, with or without 33*5c2921b0SApple OSS Distributions * modification, are permitted provided that the following conditions 34*5c2921b0SApple OSS Distributions * are met: 35*5c2921b0SApple OSS Distributions * 1. Redistributions of source code must retain the above copyright 36*5c2921b0SApple OSS Distributions * notice, this list of conditions and the following disclaimer. 37*5c2921b0SApple OSS Distributions * 2. Redistributions in binary form must reproduce the above copyright 38*5c2921b0SApple OSS Distributions * notice, this list of conditions and the following disclaimer in the 39*5c2921b0SApple OSS Distributions * documentation and/or other materials provided with the distribution. 40*5c2921b0SApple OSS Distributions * 3. All advertising materials mentioning features or use of this software 41*5c2921b0SApple OSS Distributions * must display the following acknowledgement: 42*5c2921b0SApple OSS Distributions * This product includes software developed by the University of 43*5c2921b0SApple OSS Distributions * California, Berkeley and its contributors. 44*5c2921b0SApple OSS Distributions * 4. Neither the name of the University nor the names of its contributors 45*5c2921b0SApple OSS Distributions * may be used to endorse or promote products derived from this software 46*5c2921b0SApple OSS Distributions * without specific prior written permission. 47*5c2921b0SApple OSS Distributions * 48*5c2921b0SApple OSS Distributions * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 49*5c2921b0SApple OSS Distributions * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 50*5c2921b0SApple OSS Distributions * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 51*5c2921b0SApple OSS Distributions * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 52*5c2921b0SApple OSS Distributions * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 53*5c2921b0SApple OSS Distributions * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 54*5c2921b0SApple OSS Distributions * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 55*5c2921b0SApple OSS Distributions * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 56*5c2921b0SApple OSS Distributions * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 57*5c2921b0SApple OSS Distributions * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 58*5c2921b0SApple OSS Distributions * SUCH DAMAGE. 59*5c2921b0SApple OSS Distributions * 60*5c2921b0SApple OSS Distributions * @(#)in.h 8.3 (Berkeley) 1/3/94 61*5c2921b0SApple OSS Distributions * $FreeBSD: src/sys/netinet/in.h,v 1.48.2.2 2001/04/21 14:53:06 ume Exp $ 62*5c2921b0SApple OSS Distributions */ 63*5c2921b0SApple OSS Distributions 64*5c2921b0SApple OSS Distributions #ifndef _NETINET_IN_H_ 65*5c2921b0SApple OSS Distributions #define _NETINET_IN_H_ 66*5c2921b0SApple OSS Distributions 67*5c2921b0SApple OSS Distributions #ifndef DRIVERKIT 68*5c2921b0SApple OSS Distributions #include <sys/appleapiopts.h> 69*5c2921b0SApple OSS Distributions #include <stdint.h> /* uint(8|16|32)_t */ 70*5c2921b0SApple OSS Distributions 71*5c2921b0SApple OSS Distributions #ifndef KERNEL 72*5c2921b0SApple OSS Distributions #include <Availability.h> 73*5c2921b0SApple OSS Distributions #endif 74*5c2921b0SApple OSS Distributions 75*5c2921b0SApple OSS Distributions #else 76*5c2921b0SApple OSS Distributions #include <sys/_types.h> 77*5c2921b0SApple OSS Distributions #include <sys/_types/_sa_family_t.h> 78*5c2921b0SApple OSS Distributions #endif /* DRIVERKIT */ 79*5c2921b0SApple OSS Distributions 80*5c2921b0SApple OSS Distributions #include <sys/_types/_in_addr_t.h> 81*5c2921b0SApple OSS Distributions #include <sys/_types/_in_port_t.h> 82*5c2921b0SApple OSS Distributions 83*5c2921b0SApple OSS Distributions #ifndef DRIVERKIT 84*5c2921b0SApple OSS Distributions /* 85*5c2921b0SApple OSS Distributions * POSIX 1003.1-2003 86*5c2921b0SApple OSS Distributions * "Inclusion of the <netinet/in.h> header may also make visible all 87*5c2921b0SApple OSS Distributions * symbols from <inttypes.h> and <sys/socket.h>". 88*5c2921b0SApple OSS Distributions */ 89*5c2921b0SApple OSS Distributions #include <sys/socket.h> 90*5c2921b0SApple OSS Distributions #endif /* DRIVERKIT */ 91*5c2921b0SApple OSS Distributions 92*5c2921b0SApple OSS Distributions /* 93*5c2921b0SApple OSS Distributions * The following two #includes insure htonl and family are defined 94*5c2921b0SApple OSS Distributions */ 95*5c2921b0SApple OSS Distributions #include <machine/endian.h> 96*5c2921b0SApple OSS Distributions #include <sys/_endian.h> 97*5c2921b0SApple OSS Distributions 98*5c2921b0SApple OSS Distributions /* 99*5c2921b0SApple OSS Distributions * Constants and structures defined by the internet system, 100*5c2921b0SApple OSS Distributions * Per RFC 790, September 1981, and numerous additions. 101*5c2921b0SApple OSS Distributions */ 102*5c2921b0SApple OSS Distributions 103*5c2921b0SApple OSS Distributions /* 104*5c2921b0SApple OSS Distributions * Protocols (RFC 1700) 105*5c2921b0SApple OSS Distributions */ 106*5c2921b0SApple OSS Distributions #define IPPROTO_IP 0 /* dummy for IP */ 107*5c2921b0SApple OSS Distributions #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 108*5c2921b0SApple OSS Distributions #define IPPROTO_HOPOPTS 0 /* IP6 hop-by-hop options */ 109*5c2921b0SApple OSS Distributions #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ 110*5c2921b0SApple OSS Distributions #define IPPROTO_ICMP 1 /* control message protocol */ 111*5c2921b0SApple OSS Distributions #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 112*5c2921b0SApple OSS Distributions #define IPPROTO_IGMP 2 /* group mgmt protocol */ 113*5c2921b0SApple OSS Distributions #define IPPROTO_GGP 3 /* gateway^2 (deprecated) */ 114*5c2921b0SApple OSS Distributions #define IPPROTO_IPV4 4 /* IPv4 encapsulation */ 115*5c2921b0SApple OSS Distributions #define IPPROTO_IPIP IPPROTO_IPV4 /* for compatibility */ 116*5c2921b0SApple OSS Distributions #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ 117*5c2921b0SApple OSS Distributions #define IPPROTO_TCP 6 /* tcp */ 118*5c2921b0SApple OSS Distributions #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 119*5c2921b0SApple OSS Distributions #define IPPROTO_ST 7 /* Stream protocol II */ 120*5c2921b0SApple OSS Distributions #define IPPROTO_EGP 8 /* exterior gateway protocol */ 121*5c2921b0SApple OSS Distributions #define IPPROTO_PIGP 9 /* private interior gateway */ 122*5c2921b0SApple OSS Distributions #define IPPROTO_RCCMON 10 /* BBN RCC Monitoring */ 123*5c2921b0SApple OSS Distributions #define IPPROTO_NVPII 11 /* network voice protocol*/ 124*5c2921b0SApple OSS Distributions #define IPPROTO_PUP 12 /* pup */ 125*5c2921b0SApple OSS Distributions #define IPPROTO_ARGUS 13 /* Argus */ 126*5c2921b0SApple OSS Distributions #define IPPROTO_EMCON 14 /* EMCON */ 127*5c2921b0SApple OSS Distributions #define IPPROTO_XNET 15 /* Cross Net Debugger */ 128*5c2921b0SApple OSS Distributions #define IPPROTO_CHAOS 16 /* Chaos*/ 129*5c2921b0SApple OSS Distributions #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ 130*5c2921b0SApple OSS Distributions #define IPPROTO_UDP 17 /* user datagram protocol */ 131*5c2921b0SApple OSS Distributions #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 132*5c2921b0SApple OSS Distributions #define IPPROTO_MUX 18 /* Multiplexing */ 133*5c2921b0SApple OSS Distributions #define IPPROTO_MEAS 19 /* DCN Measurement Subsystems */ 134*5c2921b0SApple OSS Distributions #define IPPROTO_HMP 20 /* Host Monitoring */ 135*5c2921b0SApple OSS Distributions #define IPPROTO_PRM 21 /* Packet Radio Measurement */ 136*5c2921b0SApple OSS Distributions #define IPPROTO_IDP 22 /* xns idp */ 137*5c2921b0SApple OSS Distributions #define IPPROTO_TRUNK1 23 /* Trunk-1 */ 138*5c2921b0SApple OSS Distributions #define IPPROTO_TRUNK2 24 /* Trunk-2 */ 139*5c2921b0SApple OSS Distributions #define IPPROTO_LEAF1 25 /* Leaf-1 */ 140*5c2921b0SApple OSS Distributions #define IPPROTO_LEAF2 26 /* Leaf-2 */ 141*5c2921b0SApple OSS Distributions #define IPPROTO_RDP 27 /* Reliable Data */ 142*5c2921b0SApple OSS Distributions #define IPPROTO_IRTP 28 /* Reliable Transaction */ 143*5c2921b0SApple OSS Distributions #define IPPROTO_TP 29 /* tp-4 w/ class negotiation */ 144*5c2921b0SApple OSS Distributions #define IPPROTO_BLT 30 /* Bulk Data Transfer */ 145*5c2921b0SApple OSS Distributions #define IPPROTO_NSP 31 /* Network Services */ 146*5c2921b0SApple OSS Distributions #define IPPROTO_INP 32 /* Merit Internodal */ 147*5c2921b0SApple OSS Distributions #define IPPROTO_SEP 33 /* Sequential Exchange */ 148*5c2921b0SApple OSS Distributions #define IPPROTO_3PC 34 /* Third Party Connect */ 149*5c2921b0SApple OSS Distributions #define IPPROTO_IDPR 35 /* InterDomain Policy Routing */ 150*5c2921b0SApple OSS Distributions #define IPPROTO_XTP 36 /* XTP */ 151*5c2921b0SApple OSS Distributions #define IPPROTO_DDP 37 /* Datagram Delivery */ 152*5c2921b0SApple OSS Distributions #define IPPROTO_CMTP 38 /* Control Message Transport */ 153*5c2921b0SApple OSS Distributions #define IPPROTO_TPXX 39 /* TP++ Transport */ 154*5c2921b0SApple OSS Distributions #define IPPROTO_IL 40 /* IL transport protocol */ 155*5c2921b0SApple OSS Distributions #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ 156*5c2921b0SApple OSS Distributions #define IPPROTO_IPV6 41 /* IP6 header */ 157*5c2921b0SApple OSS Distributions #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 158*5c2921b0SApple OSS Distributions #define IPPROTO_SDRP 42 /* Source Demand Routing */ 159*5c2921b0SApple OSS Distributions #define IPPROTO_ROUTING 43 /* IP6 routing header */ 160*5c2921b0SApple OSS Distributions #define IPPROTO_FRAGMENT 44 /* IP6 fragmentation header */ 161*5c2921b0SApple OSS Distributions #define IPPROTO_IDRP 45 /* InterDomain Routing*/ 162*5c2921b0SApple OSS Distributions #define IPPROTO_RSVP 46 /* resource reservation */ 163*5c2921b0SApple OSS Distributions #define IPPROTO_GRE 47 /* General Routing Encap. */ 164*5c2921b0SApple OSS Distributions #define IPPROTO_MHRP 48 /* Mobile Host Routing */ 165*5c2921b0SApple OSS Distributions #define IPPROTO_BHA 49 /* BHA */ 166*5c2921b0SApple OSS Distributions #define IPPROTO_ESP 50 /* IP6 Encap Sec. Payload */ 167*5c2921b0SApple OSS Distributions #define IPPROTO_AH 51 /* IP6 Auth Header */ 168*5c2921b0SApple OSS Distributions #define IPPROTO_INLSP 52 /* Integ. Net Layer Security */ 169*5c2921b0SApple OSS Distributions #define IPPROTO_SWIPE 53 /* IP with encryption */ 170*5c2921b0SApple OSS Distributions #define IPPROTO_NHRP 54 /* Next Hop Resolution */ 171*5c2921b0SApple OSS Distributions /* 55-57: Unassigned */ 172*5c2921b0SApple OSS Distributions #define IPPROTO_ICMPV6 58 /* ICMP6 */ 173*5c2921b0SApple OSS Distributions #define IPPROTO_NONE 59 /* IP6 no next header */ 174*5c2921b0SApple OSS Distributions #define IPPROTO_DSTOPTS 60 /* IP6 destination option */ 175*5c2921b0SApple OSS Distributions #define IPPROTO_AHIP 61 /* any host internal protocol */ 176*5c2921b0SApple OSS Distributions #define IPPROTO_CFTP 62 /* CFTP */ 177*5c2921b0SApple OSS Distributions #define IPPROTO_HELLO 63 /* "hello" routing protocol */ 178*5c2921b0SApple OSS Distributions #define IPPROTO_SATEXPAK 64 /* SATNET/Backroom EXPAK */ 179*5c2921b0SApple OSS Distributions #define IPPROTO_KRYPTOLAN 65 /* Kryptolan */ 180*5c2921b0SApple OSS Distributions #define IPPROTO_RVD 66 /* Remote Virtual Disk */ 181*5c2921b0SApple OSS Distributions #define IPPROTO_IPPC 67 /* Pluribus Packet Core */ 182*5c2921b0SApple OSS Distributions #define IPPROTO_ADFS 68 /* Any distributed FS */ 183*5c2921b0SApple OSS Distributions #define IPPROTO_SATMON 69 /* Satnet Monitoring */ 184*5c2921b0SApple OSS Distributions #define IPPROTO_VISA 70 /* VISA Protocol */ 185*5c2921b0SApple OSS Distributions #define IPPROTO_IPCV 71 /* Packet Core Utility */ 186*5c2921b0SApple OSS Distributions #define IPPROTO_CPNX 72 /* Comp. Prot. Net. Executive */ 187*5c2921b0SApple OSS Distributions #define IPPROTO_CPHB 73 /* Comp. Prot. HeartBeat */ 188*5c2921b0SApple OSS Distributions #define IPPROTO_WSN 74 /* Wang Span Network */ 189*5c2921b0SApple OSS Distributions #define IPPROTO_PVP 75 /* Packet Video Protocol */ 190*5c2921b0SApple OSS Distributions #define IPPROTO_BRSATMON 76 /* BackRoom SATNET Monitoring */ 191*5c2921b0SApple OSS Distributions #define IPPROTO_ND 77 /* Sun net disk proto (temp.) */ 192*5c2921b0SApple OSS Distributions #define IPPROTO_WBMON 78 /* WIDEBAND Monitoring */ 193*5c2921b0SApple OSS Distributions #define IPPROTO_WBEXPAK 79 /* WIDEBAND EXPAK */ 194*5c2921b0SApple OSS Distributions #define IPPROTO_EON 80 /* ISO cnlp */ 195*5c2921b0SApple OSS Distributions #define IPPROTO_VMTP 81 /* VMTP */ 196*5c2921b0SApple OSS Distributions #define IPPROTO_SVMTP 82 /* Secure VMTP */ 197*5c2921b0SApple OSS Distributions #define IPPROTO_VINES 83 /* Banyon VINES */ 198*5c2921b0SApple OSS Distributions #define IPPROTO_TTP 84 /* TTP */ 199*5c2921b0SApple OSS Distributions #define IPPROTO_IGP 85 /* NSFNET-IGP */ 200*5c2921b0SApple OSS Distributions #define IPPROTO_DGP 86 /* dissimilar gateway prot. */ 201*5c2921b0SApple OSS Distributions #define IPPROTO_TCF 87 /* TCF */ 202*5c2921b0SApple OSS Distributions #define IPPROTO_IGRP 88 /* Cisco/GXS IGRP */ 203*5c2921b0SApple OSS Distributions #define IPPROTO_OSPFIGP 89 /* OSPFIGP */ 204*5c2921b0SApple OSS Distributions #define IPPROTO_SRPC 90 /* Strite RPC protocol */ 205*5c2921b0SApple OSS Distributions #define IPPROTO_LARP 91 /* Locus Address Resoloution */ 206*5c2921b0SApple OSS Distributions #define IPPROTO_MTP 92 /* Multicast Transport */ 207*5c2921b0SApple OSS Distributions #define IPPROTO_AX25 93 /* AX.25 Frames */ 208*5c2921b0SApple OSS Distributions #define IPPROTO_IPEIP 94 /* IP encapsulated in IP */ 209*5c2921b0SApple OSS Distributions #define IPPROTO_MICP 95 /* Mobile Int.ing control */ 210*5c2921b0SApple OSS Distributions #define IPPROTO_SCCSP 96 /* Semaphore Comm. security */ 211*5c2921b0SApple OSS Distributions #define IPPROTO_ETHERIP 97 /* Ethernet IP encapsulation */ 212*5c2921b0SApple OSS Distributions #define IPPROTO_ENCAP 98 /* encapsulation header */ 213*5c2921b0SApple OSS Distributions #define IPPROTO_APES 99 /* any private encr. scheme */ 214*5c2921b0SApple OSS Distributions #define IPPROTO_GMTP 100 /* GMTP*/ 215*5c2921b0SApple OSS Distributions /* 101-252: Partly Unassigned */ 216*5c2921b0SApple OSS Distributions #define IPPROTO_PIM 103 /* Protocol Independent Mcast */ 217*5c2921b0SApple OSS Distributions #define IPPROTO_IPCOMP 108 /* payload compression (IPComp) */ 218*5c2921b0SApple OSS Distributions #define IPPROTO_PGM 113 /* PGM */ 219*5c2921b0SApple OSS Distributions #define IPPROTO_SCTP 132 /* SCTP */ 220*5c2921b0SApple OSS Distributions /* 253-254: Experimentation and testing; 255: Reserved (RFC3692) */ 221*5c2921b0SApple OSS Distributions /* BSD Private, local use, namespace incursion */ 222*5c2921b0SApple OSS Distributions #define IPPROTO_DIVERT 254 /* divert pseudo-protocol */ 223*5c2921b0SApple OSS Distributions #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ 224*5c2921b0SApple OSS Distributions #define IPPROTO_RAW 255 /* raw IP packet */ 225*5c2921b0SApple OSS Distributions 226*5c2921b0SApple OSS Distributions #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 227*5c2921b0SApple OSS Distributions #define IPPROTO_MAX 256 228*5c2921b0SApple OSS Distributions 229*5c2921b0SApple OSS Distributions /* last return value of *_input(), meaning "all job for this pkt is done". */ 230*5c2921b0SApple OSS Distributions #define IPPROTO_DONE 257 231*5c2921b0SApple OSS Distributions #endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ 232*5c2921b0SApple OSS Distributions 233*5c2921b0SApple OSS Distributions /* 234*5c2921b0SApple OSS Distributions * Local port number conventions: 235*5c2921b0SApple OSS Distributions * 236*5c2921b0SApple OSS Distributions * When a user does a bind(2) or connect(2) with a port number of zero, 237*5c2921b0SApple OSS Distributions * a non-conflicting local port address is chosen. 238*5c2921b0SApple OSS Distributions * The default range is IPPORT_RESERVED through 239*5c2921b0SApple OSS Distributions * IPPORT_USERRESERVED, although that is settable by sysctl. 240*5c2921b0SApple OSS Distributions * 241*5c2921b0SApple OSS Distributions * A user may set the IPPROTO_IP option IP_PORTRANGE to change this 242*5c2921b0SApple OSS Distributions * default assignment range. 243*5c2921b0SApple OSS Distributions * 244*5c2921b0SApple OSS Distributions * The value IP_PORTRANGE_DEFAULT causes the default behavior. 245*5c2921b0SApple OSS Distributions * 246*5c2921b0SApple OSS Distributions * The value IP_PORTRANGE_HIGH changes the range of candidate port numbers 247*5c2921b0SApple OSS Distributions * into the "high" range. These are reserved for client outbound connections 248*5c2921b0SApple OSS Distributions * which do not want to be filtered by any firewalls. 249*5c2921b0SApple OSS Distributions * 250*5c2921b0SApple OSS Distributions * The value IP_PORTRANGE_LOW changes the range to the "low" are 251*5c2921b0SApple OSS Distributions * that is (by convention) restricted to privileged processes. This 252*5c2921b0SApple OSS Distributions * convention is based on "vouchsafe" principles only. It is only secure 253*5c2921b0SApple OSS Distributions * if you trust the remote host to restrict these ports. 254*5c2921b0SApple OSS Distributions * 255*5c2921b0SApple OSS Distributions * The default range of ports and the high range can be changed by 256*5c2921b0SApple OSS Distributions * sysctl(3). (net.inet.ip.port{hi,low}{first,last}_auto) 257*5c2921b0SApple OSS Distributions * 258*5c2921b0SApple OSS Distributions * Changing those values has bad security implications if you are 259*5c2921b0SApple OSS Distributions * using a a stateless firewall that is allowing packets outside of that 260*5c2921b0SApple OSS Distributions * range in order to allow transparent outgoing connections. 261*5c2921b0SApple OSS Distributions * 262*5c2921b0SApple OSS Distributions * Such a firewall configuration will generally depend on the use of these 263*5c2921b0SApple OSS Distributions * default values. If you change them, you may find your Security 264*5c2921b0SApple OSS Distributions * Administrator looking for you with a heavy object. 265*5c2921b0SApple OSS Distributions * 266*5c2921b0SApple OSS Distributions * For a slightly more orthodox text view on this: 267*5c2921b0SApple OSS Distributions * 268*5c2921b0SApple OSS Distributions * ftp://ftp.isi.edu/in-notes/iana/assignments/port-numbers 269*5c2921b0SApple OSS Distributions * 270*5c2921b0SApple OSS Distributions * port numbers are divided into three ranges: 271*5c2921b0SApple OSS Distributions * 272*5c2921b0SApple OSS Distributions * 0 - 1023 Well Known Ports 273*5c2921b0SApple OSS Distributions * 1024 - 49151 Registered Ports 274*5c2921b0SApple OSS Distributions * 49152 - 65535 Dynamic and/or Private Ports 275*5c2921b0SApple OSS Distributions * 276*5c2921b0SApple OSS Distributions */ 277*5c2921b0SApple OSS Distributions 278*5c2921b0SApple OSS Distributions #define __DARWIN_IPPORT_RESERVED 1024 279*5c2921b0SApple OSS Distributions 280*5c2921b0SApple OSS Distributions #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 281*5c2921b0SApple OSS Distributions /* 282*5c2921b0SApple OSS Distributions * Ports < IPPORT_RESERVED are reserved for 283*5c2921b0SApple OSS Distributions * privileged processes (e.g. root). (IP_PORTRANGE_LOW) 284*5c2921b0SApple OSS Distributions * Ports > IPPORT_USERRESERVED are reserved 285*5c2921b0SApple OSS Distributions * for servers, not necessarily privileged. (IP_PORTRANGE_DEFAULT) 286*5c2921b0SApple OSS Distributions */ 287*5c2921b0SApple OSS Distributions #ifndef IPPORT_RESERVED 288*5c2921b0SApple OSS Distributions #define IPPORT_RESERVED __DARWIN_IPPORT_RESERVED 289*5c2921b0SApple OSS Distributions #endif 290*5c2921b0SApple OSS Distributions #define IPPORT_USERRESERVED 5000 291*5c2921b0SApple OSS Distributions 292*5c2921b0SApple OSS Distributions /* 293*5c2921b0SApple OSS Distributions * Default local port range to use by setting IP_PORTRANGE_HIGH 294*5c2921b0SApple OSS Distributions */ 295*5c2921b0SApple OSS Distributions #define IPPORT_HIFIRSTAUTO 49152 296*5c2921b0SApple OSS Distributions #define IPPORT_HILASTAUTO 65535 297*5c2921b0SApple OSS Distributions 298*5c2921b0SApple OSS Distributions /* 299*5c2921b0SApple OSS Distributions * Scanning for a free reserved port return a value below IPPORT_RESERVED, 300*5c2921b0SApple OSS Distributions * but higher than IPPORT_RESERVEDSTART. Traditionally the start value was 301*5c2921b0SApple OSS Distributions * 512, but that conflicts with some well-known-services that firewalls may 302*5c2921b0SApple OSS Distributions * have a fit if we use. 303*5c2921b0SApple OSS Distributions */ 304*5c2921b0SApple OSS Distributions #define IPPORT_RESERVEDSTART 600 305*5c2921b0SApple OSS Distributions #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ 306*5c2921b0SApple OSS Distributions 307*5c2921b0SApple OSS Distributions /* 308*5c2921b0SApple OSS Distributions * Internet address (a structure for historical reasons) 309*5c2921b0SApple OSS Distributions */ 310*5c2921b0SApple OSS Distributions struct in_addr { 311*5c2921b0SApple OSS Distributions in_addr_t s_addr; 312*5c2921b0SApple OSS Distributions }; 313*5c2921b0SApple OSS Distributions 314*5c2921b0SApple OSS Distributions /* 315*5c2921b0SApple OSS Distributions * Definitions of bits in internet address integers. 316*5c2921b0SApple OSS Distributions * On subnets, the decomposition of addresses to host and net parts 317*5c2921b0SApple OSS Distributions * is done according to subnet mask, not the masks here. 318*5c2921b0SApple OSS Distributions */ 319*5c2921b0SApple OSS Distributions #define INADDR_ANY (u_int32_t)0x00000000 320*5c2921b0SApple OSS Distributions #define INADDR_BROADCAST (u_int32_t)0xffffffff /* must be masked */ 321*5c2921b0SApple OSS Distributions 322*5c2921b0SApple OSS Distributions #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 323*5c2921b0SApple OSS Distributions #define IN_CLASSA(i) (((u_int32_t)(i) & 0x80000000) == 0) 324*5c2921b0SApple OSS Distributions #define IN_CLASSA_NET 0xff000000 325*5c2921b0SApple OSS Distributions #define IN_CLASSA_NSHIFT 24 326*5c2921b0SApple OSS Distributions #define IN_CLASSA_HOST 0x00ffffff 327*5c2921b0SApple OSS Distributions #define IN_CLASSA_MAX 128 328*5c2921b0SApple OSS Distributions 329*5c2921b0SApple OSS Distributions #define IN_CLASSB(i) (((u_int32_t)(i) & 0xc0000000) == 0x80000000) 330*5c2921b0SApple OSS Distributions #define IN_CLASSB_NET 0xffff0000 331*5c2921b0SApple OSS Distributions #define IN_CLASSB_NSHIFT 16 332*5c2921b0SApple OSS Distributions #define IN_CLASSB_HOST 0x0000ffff 333*5c2921b0SApple OSS Distributions #define IN_CLASSB_MAX 65536 334*5c2921b0SApple OSS Distributions 335*5c2921b0SApple OSS Distributions #define IN_CLASSC(i) (((u_int32_t)(i) & 0xe0000000) == 0xc0000000) 336*5c2921b0SApple OSS Distributions #define IN_CLASSC_NET 0xffffff00 337*5c2921b0SApple OSS Distributions #define IN_CLASSC_NSHIFT 8 338*5c2921b0SApple OSS Distributions #define IN_CLASSC_HOST 0x000000ff 339*5c2921b0SApple OSS Distributions 340*5c2921b0SApple OSS Distributions #define IN_CLASSD(i) (((u_int32_t)(i) & 0xf0000000) == 0xe0000000) 341*5c2921b0SApple OSS Distributions #define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */ 342*5c2921b0SApple OSS Distributions #define IN_CLASSD_NSHIFT 28 /* net and host fields, but */ 343*5c2921b0SApple OSS Distributions #define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */ 344*5c2921b0SApple OSS Distributions #define IN_MULTICAST(i) IN_CLASSD(i) 345*5c2921b0SApple OSS Distributions 346*5c2921b0SApple OSS Distributions #define IN_EXPERIMENTAL(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000) 347*5c2921b0SApple OSS Distributions #define IN_BADCLASS(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000) 348*5c2921b0SApple OSS Distributions 349*5c2921b0SApple OSS Distributions #define INADDR_LOOPBACK (u_int32_t)0x7f000001 350*5c2921b0SApple OSS Distributions 351*5c2921b0SApple OSS Distributions #ifndef KERNEL 352*5c2921b0SApple OSS Distributions #define INADDR_NONE 0xffffffff /* -1 return */ 353*5c2921b0SApple OSS Distributions #endif 354*5c2921b0SApple OSS Distributions 355*5c2921b0SApple OSS Distributions #define INADDR_UNSPEC_GROUP (u_int32_t)0xe0000000 /* 224.0.0.0 */ 356*5c2921b0SApple OSS Distributions #define INADDR_ALLHOSTS_GROUP (u_int32_t)0xe0000001 /* 224.0.0.1 */ 357*5c2921b0SApple OSS Distributions #define INADDR_ALLRTRS_GROUP (u_int32_t)0xe0000002 /* 224.0.0.2 */ 358*5c2921b0SApple OSS Distributions #define INADDR_ALLRPTS_GROUP (u_int32_t)0xe0000016 /* 224.0.0.22, IGMPv3 */ 359*5c2921b0SApple OSS Distributions #define INADDR_CARP_GROUP (u_int32_t)0xe0000012 /* 224.0.0.18 */ 360*5c2921b0SApple OSS Distributions #define INADDR_PFSYNC_GROUP (u_int32_t)0xe00000f0 /* 224.0.0.240 */ 361*5c2921b0SApple OSS Distributions #define INADDR_ALLMDNS_GROUP (u_int32_t)0xe00000fb /* 224.0.0.251 */ 362*5c2921b0SApple OSS Distributions #define INADDR_MAX_LOCAL_GROUP (u_int32_t)0xe00000ff /* 224.0.0.255 */ 363*5c2921b0SApple OSS Distributions 364*5c2921b0SApple OSS Distributions #ifdef __APPLE__ 365*5c2921b0SApple OSS Distributions #define IN_LINKLOCALNETNUM (u_int32_t)0xA9FE0000 /* 169.254.0.0 */ 366*5c2921b0SApple OSS Distributions #define IN_LINKLOCAL(i) (((u_int32_t)(i) & IN_CLASSB_NET) == IN_LINKLOCALNETNUM) 367*5c2921b0SApple OSS Distributions #define IN_LOOPBACK(i) (((u_int32_t)(i) & 0xff000000) == 0x7f000000) 368*5c2921b0SApple OSS Distributions #define IN_ZERONET(i) (((u_int32_t)(i) & 0xff000000) == 0) 369*5c2921b0SApple OSS Distributions 370*5c2921b0SApple OSS Distributions #define IN_PRIVATE(i) ((((u_int32_t)(i) & 0xff000000) == 0x0a000000) || \ 371*5c2921b0SApple OSS Distributions (((u_int32_t)(i) & 0xfff00000) == 0xac100000) || \ 372*5c2921b0SApple OSS Distributions (((u_int32_t)(i) & 0xffff0000) == 0xc0a80000)) 373*5c2921b0SApple OSS Distributions 374*5c2921b0SApple OSS Distributions #define IN_LOCAL_GROUP(i) (((u_int32_t)(i) & 0xffffff00) == 0xe0000000) 375*5c2921b0SApple OSS Distributions 376*5c2921b0SApple OSS Distributions #define IN_ANY_LOCAL(i) (IN_LINKLOCAL(i) || IN_LOCAL_GROUP(i)) 377*5c2921b0SApple OSS Distributions #endif /* __APPLE__ */ 378*5c2921b0SApple OSS Distributions 379*5c2921b0SApple OSS Distributions #define IN_LOOPBACKNET 127 /* official! */ 380*5c2921b0SApple OSS Distributions #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ 381*5c2921b0SApple OSS Distributions 382*5c2921b0SApple OSS Distributions /* 383*5c2921b0SApple OSS Distributions * Socket address, internet style. 384*5c2921b0SApple OSS Distributions */ 385*5c2921b0SApple OSS Distributions struct sockaddr_in { 386*5c2921b0SApple OSS Distributions __uint8_t sin_len; 387*5c2921b0SApple OSS Distributions sa_family_t sin_family; 388*5c2921b0SApple OSS Distributions in_port_t sin_port; 389*5c2921b0SApple OSS Distributions struct in_addr sin_addr; 390*5c2921b0SApple OSS Distributions char sin_zero[8]; 391*5c2921b0SApple OSS Distributions }; 392*5c2921b0SApple OSS Distributions 393*5c2921b0SApple OSS Distributions #define IN_ARE_ADDR_EQUAL(a, b) \ 394*5c2921b0SApple OSS Distributions (bcmp(&(a)->s_addr, &(b)->s_addr, \ 395*5c2921b0SApple OSS Distributions sizeof (struct in_addr)) == 0) 396*5c2921b0SApple OSS Distributions 397*5c2921b0SApple OSS Distributions #define INET_ADDRSTRLEN 16 398*5c2921b0SApple OSS Distributions 399*5c2921b0SApple OSS Distributions #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 400*5c2921b0SApple OSS Distributions /* 401*5c2921b0SApple OSS Distributions * Structure used to describe IP options. 402*5c2921b0SApple OSS Distributions * Used to store options internally, to pass them to a process, 403*5c2921b0SApple OSS Distributions * or to restore options retrieved earlier. 404*5c2921b0SApple OSS Distributions * The ip_dst is used for the first-hop gateway when using a source route 405*5c2921b0SApple OSS Distributions * (this gets put into the header proper). 406*5c2921b0SApple OSS Distributions */ 407*5c2921b0SApple OSS Distributions struct ip_opts { 408*5c2921b0SApple OSS Distributions struct in_addr ip_dst; /* first hop, 0 w/o src rt */ 409*5c2921b0SApple OSS Distributions char ip_opts[40]; /* actually variable in size */ 410*5c2921b0SApple OSS Distributions }; 411*5c2921b0SApple OSS Distributions 412*5c2921b0SApple OSS Distributions /* 413*5c2921b0SApple OSS Distributions * Options for use with [gs]etsockopt at the IP level. 414*5c2921b0SApple OSS Distributions * First word of comment is data type; bool is stored in int. 415*5c2921b0SApple OSS Distributions */ 416*5c2921b0SApple OSS Distributions #define IP_OPTIONS 1 /* buf/ip_opts; set/get IP options */ 417*5c2921b0SApple OSS Distributions #define IP_HDRINCL 2 /* int; header is included with data */ 418*5c2921b0SApple OSS Distributions #define IP_TOS 3 /* int; IP type of service and preced. */ 419*5c2921b0SApple OSS Distributions #define IP_TTL 4 /* int; IP time to live */ 420*5c2921b0SApple OSS Distributions #define IP_RECVOPTS 5 /* bool; receive all IP opts w/dgram */ 421*5c2921b0SApple OSS Distributions #define IP_RECVRETOPTS 6 /* bool; receive IP opts for response */ 422*5c2921b0SApple OSS Distributions #define IP_RECVDSTADDR 7 /* bool; receive IP dst addr w/dgram */ 423*5c2921b0SApple OSS Distributions #define IP_RETOPTS 8 /* ip_opts; set/get IP options */ 424*5c2921b0SApple OSS Distributions #define IP_MULTICAST_IF 9 /* u_char; set/get IP multicast i/f */ 425*5c2921b0SApple OSS Distributions #define IP_MULTICAST_TTL 10 /* u_char; set/get IP multicast ttl */ 426*5c2921b0SApple OSS Distributions #define IP_MULTICAST_LOOP 11 /* u_char; set/get IP multicast loopback */ 427*5c2921b0SApple OSS Distributions #define IP_ADD_MEMBERSHIP 12 /* ip_mreq; add an IP group membership */ 428*5c2921b0SApple OSS Distributions #define IP_DROP_MEMBERSHIP 13 /* ip_mreq; drop an IP group membership */ 429*5c2921b0SApple OSS Distributions #define IP_MULTICAST_VIF 14 /* set/get IP mcast virt. iface */ 430*5c2921b0SApple OSS Distributions #define IP_RSVP_ON 15 /* enable RSVP in kernel */ 431*5c2921b0SApple OSS Distributions #define IP_RSVP_OFF 16 /* disable RSVP in kernel */ 432*5c2921b0SApple OSS Distributions #define IP_RSVP_VIF_ON 17 /* set RSVP per-vif socket */ 433*5c2921b0SApple OSS Distributions #define IP_RSVP_VIF_OFF 18 /* unset RSVP per-vif socket */ 434*5c2921b0SApple OSS Distributions #define IP_PORTRANGE 19 /* int; range to choose for unspec port */ 435*5c2921b0SApple OSS Distributions #define IP_RECVIF 20 /* bool; receive reception if w/dgram */ 436*5c2921b0SApple OSS Distributions /* for IPSEC */ 437*5c2921b0SApple OSS Distributions #define IP_IPSEC_POLICY 21 /* int; set/get security policy */ 438*5c2921b0SApple OSS Distributions #define IP_FAITH 22 /* deprecated */ 439*5c2921b0SApple OSS Distributions #ifdef __APPLE__ 440*5c2921b0SApple OSS Distributions #define IP_STRIPHDR 23 /* bool: drop receive of raw IP header */ 441*5c2921b0SApple OSS Distributions #endif 442*5c2921b0SApple OSS Distributions #define IP_RECVTTL 24 /* bool; receive reception TTL w/dgram */ 443*5c2921b0SApple OSS Distributions #define IP_BOUND_IF 25 /* int; set/get bound interface */ 444*5c2921b0SApple OSS Distributions #define IP_PKTINFO 26 /* get pktinfo on recv socket, set src on sent dgram */ 445*5c2921b0SApple OSS Distributions #define IP_RECVPKTINFO IP_PKTINFO /* receive pktinfo w/dgram */ 446*5c2921b0SApple OSS Distributions #define IP_RECVTOS 27 /* bool; receive IP TOS w/dgram */ 447*5c2921b0SApple OSS Distributions #define IP_DONTFRAG 28 /* don't fragment packet */ 448*5c2921b0SApple OSS Distributions 449*5c2921b0SApple OSS Distributions #define IP_FW_ADD 40 /* add a firewall rule to chain */ 450*5c2921b0SApple OSS Distributions #define IP_FW_DEL 41 /* delete a firewall rule from chain */ 451*5c2921b0SApple OSS Distributions #define IP_FW_FLUSH 42 /* flush firewall rule chain */ 452*5c2921b0SApple OSS Distributions #define IP_FW_ZERO 43 /* clear single/all firewall counter(s) */ 453*5c2921b0SApple OSS Distributions #define IP_FW_GET 44 /* get entire firewall rule chain */ 454*5c2921b0SApple OSS Distributions #define IP_FW_RESETLOG 45 /* reset logging counters */ 455*5c2921b0SApple OSS Distributions 456*5c2921b0SApple OSS Distributions /* These older firewall socket option codes are maintained for backward compatibility. */ 457*5c2921b0SApple OSS Distributions #define IP_OLD_FW_ADD 50 /* add a firewall rule to chain */ 458*5c2921b0SApple OSS Distributions #define IP_OLD_FW_DEL 51 /* delete a firewall rule from chain */ 459*5c2921b0SApple OSS Distributions #define IP_OLD_FW_FLUSH 52 /* flush firewall rule chain */ 460*5c2921b0SApple OSS Distributions #define IP_OLD_FW_ZERO 53 /* clear single/all firewall counter(s) */ 461*5c2921b0SApple OSS Distributions #define IP_OLD_FW_GET 54 /* get entire firewall rule chain */ 462*5c2921b0SApple OSS Distributions #define IP_NAT__XXX 55 /* set/get NAT opts XXX Deprecated, do not use */ 463*5c2921b0SApple OSS Distributions #define IP_OLD_FW_RESETLOG 56 /* reset logging counters */ 464*5c2921b0SApple OSS Distributions 465*5c2921b0SApple OSS Distributions #define IP_DUMMYNET_CONFIGURE 60 /* add/configure a dummynet pipe */ 466*5c2921b0SApple OSS Distributions #define IP_DUMMYNET_DEL 61 /* delete a dummynet pipe from chain */ 467*5c2921b0SApple OSS Distributions #define IP_DUMMYNET_FLUSH 62 /* flush dummynet */ 468*5c2921b0SApple OSS Distributions #define IP_DUMMYNET_GET 64 /* get entire dummynet pipes */ 469*5c2921b0SApple OSS Distributions 470*5c2921b0SApple OSS Distributions #define IP_TRAFFIC_MGT_BACKGROUND 65 /* int*; get background IO flags; set background IO */ 471*5c2921b0SApple OSS Distributions #define IP_MULTICAST_IFINDEX 66 /* int*; set/get IP multicast i/f index */ 472*5c2921b0SApple OSS Distributions 473*5c2921b0SApple OSS Distributions /* IPv4 Source Filter Multicast API [RFC3678] */ 474*5c2921b0SApple OSS Distributions #define IP_ADD_SOURCE_MEMBERSHIP 70 /* join a source-specific group */ 475*5c2921b0SApple OSS Distributions #define IP_DROP_SOURCE_MEMBERSHIP 71 /* drop a single source */ 476*5c2921b0SApple OSS Distributions #define IP_BLOCK_SOURCE 72 /* block a source */ 477*5c2921b0SApple OSS Distributions #define IP_UNBLOCK_SOURCE 73 /* unblock a source */ 478*5c2921b0SApple OSS Distributions 479*5c2921b0SApple OSS Distributions /* The following option is private; do not use it from user applications. */ 480*5c2921b0SApple OSS Distributions #define IP_MSFILTER 74 /* set/get filter list */ 481*5c2921b0SApple OSS Distributions 482*5c2921b0SApple OSS Distributions /* Protocol Independent Multicast API [RFC3678] */ 483*5c2921b0SApple OSS Distributions #define MCAST_JOIN_GROUP 80 /* join an any-source group */ 484*5c2921b0SApple OSS Distributions #define MCAST_LEAVE_GROUP 81 /* leave all sources for group */ 485*5c2921b0SApple OSS Distributions #define MCAST_JOIN_SOURCE_GROUP 82 /* join a source-specific group */ 486*5c2921b0SApple OSS Distributions #define MCAST_LEAVE_SOURCE_GROUP 83 /* leave a single source */ 487*5c2921b0SApple OSS Distributions #define MCAST_BLOCK_SOURCE 84 /* block a source */ 488*5c2921b0SApple OSS Distributions #define MCAST_UNBLOCK_SOURCE 85 /* unblock a source */ 489*5c2921b0SApple OSS Distributions 490*5c2921b0SApple OSS Distributions #ifdef PRIVATE 491*5c2921b0SApple OSS Distributions /* See in_private.h for additional options */ 492*5c2921b0SApple OSS Distributions #endif /* PRIVATE */ 493*5c2921b0SApple OSS Distributions 494*5c2921b0SApple OSS Distributions /* 495*5c2921b0SApple OSS Distributions * Defaults and limits for options 496*5c2921b0SApple OSS Distributions */ 497*5c2921b0SApple OSS Distributions #define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */ 498*5c2921b0SApple OSS Distributions #define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */ 499*5c2921b0SApple OSS Distributions 500*5c2921b0SApple OSS Distributions /* 501*5c2921b0SApple OSS Distributions * The imo_membership vector for each socket is now dynamically allocated at 502*5c2921b0SApple OSS Distributions * run-time, bounded by USHRT_MAX, and is reallocated when needed, sized 503*5c2921b0SApple OSS Distributions * according to a power-of-two increment. 504*5c2921b0SApple OSS Distributions */ 505*5c2921b0SApple OSS Distributions #define IP_MIN_MEMBERSHIPS 31 506*5c2921b0SApple OSS Distributions #define IP_MAX_MEMBERSHIPS 4095 507*5c2921b0SApple OSS Distributions 508*5c2921b0SApple OSS Distributions /* 509*5c2921b0SApple OSS Distributions * Default resource limits for IPv4 multicast source filtering. 510*5c2921b0SApple OSS Distributions * These may be modified by sysctl. 511*5c2921b0SApple OSS Distributions */ 512*5c2921b0SApple OSS Distributions #define IP_MAX_GROUP_SRC_FILTER 512 /* sources per group */ 513*5c2921b0SApple OSS Distributions #define IP_MAX_SOCK_SRC_FILTER 128 /* sources per socket/group */ 514*5c2921b0SApple OSS Distributions #define IP_MAX_SOCK_MUTE_FILTER 128 /* XXX no longer used */ 515*5c2921b0SApple OSS Distributions 516*5c2921b0SApple OSS Distributions #ifndef XNU_PLATFORM_DriverKit 517*5c2921b0SApple OSS Distributions /* 518*5c2921b0SApple OSS Distributions * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. 519*5c2921b0SApple OSS Distributions */ 520*5c2921b0SApple OSS Distributions struct ip_mreq { 521*5c2921b0SApple OSS Distributions struct in_addr imr_multiaddr; /* IP multicast address of group */ 522*5c2921b0SApple OSS Distributions struct in_addr imr_interface; /* local IP address of interface */ 523*5c2921b0SApple OSS Distributions }; 524*5c2921b0SApple OSS Distributions 525*5c2921b0SApple OSS Distributions /* 526*5c2921b0SApple OSS Distributions * Modified argument structure for IP_MULTICAST_IF, obtained from Linux. 527*5c2921b0SApple OSS Distributions * This is used to specify an interface index for multicast sends, as 528*5c2921b0SApple OSS Distributions * the IPv4 legacy APIs do not support this (unless IP_SENDIF is available). 529*5c2921b0SApple OSS Distributions */ 530*5c2921b0SApple OSS Distributions struct ip_mreqn { 531*5c2921b0SApple OSS Distributions struct in_addr imr_multiaddr; /* IP multicast address of group */ 532*5c2921b0SApple OSS Distributions struct in_addr imr_address; /* local IP address of interface */ 533*5c2921b0SApple OSS Distributions int imr_ifindex; /* Interface index; cast to uint32_t */ 534*5c2921b0SApple OSS Distributions }; 535*5c2921b0SApple OSS Distributions 536*5c2921b0SApple OSS Distributions #pragma pack(4) 537*5c2921b0SApple OSS Distributions /* 538*5c2921b0SApple OSS Distributions * Argument structure for IPv4 Multicast Source Filter APIs. [RFC3678] 539*5c2921b0SApple OSS Distributions */ 540*5c2921b0SApple OSS Distributions struct ip_mreq_source { 541*5c2921b0SApple OSS Distributions struct in_addr imr_multiaddr; /* IP multicast address of group */ 542*5c2921b0SApple OSS Distributions struct in_addr imr_sourceaddr; /* IP address of source */ 543*5c2921b0SApple OSS Distributions struct in_addr imr_interface; /* local IP address of interface */ 544*5c2921b0SApple OSS Distributions }; 545*5c2921b0SApple OSS Distributions 546*5c2921b0SApple OSS Distributions /* 547*5c2921b0SApple OSS Distributions * Argument structures for Protocol-Independent Multicast Source 548*5c2921b0SApple OSS Distributions * Filter APIs. [RFC3678] 549*5c2921b0SApple OSS Distributions */ 550*5c2921b0SApple OSS Distributions struct group_req { 551*5c2921b0SApple OSS Distributions uint32_t gr_interface; /* interface index */ 552*5c2921b0SApple OSS Distributions struct sockaddr_storage gr_group; /* group address */ 553*5c2921b0SApple OSS Distributions }; 554*5c2921b0SApple OSS Distributions 555*5c2921b0SApple OSS Distributions struct group_source_req { 556*5c2921b0SApple OSS Distributions uint32_t gsr_interface; /* interface index */ 557*5c2921b0SApple OSS Distributions struct sockaddr_storage gsr_group; /* group address */ 558*5c2921b0SApple OSS Distributions struct sockaddr_storage gsr_source; /* source address */ 559*5c2921b0SApple OSS Distributions }; 560*5c2921b0SApple OSS Distributions 561*5c2921b0SApple OSS Distributions #ifndef __MSFILTERREQ_DEFINED 562*5c2921b0SApple OSS Distributions #define __MSFILTERREQ_DEFINED 563*5c2921b0SApple OSS Distributions /* 564*5c2921b0SApple OSS Distributions * The following structure is private; do not use it from user applications. 565*5c2921b0SApple OSS Distributions * It is used to communicate IP_MSFILTER/IPV6_MSFILTER information between 566*5c2921b0SApple OSS Distributions * the RFC 3678 libc functions and the kernel. 567*5c2921b0SApple OSS Distributions */ 568*5c2921b0SApple OSS Distributions struct __msfilterreq { 569*5c2921b0SApple OSS Distributions uint32_t msfr_ifindex; /* interface index */ 570*5c2921b0SApple OSS Distributions uint32_t msfr_fmode; /* filter mode for group */ 571*5c2921b0SApple OSS Distributions uint32_t msfr_nsrcs; /* # of sources in msfr_srcs */ 572*5c2921b0SApple OSS Distributions uint32_t __msfr_align; 573*5c2921b0SApple OSS Distributions struct sockaddr_storage msfr_group; /* group address */ 574*5c2921b0SApple OSS Distributions struct sockaddr_storage *msfr_srcs; 575*5c2921b0SApple OSS Distributions }; 576*5c2921b0SApple OSS Distributions 577*5c2921b0SApple OSS Distributions #ifdef BSD_KERNEL_PRIVATE 578*5c2921b0SApple OSS Distributions struct __msfilterreq32 { 579*5c2921b0SApple OSS Distributions uint32_t msfr_ifindex; /* interface index */ 580*5c2921b0SApple OSS Distributions uint32_t msfr_fmode; /* filter mode for group */ 581*5c2921b0SApple OSS Distributions uint32_t msfr_nsrcs; /* # of sources in msfr_srcs */ 582*5c2921b0SApple OSS Distributions uint32_t __msfr_align; 583*5c2921b0SApple OSS Distributions struct sockaddr_storage msfr_group; /* group address */ 584*5c2921b0SApple OSS Distributions user32_addr_t msfr_srcs; 585*5c2921b0SApple OSS Distributions }; 586*5c2921b0SApple OSS Distributions 587*5c2921b0SApple OSS Distributions struct __msfilterreq64 { 588*5c2921b0SApple OSS Distributions uint32_t msfr_ifindex; /* interface index */ 589*5c2921b0SApple OSS Distributions uint32_t msfr_fmode; /* filter mode for group */ 590*5c2921b0SApple OSS Distributions uint32_t msfr_nsrcs; /* # of sources in msfr_srcs */ 591*5c2921b0SApple OSS Distributions uint32_t __msfr_align; 592*5c2921b0SApple OSS Distributions struct sockaddr_storage msfr_group; /* group address */ 593*5c2921b0SApple OSS Distributions user64_addr_t msfr_srcs; 594*5c2921b0SApple OSS Distributions }; 595*5c2921b0SApple OSS Distributions #endif /* BSD_KERNEL_PRIVATE */ 596*5c2921b0SApple OSS Distributions #endif /* __MSFILTERREQ_DEFINED */ 597*5c2921b0SApple OSS Distributions 598*5c2921b0SApple OSS Distributions #pragma pack() 599*5c2921b0SApple OSS Distributions struct sockaddr; 600*5c2921b0SApple OSS Distributions 601*5c2921b0SApple OSS Distributions #ifndef KERNEL 602*5c2921b0SApple OSS Distributions /* 603*5c2921b0SApple OSS Distributions * Advanced (Full-state) APIs [RFC3678] 604*5c2921b0SApple OSS Distributions * The RFC specifies uint_t for the 6th argument to [sg]etsourcefilter(). 605*5c2921b0SApple OSS Distributions * We use uint32_t here to be consistent. 606*5c2921b0SApple OSS Distributions */ 607*5c2921b0SApple OSS Distributions int setipv4sourcefilter(int, struct in_addr, struct in_addr, uint32_t, 608*5c2921b0SApple OSS Distributions uint32_t, struct in_addr *) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); 609*5c2921b0SApple OSS Distributions int getipv4sourcefilter(int, struct in_addr, struct in_addr, uint32_t *, 610*5c2921b0SApple OSS Distributions uint32_t *, struct in_addr *) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); 611*5c2921b0SApple OSS Distributions int setsourcefilter(int, uint32_t, struct sockaddr *, socklen_t, 612*5c2921b0SApple OSS Distributions uint32_t, uint32_t, struct sockaddr_storage *) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); 613*5c2921b0SApple OSS Distributions int getsourcefilter(int, uint32_t, struct sockaddr *, socklen_t, 614*5c2921b0SApple OSS Distributions uint32_t *, uint32_t *, struct sockaddr_storage *) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); 615*5c2921b0SApple OSS Distributions #endif 616*5c2921b0SApple OSS Distributions #endif /* XNU_PLATFORM_DriverKit */ 617*5c2921b0SApple OSS Distributions 618*5c2921b0SApple OSS Distributions /* 619*5c2921b0SApple OSS Distributions * Filter modes; also used to represent per-socket filter mode internally. 620*5c2921b0SApple OSS Distributions */ 621*5c2921b0SApple OSS Distributions #define MCAST_UNDEFINED 0 /* fmode: not yet defined */ 622*5c2921b0SApple OSS Distributions #define MCAST_INCLUDE 1 /* fmode: include these source(s) */ 623*5c2921b0SApple OSS Distributions #define MCAST_EXCLUDE 2 /* fmode: exclude these source(s) */ 624*5c2921b0SApple OSS Distributions 625*5c2921b0SApple OSS Distributions /* 626*5c2921b0SApple OSS Distributions * Argument for IP_PORTRANGE: 627*5c2921b0SApple OSS Distributions * - which range to search when port is unspecified at bind() or connect() 628*5c2921b0SApple OSS Distributions */ 629*5c2921b0SApple OSS Distributions #define IP_PORTRANGE_DEFAULT 0 /* default range */ 630*5c2921b0SApple OSS Distributions #define IP_PORTRANGE_HIGH 1 /* "high" - request firewall bypass */ 631*5c2921b0SApple OSS Distributions #define IP_PORTRANGE_LOW 2 /* "low" - vouchsafe security */ 632*5c2921b0SApple OSS Distributions 633*5c2921b0SApple OSS Distributions 634*5c2921b0SApple OSS Distributions /* 635*5c2921b0SApple OSS Distributions * IP_PKTINFO: Packet information (equivalent to RFC2292 sec 5 for IPv4) 636*5c2921b0SApple OSS Distributions * This structure is used for 637*5c2921b0SApple OSS Distributions * 638*5c2921b0SApple OSS Distributions * 1) Receiving ancilliary data about the datagram if IP_PKTINFO sockopt is 639*5c2921b0SApple OSS Distributions * set on the socket. In this case ipi_ifindex will contain the interface 640*5c2921b0SApple OSS Distributions * index the datagram was received on, ipi_addr is the IP address the 641*5c2921b0SApple OSS Distributions * datagram was received to. 642*5c2921b0SApple OSS Distributions * 643*5c2921b0SApple OSS Distributions * 2) Sending a datagram using a specific interface or IP source address. 644*5c2921b0SApple OSS Distributions * if ipi_ifindex is set to non-zero when in_pktinfo is passed as 645*5c2921b0SApple OSS Distributions * ancilliary data of type IP_PKTINFO, this will be used as the source 646*5c2921b0SApple OSS Distributions * interface to send the datagram from. If ipi_ifindex is null, ip_spec_dst 647*5c2921b0SApple OSS Distributions * will be used for the source address. 648*5c2921b0SApple OSS Distributions * 649*5c2921b0SApple OSS Distributions * Note: if IP_BOUND_IF is set on the socket, ipi_ifindex in the ancillary 650*5c2921b0SApple OSS Distributions * IP_PKTINFO option silently overrides the bound interface when it is 651*5c2921b0SApple OSS Distributions * specified during send time. 652*5c2921b0SApple OSS Distributions */ 653*5c2921b0SApple OSS Distributions struct in_pktinfo { 654*5c2921b0SApple OSS Distributions unsigned int ipi_ifindex; /* send/recv interface index */ 655*5c2921b0SApple OSS Distributions struct in_addr ipi_spec_dst; /* Local address */ 656*5c2921b0SApple OSS Distributions struct in_addr ipi_addr; /* IP Header dst address */ 657*5c2921b0SApple OSS Distributions }; 658*5c2921b0SApple OSS Distributions 659*5c2921b0SApple OSS Distributions /* 660*5c2921b0SApple OSS Distributions * Definitions for inet sysctl operations. 661*5c2921b0SApple OSS Distributions * 662*5c2921b0SApple OSS Distributions * Third level is protocol number. 663*5c2921b0SApple OSS Distributions * Fourth level is desired variable within that protocol. 664*5c2921b0SApple OSS Distributions */ 665*5c2921b0SApple OSS Distributions #define IPPROTO_MAXID (IPPROTO_AH + 1) /* don't list to IPPROTO_MAX */ 666*5c2921b0SApple OSS Distributions 667*5c2921b0SApple OSS Distributions /* 668*5c2921b0SApple OSS Distributions * Names for IP sysctl objects 669*5c2921b0SApple OSS Distributions */ 670*5c2921b0SApple OSS Distributions #define IPCTL_FORWARDING 1 /* act as router */ 671*5c2921b0SApple OSS Distributions #define IPCTL_SENDREDIRECTS 2 /* may send redirects when forwarding */ 672*5c2921b0SApple OSS Distributions #define IPCTL_DEFTTL 3 /* default TTL */ 673*5c2921b0SApple OSS Distributions #ifdef notyet 674*5c2921b0SApple OSS Distributions #define IPCTL_DEFMTU 4 /* default MTU */ 675*5c2921b0SApple OSS Distributions #endif 676*5c2921b0SApple OSS Distributions #define IPCTL_RTEXPIRE 5 /* cloned route expiration time */ 677*5c2921b0SApple OSS Distributions #define IPCTL_RTMINEXPIRE 6 /* min value for expiration time */ 678*5c2921b0SApple OSS Distributions #define IPCTL_RTMAXCACHE 7 /* trigger level for dynamic expire */ 679*5c2921b0SApple OSS Distributions #define IPCTL_SOURCEROUTE 8 /* may perform source routes */ 680*5c2921b0SApple OSS Distributions #define IPCTL_DIRECTEDBROADCAST 9 /* may re-broadcast received packets */ 681*5c2921b0SApple OSS Distributions #define IPCTL_INTRQMAXLEN 10 /* max length of netisr queue */ 682*5c2921b0SApple OSS Distributions #define IPCTL_INTRQDROPS 11 /* number of netisr q drops */ 683*5c2921b0SApple OSS Distributions #define IPCTL_STATS 12 /* ipstat structure */ 684*5c2921b0SApple OSS Distributions #define IPCTL_ACCEPTSOURCEROUTE 13 /* may accept source routed packets */ 685*5c2921b0SApple OSS Distributions #define IPCTL_FASTFORWARDING 14 /* use fast IP forwarding code */ 686*5c2921b0SApple OSS Distributions #define IPCTL_KEEPFAITH 15 /* deprecated */ 687*5c2921b0SApple OSS Distributions #define IPCTL_GIF_TTL 16 /* default TTL for gif encap packet */ 688*5c2921b0SApple OSS Distributions #define IPCTL_MAXID 17 689*5c2921b0SApple OSS Distributions 690*5c2921b0SApple OSS Distributions #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ 691*5c2921b0SApple OSS Distributions 692*5c2921b0SApple OSS Distributions /* INET6 stuff */ 693*5c2921b0SApple OSS Distributions #define __KAME_NETINET_IN_H_INCLUDED_ 694*5c2921b0SApple OSS Distributions #include <netinet6/in6.h> 695*5c2921b0SApple OSS Distributions #undef __KAME_NETINET_IN_H_INCLUDED_ 696*5c2921b0SApple OSS Distributions 697*5c2921b0SApple OSS Distributions #ifndef XNU_PLATFORM_DriverKit 698*5c2921b0SApple OSS Distributions #ifdef KERNEL 699*5c2921b0SApple OSS Distributions #define MAX_IPv4_STR_LEN 16 700*5c2921b0SApple OSS Distributions #define MAX_IPv6_STR_LEN 64 701*5c2921b0SApple OSS Distributions 702*5c2921b0SApple OSS Distributions extern int inet_aton(const char *, struct in_addr *); /* in libkern */ 703*5c2921b0SApple OSS Distributions extern const char *inet_ntop(int, const void *, char *, socklen_t); /* in libkern*/ 704*5c2921b0SApple OSS Distributions #endif /* KERNEL */ 705*5c2921b0SApple OSS Distributions 706*5c2921b0SApple OSS Distributions #ifndef KERNEL 707*5c2921b0SApple OSS Distributions #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) 708*5c2921b0SApple OSS Distributions __BEGIN_DECLS 709*5c2921b0SApple OSS Distributions int bindresvport(int, struct sockaddr_in *); 710*5c2921b0SApple OSS Distributions struct sockaddr; 711*5c2921b0SApple OSS Distributions int bindresvport_sa(int, struct sockaddr *); 712*5c2921b0SApple OSS Distributions __END_DECLS 713*5c2921b0SApple OSS Distributions #endif 714*5c2921b0SApple OSS Distributions #endif /* !KERNEL */ 715*5c2921b0SApple OSS Distributions #endif /* XNU_PLATFORM_DriverKit */ 716*5c2921b0SApple OSS Distributions 717*5c2921b0SApple OSS Distributions #ifdef PRIVATE 718*5c2921b0SApple OSS Distributions #include <netinet/in_private.h> 719*5c2921b0SApple OSS Distributions #endif /* PRIVATE */ 720*5c2921b0SApple OSS Distributions 721*5c2921b0SApple OSS Distributions #endif /* _NETINET_IN_H_ */ 722