mirror of
https://github.com/mfontanini/libtins
synced 2026-01-23 02:35:57 +01:00
Added Dot11ReAssocResponse.
This commit is contained in:
140
include/dot11.h
140
include/dot11.h
@@ -1645,6 +1645,10 @@ namespace Tins {
|
||||
AssocRespBody _body;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Class representing an ReAssociation Request frame in the IEEE 802.11 Protocol.
|
||||
*
|
||||
*/
|
||||
class Dot11ReAssocRequest : public Dot11ManagementFrame {
|
||||
|
||||
public:
|
||||
@@ -1804,6 +1808,142 @@ namespace Tins {
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Class representing an ReAssociation Response frame in the IEEE 802.11 Protocol.
|
||||
*
|
||||
*/
|
||||
class Dot11ReAssocResponse : public Dot11ManagementFrame {
|
||||
|
||||
public:
|
||||
/**
|
||||
* \brief Default constructor for the Association Response frame.
|
||||
*
|
||||
*/
|
||||
Dot11ReAssocResponse();
|
||||
|
||||
/**
|
||||
* \brief Constructor for creating a 802.11 ReAssociation Response.
|
||||
*
|
||||
* Constructor that builds a 802.11 ReAssociation Response taking the interface name,
|
||||
* destination's and source's MAC.
|
||||
*
|
||||
* \param iface string containing the interface's name from where to send the packet.
|
||||
* \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).
|
||||
*/
|
||||
Dot11ReAssocResponse(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 Dot11ReAssocResponse 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.
|
||||
*/
|
||||
Dot11ReAssocResponse(const uint8_t *buffer, uint32_t total_sz);
|
||||
|
||||
/**
|
||||
* \brief Copy constructor.
|
||||
*/
|
||||
Dot11ReAssocResponse(const Dot11ReAssocResponse &other);
|
||||
|
||||
/**
|
||||
* \brief Copy assignment operator
|
||||
*/
|
||||
Dot11ReAssocResponse &operator= (const Dot11ReAssocResponse &other);
|
||||
|
||||
/**
|
||||
* \brief Getter for the Capabilities Information.
|
||||
*
|
||||
* \return CapabilityInformation Structure in a CapabilityInformation&.
|
||||
*/
|
||||
inline const CapabilityInformation& capabilities() const { return this->_body.capability;}
|
||||
|
||||
/**
|
||||
* \brief Getter for the Capabilities Information.
|
||||
*
|
||||
* \return CapabilityInformation Structure in a CapabilityInformation&.
|
||||
*/
|
||||
inline CapabilityInformation& capabilities() { return this->_body.capability;}
|
||||
|
||||
/**
|
||||
* \brief Getter for the status code.
|
||||
*
|
||||
* \return The status code in an uint16_t.
|
||||
*/
|
||||
inline uint16_t status_code() const { return this->_body.status_code; }
|
||||
|
||||
/**
|
||||
* \brief Getter for the AID field.
|
||||
*
|
||||
* \return The AID field value in an uint16_t.
|
||||
*/
|
||||
inline uint16_t aid() const { return this->_body.aid; }
|
||||
|
||||
/**
|
||||
* \brief Setter for the status code.
|
||||
*
|
||||
* \param new_status_code uint16_t with the new status code.
|
||||
*/
|
||||
void status_code(uint16_t new_status_code);
|
||||
|
||||
/**
|
||||
* \brief Setter for the AID field.
|
||||
*
|
||||
* \param new_aid uint16_t with the new AID value.
|
||||
*/
|
||||
void aid(uint16_t new_aid);
|
||||
|
||||
/**
|
||||
* \brief Helper method to set the supported rates.
|
||||
*
|
||||
* \param new_rates A list of rates to be set.
|
||||
*/
|
||||
void supported_rates(const std::list<float> &new_rates);
|
||||
|
||||
/**
|
||||
* \brief Helper method to set the extended supported rates.
|
||||
*
|
||||
* \param new_rates A list of rates to be set.
|
||||
*/
|
||||
void extended_supported_rates(const std::list<float> &new_rates);
|
||||
|
||||
/**
|
||||
* \brief Helper method to set the EDCA Parameter Set.
|
||||
*
|
||||
* \param ac_be uint32_t with the value of the ac_be field.
|
||||
* \param ac_bk uint32_t with the value of the ac_bk field.
|
||||
* \param ac_vi uint32_t with the value of the ac_vi field.
|
||||
* \param ac_vo uint32_t with the value of the ac_vo field.
|
||||
*/
|
||||
void edca_parameter_set(uint32_t ac_be, uint32_t ac_bk, uint32_t ac_vi, uint32_t ac_vo);
|
||||
|
||||
/**
|
||||
* \brief Returns the frame's header length.
|
||||
*
|
||||
* \return An uint32_t with the header's size.
|
||||
* \sa PDU::header_size()
|
||||
*/
|
||||
uint32_t header_size() const;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
struct ReAssocRespBody {
|
||||
CapabilityInformation capability;
|
||||
uint16_t status_code;
|
||||
uint16_t aid;
|
||||
};
|
||||
|
||||
void copy_fields(const Dot11ReAssocResponse *other);
|
||||
uint32_t write_fixed_parameters(uint8_t *buffer, uint32_t total_sz);
|
||||
|
||||
ReAssocRespBody _body;
|
||||
|
||||
};
|
||||
|
||||
class Dot11QoSData : public Dot11DataFrame {
|
||||
|
||||
public:
|
||||
|
||||
@@ -976,6 +976,77 @@ uint32_t Tins::Dot11ReAssocRequest::write_fixed_parameters(uint8_t *buffer, uint
|
||||
return sz;
|
||||
}
|
||||
|
||||
/* ReAssociation Response */
|
||||
|
||||
Tins::Dot11ReAssocResponse::Dot11ReAssocResponse() : Dot11ManagementFrame() {
|
||||
this->subtype(Dot11::REASSOC_RESP);
|
||||
memset(&_body, 0, sizeof(_body));
|
||||
}
|
||||
|
||||
Tins::Dot11ReAssocResponse::Dot11ReAssocResponse(const std::string& iface,
|
||||
const uint8_t* dst_hw_addr,
|
||||
const uint8_t* src_hw_addr) throw (std::runtime_error) : Dot11ManagementFrame(iface, dst_hw_addr, src_hw_addr) {
|
||||
this->subtype(Dot11::REASSOC_RESP);
|
||||
memset(&_body, 0, sizeof(_body));
|
||||
}
|
||||
|
||||
Tins::Dot11ReAssocResponse::Dot11ReAssocResponse(const uint8_t *buffer, uint32_t total_sz) : Dot11ManagementFrame(buffer, total_sz) {
|
||||
uint32_t sz = Dot11ManagementFrame::header_size();
|
||||
buffer += sz;
|
||||
total_sz -= sz;
|
||||
if(total_sz < sizeof(_body))
|
||||
throw std::runtime_error("Not enough size for an IEEE 802.11 reassociation response header in the buffer.");
|
||||
memcpy(&_body, buffer, sizeof(_body));
|
||||
buffer += sizeof(_body);
|
||||
total_sz -= sizeof(_body);
|
||||
parse_tagged_parameters(buffer, total_sz);
|
||||
}
|
||||
|
||||
Tins::Dot11ReAssocResponse::Dot11ReAssocResponse(const Dot11ReAssocResponse &other) : Dot11ManagementFrame(other) {
|
||||
copy_fields(&other);
|
||||
}
|
||||
|
||||
Tins::Dot11ReAssocResponse &Tins::Dot11ReAssocResponse::operator= (const Dot11ReAssocResponse &other) {
|
||||
copy_inner_pdu(other);
|
||||
copy_fields(&other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Tins::Dot11ReAssocResponse::copy_fields(const Dot11ReAssocResponse *other) {
|
||||
Dot11ManagementFrame::copy_ext_header(other);
|
||||
std::memcpy(&_body, &other->_body, sizeof(_body));
|
||||
}
|
||||
|
||||
void Tins::Dot11ReAssocResponse::status_code(uint16_t new_status_code) {
|
||||
this->_body.status_code = new_status_code;
|
||||
}
|
||||
|
||||
void Tins::Dot11ReAssocResponse::aid(uint16_t new_aid) {
|
||||
this->_body.aid = new_aid;
|
||||
}
|
||||
|
||||
void Tins::Dot11ReAssocResponse::supported_rates(const std::list<float> &new_rates) {
|
||||
Dot11ManagementFrame::supported_rates(new_rates);
|
||||
}
|
||||
|
||||
void Tins::Dot11ReAssocResponse::extended_supported_rates(const std::list<float> &new_rates) {
|
||||
Dot11ManagementFrame::extended_supported_rates(new_rates);
|
||||
}
|
||||
|
||||
void Tins::Dot11ReAssocResponse::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::Dot11ReAssocResponse::header_size() const {
|
||||
return Dot11ManagementFrame::header_size() + sizeof(this->_body);
|
||||
}
|
||||
|
||||
uint32_t Tins::Dot11ReAssocResponse::write_fixed_parameters(uint8_t *buffer, uint32_t total_sz) {
|
||||
uint32_t sz = sizeof(this->_body);
|
||||
assert(sz <= total_sz);
|
||||
memcpy(buffer, &this->_body, sz);
|
||||
return sz;
|
||||
}
|
||||
|
||||
/* QoS data. */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user