Commit f0e6bbc1 authored by Bruno Randolf's avatar Bruno Randolf

Handle frames with bad checksum

- Display and allow to filter frames with a bad FCS
- Change filter logic a bit
parent 1ff6cc57
......@@ -94,6 +94,11 @@ update_filter_win(WINDOW *win)
CHECK_FILTER_EN(i), ether_sprintf(conf.filtermac[i]));
}
l++;
wattron(win, RED);
mvwprintw(win, l++, MAC_COL, "*: [%c] Bad FCS", CHECKED(PKT_TYPE_BADFCS));
wattroff(win, RED);
l++;
wattron(win, A_BOLD);
mvwprintw(win, l++, MAC_COL, "o: [%c] All Filters Off", conf.filter_off ? '*' : ' ' );
......@@ -148,6 +153,7 @@ filter_input(WINDOW *win, int c)
case 'O': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_OLSR|PKT_TYPE_OLSR_LQ|PKT_TYPE_OLSR_GW); break;
case 'B': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_BATMAN); break;
case 'M': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_MESHZ); break;
case '*': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_BADFCS); break;
case 's':
echo();
......@@ -191,15 +197,13 @@ filter_input(WINDOW *win, int c)
}
/* convenience: */
/* if one of the individual mgmt frames is deselected we dont want to see all mgmt frames */
if ((conf.filter_pkt & PKT_TYPE_ALL_MGMT) != PKT_TYPE_ALL_MGMT)
conf.filter_pkt = conf.filter_pkt & ~PKT_TYPE_MGMT;
/* same for ctl */
if ((conf.filter_pkt & PKT_TYPE_ALL_CTRL) != PKT_TYPE_ALL_CTRL)
conf.filter_pkt = conf.filter_pkt & ~PKT_TYPE_CTRL;
/* same for data */
if ((conf.filter_pkt & PKT_TYPE_ALL_DATA) != PKT_TYPE_ALL_DATA)
conf.filter_pkt = conf.filter_pkt & ~PKT_TYPE_DATA;
/* if one of the individual subtype frames is selected we enable the general frame type */
if (conf.filter_pkt & PKT_TYPE_ALL_MGMT)
conf.filter_pkt |= PKT_TYPE_MGMT;
if (conf.filter_pkt & PKT_TYPE_ALL_CTRL)
conf.filter_pkt |= PKT_TYPE_CTRL;
if (conf.filter_pkt & PKT_TYPE_ALL_DATA)
conf.filter_pkt |= PKT_TYPE_DATA;
/* recalculate filter flag */
conf.do_macfilter = 0;
......
......@@ -387,6 +387,9 @@ update_dump_win(struct packet_info* p)
if (p->pkt_types & PKT_TYPE_IP)
wattron(dump_win, A_BOLD);
if (p->phy_flags & PHY_FLAG_BADFCS)
wattron(dump_win, RED);
wprintw(dump_win, "\n%02d ", p->phy_chan);
wprintw(dump_win, "-%02d", -p->phy_signal);
if (conf.have_noise)
......@@ -400,6 +403,9 @@ update_dump_win(struct packet_info* p)
if (p->wlan_retry)
wprintw(dump_win, "[r]");
if (p->phy_flags & PHY_FLAG_BADFCS)
wprintw(dump_win, "*BADFCS* ");
if (p->pkt_types & PKT_TYPE_OLSR) {
wprintw(dump_win, "%-7s%s ", "OLSR", ip_sprintf(p->ip_src));
switch (p->olsr_type) {
......
......@@ -24,6 +24,7 @@
#include "display.h"
#include "main.h"
#include "util.h"
#include "ieee80211_util.h"
#define STAT_PACK_POS 9
#define STAT_BYTE_POS (STAT_PACK_POS + 9)
......
......@@ -116,6 +116,8 @@ print_centered(WINDOW* win, int line, int cols, const char *fmt, ...)
int
get_packet_type_color(int type)
{
if (type == 1) /* special case for bad FCS */
return RED;
switch (type & IEEE80211_FCTL_FTYPE) {
case IEEE80211_FTYPE_DATA: return BLUE;
case IEEE80211_FTYPE_CTL: return WHITE;
......
......@@ -93,6 +93,9 @@ update_essids(struct packet_info* p, struct node_info* n)
{
struct essid_info* e;
if (p->phy_flags & PHY_FLAG_BADFCS)
return; /* ignore */
/* only check beacons (XXX: what about PROBE?) */
if (!IEEE80211_IS_MGMT_STYPE(p->wlan_type, IEEE80211_STYPE_BEACON))
return;
......
......@@ -126,7 +126,7 @@ update_history(struct packet_info* p)
hist.signal[hist.index] = p->phy_signal;
hist.noise[hist.index] = p->phy_noise;
hist.rate[hist.index] = p->phy_rate;
hist.type[hist.index] = p->wlan_type;
hist.type[hist.index] = (p->phy_flags & PHY_FLAG_BADFCS) ? 1 : p->wlan_type;
hist.retry[hist.index] = p->wlan_retry;
hist.index++;
......@@ -138,6 +138,8 @@ update_history(struct packet_info* p)
static void
update_statistics(struct packet_info* p)
{
int type = (p->phy_flags & PHY_FLAG_BADFCS) ? 1 : p->wlan_type;
if (p->phy_rate_idx == 0)
return;
......@@ -153,11 +155,11 @@ update_statistics(struct packet_info* p)
stats.duration_per_rate[p->phy_rate_idx] += p->pkt_duration;
}
if (p->wlan_type >= 0 && p->wlan_type < MAX_FSTYPE) {
stats.packets_per_type[p->wlan_type]++;
stats.bytes_per_type[p->wlan_type] += p->wlan_len;
if (type >= 0 && type < MAX_FSTYPE) {
stats.packets_per_type[type]++;
stats.bytes_per_type[type] += p->wlan_len;
if (p->phy_rate_idx > 0 && p->phy_rate_idx < MAX_RATES)
stats.duration_per_type[p->wlan_type] += p->pkt_duration;
stats.duration_per_type[type] += p->pkt_duration;
}
}
......@@ -249,7 +251,7 @@ filter_packet(struct packet_info* p)
if (conf.filter_off)
return 0;
if (!(p->pkt_types & conf.filter_pkt)) {
if (p->pkt_types & ~conf.filter_pkt) {
stats.filtered_packets++;
return 1;
}
......
......@@ -49,6 +49,8 @@
#define PKT_TYPE_MGMT 0x000002
#define PKT_TYPE_DATA 0x000004
#define PKT_TYPE_BADFCS 0x000008
#define PKT_TYPE_BEACON 0x000010
#define PKT_TYPE_PROBE 0x000020
#define PKT_TYPE_ASSOC 0x000040
......
......@@ -90,6 +90,9 @@ node_update(struct packet_info* p)
{
struct node_info* n;
if (p->phy_flags & PHY_FLAG_BADFCS)
return NULL;
if (p->wlan_src[0] == 0 && p->wlan_src[1] == 0 &&
p->wlan_src[2] == 0 && p->wlan_src[3] == 0 &&
p->wlan_src[4] == 0 && p->wlan_src[5] == 0)
......
......@@ -257,6 +257,7 @@ parse_radiotap_header(unsigned char** buf, int len, struct packet_info* p)
}
if (*b & IEEE80211_RADIOTAP_F_BADFCS) {
p->phy_flags |= PHY_FLAG_BADFCS;
p->pkt_types |= PKT_TYPE_BADFCS;
DEBUG(" badfcs");
}
DEBUG("]");
......@@ -393,7 +394,7 @@ parse_80211_header(unsigned char** buf, int len, struct packet_info* p)
switch (p->wlan_type & IEEE80211_FCTL_FTYPE) {
case IEEE80211_FTYPE_DATA:
p->pkt_types = PKT_TYPE_DATA;
p->pkt_types |= PKT_TYPE_DATA;
switch (p->wlan_type & IEEE80211_FCTL_STYPE) {
case IEEE80211_STYPE_NULLFUNC:
p->pkt_types |= PKT_TYPE_NULL;
......@@ -430,7 +431,7 @@ parse_80211_header(unsigned char** buf, int len, struct packet_info* p)
break;
case IEEE80211_FTYPE_CTL:
p->pkt_types = PKT_TYPE_CTRL;
p->pkt_types |= PKT_TYPE_CTRL;
switch (p->wlan_type & IEEE80211_FCTL_STYPE) {
case IEEE80211_STYPE_RTS:
p->pkt_types |= PKT_TYPE_RTS;
......@@ -470,7 +471,7 @@ parse_80211_header(unsigned char** buf, int len, struct packet_info* p)
break;
case IEEE80211_FTYPE_MGMT:
p->pkt_types = PKT_TYPE_MGMT;
p->pkt_types |= PKT_TYPE_MGMT;
whm = (struct ieee80211_mgmt*)*buf;
sa = whm->sa;
da = whm->da;
......
......@@ -172,6 +172,8 @@ convert_string_to_mac(const char* string, unsigned char* mac)
char
get_packet_type_char(int type)
{
if (type == 1) /* special case for bad FCS */
return '*';
switch (type & IEEE80211_FCTL_FTYPE) {
case IEEE80211_FTYPE_MGMT:
if (MGMT_NAME_INDEX(type) < sizeof(mgmt_names)/sizeof(struct pkt_names)) {
......@@ -199,6 +201,8 @@ get_packet_type_char(int type)
const char*
get_packet_type_name(int type)
{
if (type == 1) /* special case for bad FCS */
return "BADFCS";
switch (type & IEEE80211_FCTL_FTYPE) {
case IEEE80211_FTYPE_MGMT:
if (MGMT_NAME_INDEX(type) < sizeof(mgmt_names)/sizeof(struct pkt_names)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment