1 /*
2 * BSS table
3 * Copyright (c) 2009-2019, Jouni Malinen <j@w1.fi>
4 *
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
7 */
8
9 #ifndef BSS_H
10 #define BSS_H
11
12 struct wpa_scan_res;
13 struct wpa_supplicant;
14
15 /**
16 * struct wpa_bss - BSS table
17 *
18 * This structure is used to store information about neighboring BSSes in
19 * generic format. It is mainly updated based on scan results from the driver.
20 */
21 struct wpa_bss {
22 /** List entry for struct wpa_supplicant::bss */
23 struct dl_list list;
24 /** List entry for struct wpa_supplicant::bss_id */
25 struct dl_list list_id;
26 /** Unique identifier for this BSS entry */
27 unsigned int id;
28 /** Index of the last scan update */
29 unsigned int last_update_idx;
30 /** Information flags about the BSS/IBSS (WPA_BSS_*) */
31 unsigned int flags;
32 /** BSSID */
33 u8 bssid[ETH_ALEN];
34 /** SSID */
35 u8 ssid[SSID_MAX_LEN];
36 /** Length of SSID */
37 size_t ssid_len;
38 /** Frequency of the channel in MHz (e.g., 2412 = channel 1) */
39 int channel;
40 /** Beacon interval in TUs (host byte order) */
41 u16 beacon_int;
42 /** Capability information field in host byte order */
43 u16 caps;
44 /** Signal quality */
45 int qual;
46 /** Noise level */
47 int noise;
48 /** Signal level */
49 int level;
50 /** Timestamp of last Beacon/Probe Response frame */
51 u64 tsf;
52 /** Timestamp of parent aganist which it was taken */
53 u64 parent_tsf;
54 /** Time of the last update (i.e., Beacon or Probe Response RX) */
55 struct os_reltime last_update;
56 /** Length of the following IE field in octets (from Probe Response) */
57 size_t ie_len;
58 /** Length of the following Beacon IE field in octets */
59 size_t beacon_ie_len;
60 /* followed by ie_len octets of IEs */
61 /* followed by beacon_ie_len octets of IEs */
62 u8 ies[];
63 };
64
wpa_bss_ie_ptr(const struct wpa_bss * bss)65 static inline const u8 * wpa_bss_ie_ptr(const struct wpa_bss *bss)
66 {
67 return bss->ies;
68 }
69
70 void wpa_bss_update_start(struct wpa_supplicant *wpa_s);
71 void wpa_bss_update_scan_res(struct wpa_supplicant *wpa_s,
72 struct wpa_scan_res *res,
73 struct os_reltime *fetch_time);
74 void wpa_bss_remove(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
75 const char *reason);
76 void wpa_bss_update_end(struct wpa_supplicant *wpa_s);
77 int wpa_bss_init(struct wpa_supplicant *wpa_s);
78 void wpa_bss_deinit(struct wpa_supplicant *wpa_s);
79 void wpa_bss_flush(struct wpa_supplicant *wpa_s);
80 struct wpa_bss * wpa_bss_get(struct wpa_supplicant *wpa_s, const u8 *bssid,
81 const u8 *ssid, size_t ssid_len);
82 struct wpa_bss * wpa_bss_get_bssid(struct wpa_supplicant *wpa_s,
83 const u8 *bssid);
84 const u8 * wpa_bss_get_ie(const struct wpa_bss *bss, u8 ie);
85 const u8 * wpa_bss_get_vendor_ie(const struct wpa_bss *bss, u32 vendor_type);
86 int wpa_bss_ext_capab(const struct wpa_bss *bss, unsigned int capab);
87 struct wpa_bss * wpa_bss_get_next_bss(struct wpa_supplicant *wpa_s,
88 struct wpa_bss *prev_bss);
89
90 void calculate_update_time(const struct os_reltime *fetch_time,
91 unsigned int age_ms,
92 struct os_reltime *update_time);
93
94 #endif /* BSS_H */
95