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 | } |
| 59 | string getLsaKey(); |
| 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 | bd7c8e6 | 2014-02-01 14:57:40 -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 | |
| 87 | string getNameLsaData(); |
| 88 | |
| 89 | private: |
| 90 | Npl npl; |
| 91 | |
| 92 | }; |
| 93 | |
akmhoque | bd7c8e6 | 2014-02-01 14:57:40 -0600 | [diff] [blame] | 94 | std::ostream& |
| 95 | operator<<(std::ostream& os, NameLsa& nLsa); |
| 96 | |
| 97 | class AdjLsa: public Lsa{ |
akmhoque | fd1dd0a | 2014-02-01 01:11:35 -0600 | [diff] [blame] | 98 | public: |
| 99 | AdjLsa() |
| 100 | : Lsa() |
| 101 | , adl() |
| 102 | { |
| 103 | } |
| 104 | |
| 105 | private: |
| 106 | uint32_t noLink; |
| 107 | Adl adl; |
| 108 | }; |
| 109 | |
akmhoque | bd7c8e6 | 2014-02-01 14:57:40 -0600 | [diff] [blame] | 110 | class CorLsa:public Lsa{ |
akmhoque | fd1dd0a | 2014-02-01 01:11:35 -0600 | [diff] [blame] | 111 | public: |
| 112 | CorLsa() |
| 113 | :Lsa() |
| 114 | { |
| 115 | } |
akmhoque | 3c6bd92 | 2014-02-01 17:10:17 -0600 | [diff] [blame^] | 116 | |
| 117 | CorLsa(string origR, uint8_t lst, uint32_t lsn, uint32_t lt |
| 118 | , double r, double theta); |
| 119 | string getCorLsaData(); |
| 120 | |
| 121 | double getCorRadius() |
| 122 | { |
| 123 | return corRad; |
| 124 | } |
| 125 | |
| 126 | void setCorRadius(double cr) |
| 127 | { |
| 128 | corRad=cr; |
| 129 | } |
| 130 | |
| 131 | double getCorTheta() |
| 132 | { |
| 133 | return corTheta; |
| 134 | } |
| 135 | |
| 136 | void setCorTheta(double ct){ |
| 137 | corTheta=ct; |
| 138 | } |
akmhoque | fd1dd0a | 2014-02-01 01:11:35 -0600 | [diff] [blame] | 139 | private: |
| 140 | double corRad; |
| 141 | double corTheta; |
| 142 | |
| 143 | }; |
| 144 | |
akmhoque | 3c6bd92 | 2014-02-01 17:10:17 -0600 | [diff] [blame^] | 145 | std::ostream& |
| 146 | operator<<(std::ostream& os, CorLsa& cLsa); |
| 147 | |
akmhoque | fd1dd0a | 2014-02-01 01:11:35 -0600 | [diff] [blame] | 148 | |
| 149 | |
| 150 | |
| 151 | #endif |