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:
@@ -47,11 +47,11 @@ namespace Tins {
|
||||
* destination's and source's MAC.
|
||||
*
|
||||
* \param iface string containing the interface's name from where to send the packet.
|
||||
* \param mac_dst uint8_t array of 6 bytes containing the destination's MAC(optional).
|
||||
* \param mac_src uint8_t array of 6 bytes containing the source's MAC(optional).
|
||||
* \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 ethernet PDU (optional).
|
||||
*/
|
||||
EthernetII(const std::string& iface, const uint8_t* mac_dst = 0, const uint8_t* mac_src = 0, PDU* child = 0) throw (std::runtime_error);
|
||||
EthernetII(const std::string& iface, const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0, PDU* child = 0) throw (std::runtime_error);
|
||||
|
||||
/**
|
||||
* \brief Constructor for creating an ethernet PDU
|
||||
@@ -60,11 +60,11 @@ namespace Tins {
|
||||
* destination's and source's MAC.
|
||||
*
|
||||
* \param iface_index const uint32_t with the interface's index from where to send the packet.
|
||||
* \param mac_dst uint8_t array of 6 bytes containing the destination's MAC(optional).
|
||||
* \param mac_src uint8_t array of 6 bytes containing the source's MAC(optional).
|
||||
* \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 ethernet PDU (optional).
|
||||
*/
|
||||
EthernetII(uint32_t iface_index, const uint8_t* mac_dst = 0, const uint8_t* mac_src = 0, PDU* child = 0);
|
||||
EthernetII(uint32_t iface_index, const uint8_t* dst_hw_addr = 0, const uint8_t* src_hw_addr = 0, PDU* child = 0);
|
||||
|
||||
/**
|
||||
* \brief Constructor which creates an EthernetII object from a buffer and adds all identifiable
|
||||
@@ -80,14 +80,14 @@ namespace Tins {
|
||||
*
|
||||
* \return Returns the destination's mac address as a constant uint8_t pointer.
|
||||
*/
|
||||
inline const uint8_t* dst_mac() const { return _eth.dst_mac; }
|
||||
inline const uint8_t* dst_hw_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_mac() const { return _eth.src_mac; }
|
||||
inline const uint8_t* src_hw_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_mac(const uint8_t* new_dst_mac);
|
||||
void dst_hw_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_mac(const uint8_t* new_src_mac);
|
||||
void src_hw_addr(const uint8_t* new_src_mac);
|
||||
|
||||
/**
|
||||
* \brief Setter for the interface.
|
||||
|
||||
@@ -35,23 +35,23 @@
|
||||
|
||||
const uint8_t* Tins::EthernetII::BROADCAST = (const uint8_t*)"\xff\xff\xff\xff\xff\xff";
|
||||
|
||||
Tins::EthernetII::EthernetII(const std::string& iface, const uint8_t* mac_dst, const uint8_t* mac_src, PDU* child) throw (std::runtime_error) : PDU(ETHERTYPE_IP, child) {
|
||||
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(mac_dst)
|
||||
this->dst_mac(mac_dst);
|
||||
if(mac_src)
|
||||
this->src_mac(mac_src);
|
||||
if(dst_hw_addr)
|
||||
this->dst_hw_addr(dst_hw_addr);
|
||||
if(src_hw_addr)
|
||||
this->src_hw_addr(src_hw_addr);
|
||||
this->iface(iface);
|
||||
this->_eth.payload_type = 0;
|
||||
|
||||
}
|
||||
|
||||
Tins::EthernetII::EthernetII(uint32_t iface_index, const uint8_t* mac_dst, const uint8_t* mac_src, PDU* child) : PDU(ETHERTYPE_IP, child) {
|
||||
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(mac_dst)
|
||||
this->dst_mac(mac_dst);
|
||||
if(mac_src)
|
||||
this->src_mac(mac_src);
|
||||
if(dst_hw_addr)
|
||||
this->dst_hw_addr(dst_hw_addr);
|
||||
if(src_hw_addr)
|
||||
this->src_hw_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_mac(const uint8_t* new_dst_mac) {
|
||||
void Tins::EthernetII::dst_hw_addr(const uint8_t* new_dst_mac) {
|
||||
memcpy(this->_eth.dst_mac, new_dst_mac, 6);
|
||||
}
|
||||
|
||||
void Tins::EthernetII::src_mac(const uint8_t* new_src_mac) {
|
||||
void Tins::EthernetII::src_hw_addr(const uint8_t* new_src_mac) {
|
||||
memcpy(this->_eth.src_mac, new_src_mac, 6);
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ bool Tins::EthernetII::matches_response(uint8_t *ptr, uint32_t total_sz) {
|
||||
void Tins::EthernetII::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent) {
|
||||
uint32_t my_sz = header_size();
|
||||
assert(total_sz >= my_sz);
|
||||
|
||||
|
||||
/* Inner type defaults to IP */
|
||||
if ((this->_eth.payload_type == 0) && this->inner_pdu()) {
|
||||
uint16_t type = ETHERTYPE_IP;
|
||||
|
||||
Reference in New Issue
Block a user