mirror of
https://github.com/mfontanini/libtins
synced 2026-01-23 02:35:57 +01:00
Merge branch 'master' of ssh://git.code.sf.net/p/libtins/code
This commit is contained in:
@@ -37,6 +37,62 @@ namespace Tins {
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* \brief Enum for the different types of 802.11 frames.
|
||||
*
|
||||
*/
|
||||
enum Types {
|
||||
MANAGEMENT = 0,
|
||||
CONTROL = 1,
|
||||
DATA = 2
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Enum for the different subtypes of 802.11 management frames.
|
||||
*
|
||||
*/
|
||||
enum ManagementSubtypes {
|
||||
ASSOC_REQ = 0,
|
||||
ASSOC_RESP = 1,
|
||||
REASSOC_REQ = 2,
|
||||
REASSOC_RESP = 3,
|
||||
PROBE_REQ = 4,
|
||||
PROBE_RESP = 5,
|
||||
BEACON = 8,
|
||||
ATIM = 9,
|
||||
DISASSOC = 10,
|
||||
AUTH = 11,
|
||||
DEAUTH = 12
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Enum for the different subtypes of 802.11 control frames.
|
||||
*
|
||||
*/
|
||||
enum ControlSubtypes {
|
||||
PS = 10,
|
||||
RTS = 11,
|
||||
CTS = 12,
|
||||
ACK = 13,
|
||||
CF = 14,
|
||||
CFE_CFA = 15
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Enum fro the different subtypes of 802.11 data frames.
|
||||
*
|
||||
*/
|
||||
enum DataSubtypes {
|
||||
DATA_DATA = 0,
|
||||
DATA_CF_ACK = 1,
|
||||
DATA_CF_POLL = 2,
|
||||
DATA_CF_ACK_POLL = 3,
|
||||
DATA_NULL = 4,
|
||||
CF_ACK = 5,
|
||||
CF_POLL = 6,
|
||||
CF_ACK_POLL = 7
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Constructor for creating a 802.11 PDU
|
||||
*
|
||||
@@ -188,7 +244,7 @@ namespace Tins {
|
||||
*
|
||||
* \return The optional address as a constant uint8_t pointer.
|
||||
*/
|
||||
inline const uint8_t* opt_addr() const { return this->_header.opt_addr; }
|
||||
inline const uint8_t* opt_addr() const { return this->_opt_addr; }
|
||||
|
||||
/**
|
||||
* \brief Getter for the interface.
|
||||
@@ -394,15 +450,14 @@ namespace Tins {
|
||||
unsigned int seq_number:12;
|
||||
#endif
|
||||
} __attribute__((__packed__)) seq_control;
|
||||
uint8_t opt_addr[6];
|
||||
|
||||
} __attribute__((__packed__));
|
||||
|
||||
IEEE802_11(const ieee80211_header *header_ptr);
|
||||
|
||||
void write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent);
|
||||
|
||||
ieee80211_header _header;
|
||||
uint8_t _opt_addr[6];
|
||||
uint32_t _iface_index;
|
||||
};
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ void Tins::IEEE802_11::seq_num(uint16_t new_seq_num) {
|
||||
}
|
||||
|
||||
void Tins::IEEE802_11::opt_addr(const uint8_t* new_opt_addr) {
|
||||
memcpy(this->_header.opt_addr, new_opt_addr, 6);
|
||||
memcpy(this->_opt_addr, new_opt_addr, 6);
|
||||
}
|
||||
|
||||
void Tins::IEEE802_11::iface(uint32_t new_iface_index) {
|
||||
@@ -138,7 +138,10 @@ void Tins::IEEE802_11::iface(const std::string& new_iface) throw (std::runtime_e
|
||||
}
|
||||
|
||||
uint32_t Tins::IEEE802_11::header_size() const {
|
||||
return sizeof(ieee80211_header);
|
||||
uint32_t sz = sizeof(ieee80211_header);
|
||||
if (this->to_ds() && this->from_ds())
|
||||
sz += 6;
|
||||
return sz;
|
||||
}
|
||||
|
||||
bool Tins::IEEE802_11::send(PacketSender* sender) {
|
||||
@@ -160,6 +163,9 @@ void Tins::IEEE802_11::write_serialization(uint8_t *buffer, uint32_t total_sz, c
|
||||
assert(total_sz >= my_sz);
|
||||
|
||||
memcpy(buffer, &this->_header, sizeof(ieee80211_header));
|
||||
if (this->to_ds() && this->from_ds()) {
|
||||
memcpy(buffer + sizeof(ieee80211_header), this->_opt_addr, 6);
|
||||
}
|
||||
}
|
||||
|
||||
Tins::IEEE802_11::IEEE802_11(const ieee80211_header *header_ptr) : PDU(ETHERTYPE_IP) {
|
||||
|
||||
Reference in New Issue
Block a user