src/internet-node/ipv4-l3-protocol.cc
changeset 1866 e7dbcc4df546
parent 1524 3ead2b66f2e4
child 1867 16deaedc0380
--- a/src/internet-node/ipv4-l3-protocol.cc	Mon Oct 01 14:14:31 2007 +0200
+++ b/src/internet-node/ipv4-l3-protocol.cc	Mon Oct 01 14:15:56 2007 +0200
@@ -201,17 +201,17 @@
   Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
   resolver->AddSource ("tx", 
                        TraceDoc ("send ipv4 packet to outgoing interface",
-                                 "const Packet &", "packet sent",
+                                 "Ptr<const Packet>", "packet sent",
                                  "uint32_t", "index of output ipv4 interface"),
                        m_txTrace, Ipv4L3ProtocolTraceContextElement(Ipv4L3ProtocolTraceContextElement::TX));
   resolver->AddSource ("rx",
                        TraceDoc ("receive ipv4 packet from incoming interface",
-                                 "const Packet &", "packet received",
+                                 "Ptr<const Packet>", "packet received",
                                  "uint32_t", "index of input ipv4 interface"),
                        m_rxTrace, Ipv4L3ProtocolTraceContextElement(Ipv4L3ProtocolTraceContextElement::RX));
   resolver->AddSource ("drop", 
                        TraceDoc ("drop ipv4 packet",
-                                 "const Packet &", "packet dropped"),
+                                 "Ptr<const Packet>", "packet dropped"),
                        m_dropTrace, Ipv4L3ProtocolTraceContextElement (Ipv4L3ProtocolTraceContextElement::DROP));
   resolver->AddArray ("interfaces", 
                       m_interfaces.begin (), m_interfaces.end (), 
@@ -281,11 +281,11 @@
 void
 Ipv4L3Protocol::Lookup (
   Ipv4Header const &ipHeader,
-  Packet packet,
+  Ptr<Packet> packet,
   Ipv4RoutingProtocol::RouteReplyCallback routeReply)
 {
   NS_LOG_FUNCTION;
-  NS_LOG_PARAM ("(" << &ipHeader << ", " << &packet << &routeReply << ")");
+  NS_LOG_PARAM ("(" << &ipHeader << ", " << packet << &routeReply << ")");
 
   Lookup (Ipv4RoutingProtocol::IF_INDEX_ANY, ipHeader, packet, routeReply);
 }
@@ -294,11 +294,11 @@
 Ipv4L3Protocol::Lookup (
   uint32_t ifIndex,
   Ipv4Header const &ipHeader,
-  Packet packet,
+  Ptr<Packet> packet,
   Ipv4RoutingProtocol::RouteReplyCallback routeReply)
 {
   NS_LOG_FUNCTION;
-  NS_LOG_PARAM ("(" << ifIndex << ", " << &ipHeader << ", " << &packet << 
+  NS_LOG_PARAM ("(" << ifIndex << ", " << &ipHeader << ", " << packet << 
     &routeReply << ")");
 
   for (Ipv4RoutingProtocolList::const_iterator rprotoIter = 
@@ -537,10 +537,10 @@
 }  
 
 void 
-Ipv4L3Protocol::Receive( Ptr<NetDevice> device, const Packet& p, uint16_t protocol, const Address &from)
+Ipv4L3Protocol::Receive( Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol, const Address &from)
 {
   NS_LOG_FUNCTION;
-  NS_LOG_PARAM ("(" << &device << ", " << &p << ", " << protocol << ", " << 
+  NS_LOG_PARAM ("(" << &device << ", " << packet << ", " << protocol << ", " << 
     from << ")");
 
   NS_LOG_LOGIC ("Packet from " << from);
@@ -554,14 +554,13 @@
       ipv4Interface = *i;
       if (ipv4Interface->GetDevice () == device)
         {
-          m_rxTrace (p, index);
+          m_rxTrace (packet, index);
           break;
         }
       index++;
     }
-  Packet packet = p;
   Ipv4Header ipHeader;
-  packet.RemoveHeader (ipHeader);
+  packet->RemoveHeader (ipHeader);
 
   if (!ipHeader.IsChecksumOk ()) 
     {
@@ -579,13 +578,13 @@
 
 
 void 
-Ipv4L3Protocol::Send (Packet const &packet, 
+Ipv4L3Protocol::Send (Ptr<Packet> packet, 
             Ipv4Address source, 
             Ipv4Address destination,
             uint8_t protocol)
 {
   NS_LOG_FUNCTION;
-  NS_LOG_PARAM ("(" << &packet << ", " << source << ", " << ", " << 
+  NS_LOG_PARAM ("(" << packet << ", " << source << ", " << ", " << 
     destination << ", " << protocol << ")");
 
   Ipv4Header ipHeader;
@@ -593,7 +592,7 @@
   ipHeader.SetSource (source);
   ipHeader.SetDestination (destination);
   ipHeader.SetProtocol (protocol);
-  ipHeader.SetPayloadSize (packet.GetSize ());
+  ipHeader.SetPayloadSize (packet->GetSize ());
   ipHeader.SetTtl (m_defaultTtl);
   ipHeader.SetMayFragment ();
   ipHeader.SetIdentification (m_identification);
@@ -607,10 +606,10 @@
            ifaceIter != m_interfaces.end (); ifaceIter++, ifaceIndex++)
         {
           Ptr<Ipv4Interface> outInterface = *ifaceIter;
-          Packet packetCopy = packet;
+          Ptr<Packet> packetCopy = packet->Copy ();
 
-          NS_ASSERT (packetCopy.GetSize () <= outInterface->GetMtu ());
-          packetCopy.AddHeader (ipHeader);
+          NS_ASSERT (packetCopy->GetSize () <= outInterface->GetMtu ());
+          packetCopy->AddHeader (ipHeader);
           m_txTrace (packetCopy, ifaceIndex);
           outInterface->Send (packetCopy, destination);
         }
@@ -633,11 +632,11 @@
 void
 Ipv4L3Protocol::SendRealOut (bool found,
                              Ipv4Route const &route,
-                             Packet packet,
+                             Ptr<Packet> packet,
                              Ipv4Header const &ipHeader)
 {
   NS_LOG_FUNCTION;
-  NS_LOG_PARAM ("(" << found << ", " << &route << ", " << &packet << 
+  NS_LOG_PARAM ("(" << found << ", " << &route << ", " << packet << 
     &ipHeader << ")");
 
   if (!found)
@@ -649,9 +648,9 @@
 
   NS_LOG_LOGIC ("Send via interface " << route.GetInterface ());
 
-  packet.AddHeader (ipHeader);
+  packet->AddHeader (ipHeader);
   Ptr<Ipv4Interface> outInterface = GetInterface (route.GetInterface ());
-  NS_ASSERT (packet.GetSize () <= outInterface->GetMtu ());
+  NS_ASSERT (packet->GetSize () <= outInterface->GetMtu ());
   m_txTrace (packet, route.GetInterface ());
   if (route.IsGateway ()) 
     {
@@ -668,12 +667,12 @@
 bool
 Ipv4L3Protocol::Forwarding (
   uint32_t ifIndex, 
-  Packet const &packet, 
+  Ptr<Packet> packet, 
   Ipv4Header &ipHeader, 
   Ptr<NetDevice> device)
 {
   NS_LOG_FUNCTION;
-  NS_LOG_PARAM ("(" << ifIndex << ", " << &packet << ", " << &ipHeader << 
+  NS_LOG_PARAM ("(" << ifIndex << ", " << packet << ", " << &ipHeader << 
     ", " << device << ")");
 
   for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin ();
@@ -747,11 +746,11 @@
 }
 
 void
-Ipv4L3Protocol::ForwardUp (Packet p, Ipv4Header const&ip,
+Ipv4L3Protocol::ForwardUp (Ptr<Packet> p, Ipv4Header const&ip,
                            Ptr<Ipv4Interface> incomingInterface)
 {
   NS_LOG_FUNCTION;
-  NS_LOG_PARAM ("(" << &p << ", " << &ip << ")");
+  NS_LOG_PARAM ("(" << p << ", " << &ip << ")");
 
   Ptr<Ipv4L4Demux> demux = m_node->QueryInterface<Ipv4L4Demux> (Ipv4L4Demux::iid);
   Ptr<Ipv4L4Protocol> protocol = demux->GetProtocol (ip.GetProtocol ());