📄 iwctl.c
字号:
} wrq->flags = 1; // Should be define'd wrq->length = jj; memcpy(extra, sock, sizeof(struct sockaddr)*jj); memcpy(extra + sizeof(struct sockaddr)*jj, qual, sizeof(struct iw_quality)*jj); } return rc;}/* * Wireless Handler : set essid */int iwctl_siwessid(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrq, char *extra){ PSDevice pDevice = (PSDevice)dev->priv; PSMgmtObject pMgmt = &(pDevice->sMgmtObj); PWLAN_IE_SSID pItemSSID; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWESSID :\n"); // 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); printk("set essid to 'any' \n"); #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT //Unknown desired AP,so here need not associate?? return 0; #endif } 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 - 1] == '\0') { if(wrq->length>0) pItemSSID->len = wrq->length - 1; } else pItemSSID->len = wrq->length; printk("set essid to %s \n",pItemSSID->abySSID); //mike:need clear desiredBSSID if(pItemSSID->len==0) { memset(pMgmt->abyDesireBSSID, 0xFF,6); return 0; }#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT //Wext wil order another command of siwap to link with desired AP, //so here need not associate?? if(pDevice->bWPASuppWextEnabled == TRUE) { 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;}/* * Wireless Handler : get essid */int iwctl_giwessid(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrq, char *extra){ PSDevice pDevice = (PSDevice)dev->priv; PSMgmtObject pMgmt = &(pDevice->sMgmtObj); PWLAN_IE_SSID pItemSSID; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWESSID \n"); // Note : if wrq->u.data.flags != 0, we should // get the relevant SSID from the SSID list... // Get the current SSID pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; //pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID; memcpy(extra, pItemSSID->abySSID , pItemSSID->len); extra[pItemSSID->len] = '\0'; //2008-0409-03, <Add> by Einsn Liu #if WIRELESS_EXT < 21 wrq->length = pItemSSID->len + 1; #else wrq->length = pItemSSID->len; #endif wrq->flags = 1; // active return 0;}/* * Wireless Handler : set data rate */int iwctl_siwrate(struct net_device *dev, struct iw_request_info *info, struct iw_param *wrq, char *extra){ PSDevice pDevice = (PSDevice)dev->priv; int rc = 0; u8 brate = 0; int i; BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90}; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRATE \n"); if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) { rc = -EINVAL; return rc; } // First : get a valid bit rate value // Which type of value if((wrq->value < 13) && (wrq->value >= 0)) { // Setting by rate index // Find value in the magic rate table brate = wrq->value; } else { // Setting by frequency value u8 normvalue = (u8) (wrq->value/500000); // Check if rate is valid for(i = 0 ; i < 13 ; i++) { if(normvalue == abySupportedRates[i]) { brate = i; break; } } } // -1 designed the max rate (mostly auto mode) if(wrq->value == -1) { // Get the highest available rate for(i = 0 ; i < 13 ; i++) { if(abySupportedRates[i] == 0) break; } if(i != 0) brate = i - 1; } // Check that it is valid // brate is index of abySupportedRates[] if(brate > 13 ) { rc = -EINVAL; return rc; } // Now, check if we want a fixed or auto value if(wrq->fixed != 0) { // Fixed mode // One rate, fixed pDevice->bFixRate = TRUE; if ((pDevice->byBBType == BB_TYPE_11B)&& (brate > 3)) { pDevice->uConnectionRate = 3; } else { pDevice->uConnectionRate = brate; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Fixed to Rate %d \n", pDevice->uConnectionRate); } } else { pDevice->bFixRate = FALSE; pDevice->uConnectionRate = 13; } return rc;}/* * Wireless Handler : get data rate */int iwctl_giwrate(struct net_device *dev, struct iw_request_info *info, struct iw_param *wrq, char *extra){ PSDevice pDevice = (PSDevice)dev->priv; PSMgmtObject pMgmt = &(pDevice->sMgmtObj); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRATE \n"); { BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90}; int brate = 0; if (pDevice->uConnectionRate < 13) { brate = abySupportedRates[pDevice->uConnectionRate]; }else { if (pDevice->byBBType == BB_TYPE_11B) brate = 0x16; if (pDevice->byBBType == BB_TYPE_11G) brate = 0x6C; if (pDevice->byBBType == BB_TYPE_11A) brate = 0x6C; } if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { if (pDevice->byBBType == BB_TYPE_11B) brate = 0x16; if (pDevice->byBBType == BB_TYPE_11G) brate = 0x6C; if (pDevice->byBBType == BB_TYPE_11A) brate = 0x6C; } // if (pDevice->uConnectionRate == 13)// brate = abySupportedRates[pDevice->wCurrentRate]; wrq->value = brate * 500000; // If more than one rate, set auto if (pDevice->bFixRate == TRUE) wrq->fixed = TRUE; } return 0;}/* * Wireless Handler : set rts threshold */int iwctl_siwrts(struct net_device *dev, struct iw_request_info *info, struct iw_param *wrq, char *extra){ PSDevice pDevice = (PSDevice)dev->priv; int rc = 0; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRTS \n"); { int rthr = wrq->value; if(wrq->disabled) rthr = 2312; if((rthr < 0) || (rthr > 2312)) { rc = -EINVAL; }else { pDevice->wRTSThreshold = rthr; } } return 0;}/* * Wireless Handler : get rts */int iwctl_giwrts(struct net_device *dev, struct iw_request_info *info, struct iw_param *wrq, char *extra){ PSDevice pDevice = (PSDevice)dev->priv; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRTS \n"); wrq->value = pDevice->wRTSThreshold; wrq->disabled = (wrq->value >= 2312); wrq->fixed = 1; return 0;}/* * Wireless Handler : set fragment threshold */int iwctl_siwfrag(struct net_device *dev, struct iw_request_info *info, struct iw_param *wrq, char *extra){ PSDevice pDevice = (PSDevice)dev->priv; int rc = 0; int fthr = wrq->value; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFRAG \n"); if (wrq->disabled) fthr = 2312; if((fthr < 256) || (fthr > 2312)) { rc = -EINVAL; }else { fthr &= ~0x1; // Get an even value pDevice->wFragmentationThreshold = (u16)fthr; } return rc;}/* * Wireless Handler : get fragment threshold */int iwctl_giwfrag(struct net_device *dev, struct iw_request_info *info, struct iw_param *wrq, char *extra){ PSDevice pDevice = (PSDevice)dev->priv; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFRAG \n"); wrq->value = pDevice->wFragmentationThreshold; wrq->disabled = (wrq->value >= 2312); wrq->fixed = 1; return 0;}/* * Wireless Handler : set retry threshold */int iwctl_siwretry(struct net_device *dev, struct iw_request_info *info, struct iw_param *wrq, char *extra){ PSDevice pDevice = (PSDevice)dev->priv; int rc = 0; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRETRY \n"); if (wrq->disabled) { rc = -EINVAL; return rc; } if (wrq->flags & IW_RETRY_LIMIT) { if(wrq->flags & IW_RETRY_MAX) pDevice->byLongRetryLimit = wrq->value; else if (wrq->flags & IW_RETRY_MIN) pDevice->byShortRetryLimit = wrq->value; else { // No modifier : set both pDevice->byShortRetryLimit = wrq->value; pDevice->byLongRetryLimit = wrq->value; } } if (wrq->flags & IW_RETRY_LIFETIME) { pDevice->wMaxTransmitMSDULifetime = wrq->value; } return rc;}/* * Wireless Handler : get retry threshold */int iwctl_giwretry(struct net_device *dev, struct iw_request_info *info, struct iw_param *wrq, char *extra){ PSDevice pDevice = (PSDevice)dev->priv; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRETRY \n"); wrq->disabled = 0; // Can't be disabled // Note : by default, display the min retry number if((wrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) { wrq->flags = IW_RETRY_LIFETIME; wrq->value = (int)pDevice->wMaxTransmitMSDULifetime; //ms } else if((wrq->flags & IW_RETRY_MAX)) { wrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX; wrq->value = (int)pDevice->byLongRetryLimit; } else { wrq->flags = IW_RETRY_LIMIT; wrq->value = (int)pDevice->byShortRetryLimit; if((int)pDevice->byShortRetryLimit != (int)pDevice->byLongRetryLimit) wrq->flags |= IW_RETRY_MIN; } return 0;}/* * Wireless Handler : set encode mode */int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrq, char *extra){ PSDevice pDevice = (PSDevice)dev->priv; PSMgmtObject pMgmt = &(pDevice->sMgmtObj); DWORD dwKeyIndex = (DWORD)(wrq->flags & IW_ENCODE_INDEX); int ii,uu, rc = 0; int index = (wrq->flags & IW_ENCODE_INDEX); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODE \n"); // Check the size of the key if (wrq->length > WLAN_WEP232_KEYLEN) { rc = -EINVAL; return rc; } if (dwKeyIndex > WLAN_WEP_NKEYS) { rc = -EINVAL; return rc; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -