akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 1 | #include <string> |
| 2 | #include <iostream> |
| 3 | #include <sstream> |
| 4 | #include <algorithm> |
| 5 | #include <cmath> |
| 6 | #include <limits> |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 7 | #include <boost/tokenizer.hpp> |
| 8 | #include <boost/algorithm/string.hpp> |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 9 | |
| 10 | #include "nlsr.hpp" |
| 11 | #include "lsa.hpp" |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 12 | #include "name-prefix-list.hpp" |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 13 | #include "adjacent.hpp" |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 14 | |
| 15 | |
| 16 | namespace nlsr { |
| 17 | |
| 18 | using namespace std; |
| 19 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 20 | const ndn::Name |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 21 | NameLsa::getKey() const |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 22 | { |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 23 | ndn::Name key = m_origRouter; |
| 24 | key.append("name"); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 25 | return key; |
| 26 | } |
| 27 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 28 | NameLsa::NameLsa(const ndn::Name& origR, const string& lst, uint32_t lsn, |
| 29 | uint32_t lt, |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 30 | NamePrefixList& npl) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 31 | { |
| 32 | m_origRouter = origR; |
| 33 | m_lsType = lst; |
| 34 | m_lsSeqNo = lsn; |
| 35 | m_lifeTime = lt; |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 36 | std::list<ndn::Name>& nl = npl.getNameList(); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame^] | 37 | for (std::list<ndn::Name>::iterator it = nl.begin(); it != nl.end(); it++) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 38 | addName((*it)); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | string |
| 43 | NameLsa::getData() |
| 44 | { |
| 45 | string nameLsaData; |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 46 | nameLsaData = m_origRouter.toUri() + "|" + "name" + "|" |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 47 | + boost::lexical_cast<std::string>(m_lsSeqNo) + "|" |
| 48 | + boost::lexical_cast<std::string>(m_lifeTime); |
| 49 | nameLsaData += "|"; |
| 50 | nameLsaData += boost::lexical_cast<std::string>(m_npl.getSize()); |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 51 | std::list<ndn::Name> nl = m_npl.getNameList(); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame^] | 52 | for (std::list<ndn::Name>::iterator it = nl.begin(); it != nl.end(); it++) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 53 | nameLsaData += "|"; |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 54 | nameLsaData += (*it).toUri(); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 55 | } |
| 56 | return nameLsaData + "|"; |
| 57 | } |
| 58 | |
| 59 | bool |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 60 | NameLsa::initializeFromContent(const std::string& content) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 61 | { |
| 62 | uint32_t numName = 0; |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 63 | boost::char_separator<char> sep("|"); |
| 64 | boost::tokenizer<boost::char_separator<char> >tokens(content, sep); |
| 65 | boost::tokenizer<boost::char_separator<char> >::iterator tok_iter = |
| 66 | tokens.begin(); |
| 67 | m_origRouter = ndn::Name(*tok_iter++); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame^] | 68 | if (!(m_origRouter.size() > 0)) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 69 | return false; |
| 70 | } |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 71 | try { |
| 72 | m_lsType = *tok_iter++; |
| 73 | m_lsSeqNo = boost::lexical_cast<uint32_t>(*tok_iter++); |
| 74 | m_lifeTime = boost::lexical_cast<uint32_t>(*tok_iter++); |
| 75 | numName = boost::lexical_cast<uint32_t>(*tok_iter++); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 76 | } |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 77 | catch (std::exception& e) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 78 | return false; |
| 79 | } |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame^] | 80 | for (uint32_t i = 0; i < numName; i++) { |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 81 | string name(*tok_iter++); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 82 | addName(name); |
| 83 | } |
| 84 | return true; |
| 85 | } |
| 86 | |
| 87 | void |
| 88 | NameLsa::writeLog() |
| 89 | { |
| 90 | } |
| 91 | |
| 92 | std::ostream& |
| 93 | operator<<(std::ostream& os, NameLsa& nLsa) |
| 94 | { |
| 95 | os << "Name Lsa: " << endl; |
| 96 | os << " Origination Router: " << nLsa.getOrigRouter() << endl; |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 97 | os << " Ls Type: " << nLsa.getLsType() << endl; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 98 | os << " Ls Seq No: " << (unsigned int)nLsa.getLsSeqNo() << endl; |
| 99 | os << " Ls Lifetime: " << (unsigned int)nLsa.getLifeTime() << endl; |
| 100 | os << " Names: " << endl; |
| 101 | int i = 1; |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 102 | std::list<ndn::Name> nl = nLsa.getNpl().getNameList(); |
| 103 | for (std::list<ndn::Name>::iterator it = nl.begin(); it != nl.end(); it++) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 104 | { |
| 105 | os << " Name " << i << ": " << (*it) << endl; |
| 106 | } |
| 107 | return os; |
| 108 | } |
| 109 | |
| 110 | |
| 111 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 112 | CoordinateLsa::CoordinateLsa(const ndn::Name& origR, const string lst, |
| 113 | uint32_t lsn, |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 114 | uint32_t lt |
| 115 | , double r, double theta) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 116 | { |
| 117 | m_origRouter = origR; |
| 118 | m_lsType = lst; |
| 119 | m_lsSeqNo = lsn; |
| 120 | m_lifeTime = lt; |
| 121 | m_corRad = r; |
| 122 | m_corTheta = theta; |
| 123 | } |
| 124 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 125 | const ndn::Name |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 126 | CoordinateLsa::getKey() const |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 127 | { |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 128 | ndn::Name key = m_origRouter; |
| 129 | key.append("coordinate"); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 130 | return key; |
| 131 | } |
| 132 | |
| 133 | bool |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 134 | CoordinateLsa::isEqualContent(const CoordinateLsa& clsa) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 135 | { |
| 136 | return (std::abs(m_corRad - clsa.getCorRadius()) < |
| 137 | std::numeric_limits<double>::epsilon()) && |
| 138 | (std::abs(m_corTheta - clsa.getCorTheta()) < |
| 139 | std::numeric_limits<double>::epsilon()); |
| 140 | } |
| 141 | |
| 142 | string |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 143 | CoordinateLsa::getData() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 144 | { |
| 145 | string corLsaData; |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 146 | corLsaData = m_origRouter.toUri() + "|"; |
| 147 | corLsaData += "coordinate"; |
| 148 | corLsaData += "|"; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 149 | corLsaData += (boost::lexical_cast<std::string>(m_lsSeqNo) + "|"); |
| 150 | corLsaData += (boost::lexical_cast<std::string>(m_lifeTime) + "|"); |
| 151 | corLsaData += (boost::lexical_cast<std::string>(m_corRad) + "|"); |
| 152 | corLsaData += (boost::lexical_cast<std::string>(m_corTheta) + "|"); |
| 153 | return corLsaData; |
| 154 | } |
| 155 | |
| 156 | bool |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 157 | CoordinateLsa::initializeFromContent(const std::string& content) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 158 | { |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 159 | boost::char_separator<char> sep("|"); |
| 160 | boost::tokenizer<boost::char_separator<char> >tokens(content, sep); |
| 161 | boost::tokenizer<boost::char_separator<char> >::iterator tok_iter = |
| 162 | tokens.begin(); |
| 163 | m_origRouter = ndn::Name(*tok_iter++); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame^] | 164 | if (!(m_origRouter.size() > 0)) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 165 | return false; |
| 166 | } |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 167 | try { |
| 168 | m_lsType = *tok_iter++; |
| 169 | m_lsSeqNo = boost::lexical_cast<uint32_t>(*tok_iter++); |
| 170 | m_lifeTime = boost::lexical_cast<uint32_t>(*tok_iter++); |
| 171 | m_corRad = boost::lexical_cast<double>(*tok_iter++); |
| 172 | m_corTheta = boost::lexical_cast<double>(*tok_iter++); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 173 | } |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 174 | catch (std::exception& e) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 175 | return false; |
| 176 | } |
| 177 | return true; |
| 178 | } |
| 179 | |
| 180 | std::ostream& |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 181 | operator<<(std::ostream& os, const CoordinateLsa& cLsa) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 182 | { |
| 183 | os << "Cor Lsa: " << endl; |
| 184 | os << " Origination Router: " << cLsa.getOrigRouter() << endl; |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 185 | os << " Ls Type: " << cLsa.getLsType() << endl; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 186 | os << " Ls Seq No: " << (unsigned int)cLsa.getLsSeqNo() << endl; |
| 187 | os << " Ls Lifetime: " << (unsigned int)cLsa.getLifeTime() << endl; |
| 188 | os << " Hyperbolic Radius: " << cLsa.getCorRadius() << endl; |
| 189 | os << " Hyperbolic Theta: " << cLsa.getCorTheta() << endl; |
| 190 | return os; |
| 191 | } |
| 192 | |
| 193 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 194 | AdjLsa::AdjLsa(const ndn::Name& origR, const string& lst, uint32_t lsn, |
| 195 | uint32_t lt, |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 196 | uint32_t nl , AdjacencyList& adl) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 197 | { |
| 198 | m_origRouter = origR; |
| 199 | m_lsType = lst; |
| 200 | m_lsSeqNo = lsn; |
| 201 | m_lifeTime = lt; |
| 202 | m_noLink = nl; |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 203 | std::list<Adjacent> al = adl.getAdjList(); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame^] | 204 | for (std::list<Adjacent>::iterator it = al.begin(); it != al.end(); it++) { |
| 205 | if ((*it).getStatus() == 1) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 206 | addAdjacent((*it)); |
| 207 | } |
| 208 | } |
| 209 | } |
| 210 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 211 | const ndn::Name |
| 212 | AdjLsa::getKey() const |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 213 | { |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 214 | ndn::Name key = m_origRouter; |
| 215 | key.append("adjacency"); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 216 | return key; |
| 217 | } |
| 218 | |
| 219 | bool |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 220 | AdjLsa::isEqualContent(AdjLsa& alsa) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 221 | { |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 222 | return m_adl == alsa.getAdl(); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | |
| 226 | string |
| 227 | AdjLsa::getData() |
| 228 | { |
| 229 | string adjLsaData; |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 230 | adjLsaData = m_origRouter.toUri() + "|" + "adjacency" + "|" |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 231 | + boost::lexical_cast<std::string>(m_lsSeqNo) + "|" |
| 232 | + boost::lexical_cast<std::string>(m_lifeTime); |
| 233 | adjLsaData += "|"; |
| 234 | adjLsaData += boost::lexical_cast<std::string>(m_adl.getSize()); |
| 235 | std::list<Adjacent> al = m_adl.getAdjList(); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame^] | 236 | for (std::list<Adjacent>::iterator it = al.begin(); it != al.end(); it++) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 237 | adjLsaData += "|"; |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 238 | adjLsaData += (*it).getName().toUri(); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 239 | adjLsaData += "|"; |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame^] | 240 | adjLsaData += (*it).getConnectingFaceUri(); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 241 | adjLsaData += "|"; |
| 242 | adjLsaData += boost::lexical_cast<std::string>((*it).getLinkCost()); |
| 243 | } |
| 244 | return adjLsaData + "|"; |
| 245 | } |
| 246 | |
| 247 | bool |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 248 | AdjLsa::initializeFromContent(const std::string& content) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 249 | { |
| 250 | uint32_t numLink = 0; |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 251 | boost::char_separator<char> sep("|"); |
| 252 | boost::tokenizer<boost::char_separator<char> >tokens(content, sep); |
| 253 | boost::tokenizer<boost::char_separator<char> >::iterator tok_iter = |
| 254 | tokens.begin(); |
| 255 | m_origRouter = ndn::Name(*tok_iter++); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame^] | 256 | if (!(m_origRouter.size() > 0)) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 257 | return false; |
| 258 | } |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 259 | try { |
| 260 | m_lsType = *tok_iter++; |
| 261 | m_lsSeqNo = boost::lexical_cast<uint32_t>(*tok_iter++); |
| 262 | m_lifeTime = boost::lexical_cast<uint32_t>(*tok_iter++); |
| 263 | numLink = boost::lexical_cast<uint32_t>(*tok_iter++); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 264 | } |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 265 | catch (std::exception& e) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 266 | return false; |
| 267 | } |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame^] | 268 | for (uint32_t i = 0; i < numLink; i++) { |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 269 | try { |
| 270 | string adjName(*tok_iter++); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame^] | 271 | std::string connectingFaceUri(*tok_iter++); |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 272 | double linkCost = boost::lexical_cast<double>(*tok_iter++); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame^] | 273 | Adjacent adjacent(adjName, connectingFaceUri, linkCost, 0, 0); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 274 | addAdjacent(adjacent); |
| 275 | } |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 276 | catch (std::exception& e) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 277 | return false; |
| 278 | } |
| 279 | } |
| 280 | return true; |
| 281 | } |
| 282 | |
| 283 | |
| 284 | void |
| 285 | AdjLsa::addNptEntries(Nlsr& pnlsr) |
| 286 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame^] | 287 | if (getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix()) { |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 288 | pnlsr.getNamePrefixTable().addEntry(getOrigRouter(), getOrigRouter()); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 289 | } |
| 290 | } |
| 291 | |
| 292 | |
| 293 | void |
| 294 | AdjLsa::removeNptEntries(Nlsr& pnlsr) |
| 295 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame^] | 296 | if (getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix()) { |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 297 | pnlsr.getNamePrefixTable().removeEntry(getOrigRouter(), getOrigRouter()); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 298 | } |
| 299 | } |
| 300 | |
| 301 | |
| 302 | |
| 303 | std::ostream& |
| 304 | operator<<(std::ostream& os, AdjLsa& aLsa) |
| 305 | { |
| 306 | os << "Adj Lsa: " << endl; |
| 307 | os << " Origination Router: " << aLsa.getOrigRouter() << endl; |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 308 | os << " Ls Type: " << aLsa.getLsType() << endl; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 309 | os << " Ls Seq No: " << (unsigned int)aLsa.getLsSeqNo() << endl; |
| 310 | os << " Ls Lifetime: " << (unsigned int)aLsa.getLifeTime() << endl; |
| 311 | os << " No Link: " << (unsigned int)aLsa.getNoLink() << endl; |
| 312 | os << " Adjacents: " << endl; |
| 313 | int i = 1; |
| 314 | std::list<Adjacent> al = aLsa.getAdl().getAdjList(); |
| 315 | for (std::list<Adjacent>::iterator it = al.begin(); it != al.end(); it++) |
| 316 | { |
| 317 | os << " Adjacent " << i << ": " << endl; |
| 318 | os << " Adjacent Name: " << (*it).getName() << endl; |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame^] | 319 | os << " Connecting FaceUri: " << (*it).getConnectingFaceUri() << endl; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 320 | os << " Link Cost: " << (*it).getLinkCost() << endl; |
| 321 | } |
| 322 | return os; |
| 323 | } |
| 324 | |
| 325 | }//namespace nlsr |