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