1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

Merge pull request #60 from mfontanini/radiotap_fixes

Radiotap fixes
This commit is contained in:
Matias Fontanini
2015-03-06 09:04:17 -08:00
3 changed files with 329 additions and 48 deletions

View File

@@ -77,22 +77,25 @@ namespace Tins {
* \sa RadioTap::present()
*/
enum PresentFlags {
TSTF = 1,
FLAGS = 2,
RATE = 4,
CHANNEL = 8,
FHSS = 16,
DBM_SIGNAL = 32,
DBM_NOISE = 64,
LOCK_QUALITY = 128,
TX_ATTENUATION = 256,
DB_TX_ATTENUATION = 512,
DBM_TX_ATTENUATION = 1024,
ANTENNA = 2048,
DB_SIGNAL = 4096,
DB_NOISE = 8192,
RX_FLAGS = 16382,
CHANNEL_PLUS = 262144
TSTF = 1 << 0,
FLAGS = 1 << 1,
RATE = 1 << 2,
CHANNEL = 1 << 3,
FHSS = 1 << 4,
DBM_SIGNAL = 1 << 5,
DBM_NOISE = 1 << 6,
LOCK_QUALITY = 1 << 7,
TX_ATTENUATION = 1 << 8,
DB_TX_ATTENUATION = 1 << 9,
DBM_TX_ATTENUATION = 1 << 10,
ANTENNA = 1 << 11,
DB_SIGNAL = 1 << 12,
DB_NOISE = 1 << 13,
RX_FLAGS = 1 << 14,
TX_FLAGS = 1 << 15,
DATA_RETRIES = 1 << 17,
CHANNEL_PLUS = 1 << 18,
MCS = 1 << 19
};
/**
@@ -108,6 +111,16 @@ namespace Tins {
FAILED_FCS = 64,
SHORT_GI = 128
};
/**
* \brief The type used to represent the MCS flags field
*/
TINS_BEGIN_PACK
struct mcs_type {
uint8_t known;
uint8_t flags;
uint8_t mcs;
} TINS_END_PACK;
/**
* \brief Default constructor.
@@ -210,9 +223,27 @@ namespace Tins {
/**
* \brief Setter for the rx flag field.
* \param new_rx_flag The antenna signal.
* \param new_rx_flag The rx flags.
*/
void rx_flags(uint16_t new_rx_flag);
/**
* \brief Setter for the tx flag field.
* \param new_tx_flag The tx flags.
*/
void tx_flags(uint16_t new_tx_flag);
/**
* \brief Setter for the data retries field.
* \param new_rx_flag The data retries.
*/
void data_retries(uint8_t new_data_retries);
/**
* \brief Setter for the MCS field.
* \param new_rx_flag The MCS retries.
*/
void mcs(const mcs_type& new_mcs);
/* Getters */
@@ -300,12 +331,30 @@ namespace Tins {
*/
uint32_t channel_plus() const;
/**
* \brief Getter for the data retries field
* \return The data retries field.
*/
uint8_t data_retries() const;
/**
* \brief Getter for the rx flags field.
* \return The rx flags field.
*/
uint16_t rx_flags() const;
/**
* \brief Getter for the tx flags field.
* \return The tx flags field.
*/
uint16_t tx_flags() const;
/**
* \brief Getter for the MCS field.
* \return The MCS field.
*/
mcs_type mcs() const;
/**
* \brief Getter for the present bit fields.
*
@@ -358,7 +407,8 @@ namespace Tins {
TINS_BEGIN_PACK
#if TINS_IS_LITTLE_ENDIAN
struct flags_type {
uint32_t tsft:1,
uint32_t
tsft:1,
flags:1,
rate:1,
channel:1,
@@ -366,6 +416,7 @@ namespace Tins {
dbm_signal:1,
dbm_noise:1,
lock_quality:1,
tx_attenuation:1,
db_tx_attenuation:1,
dbm_tx_power:1,
@@ -373,14 +424,21 @@ namespace Tins {
db_signal:1,
db_noise:1,
rx_flags:1,
reserved1:3,
tx_flags:1,
reserved1:1,
data_retries:1,
channel_plus:1,
reserved2:12,
mcs:1,
reserved2:4,
reserved3:7,
ext:1;
} TINS_END_PACK;
#else
struct flags_type {
uint32_t lock_quality:1,
uint32_t
lock_quality:1,
dbm_noise:1,
dbm_signal:1,
fhss:1,
@@ -388,19 +446,24 @@ namespace Tins {
rate:1,
flags:1,
tsft:1,
reserved3:1,
tx_flags:1,
rx_flags:1,
db_tx_attenuation:1,
dbm_tx_power:1,
antenna:1,
db_signal:1,
db_noise:1,
db_signal:1,
antenna:1,
dbm_tx_power:1,
db_tx_attenuation:1,
tx_attenuation:1,
reserved2:5,
reserved2:4,
mcs:1,
channel_plus:1,
reserved1:2,
reserved4:7,
ext:1;
data_retries:1,
reserved1:1,
ext:1,
reserved3:7;
} TINS_END_PACK;
#endif
@@ -423,13 +486,27 @@ namespace Tins {
void init();
void write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent);
uint32_t find_extra_flag_fields_size(const uint8_t* buffer, uint32_t total_sz);
template <size_t n>
void align_buffer(const uint8_t* buffer_start, const uint8_t*& buffer, uint32_t& size) {
uint32_t offset = ((buffer - buffer_start) % n);
if(offset) {
offset = n - offset;
if (offset > size) {
throw malformed_packet();
}
buffer += offset;
size -= offset;
}
}
radiotap_hdr _radio;
// present fields...
uint64_t _tsft;
uint16_t _channel_type, _channel_freq, _rx_flags, _signal_quality;
uint8_t _antenna, _flags, _rate, _channel, _max_power, _db_signal;
uint16_t _channel_type, _channel_freq, _rx_flags, _signal_quality, _tx_flags;
mcs_type _mcs;
uint8_t _antenna, _flags, _rate, _channel, _max_power, _db_signal, _data_retries;
int8_t _dbm_signal, _dbm_noise;
};
}

View File

@@ -90,8 +90,10 @@ RadioTap::RadioTap(const uint8_t *buffer, uint32_t total_sz)
while(true) {
_radio.flags_32 |= *(const uint32_t*)current_flags;
if(current_flags->tsft)
if(current_flags->tsft) {
align_buffer<8>(buffer_start, buffer, radiotap_hdr_size);
read_field(buffer, radiotap_hdr_size, _tsft);
}
if(current_flags->flags)
read_field(buffer, radiotap_hdr_size, _flags);
@@ -100,10 +102,7 @@ RadioTap::RadioTap(const uint8_t *buffer, uint32_t total_sz)
read_field(buffer, radiotap_hdr_size, _rate);
if(current_flags->channel) {
if(((buffer - buffer_start) & 1) == 1) {
buffer++;
radiotap_hdr_size--;
}
align_buffer<2>(buffer_start, buffer, radiotap_hdr_size);
read_field(buffer, radiotap_hdr_size, _channel_freq);
read_field(buffer, radiotap_hdr_size, _channel_type);
}
@@ -124,19 +123,21 @@ RadioTap::RadioTap(const uint8_t *buffer, uint32_t total_sz)
read_field(buffer, radiotap_hdr_size, _db_signal);
if(current_flags->rx_flags) {
if(((buffer - buffer_start) & 1) == 1) {
buffer++;
radiotap_hdr_size--;
}
align_buffer<2>(buffer_start, buffer, radiotap_hdr_size);
read_field(buffer, radiotap_hdr_size, _rx_flags);
}
if(current_flags->tx_flags) {
align_buffer<2>(buffer_start, buffer, radiotap_hdr_size);
read_field(buffer, radiotap_hdr_size, _tx_flags);
}
if(current_flags->data_retries) {
read_field(buffer, radiotap_hdr_size, _data_retries);
}
if(current_flags->channel_plus) {
uint32_t offset = ((buffer - buffer_start) % 4);
if(offset) {
offset = 4 - offset;
buffer += offset;
radiotap_hdr_size -= offset;
}
align_buffer<4>(buffer_start, buffer, radiotap_hdr_size);
uint32_t dummy;
read_field(buffer, radiotap_hdr_size, dummy);
// nasty Big Endian fix
@@ -145,6 +146,11 @@ RadioTap::RadioTap(const uint8_t *buffer, uint32_t total_sz)
read_field(buffer, radiotap_hdr_size, _channel);
read_field(buffer, radiotap_hdr_size, _max_power);
}
if(current_flags->mcs) {
read_field(buffer, radiotap_hdr_size, _mcs.known);
read_field(buffer, radiotap_hdr_size, _mcs.flags);
read_field(buffer, radiotap_hdr_size, _mcs.mcs);
}
// We can do this safely because we checked the size on find_extra_flags...
if(current_flags->ext == 1) {
current_flags++;
@@ -239,6 +245,11 @@ void RadioTap::signal_quality(uint8_t new_signal_quality) {
_radio.flags.lock_quality = 1;
}
void RadioTap::data_retries(uint8_t new_data_retries) {
_data_retries = new_data_retries;
_radio.flags.data_retries = 1;
}
void RadioTap::antenna(uint8_t new_antenna) {
_antenna = new_antenna;
_radio.flags.antenna = 1;
@@ -254,6 +265,16 @@ void RadioTap::rx_flags(uint16_t new_rx_flag) {
_radio.flags.rx_flags = 1;
}
void RadioTap::tx_flags(uint16_t new_tx_flag) {
_tx_flags = Endian::host_to_le(new_tx_flag);
_radio.flags.tx_flags = 1;
}
void RadioTap::mcs(const mcs_type& new_mcs) {
_mcs = new_mcs;
_radio.flags.mcs = 1;
}
uint32_t RadioTap::header_size() const {
uint32_t total_bytes = 0;
if(_radio.flags.tsft)
@@ -282,12 +303,21 @@ uint32_t RadioTap::header_size() const {
total_bytes += (total_bytes & 1);
total_bytes += sizeof(_rx_flags);
}
if(_radio.flags.tx_flags) {
total_bytes += (total_bytes & 1);
total_bytes += sizeof(_tx_flags);
}
if(_radio.flags.data_retries)
total_bytes += sizeof(_data_retries);
if(_radio.flags.channel_plus) {
uint32_t offset = total_bytes % 4;
if(offset)
total_bytes += 4 - offset;
total_bytes += 8;
}
if(_radio.flags.mcs) {
total_bytes += sizeof(_mcs);
}
return sizeof(_radio) + total_bytes;
}
@@ -364,6 +394,12 @@ uint8_t RadioTap::antenna() const {
return _antenna;
}
RadioTap::mcs_type RadioTap::mcs() const {
if(!_radio.flags.mcs)
throw field_not_present();
return _mcs;
}
uint8_t RadioTap::db_signal() const {
if(!_radio.flags.db_signal)
throw field_not_present();
@@ -382,6 +418,18 @@ uint16_t RadioTap::rx_flags() const {
return Endian::le_to_host(_rx_flags);
}
uint16_t RadioTap::tx_flags() const {
if(!_radio.flags.tx_flags)
throw field_not_present();
return Endian::le_to_host(_tx_flags);
}
uint8_t RadioTap::data_retries() const {
if(!_radio.flags.data_retries)
throw field_not_present();
return _data_retries;
}
#ifndef WIN32
void RadioTap::send(PacketSender &sender, const NetworkInterface &iface) {
if(!iface)

View File

@@ -17,7 +17,8 @@ using namespace Tins;
class RadioTapTest : public testing::Test {
public:
static const uint8_t expected_packet[], expected_packet1[],
expected_packet2[], expected_packet3[];
expected_packet2[], expected_packet3[],
expected_packet4[], expected_packet5[];
};
const uint8_t RadioTapTest::expected_packet[] = {
@@ -75,6 +76,126 @@ const uint8_t RadioTapTest::expected_packet3[] = {
0, 0, 0, 0, 172, 31, 31, 105, 106, 113, 120, 145
};
const uint8_t RadioTapTest::expected_packet4[] = {
0, 0, 39, 0, 43, 64, 8, 160, 32, 8, 0, 0, 0, 0, 0, 0, 222, 24,
122, 92, 227, 1, 0, 0, 16, 0, 108, 9, 128, 4, 186, 0, 0, 0, 39, 0
, 1, 186, 0, 136, 66, 48, 0, 208, 231, 130, 247, 98, 61, 76, 158,
255, 127, 13, 247, 226, 145, 245, 204, 218, 252, 112, 242, 0, 0,
43, 203, 0, 32, 11, 0, 0, 0, 14, 127, 184, 209, 44, 105, 69, 251
, 60, 61, 163, 101, 84, 74, 221, 98, 99, 67, 102, 27, 57, 87, 39,
188, 200, 78, 21, 9, 29, 221, 96, 41, 207, 67, 74, 203, 34, 213,
177, 33, 98, 185, 68, 218, 127, 231, 39, 108, 110, 216, 154, 228
, 13, 12, 143, 59, 104, 185, 40, 177, 120, 162, 80, 99, 72, 39,
66, 103, 244, 85, 89, 181, 34, 131, 26, 50, 229, 201, 62, 78, 95,
114, 173, 139, 218, 18, 111, 31, 185, 194, 244, 186, 249, 168,
178, 214, 63, 159, 238, 50, 5, 176, 178, 221, 87, 124, 22, 183,
108, 231, 228, 98, 211, 62, 254, 223, 161, 137, 30, 130, 210, 158
, 241, 237, 174, 208, 67, 233, 130, 56, 95, 40, 183, 161, 229,
227, 121, 112, 191, 106, 225, 164, 78, 90, 211, 179, 193, 211, 72
, 225, 109, 112, 58, 61, 64, 128, 13, 195, 221, 100, 214, 214,
165, 154, 73, 64, 19, 212, 8, 108, 246, 72, 97, 189, 4, 88, 245,
97, 3, 48, 37, 178, 216, 169, 59, 177, 36, 159, 255, 104, 106,
130, 196, 199, 88, 59, 55, 151, 247, 159, 54, 227, 214, 114, 128,
255, 17, 6, 34, 150, 48, 234, 237, 98, 226, 146, 207, 192, 6, 49
, 247, 106, 253, 252, 196, 250, 34, 191, 51, 124, 83, 188, 30,
254, 217, 186, 70, 182, 117, 74, 55, 129, 253, 88, 43, 161, 182,
239, 24, 79, 64, 228, 168, 202, 235, 148, 134, 47, 89, 86, 123,
86, 64, 211, 53, 199, 187, 40, 212, 19, 226, 253, 55, 186, 58, 11
, 231, 114, 69, 67, 63, 139, 97, 204, 155, 122, 219, 71, 75, 82,
155, 225, 241, 11, 111, 162, 148, 2, 11, 60, 14, 62, 176, 62, 80,
190, 59, 35, 190, 221, 11, 246, 166, 166, 12, 38, 109, 208, 161,
178, 31, 72, 179, 22, 161, 169, 132, 45, 21, 34, 0, 114, 214, 91
, 62, 51, 70, 95, 108, 72, 156, 129, 32, 26, 162, 97, 139, 156,
156, 85, 142, 163, 222, 11, 63, 203, 129, 159, 230, 225, 20, 87,
185, 59, 50, 247, 217, 31, 181, 80, 164, 0, 82, 57, 7, 195, 42,
219, 231, 163, 22, 250, 255, 143, 106, 17, 198, 232, 119, 172,
184, 189, 6, 246, 92, 220, 99, 104, 255, 145, 78, 5, 17, 71, 135,
116, 126, 194, 119, 50, 121, 177, 38, 161, 132, 229, 235, 88,
106, 134, 50, 232, 218, 146, 9, 15, 150, 167, 199, 84, 149, 155,
252, 16, 237, 4, 250, 155, 30, 130, 244, 68, 188, 122, 8, 6, 167,
61, 145, 187, 18, 24, 106, 241, 236, 89, 27, 139, 132, 220, 152,
186, 1, 248, 40, 64, 162, 157, 246, 130, 228, 141, 223, 186, 51,
166, 53, 53, 201, 231, 70, 198, 70, 254, 124, 125, 44, 89, 181,
187, 19, 244, 67, 195, 179, 137, 21, 214, 227, 191, 216, 172, 165
, 213, 155, 241, 212, 249, 167, 135, 216, 33, 197, 155, 0, 70, 37
, 124, 217, 168, 113, 75, 189, 74, 253, 199, 157, 236, 187, 132,
249, 98, 129, 74, 57, 10, 202, 200, 103, 78, 139, 186, 24, 109,
161, 201, 68, 156, 188, 139, 129, 165, 137, 73, 53, 106, 204, 22,
228, 115, 101, 155, 123, 105, 111, 250, 181, 204, 48, 126, 216,
159, 2, 9, 194, 225, 193, 163, 193, 87, 244, 200, 220, 226, 12,
25, 117, 201, 52, 133, 229, 151, 27, 37, 60, 67, 112, 25, 184, 5,
255, 189, 87, 141, 81, 89, 253, 195, 126, 29, 12, 157, 194, 239,
1, 71, 65, 84, 37, 205, 114, 5, 209, 249, 74, 201, 169, 191, 150
, 248, 250, 212, 124, 199, 51, 114, 56, 28, 184, 2, 110, 254, 84,
30, 55, 254, 72, 138, 55, 139, 103, 9, 49, 74, 20, 165, 72, 252,
231, 140, 183, 170, 223, 80, 140, 238, 108, 79, 53, 217, 64, 48,
191, 67, 177, 171, 25, 48, 253, 232, 87, 247, 60, 160, 171, 111,
149, 169, 71, 30, 120, 57, 255, 25, 249, 82, 108, 232, 161, 7,
230, 163, 177, 15, 10, 122, 135, 97, 26, 197, 229, 223, 245, 249,
129, 45, 52, 139, 60, 205, 43, 106, 234, 139, 200, 217, 177, 54,
183, 62, 154, 151, 63, 163, 227, 191, 137, 216, 25, 137, 195,
156, 161, 90, 101, 244, 79, 13, 86, 129, 233, 36, 20, 171, 29,
235, 21, 228, 26, 119, 84, 110, 170, 164, 159, 35, 18, 124, 169,
2, 157, 107, 18, 86, 91, 58, 97, 159, 60, 27, 128, 93, 237, 189,
148, 26, 122, 8, 59, 21, 188, 200, 102, 26, 223, 15, 81, 143, 149
, 141, 41, 163, 244, 29, 84, 129, 165, 11, 35, 91, 127, 87, 153,
60, 9, 209, 92, 197, 156, 168, 72, 148, 137, 124, 228, 21, 245,
248, 176, 99, 199, 27, 66, 166, 67, 194, 39, 19, 36, 211, 11, 23,
36, 139, 53, 171, 119, 39, 194, 241, 36, 6, 68, 214, 247, 58, 85
, 167, 86, 241, 38, 95, 204, 68, 120, 115, 218, 241, 206, 231, 15
, 146, 64, 132, 69, 159, 246, 209, 5, 37, 93, 158, 26, 6, 130,
158, 249, 56, 48, 1, 243, 80, 4, 111, 144, 6, 116, 93, 196, 164,
249, 115, 3, 162, 26, 131, 203, 83, 156, 18, 5, 217, 108, 156, 65
, 185, 147, 45, 82, 200, 37, 207, 217, 234, 226, 200, 59, 85, 203
, 155, 232, 95, 67, 36, 231, 186, 154, 188, 135, 255, 222, 25,
112, 18, 172, 217, 213, 63, 161, 50, 239, 89, 75, 148, 1, 215, 95
, 172, 174, 19, 235, 72, 4, 53, 50, 167, 154, 31, 112, 188, 237,
162, 38, 241, 127, 112, 157, 225, 50, 113, 168, 94, 135, 166, 104
, 127, 190, 213, 60, 63, 224, 157, 171, 201, 222, 179, 182, 100,
254, 28, 172, 79, 222, 96, 70, 16, 49, 34, 75, 117, 48, 230, 216,
96, 48, 93, 86, 22, 254, 178, 188, 137, 98, 253, 242, 253, 17,
108, 138, 134, 225, 83, 200, 23, 175, 171, 114, 41, 184, 194, 153
, 236, 180, 41, 202, 104, 198, 206, 163, 100, 147, 141, 67, 134,
149, 123, 183, 209, 38, 150, 167, 28, 107, 53, 31, 236, 181, 181,
77, 217, 216, 66, 111, 101, 217, 7, 32, 74, 193, 181, 124, 9,
253, 112, 156, 169, 248, 229, 134, 16, 38, 102, 22, 220, 186, 216
, 135, 164, 5, 155, 158, 66, 39, 177, 110, 245, 101, 171, 249,
215, 17, 243, 150, 175, 189, 145, 204, 73, 115, 73, 233, 172, 199
, 241, 151, 190, 249, 209, 221, 214, 91, 212, 103, 141, 110, 185,
202, 79, 67, 78, 155, 116, 3, 53, 220, 1, 186, 191, 113, 194, 72
, 23, 116, 217, 1, 96, 235, 139, 221, 127, 213, 60, 82, 129, 36,
135, 104, 45, 197, 137, 248, 190, 94, 121, 234, 87, 137, 228, 252
, 199, 13, 1, 221, 28, 134, 128, 230, 217, 52, 97, 244, 206, 81,
184, 30, 115, 253, 46, 161, 50, 180, 191, 88, 226, 0, 121, 251,
231, 63, 247, 205, 50, 201, 88, 137, 185, 149, 67, 227, 215, 137,
161, 18, 124, 99, 223, 68, 167, 44, 249, 36, 62, 205, 199, 35,
18, 13, 65, 191, 9, 224, 70, 192, 205, 68, 160, 144, 204, 164,
232, 19, 228, 209, 130, 24, 117, 96, 236, 112, 201, 70, 100, 123,
71, 90, 25, 79, 254, 95, 28, 66, 216, 159, 188, 87, 228, 254,
145, 214, 50, 125, 233, 110, 94, 207, 33, 37, 89, 226, 145, 228,
85, 120, 36, 93, 151, 28, 172, 185, 30, 171, 32, 11, 133, 52, 99,
187, 86, 199, 112, 208, 180, 215, 41, 17, 85, 13, 215, 195, 133,
3, 187, 248, 202, 183, 104, 170, 40, 102, 122, 120, 91, 28, 217,
16, 45, 209, 248, 145, 236, 190, 11, 202, 58, 148, 93, 91, 186,
251, 22, 151, 116, 113, 117, 226, 149, 27, 193, 7, 9, 117, 120,
108, 183, 211, 254, 239, 195, 60, 8, 90, 132, 42, 53, 233, 115,
79, 165, 157, 52, 73, 107, 24, 99, 92, 147, 23, 91, 220, 52, 35,
152, 171, 27, 190, 162, 168, 22, 230, 126, 208, 162, 19, 202, 176
, 32, 223, 201, 234, 124, 65, 238, 112, 129, 227, 130, 45, 51,
184, 136, 186, 186, 111, 41, 161, 5, 147, 187, 228, 76, 138, 234,
91, 10, 62, 103, 225, 114, 194, 194, 109, 211, 108, 108, 58, 175
, 128, 117, 209, 11, 51, 252, 189, 190, 183, 109, 221, 126, 214,
155, 147, 254, 131, 152, 42, 53, 16, 200, 16, 127, 194, 77, 26,
137, 200, 63, 137, 128, 119, 159, 147, 151, 238, 41, 255, 124,
186, 129, 170, 187, 170, 198, 179, 144, 120, 123, 117, 164, 58,
117, 167, 6, 211, 206, 49, 141, 215, 2, 83, 108, 191, 120, 35, 30
, 114, 68, 23, 251, 65, 225
};
const uint8_t RadioTapTest::expected_packet5[] = {
0, 0, 14, 0, 0, 128, 10, 0, 0, 0, 0, 7, 0, 5, 136, 65, 0, 0, 76, 158, 255, 127, 13, 247, 144, 162, 218, 245, 28, 56, 84, 4, 166, 180, 209, 35, 208, 207, 0, 0, 105, 29, 0, 32, 1, 0, 0, 0, 170, 170, 3, 0, 0, 0, 8, 0, 69, 16, 0, 100, 217, 93, 64, 0, 64, 6, 220, 39, 192, 168, 1, 245, 192, 168, 1, 185, 0, 22, 132, 209, 139, 84, 229, 243, 73, 225, 122, 44, 128, 24, 14, 36, 163, 203, 0, 0, 1, 1, 8, 10, 0, 95, 217, 190, 0, 30, 133, 52, 220, 143, 231, 158, 151, 126, 243, 67, 163, 172, 214, 109, 192, 190, 238, 160, 95, 63, 206, 71, 230, 59, 143, 105, 105, 172, 142, 15, 17, 139, 55, 70, 232, 71, 84, 12, 235, 224, 159, 132, 178, 117, 5, 43, 177, 190, 152, 170
};
TEST_F(RadioTapTest, DefaultConstructor) {
RadioTap radio;
EXPECT_TRUE(radio.flags() & RadioTap::FCS);
@@ -153,6 +274,41 @@ TEST_F(RadioTapTest, ConstructorFromBuffer3) {
EXPECT_TRUE(radio.find_pdu<ARP>());
}
TEST_F(RadioTapTest, ConstructorFromBuffer4) {
RadioTap radio(expected_packet4, sizeof(expected_packet4));
EXPECT_TRUE(radio.present() & RadioTap::TSTF);
EXPECT_TRUE(radio.present() & RadioTap::DBM_SIGNAL);
EXPECT_TRUE(radio.present() & RadioTap::CHANNEL);
EXPECT_TRUE(radio.present() & RadioTap::ANTENNA);
EXPECT_TRUE(radio.present() & RadioTap::RX_FLAGS);
EXPECT_TRUE(radio.present() & RadioTap::MCS);
EXPECT_EQ(2076020709598, radio.tsft());
EXPECT_EQ(0, radio.rx_flags());
EXPECT_EQ(0, radio.antenna());
EXPECT_EQ(-70, radio.dbm_signal());
EXPECT_EQ(2412, radio.channel_freq());
EXPECT_EQ(0x0480, radio.channel_type());
EXPECT_EQ(0x27, radio.mcs().known);
EXPECT_EQ(0x00, radio.mcs().flags);
EXPECT_EQ(0x01, radio.mcs().mcs);
EXPECT_TRUE(radio.find_pdu<Dot11Data>());
}
TEST_F(RadioTapTest, ConstructorFromBuffer5) {
RadioTap radio(expected_packet5, sizeof(expected_packet5));
EXPECT_TRUE(radio.present() & RadioTap::DATA_RETRIES);
EXPECT_TRUE(radio.present() & RadioTap::TX_FLAGS);
EXPECT_TRUE(radio.present() & RadioTap::MCS);
EXPECT_EQ(0, radio.data_retries());
EXPECT_EQ(0, radio.tx_flags());
EXPECT_EQ(0x07, radio.mcs().known);
EXPECT_EQ(0x00, radio.mcs().flags);
EXPECT_EQ(0x05, radio.mcs().mcs);
}
TEST_F(RadioTapTest, Serialize) {
RadioTap radio(expected_packet, sizeof(expected_packet));
RadioTap::serialization_type buffer = radio.serialize();