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) {