#include <netinet/in.h>

netinet/in.h

includes: sys/appleapiopts.h, stdint.h, Availability.h, sys/_types/_in_addr_t.h, sys/_types/_in_port_t.h, sys/socket.h, machine/endian.h, sys/_endian.h, netinet6/in6.h
244 macros · 10 structs · 6 functions

macroIPPROTO_IP

Protocols (RFC 1700)
#define IPPROTO_IP 0
dummy for IP

macroIPPROTO_HOPOPTS

#define IPPROTO_HOPOPTS 0
IP6 hop-by-hop options

macroIPPROTO_ICMP

#define IPPROTO_ICMP 1
control message protocol

macroIPPROTO_IGMP

#define IPPROTO_IGMP 2
group mgmt protocol

macroIPPROTO_GGP

#define IPPROTO_GGP 3
gateway^2 (deprecated)

macroIPPROTO_IPV4

#define IPPROTO_IPV4 4
IPv4 encapsulation

macroIPPROTO_IPIP

#define IPPROTO_IPIP IPPROTO_IPV4
for compatibility

macroIPPROTO_TCP

#define IPPROTO_TCP 6
tcp

macroIPPROTO_ST

#define IPPROTO_ST 7
Stream protocol II

macroIPPROTO_EGP

#define IPPROTO_EGP 8
exterior gateway protocol

macroIPPROTO_PIGP

#define IPPROTO_PIGP 9
private interior gateway

macroIPPROTO_RCCMON

#define IPPROTO_RCCMON 10
BBN RCC Monitoring

macroIPPROTO_NVPII

#define IPPROTO_NVPII 11
network voice protocol

macroIPPROTO_PUP

#define IPPROTO_PUP 12
pup

macroIPPROTO_ARGUS

#define IPPROTO_ARGUS 13
Argus

macroIPPROTO_EMCON

#define IPPROTO_EMCON 14
EMCON

macroIPPROTO_XNET

#define IPPROTO_XNET 15
Cross Net Debugger

macroIPPROTO_CHAOS

#define IPPROTO_CHAOS 16
Chaos

macroIPPROTO_UDP

#define IPPROTO_UDP 17
user datagram protocol

macroIPPROTO_MUX

#define IPPROTO_MUX 18
Multiplexing

macroIPPROTO_MEAS

#define IPPROTO_MEAS 19
DCN Measurement Subsystems

macroIPPROTO_HMP

#define IPPROTO_HMP 20
Host Monitoring

macroIPPROTO_PRM

#define IPPROTO_PRM 21
Packet Radio Measurement

macroIPPROTO_IDP

#define IPPROTO_IDP 22
xns idp

macroIPPROTO_TRUNK1

#define IPPROTO_TRUNK1 23
Trunk-1

macroIPPROTO_TRUNK2

#define IPPROTO_TRUNK2 24
Trunk-2

macroIPPROTO_LEAF1

#define IPPROTO_LEAF1 25
Leaf-1

macroIPPROTO_LEAF2

#define IPPROTO_LEAF2 26
Leaf-2

macroIPPROTO_RDP

#define IPPROTO_RDP 27
Reliable Data

macroIPPROTO_IRTP

#define IPPROTO_IRTP 28
Reliable Transaction

macroIPPROTO_TP

#define IPPROTO_TP 29
tp-4 w/ class negotiation

macroIPPROTO_BLT

#define IPPROTO_BLT 30
Bulk Data Transfer

macroIPPROTO_NSP

#define IPPROTO_NSP 31
Network Services

macroIPPROTO_INP

#define IPPROTO_INP 32
Merit Internodal

macroIPPROTO_SEP

#define IPPROTO_SEP 33
Sequential Exchange

macroIPPROTO_3PC

#define IPPROTO_3PC 34
Third Party Connect

macroIPPROTO_IDPR

#define IPPROTO_IDPR 35
InterDomain Policy Routing

macroIPPROTO_XTP

#define IPPROTO_XTP 36
XTP

macroIPPROTO_DDP

#define IPPROTO_DDP 37
Datagram Delivery

macroIPPROTO_CMTP

#define IPPROTO_CMTP 38
Control Message Transport

macroIPPROTO_TPXX

