* @version 1.0
*/
-
#include "coreconfigurator.h"
#include "wilc_wlan_if.h"
#include "wilc_wlan.h"
#include <linux/errno.h>
#include <linux/slab.h>
+#include <linux/etherdevice.h>
#define TAG_PARAM_OFFSET (MAC_HDR_LEN + TIME_STAMP_LEN + \
BEACON_INTERVAL_LEN + CAP_INFO_LEN)
+#define ADDR1 4
+#define ADDR2 10
+#define ADDR3 16
/* Basic Frame Type Codes (2-bit) */
enum basic_frame_type {
/* response frame. */
static inline u16 get_beacon_period(u8 *data)
{
- u16 bcn_per = 0;
+ u16 bcn_per;
bcn_per = data[0];
bcn_per |= (data[1] << 8);
return ((header[1] & 0x02) >> 1);
}
-/* This function extracts the MAC Address in 'address1' field of the MAC */
-/* header and updates the MAC Address in the allocated 'addr' variable. */
-static inline void get_address1(u8 *pu8msa, u8 *addr)
-{
- memcpy(addr, pu8msa + 4, 6);
-}
-
-/* This function extracts the MAC Address in 'address2' field of the MAC */
-/* header and updates the MAC Address in the allocated 'addr' variable. */
-static inline void get_address2(u8 *pu8msa, u8 *addr)
-{
- memcpy(addr, pu8msa + 10, 6);
-}
-
-/* This function extracts the MAC Address in 'address3' field of the MAC */
-/* header and updates the MAC Address in the allocated 'addr' variable. */
-static inline void get_address3(u8 *pu8msa, u8 *addr)
-{
- memcpy(addr, pu8msa + 16, 6);
-}
-
/* This function extracts the BSSID from the incoming WLAN packet based on */
-/* the 'from ds' bit, and updates the MAC Address in the allocated 'addr' */
+/* the 'from ds' bit, and updates the MAC Address in the allocated 'data' */
/* variable. */
static inline void get_BSSID(u8 *data, u8 *bssid)
{
if (get_from_ds(data) == 1)
- get_address2(data, bssid);
+ /*
+ * Extract the MAC Address in 'address2' field of the MAC
+ * header and update the MAC Address in the allocated 'data'
+ * variable.
+ */
+ ether_addr_copy(data, bssid + ADDR2);
else if (get_to_ds(data) == 1)
- get_address1(data, bssid);
+ /*
+ * Extract the MAC Address in 'address1' field of the MAC
+ * header and update the MAC Address in the allocated 'data'
+ * variable.
+ */
+ ether_addr_copy(data, bssid + ADDR1);
else
- get_address3(data, bssid);
+ /*
+ * Extract the MAC Address in 'address3' field of the MAC
+ * header and update the MAC Address in the allocated 'data'
+ * variable.
+ */
+ ether_addr_copy(data, bssid + ADDR3);
}
/* This function extracts the SSID from a beacon/probe response frame */
/* response frame. */
static inline u16 get_assoc_resp_cap_info(u8 *data)
{
- u16 cap_info = 0;
+ u16 cap_info;
cap_info = data[0];
cap_info |= (data[1] << 8);
/* association response frame and returns association status code */
static inline u16 get_asoc_status(u8 *data)
{
- u16 asoc_status = 0;
+ u16 asoc_status;
asoc_status = data[3];
asoc_status = (asoc_status << 8) | data[2];
/* response frame */
static inline u16 get_asoc_id(u8 *data)
{
- u16 asoc_id = 0;
+ u16 asoc_id;
asoc_id = data[4];
asoc_id |= (data[5] << 8);
u8 *get_tim_elm(u8 *pu8msa, u16 u16RxLen, u16 u16TagParamOffset)
{
- u16 u16index = 0;
+ u16 u16index;
/*************************************************************************/
/* Beacon Frame - Frame Body */
while (u16index < (u16RxLen - FCS_LEN)) {
if (pu8msa[u16index] == ITIM)
return &pu8msa[u16index];
- else
- u16index += (IE_HDR_LEN + pu8msa[u16index + 1]);
+ u16index += (IE_HDR_LEN + pu8msa[u16index + 1]);
}
return NULL;
while (index < (u16RxLen - FCS_LEN)) {
if (pu8msa[index] == IDSPARMS)
return pu8msa[index + 2];
- else
- /* Increment index by length information and header */
- index += pu8msa[index + 1] + IE_HDR_LEN;
+ /* Increment index by length information and header */
+ index += pu8msa[index + 1] + IE_HDR_LEN;
}
/* Return current channel information from the MIB, if beacon/probe */
return 0; /* no MIB here */
}
-u8 get_current_channel(u8 *pu8msa, u16 u16RxLen)
-{
- /* Extract current channel information from */
- /* the beacon/probe response frame */
- return get_current_channel_802_11n(pu8msa, u16RxLen);
-}
-
/**
* @brief parses the received 'N' message
* @details
pstrNetworkInfo->u64Tsf = u32Tsf_Lo | ((u64)u32Tsf_Hi << 32);
/* Get SSID */
- get_ssid(pu8msa, pstrNetworkInfo->au8ssid, &(pstrNetworkInfo->u8SsidLen));
+ get_ssid(pu8msa, pstrNetworkInfo->au8ssid, &pstrNetworkInfo->u8SsidLen);
/* Get BSSID */
get_BSSID(pu8msa, pstrNetworkInfo->au8bssid);
- /* Get the current channel */
- pstrNetworkInfo->u8channel = get_current_channel(pu8msa, (u16RxLen + FCS_LEN));
+ /*
+ * Extract current channel information from
+ * the beacon/probe response frame
+ */
+ pstrNetworkInfo->u8channel = get_current_channel_802_11n(pu8msa,
+ u16RxLen + FCS_LEN);
/* Get beacon period */
- u8index = (MAC_HDR_LEN + TIME_STAMP_LEN);
+ u8index = MAC_HDR_LEN + TIME_STAMP_LEN;
pstrNetworkInfo->u16BeaconPeriod = get_beacon_period(pu8msa + u8index);
u8index += BEACON_INTERVAL_LEN + CAP_INFO_LEN;
/* Get DTIM Period */
- pu8TimElm = get_tim_elm(pu8msa, (u16RxLen + FCS_LEN), u8index);
+ pu8TimElm = get_tim_elm(pu8msa, u16RxLen + FCS_LEN, u8index);
if (pu8TimElm != NULL)
pstrNetworkInfo->u8DtimPeriod = pu8TimElm[3];
pu8IEs = &pu8msa[MAC_HDR_LEN + TIME_STAMP_LEN + BEACON_INTERVAL_LEN + CAP_INFO_LEN];
*ppstrConnectRespInfo = pstrConnectRespInfo;
-
return s32Error;
}