Jiewen Tan | a0497d8 | 2015-02-02 21:59:18 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Ashlesh Gawande | 0421bc6 | 2020-05-08 20:42:19 -0700 | [diff] [blame^] | 2 | /* |
Ashlesh Gawande | 0db4d4d | 2020-02-05 20:30:02 -0800 | [diff] [blame] | 3 | * Copyright (c) 2014-2020, The University of Memphis, |
Jiewen Tan | a0497d8 | 2015-02-02 21:59:18 -0800 | [diff] [blame] | 4 | * Regents of the University of California, |
| 5 | * Arizona Board of Regents. |
| 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/>. |
Ashlesh Gawande | 0421bc6 | 2020-05-08 20:42:19 -0700 | [diff] [blame^] | 20 | */ |
Jiewen Tan | a0497d8 | 2015-02-02 21:59:18 -0800 | [diff] [blame] | 21 | |
laqinfan | 3573185 | 2017-08-08 06:17:39 -0500 | [diff] [blame] | 22 | /*! \file dataset-interest-handler.hpp |
| 23 | |
| 24 | This file details a class that is used by NLSRC and other command-line |
| 25 | tools to examine the state of NLSR. This class doesn't only handle interest |
| 26 | from local host, but also handle interests from remote router. |
| 27 | This system is not designed to |
| 28 | be used by routers to publish data to each other. |
| 29 | */ |
| 30 | |
| 31 | #ifndef NLSR_PUBLISHER_DATASET_INTEREST_HANDLER_HPP |
| 32 | #define NLSR_PUBLISHER_DATASET_INTEREST_HANDLER_HPP |
| 33 | |
| 34 | #include "route/routing-table-entry.hpp" |
| 35 | #include "route/routing-table.hpp" |
| 36 | #include "route/nexthop-list.hpp" |
| 37 | #include "lsdb.hpp" |
| 38 | #include "logger.hpp" |
Jiewen Tan | a0497d8 | 2015-02-02 21:59:18 -0800 | [diff] [blame] | 39 | |
laqinfan | d22da51 | 2017-05-25 17:29:53 -0500 | [diff] [blame] | 40 | #include <ndn-cxx/mgmt/dispatcher.hpp> |
Jiewen Tan | a0497d8 | 2015-02-02 21:59:18 -0800 | [diff] [blame] | 41 | #include <ndn-cxx/face.hpp> |
laqinfan | d22da51 | 2017-05-25 17:29:53 -0500 | [diff] [blame] | 42 | #include <boost/noncopyable.hpp> |
Jiewen Tan | a0497d8 | 2015-02-02 21:59:18 -0800 | [diff] [blame] | 43 | |
| 44 | namespace nlsr { |
Nick Gordon | 114537f | 2017-08-09 14:51:37 -0500 | [diff] [blame] | 45 | namespace dataset { |
laqinfan | 3573185 | 2017-08-08 06:17:39 -0500 | [diff] [blame] | 46 | const ndn::Name::Component ADJACENCY_COMPONENT = ndn::Name::Component{"adjacencies"}; |
| 47 | const ndn::Name::Component NAME_COMPONENT = ndn::Name::Component{"names"}; |
| 48 | const ndn::Name::Component COORDINATE_COMPONENT = ndn::Name::Component{"coordinates"}; |
Nick Gordon | 114537f | 2017-08-09 14:51:37 -0500 | [diff] [blame] | 49 | } // namespace dataset |
| 50 | |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 51 | /*! |
laqinfan | 3573185 | 2017-08-08 06:17:39 -0500 | [diff] [blame] | 52 | \brief Class to publish all dataset |
laqinfan | d22da51 | 2017-05-25 17:29:53 -0500 | [diff] [blame] | 53 | \sa https://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet |
laqinfan | 3573185 | 2017-08-08 06:17:39 -0500 | [diff] [blame] | 54 | \sa https://redmine.named-data.net/projects/nlsr/wiki/Routing_Table_DataSet |
Jiewen Tan | a0497d8 | 2015-02-02 21:59:18 -0800 | [diff] [blame] | 55 | */ |
laqinfan | 3573185 | 2017-08-08 06:17:39 -0500 | [diff] [blame] | 56 | class DatasetInterestHandler : boost::noncopyable |
Jiewen Tan | a0497d8 | 2015-02-02 21:59:18 -0800 | [diff] [blame] | 57 | { |
| 58 | public: |
| 59 | class Error : std::runtime_error |
| 60 | { |
| 61 | public: |
| 62 | explicit |
| 63 | Error(const std::string& what) |
| 64 | : std::runtime_error(what) |
| 65 | { |
| 66 | } |
| 67 | }; |
| 68 | |
Ashlesh Gawande | 85998a1 | 2017-12-07 22:22:13 -0600 | [diff] [blame] | 69 | DatasetInterestHandler(ndn::mgmt::Dispatcher& dispatcher, |
| 70 | const Lsdb& lsdb, |
| 71 | const RoutingTable& rt); |
Vince Lehman | d6bb3fa | 2015-04-24 14:21:39 -0500 | [diff] [blame] | 72 | |
| 73 | private: |
laqinfan | 3573185 | 2017-08-08 06:17:39 -0500 | [diff] [blame] | 74 | /*! \brief set dispatcher for localhost or remote router |
laqinfan | d22da51 | 2017-05-25 17:29:53 -0500 | [diff] [blame] | 75 | */ |
Vince Lehman | d6bb3fa | 2015-04-24 14:21:39 -0500 | [diff] [blame] | 76 | void |
laqinfan | d22da51 | 2017-05-25 17:29:53 -0500 | [diff] [blame] | 77 | setDispatcher(ndn::mgmt::Dispatcher& dispatcher); |
Vince Lehman | d6bb3fa | 2015-04-24 14:21:39 -0500 | [diff] [blame] | 78 | |
laqinfan | 3573185 | 2017-08-08 06:17:39 -0500 | [diff] [blame] | 79 | /*! \brief provide routing-table dataset |
| 80 | */ |
| 81 | void |
| 82 | publishRtStatus(const ndn::Name& topPrefix, const ndn::Interest& interest, |
| 83 | ndn::mgmt::StatusDatasetContext& context); |
| 84 | |
laqinfan | d22da51 | 2017-05-25 17:29:53 -0500 | [diff] [blame] | 85 | /*! \brief provide adjacent status dataset |
| 86 | */ |
Vince Lehman | d6bb3fa | 2015-04-24 14:21:39 -0500 | [diff] [blame] | 87 | void |
laqinfan | d22da51 | 2017-05-25 17:29:53 -0500 | [diff] [blame] | 88 | publishAdjStatus(const ndn::Name& topPrefix, const ndn::Interest& interest, |
| 89 | ndn::mgmt::StatusDatasetContext& context); |
Jiewen Tan | a0497d8 | 2015-02-02 21:59:18 -0800 | [diff] [blame] | 90 | |
laqinfan | d22da51 | 2017-05-25 17:29:53 -0500 | [diff] [blame] | 91 | /*! \brief provide coordinate status dataset |
| 92 | */ |
Jiewen Tan | a0497d8 | 2015-02-02 21:59:18 -0800 | [diff] [blame] | 93 | void |
laqinfan | d22da51 | 2017-05-25 17:29:53 -0500 | [diff] [blame] | 94 | publishCoordinateStatus(const ndn::Name& topPrefix, const ndn::Interest& interest, |
| 95 | ndn::mgmt::StatusDatasetContext& context); |
| 96 | |
| 97 | /*! \brief provide name status dataset |
| 98 | */ |
| 99 | void |
| 100 | publishNameStatus(const ndn::Name& topPrefix, const ndn::Interest& interest, |
| 101 | ndn::mgmt::StatusDatasetContext& context); |
| 102 | |
Jiewen Tan | a0497d8 | 2015-02-02 21:59:18 -0800 | [diff] [blame] | 103 | private: |
laqinfan | 3573185 | 2017-08-08 06:17:39 -0500 | [diff] [blame] | 104 | ndn::mgmt::Dispatcher& m_dispatcher; |
Ashlesh Gawande | 85998a1 | 2017-12-07 22:22:13 -0600 | [diff] [blame] | 105 | const Lsdb& m_lsdb; |
Ashlesh Gawande | 0421bc6 | 2020-05-08 20:42:19 -0700 | [diff] [blame^] | 106 | const RoutingTable& m_routingTable; |
Jiewen Tan | a0497d8 | 2015-02-02 21:59:18 -0800 | [diff] [blame] | 107 | }; |
| 108 | |
Jiewen Tan | a0497d8 | 2015-02-02 21:59:18 -0800 | [diff] [blame] | 109 | } // namespace nlsr |
| 110 | |
laqinfan | 3573185 | 2017-08-08 06:17:39 -0500 | [diff] [blame] | 111 | #endif // NLSR_PUBLISHER_DATASET_INTEREST_HANDLER_HPP |