2 * Copyright (c) 2003-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.
26 #include <sys/cdefs.h>
27 __FBSDID("$FreeBSD$");
30 * IEEE 802.11 support (FreeBSD-specific code)
34 #include <sys/param.h>
35 #include <sys/kernel.h>
36 #include <sys/systm.h>
37 #include <sys/linker.h>
39 #include <sys/module.h>
41 #include <sys/sysctl.h>
43 #include <sys/socket.h>
46 #include <net/if_clone.h>
47 #include <net/if_media.h>
48 #include <net/if_types.h>
49 #include <net/ethernet.h>
50 #include <net/route.h>
52 #include <net80211/ieee80211_var.h>
54 SYSCTL_NODE(_net, OID_AUTO, wlan, CTLFLAG_RD, 0, "IEEE 80211 parameters");
56 #ifdef IEEE80211_DEBUG
57 int ieee80211_debug = 0;
58 SYSCTL_INT(_net_wlan, OID_AUTO, debug, CTLFLAG_RW, &ieee80211_debug,
59 0, "debugging printfs");
61 extern int ieee80211_recv_bar_ena;
62 SYSCTL_INT(_net_wlan, OID_AUTO, recv_bar, CTLFLAG_RW, &ieee80211_recv_bar_ena,
63 0, "BAR frame processing (ena/dis)");
64 extern int ieee80211_nol_timeout;
65 SYSCTL_INT(_net_wlan, OID_AUTO, nol_timeout, CTLFLAG_RW,
66 &ieee80211_nol_timeout, 0, "NOL timeout (secs)");
67 extern int ieee80211_cac_timeout;
68 SYSCTL_INT(_net_wlan, OID_AUTO, cac_timeout, CTLFLAG_RW,
69 &ieee80211_cac_timeout, 0, "CAC timeout (secs)");
71 MALLOC_DEFINE(M_80211_COM, "80211com", "802.11 com state");
74 * Allocate/free com structure in conjunction with ifnet;
75 * these routines are registered with if_register_com_alloc
76 * below and are called automatically by the ifnet code
77 * when the ifnet of the parent device is created.
80 wlan_alloc(u_char type, struct ifnet *ifp)
82 struct ieee80211com *ic;
84 ic = malloc(sizeof(struct ieee80211com), M_80211_COM, M_WAITOK|M_ZERO);
91 wlan_free(void *ic, u_char type)
93 free(ic, M_80211_COM);
97 wlan_clone_create(struct if_clone *ifc, int unit, caddr_t params)
99 struct ieee80211_clone_params cp;
100 struct ieee80211vap *vap;
101 struct ieee80211com *ic;
105 error = copyin(params, &cp, sizeof(cp));
108 ifp = ifunit(cp.icp_parent);
111 /* XXX move printfs to DIAGNOSTIC before release */
112 if (ifp->if_type != IFT_IEEE80211) {
113 if_printf(ifp, "%s: reject, not an 802.11 device\n", __func__);
116 if (cp.icp_opmode >= IEEE80211_OPMODE_MAX) {
117 if_printf(ifp, "%s: invalid opmode %d\n",
118 __func__, cp.icp_opmode);
122 if ((ic->ic_caps & ieee80211_opcap[cp.icp_opmode]) == 0) {
123 if_printf(ifp, "%s mode not supported\n",
124 ieee80211_opmode_name[cp.icp_opmode]);
127 vap = ic->ic_vap_create(ic, ifc->ifc_name, unit,
128 cp.icp_opmode, cp.icp_flags, cp.icp_bssid,
129 cp.icp_flags & IEEE80211_CLONE_MACADDR ?
130 cp.icp_macaddr : ic->ic_myaddr);
131 return (vap == NULL ? EIO : 0);
135 wlan_clone_destroy(struct ifnet *ifp)
137 struct ieee80211vap *vap = ifp->if_softc;
138 struct ieee80211com *ic = vap->iv_ic;
140 ic->ic_vap_delete(vap);
142 IFC_SIMPLE_DECLARE(wlan, 0);
145 ieee80211_vap_destroy(struct ieee80211vap *vap)
147 ifc_simple_destroy(&wlan_cloner, vap->iv_ifp);
151 ieee80211_sysctl_msecs_ticks(SYSCTL_HANDLER_ARGS)
153 int msecs = ticks_to_msecs(*(int *)arg1);
156 error = sysctl_handle_int(oidp, &msecs, 0, req);
157 if (error || !req->newptr)
159 t = msecs_to_ticks(msecs);
160 *(int *)arg1 = (t < 1) ? 1 : t;
164 #ifdef IEEE80211_AMPDU_AGE
165 extern int ieee80211_ampdu_age;
166 SYSCTL_PROC(_net_wlan, OID_AUTO, ampdu_age, CTLFLAG_RW,
167 &ieee80211_ampdu_age, 0, ieee80211_sysctl_msecs_ticks, "I",
168 "AMPDU max reorder age (ms)");
170 extern int ieee80211_addba_timeout;
171 SYSCTL_PROC(_net_wlan, OID_AUTO, addba_timeout, CTLFLAG_RW,
172 &ieee80211_addba_timeout, 0, ieee80211_sysctl_msecs_ticks, "I",
173 "ADDBA request timeout (ms)");
174 extern int ieee80211_addba_backoff;
175 SYSCTL_PROC(_net_wlan, OID_AUTO, addba_backoff, CTLFLAG_RW,
176 &ieee80211_addba_backoff, 0, ieee80211_sysctl_msecs_ticks, "I",
177 "ADDBA request backoff (ms)");
178 extern int ieee80211_addba_maxtries;
179 SYSCTL_INT(_net_wlan, OID_AUTO, addba_maxtries, CTLFLAG_RW,
180 &ieee80211_addba_maxtries, 0, "max ADDBA requests sent before backoff");
183 ieee80211_sysctl_inact(SYSCTL_HANDLER_ARGS)
185 int inact = (*(int *)arg1) * IEEE80211_INACT_WAIT;
188 error = sysctl_handle_int(oidp, &inact, 0, req);
189 if (error || !req->newptr)
191 *(int *)arg1 = inact / IEEE80211_INACT_WAIT;
196 ieee80211_sysctl_parent(SYSCTL_HANDLER_ARGS)
198 struct ieee80211com *ic = arg1;
199 const char *name = ic->ic_ifp->if_xname;
201 return SYSCTL_OUT(req, name, strlen(name));
205 ieee80211_sysctl_attach(struct ieee80211com *ic)
210 ieee80211_sysctl_detach(struct ieee80211com *ic)
215 ieee80211_sysctl_vattach(struct ieee80211vap *vap)
217 struct ifnet *ifp = vap->iv_ifp;
218 struct sysctl_ctx_list *ctx;
219 struct sysctl_oid *oid;
220 char num[14]; /* sufficient for 32 bits */
222 MALLOC(ctx, struct sysctl_ctx_list *, sizeof(struct sysctl_ctx_list),
223 M_DEVBUF, M_NOWAIT | M_ZERO);
225 if_printf(ifp, "%s: cannot allocate sysctl context!\n",
229 sysctl_ctx_init(ctx);
230 snprintf(num, sizeof(num), "%u", ifp->if_dunit);
231 oid = SYSCTL_ADD_NODE(ctx, &SYSCTL_NODE_CHILDREN(_net, wlan),
232 OID_AUTO, num, CTLFLAG_RD, NULL, "");
233 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
234 "%parent", CTLFLAG_RD, vap->iv_ic, 0,
235 ieee80211_sysctl_parent, "A", "parent device");
236 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
237 "driver_caps", CTLFLAG_RW, &vap->iv_caps, 0,
238 "driver capabilities");
239 #ifdef IEEE80211_DEBUG
240 vap->iv_debug = ieee80211_debug;
241 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
242 "debug", CTLFLAG_RW, &vap->iv_debug, 0,
243 "control debugging printfs");
245 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
246 "bmiss_max", CTLFLAG_RW, &vap->iv_bmiss_max, 0,
247 "consecutive beacon misses before scanning");
248 /* XXX inherit from tunables */
249 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
250 "inact_run", CTLTYPE_INT | CTLFLAG_RW, &vap->iv_inact_run, 0,
251 ieee80211_sysctl_inact, "I",
252 "station inactivity timeout (sec)");
253 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
254 "inact_probe", CTLTYPE_INT | CTLFLAG_RW, &vap->iv_inact_probe, 0,
255 ieee80211_sysctl_inact, "I",
256 "station inactivity probe timeout (sec)");
257 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
258 "inact_auth", CTLTYPE_INT | CTLFLAG_RW, &vap->iv_inact_auth, 0,
259 ieee80211_sysctl_inact, "I",
260 "station authentication timeout (sec)");
261 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
262 "inact_init", CTLTYPE_INT | CTLFLAG_RW, &vap->iv_inact_init, 0,
263 ieee80211_sysctl_inact, "I",
264 "station initial state timeout (sec)");
265 if (vap->iv_htcaps & IEEE80211_HTC_HT) {
266 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
267 "ampdu_mintraffic_bk", CTLFLAG_RW,
268 &vap->iv_ampdu_mintraffic[WME_AC_BK], 0,
269 "BK traffic tx aggr threshold (pps)");
270 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
271 "ampdu_mintraffic_be", CTLFLAG_RW,
272 &vap->iv_ampdu_mintraffic[WME_AC_BE], 0,
273 "BE traffic tx aggr threshold (pps)");
274 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
275 "ampdu_mintraffic_vo", CTLFLAG_RW,
276 &vap->iv_ampdu_mintraffic[WME_AC_VO], 0,
277 "VO traffic tx aggr threshold (pps)");
278 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
279 "ampdu_mintraffic_vi", CTLFLAG_RW,
280 &vap->iv_ampdu_mintraffic[WME_AC_VI], 0,
281 "VI traffic tx aggr threshold (pps)");
283 vap->iv_sysctl = ctx;
288 ieee80211_sysctl_vdetach(struct ieee80211vap *vap)
291 if (vap->iv_sysctl != NULL) {
292 sysctl_ctx_free(vap->iv_sysctl);
293 FREE(vap->iv_sysctl, M_DEVBUF);
294 vap->iv_sysctl = NULL;
299 ieee80211_node_dectestref(struct ieee80211_node *ni)
301 /* XXX need equivalent of atomic_dec_and_test */
302 atomic_subtract_int(&ni->ni_refcnt, 1);
303 return atomic_cmpset_int(&ni->ni_refcnt, 0, 1);
307 ieee80211_drain_ifq(struct ifqueue *ifq)
309 struct ieee80211_node *ni;
317 ni = (struct ieee80211_node *)m->m_pkthdr.rcvif;
318 KASSERT(ni != NULL, ("frame w/o node"));
319 ieee80211_free_node(ni);
320 m->m_pkthdr.rcvif = NULL;
327 ieee80211_flush_ifq(struct ifqueue *ifq, struct ieee80211vap *vap)
329 struct ieee80211_node *ni;
330 struct mbuf *m, **mprev;
333 mprev = &ifq->ifq_head;
334 while ((m = *mprev) != NULL) {
335 ni = (struct ieee80211_node *)m->m_pkthdr.rcvif;
336 if (ni != NULL && ni->ni_vap == vap) {
337 *mprev = m->m_nextpkt; /* remove from list */
341 ieee80211_free_node(ni); /* reclaim ref */
343 mprev = &m->m_nextpkt;
345 /* recalculate tail ptr */
347 for (; m != NULL && m->m_nextpkt != NULL; m = m->m_nextpkt)
354 * As above, for mbufs allocated with m_gethdr/MGETHDR
355 * or initialized by M_COPY_PKTHDR.
357 #define MC_ALIGN(m, len) \
359 (m)->m_data += (MCLBYTES - (len)) &~ (sizeof(long) - 1); \
360 } while (/* CONSTCOND */ 0)
363 * Allocate and setup a management frame of the specified
364 * size. We return the mbuf and a pointer to the start
365 * of the contiguous data area that's been reserved based
366 * on the packet length. The data area is forced to 32-bit
367 * alignment and the buffer length to a multiple of 4 bytes.
368 * This is done mainly so beacon frames (that require this)
369 * can use this interface too.
372 ieee80211_getmgtframe(uint8_t **frm, int headroom, int pktlen)
378 * NB: we know the mbuf routines will align the data area
379 * so we don't need to do anything special.
381 len = roundup2(headroom + pktlen, 4);
382 KASSERT(len <= MCLBYTES, ("802.11 mgt frame too large: %u", len));
383 if (len < MINCLSIZE) {
384 m = m_gethdr(M_NOWAIT, MT_DATA);
386 * Align the data in case additional headers are added.
387 * This should only happen when a WEP header is added
388 * which only happens for shared key authentication mgt
389 * frames which all fit in MHLEN.
394 m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
399 m->m_data += headroom;
406 ieee80211_add_callback(struct mbuf *m,
407 void (*func)(struct ieee80211_node *, void *, int), void *arg)
410 struct ieee80211_cb *cb;
412 mtag = m_tag_alloc(MTAG_ABI_NET80211, NET80211_TAG_CALLBACK,
413 sizeof(struct ieee80211_cb), M_NOWAIT);
417 cb = (struct ieee80211_cb *)(mtag+1);
420 m_tag_prepend(m, mtag);
421 m->m_flags |= M_TXCB;
426 ieee80211_process_callback(struct ieee80211_node *ni,
427 struct mbuf *m, int status)
431 mtag = m_tag_locate(m, MTAG_ABI_NET80211, NET80211_TAG_CALLBACK, NULL);
433 struct ieee80211_cb *cb = (struct ieee80211_cb *)(mtag+1);
434 cb->func(ni, cb->arg, status);
438 #include <sys/libkern.h>
441 get_random_bytes(void *p, size_t n)
446 uint32_t v = arc4random();
447 size_t nb = n > sizeof(uint32_t) ? sizeof(uint32_t) : n;
448 bcopy(&v, dp, n > sizeof(uint32_t) ? sizeof(uint32_t) : n);
449 dp += sizeof(uint32_t), n -= nb;
454 * Helper function for events that pass just a single mac address.
457 notify_macaddr(struct ifnet *ifp, int op, const uint8_t mac[IEEE80211_ADDR_LEN])
459 struct ieee80211_join_event iev;
461 memset(&iev, 0, sizeof(iev));
462 IEEE80211_ADDR_COPY(iev.iev_addr, mac);
463 rt_ieee80211msg(ifp, op, &iev, sizeof(iev));
467 ieee80211_notify_node_join(struct ieee80211_node *ni, int newassoc)
469 struct ieee80211vap *vap = ni->ni_vap;
470 struct ifnet *ifp = vap->iv_ifp;
472 IEEE80211_NOTE(vap, IEEE80211_MSG_NODE, ni, "%snode join",
473 (ni == vap->iv_bss) ? "bss " : "");
475 if (ni == vap->iv_bss) {
476 notify_macaddr(ifp, newassoc ?
477 RTM_IEEE80211_ASSOC : RTM_IEEE80211_REASSOC, ni->ni_bssid);
478 if_link_state_change(ifp, LINK_STATE_UP);
480 notify_macaddr(ifp, newassoc ?
481 RTM_IEEE80211_JOIN : RTM_IEEE80211_REJOIN, ni->ni_macaddr);
486 ieee80211_notify_node_leave(struct ieee80211_node *ni)
488 struct ieee80211vap *vap = ni->ni_vap;
489 struct ifnet *ifp = vap->iv_ifp;
491 IEEE80211_NOTE(vap, IEEE80211_MSG_NODE, ni, "%snode leave",
492 (ni == vap->iv_bss) ? "bss " : "");
494 if (ni == vap->iv_bss) {
495 rt_ieee80211msg(ifp, RTM_IEEE80211_DISASSOC, NULL, 0);
496 if_link_state_change(ifp, LINK_STATE_DOWN);
498 /* fire off wireless event station leaving */
499 notify_macaddr(ifp, RTM_IEEE80211_LEAVE, ni->ni_macaddr);
504 ieee80211_notify_scan_done(struct ieee80211vap *vap)
506 struct ifnet *ifp = vap->iv_ifp;
508 IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN, "%s\n", "notify scan done");
510 /* dispatch wireless event indicating scan completed */
511 rt_ieee80211msg(ifp, RTM_IEEE80211_SCAN, NULL, 0);
515 ieee80211_notify_replay_failure(struct ieee80211vap *vap,
516 const struct ieee80211_frame *wh, const struct ieee80211_key *k,
519 struct ifnet *ifp = vap->iv_ifp;
521 IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_CRYPTO, wh->i_addr2,
522 "%s replay detected <rsc %ju, csc %ju, keyix %u rxkeyix %u>",
523 k->wk_cipher->ic_name, (intmax_t) rsc,
524 (intmax_t) k->wk_keyrsc[IEEE80211_NONQOS_TID],
525 k->wk_keyix, k->wk_rxkeyix);
527 if (ifp != NULL) { /* NB: for cipher test modules */
528 struct ieee80211_replay_event iev;
530 IEEE80211_ADDR_COPY(iev.iev_dst, wh->i_addr1);
531 IEEE80211_ADDR_COPY(iev.iev_src, wh->i_addr2);
532 iev.iev_cipher = k->wk_cipher->ic_cipher;
533 if (k->wk_rxkeyix != IEEE80211_KEYIX_NONE)
534 iev.iev_keyix = k->wk_rxkeyix;
536 iev.iev_keyix = k->wk_keyix;
537 iev.iev_keyrsc = k->wk_keyrsc[0]; /* XXX need tid */
539 rt_ieee80211msg(ifp, RTM_IEEE80211_REPLAY, &iev, sizeof(iev));
544 ieee80211_notify_michael_failure(struct ieee80211vap *vap,
545 const struct ieee80211_frame *wh, u_int keyix)
547 struct ifnet *ifp = vap->iv_ifp;
549 IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_CRYPTO, wh->i_addr2,
550 "michael MIC verification failed <keyix %u>", keyix);
551 vap->iv_stats.is_rx_tkipmic++;
553 if (ifp != NULL) { /* NB: for cipher test modules */
554 struct ieee80211_michael_event iev;
556 IEEE80211_ADDR_COPY(iev.iev_dst, wh->i_addr1);
557 IEEE80211_ADDR_COPY(iev.iev_src, wh->i_addr2);
558 iev.iev_cipher = IEEE80211_CIPHER_TKIP;
559 iev.iev_keyix = keyix;
560 rt_ieee80211msg(ifp, RTM_IEEE80211_MICHAEL, &iev, sizeof(iev));
565 ieee80211_notify_wds_discover(struct ieee80211_node *ni)
567 struct ieee80211vap *vap = ni->ni_vap;
568 struct ifnet *ifp = vap->iv_ifp;
570 notify_macaddr(ifp, RTM_IEEE80211_WDS, ni->ni_macaddr);
574 ieee80211_notify_csa(struct ieee80211com *ic,
575 const struct ieee80211_channel *c, int mode, int count)
577 struct ifnet *ifp = ic->ic_ifp;
578 struct ieee80211_csa_event iev;
580 memset(&iev, 0, sizeof(iev));
581 iev.iev_flags = c->ic_flags;
582 iev.iev_freq = c->ic_freq;
583 iev.iev_ieee = c->ic_ieee;
585 iev.iev_count = count;
586 rt_ieee80211msg(ifp, RTM_IEEE80211_CSA, &iev, sizeof(iev));
590 ieee80211_notify_radar(struct ieee80211com *ic,
591 const struct ieee80211_channel *c)
593 struct ifnet *ifp = ic->ic_ifp;
594 struct ieee80211_radar_event iev;
596 memset(&iev, 0, sizeof(iev));
597 iev.iev_flags = c->ic_flags;
598 iev.iev_freq = c->ic_freq;
599 iev.iev_ieee = c->ic_ieee;
600 rt_ieee80211msg(ifp, RTM_IEEE80211_RADAR, &iev, sizeof(iev));
604 ieee80211_notify_cac(struct ieee80211com *ic,
605 const struct ieee80211_channel *c, enum ieee80211_notify_cac_event type)
607 struct ifnet *ifp = ic->ic_ifp;
608 struct ieee80211_cac_event iev;
610 memset(&iev, 0, sizeof(iev));
611 iev.iev_flags = c->ic_flags;
612 iev.iev_freq = c->ic_freq;
613 iev.iev_ieee = c->ic_ieee;
615 rt_ieee80211msg(ifp, RTM_IEEE80211_CAC, &iev, sizeof(iev));
619 ieee80211_notify_node_deauth(struct ieee80211_node *ni)
621 struct ieee80211vap *vap = ni->ni_vap;
622 struct ifnet *ifp = vap->iv_ifp;
624 IEEE80211_NOTE(vap, IEEE80211_MSG_NODE, ni, "%s", "node deauth");
626 notify_macaddr(ifp, RTM_IEEE80211_DEAUTH, ni->ni_macaddr);
630 ieee80211_notify_node_auth(struct ieee80211_node *ni)
632 struct ieee80211vap *vap = ni->ni_vap;
633 struct ifnet *ifp = vap->iv_ifp;
635 IEEE80211_NOTE(vap, IEEE80211_MSG_NODE, ni, "%s", "node auth");
637 notify_macaddr(ifp, RTM_IEEE80211_AUTH, ni->ni_macaddr);
641 ieee80211_notify_country(struct ieee80211vap *vap,
642 const uint8_t bssid[IEEE80211_ADDR_LEN], const uint8_t cc[2])
644 struct ifnet *ifp = vap->iv_ifp;
645 struct ieee80211_country_event iev;
647 memset(&iev, 0, sizeof(iev));
648 IEEE80211_ADDR_COPY(iev.iev_addr, bssid);
649 iev.iev_cc[0] = cc[0];
650 iev.iev_cc[1] = cc[1];
651 rt_ieee80211msg(ifp, RTM_IEEE80211_COUNTRY, &iev, sizeof(iev));
655 ieee80211_notify_radio(struct ieee80211com *ic, int state)
657 struct ifnet *ifp = ic->ic_ifp;
658 struct ieee80211_radio_event iev;
660 memset(&iev, 0, sizeof(iev));
661 iev.iev_state = state;
662 rt_ieee80211msg(ifp, RTM_IEEE80211_RADIO, &iev, sizeof(iev));
666 ieee80211_load_module(const char *modname)
670 (void)kern_kldload(curthread, modname, NULL);
672 printf("%s: load the %s module by hand for now.\n", __func__, modname);
679 * NB: the module name is "wlan" for compatibility with NetBSD.
682 wlan_modevent(module_t mod, int type, void *unused)
687 printf("wlan: <802.11 Link Layer>\n");
688 if_clone_attach(&wlan_cloner);
689 if_register_com_alloc(IFT_IEEE80211, wlan_alloc, wlan_free);
692 if_deregister_com_alloc(IFT_IEEE80211);
693 if_clone_detach(&wlan_cloner);
699 static moduledata_t wlan_mod = {
704 DECLARE_MODULE(wlan, wlan_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);
705 MODULE_VERSION(wlan, 1);
706 MODULE_DEPEND(wlan, ether, 1, 1, 1);