qcacmn: Introduce wlan_is_ie_valid()

In change "qcacld-3.0: Validate Scan Default IEs" in the qcacld-3.0
project (Change-Id: Ifd8739c96a9990f01ff159eb59a7e904f7b8c592) the
utility API hdd_is_ie_valid() was introduced. One review comment was
that this should be a converged API, so rename and relocate the API.

Change-Id: I8d2a520ea70645ab54b450de83452c0035653485
CRs-Fixed: 2169420
This commit is contained in:
Jeff Johnson 2018-01-09 10:26:11 -08:00 • committed by snandini
commit 3b17c379c5
2 changed files with 36 additions and 0 deletions

View file

@ -62,6 +62,21 @@ bool wlan_is_dsrc_channel(uint16_t center_freq);
*/
uint8_t wlan_freq_to_chan(uint32_t freq);
/**
* wlan_is_ie_valid() - Determine if an IE sequence is valid
* @ie: Pointer to the IE buffer
* @ie_len: Length of the IE buffer @ie
*
* This function validates that the IE sequence is valid by verifying
* that the sum of the lengths of the embedded elements match the
* length of the sequence.
*
* Note well that a 0-length IE sequence is considered valid.
*
* Return: true if the IE sequence is valid, false if it is invalid
*/
bool wlan_is_ie_valid(const uint8_t *ie, size_t ie_len);
/**
* wlan_get_ie_ptr_from_eid() - Find out ie from eid
* @eid: element id

View file

@ -72,6 +72,27 @@ uint8_t wlan_freq_to_chan(uint32_t freq)
return chan;
}
bool wlan_is_ie_valid(const uint8_t *ie, size_t ie_len)
{
uint8_t elen;
while (ie_len) {
if (ie_len < 2)
return false;
elen = ie[1];
ie_len -= 2;
ie += 2;
if (elen > ie_len)
return false;
ie_len -= elen;
ie += elen;
}
return true;
}
static const uint8_t *wlan_get_ie_ptr_from_eid_n_oui(uint8_t eid,
const uint8_t *oui,
uint8_t oui_size,