1753c7e08SAugustin Cavalier /*- 2*8244a9baSAugustin Cavalier * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3*8244a9baSAugustin Cavalier * 4753c7e08SAugustin Cavalier * Copyright (c) 2005-2009 Sam Leffler, Errno Consulting 5753c7e08SAugustin Cavalier * All rights reserved. 6753c7e08SAugustin Cavalier * 7753c7e08SAugustin Cavalier * Redistribution and use in source and binary forms, with or without 8753c7e08SAugustin Cavalier * modification, are permitted provided that the following conditions 9753c7e08SAugustin Cavalier * are met: 10753c7e08SAugustin Cavalier * 1. Redistributions of source code must retain the above copyright 11753c7e08SAugustin Cavalier * notice, this list of conditions and the following disclaimer. 12753c7e08SAugustin Cavalier * 2. Redistributions in binary form must reproduce the above copyright 13753c7e08SAugustin Cavalier * notice, this list of conditions and the following disclaimer in the 14753c7e08SAugustin Cavalier * documentation and/or other materials provided with the distribution. 15753c7e08SAugustin Cavalier * 16753c7e08SAugustin Cavalier * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17753c7e08SAugustin Cavalier * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18753c7e08SAugustin Cavalier * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19753c7e08SAugustin Cavalier * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20753c7e08SAugustin Cavalier * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21753c7e08SAugustin Cavalier * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22753c7e08SAugustin Cavalier * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23753c7e08SAugustin Cavalier * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24753c7e08SAugustin Cavalier * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25753c7e08SAugustin Cavalier * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26753c7e08SAugustin Cavalier * 27*8244a9baSAugustin Cavalier * $FreeBSD: releng/12.0/sys/net80211/ieee80211_scan.h 326272 2017-11-27 15:23:17Z pfg $ 28753c7e08SAugustin Cavalier */ 29753c7e08SAugustin Cavalier #ifndef _NET80211_IEEE80211_SCAN_H_ 30753c7e08SAugustin Cavalier #define _NET80211_IEEE80211_SCAN_H_ 31753c7e08SAugustin Cavalier 32753c7e08SAugustin Cavalier /* 33753c7e08SAugustin Cavalier * 802.11 scanning support. 34753c7e08SAugustin Cavalier * 35753c7e08SAugustin Cavalier * Scanning is the procedure by which a station locates a bss to join 36753c7e08SAugustin Cavalier * (infrastructure/ibss mode), or a channel to use (when operating as 37753c7e08SAugustin Cavalier * an ap or ibss master). Scans are either "active" or "passive". An 38753c7e08SAugustin Cavalier * active scan causes one or more probe request frames to be sent on 39753c7e08SAugustin Cavalier * visiting each channel. A passive request causes each channel in the 40753c7e08SAugustin Cavalier * scan set to be visited but no frames to be transmitted; the station 41753c7e08SAugustin Cavalier * only listens for traffic. Note that active scanning may still need 42753c7e08SAugustin Cavalier * to listen for traffic before sending probe request frames depending 43753c7e08SAugustin Cavalier * on regulatory constraints; the 802.11 layer handles this by generating 44753c7e08SAugustin Cavalier * a callback when scanning on a ``passive channel'' when the 45753c7e08SAugustin Cavalier * IEEE80211_FEXT_PROBECHAN flag is set. 46753c7e08SAugustin Cavalier * 47753c7e08SAugustin Cavalier * A scan operation involves constructing a set of channels to inspect 48753c7e08SAugustin Cavalier * (the scan set), visiting each channel and collecting information 49753c7e08SAugustin Cavalier * (e.g. what bss are present), and then analyzing the results to make 50753c7e08SAugustin Cavalier * decisions like which bss to join. This process needs to be as fast 51753c7e08SAugustin Cavalier * as possible so we do things like intelligently construct scan sets 52753c7e08SAugustin Cavalier * and dwell on a channel only as long as necessary. The scan code also 53753c7e08SAugustin Cavalier * maintains a cache of recent scan results and uses it to bypass scanning 54753c7e08SAugustin Cavalier * whenever possible. The scan cache is also used to enable roaming 55753c7e08SAugustin Cavalier * between access points when operating in infrastructure mode. 56753c7e08SAugustin Cavalier * 57753c7e08SAugustin Cavalier * Scanning is handled with pluggable modules that implement "policy" 58753c7e08SAugustin Cavalier * per-operating mode. The core scanning support provides an 59753c7e08SAugustin Cavalier * instrastructure to support these modules and exports a common api 60753c7e08SAugustin Cavalier * to the rest of the 802.11 layer. Policy modules decide what 61753c7e08SAugustin Cavalier * channels to visit, what state to record to make decisions (e.g. ap 62753c7e08SAugustin Cavalier * mode scanning for auto channel selection keeps significantly less 63753c7e08SAugustin Cavalier * state than sta mode scanning for an ap to associate to), and selects 64753c7e08SAugustin Cavalier * the final station/channel to return as the result of a scan. 65753c7e08SAugustin Cavalier * 66753c7e08SAugustin Cavalier * Scanning is done synchronously when initially bringing a vap to an 67753c7e08SAugustin Cavalier * operational state and optionally in the background to maintain the 68753c7e08SAugustin Cavalier * scan cache for doing roaming and rogue ap monitoring. Scanning is 69753c7e08SAugustin Cavalier * not tied to the 802.11 state machine that governs vaps though there 70753c7e08SAugustin Cavalier * is linkage to the IEEE80211_SCAN state. Only one vap at a time may 71753c7e08SAugustin Cavalier * be scanning; this scheduling policy is handled in ieee80211_new_state 72753c7e08SAugustin Cavalier * and is invisible to the scanning code. 73753c7e08SAugustin Cavalier */ 74753c7e08SAugustin Cavalier #define IEEE80211_SCAN_MAX IEEE80211_CHAN_MAX 75753c7e08SAugustin Cavalier 76753c7e08SAugustin Cavalier struct ieee80211_scanner; /* scan policy state */ 77753c7e08SAugustin Cavalier 78753c7e08SAugustin Cavalier struct ieee80211_scan_ssid { 79753c7e08SAugustin Cavalier int len; /* length in bytes */ 80753c7e08SAugustin Cavalier uint8_t ssid[IEEE80211_NWID_LEN]; /* ssid contents */ 81753c7e08SAugustin Cavalier }; 82753c7e08SAugustin Cavalier #define IEEE80211_SCAN_MAX_SSID 1 /* max # ssid's to probe */ 83753c7e08SAugustin Cavalier 84753c7e08SAugustin Cavalier /* 85753c7e08SAugustin Cavalier * High-level implementation visible to ieee80211_scan.[ch]. 86753c7e08SAugustin Cavalier * 87753c7e08SAugustin Cavalier * The default scanner (ieee80211_scan_sw.[ch]) implements a software 88753c7e08SAugustin Cavalier * driven scanner. Firmware driven scanning needs a different set of 89753c7e08SAugustin Cavalier * behaviours. 90753c7e08SAugustin Cavalier */ 91753c7e08SAugustin Cavalier struct ieee80211_scan_methods { 92753c7e08SAugustin Cavalier void (*sc_attach)(struct ieee80211com *); 93753c7e08SAugustin Cavalier void (*sc_detach)(struct ieee80211com *); 94753c7e08SAugustin Cavalier void (*sc_vattach)(struct ieee80211vap *); 95753c7e08SAugustin Cavalier void (*sc_vdetach)(struct ieee80211vap *); 96753c7e08SAugustin Cavalier void (*sc_set_scan_duration)(struct ieee80211vap *, u_int); 97753c7e08SAugustin Cavalier int (*sc_start_scan)(const struct ieee80211_scanner *, 98753c7e08SAugustin Cavalier struct ieee80211vap *, int, u_int, u_int, u_int, u_int, 99753c7e08SAugustin Cavalier const struct ieee80211_scan_ssid ssids[]); 100753c7e08SAugustin Cavalier int (*sc_check_scan)(const struct ieee80211_scanner *, 101753c7e08SAugustin Cavalier struct ieee80211vap *, int, u_int, u_int, u_int, u_int, 102753c7e08SAugustin Cavalier const struct ieee80211_scan_ssid ssids[]); 103753c7e08SAugustin Cavalier int (*sc_bg_scan)(const struct ieee80211_scanner *, 104753c7e08SAugustin Cavalier struct ieee80211vap *, int); 105753c7e08SAugustin Cavalier void (*sc_cancel_scan)(struct ieee80211vap *); 106753c7e08SAugustin Cavalier void (*sc_cancel_anyscan)(struct ieee80211vap *); 107753c7e08SAugustin Cavalier void (*sc_scan_next)(struct ieee80211vap *); 108753c7e08SAugustin Cavalier void (*sc_scan_done)(struct ieee80211vap *); 109753c7e08SAugustin Cavalier void (*sc_scan_probe_curchan)(struct ieee80211vap *, int); 110753c7e08SAugustin Cavalier void (*sc_add_scan)(struct ieee80211vap *, 111753c7e08SAugustin Cavalier struct ieee80211_channel *, 112753c7e08SAugustin Cavalier const struct ieee80211_scanparams *, 113753c7e08SAugustin Cavalier const struct ieee80211_frame *, 114753c7e08SAugustin Cavalier int, int, int); 115753c7e08SAugustin Cavalier }; 116753c7e08SAugustin Cavalier 117753c7e08SAugustin Cavalier /* 118753c7e08SAugustin Cavalier * Scan state visible to the 802.11 layer. Scan parameters and 119753c7e08SAugustin Cavalier * results are stored in this data structure. The ieee80211_scan_state 120753c7e08SAugustin Cavalier * structure is extended with space that is maintained private to 121753c7e08SAugustin Cavalier * the core scanning support. We allocate one instance and link it 122753c7e08SAugustin Cavalier * to the ieee80211com structure; then share it between all associated 123753c7e08SAugustin Cavalier * vaps. We could allocate multiple of these, e.g. to hold multiple 124753c7e08SAugustin Cavalier * scan results, but this is sufficient for current needs. 125753c7e08SAugustin Cavalier */ 126753c7e08SAugustin Cavalier struct ieee80211_scan_state { 127753c7e08SAugustin Cavalier struct ieee80211vap *ss_vap; 128753c7e08SAugustin Cavalier struct ieee80211com *ss_ic; 129753c7e08SAugustin Cavalier const struct ieee80211_scanner *ss_ops; /* policy hookup, see below */ 130753c7e08SAugustin Cavalier void *ss_priv; /* scanner private state */ 131753c7e08SAugustin Cavalier uint16_t ss_flags; 132753c7e08SAugustin Cavalier #define IEEE80211_SCAN_NOPICK 0x0001 /* scan only, no selection */ 133753c7e08SAugustin Cavalier #define IEEE80211_SCAN_ACTIVE 0x0002 /* active scan (probe req) */ 134753c7e08SAugustin Cavalier #define IEEE80211_SCAN_PICK1ST 0x0004 /* ``hey sailor'' mode */ 135753c7e08SAugustin Cavalier #define IEEE80211_SCAN_BGSCAN 0x0008 /* bg scan, exit ps at end */ 136753c7e08SAugustin Cavalier #define IEEE80211_SCAN_ONCE 0x0010 /* do one complete pass */ 137753c7e08SAugustin Cavalier #define IEEE80211_SCAN_NOBCAST 0x0020 /* no broadcast probe req */ 138753c7e08SAugustin Cavalier #define IEEE80211_SCAN_NOJOIN 0x0040 /* no auto-sequencing */ 139753c7e08SAugustin Cavalier #define IEEE80211_SCAN_GOTPICK 0x1000 /* got candidate, can stop */ 140753c7e08SAugustin Cavalier uint8_t ss_nssid; /* # ssid's to probe/match */ 141753c7e08SAugustin Cavalier struct ieee80211_scan_ssid ss_ssid[IEEE80211_SCAN_MAX_SSID]; 142753c7e08SAugustin Cavalier /* ssid's to probe/match */ 143753c7e08SAugustin Cavalier /* ordered channel set */ 144753c7e08SAugustin Cavalier struct ieee80211_channel *ss_chans[IEEE80211_SCAN_MAX]; 145753c7e08SAugustin Cavalier uint16_t ss_next; /* ix of next chan to scan */ 146753c7e08SAugustin Cavalier uint16_t ss_last; /* ix+1 of last chan to scan */ 147753c7e08SAugustin Cavalier unsigned long ss_mindwell; /* min dwell on channel */ 148753c7e08SAugustin Cavalier unsigned long ss_maxdwell; /* max dwell on channel */ 149753c7e08SAugustin Cavalier }; 150753c7e08SAugustin Cavalier 151753c7e08SAugustin Cavalier /* 152753c7e08SAugustin Cavalier * The upper 16 bits of the flags word is used to communicate 153753c7e08SAugustin Cavalier * information to the scanning code that is NOT recorded in 154753c7e08SAugustin Cavalier * ss_flags. It might be better to split this stuff out into 155753c7e08SAugustin Cavalier * a separate variable to avoid confusion. 156753c7e08SAugustin Cavalier */ 157753c7e08SAugustin Cavalier #define IEEE80211_SCAN_FLUSH 0x00010000 /* flush candidate table */ 158753c7e08SAugustin Cavalier #define IEEE80211_SCAN_NOSSID 0x80000000 /* don't update ssid list */ 159753c7e08SAugustin Cavalier 160753c7e08SAugustin Cavalier struct ieee80211com; 161753c7e08SAugustin Cavalier void ieee80211_scan_attach(struct ieee80211com *); 162753c7e08SAugustin Cavalier void ieee80211_scan_detach(struct ieee80211com *); 163753c7e08SAugustin Cavalier void ieee80211_scan_vattach(struct ieee80211vap *); 164753c7e08SAugustin Cavalier void ieee80211_scan_vdetach(struct ieee80211vap *); 165753c7e08SAugustin Cavalier 166753c7e08SAugustin Cavalier void ieee80211_scan_dump_channels(const struct ieee80211_scan_state *); 167753c7e08SAugustin Cavalier 168753c7e08SAugustin Cavalier #define IEEE80211_SCAN_FOREVER 0x7fffffff 169753c7e08SAugustin Cavalier int ieee80211_start_scan(struct ieee80211vap *, int flags, 170753c7e08SAugustin Cavalier u_int duration, u_int mindwell, u_int maxdwell, 171753c7e08SAugustin Cavalier u_int nssid, const struct ieee80211_scan_ssid ssids[]); 172753c7e08SAugustin Cavalier int ieee80211_check_scan(struct ieee80211vap *, int flags, 173753c7e08SAugustin Cavalier u_int duration, u_int mindwell, u_int maxdwell, 174753c7e08SAugustin Cavalier u_int nssid, const struct ieee80211_scan_ssid ssids[]); 175753c7e08SAugustin Cavalier int ieee80211_check_scan_current(struct ieee80211vap *); 176753c7e08SAugustin Cavalier int ieee80211_bg_scan(struct ieee80211vap *, int); 177753c7e08SAugustin Cavalier void ieee80211_cancel_scan(struct ieee80211vap *); 178753c7e08SAugustin Cavalier void ieee80211_cancel_anyscan(struct ieee80211vap *); 179753c7e08SAugustin Cavalier void ieee80211_scan_next(struct ieee80211vap *); 180753c7e08SAugustin Cavalier void ieee80211_scan_done(struct ieee80211vap *); 181753c7e08SAugustin Cavalier void ieee80211_probe_curchan(struct ieee80211vap *, int); 182753c7e08SAugustin Cavalier struct ieee80211_channel *ieee80211_scan_pickchannel(struct ieee80211com *, int); 183753c7e08SAugustin Cavalier 184753c7e08SAugustin Cavalier struct ieee80211_scanparams; 185753c7e08SAugustin Cavalier void ieee80211_add_scan(struct ieee80211vap *, 186753c7e08SAugustin Cavalier struct ieee80211_channel *, 187753c7e08SAugustin Cavalier const struct ieee80211_scanparams *, 188753c7e08SAugustin Cavalier const struct ieee80211_frame *, 189753c7e08SAugustin Cavalier int subtype, int rssi, int noise); 190753c7e08SAugustin Cavalier void ieee80211_scan_timeout(struct ieee80211com *); 191753c7e08SAugustin Cavalier 192753c7e08SAugustin Cavalier void ieee80211_scan_assoc_success(struct ieee80211vap *, 193753c7e08SAugustin Cavalier const uint8_t mac[IEEE80211_ADDR_LEN]); 194753c7e08SAugustin Cavalier enum { 195753c7e08SAugustin Cavalier IEEE80211_SCAN_FAIL_TIMEOUT = 1, /* no response to mgmt frame */ 196753c7e08SAugustin Cavalier IEEE80211_SCAN_FAIL_STATUS = 2 /* negative response to " " */ 197753c7e08SAugustin Cavalier }; 198753c7e08SAugustin Cavalier void ieee80211_scan_assoc_fail(struct ieee80211vap *, 199753c7e08SAugustin Cavalier const uint8_t mac[IEEE80211_ADDR_LEN], int reason); 200753c7e08SAugustin Cavalier void ieee80211_scan_flush(struct ieee80211vap *); 201753c7e08SAugustin Cavalier 202753c7e08SAugustin Cavalier struct ieee80211_scan_entry; 203753c7e08SAugustin Cavalier typedef void ieee80211_scan_iter_func(void *, 204753c7e08SAugustin Cavalier const struct ieee80211_scan_entry *); 205753c7e08SAugustin Cavalier void ieee80211_scan_iterate(struct ieee80211vap *, 206753c7e08SAugustin Cavalier ieee80211_scan_iter_func, void *); 207753c7e08SAugustin Cavalier enum { 208753c7e08SAugustin Cavalier IEEE80211_BPARSE_BADIELEN = 0x01, /* ie len past end of frame */ 209753c7e08SAugustin Cavalier IEEE80211_BPARSE_RATES_INVALID = 0x02, /* invalid RATES ie */ 210753c7e08SAugustin Cavalier IEEE80211_BPARSE_XRATES_INVALID = 0x04, /* invalid XRATES ie */ 211753c7e08SAugustin Cavalier IEEE80211_BPARSE_SSID_INVALID = 0x08, /* invalid SSID ie */ 212753c7e08SAugustin Cavalier IEEE80211_BPARSE_CHAN_INVALID = 0x10, /* invalid FH/DSPARMS chan */ 213753c7e08SAugustin Cavalier IEEE80211_BPARSE_OFFCHAN = 0x20, /* DSPARMS chan != curchan */ 214753c7e08SAugustin Cavalier IEEE80211_BPARSE_BINTVAL_INVALID= 0x40, /* invalid beacon interval */ 215753c7e08SAugustin Cavalier IEEE80211_BPARSE_CSA_INVALID = 0x80, /* invalid CSA ie */ 216753c7e08SAugustin Cavalier }; 217753c7e08SAugustin Cavalier 218753c7e08SAugustin Cavalier /* 219753c7e08SAugustin Cavalier * Parameters supplied when adding/updating an entry in a 220753c7e08SAugustin Cavalier * scan cache. Pointer variables should be set to NULL 221753c7e08SAugustin Cavalier * if no data is available. Pointer references can be to 222753c7e08SAugustin Cavalier * local data; any information that is saved will be copied. 223753c7e08SAugustin Cavalier * All multi-byte values must be in host byte order. 224753c7e08SAugustin Cavalier */ 225753c7e08SAugustin Cavalier struct ieee80211_scanparams { 226753c7e08SAugustin Cavalier uint8_t status; /* bitmask of IEEE80211_BPARSE_* */ 227753c7e08SAugustin Cavalier uint8_t chan; /* channel # from FH/DSPARMS */ 228753c7e08SAugustin Cavalier uint8_t bchan; /* curchan's channel # */ 229753c7e08SAugustin Cavalier uint8_t fhindex; 230753c7e08SAugustin Cavalier uint16_t fhdwell; /* FHSS dwell interval */ 231753c7e08SAugustin Cavalier uint16_t capinfo; /* 802.11 capabilities */ 232753c7e08SAugustin Cavalier uint16_t erp; /* NB: 0x100 indicates ie present */ 233753c7e08SAugustin Cavalier uint16_t bintval; 234753c7e08SAugustin Cavalier uint8_t timoff; 235753c7e08SAugustin Cavalier uint8_t *ies; /* all captured ies */ 236753c7e08SAugustin Cavalier size_t ies_len; /* length of all captured ies */ 237753c7e08SAugustin Cavalier uint8_t *tim; 238753c7e08SAugustin Cavalier uint8_t *tstamp; 239753c7e08SAugustin Cavalier uint8_t *country; 240753c7e08SAugustin Cavalier uint8_t *ssid; 241753c7e08SAugustin Cavalier uint8_t *rates; 242753c7e08SAugustin Cavalier uint8_t *xrates; 243753c7e08SAugustin Cavalier uint8_t *doth; 244753c7e08SAugustin Cavalier uint8_t *wpa; 245753c7e08SAugustin Cavalier uint8_t *rsn; 246753c7e08SAugustin Cavalier uint8_t *wme; 247753c7e08SAugustin Cavalier uint8_t *htcap; 248753c7e08SAugustin Cavalier uint8_t *htinfo; 249753c7e08SAugustin Cavalier uint8_t *ath; 250753c7e08SAugustin Cavalier uint8_t *tdma; 251753c7e08SAugustin Cavalier uint8_t *csa; 252753c7e08SAugustin Cavalier uint8_t *quiet; 253753c7e08SAugustin Cavalier uint8_t *meshid; 254753c7e08SAugustin Cavalier uint8_t *meshconf; 255*8244a9baSAugustin Cavalier uint8_t *vhtcap; 256*8244a9baSAugustin Cavalier uint8_t *vhtopmode; 257*8244a9baSAugustin Cavalier uint8_t *spare[1]; 258753c7e08SAugustin Cavalier }; 259753c7e08SAugustin Cavalier 260753c7e08SAugustin Cavalier /* 261753c7e08SAugustin Cavalier * Scan cache entry format used when exporting data from a policy 262753c7e08SAugustin Cavalier * module; this data may be represented some other way internally. 263753c7e08SAugustin Cavalier */ 264753c7e08SAugustin Cavalier struct ieee80211_scan_entry { 265753c7e08SAugustin Cavalier uint8_t se_macaddr[IEEE80211_ADDR_LEN]; 266753c7e08SAugustin Cavalier uint8_t se_bssid[IEEE80211_ADDR_LEN]; 267753c7e08SAugustin Cavalier /* XXX can point inside se_ies */ 268753c7e08SAugustin Cavalier uint8_t se_ssid[2+IEEE80211_NWID_LEN]; 269753c7e08SAugustin Cavalier uint8_t se_rates[2+IEEE80211_RATE_MAXSIZE]; 270753c7e08SAugustin Cavalier uint8_t se_xrates[2+IEEE80211_RATE_MAXSIZE]; 271753c7e08SAugustin Cavalier union { 272753c7e08SAugustin Cavalier uint8_t data[8]; 273753c7e08SAugustin Cavalier u_int64_t tsf; 274753c7e08SAugustin Cavalier } se_tstamp; /* from last rcv'd beacon */ 275753c7e08SAugustin Cavalier uint16_t se_intval; /* beacon interval (host byte order) */ 276753c7e08SAugustin Cavalier uint16_t se_capinfo; /* capabilities (host byte order) */ 277753c7e08SAugustin Cavalier struct ieee80211_channel *se_chan;/* channel where sta found */ 278753c7e08SAugustin Cavalier uint16_t se_timoff; /* byte offset to TIM ie */ 279753c7e08SAugustin Cavalier uint16_t se_fhdwell; /* FH only (host byte order) */ 280753c7e08SAugustin Cavalier uint8_t se_fhindex; /* FH only */ 281753c7e08SAugustin Cavalier uint8_t se_dtimperiod; /* DTIM period */ 282753c7e08SAugustin Cavalier uint16_t se_erp; /* ERP from beacon/probe resp */ 283753c7e08SAugustin Cavalier int8_t se_rssi; /* avg'd recv ssi */ 284753c7e08SAugustin Cavalier int8_t se_noise; /* noise floor */ 285753c7e08SAugustin Cavalier uint8_t se_cc[2]; /* captured country code */ 286753c7e08SAugustin Cavalier uint8_t se_meshid[2+IEEE80211_MESHID_LEN]; 287753c7e08SAugustin Cavalier struct ieee80211_ies se_ies; /* captured ie's */ 288753c7e08SAugustin Cavalier u_int se_age; /* age of entry (0 on create) */ 289753c7e08SAugustin Cavalier }; 290753c7e08SAugustin Cavalier MALLOC_DECLARE(M_80211_SCAN); 291753c7e08SAugustin Cavalier 292753c7e08SAugustin Cavalier /* 293753c7e08SAugustin Cavalier * Template for an in-kernel scan policy module. 294753c7e08SAugustin Cavalier * Modules register with the scanning code and are 295753c7e08SAugustin Cavalier * typically loaded as needed. 296753c7e08SAugustin Cavalier */ 297753c7e08SAugustin Cavalier struct ieee80211_scanner { 298753c7e08SAugustin Cavalier const char *scan_name; /* printable name */ 299753c7e08SAugustin Cavalier int (*scan_attach)(struct ieee80211_scan_state *); 300753c7e08SAugustin Cavalier int (*scan_detach)(struct ieee80211_scan_state *); 301753c7e08SAugustin Cavalier int (*scan_start)(struct ieee80211_scan_state *, 302753c7e08SAugustin Cavalier struct ieee80211vap *); 303753c7e08SAugustin Cavalier int (*scan_restart)(struct ieee80211_scan_state *, 304753c7e08SAugustin Cavalier struct ieee80211vap *); 305753c7e08SAugustin Cavalier int (*scan_cancel)(struct ieee80211_scan_state *, 306753c7e08SAugustin Cavalier struct ieee80211vap *); 307753c7e08SAugustin Cavalier int (*scan_end)(struct ieee80211_scan_state *, 308753c7e08SAugustin Cavalier struct ieee80211vap *); 309753c7e08SAugustin Cavalier int (*scan_flush)(struct ieee80211_scan_state *); 310753c7e08SAugustin Cavalier struct ieee80211_channel *(*scan_pickchan)( 311753c7e08SAugustin Cavalier struct ieee80211_scan_state *, int); 312753c7e08SAugustin Cavalier /* add an entry to the cache */ 313753c7e08SAugustin Cavalier int (*scan_add)(struct ieee80211_scan_state *, 314753c7e08SAugustin Cavalier struct ieee80211_channel *, 315753c7e08SAugustin Cavalier const struct ieee80211_scanparams *, 316753c7e08SAugustin Cavalier const struct ieee80211_frame *, 317753c7e08SAugustin Cavalier int subtype, int rssi, int noise); 318753c7e08SAugustin Cavalier /* age and/or purge entries in the cache */ 319753c7e08SAugustin Cavalier void (*scan_age)(struct ieee80211_scan_state *); 320753c7e08SAugustin Cavalier /* note that association failed for an entry */ 321753c7e08SAugustin Cavalier void (*scan_assoc_fail)(struct ieee80211_scan_state *, 322753c7e08SAugustin Cavalier const uint8_t macaddr[IEEE80211_ADDR_LEN], 323753c7e08SAugustin Cavalier int reason); 324753c7e08SAugustin Cavalier /* note that association succeed for an entry */ 325753c7e08SAugustin Cavalier void (*scan_assoc_success)(struct ieee80211_scan_state *, 326753c7e08SAugustin Cavalier const uint8_t macaddr[IEEE80211_ADDR_LEN]); 327753c7e08SAugustin Cavalier /* iterate over entries in the scan cache */ 328753c7e08SAugustin Cavalier void (*scan_iterate)(struct ieee80211_scan_state *, 329753c7e08SAugustin Cavalier ieee80211_scan_iter_func *, void *); 330753c7e08SAugustin Cavalier void (*scan_spare0)(void); 331753c7e08SAugustin Cavalier void (*scan_spare1)(void); 332753c7e08SAugustin Cavalier void (*scan_spare2)(void); 333753c7e08SAugustin Cavalier void (*scan_spare4)(void); 334753c7e08SAugustin Cavalier }; 335753c7e08SAugustin Cavalier void ieee80211_scanner_register(enum ieee80211_opmode, 336753c7e08SAugustin Cavalier const struct ieee80211_scanner *); 337753c7e08SAugustin Cavalier void ieee80211_scanner_unregister(enum ieee80211_opmode, 338753c7e08SAugustin Cavalier const struct ieee80211_scanner *); 339753c7e08SAugustin Cavalier void ieee80211_scanner_unregister_all(const struct ieee80211_scanner *); 340753c7e08SAugustin Cavalier const struct ieee80211_scanner *ieee80211_scanner_get(enum ieee80211_opmode); 341753c7e08SAugustin Cavalier void ieee80211_scan_update_locked(struct ieee80211vap *vap, 342753c7e08SAugustin Cavalier const struct ieee80211_scanner *scan); 343753c7e08SAugustin Cavalier void ieee80211_scan_copy_ssid(struct ieee80211vap *vap, 344753c7e08SAugustin Cavalier struct ieee80211_scan_state *ss, 345753c7e08SAugustin Cavalier int nssid, const struct ieee80211_scan_ssid ssids[]); 346753c7e08SAugustin Cavalier void ieee80211_scan_dump_probe_beacon(uint8_t subtype, int isnew, 347753c7e08SAugustin Cavalier const uint8_t mac[IEEE80211_ADDR_LEN], 348753c7e08SAugustin Cavalier const struct ieee80211_scanparams *sp, int rssi); 349753c7e08SAugustin Cavalier void ieee80211_scan_dump(struct ieee80211_scan_state *ss); 350753c7e08SAugustin Cavalier 351753c7e08SAugustin Cavalier #endif /* _NET80211_IEEE80211_SCAN_H_ */ 352