blob: 2a90fc15695755e758904af18a3c82b0e8130dc0 [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:
akmhoquefdbddb12014-05-02 18:35:19 -050019 Fib(ndn::Face& face)
akmhoque53353462014-04-22 08:43:45 -050020 : m_table()
21 , m_refreshTime(0)
akmhoquefdbddb12014-05-02 18:35:19 -050022 , m_controller(face)
23 {
24 }
25 ~Fib()
akmhoque53353462014-04-22 08:43:45 -050026 {
27 }
28
29 void
akmhoquefdbddb12014-05-02 18:35:19 -050030 remove(Nlsr& pnlsr, const std::string& name);
akmhoque53353462014-04-22 08:43:45 -050031
32 void
akmhoquefdbddb12014-05-02 18:35:19 -050033 update(Nlsr& pnlsr, const std::string& name, NexthopList& nextHopList);
akmhoque53353462014-04-22 08:43:45 -050034
35 void
36 clean(Nlsr& pnlsr);
37
38 void
akmhoquefdbddb12014-05-02 18:35:19 -050039 setEntryRefreshTime(int32_t fert)
akmhoque53353462014-04-22 08:43:45 -050040 {
41 m_refreshTime = fert;
42 }
43
44 void
45 print();
46
47private:
48 void
akmhoquefdbddb12014-05-02 18:35:19 -050049 removeHop(Nlsr& pnlsr, NexthopList& nl, uint32_t doNotRemoveHopFaceId,
50 const std::string& name);
akmhoque53353462014-04-22 08:43:45 -050051
52 int
akmhoquefdbddb12014-05-02 18:35:19 -050053 getNumberOfFacesForName(NexthopList& nextHopList, uint32_t maxFacesPerPrefix);
akmhoque53353462014-04-22 08:43:45 -050054
55 ndn::EventId
akmhoquefdbddb12014-05-02 18:35:19 -050056 scheduleEntryRefreshing(Nlsr& pnlsr, const std::string& name, int32_t feSeqNum,
57 int32_t refreshTime);
akmhoque53353462014-04-22 08:43:45 -050058
59 void
akmhoquefdbddb12014-05-02 18:35:19 -050060 cancelScheduledExpiringEvent(Nlsr& pnlsr, ndn::EventId eid);
61
62 void
63 refreshEntry(Nlsr& nlsr, const std::string& name, int32_t feSeqNum);
64
65 void
66 registerPrefixInNfd(const std::string& namePrefix, uint64_t faceId, uint64_t faceCost);
67
68 void
69 unregisterPrefixFromNfd(const std::string& namePrefix, uint64_t faceId);
70
71 void
72 onSuccess(const ndn::nfd::ControlParameters& commandSuccessResult, const std::string& message);
73
74 void
75 onFailure(uint32_t code, const std::string& error, const std::string& message);
akmhoque53353462014-04-22 08:43:45 -050076
77private:
78 std::list<FibEntry> m_table;
akmhoquefdbddb12014-05-02 18:35:19 -050079 int32_t m_refreshTime;
80 ndn::nfd::Controller m_controller;
akmhoque53353462014-04-22 08:43:45 -050081};
82
83}//namespace nlsr
84#endif //NLSR_FIB_HPP