mirror of
https://github.com/mfontanini/libtins
synced 2026-01-26 03:51:35 +01:00
Refactored several classes.
This commit is contained in:
@@ -56,10 +56,6 @@ Tins::EthernetII::EthernetII(uint32_t iface_index, const uint8_t* dst_hw_addr, c
|
||||
this->_eth.payload_type = 0;
|
||||
}
|
||||
|
||||
Tins::EthernetII::EthernetII(const EthernetII &other) : PDU(other) {
|
||||
copy_fields(&other);
|
||||
}
|
||||
|
||||
Tins::EthernetII::EthernetII(const uint8_t *buffer, uint32_t total_sz) : PDU(ETHERTYPE_IP) {
|
||||
if(total_sz < sizeof(ethhdr))
|
||||
throw std::runtime_error("Not enough size for an ethernetII header in the buffer.");
|
||||
@@ -179,15 +175,3 @@ Tins::PDU *Tins::EthernetII::clone_packet(const uint8_t *ptr, uint32_t total_sz)
|
||||
cloned->inner_pdu(child);
|
||||
return cloned;
|
||||
}
|
||||
|
||||
void Tins::EthernetII::copy_fields(const EthernetII *other) {
|
||||
memcpy(&_eth, &other->_eth, sizeof(_eth));
|
||||
_iface_index = other->_iface_index;
|
||||
}
|
||||
|
||||
Tins::PDU *Tins::EthernetII::clone_pdu() const {
|
||||
EthernetII *new_pdu = new EthernetII(_iface_index);
|
||||
new_pdu->copy_fields(this);
|
||||
new_pdu->copy_inner_pdu(*this);
|
||||
return new_pdu;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user