From 83476fd195754eda0f221799586d2f8ced0e7355 Mon Sep 17 00:00:00 2001 From: Matias Fontanini Date: Fri, 19 Aug 2011 11:44:04 -0300 Subject: [PATCH] Normalized EthernetII source and destination addresses getters/setters. --- include/ethernetII.h | 8 ++++---- src/ethernetII.cpp | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/ethernetII.h b/include/ethernetII.h index 7a0361e..ca1adc0 100644 --- a/include/ethernetII.h +++ b/include/ethernetII.h @@ -80,14 +80,14 @@ namespace Tins { * * \return Returns the destination's mac address as a constant uint8_t pointer. */ - inline const uint8_t* dst_hw_addr() const { return _eth.dst_mac; } + inline const uint8_t* dst_addr() const { return _eth.dst_mac; } /** * \brief Getter for the source's mac address. * * \return Returns the source's mac address as a constant uint8_t pointer. */ - inline const uint8_t* src_hw_addr() const { return _eth.src_mac; } + inline const uint8_t* src_addr() const { return _eth.src_mac; } /** * \brief Getter for the interface. @@ -109,14 +109,14 @@ namespace Tins { * * \param new_dst_mac uint8_t array of 6 bytes containing the new destination's MAC. */ - void dst_hw_addr(const uint8_t* new_dst_mac); + void dst_addr(const uint8_t* new_dst_mac); /** * \brief Setter for the source's MAC. * * \param new_src_mac uint8_t array of 6 bytes containing the new source's MAC. */ - void src_hw_addr(const uint8_t* new_src_mac); + void src_addr(const uint8_t* new_src_mac); /** * \brief Setter for the interface. diff --git a/src/ethernetII.cpp b/src/ethernetII.cpp index 114bba2..77af3e8 100644 --- a/src/ethernetII.cpp +++ b/src/ethernetII.cpp @@ -38,9 +38,9 @@ const uint8_t* Tins::EthernetII::BROADCAST = (const uint8_t*)"\xff\xff\xff\xff\x Tins::EthernetII::EthernetII(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(&_eth, 0, sizeof(ethhdr)); if(dst_hw_addr) - this->dst_hw_addr(dst_hw_addr); + this->dst_addr(dst_hw_addr); if(src_hw_addr) - this->src_hw_addr(src_hw_addr); + this->src_addr(src_hw_addr); this->iface(iface); this->_eth.payload_type = 0; @@ -49,9 +49,9 @@ Tins::EthernetII::EthernetII(const std::string& iface, const uint8_t* dst_hw_add Tins::EthernetII::EthernetII(uint32_t iface_index, const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr, PDU* child) : PDU(ETHERTYPE_IP, child) { memset(&_eth, 0, sizeof(ethhdr)); if(dst_hw_addr) - this->dst_hw_addr(dst_hw_addr); + this->dst_addr(dst_hw_addr); if(src_hw_addr) - this->src_hw_addr(src_hw_addr); + this->src_addr(src_hw_addr); this->iface(iface_index); this->_eth.payload_type = 0; } @@ -81,11 +81,11 @@ uint16_t Tins::EthernetII::payload_type() const { return Utils::net_to_host_s(_eth.payload_type); } -void Tins::EthernetII::dst_hw_addr(const uint8_t* new_dst_mac) { +void Tins::EthernetII::dst_addr(const uint8_t* new_dst_mac) { memcpy(this->_eth.dst_mac, new_dst_mac, 6); } -void Tins::EthernetII::src_hw_addr(const uint8_t* new_src_mac) { +void Tins::EthernetII::src_addr(const uint8_t* new_src_mac) { memcpy(this->_eth.src_mac, new_src_mac, 6); }