blob: 0f5835175f0a949bd1662dc554353ea8852e0c09 [file] [log] [blame]
akmhoque53353462014-04-22 08:43:45 -05001#ifndef NLSR_FIB_HPP
2#define NLSR_FIB_HPP
3
4#include <list>
akmhoquefdbddb12014-05-02 18:35:19 -05005#include <boost/cstdint.hpp>
6
7#include <ndn-cxx/management/nfd-controller.hpp>
8
akmhoque53353462014-04-22 08:43:45 -05009#include "fib-entry.hpp"
10
11namespace nlsr {
12
13class Nlsr;
14
akmhoque53353462014-04-22 08:43:45 -050015
16class Fib
17{
18public:
akmhoque31d1d4b2014-05-05 22:08:14 -050019 Fib(Nlsr& nlsr, ndn::Face& face)
20 : m_nlsr(nlsr)
21 , m_table()
akmhoque53353462014-04-22 08:43:45 -050022 , m_refreshTime(0)
akmhoquefdbddb12014-05-02 18:35:19 -050023 , m_controller(face)
24 {
25 }
26 ~Fib()
akmhoque53353462014-04-22 08:43:45 -050027 {
28 }
29
30 void
akmhoque31d1d4b2014-05-05 22:08:14 -050031 remove(const ndn::Name& name);
akmhoque53353462014-04-22 08:43:45 -050032
33 void
akmhoque31d1d4b2014-05-05 22:08:14 -050034 update(const ndn::Name& name, NexthopList& nextHopList);
akmhoque53353462014-04-22 08:43:45 -050035
36 void
akmhoque31d1d4b2014-05-05 22:08:14 -050037 clean();
akmhoque53353462014-04-22 08:43:45 -050038
39 void
akmhoquefdbddb12014-05-02 18:35:19 -050040 setEntryRefreshTime(int32_t fert)
akmhoque53353462014-04-22 08:43:45 -050041 {
42 m_refreshTime = fert;
43 }
44
45 void
46 print();
47
48private:
49 void
akmhoque31d1d4b2014-05-05 22:08:14 -050050 removeHop(NexthopList& nl, uint32_t doNotRemoveHopFaceId,
51 const ndn::Name& name);
akmhoque53353462014-04-22 08:43:45 -050052
53 int
akmhoquefdbddb12014-05-02 18:35:19 -050054 getNumberOfFacesForName(NexthopList& nextHopList, uint32_t maxFacesPerPrefix);
akmhoque53353462014-04-22 08:43:45 -050055
56 ndn::EventId
akmhoque31d1d4b2014-05-05 22:08:14 -050057 scheduleEntryRefreshing(const ndn::Name& name, int32_t feSeqNum,
akmhoquefdbddb12014-05-02 18:35:19 -050058 int32_t refreshTime);
akmhoque53353462014-04-22 08:43:45 -050059
60 void
akmhoque31d1d4b2014-05-05 22:08:14 -050061 cancelScheduledExpiringEvent(ndn::EventId eid);
akmhoquefdbddb12014-05-02 18:35:19 -050062
63 void
akmhoque31d1d4b2014-05-05 22:08:14 -050064 refreshEntry(const ndn::Name& name, int32_t feSeqNum);
akmhoquefdbddb12014-05-02 18:35:19 -050065
66 void
akmhoque31d1d4b2014-05-05 22:08:14 -050067 registerPrefixInNfd(const ndn::Name& namePrefix, uint64_t faceId,
68 uint64_t faceCost);
akmhoquefdbddb12014-05-02 18:35:19 -050069
70 void
akmhoque31d1d4b2014-05-05 22:08:14 -050071 unregisterPrefixFromNfd(const ndn::Name& namePrefix, uint64_t faceId);
72
akmhoquefdbddb12014-05-02 18:35:19 -050073 void
akmhoque31d1d4b2014-05-05 22:08:14 -050074 onSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
75 const std::string& message);
akmhoquefdbddb12014-05-02 18:35:19 -050076
77 void
78 onFailure(uint32_t code, const std::string& error, const std::string& message);
akmhoque53353462014-04-22 08:43:45 -050079
80private:
akmhoque31d1d4b2014-05-05 22:08:14 -050081 Nlsr& m_nlsr;
akmhoque53353462014-04-22 08:43:45 -050082 std::list<FibEntry> m_table;
akmhoquefdbddb12014-05-02 18:35:19 -050083 int32_t m_refreshTime;
84 ndn::nfd::Controller m_controller;
akmhoque53353462014-04-22 08:43:45 -050085};
86
87}//namespace nlsr
88#endif //NLSR_FIB_HPP