2 * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 * $FreeBSD: head/sys/net80211/ieee80211_wds.c 203422 2010-02-03 10:07:43Z rpaulo $
30 * IEEE 802.11 WDS mode support.
35 #include <sys/param.h>
36 #include <sys/systm.h>
38 #include <sys/malloc.h>
39 #include <sys/kernel.h>
41 #include <sys/socket.h>
42 #include <sys/sockio.h>
43 #include <sys/endian.h>
44 #include <sys/errno.h>
46 #include <sys/sysctl.h>
49 #include <net/if_media.h>
50 #include <net/if_llc.h>
51 #include <net/ethernet.h>
52 #include <net/route.h>
56 #include <netproto/802_11/ieee80211_var.h>
57 #include <netproto/802_11/ieee80211_wds.h>
58 #include <netproto/802_11/ieee80211_input.h>
59 #ifdef IEEE80211_SUPPORT_SUPERG
60 #include <netproto/802_11/ieee80211_superg.h>
63 static void wds_vattach(struct ieee80211vap *);
64 static int wds_newstate(struct ieee80211vap *, enum ieee80211_state, int);
65 static int wds_input(struct ieee80211_node *ni, struct mbuf *m, int, int);
66 static void wds_recv_mgmt(struct ieee80211_node *, struct mbuf *,
67 int subtype, int, int);
70 ieee80211_wds_attach(struct ieee80211com *ic)
72 ic->ic_vattach[IEEE80211_M_WDS] = wds_vattach;
76 ieee80211_wds_detach(struct ieee80211com *ic)
81 wds_vdetach(struct ieee80211vap *vap)
83 if (vap->iv_bss != NULL) {
85 if (vap->iv_bss->ni_wdsvap == vap)
86 vap->iv_bss->ni_wdsvap = NULL;
91 wds_vattach(struct ieee80211vap *vap)
93 vap->iv_newstate = wds_newstate;
94 vap->iv_input = wds_input;
95 vap->iv_recv_mgmt = wds_recv_mgmt;
96 vap->iv_opdetach = wds_vdetach;
100 wds_flush(struct ieee80211_node *ni)
102 struct ieee80211com *ic = ni->ni_ic;
103 struct mbuf *m, *next;
106 m = ieee80211_ageq_remove(&ic->ic_stageq,
107 (void *)(uintptr_t) ieee80211_mac_hash(ic, ni->ni_macaddr));
111 IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_WDS, ni,
112 "%s", "flush wds queue");
113 ic->ic_node_getsignal(ni, &rssi, &nf);
114 for (; m != NULL; m = next) {
117 ieee80211_input(ni, m, rssi, nf);
122 ieee80211_create_wds(struct ieee80211vap *vap, struct ieee80211_channel *chan)
124 struct ieee80211com *ic = vap->iv_ic;
125 struct ieee80211_node_table *nt = &ic->ic_sta;
126 struct ieee80211_node *ni, *obss;
128 IEEE80211_DPRINTF(vap, IEEE80211_MSG_WDS,
129 "%s: creating link to %6D on channel %u\n", __func__,
130 vap->iv_des_bssid, ":", ieee80211_chan2ieee(ic, chan));
132 /* NB: vap create must specify the bssid for the link */
133 KASSERT(vap->iv_flags & IEEE80211_F_DESBSSID, ("no bssid"));
134 /* NB: we should only be called on RUN transition */
135 KASSERT(vap->iv_state == IEEE80211_S_RUN, ("!RUN state"));
137 if ((vap->iv_flags_ext & IEEE80211_FEXT_WDSLEGACY) == 0) {
139 * Dynamic/non-legacy WDS. Reference the associated
140 * station specified by the desired bssid setup at vap
141 * create. Point ni_wdsvap at the WDS vap so 4-address
142 * frames received through the associated AP vap will
143 * be dispatched upward (e.g. to a bridge) as though
144 * they arrived on the WDS vap.
146 IEEE80211_NODE_LOCK(nt);
148 ni = ieee80211_find_node_locked(&ic->ic_sta, vap->iv_des_bssid);
151 * Node went away before we could hookup. This
152 * should be ok; no traffic will flow and a leave
153 * event will be dispatched that should cause
154 * the vap to be destroyed.
156 IEEE80211_DPRINTF(vap, IEEE80211_MSG_WDS,
157 "%s: station %6D went away\n",
158 __func__, vap->iv_des_bssid, ":");
160 } else if (ni->ni_wdsvap != NULL) {
162 * Node already setup with a WDS vap; we cannot
163 * allow multiple references so disallow. If
164 * ni_wdsvap points at us that's ok; we should
167 /* XXX printf instead? */
168 IEEE80211_DPRINTF(vap, IEEE80211_MSG_WDS,
169 "%s: station %6D in use with %s\n",
170 __func__, vap->iv_des_bssid, ":",
171 ni->ni_wdsvap->iv_ifp->if_xname);
175 * Committed to new node, setup state.
181 IEEE80211_NODE_UNLOCK(nt);
183 /* NB: deferred to avoid recursive lock */
184 ieee80211_free_node(obss);
188 * Legacy WDS vap setup.
191 * The far end does not associate so we just create
192 * create a new node and install it as the vap's
193 * bss node. We must simulate an association and
194 * authorize the port for traffic to flow.
195 * XXX check if node already in sta table?
197 ni = ieee80211_node_create_wds(vap, vap->iv_des_bssid, chan);
200 vap->iv_bss = ieee80211_ref_node(ni);
201 ni->ni_flags |= IEEE80211_NODE_AREF;
203 ieee80211_free_node(obss);
204 /* give driver a chance to setup state like ni_txrate */
205 if (ic->ic_newassoc != NULL)
206 ic->ic_newassoc(ni, 1);
207 /* tell the authenticator about new station */
208 if (vap->iv_auth->ia_node_join != NULL)
209 vap->iv_auth->ia_node_join(ni);
210 if (ni->ni_authmode != IEEE80211_AUTH_8021X)
211 ieee80211_node_authorize(ni);
213 ieee80211_notify_node_join(ni, 1 /*newassoc*/);
214 /* XXX inject l2uf frame */
219 * Flush any pending frames now that were setup.
223 return (ni == NULL ? ENOENT : 0);
227 * Propagate multicast frames of an ap vap to all DWDS links.
228 * The caller is assumed to have verified this frame is multicast.
231 ieee80211_dwds_mcast(struct ieee80211vap *vap0, struct mbuf *m)
233 struct ieee80211com *ic = vap0->iv_ic;
234 struct ifnet *parent = ic->ic_ifp;
235 const struct ether_header *eh = mtod(m, const struct ether_header *);
236 struct ieee80211_node *ni;
237 struct ieee80211vap *vap;
242 KASSERT(ETHER_IS_MULTICAST(eh->ether_dhost),
243 ("%6D not mcast", eh->ether_dhost, ":"));
246 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
247 /* only DWDS vaps are interesting */
248 if (vap->iv_opmode != IEEE80211_M_WDS ||
249 (vap->iv_flags_ext & IEEE80211_FEXT_WDSLEGACY))
251 /* if it came in this interface, don't send it back out */
253 if (ifp == m->m_pkthdr.rcvif)
256 * Duplicate the frame and send it.
258 mcopy = m_copypacket(m, MB_DONTWAIT);
264 ni = ieee80211_find_txnode(vap, eh->ether_dhost);
266 /* NB: ieee80211_find_txnode does stat+msg */
271 /* calculate priority so drivers can find the tx queue */
272 if (ieee80211_classify(ni, mcopy)) {
273 IEEE80211_DISCARD_MAC(vap,
274 IEEE80211_MSG_OUTPUT | IEEE80211_MSG_WDS,
275 eh->ether_dhost, NULL,
276 "%s", "classification failure");
277 vap->iv_stats.is_tx_classify++;
280 ieee80211_free_node(ni);
284 BPF_MTAP(ifp, m); /* 802.3 tx */
287 * Encapsulate the packet in prep for transmission.
289 mcopy = ieee80211_encap(vap, ni, mcopy);
291 /* NB: stat+msg handled in ieee80211_encap */
292 ieee80211_free_node(ni);
295 mcopy->m_flags |= M_MCAST;
296 mcopy->m_pkthdr.rcvif = (void *) ni;
298 err = parent->if_transmit(parent, mcopy);
300 /* NB: IFQ_HANDOFF reclaims mbuf */
302 ieee80211_free_node(ni);
309 * Handle DWDS discovery on receipt of a 4-address frame in
310 * ap mode. Queue the frame and post an event for someone
311 * to plumb the necessary WDS vap for this station. Frames
312 * received prior to the vap set running will then be reprocessed
313 * as if they were just received.
316 ieee80211_dwds_discover(struct ieee80211_node *ni, struct mbuf *m)
318 struct ieee80211com *ic = ni->ni_ic;
321 * Save the frame with an aging interval 4 times
322 * the listen interval specified by the station.
323 * Frames that sit around too long are reclaimed
324 * using this information.
325 * XXX handle overflow?
326 * XXX per/vap beacon interval?
328 m->m_pkthdr.rcvif = (void *)(uintptr_t)
329 ieee80211_mac_hash(ic, ni->ni_macaddr);
330 (void) ieee80211_ageq_append(&ic->ic_stageq, m,
331 ((ni->ni_intval * ic->ic_lintval) << 2) / 1024);
332 ieee80211_notify_wds_discover(ni);
336 * IEEE80211_M_WDS vap state machine handler.
339 wds_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
341 struct ieee80211com *ic = vap->iv_ic;
342 struct ieee80211_node *ni;
343 enum ieee80211_state ostate;
346 IEEE80211_LOCK_ASSERT(ic);
348 ostate = vap->iv_state;
349 IEEE80211_DPRINTF(vap, IEEE80211_MSG_STATE, "%s: %s -> %s\n", __func__,
350 ieee80211_state_name[ostate], ieee80211_state_name[nstate]);
351 vap->iv_state = nstate; /* state transition */
352 callout_stop(&vap->iv_mgtsend); /* XXX callout_drain */
353 if (ostate != IEEE80211_S_SCAN)
354 ieee80211_cancel_scan(vap); /* background scan */
355 ni = vap->iv_bss; /* NB: no reference held */
358 case IEEE80211_S_INIT:
360 case IEEE80211_S_SCAN:
361 ieee80211_cancel_scan(vap);
366 if (ostate != IEEE80211_S_INIT) {
367 /* NB: optimize INIT -> INIT case */
368 ieee80211_reset_bss(vap);
371 case IEEE80211_S_SCAN:
373 case IEEE80211_S_INIT:
374 ieee80211_check_scan_current(vap);
380 case IEEE80211_S_RUN:
381 if (ostate == IEEE80211_S_INIT) {
383 * Already have a channel; bypass the scan
384 * and startup immediately.
386 error = ieee80211_create_wds(vap, ic->ic_curchan);
396 * Process a received frame. The node associated with the sender
397 * should be supplied. If nothing was found in the node table then
398 * the caller is assumed to supply a reference to iv_bss instead.
399 * The RSSI and a timestamp are also supplied. The RSSI data is used
400 * during AP scanning to select a AP to associate with; it can have
401 * any units so long as values have consistent units and higher values
402 * mean ``better signal''. The receive timestamp is currently not used
403 * by the 802.11 layer.
406 wds_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int nf)
408 #define SEQ_LEQ(a,b) ((int)((a)-(b)) <= 0)
409 #define HAS_SEQ(type) ((type & 0x4) == 0)
410 struct ieee80211vap *vap = ni->ni_vap;
411 struct ieee80211com *ic = ni->ni_ic;
412 struct ifnet *ifp = vap->iv_ifp;
413 struct ieee80211_frame *wh;
414 struct ieee80211_key *key;
415 struct ether_header *eh;
416 int hdrspace, need_tap = 1; /* mbuf need to be tapped. */
417 uint8_t dir, type, subtype, qos;
420 if (m->m_flags & M_AMPDU_MPDU) {
422 * Fastpath for A-MPDU reorder q resubmission. Frames
423 * w/ M_AMPDU_MPDU marked have already passed through
424 * here but were received out of order and been held on
425 * the reorder queue. When resubmitted they are marked
426 * with the M_AMPDU_MPDU flag and we can bypass most of
427 * the normal processing.
429 wh = mtod(m, struct ieee80211_frame *);
430 type = IEEE80211_FC0_TYPE_DATA;
431 dir = wh->i_fc[1] & IEEE80211_FC1_DIR_MASK;
432 subtype = IEEE80211_FC0_SUBTYPE_QOS;
433 hdrspace = ieee80211_hdrspace(ic, wh); /* XXX optimize? */
437 KASSERT(ni != NULL, ("null node"));
439 type = -1; /* undefined */
441 if (m->m_pkthdr.len < sizeof(struct ieee80211_frame_min)) {
442 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY,
443 ni->ni_macaddr, NULL,
444 "too short (1): len %u", m->m_pkthdr.len);
445 vap->iv_stats.is_rx_tooshort++;
449 * Bit of a cheat here, we use a pointer for a 3-address
450 * frame format but don't reference fields past outside
451 * ieee80211_frame_min w/o first validating the data is
454 wh = mtod(m, struct ieee80211_frame *);
456 if ((wh->i_fc[0] & IEEE80211_FC0_VERSION_MASK) !=
457 IEEE80211_FC0_VERSION_0) {
458 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY,
459 ni->ni_macaddr, NULL, "wrong version, fc %02x:%02x",
460 wh->i_fc[0], wh->i_fc[1]);
461 vap->iv_stats.is_rx_badversion++;
465 dir = wh->i_fc[1] & IEEE80211_FC1_DIR_MASK;
466 type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
467 subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK;
469 /* NB: WDS vap's do not scan */
470 if (m->m_pkthdr.len < sizeof(struct ieee80211_frame_addr4)) {
471 IEEE80211_DISCARD_MAC(vap,
472 IEEE80211_MSG_ANY, ni->ni_macaddr, NULL,
473 "too short (3): len %u", m->m_pkthdr.len);
474 vap->iv_stats.is_rx_tooshort++;
477 /* NB: the TA is implicitly verified by finding the wds peer node */
478 if (!IEEE80211_ADDR_EQ(wh->i_addr1, vap->iv_myaddr) &&
479 !IEEE80211_ADDR_EQ(wh->i_addr1, ifp->if_broadcastaddr)) {
480 /* not interested in */
481 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_INPUT,
482 wh->i_addr1, NULL, "%s", "not to bss");
483 vap->iv_stats.is_rx_wrongbss++;
486 IEEE80211_RSSI_LPF(ni->ni_avgrssi, rssi);
489 uint8_t tid = ieee80211_gettid(wh);
490 if (IEEE80211_QOS_HAS_SEQ(wh) &&
491 TID_TO_WME_AC(tid) >= WME_AC_VI)
492 ic->ic_wme.wme_hipri_traffic++;
493 rxseq = le16toh(*(uint16_t *)wh->i_seq);
494 if ((ni->ni_flags & IEEE80211_NODE_HT) == 0 &&
495 (wh->i_fc[1] & IEEE80211_FC1_RETRY) &&
496 SEQ_LEQ(rxseq, ni->ni_rxseqs[tid])) {
497 /* duplicate, discard */
498 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_INPUT,
499 wh->i_addr1, "duplicate",
500 "seqno <%u,%u> fragno <%u,%u> tid %u",
501 rxseq >> IEEE80211_SEQ_SEQ_SHIFT,
502 ni->ni_rxseqs[tid] >> IEEE80211_SEQ_SEQ_SHIFT,
503 rxseq & IEEE80211_SEQ_FRAG_MASK,
504 ni->ni_rxseqs[tid] & IEEE80211_SEQ_FRAG_MASK,
506 vap->iv_stats.is_rx_dup++;
507 IEEE80211_NODE_STAT(ni, rx_dup);
510 ni->ni_rxseqs[tid] = rxseq;
513 case IEEE80211_FC0_TYPE_DATA:
514 hdrspace = ieee80211_hdrspace(ic, wh);
515 if (m->m_len < hdrspace &&
516 (m = m_pullup(m, hdrspace)) == NULL) {
517 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY,
518 ni->ni_macaddr, NULL,
519 "data too short: expecting %u", hdrspace);
520 vap->iv_stats.is_rx_tooshort++;
523 if (dir != IEEE80211_FC1_DIR_DSTODS) {
524 IEEE80211_DISCARD(vap, IEEE80211_MSG_INPUT,
525 wh, "data", "incorrect dir 0x%x", dir);
526 vap->iv_stats.is_rx_wrongdir++;
530 * Only legacy WDS traffic should take this path.
532 if ((vap->iv_flags_ext & IEEE80211_FEXT_WDSLEGACY) == 0) {
533 IEEE80211_DISCARD(vap, IEEE80211_MSG_INPUT,
534 wh, "data", "%s", "not legacy wds");
535 vap->iv_stats.is_rx_wrongdir++;/*XXX*/
538 if (!IEEE80211_IS_MULTICAST(wh->i_addr1))
539 ni->ni_inact = ni->ni_inact_reload;
541 * Handle A-MPDU re-ordering. If the frame is to be
542 * processed directly then ieee80211_ampdu_reorder
543 * will return 0; otherwise it has consumed the mbuf
544 * and we should do nothing more with it.
546 if ((m->m_flags & M_AMPDU) &&
547 ieee80211_ampdu_reorder(ni, m) != 0) {
554 * Handle privacy requirements. Note that we
555 * must not be preempted from here until after
556 * we (potentially) call ieee80211_crypto_demic;
557 * otherwise we may violate assumptions in the
558 * crypto cipher modules used to do delayed update
559 * of replay sequence numbers.
561 if (wh->i_fc[1] & IEEE80211_FC1_WEP) {
562 if ((vap->iv_flags & IEEE80211_F_PRIVACY) == 0) {
564 * Discard encrypted frames when privacy is off.
566 IEEE80211_DISCARD(vap, IEEE80211_MSG_INPUT,
567 wh, "WEP", "%s", "PRIVACY off");
568 vap->iv_stats.is_rx_noprivacy++;
569 IEEE80211_NODE_STAT(ni, rx_noprivacy);
572 key = ieee80211_crypto_decap(ni, m, hdrspace);
574 /* NB: stats+msgs handled in crypto_decap */
575 IEEE80211_NODE_STAT(ni, rx_wepfail);
578 wh = mtod(m, struct ieee80211_frame *);
579 wh->i_fc[1] &= ~IEEE80211_FC1_WEP;
581 /* XXX M_WEP and IEEE80211_F_PRIVACY */
586 * Save QoS bits for use below--before we strip the header.
588 if (subtype == IEEE80211_FC0_SUBTYPE_QOS) {
589 qos = (dir == IEEE80211_FC1_DIR_DSTODS) ?
590 ((struct ieee80211_qosframe_addr4 *)wh)->i_qos[0] :
591 ((struct ieee80211_qosframe *)wh)->i_qos[0];
596 * Next up, any fragmentation.
598 if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) {
599 m = ieee80211_defrag(ni, m, hdrspace);
601 /* Fragment dropped or frame not complete yet */
605 wh = NULL; /* no longer valid, catch any uses */
608 * Next strip any MSDU crypto bits.
610 if (key != NULL && !ieee80211_crypto_demic(vap, key, m, 0)) {
611 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_INPUT,
612 ni->ni_macaddr, "data", "%s", "demic error");
613 vap->iv_stats.is_rx_demicfail++;
614 IEEE80211_NODE_STAT(ni, rx_demicfail);
618 /* copy to listener after decrypt */
619 if (ieee80211_radiotap_active_vap(vap))
620 ieee80211_radiotap_rx(vap, m);
624 * Finally, strip the 802.11 header.
626 m = ieee80211_decap(vap, m, hdrspace);
628 /* XXX mask bit to check for both */
629 /* don't count Null data frames as errors */
630 if (subtype == IEEE80211_FC0_SUBTYPE_NODATA ||
631 subtype == IEEE80211_FC0_SUBTYPE_QOS_NULL)
633 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_INPUT,
634 ni->ni_macaddr, "data", "%s", "decap error");
635 vap->iv_stats.is_rx_decap++;
636 IEEE80211_NODE_STAT(ni, rx_decap);
639 eh = mtod(m, struct ether_header *);
640 if (!ieee80211_node_is_authorized(ni)) {
642 * Deny any non-PAE frames received prior to
643 * authorization. For open/shared-key
644 * authentication the port is mark authorized
645 * after authentication completes. For 802.1x
646 * the port is not marked authorized by the
647 * authenticator until the handshake has completed.
649 if (eh->ether_type != htons(ETHERTYPE_PAE)) {
650 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_INPUT,
651 eh->ether_shost, "data",
652 "unauthorized port: ether type 0x%x len %u",
653 eh->ether_type, m->m_pkthdr.len);
654 vap->iv_stats.is_rx_unauth++;
655 IEEE80211_NODE_STAT(ni, rx_unauth);
660 * When denying unencrypted frames, discard
661 * any non-PAE frames received without encryption.
663 if ((vap->iv_flags & IEEE80211_F_DROPUNENC) &&
664 (key == NULL && (m->m_flags & M_WEP) == 0) &&
665 eh->ether_type != htons(ETHERTYPE_PAE)) {
667 * Drop unencrypted frames.
669 vap->iv_stats.is_rx_unencrypted++;
670 IEEE80211_NODE_STAT(ni, rx_unencrypted);
674 /* XXX require HT? */
675 if (qos & IEEE80211_QOS_AMSDU) {
676 m = ieee80211_decap_amsdu(ni, m);
678 return IEEE80211_FC0_TYPE_DATA;
680 #ifdef IEEE80211_SUPPORT_SUPERG
681 m = ieee80211_decap_fastframe(vap, ni, m);
683 return IEEE80211_FC0_TYPE_DATA;
686 ieee80211_deliver_data(vap, ni, m);
687 return IEEE80211_FC0_TYPE_DATA;
689 case IEEE80211_FC0_TYPE_MGT:
690 vap->iv_stats.is_rx_mgmt++;
691 IEEE80211_NODE_STAT(ni, rx_mgmt);
692 if (dir != IEEE80211_FC1_DIR_NODS) {
693 IEEE80211_DISCARD(vap, IEEE80211_MSG_INPUT,
694 wh, "data", "incorrect dir 0x%x", dir);
695 vap->iv_stats.is_rx_wrongdir++;
698 if (m->m_pkthdr.len < sizeof(struct ieee80211_frame)) {
699 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY,
700 ni->ni_macaddr, "mgt", "too short: len %u",
702 vap->iv_stats.is_rx_tooshort++;
705 #ifdef IEEE80211_DEBUG
706 if (ieee80211_msg_debug(vap) || ieee80211_msg_dumppkts(vap)) {
707 if_printf(ifp, "received %s from %6D rssi %d\n",
708 ieee80211_mgt_subtype_name[subtype >>
709 IEEE80211_FC0_SUBTYPE_SHIFT],
710 wh->i_addr2, ":", rssi);
713 if (wh->i_fc[1] & IEEE80211_FC1_WEP) {
714 IEEE80211_DISCARD(vap, IEEE80211_MSG_INPUT,
715 wh, NULL, "%s", "WEP set but not permitted");
716 vap->iv_stats.is_rx_mgtdiscard++; /* XXX */
719 vap->iv_recv_mgmt(ni, m, subtype, rssi, nf);
722 case IEEE80211_FC0_TYPE_CTL:
723 vap->iv_stats.is_rx_ctl++;
724 IEEE80211_NODE_STAT(ni, rx_ctrl);
728 IEEE80211_DISCARD(vap, IEEE80211_MSG_ANY,
729 wh, "bad", "frame type 0x%x", type);
730 /* should not come here */
737 if (need_tap && ieee80211_radiotap_active_vap(vap))
738 ieee80211_radiotap_rx(vap, m);
746 wds_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m0,
747 int subtype, int rssi, int nf)
749 struct ieee80211vap *vap = ni->ni_vap;
750 struct ieee80211com *ic = ni->ni_ic;
751 struct ieee80211_frame *wh;
752 u_int8_t *frm, *efrm;
754 wh = mtod(m0, struct ieee80211_frame *);
755 frm = (u_int8_t *)&wh[1];
756 efrm = mtod(m0, u_int8_t *) + m0->m_len;
758 case IEEE80211_FC0_SUBTYPE_DEAUTH:
759 case IEEE80211_FC0_SUBTYPE_PROBE_RESP:
760 case IEEE80211_FC0_SUBTYPE_BEACON:
761 case IEEE80211_FC0_SUBTYPE_PROBE_REQ:
762 case IEEE80211_FC0_SUBTYPE_AUTH:
763 case IEEE80211_FC0_SUBTYPE_ASSOC_REQ:
764 case IEEE80211_FC0_SUBTYPE_REASSOC_REQ:
765 case IEEE80211_FC0_SUBTYPE_ASSOC_RESP:
766 case IEEE80211_FC0_SUBTYPE_REASSOC_RESP:
767 case IEEE80211_FC0_SUBTYPE_DISASSOC:
768 vap->iv_stats.is_rx_mgtdiscard++;
770 case IEEE80211_FC0_SUBTYPE_ACTION:
771 if (vap->iv_state != IEEE80211_S_RUN ||
772 IEEE80211_IS_MULTICAST(wh->i_addr1)) {
773 vap->iv_stats.is_rx_mgtdiscard++;
776 ni->ni_inact = ni->ni_inact_reload;
777 if (ieee80211_parse_action(ni, m0) == 0)
778 ic->ic_recv_action(ni, wh, frm, efrm);
781 IEEE80211_DISCARD(vap, IEEE80211_MSG_ANY,
782 wh, "mgt", "subtype 0x%x not handled", subtype);
783 vap->iv_stats.is_rx_badsubtype++;