bss_t * wlan_node_remove(struct ieee80211_node_table *nt, A_UINT8 *bssid) { bss_t *bss, *nextBss; IEEE80211_NODE_LOCK(nt); bss = nt->nt_node_first; while (bss != NULL) { nextBss = bss->ni_list_next; if (A_MEMCMP(bssid, bss->ni_macaddr, 6) == 0) { wlan_node_remove_core (nt, bss); IEEE80211_NODE_UNLOCK(nt); return bss; } bss = nextBss; } IEEE80211_NODE_UNLOCK(nt); return NULL; }
void CAR6KMini::removeNewStation(A_UINT8 *mac) { A_INT8 i; A_UINT8 sta_mac[6] = {0}; A_MEMCPY(sta_mac,mac,ETHERNET_MAC_ADDRESS_LENGTH); if(IS_MAC_NULL(sta_mac)) { return ; } for(i=0; i < AP_MAX_NUM_STA; i++) { if(A_MEMCMP(m_staList[i].mac, sta_mac, 6)==0) { /* Zero out the state fields */ A_MEMZERO(m_staList[i].mac, 6); A_MEMZERO(m_staList[i].wpa_ie, IEEE80211_MAX_IE); m_staList[i].aid = 0; m_staList[i].flags = 0; m_staList[i].m_keyState = 0; m_staList[i].PTKlength = 0; m_staList[i].hnd_shk_completed = FALSE; A_MEMZERO(m_staList[i].ANonce, sizeof (m_staList[i].ANonce)); A_MEMZERO(m_staList[i].SNonce, sizeof (m_staList[i].SNonce)); A_MEMZERO(m_staList[i].PTK, sizeof (m_staList[i].PTK)); m_staListIndex = m_staListIndex & ~(1 << i); flushNdisPacketQ(&(m_staList[i].ucastq)); m_AP_conn_sta -- ; } } }
void wlan_refresh_inactive_nodes (struct ieee80211_node_table *nt) { bss_t *bss, *nextBss; A_UINT8 myBssid[IEEE80211_ADDR_LEN]; A_UINT32 timeoutValue = 0; A_UINT32 now = A_GET_MS(0); timeoutValue = nt->nt_nodeAge; wmi_get_current_bssid(nt->nt_wmip, myBssid); bss = nt->nt_node_first; while (bss != NULL) { nextBss = bss->ni_list_next; if (A_MEMCMP(myBssid, bss->ni_macaddr, sizeof(myBssid)) != 0) { if (((now - bss->ni_tstamp) > timeoutValue) || --bss->ni_actcnt == 0) { /* * free up all but the current bss - if set */ wlan_node_reclaim(nt, bss); } } bss = nextBss; } }
void wlan_refresh_scan_table (struct ieee80211_node_table *nt, ULONGLONG OldestAllowedEntry) { bss_t *bss, *nextBss; A_UINT8 myBssid[IEEE80211_ADDR_LEN], reArmTimer = FALSE; wmi_get_current_bssid(nt->nt_wmip, myBssid); bss = nt->nt_node_first; while (bss != NULL) { nextBss = bss->ni_list_next; if (A_MEMCMP(myBssid, bss->ni_macaddr, sizeof(myBssid)) != 0) { if (bss->HostTimestamp <= OldestAllowedEntry) { /* * free up all but the current bss - if set */ wlan_node_reclaim(nt, bss); } } bss = nextBss; } }
static void wlan_node_timeout(void *arg) { struct ieee80211_node_table *nt = (struct ieee80211_node_table *)arg; bss_t *bss, *nextBss; A_UINT8 myBssid[IEEE80211_ADDR_LEN]; wmi_get_current_bssid(nt->nt_wmip, myBssid); IEEE80211_NODE_LOCK(nt); bss = nt->nt_node_first; while (bss != NULL) { nextBss = bss->ni_list_next; if ((A_MEMCMP(myBssid, bss->ni_macaddr, sizeof(myBssid)) != 0) && (bss->ni_tstamp <= A_MS_TICKGET())) { /* * free up all but the current bss - if set */ wlan_node_reclaim(nt, bss); } bss = nextBss; } IEEE80211_NODE_UNLOCK(nt); A_TIMEOUT_MS(&nt->nt_inact_timer, WLAN_NODE_INACT_TIMEOUT_MSEC, 0); }
void wlan_refresh_inactive_nodes (struct ieee80211_node_table *nt) { bss_t *bss, *nextBss; A_UINT8 myBssid[IEEE80211_ADDR_LEN]; A_UINT32 timeoutValue = 0; A_UINT32 now = A_GET_MS(0); timeoutValue = nt->nt_nodeAge; wmi_get_current_bssid(nt->nt_wmip, myBssid); bss = nt->nt_node_first; while (bss != NULL) { nextBss = bss->ni_list_next; if (A_MEMCMP(myBssid, bss->ni_macaddr, sizeof(myBssid)) != 0) { if (((now - bss->ni_tstamp) > timeoutValue) || --bss->ni_actcnt == 0) { PBYTE pIE; char a[128]; A_UINT32 length, ch, freq; //wchar_t b[128] = {0}; pIE = bss->ni_cie.ie_ssid; length = pIE[1]; memcpy( a, &pIE[2], length ); a[length] = '\0'; //MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, a, 32, b, 64 ); freq = bss->ni_cie.ie_chan; if (freq == 2484) ch = 14; else if (freq < 2484) ch = (freq - 2407) / 5; else if (freq < 5000) ch = 15 + ((freq - 2512) / 20); else ch = (freq - 5000) / 5; RETAIL_DEBUG_PRINTF(debugBssInfo, (TEXT("builder:ar6k2: remove bss info, SSID = %S, RSSI = %d, CHANNEL = %d\r\n"), a, bss->ni_rssi, ch)); RETAIL_DEBUG_PRINTF(debugBssInfo, (TEXT("builder:ar6k2: BSSID = %02x:%02x:%02x:%02x:%02x:%02x \r\n") , bss->ni_macaddr[0], bss->ni_macaddr[1], bss->ni_macaddr[2], bss->ni_macaddr[3], bss->ni_macaddr[4], bss->ni_macaddr[5])); logPrintf( (debugFileLog && debugBssInfo), "builder:ar6k2: remove bss info, SSID = %s, RSSI = %d, CHANNEL = %d\r\n", a, bss->ni_rssi, ch); logPrintf( (debugFileLog && debugBssInfo), "builder:ar6k2: BSSID = %02x:%02x:%02x:%02x:%02x:%02x \r\n", bss->ni_macaddr[0], bss->ni_macaddr[1], bss->ni_macaddr[2], bss->ni_macaddr[3], bss->ni_macaddr[4], bss->ni_macaddr[5]); /* * free up all but the current bss - if set */ wlan_node_reclaim(nt, bss); } } bss = nextBss; } }
static void NewLinkEvent(ATH_BT_FILTER_INSTANCE *pInstance, struct nlmsghdr *h, int len) { struct ifinfomsg *ifi; struct rtattr * attr; int attrlen, nlmsg_len, rta_len; ATHBT_FILTER_INFO *pInfo = (ATHBT_FILTER_INFO *)pInstance->pContext; ABF_WLAN_INFO *pAbfWlanInfo = (ABF_WLAN_INFO *)pInfo->pWlanInfo; if (len < sizeof(*ifi)) { A_DEBUG("packet too short\n"); return; } ifi = NLMSG_DATA(h); nlmsg_len = NLMSG_ALIGN(sizeof(struct ifinfomsg)); attrlen = h->nlmsg_len - nlmsg_len; if (attrlen < 0) { A_DEBUG("bad attrlen\n"); return; } attr = (struct rtattr *) (((char *) ifi) + nlmsg_len); rta_len = RTA_ALIGN(sizeof(struct rtattr)); while (RTA_OK(attr, attrlen)) { if (attr->rta_type == IFLA_WIRELESS) { /* * We need to ensure that the event is from the WLAN instance * that we are interested in TODO */ WirelessEvent(pInstance, ((char*)attr) + rta_len, attr->rta_len - rta_len); } else if (attr->rta_type == IFLA_IFNAME) { /* * Shall be used to get the socket descriptor. Also we should do * it only until we get the adapter we are interested in */ if (!pAbfWlanInfo->Handle) { A_DEBUG("WLAN Adapter Interface: %s, Len: %d\n", (((char *)attr) + rta_len), attr->rta_len - rta_len); A_MEMCPY(pAbfWlanInfo->IfName, ((char *)attr + rta_len), attr->rta_len - rta_len); pAbfWlanInfo->IfIndex = if_nametoindex(pAbfWlanInfo->IfName); } else if (ifi->ifi_change && pAbfWlanInfo->IfIndex == ifi->ifi_index) { A_CHAR ifName[IFNAMSIZ]; A_MEMCPY(ifName, ((char *)attr + rta_len), attr->rta_len - rta_len); if (A_MEMCMP(pAbfWlanInfo->IfName, ifName, sizeof(ifName))!=0) { A_MEMCPY(pAbfWlanInfo->IfName, ifName, sizeof(ifName)); } } } attr = RTA_NEXT(attr, attrlen); } }
void CAR6KMini::addNewStation(A_UINT8 *mac,A_UINT16 aid,A_UINT8 *wpaie,A_UINT8 ielen) { A_INT8 free_slot=-1,i; for(i=0;i<AP_MAX_NUM_STA;i++) { if(A_MEMCMP(m_staList[i].mac,mac,6) == 0) { NDIS_DEBUG_PRINTF(ATH_LOG_TRC,"AR6K: Station Already Available"); return ; /* Station already available cond. */ } if(!((1 << i) & m_staListIndex)) { free_slot = i; break; } } if(free_slot >= 0) { A_MEMCPY(m_staList[free_slot].mac,mac,6); A_MEMCPY(m_staList[free_slot].wpa_ie,wpaie,ielen); m_staList[free_slot].aid = aid; m_staList[free_slot].hnd_shk_completed = FALSE; m_staList[i].m_keyState = 0; m_staList[i].PTKlength = 0; A_MEMZERO(m_staList[i].ANonce, sizeof (m_staList[i].ANonce)); A_MEMZERO(m_staList[i].SNonce, sizeof (m_staList[i].SNonce)); A_MEMZERO(m_staList[i].PTK, sizeof (m_staList[i].PTK)); m_staListIndex = m_staListIndex | (1 << free_slot); InitializeListHead(&m_staList[free_slot].ucastq); m_AP_conn_sta ++; } else { NDIS_DEBUG_PRINTF(ATH_LOG_TRC,"AR6K: Error Adding New Station"); } if (m_AP_conn_sta == 1) { NdisMIndicateStatus (m_MiniportAdapterHandle, NDIS_STATUS_MEDIA_CONNECT, 0, 0); NdisMIndicateStatusComplete (m_MiniportAdapterHandle); } }
static ATH_DEBUG_MODULE_DBG_INFO *FindModule(A_CHAR *module_name) { ATH_DEBUG_MODULE_DBG_INFO *pInfo = g_pModuleInfoHead; if (!g_ModuleDebugInit) { return NULL; } while (pInfo != NULL) { /* TODO: need to use something other than strlen */ if (A_MEMCMP(pInfo->ModuleName,module_name,strlen(module_name)) == 0) { break; } pInfo = pInfo->pNext; } return pInfo; }
static void wlan_node_timeout (A_ATH_TIMER arg) { struct ieee80211_node_table *nt = (struct ieee80211_node_table *)arg; bss_t *bss, *nextBss; A_UINT8 myBssid[IEEE80211_ADDR_LEN], reArmTimer = FALSE; A_UINT32 timeoutValue = 0; timeoutValue = nt->nt_nodeAge; wmi_get_current_bssid(nt->nt_wmip, myBssid); bss = nt->nt_node_first; while (bss != NULL) { nextBss = bss->ni_list_next; if (A_MEMCMP(myBssid, bss->ni_macaddr, sizeof(myBssid)) != 0) { if (bss->ni_tstamp <= A_GET_MS(0)) { /* * free up all but the current bss - if set */ wlan_node_reclaim(nt, bss); } else { /* * Re-arm timer, only when we have a bss other than * current bss AND it is not aged-out. */ reArmTimer = TRUE; } } bss = nextBss; } if (reArmTimer) A_TIMEOUT_MS (&nt->nt_inact_timer, timeoutValue, 0); nt->isTimerArmed = reArmTimer; }
void a_dump_module_debug_info_by_name(A_CHAR *module_name) { ATH_DEBUG_MODULE_DBG_INFO *pInfo = g_pModuleInfoHead; if (!g_ModuleDebugInit) { return; } if (A_MEMCMP(module_name,"all",3) == 0) { /* dump all */ while (pInfo != NULL) { a_dump_module_debug_info(pInfo); pInfo = pInfo->pNext; } return; } pInfo = FindModule(module_name); if (pInfo != NULL) { a_dump_module_debug_info(pInfo); } }
void CAR6KMini::ReceiveWMIDataPacket( HTC_EVENT_INFO *evInfo) // // This function processes data from an HTC_BUFFER_RECEIVED indication // not on the WMI_CONTROL_MBOX endpoint. // { ndis_mini_buf_t *pb = (ndis_mini_buf_t *)evInfo->cookie; NDIS_STATUS Status; NDIS_PACKET *pPacket; NDIS_BUFFER *pBuffer; PBYTE pData; ULONG cbData; BOOL doDix = FALSE; USHORT etherType; SNAP_HEADER *pSnapHdr; MAC_ADDRESS *pDestAddr,*tempAddr; BOOL mcForUs = FALSE; NDIS_DEBUG_PRINTF(ATH_LOG_TRC | ATH_LOG_RECV, "AR6K: +ReceiveWMIDataPacket"); if (evInfo->status != A_OK) { NDIS_DEBUG_PRINTF(ATH_LOG_ERR, "AR6K: ERROR - ReceiveWMIPacket Error in receiving : status = %x\n", evInfo->status); if (A_OK != HTCBufferReceive(m_pHTCTarget, ENDPOINT2, a_netbuf_to_data(pb), AR6000_BUFFER_SIZE, pb)) { a_netbuf_free(pb); } goto done; } // evInfo->actualLength is the length of the pb->data including // 2 bytes: WMI_DATA_HEADER [optional - only if HTC header is 46 00] // 14 bytes: 802.3 MAC header // 8 bytes: SNAP header (with EthType as last 2 bytes) // N bytes: payload (e.g. IP packet) pData = evInfo->buffer; cbData = evInfo->actualLength; // Remove the WMI_DATA_HDR. if (cbData < sizeof(WMI_DATA_HDR)) { NDIS_DEBUG_PRINTF(ATH_LOG_ERR, "AR6K: ERROR - ReceiveWMIPacket missing WMI header (%u bytes)\n", evInfo->actualLength); if ( A_OK != HTCBufferReceive(m_pHTCTarget, ENDPOINT2, a_netbuf_to_data(pb), AR6000_BUFFER_SIZE, pb)) { a_netbuf_free(pb); } goto done; } pData += sizeof(WMI_DATA_HDR); cbData -= sizeof(WMI_DATA_HDR); if (cbData < sizeof(ETHERNET_MAC_HEADER) + sizeof(SNAP_HEADER)) { NDIS_DEBUG_PRINTF(ATH_LOG_ERR, "AR6K: ERROR - ReceiveWMIPacket missing MAC + SNAP (%u bytes)\n", cbData); if ( A_OK != HTCBufferReceive(m_pHTCTarget, ENDPOINT2, a_netbuf_to_data(pb), AR6000_BUFFER_SIZE, pb)) { a_netbuf_free(pb); } goto done; } #ifdef WMM Lock(); wmi_implicit_create_pstream((wmi_t *)m_pWMI, pb, DNLINK_TRAFFIC,1); Unlock(); #endif //WMM pDestAddr=(MAC_ADDRESS *)pData; /* Apply NDIS receive filter */ if (isGrp(pDestAddr)) { if (isBcast(pDestAddr)) { if (!(m_CurrentPacketFilter & NDIS_PACKET_TYPE_BROADCAST)) { if ( A_OK != HTCBufferReceive(m_pHTCTarget, ENDPOINT2, a_netbuf_to_data(pb), AR6000_BUFFER_SIZE, pb)) { a_netbuf_free(pb); } goto done; } } else { isMcForUs(pDestAddr,&mcForUs); if (!(m_CurrentPacketFilter & (NDIS_PACKET_TYPE_MULTICAST | NDIS_PACKET_TYPE_ALL_MULTICAST)) || !(mcForUs)) { if ( A_OK != HTCBufferReceive(m_pHTCTarget, ENDPOINT2, a_netbuf_to_data(pb), AR6000_BUFFER_SIZE, pb)) { a_netbuf_free(pb); } goto done; } } } else { tempAddr=(MAC_ADDRESS *) m_PermanentAddress; if ((A_MACADDR_COMP(pDestAddr,tempAddr) != 0) && !(m_CurrentPacketFilter & NDIS_PACKET_TYPE_PROMISCUOUS)) { if ( A_OK != HTCBufferReceive(m_pHTCTarget, ENDPOINT2, a_netbuf_to_data(pb), AR6000_BUFFER_SIZE, pb)) { a_netbuf_free(pb); } goto done; } } // Allocate an NDIS_PACKET from our packet pool. NdisAllocatePacket(&Status, &pPacket, m_RxPacketPool); if (NDIS_STATUS_SUCCESS != Status) { NDIS_DEBUG_PRINTF(ATH_LOG_ERR, "AR6K: ERROR - NdisAllocatePacket failed\n"); if ( A_OK != HTCBufferReceive(m_pHTCTarget, ENDPOINT2, a_netbuf_to_data(pb), AR6000_BUFFER_SIZE, pb)) { a_netbuf_free(pb); } goto done; } // Check for ethernetType in SNAP header for NOVELL_IPX, APPLE_TALK_ARP etc // remove 802.3 length and SNAP header if it is not of these types pSnapHdr=(SNAP_HEADER *)(pData+sizeof(ETHERNET_MAC_HEADER)); etherType=A_BE2CPU16(pSnapHdr->Type); doDix=((A_MEMCMP(pSnapHdr,&bridgeTunnel, sizeof(CAP_CONST))) == 0); if((!doDix) && ((A_MEMCMP(pSnapHdr,&vrfc1042, sizeof(CAP_CONST))) == 0)) { doDix = ((etherType != APPLE_TALK_ARP) && (etherType != NOVELL_IPX)); } // Get rid of the 802.3 length and SNAP header by copying // the 802.3 DestMACAddr and SrcMACAddr forward so they // immediately precede the EthType at the end of the SNAP header. // That gives us a DIX packet. if (doDix) { memmove(pData + sizeof(SNAP_HEADER), pData, ETHERNET_MAC_ADDRESS_LENGTH * 2); pData += sizeof(SNAP_HEADER); cbData -= sizeof(SNAP_HEADER); } // Setup the fields of NDIS_BUFFER to point to our data. pBuffer = &pb->NdisBuffer; NdisInitializeBuffer(pBuffer, pData, cbData); // Chain the NDIS_BUFFER to the start of the NDIS_PACKET NdisChainBufferAtBack(pPacket, pBuffer); NDIS_SET_PACKET_HEADER_SIZE(pPacket, sizeof(ETHERNET_MAC_HEADER)); NDIS_SET_PACKET_STATUS(pPacket, NDIS_STATUS_SUCCESS); #ifdef NDIS_BUS_DRIVER NDIS_PACKET *PacketArray[1]; PacketArray[0]=pPacket; NdisMIndicateReceivePacket(m_MiniportAdapterHandle, PacketArray, 1); #else // Perform the indicate on the timer thread because tying up the // SDIO receive indication thread can result in a deadlock. PLIST_ENTRY pEntry = (PLIST_ENTRY)(pPacket->MiniportReserved); Lock(); InsertTailList(&m_RxPendingPacketList, pEntry); NdisSetEvent(&m_RxPendingEvent); Unlock(); #endif done: NDIS_DEBUG_PRINTF(ATH_LOG_TRC | ATH_LOG_RECV, "AR6K: -ReceiveWMIDataPacket"); }
static void wlan_node_timeout(A_ATH_TIMER arg) { struct ieee80211_node_table *nt = (struct ieee80211_node_table *)arg; bss_t *bss, *nextBss; A_UINT8 myBssid[IEEE80211_ADDR_LEN], reArmTimer = FALSE; A_UINT32 timeoutValue = 0; timeoutValue = nt->nt_nodeAge; wmi_get_current_bssid(nt->nt_wmip, myBssid); bss = nt->nt_node_first; while (bss != NULL) { nextBss = bss->ni_list_next; if (A_MEMCMP(myBssid, bss->ni_macaddr, sizeof(myBssid)) != 0) { if (bss->ni_tstamp <= A_GET_MS(0)) { PBYTE pIE; char a[128]; A_UINT32 length, ch, freq; //wchar_t b[128] = {0}; pIE = bss->ni_cie.ie_ssid; length = pIE[1]; memcpy( a, &pIE[2], length ); a[length] = '\0'; //MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, a, 32, b, 64 ); freq = bss->ni_cie.ie_chan; if (freq == 2484) ch = 14; else if (freq < 2484) ch = (freq - 2407) / 5; else if (freq < 5000) ch = 15 + ((freq - 2512) / 20); else ch = (freq - 5000) / 5; RETAIL_DEBUG_PRINTF(debugBssInfo, (TEXT("builder:ar6k2: remove bss info, SSID = %S, RSSI = %d, CHANNEL = %d\r\n"), a, bss->ni_rssi, ch)); RETAIL_DEBUG_PRINTF(debugBssInfo, (TEXT("builder:ar6k2: BSSID = %02x:%02x:%02x:%02x:%02x:%02x \r\n") , bss->ni_macaddr[0], bss->ni_macaddr[1], bss->ni_macaddr[2], bss->ni_macaddr[3], bss->ni_macaddr[4], bss->ni_macaddr[5])); logPrintf( (debugFileLog && debugBssInfo), "builder:ar6k2: remove bss info, SSID = %s, RSSI = %d, CHANNEL = %d\r\n", a, bss->ni_rssi, ch); logPrintf( (debugFileLog && debugBssInfo), "builder:ar6k2: BSSID = %02x:%02x:%02x:%02x:%02x:%02x \r\n", bss->ni_macaddr[0], bss->ni_macaddr[1], bss->ni_macaddr[2], bss->ni_macaddr[3], bss->ni_macaddr[4], bss->ni_macaddr[5]); /* * free up all but the current bss - if set */ wlan_node_reclaim(nt, bss); } else { /* * Re-arm timer, only when we have a bss other than * current bss AND it is not aged-out. */ reArmTimer = TRUE; } } bss = nextBss; } if(reArmTimer) A_TIMEOUT_MS(&nt->nt_inact_timer, timeoutValue, 0); nt->isTimerArmed = reArmTimer; }