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

Added copy constructor and copy assignment operator to all PDUs.

This commit is contained in:
Matias Fontanini
2011-09-03 18:58:57 -03:00
parent fdcefd2132
commit 3178c217b3
22 changed files with 615 additions and 22 deletions

View File

@@ -57,6 +57,16 @@ Tins::SNAP::SNAP(const uint8_t *buffer, uint32_t total_sz) : PDU(0xff) {
};
}
Tins::SNAP::SNAP(const SNAP &other) : PDU(other) {
copy_fields(&other);
}
Tins::SNAP &Tins::SNAP::operator= (const SNAP &other) {
copy_fields(&other);
copy_inner_pdu(other);
return *this;
}
uint32_t Tins::SNAP::header_size() const {
return sizeof(_snap);
}
@@ -83,3 +93,12 @@ void Tins::SNAP::write_serialization(uint8_t *buffer, uint32_t total_sz, const P
std::memcpy(buffer, &_snap, sizeof(_snap));
}
void Tins::SNAP::copy_fields(const SNAP *other) {
std::memcpy(&_snap, &other->_snap, sizeof(_snap));
}
Tins::PDU *Tins::SNAP::clone_pdu() const {
SNAP *new_pdu = new SNAP();
new_pdu->copy_fields(this);
return new_pdu;
}