LEFT | RIGHT |
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 *pLSA1 = new GlobalRoutingLSA; | 734 pLSA = new GlobalRoutingLSA; |
735 pLSA1->SetLSType (GlobalRoutingLSA::ASExternalLSAs); | 735 pLSA->SetLSType (GlobalRoutingLSA::ASExternalLSAs); |
736 pLSA1->SetLinkStateId ((*i)->GetDestNetwork ()); | 736 pLSA->SetLinkStateId ((*i)->GetDestNetwork ()); |
737 pLSA1->SetAdvertisingRouter (m_routerId); | 737 pLSA->SetAdvertisingRouter (m_routerId); |
738 pLSA1->SetNetworkLSANetworkMask ((*i)->GetDestNetworkMask ()); | 738 pLSA->SetNetworkLSANetworkMask ((*i)->GetDestNetworkMask ()); |
739 pLSA1->SetStatus (GlobalRoutingLSA::LSA_SPF_NOT_EXPLORED); | 739 pLSA->SetStatus (GlobalRoutingLSA::LSA_SPF_NOT_EXPLORED); |
740 m_LSAs.push_back (pLSA1);· | 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 NS_LOG_LOGIC ("Router-LSA Transit Network"); | 831 NS_LOG_LOGIC ("Router-LSA Transit Network"); |
832 plr->SetLinkType (GlobalRoutingLinkRecord::TransitNetwork); | 832 plr->SetLinkType (GlobalRoutingLinkRecord::TransitNetwork); |
833 | 833 |
834 //· | 834 //· |
835 // By definition, the router with the lowest IP address is the | 835 // By definition, the router with the lowest IP address is the |
836 // designated router for the network. OSPF says that the Link ID | 836 // designated router for the network. OSPF says that the Link ID |
837 // gets the IP interface address of the designated router in this· | 837 // gets the IP interface address of the designated router in this· |
838 // case. | 838 // case. |
839 // | 839 // |
840 ClearBridgesVisited (); | 840 ClearBridgesVisited (); |
841 Ipv4Address desigRtr = FindDesignatedRouterForLink (nd); | 841 Ipv4Address desigRtr; |
| 842 desigRtr = FindDesignatedRouterForLink (nd); |
842 | 843 |
843 // | 844 // |
844 // Let's double-check that any designated router we find out on our | 845 // Let's double-check that any designated router we find out on our |
845 // network is really on our network. | 846 // network is really on our network. |
846 // | 847 // |
847 if (desigRtr != "255.255.255.255") | 848 if (desigRtr != "255.255.255.255") |
848 { | 849 { |
849 Ipv4Address networkHere = addrLocal.CombineMask (maskLocal); | 850 Ipv4Address networkHere = addrLocal.CombineMask (maskLocal); |
850 Ipv4Address networkThere = desigRtr.CombineMask (maskLocal); | 851 Ipv4Address networkThere = desigRtr.CombineMask (maskLocal); |
851 NS_ABORT_MSG_UNLESS (networkHere == networkThere, | 852 NS_ABORT_MSG_UNLESS (networkHere == networkThere, |
(...skipping 565 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> nodeOther1 = ndOther->GetNode (); | 1428 nodeOther = ndOther->GetNode (); |
1428 NS_ASSERT (nodeOther1); | 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 = nodeOther1->GetObject<GlobalRouter> (); | 1435 Ptr<GlobalRouter> rtr = nodeOther->GetObject<GlobalRouter> (); |
1435 Ptr<Ipv4> ipv4 = nodeOther1->GetObject<Ipv4> (); | 1436 Ptr<Ipv4> ipv4 = nodeOther->GetObject<Ipv4> (); |
1436 if (rtr && ipv4) | 1437 if (rtr && ipv4) |
1437 { | 1438 { |
1438 // Initialize to value out of bounds to silence compiler | 1439 // Initialize to value out of bounds to silence compiler |
1439 uint32_t interfaceOther = ipv4->GetNInterfaces () + 1; | 1440 uint32_t interfaceOther = ipv4->GetNInterfaces () + 1; |
1440 if (FindInterfaceForDevice (nodeOther1, ndOther, interfaceOther)) | 1441 if (FindInterfaceForDevice (nodeOther, ndOther, interfaceOther)) |
1441 { | 1442 { |
1442 if (!ipv4->IsUp (interfaceOther)) | 1443 if (!ipv4->IsUp (interfaceOther)) |
1443 { | 1444 { |
1444 NS_LOG_LOGIC ("Remote side interface " << interfaceOther <
< " not up"); | 1445 NS_LOG_LOGIC ("Remote side interface " << interfaceOther <
< " not up"); |
1445 continue; | 1446 continue; |
1446 } | 1447 } |
1447 NS_LOG_LOGIC ("Found router on net device " << ndOther); | 1448 NS_LOG_LOGIC ("Found router on net device " << ndOther); |
1448 if (ipv4->GetNAddresses (interfaceOther) > 1) | 1449 if (ipv4->GetNAddresses (interfaceOther) > 1) |
1449 { | 1450 { |
1450 NS_LOG_WARN ("Warning, interface has multiple IP addresses
; using only the primary one"); | 1451 NS_LOG_WARN ("Warning, interface has multiple IP addresses
; using only the primary one"); |
(...skipping 113 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 |
LEFT | RIGHT |