blob: 248c0fd1e6f41359e84b6cef15c5c394bdb945c9 [file] [log] [blame]
akmhoque3d06e792014-05-27 16:23:20 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesaventoaf7a2112019-03-19 14:55:20 -04002/*
3 * Copyright (c) 2014-2019, The University of Memphis,
Nick Gordonf8b5bcd2016-08-11 15:06:50 -05004 * Regents of the University of California
akmhoque3d06e792014-05-27 16:23:20 -05005 *
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/>.
akmhoque3d06e792014-05-27 16:23:20 -050019 **/
Muktadir Chowdhury3be64662015-05-01 14:50:53 -050020
akmhoquefdbddb12014-05-02 18:35:19 -050021#ifndef NLSR_FIB_ENTRY_HPP
22#define NLSR_FIB_ENTRY_HPP
akmhoque53353462014-04-22 08:43:45 -050023
akmhoquec8a10f72014-04-25 18:42:55 -050024#include "nexthop-list.hpp"
akmhoque53353462014-04-22 08:43:45 -050025
Ashlesh Gawandee5002b32018-12-20 21:07:31 -060026#include <ndn-cxx/util/scheduler.hpp>
27
akmhoque53353462014-04-22 08:43:45 -050028namespace nlsr {
29
akmhoque53353462014-04-22 08:43:45 -050030class FibEntry
31{
32public:
Davide Pesaventoaf7a2112019-03-19 14:55:20 -040033 FibEntry() = default;
akmhoque53353462014-04-22 08:43:45 -050034
akmhoque31d1d4b2014-05-05 22:08:14 -050035 FibEntry(const ndn::Name& name)
Davide Pesaventoaf7a2112019-03-19 14:55:20 -040036 : m_name(name)
akmhoque53353462014-04-22 08:43:45 -050037 {
akmhoque53353462014-04-22 08:43:45 -050038 }
39
akmhoque31d1d4b2014-05-05 22:08:14 -050040 const ndn::Name&
akmhoque53353462014-04-22 08:43:45 -050041 getName() const
42 {
43 return m_name;
44 }
45
akmhoquec8a10f72014-04-25 18:42:55 -050046 NexthopList&
akmhoquefdbddb12014-05-02 18:35:19 -050047 getNexthopList()
akmhoque53353462014-04-22 08:43:45 -050048 {
akmhoquefdbddb12014-05-02 18:35:19 -050049 return m_nexthopList;
akmhoque53353462014-04-22 08:43:45 -050050 }
51
akmhoque53353462014-04-22 08:43:45 -050052 void
Davide Pesaventoaf7a2112019-03-19 14:55:20 -040053 setRefreshEventId(ndn::scheduler::EventId id)
akmhoque53353462014-04-22 08:43:45 -050054 {
Davide Pesaventoaf7a2112019-03-19 14:55:20 -040055 m_refreshEventId = std::move(id);
akmhoque53353462014-04-22 08:43:45 -050056 }
57
Davide Pesaventoaf7a2112019-03-19 14:55:20 -040058 ndn::scheduler::EventId
Muktadir Chowdhury3be64662015-05-01 14:50:53 -050059 getRefreshEventId() const
akmhoque53353462014-04-22 08:43:45 -050060 {
Muktadir Chowdhury3be64662015-05-01 14:50:53 -050061 return m_refreshEventId;
akmhoque53353462014-04-22 08:43:45 -050062 }
63
64 void
akmhoquefdbddb12014-05-02 18:35:19 -050065 setSeqNo(int32_t fsn)
akmhoque53353462014-04-22 08:43:45 -050066 {
67 m_seqNo = fsn;
68 }
69
akmhoquefdbddb12014-05-02 18:35:19 -050070 int32_t
Muktadir Chowdhury3be64662015-05-01 14:50:53 -050071 getSeqNo() const
akmhoque53353462014-04-22 08:43:45 -050072 {
73 return m_seqNo;
74 }
75
akmhoque674b0b12014-05-20 14:33:28 -050076 void
Ashlesh Gawandee5002b32018-12-20 21:07:31 -060077 writeLog() const;
akmhoque674b0b12014-05-20 14:33:28 -050078
Muktadir Chowdhury3be64662015-05-01 14:50:53 -050079 typedef NexthopList::const_iterator const_iterator;
80
81 const_iterator
82 begin() const;
83
84 const_iterator
85 end() const;
86
akmhoque53353462014-04-22 08:43:45 -050087private:
akmhoque31d1d4b2014-05-05 22:08:14 -050088 ndn::Name m_name;
Davide Pesaventoaf7a2112019-03-19 14:55:20 -040089 ndn::scheduler::EventId m_refreshEventId;
90 int32_t m_seqNo = 1;
akmhoquefdbddb12014-05-02 18:35:19 -050091 NexthopList m_nexthopList;
akmhoque53353462014-04-22 08:43:45 -050092};
93
Muktadir Chowdhury3be64662015-05-01 14:50:53 -050094inline FibEntry::const_iterator
95FibEntry::begin() const
96{
97 return m_nexthopList.cbegin();
98}
99
100inline FibEntry::const_iterator
101FibEntry::end() const
102{
103 return m_nexthopList.cend();
104}
105
Nick Gordonfad8e252016-08-11 14:21:38 -0500106} // namespace nlsr
akmhoque53353462014-04-22 08:43:45 -0500107
Muktadir Chowdhury3be64662015-05-01 14:50:53 -0500108#endif // NLSR_FIB_ENTRY_HPP