diff options
Diffstat (limited to 'drivers/staging/wilc1000/coreconfigurator.c')
-rw-r--r-- | drivers/staging/wilc1000/coreconfigurator.c | 140 |
1 files changed, 46 insertions, 94 deletions
diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index db66b1cc80b3..44816024f79c 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -1,9 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include "coreconfigurator.h" -#include "wilc_wlan_if.h" -#include "wilc_wlan.h" -#include <linux/errno.h> -#include <linux/slab.h> + #define TAG_PARAM_OFFSET (MAC_HDR_LEN + TIME_STAMP_LEN + \ BEACON_INTERVAL_LEN + CAP_INFO_LEN) @@ -210,16 +207,6 @@ static inline u16 get_cap_info(u8 *data) return cap_info; } -static inline u16 get_assoc_resp_cap_info(u8 *data) -{ - u16 cap_info; - - cap_info = data[0]; - cap_info |= (data[1] << 8); - - return cap_info; -} - static inline u16 get_asoc_status(u8 *data) { u16 asoc_status; @@ -228,16 +215,6 @@ static inline u16 get_asoc_status(u8 *data) return (asoc_status << 8) | data[2]; } -static inline u16 get_asoc_id(u8 *data) -{ - u16 asoc_id; - - asoc_id = data[4]; - asoc_id |= (data[5] << 8); - - return asoc_id; -} - static u8 *get_tim_elm(u8 *msa, u16 rx_len, u16 tag_param_offset) { u16 index; @@ -272,78 +249,68 @@ s32 wilc_parse_network_info(u8 *msg_buffer, { struct network_info *network_info = NULL; u8 msg_type = 0; - u8 msg_id = 0; - u16 msg_len = 0; - - u16 wid_id = (u16)WID_NIL; u16 wid_len = 0; u8 *wid_val = NULL; + u8 *msa = NULL; + u16 rx_len = 0; + u8 *tim_elm = NULL; + u8 *ies = NULL; + u16 ies_len = 0; + u8 index = 0; + u32 tsf_lo; + u32 tsf_hi; msg_type = msg_buffer[0]; if ('N' != msg_type) return -EFAULT; - msg_id = msg_buffer[1]; - msg_len = MAKE_WORD16(msg_buffer[2], msg_buffer[3]); - wid_id = MAKE_WORD16(msg_buffer[4], msg_buffer[5]); wid_len = MAKE_WORD16(msg_buffer[6], msg_buffer[7]); wid_val = &msg_buffer[8]; - { - u8 *msa = NULL; - u16 rx_len = 0; - u8 *tim_elm = NULL; - u8 *ies = NULL; - u16 ies_len = 0; - u8 index = 0; - u32 tsf_lo; - u32 tsf_hi; - - network_info = kzalloc(sizeof(*network_info), GFP_KERNEL); - if (!network_info) - return -ENOMEM; + network_info = kzalloc(sizeof(*network_info), GFP_KERNEL); + if (!network_info) + return -ENOMEM; - network_info->rssi = wid_val[0]; + network_info->rssi = wid_val[0]; - msa = &wid_val[1]; + msa = &wid_val[1]; - rx_len = wid_len - 1; - network_info->cap_info = get_cap_info(msa); - network_info->tsf_lo = get_beacon_timestamp_lo(msa); + rx_len = wid_len - 1; + network_info->cap_info = get_cap_info(msa); + network_info->tsf_lo = get_beacon_timestamp_lo(msa); - tsf_lo = get_beacon_timestamp_lo(msa); - tsf_hi = get_beacon_timestamp_hi(msa); + tsf_lo = get_beacon_timestamp_lo(msa); + tsf_hi = get_beacon_timestamp_hi(msa); - network_info->tsf_hi = tsf_lo | ((u64)tsf_hi << 32); + network_info->tsf_hi = tsf_lo | ((u64)tsf_hi << 32); - get_ssid(msa, network_info->ssid, &network_info->ssid_len); - get_BSSID(msa, network_info->bssid); + get_ssid(msa, network_info->ssid, &network_info->ssid_len); + get_BSSID(msa, network_info->bssid); - network_info->ch = get_current_channel_802_11n(msa, rx_len - + FCS_LEN); + network_info->ch = get_current_channel_802_11n(msa, rx_len + + FCS_LEN); - index = MAC_HDR_LEN + TIME_STAMP_LEN; + index = MAC_HDR_LEN + TIME_STAMP_LEN; - network_info->beacon_period = get_beacon_period(msa + index); + network_info->beacon_period = get_beacon_period(msa + index); - index += BEACON_INTERVAL_LEN + CAP_INFO_LEN; + index += BEACON_INTERVAL_LEN + CAP_INFO_LEN; - tim_elm = get_tim_elm(msa, rx_len + FCS_LEN, index); - if (tim_elm) - network_info->dtim_period = tim_elm[3]; - ies = &msa[TAG_PARAM_OFFSET]; - ies_len = rx_len - TAG_PARAM_OFFSET; + tim_elm = get_tim_elm(msa, rx_len + FCS_LEN, index); + if (tim_elm) + network_info->dtim_period = tim_elm[3]; + ies = &msa[TAG_PARAM_OFFSET]; + ies_len = rx_len - TAG_PARAM_OFFSET; - if (ies_len > 0) { - network_info->ies = kmemdup(ies, ies_len, GFP_KERNEL); - if (!network_info->ies) { - kfree(network_info); - return -ENOMEM; - } + if (ies_len > 0) { + network_info->ies = kmemdup(ies, ies_len, GFP_KERNEL); + if (!network_info->ies) { + kfree(network_info); + return -ENOMEM; } - network_info->ies_len = ies_len; } + network_info->ies_len = ies_len; *ret_network_info = network_info; @@ -351,38 +318,23 @@ s32 wilc_parse_network_info(u8 *msg_buffer, } s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len, - struct connect_resp_info **ret_connect_resp_info) + struct connect_info *ret_conn_info) { - struct connect_resp_info *connect_resp_info = NULL; - u16 assoc_resp_len = 0; u8 *ies = NULL; u16 ies_len = 0; - connect_resp_info = kzalloc(sizeof(*connect_resp_info), GFP_KERNEL); - if (!connect_resp_info) - return -ENOMEM; - - assoc_resp_len = (u16)buffer_len; - - connect_resp_info->status = get_asoc_status(buffer); - if (connect_resp_info->status == SUCCESSFUL_STATUSCODE) { - connect_resp_info->capability = get_assoc_resp_cap_info(buffer); - connect_resp_info->assoc_id = get_asoc_id(buffer); - + ret_conn_info->status = get_asoc_status(buffer); + if (ret_conn_info->status == SUCCESSFUL_STATUSCODE) { ies = &buffer[CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN]; - ies_len = assoc_resp_len - (CAP_INFO_LEN + STATUS_CODE_LEN + - AID_LEN); + ies_len = buffer_len - (CAP_INFO_LEN + STATUS_CODE_LEN + + AID_LEN); - connect_resp_info->ies = kmemdup(ies, ies_len, GFP_KERNEL); - if (!connect_resp_info->ies) { - kfree(connect_resp_info); + ret_conn_info->resp_ies = kmemdup(ies, ies_len, GFP_KERNEL); + if (!ret_conn_info->resp_ies) return -ENOMEM; - } - connect_resp_info->ies_len = ies_len; + ret_conn_info->resp_ies_len = ies_len; } - *ret_connect_resp_info = connect_resp_info; - return 0; } |