How to monitor the event indication between NDIS and 802.11 NIC from user mode

Posted on 2005-04-28
Medium Priority
Last Modified: 2013-12-09
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_DISCONNECT 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!

Question by:overlook
  • 5
  • 2

Expert Comment

ID: 13890182
Hi Liang,

The OID you can use for monitoring NIC status is OID_GEN_MEDIA_CONNECT_STATUS. It works like the 802.11 Wireless LAN OIDs. The values you can get from the NIC are these:

- NdisMediaStateConnected
- NdisMediaStateDisconnected

For more information about OID_GEN_MEDIA_CONNECT_STATUS: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/network/hh/network/22genoid_3c85f327-a594-4cfc-a2c0-e320e157934f.xml.asp

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)

Author Comment

ID: 13892750
Thanks for the rapid expertise feedback.

Do you mean I can query the OID_GEN_MEDIA_CONNECT_STATUS 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.


Expert Comment

ID: 13892833
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_INDICATION
  NDIS_802_11_STATUS_TYPE  StatusType;

The NDIS_802_11_STATUS_TYPE enumeration has the following values:

- Ndis802_11StatusType_Authentication
- Ndis802_11StatusType_PMKID_CandidateList
- Ndis802_11StatusType_MediaStreamMode
- Ndis802_11StatusType_RadioState
Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.


Expert Comment

ID: 13892889
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_INDICATION.

Sorry about that.

Expert Comment

ID: 13915940
Maybe you can try IOCTL_NDISUIO_REQUEST_NOTIFICATION. This IOCTL allows the application to get adapter-related notifications. It fills in a NDISUIO_DEVICE_NOTIFICATION structure. This strcture is for device notification of Media State, bind/unbind, power up/down, adapter arrival/removal, etc.

Author Comment

ID: 13934351
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_DISCONNECT.


NDIS_STATUS                  Dot11_GetMediaConnectStatus(
      HANDLE      handle )
      UCHAR                               buf[1024];
      NDIS_STATUS                        status = S_OK;
      PNDISUIO_QUERY_OID            pQueryOid;
      DWORD                              dwBytesReturned;
      DWORD                              dwError;

      pQueryOid = (PNDISUIO_QUERY_OID)&buf[0];

      if (!DeviceIoControl(
                        (LPVOID) &buf[0],
                        (LPVOID) &buf[0],
            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_DISCONNECT )
            PRINTF(("media disconnected.\n"));
            PRINTF(("undefined return value.\n"));

      return status;

Accepted Solution

opanza earned 2000 total points
ID: 13934551
Try this:

- Initialize buf: UCHAR buf[ 1024 ] = { 0 };


- Copy pQueryOid->Data instead of buf (it doesn't really matter) and change sizeof( NDIS_STATUS ) for sizeof( NDIS_MEDIA_STATE ).
memcpy( &status, pQueryOid->Data, sizeof( NDIS_MEDIA_STATE ) );

- Then, if connected, you will have NdisMediaStateConnected. If disconnected, then you will get NdisMediaStateDisconnected.

I'm getting correctly the connection status via this OID (OID_GEN_MEDIA_CONNECT_STATUS).

Expert Comment

ID: 14506963

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_DISCONNECT' with simple example.

it is better if u can provide me a full solution of sample application as help.

thanks in advance,

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month17 days, 10 hours left to enroll

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question