--- a/src/devices/point-to-point/ppp-header.cc Thu Feb 05 09:43:27 2009 -0800
+++ b/src/devices/point-to-point/ppp-header.cc Fri Feb 06 11:10:51 2009 -0800
@@ -17,6 +17,7 @@
*/
#include <iostream>
+#include "ns3/abort.h"
#include "ns3/assert.h"
#include "ns3/log.h"
#include "ns3/header.h"
@@ -73,9 +74,8 @@
uint32_t
PppHeader::Deserialize (Buffer::Iterator start)
{
- uint16_t __attribute__((unused))data = start.ReadNtohU16 ();
- NS_ASSERT_MSG (data == 0x0021, "MyHeader::Deserialize(): "
- "expected protocol 0x0021");
+ uint16_t data = start.ReadNtohU16 ();
+ NS_ABORT_MSG_UNLESS (data == 0x0021, "MyHeader::Deserialize(): expected protocol 0x0021");
return 2;
}
--- a/src/devices/tap-bridge/tap-bridge.cc Thu Feb 05 09:43:27 2009 -0800
+++ b/src/devices/tap-bridge/tap-bridge.cc Fri Feb 06 11:10:51 2009 -0800
@@ -25,6 +25,7 @@
#include "ns3/ethernet-header.h"
#include "ns3/llc-snap-header.h"
#include "ns3/log.h"
+#include "ns3/abort.h"
#include "ns3/boolean.h"
#include "ns3/string.h"
#include "ns3/ipv4.h"
@@ -153,14 +154,11 @@
{
NS_LOG_FUNCTION_NOARGS ();
+ NS_ABORT_MSG_IF (m_sock != -1, "TapBridge::StartTapDevice(): Tap is already started");
+
//
// Spin up the tap bridge and start receiving packets.
//
- if (m_sock != -1)
- {
- NS_FATAL_ERROR ("TapBridge::StartTapDevice(): Tap is already started");
- }
-
NS_LOG_LOGIC ("Creating tap device");
//
@@ -175,11 +173,7 @@
//
// Now spin up a read thread to read packets from the tap device.
//
- if (m_readThread != 0)
- {
- NS_FATAL_ERROR ("TapBridge::StartTapDevice(): Receive thread is already running");
- }
-
+ NS_ABORT_MSG_IF (m_readThread != 0,"TapBridge::StartTapDevice(): Receive thread is already running");
NS_LOG_LOGIC ("Spinning up read thread");
m_readThread = Create<SystemThread> (MakeCallback (&TapBridge::ReadThread, this));
@@ -215,10 +209,7 @@
// socket for that purpose.
//
int sock = socket (PF_UNIX, SOCK_DGRAM, 0);
- if (sock == -1)
- {
- NS_FATAL_ERROR ("TapBridge::CreateTap(): Unix socket creation error, errno = " << strerror (errno));
- }
+ NS_ABORT_MSG_IF (sock == -1, "TapBridge::CreateTap(): Unix socket creation error, errno = " << strerror (errno));
//
// Bind to that socket and let the kernel allocate an endpoint
@@ -227,11 +218,7 @@
memset (&un, 0, sizeof (un));
un.sun_family = AF_UNIX;
int status = bind (sock, (struct sockaddr*)&un, sizeof (sa_family_t));
- if (status == -1)
- {
- NS_FATAL_ERROR ("TapBridge::CreateTap(): Could not bind(): errno = " << strerror (errno));
- }
-
+ NS_ABORT_MSG_IF (status == -1, "TapBridge::CreateTap(): Could not bind(): errno = " << strerror (errno));
NS_LOG_INFO ("Created Unix socket");
NS_LOG_INFO ("sun_family = " << un.sun_family);
NS_LOG_INFO ("sun_path = " << un.sun_path);
@@ -244,10 +231,7 @@
//
socklen_t len = sizeof (un);
status = getsockname (sock, (struct sockaddr*)&un, &len);
- if (status == -1)
- {
- NS_FATAL_ERROR ("TapBridge::CreateTap(): Could not getsockname(): errno = " << strerror (errno));
- }
+ NS_ABORT_MSG_IF (status == -1, "TapBridge::CreateTap(): Could not getsockname(): errno = " << strerror (errno));
//
// Now encode that socket name (family and path) as a string of hex digits
@@ -386,10 +370,7 @@
//
int st;
pid_t waited = waitpid (pid, &st, 0);
- if (waited == -1)
- {
- NS_FATAL_ERROR ("TapBridge::CreateTap(): waitpid() fails, errno = " << strerror (errno));
- }
+ NS_ABORT_MSG_IF (waited == -1, "TapBridge::CreateTap(): waitpid() fails, errno = " << strerror (errno));
NS_ASSERT_MSG (pid == waited, "TapBridge::CreateTap(): pid mismatch");
//
@@ -400,10 +381,8 @@
if (WIFEXITED (st))
{
int exitStatus = WEXITSTATUS (st);
- if (exitStatus != 0)
- {
- NS_FATAL_ERROR ("TapBridge::CreateTap(): socket creator exited normally with status " << exitStatus);
- }
+ NS_ABORT_MSG_IF (exitStatus != 0,
+ "TapBridge::CreateTap(): socket creator exited normally with status " << exitStatus);
}
else
{
@@ -466,10 +445,7 @@
// creator process.
//
ssize_t bytesRead = recvmsg (sock, &msg, 0);
- if (bytesRead != sizeof(int))
- {
- NS_FATAL_ERROR ("TapBridge::CreateTap(): Wrong byte count from socket creator");
- }
+ NS_ABORT_MSG_IF (bytesRead != sizeof(int), "TapBridge::CreateTap(): Wrong byte count from socket creator");
//
// There may be a number of message headers/ancillary data arrays coming in.
@@ -562,11 +538,7 @@
{
uint32_t bufferSize = 65536;
uint8_t *buf = (uint8_t *)malloc (bufferSize);
- if (buf == 0)
- {
- NS_FATAL_ERROR ("TapBridge::ReadThread(): malloc packet buffer failed");
- }
-
+ NS_ABORT_MSG_IF (buf == 0, "TapBridge::ReadThread(): malloc packet buffer failed");
NS_LOG_LOGIC ("Calling read on tap device socket fd");
len = read (m_sock, buf, bufferSize);
@@ -770,8 +742,8 @@
NS_LOG_LOGIC ("Pkt LengthType is " << header.GetLengthType ());
NS_LOG_LOGIC ("Pkt size is " << p->GetSize ());
- int32_t result __attribute__ ((unused));
- result = write (m_sock, p->PeekData (), p->GetSize ());
+ uint32_t bytesWritten = write (m_sock, p->PeekData (), p->GetSize ());
+ NS_ABORT_MSG_IF (bytesWritten != p->GetSize (), "TapBridge::ReceiveFromBridgedDevice(): Write error.");
}
void
--- a/src/internet-stack/arp-header.cc Thu Feb 05 09:43:27 2009 -0800
+++ b/src/internet-stack/arp-header.cc Fri Feb 06 11:10:51 2009 -0800
@@ -148,7 +148,7 @@
ArpHeader::Deserialize (Buffer::Iterator start)
{
Buffer::Iterator i = start;
- uint32_t hardwareType __attribute__ ((unused)) = i.ReadNtohU16 (); // Read HRD
+ i.Next (2); // Skip HRD
uint32_t protocolType = i.ReadNtohU16 (); // Read PRO
uint32_t hardwareAddressLen = i.ReadU8 (); // Read HLN
uint32_t protocolAddressLen = i.ReadU8 (); // Read PLN
--- a/src/node/ipv4-address-generator.cc Thu Feb 05 09:43:27 2009 -0800
+++ b/src/node/ipv4-address-generator.cc Fri Feb 06 11:10:51 2009 -0800
@@ -17,6 +17,7 @@
*/
#include <list>
+#include "ns3/abort.h"
#include "ns3/assert.h"
#include "ns3/log.h"
#include "ns3/simulation-singleton.h"
@@ -137,17 +138,14 @@
// We're going to be playing with the actual bits in the network and mask so
// pull them out into ints.
//
- uint32_t maskBits __attribute__((unused)) = mask.Get ();
+ uint32_t maskBits = mask.Get ();
uint32_t netBits = net.Get ();
uint32_t addrBits = addr.Get ();
//
// Some quick reasonableness testing.
//
- NS_ASSERT_MSG((netBits & ~maskBits) == 0,
- "Ipv4AddressGeneratorImpl::Init (): Inconsistent network and mask");
-
- NS_ASSERT_MSG((addrBits & maskBits) == 0,
- "Ipv4AddressGeneratorImpl::Init (): Inconsistent address and mask");
+ NS_ABORT_MSG_UNLESS ((netBits & ~maskBits) == 0, "Ipv4AddressGeneratorImpl::Init (): Inconsistent network and mask");
+ NS_ABORT_MSG_UNLESS ((addrBits & maskBits) == 0, "Ipv4AddressGeneratorImpl::Init (): Inconsistent address and mask");
//
// Convert the network mask into an index into the network number table.
@@ -158,10 +156,7 @@
uint32_t index = MaskToIndex (mask);
m_netTable[index].network = netBits >> m_netTable[index].shift;
-
- NS_ASSERT_MSG (addrBits <= m_netTable[index].addrMax,
- "Ipv4AddressGeneratorImpl::Init(): Address overflow");
-
+ NS_ABORT_MSG_UNLESS (addrBits <= m_netTable[index].addrMax, "Ipv4AddressGeneratorImpl::Init(): Address overflow");
m_netTable[index].addr = addrBits;
return;
}
@@ -205,9 +200,7 @@
uint32_t index = MaskToIndex (mask);
uint32_t addrBits = addr.Get ();
- NS_ASSERT_MSG (addrBits <= m_netTable[index].addrMax,
- "Ipv4AddressGeneratorImpl::InitAddress(): Address overflow");
-
+ NS_ABORT_MSG_UNLESS (addrBits <= m_netTable[index].addrMax, "Ipv4AddressGeneratorImpl::InitAddress(): Address overflow");
m_netTable[index].addr = addrBits;
}
@@ -237,8 +230,8 @@
//
uint32_t index = MaskToIndex (mask);
- NS_ASSERT_MSG (m_netTable[index].addr <= m_netTable[index].addrMax,
- "Ipv4AddressGeneratorImpl::NextAddress(): Address overflow");
+ NS_ABORT_MSG_UNLESS (m_netTable[index].addr <= m_netTable[index].addrMax,
+ "Ipv4AddressGeneratorImpl::NextAddress(): Address overflow");
Ipv4Address addr = Ipv4Address (
(m_netTable[index].network << m_netTable[index].shift) |
@@ -260,8 +253,7 @@
uint32_t addr = address.Get ();
- NS_ASSERT_MSG (addr, "Ipv4AddressGeneratorImpl::Add(): "
- "Allocating the broadcast address is not a good idea");
+ NS_ABORT_MSG_UNLESS (addr, "Ipv4AddressGeneratorImpl::Add(): Allocating the broadcast address is not a good idea");
std::list<Entry>::iterator i;
@@ -275,12 +267,10 @@
//
if (addr >= (*i).addrLow && addr <= (*i).addrHigh)
{
- NS_LOG_LOGIC ("Ipv4AddressGeneratorImpl::Add(): "
- "Address Collision: " << Ipv4Address (addr));
+ NS_LOG_LOGIC ("Ipv4AddressGeneratorImpl::Add(): Address Collision: " << Ipv4Address (addr));
if (!m_test)
{
- NS_ASSERT_MSG (0, "Ipv4AddressGeneratorImpl::Add(): "
- "Address Collision: " << Ipv4Address (addr));
+ NS_FATAL_ERROR ("Ipv4AddressGeneratorImpl::Add(): Address Collision: " << Ipv4Address (addr));
}
return false;
}
@@ -313,9 +303,7 @@
"Address Collision: " << Ipv4Address (addr));
if (!m_test)
{
- NS_ASSERT_MSG (0,
- "Ipv4AddressGeneratorImpl::Add(): "
- "Address Collision: " << Ipv4Address (addr));
+ NS_FATAL_ERROR ("Ipv4AddressGeneratorImpl::Add(): Address Collision: " << Ipv4Address (addr));
}
return false;
}
@@ -374,10 +362,7 @@
if (maskBits & 1)
{
uint32_t index = N_BITS - i;
-
- NS_ASSERT_MSG (index > 0 && index < N_BITS,
- "Ipv4AddressGenerator::MaskToIndex(): Illegal Mask");
-
+ NS_ABORT_MSG_UNLESS (index > 0 && index < N_BITS, "Ipv4AddressGenerator::MaskToIndex(): Illegal Mask");
return index;
}
maskBits >>= 1;