blob: f43ddb1e8bf995c0a052aa5df13bc6e0569ddf51 [file] [log] [blame]
akmhoque3d06e792014-05-27 16:23:20 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Nick Gordonc6a85222017-01-03 16:54:34 -06003 * Copyright (c) 2014-2017, 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 <ndn-cxx/util/scheduler.hpp>
akmhoque53353462014-04-22 08:43:45 -050025
akmhoquec8a10f72014-04-25 18:42:55 -050026#include "nexthop-list.hpp"
akmhoque53353462014-04-22 08:43:45 -050027
28namespace nlsr {
29
akmhoque53353462014-04-22 08:43:45 -050030class FibEntry
31{
32public:
33 FibEntry()
34 : m_name()
Muktadir Chowdhury3be64662015-05-01 14:50:53 -050035 , m_seqNo(1)
akmhoquefdbddb12014-05-02 18:35:19 -050036 , m_nexthopList()
akmhoque53353462014-04-22 08:43:45 -050037 {
38 }
39
akmhoque31d1d4b2014-05-05 22:08:14 -050040 FibEntry(const ndn::Name& name)
Muktadir Chowdhury3be64662015-05-01 14:50:53 -050041 : m_seqNo(1)
akmhoquefdbddb12014-05-02 18:35:19 -050042 , m_nexthopList()
akmhoque53353462014-04-22 08:43:45 -050043 {
akmhoquefdbddb12014-05-02 18:35:19 -050044 m_name = name;
akmhoque53353462014-04-22 08:43:45 -050045 }
46
akmhoque31d1d4b2014-05-05 22:08:14 -050047 const ndn::Name&
akmhoque53353462014-04-22 08:43:45 -050048 getName() const
49 {
50 return m_name;
51 }
52
akmhoquec8a10f72014-04-25 18:42:55 -050053 NexthopList&
akmhoquefdbddb12014-05-02 18:35:19 -050054 getNexthopList()
akmhoque53353462014-04-22 08:43:45 -050055 {
akmhoquefdbddb12014-05-02 18:35:19 -050056 return m_nexthopList;
akmhoque53353462014-04-22 08:43:45 -050057 }
58
akmhoque53353462014-04-22 08:43:45 -050059 void
Muktadir Chowdhury3be64662015-05-01 14:50:53 -050060 setRefreshEventId(ndn::EventId id)
akmhoque53353462014-04-22 08:43:45 -050061 {
Muktadir Chowdhury3be64662015-05-01 14:50:53 -050062 m_refreshEventId = id;
akmhoque53353462014-04-22 08:43:45 -050063 }
64
65 ndn::EventId
Muktadir Chowdhury3be64662015-05-01 14:50:53 -050066 getRefreshEventId() const
akmhoque53353462014-04-22 08:43:45 -050067 {
Muktadir Chowdhury3be64662015-05-01 14:50:53 -050068 return m_refreshEventId;
akmhoque53353462014-04-22 08:43:45 -050069 }
70
71 void
akmhoquefdbddb12014-05-02 18:35:19 -050072 setSeqNo(int32_t fsn)
akmhoque53353462014-04-22 08:43:45 -050073 {
74 m_seqNo = fsn;
75 }
76
akmhoquefdbddb12014-05-02 18:35:19 -050077 int32_t
Muktadir Chowdhury3be64662015-05-01 14:50:53 -050078 getSeqNo() const
akmhoque53353462014-04-22 08:43:45 -050079 {
80 return m_seqNo;
81 }
82
akmhoque674b0b12014-05-20 14:33:28 -050083 void
84 writeLog();
85
Muktadir Chowdhury3be64662015-05-01 14:50:53 -050086 typedef NexthopList::const_iterator const_iterator;
87
88 const_iterator
89 begin() const;
90
91 const_iterator
92 end() const;
93
akmhoque53353462014-04-22 08:43:45 -050094private:
akmhoque31d1d4b2014-05-05 22:08:14 -050095 ndn::Name m_name;
Muktadir Chowdhury3be64662015-05-01 14:50:53 -050096 ndn::EventId m_refreshEventId;
akmhoquefdbddb12014-05-02 18:35:19 -050097 int32_t m_seqNo;
98 NexthopList m_nexthopList;
akmhoque53353462014-04-22 08:43:45 -050099};
100
Muktadir Chowdhury3be64662015-05-01 14:50:53 -0500101inline FibEntry::const_iterator
102FibEntry::begin() const
103{
104 return m_nexthopList.cbegin();
105}
106
107inline FibEntry::const_iterator
108FibEntry::end() const
109{
110 return m_nexthopList.cend();
111}
112
Nick Gordonfad8e252016-08-11 14:21:38 -0500113} // namespace nlsr
akmhoque53353462014-04-22 08:43:45 -0500114
Muktadir Chowdhury3be64662015-05-01 14:50:53 -0500115#endif // NLSR_FIB_ENTRY_HPP