#define IPPROTO_TPXX 39
TP++ Transport

macroIPPROTO_IL

#define IPPROTO_IL 40
IL transport protocol

macroIPPROTO_IPV6

#define IPPROTO_IPV6 41
IP6 header

macroIPPROTO_SDRP

#define IPPROTO_SDRP 42
Source Demand Routing

macroIPPROTO_ROUTING

#define IPPROTO_ROUTING 43
IP6 routing header

macroIPPROTO_FRAGMENT

#define IPPROTO_FRAGMENT 44
IP6 fragmentation header

macroIPPROTO_IDRP

#define IPPROTO_IDRP 45
InterDomain Routing

macroIPPROTO_RSVP

#define IPPROTO_RSVP 46
resource reservation

macroIPPROTO_GRE

#define IPPROTO_GRE 47
General Routing Encap.

macroIPPROTO_MHRP

#define IPPROTO_MHRP 48
Mobile Host Routing

macroIPPROTO_BHA

#define IPPROTO_BHA 49
BHA

macroIPPROTO_ESP

#define IPPROTO_ESP 50
IP6 Encap Sec. Payload

macroIPPROTO_AH

#define IPPROTO_AH 51
IP6 Auth Header

macroIPPROTO_INLSP

#define IPPROTO_INLSP 52
Integ. Net Layer Security

macroIPPROTO_SWIPE

#define IPPROTO_SWIPE 53
IP with encryption

macroIPPROTO_NHRP

#define IPPROTO_NHRP 54
Next Hop Resolution

macroIPPROTO_ICMPV6

55-57: Unassigned
#define IPPROTO_ICMPV6 58
ICMP6

macroIPPROTO_NONE

#define IPPROTO_NONE 59
IP6 no next header

macroIPPROTO_DSTOPTS

#define IPPROTO_DSTOPTS 60
IP6 destination option

macroIPPROTO_AHIP

#define IPPROTO_AHIP 61
any host internal protocol

macroIPPROTO_CFTP

#define IPPROTO_CFTP 62
CFTP

macroIPPROTO_HELLO

#define IPPROTO_HELLO 63
"hello" routing protocol

macroIPPROTO_SATEXPAK

#define IPPROTO_SATEXPAK 64
SATNET/Backroom EXPAK

macroIPPROTO_KRYPTOLAN

#define IPPROTO_KRYPTOLAN 65
Kryptolan

macroIPPROTO_RVD

#define IPPROTO_RVD 66
Remote Virtual Disk

macroIPPROTO_IPPC

#define IPPROTO_IPPC 67
Pluribus Packet Core

macroIPPROTO_ADFS

#define IPPROTO_ADFS 68
Any distributed FS

macroIPPROTO_SATMON

#define IPPROTO_SATMON 69
Satnet Monitoring

macroIPPROTO_VISA

#define IPPROTO_VISA 70
VISA Protocol

macroIPPROTO_IPCV

#define IPPROTO_IPCV 71
Packet Core Utility

macroIPPROTO_CPNX

#define IPPROTO_CPNX 72
Comp. Prot. Net. Executive

macroIPPROTO_CPHB

#define IPPROTO_CPHB 73
Comp. Prot. HeartBeat

macroIPPROTO_WSN

#define IPPROTO_WSN 74
Wang Span Network

macroIPPROTO_PVP

#define IPPROTO_PVP 75
Packet Video Protocol

macroIPPROTO_BRSATMON

#define IPPROTO_BRSATMON 76
BackRoom SATNET Monitoring

macroIPPROTO_ND

#define IPPROTO_ND 77
Sun net disk proto (temp.)

macroIPPROTO_WBMON

#define IPPROTO_WBMON 78
WIDEBAND Monitoring

macroIPPROTO_WBEXPAK

#define IPPROTO_WBEXPAK 79
WIDEBAND EXPAK

macroIPPROTO_EON

#define IPPROTO_EON 80
ISO cnlp

macroIPPROTO_VMTP

#define IPPROTO_VMTP 81
VMTP

macroIPPROTO_SVMTP

#define IPPROTO_SVMTP 82
Secure VMTP

macroIPPROTO_VINES

#define IPPROTO_VINES 83
Banyon VINES

macroIPPROTO_TTP

#define IPPROTO_TTP 84
TTP

macroIPPROTO_IGP

#define IPPROTO_IGP 85
NSFNET-IGP

macroIPPROTO_DGP

#define IPPROTO_DGP 86
dissimilar gateway prot.

macroIPPROTO_TCF

#define IPPROTO_TCF 87
TCF

macroIPPROTO_IGRP

#define IPPROTO_IGRP 88
Cisco/GXS IGRP

macroIPPROTO_OSPFIGP

#define IPPROTO_OSPFIGP 89
OSPFIGP

macroIPPROTO_SRPC

#define IPPROTO_SRPC 90
Strite RPC protocol

macroIPPROTO_LARP

#define IPPROTO_LARP 91
Locus Address Resoloution

macroIPPROTO_MTP

#define IPPROTO_MTP 92
Multicast Transport

macroIPPROTO_AX25

#define IPPROTO_AX25 93
AX.25 Frames

macroIPPROTO_IPEIP

#define IPPROTO_IPEIP 94
IP encapsulated in IP

macroIPPROTO_MICP

#define IPPROTO_MICP 95
Mobile Int.ing control

macroIPPROTO_SCCSP

#define IPPROTO_SCCSP 96
Semaphore Comm. security

macroIPPROTO_ETHERIP

#define IPPROTO_ETHERIP 97
Ethernet IP encapsulation

macroIPPROTO_ENCAP

#define IPPROTO_ENCAP 98
encapsulation header

macroIPPROTO_APES

#define IPPROTO_APES 99
any private encr. scheme

macroIPPROTO_GMTP

#define IPPROTO_GMTP 100
GMTP

macroIPPROTO_PIM

101-252: Partly Unassigned
#define IPPROTO_PIM 103
Protocol Independent Mcast

macroIPPROTO_IPCOMP

#define IPPROTO_IPCOMP 108
payload compression (IPComp)

macroIPPROTO_PGM

#define IPPROTO_PGM 113
PGM

macroIPPROTO_SCTP

#define IPPROTO_SCTP 132
SCTP

macroIPPROTO_DIVERT

253-254: Experimentation and testing; 255: Reserved (RFC3692) BSD Private, local use, namespace incursion
#define IPPROTO_DIVERT 254
divert pseudo-protocol

macroIPPROTO_RAW

#define IPPROTO_RAW 255
raw IP packet

macroIPPROTO_MAX

#define IPPROTO_MAX 256

macroIPPROTO_DONE

last return value of *_input(), meaning "all job for this pkt is done".
#define IPPROTO_DONE 257

macroIPPORT_RESERVED

Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root). (IP_PORTRANGE_LOW) Ports > IPPORT_USERRESERVED are reserved for servers, not necessarily privileged. (IP_PORTRANGE_DEFAULT)
#define IPPORT_RESERVED __DARWIN_IPPORT_RESERVED

macroIPPORT_USERRESERVED

#define IPPORT_USERRESERVED 5000

macroIPPORT_HIFIRSTAUTO

Default local port range to use by setting IP_PORTRANGE_HIGH
#define IPPORT_HIFIRSTAUTO 49152

macroIPPORT_HILASTAUTO

#define IPPORT_HILASTAUTO 65535

macroIPPORT_RESERVEDSTART

Scanning for a free reserved port return a value below IPPORT_RESERVED, but higher than IPPORT_RESERVEDSTART. Traditionally the start value was 512, but that conflicts with some well-known-services that firewalls may have a fit if we use.
#define IPPORT_RESERVEDSTART 600

structin_addr

Internet address (a structure for historical reasons)
size 4, align 4
in_addr_ts_addr

macroINADDR_ANY

Definitions of bits in internet address integers. On subnets, the decomposition of addresses to host and net parts is done according to subnet mask, not the masks here.
#define INADDR_ANY (u_int32_t)0x00000000

macroINADDR_BROADCAST

#define INADDR_BROADCAST (u_int32_t)0xffffffff
must be masked

macroIN_CLASSA

#define IN_CLASSA(i) (((u_int32_t)(i) & 0x80000000) == 0)

