Untested radiotap support.
This commit is contained in:
@@ -29,7 +29,7 @@ AC_CONFIG_AUX_DIR(config)
|
|||||||
AC_CANONICAL_SYSTEM
|
AC_CANONICAL_SYSTEM
|
||||||
|
|
||||||
AM_CONFIG_HEADER(config.h)
|
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])
|
AC_DEFINE_UNQUOTED(IFTOP_VERSION, "$VERSION", [The iftop version number])
|
||||||
|
|
||||||
|
|||||||
10
ether.h
10
ether.h
@@ -20,4 +20,14 @@ struct vlan_8021q_header {
|
|||||||
u_int16_t ether_type;
|
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
|
#endif
|
||||||
|
|||||||
31
iftop.c
31
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. */
|
/* 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
|
#define CAPTURE_LENGTH 92
|
||||||
|
|
||||||
void init_history() {
|
void init_history() {
|
||||||
@@ -230,8 +234,8 @@ static void handle_ip_packet(struct ip* iptr, int hw_dir)
|
|||||||
int direction = 0; /* incoming */
|
int direction = 0; /* incoming */
|
||||||
history_type* ht;
|
history_type* ht;
|
||||||
union {
|
union {
|
||||||
history_type **ht_pp;
|
history_type **ht_pp;
|
||||||
void **void_pp;
|
void **void_pp;
|
||||||
} u_ht = { &ht };
|
} u_ht = { &ht };
|
||||||
addr_pair ap;
|
addr_pair ap;
|
||||||
unsigned int len = 0;
|
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);
|
hdrlen = BPF_WORDALIGN(hdr->length);
|
||||||
length -= hdrlen;
|
length -= hdrlen;
|
||||||
packet += hdrlen;
|
packet += hdrlen;
|
||||||
handle_ip_packet((struct ip*)packet, length);
|
handle_ip_packet((struct ip*)packet, -1);
|
||||||
}
|
}
|
||||||
#endif
|
#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:
|
/* set_filter_code:
|
||||||
* Install some filter code. Returns NULL on success or an error message on
|
* Install some filter code. Returns NULL on success or an error message on
|
||||||
@@ -698,6 +716,11 @@ void packet_init() {
|
|||||||
else if(dlt == DLT_LOOP) {
|
else if(dlt == DLT_LOOP) {
|
||||||
packet_handler = handle_null_packet;
|
packet_handler = handle_null_packet;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef DLT_IEEE802_11_RADIO
|
||||||
|
else if(dlt == DLT_IEEE802_11_RADIO) {
|
||||||
|
packet_handler = handle_radiotap_packet;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
else if(dlt == DLT_IEEE802) {
|
else if(dlt == DLT_IEEE802) {
|
||||||
packet_handler = handle_tokenring_packet;
|
packet_handler = handle_tokenring_packet;
|
||||||
|
|||||||
Reference in New Issue
Block a user