1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-28 20:44:26 +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

@@ -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;
}