internet: Add Ptr<Node> member to SPFVertex
This commit is contained in:
@@ -104,6 +104,7 @@ SPFVertex::SPFVertex(GlobalRoutingLSA* lsa)
|
||||
{
|
||||
NS_LOG_LOGIC("Setting m_vertexType to VertexRouter");
|
||||
m_vertexType = SPFVertex::VertexRouter;
|
||||
m_node = lsa->GetNode();
|
||||
}
|
||||
else if (lsa->GetLSType() == GlobalRoutingLSA::NetworkLSA)
|
||||
{
|
||||
@@ -405,6 +406,12 @@ SPFVertex::ClearVertexProcessed()
|
||||
this->SetVertexProcessed(false);
|
||||
}
|
||||
|
||||
Ptr<Node>
|
||||
SPFVertex::GetNode() const
|
||||
{
|
||||
return m_node;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// GlobalRouteManagerLSDB Implementation
|
||||
@@ -1529,37 +1536,30 @@ GlobalRouteManagerImpl::SPFAddASExternal(GlobalRoutingLSA* extlsa, SPFVertex* v)
|
||||
|
||||
NS_LOG_LOGIC("Vertex ID = " << routerId);
|
||||
//
|
||||
// We need to walk the list of nodes looking for the one that has the router
|
||||
// ID corresponding to the root vertex. This is the one we're going to write
|
||||
// the routing information to.
|
||||
// The node we need to add routes to is the node corresponding to the root vertex.
|
||||
// This is the node for which we are building the routing table.
|
||||
//
|
||||
for (auto i = NodeList::Begin(); i != NodeList::End(); i++)
|
||||
Ptr<Node> node = m_spfroot->GetNode();
|
||||
|
||||
if (!node)
|
||||
{
|
||||
Ptr<Node> node = *i;
|
||||
NS_FATAL_ERROR("SPFAddASExternal():Can't find root node " << routerId);
|
||||
return;
|
||||
}
|
||||
//
|
||||
// The router ID is accessible through the GlobalRouter interface, so we need
|
||||
// to QI for that interface. If there's no GlobalRouter interface, the node
|
||||
// in question cannot be the router we want, so we continue.
|
||||
//
|
||||
Ptr<GlobalRouter> rtr = node->GetObject<GlobalRouter>();
|
||||
|
||||
if (!rtr)
|
||||
{
|
||||
NS_LOG_LOGIC("No GlobalRouter interface on node " << node->GetId());
|
||||
continue;
|
||||
}
|
||||
Ptr<GlobalRouter> router = node->GetObject<GlobalRouter>();
|
||||
NS_ASSERT_MSG(router, "No GlobalRouter interface on SPF root node " << node->GetId());
|
||||
//
|
||||
// If the router ID of the current node is equal to the router ID of the
|
||||
// root of the SPF tree, then this node is the one for which we need to
|
||||
// write the routing tables.
|
||||
//
|
||||
NS_LOG_LOGIC("Considering router " << rtr->GetRouterId());
|
||||
|
||||
if (rtr->GetRouterId() != routerId)
|
||||
if (router->GetRouterId() == routerId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
NS_LOG_LOGIC("Setting routes for node " << node->GetId());
|
||||
//
|
||||
// Routing information is updated using the Ipv4 interface. We need to QI
|
||||
@@ -1597,10 +1597,9 @@ GlobalRouteManagerImpl::SPFAddASExternal(GlobalRoutingLSA* extlsa, SPFVertex* v)
|
||||
// which the packets should be send for forwarding.
|
||||
//
|
||||
Ptr<GlobalRouter> router = node->GetObject<GlobalRouter>();
|
||||
if (!router)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
NS_ASSERT_MSG(router, "No GlobalRouter interface on node " << node->GetId());
|
||||
|
||||
Ptr<Ipv4GlobalRouting> gr = router->GetRoutingProtocol();
|
||||
NS_ASSERT(gr);
|
||||
// walk through all next-hop-IPs and out-going-interfaces for reaching
|
||||
@@ -1628,6 +1627,8 @@ GlobalRouteManagerImpl::SPFAddASExternal(GlobalRoutingLSA* extlsa, SPFVertex* v)
|
||||
}
|
||||
return;
|
||||
}
|
||||
// This should never happen. The RouterId and vertexId should match
|
||||
NS_FATAL_ERROR("SPFIntraAddRouter(): routerId and vertex ID do not match");
|
||||
}
|
||||
|
||||
// Processing logic from RFC 2328, page 166 and quagga ospf_spf_process_stubs ()
|
||||
@@ -1695,33 +1696,28 @@ GlobalRouteManagerImpl::SPFIntraAddStub(GlobalRoutingLinkRecord* l, SPFVertex* v
|
||||
|
||||
NS_LOG_LOGIC("Vertex ID = " << routerId);
|
||||
//
|
||||
// We need to walk the list of nodes looking for the one that has the router
|
||||
// ID corresponding to the root vertex. This is the one we're going to write
|
||||
// the routing information to.
|
||||
// The node we need to add routes to is the node corresponding to the root vertex.
|
||||
// This is the node for which we are building the routing table.
|
||||
//
|
||||
for (auto i = NodeList::Begin(); i != NodeList::End(); i++)
|
||||
Ptr<Node> node = m_spfroot->GetNode();
|
||||
if (!node)
|
||||
{
|
||||
Ptr<Node> node = *i;
|
||||
NS_LOG_ERROR("SPFIntraAddStub():Can't find root node " << routerId);
|
||||
return;
|
||||
}
|
||||
//
|
||||
// The router ID is accessible through the GlobalRouter interface, so we need
|
||||
// to QI for that interface. If there's no GlobalRouter interface, the node
|
||||
// in question cannot be the router we want, so we continue.
|
||||
//
|
||||
Ptr<GlobalRouter> rtr = node->GetObject<GlobalRouter>();
|
||||
|
||||
if (!rtr)
|
||||
{
|
||||
NS_LOG_LOGIC("No GlobalRouter interface on node " << node->GetId());
|
||||
continue;
|
||||
}
|
||||
Ptr<GlobalRouter> router = node->GetObject<GlobalRouter>();
|
||||
NS_ASSERT_MSG(router, "No GlobalRouter interface on node " << node->GetId());
|
||||
//
|
||||
// If the router ID of the current node is equal to the router ID of the
|
||||
// root of the SPF tree, then this node is the one for which we need to
|
||||
// write the routing tables.
|
||||
//
|
||||
NS_LOG_LOGIC("Considering router " << rtr->GetRouterId());
|
||||
|
||||
if (rtr->GetRouterId() == routerId)
|
||||
if (routerId == router->GetRouterId())
|
||||
{
|
||||
NS_LOG_LOGIC("Setting routes for node " << node->GetId());
|
||||
//
|
||||
@@ -1760,10 +1756,7 @@ GlobalRouteManagerImpl::SPFIntraAddStub(GlobalRoutingLinkRecord* l, SPFVertex* v
|
||||
//
|
||||
|
||||
Ptr<GlobalRouter> router = node->GetObject<GlobalRouter>();
|
||||
if (!router)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Ptr<Ipv4GlobalRouting> gr = router->GetRoutingProtocol();
|
||||
NS_ASSERT(gr);
|
||||
// walk through all next-hop-IPs and out-going-interfaces for reaching
|
||||
@@ -1777,9 +1770,8 @@ GlobalRouteManagerImpl::SPFIntraAddStub(GlobalRoutingLinkRecord* l, SPFVertex* v
|
||||
{
|
||||
gr->AddNetworkRouteTo(tempip, tempmask, nextHop, outIf);
|
||||
NS_LOG_LOGIC("(Route " << i << ") Node " << node->GetId()
|
||||
<< " add network route to " << tempip
|
||||
<< " using next hop " << nextHop << " via interface "
|
||||
<< outIf);
|
||||
<< " add network route to " << tempip << " using next hop "
|
||||
<< nextHop << " via interface " << outIf);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1791,7 +1783,8 @@ GlobalRouteManagerImpl::SPFIntraAddStub(GlobalRoutingLinkRecord* l, SPFVertex* v
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
// This should never happen. The RouterId and vertex Id should match
|
||||
NS_LOG_ERROR("SPFIntraAddStub(): routerId and vertex ID do not match");
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1815,23 +1808,25 @@ GlobalRouteManagerImpl::FindOutgoingInterfaceId(Ipv4Address a, Ipv4Mask amask)
|
||||
//
|
||||
Ipv4Address routerId = m_spfroot->GetVertexId();
|
||||
//
|
||||
// Walk the list of nodes in the system looking for the one corresponding to
|
||||
// the node at the root of the SPF tree. This is the node for which we are
|
||||
// building the routing table.
|
||||
// The node we need to add routes to is the node corresponding to the root vertex.
|
||||
// This is the node for which we are building the routing table.
|
||||
//
|
||||
for (auto i = NodeList::Begin(); i != NodeList::End(); i++)
|
||||
Ptr<Node> node = m_spfroot->GetNode();
|
||||
if (!node)
|
||||
{
|
||||
Ptr<Node> node = *i;
|
||||
//
|
||||
// Couldn't find it.
|
||||
//
|
||||
NS_LOG_LOGIC("FindOutgoingInterfaceId():Can't find root node " << routerId);
|
||||
return -1;
|
||||
}
|
||||
|
||||
Ptr<GlobalRouter> rtr = node->GetObject<GlobalRouter>();
|
||||
NS_ASSERT_MSG(rtr, "No GlobalRouter interface on node " << node->GetId());
|
||||
//
|
||||
// If the node doesn't have a GlobalRouter interface it can't be the one
|
||||
// we're interested in.
|
||||
//
|
||||
if (!rtr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (rtr->GetRouterId() == routerId)
|
||||
{
|
||||
@@ -1861,11 +1856,8 @@ GlobalRouteManagerImpl::FindOutgoingInterfaceId(Ipv4Address a, Ipv4Mask amask)
|
||||
#endif
|
||||
return interface;
|
||||
}
|
||||
}
|
||||
//
|
||||
// Couldn't find it.
|
||||
//
|
||||
NS_LOG_LOGIC("FindOutgoingInterfaceId():Can't find root node " << routerId);
|
||||
// This should never happen. The RouterId and vertex Id should match
|
||||
NS_FATAL_ERROR("SPFIntraAddRouter(): routerId and vertex ID do not match");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1902,37 +1894,31 @@ GlobalRouteManagerImpl::SPFIntraAddRouter(SPFVertex* v)
|
||||
|
||||
NS_LOG_LOGIC("Vertex ID = " << routerId);
|
||||
//
|
||||
// We need to walk the list of nodes looking for the one that has the router
|
||||
// ID corresponding to the root vertex. This is the one we're going to write
|
||||
// the routing information to.
|
||||
// The node we need to add routes to is the node corresponding to the root vertex.
|
||||
// This is the node for which we are building the routing table.
|
||||
//
|
||||
for (auto i = NodeList::Begin(); i != NodeList::End(); i++)
|
||||
Ptr<Node> node = m_spfroot->GetNode();
|
||||
if (!node)
|
||||
{
|
||||
Ptr<Node> node = *i;
|
||||
NS_LOG_ERROR("SPFIntraAddRouter():Can't find root node " << routerId);
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// The router ID is accessible through the GlobalRouter interface, so we need
|
||||
// to GetObject for that interface. If there's no GlobalRouter interface,
|
||||
// the node in question cannot be the router we want, so we continue.
|
||||
//
|
||||
Ptr<GlobalRouter> rtr = node->GetObject<GlobalRouter>();
|
||||
|
||||
if (!rtr)
|
||||
{
|
||||
NS_LOG_LOGIC("No GlobalRouter interface on node " << node->GetId());
|
||||
continue;
|
||||
}
|
||||
NS_ASSERT_MSG(rtr, "No GlobalRouter interface on node " << node->GetId());
|
||||
//
|
||||
// If the router ID of the current node is equal to the router ID of the
|
||||
// root of the SPF tree, then this node is the one for which we need to
|
||||
// write the routing tables.
|
||||
//
|
||||
NS_LOG_LOGIC("Considering router " << rtr->GetRouterId());
|
||||
|
||||
if (rtr->GetRouterId() != routerId)
|
||||
if (rtr->GetRouterId() == routerId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
NS_LOG_LOGIC("Setting routes for node " << node->GetId());
|
||||
//
|
||||
// Routing information is updated using the Ipv4 interface. We need to
|
||||
@@ -2026,6 +2012,8 @@ GlobalRouteManagerImpl::SPFIntraAddRouter(SPFVertex* v)
|
||||
//
|
||||
return;
|
||||
}
|
||||
// This should never happen. The RouterId and vertex Id should match
|
||||
NS_FATAL_ERROR("SPFIntraAddRouter(): routerId and vertex ID do not match");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2045,31 +2033,28 @@ GlobalRouteManagerImpl::SPFIntraAddTransit(SPFVertex* v)
|
||||
|
||||
NS_LOG_LOGIC("Vertex ID = " << routerId);
|
||||
//
|
||||
// We need to walk the list of nodes looking for the one that has the router
|
||||
// ID corresponding to the root vertex. This is the one we're going to write
|
||||
// the routing information to.
|
||||
// The node we need to add routes to is the node corresponding to the root vertex.
|
||||
// This is the node for which we are building the routing table.
|
||||
//
|
||||
for (auto i = NodeList::Begin(); i != NodeList::End(); i++)
|
||||
Ptr<Node> node = m_spfroot->GetNode();
|
||||
if (!node)
|
||||
{
|
||||
Ptr<Node> node = *i;
|
||||
NS_LOG_ERROR("SPFIntraAddTransit():Can't find root node " << routerId);
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// The router ID is accessible through the GlobalRouter interface, so we need
|
||||
// to GetObject for that interface. If there's no GlobalRouter interface,
|
||||
// the node in question cannot be the router we want, so we continue.
|
||||
//
|
||||
Ptr<GlobalRouter> rtr = node->GetObject<GlobalRouter>();
|
||||
|
||||
if (!rtr)
|
||||
{
|
||||
NS_LOG_LOGIC("No GlobalRouter interface on node " << node->GetId());
|
||||
continue;
|
||||
}
|
||||
NS_ASSERT_MSG(rtr, "No GlobalRouter interface on node " << node->GetId());
|
||||
//
|
||||
// If the router ID of the current node is equal to the router ID of the
|
||||
// root of the SPF tree, then this node is the one for which we need to
|
||||
// write the routing tables.
|
||||
//
|
||||
NS_LOG_LOGIC("Considering router " << rtr->GetRouterId());
|
||||
|
||||
if (rtr->GetRouterId() == routerId)
|
||||
{
|
||||
@@ -2097,10 +2082,6 @@ GlobalRouteManagerImpl::SPFIntraAddTransit(SPFVertex* v)
|
||||
Ipv4Address tempip = lsa->GetLinkStateId();
|
||||
tempip = tempip.CombineMask(tempmask);
|
||||
Ptr<GlobalRouter> router = node->GetObject<GlobalRouter>();
|
||||
if (!router)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Ptr<Ipv4GlobalRouting> gr = router->GetRoutingProtocol();
|
||||
NS_ASSERT(gr);
|
||||
// walk through all available exit directions due to ECMP,
|
||||
@@ -2116,9 +2097,8 @@ GlobalRouteManagerImpl::SPFIntraAddTransit(SPFVertex* v)
|
||||
{
|
||||
gr->AddNetworkRouteTo(tempip, tempmask, nextHop, outIf);
|
||||
NS_LOG_LOGIC("(Route " << i << ") Node " << node->GetId()
|
||||
<< " add network route to " << tempip
|
||||
<< " using next hop " << nextHop << " via interface "
|
||||
<< outIf);
|
||||
<< " add network route to " << tempip << " using next hop "
|
||||
<< nextHop << " via interface " << outIf);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2128,8 +2108,13 @@ GlobalRouteManagerImpl::SPFIntraAddTransit(SPFVertex* v)
|
||||
<< " since outgoing interface id is negative " << outIf);
|
||||
}
|
||||
}
|
||||
//
|
||||
// done adding routes for the root node.
|
||||
//
|
||||
return;
|
||||
}
|
||||
}
|
||||
// This should never happen. The RouterId and vertex Id should match
|
||||
NS_FATAL_ERROR("SPFIntraAddTransit(): routerId and vertex ID do not match");
|
||||
}
|
||||
|
||||
// Derived from quagga ospf_vertex_add_parents ()
|
||||
|
||||
@@ -522,6 +522,12 @@ class SPFVertex
|
||||
*/
|
||||
void ClearVertexProcessed();
|
||||
|
||||
/**
|
||||
* @brief Get the node pointer corresponding to this Vertex
|
||||
* @returns the node pointer corresponding to this Vertex
|
||||
*/
|
||||
Ptr<Node> GetNode() const;
|
||||
|
||||
private:
|
||||
VertexType m_vertexType; //!< Vertex type
|
||||
Ipv4Address m_vertexId; //!< Vertex ID
|
||||
@@ -536,6 +542,7 @@ class SPFVertex
|
||||
ListOfSPFVertex_t m_children; //!< Children list
|
||||
bool m_vertexProcessed; //!< Flag to note whether vertex has been processed in stage two of SPF
|
||||
//!< computation
|
||||
Ptr<Node> m_node; //!< node pointer corresponding to the this Vertex
|
||||
|
||||
/**
|
||||
* @brief Stream insertion operator.
|
||||
|
||||
Reference in New Issue
Block a user