OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright 2007 University of Washington | 3 * Copyright 2007 University of Washington |
4 *· | 4 *· |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 } | 241 } |
242 NS_LOG_LOGIC ("Clear list"); | 242 NS_LOG_LOGIC ("Clear list"); |
243 m_linkRecords.clear (); | 243 m_linkRecords.clear (); |
244 } | 244 } |
245 | 245 |
246 uint32_t | 246 uint32_t |
247 GlobalRoutingLSA::AddLinkRecord (GlobalRoutingLinkRecord* lr) | 247 GlobalRoutingLSA::AddLinkRecord (GlobalRoutingLinkRecord* lr) |
248 { | 248 { |
249 NS_LOG_FUNCTION (this << lr); | 249 NS_LOG_FUNCTION (this << lr); |
250 m_linkRecords.push_back (lr); | 250 m_linkRecords.push_back (lr); |
251 return m_linkRecords.size (); | 251 return static_cast<uint32_t> (m_linkRecords.size ()); |
252 } | 252 } |
253 | 253 |
254 uint32_t | 254 uint32_t |
255 GlobalRoutingLSA::GetNLinkRecords (void) const | 255 GlobalRoutingLSA::GetNLinkRecords (void) const |
256 { | 256 { |
257 NS_LOG_FUNCTION (this); | 257 NS_LOG_FUNCTION (this); |
258 return m_linkRecords.size (); | 258 return static_cast<uint32_t> (m_linkRecords.size ()); |
259 } | 259 } |
260 | 260 |
261 GlobalRoutingLinkRecord * | 261 GlobalRoutingLinkRecord * |
262 GlobalRoutingLSA::GetLinkRecord (uint32_t n) const | 262 GlobalRoutingLSA::GetLinkRecord (uint32_t n) const |
263 { | 263 { |
264 NS_LOG_FUNCTION (this << n); | 264 NS_LOG_FUNCTION (this << n); |
265 uint32_t j = 0; | 265 uint32_t j = 0; |
266 for ( ListOfLinkRecords_t::const_iterator i = m_linkRecords.begin (); | 266 for ( ListOfLinkRecords_t::const_iterator i = m_linkRecords.begin (); |
267 i != m_linkRecords.end ();· | 267 i != m_linkRecords.end ();· |
268 i++, j++) | 268 i++, j++) |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 { | 344 { |
345 NS_LOG_FUNCTION (this); | 345 NS_LOG_FUNCTION (this); |
346 return m_status; | 346 return m_status; |
347 } | 347 } |
348 | 348 |
349 uint32_t | 349 uint32_t |
350 GlobalRoutingLSA::AddAttachedRouter (Ipv4Address addr) | 350 GlobalRoutingLSA::AddAttachedRouter (Ipv4Address addr) |
351 { | 351 { |
352 NS_LOG_FUNCTION (this << addr); | 352 NS_LOG_FUNCTION (this << addr); |
353 m_attachedRouters.push_back (addr); | 353 m_attachedRouters.push_back (addr); |
354 return m_attachedRouters.size (); | 354 return static_cast<uint32_t> (m_attachedRouters.size ()); |
355 } | 355 } |
356 | 356 |
357 uint32_t | 357 uint32_t |
358 GlobalRoutingLSA::GetNAttachedRouters (void) const | 358 GlobalRoutingLSA::GetNAttachedRouters (void) const |
359 { | 359 { |
360 NS_LOG_FUNCTION (this); | 360 NS_LOG_FUNCTION (this); |
361 return m_attachedRouters.size ();· | 361 return static_cast<uint32_t> (m_attachedRouters.size ());· |
362 } | 362 } |
363 | 363 |
364 Ipv4Address | 364 Ipv4Address |
365 GlobalRoutingLSA::GetAttachedRouter (uint32_t n) const | 365 GlobalRoutingLSA::GetAttachedRouter (uint32_t n) const |
366 { | 366 { |
367 NS_LOG_FUNCTION (this << n); | 367 NS_LOG_FUNCTION (this << n); |
368 uint32_t j = 0; | 368 uint32_t j = 0; |
369 for ( ListOfAttachedRouters_t::const_iterator i = m_attachedRouters.begin (); | 369 for ( ListOfAttachedRouters_t::const_iterator i = m_attachedRouters.begin (); |
370 i != m_attachedRouters.end ();· | 370 i != m_attachedRouters.end ();· |
371 i++, j++) | 371 i++, j++) |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 } | 724 } |
725 | 725 |
726 // | 726 // |
727 // Build injected route LSAs as external routes | 727 // Build injected route LSAs as external routes |
728 // RFC 2328, section 12.4.4 | 728 // RFC 2328, section 12.4.4 |
729 // | 729 // |
730 for (InjectedRoutesCI i = m_injectedRoutes.begin (); | 730 for (InjectedRoutesCI i = m_injectedRoutes.begin (); |
731 i != m_injectedRoutes.end (); | 731 i != m_injectedRoutes.end (); |
732 i++) | 732 i++) |
733 { | 733 { |
734 GlobalRoutingLSA *pLSA = new GlobalRoutingLSA; | 734 pLSA = new GlobalRoutingLSA; |
735 pLSA->SetLSType (GlobalRoutingLSA::ASExternalLSAs); | 735 pLSA->SetLSType (GlobalRoutingLSA::ASExternalLSAs); |
736 pLSA->SetLinkStateId ((*i)->GetDestNetwork ()); | 736 pLSA->SetLinkStateId ((*i)->GetDestNetwork ()); |
737 pLSA->SetAdvertisingRouter (m_routerId); | 737 pLSA->SetAdvertisingRouter (m_routerId); |
738 pLSA->SetNetworkLSANetworkMask ((*i)->GetDestNetworkMask ()); | 738 pLSA->SetNetworkLSANetworkMask ((*i)->GetDestNetworkMask ()); |
739 pLSA->SetStatus (GlobalRoutingLSA::LSA_SPF_NOT_EXPLORED); | 739 pLSA->SetStatus (GlobalRoutingLSA::LSA_SPF_NOT_EXPLORED); |
740 m_LSAs.push_back (pLSA);· | 740 m_LSAs.push_back (pLSA);· |
741 } | 741 } |
742 return m_LSAs.size (); | 742 return static_cast<uint32_t> (m_LSAs.size ()); |
743 } | 743 } |
744 | 744 |
745 void | 745 void |
746 GlobalRouter::ProcessBroadcastLink (Ptr<NetDevice> nd, GlobalRoutingLSA *pLSA, N
etDeviceContainer &c) | 746 GlobalRouter::ProcessBroadcastLink (Ptr<NetDevice> nd, GlobalRoutingLSA *pLSA, N
etDeviceContainer &c) |
747 { | 747 { |
748 NS_LOG_FUNCTION (this << nd << pLSA << &c); | 748 NS_LOG_FUNCTION (this << nd << pLSA << &c); |
749 | 749 |
750 if (nd->IsBridge ()) | 750 if (nd->IsBridge ()) |
751 { | 751 { |
752 ProcessBridgedBroadcastLink (nd, pLSA, c); | 752 ProcessBridgedBroadcastLink (nd, pLSA, c); |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 | 1196 |
1197 // | 1197 // |
1198 // Build a list of AttachedRouters by walking the devices in the channel | 1198 // Build a list of AttachedRouters by walking the devices in the channel |
1199 // and, if we find a node with a GlobalRouter interface and an IPv4· | 1199 // and, if we find a node with a GlobalRouter interface and an IPv4· |
1200 // interface associated with that device, we call it an attached router. | 1200 // interface associated with that device, we call it an attached router. |
1201 // | 1201 // |
1202 ClearBridgesVisited (); | 1202 ClearBridgesVisited (); |
1203 Ptr<Channel> ch = ndLocal->GetChannel (); | 1203 Ptr<Channel> ch = ndLocal->GetChannel (); |
1204 uint32_t nDevices = ch->GetNDevices (); | 1204 uint32_t nDevices = ch->GetNDevices (); |
1205 NS_ASSERT (nDevices); | 1205 NS_ASSERT (nDevices); |
| 1206 (void)nDevices; // make compiler happy |
1206 NetDeviceContainer deviceList = FindAllNonBridgedDevicesOnLink (ch); | 1207 NetDeviceContainer deviceList = FindAllNonBridgedDevicesOnLink (ch); |
1207 NS_LOG_LOGIC ("Found " << deviceList.GetN () << " non-bridged devices on c
hannel"); | 1208 NS_LOG_LOGIC ("Found " << deviceList.GetN () << " non-bridged devices on c
hannel"); |
1208 | 1209 |
1209 for (uint32_t i = 0; i < deviceList.GetN (); i++) | 1210 for (uint32_t j = 0; j < deviceList.GetN (); j++) |
1210 { | 1211 { |
1211 Ptr<NetDevice> tempNd = deviceList.Get (i); | 1212 Ptr<NetDevice> tempNd = deviceList.Get (j); |
1212 NS_ASSERT (tempNd); | 1213 NS_ASSERT (tempNd); |
1213 if (tempNd == ndLocal) | 1214 if (tempNd == ndLocal) |
1214 { | 1215 { |
1215 NS_LOG_LOGIC ("Adding " << addrLocal << " to Network LSA"); | 1216 NS_LOG_LOGIC ("Adding " << addrLocal << " to Network LSA"); |
1216 pLSA->AddAttachedRouter (addrLocal); | 1217 pLSA->AddAttachedRouter (addrLocal); |
1217 continue; | 1218 continue; |
1218 } | 1219 } |
1219 Ptr<Node> tempNode = tempNd->GetNode (); | 1220 Ptr<Node> tempNode = tempNd->GetNode (); |
1220 | 1221 |
1221 // Does the node in question have a GlobalRouter interface? If not it
can | 1222 // Does the node in question have a GlobalRouter interface? If not it
can |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1417 | 1418 |
1418 NS_LOG_LOGIC ("Recursively looking for routers down bridge port "
<< ndBridged); | 1419 NS_LOG_LOGIC ("Recursively looking for routers down bridge port "
<< ndBridged); |
1419 Ipv4Address addrOther = FindDesignatedRouterForLink (ndBridged); | 1420 Ipv4Address addrOther = FindDesignatedRouterForLink (ndBridged); |
1420 desigRtr = addrOther < desigRtr ? addrOther : desigRtr; | 1421 desigRtr = addrOther < desigRtr ? addrOther : desigRtr; |
1421 NS_LOG_LOGIC ("designated router now " << desigRtr); | 1422 NS_LOG_LOGIC ("designated router now " << desigRtr); |
1422 } | 1423 } |
1423 } | 1424 } |
1424 else | 1425 else |
1425 { | 1426 { |
1426 NS_LOG_LOGIC ("This device is not bridged"); | 1427 NS_LOG_LOGIC ("This device is not bridged"); |
1427 Ptr<Node> nodeOther = ndOther->GetNode (); | 1428 nodeOther = ndOther->GetNode (); |
1428 NS_ASSERT (nodeOther); | 1429 NS_ASSERT (nodeOther); |
1429 | 1430 |
1430 // | 1431 // |
1431 // We require a designated router to have a GlobalRouter interface and | 1432 // We require a designated router to have a GlobalRouter interface and |
1432 // an internet stack that includes the Ipv4 interface. If it doesn't | 1433 // an internet stack that includes the Ipv4 interface. If it doesn't |
1433 // | 1434 // |
1434 Ptr<GlobalRouter> rtr = nodeOther->GetObject<GlobalRouter> (); | 1435 Ptr<GlobalRouter> rtr = nodeOther->GetObject<GlobalRouter> (); |
1435 Ptr<Ipv4> ipv4 = nodeOther->GetObject<Ipv4> (); | 1436 Ptr<Ipv4> ipv4 = nodeOther->GetObject<Ipv4> (); |
1436 if (rtr && ipv4) | 1437 if (rtr && ipv4) |
1437 { | 1438 { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 } | 1565 } |
1565 } | 1566 } |
1566 NS_LOG_LOGIC ("No routers found, return false"); | 1567 NS_LOG_LOGIC ("No routers found, return false"); |
1567 return false; | 1568 return false; |
1568 } | 1569 } |
1569 | 1570 |
1570 uint32_t | 1571 uint32_t |
1571 GlobalRouter::GetNumLSAs (void) const | 1572 GlobalRouter::GetNumLSAs (void) const |
1572 { | 1573 { |
1573 NS_LOG_FUNCTION (this); | 1574 NS_LOG_FUNCTION (this); |
1574 return m_LSAs.size (); | 1575 return static_cast<uint32_t> (m_LSAs.size ()); |
1575 } | 1576 } |
1576 | 1577 |
1577 // | 1578 // |
1578 // Get the nth link state advertisement from this router. | 1579 // Get the nth link state advertisement from this router. |
1579 // | 1580 // |
1580 bool | 1581 bool |
1581 GlobalRouter::GetLSA (uint32_t n, GlobalRoutingLSA &lsa) const | 1582 GlobalRouter::GetLSA (uint32_t n, GlobalRoutingLSA &lsa) const |
1582 { | 1583 { |
1583 NS_LOG_FUNCTION (this << n << &lsa); | 1584 NS_LOG_FUNCTION (this << n << &lsa); |
1584 NS_ASSERT_MSG (lsa.IsEmpty (), "GlobalRouter::GetLSA (): Must pass empty LSA")
; | 1585 NS_ASSERT_MSG (lsa.IsEmpty (), "GlobalRouter::GetLSA (): Must pass empty LSA")
; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1637 } | 1638 } |
1638 NS_ASSERT (false); | 1639 NS_ASSERT (false); |
1639 // quiet compiler. | 1640 // quiet compiler. |
1640 return 0; | 1641 return 0; |
1641 } | 1642 } |
1642 | 1643 |
1643 uint32_t | 1644 uint32_t |
1644 GlobalRouter::GetNInjectedRoutes () | 1645 GlobalRouter::GetNInjectedRoutes () |
1645 { | 1646 { |
1646 NS_LOG_FUNCTION (this); | 1647 NS_LOG_FUNCTION (this); |
1647 return m_injectedRoutes.size (); | 1648 return static_cast<uint32_t> (m_injectedRoutes.size ()); |
1648 } | 1649 } |
1649 | 1650 |
1650 void | 1651 void |
1651 GlobalRouter::RemoveInjectedRoute (uint32_t index) | 1652 GlobalRouter::RemoveInjectedRoute (uint32_t index) |
1652 { | 1653 { |
1653 NS_LOG_FUNCTION (this << index); | 1654 NS_LOG_FUNCTION (this << index); |
1654 NS_ASSERT (index < m_injectedRoutes.size ()); | 1655 NS_ASSERT (index < m_injectedRoutes.size ()); |
1655 uint32_t tmp = 0; | 1656 uint32_t tmp = 0; |
1656 for (InjectedRoutesI i = m_injectedRoutes.begin (); i != m_injectedRoutes.end
(); i++) | 1657 for (InjectedRoutesI i = m_injectedRoutes.begin (); i != m_injectedRoutes.end
(); i++) |
1657 { | 1658 { |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1828 // | 1829 // |
1829 void· | 1830 void· |
1830 GlobalRouter::MarkBridgeAsVisited (Ptr<BridgeNetDevice> bridgeNetDevice) const | 1831 GlobalRouter::MarkBridgeAsVisited (Ptr<BridgeNetDevice> bridgeNetDevice) const |
1831 { | 1832 { |
1832 NS_LOG_FUNCTION (this << bridgeNetDevice); | 1833 NS_LOG_FUNCTION (this << bridgeNetDevice); |
1833 m_bridgesVisited.push_back (bridgeNetDevice); | 1834 m_bridgesVisited.push_back (bridgeNetDevice); |
1834 } | 1835 } |
1835 | 1836 |
1836 | 1837 |
1837 } // namespace ns3 | 1838 } // namespace ns3 |
OLD | NEW |