cosmetics
authorBorovkova Elena <borovkovaes@iitp.ru>
Mon, 03 Aug 2009 18:54:00 +0400
changeset 5630 16cbbefaa1f6
parent 5629 782756bbd870
child 5631 6f81010ecdb1
cosmetics
src/routing/aodv/aodv-packet.cc
src/routing/aodv/aodv-rqueue.cc
src/routing/aodv/aodv-rtable.cc
src/routing/aodv/id-cache.cc
--- a/src/routing/aodv/aodv-packet.cc	Mon Aug 03 18:42:39 2009 +0400
+++ b/src/routing/aodv/aodv-packet.cc	Mon Aug 03 18:54:00 2009 +0400
@@ -30,27 +30,30 @@
 #include "ns3/address-utils.h"
 #include "ns3/packet.h"
 
-namespace ns3 {
-namespace aodv {
+namespace ns3
+{
+namespace aodv
+{
 
-TypeHeader::TypeHeader(uint8_t t) : m_type(t), m_valid(true)
+TypeHeader::TypeHeader (uint8_t t ) :
+  m_type (t), m_valid (true)
 {
   switch (m_type)
-  {
-  case AODVTYPE_RREQ:
-  case AODVTYPE_RREP:
-  case AODVTYPE_RERR:
-  case AODVTYPE_RREP_ACK:
-    break;
-  default:
-    m_valid = false;
-  }
+    {
+    case AODVTYPE_RREQ:
+    case AODVTYPE_RREP:
+    case AODVTYPE_RERR:
+    case AODVTYPE_RREP_ACK:
+      break;
+    default:
+      m_valid = false;
+    }
 }
 
 TypeId
-TypeHeader::GetInstanceTypeId() const
+TypeHeader::GetInstanceTypeId () const
 {
-  return TypeId();
+  return TypeId ();
 }
 
 uint32_t
@@ -60,131 +63,131 @@
 }
 
 void
-TypeHeader::Serialize (Buffer::Iterator i) const
+TypeHeader::Serialize (Buffer::Iterator i ) const
 {
-  i.WriteU8(m_type);
+  i.WriteU8 (m_type);
 }
 
 uint32_t
-TypeHeader::Deserialize (Buffer::Iterator start)
+TypeHeader::Deserialize (Buffer::Iterator start )
 {
   Buffer::Iterator i = start;
   m_type = i.ReadU8 ();
   m_valid = true;
   switch (m_type)
-  {
-  case AODVTYPE_RREQ:
-  case AODVTYPE_RREP:
-  case AODVTYPE_RERR:
-  case AODVTYPE_RREP_ACK:
-    break;
-  default:
-    m_valid = false;
-  }
+    {
+    case AODVTYPE_RREQ:
+    case AODVTYPE_RREP:
+    case AODVTYPE_RERR:
+    case AODVTYPE_RREP_ACK:
+      break;
+    default:
+      m_valid = false;
+    }
   uint32_t dist = i.GetDistanceFrom (start);
   NS_ASSERT (dist == GetSerializedSize ());
   return dist;
 }
 
 void
-TypeHeader::Print (std::ostream &os) const
+TypeHeader::Print (std::ostream &os ) const
 {
-  switch(m_type)
-  {
-  case AODVTYPE_RREQ:
-  {
-    os << "RREQ" << "\n";
-    break;
-  }
-  case AODVTYPE_RREP:
-  {
-    os << "RREP" << "\n";
-    break;
-  }
-  case AODVTYPE_RERR:
-  {
-    os << "RERR" << "\n";
-    break;
-  }
-  case AODVTYPE_RREP_ACK:
-  {
-    os << "RREP_ACK" << "\n";
-    break;
-  }
-  default:
-    os << "UNKNOWN_TYPE";
-  }
+  switch (m_type)
+    {
+    case AODVTYPE_RREQ:
+      {
+        os << "RREQ" << "\n";
+        break;
+      }
+    case AODVTYPE_RREP:
+      {
+        os << "RREP" << "\n";
+        break;
+      }
+    case AODVTYPE_RERR:
+      {
+        os << "RERR" << "\n";
+        break;
+      }
+    case AODVTYPE_RREP_ACK:
+      {
+        os << "RREP_ACK" << "\n";
+        break;
+      }
+    default:
+      os << "UNKNOWN_TYPE";
+    }
 }
 
 bool
-TypeHeader::operator==(TypeHeader const & o) const
+TypeHeader::operator== (TypeHeader const & o ) const
 {
-  return ( m_type == o.m_type && m_valid == o.m_valid );
+  return (m_type == o.m_type && m_valid == o.m_valid);
 }
 
-std::ostream & operator<<(std::ostream & os, TypeHeader const & h)
+std::ostream &
+operator<< (std::ostream & os, TypeHeader const & h )
 {
-  h.Print(os);
+  h.Print (os);
   return os;
 }
 
-
 #ifdef RUN_SELF_TESTS
 /// Unit test for TypeHeader
 struct TypeHeaderTest : public Test
-{
-  TypeHeaderTest () : Test ("AODV/TypeHeader") {}
-  virtual bool RunTests();
-};
+  {
+    TypeHeaderTest () : Test ("AODV/TypeHeader")
+      {}
+    virtual bool RunTests();
+  };
 
 /// Test instance
 static TypeHeaderTest g_TypeHeaderTest;
 
 bool TypeHeaderTest::RunTests ()
-{
-  bool result(true);
+  {
+    bool result(true);
 
-  TypeHeader badType(12);
-  NS_TEST_ASSERT(!badType.IsValid ());
-
-  TypeHeader h(AODVTYPE_RREQ);
-  NS_TEST_ASSERT(h.IsValid());
-  TypeHeader h1(13);
-  NS_TEST_ASSERT(!h1.IsValid());
+    TypeHeader badType(12);
+    NS_TEST_ASSERT(!badType.IsValid ());
 
-  Ptr<Packet> p = Create<Packet> ();
-  p->AddHeader (h);
-  TypeHeader h2(AODVTYPE_RREP);
-  uint32_t bytes = p->RemoveHeader(h2);
-  NS_TEST_ASSERT_EQUAL (bytes, 1);
-  NS_TEST_ASSERT_EQUAL (h, h2);
-  return result;
-}
+    TypeHeader h(AODVTYPE_RREQ);
+    NS_TEST_ASSERT(h.IsValid());
+    TypeHeader h1(13);
+    NS_TEST_ASSERT(!h1.IsValid());
+
+    Ptr<Packet> p = Create<Packet> ();
+    p->AddHeader (h);
+    TypeHeader h2(AODVTYPE_RREP);
+    uint32_t bytes = p->RemoveHeader(h2);
+    NS_TEST_ASSERT_EQUAL (bytes, 1);
+    NS_TEST_ASSERT_EQUAL (h, h2);
+    return result;
+  }
 #endif
 
-
 //-----------------------------------------------------------------------------
 // RREQ
 //-----------------------------------------------------------------------------
-RreqHeader::RreqHeader () : m_flags(0), m_reserved(0), m_hopCount(0), m_broadcastID(0),
-m_dstSeqNo(0), m_srcSeqNo(0)
+RreqHeader::RreqHeader () :
+  m_flags (0), m_reserved (0), m_hopCount (0), m_broadcastID (0), m_dstSeqNo (0), m_srcSeqNo (0)
 {
 }
 
 TypeId
-RreqHeader::GetInstanceTypeId() const
+RreqHeader::GetInstanceTypeId () const
 {
-  return TypeId();
+  return TypeId ();
 }
 
-uint32_t 
+uint32_t
 RreqHeader::GetSerializedSize () const
 {
   return 23;
 }
 
-void 
-RreqHeader::Serialize (Buffer::Iterator i) const
+void
+RreqHeader::Serialize (Buffer::Iterator i ) const
 {
   i.WriteU8 (m_flags);
   i.WriteU8 (m_reserved);
@@ -196,8 +199,8 @@
   i.WriteHtonU32 (m_srcSeqNo);
 }
 
-uint32_t 
-RreqHeader::Deserialize (Buffer::Iterator start)
+uint32_t
+RreqHeader::Deserialize (Buffer::Iterator start )
 {
   Buffer::Iterator i = start;
   m_flags = i.ReadU8 ();
@@ -214,134 +217,133 @@
   return dist;
 }
 
-void 
-RreqHeader::Print (std::ostream &os) const
+void
+RreqHeader::Print (std::ostream &os ) const
 {
-  os << "RREQ ID " << m_broadcastID << "\n"
-  << "destination: ipv4 " << m_dst << " "
-  << "sequence number " << m_dstSeqNo << "\n"
-  << "source: ipv4 " << m_origin << " "
-  << "sequence number " << m_srcSeqNo << "\n"
-  << "flags:\n"
-  << "Gratuitous RREP " << (*this).GetGratiousRrep() << "\n"
-  << "Destination only " << (*this).GetDestinationOnly() << "\n"
-  << "Unknown sequence number " << (*this).GetUnknownSeqno() << "\n";
+  os << "RREQ ID " << m_broadcastID << "\n" << "destination: ipv4 " << m_dst << " " << "sequence number " << m_dstSeqNo << "\n" << "source: ipv4 "
+      << m_origin << " " << "sequence number " << m_srcSeqNo << "\n" << "flags:\n" << "Gratuitous RREP " << (*this).GetGratiousRrep () << "\n"
+      << "Destination only " << (*this).GetDestinationOnly () << "\n" << "Unknown sequence number " << (*this).GetUnknownSeqno () << "\n";
 }
 
-std::ostream & operator<<(std::ostream & os, RreqHeader const & h)
+std::ostream &
+operator<< (std::ostream & os, RreqHeader const & h )
 {
   h.Print (os);
   return os;
 }
 
-void 
-RreqHeader::SetGratiousRrep (bool f)
+void
+RreqHeader::SetGratiousRrep (bool f )
 {
-  if (f) m_flags |= (1 << 5);
-  else   m_flags &= ~(1 << 5);
+  if (f)
+    m_flags |= (1 << 5);
+  else
+    m_flags &= ~(1 << 5);
 }
 
-bool 
+bool
 RreqHeader::GetGratiousRrep () const
 {
   return (m_flags & (1 << 5));
 }
 
-void 
-RreqHeader::SetDestinationOnly (bool f)
+void
+RreqHeader::SetDestinationOnly (bool f )
 {
-  if (f) m_flags |= (1 << 4);
-  else   m_flags &= ~(1 << 4);
+  if (f)
+    m_flags |= (1 << 4);
+  else
+    m_flags &= ~(1 << 4);
 }
 
-bool 
+bool
 RreqHeader::GetDestinationOnly () const
 {
   return (m_flags & (1 << 4));
 }
 
-void 
-RreqHeader::SetUnknownSeqno (bool f)
+void
+RreqHeader::SetUnknownSeqno (bool f )
 {
-  if (f) m_flags |= (1 << 3);
-  else   m_flags &= ~(1 << 3);
+  if (f)
+    m_flags |= (1 << 3);
+  else
+    m_flags &= ~(1 << 3);
 }
 
-bool 
+bool
 RreqHeader::GetUnknownSeqno () const
 {
   return (m_flags & (1 << 3));
 }
 
 bool
-RreqHeader::operator==(RreqHeader const & o) const
+RreqHeader::operator== (RreqHeader const & o ) const
 {
-  return (m_flags == o.m_flags && m_reserved == o.m_reserved &&
-      m_hopCount == o.m_hopCount && m_broadcastID == o.m_broadcastID &&
-      m_dst == o.m_dst && m_dstSeqNo == o.m_dstSeqNo &&
-      m_origin == o.m_origin && m_srcSeqNo == o.m_srcSeqNo);
+  return (m_flags == o.m_flags && m_reserved == o.m_reserved && m_hopCount == o.m_hopCount && m_broadcastID == o.m_broadcastID && m_dst == o.m_dst
+      && m_dstSeqNo == o.m_dstSeqNo && m_origin == o.m_origin && m_srcSeqNo == o.m_srcSeqNo);
 }
 
 #ifdef RUN_SELF_TESTS
 /// Unit test for RREQ
 struct RreqHeaderTest : public Test
-{
-  RreqHeaderTest () : Test ("AODV/RREQ") {}
-  virtual bool RunTests();
-};
+  {
+    RreqHeaderTest () : Test ("AODV/RREQ")
+      {}
+    virtual bool RunTests();
+  };
 
 /// Test instance
 static RreqHeaderTest g_RreqHeaderTest;
 
 bool RreqHeaderTest::RunTests ()
-{
-  bool result(true);
+  {
+    bool result(true);
 
-  RreqHeader h;
-  h.SetDst (Ipv4Address("1.2.3.4"));
-  h.SetDstSeqno (123);
-  h.SetOrigin (Ipv4Address("4.3.2.1"));
-  h.SetOriginSeqno (321);
-  h.SetId (1);
+    RreqHeader h;
+    h.SetDst (Ipv4Address("1.2.3.4"));
+    h.SetDstSeqno (123);
+    h.SetOrigin (Ipv4Address("4.3.2.1"));
+    h.SetOriginSeqno (321);
+    h.SetId (1);
 
-  h.SetGratiousRrep (true);
-  NS_TEST_ASSERT(h.GetGratiousRrep ());
-  h.SetGratiousRrep (false);
-  NS_TEST_ASSERT_EQUAL(h.GetGratiousRrep (), 0);
-  h.SetDestinationOnly (true);
-  NS_TEST_ASSERT(h.GetDestinationOnly ());
-  h.SetDestinationOnly (false);
-  NS_TEST_ASSERT_EQUAL(h.GetDestinationOnly (), 0);
-  h.SetUnknownSeqno (true);
-  NS_TEST_ASSERT(h.GetUnknownSeqno ());
-  h.SetUnknownSeqno (false);
-  NS_TEST_ASSERT_EQUAL(h.GetUnknownSeqno (), 0);
+    h.SetGratiousRrep (true);
+    NS_TEST_ASSERT(h.GetGratiousRrep ());
+    h.SetGratiousRrep (false);
+    NS_TEST_ASSERT_EQUAL(h.GetGratiousRrep (), 0);
+    h.SetDestinationOnly (true);
+    NS_TEST_ASSERT(h.GetDestinationOnly ());
+    h.SetDestinationOnly (false);
+    NS_TEST_ASSERT_EQUAL(h.GetDestinationOnly (), 0);
+    h.SetUnknownSeqno (true);
+    NS_TEST_ASSERT(h.GetUnknownSeqno ());
+    h.SetUnknownSeqno (false);
+    NS_TEST_ASSERT_EQUAL(h.GetUnknownSeqno (), 0);
 
-  Ptr<Packet> p = Create<Packet> ();
-  p->AddHeader (h);
-  RreqHeader h2;
-  uint32_t bytes = p->RemoveHeader(h2);
-  NS_TEST_ASSERT_EQUAL (bytes, 23);
-  NS_TEST_ASSERT_EQUAL (h, h2);
-  return result;
-}
+    Ptr<Packet> p = Create<Packet> ();
+    p->AddHeader (h);
+    RreqHeader h2;
+    uint32_t bytes = p->RemoveHeader(h2);
+    NS_TEST_ASSERT_EQUAL (bytes, 23);
+    NS_TEST_ASSERT_EQUAL (h, h2);
+    return result;
+  }
 #endif
 
 //-----------------------------------------------------------------------------
 // RREP
 //-----------------------------------------------------------------------------
 
-RrepHeader::RrepHeader(uint8_t prefixSize, uint8_t hopCount, Ipv4Address dst,
-                       uint32_t dstSeqNo, Ipv4Address origin, Time lifeTime) : m_flags(0), m_prefixSize(prefixSize), m_hopCount(hopCount),
-                       m_dst(dst), m_dstSeqNo(dstSeqNo), m_origin(origin)
+RrepHeader::RrepHeader (uint8_t prefixSize, uint8_t hopCount, Ipv4Address dst, uint32_t dstSeqNo, Ipv4Address origin, Time lifeTime ) :
+  m_flags (0), m_prefixSize (prefixSize), m_hopCount (hopCount), m_dst (dst), m_dstSeqNo (dstSeqNo), m_origin (origin)
 {
-  m_lifeTime = uint32_t(lifeTime.GetMilliSeconds());
+  m_lifeTime = uint32_t (lifeTime.GetMilliSeconds ());
 }
 
 TypeId
-RrepHeader::GetInstanceTypeId() const
+RrepHeader::GetInstanceTypeId () const
 {
-  return TypeId();
+  return TypeId ();
 }
 
 uint32_t
@@ -351,10 +353,10 @@
 }
 
 void
-RrepHeader::Serialize (Buffer::Iterator i) const
+RrepHeader::Serialize (Buffer::Iterator i ) const
 {
-  i.WriteU8(m_flags);
-  i.WriteU8(m_prefixSize);
+  i.WriteU8 (m_flags);
+  i.WriteU8 (m_prefixSize);
   i.WriteU8 (m_hopCount);
   WriteTo (i, m_dst);
   i.WriteHtonU32 (m_dstSeqNo);
@@ -363,7 +365,7 @@
 }
 
 uint32_t
-RrepHeader::Deserialize (Buffer::Iterator start)
+RrepHeader::Deserialize (Buffer::Iterator start )
 {
   Buffer::Iterator i = start;
 
@@ -381,35 +383,36 @@
 }
 
 void
-RrepHeader::Print (std::ostream &os) const
+RrepHeader::Print (std::ostream &os ) const
 {
-  os << "destination: ipv4 " << m_dst
-  << "sequence number " <<  m_dstSeqNo;
-  if(m_prefixSize != 0)
+  os << "destination: ipv4 " << m_dst << "sequence number " << m_dstSeqNo;
+  if (m_prefixSize != 0)
     os << "prefix size " << m_prefixSize << "\n";
-  else os << "\n";
-  os << "source ipv4 " << m_origin << "\n"
-  << "life time " << m_lifeTime << "\n"
-  << "acknowledgment required flag " << (*this).GetAckRequired() << "\n";
+  else
+    os << "\n";
+  os << "source ipv4 " << m_origin << "\n" << "life time " << m_lifeTime << "\n" << "acknowledgment required flag " << (*this).GetAckRequired ()
+      << "\n";
 }
 
 void
-RrepHeader::SetLifeTime (Time t)
+RrepHeader::SetLifeTime (Time t )
 {
-  m_lifeTime = t.GetMilliSeconds();
+  m_lifeTime = t.GetMilliSeconds ();
 }
 Time
 RrepHeader::GetLifeTime () const
 {
-  Time t(MilliSeconds(m_lifeTime));
+  Time t (MilliSeconds (m_lifeTime));
   return t;
 }
 
 void
-RrepHeader::SetAckRequired (bool f)
+RrepHeader::SetAckRequired (bool f )
 {
-  if (f) m_flags |= (1 << 6);
-  else   m_flags &= ~(1 << 6);
+  if (f)
+    m_flags |= (1 << 6);
+  else
+    m_flags &= ~(1 << 6);
 }
 
 bool
@@ -419,28 +422,26 @@
 }
 
 void
-RrepHeader::SetPrefixSize(uint8_t sz)
+RrepHeader::SetPrefixSize (uint8_t sz )
 {
   m_prefixSize = sz;
 }
 
 uint8_t
-RrepHeader::GetPrefixSize() const
+RrepHeader::GetPrefixSize () const
 {
   return m_prefixSize;
 }
 
 bool
-RrepHeader::operator==(RrepHeader const & o) const
+RrepHeader::operator== (RrepHeader const & o ) const
 {
-  return (m_flags == o.m_flags && m_prefixSize == o.m_prefixSize &&
-      m_hopCount == o.m_hopCount && m_dst == o.m_dst &&
-      m_dstSeqNo == o.m_dstSeqNo && m_origin == o.m_origin &&
-      m_lifeTime == o.m_lifeTime);
+  return (m_flags == o.m_flags && m_prefixSize == o.m_prefixSize && m_hopCount == o.m_hopCount && m_dst == o.m_dst && m_dstSeqNo == o.m_dstSeqNo
+      && m_origin == o.m_origin && m_lifeTime == o.m_lifeTime);
 }
 
 void
-RrepHeader::SetHello(Ipv4Address origin, uint32_t srcSeqNo, Time lifetime)
+RrepHeader::SetHello (Ipv4Address origin, uint32_t srcSeqNo, Time lifetime )
 {
   m_flags = 0;
   m_prefixSize = 0;
@@ -451,7 +452,8 @@
   m_lifeTime = lifetime.GetMilliSeconds ();
 }
 
-std::ostream & operator<<(std::ostream & os, RrepHeader const & h)
+std::ostream &
+operator<< (std::ostream & os, RrepHeader const & h )
 {
   h.Print (os);
   return os;
@@ -460,63 +462,65 @@
 #ifdef RUN_SELF_TESTS
 /// Unit test for RREP
 struct RrepHeaderTest : public Test
-{
-  RrepHeaderTest () : Test ("AODV/RREP") {}
-  virtual bool RunTests();
-};
+  {
+    RrepHeaderTest () : Test ("AODV/RREP")
+      {}
+    virtual bool RunTests();
+  };
 
 /// Test instance
 static RrepHeaderTest g_RrepHeaderTest;
 
 bool RrepHeaderTest::RunTests ()
-{
-  bool result(true);
+  {
+    bool result(true);
 
-  RrepHeader h (/*prefixSize*/0, /*hopCount*/12, /*dst*/Ipv4Address("1.2.3.4"), /*dstSeqNo*/2,
-                /*origin*/Ipv4Address("4.3.2.1"), /*lifetime*/Seconds(3));
-  NS_TEST_ASSERT_EQUAL (h.GetPrefixSize (), 0);
-  NS_TEST_ASSERT_EQUAL (h.GetHopCount (), 12);
-  NS_TEST_ASSERT_EQUAL (h.GetDst (), Ipv4Address("1.2.3.4"));
-  NS_TEST_ASSERT_EQUAL (h.GetDstSeqno (), 2);
-  NS_TEST_ASSERT_EQUAL (h.GetOrigin (), Ipv4Address("4.3.2.1"));
-  NS_TEST_ASSERT_EQUAL (h.GetLifeTime(), Seconds(3));
-  h.SetDst (Ipv4Address("1.1.1.1"));
-  NS_TEST_ASSERT_EQUAL (h.GetDst (), Ipv4Address("1.1.1.1"));
-  h.SetDstSeqno (123);
-  NS_TEST_ASSERT_EQUAL (h.GetDstSeqno (), 123);
-  h.SetOrigin (Ipv4Address("4.4.4.4"));
-  NS_TEST_ASSERT_EQUAL (h.GetOrigin (), Ipv4Address("4.4.4.4"));
-  h.SetLifeTime(MilliSeconds(1200));
-  NS_TEST_ASSERT_EQUAL (h.GetLifeTime(), MilliSeconds(1200));
-  h.SetAckRequired(true);
-  NS_TEST_ASSERT(h.GetAckRequired ());
-  h.SetAckRequired(false);
-  NS_TEST_ASSERT(!h.GetAckRequired ());
-  h.SetPrefixSize(2);
-  NS_TEST_ASSERT_EQUAL (h.GetPrefixSize (), 2);
+    RrepHeader h (/*prefixSize*/0, /*hopCount*/12, /*dst*/Ipv4Address("1.2.3.4"), /*dstSeqNo*/2,
+        /*origin*/Ipv4Address("4.3.2.1"), /*lifetime*/Seconds(3));
+    NS_TEST_ASSERT_EQUAL (h.GetPrefixSize (), 0);
+    NS_TEST_ASSERT_EQUAL (h.GetHopCount (), 12);
+    NS_TEST_ASSERT_EQUAL (h.GetDst (), Ipv4Address("1.2.3.4"));
+    NS_TEST_ASSERT_EQUAL (h.GetDstSeqno (), 2);
+    NS_TEST_ASSERT_EQUAL (h.GetOrigin (), Ipv4Address("4.3.2.1"));
+    NS_TEST_ASSERT_EQUAL (h.GetLifeTime(), Seconds(3));
+    h.SetDst (Ipv4Address("1.1.1.1"));
+    NS_TEST_ASSERT_EQUAL (h.GetDst (), Ipv4Address("1.1.1.1"));
+    h.SetDstSeqno (123);
+    NS_TEST_ASSERT_EQUAL (h.GetDstSeqno (), 123);
+    h.SetOrigin (Ipv4Address("4.4.4.4"));
+    NS_TEST_ASSERT_EQUAL (h.GetOrigin (), Ipv4Address("4.4.4.4"));
+    h.SetLifeTime(MilliSeconds(1200));
+    NS_TEST_ASSERT_EQUAL (h.GetLifeTime(), MilliSeconds(1200));
+    h.SetAckRequired(true);
+    NS_TEST_ASSERT(h.GetAckRequired ());
+    h.SetAckRequired(false);
+    NS_TEST_ASSERT(!h.GetAckRequired ());
+    h.SetPrefixSize(2);
+    NS_TEST_ASSERT_EQUAL (h.GetPrefixSize (), 2);
 
-  Ptr<Packet> p = Create<Packet> ();
-  p->AddHeader (h);
-  RrepHeader h2;
-  uint32_t bytes = p->RemoveHeader(h2);
-  NS_TEST_ASSERT_EQUAL (bytes, 19);
-  NS_TEST_ASSERT_EQUAL (h, h2);
-  return result;
-}
+    Ptr<Packet> p = Create<Packet> ();
+    p->AddHeader (h);
+    RrepHeader h2;
+    uint32_t bytes = p->RemoveHeader(h2);
+    NS_TEST_ASSERT_EQUAL (bytes, 19);
+    NS_TEST_ASSERT_EQUAL (h, h2);
+    return result;
+  }
 #endif
 
 //-----------------------------------------------------------------------------
 // RREP-ACK
 //-----------------------------------------------------------------------------
 
-RrepAckHeader::RrepAckHeader () : m_reserved(0)
+RrepAckHeader::RrepAckHeader () :
+  m_reserved (0)
 {
 }
 
 TypeId
-RrepAckHeader::GetInstanceTypeId() const
+RrepAckHeader::GetInstanceTypeId () const
 {
-  return TypeId();
+  return TypeId ();
 }
 
 uint32_t
@@ -526,13 +530,13 @@
 }
 
 void
-RrepAckHeader::Serialize (Buffer::Iterator i) const
+RrepAckHeader::Serialize (Buffer::Iterator i ) const
 {
-  i.WriteU8(m_reserved);
+  i.WriteU8 (m_reserved);
 }
 
 uint32_t
-RrepAckHeader::Deserialize (Buffer::Iterator start)
+RrepAckHeader::Deserialize (Buffer::Iterator start )
 {
   Buffer::Iterator i = start;
   m_reserved = i.ReadU8 ();
@@ -542,97 +546,100 @@
 }
 
 void
-RrepAckHeader::Print (std::ostream &os) const
+RrepAckHeader::Print (std::ostream &os ) const
 {
 }
 
 bool
-RrepAckHeader::operator==(RrepAckHeader const & o) const
+RrepAckHeader::operator== (RrepAckHeader const & o ) const
 {
   return m_reserved == o.m_reserved;
 }
 
-std::ostream & operator<<(std::ostream & os, RrepAckHeader const & h)
+std::ostream &
+operator<< (std::ostream & os, RrepAckHeader const & h )
 {
-  h.Print(os);
+  h.Print (os);
   return os;
 }
 
 #ifdef RUN_SELF_TESTS
 /// Unit test for RREP-ACK
 struct RrepAckHeaderTest : public Test
-{
-  RrepAckHeaderTest () : Test ("AODV/RREP-ACK") {}
-  virtual bool RunTests();
-};
+  {
+    RrepAckHeaderTest () : Test ("AODV/RREP-ACK")
+      {}
+    virtual bool RunTests();
+  };
 
 /// Test instance
 static RrepAckHeaderTest g_RrepAckHeaderTest;
 
 bool RrepAckHeaderTest::RunTests ()
-{
-  bool result(true);
+  {
+    bool result(true);
 
-  RrepAckHeader h;
-  Ptr<Packet> p = Create<Packet> ();
-  p->AddHeader (h);
-  RrepAckHeader h2;
-  uint32_t bytes = p->RemoveHeader(h2);
-  NS_TEST_ASSERT_EQUAL (bytes, 1);
-  NS_TEST_ASSERT_EQUAL (h, h2);
-  return result;
-}
+    RrepAckHeader h;
+    Ptr<Packet> p = Create<Packet> ();
+    p->AddHeader (h);
+    RrepAckHeader h2;
+    uint32_t bytes = p->RemoveHeader(h2);
+    NS_TEST_ASSERT_EQUAL (bytes, 1);
+    NS_TEST_ASSERT_EQUAL (h, h2);
+    return result;
+  }
 #endif
 
 //-----------------------------------------------------------------------------
 // RERR
 //-----------------------------------------------------------------------------
-RerrHeader::RerrHeader() : m_flag(0), m_reserved(0)
+RerrHeader::RerrHeader () :
+  m_flag (0), m_reserved (0)
 {
 }
 
 TypeId
-RerrHeader::GetInstanceTypeId() const
+RerrHeader::GetInstanceTypeId () const
 {
-  return TypeId();
+  return TypeId ();
 }
 
 uint32_t
 RerrHeader::GetSerializedSize () const
 {
-  return ( 3 + 8*GetDestCount());
+  return (3 + 8 * GetDestCount ());
 }
 
 void
-RerrHeader::Serialize (Buffer::Iterator i) const
+RerrHeader::Serialize (Buffer::Iterator i ) const
 {
-  i.WriteU8(m_flag);
-  i.WriteU8(m_reserved);
-  i.WriteU8(GetDestCount());
+  i.WriteU8 (m_flag);
+  i.WriteU8 (m_reserved);
+  i.WriteU8 (GetDestCount ());
   std::map<Ipv4Address, uint32_t>::const_iterator j;
-  for(j = m_unreachableDstSeqNo.begin(); j != m_unreachableDstSeqNo.end(); ++j)
-  {
-    WriteTo (i, (*j).first);
-    i.WriteHtonU32 ((*j).second);
-  }
+  for (j = m_unreachableDstSeqNo.begin (); j != m_unreachableDstSeqNo.end (); ++j)
+    {
+      WriteTo (i, (*j).first);
+      i.WriteHtonU32 ((*j).second);
+    }
 }
 
 uint32_t
-RerrHeader::Deserialize (Buffer::Iterator start)
+RerrHeader::Deserialize (Buffer::Iterator start )
 {
   Buffer::Iterator i = start;
   m_flag = i.ReadU8 ();
   m_reserved = i.ReadU8 ();
   uint8_t dest = i.ReadU8 ();
-  m_unreachableDstSeqNo.clear();
+  m_unreachableDstSeqNo.clear ();
   Ipv4Address address;
   uint32_t seqNo;
-  for(uint8_t k = 0; k < dest; ++k)
-  {
-    ReadFrom (i, address);
-    seqNo = i.ReadNtohU32 ();
-    m_unreachableDstSeqNo.insert(std::make_pair(address, seqNo));
-  }
+  for (uint8_t k = 0; k < dest; ++k)
+    {
+      ReadFrom (i, address);
+      seqNo = i.ReadNtohU32 ();
+      m_unreachableDstSeqNo.insert (std::make_pair (address, seqNo));
+    }
 
   uint32_t dist = i.GetDistanceFrom (start);
   NS_ASSERT (dist == GetSerializedSize ());
@@ -640,120 +647,123 @@
 }
 
 void
-RerrHeader::Print (std::ostream &os) const
+RerrHeader::Print (std::ostream &os ) const
 {
   os << "Unreachable destination (ipv4 address, seq. number):\n";
   std::map<Ipv4Address, uint32_t>::const_iterator j;
-  for(j = m_unreachableDstSeqNo.begin(); j != m_unreachableDstSeqNo.end(); ++j)
-  {
-    os << (*j).first << ", " << (*j).second << "\n";
-  }
-  os << "No delete flag " << (*this).GetNoDelete() << "\n";
+  for (j = m_unreachableDstSeqNo.begin (); j != m_unreachableDstSeqNo.end (); ++j)
+    {
+      os << (*j).first << ", " << (*j).second << "\n";
+    }
+  os << "No delete flag " << (*this).GetNoDelete () << "\n";
 }
 
 void
-RerrHeader::SetNoDelete(bool f)
+RerrHeader::SetNoDelete (bool f )
 {
-  if (f) m_flag |= (1 << 0);
-  else   m_flag &= ~(1 << 0);
+  if (f)
+    m_flag |= (1 << 0);
+  else
+    m_flag &= ~(1 << 0);
 }
 
 bool
-RerrHeader::GetNoDelete() const
+RerrHeader::GetNoDelete () const
 {
   return (m_flag & (1 << 0));
 }
 
 bool
-RerrHeader::AddUnDestination(Ipv4Address dst, uint32_t seqNo)
+RerrHeader::AddUnDestination (Ipv4Address dst, uint32_t seqNo )
 {
-  if(m_unreachableDstSeqNo.find(dst) != m_unreachableDstSeqNo.end())
+  if (m_unreachableDstSeqNo.find (dst) != m_unreachableDstSeqNo.end ())
     return false;
 
   NS_ASSERT (GetDestCount() < 255); // can't support more than 255 destinations in single RERR
-  m_unreachableDstSeqNo.insert(std::make_pair(dst, seqNo));
+  m_unreachableDstSeqNo.insert (std::make_pair (dst, seqNo));
   return true;
 }
 
 bool
-RerrHeader::RemoveUnDestination(std::pair<Ipv4Address, uint32_t> & un)
+RerrHeader::RemoveUnDestination (std::pair<Ipv4Address, uint32_t> & un )
 {
-  if(GetDestCount() == 0)
+  if (GetDestCount () == 0)
     return false;
-  std::map<Ipv4Address, uint32_t>::iterator i = m_unreachableDstSeqNo.end();
+  std::map<Ipv4Address, uint32_t>::iterator i = m_unreachableDstSeqNo.end ();
   un = *i;
-  m_unreachableDstSeqNo.erase(i);
+  m_unreachableDstSeqNo.erase (i);
   return true;
 }
 
-
 void
-RerrHeader::Clear()
+RerrHeader::Clear ()
 {
-  m_unreachableDstSeqNo.clear();
+  m_unreachableDstSeqNo.clear ();
   m_flag = 0;
   m_reserved = 0;
 }
 
-
 bool
-RerrHeader::operator==(RerrHeader const & o) const
+RerrHeader::operator== (RerrHeader const & o ) const
 {
-  if (m_flag != o.m_flag || m_reserved != o.m_reserved || GetDestCount() != o.GetDestCount())
+  if (m_flag != o.m_flag || m_reserved != o.m_reserved || GetDestCount () != o.GetDestCount ())
     return false;
 
-  std::map<Ipv4Address, uint32_t>::const_iterator j = m_unreachableDstSeqNo.begin();
-  std::map<Ipv4Address, uint32_t>::const_iterator k = o.m_unreachableDstSeqNo.begin();
-  for(uint8_t i = 0; i < GetDestCount(); ++i)
-  {
-    if ((j->first != k->first ) || (j->second != k->second))
-      return false;
+  std::map<Ipv4Address, uint32_t>::const_iterator j = m_unreachableDstSeqNo.begin ();
+  std::map<Ipv4Address, uint32_t>::const_iterator k = o.m_unreachableDstSeqNo.begin ();
+  for (uint8_t i = 0; i < GetDestCount (); ++i)
+    {
+      if ((j->first != k->first) || (j->second != k->second))
+        return false;
 
-    j++;
-    k++;
-  }
+      j++;
+      k++;
+    }
   return true;
 }
 
-std::ostream & operator<<(std::ostream & os, RerrHeader const & h)
+std::ostream &
+operator<< (std::ostream & os, RerrHeader const & h )
 {
-  h.Print(os);
+  h.Print (os);
   return os;
 }
 
 #ifdef RUN_SELF_TESTS
 /// Unit test for RERR
 struct RerrHeaderTest : public Test
-{
-  RerrHeaderTest () : Test ("AODV/RERR") {}
-  virtual bool RunTests();
-};
+  {
+    RerrHeaderTest () : Test ("AODV/RERR")
+      {}
+    virtual bool RunTests();
+  };
 
 /// Test instance
 static RerrHeaderTest g_RerrHeaderTest;
 
 bool RerrHeaderTest::RunTests ()
-{
-  bool result(true);
+  {
+    bool result(true);
 
-  RerrHeader h;
-  h.SetNoDelete(true);
-  NS_TEST_ASSERT(h.GetNoDelete());
-  Ipv4Address dst = Ipv4Address("1.2.3.4");
-  NS_TEST_ASSERT(h.AddUnDestination(dst, 12));
-  NS_TEST_ASSERT_EQUAL(h.GetDestCount(),1);
-  NS_TEST_ASSERT(!h.AddUnDestination(dst, 13));
-  Ipv4Address dst2 = Ipv4Address("4.3.2.1");
-  NS_TEST_ASSERT(h.AddUnDestination(dst2, 12));
-  NS_TEST_ASSERT_EQUAL(h.GetDestCount(), 2);
+    RerrHeader h;
+    h.SetNoDelete(true);
+    NS_TEST_ASSERT(h.GetNoDelete());
+    Ipv4Address dst = Ipv4Address("1.2.3.4");
+    NS_TEST_ASSERT(h.AddUnDestination(dst, 12));
+    NS_TEST_ASSERT_EQUAL(h.GetDestCount(),1);
+    NS_TEST_ASSERT(!h.AddUnDestination(dst, 13));
+    Ipv4Address dst2 = Ipv4Address("4.3.2.1");
+    NS_TEST_ASSERT(h.AddUnDestination(dst2, 12));
+    NS_TEST_ASSERT_EQUAL(h.GetDestCount(), 2);
 
-  Ptr<Packet> p = Create<Packet> ();
-  p->AddHeader (h);
-  RerrHeader h2;
-  uint32_t bytes = p->RemoveHeader(h2);
-  NS_TEST_ASSERT_EQUAL (bytes, h.GetSerializedSize());
-  NS_TEST_ASSERT_EQUAL (h, h2);
-  return result;
+    Ptr<Packet> p = Create<Packet> ();
+    p->AddHeader (h);
+    RerrHeader h2;
+    uint32_t bytes = p->RemoveHeader(h2);
+    NS_TEST_ASSERT_EQUAL (bytes, h.GetSerializedSize());
+    NS_TEST_ASSERT_EQUAL (h, h2);
+    return result;
+  }
+#endif
 }
-#endif
-}}
+}
--- a/src/routing/aodv/aodv-rqueue.cc	Mon Aug 03 18:42:39 2009 +0400
+++ b/src/routing/aodv/aodv-rqueue.cc	Mon Aug 03 18:54:00 2009 +0400
@@ -35,134 +35,105 @@
 
 NS_LOG_COMPONENT_DEFINE ("AodvRequestQueue");
 
