akmhoque | fd1dd0a | 2014-02-01 01:11:35 -0600 | [diff] [blame] | 1 | #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 | |
| 8 | using namespace std; |
| 9 | |
| 10 | class Lsa{ |
| 11 | public: |
| 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 | } |
akmhoque | 3fdf761 | 2014-02-04 21:18:23 -0600 | [diff] [blame] | 59 | //string getLsaKey(); |
akmhoque | fd1dd0a | 2014-02-01 01:11:35 -0600 | [diff] [blame] | 60 | protected: |
| 61 | string origRouter; |
| 62 | uint8_t lsType; |
| 63 | uint32_t lsSeqNo; |
| 64 | uint32_t lifeTime; |
| 65 | }; |
| 66 | |
akmhoque | bd7c8e6 | 2014-02-01 14:57:40 -0600 | [diff] [blame] | 67 | class NameLsa:public Lsa{ |
akmhoque | fd1dd0a | 2014-02-01 01:11:35 -0600 | [diff] [blame] | 68 | public: |
| 69 | NameLsa() |
| 70 | : Lsa() |
| 71 | , npl() |
| 72 | { |
| 73 | setLsType(1); |
| 74 | } |
| 75 | |
akmhoque | cd55247 | 2014-02-01 21:22:16 -0600 | [diff] [blame] | 76 | NameLsa(string origR, uint8_t lst, uint32_t lsn, uint32_t lt, Npl npl); |
akmhoque | fd1dd0a | 2014-02-01 01:11:35 -0600 | [diff] [blame] | 77 | |
| 78 | Npl& getNpl(){ |
| 79 | return npl; |
| 80 | } |
| 81 | |
| 82 | void addNameToLsa(string& name) |
| 83 | { |
| 84 | npl.insertIntoNpl(name); |
| 85 | } |
| 86 | |
akmhoque | 3fdf761 | 2014-02-04 21:18:23 -0600 | [diff] [blame] | 87 | string getNameLsaKey(); |
| 88 | |
akmhoque | fd1dd0a | 2014-02-01 01:11:35 -0600 | [diff] [blame] | 89 | string getNameLsaData(); |
| 90 | |
| 91 | private: |
| 92 | Npl npl; |
| 93 | |
| 94 | }; |
| 95 | |
akmhoque | bd7c8e6 | 2014-02-01 14:57:40 -0600 | [diff] [blame] | 96 | std::ostream& |
| 97 | operator<<(std::ostream& os, NameLsa& nLsa); |
| 98 | |
| 99 | class AdjLsa: public Lsa{ |
akmhoque | fd1dd0a | 2014-02-01 01:11:35 -0600 | [diff] [blame] | 100 | public: |
| 101 | AdjLsa() |
| 102 | : Lsa() |
| 103 | , adl() |
| 104 | { |
akmhoque | cd55247 | 2014-02-01 21:22:16 -0600 | [diff] [blame] | 105 | setLsType(2); |
| 106 | } |
| 107 | |
| 108 | AdjLsa(string origR, uint8_t lst, uint32_t lsn, uint32_t lt, |
| 109 | uint32_t nl ,Adl padl); |
| 110 | Adl& getAdl(){ |
| 111 | return adl; |
| 112 | } |
| 113 | |
| 114 | void addAdjacentToLsa(Adjacent adj) |
| 115 | { |
| 116 | adl.insert(adj); |
| 117 | } |
akmhoque | 3fdf761 | 2014-02-04 21:18:23 -0600 | [diff] [blame] | 118 | string getAdjLsaKey(); |
akmhoque | cd55247 | 2014-02-01 21:22:16 -0600 | [diff] [blame] | 119 | string getAdjLsaData(); |
| 120 | uint32_t getNoLink() |
| 121 | { |
| 122 | return noLink; |
akmhoque | fd1dd0a | 2014-02-01 01:11:35 -0600 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | private: |
| 126 | uint32_t noLink; |
| 127 | Adl adl; |
| 128 | }; |
| 129 | |
akmhoque | cd55247 | 2014-02-01 21:22:16 -0600 | [diff] [blame] | 130 | std::ostream& |
| 131 | operator<<(std::ostream& os, AdjLsa& aLsa); |
| 132 | |
akmhoque | bd7c8e6 | 2014-02-01 14:57:40 -0600 | [diff] [blame] | 133 | class CorLsa:public Lsa{ |
akmhoque | fd1dd0a | 2014-02-01 01:11:35 -0600 | [diff] [blame] | 134 | public: |
| 135 | CorLsa() |
| 136 | :Lsa() |
| 137 | { |
akmhoque | cd55247 | 2014-02-01 21:22:16 -0600 | [diff] [blame] | 138 | setLsType(3); |
akmhoque | fd1dd0a | 2014-02-01 01:11:35 -0600 | [diff] [blame] | 139 | } |
akmhoque | 3c6bd92 | 2014-02-01 17:10:17 -0600 | [diff] [blame] | 140 | |
| 141 | CorLsa(string origR, uint8_t lst, uint32_t lsn, uint32_t lt |
| 142 | , double r, double theta); |
akmhoque | 3fdf761 | 2014-02-04 21:18:23 -0600 | [diff] [blame] | 143 | string getCorLsaKey(); |
akmhoque | 3c6bd92 | 2014-02-01 17:10:17 -0600 | [diff] [blame] | 144 | string getCorLsaData(); |
| 145 | |
| 146 | double getCorRadius() |
| 147 | { |
akmhoque | f7c2c7c | 2014-02-06 11:32:43 -0600 | [diff] [blame^] | 148 | if ( corRad >= 0 ) |
| 149 | { |
| 150 | return corRad; |
| 151 | } |
| 152 | else |
| 153 | { |
| 154 | return -1; |
| 155 | } |
akmhoque | 3c6bd92 | 2014-02-01 17:10:17 -0600 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | void setCorRadius(double cr) |
| 159 | { |
| 160 | corRad=cr; |
| 161 | } |
| 162 | |
| 163 | double getCorTheta() |
| 164 | { |
| 165 | return corTheta; |
| 166 | } |
| 167 | |
| 168 | void setCorTheta(double ct){ |
| 169 | corTheta=ct; |
| 170 | } |
akmhoque | fd1dd0a | 2014-02-01 01:11:35 -0600 | [diff] [blame] | 171 | private: |
| 172 | double corRad; |
| 173 | double corTheta; |
| 174 | |
| 175 | }; |
| 176 | |
akmhoque | 3c6bd92 | 2014-02-01 17:10:17 -0600 | [diff] [blame] | 177 | std::ostream& |
| 178 | operator<<(std::ostream& os, CorLsa& cLsa); |
| 179 | |
akmhoque | fd1dd0a | 2014-02-01 01:11:35 -0600 | [diff] [blame] | 180 | |
| 181 | |
| 182 | |
| 183 | #endif |