/** * \fn sme_SelectWscMatch * \brief checks if the configred WSC mode equals the WSC mode of a site * * checks if the configred WSC mode equals the WSC mode of a site * * \param hSme - handle to the SME object * \param pCurrentSite - site to check * \return TI_TRUE if site macthes current WSC mode, TI_FALSE if it doesn't match * \sa sme_Select */ TI_BOOL sme_SelectWscMatch (TI_HANDLE hSme, TSiteEntry *pCurrentSite, TI_BOOL *pbWscPbAbort, TI_BOOL *pbWscPbApFound) { TSme *pSme = (TSme*)hSme; TIWLN_SIMPLE_CONFIG_MODE wscMode; /* get the WSC mode from site mgr */ siteMgr_getParamWSC(pSme->hSiteMgr, &wscMode); /* SITE_MGR_SIMPLE_CONFIG_MODE - get the WSC mode from site mgr */ /* if simple config is off, site match */ if (TIWLN_SIMPLE_CONFIG_OFF == wscMode) { return TI_TRUE; } /* if WSC is supported, and more than one AP with PB configuration is found - indicate to abort */ if ((TI_TRUE == *pbWscPbApFound) && (TIWLN_SIMPLE_CONFIG_PBC_METHOD == pCurrentSite->WSCSiteMode)) { TRACE1(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_SelectWscMatch: WSC mode is %d, and more than one AP with WSC PB found - aborting\n", wscMode); *pbWscPbAbort = TI_TRUE; return TI_FALSE; } else { /* indicate NOT to abort the select process */ *pbWscPbAbort = TI_FALSE; } /* if configured simple config mode equals site simple config mode, site match */ if (pCurrentSite->WSCSiteMode == wscMode) { return TI_TRUE; } /* site doesn't match */ return TI_FALSE; }
/** * \fn sme_Select * \brief Select a connection candidate from the scan result table * * Select a connection candidate from the scan result table. * * Connection candidate must match SSID, BSSID, BSS type, RSN and WSC settings, has the best * RSSI level from all matching sites, and connection was not attempted to it in this SME cycle * (since last scan was completed) * * \param hSme - handle to the SME object * \return A pointer to the selected site, NULL if no site macthes the selection criteria */ TSiteEntry *sme_Select (TI_HANDLE hSme) { TSme *pSme = (TSme*)hSme; TSiteEntry *pCurrentSite, *pSelectedSite = NULL; TI_INT8 iSelectedSiteRssi = -127; /* minimum RSSI */ TI_BOOL bWscPbAbort, pWscPbApFound = TI_FALSE; int apFoundCtr =0; TIWLN_SIMPLE_CONFIG_MODE eWscMode; TRACE0(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_Select called\n"); /* on SG avalanche, select is not needed, send connect event automatically */ if (TI_TRUE == pSme->bReselect) { paramInfo_t *pParam; TRACE0(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_Select: reselect flag is on, reselecting the current site\n"); pParam = (paramInfo_t *)os_memoryAlloc(pSme->hOS, sizeof(paramInfo_t)); if (!pParam) { return NULL; } pSme->bReselect = TI_FALSE; /* Get Primary Site */ pParam->paramType = SITE_MGR_GET_PRIMARY_SITE; siteMgr_getParam(pSme->hSiteMgr, pParam); pCurrentSite = pParam->content.pPrimarySite; os_memoryFree(pSme->hOS, pParam, sizeof(paramInfo_t)); return pCurrentSite; } /* get the first site from the scan result table */ pCurrentSite = scanResultTable_GetFirst (pSme->hScanResultTable); /* check all sites */ while (NULL != pCurrentSite) { TRACE6(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_Select: considering BSSID: %02x:%02x:%02x:%02x:%02x:%02x for selection\n", pCurrentSite->bssid[ 0 ], pCurrentSite->bssid[ 1 ], pCurrentSite->bssid[ 2 ], pCurrentSite->bssid[ 3 ], pCurrentSite->bssid[ 4 ], pCurrentSite->bssid[ 5 ]); /* if this site was previously selected in the current SME connection attempt, and conn mode is auto */ if (TI_TRUE == pCurrentSite->bConsideredForSelect) { TRACE6(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_Select: BSSID: %02x:%02x:%02x:%02x:%02x:%02x was selected previously\n", pCurrentSite->bssid[ 0 ], pCurrentSite->bssid[ 1 ], pCurrentSite->bssid[ 2 ], pCurrentSite->bssid[ 3 ], pCurrentSite->bssid[ 4 ], pCurrentSite->bssid[ 5 ]); /* get the next site and continue the loop */ pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable); continue; } /* check if site matches */ /* first check SSID match */ if (TI_FALSE == sme_SelectSsidMatch (hSme, &(pCurrentSite->ssid), &(pSme->tSsid), pSme->eSsidType)) /* site doesn't match */ { TRACE6(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_Select: BSSID: %02x:%02x:%02x:%02x:%02x:%02x doesn't match SSID\n", pCurrentSite->bssid[ 0 ], pCurrentSite->bssid[ 1 ], pCurrentSite->bssid[ 2 ], pCurrentSite->bssid[ 3 ], pCurrentSite->bssid[ 4 ], pCurrentSite->bssid[ 5 ]); pCurrentSite->bConsideredForSelect = TI_TRUE; /* don't try this site again */ /* get the next site and continue the loop */ pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable); continue; } /* Now check BSSID match */ if (TI_FALSE == sme_SelectBssidMatch (&(pCurrentSite->bssid), &(pSme->tBssid))) /* site doesn't match */ { TRACE6(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_Select: BSSID: %02x:%02x:%02x:%02x:%02x:%02x doesn't match SSID\n", pCurrentSite->bssid[ 0 ], pCurrentSite->bssid[ 1 ], pCurrentSite->bssid[ 2 ], pCurrentSite->bssid[ 3 ], pCurrentSite->bssid[ 4 ], pCurrentSite->bssid[ 5 ]); pCurrentSite->bConsideredForSelect = TI_TRUE; /* don't try this site again */ /* get the next site and continue the loop */ pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable); continue; } /* and BSS type match */ if (TI_FALSE == sme_SelectBssTypeMatch (pCurrentSite->bssType, pSme->eBssType)) /* site doesn't match */ { TRACE6(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_Select: BSSID: %02x:%02x:%02x:%02x:%02x:%02x doesn't match BSS type\n", pCurrentSite->bssid[ 0 ], pCurrentSite->bssid[ 1 ], pCurrentSite->bssid[ 2 ], pCurrentSite->bssid[ 3 ], pCurrentSite->bssid[ 4 ], pCurrentSite->bssid[ 5 ]); pCurrentSite->bConsideredForSelect = TI_TRUE; /* don't try this site again */ /* get the next site and continue the loop */ pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable); continue; } if (pCurrentSite->WSCSiteMode == TIWLN_SIMPLE_CONFIG_PBC_METHOD) { apFoundCtr++; } if (apFoundCtr > 1) { pWscPbApFound = TI_TRUE; } /* and simple config match */ if (TI_FALSE == sme_SelectWscMatch (hSme, pCurrentSite, &bWscPbAbort, &pWscPbApFound)) /* site doesn't match */ { /* also check if abort was indicated */ if (TI_TRUE == bWscPbAbort) { /* send event to user mode to indicate this */ EvHandlerSendEvent (pSme->hEvHandler, IPC_EVENT_WPS_SESSION_OVERLAP, NULL, 0); /* select failed - will rescan in time */ return NULL; } TRACE6(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_Select: BSSID: %02x:%02x:%02x:%02x:%02x:%02x doesn't match WSC\n", pCurrentSite->bssid[ 0 ], pCurrentSite->bssid[ 1 ], pCurrentSite->bssid[ 2 ], pCurrentSite->bssid[ 3 ], pCurrentSite->bssid[ 4 ], pCurrentSite->bssid[ 5 ]); pCurrentSite->bConsideredForSelect = TI_TRUE; /* don't try this site again */ /* get the next site and continue the loop */ pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable); continue; } /* and security match */ siteMgr_getParamWSC(pSme->hSiteMgr, &eWscMode); /* we don't need to check RSN match while WSC is active */ if ((pCurrentSite->WSCSiteMode == TIWLN_SIMPLE_CONFIG_OFF) || (pCurrentSite->WSCSiteMode != eWscMode)) { if (TI_FALSE == sme_SelectRsnMatch (hSme, pCurrentSite)) /* site doesn't match */ { TRACE6(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_Select: BSSID: %02x:%02x:%02x:%02x:%02x:%02x doesn't match RSN\n", pCurrentSite->bssid[ 0 ], pCurrentSite->bssid[ 1 ], pCurrentSite->bssid[ 2 ], pCurrentSite->bssid[ 3 ], pCurrentSite->bssid[ 4 ], pCurrentSite->bssid[ 5 ]); pCurrentSite->bConsideredForSelect = TI_TRUE; /* don't try this site again */ /* get the next site and continue the loop */ pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable); continue; } } /* and rate match */ if (TI_FALSE == siteMgr_SelectRateMatch (pSme->hSiteMgr, pCurrentSite)) /* site doesn't match */ { TRACE6(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_Select: BSSID: %02x:%02x:%02x:%02x:%02x:%02x doesn't match rates\n", pCurrentSite->bssid[ 0 ], pCurrentSite->bssid[ 1 ], pCurrentSite->bssid[ 2 ], pCurrentSite->bssid[ 3 ], pCurrentSite->bssid[ 4 ], pCurrentSite->bssid[ 5 ]); pCurrentSite->bConsideredForSelect = TI_TRUE; /* don't try this site again */ /* get the next site and continue the loop */ pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable); continue; } if (TI_TRUE == pCurrentSite->bChannelSwitchAnnoncIEFound) { TRACE6(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_Select: BSSID: %02x:%02x:%02x:%02x:%02x:%02x has channel switch IE so ignore it \n", pCurrentSite->bssid[ 0 ], pCurrentSite->bssid[ 1 ], pCurrentSite->bssid[ 2 ], pCurrentSite->bssid[ 3 ], pCurrentSite->bssid[ 4 ], pCurrentSite->bssid[ 5 ]); pCurrentSite->bConsideredForSelect = TI_TRUE; /* don't try this site again */ /* get the next site and continue the loop */ pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable); continue; } /* if this site RSSI is higher than current maximum, select it */ if (pCurrentSite->rssi > iSelectedSiteRssi) { TRACE6(pSme->hReport, REPORT_SEVERITY_INFORMATION , "sme_Select: BSSID: %02x:%02x:%02x:%02x:%02x:%02x match and has highest RSSI so far!\n", pCurrentSite->bssid[ 0 ], pCurrentSite->bssid[ 1 ], pCurrentSite->bssid[ 2 ], pCurrentSite->bssid[ 3 ], pCurrentSite->bssid[ 4 ], pCurrentSite->bssid[ 5 ]); pSelectedSite = pCurrentSite; iSelectedSiteRssi = pCurrentSite->rssi; } /* and continue to the next site */ pCurrentSite = scanResultTable_GetNext (pSme->hScanResultTable); } /* if a matching site was found */ if (NULL != pSelectedSite) { /* mark that a connection to this site was (actually is) attempted */ pSelectedSite->bConsideredForSelect = TI_TRUE; /* hope this is the correct place for siteMgr_changeBandParams */ siteMgr_changeBandParams (pSme->hSiteMgr, pSelectedSite->eBand); /* * Coordinate between SME module site table and Site module site Table * copy candidate AP to Site module site Table. */ siteMgr_CopyToPrimarySite(pSme->hSiteMgr, pSelectedSite); /* copy the result, rather than returning a pointer to the entry in the scan result table. * This is done since the table might change durring the connection process, and the pointer * will point to the wrong entry in the table, causing connection/disconnection problems */ os_memoryCopy(pSme->hOS, &(pSme->tCandidate), pSelectedSite, sizeof(TSiteEntry)); return &(pSme->tCandidate); } /* return NULL if no site was selected */ return NULL; }
TI_STATUS admCtrlWpa_getInfoElement(admCtrl_t *pAdmCtrl, TI_UINT8 *pIe, TI_UINT32 *pLength) { wpaIePacket_t localWpaPkt; wpaIePacket_t *pWpaIePacket; TI_UINT8 length; TI_UINT16 tempInt; TI_STATUS status; TIWLN_SIMPLE_CONFIG_MODE wscMode; /* Get Simple-Config state */ status = siteMgr_getParamWSC(pAdmCtrl->pRsn->hSiteMgr, &wscMode); /* SITE_MGR_SIMPLE_CONFIG_MODE */ if (pIe==NULL) { *pLength = 0; return TI_NOK; } if ((wscMode != TIWLN_SIMPLE_CONFIG_OFF) && (pAdmCtrl->broadcastSuite == TWD_CIPHER_NONE) && (pAdmCtrl->unicastSuite == TWD_CIPHER_NONE)) { *pLength = 0; return TI_NOK; } /* Check validity of WPA IE */ if (!broadcastCipherSuiteValidity[pAdmCtrl->networkMode][pAdmCtrl->broadcastSuite]) { /* check Group suite validity */ *pLength = 0; return TI_NOK; } if (pAdmCtrl->unicastSuite == TWD_CIPHER_WEP) { /* check pairwise suite validity */ *pLength = 0; return TI_NOK; } /* Build Wpa IE */ pWpaIePacket = &localWpaPkt; os_memoryZero(pAdmCtrl->hOs, pWpaIePacket, sizeof(wpaIePacket_t)); pWpaIePacket->elementid= WPA_IE_ID; os_memoryCopy(pAdmCtrl->hOs, (void *)pWpaIePacket->oui, wpaIeOuiIe, 3); pWpaIePacket->ouiType = WPA_OUI_DEF_TYPE; tempInt = WPA_OUI_MAX_VERSION; COPY_WLAN_WORD(&pWpaIePacket->version, &tempInt); length = sizeof(wpaIePacket_t)-2; /* check defaults */ if (pAdmCtrl->replayCnt==1) { length -= 2; /* 2: capabilities + 4: keyMng suite, 2: keyMng count*/ #if 0 /* The following was removed since there are APs which do no accept the default WPA IE */ if (pAdmCtrl->externalAuthMode == RSN_EXT_AUTH_MODE_WPA) { length -= 6; /* 2: capabilities + 4: keyMng suite, 2: keyMng count*/ if (pAdmCtrl->unicastSuite == TWD_CIPHER_TKIP) { length -= 6; /* 4: unicast suite, 2: unicast count */ if (pAdmCtrl->broadcastSuite == TWD_CIPHER_TKIP) { length -= 4; /* broadcast suite */ } } } #endif }