macroIN_CLASSA_NET

#define IN_CLASSA_NET 0xff000000

macroIN_CLASSA_NSHIFT

#define IN_CLASSA_NSHIFT 24

macroIN_CLASSA_HOST

#define IN_CLASSA_HOST 0x00ffffff

macroIN_CLASSA_MAX

#define IN_CLASSA_MAX 128

macroIN_CLASSB

#define IN_CLASSB(i) (((u_int32_t)(i) & 0xc0000000) == 0x80000000)

macroIN_CLASSB_NET

#define IN_CLASSB_NET 0xffff0000

macroIN_CLASSB_NSHIFT

#define IN_CLASSB_NSHIFT 16

macroIN_CLASSB_HOST

#define IN_CLASSB_HOST 0x0000ffff

macroIN_CLASSB_MAX

#define IN_CLASSB_MAX 65536

macroIN_CLASSC

#define IN_CLASSC(i) (((u_int32_t)(i) & 0xe0000000) == 0xc0000000)

macroIN_CLASSC_NET

#define IN_CLASSC_NET 0xffffff00

macroIN_CLASSC_NSHIFT

#define IN_CLASSC_NSHIFT 8

macroIN_CLASSC_HOST

#define IN_CLASSC_HOST 0x000000ff

macroIN_CLASSD

#define IN_CLASSD(i) (((u_int32_t)(i) & 0xf0000000) == 0xe0000000)

macroIN_CLASSD_NET

#define IN_CLASSD_NET 0xf0000000
These ones aren't really

macroIN_CLASSD_NSHIFT

#define IN_CLASSD_NSHIFT 28
net and host fields, but

macroIN_CLASSD_HOST

#define IN_CLASSD_HOST 0x0fffffff
routing needn't know.

macroIN_MULTICAST

#define IN_MULTICAST(i) IN_CLASSD(i)

macroIN_EXPERIMENTAL

#define IN_EXPERIMENTAL(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000)

macroIN_BADCLASS

#define IN_BADCLASS(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000)

macroINADDR_LOOPBACK

#define INADDR_LOOPBACK (u_int32_t)0x7f000001

macroINADDR_NONE

#define INADDR_NONE 0xffffffff
-1 return

macroINADDR_UNSPEC_GROUP

#define INADDR_UNSPEC_GROUP (u_int32_t)0xe0000000
224.0.0.0

macroINADDR_ALLHOSTS_GROUP

#define INADDR_ALLHOSTS_GROUP (u_int32_t)0xe0000001
224.0.0.1

macroINADDR_ALLRTRS_GROUP

#define INADDR_ALLRTRS_GROUP (u_int32_t)0xe0000002
224.0.0.2

macroINADDR_ALLRPTS_GROUP

#define INADDR_ALLRPTS_GROUP (u_int32_t)0xe0000016
224.0.0.22, IGMPv3

macroINADDR_CARP_GROUP

#define INADDR_CARP_GROUP (u_int32_t)0xe0000012
224.0.0.18

macroINADDR_PFSYNC_GROUP

#define INADDR_PFSYNC_GROUP (u_int32_t)0xe00000f0
224.0.0.240

macroINADDR_ALLMDNS_GROUP

#define INADDR_ALLMDNS_GROUP (u_int32_t)0xe00000fb
224.0.0.251

macroINADDR_MAX_LOCAL_GROUP

#define INADDR_MAX_LOCAL_GROUP (u_int32_t)0xe00000ff
224.0.0.255

macroIN_LINKLOCALNETNUM

#define IN_LINKLOCALNETNUM (u_int32_t)0xA9FE0000
169.254.0.0

macroIN_LINKLOCAL

#define IN_LINKLOCAL(i) (((u_int32_t)(i) & IN_CLASSB_NET) == IN_LINKLOCALNETNUM)

macroIN_LOOPBACK

#define IN_LOOPBACK(i) (((u_int32_t)(i) & 0xff000000) == 0x7f000000)

macroIN_ZERONET

#define IN_ZERONET(i) (((u_int32_t)(i) & 0xff000000) == 0)

macroIN_PRIVATE

