Watt-32 tcp/ip  2.2 dev-rel.10
Data Structures | Typedefs | Functions | Variables
winadinf.c File Reference

Go to the source code of this file.

Data Structures

struct  one_addr
 

Typedefs

typedef __inout LPWSADATA data
 
typedef __in DWORD dwAddressLength
 
typedef __in DWORD __in_opt
LPWSAPROTOCOL_INFO 
lpProtocolInfo
 
typedef __in DWORD __in_opt
LPWSAPROTOCOL_INFO __inout
LPSTR 
lpszAddressString
 
typedef __in DWORD __in_opt
LPWSAPROTOCOL_INFO __inout
LPSTR __inout DWORD * 
lpdwAddressStringLength
 
typedef __in ULONG Flags
 
typedef __in ULONG __in VOID * Reserved
 
typedef __in ULONG __in VOID
__out IP_ADAPTER_ADDRESSES * 
AdapterAddresses
 
typedef __in ULONG __in VOID
__out IP_ADAPTER_ADDRESSES
__inout PULONG 
outBufLen
 
typedef __inout PULONG pdwSize
 
typedef __inout PULONG __in BOOL bOrder
 
typedef __out PMIB_IF_TABLE2 * table
 
typedef __inout ULONG * size
 
typedef __inout ULONG __in BOOL sort
 
typedef __inout DWORD * lpcb
 
typedef __inout DWORD __out DWORD * lpcConnections
 
typedef __inout RAS_STATS * lpStatistics
 
typedef __out LPSTR lpszErrorString
 
typedef __out LPSTR __in DWORD cBufSize
 
typedef __in RASPROJECTION rasprojection
 
typedef __in RASPROJECTION
__out VOID * 
lpprojection
 
typedef __reserved VOID * pReserved
 
typedef __reserved VOID __out
DWORD * 
pdwNegotiatedVersion
 
typedef __reserved VOID __out
DWORD __out HANDLE * 
phClientHandle
 
typedef __reserved VOID
__deref_out
WLAN_INTERFACE_INFO_LIST ** 
ppInterfaceList
 
typedef __in const GUID * pInterfaceGuid
 
typedef __in const GUID __in
WLAN_INTF_OPCODE 
OpCode
 
typedef __in const GUID __in
WLAN_INTF_OPCODE __reserved
VOID __out DWORD * 
pdwDataSize
 
typedef __in const GUID __in
WLAN_INTF_OPCODE __reserved
VOID __out DWORD __out VOID ** 
ppData
 
typedef __in const GUID __in
WLAN_INTF_OPCODE __reserved
VOID __out DWORD __out VOID
__out_opt
WLAN_OPCODE_VALUE_TYPE * 
pWlanOpcodeValueType
 
typedef __in const GUID __in DWORD dwFlags
 
typedef __in const GUID __in
DWORD __reserved VOID __out
WLAN_AVAILABLE_NETWORK_LIST ** 
AvailableNetworks
 
typedef __in DWORD dwBufferSize
 
typedef __in DWORD __in WCHAR * pStringBuffer
 
typedef __in const GUID
__reserved VOID __out
WLAN_INTERFACE_CAPABILITY ** 
ppCapability
 
typedef __out LPOLESTR lpsz
 
typedef __out LPOLESTR __in int cchMax
 
typedef char address_buf [MAX_IP6_SZ+1]
 

Functions

