blob: ee8df2bb540e6ae55da6dad2ae4b2c829042a43e [file] [log] [blame]
akmhoque3d06e792014-05-27 16:23:20 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014 University of Memphis,
4 * Regents of the University of California
5 *
6 * This file is part of NLSR (Named-data Link State Routing).
7 * See AUTHORS.md for complete list of NLSR authors and contributors.
8 *
9 * NLSR is free software: you can redistribute it and/or modify it under the terms
10 * of the GNU General Public License as published by the Free Software Foundation,
11 * either version 3 of the License, or (at your option) any later version.
12 *
13 * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
14 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
21 *
22 **/
akmhoquefdbddb12014-05-02 18:35:19 -050023#ifndef NLSR_NAME_PREFIX_TABLE_ENTRY_HPP
24#define NLSR_NAME_PREFIX_TABLE_ENTRY_HPP
akmhoque53353462014-04-22 08:43:45 -050025
26#include <list>
27#include <utility>
akmhoquefdbddb12014-05-02 18:35:19 -050028#include <boost/cstdint.hpp>
29
akmhoque53353462014-04-22 08:43:45 -050030#include "routing-table-entry.hpp"
31
32namespace nlsr {
33
akmhoquec8a10f72014-04-25 18:42:55 -050034class NamePrefixTableEntry
akmhoque53353462014-04-22 08:43:45 -050035{
36public:
akmhoquec8a10f72014-04-25 18:42:55 -050037 NamePrefixTableEntry()
akmhoque53353462014-04-22 08:43:45 -050038 {
39 }
40
akmhoque31d1d4b2014-05-05 22:08:14 -050041 NamePrefixTableEntry(const ndn::Name& namePrefix)
42 : m_namePrefix(namePrefix)
43 , m_nexthopList()
akmhoque53353462014-04-22 08:43:45 -050044 {
akmhoque53353462014-04-22 08:43:45 -050045 }
46
akmhoque31d1d4b2014-05-05 22:08:14 -050047 const ndn::Name&
akmhoquefdbddb12014-05-02 18:35:19 -050048 getNamePrefix() const
akmhoque53353462014-04-22 08:43:45 -050049 {
50 return m_namePrefix;
51 }
52
53 std::list<RoutingTableEntry>&
54 getRteList()
55 {
56 return m_rteList;
57 }
58
59 void
60 resetRteListNextHop()
61 {
akmhoque157b0a42014-05-13 00:26:37 -050062 if (m_rteList.size() > 0) {
akmhoque53353462014-04-22 08:43:45 -050063 for (std::list<RoutingTableEntry>::iterator it = m_rteList.begin();
akmhoque157b0a42014-05-13 00:26:37 -050064 it != m_rteList.end(); ++it) {
akmhoquefdbddb12014-05-02 18:35:19 -050065 (*it).getNexthopList().reset();
akmhoque53353462014-04-22 08:43:45 -050066 }
67 }
68 }
69
akmhoquefdbddb12014-05-02 18:35:19 -050070 size_t
akmhoque53353462014-04-22 08:43:45 -050071 getRteListSize()
72 {
73 return m_rteList.size();
74 }
75
akmhoquec8a10f72014-04-25 18:42:55 -050076 NexthopList&
akmhoquefdbddb12014-05-02 18:35:19 -050077 getNexthopList()
akmhoque53353462014-04-22 08:43:45 -050078 {
akmhoquefdbddb12014-05-02 18:35:19 -050079 return m_nexthopList;
akmhoque53353462014-04-22 08:43:45 -050080 }
81
82 void
83 generateNhlfromRteList();
84
85 void
86 removeRoutingTableEntry(RoutingTableEntry& rte);
87
88 void
89 addRoutingTableEntry(RoutingTableEntry& rte);
90
akmhoque674b0b12014-05-20 14:33:28 -050091 void
92 writeLog();
93
akmhoque53353462014-04-22 08:43:45 -050094private:
akmhoque31d1d4b2014-05-05 22:08:14 -050095 ndn::Name m_namePrefix;
akmhoque53353462014-04-22 08:43:45 -050096 std::list<RoutingTableEntry> m_rteList;
akmhoquefdbddb12014-05-02 18:35:19 -050097 NexthopList m_nexthopList;
akmhoque53353462014-04-22 08:43:45 -050098};
99
100std::ostream&
akmhoquec8a10f72014-04-25 18:42:55 -0500101operator<<(std::ostream& os, NamePrefixTableEntry& npte);
akmhoque53353462014-04-22 08:43:45 -0500102
103}//namespace nlsr
104
akmhoquefdbddb12014-05-02 18:35:19 -0500105#endif //NLSR_NAME_PREFIX_TABLE_ENTRY_HPP