-namespace ns3 {
-namespace aodv {
-
-#if 0
-#ifdef RUN_SELF_TESTS
-/// Unit test for AODV routing table entry
-struct QueueEntryTest : public Test
+namespace ns3
 {
-  QueueEntryTest () : Test ("AODV/QueueEntry"), result(true) {}
-  virtual bool RunTests();
-  void Unicast (Ptr<Ipv4Route> route, Ptr<const Packet> packet, const Ipv4Header & header);
-  void Error (Ptr<const Packet>, const Ipv4Header &, Socket::SocketErrno);
-  bool result;
-};
-
-/// Test instance
-static QueueEntryTest g_QueueEntryTest;
-
-bool
-QueueEntryTest::RunTests ()
+namespace aodv
 {
-  Ptr<Packet> packet;
-  Ipv4Header h;
-  h.SetDestination (Ipv4Address("1.2.3.4"));
-  h.SetSource (Ipv4Address("4.3.2.1"));
-  Ipv4RoutingProtocol::UnicastForwardCallback ucb = MakeCallback (&QueueEntryTest::Unicast, this);
-  Ipv4RoutingProtocol::ErrorCallback ecb = MakeCallback (&QueueEntryTest::Error, this);
-  QueueEntry entry (packet, h, ucb, ecb, Seconds(5));
-//  NS_TEST_ASSERT_EQUAL (h.GetDestination (),  entry.GetIpv4Header ().GetDestination ());
-//  NS_TEST_ASSERT_EQUAL (h.GetSource (),  entry.GetIpv4Header ().GetSource ());
-
-  return result;
-}
-#endif
-#endif
 
 uint32_t
 RequestQueue::GetSize ()
 {
-  Purge();
-  return m_queue.size();
-}
-
-void
-RequestQueue::Enqueue(QueueEntry & entry)
-{
-  Purge();
-  entry.SetExpireTime (m_queueTimeout);
-
-  if (m_queue.size() == m_maxLen) Drop(Pop(), "Drop the most aged packet"); // Drop the most aged packet
-  m_queue.push_back(entry);
-}
-
-QueueEntry
-RequestQueue::Dequeue()
-{
-  NS_LOG_FUNCTION (this);
-  Purge();
-  return Pop();
+  Purge ();
+  return m_queue.size ();
 }
 
 void
-RequestQueue::DropPacketWithDst (Ipv4Address dst)
+RequestQueue::Enqueue (QueueEntry & entry )
+{
+  Purge ();
+  entry.SetExpireTime (m_queueTimeout);
+
+  if (m_queue.size () == m_maxLen)
+    Drop (Pop (), "Drop the most aged packet"); // Drop the most aged packet
+  m_queue.push_back (entry);
+}
+
+QueueEntry
+RequestQueue::Dequeue ()
+{
+  NS_LOG_FUNCTION (this);
+  Purge ();
+  return Pop ();
+}
+
+void
+RequestQueue::DropPacketWithDst (Ipv4Address dst )
 {
   NS_LOG_FUNCTION (this << dst);
-  Purge();
+  Purge ();
   const Ipv4Address addr = dst;
-  std::vector<QueueEntry>::iterator i = std::remove_if (m_queue.begin(), m_queue.end(), std::bind2nd(std::ptr_fun( RequestQueue::IsEqual), dst) );
-  for(std::vector<QueueEntry>::iterator j = i; i != m_queue.end(); ++j)
-  {
-    Drop(*j, "DropPacketWithDst ");
-  }
-  m_queue.erase(i, m_queue.end());
+  std::vector<QueueEntry>::iterator i = std::remove_if (m_queue.begin (), m_queue.end (), std::bind2nd (std::ptr_fun (RequestQueue::IsEqual), dst));
+  for (std::vector<QueueEntry>::iterator j = i; i != m_queue.end (); ++j)
+    {
+      Drop (*j, "DropPacketWithDst ");
+    }
+  m_queue.erase (i, m_queue.end ());
 }
 
 bool
-RequestQueue::Dequeue(Ipv4Address dst, QueueEntry & entry)
+RequestQueue::Dequeue (Ipv4Address dst, QueueEntry & entry )
 {
-  Purge();
-  for(std::vector<QueueEntry>::iterator i = m_queue.begin(); i != m_queue.end(); ++i)
-    if(i->GetIpv4Header ().GetDestination() == dst)
+  Purge ();
+  for (std::vector<QueueEntry>::iterator i = m_queue.begin (); i != m_queue.end (); ++i)
+    if (i->GetIpv4Header ().GetDestination () == dst)
       {
         entry = *i;
-        m_queue.erase(i);
+        m_queue.erase (i);
         return true;
       }
   return false;
 }
 
 bool
-RequestQueue::Find(Ipv4Address dst)
+RequestQueue::Find (Ipv4Address dst )
 {
-  for( std::vector<QueueEntry>::const_iterator i = m_queue.begin(); i != m_queue.end(); ++i)
-    if(i->GetIpv4Header ().GetDestination() == dst)
+  for (std::vector<QueueEntry>::const_iterator i = m_queue.begin (); i != m_queue.end (); ++i)
+    if (i->GetIpv4Header ().GetDestination () == dst)
       return true;
   return false;
 }
 
 QueueEntry
-RequestQueue::Pop()
+RequestQueue::Pop ()
 {
   NS_LOG_FUNCTION (this);
-  QueueEntry entry = m_queue.front();
-  m_queue.erase(m_queue.begin());
+  QueueEntry entry = m_queue.front ();
+  m_queue.erase (m_queue.begin ());
   return entry;
 }
 
 struct IsExpired
 {
-  bool operator() (QueueEntry const & e) const
+  bool
+  operator() (QueueEntry const & e ) const
   {
-    return (e.GetExpireTime () < Seconds(0));
+    return (e.GetExpireTime () < Seconds (0));
   }
 };
 
 void
-RequestQueue::Purge()
+RequestQueue::Purge ()
 {
-  std::vector<QueueEntry>::iterator i = std::remove_if(m_queue.begin(), m_queue.end(), IsExpired());
-  for (std::vector<QueueEntry>::iterator j = i ; j < m_queue.end(); ++j)
-  {
-    Drop (*j, "Drop outdated packet ");
-  }
-  m_queue.erase(i, m_queue.end());
+  std::vector<QueueEntry>::iterator i = std::remove_if (m_queue.begin (), m_queue.end (), IsExpired ());
+  for (std::vector<QueueEntry>::iterator j = i; j < m_queue.end (); ++j)
+    {
+      Drop (*j, "Drop outdated packet ");
+    }
+  m_queue.erase (i, m_queue.end ());
 }
 
 void
-RequestQueue::Drop(QueueEntry en, std::string reason)
+RequestQueue::Drop (QueueEntry en, std::string reason )
 {
   NS_LOG_LOGIC (reason << en.GetPacket ()->GetUid ());
 }
@@ -171,77 +142,78 @@
 #ifdef RUN_SELF_TESTS
 /// Unit test for RequestQueue
 struct AodvRqueueTest : public Test
-{
-  AodvRqueueTest () : Test ("AODV/Rqueue"), result(true) {}
-  virtual bool RunTests();
+  {
+    AodvRqueueTest () : Test ("AODV/Rqueue"), result(true) {}
+    virtual bool RunTests();
 
-  void CheckSizeLimit ();
-  void CheckTimeout ();
+    void CheckSizeLimit ();
+    void CheckTimeout ();
 
-  RequestQueue q;
-  bool result;
-};
+    RequestQueue q;
+    bool result;
+  };
 
 /// Test instance
 static AodvRqueueTest g_AodvRqueueTest;
 
 bool
 AodvRqueueTest::RunTests ()
-{
-  Ptr<Packet> packet = Create<Packet>();
-  Ipv4Header header;
-  QueueEntry e1 (packet, header);
-  q.Enqueue (e1);
-  QueueEntry e2 = q.Dequeue ();
-  NS_TEST_ASSERT (e1 == e2);
+  {
+    Ptr<Packet> packet = Create<Packet>();
+    Ipv4Header header;
+    QueueEntry e1 (packet, header);
+    q.Enqueue (e1);
+    QueueEntry e2 = q.Dequeue ();
+    NS_TEST_ASSERT (e1 == e2);
 
-  Ipv4Address dst("1.2.3.4");
-  header.SetDestination (dst);
-  e1 = QueueEntry (packet, header);
-  q.Enqueue (e1);
+    Ipv4Address dst("1.2.3.4");
+    header.SetDestination (dst);
+    e1 = QueueEntry (packet, header);
+    q.Enqueue (e1);
 
-  bool ok = q.Dequeue (dst, e2);
-  NS_TEST_ASSERT (ok);
-  NS_TEST_ASSERT (e1 == e2);
-  NS_TEST_ASSERT (! q.Find(dst));
-  q.Enqueue (e1);
-  NS_TEST_ASSERT (q.Find(dst));
+    bool ok = q.Dequeue (dst, e2);
+    NS_TEST_ASSERT (ok);
+    NS_TEST_ASSERT (e1 == e2);
+    NS_TEST_ASSERT (! q.Find(dst));
+    q.Enqueue (e1);
+    NS_TEST_ASSERT (q.Find(dst));
 
-  CheckSizeLimit ();
+    CheckSizeLimit ();
 
-  Ipv4Header header2;
-  Ipv4Address dst2("1.2.3.4");
-  header2.SetDestination (dst2);
+    Ipv4Header header2;
+    Ipv4Address dst2("1.2.3.4");
+    header2.SetDestination (dst2);
 
-  Simulator::Schedule (Seconds(AODV_RTQ_TIMEOUT+1), & AodvRqueueTest::CheckTimeout, this);
+    Simulator::Schedule (Seconds(AODV_RTQ_TIMEOUT+1), & AodvRqueueTest::CheckTimeout, this);
 
-  Simulator::Run ();
-  Simulator::Destroy ();
+    Simulator::Run ();
+    Simulator::Destroy ();
 
-  return result;
-}
+    return result;
+  }
 
 void
 AodvRqueueTest::CheckSizeLimit ()
-{
-  Ptr<Packet> packet = Create<Packet>();
-  Ipv4Header header;
-  QueueEntry e1 (packet, header);
+  {
+    Ptr<Packet> packet = Create<Packet>();
+    Ipv4Header header;
+    QueueEntry e1 (packet, header);
 
-  for (uint32_t i = 0; i < AODV_RTQ_MAX_LEN; ++i)
+    for (uint32_t i = 0; i < AODV_RTQ_MAX_LEN; ++i)
     q.Enqueue (e1);
-  NS_TEST_ASSERT (q.GetSize() == AODV_RTQ_MAX_LEN);
+    NS_TEST_ASSERT (q.GetSize() == AODV_RTQ_MAX_LEN);
 
-  for (uint32_t i = 0; i < AODV_RTQ_MAX_LEN; ++i)
+    for (uint32_t i = 0; i < AODV_RTQ_MAX_LEN; ++i)
     q.Enqueue (e1);
-  NS_TEST_ASSERT (q.GetSize() == AODV_RTQ_MAX_LEN);
-}
+    NS_TEST_ASSERT (q.GetSize() == AODV_RTQ_MAX_LEN);
+  }
 
 void
 AodvRqueueTest::CheckTimeout ()
-{
-  NS_TEST_ASSERT (q.GetSize() == 0);
-}
+  {
+    NS_TEST_ASSERT (q.GetSize() == 0);
+  }
 #endif
 #endif
-}}
+}
+}
--- a/src/routing/aodv/aodv-rtable.cc	Mon Aug 03 18:42:39 2009 +0400
+++ b/src/routing/aodv/aodv-rtable.cc	Mon Aug 03 18:54:00 2009 +0400
@@ -31,19 +31,20 @@
 #include "ns3/test.h"
 #include "ns3/log.h"
 
