annotate win32/ws2tcpip.d @ 1:4a9dcbd9e54f

-files of 0.13 beta -fixes so that it now compiles with the current dmd version
author marton@basel.hu
date Tue, 05 Apr 2011 20:44:01 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
1 /***********************************************************************\
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
2 * ws2tcpip.d *
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
3 * *
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
4 * Windows API header module *
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
5 * *
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
6 * Translated from MinGW Windows headers *
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
7 * *
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
8 * Placed into public domain *
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
9 \***********************************************************************/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
10
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
11 module win32.ws2tcpip;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
12
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
13 import win32.w32api;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
14 //import win32.winbase;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
15 import win32.windef;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
16 //import win32.basetyps;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
17 import win32.winsock2;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
18
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
19 enum {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
20 IP_OPTIONS = 1,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
21
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
22 IP_HDRINCL = 2,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
23 IP_TOS = 3,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
24 IP_TTL = 4,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
25 IP_MULTICAST_IF = 9,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
26 IP_MULTICAST_TTL = 10,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
27 IP_MULTICAST_LOOP = 11,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
28 IP_ADD_MEMBERSHIP = 12,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
29 IP_DROP_MEMBERSHIP = 13,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
30 IP_DONTFRAGMENT = 14,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
31 IP_ADD_SOURCE_MEMBERSHIP = 15,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
32 IP_DROP_SOURCE_MEMBERSHIP = 16,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
33 IP_BLOCK_SOURCE = 17,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
34 IP_UNBLOCK_SOURCE = 18,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
35 IP_PKTINFO = 19
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
36 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
37
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
38 enum {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
39 IPV6_UNICAST_HOPS = 4,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
40 IPV6_MULTICAST_IF = 9,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
41 IPV6_MULTICAST_HOPS = 10,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
42 IPV6_MULTICAST_LOOP = 11,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
43 IPV6_ADD_MEMBERSHIP = 12,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
44 IPV6_DROP_MEMBERSHIP = 13,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
45 IPV6_JOIN_GROUP = IPV6_ADD_MEMBERSHIP,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
46 IPV6_LEAVE_GROUP = IPV6_DROP_MEMBERSHIP,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
47 IPV6_PKTINFO = 19
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
48 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
49
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
50 const IP_DEFAULT_MULTICAST_TTL = 1;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
51 const IP_DEFAULT_MULTICAST_LOOP = 1;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
52 const IP_MAX_MEMBERSHIPS = 20;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
53
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
54 const TCP_EXPEDITED_1122 = 2;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
55
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
56 const UDP_NOCHECKSUM = 1;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
57
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
58 enum {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
59 IFF_UP = 1,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
60 IFF_BROADCAST = 2,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
61 IFF_LOOPBACK = 4,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
62 IFF_POINTTOPOINT = 8,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
63 IFF_MULTICAST = 16
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
64 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
65
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
66 const SIO_GET_INTERFACE_LIST = _IOR!('t', 127, u_long);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
67
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
68 const INET_ADDRSTRLEN = 16;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
69 const INET6_ADDRSTRLEN = 46;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
70
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
71 const NI_MAXHOST = 1025;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
72 const NI_MAXSERV = 32;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
73
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
74 const NI_NOFQDN = 0x01;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
75 const NI_NUMERICHOST = 0x02;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
76 const NI_NAMEREQD = 0x04;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
77 const NI_NUMERICSERV = 0x08;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
78 const NI_DGRAM = 0x10;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
79
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
80 const AI_PASSIVE = 1;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
81 const AI_CANONNAME = 2;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
82 const AI_NUMERICHOST = 4;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
83
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
84 const EAI_AGAIN = WSATRY_AGAIN;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
85 const EAI_BADFLAGS = WSAEINVAL;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
86 const EAI_FAIL = WSANO_RECOVERY;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
87 const EAI_FAMILY = WSAEAFNOSUPPORT;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
88 const EAI_MEMORY = WSA_NOT_ENOUGH_MEMORY;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
89 const EAI_NODATA = WSANO_DATA;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
90 const EAI_NONAME = WSAHOST_NOT_FOUND;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
91 const EAI_SERVICE = WSATYPE_NOT_FOUND;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
92 const EAI_SOCKTYPE = WSAESOCKTNOSUPPORT;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
93
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
94 struct ip_mreq {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
95 IN_ADDR imr_multiaddr;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
96 IN_ADDR imr_interface;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
97 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
98
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
99 struct ip_mreq_source {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
100 IN_ADDR imr_multiaddr;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
101 IN_ADDR imr_sourceaddr;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
102 IN_ADDR imr_interface;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
103 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
104
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
105 struct ip_msfilter {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
106 IN_ADDR imsf_multiaddr;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
107 IN_ADDR imsf_interface;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
108 u_long imsf_fmode;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
109 u_long imsf_numsrc;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
110 IN_ADDR[1] imsf_slist;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
111 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
112
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
113 template IP_MSFILTER_SIZE(ULONG numsrc) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
114 const DWORD IP_MSFILTER_SIZE = ip_msfilter.sizeof - IN_ADDR.sizeof + numsrc * IN_ADDR.sizeof;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
115 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
116
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
117 struct IN_PKTINFO {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
118 IN_ADDR ipi_addr;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
119 UINT ipi_ifindex;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
120 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
121
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
122 struct IN6_ADDR {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
123 union {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
124 u_char[16] _S6_u8;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
125 u_short[8] _S6_u16;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
126 u_long[4] _S6_u32;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
127 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
128 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
129 alias IN6_ADDR* PIN6_ADDR, LPIN6_ADDR;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
130
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
131 struct SOCKADDR_IN6 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
132 short sin6_family;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
133 u_short sin6_port;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
134 u_long sin6_flowinfo;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
135 IN6_ADDR sin6_addr;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
136 u_long sin6_scope_id;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
137 };
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
138 alias SOCKADDR_IN6* PSOCKADDR_IN6, LPSOCKADDR_IN6;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
139
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
140 extern IN6_ADDR in6addr_any;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
141 extern IN6_ADDR in6addr_loopback;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
142
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
143 /+ TODO:
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
144 #define IN6_ARE_ADDR_EQUAL(a, b) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
145 (memcmp ((void*)(a), (void*)(b), sizeof (struct in6_addr)) == 0)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
146
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
147 #define IN6_IS_ADDR_UNSPECIFIED(_addr) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
148 ( (((const u_long *)(_addr))[0] == 0) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
149 && (((const u_long *)(_addr))[1] == 0) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
150 && (((const u_long *)(_addr))[2] == 0) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
151 && (((const u_long *)(_addr))[3] == 0))
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
152
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
153 #define IN6_IS_ADDR_LOOPBACK(_addr) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
154 ( (((const u_long *)(_addr))[0] == 0) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
155 && (((const u_long *)(_addr))[1] == 0) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
156 && (((const u_long *)(_addr))[2] == 0) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
157 && (((const u_long *)(_addr))[3] == 0x01000000))
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
158
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
159 #define IN6_IS_ADDR_MULTICAST(_addr) (((const u_char *) (_addr))[0] == 0xff)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
160
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
161 #define IN6_IS_ADDR_LINKLOCAL(_addr) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
162 ( (((const u_char *)(_addr))[0] == 0xfe) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
163 && ((((const u_char *)(_addr))[1] & 0xc0) == 0x80))
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
164
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
165 #define IN6_IS_ADDR_SITELOCAL(_addr) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
166 ( (((const u_char *)(_addr))[0] == 0xfe) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
167 && ((((const u_char *)(_addr))[1] & 0xc0) == 0xc0))
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
168
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
169 #define IN6_IS_ADDR_V4MAPPED(_addr) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
170 ( (((const u_long *)(_addr))[0] == 0) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
171 && (((const u_long *)(_addr))[1] == 0) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
172 && (((const u_long *)(_addr))[2] == 0xffff0000))
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
173
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
174 #define IN6_IS_ADDR_V4COMPAT(_addr) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
175 ( (((const u_long *)(_addr))[0] == 0) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
176 && (((const u_long *)(_addr))[1] == 0) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
177 && (((const u_long *)(_addr))[2] == 0) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
178 && (((const u_long *)(_addr))[3] != 0) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
179 && (((const u_long *)(_addr))[3] != 0x01000000))
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
180
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
181 #define IN6_IS_ADDR_MC_NODELOCAL(_addr) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
182 ( IN6_IS_ADDR_MULTICAST(_addr) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
183 && ((((const u_char *)(_addr))[1] & 0xf) == 0x1))
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
184
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
185 #define IN6_IS_ADDR_MC_LINKLOCAL(_addr) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
186 ( IN6_IS_ADDR_MULTICAST (_addr) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
187 && ((((const u_char *)(_addr))[1] & 0xf) == 0x2))
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
188
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
189 #define IN6_IS_ADDR_MC_SITELOCAL(_addr) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
190 ( IN6_IS_ADDR_MULTICAST(_addr) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
191 && ((((const u_char *)(_addr))[1] & 0xf) == 0x5))
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
192
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
193 #define IN6_IS_ADDR_MC_ORGLOCAL(_addr) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
194 ( IN6_IS_ADDR_MULTICAST(_addr) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
195 && ((((const u_char *)(_addr))[1] & 0xf) == 0x8))
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
196
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
197 #define IN6_IS_ADDR_MC_GLOBAL(_addr) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
198 ( IN6_IS_ADDR_MULTICAST(_addr) \
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
199 && ((((const u_char *)(_addr))[1] & 0xf) == 0xe))
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
200 +/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
201
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
202 alias int socklen_t;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
203
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
204 struct IPV6_MREG {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
205 IN6_ADDR ipv6mr_multiaddr;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
206 uint ipv6mr_interface;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
207 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
208
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
209 struct IN6_PKTINFO {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
210 IN6_ADDR ipi6_addr;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
211 UINT ipi6_ifindex;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
212 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
213
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
214 struct addrinfo {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
215 int ai_flags;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
216 int ai_family;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
217 int ai_socktype;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
218 int ai_protocol;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
219 size_t ai_addrlen;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
220 char* ai_canonname;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
221 SOCKADDR* ai_addr;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
222 addrinfo* ai_next;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
223 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
224
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
225 extern(Windows) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
226 static if (_WIN32_WINNT >= 0x0501) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
227 void freeaddrinfo(addrinfo*);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
228 int getaddrinfo (char*, char*, addrinfo*, addrinfo**);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
229 int getnameinfo(SOCKADDR*, socklen_t, char*, DWORD, char*, DWORD, int);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
230 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
231 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
232
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
233 /+ TODO
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
234 static __inline char*
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
235 gai_strerrorA(int ecode)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
236 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
237 static char message[1024+1];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
238 DWORD dwFlags = FORMAT_MESSAGE_FROM_SYSTEM
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
239 | FORMAT_MESSAGE_IGNORE_INSERTS
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
240 | FORMAT_MESSAGE_MAX_WIDTH_MASK;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
241 DWORD dwLanguageId = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
242 FormatMessageA(dwFlags, NULL, ecode, dwLanguageId, (LPSTR)message, 1024, NULL);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
243 return message;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
244 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
245 static __inline WCHAR*
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
246 gai_strerrorW(int ecode)
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
247 {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
248 static WCHAR message[1024+1];
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
249 DWORD dwFlags = FORMAT_MESSAGE_FROM_SYSTEM
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
250 | FORMAT_MESSAGE_IGNORE_INSERTS
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
251 | FORMAT_MESSAGE_MAX_WIDTH_MASK;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
252 DWORD dwLanguageId = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
253 FormatMessageW(dwFlags, NULL, ecode, dwLanguageId, (LPWSTR)message, 1024, NULL);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
254 return message;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
255 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
256 #ifdef UNICODE
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
257 #define gai_strerror gai_strerrorW
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
258 #else
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
259 #define gai_strerror gai_strerrorA
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
260 #endif
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
261 +/
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
262
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
263 extern(Windows) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
264 INT getnameinfo(SOCKADDR* pSockaddr, socklen_t SockaddrLength,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
265 PCHAR pNodeBuffer, DWORD NodeBufferSize, PCHAR pServiceBuffer,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
266 DWORD ServiceBufferSize, INT Flags);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
267
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
268 static if (_WIN32_WINNT >= 0x0502) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
269 INT GetNameInfoW(SOCKADDR* pSockaddr, socklen_t SockaddrLength,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
270 PWCHAR pNodeBuffer, DWORD NodeBufferSize, PWCHAR pServiceBuffer,
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
271 DWORD ServiceBufferSize, INT Flags);
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
272
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
273 alias getnameinfo GetNameInfoA;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
274
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
275 version(Unicode) {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
276 alias GetNameInfoW GetNameInfo;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
277 } else {
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
278 alias GetNameInfoA GetNameInfo;
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
279 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
280 }
4a9dcbd9e54f -files of 0.13 beta
marton@basel.hu
parents:
diff changeset
281 }