The OpenD Programming Language

1 //Written in the D programming language
2 
3 /++
4     D header file for Darwin's extensions to POSIX's netinet/in.h.
5 
6     Copyright: Copyright 2017 -
7     License:   $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
8     Authors:   $(HTTP jmdavisprog.com, Jonathan M Davis)
9  +/
10 module core.sys.darwin.netinet.in_;
11 
12 import core.sys.darwin.sys.cdefs;
13 
14 public import core.sys.posix.netinet.in_;
15 
16 version (OSX)
17     version = Darwin;
18 else version (iOS)
19     version = Darwin;
20 else version (TVOS)
21     version = Darwin;
22 else version (WatchOS)
23     version = Darwin;
24 
25 version (Darwin):
26 extern(C) nothrow @nogc:
27 
28 enum IPPROTO_IP = 0;
29 static if (_DARWIN_C_SOURCE)
30     enum IPPROTO_HOPOPTS = 0;
31 enum IPPROTO_ICMP = 1;
32 static if (_DARWIN_C_SOURCE)
33 {
34     enum IPPROTO_IGMP = 2;
35     enum IPPROTO_GGP  = 3;
36     enum IPPROTO_IPV4 = 4;
37     enum IPPROTO_IPIP = IPPROTO_IPV4;
38 }
39 enum IPPROTO_TCP = 6;
40 static if (_DARWIN_C_SOURCE)
41 {
42     enum IPPROTO_ST     = 7;
43     enum IPPROTO_EGP    = 8;
44     enum IPPROTO_PIGP   = 9;
45     enum IPPROTO_RCCMON = 10;
46     enum IPPROTO_NVPII  = 11;
47     enum IPPROTO_PUP    = 12;
48     enum IPPROTO_ARGUS  = 13;
49     enum IPPROTO_EMCON  = 14;
50     enum IPPROTO_XNET   = 15;
51     enum IPPROTO_CHAOS  = 16;
52 }
53 enum IPPROTO_UDP = 17;
54 static if (_DARWIN_C_SOURCE)
55 {
56     enum IPPROTO_MUX    = 18;
57     enum IPPROTO_MEAS   = 19;
58     enum IPPROTO_HMP    = 20;
59     enum IPPROTO_PRM    = 21;
60     enum IPPROTO_IDP    = 22;
61     enum IPPROTO_TRUNK1 = 23;
62     enum IPPROTO_TRUNK2 = 24;
63     enum IPPROTO_LEAF1  = 25;
64     enum IPPROTO_LEAF2  = 26;
65     enum IPPROTO_RDP    = 27;
66     enum IPPROTO_IRTP   = 28;
67     enum IPPROTO_TP     = 29;
68     enum IPPROTO_BLT    = 30;
69     enum IPPROTO_NSP    = 31;
70     enum IPPROTO_INP    = 32;
71     enum IPPROTO_SEP    = 33;
72     enum IPPROTO_3PC    = 34;
73     enum IPPROTO_IDPR   = 35;
74     enum IPPROTO_XTP    = 36;
75     enum IPPROTO_DDP    = 37;
76     enum IPPROTO_CMTP   = 38;
77     enum IPPROTO_TPXX   = 39;
78     enum IPPROTO_IL     = 40;
79 }
80 enum IPPROTO_IPV6 = 41;
81 static if (_DARWIN_C_SOURCE)
82 {
83     enum IPPROTO_SDRP      = 42;
84     enum IPPROTO_ROUTING   = 43;
85     enum IPPROTO_FRAGMENT  = 44;
86     enum IPPROTO_IDRP      = 45;
87     enum IPPROTO_RSVP      = 46;
88     enum IPPROTO_GRE       = 47;
89     enum IPPROTO_MHRP      = 48;
90     enum IPPROTO_BHA       = 49;
91     enum IPPROTO_ESP       = 50;
92     enum IPPROTO_AH        = 51;
93     enum IPPROTO_INLSP     = 52;
94     enum IPPROTO_SWIPE     = 53;
95     enum IPPROTO_NHRP      = 54;
96     enum IPPROTO_ICMPV6    = 58;
97     enum IPPROTO_NONE      = 59;
98     enum IPPROTO_DSTOPTS   = 60;
99     enum IPPROTO_AHIP      = 61;
100     enum IPPROTO_CFTP      = 62;
101     enum IPPROTO_HELLO     = 63;
102     enum IPPROTO_SATEXPAK  = 64;
103     enum IPPROTO_KRYPTOLAN = 65;
104     enum IPPROTO_RVD       = 66;
105     enum IPPROTO_IPPC      = 67;
106     enum IPPROTO_ADFS      = 68;
107     enum IPPROTO_SATMON    = 69;
108     enum IPPROTO_VISA      = 70;
109     enum IPPROTO_IPCV      = 71;
110     enum IPPROTO_CPNX      = 72;
111     enum IPPROTO_CPHB      = 73;
112     enum IPPROTO_WSN       = 74;
113     enum IPPROTO_PVP       = 75;
114     enum IPPROTO_BRSATMON  = 76;
115     enum IPPROTO_ND        = 77;
116     enum IPPROTO_WBMON     = 78;
117     enum IPPROTO_WBEXPAK   = 79;
118     enum IPPROTO_EON       = 80;
119     enum IPPROTO_VMTP      = 81;
120     enum IPPROTO_SVMTP     = 82;
121     enum IPPROTO_VINES     = 83;
122     enum IPPROTO_TTP       = 84;
123     enum IPPROTO_IGP       = 85;
124     enum IPPROTO_DGP       = 86;
125     enum IPPROTO_TCF       = 87;
126     enum IPPROTO_IGRP      = 88;
127     enum IPPROTO_OSPFIGP   = 89;
128     enum IPPROTO_SRPC      = 90;
129     enum IPPROTO_LARP      = 91;
130     enum IPPROTO_MTP       = 92;
131     enum IPPROTO_AX25      = 93;
132     enum IPPROTO_IPEIP     = 94;
133     enum IPPROTO_MICP      = 95;
134     enum IPPROTO_SCCSP     = 96;
135     enum IPPROTO_ETHERIP   = 97;
136     enum IPPROTO_ENCAP     = 98;
137     enum IPPROTO_APES      = 99;
138     enum IPPROTO_GMTP      = 100;
139     enum IPPROTO_PIM       = 103;
140     enum IPPROTO_IPCOMP    = 108;
141     enum IPPROTO_PGM       = 113;
142     enum IPPROTO_SCTP      = 132;
143     enum IPPROTO_DIVERT    = 254;
144 }
145 enum IPPROTO_RAW = 255;
146 
147 static if (_DARWIN_C_SOURCE)
148 {
149     enum IPPROTO_MAX  = 256;
150     enum IPPROTO_DONE = 257;
151 }
152 
153 static if (_DARWIN_C_SOURCE)
154 {
155     enum IPPORT_RESERVED = 1024;
156     enum IPPORT_USERRESERVED = 5000;
157 
158     enum IPPORT_HIFIRSTAUTO = 49152;
159     enum IPPORT_HILASTAUTO  = 65535;
160 
161     enum IPPORT_RESERVEDSTART = 600;
162 }
163 
164 static if (_DARWIN_C_SOURCE)
165 {
166     extern(D) bool IN_CLASSA(in_addr_t i) pure @safe { return (i & 0x80000000) == 0; }
167     enum IN_CLASSA_NET    = 0xff000000;
168     enum IN_CLASSA_NSHIFT = 24;
169     enum IN_CLASSA_HOST   = 0x00ffffff;
170     enum IN_CLASSA_MAX    = 128;
171 
172     extern(D) bool IN_CLASSB(in_addr_t i) pure @safe { return (i & 0xc0000000) == 0x80000000; }
173     enum IN_CLASSB_NET    = 0xffff0000;
174     enum IN_CLASSB_NSHIFT = 16;
175     enum IN_CLASSB_HOST   = 0x0000ffff;
176     enum IN_CLASSB_MAX    = 65536;
177 
178     extern(D) bool IN_CLASSC(in_addr_t i) pure @safe { return (i & 0xe0000000) == 0xc0000000; }
179     enum IN_CLASSC_NET    = 0xffffff00;
180     enum IN_CLASSC_NSHIFT = 8;
181     enum IN_CLASSC_HOST   = 0x000000ff;
182 
183     extern(D) bool IN_CLASSD(in_addr_t i) pure @safe { return (i & 0xf0000000) == 0xe0000000; }
184     enum IN_CLASSD_NET    = 0xf0000000;
185     enum IN_CLASSD_NSHIFT = 28;
186     enum IN_CLASSD_HOST   = 0x0fffffff;
187     extern(D) bool IN_MULTICAST(in_addr_t i) pure @safe { return IN_CLASSD(i); }
188 
189     // The fact that these are identical looks suspicious (they're not quite
190     // identical on Linux). However, this _is_ how they're defined in FreeBSD
191     // and on OS X. So, while it _might_ be a bug, if it is, it's an upstream
192     // one, and we're compatible with it.
193     extern(D) bool IN_EXPERIMENTAL(in_addr_t i) pure @safe { return (i & 0xf0000000) == 0xf0000000; }
194     extern(D) bool IN_BADCLASS(in_addr_t i) pure @safe { return (i & 0xf0000000) == 0xf0000000; }
195 
196     enum INADDR_UNSPEC_GROUP    = 0xe0000000;
197     enum INADDR_ALLHOSTS_GROUP  = 0xe0000001;
198     enum INADDR_ALLRTRS_GROUP   = 0xe0000002;
199     enum INADDR_ALLRPTS_GROUP   = 0xe0000016;
200     enum INADDR_CARP_GROUP      = 0xe0000012;
201     enum INADDR_PFSYNC_GROUP    = 0xe00000f0;
202     enum INADDR_ALLMDNS_GROUP   = 0xe00000fb;
203     enum INADDR_MAX_LOCAL_GROUP = 0xe00000ff;
204 
205     enum IN_LINKLOCALNETNUM = 0xA9FE0000;
206     extern(D) bool IN_LINKLOCAL(in_addr_t i) pure @safe { return (i & IN_CLASSB_NET) == IN_LINKLOCALNETNUM; }
207     extern(D) bool IN_LOOPBACK(in_addr_t i) pure @safe { return (i & 0xff000000) == 0x7f000000; }
208     extern(D) bool IN_ZERONET(in_addr_t i) pure @safe { return (i & 0xff000000) == 0; }
209 
210     extern(D) bool IN_PRIVATE(in_addr_t i) pure @safe
211     {
212         return (i & 0xff000000) == 0x0a000000 ||
213                (i & 0xfff00000) == 0xac100000 ||
214                (i & 0xffff0000) == 0xc0a80000;
215     }
216 
217     extern(D) bool IN_LOCAL_GROUP(in_addr_t i) pure @safe { return (i & 0xffffff00) == 0xe0000000; }
218 
219     extern(D) bool IN_ANY_LOCAL(in_addr_t i) pure @safe { return IN_LINKLOCAL(i) || IN_LOCAL_GROUP(i); }
220 
221     enum IN_LOOPBACKNET = 127;
222 
223 
224     struct ip_opts
225     {
226         in_addr  ip_dst;
227         char[40] ip_opts = 0;
228     }
229 
230     enum IP_OPTIONS         = 1;
231     enum IP_HDRINCL         = 2;
232     enum IP_TOS             = 3;
233     enum IP_TTL             = 4;
234     enum IP_RECVOPTS        = 5;
235     enum IP_RECVRETOPTS     = 6;
236     enum IP_RECVDSTADDR     = 7;
237     enum IP_RETOPTS         = 8;
238     enum IP_MULTICAST_IF    = 9;
239     enum IP_MULTICAST_TTL   = 10;
240     enum IP_MULTICAST_LOOP  = 11;
241     enum IP_ADD_MEMBERSHIP  = 12;
242     enum IP_DROP_MEMBERSHIP = 13;
243     enum IP_MULTICAST_VIF   = 14;
244     enum IP_RSVP_ON         = 15;
245     enum IP_RSVP_OFF        = 16;
246     enum IP_RSVP_VIF_ON     = 17;
247     enum IP_RSVP_VIF_OFF    = 18;
248     enum IP_PORTRANGE       = 19;
249     enum IP_RECVIF          = 20;
250 
251     enum IP_IPSEC_POLICY = 21;
252     enum IP_STRIPHDR     = 23;
253     enum IP_RECVTTL      = 24;
254     enum IP_BOUND_IF     = 25;
255     enum IP_PKTINFO      = 26;
256     enum IP_RECVPKTINFO  = IP_PKTINFO;
257     enum IP_RECVTOS      = 27;
258 
259     enum IP_FW_ADD      = 40;
260     enum IP_FW_DEL      = 41;
261     enum IP_FW_FLUSH    = 42;
262     enum IP_FW_ZERO     = 43;
263     enum IP_FW_GET      = 44;
264     enum IP_FW_RESETLOG = 45;
265 
266     enum IP_OLD_FW_ADD      = 50;
267     enum IP_OLD_FW_DEL      = 51;
268     enum IP_OLD_FW_FLUSH    = 52;
269     enum IP_OLD_FW_ZERO     = 53;
270     enum IP_OLD_FW_GET      = 54;
271     enum IP_NAT__XXX        = 55;
272     enum IP_OLD_FW_RESETLOG = 56;
273 
274     enum IP_DUMMYNET_CONFIGURE = 60;
275     enum IP_DUMMYNET_DEL       = 61;
276     enum IP_DUMMYNET_FLUSH     = 62;
277     enum IP_DUMMYNET_GET       = 64;
278 
279     enum IP_TRAFFIC_MGT_BACKGROUND = 65;
280     enum IP_MULTICAST_IFINDEX      = 66;
281 
282     enum IP_ADD_SOURCE_MEMBERSHIP  = 70;
283     enum IP_DROP_SOURCE_MEMBERSHIP = 71;
284     enum IP_BLOCK_SOURCE           = 72;
285     enum IP_UNBLOCK_SOURCE         = 73;
286 
287     enum IP_MSFILTER = 74;
288 
289     enum MCAST_JOIN_GROUP         = 80;
290     enum MCAST_LEAVE_GROUP        = 81;
291     enum MCAST_JOIN_SOURCE_GROUP  = 82;
292     enum MCAST_LEAVE_SOURCE_GROUP = 83;
293     enum MCAST_BLOCK_SOURCE       = 84;
294     enum MCAST_UNBLOCK_SOURCE     = 85;
295 
296     enum IP_DEFAULT_MULTICAST_TTL  = 1;
297     enum IP_DEFAULT_MULTICAST_LOOP = 1;
298 
299     enum IP_MIN_MEMBERSHIPS = 31;
300     enum IP_MAX_MEMBERSHIPS = 4095;
301 
302     enum IP_MAX_GROUP_SRC_FILTER = 512;
303     enum IP_MAX_SOCK_SRC_FILTER  = 128;
304     enum IP_MAX_SOCK_MUTE_FILTER = 128;
305 
306     struct ip_mreq
307     {
308         in_addr imr_multiaddr;
309         in_addr imr_interface;
310     }
311 
312     struct ip_mreqn
313     {
314         in_addr imr_multiaddr;
315         in_addr imr_address;
316         int     imr_ifindex;
317     }
318 
319     struct ip_mreq_source
320     {
321         align(4):
322         in_addr imr_multiaddr;
323         in_addr imr_sourceaddr;
324         in_addr imr_interface;
325     }
326 
327     struct group_req
328     {
329         align(4):
330         uint             gr_interface;
331         sockaddr_storage gr_group;
332     }
333 
334     struct group_source_req
335     {
336         align(4):
337         uint             gsr_interface;
338         sockaddr_storage gsr_group;
339         sockaddr_storage gsr_source;
340     }
341 
342     int setipv4sourcefilter(int, in_addr, in_addr, uint, uint, in_addr*);
343     int getipv4sourcefilter(int, in_addr, in_addr, uint*, uint*, in_addr*);
344     int setsourcefilter(int, uint, sockaddr*, socklen_t, uint, uint, sockaddr_storage*);
345     int getsourcefilter(int, uint, sockaddr*, socklen_t, uint*, uint*, sockaddr_storage*);
346 
347     enum MCAST_UNDEFINED = 0;
348     enum MCAST_INCLUDE   = 1;
349     enum MCAST_EXCLUDE   = 2;
350 
351     enum IP_PORTRANGE_DEFAULT = 0;
352     enum IP_PORTRANGE_HIGH    = 1;
353     enum IP_PORTRANGE_LOW     = 2;
354 
355     struct in_pktinfo
356     {
357         uint     ipi_ifindex;
358         in_addr  ipi_spec_dst;
359         in_addr  ipi_addr;
360     }
361 
362     enum IPPROTO_MAXID = IPPROTO_AH + 1;
363 
364 
365     enum IPCTL_FORWARDING        = 1;
366     enum IPCTL_SENDREDIRECTS     = 2;
367     enum IPCTL_DEFTTL            = 3;
368     enum IPCTL_DEFMTU            = 4;
369     enum IPCTL_RTEXPIRE          = 5;
370     enum IPCTL_RTMINEXPIRE       = 6;
371     enum IPCTL_RTMAXCACHE        = 7;
372     enum IPCTL_SOURCEROUTE       = 8;
373     enum IPCTL_DIRECTEDBROADCAST = 9;
374     enum IPCTL_INTRQMAXLEN       = 10;
375     enum IPCTL_INTRQDROPS        = 11;
376     enum IPCTL_STATS             = 12;
377     enum IPCTL_ACCEPTSOURCEROUTE = 13;
378     enum IPCTL_FASTFORWARDING    = 14;
379     enum IPCTL_KEEPFAITH         = 15;
380     enum IPCTL_GIF_TTL           = 16;
381     enum IPCTL_MAXID             = 17;
382 
383     int bindresvport(int, sockaddr_in*);
384     int bindresvport_sa(int, sockaddr*);
385 }
386 
387 // =============================================================================
388 // What follows is from netinet6/in6.h, but since netinet6/in6.h specifically
389 // says that it should only be #included by #including netinet/in.h, it makes
390 // more sense to put them in here so that the way they're imported corresponds
391 // with the correct way of #including them in C/C++.
392 // =============================================================================
393 
394 static if (_DARWIN_C_SOURCE)
395 {
396     enum IPV6PORT_RESERVED    = 1024;
397     enum IPV6PORT_ANONMIN     = 49152;
398     enum IPV6PORT_ANONMAX     = 65535;
399     enum IPV6PORT_RESERVEDMIN = 600;
400     enum IPV6PORT_RESERVEDMAX = IPV6PORT_RESERVED - 1;
401 }
402 
403 
404 enum IN6ADDR_ANY_INIT = in6_addr.init;
405 enum IN6ADDR_LOOPBACK_INIT = in6_addr([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
406                                        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01]);
407 
408 static if (_DARWIN_C_SOURCE)
409 {
410     enum IN6ADDR_NODELOCAL_ALLNODES_INIT = in6_addr([0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
411                                                      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01]);
412     enum IN6ADDR_INTFACELOCAL_ALLNODES_INIT = in6_addr([0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
413                                                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01]);
414     enum IN6ADDR_LINKLOCAL_ALLNODES_INIT = in6_addr([0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
415                                                      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01]);
416     enum IN6ADDR_LINKLOCAL_ALLROUTERS_INIT = in6_addr([0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
417                                                        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02]);
418     enum IN6ADDR_LINKLOCAL_ALLV2ROUTERS_INIT = in6_addr([0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
419                                                          0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16]);
420     enum IN6ADDR_V4MAPPED_INIT = in6_addr([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
421                                            0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00]);
422 }
423 
424 __gshared const in6_addr in6addr_any;
425 __gshared const in6_addr in6addr_loopback;
426 static if (_DARWIN_C_SOURCE)
427 {
428     __gshared const in6_addr in6addr_nodelocal_allnodes;
429     __gshared const in6_addr in6addr_linklocal_allnodes;
430     __gshared const in6_addr in6addr_linklocal_allrouters;
431     __gshared const in6_addr in6addr_linklocal_allv2routers;
432 
433     extern(D) bool IN6_ARE_ADDR_EQUAL(in6_addr* a, in6_addr* b) pure @safe { return *a == *b; }
434 }
435 
436 extern(D) bool IN6_IS_ADDR_6TO4(in6_addr* x) pure @safe { return ntohs(x.s6_addr16[0]) == 0x2002; }
437 
438 enum __IPV6_ADDR_SCOPE_NODELOCAL    = 0x01;
439 enum __IPV6_ADDR_SCOPE_INTFACELOCAL = 0x01;
440 enum __IPV6_ADDR_SCOPE_LINKLOCAL    = 0x02;
441 enum __IPV6_ADDR_SCOPE_SITELOCAL    = 0x05;
442 enum __IPV6_ADDR_SCOPE_GLOBAL       = 0x0e;
443 
444 extern(D) bool IN6_IS_ADDR_UNIQUE_LOCAL(in6_addr* a) pure @safe
445 {
446     return a.s6_addr[0] == 0xfc || a.s6_addr[0] == 0xfd;
447 }
448 
449 static if (_DARWIN_C_SOURCE)
450     enum IPV6_SOCKOPT_RESERVED1 = 3;
451 enum IPV6_UNICAST_HOPS   = 4;
452 enum IPV6_MULTICAST_IF   = 9;
453 enum IPV6_MULTICAST_HOPS = 10;
454 enum IPV6_MULTICAST_LOOP = 11;
455 enum IPV6_JOIN_GROUP     = 12;
456 enum IPV6_LEAVE_GROUP    = 13;
457 
458 static if (_DARWIN_C_SOURCE)
459 {
460     enum IPV6_PORTRANGE    = 14;
461     enum ICMP6_FILTER      = 18;
462 
463     enum IPV6_CHECKSUM = 26;
464 }
465 enum IPV6_V6ONLY = 27;
466 static if (_DARWIN_C_SOURCE)
467 {
468     enum IPV6_BINDV6ONLY = IPV6_V6ONLY;
469 
470     enum IPV6_IPSEC_POLICY = 28;
471 
472     enum IPV6_FW_ADD   = 30;
473     enum IPV6_FW_DEL   = 31;
474     enum IPV6_FW_FLUSH = 32;
475     enum IPV6_FW_ZERO  = 33;
476     enum IPV6_FW_GET   = 34;
477 
478     enum IPV6_RECVTCLASS = 35;
479     enum IPV6_TCLASS     = 36;
480 
481     enum IPV6_RTHDRDSTOPTS = 57;
482 
483     enum IPV6_RECVPKTINFO = 61;
484 
485     enum IPV6_RECVHOPLIMIT = 37;
486     enum IPV6_RECVRTHDR    = 38;
487     enum IPV6_RECVHOPOPTS  = 39;
488     enum IPV6_RECVDSTOPTS  = 40;
489 
490     enum IPV6_USE_MIN_MTU  = 42;
491     enum IPV6_RECVPATHMTU  = 43;
492 
493     enum IPV6_PATHMTU = 44;
494 
495     enum IPV6_PKTINFO  = 46;
496     enum IPV6_HOPLIMIT = 47;
497     enum IPV6_NEXTHOP  = 48;
498     enum IPV6_HOPOPTS  = 49;
499     enum IPV6_DSTOPTS  = 50;
500     enum IPV6_RTHDR    = 51;
501 
502     enum IPV6_AUTOFLOWLABEL = 59;
503 
504     enum IPV6_DONTFRAG = 62;
505 
506     enum IPV6_PREFER_TEMPADDR = 63;
507 
508     enum IPV6_BOUND_IF = 125;
509 
510     enum IPV6_RTHDR_LOOSE  = 0;
511     enum IPV6_RTHDR_STRICT = 1;
512     enum IPV6_RTHDR_TYPE_0 = 0;
513 
514     enum IPV6_DEFAULT_MULTICAST_HOPS = 1;
515     enum IPV6_DEFAULT_MULTICAST_LOOP = 1;
516 
517     enum IPV6_MIN_MEMBERSHIPS = 31;
518     enum IPV6_MAX_MEMBERSHIPS = 4095;
519 
520     enum IPV6_MAX_GROUP_SRC_FILTER = 512;
521     enum IPV6_MAX_SOCK_SRC_FILTER  = 128;
522 
523     struct in6_pktinfo
524     {
525         in6_addr ipi6_addr;
526         uint     ipi6_ifindex;
527     }
528 
529     struct ip6_mtuinfo
530     {
531         sockaddr_in6 ip6m_addr;
532         uint         ip6m_mtu;
533     }
534 
535     enum IPV6_PORTRANGE_DEFAULT = 0;
536     enum IPV6_PORTRANGE_HIGH    = 1;
537     enum IPV6_PORTRANGE_LOW     = 2;
538 
539     enum IPV6PROTO_MAXID = IPPROTO_PIM + 1;
540 
541     enum IPV6CTL_FORWARDING         = 1;
542     enum IPV6CTL_SENDREDIRECTS      = 2;
543     enum IPV6CTL_DEFHLIM            = 3;
544     enum IPV6CTL_DEFMTU             = 4;
545     enum IPV6CTL_FORWSRCRT          = 5;
546     enum IPV6CTL_STATS              = 6;
547     enum IPV6CTL_MRTSTATS           = 7;
548     enum IPV6CTL_MRTPROTO           = 8;
549     enum IPV6CTL_MAXFRAGPACKETS     = 9;
550     enum IPV6CTL_SOURCECHECK        = 10;
551     enum IPV6CTL_SOURCECHECK_LOGINT = 11;
552     enum IPV6CTL_ACCEPT_RTADV       = 12;
553 
554     enum IPV6CTL_LOG_INTERVAL   = 14;
555     enum IPV6CTL_HDRNESTLIMIT   = 15;
556     enum IPV6CTL_DAD_COUNT      = 16;
557     enum IPV6CTL_AUTO_FLOWLABEL = 17;
558     enum IPV6CTL_DEFMCASTHLIM   = 18;
559     enum IPV6CTL_GIF_HLIM       = 19;
560     enum IPV6CTL_KAME_VERSION   = 20;
561     enum IPV6CTL_USE_DEPRECATED = 21;
562     enum IPV6CTL_RR_PRUNE       = 22;
563     enum IPV6CTL_V6ONLY         = 24;
564     enum IPV6CTL_RTEXPIRE       = 25;
565     enum IPV6CTL_RTMINEXPIRE    = 26;
566     enum IPV6CTL_RTMAXCACHE     = 27;
567 
568     enum IPV6CTL_USETEMPADDR     = 32;
569     enum IPV6CTL_TEMPPLTIME      = 33;
570     enum IPV6CTL_TEMPVLTIME      = 34;
571     enum IPV6CTL_AUTO_LINKLOCAL  = 35;
572     enum IPV6CTL_RIP6STATS       = 36;
573     enum IPV6CTL_PREFER_TEMPADDR = 37;
574     enum IPV6CTL_ADDRCTLPOLICY   = 38;
575     enum IPV6CTL_USE_DEFAULTZONE = 39;
576 
577     enum IPV6CTL_MAXFRAGS   = 41;
578     enum IPV6CTL_MCAST_PMTU = 44;
579 
580     enum IPV6CTL_NEIGHBORGCTHRESH      = 46;
581     enum IPV6CTL_MAXIFPREFIXES         = 47;
582     enum IPV6CTL_MAXIFDEFROUTERS       = 48;
583     enum IPV6CTL_MAXDYNROUTES          = 49;
584     enum ICMPV6CTL_ND6_ONLINKNSRFC4861 = 50;
585 
586     enum IPV6CTL_MAXID = 51;
587 
588     size_t inet6_rthdr_space(int, int) @trusted;
589     cmsghdr* inet6_rthdr_init(void*, int);
590     int inet6_rthdr_add(cmsghdr*, const in6_addr*, uint);
591     int inet6_rthdr_lasthop(cmsghdr*, uint);
592     int inet6_rthdr_segments(const cmsghdr*);
593     in6_addr* inet6_rthdr_getaddr(cmsghdr*, int);
594     int inet6_rthdr_getflags(const cmsghdr*, int);
595 
596     int inet6_opt_init(void*, socklen_t);
597     int inet6_opt_append(void*, socklen_t, int, ubyte, socklen_t, ubyte, void**);
598     int inet6_opt_finish(void*, socklen_t, int);
599     int inet6_opt_set_val(void*, int, void*, socklen_t);
600 
601     int inet6_opt_next(void*, socklen_t, int, ubyte*, socklen_t*, void**);
602     int inet6_opt_find(void*, socklen_t, int, ubyte, socklen_t*, void**);
603     int inet6_opt_get_val(void*, int, void*, socklen_t);
604     socklen_t inet6_rth_space(int, int) @trusted;
605     void* inet6_rth_init(void*, socklen_t, int, int);
606     int inet6_rth_add(void*, const in6_addr*);
607     int inet6_rth_reverse(const void*, void*);
608     int inet6_rth_segments(const void*);
609     in6_addr* inet6_rth_getaddr(const void*, int);
610     void addrsel_policy_init();
611 }