39#include <sys/_types.h>
40#include <machine/endian.h>
48#define INADDR_ANY ((in_addr_t)0x00000000)
49#define INADDR_BROADCAST ((in_addr_t)0xffffffff)
51#ifndef _UINT8_T_DECLARED
53#define _UINT8_T_DECLARED
56#ifndef _UINT16_T_DECLARED
58#define _UINT16_T_DECLARED
61#ifndef _UINT32_T_DECLARED
63#define _UINT32_T_DECLARED
66#ifndef _IN_ADDR_T_DECLARED
68#define _IN_ADDR_T_DECLARED
71#ifndef _IN_PORT_T_DECLARED
73#define _IN_PORT_T_DECLARED
76#ifndef _SA_FAMILY_T_DECLARED
78#define _SA_FAMILY_T_DECLARED
82#ifndef _STRUCT_IN_ADDR_DECLARED
86#define _STRUCT_IN_ADDR_DECLARED
89#ifndef _SOCKLEN_T_DECLARED
91#define _SOCKLEN_T_DECLARED
94#include <sys/_sockaddr_storage.h>
105#if !defined(_KERNEL) && __POSIX_VISIBLE >= 200112
107#ifndef _BYTEORDER_PROTOTYPED
108#define _BYTEORDER_PROTOTYPED
117#ifndef _BYTEORDER_FUNC_DEFINED
118#define _BYTEORDER_FUNC_DEFINED
119#define htonl(x) __htonl(x)
120#define htons(x) __htons(x)
121#define ntohl(x) __ntohl(x)
122#define ntohs(x) __ntohs(x)
127#if __POSIX_VISIBLE >= 200112
128#define IPPROTO_IPV6 41
129#define IPPROTO_RAW 255
130#define INET_ADDRSTRLEN 16
142#define IPPROTO_HOPOPTS 0
143#define IPPROTO_IGMP 2
145#define IPPROTO_IPV4 4
146#define IPPROTO_IPIP IPPROTO_IPV4
149#define IPPROTO_PIGP 9
150#define IPPROTO_RCCMON 10
151#define IPPROTO_NVPII 11
152#define IPPROTO_PUP 12
153#define IPPROTO_ARGUS 13
154#define IPPROTO_EMCON 14
155#define IPPROTO_XNET 15
156#define IPPROTO_CHAOS 16
157#define IPPROTO_MUX 18
158#define IPPROTO_MEAS 19
159#define IPPROTO_HMP 20
160#define IPPROTO_PRM 21
161#define IPPROTO_IDP 22
162#define IPPROTO_TRUNK1 23
163#define IPPROTO_TRUNK2 24
164#define IPPROTO_LEAF1 25
165#define IPPROTO_LEAF2 26
166#define IPPROTO_RDP 27
167#define IPPROTO_IRTP 28
169#define IPPROTO_BLT 30
170#define IPPROTO_NSP 31
171#define IPPROTO_INP 32
172#define IPPROTO_DCCP 33
173#define IPPROTO_3PC 34
174#define IPPROTO_IDPR 35
175#define IPPROTO_XTP 36
176#define IPPROTO_DDP 37
177#define IPPROTO_CMTP 38
178#define IPPROTO_TPXX 39
180#define IPPROTO_SDRP 42
181#define IPPROTO_ROUTING 43
182#define IPPROTO_FRAGMENT 44
183#define IPPROTO_IDRP 45
184#define IPPROTO_RSVP 46
185#define IPPROTO_GRE 47
186#define IPPROTO_MHRP 48
187#define IPPROTO_BHA 49
188#define IPPROTO_ESP 50
190#define IPPROTO_INLSP 52
191#define IPPROTO_SWIPE 53
192#define IPPROTO_NHRP 54
193#define IPPROTO_MOBILE 55
194#define IPPROTO_TLSP 56
195#define IPPROTO_SKIP 57
196#define IPPROTO_ICMPV6 58
197#define IPPROTO_NONE 59
198#define IPPROTO_DSTOPTS 60
199#define IPPROTO_AHIP 61
200#define IPPROTO_CFTP 62
201#define IPPROTO_HELLO 63
202#define IPPROTO_SATEXPAK 64
203#define IPPROTO_KRYPTOLAN 65
204#define IPPROTO_RVD 66
205#define IPPROTO_IPPC 67
206#define IPPROTO_ADFS 68
207#define IPPROTO_SATMON 69
208#define IPPROTO_VISA 70
209#define IPPROTO_IPCV 71
210#define IPPROTO_CPNX 72
211#define IPPROTO_CPHB 73
212#define IPPROTO_WSN 74
213#define IPPROTO_PVP 75
214#define IPPROTO_BRSATMON 76
216#define IPPROTO_WBMON 78
217#define IPPROTO_WBEXPAK 79
218#define IPPROTO_EON 80
219#define IPPROTO_VMTP 81
220#define IPPROTO_SVMTP 82
221#define IPPROTO_VINES 83
222#define IPPROTO_TTP 84
223#define IPPROTO_IGP 85
224#define IPPROTO_DGP 86
225#define IPPROTO_TCF 87
226#define IPPROTO_IGRP 88
227#define IPPROTO_OSPFIGP 89
228#define IPPROTO_SRPC 90
229#define IPPROTO_LARP 91
230#define IPPROTO_MTP 92
231#define IPPROTO_AX25 93
232#define IPPROTO_IPEIP 94
233#define IPPROTO_MICP 95
234#define IPPROTO_SCCSP 96
235#define IPPROTO_ETHERIP 97
236#define IPPROTO_ENCAP 98
237#define IPPROTO_APES 99
238#define IPPROTO_GMTP 100
239#define IPPROTO_IPCOMP 108
240#define IPPROTO_SCTP 132
241#define IPPROTO_MH 135
242#define IPPROTO_UDPLITE 136
243#define IPPROTO_HIP 139
244#define IPPROTO_SHIM6 140
246#define IPPROTO_PIM 103
247#define IPPROTO_CARP 112
248#define IPPROTO_PGM 113
249#define IPPROTO_MPLS 137
250#define IPPROTO_PFSYNC 240
251#define IPPROTO_RESERVED_253 253
252#define IPPROTO_RESERVED_254 254
255#define IPPROTO_OLD_DIVERT 254
256#define IPPROTO_MAX 256
259#define IPPROTO_DONE 257
262#define IPPROTO_DIVERT 258
263#define IPPROTO_SEND 259
269#define IPPROTO_SPACER 32767
320#define IPPORT_RESERVED 1024
325#define IPPORT_EPHEMERALFIRST 10000
326#define IPPORT_EPHEMERALLAST 65535
331#define IPPORT_HIFIRSTAUTO 49152
332#define IPPORT_HILASTAUTO 65535
340#define IPPORT_RESERVEDSTART 600
342#define IPPORT_MAX 65535
351#define IN_HISTORICAL_NETS
353#ifdef IN_HISTORICAL_NETS
354#define IN_CLASSA(i) (((in_addr_t)(i) & 0x80000000) == 0)
355#define IN_CLASSA_NET 0xff000000
356#define IN_CLASSA_NSHIFT 24
357#define IN_CLASSA_HOST 0x00ffffff
358#define IN_CLASSA_MAX 128
360#define IN_CLASSB(i) (((in_addr_t)(i) & 0xc0000000) == 0x80000000)
361#define IN_CLASSB_NET 0xffff0000
362#define IN_CLASSB_NSHIFT 16
363#define IN_CLASSB_HOST 0x0000ffff
364#define IN_CLASSB_MAX 65536
366#define IN_CLASSC(i) (((in_addr_t)(i) & 0xe0000000) == 0xc0000000)
367#define IN_CLASSC_NET 0xffffff00
368#define IN_CLASSC_NSHIFT 8
369#define IN_CLASSC_HOST 0x000000ff
372#define IN_NETMASK_DEFAULT 0xffffff00
374#define IN_MULTICAST(i) (((in_addr_t)(i) & 0xf0000000) == 0xe0000000)
375#ifdef IN_HISTORICAL_NETS
376#define IN_CLASSD(i) IN_MULTICAST(i)
377#define IN_CLASSD_NET 0xf0000000
378#define IN_CLASSD_NSHIFT 28
379#define IN_CLASSD_HOST 0x0fffffff
382#define IN_EXPERIMENTAL(i) (((in_addr_t)(i) & 0xf0000000) == 0xf0000000)
383#define IN_BADCLASS(i) (((in_addr_t)(i) & 0xf0000000) == 0xf0000000)
385#define IN_LINKLOCAL(i) (((in_addr_t)(i) & 0xffff0000) == 0xa9fe0000)
386#define IN_LOOPBACK(i) (((in_addr_t)(i) & 0xff000000) == 0x7f000000)
387#define IN_ZERONET(i) (((in_addr_t)(i) & 0xff000000) == 0)
389#define IN_PRIVATE(i) ((((in_addr_t)(i) & 0xff000000) == 0x0a000000) || \
390 (((in_addr_t)(i) & 0xfff00000) == 0xac100000) || \
391 (((in_addr_t)(i) & 0xffff0000) == 0xc0a80000))
393#define IN_LOCAL_GROUP(i) (((in_addr_t)(i) & 0xffffff00) == 0xe0000000)
395#define IN_ANY_LOCAL(i) (IN_LINKLOCAL(i) || IN_LOCAL_GROUP(i))
397#define INADDR_LOOPBACK ((in_addr_t)0x7f000001)
399#define INADDR_NONE ((in_addr_t)0xffffffff)
402#define INADDR_UNSPEC_GROUP ((in_addr_t)0xe0000000)
403#define INADDR_ALLHOSTS_GROUP ((in_addr_t)0xe0000001)
404#define INADDR_ALLRTRS_GROUP ((in_addr_t)0xe0000002)
405#define INADDR_ALLRPTS_GROUP ((in_addr_t)0xe0000016)
406#define INADDR_CARP_GROUP ((in_addr_t)0xe0000012)
407#define INADDR_PFSYNC_GROUP ((in_addr_t)0xe00000f0)
408#define INADDR_ALLMDNS_GROUP ((in_addr_t)0xe00000fb)
409#define INADDR_MAX_LOCAL_GROUP ((in_addr_t)0xe00000ff)
411#ifdef IN_HISTORICAL_NETS
412#define IN_LOOPBACKNET 127
415#define IN_RFC3021_MASK ((in_addr_t)0xfffffffe)
426#define IP_RECVRETOPTS 6
427#define IP_RECVDSTADDR 7
428#define IP_SENDSRCADDR IP_RECVDSTADDR
430#define IP_MULTICAST_IF 9
432#define IP_MULTICAST_TTL 10
433#define IP_MULTICAST_LOOP 11
434#define IP_ADD_MEMBERSHIP 12
435#define IP_DROP_MEMBERSHIP 13
436#define IP_MULTICAST_VIF 14
438#define IP_RSVP_OFF 16
439#define IP_RSVP_VIF_ON 17
440#define IP_RSVP_VIF_OFF 18
441#define IP_PORTRANGE 19
444#define IP_IPSEC_POLICY 21
446#define IP_ONESBCAST 23
448#define IP_BINDMULTI 25
449#define IP_RSS_LISTEN_BUCKET 26
450#define IP_ORIGDSTADDR 27
451#define IP_RECVORIGDSTADDR IP_ORIGDSTADDR
458#define IP_FW_TABLE_ADD 40
459#define IP_FW_TABLE_DEL 41
460#define IP_FW_TABLE_FLUSH 42
461#define IP_FW_TABLE_GETSIZE 43
462#define IP_FW_TABLE_LIST 44
465#define IP_DUMMYNET3 49
469#define IP_FW_FLUSH 52
472#define IP_FW_RESETLOG 55
474#define IP_FW_NAT_CFG 56
475#define IP_FW_NAT_DEL 57
476#define IP_FW_NAT_GET_CONFIG 58
477#define IP_FW_NAT_GET_LOG 59
479#define IP_DUMMYNET_CONFIGURE 60
480#define IP_DUMMYNET_DEL 61
481#define IP_DUMMYNET_FLUSH 62
482#define IP_DUMMYNET_GET 64
486#define IP_DONTFRAG 67
490#define IP_ADD_SOURCE_MEMBERSHIP 70
491#define IP_DROP_SOURCE_MEMBERSHIP 71
492#define IP_BLOCK_SOURCE 72
493#define IP_UNBLOCK_SOURCE 73
496#define IP_MSFILTER 74
499#define IP_VLAN_PCP 75
503#define MCAST_JOIN_GROUP 80
504#define MCAST_LEAVE_GROUP 81
505#define MCAST_JOIN_SOURCE_GROUP 82
506#define MCAST_LEAVE_SOURCE_GROUP 83
507#define MCAST_BLOCK_SOURCE 84
508#define MCAST_UNBLOCK_SOURCE 85
512#define IP_FLOWTYPE 91
513#define IP_RSSBUCKETID 92
514#define IP_RECVFLOWID 93
515#define IP_RECVRSSBUCKETID 94
520#define IP_DEFAULT_MULTICAST_TTL 1
521#define IP_DEFAULT_MULTICAST_LOOP 1
526#define IP_MAX_MEMBERSHIPS 4095
532#define IP_MAX_GROUP_SRC_FILTER 512
533#define IP_MAX_SOCK_SRC_FILTER 128
534#define IP_MAX_SOCK_MUTE_FILTER 128
558struct ip_mreq_source {
570 struct sockaddr_storage gr_group;
573struct group_source_req {
575 struct sockaddr_storage gsr_group;
576 struct sockaddr_storage gsr_source;
579#ifndef __MSFILTERREQ_DEFINED
580#define __MSFILTERREQ_DEFINED
586struct __msfilterreq {
590 struct sockaddr_storage msfr_group;
591 struct sockaddr_storage *msfr_srcs;
617#define MCAST_UNDEFINED 0
618#define MCAST_INCLUDE 1
619#define MCAST_EXCLUDE 2
625#define IP_PORTRANGE_DEFAULT 0
626#define IP_PORTRANGE_HIGH 1
627#define IP_PORTRANGE_LOW 2
632#define IPCTL_FORWARDING 1
633#define IPCTL_SENDREDIRECTS 2
634#define IPCTL_DEFTTL 3
636#define IPCTL_DEFMTU 4
641#define IPCTL_SOURCEROUTE 8
642#define IPCTL_DIRECTEDBROADCAST 9
643#define IPCTL_INTRQMAXLEN 10
644#define IPCTL_INTRQDROPS 11
645#define IPCTL_STATS 12
646#define IPCTL_ACCEPTSOURCEROUTE 13
647#define IPCTL_FASTFORWARDING 14
649#define IPCTL_GIF_TTL 16
650#define IPCTL_INTRDQMAXLEN 17
651#define IPCTL_INTRDQDROPS 18
657struct ifnet;
struct mbuf;
674#define in_hosteq(s, t) ((s).s_addr == (t).s_addr)
675#define in_nullhost(x) ((x).s_addr == INADDR_ANY)
676#define in_allhosts(x) ((x).s_addr == htonl(INADDR_ALLHOSTS_GROUP))
678#define satosin(sa) ((struct sockaddr_in *)(sa))
679#define sintosa(sin) ((struct sockaddr *)(sin))
680#define ifatoia(ifa) ((struct in_ifaddr *)(ifa))
684#if __POSIX_VISIBLE >= 200112
685#define __KAME_NETINET_IN_H_INCLUDED_
686#include <netinet6/in6.h>
687#undef __KAME_NETINET_IN_H_INCLUDED_
char * inet_ntop(int, const void *, char *, socklen_t)
struct in_ifaddr * in_findlocal(uint32_t, bool)
char * inet_ntoa_r(struct in_addr ina, char *buf)
int in_ifaddr_broadcast(struct in_addr, struct in_ifaddr *)
bool in_localip_fib(struct in_addr, uint16_t)
int inet_pton(int af, const char *, void *)
int in_ifhasaddr(struct ifnet *, struct in_addr)
int in_localaddr(struct in_addr)
int inet_aton(const char *, struct in_addr *)
int in_broadcast(struct in_addr, struct ifnet *)
int in_canforward(struct in_addr)
__sa_family_t sa_family_t
bool in_localip(struct in_addr)
void in_ifdetach(struct ifnet *)