blob: a75f572079c39b35f2414b13fecf6a1ada5795d4 [file] [log] [blame]
akmhoquefd1dd0a2014-02-01 01:11:35 -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 }
akmhoque3fdf7612014-02-04 21:18:23 -060059 //string getLsaKey();
akmhoquefd1dd0a2014-02-01 01:11:35 -060060protected:
61 string origRouter;
62 uint8_t lsType;
63 uint32_t lsSeqNo;
64 uint32_t lifeTime;
65};
66
akmhoquebd7c8e62014-02-01 14:57:40 -060067class NameLsa:public Lsa{
akmhoquefd1dd0a2014-02-01 01:11:35 -060068public:
69 NameLsa()
70 : Lsa()
71 , npl()
72 {
73 setLsType(1);
74 }
75
akmhoquecd552472014-02-01 21:22:16 -060076 NameLsa(string origR, uint8_t lst, uint32_t lsn, uint32_t lt, Npl npl);
akmhoquefd1dd0a2014-02-01 01:11:35 -060077
78 Npl& getNpl(){
79 return npl;
80 }
81
82 void addNameToLsa(string& name)
83 {
84 npl.insertIntoNpl(name);
85 }
86
akmhoque62a8e402014-02-08 12:00:27 -060087 void removeNameFromLsa(string& name)
88 {
89 npl.removeFromNpl(name);
90 }
91
akmhoque3fdf7612014-02-04 21:18:23 -060092 string getNameLsaKey();
93
akmhoquefd1dd0a2014-02-01 01:11:35 -060094 string getNameLsaData();
95
96private:
97 Npl npl;
98
99};
100
akmhoquebd7c8e62014-02-01 14:57:40 -0600101std::ostream&
102operator<<(std::ostream& os, NameLsa& nLsa);
103
104class AdjLsa: public Lsa{
akmhoquefd1dd0a2014-02-01 01:11:35 -0600105public:
106 AdjLsa()
107 : Lsa()
108 , adl()
109 {
akmhoquecd552472014-02-01 21:22:16 -0600110 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 }
akmhoque3fdf7612014-02-04 21:18:23 -0600123 string getAdjLsaKey();
akmhoquecd552472014-02-01 21:22:16 -0600124 string getAdjLsaData();
125 uint32_t getNoLink()
126 {
127 return noLink;
akmhoquefd1dd0a2014-02-01 01:11:35 -0600128 }
129
130private:
131 uint32_t noLink;
132 Adl adl;
133};
134
akmhoquecd552472014-02-01 21:22:16 -0600135std::ostream&
136operator<<(std::ostream& os, AdjLsa& aLsa);
137
akmhoquebd7c8e62014-02-01 14:57:40 -0600138class CorLsa:public Lsa{
akmhoquefd1dd0a2014-02-01 01:11:35 -0600139public:
140 CorLsa()
141 :Lsa()
142 {
akmhoquecd552472014-02-01 21:22:16 -0600143 setLsType(3);
akmhoquefd1dd0a2014-02-01 01:11:35 -0600144 }
akmhoque3c6bd922014-02-01 17:10:17 -0600145
146 CorLsa(string origR, uint8_t lst, uint32_t lsn, uint32_t lt
147 , double r, double theta);
akmhoque3fdf7612014-02-04 21:18:23 -0600148 string getCorLsaKey();
akmhoque3c6bd922014-02-01 17:10:17 -0600149 string getCorLsaData();
150
151 double getCorRadius()
152 {
akmhoquef7c2c7c2014-02-06 11:32:43 -0600153 if ( corRad >= 0 )
154 {
155 return corRad;
156 }
157 else
158 {
159 return -1;
160 }
akmhoque3c6bd922014-02-01 17:10:17 -0600161 }
162
163 void setCorRadius(double cr)
164 {
165 corRad=cr;
166 }
167
168 double getCorTheta()
169 {
170 return corTheta;
171 }
172
173 void setCorTheta(double ct){
174 corTheta=ct;
175 }
akmhoquefd1dd0a2014-02-01 01:11:35 -0600176private:
177 double corRad;
178 double corTheta;
179
180};
181
akmhoque3c6bd922014-02-01 17:10:17 -0600182std::ostream&
183operator<<(std::ostream& os, CorLsa& cLsa);
184
akmhoquefd1dd0a2014-02-01 01:11:35 -0600185
186
187
188#endif