overlook
asked on
How to monitor the event indication between NDIS and 802.11 NIC from user mode
Dear experts,
I wanna to enable my application the cabability to record and monitor the status of 802.11 NIC real-time. The DDK document of NdisMIndicateStatus() showes that 802.11 NIC probably indicates the link status, such as NDIS_STATUS_MEDIA_DISCONNE CT and NDIS_STATUS_MEDIA_CONNECT, to ndis by NdisMIndicateStatus().
Could you please tell me if there is any possible idea and example to get these indications form IO manager, the ISR of ndis, or some kinds of virtual NIC?
Thank you very much!
-Liang
I wanna to enable my application the cabability to record and monitor the status of 802.11 NIC real-time. The DDK document of NdisMIndicateStatus() showes that 802.11 NIC probably indicates the link status, such as NDIS_STATUS_MEDIA_DISCONNE
Could you please tell me if there is any possible idea and example to get these indications form IO manager, the ISR of ndis, or some kinds of virtual NIC?
Thank you very much!
-Liang
ASKER
Thanks for the rapid expertise feedback.
Do you mean I can query the OID_GEN_MEDIA_CONNECT_STAT US periodicly in my application to get the current status of 802.11 NIC?
However, the polling mechanism can not get all the events generated by 802.11 NIC. According to Microsoft's document "IEEE 802.11 Network Adapter Design Guidelines for Windows XP", Native WiFi driver not only generates meida connect event when the association status changes, but also trigger a notification to the upper layer when the RSSI is below or above the threshold.
Anyway, it's desireable if there is a facility to capture the registered NDIS events in user mode.
-Liang
Do you mean I can query the OID_GEN_MEDIA_CONNECT_STAT
However, the polling mechanism can not get all the events generated by 802.11 NIC. According to Microsoft's document "IEEE 802.11 Network Adapter Design Guidelines for Windows XP", Native WiFi driver not only generates meida connect event when the association status changes, but also trigger a notification to the upper layer when the RSSI is below or above the threshold.
Anyway, it's desireable if there is a facility to capture the registered NDIS events in user mode.
-Liang
Then set an RSSI trigger value. This value not only determines whether the signal strength (RSSI) changes, but also when a media-specific status indication happened.
These media-specific status indications are:
- Received signal strength indication.
- Authentication indication.
- Pairwise master key ID candidate indication.
- Media streaming indication.
- Radio state indication.
For RSSI indications, the buffer referenced by StatusBuffer must contain an NDIS_802_11_RSSI value.
For the other indications, the buffer referenced by StatusBuffer must contain the following structure:
typedef struct _NDIS_802_11_STATUS_INDICA TION
{
NDIS_802_11_STATUS_TYPE StatusType;
} NDIS_802_11_STATUS_INDICAT ION, *PNDIS_802_11_STATUS_INDIC ATION;
The NDIS_802_11_STATUS_TYPE enumeration has the following values:
- Ndis802_11StatusType_Authe ntication
- Ndis802_11StatusType_PMKID _Candidate List
- Ndis802_11StatusType_Media StreamMode
- Ndis802_11StatusType_Radio State
These media-specific status indications are:
- Received signal strength indication.
- Authentication indication.
- Pairwise master key ID candidate indication.
- Media streaming indication.
- Radio state indication.
For RSSI indications, the buffer referenced by StatusBuffer must contain an NDIS_802_11_RSSI value.
For the other indications, the buffer referenced by StatusBuffer must contain the following structure:
typedef struct _NDIS_802_11_STATUS_INDICA
{
NDIS_802_11_STATUS_TYPE StatusType;
} NDIS_802_11_STATUS_INDICAT
The NDIS_802_11_STATUS_TYPE enumeration has the following values:
- Ndis802_11StatusType_Authe
- Ndis802_11StatusType_PMKID
- Ndis802_11StatusType_Media
- Ndis802_11StatusType_Radio
A correction to the above. Setting an RSSI trigger value only will retrieve media-specific RSSI indications (signal strength).
To retrive Authentication, Pairwise master key ID candidate, Media streaming and Radio state indications you have to use NdisMIndicateStatus function with the GeneralStatus parameter set to NDIS_STATUS_MEDIA_SPECIFIC _INDICATIO N.
Sorry about that.
To retrive Authentication, Pairwise master key ID candidate, Media streaming and Radio state indications you have to use NdisMIndicateStatus function with the GeneralStatus parameter set to NDIS_STATUS_MEDIA_SPECIFIC
Sorry about that.
Maybe you can try IOCTL_NDISUIO_REQUEST_NOTI FICATION. This IOCTL allows the application to get adapter-related notifications. It fills in a NDISUIO_DEVICE_NOTIFICATIO N structure. This strcture is for device notification of Media State, bind/unbind, power up/down, adapter arrival/removal, etc.
ASKER
I tried to get the connection status information via the DeviceIoControl interface. However, the return value fails to be matched with the expected value: NDIS_STATUS_MEDIA_CONNECT and NDIS_STATUS_MEDIA_DISCONNE CT.
Why?
NDIS_STATUS Dot11_GetMediaConnectStatu s(
HANDLE handle )
{
UCHAR buf[1024];
NDIS_STATUS status = S_OK;
PNDISUIO_QUERY_OID pQueryOid;
DWORD dwBytesReturned;
DWORD dwError;
pQueryOid = (PNDISUIO_QUERY_OID)&buf[0 ];
pQueryOid->Oid = OID_GEN_MEDIA_CONNECT_STAT US;
if (!DeviceIoControl(
handle,
IOCTL_NDISUIO_QUERY_OID_VA LUE,
(LPVOID) &buf[0],
sizeof(buf),
(LPVOID) &buf[0],
sizeof(buf),
&dwBytesReturned,
NULL))
{
dwError = GetLastError();
DEBUGP(("IOCTL GET_MEDIA_CONNECT_STATUS failed: %d\n", dwError));
status = E_FAIL;
}
memcpy( &status, buf, sizeof(NDIS_STATUS));
if( status == NDIS_STATUS_MEDIA_CONNECT )
{
PRINTF(("media connected.\n"));
}
else if( status == NDIS_STATUS_MEDIA_DISCONNE CT )
{
PRINTF(("media disconnected.\n"));
}
else
{
PRINTF(("undefined return value.\n"));
}
return status;
}
Why?
NDIS_STATUS Dot11_GetMediaConnectStatu
HANDLE handle )
{
UCHAR buf[1024];
NDIS_STATUS status = S_OK;
PNDISUIO_QUERY_OID pQueryOid;
DWORD dwBytesReturned;
DWORD dwError;
pQueryOid = (PNDISUIO_QUERY_OID)&buf[0
pQueryOid->Oid = OID_GEN_MEDIA_CONNECT_STAT
if (!DeviceIoControl(
handle,
IOCTL_NDISUIO_QUERY_OID_VA
(LPVOID) &buf[0],
sizeof(buf),
(LPVOID) &buf[0],
sizeof(buf),
&dwBytesReturned,
NULL))
{
dwError = GetLastError();
DEBUGP(("IOCTL GET_MEDIA_CONNECT_STATUS failed: %d\n", dwError));
status = E_FAIL;
}
memcpy( &status, buf, sizeof(NDIS_STATUS));
if( status == NDIS_STATUS_MEDIA_CONNECT )
{
PRINTF(("media connected.\n"));
}
else if( status == NDIS_STATUS_MEDIA_DISCONNE
{
PRINTF(("media disconnected.\n"));
}
else
{
PRINTF(("undefined return value.\n"));
}
return status;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Liang,
i'm also trying to develop a deamon to monitor whether the Wi-Fi NIC is connected or not with Wi-Fi n/w. i want to catch the connected status and then load another C# application, and when the connection goes bad i want to pass a message to the loaded C# app. i cant go to 'rawether' library because it is commerial.
but i'm unable to understant how to start with Win DDK's NDIS. i'm not much familer with DDK. so can u explain how to monitor the Wi-Fi NIC connection status ' NDIS_STATUS_MEDIA_CONNECT' and 'NDIS_STATUS_MEDIA_DISCONN ECT' with simple example.
it is better if u can provide me a full solution of sample application as help.
thanks in advance,
netbirds@gmail.com
-netbirds-
i'm also trying to develop a deamon to monitor whether the Wi-Fi NIC is connected or not with Wi-Fi n/w. i want to catch the connected status and then load another C# application, and when the connection goes bad i want to pass a message to the loaded C# app. i cant go to 'rawether' library because it is commerial.
but i'm unable to understant how to start with Win DDK's NDIS. i'm not much familer with DDK. so can u explain how to monitor the Wi-Fi NIC connection status ' NDIS_STATUS_MEDIA_CONNECT'
it is better if u can provide me a full solution of sample application as help.
thanks in advance,
netbirds@gmail.com
-netbirds-
The OID you can use for monitoring NIC status is OID_GEN_MEDIA_CONNECT_STAT
- NdisMediaStateConnected
- NdisMediaStateDisconnected
For more information about OID_GEN_MEDIA_CONNECT_STAT
If you want to know what OIDs your device supports, please have a look to OID_GEN_SUPPORTED_LIST (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/network/hh/network/22genoid_bef9c800-d23a-44d3-bd6c-19be54f291cb.xml.asp)