akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Nick Gordon | c6a8522 | 2017-01-03 16:54:34 -0600 | [diff] [blame] | 3 | * Copyright (c) 2014-2017, The University of Memphis, |
Vince Lehman | c2e51f6 | 2015-01-20 15:03:11 -0600 | [diff] [blame] | 4 | * Regents of the University of California, |
| 5 | * Arizona Board of Regents. |
akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 6 | * |
| 7 | * This file is part of NLSR (Named-data Link State Routing). |
| 8 | * See AUTHORS.md for complete list of NLSR authors and contributors. |
| 9 | * |
| 10 | * NLSR is free software: you can redistribute it and/or modify it under the terms |
| 11 | * of the GNU General Public License as published by the Free Software Foundation, |
| 12 | * either version 3 of the License, or (at your option) any later version. |
| 13 | * |
| 14 | * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 15 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE. See the GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along with |
| 19 | * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 20 | **/ |
Vince Lehman | c2e51f6 | 2015-01-20 15:03:11 -0600 | [diff] [blame] | 21 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 22 | #ifndef NLSR_LSA_HPP |
| 23 | #define NLSR_LSA_HPP |
| 24 | |
Nick Gordon | 22b5c95 | 2017-08-10 17:48:15 -0500 | [diff] [blame] | 25 | #include "name-prefix-list.hpp" |
| 26 | #include "adjacent.hpp" |
| 27 | #include "adjacency-list.hpp" |
| 28 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 29 | #include <boost/cstdint.hpp> |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 30 | #include <ndn-cxx/util/scheduler.hpp> |
akmhoque | c7a79b2 | 2014-05-26 08:06:19 -0500 | [diff] [blame] | 31 | #include <ndn-cxx/util/time.hpp> |
Nick Gordon | 0fa4c77 | 2017-10-23 13:33:03 -0500 | [diff] [blame] | 32 | #include <boost/tokenizer.hpp> |
akmhoque | c7a79b2 | 2014-05-26 08:06:19 -0500 | [diff] [blame] | 33 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 34 | namespace nlsr { |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 35 | |
Vince Lehman | f7eec4f | 2015-05-08 19:02:31 -0500 | [diff] [blame] | 36 | class Nlsr; |
| 37 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 38 | class Lsa |
| 39 | { |
| 40 | public: |
Nick Gordon | 727d483 | 2017-10-13 18:04:25 -0500 | [diff] [blame] | 41 | enum class Type { |
| 42 | ADJACENCY, |
| 43 | COORDINATE, |
| 44 | NAME, |
Nick Gordon | 9212bd4 | 2017-10-23 10:59:38 -0500 | [diff] [blame] | 45 | BASE, |
| 46 | MOCK |
Nick Gordon | 727d483 | 2017-10-13 18:04:25 -0500 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | Lsa() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 50 | : m_origRouter() |
| 51 | , m_lsSeqNo() |
akmhoque | c7a79b2 | 2014-05-26 08:06:19 -0500 | [diff] [blame] | 52 | , m_expirationTimePoint() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 53 | , m_expiringEventId() |
| 54 | { |
| 55 | } |
| 56 | |
Nick Gordon | 727d483 | 2017-10-13 18:04:25 -0500 | [diff] [blame] | 57 | virtual Type |
| 58 | getType() const |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 59 | { |
Nick Gordon | 727d483 | 2017-10-13 18:04:25 -0500 | [diff] [blame] | 60 | return Type::BASE; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | void |
| 64 | setLsSeqNo(uint32_t lsn) |
| 65 | { |
| 66 | m_lsSeqNo = lsn; |
| 67 | } |
| 68 | |
| 69 | uint32_t |
| 70 | getLsSeqNo() const |
| 71 | { |
| 72 | return m_lsSeqNo; |
| 73 | } |
| 74 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 75 | const ndn::Name& |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 76 | getOrigRouter() const |
| 77 | { |
| 78 | return m_origRouter; |
| 79 | } |
| 80 | |
| 81 | void |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 82 | setOrigRouter(const ndn::Name& org) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 83 | { |
| 84 | m_origRouter = org; |
| 85 | } |
| 86 | |
akmhoque | c7a79b2 | 2014-05-26 08:06:19 -0500 | [diff] [blame] | 87 | const ndn::time::system_clock::TimePoint& |
| 88 | getExpirationTimePoint() const |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 89 | { |
akmhoque | c7a79b2 | 2014-05-26 08:06:19 -0500 | [diff] [blame] | 90 | return m_expirationTimePoint; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | void |
akmhoque | c7a79b2 | 2014-05-26 08:06:19 -0500 | [diff] [blame] | 94 | setExpirationTimePoint(const ndn::time::system_clock::TimePoint& lt) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 95 | { |
akmhoque | c7a79b2 | 2014-05-26 08:06:19 -0500 | [diff] [blame] | 96 | m_expirationTimePoint = lt; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | void |
| 100 | setExpiringEventId(const ndn::EventId leei) |
| 101 | { |
| 102 | m_expiringEventId = leei; |
| 103 | } |
| 104 | |
| 105 | ndn::EventId |
| 106 | getExpiringEventId() const |
| 107 | { |
| 108 | return m_expiringEventId; |
| 109 | } |
| 110 | |
Nick Gordon | faf49f4 | 2017-10-23 12:36:28 -0500 | [diff] [blame] | 111 | /*! \brief Return the data that this LSA represents. |
| 112 | */ |
Nick Gordon | 9212bd4 | 2017-10-23 10:59:38 -0500 | [diff] [blame] | 113 | virtual std::string |
Nick Gordon | faf49f4 | 2017-10-23 12:36:28 -0500 | [diff] [blame] | 114 | serialize() const = 0; |
Nick Gordon | 9212bd4 | 2017-10-23 10:59:38 -0500 | [diff] [blame] | 115 | |
Nick Gordon | 22cc1a8 | 2017-10-23 13:06:53 -0500 | [diff] [blame] | 116 | /*! \brief Gets the key for this LSA. |
| 117 | |
| 118 | Format is: \<router name\>/\<LSA type>\ |
| 119 | */ |
| 120 | const ndn::Name |
| 121 | getKey() const; |
| 122 | |
Nick Gordon | 9212bd4 | 2017-10-23 10:59:38 -0500 | [diff] [blame] | 123 | virtual bool |
Nick Gordon | 0fa4c77 | 2017-10-23 13:33:03 -0500 | [diff] [blame] | 124 | deserialize(const std::string& content) = 0; |
Nick Gordon | 9212bd4 | 2017-10-23 10:59:38 -0500 | [diff] [blame] | 125 | |
Nick Gordon | ae0a047 | 2017-10-23 15:51:23 -0500 | [diff] [blame^] | 126 | virtual void |
| 127 | writeLog() const = 0; |
| 128 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 129 | protected: |
Nick Gordon | faf49f4 | 2017-10-23 12:36:28 -0500 | [diff] [blame] | 130 | /*! Get data common to all LSA types. |
| 131 | |
| 132 | This method should be called by all LSA classes in their |
| 133 | serialize() method. |
| 134 | */ |
| 135 | std::string |
| 136 | getData() const; |
| 137 | |
Nick Gordon | ae0a047 | 2017-10-23 15:51:23 -0500 | [diff] [blame^] | 138 | /*! Print data common to all LSA types. |
| 139 | */ |
| 140 | std::string |
| 141 | toString() const; |
| 142 | |
Nick Gordon | 0fa4c77 | 2017-10-23 13:33:03 -0500 | [diff] [blame] | 143 | bool |
| 144 | deserializeCommon(boost::tokenizer<boost::char_separator<char>>::iterator& iterator); |
| 145 | |
Nick Gordon | faf49f4 | 2017-10-23 12:36:28 -0500 | [diff] [blame] | 146 | protected: |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 147 | ndn::Name m_origRouter; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 148 | uint32_t m_lsSeqNo; |
akmhoque | c7a79b2 | 2014-05-26 08:06:19 -0500 | [diff] [blame] | 149 | ndn::time::system_clock::TimePoint m_expirationTimePoint; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 150 | ndn::EventId m_expiringEventId; |
| 151 | }; |
| 152 | |
| 153 | class NameLsa: public Lsa |
| 154 | { |
| 155 | public: |
| 156 | NameLsa() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 157 | { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 158 | } |
| 159 | |
Ashlesh Gawande | d02c388 | 2015-12-29 16:02:51 -0600 | [diff] [blame] | 160 | NameLsa(const ndn::Name& origR, uint32_t lsn, |
akmhoque | c7a79b2 | 2014-05-26 08:06:19 -0500 | [diff] [blame] | 161 | const ndn::time::system_clock::TimePoint& lt, |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 162 | NamePrefixList& npl); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 163 | |
Nick Gordon | 727d483 | 2017-10-13 18:04:25 -0500 | [diff] [blame] | 164 | Lsa::Type |
| 165 | getType() const override |
| 166 | { |
| 167 | return Lsa::Type::NAME; |
| 168 | } |
| 169 | |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 170 | NamePrefixList& |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 171 | getNpl() |
| 172 | { |
| 173 | return m_npl; |
| 174 | } |
| 175 | |
Nick Gordon | 56d1fae | 2017-05-26 16:39:25 -0500 | [diff] [blame] | 176 | const NamePrefixList& |
| 177 | getNpl() const |
| 178 | { |
| 179 | return m_npl; |
| 180 | } |
| 181 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 182 | void |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 183 | addName(const ndn::Name& name) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 184 | { |
| 185 | m_npl.insert(name); |
| 186 | } |
| 187 | |
| 188 | void |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 189 | removeName(const ndn::Name& name) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 190 | { |
| 191 | m_npl.remove(name); |
| 192 | } |
| 193 | |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 194 | /*! \brief Initializes this LSA object with content's data. |
| 195 | |
| 196 | \param content The data (e.g. name prefixes) to initialize this LSA with. |
| 197 | |
| 198 | This function initializes this object to represent the data |
| 199 | contained in content. The format for this is the same as for |
| 200 | getData(); getData() returns data of this format, in other words. |
| 201 | */ |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 202 | bool |
Nick Gordon | 0fa4c77 | 2017-10-23 13:33:03 -0500 | [diff] [blame] | 203 | deserialize(const std::string& content) override; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 204 | |
Nick Gordon | 56d1fae | 2017-05-26 16:39:25 -0500 | [diff] [blame] | 205 | bool |
| 206 | isEqualContent(const NameLsa& other) const; |
| 207 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 208 | void |
Nick Gordon | ae0a047 | 2017-10-23 15:51:23 -0500 | [diff] [blame^] | 209 | writeLog() const override; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 210 | |
Nick Gordon | faf49f4 | 2017-10-23 12:36:28 -0500 | [diff] [blame] | 211 | /*! \brief Returns the data that this name LSA has. |
| 212 | |
| 213 | Format is: \<original router |
| 214 | prefix\>|name|\<seq. no.\>|\<exp. time\>|\<prefix 1\>|\<prefix |
| 215 | 2\>|...|\<prefix n\>| |
| 216 | */ |
| 217 | std::string |
| 218 | serialize() const override; |
| 219 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 220 | private: |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 221 | NamePrefixList m_npl; |
Nick Gordon | ae0a047 | 2017-10-23 15:51:23 -0500 | [diff] [blame^] | 222 | |
| 223 | friend std::ostream& |
| 224 | operator<<(std::ostream& os, const NameLsa& lsa); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 225 | }; |
| 226 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 227 | class AdjLsa: public Lsa |
| 228 | { |
| 229 | public: |
alvy | dce3f18 | 2015-04-09 11:23:30 -0500 | [diff] [blame] | 230 | typedef AdjacencyList::const_iterator const_iterator; |
| 231 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 232 | AdjLsa() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 233 | { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 234 | } |
| 235 | |
Ashlesh Gawande | d02c388 | 2015-12-29 16:02:51 -0600 | [diff] [blame] | 236 | AdjLsa(const ndn::Name& origR, uint32_t lsn, |
akmhoque | c7a79b2 | 2014-05-26 08:06:19 -0500 | [diff] [blame] | 237 | const ndn::time::system_clock::TimePoint& lt, |
| 238 | uint32_t nl , AdjacencyList& adl); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 239 | |
Nick Gordon | 727d483 | 2017-10-13 18:04:25 -0500 | [diff] [blame] | 240 | Lsa::Type |
| 241 | getType() const override |
| 242 | { |
| 243 | return Lsa::Type::ADJACENCY; |
| 244 | } |
| 245 | |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 246 | AdjacencyList& |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 247 | getAdl() |
| 248 | { |
| 249 | return m_adl; |
| 250 | } |
| 251 | |
Nick Gordon | 22b5c95 | 2017-08-10 17:48:15 -0500 | [diff] [blame] | 252 | const AdjacencyList& |
| 253 | getAdl() const |
| 254 | { |
| 255 | return m_adl; |
| 256 | } |
| 257 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 258 | void |
| 259 | addAdjacent(Adjacent adj) |
| 260 | { |
| 261 | m_adl.insert(adj); |
| 262 | } |
| 263 | |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 264 | /*! \brief Initializes this adj. LSA from the supplied content. |
| 265 | |
| 266 | \param content The content that this LSA is to have, formatted |
| 267 | according to getData(). |
| 268 | */ |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 269 | bool |
Nick Gordon | 0fa4c77 | 2017-10-23 13:33:03 -0500 | [diff] [blame] | 270 | deserialize(const std::string& content) override; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 271 | |
| 272 | uint32_t |
| 273 | getNoLink() |
| 274 | { |
| 275 | return m_noLink; |
| 276 | } |
| 277 | |
| 278 | bool |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 279 | isEqualContent(AdjLsa& alsa); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 280 | |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 281 | /*! \brief Installs this LSA's name prefixes into the NPT. |
| 282 | |
| 283 | \param pnlsr The NLSR top-level whose NPT you want to install the |
| 284 | entries into. |
| 285 | */ |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 286 | void |
| 287 | addNptEntries(Nlsr& pnlsr); |
| 288 | |
| 289 | void |
| 290 | removeNptEntries(Nlsr& pnlsr); |
| 291 | |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 292 | void |
Nick Gordon | ae0a047 | 2017-10-23 15:51:23 -0500 | [diff] [blame^] | 293 | writeLog() const override; |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 294 | |
alvy | dce3f18 | 2015-04-09 11:23:30 -0500 | [diff] [blame] | 295 | const_iterator |
| 296 | begin() const |
| 297 | { |
| 298 | return m_adl.begin(); |
| 299 | } |
| 300 | |
| 301 | const_iterator |
| 302 | end() const |
| 303 | { |
| 304 | return m_adl.end(); |
| 305 | } |
| 306 | |
Nick Gordon | faf49f4 | 2017-10-23 12:36:28 -0500 | [diff] [blame] | 307 | /*! \brief Returns the data this adjacency LSA has. |
| 308 | |
| 309 | The format is: \<original |
| 310 | router\>|adjacency|\<seq. no.\>|\<exp. time\>|\<size\>|\<adjacency prefix |
| 311 | 1\>|\<face uri 1\>|\<cost 1\>|...|\<adjacency prefix n\>|\<face uri |
| 312 | n\>|\<cost n\>| |
| 313 | */ |
| 314 | std::string |
| 315 | serialize() const override; |
| 316 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 317 | private: |
| 318 | uint32_t m_noLink; |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 319 | AdjacencyList m_adl; |
Nick Gordon | ae0a047 | 2017-10-23 15:51:23 -0500 | [diff] [blame^] | 320 | |
| 321 | friend std::ostream& |
| 322 | operator<<(std::ostream& os, const AdjLsa& lsa); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 323 | }; |
| 324 | |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 325 | class CoordinateLsa: public Lsa |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 326 | { |
| 327 | public: |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 328 | CoordinateLsa() |
Nick Gordon | 727d483 | 2017-10-13 18:04:25 -0500 | [diff] [blame] | 329 | : m_corRad(0) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 330 | { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 331 | } |
| 332 | |
Ashlesh Gawande | d02c388 | 2015-12-29 16:02:51 -0600 | [diff] [blame] | 333 | CoordinateLsa(const ndn::Name& origR, uint32_t lsn, |
akmhoque | c7a79b2 | 2014-05-26 08:06:19 -0500 | [diff] [blame] | 334 | const ndn::time::system_clock::TimePoint& lt, |
Muktadir R Chowdhury | b00dc2a | 2016-11-05 10:48:58 -0600 | [diff] [blame] | 335 | double r, std::vector<double> theta); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 336 | |
Nick Gordon | 727d483 | 2017-10-13 18:04:25 -0500 | [diff] [blame] | 337 | Lsa::Type |
| 338 | getType() const override |
| 339 | { |
| 340 | return Lsa::Type::COORDINATE; |
| 341 | } |
| 342 | |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 343 | /*! \brief Initializes this coordinate LSA with the data in content. |
| 344 | |
| 345 | \param content The string content that is used to build the LSA. |
| 346 | |
| 347 | This function initializes this LSA object to represent the data |
| 348 | specified by the parameter. The format that it is expecting is the |
| 349 | same as for getData(); |
| 350 | */ |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 351 | bool |
Nick Gordon | 0fa4c77 | 2017-10-23 13:33:03 -0500 | [diff] [blame] | 352 | deserialize(const std::string& content) override; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 353 | |
| 354 | double |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 355 | getCorRadius() const |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 356 | { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 357 | return m_corRad; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | void |
| 361 | setCorRadius(double cr) |
| 362 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 363 | m_corRad = cr; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 364 | } |
| 365 | |
Muktadir R Chowdhury | b00dc2a | 2016-11-05 10:48:58 -0600 | [diff] [blame] | 366 | const std::vector<double> |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 367 | getCorTheta() const |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 368 | { |
Muktadir R Chowdhury | b00dc2a | 2016-11-05 10:48:58 -0600 | [diff] [blame] | 369 | return m_angles; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | void |
Muktadir R Chowdhury | b00dc2a | 2016-11-05 10:48:58 -0600 | [diff] [blame] | 373 | setCorTheta(std::vector<double> ct) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 374 | { |
Muktadir R Chowdhury | b00dc2a | 2016-11-05 10:48:58 -0600 | [diff] [blame] | 375 | m_angles = ct; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | bool |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 379 | isEqualContent(const CoordinateLsa& clsa); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 380 | |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 381 | void |
Nick Gordon | ae0a047 | 2017-10-23 15:51:23 -0500 | [diff] [blame^] | 382 | writeLog() const override; |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 383 | |
Nick Gordon | faf49f4 | 2017-10-23 12:36:28 -0500 | [diff] [blame] | 384 | /*! \brief Returns the data that this coordinate LSA represents. |
| 385 | |
| 386 | The format is: \<original |
| 387 | router\>|coordinate|\<seq. no.\>|\<exp. time\>|\<radians\>|\<theta\>| |
| 388 | */ |
| 389 | std::string |
| 390 | serialize() const override; |
| 391 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 392 | private: |
| 393 | double m_corRad; |
Muktadir R Chowdhury | b00dc2a | 2016-11-05 10:48:58 -0600 | [diff] [blame] | 394 | std::vector<double> m_angles; |
Nick Gordon | ae0a047 | 2017-10-23 15:51:23 -0500 | [diff] [blame^] | 395 | |
| 396 | friend std::ostream& |
| 397 | operator<<(std::ostream& os, const CoordinateLsa& lsa); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 398 | }; |
| 399 | |
alvy | dce3f18 | 2015-04-09 11:23:30 -0500 | [diff] [blame] | 400 | std::ostream& |
Nick Gordon | ae0a047 | 2017-10-23 15:51:23 -0500 | [diff] [blame^] | 401 | operator<<(std::ostream& os, const AdjLsa& lsa); |
| 402 | |
| 403 | std::ostream& |
| 404 | operator<<(std::ostream& os, const CoordinateLsa& lsa); |
| 405 | |
| 406 | std::ostream& |
| 407 | operator<<(std::ostream& os, const NameLsa& lsa); |
alvy | dce3f18 | 2015-04-09 11:23:30 -0500 | [diff] [blame] | 408 | |
Nick Gordon | 727d483 | 2017-10-13 18:04:25 -0500 | [diff] [blame] | 409 | std::ostream& |
| 410 | operator<<(std::ostream& os, const Lsa::Type& type); |
| 411 | |
| 412 | std::istream& |
| 413 | operator>>(std::istream& is, Lsa::Type& type); |
| 414 | |
Nick Gordon | fad8e25 | 2016-08-11 14:21:38 -0500 | [diff] [blame] | 415 | } // namespace nlsr |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 416 | |
Nick Gordon | 727d483 | 2017-10-13 18:04:25 -0500 | [diff] [blame] | 417 | namespace std { |
| 418 | std::string |
| 419 | to_string(const nlsr::Lsa::Type& type); |
| 420 | } // namespace std |
| 421 | |
Nick Gordon | 56d1fae | 2017-05-26 16:39:25 -0500 | [diff] [blame] | 422 | #endif // NLSR_LSA_HPP |