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