blob: d04acd732e862129d8db2107b9b384916c8bae01 [file] [log] [blame]
akmhoque298385a2014-02-13 14:13:09 -06001#ifndef NLSR_LSDB_HPP
2#define NLSR_LSDB_HPP
3
4#include <utility>
5#include "nlsr_lsa.hpp"
6
7using namespace std;
8
akmhoque1a481092014-02-19 16:34:22 -06009class Nlsr;
akmhoque298385a2014-02-13 14:13:09 -060010
11class Lsdb{
12public:
13 Lsdb()
14 : lsaRefreshTime(0)
15 {
16 }
17
18
19 bool doesLsaExist(string key, int lsType);
20 // function related to Name LSDB
akmhoque1a481092014-02-19 16:34:22 -060021 bool buildAndInstallOwnNameLsa(Nlsr& pnlsr);
akmhoque298385a2014-02-13 14:13:09 -060022 std::pair<NameLsa&, bool> getNameLsa(string key);
akmhoque1a481092014-02-19 16:34:22 -060023 bool installNameLsa(Nlsr& pnlsr, NameLsa &nlsa);
24 bool removeNameLsa(Nlsr& pnlsr, string& key);
akmhoque298385a2014-02-13 14:13:09 -060025 void printNameLsdb(); //debugging
26
27 //function related to Cor LSDB
akmhoque1a481092014-02-19 16:34:22 -060028 bool buildAndInstallOwnCorLsa(Nlsr& pnlsr);
akmhoque298385a2014-02-13 14:13:09 -060029 std::pair<CorLsa&, bool> getCorLsa(string key);
akmhoque1a481092014-02-19 16:34:22 -060030 bool installCorLsa(Nlsr& pnlsr, CorLsa &clsa);
31 bool removeCorLsa(Nlsr& pnlsr, string& key);
akmhoque298385a2014-02-13 14:13:09 -060032 void printCorLsdb(); //debugging
33
34 //function related to Adj LSDB
akmhoque1a481092014-02-19 16:34:22 -060035 void scheduledAdjLsaBuild(Nlsr& pnlsr);
36 bool buildAndInstallOwnAdjLsa(Nlsr& pnlsr);
37 bool removeAdjLsa(Nlsr& pnlsr, string& key);
38 bool installAdjLsa(Nlsr& pnlsr, AdjLsa &alsa);
akmhoque298385a2014-02-13 14:13:09 -060039 std::pair<AdjLsa& , bool> getAdjLsa(string key);
40 std::list<AdjLsa>& getAdjLsdb();
41 void printAdjLsdb();
42
akmhoque1a481092014-02-19 16:34:22 -060043 //void scheduleRefreshLsdb(Nlsr& pnlsr, int interval);
akmhoque298385a2014-02-13 14:13:09 -060044 void setLsaRefreshTime(int lrt);
45 void setThisRouterPrefix(string trp);
46
47private:
48 bool addNameLsa(NameLsa &nlsa);
49 bool doesNameLsaExist(string key);
50
51
52 bool addCorLsa(CorLsa& clsa);
53 bool doesCorLsaExist(string key);
54
55 bool addAdjLsa(AdjLsa &alsa);
56 bool doesAdjLsaExist(string key);
akmhoque85d88332014-02-17 21:11:21 -060057
58 ndn::EventId
akmhoque1a481092014-02-19 16:34:22 -060059 scheduleNameLsaExpiration(Nlsr& pnlsr, string key, int seqNo, int expTime);
60 void exprireOrRefreshNameLsa(Nlsr& pnlsr, string lsaKey, int seqNo);
akmhoque85d88332014-02-17 21:11:21 -060061 ndn::EventId
akmhoque1a481092014-02-19 16:34:22 -060062 scheduleAdjLsaExpiration(Nlsr& pnlsr, string key, int seqNo, int expTime);
63 void exprireOrRefreshAdjLsa(Nlsr& pnlsr, string lsaKey, int seqNo);
akmhoque85d88332014-02-17 21:11:21 -060064 ndn::EventId
akmhoque1a481092014-02-19 16:34:22 -060065 scheduleCorLsaExpiration(Nlsr& pnlsr, string key, int seqNo, int expTime);
66 void exprireOrRefreshCorLsa(Nlsr& pnlsr, string lsaKey, int seqNo);
akmhoque298385a2014-02-13 14:13:09 -060067
68
69private:
akmhoque1a481092014-02-19 16:34:22 -060070 void cancelScheduleLsaExpiringEvent(Nlsr& pnlsr, EventId eid);
akmhoque85d88332014-02-17 21:11:21 -060071
akmhoque298385a2014-02-13 14:13:09 -060072 std::list<NameLsa> nameLsdb;
73 std::list<AdjLsa> adjLsdb;
74 std::list<CorLsa> corLsdb;
75
76 int lsaRefreshTime;
77 string thisRouterPrefix;
78
79};
80
81#endif