Utils/Logger: BUGFIX: add SENF_LOG_TPL variants which work with templatized log param...
[senf.git] / Packets / DefaultBundle / EthernetPacket.test.cc
index 529d317..397f6f5 100644 (file)
@@ -27,7 +27,7 @@
 
 // Custom includes
 #include "EthernetPacket.hh"
-#include "Packets/DataPacket.hh"
+#include "IpV4Packet.hh"
 
 #include <boost/test/auto_unit_test.hpp>
 #include <boost/test/test_tools.hpp>
@@ -37,7 +37,7 @@
 
 BOOST_AUTO_UNIT_TEST(ethernetPacket_packet)
 {
-    senf::EthernetPacket::byte data[] = 
+    senf::PacketData::byte data[] = 
         { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,  // destination MAC
           0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,  // source MAC
           0x10, 0x11 };                        // EtherType
@@ -69,6 +69,26 @@ BOOST_AUTO_UNIT_TEST(ethernetPacket_chain)
     BOOST_CHECK_EQUAL( *v.next().data().begin(), 0xf0 );
 }
 
+BOOST_AUTO_UNIT_TEST(ethernetPacket_create)
+{
+    senf::EthernetPacket eth (senf::EthernetPacket::create());
+    eth->source() = senf::MACAddress::from_string("01:02:03:04:05:06");
+    eth->destination() = senf::MACAddress::from_string("07:08:09:0a:0b:0c");
+    
+    senf::EthVLanPacket vlan (senf::EthVLanPacket::createAfter(eth));
+    vlan->priority() = 9u;
+    vlan->cfi() = true;
+    vlan->vlanId() = 0x234u;
+
+    eth.finalize();
+    BOOST_CHECK_EQUAL(eth->type(), 0x8100u);
+    BOOST_CHECK_EQUAL(vlan->type(), 0u);
+
+    senf::IpV4Packet ip (senf::IpV4Packet::createAfter(vlan));
+    eth.finalize();
+    BOOST_CHECK_EQUAL(vlan->type(), 0x0800u);
+}
+
 ///////////////////////////////cc.e////////////////////////////////////////
 #undef prefix_