blob: 559df7ae7a61091462ceb20fd836c25f63ff7810 [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
79private:
80 void
81 unregisterPrefix(const ndn::Name& namePrefix, const std::string& faceUri);
82
83 void
84 onRegistration(const ndn::nfd::ControlParameters& commandSuccessResult,
85 const std::string& message, const std::string& faceUri);
akmhoque31d1d4b2014-05-05 22:08:14 -050086
akmhoquefdbddb12014-05-02 18:35:19 -050087 void
akmhoque31d1d4b2014-05-05 22:08:14 -050088 onSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
89 const std::string& message);
akmhoquefdbddb12014-05-02 18:35:19 -050090
91 void
92 onFailure(uint32_t code, const std::string& error, const std::string& message);
akmhoque53353462014-04-22 08:43:45 -050093
94private:
akmhoque31d1d4b2014-05-05 22:08:14 -050095 Nlsr& m_nlsr;
akmhoque53353462014-04-22 08:43:45 -050096 std::list<FibEntry> m_table;
akmhoquefdbddb12014-05-02 18:35:19 -050097 int32_t m_refreshTime;
98 ndn::nfd::Controller m_controller;
akmhoque157b0a42014-05-13 00:26:37 -050099 FaceMap m_faceMap;
akmhoque53353462014-04-22 08:43:45 -0500100};
101
102}//namespace nlsr
103#endif //NLSR_FIB_HPP