FreeBSD kernel WLAN code
ieee80211_wds.c
Go to the documentation of this file.
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
29#ifdef __FreeBSD__
30__FBSDID("$FreeBSD$");
31#endif
32
33/*
34 * IEEE 802.11 WDS mode support.
35 */
36#include "opt_inet.h"
37#include "opt_wlan.h"
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/mbuf.h>
42#include <sys/malloc.h>
43#include <sys/kernel.h>
44
45#include <sys/socket.h>
46#include <sys/sockio.h>
47#include <sys/endian.h>
48#include <sys/errno.h>
49#include <sys/proc.h>
50#include <sys/sysctl.h>
51
52#include <net/if.h>
53#include <net/if_var.h>
54#include <net/if_media.h>
55#include <net/if_llc.h>
56#include <net/ethernet.h>
57
58#include <net/bpf.h>
59
63#ifdef IEEE80211_SUPPORT_SUPERG
65#endif
66
67static void wds_vattach(struct ieee80211vap *);
68static int wds_newstate(struct ieee80211vap *, enum ieee80211_state, int);
69static int wds_input(struct ieee80211_node *ni, struct mbuf *m,
70 const struct ieee80211_rx_stats *rxs, int, int);
71static void wds_recv_mgmt(struct ieee80211_node *, struct mbuf *, int subtype,
72 const struct ieee80211_rx_stats *, int, int);
73
74void
76{
78}
79
80void
82{
83}
84
85static void
87{
88 if (vap->iv_bss != NULL) {
89 /* XXX locking? */
90 if (vap->iv_bss->ni_wdsvap == vap)
91 vap->iv_bss->ni_wdsvap = NULL;
92 }
93}
94
95static void
97{
99 vap->iv_input = wds_input;
102}
103
104static void
106{
107 struct ieee80211com *ic = ni->ni_ic;
108 struct mbuf *m, *next;
109 int8_t rssi, nf;
110
112 (void *)(uintptr_t) ieee80211_mac_hash(ic, ni->ni_macaddr));
113 if (m == NULL)
114 return;
115
117 "%s", "flush wds queue");
118 ic->ic_node_getsignal(ni, &rssi, &nf);
119 for (; m != NULL; m = next) {
120 next = m->m_nextpkt;
121 m->m_nextpkt = NULL;
122 ieee80211_input(ni, m, rssi, nf);
123 }
124}
125
126static int
128{
129 struct ieee80211com *ic = vap->iv_ic;
130 struct ieee80211_node_table *nt = &ic->ic_sta;
131 struct ieee80211_node *ni, *obss;
132
134 "%s: creating link to %s on channel %u\n", __func__,
135 ether_sprintf(vap->iv_des_bssid), ieee80211_chan2ieee(ic, chan));
136
137 /* NB: vap create must specify the bssid for the link */
138 KASSERT(vap->iv_flags & IEEE80211_F_DESBSSID, ("no bssid"));
139 /* NB: we should only be called on RUN transition */
140 KASSERT(vap->iv_state == IEEE80211_S_RUN, ("!RUN state"));
141
142 if ((vap->iv_flags_ext & IEEE80211_FEXT_WDSLEGACY) == 0) {
143 /*
144 * Dynamic/non-legacy WDS. Reference the associated
145 * station specified by the desired bssid setup at vap
146 * create. Point ni_wdsvap at the WDS vap so 4-address
147 * frames received through the associated AP vap will
148 * be dispatched upward (e.g. to a bridge) as though
149 * they arrived on the WDS vap.
150 */
152 obss = NULL;
154 if (ni == NULL) {
155 /*
156 * Node went away before we could hookup. This
157 * should be ok; no traffic will flow and a leave
158 * event will be dispatched that should cause
159 * the vap to be destroyed.
160 */
162 "%s: station %s went away\n",
163 __func__, ether_sprintf(vap->iv_des_bssid));
164 /* XXX stat? */
165 } else if (ni->ni_wdsvap != NULL) {
166 /*
167 * Node already setup with a WDS vap; we cannot
168 * allow multiple references so disallow. If
169 * ni_wdsvap points at us that's ok; we should
170 * do nothing anyway.
171 */
172 /* XXX printf instead? */
174 "%s: station %s in use with %s\n",
175 __func__, ether_sprintf(vap->iv_des_bssid),
176 ni->ni_wdsvap->iv_ifp->if_xname);
177 /* XXX stat? */
178 } else {
179 /*
180 * Committed to new node, setup state.
181 */
182 obss = vap->iv_bss;
183 vap->iv_bss = ni;
184 ni->ni_wdsvap = vap;
185 }
187 if (obss != NULL) {
188 /* NB: deferred to avoid recursive lock */
190 }
191 } else {
192 /*
193 * Legacy WDS vap setup.
194 */
195 /*
196 * The far end does not associate so we just create
197 * create a new node and install it as the vap's
198 * bss node. We must simulate an association and
199 * authorize the port for traffic to flow.
200 * XXX check if node already in sta table?
201 */
202 ni = ieee80211_node_create_wds(vap, vap->iv_des_bssid, chan);
203 if (ni != NULL) {
204 obss = vap->iv_bss;
205 vap->iv_bss = ieee80211_ref_node(ni);
207 if (obss != NULL)
209 /* give driver a chance to setup state like ni_txrate */
210 if (ic->ic_newassoc != NULL)
211 ic->ic_newassoc(ni, 1);
212 /* tell the authenticator about new station */
213 if (vap->iv_auth->ia_node_join != NULL)
214 vap->iv_auth->ia_node_join(ni);
217
218 ieee80211_notify_node_join(ni, 1 /*newassoc*/);
219 /* XXX inject l2uf frame */
220 }
221 }
222
223 /*
224 * Flush any pending frames now that were setup.
225 */
226 if (ni != NULL)
227 wds_flush(ni);
228 return (ni == NULL ? ENOENT : 0);
229}
230
231/*
232 * Propagate multicast frames of an ap vap to all DWDS links.
233 * The caller is assumed to have verified this frame is multicast.
234 */
235void
236ieee80211_dwds_mcast(struct ieee80211vap *vap0, struct mbuf *m)
237{
238 struct ieee80211com *ic = vap0->iv_ic;
239 const struct ether_header *eh = mtod(m, const struct ether_header *);
240 struct ieee80211_node *ni;
241 struct ieee80211vap *vap;
242 struct ifnet *ifp;
243 struct mbuf *mcopy;
244 int err;
245
246 KASSERT(ETHER_IS_MULTICAST(eh->ether_dhost),
247 ("%s not mcast", ether_sprintf(eh->ether_dhost)));
248
249 /* XXX locking */
250 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
251 /* only DWDS vaps are interesting */
252 if (vap->iv_opmode != IEEE80211_M_WDS ||
254 continue;
255 /* if it came in this interface, don't send it back out */
256 ifp = vap->iv_ifp;
257 if (ifp == m->m_pkthdr.rcvif)
258 continue;
259 /*
260 * Duplicate the frame and send it.
261 */
262 mcopy = m_copypacket(m, M_NOWAIT);
263 if (mcopy == NULL) {
264 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
265 /* XXX stat + msg */
266 continue;
267 }
268 ni = ieee80211_find_txnode(vap, eh->ether_dhost);
269 if (ni == NULL) {
270 /* NB: ieee80211_find_txnode does stat+msg */
271 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
272 m_freem(mcopy);
273 continue;
274 }
275 /* calculate priority so drivers can find the tx queue */
276 if (ieee80211_classify(ni, mcopy)) {
279 eh->ether_dhost, NULL,
280 "%s", "classification failure");
282 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
283 m_freem(mcopy);
285 continue;
286 }
287
288 BPF_MTAP(ifp, m); /* 802.3 tx */
289
290 /*
291 * Encapsulate the packet in prep for transmission.
292 */
294 mcopy = ieee80211_encap(vap, ni, mcopy);
295 if (mcopy == NULL) {
296 /* NB: stat+msg handled in ieee80211_encap */
299 continue;
300 }
301 mcopy->m_flags |= M_MCAST;
302 MPASS((mcopy->m_pkthdr.csum_flags & CSUM_SND_TAG) == 0);
303 mcopy->m_pkthdr.rcvif = (void *) ni;
304
305 err = ieee80211_parent_xmitpkt(ic, mcopy);
307 if (!err) {
308 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
309 if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1);
310 if_inc_counter(ifp, IFCOUNTER_OBYTES,
311 m->m_pkthdr.len);
312 }
313 }
314}
315
316/*
317 * Handle DWDS discovery on receipt of a 4-address frame in
318 * ap mode. Queue the frame and post an event for someone
319 * to plumb the necessary WDS vap for this station. Frames
320 * received prior to the vap set running will then be reprocessed
321 * as if they were just received.
322 */
323void
324ieee80211_dwds_discover(struct ieee80211_node *ni, struct mbuf *m)
325{
326 struct ieee80211com *ic = ni->ni_ic;
327
328 /*
329 * Save the frame with an aging interval 4 times
330 * the listen interval specified by the station.
331 * Frames that sit around too long are reclaimed
332 * using this information.
333 * XXX handle overflow?
334 * XXX per/vap beacon interval?
335 */
336 MPASS((m->m_pkthdr.csum_flags & CSUM_SND_TAG) == 0);
337 m->m_pkthdr.rcvif = (void *)(uintptr_t)
339 (void) ieee80211_ageq_append(&ic->ic_stageq, m,
340 ((ni->ni_intval * ic->ic_lintval) << 2) / 1024);
342}
343
344/*
345 * IEEE80211_M_WDS vap state machine handler.
346 */
347static int
348wds_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
349{
350 struct ieee80211com *ic = vap->iv_ic;
351 enum ieee80211_state ostate;
352 int error;
353
355
356 ostate = vap->iv_state;
357 IEEE80211_DPRINTF(vap, IEEE80211_MSG_STATE, "%s: %s -> %s\n", __func__,
359 vap->iv_state = nstate; /* state transition */
360 callout_stop(&vap->iv_mgtsend); /* XXX callout_drain */
361 if (ostate != IEEE80211_S_SCAN)
362 ieee80211_cancel_scan(vap); /* background scan */
363 error = 0;
364 switch (nstate) {
365 case IEEE80211_S_INIT:
366 switch (ostate) {
367 case IEEE80211_S_SCAN:
369 break;
370 default:
371 break;
372 }
373 if (ostate != IEEE80211_S_INIT) {
374 /* NB: optimize INIT -> INIT case */
376 }
377 break;
378 case IEEE80211_S_SCAN:
379 switch (ostate) {
380 case IEEE80211_S_INIT:
382 break;
383 default:
384 break;
385 }
386 break;
387 case IEEE80211_S_RUN:
388 if (ostate == IEEE80211_S_INIT) {
389 /*
390 * Already have a channel; bypass the scan
391 * and startup immediately.
392 */
393 error = ieee80211_create_wds(vap, ic->ic_curchan);
394 }
395 break;
396 default:
397 break;
398 }
399 return error;
400}
401
402/*
403 * Process a received frame. The node associated with the sender
404 * should be supplied. If nothing was found in the node table then
405 * the caller is assumed to supply a reference to iv_bss instead.
406 * The RSSI and a timestamp are also supplied. The RSSI data is used
407 * during AP scanning to select a AP to associate with; it can have
408 * any units so long as values have consistent units and higher values
409 * mean ``better signal''. The receive timestamp is currently not used
410 * by the 802.11 layer.
411 */
412static int
413wds_input(struct ieee80211_node *ni, struct mbuf *m,
414 const struct ieee80211_rx_stats *rxs, int rssi, int nf)
415{
416 struct ieee80211vap *vap = ni->ni_vap;
417 struct ieee80211com *ic = ni->ni_ic;
418 struct ifnet *ifp = vap->iv_ifp;
419 struct ieee80211_frame *wh;
420 struct ieee80211_key *key;
421 struct ether_header *eh;
422 int hdrspace, need_tap = 1; /* mbuf need to be tapped. */
423 uint8_t dir, type, subtype, qos;
424 int is_hw_decrypted = 0;
425 int has_decrypted = 0;
426
427 /*
428 * Some devices do hardware decryption all the way through
429 * to pretending the frame wasn't encrypted in the first place.
430 * So, tag it appropriately so it isn't discarded inappropriately.
431 */
432 if ((rxs != NULL) && (rxs->c_pktflags & IEEE80211_RX_F_DECRYPTED))
433 is_hw_decrypted = 1;
434
435 if (m->m_flags & M_AMPDU_MPDU) {
436 /*
437 * Fastpath for A-MPDU reorder q resubmission. Frames
438 * w/ M_AMPDU_MPDU marked have already passed through
439 * here but were received out of order and been held on
440 * the reorder queue. When resubmitted they are marked
441 * with the M_AMPDU_MPDU flag and we can bypass most of
442 * the normal processing.
443 */
444 wh = mtod(m, struct ieee80211_frame *);
446 dir = wh->i_fc[1] & IEEE80211_FC1_DIR_MASK;
448 hdrspace = ieee80211_hdrspace(ic, wh); /* XXX optimize? */
449 goto resubmit_ampdu;
450 }
451
452 KASSERT(ni != NULL, ("null node"));
453
454 type = -1; /* undefined */
455
456 if (m->m_pkthdr.len < sizeof(struct ieee80211_frame_min)) {
458 ni->ni_macaddr, NULL,
459 "too short (1): len %u", m->m_pkthdr.len);
461 goto out;
462 }
463 /*
464 * Bit of a cheat here, we use a pointer for a 3-address
465 * frame format but don't reference fields past outside
466 * ieee80211_frame_min w/o first validating the data is
467 * present.
468 */
469 wh = mtod(m, struct ieee80211_frame *);
470
472 ni->ni_inact = ni->ni_inact_reload;
473
474 if ((wh->i_fc[0] & IEEE80211_FC0_VERSION_MASK) !=
477 ni->ni_macaddr, NULL, "wrong version, fc %02x:%02x",
478 wh->i_fc[0], wh->i_fc[1]);
480 goto err;
481 }
482
483 dir = wh->i_fc[1] & IEEE80211_FC1_DIR_MASK;
484 type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
485 subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK;
486
487 /* NB: WDS vap's do not scan */
488 if (m->m_pkthdr.len < sizeof(struct ieee80211_frame_addr4)) {
490 IEEE80211_MSG_ANY, ni->ni_macaddr, NULL,
491 "too short (3): len %u", m->m_pkthdr.len);
493 goto out;
494 }
495 /* NB: the TA is implicitly verified by finding the wds peer node */
496 if (!IEEE80211_ADDR_EQ(wh->i_addr1, vap->iv_myaddr) &&
497 !IEEE80211_ADDR_EQ(wh->i_addr1, ifp->if_broadcastaddr)) {
498 /* not interested in */
500 wh->i_addr1, NULL, "%s", "not to bss");
502 goto out;
503 }
505 ni->ni_noise = nf;
506 if (IEEE80211_HAS_SEQ(type, subtype)) {
507 uint8_t tid = ieee80211_gettid(wh);
508 if (IEEE80211_QOS_HAS_SEQ(wh) &&
509 TID_TO_WME_AC(tid) >= WME_AC_VI)
511 if (! ieee80211_check_rxseq(ni, wh, wh->i_addr1, rxs))
512 goto out;
513 }
514 switch (type) {
516 hdrspace = ieee80211_hdrspace(ic, wh);
517 if (m->m_len < hdrspace &&
518 (m = m_pullup(m, hdrspace)) == NULL) {
520 ni->ni_macaddr, NULL,
521 "data too short: expecting %u", hdrspace);
523 goto out; /* XXX */
524 }
525 if (dir != IEEE80211_FC1_DIR_DSTODS) {
527 wh, "data", "incorrect dir 0x%x", dir);
529 goto out;
530 }
531 /*
532 * Only legacy WDS traffic should take this path.
533 */
534 if ((vap->iv_flags_ext & IEEE80211_FEXT_WDSLEGACY) == 0) {
536 wh, "data", "%s", "not legacy wds");
537 vap->iv_stats.is_rx_wrongdir++;/*XXX*/
538 goto out;
539 }
540 /*
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.
545 */
546 if ((m->m_flags & M_AMPDU) &&
547 ieee80211_ampdu_reorder(ni, m, rxs) != 0) {
548 m = NULL;
549 goto out;
550 }
551 resubmit_ampdu:
552
553 /*
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.
560 */
561 if (is_hw_decrypted || wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
562 if ((vap->iv_flags & IEEE80211_F_PRIVACY) == 0) {
563 /*
564 * Discard encrypted frames when privacy is off.
565 */
567 wh, "WEP", "%s", "PRIVACY off");
569 IEEE80211_NODE_STAT(ni, rx_noprivacy);
570 goto out;
571 }
572 if (ieee80211_crypto_decap(ni, m, hdrspace, &key) == 0) {
573 /* NB: stats+msgs handled in crypto_decap */
574 IEEE80211_NODE_STAT(ni, rx_wepfail);
575 goto out;
576 }
577 wh = mtod(m, struct ieee80211_frame *);
578 wh->i_fc[1] &= ~IEEE80211_FC1_PROTECTED;
579 has_decrypted = 1;
580 } else {
581 /* XXX M_WEP and IEEE80211_F_PRIVACY */
582 key = NULL;
583 }
584
585 /*
586 * Save QoS bits for use below--before we strip the header.
587 */
588 if (subtype == IEEE80211_FC0_SUBTYPE_QOS)
589 qos = ieee80211_getqos(wh)[0];
590 else
591 qos = 0;
592
593 /*
594 * Next up, any fragmentation.
595 */
597 m = ieee80211_defrag(ni, m, hdrspace, has_decrypted);
598 if (m == NULL) {
599 /* Fragment dropped or frame not complete yet */
600 goto out;
601 }
602 }
603 wh = NULL; /* no longer valid, catch any uses */
604
605 /*
606 * Next strip any MSDU crypto bits.
607 */
608 if (!ieee80211_crypto_demic(vap, key, m, 0)) {
610 ni->ni_macaddr, "data", "%s", "demic error");
612 IEEE80211_NODE_STAT(ni, rx_demicfail);
613 goto out;
614 }
615
616 /* copy to listener after decrypt */
618 ieee80211_radiotap_rx(vap, m);
619 need_tap = 0;
620
621 /*
622 * Finally, strip the 802.11 header.
623 */
624 m = ieee80211_decap(vap, m, hdrspace, qos);
625 if (m == NULL) {
626 /* XXX mask bit to check for both */
627 /* don't count Null data frames as errors */
628 if (subtype == IEEE80211_FC0_SUBTYPE_NODATA ||
630 goto out;
632 ni->ni_macaddr, "data", "%s", "decap error");
633 vap->iv_stats.is_rx_decap++;
634 IEEE80211_NODE_STAT(ni, rx_decap);
635 goto err;
636 }
637 if (!(qos & IEEE80211_QOS_AMSDU))
638 eh = mtod(m, struct ether_header *);
639 else
640 eh = NULL;
642 /*
643 * Deny any non-PAE frames received prior to
644 * authorization. For open/shared-key
645 * authentication the port is mark authorized
646 * after authentication completes. For 802.1x
647 * the port is not marked authorized by the
648 * authenticator until the handshake has completed.
649 */
650 if (eh == NULL ||
651 eh->ether_type != htons(ETHERTYPE_PAE)) {
653 ni->ni_macaddr, "data", "unauthorized or "
654 "unknown port: ether type 0x%x len %u",
655 eh == NULL ? -1 : eh->ether_type,
656 m->m_pkthdr.len);
657 vap->iv_stats.is_rx_unauth++;
658 IEEE80211_NODE_STAT(ni, rx_unauth);
659 goto err;
660 }
661 } else {
662 /*
663 * When denying unencrypted frames, discard
664 * any non-PAE frames received without encryption.
665 */
666 if ((vap->iv_flags & IEEE80211_F_DROPUNENC) &&
667 ((has_decrypted == 0) && (m->m_flags & M_WEP) == 0) &&
668 (is_hw_decrypted == 0) &&
669 (eh == NULL ||
670 eh->ether_type != htons(ETHERTYPE_PAE))) {
671 /*
672 * Drop unencrypted frames.
673 */
675 IEEE80211_NODE_STAT(ni, rx_unencrypted);
676 goto out;
677 }
678 }
679 /* XXX require HT? */
680 if (qos & IEEE80211_QOS_AMSDU) {
681 m = ieee80211_decap_amsdu(ni, m);
682 if (m == NULL)
684 } else {
685#ifdef IEEE80211_SUPPORT_SUPERG
686 m = ieee80211_decap_fastframe(vap, ni, m);
687 if (m == NULL)
689#endif
690 }
691 ieee80211_deliver_data(vap, ni, m);
693
695 vap->iv_stats.is_rx_mgmt++;
696 IEEE80211_NODE_STAT(ni, rx_mgmt);
697 if (dir != IEEE80211_FC1_DIR_NODS) {
699 wh, "data", "incorrect dir 0x%x", dir);
701 goto err;
702 }
703 if (m->m_pkthdr.len < sizeof(struct ieee80211_frame)) {
705 ni->ni_macaddr, "mgt", "too short: len %u",
706 m->m_pkthdr.len);
708 goto out;
709 }
710#ifdef IEEE80211_DEBUG
711 if (ieee80211_msg_debug(vap) || ieee80211_msg_dumppkts(vap)) {
712 if_printf(ifp, "received %s from %s rssi %d\n",
714 ether_sprintf(wh->i_addr2), rssi);
715 }
716#endif
717 if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
719 wh, NULL, "%s", "WEP set but not permitted");
720 vap->iv_stats.is_rx_mgtdiscard++; /* XXX */
721 goto out;
722 }
723 vap->iv_recv_mgmt(ni, m, subtype, rxs, rssi, nf);
724 goto out;
725
727 vap->iv_stats.is_rx_ctl++;
728 IEEE80211_NODE_STAT(ni, rx_ctrl);
729 goto out;
730
731 default:
733 wh, "bad", "frame type 0x%x", type);
734 /* should not come here */
735 break;
736 }
737err:
738 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
739out:
740 if (m != NULL) {
741 if (need_tap && ieee80211_radiotap_active_vap(vap))
742 ieee80211_radiotap_rx(vap, m);
743 m_freem(m);
744 }
745 return type;
746}
747
748static void
749wds_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m0, int subtype,
750 const struct ieee80211_rx_stats *rxs, int rssi, int nf)
751{
752 struct ieee80211vap *vap = ni->ni_vap;
753 struct ieee80211com *ic = ni->ni_ic;
754 struct ieee80211_frame *wh;
755 u_int8_t *frm, *efrm;
756
757 wh = mtod(m0, struct ieee80211_frame *);
758 frm = (u_int8_t *)&wh[1];
759 efrm = mtod(m0, u_int8_t *) + m0->m_len;
760 switch (subtype) {
763 if (ni == vap->iv_bss) {
765 wh, NULL, "%s", "unknown node");
767 } else if (!IEEE80211_ADDR_EQ(vap->iv_myaddr, wh->i_addr1)) {
768 /* NB: not interested in multicast frames. */
770 wh, NULL, "%s", "not for us");
772 } else if (vap->iv_state != IEEE80211_S_RUN) {
774 wh, NULL, "wrong state %s",
777 } else {
778 if (ieee80211_parse_action(ni, m0) == 0)
779 (void)ic->ic_recv_action(ni, wh, frm, efrm);
780 }
781 break;
782
796 wh, NULL, "%s", "not handled");
798 break;
799
800 default:
802 wh, "mgt", "subtype 0x%x not handled", subtype);
804 break;
805 }
806}
#define IEEE80211_RX_F_DECRYPTED
Definition: _ieee80211.h:570
@ IEEE80211_AUTH_8021X
Definition: _ieee80211.h:116
@ IEEE80211_M_WDS
Definition: _ieee80211.h:88
int ieee80211_chan2ieee(struct ieee80211com *ic, const struct ieee80211_channel *c)
Definition: ieee80211.c:1076
uint32_t ieee80211_mac_hash(const struct ieee80211com *ic, const uint8_t addr[IEEE80211_ADDR_LEN])
Definition: ieee80211.c:2607
#define IEEE80211_FC0_SUBTYPE_ASSOC_REQ
Definition: ieee80211.h:127
#define IEEE80211_FC0_SUBTYPE_ACTION
Definition: ieee80211.h:139
#define IEEE80211_FC0_TYPE_CTL
Definition: ieee80211.h:121
#define IEEE80211_FC0_TYPE_MASK
Definition: ieee80211.h:118
#define IEEE80211_FC0_SUBTYPE_ATIM
Definition: ieee80211.h:135
#define IEEE80211_FC0_SUBTYPE_REASSOC_REQ
Definition: ieee80211.h:129
#define IEEE80211_FC0_SUBTYPE_PROBE_REQ
Definition: ieee80211.h:131
#define WME_AC_VI
Definition: ieee80211.h:1209
#define IEEE80211_FC1_PROTECTED
Definition: ieee80211.h:195
#define IEEE80211_HAS_SEQ(type, subtype)
Definition: ieee80211.h:198
#define IEEE80211_FC0_SUBTYPE_ASSOC_RESP
Definition: ieee80211.h:128
#define IEEE80211_FC0_VERSION_MASK
Definition: ieee80211.h:115
#define IEEE80211_FC0_SUBTYPE_DEAUTH
Definition: ieee80211.h:138
#define IEEE80211_FC1_DIR_DSTODS
Definition: ieee80211.h:186
#define IEEE80211_FC0_TYPE_MGT
Definition: ieee80211.h:120
#define IEEE80211_FC0_SUBTYPE_PROBE_RESP
Definition: ieee80211.h:132
#define IEEE80211_FC0_TYPE_DATA
Definition: ieee80211.h:122
#define IEEE80211_IS_MULTICAST(_a)
Definition: ieee80211.h:39
#define IEEE80211_QOS_HAS_SEQ(wh)
Definition: ieee80211.h:244
#define IEEE80211_FC0_SUBTYPE_TIMING_ADV
Definition: ieee80211.h:133
#define IEEE80211_FC0_SUBTYPE_DISASSOC
Definition: ieee80211.h:136
#define TID_TO_WME_AC(_tid)
Definition: ieee80211.h:319
#define IEEE80211_FC1_DIR_NODS
Definition: ieee80211.h:183
#define IEEE80211_FC1_DIR_MASK
Definition: ieee80211.h:182
#define IEEE80211_FC0_VERSION_0
Definition: ieee80211.h:117
#define IEEE80211_FC0_SUBTYPE_NODATA
Definition: ieee80211.h:156
#define IEEE80211_FC0_SUBTYPE_REASSOC_RESP
Definition: ieee80211.h:130
#define IEEE80211_FC0_SUBTYPE_QOS
Definition: ieee80211.h:160
#define IEEE80211_FC0_SUBTYPE_ACTION_NOACK
Definition: ieee80211.h:140
#define IEEE80211_FC0_SUBTYPE_QOS_NULL
Definition: ieee80211.h:164
#define IEEE80211_QOS_AMSDU
Definition: ieee80211.h:226
#define IEEE80211_FC0_SUBTYPE_MASK
Definition: ieee80211.h:124
#define IEEE80211_FC0_SUBTYPE_BEACON
Definition: ieee80211.h:134
#define IEEE80211_FC0_SUBTYPE_AUTH
Definition: ieee80211.h:137
int ieee80211_ageq_append(struct ieee80211_ageq *aq, struct mbuf *m, int age)
struct mbuf * ieee80211_ageq_remove(struct ieee80211_ageq *aq, struct ieee80211_node *match)
int ieee80211_crypto_decap(struct ieee80211_node *ni, struct mbuf *m, int hdrlen, struct ieee80211_key **key)
int ieee80211_crypto_demic(struct ieee80211vap *vap, struct ieee80211_key *k, struct mbuf *m, int force)
void ieee80211_notify_node_join(struct ieee80211_node *ni, int newassoc)
void ieee80211_notify_wds_discover(struct ieee80211_node *ni)
int ieee80211_parent_xmitpkt(struct ieee80211com *ic, struct mbuf *m)
#define IEEE80211_TX_LOCK(_ic)
#define M_WEP
#define IEEE80211_LOCK_ASSERT(_ic)
#define IEEE80211_TX_UNLOCK(_ic)
#define IEEE80211_NODE_LOCK(_nt)
#define IEEE80211_NODE_UNLOCK(_nt)
#define M_AMPDU_MPDU
#define M_AMPDU
int ieee80211_ampdu_reorder(struct ieee80211_node *ni, struct mbuf *m, const struct ieee80211_rx_stats *rxs)
struct mbuf * ieee80211_decap_amsdu(struct ieee80211_node *ni, struct mbuf *m)
Definition: ieee80211_ht.c:471
int ieee80211_parse_action(struct ieee80211_node *ni, struct mbuf *m)
struct mbuf * ieee80211_decap(struct ieee80211vap *vap, struct mbuf *m, int hdrlen, uint8_t qos)
void ieee80211_deliver_data(struct ieee80211vap *vap, struct ieee80211_node *ni, struct mbuf *m)
struct mbuf * ieee80211_defrag(struct ieee80211_node *ni, struct mbuf *m, int hdrspace, int has_decrypted)
static __inline int ieee80211_check_rxseq(struct ieee80211_node *ni, struct ieee80211_frame *wh, uint8_t *bssid, const struct ieee80211_rx_stats *rxs)
void ieee80211_free_node(struct ieee80211_node *ni)
void ieee80211_reset_bss(struct ieee80211vap *vap)
void ieee80211_node_authorize(struct ieee80211_node *ni)
struct ieee80211_node * ieee80211_find_node_locked(struct ieee80211_node_table *nt, const uint8_t macaddr[IEEE80211_ADDR_LEN])
struct ieee80211_node * ieee80211_find_txnode(struct ieee80211vap *vap, const uint8_t macaddr[IEEE80211_ADDR_LEN])
struct ieee80211_node * ieee80211_node_create_wds(struct ieee80211vap *vap, const uint8_t bssid[IEEE80211_ADDR_LEN], struct ieee80211_channel *chan)
#define IEEE80211_RSSI_LPF(x, y)
static __inline int ieee80211_node_is_authorized(const struct ieee80211_node *ni)
#define IEEE80211_NODE_STAT(ni, stat)
static __inline struct ieee80211_node * ieee80211_ref_node(struct ieee80211_node *ni)
#define IEEE80211_NODE_AREF
struct mbuf * ieee80211_encap(struct ieee80211vap *vap, struct ieee80211_node *ni, struct mbuf *m)
int ieee80211_classify(struct ieee80211_node *ni, struct mbuf *m)
const char * ieee80211_state_name[IEEE80211_S_MAX]
#define ieee80211_input(ni, m, rssi, nf)
ieee80211_state
@ IEEE80211_S_RUN
@ IEEE80211_S_SCAN
@ IEEE80211_S_INIT
static __inline uint8_t ieee80211_gettid(const struct ieee80211_frame *wh)
static __inline uint8_t * ieee80211_getqos(void *data)
static __inline const char * ieee80211_mgt_subtype_name(uint8_t subtype)
void ieee80211_radiotap_rx(struct ieee80211vap *vap0, struct mbuf *m)
void ieee80211_cancel_scan(struct ieee80211vap *vap)
int ieee80211_check_scan_current(struct ieee80211vap *vap)
static __inline struct mbuf * ieee80211_decap_fastframe(struct ieee80211vap *vap, struct ieee80211_node *ni, struct mbuf *m)
static __inline int ieee80211_radiotap_active_vap(const struct ieee80211vap *vap)
#define IEEE80211_MSG_STATE
#define IEEE80211_F_DESBSSID
#define IEEE80211_MSG_OUTPUT
static __inline int ieee80211_hdrspace(struct ieee80211com *ic, const void *data)
#define IEEE80211_MSG_ANY
#define IEEE80211_FEXT_WDSLEGACY
#define IEEE80211_ADDR_EQ(a1, a2)
#define IEEE80211_F_PRIVACY
#define IEEE80211_NOTE(_vap, _m, _ni, _fmt,...)
#define IEEE80211_DISCARD_MAC(_vap, _m, _mac, _type, _fmt,...)
#define IEEE80211_DPRINTF(_vap, _m, _fmt,...)
#define IEEE80211_MSG_INPUT
#define IEEE80211_MSG_WDS
#define IEEE80211_DISCARD(_vap, _m, _wh, _type, _fmt,...)
#define ieee80211_msg_dumppkts(_vap)
#define IEEE80211_F_DROPUNENC
static void wds_vdetach(struct ieee80211vap *vap)
Definition: ieee80211_wds.c:86
static void wds_recv_mgmt(struct ieee80211_node *, struct mbuf *, int subtype, const struct ieee80211_rx_stats *, int, int)
void ieee80211_wds_attach(struct ieee80211com *ic)
Definition: ieee80211_wds.c:75
void ieee80211_wds_detach(struct ieee80211com *ic)
Definition: ieee80211_wds.c:81
static int wds_newstate(struct ieee80211vap *, enum ieee80211_state, int)
static int ieee80211_create_wds(struct ieee80211vap *vap, struct ieee80211_channel *chan)
void ieee80211_dwds_discover(struct ieee80211_node *ni, struct mbuf *m)
static int wds_input(struct ieee80211_node *ni, struct mbuf *m, const struct ieee80211_rx_stats *rxs, int, int)
__FBSDID("$FreeBSD$")
static void wds_vattach(struct ieee80211vap *)
Definition: ieee80211_wds.c:96
static void wds_flush(struct ieee80211_node *ni)
void ieee80211_dwds_mcast(struct ieee80211vap *vap0, struct mbuf *m)
void(* ia_node_join)(struct ieee80211_node *)
uint8_t i_addr1[IEEE80211_ADDR_LEN]
Definition: ieee80211.h:70
uint8_t i_addr2[IEEE80211_ADDR_LEN]
Definition: ieee80211.h:71
uint8_t i_fc[2]
Definition: ieee80211.h:68
struct ieee80211com * ni_ic
uint8_t ni_macaddr[IEEE80211_ADDR_LEN]
struct ieee80211vap * ni_vap
uint16_t ni_intval
struct ieee80211vap * ni_wdsvap
uint32_t ni_avgrssi
uint32_t c_pktflags
Definition: _ieee80211.h:594
uint32_t is_rx_tooshort
uint32_t is_rx_badversion
uint32_t is_rx_badsubtype
uint32_t is_rx_mgtdiscard
uint32_t is_tx_classify
uint32_t is_rx_demicfail
uint32_t is_rx_wrongbss
uint32_t is_rx_wrongdir
uint32_t is_rx_noprivacy
uint32_t is_rx_unencrypted
void(* ic_node_getsignal)(const struct ieee80211_node *, int8_t *, int8_t *)
ieee80211vap_attach ic_vattach[IEEE80211_OPMODE_MAX]
struct ieee80211_node_table ic_sta
struct ieee80211_ageq ic_stageq
struct ieee80211_wme_state ic_wme
int(* ic_recv_action)(struct ieee80211_node *, const struct ieee80211_frame *, const uint8_t *frm, const uint8_t *efrm)
uint16_t ic_lintval
struct ieee80211_channel * ic_curchan
void(* ic_newassoc)(struct ieee80211_node *, int)
struct ieee80211com * iv_ic
struct ieee80211_node * iv_bss
enum ieee80211_opmode iv_opmode
uint8_t iv_myaddr[IEEE80211_ADDR_LEN]
struct ieee80211_stats iv_stats
void(* iv_recv_mgmt)(struct ieee80211_node *, struct mbuf *, int, const struct ieee80211_rx_stats *, int, int)
const struct ieee80211_authenticator * iv_auth
uint32_t iv_flags
uint32_t iv_flags_ext
uint8_t iv_des_bssid[IEEE80211_ADDR_LEN]
enum ieee80211_state iv_state
void(* iv_opdetach)(struct ieee80211vap *)
int(* iv_input)(struct ieee80211_node *, struct mbuf *, const struct ieee80211_rx_stats *, int, int)
struct ifnet * iv_ifp
struct callout iv_mgtsend
int(* iv_newstate)(struct ieee80211vap *, enum ieee80211_state, int)