#define IN_PRIVATE(i) ((((u_int32_t)(i) & 0xff000000) == 0x0a000000) ||
	                 (((u_int32_t)(i) & 0xfff00000) == 0xac100000) ||
	                 (((u_int32_t)(i) & 0xffff0000) == 0xc0a80000))

macroIN_LOCAL_GROUP

#define IN_LOCAL_GROUP(i) (((u_int32_t)(i) & 0xffffff00) == 0xe0000000)

macroIN_ANY_LOCAL

#define IN_ANY_LOCAL(i) (IN_LINKLOCAL(i) || IN_LOCAL_GROUP(i))

macroIN_LOOPBACKNET

#define IN_LOOPBACKNET 127
official!

structsockaddr_in

Socket address, internet style.
size 16, align 4
__uint8_tsin_len
sa_family_tsin_family
in_port_tsin_port
struct in_addrsin_addr
char[8]sin_zero

macroIN_ARE_ADDR_EQUAL

#define IN_ARE_ADDR_EQUAL(a, b) (bcmp(&(a)->s_addr, &(b)->s_addr,
	sizeof (struct in_addr)) == 0)

macroINET_ADDRSTRLEN

#define INET_ADDRSTRLEN 16

structip_opts

Structure used to describe IP options. Used to store options internally, to pass them to a process, or to restore options retrieved earlier. The ip_dst is used for the first-hop gateway when using a source route (this gets put into the header proper).
size 44, align 4
struct in_addrip_dstfirst hop, 0 w/o src rt
char[40]ip_optsactually variable in size

macroIP_OPTIONS

Options for use with [gs]etsockopt at the IP level. First word of comment is data type; bool is stored in int.
#define IP_OPTIONS 1
buf/ip_opts; set/get IP options

macroIP_HDRINCL

#define IP_HDRINCL 2
int; header is included with data

macroIP_TOS

#define IP_TOS 3
int; IP type of service and preced.

macroIP_TTL

#define IP_TTL 4
int; IP time to live

macroIP_RECVOPTS

#define IP_RECVOPTS 5
bool; receive all IP opts w/dgram

macroIP_RECVRETOPTS

#define IP_RECVRETOPTS 6
bool; receive IP opts for response

macroIP_RECVDSTADDR

#define IP_RECVDSTADDR 7
bool; receive IP dst addr w/dgram

macroIP_RETOPTS

#define IP_RETOPTS 8
ip_opts; set/get IP options

macroIP_MULTICAST_IF

#define IP_MULTICAST_IF 9
u_char; set/get IP multicast i/f

macroIP_MULTICAST_TTL

#define IP_MULTICAST_TTL 10
u_char; set/get IP multicast ttl

macroIP_MULTICAST_LOOP

#define IP_MULTICAST_LOOP 11
u_char; set/get IP multicast loopback

macroIP_ADD_MEMBERSHIP

#define IP_ADD_MEMBERSHIP 12
ip_mreq; add an IP group membership

macroIP_DROP_MEMBERSHIP

#define IP_DROP_MEMBERSHIP 13
ip_mreq; drop an IP group membership

macroIP_MULTICAST_VIF

#define IP_MULTICAST_VIF 14
set/get IP mcast virt. iface

macroIP_RSVP_ON

#define IP_RSVP_ON 15
enable RSVP in kernel

macroIP_RSVP_OFF

#define IP_RSVP_OFF 16
disable RSVP in kernel

macroIP_RSVP_VIF_ON

#define IP_RSVP_VIF_ON 17
set RSVP per-vif socket

macroIP_RSVP_VIF_OFF

#define IP_RSVP_VIF_OFF 18
unset RSVP per-vif socket

macroIP_PORTRANGE

#define IP_PORTRANGE 19
int; range to choose for unspec port

macroIP_RECVIF

#define IP_RECVIF 20
bool; receive reception if w/dgram

macroIP_IPSEC_POLICY

for IPSEC
#define IP_IPSEC_POLICY 21
int; set/get security policy

macroIP_FAITH

#define IP_FAITH 22
deprecated

macroIP_STRIPHDR

#define IP_STRIPHDR 23
bool: drop receive of raw IP header

macroIP_RECVTTL

#define IP_RECVTTL 24
bool; receive reception TTL w/dgram

