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