blob: 28a6c4cef8832703f7d0ed902eb1185aed27e21d [file] [log] [blame]
Jiewen Tana0497d82015-02-02 21:59:18 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Ashlesh Gawande0db4d4d2020-02-05 20:30:02 -08003 * Copyright (c) 2014-2020, The University of Memphis,
Jiewen Tana0497d82015-02-02 21:59:18 -08004 * 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/>.
20 **/
21
laqinfan35731852017-08-08 06:17:39 -050022 /*! \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 Tana0497d82015-02-02 21:59:18 -080039
laqinfan35731852017-08-08 06:17:39 -050040#include "tlv/routing-table-status.hpp"
41#include "tlv/routing-table-entry.hpp"
Jiewen Tana0497d82015-02-02 21:59:18 -080042
laqinfand22da512017-05-25 17:29:53 -050043#include <ndn-cxx/mgmt/dispatcher.hpp>
Jiewen Tana0497d82015-02-02 21:59:18 -080044#include <ndn-cxx/face.hpp>
laqinfand22da512017-05-25 17:29:53 -050045#include <boost/noncopyable.hpp>
Jiewen Tana0497d82015-02-02 21:59:18 -080046
47namespace nlsr {
Nick Gordon114537f2017-08-09 14:51:37 -050048namespace dataset {
laqinfan35731852017-08-08 06:17:39 -050049const ndn::Name::Component ADJACENCY_COMPONENT = ndn::Name::Component{"adjacencies"};
50const ndn::Name::Component NAME_COMPONENT = ndn::Name::Component{"names"};
51const ndn::Name::Component COORDINATE_COMPONENT = ndn::Name::Component{"coordinates"};
Nick Gordon114537f2017-08-09 14:51:37 -050052} // namespace dataset
53
Nick G97e34942016-07-11 14:46:27 -050054/*!
laqinfan35731852017-08-08 06:17:39 -050055 \brief Class to publish all dataset
laqinfand22da512017-05-25 17:29:53 -050056 \sa https://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
laqinfan35731852017-08-08 06:17:39 -050057 \sa https://redmine.named-data.net/projects/nlsr/wiki/Routing_Table_DataSet
Jiewen Tana0497d82015-02-02 21:59:18 -080058 */
laqinfan35731852017-08-08 06:17:39 -050059class DatasetInterestHandler : boost::noncopyable
Jiewen Tana0497d82015-02-02 21:59:18 -080060{
61public:
62 class Error : std::runtime_error
63 {
64 public:
65 explicit
66 Error(const std::string& what)
67 : std::runtime_error(what)
68 {
69 }
70 };
71
Ashlesh Gawande85998a12017-12-07 22:22:13 -060072 DatasetInterestHandler(ndn::mgmt::Dispatcher& dispatcher,
73 const Lsdb& lsdb,
74 const RoutingTable& rt);
Vince Lehmand6bb3fa2015-04-24 14:21:39 -050075
76private:
laqinfan35731852017-08-08 06:17:39 -050077 /*! \brief set dispatcher for localhost or remote router
laqinfand22da512017-05-25 17:29:53 -050078 */
Vince Lehmand6bb3fa2015-04-24 14:21:39 -050079 void
laqinfand22da512017-05-25 17:29:53 -050080 setDispatcher(ndn::mgmt::Dispatcher& dispatcher);
Vince Lehmand6bb3fa2015-04-24 14:21:39 -050081
laqinfana073e2e2018-01-15 21:17:24 +000082 /*! \brief generate a TLV-format of routing table entry
83 */
84 std::vector<tlv::RoutingTable>
85 getTlvRTEntries();
86
laqinfan35731852017-08-08 06:17:39 -050087 /*! \brief provide routing-table dataset
88 */
89 void
90 publishRtStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
91 ndn::mgmt::StatusDatasetContext& context);
92
laqinfand22da512017-05-25 17:29:53 -050093 /*! \brief provide adjacent status dataset
94 */
Vince Lehmand6bb3fa2015-04-24 14:21:39 -050095 void
laqinfand22da512017-05-25 17:29:53 -050096 publishAdjStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
97 ndn::mgmt::StatusDatasetContext& context);
Jiewen Tana0497d82015-02-02 21:59:18 -080098
laqinfand22da512017-05-25 17:29:53 -050099 /*! \brief provide coordinate status dataset
100 */
Jiewen Tana0497d82015-02-02 21:59:18 -0800101 void
laqinfand22da512017-05-25 17:29:53 -0500102 publishCoordinateStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
103 ndn::mgmt::StatusDatasetContext& context);
104
105 /*! \brief provide name status dataset
106 */
107 void
108 publishNameStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
109 ndn::mgmt::StatusDatasetContext& context);
110
Jiewen Tana0497d82015-02-02 21:59:18 -0800111private:
laqinfan35731852017-08-08 06:17:39 -0500112 ndn::mgmt::Dispatcher& m_dispatcher;
Ashlesh Gawande85998a12017-12-07 22:22:13 -0600113 const Lsdb& m_lsdb;
laqinfan35731852017-08-08 06:17:39 -0500114
115 const std::list<RoutingTableEntry>& m_routingTableEntries;
116 const std::list<RoutingTableEntry>& m_dryRoutingTableEntries;
Jiewen Tana0497d82015-02-02 21:59:18 -0800117};
118
Jiewen Tana0497d82015-02-02 21:59:18 -0800119} // namespace nlsr
120
laqinfan35731852017-08-08 06:17:39 -0500121#endif // NLSR_PUBLISHER_DATASET_INTEREST_HANDLER_HPP