Deleted Added
full compact
if_wtap.c (286410) if_wtap.c (286437)
1/*-
2 * Copyright (c) 2010-2011 Monthadar Al Jaberi, TerraNet AB
3 * All rights reserved.
4 *
5 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 15 unchanged lines hidden (view full) ---

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.
31 *
1/*-
2 * Copyright (c) 2010-2011 Monthadar Al Jaberi, TerraNet AB
3 * All rights reserved.
4 *
5 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 15 unchanged lines hidden (view full) ---

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.
31 *
32 * $FreeBSD: head/sys/dev/wtap/if_wtap.c 286410 2015-08-07 11:43:14Z glebius $
32 * $FreeBSD: head/sys/dev/wtap/if_wtap.c 286437 2015-08-08 01:10:17Z adrian $
33 */
34#include "if_wtapvar.h"
35#include <sys/uio.h> /* uio struct */
36#include <sys/jail.h>
37#include <net/if_var.h>
38#include <net/vnet.h>
39
40#include <net80211/ieee80211_ratectl.h>

--- 215 unchanged lines hidden (view full) ---

256 wtap_medium_enqueue(avp, m);
257 callout_schedule(&avp->av_swba, avp->av_bcinterval);
258}
259
260static int
261wtap_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
262{
263 struct ieee80211com *ic = vap->iv_ic;
33 */
34#include "if_wtapvar.h"
35#include <sys/uio.h> /* uio struct */
36#include <sys/jail.h>
37#include <net/if_var.h>
38#include <net/vnet.h>
39
40#include <net80211/ieee80211_ratectl.h>

--- 215 unchanged lines hidden (view full) ---

256 wtap_medium_enqueue(avp, m);
257 callout_schedule(&avp->av_swba, avp->av_bcinterval);
258}
259
260static int
261wtap_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
262{
263 struct ieee80211com *ic = vap->iv_ic;
264 struct wtap_softc *sc = ic->ic_softc;
264 struct wtap_softc *sc = ic->ic_ifp->if_softc;
265 struct wtap_vap *avp = WTAP_VAP(vap);
266 struct ieee80211_node *ni = NULL;
267 int error;
268
269 DWTAP_PRINTF("%s\n", __func__);
270
271 ni = ieee80211_ref_node(vap->iv_bss);
272 /*

--- 40 unchanged lines hidden (view full) ---

313}
314
315static struct ieee80211vap *
316wtap_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ],
317 int unit, enum ieee80211_opmode opmode, int flags,
318 const uint8_t bssid[IEEE80211_ADDR_LEN],
319 const uint8_t mac[IEEE80211_ADDR_LEN])
320{
265 struct wtap_vap *avp = WTAP_VAP(vap);
266 struct ieee80211_node *ni = NULL;
267 int error;
268
269 DWTAP_PRINTF("%s\n", __func__);
270
271 ni = ieee80211_ref_node(vap->iv_bss);
272 /*

--- 40 unchanged lines hidden (view full) ---

313}
314
315static struct ieee80211vap *
316wtap_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ],
317 int unit, enum ieee80211_opmode opmode, int flags,
318 const uint8_t bssid[IEEE80211_ADDR_LEN],
319 const uint8_t mac[IEEE80211_ADDR_LEN])
320{
321 struct wtap_softc *sc = ic->ic_softc;
321 struct wtap_softc *sc = ic->ic_ifp->if_softc;
322 struct ieee80211vap *vap;
323 struct wtap_vap *avp;
324 int error;
325 struct ieee80211_node *ni;
326
327 DWTAP_PRINTF("%s\n", __func__);
328
322 struct ieee80211vap *vap;
323 struct wtap_vap *avp;
324 int error;
325 struct ieee80211_node *ni;
326
327 DWTAP_PRINTF("%s\n", __func__);
328
329 avp = malloc(sizeof(struct wtap_vap), M_80211_VAP, M_WAITOK | M_ZERO);
329 avp = malloc(sizeof(struct wtap_vap), M_80211_VAP, M_NOWAIT | M_ZERO);
330 if (avp == NULL)
331 return (NULL);
330 avp->id = sc->id;
331 avp->av_md = sc->sc_md;
332 avp->av_bcinterval = msecs_to_ticks(BEACON_INTRERVAL + 100*sc->id);
333 vap = (struct ieee80211vap *) avp;
334 error = ieee80211_vap_setup(ic, vap, name, unit, IEEE80211_M_MBSS,
332 avp->id = sc->id;
333 avp->av_md = sc->sc_md;
334 avp->av_bcinterval = msecs_to_ticks(BEACON_INTRERVAL + 100*sc->id);
335 vap = (struct ieee80211vap *) avp;
336 error = ieee80211_vap_setup(ic, vap, name, unit, IEEE80211_M_MBSS,
335 flags | IEEE80211_CLONE_NOBEACONS, bssid);
337 flags | IEEE80211_CLONE_NOBEACONS, bssid, mac);
336 if (error) {
337 free(avp, M_80211_VAP);
338 return (NULL);
339 }
340
341 /* override various methods */
342 avp->av_recv_mgmt = vap->iv_recv_mgmt;
343 vap->iv_recv_mgmt = wtap_recv_mgmt;
344 vap->iv_reset = wtap_reset_vap;
345 vap->iv_update_beacon = wtap_beacon_update;
346 avp->av_newstate = vap->iv_newstate;
347 vap->iv_newstate = wtap_newstate;
348 avp->av_bmiss = vap->iv_bmiss;
349 vap->iv_bmiss = wtap_bmiss;
350
351 /* complete setup */
338 if (error) {
339 free(avp, M_80211_VAP);
340 return (NULL);
341 }
342
343 /* override various methods */
344 avp->av_recv_mgmt = vap->iv_recv_mgmt;
345 vap->iv_recv_mgmt = wtap_recv_mgmt;
346 vap->iv_reset = wtap_reset_vap;
347 vap->iv_update_beacon = wtap_beacon_update;
348 avp->av_newstate = vap->iv_newstate;
349 vap->iv_newstate = wtap_newstate;
350 avp->av_bmiss = vap->iv_bmiss;
351 vap->iv_bmiss = wtap_bmiss;
352
353 /* complete setup */
352 ieee80211_vap_attach(vap, wtap_media_change, ieee80211_media_status,
353 mac);
354 ieee80211_vap_attach(vap, wtap_media_change, ieee80211_media_status);
354 avp->av_dev = make_dev(&wtap_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600,
355 avp->av_dev = make_dev(&wtap_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600,
355 "%s", (const char *)sc->name);
356 "%s", (const char *)ic->ic_ifp->if_xname);
356
357 /* TODO this is a hack to force it to choose the rate we want */
358 ni = ieee80211_ref_node(vap->iv_bss);
359 ni->ni_txrate = 130;
360 ieee80211_free_node(ni);
361 return vap;
362}
363

