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