Page MenuHomeFreeBSD

D36469.diff
No OneTemporary

D36469.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,43 @@
DWTAP_PRINTF("%s\n", __func__);
}
+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)
{
@@ -267,8 +304,10 @@
wh = mtod(m, struct ieee80211_frame *);
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);
+ }
#if 0
medium_transmit(avp->av_md, avp->id, m);
@@ -485,6 +524,7 @@
}
if (ieee80211_radiotap_active_vap(vap)) {
+ wtap_tx_tap(sc);
ieee80211_radiotap_tx(vap, m);
}
if (m->m_flags & M_TXCB)
@@ -548,6 +588,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);
+ }
/*
* Locate the node for sender, track state, and then
@@ -613,12 +657,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);
ieee80211_radiotap_tx(vap, m);
+ }
}
if (m->m_flags & M_TXCB)
ieee80211_process_callback(ni, m, 0);
@@ -671,7 +718,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,42 @@
/*
* 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_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_antenna;
- u_int8_t wr_pad[3];
+ u_int8_t wr_pad[2];
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_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;
- u_int8_t wt_antenna;
+ u_int8_t wr_pad[2];
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, 3:39 AM (15 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33071935
Default Alt Text
D36469.diff (4 KB)

Event Timeline