Page MenuHomeFreeBSD

D36469.id110219.diff
No OneTemporary

D36469.id110219.diff

diff --git a/sys/dev/wtap/if_wtap.c b/sys/dev/wtap/if_wtap.c
--- a/sys/dev/wtap/if_wtap.c
+++ b/sys/dev/wtap/if_wtap.c
@@ -235,6 +235,48 @@
DWTAP_PRINTF("%s\n", __func__);
}
+static void
+wtap_rx_tap(struct wtap_softc *sc, uint64_t tsf, int rssi, int nf)
+{
+ 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_antsignal = nf + rssi;
+ rh->wr_antnoise = nf;
+ rh->wr_antenna = 0;
+ rh->wr_chan_flags = IEEE80211_CHAN_CCK;
+ rh->wr_chan_freq = ic->ic_curchan->ic_freq;
+ rh->wr_chan_ieee = ic->ic_curchan->ic_ieee;
+ rh->wr_chan_maxpow = 1U << 7;
+}
+
+static void
+wtap_tx_tap(struct wtap_softc *sc, struct ieee80211_node *ni)
+{
+ 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_txpower = ieee80211_get_node_txpower(ni);
+ th->wt_antenna = 0;
+ th->wt_chan_flags = IEEE80211_CHAN_CCK;
+ th->wt_chan_freq = ic->ic_curchan->ic_freq;
+ th->wt_chan_ieee = ic->ic_curchan->ic_ieee;
+ th->wt_chan_maxpow = 1U << 7;
+}
+
static void
wtap_beacon_intrp(void *arg)
{
@@ -267,8 +309,12 @@
wh = mtod(m, struct ieee80211_frame *);
memcpy(&wh[1], &tsf, sizeof(tsf));
- if (ieee80211_radiotap_active_vap(vap))
+ if (ieee80211_radiotap_active_vap(vap)) {
+ struct ieee80211_node *ni = ieee80211_ref_node(vap->iv_bss);
+ wtap_tx_tap(sc, ni);
ieee80211_radiotap_tx(vap, m);
+ ieee80211_free_node(ni);
+ }
#if 0
medium_transmit(avp->av_md, avp->id, m);
@@ -485,6 +531,7 @@
}
if (ieee80211_radiotap_active_vap(vap)) {
+ wtap_tx_tap(sc, ni);
ieee80211_radiotap_tx(vap, m);
}
if (m->m_flags & M_TXCB)
@@ -548,6 +595,10 @@
#if 0
ieee80211_dump_pkt(ic, mtod(m, caddr_t), 0,0,0);
#endif
+ if (ieee80211_radiotap_active(ic)) {
+ uint64_t tsf = wtap_hal_get_tsf(sc->hal);
+ wtap_rx_tap(sc, tsf, 1<<7, 10);
+ }
/*
* Locate the node for sender, track state, and then
@@ -613,12 +664,15 @@
(struct ieee80211_node *) m->m_pkthdr.rcvif;
struct ieee80211vap *vap = ni->ni_vap;
struct wtap_vap *avp = WTAP_VAP(vap);
+ struct wtap_softc *sc = vap->iv_ic->ic_softc;
if(ni == NULL){
printf("m->m_pkthdr.rcvif is NULL we cant radiotap_tx\n");
}else{
- if (ieee80211_radiotap_active_vap(vap))
+ if (ieee80211_radiotap_active_vap(vap)) {
+ wtap_tx_tap(sc, ni);
ieee80211_radiotap_tx(vap, m);
+ }
}
if (m->m_flags & M_TXCB)
ieee80211_process_callback(ni, m, 0);
@@ -671,7 +725,8 @@
ic->ic_phytype = IEEE80211_T_DS;
ic->ic_opmode = IEEE80211_M_MBSS;
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 */
diff --git a/sys/dev/wtap/if_wtapioctl.h b/sys/dev/wtap/if_wtapioctl.h
--- a/sys/dev/wtap/if_wtapioctl.h
+++ b/sys/dev/wtap/if_wtapioctl.h
@@ -141,41 +141,51 @@
/*
* Radio capture format.
*/
-#define WTAP_RX_RADIOTAP_PRESENT ( \
+#define WTAP_RX_RADIOTAP_PRESENT ( \
+ (1 << IEEE80211_RADIOTAP_TSFT) | \
+ (1 << IEEE80211_RADIOTAP_FLAGS) | \
+ (1 << IEEE80211_RADIOTAP_RATE) | \
+ (1 << IEEE80211_RADIOTAP_ANTENNA) | \
+ (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \
+ (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) | \
+ (1 << IEEE80211_RADIOTAP_XCHANNEL) | \
0)
struct wtap_rx_radiotap_header {
struct ieee80211_radiotap_header wr_ihdr;
-#if 0
+
u_int64_t wr_tsf;
u_int8_t wr_flags;
u_int8_t wr_rate;
- int8_t wr_antsignal;
- int8_t wr_antnoise;
+ u_int8_t wr_antsignal;
+ u_int8_t wr_antnoise;
u_int8_t wr_antenna;
u_int8_t wr_pad[3];
u_int32_t wr_chan_flags;
u_int16_t wr_chan_freq;
u_int8_t wr_chan_ieee;
- int8_t wr_chan_maxpow;
-#endif
+ u_int8_t wr_chan_maxpow;
} __packed __aligned(8);
-#define WTAP_TX_RADIOTAP_PRESENT ( \
+#define WTAP_TX_RADIOTAP_PRESENT ( \
+ (1 << IEEE80211_RADIOTAP_FLAGS) | \
+ (1 << IEEE80211_RADIOTAP_RATE) | \
+ (1 << IEEE80211_RADIOTAP_DBM_TX_POWER) | \
+ (1 << IEEE80211_RADIOTAP_ANTENNA) | \
+ (1 << IEEE80211_RADIOTAP_XCHANNEL) | \
0)
struct wtap_tx_radiotap_header {
struct ieee80211_radiotap_header wt_ihdr;
-#if 0
+
u_int8_t wt_flags;
u_int8_t wt_rate;
- u_int8_t wt_txpower;
+ int8_t wt_txpower;
u_int8_t wt_antenna;
u_int32_t wt_chan_flags;
u_int16_t wt_chan_freq;
u_int8_t wt_chan_ieee;
- int8_t wt_chan_maxpow;
-#endif
-} __packed;
+ u_int8_t wt_chan_maxpow;
+} __packed __aligned(8);
#endif

File Metadata

Mime Type
text/plain
Expires
Fri, May 15, 8:49 PM (19 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33098471
Default Alt Text
D36469.id110219.diff (4 KB)

Event Timeline