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