diff -r 0b8c6e883208 src/openflow/model/openflow-switch-net-device.cc --- a/src/openflow/model/openflow-switch-net-device.cc Mon Aug 31 10:41:05 2015 -0700 +++ b/src/openflow/model/openflow-switch-net-device.cc Mon Aug 31 13:57:59 2015 -0700 @@ -444,10 +444,11 @@ } ofpbuf * -OpenFlowSwitchNetDevice::BufferFromPacket (Ptr packet, Address src, Address dst, int mtu, uint16_t protocol) +OpenFlowSwitchNetDevice::BufferFromPacket (Ptr constPacket, Address src, Address dst, int mtu, uint16_t protocol) { NS_LOG_INFO ("Creating Openflow buffer from packet."); + Ptr packet = constPacket->Copy (); /* * Allocate buffer with some headroom to add headers in forwarding * to the controller or adding a vlan tag, plus an extra 2 bytes to @@ -470,6 +471,7 @@ src.CopyTo (eth_h->eth_src); // Source Mac Address eth_h->eth_type = htons (ETH_TYPE_IP); // Ether Type NS_LOG_INFO ("Parsed EthernetHeader"); + packet->RemoveHeader (eth_hd); l2_length = ETH_HEADER_LEN; } @@ -493,6 +495,7 @@ ip_h->ip_dst = htonl (ip_hd.GetDestination ().Get ()); // Destination Address ip_h->ip_csum = csum (&ip_h, sizeof ip_h); // Header Checksum NS_LOG_INFO ("Parsed Ipv4Header"); + packet->RemoveHeader (ip_hd); l3_length = IP_HEADER_LEN; } @@ -515,6 +518,7 @@ arp_h->ar_hln = sizeof arp_h->ar_tha; // Hardware address length. arp_h->ar_pln = sizeof arp_h->ar_tpa; // Protocol address length. NS_LOG_INFO ("Parsed ArpHeader"); + packet->RemoveHeader (arp_hd); l3_length = ARP_ETH_HEADER_LEN; } @@ -539,6 +543,7 @@ tcp_h->tcp_urg = tcp_hd.GetUrgentPointer (); // Urgent Pointer tcp_h->tcp_csum = csum (&tcp_h, sizeof tcp_h); // Header Checksum NS_LOG_INFO ("Parsed TcpHeader"); + packet->RemoveHeader (tcp_hd); l4_length = TCP_HEADER_LEN; } @@ -562,13 +567,14 @@ udp_csum = csum_continue (udp_csum, udp_h, sizeof udp_h); udp_h->udp_csum = csum_finish (csum_continue (udp_csum, buffer->data, buffer->size)); // Header Checksum NS_LOG_INFO ("Parsed UdpHeader"); + packet->RemoveHeader (udp_hd); l4_length = UDP_HEADER_LEN; } } } - // Load Packet data into buffer data + // Load any remaining packet data into buffer data packet->CopyData ((uint8_t*)buffer->data, packet->GetSize ()); if (buffer->l4) diff -r 0b8c6e883208 src/openflow/model/openflow-switch-net-device.h --- a/src/openflow/model/openflow-switch-net-device.h Mon Aug 31 10:41:05 2015 -0700 +++ b/src/openflow/model/openflow-switch-net-device.h Mon Aug 31 13:57:59 2015 -0700 @@ -272,7 +272,7 @@ * \param protocol The protocol defining the packet. * \return The OpenFlow Buffer created from the packet. */ - ofpbuf * BufferFromPacket (Ptr packet, Address src, Address dst, int mtu, uint16_t protocol); + ofpbuf * BufferFromPacket (Ptr packet, Address src, Address dst, int mtu, uint16_t protocol); private: /**