|
120 |
Ipv4RawSocketImplTest::DoSendData (Ptr<Socket> socket, std::string to) |
120 |
Ipv4RawSocketImplTest::DoSendData (Ptr<Socket> socket, std::string to) |
121 |
{ |
121 |
{ |
122 |
Address realTo = InetSocketAddress (Ipv4Address(to.c_str()), 0); |
122 |
Address realTo = InetSocketAddress (Ipv4Address(to.c_str()), 0); |
123 |
socket->SendTo (Create<Packet> (123), 0, realTo); |
123 |
NS_TEST_EXPECT_MSG_EQ (socket->SendTo (Create<Packet> (123), 0, realTo), |
124 |
// NS_TEST_EXPECT_MSG_NE (socket->SendTo (Create<Packet> (123), 0, realTo), |
124 |
123, to); |
125 |
// -1, to); |
|
|
126 |
} |
125 |
} |
127 |
|
126 |
|
128 |
void |
127 |
void |
|
205 |
// Create the IPv4 Raw sockets |
204 |
// Create the IPv4 Raw sockets |
206 |
Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<Ipv4RawSocketFactory> (); |
205 |
Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<Ipv4RawSocketFactory> (); |
207 |
Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket (); |
206 |
Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket (); |
208 |
NS_TEST_EXPECT_MSG_EQ (rxSocket->Bind (InetSocketAddress (Ipv4Address ("0.0.0.0.0"), 0)), 0, "trivial"); |
207 |
NS_TEST_EXPECT_MSG_EQ (rxSocket->Bind (InetSocketAddress (Ipv4Address ("0.0.0.0"), 0)), 0, "trivial"); |
209 |
rxSocket->SetRecvCallback (MakeCallback (&Ipv4RawSocketImplTest::ReceivePkt, this)); |
208 |
rxSocket->SetRecvCallback (MakeCallback (&Ipv4RawSocketImplTest::ReceivePkt, this)); |
210 |
|
209 |
|
211 |
Ptr<Socket> rxSocket2 = rxSocketFactory->CreateSocket (); |
210 |
Ptr<Socket> rxSocket2 = rxSocketFactory->CreateSocket (); |
|
230 |
|
229 |
|
231 |
SendData (txSocket, "255.255.255.255"); |
230 |
SendData (txSocket, "255.255.255.255"); |
232 |
NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 143, "recv: 255.255.255.255"); |
231 |
NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 143, "recv: 255.255.255.255"); |
233 |
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"); |
232 |
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"); |
234 |
|
233 |
|
235 |
m_receivedPacket->RemoveAllByteTags (); |
234 |
m_receivedPacket->RemoveAllByteTags (); |
236 |
m_receivedPacket2->RemoveAllByteTags (); |
235 |
m_receivedPacket2->RemoveAllByteTags (); |
|
240 |
|
239 |
|
241 |
txSocket->Bind (InetSocketAddress (Ipv4Address ("10.0.0.2"), 0)); |
240 |
txSocket->Bind (InetSocketAddress (Ipv4Address ("10.0.0.2"), 0)); |
242 |
SendData (txSocket, "224.0.0.9"); |
241 |
SendData (txSocket, "224.0.0.9"); |
243 |
#if 0 |
|
|
244 |
NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 143, "recv: 224.0.0.9"); |
242 |
NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 143, "recv: 224.0.0.9"); |
245 |
#endif |
|
|
246 |
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"); |
243 |
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"); |
247 |
|
244 |
|
248 |
m_receivedPacket->RemoveAllByteTags (); |
245 |
m_receivedPacket->RemoveAllByteTags (); |