blob: f16075fcaf2975fea4931debe52d0086190c242a [file] [log] [blame]
Jiewen Tana0497d82015-02-02 21:59:18 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Nick Gordonc6a85222017-01-03 16:54:34 -06003 * Copyright (c) 2014-2017, 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
22#ifndef NLSR_PUBLISHER_LSDB_DATASET_INTEREST_HANDLER_HPP
23#define NLSR_PUBLISHER_LSDB_DATASET_INTEREST_HANDLER_HPP
24
25#include "lsa-publisher.hpp"
Jiewen Tana0497d82015-02-02 21:59:18 -080026
laqinfand22da512017-05-25 17:29:53 -050027#include <ndn-cxx/mgmt/dispatcher.hpp>
Jiewen Tana0497d82015-02-02 21:59:18 -080028#include <ndn-cxx/face.hpp>
laqinfand22da512017-05-25 17:29:53 -050029#include <boost/noncopyable.hpp>
30#include "tlv/adjacency-lsa.hpp"
31#include "tlv/coordinate-lsa.hpp"
32#include "tlv/name-lsa.hpp"
Jiewen Tana0497d82015-02-02 21:59:18 -080033
34namespace nlsr {
35
Nick G97e34942016-07-11 14:46:27 -050036/*!
37 \brief Class to publish all lsa dataset
laqinfand22da512017-05-25 17:29:53 -050038 \sa https://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
Jiewen Tana0497d82015-02-02 21:59:18 -080039 */
laqinfand22da512017-05-25 17:29:53 -050040class LsdbDatasetInterestHandler : boost::noncopyable
Jiewen Tana0497d82015-02-02 21:59:18 -080041{
42public:
43 class Error : std::runtime_error
44 {
45 public:
46 explicit
47 Error(const std::string& what)
48 : std::runtime_error(what)
49 {
50 }
51 };
52
53 LsdbDatasetInterestHandler(Lsdb& lsdb,
laqinfand22da512017-05-25 17:29:53 -050054 ndn::mgmt::Dispatcher& localHostDispatcher,
55 ndn::mgmt::Dispatcher& routerNameDispatcher,
Jiewen Tana0497d82015-02-02 21:59:18 -080056 ndn::Face& face,
Jiewen Tana0497d82015-02-02 21:59:18 -080057 ndn::KeyChain& keyChain);
58
Vince Lehmand6bb3fa2015-04-24 14:21:39 -050059 const ndn::Name&
60 getLocalhostCommandPrefix()
61 {
62 return LOCALHOST_COMMAND_PREFIX;
63 }
64
Muktadir R Chowdhury3ac07282016-06-17 16:30:29 -050065 ndn::Name&
Vince Lehmand6bb3fa2015-04-24 14:21:39 -050066 getRouterNameCommandPrefix()
67 {
laqinfand22da512017-05-25 17:29:53 -050068 return m_routerNamePrefix;
Muktadir R Chowdhury3ac07282016-06-17 16:30:29 -050069 }
70
71 void
72 setRouterNameCommandPrefix(const ndn::Name& routerName) {
laqinfand22da512017-05-25 17:29:53 -050073 m_routerNamePrefix = routerName;
74 m_routerNamePrefix.append(Lsdb::NAME_COMPONENT);
Vince Lehmand6bb3fa2015-04-24 14:21:39 -050075 }
76
77private:
laqinfand22da512017-05-25 17:29:53 -050078 /*! \brief set dispatcher for localhost/router name.
79 */
Vince Lehmand6bb3fa2015-04-24 14:21:39 -050080 void
laqinfand22da512017-05-25 17:29:53 -050081 setDispatcher(ndn::mgmt::Dispatcher& dispatcher);
Vince Lehmand6bb3fa2015-04-24 14:21:39 -050082
laqinfand22da512017-05-25 17:29:53 -050083 /*! \brief provide adjacent status dataset
84 */
Vince Lehmand6bb3fa2015-04-24 14:21:39 -050085 void
laqinfand22da512017-05-25 17:29:53 -050086 publishAdjStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
87 ndn::mgmt::StatusDatasetContext& context);
Jiewen Tana0497d82015-02-02 21:59:18 -080088
laqinfand22da512017-05-25 17:29:53 -050089 /*! \brief provide coordinate status dataset
90 */
Jiewen Tana0497d82015-02-02 21:59:18 -080091 void
laqinfand22da512017-05-25 17:29:53 -050092 publishCoordinateStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
93 ndn::mgmt::StatusDatasetContext& context);
94
95 /*! \brief provide name status dataset
96 */
97 void
98 publishNameStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
99 ndn::mgmt::StatusDatasetContext& context);
100
101 /*! \brief provide ladb status dataset
102 */
103 void
104 publishAllStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
105 ndn::mgmt::StatusDatasetContext& context);
Jiewen Tana0497d82015-02-02 21:59:18 -0800106
107private:
laqinfand22da512017-05-25 17:29:53 -0500108 static const ndn::Name LOCALHOST_COMMAND_PREFIX;
109 ndn::Name m_routerNamePrefix;
Jiewen Tana0497d82015-02-02 21:59:18 -0800110
laqinfand22da512017-05-25 17:29:53 -0500111 ndn::mgmt::Dispatcher& m_localhostDispatcher;
112 ndn::mgmt::Dispatcher& m_routerNameDispatcher;
Jiewen Tana0497d82015-02-02 21:59:18 -0800113
114 AdjacencyLsaPublisher m_adjacencyLsaPublisher;
115 CoordinateLsaPublisher m_coordinateLsaPublisher;
116 NameLsaPublisher m_nameLsaPublisher;
Vince Lehmand6bb3fa2015-04-24 14:21:39 -0500117
laqinfand22da512017-05-25 17:29:53 -0500118 const std::list<AdjLsa>& m_adjacencyLsas;
119 const std::list<CoordinateLsa>& m_coordinateLsas;
120 const std::list<NameLsa>& m_nameLsas;
Jiewen Tana0497d82015-02-02 21:59:18 -0800121};
122
123} // namespace nlsr
124
125#endif // NLSR_PUBLISHER_LSDB_DATASET_INTEREST_HANDLER_HPP