macroIP_BOUND_IF

#define IP_BOUND_IF 25
int; set/get bound interface

macroIP_PKTINFO

#define IP_PKTINFO 26
get pktinfo on recv socket, set src on sent dgram

macroIP_RECVPKTINFO

#define IP_RECVPKTINFO IP_PKTINFO
receive pktinfo w/dgram

macroIP_RECVTOS

#define IP_RECVTOS 27
bool; receive IP TOS w/dgram

macroIP_DONTFRAG

#define IP_DONTFRAG 28
don't fragment packet

macroIP_FW_ADD

#define IP_FW_ADD 40
add a firewall rule to chain

macroIP_FW_DEL

#define IP_FW_DEL 41
delete a firewall rule from chain

macroIP_FW_FLUSH

#define IP_FW_FLUSH 42
flush firewall rule chain

macroIP_FW_ZERO

#define IP_FW_ZERO 43
clear single/all firewall counter(s)

macroIP_FW_GET

#define IP_FW_GET 44
get entire firewall rule chain

macroIP_FW_RESETLOG

#define IP_FW_RESETLOG 45
reset logging counters

macroIP_OLD_FW_ADD

These older firewall socket option codes are maintained for backward compatibility.
#define IP_OLD_FW_ADD 50
add a firewall rule to chain

macroIP_OLD_FW_DEL

#define IP_OLD_FW_DEL 51
delete a firewall rule from chain

macroIP_OLD_FW_FLUSH

#define IP_OLD_FW_FLUSH 52
flush firewall rule chain

macroIP_OLD_FW_ZERO

#define IP_OLD_FW_ZERO 53
clear single/all firewall counter(s)

macroIP_OLD_FW_GET

#define IP_OLD_FW_GET 54
get entire firewall rule chain

macroIP_NAT__XXX

#define IP_NAT__XXX 55
set/get NAT opts XXX Deprecated, do not use

macroIP_OLD_FW_RESETLOG

#define IP_OLD_FW_RESETLOG 56
reset logging counters

macroIP_DUMMYNET_CONFIGURE

#define IP_DUMMYNET_CONFIGURE 60
add/configure a dummynet pipe

macroIP_DUMMYNET_DEL

#define IP_DUMMYNET_DEL 61
delete a dummynet pipe from chain

macroIP_DUMMYNET_FLUSH

#define IP_DUMMYNET_FLUSH 62
flush dummynet

macroIP_DUMMYNET_GET

#define IP_DUMMYNET_GET 64
get entire dummynet pipes

macroIP_TRAFFIC_MGT_BACKGROUND

#define IP_TRAFFIC_MGT_BACKGROUND 65
int*; get background IO flags; set background IO

macroIP_MULTICAST_IFINDEX

#define IP_MULTICAST_IFINDEX 66
int*; set/get IP multicast i/f index

macroIP_ADD_SOURCE_MEMBERSHIP

IPv4 Source Filter Multicast API [RFC3678]
#define IP_ADD_SOURCE_MEMBERSHIP 70
join a source-specific group

macroIP_DROP_SOURCE_MEMBERSHIP

#define IP_DROP_SOURCE_MEMBERSHIP 71
drop a single source

macroIP_BLOCK_SOURCE

#define IP_BLOCK_SOURCE 72
block a source

macroIP_UNBLOCK_SOURCE

#define IP_UNBLOCK_SOURCE 73
unblock a source

macroIP_MSFILTER

The following option is private; do not use it from user applications.
#define IP_MSFILTER 74
set/get filter list

macroMCAST_JOIN_GROUP

Protocol Independent Multicast API [RFC3678]
#define MCAST_JOIN_GROUP 80
join an any-source group

macroMCAST_LEAVE_GROUP

#define MCAST_LEAVE_GROUP 81
leave all sources for group

macroMCAST_JOIN_SOURCE_GROUP

#define MCAST_JOIN_SOURCE_GROUP 82
join a source-specific group

macroMCAST_LEAVE_SOURCE_GROUP

#define MCAST_LEAVE_SOURCE_GROUP 83
leave a single source

macroMCAST_BLOCK_SOURCE

#define MCAST_BLOCK_SOURCE 84
block a source

