blob: 444001aff5822e5d3d3ba7344c03d3ce0b266b9a [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
akmhoque1fd8c1e2014-02-19 19:41:49 -06007namespace nlsr
8{
akmhoqueb1710aa2014-02-19 17:13:36 -06009
akmhoque5a44dd42014-03-12 18:11:32 -050010 using namespace std;
akmhoque298385a2014-02-13 14:13:09 -060011
akmhoque5a44dd42014-03-12 18:11:32 -050012 class Nlsr;
akmhoque298385a2014-02-13 14:13:09 -060013
akmhoque5a44dd42014-03-12 18:11:32 -050014 class Lsdb
15 {
16 public:
17 Lsdb()
akmhoque082403a2014-04-15 15:32:07 -050018 : m_lsaRefreshTime(0)
akmhoque1fd8c1e2014-02-19 19:41:49 -060019 {
akmhoque5a44dd42014-03-12 18:11:32 -050020 }
akmhoque298385a2014-02-13 14:13:09 -060021
akmhoque298385a2014-02-13 14:13:09 -060022
akmhoque5a44dd42014-03-12 18:11:32 -050023 bool doesLsaExist(string key, int lsType);
24 // function related to Name LSDB
25 bool buildAndInstallOwnNameLsa(Nlsr& pnlsr);
26 std::pair<NameLsa&, bool> getNameLsa(string key);
27 bool installNameLsa(Nlsr& pnlsr, NameLsa &nlsa);
28 bool removeNameLsa(Nlsr& pnlsr, string& key);
29 bool isNameLsaNew(string key, uint64_t seqNo);
30 void printNameLsdb(); //debugging
akmhoque298385a2014-02-13 14:13:09 -060031
akmhoque5a44dd42014-03-12 18:11:32 -050032 //function related to Cor LSDB
33 bool buildAndInstallOwnCorLsa(Nlsr& pnlsr);
34 std::pair<CorLsa&, bool> getCorLsa(string key);
35 bool installCorLsa(Nlsr& pnlsr, CorLsa &clsa);
36 bool removeCorLsa(Nlsr& pnlsr, string& key);
37 bool isCorLsaNew(string key, uint64_t seqNo);
38 void printCorLsdb(); //debugging
akmhoque298385a2014-02-13 14:13:09 -060039
akmhoque5a44dd42014-03-12 18:11:32 -050040 //function related to Adj LSDB
41 void scheduledAdjLsaBuild(Nlsr& pnlsr);
42 bool buildAndInstallOwnAdjLsa(Nlsr& pnlsr);
43 bool removeAdjLsa(Nlsr& pnlsr, string& key);
44 bool isAdjLsaNew(string key, uint64_t seqNo);
45 bool installAdjLsa(Nlsr& pnlsr, AdjLsa &alsa);
46 std::pair<AdjLsa& , bool> getAdjLsa(string key);
47 std::list<AdjLsa>& getAdjLsdb();
48 void printAdjLsdb();
akmhoque298385a2014-02-13 14:13:09 -060049
akmhoque5a44dd42014-03-12 18:11:32 -050050 //void scheduleRefreshLsdb(Nlsr& pnlsr, int interval);
51 void setLsaRefreshTime(int lrt);
52 void setThisRouterPrefix(string trp);
akmhoque85d88332014-02-17 21:11:21 -060053
akmhoque5a44dd42014-03-12 18:11:32 -050054 private:
55 bool addNameLsa(NameLsa &nlsa);
56 bool doesNameLsaExist(string key);
akmhoque298385a2014-02-13 14:13:09 -060057
akmhoque85d88332014-02-17 21:11:21 -060058
akmhoque5a44dd42014-03-12 18:11:32 -050059 bool addCorLsa(CorLsa& clsa);
60 bool doesCorLsaExist(string key);
akmhoque298385a2014-02-13 14:13:09 -060061
akmhoque5a44dd42014-03-12 18:11:32 -050062 bool addAdjLsa(AdjLsa &alsa);
63 bool doesAdjLsaExist(string key);
akmhoque298385a2014-02-13 14:13:09 -060064
akmhoque5a44dd42014-03-12 18:11:32 -050065 ndn::EventId
66 scheduleNameLsaExpiration(Nlsr& pnlsr, string key, int seqNo, int expTime);
67 void exprireOrRefreshNameLsa(Nlsr& pnlsr, string lsaKey, int seqNo);
68 ndn::EventId
69 scheduleAdjLsaExpiration(Nlsr& pnlsr, string key, int seqNo, int expTime);
70 void exprireOrRefreshAdjLsa(Nlsr& pnlsr, string lsaKey, int seqNo);
71 ndn::EventId
72 scheduleCorLsaExpiration(Nlsr& pnlsr, string key, int seqNo, int expTime);
73 void exprireOrRefreshCorLsa(Nlsr& pnlsr, string lsaKey, int seqNo);
akmhoque1fd8c1e2014-02-19 19:41:49 -060074
75
akmhoque5a44dd42014-03-12 18:11:32 -050076 private:
77 void cancelScheduleLsaExpiringEvent(Nlsr& pnlsr, EventId eid);
akmhoque1fd8c1e2014-02-19 19:41:49 -060078
akmhoque082403a2014-04-15 15:32:07 -050079 std::list<NameLsa> m_nameLsdb;
80 std::list<AdjLsa> m_adjLsdb;
81 std::list<CorLsa> m_corLsdb;
akmhoque1fd8c1e2014-02-19 19:41:49 -060082
akmhoque082403a2014-04-15 15:32:07 -050083 int m_lsaRefreshTime;
84 string m_thisRouterPrefix;
akmhoque1fd8c1e2014-02-19 19:41:49 -060085
akmhoque5a44dd42014-03-12 18:11:32 -050086 };
akmhoque298385a2014-02-13 14:13:09 -060087
akmhoqueb1710aa2014-02-19 17:13:36 -060088}//namespace nlsr
89
akmhoque298385a2014-02-13 14:13:09 -060090#endif