typedef int (WINAPI *func_WSAStartup)(__in WORD version
 
typedef INT (WINAPI *func_WSAAddressToStringA)(__in LPSOCKADDR lpsaAddress
 
typedef ULONG (WINAPI *func_GetAdaptersAddresses)(__in ULONG Family
 
typedef DWORD (WINAPI *func_GetIfTable)(__out PMIB_IFTABLE pIfTable
 
typedef VOID (WINAPI *func_WlanFreeMemory)(__in VOID *memory)
 
static void unload_dlls (void)
 
static int load_dlls (void)
 
static const char * _list_lookup (DWORD type, const struct search_list *list, int num)
 Search 'list' for 'type' and return it's name. More...
 
static const char * get_wsock_err (void)
 
static char * strip_end (char *buf, char ch)
 
static void check_indent_and_print (const char *buf)
 
static const char * dword_string (DWORD val)
 Return nicely formatted string "xx.xxx.xxx" with thousand separators (left adjusted). More...
 
static const char * speed_string (DWORD val)
 Return a number with suffix for a link-speed 32-bit value.
 
static const char * speed64_string (ULONG64 val)
 Return a number with suffix for a link-speed of 64-bit value.
 
static const char * duration_string (DWORD msec)
 
static const char * get_address_flags (DWORD flags)
 
static const char * get_addr_common (int num, const address_buf *abuf)
 
 GET_ADDRESSES (get_unicast_addrs, const IP_ADAPTER_UNICAST_ADDRESS, uca)
 
int W32_CALL pkt_win_print_GetIfTable (void)
 
int W32_CALL pkt_win_print_GetIfTable2 (void)
 
int W32_CALL pkt_win_print_GetIpNetTable (void)
 
int W32_CALL pkt_win_print_GetAdaptersAddresses (void)
 
static const char * ras_strerror (DWORD err)
 
static const char * get_ccp_flags (DWORD flags)
 
static const char * get_lcp_flags (DWORD flags)
 
int W32_CALL pkt_win_print_RasEnumConnections (void)
 
static int print_wlan_networklist (const WLAN_AVAILABLE_NETWORK_LIST *wlist)
 
static int print_wlan_current_connection (const WLAN_CONNECTION_ATTRIBUTES *conn_attr)
 
int W32_CALL pkt_win_print_WlanEnumInterfaces (void)
 

Variables

static func_WSAStartup p_WSAStartup = NULL
 
static func_WSACleanup p_WSACleanup = NULL
 
static func_WSAAddressToStringA p_WSAAddressToStringA = NULL
 
static func_WSAGetLastError p_WSAGetLastError = NULL
 
static func_GetAdaptersAddresses p_GetAdaptersAddresses = NULL
 
static func_GetIfTable p_GetIfTable = NULL
 
static func_GetIfTable2 p_GetIfTable2 = NULL
 
static func_GetIfTable2Ex p_GetIfTable2Ex = NULL
 
static func_GetIpNetTable p_GetIpNetTable = NULL
 
static func_RasEnumConnectionsA p_RasEnumConnectionsA = NULL
 
static func_RasGetErrorStringA p_RasGetErrorStringA = NULL
 
static
func_RasGetConnectionStatistics 
p_RasGetConnectionStatistics = NULL
 
static func_RasGetProjectionInfoA p_RasGetProjectionInfoA = NULL
 
static func_WlanOpenHandle p_WlanOpenHandle = NULL
 
static func_WlanCloseHandle p_WlanCloseHandle = NULL
 
static func_WlanEnumInterfaces p_WlanEnumInterfaces = NULL
 
static func_WlanQueryInterface p_WlanQueryInterface = NULL
 
static
func_WlanGetAvailableNetworkList 
p_WlanGetAvailableNetworkList = NULL
 
static func_WlanFreeMemory p_WlanFreeMemory = NULL
 
static func_WlanReasonCodeToString p_WlanReasonCodeToString = NULL
 
static func_StringFromGUID2 p_StringFromGUID2 = NULL
 
static struct LoadTable dyn_funcs2 []
 
static const struct search_list wsock_err_tab []
 
static const struct search_list if_types []
 
static const struct search_list mib_oper_status []
 
static const struct search_list oper_status []
 
static char work_buf [10000]
 
static const struct search_list auth_proto []
 
static const struct search_list auth_data []
 
static const struct search_list compression []
 
static const struct search_list wlan_intf_state []
 
static const struct search_list wlan_conn_mode []
 
static const struct search_list dot11_auth_algo []
 
static const struct search_list dot11_cipher_algo []
 
static const struct search_list bss_types []
 

Detailed Description

Functions for getting the details of network adapters under Windows. Using IPHlpApi Adapter Information (Win32/64).

Copyright (c) 2011 Gisle Vanem gvane.nosp@m.m@ya.nosp@m.hoo.n.nosp@m.o

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by Gisle Vanem Bergen, Norway.

THIS SOFTWARE IS PROVIDED BY ME (Gisle Vanem) AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL I OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Version

0.5 : July 07, 2011 : G. Vanem - created

Definition in file winadinf.c.

Function Documentation

static const char* _list_lookup ( DWORD  type,
const struct search_list list,
int  num 
)
static

Search 'list' for 'type' and return it's name.

Duplicate it here in-case '#define USE_DEBUG' isn't defined for misc.c.

Definition at line 283 of file winadinf.c.

static const char* dword_string ( DWORD  val)
static

Return nicely formatted string "xx.xxx.xxx" with thousand separators (left adjusted).

Use 8 buffers in round-robin.

Definition at line 355 of file winadinf.c.

References strltrim().

Variable Documentation

const struct search_list auth_data[]
static
Initial value:
= {
{ 0, NONE_STR },
{ RASLCPAD_CHAP_MD5, "CHAP MD5" },
{ RASLCPAD_CHAP_MS, "Microsoft CHAP" },
{ RASLCPAD_CHAP_MSV2, "Microsoft CHAP v2" }
}

Definition at line 913 of file winadinf.c.

const struct search_list auth_proto[]
static
Initial value:
= {
{ 0, NONE_STR },
{ RASLCPAP_PAP, "PAP" },
{ RASLCPAP_SPAP, "Shiva" },
{ RASLCPAP_CHAP, "CHAP" },
{ RASLCPAP_EAP, "EAP" }
}

Definition at line 905 of file winadinf.c.

const struct search_list bss_types[]
static
Initial value:
= {
{ dot11_BSS_type_infrastructure, "Infrastructure" },
{ dot11_BSS_type_independent, "Ad-hoc" }
}

Definition at line 1276 of file winadinf.c.

const struct search_list compression[]
static
Initial value:
= {
{ RASCCPCA_MPPC, "MPPC" },
{ RASCCPCA_STAC, "STAC" }
}

Definition at line 920 of file winadinf.c.

const struct search_list dot11_auth_algo[]
static
Initial value:
= {
{ DOT11_AUTH_ALGO_80211_OPEN, "802.11 Open" },
{ DOT11_AUTH_ALGO_80211_SHARED_KEY, "802.11 Shared" },
{ DOT11_AUTH_ALGO_WPA, "WPA" },
{ DOT11_AUTH_ALGO_WPA_PSK, "WPA-PSK" },
{ DOT11_AUTH_ALGO_WPA_NONE, "WPA-None" },
{ DOT11_AUTH_ALGO_RSNA, "RSNA" },
{ DOT11_AUTH_ALGO_RSNA_PSK, "RSNA with PSK (WEP2)" }
}

Definition at line 1257 of file winadinf.c.

const struct search_list dot11_cipher_algo[]
static
Initial value:
= {
{ DOT11_CIPHER_ALGO_NONE, "None" },
{ DOT11_CIPHER_ALGO_WEP40, "WEP-40" },
{ DOT11_CIPHER_ALGO_TKIP, "TKIP" },
{ DOT11_CIPHER_ALGO_CCMP, "CCMP" },
{ DOT11_CIPHER_ALGO_WEP104, "WEP-104" },
{ DOT11_CIPHER_ALGO_WEP, "WEP" }
}

Definition at line 1267 of file winadinf.c.

struct LoadTable dyn_funcs2[]
static
Initial value:
= {
ADD_VALUE ("ws2_32.dll", WSAStartup),
ADD_VALUE ("ws2_32.dll", WSACleanup),
ADD_VALUE ("ws2_32.dll", WSAAddressToStringA),
ADD_VALUE ("ws2_32.dll", WSAGetLastError),
ADD_VALUE ("Ole32.dll", StringFromGUID2),
ADD_VALUE ("IPhlpApi.dll", GetAdaptersAddresses),
ADD_VALUE ("IPhlpApi.dll", GetIfTable),
ADD_VALUE ("IPhlpApi.dll", GetIfTable2),
ADD_VALUE ("IPhlpApi.dll", GetIfTable2Ex),
ADD_VALUE ("IPhlpApi.dll", GetIpNetTable),
ADD_VALUE ("RasApi32.dll", RasEnumConnectionsA),
ADD_VALUE ("RasApi32.dll", RasGetConnectionStatistics),
ADD_VALUE ("RasApi32.dll", RasGetErrorStringA),
ADD_VALUE ("RasApi32.dll", RasGetProjectionInfoA),
ADD_VALUE ("WlanApi.dll" , WlanOpenHandle),
ADD_VALUE ("WlanApi.dll" , WlanCloseHandle),
ADD_VALUE ("WlanApi.dll" , WlanEnumInterfaces),
ADD_VALUE ("WlanApi.dll" , WlanFreeMemory),
ADD_VALUE ("WlanApi.dll" , WlanGetAvailableNetworkList),
ADD_VALUE ("WlanApi.dll" , WlanQueryInterface),
ADD_VALUE ("WlanApi.dll" , WlanReasonCodeToString)
}

Definition at line 215 of file winadinf.c.

const struct search_list if_types[]
static
Initial value:
= {
{ IF_TYPE_OTHER, "Other type" },
{ IF_TYPE_ETHERNET_CSMACD, "Ethernet" },
{ IF_TYPE_ISO88025_TOKENRING, "Token-ring" },
{ IF_TYPE_PPP, "Point-to-Point" },
{ IF_TYPE_SOFTWARE_LOOPBACK, "Loopback" },
{ IF_TYPE_ATM, "ATM" },
{ IF_TYPE_IEEE80211, "IEEE 802.11 wireless" },
{ IF_TYPE_TUNNEL, "Tunnel" },
{ IF_TYPE_IEEE1394, "IEEE 1394 (Firewire)" }
}

Definition at line 464 of file winadinf.c.

const struct search_list mib_oper_status[]
static
Initial value:
= {
{ IF_OPER_STATUS_NON_OPERATIONAL, "disabled" },
{ IF_OPER_STATUS_UNREACHABLE, "WAN not connected" },
{ IF_OPER_STATUS_DISCONNECTED, "disconnected/no carrier" },
{ IF_OPER_STATUS_CONNECTING, "WAN connecting" },
{ IF_OPER_STATUS_CONNECTED, "WAN connected" },
{ IF_OPER_STATUS_OPERATIONAL, "LAN okay" },
}

Definition at line 476 of file winadinf.c.

const struct search_list oper_status[]
static
Initial value:
= {
{ IfOperStatusUp, "Up" },
{ IfOperStatusDown, "Down" },
{ IfOperStatusTesting, "Testing" },
{ IfOperStatusUnknown, "Unknown" },
{ IfOperStatusDormant, "Dormant" },
{ IfOperStatusNotPresent, "Not present" },
{ IfOperStatusLowerLayerDown, "Lower layer down" }
}

Definition at line 485 of file winadinf.c.

const struct search_list wlan_conn_mode[]
static
Initial value:
= {
{ wlan_connection_mode_profile, "Profile" },
{ wlan_connection_mode_temporary_profile, "Temporary profile" },
{ wlan_connection_mode_discovery_secure, "Secure discovery" },
{ wlan_connection_mode_discovery_unsecure, "Unsecure discovery" },
{ wlan_connection_mode_auto, "Auto" },
{ wlan_connection_mode_invalid, "N/A" }
}

Definition at line 1133 of file winadinf.c.

const struct search_list wlan_intf_state[]
static
Initial value:
= {
{ wlan_interface_state_not_ready, "Not ready" },
{ wlan_interface_state_connected, "Connected" },
{ wlan_interface_state_ad_hoc_network_formed, "First node in a Ad Hoc network" },
{ wlan_interface_state_disconnecting, "Disconnecting" },
{ wlan_interface_state_disconnected, "Disconnected" },
{ wlan_interface_state_associating, "Attempting to associate with a network" },
{ wlan_interface_state_discovering, "Auto configuration is discovering settings for the network" },
{ wlan_interface_state_authenticating, "Authenticating in process" },
}

Definition at line 1122 of file winadinf.c.

const struct search_list wsock_err_tab[]
static
Initial value:
= {
{ 10004, "Call interrupted" },
}

Definition at line 299 of file winadinf.c.