macroMCAST_UNBLOCK_SOURCE

#define MCAST_UNBLOCK_SOURCE 85
unblock a source

macroIP_DEFAULT_MULTICAST_TTL

Defaults and limits for options
#define IP_DEFAULT_MULTICAST_TTL 1
normally limit m'casts to 1 hop

macroIP_DEFAULT_MULTICAST_LOOP

#define IP_DEFAULT_MULTICAST_LOOP 1
normally hear sends if a member

macroIP_MIN_MEMBERSHIPS

The imo_membership vector for each socket is now dynamically allocated at run-time, bounded by USHRT_MAX, and is reallocated when needed, sized according to a power-of-two increment.
#define IP_MIN_MEMBERSHIPS 31

macroIP_MAX_MEMBERSHIPS

#define IP_MAX_MEMBERSHIPS 4095

macroIP_MAX_GROUP_SRC_FILTER

Default resource limits for IPv4 multicast source filtering. These may be modified by sysctl.
#define IP_MAX_GROUP_SRC_FILTER 512
sources per group

macroIP_MAX_SOCK_SRC_FILTER

#define IP_MAX_SOCK_SRC_FILTER 128
sources per socket/group

macroIP_MAX_SOCK_MUTE_FILTER

#define IP_MAX_SOCK_MUTE_FILTER 128
XXX no longer used

structip_mreq

Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
size 8, align 4
struct in_addrimr_multiaddrIP multicast address of group
struct in_addrimr_interfacelocal IP address of interface

structip_mreqn

Modified argument structure for IP_MULTICAST_IF, obtained from Linux. This is used to specify an interface index for multicast sends, as the IPv4 legacy APIs do not support this (unless IP_SENDIF is available).
size 12, align 4
struct in_addrimr_multiaddrIP multicast address of group
struct in_addrimr_addresslocal IP address of interface
intimr_ifindexInterface index; cast to uint32_t

structip_mreq_source

Argument structure for IPv4 Multicast Source Filter APIs. [RFC3678]
size 12, align 4
struct in_addrimr_multiaddrIP multicast address of group
struct in_addrimr_sourceaddrIP address of source
struct in_addrimr_interfacelocal IP address of interface

structgroup_req

Argument structures for Protocol-Independent Multicast Source Filter APIs. [RFC3678]
size 132, align 4
uint32_tgr_interfaceinterface index
struct sockaddr_storagegr_groupgroup address

structgroup_source_req

size 260, align 4
uint32_tgsr_interfaceinterface index
struct sockaddr_storagegsr_groupgroup address
struct sockaddr_storagegsr_sourcesource address

struct__msfilterreq

The following structure is private; do not use it from user applications. It is used to communicate IP_MSFILTER/IPV6_MSFILTER information between the RFC 3678 libc functions and the kernel.
size 152, align 4
uint32_tmsfr_ifindexinterface index
uint32_tmsfr_fmodefilter mode for group
uint32_tmsfr_nsrcs# of sources in msfr_srcs
uint32_t__msfr_align
struct sockaddr_storagemsfr_groupgroup address
struct sockaddr_storage *msfr_srcs

functionsetipv4sourcefilter

__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3)
int setipv4sourcefilter(
	int,
	struct in_addr,
	struct in_addr,
	uint32_t,
	uint32_t,
	struct in_addr *
)
Advanced (Full-state) APIs [RFC3678] The RFC specifies uint_t for the 6th argument to [sg]etsourcefilter(). We use uint32_t here to be consistent.

functiongetipv4sourcefilter

__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3)
int getipv4sourcefilter(
	int,
	struct in_addr,
	struct in_addr,
	uint32_t *,
	uint32_t *,
	struct in_addr *
)

functionsetsourcefilter

__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3)
int setsourcefilter(
	int,
	uint32_t,
	struct sockaddr *,
	socklen_t,
	uint32_t,
	uint32_t,
	struct sockaddr_storage *
)

functiongetsourcefilter

__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3)
int getsourcefilter(
	int,
	uint32_t,
	struct sockaddr *,
	socklen_t,
	uint32_t *,
	uint32_t *,
	struct sockaddr_storage *
)

macroMCAST_UNDEFINED

