--- a/src/routing/static-route-manager.cc Tue Jul 10 01:28:19 2007 -0700
+++ b/src/routing/static-route-manager.cc Tue Jul 10 09:31:07 2007 -0700
@@ -92,10 +92,8 @@
StaticRouterLSA lsa;
rtr->GetLSA(j, lsa);
NS_DEBUG_UNCOND ("LSA " << j);
- NS_DEBUG_UNCOND ("----------------------------------------");
- NS_DEBUG_UNCOND("m_linkStateId = " << lsa.m_linkStateId);
- NS_DEBUG_UNCOND("m_advertisingRtr = " << lsa.m_advertisingRtr);
- NS_DEBUG_UNCOND ("----------------------------------------");
+ NS_DEBUG_UNCOND ("----------------------------");
+ NS_DEBUG_UNCOND(lsa);
}
}
}
--- a/src/routing/static-router.cc Tue Jul 10 01:28:19 2007 -0700
+++ b/src/routing/static-router.cc Tue Jul 10 09:31:07 2007 -0700
@@ -35,9 +35,6 @@
NS_DEBUG("StaticRouterLSA::StaticRouterLSA ()");
}
-//
-// Copy constructor for StaticRouterLSA
-//
StaticRouterLSA::StaticRouterLSA (StaticRouterLSA& lsa)
: m_linkStateId(lsa.m_linkStateId), m_advertisingRtr(lsa.m_advertisingRtr)
{
@@ -57,18 +54,27 @@
}
}
-//
-// Assignment operator for StaticRouterLSA
-//
-// This uses the non-obvious trick of taking the source LSA passed by
-// value instead of by reference. This causes the copy constructor to be
-// invoked (where the real work is done -- see above). All we have to do
-// here is to return the newly constructed LSA.
-//
StaticRouterLSA&
StaticRouterLSA::operator= (StaticRouterLSA lsa)
{
NS_DEBUG("StaticRouterLSA Operator =");
+ NS_ASSERT_MSG(IsEmpty(), "The LSA must be empty before assignment");
+
+ m_linkStateId = lsa.m_linkStateId;
+ m_advertisingRtr = lsa.m_advertisingRtr;
+
+ for ( ListOfLinkRecords_t::iterator i = lsa.m_linkRecords.begin ();
+ i != lsa.m_linkRecords.end ();
+ i++)
+ {
+ StaticRouterLinkRecord *pSrc = *i;
+ StaticRouterLinkRecord *pDst = new StaticRouterLinkRecord;
+ pDst->m_linkId = pSrc->m_linkId;
+ pDst->m_linkData = pSrc->m_linkData;
+ m_linkRecords.push_back(pDst);
+ pDst = 0;
+ }
+
return *this;
}