From 393beda0d7ae30ea5b4108f5732cabcb4ba1f746 Mon Sep 17 00:00:00 2001 From: Matias Fontanini Date: Sun, 21 Aug 2011 20:58:20 -0300 Subject: [PATCH] Added a constructor on IEEE802_11 which doesn't take an interface as a parameter. --- include/ieee802-11.h | 11 +++++++++++ src/ieee802-11.cpp | 9 ++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/ieee802-11.h b/include/ieee802-11.h index f264e50..e7b3988 100644 --- a/include/ieee802-11.h +++ b/include/ieee802-11.h @@ -93,6 +93,17 @@ namespace Tins { CF_ACK_POLL = 7 }; + /** + * \brief Constructor for creating a 802.11 PDU + * + * Constructor that builds a 802.11 PDU taking the destination's and source's MAC. + * + * \param dst_hw_addr uint8_t array of 6 bytes containing the destination's MAC(optional). + * \param src_hw_addr uint8_t array of 6 bytes containing the source's MAC(optional). + * \param child PDU* with the PDU contained by the 802.11 PDU (optional). + */ + IEEE802_11(const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0, PDU* child = 0); + /** * \brief Constructor for creating a 802.11 PDU * diff --git a/src/ieee802-11.cpp b/src/ieee802-11.cpp index f0cda6d..204cecc 100644 --- a/src/ieee802-11.cpp +++ b/src/ieee802-11.cpp @@ -35,6 +35,14 @@ using namespace std; +Tins::IEEE802_11::IEEE802_11(const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr, PDU* child) : PDU(ETHERTYPE_IP, child) { + memset(&this->_header, 0, sizeof(ieee80211_header)); + if(dst_hw_addr) + this->dst_addr(dst_hw_addr); + if(src_hw_addr) + this->src_addr(src_hw_addr); +} + Tins::IEEE802_11::IEEE802_11(const std::string& iface, const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr, PDU* child) throw (std::runtime_error) : PDU(ETHERTYPE_IP, child) { memset(&this->_header, 0, sizeof(ieee80211_header)); if(dst_hw_addr) @@ -42,7 +50,6 @@ Tins::IEEE802_11::IEEE802_11(const std::string& iface, const uint8_t* dst_hw_add if(src_hw_addr) this->src_addr(src_hw_addr); this->iface(iface); - }