blob: ddae8ce304a03c0f4cdbf452252969ea4e05c9d6 [file] [log] [blame]
akmhoque3d06e792014-05-27 16:23:20 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Muktadir R Chowdhury800833b2016-07-29 13:43:59 -05003 * Copyright (c) 2014-2016, The University of Memphis,
Vince Lehmancae33b62015-06-05 09:21:30 -05004 * Regents of the University of California,
5 * Arizona Board of Regents.
akmhoque3d06e792014-05-27 16:23:20 -05006 *
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/>.
akmhoque3d06e792014-05-27 16:23:20 -050020 **/
Vince Lehmancae33b62015-06-05 09:21:30 -050021
akmhoquefdbddb12014-05-02 18:35:19 -050022#ifndef NLSR_NAME_PREFIX_TABLE_ENTRY_HPP
23#define NLSR_NAME_PREFIX_TABLE_ENTRY_HPP
akmhoque53353462014-04-22 08:43:45 -050024
Vince Lehmancae33b62015-06-05 09:21:30 -050025#include "routing-table-entry.hpp"
26
akmhoque53353462014-04-22 08:43:45 -050027#include <list>
28#include <utility>
akmhoque53353462014-04-22 08:43:45 -050029
30namespace nlsr {
31
akmhoquec8a10f72014-04-25 18:42:55 -050032class NamePrefixTableEntry
akmhoque53353462014-04-22 08:43:45 -050033{
34public:
akmhoquec8a10f72014-04-25 18:42:55 -050035 NamePrefixTableEntry()
akmhoque53353462014-04-22 08:43:45 -050036 {
37 }
38
akmhoque31d1d4b2014-05-05 22:08:14 -050039 NamePrefixTableEntry(const ndn::Name& namePrefix)
40 : m_namePrefix(namePrefix)
41 , m_nexthopList()
akmhoque53353462014-04-22 08:43:45 -050042 {
akmhoque53353462014-04-22 08:43:45 -050043 }
44
akmhoque31d1d4b2014-05-05 22:08:14 -050045 const ndn::Name&
akmhoquefdbddb12014-05-02 18:35:19 -050046 getNamePrefix() const
akmhoque53353462014-04-22 08:43:45 -050047 {
48 return m_namePrefix;
49 }
50
Vince Lehmancae33b62015-06-05 09:21:30 -050051 const std::list<RoutingTableEntry>&
52 getRteList() const
akmhoque53353462014-04-22 08:43:45 -050053 {
54 return m_rteList;
55 }
56
57 void
58 resetRteListNextHop()
59 {
akmhoque157b0a42014-05-13 00:26:37 -050060 if (m_rteList.size() > 0) {
akmhoque53353462014-04-22 08:43:45 -050061 for (std::list<RoutingTableEntry>::iterator it = m_rteList.begin();
akmhoque157b0a42014-05-13 00:26:37 -050062 it != m_rteList.end(); ++it) {
akmhoquefdbddb12014-05-02 18:35:19 -050063 (*it).getNexthopList().reset();
akmhoque53353462014-04-22 08:43:45 -050064 }
65 }
66 }
67
akmhoquefdbddb12014-05-02 18:35:19 -050068 size_t
akmhoque53353462014-04-22 08:43:45 -050069 getRteListSize()
70 {
71 return m_rteList.size();
72 }
73
akmhoquec8a10f72014-04-25 18:42:55 -050074 NexthopList&
akmhoquefdbddb12014-05-02 18:35:19 -050075 getNexthopList()
akmhoque53353462014-04-22 08:43:45 -050076 {
akmhoquefdbddb12014-05-02 18:35:19 -050077 return m_nexthopList;
akmhoque53353462014-04-22 08:43:45 -050078 }
79
Nick G97e34942016-07-11 14:46:27 -050080 /*! \brief Generates a next-hop list from routing table entries. */
akmhoque53353462014-04-22 08:43:45 -050081 void
82 generateNhlfromRteList();
83
84 void
85 removeRoutingTableEntry(RoutingTableEntry& rte);
86
Nick G97e34942016-07-11 14:46:27 -050087 /*! \brief Adds a routing table entry to this object's list.
88 \param rte The routing table entry.
89
90 Adds a routing table entry to this NPT entry's list. (reminder:
91 each RTE has a next-hop list) They are used to calculate this
92 entry's next-hop list.
93 */
akmhoque53353462014-04-22 08:43:45 -050094 void
95 addRoutingTableEntry(RoutingTableEntry& rte);
96
akmhoque674b0b12014-05-20 14:33:28 -050097 void
98 writeLog();
99
akmhoque53353462014-04-22 08:43:45 -0500100private:
akmhoque31d1d4b2014-05-05 22:08:14 -0500101 ndn::Name m_namePrefix;
akmhoque53353462014-04-22 08:43:45 -0500102 std::list<RoutingTableEntry> m_rteList;
akmhoquefdbddb12014-05-02 18:35:19 -0500103 NexthopList m_nexthopList;
akmhoque53353462014-04-22 08:43:45 -0500104};
105
Vince Lehmancae33b62015-06-05 09:21:30 -0500106std::ostream&
107operator<<(std::ostream& os, const NamePrefixTableEntry& entry);
akmhoque53353462014-04-22 08:43:45 -0500108
Vince Lehmancae33b62015-06-05 09:21:30 -0500109} // namespace nlsr
110
111#endif // NLSR_NAME_PREFIX_TABLE_ENTRY_HPP