xref: /haiku/src/libs/compat/freebsd_wlan/net80211/ieee80211_scan.h (revision 753c7e0805fa38e422339966ddc4d6d71944a040)
1*753c7e08SAugustin Cavalier /*-
2*753c7e08SAugustin Cavalier  * Copyright (c) 2005-2009 Sam Leffler, Errno Consulting
3*753c7e08SAugustin Cavalier  * All rights reserved.
4*753c7e08SAugustin Cavalier  *
5*753c7e08SAugustin Cavalier  * Redistribution and use in source and binary forms, with or without
6*753c7e08SAugustin Cavalier  * modification, are permitted provided that the following conditions
7*753c7e08SAugustin Cavalier  * are met:
8*753c7e08SAugustin Cavalier  * 1. Redistributions of source code must retain the above copyright
9*753c7e08SAugustin Cavalier  *    notice, this list of conditions and the following disclaimer.
10*753c7e08SAugustin Cavalier  * 2. Redistributions in binary form must reproduce the above copyright
11*753c7e08SAugustin Cavalier  *    notice, this list of conditions and the following disclaimer in the
12*753c7e08SAugustin Cavalier  *    documentation and/or other materials provided with the distribution.
13*753c7e08SAugustin Cavalier  *
14*753c7e08SAugustin Cavalier  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15*753c7e08SAugustin Cavalier  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16*753c7e08SAugustin Cavalier  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17*753c7e08SAugustin Cavalier  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18*753c7e08SAugustin Cavalier  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19*753c7e08SAugustin Cavalier  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20*753c7e08SAugustin Cavalier  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21*753c7e08SAugustin Cavalier  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22*753c7e08SAugustin Cavalier  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23*753c7e08SAugustin Cavalier  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24*753c7e08SAugustin Cavalier  *
25*753c7e08SAugustin Cavalier  * $FreeBSD: releng/11.1/sys/net80211/ieee80211_scan.h 284143 2015-06-08 02:35:43Z adrian $
26*753c7e08SAugustin Cavalier  */
27*753c7e08SAugustin Cavalier #ifndef _NET80211_IEEE80211_SCAN_H_
28*753c7e08SAugustin Cavalier #define _NET80211_IEEE80211_SCAN_H_
29*753c7e08SAugustin Cavalier 
30*753c7e08SAugustin Cavalier /*
31*753c7e08SAugustin Cavalier  * 802.11 scanning support.
32*753c7e08SAugustin Cavalier  *
33*753c7e08SAugustin Cavalier  * Scanning is the procedure by which a station locates a bss to join
34*753c7e08SAugustin Cavalier  * (infrastructure/ibss mode), or a channel to use (when operating as
35*753c7e08SAugustin Cavalier  * an ap or ibss master).  Scans are either "active" or "passive".  An
36*753c7e08SAugustin Cavalier  * active scan causes one or more probe request frames to be sent on
37*753c7e08SAugustin Cavalier  * visiting each channel.  A passive request causes each channel in the
38*753c7e08SAugustin Cavalier  * scan set to be visited but no frames to be transmitted; the station
39*753c7e08SAugustin Cavalier  * only listens for traffic.  Note that active scanning may still need
40*753c7e08SAugustin Cavalier  * to listen for traffic before sending probe request frames depending
41*753c7e08SAugustin Cavalier  * on regulatory constraints; the 802.11 layer handles this by generating
42*753c7e08SAugustin Cavalier  * a callback when scanning on a ``passive channel'' when the
43*753c7e08SAugustin Cavalier  * IEEE80211_FEXT_PROBECHAN flag is set.
44*753c7e08SAugustin Cavalier  *
45*753c7e08SAugustin Cavalier  * A scan operation involves constructing a set of channels to inspect
46*753c7e08SAugustin Cavalier  * (the scan set), visiting each channel and collecting information
47*753c7e08SAugustin Cavalier  * (e.g. what bss are present), and then analyzing the results to make
48*753c7e08SAugustin Cavalier  * decisions like which bss to join.  This process needs to be as fast
49*753c7e08SAugustin Cavalier  * as possible so we do things like intelligently construct scan sets
50*753c7e08SAugustin Cavalier  * and dwell on a channel only as long as necessary.  The scan code also
51*753c7e08SAugustin Cavalier  * maintains a cache of recent scan results and uses it to bypass scanning
52*753c7e08SAugustin Cavalier  * whenever possible.  The scan cache is also used to enable roaming
53*753c7e08SAugustin Cavalier  * between access points when operating in infrastructure mode.
54*753c7e08SAugustin Cavalier  *
55*753c7e08SAugustin Cavalier  * Scanning is handled with pluggable modules that implement "policy"
56*753c7e08SAugustin Cavalier  * per-operating mode.  The core scanning support provides an
57*753c7e08SAugustin Cavalier  * instrastructure to support these modules and exports a common api
58*753c7e08SAugustin Cavalier  * to the rest of the 802.11 layer.  Policy modules decide what
59*753c7e08SAugustin Cavalier  * channels to visit, what state to record to make decisions (e.g. ap
60*753c7e08SAugustin Cavalier  * mode scanning for auto channel selection keeps significantly less
61*753c7e08SAugustin Cavalier  * state than sta mode scanning for an ap to associate to), and selects
62*753c7e08SAugustin Cavalier  * the final station/channel to return as the result of a scan.
63*753c7e08SAugustin Cavalier  *
64*753c7e08SAugustin Cavalier  * Scanning is done synchronously when initially bringing a vap to an
65*753c7e08SAugustin Cavalier  * operational state and optionally in the background to maintain the
66*753c7e08SAugustin Cavalier  * scan cache for doing roaming and rogue ap monitoring.  Scanning is
67*753c7e08SAugustin Cavalier  * not tied to the 802.11 state machine that governs vaps though there
68*753c7e08SAugustin Cavalier  * is linkage to the IEEE80211_SCAN state.  Only one vap at a time may
69*753c7e08SAugustin Cavalier  * be scanning; this scheduling policy is handled in ieee80211_new_state
70*753c7e08SAugustin Cavalier  * and is invisible to the scanning code.
71*753c7e08SAugustin Cavalier */
72*753c7e08SAugustin Cavalier #define	IEEE80211_SCAN_MAX	IEEE80211_CHAN_MAX
73*753c7e08SAugustin Cavalier 
74*753c7e08SAugustin Cavalier struct ieee80211_scanner;			/* scan policy state */
75*753c7e08SAugustin Cavalier 
76*753c7e08SAugustin Cavalier struct ieee80211_scan_ssid {
77*753c7e08SAugustin Cavalier 	int	 len;				/* length in bytes */
78*753c7e08SAugustin Cavalier 	uint8_t ssid[IEEE80211_NWID_LEN];	/* ssid contents */
79*753c7e08SAugustin Cavalier };
80*753c7e08SAugustin Cavalier #define	IEEE80211_SCAN_MAX_SSID	1		/* max # ssid's to probe */
81*753c7e08SAugustin Cavalier 
82*753c7e08SAugustin Cavalier /*
83*753c7e08SAugustin Cavalier  * High-level implementation visible to ieee80211_scan.[ch].
84*753c7e08SAugustin Cavalier  *
85*753c7e08SAugustin Cavalier  * The default scanner (ieee80211_scan_sw.[ch]) implements a software
86*753c7e08SAugustin Cavalier  * driven scanner.  Firmware driven scanning needs a different set of
87*753c7e08SAugustin Cavalier  * behaviours.
88*753c7e08SAugustin Cavalier  */
89*753c7e08SAugustin Cavalier struct ieee80211_scan_methods {
90*753c7e08SAugustin Cavalier 	void (*sc_attach)(struct ieee80211com *);
91*753c7e08SAugustin Cavalier 	void (*sc_detach)(struct ieee80211com *);
92*753c7e08SAugustin Cavalier 	void (*sc_vattach)(struct ieee80211vap *);
93*753c7e08SAugustin Cavalier 	void (*sc_vdetach)(struct ieee80211vap *);
94*753c7e08SAugustin Cavalier 	void (*sc_set_scan_duration)(struct ieee80211vap *, u_int);
95*753c7e08SAugustin Cavalier 	int (*sc_start_scan)(const struct ieee80211_scanner *,
96*753c7e08SAugustin Cavalier 	    struct ieee80211vap *, int, u_int, u_int, u_int, u_int,
97*753c7e08SAugustin Cavalier 	    const struct ieee80211_scan_ssid ssids[]);
98*753c7e08SAugustin Cavalier 	int (*sc_check_scan)(const struct ieee80211_scanner *,
99*753c7e08SAugustin Cavalier 	    struct ieee80211vap *, int, u_int, u_int, u_int, u_int,
100*753c7e08SAugustin Cavalier 	    const struct ieee80211_scan_ssid ssids[]);
101*753c7e08SAugustin Cavalier 	int (*sc_bg_scan)(const struct ieee80211_scanner *,
102*753c7e08SAugustin Cavalier 	    struct ieee80211vap *, int);
103*753c7e08SAugustin Cavalier 	void (*sc_cancel_scan)(struct ieee80211vap *);
104*753c7e08SAugustin Cavalier 	void (*sc_cancel_anyscan)(struct ieee80211vap *);
105*753c7e08SAugustin Cavalier 	void (*sc_scan_next)(struct ieee80211vap *);
106*753c7e08SAugustin Cavalier 	void (*sc_scan_done)(struct ieee80211vap *);
107*753c7e08SAugustin Cavalier 	void (*sc_scan_probe_curchan)(struct ieee80211vap *, int);
108*753c7e08SAugustin Cavalier 	void (*sc_add_scan)(struct ieee80211vap *,
109*753c7e08SAugustin Cavalier 	    struct ieee80211_channel *,
110*753c7e08SAugustin Cavalier 	    const struct ieee80211_scanparams *,
111*753c7e08SAugustin Cavalier 	    const struct ieee80211_frame *,
112*753c7e08SAugustin Cavalier 	    int, int, int);
113*753c7e08SAugustin Cavalier };
114*753c7e08SAugustin Cavalier 
115*753c7e08SAugustin Cavalier /*
116*753c7e08SAugustin Cavalier  * Scan state visible to the 802.11 layer.  Scan parameters and
117*753c7e08SAugustin Cavalier  * results are stored in this data structure.  The ieee80211_scan_state
118*753c7e08SAugustin Cavalier  * structure is extended with space that is maintained private to
119*753c7e08SAugustin Cavalier  * the core scanning support.  We allocate one instance and link it
120*753c7e08SAugustin Cavalier  * to the ieee80211com structure; then share it between all associated
121*753c7e08SAugustin Cavalier  * vaps.  We could allocate multiple of these, e.g. to hold multiple
122*753c7e08SAugustin Cavalier  * scan results, but this is sufficient for current needs.
123*753c7e08SAugustin Cavalier  */
124*753c7e08SAugustin Cavalier struct ieee80211_scan_state {
125*753c7e08SAugustin Cavalier 	struct ieee80211vap *ss_vap;
126*753c7e08SAugustin Cavalier 	struct ieee80211com *ss_ic;
127*753c7e08SAugustin Cavalier 	const struct ieee80211_scanner *ss_ops;	/* policy hookup, see below */
128*753c7e08SAugustin Cavalier 	void		*ss_priv;		/* scanner private state */
129*753c7e08SAugustin Cavalier 	uint16_t	ss_flags;
130*753c7e08SAugustin Cavalier #define	IEEE80211_SCAN_NOPICK	0x0001		/* scan only, no selection */
131*753c7e08SAugustin Cavalier #define	IEEE80211_SCAN_ACTIVE	0x0002		/* active scan (probe req) */
132*753c7e08SAugustin Cavalier #define	IEEE80211_SCAN_PICK1ST	0x0004		/* ``hey sailor'' mode */
133*753c7e08SAugustin Cavalier #define	IEEE80211_SCAN_BGSCAN	0x0008		/* bg scan, exit ps at end */
134*753c7e08SAugustin Cavalier #define	IEEE80211_SCAN_ONCE	0x0010		/* do one complete pass */
135*753c7e08SAugustin Cavalier #define	IEEE80211_SCAN_NOBCAST	0x0020		/* no broadcast probe req */
136*753c7e08SAugustin Cavalier #define	IEEE80211_SCAN_NOJOIN	0x0040		/* no auto-sequencing */
137*753c7e08SAugustin Cavalier #define	IEEE80211_SCAN_GOTPICK	0x1000		/* got candidate, can stop */
138*753c7e08SAugustin Cavalier 	uint8_t		ss_nssid;		/* # ssid's to probe/match */
139*753c7e08SAugustin Cavalier 	struct ieee80211_scan_ssid ss_ssid[IEEE80211_SCAN_MAX_SSID];
140*753c7e08SAugustin Cavalier 						/* ssid's to probe/match */
141*753c7e08SAugustin Cavalier 						/* ordered channel set */
142*753c7e08SAugustin Cavalier 	struct ieee80211_channel *ss_chans[IEEE80211_SCAN_MAX];
143*753c7e08SAugustin Cavalier 	uint16_t	ss_next;		/* ix of next chan to scan */
144*753c7e08SAugustin Cavalier 	uint16_t	ss_last;		/* ix+1 of last chan to scan */
145*753c7e08SAugustin Cavalier 	unsigned long	ss_mindwell;		/* min dwell on channel */
146*753c7e08SAugustin Cavalier 	unsigned long	ss_maxdwell;		/* max dwell on channel */
147*753c7e08SAugustin Cavalier };
148*753c7e08SAugustin Cavalier 
149*753c7e08SAugustin Cavalier /*
150*753c7e08SAugustin Cavalier  * The upper 16 bits of the flags word is used to communicate
151*753c7e08SAugustin Cavalier  * information to the scanning code that is NOT recorded in
152*753c7e08SAugustin Cavalier  * ss_flags.  It might be better to split this stuff out into
153*753c7e08SAugustin Cavalier  * a separate variable to avoid confusion.
154*753c7e08SAugustin Cavalier  */
155*753c7e08SAugustin Cavalier #define	IEEE80211_SCAN_FLUSH	0x00010000	/* flush candidate table */
156*753c7e08SAugustin Cavalier #define	IEEE80211_SCAN_NOSSID	0x80000000	/* don't update ssid list */
157*753c7e08SAugustin Cavalier 
158*753c7e08SAugustin Cavalier struct ieee80211com;
159*753c7e08SAugustin Cavalier void	ieee80211_scan_attach(struct ieee80211com *);
160*753c7e08SAugustin Cavalier void	ieee80211_scan_detach(struct ieee80211com *);
161*753c7e08SAugustin Cavalier void	ieee80211_scan_vattach(struct ieee80211vap *);
162*753c7e08SAugustin Cavalier void	ieee80211_scan_vdetach(struct ieee80211vap *);
163*753c7e08SAugustin Cavalier 
164*753c7e08SAugustin Cavalier void	ieee80211_scan_dump_channels(const struct ieee80211_scan_state *);
165*753c7e08SAugustin Cavalier 
166*753c7e08SAugustin Cavalier #define	IEEE80211_SCAN_FOREVER	0x7fffffff
167*753c7e08SAugustin Cavalier int	ieee80211_start_scan(struct ieee80211vap *, int flags,
168*753c7e08SAugustin Cavalier 		u_int duration, u_int mindwell, u_int maxdwell,
169*753c7e08SAugustin Cavalier 		u_int nssid, const struct ieee80211_scan_ssid ssids[]);
170*753c7e08SAugustin Cavalier int	ieee80211_check_scan(struct ieee80211vap *, int flags,
171*753c7e08SAugustin Cavalier 		u_int duration, u_int mindwell, u_int maxdwell,
172*753c7e08SAugustin Cavalier 		u_int nssid, const struct ieee80211_scan_ssid ssids[]);
173*753c7e08SAugustin Cavalier int	ieee80211_check_scan_current(struct ieee80211vap *);
174*753c7e08SAugustin Cavalier int	ieee80211_bg_scan(struct ieee80211vap *, int);
175*753c7e08SAugustin Cavalier void	ieee80211_cancel_scan(struct ieee80211vap *);
176*753c7e08SAugustin Cavalier void	ieee80211_cancel_anyscan(struct ieee80211vap *);
177*753c7e08SAugustin Cavalier void	ieee80211_scan_next(struct ieee80211vap *);
178*753c7e08SAugustin Cavalier void	ieee80211_scan_done(struct ieee80211vap *);
179*753c7e08SAugustin Cavalier void	ieee80211_probe_curchan(struct ieee80211vap *, int);
180*753c7e08SAugustin Cavalier struct ieee80211_channel *ieee80211_scan_pickchannel(struct ieee80211com *, int);
181*753c7e08SAugustin Cavalier 
182*753c7e08SAugustin Cavalier struct ieee80211_scanparams;
183*753c7e08SAugustin Cavalier void	ieee80211_add_scan(struct ieee80211vap *,
184*753c7e08SAugustin Cavalier 		struct ieee80211_channel *,
185*753c7e08SAugustin Cavalier 		const struct ieee80211_scanparams *,
186*753c7e08SAugustin Cavalier 		const struct ieee80211_frame *,
187*753c7e08SAugustin Cavalier 		int subtype, int rssi, int noise);
188*753c7e08SAugustin Cavalier void	ieee80211_scan_timeout(struct ieee80211com *);
189*753c7e08SAugustin Cavalier 
190*753c7e08SAugustin Cavalier void	ieee80211_scan_assoc_success(struct ieee80211vap *,
191*753c7e08SAugustin Cavalier 		const uint8_t mac[IEEE80211_ADDR_LEN]);
192*753c7e08SAugustin Cavalier enum {
193*753c7e08SAugustin Cavalier 	IEEE80211_SCAN_FAIL_TIMEOUT	= 1,	/* no response to mgmt frame */
194*753c7e08SAugustin Cavalier 	IEEE80211_SCAN_FAIL_STATUS	= 2	/* negative response to " " */
195*753c7e08SAugustin Cavalier };
196*753c7e08SAugustin Cavalier void	ieee80211_scan_assoc_fail(struct ieee80211vap *,
197*753c7e08SAugustin Cavalier 		const uint8_t mac[IEEE80211_ADDR_LEN], int reason);
198*753c7e08SAugustin Cavalier void	ieee80211_scan_flush(struct ieee80211vap *);
199*753c7e08SAugustin Cavalier 
200*753c7e08SAugustin Cavalier struct ieee80211_scan_entry;
201*753c7e08SAugustin Cavalier typedef void ieee80211_scan_iter_func(void *,
202*753c7e08SAugustin Cavalier 		const struct ieee80211_scan_entry *);
203*753c7e08SAugustin Cavalier void	ieee80211_scan_iterate(struct ieee80211vap *,
204*753c7e08SAugustin Cavalier 		ieee80211_scan_iter_func, void *);
205*753c7e08SAugustin Cavalier enum {
206*753c7e08SAugustin Cavalier 	IEEE80211_BPARSE_BADIELEN	= 0x01,	/* ie len past end of frame */
207*753c7e08SAugustin Cavalier 	IEEE80211_BPARSE_RATES_INVALID	= 0x02,	/* invalid RATES ie */
208*753c7e08SAugustin Cavalier 	IEEE80211_BPARSE_XRATES_INVALID	= 0x04,	/* invalid XRATES ie */
209*753c7e08SAugustin Cavalier 	IEEE80211_BPARSE_SSID_INVALID	= 0x08,	/* invalid SSID ie */
210*753c7e08SAugustin Cavalier 	IEEE80211_BPARSE_CHAN_INVALID	= 0x10,	/* invalid FH/DSPARMS chan */
211*753c7e08SAugustin Cavalier 	IEEE80211_BPARSE_OFFCHAN	= 0x20,	/* DSPARMS chan != curchan */
212*753c7e08SAugustin Cavalier 	IEEE80211_BPARSE_BINTVAL_INVALID= 0x40,	/* invalid beacon interval */
213*753c7e08SAugustin Cavalier 	IEEE80211_BPARSE_CSA_INVALID	= 0x80,	/* invalid CSA ie */
214*753c7e08SAugustin Cavalier };
215*753c7e08SAugustin Cavalier 
216*753c7e08SAugustin Cavalier /*
217*753c7e08SAugustin Cavalier  * Parameters supplied when adding/updating an entry in a
218*753c7e08SAugustin Cavalier  * scan cache.  Pointer variables should be set to NULL
219*753c7e08SAugustin Cavalier  * if no data is available.  Pointer references can be to
220*753c7e08SAugustin Cavalier  * local data; any information that is saved will be copied.
221*753c7e08SAugustin Cavalier  * All multi-byte values must be in host byte order.
222*753c7e08SAugustin Cavalier  */
223*753c7e08SAugustin Cavalier struct ieee80211_scanparams {
224*753c7e08SAugustin Cavalier 	uint8_t		status;		/* bitmask of IEEE80211_BPARSE_* */
225*753c7e08SAugustin Cavalier 	uint8_t		chan;		/* channel # from FH/DSPARMS */
226*753c7e08SAugustin Cavalier 	uint8_t		bchan;		/* curchan's channel # */
227*753c7e08SAugustin Cavalier 	uint8_t		fhindex;
228*753c7e08SAugustin Cavalier 	uint16_t	fhdwell;	/* FHSS dwell interval */
229*753c7e08SAugustin Cavalier 	uint16_t	capinfo;	/* 802.11 capabilities */
230*753c7e08SAugustin Cavalier 	uint16_t	erp;		/* NB: 0x100 indicates ie present */
231*753c7e08SAugustin Cavalier 	uint16_t	bintval;
232*753c7e08SAugustin Cavalier 	uint8_t		timoff;
233*753c7e08SAugustin Cavalier 	uint8_t		*ies;		/* all captured ies */
234*753c7e08SAugustin Cavalier 	size_t		ies_len;	/* length of all captured ies */
235*753c7e08SAugustin Cavalier 	uint8_t		*tim;
236*753c7e08SAugustin Cavalier 	uint8_t		*tstamp;
237*753c7e08SAugustin Cavalier 	uint8_t		*country;
238*753c7e08SAugustin Cavalier 	uint8_t		*ssid;
239*753c7e08SAugustin Cavalier 	uint8_t		*rates;
240*753c7e08SAugustin Cavalier 	uint8_t		*xrates;
241*753c7e08SAugustin Cavalier 	uint8_t		*doth;
242*753c7e08SAugustin Cavalier 	uint8_t		*wpa;
243*753c7e08SAugustin Cavalier 	uint8_t		*rsn;
244*753c7e08SAugustin Cavalier 	uint8_t		*wme;
245*753c7e08SAugustin Cavalier 	uint8_t		*htcap;
246*753c7e08SAugustin Cavalier 	uint8_t		*htinfo;
247*753c7e08SAugustin Cavalier 	uint8_t		*ath;
248*753c7e08SAugustin Cavalier 	uint8_t		*tdma;
249*753c7e08SAugustin Cavalier 	uint8_t		*csa;
250*753c7e08SAugustin Cavalier 	uint8_t		*quiet;
251*753c7e08SAugustin Cavalier 	uint8_t		*meshid;
252*753c7e08SAugustin Cavalier 	uint8_t		*meshconf;
253*753c7e08SAugustin Cavalier 	uint8_t		*spare[3];
254*753c7e08SAugustin Cavalier };
255*753c7e08SAugustin Cavalier 
256*753c7e08SAugustin Cavalier /*
257*753c7e08SAugustin Cavalier  * Scan cache entry format used when exporting data from a policy
258*753c7e08SAugustin Cavalier  * module; this data may be represented some other way internally.
259*753c7e08SAugustin Cavalier  */
260*753c7e08SAugustin Cavalier struct ieee80211_scan_entry {
261*753c7e08SAugustin Cavalier 	uint8_t		se_macaddr[IEEE80211_ADDR_LEN];
262*753c7e08SAugustin Cavalier 	uint8_t		se_bssid[IEEE80211_ADDR_LEN];
263*753c7e08SAugustin Cavalier 	/* XXX can point inside se_ies */
264*753c7e08SAugustin Cavalier 	uint8_t		se_ssid[2+IEEE80211_NWID_LEN];
265*753c7e08SAugustin Cavalier 	uint8_t		se_rates[2+IEEE80211_RATE_MAXSIZE];
266*753c7e08SAugustin Cavalier 	uint8_t		se_xrates[2+IEEE80211_RATE_MAXSIZE];
267*753c7e08SAugustin Cavalier 	union {
268*753c7e08SAugustin Cavalier 		uint8_t		data[8];
269*753c7e08SAugustin Cavalier 		u_int64_t	tsf;
270*753c7e08SAugustin Cavalier 	} se_tstamp;			/* from last rcv'd beacon */
271*753c7e08SAugustin Cavalier 	uint16_t	se_intval;	/* beacon interval (host byte order) */
272*753c7e08SAugustin Cavalier 	uint16_t	se_capinfo;	/* capabilities (host byte order) */
273*753c7e08SAugustin Cavalier 	struct ieee80211_channel *se_chan;/* channel where sta found */
274*753c7e08SAugustin Cavalier 	uint16_t	se_timoff;	/* byte offset to TIM ie */
275*753c7e08SAugustin Cavalier 	uint16_t	se_fhdwell;	/* FH only (host byte order) */
276*753c7e08SAugustin Cavalier 	uint8_t		se_fhindex;	/* FH only */
277*753c7e08SAugustin Cavalier 	uint8_t		se_dtimperiod;	/* DTIM period */
278*753c7e08SAugustin Cavalier 	uint16_t	se_erp;		/* ERP from beacon/probe resp */
279*753c7e08SAugustin Cavalier 	int8_t		se_rssi;	/* avg'd recv ssi */
280*753c7e08SAugustin Cavalier 	int8_t		se_noise;	/* noise floor */
281*753c7e08SAugustin Cavalier 	uint8_t		se_cc[2];	/* captured country code */
282*753c7e08SAugustin Cavalier 	uint8_t		se_meshid[2+IEEE80211_MESHID_LEN];
283*753c7e08SAugustin Cavalier 	struct ieee80211_ies se_ies;	/* captured ie's */
284*753c7e08SAugustin Cavalier 	u_int		se_age;		/* age of entry (0 on create) */
285*753c7e08SAugustin Cavalier };
286*753c7e08SAugustin Cavalier MALLOC_DECLARE(M_80211_SCAN);
287*753c7e08SAugustin Cavalier 
288*753c7e08SAugustin Cavalier /*
289*753c7e08SAugustin Cavalier  * Template for an in-kernel scan policy module.
290*753c7e08SAugustin Cavalier  * Modules register with the scanning code and are
291*753c7e08SAugustin Cavalier  * typically loaded as needed.
292*753c7e08SAugustin Cavalier  */
293*753c7e08SAugustin Cavalier struct ieee80211_scanner {
294*753c7e08SAugustin Cavalier 	const char *scan_name;		/* printable name */
295*753c7e08SAugustin Cavalier 	int	(*scan_attach)(struct ieee80211_scan_state *);
296*753c7e08SAugustin Cavalier 	int	(*scan_detach)(struct ieee80211_scan_state *);
297*753c7e08SAugustin Cavalier 	int	(*scan_start)(struct ieee80211_scan_state *,
298*753c7e08SAugustin Cavalier 			struct ieee80211vap *);
299*753c7e08SAugustin Cavalier 	int	(*scan_restart)(struct ieee80211_scan_state *,
300*753c7e08SAugustin Cavalier 			struct ieee80211vap *);
301*753c7e08SAugustin Cavalier 	int	(*scan_cancel)(struct ieee80211_scan_state *,
302*753c7e08SAugustin Cavalier 			struct ieee80211vap *);
303*753c7e08SAugustin Cavalier 	int	(*scan_end)(struct ieee80211_scan_state *,
304*753c7e08SAugustin Cavalier 			struct ieee80211vap *);
305*753c7e08SAugustin Cavalier 	int	(*scan_flush)(struct ieee80211_scan_state *);
306*753c7e08SAugustin Cavalier 	struct ieee80211_channel *(*scan_pickchan)(
307*753c7e08SAugustin Cavalier 			struct ieee80211_scan_state *, int);
308*753c7e08SAugustin Cavalier 	/* add an entry to the cache */
309*753c7e08SAugustin Cavalier 	int	(*scan_add)(struct ieee80211_scan_state *,
310*753c7e08SAugustin Cavalier 			struct ieee80211_channel *,
311*753c7e08SAugustin Cavalier 			const struct ieee80211_scanparams *,
312*753c7e08SAugustin Cavalier 			const struct ieee80211_frame *,
313*753c7e08SAugustin Cavalier 			int subtype, int rssi, int noise);
314*753c7e08SAugustin Cavalier 	/* age and/or purge entries in the cache */
315*753c7e08SAugustin Cavalier 	void	(*scan_age)(struct ieee80211_scan_state *);
316*753c7e08SAugustin Cavalier 	/* note that association failed for an entry */
317*753c7e08SAugustin Cavalier 	void	(*scan_assoc_fail)(struct ieee80211_scan_state *,
318*753c7e08SAugustin Cavalier 			const uint8_t macaddr[IEEE80211_ADDR_LEN],
319*753c7e08SAugustin Cavalier 			int reason);
320*753c7e08SAugustin Cavalier 	/* note that association succeed for an entry */
321*753c7e08SAugustin Cavalier 	void	(*scan_assoc_success)(struct ieee80211_scan_state *,
322*753c7e08SAugustin Cavalier 			const uint8_t macaddr[IEEE80211_ADDR_LEN]);
323*753c7e08SAugustin Cavalier 	/* iterate over entries in the scan cache */
324*753c7e08SAugustin Cavalier 	void	(*scan_iterate)(struct ieee80211_scan_state *,
325*753c7e08SAugustin Cavalier 			ieee80211_scan_iter_func *, void *);
326*753c7e08SAugustin Cavalier 	void	(*scan_spare0)(void);
327*753c7e08SAugustin Cavalier 	void	(*scan_spare1)(void);
328*753c7e08SAugustin Cavalier 	void	(*scan_spare2)(void);
329*753c7e08SAugustin Cavalier 	void	(*scan_spare4)(void);
330*753c7e08SAugustin Cavalier };
331*753c7e08SAugustin Cavalier void	ieee80211_scanner_register(enum ieee80211_opmode,
332*753c7e08SAugustin Cavalier 		const struct ieee80211_scanner *);
333*753c7e08SAugustin Cavalier void	ieee80211_scanner_unregister(enum ieee80211_opmode,
334*753c7e08SAugustin Cavalier 		const struct ieee80211_scanner *);
335*753c7e08SAugustin Cavalier void	ieee80211_scanner_unregister_all(const struct ieee80211_scanner *);
336*753c7e08SAugustin Cavalier const struct ieee80211_scanner *ieee80211_scanner_get(enum ieee80211_opmode);
337*753c7e08SAugustin Cavalier void	ieee80211_scan_update_locked(struct ieee80211vap *vap,
338*753c7e08SAugustin Cavalier 		const struct ieee80211_scanner *scan);
339*753c7e08SAugustin Cavalier void	ieee80211_scan_copy_ssid(struct ieee80211vap *vap,
340*753c7e08SAugustin Cavalier 		struct ieee80211_scan_state *ss,
341*753c7e08SAugustin Cavalier 		int nssid, const struct ieee80211_scan_ssid ssids[]);
342*753c7e08SAugustin Cavalier void	ieee80211_scan_dump_probe_beacon(uint8_t subtype, int isnew,
343*753c7e08SAugustin Cavalier 		const uint8_t mac[IEEE80211_ADDR_LEN],
344*753c7e08SAugustin Cavalier 		const struct ieee80211_scanparams *sp, int rssi);
345*753c7e08SAugustin Cavalier void	ieee80211_scan_dump(struct ieee80211_scan_state *ss);
346*753c7e08SAugustin Cavalier 
347*753c7e08SAugustin Cavalier #endif /* _NET80211_IEEE80211_SCAN_H_ */
348