blob: d144e1f027b940f6861c772a68c4e249e2556611 [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>
akmhoque157b0a42014-05-13 00:26:37 -05008#include "face-map.hpp"
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)
akmhoque157b0a42014-05-13 00:26:37 -050024 , m_faceMap()
akmhoquefdbddb12014-05-02 18:35:19 -050025 {
26 }
27 ~Fib()
akmhoque53353462014-04-22 08:43:45 -050028 {
29 }
30
31 void
akmhoque31d1d4b2014-05-05 22:08:14 -050032 remove(const ndn::Name& name);
akmhoque53353462014-04-22 08:43:45 -050033
34 void
akmhoque31d1d4b2014-05-05 22:08:14 -050035 update(const ndn::Name& name, NexthopList& nextHopList);
akmhoque53353462014-04-22 08:43:45 -050036
37 void
akmhoque31d1d4b2014-05-05 22:08:14 -050038 clean();
akmhoque53353462014-04-22 08:43:45 -050039
40 void
akmhoquefdbddb12014-05-02 18:35:19 -050041 setEntryRefreshTime(int32_t fert)
akmhoque53353462014-04-22 08:43:45 -050042 {
43 m_refreshTime = fert;
44 }
45
46 void
47 print();
48
49private:
50 void
akmhoque157b0a42014-05-13 00:26:37 -050051 removeHop(NexthopList& nl, const std::string& doNotRemoveHopFaceUri,
akmhoque31d1d4b2014-05-05 22:08:14 -050052 const ndn::Name& name);
akmhoque53353462014-04-22 08:43:45 -050053
54 int
akmhoquefdbddb12014-05-02 18:35:19 -050055 getNumberOfFacesForName(NexthopList& nextHopList, uint32_t maxFacesPerPrefix);
akmhoque53353462014-04-22 08:43:45 -050056
57 ndn::EventId
akmhoque31d1d4b2014-05-05 22:08:14 -050058 scheduleEntryRefreshing(const ndn::Name& name, int32_t feSeqNum,
akmhoquefdbddb12014-05-02 18:35:19 -050059 int32_t refreshTime);
akmhoque53353462014-04-22 08:43:45 -050060
61 void
akmhoque31d1d4b2014-05-05 22:08:14 -050062 cancelScheduledExpiringEvent(ndn::EventId eid);
akmhoquefdbddb12014-05-02 18:35:19 -050063
64 void
akmhoque31d1d4b2014-05-05 22:08:14 -050065 refreshEntry(const ndn::Name& name, int32_t feSeqNum);
akmhoquefdbddb12014-05-02 18:35:19 -050066
akmhoque157b0a42014-05-13 00:26:37 -050067public:
akmhoquefdbddb12014-05-02 18:35:19 -050068 void
akmhoque157b0a42014-05-13 00:26:37 -050069 registerPrefix(const ndn::Name& namePrefix, const std::string& faceUri,
70 uint64_t faceCost, uint64_t timeout);
akmhoquefdbddb12014-05-02 18:35:19 -050071
72 void
akmhoque157b0a42014-05-13 00:26:37 -050073 registerPrefixInNfd(const ndn::nfd::ControlParameters& faceCreateResult,
74 const ndn::Name& namePrefix, uint64_t faceCost, uint64_t timeout);
75
76 void
77 setStrategy(const ndn::Name& name, const std::string& strategy);
78
akmhoque674b0b12014-05-20 14:33:28 -050079 void
80 writeLog();
81
akmhoque157b0a42014-05-13 00:26:37 -050082private:
83 void
84 unregisterPrefix(const ndn::Name& namePrefix, const std::string& faceUri);
85
86 void
87 onRegistration(const ndn::nfd::ControlParameters& commandSuccessResult,
88 const std::string& message, const std::string& faceUri);
akmhoque31d1d4b2014-05-05 22:08:14 -050089
akmhoquefdbddb12014-05-02 18:35:19 -050090 void
akmhoque31d1d4b2014-05-05 22:08:14 -050091 onSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
92 const std::string& message);
akmhoquefdbddb12014-05-02 18:35:19 -050093
94 void
95 onFailure(uint32_t code, const std::string& error, const std::string& message);
akmhoque53353462014-04-22 08:43:45 -050096
97private:
akmhoque31d1d4b2014-05-05 22:08:14 -050098 Nlsr& m_nlsr;
akmhoque53353462014-04-22 08:43:45 -050099 std::list<FibEntry> m_table;
akmhoquefdbddb12014-05-02 18:35:19 -0500100 int32_t m_refreshTime;
101 ndn::nfd::Controller m_controller;
akmhoque157b0a42014-05-13 00:26:37 -0500102 FaceMap m_faceMap;
akmhoque53353462014-04-22 08:43:45 -0500103};
104
105}//namespace nlsr
106#endif //NLSR_FIB_HPP