[Click] [PATCH] Add channel information to annotation
Roberto Riggio
roberto.riggio at create-net.org
Tue Sep 29 16:31:36 EDT 2009
This patch adds the channel and the fhss info to the packet's annotation.
Tested with radiotap headers.
Signed-off-by: Roberto Riggio<roberto.riggio at create-net.org>
--
diff --git a/elements/wifi/radiotapdecap.cc b/elements/wifi/radiotapdecap.cc
index aef3e8e..552451b 100644
--- a/elements/wifi/radiotapdecap.cc
+++ b/elements/wifi/radiotapdecap.cc
@@ -25,6 +25,7 @@
#include<clicknet/radiotap.h>
#include<click/packet_anno.hh>
#include<clicknet/llc.h>
+#include<click/string.hh>
CLICK_DECLS
#define NUM_RADIOTAP_ELEMENTS 18
@@ -124,6 +125,14 @@ RadiotapDecap::simple_action(Packet *p)
if (rt_check_header(th, p->length())) {
ceh->magic = WIFI_EXTRA_MAGIC;
+ if (rt_el_present(th, IEEE80211_RADIOTAP_CHANNEL)) {
+ ceh->channel = *((u_int16_t *) rt_el_offset(th, IEEE80211_RADIOTAP_CHANNEL));
+ }
+
+ if (rt_el_present(th, IEEE80211_RADIOTAP_FHSS)) {
+ ceh->fhss = *((u_int16_t *) rt_el_offset(th, IEEE80211_RADIOTAP_FHSS));
+ }
+
if (rt_el_present(th, IEEE80211_RADIOTAP_RATE)) {
ceh->rate = *((u_int8_t *) rt_el_offset(th, IEEE80211_RADIOTAP_RATE));
}
diff --git a/include/click/packet_anno.hh b/include/click/packet_anno.hh
index f5c9955..f0706da 100644
--- a/include/click/packet_anno.hh
+++ b/include/click/packet_anno.hh
@@ -13,7 +13,7 @@
// bytes 16-31
#define WIFI_EXTRA_ANNO_OFFSET 16
-#define WIFI_EXTRA_ANNO_SIZE 24
+#define WIFI_EXTRA_ANNO_SIZE 28
#define WIFI_EXTRA_ANNO(p) ((click_wifi_extra *) ((p)->anno_u8() + WIFI_EXTRA_ANNO_OFFSET))
// byte 16
diff --git a/include/clicknet/wifi.h b/include/clicknet/wifi.h
index 4612e1f..b8d8ab7 100644
--- a/include/clicknet/wifi.h
+++ b/include/clicknet/wifi.h
@@ -31,6 +31,9 @@ struct click_wifi_extra {
uint32_t magic;
uint32_t flags;
+ uint16_t channel;
+ uint16_t fhss;
+
uint8_t rssi;
uint8_t silence;
uint8_t power;
More information about the click
mailing list