ieee80211_var.h revision 167242
14910Swollman/*-
24910Swollman * Copyright (c) 2001 Atsushi Onoe
34910Swollman * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
44910Swollman * All rights reserved.
530300Sjoerg *
625944Sjoerg * Redistribution and use in source and binary forms, with or without
74910Swollman * modification, are permitted provided that the following conditions
825944Sjoerg * are met:
925944Sjoerg * 1. Redistributions of source code must retain the above copyright
1025944Sjoerg *    notice, this list of conditions and the following disclaimer.
114910Swollman * 2. Redistributions in binary form must reproduce the above copyright
124910Swollman *    notice, this list of conditions and the following disclaimer in the
134910Swollman *    documentation and/or other materials provided with the distribution.
144910Swollman * 3. The name of the author may not be used to endorse or promote products
154910Swollman *    derived from this software without specific prior written permission.
164910Swollman *
174910Swollman * Alternatively, this software may be distributed under the terms of the
1830300Sjoerg * GNU General Public License ("GPL") version 2 as published by the Free
1916288Sgpalmer * Software Foundation.
2050477Speter *
214910Swollman * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
224910Swollman * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2340008Sjoerg * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2440008Sjoerg * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2542065Sphk * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2632350Seivind * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2731742Seivind * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2840008Sjoerg * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2931742Seivind * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3040008Sjoerg * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3140008Sjoerg *
3240008Sjoerg * $FreeBSD: head/sys/net80211/ieee80211_var.h 167242 2007-03-05 18:52:35Z sam $
3340008Sjoerg */
3440008Sjoerg#ifndef _NET80211_IEEE80211_VAR_H_
3540008Sjoerg#define _NET80211_IEEE80211_VAR_H_
3640008Sjoerg
374952Sbde/*
384952Sbde * Definitions for IEEE 802.11 drivers.
3924204Sbde */
404910Swollman#define	IEEE80211_DEBUG
4125706Sjoerg#undef	IEEE80211_DEBUG_REFCNT			/* node refcnt stuff */
4242104Sphk
4342104Sphk/* NB: portability glue must go first */
4442104Sphk#ifdef __NetBSD__
4529024Sbde#include <net80211/ieee80211_netbsd.h>
464910Swollman#elif __FreeBSD__
4740008Sjoerg#include <net80211/ieee80211_freebsd.h>
4840008Sjoerg#elif __linux__
4940008Sjoerg#include <net80211/ieee80211_linux.h>
5040008Sjoerg#else
5130300Sjoerg#error	"No support for your operating system!"
5240008Sjoerg#endif
534910Swollman
544910Swollman#include <net80211/_ieee80211.h>
554910Swollman#include <net80211/ieee80211.h>
564910Swollman#include <net80211/ieee80211_crypto.h>
5742104Sphk#include <net80211/ieee80211_ioctl.h>		/* for ieee80211_stats */
584910Swollman#include <net80211/ieee80211_node.h>
5942065Sphk#include <net80211/ieee80211_proto.h>
6040008Sjoerg
6140008Sjoerg#define	IEEE80211_TXPOWER_MAX	100	/* .5 dbM (XXX units?) */
6240008Sjoerg#define	IEEE80211_TXPOWER_MIN	0	/* kill radio */
6340008Sjoerg
6440008Sjoerg#define	IEEE80211_DTIM_DEFAULT	1	/* default DTIM period */
6542104Sphk#define	IEEE80211_BINTVAL_DEFAULT 100	/* default beacon interval (TU's) */
6630300Sjoerg
6730300Sjoerg#define	IEEE80211_BMISS_MAX	2	/* maximum consecutive bmiss allowed */
684910Swollman#define	IEEE80211_HWBMISS_DEFAULT 7	/* h/w bmiss threshold (beacons) */
694910Swollman
704910Swollman#define	IEEE80211_PS_SLEEP	0x1	/* STA is in power saving mode */
714910Swollman#define	IEEE80211_PS_MAX_QUEUE	50	/* maximum saved packets */
724910Swollman
734910Swollman#define	IEEE80211_FIXED_RATE_NONE	-1
7440008Sjoerg#define	IEEE80211_MCAST_RATE_DEFAULT	(2*1)	/* default mcast rate (1M) */
7540008Sjoerg
7640008Sjoerg#define	IEEE80211_RTS_DEFAULT		IEEE80211_RTS_MAX
7740008Sjoerg#define	IEEE80211_FRAG_DEFAULT		IEEE80211_FRAG_MAX
7840008Sjoerg
7932350Seivind#define	IEEE80211_MS_TO_TU(x)	(((x) * 1000) / 1024)
8040008Sjoerg#define	IEEE80211_TU_TO_MS(x)	(((x) * 1024) / 1000)
814910Swollman#define	IEEE80211_TU_TO_TICKS(x)(((x) * 1024 * hz) / (1000 * 1000))
824910Swollman
8311819Sjulianstruct ieee80211_aclator;
8411819Sjulianstruct sysctl_ctx_list;
8511819Sjulian
8611819Sjulianstruct ieee80211com {
8711819Sjulian	SLIST_ENTRY(ieee80211com) ic_next;
884910Swollman	struct ifnet		*ic_ifp;	/* associated device */
894910Swollman	struct ieee80211_stats	ic_stats;	/* statistics */
904910Swollman	struct sysctl_ctx_list	*ic_sysctl;	/* dynamic sysctl context */
914910Swollman	u_int32_t		ic_debug;	/* debug msg flags */
924910Swollman	int			ic_vap;		/* virtual AP index */
934910Swollman	ieee80211_beacon_lock_t	ic_beaconlock;	/* beacon update lock */
944910Swollman
954910Swollman	int			(*ic_reset)(struct ifnet *);
964910Swollman	void			(*ic_recv_mgmt)(struct ieee80211com *,
974910Swollman				    struct mbuf *, struct ieee80211_node *,
984910Swollman				    int, int, u_int32_t);
994910Swollman	int			(*ic_send_mgmt)(struct ieee80211com *,
1004910Swollman				    struct ieee80211_node *, int, int);
1014910Swollman	int			(*ic_newstate)(struct ieee80211com *,
10242065Sphk				    enum ieee80211_state, int);
10342064Sphk	void			(*ic_newassoc)(struct ieee80211_node *, int);
10442064Sphk	void			(*ic_updateslot)(struct ifnet *);
10542104Sphk	void			(*ic_set_tim)(struct ieee80211_node *, int);
10640008Sjoerg	int			(*ic_raw_xmit)(struct ieee80211_node *,
10742064Sphk				    struct mbuf *,
10842064Sphk				    const struct ieee80211_bpf_params *);
10942104Sphk	u_int8_t		ic_myaddr[IEEE80211_ADDR_LEN];
11040008Sjoerg	struct ieee80211_rateset ic_sup_rates[IEEE80211_MODE_MAX];
11142104Sphk	struct ieee80211_channel ic_channels[IEEE80211_CHAN_MAX+1];
1124910Swollman	u_int8_t		ic_chan_avail[IEEE80211_CHAN_BYTES];
1134910Swollman	u_int8_t		ic_chan_active[IEEE80211_CHAN_BYTES];
11425944Sjoerg	u_int8_t		ic_chan_scan[IEEE80211_CHAN_BYTES];
11525944Sjoerg	struct ieee80211_node_table ic_scan;	/* scan candidates */
11625944Sjoerg	struct ifqueue		ic_mgtq;
11725955Sjoerg	u_int32_t		ic_flags;	/* state flags */
11825944Sjoerg	u_int32_t		ic_flags_ext;	/* extended state flags */
11925944Sjoerg	u_int32_t		ic_caps;	/* capabilities */
12025944Sjoerg	u_int16_t		ic_modecaps;	/* set of mode capabilities */
12125955Sjoerg	u_int16_t		ic_curmode;	/* current mode */
12225955Sjoerg	enum ieee80211_phytype	ic_phytype;	/* XXX wrong for multi-mode */
12325955Sjoerg	enum ieee80211_opmode	ic_opmode;	/* operation mode */
12430300Sjoerg	enum ieee80211_state	ic_state;	/* 802.11 state */
12530300Sjoerg	enum ieee80211_protmode	ic_protmode;	/* 802.11g protection mode */
12630300Sjoerg	enum ieee80211_roamingmode ic_roaming;	/* roaming mode */
12730300Sjoerg	struct ieee80211_node_table ic_sta;	/* stations/neighbors */
12830300Sjoerg	u_int32_t		*ic_aid_bitmap;	/* association id map */
12930300Sjoerg	u_int16_t		ic_max_aid;
13030300Sjoerg	u_int16_t		ic_sta_assoc;	/* stations associated */
13130300Sjoerg	u_int16_t		ic_ps_sta;	/* stations in power save */
13230300Sjoerg	u_int16_t		ic_ps_pending;	/* ps sta's w/ pending frames */
13325944Sjoerg	u_int8_t		*ic_tim_bitmap;	/* power-save stations w/ data*/
13425944Sjoerg	u_int16_t		ic_tim_len;	/* ic_tim_bitmap size (bytes) */
13525955Sjoerg	u_int8_t		ic_dtim_period;	/* DTIM period */
13625955Sjoerg	u_int8_t		ic_dtim_count;	/* DTIM count for last bcn */
13745152Sphk	struct ifmedia		ic_media;	/* interface media config */
13825944Sjoerg	struct bpf_if		*ic_rawbpf;	/* packet filter structure */
13930300Sjoerg	struct ieee80211_node	*ic_bss;	/* information for this node */
14030300Sjoerg	struct ieee80211_channel *ic_ibss_chan;
14130300Sjoerg	struct ieee80211_channel *ic_curchan;	/* current channel */
14230300Sjoerg	int			ic_fixed_rate;	/* index to ic_sup_rates[] */
14330300Sjoerg	int			ic_mcast_rate;	/* rate for mcast frames */
14430300Sjoerg	u_int16_t		ic_rtsthreshold;
14530300Sjoerg	u_int16_t		ic_fragthreshold;
14630300Sjoerg	u_int8_t		ic_bmissthreshold;
14730300Sjoerg	u_int8_t		ic_bmiss_count;	/* current beacon miss count */
14830300Sjoerg	int			ic_bmiss_max;	/* max bmiss before scan */
1494910Swollman	u_int16_t		ic_swbmiss_count;/* beacons in last period */
15025944Sjoerg	u_int16_t		ic_swbmiss_period;/* s/w bmiss period */
15125944Sjoerg	struct callout		ic_swbmiss;	/* s/w beacon miss timer */
15225944Sjoerg	struct ieee80211_node	*(*ic_node_alloc)(struct ieee80211_node_table*);
15325944Sjoerg	void			(*ic_node_free)(struct ieee80211_node *);
15425944Sjoerg	void			(*ic_node_cleanup)(struct ieee80211_node *);
15525944Sjoerg	u_int8_t		(*ic_node_getrssi)(const struct ieee80211_node*);
15625944Sjoerg	u_int16_t		ic_lintval;	/* listen interval */
15725944Sjoerg	u_int16_t		ic_bintval;	/* beacon interval */
15825944Sjoerg	u_int16_t		ic_holdover;	/* PM hold over duration */
15925944Sjoerg	u_int16_t		ic_txmin;	/* min tx retry count */
16025944Sjoerg	u_int16_t		ic_txmax;	/* max tx retry count */
1614910Swollman	u_int16_t		ic_txlifetime;	/* tx lifetime */
16230300Sjoerg	u_int16_t		ic_txpowlimit;	/* global tx power limit */
16330300Sjoerg	u_int16_t		ic_nonerpsta;	/* # non-ERP stations */
16430300Sjoerg	u_int16_t		ic_longslotsta;	/* # long slot time stations */
16530300Sjoerg	int			ic_mgt_timer;	/* mgmt timeout */
16630300Sjoerg	int			ic_inact_timer;	/* inactivity timer wait */
16730300Sjoerg	int			ic_des_esslen;
16830300Sjoerg	u_int8_t		ic_des_essid[IEEE80211_NWID_LEN];
16930300Sjoerg	struct ieee80211_channel *ic_des_chan;	/* desired channel */
1704910Swollman	u_int8_t		ic_des_bssid[IEEE80211_ADDR_LEN];
17125944Sjoerg	void			*ic_opt_ie;	/* user-specified IE's */
17225944Sjoerg	u_int16_t		ic_opt_ie_len;	/* length of ni_opt_ie */
17325944Sjoerg	/*
1744910Swollman	 * Inactivity timer settings for nodes.
17530300Sjoerg	 */
17630300Sjoerg	int			ic_inact_init;	/* initial setting */
17730300Sjoerg	int			ic_inact_auth;	/* auth but not assoc setting */
1784910Swollman	int			ic_inact_run;	/* authorized setting */
17930300Sjoerg	int			ic_inact_probe;	/* inactive probe time */
18030300Sjoerg
18130300Sjoerg	/*
18230300Sjoerg	 * WME/WMM state.
18330300Sjoerg	 */
18430300Sjoerg	struct ieee80211_wme_state ic_wme;
18530300Sjoerg
18630300Sjoerg	/*
18730300Sjoerg	 * Cipher state/configuration.
18830300Sjoerg	 */
18930300Sjoerg	struct ieee80211_crypto_state ic_crypto;
19030300Sjoerg#define	ic_nw_keys	ic_crypto.cs_nw_keys	/* XXX compatibility */
19130300Sjoerg#define	ic_def_txkey	ic_crypto.cs_def_txkey	/* XXX compatibility */
19230300Sjoerg
19325944Sjoerg	/*
19425944Sjoerg	 * 802.1x glue.  When an authenticator attaches it
19525944Sjoerg	 * fills in this section.  We assume that when ic_ec
19625944Sjoerg	 * is setup that the methods are safe to call.
19725944Sjoerg	 */
19825944Sjoerg	const struct ieee80211_authenticator *ic_auth;
19925944Sjoerg	struct eapolcom		*ic_ec;
20025944Sjoerg
20125944Sjoerg	/*
20225944Sjoerg	 * Access control glue.  When a control agent attaches
20325944Sjoerg	 * it fills in this section.  We assume that when ic_ac
20425944Sjoerg	 * is setup that the methods are safe to call.
2054910Swollman	 */
20611189Sjkh	const struct ieee80211_aclator *ic_acl;
20711189Sjkh	void			*ic_as;
20811189Sjkh};
2094910Swollman
2104910Swollman#define	IEEE80211_ADDR_EQ(a1,a2)	(memcmp(a1,a2,IEEE80211_ADDR_LEN) == 0)
2114910Swollman#define	IEEE80211_ADDR_COPY(dst,src)	memcpy(dst,src,IEEE80211_ADDR_LEN)
2124910Swollman
21311189Sjkh/* ic_flags */
21411189Sjkh/* NB: bits 0x4c available */
21511189Sjkh#define	IEEE80211_F_FF		0x00000001	/* CONF: ATH FF enabled */
2164910Swollman#define	IEEE80211_F_TURBOP	0x00000002	/* CONF: ATH Turbo enabled*/
2174910Swollman#define	IEEE80211_F_BURST	0x00000004	/* CONF: bursting enabled */
2184910Swollman/* NB: this is intentionally setup to be IEEE80211_CAPINFO_PRIVACY */
2194910Swollman#define	IEEE80211_F_PRIVACY	0x00000010	/* CONF: privacy enabled */
22011189Sjkh#define	IEEE80211_F_PUREG	0x00000020	/* CONF: 11g w/o 11b sta's */
22111189Sjkh#define	IEEE80211_F_SCAN	0x00000080	/* STATUS: scanning */
22211189Sjkh#define	IEEE80211_F_ASCAN	0x00000100	/* STATUS: active scan */
22311189Sjkh#define	IEEE80211_F_SIBSS	0x00000200	/* STATUS: start IBSS */
22411189Sjkh/* NB: this is intentionally setup to be IEEE80211_CAPINFO_SHORT_SLOTTIME */
22511189Sjkh#define	IEEE80211_F_SHSLOT	0x00000400	/* STATUS: use short slot time*/
2264910Swollman#define	IEEE80211_F_PMGTON	0x00000800	/* CONF: Power mgmt enable */
2274910Swollman#define	IEEE80211_F_DESBSSID	0x00001000	/* CONF: des_bssid is set */
2284910Swollman#define	IEEE80211_F_WME		0x00002000	/* CONF: enable WME use */
22925944Sjoerg#define	IEEE80211_F_BGSCAN	0x00004000	/* CONF: bg scan enabled (???)*/
23025944Sjoerg#define	IEEE80211_F_SWRETRY	0x00008000	/* CONF: sw tx retry enabled */
23125944Sjoerg#define IEEE80211_F_TXPOW_FIXED	0x00010000	/* TX Power: fixed rate */
23225944Sjoerg#define	IEEE80211_F_IBSSON	0x00020000	/* CONF: IBSS creation enable */
23325944Sjoerg#define	IEEE80211_F_SHPREAMBLE	0x00040000	/* STATUS: use short preamble */
23425944Sjoerg#define	IEEE80211_F_DATAPAD	0x00080000	/* CONF: do alignment pad */
23525944Sjoerg#define	IEEE80211_F_USEPROT	0x00100000	/* STATUS: protection enabled */
23625944Sjoerg#define	IEEE80211_F_USEBARKER	0x00200000	/* STATUS: use barker preamble*/
23725944Sjoerg#define	IEEE80211_F_TIMUPDATE	0x00400000	/* STATUS: update beacon tim */
23825944Sjoerg#define	IEEE80211_F_WPA1	0x00800000	/* CONF: WPA enabled */
23925944Sjoerg#define	IEEE80211_F_WPA2	0x01000000	/* CONF: WPA2 enabled */
24025944Sjoerg#define	IEEE80211_F_WPA		0x01800000	/* CONF: WPA/WPA2 enabled */
24125944Sjoerg#define	IEEE80211_F_DROPUNENC	0x02000000	/* CONF: drop unencrypted */
24225944Sjoerg#define	IEEE80211_F_COUNTERM	0x04000000	/* CONF: TKIP countermeasures */
24325944Sjoerg#define	IEEE80211_F_HIDESSID	0x08000000	/* CONF: hide SSID in beacon */
24425944Sjoerg#define	IEEE80211_F_NOBRIDGE	0x10000000	/* CONF: dis. internal bridge */
24525944Sjoerg#define	IEEE80211_F_WMEUPDATE	0x20000000	/* STATUS: update beacon wme */
24625944Sjoerg
24725944Sjoerg/* ic_flags_ext */
24825944Sjoerg#define	IEEE80211_FEXT_WDS	0x00000001	/* CONF: 4 addr allowed */
24925944Sjoerg/* 0x00000006 reserved */
25025944Sjoerg#define	IEEE80211_FEXT_BGSCAN	0x00000008	/* STATUS: enable full bgscan completion */
25125944Sjoerg#define	IEEE80211_FEXT_ERPUPDATE 0x00000200	/* STATUS: update ERP element */
25225944Sjoerg#define	IEEE80211_FEXT_SWBMISS	0x00000400	/* CONF: do bmiss in s/w */
25325944Sjoerg#define	IEEE80211_FEXT_PROBECHAN 0x00020000	/* CONF: probe passive channel*/
25425944Sjoerg
25525944Sjoerg/* ic_caps */
25625944Sjoerg#define	IEEE80211_C_WEP		0x00000001	/* CAPABILITY: WEP available */
25725944Sjoerg#define	IEEE80211_C_TKIP	0x00000002	/* CAPABILITY: TKIP available */
25825944Sjoerg#define	IEEE80211_C_AES		0x00000004	/* CAPABILITY: AES OCB avail */
25925944Sjoerg#define	IEEE80211_C_AES_CCM	0x00000008	/* CAPABILITY: AES CCM avail */
26025944Sjoerg#define	IEEE80211_C_CKIP	0x00000020	/* CAPABILITY: CKIP available */
26112820Sphk#define	IEEE80211_C_FF		0x00000040	/* CAPABILITY: ATH FF avail */
26242065Sphk#define	IEEE80211_C_TURBOP	0x00000080	/* CAPABILITY: ATH Turbo avail*/
26330300Sjoerg#define	IEEE80211_C_IBSS	0x00000100	/* CAPABILITY: IBSS available */
26440008Sjoerg#define	IEEE80211_C_PMGT	0x00000200	/* CAPABILITY: Power mgmt */
2654910Swollman#define	IEEE80211_C_HOSTAP	0x00000400	/* CAPABILITY: HOSTAP avail */
26642065Sphk#define	IEEE80211_C_AHDEMO	0x00000800	/* CAPABILITY: Old Adhoc Demo */
26740008Sjoerg#define	IEEE80211_C_SWRETRY	0x00001000	/* CAPABILITY: sw tx retry */
26840008Sjoerg#define	IEEE80211_C_TXPMGT	0x00002000	/* CAPABILITY: tx power mgmt */
26940008Sjoerg#define	IEEE80211_C_SHSLOT	0x00004000	/* CAPABILITY: short slottime */
27040008Sjoerg#define	IEEE80211_C_SHPREAMBLE	0x00008000	/* CAPABILITY: short preamble */
27140008Sjoerg#define	IEEE80211_C_MONITOR	0x00010000	/* CAPABILITY: monitor mode */
27240008Sjoerg#define	IEEE80211_C_TKIPMIC	0x00020000	/* CAPABILITY: TKIP MIC avail */
27340008Sjoerg#define	IEEE80211_C_WPA1	0x00800000	/* CAPABILITY: WPA1 avail */
2744910Swollman#define	IEEE80211_C_WPA2	0x01000000	/* CAPABILITY: WPA2 avail */
2754910Swollman#define	IEEE80211_C_WPA		0x01800000	/* CAPABILITY: WPA1+WPA2 avail*/
2764910Swollman#define	IEEE80211_C_BURST	0x02000000	/* CAPABILITY: frame bursting */
2774910Swollman#define	IEEE80211_C_WME		0x04000000	/* CAPABILITY: WME avail */
2784910Swollman#define	IEEE80211_C_WDS		0x08000000	/* CAPABILITY: 4-addr support */
27930300Sjoerg/* 0x10000000 reserved */
28030300Sjoerg#define	IEEE80211_C_BGSCAN	0x20000000	/* CAPABILITY: bg scanning */
2814910Swollman#define	IEEE80211_C_TXFRAG	0x40000000	/* CAPABILITY: tx fragments */
28211189Sjkh/* XXX protection/barker? */
2834910Swollman
2844910Swollman#define	IEEE80211_C_CRYPTO	0x0000002f	/* CAPABILITY: crypto alg's */
2854910Swollman
2864910Swollmanvoid	ieee80211_ifattach(struct ieee80211com *);
2874910Swollmanvoid	ieee80211_ifdetach(struct ieee80211com *);
28825944Sjoergconst struct ieee80211_rateset *ieee80211_get_suprates(struct ieee80211com *,
28925944Sjoerg		const struct ieee80211_channel *);
29025944Sjoergvoid	ieee80211_announce(struct ieee80211com *);
29125944Sjoergvoid	ieee80211_media_init(struct ieee80211com *,
29211189Sjkh		ifm_change_cb_t, ifm_stat_cb_t);
29330300Sjoergstruct ieee80211com *ieee80211_find_vap(const u_int8_t mac[IEEE80211_ADDR_LEN]);
29425944Sjoergint	ieee80211_media_change(struct ifnet *);
2954910Swollmanvoid	ieee80211_media_status(struct ifnet *, struct ifmediareq *);
29625944Sjoergint	ieee80211_ioctl(struct ieee80211com *, u_long, caddr_t);
29725944Sjoergint	ieee80211_cfgget(struct ieee80211com *, u_long, caddr_t);
29825944Sjoergint	ieee80211_cfgset(struct ieee80211com *, u_long, caddr_t);
29925944Sjoergvoid	ieee80211_watchdog(struct ieee80211com *);
30025944Sjoergint	ieee80211_rate2media(struct ieee80211com *, int,
30125944Sjoerg		enum ieee80211_phymode);
30225944Sjoergint	ieee80211_media2rate(int);
30342104Sphkint	ieee80211_mhz2ieee(u_int, u_int);
30425944Sjoergint	ieee80211_chan2ieee(struct ieee80211com *, const struct ieee80211_channel *);
30525944Sjoergu_int	ieee80211_ieee2mhz(u_int, u_int);
30630300Sjoergint	ieee80211_setmode(struct ieee80211com *, enum ieee80211_phymode);
30742104Sphkenum ieee80211_phymode ieee80211_chan2mode(struct ieee80211com *,
30830300Sjoerg		const struct ieee80211_channel *);
30925944Sjoerg
31025944Sjoerg/*
31125944Sjoerg * Key update synchronization methods.  XXX should not be visible.
31225944Sjoerg */
31325944Sjoergstatic __inline void
31425944Sjoergieee80211_key_update_begin(struct ieee80211com *ic)
31525944Sjoerg{
31630300Sjoerg	ic->ic_crypto.cs_key_update_begin(ic);
31730300Sjoerg}
31825944Sjoergstatic __inline void
31925944Sjoergieee80211_key_update_end(struct ieee80211com *ic)
32025944Sjoerg{
32125944Sjoerg	ic->ic_crypto.cs_key_update_end(ic);
32225944Sjoerg}
32325944Sjoerg
32425944Sjoerg/*
32525944Sjoerg * XXX these need to be here for IEEE80211_F_DATAPAD
32625944Sjoerg */
32725944Sjoerg
32825944Sjoerg/*
32925944Sjoerg * Return the space occupied by the 802.11 header and any
33025944Sjoerg * padding required by the driver.  This works for a
33125944Sjoerg * management or data frame.
33230300Sjoerg */
33330300Sjoergstatic __inline int
33425944Sjoergieee80211_hdrspace(struct ieee80211com *ic, const void *data)
33525944Sjoerg{
33625944Sjoerg	int size = ieee80211_hdrsize(data);
33725944Sjoerg	if (ic->ic_flags & IEEE80211_F_DATAPAD)
33825944Sjoerg		size = roundup(size, sizeof(u_int32_t));
33925944Sjoerg	return size;
34025944Sjoerg}
34125944Sjoerg
34225944Sjoerg/*
34325944Sjoerg * Like ieee80211_hdrspace, but handles any type of frame.
34425944Sjoerg */
34525944Sjoergstatic __inline int
34625944Sjoergieee80211_anyhdrspace(struct ieee80211com *ic, const void *data)
34725944Sjoerg{
34825944Sjoerg	int size = ieee80211_anyhdrsize(data);
34925944Sjoerg	if (ic->ic_flags & IEEE80211_F_DATAPAD)
35030300Sjoerg		size = roundup(size, sizeof(u_int32_t));
35130300Sjoerg	return size;
35230300Sjoerg}
35330300Sjoerg
35430300Sjoerg#define	IEEE80211_MSG_DEBUG	0x40000000	/* IFF_DEBUG equivalent */
35530300Sjoerg#define	IEEE80211_MSG_DUMPPKTS	0x20000000	/* IFF_LINK2 equivalant */
35630300Sjoerg#define	IEEE80211_MSG_CRYPTO	0x10000000	/* crypto work */
35730300Sjoerg#define	IEEE80211_MSG_INPUT	0x08000000	/* input handling */
35830300Sjoerg#define	IEEE80211_MSG_XRATE	0x04000000	/* rate set handling */
35930300Sjoerg#define	IEEE80211_MSG_ELEMID	0x02000000	/* element id parsing */
36030300Sjoerg#define	IEEE80211_MSG_NODE	0x01000000	/* node handling */
36130300Sjoerg#define	IEEE80211_MSG_ASSOC	0x00800000	/* association handling */
36230300Sjoerg#define	IEEE80211_MSG_AUTH	0x00400000	/* authentication handling */
36330300Sjoerg#define	IEEE80211_MSG_SCAN	0x00200000	/* scanning */
36430300Sjoerg#define	IEEE80211_MSG_OUTPUT	0x00100000	/* output handling */
36530300Sjoerg#define	IEEE80211_MSG_STATE	0x00080000	/* state machine */
36630300Sjoerg#define	IEEE80211_MSG_POWER	0x00040000	/* power save handling */
36730300Sjoerg#define	IEEE80211_MSG_DOT1X	0x00020000	/* 802.1x authenticator */
36830300Sjoerg#define	IEEE80211_MSG_DOT1XSM	0x00010000	/* 802.1x state machine */
36930300Sjoerg#define	IEEE80211_MSG_RADIUS	0x00008000	/* 802.1x radius client */
37025944Sjoerg#define	IEEE80211_MSG_RADDUMP	0x00004000	/* dump 802.1x radius packets */
37130300Sjoerg#define	IEEE80211_MSG_RADKEYS	0x00002000	/* dump 802.1x keys */
37230300Sjoerg#define	IEEE80211_MSG_WPA	0x00001000	/* WPA/RSN protocol */
37325944Sjoerg#define	IEEE80211_MSG_ACL	0x00000800	/* ACL handling */
37425944Sjoerg#define	IEEE80211_MSG_WME	0x00000400	/* WME protocol */
37525944Sjoerg#define	IEEE80211_MSG_SUPERG	0x00000200	/* Atheros SuperG protocol */
37630300Sjoerg#define	IEEE80211_MSG_DOTH	0x00000100	/* 802.11h support */
37738343Sbde#define	IEEE80211_MSG_INACT	0x00000080	/* inactivity handling */
37830300Sjoerg#define	IEEE80211_MSG_ROAM	0x00000040	/* sta-mode roaming */
37930300Sjoerg#define	IEEE80211_MSG_RATECTL	0x00000020	/* tx rate control */
38030300Sjoerg
38125944Sjoerg#define	IEEE80211_MSG_ANY	0xffffffff	/* anything */
38230300Sjoerg
38330300Sjoerg#ifdef IEEE80211_DEBUG
38430300Sjoerg#define	ieee80211_msg(_ic, _m)	((_ic)->ic_debug & (_m))
38525944Sjoerg#define	IEEE80211_DPRINTF(_ic, _m, _fmt, ...) do {			\
38625944Sjoerg	if (ieee80211_msg(_ic, _m))					\
38725944Sjoerg		ieee80211_note(_ic, _fmt, __VA_ARGS__);		\
38825944Sjoerg} while (0)
38933181Seivind#define	IEEE80211_NOTE(_ic, _m, _ni, _fmt, ...) do {			\
39025944Sjoerg	if (ieee80211_msg(_ic, _m))					\
39125944Sjoerg		ieee80211_note_mac(_ic, (_ni)->ni_macaddr, _fmt, __VA_ARGS__);\
39225944Sjoerg} while (0)
39325944Sjoerg#define	IEEE80211_NOTE_MAC(_ic, _m, _mac, _fmt, ...) do {		\
39425944Sjoerg	if (ieee80211_msg(_ic, _m))					\
39525944Sjoerg		ieee80211_note_mac(_ic, _mac, _fmt, __VA_ARGS__);	\
39625944Sjoerg} while (0)
39733181Seivind#define	IEEE80211_NOTE_FRAME(_ic, _m, _wh, _fmt, ...) do {		\
39825944Sjoerg	if (ieee80211_msg(_ic, _m))					\
39925944Sjoerg		ieee80211_note_frame(_ic, _wh, _fmt, __VA_ARGS__);	\
40025944Sjoerg} while (0)
40125944Sjoergvoid	ieee80211_note(struct ieee80211com *ic, const char *fmt, ...);
40225944Sjoergvoid	ieee80211_note_mac(struct ieee80211com *ic,
40325944Sjoerg		const u_int8_t mac[IEEE80211_ADDR_LEN], const char *fmt, ...);
40425944Sjoergvoid	ieee80211_note_frame(struct ieee80211com *ic,
40533181Seivind		const struct ieee80211_frame *wh, const char *fmt, ...);
40630300Sjoerg#define	ieee80211_msg_debug(_ic) \
40730300Sjoerg	((_ic)->ic_debug & IEEE80211_MSG_DEBUG)
40830300Sjoerg#define	ieee80211_msg_dumppkts(_ic) \
40930300Sjoerg	((_ic)->ic_debug & IEEE80211_MSG_DUMPPKTS)
41030300Sjoerg#define	ieee80211_msg_input(_ic) \
41130300Sjoerg	((_ic)->ic_debug & IEEE80211_MSG_INPUT)
41230300Sjoerg#define	ieee80211_msg_radius(_ic) \
41333181Seivind	((_ic)->ic_debug & IEEE80211_MSG_RADIUS)
41430300Sjoerg#define	ieee80211_msg_dumpradius(_ic) \
41530300Sjoerg	((_ic)->ic_debug & IEEE80211_MSG_RADDUMP)
41630300Sjoerg#define	ieee80211_msg_dumpradkeys(_ic) \
41730300Sjoerg	((_ic)->ic_debug & IEEE80211_MSG_RADKEYS)
41830300Sjoerg#define	ieee80211_msg_scan(_ic) \
41930300Sjoerg	((_ic)->ic_debug & IEEE80211_MSG_SCAN)
42030300Sjoerg#define	ieee80211_msg_assoc(_ic) \
42133181Seivind	((_ic)->ic_debug & IEEE80211_MSG_ASSOC)
42225944Sjoerg#else
42325944Sjoerg#define	IEEE80211_DPRINTF(_ic, _m, _fmt, ...)
42430300Sjoerg#define	IEEE80211_NOTE_FRAME(_ic, _m, _wh, _fmt, ...)
42530300Sjoerg#define	IEEE80211_NOTE_MAC(_ic, _m, _mac, _fmt, ...)
42625944Sjoerg#define	ieee80211_msg_dumppkts(_ic)	0
42725944Sjoerg#define	ieee80211_msg(_ic, _m)		0
42825944Sjoerg#endif
42925944Sjoerg
43025944Sjoerg#endif /* _NET80211_IEEE80211_VAR_H_ */
4314910Swollman