diff options
| -rw-r--r-- | include/net/cfg80211.h | 16 | ||||
| -rw-r--r-- | net/wireless/scan.c | 38 |
2 files changed, 36 insertions, 18 deletions
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index c5d16f299d6f..a3f0a7ed31ac 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h | |||
| @@ -1658,6 +1658,22 @@ void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list, | |||
| 1658 | */ | 1658 | */ |
| 1659 | unsigned int cfg80211_classify8021d(struct sk_buff *skb); | 1659 | unsigned int cfg80211_classify8021d(struct sk_buff *skb); |
| 1660 | 1660 | ||
| 1661 | /** | ||
| 1662 | * cfg80211_find_ie - find information element in data | ||
| 1663 | * | ||
| 1664 | * @eid: element ID | ||
| 1665 | * @ies: data consisting of IEs | ||
| 1666 | * @len: length of data | ||
| 1667 | * | ||
| 1668 | * This function will return %NULL if the element ID could | ||
| 1669 | * not be found or if the element is invalid (claims to be | ||
| 1670 | * longer than the given data), or a pointer to the first byte | ||
| 1671 | * of the requested element, that is the byte containing the | ||
| 1672 | * element ID. There are no checks on the element length | ||
| 1673 | * other than having to fit into the given data. | ||
| 1674 | */ | ||
| 1675 | const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len); | ||
| 1676 | |||
| 1661 | /* | 1677 | /* |
| 1662 | * Regulatory helper functions for wiphys | 1678 | * Regulatory helper functions for wiphys |
| 1663 | */ | 1679 | */ |
diff --git a/net/wireless/scan.c b/net/wireless/scan.c index 06b0231ee5e3..978cac3414b5 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c | |||
| @@ -143,9 +143,9 @@ void cfg80211_bss_expire(struct cfg80211_registered_device *dev) | |||
| 143 | dev->bss_generation++; | 143 | dev->bss_generation++; |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | static u8 *find_ie(u8 num, u8 *ies, int len) | 146 | const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len) |
| 147 | { | 147 | { |
| 148 | while (len > 2 && ies[0] != num) { | 148 | while (len > 2 && ies[0] != eid) { |
| 149 | len -= ies[1] + 2; | 149 | len -= ies[1] + 2; |
| 150 | ies += ies[1] + 2; | 150 | ies += ies[1] + 2; |
| 151 | } | 151 | } |
| @@ -155,11 +155,12 @@ static u8 *find_ie(u8 num, u8 *ies, int len) | |||
| 155 | return NULL; | 155 | return NULL; |
| 156 | return ies; | 156 | return ies; |
| 157 | } | 157 | } |
| 158 | EXPORT_SYMBOL(cfg80211_find_ie); | ||
| 158 | 159 | ||
| 159 | static int cmp_ies(u8 num, u8 *ies1, size_t len1, u8 *ies2, size_t len2) | 160 | static int cmp_ies(u8 num, u8 *ies1, size_t len1, u8 *ies2, size_t len2) |
| 160 | { | 161 | { |
| 161 | const u8 *ie1 = find_ie(num, ies1, len1); | 162 | const u8 *ie1 = cfg80211_find_ie(num, ies1, len1); |
| 162 | const u8 *ie2 = find_ie(num, ies2, len2); | 163 | const u8 *ie2 = cfg80211_find_ie(num, ies2, len2); |
| 163 | int r; | 164 | int r; |
| 164 | 165 | ||
| 165 | if (!ie1 && !ie2) | 166 | if (!ie1 && !ie2) |
| @@ -185,9 +186,9 @@ static bool is_bss(struct cfg80211_bss *a, | |||
| 185 | if (!ssid) | 186 | if (!ssid) |
| 186 | return true; | 187 | return true; |
| 187 | 188 | ||
| 188 | ssidie = find_ie(WLAN_EID_SSID, | 189 | ssidie = cfg80211_find_ie(WLAN_EID_SSID, |
| 189 | a->information_elements, | 190 | a->information_elements, |
| 190 | a->len_information_elements); | 191 | a->len_information_elements); |
| 191 | if (!ssidie) | 192 | if (!ssidie) |
| 192 | return false; | 193 | return false; |
| 193 | if (ssidie[1] != ssid_len) | 194 | if (ssidie[1] != ssid_len) |
| @@ -204,9 +205,9 @@ static bool is_mesh(struct cfg80211_bss *a, | |||
| 204 | if (!is_zero_ether_addr(a->bssid)) | 205 | if (!is_zero_ether_addr(a->bssid)) |
| 205 | return false; | 206 | return false; |
| 206 | 207 | ||
| 207 | ie = find_ie(WLAN_EID_MESH_ID, | 208 | ie = cfg80211_find_ie(WLAN_EID_MESH_ID, |
| 208 | a->information_elements, | 209 | a->information_elements, |
| 209 | a->len_information_elements); | 210 | a->len_information_elements); |
| 210 | if (!ie) | 211 | if (!ie) |
| 211 | return false; | 212 | return false; |
| 212 | if (ie[1] != meshidlen) | 213 | if (ie[1] != meshidlen) |
| @@ -214,9 +215,9 @@ static bool is_mesh(struct cfg80211_bss *a, | |||
| 214 | if (memcmp(ie + 2, meshid, meshidlen)) | 215 | if (memcmp(ie + 2, meshid, meshidlen)) |
| 215 | return false; | 216 | return false; |
| 216 | 217 | ||
| 217 | ie = find_ie(WLAN_EID_MESH_CONFIG, | 218 | ie = cfg80211_find_ie(WLAN_EID_MESH_CONFIG, |
| 218 | a->information_elements, | 219 | a->information_elements, |
| 219 | a->len_information_elements); | 220 | a->len_information_elements); |
| 220 | if (!ie) | 221 | if (!ie) |
| 221 | return false; | 222 | return false; |
| 222 | if (ie[1] != sizeof(struct ieee80211_meshconf_ie)) | 223 | if (ie[1] != sizeof(struct ieee80211_meshconf_ie)) |
| @@ -395,11 +396,12 @@ cfg80211_bss_update(struct cfg80211_registered_device *dev, | |||
| 395 | 396 | ||
| 396 | if (is_zero_ether_addr(res->pub.bssid)) { | 397 | if (is_zero_ether_addr(res->pub.bssid)) { |
| 397 | /* must be mesh, verify */ | 398 | /* must be mesh, verify */ |
| 398 | meshid = find_ie(WLAN_EID_MESH_ID, res->pub.information_elements, | 399 | meshid = cfg80211_find_ie(WLAN_EID_MESH_ID, |
| 399 | res->pub.len_information_elements); | 400 | res->pub.information_elements, |
| 400 | meshcfg = find_ie(WLAN_EID_MESH_CONFIG, | 401 | res->pub.len_information_elements); |
| 401 | res->pub.information_elements, | 402 | meshcfg = cfg80211_find_ie(WLAN_EID_MESH_CONFIG, |
| 402 | res->pub.len_information_elements); | 403 | res->pub.information_elements, |
| 404 | res->pub.len_information_elements); | ||
| 403 | if (!meshid || !meshcfg || | 405 | if (!meshid || !meshcfg || |
| 404 | meshcfg[1] != sizeof(struct ieee80211_meshconf_ie)) { | 406 | meshcfg[1] != sizeof(struct ieee80211_meshconf_ie)) { |
| 405 | /* bogus mesh */ | 407 | /* bogus mesh */ |
