update testcase to deal with the return value of Socket::Send. Make sure udp packets are copied before going down the ip stack.
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Tue, 15 Apr 2008 10:49:09 -0700
changeset 2914 5092e8290b9b
parent 2913 66dd24c80d75
child 2915 3573d91994cc
update testcase to deal with the return value of Socket::Send. Make sure udp packets are copied before going down the ip stack.
src/internet-node/udp-socket.cc
--- a/src/internet-node/udp-socket.cc	Tue Apr 15 10:09:42 2008 -0700
+++ b/src/internet-node/udp-socket.cc	Tue Apr 15 10:49:09 2008 -0700
@@ -305,7 +305,7 @@
   else if (ipv4->GetIfIndexForDestination(dest, localIfIndex))
     {
       NS_LOG_LOGIC ("Route exists");
-      m_udp->Send (p, ipv4->GetAddress (localIfIndex), dest,
+      m_udp->Send (p->Copy (), ipv4->GetAddress (localIfIndex), dest,
 		   m_endPoint->GetLocalPort (), port);
       NotifyDataSent (p->GetSize ());
       return p->GetSize();;
@@ -479,7 +479,7 @@
   m_receivedPacket = Create<Packet> ();
   m_receivedPacket2 = Create<Packet> ();
   NS_TEST_ASSERT_EQUAL (txSocket->SendTo (InetSocketAddress (Ipv4Address("10.0.0.1"), 1234),
-                                          Create<Packet> (123)), 0);
+                                          Create<Packet> (123)), 123);
   Simulator::Run ();
   NS_TEST_ASSERT_EQUAL (m_receivedPacket->GetSize (), 123);
   NS_TEST_ASSERT_EQUAL (m_receivedPacket2->GetSize (), 0); // second interface should receive it
@@ -490,7 +490,7 @@
   m_receivedPacket = Create<Packet> ();
   m_receivedPacket2 = Create<Packet> ();
   NS_TEST_ASSERT_EQUAL (txSocket->SendTo (InetSocketAddress (Ipv4Address("255.255.255.255"), 1234),
-                                          Create<Packet> (123)), 0);
+                                          Create<Packet> (123)), 123);
   Simulator::Run ();
   NS_TEST_ASSERT_EQUAL (m_receivedPacket->GetSize (), 123);
   // second socket should not receive it (it is bound specifically to the second interface's address
@@ -510,7 +510,7 @@
   m_receivedPacket = Create<Packet> ();
   m_receivedPacket2 = Create<Packet> ();
   NS_TEST_ASSERT_EQUAL (txSocket->SendTo (InetSocketAddress (Ipv4Address("255.255.255.255"), 1234),
-                                          Create<Packet> (123)), 0);
+                                          Create<Packet> (123)), 123);
   Simulator::Run ();
   NS_TEST_ASSERT_EQUAL (m_receivedPacket->GetSize (), 123);
   NS_TEST_ASSERT_EQUAL (m_receivedPacket2->GetSize (), 123);