bug 2157: OpenFlowSwitchNetDevice::BufferFromPacket setting eth_type incorrectly (patch due to Kang Chen)
authorTom Henderson <tomh@tomh.org>
Wed, 02 Sep 2015 16:37:05 -0700
changeset 11627 01fcacb5eedf
parent 11626 6174db6ec156
child 11628 243b71de25a0
bug 2157: OpenFlowSwitchNetDevice::BufferFromPacket setting eth_type incorrectly (patch due to Kang Chen)
src/openflow/model/openflow-switch-net-device.cc
--- a/src/openflow/model/openflow-switch-net-device.cc	Wed Sep 02 16:32:46 2015 -0700
+++ b/src/openflow/model/openflow-switch-net-device.cc	Wed Sep 02 16:37:05 2015 -0700
@@ -466,7 +466,18 @@
   eth_header* eth_h = (eth_header*)buffer->l2;
   dst.CopyTo (eth_h->eth_dst);              // Destination Mac Address
   src.CopyTo (eth_h->eth_src);              // Source Mac Address
-  eth_h->eth_type = htons (ETH_TYPE_IP);    // Ether Type
+  if (protocol == ArpL3Protocol::PROT_NUMBER)
+    {
+      eth_h->eth_type = htons (ETH_TYPE_ARP);    // Ether Type
+    }
+  else if (protocol == Ipv4L3Protocol::PROT_NUMBER)
+    {
+      eth_h->eth_type = htons (ETH_TYPE_IP);    // Ether Type
+    }
+  else
+    {
+      NS_LOG_WARN ("Protocol unsupported: " << protocol);
+    }
   NS_LOG_INFO ("Parsed EthernetHeader");
 
   l2_length = ETH_HEADER_LEN;