From 3634c939cee25c482626acb3ac1539d9d282af65 Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Wed, 2 Sep 2015 16:37:05 -0700 Subject: [PATCH] bug 2157: OpenFlowSwitchNetDevice::BufferFromPacket setting eth_type incorrectly (patch due to Kang Chen) --- src/openflow/model/openflow-switch-net-device.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/openflow/model/openflow-switch-net-device.cc b/src/openflow/model/openflow-switch-net-device.cc index 27a4508ee..b9b3bba7c 100644 --- a/src/openflow/model/openflow-switch-net-device.cc +++ b/src/openflow/model/openflow-switch-net-device.cc @@ -466,7 +466,18 @@ OpenFlowSwitchNetDevice::BufferFromPacket (Ptr constPacket, Addres 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;