199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copyright (c) 1982, 1986, 1990, 1993
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The Regents of the University of California. All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Redistribution and use in source and binary forms, with or without
199767f8919635c4928607450d9e0abb932109ceToomas Soome * modification, are permitted provided that the following conditions
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 1. Redistributions of source code must retain the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 2. Redistributions in binary form must reproduce the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer in the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * documentation and/or other materials provided with the distribution.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 4. Neither the name of the University nor the names of its contributors
199767f8919635c4928607450d9e0abb932109ceToomas Soome * may be used to endorse or promote products derived from this software
199767f8919635c4928607450d9e0abb932109ceToomas Soome * without specific prior written permission.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
199767f8919635c4928607450d9e0abb932109ceToomas Soome * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
199767f8919635c4928607450d9e0abb932109ceToomas Soome * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
199767f8919635c4928607450d9e0abb932109ceToomas Soome * SUCH DAMAGE.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * @(#)in.h 8.3 (Berkeley) 1/3/94
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Protocols common to RFC 1700, POSIX, and X/Open. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_ICMP 1 /* control message protocol */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_UDP 17 /* user datagram protocol */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define INADDR_BROADCAST ((in_addr_t)0xffffffff) /* must be masked */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Internet address (a structure for historical reasons). */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Socket address, internet style. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if !defined(_KERNEL) && __POSIX_VISIBLE >= 200112
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* !_KERNEL && __POSIX_VISIBLE >= 200112 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Constants and structures defined by the internet system,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Per RFC 790, September 1981, and numerous additions.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Protocols (RFC 1700)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_HOPOPTS 0 /* IP6 hop-by-hop options */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_IGMP 2 /* group mgmt protocol */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_GGP 3 /* gateway^2 (deprecated) */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_IPIP IPPROTO_IPV4 /* for compatibility */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_EGP 8 /* exterior gateway protocol */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_PIGP 9 /* private interior gateway */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_RCCMON 10 /* BBN RCC Monitoring */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_NVPII 11 /* network voice protocol*/
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_XNET 15 /* Cross Net Debugger */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_MEAS 19 /* DCN Measurement Subsystems */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_PRM 21 /* Packet Radio Measurement */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_IRTP 28 /* Reliable Transaction */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_TP 29 /* tp-4 w/ class negotiation */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_SEP 33 /* Sequential Exchange */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_3PC 34 /* Third Party Connect */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_IDPR 35 /* InterDomain Policy Routing */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_CMTP 38 /* Control Message Transport */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_IL 40 /* IL transport protocol */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_SDRP 42 /* Source Demand Routing */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_ROUTING 43 /* IP6 routing header */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_FRAGMENT 44 /* IP6 fragmentation header */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_IDRP 45 /* InterDomain Routing*/
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_RSVP 46 /* resource reservation */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_GRE 47 /* General Routing Encap. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_MHRP 48 /* Mobile Host Routing */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_ESP 50 /* IP6 Encap Sec. Payload */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_INLSP 52 /* Integ. Net Layer Security */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_SWIPE 53 /* IP with encryption */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_NHRP 54 /* Next Hop Resolution */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_TLSP 56 /* Transport Layer Security */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_NONE 59 /* IP6 no next header */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_DSTOPTS 60 /* IP6 destination option */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_AHIP 61 /* any host internal protocol */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_HELLO 63 /* "hello" routing protocol */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_SATEXPAK 64 /* SATNET/Backroom EXPAK */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_RVD 66 /* Remote Virtual Disk */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_IPPC 67 /* Pluribus Packet Core */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_ADFS 68 /* Any distributed FS */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_SATMON 69 /* Satnet Monitoring */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_IPCV 71 /* Packet Core Utility */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_CPNX 72 /* Comp. Prot. Net. Executive */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_CPHB 73 /* Comp. Prot. HeartBeat */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_PVP 75 /* Packet Video Protocol */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_BRSATMON 76 /* BackRoom SATNET Monitoring */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_ND 77 /* Sun net disk proto (temp.) */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_WBMON 78 /* WIDEBAND Monitoring */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_DGP 86 /* dissimilar gateway prot. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_SRPC 90 /* Strite RPC protocol */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_LARP 91 /* Locus Address Resoloution */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_MTP 92 /* Multicast Transport */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_IPEIP 94 /* IP encapsulated in IP */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_MICP 95 /* Mobile Int.ing control */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_SCCSP 96 /* Semaphore Comm. security */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_ETHERIP 97 /* Ethernet IP encapsulation */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_ENCAP 98 /* encapsulation header */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_APES 99 /* any private encr. scheme */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_IPCOMP 108 /* payload compression (IPComp) */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_MH 135 /* IPv6 Mobility Header */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_HIP 139 /* IP6 Host Identity Protocol */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_SHIM6 140 /* IP6 Shim6 Protocol */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* 101-254: Partly Unassigned */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_PIM 103 /* Protocol Independent Mcast */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* 255: Reserved */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* BSD Private, local use, namespace incursion, no longer used */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_OLD_DIVERT 254 /* OLD divert pseudo-proto */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* last return value of *_input(), meaning "all job for this pkt is done". */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Only used internally, so can be outside the range of valid IP protocols. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_DIVERT 258 /* divert pseudo-protocol */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_SEND 259 /* SeND pseudo-protocol */
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Defined to avoid confusion. The master value is defined by
199767f8919635c4928607450d9e0abb932109ceToomas Soome * PROTO_SPACER in sys/protosw.h.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPPROTO_SPACER 32767 /* spacer for loadable protos */
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Local port number conventions:
199767f8919635c4928607450d9e0abb932109ceToomas Soome * When a user does a bind(2) or connect(2) with a port number of zero,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * a non-conflicting local port address is chosen.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The default range is IPPORT_HIFIRSTAUTO through
199767f8919635c4928607450d9e0abb932109ceToomas Soome * IPPORT_HILASTAUTO, although that is settable by sysctl.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * A user may set the IPPROTO_IP option IP_PORTRANGE to change this
199767f8919635c4928607450d9e0abb932109ceToomas Soome * default assignment range.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The value IP_PORTRANGE_DEFAULT causes the default behavior.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The value IP_PORTRANGE_HIGH changes the range of candidate port numbers
199767f8919635c4928607450d9e0abb932109ceToomas Soome * into the "high" range. These are reserved for client outbound connections
199767f8919635c4928607450d9e0abb932109ceToomas Soome * which do not want to be filtered by any firewalls.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The value IP_PORTRANGE_LOW changes the range to the "low" are
199767f8919635c4928607450d9e0abb932109ceToomas Soome * that is (by convention) restricted to privileged processes. This
199767f8919635c4928607450d9e0abb932109ceToomas Soome * convention is based on "vouchsafe" principles only. It is only secure
199767f8919635c4928607450d9e0abb932109ceToomas Soome * if you trust the remote host to restrict these ports.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The default range of ports and the high range can be changed by
199767f8919635c4928607450d9e0abb932109ceToomas Soome * sysctl(3). (net.inet.ip.port{hi,low}{first,last}_auto)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Changing those values has bad security implications if you are
199767f8919635c4928607450d9e0abb932109ceToomas Soome * using a stateless firewall that is allowing packets outside of that
199767f8919635c4928607450d9e0abb932109ceToomas Soome * range in order to allow transparent outgoing connections.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Such a firewall configuration will generally depend on the use of these
199767f8919635c4928607450d9e0abb932109ceToomas Soome * default values. If you change them, you may find your Security
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Administrator looking for you with a heavy object.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * For a slightly more orthodox text view on this:
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ftp://ftp.isi.edu/in-notes/iana/assignments/port-numbers
199767f8919635c4928607450d9e0abb932109ceToomas Soome * port numbers are divided into three ranges:
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 0 - 1023 Well Known Ports
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 1024 - 49151 Registered Ports
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 49152 - 65535 Dynamic and/or Private Ports
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Ports < IPPORT_RESERVED are reserved for
199767f8919635c4928607450d9e0abb932109ceToomas Soome * privileged processes (e.g. root). (IP_PORTRANGE_LOW)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Default local port range, used by IP_PORTRANGE_DEFAULT
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Dynamic port range, used by IP_PORTRANGE_HIGH.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Scanning for a free reserved port return a value below IPPORT_RESERVED,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * but higher than IPPORT_RESERVEDSTART. Traditionally the start value was
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 512, but that conflicts with some well-known-services that firewalls may
199767f8919635c4928607450d9e0abb932109ceToomas Soome * have a fit if we use.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Definitions of bits in internet address integers.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * On subnets, the decomposition of addresses to host and net parts
199767f8919635c4928607450d9e0abb932109ceToomas Soome * is done according to subnet mask, not the masks here.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IN_CLASSA(i) (((in_addr_t)(i) & 0x80000000) == 0)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IN_CLASSB(i) (((in_addr_t)(i) & 0xc0000000) == 0x80000000)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IN_CLASSC(i) (((in_addr_t)(i) & 0xe0000000) == 0xc0000000)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IN_CLASSD(i) (((in_addr_t)(i) & 0xf0000000) == 0xe0000000)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IN_CLASSD_NSHIFT 28 /* net and host fields, but */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IN_EXPERIMENTAL(i) (((in_addr_t)(i) & 0xf0000000) == 0xf0000000)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IN_BADCLASS(i) (((in_addr_t)(i) & 0xf0000000) == 0xf0000000)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IN_LINKLOCAL(i) (((in_addr_t)(i) & 0xffff0000) == 0xa9fe0000)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IN_LOOPBACK(i) (((in_addr_t)(i) & 0xff000000) == 0x7f000000)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IN_ZERONET(i) (((in_addr_t)(i) & 0xff000000) == 0)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IN_PRIVATE(i) ((((in_addr_t)(i) & 0xff000000) == 0x0a000000) || \
199767f8919635c4928607450d9e0abb932109ceToomas Soome (((in_addr_t)(i) & 0xfff00000) == 0xac100000) || \
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IN_LOCAL_GROUP(i) (((in_addr_t)(i) & 0xffffff00) == 0xe0000000)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IN_ANY_LOCAL(i) (IN_LINKLOCAL(i) || IN_LOCAL_GROUP(i))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define INADDR_NONE ((in_addr_t)0xffffffff) /* -1 return */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define INADDR_UNSPEC_GROUP ((in_addr_t)0xe0000000) /* 224.0.0.0 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define INADDR_ALLHOSTS_GROUP ((in_addr_t)0xe0000001) /* 224.0.0.1 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define INADDR_ALLRTRS_GROUP ((in_addr_t)0xe0000002) /* 224.0.0.2 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define INADDR_ALLRPTS_GROUP ((in_addr_t)0xe0000016) /* 224.0.0.22, IGMPv3 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define INADDR_CARP_GROUP ((in_addr_t)0xe0000012) /* 224.0.0.18 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define INADDR_PFSYNC_GROUP ((in_addr_t)0xe00000f0) /* 224.0.0.240 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define INADDR_ALLMDNS_GROUP ((in_addr_t)0xe00000fb) /* 224.0.0.251 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define INADDR_MAX_LOCAL_GROUP ((in_addr_t)0xe00000ff) /* 224.0.0.255 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Options for use with [gs]etsockopt at the IP level.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * First word of comment is data type; bool is stored in int.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_OPTIONS 1 /* buf/ip_opts; set/get IP options */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_HDRINCL 2 /* int; header is included with data */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_TOS 3 /* int; IP type of service and preced. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_RECVOPTS 5 /* bool; receive all IP opts w/dgram */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_RECVRETOPTS 6 /* bool; receive IP opts for response */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_RECVDSTADDR 7 /* bool; receive IP dst addr w/dgram */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_SENDSRCADDR IP_RECVDSTADDR /* cmsg_type to set src addr */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_RETOPTS 8 /* ip_opts; set/get IP options */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_MULTICAST_IF 9 /* struct in_addr *or* struct ip_mreqn;
199767f8919635c4928607450d9e0abb932109ceToomas Soome * set/get IP multicast i/f */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_MULTICAST_TTL 10 /* u_char; set/get IP multicast ttl */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_MULTICAST_LOOP 11 /* u_char; set/get IP multicast loopback */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_ADD_MEMBERSHIP 12 /* ip_mreq; add an IP group membership */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_DROP_MEMBERSHIP 13 /* ip_mreq; drop an IP group membership */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_MULTICAST_VIF 14 /* set/get IP mcast virt. iface */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_RSVP_ON 15 /* enable RSVP in kernel */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_RSVP_OFF 16 /* disable RSVP in kernel */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_RSVP_VIF_ON 17 /* set RSVP per-vif socket */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_RSVP_VIF_OFF 18 /* unset RSVP per-vif socket */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_PORTRANGE 19 /* int; range to choose for unspec port */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_RECVIF 20 /* bool; receive reception if w/dgram */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* for IPSEC */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_IPSEC_POLICY 21 /* int; set/get security policy */
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* unused; was IP_FAITH */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_ONESBCAST 23 /* bool: send all-ones broadcast */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_BINDANY 24 /* bool: allow bind to any address */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_BINDMULTI 25 /* bool: allow multiple listeners on a tuple */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_RSS_LISTEN_BUCKET 26 /* int; set RSS listen bucket */
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Options for controlling the firewall and dummynet.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Historical options (from 40 to 64) will eventually be
199767f8919635c4928607450d9e0abb932109ceToomas Soome * replaced by only two options, IP_FW3 and IP_DUMMYNET3.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_FW_TABLE_GETSIZE 43 /* get table size */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_FW_TABLE_LIST 44 /* list table contents */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_FW3 48 /* generic ipfw v.3 sockopts */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_DUMMYNET3 49 /* generic dummynet v.3 sockopts */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_FW_ADD 50 /* add a firewall rule to chain */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_FW_DEL 51 /* delete a firewall rule from chain */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_FW_FLUSH 52 /* flush firewall rule chain */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_FW_ZERO 53 /* clear single/all firewall counter(s) */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_FW_GET 54 /* get entire firewall rule chain */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_FW_RESETLOG 55 /* reset logging counters */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_FW_NAT_CFG 56 /* add/config a nat rule */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_FW_NAT_DEL 57 /* delete a nat rule */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_FW_NAT_GET_CONFIG 58 /* get configuration of a nat rule */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_FW_NAT_GET_LOG 59 /* get log of a nat rule */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_DUMMYNET_CONFIGURE 60 /* add/configure a dummynet pipe */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_DUMMYNET_DEL 61 /* delete a dummynet pipe from chain */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_DUMMYNET_FLUSH 62 /* flush dummynet */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_DUMMYNET_GET 64 /* get entire dummynet pipes */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_RECVTTL 65 /* bool; receive IP TTL w/dgram */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_MINTTL 66 /* minimum TTL for packet or drop */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_DONTFRAG 67 /* don't fragment packet */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_RECVTOS 68 /* bool; receive IP TOS w/dgram */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* IPv4 Source Filter Multicast API [RFC3678] */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_ADD_SOURCE_MEMBERSHIP 70 /* join a source-specific group */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_DROP_SOURCE_MEMBERSHIP 71 /* drop a single source */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_UNBLOCK_SOURCE 73 /* unblock a source */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* The following option is private; do not use it from user applications. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_MSFILTER 74 /* set/get filter list */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Protocol Independent Multicast API [RFC3678] */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MCAST_JOIN_GROUP 80 /* join an any-source group */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MCAST_LEAVE_GROUP 81 /* leave all sources for group */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MCAST_JOIN_SOURCE_GROUP 82 /* join a source-specific group */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MCAST_LEAVE_SOURCE_GROUP 83 /* leave a single source */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MCAST_BLOCK_SOURCE 84 /* block a source */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MCAST_UNBLOCK_SOURCE 85 /* unblock a source */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Flow and RSS definitions */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_FLOWID 90 /* get flow id for the given socket/inp */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_FLOWTYPE 91 /* get flow type (M_HASHTYPE) */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_RSSBUCKETID 92 /* get RSS flowid -> bucket mapping */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_RECVFLOWID 93 /* bool; receive IP flowid/flowtype w/ datagram */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_RECVRSSBUCKETID 94 /* bool; receive IP RSS bucket id w/ datagram */
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Defaults and limits for options
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The imo_membership vector for each socket is now dynamically allocated at
199767f8919635c4928607450d9e0abb932109ceToomas Soome * run-time, bounded by USHRT_MAX, and is reallocated when needed, sized
199767f8919635c4928607450d9e0abb932109ceToomas Soome * according to a power-of-two increment.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_MAX_SOURCE_FILTER 1024 /* XXX to be unused */
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Default resource limits for IPv4 multicast source filtering.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * These may be modified by sysctl.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_MAX_GROUP_SRC_FILTER 512 /* sources per group */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_MAX_SOCK_SRC_FILTER 128 /* sources per socket/group */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_MAX_SOCK_MUTE_FILTER 128 /* XXX no longer used */
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct in_addr imr_multiaddr; /* IP multicast address of group */
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct in_addr imr_interface; /* local IP address of interface */
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Modified argument structure for IP_MULTICAST_IF, obtained from Linux.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * This is used to specify an interface index for multicast sends, as
199767f8919635c4928607450d9e0abb932109ceToomas Soome * the IPv4 legacy APIs do not support this (unless IP_SENDIF is available).
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct in_addr imr_multiaddr; /* IP multicast address of group */
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct in_addr imr_address; /* local IP address of interface */
199767f8919635c4928607450d9e0abb932109ceToomas Soome int imr_ifindex; /* Interface index; cast to uint32_t */
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Argument structure for IPv4 Multicast Source Filter APIs. [RFC3678]
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct in_addr imr_multiaddr; /* IP multicast address of group */
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct in_addr imr_sourceaddr; /* IP address of source */
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct in_addr imr_interface; /* local IP address of interface */
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Argument structures for Protocol-Independent Multicast Source
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Filter APIs. [RFC3678]
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct sockaddr_storage gr_group; /* group address */
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct sockaddr_storage gsr_group; /* group address */
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct sockaddr_storage gsr_source; /* source address */
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The following structure is private; do not use it from user applications.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * It is used to communicate IP_MSFILTER/IPV6_MSFILTER information between
199767f8919635c4928607450d9e0abb932109ceToomas Soome * the RFC 3678 libc functions and the kernel.
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint32_t msfr_fmode; /* filter mode for group */
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint32_t msfr_nsrcs; /* # of sources in msfr_srcs */
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct sockaddr_storage msfr_group; /* group address */
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct sockaddr_storage *msfr_srcs; /* pointer to the first member
199767f8919635c4928607450d9e0abb932109ceToomas Soome * of a contiguous array of
199767f8919635c4928607450d9e0abb932109ceToomas Soome * sources to filter in full.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Advanced (Full-state) APIs [RFC3678]
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The RFC specifies uint_t for the 6th argument to [sg]etsourcefilter().
199767f8919635c4928607450d9e0abb932109ceToomas Soome * We use uint32_t here to be consistent.
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint setipv4sourcefilter(int, struct in_addr, struct in_addr, uint32_t,
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint getipv4sourcefilter(int, struct in_addr, struct in_addr, uint32_t *,
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint setsourcefilter(int, uint32_t, struct sockaddr *, socklen_t,
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint32_t, uint32_t, struct sockaddr_storage *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint getsourcefilter(int, uint32_t, struct sockaddr *, socklen_t,
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint32_t *, uint32_t *, struct sockaddr_storage *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Filter modes; also used to represent per-socket filter mode internally.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MCAST_UNDEFINED 0 /* fmode: not yet defined */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MCAST_INCLUDE 1 /* fmode: include these source(s) */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MCAST_EXCLUDE 2 /* fmode: exclude these source(s) */
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Argument for IP_PORTRANGE:
199767f8919635c4928607450d9e0abb932109ceToomas Soome * - which range to search when port is unspecified at bind() or connect()
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_PORTRANGE_DEFAULT 0 /* default range */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_PORTRANGE_HIGH 1 /* "high" - request firewall bypass */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IP_PORTRANGE_LOW 2 /* "low" - vouchsafe security */
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Identifiers for IP sysctl nodes
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPCTL_SENDREDIRECTS 2 /* may send redirects when forwarding */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* IPCTL_RTEXPIRE 5 deprecated */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* IPCTL_RTMINEXPIRE 6 deprecated */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* IPCTL_RTMAXCACHE 7 deprecated */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPCTL_SOURCEROUTE 8 /* may perform source routes */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPCTL_DIRECTEDBROADCAST 9 /* may re-broadcast received packets */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPCTL_INTRQMAXLEN 10 /* max length of netisr queue */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPCTL_INTRQDROPS 11 /* number of netisr q drops */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPCTL_ACCEPTSOURCEROUTE 13 /* may accept source routed packets */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPCTL_FASTFORWARDING 14 /* use fast IP forwarding code */
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* 15, unused, was: IPCTL_KEEPFAITH */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IPCTL_GIF_TTL 16 /* default TTL for gif encap packet */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* __BSD_VISIBLE */
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct ifnet; struct mbuf; /* forward declarations for Standard C */
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint in_broadcast(struct in_addr, struct ifnet *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint in_ifhasaddr(struct ifnet *, struct in_addr);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint inet_aton(const char *, struct in_addr *); /* in libkern */
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *inet_ntoa(struct in_addr); /* in libkern */
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *inet_ntoa_r(struct in_addr ina, char *buf); /* in libkern */
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *inet_ntop(int, const void *, char *, socklen_t); /* in libkern */
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint inet_pton(int af, const char *, void *); /* in libkern */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define in_hosteq(s, t) ((s).s_addr == (t).s_addr)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define in_nullhost(x) ((x).s_addr == INADDR_ANY)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define in_allhosts(x) ((x).s_addr == htonl(INADDR_ALLHOSTS_GROUP))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define satosin(sa) ((struct sockaddr_in *)(sa))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define ifatoia(ifa) ((struct in_ifaddr *)(ifa))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* _KERNEL */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* INET6 stuff */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* !_NETINET_IN_H_*/