diff options
Diffstat (limited to 'drivers/staging/vt6656/iwctl.c')
-rw-r--r-- | drivers/staging/vt6656/iwctl.c | 510 |
1 files changed, 316 insertions, 194 deletions
diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c index 8f19874..52fce69 100644 --- a/drivers/staging/vt6656/iwctl.c +++ b/drivers/staging/vt6656/iwctl.c @@ -31,26 +31,17 @@ */ #include "device.h" -#include "ioctl.h" -#include "iocmd.h" +#include "iwctl.h" #include "mac.h" #include "card.h" #include "hostap.h" #include "power.h" #include "rf.h" - -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT #include "iowpa.h" #include "wpactl.h" -#endif - -#include <net/iw_handler.h> +#include "control.h" +#include "rndis.h" -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT -#define SUPPORTED_WIRELESS_EXT 18 -#else -#define SUPPORTED_WIRELESS_EXT 17 -#endif static const long frequency_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484, @@ -88,9 +79,9 @@ struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev) * Wireless Handler: get protocol name */ int iwctl_giwname(struct net_device *dev, struct iw_request_info *info, - char *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { - strcpy(wrq, "802.11-a/b/g"); + strcpy(wrqu->name, "802.11-a/b/g"); return 0; } @@ -98,9 +89,10 @@ int iwctl_giwname(struct net_device *dev, struct iw_request_info *info, * Wireless Handler: set scan */ int iwctl_siwscan(struct net_device *dev, struct iw_request_info *info, - struct iw_point *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); + struct iw_point *wrq = &wrqu->data; PSMgmtObject pMgmt = &(pDevice->sMgmtObj); struct iw_scan_req *req = (struct iw_scan_req *)extra; BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; @@ -109,7 +101,10 @@ int iwctl_siwscan(struct net_device *dev, struct iw_request_info *info, if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) return -EINVAL; - PRINT_K(" SIOCSIWSCAN \n"); + PRINT_K(" SIOCSIWSCAN\n"); + + if (pMgmt == NULL) + return -EFAULT; if (pMgmt->eScanState == WMAC_IS_SCANNING) { // In scanning.. @@ -137,9 +132,9 @@ int iwctl_siwscan(struct net_device *dev, struct iw_request_info *info, pItemSSID = (PWLAN_IE_SSID)abyScanSSID; pItemSSID->byElementID = WLAN_EID_SSID; memcpy(pItemSSID->abySSID, req->essid, (int)req->essid_len); - if (pItemSSID->abySSID[req->essid_len - 1] == '\0') { + if (pItemSSID->abySSID[req->essid_len] == '\0') { if (req->essid_len > 0) - pItemSSID->len = req->essid_len - 1; + pItemSSID->len = req->essid_len; } else { pItemSSID->len = req->essid_len; } @@ -168,8 +163,9 @@ int iwctl_siwscan(struct net_device *dev, struct iw_request_info *info, * Wireless Handler : get scan results */ int iwctl_giwscan(struct net_device *dev, struct iw_request_info *info, - struct iw_point *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { + struct iw_point *wrq = &wrqu->data; int ii; int jj; int kk; @@ -184,10 +180,12 @@ int iwctl_giwscan(struct net_device *dev, struct iw_request_info *info, char *current_val = NULL; struct iw_event iwe; long ldBm; - char buf[MAX_WPA_IE_LEN * 2 + 30]; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSCAN\n"); + if (pMgmt == NULL) + return -EFAULT; + if (pMgmt->eScanState == WMAC_IS_SCANNING) { // In scanning.. return -EAGAIN; @@ -286,12 +284,6 @@ int iwctl_giwscan(struct net_device *dev, struct iw_request_info *info, if ((current_val - current_ev) > IW_EV_LCP_LEN) current_ev = current_val; - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVCUSTOM; - sprintf(buf, "bcn_int=%d", pBSS->wBeaconInterval); - iwe.u.data.length = strlen(buf); - current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, buf); - if ((pBSS->wWPALen > 0) && (pBSS->wWPALen <= MAX_WPA_IE_LEN)) { memset(&iwe, 0, sizeof(iwe)); iwe.cmd = IWEVGENIE; @@ -315,12 +307,13 @@ int iwctl_giwscan(struct net_device *dev, struct iw_request_info *info, * Wireless Handler: set frequence or channel */ int iwctl_siwfreq(struct net_device *dev, struct iw_request_info *info, - struct iw_freq *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); + struct iw_freq *wrq = &wrqu->freq; int rc = 0; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFREQ \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFREQ\n"); // If setting by frequency, convert to a channel if ((wrq->e == 1) && (wrq->m >= (int)2.412e8) && @@ -353,12 +346,17 @@ int iwctl_siwfreq(struct net_device *dev, struct iw_request_info *info, * Wireless Handler: get frequence or channel */ int iwctl_giwfreq(struct net_device *dev, struct iw_request_info *info, - struct iw_freq *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); + struct iw_freq *wrq = &wrqu->freq; PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFREQ \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFREQ\n"); + + if (pMgmt == NULL) + return -EFAULT; + #ifdef WEXT_USECHANNELS wrq->m = (int)pMgmt->uCurrChannel; @@ -379,16 +377,21 @@ int iwctl_giwfreq(struct net_device *dev, struct iw_request_info *info, * Wireless Handler: set operation mode */ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info, - __u32 *wmode, char *extra) + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); + __u32 *wmode = &wrqu->mode; PSMgmtObject pMgmt = &(pDevice->sMgmtObj); int rc = 0; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWMODE \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWMODE\n"); + + if (pMgmt == NULL) + return -EFAULT; if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP && pDevice->bEnableHostapd) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Can't set operation mode, hostapd is running \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "Can't set operation mode, hostapd is running\n"); return rc; } @@ -432,19 +435,72 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info, rc = -EINVAL; } + if (pDevice->bCommit) { + if (pMgmt->eConfigMode == WMAC_CONFIG_AP) { + netif_stop_queue(pDevice->dev); + spin_lock_irq(&pDevice->lock); + bScheduleCommand((void *) pDevice, + WLAN_CMD_RUN_AP, NULL); + spin_unlock_irq(&pDevice->lock); + } else { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "Commit the settings\n"); + + spin_lock_irq(&pDevice->lock); + + if (pDevice->bLinkPass && + memcmp(pMgmt->abyCurrSSID, + pMgmt->abyDesireSSID, + WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN)) { + bScheduleCommand((void *) pDevice, + WLAN_CMD_DISASSOCIATE, NULL); + } else { + pDevice->bLinkPass = FALSE; + pMgmt->eCurrState = WMAC_STATE_IDLE; + memset(pMgmt->abyCurrBSSID, 0, 6); + } + + ControlvMaskByte(pDevice, + MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, + LEDSTS_STS, LEDSTS_SLOW); + + netif_stop_queue(pDevice->dev); + + pMgmt->eScanType = WMAC_SCAN_ACTIVE; + + if (!pDevice->bWPASuppWextEnabled) + bScheduleCommand((void *) pDevice, + WLAN_CMD_BSSID_SCAN, + pMgmt->abyDesireSSID); + + bScheduleCommand((void *) pDevice, + WLAN_CMD_SSID, + NULL); + + spin_unlock_irq(&pDevice->lock); + } + pDevice->bCommit = FALSE; + } + + return rc; } /* * Wireless Handler: get operation mode */ -void iwctl_giwmode(struct net_device *dev, struct iw_request_info *info, - __u32 *wmode, char *extra) +int iwctl_giwmode(struct net_device *dev, struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); + __u32 *wmode = &wrqu->mode; PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWMODE \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWMODE\n"); + + if (pMgmt == NULL) + return -EFAULT; + // If not managed, assume it's ad-hoc switch (pMgmt->eConfigMode) { case WMAC_CONFIG_ESS_STA: @@ -462,14 +518,17 @@ void iwctl_giwmode(struct net_device *dev, struct iw_request_info *info, default: *wmode = IW_MODE_ADHOC; } + + return 0; } /* * Wireless Handler: get capability range */ -void iwctl_giwrange(struct net_device *dev, struct iw_request_info *info, - struct iw_point *wrq, char *extra) +int iwctl_giwrange(struct net_device *dev, struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { + struct iw_point *wrq = &wrqu->data; struct iw_range *range = (struct iw_range *)extra; int i; int k; @@ -546,7 +605,7 @@ void iwctl_giwrange(struct net_device *dev, struct iw_request_info *info, range->txpower[0] = 100; range->num_txpower = 1; range->txpower_capa = IW_TXPOW_MWATT; - range->we_version_source = SUPPORTED_WIRELESS_EXT; + range->we_version_source = WIRELESS_EXT; range->we_version_compiled = WIRELESS_EXT; range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME; range->retry_flags = IW_RETRY_LIMIT; @@ -562,20 +621,26 @@ void iwctl_giwrange(struct net_device *dev, struct iw_request_info *info, range->avg_qual.level = 176; // -80 dBm range->avg_qual.noise = 0; } + + return 0; } /* * Wireless Handler : set ap mac address */ int iwctl_siwap(struct net_device *dev, struct iw_request_info *info, - struct sockaddr *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); + struct sockaddr *wrq = &wrqu->ap_addr; PSMgmtObject pMgmt = &(pDevice->sMgmtObj); int rc = 0; BYTE ZeroBSSID[WLAN_BSSID_LEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - PRINT_K(" SIOCSIWAP \n"); + PRINT_K(" SIOCSIWAP\n"); + + if (pMgmt == NULL) + return -EFAULT; if (wrq->sa_family != ARPHRD_ETHER) { rc = -EINVAL; @@ -616,12 +681,16 @@ int iwctl_siwap(struct net_device *dev, struct iw_request_info *info, * Wireless Handler: get ap mac address */ int iwctl_giwap(struct net_device *dev, struct iw_request_info *info, - struct sockaddr *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); + struct sockaddr *wrq = &wrqu->ap_addr; PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAP \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAP\n"); + + if (pMgmt == NULL) + return -EFAULT; memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6); @@ -639,59 +708,77 @@ int iwctl_giwap(struct net_device *dev, struct iw_request_info *info, * Wireless Handler: get ap list */ int iwctl_giwaplist(struct net_device *dev, struct iw_request_info *info, - struct iw_point *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { + struct iw_point *wrq = &wrqu->data; + struct sockaddr *sock; + struct iw_quality *qual; + PSDevice pDevice = netdev_priv(dev); + PSMgmtObject pMgmt = &pDevice->sMgmtObj; + PKnownBSS pBSS = &pMgmt->sBSSList[0]; int ii; int jj; - int rc = 0; - struct sockaddr sock[IW_MAX_AP]; - struct iw_quality qual[IW_MAX_AP]; - PSDevice pDevice = netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAPLIST \n"); - // Only super-user can see AP list + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAPLIST\n"); + /* Only super-user can see AP list */ - if (!capable(CAP_NET_ADMIN)) { - rc = -EPERM; - return rc; - } + if (pBSS == NULL) + return -ENODEV; - if (wrq->pointer) { - PKnownBSS pBSS = &(pMgmt->sBSSList[0]); + if (!capable(CAP_NET_ADMIN)) + return -EPERM; - for (ii = 0, jj= 0; ii < MAX_BSS_NUM; ii++) { - pBSS = &(pMgmt->sBSSList[ii]); - if (!pBSS->bActive) - continue; - if (jj >= IW_MAX_AP) - break; - memcpy(sock[jj].sa_data, pBSS->abyBSSID, 6); - sock[jj].sa_family = ARPHRD_ETHER; - qual[jj].level = pBSS->uRSSI; - qual[jj].qual = qual[jj].noise = 0; - qual[jj].updated = 2; - jj++; - } + if (!wrq->pointer) + return -EINVAL; - wrq->flags = 1; // Should be defined - wrq->length = jj; - memcpy(extra, sock, sizeof(struct sockaddr) * jj); - memcpy(extra + sizeof(struct sockaddr) * jj, qual, sizeof(struct iw_quality) * jj); + sock = kzalloc(sizeof(struct sockaddr) * IW_MAX_AP, GFP_KERNEL); + if (sock == NULL) + return -ENOMEM; + qual = kzalloc(sizeof(struct iw_quality) * IW_MAX_AP, GFP_KERNEL); + if (qual == NULL) { + kfree(sock); + return -ENOMEM; } - return rc; + + for (ii = 0, jj = 0; ii < MAX_BSS_NUM; ii++) { + if (!pBSS[ii].bActive) + continue; + if (jj >= IW_MAX_AP) + break; + memcpy(sock[jj].sa_data, pBSS[ii].abyBSSID, 6); + sock[jj].sa_family = ARPHRD_ETHER; + qual[jj].level = pBSS[ii].uRSSI; + qual[jj].qual = qual[jj].noise = 0; + qual[jj].updated = 2; + jj++; + } + + wrq->flags = 1; /* Should be defined */ + wrq->length = jj; + memcpy(extra, sock, sizeof(struct sockaddr) * jj); + memcpy(extra + sizeof(struct sockaddr) * jj, qual, + sizeof(struct iw_quality) * jj); + + kfree(sock); + kfree(qual); + + return 0; } /* * Wireless Handler: set essid */ int iwctl_siwessid(struct net_device *dev, struct iw_request_info *info, - struct iw_point *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); + struct iw_point *wrq = &wrqu->essid; PSMgmtObject pMgmt = &(pDevice->sMgmtObj); PWLAN_IE_SSID pItemSSID; + if (pMgmt == NULL) + return -EFAULT; + if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) return -EINVAL; @@ -704,10 +791,8 @@ int iwctl_siwessid(struct net_device *dev, struct iw_request_info *info, 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 // 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); @@ -715,9 +800,9 @@ int iwctl_siwessid(struct net_device *dev, struct iw_request_info *info, pItemSSID->byElementID = WLAN_EID_SSID; memcpy(pItemSSID->abySSID, extra, wrq->length); - if (pItemSSID->abySSID[wrq->length - 1] == '\0') { + if (pItemSSID->abySSID[wrq->length] == '\0') { if (wrq->length>0) - pItemSSID->len = wrq->length - 1; + pItemSSID->len = wrq->length; } else { pItemSSID->len = wrq->length; } @@ -729,7 +814,6 @@ int iwctl_siwessid(struct net_device *dev, struct iw_request_info *info, 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) { @@ -778,7 +862,6 @@ int iwctl_siwessid(struct net_device *dev, struct iw_request_info *info, } return 0; } -#endif DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set essid = %s \n", pItemSSID->abySSID); } @@ -792,14 +875,18 @@ int iwctl_siwessid(struct net_device *dev, struct iw_request_info *info, /* * Wireless Handler: get essid */ -void iwctl_giwessid(struct net_device *dev, struct iw_request_info *info, - struct iw_point *wrq, char *extra) +int iwctl_giwessid(struct net_device *dev, struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); + struct iw_point *wrq = &wrqu->essid; PSMgmtObject pMgmt = &(pDevice->sMgmtObj); PWLAN_IE_SSID pItemSSID; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWESSID \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWESSID\n"); + + if (pMgmt == NULL) + return -EFAULT; // Note: if wrq->u.data.flags != 0, we should get the relevant // SSID from the SSID list... @@ -811,15 +898,18 @@ void iwctl_giwessid(struct net_device *dev, struct iw_request_info *info, wrq->length = pItemSSID->len; 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) + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); + struct iw_param *wrq = &wrqu->bitrate; int rc = 0; u8 brate = 0; int i; @@ -893,13 +983,18 @@ int iwctl_siwrate(struct net_device *dev, struct iw_request_info *info, /* * Wireless Handler: get data rate */ -void iwctl_giwrate(struct net_device *dev, struct iw_request_info *info, - struct iw_param *wrq, char *extra) +int iwctl_giwrate(struct net_device *dev, struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); + struct iw_param *wrq = &wrqu->bitrate; PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRATE \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRATE\n"); + + if (pMgmt == NULL) + return -EFAULT; + { BYTE abySupportedRates[13] = { 0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, @@ -932,14 +1027,18 @@ void iwctl_giwrate(struct net_device *dev, struct iw_request_info *info, if (pDevice->bFixRate == TRUE) wrq->fixed = TRUE; } + + return 0; } /* * Wireless Handler: set rts threshold */ -int iwctl_siwrts(struct net_device *dev, struct iw_param *wrq) +int iwctl_siwrts(struct net_device *dev, struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); + struct iw_param *wrq = &wrqu->rts; if ((wrq->value < 0 || wrq->value > 2312) && !wrq->disabled) return -EINVAL; @@ -956,11 +1055,12 @@ int iwctl_siwrts(struct net_device *dev, struct iw_param *wrq) * Wireless Handler: get rts */ int iwctl_giwrts(struct net_device *dev, struct iw_request_info *info, - struct iw_param *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); + struct iw_param *wrq = &wrqu->rts; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRTS \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRTS\n"); wrq->value = pDevice->wRTSThreshold; wrq->disabled = (wrq->value >= 2312); wrq->fixed = 1; @@ -971,13 +1071,14 @@ int iwctl_giwrts(struct net_device *dev, struct iw_request_info *info, * Wireless Handler: set fragment threshold */ int iwctl_siwfrag(struct net_device *dev, struct iw_request_info *info, - struct iw_param *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); + struct iw_param *wrq = &wrqu->frag; int rc = 0; int fthr = wrq->value; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFRAG \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFRAG\n"); if (wrq->disabled) fthr = 2312; @@ -994,11 +1095,12 @@ int iwctl_siwfrag(struct net_device *dev, struct iw_request_info *info, * Wireless Handler: get fragment threshold */ int iwctl_giwfrag(struct net_device *dev, struct iw_request_info *info, - struct iw_param *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); + struct iw_param *wrq = &wrqu->frag; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFRAG \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFRAG\n"); wrq->value = pDevice->wFragmentationThreshold; wrq->disabled = (wrq->value >= 2312); wrq->fixed = 1; @@ -1009,12 +1111,13 @@ int iwctl_giwfrag(struct net_device *dev, struct iw_request_info *info, * Wireless Handler: set retry threshold */ int iwctl_siwretry(struct net_device *dev, struct iw_request_info *info, - struct iw_param *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); + struct iw_param *wrq = &wrqu->retry; int rc = 0; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRETRY \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRETRY\n"); if (wrq->disabled) { rc = -EINVAL; @@ -1041,10 +1144,11 @@ int iwctl_siwretry(struct net_device *dev, struct iw_request_info *info, * Wireless Handler: get retry threshold */ int iwctl_giwretry(struct net_device *dev, struct iw_request_info *info, - struct iw_param *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRETRY \n"); + struct iw_param *wrq = &wrqu->retry; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRETRY\n"); wrq->disabled = 0; // Can't be disabled // Note: by default, display the min retry number @@ -1067,17 +1171,21 @@ int iwctl_giwretry(struct net_device *dev, struct iw_request_info *info, * Wireless Handler: set encode mode */ int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info, - struct iw_point *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - DWORD dwKeyIndex = (DWORD)(wrq->flags & IW_ENCODE_INDEX); + struct iw_point *wrq = &wrqu->encoding; + u32 dwKeyIndex = (u32)(wrq->flags & IW_ENCODE_INDEX); int ii; int uu; int rc = 0; int index = (wrq->flags & IW_ENCODE_INDEX); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODE \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODE\n"); + + if (pMgmt == NULL) + return -EFAULT; // Check the size of the key if (wrq->length > WLAN_WEP232_KEYLEN) { @@ -1155,17 +1263,17 @@ int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info, pMgmt->bShareKeyAlgorithm = FALSE; } -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT memset(pMgmt->abyDesireBSSID, 0xFF, 6); -#endif + return rc; } int iwctl_giwencode(struct net_device *dev, struct iw_request_info *info, - struct iw_point *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct iw_point *wrq = &wrqu->encoding; char abyKey[WLAN_WEP232_KEYLEN]; unsigned index = (unsigned)(wrq->flags & IW_ENCODE_INDEX); @@ -1173,6 +1281,9 @@ int iwctl_giwencode(struct net_device *dev, struct iw_request_info *info, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n"); + if (pMgmt == NULL) + return -EFAULT; + if (index > WLAN_WEP_NKEYS) return -EINVAL; if (index < 1) { // get default key @@ -1220,13 +1331,17 @@ int iwctl_giwencode(struct net_device *dev, struct iw_request_info *info, * Wireless Handler: set power mode */ int iwctl_siwpower(struct net_device *dev, struct iw_request_info *info, - struct iw_param *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct iw_param *wrq = &wrqu->power; int rc = 0; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER\n"); + + if (pMgmt == NULL) + return -EFAULT; if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) { rc = -EINVAL; @@ -1268,24 +1383,31 @@ int iwctl_siwpower(struct net_device *dev, struct iw_request_info *info, * Wireless Handler: get power mode */ int iwctl_giwpower(struct net_device *dev, struct iw_request_info *info, - struct iw_param *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct iw_param *wrq = &wrqu->power; int mode = pDevice->ePSMode; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWPOWER \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWPOWER\n"); + + if (pMgmt == NULL) + return -EFAULT; if ((wrq->disabled = (mode == WMAC_POWER_CAM))) return 0; if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) { - wrq->value = (int)((pMgmt->wListenInterval * pMgmt->wCurrBeaconPeriod) << 10); + wrq->value = (int)((pMgmt->wListenInterval * + pMgmt->wCurrBeaconPeriod) / 100); wrq->flags = IW_POWER_TIMEOUT; } else { - wrq->value = (int)((pMgmt->wListenInterval * pMgmt->wCurrBeaconPeriod) << 10); + wrq->value = (int)((pMgmt->wListenInterval * + pMgmt->wCurrBeaconPeriod) / 100); wrq->flags = IW_POWER_PERIOD; } + wrq->flags |= IW_POWER_ALL_R; return 0; } @@ -1294,12 +1416,13 @@ int iwctl_giwpower(struct net_device *dev, struct iw_request_info *info, * Wireless Handler: get Sensitivity */ int iwctl_giwsens(struct net_device *dev, struct iw_request_info *info, - struct iw_param *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); + struct iw_param *wrq = &wrqu->sens; long ldBm; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSENS \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSENS\n"); if (pDevice->bLinkPass == TRUE) { RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm); wrq->value = ldBm; @@ -1311,18 +1434,20 @@ int iwctl_giwsens(struct net_device *dev, struct iw_request_info *info, return 0; } -#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT - int iwctl_siwauth(struct net_device *dev, struct iw_request_info *info, - struct iw_param *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct iw_param *wrq = &wrqu->param; int ret = 0; static int wpa_version = 0; // must be static to save the last value, einsn liu static int pairwise = 0; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWAUTH \n"); + if (pMgmt == NULL) + return -EFAULT; + + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWAUTH\n"); switch (wrq->flags & IW_AUTH_INDEX) { case IW_AUTH_WPA_VERSION: wpa_version = wrq->value; @@ -1406,6 +1531,7 @@ int iwctl_siwauth(struct net_device *dev, struct iw_request_info *info, } break; default: + PRINT_K("iwctl_siwauth: not supported %x\n", wrq->flags); ret = -EOPNOTSUPP; break; } @@ -1413,18 +1539,22 @@ int iwctl_siwauth(struct net_device *dev, struct iw_request_info *info, } int iwctl_giwauth(struct net_device *dev, struct iw_request_info *info, - struct iw_param *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { return -EOPNOTSUPP; } int iwctl_siwgenie(struct net_device *dev, struct iw_request_info *info, - struct iw_point *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct iw_point *wrq = &wrqu->data; int ret = 0; + if (pMgmt == NULL) + return -EFAULT; + if (wrq->length){ if ((wrq->length < 2) || (extra[1] + 2 != wrq->length)) { ret = -EINVAL; @@ -1450,13 +1580,17 @@ out: // not completely ...not necessary in wpa_supplicant 0.5.8 } int iwctl_giwgenie(struct net_device *dev, struct iw_request_info *info, - struct iw_point *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct iw_point *wrq = &wrqu->data; int ret = 0; int space = wrq->length; + if (pMgmt == NULL) + return -EFAULT; + wrq->length = 0; if (pMgmt->wWPAIELen > 0) { wrq->length = pMgmt->wWPAIELen; @@ -1472,10 +1606,11 @@ int iwctl_giwgenie(struct net_device *dev, struct iw_request_info *info, } int iwctl_siwencodeext(struct net_device *dev, struct iw_request_info *info, - struct iw_point *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct iw_point *wrq = &wrqu->encoding; struct iw_encode_ext *ext = (struct iw_encode_ext*)extra; struct viawget_wpa_param *param=NULL; // original member @@ -1488,17 +1623,18 @@ int iwctl_siwencodeext(struct net_device *dev, struct iw_request_info *info, size_t seq_len = 0; size_t key_len = 0; u8 *buf; - size_t blen; u8 key_array[64]; int ret = 0; - PRINT_K("SIOCSIWENCODEEXT...... \n"); + PRINT_K("SIOCSIWENCODEEXT......\n"); - blen = sizeof(*param); - buf = kmalloc((int)blen, (int)GFP_KERNEL); + if (pMgmt == NULL) + return -EFAULT; + + buf = kzalloc(sizeof(struct viawget_wpa_param), GFP_KERNEL); if (buf == NULL) return -ENOMEM; - memset(buf, 0, blen); + param = (struct viawget_wpa_param *)buf; // recover alg_name @@ -1588,28 +1724,33 @@ int iwctl_siwencodeext(struct net_device *dev, struct iw_request_info *info, } /*******/ spin_lock_irq(&pDevice->lock); - ret = wpa_set_keys(pDevice, param, TRUE); + ret = wpa_set_keys(pDevice, param); spin_unlock_irq(&pDevice->lock); error: - kfree(param); + kfree(buf); return ret; } int iwctl_giwencodeext(struct net_device *dev, struct iw_request_info *info, - struct iw_point *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { return -EOPNOTSUPP; } int iwctl_siwmlme(struct net_device *dev, struct iw_request_info *info, - struct iw_point *wrq, char *extra) + union iwreq_data *wrqu, char *extra) { PSDevice pDevice = netdev_priv(dev); PSMgmtObject pMgmt = &(pDevice->sMgmtObj); struct iw_mlme *mlme = (struct iw_mlme *)extra; int ret = 0; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWMLME\n"); + + if (pMgmt == NULL) + return -EFAULT; + if (memcmp(pMgmt->abyCurrBSSID, mlme->addr.sa_data, ETH_ALEN)) { ret = -EINVAL; return ret; @@ -1629,81 +1770,62 @@ int iwctl_siwmlme(struct net_device *dev, struct iw_request_info *info, return ret; } -#endif +static int iwctl_config_commit(struct net_device *dev, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra) +{ + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "SIOCSIWCOMMIT\n"); + + return 0; +} static const iw_handler iwctl_handler[] = { - (iw_handler)NULL, // SIOCSIWCOMMIT - (iw_handler)NULL, // SIOCGIWNAME - (iw_handler)NULL, // SIOCSIWNWID - (iw_handler)NULL, // SIOCGIWNWID - (iw_handler)NULL, // SIOCSIWFREQ - (iw_handler)NULL, // SIOCGIWFREQ - (iw_handler)NULL, // SIOCSIWMODE - (iw_handler)NULL, // SIOCGIWMODE - (iw_handler)NULL, // SIOCSIWSENS - (iw_handler)NULL, // SIOCGIWSENS - (iw_handler)NULL, // SIOCSIWRANGE - (iw_handler)iwctl_giwrange, // SIOCGIWRANGE - (iw_handler)NULL, // SIOCSIWPRIV - (iw_handler)NULL, // SIOCGIWPRIV - (iw_handler)NULL, // SIOCSIWSTATS - (iw_handler)NULL, // SIOCGIWSTATS - (iw_handler)NULL, // SIOCSIWSPY - (iw_handler)NULL, // SIOCGIWSPY - (iw_handler)NULL, // -- hole -- - (iw_handler)NULL, // -- hole -- - (iw_handler)NULL, // SIOCSIWAP - (iw_handler)NULL, // SIOCGIWAP - (iw_handler)NULL, // -- hole -- 0x16 - (iw_handler)NULL, // SIOCGIWAPLIST - (iw_handler)iwctl_siwscan, // SIOCSIWSCAN - (iw_handler)iwctl_giwscan, // SIOCGIWSCAN - (iw_handler)NULL, // SIOCSIWESSID - (iw_handler)NULL, // SIOCGIWESSID - (iw_handler)NULL, // SIOCSIWNICKN - (iw_handler)NULL, // SIOCGIWNICKN - (iw_handler)NULL, // -- hole -- - (iw_handler)NULL, // -- hole -- - (iw_handler)NULL, // SIOCSIWRATE 0x20 - (iw_handler)NULL, // SIOCGIWRATE - (iw_handler)NULL, // SIOCSIWRTS - (iw_handler)NULL, // SIOCGIWRTS - (iw_handler)NULL, // SIOCSIWFRAG - (iw_handler)NULL, // SIOCGIWFRAG - (iw_handler)NULL, // SIOCSIWTXPOW - (iw_handler)NULL, // SIOCGIWTXPOW - (iw_handler)NULL, // SIOCSIWRETRY - (iw_handler)NULL, // SIOCGIWRETRY - (iw_handler)NULL, // SIOCSIWENCODE - (iw_handler)NULL, // SIOCGIWENCODE - (iw_handler)NULL, // SIOCSIWPOWER - (iw_handler)NULL, // SIOCGIWPOWER - (iw_handler)NULL, // -- hole -- - (iw_handler)NULL, // -- hole -- - (iw_handler)NULL, // SIOCSIWGENIE - (iw_handler)NULL, // SIOCGIWGENIE - (iw_handler)NULL, // SIOCSIWAUTH - (iw_handler)NULL, // SIOCGIWAUTH - (iw_handler)NULL, // SIOCSIWENCODEEXT - (iw_handler)NULL, // SIOCGIWENCODEEXT - (iw_handler)NULL, // SIOCSIWPMKSA - (iw_handler)NULL, // -- hole -- + IW_HANDLER(SIOCSIWCOMMIT, iwctl_config_commit), + IW_HANDLER(SIOCGIWNAME, iwctl_giwname), + IW_HANDLER(SIOCSIWFREQ, iwctl_siwfreq), + IW_HANDLER(SIOCGIWFREQ, iwctl_giwfreq), + IW_HANDLER(SIOCSIWMODE, iwctl_siwmode), + IW_HANDLER(SIOCGIWMODE, iwctl_giwmode), + IW_HANDLER(SIOCGIWSENS, iwctl_giwsens), + IW_HANDLER(SIOCGIWRANGE, iwctl_giwrange), + IW_HANDLER(SIOCSIWAP, iwctl_siwap), + IW_HANDLER(SIOCGIWAP, iwctl_giwap), + IW_HANDLER(SIOCSIWMLME, iwctl_siwmlme), + IW_HANDLER(SIOCGIWAPLIST, iwctl_giwaplist), + IW_HANDLER(SIOCSIWSCAN, iwctl_siwscan), + IW_HANDLER(SIOCGIWSCAN, iwctl_giwscan), + IW_HANDLER(SIOCSIWESSID, iwctl_siwessid), + IW_HANDLER(SIOCGIWESSID, iwctl_giwessid), + IW_HANDLER(SIOCSIWRATE, iwctl_siwrate), + IW_HANDLER(SIOCGIWRATE, iwctl_giwrate), + IW_HANDLER(SIOCSIWRTS, iwctl_siwrts), + IW_HANDLER(SIOCGIWRTS, iwctl_giwrts), + IW_HANDLER(SIOCSIWFRAG, iwctl_siwfrag), + IW_HANDLER(SIOCGIWFRAG, iwctl_giwfrag), + IW_HANDLER(SIOCSIWRETRY, iwctl_siwretry), + IW_HANDLER(SIOCGIWRETRY, iwctl_giwretry), + IW_HANDLER(SIOCSIWENCODE, iwctl_siwencode), + IW_HANDLER(SIOCGIWENCODE, iwctl_giwencode), + IW_HANDLER(SIOCSIWPOWER, iwctl_siwpower), + IW_HANDLER(SIOCGIWPOWER, iwctl_giwpower), + IW_HANDLER(SIOCSIWGENIE, iwctl_siwgenie), + IW_HANDLER(SIOCGIWGENIE, iwctl_giwgenie), + IW_HANDLER(SIOCSIWMLME, iwctl_siwmlme), + IW_HANDLER(SIOCSIWAUTH, iwctl_siwauth), + IW_HANDLER(SIOCGIWAUTH, iwctl_giwauth), + IW_HANDLER(SIOCSIWENCODEEXT, iwctl_siwencodeext), + IW_HANDLER(SIOCGIWENCODEEXT, iwctl_giwencodeext) }; static const iw_handler iwctl_private_handler[] = { NULL, // SIOCIWFIRSTPRIV }; -struct iw_priv_args iwctl_private_args[] = { - { IOCTL_CMD_SET, IW_PRIV_TYPE_CHAR | 1024, 0, "set" }, -}; - const struct iw_handler_def iwctl_handler_def = { .get_wireless_stats = &iwctl_get_wireless_stats, - .num_standard = sizeof(iwctl_handler) / sizeof(iw_handler), + .num_standard = ARRAY_SIZE(iwctl_handler), .num_private = 0, .num_private_args = 0, - .standard = (iw_handler *)iwctl_handler, + .standard = iwctl_handler, .private = NULL, .private_args = NULL, }; |