blob: 02aa4009197dcf92f450eaec5e98f25af4a926b8 [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>
akmhoquec7a79b22014-05-26 08:06:19 -05008#include <ndn-cxx/util/time.hpp>
akmhoque157b0a42014-05-13 00:26:37 -05009#include "face-map.hpp"
akmhoque53353462014-04-22 08:43:45 -050010#include "fib-entry.hpp"
11
12namespace nlsr {
13
14class Nlsr;
15
akmhoque53353462014-04-22 08:43:45 -050016
17class Fib
18{
19public:
akmhoque31d1d4b2014-05-05 22:08:14 -050020 Fib(Nlsr& nlsr, ndn::Face& face)
21 : m_nlsr(nlsr)
22 , m_table()
akmhoque53353462014-04-22 08:43:45 -050023 , m_refreshTime(0)
akmhoquefdbddb12014-05-02 18:35:19 -050024 , m_controller(face)
akmhoque157b0a42014-05-13 00:26:37 -050025 , m_faceMap()
akmhoquefdbddb12014-05-02 18:35:19 -050026 {
27 }
28 ~Fib()
akmhoque53353462014-04-22 08:43:45 -050029 {
30 }
31
32 void
akmhoque31d1d4b2014-05-05 22:08:14 -050033 remove(const ndn::Name& name);
akmhoque53353462014-04-22 08:43:45 -050034
35 void
akmhoque31d1d4b2014-05-05 22:08:14 -050036 update(const ndn::Name& name, NexthopList& nextHopList);
akmhoque53353462014-04-22 08:43:45 -050037
38 void
akmhoque31d1d4b2014-05-05 22:08:14 -050039 clean();
akmhoque53353462014-04-22 08:43:45 -050040
41 void
akmhoquefdbddb12014-05-02 18:35:19 -050042 setEntryRefreshTime(int32_t fert)
akmhoque53353462014-04-22 08:43:45 -050043 {
44 m_refreshTime = fert;
45 }
46
47 void
48 print();
49
50private:
51 void
akmhoque157b0a42014-05-13 00:26:37 -050052 removeHop(NexthopList& nl, const std::string& doNotRemoveHopFaceUri,
akmhoque31d1d4b2014-05-05 22:08:14 -050053 const ndn::Name& name);
akmhoque53353462014-04-22 08:43:45 -050054
55 int
akmhoquefdbddb12014-05-02 18:35:19 -050056 getNumberOfFacesForName(NexthopList& nextHopList, uint32_t maxFacesPerPrefix);
akmhoque53353462014-04-22 08:43:45 -050057
58 ndn::EventId
akmhoque31d1d4b2014-05-05 22:08:14 -050059 scheduleEntryRefreshing(const ndn::Name& name, int32_t feSeqNum,
akmhoquec7a79b22014-05-26 08:06:19 -050060 const ndn::time::seconds& expTime);
akmhoque53353462014-04-22 08:43:45 -050061
62 void
akmhoque31d1d4b2014-05-05 22:08:14 -050063 cancelScheduledExpiringEvent(ndn::EventId eid);
akmhoquefdbddb12014-05-02 18:35:19 -050064
65 void
akmhoque31d1d4b2014-05-05 22:08:14 -050066 refreshEntry(const ndn::Name& name, int32_t feSeqNum);
akmhoquefdbddb12014-05-02 18:35:19 -050067
akmhoque157b0a42014-05-13 00:26:37 -050068public:
akmhoquefdbddb12014-05-02 18:35:19 -050069 void
akmhoque157b0a42014-05-13 00:26:37 -050070 registerPrefix(const ndn::Name& namePrefix, const std::string& faceUri,
71 uint64_t faceCost, uint64_t timeout);
akmhoquefdbddb12014-05-02 18:35:19 -050072
73 void
akmhoque157b0a42014-05-13 00:26:37 -050074 registerPrefixInNfd(const ndn::nfd::ControlParameters& faceCreateResult,
75 const ndn::Name& namePrefix, uint64_t faceCost, uint64_t timeout);
76
77 void
78 setStrategy(const ndn::Name& name, const std::string& strategy);
79
akmhoque674b0b12014-05-20 14:33:28 -050080 void
81 writeLog();
82
akmhoque157b0a42014-05-13 00:26:37 -050083private:
84 void
85 unregisterPrefix(const ndn::Name& namePrefix, const std::string& faceUri);
86
87 void
88 onRegistration(const ndn::nfd::ControlParameters& commandSuccessResult,
89 const std::string& message, const std::string& faceUri);
akmhoque31d1d4b2014-05-05 22:08:14 -050090
akmhoquefdbddb12014-05-02 18:35:19 -050091 void
akmhoque31d1d4b2014-05-05 22:08:14 -050092 onSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
93 const std::string& message);
akmhoquefdbddb12014-05-02 18:35:19 -050094
95 void
96 onFailure(uint32_t code, const std::string& error, const std::string& message);
akmhoque53353462014-04-22 08:43:45 -050097
98private:
akmhoque31d1d4b2014-05-05 22:08:14 -050099 Nlsr& m_nlsr;
akmhoque53353462014-04-22 08:43:45 -0500100 std::list<FibEntry> m_table;
akmhoquefdbddb12014-05-02 18:35:19 -0500101 int32_t m_refreshTime;
102 ndn::nfd::Controller m_controller;
akmhoque157b0a42014-05-13 00:26:37 -0500103 FaceMap m_faceMap;
akmhoque53353462014-04-22 08:43:45 -0500104};
105
106}//namespace nlsr
107#endif //NLSR_FIB_HPP