168e8e04eSSam Leffler /*- 24d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3fe267a55SPedro F. Giffuni * 410ad9a77SSam Leffler * Copyright (c) 2005-2009 Sam Leffler, Errno Consulting 568e8e04eSSam Leffler * All rights reserved. 668e8e04eSSam Leffler * 768e8e04eSSam Leffler * Redistribution and use in source and binary forms, with or without 868e8e04eSSam Leffler * modification, are permitted provided that the following conditions 968e8e04eSSam Leffler * are met: 1068e8e04eSSam Leffler * 1. Redistributions of source code must retain the above copyright 1168e8e04eSSam Leffler * notice, this list of conditions and the following disclaimer. 1268e8e04eSSam Leffler * 2. Redistributions in binary form must reproduce the above copyright 1368e8e04eSSam Leffler * notice, this list of conditions and the following disclaimer in the 1468e8e04eSSam Leffler * documentation and/or other materials provided with the distribution. 1568e8e04eSSam Leffler * 1668e8e04eSSam Leffler * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1768e8e04eSSam Leffler * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1868e8e04eSSam Leffler * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1968e8e04eSSam Leffler * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2068e8e04eSSam Leffler * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2168e8e04eSSam Leffler * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2268e8e04eSSam Leffler * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2368e8e04eSSam Leffler * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2468e8e04eSSam Leffler * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2568e8e04eSSam Leffler * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2668e8e04eSSam Leffler */ 2768e8e04eSSam Leffler #ifndef _NET80211_IEEE80211_SCAN_H_ 2868e8e04eSSam Leffler #define _NET80211_IEEE80211_SCAN_H_ 2968e8e04eSSam Leffler 30b032f27cSSam Leffler /* 31b032f27cSSam Leffler * 802.11 scanning support. 32b032f27cSSam Leffler * 33b032f27cSSam Leffler * Scanning is the procedure by which a station locates a bss to join 34b032f27cSSam Leffler * (infrastructure/ibss mode), or a channel to use (when operating as 35b032f27cSSam Leffler * an ap or ibss master). Scans are either "active" or "passive". An 36b032f27cSSam Leffler * active scan causes one or more probe request frames to be sent on 37b032f27cSSam Leffler * visiting each channel. A passive request causes each channel in the 38b032f27cSSam Leffler * scan set to be visited but no frames to be transmitted; the station 39b032f27cSSam Leffler * only listens for traffic. Note that active scanning may still need 40b032f27cSSam Leffler * to listen for traffic before sending probe request frames depending 41b032f27cSSam Leffler * on regulatory constraints; the 802.11 layer handles this by generating 42b032f27cSSam Leffler * a callback when scanning on a ``passive channel'' when the 43b032f27cSSam Leffler * IEEE80211_FEXT_PROBECHAN flag is set. 44b032f27cSSam Leffler * 454f8cb6ffSRui Paulo * A scan operation involves constructing a set of channels to inspect 46b032f27cSSam Leffler * (the scan set), visiting each channel and collecting information 47b032f27cSSam Leffler * (e.g. what bss are present), and then analyzing the results to make 48b032f27cSSam Leffler * decisions like which bss to join. This process needs to be as fast 49b032f27cSSam Leffler * as possible so we do things like intelligently construct scan sets 50b032f27cSSam Leffler * and dwell on a channel only as long as necessary. The scan code also 51b032f27cSSam Leffler * maintains a cache of recent scan results and uses it to bypass scanning 52b032f27cSSam Leffler * whenever possible. The scan cache is also used to enable roaming 53b032f27cSSam Leffler * between access points when operating in infrastructure mode. 54b032f27cSSam Leffler * 55b032f27cSSam Leffler * Scanning is handled with pluggable modules that implement "policy" 56b032f27cSSam Leffler * per-operating mode. The core scanning support provides an 57b032f27cSSam Leffler * instrastructure to support these modules and exports a common api 58b032f27cSSam Leffler * to the rest of the 802.11 layer. Policy modules decide what 59b032f27cSSam Leffler * channels to visit, what state to record to make decisions (e.g. ap 60b032f27cSSam Leffler * mode scanning for auto channel selection keeps significantly less 61b032f27cSSam Leffler * state than sta mode scanning for an ap to associate to), and selects 62b032f27cSSam Leffler * the final station/channel to return as the result of a scan. 63b032f27cSSam Leffler * 64b032f27cSSam Leffler * Scanning is done synchronously when initially bringing a vap to an 65b032f27cSSam Leffler * operational state and optionally in the background to maintain the 66b032f27cSSam Leffler * scan cache for doing roaming and rogue ap monitoring. Scanning is 67b032f27cSSam Leffler * not tied to the 802.11 state machine that governs vaps though there 68b032f27cSSam Leffler * is linkage to the IEEE80211_SCAN state. Only one vap at a time may 69b032f27cSSam Leffler * be scanning; this scheduling policy is handled in ieee80211_new_state 70b032f27cSSam Leffler * and is invisible to the scanning code. 71b032f27cSSam Leffler */ 7268e8e04eSSam Leffler #define IEEE80211_SCAN_MAX IEEE80211_CHAN_MAX 7368e8e04eSSam Leffler 74b032f27cSSam Leffler struct ieee80211_scanner; /* scan policy state */ 7568e8e04eSSam Leffler 7668e8e04eSSam Leffler struct ieee80211_scan_ssid { 7768e8e04eSSam Leffler int len; /* length in bytes */ 7868e8e04eSSam Leffler uint8_t ssid[IEEE80211_NWID_LEN]; /* ssid contents */ 7968e8e04eSSam Leffler }; 80b032f27cSSam Leffler #define IEEE80211_SCAN_MAX_SSID 1 /* max # ssid's to probe */ 8168e8e04eSSam Leffler 82b032f27cSSam Leffler /* 83f7f155faSAdrian Chadd * High-level implementation visible to ieee80211_scan.[ch]. 84f7f155faSAdrian Chadd * 85f7f155faSAdrian Chadd * The default scanner (ieee80211_scan_sw.[ch]) implements a software 86f7f155faSAdrian Chadd * driven scanner. Firmware driven scanning needs a different set of 87f7f155faSAdrian Chadd * behaviours. 88f7f155faSAdrian Chadd */ 89f7f155faSAdrian Chadd struct ieee80211_scan_methods { 90f7f155faSAdrian Chadd void (*sc_attach)(struct ieee80211com *); 91f7f155faSAdrian Chadd void (*sc_detach)(struct ieee80211com *); 92f7f155faSAdrian Chadd void (*sc_vattach)(struct ieee80211vap *); 93f7f155faSAdrian Chadd void (*sc_vdetach)(struct ieee80211vap *); 94f7f155faSAdrian Chadd void (*sc_set_scan_duration)(struct ieee80211vap *, u_int); 95f7f155faSAdrian Chadd int (*sc_start_scan)(const struct ieee80211_scanner *, 96f7f155faSAdrian Chadd struct ieee80211vap *, int, u_int, u_int, u_int, u_int, 97f7f155faSAdrian Chadd const struct ieee80211_scan_ssid ssids[]); 98f7f155faSAdrian Chadd int (*sc_check_scan)(const struct ieee80211_scanner *, 99f7f155faSAdrian Chadd struct ieee80211vap *, int, u_int, u_int, u_int, u_int, 100f7f155faSAdrian Chadd const struct ieee80211_scan_ssid ssids[]); 101f7f155faSAdrian Chadd int (*sc_bg_scan)(const struct ieee80211_scanner *, 102f7f155faSAdrian Chadd struct ieee80211vap *, int); 103f7f155faSAdrian Chadd void (*sc_cancel_scan)(struct ieee80211vap *); 104f7f155faSAdrian Chadd void (*sc_cancel_anyscan)(struct ieee80211vap *); 105f7f155faSAdrian Chadd void (*sc_scan_next)(struct ieee80211vap *); 106f7f155faSAdrian Chadd void (*sc_scan_done)(struct ieee80211vap *); 107*9776aba3SBjoern A. Zeeb void (*sc_scan_probe_curchan)(struct ieee80211vap *, bool); 108f7f155faSAdrian Chadd void (*sc_add_scan)(struct ieee80211vap *, 109f7f155faSAdrian Chadd struct ieee80211_channel *, 110f7f155faSAdrian Chadd const struct ieee80211_scanparams *, 111f7f155faSAdrian Chadd const struct ieee80211_frame *, 112f7f155faSAdrian Chadd int, int, int); 113f7f155faSAdrian Chadd }; 114f7f155faSAdrian Chadd 115f7f155faSAdrian Chadd /* 116b032f27cSSam Leffler * Scan state visible to the 802.11 layer. Scan parameters and 117b032f27cSSam Leffler * results are stored in this data structure. The ieee80211_scan_state 118b032f27cSSam Leffler * structure is extended with space that is maintained private to 119b032f27cSSam Leffler * the core scanning support. We allocate one instance and link it 120b032f27cSSam Leffler * to the ieee80211com structure; then share it between all associated 121b032f27cSSam Leffler * vaps. We could allocate multiple of these, e.g. to hold multiple 122b032f27cSSam Leffler * scan results, but this is sufficient for current needs. 123b032f27cSSam Leffler */ 12468e8e04eSSam Leffler struct ieee80211_scan_state { 125b032f27cSSam Leffler struct ieee80211vap *ss_vap; 1265efea30fSAndrew Thompson struct ieee80211com *ss_ic; 12768e8e04eSSam Leffler const struct ieee80211_scanner *ss_ops; /* policy hookup, see below */ 12868e8e04eSSam Leffler void *ss_priv; /* scanner private state */ 12968e8e04eSSam Leffler uint16_t ss_flags; 13068e8e04eSSam Leffler #define IEEE80211_SCAN_NOPICK 0x0001 /* scan only, no selection */ 13168e8e04eSSam Leffler #define IEEE80211_SCAN_ACTIVE 0x0002 /* active scan (probe req) */ 13268e8e04eSSam Leffler #define IEEE80211_SCAN_PICK1ST 0x0004 /* ``hey sailor'' mode */ 13368e8e04eSSam Leffler #define IEEE80211_SCAN_BGSCAN 0x0008 /* bg scan, exit ps at end */ 13468e8e04eSSam Leffler #define IEEE80211_SCAN_ONCE 0x0010 /* do one complete pass */ 135b032f27cSSam Leffler #define IEEE80211_SCAN_NOBCAST 0x0020 /* no broadcast probe req */ 136b032f27cSSam Leffler #define IEEE80211_SCAN_NOJOIN 0x0040 /* no auto-sequencing */ 1373346164cSBjoern A. Zeeb #define IEEE80211_SCAN_PUBLIC_MASK 0x0fff /* top 4 bits for internal use */ 13868e8e04eSSam Leffler #define IEEE80211_SCAN_GOTPICK 0x1000 /* got candidate, can stop */ 13968e8e04eSSam Leffler uint8_t ss_nssid; /* # ssid's to probe/match */ 14068e8e04eSSam Leffler struct ieee80211_scan_ssid ss_ssid[IEEE80211_SCAN_MAX_SSID]; 14168e8e04eSSam Leffler /* ssid's to probe/match */ 14268e8e04eSSam Leffler /* ordered channel set */ 14368e8e04eSSam Leffler struct ieee80211_channel *ss_chans[IEEE80211_SCAN_MAX]; 14468e8e04eSSam Leffler uint16_t ss_next; /* ix of next chan to scan */ 14568e8e04eSSam Leffler uint16_t ss_last; /* ix+1 of last chan to scan */ 14668e8e04eSSam Leffler unsigned long ss_mindwell; /* min dwell on channel */ 14768e8e04eSSam Leffler unsigned long ss_maxdwell; /* max dwell on channel */ 14868e8e04eSSam Leffler }; 14968e8e04eSSam Leffler 15033396ec2SBjoern A. Zeeb #define IEEE80211_SS_FLAGS_BITS \ 15133396ec2SBjoern A. Zeeb "\20\1NOPICK\2ACTIVE\3PICK1ST\4BGSCAN\5ONCE\6NOBCAST\7NOJOIN" \ 15233396ec2SBjoern A. Zeeb "\15GOTPICK" 15333396ec2SBjoern A. Zeeb 15468e8e04eSSam Leffler /* 15568e8e04eSSam Leffler * The upper 16 bits of the flags word is used to communicate 15668e8e04eSSam Leffler * information to the scanning code that is NOT recorded in 15768e8e04eSSam Leffler * ss_flags. It might be better to split this stuff out into 15868e8e04eSSam Leffler * a separate variable to avoid confusion. 15968e8e04eSSam Leffler */ 160b032f27cSSam Leffler #define IEEE80211_SCAN_FLUSH 0x00010000 /* flush candidate table */ 161b032f27cSSam Leffler #define IEEE80211_SCAN_NOSSID 0x80000000 /* don't update ssid list */ 16268e8e04eSSam Leffler 16368e8e04eSSam Leffler struct ieee80211com; 16468e8e04eSSam Leffler void ieee80211_scan_attach(struct ieee80211com *); 16568e8e04eSSam Leffler void ieee80211_scan_detach(struct ieee80211com *); 166b032f27cSSam Leffler void ieee80211_scan_vattach(struct ieee80211vap *); 167b032f27cSSam Leffler void ieee80211_scan_vdetach(struct ieee80211vap *); 16868e8e04eSSam Leffler 16968e8e04eSSam Leffler #define IEEE80211_SCAN_FOREVER 0x7fffffff 170b032f27cSSam Leffler int ieee80211_start_scan(struct ieee80211vap *, int flags, 171b032f27cSSam Leffler u_int duration, u_int mindwell, u_int maxdwell, 17268e8e04eSSam Leffler u_int nssid, const struct ieee80211_scan_ssid ssids[]); 173b032f27cSSam Leffler int ieee80211_check_scan(struct ieee80211vap *, int flags, 174b032f27cSSam Leffler u_int duration, u_int mindwell, u_int maxdwell, 17568e8e04eSSam Leffler u_int nssid, const struct ieee80211_scan_ssid ssids[]); 176b032f27cSSam Leffler int ieee80211_check_scan_current(struct ieee80211vap *); 177b032f27cSSam Leffler int ieee80211_bg_scan(struct ieee80211vap *, int); 178b032f27cSSam Leffler void ieee80211_cancel_scan(struct ieee80211vap *); 179b032f27cSSam Leffler void ieee80211_cancel_anyscan(struct ieee80211vap *); 180b032f27cSSam Leffler void ieee80211_scan_next(struct ieee80211vap *); 181b032f27cSSam Leffler void ieee80211_scan_done(struct ieee80211vap *); 182*9776aba3SBjoern A. Zeeb void ieee80211_probe_curchan(struct ieee80211vap *, bool); 183b032f27cSSam Leffler struct ieee80211_channel *ieee80211_scan_pickchannel(struct ieee80211com *, int); 18468e8e04eSSam Leffler 18568e8e04eSSam Leffler struct ieee80211_scanparams; 186b032f27cSSam Leffler void ieee80211_add_scan(struct ieee80211vap *, 1872808a02bSAdrian Chadd struct ieee80211_channel *, 18868e8e04eSSam Leffler const struct ieee80211_scanparams *, 18968e8e04eSSam Leffler const struct ieee80211_frame *, 1905463c4a4SSam Leffler int subtype, int rssi, int noise); 19168e8e04eSSam Leffler void ieee80211_scan_timeout(struct ieee80211com *); 19268e8e04eSSam Leffler 193b032f27cSSam Leffler void ieee80211_scan_assoc_success(struct ieee80211vap *, 19468e8e04eSSam Leffler const uint8_t mac[IEEE80211_ADDR_LEN]); 19568e8e04eSSam Leffler enum { 19668e8e04eSSam Leffler IEEE80211_SCAN_FAIL_TIMEOUT = 1, /* no response to mgmt frame */ 19768e8e04eSSam Leffler IEEE80211_SCAN_FAIL_STATUS = 2 /* negative response to " " */ 19868e8e04eSSam Leffler }; 199b032f27cSSam Leffler void ieee80211_scan_assoc_fail(struct ieee80211vap *, 20068e8e04eSSam Leffler const uint8_t mac[IEEE80211_ADDR_LEN], int reason); 201b032f27cSSam Leffler void ieee80211_scan_flush(struct ieee80211vap *); 20268e8e04eSSam Leffler 20368e8e04eSSam Leffler struct ieee80211_scan_entry; 20468e8e04eSSam Leffler typedef void ieee80211_scan_iter_func(void *, 20568e8e04eSSam Leffler const struct ieee80211_scan_entry *); 206b032f27cSSam Leffler void ieee80211_scan_iterate(struct ieee80211vap *, 20768e8e04eSSam Leffler ieee80211_scan_iter_func, void *); 208b032f27cSSam Leffler enum { 209b032f27cSSam Leffler IEEE80211_BPARSE_BADIELEN = 0x01, /* ie len past end of frame */ 210b032f27cSSam Leffler IEEE80211_BPARSE_RATES_INVALID = 0x02, /* invalid RATES ie */ 211b032f27cSSam Leffler IEEE80211_BPARSE_XRATES_INVALID = 0x04, /* invalid XRATES ie */ 212b032f27cSSam Leffler IEEE80211_BPARSE_SSID_INVALID = 0x08, /* invalid SSID ie */ 213b032f27cSSam Leffler IEEE80211_BPARSE_CHAN_INVALID = 0x10, /* invalid FH/DSPARMS chan */ 214b032f27cSSam Leffler IEEE80211_BPARSE_OFFCHAN = 0x20, /* DSPARMS chan != curchan */ 215b032f27cSSam Leffler IEEE80211_BPARSE_BINTVAL_INVALID= 0x40, /* invalid beacon interval */ 216c70761e6SSam Leffler IEEE80211_BPARSE_CSA_INVALID = 0x80, /* invalid CSA ie */ 21773547826SBjoern A. Zeeb IEEE80211_BPARSE_MESHID_INVALID = 0x100, /* invalid Mesh ID ie */ 218b032f27cSSam Leffler }; 21968e8e04eSSam Leffler 22068e8e04eSSam Leffler /* 22168e8e04eSSam Leffler * Parameters supplied when adding/updating an entry in a 22268e8e04eSSam Leffler * scan cache. Pointer variables should be set to NULL 22368e8e04eSSam Leffler * if no data is available. Pointer references can be to 22468e8e04eSSam Leffler * local data; any information that is saved will be copied. 22568e8e04eSSam Leffler * All multi-byte values must be in host byte order. 22668e8e04eSSam Leffler */ 22768e8e04eSSam Leffler struct ieee80211_scanparams { 22873547826SBjoern A. Zeeb uint32_t status; /* bitmask of IEEE80211_BPARSE_* */ 229b032f27cSSam Leffler uint8_t chan; /* channel # from FH/DSPARMS */ 230b032f27cSSam Leffler uint8_t bchan; /* curchan's channel # */ 23168e8e04eSSam Leffler uint8_t fhindex; 232b032f27cSSam Leffler uint16_t fhdwell; /* FHSS dwell interval */ 233b032f27cSSam Leffler uint16_t capinfo; /* 802.11 capabilities */ 234b032f27cSSam Leffler uint16_t erp; /* NB: 0x100 indicates ie present */ 23568e8e04eSSam Leffler uint16_t bintval; 23668e8e04eSSam Leffler uint8_t timoff; 237b032f27cSSam Leffler uint8_t *ies; /* all captured ies */ 238b032f27cSSam Leffler size_t ies_len; /* length of all captured ies */ 23968e8e04eSSam Leffler uint8_t *tim; 24068e8e04eSSam Leffler uint8_t *tstamp; 24168e8e04eSSam Leffler uint8_t *country; 24268e8e04eSSam Leffler uint8_t *ssid; 24368e8e04eSSam Leffler uint8_t *rates; 24468e8e04eSSam Leffler uint8_t *xrates; 24568e8e04eSSam Leffler uint8_t *doth; 24668e8e04eSSam Leffler uint8_t *wpa; 24768e8e04eSSam Leffler uint8_t *rsn; 24868e8e04eSSam Leffler uint8_t *wme; 24968e8e04eSSam Leffler uint8_t *htcap; 25068e8e04eSSam Leffler uint8_t *htinfo; 25168e8e04eSSam Leffler uint8_t *ath; 25210ad9a77SSam Leffler uint8_t *tdma; 253c70761e6SSam Leffler uint8_t *csa; 25432b0e64bSAdrian Chadd uint8_t *quiet; 25559aa14a9SRui Paulo uint8_t *meshid; 25659aa14a9SRui Paulo uint8_t *meshconf; 25755c68c64SAdrian Chadd uint8_t *vhtcap; 25855c68c64SAdrian Chadd uint8_t *vhtopmode; 25955c68c64SAdrian Chadd uint8_t *spare[1]; 26068e8e04eSSam Leffler }; 26168e8e04eSSam Leffler 26268e8e04eSSam Leffler /* 26368e8e04eSSam Leffler * Scan cache entry format used when exporting data from a policy 26468e8e04eSSam Leffler * module; this data may be represented some other way internally. 26568e8e04eSSam Leffler */ 26668e8e04eSSam Leffler struct ieee80211_scan_entry { 26768e8e04eSSam Leffler uint8_t se_macaddr[IEEE80211_ADDR_LEN]; 26868e8e04eSSam Leffler uint8_t se_bssid[IEEE80211_ADDR_LEN]; 269b032f27cSSam Leffler /* XXX can point inside se_ies */ 27068e8e04eSSam Leffler uint8_t se_ssid[2+IEEE80211_NWID_LEN]; 27168e8e04eSSam Leffler uint8_t se_rates[2+IEEE80211_RATE_MAXSIZE]; 27268e8e04eSSam Leffler uint8_t se_xrates[2+IEEE80211_RATE_MAXSIZE]; 27368e8e04eSSam Leffler union { 27468e8e04eSSam Leffler uint8_t data[8]; 275b032f27cSSam Leffler u_int64_t tsf; 27668e8e04eSSam Leffler } se_tstamp; /* from last rcv'd beacon */ 27768e8e04eSSam Leffler uint16_t se_intval; /* beacon interval (host byte order) */ 27868e8e04eSSam Leffler uint16_t se_capinfo; /* capabilities (host byte order) */ 27968e8e04eSSam Leffler struct ieee80211_channel *se_chan;/* channel where sta found */ 28068e8e04eSSam Leffler uint16_t se_timoff; /* byte offset to TIM ie */ 28168e8e04eSSam Leffler uint16_t se_fhdwell; /* FH only (host byte order) */ 28268e8e04eSSam Leffler uint8_t se_fhindex; /* FH only */ 283b032f27cSSam Leffler uint8_t se_dtimperiod; /* DTIM period */ 284b032f27cSSam Leffler uint16_t se_erp; /* ERP from beacon/probe resp */ 28568e8e04eSSam Leffler int8_t se_rssi; /* avg'd recv ssi */ 28668e8e04eSSam Leffler int8_t se_noise; /* noise floor */ 287b032f27cSSam Leffler uint8_t se_cc[2]; /* captured country code */ 28859aa14a9SRui Paulo uint8_t se_meshid[2+IEEE80211_MESHID_LEN]; 289b032f27cSSam Leffler struct ieee80211_ies se_ies; /* captured ie's */ 29068e8e04eSSam Leffler u_int se_age; /* age of entry (0 on create) */ 29168e8e04eSSam Leffler }; 29268e8e04eSSam Leffler MALLOC_DECLARE(M_80211_SCAN); 29368e8e04eSSam Leffler 29468e8e04eSSam Leffler /* 29568e8e04eSSam Leffler * Template for an in-kernel scan policy module. 29668e8e04eSSam Leffler * Modules register with the scanning code and are 29768e8e04eSSam Leffler * typically loaded as needed. 29868e8e04eSSam Leffler */ 29968e8e04eSSam Leffler struct ieee80211_scanner { 30068e8e04eSSam Leffler const char *scan_name; /* printable name */ 30168e8e04eSSam Leffler int (*scan_attach)(struct ieee80211_scan_state *); 30268e8e04eSSam Leffler int (*scan_detach)(struct ieee80211_scan_state *); 30368e8e04eSSam Leffler int (*scan_start)(struct ieee80211_scan_state *, 304b032f27cSSam Leffler struct ieee80211vap *); 30568e8e04eSSam Leffler int (*scan_restart)(struct ieee80211_scan_state *, 306b032f27cSSam Leffler struct ieee80211vap *); 30768e8e04eSSam Leffler int (*scan_cancel)(struct ieee80211_scan_state *, 308b032f27cSSam Leffler struct ieee80211vap *); 30968e8e04eSSam Leffler int (*scan_end)(struct ieee80211_scan_state *, 310b032f27cSSam Leffler struct ieee80211vap *); 31168e8e04eSSam Leffler int (*scan_flush)(struct ieee80211_scan_state *); 312b032f27cSSam Leffler struct ieee80211_channel *(*scan_pickchan)( 313b032f27cSSam Leffler struct ieee80211_scan_state *, int); 31468e8e04eSSam Leffler /* add an entry to the cache */ 31568e8e04eSSam Leffler int (*scan_add)(struct ieee80211_scan_state *, 3162808a02bSAdrian Chadd struct ieee80211_channel *, 31768e8e04eSSam Leffler const struct ieee80211_scanparams *, 31868e8e04eSSam Leffler const struct ieee80211_frame *, 3195463c4a4SSam Leffler int subtype, int rssi, int noise); 32068e8e04eSSam Leffler /* age and/or purge entries in the cache */ 32168e8e04eSSam Leffler void (*scan_age)(struct ieee80211_scan_state *); 32268e8e04eSSam Leffler /* note that association failed for an entry */ 32368e8e04eSSam Leffler void (*scan_assoc_fail)(struct ieee80211_scan_state *, 32468e8e04eSSam Leffler const uint8_t macaddr[IEEE80211_ADDR_LEN], 32568e8e04eSSam Leffler int reason); 32668e8e04eSSam Leffler /* note that association succeed for an entry */ 32768e8e04eSSam Leffler void (*scan_assoc_success)(struct ieee80211_scan_state *, 32868e8e04eSSam Leffler const uint8_t macaddr[IEEE80211_ADDR_LEN]); 32968e8e04eSSam Leffler /* iterate over entries in the scan cache */ 33068e8e04eSSam Leffler void (*scan_iterate)(struct ieee80211_scan_state *, 33168e8e04eSSam Leffler ieee80211_scan_iter_func *, void *); 332a43cee70SSam Leffler void (*scan_spare0)(void); 333a43cee70SSam Leffler void (*scan_spare1)(void); 334a43cee70SSam Leffler void (*scan_spare2)(void); 33533396ec2SBjoern A. Zeeb void (*scan_spare3)(void); 33668e8e04eSSam Leffler }; 33768e8e04eSSam Leffler void ieee80211_scanner_register(enum ieee80211_opmode, 33868e8e04eSSam Leffler const struct ieee80211_scanner *); 33968e8e04eSSam Leffler void ieee80211_scanner_unregister(enum ieee80211_opmode, 34068e8e04eSSam Leffler const struct ieee80211_scanner *); 34168e8e04eSSam Leffler void ieee80211_scanner_unregister_all(const struct ieee80211_scanner *); 34268e8e04eSSam Leffler const struct ieee80211_scanner *ieee80211_scanner_get(enum ieee80211_opmode); 343cc6dd788SAdrian Chadd void ieee80211_scan_update_locked(struct ieee80211vap *vap, 344cc6dd788SAdrian Chadd const struct ieee80211_scanner *scan); 345cc6dd788SAdrian Chadd void ieee80211_scan_copy_ssid(struct ieee80211vap *vap, 346cc6dd788SAdrian Chadd struct ieee80211_scan_state *ss, 347cc6dd788SAdrian Chadd int nssid, const struct ieee80211_scan_ssid ssids[]); 348cc6dd788SAdrian Chadd void ieee80211_scan_dump_probe_beacon(uint8_t subtype, int isnew, 349cc6dd788SAdrian Chadd const uint8_t mac[IEEE80211_ADDR_LEN], 350cc6dd788SAdrian Chadd const struct ieee80211_scanparams *sp, int rssi); 351cc6dd788SAdrian Chadd void ieee80211_scan_dump(struct ieee80211_scan_state *ss); 352cc6dd788SAdrian Chadd 35368e8e04eSSam Leffler #endif /* _NET80211_IEEE80211_SCAN_H_ */ 354