blob: d6bf0903226acfaf8f1b49f4c05a5a71615ff5d6 [file] [log] [blame]
Jiewen Tana0497d82015-02-02 21:59:18 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Ashlesh Gawande0421bc62020-05-08 20:42:19 -07002/*
Davide Pesaventoc1d0e8e2022-06-15 14:26:02 -04003 * Copyright (c) 2014-2022, 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/>.
Ashlesh Gawande0421bc62020-05-08 20:42:19 -070020 */
Jiewen Tana0497d82015-02-02 21:59:18 -080021
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"
Jiewen Tana0497d82015-02-02 21:59:18 -080038
Jiewen Tana0497d82015-02-02 21:59:18 -080039#include <ndn-cxx/face.hpp>
Davide Pesaventoc1d0e8e2022-06-15 14:26:02 -040040#include <ndn-cxx/mgmt/dispatcher.hpp>
laqinfand22da512017-05-25 17:29:53 -050041#include <boost/noncopyable.hpp>
Jiewen Tana0497d82015-02-02 21:59:18 -080042
43namespace nlsr {
Davide Pesaventoc1d0e8e2022-06-15 14:26:02 -040044
Nick Gordon114537f2017-08-09 14:51:37 -050045namespace dataset {
Davide Pesaventoc1d0e8e2022-06-15 14:26:02 -040046inline const ndn::Name::Component ADJACENCY_COMPONENT{"adjacencies"};
47inline const ndn::Name::Component NAME_COMPONENT{"names"};
48inline const ndn::Name::Component COORDINATE_COMPONENT{"coordinates"};
Nick Gordon114537f2017-08-09 14:51:37 -050049} // namespace dataset
50
Nick G97e34942016-07-11 14:46:27 -050051/*!
laqinfan35731852017-08-08 06:17:39 -050052 \brief Class to publish all dataset
laqinfand22da512017-05-25 17:29:53 -050053 \sa https://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
laqinfan35731852017-08-08 06:17:39 -050054 \sa https://redmine.named-data.net/projects/nlsr/wiki/Routing_Table_DataSet
Jiewen Tana0497d82015-02-02 21:59:18 -080055 */
laqinfan35731852017-08-08 06:17:39 -050056class DatasetInterestHandler : boost::noncopyable
Jiewen Tana0497d82015-02-02 21:59:18 -080057{
58public:
59 class Error : std::runtime_error
60 {
61 public:
Davide Pesaventoc1d0e8e2022-06-15 14:26:02 -040062 using std::runtime_error::runtime_error;
Jiewen Tana0497d82015-02-02 21:59:18 -080063 };
64
Ashlesh Gawande85998a12017-12-07 22:22:13 -060065 DatasetInterestHandler(ndn::mgmt::Dispatcher& dispatcher,
66 const Lsdb& lsdb,
67 const RoutingTable& rt);
Vince Lehmand6bb3fa2015-04-24 14:21:39 -050068
69private:
laqinfan35731852017-08-08 06:17:39 -050070 /*! \brief provide routing-table dataset
71 */
72 void
73 publishRtStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
74 ndn::mgmt::StatusDatasetContext& context);
75
Ashlesh Gawande57a87172020-05-09 19:47:06 -070076 /*! \brief provide LSA status dataset
laqinfand22da512017-05-25 17:29:53 -050077 */
Davide Pesaventoc1d0e8e2022-06-15 14:26:02 -040078 template<typename T>
Vince Lehmand6bb3fa2015-04-24 14:21:39 -050079 void
Ashlesh Gawande57a87172020-05-09 19:47:06 -070080 publishLsaStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
laqinfand22da512017-05-25 17:29:53 -050081 ndn::mgmt::StatusDatasetContext& context);
Jiewen Tana0497d82015-02-02 21:59:18 -080082
Jiewen Tana0497d82015-02-02 21:59:18 -080083private:
Ashlesh Gawande85998a12017-12-07 22:22:13 -060084 const Lsdb& m_lsdb;
Ashlesh Gawande0421bc62020-05-08 20:42:19 -070085 const RoutingTable& m_routingTable;
Jiewen Tana0497d82015-02-02 21:59:18 -080086};
87
Jiewen Tana0497d82015-02-02 21:59:18 -080088} // namespace nlsr
89
laqinfan35731852017-08-08 06:17:39 -050090#endif // NLSR_PUBLISHER_DATASET_INTEREST_HANDLER_HPP