Home | History | Annotate | Download | only in wpa_supplicant
      1 /*
      2  * BSS table
      3  * Copyright (c) 2009-2010, Jouni Malinen <j (at) 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 #define WPA_BSS_QUAL_INVALID		BIT(0)
     15 #define WPA_BSS_NOISE_INVALID		BIT(1)
     16 #define WPA_BSS_LEVEL_INVALID		BIT(2)
     17 #define WPA_BSS_LEVEL_DBM		BIT(3)
     18 #define WPA_BSS_AUTHENTICATED		BIT(4)
     19 #define WPA_BSS_ASSOCIATED		BIT(5)
     20 #define WPA_BSS_ANQP_FETCH_TRIED	BIT(6)
     21 
     22 #define WPA_BSS_MASK_ALL		0xFFFFFFFF
     23 #define WPA_BSS_MASK_ID			BIT(0)
     24 #define WPA_BSS_MASK_BSSID		BIT(1)
     25 #define WPA_BSS_MASK_FREQ		BIT(2)
     26 #define WPA_BSS_MASK_BEACON_INT		BIT(3)
     27 #define WPA_BSS_MASK_CAPABILITIES	BIT(4)
     28 #define WPA_BSS_MASK_QUAL		BIT(5)
     29 #define WPA_BSS_MASK_NOISE		BIT(6)
     30 #define WPA_BSS_MASK_LEVEL		BIT(7)
     31 #define WPA_BSS_MASK_TSF		BIT(8)
     32 #define WPA_BSS_MASK_AGE		BIT(9)
     33 #define WPA_BSS_MASK_IE			BIT(10)
     34 #define WPA_BSS_MASK_FLAGS		BIT(11)
     35 #define WPA_BSS_MASK_SSID		BIT(12)
     36 #define WPA_BSS_MASK_WPS_SCAN		BIT(13)
     37 #define WPA_BSS_MASK_P2P_SCAN		BIT(14)
     38 #define WPA_BSS_MASK_INTERNETW		BIT(15)
     39 
     40 /**
     41  * struct wpa_bss - BSS table
     42  * @list: List entry for struct wpa_supplicant::bss
     43  * @list_id: List entry for struct wpa_supplicant::bss_id
     44  * @id: Unique identifier for this BSS entry
     45  * @scan_miss_count: Number of counts without seeing this BSS
     46  * @flags: information flags about the BSS/IBSS (WPA_BSS_*)
     47  * @last_update_idx: Index of the last scan update
     48  * @bssid: BSSID
     49  * @freq: frequency of the channel in MHz (e.g., 2412 = channel 1)
     50  * @beacon_int: beacon interval in TUs (host byte order)
     51  * @caps: capability information field in host byte order
     52  * @qual: signal quality
     53  * @noise: noise level
     54  * @level: signal level
     55  * @tsf: Timestamp of last Beacon/Probe Response frame
     56  * @last_update: Time of the last update (i.e., Beacon or Probe Response RX)
     57  * @ie_len: length of the following IE field in octets (from Probe Response)
     58  * @beacon_ie_len: length of the following Beacon IE field in octets
     59  *
     60  * This structure is used to store information about neighboring BSSes in
     61  * generic format. It is mainly updated based on scan results from the driver.
     62  */
     63 struct wpa_bss {
     64 	struct dl_list list;
     65 	struct dl_list list_id;
     66 	unsigned int id;
     67 	unsigned int scan_miss_count;
     68 	unsigned int last_update_idx;
     69 	unsigned int flags;
     70 	u8 bssid[ETH_ALEN];
     71 	u8 ssid[32];
     72 	size_t ssid_len;
     73 	int freq;
     74 	u16 beacon_int;
     75 	u16 caps;
     76 	int qual;
     77 	int noise;
     78 	int level;
     79 	u64 tsf;
     80 	struct os_time last_update;
     81 #ifdef CONFIG_INTERWORKING
     82 	struct wpabuf *anqp_venue_name;
     83 	struct wpabuf *anqp_network_auth_type;
     84 	struct wpabuf *anqp_roaming_consortium;
     85 	struct wpabuf *anqp_ip_addr_type_availability;
     86 	struct wpabuf *anqp_nai_realm;
     87 	struct wpabuf *anqp_3gpp;
     88 	struct wpabuf *anqp_domain_name;
     89 #endif /* CONFIG_INTERWORKING */
     90 	size_t ie_len;
     91 	size_t beacon_ie_len;
     92 	/* followed by ie_len octets of IEs */
     93 	/* followed by beacon_ie_len octets of IEs */
     94 };
     95 
     96 void wpa_bss_update_start(struct wpa_supplicant *wpa_s);
     97 void wpa_bss_update_scan_res(struct wpa_supplicant *wpa_s,
     98 			     struct wpa_scan_res *res);
     99 void wpa_bss_update_end(struct wpa_supplicant *wpa_s, struct scan_info *info,
    100 			int new_scan);
    101 int wpa_bss_init(struct wpa_supplicant *wpa_s);
    102 void wpa_bss_deinit(struct wpa_supplicant *wpa_s);
    103 void wpa_bss_flush(struct wpa_supplicant *wpa_s);
    104 void wpa_bss_flush_by_age(struct wpa_supplicant *wpa_s, int age);
    105 struct wpa_bss * wpa_bss_get(struct wpa_supplicant *wpa_s, const u8 *bssid,
    106 			     const u8 *ssid, size_t ssid_len);
    107 struct wpa_bss * wpa_bss_get_bssid(struct wpa_supplicant *wpa_s,
    108 				   const u8 *bssid);
    109 struct wpa_bss * wpa_bss_get_p2p_dev_addr(struct wpa_supplicant *wpa_s,
    110 					  const u8 *dev_addr);
    111 struct wpa_bss * wpa_bss_get_id(struct wpa_supplicant *wpa_s, unsigned int id);
    112 const u8 * wpa_bss_get_ie(const struct wpa_bss *bss, u8 ie);
    113 const u8 * wpa_bss_get_vendor_ie(const struct wpa_bss *bss, u32 vendor_type);
    114 struct wpabuf * wpa_bss_get_vendor_ie_multi(const struct wpa_bss *bss,
    115 					    u32 vendor_type);
    116 int wpa_bss_get_max_rate(const struct wpa_bss *bss);
    117 int wpa_bss_get_bit_rates(const struct wpa_bss *bss, u8 **rates);
    118 
    119 #endif /* BSS_H */
    120