2 * D header file for POSIX.
4 * Copyright: Public Domain
5 * License: Public Domain
7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
9 module stdc.posix.netinet.in_;
11 private import stdc.posix.config;
12 public import stdc.inttypes : uint32_t, uint16_t, uint8_t;
13 public import stdc.posix.arpa.inet;
14 public import stdc.posix.sys.socket; // for sa_family_t
22 NOTE: The following must must be defined in stdc.posix.arpa.inet to break
23 a circular import: in_port_t, in_addr_t, struct in_addr, INET_ADDRSTRLEN.
28 sa_family_t // from stdc.posix.sys.socket
29 uint8_t // from stdc.inttypes
30 uint32_t // from stdc.inttypes
39 sa_family_t sin_family;
54 htonl() // from stdc.posix.arpa.inet
55 htons() // from stdc.posix.arpa.inet
56 ntohl() // from stdc.posix.arpa.inet
57 ntohs() // from stdc.posix.arpa.inet
62 private const __SOCK_SIZE__ = 16;
66 sa_family_t sin_family;
70 /* Pad to size of `struct sockaddr'. */
71 ubyte[__SOCK_SIZE__ - sa_family_t.sizeof -
72 in_port_t.sizeof - in_addr.sizeof] __pad;
83 const uint INADDR_ANY = 0x00000000;
84 const uint INADDR_BROADCAST = 0xffffffff;
86 else version( darwin )
88 private const __SOCK_SIZE__ = 16;
93 sa_family_t sin_family;
107 const uint INADDR_ANY = 0x00000000;
108 const uint INADDR_BROADCAST = 0xffffffff;
110 else version( freebsd )
112 private const __SOCK_SIZE__ = 16;
117 sa_family_t sin_family;
131 const uint INADDR_ANY = 0x00000000;
132 const uint INADDR_BROADCAST = 0xffffffff;
140 NOTE: The following must must be defined in stdc.posix.arpa.inet to break
141 a circular import: INET6_ADDRSTRLEN.
150 sa_family_t sin6_family;
152 uint32_t sin6_flowinfo;
154 uint32_t sin6_scope_id;
157 extern in6_addr in6addr_any;
158 extern in6_addr in6addr_loopback;
162 in6_addr ipv6mr_multiaddr;
163 uint ipv6mr_interface;
179 int IN6_IS_ADDR_UNSPECIFIED(in6_addr*)
180 int IN6_IS_ADDR_LOOPBACK(in6_addr*)
181 int IN6_IS_ADDR_MULTICAST(in6_addr*)
182 int IN6_IS_ADDR_LINKLOCAL(in6_addr*)
183 int IN6_IS_ADDR_SITELOCAL(in6_addr*)
184 int IN6_IS_ADDR_V4MAPPED(in6_addr*)
185 int IN6_IS_ADDR_V4COMPAT(in6_addr*)
186 int IN6_IS_ADDR_MC_NODELOCAL(in6_addr*)
187 int IN6_IS_ADDR_MC_LINKLOCAL(in6_addr*)
188 int IN6_IS_ADDR_MC_SITELOCAL(in6_addr*)
189 int IN6_IS_ADDR_MC_ORGLOCAL(in6_addr*)
190 int IN6_IS_ADDR_MC_GLOBAL(in6_addr*)
200 uint16_t[8] s6_addr16;
201 uint32_t[4] s6_addr32;
207 sa_family_t sin6_family;
209 uint32_t sin6_flowinfo;
211 uint32_t sin6_scope_id;
214 extern in6_addr in6addr_any;
215 extern in6_addr in6addr_loopback;
219 in6_addr ipv6mr_multiaddr;
220 uint ipv6mr_interface;
227 INET6_ADDRSTRLEN = 46,
229 IPV6_JOIN_GROUP = 20,
230 IPV6_LEAVE_GROUP = 21,
231 IPV6_MULTICAST_HOPS = 18,
232 IPV6_MULTICAST_IF = 17,
233 IPV6_MULTICAST_LOOP = 19,
234 IPV6_UNICAST_HOPS = 16,
239 extern (D) int IN6_IS_ADDR_UNSPECIFIED( in6_addr* addr )
241 return (cast(uint32_t*) addr)[0] == 0 &&
242 (cast(uint32_t*) addr)[1] == 0 &&
243 (cast(uint32_t*) addr)[2] == 0 &&
244 (cast(uint32_t*) addr)[3] == 0;
247 extern (D) int IN6_IS_ADDR_LOOPBACK( in6_addr* addr )
249 return (cast(uint32_t*) addr)[0] == 0 &&
250 (cast(uint32_t*) addr)[1] == 0 &&
251 (cast(uint32_t*) addr)[2] == 0 &&
252 (cast(uint32_t*) addr)[3] == htonl( 1 );
255 extern (D) int IN6_IS_ADDR_MULTICAST( in6_addr* addr )
257 return (cast(uint8_t*) addr)[0] == 0xff;
260 extern (D) int IN6_IS_ADDR_LINKLOCAL( in6_addr* addr )
262 return ((cast(uint32_t*) addr)[0] & htonl( 0xffc00000 )) == htonl( 0xfe800000 );
265 extern (D) int IN6_IS_ADDR_SITELOCAL( in6_addr* addr )
267 return ((cast(uint32_t*) addr)[0] & htonl( 0xffc00000 )) == htonl( 0xfec00000 );
270 extern (D) int IN6_IS_ADDR_V4MAPPED( in6_addr* addr )
272 return (cast(uint32_t*) addr)[0] == 0 &&
273 (cast(uint32_t*) addr)[1] == 0 &&
274 (cast(uint32_t*) addr)[2] == htonl( 0xffff );
277 extern (D) int IN6_IS_ADDR_V4COMPAT( in6_addr* addr )
279 return (cast(uint32_t*) addr)[0] == 0 &&
280 (cast(uint32_t*) addr)[1] == 0 &&
281 (cast(uint32_t*) addr)[2] == 0 &&
282 ntohl( (cast(uint32_t*) addr)[3] ) > 1;
285 extern (D) int IN6_IS_ADDR_MC_NODELOCAL( in6_addr* addr )
287 return IN6_IS_ADDR_MULTICAST( addr ) &&
288 ((cast(uint8_t*) addr)[1] & 0xf) == 0x1;
291 extern (D) int IN6_IS_ADDR_MC_LINKLOCAL( in6_addr* addr )
293 return IN6_IS_ADDR_MULTICAST( addr ) &&
294 ((cast(uint8_t*) addr)[1] & 0xf) == 0x2;
297 extern (D) int IN6_IS_ADDR_MC_SITELOCAL( in6_addr* addr )
299 return IN6_IS_ADDR_MULTICAST(addr) &&
300 ((cast(uint8_t*) addr)[1] & 0xf) == 0x5;
303 extern (D) int IN6_IS_ADDR_MC_ORGLOCAL( in6_addr* addr )
305 return IN6_IS_ADDR_MULTICAST( addr) &&
306 ((cast(uint8_t*) addr)[1] & 0xf) == 0x8;
309 extern (D) int IN6_IS_ADDR_MC_GLOBAL( in6_addr* addr )
311 return IN6_IS_ADDR_MULTICAST( addr ) &&
312 ((cast(uint8_t*) addr)[1] & 0xf) == 0xe;
326 const uint IPPROTO_RAW = 255;