mirror of
https://github.com/mfontanini/libtins
synced 2026-01-23 02:35:57 +01:00
Fixed some endianess bugs in RadioTap.
This commit is contained in:
@@ -29,6 +29,11 @@ namespace Tins {
|
||||
|
||||
/**
|
||||
* \brief Class that represents the IEEE 802.11 radio tap header.
|
||||
*
|
||||
* By default, RadioTap PDUs set the necesary fields to send an 802.11
|
||||
* PDU as its inner pdu, avoiding packet drops. As a consequence,
|
||||
* the FCS-at-end flag is on, the channel is set to 1, TSFT is set to 0,
|
||||
* dbm_signal is set to 0xce, and the rx_flag and antenna fields to 0.
|
||||
*/
|
||||
class RadioTap : public PDU {
|
||||
public:
|
||||
@@ -88,14 +93,16 @@ namespace Tins {
|
||||
/**
|
||||
* \brief Creates an instance of RadioTap.
|
||||
* \param iface The name of the interface in which to send this PDU.
|
||||
* \param child The child PDU.(optional)
|
||||
*/
|
||||
RadioTap(const std::string &iface) throw (std::runtime_error);
|
||||
RadioTap(const std::string &iface, PDU *child = 0) throw (std::runtime_error);
|
||||
|
||||
/**
|
||||
* \brief Creates an instance of RadioTap.
|
||||
* \param iface_index The index of the interface in which to send this PDU.
|
||||
* \param child The child PDU.(optional)
|
||||
*/
|
||||
RadioTap(uint32_t iface_index);
|
||||
RadioTap(uint32_t iface_index, PDU *child = 0);
|
||||
|
||||
/**
|
||||
* \brief Constructor which creates a RadioTap object from a buffer and adds all
|
||||
@@ -297,6 +304,7 @@ namespace Tins {
|
||||
ext:1;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
void init();
|
||||
void write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent);
|
||||
|
||||
|
||||
|
||||
@@ -30,14 +30,16 @@
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
Tins::RadioTap::RadioTap(const std::string &iface) throw (std::runtime_error) : PDU(0xff), _options_size(0) {
|
||||
Tins::RadioTap::RadioTap(const std::string &iface, PDU *child) throw (std::runtime_error) : PDU(0xff, child), _options_size(0) {
|
||||
if(!Utils::interface_id(iface, _iface_index))
|
||||
throw std::runtime_error("Invalid interface name!");
|
||||
std::memset(&_radio, 0, sizeof(_radio));
|
||||
init();
|
||||
}
|
||||
|
||||
Tins::RadioTap::RadioTap(uint32_t iface_index) : PDU(0xff), _iface_index(iface_index) {
|
||||
Tins::RadioTap::RadioTap(uint32_t iface_index, PDU *child) : PDU(0xff, child), _iface_index(iface_index) {
|
||||
std::memset(&_radio, 0, sizeof(_radio));
|
||||
init();
|
||||
}
|
||||
|
||||
Tins::RadioTap::RadioTap(const uint8_t *buffer, uint32_t total_sz) : PDU(0xff) {
|
||||
@@ -111,6 +113,15 @@ Tins::RadioTap::RadioTap(const uint8_t *buffer, uint32_t total_sz) : PDU(0xff) {
|
||||
inner_pdu(Dot11::from_bytes(buffer, total_sz));
|
||||
}
|
||||
|
||||
void Tins::RadioTap::init() {
|
||||
channel(Utils::channel_to_mhz(1), 0xa0);
|
||||
flags(FCS);
|
||||
tsft(0);
|
||||
dbm_signal(0xce);
|
||||
rx_flag(0);
|
||||
antenna(0);
|
||||
}
|
||||
|
||||
void Tins::RadioTap::version(uint8_t new_version) {
|
||||
_radio.it_version = new_version;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user