1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-28 12:44:25 +01:00

Fix serialization for QinQ (#316)

* Add QinQ Frame

* Fix serialization for QinQ
This commit is contained in:
Teodoro Vargas
2018-10-09 15:02:01 -06:00
committed by Matias Fontanini
parent c26e4943c2
commit 57ac099703
6 changed files with 27 additions and 10 deletions

View File

@@ -156,7 +156,7 @@ bool EthernetII::matches_response(const uint8_t* ptr, uint32_t total_sz) const {
void EthernetII::write_serialization(uint8_t* buffer, uint32_t total_sz) {
OutputMemoryStream stream(buffer, total_sz);
if (inner_pdu()) {
Constants::Ethernet::e flag;
Constants::Ethernet::e flag = Constants::Ethernet::UNKNOWN;
const PDUType type = inner_pdu()->pdu_type();
// Dirty trick to successfully tag PPPoE session/discovery packets
if (type == PDU::PPPOE) {
@@ -164,6 +164,15 @@ void EthernetII::write_serialization(uint8_t* buffer, uint32_t total_sz) {
flag = (pppoe->code() == 0) ? Constants::Ethernet::PPPOES
: Constants::Ethernet::PPPOED;
}
// Dirty trick: Double Dot1Q is interpreted as Dot1AD
else if (type == PDU::DOT1Q) {
if (inner_pdu()->inner_pdu()) {
const PDUType inner_type = inner_pdu()->inner_pdu()->pdu_type();
if (inner_type == PDU::DOT1Q) {
flag = Constants::Ethernet::QINQ;
}
}
}
else {
flag = Internals::pdu_flag_to_ether_type(type);
}