View | Details | Raw Unified | Return to bug 1557
Collapse All | Expand All

(-)a/src/openflow/model/openflow-switch-net-device.cc (-2 / +8 lines)
 Lines 444-453    Link Here 
444
}
444
}
445
445
446
ofpbuf *
446
ofpbuf *
447
OpenFlowSwitchNetDevice::BufferFromPacket (Ptr<Packet> packet, Address src, Address dst, int mtu, uint16_t protocol)
447
OpenFlowSwitchNetDevice::BufferFromPacket (Ptr<const Packet> constPacket, Address src, Address dst, int mtu, uint16_t protocol)
448
{
448
{
449
  NS_LOG_INFO ("Creating Openflow buffer from packet.");
449
  NS_LOG_INFO ("Creating Openflow buffer from packet.");
450
450
451
  Ptr<Packet> packet = constPacket->Copy ();
451
  /*
452
  /*
452
   * Allocate buffer with some headroom to add headers in forwarding
453
   * Allocate buffer with some headroom to add headers in forwarding
453
   * to the controller or adding a vlan tag, plus an extra 2 bytes to
454
   * to the controller or adding a vlan tag, plus an extra 2 bytes to
 Lines 470-475    Link Here 
470
      src.CopyTo (eth_h->eth_src);              // Source Mac Address
471
      src.CopyTo (eth_h->eth_src);              // Source Mac Address
471
      eth_h->eth_type = htons (ETH_TYPE_IP);    // Ether Type
472
      eth_h->eth_type = htons (ETH_TYPE_IP);    // Ether Type
472
      NS_LOG_INFO ("Parsed EthernetHeader");
473
      NS_LOG_INFO ("Parsed EthernetHeader");
474
      packet->RemoveHeader (eth_hd);
473
475
474
      l2_length = ETH_HEADER_LEN;
476
      l2_length = ETH_HEADER_LEN;
475
    }
477
    }
 Lines 493-498    Link Here 
493
          ip_h->ip_dst      = htonl (ip_hd.GetDestination ().Get ()); // Destination Address
495
          ip_h->ip_dst      = htonl (ip_hd.GetDestination ().Get ()); // Destination Address
494
          ip_h->ip_csum     = csum (&ip_h, sizeof ip_h);        // Header Checksum
496
          ip_h->ip_csum     = csum (&ip_h, sizeof ip_h);        // Header Checksum
495
          NS_LOG_INFO ("Parsed Ipv4Header");
497
          NS_LOG_INFO ("Parsed Ipv4Header");
498
          packet->RemoveHeader (ip_hd);
496
499
497
          l3_length = IP_HEADER_LEN;
500
          l3_length = IP_HEADER_LEN;
498
        }
501
        }
 Lines 515-520    Link Here 
515
          arp_h->ar_hln = sizeof arp_h->ar_tha;                         // Hardware address length.
518
          arp_h->ar_hln = sizeof arp_h->ar_tha;                         // Hardware address length.
516
          arp_h->ar_pln = sizeof arp_h->ar_tpa;                         // Protocol address length.
519
          arp_h->ar_pln = sizeof arp_h->ar_tpa;                         // Protocol address length.
517
          NS_LOG_INFO ("Parsed ArpHeader");
520
          NS_LOG_INFO ("Parsed ArpHeader");
521
          packet->RemoveHeader (arp_hd);
518
522
519
          l3_length = ARP_ETH_HEADER_LEN;
523
          l3_length = ARP_ETH_HEADER_LEN;
520
        }
524
        }
 Lines 539-544    Link Here 
539
              tcp_h->tcp_urg = tcp_hd.GetUrgentPointer ();      // Urgent Pointer
543
              tcp_h->tcp_urg = tcp_hd.GetUrgentPointer ();      // Urgent Pointer
540
              tcp_h->tcp_csum = csum (&tcp_h, sizeof tcp_h);    // Header Checksum
544
              tcp_h->tcp_csum = csum (&tcp_h, sizeof tcp_h);    // Header Checksum
541
              NS_LOG_INFO ("Parsed TcpHeader");
545
              NS_LOG_INFO ("Parsed TcpHeader");
546
              packet->RemoveHeader (tcp_hd);
542
547
543
              l4_length = TCP_HEADER_LEN;
548
              l4_length = TCP_HEADER_LEN;
544
            }
549
            }
 Lines 562-574    Link Here 
562
              udp_csum = csum_continue (udp_csum, udp_h, sizeof udp_h);
567
              udp_csum = csum_continue (udp_csum, udp_h, sizeof udp_h);
563
              udp_h->udp_csum = csum_finish (csum_continue (udp_csum, buffer->data, buffer->size)); // Header Checksum
568
              udp_h->udp_csum = csum_finish (csum_continue (udp_csum, buffer->data, buffer->size)); // Header Checksum
564
              NS_LOG_INFO ("Parsed UdpHeader");
569
              NS_LOG_INFO ("Parsed UdpHeader");
570
              packet->RemoveHeader (udp_hd);
565
571
566
              l4_length = UDP_HEADER_LEN;
572
              l4_length = UDP_HEADER_LEN;
567
            }
573
            }
568
        }
574
        }
569
    }
575
    }
570
576
571
  // Load Packet data into buffer data
577
  // Load any remaining packet data into buffer data
572
  packet->CopyData ((uint8_t*)buffer->data, packet->GetSize ());
578
  packet->CopyData ((uint8_t*)buffer->data, packet->GetSize ());
573
579
574
  if (buffer->l4)
580
  if (buffer->l4)
(-)a/src/openflow/model/openflow-switch-net-device.h (-1 / +1 lines)
 Lines 272-278    Link Here 
272
   * \param protocol The protocol defining the packet.
272
   * \param protocol The protocol defining the packet.
273
   * \return The OpenFlow Buffer created from the packet.
273
   * \return The OpenFlow Buffer created from the packet.
274
   */
274
   */
275
  ofpbuf * BufferFromPacket (Ptr<Packet> packet, Address src, Address dst, int mtu, uint16_t protocol);
275
  ofpbuf * BufferFromPacket (Ptr<const Packet> packet, Address src, Address dst, int mtu, uint16_t protocol);
276
276
277
private:
277
private:
278
  /**
278
  /**

Return to bug 1557