From 692ca42c696e7d3ad2fe2c41dc4ee0d122fc001f Mon Sep 17 00:00:00 2001 From: "frederic." Date: Thu, 15 Mar 2012 09:59:11 +0100 Subject: [PATCH] Add metric in Ipv4StaticRouting::PrintRoutingTable --- src/internet/model/ipv4-static-routing.cc | 15 ++++++--------- src/internet/model/ipv4-static-routing.h | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/internet/model/ipv4-static-routing.cc b/src/internet/model/ipv4-static-routing.cc index 278440352..305a55f87 100644 --- a/src/internet/model/ipv4-static-routing.cc +++ b/src/internet/model/ipv4-static-routing.cc @@ -413,11 +413,11 @@ Ipv4StaticRouting::GetRoute (uint32_t index) const } uint32_t -Ipv4StaticRouting::GetMetric (uint32_t index) +Ipv4StaticRouting::GetMetric (uint32_t index) const { NS_LOG_FUNCTION (this << index); uint32_t tmp = 0; - for (NetworkRoutesI j = m_networkRoutes.begin (); + for (NetworkRoutesCI j = m_networkRoutes.begin (); j != m_networkRoutes.end (); j++) { @@ -700,7 +700,6 @@ Ipv4StaticRouting::SetIpv4 (Ptr ipv4) } } } - // Formatted like output of "route -n" command void Ipv4StaticRouting::PrintRoutingTable (Ptr stream) const @@ -713,11 +712,11 @@ Ipv4StaticRouting::PrintRoutingTable (Ptr stream) const { std::ostringstream dest, gw, mask, flags; Ipv4RoutingTableEntry route = GetRoute (j); - dest << route.GetDest (); + dest << route.GetDest (); *os << std::setiosflags (std::ios::left) << std::setw (16) << dest.str (); - gw << route.GetGateway (); + gw << route.GetGateway (); *os << std::setiosflags (std::ios::left) << std::setw (16) << gw.str (); - mask << route.GetDestNetworkMask (); + mask << route.GetDestNetworkMask (); *os << std::setiosflags (std::ios::left) << std::setw (16) << mask.str (); flags << "U"; if (route.IsHost ()) @@ -729,8 +728,7 @@ Ipv4StaticRouting::PrintRoutingTable (Ptr stream) const flags << "GS"; } *os << std::setiosflags (std::ios::left) << std::setw (6) << flags.str (); - // Metric not implemented - *os << "-" << " "; + *os << std::setiosflags (std::ios::left) << std::setw (7) << GetMetric (j); // Ref ct not implemented *os << "-" << " "; // Use not implemented @@ -747,7 +745,6 @@ Ipv4StaticRouting::PrintRoutingTable (Ptr stream) const } } } - Ipv4Address Ipv4StaticRouting::SourceAddressSelection (uint32_t interfaceIdx, Ipv4Address dest) { diff --git a/src/internet/model/ipv4-static-routing.h b/src/internet/model/ipv4-static-routing.h index 8ae679790..879ad7bf2 100644 --- a/src/internet/model/ipv4-static-routing.h +++ b/src/internet/model/ipv4-static-routing.h @@ -213,7 +213,7 @@ public: * \return If route is set, the metric is returned. If not, an infinity metric (0xffffffff) is returned * */ - uint32_t GetMetric (uint32_t index); + uint32_t GetMetric (uint32_t index) const; /** * \brief Remove a route from the static unicast routing table.