static const unsigned char pkt0[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, // dst mac 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, // src mac 0x88, 0xA8, 0x00, 0x03, // 0x88A8, 0x0002 (PCP: 0, DEI: 0, VID: 3) 0x81, 0x00, 0x00, 0x02, // 0x8100, 0x0003 (PCP: 0, DEI: 0, VID: 2) 0x86, 0xdd, // TPID, TCI, ETHERTYPE (IPv6 == 0x86DD) 0xf8, 0xfe, 0x02, 0x03, 0x00, 0x80, 0x00, 0x00, 0x00, 0x0f, 0x01, 0xb0, 0x00, 0x11, 0x00, 0x00, 0x00, 0x07, 0xcd, 0xb9, 0x6c, 0xd0, 0x00, 0x56, 0x00, 0x00, 0x33, 0x33, 0x00, 0x00, 0x00, 0x61, 0x00, 0x50, 0xc2, 0xa9, 0xc0, 0x6b, 0x81, 0x00, 0x00, 0x02, 0x86, 0xdd, 0x60, 0x00, 0x00, 0x00, 0x00, 0x18, 0x11, 0x01, 0xfd, 0x53, 0x7c, 0xb8, 0x03, 0x83, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0f, 0xff, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x61, 0xa6, 0x3d, 0xa6, 0x3d, 0x00, 0x18, 0x01, 0xfd, 0x00, 0x00, 0x03, 0xa3, 0x00, 0x00, 0x00, 0x08, 0xd9, 0xe4, 0xff, 0xaf, 0x55, 0xf0, 0xff, 0xff, 0xaa, 0xf1, 0x22, 0x31 };
RawPacket oRawPacket(pkt0, sizeof pkt0, {0, 0}, false, LINKTYPE_ETHERNET); Packet oPacket(&oRawPacket, false, VLAN);
// optional VLAN
uint16_t ethertype = 0x86DD; const auto* const vlanLayer = packet.getLayerOfType<VlanLayer>(); if (vlanLayer) { const auto etherType = ntohs(vlanLayer->getVlanHeader()->etherType); REQUIRE(etherType == ethertype); } else { const auto etherType = ntohs(etherHeader->etherType); REQUIRE(etherType == ethertype); }
REQUIRE( etherType == ethertype )with expansion: 34984 == 34525
--
You received this message because you are subscribed to the Google Groups "PcapPlusPlus support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pcapplusplus-sup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pcapplusplus-support/7db2d124-a8ff-445e-934b-0c81e805e65fo%40googlegroups.com.
const auto* const outerVlan = static_cast<VlanLayer*>(oPacket.getLayerOfType(VLAN, 0)); const auto* const outerVlan2 = static_cast<VlanLayer*>(oPacket.getLayerOfType<VlanLayer>());
static const unsigned char pkt0[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, // dst mac 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, // src mac
0x88, 0xA8, 0x61, 0x23, // outer { TPID: 0x88A8, TCI: 0x6123 (PCP: 3, DEI: 0, VID: 291) } 0x81, 0x00, 0xA4, 0x56, // inner { TPID: 0x8100, TCI: 0xA456 (PCP: 5, DEI: 0, VID: 1110) }
0x86, 0xdd, // TPID, TCI, ETHERTYPE (IPv6 == 0x86DD) 0xf8, 0xfe, 0x02, 0x03, 0x00, 0x80, 0x00, 0x00, 0x00, 0x0f, 0x01, 0xb0, 0x00, 0x11, 0x00, 0x00, 0x00, 0x07, 0xcd, 0xb9, 0x6c, 0xd0, 0x00, 0x56, 0x00, 0x00, 0x33, 0x33, 0x00, 0x00, 0x00, 0x61, 0x00, 0x50, 0xc2, 0xa9, 0xc0, 0x6b, 0x81, 0x00, 0x00, 0x02, 0x86, 0xdd, 0x60, 0x00, 0x00, 0x00, 0x00, 0x18, 0x11, 0x01, 0xfd, 0x53, 0x7c, 0xb8, 0x03, 0x83, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0f, 0xff, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x61, 0xa6, 0x3d, 0xa6, 0x3d, 0x00, 0x18, 0x01, 0xfd, 0x00, 0x00, 0x03, 0xa3, 0x00, 0x00, 0x00, 0x08, 0xd9, 0xe4, 0xff, 0xaf, 0x55, 0xf0, 0xff, 0xff, 0xaa, 0xf1, 0x22, 0x31};
RawPacket oRawPacket(pkt0, sizeof pkt0, {0, 0}, false, LINKTYPE_ETHERNET); Packet oPacket(&oRawPacket, false, VLAN);
const auto* const ethernetLayer = static_cast<EthLayer*>(oPacket.getLayerOfType(Ethernet)); REQUIRE(ethernetLayer); const auto* const outerVlan = static_cast<VlanLayer*>(oPacket.getLayerOfType(VLAN, 0)); const auto* const outerVlan2 = static_cast<VlanLayer*>(oPacket.getLayerOfType<VlanLayer>()); REQUIRE(outerVlan); REQUIRE(outerVlan2); const auto* const innerVlan = static_cast<VlanLayer*>(oPacket.getLayerOfType(VLAN, 1)); REQUIRE(innerVlan);
REQUIRE(ethernetLayer->getEthHeader()->etherType == htons(0x88A8)); // double VLAN REQUIRE(outerVlan->getVlanHeader()->etherType == htons(0x8100)); // single VLAN REQUIRE(innerVlan->getVlanHeader()->etherType == htons(0x86dd)); // IPv6
#define PCPP_ETHERTYPE_VLAN 0x8100
Hi Rick,Double tagging should be supported. Are you trying to access the first or second vlan layer?Thanks,PcapPlusPlus maintainer
To unsubscribe from this group and stop receiving emails from it, send an email to pcapplusplus-support+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to pcapplusplus-sup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pcapplusplus-support/7db2d124-a8ff-445e-934b-0c81e805e65fo%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "PcapPlusPlus support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pcapplusplus-sup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pcapplusplus-support/051c1556-ad83-49e0-a347-46b4c9d5b721o%40googlegroups.com.