30#include <tins/config.h>
32#if !defined(TINS_DOT11_DOT11_MGMT_H) && defined(TINS_HAVE_DOT11)
34#define TINS_DOT11_DOT11_MGMT_H
38#include <tins/dot11/dot11_base.h>
39#include <tins/macros.h>
45class TINS_API Dot11ManagementFrame :
public Dot11 {
80 PREV_AUTH_NOT_VALID = 2,
81 STA_LEAVING_IBSS_ESS = 3,
84 CLASS2_FROM_NO_AUTH = 6,
85 CLASS3_FROM_NO_AUTH = 7,
87 STA_NOT_AUTH_WITH_STA = 9,
88 POW_CAP_NOT_VALID = 10,
89 SUPPORTED_CHANN_NOT_VALID = 11,
92 HANDSHAKE_TIMEOUT = 15,
93 GROUP_KEY_TIMEOUT = 16,
95 INVALID_GROUP_CIPHER = 18,
96 INVALID_PAIRWISE_CIPHER = 19,
98 UNSOPPORTED_RSN_VERSION = 21,
99 INVALID_RSN_CAPABILITIES = 22,
101 CIPHER_SUITE_REJECTED = 24,
102 UNSPECIFIED_QOS_REASON = 32,
103 NOT_ENOUGH_BANDWITH = 33,
105 STA_OUT_OF_LIMITS = 35,
106 REQUESTED_BY_STA_LEAVING = 36,
107 REQUESTED_BY_STA_REJECT_MECHANISM = 37,
108 REQUESTED_BY_STA_REJECT_SETUP = 38,
109 REQUESTED_BY_STA_TIMEOUT = 39,
110 PEER_STA_NOT_SUPPORT_CIPHER = 45
122 UNIDENTIFIED_SIGNAL = 0x4,
134 #if TINS_IS_LITTLE_ENDIAN
147 radio_measurement_:1,
149 delayed_block_ack_:1,
150 immediate_block_ack_:1;
151 #elif TINS_IS_BIG_ENDIAN
152 uint16_t channel_agility_:1,
160 immediate_block_ack_:1,
161 delayed_block_ack_:1,
163 radio_measurement_:1,
221 return short_preamble_;
239 return channel_agility_;
248 return spectrum_mgmt_;
284 return radio_measurement_;
302 return delayed_block_ack_;
311 return immediate_block_ack_;
319 void ess(
bool new_value) {
338 cf_poll_ = new_value;
347 cf_poll_req_ = new_value;
356 privacy_ = new_value;
365 short_preamble_ = new_value;
383 channel_agility_ = new_value;
392 spectrum_mgmt_ = new_value;
400 void qos(
bool new_value) {
409 void sst(
bool new_value) {
428 radio_measurement_ = new_value;
437 dsss_ofdm_ = new_value;
446 delayed_block_ack_ = new_value;
455 immediate_block_ack_ = new_value;
462 struct fh_params_set {
464 uint8_t hop_set, hop_pattern, hop_index;
467 : dwell_time(0), hop_set(0), hop_pattern(0), hop_index(0) {}
469 fh_params_set(uint16_t dwell_time,
473 : dwell_time(dwell_time), hop_set(hop_set),
474 hop_pattern(hop_pattern), hop_index(hop_index) {}
476 static fh_params_set from_option(
const option& opt);
482 struct cf_params_set {
483 uint8_t cfp_count, cfp_period;
484 uint16_t cfp_max_duration, cfp_dur_remaining;
487 : cfp_count(0), cfp_period(0), cfp_max_duration(0), cfp_dur_remaining(0) {}
489 cf_params_set(uint8_t cfp_count,
491 uint16_t cfp_max_duration,
492 uint16_t cfp_dur_remaining)
493 : cfp_count(cfp_count), cfp_period(cfp_period),
494 cfp_max_duration(cfp_max_duration),
495 cfp_dur_remaining(cfp_dur_remaining) {}
497 static cf_params_set from_option(
const option& opt);
503 struct ibss_dfs_params {
507 uint8_t recovery_interval;
510 ibss_dfs_params() : recovery_interval(0) {}
513 uint8_t recovery_interval,
515 : dfs_owner(addr), recovery_interval(recovery_interval),
516 channel_map(channel_map) {}
518 static ibss_dfs_params from_option(
const option& opt);
524 struct country_params {
526 static const size_t minimum_size = 3 +
sizeof(uint8_t) * 3;
529 byte_array first_channel, number_channels, max_transmit_power;
533 country_params(
const std::string& country,
537 : country(country), first_channel(first), number_channels(number),
538 max_transmit_power(max) {}
540 static country_params from_option(
const option& opt);
546 struct fh_pattern_type {
547 static const size_t minimum_size =
sizeof(uint8_t) * 4;
549 uint8_t flag, number_of_sets, modulus, offset;
553 : flag(0), number_of_sets(0), modulus(0), offset(0) {}
555 fh_pattern_type(uint8_t flag,
560 : flag(flag), number_of_sets(sets), modulus(modulus),
561 offset(offset), random_table(table) {}
563 static fh_pattern_type from_option(
const option& opt);
569 struct channel_switch_type {
570 uint8_t switch_mode, new_channel, switch_count;
572 channel_switch_type()
573 : switch_mode(0), new_channel(0), switch_count(0) {}
575 channel_switch_type(uint8_t mode,
578 : switch_mode(mode), new_channel(channel), switch_count(count) { }
580 static channel_switch_type from_option(
const option& opt);
587 uint8_t quiet_count, quiet_period;
588 uint16_t quiet_duration, quiet_offset;
591 : quiet_count(0), quiet_period(0), quiet_duration(0), quiet_offset(0) {}
593 quiet_type(uint8_t count,
597 : quiet_count(count), quiet_period(period),
598 quiet_duration(duration), quiet_offset(offset) {}
600 static quiet_type from_option(
const option& opt);
606 struct bss_load_type {
607 uint16_t station_count;
608 uint16_t available_capacity;
609 uint8_t channel_utilization;
612 : station_count(0), available_capacity(0), channel_utilization(0) {}
614 bss_load_type(uint16_t count, uint8_t utilization, uint16_t capacity)
615 : station_count(count), available_capacity(capacity),
616 channel_utilization(utilization) {}
618 static bss_load_type from_option(
const option& opt);
625 uint8_t dtim_count, dtim_period, bitmap_control;
629 : dtim_count(0), dtim_period(0), bitmap_control(0) {}
631 tim_type(uint8_t count,
635 : dtim_count(count), dtim_period(period), bitmap_control(control),
636 partial_virtual_bitmap(bitmap) {}
638 static tim_type from_option(
const option& opt);
644 struct vendor_specific_type {
650 vendor_specific_type(
const oui_type& oui = oui_type(),
652 : oui(oui), data(data) { }
654 static vendor_specific_type from_bytes(
const uint8_t* buffer, uint32_t sz);
668 return ext_header_.addr2;
677 return ext_header_.addr3;
686 #if TINS_IS_LITTLE_ENDIAN
687 return ext_header_.frag_seq & 0xf;
689 return (ext_header_.frag_seq >> 8) & 0xf;
699 #if TINS_IS_LITTLE_ENDIAN
700 return (ext_header_.frag_seq >> 4) & 0xfff;
702 return (Endian::le_to_host<uint16_t>(ext_header_.frag_seq) >> 4) & 0xfff;
720 void addr2(
const address_type& new_addr2);
727 void addr3(
const address_type& new_addr3);
748 void addr4(
const address_type& new_addr4);
757 void ssid(
const std::string& new_ssid);
814 void edca_parameter_set(uint32_t ac_be, uint32_t ac_bk, uint32_t ac_vi, uint32_t ac_vo);
871 void fh_parameters(uint8_t prime_radix, uint8_t number_channels);
907 void tpc_report(uint8_t transmit_power, uint8_t link_margin);
965 std::string
ssid()
const;
1150 std::pair<uint8_t, uint8_t>
tpc_report()
const;
1255 Dot11ManagementFrame(
const uint8_t* buffer, uint32_t total_sz);
1257 void write_ext_header(Memory::OutputMemoryStream& stream);
1259 uint32_t management_frame_size() {
1263 static std::vector<uint8_t> serialize_rates(
const rates_type& rates);
1264 static rates_type deserialize_rates(
const option* option);
1266 template<
typename T>
1267 T search_and_convert(OptionTypes opt_type)
const {
1268 const option* opt = search_option(opt_type);
1272 return opt->to<T>();
1275 dot11_extended_header ext_header_;
1276 address_type addr4_;
void erp_information(uint8_t value)
Helper method to set the ERP Information tagged option.
Definition dot11_mgmt.cpp:314
std::vector< std::pair< uint8_t, uint8_t > > channels_type
Definition dot11_mgmt.h:55
void channel_switch(const channel_switch_type &data)
Helper method to set the Channel Switch tagged option.
Definition dot11_mgmt.cpp:287
void power_capability(uint8_t min_power, uint8_t max_power)
Helper method to set the power capabilities option.
Definition dot11_mgmt.cpp:162
void quiet(const quiet_type &data)
Helper method to set the Quiet tagged option.
Definition dot11_mgmt.cpp:296
std::vector< uint8_t > request_info_type
Definition dot11_mgmt.h:65
void cf_parameter_set(const cf_params_set ¶ms)
Helper method to set the CF parameter set tagged option.
Definition dot11_mgmt.cpp:209
void qos_capability(qos_capability_type new_qos_capability)
Helper method to set the QoS capabilities option.
Definition dot11_mgmt.cpp:158
uint32_t header_size() const
Returns the 802.11 frame's header length.
Definition dot11_mgmt.cpp:69
void vendor_specific(const vendor_specific_type &data)
Helper method to add a Vendor Specific tagged option.
Definition dot11_mgmt.cpp:365
void rsn_information(const RSNInformation &info)
Helper method to set the RSN information option.
Definition dot11_mgmt.cpp:121
void power_constraint(uint8_t local_power_constraint)
Helper method to set the Power Constraint tagged option.
Definition dot11_mgmt.cpp:283
std::vector< float > rates_type
Definition dot11_mgmt.h:50
uint8_t qos_capability_type
Definition dot11_mgmt.h:660
void ibss_parameter_set(uint16_t atim_window)
Helper method to set the IBSS parameter set tagged option.
Definition dot11_mgmt.cpp:219
void tim(const tim_type &data)
Helper method to set the TIM tagged option.
Definition dot11_mgmt.cpp:343
void country(const country_params ¶ms)
Helper method to set the country tagged option.
Definition dot11_mgmt.cpp:239
ReasonCodes
Enum used in the reason code field.
Definition dot11_mgmt.h:78
void ds_parameter_set(uint8_t current_channel)
Helper method to set the DS parameter tagged option.
Definition dot11_mgmt.cpp:205
std::vector< std::pair< uint8_t, uint8_t > > channel_map_type
Definition dot11_mgmt.h:60
const address_type & addr4() const
Getter for the fourth address.
Definition dot11_mgmt.h:711
void ssid(const std::string &new_ssid)
Helper method to set the SSID.
void fh_pattern_table(const fh_pattern_type ¶ms)
Helper method to set the FH pattern table tagged option.
Definition dot11_mgmt.cpp:269
small_uint< 4 > frag_num() const
Getter for the fragment number.
Definition dot11_mgmt.h:685
address_type addr2() const
Getter for the second address.
Definition dot11_mgmt.h:667
void supported_channels(const channels_type &new_channels)
Helper method to set the supported channels option.
Definition dot11_mgmt.cpp:169
void supported_rates(const rates_type &new_rates)
Helper method to set the supported rates option.
Definition dot11_mgmt.cpp:148
small_uint< 12 > seq_num() const
Getter for the sequence number field.
Definition dot11_mgmt.h:698
address_type addr3() const
Getter for the third address.
Definition dot11_mgmt.h:676
void fh_parameters(uint8_t prime_radix, uint8_t number_channels)
Helper method to set the FH parameters set tagged option.
Definition dot11_mgmt.cpp:262
void challenge_text(const std::string &text)
Helper method to set the Challenge Text tagged option.
void bss_load(const bss_load_type &data)
Helper method to set the BSS Load tagged option.
Definition dot11_mgmt.cpp:318
void ibss_dfs(const ibss_dfs_params ¶ms)
Helper method to set the IBSS DFS tagged option.
Definition dot11_mgmt.cpp:224
void extended_supported_rates(const rates_type &new_rates)
Helper method to set the extended supported rates option.
Definition dot11_mgmt.cpp:153
void fh_parameter_set(const fh_params_set &fh_params)
Helper method to set the FH parameter set tagged option.
Definition dot11_mgmt.cpp:195
void tpc_report(uint8_t transmit_power, uint8_t link_margin)
Helper method to set the TPC Report tagged option.
Definition dot11_mgmt.cpp:306
PDUType pdu_type() const
Getter for the PDU's type.
Definition dot11_mgmt.h:1217
MapMask
Enum that represents the map field within a channels map field.
Definition dot11_mgmt.h:119
bool matches_flag(PDUType flag) const
Check whether this PDU matches the specified flag.
Definition dot11_mgmt.h:1226
void request_information(const request_info_type elements)
Helper method to set the Request Information element tagged option.
Definition dot11_mgmt.cpp:191
void edca_parameter_set(uint32_t ac_be, uint32_t ac_bk, uint32_t ac_vi, uint32_t ac_vo)
Helper method to set the EDCA Parameter Set.
Definition dot11_mgmt.cpp:179
static const PDU::PDUType pdu_flag
Definition dot11_mgmt.h:70
bool matches_flag(PDUType flag) const
Check whether this PDU matches the specified flag.
Definition dot11_base.h:636
Dot11(const address_type &dst_hw_addr=address_type())
Constructs an 802.11 PDU.
Definition dot11_base.cpp:61
HWAddress< 6 > address_type
Definition dot11_base.h:59
PDUOption< uint8_t, Dot11 > option
IEEE 802.11 options struct.
Definition dot11_base.h:64
Represents a hardware address.
Definition hw_address.h:91
static const size_t address_size
Definition hw_address.h:112
PDUType
Enum which identifies each type of PDU.
Definition pdu.h:127
Exception thrown when an option is not found.
Definition exceptions.h:56
Represents a field of n bits.
Definition small_uint.h:52
The Tins namespace.
Definition address_range.h:38
std::vector< uint8_t > byte_array
Definition pdu.h:50
Definition dot11_mgmt.h:606
Definition dot11_mgmt.h:482
Definition dot11_mgmt.h:569
Definition dot11_mgmt.h:524
Definition dot11_mgmt.h:462
Definition dot11_mgmt.h:546
Definition dot11_mgmt.h:503
Definition dot11_mgmt.h:586
Definition dot11_mgmt.h:624
Definition dot11_mgmt.h:644