/*----------------------------------------------------------------------------*/ int mtk_cfg80211_connect ( struct wiphy *wiphy, struct net_device *ndev, struct cfg80211_connect_params *sme ) { P_GLUE_INFO_T prGlueInfo = NULL; WLAN_STATUS rStatus; UINT_32 u4BufLen; ENUM_PARAM_ENCRYPTION_STATUS_T eEncStatus; ENUM_PARAM_AUTH_MODE_T eAuthMode; UINT_32 cipher; PARAM_SSID_T rNewSsid; BOOLEAN fgCarryWPSIE = FALSE; ENUM_PARAM_OP_MODE_T eOpMode; prGlueInfo = (P_GLUE_INFO_T) wiphy_priv(wiphy); ASSERT(prGlueInfo); if (prGlueInfo->prAdapter->rWifiVar.rConnSettings.eOPMode > NET_TYPE_AUTO_SWITCH) eOpMode = NET_TYPE_AUTO_SWITCH; else eOpMode = prGlueInfo->prAdapter->rWifiVar.rConnSettings.eOPMode; rStatus = kalIoctl(prGlueInfo, wlanoidSetInfrastructureMode, &eOpMode, sizeof(eOpMode), FALSE, FALSE, TRUE, FALSE, &u4BufLen); if (rStatus != WLAN_STATUS_SUCCESS) { DBGLOG(INIT, INFO, ("wlanoidSetInfrastructureMode fail 0x%lx\n", rStatus)); return -EFAULT; } /* after set operation mode, key table are cleared */ /* reset wpa info */ prGlueInfo->rWpaInfo.u4WpaVersion = IW_AUTH_WPA_VERSION_DISABLED; prGlueInfo->rWpaInfo.u4KeyMgmt = 0; prGlueInfo->rWpaInfo.u4CipherGroup = IW_AUTH_CIPHER_NONE; prGlueInfo->rWpaInfo.u4CipherPairwise = IW_AUTH_CIPHER_NONE; prGlueInfo->rWpaInfo.u4AuthAlg = IW_AUTH_ALG_OPEN_SYSTEM; #if CFG_SUPPORT_802_11W prGlueInfo->rWpaInfo.u4Mfp = IW_AUTH_MFP_DISABLED; #endif if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) prGlueInfo->rWpaInfo.u4WpaVersion = IW_AUTH_WPA_VERSION_WPA; else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) prGlueInfo->rWpaInfo.u4WpaVersion = IW_AUTH_WPA_VERSION_WPA2; else prGlueInfo->rWpaInfo.u4WpaVersion = IW_AUTH_WPA_VERSION_DISABLED; switch (sme->auth_type) { case NL80211_AUTHTYPE_OPEN_SYSTEM: prGlueInfo->rWpaInfo.u4AuthAlg = IW_AUTH_ALG_OPEN_SYSTEM; break; case NL80211_AUTHTYPE_SHARED_KEY: prGlueInfo->rWpaInfo.u4AuthAlg = IW_AUTH_ALG_SHARED_KEY; break; default: prGlueInfo->rWpaInfo.u4AuthAlg = IW_AUTH_ALG_OPEN_SYSTEM | IW_AUTH_ALG_SHARED_KEY; break; } if (sme->crypto.n_ciphers_pairwise) { switch (sme->crypto.ciphers_pairwise[0]) { case WLAN_CIPHER_SUITE_WEP40: prGlueInfo->rWpaInfo.u4CipherPairwise = IW_AUTH_CIPHER_WEP40; break; case WLAN_CIPHER_SUITE_WEP104: prGlueInfo->rWpaInfo.u4CipherPairwise = IW_AUTH_CIPHER_WEP104; break; case WLAN_CIPHER_SUITE_TKIP: prGlueInfo->rWpaInfo.u4CipherPairwise = IW_AUTH_CIPHER_TKIP; break; case WLAN_CIPHER_SUITE_CCMP: prGlueInfo->rWpaInfo.u4CipherPairwise = IW_AUTH_CIPHER_CCMP; break; case WLAN_CIPHER_SUITE_AES_CMAC: prGlueInfo->rWpaInfo.u4CipherPairwise = IW_AUTH_CIPHER_CCMP; break; default: DBGLOG(REQ, WARN, ("invalid cipher pairwise (%d)\n", sme->crypto.ciphers_pairwise[0])); return -EINVAL; } } if (sme->crypto.cipher_group) { switch (sme->crypto.cipher_group) { case WLAN_CIPHER_SUITE_WEP40: prGlueInfo->rWpaInfo.u4CipherGroup = IW_AUTH_CIPHER_WEP40; break; case WLAN_CIPHER_SUITE_WEP104: prGlueInfo->rWpaInfo.u4CipherGroup = IW_AUTH_CIPHER_WEP104; break; case WLAN_CIPHER_SUITE_TKIP: prGlueInfo->rWpaInfo.u4CipherGroup = IW_AUTH_CIPHER_TKIP; break; case WLAN_CIPHER_SUITE_CCMP: prGlueInfo->rWpaInfo.u4CipherGroup = IW_AUTH_CIPHER_CCMP; break; case WLAN_CIPHER_SUITE_AES_CMAC: prGlueInfo->rWpaInfo.u4CipherGroup = IW_AUTH_CIPHER_CCMP; break; default: DBGLOG(REQ, WARN, ("invalid cipher group (%d)\n", sme->crypto.cipher_group)); return -EINVAL; } } if (sme->crypto.n_akm_suites) { if (prGlueInfo->rWpaInfo.u4WpaVersion == IW_AUTH_WPA_VERSION_WPA) { switch (sme->crypto.akm_suites[0]) { case WLAN_AKM_SUITE_8021X: eAuthMode = AUTH_MODE_WPA; break; case WLAN_AKM_SUITE_PSK: eAuthMode = AUTH_MODE_WPA_PSK; break; default: DBGLOG(REQ, WARN, ("invalid cipher group (%d)\n", sme->crypto.cipher_group)); return -EINVAL; } } else if (prGlueInfo->rWpaInfo.u4WpaVersion == IW_AUTH_WPA_VERSION_WPA2) { switch (sme->crypto.akm_suites[0]) { case WLAN_AKM_SUITE_8021X: eAuthMode = AUTH_MODE_WPA2; break; case WLAN_AKM_SUITE_PSK: eAuthMode = AUTH_MODE_WPA2_PSK; break; default: DBGLOG(REQ, WARN, ("invalid cipher group (%d)\n", sme->crypto.cipher_group)); return -EINVAL; } } } if (prGlueInfo->rWpaInfo.u4WpaVersion == IW_AUTH_WPA_VERSION_DISABLED) { eAuthMode = (prGlueInfo->rWpaInfo.u4AuthAlg == IW_AUTH_ALG_OPEN_SYSTEM) ? AUTH_MODE_OPEN : AUTH_MODE_AUTO_SWITCH; } prGlueInfo->rWpaInfo.fgPrivacyInvoke = sme->privacy; //prGlueInfo->prAdapter->rWifiVar.rConnSettings.fgWapiMode = FALSE; //prGlueInfo->prAdapter->prGlueInfo->u2WapiAssocInfoIESz = 0; prGlueInfo->fgWpsActive = FALSE; //prGlueInfo->prAdapter->prGlueInfo->u2WSCAssocInfoIELen = 0; if (sme->ie && sme->ie_len > 0) { WLAN_STATUS rStatus; UINT_32 u4BufLen; PUINT_8 prDesiredIE = NULL; #if CFG_SUPPORT_WAPI rStatus = kalIoctl(prGlueInfo, wlanoidSetWapiAssocInfo, sme->ie, sme->ie_len, FALSE, FALSE, FALSE, FALSE, &u4BufLen); if (rStatus != WLAN_STATUS_SUCCESS) { DBGLOG(SEC, WARN, ("[wapi] set wapi assoc info error:%lx\n", rStatus)); } #endif #if CFG_SUPPORT_WPS2 if (wextSrchDesiredWPSIE(sme->ie, sme->ie_len, 0xDD, (PUINT_8 *)&prDesiredIE)) { prGlueInfo->fgWpsActive = TRUE; fgCarryWPSIE = TRUE; rStatus = kalIoctl(prGlueInfo, wlanoidSetWSCAssocInfo, prDesiredIE, IE_SIZE(prDesiredIE), FALSE, FALSE, FALSE, FALSE, &u4BufLen); if (rStatus != WLAN_STATUS_SUCCESS) { DBGLOG(SEC, WARN, ("WSC] set WSC assoc info error:%lx\n", rStatus)); } } #endif } /* clear WSC Assoc IE buffer in case WPS IE is not detected */ if(fgCarryWPSIE == FALSE) { kalMemZero(&prGlueInfo->aucWSCAssocInfoIE, 200); prGlueInfo->u2WSCAssocInfoIELen = 0; } rStatus = kalIoctl(prGlueInfo, wlanoidSetAuthMode, &eAuthMode, sizeof(eAuthMode), FALSE, FALSE, FALSE, FALSE, &u4BufLen); if (rStatus != WLAN_STATUS_SUCCESS) { DBGLOG(REQ, WARN, ("set auth mode error:%lx\n", rStatus)); } cipher = prGlueInfo->rWpaInfo.u4CipherGroup | prGlueInfo->rWpaInfo.u4CipherPairwise; if (prGlueInfo->rWpaInfo.fgPrivacyInvoke) { if (cipher & IW_AUTH_CIPHER_CCMP) { eEncStatus = ENUM_ENCRYPTION3_ENABLED; } else if (cipher & IW_AUTH_CIPHER_TKIP) { eEncStatus = ENUM_ENCRYPTION2_ENABLED; } else if (cipher & (IW_AUTH_CIPHER_WEP104 | IW_AUTH_CIPHER_WEP40)) { eEncStatus = ENUM_ENCRYPTION1_ENABLED; } else if (cipher & IW_AUTH_CIPHER_NONE){ if (prGlueInfo->rWpaInfo.fgPrivacyInvoke) eEncStatus = ENUM_ENCRYPTION1_ENABLED; else eEncStatus = ENUM_ENCRYPTION_DISABLED; } else { eEncStatus = ENUM_ENCRYPTION_DISABLED; } } else { eEncStatus = ENUM_ENCRYPTION_DISABLED; } rStatus = kalIoctl(prGlueInfo, wlanoidSetEncryptionStatus, &eEncStatus, sizeof(eEncStatus), FALSE, FALSE, FALSE, FALSE, &u4BufLen); if (rStatus != WLAN_STATUS_SUCCESS) { DBGLOG(REQ, WARN, ("set encryption mode error:%lx\n", rStatus)); } if (sme->key_len != 0 && prGlueInfo->rWpaInfo.u4WpaVersion == IW_AUTH_WPA_VERSION_DISABLED) { P_PARAM_WEP_T prWepKey = (P_PARAM_WEP_T) wepBuf; kalMemSet(prWepKey, 0, sizeof(prWepKey)); prWepKey->u4Length = 12 + sme->key_len; prWepKey->u4KeyLength = (UINT_32) sme->key_len; prWepKey->u4KeyIndex = (UINT_32) sme->key_idx; prWepKey->u4KeyIndex |= BIT(31); if (prWepKey->u4KeyLength > 32) { DBGLOG(REQ, WARN, ("Too long key length (%u)\n", prWepKey->u4KeyLength)); return -EINVAL; } kalMemCopy(prWepKey->aucKeyMaterial, sme->key, prWepKey->u4KeyLength); rStatus = kalIoctl(prGlueInfo, wlanoidSetAddWep, prWepKey, prWepKey->u4Length, FALSE, FALSE, TRUE, FALSE, &u4BufLen); if (rStatus != WLAN_STATUS_SUCCESS) { DBGLOG(INIT, INFO, ("wlanoidSetAddWep fail 0x%lx\n", rStatus)); return -EFAULT; } } if(sme->ssid_len > 0) { /* connect by SSID */ COPY_SSID(rNewSsid.aucSsid, rNewSsid.u4SsidLen, sme->ssid, sme->ssid_len); rStatus = kalIoctl(prGlueInfo, wlanoidSetSsid, (PVOID) &rNewSsid, sizeof(PARAM_SSID_T), FALSE, FALSE, TRUE, FALSE, &u4BufLen); if (rStatus != WLAN_STATUS_SUCCESS) { DBGLOG(REQ, WARN, ("set SSID:%lx\n", rStatus)); return -EINVAL; } } else { /* connect by BSSID */ rStatus = kalIoctl(prGlueInfo, wlanoidSetBssid, (PVOID) sme->bssid, sizeof(MAC_ADDR_LEN), FALSE, FALSE, TRUE, FALSE, &u4BufLen); if (rStatus != WLAN_STATUS_SUCCESS) { DBGLOG(REQ, WARN, ("set BSSID:%lx\n", rStatus)); return -EINVAL; } } return 0; }
/*----------------------------------------------------------------------------*/ VOID kalUpdateReAssocReqInfo(IN P_GLUE_INFO_T prGlueInfo, IN PUINT_8 pucFrameBody, IN UINT_32 u4FrameBodyLen, IN BOOLEAN fgReassocRequest) { PUINT_8 cp; PNDIS_802_11_ASSOCIATION_INFORMATION prNdisAssocInfo; if (fgReassocRequest) { ASSERT(u4FrameBodyLen >= MIN_REASSOC_REQ_BODY_LEN); if (u4FrameBodyLen < MIN_REASSOC_REQ_BODY_LEN) { return; } } else { ASSERT(u4FrameBodyLen >= MIN_ASSOC_REQ_BODY_LEN); if (u4FrameBodyLen < MIN_ASSOC_REQ_BODY_LEN) { return; } } prNdisAssocInfo = &prGlueInfo->rNdisAssocInfo; cp = pucFrameBody; /* Update the fixed information elements. */ if (fgReassocRequest) { prNdisAssocInfo->AvailableRequestFixedIEs = NDIS_802_11_AI_REQFI_CAPABILITIES | NDIS_802_11_AI_REQFI_LISTENINTERVAL | NDIS_802_11_AI_REQFI_CURRENTAPADDRESS; } else { prNdisAssocInfo->AvailableRequestFixedIEs = NDIS_802_11_AI_REQFI_CAPABILITIES | NDIS_802_11_AI_REQFI_LISTENINTERVAL; } kalMemCopy(&prNdisAssocInfo->RequestFixedIEs.Capabilities, cp, 2); cp += 2; u4FrameBodyLen -= 2; kalMemCopy(&prNdisAssocInfo->RequestFixedIEs.ListenInterval, cp, 2); cp += 2; u4FrameBodyLen -= 2; if (fgReassocRequest) { kalMemCopy(&prNdisAssocInfo->RequestFixedIEs.CurrentAPAddress, cp, 6); cp += 6; u4FrameBodyLen -= 6; } else { kalMemZero(&prNdisAssocInfo->RequestFixedIEs.CurrentAPAddress, 6); } /* Update the variable length information elements. */ prNdisAssocInfo->RequestIELength = u4FrameBodyLen; prNdisAssocInfo->OffsetRequestIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION); kalMemCopy(prGlueInfo->aucNdisAssocInfoIEs, cp, u4FrameBodyLen); /* Clear the information for the last association/reassociation response from the AP. */ prNdisAssocInfo->AvailableResponseFixedIEs = 0; prNdisAssocInfo->ResponseFixedIEs.Capabilities = 0; prNdisAssocInfo->ResponseFixedIEs.StatusCode = 0; prNdisAssocInfo->ResponseFixedIEs.AssociationId = 0; prNdisAssocInfo->ResponseIELength = 0; prNdisAssocInfo->OffsetResponseIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION) + u4FrameBodyLen; } /* kalUpdateReAssocReqInfo */
static int netdev_event(struct notifier_block *nb, unsigned long notification, void *ptr) { UINT_8 ip[4] = { 0 }; UINT_32 u4NumIPv4 = 0; //#ifdef CONFIG_IPV6 #if 0 UINT_8 ip6[16] = { 0 }; // FIX ME: avoid to allocate large memory in stack UINT_32 u4NumIPv6 = 0; #endif struct in_ifaddr *ifa = (struct in_ifaddr *) ptr; struct net_device *prDev = ifa->ifa_dev->dev; UINT_32 i; P_PARAM_NETWORK_ADDRESS_IP prParamIpAddr; P_GLUE_INFO_T prGlueInfo = NULL; if (prDev == NULL) { DBGLOG(REQ, INFO, ("netdev_event: device is empty.\n")); return NOTIFY_DONE; } if ((strncmp(prDev->name, "p2p", 3) != 0) && (strncmp(prDev->name, "wlan", 4) != 0)) { DBGLOG(REQ, INFO, ("netdev_event: xxx\n")); return NOTIFY_DONE; } #if 0//CFG_SUPPORT_HOTSPOT_2_0 { //printk(KERN_INFO "[netdev_event] IPV4_DAD is unlock now!!\n"); prGlueInfo->fgIsDad = FALSE; } #endif prGlueInfo = *((P_GLUE_INFO_T *) netdev_priv(prDev)); if (prGlueInfo == NULL) { DBGLOG(REQ, INFO, ("netdev_event: prGlueInfo is empty.\n")); return NOTIFY_DONE; } ASSERT(prGlueInfo); if (fgIsUnderEarlierSuspend == false) { DBGLOG(REQ, INFO, ("netdev_event: PARAM_MEDIA_STATE_DISCONNECTED. (%d)\n", prGlueInfo->eParamMediaStateIndicated)); return NOTIFY_DONE; } // <3> get the IPv4 address if(!prDev || !(prDev->ip_ptr)||\ !((struct in_device *)(prDev->ip_ptr))->ifa_list||\ !(&(((struct in_device *)(prDev->ip_ptr))->ifa_list->ifa_local))){ DBGLOG(REQ, INFO, ("ip is not avaliable.\n")); return NOTIFY_DONE; } kalMemCopy(ip, &(((struct in_device *)(prDev->ip_ptr))->ifa_list->ifa_local), sizeof(ip)); DBGLOG(REQ, INFO, ("ip is %d.%d.%d.%d\n", ip[0],ip[1],ip[2],ip[3])); // todo: traverse between list to find whole sets of IPv4 addresses if (!((ip[0] == 0) && (ip[1] == 0) && (ip[2] == 0) && (ip[3] == 0))) { u4NumIPv4++; } //#ifdef CONFIG_IPV6 #if 0 if(!prDev || !(prDev->ip6_ptr)||\ !((struct in_device *)(prDev->ip6_ptr))->ifa_list||\ !(&(((struct in_device *)(prDev->ip6_ptr))->ifa_list->ifa_local))){ printk(KERN_INFO "ipv6 is not avaliable.\n"); return NOTIFY_DONE; } kalMemCopy(ip6, &(((struct in_device *)(prDev->ip6_ptr))->ifa_list->ifa_local), sizeof(ip6)); printk(KERN_INFO"ipv6 is %d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d\n", ip6[0],ip6[1],ip6[2],ip6[3], ip6[4],ip6[5],ip6[6],ip6[7], ip6[8],ip6[9],ip6[10],ip6[11], ip6[12],ip6[13],ip6[14],ip6[15] ); // todo: traverse between list to find whole sets of IPv6 addresses if (!((ip6[0] == 0) && (ip6[1] == 0) && (ip6[2] == 0) && (ip6[3] == 0) && (ip6[4] == 0) && (ip6[5] == 0))) { //u4NumIPv6++; } #endif // here we can compare the dev with other network's netdev to // set the proper arp filter // // IMPORTANT: please make sure if the context can sleep, if the context can't sleep // we should schedule a kernel thread to do this for us // <7> set up the ARP filter { WLAN_STATUS rStatus = WLAN_STATUS_FAILURE; UINT_32 u4SetInfoLen = 0; UINT_8 aucBuf[32] = {0}; UINT_32 u4Len = OFFSET_OF(PARAM_NETWORK_ADDRESS_LIST, arAddress); P_PARAM_NETWORK_ADDRESS_LIST prParamNetAddrList = (P_PARAM_NETWORK_ADDRESS_LIST)aucBuf; P_PARAM_NETWORK_ADDRESS prParamNetAddr = prParamNetAddrList->arAddress; //#ifdef CONFIG_IPV6 #if 0 prParamNetAddrList->u4AddressCount = u4NumIPv4 + u4NumIPv6; #else prParamNetAddrList->u4AddressCount = u4NumIPv4; #endif prParamNetAddrList->u2AddressType = PARAM_PROTOCOL_ID_TCP_IP; for (i = 0; i < u4NumIPv4; i++) { prParamNetAddr->u2AddressLength = sizeof(PARAM_NETWORK_ADDRESS_IP);//4;; prParamNetAddr->u2AddressType = PARAM_PROTOCOL_ID_TCP_IP;; #if 0 kalMemCopy(prParamNetAddr->aucAddress, ip, sizeof(ip)); prParamNetAddr = (P_PARAM_NETWORK_ADDRESS)((UINT_32)prParamNetAddr + sizeof(ip)); u4Len += OFFSET_OF(PARAM_NETWORK_ADDRESS, aucAddress) + sizeof(ip); #else prParamIpAddr = (P_PARAM_NETWORK_ADDRESS_IP)prParamNetAddr->aucAddress; kalMemCopy(&prParamIpAddr->in_addr, ip, sizeof(ip)); prParamNetAddr = (P_PARAM_NETWORK_ADDRESS)((UINT_32)prParamNetAddr + sizeof(PARAM_NETWORK_ADDRESS)); u4Len += OFFSET_OF(PARAM_NETWORK_ADDRESS, aucAddress) + sizeof(PARAM_NETWORK_ADDRESS); #endif } //#ifdef CONFIG_IPV6 #if 0 for (i = 0; i < u4NumIPv6; i++) { prParamNetAddr->u2AddressLength = 6;; prParamNetAddr->u2AddressType = PARAM_PROTOCOL_ID_TCP_IP;; kalMemCopy(prParamNetAddr->aucAddress, ip6, sizeof(ip6)); prParamNetAddr = (P_PARAM_NETWORK_ADDRESS)((UINT_32)prParamNetAddr + sizeof(ip6)); u4Len += OFFSET_OF(PARAM_NETWORK_ADDRESS, aucAddress) + sizeof(ip6); } #endif ASSERT(u4Len <= sizeof(aucBuf)); DBGLOG(REQ, INFO, ("kalIoctl (0x%x, 0x%x)\n", prGlueInfo, prParamNetAddrList)); rStatus = kalIoctl(prGlueInfo, wlanoidSetNetworkAddress, (PVOID)prParamNetAddrList, u4Len, FALSE, FALSE, TRUE, FALSE, &u4SetInfoLen); if (rStatus != WLAN_STATUS_SUCCESS) { DBGLOG(REQ, INFO, ("set HW pattern filter fail 0x%lx\n", rStatus)); } } return NOTIFY_DONE; }
/*----------------------------------------------------------------------------*/ int mtk_cfg80211_add_key ( struct wiphy *wiphy, struct net_device *ndev, u8 key_index, bool pairwise, const u8 *mac_addr, struct key_params *params ) { PARAM_KEY_T rKey; P_GLUE_INFO_T prGlueInfo = NULL; WLAN_STATUS rStatus = WLAN_STATUS_SUCCESS; INT_32 i4Rslt = -EINVAL; UINT_32 u4BufLen = 0; UINT_8 tmp1[8]; UINT_8 tmp2[8]; prGlueInfo = (P_GLUE_INFO_T) wiphy_priv(wiphy); ASSERT(prGlueInfo); kalMemZero(&rKey, sizeof(PARAM_KEY_T)); rKey.u4KeyIndex = key_index; if(mac_addr) { COPY_MAC_ADDR(rKey.arBSSID, mac_addr); if ((rKey.arBSSID[0] == 0x00) && (rKey.arBSSID[1] == 0x00) && (rKey.arBSSID[2] == 0x00) && (rKey.arBSSID[3] == 0x00) && (rKey.arBSSID[4] == 0x00) && (rKey.arBSSID[5] == 0x00)) { rKey.arBSSID[0] = 0xff; rKey.arBSSID[1] = 0xff; rKey.arBSSID[2] = 0xff; rKey.arBSSID[3] = 0xff; rKey.arBSSID[4] = 0xff; rKey.arBSSID[5] = 0xff; } if (rKey.arBSSID[0] != 0xFF) { rKey.u4KeyIndex |= BIT(31); if ((rKey.arBSSID[0] != 0x00) || (rKey.arBSSID[1] != 0x00) || (rKey.arBSSID[2] != 0x00) || (rKey.arBSSID[3] != 0x00) || (rKey.arBSSID[4] != 0x00) || (rKey.arBSSID[5] != 0x00)) rKey.u4KeyIndex |= BIT(30); } } else { rKey.arBSSID[0] = 0xff; rKey.arBSSID[1] = 0xff; rKey.arBSSID[2] = 0xff; rKey.arBSSID[3] = 0xff; rKey.arBSSID[4] = 0xff; rKey.arBSSID[5] = 0xff; //rKey.u4KeyIndex |= BIT(31); //Enable BIT 31 will make tx use bc key id, should use pairwise key id 0 } if(params->key) { //rKey.aucKeyMaterial[0] = kalMemAlloc(params->key_len, VIR_MEM_TYPE); kalMemCopy(rKey.aucKeyMaterial, params->key, params->key_len); if (params->key_len == 32) { kalMemCopy(tmp1, ¶ms->key[16], 8); kalMemCopy(tmp2, ¶ms->key[24], 8); kalMemCopy(&rKey.aucKeyMaterial[16], tmp2, 8); kalMemCopy(&rKey.aucKeyMaterial[24], tmp1, 8); } } rKey.u4KeyLength = params->key_len; rKey.u4Length = ((UINT_32)&(((P_P2P_PARAM_KEY_T)0)->aucKeyMaterial)) + rKey.u4KeyLength; rStatus = kalIoctl(prGlueInfo, wlanoidSetAddKey, &rKey, rKey.u4Length, FALSE, FALSE, TRUE, FALSE, &u4BufLen); if (rStatus == WLAN_STATUS_SUCCESS) i4Rslt = 0; return i4Rslt; }
/*----------------------------------------------------------------------------*/ UINT_8 secPrivacySeekForBcEntry(IN P_ADAPTER_T prAdapter, IN UINT_8 ucBssIndex, IN PUINT_8 pucAddr, IN UINT_8 ucStaIdx, IN UINT_8 ucAlg, IN UINT_8 ucKeyId, IN UINT_8 ucCurrentKeyId, IN UINT_8 ucTxRx) { UINT_8 ucEntry = WTBL_ALLOC_FAIL; UINT_8 ucStartIDX = 0, ucMaxIDX = 0; UINT_8 i; BOOLEAN fgCheckKeyId = TRUE; P_WLAN_TABLE_T prWtbl; /* P_BSS_INFO_T prBSSInfo = GET_BSS_INFO_BY_INDEX(prAdapter,ucBssIndex); */ prWtbl = prAdapter->rWifiVar.arWtbl; ASSERT(prAdapter); ASSERT(pucAddr); #if 1 ucStartIDX = 0; ucMaxIDX = NIC_TX_DEFAULT_WLAN_INDEX - 1; #else if (ucAlg == CIPHER_SUITE_BIP) { if (ucNetTypeIdx != NETWORK_TYPE_AIS) { ASSERT(FALSE); return ucEntry; } ucEntry = WTBL_AIS_BIP_IDX; /* Only support 11w at STA mode */ } #endif if (ucAlg == CIPHER_SUITE_WPI || ucAlg == CIPHER_SUITE_WEP40 || ucAlg == CIPHER_SUITE_WEP104 || ucAlg == CIPHER_SUITE_WEP128 || ucAlg == CIPHER_SUITE_NONE) fgCheckKeyId = FALSE; #if 0 if ((ucNetTypeIdx == NETWORK_TYPE_AIS) && (prAdapter->aprBssInfo[ucBssIndex]->eCurrentOPMode == OP_MODE_IBSS)) { ucStartIDX = WTBL_IBSS_BC_IDX_0; ucMaxIDX = WTBL_BC_IDX_MAX; } else { ucStartIDX = WTBL_BC_IDX_0; ucMaxIDX = WTBL_BC_IDX_MAX; } #endif for (i = ucStartIDX; i <= ucMaxIDX; i++) { #if DBG if (i < 10) { DBGLOG(RSN, TRACE, ("idx=%d use=%d P=%d BSSIdx=%d Addr=" MACSTR " keyid=%d\n", i, prWtbl[i].ucUsed, prWtbl[i].ucPairwise, prWtbl[i].ucBssIndex, MAC2STR(prWtbl[i].aucMacAddr), prWtbl[i].ucKeyId)); } #endif if (prWtbl[i].ucUsed && !prWtbl[i].ucPairwise && prWtbl[i].ucBssIndex == ucBssIndex && 1 /* (EQUAL_MAC_ADDR(prWtbl[i].aucMacAddr, pucAddr) || (prBSSInfo && EQUAL_MAC_ADDR(prWtbl[i].aucMacAddr, prBSSInfo->aucOwnMacAddr))) */ ) { if (!fgCheckKeyId || prWtbl[i].ucKeyId == 0xff || (fgCheckKeyId && prWtbl[i].ucKeyId == ucKeyId)) { ucEntry = i; DBGLOG(RSN, TRACE, ("[Wlan index]: Reuse entry #%d\n", i)); break; } if (fgCheckKeyId && (prWtbl[i].ucKeyId != ucCurrentKeyId)) { ucEntry = i; DBGLOG(RSN, TRACE, ("[Wlan index]: Replace the not current keyid entry #%d\n", i)); break; } } } if (i == (ucMaxIDX + 1)) { for (i = ucStartIDX; i <= ucMaxIDX; i++) { if (prWtbl[i].ucUsed == FALSE) { ucEntry = i; DBGLOG(RSN, TRACE, ("[Wlan index]: Assign entry #%d\n", i)); break; } } } if (ucEntry < WTBL_SIZE) { prWtbl[ucEntry].ucUsed = TRUE; prWtbl[ucEntry].ucKeyId = ucKeyId; prWtbl[ucEntry].ucBssIndex = ucBssIndex; prWtbl[ucEntry].ucPairwise = 0; kalMemCopy(prWtbl[ucEntry].aucMacAddr, pucAddr, MAC_ADDR_LEN); prWtbl[ucEntry].ucStaIndex = ucStaIdx; DBGLOG(RSN, TRACE, ("[Wlan index] BSS#%d keyid#%d P=%d use WlanIndex#%d STAIdx=%d " MACSTR "\n", ucBssIndex, ucKeyId, prWtbl[ucEntry].ucPairwise, ucEntry, ucStaIdx, MAC2STR(pucAddr))); #if DBG secCheckWTBLAssign(prAdapter); #endif } ASSERT(ucEntry != WTBL_ALLOC_FAIL); return ucEntry; }
/*----------------------------------------------------------------------------*/ int mtk_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *ndev, struct cfg80211_ibss_params *params) { PARAM_SSID_T rNewSsid; P_GLUE_INFO_T prGlueInfo = NULL; UINT_32 u4ChnlFreq; /* Store channel or frequency information */ UINT_32 u4BufLen = 0; WLAN_STATUS rStatus; prGlueInfo = (P_GLUE_INFO_T) wiphy_priv(wiphy); ASSERT(prGlueInfo); /* set channel */ #if LINUX_VERSION_CODE <= KERNEL_VERSION(3, 7, 0) if (params->channel) { u4ChnlFreq = nicChannelNum2Freq(params->channel->hw_value); #else if (params->chandef.chan) { u4ChnlFreq = nicChannelNum2Freq(params->chandef.chan->hw_value); #endif rStatus = kalIoctl(prGlueInfo, wlanoidSetFrequency, &u4ChnlFreq, sizeof(u4ChnlFreq), FALSE, FALSE, FALSE, FALSE, &u4BufLen); if (rStatus != WLAN_STATUS_SUCCESS) { return -EFAULT; } } /* set SSID */ kalMemCopy(rNewSsid.aucSsid, params->ssid, params->ssid_len); rStatus = kalIoctl(prGlueInfo, wlanoidSetSsid, (PVOID) & rNewSsid, sizeof(PARAM_SSID_T), FALSE, FALSE, TRUE, FALSE, &u4BufLen); if (rStatus != WLAN_STATUS_SUCCESS) { DBGLOG(REQ, WARN, ("set SSID:%lx\n", rStatus)); return -EFAULT; } return 0; return -EINVAL; } /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/ int mtk_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *ndev) { P_GLUE_INFO_T prGlueInfo = NULL; WLAN_STATUS rStatus; UINT_32 u4BufLen; prGlueInfo = (P_GLUE_INFO_T) wiphy_priv(wiphy); ASSERT(prGlueInfo); rStatus = kalIoctl(prGlueInfo, wlanoidSetDisassociate, NULL, 0, FALSE, FALSE, TRUE, FALSE, &u4BufLen); if (rStatus != WLAN_STATUS_SUCCESS) { DBGLOG(REQ, WARN, ("disassociate error:%lx\n", rStatus)); return -EFAULT; } return 0; }
int mtk_cfg80211_vendor_set_significant_change(struct wiphy *wiphy, struct wireless_dev *wdev, const void *data, int data_len) { INT_32 i4Status = -EINVAL; P_PARAM_WIFI_SIGNIFICANT_CHANGE prWifiChangeCmd = NULL; UINT_8 flush = 0; /* struct nlattr *attr[GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_FLUSH + 1]; */ struct nlattr **attr = NULL; struct nlattr *paplist; int i, k; UINT_32 len_basic, len_aplist; ASSERT(wiphy); ASSERT(wdev); if ((data == NULL) || !data_len) goto nla_put_failure; DBGLOG(REQ, INFO, "%s for vendor command: data_len=%d \r\n", __func__, data_len); for (i = 0; i < 6; i++) DBGLOG(REQ, LOUD, "0x%x 0x%x 0x%x 0x%x \r\n", *((UINT_32 *) data + i * 4), *((UINT_32 *) data + i * 4 + 1), *((UINT_32 *) data + i * 4 + 2), *((UINT_32 *) data + i * 4 + 3)); prWifiChangeCmd = kalMemAlloc(sizeof(PARAM_WIFI_SIGNIFICANT_CHANGE), VIR_MEM_TYPE); if (prWifiChangeCmd == NULL) goto nla_put_failure; kalMemZero(prWifiChangeCmd, sizeof(PARAM_WIFI_SIGNIFICANT_CHANGE)); attr = kalMemAlloc(sizeof(struct nlattr *) * (GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_FLUSH + 1), VIR_MEM_TYPE); if (attr == NULL) goto nla_put_failure; kalMemZero(attr, sizeof(struct nlattr *) * (GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_FLUSH + 1)); if (nla_parse_nested(attr, GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_FLUSH, (struct nlattr *)(data - NLA_HDRLEN), nla_parse_policy) < 0) goto nla_put_failure; len_basic = 0; for (k = GSCAN_ATTRIBUTE_RSSI_SAMPLE_SIZE; k <= GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_FLUSH; k++) { if (attr[k]) { switch (k) { case GSCAN_ATTRIBUTE_RSSI_SAMPLE_SIZE: prWifiChangeCmd->rssi_sample_size = nla_get_u16(attr[k]); len_basic += NLA_ALIGN(attr[k]->nla_len); break; case GSCAN_ATTRIBUTE_LOST_AP_SAMPLE_SIZE: prWifiChangeCmd->lost_ap_sample_size = nla_get_u16(attr[k]); len_basic += NLA_ALIGN(attr[k]->nla_len); break; case GSCAN_ATTRIBUTE_MIN_BREACHING: prWifiChangeCmd->min_breaching = nla_get_u16(attr[k]); len_basic += NLA_ALIGN(attr[k]->nla_len); break; case GSCAN_ATTRIBUTE_NUM_AP: prWifiChangeCmd->num_ap = nla_get_u16(attr[k]); len_basic += NLA_ALIGN(attr[k]->nla_len); DBGLOG(REQ, TRACE, "attr=0x%x, num_ap=%d nla_len=%d, \r\n", *(UINT_32 *) attr[k], prWifiChangeCmd->num_ap, attr[k]->nla_len); break; case GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_FLUSH: flush = nla_get_u8(attr[k]); len_basic += NLA_ALIGN(attr[k]->nla_len); break; } } } paplist = (struct nlattr *)((UINT_8 *) data + len_basic); DBGLOG(REQ, TRACE, "+++basic attribute size=%d flush=%d\r\n", len_basic, flush); if (paplist->nla_type == GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_BSSIDS) paplist = (struct nlattr *)((UINT_8 *) paplist + NLA_HDRLEN); for (i = 0; i < prWifiChangeCmd->num_ap; i++) { if (nla_parse_nested(attr, GSCAN_ATTRIBUTE_RSSI_HIGH, (struct nlattr *)paplist, nla_parse_policy) < 0) goto nla_put_failure; paplist = (struct nlattr *)((UINT_8 *) paplist + NLA_HDRLEN); /* request.attr_start(i) as nested attribute */ len_aplist = 0; for (k = GSCAN_ATTRIBUTE_BSSID; k <= GSCAN_ATTRIBUTE_RSSI_HIGH; k++) { if (attr[k]) { switch (k) { case GSCAN_ATTRIBUTE_BSSID: kalMemCopy(prWifiChangeCmd->ap[i].bssid, nla_data(attr[k]), sizeof(mac_addr)); len_aplist += NLA_ALIGN(attr[k]->nla_len); break; case GSCAN_ATTRIBUTE_RSSI_LOW: prWifiChangeCmd->ap[i].low = nla_get_u32(attr[k]); len_aplist += NLA_ALIGN(attr[k]->nla_len); break; case GSCAN_ATTRIBUTE_RSSI_HIGH: prWifiChangeCmd->ap[i].high = nla_get_u32(attr[k]); len_aplist += NLA_ALIGN(attr[k]->nla_len); break; } } } if (((i + 1) % 4 == 0) || (i == prWifiChangeCmd->num_ap - 1)) DBGLOG(REQ, TRACE, "ap[%d], len_aplist=%d\n", i, len_aplist); else DBGLOG(REQ, TRACE, "ap[%d], len_aplist=%d \t", i, len_aplist); paplist = (struct nlattr *)((UINT_8 *) paplist + len_aplist); } DBGLOG(REQ, TRACE, "flush=%d, rssi_sample_size=%d lost_ap_sample_size=%d min_breaching=%d", flush, prWifiChangeCmd->rssi_sample_size, prWifiChangeCmd->lost_ap_sample_size, prWifiChangeCmd->min_breaching); DBGLOG(REQ, TRACE, "ap[0].channel=%d low=%d high=%d, ap[1].channel=%d low=%d high=%d", prWifiChangeCmd->ap[0].channel, prWifiChangeCmd->ap[0].low, prWifiChangeCmd->ap[0].high, prWifiChangeCmd->ap[1].channel, prWifiChangeCmd->ap[1].low, prWifiChangeCmd->ap[1].high); kalMemFree(prWifiChangeCmd, VIR_MEM_TYPE, sizeof(PARAM_WIFI_SIGNIFICANT_CHANGE)); kalMemFree(attr, VIR_MEM_TYPE, sizeof(struct nlattr *) * (GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_FLUSH + 1)); return 0; nla_put_failure: if (prWifiChangeCmd) kalMemFree(prWifiChangeCmd, VIR_MEM_TYPE, sizeof(PARAM_WIFI_SIGNIFICANT_CHANGE)); if (attr) kalMemFree(attr, VIR_MEM_TYPE, sizeof(struct nlattr *) * (GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_FLUSH + 1)); return i4Status; }
int mtk_cfg80211_vendor_set_hotlist(struct wiphy *wiphy, struct wireless_dev *wdev, const void *data, int data_len) { /*WLAN_STATUS rStatus;*/ P_GLUE_INFO_T prGlueInfo = NULL; CMD_SET_PSCAN_ADD_HOTLIST_BSSID rCmdPscnAddHotlist; INT_32 i4Status = -EINVAL; P_PARAM_WIFI_BSSID_HOTLIST prWifiHotlistCmd = NULL; UINT_8 flush = 0; /* struct nlattr *attr[GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_FLUSH + 1]; */ struct nlattr **attr = NULL; struct nlattr *paplist; int i, k; UINT_32 len_basic, len_aplist; ASSERT(wiphy); ASSERT(wdev); if ((data == NULL) || !data_len) goto nla_put_failure; DBGLOG(REQ, INFO, "%s for vendor command: data_len=%d \r\n", __func__, data_len); for (i = 0; i < 5; i++) DBGLOG(REQ, LOUD, "0x%x 0x%x 0x%x 0x%x \r\n", *((UINT_32 *) data + i * 4), *((UINT_32 *) data + i * 4 + 1), *((UINT_32 *) data + i * 4 + 2), *((UINT_32 *) data + i * 4 + 3)); prWifiHotlistCmd = kalMemAlloc(sizeof(PARAM_WIFI_BSSID_HOTLIST), VIR_MEM_TYPE); if (prWifiHotlistCmd == NULL) goto nla_put_failure; kalMemZero(prWifiHotlistCmd, sizeof(PARAM_WIFI_BSSID_HOTLIST)); attr = kalMemAlloc(sizeof(struct nlattr *) * (GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_FLUSH + 1), VIR_MEM_TYPE); if (attr == NULL) goto nla_put_failure; kalMemZero(attr, sizeof(struct nlattr *) * (GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_FLUSH + 1)); if (nla_parse_nested(attr, GSCAN_ATTRIBUTE_NUM_AP, (struct nlattr *)(data - NLA_HDRLEN), nla_parse_policy) < 0) goto nla_put_failure; len_basic = 0; for (k = GSCAN_ATTRIBUTE_HOTLIST_FLUSH; k <= GSCAN_ATTRIBUTE_NUM_AP; k++) { if (attr[k]) { switch (k) { case GSCAN_ATTRIBUTE_LOST_AP_SAMPLE_SIZE: prWifiHotlistCmd->lost_ap_sample_size = nla_get_u32(attr[k]); len_basic += NLA_ALIGN(attr[k]->nla_len); break; case GSCAN_ATTRIBUTE_NUM_AP: prWifiHotlistCmd->num_ap = nla_get_u16(attr[k]); len_basic += NLA_ALIGN(attr[k]->nla_len); DBGLOG(REQ, TRACE, "attr=0x%x, num_ap=%d nla_len=%d, \r\n", *(UINT_32 *) attr[k], prWifiHotlistCmd->num_ap, attr[k]->nla_len); break; case GSCAN_ATTRIBUTE_HOTLIST_FLUSH: flush = nla_get_u8(attr[k]); len_basic += NLA_ALIGN(attr[k]->nla_len); break; } } } paplist = (struct nlattr *)((UINT_8 *) data + len_basic); DBGLOG(REQ, TRACE, "+++basic attribute size=%d flush=%d\r\n", len_basic, flush); if (paplist->nla_type == GSCAN_ATTRIBUTE_HOTLIST_BSSIDS) paplist = (struct nlattr *)((UINT_8 *) paplist + NLA_HDRLEN); for (i = 0; i < prWifiHotlistCmd->num_ap; i++) { if (nla_parse_nested(attr, GSCAN_ATTRIBUTE_RSSI_HIGH, (struct nlattr *)paplist, nla_parse_policy) < 0) goto nla_put_failure; paplist = (struct nlattr *)((UINT_8 *) paplist + NLA_HDRLEN); /* request.attr_start(i) as nested attribute */ len_aplist = 0; for (k = GSCAN_ATTRIBUTE_BSSID; k <= GSCAN_ATTRIBUTE_RSSI_HIGH; k++) { if (attr[k]) { switch (k) { case GSCAN_ATTRIBUTE_BSSID: kalMemCopy(prWifiHotlistCmd->ap[i].bssid, nla_data(attr[k]), sizeof(mac_addr)); len_aplist += NLA_ALIGN(attr[k]->nla_len); break; case GSCAN_ATTRIBUTE_RSSI_LOW: prWifiHotlistCmd->ap[i].low = nla_get_u32(attr[k]); len_aplist += NLA_ALIGN(attr[k]->nla_len); break; case GSCAN_ATTRIBUTE_RSSI_HIGH: prWifiHotlistCmd->ap[i].high = nla_get_u32(attr[k]); len_aplist += NLA_ALIGN(attr[k]->nla_len); break; } } } if (((i + 1) % 4 == 0) || (i == prWifiHotlistCmd->num_ap - 1)) DBGLOG(REQ, TRACE, "ap[%d], len_aplist=%d\n", i, len_aplist); else DBGLOG(REQ, TRACE, "ap[%d], len_aplist=%d \t", i, len_aplist); paplist = (struct nlattr *)((UINT_8 *) paplist + len_aplist); } DBGLOG(REQ, TRACE, "flush=%d, lost_ap_sample_size=%d, Hotlist:ap[0].channel=%d low=%d high=%d, ap[1].channel=%d low=%d high=%d", flush, prWifiHotlistCmd->lost_ap_sample_size, prWifiHotlistCmd->ap[0].channel, prWifiHotlistCmd->ap[0].low, prWifiHotlistCmd->ap[0].high, prWifiHotlistCmd->ap[1].channel, prWifiHotlistCmd->ap[1].low, prWifiHotlistCmd->ap[1].high); memcpy(&(rCmdPscnAddHotlist.aucMacAddr), &(prWifiHotlistCmd->ap[0].bssid), 6 * sizeof(UINT_8)); rCmdPscnAddHotlist.ucFlags = (UINT_8) TRUE; prGlueInfo = (P_GLUE_INFO_T) wiphy_priv(wiphy); ASSERT(prGlueInfo); kalMemFree(prWifiHotlistCmd, VIR_MEM_TYPE, sizeof(PARAM_WIFI_BSSID_HOTLIST)); kalMemFree(attr, VIR_MEM_TYPE, sizeof(struct nlattr *) * (GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_FLUSH + 1)); return 0; nla_put_failure: if (prWifiHotlistCmd) kalMemFree(prWifiHotlistCmd, VIR_MEM_TYPE, sizeof(PARAM_WIFI_BSSID_HOTLIST)); if (attr) kalMemFree(attr, VIR_MEM_TYPE, sizeof(struct nlattr *) * (GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_FLUSH + 1)); return i4Status; }
static int netdev_event(struct notifier_block *nb, unsigned long notification, void *ptr) { struct in_device *in_dev; /* ALPS00409409406 */ UINT_8 ip[4] = { 0 }; UINT_32 u4NumIPv4 = 0; //#ifdef CONFIG_IPV6 #if 0 UINT_8 ip6[16] = { 0 }; // FIX ME: avoid to allocate large memory in stack UINT_32 u4NumIPv6 = 0; #endif struct in_ifaddr *ifa = (struct in_ifaddr *) ptr; struct net_device *prDev = ifa->ifa_dev->dev; UINT_32 i; P_PARAM_NETWORK_ADDRESS_IP prParamIpAddr; P_GLUE_INFO_T prGlueInfo = NULL; if (prDev == NULL) { DBGLOG(REQ, INFO, ("netdev_event: device is empty.\n")); return NOTIFY_DONE; } if ((strncmp(prDev->name, "p2p", 3) != 0) && (strncmp(prDev->name, "wlan", 4) != 0)) { DBGLOG(REQ, INFO, ("netdev_event: xxx\n")); return NOTIFY_DONE; } prGlueInfo = *((P_GLUE_INFO_T *) netdev_priv(prDev)); if (prGlueInfo == NULL) { DBGLOG(REQ, INFO, ("netdev_event: prGlueInfo is empty.\n")); return NOTIFY_DONE; } ASSERT(prGlueInfo); #ifdef FIX_ALPS00409409406 // <3> get the IPv4 address in_dev = in_dev_get(prDev); if (!in_dev) return; //rtnl_lock(); if(!in_dev->ifa_list ||!in_dev->ifa_list->ifa_local) { //rtnl_unlock(); in_dev_put(in_dev); DBGLOG(REQ, INFO, ("ip is not avaliable.\n")); return; } // <4> copy the IPv4 address kalMemCopy(ip, &(in_dev->ifa_list->ifa_local), sizeof(ip)); //rtnl_unlock(); in_dev_put(in_dev); DBGLOG(REQ, INFO, ("ip is %d.%d.%d.%d\n", ip[0],ip[1],ip[2],ip[3])); #else // <3> get the IPv4 address if(!prDev || !(prDev->ip_ptr)||\ !((struct in_device *)(prDev->ip_ptr))->ifa_list||\ !(&(((struct in_device *)(prDev->ip_ptr))->ifa_list->ifa_local))){ DBGLOG(REQ, INFO, ("ip is not avaliable.\n")); return NOTIFY_DONE; } kalMemCopy(ip, &(((struct in_device *)(prDev->ip_ptr))->ifa_list->ifa_local), sizeof(ip)); DBGLOG(REQ, INFO, ("ip is %d.%d.%d.%d\n", ip[0],ip[1],ip[2],ip[3])); #endif // todo: traverse between list to find whole sets of IPv4 addresses if (!((ip[0] == 0) && (ip[1] == 0) && (ip[2] == 0) && (ip[3] == 0))) { u4NumIPv4++; } #if defined(MTK_WLAN_ARP_OFFLOAD) if(NETDEV_UP == notification && PARAM_MEDIA_STATE_CONNECTED == prGlueInfo->eParamMediaStateIndicated){ PARAM_CUSTOM_SW_CTRL_STRUC_T SwCtrlInfo; UINT_32 u4SetInfoLen; WLAN_STATUS rStatus = WLAN_STATUS_FAILURE; SwCtrlInfo.u4Id = 0x90110000; SwCtrlInfo.u4Data = 1; rStatus = kalIoctl(prGlueInfo, wlanoidSetSwCtrlWrite, (PVOID)&SwCtrlInfo, sizeof(SwCtrlInfo), FALSE, FALSE, TRUE, FALSE, &u4SetInfoLen); if (rStatus != WLAN_STATUS_SUCCESS) { DBGLOG(REQ, INFO, ("ARP OFFLOAD fail 0x%lx\n", rStatus)); }else{ DBGLOG(REQ, INFO, ("ARP OFFLOAD success\n")); } } #endif #ifdef FIX_ALPS00409409406 if(atomic_read(&fgIsUnderEarlierSuspend)==0){ #else if (fgIsUnderEarlierSuspend == false) { #endif DBGLOG(REQ, INFO, ("netdev_event: PARAM_MEDIA_STATE_DISCONNECTED. (%d)\n", prGlueInfo->eParamMediaStateIndicated)); return NOTIFY_DONE; } //#ifdef CONFIG_IPV6 #if 0 if(!prDev || !(prDev->ip6_ptr)||\ !((struct in_device *)(prDev->ip6_ptr))->ifa_list||\ !(&(((struct in_device *)(prDev->ip6_ptr))->ifa_list->ifa_local))){ printk(KERN_INFO "ipv6 is not avaliable.\n"); return NOTIFY_DONE; } kalMemCopy(ip6, &(((struct in_device *)(prDev->ip6_ptr))->ifa_list->ifa_local), sizeof(ip6)); printk(KERN_INFO"ipv6 is %d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d\n", ip6[0],ip6[1],ip6[2],ip6[3], ip6[4],ip6[5],ip6[6],ip6[7], ip6[8],ip6[9],ip6[10],ip6[11], ip6[12],ip6[13],ip6[14],ip6[15] ); // todo: traverse between list to find whole sets of IPv6 addresses if (!((ip6[0] == 0) && (ip6[1] == 0) && (ip6[2] == 0) && (ip6[3] == 0) && (ip6[4] == 0) && (ip6[5] == 0))) { //u4NumIPv6++; } #endif // here we can compare the dev with other network's netdev to // set the proper arp filter // // IMPORTANT: please make sure if the context can sleep, if the context can't sleep // we should schedule a kernel thread to do this for us // <7> set up the ARP filter { WLAN_STATUS rStatus = WLAN_STATUS_FAILURE; UINT_32 u4SetInfoLen = 0; UINT_8 aucBuf[32] = {0}; UINT_32 u4Len = OFFSET_OF(PARAM_NETWORK_ADDRESS_LIST, arAddress); P_PARAM_NETWORK_ADDRESS_LIST prParamNetAddrList = (P_PARAM_NETWORK_ADDRESS_LIST)aucBuf; P_PARAM_NETWORK_ADDRESS prParamNetAddr = prParamNetAddrList->arAddress; //#ifdef CONFIG_IPV6 #if 0 prParamNetAddrList->u4AddressCount = u4NumIPv4 + u4NumIPv6; #else prParamNetAddrList->u4AddressCount = u4NumIPv4; #endif prParamNetAddrList->u2AddressType = PARAM_PROTOCOL_ID_TCP_IP; for (i = 0; i < u4NumIPv4; i++) { prParamNetAddr->u2AddressLength = sizeof(PARAM_NETWORK_ADDRESS_IP);//4;; prParamNetAddr->u2AddressType = PARAM_PROTOCOL_ID_TCP_IP;; #if 0 kalMemCopy(prParamNetAddr->aucAddress, ip, sizeof(ip)); prParamNetAddr = (P_PARAM_NETWORK_ADDRESS)((UINT_32)prParamNetAddr + sizeof(ip)); u4Len += OFFSET_OF(PARAM_NETWORK_ADDRESS, aucAddress) + sizeof(ip); #else prParamIpAddr = (P_PARAM_NETWORK_ADDRESS_IP)prParamNetAddr->aucAddress; kalMemCopy(&prParamIpAddr->in_addr, ip, sizeof(ip)); prParamNetAddr = (P_PARAM_NETWORK_ADDRESS)((UINT_32)prParamNetAddr + sizeof(PARAM_NETWORK_ADDRESS)); u4Len += OFFSET_OF(PARAM_NETWORK_ADDRESS, aucAddress) + sizeof(PARAM_NETWORK_ADDRESS); #endif } //#ifdef CONFIG_IPV6 #if 0 for (i = 0; i < u4NumIPv6; i++) { prParamNetAddr->u2AddressLength = 6;; prParamNetAddr->u2AddressType = PARAM_PROTOCOL_ID_TCP_IP;; kalMemCopy(prParamNetAddr->aucAddress, ip6, sizeof(ip6)); prParamNetAddr = (P_PARAM_NETWORK_ADDRESS)((UINT_32)prParamNetAddr + sizeof(ip6)); u4Len += OFFSET_OF(PARAM_NETWORK_ADDRESS, aucAddress) + sizeof(ip6); } #endif ASSERT(u4Len <= sizeof(aucBuf)); DBGLOG(REQ, INFO, ("kalIoctl (0x%x, 0x%x)\n", prGlueInfo, prParamNetAddrList)); rStatus = kalIoctl(prGlueInfo, wlanoidSetNetworkAddress, (PVOID)prParamNetAddrList, u4Len, FALSE, FALSE, TRUE, FALSE, &u4SetInfoLen); if (rStatus != WLAN_STATUS_SUCCESS) { DBGLOG(REQ, INFO, ("set HW pattern filter fail 0x%lx\n", rStatus)); } } return NOTIFY_DONE; } static struct notifier_block inetaddr_notifier = { .notifier_call = netdev_event, }; void wlanRegisterNotifier(void) { register_inetaddr_notifier(&inetaddr_notifier); }
/*----------------------------------------------------------------------------*/ VOID kalP2PInvitationIndication(IN P_GLUE_INFO_T prGlueInfo, IN P_P2P_DEVICE_DESC_T prP2pDevDesc, IN PUINT_8 pucSsid, IN UINT_8 ucSsidLen, IN UINT_8 ucOperatingChnl, IN UINT_8 ucInvitationType, IN PUINT_8 pucGroupBssid) { #if 1 union iwreq_data evt; UINT_8 aucBuffer[IW_CUSTOM_MAX]; ASSERT(prGlueInfo); /* buffer peer information for later IOC_P2P_GET_STRUCT access */ prGlueInfo->prP2PInfo->u4ConnReqNameLength = (UINT_32) ((prP2pDevDesc->u2NameLength > 32) ? 32 : prP2pDevDesc->u2NameLength); kalMemCopy(prGlueInfo->prP2PInfo->aucConnReqDevName, prP2pDevDesc->aucName, prGlueInfo->prP2PInfo->u4ConnReqNameLength); COPY_MAC_ADDR(prGlueInfo->prP2PInfo->rConnReqPeerAddr, prP2pDevDesc->aucDeviceAddr); COPY_MAC_ADDR(prGlueInfo->prP2PInfo->rConnReqGroupAddr, pucGroupBssid); prGlueInfo->prP2PInfo->i4ConnReqConfigMethod = (INT_32) (prP2pDevDesc->u2ConfigMethod); prGlueInfo->prP2PInfo->ucOperatingChnl = ucOperatingChnl; prGlueInfo->prP2PInfo->ucInvitationType = ucInvitationType; /* prepare event structure */ memset(&evt, 0, sizeof(evt)); snprintf(aucBuffer, IW_CUSTOM_MAX - 1, "P2P_INV_INDICATE"); evt.data.length = strlen(aucBuffer); /* indicate in IWEVCUSTOM event */ wireless_send_event(prGlueInfo->prP2PInfo->prDevHandler, IWEVCUSTOM, &evt, aucBuffer); return; #else P_MSG_P2P_CONNECTION_REQUEST_T prP2pConnReq = (P_MSG_P2P_CONNECTION_REQUEST_T) NULL; P_P2P_SPECIFIC_BSS_INFO_T prP2pSpecificBssInfo = (P_P2P_SPECIFIC_BSS_INFO_T) NULL; P_P2P_CONNECTION_SETTINGS_T prP2pConnSettings = (P_P2P_CONNECTION_SETTINGS_T) NULL; do { ASSERT_BREAK((prGlueInfo != NULL) && (prP2pDevDesc != NULL)); /* Not a real solution */ prP2pSpecificBssInfo = prGlueInfo->prAdapter->rWifiVar.prP2pSpecificBssInfo; prP2pConnSettings = prGlueInfo->prAdapter->rWifiVar.prP2PConnSettings; prP2pConnReq = (P_MSG_P2P_CONNECTION_REQUEST_T) cnmMemAlloc(prGlueInfo->prAdapter, RAM_TYPE_MSG, sizeof (MSG_P2P_CONNECTION_REQUEST_T)); if (prP2pConnReq == NULL) { break; } kalMemZero(prP2pConnReq, sizeof(MSG_P2P_CONNECTION_REQUEST_T)); prP2pConnReq->rMsgHdr.eMsgId = MID_MNY_P2P_CONNECTION_REQ; prP2pConnReq->eFormationPolicy = ENUM_P2P_FORMATION_POLICY_AUTO; COPY_MAC_ADDR(prP2pConnReq->aucDeviceID, prP2pDevDesc->aucDeviceAddr); prP2pConnReq->u2ConfigMethod = prP2pDevDesc->u2ConfigMethod; if (ucInvitationType == P2P_INVITATION_TYPE_INVITATION) { prP2pConnReq->fgIsPersistentGroup = FALSE; prP2pConnReq->fgIsTobeGO = FALSE; } else if (ucInvitationType == P2P_INVITATION_TYPE_REINVOKE) { DBGLOG(P2P, TRACE, ("Re-invoke Persistent Group\n")); prP2pConnReq->fgIsPersistentGroup = TRUE; prP2pConnReq->fgIsTobeGO = (prGlueInfo->prP2PInfo->ucRole == 2) ? TRUE : FALSE; } p2pFsmRunEventDeviceDiscoveryAbort(prGlueInfo->prAdapter, NULL); if (ucOperatingChnl != 0) { prP2pSpecificBssInfo->ucPreferredChannel = ucOperatingChnl; } if ((ucSsidLen < 32) && (pucSsid != NULL)) { COPY_SSID(prP2pConnSettings->aucSSID, prP2pConnSettings->ucSSIDLen, pucSsid, ucSsidLen); } mboxSendMsg(prGlueInfo->prAdapter, MBOX_ID_0, (P_MSG_HDR_T) prP2pConnReq, MSG_SEND_METHOD_BUF); } while (FALSE); /* frog add. */ /* TODO: Invitation Indication */ return; #endif } /* kalP2PInvitationIndication */
VOID wfdFuncGenerateWfd_IE ( IN P_ADAPTER_T prAdapter, IN BOOLEAN fgIsAssocFrame, IN PUINT_16 pu2Offset, IN PUINT_8 pucBuf, IN UINT_16 u2BufSize, IN APPEND_VAR_ATTRI_ENTRY_T arAppendAttriTable[], IN UINT_32 u4AttriTableSize ) { PUINT_8 pucBuffer = (PUINT_8)NULL; P_IE_WFD_T prIeWFD = (P_IE_WFD_T)NULL; UINT_32 u4OverallAttriLen; UINT_32 u4AttriLen; UINT_8 aucWfaOui[] = VENDOR_OUI_WFA_SPECIFIC; UINT_8 aucTempBuffer[P2P_MAXIMUM_ATTRIBUTE_LEN]; UINT_32 i; do { ASSERT_BREAK((prAdapter != NULL) && (pucBuf != NULL)); pucBuffer = (PUINT_8)((UINT_32)pucBuf + (*pu2Offset)); ASSERT_BREAK(pucBuffer != NULL); /* Check buffer length is still enough. */ ASSERT_BREAK((u2BufSize - (*pu2Offset)) >= WFD_IE_OUI_HDR); prIeWFD = (P_IE_WFD_T)pucBuffer; prIeWFD->ucId = ELEM_ID_WFD; prIeWFD->aucOui[0] = aucWfaOui[0]; prIeWFD->aucOui[1] = aucWfaOui[1]; prIeWFD->aucOui[2] = aucWfaOui[2]; prIeWFD->ucOuiType = VENDOR_OUI_TYPE_WFD; (*pu2Offset) += WFD_IE_OUI_HDR; /* Overall length of all Attributes */ u4OverallAttriLen = 0; for (i = 0; i < u4AttriTableSize; i++) { if (arAppendAttriTable[i].pfnAppendAttri) { u4AttriLen = arAppendAttriTable[i].pfnAppendAttri(prAdapter, fgIsAssocFrame, pu2Offset, pucBuf, u2BufSize); u4OverallAttriLen += u4AttriLen; if (u4OverallAttriLen > P2P_MAXIMUM_ATTRIBUTE_LEN) { u4OverallAttriLen -= P2P_MAXIMUM_ATTRIBUTE_LEN; prIeWFD->ucLength = (VENDOR_OUI_TYPE_LEN + P2P_MAXIMUM_ATTRIBUTE_LEN); pucBuffer = (PUINT_8)((UINT_32)prIeWFD + (WFD_IE_OUI_HDR + P2P_MAXIMUM_ATTRIBUTE_LEN)); prIeWFD = (P_IE_WFD_T)((UINT_32)prIeWFD + (WFD_IE_OUI_HDR + P2P_MAXIMUM_ATTRIBUTE_LEN)); kalMemCopy(aucTempBuffer, pucBuffer, u4OverallAttriLen); prIeWFD->ucId = ELEM_ID_WFD; prIeWFD->aucOui[0] = aucWfaOui[0]; prIeWFD->aucOui[1] = aucWfaOui[1]; prIeWFD->aucOui[2] = aucWfaOui[2]; prIeWFD->ucOuiType = VENDOR_OUI_TYPE_WFD; kalMemCopy(prIeWFD->aucWFDAttributes, aucTempBuffer, u4OverallAttriLen); (*pu2Offset) += WFD_IE_OUI_HDR; } } } prIeWFD->ucLength = (UINT_8)(VENDOR_OUI_TYPE_LEN + u4OverallAttriLen); } while (FALSE); return; } /* wfdFuncGenerateWfd_IE */
/*----------------------------------------------------------------------------*/ VOID joinComplete(IN P_ADAPTER_T prAdapter) { P_JOIN_INFO_T prJoinInfo; P_BSS_DESC_T prBssDesc; P_PEER_BSS_INFO_T prPeerBssInfo; P_BSS_INFO_T prBssInfo; P_CONNECTION_SETTINGS_T prConnSettings; P_STA_RECORD_T prStaRec; P_TX_CTRL_T prTxCtrl; #if CFG_SUPPORT_802_11D P_IE_COUNTRY_T prIECountry; #endif DEBUGFUNC("joinComplete"); ASSERT(prAdapter); prJoinInfo = &prAdapter->rJoinInfo; prBssDesc = prJoinInfo->prBssDesc; prPeerBssInfo = &prAdapter->rPeerBssInfo; prBssInfo = &prAdapter->rBssInfo; prConnSettings = &prAdapter->rConnSettings; prTxCtrl = &prAdapter->rTxCtrl; /* 4 <1> Update Connecting & Connected Flag of BSS_DESC_T. */ /* Remove previous AP's Connection Flags if have */ scanRemoveConnectionFlagOfBssDescByBssid(prAdapter, prBssInfo->aucBSSID); prBssDesc->fgIsConnected = TRUE; /* Mask as Connected */ if (prBssDesc->fgIsHiddenSSID) { /* NOTE(Kevin): This is for the case of Passive Scan and the target BSS didn't * broadcast SSID on its Beacon Frame. */ COPY_SSID(prBssDesc->aucSSID, prBssDesc->ucSSIDLen, prAdapter->rConnSettings.aucSSID, prAdapter->rConnSettings.ucSSIDLen); if (prBssDesc->ucSSIDLen) prBssDesc->fgIsHiddenSSID = FALSE; #if DBG else ASSERT(0); #endif /* DBG */ DBGLOG(JOIN, INFO, ("Hidden SSID! - Update SSID : %s\n", prBssDesc->aucSSID)); } /* 4 <2> Update BSS_INFO_T from BSS_DESC_T */ /* 4 <2.A> PHY Type */ prBssInfo->ePhyType = prBssDesc->ePhyType; /* 4 <2.B> BSS Type */ prBssInfo->eBSSType = BSS_TYPE_INFRASTRUCTURE; /* 4 <2.C> BSSID */ COPY_MAC_ADDR(prBssInfo->aucBSSID, prBssDesc->aucBSSID); DBGLOG(JOIN, INFO, ("JOIN to BSSID: [" MACSTR "]\n", MAC2STR(prBssDesc->aucBSSID))); /* 4 <2.D> SSID */ COPY_SSID(prBssInfo->aucSSID, prBssInfo->ucSSIDLen, prBssDesc->aucSSID, prBssDesc->ucSSIDLen); /* 4 <2.E> Channel / Band information. */ prBssInfo->eBand = prBssDesc->eBand; prBssInfo->ucChnl = prBssDesc->ucChannelNum; /* 4 <2.F> RSN/WPA information. */ secFsmRunEventStart(prAdapter); prBssInfo->u4RsnSelectedPairwiseCipher = prBssDesc->u4RsnSelectedPairwiseCipher; prBssInfo->u4RsnSelectedGroupCipher = prBssDesc->u4RsnSelectedGroupCipher; prBssInfo->u4RsnSelectedAKMSuite = prBssDesc->u4RsnSelectedAKMSuite; if (secRsnKeyHandshakeEnabled()) prBssInfo->fgIsWPAorWPA2Enabled = TRUE; else prBssInfo->fgIsWPAorWPA2Enabled = FALSE; /* 4 <2.G> Beacon interval. */ prBssInfo->u2BeaconInterval = prBssDesc->u2BeaconInterval; /* 4 <2.H> DTIM period. */ prBssInfo->ucDtimPeriod = prBssDesc->ucDTIMPeriod; /* 4 <2.I> ERP Information */ if ((prBssInfo->ePhyType == PHY_TYPE_ERP_INDEX) && /* Our BSS's PHY_TYPE is ERP now. */ (prBssDesc->fgIsERPPresent)) { prBssInfo->fgIsERPPresent = TRUE; prBssInfo->ucERP = prBssDesc->ucERP; /* Save the ERP for later check */ } else { /* Some AP, may send ProbeResp without ERP IE. Thus prBssDesc->fgIsERPPresent is FALSE. */ prBssInfo->fgIsERPPresent = FALSE; prBssInfo->ucERP = 0; } #if CFG_SUPPORT_802_11D /* 4 <2.J> Country inforamtion of the associated AP */ if (prConnSettings->fgMultiDomainCapabilityEnabled) { DOMAIN_INFO_ENTRY rDomainInfo; if (domainGetDomainInfoByScanResult(prAdapter, &rDomainInfo)) { if (prBssDesc->prIECountry) { prIECountry = prBssDesc->prIECountry; domainParseCountryInfoElem(prIECountry, &prBssInfo->rDomainInfo); /* use the domain get from the BSS info */ prBssInfo->fgIsCountryInfoPresent = TRUE; nicSetupOpChnlList(prAdapter, prBssInfo->rDomainInfo.u2CountryCode, FALSE); } else { /* use the domain get from the scan result */ prBssInfo->fgIsCountryInfoPresent = TRUE; nicSetupOpChnlList(prAdapter, rDomainInfo.u2CountryCode, FALSE); } } } #endif /* 4 <2.K> Signal Power of the associated AP */ prBssInfo->rRcpi = prBssDesc->rRcpi; prBssInfo->rRssi = RCPI_TO_dBm(prBssInfo->rRcpi); GET_CURRENT_SYSTIME(&prBssInfo->rRssiLastUpdateTime); /* 4 <2.L> Capability Field of the associated AP */ prBssInfo->u2CapInfo = prBssDesc->u2CapInfo; DBGLOG(JOIN, INFO, ("prBssInfo-> fgIsERPPresent = %d, ucERP = %02x, rRcpi = %d, rRssi = %ld\n", prBssInfo->fgIsERPPresent, prBssInfo->ucERP, prBssInfo->rRcpi, prBssInfo->rRssi)); /* 4 <3> Update BSS_INFO_T from PEER_BSS_INFO_T & NIC RATE FUNC */ /* 4 <3.A> Association ID */ prBssInfo->u2AssocId = prPeerBssInfo->u2AssocId; /* 4 <3.B> WMM Infomation */ if (prAdapter->fgIsEnableWMM && (prPeerBssInfo->rWmmInfo.ucWmmFlag & WMM_FLAG_SUPPORT_WMM)) { prBssInfo->fgIsWmmAssoc = TRUE; prTxCtrl->rTxQForVoipAccess = TXQ_AC3; qosWmmInfoInit(&prBssInfo->rWmmInfo, (prBssInfo->ePhyType == PHY_TYPE_HR_DSSS_INDEX) ? TRUE : FALSE); if (prPeerBssInfo->rWmmInfo.ucWmmFlag & WMM_FLAG_AC_PARAM_PRESENT) { kalMemCopy(&prBssInfo->rWmmInfo, &prPeerBssInfo->rWmmInfo, sizeof(WMM_INFO_T)); } else { kalMemCopy(&prBssInfo->rWmmInfo, &prPeerBssInfo->rWmmInfo, sizeof(WMM_INFO_T) - sizeof(prPeerBssInfo->rWmmInfo.arWmmAcParams)); } } else { prBssInfo->fgIsWmmAssoc = FALSE; prTxCtrl->rTxQForVoipAccess = TXQ_AC1; kalMemZero(&prBssInfo->rWmmInfo, sizeof(WMM_INFO_T)); } /* 4 <3.C> Operational Rate Set & BSS Basic Rate Set */ prBssInfo->u2OperationalRateSet = prPeerBssInfo->u2OperationalRateSet; prBssInfo->u2BSSBasicRateSet = prPeerBssInfo->u2BSSBasicRateSet; /* 4 <3.D> Short Preamble */ if (prBssInfo->fgIsERPPresent) { /* NOTE(Kevin 2007/12/24): Truth Table. * Short Preamble Bit in * <AssocReq><AssocResp w/i ERP><BARKER(Long)>Final Driver Setting(Short) * TRUE FALSE FALSE FALSE(shouldn't have such case, use the AssocResp) * TRUE FALSE TRUE FALSE * FALSE FALSE FALSE FALSE(shouldn't have such case, use the AssocResp) * FALSE FALSE TRUE FALSE * TRUE TRUE FALSE TRUE(follow ERP) * TRUE TRUE TRUE FALSE(follow ERP) * FALSE TRUE FALSE FALSE(shouldn't have such case, and we should set to FALSE) * FALSE TRUE TRUE FALSE(we should set to FALSE) */ if ((prPeerBssInfo->fgIsShortPreambleAllowed) && ((prConnSettings->ePreambleType == PREAMBLE_TYPE_SHORT) || /* Short Preamble Option Enable is TRUE */ ((prConnSettings->ePreambleType == PREAMBLE_TYPE_AUTO) && (prBssDesc-> u2CapInfo & CAP_INFO_SHORT_PREAMBLE)))) { prBssInfo->fgIsShortPreambleAllowed = TRUE; if (prBssInfo->ucERP & ERP_INFO_BARKER_PREAMBLE_MODE) prBssInfo->fgUseShortPreamble = FALSE; else prBssInfo->fgUseShortPreamble = TRUE; } else { prBssInfo->fgIsShortPreambleAllowed = FALSE; prBssInfo->fgUseShortPreamble = FALSE; } } else { /* NOTE(Kevin 2007/12/24): Truth Table. * Short Preamble Bit in * <AssocReq> <AssocResp w/o ERP> Final Driver Setting(Short) * TRUE FALSE FALSE * FALSE FALSE FALSE * TRUE TRUE TRUE * FALSE TRUE(status success) TRUE * --> Honor the result of prPeerBssInfo. */ prBssInfo->fgIsShortPreambleAllowed = prBssInfo->fgUseShortPreamble = prPeerBssInfo->fgIsShortPreambleAllowed; } DBGLOG(JOIN, INFO, ("prBssInfo->fgIsShortPreambleAllowed = %d, prBssInfo->fgUseShortPreamble = %d\n", prBssInfo->fgIsShortPreambleAllowed, prBssInfo->fgUseShortPreamble)); /* 4 <3.E> Short Slot Time */ prBssInfo->fgUseShortSlotTime = prPeerBssInfo->fgUseShortSlotTime; /* AP support Short Slot Time */ DBGLOG(JOIN, INFO, ("prBssInfo->fgUseShortSlotTime = %d\n", prBssInfo->fgUseShortSlotTime)); nicSetSlotTime(prAdapter, prBssInfo->ePhyType, ((prConnSettings->fgIsShortSlotTimeOptionEnable && prBssInfo->fgUseShortSlotTime) ? TRUE : FALSE)); /* 4 <3.F> Update Tx Rate for Control Frame */ bssUpdateTxRateForControlFrame(prAdapter); /* 4 <3.G> Save the available Auth Types during Roaming (Design for Fast BSS Transition). */ /* if (prAdapter->fgIsEnableRoaming) */ /* NOTE(Kevin): Always prepare info for roaming */ { if (prJoinInfo->ucCurrAuthAlgNum == AUTH_ALGORITHM_NUM_OPEN_SYSTEM) prJoinInfo->ucRoamingAuthTypes |= AUTH_TYPE_OPEN_SYSTEM; else if (prJoinInfo->ucCurrAuthAlgNum == AUTH_ALGORITHM_NUM_SHARED_KEY) prJoinInfo->ucRoamingAuthTypes |= AUTH_TYPE_SHARED_KEY; prBssInfo->ucRoamingAuthTypes = prJoinInfo->ucRoamingAuthTypes; /* Set the stable time of the associated BSS. We won't do roaming decision * during the stable time. */ SET_EXPIRATION_TIME(prBssInfo->rRoamingStableExpirationTime, SEC_TO_SYSTIME(ROAMING_STABLE_TIMEOUT_SEC)); } /* 4 <3.H> Update Parameter for TX Fragmentation Threshold */ #if CFG_TX_FRAGMENT txFragInfoUpdate(prAdapter); #endif /* CFG_TX_FRAGMENT */ /* 4 <4> Update STA_RECORD_T */ /* Get a Station Record if possible */ prStaRec = staRecGetStaRecordByAddr(prAdapter, prBssDesc->aucBSSID); if (prStaRec) { UINT_16 u2OperationalRateSet, u2DesiredRateSet; /* 4 <4.A> Desired Rate Set */ u2OperationalRateSet = (rPhyAttributes[prBssInfo->ePhyType].u2SupportedRateSet & prBssInfo->u2OperationalRateSet); u2DesiredRateSet = (u2OperationalRateSet & prConnSettings->u2DesiredRateSet); if (u2DesiredRateSet) { prStaRec->u2DesiredRateSet = u2DesiredRateSet; } else { /* For Error Handling - The Desired Rate Set is not covered in Operational Rate Set. */ prStaRec->u2DesiredRateSet = u2OperationalRateSet; } /* Try to set the best initial rate for this entry */ if (!rateGetBestInitialRateIndex(prStaRec->u2DesiredRateSet, prStaRec->rRcpi, &prStaRec->ucCurrRate1Index)) { if (!rateGetLowestRateIndexFromRateSet(prStaRec->u2DesiredRateSet, &prStaRec->ucCurrRate1Index)) { ASSERT(0); } } DBGLOG(JOIN, INFO, ("prStaRec->ucCurrRate1Index = %d\n", prStaRec->ucCurrRate1Index)); /* 4 <4.B> Preamble Mode */ prStaRec->fgIsShortPreambleOptionEnable = prBssInfo->fgUseShortPreamble; /* 4 <4.C> QoS Flag */ prStaRec->fgIsQoS = prBssInfo->fgIsWmmAssoc; } #if DBG else ASSERT(0); #endif /* DBG */ /* 4 <5> Update NIC */ /* 4 <5.A> Update BSSID & Operation Mode */ nicSetupBSS(prAdapter, prBssInfo); /* 4 <5.B> Update WLAN Table. */ if (nicSetHwBySta(prAdapter, prStaRec) == FALSE) ASSERT(FALSE); /* 4 <5.C> Update Desired Rate Set for BT. */ #if CFG_TX_FRAGMENT if (prConnSettings->fgIsEnableTxAutoFragmentForBT) txRateSetInitForBT(prAdapter, prStaRec); #endif /* CFG_TX_FRAGMENT */ /* 4 <5.D> TX AC Parameter and TX/RX Queue Control */ if (prBssInfo->fgIsWmmAssoc) { #if CFG_TX_AGGREGATE_HW_FIFO nicTxAggregateTXQ(prAdapter, FALSE); #endif /* CFG_TX_AGGREGATE_HW_FIFO */ qosUpdateWMMParametersAndAssignAllowedACI(prAdapter, &prBssInfo->rWmmInfo); } else { #if CFG_TX_AGGREGATE_HW_FIFO nicTxAggregateTXQ(prAdapter, TRUE); #endif /* CFG_TX_AGGREGATE_HW_FIFO */ nicTxNonQoSAssignDefaultAdmittedTXQ(prAdapter); nicTxNonQoSUpdateTXQParameters(prAdapter, prBssInfo->ePhyType); } #if CFG_TX_STOP_WRITE_TX_FIFO_UNTIL_JOIN { prTxCtrl->fgBlockTxDuringJoin = FALSE; #if !CFG_TX_AGGREGATE_HW_FIFO /* TX FIFO AGGREGATE already do flush once */ nicTxFlushStopQueues(prAdapter, (UINT_8) TXQ_DATA_MASK, (UINT_8) NULL); #endif /* CFG_TX_AGGREGATE_HW_FIFO */ nicTxRetransmitOfSendWaitQue(prAdapter); if (prTxCtrl->fgIsPacketInOsSendQueue) nicTxRetransmitOfOsSendQue(prAdapter); #if CFG_SDIO_TX_ENHANCE halTxLeftClusteredMpdu(prAdapter); #endif /* CFG_SDIO_TX_ENHANCE */ } #endif /* CFG_TX_STOP_WRITE_TX_FIFO_UNTIL_JOIN */ /* 4 <6> Setup CONNECTION flag. */ prAdapter->eConnectionState = MEDIA_STATE_CONNECTED; prAdapter->eConnectionStateIndicated = MEDIA_STATE_CONNECTED; if (prJoinInfo->fgIsReAssoc) prAdapter->fgBypassPortCtrlForRoaming = TRUE; else prAdapter->fgBypassPortCtrlForRoaming = FALSE; kalIndicateStatusAndComplete(prAdapter->prGlueInfo, WLAN_STATUS_MEDIA_CONNECT, (PVOID) NULL, 0); return; } /* end of joinComplete() */
static void wlanP2PEarlySuspend(void) { struct net_device *prDev = NULL; P_GLUE_INFO_T prGlueInfo = NULL; UINT_8 ip[4] = { 0 }; UINT_32 u4NumIPv4 = 0; #ifdef CONFIG_IPV6 UINT_8 ip6[16] = { 0 }; /* FIX ME: avoid to allocate large memory in stack */ UINT_32 u4NumIPv6 = 0; #endif UINT_32 i; P_PARAM_NETWORK_ADDRESS_IP prParamIpAddr; printk(KERN_INFO "*********p2pEarlySuspend************\n"); if (!wlanExportGlueInfo(&prGlueInfo)) { printk(KERN_INFO "*********p2pEarlySuspend ignored************\n"); return; } ASSERT(prGlueInfo); /* <1> Sanity check and acquire the net_device */ prDev = prGlueInfo->prP2PInfo->prDevHandler; ASSERT(prDev); /* <3> get the IPv4 address */ if (!prDev || !(prDev->ip_ptr) || !((struct in_device *)(prDev->ip_ptr))->ifa_list || !(&(((struct in_device *)(prDev->ip_ptr))->ifa_list->ifa_local))) { printk(KERN_INFO "ip is not avaliable.\n"); return; } /* <4> copy the IPv4 address */ kalMemCopy(ip, &(((struct in_device *)(prDev->ip_ptr))->ifa_list->ifa_local), sizeof(ip)); printk(KERN_INFO "ip is %d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]); /* todo: traverse between list to find whole sets of IPv4 addresses */ if (!((ip[0] == 0) && (ip[1] == 0) && (ip[2] == 0) && (ip[3] == 0))) { u4NumIPv4++; } #ifdef CONFIG_IPV6 /* <5> get the IPv6 address */ if (!prDev || !(prDev->ip6_ptr) || !((struct in_device *)(prDev->ip6_ptr))->ifa_list || !(&(((struct in_device *)(prDev->ip6_ptr))->ifa_list->ifa_local))) { printk(KERN_INFO "ipv6 is not avaliable.\n"); return; } /* <6> copy the IPv6 address */ kalMemCopy(ip6, &(((struct in_device *)(prDev->ip6_ptr))->ifa_list->ifa_local), sizeof(ip6)); printk(KERN_INFO "ipv6 is %d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d\n", ip6[0], ip6[1], ip6[2], ip6[3], ip6[4], ip6[5], ip6[6], ip6[7], ip6[8], ip6[9], ip6[10], ip6[11], ip6[12], ip6[13], ip6[14], ip6[15] ); /* todo: traverse between list to find whole sets of IPv6 addresses */ if (!((ip6[0] == 0) && (ip6[1] == 0) && (ip6[2] == 0) && (ip6[3] == 0) && (ip6[4] == 0) && (ip6[5] == 0))) { } #endif /* <7> set up the ARP filter */ { WLAN_STATUS rStatus = WLAN_STATUS_FAILURE; UINT_32 u4SetInfoLen = 0; /* UINT_8 aucBuf[32] = {0}; */ UINT_32 u4Len = OFFSET_OF(PARAM_NETWORK_ADDRESS_LIST, arAddress); P_PARAM_NETWORK_ADDRESS_LIST prParamNetAddrList = (P_PARAM_NETWORK_ADDRESS_LIST) g_aucBufIpAddr; /* aucBuf; */ P_PARAM_NETWORK_ADDRESS prParamNetAddr = prParamNetAddrList->arAddress; kalMemZero(g_aucBufIpAddr, sizeof(g_aucBufIpAddr)); prParamNetAddrList->u4AddressCount = u4NumIPv4 + u4NumIPv6; prParamNetAddrList->u2AddressType = PARAM_PROTOCOL_ID_TCP_IP; for (i = 0; i < u4NumIPv4; i++) { prParamNetAddr->u2AddressLength = sizeof(PARAM_NETWORK_ADDRESS_IP); /* 4;; */ prParamNetAddr->u2AddressType = PARAM_PROTOCOL_ID_TCP_IP; #if 0 kalMemCopy(prParamNetAddr->aucAddress, ip, sizeof(ip)); prParamNetAddr = (P_PARAM_NETWORK_ADDRESS) ((UINT_32) prParamNetAddr + sizeof(ip)); u4Len += OFFSET_OF(PARAM_NETWORK_ADDRESS, aucAddress) + sizeof(ip); #else prParamIpAddr = (P_PARAM_NETWORK_ADDRESS_IP) prParamNetAddr->aucAddress; kalMemCopy(&prParamIpAddr->in_addr, ip, sizeof(ip)); /* prParamNetAddr = (P_PARAM_NETWORK_ADDRESS)((UINT_32)prParamNetAddr + sizeof(PARAM_NETWORK_ADDRESS)); // TODO: frog. The pointer is not right. */ prParamNetAddr = (P_PARAM_NETWORK_ADDRESS) ((UINT_32) prParamNetAddr + (UINT_32) (prParamNetAddr-> u2AddressLength + OFFSET_OF (PARAM_NETWORK_ADDRESS, aucAddress))); u4Len += OFFSET_OF(PARAM_NETWORK_ADDRESS, aucAddress) + sizeof(PARAM_NETWORK_ADDRESS_IP); #endif } #ifdef CONFIG_IPV6 for (i = 0; i < u4NumIPv6; i++) { prParamNetAddr->u2AddressLength = 6; prParamNetAddr->u2AddressType = PARAM_PROTOCOL_ID_TCP_IP; kalMemCopy(prParamNetAddr->aucAddress, ip6, sizeof(ip6)); /* prParamNetAddr = (P_PARAM_NETWORK_ADDRESS)((UINT_32)prParamNetAddr + sizeof(ip6)); */ prParamNetAddr = (P_PARAM_NETWORK_ADDRESS) ((UINT_32) prParamNetAddr + (UINT_32) (prParamNetAddr-> u2AddressLength + OFFSET_OF (PARAM_NETWORK_ADDRESS, aucAddress))); u4Len += OFFSET_OF(PARAM_NETWORK_ADDRESS, aucAddress) + sizeof(ip6); } #endif ASSERT(u4Len <= sizeof(g_aucBufIpAddr /*aucBuf */)); rStatus = kalIoctl(prGlueInfo, wlanoidSetP2pSetNetworkAddress, (PVOID) prParamNetAddrList, u4Len, FALSE, FALSE, TRUE, TRUE, &u4SetInfoLen); if (rStatus != WLAN_STATUS_SUCCESS) { printk(KERN_INFO DRV_NAME "set HW pattern filter fail 0x%lx\n", rStatus); } } }
static void wlanP2PLateResume(void) { struct net_device *prDev = NULL; P_GLUE_INFO_T prGlueInfo = NULL; UINT_8 ip[4] = { 0 }; #ifdef CONFIG_IPV6 UINT_8 ip6[16] = { 0 }; /* FIX ME: avoid to allocate large memory in stack */ #endif printk(KERN_INFO "*********wlanP2PLateResume************\n"); if (!wlanExportGlueInfo(&prGlueInfo)) { printk(KERN_INFO "*********p2pLateResume ignored************\n"); return; } ASSERT(prGlueInfo); /* <1> Sanity check and acquire the net_device */ prDev = prGlueInfo->prP2PInfo->prDevHandler; ASSERT(prDev); /* <3> get the IPv4 address */ if (!prDev || !(prDev->ip_ptr) || !((struct in_device *)(prDev->ip_ptr))->ifa_list || !(&(((struct in_device *)(prDev->ip_ptr))->ifa_list->ifa_local))) { printk(KERN_INFO "ip is not avaliable.\n"); return; } /* <4> copy the IPv4 address */ kalMemCopy(ip, &(((struct in_device *)(prDev->ip_ptr))->ifa_list->ifa_local), sizeof(ip)); printk(KERN_INFO "ip is %d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]); #ifdef CONFIG_IPV6 /* <5> get the IPv6 address */ if (!prDev || !(prDev->ip6_ptr) || !((struct in_device *)(prDev->ip6_ptr))->ifa_list || !(&(((struct in_device *)(prDev->ip6_ptr))->ifa_list->ifa_local))) { printk(KERN_INFO "ipv6 is not avaliable.\n"); return; } /* <6> copy the IPv6 address */ kalMemCopy(ip6, &(((struct in_device *)(prDev->ip6_ptr))->ifa_list->ifa_local), sizeof(ip6)); printk(KERN_INFO "ipv6 is %d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d\n", ip6[0], ip6[1], ip6[2], ip6[3], ip6[4], ip6[5], ip6[6], ip6[7], ip6[8], ip6[9], ip6[10], ip6[11], ip6[12], ip6[13], ip6[14], ip6[15] ); #endif /* <7> clear the ARP filter */ { WLAN_STATUS rStatus = WLAN_STATUS_FAILURE; UINT_32 u4SetInfoLen = 0; /* UINT_8 aucBuf[32] = {0}; */ UINT_32 u4Len = sizeof(PARAM_NETWORK_ADDRESS_LIST); P_PARAM_NETWORK_ADDRESS_LIST prParamNetAddrList = (P_PARAM_NETWORK_ADDRESS_LIST) g_aucBufIpAddr; /* aucBuf; */ kalMemZero(g_aucBufIpAddr, sizeof(g_aucBufIpAddr)); prParamNetAddrList->u4AddressCount = 0; prParamNetAddrList->u2AddressType = PARAM_PROTOCOL_ID_TCP_IP; ASSERT(u4Len <= sizeof(g_aucBufIpAddr /*aucBuf */)); rStatus = kalIoctl(prGlueInfo, wlanoidSetP2pSetNetworkAddress, (PVOID) prParamNetAddrList, u4Len, FALSE, FALSE, TRUE, TRUE, &u4SetInfoLen); if (rStatus != WLAN_STATUS_SUCCESS) { printk(KERN_INFO DRV_NAME "set HW pattern filter fail 0x%lx\n", rStatus); } } }
/*----------------------------------------------------------------------------*/ VOID rlmFuncCommonChannelList(IN P_ADAPTER_T prAdapter, IN P_CHANNEL_ENTRY_FIELD_T prChannelEntryII, IN UINT_8 ucChannelListSize) { P_P2P_CONNECTION_SETTINGS_T prP2pConnSetting = (P_P2P_CONNECTION_SETTINGS_T) NULL; P_CHANNEL_ENTRY_FIELD_T prChannelEntryI = (P_CHANNEL_ENTRY_FIELD_T) NULL, prChannelEntryIII = (P_CHANNEL_ENTRY_FIELD_T) NULL; UINT_8 aucCommonChannelList[P2P_MAX_SUPPORTED_CHANNEL_LIST_SIZE]; UINT_8 ucOriChnlSize = 0, ucNewChnlSize = 0; do { ASSERT_BREAK(prAdapter != NULL); prP2pConnSetting = prAdapter->rWifiVar.prP2PConnSettings; prChannelEntryIII = (P_CHANNEL_ENTRY_FIELD_T) aucCommonChannelList; while (ucChannelListSize > 0) { prChannelEntryI = (P_CHANNEL_ENTRY_FIELD_T) prP2pConnSetting->aucChannelEntriesField; ucOriChnlSize = prP2pConnSetting->ucRfChannelListSize; while (ucOriChnlSize > 0) { if (prChannelEntryI->ucRegulatoryClass == prChannelEntryII->ucRegulatoryClass) { prChannelEntryIII->ucRegulatoryClass = prChannelEntryI->ucRegulatoryClass; /* TODO: Currently we assume that the regulatory class the same, the channels are the same. */ kalMemCopy(prChannelEntryIII->aucChannelList, prChannelEntryII->aucChannelList, prChannelEntryII->ucNumberOfChannels); prChannelEntryIII->ucNumberOfChannels = prChannelEntryII->ucNumberOfChannels; ucNewChnlSize += P2P_ATTRI_LEN_CHANNEL_ENTRY + prChannelEntryIII->ucNumberOfChannels; prChannelEntryIII = (P_CHANNEL_ENTRY_FIELD_T) ((ULONG) prChannelEntryIII + P2P_ATTRI_LEN_CHANNEL_ENTRY + (ULONG) prChannelEntryIII-> ucNumberOfChannels); } ucOriChnlSize -= (P2P_ATTRI_LEN_CHANNEL_ENTRY + prChannelEntryI->ucNumberOfChannels); prChannelEntryI = (P_CHANNEL_ENTRY_FIELD_T) ((ULONG) prChannelEntryI + P2P_ATTRI_LEN_CHANNEL_ENTRY + (ULONG) prChannelEntryI-> ucNumberOfChannels); } ucChannelListSize -= (P2P_ATTRI_LEN_CHANNEL_ENTRY + prChannelEntryII->ucNumberOfChannels); prChannelEntryII = (P_CHANNEL_ENTRY_FIELD_T) ((ULONG) prChannelEntryII + P2P_ATTRI_LEN_CHANNEL_ENTRY + (ULONG) prChannelEntryII-> ucNumberOfChannels); } kalMemCopy(prP2pConnSetting->aucChannelEntriesField, aucCommonChannelList, ucNewChnlSize); prP2pConnSetting->ucRfChannelListSize = ucNewChnlSize; } while (FALSE); return; } /* rlmFuncCommonChannelList */