diff options
author | pdw <> | 2011-10-03 21:46:35 +0000 |
---|---|---|
committer | pdw <> | 2011-10-03 21:46:35 +0000 |
commit | a85b2c76cdff2a82975ee53429de6992370dfc84 (patch) | |
tree | 8541f6097fdf43b48a3a0adb9ad23d34167b8b82 | |
parent | 067bc0d96f5bfc065c7033cce5e16e20e0170782 (diff) | |
download | iftop-a85b2c76cdff2a82975ee53429de6992370dfc84.zip |
Untested radiotap support.
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | ether.h | 10 | ||||
-rw-r--r-- | iftop.c | 31 |
3 files changed, 38 insertions, 5 deletions
diff --git a/configure.in b/configure.in index 2aee6e3..abc3138 100644 --- a/configure.in +++ b/configure.in @@ -29,7 +29,7 @@ AC_CONFIG_AUX_DIR(config) AC_CANONICAL_SYSTEM AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(iftop, "1.0pre1") +AM_INIT_AUTOMAKE(iftop, "1.0pre2") AC_DEFINE_UNQUOTED(IFTOP_VERSION, "$VERSION", [The iftop version number]) @@ -20,4 +20,14 @@ struct vlan_8021q_header { u_int16_t ether_type; }; +/* + * http://www.gsp.com/cgi-bin/man.cgi?section=9&topic=ieee80211_radiotap + */ +struct radiotap_header { + u_int8_t it_version; /* set to 0 */ + u_int8_t it_pad; + u_int16_t it_len; /* entire length */ + u_int32_t it_present; /* fields present */ +}; + #endif @@ -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; } |