Print this page
Split |
Close |
Expand all |
Collapse all |
--- old/src/windows/native/java/net/NetworkInterface.h
+++ new/src/windows/native/java/net/NetworkInterface.h
1 1 /*
2 2 * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation. Sun designates this
8 8 * particular file as subject to the "Classpath" exception as provided
9 9 * by Sun in the LICENSE file that accompanied this code.
10 10 *
11 11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 14 * version 2 for more details (a copy is included in the LICENSE file that
15 15 * accompanied this code).
16 16 *
17 17 * You should have received a copy of the GNU General Public License version
18 18 * 2 along with this work; if not, write to the Free Software Foundation,
19 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 20 *
21 21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 23 * have any questions.
24 24 */
25 25
26 26 #ifndef NETWORK_INTERFACE_H
27 27 #define NETWORK_INTERFACE_H
28 28
29 29 #include <iphlpapi.h>
30 30 #include "net_util.h"
31 31
32 32 /*
33 33 * Structures used when enumerating interfaces and addresses
34 34 */
35 35 typedef struct _netaddr {
36 36 SOCKETADDRESS addr; /* IPv4 or IPv6 address */
37 37 SOCKETADDRESS brdcast;
38 38 short mask;
39 39 struct _netaddr *next;
40 40 } netaddr;
41 41
42 42 typedef struct _netif {
43 43 char *name;
44 44 char *displayName;
45 45 DWORD dwIndex; /* Internal index */
46 46 DWORD ifType; /* Interface type */
47 47 int index; /* Friendly index */
48 48 struct _netif *next;
49 49
50 50 /* Following fields used on Windows XP when IPv6 is used only */
51 51 jboolean hasIpv6Address; /* true when following fields valid */
52 52 jboolean dNameIsUnicode; /* Display Name is Unicode */
53 53 int naddrs; /* Number of addrs */
↓ open down ↓ |
53 lines elided |
↑ open up ↑ |
54 54 DWORD ipv6Index;
55 55 struct _netaddr *addrs; /* addr list for interfaces */
56 56 } netif;
57 57
58 58 extern void free_netif(netif *netifP);
59 59 extern void free_netaddr(netaddr *netaddrP);
60 60
61 61 /* various JNI ids */
62 62 extern jclass ni_class; /* NetworkInterface */
63 63
64 -extern jmethodID ni_ctor; /* NetworkInterface() */
64 +extern jmethodID ni_ctrID; /* NetworkInterface() */
65 65
66 66 extern jfieldID ni_indexID; /* NetworkInterface.index */
67 67 extern jfieldID ni_addrsID; /* NetworkInterface.addrs */
68 68 extern jfieldID ni_bindsID; /* NetworkInterface.bindings */
69 69 extern jfieldID ni_nameID; /* NetworkInterface.name */
70 70 extern jfieldID ni_displayNameID; /* NetworkInterface.displayName */
71 71 extern jfieldID ni_childsID; /* NetworkInterface.childs */
72 72
73 -extern jclass ni_iacls; /* InetAddress */
74 -extern jfieldID ni_iaAddr; /* InetAddress.address */
75 -
76 -extern jclass ni_ia4cls; /* Inet4Address */
77 -extern jmethodID ni_ia4Ctor; /* Inet4Address() */
78 -
79 -extern jclass ni_ia6cls; /* Inet6Address */
80 -extern jmethodID ni_ia6ctrID; /* Inet6Address() */
81 -extern jfieldID ni_ia6ipaddressID;
82 -extern jfieldID ni_ia6ipaddressID;
83 -
84 73 extern jclass ni_ibcls; /* InterfaceAddress */
85 74 extern jmethodID ni_ibctrID; /* InterfaceAddress() */
86 75 extern jfieldID ni_ibaddressID; /* InterfaceAddress.address */
87 76 extern jfieldID ni_ibbroadcastID; /* InterfaceAddress.broadcast */
88 77 extern jfieldID ni_ibmaskID; /* InterfaceAddress.maskLength */
89 78
90 79 int enumInterfaces_win(JNIEnv *env, netif **netifPP);
91 80
92 81 /* We have included iphlpapi.h which includes iptypes.h which has the definition
93 82 * for MAX_ADAPTER_DESCRIPTION_LENGTH (along with the other definitions in this
94 83 * ifndef block). Therefore if MAX_ADAPTER_DESCRIPTION_LENGTH is defined we can
95 84 * be sure that the other definitions are also defined */
96 85 #ifndef MAX_ADAPTER_DESCRIPTION_LENGTH
97 86
98 87 /*
99 88 * Following includes come from iptypes.h
100 89 */
101 90
102 91 #pragma warning(push)
103 92 #pragma warning(disable:4201)
104 93
105 94 #include <time.h>
106 95
107 96 // Definitions and structures used by getnetworkparams and getadaptersinfo apis
108 97
109 98 #define MAX_ADAPTER_DESCRIPTION_LENGTH 128 // arb.
110 99 #define MAX_ADAPTER_NAME_LENGTH 256 // arb.
111 100 #define MAX_ADAPTER_ADDRESS_LENGTH 8 // arb.
112 101 #define DEFAULT_MINIMUM_ENTITIES 32 // arb.
113 102 #define MAX_HOSTNAME_LEN 128 // arb.
114 103 #define MAX_DOMAIN_NAME_LEN 128 // arb.
115 104 #define MAX_SCOPE_ID_LEN 256 // arb.
116 105
117 106 //
118 107 // types
119 108 //
120 109
121 110 // Node Type
122 111
123 112 #define BROADCAST_NODETYPE 1
124 113 #define PEER_TO_PEER_NODETYPE 2
125 114 #define MIXED_NODETYPE 4
126 115 #define HYBRID_NODETYPE 8
127 116
128 117 //
129 118 // IP_ADDRESS_STRING - store an IP address as a dotted decimal string
130 119 //
131 120
132 121 typedef struct {
133 122 char String[4 * 4];
134 123 } IP_ADDRESS_STRING, *PIP_ADDRESS_STRING, IP_MASK_STRING, *PIP_MASK_STRING;
135 124
136 125 //
137 126 // IP_ADDR_STRING - store an IP address with its corresponding subnet mask,
138 127 // both as dotted decimal strings
139 128 //
140 129
141 130 typedef struct _IP_ADDR_STRING {
142 131 struct _IP_ADDR_STRING* Next;
143 132 IP_ADDRESS_STRING IpAddress;
144 133 IP_MASK_STRING IpMask;
145 134 DWORD Context;
146 135 } IP_ADDR_STRING, *PIP_ADDR_STRING;
147 136
148 137 //
149 138 // ADAPTER_INFO - per-adapter information. All IP addresses are stored as
150 139 // strings
151 140 //
152 141
153 142 typedef struct _IP_ADAPTER_INFO {
154 143 struct _IP_ADAPTER_INFO* Next;
155 144 DWORD ComboIndex;
156 145 char AdapterName[MAX_ADAPTER_NAME_LENGTH + 4];
157 146 char Description[MAX_ADAPTER_DESCRIPTION_LENGTH + 4];
158 147 UINT AddressLength;
159 148 BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH];
160 149 DWORD Index;
161 150 UINT Type;
162 151 UINT DhcpEnabled;
163 152 PIP_ADDR_STRING CurrentIpAddress;
164 153 IP_ADDR_STRING IpAddressList;
165 154 IP_ADDR_STRING GatewayList;
166 155 IP_ADDR_STRING DhcpServer;
167 156 BOOL HaveWins;
168 157 IP_ADDR_STRING PrimaryWinsServer;
169 158 IP_ADDR_STRING SecondaryWinsServer;
170 159 time_t LeaseObtained;
171 160 time_t LeaseExpires;
172 161 } IP_ADAPTER_INFO, *PIP_ADAPTER_INFO;
173 162
174 163 #ifdef _WINSOCK2API_
175 164
176 165 //
177 166 // The following types require Winsock2.
178 167 //
179 168
180 169 typedef enum {
181 170 IpPrefixOriginOther = 0,
182 171 IpPrefixOriginManual,
183 172 IpPrefixOriginWellKnown,
184 173 IpPrefixOriginDhcp,
185 174 IpPrefixOriginRouterAdvertisement,
186 175 } IP_PREFIX_ORIGIN;
187 176
188 177 typedef enum {
189 178 IpSuffixOriginOther = 0,
190 179 IpSuffixOriginManual,
191 180 IpSuffixOriginWellKnown,
192 181 IpSuffixOriginDhcp,
193 182 IpSuffixOriginLinkLayerAddress,
194 183 IpSuffixOriginRandom,
195 184 } IP_SUFFIX_ORIGIN;
196 185
197 186 typedef enum {
198 187 IpDadStateInvalid = 0,
199 188 IpDadStateTentative,
200 189 IpDadStateDuplicate,
201 190 IpDadStateDeprecated,
202 191 IpDadStatePreferred,
203 192 } IP_DAD_STATE;
204 193
205 194 typedef struct _IP_ADAPTER_UNICAST_ADDRESS {
206 195 union {
207 196 ULONGLONG Alignment;
208 197 struct {
209 198 ULONG Length;
210 199 DWORD Flags;
211 200 };
212 201 };
213 202 struct _IP_ADAPTER_UNICAST_ADDRESS *Next;
214 203 SOCKET_ADDRESS Address;
215 204
216 205 IP_PREFIX_ORIGIN PrefixOrigin;
217 206 IP_SUFFIX_ORIGIN SuffixOrigin;
218 207 IP_DAD_STATE DadState;
219 208
220 209 ULONG ValidLifetime;
221 210 ULONG PreferredLifetime;
222 211 ULONG LeaseLifetime;
223 212 } IP_ADAPTER_UNICAST_ADDRESS, *PIP_ADAPTER_UNICAST_ADDRESS;
224 213
225 214 typedef struct _IP_ADAPTER_ANYCAST_ADDRESS {
226 215 union {
227 216 ULONGLONG Alignment;
228 217 struct {
229 218 ULONG Length;
230 219 DWORD Flags;
231 220 };
232 221 };
233 222 struct _IP_ADAPTER_ANYCAST_ADDRESS *Next;
234 223 SOCKET_ADDRESS Address;
235 224 } IP_ADAPTER_ANYCAST_ADDRESS, *PIP_ADAPTER_ANYCAST_ADDRESS;
236 225
237 226 typedef struct _IP_ADAPTER_MULTICAST_ADDRESS {
238 227 union {
239 228 ULONGLONG Alignment;
240 229 struct {
241 230 ULONG Length;
242 231 DWORD Flags;
243 232 };
244 233 };
245 234 struct _IP_ADAPTER_MULTICAST_ADDRESS *Next;
246 235 SOCKET_ADDRESS Address;
247 236 } IP_ADAPTER_MULTICAST_ADDRESS, *PIP_ADAPTER_MULTICAST_ADDRESS;
248 237
249 238 //
250 239 // Per-address Flags
251 240 //
252 241 #define IP_ADAPTER_ADDRESS_DNS_ELIGIBLE 0x01
253 242 #define IP_ADAPTER_ADDRESS_TRANSIENT 0x02
254 243
255 244 typedef struct _IP_ADAPTER_DNS_SERVER_ADDRESS {
256 245 union {
257 246 ULONGLONG Alignment;
258 247 struct {
259 248 ULONG Length;
260 249 DWORD Reserved;
261 250 };
262 251 };
263 252 struct _IP_ADAPTER_DNS_SERVER_ADDRESS *Next;
264 253 SOCKET_ADDRESS Address;
265 254 } IP_ADAPTER_DNS_SERVER_ADDRESS, *PIP_ADAPTER_DNS_SERVER_ADDRESS;
266 255
267 256 typedef struct _IP_ADAPTER_PREFIX {
268 257 union {
269 258 ULONGLONG Alignment;
270 259 struct {
271 260 ULONG Length;
272 261 DWORD Flags;
273 262 };
274 263 };
275 264 struct _IP_ADAPTER_PREFIX *Next;
276 265 SOCKET_ADDRESS Address;
277 266 ULONG PrefixLength;
278 267 } IP_ADAPTER_PREFIX, *PIP_ADAPTER_PREFIX;
279 268
280 269 //
281 270 // Per-adapter Flags
282 271 //
283 272 #define IP_ADAPTER_DDNS_ENABLED 0x01
284 273 #define IP_ADAPTER_REGISTER_ADAPTER_SUFFIX 0x02
285 274 #define IP_ADAPTER_DHCP_ENABLED 0x04
286 275 #define IP_ADAPTER_RECEIVE_ONLY 0x08
287 276 #define IP_ADAPTER_NO_MULTICAST 0x10
288 277 #define IP_ADAPTER_IPV6_OTHER_STATEFUL_CONFIG 0x20
289 278
290 279 //
291 280 // OperStatus values from RFC 2863
292 281 //
293 282 typedef enum {
294 283 IfOperStatusUp = 1,
295 284 IfOperStatusDown,
296 285 IfOperStatusTesting,
297 286 IfOperStatusUnknown,
298 287 IfOperStatusDormant,
299 288 IfOperStatusNotPresent,
300 289 IfOperStatusLowerLayerDown
301 290 } IF_OPER_STATUS;
302 291
303 292 //
304 293 // Scope levels from RFC 2373 used with ZoneIndices array.
305 294 //
306 295 typedef enum {
307 296 ScopeLevelInterface = 1,
308 297 ScopeLevelLink = 2,
309 298 ScopeLevelSubnet = 3,
310 299 ScopeLevelAdmin = 4,
311 300 ScopeLevelSite = 5,
312 301 ScopeLevelOrganization = 8,
313 302 ScopeLevelGlobal = 14
314 303 } SCOPE_LEVEL;
315 304
316 305 typedef struct _IP_ADAPTER_ADDRESSES {
317 306 union {
318 307 ULONGLONG Alignment;
319 308 struct {
320 309 ULONG Length;
321 310 DWORD IfIndex;
322 311 };
323 312 };
324 313 struct _IP_ADAPTER_ADDRESSES *Next;
325 314 PCHAR AdapterName;
326 315 PIP_ADAPTER_UNICAST_ADDRESS FirstUnicastAddress;
327 316 PIP_ADAPTER_ANYCAST_ADDRESS FirstAnycastAddress;
328 317 PIP_ADAPTER_MULTICAST_ADDRESS FirstMulticastAddress;
329 318 PIP_ADAPTER_DNS_SERVER_ADDRESS FirstDnsServerAddress;
330 319 PWCHAR DnsSuffix;
331 320 PWCHAR Description;
332 321 PWCHAR FriendlyName;
333 322 BYTE PhysicalAddress[MAX_ADAPTER_ADDRESS_LENGTH];
334 323 DWORD PhysicalAddressLength;
335 324 DWORD Flags;
336 325 DWORD Mtu;
337 326 DWORD IfType;
338 327 IF_OPER_STATUS OperStatus;
339 328 DWORD Ipv6IfIndex;
340 329 DWORD ZoneIndices[16];
341 330 PIP_ADAPTER_PREFIX FirstPrefix;
342 331 } IP_ADAPTER_ADDRESSES, *PIP_ADAPTER_ADDRESSES;
343 332
344 333 //
345 334 // Flags used as argument to GetAdaptersAddresses().
346 335 // "SKIP" flags are added when the default is to include the information.
347 336 // "INCLUDE" flags are added when the default is to skip the information.
348 337 //
349 338 #define GAA_FLAG_SKIP_UNICAST 0x0001
350 339 #define GAA_FLAG_SKIP_ANYCAST 0x0002
351 340 #define GAA_FLAG_SKIP_MULTICAST 0x0004
352 341 #define GAA_FLAG_SKIP_DNS_SERVER 0x0008
353 342 #define GAA_FLAG_INCLUDE_PREFIX 0x0010
354 343 #define GAA_FLAG_SKIP_FRIENDLY_NAME 0x0020
355 344
356 345 #endif /* _WINSOCK2API_ */
357 346
358 347 //
359 348 // IP_PER_ADAPTER_INFO - per-adapter IP information such as DNS server list.
360 349 //
361 350
362 351 typedef struct _IP_PER_ADAPTER_INFO {
363 352 UINT AutoconfigEnabled;
364 353 UINT AutoconfigActive;
365 354 PIP_ADDR_STRING CurrentDnsServer;
366 355 IP_ADDR_STRING DnsServerList;
367 356 } IP_PER_ADAPTER_INFO, *PIP_PER_ADAPTER_INFO;
368 357
369 358 //
370 359 // FIXED_INFO - the set of IP-related information which does not depend on DHCP
371 360 //
372 361
373 362 typedef struct {
374 363 char HostName[MAX_HOSTNAME_LEN + 4] ;
375 364 char DomainName[MAX_DOMAIN_NAME_LEN + 4];
376 365 PIP_ADDR_STRING CurrentDnsServer;
377 366 IP_ADDR_STRING DnsServerList;
378 367 UINT NodeType;
379 368 char ScopeId[MAX_SCOPE_ID_LEN + 4];
380 369 UINT EnableRouting;
381 370 UINT EnableProxy;
382 371 UINT EnableDns;
383 372 } FIXED_INFO, *PFIXED_INFO;
384 373
385 374 #pragma warning(pop)
386 375
387 376 #endif /*!MAX_ADAPTER_DESCRIPTION_LENGTH*/
388 377
389 378 #ifndef IP_INTERFACE_NAME_INFO_DEFINED
390 379 #define IP_INTERFACE_NAME_INFO_DEFINED
391 380
392 381 typedef struct ip_interface_name_info {
393 382 ULONG Index; // Interface Index
394 383 ULONG MediaType; // Interface Types - see ipifcons.h
395 384 UCHAR ConnectionType;
396 385 UCHAR AccessType;
397 386 GUID DeviceGuid; // Device GUID is the guid of the device
398 387 // that IP exposes
399 388 GUID InterfaceGuid; // Interface GUID, if not GUID_NULL is the
400 389 // GUID for the interface mapped to the device.
401 390 } IP_INTERFACE_NAME_INFO, *PIP_INTERFACE_NAME_INFO;
402 391
403 392 #endif
404 393
405 394
406 395 /* from ipifcons.h */
407 396
408 397 #ifndef IF_TYPE_PPP
409 398 #define IF_TYPE_PPP 23
410 399 #endif
411 400
412 401 #ifndef IF_TYPE_SOFTWARE_LOOPBACK
413 402 #define IF_TYPE_SOFTWARE_LOOPBACK 24
414 403 #endif
415 404
416 405 #ifndef IF_TYPE_SLIP
417 406 #define IF_TYPE_SLIP 28
418 407 #endif
419 408
420 409 #ifndef IF_TYPE_TUNNEL
421 410 #define IF_TYPE_TUNNEL 131
422 411 #endif
423 412
424 413 #endif
↓ open down ↓ |
331 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX