132176cfdSRui Paulo /*-
2f186073cSJoerg Sonnenberger * Copyright (c) 2001 Atsushi Onoe
332176cfdSRui Paulo * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
4f186073cSJoerg Sonnenberger * All rights reserved.
5f186073cSJoerg Sonnenberger *
6f186073cSJoerg Sonnenberger * Redistribution and use in source and binary forms, with or without
7f186073cSJoerg Sonnenberger * modification, are permitted provided that the following conditions
8f186073cSJoerg Sonnenberger * are met:
9f186073cSJoerg Sonnenberger * 1. Redistributions of source code must retain the above copyright
10f186073cSJoerg Sonnenberger * notice, this list of conditions and the following disclaimer.
11f186073cSJoerg Sonnenberger * 2. Redistributions in binary form must reproduce the above copyright
12f186073cSJoerg Sonnenberger * notice, this list of conditions and the following disclaimer in the
13f186073cSJoerg Sonnenberger * documentation and/or other materials provided with the distribution.
14f186073cSJoerg Sonnenberger *
15f186073cSJoerg Sonnenberger * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16f186073cSJoerg Sonnenberger * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17f186073cSJoerg Sonnenberger * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18f186073cSJoerg Sonnenberger * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19f186073cSJoerg Sonnenberger * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20f186073cSJoerg Sonnenberger * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21f186073cSJoerg Sonnenberger * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22f186073cSJoerg Sonnenberger * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23f186073cSJoerg Sonnenberger * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24f186073cSJoerg Sonnenberger * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25f186073cSJoerg Sonnenberger *
26085ff963SMatthew Dillon * $FreeBSD$
27f186073cSJoerg Sonnenberger */
28841ab66cSSepherosa Ziehau #ifndef _NET80211_IEEE80211_PROTO_H_
29841ab66cSSepherosa Ziehau #define _NET80211_IEEE80211_PROTO_H_
30f186073cSJoerg Sonnenberger
31f186073cSJoerg Sonnenberger /*
32f186073cSJoerg Sonnenberger * 802.11 protocol implementation definitions.
33f186073cSJoerg Sonnenberger */
34f186073cSJoerg Sonnenberger
35f186073cSJoerg Sonnenberger enum ieee80211_state {
36f186073cSJoerg Sonnenberger IEEE80211_S_INIT = 0, /* default state */
37f186073cSJoerg Sonnenberger IEEE80211_S_SCAN = 1, /* scanning */
38f186073cSJoerg Sonnenberger IEEE80211_S_AUTH = 2, /* try to authenticate */
39f186073cSJoerg Sonnenberger IEEE80211_S_ASSOC = 3, /* try to assoc */
4032176cfdSRui Paulo IEEE80211_S_CAC = 4, /* doing channel availability check */
4132176cfdSRui Paulo IEEE80211_S_RUN = 5, /* operational (e.g. associated) */
4232176cfdSRui Paulo IEEE80211_S_CSA = 6, /* channel switch announce pending */
4332176cfdSRui Paulo IEEE80211_S_SLEEP = 7, /* power save */
44f186073cSJoerg Sonnenberger };
4532176cfdSRui Paulo #define IEEE80211_S_MAX (IEEE80211_S_SLEEP+1)
46f186073cSJoerg Sonnenberger
4732176cfdSRui Paulo #define IEEE80211_SEND_MGMT(_ni,_type,_arg) \
4832176cfdSRui Paulo ((*(_ni)->ni_ic->ic_send_mgmt)(_ni, _type, _arg))
49f186073cSJoerg Sonnenberger
50*4f655ef5SMatthew Dillon extern const char *mgt_subtype_name[];
51*4f655ef5SMatthew Dillon extern const char *ctl_subtype_name[];
5232176cfdSRui Paulo extern const char *ieee80211_phymode_name[IEEE80211_MODE_MAX];
5332176cfdSRui Paulo extern const int ieee80211_opcap[IEEE80211_OPMODE_MAX];
54f186073cSJoerg Sonnenberger
55*4f655ef5SMatthew Dillon static __inline const char *
ieee80211_mgt_subtype_name(uint8_t subtype)56*4f655ef5SMatthew Dillon ieee80211_mgt_subtype_name(uint8_t subtype)
57*4f655ef5SMatthew Dillon {
58*4f655ef5SMatthew Dillon return mgt_subtype_name[(subtype & IEEE80211_FC0_SUBTYPE_MASK) >>
59*4f655ef5SMatthew Dillon IEEE80211_FC0_SUBTYPE_SHIFT];
60*4f655ef5SMatthew Dillon }
61*4f655ef5SMatthew Dillon
62*4f655ef5SMatthew Dillon static __inline const char *
ieee80211_ctl_subtype_name(uint8_t subtype)63*4f655ef5SMatthew Dillon ieee80211_ctl_subtype_name(uint8_t subtype)
64*4f655ef5SMatthew Dillon {
65*4f655ef5SMatthew Dillon return ctl_subtype_name[(subtype & IEEE80211_FC0_SUBTYPE_MASK) >>
66*4f655ef5SMatthew Dillon IEEE80211_FC0_SUBTYPE_SHIFT];
67*4f655ef5SMatthew Dillon }
68*4f655ef5SMatthew Dillon
69*4f655ef5SMatthew Dillon const char *ieee80211_reason_to_string(uint16_t);
70*4f655ef5SMatthew Dillon
71841ab66cSSepherosa Ziehau void ieee80211_proto_attach(struct ieee80211com *);
72841ab66cSSepherosa Ziehau void ieee80211_proto_detach(struct ieee80211com *);
7332176cfdSRui Paulo void ieee80211_proto_vattach(struct ieee80211vap *);
7432176cfdSRui Paulo void ieee80211_proto_vdetach(struct ieee80211vap *);
75f186073cSJoerg Sonnenberger
76*4f655ef5SMatthew Dillon #if defined(__DragonFly__)
77*4f655ef5SMatthew Dillon void ieee80211_promisc(struct ieee80211vap *, int);
78*4f655ef5SMatthew Dillon void ieee80211_allmulti(struct ieee80211vap *, int);
79*4f655ef5SMatthew Dillon #else
80*4f655ef5SMatthew Dillon void ieee80211_promisc(struct ieee80211vap *, bool);
81*4f655ef5SMatthew Dillon void ieee80211_allmulti(struct ieee80211vap *, bool);
82*4f655ef5SMatthew Dillon #endif
8332176cfdSRui Paulo void ieee80211_syncflag(struct ieee80211vap *, int flag);
8432176cfdSRui Paulo void ieee80211_syncflag_ht(struct ieee80211vap *, int flag);
8532176cfdSRui Paulo void ieee80211_syncflag_ext(struct ieee80211vap *, int flag);
8632176cfdSRui Paulo
87085ff963SMatthew Dillon #if defined(__DragonFly__)
88085ff963SMatthew Dillon struct route;
89085ff963SMatthew Dillon #endif
90085ff963SMatthew Dillon
9132176cfdSRui Paulo #define ieee80211_input(ni, m, rssi, nf) \
924f898719SImre Vadász ((ni)->ni_vap->iv_input(ni, m, NULL, rssi, nf))
9332176cfdSRui Paulo int ieee80211_input_all(struct ieee80211com *, struct mbuf *, int, int);
94085ff963SMatthew Dillon
95085ff963SMatthew Dillon int ieee80211_input_mimo(struct ieee80211_node *, struct mbuf *,
96085ff963SMatthew Dillon struct ieee80211_rx_stats *);
97085ff963SMatthew Dillon int ieee80211_input_mimo_all(struct ieee80211com *, struct mbuf *,
98085ff963SMatthew Dillon struct ieee80211_rx_stats *);
99085ff963SMatthew Dillon
10032176cfdSRui Paulo struct ieee80211_bpf_params;
10132176cfdSRui Paulo int ieee80211_mgmt_output(struct ieee80211_node *, struct mbuf *, int,
10232176cfdSRui Paulo struct ieee80211_bpf_params *);
10332176cfdSRui Paulo int ieee80211_raw_xmit(struct ieee80211_node *, struct mbuf *,
10432176cfdSRui Paulo const struct ieee80211_bpf_params *);
105085ff963SMatthew Dillon #if defined(__DragonFly__)
10632176cfdSRui Paulo int ieee80211_output(struct ifnet *, struct mbuf *,
10734a60cf6SRui Paulo struct sockaddr *, struct rtentry *rt);
108085ff963SMatthew Dillon #else
109085ff963SMatthew Dillon int ieee80211_output(struct ifnet *, struct mbuf *,
110294727bfSImre Vadász const struct sockaddr *, struct route *ro);
111085ff963SMatthew Dillon #endif
112085ff963SMatthew Dillon int ieee80211_vap_pkt_send_dest(struct ieee80211vap *, struct mbuf *,
113085ff963SMatthew Dillon struct ieee80211_node *);
114085ff963SMatthew Dillon int ieee80211_raw_output(struct ieee80211vap *, struct ieee80211_node *,
115085ff963SMatthew Dillon struct mbuf *, const struct ieee80211_bpf_params *);
11632176cfdSRui Paulo void ieee80211_send_setup(struct ieee80211_node *, struct mbuf *, int, int,
11732176cfdSRui Paulo const uint8_t [IEEE80211_ADDR_LEN], const uint8_t [IEEE80211_ADDR_LEN],
11832176cfdSRui Paulo const uint8_t [IEEE80211_ADDR_LEN]);
119*4f655ef5SMatthew Dillon #if defined(__DragonFly__)
120085ff963SMatthew Dillon void ieee80211_vap_start(struct ifnet *ifp, struct ifaltq_subque *ifsq);
121*4f655ef5SMatthew Dillon #endif
122085ff963SMatthew Dillon int ieee80211_vap_transmit(struct ifnet *ifp, struct mbuf *m);
123085ff963SMatthew Dillon void ieee80211_vap_qflush(struct ifnet *ifp);
124841ab66cSSepherosa Ziehau int ieee80211_send_nulldata(struct ieee80211_node *);
12532176cfdSRui Paulo int ieee80211_classify(struct ieee80211_node *, struct mbuf *m);
12632176cfdSRui Paulo struct mbuf *ieee80211_mbuf_adjust(struct ieee80211vap *, int,
12732176cfdSRui Paulo struct ieee80211_key *, struct mbuf *);
12832176cfdSRui Paulo struct mbuf *ieee80211_encap(struct ieee80211vap *, struct ieee80211_node *,
12932176cfdSRui Paulo struct mbuf *);
130*4f655ef5SMatthew Dillon void ieee80211_free_mbuf(struct mbuf *);
13132176cfdSRui Paulo int ieee80211_send_mgmt(struct ieee80211_node *, int, int);
13232176cfdSRui Paulo struct ieee80211_appie;
133841ab66cSSepherosa Ziehau int ieee80211_send_probereq(struct ieee80211_node *ni,
134841ab66cSSepherosa Ziehau const uint8_t sa[IEEE80211_ADDR_LEN],
135841ab66cSSepherosa Ziehau const uint8_t da[IEEE80211_ADDR_LEN],
136841ab66cSSepherosa Ziehau const uint8_t bssid[IEEE80211_ADDR_LEN],
13732176cfdSRui Paulo const uint8_t *ssid, size_t ssidlen);
138085ff963SMatthew Dillon struct mbuf * ieee80211_ff_encap1(struct ieee80211vap *, struct mbuf *,
139085ff963SMatthew Dillon const struct ether_header *);
1407115973eSMatthew Dillon void ieee80211_tx_complete(struct ieee80211_node *,
1417115973eSMatthew Dillon struct mbuf *, int);
1427115973eSMatthew Dillon
14332176cfdSRui Paulo /*
14432176cfdSRui Paulo * The formation of ProbeResponse frames requires guidance to
14532176cfdSRui Paulo * deal with legacy clients. When the client is identified as
14632176cfdSRui Paulo * "legacy 11b" ieee80211_send_proberesp is passed this token.
14732176cfdSRui Paulo */
14832176cfdSRui Paulo #define IEEE80211_SEND_LEGACY_11B 0x1 /* legacy 11b client */
14932176cfdSRui Paulo #define IEEE80211_SEND_LEGACY_11 0x2 /* other legacy client */
15032176cfdSRui Paulo #define IEEE80211_SEND_LEGACY 0x3 /* any legacy client */
15132176cfdSRui Paulo struct mbuf *ieee80211_alloc_proberesp(struct ieee80211_node *, int);
15232176cfdSRui Paulo int ieee80211_send_proberesp(struct ieee80211vap *,
15332176cfdSRui Paulo const uint8_t da[IEEE80211_ADDR_LEN], int);
15432176cfdSRui Paulo struct mbuf *ieee80211_alloc_rts(struct ieee80211com *ic,
15532176cfdSRui Paulo const uint8_t [IEEE80211_ADDR_LEN],
15632176cfdSRui Paulo const uint8_t [IEEE80211_ADDR_LEN], uint16_t);
15732176cfdSRui Paulo struct mbuf *ieee80211_alloc_cts(struct ieee80211com *,
15832176cfdSRui Paulo const uint8_t [IEEE80211_ADDR_LEN], uint16_t);
15932176cfdSRui Paulo
16032176cfdSRui Paulo uint8_t *ieee80211_add_rates(uint8_t *, const struct ieee80211_rateset *);
16132176cfdSRui Paulo uint8_t *ieee80211_add_xrates(uint8_t *, const struct ieee80211_rateset *);
162*4f655ef5SMatthew Dillon uint8_t *ieee80211_add_ssid(uint8_t *, const uint8_t *, u_int);
163085ff963SMatthew Dillon uint8_t *ieee80211_add_wpa(uint8_t *, const struct ieee80211vap *);
164085ff963SMatthew Dillon uint8_t *ieee80211_add_rsn(uint8_t *, const struct ieee80211vap *);
165085ff963SMatthew Dillon uint8_t *ieee80211_add_qos(uint8_t *, const struct ieee80211_node *);
16632176cfdSRui Paulo uint16_t ieee80211_getcapinfo(struct ieee80211vap *,
16732176cfdSRui Paulo struct ieee80211_channel *);
168*4f655ef5SMatthew Dillon struct ieee80211_wme_state;
169*4f655ef5SMatthew Dillon uint8_t * ieee80211_add_wme_info(uint8_t *frm, struct ieee80211_wme_state *wme);
170841ab66cSSepherosa Ziehau
171841ab66cSSepherosa Ziehau void ieee80211_reset_erp(struct ieee80211com *);
17232176cfdSRui Paulo void ieee80211_set_shortslottime(struct ieee80211com *, int onoff);
17332176cfdSRui Paulo int ieee80211_iserp_rateset(const struct ieee80211_rateset *);
17432176cfdSRui Paulo void ieee80211_setbasicrates(struct ieee80211_rateset *,
17532176cfdSRui Paulo enum ieee80211_phymode);
17632176cfdSRui Paulo void ieee80211_addbasicrates(struct ieee80211_rateset *,
17732176cfdSRui Paulo enum ieee80211_phymode);
178841ab66cSSepherosa Ziehau
179841ab66cSSepherosa Ziehau /*
180841ab66cSSepherosa Ziehau * Return the size of the 802.11 header for a management or data frame.
181841ab66cSSepherosa Ziehau */
182841ab66cSSepherosa Ziehau static __inline int
ieee80211_hdrsize(const void * data)183841ab66cSSepherosa Ziehau ieee80211_hdrsize(const void *data)
184841ab66cSSepherosa Ziehau {
185841ab66cSSepherosa Ziehau const struct ieee80211_frame *wh = data;
186841ab66cSSepherosa Ziehau int size = sizeof(struct ieee80211_frame);
187841ab66cSSepherosa Ziehau
188841ab66cSSepherosa Ziehau /* NB: we don't handle control frames */
189841ab66cSSepherosa Ziehau KASSERT((wh->i_fc[0]&IEEE80211_FC0_TYPE_MASK) != IEEE80211_FC0_TYPE_CTL,
190841ab66cSSepherosa Ziehau ("%s: control frame", __func__));
19132176cfdSRui Paulo if (IEEE80211_IS_DSTODS(wh))
192841ab66cSSepherosa Ziehau size += IEEE80211_ADDR_LEN;
193841ab66cSSepherosa Ziehau if (IEEE80211_QOS_HAS_SEQ(wh))
194841ab66cSSepherosa Ziehau size += sizeof(uint16_t);
195841ab66cSSepherosa Ziehau return size;
196841ab66cSSepherosa Ziehau }
197841ab66cSSepherosa Ziehau
198841ab66cSSepherosa Ziehau /*
19932176cfdSRui Paulo * Like ieee80211_hdrsize, but handles any type of frame.
200841ab66cSSepherosa Ziehau */
201841ab66cSSepherosa Ziehau static __inline int
ieee80211_anyhdrsize(const void * data)202841ab66cSSepherosa Ziehau ieee80211_anyhdrsize(const void *data)
203841ab66cSSepherosa Ziehau {
204841ab66cSSepherosa Ziehau const struct ieee80211_frame *wh = data;
205841ab66cSSepherosa Ziehau
206841ab66cSSepherosa Ziehau if ((wh->i_fc[0]&IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_CTL) {
207841ab66cSSepherosa Ziehau switch (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) {
208841ab66cSSepherosa Ziehau case IEEE80211_FC0_SUBTYPE_CTS:
209841ab66cSSepherosa Ziehau case IEEE80211_FC0_SUBTYPE_ACK:
210841ab66cSSepherosa Ziehau return sizeof(struct ieee80211_frame_ack);
21132176cfdSRui Paulo case IEEE80211_FC0_SUBTYPE_BAR:
21232176cfdSRui Paulo return sizeof(struct ieee80211_frame_bar);
213841ab66cSSepherosa Ziehau }
214841ab66cSSepherosa Ziehau return sizeof(struct ieee80211_frame_min);
215841ab66cSSepherosa Ziehau } else
216841ab66cSSepherosa Ziehau return ieee80211_hdrsize(data);
217841ab66cSSepherosa Ziehau }
218841ab66cSSepherosa Ziehau
219841ab66cSSepherosa Ziehau /*
220841ab66cSSepherosa Ziehau * Template for an in-kernel authenticator. Authenticators
221841ab66cSSepherosa Ziehau * register with the protocol code and are typically loaded
22232176cfdSRui Paulo * as separate modules as needed. One special authenticator
22332176cfdSRui Paulo * is xauth; it intercepts requests so that protocols like
22432176cfdSRui Paulo * WPA can be handled in user space.
225841ab66cSSepherosa Ziehau */
226841ab66cSSepherosa Ziehau struct ieee80211_authenticator {
227841ab66cSSepherosa Ziehau const char *ia_name; /* printable name */
22832176cfdSRui Paulo int (*ia_attach)(struct ieee80211vap *);
22932176cfdSRui Paulo void (*ia_detach)(struct ieee80211vap *);
23032176cfdSRui Paulo void (*ia_node_join)(struct ieee80211_node *);
23132176cfdSRui Paulo void (*ia_node_leave)(struct ieee80211_node *);
232841ab66cSSepherosa Ziehau };
233841ab66cSSepherosa Ziehau void ieee80211_authenticator_register(int type,
234841ab66cSSepherosa Ziehau const struct ieee80211_authenticator *);
235841ab66cSSepherosa Ziehau void ieee80211_authenticator_unregister(int type);
236841ab66cSSepherosa Ziehau const struct ieee80211_authenticator *ieee80211_authenticator_get(int auth);
237841ab66cSSepherosa Ziehau
238841ab66cSSepherosa Ziehau struct ieee80211req;
239841ab66cSSepherosa Ziehau /*
240841ab66cSSepherosa Ziehau * Template for an MAC ACL policy module. Such modules
241841ab66cSSepherosa Ziehau * register with the protocol code and are passed the sender's
24232176cfdSRui Paulo * address of each received auth frame for validation.
243841ab66cSSepherosa Ziehau */
244841ab66cSSepherosa Ziehau struct ieee80211_aclator {
245841ab66cSSepherosa Ziehau const char *iac_name; /* printable name */
24632176cfdSRui Paulo int (*iac_attach)(struct ieee80211vap *);
24732176cfdSRui Paulo void (*iac_detach)(struct ieee80211vap *);
24832176cfdSRui Paulo int (*iac_check)(struct ieee80211vap *,
249085ff963SMatthew Dillon const struct ieee80211_frame *wh);
25032176cfdSRui Paulo int (*iac_add)(struct ieee80211vap *,
251841ab66cSSepherosa Ziehau const uint8_t mac[IEEE80211_ADDR_LEN]);
25232176cfdSRui Paulo int (*iac_remove)(struct ieee80211vap *,
253841ab66cSSepherosa Ziehau const uint8_t mac[IEEE80211_ADDR_LEN]);
25432176cfdSRui Paulo int (*iac_flush)(struct ieee80211vap *);
25532176cfdSRui Paulo int (*iac_setpolicy)(struct ieee80211vap *, int);
25632176cfdSRui Paulo int (*iac_getpolicy)(struct ieee80211vap *);
25732176cfdSRui Paulo int (*iac_setioctl)(struct ieee80211vap *, struct ieee80211req *);
25832176cfdSRui Paulo int (*iac_getioctl)(struct ieee80211vap *, struct ieee80211req *);
259841ab66cSSepherosa Ziehau };
260841ab66cSSepherosa Ziehau void ieee80211_aclator_register(const struct ieee80211_aclator *);
261841ab66cSSepherosa Ziehau void ieee80211_aclator_unregister(const struct ieee80211_aclator *);
262841ab66cSSepherosa Ziehau const struct ieee80211_aclator *ieee80211_aclator_get(const char *name);
263841ab66cSSepherosa Ziehau
264841ab66cSSepherosa Ziehau /* flags for ieee80211_fix_rate() */
265841ab66cSSepherosa Ziehau #define IEEE80211_F_DOSORT 0x00000001 /* sort rate list */
26632176cfdSRui Paulo #define IEEE80211_F_DOFRATE 0x00000002 /* use fixed legacy rate */
267841ab66cSSepherosa Ziehau #define IEEE80211_F_DONEGO 0x00000004 /* calc negotiated rate */
268841ab66cSSepherosa Ziehau #define IEEE80211_F_DODEL 0x00000008 /* delete ignore rate */
26932176cfdSRui Paulo #define IEEE80211_F_DOBRS 0x00000010 /* check basic rate set */
27032176cfdSRui Paulo #define IEEE80211_F_JOIN 0x00000020 /* sta joining our bss */
27132176cfdSRui Paulo #define IEEE80211_F_DOFMCS 0x00000040 /* use fixed HT rate */
27232176cfdSRui Paulo int ieee80211_fix_rate(struct ieee80211_node *,
27332176cfdSRui Paulo struct ieee80211_rateset *, int);
274841ab66cSSepherosa Ziehau
275841ab66cSSepherosa Ziehau /*
276841ab66cSSepherosa Ziehau * WME/WMM support.
277841ab66cSSepherosa Ziehau */
278841ab66cSSepherosa Ziehau struct wmeParams {
279841ab66cSSepherosa Ziehau uint8_t wmep_acm;
280841ab66cSSepherosa Ziehau uint8_t wmep_aifsn;
281841ab66cSSepherosa Ziehau uint8_t wmep_logcwmin; /* log2(cwmin) */
282841ab66cSSepherosa Ziehau uint8_t wmep_logcwmax; /* log2(cwmax) */
283841ab66cSSepherosa Ziehau uint8_t wmep_txopLimit;
284841ab66cSSepherosa Ziehau uint8_t wmep_noackPolicy; /* 0 (ack), 1 (no ack) */
285841ab66cSSepherosa Ziehau };
286841ab66cSSepherosa Ziehau #define IEEE80211_TXOP_TO_US(_txop) ((_txop)<<5)
287841ab66cSSepherosa Ziehau #define IEEE80211_US_TO_TXOP(_us) ((_us)>>5)
288841ab66cSSepherosa Ziehau
289841ab66cSSepherosa Ziehau struct chanAccParams {
290841ab66cSSepherosa Ziehau uint8_t cap_info; /* version of the current set */
291841ab66cSSepherosa Ziehau struct wmeParams cap_wmeParams[WME_NUM_AC];
292841ab66cSSepherosa Ziehau };
293841ab66cSSepherosa Ziehau
294841ab66cSSepherosa Ziehau struct ieee80211_wme_state {
295841ab66cSSepherosa Ziehau u_int wme_flags;
296*4f655ef5SMatthew Dillon #define WME_F_AGGRMODE 0x00000001 /* STATUS: WME aggressive mode */
297841ab66cSSepherosa Ziehau u_int wme_hipri_traffic; /* VI/VO frames in beacon interval */
298*4f655ef5SMatthew Dillon u_int wme_hipri_switch_thresh;/* aggressive mode switch thresh */
299*4f655ef5SMatthew Dillon u_int wme_hipri_switch_hysteresis;/* aggressive mode switch hysteresis */
300841ab66cSSepherosa Ziehau
301841ab66cSSepherosa Ziehau struct wmeParams wme_params[4]; /* from assoc resp for each AC*/
302841ab66cSSepherosa Ziehau struct chanAccParams wme_wmeChanParams; /* WME params applied to self */
303841ab66cSSepherosa Ziehau struct chanAccParams wme_wmeBssChanParams;/* WME params bcast to stations */
304841ab66cSSepherosa Ziehau struct chanAccParams wme_chanParams; /* params applied to self */
305841ab66cSSepherosa Ziehau struct chanAccParams wme_bssChanParams; /* params bcast to stations */
306841ab66cSSepherosa Ziehau
307841ab66cSSepherosa Ziehau int (*wme_update)(struct ieee80211com *);
308841ab66cSSepherosa Ziehau };
309841ab66cSSepherosa Ziehau
31032176cfdSRui Paulo void ieee80211_wme_initparams(struct ieee80211vap *);
31132176cfdSRui Paulo void ieee80211_wme_updateparams(struct ieee80211vap *);
31232176cfdSRui Paulo void ieee80211_wme_updateparams_locked(struct ieee80211vap *);
313841ab66cSSepherosa Ziehau
31432176cfdSRui Paulo /*
31532176cfdSRui Paulo * Return the WME TID from a QoS frame. If no TID
31632176cfdSRui Paulo * is present return the index for the "non-QoS" entry.
31732176cfdSRui Paulo */
31832176cfdSRui Paulo static __inline uint8_t
ieee80211_gettid(const struct ieee80211_frame * wh)31932176cfdSRui Paulo ieee80211_gettid(const struct ieee80211_frame *wh)
32032176cfdSRui Paulo {
32132176cfdSRui Paulo uint8_t tid;
32232176cfdSRui Paulo
32332176cfdSRui Paulo if (IEEE80211_QOS_HAS_SEQ(wh)) {
32432176cfdSRui Paulo if (IEEE80211_IS_DSTODS(wh))
32532176cfdSRui Paulo tid = ((const struct ieee80211_qosframe_addr4 *)wh)->
32632176cfdSRui Paulo i_qos[0];
32732176cfdSRui Paulo else
32832176cfdSRui Paulo tid = ((const struct ieee80211_qosframe *)wh)->i_qos[0];
32932176cfdSRui Paulo tid &= IEEE80211_QOS_TID;
33032176cfdSRui Paulo } else
33132176cfdSRui Paulo tid = IEEE80211_NONQOS_TID;
33232176cfdSRui Paulo return tid;
33332176cfdSRui Paulo }
33432176cfdSRui Paulo
33532176cfdSRui Paulo void ieee80211_waitfor_parent(struct ieee80211com *);
33632176cfdSRui Paulo void ieee80211_start_locked(struct ieee80211vap *);
33732176cfdSRui Paulo void ieee80211_init(void *);
33832176cfdSRui Paulo void ieee80211_start_all(struct ieee80211com *);
33932176cfdSRui Paulo void ieee80211_stop_locked(struct ieee80211vap *);
34032176cfdSRui Paulo void ieee80211_stop(struct ieee80211vap *);
34132176cfdSRui Paulo void ieee80211_stop_all(struct ieee80211com *);
34232176cfdSRui Paulo void ieee80211_suspend_all(struct ieee80211com *);
34332176cfdSRui Paulo void ieee80211_resume_all(struct ieee80211com *);
344*4f655ef5SMatthew Dillon void ieee80211_restart_all(struct ieee80211com *);
34532176cfdSRui Paulo void ieee80211_dturbo_switch(struct ieee80211vap *, int newflags);
346085ff963SMatthew Dillon void ieee80211_swbmiss(void *arg);
347841ab66cSSepherosa Ziehau void ieee80211_beacon_miss(struct ieee80211com *);
34832176cfdSRui Paulo int ieee80211_new_state(struct ieee80211vap *, enum ieee80211_state, int);
349d98a0bcfSMatthew Dillon int ieee80211_new_state_locked(struct ieee80211vap *, enum ieee80211_state,
350d98a0bcfSMatthew Dillon int);
351841ab66cSSepherosa Ziehau void ieee80211_print_essid(const uint8_t *, int);
35232176cfdSRui Paulo void ieee80211_dump_pkt(struct ieee80211com *,
35332176cfdSRui Paulo const uint8_t *, int, int, int);
354f186073cSJoerg Sonnenberger
35532176cfdSRui Paulo extern const char *ieee80211_opmode_name[];
356f186073cSJoerg Sonnenberger extern const char *ieee80211_state_name[IEEE80211_S_MAX];
357841ab66cSSepherosa Ziehau extern const char *ieee80211_wme_acnames[];
358841ab66cSSepherosa Ziehau
359841ab66cSSepherosa Ziehau /*
360841ab66cSSepherosa Ziehau * Beacon frames constructed by ieee80211_beacon_alloc
361841ab66cSSepherosa Ziehau * have the following structure filled in so drivers
362841ab66cSSepherosa Ziehau * can update the frame later w/ minimal overhead.
363841ab66cSSepherosa Ziehau */
364841ab66cSSepherosa Ziehau struct ieee80211_beacon_offsets {
36532176cfdSRui Paulo uint8_t bo_flags[4]; /* update/state flags */
366841ab66cSSepherosa Ziehau uint16_t *bo_caps; /* capabilities */
36732176cfdSRui Paulo uint8_t *bo_cfp; /* start of CFParms element */
368841ab66cSSepherosa Ziehau uint8_t *bo_tim; /* start of atim/dtim */
369841ab66cSSepherosa Ziehau uint8_t *bo_wme; /* start of WME parameters */
37032176cfdSRui Paulo uint8_t *bo_tdma; /* start of TDMA parameters */
37132176cfdSRui Paulo uint8_t *bo_tim_trailer;/* start of fixed-size trailer */
372841ab66cSSepherosa Ziehau uint16_t bo_tim_len; /* atim/dtim length in bytes */
37332176cfdSRui Paulo uint16_t bo_tim_trailer_len;/* tim trailer length in bytes */
374841ab66cSSepherosa Ziehau uint8_t *bo_erp; /* start of ERP element */
37532176cfdSRui Paulo uint8_t *bo_htinfo; /* start of HT info element */
37632176cfdSRui Paulo uint8_t *bo_ath; /* start of ATH parameters */
37732176cfdSRui Paulo uint8_t *bo_appie; /* start of AppIE element */
37832176cfdSRui Paulo uint16_t bo_appie_len; /* AppIE length in bytes */
37932176cfdSRui Paulo uint16_t bo_csa_trailer_len;
38032176cfdSRui Paulo uint8_t *bo_csa; /* start of CSA element */
381085ff963SMatthew Dillon uint8_t *bo_quiet; /* start of Quiet element */
38232176cfdSRui Paulo uint8_t *bo_meshconf; /* start of MESHCONF element */
38332176cfdSRui Paulo uint8_t *bo_spare[3];
384841ab66cSSepherosa Ziehau };
385*4f655ef5SMatthew Dillon struct mbuf *ieee80211_beacon_alloc(struct ieee80211_node *);
386841ab66cSSepherosa Ziehau
38732176cfdSRui Paulo /*
38832176cfdSRui Paulo * Beacon frame updates are signaled through calls to iv_update_beacon
38932176cfdSRui Paulo * with one of the IEEE80211_BEACON_* tokens defined below. For devices
39032176cfdSRui Paulo * that construct beacon frames on the host this can trigger a rebuild
39132176cfdSRui Paulo * or defer the processing. For devices that offload beacon frame
39232176cfdSRui Paulo * handling this callback can be used to signal a rebuild. The bo_flags
39332176cfdSRui Paulo * array in the ieee80211_beacon_offsets structure is intended to record
39432176cfdSRui Paulo * deferred processing requirements; ieee80211_beacon_update uses the
39532176cfdSRui Paulo * state to optimize work. Since this structure is owned by the driver
39632176cfdSRui Paulo * and not visible to the 802.11 layer drivers must supply an iv_update_beacon
39732176cfdSRui Paulo * callback that marks the flag bits and schedules (as necessary) an update.
39832176cfdSRui Paulo */
39932176cfdSRui Paulo enum {
40032176cfdSRui Paulo IEEE80211_BEACON_CAPS = 0, /* capabilities */
40132176cfdSRui Paulo IEEE80211_BEACON_TIM = 1, /* DTIM/ATIM */
40232176cfdSRui Paulo IEEE80211_BEACON_WME = 2,
40332176cfdSRui Paulo IEEE80211_BEACON_ERP = 3, /* Extended Rate Phy */
40432176cfdSRui Paulo IEEE80211_BEACON_HTINFO = 4, /* HT Information */
40532176cfdSRui Paulo IEEE80211_BEACON_APPIE = 5, /* Application IE's */
40632176cfdSRui Paulo IEEE80211_BEACON_CFP = 6, /* CFParms */
40732176cfdSRui Paulo IEEE80211_BEACON_CSA = 7, /* Channel Switch Announcement */
40832176cfdSRui Paulo IEEE80211_BEACON_TDMA = 9, /* TDMA Info */
40932176cfdSRui Paulo IEEE80211_BEACON_ATH = 10, /* ATH parameters */
41032176cfdSRui Paulo IEEE80211_BEACON_MESHCONF = 11, /* Mesh Configuration */
41132176cfdSRui Paulo };
41232176cfdSRui Paulo int ieee80211_beacon_update(struct ieee80211_node *,
413*4f655ef5SMatthew Dillon struct mbuf *, int mcast);
4143da93495SSepherosa Ziehau
41532176cfdSRui Paulo void ieee80211_csa_startswitch(struct ieee80211com *,
41632176cfdSRui Paulo struct ieee80211_channel *, int mode, int count);
41732176cfdSRui Paulo void ieee80211_csa_completeswitch(struct ieee80211com *);
41832176cfdSRui Paulo void ieee80211_csa_cancelswitch(struct ieee80211com *);
41932176cfdSRui Paulo void ieee80211_cac_completeswitch(struct ieee80211vap *);
4202d7dda79SSepherosa Ziehau
421841ab66cSSepherosa Ziehau /*
422841ab66cSSepherosa Ziehau * Notification methods called from the 802.11 state machine.
423841ab66cSSepherosa Ziehau * Note that while these are defined here, their implementation
424841ab66cSSepherosa Ziehau * is OS-specific.
425841ab66cSSepherosa Ziehau */
42632176cfdSRui Paulo void ieee80211_notify_node_join(struct ieee80211_node *, int newassoc);
42732176cfdSRui Paulo void ieee80211_notify_node_leave(struct ieee80211_node *);
42832176cfdSRui Paulo void ieee80211_notify_scan_done(struct ieee80211vap *);
42932176cfdSRui Paulo void ieee80211_notify_wds_discover(struct ieee80211_node *);
43032176cfdSRui Paulo void ieee80211_notify_csa(struct ieee80211com *,
43132176cfdSRui Paulo const struct ieee80211_channel *, int mode, int count);
43232176cfdSRui Paulo void ieee80211_notify_radar(struct ieee80211com *,
43332176cfdSRui Paulo const struct ieee80211_channel *);
43432176cfdSRui Paulo enum ieee80211_notify_cac_event {
43532176cfdSRui Paulo IEEE80211_NOTIFY_CAC_START = 0, /* CAC timer started */
43632176cfdSRui Paulo IEEE80211_NOTIFY_CAC_STOP = 1, /* CAC intentionally stopped */
43732176cfdSRui Paulo IEEE80211_NOTIFY_CAC_RADAR = 2, /* CAC stopped due to radar detectio */
43832176cfdSRui Paulo IEEE80211_NOTIFY_CAC_EXPIRE = 3, /* CAC expired w/o radar */
43932176cfdSRui Paulo };
44032176cfdSRui Paulo void ieee80211_notify_cac(struct ieee80211com *,
44132176cfdSRui Paulo const struct ieee80211_channel *,
44232176cfdSRui Paulo enum ieee80211_notify_cac_event);
44332176cfdSRui Paulo void ieee80211_notify_node_deauth(struct ieee80211_node *);
44432176cfdSRui Paulo void ieee80211_notify_node_auth(struct ieee80211_node *);
44532176cfdSRui Paulo void ieee80211_notify_country(struct ieee80211vap *, const uint8_t [],
44632176cfdSRui Paulo const uint8_t cc[2]);
44732176cfdSRui Paulo void ieee80211_notify_radio(struct ieee80211com *, int);
448841ab66cSSepherosa Ziehau #endif /* _NET80211_IEEE80211_PROTO_H_ */
449