コード例 #1
0
ファイル: iwctl.c プロジェクト: 7799/linux
/*
 * Wireless Handler: set essid
 */
int iwctl_siwessid(struct net_device *dev, struct iw_request_info *info,
		union iwreq_data *wrqu, char *extra)
{
	struct vnt_private *pDevice = netdev_priv(dev);
	struct iw_point	*wrq = &wrqu->essid;
	struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
	PWLAN_IE_SSID pItemSSID;

	if (pMgmt == NULL)
		return -EFAULT;

	if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
		return -EINVAL;

	DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWESSID :\n");

	pDevice->fWPA_Authened = false;
	// Check if we asked for `any'
	if (wrq->flags == 0) {
		// Just send an empty SSID list
		memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
		memset(pMgmt->abyDesireBSSID, 0xFF, 6);
		PRINT_K("set essid to 'any'\n");
		// Unknown desired AP, so here need not associate??
		return 0;
	} else {
		// Set the SSID
		memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
		pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
		pItemSSID->byElementID = WLAN_EID_SSID;

		memcpy(pItemSSID->abySSID, extra, wrq->length);
		if (pItemSSID->abySSID[wrq->length] == '\0') {
			if (wrq->length > 0)
				pItemSSID->len = wrq->length;
		} else {
			pItemSSID->len = wrq->length;
		}
		PRINT_K("set essid to %s\n", pItemSSID->abySSID);

		// mike: need clear desiredBSSID
		if (pItemSSID->len == 0) {
			memset(pMgmt->abyDesireBSSID, 0xFF, 6);
			return 0;
		}

		// Wext wil order another command of siwap to link
		// with desired AP, so here need not associate??
		if (pDevice->bWPASuppWextEnabled == true)  {
			/*******search if  in hidden ssid mode ****/
			PKnownBSS pCurr = NULL;
			u8 abyTmpDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
			unsigned ii;
			unsigned uSameBssidNum = 0;

			memcpy(abyTmpDesireSSID, pMgmt->abyDesireSSID, sizeof(abyTmpDesireSSID));
			pCurr = BSSpSearchBSSList(pDevice, NULL,
						abyTmpDesireSSID,
						pDevice->eConfigPHYMode);

			if (pCurr == NULL) {
				PRINT_K("SIOCSIWESSID:hidden ssid site survey before associate.......\n");
				vResetCommandTimer((void *)pDevice);
				pMgmt->eScanType = WMAC_SCAN_ACTIVE;
				bScheduleCommand((void *)pDevice,
						WLAN_CMD_BSSID_SCAN,
						pMgmt->abyDesireSSID);
				bScheduleCommand((void *)pDevice,
						WLAN_CMD_SSID,
						pMgmt->abyDesireSSID);
			} else {  // mike: to find out if that desired SSID is a
				// hidden-ssid AP, by means of judging if there
				// are two same BSSID exist in list ?
				for (ii = 0; ii < MAX_BSS_NUM; ii++) {
					if (pMgmt->sBSSList[ii].bActive &&
						ether_addr_equal(pMgmt->sBSSList[ii].abyBSSID,
								 pCurr->abyBSSID)) {
						uSameBssidNum++;
					}
				}
				if (uSameBssidNum >= 2) { // hit: desired AP is in hidden ssid mode!!!
					PRINT_K("SIOCSIWESSID:hidden ssid directly associate.......\n");
					vResetCommandTimer((void *)pDevice);
					pMgmt->eScanType = WMAC_SCAN_PASSIVE; // this scan type, you'll submit scan result!
					bScheduleCommand((void *)pDevice,
							WLAN_CMD_BSSID_SCAN,
							pMgmt->abyDesireSSID);
					bScheduleCommand((void *)pDevice,
							WLAN_CMD_SSID,
							pMgmt->abyDesireSSID);
				}
			}
			return 0;
		}

		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set essid = %s\n", pItemSSID->abySSID);
	}

	if (pDevice->flags & DEVICE_FLAGS_OPENED)
		pDevice->bCommit = true;

	return 0;
}
コード例 #2
0
int iwctl_siwessid(struct net_device *dev,
             struct iw_request_info *info,
             struct iw_point *wrq,
             char *extra)
{
	PSDevice	        pDevice = (PSDevice)netdev_priv(dev);
    PSMgmtObject        pMgmt = &(pDevice->sMgmtObj);
    PWLAN_IE_SSID       pItemSSID;

  if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
        return -EINVAL;

    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWESSID :\n");

         pDevice->fWPA_Authened = FALSE;
	
	if(wrq->flags == 0) {
		
		memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
                  memset(pMgmt->abyDesireBSSID, 0xFF,6);
	    PRINT_K("set essid to 'any' \n");
           #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
             
                  return 0;
            #endif
	} else {
		
		memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
        pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
        pItemSSID->byElementID = WLAN_EID_SSID;

		memcpy(pItemSSID->abySSID, extra, wrq->length);
         if (pItemSSID->abySSID[wrq->length - 1] == '\0') {
           if(wrq->length>0)
		pItemSSID->len = wrq->length - 1;
         }
	else
	  pItemSSID->len = wrq->length;
	PRINT_K("set essid to %s \n",pItemSSID->abySSID);

     
     if(pItemSSID->len==0) {
        memset(pMgmt->abyDesireBSSID, 0xFF,6);
        return 0;
     }

#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
 
 
  if(pDevice->bWPASuppWextEnabled == TRUE)  {
        
        {
           PKnownBSS       pCurr = NULL;
           BYTE                   abyTmpDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
	  unsigned int ii, uSameBssidNum = 0;

	  memcpy(abyTmpDesireSSID,pMgmt->abyDesireSSID,sizeof(abyTmpDesireSSID));
            pCurr = BSSpSearchBSSList(pDevice,
                                      NULL,
                                      abyTmpDesireSSID,
                                      pDevice->eConfigPHYMode
                                      );

            if (pCurr == NULL){
               PRINT_K("SIOCSIWESSID:hidden ssid site survey before associate.......\n");
	      vResetCommandTimer((void *) pDevice);
	      pMgmt->eScanType = WMAC_SCAN_ACTIVE;
	      bScheduleCommand((void *) pDevice,
			       WLAN_CMD_BSSID_SCAN,
			       pMgmt->abyDesireSSID);
	      bScheduleCommand((void *) pDevice,
			       WLAN_CMD_SSID,
			       pMgmt->abyDesireSSID);
          }
	 else {  
                     
                  for (ii = 0; ii < MAX_BSS_NUM; ii++) {
                     if (pMgmt->sBSSList[ii].bActive &&
			 !compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID,
					     pCurr->abyBSSID)) {
                        uSameBssidNum++;
                     }
                  }
	     if(uSameBssidNum >= 2) {  
                 PRINT_K("SIOCSIWESSID:hidden ssid directly associate.......\n");
		 vResetCommandTimer((void *) pDevice);
	        pMgmt->eScanType = WMAC_SCAN_PASSIVE;          
		bScheduleCommand((void *) pDevice,
				 WLAN_CMD_BSSID_SCAN,
				 pMgmt->abyDesireSSID);
		bScheduleCommand((void *) pDevice,
				 WLAN_CMD_SSID,
				 pMgmt->abyDesireSSID);
	     }
	 }
        }
     return 0;
  }
	     #endif

	    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set essid = %s \n", pItemSSID->abySSID);
	}

    if (pDevice->flags & DEVICE_FLAGS_OPENED) {
	    pDevice->bCommit = TRUE;
	}


	return 0;
}