nsc: make sure nsc has a configured interface
the receive method hands packets to the nsc core via
nsc's if_receive_packet() method.
NSC (rightfully) assumes that if it gets a packet, there must
be a network interface. However, at this time the interface
initialization in ns-3-nsc is done when the first socket is created.
The result is a segmentation fault inside nsc when ns-3 receives
a packet on an nsc-enabled node before a socked has been created
on that node.
For the time being, use NS_ASSERT to make sure the nsc interface exits.
This also gets rid of the NS_LOG use inside the Softinterrupt timer
method and replaces
NS_LOG_FUNCTION_NOARGS with NS_LOG_FUNCTION (this), as suggested by
Mathieu Lacage.
--- a/src/internet-stack/nsc-tcp-l4-protocol.cc Mon Sep 22 10:36:24 2008 -0700
+++ b/src/internet-stack/nsc-tcp-l4-protocol.cc Mon Sep 22 22:18:53 2008 +0200
@@ -86,13 +86,12 @@
m_softTimer (Timer::CANCEL_ON_DESTROY)
{
m_dlopenHandle = NULL;
- NS_LOG_FUNCTION_NOARGS ();
NS_LOG_LOGIC("Made a NscTcpL4Protocol "<<this);
}
NscTcpL4Protocol::~NscTcpL4Protocol ()
{
- NS_LOG_FUNCTION_NOARGS ();
+ NS_LOG_FUNCTION (this);
dlclose(m_dlopenHandle);
}
@@ -151,7 +150,7 @@
void
NscTcpL4Protocol::DoDispose (void)
{
- NS_LOG_FUNCTION_NOARGS ();
+ NS_LOG_FUNCTION (this);
if (m_endPoints != 0)
{
delete m_endPoints;
@@ -164,7 +163,7 @@
Ptr<Socket>
NscTcpL4Protocol::CreateSocket (void)
{
- NS_LOG_FUNCTION_NOARGS ();
+ NS_LOG_FUNCTION (this);
if (!m_nscInterfacesSetUp)
{
Ptr<Ipv4> ip = m_node->GetObject<Ipv4> ();
@@ -229,7 +228,7 @@
Ipv4EndPoint *
NscTcpL4Protocol::Allocate (void)
{
- NS_LOG_FUNCTION_NOARGS ();
+ NS_LOG_FUNCTION (this);
return m_endPoints->Allocate ();
}
@@ -298,6 +297,7 @@
const uint8_t *data = const_cast<uint8_t *>(packet->PeekData());
+ NS_ASSERT_MSG (m_nscInterfacesSetUp, "got packet, but no listening sockets (and no interface)");
// deliver complete packet to the NSC network stack
m_nscStack->if_receive_packet(0, data, packetSize);
wakeup ();
@@ -305,7 +305,6 @@
void NscTcpL4Protocol::SoftInterrupt (void)
{
- NS_LOG_FUNCTION_NOARGS ();
m_nscStack->timer_interrupt ();
m_nscStack->increment_ticks ();
m_softTimer.Schedule ();