Filter modes; also used to represent per-socket filter mode internally.
#define MCAST_UNDEFINED 0
fmode: not yet defined

macroMCAST_INCLUDE

#define MCAST_INCLUDE 1
fmode: include these source(s)

macroMCAST_EXCLUDE

#define MCAST_EXCLUDE 2
fmode: exclude these source(s)

macroIP_PORTRANGE_DEFAULT

Argument for IP_PORTRANGE: - which range to search when port is unspecified at bind() or connect()
#define IP_PORTRANGE_DEFAULT 0
default range

macroIP_PORTRANGE_HIGH

#define IP_PORTRANGE_HIGH 1
"high" - request firewall bypass

macroIP_PORTRANGE_LOW

#define IP_PORTRANGE_LOW 2
"low" - vouchsafe security

structin_pktinfo

IP_PKTINFO: Packet information (equivalent to RFC2292 sec 5 for IPv4) This structure is used for 1) Receiving ancilliary data about the datagram if IP_PKTINFO sockopt is set on the socket. In this case ipi_ifindex will contain the interface index the datagram was received on, ipi_addr is the IP address the datagram was received to. 2) Sending a datagram using a specific interface or IP source address. if ipi_ifindex is set to non-zero when in_pktinfo is passed as ancilliary data of type IP_PKTINFO, this will be used as the source interface to send the datagram from. If ipi_ifindex is null, ip_spec_dst will be used for the source address. Note: if IP_BOUND_IF is set on the socket, ipi_ifindex in the ancillary IP_PKTINFO option silently overrides the bound interface when it is specified during send time.
size 12, align 4
unsigned intipi_ifindexsend/recv interface index
struct in_addripi_spec_dstLocal address
struct in_addripi_addrIP Header dst address

macroIPPROTO_MAXID

Definitions for inet sysctl operations. Third level is protocol number. Fourth level is desired variable within that protocol.
#define IPPROTO_MAXID (IPPROTO_AH + 1)
don't list to IPPROTO_MAX

macroIPCTL_FORWARDING

Names for IP sysctl objects
#define IPCTL_FORWARDING 1
act as router

macroIPCTL_SENDREDIRECTS

#define IPCTL_SENDREDIRECTS 2
may send redirects when forwarding

macroIPCTL_DEFTTL

#define IPCTL_DEFTTL 3
default TTL

macroIPCTL_RTEXPIRE

#define IPCTL_RTEXPIRE 5
cloned route expiration time

macroIPCTL_RTMINEXPIRE

#define IPCTL_RTMINEXPIRE 6
min value for expiration time

macroIPCTL_RTMAXCACHE

#define IPCTL_RTMAXCACHE 7
trigger level for dynamic expire

macroIPCTL_SOURCEROUTE

#define IPCTL_SOURCEROUTE 8
may perform source routes

macroIPCTL_DIRECTEDBROADCAST

#define IPCTL_DIRECTEDBROADCAST 9
may re-broadcast received packets

macroIPCTL_INTRQMAXLEN

#define IPCTL_INTRQMAXLEN 10
max length of netisr queue

macroIPCTL_INTRQDROPS

#define IPCTL_INTRQDROPS 11
number of netisr q drops

macroIPCTL_STATS

#define IPCTL_STATS 12
ipstat structure

macroIPCTL_ACCEPTSOURCEROUTE

#define IPCTL_ACCEPTSOURCEROUTE 13
may accept source routed packets

macroIPCTL_FASTFORWARDING

#define IPCTL_FASTFORWARDING 14
use fast IP forwarding code

macroIPCTL_KEEPFAITH

#define IPCTL_KEEPFAITH 15
deprecated

macroIPCTL_GIF_TTL

#define IPCTL_GIF_TTL 16
default TTL for gif encap packet

macroIPCTL_MAXID

#define IPCTL_MAXID 17

functionbindresvport

int bindresvport(int, struct sockaddr_in *)
man page · November 22, 1987
bindresvport(3) — bind a socket to a privileged IP port

functionbindresvport_sa

int bindresvport_sa(int, struct sockaddr *)
man page · November 22, 1987
bindresvport_sa(3) — bind a socket to a privileged IP port