Watt-32 tcp/ip  2.2 dev-rel.10
winadinf.h
Go to the documentation of this file.
1 
17 #ifndef _w32_WINADINF_H
18 #define _w32_WINADINF_H
19 
20 #if (defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)) && !defined(__DMC__)
21 
22 #define __NETINET_IN_H /* don't pull in these in "../inc/" */
23 #define __SYS_SOCKET_H
24 #define __SYS_WERRNO_H
25 #define __SYS_WTIME_H
26 #define __SYS_SWAP_BYTES_H
27 #define _WATT32_FAKE_WINSOCK_H /* suppress errors from <w32api.h> */
28 #define _WATT32_FAKE_WINSOCK2_H
29 #define _WATT32_FAKE_WS2TCPIP_H
30 #define USE_SYS_TYPES_FD_SET /* Shutup CygWin */
31 
32 #define WATT32_COMPILING_WINADINF_C
33 
34 /* We're now ready to pull in the real Winsock headers needed.
35  */
36 
37 #define WIN32_LEAN_AND_MEAN
38 
39 #if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0501)
40  #undef _WIN32_WINNT
41  #define _WIN32_WINNT 0x0501
42 #endif
43 
44 #if !defined(WINVER) || (WINVER < 0x0501)
45  #undef WINVER
46  #define WINVER _WIN32_WINNT /* Required for OpenWatcom */
47  #define NTDDI_VERSION NTDDI_VERSION_FROM_WIN32_WINNT(WINVER)
48 #endif
49 
50 #include <windows.h>
51 #include <windowsx.h>
52 #include <winsock2.h>
53 #include <ws2tcpip.h>
54 #include <specstrings.h>
55 #include <objbase.h>
56 #include <iptypes.h>
57 #include <iphlpapi.h>
58 #include <ipifcons.h>
59 #include <ras.h>
60 #include <raserror.h>
61 
62 #include <sys/cdefs.h>
63 
64 #if defined(_MSC_VER)
65  #define _STR2(x) #x
66  #define _STR(x) _STR2(x)
67 
68  #pragma message (__FILE__ "(" _STR(__LINE__) "): MSVC: WINVER=" _STR(WINVER))
69 
70  #if (NTDDI_VERSION >= NTDDI_VISTASP1)
71  #define ON_WIN_VISTA_SP1
72  #pragma message (__FILE__ "(" _STR(__LINE__) "): MSVC: Using WinVista SP1+ SDK")
73 
74  #elif (NTDDI_VERSION >= NTDDI_VISTA)
75  #define ON_WIN_VISTA
76  #pragma message (__FILE__ "(" _STR(__LINE__) "): MSVC: Using WinVista SDK")
77  #endif
78 
79 #elif defined(_WIN32_WINNT)
80 
81  #define _STR2(x) #x
82  #define _STR(x) _STR2(x)
83 
84  #if (W32_GCC_VERSION >= 40600)
85  #pragma message ("WINVER=" _STR(WINVER))
86  #pragma message (__FILE__ "(" _STR(__LINE__) "): WINVER=" _STR(WINVER))
87  #endif
88 
89  #if (_WIN32_WINNT >= 0x0600)
90  #define ON_WIN_VISTA
91  #endif
92  #if (_WIN32_WINNT >= 0x0601) /* Is this right? */
93  #define ON_WIN_VISTA_SP1
94  #endif
95 #endif
96 
97 #if defined(_MSC_VER)
98  #include <wtypes.h>
99  #include <wlanapi.h>
100  #include <windot11.h>
101  #include <netioapi.h>
102 
103  #define HAVE_NETIOAPI_H
104  #define HAVE_WLANAPI_H
105  #define HAVE_WINDOT11_H
106  #define COMPILE_WINADINF_C /* We have all stuff need to compile winadinf.c */
107 
108 #elif defined(__WATCOMC__)
109  #include <wtypes.h>
110  #include <wlantype.h>
111  #include <windot11.h>
112 
113  #define HAVE_WINDOT11_H
114  #define COMPILE_WINADINF_C
115 
116 #elif defined(__MINGW32__)
117  #define COMPILE_WINADINF_C
118 
119 #elif defined(__CYGWIN__)
120  #define COMPILE_WINADINF_C
121 #endif
122 
123 /* Assume for now, that all compilers have 'MIB_IPNETTABLE'.
124  */
125 #define HAVE_MIB_IPNETTABLE
126 
127 /* For GetIpNetTable():
128  */
129 #if !defined(HAVE_MIB_IPNETTABLE)
130  typedef struct {
131  DWORD dwIndex;
132  DWORD dwPhysAddrLen;
133  BYTE bPhysAddr [MAXLEN_PHYSADDR]; /* =8, not 6 for EtherNet */
134  DWORD dwAddr;
135  DWORD dwType;
136  } MIB_IPNETROW;
137 
138  typedef struct {
139  DWORD dwNumEntries;
140  MIB_IPNETROW table[ANY_SIZE];
141  } MIB_IPNETTABLE;
142 #endif
143 
144 /* For GetIpNetTable2() + GetIpNetTable2Ex():
145  */
146 #if !defined(HAVE_NETIOAPI_H)
147  typedef void PMIB_IF_TABLE2;
148  typedef enum MIB_IF_TABLE_LEVEL {
149  MibIfTableNormal,
150  MibIfTableRaw
151  } MIB_IF_TABLE_LEVEL;
152 #endif
153 
154 
155 #if !defined(HAVE_WINDOT11_H)
156  /*
157  * The DOT11 stuff ripped from OpenWatcom's <wlantype.h> and <windot11.h>.
158  */
159  #define DOT11_SSID_MAX_LENGTH 32 /* 802.11 SSID maximum length */
160 
161  typedef struct _DOT11_SSID { /* 802.11 SSID */
162  ULONG uSSIDLength;
163  UCHAR ucSSID [DOT11_SSID_MAX_LENGTH];
164  } DOT11_SSID;
165 
166  typedef enum _DOT11_PHY_TYPE { /* 802.11 physical types */
167  dot11_phy_type_unknown = 0,
168  dot11_phy_type_any = dot11_phy_type_unknown,
169  dot11_phy_type_fhss = 1,
170  dot11_phy_type_dsss = 2,
171  dot11_phy_type_irbaseband = 3,
172  dot11_phy_type_ofdm = 4,
173  dot11_phy_type_hrdsss = 5,
174  dot11_phy_type_erp = 6,
175  dot11_phy_type_ht = 7,
176  dot11_phy_type_IHV_start = 0x80000000,
177  dot11_phy_type_IHV_end = 0xFFFFFFFF
178  } DOT11_PHY_TYPE;
179 
180  typedef enum _DOT11_BSS_TYPE { /* 802.11 BSS types */
181  dot11_BSS_type_infrastructure = 1,
182  dot11_BSS_type_independent = 2,
183  dot11_BSS_type_any = 3
184  } DOT11_BSS_TYPE;
185 
186  typedef enum _DOT11_AUTH_ALGORITHM { /* 802.11 authentication algorithms */
187  DOT11_AUTH_ALGO_80211_OPEN = 1,
188  DOT11_AUTH_ALGO_80211_SHARED_KEY = 2,
189  DOT11_AUTH_ALGO_WPA = 3,
190  DOT11_AUTH_ALGO_WPA_PSK = 4,
191  DOT11_AUTH_ALGO_WPA_NONE = 5,
192  DOT11_AUTH_ALGO_WPA_RSNA = 6,
193  DOT11_AUTH_ALGO_WPA_RSNA_PSK = 7,
194  DOT11_AUTH_ALGO_IHV_START = 0x80000000,
195  DOT11_AUTH_ALGO_IHV_END = 0xFFFFFFFF
196  } DOT11_AUTH_ALGORITHM;
197 
198  typedef enum _DOT11_CIPHER_ALGORITHM { /* 802.11 cipher algorithms */
199  DOT11_CIPHER_ALGO_NONE = 0x00000000,
200  DOT11_CIPHER_ALGO_WEP40 = 0x00000001,
201  DOT11_CIPHER_ALGO_TKIP = 0x00000002,
202  DOT11_CIPHER_ALGO_CCMP = 0x00000004,
203  DOT11_CIPHER_ALGO_WEP104 = 0x00000005,
204  DOT11_CIPHER_ALGO_WPA_USE_GROUP = 0x00000100,
205  DOT11_CIPHER_ALGO_RSN_USE_GROUP = 0x00000100,
206  DOT11_CIPHER_ALGO_WEP = 0x00000101,
207  DOT11_CIPHER_ALGO_IHV_START = 0x80000000,
208  DOT11_CIPHER_ALGO_IHV_END = 0xFFFFFFFF
209  } DOT11_CIPHER_ALGORITHM;
210 
211  typedef UCHAR DOT11_MAC_ADDRESS [6]; /* 802.11 MAC address */
212 
213 #endif
214 
215 #if !defined(HAVE_WLANAPI_H)
216  #define WLAN_MAX_PHY_TYPE_NUMBER 8
217  #define WLAN_MAX_NAME_LENGTH 256
218  #define WLAN_MAX_PHY_INDEX 64 /* max # of PHYs supported by a NIC */
219 
220  /* WLAN_AVAILABLE_NETWORK::dwFlags */
221  #define WLAN_AVAILABLE_NETWORK_CONNECTED 0x00000001
222  #define WLAN_AVAILABLE_NETWORK_HAS_PROFILE 0x00000002
223  #define WLAN_AVAILABLE_NETWORK_CONSOLE_USER_PROFILE 0x00000004
224 
225  /* flags that control the list returned by WlanGetAvailableNetworkList
226  * include all ad hoc network profiles in the available network list,
227  * regardless they are visible or not
228  */
229  #define WLAN_AVAILABLE_NETWORK_INCLUDE_ALL_ADHOC_PROFILES 0x00000001
230 
231  /* include all hidden network profiles in the available network list,
232  * regardless they are visible or not
233  */
234  #define WLAN_AVAILABLE_NETWORK_INCLUDE_ALL_MANUAL_HIDDEN_PROFILES 0x00000002
235 
236  typedef enum _WLAN_CONNECTION_MODE {
237  wlan_connection_mode_profile = 0,
238  wlan_connection_mode_temporary_profile,
239  wlan_connection_mode_discovery_secure,
240  wlan_connection_mode_discovery_unsecure,
241  wlan_connection_mode_auto,
242  wlan_connection_mode_invalid
243  } WLAN_CONNECTION_MODE;
244 
245  typedef enum _WLAN_INTERFACE_TYPE {
246  wlan_interface_type_emulated_802_11 = 0,
247  wlan_interface_type_native_802_11,
248  wlan_interface_type_invalid
249  } WLAN_INTERFACE_TYPE;
250 
251  typedef struct _WLAN_INTERFACE_CAPABILITY {
252  WLAN_INTERFACE_TYPE interfaceType;
253  BOOL bDot11DSupported;
254  DWORD dwMaxDesiredSsidListSize;
255  DWORD dwMaxDesiredBssidListSize;
256  DWORD dwNumberOfSupportedPhys;
257  DOT11_PHY_TYPE dot11PhyTypes [WLAN_MAX_PHY_INDEX];
259 
260  typedef enum _WLAN_INTERFACE_STATE {
261  wlan_interface_state_not_ready,
262  wlan_interface_state_connected,
263  wlan_interface_state_ad_hoc_network_formed,
264  wlan_interface_state_disconnecting,
265  wlan_interface_state_disconnected,
266  wlan_interface_state_associating,
267  wlan_interface_state_discovering,
268  wlan_interface_state_authenticating
269  } WLAN_INTERFACE_STATE;
270 
271  typedef struct _WLAN_INTERFACE_INFO {
272  GUID InterfaceGuid;
273  WCHAR strInterfaceDescription [WLAN_MAX_NAME_LENGTH];
274  WLAN_INTERFACE_STATE isState;
276 
277  typedef struct _WLAN_INTERFACE_INFO_LIST {
278  DWORD dwNumberOfItems;
279  DWORD dwIndex;
280  WLAN_INTERFACE_INFO InterfaceInfo[1];
282 
283  typedef enum _WLAN_INTF_OPCODE {
284  wlan_intf_opcode_autoconf_start = 0x000000000,
285  wlan_intf_opcode_autoconf_enabled,
286  wlan_intf_opcode_background_scan_enabled,
287  wlan_intf_opcode_media_streaming_mode,
288  wlan_intf_opcode_radio_state,
289  wlan_intf_opcode_bss_type,
290  wlan_intf_opcode_interface_state,
291  wlan_intf_opcode_current_connection,
292  wlan_intf_opcode_channel_number,
293  wlan_intf_opcode_supported_infrastructure_auth_cipher_pairs,
294  wlan_intf_opcode_supported_adhoc_auth_cipher_pairs,
295  wlan_intf_opcode_supported_country_or_region_string_list,
296  wlan_intf_opcode_current_operation_mode,
297  wlan_intf_opcode_supported_safe_mode,
298  wlan_intf_opcode_certified_safe_mode,
299  wlan_intf_opcode_hosted_network_capable,
300  wlan_intf_opcode_autoconf_end = 0x0fffffff,
301  wlan_intf_opcode_msm_start = 0x10000100,
302  wlan_intf_opcode_statistics,
303  wlan_intf_opcode_rssi,
304  wlan_intf_opcode_msm_end = 0x1fffffff,
305  wlan_intf_opcode_security_start = 0x20010000,
306  wlan_intf_opcode_security_end = 0x2fffffff,
307  wlan_intf_opcode_ihv_start = 0x30000000,
308  wlan_intf_opcode_ihv_end = 0x3fffffff
309  } WLAN_INTF_OPCODE;
310 
311  typedef enum _WLAN_OPCODE_VALUE_TYPE {
312  wlan_opcode_value_type_query_only = 0,
313  wlan_opcode_value_type_set_by_group_policy,
314  wlan_opcode_value_type_set_by_user,
315  wlan_opcode_value_type_invalid
316  } WLAN_OPCODE_VALUE_TYPE;
317 
318  /* Structure WLAN_ASSOCIATION_ATTRIBUTES defines attributes of a wireless
319  * association. The unit for Rx/Tx rate is Kbits/second.
320  */
322  DOT11_SSID dot11Ssid;
323  DOT11_BSS_TYPE dot11BssType;
324  DOT11_MAC_ADDRESS dot11Bssid;
325  DOT11_PHY_TYPE dot11PhyType;
326  ULONG uDot11PhyIndex;
327  ULONG wlanSignalQuality;
328  ULONG ulRxRate;
329  ULONG ulTxRate;
331 
332  typedef struct _WLAN_SECURITY_ATTRIBUTES {
333  BOOL bSecurityEnabled;
334  BOOL bOneXEnabled;
335  DOT11_AUTH_ALGORITHM dot11AuthAlgorithm;
336  DOT11_CIPHER_ALGORITHM dot11CipherAlgorithm;
338 
340  WLAN_INTERFACE_STATE isState;
341  WLAN_CONNECTION_MODE wlanConnectionMode;
342  WCHAR strProfileName [WLAN_MAX_NAME_LENGTH];
343  WLAN_ASSOCIATION_ATTRIBUTES wlanAssociationAttributes;
344  WLAN_SECURITY_ATTRIBUTES wlanSecurityAttributes;
346 
347  typedef struct _WLAN_AVAILABLE_NETWORK {
348  WCHAR strProfileName[WLAN_MAX_NAME_LENGTH];
349  DOT11_SSID dot11Ssid;
350  DOT11_BSS_TYPE dot11BssType;
351  ULONG uNumberOfBssids;
352  BOOL bNetworkConnectable;
353  DWORD wlanNotConnectableReason;
354  ULONG uNumberOfPhyTypes;
355  DOT11_PHY_TYPE dot11PhyTypes[WLAN_MAX_PHY_TYPE_NUMBER];
356 
357  /* bMorePhyTypes is set to TRUE if the PHY types for the network
358  * exceeds WLAN_MAX_PHY_TYPE_NUMBER.
359  * In this case, uNumerOfPhyTypes is WLAN_MAX_PHY_TYPE_NUMBER and the
360  * first WLAN_MAX_PHY_TYPE_NUMBER PHY types are returned.
361  */
362  BOOL bMorePhyTypes;
363  ULONG wlanSignalQuality;
364  BOOL bSecurityEnabled;
365  DOT11_AUTH_ALGORITHM dot11DefaultAuthAlgorithm;
366  DOT11_CIPHER_ALGORITHM dot11DefaultCipherAlgorithm;
367  DWORD dwFlags;
368  DWORD dwReserved;
370 
372  DWORD dwNumberOfItems;
373  DWORD dwIndex;
374  WLAN_AVAILABLE_NETWORK Network[1];
376 
377 #endif /* HAVE_WLANAPI_H */
378 
379 #ifndef IP_ADAPTER_NETBIOS_OVER_TCPIP_ENABLED
380 #define IP_ADAPTER_NETBIOS_OVER_TCPIP_ENABLED 0x0040
381 #endif
382 
383 #ifndef IP_ADAPTER_IPV4_ENABLED
384 #define IP_ADAPTER_IPV4_ENABLED 0x0080
385 #endif
386 
387 #ifndef IP_ADAPTER_IPV6_ENABLED
388 #define IP_ADAPTER_IPV6_ENABLED 0x0100
389 #endif
390 
391 #ifndef GAA_FLAG_INCLUDE_ALL_INTERFACES
392 #define GAA_FLAG_INCLUDE_ALL_INTERFACES 0x0100L
393 #endif
394 
395 #ifndef GAA_FLAG_INCLUDE_WINS_INFO
396 #define GAA_FLAG_INCLUDE_WINS_INFO 0x0040L
397 #endif
398 
399 #ifndef GAA_FLAG_INCLUDE_GATEWAYS
400 #define GAA_FLAG_INCLUDE_GATEWAYS 0x0080L
401 #endif
402 
403 #ifndef GAA_FLAG_INCLUDE_TUNNEL_BINDINGORDER
404 #define GAA_FLAG_INCLUDE_TUNNEL_BINDINGORDER 0x0400L
405 #endif
406 
407 #ifndef DOT11_AUTH_ALGO_RSNA
408 #define DOT11_AUTH_ALGO_RSNA 6
409 #endif
410 
411 #ifndef DOT11_AUTH_ALGO_RSNA_PSK
412 #define DOT11_AUTH_ALGO_RSNA_PSK 7
413 #endif
414 
415 #ifndef DOT11_AUTH_ALGO_WPA_NONE
416 #define DOT11_AUTH_ALGO_WPA_NONE 5
417 #endif
418 
419 #ifndef DOT11_OPERATION_MODE_EXTENSIBLE_STATION
420 #define DOT11_OPERATION_MODE_EXTENSIBLE_STATION 0x00000004
421 #endif
422 
423 #ifndef DOT11_OPERATION_MODE_NETWORK_MONITOR
424 #define DOT11_OPERATION_MODE_NETWORK_MONITOR 0x80000000
425 #endif
426 
427 #ifndef RASLCPO_AES_128
428 #define RASLCPO_AES_128 0x00000020
429 #endif
430 
431 #ifndef RASLCPO_AES_256
432 #define RASLCPO_AES_256 0x00000040
433 #endif
434 
435 #define MAX_IP6_SZ sizeof ("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")
436 
437 #if defined(COMPILE_WINADINF_C)
438  #ifndef __in
439  #define __in
440  #endif
441 
442  #ifndef __inout
443  #define __inout
444  #endif
445 
446  #ifndef __in_opt
447  #define __in_opt
448  #endif
449 
450  #ifndef __out
451  #define __out
452  #endif
453 
454  #ifndef __out_opt
455  #define __out_opt
456  #endif
457 
458  #ifndef __deref_out
459  #define __deref_out
460  #endif
461 
462  #ifndef __reserved
463  #define __reserved
464  #endif
465 #endif
466 
467 #endif /* (WIN32 || _WIN32 || __CYGWIN__) && !__DMC__ */
468 #endif /* _w32_WINADINF_H */