📄 dot11ksllib.c
字号:
{ DOT11_KSL_ENTRY * pKsl; /* Lock out the table so that nobody can modify/use it */ if (dot11KslLock(pDot11) != OK) { DOT11_LOG(DOT11_DEBUG_ERROR, DOT11_AREA_SME, ("dot11KslTxUpdate: Cannot get lock.\n", 0, 0, 0, 0, 0, 0)); return NULL; } /* Check if there is a real KSL entry for this station */ if ((pKsl = dot11KslLookup(pDot11, macAddr)) == NULL) { /* This must have been a multicast packet */ dot11KslUnlock(pDot11); return NULL; } pKsl->rcInfo.packetTotal ++; if (success) { /* Only successful packets have an ACK SSI */ pKsl->rcInfo.ackTotal += ackSSI; /* Just because it was successfull doesn't mean that it was perfect */ pKsl->rcInfo.retryTotal += nRetries; } else { pKsl->rcInfo.failureTotal ++; pKsl->rcInfo.retryTotal += DOT11_RC_RETRY_FAIL_WEIGHT; } if (dot11KslUnlock(pDot11) != OK) { DOT11_LOG(DOT11_DEBUG_FATAL, DOT11_AREA_INIT, ("dot11KslRxUpdate: Cannot free lock\n", 0,0,0,0,0,0)); /* No point in returning NULL, since we may already have a valid KSL entry */ } return pKsl; }#ifdef DOT11_DEBUG_GLOBAL/***************************************************************************** dot11KslShow - Show routine for the KSL ** This routine prints a list of all entries in the KSL to the console. * Information about each entry that is specific to the type of entry is also* printed.** RETURNS: OK or ERROR** \IFSET KERNEL** ERRNO: N/A*/STATUS dot11KslShow ( int unitNum ) { int i; DOT11_KSL_ENTRY * pKsl; DOT11_FW * pDot11; pDot11 = (DOT11_FW *)endFindByName("wls",unitNum); if ((pDot11 == NULL) || (pDot11->sme == NULL)) { printf("Device wls%d is not initialized\n", unitNum); return ERROR; } printf("Total KSL entries allocated = %d, highest num = %d, max = %d\n", pDot11->sme->ksl.poolUsed, pDot11->sme->ksl.poolMaxUsed, DOT11_KSL_POOL_SIZE); for (i=0; i<DOT11_KSL_MAX_HASH; i++) { if (pDot11->sme->ksl.list[i] == NULL) { continue; } pKsl = pDot11->sme->ksl.list[i]; do { dot11KslPrint(pDot11, pKsl); } while ((pKsl = pKsl->pNext) != NULL); } return OK; }/***************************************************************************** dot11KslPrint - Prints information about one KSL entry** This routine is used by dot11KslShow() to print KSL entries.** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS dot11KslPrint ( DOT11_FW * pDot11, DOT11_KSL_ENTRY * pKsl /* Pointer to entry to print */ ) { int i; printf("%d %02x:%02x:%02x:%02x:%02x:%02x", DOT11_KSL_HASH(pKsl->macAddr), pKsl->macAddr[0], pKsl->macAddr[1], pKsl->macAddr[2], pKsl->macAddr[3], pKsl->macAddr[4], pKsl->macAddr[5] ); switch (pKsl->dot11Mode) { case DOT11_MODE_ESS: printf(" #ESS# AUTH=%s ASSOC=%s AID=%d PM=%s", pKsl->type.sta.authenticated?"TRUE":"FALSE", pKsl->type.sta.associated?"TRUE":"FALSE", pKsl->type.sta.aid, pKsl->type.sta.powerManaged?"TRUE":"FALSE" ); if (pKsl->type.sta.powerManaged) { printf("(Q=%d)", dot11KslPmQCount(pDot11, pKsl)); } break; case DOT11_MODE_AP: printf(" #AP# SSID=\"%s\" chan=%d mode=0x%x", pKsl->ssid, pKsl->type.ap.channel, pKsl->type.ap.mode); if (pKsl->type.ap.countryCode != 0) { printf(" country=%d", pKsl->type.ap.countryCode); } break; case DOT11_MODE_IBSS: printf(" #IBSS# SSID=\"%s\" BSSID=" DOT11_MAC_ADDR_STR " BI=%d " "chan=%d mode=0x%x", pKsl->ssid, DOT11_MAC_ADDR(pKsl->type.ibss.bssid), pKsl->type.ibss.beaconInterval, pKsl->type.ibss.channel, pKsl->type.ibss.mode); break; default: printf(" ?TYPE? "); } printf(" caps=%x", DOT11_CPU_TO_LE_16(pKsl->capabilities)); printf(" ssi=%d ", pKsl->type.ap.ssi); printf(" age=%lds", (tickGet() - pKsl->timestamp) / sysClkRateGet()); if (pKsl->dot1xControlled || pKsl->accessControlled || pKsl->wepKeyMapping) { printf("\n "); } if (pKsl->dot1xControlled) { if (pKsl->dot1xAllowed) { printf("dot1xAllowed "); } else { printf("dot1xBlocked "); } } if (pKsl->accessControlled) { printf("AccessControlled "); } if (pKsl->wepKeyMapping) { printf("WepKeyMapping "); } printf("\n"); printf(" RC: Rate=%dMbps packet=%d(idx%d) retry=%d fail=%d\n", pKsl->currentTxRate/2, pKsl->currentTxRateIndex, pKsl->rcInfo.packetTotal, pKsl->rcInfo.retryTotal, pKsl->rcInfo.failureTotal); if (pKsl->suppRates.length > 0) { printf(" suppRates="); for (i=0; i<pKsl->suppRates.length; i++) { printf("%s%d%s ",DOT11_IS_BRATE(pKsl->suppRates.rates[i])?"[":"", DOT11_RATE(pKsl->suppRates.rates[i]), DOT11_IS_BRATE(pKsl->suppRates.rates[i])?"]":""); } printf("\n"); } if (pKsl->actualRates.length > 0) { printf(" actualRates="); for (i=0; i<pKsl->actualRates.length; i++) { printf("%s%d%s ",DOT11_IS_BRATE(pKsl->actualRates.rates[i])?"[":"", DOT11_RATE(pKsl->actualRates.rates[i]), DOT11_IS_BRATE(pKsl->actualRates.rates[i])?"]":""); } printf("\n"); } printf(" Current unicast encrypt = %s, key=%d %d\n", dot11EncryptNames[pKsl->uniEncryptType], pKsl->uniDecryptIndex, pKsl->uniEncryptIndex); /* Print the collected security information for this station if security policies are enabled */ if (pKsl->pBss->secPol != 0) { printf(" 4way state = %s\n", dot114wayStateNames[pKsl->fourWayState]); printf(" negSecPol=%s negAuthPol=%s uniEncrypt=%s secPol=%s " "authPol=%s ciphPol=%s groupPol=%s\n", dot11SecPolNames[pKsl->negSecPol], dot11AuthPolNames[pKsl->negAuthPol], dot11EncryptNames[pKsl->uniEncryptType], dot11SecPolNames[pKsl->secPol], dot11AuthPolNames[pKsl->authPol], dot11EncryptNames[pKsl->ciphPol], dot11EncryptNames[pKsl->groupPol]); } return OK; }#endif /* DOT11_DEBUG_GLOBAL *//***************************************************************************** dot11KslCleanup - cleanup task that removes old KSL entries** This routine runs periodically and cleans up stale KSL entries. Any entries* older than DOT11_KSL_MAX_AGE are removed.** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS dot11KslCleanup ( DOT11_FW * pDot11 /* Pointer to device structure */ ) { int i; UINT32 curTime; /* Copy of the current time */ DOT11_KSL_ENTRY * pKsl; /* Temp. KSL pointer for walking list */ DOT11_KSL_ENTRY * pLastKsl; /* Used to de-link entries from KSL */ DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_SME, ("dot11KslCleanup: Running.\n",0,0,0,0,0,0)); /* Store the current time so that we're not doing repeated function calls to get it. Add one to allow for delays / premptions/ etc */ curTime = tickGet() + 1; /* Loop through all of the entires is the KSL, checking for entries that are older that DOT11_KSL_MAX_AGE. Prune any that are found, first sending disassociation and deauthentication messages */ if (dot11KslLock(pDot11) != OK) { DOT11_LOG(DOT11_DEBUG_ERROR, DOT11_AREA_SME, ("dot11KslCleanup: Unable to get KSL lock.\n", 0,0,0,0,0,0)); /* Restart the timer */ return dot11TimerAdd(DOT11_KSL_CLEANUP_TIME, (FUNCPTR)dot11KslCleanup, (int)pDot11, 0); } for (i=0; i< DOT11_KSL_MAX_HASH; i++) { pKsl = pDot11->sme->ksl.list[i]; pLastKsl = NULL; while (pKsl != NULL) { if (((curTime) - pKsl->timestamp) > (UINT32)DOT11_KSL_MAX_AGE) { /* Check if the entry is a static entry. If so, don't prune it */ if ((!pKsl->accessControlled) && (!pKsl->wepKeyMapping)) { DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_SME, ("dot11KslCleanup: Pruning " DOT11_MAC_ADDR_STR ".\n", DOT11_MAC_ADDR(pKsl->macAddr))); /* pLastKsl does not move. Since we removed the current item, it's still the previous item in the queue */ pLastKsl = pKsl; pKsl = pKsl->pNext; dot11KslEntryFree(pDot11, pLastKsl); } else { /* If this is a static entry, then keep going */ pKsl = pKsl->pNext; } } else { pKsl = pKsl->pNext; } } } if(dot11KslUnlock(pDot11) != OK) { DOT11_LOG(DOT11_DEBUG_ERROR, DOT11_AREA_SME, ("dot11KslCleanup: Unable to free KSL lock.\n", 0,0,0,0,0,0)); return ERROR; } /* Restart the timer */ return dot11TimerAdd(DOT11_KSL_CLEANUP_TIME, (FUNCPTR)dot11KslCleanup, (int)pDot11, 0); }/***************************************************************************** dot11LastAttemptReset - Resets all ap's "last attempt" ** This function is called by the ESS whenever the user initiates an action. It* resets the "lastAttemp" field of all KSL entries, so that the best AP will * not be rejected if the user decided to reassociate to it.** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS dot11KslLastAttemptReset ( DOT11_FW * pDot11 /* Poitner to DOT11 root object */ ) { int i; DOT11_KSL_ENTRY * pKsl; for (i=0; i<DOT11_KSL_MAX_HASH; i++) { if (pDot11->sme->ksl.list[i] == NULL) { continue; } pKsl = pDot11->sme->ksl.list[i]; do { pKsl->lastAttempt = 0; } while ((pKsl = pKsl->pNext) != NULL); } return OK; }/***************************************************************************** dot11KslPmQCount - Returns the numbers of stations on the KSL's PM queue** This function is called by dot11KslShow() to determine the nubmer of stations* on the KSL entry's PM queue.** RETURNS: Number of stations on PM queue** ERRNO: N/A*/LOCAL INT32 dot11KslPmQCount ( DOT11_FW * pDot11, /* Pointer to root object */ DOT11_KSL_ENTRY * pKsl /* KSL entry to analyse */ ) { M_BLK_ID pMblk; int i = 0; if ((pDot11 == NULL) || (pKsl == NULL)) { return 0; } if (pKsl->type.sta.pmQueueHead == NULL) { return 0; } if (pDot11->sme->ksl.lock(pDot11) != OK) { return -1; } pMblk = pKsl->type.sta.pmQueueHead; i = 1; while (pMblk != pKsl->type.sta.pmQueueTail) { i++; pMblk = pMblk->mBlkHdr.mNextPkt; } /* Release the KSL lock now that we are done traversing LL */ pDot11->sme->ksl.unlock(pDot11); return i; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -