bug 868 - invalid packet size after Ipv4L3Protocol::Send
authorHajime Tazaki <tazaki@sfc.wide.ad.jp>
Thu, 08 Apr 2010 23:01:34 +0900
changeset 6182 9e060dd421fa
parent 6181 05727a89b220
child 6183 8a5e1f9db873
bug 868 - invalid packet size after Ipv4L3Protocol::Send
RELEASE_NOTES
src/internet-stack/ipv4-l3-protocol.cc
src/internet-stack/ipv4-raw-test.cc
--- a/RELEASE_NOTES	Thu Apr 08 22:51:09 2010 +0900
+++ b/RELEASE_NOTES	Thu Apr 08 23:01:34 2010 +0900
@@ -110,6 +110,7 @@
    - bug 865 - Ipv4RawSocketImpl::RecvFrom does not return from address all the time.
    - bug 859 - Output interface estimation for the source address bound socket in IPv4 Raw socket
    - bug 857 - Link-Local Multicast handle in Ipv4 Output processing 
+   - bug 868 - invalid packet size after Ipv4L3Protocol::Send
 
 Known issues
 ------------
--- a/src/internet-stack/ipv4-l3-protocol.cc	Thu Apr 08 22:51:09 2010 +0900
+++ b/src/internet-stack/ipv4-l3-protocol.cc	Thu Apr 08 23:01:34 2010 +0900
@@ -594,7 +594,7 @@
       ipHeader = BuildHeader (source, destination, protocol, packet->GetSize (), ttl, mayFragment);
       int32_t interface = GetInterfaceForDevice (route->GetOutputDevice ());
       m_sendOutgoingTrace (ipHeader, packet, interface);
-      SendRealOut (route, packet, ipHeader);
+      SendRealOut (route, packet->Copy (), ipHeader);
       return; 
     } 
   // 4) packet is not broadcast, and is passed in with a route entry but route->GetGateway is not set (e.g., on-demand)
@@ -624,7 +624,7 @@
     {
       int32_t interface = GetInterfaceForDevice (newRoute->GetOutputDevice ());
       m_sendOutgoingTrace (ipHeader, packet, interface);
-      SendRealOut (newRoute, packet, ipHeader);
+      SendRealOut (newRoute, packet->Copy (), ipHeader);
     }
   else
     {
--- a/src/internet-stack/ipv4-raw-test.cc	Thu Apr 08 22:51:09 2010 +0900
+++ b/src/internet-stack/ipv4-raw-test.cc	Thu Apr 08 23:01:34 2010 +0900
@@ -120,9 +120,8 @@
 Ipv4RawSocketImplTest::DoSendData (Ptr<Socket> socket, std::string to)
 {
   Address realTo = InetSocketAddress (Ipv4Address(to.c_str()), 0);
-  socket->SendTo (Create<Packet> (123), 0, realTo);
-  // NS_TEST_EXPECT_MSG_NE (socket->SendTo (Create<Packet> (123), 0, realTo),
-  //                        -1, to);
+  NS_TEST_EXPECT_MSG_EQ (socket->SendTo (Create<Packet> (123), 0, realTo),
+                         123, to);
 }
 
 void
@@ -205,7 +204,7 @@
   // Create the IPv4 Raw sockets
   Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<Ipv4RawSocketFactory> ();
   Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket ();
-  NS_TEST_EXPECT_MSG_EQ (rxSocket->Bind (InetSocketAddress (Ipv4Address ("0.0.0.0.0"), 0)), 0, "trivial");
+  NS_TEST_EXPECT_MSG_EQ (rxSocket->Bind (InetSocketAddress (Ipv4Address ("0.0.0.0"), 0)), 0, "trivial");
   rxSocket->SetRecvCallback (MakeCallback (&Ipv4RawSocketImplTest::ReceivePkt, this));
 
   Ptr<Socket> rxSocket2 = rxSocketFactory->CreateSocket ();
@@ -230,7 +229,7 @@
 
   SendData (txSocket, "255.255.255.255");
   NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 143, "recv: 255.255.255.255");
-  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket2->GetSize (), 143, "second socket should not receive it (it is bound specifically to the second interface's address");
+  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket2->GetSize (), 0, "second socket should not receive it (it is bound specifically to the second interface's address");
 
   m_receivedPacket->RemoveAllByteTags ();
   m_receivedPacket2->RemoveAllByteTags ();
@@ -240,9 +239,7 @@
 
   txSocket->Bind (InetSocketAddress (Ipv4Address ("10.0.0.2"), 0));
   SendData (txSocket, "224.0.0.9");
-#if 0
   NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 143, "recv: 224.0.0.9");
-#endif
   NS_TEST_EXPECT_MSG_EQ (m_receivedPacket2->GetSize (), 0, "second socket should not receive it (it is bound specifically to the second interface's address");
 
   m_receivedPacket->RemoveAllByteTags ();