1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-26 03:51:35 +01:00

Refactored several classes.

This commit is contained in:
Matias Fontanini
2012-08-03 13:08:24 -03:00
parent c4a92d2b96
commit c5fce38c3a
18 changed files with 204 additions and 306 deletions

View File

@@ -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;
}