mirror of
https://github.com/mfontanini/libtins
synced 2026-01-29 21:14:28 +01:00
Fixed a bug in PPI and Dot1Q triggered when constructing from buffer/serializing. Done some documentation fixes.
This commit is contained in:
@@ -118,7 +118,8 @@ public:
|
||||
TCLAS_PROCESSING,
|
||||
QOS_CAPABILITY = 46,
|
||||
RSN = 48,
|
||||
EXT_SUPPORTED_RATES = 50
|
||||
EXT_SUPPORTED_RATES = 50,
|
||||
VENDOR_SPECIFIC = 221
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -175,10 +176,7 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Constructor for creating an 802.11 PDU
|
||||
*
|
||||
* Constructor that builds an 802.11 PDU taking the interface index,
|
||||
* destination's and source's MAC.
|
||||
* \brief Constructs an 802.11 PDU.
|
||||
*
|
||||
* \param dst_hw_addr The destination hardware address.
|
||||
*/
|
||||
@@ -199,163 +197,165 @@ public:
|
||||
Dot11(const uint8_t *buffer, uint32_t total_sz);
|
||||
|
||||
/**
|
||||
* \brief Getter for the protocol version.
|
||||
* \brief Getter for the protocol version field.
|
||||
*
|
||||
* \return uint8_t containing the protocol version.
|
||||
* \return The stored protocol version field.
|
||||
*/
|
||||
small_uint<2> protocol() const { return _header.control.protocol; }
|
||||
|
||||
/**
|
||||
* \brief Getter for the 802.11 frame's type.
|
||||
* \brief Getter for the Type field.
|
||||
*
|
||||
* \return uint8_t containing the type of this 802.11 frame.
|
||||
* \return The stored Type field.
|
||||
*/
|
||||
small_uint<2> type() const { return _header.control.type; }
|
||||
|
||||
/**
|
||||
* \brief Getter for the 802.11 frame's subtype.
|
||||
* \brief Getter for the Subtype field.
|
||||
*
|
||||
* \return uint8_t cotaining the subtype of this 802.11 frame.
|
||||
* \return The stored Subtype field.
|
||||
*/
|
||||
small_uint<4> subtype() const { return _header.control.subtype; }
|
||||
|
||||
/**
|
||||
* \brief Getter for the 802.11 frame's To-DS field.
|
||||
* \brief Getter for the To-DS field.
|
||||
*
|
||||
* \return small_uint<1> containing the To-DS field.
|
||||
* \return The stored To-DS field.
|
||||
*/
|
||||
small_uint<1> to_ds() const { return _header.control.to_ds; }
|
||||
|
||||
/**
|
||||
* \brief Getter for the 802.11 frame's From-DS field.
|
||||
* \brief Getter for the From-DS field.
|
||||
*
|
||||
* \return small_uint<1> containing the From-DS field.
|
||||
* \return The stored From-DS field.
|
||||
*/
|
||||
small_uint<1> from_ds() const { return _header.control.from_ds; }
|
||||
|
||||
/**
|
||||
* \brief Getter for the 802.11 frame's More-Frag field.
|
||||
* \brief Getter for the More-Frag field.
|
||||
*
|
||||
* \return small_uint<1> containing the More-Frag field.
|
||||
* \return The stored More-Frag field.
|
||||
*/
|
||||
small_uint<1> more_frag() const { return _header.control.more_frag; }
|
||||
|
||||
/**
|
||||
* \brief Getter for the 802.11 frame's Retry field.
|
||||
* \brief Getter for the Retry field.
|
||||
*
|
||||
* \return small_uint<1> containing the Retry field.
|
||||
* \return The stored Retry field.
|
||||
*/
|
||||
small_uint<1> retry() const { return _header.control.retry; }
|
||||
|
||||
/**
|
||||
* \brief Getter for the 802.11 frame's Power-Management field.
|
||||
* \brief Getter for the Power-Management field.
|
||||
*
|
||||
* \return small_uint<1> containing the Power-Management field.
|
||||
* \return The stored Power-Management field.
|
||||
*/
|
||||
small_uint<1> power_mgmt() const { return _header.control.power_mgmt; }
|
||||
|
||||
/**
|
||||
* \brief Getter for the 802.11 frame's WEP field.
|
||||
* \brief Getter for the WEP field.
|
||||
*
|
||||
* \return small_uint<1> containing the WEP field.
|
||||
* \return The stored WEP field.
|
||||
*/
|
||||
small_uint<1> wep() const { return _header.control.wep; }
|
||||
|
||||
/**
|
||||
* \brief Getter for the 802.11 frame's Order field.
|
||||
* \brief Getter for the Order field.
|
||||
*
|
||||
* \return small_uint<1> containing the Order field.
|
||||
* \return The stored Order field.
|
||||
*/
|
||||
small_uint<1> order() const { return _header.control.order; }
|
||||
|
||||
/**
|
||||
* \brief Getter for the Duration-ID field.
|
||||
*
|
||||
* \return uint16_t containing the Duration-ID field.
|
||||
* \return The stored Duration-ID field.
|
||||
*/
|
||||
uint16_t duration_id() const { return Endian::le_to_host(_header.duration_id); }
|
||||
|
||||
/**
|
||||
* \brief Getter for the first address.
|
||||
*
|
||||
* \return address_type containing the first address.
|
||||
* \return The stored first address.
|
||||
*/
|
||||
address_type addr1() const { return _header.addr1; }
|
||||
|
||||
// Setters
|
||||
|
||||
/**
|
||||
* \brief Setter for the protocol version.
|
||||
* \brief Setter for the protocol version field.
|
||||
*
|
||||
* \param new_proto The new protocol version.
|
||||
* \param new_proto The new protocol version field value.
|
||||
*/
|
||||
void protocol(small_uint<2> new_proto);
|
||||
|
||||
/**
|
||||
* \brief Setter for the 802.11 frame's type.
|
||||
* \brief Setter for the type field.
|
||||
*
|
||||
* \param new_type The new type of this 802.11 frame.
|
||||
* \param new_type The new type field value.
|
||||
*/
|
||||
void type(small_uint<2> new_type);
|
||||
|
||||
/**
|
||||
* \brief Setter for the 802.11 frame's subtype.
|
||||
* \brief Setter for the subtype field.
|
||||
*
|
||||
* \param new_subtype The new subtype of this 802.11 frame.
|
||||
* \param new_subtype The new subtype field value.
|
||||
*/
|
||||
void subtype(small_uint<4> new_subtype);
|
||||
|
||||
/**
|
||||
* \brief Setter for the 802.11 frame's To-DS field.
|
||||
* \brief Setter for the To-DS field.
|
||||
*
|
||||
* \param new_value The new value of the To-DS field.
|
||||
* \param new_value The new To-DS field value.
|
||||
*/
|
||||
void to_ds(small_uint<1> new_value);
|
||||
|
||||
/**
|
||||
* \brief Setter for the 802.11 frame's From-DS field.
|
||||
* \brief Setter for the From-DS field.
|
||||
*
|
||||
* \param new_value The new value of the From-DS field.
|
||||
* \param new_value The new From-DS field value.
|
||||
*/
|
||||
void from_ds(small_uint<1> new_value);
|
||||
|
||||
/**
|
||||
* \brief Setter for the 802.11 frame's More-Frag field.
|
||||
* \brief Setter for the More-Frag field.
|
||||
*
|
||||
* \param new_value The new value of the More-Frag field.
|
||||
* \param new_value The new More-Frag field value.
|
||||
*/
|
||||
void more_frag(small_uint<1> new_value);
|
||||
|
||||
/**
|
||||
* \brief Setter for the 802.11 frame's Retry field.
|
||||
* \brief Setter for the Retry field.
|
||||
*
|
||||
* \param new_value sThe new value of the Retry field.
|
||||
* \param new_value The new Retry field value.
|
||||
*/
|
||||
void retry(small_uint<1> new_value);
|
||||
|
||||
/**
|
||||
* \brief Setter for the 802.11 frame's Power-Management field.
|
||||
* \brief Setter for the Power-Management field.
|
||||
*
|
||||
* \param new_value The new value of the Power-Management field.
|
||||
* \param new_value The new Power-Management field value.
|
||||
*/
|
||||
void power_mgmt(small_uint<1> new_value);
|
||||
|
||||
/**
|
||||
* \brief Setter for the 802.11 frame's WEP field.
|
||||
* \brief Setter for the WEP field.
|
||||
*
|
||||
* \param new_value The new value of the WEP field.
|
||||
* \param new_value The new WEP field value.
|
||||
*/
|
||||
void wep(small_uint<1> new_value);
|
||||
|
||||
/**
|
||||
* \brief Setter for the 802.11 frame's Order field.
|
||||
* \brief Setter for the Order field.
|
||||
*
|
||||
* \param new_value The new value of the Order field.
|
||||
* \param new_value The new Order field value.
|
||||
*/
|
||||
void order(small_uint<1> new_value);
|
||||
|
||||
/**
|
||||
* \brief Setter for the Duration-ID field.
|
||||
*
|
||||
* \param new_duration_id The new value of the Duration-ID field.
|
||||
* \param new_duration_id The new Duration-ID field value.
|
||||
*/
|
||||
void duration_id(uint16_t new_duration_id);
|
||||
|
||||
@@ -445,7 +445,9 @@ public:
|
||||
* \brief Allocates an Dot11 PDU from a buffer.
|
||||
*
|
||||
* This can be used somehow as a "virtual constructor". This
|
||||
* method instantiates a subclass of Dot11 from the given buffer.
|
||||
* method instantiates the appropriate subclass of Dot11 from the
|
||||
* given buffer.
|
||||
*
|
||||
* The allocated class' type will be figured out from the
|
||||
* information provided in the buffer.
|
||||
*
|
||||
|
||||
@@ -363,7 +363,9 @@ public:
|
||||
|
||||
} TINS_END_PACK;
|
||||
|
||||
TINS_BEGIN_PACK
|
||||
/**
|
||||
* The type used to store the FS parameters set option data.
|
||||
*/
|
||||
struct fh_params_set {
|
||||
uint16_t dwell_time;
|
||||
uint8_t hop_set, hop_pattern, hop_index;
|
||||
@@ -374,9 +376,11 @@ public:
|
||||
uint8_t hop_pattern, uint8_t hop_index)
|
||||
: dwell_time(dwell_time), hop_set(hop_set),
|
||||
hop_pattern(hop_pattern), hop_index(hop_index) {}
|
||||
} TINS_END_PACK;
|
||||
};
|
||||
|
||||
TINS_BEGIN_PACK
|
||||
/**
|
||||
* The type used to store the CF parameters set option data.
|
||||
*/
|
||||
struct cf_params_set {
|
||||
uint8_t cfp_count, cfp_period;
|
||||
uint16_t cfp_max_duration, cfp_dur_remaining;
|
||||
@@ -388,8 +392,11 @@ public:
|
||||
: cfp_count(cfp_count), cfp_period(cfp_period),
|
||||
cfp_max_duration(cfp_max_duration),
|
||||
cfp_dur_remaining(cfp_dur_remaining) {}
|
||||
} TINS_END_PACK;
|
||||
};
|
||||
|
||||
/**
|
||||
* The type used to store the IBSS DFS parameters option data.
|
||||
*/
|
||||
struct ibss_dfs_params {
|
||||
static const size_t minimum_size = address_type::address_size + sizeof(uint8_t) + 2 * sizeof(uint8_t);
|
||||
|
||||
@@ -405,37 +412,44 @@ public:
|
||||
channel_map(channels) {}
|
||||
};
|
||||
|
||||
/**
|
||||
* The type used to store the Country parameters option data.
|
||||
*/
|
||||
struct country_params {
|
||||
typedef std::vector<uint8_t> container_type;
|
||||
// String identifier: 3 bytes
|
||||
static const size_t minimum_size = 3 + sizeof(uint8_t) * 3;
|
||||
|
||||
std::string country;
|
||||
container_type first_channel, number_channels, max_transmit_power;
|
||||
byte_array first_channel, number_channels, max_transmit_power;
|
||||
|
||||
country_params() {}
|
||||
|
||||
country_params(const std::string &country, const container_type &first,
|
||||
const container_type &number, const container_type &max)
|
||||
country_params(const std::string &country, const byte_array &first,
|
||||
const byte_array &number, const byte_array &max)
|
||||
: country(country), first_channel(first), number_channels(number),
|
||||
max_transmit_power(max) {}
|
||||
};
|
||||
|
||||
/**
|
||||
* The type used to store the FH pattern option data.
|
||||
*/
|
||||
struct fh_pattern_type {
|
||||
typedef std::vector<uint8_t> container_type;
|
||||
static const size_t minimum_size = sizeof(uint8_t) * 4;
|
||||
|
||||
uint8_t flag, number_of_sets, modulus, offset;
|
||||
container_type random_table;
|
||||
byte_array random_table;
|
||||
|
||||
fh_pattern_type() {}
|
||||
|
||||
fh_pattern_type(uint8_t flag, uint8_t sets, uint8_t modulus,
|
||||
uint8_t offset, const container_type& table)
|
||||
uint8_t offset, const byte_array& table)
|
||||
: flag(flag), number_of_sets(sets), modulus(modulus),
|
||||
offset(offset), random_table(table) {}
|
||||
};
|
||||
|
||||
/**
|
||||
* The type used to store the Channel Switch option data.
|
||||
*/
|
||||
struct channel_switch_type {
|
||||
uint8_t switch_mode, new_channel, switch_count;
|
||||
|
||||
@@ -445,6 +459,9 @@ public:
|
||||
: switch_mode(mode), new_channel(channel), switch_count(count) { }
|
||||
};
|
||||
|
||||
/**
|
||||
* The type used to store the Quiet option data.
|
||||
*/
|
||||
struct quiet_type {
|
||||
uint8_t quiet_count, quiet_period;
|
||||
uint16_t quiet_duration, quiet_offset;
|
||||
@@ -456,7 +473,10 @@ public:
|
||||
: quiet_count(count), quiet_period(period),
|
||||
quiet_duration(duration), quiet_offset(offset) {}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* The type used to store the BSS Load option data.
|
||||
*/
|
||||
struct bss_load_type {
|
||||
uint16_t station_count;
|
||||
uint16_t available_capacity;
|
||||
@@ -470,20 +490,37 @@ public:
|
||||
channel_utilization(utilization) {}
|
||||
};
|
||||
|
||||
/**
|
||||
* The type used to store the TIM option data.
|
||||
*/
|
||||
struct tim_type {
|
||||
typedef std::vector<uint8_t> container_type;
|
||||
|
||||
uint8_t dtim_count, dtim_period, bitmap_control;
|
||||
container_type partial_virtual_bitmap;
|
||||
byte_array partial_virtual_bitmap;
|
||||
|
||||
tim_type() {}
|
||||
|
||||
tim_type(uint8_t count, uint8_t period, uint8_t control,
|
||||
const container_type &bitmap)
|
||||
const byte_array &bitmap)
|
||||
: dtim_count(count), dtim_period(period), bitmap_control(control),
|
||||
partial_virtual_bitmap(bitmap) {}
|
||||
};
|
||||
|
||||
/**
|
||||
* The type used to store the Vendor Specific option data.
|
||||
*/
|
||||
struct vendor_specific_type {
|
||||
typedef HWAddress<3> oui_type;
|
||||
|
||||
oui_type oui;
|
||||
byte_array data;
|
||||
|
||||
vendor_specific_type(const oui_type &oui = oui_type(),
|
||||
const byte_array &data = byte_array())
|
||||
: oui(oui), data(data) { }
|
||||
|
||||
static vendor_specific_type from_bytes(const uint8_t *buffer, uint32_t sz);
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Getter for the second address.
|
||||
*
|
||||
@@ -527,7 +564,7 @@ public:
|
||||
/**
|
||||
* \brief Getter for the fourth address.
|
||||
*
|
||||
* \return address_type containing the fourth address.
|
||||
* \return The stored fourth address.
|
||||
*/
|
||||
const address_type &addr4() const { return _addr4; }
|
||||
|
||||
@@ -640,7 +677,7 @@ public:
|
||||
*
|
||||
* \param fh_params the fh parameter set.
|
||||
*/
|
||||
void fh_parameter_set(fh_params_set fh_params);
|
||||
void fh_parameter_set(const fh_params_set &fh_params);
|
||||
|
||||
/**
|
||||
* \brief Helper method to set the DS parameter.
|
||||
@@ -654,7 +691,7 @@ public:
|
||||
*
|
||||
* \param params the CF parammeters to be set.
|
||||
*/
|
||||
void cf_parameter_set(cf_params_set params);
|
||||
void cf_parameter_set(const cf_params_set ¶ms);
|
||||
|
||||
/**
|
||||
* \brief Helper method to set the IBSS parameter.
|
||||
@@ -748,6 +785,13 @@ public:
|
||||
* \brief text The challenge text to be added.
|
||||
*/
|
||||
void challenge_text(const std::string &text);
|
||||
|
||||
/**
|
||||
* \brief Helper method to add a Vendor Specific tagged option.
|
||||
*
|
||||
* \brief text The option to be added.
|
||||
*/
|
||||
void vendor_specific(const vendor_specific_type &data);
|
||||
|
||||
// Option searching helpers
|
||||
|
||||
@@ -851,6 +895,17 @@ public:
|
||||
* \return uint8_t containing the ds parameter set.
|
||||
*/
|
||||
uint8_t ds_parameter_set() const;
|
||||
|
||||
/**
|
||||
* \brief Helper method to get the cf parameter set.
|
||||
*
|
||||
* An option_not_found exception is thrown if the option has not
|
||||
* been set.
|
||||
*
|
||||
* \return uint8_t containing the cf parameter set.
|
||||
*/
|
||||
cf_params_set cf_parameter_set() const;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Helper method to get the ibss parameter set.
|
||||
@@ -982,6 +1037,16 @@ public:
|
||||
*/
|
||||
std::string challenge_text() const;
|
||||
|
||||
/**
|
||||
* \brief Helper method to get a Vendor Specific option.
|
||||
*
|
||||
* An option_not_found exception is thrown if the option has not
|
||||
* been set.
|
||||
*
|
||||
* \return vendor_specific_type containing the option value.
|
||||
*/
|
||||
vendor_specific_type vendor_specific() const;
|
||||
|
||||
// ************************
|
||||
|
||||
/**
|
||||
|
||||
@@ -135,6 +135,16 @@ public:
|
||||
return "The sniffed link layer PDU type is unknown";
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Exception thrown when a malformed option is found.
|
||||
*/
|
||||
class malformed_option : public std::exception {
|
||||
public:
|
||||
const char *what() const throw() {
|
||||
return "Malformed option";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // TINS_EXCEPTIONS_H
|
||||
|
||||
Reference in New Issue
Block a user