3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-26 10:39:23 +01:00

scan: Add scan_bss_new_from_probe_req

This commit is contained in:
Andrew Zaborowski 2019-11-21 21:15:57 +01:00 committed by Denis Kenzior
parent 1d57ec0d46
commit becba0dd09
2 changed files with 33 additions and 0 deletions

View File

@ -47,6 +47,7 @@
#include "src/nl80211util.h" #include "src/nl80211util.h"
#include "src/util.h" #include "src/util.h"
#include "src/p2putil.h" #include "src/p2putil.h"
#include "src/mpdu.h"
#include "src/scan.h" #include "src/scan.h"
#define SCAN_MAX_INTERVAL 320 #define SCAN_MAX_INTERVAL 320
@ -1334,6 +1335,32 @@ static void scan_bss_compute_rank(struct scan_bss *bss)
bss->rank = irank; bss->rank = irank;
} }
struct scan_bss *scan_bss_new_from_probe_req(const struct mmpdu_header *mpdu,
const uint8_t *body,
size_t body_len,
uint32_t frequency, int rssi)
{
struct scan_bss *bss;
bss = l_new(struct scan_bss, 1);
memcpy(bss->addr, mpdu->address_2, 6);
bss->utilization = 127;
bss->source_frame = SCAN_BSS_PROBE_REQ;
bss->frequency = frequency;
bss->signal_strength = rssi;
if (!scan_parse_bss_information_elements(bss, body, body_len))
goto fail;
scan_bss_compute_rank(bss);
return bss;
fail:
scan_bss_free(bss);
return NULL;
}
void scan_bss_free(struct scan_bss *bss) void scan_bss_free(struct scan_bss *bss)
{ {
l_free(bss->ext_supp_rates_ie); l_free(bss->ext_supp_rates_ie);

View File

@ -43,6 +43,7 @@ struct ie_rsn_info;
struct p2p_probe_resp; struct p2p_probe_resp;
struct p2p_probe_req; struct p2p_probe_req;
struct p2p_beacon; struct p2p_beacon;
struct mmpdu_header;
enum scan_bss_frame_type { enum scan_bss_frame_type {
SCAN_BSS_PROBE_RESP, SCAN_BSS_PROBE_RESP,
@ -144,6 +145,11 @@ int scan_bss_rank_compare(const void *a, const void *b, void *user);
int scan_bss_get_rsn_info(const struct scan_bss *bss, struct ie_rsn_info *info); int scan_bss_get_rsn_info(const struct scan_bss *bss, struct ie_rsn_info *info);
struct scan_bss *scan_bss_new_from_probe_req(const struct mmpdu_header *mpdu,
const uint8_t *body,
size_t body_len,
uint32_t frequency, int rssi);
uint8_t scan_freq_to_channel(uint32_t freq, enum scan_band *out_band); uint8_t scan_freq_to_channel(uint32_t freq, enum scan_band *out_band);
uint32_t scan_channel_to_freq(uint8_t channel, enum scan_band band); uint32_t scan_channel_to_freq(uint8_t channel, enum scan_band band);
enum scan_band scan_oper_class_to_band(const uint8_t *country, enum scan_band scan_oper_class_to_band(const uint8_t *country,