int get_wpa2_cipher_suite(u8 *s) { if (_memcmp(s, RSN_CIPHER_SUITE_NONE, RSN_SELECTOR_LEN) == _TRUE) return WPA_CIPHER_NONE; if (_memcmp(s, RSN_CIPHER_SUITE_WEP40, RSN_SELECTOR_LEN) == _TRUE) return WPA_CIPHER_WEP40; if (_memcmp(s, RSN_CIPHER_SUITE_TKIP, RSN_SELECTOR_LEN) == _TRUE) return WPA_CIPHER_TKIP; if (_memcmp(s, RSN_CIPHER_SUITE_CCMP, RSN_SELECTOR_LEN) == _TRUE) return WPA_CIPHER_CCMP; if (_memcmp(s, RSN_CIPHER_SUITE_WEP104, RSN_SELECTOR_LEN) == _TRUE) return WPA_CIPHER_WEP104; return 0; }
int get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen) { int match; uint cnt; u8 eid, wps_oui[4]={0x0,0x50,0xf2,0x04}; cnt=12; match=_FALSE; while(cnt<in_len) { eid = in_ie[cnt]; if((eid==_WPA_IE_ID_)&&(_memcmp(&in_ie[cnt+2], wps_oui, 4)==_TRUE)) { _memcpy(wps_ie, &in_ie[cnt], in_ie[cnt+1]+2); *wps_ielen = in_ie[cnt+1]+2; cnt+=in_ie[cnt+1]+2; match = _TRUE; break; } else { cnt+=in_ie[cnt+1]+2; //goto next } } return match; }
int get_sec_ie(u8 *in_ie,uint in_len,u8 *rsn_ie,u16 *rsn_len,u8 *wpa_ie,u16 *wpa_len) { u8 authmode, sec_idx, i; u8 wpa_oui[4]={0x0,0x50,0xf2,0x01}; uint cnt; _func_enter_; //Search required WPA or WPA2 IE and copy to sec_ie[ ] cnt = (_TIMESTAMP_ + _BEACON_ITERVAL_ + _CAPABILITY_); sec_idx=0; while(cnt<in_len) { authmode=in_ie[cnt]; if((authmode==_WPA_IE_ID_)&&(_memcmp(&in_ie[cnt+2], &wpa_oui[0],4)==_TRUE)) { RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("\n get_wpa_ie: sec_idx=%d in_ie[cnt+1]+2=%d\n",sec_idx,in_ie[cnt+1]+2)); _memcpy(wpa_ie, &in_ie[cnt],in_ie[cnt+1]+2); for(i=0;i<(in_ie[cnt+1]+2);i=i+8){ RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("\n %2x,%2x,%2x,%2x,%2x,%2x,%2x,%2x\n",wpa_ie[i],wpa_ie[i+1],wpa_ie[i+2],wpa_ie[i+3],wpa_ie[i+4],wpa_ie[i+5],wpa_ie[i+6],wpa_ie[i+7])); } *wpa_len=in_ie[cnt+1]+2; cnt+=in_ie[cnt+1]+2; //get next } else { if(authmode==_WPA2_IE_ID_) { RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("\n get_rsn_ie: sec_idx=%d in_ie[cnt+1]+2=%d\n",sec_idx,in_ie[cnt+1]+2)); _memcpy(rsn_ie, &in_ie[cnt],in_ie[cnt+1]+2); for(i=0;i<(in_ie[cnt+1]+2);i=i+8){ RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("\n %2x,%2x,%2x,%2x,%2x,%2x,%2x,%2x\n",rsn_ie[i],rsn_ie[i+1],rsn_ie[i+2],rsn_ie[i+3],rsn_ie[i+4],rsn_ie[i+5],rsn_ie[i+6],rsn_ie[i+7])); } *rsn_len=in_ie[cnt+1]+2; cnt+=in_ie[cnt+1]+2; //get next } else { cnt+=in_ie[cnt+1]+2; //get next } } } _func_exit_; return (*rsn_len+*wpa_len); }
/* any station allocated can be searched by hash list */ struct sta_info *get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) { _irqL irqL; _list *plist, *phead; struct sta_info *psta = NULL; u32 index; u8 *addr; u8 bc_addr[ETH_ALEN] = {0xff,0xff,0xff,0xff,0xff,0xff}; _func_enter_; if(hwaddr==NULL) return NULL; if(IS_MCAST(hwaddr)) { addr = bc_addr; } else { addr = hwaddr; } index = wifi_mac_hash(addr); _enter_critical_bh(&pstapriv->sta_hash_lock, &irqL); phead = &(pstapriv->sta_hash[index]); plist = get_next(phead); while ((end_of_queue_search(phead, plist)) == _FALSE) { psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); if ((_memcmp(psta->hwaddr, addr, ETH_ALEN))== _TRUE) { // if found the matched address break; } psta=NULL; plist = get_next(plist); } _exit_critical_bh(&pstapriv->sta_hash_lock, &irqL); _func_exit_; return psta; }
sint amsdu_wlanhdr_to_ethhdr (union recv_frame *precvframe, _pkt *skb) { //remove the wlanhdr and add the eth_hdr u8 srcaddr[6]; u8 desaddr[6]; u8 RemoveLLCFlag=_FALSE; u8 *pLLC, *pFrame; u8 NeedCheckTypes=1; u8 LLCHeader[1][5]={ // Remember to check NeedCheckTypes {0x00,0x00,0x00,0x81,0x37}, }; int i; _func_enter_; pLLC = skb->data; // Get Source Address and Destination Address _memcpy(desaddr, pLLC - ETHERNET_HEADER_SIZE, ETH_ALEN); _memcpy(srcaddr, pLLC - ETHERNET_HEADER_SIZE + ETHERNET_ADDRESS_LENGTH, ETH_ALEN); pFrame = pLLC -ETHERNET_HEADER_SIZE; if( *(pLLC + 0) == 0xaa && *(pLLC + 1) == 0xaa && *(pLLC + 2) == 0x03 ) { // check if need remove LLC header RemoveLLCFlag=_TRUE; for(i=0;i<NeedCheckTypes;i++) { if(_memcmp((pLLC + 3), LLCHeader[i], 5)) { RemoveLLCFlag=_FALSE; break; } } if(RemoveLLCFlag) pFrame += 8; } _memcpy(pFrame , desaddr, ETH_ALEN); _memcpy(pFrame+6, srcaddr, ETH_ALEN); //2 Insert length field if LLC is not removed if(!RemoveLLCFlag) { u16 len=skb->len; *(pFrame + 12)=(u8)(len>>8); *(pFrame + 13)=(u8)(len&0xff); }
unsigned char *get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit) { int len; u16 val16; unsigned char wpa_oui_type[] = {0x00, 0x50, 0xf2, 0x01}; u8 *pbuf = pie; while(1) { pbuf = get_ie(pbuf, _WPA_IE_ID_, &len, limit); if (pbuf) { //check if oui matches... if (_memcmp((pbuf + 2), wpa_oui_type, sizeof (wpa_oui_type)) == _FALSE) { goto check_next_ie; } //check version... _memcpy((u8 *)&val16, (pbuf + 6), sizeof(val16)); val16 = le16_to_cpu(val16); if (val16 != 0x0001) goto check_next_ie; *wpa_ie_len = *(pbuf + 1); return pbuf; } else { *wpa_ie_len = 0; return NULL; } check_next_ie: limit = limit - (pbuf - pie) - 2 - len; if (limit <= 0) break; pbuf += (2 + len); } *wpa_ie_len = 0; return NULL; }
// attr_content: The output buffer, contains the "body field" of P2P attribute. // attr_contentlen: The data length of the "body field" of P2P attribute. int get_p2p_attr_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id ,u8 *attr_content, uint *attr_contentlen) { int match; uint cnt = 0; u8 attr_id, p2p_oui[4]={0x50,0x6F,0x9A,0x09}; match=_FALSE; if ( ( p2p_ie[ 0 ] != _VENDOR_SPECIFIC_IE_ ) || ( _memcmp( p2p_ie + 2, p2p_oui , 4 ) != _TRUE ) ) { return( match ); } // 1 ( P2P IE ) + 1 ( Length ) + 3 ( OUI ) + 1 ( OUI Type ) cnt = 6; while( cnt < p2p_ielen ) { u16 attrlen = le16_to_cpu(*(u16*)(p2p_ie + cnt + 1 )); attr_id = p2p_ie[cnt]; if( attr_id == target_attr_id ) { // 3 -> 1 byte for attribute ID field, 2 bytes for length field if(attr_content) _memcpy( attr_content, &p2p_ie[ cnt + 3 ], attrlen ); if(attr_contentlen) *attr_contentlen = attrlen; cnt += attrlen + 3; match = _TRUE; break; } else { cnt += attrlen + 3; //goto next } } return match; }
int get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id ,u8 *attr_content, uint *attr_contentlen) { int match; uint cnt = 0; u8 wps_oui[4]={0x00,0x50,0xF2,0x04}; u16 attr_id; match=_FALSE; if ( ( wps_ie[ 0 ] != _VENDOR_SPECIFIC_IE_ ) || ( _memcmp( wps_ie + 2, wps_oui , 4 ) != _TRUE ) ) { return( match ); } // 1 ( WPS IE ) + 1 ( Length ) + 4 ( WPS OUI ) cnt = 6; while( cnt < wps_ielen ) { // 2 -> the length of WPS attribute type field. u16 attrlen = be16_to_cpu(*(u16*)(wps_ie + cnt + 2 )); attr_id = be16_to_cpu( *(u16*) ( wps_ie + cnt ) ); if( attr_id == target_attr_id ) { // 3 -> 1 byte for attribute ID field, 2 bytes for length field _memcpy( attr_content, &wps_ie[ cnt + 4 ], attrlen ); *attr_contentlen = attrlen; cnt += attrlen + 4; match = _TRUE; break; } else { cnt += attrlen + 4; //goto next } } return match; }
int get_p2p_ie(u8 *in_ie, uint in_len, u8 *p2p_ie, uint *p2p_ielen) { int match; uint cnt = 0; u8 eid, p2p_oui[4]={0x50,0x6F,0x9A,0x09}; match=_FALSE; while(cnt<in_len) { eid = in_ie[cnt]; if( ( eid == _VENDOR_SPECIFIC_IE_ ) && ( _memcmp( &in_ie[cnt+2], p2p_oui, 4) == _TRUE ) ) { if ( p2p_ie != NULL ) { _memcpy( p2p_ie, &in_ie[ cnt ], in_ie[ cnt + 1 ] + 2 ); if ( p2p_ielen != NULL ) { *p2p_ielen = in_ie[ cnt + 1 ] + 2; } } else { if ( p2p_ielen != NULL ) { *p2p_ielen = 0; } } cnt += in_ie[ cnt + 1 ] + 2; match = _TRUE; break; } else { cnt += in_ie[ cnt + 1 ] +2; //goto next } } return match; }
/** * rtw_get_wps_ie - Search WPS IE from a series of IEs * @in_ie: Address of IEs to search * @in_len: Length limit from in_ie * @wps_ie: If not NULL and WPS IE is found, WPS IE will be copied to the buf starting from wps_ie * @wps_ielen: If not NULL and WPS IE is found, will set to the length of the entire WPS IE * * Returns: The address of the WPS IE found, or NULL */ u8 *get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen) { uint cnt; u8 *wpsie_ptr=NULL; u8 eid, wps_oui[4]={0x0,0x50,0xf2,0x04}; if(wps_ielen) *wps_ielen = 0; if(!in_ie || in_len<=0) return wpsie_ptr; cnt = 0; while(cnt<in_len) { eid = in_ie[cnt]; if((eid==_WPA_IE_ID_)&&(_memcmp(&in_ie[cnt+2], wps_oui, 4)==_TRUE)) { wpsie_ptr = &in_ie[cnt]; if(wps_ie) _memcpy(wps_ie, &in_ie[cnt], in_ie[cnt+1]+2); if(wps_ielen) *wps_ielen = in_ie[cnt+1]+2; cnt+=in_ie[cnt+1]+2; break; } else { cnt+=in_ie[cnt+1]+2; //goto next } } return wpsie_ptr; }
u8 *get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen) { //int match; uint cnt; u8 *wpsie_ptr=NULL; u8 eid, wps_oui[4]={0x0,0x50,0xf2,0x04}; cnt=_FIXED_IE_LENGTH_; //match=_FALSE; while(cnt<in_len) { eid = in_ie[cnt]; if((eid==_WPA_IE_ID_)&&(_memcmp(&in_ie[cnt+2], wps_oui, 4)==_TRUE)) { if(wps_ie) _memcpy(wps_ie, &in_ie[cnt], in_ie[cnt+1]+2); wpsie_ptr = &in_ie[cnt]; *wps_ielen = in_ie[cnt+1]+2; cnt+=in_ie[cnt+1]+2; //match = _TRUE; break; } else { cnt+=in_ie[cnt+1]+2; //goto next } } //return match; return wpsie_ptr; }
int parse_wpa_ie(u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher) { int i, ret=_SUCCESS; int left, count; u8 *pos; if (wpa_ie_len <= 0) { /* No WPA IE - fail silently */ return _FAIL; } if ((*wpa_ie != _WPA_IE_ID_) || (*(wpa_ie+1) != (u8)(wpa_ie_len - 2)) || (_memcmp(wpa_ie+2, WPA_OUI_TYPE, WPA_SELECTOR_LEN) != _TRUE) ) { return _FAIL; } pos = wpa_ie; pos += 8; left = wpa_ie_len - 8; //group_cipher if (left >= WPA_SELECTOR_LEN) { *group_cipher = get_wpa_cipher_suite(pos); pos += WPA_SELECTOR_LEN; left -= WPA_SELECTOR_LEN; } else if (left > 0) { RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("%s: ie length mismatch, %u too much", __FUNCTION__, left)); return _FAIL; } //pairwise_cipher if (left >= 2) { count = le16_to_cpu(*(u16*)pos);// pos += 2; left -= 2; if (count == 0 || left < count * WPA_SELECTOR_LEN) { RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("%s: ie count botch (pairwise), " "count %u left %u", __FUNCTION__, count, left)); return _FAIL; } for (i = 0; i < count; i++) { *pairwise_cipher |= get_wpa_cipher_suite(pos); pos += WPA_SELECTOR_LEN; left -= WPA_SELECTOR_LEN; } } else if (left == 1) { RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("%s: ie too short (for key mgmt)", __FUNCTION__)); return _FAIL; } return ret; }
u8 do_join(_adapter *padapter) { _list *plist, *phead; u8* pibss = NULL; struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); _queue *queue = &(pmlmepriv->scanned_queue); u8 ret = _TRUE; _func_enter_; phead = get_list_head(queue); plist = get_next(phead); RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_notice_, ("+do_join: phead=%p; plist=%p\n", phead, plist)); pmlmepriv->cur_network.join_res = -2; pmlmepriv->fw_state |= _FW_UNDER_LINKING; pmlmepriv->pscanned = plist; pmlmepriv->to_join = _TRUE; if (_queue_empty(queue) == _TRUE) { if(pmlmepriv->fw_state & _FW_UNDER_LINKING) pmlmepriv->fw_state ^= _FW_UNDER_LINKING; //when set_ssid/set_bssid for do_join(), but scanning queue is empty //we try to issue sitesurvey firstly if (pmlmepriv->sitesurveyctrl.traffic_busy == _FALSE) { // submit site_survey_cmd sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid); RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("do_join(): site survey if scanned_queue is empty\n.")); } //ret=_FALSE; goto exit; } else { int ret; if((ret=select_and_join_from_scanned_queue(pmlmepriv))==_SUCCESS) { _set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT); } #if 0 else if(ret == 2) { DBG_8712("*****UNDER_LINKED WITH SAME NETWORK, RETURN*****\n"); if(pmlmepriv->fw_state & _FW_UNDER_LINKING) pmlmepriv->fw_state ^= _FW_UNDER_LINKING; } #endif else { if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == _TRUE) { // submit createbss_cmd to change to a ADHOC_MASTER //pmlmepriv->lock has been acquired by caller... WLAN_BSSID_EX *pdev_network = &(padapter->registrypriv.dev_network); pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE; pibss = padapter->registrypriv.dev_network.MacAddress; _memset(&pdev_network->Ssid, 0, sizeof(NDIS_802_11_SSID)); _memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(NDIS_802_11_SSID)); update_registrypriv_dev_network(padapter); generate_random_ibss(pibss); if(createbss_cmd(padapter)!=_SUCCESS) { RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_err_,("***Error=>do_goin: createbss_cmd status FAIL*** \n ")); return _FALSE; } pmlmepriv->to_join = _FALSE; RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("***Error=> select_and_join_from_scanned_queue FAIL under STA_Mode*** \n ")); } else { // can't associate ; reset under-linking if(pmlmepriv->fw_state & _FW_UNDER_LINKING) pmlmepriv->fw_state ^= _FW_UNDER_LINKING; #if 0 if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == _TRUE) { if(_memcmp(pmlmepriv->cur_network.network.Ssid.Ssid, pmlmepriv->assoc_ssid.Ssid, pmlmepriv->assoc_ssid.SsidLength)) { // for funk to do roaming // funk will reconnect, but funk will not sitesurvey before reconnect RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("for funk to do roaming")); if(pmlmepriv->sitesurveyctrl.traffic_busy==_FALSE) sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid); } } #endif //when set_ssid/set_bssid for do_join(), but there are no desired bss in scanning queue //we try to issue sitesurvey firstly if(pmlmepriv->sitesurveyctrl.traffic_busy==_FALSE) { //printk("do_join() when no desired bss in scanning queue\n"); sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid); } } } } exit: _func_exit_; return ret; }
u8 set_802_11_ssid(_adapter *padapter, NDIS_802_11_SSID *ssid) { _irqL irqL; u8 status = _TRUE; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_network *pnetwork = &pmlmepriv->cur_network; _queue *queue = &pmlmepriv->scanned_queue; #ifdef PLATFORM_WINDOWS LARGE_INTEGER sys_time; u32 diff_time, cur_time; #endif _func_enter_; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_notice_, ("+set_802_11_ssid: ssid=[%s] fw_state=0x%08x\n", ssid->Ssid, get_fwstate(pmlmepriv))); if (padapter->hw_init_completed == _FALSE) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("set_ssid: hw_init_completed==_FALSE=>exit!!!\n")); return _FALSE; } _enter_critical(&pmlmepriv->lock, &irqL); if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING) == _TRUE) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("Set SSID is not allowed under surveying || adhoc master || under linking\n")); status = check_fwstate(pmlmepriv, _FW_UNDER_LINKING); goto _Abort_Set_SSID; } if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == _TRUE) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_ssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n")); if ((pmlmepriv->assoc_ssid.SsidLength == ssid->SsidLength) && (_memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid, ssid->SsidLength) == _TRUE)) { if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == _FALSE)) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("Set SSID is the same ssid, fw_state=0x%08x\n", get_fwstate(pmlmepriv))); if (is_same_ibss(padapter, pnetwork) == _FALSE) { //if in WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE, create bss or rejoin again disassoc_cmd(padapter); if (check_fwstate(pmlmepriv, _FW_LINKED) == _TRUE) indicate_disconnect(padapter); free_assoc_resources(padapter); if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == _TRUE) { _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); } } else { goto _Abort_Set_SSID;//it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. } } } else { RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("Set SSID not the same ssid\n")); RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("set_ssid=[%s] len=0x%x\n", ssid->Ssid, (unsigned int)ssid->SsidLength)); RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("assoc_ssid=[%s] len=0x%x\n", pmlmepriv->assoc_ssid.Ssid, (unsigned int)pmlmepriv->assoc_ssid.SsidLength)); disassoc_cmd(padapter); if (check_fwstate(pmlmepriv, _FW_LINKED) == _TRUE) indicate_disconnect(padapter); free_assoc_resources(padapter); if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == _TRUE) { _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); } } } #ifdef PLATFORM_WINDOWS if (padapter->securitypriv.btkip_countermeasure == _TRUE) { RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("set_802_11_ssid:padapter->securitypriv.btkip_countermeasure==_TRUE\n")); NdisGetCurrentSystemTime(&sys_time); cur_time=(u32)(sys_time.QuadPart/10); // In micro-second. RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("set_802_11_ssid:cur_time=0x%x\n",cur_time)); RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("set_802_11_ssid:psecuritypriv->last_mic_err_time=0x%x\n",padapter->securitypriv.btkip_countermeasure_time)); diff_time = cur_time -padapter->securitypriv.btkip_countermeasure_time; // In micro-second. RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("set_802_11_ssid:diff_time=0x%x\n",diff_time)); if (diff_time > 60000000) { RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("set_802_11_ssid(): countermeasure time >60s.\n")); padapter->securitypriv.btkip_countermeasure = _FALSE; // Update MIC error time. padapter->securitypriv.btkip_countermeasure_time = 0; } else { // can't join in 60 seconds. status = _FALSE; RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("set_802_11_ssid(): countermeasure time <60s.\n")); goto _Abort_Set_SSID; } } #endif #ifdef PLATFORM_LINUX if (padapter->securitypriv.btkip_countermeasure == _TRUE) { status = _FALSE; goto _Abort_Set_SSID; } #endif if (validate_ssid(ssid) == _FALSE) { status = _FALSE; goto _Abort_Set_SSID; } _memcpy(&pmlmepriv->assoc_ssid, ssid, sizeof(NDIS_802_11_SSID)); pmlmepriv->assoc_by_bssid = _FALSE; status = do_join(padapter); goto done; _Abort_Set_SSID: RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("-set_802_11_ssid: _Abort_Set_SSID: status=%d\n", status)); done: _exit_critical(&pmlmepriv->lock, &irqL); _func_exit_; return status; }
u8 set_802_11_bssid(_adapter *padapter, u8 *bssid) { _irqL irqL; u8 status = _TRUE; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; _queue *queue = &pmlmepriv->scanned_queue; _func_enter_; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_notice_, ("+set_802_11_bssid: bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5])); if ((bssid[0]==0x00 && bssid[1]==0x00 && bssid[2]==0x00 && bssid[3]==0x00 && bssid[4]==0x00 &&bssid[5]==0x00) || (bssid[0]==0xFF && bssid[1]==0xFF && bssid[2]==0xFF && bssid[3]==0xFF && bssid[4]==0xFF &&bssid[5]==0xFF)) { status = _FALSE; return status; } _enter_critical(&pmlmepriv->lock, &irqL); if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING) == _TRUE) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("Set BSSID is not allowed under surveying || adhoc master || under linking, fw_state=0x%08x\n", get_fwstate(pmlmepriv))); status = check_fwstate(pmlmepriv, _FW_UNDER_LINKING); goto _Abort_Set_BSSID; } if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == _TRUE) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_bssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n")); if (_memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid, ETH_ALEN) == _TRUE) { if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == _FALSE) goto _Abort_Set_BSSID;//it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. } else { RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("Set BSSID not the same ssid\n")); RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("set_bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", bssid[0],bssid[1],bssid[2],bssid[3],bssid[4],bssid[5])); RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("cur_bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", pmlmepriv->cur_network.network.MacAddress[0],pmlmepriv->cur_network.network.MacAddress[1],pmlmepriv->cur_network.network.MacAddress[2], pmlmepriv->cur_network.network.MacAddress[3],pmlmepriv->cur_network.network.MacAddress[4],pmlmepriv->cur_network.network.MacAddress[5])); disassoc_cmd(padapter); if (check_fwstate(pmlmepriv, _FW_LINKED) == _TRUE) indicate_disconnect(padapter); free_assoc_resources(padapter); if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == _TRUE)) { _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); } } } _memcpy(&pmlmepriv->assoc_bssid, bssid, ETH_ALEN); pmlmepriv->assoc_by_bssid = _TRUE; status = do_join(padapter); goto done; _Abort_Set_BSSID: RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("set_802_11_bssid: _Abort_Set_BSSID\n")); done: _exit_critical(&pmlmepriv->lock, &irqL); _func_exit_; return status; }
int memcmp(const void *s1, const void *s2, long n) { return _memcmp(s1, s2, n); }