blob: 62c91ee71d975ba598380c6fff47df7939ac7e85 [file] [log] [blame]
akmhoquebd7c8e62014-02-01 14:57:40 -06001#ifndef NLSR_LSDB_HPP
2#define NLSR_LSDB_HPP
3
akmhoque62a8e402014-02-08 12:00:27 -06004#include <utility>
akmhoquebd7c8e62014-02-01 14:57:40 -06005#include "nlsr_lsa.hpp"
6
7using namespace std;
8
9class nlsr;
10
11class Lsdb{
12public:
13 Lsdb()
akmhoquee77d8142014-02-11 11:59:57 -060014 : lsaRefreshTime(0)
akmhoquebd7c8e62014-02-01 14:57:40 -060015 {
16 }
17
18
19 bool doesLsaExist(string key, int lsType);
20 // function related to Name LSDB
akmhoque3c6bd922014-02-01 17:10:17 -060021 bool buildAndInstallOwnNameLsa(nlsr& pnlsr);
akmhoque62a8e402014-02-08 12:00:27 -060022 std::pair<NameLsa&, bool> getNameLsa(string key);
23 bool installNameLsa(nlsr& pnlsr, NameLsa &nlsa);
akmhoque4768f892014-02-08 23:58:07 -060024 bool removeNameLsa(nlsr& pnlsr, string& key);
akmhoquebd7c8e62014-02-01 14:57:40 -060025 void printNameLsdb(); //debugging
26
27 //function related to Cor LSDB
akmhoque3c6bd922014-02-01 17:10:17 -060028 bool buildAndInstallOwnCorLsa(nlsr& pnlsr);
akmhoque62a8e402014-02-08 12:00:27 -060029 std::pair<CorLsa&, bool> getCorLsa(string key);
akmhoquef7c2c7c2014-02-06 11:32:43 -060030 bool installCorLsa(nlsr& pnlsr, CorLsa &clsa);
akmhoque4768f892014-02-08 23:58:07 -060031 bool removeCorLsa(nlsr& pnlsr, string& key);
akmhoquebd7c8e62014-02-01 14:57:40 -060032 void printCorLsdb(); //debugging
akmhoquecd552472014-02-01 21:22:16 -060033
akmhoque79d355f2014-02-04 15:11:16 -060034 //function related to Adj LSDB
akmhoquecd552472014-02-01 21:22:16 -060035 void scheduledAdjLsaBuild(nlsr& pnlsr);
36 bool buildAndInstallOwnAdjLsa(nlsr& pnlsr);
akmhoque4768f892014-02-08 23:58:07 -060037 bool removeAdjLsa(nlsr& pnlsr, string& key);
akmhoquedfa4a5b2014-02-03 20:12:29 -060038 bool installAdjLsa(nlsr& pnlsr, AdjLsa &alsa);
akmhoque62a8e402014-02-08 12:00:27 -060039 std::pair<AdjLsa& , bool> getAdjLsa(string key);
akmhoque79d355f2014-02-04 15:11:16 -060040 std::list<AdjLsa>& getAdjLsdb();
akmhoquecd552472014-02-01 21:22:16 -060041 void printAdjLsdb();
akmhoquee77d8142014-02-11 11:59:57 -060042
43 //void scheduleRefreshLsdb(nlsr& pnlsr, int interval);
44 void setLsaRefreshTime(int lrt);
45 void setThisRouterPrefix(string trp);
akmhoquebd7c8e62014-02-01 14:57:40 -060046
47private:
48 bool addNameLsa(NameLsa &nlsa);
akmhoquebd7c8e62014-02-01 14:57:40 -060049 bool doesNameLsaExist(string key);
akmhoquecd552472014-02-01 21:22:16 -060050
akmhoque4768f892014-02-08 23:58:07 -060051
akmhoquecd552472014-02-01 21:22:16 -060052 bool addCorLsa(CorLsa& clsa);
akmhoquebd7c8e62014-02-01 14:57:40 -060053 bool doesCorLsaExist(string key);
54
akmhoquecd552472014-02-01 21:22:16 -060055 bool addAdjLsa(AdjLsa &alsa);
56 bool doesAdjLsaExist(string key);
akmhoquee77d8142014-02-11 11:59:57 -060057
58 void scheduleNameLsaExpiration(nlsr& pnlsr, string key, int seqNo, int expTime);
59 void exprireOrRefreshNameLsa(nlsr& pnlsr, string lsaKey, int seqNo);
60 void scheduleAdjLsaExpiration(nlsr& pnlsr, string key, int seqNo, int expTime);
61 void exprireOrRefreshAdjLsa(nlsr& pnlsr, string lsaKey, int seqNo);
62 void scheduleCorLsaExpiration(nlsr& pnlsr, string key, int seqNo, int expTime);
63 void exprireOrRefreshCorLsa(nlsr& pnlsr, string lsaKey, int seqNo);
akmhoquecd552472014-02-01 21:22:16 -060064
65
akmhoquebd7c8e62014-02-01 14:57:40 -060066private:
67 std::list<NameLsa> nameLsdb;
68 std::list<AdjLsa> adjLsdb;
69 std::list<CorLsa> corLsdb;
70
akmhoquee77d8142014-02-11 11:59:57 -060071 int lsaRefreshTime;
72 string thisRouterPrefix;
73
akmhoquebd7c8e62014-02-01 14:57:40 -060074};
75
76#endif