--- 4 unchanged lines hidden (view full) ---

368
369 DWTAP_PRINTF("%s\n", __func__);
370 destroy_dev(avp->av_dev);
371 callout_stop(&avp->av_swba);
372 ieee80211_vap_detach(vap);
373 free((struct wtap_vap*) vap, M_80211_VAP);
374}
375
357
358 /* TODO this is a hack to force it to choose the rate we want */
359 ni = ieee80211_ref_node(vap->iv_bss);
360 ni->ni_txrate = 130;
361 ieee80211_free_node(ni);
362 return vap;
363}
364

--- 4 unchanged lines hidden (view full) ---

369
370 DWTAP_PRINTF("%s\n", __func__);
371 destroy_dev(avp->av_dev);
372 callout_stop(&avp->av_swba);
373 ieee80211_vap_detach(vap);
374 free((struct wtap_vap*) vap, M_80211_VAP);
375}
376
377/* NB: This function is not used.
378 * I had the problem of the queue
379 * being empty all the time.
380 * Maybe I am setting the queue wrong?
381 */
376static void
382static void
377wtap_parent(struct ieee80211com *ic)
383wtap_start(struct ifnet *ifp)
378{
384{
379 struct wtap_softc *sc = ic->ic_softc;
385 struct ieee80211com *ic = ifp->if_l2com;
386 struct ifnet *icifp = ic->ic_ifp;
387 struct wtap_softc *sc = icifp->if_softc;
388 struct ieee80211_node *ni;
389 struct mbuf *m;
380
390
381 if (ic->ic_nrunning > 0) {
382 sc->up = 1;
383 ieee80211_start_all(ic);
384 } else
385 sc->up = 0;
391 DWTAP_PRINTF("my_start, with id=%u\n", sc->id);
392
393 if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || sc->up == 0)
394 return;
395 for (;;) {
396 if(IFQ_IS_EMPTY(&ifp->if_snd)){
397 printf("queue empty, just trying to see "
398 "if the other queue is empty\n");
399#if 0
400 printf("queue for id=1, %u\n",
401 IFQ_IS_EMPTY(&global_mscs[1]->ifp->if_snd));
402 printf("queue for id=0, %u\n",
403 IFQ_IS_EMPTY(&global_mscs[0]->ifp->if_snd));
404#endif
405 break;
406 }
407 IFQ_DEQUEUE(&ifp->if_snd, m);
408 if (m == NULL) {
409 printf("error dequeueing from ifp->snd\n");
410 break;
411 }
412 ni = (struct ieee80211_node *) m->m_pkthdr.rcvif;
413 /*
414 * Check for fragmentation. If this frame
415 * has been broken up verify we have enough
416 * buffers to send all the fragments so all
417 * go out or none...
418 */
419#if 0
420 STAILQ_INIT(&frags);
421#endif
422 if ((m->m_flags & M_FRAG)){
423 printf("dont support frags\n");
424 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
425 return;
426 }
427 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
428 if(wtap_raw_xmit(ni, m, NULL) < 0){
429 printf("error raw_xmiting\n");
430 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
431 return;
432 }
433 }
386}
387
434}
435
436static int
437wtap_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
438{
439#if 0
440 DWTAP_PRINTF("%s\n", __func__);
441 uprintf("%s, command %lu\n", __func__, cmd);
442#endif
443#define IS_RUNNING(ifp) \
444 ((ifp->if_flags & IFF_UP) && (ifp->if_drv_flags & IFF_DRV_RUNNING))
445 struct ieee80211com *ic = ifp->if_l2com;
446 struct wtap_softc *sc = ifp->if_softc;
447 struct ifreq *ifr = (struct ifreq *)data;
448 int error = 0;
449
450 switch (cmd) {
451 case SIOCSIFFLAGS:
452 //printf("%s: %s\n", __func__, "SIOCSIFFLAGS");
453 if (IS_RUNNING(ifp)) {
454 DWTAP_PRINTF("running\n");
455#if 0
456 /*
457 * To avoid rescanning another access point,
458 * do not call ath_init() here. Instead,
459 * only reflect promisc mode settings.
460 */
461 //ath_mode_init(sc);
462#endif
463 } else if (ifp->if_flags & IFF_UP) {
464 DWTAP_PRINTF("up\n");
465 sc->up = 1;
466#if 0
467 /*
468 * Beware of being called during attach/detach
469 * to reset promiscuous mode. In that case we
470 * will still be marked UP but not RUNNING.
471 * However trying to re-init the interface
472 * is the wrong thing to do as we've already
473 * torn down much of our state. There's
474 * probably a better way to deal with this.
475 */
476 //if (!sc->sc_invalid)
477 // ath_init(sc); /* XXX lose error */
478#endif
479 ifp->if_drv_flags |= IFF_DRV_RUNNING;
480 ieee80211_start_all(ic);
481 } else {
482 DWTAP_PRINTF("stoping\n");
483#if 0
484 ath_stop_locked(ifp);
485#ifdef notyet
486 /* XXX must wakeup in places like ath_vap_delete */
487 if (!sc->sc_invalid)
488 ath_hal_setpower(sc->sc_ah, HAL_PM_FULL_SLEEP);
489#endif
490#endif
491 }
492 break;
493 case SIOCGIFMEDIA:
494 case SIOCSIFMEDIA:
495#if 0
496 DWTAP_PRINTF("%s: %s\n", __func__, "SIOCGIFMEDIA|SIOCSIFMEDIA");
497#endif
498 error = ifmedia_ioctl(ifp, ifr, &ic->ic_media, cmd);
499 break;
500 case SIOCGIFADDR:
501#if 0
502 DWTAP_PRINTF("%s: %s\n", __func__, "SIOCGIFADDR");
503#endif
504 error = ether_ioctl(ifp, cmd, data);
505 break;
506 default:
507 DWTAP_PRINTF("%s: %s [%lu]\n", __func__, "EINVAL", cmd);
508 error = EINVAL;
509 break;
510 }
511 return error;
512#undef IS_RUNNING
513}
514
388static void
515static void
516wtap_init(void *arg){
517
518 DWTAP_PRINTF("%s\n", __func__);
519}
520
521static void
389wtap_scan_start(struct ieee80211com *ic)
390{
391
392#if 0
393 DWTAP_PRINTF("%s\n", __func__);
394#endif
395}
396

