2 * Copyright (c) 2010-2011 Monthadar Al Jaberi, TerraNet AB
5 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer,
13 * without modification.
14 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
15 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
16 * redistribution must be conditioned upon including a substantially
17 * similar Disclaimer requirement for further binary redistribution.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
23 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
24 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
25 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
28 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGES.
34 #include "if_wtapvar.h"
35 #include <sys/uio.h> /* uio struct */
37 #include <net/if_var.h>
40 #include <net80211/ieee80211_ratectl.h>
41 #include "if_medium.h"
43 /* device for IOCTL and read/write for debuggin purposes */
44 /* Function prototypes */
45 static d_open_t wtap_node_open;
46 static d_close_t wtap_node_close;
47 static d_write_t wtap_node_write;
48 static d_ioctl_t wtap_node_ioctl;
50 static struct cdevsw wtap_cdevsw = {
51 .d_version = D_VERSION,
53 .d_open = wtap_node_open,
54 .d_close = wtap_node_close,
55 .d_write = wtap_node_write,
56 .d_ioctl = wtap_node_ioctl,
61 wtap_node_open(struct cdev *dev, int oflags, int devtype, struct thread *p)
65 uprintf("Opened device \"echo\" successfully.\n");
70 wtap_node_close(struct cdev *dev, int fflag, int devtype, struct thread *p)
73 uprintf("Closing device \"echo.\"\n");
78 wtap_node_write(struct cdev *dev, struct uio *uio, int ioflag)
83 struct wtap_softc *sc;
87 uprintf("write device %s \"echo.\"\n", devtoname(dev));
88 buf_len = MIN(uio->uio_iov->iov_len, 1024);
89 err = copyin(uio->uio_iov->iov_base, buf, buf_len);
92 uprintf("Write failed: bad address!\n");
96 MGETHDR(m, M_DONTWAIT, MT_DATA);
97 m_copyback(m, 0, buf_len, buf);
99 CURVNET_SET(TD_TO_VNET(curthread));
100 IFNET_RLOCK_NOSLEEP();
102 TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
103 printf("ifp->if_xname = %s\n", ifp->if_xname);
104 if(strcmp(devtoname(dev), ifp->if_xname) == 0){
105 printf("found match, correspoding wtap = %s\n",
107 sc = (struct wtap_softc *)ifp->if_softc;
108 printf("wtap id = %d\n", sc->id);
113 IFNET_RUNLOCK_NOSLEEP();
120 wtap_node_ioctl(struct cdev *dev, u_long cmd, caddr_t data,
121 int fflag, struct thread *td)
127 DWTAP_PRINTF("Unkown WTAP IOCTL\n");
133 static int wtap_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
134 const struct ieee80211_bpf_params *params);
137 wtap_medium_enqueue(struct wtap_vap *avp, struct mbuf *m)
140 return medium_transmit(avp->av_md, avp->id, m);
144 wtap_media_change(struct ifnet *ifp)
147 DWTAP_PRINTF("%s\n", __func__);
148 int error = ieee80211_media_change(ifp);
149 /* NB: only the fixed rate can change and that doesn't need a reset */
150 return (error == ENETRESET ? 0 : error);
154 * Intercept management frames to collect beacon rssi data
155 * and to do ibss merges.
158 wtap_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m,
159 int subtype, int rssi, int nf)
161 struct ieee80211vap *vap = ni->ni_vap;
163 DWTAP_PRINTF("[%d] %s\n", myath_id(ni), __func__);
165 WTAP_VAP(vap)->av_recv_mgmt(ni, m, subtype, rssi, nf);
169 wtap_reset_vap(struct ieee80211vap *vap, u_long cmd)
172 DWTAP_PRINTF("%s\n", __func__);
177 wtap_beacon_update(struct ieee80211vap *vap, int item)
179 struct ieee80211_beacon_offsets *bo = &WTAP_VAP(vap)->av_boff;
181 DWTAP_PRINTF("%s\n", __func__);
182 setbit(bo->bo_flags, item);
186 * Allocate and setup an initial beacon frame.
189 wtap_beacon_alloc(struct wtap_softc *sc, struct ieee80211_node *ni)
191 struct ieee80211vap *vap = ni->ni_vap;
192 struct wtap_vap *avp = WTAP_VAP(vap);
194 DWTAP_PRINTF("[%s] %s\n", ether_sprintf(ni->ni_macaddr), __func__);
197 * NB: the beacon data buffer must be 32-bit aligned;
198 * we assume the mbuf routines will return us something
199 * with this alignment (perhaps should assert).
201 avp->beacon = ieee80211_beacon_alloc(ni, &avp->av_boff);
202 if (avp->beacon == NULL) {
203 printf("%s: cannot get mbuf\n", __func__);
206 callout_init(&avp->av_swba, 0);
207 avp->bf_node = ieee80211_ref_node(ni);
213 wtap_beacon_config(struct wtap_softc *sc, struct ieee80211vap *vap)
216 DWTAP_PRINTF("%s\n", __func__);
220 wtap_beacon_intrp(void *arg)
222 struct wtap_vap *avp = arg;
223 struct ieee80211vap *vap = arg;
226 KASSERT(vap->iv_state >= IEEE80211_S_RUN,
227 ("not running, state %d", vap->iv_state));
228 DWTAP_PRINTF("[%d] beacon intrp\n", avp->id); //burst mode
230 * Update dynamic beacon contents. If this returns
231 * non-zero then we need to remap the memory because
232 * the beacon frame changed size (probably because
233 * of the TIM bitmap).
235 m = m_dup(avp->beacon, M_DONTWAIT);
236 if (ieee80211_beacon_update(avp->bf_node, &avp->av_boff, m, 0)) {
237 printf("%s, need to remap the memory because the beacon frame"
238 " changed size.\n",__func__);
241 if (ieee80211_radiotap_active_vap(vap))
242 ieee80211_radiotap_tx(vap, m);
245 medium_transmit(avp->av_md, avp->id, m);
247 wtap_medium_enqueue(avp, m);
248 callout_schedule(&avp->av_swba, avp->av_bcinterval);
252 wtap_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
254 struct ieee80211com *ic = vap->iv_ic;
255 struct wtap_softc *sc = ic->ic_ifp->if_softc;
256 struct wtap_vap *avp = WTAP_VAP(vap);
257 struct ieee80211_node *ni = NULL;
260 DWTAP_PRINTF("%s\n", __func__);
264 * Invoke the parent method to do net80211 work.
266 error = avp->av_newstate(vap, nstate, arg);
270 if (nstate == IEEE80211_S_RUN) {
271 /* NB: collect bss node again, it may have changed */
273 switch (vap->iv_opmode) {
274 case IEEE80211_M_MBSS:
275 error = wtap_beacon_alloc(sc, ni);
278 wtap_beacon_config(sc, vap);
279 callout_reset(&avp->av_swba, avp->av_bcinterval,
280 wtap_beacon_intrp, vap);
288 printf("%s: bad\n", __func__);
293 wtap_bmiss(struct ieee80211vap *vap)
295 struct wtap_vap *avp = (struct wtap_vap *)vap;
297 DWTAP_PRINTF("%s\n", __func__);
301 static struct ieee80211vap *
302 wtap_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ],
303 int unit, enum ieee80211_opmode opmode, int flags,
304 const uint8_t bssid[IEEE80211_ADDR_LEN],
305 const uint8_t mac[IEEE80211_ADDR_LEN])
307 struct wtap_softc *sc = ic->ic_ifp->if_softc;
308 struct ieee80211vap *vap;
309 struct wtap_vap *avp;
312 DWTAP_PRINTF("%s\n", __func__);
314 avp = (struct wtap_vap *) malloc(sizeof(struct wtap_vap),
315 M_80211_VAP, M_NOWAIT | M_ZERO);
317 avp->av_md = sc->sc_md;
318 avp->av_bcinterval = BEACON_INTRERVAL + 100*sc->id;
319 vap = (struct ieee80211vap *) avp;
320 error = ieee80211_vap_setup(ic, vap, name, unit, IEEE80211_M_MBSS,
321 flags | IEEE80211_CLONE_NOBEACONS, bssid, mac);
323 /* override various methods */
324 avp->av_recv_mgmt = vap->iv_recv_mgmt;
325 vap->iv_recv_mgmt = wtap_recv_mgmt;
326 vap->iv_reset = wtap_reset_vap;
327 vap->iv_update_beacon = wtap_beacon_update;
328 avp->av_newstate = vap->iv_newstate;
329 vap->iv_newstate = wtap_newstate;
330 avp->av_bmiss = vap->iv_bmiss;
331 vap->iv_bmiss = wtap_bmiss;
334 ieee80211_vap_attach(vap, wtap_media_change, ieee80211_media_status);
335 avp->av_dev = make_dev(&wtap_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600,
336 (const char *)ic->ic_ifp->if_xname);
338 /* TODO this is a hack to force it to choose the rate we want */
339 vap->iv_bss->ni_txrate = 130;
344 wtap_vap_delete(struct ieee80211vap *vap)
346 struct wtap_vap *avp = WTAP_VAP(vap);
348 DWTAP_PRINTF("%s\n", __func__);
349 destroy_dev(avp->av_dev);
350 callout_stop(&avp->av_swba);
351 ieee80211_vap_detach(vap);
352 free((struct wtap_vap*) vap, M_80211_VAP);
355 /* NB: This function is not used.
356 * I had the problem of the queue
357 * being empty all the time.
358 * Maybe I am setting the queue wrong?
361 wtap_start(struct ifnet *ifp)
363 struct ieee80211com *ic = ifp->if_l2com;
364 struct ifnet *icifp = ic->ic_ifp;
365 struct wtap_softc *sc = icifp->if_softc;
366 struct ieee80211_node *ni;
369 DWTAP_PRINTF("my_start, with id=%u\n", sc->id);
371 if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || sc->up == 0)
374 if(IFQ_IS_EMPTY(&ifp->if_snd)){
375 printf("queue empty, just trying to see "
376 "if the other queue is empty\n");
378 printf("queue for id=1, %u\n",
379 IFQ_IS_EMPTY(&global_mscs[1]->ifp->if_snd));
380 printf("queue for id=0, %u\n",
381 IFQ_IS_EMPTY(&global_mscs[0]->ifp->if_snd));
385 IFQ_DEQUEUE(&ifp->if_snd, m);
387 printf("error dequeueing from ifp->snd\n");
390 ni = (struct ieee80211_node *) m->m_pkthdr.rcvif;
392 * Check for fragmentation. If this frame
393 * has been broken up verify we have enough
394 * buffers to send all the fragments so all
400 if ((m->m_flags & M_FRAG)){
401 printf("dont support frags\n");
406 if(wtap_raw_xmit(ni, m, NULL) < 0){
407 printf("error raw_xmiting\n");
415 wtap_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
418 DWTAP_PRINTF("%s\n", __func__);
419 uprintf("%s, command %lu\n", __func__, cmd);
421 #define IS_RUNNING(ifp) \
422 ((ifp->if_flags & IFF_UP) && (ifp->if_drv_flags & IFF_DRV_RUNNING))
423 struct ieee80211com *ic = ifp->if_l2com;
424 struct wtap_softc *sc = ifp->if_softc;
425 struct ifreq *ifr = (struct ifreq *)data;
430 //printf("%s: %s\n", __func__, "SIOCSIFFLAGS");
431 if (IS_RUNNING(ifp)) {
432 DWTAP_PRINTF("running\n");
435 * To avoid rescanning another access point,
436 * do not call ath_init() here. Instead,
437 * only reflect promisc mode settings.
441 } else if (ifp->if_flags & IFF_UP) {
442 DWTAP_PRINTF("up\n");
446 * Beware of being called during attach/detach
447 * to reset promiscuous mode. In that case we
448 * will still be marked UP but not RUNNING.
449 * However trying to re-init the interface
450 * is the wrong thing to do as we've already
451 * torn down much of our state. There's
452 * probably a better way to deal with this.
454 //if (!sc->sc_invalid)
455 // ath_init(sc); /* XXX lose error */
457 ifp->if_drv_flags |= IFF_DRV_RUNNING;
458 ieee80211_start_all(ic);
460 DWTAP_PRINTF("stoping\n");
462 ath_stop_locked(ifp);
464 /* XXX must wakeup in places like ath_vap_delete */
466 ath_hal_setpower(sc->sc_ah, HAL_PM_FULL_SLEEP);
474 DWTAP_PRINTF("%s: %s\n", __func__, "SIOCGIFMEDIA|SIOCSIFMEDIA");
476 error = ifmedia_ioctl(ifp, ifr, &ic->ic_media, cmd);
480 DWTAP_PRINTF("%s: %s\n", __func__, "SIOCGIFADDR");
482 error = ether_ioctl(ifp, cmd, data);
485 DWTAP_PRINTF("%s: %s [%lu]\n", __func__, "EINVAL", cmd);
494 wtap_init(void *arg){
496 DWTAP_PRINTF("%s\n", __func__);
500 wtap_scan_start(struct ieee80211com *ic)
504 DWTAP_PRINTF("%s\n", __func__);
509 wtap_scan_end(struct ieee80211com *ic)
513 DWTAP_PRINTF("%s\n", __func__);
518 wtap_set_channel(struct ieee80211com *ic)
522 DWTAP_PRINTF("%s\n", __func__);
527 wtap_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
528 const struct ieee80211_bpf_params *params)
531 DWTAP_PRINTF("%s, %p\n", __func__, m);
533 struct ieee80211vap *vap = ni->ni_vap;
534 struct wtap_vap *avp = WTAP_VAP(vap);
536 if (ieee80211_radiotap_active_vap(vap)) {
537 ieee80211_radiotap_tx(vap, m);
539 if (m->m_flags & M_TXCB)
540 ieee80211_process_callback(ni, m, 0);
541 ieee80211_free_node(ni);
542 return wtap_medium_enqueue(avp, m);
546 wtap_inject(struct wtap_softc *sc, struct mbuf *m)
548 struct wtap_buf *bf = (struct wtap_buf *)malloc(sizeof(struct wtap_buf),
549 M_WTAP_RXBUF, M_NOWAIT | M_ZERO);
550 KASSERT(bf != NULL, ("could not allocated a new wtap_buf\n"));
553 mtx_lock(&sc->sc_mtx);
554 STAILQ_INSERT_TAIL(&sc->sc_rxbuf, bf, bf_list);
555 taskqueue_enqueue(sc->sc_tq, &sc->sc_rxtask);
556 mtx_unlock(&sc->sc_mtx);
560 wtap_rx_deliver(struct wtap_softc *sc, struct mbuf *m)
562 struct ifnet *ifp = sc->sc_ifp;
563 struct ieee80211com *ic = ifp->if_l2com;
564 struct ieee80211_node *ni;
567 DWTAP_PRINTF("%s\n", __func__);
570 DWTAP_PRINTF("[%d] receiving m=%p\n", sc->id, m);
571 if (m == NULL) { /* NB: shouldn't happen */
572 if_printf(ifp, "%s: no mbuf!\n", __func__);
577 ieee80211_dump_pkt(ic, mtod(m, caddr_t), 0,0,0);
580 * Locate the node for sender, track state, and then
581 * pass the (referenced) node up to the 802.11 layer
584 ni = ieee80211_find_rxnode_withkey(ic,
585 mtod(m, const struct ieee80211_frame_min *),IEEE80211_KEYIX_NONE);
588 * Sending station is known, dispatch directly.
590 type = ieee80211_input(ni, m, 1<<7, 10);
591 ieee80211_free_node(ni);
593 type = ieee80211_input_all(ic, m, 1<<7, 10);
598 wtap_rx_proc(void *arg, int npending)
600 struct wtap_softc *sc = (struct wtap_softc *)arg;
601 struct ifnet *ifp = sc->sc_ifp;
602 struct ieee80211com *ic = ifp->if_l2com;
604 struct ieee80211_node *ni;
609 DWTAP_PRINTF("%s\n", __func__);
613 mtx_lock(&sc->sc_mtx);
614 bf = STAILQ_FIRST(&sc->sc_rxbuf);
616 mtx_unlock(&sc->sc_mtx);
619 STAILQ_REMOVE_HEAD(&sc->sc_rxbuf, bf_list);
620 mtx_unlock(&sc->sc_mtx);
621 KASSERT(bf != NULL, ("wtap_buf is NULL\n"));
623 DWTAP_PRINTF("[%d] receiving m=%p\n", sc->id, bf->m);
624 if (m == NULL) { /* NB: shouldn't happen */
625 if_printf(ifp, "%s: no mbuf!\n", __func__);
626 free(bf, M_WTAP_RXBUF);
632 ieee80211_dump_pkt(ic, mtod(m, caddr_t), 0,0,0);
636 * Locate the node for sender, track state, and then
637 * pass the (referenced) node up to the 802.11 layer
640 ni = ieee80211_find_rxnode_withkey(ic,
641 mtod(m, const struct ieee80211_frame_min *),
642 IEEE80211_KEYIX_NONE);
645 * Sending station is known, dispatch directly.
648 ieee80211_radiotap_rx(ni->ni_vap, m);
650 type = ieee80211_input(ni, m, 1<<7, 10);
651 ieee80211_free_node(ni);
654 ieee80211_radiotap_rx_all(ic, m);
656 type = ieee80211_input_all(ic, m, 1<<7, 10);
659 /* The mbufs are freed by the Net80211 stack */
660 free(bf, M_WTAP_RXBUF);
665 wtap_newassoc(struct ieee80211_node *ni, int isnew)
668 DWTAP_PRINTF("%s\n", __func__);
672 * Callback from the 802.11 layer to update WME parameters.
675 wtap_wme_update(struct ieee80211com *ic)
678 DWTAP_PRINTF("%s\n", __func__);
683 wtap_update_mcast(struct ifnet *ifp)
686 DWTAP_PRINTF("%s\n", __func__);
690 wtap_update_promisc(struct ifnet *ifp)
693 DWTAP_PRINTF("%s\n", __func__);
697 wtap_if_transmit(struct ifnet *ifp, struct mbuf *m)
699 struct ieee80211_node *ni =
700 (struct ieee80211_node *) m->m_pkthdr.rcvif;
701 struct ieee80211vap *vap = ni->ni_vap;
702 struct wtap_vap *avp = WTAP_VAP(vap);
705 printf("m->m_pkthdr.rcvif is NULL we cant radiotap_tx\n");
707 if (ieee80211_radiotap_active_vap(vap))
708 ieee80211_radiotap_tx(vap, m);
710 if (m->m_flags & M_TXCB)
711 ieee80211_process_callback(ni, m, 0);
712 ieee80211_free_node(ni);
713 return wtap_medium_enqueue(avp, m);
716 static struct ieee80211_node *
717 wtap_node_alloc(struct ieee80211vap *vap, const uint8_t mac[IEEE80211_ADDR_LEN])
719 struct ieee80211_node *ni;
721 DWTAP_PRINTF("%s\n", __func__);
723 ni = malloc(sizeof(struct ieee80211_node), M_80211_NODE,
731 wtap_node_free(struct ieee80211_node *ni)
733 struct ieee80211com *ic = ni->ni_ic;
734 struct wtap_softc *sc = ic->ic_ifp->if_softc;
736 DWTAP_PRINTF("%s\n", __func__);
737 sc->sc_node_free(ni);
741 wtap_attach(struct wtap_softc *sc, const uint8_t *macaddr)
744 struct ieee80211com *ic;
745 char wtap_name[] = {'w','T','a','p',sc->id,
746 '_','t','a','s','k','q','\0'};
748 DWTAP_PRINTF("%s\n", __func__);
750 ifp = if_alloc(IFT_IEEE80211);
752 printf("can not if_alloc()\n");
756 if_initname(ifp, "wtap", sc->id);
761 STAILQ_INIT(&sc->sc_rxbuf);
762 sc->sc_tq = taskqueue_create(wtap_name, M_NOWAIT | M_ZERO,
763 taskqueue_thread_enqueue, &sc->sc_tq);
764 taskqueue_start_threads(&sc->sc_tq, 1, PI_SOFT, "%s taskQ",
766 TASK_INIT(&sc->sc_rxtask, 0, wtap_rx_proc, sc);
769 ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST;
770 ifp->if_start = wtap_start;
771 ifp->if_ioctl = wtap_ioctl;
772 ifp->if_init = wtap_init;
773 IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
774 ifp->if_snd.ifq_drv_maxlen = ifqmaxlen;
775 IFQ_SET_READY(&ifp->if_snd);
778 ic->ic_phytype = IEEE80211_T_DS;
779 ic->ic_opmode = IEEE80211_M_MBSS;
780 ic->ic_caps = IEEE80211_C_MBSS;
782 ic->ic_max_keyix = 128; /* A value read from Atheros ATH_KEYMAX */
784 ic->ic_regdomain.regdomain = SKU_ETSI;
785 ic->ic_regdomain.country = CTRY_SWEDEN;
786 ic->ic_regdomain.location = 1; /* Indoors */
787 ic->ic_regdomain.isocc[0] = 'S';
788 ic->ic_regdomain.isocc[1] = 'E';
790 * Indicate we need the 802.11 header padded to a
791 * 32-bit boundary for 4-address and QoS frames.
793 ic->ic_flags |= IEEE80211_F_DATAPAD;
795 ic->ic_channels[0].ic_flags = IEEE80211_CHAN_B;
796 ic->ic_channels[0].ic_freq = 2412;
798 ieee80211_ifattach(ic, macaddr);
801 /* new prototype hook-ups */
802 msc->if_input = ifp->if_input;
803 ifp->if_input = myath_if_input;
804 msc->if_output = ifp->if_output;
805 ifp->if_output = myath_if_output;
807 sc->if_transmit = ifp->if_transmit;
808 ifp->if_transmit = wtap_if_transmit;
810 /* override default methods */
811 ic->ic_newassoc = wtap_newassoc;
813 ic->ic_updateslot = myath_updateslot;
815 ic->ic_wme.wme_update = wtap_wme_update;
816 ic->ic_vap_create = wtap_vap_create;
817 ic->ic_vap_delete = wtap_vap_delete;
818 ic->ic_raw_xmit = wtap_raw_xmit;
819 ic->ic_update_mcast = wtap_update_mcast;
820 ic->ic_update_promisc = wtap_update_promisc;
822 sc->sc_node_alloc = ic->ic_node_alloc;
823 ic->ic_node_alloc = wtap_node_alloc;
824 sc->sc_node_free = ic->ic_node_free;
825 ic->ic_node_free = wtap_node_free;
828 ic->ic_node_getsignal = myath_node_getsignal;
830 ic->ic_scan_start = wtap_scan_start;
831 ic->ic_scan_end = wtap_scan_end;
832 ic->ic_set_channel = wtap_set_channel;
834 ieee80211_radiotap_attach(ic,
835 &sc->sc_tx_th.wt_ihdr, sizeof(sc->sc_tx_th),
836 WTAP_TX_RADIOTAP_PRESENT,
837 &sc->sc_rx_th.wr_ihdr, sizeof(sc->sc_rx_th),
838 WTAP_RX_RADIOTAP_PRESENT);
840 /* Work here, we must find a way to populate the rate table */
842 if(ic->ic_rt == NULL){
843 printf("no table for ic_curchan\n");
844 ic->ic_rt = ieee80211_get_ratetable(&ic->ic_channels[0]);
846 printf("ic->ic_rt =%p\n", ic->ic_rt);
847 printf("rate count %d\n", ic->ic_rt->rateCount);
849 uint8_t code = ic->ic_rt->info[0].dot11Rate;
850 uint8_t cix = ic->ic_rt->info[0].ctlRateIndex;
851 uint8_t ctl_rate = ic->ic_rt->info[cix].dot11Rate;
852 printf("code=%d, cix=%d, ctl_rate=%d\n", code, cix, ctl_rate);
854 uint8_t rix0 = ic->ic_rt->rateCodeToIndex[130];
855 uint8_t rix1 = ic->ic_rt->rateCodeToIndex[132];
856 uint8_t rix2 = ic->ic_rt->rateCodeToIndex[139];
857 uint8_t rix3 = ic->ic_rt->rateCodeToIndex[150];
858 printf("rix0 %u,rix1 %u,rix2 %u,rix3 %u\n", rix0,rix1,rix2,rix3);
859 printf("lpAckDuration=%u\n", ic->ic_rt->info[0].lpAckDuration);
860 printf("rate=%d\n", ic->ic_rt->info[0].rateKbps);
866 wtap_detach(struct wtap_softc *sc)
868 struct ifnet *ifp = sc->sc_ifp;
869 struct ieee80211com *ic = ifp->if_l2com;
871 DWTAP_PRINTF("%s\n", __func__);
872 ieee80211_ageq_drain(&ic->ic_stageq);
873 ieee80211_ifdetach(ic);
879 wtap_resume(struct wtap_softc *sc)
882 DWTAP_PRINTF("%s\n", __func__);
886 wtap_suspend(struct wtap_softc *sc)
889 DWTAP_PRINTF("%s\n", __func__);
893 wtap_shutdown(struct wtap_softc *sc)
896 DWTAP_PRINTF("%s\n", __func__);
900 wtap_intr(struct wtap_softc *sc)
903 DWTAP_PRINTF("%s\n", __func__);