summaryrefslogtreecommitdiff
path: root/iftop.c
diff options
context:
space:
mode:
authorpdw <>2011-10-03 21:46:35 +0000
committerpdw <>2011-10-03 21:46:35 +0000
commita85b2c76cdff2a82975ee53429de6992370dfc84 (patch)
tree8541f6097fdf43b48a3a0adb9ad23d34167b8b82 /iftop.c
parent067bc0d96f5bfc065c7033cce5e16e20e0170782 (diff)
downloadiftop-a85b2c76cdff2a82975ee53429de6992370dfc84.zip
Untested radiotap support.
Diffstat (limited to 'iftop.c')
-rw-r--r--iftop.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/iftop.c b/iftop.c
index a604350..43329f8 100644
--- a/iftop.c
+++ b/iftop.c
@@ -81,8 +81,12 @@ static void finish(int sig) {
-/* Only need ethernet (plus optional 4 byte VLAN) and IP headers (48) + first 2 bytes of tcp/udp header */
+/* Only need ethernet (plus optional 4 byte VLAN) and IP headers (48) + first 2
+ * bytes of tcp/udp header */
/* Increase with a further 20 to account for IPv6 header length. */
+/* IEEE 802.11 radiotap throws in a variable length header plus 8 (radiotap
+ * header header) plus 30 (802.11 MAC) plus 40 (IPv6) = 78, plus whatever's in
+ * the radiotap payload */
#define CAPTURE_LENGTH 92
void init_history() {
@@ -230,8 +234,8 @@ static void handle_ip_packet(struct ip* iptr, int hw_dir)
int direction = 0; /* incoming */
history_type* ht;
union {
- history_type **ht_pp;
- void **void_pp;
+ history_type **ht_pp;
+ void **void_pp;
} u_ht = { &ht };
addr_pair ap;
unsigned int len = 0;
@@ -446,7 +450,7 @@ static void handle_pflog_packet(unsigned char* args, const struct pcap_pkthdr* p
hdrlen = BPF_WORDALIGN(hdr->length);
length -= hdrlen;
packet += hdrlen;
- handle_ip_packet((struct ip*)packet, length);
+ handle_ip_packet((struct ip*)packet, -1);
}
#endif
@@ -600,6 +604,20 @@ static void handle_eth_packet(unsigned char* args, const struct pcap_pkthdr* pkt
}
}
+#ifdef DLT_IEEE802_11_RADIO
+/*
+ * Packets with a bonus radiotap header.
+ * See http://www.gsp.com/cgi-bin/man.cgi?section=9&topic=ieee80211_radiotap
+ */
+static void handle_radiotap_packet(unsigned char* args, const struct pcap_pkthdr* pkthdr, const unsigned char* packet)
+{
+ /* 802.11 MAC header is = 30 bytes */
+ /* We could try harder to figure out hardware direction from the MAC header */
+ handle_ip_packet((struct ip*)(packet + ((struct radiotap_header *)packet)->it_len + 30),-1);
+}
+
+
+#endif
/* set_filter_code:
* Install some filter code. Returns NULL on success or an error message on
@@ -699,6 +717,11 @@ void packet_init() {
packet_handler = handle_null_packet;
}
#endif
+#ifdef DLT_IEEE802_11_RADIO
+ else if(dlt == DLT_IEEE802_11_RADIO) {
+ packet_handler = handle_radiotap_packet;
+ }
+#endif
else if(dlt == DLT_IEEE802) {
packet_handler = handle_tokenring_packet;
}