mirror of
https://github.com/mfontanini/libtins
synced 2026-01-23 02:35:57 +01:00
Fixed merge conflicts
This commit is contained in:
@@ -944,6 +944,44 @@ namespace Tins {
|
||||
*/
|
||||
void group_suite(CypherSuites group);
|
||||
|
||||
/**
|
||||
* \brief Sets the version.
|
||||
* \param ver The version to be set.
|
||||
*/
|
||||
void version(uint16_t ver);
|
||||
|
||||
/**
|
||||
* \brief Sets the capabilities field.
|
||||
* \param cap The capabilities to be set.
|
||||
*/
|
||||
void capabilities(uint16_t cap);
|
||||
|
||||
/* Getters */
|
||||
|
||||
/**
|
||||
* \brief Getter for the group suite field.
|
||||
* \return The group suite field.
|
||||
*/
|
||||
inline CypherSuites group_suite() const { return _group_suite; }
|
||||
|
||||
/**
|
||||
* \brief Getter for the version field.
|
||||
* \return The version field.
|
||||
*/
|
||||
inline uint16_t version() const { return _version; }
|
||||
|
||||
/**
|
||||
* \brief Getter for the pairwise cypher suite list.
|
||||
* \return A list of pairwise cypher suites.
|
||||
*/
|
||||
inline const std::list<CypherSuites> &pairwise_cyphers() const { return _pairwise_cyphers; }
|
||||
|
||||
/**
|
||||
* \brief Getter for the akm suite list.
|
||||
* \return A list of akm suites.
|
||||
*/
|
||||
inline const std::list<AKMSuites> &akm_cyphers() const { return _akm_cyphers; }
|
||||
|
||||
/**
|
||||
* \brief Serializes this object.
|
||||
* \param size Output parameter which will contain the size of
|
||||
@@ -1068,7 +1106,16 @@ namespace Tins {
|
||||
* string if no essid has been set.
|
||||
*/
|
||||
std::string essid() const;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Helper method to search for the RSN information of this beacon.
|
||||
*
|
||||
* This method fills the RSN information structure of this beacon.
|
||||
* \param rsn A pointer in which the RSN information will be stored.
|
||||
* \return True if the RSNInformation option has been set.
|
||||
*/
|
||||
bool rsn_information(RSNInformation *rsn);
|
||||
|
||||
/**
|
||||
* \brief Returns the frame's header length.
|
||||
*
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
#include <iostream> //borrame
|
||||
#ifndef WIN32
|
||||
#include <net/ethernet.h>
|
||||
#include <netpacket/packet.h>
|
||||
@@ -30,6 +31,8 @@
|
||||
#endif
|
||||
#include "ieee802-11.h"
|
||||
#include "rawpdu.h"
|
||||
#include "radiotap.h"
|
||||
#include "sniffer.h"
|
||||
#include "utils.h"
|
||||
|
||||
using namespace std;
|
||||
@@ -245,6 +248,8 @@ Tins::PDU *Tins::IEEE802_11::from_bytes(const uint8_t *buffer, uint32_t total_sz
|
||||
PDU *ret = 0;
|
||||
if(hdr->control.type == 0 && hdr->control.subtype == 8)
|
||||
ret = new IEEE802_11_Beacon(buffer, total_sz);
|
||||
else
|
||||
ret = new IEEE802_11(buffer, total_sz);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -330,11 +335,52 @@ void Tins::IEEE802_11_Beacon::rsn_information(const RSNInformation& info) {
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
std::string Tins::IEEE802_11_Beacon::essid() const {
|
||||
string Tins::IEEE802_11_Beacon::essid() const {
|
||||
const IEEE802_11::IEEE802_11_Option *option = lookup_option(SSID);
|
||||
return (option) ? string((const char*)option->value, option->length) : 0;
|
||||
}
|
||||
|
||||
bool Tins::IEEE802_11_Beacon::rsn_information(RSNInformation *rsn) {
|
||||
const IEEE802_11::IEEE802_11_Option *option = lookup_option(RSN);
|
||||
if(!option || option->length < (sizeof(uint16_t) << 1) + sizeof(uint32_t))
|
||||
return false;
|
||||
const uint8_t *buffer = option->value;
|
||||
uint32_t bytes_left = option->length;
|
||||
rsn->version(*(uint16_t*)buffer);
|
||||
buffer += sizeof(uint16_t);
|
||||
rsn->group_suite((RSNInformation::CypherSuites)*(uint32_t*)buffer);
|
||||
buffer += sizeof(uint32_t);
|
||||
|
||||
bytes_left -= (sizeof(uint16_t) << 1) + sizeof(uint32_t);
|
||||
if(bytes_left < sizeof(uint16_t))
|
||||
return false;
|
||||
uint16_t count = *(uint16_t*)buffer;
|
||||
buffer += sizeof(uint16_t);
|
||||
if(count * sizeof(uint32_t) > bytes_left)
|
||||
return false;
|
||||
bytes_left -= count * sizeof(uint32_t);
|
||||
while(count--) {
|
||||
rsn->add_pairwise_cypher((RSNInformation::CypherSuites)*(uint32_t*)buffer);
|
||||
buffer += sizeof(uint32_t);
|
||||
}
|
||||
if(bytes_left < sizeof(uint16_t))
|
||||
return false;
|
||||
count = *(uint16_t*)buffer;
|
||||
buffer += sizeof(uint16_t);
|
||||
bytes_left -= sizeof(uint16_t);
|
||||
if(count * sizeof(uint32_t) > bytes_left)
|
||||
return false;
|
||||
bytes_left -= count * sizeof(uint32_t);
|
||||
while(count--) {
|
||||
rsn->add_akm_cypher((RSNInformation::AKMSuites)*(uint32_t*)buffer);
|
||||
buffer += sizeof(uint32_t);
|
||||
}
|
||||
if(bytes_left < sizeof(uint16_t))
|
||||
return false;
|
||||
rsn->capabilities(*(uint16_t*)buffer);
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t Tins::IEEE802_11_Beacon::header_size() const {
|
||||
return IEEE802_11::header_size() + sizeof(BeaconBody);
|
||||
}
|
||||
@@ -392,6 +438,14 @@ 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.
|
||||
|
||||
Reference in New Issue
Block a user