Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/wtap/if_wtap.c
Show First 20 Lines • Show All 230 Lines • ▼ Show 20 Lines | |||||
static void | static void | ||||
wtap_beacon_config(struct wtap_softc *sc, struct ieee80211vap *vap) | wtap_beacon_config(struct wtap_softc *sc, struct ieee80211vap *vap) | ||||
{ | { | ||||
DWTAP_PRINTF("%s\n", __func__); | DWTAP_PRINTF("%s\n", __func__); | ||||
} | } | ||||
static void | static void | ||||
wtap_rx_tap(struct wtap_softc *sc, uint64_t tsf) | |||||
{ | |||||
struct ieee80211com *ic = &sc->sc_ic; | |||||
const struct ieee80211_rate_table *rt = ic->ic_rt; | |||||
struct wtap_rx_radiotap_header *rh = &sc->sc_rx_th; | |||||
rh->wr_tsf = tsf; | |||||
rh->wr_flags = 0; | |||||
if (rt->rateCount) { | |||||
/* choose the fastest rate */ | |||||
rh->wr_rate = IEEE80211_RV(rt->info[rt->rateCount - 1].dot11Rate); | |||||
} | |||||
rh->wr_chan_flags = IEEE80211_CHAN_2GHZ; | |||||
rh->wr_chan_freq = ic->ic_curchan->ic_freq; | |||||
rh->wr_chan_ieee = ic->ic_curchan->ic_ieee; | |||||
rh->wr_chan_maxpow = 0; | |||||
} | |||||
static void | |||||
wtap_tx_tap(struct wtap_softc *sc) | |||||
{ | |||||
struct ieee80211com *ic = &sc->sc_ic; | |||||
const struct ieee80211_rate_table *rt = ic->ic_rt; | |||||
struct wtap_tx_radiotap_header *th = &sc->sc_tx_th; | |||||
th->wt_flags = 0; | |||||
if (rt->rateCount) { | |||||
/* choose the fastest rate */ | |||||
th->wt_rate = IEEE80211_RV(rt->info[rt->rateCount - 1].dot11Rate); | |||||
} | |||||
th->wt_chan_flags = IEEE80211_CHAN_2GHZ; | |||||
th->wt_chan_freq = ic->ic_curchan->ic_freq; | |||||
th->wt_chan_ieee = ic->ic_curchan->ic_ieee; | |||||
th->wt_chan_maxpow = 0; | |||||
} | |||||
static void | |||||
wtap_beacon_intrp(void *arg) | wtap_beacon_intrp(void *arg) | ||||
{ | { | ||||
struct wtap_vap *avp = arg; | struct wtap_vap *avp = arg; | ||||
struct ieee80211vap *vap = arg; | struct ieee80211vap *vap = arg; | ||||
struct wtap_softc *sc = vap->iv_ic->ic_softc; | struct wtap_softc *sc = vap->iv_ic->ic_softc; | ||||
struct ieee80211_frame *wh; | struct ieee80211_frame *wh; | ||||
struct mbuf *m; | struct mbuf *m; | ||||
uint64_t tsf; | uint64_t tsf; | ||||
Show All 15 Lines | printf("%s, need to remap the memory because the beacon frame" | ||||
" changed size.\n",__func__); | " changed size.\n",__func__); | ||||
} | } | ||||
/* Get TSF from HAL, and insert it into beacon frame */ | /* Get TSF from HAL, and insert it into beacon frame */ | ||||
tsf = wtap_hal_get_tsf(sc->hal); | tsf = wtap_hal_get_tsf(sc->hal); | ||||
wh = mtod(m, struct ieee80211_frame *); | wh = mtod(m, struct ieee80211_frame *); | ||||
memcpy(&wh[1], &tsf, sizeof(tsf)); | memcpy(&wh[1], &tsf, sizeof(tsf)); | ||||
if (ieee80211_radiotap_active_vap(vap)) | if (ieee80211_radiotap_active_vap(vap)) { | ||||
wtap_tx_tap(sc); | |||||
ieee80211_radiotap_tx(vap, m); | ieee80211_radiotap_tx(vap, m); | ||||
} | |||||
#if 0 | #if 0 | ||||
medium_transmit(avp->av_md, avp->id, m); | medium_transmit(avp->av_md, avp->id, m); | ||||
#endif | #endif | ||||
wtap_medium_enqueue(avp, m); | wtap_medium_enqueue(avp, m); | ||||
callout_schedule(&avp->av_swba, avp->av_bcinterval); | callout_schedule(&avp->av_swba, avp->av_bcinterval); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 200 Lines • ▼ Show 20 Lines | #endif | ||||
/* insert TSF into prob resp */ | /* insert TSF into prob resp */ | ||||
if (vap->iv_opmode == IEEE80211_M_HOSTAP && | if (vap->iv_opmode == IEEE80211_M_HOSTAP && | ||||
subtype == IEEE80211_FC0_SUBTYPE_PROBE_RESP) { | subtype == IEEE80211_FC0_SUBTYPE_PROBE_RESP) { | ||||
uint64_t tsf = wtap_hal_get_tsf(sc->hal); | uint64_t tsf = wtap_hal_get_tsf(sc->hal); | ||||
memcpy(&wh[1], &tsf, sizeof(tsf)); | memcpy(&wh[1], &tsf, sizeof(tsf)); | ||||
} | } | ||||
if (ieee80211_radiotap_active_vap(vap)) { | if (ieee80211_radiotap_active_vap(vap)) { | ||||
wtap_tx_tap(sc); | |||||
ieee80211_radiotap_tx(vap, m); | ieee80211_radiotap_tx(vap, m); | ||||
} | } | ||||
if (m->m_flags & M_TXCB) | if (m->m_flags & M_TXCB) | ||||
ieee80211_process_callback(ni, m, 0); | ieee80211_process_callback(ni, m, 0); | ||||
ieee80211_free_node(ni); | ieee80211_free_node(ni); | ||||
return wtap_medium_enqueue(avp, m); | return wtap_medium_enqueue(avp, m); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | for(;;) { | ||||
* It's weird to do this, but sometimes wtap will | * It's weird to do this, but sometimes wtap will | ||||
* receive AMPDU packets (like ping(8)) even when | * receive AMPDU packets (like ping(8)) even when | ||||
* the ic does not supports 11n HT. | * the ic does not supports 11n HT. | ||||
*/ | */ | ||||
m->m_flags &= ~M_AMPDU; | m->m_flags &= ~M_AMPDU; | ||||
#if 0 | #if 0 | ||||
ieee80211_dump_pkt(ic, mtod(m, caddr_t), 0,0,0); | ieee80211_dump_pkt(ic, mtod(m, caddr_t), 0,0,0); | ||||
#endif | #endif | ||||
if (ieee80211_radiotap_active(ic)) { | |||||
uint64_t tsf = wtap_hal_get_tsf(sc->hal); | |||||
wtap_rx_tap(sc, tsf); | |||||
} | |||||
/* | /* | ||||
* Locate the node for sender, track state, and then | * Locate the node for sender, track state, and then | ||||
* pass the (referenced) node up to the 802.11 layer | * pass the (referenced) node up to the 802.11 layer | ||||
* for its use. | * for its use. | ||||
*/ | */ | ||||
ni = ieee80211_find_rxnode_withkey(ic, | ni = ieee80211_find_rxnode_withkey(ic, | ||||
mtod(m, const struct ieee80211_frame_min *), | mtod(m, const struct ieee80211_frame_min *), | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | |||||
static int | static int | ||||
wtap_transmit(struct ieee80211com *ic, struct mbuf *m) | wtap_transmit(struct ieee80211com *ic, struct mbuf *m) | ||||
{ | { | ||||
struct ieee80211_node *ni = | struct ieee80211_node *ni = | ||||
(struct ieee80211_node *) m->m_pkthdr.rcvif; | (struct ieee80211_node *) m->m_pkthdr.rcvif; | ||||
struct ieee80211vap *vap = ni->ni_vap; | struct ieee80211vap *vap = ni->ni_vap; | ||||
struct wtap_vap *avp = WTAP_VAP(vap); | struct wtap_vap *avp = WTAP_VAP(vap); | ||||
struct wtap_softc *sc = vap->iv_ic->ic_softc; | |||||
if(ni == NULL){ | if(ni == NULL){ | ||||
printf("m->m_pkthdr.rcvif is NULL we cant radiotap_tx\n"); | printf("m->m_pkthdr.rcvif is NULL we cant radiotap_tx\n"); | ||||
}else{ | }else{ | ||||
if (ieee80211_radiotap_active_vap(vap)) | if (ieee80211_radiotap_active_vap(vap)) { | ||||
wtap_tx_tap(sc); | |||||
ieee80211_radiotap_tx(vap, m); | ieee80211_radiotap_tx(vap, m); | ||||
} | } | ||||
} | |||||
if (m->m_flags & M_TXCB) | if (m->m_flags & M_TXCB) | ||||
ieee80211_process_callback(ni, m, 0); | ieee80211_process_callback(ni, m, 0); | ||||
ieee80211_free_node(ni); | ieee80211_free_node(ni); | ||||
return wtap_medium_enqueue(avp, m); | return wtap_medium_enqueue(avp, m); | ||||
} | } | ||||
static struct ieee80211_node * | static struct ieee80211_node * | ||||
wtap_node_alloc(struct ieee80211vap *vap, const uint8_t mac[IEEE80211_ADDR_LEN]) | wtap_node_alloc(struct ieee80211vap *vap, const uint8_t mac[IEEE80211_ADDR_LEN]) | ||||
Show All 35 Lines | wtap_attach(struct wtap_softc *sc, const uint8_t *macaddr) | ||||
taskqueue_start_threads(&sc->sc_tq, 1, PI_SOFT, "%s taskQ", sc->name); | taskqueue_start_threads(&sc->sc_tq, 1, PI_SOFT, "%s taskQ", sc->name); | ||||
NET_TASK_INIT(&sc->sc_rxtask, 0, wtap_rx_proc, sc); | NET_TASK_INIT(&sc->sc_rxtask, 0, wtap_rx_proc, sc); | ||||
ic->ic_softc = sc; | ic->ic_softc = sc; | ||||
ic->ic_name = sc->name; | ic->ic_name = sc->name; | ||||
ic->ic_phytype = IEEE80211_T_DS; | ic->ic_phytype = IEEE80211_T_DS; | ||||
ic->ic_opmode = IEEE80211_M_MBSS; | ic->ic_opmode = IEEE80211_M_MBSS; | ||||
ic->ic_caps = IEEE80211_C_MBSS | IEEE80211_C_IBSS | | ic->ic_caps = IEEE80211_C_MBSS | IEEE80211_C_IBSS | | ||||
IEEE80211_C_STA | IEEE80211_C_HOSTAP; | IEEE80211_C_STA | IEEE80211_C_HOSTAP | | ||||
IEEE80211_C_MONITOR; | |||||
ic->ic_max_keyix = 128; /* A value read from Atheros ATH_KEYMAX */ | ic->ic_max_keyix = 128; /* A value read from Atheros ATH_KEYMAX */ | ||||
ic->ic_regdomain.regdomain = SKU_ETSI; | ic->ic_regdomain.regdomain = SKU_ETSI; | ||||
ic->ic_regdomain.country = CTRY_SWEDEN; | ic->ic_regdomain.country = CTRY_SWEDEN; | ||||
ic->ic_regdomain.location = 1; /* Indoors */ | ic->ic_regdomain.location = 1; /* Indoors */ | ||||
ic->ic_regdomain.isocc[0] = 'S'; | ic->ic_regdomain.isocc[0] = 'S'; | ||||
ic->ic_regdomain.isocc[1] = 'E'; | ic->ic_regdomain.isocc[1] = 'E'; | ||||
▲ Show 20 Lines • Show All 97 Lines • Show Last 20 Lines |