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

Renamed IEEE802_11 and all subclasses to Dot11

This commit is contained in:
Matias Fontanini
2011-09-04 10:19:58 -03:00
parent 3178c217b3
commit 477a757f5a
6 changed files with 238 additions and 238 deletions

View File

@@ -19,8 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __IEEE802_11_h
#define __IEEE802_11_h
#ifndef __DOT_11
#define __DOT_11
#include <list>
#include <stdint.h>
@@ -35,7 +35,7 @@ namespace Tins {
/**
* \brief Class representing an 802.11 frame.
*/
class IEEE802_11 : public PDU {
class Dot11 : public PDU {
public:
/**
* \brief Broadcast hardware address.
@@ -145,7 +145,7 @@ namespace Tins {
/**
* \brief IEEE 802.11 options struct.
*/
struct IEEE802_11_Option {
struct Dot11_Option {
/**
* \brief The option number.
*/
@@ -160,7 +160,7 @@ namespace Tins {
uint8_t *value;
/**
* \brief Creates an instance of IEEE802_11_Option.
* \brief Creates an instance of Dot11_Option.
*
* The option's value is copied, therefore the user should
* manually free any memory pointed by the "val" parameter.
@@ -168,7 +168,7 @@ namespace Tins {
* \param len The length of the option's value in bytes.
* \param val The option's value.
*/
IEEE802_11_Option(uint8_t opt, uint8_t len, const uint8_t *val);
Dot11_Option(uint8_t opt, uint8_t len, const uint8_t *val);
};
/**
@@ -180,7 +180,7 @@ namespace Tins {
* \param src_hw_addr uint8_t array of 6 bytes containing the source's MAC(optional).
* \param child PDU* with the PDU contained by the 802.11 PDU (optional).
*/
IEEE802_11(const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0, PDU* child = 0);
Dot11(const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0, PDU* child = 0);
/**
* \brief Constructor for creating a 802.11 PDU
@@ -193,7 +193,7 @@ namespace Tins {
* \param src_hw_addr uint8_t array of 6 bytes containing the source's MAC(optional).
* \param child PDU* with the PDU contained by the 802.11 PDU (optional).
*/
IEEE802_11(const std::string& iface, const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0, PDU* child = 0) throw (std::runtime_error);
Dot11(const std::string& iface, const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0, PDU* child = 0) throw (std::runtime_error);
/**
* \brief Constructor for creating an 802.11 PDU
@@ -206,7 +206,7 @@ namespace Tins {
* \param src_hw_addr uint8_t array of 6 bytes containing the source's MAC(optional).
* \param child PDU* with the PDU contained by the 802.11 PDU (optional).
*/
IEEE802_11(uint32_t iface_index, const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0, PDU* child = 0);
Dot11(uint32_t iface_index, const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0, PDU* child = 0);
/**
* \brief Constructor which creates an 802.11 object from a buffer and adds all identifiable
@@ -214,24 +214,24 @@ namespace Tins {
* \param buffer The buffer from which this PDU will be constructed.
* \param total_sz The total size of the buffer.
*/
IEEE802_11(const uint8_t *buffer, uint32_t total_sz);
Dot11(const uint8_t *buffer, uint32_t total_sz);
/**
* \brief Copy constructor.
*/
IEEE802_11(const IEEE802_11 &other);
Dot11(const Dot11 &other);
/**
* \brief IEEE802_11 destructor.
* \brief Dot11 destructor.
*
* Releases the memory allocated for tagged options.
*/
~IEEE802_11();
~Dot11();
/**
* \brief Copy assignment operator.
*/
IEEE802_11 &operator= (const IEEE802_11 &other);
Dot11 &operator= (const Dot11 &other);
/**
* \brief Getter for the protocol version.
@@ -507,7 +507,7 @@ namespace Tins {
bool send(PacketSender* sender);
/**
* \brief Adds a new option to this IEEE802_11 PDU.
* \brief Adds a new option to this Dot11 PDU.
*
* This copies the value buffer.
* \param opt The option identifier.
@@ -521,16 +521,16 @@ namespace Tins {
* \param opt The option identifier.
* \return The option found, or 0 if no such option has been set.
*/
const IEEE802_11_Option *lookup_option(TaggedOption opt) const;
const Dot11_Option *lookup_option(TaggedOption opt) const;
/**
* \brief Getter for the PDU's type.
* \sa PDU::pdu_type
*/
PDUType pdu_type() const { return PDU::IEEE802_11; }
PDUType pdu_type() const { return PDU::DOT11; }
/**
* \brief Allocates an IEEE802_11 PDU from a buffer.
* \brief Allocates an Dot11 PDU from a buffer.
* \param buffer The buffer from which to take the PDU data.
* \param total_sz The total size of the buffer.
* \return The allocated PDU.
@@ -539,7 +539,7 @@ namespace Tins {
protected:
virtual uint32_t write_fixed_parameters(uint8_t *buffer, uint32_t total_sz) { return 0; }
void parse_tagged_parameters(const uint8_t *buffer, uint32_t total_sz);
void copy_80211_fields(const IEEE802_11 *other);
void copy_80211_fields(const Dot11 *other);
protected:
/**
* Struct that represents the 802.11 header
@@ -589,7 +589,7 @@ namespace Tins {
} __attribute__((__packed__));
private:
IEEE802_11(const ieee80211_header *header_ptr);
Dot11(const ieee80211_header *header_ptr);
void write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent);
@@ -597,7 +597,7 @@ namespace Tins {
ieee80211_header _header;
uint8_t _addr4[6];
uint32_t _iface_index, _options_size;
std::list<IEEE802_11_Option> _options;
std::list<Dot11_Option> _options;
};
/**
@@ -711,7 +711,7 @@ namespace Tins {
/**
* \brief Abstract class that englobes all Management frames in the 802.11 protocol.
*/
class ManagementFrame : public IEEE802_11 {
class Dot11ManagementFrame : public Dot11 {
public:
@@ -996,15 +996,15 @@ namespace Tins {
protected:
/**
* \brief Constructor which creates a ManagementFrame object from a buffer and adds all identifiable
* \brief Constructor which creates a Dot11ManagementFrame object from a buffer and adds all identifiable
* PDUs found in the buffer as children of this one.
* \param buffer The buffer from which this PDU will be constructed.
* \param total_sz The total size of the buffer.
*/
ManagementFrame(const uint8_t *dst_hw_addr = 0, const uint8_t *src_hw_addr = 0);
ManagementFrame(const std::string &iface, const uint8_t *dst_hw_addr, const uint8_t *src_hw_addr) throw (std::runtime_error);
ManagementFrame(const uint8_t *buffer, uint32_t total_sz);
ManagementFrame(const ManagementFrame &other);
Dot11ManagementFrame(const uint8_t *dst_hw_addr = 0, const uint8_t *src_hw_addr = 0);
Dot11ManagementFrame(const std::string &iface, const uint8_t *dst_hw_addr, const uint8_t *src_hw_addr) throw (std::runtime_error);
Dot11ManagementFrame(const uint8_t *buffer, uint32_t total_sz);
Dot11ManagementFrame(const Dot11ManagementFrame &other);
void ssid(const std::string &new_ssid);
void rates(const std::list<float> &new_rates);
@@ -1028,7 +1028,7 @@ namespace Tins {
* \brief Class representing a Beacon in the IEEE 802.11 Protocol.
*
*/
class IEEE802_11_Beacon : public ManagementFrame {
class Dot11Beacon : public Dot11ManagementFrame {
public:
@@ -1037,7 +1037,7 @@ namespace Tins {
* \param dst_hw_addr uint8_t array of 6 bytes containing the destination's MAC(optional).
* \param src_hw_addr uint8_t array of 6 bytes containing the source's MAC(optional).
*/
IEEE802_11_Beacon(const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0);
Dot11Beacon(const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0);
/**
* \brief Constructor for creating a 802.11 Beacon.
@@ -1049,26 +1049,26 @@ namespace Tins {
* \param dst_hw_addr uint8_t array of 6 bytes containing the destination's MAC(optional).
* \param src_hw_addr uint8_t array of 6 bytes containing the source's MAC(optional).
*/
IEEE802_11_Beacon(const std::string& iface, const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0) throw (std::runtime_error);
Dot11Beacon(const std::string& iface, const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0) throw (std::runtime_error);
/**
* \brief Constructor which creates a IEEE802_11_Beacon object from a buffer and adds
* \brief Constructor which creates a Dot11Beacon object from a buffer and adds
* all identifiable PDUs found in the buffer as children of this one.
*
* \param buffer The buffer from which this PDU will be constructed.
* \param total_sz The total size of the buffer.
*/
IEEE802_11_Beacon(const uint8_t *buffer, uint32_t total_sz);
Dot11Beacon(const uint8_t *buffer, uint32_t total_sz);
/**
* \brief Copy constructor.
*/
IEEE802_11_Beacon(const IEEE802_11_Beacon &other);
Dot11Beacon(const Dot11Beacon &other);
/**
* \brief Copy assignment operator.
*/
IEEE802_11_Beacon &operator= (const IEEE802_11_Beacon &other);
Dot11Beacon &operator= (const Dot11Beacon &other);
/**
* \brief Getter for the timestamp field.
@@ -1168,7 +1168,7 @@ namespace Tins {
CapabilityInformation capability;
} __attribute__((__packed__));
void copy_fields(const IEEE802_11_Beacon *other);
void copy_fields(const Dot11Beacon *other);
uint32_t write_fixed_parameters(uint8_t *buffer, uint32_t total_sz);
@@ -1179,7 +1179,7 @@ namespace Tins {
* \brief Class representing a Disassociation frame in the IEEE 802.11 Protocol.
*
*/
class IEEE802_11_Disassoc : public ManagementFrame {
class Dot11Disassoc : public Dot11ManagementFrame {
public:
@@ -1187,7 +1187,7 @@ namespace Tins {
* \brief Default constructor for the Disassociation frame.
*
*/
IEEE802_11_Disassoc();
Dot11Disassoc();
/**
* \brief Constructor for creating a 802.11 Disassociation.
@@ -1199,17 +1199,17 @@ namespace Tins {
* \param dst_hw_addr uint8_t array of 6 bytes containing the destination's MAC(optional).
* \param src_hw_addr uint8_t array of 6 bytes containing the source's MAC(optional).
*/
IEEE802_11_Disassoc(const std::string& iface, const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0) throw (std::runtime_error);
Dot11Disassoc(const std::string& iface, const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0) throw (std::runtime_error);
/**
* \brief Copy constructor.
*/
IEEE802_11_Disassoc(const IEEE802_11_Disassoc &other);
Dot11Disassoc(const Dot11Disassoc &other);
/**
* \brief Copy assignment operator.
*/
IEEE802_11_Disassoc &operator= (const IEEE802_11_Disassoc &other);
Dot11Disassoc &operator= (const Dot11Disassoc &other);
/**
* \brief Getter for the reason code.
@@ -1237,7 +1237,7 @@ namespace Tins {
uint16_t reason_code;
};
void copy_fields(const IEEE802_11_Disassoc *other);
void copy_fields(const Dot11Disassoc *other);
uint32_t write_fixed_parameters(uint8_t *buffer, uint32_t total_sz);
@@ -1248,7 +1248,7 @@ namespace Tins {
* \brief Class representing an Association Request frame in the IEEE 802.11 Protocol.
*
*/
class IEEE802_11_Assoc_Request : public ManagementFrame {
class Dot11AssocRequest : public Dot11ManagementFrame {
public:
@@ -1256,7 +1256,7 @@ namespace Tins {
* \brief Default constructor for the Association Request frame.
*
*/
IEEE802_11_Assoc_Request();
Dot11AssocRequest();
/**
* \brief Constructor for creating a 802.11 Association Request.
@@ -1268,26 +1268,26 @@ namespace Tins {
* \param dst_hw_addr uint8_t array of 6 bytes containing the destination's MAC(optional).
* \param src_hw_addr uint8_t array of 6 bytes containing the source's MAC(optional).
*/
IEEE802_11_Assoc_Request(const std::string& iface, const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0) throw (std::runtime_error);
Dot11AssocRequest(const std::string& iface, const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0) throw (std::runtime_error);
/**
* \brief Constructor which creates a IEEE802_11_Assoc_Request object from a
* \brief Constructor which creates a Dot11AssocRequest object from a
* buffer and adds all identifiable PDUs found in the buffer as children of this one.
*
* \param buffer The buffer from which this PDU will be constructed.
* \param total_sz The total size of the buffer.
*/
IEEE802_11_Assoc_Request(const uint8_t *buffer, uint32_t total_sz);
Dot11AssocRequest(const uint8_t *buffer, uint32_t total_sz);
/**
* \brief Copy constructor.
*/
IEEE802_11_Assoc_Request(const IEEE802_11_Assoc_Request &other);
Dot11AssocRequest(const Dot11AssocRequest &other);
/**
* \brief Copy assignment operator.
*/
IEEE802_11_Assoc_Request &operator= (const IEEE802_11_Assoc_Request &other);
Dot11AssocRequest &operator= (const Dot11AssocRequest &other);
/**
* \brief Getter for the Capabilities Information.
@@ -1380,7 +1380,7 @@ namespace Tins {
uint16_t listen_interval;
};
void copy_fields(const IEEE802_11_Assoc_Request *other);
void copy_fields(const Dot11AssocRequest *other);
uint32_t write_fixed_parameters(uint8_t *buffer, uint32_t total_sz);
AssocReqBody _body;
@@ -1390,7 +1390,7 @@ namespace Tins {
* \brief Class representing an Association Response frame in the IEEE 802.11 Protocol.
*
*/
class IEEE802_11_Assoc_Response : public ManagementFrame {
class Dot11AssocResponse : public Dot11ManagementFrame {
public:
@@ -1398,7 +1398,7 @@ namespace Tins {
* \brief Default constructor for the Association Response frame.
*
*/
IEEE802_11_Assoc_Response();
Dot11AssocResponse();
/**
* \brief Constructor for creating a 802.11 Association Response.
@@ -1410,26 +1410,26 @@ namespace Tins {
* \param dst_hw_addr uint8_t array of 6 bytes containing the destination's MAC(optional).
* \param src_hw_addr uint8_t array of 6 bytes containing the source's MAC(optional).
*/
IEEE802_11_Assoc_Response(const std::string& iface, const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0) throw (std::runtime_error);
Dot11AssocResponse(const std::string& iface, const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0) throw (std::runtime_error);
/**
* \brief Constructor which creates a IEEE802_11_Assoc_Response object from a
* \brief Constructor which creates a Dot11AssocResponse object from a
* buffer and adds all identifiable PDUs found in the buffer as children of this one.
*
* \param buffer The buffer from which this PDU will be constructed.
* \param total_sz The total size of the buffer.
*/
IEEE802_11_Assoc_Response(const uint8_t *buffer, uint32_t total_sz);
Dot11AssocResponse(const uint8_t *buffer, uint32_t total_sz);
/**
* \brief Copy constructor.
*/
IEEE802_11_Assoc_Response(const IEEE802_11_Assoc_Response &other);
Dot11AssocResponse(const Dot11AssocResponse &other);
/**
* \brief Copy assignment operator
*/
IEEE802_11_Assoc_Response &operator= (const IEEE802_11_Assoc_Response &other);
Dot11AssocResponse &operator= (const Dot11AssocResponse &other);
/**
* \brief Getter for the Capabilities Information.
@@ -1511,13 +1511,13 @@ namespace Tins {
uint16_t aid;
};
void copy_fields(const IEEE802_11_Assoc_Response *other);
void copy_fields(const Dot11AssocResponse *other);
uint32_t write_fixed_parameters(uint8_t *buffer, uint32_t total_sz);
AssocRespBody _body;
};
class IEEE802_11_QoS_Data : public IEEE802_11 {
class Dot11QoSData : public Dot11 {
public:
@@ -1530,7 +1530,7 @@ namespace Tins {
* \param src_hw_addr uint8_t array of 6 bytes containing the source's MAC(optional).
* \param child PDU* with the PDU contained by the 802.11 PDU (optional).
*/
IEEE802_11_QoS_Data(const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0, PDU* child = 0);
Dot11QoSData(const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0, PDU* child = 0);
/**
* \brief Constructor for creating a 802.11 QoS Data PDU
@@ -1543,7 +1543,7 @@ namespace Tins {
* \param src_hw_addr uint8_t array of 6 bytes containing the source's MAC(optional).
* \param child PDU* with the PDU contained by the 802.11 PDU (optional).
*/
IEEE802_11_QoS_Data(const std::string& iface, const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0, PDU* child = 0) throw (std::runtime_error);
Dot11QoSData(const std::string& iface, const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0, PDU* child = 0) throw (std::runtime_error);
/**
* \brief Constructor for creating an 802.11 QoS Data PDU
@@ -1556,7 +1556,7 @@ namespace Tins {
* \param src_hw_addr uint8_t array of 6 bytes containing the source's MAC(optional).
* \param child PDU* with the PDU contained by the 802.11 PDU (optional).
*/
IEEE802_11_QoS_Data(uint32_t iface_index, const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0, PDU* child = 0);
Dot11QoSData(uint32_t iface_index, const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0, PDU* child = 0);
/**
* \brief Constructor which creates an 802.11 QoS Data object from a buffer and adds all identifiable
@@ -1564,17 +1564,17 @@ namespace Tins {
* \param buffer The buffer from which this PDU will be constructed.
* \param total_sz The total size of the buffer.
*/
IEEE802_11_QoS_Data(const uint8_t *buffer, uint32_t total_sz);
Dot11QoSData(const uint8_t *buffer, uint32_t total_sz);
/**
* \brief Copy constructor.
*/
IEEE802_11_QoS_Data(const IEEE802_11_QoS_Data &other);
Dot11QoSData(const Dot11QoSData &other);
/**
* \brief Copy assignment operator.
*/
IEEE802_11_QoS_Data &operator= (const IEEE802_11_QoS_Data &other);
Dot11QoSData &operator= (const Dot11QoSData &other);
/**
* \brief Getter for the qos_control field.
@@ -1598,7 +1598,7 @@ namespace Tins {
*/
uint32_t header_size() const;
private:
void copy_fields(const IEEE802_11_QoS_Data *other);
void copy_fields(const Dot11QoSData *other);
uint32_t write_fixed_parameters(uint8_t *buffer, uint32_t total_sz);

View File

@@ -52,7 +52,7 @@ namespace Tins {
enum PDUType {
RAW,
ETHERNET_II,
IEEE802_11,
DOT11,
SNAP,
RADIOTAP,
IP,

View File

@@ -28,7 +28,7 @@
#include "eapol.h"
#include "ethernetII.h"
#include "icmp.h"
#include "ieee802-11.h"
#include "dot11.h"
#include "ip.h"
#include "packetsender.h"
#include "pdu.h"

View File

@@ -29,7 +29,7 @@
#include <netpacket/packet.h>
#include <netinet/in.h>
#endif
#include "ieee802-11.h"
#include "dot11.h"
#include "rawpdu.h"
#include "radiotap.h"
#include "sniffer.h"
@@ -38,9 +38,9 @@
using namespace std;
const uint8_t *Tins::IEEE802_11::BROADCAST = (const uint8_t*)"\xff\xff\xff\xff\xff\xff";
const uint8_t *Tins::Dot11::BROADCAST = (const uint8_t*)"\xff\xff\xff\xff\xff\xff";
Tins::IEEE802_11::IEEE802_11(const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr, PDU* child) : PDU(ETHERTYPE_IP, child), _options_size(0) {
Tins::Dot11::Dot11(const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr, PDU* child) : PDU(ETHERTYPE_IP, child), _options_size(0) {
memset(&this->_header, 0, sizeof(ieee80211_header));
if(dst_hw_addr)
this->addr1(dst_hw_addr);
@@ -48,7 +48,7 @@ Tins::IEEE802_11::IEEE802_11(const uint8_t* dst_hw_addr, const uint8_t* src_hw_a
this->addr2(src_hw_addr);
}
Tins::IEEE802_11::IEEE802_11(const std::string& iface, const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr, PDU* child) throw (std::runtime_error) : PDU(ETHERTYPE_IP, child), _options_size(0) {
Tins::Dot11::Dot11(const std::string& iface, const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr, PDU* child) throw (std::runtime_error) : PDU(ETHERTYPE_IP, child), _options_size(0) {
memset(&this->_header, 0, sizeof(ieee80211_header));
if(dst_hw_addr)
this->addr1(dst_hw_addr);
@@ -58,7 +58,7 @@ Tins::IEEE802_11::IEEE802_11(const std::string& iface, const uint8_t* dst_hw_add
}
Tins::IEEE802_11::IEEE802_11(uint32_t iface_index, const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr, PDU* child) : PDU(ETHERTYPE_IP, child), _options_size(0) {
Tins::Dot11::Dot11(uint32_t iface_index, const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr, PDU* child) : PDU(ETHERTYPE_IP, child), _options_size(0) {
memset(&this->_header, 0, sizeof(ieee80211_header));
if(dst_hw_addr)
this->addr1(dst_hw_addr);
@@ -67,11 +67,11 @@ Tins::IEEE802_11::IEEE802_11(uint32_t iface_index, const uint8_t* dst_hw_addr, c
this->iface(iface_index);
}
Tins::IEEE802_11::IEEE802_11(const ieee80211_header *header_ptr) : PDU(ETHERTYPE_IP) {
Tins::Dot11::Dot11(const ieee80211_header *header_ptr) : PDU(ETHERTYPE_IP) {
}
Tins::IEEE802_11::IEEE802_11(const uint8_t *buffer, uint32_t total_sz) : PDU(ETHERTYPE_IP), _options_size(0) {
Tins::Dot11::Dot11(const uint8_t *buffer, uint32_t total_sz) : PDU(ETHERTYPE_IP), _options_size(0) {
if(total_sz < sizeof(_header.control))
throw std::runtime_error("Not enough size for an IEEE 802.11 header in the buffer.");
uint32_t sz = std::min((uint32_t)sizeof(_header), total_sz);
@@ -84,24 +84,24 @@ Tins::IEEE802_11::IEEE802_11(const uint8_t *buffer, uint32_t total_sz) : PDU(ETH
}
}
Tins::IEEE802_11::IEEE802_11(const IEEE802_11 &other) : PDU(other) {
Tins::Dot11::Dot11(const Dot11 &other) : PDU(other) {
copy_80211_fields(&other);
}
Tins::IEEE802_11::~IEEE802_11() {
Tins::Dot11::~Dot11() {
while(_options.size()) {
delete[] _options.front().value;
_options.pop_front();
}
}
Tins::IEEE802_11 &Tins::IEEE802_11::operator= (const IEEE802_11 &other) {
Tins::Dot11 &Tins::Dot11::operator= (const Dot11 &other) {
copy_80211_fields(&other);
copy_inner_pdu(other);
return *this;
}
void Tins::IEEE802_11::parse_tagged_parameters(const uint8_t *buffer, uint32_t total_sz) {
void Tins::Dot11::parse_tagged_parameters(const uint8_t *buffer, uint32_t total_sz) {
uint8_t opcode, length;
while(total_sz >= 2) {
opcode = buffer[0];
@@ -116,110 +116,110 @@ void Tins::IEEE802_11::parse_tagged_parameters(const uint8_t *buffer, uint32_t t
}
}
Tins::IEEE802_11::IEEE802_11_Option::IEEE802_11_Option(uint8_t opt, uint8_t len, const uint8_t *val) : option(opt), length(len) {
Tins::Dot11::Dot11_Option::Dot11_Option(uint8_t opt, uint8_t len, const uint8_t *val) : option(opt), length(len) {
value = new uint8_t[len];
std::memcpy(value, val, len);
}
void Tins::IEEE802_11::add_tagged_option(TaggedOption opt, uint8_t len, const uint8_t *val) {
void Tins::Dot11::add_tagged_option(TaggedOption opt, uint8_t len, const uint8_t *val) {
uint32_t opt_size = len + (sizeof(uint8_t) << 1);
_options.push_back(IEEE802_11_Option((uint8_t)opt, len, val));
_options.push_back(Dot11_Option((uint8_t)opt, len, val));
_options_size += opt_size;
}
const Tins::IEEE802_11::IEEE802_11_Option *Tins::IEEE802_11::lookup_option(TaggedOption opt) const {
for(std::list<IEEE802_11_Option>::const_iterator it = _options.begin(); it != _options.end(); ++it)
const Tins::Dot11::Dot11_Option *Tins::Dot11::lookup_option(TaggedOption opt) const {
for(std::list<Dot11_Option>::const_iterator it = _options.begin(); it != _options.end(); ++it)
if(it->option == (uint8_t)opt)
return &(*it);
return 0;
}
void Tins::IEEE802_11::protocol(uint8_t new_proto) {
void Tins::Dot11::protocol(uint8_t new_proto) {
this->_header.control.protocol = new_proto;
}
void Tins::IEEE802_11::type(uint8_t new_type) {
void Tins::Dot11::type(uint8_t new_type) {
this->_header.control.type = new_type;
}
void Tins::IEEE802_11::subtype(uint8_t new_subtype) {
void Tins::Dot11::subtype(uint8_t new_subtype) {
this->_header.control.subtype = new_subtype;
}
void Tins::IEEE802_11::to_ds(bool new_value) {
void Tins::Dot11::to_ds(bool new_value) {
this->_header.control.to_ds = (new_value)? 1 : 0;
}
void Tins::IEEE802_11::from_ds(bool new_value) {
void Tins::Dot11::from_ds(bool new_value) {
this->_header.control.from_ds = (new_value)? 1 : 0;
}
void Tins::IEEE802_11::more_frag(bool new_value) {
void Tins::Dot11::more_frag(bool new_value) {
this->_header.control.more_frag = (new_value)? 1 : 0;
}
void Tins::IEEE802_11::retry(bool new_value) {
void Tins::Dot11::retry(bool new_value) {
this->_header.control.retry = (new_value)? 1 : 0;
}
void Tins::IEEE802_11::power_mgmt(bool new_value) {
void Tins::Dot11::power_mgmt(bool new_value) {
this->_header.control.power_mgmt = (new_value)? 1 : 0;
}
void Tins::IEEE802_11::wep(bool new_value) {
void Tins::Dot11::wep(bool new_value) {
this->_header.control.wep = (new_value)? 1 : 0;
}
void Tins::IEEE802_11::order(bool new_value) {
void Tins::Dot11::order(bool new_value) {
this->_header.control.order = (new_value)? 1 : 0;
}
void Tins::IEEE802_11::duration_id(uint16_t new_duration_id) {
void Tins::Dot11::duration_id(uint16_t new_duration_id) {
this->_header.duration_id = Utils::net_to_host_s(new_duration_id);
}
void Tins::IEEE802_11::addr1(const uint8_t* new_addr1) {
void Tins::Dot11::addr1(const uint8_t* new_addr1) {
memcpy(this->_header.addr1, new_addr1, 6);
}
void Tins::IEEE802_11::addr2(const uint8_t* new_addr2) {
void Tins::Dot11::addr2(const uint8_t* new_addr2) {
memcpy(this->_header.addr2, new_addr2, 6);
}
void Tins::IEEE802_11::addr3(const uint8_t* new_addr3) {
void Tins::Dot11::addr3(const uint8_t* new_addr3) {
memcpy(this->_header.addr3, new_addr3, 6);
}
void Tins::IEEE802_11::frag_num(uint8_t new_frag_num) {
void Tins::Dot11::frag_num(uint8_t new_frag_num) {
this->_header.seq_control.frag_number = new_frag_num;
}
void Tins::IEEE802_11::seq_num(uint16_t new_seq_num) {
void Tins::Dot11::seq_num(uint16_t new_seq_num) {
this->_header.seq_control.seq_number = Utils::net_to_host_s(new_seq_num);
}
void Tins::IEEE802_11::addr4(const uint8_t* new_addr4) {
void Tins::Dot11::addr4(const uint8_t* new_addr4) {
memcpy(this->_addr4, new_addr4, 6);
}
void Tins::IEEE802_11::iface(uint32_t new_iface_index) {
void Tins::Dot11::iface(uint32_t new_iface_index) {
this->_iface_index = new_iface_index;
}
void Tins::IEEE802_11::iface(const std::string& new_iface) throw (std::runtime_error) {
void Tins::Dot11::iface(const std::string& new_iface) throw (std::runtime_error) {
if (!Tins::Utils::interface_id(new_iface, this->_iface_index)) {
throw std::runtime_error("Invalid interface name!");
}
}
uint32_t Tins::IEEE802_11::header_size() const {
uint32_t Tins::Dot11::header_size() const {
uint32_t sz = sizeof(ieee80211_header) + _options_size;
if (this->to_ds() && this->from_ds())
sz += 6;
return sz;
}
bool Tins::IEEE802_11::send(PacketSender* sender) {
bool Tins::Dot11::send(PacketSender* sender) {
struct sockaddr_ll addr;
memset(&addr, 0, sizeof(struct sockaddr_ll));
@@ -233,7 +233,7 @@ bool Tins::IEEE802_11::send(PacketSender* sender) {
return sender->send_l2(this, (struct sockaddr*)&addr, (uint32_t)sizeof(addr));
}
void Tins::IEEE802_11::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent) {
void Tins::Dot11::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent) {
uint32_t my_sz = header_size();
assert(total_sz >= my_sz);
memcpy(buffer, &this->_header, sizeof(ieee80211_header));
@@ -247,7 +247,7 @@ void Tins::IEEE802_11::write_serialization(uint8_t *buffer, uint32_t total_sz, c
uint32_t child_len = write_fixed_parameters(buffer, total_sz - sizeof(ieee80211_header) - _options_size);
buffer += child_len;
assert(total_sz > child_len + _options_size);
for(std::list<IEEE802_11_Option>::const_iterator it = _options.begin(); it != _options.end(); ++it) {
for(std::list<Dot11_Option>::const_iterator it = _options.begin(); it != _options.end(); ++it) {
*(buffer++) = it->option;
*(buffer++) = it->length;
std::memcpy(buffer, it->value, it->length);
@@ -255,7 +255,7 @@ void Tins::IEEE802_11::write_serialization(uint8_t *buffer, uint32_t total_sz, c
}
}
Tins::PDU *Tins::IEEE802_11::from_bytes(const uint8_t *buffer, uint32_t total_sz) {
Tins::PDU *Tins::Dot11::from_bytes(const uint8_t *buffer, uint32_t total_sz) {
// We only need the control field, the length of the PDU will depend on the flags set.
if(total_sz < sizeof(ieee80211_header::control))
throw std::runtime_error("Not enough size for a IEEE 802.11 header in the buffer.");
@@ -264,49 +264,49 @@ Tins::PDU *Tins::IEEE802_11::from_bytes(const uint8_t *buffer, uint32_t total_sz
if(hdr->control.type == 0 && hdr->control.subtype == 8) {
if(total_sz < sizeof(_header))
throw std::runtime_error("Not enough size for an IEEE 802.11 header in the buffer.");
ret = new IEEE802_11_Beacon(buffer, total_sz);
ret = new Dot11Beacon(buffer, total_sz);
}
else
ret = new IEEE802_11(buffer, total_sz);
ret = new Dot11(buffer, total_sz);
return ret;
}
void Tins::IEEE802_11::copy_80211_fields(const IEEE802_11 *other) {
void Tins::Dot11::copy_80211_fields(const Dot11 *other) {
std::memcpy(&_header, &other->_header, sizeof(_header));
std::memcpy(_addr4, other->_addr4, sizeof(_header));
_iface_index = other->_iface_index;
_options_size = other->_options_size;
for(std::list<IEEE802_11_Option>::const_iterator it = other->_options.begin(); it != other->_options.end(); ++it)
_options.push_back(IEEE802_11_Option(it->option, it->length, it->value));
for(std::list<Dot11_Option>::const_iterator it = other->_options.begin(); it != other->_options.end(); ++it)
_options.push_back(Dot11_Option(it->option, it->length, it->value));
}
/*
* ManagementFrame
* Dot11ManagementFrame
*/
Tins::ManagementFrame::ManagementFrame(const uint8_t *buffer, uint32_t total_sz) : IEEE802_11(buffer, total_sz) {
Tins::Dot11ManagementFrame::Dot11ManagementFrame(const uint8_t *buffer, uint32_t total_sz) : Dot11(buffer, total_sz) {
}
Tins::ManagementFrame::ManagementFrame(const uint8_t *dst_hw_addr, const uint8_t *src_hw_addr) : IEEE802_11(dst_hw_addr, src_hw_addr) {
this->type(IEEE802_11::MANAGEMENT);
Tins::Dot11ManagementFrame::Dot11ManagementFrame(const uint8_t *dst_hw_addr, const uint8_t *src_hw_addr) : Dot11(dst_hw_addr, src_hw_addr) {
this->type(Dot11::MANAGEMENT);
}
Tins::ManagementFrame::ManagementFrame(const std::string &iface,
Tins::Dot11ManagementFrame::Dot11ManagementFrame(const std::string &iface,
const uint8_t *dst_hw_addr,
const uint8_t *src_hw_addr) throw (std::runtime_error) : IEEE802_11(iface, dst_hw_addr, src_hw_addr) {
this->type(IEEE802_11::MANAGEMENT);
const uint8_t *src_hw_addr) throw (std::runtime_error) : Dot11(iface, dst_hw_addr, src_hw_addr) {
this->type(Dot11::MANAGEMENT);
}
Tins::ManagementFrame::ManagementFrame(const ManagementFrame &other) : IEEE802_11(other) {
Tins::Dot11ManagementFrame::Dot11ManagementFrame(const Dot11ManagementFrame &other) : Dot11(other) {
}
void Tins::ManagementFrame::ssid(const std::string &new_ssid) {
add_tagged_option(IEEE802_11::SSID, new_ssid.size(), (const uint8_t*)new_ssid.c_str());
void Tins::Dot11ManagementFrame::ssid(const std::string &new_ssid) {
add_tagged_option(Dot11::SSID, new_ssid.size(), (const uint8_t*)new_ssid.c_str());
}
void Tins::ManagementFrame::rates(const std::list<float> &new_rates) {
void Tins::Dot11ManagementFrame::rates(const std::list<float> &new_rates) {
uint8_t *buffer = new uint8_t[new_rates.size()], *ptr = buffer;
for(std::list<float>::const_iterator it = new_rates.begin(); it != new_rates.end(); ++it) {
uint8_t result = 0x80, left = *it / 0.5;
@@ -318,18 +318,18 @@ void Tins::ManagementFrame::rates(const std::list<float> &new_rates) {
delete[] buffer;
}
void Tins::ManagementFrame::channel(uint8_t new_channel) {
void Tins::Dot11ManagementFrame::channel(uint8_t new_channel) {
add_tagged_option(DS_SET, 1, &new_channel);
}
void Tins::ManagementFrame::rsn_information(const RSNInformation& info) {
void Tins::Dot11ManagementFrame::rsn_information(const RSNInformation& info) {
uint32_t size;
uint8_t *buffer = info.serialize(size);
add_tagged_option(RSN, size, buffer);
delete[] buffer;
}
void Tins::ManagementFrame::supported_rates(const std::list<float> &new_rates) {
void Tins::Dot11ManagementFrame::supported_rates(const std::list<float> &new_rates) {
uint8_t *buffer = new uint8_t[new_rates.size()], *ptr = buffer;
for(std::list<float>::const_iterator it = new_rates.begin(); it != new_rates.end(); ++it) {
uint8_t result = 0x80, left = *it / 0.5;
@@ -341,7 +341,7 @@ void Tins::ManagementFrame::supported_rates(const std::list<float> &new_rates) {
delete[] buffer;
}
void Tins::ManagementFrame::extended_supported_rates(const std::list<float> &new_rates) {
void Tins::Dot11ManagementFrame::extended_supported_rates(const std::list<float> &new_rates) {
uint8_t *buffer = new uint8_t[new_rates.size()], *ptr = buffer;
for(std::list<float>::const_iterator it = new_rates.begin(); it != new_rates.end(); ++it) {
uint8_t result = 0x80, left = *it / 0.5;
@@ -353,18 +353,18 @@ void Tins::ManagementFrame::extended_supported_rates(const std::list<float> &new
delete[] buffer;
}
void Tins::ManagementFrame::qos_capabilities(uint8_t new_qos_capabilities) {
void Tins::Dot11ManagementFrame::qos_capabilities(uint8_t new_qos_capabilities) {
add_tagged_option(QOS_CAPABILITY, 1, &new_qos_capabilities);
}
void Tins::ManagementFrame::power_capabilities(uint8_t min_power, uint8_t max_power) {
void Tins::Dot11ManagementFrame::power_capabilities(uint8_t min_power, uint8_t max_power) {
uint8_t buffer[2];
buffer[0] = min_power;
buffer[1] = max_power;
add_tagged_option(POWER_CAPABILITY, 2, buffer);
}
void Tins::ManagementFrame::supported_channels(const std::list<std::pair<uint8_t, uint8_t> > &new_channels) {
void Tins::Dot11ManagementFrame::supported_channels(const std::list<std::pair<uint8_t, uint8_t> > &new_channels) {
uint8_t* buffer = new uint8_t[new_channels.size() * 2];
uint8_t* ptr = buffer;
for(std::list<pair<uint8_t, uint8_t> >::const_iterator it = new_channels.begin(); it != new_channels.end(); ++it) {
@@ -375,7 +375,7 @@ void Tins::ManagementFrame::supported_channels(const std::list<std::pair<uint8_t
delete[] buffer;
}
void Tins::ManagementFrame::edca_parameter_set(uint32_t ac_be, uint32_t ac_bk, uint32_t ac_vi, uint32_t ac_vo) {
void Tins::Dot11ManagementFrame::edca_parameter_set(uint32_t ac_be, uint32_t ac_bk, uint32_t ac_vi, uint32_t ac_vo) {
uint8_t* buffer = new uint8_t[18];
buffer[0] = 0;
uint32_t* ptr = (uint32_t*)(buffer + 1);
@@ -391,19 +391,19 @@ void Tins::ManagementFrame::edca_parameter_set(uint32_t ac_be, uint32_t ac_bk, u
* Beacon
*/
Tins::IEEE802_11_Beacon::IEEE802_11_Beacon(const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr) : ManagementFrame() {
this->subtype(IEEE802_11::BEACON);
Tins::Dot11Beacon::Dot11Beacon(const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr) : Dot11ManagementFrame() {
this->subtype(Dot11::BEACON);
memset(&_body, 0, sizeof(_body));
}
Tins::IEEE802_11_Beacon::IEEE802_11_Beacon(const std::string& iface,
Tins::Dot11Beacon::Dot11Beacon(const std::string& iface,
const uint8_t* dst_hw_addr,
const uint8_t* src_hw_addr) throw (std::runtime_error) : ManagementFrame(iface, dst_hw_addr, src_hw_addr){
this->subtype(IEEE802_11::BEACON);
const uint8_t* src_hw_addr) throw (std::runtime_error) : Dot11ManagementFrame(iface, dst_hw_addr, src_hw_addr){
this->subtype(Dot11::BEACON);
memset(&_body, 0, sizeof(_body));
}
Tins::IEEE802_11_Beacon::IEEE802_11_Beacon(const uint8_t *buffer, uint32_t total_sz) : ManagementFrame(buffer, total_sz) {
Tins::Dot11Beacon::Dot11Beacon(const uint8_t *buffer, uint32_t total_sz) : Dot11ManagementFrame(buffer, total_sz) {
buffer += sizeof(ieee80211_header);
total_sz -= sizeof(ieee80211_header);
if(total_sz < sizeof(_body))
@@ -414,52 +414,52 @@ Tins::IEEE802_11_Beacon::IEEE802_11_Beacon(const uint8_t *buffer, uint32_t total
parse_tagged_parameters(buffer, total_sz);
}
Tins::IEEE802_11_Beacon::IEEE802_11_Beacon(const IEEE802_11_Beacon &other) : ManagementFrame(other) {
Tins::Dot11Beacon::Dot11Beacon(const Dot11Beacon &other) : Dot11ManagementFrame(other) {
}
Tins::IEEE802_11_Beacon &Tins::IEEE802_11_Beacon::operator= (const IEEE802_11_Beacon &other) {
Tins::Dot11Beacon &Tins::Dot11Beacon::operator= (const Dot11Beacon &other) {
copy_fields(&other);
copy_inner_pdu(other);
return *this;
}
void Tins::IEEE802_11_Beacon::copy_fields(const IEEE802_11_Beacon *other) {
void Tins::Dot11Beacon::copy_fields(const Dot11Beacon *other) {
copy_80211_fields(other);
std::memcpy(&_body, &other->_body, sizeof(_body));
}
void Tins::IEEE802_11_Beacon::timestamp(uint64_t new_timestamp) {
void Tins::Dot11Beacon::timestamp(uint64_t new_timestamp) {
this->_body.timestamp = new_timestamp;
}
void Tins::IEEE802_11_Beacon::interval(uint16_t new_interval) {
void Tins::Dot11Beacon::interval(uint16_t new_interval) {
this->_body.interval = Utils::net_to_host_s(new_interval);
}
void Tins::IEEE802_11_Beacon::essid(const std::string &new_essid) {
ManagementFrame::ssid(new_essid);
void Tins::Dot11Beacon::essid(const std::string &new_essid) {
Dot11ManagementFrame::ssid(new_essid);
}
void Tins::IEEE802_11_Beacon::rates(const std::list<float> &new_rates) {
ManagementFrame::rates(new_rates);
void Tins::Dot11Beacon::rates(const std::list<float> &new_rates) {
Dot11ManagementFrame::rates(new_rates);
}
void Tins::IEEE802_11_Beacon::channel(uint8_t new_channel) {
ManagementFrame::channel(new_channel);
void Tins::Dot11Beacon::channel(uint8_t new_channel) {
Dot11ManagementFrame::channel(new_channel);
}
void Tins::IEEE802_11_Beacon::rsn_information(const RSNInformation& info) {
ManagementFrame::rsn_information(info);
void Tins::Dot11Beacon::rsn_information(const RSNInformation& info) {
Dot11ManagementFrame::rsn_information(info);
}
string Tins::IEEE802_11_Beacon::essid() const {
const IEEE802_11::IEEE802_11_Option *option = lookup_option(SSID);
string Tins::Dot11Beacon::essid() const {
const Dot11::Dot11_Option *option = lookup_option(SSID);
return (option) ? string((const char*)option->value, option->length) : 0;
}
bool Tins::IEEE802_11_Beacon::rsn_information(RSNInformation *rsn) {
const IEEE802_11::IEEE802_11_Option *option = lookup_option(RSN);
bool Tins::Dot11Beacon::rsn_information(RSNInformation *rsn) {
const Dot11::Dot11_Option *option = lookup_option(RSN);
if(!option || option->length < (sizeof(uint16_t) << 1) + sizeof(uint32_t))
return false;
const uint8_t *buffer = option->value;
@@ -499,11 +499,11 @@ bool Tins::IEEE802_11_Beacon::rsn_information(RSNInformation *rsn) {
return true;
}
uint32_t Tins::IEEE802_11_Beacon::header_size() const {
return IEEE802_11::header_size() + sizeof(BeaconBody);
uint32_t Tins::Dot11Beacon::header_size() const {
return Dot11::header_size() + sizeof(BeaconBody);
}
uint32_t Tins::IEEE802_11_Beacon::write_fixed_parameters(uint8_t *buffer, uint32_t total_sz) {
uint32_t Tins::Dot11Beacon::write_fixed_parameters(uint8_t *buffer, uint32_t total_sz) {
uint32_t sz = sizeof(BeaconBody);
assert(sz <= total_sz);
memcpy(buffer, &this->_body, sz);
@@ -512,42 +512,42 @@ uint32_t Tins::IEEE802_11_Beacon::write_fixed_parameters(uint8_t *buffer, uint32
/* 802.11 diassoc */
Tins::IEEE802_11_Disassoc::IEEE802_11_Disassoc() : ManagementFrame() {
this->subtype(IEEE802_11::DISASSOC);
Tins::Dot11Disassoc::Dot11Disassoc() : Dot11ManagementFrame() {
this->subtype(Dot11::DISASSOC);
memset(&_body, 0, sizeof(_body));
}
Tins::IEEE802_11_Disassoc::IEEE802_11_Disassoc(const std::string& iface,
Tins::Dot11Disassoc::Dot11Disassoc(const std::string& iface,
const uint8_t* dst_hw_addr,
const uint8_t* src_hw_addr) throw (std::runtime_error) : ManagementFrame(iface, dst_hw_addr, src_hw_addr){
this->subtype(IEEE802_11::DISASSOC);
const uint8_t* src_hw_addr) throw (std::runtime_error) : Dot11ManagementFrame(iface, dst_hw_addr, src_hw_addr){
this->subtype(Dot11::DISASSOC);
memset(&_body, 0, sizeof(_body));
}
Tins::IEEE802_11_Disassoc::IEEE802_11_Disassoc(const IEEE802_11_Disassoc &other) : ManagementFrame(other) {
Tins::Dot11Disassoc::Dot11Disassoc(const Dot11Disassoc &other) : Dot11ManagementFrame(other) {
copy_fields(&other);
}
Tins::IEEE802_11_Disassoc &Tins::IEEE802_11_Disassoc::operator= (const IEEE802_11_Disassoc &other) {
Tins::Dot11Disassoc &Tins::Dot11Disassoc::operator= (const Dot11Disassoc &other) {
copy_inner_pdu(other);
copy_fields(&other);
return *this;
}
void Tins::IEEE802_11_Disassoc::copy_fields(const IEEE802_11_Disassoc *other) {
void Tins::Dot11Disassoc::copy_fields(const Dot11Disassoc *other) {
copy_80211_fields(other);
std::memcpy(&_body, &other->_body, sizeof(_body));
}
void Tins::IEEE802_11_Disassoc::reason_code(uint16_t new_reason_code) {
void Tins::Dot11Disassoc::reason_code(uint16_t new_reason_code) {
this->_body.reason_code = new_reason_code;
}
uint32_t Tins::IEEE802_11_Disassoc::header_size() const {
return IEEE802_11::header_size() + sizeof(DisassocBody);
uint32_t Tins::Dot11Disassoc::header_size() const {
return Dot11::header_size() + sizeof(DisassocBody);
}
uint32_t Tins::IEEE802_11_Disassoc::write_fixed_parameters(uint8_t *buffer, uint32_t total_sz) {
uint32_t Tins::Dot11Disassoc::write_fixed_parameters(uint8_t *buffer, uint32_t total_sz) {
uint32_t sz = sizeof(DisassocBody);
assert(sz <= total_sz);
memcpy(buffer, &this->_body, sz);
@@ -617,19 +617,19 @@ Tins::RSNInformation Tins::RSNInformation::wpa2_psk() {
/* Assoc request. */
Tins::IEEE802_11_Assoc_Request::IEEE802_11_Assoc_Request() : ManagementFrame() {
this->subtype(IEEE802_11::ASSOC_REQ);
Tins::Dot11AssocRequest::Dot11AssocRequest() : Dot11ManagementFrame() {
this->subtype(Dot11::ASSOC_REQ);
memset(&_body, 0, sizeof(_body));
}
Tins::IEEE802_11_Assoc_Request::IEEE802_11_Assoc_Request(const std::string& iface,
Tins::Dot11AssocRequest::Dot11AssocRequest(const std::string& iface,
const uint8_t* dst_hw_addr,
const uint8_t* src_hw_addr) throw (std::runtime_error) : ManagementFrame(iface, dst_hw_addr, src_hw_addr){
this->subtype(IEEE802_11::ASSOC_REQ);
const uint8_t* src_hw_addr) throw (std::runtime_error) : Dot11ManagementFrame(iface, dst_hw_addr, src_hw_addr){
this->subtype(Dot11::ASSOC_REQ);
memset(&_body, 0, sizeof(_body));
}
Tins::IEEE802_11_Assoc_Request::IEEE802_11_Assoc_Request(const uint8_t *buffer, uint32_t total_sz) : ManagementFrame(buffer, total_sz) {
Tins::Dot11AssocRequest::Dot11AssocRequest(const uint8_t *buffer, uint32_t total_sz) : Dot11ManagementFrame(buffer, total_sz) {
buffer += sizeof(ieee80211_header);
total_sz -= sizeof(ieee80211_header);
if(total_sz < sizeof(_body))
@@ -640,58 +640,58 @@ Tins::IEEE802_11_Assoc_Request::IEEE802_11_Assoc_Request(const uint8_t *buffer,
parse_tagged_parameters(buffer, total_sz);
}
Tins::IEEE802_11_Assoc_Request::IEEE802_11_Assoc_Request(const IEEE802_11_Assoc_Request &other) : ManagementFrame(other) {
Tins::Dot11AssocRequest::Dot11AssocRequest(const Dot11AssocRequest &other) : Dot11ManagementFrame(other) {
copy_fields(&other);
}
Tins::IEEE802_11_Assoc_Request &Tins::IEEE802_11_Assoc_Request::operator= (const IEEE802_11_Assoc_Request &other) {
Tins::Dot11AssocRequest &Tins::Dot11AssocRequest::operator= (const Dot11AssocRequest &other) {
copy_inner_pdu(other);
copy_fields(&other);
return *this;
}
void Tins::IEEE802_11_Assoc_Request::copy_fields(const IEEE802_11_Assoc_Request *other) {
void Tins::Dot11AssocRequest::copy_fields(const Dot11AssocRequest *other) {
copy_80211_fields(other);
std::memcpy(&_body, &other->_body, sizeof(_body));
}
void Tins::IEEE802_11_Assoc_Request::listen_interval(uint16_t new_listen_interval) {
void Tins::Dot11AssocRequest::listen_interval(uint16_t new_listen_interval) {
this->_body.listen_interval = new_listen_interval;
}
void Tins::IEEE802_11_Assoc_Request::ssid(const std::string &new_ssid) {
ManagementFrame::ssid(new_ssid);
void Tins::Dot11AssocRequest::ssid(const std::string &new_ssid) {
Dot11ManagementFrame::ssid(new_ssid);
}
void Tins::IEEE802_11_Assoc_Request::supported_rates(const std::list<float> &new_rates) {
ManagementFrame::supported_rates(new_rates);
void Tins::Dot11AssocRequest::supported_rates(const std::list<float> &new_rates) {
Dot11ManagementFrame::supported_rates(new_rates);
}
void Tins::IEEE802_11_Assoc_Request::extended_supported_rates(const std::list<float> &new_rates) {
ManagementFrame::extended_supported_rates(new_rates);
void Tins::Dot11AssocRequest::extended_supported_rates(const std::list<float> &new_rates) {
Dot11ManagementFrame::extended_supported_rates(new_rates);
}
void Tins::IEEE802_11_Assoc_Request::power_capabilities(uint8_t min_power, uint8_t max_power) {
ManagementFrame::power_capabilities(min_power, max_power);
void Tins::Dot11AssocRequest::power_capabilities(uint8_t min_power, uint8_t max_power) {
Dot11ManagementFrame::power_capabilities(min_power, max_power);
}
void Tins::IEEE802_11_Assoc_Request::supported_channels(const std::list<pair<uint8_t, uint8_t> > &new_channels) {
ManagementFrame::supported_channels(new_channels);
void Tins::Dot11AssocRequest::supported_channels(const std::list<pair<uint8_t, uint8_t> > &new_channels) {
Dot11ManagementFrame::supported_channels(new_channels);
}
void Tins::IEEE802_11_Assoc_Request::rsn_information(const RSNInformation& info) {
ManagementFrame::rsn_information(info);
void Tins::Dot11AssocRequest::rsn_information(const RSNInformation& info) {
Dot11ManagementFrame::rsn_information(info);
}
void Tins::IEEE802_11_Assoc_Request::qos_capabilities(uint8_t new_qos_capabilities) {
ManagementFrame::qos_capabilities(new_qos_capabilities);
void Tins::Dot11AssocRequest::qos_capabilities(uint8_t new_qos_capabilities) {
Dot11ManagementFrame::qos_capabilities(new_qos_capabilities);
}
uint32_t Tins::IEEE802_11_Assoc_Request::header_size() const {
return IEEE802_11::header_size() + sizeof(AssocReqBody);
uint32_t Tins::Dot11AssocRequest::header_size() const {
return Dot11::header_size() + sizeof(AssocReqBody);
}
uint32_t Tins::IEEE802_11_Assoc_Request::write_fixed_parameters(uint8_t *buffer, uint32_t total_sz) {
uint32_t Tins::Dot11AssocRequest::write_fixed_parameters(uint8_t *buffer, uint32_t total_sz) {
uint32_t sz = sizeof(AssocReqBody);
assert(sz <= total_sz);
memcpy(buffer, &this->_body, sz);
@@ -700,19 +700,19 @@ uint32_t Tins::IEEE802_11_Assoc_Request::write_fixed_parameters(uint8_t *buffer,
/* Assoc response. */
Tins::IEEE802_11_Assoc_Response::IEEE802_11_Assoc_Response() : ManagementFrame() {
this->subtype(IEEE802_11::ASSOC_RESP);
Tins::Dot11AssocResponse::Dot11AssocResponse() : Dot11ManagementFrame() {
this->subtype(Dot11::ASSOC_RESP);
memset(&_body, 0, sizeof(_body));
}
Tins::IEEE802_11_Assoc_Response::IEEE802_11_Assoc_Response(const std::string& iface,
Tins::Dot11AssocResponse::Dot11AssocResponse(const std::string& iface,
const uint8_t* dst_hw_addr,
const uint8_t* src_hw_addr) throw (std::runtime_error) : ManagementFrame(iface, dst_hw_addr, src_hw_addr) {
this->subtype(IEEE802_11::ASSOC_RESP);
const uint8_t* src_hw_addr) throw (std::runtime_error) : Dot11ManagementFrame(iface, dst_hw_addr, src_hw_addr) {
this->subtype(Dot11::ASSOC_RESP);
memset(&_body, 0, sizeof(_body));
}
Tins::IEEE802_11_Assoc_Response::IEEE802_11_Assoc_Response(const uint8_t *buffer, uint32_t total_sz) : ManagementFrame(buffer, total_sz) {
Tins::Dot11AssocResponse::Dot11AssocResponse(const uint8_t *buffer, uint32_t total_sz) : Dot11ManagementFrame(buffer, total_sz) {
buffer += sizeof(ieee80211_header);
total_sz -= sizeof(ieee80211_header);
if(total_sz < sizeof(_body))
@@ -723,46 +723,46 @@ Tins::IEEE802_11_Assoc_Response::IEEE802_11_Assoc_Response(const uint8_t *buffer
parse_tagged_parameters(buffer, total_sz);
}
Tins::IEEE802_11_Assoc_Response::IEEE802_11_Assoc_Response(const IEEE802_11_Assoc_Response &other) : ManagementFrame(other) {
Tins::Dot11AssocResponse::Dot11AssocResponse(const Dot11AssocResponse &other) : Dot11ManagementFrame(other) {
copy_fields(&other);
}
Tins::IEEE802_11_Assoc_Response &Tins::IEEE802_11_Assoc_Response::operator= (const IEEE802_11_Assoc_Response &other) {
Tins::Dot11AssocResponse &Tins::Dot11AssocResponse::operator= (const Dot11AssocResponse &other) {
copy_inner_pdu(other);
copy_fields(&other);
return *this;
}
void Tins::IEEE802_11_Assoc_Response::copy_fields(const IEEE802_11_Assoc_Response *other) {
void Tins::Dot11AssocResponse::copy_fields(const Dot11AssocResponse *other) {
copy_80211_fields(other);
std::memcpy(&_body, &other->_body, sizeof(_body));
}
void Tins::IEEE802_11_Assoc_Response::status_code(uint16_t new_status_code) {
void Tins::Dot11AssocResponse::status_code(uint16_t new_status_code) {
this->_body.status_code = new_status_code;
}
void Tins::IEEE802_11_Assoc_Response::aid(uint16_t new_aid) {
void Tins::Dot11AssocResponse::aid(uint16_t new_aid) {
this->_body.aid = new_aid;
}
void Tins::IEEE802_11_Assoc_Response::supported_rates(const std::list<float> &new_rates) {
ManagementFrame::supported_rates(new_rates);
void Tins::Dot11AssocResponse::supported_rates(const std::list<float> &new_rates) {
Dot11ManagementFrame::supported_rates(new_rates);
}
void Tins::IEEE802_11_Assoc_Response::extended_supported_rates(const std::list<float> &new_rates) {
ManagementFrame::extended_supported_rates(new_rates);
void Tins::Dot11AssocResponse::extended_supported_rates(const std::list<float> &new_rates) {
Dot11ManagementFrame::extended_supported_rates(new_rates);
}
void Tins::IEEE802_11_Assoc_Response::edca_parameter_set(uint32_t ac_be, uint32_t ac_bk, uint32_t ac_vi, uint32_t ac_vo) {
ManagementFrame::edca_parameter_set(ac_be, ac_bk, ac_vi, ac_vo);
void Tins::Dot11AssocResponse::edca_parameter_set(uint32_t ac_be, uint32_t ac_bk, uint32_t ac_vi, uint32_t ac_vo) {
Dot11ManagementFrame::edca_parameter_set(ac_be, ac_bk, ac_vi, ac_vo);
}
uint32_t Tins::IEEE802_11_Assoc_Response::header_size() const {
return IEEE802_11::header_size() + sizeof(AssocRespBody);
uint32_t Tins::Dot11AssocResponse::header_size() const {
return Dot11::header_size() + sizeof(AssocRespBody);
}
uint32_t Tins::IEEE802_11_Assoc_Response::write_fixed_parameters(uint8_t *buffer, uint32_t total_sz) {
uint32_t Tins::Dot11AssocResponse::write_fixed_parameters(uint8_t *buffer, uint32_t total_sz) {
uint32_t sz = sizeof(AssocRespBody);
assert(sz <= total_sz);
memcpy(buffer, &this->_body, sz);
@@ -771,25 +771,25 @@ uint32_t Tins::IEEE802_11_Assoc_Response::write_fixed_parameters(uint8_t *buffer
/* QoS data. */
Tins::IEEE802_11_QoS_Data::IEEE802_11_QoS_Data(const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr, PDU* child) : IEEE802_11(dst_hw_addr, src_hw_addr, child) {
this->type(IEEE802_11::DATA);
this->subtype(IEEE802_11::QOS_DATA_DATA);
Tins::Dot11QoSData::Dot11QoSData(const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr, PDU* child) : Dot11(dst_hw_addr, src_hw_addr, child) {
this->type(Dot11::DATA);
this->subtype(Dot11::QOS_DATA_DATA);
this->_qos_control = 0;
}
Tins::IEEE802_11_QoS_Data::IEEE802_11_QoS_Data(const std::string& iface, const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr, PDU* child) throw (std::runtime_error) : IEEE802_11(iface, dst_hw_addr, src_hw_addr, child) {
this->type(IEEE802_11::DATA);
this->subtype(IEEE802_11::QOS_DATA_DATA);
Tins::Dot11QoSData::Dot11QoSData(const std::string& iface, const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr, PDU* child) throw (std::runtime_error) : Dot11(iface, dst_hw_addr, src_hw_addr, child) {
this->type(Dot11::DATA);
this->subtype(Dot11::QOS_DATA_DATA);
this->_qos_control = 0;
}
Tins::IEEE802_11_QoS_Data::IEEE802_11_QoS_Data(uint32_t iface_index, const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr, PDU* child) : IEEE802_11(iface_index, dst_hw_addr, src_hw_addr, child) {
this->type(IEEE802_11::DATA);
this->subtype(IEEE802_11::QOS_DATA_DATA);
Tins::Dot11QoSData::Dot11QoSData(uint32_t iface_index, const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr, PDU* child) : Dot11(iface_index, dst_hw_addr, src_hw_addr, child) {
this->type(Dot11::DATA);
this->subtype(Dot11::QOS_DATA_DATA);
this->_qos_control = 0;
}
Tins::IEEE802_11_QoS_Data::IEEE802_11_QoS_Data(const uint8_t *buffer, uint32_t total_sz) : IEEE802_11(buffer, total_sz) {
Tins::Dot11QoSData::Dot11QoSData(const uint8_t *buffer, uint32_t total_sz) : Dot11(buffer, total_sz) {
buffer += sizeof(ieee80211_header);
total_sz -= sizeof(ieee80211_header);
assert(total_sz >= sizeof(this->_qos_control));
@@ -800,30 +800,30 @@ Tins::IEEE802_11_QoS_Data::IEEE802_11_QoS_Data(const uint8_t *buffer, uint32_t t
inner_pdu(new Tins::SNAP(buffer, total_sz));
}
Tins::IEEE802_11_QoS_Data::IEEE802_11_QoS_Data(const IEEE802_11_QoS_Data &other) : IEEE802_11(other) {
Tins::Dot11QoSData::Dot11QoSData(const Dot11QoSData &other) : Dot11(other) {
copy_fields(&other);
}
Tins::IEEE802_11_QoS_Data &Tins::IEEE802_11_QoS_Data::operator= (const IEEE802_11_QoS_Data &other) {
Tins::Dot11QoSData &Tins::Dot11QoSData::operator= (const Dot11QoSData &other) {
copy_inner_pdu(other);
copy_fields(&other);
return *this;
}
void Tins::IEEE802_11_QoS_Data::copy_fields(const IEEE802_11_QoS_Data *other) {
void Tins::Dot11QoSData::copy_fields(const Dot11QoSData *other) {
copy_80211_fields(other);
_qos_control = other->_qos_control;
}
void Tins::IEEE802_11_QoS_Data::qos_control(uint16_t new_qos_control) {
void Tins::Dot11QoSData::qos_control(uint16_t new_qos_control) {
this->_qos_control = new_qos_control;
}
uint32_t Tins::IEEE802_11_QoS_Data::header_size() const {
return IEEE802_11::header_size() + sizeof(this->_qos_control);
uint32_t Tins::Dot11QoSData::header_size() const {
return Dot11::header_size() + sizeof(this->_qos_control);
}
uint32_t Tins::IEEE802_11_QoS_Data::write_fixed_parameters(uint8_t *buffer, uint32_t total_sz) {
uint32_t Tins::Dot11QoSData::write_fixed_parameters(uint8_t *buffer, uint32_t total_sz) {
uint32_t sz = sizeof(this->_qos_control);
assert(sz <= total_sz);
*(uint16_t*)buffer = this->_qos_control;

View File

@@ -23,7 +23,7 @@
#include <cassert>
#include <stdexcept>
#include "eapol.h"
#include "ieee802-11.h"
#include "dot11.h"
Tins::EAPOL::EAPOL(uint8_t packet_type, EAPOLTYPE type) : PDU(0xff) {
@@ -287,7 +287,7 @@ void Tins::RSNEAPOL::write_body(uint8_t *buffer, uint32_t total_sz) {
buffer += sizeof(_header);
if(_key) {
if(_header.key_type && _key_size) {
*(buffer++) = IEEE802_11::RSN;
*(buffer++) = Dot11::RSN;
*(buffer++) = _key_size;
}
std::memcpy(buffer, _key, _key_size);

View File

@@ -26,7 +26,7 @@
#include <netpacket/packet.h>
#endif
#include "radiotap.h"
#include "ieee802-11.h"
#include "dot11.h"
#include "utils.h"
@@ -108,7 +108,7 @@ Tins::RadioTap::RadioTap(const uint8_t *buffer, uint32_t total_sz) : PDU(0xff) {
total_sz -= sizeof(_rx_flags);
}
if(total_sz)
inner_pdu(IEEE802_11::from_bytes(buffer, total_sz));
inner_pdu(Dot11::from_bytes(buffer, total_sz));
}
void Tins::RadioTap::version(uint8_t new_version) {
@@ -196,7 +196,7 @@ bool Tins::RadioTap::send(PacketSender* sender) {
addr.sll_halen = 6;
addr.sll_ifindex = _iface_index;
Tins::IEEE802_11 *wlan = dynamic_cast<Tins::IEEE802_11*>(inner_pdu());
Tins::Dot11 *wlan = dynamic_cast<Tins::Dot11*>(inner_pdu());
if(wlan)
memcpy(&(addr.sll_addr), wlan->addr1(), 6);