From 86199d079183dc920e73f611779d28232a5aafc8 Mon Sep 17 00:00:00 2001 From: Carlos Garces Date: Thu, 21 Oct 2021 18:42:12 +0200 Subject: [PATCH] use native wireless IE codes from linux/ieee80211.h IE code definitions have been replaced with native ones to avoid code duplication. The unobvious substitutions are: _WPA_IE_ID_ -> WLAN_EID_VENDOR_SPECIFIC; _WPA2_IE_ID_ -> WLAN_EID_RSN. Link: https://lore.kernel.org/r/20201011105050.5896-1-insafonov@gmail.com --- core/rtw_ieee80211.c | 12 ++++++------ core/rtw_mlme.c | 6 +++--- core/rtw_mlme_ext.c | 4 ++-- core/rtw_tdls.c | 40 +++++++++++++++++++-------------------- include/rtw_security.h | 3 --- os_dep/linux/mlme_linux.c | 2 +- 6 files changed, 32 insertions(+), 35 deletions(-) diff --git a/core/rtw_ieee80211.c b/core/rtw_ieee80211.c index 0b1ca99..48d136e 100644 --- a/core/rtw_ieee80211.c +++ b/core/rtw_ieee80211.c @@ -592,7 +592,7 @@ unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit) int limit_new = limit; while (1) { - pbuf = rtw_get_ie(pbuf, _WPA_IE_ID_, &len, limit_new); + pbuf = rtw_get_ie(pbuf, WLAN_EID_VENDOR_SPECIFIC, &len, limit_new); if (pbuf) { @@ -638,7 +638,7 @@ check_next_ie: unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit) { - return rtw_get_ie(pie, _WPA2_IE_ID_, rsn_ie_len, limit); + return rtw_get_ie(pie, WLAN_EID_RSN, rsn_ie_len, limit); } @@ -724,7 +724,7 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, } - if ((*wpa_ie != _WPA_IE_ID_) || (*(wpa_ie + 1) != (u8)(wpa_ie_len - 2)) || + if ((*wpa_ie != WLAN_EID_VENDOR_SPECIFIC) || (*(wpa_ie + 1) != (u8)(wpa_ie_len - 2)) || (_rtw_memcmp(wpa_ie + 2, RTW_WPA_OUI_TYPE, WPA_SELECTOR_LEN) != _TRUE)) return _FAIL; @@ -982,7 +982,7 @@ int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, while (cnt < in_len) { authmode = in_ie[cnt]; - if ((authmode == _WPA_IE_ID_) && (_rtw_memcmp(&in_ie[cnt + 2], &wpa_oui[0], 4) == _TRUE)) { + if ((authmode == WLAN_EID_VENDOR_SPECIFIC) && (_rtw_memcmp(&in_ie[cnt + 2], &wpa_oui[0], 4) == _TRUE)) { if (wpa_ie) memcpy(wpa_ie, &in_ie[cnt], in_ie[cnt + 1] + 2); @@ -990,7 +990,7 @@ int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, *wpa_len = in_ie[cnt + 1] + 2; cnt += in_ie[cnt + 1] + 2; /* get next */ } else { - if (authmode == _WPA2_IE_ID_) { + if (authmode == WLAN_EID_RSN) { if (rsn_ie) memcpy(rsn_ie, &in_ie[cnt], in_ie[cnt + 1] + 2); @@ -1019,7 +1019,7 @@ u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen) eid = ie_ptr[0]; - if ((eid == _WPA_IE_ID_) && (_rtw_memcmp(&ie_ptr[2], wps_oui, 4) == _TRUE)) { + if ((eid == WLAN_EID_VENDOR_SPECIFIC) && (_rtw_memcmp(&ie_ptr[2], wps_oui, 4) == _TRUE)) { /* RTW_INFO("==> found WPS_IE.....\n"); */ *wps_ielen = ie_ptr[1] + 2; match = _TRUE; diff --git a/core/rtw_mlme.c b/core/rtw_mlme.c index 34fcfef..0758643 100644 --- a/core/rtw_mlme.c +++ b/core/rtw_mlme.c @@ -4350,15 +4350,15 @@ sint rtw_restruct_sec_ie(_adapter *adapter, u8 *out_ie) uint ndisauthmode = psecuritypriv->ndisauthtype; if ((ndisauthmode == Ndis802_11AuthModeWPA) || (ndisauthmode == Ndis802_11AuthModeWPAPSK)) - authmode = _WPA_IE_ID_; + authmode = WLAN_EID_VENDOR_SPECIFIC; if ((ndisauthmode == Ndis802_11AuthModeWPA2) || (ndisauthmode == Ndis802_11AuthModeWPA2PSK)) - authmode = _WPA2_IE_ID_; + authmode = WLAN_EID_RSN; if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { memcpy(out_ie, psecuritypriv->wps_ie, psecuritypriv->wps_ie_len); ielength = psecuritypriv->wps_ie_len; - } else if ((authmode == _WPA_IE_ID_) || (authmode == _WPA2_IE_ID_)) { + } else if ((authmode == WLAN_EID_VENDOR_SPECIFIC) || (authmode == WLAN_EID_RSN)) { /* copy RSN or SSN */ memcpy(out_ie, psecuritypriv->supplicant_ie, psecuritypriv->supplicant_ie[1] + 2); /* debug for CONFIG_IEEE80211W diff --git a/core/rtw_mlme_ext.c b/core/rtw_mlme_ext.c index 217c3b1..3a88380 100644 --- a/core/rtw_mlme_ext.c +++ b/core/rtw_mlme_ext.c @@ -13372,9 +13372,9 @@ static u8 rtw_ft_update_ftie( u8 *pie; u32 len; - if ((pie = rtw_get_ie(pft_roam->updated_ft_ies, _FTIE_, &len, + if ((pie = rtw_get_ie(pft_roam->updated_ft_ies, WLAN_EID_FAST_BSS_TRANSITION, &len, pft_roam->updated_ft_ies_len)) != NULL) { - *pframe = rtw_set_ie(*pframe, _FTIE_, len , + *pframe = rtw_set_ie(*pframe, WLAN_EID_FAST_BSS_TRANSITION, len , (pie+2), &(pattrib->pktlen)); } else return _FAIL; diff --git a/core/rtw_tdls.c b/core/rtw_tdls.c index 2fba19c..84787ce 100644 --- a/core/rtw_tdls.c +++ b/core/rtw_tdls.c @@ -754,17 +754,17 @@ u8 *rtw_tdls_set_ftie(struct tdls_txmgmt *ptxmgmt, u8 *pframe, struct pkt_attrib int len = 0; if (ptxmgmt->len > 0) - p = rtw_get_ie(ptxmgmt->buf, _FTIE_, &len, ptxmgmt->len); + p = rtw_get_ie(ptxmgmt->buf, WLAN_EID_FAST_BSS_TRANSITION, &len, ptxmgmt->len); if (p != NULL) - return rtw_set_ie(pframe, _FTIE_, len, p + 2, &(pattrib->pktlen)); + return rtw_set_ie(pframe, WLAN_EID_FAST_BSS_TRANSITION, len, p + 2, &(pattrib->pktlen)); else { if (ANonce != NULL) memcpy(FTIE.Anonce, ANonce, WPA_NONCE_LEN); if (SNonce != NULL) memcpy(FTIE.Snonce, SNonce, WPA_NONCE_LEN); - return rtw_set_ie(pframe, _FTIE_, TDLS_FTIE_DATA_LEN, + return rtw_set_ie(pframe, WLAN_EID_FAST_BSS_TRANSITION, TDLS_FTIE_DATA_LEN, (u8 *)FTIE.data, &(pattrib->pktlen)); } } @@ -881,7 +881,7 @@ u8 *rtw_tdls_set_supported_rate(_adapter *padapter, u8 *pframe, struct pkt_attri u8 *rtw_tdls_set_sup_reg_class(u8 *pframe, struct pkt_attrib *pattrib) { - return rtw_set_ie(pframe, _SRC_IE_ , sizeof(TDLS_SRC), TDLS_SRC, &(pattrib->pktlen)); + return rtw_set_ie(pframe, WLAN_EID_SUPPORTED_REGULATORY_CLASSES , sizeof(TDLS_SRC), TDLS_SRC, &(pattrib->pktlen)); } u8 *rtw_tdls_set_linkid(_adapter *padapter, u8 *pframe, struct pkt_attrib *pattrib, u8 init) @@ -900,7 +900,7 @@ u8 *rtw_tdls_set_linkid(_adapter *padapter, u8 *pframe, struct pkt_attrib *pattr memcpy((link_id_addr + 6), pattrib->dst, 6); memcpy((link_id_addr + 12), pattrib->src, 6); } - return rtw_set_ie(pframe, _LINK_ID_IE_, 18, link_id_addr, &(pattrib->pktlen)); + return rtw_set_ie(pframe, WLAN_EID_LINK_ID, 18, link_id_addr, &(pattrib->pktlen)); } #ifdef CONFIG_TDLS_CH_SW @@ -924,7 +924,7 @@ u8 *rtw_tdls_set_ch_sw(u8 *pframe, struct pkt_attrib *pattrib, struct sta_info * memcpy(ch_switch_timing, &switch_time, 2); memcpy(ch_switch_timing + 2, &switch_timeout, 2); - return rtw_set_ie(pframe, _CH_SWITCH_TIMING_, 4, ch_switch_timing, &(pattrib->pktlen)); + return rtw_set_ie(pframe, WLAN_EID_CHAN_SWITCH_TIMING, 4, ch_switch_timing, &(pattrib->pktlen)); } void rtw_tdls_set_ch_sw_oper_control(_adapter *padapter, u8 enable) @@ -1945,7 +1945,7 @@ sint On_TDLS_Setup_Req(_adapter *padapter, union recv_frame *precv_frame, struct break; case WLAN_EID_VENDOR_SPECIFIC: break; - case _FTIE_: + case WLAN_EID_FAST_BSS_TRANSITION: if (prx_pkt_attrib->encrypt) memcpy(SNonce, (ptr + j + 52), 32); break; @@ -1953,7 +1953,7 @@ sint On_TDLS_Setup_Req(_adapter *padapter, union recv_frame *precv_frame, struct if (prx_pkt_attrib->encrypt) timeout_interval = cpu_to_le32(*(u32 *)(ptr + j + 3)); break; - case _RIC_Descriptor_IE_: + case WLAN_EID_RIC_DESCRIPTOR: break; #ifdef CONFIG_80211N_HT case WLAN_EID_HT_CAPABILITY: @@ -1969,7 +1969,7 @@ sint On_TDLS_Setup_Req(_adapter *padapter, union recv_frame *precv_frame, struct #endif case EID_BSSCoexistence: break; - case _LINK_ID_IE_: + case WLAN_EID_LINK_ID: if (_rtw_memcmp(get_bssid(pmlmepriv), pIE->data, 6) == _FALSE) txmgmt.status_code = _STATS_NOT_IN_SAME_BSS_; break; @@ -2124,7 +2124,7 @@ int On_TDLS_Setup_Rsp(_adapter *padapter, union recv_frame *precv_frame, struct ptdls_sta->qos_option = _TRUE; } break; - case _FTIE_: + case WLAN_EID_FAST_BSS_TRANSITION: pftie = (u8 *)pIE; memcpy(ANonce, (ptr + j + 20), 32); break; @@ -2132,7 +2132,7 @@ int On_TDLS_Setup_Rsp(_adapter *padapter, union recv_frame *precv_frame, struct ptimeout_ie = (u8 *)pIE; timeout_interval = cpu_to_le32(*(u32 *)(ptimeout_ie + 3)); break; - case _RIC_Descriptor_IE_: + case WLAN_EID_RIC_DESCRIPTOR: break; #ifdef CONFIG_80211N_HT case WLAN_EID_HT_CAPABILITY: @@ -2152,7 +2152,7 @@ int On_TDLS_Setup_Rsp(_adapter *padapter, union recv_frame *precv_frame, struct #endif case EID_BSSCoexistence: break; - case _LINK_ID_IE_: + case WLAN_EID_LINK_ID: plinkid_ie = (u8 *)pIE; break; default: @@ -2271,7 +2271,7 @@ int On_TDLS_Setup_Cfm(_adapter *padapter, union recv_frame *precv_frame, struct ptdls_sta->qos_option = _TRUE; } break; - case _FTIE_: + case WLAN_EID_FAST_BSS_TRANSITION: pftie = (u8 *)pIE; break; case WLAN_EID_TIMEOUT_INTERVAL: @@ -2289,7 +2289,7 @@ int On_TDLS_Setup_Cfm(_adapter *padapter, union recv_frame *precv_frame, struct rtw_tdls_process_vht_op_mode_notify(padapter, ptdls_sta, pIE->data, pIE->Length); break; #endif - case _LINK_ID_IE_: + case WLAN_EID_LINK_ID: plinkid_ie = (u8 *)pIE; break; default: @@ -2371,7 +2371,7 @@ int On_TDLS_Dis_Req(_adapter *padapter, union recv_frame *precv_frame) pIE = (PNDIS_802_11_VARIABLE_IEs)(ptr + j); switch (pIE->ElementID) { - case _LINK_ID_IE_: + case WLAN_EID_LINK_ID: psta_ap = rtw_get_stainfo(pstapriv, pIE->data); if (psta_ap == NULL) goto exit; @@ -2574,9 +2574,9 @@ sint On_TDLS_Ch_Switch_Req(_adapter *padapter, union recv_frame *precv_frame, st break; } break; - case _LINK_ID_IE_: + case WLAN_EID_LINK_ID: break; - case _CH_SWITCH_TIMING_: + case WLAN_EID_CHAN_SWITCH_TIMING: ptdls_sta->ch_switch_time = (RTW_GET_LE16(pIE->data) >= TDLS_CH_SWITCH_TIME * 1000) ? RTW_GET_LE16(pIE->data) : TDLS_CH_SWITCH_TIME * 1000; ptdls_sta->ch_switch_timeout = (RTW_GET_LE16(pIE->data + 2) >= TDLS_CH_SWITCH_TIMEOUT * 1000) ? @@ -2672,9 +2672,9 @@ sint On_TDLS_Ch_Switch_Rsp(_adapter *padapter, union recv_frame *precv_frame, st pIE = (PNDIS_802_11_VARIABLE_IEs)(ptr + j); switch (pIE->ElementID) { - case _LINK_ID_IE_: + case WLAN_EID_LINK_ID: break; - case _CH_SWITCH_TIMING_: + case WLAN_EID_CHAN_SWITCH_TIMING: memcpy(&switch_time, pIE->data, 2); if (switch_time > ptdls_sta->ch_switch_time) memcpy(&ptdls_sta->ch_switch_time, &switch_time, 2); @@ -3144,7 +3144,7 @@ void rtw_build_tdls_peer_traffic_indication_ies(_adapter *padapter, struct xmit_ AC_queue = BIT(2); if (ptdls_sta->uapsd_vo & BIT(1)) AC_queue = BIT(3); - pframe = rtw_set_ie(pframe, _PTI_BUFFER_STATUS_, 1, &AC_queue, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_PU_BUFFER_STATUS, 1, &AC_queue, &(pattrib->pktlen)); } diff --git a/include/rtw_security.h b/include/rtw_security.h index 5d52d42..ff3c739 100644 --- a/include/rtw_security.h +++ b/include/rtw_security.h @@ -38,9 +38,6 @@ const char *security_type_str(u8 value); -#define _WPA_IE_ID_ 0xdd -#define _WPA2_IE_ID_ 0x30 - #define SHA256_MAC_LEN 32 #define AES_BLOCK_SIZE 16 #define AES_PRIV_SIZE (4 * 44) diff --git a/os_dep/linux/mlme_linux.c b/os_dep/linux/mlme_linux.c index 2098c19..4e66201 100644 --- a/os_dep/linux/mlme_linux.c +++ b/os_dep/linux/mlme_linux.c @@ -187,7 +187,7 @@ void rtw_report_sec_ie(_adapter *adapter, u8 authmode, u8 *sec_ie) buff = NULL; - if (authmode == _WPA_IE_ID_) { + if (authmode == WLAN_EID_VENDOR_SPECIFIC) { buff = rtw_zmalloc(IW_CUSTOM_MAX); if (NULL == buff) {