akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Muktadir R Chowdhury | 800833b | 2016-07-29 13:43:59 -0500 | [diff] [blame] | 3 | * Copyright (c) 2014-2016, The University of Memphis, |
Vince Lehman | cae33b6 | 2015-06-05 09:21:30 -0500 | [diff] [blame] | 4 | * Regents of the University of California, |
| 5 | * Arizona Board of Regents. |
akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 6 | * |
| 7 | * This file is part of NLSR (Named-data Link State Routing). |
| 8 | * See AUTHORS.md for complete list of NLSR authors and contributors. |
| 9 | * |
| 10 | * NLSR is free software: you can redistribute it and/or modify it under the terms |
| 11 | * of the GNU General Public License as published by the Free Software Foundation, |
| 12 | * either version 3 of the License, or (at your option) any later version. |
| 13 | * |
| 14 | * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 15 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE. See the GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along with |
| 19 | * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 20 | **/ |
Vince Lehman | cae33b6 | 2015-06-05 09:21:30 -0500 | [diff] [blame] | 21 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 22 | #ifndef NLSR_NAME_PREFIX_TABLE_ENTRY_HPP |
| 23 | #define NLSR_NAME_PREFIX_TABLE_ENTRY_HPP |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 24 | |
Nick Gordon | b50e51b | 2016-07-22 16:05:57 -0500 | [diff] [blame^] | 25 | #include "routing-table-pool-entry.hpp" |
| 26 | |
| 27 | #include "test-access-control.hpp" |
Vince Lehman | cae33b6 | 2015-06-05 09:21:30 -0500 | [diff] [blame] | 28 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 29 | #include <list> |
| 30 | #include <utility> |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 31 | |
| 32 | namespace nlsr { |
| 33 | |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 34 | class NamePrefixTableEntry |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 35 | { |
| 36 | public: |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 37 | NamePrefixTableEntry() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 38 | { |
| 39 | } |
| 40 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 41 | NamePrefixTableEntry(const ndn::Name& namePrefix) |
| 42 | : m_namePrefix(namePrefix) |
| 43 | , m_nexthopList() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 44 | { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 45 | } |
| 46 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 47 | const ndn::Name& |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 48 | getNamePrefix() const |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 49 | { |
| 50 | return m_namePrefix; |
| 51 | } |
| 52 | |
Nick Gordon | b50e51b | 2016-07-22 16:05:57 -0500 | [diff] [blame^] | 53 | const std::list<std::shared_ptr<RoutingTablePoolEntry>>& |
Vince Lehman | cae33b6 | 2015-06-05 09:21:30 -0500 | [diff] [blame] | 54 | getRteList() const |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 55 | { |
| 56 | return m_rteList; |
| 57 | } |
| 58 | |
| 59 | void |
| 60 | resetRteListNextHop() |
| 61 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 62 | if (m_rteList.size() > 0) { |
Nick Gordon | b50e51b | 2016-07-22 16:05:57 -0500 | [diff] [blame^] | 63 | for (auto it = m_rteList.begin(); it != m_rteList.end(); ++it) { |
| 64 | (*it)->getNexthopList().reset(); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 65 | } |
| 66 | } |
| 67 | } |
| 68 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 69 | size_t |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 70 | getRteListSize() |
| 71 | { |
| 72 | return m_rteList.size(); |
| 73 | } |
| 74 | |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 75 | NexthopList& |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 76 | getNexthopList() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 77 | { |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 78 | return m_nexthopList; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 79 | } |
| 80 | |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 81 | /*! \brief Generates a next-hop list from routing table entries. */ |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 82 | void |
| 83 | generateNhlfromRteList(); |
| 84 | |
Nick Gordon | b50e51b | 2016-07-22 16:05:57 -0500 | [diff] [blame^] | 85 | /*! \brief Removes a routing entry from this NPT entry. |
| 86 | \param rtpePtr The routing entry |
| 87 | \return The remaining number of other NPTs using the removed routing entry. |
| 88 | */ |
| 89 | uint64_t |
| 90 | removeRoutingTableEntry(std::shared_ptr<RoutingTablePoolEntry> rtpePtr); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 91 | |
Nick Gordon | b50e51b | 2016-07-22 16:05:57 -0500 | [diff] [blame^] | 92 | /*! \brief Adds a routing entry to this NPT entry. |
| 93 | \param rtpePtr The routing entry. |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 94 | |
Nick Gordon | b50e51b | 2016-07-22 16:05:57 -0500 | [diff] [blame^] | 95 | Adds a routing table pool entry to this NPT entry's list |
| 96 | (reminder: each RTPE has a next-hop list). They are used to |
| 97 | calculate this entry's overall next-hop list. |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 98 | */ |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 99 | void |
Nick Gordon | b50e51b | 2016-07-22 16:05:57 -0500 | [diff] [blame^] | 100 | addRoutingTableEntry(std::shared_ptr<RoutingTablePoolEntry> rtpePtr); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 101 | |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 102 | void |
| 103 | writeLog(); |
| 104 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 105 | private: |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 106 | ndn::Name m_namePrefix; |
Nick Gordon | b50e51b | 2016-07-22 16:05:57 -0500 | [diff] [blame^] | 107 | |
| 108 | PUBLIC_WITH_TESTS_ELSE_PRIVATE: |
| 109 | std::list<std::shared_ptr<RoutingTablePoolEntry>> m_rteList; |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 110 | NexthopList m_nexthopList; |
Nick Gordon | b50e51b | 2016-07-22 16:05:57 -0500 | [diff] [blame^] | 111 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 112 | }; |
| 113 | |
Nick Gordon | b50e51b | 2016-07-22 16:05:57 -0500 | [diff] [blame^] | 114 | bool |
| 115 | operator==(const NamePrefixTableEntry& lhs, const NamePrefixTableEntry& rhs); |
| 116 | |
| 117 | bool |
| 118 | operator==(const NamePrefixTableEntry& lhs, const ndn::Name& rhs); |
| 119 | |
Vince Lehman | cae33b6 | 2015-06-05 09:21:30 -0500 | [diff] [blame] | 120 | std::ostream& |
| 121 | operator<<(std::ostream& os, const NamePrefixTableEntry& entry); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 122 | |
Vince Lehman | cae33b6 | 2015-06-05 09:21:30 -0500 | [diff] [blame] | 123 | } // namespace nlsr |
| 124 | |
| 125 | #endif // NLSR_NAME_PREFIX_TABLE_ENTRY_HPP |