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

Implemented ProbeResponse. Still unfinished

This commit is contained in:
Santiago Alessandri
2011-09-08 10:42:50 -03:00
parent 418b753a3b
commit 1c40470418
2 changed files with 857 additions and 374 deletions

View File

@@ -1013,32 +1013,197 @@ namespace Tins {
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);
Dot11ManagementFrame(const Dot11ManagementFrame& other);
/**
* \brief Helper method to set the ssid.
*
* \param new_ssid The ssid to be set.
*/
void ssid(const std::string &new_ssid);
void rates(const std::list<float> &new_rates);
void channel(uint8_t new_channel);
/**
* \brief Helper method to set the RSN information option.
*
* \param info The RSNInformation structure to be set.
*/
void rsn_information(const RSNInformation& info);
/**
* \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 QoS capabilities.
*
* \param new_qos_capabilities uint8_t with the capabilities.
*/
void qos_capabilities(uint8_t new_qos_capabilities);
/**
* \brief Helper method to set the power capabilities.
*
* \param min_power uint8_t indicating the minimum transmiting power capability.
* \param max_power uint8_t indicating the maximum transmiting power capability.
*/
void power_capabilities(uint8_t min_power, uint8_t max_power);
/**
* \brief Helper method to set the supported channels.
*
* \param new_channels A list of channels to be set.
*/
void supported_channels(const std::list<std::pair<uint8_t, uint8_t> > &new_channels);
/**
* \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 Helper method to set the Request Information element.
*
* \param elements A list of elements.
*/
void request_information(const std::list<uint8_t> elements);
/**
* \brief Helper method to set the FH parameter.
*
* \param dwell_time uint16_t with the dwell_time value.
* \param hop_set uint8_t with the value of the set_hop.
* \param hop_pattern uint8_t with the value of the hop_pattern field.
* \param hop_index uint8_t with the value of the hop_index field.
*/
void fh_parameter_set(uint16_t dwell_time, uint8_t hop_set, uint8_t hop_pattern, uint8_t hop_index);
/**
* \brief Helper method to set the DS parameter.
*
* \param current_channel uint8_t with the value of the current_channel field.
*/
void ds_parameter_set(uint8_t current_channel);
/**
* \brief Helper method to set the CF parameter.
*
* \param cfp_count uint8_t with the value of the cfp count field.
* \param cfp_period uint8_t with the value of the cfp period field.
* \param cfp_max_duration uint16_t with the value of the cfp max duration field.
* \param cfp_dur_remaining uint16_t with the value of the DurRemaining field.
*/
void cf_parameter_set(uint8_t cfp_count, uint8_t cfp_period, uint16_t cfp_max_duration, uint16_t cfp_dur_remaining);
/**
* \brief Helper method to set the IBSS parameter.
*
* \param atim_window uint16_t with the value of the ATIM window field.
*/
void ibss_parameter_set(uint16_t atim_window);
/**
* \brief Helper method to set the IBSS DFS tagged option.
*
* \param dfs_owner uint8_t array of 6 bytes with the dfs owner.
* \param recovery_interval uint8_t with the value of the recovery interval field.
* \param channel_map Reference to a constant vector of pair of uint8_t with the map of channels.
*/
void ibss_dfs(const uint8_t* dfs_owner, uint8_t recovery_interval, const std::vector<std::pair<uint8_t, uint8_t> >& channel_map);
/**
* \brief Helper method to set the country tagged option.
*
* \param countries Reference to a vector of uint8_t arrays of 3 bytes. Containing the list of countries.
* \param first_channels Reference to a vector of uint8_t. Containing the first channels for each country.
* \param num_channels Reference to a vector of uint8_t. Containing the number of channels for each country.
* \param max_power Reference to a vector of uint8_t. Containing the max power for each country.
*/
void country(const std::vector<uint8_t*>& countries, const std::vector<uint8_t>& first_channels, const std::vector<uint8_t>& number_channels, const std::vector<uint8_t>& max_power);
/**
* \brief Helper method to set the FH parameters.
*
* \param prime_radix uint8_t with the value of the prime radix field.
* \param number_channels uint8_t with the value of the number channels field.
*/
void fh_parameters(uint8_t prime_radix, uint8_t number_channels);
/**
* \brief Helper method to set the FH pattern table.
*
* \param flag uint8_t with the value of the flag field.
* \param number_of_sets uint8_t with the value of the number of sets field.
* \param modulus uint8_t with the value of the modulus field.
* \param offset uint8_t with the value of the offset field.
* \param random_table reference to vector of uint8_t witht the elements of the table.
*/
void fh_pattern_table(uint8_t flag, uint8_t number_of_sets, uint8_t modulus, uint8_t offset, const std::vector<uint8_t>& random_table);
/**
* \brief Helper method to set the Power Constraint tagged option.
*
* \param local_power_constraint uint8_t with the value of the local power constraint field.
*/
void power_constraint(uint8_t local_power_constraint);
/**
* \brief Helper method to set the Channel Switch tagged option.
*
* \param switch_mode uint8_t with the value of the switch mode field.
* \param new_channel uint8_t with the value of the new channel field.
* \param switch_count uint8_t with the value of the switch count field.
*/
void channel_switch(uint8_t switch_mode, uint8_t new_channel, uint8_t switch_count);
/**
* \brief Helper method to set the Quiet tagged option.
*
* \param quiet_count uint8_t with the value of the quiet count field.
* \param quiet_period uint8_t with the value of the quiet period field.
* \param quiet_duration uint16_t with the value of the quiet duration field.
* \param quiet_offset uint16_t with the value of the quiet offset field.
*/
void quiet(uint8_t quiet_count, uint8_t quiet_period, uint16_t quiet_duration, uint16_t quiet_offset);
/**
* \brief Helper method to set the TPC Report tagged option.
*
* \param transmit_power uint8_t with the value of the transmit power field.
* \param link_margin uint8_t with the value of the link margin field.
*/
void tpc_report(uint8_t transmit_power, uint8_t link_margin);
/**
* \brief Helper method to set the ERP Information tagged option.
*
* \param value with the value to set as argument of the tagged option.
*/
void erp_information(uint8_t value);
/**
* \brief Helper method to set the BSS Load tagged option.
*
* \param station_count uint16_t with the value of the station count field.
* \param channel_utilization uint8_t with the value of the channel utilization field.
* \param available_capacity uint16_t with the value of the available capacity field.
*/
void bss_load(uint16_t station_count, uint8_t channel_utilization, uint16_t avaliable_capacity);
uint32_t write_ext_header(uint8_t *buffer, uint32_t total_sz);
void copy_ext_header(const Dot11ManagementFrame *other);
@@ -1085,16 +1250,6 @@ namespace Tins {
*/
Dot11Beacon(const uint8_t *buffer, uint32_t total_sz);
/**
* \brief Copy constructor.
*/
Dot11Beacon(const Dot11Beacon &other);
/**
* \brief Copy assignment operator.
*/
Dot11Beacon &operator= (const Dot11Beacon &other);
/**
* \brief Getter for the timestamp field.
*
@@ -1107,7 +1262,7 @@ namespace Tins {
*
* \return Timestamp value in an uint16_t.
*/
inline uint16_t interval() const { return Utils::net_to_host_s(this->_body.interval); }
inline uint16_t interval() const { return this->_body.interval; }
/**
* \brief Getter for the Capabilities Information.
@@ -1147,16 +1302,45 @@ namespace Tins {
* \brief Helper method to set the supported rates.
* \param new_rates A list of rates to be set.
*/
void rates(const std::list<float> &new_rates);
void supported_rates(const std::list<float> &new_rates);
/**
* \brief Helper method to set the current channel.
* \param new_channel The new channel to be set.
* \brief Helper method to set the FH parameter.
*
* \param dwell_time uint16_t with the dwell_time value.
* \param hop_set uint8_t with the value of the set_hop.
* \param hop_pattern uint8_t with the value of the hop_pattern field.
* \param hop_index uint8_t with the value of the hop_index field.
*/
void channel(uint8_t new_channel);
void fh_parameter_set(uint16_t dwell_time, uint8_t hop_set, uint8_t hop_pattern, uint8_t hop_index);
/**
* \brief Helper method to set the DS parameter.
*
* \param current_channel uint8_t with the value of the current_channel field.
*/
void ds_parameter_set(uint8_t current_channel);
/**
* \brief Helper method to set the CF parameter.
*
* \param cfp_count uint8_t with the value of the cfp count field.
* \param cfp_period uint8_t with the value of the cfp period field.
* \param cfp_max_duration uint16_t with the value of the cfp max duration field.
* \param cfp_dur_remaining uint16_t with the value of the DurRemaining field.
*/
void cf_parameter_set(uint8_t cfp_count, uint8_t cfp_period, uint16_t cfp_max_duration, uint16_t cfp_dur_remaining);
/**
* \brief Helper method to set the IBSS parameter.
*
* \param atim_window uint16_t with the value of the ATIM window field.
*/
void ibss_parameter_set(uint16_t atim_window);
/**
* \brief Helper method to set the RSN information option.
*
* \param info The RSNInformation structure to be set.
*/
void rsn_information(const RSNInformation& info);
@@ -1205,7 +1389,6 @@ namespace Tins {
CapabilityInformation capability;
} __attribute__((__packed__));
void copy_fields(const Dot11Beacon *other);
uint32_t write_fixed_parameters(uint8_t *buffer, uint32_t total_sz);
BeaconBody _body;
@@ -1222,8 +1405,10 @@ namespace Tins {
/**
* \brief Default constructor for the Disassociation frame.
*
* \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).
*/
Dot11Disassoc();
Dot11Disassoc(const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0);
/**
* \brief Constructor for creating a 802.11 Disassociation.
@@ -1238,14 +1423,13 @@ namespace Tins {
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.
* \brief Constructor which creates a Dot11Disassoc 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.
*/
Dot11Disassoc(const Dot11Disassoc &other);
/**
* \brief Copy assignment operator.
*/
Dot11Disassoc &operator= (const Dot11Disassoc &other);
Dot11Disassoc(const uint8_t *buffer, uint32_t total_sz);
/**
* \brief Getter for the reason code.
@@ -1280,10 +1464,8 @@ namespace Tins {
uint16_t reason_code;
};
void copy_fields(const Dot11Disassoc *other);
uint32_t write_fixed_parameters(uint8_t *buffer, uint32_t total_sz);
DisassocBody _body;
};
@@ -1298,8 +1480,10 @@ namespace Tins {
/**
* \brief Default constructor for the Association Request frame.
*
* \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).
*/
Dot11AssocRequest();
Dot11AssocRequest(const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0);
/**
* \brief Constructor for creating a 802.11 Association Request.
@@ -1322,16 +1506,6 @@ namespace Tins {
*/
Dot11AssocRequest(const uint8_t *buffer, uint32_t total_sz);
/**
* \brief Copy constructor.
*/
Dot11AssocRequest(const Dot11AssocRequest &other);
/**
* \brief Copy assignment operator.
*/
Dot11AssocRequest &operator= (const Dot11AssocRequest &other);
/**
* \brief Getter for the Capabilities Information.
*
@@ -1430,7 +1604,6 @@ namespace Tins {
uint16_t listen_interval;
};
void copy_fields(const Dot11AssocRequest *other);
uint32_t write_fixed_parameters(uint8_t *buffer, uint32_t total_sz);
AssocReqBody _body;
@@ -1447,8 +1620,10 @@ namespace Tins {
/**
* \brief Default constructor for the Association Response frame.
*
* \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).
*/
Dot11AssocResponse();
Dot11AssocResponse(const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0);
/**
* \brief Constructor for creating a 802.11 Association Response.
@@ -1471,16 +1646,6 @@ namespace Tins {
*/
Dot11AssocResponse(const uint8_t *buffer, uint32_t total_sz);
/**
* \brief Copy constructor.
*/
Dot11AssocResponse(const Dot11AssocResponse &other);
/**
* \brief Copy assignment operator
*/
Dot11AssocResponse &operator= (const Dot11AssocResponse &other);
/**
* \brief Getter for the Capabilities Information.
*
@@ -1568,12 +1733,352 @@ namespace Tins {
uint16_t aid;
};
void copy_fields(const Dot11AssocResponse *other);
uint32_t write_fixed_parameters(uint8_t *buffer, uint32_t total_sz);
AssocRespBody _body;
};
/**
* \brief Class representing an Probe Request frame in the IEEE 802.11 Protocol.
*
*/
class Dot11ProbeRequest : public Dot11ManagementFrame {
public:
/**
* \brief Default constructor for the Probe Request frame.
*
* \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).
*/
Dot11ProbeRequest(const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0);
/**
* \brief Constructor for creating a 802.11 Probe Request.
*
* Constructor that builds a 802.11 Probe Request 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).
*/
Dot11ProbeRequest(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 Dot11ProbeRequest 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.
*/
Dot11ProbeRequest(const uint8_t *buffer, uint32_t total_sz);
/**
* \brief Helper method to set the essid.
*
* \param new_ssid The ssid to be set.
*/
void ssid(const std::string &new_ssid);
/**
* \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 Request Information element.
*
* \param elements A list of elements.
*/
void request_information(const std::list<uint8_t> elements);
/**
* \brief Clones this PDU.
*
* \sa PDU::clone_pdu()
*/
PDU* clone_pdu() const;
};
/**
* \brief Class representing an Probe Response frame in the IEEE 802.11 Protocol.
*
*/
class Dot11ProbeResponse : public Dot11ManagementFrame {
public:
/**
* \brief Default constructor for the Probe Response frame.
*
* \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).
*/
Dot11ProbeResponse(const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0);
/**
* \brief Constructor for creating a 802.11 Probe Response.
*
* Constructor that builds a 802.11 Probe 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).
*/
Dot11ProbeResponse(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 Dot11ProbeResponse 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.
*/
Dot11ProbeResponse(const uint8_t *buffer, uint32_t total_sz);
/**
* \brief Getter for the timestamp field.
*
* \return Timestamp value in an uint64_t.
*/
inline uint64_t timestamp() const { return this->_body.timestamp; }
/**
* \brief Getter for the interval field.
*
* \return Timestamp value in an uint16_t.
*/
inline uint16_t interval() const { return this->_body.interval; }
/**
* \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 Setter for the timestamp field.
*
* \param new_timestamp uint64_t with the timestamp to set.
*/
void timestamp(uint64_t new_timestamp);
/**
* \brief Setter for the interval field.
*
* \param new_interval uint16_t with the interval to set.
*/
void interval(uint16_t new_interval);
/**
* \brief Helper method to set the ssid.
*
* \param new_ssid The ssid to be set.
*/
void ssid(const std::string &new_ssid);
/**
* \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 FH parameter.
*
* \param dwell_time uint16_t with the dwell_time value.
* \param hop_set uint8_t with the value of the set_hop.
* \param hop_pattern uint8_t with the value of the hop_pattern field.
* \param hop_index uint8_t with the value of the hop_index field.
*/
void fh_parameter_set(uint16_t dwell_time, uint8_t hop_set, uint8_t hop_pattern, uint8_t hop_index);
/**
* \brief Helper method to set the DS parameter.
*
* \param current_channel uint8_t with the value of the current_channel field.
*/
void ds_parameter_set(uint8_t current_channel);
/**
* \brief Helper method to set the CF parameter.
*
* \param cfp_count uint8_t with the value of the cfp count field.
* \param cfp_period uint8_t with the value of the cfp period field.
* \param cfp_max_duration uint16_t with the value of the cfp max duration field.
* \param cfp_dur_remaining uint16_t with the value of the DurRemaining field.
*/
void cf_parameter_set(uint8_t cfp_count, uint8_t cfp_period, uint16_t cfp_max_duration, uint16_t cfp_dur_remaining);
/**
* \brief Helper method to set the IBSS parameter.
*
* \param atim_window uint16_t with the value of the ATIM window field.
*/
void ibss_parameter_set(uint16_t atim_window);
/**
* \brief Helper method to set the country tagged option.
*
* \param countries Reference to a vector of uint8_t arrays of 3 bytes. Containing the list of countries.
* \param first_channels Reference to a vector of uint8_t. Containing the first channels for each country.
* \param num_channels Reference to a vector of uint8_t. Containing the number of channels for each country.
* \param max_power Reference to a vector of uint8_t. Containing the max power for each country.
*/
void country(const std::vector<uint8_t*>& countries, const std::vector<uint8_t>& first_channels, const std::vector<uint8_t>& number_channels, const std::vector<uint8_t>& max_power);
/**
* \brief Helper method to set the FH parameters.
*
* \param prime_radix uint8_t with the value of the prime radix field.
* \param number_channels uint8_t with the value of the number channels field.
*/
void fh_parameters(uint8_t prime_radix, uint8_t number_channels);
/**
* \brief Helper method to set the FH pattern table.
*
* \param flag uint8_t with the value of the flag field.
* \param number_of_sets uint8_t with the value of the number of sets field.
* \param modulus uint8_t with the value of the modulus field.
* \param offset uint8_t with the value of the offset field.
* \param random_table reference to vector of uint8_t witht the elements of the table.
*/
void fh_pattern_table(uint8_t flag, uint8_t number_of_sets, uint8_t modulus, uint8_t offset, const std::vector<uint8_t>& random_table);
/**
* \brief Helper method to set the Power Constraint tagged option.
*
* \param local_power_constraint uint8_t with the value of the local power constraint field.
*/
void power_constraint(uint8_t local_power_constraint);
/**
* \brief Helper method to set the Channel Switch tagged option.
*
* \param switch_mode uint8_t with the value of the switch mode field.
* \param new_channel uint8_t with the value of the new channel field.
* \param switch_count uint8_t with the value of the switch count field.
*/
void channel_switch(uint8_t switch_mode, uint8_t new_channel, uint8_t switch_count);
/**
* \brief Helper method to set the Quiet tagged option.
*
* \param quiet_count uint8_t with the value of the quiet count field.
* \param quiet_period uint8_t with the value of the quiet period field.
* \param quiet_duration uint16_t with the value of the quiet duration field.
* \param quiet_offset uint16_t with the value of the quiet offset field.
*/
void quiet(uint8_t quiet_count, uint8_t quiet_period, uint16_t quiet_duration, uint16_t quiet_offset);
/**
* \brief Helper method to set the IBSS DFS tagged option.
*
* \param dfs_owner uint8_t array of 6 bytes with the dfs owner.
* \param recovery_interval uint8_t with the value of the recovery interval field.
* \param channel_map Reference to a constant vector of pair of uint8_t with the map of channels.
*/
void ibss_dfs(const uint8_t* dfs_owner, uint8_t recovery_interval, const std::vector<std::pair<uint8_t, uint8_t> >& channel_map);
/**
* \brief Helper method to set the TPC Report tagged option.
*
* \param transmit_power uint8_t with the value of the transmit power field.
* \param link_margin uint8_t with the value of the link margin field.
*/
void tpc_report(uint8_t transmit_power, uint8_t link_margin);
/**
* \brief Helper method to set the ERP Information tagged option.
*
* \param value with the value to set as argument of the tagged option.
*/
void erp_information(uint8_t value);
/**
* \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 RSN information option.
*
* \param info The RSNInformation structure to be set.
*/
void rsn_information(const RSNInformation& info);
/**
* \brief Helper method to set the BSS Load tagged option.
*
* \param station_count uint16_t with the value of the station count field.
* \param channel_utilization uint8_t with the value of the channel utilization field.
* \param available_capacity uint16_t with the value of the available capacity field.
*/
void bss_load(uint16_t station_count, uint8_t channel_utilization, uint16_t avaliable_capacity);
/**
* \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;
/**
* \brief Clones this PDU.
*
* \sa PDU::clone_pdu()
*/
PDU* clone_pdu() const;
protected:
private:
struct ProbeResp {
uint64_t timestamp;
uint16_t interval;
CapabilityInformation capability;
};
ProbeResp _body;
};
class Dot11Data : public Dot11 {
public:
/**
@@ -1699,141 +2204,6 @@ namespace Tins {
uint8_t _addr4[6];
};
/**
* \brief Class representing an Probe Request frame in the IEEE 802.11 Protocol.
*
*/
class Dot11ProbeRequest : public Dot11ManagementFrame {
public:
/**
* \brief Default constructor for the Probe Request frame.
*
*/
Dot11ProbeRequest();
/**
* \brief Constructor for creating a 802.11 Probe Request.
*
* Constructor that builds a 802.11 Probe Request 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).
*/
Dot11ProbeRequest(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 Dot11ProbeRequest 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.
*/
Dot11ProbeRequest(const uint8_t *buffer, uint32_t total_sz);
/**
* \brief Helper method to set the essid.
*
* \param new_ssid The ssid to be set.
*/
void ssid(const std::string &new_ssid);
/**
* \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 Request Information element.
*
* \param elements A list of elements.
*/
void request_information(const std::list<uint8_t> elements);
/**
* \brief Clones this PDU.
*
* \sa PDU::clone_pdu()
*/
PDU* clone_pdu() const;
};
/**
* \brief Class representing an Probe Response frame in the IEEE 802.11 Protocol.
*
*/
class Dot11ProbeResponse : public Dot11ManagementFrame {
public:
/**
* \brief Getter for the timestamp field.
*
* \return Timestamp value in an uint64_t.
*/
inline uint64_t timestamp() const { return this->_body.timestamp; }
/**
* \brief Getter for the interval field.
*
* \return Timestamp value in an uint16_t.
*/
inline uint16_t interval() const { return Utils::net_to_host_s(this->_body.interval); }
/**
* \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 Setter for the timestamp field.
*
* \param new_timestamp uint64_t with the timestamp to set.
*/
void timestamp(uint64_t new_timestamp);
/**
* \brief Setter for the interval field.
*
* \param new_interval uint16_t with the interval to set.
*/
void interval(uint16_t new_interval);
protected:
private:
struct ProbeResp {
uint64_t timestamp;
uint16_t interval;
CapabilityInformation capability;
};
ProbeResp _body;
};
class Dot11QoSData : public Dot11Data {
public:

View File

@@ -354,22 +354,6 @@ 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::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;
if(*it - left > 0)
left++;
*(ptr++) = (result | left);
}
add_tagged_option(SUPPORTED_RATES, new_rates.size(), buffer);
delete[] buffer;
}
void Tins::Dot11ManagementFrame::channel(uint8_t new_channel) {
add_tagged_option(DS_SET, 1, &new_channel);
}
void Tins::Dot11ManagementFrame::rsn_information(const RSNInformation& info) {
uint32_t size;
uint8_t *buffer = info.serialize(size);
@@ -592,6 +576,21 @@ void Tins::Dot11ManagementFrame::tpc_report(uint8_t transmit_power, uint8_t link
}
void Tins::Dot11ManagementFrame::erp_information(uint8_t value) {
add_tagged_option(ERP_INFORMATION, 1, &value);
}
void Tins::Dot11ManagementFrame::bss_load(uint16_t station_count, uint8_t channel_utilization, uint16_t available_capacity) {
uint8_t buffer[5];
buffer[0] = station_count & 0xFF;
buffer[1] = station_count >> 8;
buffer[2] = channel_utilization;
buffer[3] = available_capacity & 0xFF;
buffer[4] = available_capacity >> 8;
add_tagged_option(BSS_LOAD, 5, buffer);
}
/* Dot11Beacon */
Tins::Dot11Beacon::Dot11Beacon(const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr) : Dot11ManagementFrame() {
@@ -618,45 +617,48 @@ Tins::Dot11Beacon::Dot11Beacon(const uint8_t *buffer, uint32_t total_sz) : Dot11
parse_tagged_parameters(buffer, total_sz);
}
Tins::Dot11Beacon::Dot11Beacon(const Dot11Beacon &other) : Dot11ManagementFrame(other) {
copy_fields(&other);
}
Tins::Dot11Beacon &Tins::Dot11Beacon::operator= (const Dot11Beacon &other) {
copy_fields(&other);
copy_inner_pdu(other);
return *this;
}
void Tins::Dot11Beacon::copy_fields(const Dot11Beacon *other) {
Dot11ManagementFrame::copy_ext_header(other);
std::memcpy(&_body, &other->_body, sizeof(_body));
}
void Tins::Dot11Beacon::timestamp(uint64_t new_timestamp) {
this->_body.timestamp = new_timestamp;
}
void Tins::Dot11Beacon::interval(uint16_t new_interval) {
this->_body.interval = Utils::net_to_host_s(new_interval);
this->_body.interval = new_interval;
}
void Tins::Dot11Beacon::essid(const std::string &new_essid) {
Dot11ManagementFrame::ssid(new_essid);
}
void Tins::Dot11Beacon::rates(const std::list<float> &new_rates) {
Dot11ManagementFrame::rates(new_rates);
void Tins::Dot11Beacon::supported_rates(const std::list<float> &new_rates) {
Dot11ManagementFrame::supported_rates(new_rates);
}
void Tins::Dot11Beacon::channel(uint8_t new_channel) {
Dot11ManagementFrame::channel(new_channel);
void Tins::Dot11Beacon::ds_parameter_set(uint8_t current_channel) {
Dot11ManagementFrame::ds_parameter_set(current_channel);
}
void Tins::Dot11Beacon::rsn_information(const RSNInformation& info) {
Dot11ManagementFrame::rsn_information(info);
}
void Tins::Dot11Beacon::fh_parameter_set(uint16_t dwell_time,
uint8_t hop_set,
uint8_t hop_pattern,
uint8_t hop_index) {
Dot11ManagementFrame::fh_parameter_set(dwell_time, hop_set, hop_pattern, hop_index);
}
void Tins::Dot11Beacon::cf_parameter_set(uint8_t cfp_count,
uint8_t cfp_period,
uint16_t cfp_max_duration,
uint16_t cfp_dur_remaining) {
Dot11ManagementFrame::cf_parameter_set(cfp_count, cfp_period, cfp_max_duration, cfp_dur_remaining);
}
void Tins::Dot11Beacon::ibss_parameter_set(uint16_t atim_window) {
Dot11ManagementFrame::ibss_parameter_set(atim_window);
}
string Tins::Dot11Beacon::essid() const {
const Dot11::Dot11_Option *option = lookup_option(SSID);
return (option) ? string((const char*)option->value, option->length) : 0;
@@ -717,12 +719,14 @@ uint32_t Tins::Dot11Beacon::write_fixed_parameters(uint8_t *buffer, uint32_t tot
Tins::PDU *Tins::Dot11Beacon::clone_pdu() const {
Dot11Beacon *new_pdu = new Dot11Beacon();
new_pdu->copy_80211_fields(this);
new_pdu->copy_ext_header(this);
std::memcpy(&new_pdu->_body, &_body, sizeof(_body));
return new_pdu;
}
/* 802.11 diassoc */
/* Diassoc */
Tins::Dot11Disassoc::Dot11Disassoc() : Dot11ManagementFrame() {
Tins::Dot11Disassoc::Dot11Disassoc(const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr) : Dot11ManagementFrame(dst_hw_addr, src_hw_addr) {
this->subtype(Dot11::DISASSOC);
memset(&_body, 0, sizeof(_body));
}
@@ -734,19 +738,16 @@ Tins::Dot11Disassoc::Dot11Disassoc(const std::string& iface,
memset(&_body, 0, sizeof(_body));
}
Tins::Dot11Disassoc::Dot11Disassoc(const Dot11Disassoc &other) : Dot11ManagementFrame(other) {
copy_fields(&other);
}
Tins::Dot11Disassoc &Tins::Dot11Disassoc::operator= (const Dot11Disassoc &other) {
copy_inner_pdu(other);
copy_fields(&other);
return *this;
}
void Tins::Dot11Disassoc::copy_fields(const Dot11Disassoc *other) {
Dot11ManagementFrame::copy_ext_header(other);
std::memcpy(&_body, &other->_body, sizeof(_body));
Tins::Dot11Disassoc::Dot11Disassoc(const uint8_t *buffer, uint32_t 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 a IEEE 802.11 disassociation header in the buffer.");
memcpy(&_body, buffer, sizeof(_body));
buffer += sizeof(_body);
total_sz -= sizeof(_body);
parse_tagged_parameters(buffer, total_sz);
}
void Tins::Dot11Disassoc::reason_code(uint16_t new_reason_code) {
@@ -767,72 +768,14 @@ uint32_t Tins::Dot11Disassoc::write_fixed_parameters(uint8_t *buffer, uint32_t t
Tins::PDU *Tins::Dot11Disassoc::clone_pdu() const {
Dot11Disassoc *new_pdu = new Dot11Disassoc();
new_pdu->copy_80211_fields(this);
new_pdu->copy_ext_header(this);
memcpy(&new_pdu->_body, &this->_body, sizeof(this->_body));
return new_pdu;
}
/* RSNInformation */
Tins::RSNInformation::RSNInformation() : _version(1), _capabilities(0) {
}
void Tins::RSNInformation::add_pairwise_cypher(CypherSuites cypher) {
_pairwise_cyphers.push_back(cypher);
}
void Tins::RSNInformation::add_akm_cypher(AKMSuites akm) {
_akm_cyphers.push_back(akm);
}
void Tins::RSNInformation::group_suite(CypherSuites group) {
_group_suite = group;
}
void Tins::RSNInformation::version(uint16_t ver) {
_version = ver;
}
void Tins::RSNInformation::capabilities(uint16_t cap) {
_capabilities = cap;
}
uint8_t *Tins::RSNInformation::serialize(uint32_t &size) const {
size = sizeof(_version) + sizeof(_capabilities) + sizeof(uint32_t);
size += (sizeof(uint16_t) << 1); // 2 lists count.
size += sizeof(uint32_t) * (_akm_cyphers.size() + _pairwise_cyphers.size());
uint8_t *buffer = new uint8_t[size], *ptr = buffer;
*(uint16_t*)ptr = _version;
ptr += sizeof(_version);
*(uint32_t*)ptr = _group_suite;
ptr += sizeof(uint32_t);
*(uint16_t*)ptr = _pairwise_cyphers.size();
ptr += sizeof(uint16_t);
for(std::list<CypherSuites>::const_iterator it = _pairwise_cyphers.begin(); it != _pairwise_cyphers.end(); ++it) {
*(uint32_t*)ptr = *it;
ptr += sizeof(uint32_t);
}
*(uint16_t*)ptr = _akm_cyphers.size();
ptr += sizeof(uint16_t);
for(std::list<AKMSuites>::const_iterator it = _akm_cyphers.begin(); it != _akm_cyphers.end(); ++it) {
*(uint32_t*)ptr = *it;
ptr += sizeof(uint32_t);
}
*(uint16_t*)ptr = _capabilities;
return buffer;
}
Tins::RSNInformation Tins::RSNInformation::wpa2_psk() {
RSNInformation info;
info.group_suite(RSNInformation::CCMP);
info.add_pairwise_cypher(RSNInformation::CCMP);
info.add_akm_cypher(RSNInformation::PSK);
return info;
}
/* Assoc request. */
Tins::Dot11AssocRequest::Dot11AssocRequest() : Dot11ManagementFrame() {
Tins::Dot11AssocRequest::Dot11AssocRequest(const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr) : Dot11ManagementFrame(dst_hw_addr, src_hw_addr) {
this->subtype(Dot11::ASSOC_REQ);
memset(&_body, 0, sizeof(_body));
}
@@ -849,28 +792,13 @@ Tins::Dot11AssocRequest::Dot11AssocRequest(const uint8_t *buffer, uint32_t total
buffer += sz;
total_sz -= sz;
if(total_sz < sizeof(_body))
throw std::runtime_error("Not enough size for an IEEE 802.11 association header in the buffer.");
throw std::runtime_error("Not enough size for an IEEE 802.11 association request header in the buffer.");
memcpy(&_body, buffer, sizeof(_body));
buffer += sizeof(_body);
total_sz -= sizeof(_body);
parse_tagged_parameters(buffer, total_sz);
}
Tins::Dot11AssocRequest::Dot11AssocRequest(const Dot11AssocRequest &other) : Dot11ManagementFrame(other) {
copy_fields(&other);
}
Tins::Dot11AssocRequest &Tins::Dot11AssocRequest::operator= (const Dot11AssocRequest &other) {
copy_inner_pdu(other);
copy_fields(&other);
return *this;
}
void Tins::Dot11AssocRequest::copy_fields(const Dot11AssocRequest *other) {
Dot11ManagementFrame::copy_ext_header(other);
std::memcpy(&_body, &other->_body, sizeof(_body));
}
void Tins::Dot11AssocRequest::listen_interval(uint16_t new_listen_interval) {
this->_body.listen_interval = new_listen_interval;
}
@@ -917,12 +845,14 @@ uint32_t Tins::Dot11AssocRequest::write_fixed_parameters(uint8_t *buffer, uint32
Tins::PDU *Tins::Dot11AssocRequest::clone_pdu() const {
Dot11AssocRequest *new_pdu = new Dot11AssocRequest();
new_pdu->copy_80211_fields(this);
new_pdu->copy_ext_header(this);
std::memcpy(&new_pdu->_body, &_body, sizeof(_body));
return new_pdu;
}
/* Assoc response. */
Tins::Dot11AssocResponse::Dot11AssocResponse() : Dot11ManagementFrame() {
Tins::Dot11AssocResponse::Dot11AssocResponse(const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr) : Dot11ManagementFrame(dst_hw_addr, src_hw_addr) {
this->subtype(Dot11::ASSOC_RESP);
memset(&_body, 0, sizeof(_body));
}
@@ -935,8 +865,9 @@ Tins::Dot11AssocResponse::Dot11AssocResponse(const std::string& iface,
}
Tins::Dot11AssocResponse::Dot11AssocResponse(const uint8_t *buffer, uint32_t total_sz) : Dot11ManagementFrame(buffer, total_sz) {
buffer += sizeof(ieee80211_header);
total_sz -= sizeof(ieee80211_header);
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 association response header in the buffer.");
memcpy(&_body, buffer, sizeof(_body));
@@ -945,21 +876,6 @@ Tins::Dot11AssocResponse::Dot11AssocResponse(const uint8_t *buffer, uint32_t tot
parse_tagged_parameters(buffer, total_sz);
}
Tins::Dot11AssocResponse::Dot11AssocResponse(const Dot11AssocResponse &other) : Dot11ManagementFrame(other) {
copy_fields(&other);
}
Tins::Dot11AssocResponse &Tins::Dot11AssocResponse::operator= (const Dot11AssocResponse &other) {
copy_inner_pdu(other);
copy_fields(&other);
return *this;
}
void Tins::Dot11AssocResponse::copy_fields(const Dot11AssocResponse *other) {
Dot11ManagementFrame::copy_ext_header(other);
std::memcpy(&_body, &other->_body, sizeof(_body));
}
void Tins::Dot11AssocResponse::status_code(uint16_t new_status_code) {
this->_body.status_code = new_status_code;
}
@@ -994,6 +910,183 @@ uint32_t Tins::Dot11AssocResponse::write_fixed_parameters(uint8_t *buffer, uint3
Tins::PDU *Tins::Dot11AssocResponse::clone_pdu() const {
Dot11AssocResponse *new_pdu = new Dot11AssocResponse();
new_pdu->copy_80211_fields(this);
new_pdu->copy_ext_header(this);
std::memcpy(&new_pdu->_body, &_body, sizeof(_body));
return new_pdu;
}
/* Probe Request */
Tins::Dot11ProbeRequest::Dot11ProbeRequest(const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr) : Dot11ManagementFrame(dst_hw_addr, src_hw_addr) {
this->subtype(Dot11::PROBE_REQ);
}
Tins::Dot11ProbeRequest::Dot11ProbeRequest(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::PROBE_REQ);
}
Tins::Dot11ProbeRequest::Dot11ProbeRequest(const uint8_t *buffer, uint32_t total_sz) : Dot11ManagementFrame(buffer, total_sz) {
parse_tagged_parameters(buffer, total_sz);
}
void Tins::Dot11ProbeRequest::ssid(const std::string &new_ssid) {
Dot11ManagementFrame::ssid(new_ssid);
}
void Tins::Dot11ProbeRequest::supported_rates(const std::list<float> &new_rates) {
Dot11ManagementFrame::supported_rates(new_rates);
}
void Tins::Dot11ProbeRequest::request_information(const std::list<uint8_t> elements) {
Dot11ManagementFrame::request_information(elements);
}
void Tins::Dot11ProbeRequest::extended_supported_rates(const std::list<float> &new_rates) {
Dot11ManagementFrame::extended_supported_rates(new_rates);
}
Tins::PDU* Tins::Dot11ProbeRequest::clone_pdu() const {
Dot11ProbeRequest* new_pdu = new Dot11ProbeRequest();
new_pdu->copy_80211_fields(this);
new_pdu->copy_ext_header(this);
return new_pdu;
}
/* Probe Response */
Tins::Dot11ProbeResponse::Dot11ProbeResponse(const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr) : Dot11ManagementFrame(dst_hw_addr, src_hw_addr) {
this->subtype(Dot11::PROBE_RESP);
memset(&this->_body, 0, sizeof(this->_body));
}
Tins::Dot11ProbeResponse::Dot11ProbeResponse(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::PROBE_RESP);
memset(&this->_body, 0, sizeof(this->_body));
}
Tins::Dot11ProbeResponse::Dot11ProbeResponse(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 probe response header in the buffer.");
memcpy(&_body, buffer, sizeof(_body));
buffer += sizeof(_body);
total_sz -= sizeof(_body);
parse_tagged_parameters(buffer, total_sz);
}
void Tins::Dot11ProbeResponse::timestamp(uint64_t new_timestamp) {
this->_body.timestamp = new_timestamp;
}
void Tins::Dot11ProbeResponse::interval(uint16_t new_interval) {
this->_body.interval = new_interval;
}
void Tins::Dot11ProbeResponse::ssid(const std::string &new_ssid) {
Dot11ManagementFrame::ssid(new_ssid);
}
void Tins::Dot11ProbeResponse::supported_rates(const std::list<float> &new_rates) {
Dot11ManagementFrame::supported_rates(new_rates);
}
void Tins::Dot11ProbeResponse::fh_parameter_set(uint16_t dwell_time, uint8_t hop_set, uint8_t hop_pattern, uint8_t hop_index) {
Dot11ManagementFrame::fh_parameter_set(dwell_time, hop_set, hop_pattern, hop_index);
}
void Tins::Dot11ProbeResponse::ds_parameter_set(uint8_t current_channel) {
Dot11ManagementFrame::ds_parameter_set(current_channel);
}
void Tins::Dot11ProbeResponse::cf_parameter_set(uint8_t cfp_count, uint8_t cfp_period, uint16_t cfp_max_duration, uint16_t cfp_dur_remaining) {
Dot11ManagementFrame::cf_parameter_set(cfp_count, cfp_period, cfp_max_duration, cfp_dur_remaining);
}
void Tins::Dot11ProbeResponse::ibss_parameter_set(uint16_t atim_window) {
Dot11ManagementFrame::ibss_parameter_set(atim_window);
}
void Tins::Dot11ProbeResponse::country(const std::vector<uint8_t*>& countries,
const std::vector<uint8_t>& first_channels,
const std::vector<uint8_t>& number_channels,
const std::vector<uint8_t>& max_power) {
Dot11ManagementFrame::country(countries, first_channels, number_channels, max_power);
}
void Tins::Dot11ProbeResponse::fh_parameters(uint8_t prime_radix, uint8_t number_channels) {
Dot11ManagementFrame::fh_parameters(prime_radix, number_channels);
}
void Tins::Dot11ProbeResponse::fh_pattern_table(uint8_t flag,
uint8_t number_of_sets,
uint8_t modulus,
uint8_t offset,
const std::vector<uint8_t>& random_table) {
Dot11ManagementFrame::fh_pattern_table(flag, number_of_sets, modulus, offset, random_table);
}
void Tins::Dot11ProbeResponse::power_constraint(uint8_t local_power_constraint) {
Dot11ManagementFrame::power_constraint(local_power_constraint);
}
void Tins::Dot11ProbeResponse::channel_switch(uint8_t switch_mode, uint8_t new_channel, uint8_t switch_count) {
Dot11ManagementFrame::channel_switch(switch_mode, new_channel, switch_count);
}
void Tins::Dot11ProbeResponse::quiet(uint8_t quiet_count, uint8_t quiet_period, uint16_t quiet_duration, uint16_t quiet_offset) {
Dot11ManagementFrame::quiet(quiet_count, quiet_period, quiet_duration, quiet_offset);
}
void Tins::Dot11ProbeResponse::ibss_dfs(const uint8_t* dfs_owner,
uint8_t recovery_interval,
const std::vector<std::pair<uint8_t, uint8_t> >& channel_map) {
Dot11ManagementFrame::ibss_dfs(dfs_owner, recovery_interval, channel_map);
}
void Tins::Dot11ProbeResponse::tpc_report(uint8_t transmit_power, uint8_t link_margin) {
Dot11ManagementFrame::tpc_report(transmit_power, link_margin);
}
void Tins::Dot11ProbeResponse::erp_information(uint8_t value) {
Dot11ManagementFrame::erp_information(value);
}
void Tins::Dot11ProbeResponse::extended_supported_rates(const std::list<float> &new_rates) {
Dot11ManagementFrame::extended_supported_rates(new_rates);
}
void Tins::Dot11ProbeResponse::rsn_information(const RSNInformation& info) {
Dot11ManagementFrame::rsn_information(info);
}
void Tins::Dot11ProbeResponse::bss_load(uint16_t station_count,
uint8_t channel_utilization,
uint16_t available_capacity) {
Dot11ManagementFrame::bss_load(station_count, channel_utilization, available_capacity);
}
void Tins::Dot11ProbeResponse::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::Dot11ProbeResponse::header_size() const {
return Dot11ManagementFrame::header_size() + sizeof(this->_body);
}
Tins::PDU* Tins::Dot11ProbeResponse::clone_pdu() const {
Dot11ProbeResponse* new_pdu = new Dot11ProbeResponse();
new_pdu->copy_80211_fields(this);
new_pdu->copy_ext_header(this);
memcpy(&new_pdu->_body, &this->_body, sizeof(this->_body));
return new_pdu;
}
@@ -1103,46 +1196,6 @@ Tins::Dot11QoSData::Dot11QoSData(const uint8_t* dst_hw_addr, const uint8_t* src_
}
/* Probe Request */
Tins::Dot11ProbeRequest::Dot11ProbeRequest() : Dot11ManagementFrame() {
this->subtype(Dot11::PROBE_REQ);
}
Tins::Dot11ProbeRequest::Dot11ProbeRequest(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::PROBE_REQ);
}
Tins::Dot11ProbeRequest::Dot11ProbeRequest(const uint8_t *buffer, uint32_t total_sz) : Dot11ManagementFrame(buffer, total_sz) {
parse_tagged_parameters(buffer, total_sz);
}
void Tins::Dot11ProbeRequest::ssid(const std::string &new_ssid) {
Dot11ManagementFrame::ssid(new_ssid);
}
void Tins::Dot11ProbeRequest::supported_rates(const std::list<float> &new_rates) {
Dot11ManagementFrame::supported_rates(new_rates);
}
void Tins::Dot11ProbeRequest::request_information(const std::list<uint8_t> elements) {
Dot11ManagementFrame::request_information(elements);
}
void Tins::Dot11ProbeRequest::extended_supported_rates(const std::list<float> &new_rates) {
Dot11ManagementFrame::extended_supported_rates(new_rates);
}
Tins::PDU* Tins::Dot11ProbeRequest::clone_pdu() const {
Dot11ProbeRequest* new_pdu = new Dot11ProbeRequest();
new_pdu->copy_80211_fields(this);
return new_pdu;
}
/* QoS 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) : Dot11Data(iface, dst_hw_addr, src_hw_addr, child) {
this->subtype(Dot11::QOS_DATA_DATA);
this->_qos_control = 0;
@@ -1485,3 +1538,63 @@ Tins::PDU *Tins::Dot11BlockAck::clone_pdu() const {
new_pdu->copy_80211_fields(this);
return new_pdu;
}
/* RSNInformation */
Tins::RSNInformation::RSNInformation() : _version(1), _capabilities(0) {
}
void Tins::RSNInformation::add_pairwise_cypher(CypherSuites cypher) {
_pairwise_cyphers.push_back(cypher);
}
void Tins::RSNInformation::add_akm_cypher(AKMSuites akm) {
_akm_cyphers.push_back(akm);
}
void Tins::RSNInformation::group_suite(CypherSuites group) {
_group_suite = group;
}
void Tins::RSNInformation::version(uint16_t ver) {
_version = ver;
}
void Tins::RSNInformation::capabilities(uint16_t cap) {
_capabilities = cap;
}
uint8_t *Tins::RSNInformation::serialize(uint32_t &size) const {
size = sizeof(_version) + sizeof(_capabilities) + sizeof(uint32_t);
size += (sizeof(uint16_t) << 1); // 2 lists count.
size += sizeof(uint32_t) * (_akm_cyphers.size() + _pairwise_cyphers.size());
uint8_t *buffer = new uint8_t[size], *ptr = buffer;
*(uint16_t*)ptr = _version;
ptr += sizeof(_version);
*(uint32_t*)ptr = _group_suite;
ptr += sizeof(uint32_t);
*(uint16_t*)ptr = _pairwise_cyphers.size();
ptr += sizeof(uint16_t);
for(std::list<CypherSuites>::const_iterator it = _pairwise_cyphers.begin(); it != _pairwise_cyphers.end(); ++it) {
*(uint32_t*)ptr = *it;
ptr += sizeof(uint32_t);
}
*(uint16_t*)ptr = _akm_cyphers.size();
ptr += sizeof(uint16_t);
for(std::list<AKMSuites>::const_iterator it = _akm_cyphers.begin(); it != _akm_cyphers.end(); ++it) {
*(uint32_t*)ptr = *it;
ptr += sizeof(uint32_t);
}
*(uint16_t*)ptr = _capabilities;
return buffer;
}
Tins::RSNInformation Tins::RSNInformation::wpa2_psk() {
RSNInformation info;
info.group_suite(RSNInformation::CCMP);
info.add_pairwise_cypher(RSNInformation::CCMP);
info.add_akm_cypher(RSNInformation::PSK);
return info;
}