blob: e7ab561e4266b7a6c8fdf2e081fb51daa97c1c21 [file] [log] [blame]
akmhoque298385a2014-02-13 14:13:09 -06001#ifndef NLSR_LSA_HPP
2#define NLSR_LSA_HPP
3
akmhoque85d88332014-02-17 21:11:21 -06004#include <ndn-cpp-dev/util/scheduler.hpp>
akmhoque298385a2014-02-13 14:13:09 -06005#include "nlsr_adjacent.hpp"
6#include "nlsr_npl.hpp"
7#include "nlsr_adl.hpp"
8
akmhoqueb1710aa2014-02-19 17:13:36 -06009namespace nlsr {
10
akmhoque298385a2014-02-13 14:13:09 -060011using namespace std;
akmhoque85d88332014-02-17 21:11:21 -060012using namespace ndn;
akmhoque298385a2014-02-13 14:13:09 -060013
14class Lsa{
15public:
16 Lsa()
17 : origRouter()
18 , lsSeqNo()
19 , lifeTime()
akmhoque85d88332014-02-17 21:11:21 -060020 , lsaExpiringEventId()
akmhoque298385a2014-02-13 14:13:09 -060021 {
22 }
23
24
25 void setLsType(uint8_t lst)
26 {
27 lsType=lst;
28 }
29
30 uint8_t getLsType()
31 {
32 return lsType;
33 }
34
35 void setLsSeqNo(uint32_t lsn)
36 {
37 lsSeqNo=lsn;
38 }
39
40 uint32_t getLsSeqNo()
41 {
42 return lsSeqNo;
43 }
44
45 string& getOrigRouter()
46 {
47 return origRouter;
48 }
49
50 void setOrigRouter(string& org)
51 {
52 origRouter=org;
53 }
54
55 uint32_t getLifeTime()
56 {
57 return lifeTime;
58 }
59
60 void setLifeTime(uint32_t lt)
61 {
62 lifeTime=lt;
63 }
akmhoque85d88332014-02-17 21:11:21 -060064
65 void setLsaExpiringEventId(ndn::EventId leei)
66 {
67 lsaExpiringEventId=leei;
68 }
69
70 ndn::EventId getLsaExpiringEventId()
71 {
72 return lsaExpiringEventId;
73 }
74
75
akmhoque298385a2014-02-13 14:13:09 -060076protected:
77 string origRouter;
78 uint8_t lsType;
79 uint32_t lsSeqNo;
80 uint32_t lifeTime;
akmhoque85d88332014-02-17 21:11:21 -060081 ndn::EventId lsaExpiringEventId;
akmhoque298385a2014-02-13 14:13:09 -060082};
83
84class NameLsa:public Lsa{
85public:
86 NameLsa()
87 : Lsa()
88 , npl()
89 {
90 setLsType(1);
91 }
92
93 NameLsa(string origR, uint8_t lst, uint32_t lsn, uint32_t lt, Npl npl);
94
95 Npl& getNpl(){
96 return npl;
97 }
98
99 void addNameToLsa(string& name)
100 {
101 npl.insertIntoNpl(name);
102 }
103
104 void removeNameFromLsa(string& name)
105 {
106 npl.removeFromNpl(name);
107 }
108
109 string getNameLsaKey();
110
111 string getNameLsaData();
112
113private:
114 Npl npl;
115
116};
117
118std::ostream&
119operator<<(std::ostream& os, NameLsa& nLsa);
120
121class AdjLsa: public Lsa{
122public:
123 AdjLsa()
124 : Lsa()
125 , adl()
126 {
127 setLsType(2);
128 }
129
130 AdjLsa(string origR, uint8_t lst, uint32_t lsn, uint32_t lt,
131 uint32_t nl ,Adl padl);
132 Adl& getAdl(){
133 return adl;
134 }
135
136 void addAdjacentToLsa(Adjacent adj)
137 {
138 adl.insert(adj);
139 }
140 string getAdjLsaKey();
141 string getAdjLsaData();
142 uint32_t getNoLink()
143 {
144 return noLink;
145 }
146
147 bool isLsaContentEqual(AdjLsa& alsa);
akmhoque1a481092014-02-19 16:34:22 -0600148 void addNptEntriesForAdjLsa(Nlsr& pnlsr);
149 void removeNptEntriesForAdjLsa(Nlsr& pnlsr);
akmhoque298385a2014-02-13 14:13:09 -0600150
151private:
152 uint32_t noLink;
153 Adl adl;
154};
155
156std::ostream&
157operator<<(std::ostream& os, AdjLsa& aLsa);
158
159class CorLsa:public Lsa{
160public:
161 CorLsa()
162 :Lsa()
163 {
164 setLsType(3);
165 }
166
167 CorLsa(string origR, uint8_t lst, uint32_t lsn, uint32_t lt
168 , double r, double theta);
169 string getCorLsaKey();
170 string getCorLsaData();
171
172 double getCorRadius()
173 {
174 if ( corRad >= 0 )
175 {
176 return corRad;
177 }
178 else
179 {
180 return -1;
181 }
182 }
183
184 void setCorRadius(double cr)
185 {
186 corRad=cr;
187 }
188
189 double getCorTheta()
190 {
191 return corTheta;
192 }
193
194 void setCorTheta(double ct){
195 corTheta=ct;
196 }
197
198 bool isLsaContentEqual(CorLsa& clsa);
199private:
200 double corRad;
201 double corTheta;
202
203};
204
205std::ostream&
206operator<<(std::ostream& os, CorLsa& cLsa);
207
208
akmhoqueb1710aa2014-02-19 17:13:36 -0600209}//namespace nlsr
akmhoque298385a2014-02-13 14:13:09 -0600210
211#endif