scan.h (5711B)
1 /* 2 * 3 * Wireless daemon for Linux 4 * 5 * Copyright (C) 2015-2019 Intel Corporation. All rights reserved. 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 * 21 */ 22 23 #include "src/defs.h" 24 #include "src/vendor_quirks.h" 25 26 struct scan_freq_set; 27 struct ie_rsn_info; 28 struct ie_owe_transition_info; 29 struct p2p_probe_resp; 30 struct p2p_probe_req; 31 struct p2p_beacon; 32 struct mmpdu_header; 33 struct wiphy; 34 enum security; 35 enum band_freq; 36 37 enum scan_state { 38 SCAN_STATE_NOT_RUNNING, 39 SCAN_STATE_PASSIVE, 40 SCAN_STATE_ACTIVE, 41 }; 42 43 enum scan_bss_frame_type { 44 SCAN_BSS_PROBE_RESP, 45 SCAN_BSS_PROBE_REQ, 46 SCAN_BSS_BEACON, 47 }; 48 49 struct scan_bss { 50 uint8_t addr[6]; 51 uint32_t frequency; 52 int32_t signal_strength; 53 uint16_t capability; 54 uint8_t *rsne; 55 uint8_t *rsnxe; 56 uint8_t *wpa; 57 uint8_t *osen; 58 uint8_t *wsc; /* Concatenated WSC IEs */ 59 ssize_t wsc_size; /* Size of Concatenated WSC IEs */ 60 enum scan_bss_frame_type source_frame; 61 union { 62 struct p2p_probe_resp *p2p_probe_resp_info; 63 struct p2p_probe_req *p2p_probe_req_info; 64 struct p2p_beacon *p2p_beacon_info; 65 }; 66 struct ie_owe_transition_info *owe_trans; 67 uint8_t mde[3]; 68 uint8_t ssid[SSID_MAX_SIZE]; 69 uint8_t ssid_len; 70 uint8_t utilization; 71 uint16_t sta_count; 72 uint8_t cc[3]; 73 uint16_t rank; 74 uint64_t time_stamp; 75 uint64_t data_rate; 76 uint8_t hessid[6]; 77 uint8_t *rc_ie; /* Roaming consortium IE */ 78 uint8_t hs20_version; 79 uint64_t parent_tsf; 80 uint8_t *wfd; /* Concatenated WFD IEs */ 81 ssize_t wfd_size; /* Size of Concatenated WFD IEs */ 82 int8_t snr; 83 struct vendor_quirk vendor_quirks; 84 bool mde_present : 1; 85 bool cc_present : 1; 86 bool cap_rm_neighbor_report : 1; 87 bool ht_capable : 1; 88 bool vht_capable : 1; 89 bool anqp_capable : 1; 90 bool hs20_capable : 1; 91 bool proxy_arp : 1; 92 bool hs20_dgaf_disable : 1; 93 uint8_t cost_level : 3; 94 uint8_t cost_flags : 4; 95 bool dpp_configurator : 1; 96 bool sae_pw_id_used : 1; 97 bool sae_pw_id_exclusive : 1; 98 bool have_snr : 1; 99 bool have_utilization : 1; 100 }; 101 102 struct scan_parameters { 103 const uint8_t *extra_ie; 104 size_t extra_ie_size; 105 const struct scan_freq_set *freqs; 106 uint16_t duration; 107 bool flush : 1; 108 bool randomize_mac_addr_hint : 1; 109 bool no_cck_rates : 1; 110 bool duration_mandatory : 1; 111 bool ap_scan : 1; 112 const uint8_t *ssid; /* Used for direct probe request */ 113 size_t ssid_len; 114 const uint8_t *source_mac; 115 }; 116 117 typedef void (*scan_func_t)(struct l_genl_msg *msg, void *user_data); 118 typedef void (*scan_trigger_func_t)(int, void *); 119 typedef bool (*scan_notify_func_t)(int err, struct l_queue *bss_list, 120 const struct scan_freq_set *freqs, 121 void *userdata); 122 typedef void (*scan_destroy_func_t)(void *userdata); 123 124 static inline int scan_bss_addr_cmp(const struct scan_bss *a1, 125 const struct scan_bss *a2) 126 { 127 return memcmp(a1->addr, a2->addr, sizeof(a1->addr)); 128 } 129 130 static inline bool scan_bss_addr_eq(const struct scan_bss *a1, 131 const struct scan_bss *a2) 132 { 133 return !memcmp(a1->addr, a2->addr, sizeof(a1->addr)); 134 } 135 136 struct l_genl_msg *scan_build_trigger_scan_bss(uint32_t ifindex, 137 struct wiphy *wiphy, 138 uint32_t frequency, 139 const uint8_t *ssid, 140 uint32_t ssid_len); 141 142 uint32_t scan_passive(uint64_t wdev_id, const struct scan_freq_set *freqs, 143 scan_trigger_func_t trigger, scan_notify_func_t notify, 144 void *userdata, scan_destroy_func_t destroy); 145 uint32_t scan_passive_full(uint64_t wdev_id, 146 const struct scan_parameters *params, 147 scan_trigger_func_t trigger, 148 scan_notify_func_t notify, void *userdata, 149 scan_destroy_func_t destroy); 150 uint32_t scan_active(uint64_t wdev_id, uint8_t *extra_ie, size_t extra_ie_size, 151 scan_trigger_func_t trigger, 152 scan_notify_func_t notify, void *userdata, 153 scan_destroy_func_t destroy); 154 uint32_t scan_active_full(uint64_t wdev_id, 155 const struct scan_parameters *params, 156 scan_trigger_func_t trigger, scan_notify_func_t notify, 157 void *userdata, scan_destroy_func_t destroy); 158 uint32_t scan_owe_hidden(uint64_t wdev_id, struct l_queue *list, 159 scan_trigger_func_t trigger, scan_notify_func_t notify, 160 void *userdata, scan_destroy_func_t destroy); 161 bool scan_cancel(uint64_t wdev_id, uint32_t id); 162 163 void scan_periodic_start(uint64_t wdev_id, scan_trigger_func_t trigger, 164 scan_notify_func_t func, void *userdata); 165 bool scan_periodic_stop(uint64_t wdev_id); 166 167 uint64_t scan_get_triggered_time(uint64_t wdev_id, uint32_t id); 168 169 bool scan_get_firmware_scan(uint64_t wdev_id, scan_notify_func_t notify, 170 void *userdata, scan_destroy_func_t destroy); 171 172 void scan_bss_free(struct scan_bss *bss); 173 int scan_bss_rank_compare(const void *a, const void *b, void *user); 174 175 int scan_bss_get_rsn_info(const struct scan_bss *bss, struct ie_rsn_info *info); 176 int scan_bss_get_security(const struct scan_bss *bss, enum security *security); 177 178 struct scan_bss *scan_bss_new_from_probe_req(const struct mmpdu_header *mpdu, 179 const uint8_t *body, 180 size_t body_len, 181 uint32_t frequency, int rssi); 182 183 double scan_get_band_rank_modifier(enum band_freq band); 184 185 bool scan_wdev_add(uint64_t wdev_id); 186 bool scan_wdev_remove(uint64_t wdev_id);