/* * Wireless Handler: get data rate */ int iwctl_giwrate(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { struct vnt_private *pDevice = netdev_priv(dev); struct iw_param *wrq = &wrqu->bitrate; struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; 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, 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; }
int FIRMWAREbBrach2Sram(struct vnt_private *pDevice) { int NdisStatus; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Branch to Sram\n"); NdisStatus = CONTROLnsRequestOut(pDevice, 1, 0x1200, 0x0000, 0, NULL); if (NdisStatus != STATUS_SUCCESS) return false; else return true; }
/* * Description: * set station flag * * Parameters: * In: * pDevice - * param - * Out: * * Return Value: * */ static int hostap_set_flags_sta(PSDevice pDevice, struct viawget_hostapd_param *param) { PSMgmtObject pMgmt = pDevice->pMgmt; unsigned int uNodeIndex; if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &uNodeIndex)) { pMgmt->sNodeDBTable[uNodeIndex].dwFlags |= param->u.set_flags_sta.flags_or; pMgmt->sNodeDBTable[uNodeIndex].dwFlags &= param->u.set_flags_sta.flags_and; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " dwFlags = %x \n", (unsigned int)pMgmt->sNodeDBTable[uNodeIndex].dwFlags); } else { return -ENOENT; } return 0; }
static int wpa_release_wpadev(PSDevice pDevice) { if (pDevice->skb) { dev_kfree_skb(pDevice->skb); pDevice->skb = NULL; } if (pDevice->wpadev) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Netdevice %s unregistered\n", pDevice->dev->name, pDevice->wpadev->name); unregister_netdev(pDevice->wpadev); free_netdev(pDevice->wpadev); pDevice->wpadev = NULL; } return 0; }
BOOL PSbConsiderPowerDown(void *hDeviceContext, BOOL bCheckRxDMA, BOOL bCheckCountToWakeUp) { PSDevice pDevice = (PSDevice)hDeviceContext; PSMgmtObject pMgmt = &(pDevice->sMgmtObj); BYTE byData; ControlvReadByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PSCTL, &byData); if ((byData & PSCTL_PS) != 0) return TRUE; if (pMgmt->eCurrMode != WMAC_MODE_IBSS_STA) { if (pMgmt->bInTIMWake) return FALSE; } if (pDevice->bCmdRunning) return FALSE; if (pDevice->bPSModeTxBurst) return FALSE; MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_PSEN); if (pMgmt->eCurrMode != WMAC_MODE_IBSS_STA) { if (bCheckCountToWakeUp && (pMgmt->wCountToWakeUp == 0 || pMgmt->wCountToWakeUp == 1)) { return FALSE; } } pDevice->bPSRxBeacon = TRUE; MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_GO2DOZE); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Go to Doze ZZZZZZZZZZZZZZZ\n"); return TRUE; }
int iwctl_giwaplist(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrq, char *extra) { int ii,jj, rc = 0; struct sockaddr sock[IW_MAX_AP]; struct iw_quality qual[IW_MAX_AP]; PSDevice pDevice = (PSDevice)netdev_priv(dev); PSMgmtObject pMgmt = &(pDevice->sMgmtObj); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAPLIST \n"); if (!capable(CAP_NET_ADMIN)) { rc = -EPERM; return rc; } if (wrq->pointer) { PKnownBSS pBSS = &(pMgmt->sBSSList[0]); 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++; } wrq->flags = 1; wrq->length = jj; memcpy(extra, sock, sizeof(struct sockaddr)*jj); memcpy(extra + sizeof(struct sockaddr)*jj, qual, sizeof(struct iw_quality)*jj); } return rc; }
int PSbSendNullPacket(struct vnt_private *pDevice) { struct vnt_tx_mgmt *pTxPacket = NULL; struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; u16 flags = 0; if (pDevice->bLinkPass == false) return false; if ((pDevice->bEnablePSMode == false) && (pDevice->fTxDataInSleep == false)) { return false; } memset(pMgmt->pbyPSPacketPool, 0, sizeof(struct vnt_tx_mgmt) + WLAN_NULLDATA_FR_MAXLEN); pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyPSPacketPool; pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket + sizeof(struct vnt_tx_mgmt)); flags = WLAN_SET_FC_FTYPE(WLAN_TYPE_DATA) | WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_NULL); if (pDevice->bEnablePSMode) flags |= WLAN_SET_FC_PWRMGT(1); else flags |= WLAN_SET_FC_PWRMGT(0); pTxPacket->p80211Header->sA3.wFrameCtl = cpu_to_le16(flags); if (pMgmt->eCurrMode != WMAC_MODE_IBSS_STA) pTxPacket->p80211Header->sA3.wFrameCtl |= cpu_to_le16((WORD)WLAN_SET_FC_TODS(1)); memcpy(pTxPacket->p80211Header->sA3.abyAddr1, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN); memcpy(pTxPacket->p80211Header->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); memcpy(pTxPacket->p80211Header->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); pTxPacket->cbMPDULen = WLAN_HDR_ADDR3_LEN; pTxPacket->cbPayloadLen = 0; /* log error if sending failed */ if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Send Null Packet failed !\n"); return false; } return true; }
/* * Wireless Handler: get Sensitivity */ int iwctl_giwsens(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { struct vnt_private *pDevice = netdev_priv(dev); struct iw_param *wrq = &wrqu->sens; long ldBm; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSENS\n"); if (pDevice->bLinkPass == true) { RFvRSSITodBm(pDevice, (u8)(pDevice->uCurrRSSI), &ldBm); wrq->value = ldBm; } else { wrq->value = 0; } wrq->disabled = (wrq->value == 0); wrq->fixed = 1; return 0; }
/* * Description: * set station flag * * Parameters: * In: * pDevice - * param - * Out: * * Return Value: * */ static int hostap_set_flags_sta(struct vnt_private *pDevice, struct viawget_hostapd_param *param) { struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; unsigned int uNodeIndex; if (BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &uNodeIndex)) { pMgmt->sNodeDBTable[uNodeIndex].dwFlags |= param->u.set_flags_sta.flags_or; pMgmt->sNodeDBTable[uNodeIndex].dwFlags &= param->u.set_flags_sta.flags_and; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " dwFlags = %x\n", (unsigned int) pMgmt->sNodeDBTable[uNodeIndex].dwFlags); } else { return -ENOENT; } return 0; }
BOOL PSbSendNullPacket(void *hDeviceContext) { PSDevice pDevice = (PSDevice)hDeviceContext; PSTxMgmtPacket pTxPacket = NULL; PSMgmtObject pMgmt = &(pDevice->sMgmtObj); u16 flags = 0; if (pDevice->bLinkPass == FALSE) return FALSE; if ((pDevice->bEnablePSMode == FALSE) && (pDevice->fTxDataInSleep == FALSE)) { return FALSE; } memset(pMgmt->pbyPSPacketPool, 0, sizeof(STxMgmtPacket) + WLAN_NULLDATA_FR_MAXLEN); pTxPacket = (PSTxMgmtPacket)pMgmt->pbyPSPacketPool; pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); flags = WLAN_SET_FC_FTYPE(WLAN_TYPE_DATA) | WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_NULL); if (pDevice->bEnablePSMode) flags |= WLAN_SET_FC_PWRMGT(1); else flags |= WLAN_SET_FC_PWRMGT(0); pTxPacket->p80211Header->sA3.wFrameCtl = cpu_to_le16(flags); if (pMgmt->eCurrMode != WMAC_MODE_IBSS_STA) pTxPacket->p80211Header->sA3.wFrameCtl |= cpu_to_le16((WORD)WLAN_SET_FC_TODS(1)); memcpy(pTxPacket->p80211Header->sA3.abyAddr1, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN); memcpy(pTxPacket->p80211Header->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); memcpy(pTxPacket->p80211Header->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); pTxPacket->cbMPDULen = WLAN_HDR_ADDR3_LEN; pTxPacket->cbPayloadLen = 0; if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Send Null Packet failed !\n"); return FALSE; } return TRUE; }
int PSbConsiderPowerDown(struct vnt_private *pDevice, int bCheckRxDMA, int bCheckCountToWakeUp) { struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; u8 byData; /* check if already in Doze mode */ ControlvReadByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PSCTL, &byData); if ((byData & PSCTL_PS) != 0) return true; if (pMgmt->eCurrMode != WMAC_MODE_IBSS_STA) { /* check if in TIM wake period */ if (pMgmt->bInTIMWake) return false; } /* check scan state */ if (pDevice->bCmdRunning) return false; /* Tx Burst */ if (pDevice->bPSModeTxBurst) return false; /* Froce PSEN on */ MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_PSEN); if (pMgmt->eCurrMode != WMAC_MODE_IBSS_STA) { if (bCheckCountToWakeUp && (pMgmt->wCountToWakeUp == 0 || pMgmt->wCountToWakeUp == 1)) { return false; } } pDevice->bPSRxBeacon = true; /* no Tx, no Rx isr, now go to Doze */ MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_GO2DOZE); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Go to Doze ZZZZZZZZZZZZZZZ\n"); return true; }
bool brain::dbg_br_compute_binary(row_neuron_t& neus){ #ifdef FULL_DEBUG long ii; for(ii = 0; ii < neus.size(); ii++){ BRAIN_CK(neus[ii] != NULL_PT); neuron& neu = *(neus[ii]); if(! neu.ne_original){ continue; } if(!(neu.is_ne_inert())){ DBG_PRT(24, os << "FAILED compute neu=" << &(neu)); return false; } } #endif return true; }
void INTnsProcessData(PSDevice pDevice) { PSINTData pINTData; PSMgmtObject pMgmt = &(pDevice->sMgmtObj); struct net_device_stats *pStats = &pDevice->stats; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsInterruptProcessData\n"); pINTData = (PSINTData) pDevice->intBuf.pDataBuf; if (pINTData->byTSR0 & TSR_VALID) { STAvUpdateTDStatCounter(&(pDevice->scStatistic), (BYTE)(pINTData->byPkt0 & 0x0F), (BYTE)(pINTData->byPkt0>>4), pINTData->byTSR0); BSSvUpdateNodeTxCounter(pDevice, &(pDevice->scStatistic), pINTData->byTSR0, pINTData->byPkt0); /*DBG_PRN_GRP01(("TSR0 %02x\n", pINTData->byTSR0));*/ }
/* * Wireless Handler: set fragment threshold */ int iwctl_siwfrag(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { struct vnt_private *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"); 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; }
/* * initrd_get_addr() * Compute a starting address for the initial RAMdisk image. * For now we suggest 'initrd_addr_max' with room for 32MB, * as image->pgcnt is not initialized yet. */ INTN sysdeps_initrd_get_addr(kdesc_t *kd, memdesc_t *imem) { DBG_PRT((L"initrd_get_addr()\n")); if (!kd || !imem) { ERR_PRT((L"kd="PTR_FMT" imem="PTR_FMT"", kd, imem)); return -1; } VERB_PRT(3, Print(L"initrd_addr_max="PTR_FMT" reserve=%d\n", param_start->s.initrd_addr_max, 32*MB)); imem->start_addr = (VOID *) (((UINT64)param_start->s.initrd_addr_max - 32*MB + 1) & ~EFI_PAGE_MASK); VERB_PRT(3, Print(L"initrd start_addr="PTR_FMT" pgcnt=%d\n", imem->start_addr, imem->pgcnt)); return 0; }
void iwctl_giwrate(struct net_device *dev, struct iw_request_info *info, struct iw_param *wrq, char *extra) { PSDevice pDevice = (PSDevice)netdev_priv(dev); 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 (pDevice->bFixRate == TRUE) wrq->fixed = TRUE; } }
BOOL KeybGetKey ( IN PSKeyManagement pTable, IN PBYTE pbyBSSID, IN DWORD dwKeyIndex, OUT PSKeyItem *pKey ) { int i; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybGetKey() \n"); *pKey = NULL; for (i=0;i<MAX_KEY_TABLE;i++) { if ((pTable->KeyTable[i].bInUse == TRUE) && IS_ETH_ADDRESS_EQUAL(pTable->KeyTable[i].abyBSSID,pbyBSSID)) { if (dwKeyIndex == 0xFFFFFFFF) { if (pTable->KeyTable[i].PairwiseKey.bKeyValid == TRUE) { *pKey = &(pTable->KeyTable[i].PairwiseKey); return (TRUE); } else { return (FALSE); } } else if (dwKeyIndex < MAX_GROUP_KEY) { if (pTable->KeyTable[i].GroupKey[dwKeyIndex].bKeyValid == TRUE) { *pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex]); return (TRUE); } else { return (FALSE); } } else { return (FALSE); } } } return (FALSE); }
int iwctl_giwsens(struct net_device *dev, struct iw_request_info *info, struct iw_param *wrq, char *extra) { PSDevice pDevice = (PSDevice)netdev_priv(dev); long ldBm; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSENS \n"); if (pDevice->bLinkPass == TRUE) { RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm); wrq->value = ldBm; } else { wrq->value = 0; }; wrq->disabled = (wrq->value == 0); wrq->fixed = 1; return 0; }
static bool device_init_defrag_cb(struct vnt_private *pDevice) { int i; PSDeFragControlBlock pDeF; /* Init the fragment ctl entries */ for (i = 0; i < CB_MAX_RX_FRAG; i++) { pDeF = &(pDevice->sRxDFCB[i]); if (!device_alloc_frag_buf(pDevice, pDeF)) { DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc frag bufs\n", pDevice->dev->name); goto free_frag; } } pDevice->cbDFCB = CB_MAX_RX_FRAG; pDevice->cbFreeDFCB = pDevice->cbDFCB; return true; free_frag: device_free_frag_bufs(pDevice); return false; }
/* * Description: Get Key from table * * Parameters: * In: * pTable - Pointer to Key table * pbyBSSID - BSSID of Key * dwKeyIndex - Key Index (0xFFFFFFFF means pairwise key) * Out: * pKey - Key return * * Return Value: true if found otherwise false * */ bool KeybGetKey ( PSKeyManagement pTable, unsigned char *pbyBSSID, unsigned long dwKeyIndex, PSKeyItem *pKey ) { int i; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybGetKey() \n"); *pKey = NULL; for (i=0;i<MAX_KEY_TABLE;i++) { if ((pTable->KeyTable[i].bInUse == true) && !compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { if (dwKeyIndex == 0xFFFFFFFF) { if (pTable->KeyTable[i].PairwiseKey.bKeyValid == true) { *pKey = &(pTable->KeyTable[i].PairwiseKey); return (true); } else { return (false); } } else if (dwKeyIndex < MAX_GROUP_KEY) { if (pTable->KeyTable[i].GroupKey[dwKeyIndex].bKeyValid == true) { *pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex]); return (true); } else { return (false); } } else { return (false); } } } return (false); }
void vMgrDecodeProbeRequest( PWLAN_FR_PROBEREQ pFrame ) { PWLAN_IE pItem; pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; // Information elements pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))); while( ((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len) ) { switch (pItem->byElementID) { case WLAN_EID_SSID: if (pFrame->pSSID == NULL) pFrame->pSSID = (PWLAN_IE_SSID)pItem; break; case WLAN_EID_SUPP_RATES: if (pFrame->pSuppRates == NULL) pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem; break; case WLAN_EID_EXTSUPP_RATES: if (pFrame->pExtSuppRates == NULL) pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; break; default: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in probereq\n", pItem->byElementID); break; } pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len); } return; }
int iwctl_siwrts(struct net_device *dev, struct iw_request_info *info, struct iw_param *wrq, char *extra) { PSDevice pDevice = (PSDevice)netdev_priv(dev); 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; }
void iwctl_giwessid(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; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWESSID \n"); pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; memcpy(extra, pItemSSID->abySSID , pItemSSID->len); extra[pItemSSID->len] = '\0'; wrq->length = pItemSSID->len; wrq->flags = 1; }
BOOL FIRMWAREbBrach2Sram( PSDevice pDevice ) { int NdisStatus; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Branch to Sram\n"); NdisStatus = CONTROLnsRequestOut(pDevice, 1, 0x1200, 0x0000, 0, NULL ); if (NdisStatus != STATUS_SUCCESS) { return (FALSE); } else { return (TRUE); } }
/* * Wireless Handler: get ap mac address */ int iwctl_giwap(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { struct vnt_private *pDevice = netdev_priv(dev); struct sockaddr *wrq = &wrqu->ap_addr; struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAP\n"); if (pMgmt == NULL) return -EFAULT; memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6); if ((pDevice->bLinkPass == false) && (pMgmt->eCurrMode != WMAC_MODE_ESS_AP)) memset(wrq->sa_data, 0, 6); if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6); wrq->sa_family = ARPHRD_ETHER; return 0; }
/* * Wireless Handler: get retry threshold */ int iwctl_giwretry(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { struct vnt_private *pDevice = netdev_priv(dev); 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 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; }
void brain::dbg_check_sat_assig(){ #ifdef FULL_DEBUG row_quanton_t& the_assig = br_tmp_assig_quantons; if(the_assig.is_empty()){ br_charge_trail.get_all_ordered_quantons(the_assig); } row_neuron_t& neus = br_tmp_ck_sat_neus; fill_with_origs(neus); if(! dbg_br_compute_binary(neus)){ abort_func(1, "FATAL ERROR 001. Wrong is_sat answer !"); } if(! dbg_br_compute_ck_sat_of(neus, the_assig)){ abort_func(1, "FATAL ERROR 002. Wrong is_sat answer !"); } DBG_PRT(36, os << "CHECKED_ASSIG=" << the_assig << bj_eol); //print_satifying(cho_nm); #endif }
int iwctl_siwfrag(struct net_device *dev, struct iw_request_info *info, struct iw_param *wrq, char *extra) { PSDevice pDevice = (PSDevice)netdev_priv(dev); 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; pDevice->wFragmentationThreshold = (u16)fthr; } return rc; }
int private_ioctl(PSDevice pDevice, struct ifreq *rq) { PSCmdRequest pReq = (PSCmdRequest)rq; PSMgmtObject pMgmt = &(pDevice->sMgmtObj); int result = 0; PWLAN_IE_SSID pItemSSID; SCmdBSSJoin sJoinCmd; SCmdZoneTypeSet sZoneTypeCmd; SCmdScan sScanCmd; SCmdStartAP sStartAPCmd; SCmdSetWEP sWEPCmd; SCmdValue sValue; SBSSIDList sList; SNodeList sNodeList; PSBSSIDList pList; PSNodeList pNodeList; unsigned int cbListCount; PKnownBSS pBSS; PKnownNodeDB pNode; unsigned int ii, jj; SCmdLinkStatus sLinkStatus; BYTE abySuppRates[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16}; BYTE abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; DWORD dwKeyIndex= 0; BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; signed long ldBm; pReq->wResult = 0; switch(pReq->wCmdCode) { case WLAN_CMD_BSS_SCAN: if (copy_from_user(&sScanCmd, pReq->data, sizeof(SCmdScan))) { result = -EFAULT; break; } pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid; if (pItemSSID->len != 0) { memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); memcpy(abyScanSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); } spin_lock_irq(&pDevice->lock); if (memcmp(pMgmt->abyCurrBSSID, &abyNullAddr[0], 6) == 0) BSSvClearBSSList((void *) pDevice, FALSE); else BSSvClearBSSList((void *) pDevice, pDevice->bLinkPass); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_BSS_SCAN..begin\n"); if (pItemSSID->len != 0) bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID); else bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL); spin_unlock_irq(&pDevice->lock); break; case WLAN_CMD_ZONETYPE_SET: //mike add :cann't support. result=-EOPNOTSUPP; break; if (copy_from_user(&sZoneTypeCmd, pReq->data, sizeof(SCmdZoneTypeSet))) { result = -EFAULT; break; } if(sZoneTypeCmd.bWrite==TRUE) { //////write zonetype if(sZoneTypeCmd.ZoneType == ZoneType_USA) { //set to USA printk("set_ZoneType:USA\n"); } else if(sZoneTypeCmd.ZoneType == ZoneType_Japan) { //set to Japan printk("set_ZoneType:Japan\n"); } else if(sZoneTypeCmd.ZoneType == ZoneType_Europe) { //set to Europe printk("set_ZoneType:Europe\n"); } } else { ///////read zonetype BYTE zonetype=0; if(zonetype == 0x00) { //USA sZoneTypeCmd.ZoneType = ZoneType_USA; } else if(zonetype == 0x01) { //Japan sZoneTypeCmd.ZoneType = ZoneType_Japan; } else if(zonetype == 0x02) { //Europe sZoneTypeCmd.ZoneType = ZoneType_Europe; } else { //Unknown ZoneType printk("Error:ZoneType[%x] Unknown ???\n",zonetype); result = -EFAULT; break; } if (copy_to_user(pReq->data, &sZoneTypeCmd, sizeof(SCmdZoneTypeSet))) { result = -EFAULT; break; } } break; case WLAN_CMD_BSS_JOIN: if (copy_from_user(&sJoinCmd, pReq->data, sizeof(SCmdBSSJoin))) { result = -EFAULT; break; } pItemSSID = (PWLAN_IE_SSID)sJoinCmd.ssid; memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); if (sJoinCmd.wBSSType == ADHOC) { pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to adhoc mode\n"); } else { pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to STA mode\n"); } if (sJoinCmd.bPSEnable == TRUE) { pDevice->ePSMode = WMAC_POWER_FAST; // pDevice->ePSMode = WMAC_POWER_MAX; pMgmt->wListenInterval = 2; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving On\n"); } else { pDevice->ePSMode = WMAC_POWER_CAM; pMgmt->wListenInterval = 1; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving Off \n"); } if (sJoinCmd.bShareKeyAuth == TRUE){ pMgmt->bShareKeyAlgorithm = TRUE; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key \n"); } else { pMgmt->bShareKeyAlgorithm = FALSE; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System \n"); } pDevice->uChannel = sJoinCmd.uChannel; netif_stop_queue(pDevice->dev); spin_lock_irq(&pDevice->lock); pMgmt->eCurrState = WMAC_STATE_IDLE; bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID); bScheduleCommand((void *) pDevice, WLAN_CMD_SSID, NULL); spin_unlock_irq(&pDevice->lock); break; case WLAN_CMD_SET_WEP: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WEP Key. \n"); memset(&sWEPCmd, 0 ,sizeof(SCmdSetWEP)); if (copy_from_user(&sWEPCmd, pReq->data, sizeof(SCmdSetWEP))) { result = -EFAULT; break; } if (sWEPCmd.bEnableWep != TRUE) { int uu; pDevice->bEncryptionEnable = FALSE; pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; spin_lock_irq(&pDevice->lock); for (uu = 0; uu < MAX_KEY_TABLE; uu++) MACvDisableKeyEntry(pDevice, uu); spin_unlock_irq(&pDevice->lock); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WEP function disable.\n"); break; } for (ii = 0; ii < WLAN_WEP_NKEYS; ii ++) { if (sWEPCmd.bWepKeyAvailable[ii]) { if (ii == sWEPCmd.byKeyIndex) //2006-1207-01<Modify>by Einsn Liu // dwKeyIndex|= (1 << 31); dwKeyIndex=ii|(1 << 31); else dwKeyIndex = ii; spin_lock_irq(&pDevice->lock); KeybSetDefaultKey( pDevice, &(pDevice->sKey), dwKeyIndex, sWEPCmd.auWepKeyLength[ii], NULL, (PBYTE)&sWEPCmd.abyWepKey[ii][0], KEY_CTL_WEP ); spin_unlock_irq(&pDevice->lock); } } pDevice->byKeyIndex = sWEPCmd.byKeyIndex; pDevice->bTransmitKey = TRUE; pDevice->bEncryptionEnable = TRUE; pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; break; case WLAN_CMD_GET_LINK: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_GET_LINK status. \n"); memset(sLinkStatus.abySSID, 0 , WLAN_SSID_MAXLEN + 1); if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) sLinkStatus.wBSSType = ADHOC; else sLinkStatus.wBSSType = INFRA; if (pMgmt->eCurrState == WMAC_STATE_JOINTED) sLinkStatus.byState = ADHOC_JOINTED; else sLinkStatus.byState = ADHOC_STARTED; sLinkStatus.uChannel = pMgmt->uCurrChannel; if (pDevice->bLinkPass == TRUE) { sLinkStatus.bLink = TRUE; pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; memcpy(sLinkStatus.abySSID, pItemSSID->abySSID, pItemSSID->len); memcpy(sLinkStatus.abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); sLinkStatus.uLinkRate = pMgmt->sNodeDBTable[0].wTxDataRate; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Link Success ! \n"); } else { sLinkStatus.bLink = FALSE; } if (copy_to_user(pReq->data, &sLinkStatus, sizeof(SCmdLinkStatus))) { result = -EFAULT; break; } break; case WLAN_CMD_GET_LISTLEN: cbListCount = 0; pBSS = &(pMgmt->sBSSList[0]); for (ii = 0; ii < MAX_BSS_NUM; ii++) { pBSS = &(pMgmt->sBSSList[ii]); if (!pBSS->bActive) continue; cbListCount++; } sList.uItem = cbListCount; if (copy_to_user(pReq->data, &sList, sizeof(SBSSIDList))) { result = -EFAULT; break; } pReq->wResult = 0; break; case WLAN_CMD_GET_LIST: if (copy_from_user(&sList, pReq->data, sizeof(SBSSIDList))) { result = -EFAULT; break; } pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), (int)GFP_ATOMIC); if (pList == NULL) { result = -ENOMEM; break; } pList->uItem = sList.uItem; pBSS = &(pMgmt->sBSSList[0]); for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) { pBSS = &(pMgmt->sBSSList[jj]); if (pBSS->bActive) { pList->sBSSIDList[ii].uChannel = pBSS->uChannel; pList->sBSSIDList[ii].wBeaconInterval = pBSS->wBeaconInterval; pList->sBSSIDList[ii].wCapInfo = pBSS->wCapInfo; RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm); pList->sBSSIDList[ii].uRSSI = (unsigned int) ldBm; // pList->sBSSIDList[ii].uRSSI = pBSS->uRSSI; memcpy(pList->sBSSIDList[ii].abyBSSID, pBSS->abyBSSID, WLAN_BSSID_LEN); pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID; memset(pList->sBSSIDList[ii].abySSID, 0, WLAN_SSID_MAXLEN + 1); memcpy(pList->sBSSIDList[ii].abySSID, pItemSSID->abySSID, pItemSSID->len); if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) { pList->sBSSIDList[ii].byNetType = INFRA; } else { pList->sBSSIDList[ii].byNetType = ADHOC; } if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) { pList->sBSSIDList[ii].bWEPOn = TRUE; } else { pList->sBSSIDList[ii].bWEPOn = FALSE; } ii ++; if (ii >= pList->uItem) break; } } if (copy_to_user(pReq->data, pList, sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)))) { result = -EFAULT; break; } kfree(pList); pReq->wResult = 0; break; case WLAN_CMD_GET_MIB: if (copy_to_user(pReq->data, &(pDevice->s802_11Counter), sizeof(SDot11MIBCount))) { result = -EFAULT; break; } break; case WLAN_CMD_GET_STAT: if (copy_to_user(pReq->data, &(pDevice->scStatistic), sizeof(SStatCounter))) { result = -EFAULT; break; } break; case WLAN_CMD_STOP_MAC: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_STOP_MAC\n"); // Todo xxxxxx netif_stop_queue(pDevice->dev); spin_lock_irq(&pDevice->lock); if (pDevice->bRadioOff == FALSE) { CARDbRadioPowerOff(pDevice); } pDevice->bLinkPass = FALSE; ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW); memset(pMgmt->abyCurrBSSID, 0, 6); pMgmt->eCurrState = WMAC_STATE_IDLE; // del_timer(&pDevice->sTimerCommand); // del_timer(&pMgmt->sTimerSecondCallback); pDevice->bCmdRunning = FALSE; spin_unlock_irq(&pDevice->lock); break; case WLAN_CMD_START_MAC: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_START_MAC\n"); // Todo xxxxxxx if (pDevice->bRadioOff == TRUE) CARDbRadioPowerOn(pDevice); break; case WLAN_CMD_SET_HOSTAPD: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD\n"); if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { result = -EFAULT; break; } if (sValue.dwValue == 1) { if (vt6656_hostap_set_hostapd(pDevice, 1, 1) == 0){ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HOSTAP\n"); } else { result = -EFAULT; break; } } else { vt6656_hostap_set_hostapd(pDevice, 0, 1); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HOSTAP\n"); } break; case WLAN_CMD_SET_HOSTAPD_STA: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD_STA\n"); break; case WLAN_CMD_SET_802_1X: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_802_1X\n"); if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { result = -EFAULT; break; } if (sValue.dwValue == 1) { pDevice->bEnable8021x = TRUE; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable 802.1x\n"); } else { pDevice->bEnable8021x = FALSE; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable 802.1x\n"); } break; case WLAN_CMD_SET_HOST_WEP: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOST_WEP\n"); if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { result = -EFAULT; break; } if (sValue.dwValue == 1) { pDevice->bEnableHostWEP = TRUE; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HostWEP\n"); } else { pDevice->bEnableHostWEP = FALSE; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HostWEP\n"); } break; case WLAN_CMD_SET_WPA: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WPA\n"); if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) { result = -EFAULT; break; } if (sValue.dwValue == 1) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "up wpadev\n"); memcpy(pDevice->wpadev->dev_addr, pDevice->dev->dev_addr, ETH_ALEN); pDevice->bWPADEVUp = TRUE; } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "close wpadev\n"); pDevice->bWPADEVUp = FALSE; } break; case WLAN_CMD_AP_START: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_AP_START\n"); if (pDevice->bRadioOff == TRUE) { CARDbRadioPowerOn(pDevice); add_timer(&pMgmt->sTimerSecondCallback); } if (copy_from_user(&sStartAPCmd, pReq->data, sizeof(SCmdStartAP))) { result = -EFAULT; break; } if (sStartAPCmd.wBSSType == AP) { pMgmt->eConfigMode = WMAC_CONFIG_AP; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to AP mode\n"); } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct BSS type not set to AP mode\n"); result = -EFAULT; break; } if (sStartAPCmd.wBBPType == PHY80211g) { pMgmt->byAPBBType = PHY_TYPE_11G; } else if (sStartAPCmd.wBBPType == PHY80211a) { pMgmt->byAPBBType = PHY_TYPE_11A; } else { pMgmt->byAPBBType = PHY_TYPE_11B; } pItemSSID = (PWLAN_IE_SSID)sStartAPCmd.ssid; memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); if ((sStartAPCmd.uChannel > 0)&&(sStartAPCmd.uChannel <= 14)) pDevice->uChannel = sStartAPCmd.uChannel; if ((sStartAPCmd.uBeaconInt >= 20) && (sStartAPCmd.uBeaconInt <= 1000)) pMgmt->wIBSSBeaconPeriod = sStartAPCmd.uBeaconInt; else pMgmt->wIBSSBeaconPeriod = 100; if (sStartAPCmd.bShareKeyAuth == TRUE){ pMgmt->bShareKeyAlgorithm = TRUE; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key \n"); } else { pMgmt->bShareKeyAlgorithm = FALSE; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System \n"); } memcpy(pMgmt->abyIBSSSuppRates, abySuppRates, 6); if (sStartAPCmd.byBasicRate & BIT3) { pMgmt->abyIBSSSuppRates[2] |= BIT7; pMgmt->abyIBSSSuppRates[3] |= BIT7; pMgmt->abyIBSSSuppRates[4] |= BIT7; pMgmt->abyIBSSSuppRates[5] |= BIT7; }else if (sStartAPCmd.byBasicRate & BIT2) { pMgmt->abyIBSSSuppRates[2] |= BIT7; pMgmt->abyIBSSSuppRates[3] |= BIT7; pMgmt->abyIBSSSuppRates[4] |= BIT7; }else if (sStartAPCmd.byBasicRate & BIT1) { pMgmt->abyIBSSSuppRates[2] |= BIT7; pMgmt->abyIBSSSuppRates[3] |= BIT7; }else if (sStartAPCmd.byBasicRate & BIT1) { pMgmt->abyIBSSSuppRates[2] |= BIT7; }else { //default 1,2M pMgmt->abyIBSSSuppRates[2] |= BIT7; pMgmt->abyIBSSSuppRates[3] |= BIT7; } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Support Rate= %x %x %x %x\n", pMgmt->abyIBSSSuppRates[2], pMgmt->abyIBSSSuppRates[3], pMgmt->abyIBSSSuppRates[4], pMgmt->abyIBSSSuppRates[5] ); netif_stop_queue(pDevice->dev); spin_lock_irq(&pDevice->lock); bScheduleCommand((void *) pDevice, WLAN_CMD_RUN_AP, NULL); spin_unlock_irq(&pDevice->lock); break; case WLAN_CMD_GET_NODE_CNT: cbListCount = 0; pNode = &(pMgmt->sNodeDBTable[0]); for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) { pNode = &(pMgmt->sNodeDBTable[ii]); if (!pNode->bActive) continue; cbListCount++; } sNodeList.uItem = cbListCount; if (copy_to_user(pReq->data, &sNodeList, sizeof(SNodeList))) { result = -EFAULT; break; } pReq->wResult = 0; break; case WLAN_CMD_GET_NODE_LIST: if (copy_from_user(&sNodeList, pReq->data, sizeof(SNodeList))) { result = -EFAULT; break; } pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC); if (pNodeList == NULL) { result = -ENOMEM; break; } pNodeList->uItem = sNodeList.uItem; pNode = &(pMgmt->sNodeDBTable[0]); for (ii = 0, jj = 0; ii < (MAX_NODE_NUM + 1); ii++) { pNode = &(pMgmt->sNodeDBTable[ii]); if (pNode->bActive) { pNodeList->sNodeList[jj].wAID = pNode->wAID; memcpy(pNodeList->sNodeList[jj].abyMACAddr, pNode->abyMACAddr, WLAN_ADDR_LEN); pNodeList->sNodeList[jj].wTxDataRate = pNode->wTxDataRate; pNodeList->sNodeList[jj].wInActiveCount = (WORD)pNode->uInActiveCount; pNodeList->sNodeList[jj].wEnQueueCnt = (WORD)pNode->wEnQueueCnt; pNodeList->sNodeList[jj].wFlags = (WORD)pNode->dwFlags; pNodeList->sNodeList[jj].bPWBitOn = pNode->bPSEnable; pNodeList->sNodeList[jj].byKeyIndex = pNode->byKeyIndex; pNodeList->sNodeList[jj].wWepKeyLength = pNode->uWepKeyLength; memcpy(&(pNodeList->sNodeList[jj].abyWepKey[0]), &(pNode->abyWepKey[0]), WEP_KEYMAXLEN); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "key= %2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", pNodeList->sNodeList[jj].abyWepKey[0], pNodeList->sNodeList[jj].abyWepKey[1], pNodeList->sNodeList[jj].abyWepKey[2], pNodeList->sNodeList[jj].abyWepKey[3], pNodeList->sNodeList[jj].abyWepKey[4] ); pNodeList->sNodeList[jj].bIsInFallback = pNode->bIsInFallback; pNodeList->sNodeList[jj].uTxFailures = pNode->uTxFailures; pNodeList->sNodeList[jj].uTxAttempts = pNode->uTxAttempts; pNodeList->sNodeList[jj].wFailureRatio = (WORD)pNode->uFailureRatio; jj ++; if (jj >= pNodeList->uItem) break; } } if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) { result = -EFAULT; break; } kfree(pNodeList); pReq->wResult = 0; break; case 0xFF: memset(wpa_Result.ifname,0,sizeof(wpa_Result.ifname)); wpa_Result.proto = 0; wpa_Result.key_mgmt = 0; wpa_Result.eap_type = 0; wpa_Result.authenticated = FALSE; pDevice->fWPA_Authened = FALSE; if (copy_from_user(&wpa_Result, pReq->data, sizeof(wpa_Result))) { result = -EFAULT; break; } //DavidWang for some AP maybe good authenticate if(wpa_Result.key_mgmt==0x20) pMgmt->Cisco_cckm =1; else pMgmt->Cisco_cckm =0; if(wpa_Result.authenticated==TRUE) { { union iwreq_data wrqu; pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; memset(&wrqu, 0, sizeof(wrqu)); wrqu.data.flags = RT_WPACONNECTED_EVENT_FLAG; wrqu.data.length =pItemSSID->len; wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, pItemSSID->abySSID); } pDevice->fWPA_Authened = TRUE; //is successful peer to wpa_Result.authenticated? } //printk("get private wpa_supplicant announce WPA SM\n"); //printk("wpa-->ifname=%s\n",wpa_Result.ifname); //printk("wpa-->proto=%d\n",wpa_Result.proto); //printk("wpa-->key-mgmt=%d\n",wpa_Result.key_mgmt); //printk("wpa-->eap_type=%d\n",wpa_Result.eap_type); //printk("wpa-->authenticated is %s\n",(wpa_Result.authenticated==TRUE)?"TRUE":"FALSE"); pReq->wResult = 0; break; default: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Private command not support..\n"); } return result; }
/* * Description: Set Key to table * * Parameters: * In: * pTable - Pointer to Key table * dwKeyIndex - Key index (reference to NDIS DDK) * uKeyLength - Key length * KeyRSC - Key RSC * pbyKey - Pointer to key * Out: * none * * Return Value: TRUE if success otherwise FALSE * */ BOOL KeybSetAllGroupKey( void *pDeviceHandler, PSKeyManagement pTable, DWORD dwKeyIndex, unsigned long uKeyLength, PQWORD pKeyRSC, PBYTE pbyKey, BYTE byKeyDecMode ) { PSDevice pDevice = (PSDevice) pDeviceHandler; int i; unsigned int ii; PSKeyItem pKey; unsigned int uKeyIdx; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Enter KeybSetAllGroupKey: %lX\n", dwKeyIndex); if ((dwKeyIndex & PAIRWISE_KEY) != 0) { // Pairwise key return (FALSE); } else if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) { return (FALSE); } for (i=0; i < MAX_KEY_TABLE-1; i++) { if (pTable->KeyTable[i].bInUse == TRUE) { // found table already exist // Group key pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF]); if ((dwKeyIndex & TRANSMIT_KEY) != 0) { // Group transmit key pTable->KeyTable[i].dwGTKeyIndex = dwKeyIndex; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Group transmit key(R)[%lX]: %d\n", pTable->KeyTable[i].dwGTKeyIndex, i); } pTable->KeyTable[i].wKeyCtl &= 0xFF0F; // clear group key control filed pTable->KeyTable[i].wKeyCtl |= (byKeyDecMode << 4); pTable->KeyTable[i].wKeyCtl |= 0x0040; // use group key for group address uKeyIdx = (dwKeyIndex & 0x000000FF); pTable->KeyTable[i].wKeyCtl |= 0x8000; // enable on-fly pKey->bKeyValid = TRUE; pKey->uKeyLength = uKeyLength; pKey->dwKeyIndex = dwKeyIndex; pKey->byCipherSuite = byKeyDecMode; memcpy(pKey->abyKey, pbyKey, uKeyLength); if (byKeyDecMode == KEY_CTL_WEP) { if (uKeyLength == WLAN_WEP40_KEYLEN) pKey->abyKey[15] &= 0x7F; if (uKeyLength == WLAN_WEP104_KEYLEN) pKey->abyKey[15] |= 0x80; } MACvSetKeyEntry(pDevice, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pTable->KeyTable[i].abyBSSID, (PDWORD) pKey->abyKey); if ((dwKeyIndex & USE_KEYRSC) == 0) { // RSC set by NIC memset(&(pKey->KeyRSC), 0, sizeof(QWORD)); } else { memcpy(&(pKey->KeyRSC), pKeyRSC, sizeof(QWORD)); } pKey->dwTSC47_16 = 0; pKey->wTSC15_0 = 0; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybSetKey(R): \n"); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->bKeyValid: %d\n ", pKey->bKeyValid); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->uKeyLength: %d\n ", (int)pKey->uKeyLength); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->abyKey: "); for (ii = 0; ii < pKey->uKeyLength; ii++) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", pKey->abyKey[ii]); } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n"); //DBG_PRN_GRP12(("pKey->dwTSC47_16: %lX\n ", pKey->dwTSC47_16)); //DBG_PRN_GRP12(("pKey->wTSC15_0: %X\n ", pKey->wTSC15_0)); //DBG_PRN_GRP12(("pKey->dwKeyIndex: %lX\n ", pKey->dwKeyIndex)); } // (pTable->KeyTable[i].bInUse == TRUE) } return (TRUE); }