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