23 typedef struct _MIBICMPSTATS_EX
27 DWORD rgdwTypeCount[256];
28 } MIBICMPSTATS_EX, *PMIBICMPSTATS_EX;
29 typedef struct _MIB_ICMP_EX
31 MIBICMPSTATS_EX icmpInStats;
32 MIBICMPSTATS_EX icmpOutStats;
33 } MIB_ICMP_EX,*PMIB_ICMP_EX;
37#pragma comment(lib, "iphlpapi.lib")
69 if ( lpszAddress == NULL || lpszAddress[0] == 0 )
73 DWORD dwIp = ::inet_addr(lpszAddress);
74 if ( dwIp == INADDR_NONE )
77 LPHOSTENT ptHost = ::gethostbyname(lpszAddress);
80 TRACE2A(
"::gethostbyname(%s) error = %d\n", lpszAddress, ::WSAGetLastError() );
83 dwIp = *(
reinterpret_cast<DWORD*
>(ptHost->h_addr));
87 ::GetIpAddrTable(NULL, &d, FALSE);
89 MIB_IPADDRTABLE* P =
reinterpret_cast<MIB_IPADDRTABLE*
>(mem.
Ref());
90 if ( ::GetIpAddrTable(P, &d, FALSE) == NO_ERROR )
92 loop ( i, P->dwNumEntries )
94 if ( dwIp == P->table[i].dwAddr )
96 return P->table[i].dwIndex;
100 return INVALID_INDEX;
113 ::GetIpAddrTable(NULL, &d, FALSE);
115 MIB_IFTABLE* P =
reinterpret_cast<MIB_IFTABLE*
>(mem.
Ref());
116 if ( ::GetIfTable(P, &d, FALSE) == NO_ERROR )
118 loop ( i, P->dwNumEntries )
120 if ( P->table[i].dwIndex == dwMibIndex )
122 _tMibIfRow = P->table[i];
137 static bool GetMibIfRow(LPCSTR lpszAddress, MIB_IFROW& _tMibIfRow)
140 if ( r != INVALID_INDEX )
156 IPAddr ipAddr = ::inet_addr(lpszAddress);
157 if ( ipAddr == INADDR_NONE )
161 ULONG aulMac[2] = { 0xFFFFFFFF, 0xFFFFFFFF };
163 HRESULT hr = ::SendARP(ipAddr, 0, aulMac, &ulLen);
169 BYTE* pbHexMac =
reinterpret_cast<BYTE*
>(aulMac);
188 IP_INTERFACE_INFO* pIfTable;
191 if ( ::GetInterfaceInfo( NULL, &dwOutBufLen ) == ERROR_INSUFFICIENT_BUFFER )
193 pIfTable = (IP_INTERFACE_INFO*)malloc( dwOutBufLen );
196 DWORD dwRet = ::GetInterfaceInfo( pIfTable, &dwOutBufLen );
197 if ( dwRet == NO_ERROR )
205 TCHAR szFileName[ MAX_PATH ];
206 _stprintf( szFileName, _T(
"\\\\.\\%s" ), szAdapterName );
208 HANDLE hDevice = ::CreateFile( szFileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
209 NULL, OPEN_EXISTING, 0, NULL);
215 #define BUFFER_SIZE ( sizeof(NDIS_WLAN_BSSID) * MAX_BSSID + sizeof(ULONG) )
217 NDIS_802_11_BSSID_LIST* pBSSIDList = (NDIS_802_11_BSSID_LIST*)malloc( BUFFER_SIZE );
218 if ( pBSSIDList == NULL )
223 DWORD nBytesReturned;
224 DWORD dwIoControlCode;
226 ::ZeroMemory( pBSSIDList, BUFFER_SIZE );
227 dwIoControlCode = OID_802_11_BSSID_LIST_SCAN;
229 ::DeviceIoControl( hDevice, IOCTL_NDIS_QUERY_GLOBAL_STATS,
230 &dwIoControlCode,
sizeof(dwIoControlCode),
232 &nBytesReturned, NULL );
237 ::ZeroMemory( pBSSIDList, BUFFER_SIZE );
238 dwIoControlCode = OID_802_11_BSSID_LIST;
240 if ( ::DeviceIoControl( hDevice, IOCTL_NDIS_QUERY_GLOBAL_STATS,
241 &dwIoControlCode,
sizeof(dwIoControlCode),
242 pBSSIDList,
sizeof(NDIS_802_11_BSSID_LIST) * MAX_BSSID,
243 &nBytesReturned, NULL ) )
253 NDIS_WLAN_BSSID* pBssid= pBSSIDList->Bssid;
254 for(
int i = 0; i < pBSSIDList->NumberOfItems; i++ )
258 TRACE( _T(
"%s: %d\n"), A2T( (LPCSTR)pBssid->Ssid.Ssid ), pBssid->Rssi );
260 pBssid = (NDIS_WLAN_BSSID*)( (BYTE*)pBssid + pBssid->Length );
#define loop(VAR, CNT)
loop構文.
static INDEX GetMibIndex(LPCSTR lpszAddress)
IPアドレスからMIB-INDEXを取得
static bool GetMacAddress(CWorkMem &_mac, LPCSTR lpszAddress)
[取得] MACアドレス取得
static bool GetMibIfRow(INDEX dwMibIndex, MIB_IFROW &_tMibIfRow)
[取得] MIB-INDEXの情報取得
static bool GetMibIfRow(LPCSTR lpszAddress, MIB_IFROW &_tMibIfRow)
[取得] MIB-INDEXの情報取得
void Resize(size_t l)
[設定] サイズ再設定
const TYP * Ref(void) const
[取得] ポインタ取得
void MemCopy(T *_pDst, const void *pSrc, size_t len)
[複製] メモリコピー