From 26e65d17f65ce567bd22e1a75dc30d0acec8aa33 Mon Sep 17 00:00:00 2001 From: Santiago Alessandri Date: Sun, 21 Aug 2011 19:12:36 -0300 Subject: [PATCH 1/2] Fixed bugs in 802.11 PDU. --- include/ieee802-11.h | 5 ++--- src/ieee802-11.cpp | 10 ++++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/ieee802-11.h b/include/ieee802-11.h index f2f72d3..b512b91 100644 --- a/include/ieee802-11.h +++ b/include/ieee802-11.h @@ -188,7 +188,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 +394,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; }; diff --git a/src/ieee802-11.cpp b/src/ieee802-11.cpp index 183d014..f0cda6d 100644 --- a/src/ieee802-11.cpp +++ b/src/ieee802-11.cpp @@ -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) { From 6f4f4bedb4eebbc6bcb59cc425813c4368f1f2b7 Mon Sep 17 00:00:00 2001 From: Santiago Alessandri Date: Sun, 21 Aug 2011 19:40:11 -0300 Subject: [PATCH 2/2] Added enums for types and subtypes of IEEE802_11 frames --- include/ieee802-11.h | 56 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/include/ieee802-11.h b/include/ieee802-11.h index b512b91..f264e50 100644 --- a/include/ieee802-11.h +++ b/include/ieee802-11.h @@ -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 *