Wifi driver handling of OID_802_11_SSID set requests

Wireless Zero Configuration (WZC) will issue OID_802_11_SSID set requests to an 802.11 (Wifi) miniport driver in a couple of distinct circumstances:

  1. WZC wants the miniport adapter to associate with Access Points (APs) that match the specified SSID, or
  2. WZC wants the miniport adapter to disassociate from any/all APs

In case #2, WZC attempts to cause the disassociation by generating a random SSID that is 32 bytes long, with each byte of the SSID in the range 0x01 - 0x1F. WZC expects that the adapter will be unable to find an AP with SSID that matches the randomly generated one and thus the adapter will end up disassociated.

 It is inefficient in both time and power consumption, however, to attempt to connect to that SSID when what is desired is disassociation. Thus it would be preferable if a miniport driver detects this "special" SSID value that WZC issues in a set request and immediately disassociates rather than attempt to associate to it.

Sample code that would identify this special SSID would be something like:

     boolean
    SSIDIsValid(
      const NDIS_802_11_SSID *pSSID)
    //
    //  WZC will set the SSID to a random string of 32 invalid
    //  characters in the range 0x01 - 0x1F in order to stop
    //  an adapter from associating with any SSID.
    //
    //  Return false if the SSID is one of these special values
    //  being set by WZC.
    {
     boolean isValid = true;
     UINT    i;

      if (pSSID->SsidLength == 32)
     {
           isValid = false;
            for (i = 0; i < 32; i++)
             if (!(0 < pSSID->Ssid[i] && pSSID->Ssid[i] <= 0x1F))
                {
                   isValid = true;
                 break;
              }
       }
       return isValid;
    }

    NDIS_STATUS
    MyMiniportSSIDSetRequestHandler(
     IN NDIS_802_11_SSID *SSID)
    //
    //  Function that handles OID_802_11_SSID Set Requests
    //
    {
        boolean WantToBeConnected = SSIDIsValid(SSID);
        if (false == WantToBeConnected)
        {
            // WZC is requesting that we disassociate
            // [Insert code that disassociates]
        }
        else
        {
            // WZC is requesting that we associate with the specified SSID
            // [Insert code that handles association]
        }

    }