-
-namespace ns3 {
-namespace aodv {
+namespace ns3
+{
+namespace aodv
+{
 
 /*
-  The Routing Table
+ The Routing Table
  */
 
-RoutingTableEntry::RoutingTableEntry(Ptr<NetDevice> dev, Ipv4Address dst, bool vSeqNo, u_int32_t seqNo, Ipv4InterfaceAddress iface, u_int16_t  hops,
-                              Ipv4Address nextHop, Time lifetime)
-                            : m_validSeqNo(vSeqNo), m_seqNo(seqNo), m_hops(hops), m_lifeTime(lifetime + Simulator::Now()), m_iface(iface), m_flag(RTF_UP),
-                              m_reqCount(0), m_blackListState(false), m_blackListTimeout(Simulator::Now()),
-                              m_ackTimer(Timer::CANCEL_ON_DESTROY), lifeTimeTimer(Timer::CANCEL_ON_DESTROY)
+RoutingTableEntry::RoutingTableEntry (Ptr<NetDevice> dev, Ipv4Address dst, bool vSeqNo, u_int32_t seqNo, Ipv4InterfaceAddress iface, u_int16_t hops,
+    Ipv4Address nextHop, Time lifetime ) :
+  m_validSeqNo (vSeqNo), m_seqNo (seqNo), m_hops (hops), m_lifeTime (lifetime + Simulator::Now ()), m_iface (iface), m_flag (RTF_UP), m_reqCount (0),
+      m_blackListState (false), m_blackListTimeout (Simulator::Now ()), m_ackTimer (Timer::CANCEL_ON_DESTROY), lifeTimeTimer (
+          Timer::CANCEL_ON_DESTROY)
 {
   m_ipv4Route = Create<Ipv4Route> ();
   m_ipv4Route->SetDestination (dst);
@@ -52,306 +53,320 @@
   m_ipv4Route->SetOutputDevice (dev);
 }
 
-RoutingTableEntry::~RoutingTableEntry()
+RoutingTableEntry::~RoutingTableEntry ()
 {
 }
 
 bool
-RoutingTableEntry::InsertPrecursor(Ipv4Address id)
+RoutingTableEntry::InsertPrecursor (Ipv4Address id )
 {
-  if (! LookupPrecursor(id))
+  if (!LookupPrecursor (id))
     {
-      m_precursorList.push_back(id);
+      m_precursorList.push_back (id);
       return true;
     }
-  else return false;
+  else
+    return false;
 }
 
 bool
-RoutingTableEntry::LookupPrecursor(Ipv4Address id)
+RoutingTableEntry::LookupPrecursor (Ipv4Address id )
 {
-  for(std::vector<Ipv4Address>::const_iterator i = m_precursorList.begin(); i != m_precursorList.end(); ++i)
-    if (*i == id) return true;
+  for (std::vector<Ipv4Address>::const_iterator i = m_precursorList.begin (); i != m_precursorList.end (); ++i)
+    if (*i == id)
+      return true;
   return false;
 }
 
 bool
-RoutingTableEntry::DeletePrecursor(Ipv4Address id)
+RoutingTableEntry::DeletePrecursor (Ipv4Address id )
 {
-  std::vector<Ipv4Address>::iterator i = std::remove(m_precursorList.begin(), m_precursorList.end(), id);
-  if(i == m_precursorList.end())
+  std::vector<Ipv4Address>::iterator i = std::remove (m_precursorList.begin (), m_precursorList.end (), id);
+  if (i == m_precursorList.end ())
     return false;
   else
-    m_precursorList.erase (i, m_precursorList.end());
+    m_precursorList.erase (i, m_precursorList.end ());
   return true;
 }
 
 void
-RoutingTableEntry::DeleteAllPrecursors()
+RoutingTableEntry::DeleteAllPrecursors ()
 {
-  m_precursorList.clear();
+  m_precursorList.clear ();
   NS_ASSERT(m_precursorList.empty ());
 }
 
 bool
-RoutingTableEntry::IsPrecursorListEmpty() const
+RoutingTableEntry::IsPrecursorListEmpty () const
 {
-  return m_precursorList.empty();
+  return m_precursorList.empty ();
 }
 
 void
-RoutingTableEntry::GetPrecursors(std::vector<Ipv4Address> & prec) const
+RoutingTableEntry::GetPrecursors (std::vector<Ipv4Address> & prec ) const
 {
-  if (IsPrecursorListEmpty()) return;
-  for(std::vector<Ipv4Address>::const_iterator i = m_precursorList.begin(); i != m_precursorList.end(); ++i)
-  {
-    bool result = true;
-    for(std::vector<Ipv4Address>::const_iterator j = prec.begin(); j != prec.end(); ++j)
-      if (*j == *i) result = false;
-    if(result) prec.push_back(*i);
-  }
-}
-
-void
-RoutingTableEntry::Invalidate (Time badLinkLifetime)
-{
-  if(m_flag == RTF_DOWN) return;
-  m_flag = RTF_DOWN;
-  m_lifeTime = badLinkLifetime + Simulator::Now();
+  if (IsPrecursorListEmpty ())
+    return;
+  for (std::vector<Ipv4Address>::const_iterator i = m_precursorList.begin (); i != m_precursorList.end (); ++i)
+    {
+      bool result = true;
+      for (std::vector<Ipv4Address>::const_iterator j = prec.begin (); j != prec.end (); ++j)
+        if (*j == *i)
+          result = false;
+      if (result)
+        prec.push_back (*i);
+    }
 }
 
 void
-RoutingTableEntry::Print(std::ostream & os) const
+RoutingTableEntry::Invalidate (Time badLinkLifetime )
 {
-  os << m_ipv4Route->GetDestination() << "\t" << m_ipv4Route->GetGateway() << "\t"
-     << m_ipv4Route->GetSource() << "\t";
+  if (m_flag == RTF_DOWN)
+    return;
+  m_flag = RTF_DOWN;
+  m_lifeTime = badLinkLifetime + Simulator::Now ();
+}
+
+void
+RoutingTableEntry::Print (std::ostream & os ) const
+{
+  os << m_ipv4Route->GetDestination () << "\t" << m_ipv4Route->GetGateway () << "\t" << m_ipv4Route->GetSource () << "\t";
   switch (m_flag)
-  {
-    case RTF_UP:
-    {
-      os << "UP";
-      break;
-    }
-    case RTF_DOWN:
     {
-      os << "DOWN";
-      break;
-    }
+    case RTF_UP:
+      {
+        os << "UP";
+        break;
+      }
+    case RTF_DOWN:
+      {
+        os << "DOWN";
+        break;
+      }
     case RTF_IN_REPAIR:
-    {
-      os << "IN_REPAIR";
-      break;
+      {
+        os << "IN_REPAIR";
+        break;
+      }
+    case RTF_IN_SEARCH:
+      {
+        os << "IN_SEARCH";
+        break;
+      }
     }
-    case RTF_IN_SEARCH:
-    {
-      os << "IN_SEARCH";
-      break;
-    }
-  }
-  os << "\t" << (m_lifeTime - Simulator::Now()).GetSeconds() << "\n";
+  os << "\t" << (m_lifeTime - Simulator::Now ()).GetSeconds () << "\n";
 }
 
 #ifdef RUN_SELF_TESTS
 /// Unit test for AODV routing table entry
 struct AodvRtableEntryTest : public Test
-{
-  AodvRtableEntryTest () : Test ("AODV/RtableEntry"), result(true) {}
-  virtual bool RunTests();
-  bool result;
-};
+  {
+    AodvRtableEntryTest () : Test ("AODV/RtableEntry"), result(true)
+      {}
+    virtual bool RunTests();
+    bool result;
+  };
 
 /// Test instance
 static AodvRtableEntryTest g_AodvRtableEntryTest;
 
 bool
 AodvRtableEntryTest::RunTests ()
-{
-  Ptr<NetDevice> dev;
-  Ipv4InterfaceAddress iface;
-  RoutingTableEntry rt (/*output device*/dev, /*dst*/Ipv4Address("1.2.3.4"), /*validSeqNo*/true, /*seqNo*/10,
-                           /*interface*/iface, /*hop*/5, /*next hop*/Ipv4Address("3.3.3.3"), /*lifetime*/Seconds(10));
-  NS_TEST_ASSERT_EQUAL (rt.GetOutputDevice (), dev);
-  NS_TEST_ASSERT_EQUAL (rt.GetDestination (), Ipv4Address("1.2.3.4"));
-  NS_TEST_ASSERT_EQUAL (rt.GetValidSeqNo (), true);
-  NS_TEST_ASSERT_EQUAL (rt.GetSeqNo (), 10);
-  NS_TEST_ASSERT_EQUAL (rt.GetInterface(), iface);
-  NS_TEST_ASSERT_EQUAL (rt.GetHop(), 5);
-  NS_TEST_ASSERT_EQUAL (rt.GetNextHop (), Ipv4Address ("3.3.3.3"));
-  NS_TEST_ASSERT_EQUAL (rt.GetLifeTime (), Seconds (10));
-  NS_TEST_ASSERT_EQUAL (rt.GetFlag (), RTF_UP);
-  NS_TEST_ASSERT_EQUAL (rt.GetRreqCnt(), 0);
-  NS_TEST_ASSERT_EQUAL (rt.IsPrecursorListEmpty(), true);
+  {
+    Ptr<NetDevice> dev;
+    Ipv4InterfaceAddress iface;
+    RoutingTableEntry rt (/*output device*/dev, /*dst*/Ipv4Address("1.2.3.4"), /*validSeqNo*/true, /*seqNo*/10,
+        /*interface*/iface, /*hop*/5, /*next hop*/Ipv4Address("3.3.3.3"), /*lifetime*/Seconds(10));
+    NS_TEST_ASSERT_EQUAL (rt.GetOutputDevice (), dev);
+    NS_TEST_ASSERT_EQUAL (rt.GetDestination (), Ipv4Address("1.2.3.4"));
+    NS_TEST_ASSERT_EQUAL (rt.GetValidSeqNo (), true);
+    NS_TEST_ASSERT_EQUAL (rt.GetSeqNo (), 10);
+    NS_TEST_ASSERT_EQUAL (rt.GetInterface(), iface);
+    NS_TEST_ASSERT_EQUAL (rt.GetHop(), 5);
+    NS_TEST_ASSERT_EQUAL (rt.GetNextHop (), Ipv4Address ("3.3.3.3"));
+    NS_TEST_ASSERT_EQUAL (rt.GetLifeTime (), Seconds (10));
+    NS_TEST_ASSERT_EQUAL (rt.GetFlag (), RTF_UP);
+    NS_TEST_ASSERT_EQUAL (rt.GetRreqCnt(), 0);
+    NS_TEST_ASSERT_EQUAL (rt.IsPrecursorListEmpty(), true);
 
-  rt.SetFlag(RTF_DOWN);
-  NS_TEST_ASSERT_EQUAL (rt.GetFlag (), RTF_DOWN);
-  rt.SetFlag(RTF_IN_REPAIR);
-  NS_TEST_ASSERT_EQUAL (rt.GetFlag (), RTF_IN_REPAIR);
-  rt.SetHop(12);
-  NS_TEST_ASSERT_EQUAL (rt.GetHop (), 12);
-  rt.SetLifeTime(Seconds(1));
-  NS_TEST_ASSERT_EQUAL (rt.GetLifeTime (), Seconds(1));
-  rt.SetNextHop(Ipv4Address("1.1.1.1"));
-  NS_TEST_ASSERT_EQUAL (rt.GetNextHop (), Ipv4Address ("1.1.1.1"));
-  rt.SetUnidirectional(true);
-  NS_TEST_ASSERT_EQUAL (rt.IsUnidirectional (), true);
-  rt.SetBalcklistTimeout (Seconds(7));
-  NS_TEST_ASSERT_EQUAL (rt.GetBlacklistTimeout(), Seconds (7));
-  rt.SetRreqCnt(2);
-  NS_TEST_ASSERT_EQUAL (rt.GetRreqCnt(), 2);
-  rt.IncrementRreqCnt();
-  NS_TEST_ASSERT_EQUAL (rt.GetRreqCnt(), 3);
-  rt.Invalidate(Seconds(13));
-  NS_TEST_ASSERT_EQUAL (rt.GetFlag (), RTF_DOWN);
-  NS_TEST_ASSERT_EQUAL (rt.GetLifeTime (), Seconds (13));
-  rt.SetLifeTime(Seconds(0.1));
-  NS_TEST_ASSERT_EQUAL (rt.GetLifeTime (), Seconds (0.1));
-  Ptr<Ipv4Route> route = rt.GetRoute();
-  NS_TEST_ASSERT_EQUAL (route->GetDestination(), Ipv4Address("1.2.3.4"));
+    rt.SetFlag(RTF_DOWN);
+    NS_TEST_ASSERT_EQUAL (rt.GetFlag (), RTF_DOWN);
+    rt.SetFlag(RTF_IN_REPAIR);
+    NS_TEST_ASSERT_EQUAL (rt.GetFlag (), RTF_IN_REPAIR);
+    rt.SetHop(12);
+    NS_TEST_ASSERT_EQUAL (rt.GetHop (), 12);
+    rt.SetLifeTime(Seconds(1));
+    NS_TEST_ASSERT_EQUAL (rt.GetLifeTime (), Seconds(1));
+    rt.SetNextHop(Ipv4Address("1.1.1.1"));
+    NS_TEST_ASSERT_EQUAL (rt.GetNextHop (), Ipv4Address ("1.1.1.1"));
+    rt.SetUnidirectional(true);
+    NS_TEST_ASSERT_EQUAL (rt.IsUnidirectional (), true);
+    rt.SetBalcklistTimeout (Seconds(7));
+    NS_TEST_ASSERT_EQUAL (rt.GetBlacklistTimeout(), Seconds (7));
+    rt.SetRreqCnt(2);
+    NS_TEST_ASSERT_EQUAL (rt.GetRreqCnt(), 2);
+    rt.IncrementRreqCnt();
+    NS_TEST_ASSERT_EQUAL (rt.GetRreqCnt(), 3);
+    rt.Invalidate(Seconds(13));
+    NS_TEST_ASSERT_EQUAL (rt.GetFlag (), RTF_DOWN);
+    NS_TEST_ASSERT_EQUAL (rt.GetLifeTime (), Seconds (13));
+    rt.SetLifeTime(Seconds(0.1));
+    NS_TEST_ASSERT_EQUAL (rt.GetLifeTime (), Seconds (0.1));
+    Ptr<Ipv4Route> route = rt.GetRoute();
+    NS_TEST_ASSERT_EQUAL (route->GetDestination(), Ipv4Address("1.2.3.4"));
 
-  NS_TEST_ASSERT_EQUAL (rt.InsertPrecursor(Ipv4Address("10.0.0.1")), true);
-  NS_TEST_ASSERT_EQUAL (rt.IsPrecursorListEmpty(), false);
-  NS_TEST_ASSERT_EQUAL (rt.InsertPrecursor(Ipv4Address("10.0.0.2")), true);
-  NS_TEST_ASSERT_EQUAL (rt.InsertPrecursor(Ipv4Address("10.0.0.2")), false);
-  NS_TEST_ASSERT_EQUAL (rt.LookupPrecursor(Ipv4Address("10.0.0.3")), false);
-  NS_TEST_ASSERT_EQUAL (rt.LookupPrecursor(Ipv4Address("10.0.0.1")), true);
-  NS_TEST_ASSERT_EQUAL (rt.DeletePrecursor(Ipv4Address("10.0.0.2")), true);
-  NS_TEST_ASSERT_EQUAL (rt.LookupPrecursor(Ipv4Address("10.0.0.2")), false);
-  std::vector<Ipv4Address>  prec;
-  rt.GetPrecursors(prec);
-  NS_TEST_ASSERT_EQUAL (prec.size(), 1);
-  NS_TEST_ASSERT_EQUAL (rt.InsertPrecursor(Ipv4Address("10.0.0.4")), true);
-  NS_TEST_ASSERT_EQUAL (rt.DeletePrecursor(Ipv4Address("10.0.0.5")), false);
-  rt.GetPrecursors(prec);
-  NS_TEST_ASSERT_EQUAL (prec.size(), 2);
-  rt.DeleteAllPrecursors();
-  NS_TEST_ASSERT_EQUAL (rt.IsPrecursorListEmpty(), true);
-  rt.GetPrecursors(prec);
-  NS_TEST_ASSERT_EQUAL (prec.size (), 2);
+    NS_TEST_ASSERT_EQUAL (rt.InsertPrecursor(Ipv4Address("10.0.0.1")), true);
+    NS_TEST_ASSERT_EQUAL (rt.IsPrecursorListEmpty(), false);
+    NS_TEST_ASSERT_EQUAL (rt.InsertPrecursor(Ipv4Address("10.0.0.2")), true);
+    NS_TEST_ASSERT_EQUAL (rt.InsertPrecursor(Ipv4Address("10.0.0.2")), false);
+    NS_TEST_ASSERT_EQUAL (rt.LookupPrecursor(Ipv4Address("10.0.0.3")), false);
+    NS_TEST_ASSERT_EQUAL (rt.LookupPrecursor(Ipv4Address("10.0.0.1")), true);
+    NS_TEST_ASSERT_EQUAL (rt.DeletePrecursor(Ipv4Address("10.0.0.2")), true);
+    NS_TEST_ASSERT_EQUAL (rt.LookupPrecursor(Ipv4Address("10.0.0.2")), false);
+    std::vector<Ipv4Address> prec;
+    rt.GetPrecursors(prec);
+    NS_TEST_ASSERT_EQUAL (prec.size(), 1);
+    NS_TEST_ASSERT_EQUAL (rt.InsertPrecursor(Ipv4Address("10.0.0.4")), true);
+    NS_TEST_ASSERT_EQUAL (rt.DeletePrecursor(Ipv4Address("10.0.0.5")), false);
+    rt.GetPrecursors(prec);
+    NS_TEST_ASSERT_EQUAL (prec.size(), 2);
+    rt.DeleteAllPrecursors();
+    NS_TEST_ASSERT_EQUAL (rt.IsPrecursorListEmpty(), true);
+    rt.GetPrecursors(prec);
+    NS_TEST_ASSERT_EQUAL (prec.size (), 2);
 
-
-  return result;
-}
+    return result;
+  }
 #endif
 
 /*
-  The Routing Table
+ The Routing Table
  */
 
 bool
-RoutingTable::LookupRoute(Ipv4Address id, RoutingTableEntry & rt)
+RoutingTable::LookupRoute (Ipv4Address id, RoutingTableEntry & rt )
 {
   Purge ();
-  if(m_ipv4AddressEntry.empty ()) return false;
-  std::map<Ipv4Address, RoutingTableEntry>::const_iterator i = m_ipv4AddressEntry.find(id);
-  if (i == m_ipv4AddressEntry.end()) return false;
+  if (m_ipv4AddressEntry.empty ())
+    return false;
+  std::map<Ipv4Address, RoutingTableEntry>::const_iterator i = m_ipv4AddressEntry.find (id);
+  if (i == m_ipv4AddressEntry.end ())
+    return false;
   rt = i->second;
   return true;
 }
 
 bool
-RoutingTable::DeleteRoute(Ipv4Address dst)
+RoutingTable::DeleteRoute (Ipv4Address dst )
 {
   Purge ();
-  if(m_ipv4AddressEntry.erase (dst) != 0) return true;
+  if (m_ipv4AddressEntry.erase (dst) != 0)
+    return true;
   return false;
 }
 
 bool
-RoutingTable::AddRoute(RoutingTableEntry & rt)
+RoutingTable::AddRoute (RoutingTableEntry & rt )
 {
   Purge ();
-  if(rt.GetFlag() != RTF_IN_SEARCH) rt.SetRreqCnt (0);
-  std::pair<std::map<Ipv4Address, RoutingTableEntry>::iterator, bool> result = m_ipv4AddressEntry.insert(std::make_pair(rt.GetDestination(), rt));
+  if (rt.GetFlag () != RTF_IN_SEARCH)
+    rt.SetRreqCnt (0);
+  std::pair<std::map<Ipv4Address, RoutingTableEntry>::iterator, bool> result = m_ipv4AddressEntry.insert (std::make_pair (rt.GetDestination (), rt));
   return result.second;
 }
 
 bool
-RoutingTable::Update(RoutingTableEntry & rt)
+RoutingTable::Update (RoutingTableEntry & rt )
 {
   Purge ();
-  std::map<Ipv4Address, RoutingTableEntry>::iterator i = m_ipv4AddressEntry.find(rt.GetDestination());
-  if (i == m_ipv4AddressEntry.end()) return false;
+  std::map<Ipv4Address, RoutingTableEntry>::iterator i = m_ipv4AddressEntry.find (rt.GetDestination ());
+  if (i == m_ipv4AddressEntry.end ())
+    return false;
   i->second = rt;
-  if(i->second.GetFlag() != RTF_IN_SEARCH) i->second.SetRreqCnt (0);
+  if (i->second.GetFlag () != RTF_IN_SEARCH)
+    i->second.SetRreqCnt (0);
   return true;
 }
 
 bool
-RoutingTable::SetEntryState (Ipv4Address id, RouteFlags state)
+RoutingTable::SetEntryState (Ipv4Address id, RouteFlags state )
 {
-  std::map<Ipv4Address, RoutingTableEntry>::iterator i = m_ipv4AddressEntry.find(id);
-  if (i == m_ipv4AddressEntry.end()) return false;
-  i->second.SetFlag(state);
+  std::map<Ipv4Address, RoutingTableEntry>::iterator i = m_ipv4AddressEntry.find (id);
+  if (i == m_ipv4AddressEntry.end ())
+    return false;
+  i->second.SetFlag (state);
   return true;
 }
 
 void
-RoutingTable::GetListOfDestinationWithNextHop(Ipv4Address nextHop, std::map<Ipv4Address, uint32_t> unreachable)
+RoutingTable::GetListOfDestinationWithNextHop (Ipv4Address nextHop, std::map<Ipv4Address, uint32_t> unreachable )
 {
   Purge ();
-  unreachable.clear();
-  for(std::map<Ipv4Address, RoutingTableEntry>::const_iterator i = m_ipv4AddressEntry.begin(); i != m_ipv4AddressEntry.end(); ++i)
-    if ( (i->second.GetNextHop() == nextHop) && (i->second.GetFlag() == RTF_UP)  && (!i->second.IsPrecursorListEmpty()) )
-      unreachable.insert(std::make_pair(i->first, i->second.GetSeqNo()));
+  unreachable.clear ();
+  for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator i = m_ipv4AddressEntry.begin (); i != m_ipv4AddressEntry.end (); ++i)
+    if ((i->second.GetNextHop () == nextHop) && (i->second.GetFlag () == RTF_UP) && (!i->second.IsPrecursorListEmpty ()))
+      unreachable.insert (std::make_pair (i->first, i->second.GetSeqNo ()));
 }
 
 void
-RoutingTable::InvalidateRoutesWithDst(const std::map<Ipv4Address, uint32_t> & unreachable)
+RoutingTable::InvalidateRoutesWithDst (const std::map<Ipv4Address, uint32_t> & unreachable )
 {
   Purge ();
-  for(std::map<Ipv4Address, RoutingTableEntry>::iterator i = m_ipv4AddressEntry.begin(); i != m_ipv4AddressEntry.end(); ++i)
-  {
-    for(std::map<Ipv4Address, uint32_t>::const_iterator j =  unreachable.begin(); j != unreachable.end(); ++j)
-      if ( (i->first == j->first) && (i->second.GetFlag() == RTF_UP))
-        i->second.Invalidate(m_badLinkLifetime);
-  }
+  for (std::map<Ipv4Address, RoutingTableEntry>::iterator i = m_ipv4AddressEntry.begin (); i != m_ipv4AddressEntry.end (); ++i)
+    {
+      for (std::map<Ipv4Address, uint32_t>::const_iterator j = unreachable.begin (); j != unreachable.end (); ++j)
+        if ((i->first == j->first) && (i->second.GetFlag () == RTF_UP))
+          i->second.Invalidate (m_badLinkLifetime);
+    }
 
 }
 
 void
-RoutingTable::Purge()
+RoutingTable::Purge ()
 {
-  if(m_ipv4AddressEntry.empty ()) return;
-  for(std::map<Ipv4Address, RoutingTableEntry>::iterator i = m_ipv4AddressEntry.begin(); i != m_ipv4AddressEntry.end();)
-  {
-    if(i->second.GetLifeTime() < Seconds(0))
+  if (m_ipv4AddressEntry.empty ())
+    return;
+  for (std::map<Ipv4Address, RoutingTableEntry>::iterator i = m_ipv4AddressEntry.begin (); i != m_ipv4AddressEntry.end ();)
     {
-      if(i->second.GetFlag() == RTF_DOWN)
-      {
-        std::map<Ipv4Address, RoutingTableEntry>::iterator tmp = i;
-        ++i;
-        m_ipv4AddressEntry.erase(tmp);
-      }
-      else if (i->second.GetFlag() == RTF_UP)
-      {
-        NS_LOG_UNCOND ("ivalidate route with dst " << i->first );
-        i->second.Invalidate(m_badLinkLifetime);
-        ++i;
-      }
-      else ++i;
+      if (i->second.GetLifeTime () < Seconds (0))
+        {
+          if (i->second.GetFlag () == RTF_DOWN)
+            {
+              std::map<Ipv4Address, RoutingTableEntry>::iterator tmp = i;
+              ++i;
+              m_ipv4AddressEntry.erase (tmp);
+            }
+          else if (i->second.GetFlag () == RTF_UP)
+            {
+              NS_LOG_UNCOND ("ivalidate route with dst " << i->first );
+              i->second.Invalidate (m_badLinkLifetime);
+              ++i;
+            }
+          else
+            ++i;
+        }
+      ++i;
     }
-    ++i;
-  }
 }
 
 bool
-RoutingTable::MarkLinkAsUinidirectional (Ipv4Address neighbor, Time blacklistTimeout)
+RoutingTable::MarkLinkAsUinidirectional (Ipv4Address neighbor, Time blacklistTimeout )
 {
-  std::map<Ipv4Address, RoutingTableEntry>::iterator i = m_ipv4AddressEntry.find(neighbor);
-  if (i == m_ipv4AddressEntry.end()) return false;
+  std::map<Ipv4Address, RoutingTableEntry>::iterator i = m_ipv4AddressEntry.find (neighbor);
+  if (i == m_ipv4AddressEntry.end ())
+    return false;
   i->second.SetUnidirectional (true);
-  i->second.SetBalcklistTimeout(blacklistTimeout);
+  i->second.SetBalcklistTimeout (blacklistTimeout);
   return true;
 }
 
 void
-RoutingTable::Print(std::ostream &os) const
+RoutingTable::Print (std::ostream &os ) const
 {
-  os << "\nAODV Routing table\n"
-     << "Destination\tGateway\t\tInterface\tFlag\tExpire\n";
-  for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator i = m_ipv4AddressEntry.begin(); i != m_ipv4AddressEntry.end(); ++i)
+  os << "\nAODV Routing table\n" << "Destination\tGateway\t\tInterface\tFlag\tExpire\n";
+  for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator i = m_ipv4AddressEntry.begin (); i != m_ipv4AddressEntry.end (); ++i)
     {
-      i->second.Print(os);
+      i->second.Print (os);
     }
   os << "\n";
 
@@ -360,68 +375,67 @@
 #ifdef RUN_SELF_TESTS
 /// Unit test for AODV routing table
 struct AodvRtableTest : public Test
-{
-  AodvRtableTest () : Test ("AODV/Rtable"), result(true) {}
-  virtual bool RunTests();
-  bool result;
-};
+  {
+    AodvRtableTest () : Test ("AODV/Rtable"), result(true)
+      {}
+    virtual bool RunTests();
+    bool result;
+  };
 
 /// Test instance
 static AodvRtableTest g_AodvRtableTest;
 
 bool
 AodvRtableTest::RunTests ()
-{
-  RoutingTable rtable (Seconds(2));
-  NS_TEST_ASSERT_EQUAL (rtable.GetBadLinkLifetime(), Seconds(2));
-  rtable.SetBadLinkLifetime(Seconds(1));
-  NS_TEST_ASSERT_EQUAL (rtable.GetBadLinkLifetime(), Seconds(1));
-  Ptr<NetDevice> dev;
-  Ipv4InterfaceAddress iface;
-  RoutingTableEntry rt (/*output device*/dev, /*dst*/Ipv4Address("1.2.3.4"), /*validSeqNo*/true, /*seqNo*/10,
-                           /*interface*/iface, /*hop*/5, /*next hop*/Ipv4Address("1.1.1.1"), /*lifetime*/Seconds(10));
-  NS_TEST_ASSERT_EQUAL (rtable.AddRoute (rt), true);
-  NS_TEST_ASSERT_EQUAL (rtable.AddRoute (rt), false);
-  RoutingTableEntry rt2 (/*output device*/dev, /*dst*/Ipv4Address("4.3.2.1"), /*validSeqNo*/false, /*seqNo*/0,
-                           /*interface*/iface, /*hop*/15, /*next hop*/Ipv4Address("1.1.1.1"), /*lifetime*/Seconds(1));
-  NS_TEST_ASSERT_EQUAL (rtable.AddRoute (rt2), true);
-  NS_TEST_ASSERT_EQUAL (rtable.LookupRoute(rt2.GetDestination(), rt), true);
-  NS_TEST_ASSERT_EQUAL (rt2.GetDestination (), rt.GetDestination ());
-  rt.SetHop(20);
-  rt.InsertPrecursor(Ipv4Address("10.0.0.3"));
-  NS_TEST_ASSERT_EQUAL (rtable.Update (rt), true);
-  RoutingTableEntry rt3;
-  NS_TEST_ASSERT_EQUAL (rtable.LookupRoute(Ipv4Address("10.0.0.1"), rt), false);
-  NS_TEST_ASSERT_EQUAL (rtable.Update (rt3), false);
-  NS_TEST_ASSERT_EQUAL (rtable.SetEntryState(Ipv4Address("10.0.0.1"), RTF_DOWN), false);
-  NS_TEST_ASSERT_EQUAL (rtable.SetEntryState(Ipv4Address("1.2.3.4"), RTF_IN_SEARCH), true);
-  NS_TEST_ASSERT_EQUAL (rtable.DeleteRoute(Ipv4Address("5.5.5.5")), false);
-  RoutingTableEntry rt4 (/*output device*/dev, /*dst*/Ipv4Address("5.5.5.5"), /*validSeqNo*/false, /*seqNo*/0,
-                           /*interface*/iface, /*hop*/15, /*next hop*/Ipv4Address("1.1.1.1"), /*lifetime*/Seconds(-10));
-  NS_TEST_ASSERT_EQUAL (rtable.AddRoute (rt4), true);
-  NS_TEST_ASSERT_EQUAL (rtable.SetEntryState(Ipv4Address("5.5.5.5"), RTF_DOWN), true);
-  NS_TEST_ASSERT_EQUAL (rtable.LookupRoute(Ipv4Address("5.5.5.5"), rt), false);
+  {
+    RoutingTable rtable (Seconds(2));
+    NS_TEST_ASSERT_EQUAL (rtable.GetBadLinkLifetime(), Seconds(2));
+    rtable.SetBadLinkLifetime(Seconds(1));
+    NS_TEST_ASSERT_EQUAL (rtable.GetBadLinkLifetime(), Seconds(1));
+    Ptr<NetDevice> dev;
+    Ipv4InterfaceAddress iface;
+    RoutingTableEntry rt (/*output device*/dev, /*dst*/Ipv4Address("1.2.3.4"), /*validSeqNo*/true, /*seqNo*/10,
+        /*interface*/iface, /*hop*/5, /*next hop*/Ipv4Address("1.1.1.1"), /*lifetime*/Seconds(10));
+    NS_TEST_ASSERT_EQUAL (rtable.AddRoute (rt), true);
+    NS_TEST_ASSERT_EQUAL (rtable.AddRoute (rt), false);
+    RoutingTableEntry rt2 (/*output device*/dev, /*dst*/Ipv4Address("4.3.2.1"), /*validSeqNo*/false, /*seqNo*/0,
+        /*interface*/iface, /*hop*/15, /*next hop*/Ipv4Address("1.1.1.1"), /*lifetime*/Seconds(1));
+    NS_TEST_ASSERT_EQUAL (rtable.AddRoute (rt2), true);
+    NS_TEST_ASSERT_EQUAL (rtable.LookupRoute(rt2.GetDestination(), rt), true);
+    NS_TEST_ASSERT_EQUAL (rt2.GetDestination (), rt.GetDestination ());
+    rt.SetHop(20);
+    rt.InsertPrecursor(Ipv4Address("10.0.0.3"));
+    NS_TEST_ASSERT_EQUAL (rtable.Update (rt), true);
+    RoutingTableEntry rt3;
+    NS_TEST_ASSERT_EQUAL (rtable.LookupRoute(Ipv4Address("10.0.0.1"), rt), false);
+    NS_TEST_ASSERT_EQUAL (rtable.Update (rt3), false);
+    NS_TEST_ASSERT_EQUAL (rtable.SetEntryState(Ipv4Address("10.0.0.1"), RTF_DOWN), false);
+    NS_TEST_ASSERT_EQUAL (rtable.SetEntryState(Ipv4Address("1.2.3.4"), RTF_IN_SEARCH), true);
+    NS_TEST_ASSERT_EQUAL (rtable.DeleteRoute(Ipv4Address("5.5.5.5")), false);
+    RoutingTableEntry rt4 (/*output device*/dev, /*dst*/Ipv4Address("5.5.5.5"), /*validSeqNo*/false, /*seqNo*/0,
+        /*interface*/iface, /*hop*/15, /*next hop*/Ipv4Address("1.1.1.1"), /*lifetime*/Seconds(-10));
+    NS_TEST_ASSERT_EQUAL (rtable.AddRoute (rt4), true);
+    NS_TEST_ASSERT_EQUAL (rtable.SetEntryState(Ipv4Address("5.5.5.5"), RTF_DOWN), true);
+    NS_TEST_ASSERT_EQUAL (rtable.LookupRoute(Ipv4Address("5.5.5.5"), rt), false);
 
-  NS_TEST_ASSERT_EQUAL (rtable.MarkLinkAsUinidirectional(Ipv4Address("1.2.3.4"), Seconds(2)), true);
-  NS_TEST_ASSERT_EQUAL (rtable.LookupRoute(Ipv4Address("1.2.3.4"), rt), true);
-  NS_TEST_ASSERT_EQUAL (rt.IsUnidirectional(), true);
-  rt.SetLifeTime(Seconds(-5));
-  NS_TEST_ASSERT_EQUAL (rtable.Update (rt), true);
-  std::map<Ipv4Address, uint32_t>  unreachable;
-  unreachable.insert (std::make_pair(Ipv4Address("4.3.2.1"), 3));
-  rtable.InvalidateRoutesWithDst(unreachable);
-  NS_TEST_ASSERT_EQUAL (rtable.LookupRoute(Ipv4Address("4.3.2.1"), rt), true);
-  NS_TEST_ASSERT_EQUAL (rt.GetFlag(), RTF_DOWN);
-  rtable.GetListOfDestinationWithNextHop(Ipv4Address("1.1.1.1"), unreachable);
-  NS_TEST_ASSERT_EQUAL (unreachable.size (), 1);
-  NS_TEST_ASSERT_EQUAL (rtable.DeleteRoute(Ipv4Address("1.2.3.4")), true);
-  NS_TEST_ASSERT_EQUAL (rtable.DeleteRoute(Ipv4Address("1.2.3.4")), false);
+    NS_TEST_ASSERT_EQUAL (rtable.MarkLinkAsUinidirectional(Ipv4Address("1.2.3.4"), Seconds(2)), true);
+    NS_TEST_ASSERT_EQUAL (rtable.LookupRoute(Ipv4Address("1.2.3.4"), rt), true);
+    NS_TEST_ASSERT_EQUAL (rt.IsUnidirectional(), true);
+    rt.SetLifeTime(Seconds(-5));
+    NS_TEST_ASSERT_EQUAL (rtable.Update (rt), true);
+    std::map<Ipv4Address, uint32_t> unreachable;
+    unreachable.insert (std::make_pair(Ipv4Address("4.3.2.1"), 3));
+    rtable.InvalidateRoutesWithDst(unreachable);
+    NS_TEST_ASSERT_EQUAL (rtable.LookupRoute(Ipv4Address("4.3.2.1"), rt), true);
+    NS_TEST_ASSERT_EQUAL (rt.GetFlag(), RTF_DOWN);
+    rtable.GetListOfDestinationWithNextHop(Ipv4Address("1.1.1.1"), unreachable);
+    NS_TEST_ASSERT_EQUAL (unreachable.size (), 1);
+    NS_TEST_ASSERT_EQUAL (rtable.DeleteRoute(Ipv4Address("1.2.3.4")), true);
+    NS_TEST_ASSERT_EQUAL (rtable.DeleteRoute(Ipv4Address("1.2.3.4")), false);
 
-
-  return result;
-}
+    return result;
+  }
 #endif
 
-
-
-}}
+}
+}
--- a/src/routing/aodv/id-cache.cc	Mon Aug 03 18:42:39 2009 +0400
+++ b/src/routing/aodv/id-cache.cc	Mon Aug 03 18:54:00 2009 +0400
@@ -32,11 +32,12 @@
 namespace aodv
 {
 void
-IdCache::InsertId (Ipv4Address addr, uint32_t id, Time saveTime)
+IdCache::InsertId (Ipv4Address addr, uint32_t id, Time saveTime )
 {
   if (LookupId (addr, id))
     return;
-  struct UniqueId uniqueId = { addr, id, saveTime + Simulator::Now () };
+  struct UniqueId uniqueId =
+  { addr, id, saveTime + Simulator::Now () };
   m_idCache.push_back (uniqueId);
 }
 bool