Commit 316809f7 authored by Bruno Randolf's avatar Bruno Randolf

sanitize rates, they are sometimes reported as 0 :(

parent d3ef8895
......@@ -19,6 +19,7 @@
#include "ieee80211.h"
#include "ieee80211_radiotap.h"
#include "main.h"
#include "util.h"
#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
......@@ -227,7 +228,10 @@ ieee80211_frame_duration(int phymode, size_t len,
* DIV_ROUND_UP() operations.
*/
DEBUG("mode %d, len %d, rate %d, shortpre %d\n", phymode, len, rate, short_preamble);
if (phymode == PHY_FLAG_A || erp) {
DEBUG("OFDM\n");
/*
* OFDM:
*
......@@ -247,6 +251,7 @@ ieee80211_frame_duration(int phymode, size_t len,
dur += 4 * DIV_ROUND_UP((16 + 8 * (len + 4) + 6) * 10,
4 * rate); /* T_SYM x N_SYM */
} else {
DEBUG("B\n");
/*
* 802.11b or 802.11g with 802.11b compatibility:
* 18.3.4: TXTIME = PreambleLength + PLCPHeaderTime +
......
......@@ -267,9 +267,21 @@ parse_radiotap_header(unsigned char** buf, int len)
DEBUG("0");
}
}
DEBUG("\n");
/* sanitize */
if (current_packet.snr > 99)
current_packet.snr = 99;
if (current_packet.rate == 0 || current_packet.rate > 108) {
/* assume min rate for mode */
DEBUG("*** fixing wrong rate\n");
if (current_packet.phy_flags & PHY_FLAG_A)
current_packet.rate = 12; /* 6 * 2 */
if (current_packet.phy_flags & PHY_FLAG_B)
current_packet.rate = 2; /* 1 * 2 */
if (current_packet.phy_flags & PHY_FLAG_G)
current_packet.rate = 12; /* 6 * 2 */
}
DEBUG("\nrate: %d\n", current_packet.rate);
DEBUG("signal: %d\n", current_packet.signal);
......
......@@ -20,6 +20,8 @@
#ifndef _UTIL_H_
#define _UTIL_H_
#include <stdio.h>
#if DO_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
......
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