--- 46 unchanged lines hidden (view full) ---

443 STAILQ_INSERT_TAIL(&sc->sc_rxbuf, bf, bf_list);
444 taskqueue_enqueue(sc->sc_tq, &sc->sc_rxtask);
445 mtx_unlock(&sc->sc_mtx);
446}
447
448void
449wtap_rx_deliver(struct wtap_softc *sc, struct mbuf *m)
450{
522wtap_scan_start(struct ieee80211com *ic)
523{
524
525#if 0
526 DWTAP_PRINTF("%s\n", __func__);
527#endif
528}
529

--- 46 unchanged lines hidden (view full) ---

576 STAILQ_INSERT_TAIL(&sc->sc_rxbuf, bf, bf_list);
577 taskqueue_enqueue(sc->sc_tq, &sc->sc_rxtask);
578 mtx_unlock(&sc->sc_mtx);
579}
580
581void
582wtap_rx_deliver(struct wtap_softc *sc, struct mbuf *m)
583{
451 struct ieee80211com *ic = &sc->sc_ic;
584 struct ifnet *ifp = sc->sc_ifp;
585 struct ieee80211com *ic = ifp->if_l2com;
452 struct ieee80211_node *ni;
453 int type;
454#if 0
455 DWTAP_PRINTF("%s\n", __func__);
456#endif
457
458 DWTAP_PRINTF("[%d] receiving m=%p\n", sc->id, m);
459 if (m == NULL) { /* NB: shouldn't happen */
586 struct ieee80211_node *ni;
587 int type;
588#if 0
589 DWTAP_PRINTF("%s\n", __func__);
590#endif
591
592 DWTAP_PRINTF("[%d] receiving m=%p\n", sc->id, m);
593 if (m == NULL) { /* NB: shouldn't happen */
460 ic_printf(ic, "%s: no mbuf!\n", __func__);
594 if_printf(ifp, "%s: no mbuf!\n", __func__);
461 }
462
595 }
596
597 if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
598
463 ieee80211_dump_pkt(ic, mtod(m, caddr_t), 0,0,0);
464
465 /*
466 * Locate the node for sender, track state, and then
467 * pass the (referenced) node up to the 802.11 layer
468 * for its use.
469 */
470 ni = ieee80211_find_rxnode_withkey(ic,

--- 8 unchanged lines hidden (view full) ---

479 type = ieee80211_input_all(ic, m, 1<<7, 10);
480 }
481}
482
483static void
484wtap_rx_proc(void *arg, int npending)
485{
486 struct wtap_softc *sc = (struct wtap_softc *)arg;
599 ieee80211_dump_pkt(ic, mtod(m, caddr_t), 0,0,0);
600
601 /*
602 * Locate the node for sender, track state, and then
603 * pass the (referenced) node up to the 802.11 layer
604 * for its use.
605 */
606 ni = ieee80211_find_rxnode_withkey(ic,

--- 8 unchanged lines hidden (view full) ---

615 type = ieee80211_input_all(ic, m, 1<<7, 10);
616 }
617}
618
619static void
620wtap_rx_proc(void *arg, int npending)
621{
622 struct wtap_softc *sc = (struct wtap_softc *)arg;
487 struct ieee80211com *ic = &sc->sc_ic;
623 struct ifnet *ifp = sc->sc_ifp;
624 struct ieee80211com *ic = ifp->if_l2com;
488 struct mbuf *m;
489 struct ieee80211_node *ni;
490 int type;
491 struct wtap_buf *bf;
492
493#if 0
494 DWTAP_PRINTF("%s\n", __func__);
495#endif

--- 6 unchanged lines hidden (view full) ---

502 return;
503 }
504 STAILQ_REMOVE_HEAD(&sc->sc_rxbuf, bf_list);
505 mtx_unlock(&sc->sc_mtx);
506 KASSERT(bf != NULL, ("wtap_buf is NULL\n"));
507 m = bf->m;
508 DWTAP_PRINTF("[%d] receiving m=%p\n", sc->id, bf->m);
509 if (m == NULL) { /* NB: shouldn't happen */
625 struct mbuf *m;
626 struct ieee80211_node *ni;
627 int type;
628 struct wtap_buf *bf;
629
630#if 0
631 DWTAP_PRINTF("%s\n", __func__);
632#endif

--- 6 unchanged lines hidden (view full) ---

639 return;
640 }
641 STAILQ_REMOVE_HEAD(&sc->sc_rxbuf, bf_list);
642 mtx_unlock(&sc->sc_mtx);
643 KASSERT(bf != NULL, ("wtap_buf is NULL\n"));
644 m = bf->m;
645 DWTAP_PRINTF("[%d] receiving m=%p\n", sc->id, bf->m);
646 if (m == NULL) { /* NB: shouldn't happen */
510 ic_printf(ic, "%s: no mbuf!\n", __func__);
647 if_printf(ifp, "%s: no mbuf!\n", __func__);
511 free(bf, M_WTAP_RXBUF);
512 return;
513 }
648 free(bf, M_WTAP_RXBUF);
649 return;
650 }
651
652 if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
514#if 0
515 ieee80211_dump_pkt(ic, mtod(m, caddr_t), 0,0,0);
516#endif
517
518 /*
519 * Locate the node for sender, track state, and then
520 * pass the (referenced) node up to the 802.11 layer
521 * for its use.

--- 50 unchanged lines hidden (view full) ---

572static void
573wtap_update_promisc(struct ieee80211com *ic)
574{
575
576 DWTAP_PRINTF("%s\n", __func__);
577}
578
579static int
653#if 0
654 ieee80211_dump_pkt(ic, mtod(m, caddr_t), 0,0,0);
655#endif
656
657 /*
658 * Locate the node for sender, track state, and then
659 * pass the (referenced) node up to the 802.11 layer
660 * for its use.

--- 50 unchanged lines hidden (view full) ---

711static void
712wtap_update_promisc(struct ieee80211com *ic)
713{
714
715 DWTAP_PRINTF("%s\n", __func__);
716}
717
718static int
580wtap_transmit(struct ieee80211com *ic, struct mbuf *m)
719wtap_if_transmit(struct ifnet *ifp, struct mbuf *m)
581{
582 struct ieee80211_node *ni =
583 (struct ieee80211_node *) m->m_pkthdr.rcvif;
584 struct ieee80211vap *vap = ni->ni_vap;
585 struct wtap_vap *avp = WTAP_VAP(vap);
586
587 if(ni == NULL){
588 printf("m->m_pkthdr.rcvif is NULL we cant radiotap_tx\n");

--- 20 unchanged lines hidden (view full) ---

609 ni->ni_txrate = 130;
610 return ni;
611}
612
613static void
614wtap_node_free(struct ieee80211_node *ni)
615{
616 struct ieee80211com *ic = ni->ni_ic;
720{
721 struct ieee80211_node *ni =
722 (struct ieee80211_node *) m->m_pkthdr.rcvif;
723 struct ieee80211vap *vap = ni->ni_vap;
724 struct wtap_vap *avp = WTAP_VAP(vap);
725
726 if(ni == NULL){
727 printf("m->m_pkthdr.rcvif is NULL we cant radiotap_tx\n");

--- 20 unchanged lines hidden (view full) ---

748 ni->ni_txrate = 130;
749 return ni;
750}
751
752static void
753wtap_node_free(struct ieee80211_node *ni)
754{
755 struct ieee80211com *ic = ni->ni_ic;
617 struct wtap_softc *sc = ic->ic_softc;
756 struct wtap_softc *sc = ic->ic_ifp->if_softc;
618
619 DWTAP_PRINTF("%s\n", __func__);
620 sc->sc_node_free(ni);
621}
622
623int32_t
624wtap_attach(struct wtap_softc *sc, const uint8_t *macaddr)
625{
757
758 DWTAP_PRINTF("%s\n", __func__);
759 sc->sc_node_free(ni);
760}
761
762int32_t
763wtap_attach(struct wtap_softc *sc, const uint8_t *macaddr)
764{
626 struct ieee80211com *ic = &sc->sc_ic;
765 struct ifnet *ifp;
766 struct ieee80211com *ic;
767 char wtap_name[] = {'w','T','a','p',sc->id,
768 '_','t','a','s','k','q','\0'};
627
628 DWTAP_PRINTF("%s\n", __func__);
629
769
770 DWTAP_PRINTF("%s\n", __func__);
771
772 ifp = if_alloc(IFT_IEEE80211);
773 if (ifp == NULL) {
774 printf("can not if_alloc()\n");
775 return -1;
776 }
777 ic = ifp->if_l2com;
778 if_initname(ifp, "wtap", sc->id);
779
780 sc->sc_ifp = ifp;
630 sc->up = 0;
781 sc->up = 0;
782
631 STAILQ_INIT(&sc->sc_rxbuf);
783 STAILQ_INIT(&sc->sc_rxbuf);
632 sc->sc_tq = taskqueue_create("wtap_taskq", M_NOWAIT | M_ZERO,
784 sc->sc_tq = taskqueue_create(wtap_name, M_NOWAIT | M_ZERO,
633 taskqueue_thread_enqueue, &sc->sc_tq);
785 taskqueue_thread_enqueue, &sc->sc_tq);
634 taskqueue_start_threads(&sc->sc_tq, 1, PI_SOFT, "%s taskQ", sc->name);
786 taskqueue_start_threads(&sc->sc_tq, 1, PI_SOFT, "%s taskQ",
787 ifp->if_xname);
635 TASK_INIT(&sc->sc_rxtask, 0, wtap_rx_proc, sc);
636
788 TASK_INIT(&sc->sc_rxtask, 0, wtap_rx_proc, sc);
789
790 ifp->if_softc = sc;
791 ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST;
792 ifp->if_start = wtap_start;
793 ifp->if_ioctl = wtap_ioctl;
794 ifp->if_init = wtap_init;
795 IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
796 ifp->if_snd.ifq_drv_maxlen = ifqmaxlen;
797 IFQ_SET_READY(&ifp->if_snd);
798
799 ic->ic_ifp = ifp;
637 ic->ic_softc = sc;
638 ic->ic_name = sc->name;
639 ic->ic_phytype = IEEE80211_T_DS;
640 ic->ic_opmode = IEEE80211_M_MBSS;
641 ic->ic_caps = IEEE80211_C_MBSS;
642
643 ic->ic_max_keyix = 128; /* A value read from Atheros ATH_KEYMAX */
644
645 ic->ic_regdomain.regdomain = SKU_ETSI;
646 ic->ic_regdomain.country = CTRY_SWEDEN;
647 ic->ic_regdomain.location = 1; /* Indoors */
648 ic->ic_regdomain.isocc[0] = 'S';
649 ic->ic_regdomain.isocc[1] = 'E';
650
651 ic->ic_nchans = 1;
652 ic->ic_channels[0].ic_flags = IEEE80211_CHAN_B;
653 ic->ic_channels[0].ic_freq = 2412;
654
800 ic->ic_softc = sc;
801 ic->ic_name = sc->name;
802 ic->ic_phytype = IEEE80211_T_DS;
803 ic->ic_opmode = IEEE80211_M_MBSS;
804 ic->ic_caps = IEEE80211_C_MBSS;
805
806 ic->ic_max_keyix = 128; /* A value read from Atheros ATH_KEYMAX */
807
808 ic->ic_regdomain.regdomain = SKU_ETSI;
809 ic->ic_regdomain.country = CTRY_SWEDEN;
810 ic->ic_regdomain.location = 1; /* Indoors */
811 ic->ic_regdomain.isocc[0] = 'S';
812 ic->ic_regdomain.isocc[1] = 'E';
813
814 ic->ic_nchans = 1;
815 ic->ic_channels[0].ic_flags = IEEE80211_CHAN_B;
816 ic->ic_channels[0].ic_freq = 2412;
817
655 IEEE80211_ADDR_COPY(ic->ic_macaddr, macaddr);
656 ieee80211_ifattach(ic);
818 ieee80211_ifattach(ic, macaddr);
657
819
820#if 0
821 /* new prototype hook-ups */
822 msc->if_input = ifp->if_input;
823 ifp->if_input = myath_if_input;
824 msc->if_output = ifp->if_output;
825 ifp->if_output = myath_if_output;
826#endif
827 sc->if_transmit = ifp->if_transmit;
828 ifp->if_transmit = wtap_if_transmit;
829
658 /* override default methods */
659 ic->ic_newassoc = wtap_newassoc;
660 ic->ic_wme.wme_update = wtap_wme_update;
661 ic->ic_vap_create = wtap_vap_create;
662 ic->ic_vap_delete = wtap_vap_delete;
663 ic->ic_raw_xmit = wtap_raw_xmit;
664 ic->ic_update_mcast = wtap_update_mcast;
665 ic->ic_update_promisc = wtap_update_promisc;
830 /* override default methods */
831 ic->ic_newassoc = wtap_newassoc;
832 ic->ic_wme.wme_update = wtap_wme_update;
833 ic->ic_vap_create = wtap_vap_create;
834 ic->ic_vap_delete = wtap_vap_delete;
835 ic->ic_raw_xmit = wtap_raw_xmit;
836 ic->ic_update_mcast = wtap_update_mcast;
837 ic->ic_update_promisc = wtap_update_promisc;
666 ic->ic_transmit = wtap_transmit;
667 ic->ic_parent = wtap_parent;
668
669 sc->sc_node_alloc = ic->ic_node_alloc;
670 ic->ic_node_alloc = wtap_node_alloc;
671 sc->sc_node_free = ic->ic_node_free;
672 ic->ic_node_free = wtap_node_free;
673
838
839 sc->sc_node_alloc = ic->ic_node_alloc;
840 ic->ic_node_alloc = wtap_node_alloc;
841 sc->sc_node_free = ic->ic_node_free;
842 ic->ic_node_free = wtap_node_free;
843
844#if 0
845 ic->ic_node_getsignal = myath_node_getsignal;
846#endif
674 ic->ic_scan_start = wtap_scan_start;
675 ic->ic_scan_end = wtap_scan_end;
676 ic->ic_set_channel = wtap_set_channel;
677
678 ieee80211_radiotap_attach(ic,
679 &sc->sc_tx_th.wt_ihdr, sizeof(sc->sc_tx_th),
680 WTAP_TX_RADIOTAP_PRESENT,
681 &sc->sc_rx_th.wr_ihdr, sizeof(sc->sc_rx_th),

--- 22 unchanged lines hidden (view full) ---

704 printf("rate=%d\n", ic->ic_rt->info[0].rateKbps);
705#endif
706 return 0;
707}
708
709int32_t
710wtap_detach(struct wtap_softc *sc)
711{
847 ic->ic_scan_start = wtap_scan_start;
848 ic->ic_scan_end = wtap_scan_end;
849 ic->ic_set_channel = wtap_set_channel;
850
851 ieee80211_radiotap_attach(ic,
852 &sc->sc_tx_th.wt_ihdr, sizeof(sc->sc_tx_th),
853 WTAP_TX_RADIOTAP_PRESENT,
854 &sc->sc_rx_th.wr_ihdr, sizeof(sc->sc_rx_th),

--- 22 unchanged lines hidden (view full) ---

877 printf("rate=%d\n", ic->ic_rt->info[0].rateKbps);
878#endif
879 return 0;
880}
881
882int32_t
883wtap_detach(struct wtap_softc *sc)
884{
712 struct ieee80211com *ic = &sc->sc_ic;
885 struct ifnet *ifp = sc->sc_ifp;
886 struct ieee80211com *ic = ifp->if_l2com;
713
714 DWTAP_PRINTF("%s\n", __func__);
715 ieee80211_ageq_drain(&ic->ic_stageq);
716 ieee80211_ifdetach(ic);
887
888 DWTAP_PRINTF("%s\n", __func__);
889 ieee80211_ageq_drain(&ic->ic_stageq);
890 ieee80211_ifdetach(ic);
891 if_free(ifp);
717 return 0;
718}
719
720void
721wtap_resume(struct wtap_softc *sc)
722{
723
724 DWTAP_PRINTF("%s\n", __func__);

--- 22 unchanged lines hidden ---
892 return 0;
893}
894
895void
896wtap_resume(struct wtap_softc *sc)
897{
898
899 DWTAP_PRINTF("%s\n", __func__);

--- 22 unchanged lines hidden ---