--- a/src/internet-stack/ipv4-l3-protocol.cc Tue Feb 09 10:40:54 2010 +0100
+++ b/src/internet-stack/ipv4-l3-protocol.cc Wed Feb 10 11:03:32 2010 +0100
@@ -482,6 +482,7 @@
socket->ForwardUp (packet, ipHeader, device);
}
+ NS_ASSERT_MSG (m_routingProtocol != 0, "Need a routing protocol object to process packets");
m_routingProtocol->RouteInput (packet, ipHeader, device,
MakeCallback (&Ipv4L3Protocol::IpForward, this),
MakeCallback (&Ipv4L3Protocol::IpMulticastForward, this),
@@ -609,7 +610,15 @@
Socket::SocketErrno errno_;
Ptr<NetDevice> oif (0); // unused for now
ipHeader = BuildHeader (source, destination, protocol, packet->GetSize (), ttl, mayFragment);
- Ptr<Ipv4Route> newRoute = m_routingProtocol->RouteOutput (packet, ipHeader, oif, errno_);
+ Ptr<Ipv4Route> newRoute;
+ if (m_routingProtocol != 0)
+ {
+ newRoute = m_routingProtocol->RouteOutput (packet, ipHeader, oif, errno_);
+ }
+ else
+ {
+ NS_LOG_ERROR ("Ipv4L3Protocol::Send: m_routingProtocol == 0");
+ }
if (newRoute)
{
int32_t interface = GetInterfaceForDevice (newRoute->GetOutputDevice ());
--- a/src/internet-stack/tcp-l4-protocol.cc Tue Feb 09 10:40:54 2010 +0100
+++ b/src/internet-stack/tcp-l4-protocol.cc Wed Feb 10 11:03:32 2010 +0100
@@ -584,7 +584,15 @@
Socket::SocketErrno errno_;
Ptr<Ipv4Route> route;
Ptr<NetDevice> oif (0); //specify non-zero if bound to a source address
- route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_);
+ if (ipv4->GetRoutingProtocol () != 0)
+ {
+ route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_);
+ }
+ else
+ {
+ NS_LOG_ERROR ("No IPV4 Routing Protocol");
+ route = 0;
+ }
ipv4->Send (packet, saddr, daddr, PROT_NUMBER, route);
}
}
@@ -623,7 +631,15 @@
header.SetProtocol (PROT_NUMBER);
Socket::SocketErrno errno_;
Ptr<Ipv4Route> route;
- route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_);
+ if (ipv4->GetRoutingProtocol () != 0)
+ {
+ route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_);
+ }
+ else
+ {
+ NS_LOG_ERROR ("No IPV4 Routing Protocol");
+ route = 0;
+ }
ipv4->Send (packet, saddr, daddr, PROT_NUMBER, route);
}
else
--- a/src/internet-stack/tcp-socket-impl.cc Tue Feb 09 10:40:54 2010 +0100
+++ b/src/internet-stack/tcp-socket-impl.cc Wed Feb 10 11:03:32 2010 +0100
@@ -358,6 +358,7 @@
NS_LOG_FUNCTION (this << address);
Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4> ();
+ NS_ASSERT (ipv4 != 0);
if (m_endPoint == 0)
{
@@ -772,11 +773,17 @@
Ptr<Packet> p = Create<Packet> ();
TcpHeader header;
+ if (m_endPoint == 0)
+ {
+ NS_LOG_WARN ("Failed to send empty packet due to null endpoint");
+ return;
+ }
+
if (flags & TcpHeader::FIN)
{
flags |= TcpHeader::ACK;
}
-
+
header.SetFlags (flags);
header.SetSequenceNumber (m_nextTxSequence);
header.SetAckNumber (m_nextRxSequence);
@@ -811,9 +818,12 @@
SendEmptyPacket(TcpHeader::RST);
NotifyErrorClose();
CancelAllTimers();
- m_endPoint->SetDestroyCallback(MakeNullCallback<void>());
- m_tcp->DeAllocate (m_endPoint);
- m_endPoint = 0;
+ if (m_endPoint != 0)
+ {
+ m_endPoint->SetDestroyCallback(MakeNullCallback<void>());
+ m_tcp->DeAllocate (m_endPoint);
+ m_endPoint = 0;
+ }
}
@@ -1093,6 +1103,11 @@
{
return false; // No data exists
}
+ if (m_endPoint == 0)
+ {
+ NS_LOG_INFO ("TcpSocketImpl::SendPendingData: No endpoint; m_shutdownSend=" << m_shutdownSend);
+ return false; // Is this the right way to handle this condition?
+ }
uint32_t nPacketsSent = 0;
while (m_pendingData->SizeFromSeq (m_firstPendingSequence, m_nextTxSequence))
{
@@ -1142,7 +1157,7 @@
if (m_shutdownSend)
{
m_errno = ERROR_SHUTDOWN;
- return -1;
+ return false;
}