1
0
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:
Matias Fontanini
2011-09-06 11:44:45 -03:00
parent 0f2c73ce72
commit 69c018ce68
2 changed files with 23 additions and 4 deletions

View File

@@ -29,6 +29,11 @@ namespace Tins {
/** /**
* \brief Class that represents the IEEE 802.11 radio tap header. * \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 { class RadioTap : public PDU {
public: public:
@@ -88,14 +93,16 @@ namespace Tins {
/** /**
* \brief Creates an instance of RadioTap. * \brief Creates an instance of RadioTap.
* \param iface The name of the interface in which to send this PDU. * \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. * \brief Creates an instance of RadioTap.
* \param iface_index The index of the interface in which to send this PDU. * \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 * \brief Constructor which creates a RadioTap object from a buffer and adds all
@@ -297,6 +304,7 @@ namespace Tins {
ext:1; ext:1;
} __attribute__((__packed__)); } __attribute__((__packed__));
void init();
void write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent); void write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent);

View File

@@ -30,14 +30,16 @@
#include "utils.h" #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)) if(!Utils::interface_id(iface, _iface_index))
throw std::runtime_error("Invalid interface name!"); throw std::runtime_error("Invalid interface name!");
std::memset(&_radio, 0, sizeof(_radio)); 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)); std::memset(&_radio, 0, sizeof(_radio));
init();
} }
Tins::RadioTap::RadioTap(const uint8_t *buffer, uint32_t total_sz) : PDU(0xff) { 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)); 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) { void Tins::RadioTap::version(uint8_t new_version) {
_radio.it_version = new_version; _radio.it_version = new_version;
} }