blob: b2a63ede48ac123c5baa1743c60a7f1903f23c2d [file] [log] [blame]
Alexander Afanasyev2a655f72015-01-26 18:38:33 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Junxiao Shif748a4e2017-07-05 23:41:48 +00002/*
Davide Pesaventoe422f9e2022-06-03 01:30:23 -04003 * Copyright (c) 2014-2022, Regents of the University of California,
Alexander Afanasyev2a655f72015-01-26 18:38:33 -08004 * Arizona Board of Regents,
5 * Colorado State University,
6 * University Pierre & Marie Curie, Sorbonne University,
7 * Washington University in St. Louis,
8 * Beijing Institute of Technology,
9 * The University of Memphis.
10 *
11 * This file is part of NFD (Named Data Networking Forwarding Daemon).
12 * See AUTHORS.md for complete list of NFD authors and contributors.
13 *
14 * NFD is free software: you can redistribute it and/or modify it under the terms
15 * of the GNU General Public License as published by the Free Software Foundation,
16 * either version 3 of the License, or (at your option) any later version.
17 *
18 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 * PURPOSE. See the GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along with
23 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24 */
25
26#ifndef NFD_TOOLS_NDN_AUTOCONFIG_MULTICAST_DISCOVERY_HPP
27#define NFD_TOOLS_NDN_AUTOCONFIG_MULTICAST_DISCOVERY_HPP
28
Junxiao Shif748a4e2017-07-05 23:41:48 +000029#include "stage.hpp"
Junxiao Shicb766862017-07-07 22:21:04 +000030#include <ndn-cxx/face.hpp>
31#include <ndn-cxx/mgmt/nfd/controller.hpp>
32#include <ndn-cxx/mgmt/nfd/face-status.hpp>
Alexander Afanasyev2a655f72015-01-26 18:38:33 -080033
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040034namespace ndn::autoconfig {
Alexander Afanasyev2a655f72015-01-26 18:38:33 -080035
Junxiao Shia5a3a872017-07-08 12:42:11 +000036/** \brief multicast discovery stage
Alexander Afanasyev2a655f72015-01-26 18:38:33 -080037 *
Junxiao Shia5a3a872017-07-08 12:42:11 +000038 * This stage locates an NDN gateway router, commonly known as a "hub", in the local network by
39 * sending a hub discovery Interest ndn:/localhop/ndn-autoconf/hub via multicast. This class
40 * configures routes and strategy on local NFD, so that this Interest is multicast to all
41 * multi-access faces.
Alexander Afanasyev2a655f72015-01-26 18:38:33 -080042 *
Junxiao Shia5a3a872017-07-08 12:42:11 +000043 * If an NDN gateway router is present in the local network, it should reply with a Data
44 * containing its own FaceUri. The Data payload contains a Uri element, and the value of this
45 * element is an ASCII-encoded string of the router's FaceUri. The router may use
46 * ndn-autoconfig-server program to serve this Data.
Alexander Afanasyev2a655f72015-01-26 18:38:33 -080047 *
Junxiao Shia5a3a872017-07-08 12:42:11 +000048 * Signature on this Data is currently not verified. This stage succeeds when the Data is
49 * successfully decoded.
Alexander Afanasyev2a655f72015-01-26 18:38:33 -080050 */
Junxiao Shif748a4e2017-07-05 23:41:48 +000051class MulticastDiscovery : public Stage
Alexander Afanasyev2a655f72015-01-26 18:38:33 -080052{
53public:
Junxiao Shicb766862017-07-07 22:21:04 +000054 MulticastDiscovery(Face& face, nfd::Controller& controller);
Alexander Afanasyev2a655f72015-01-26 18:38:33 -080055
Junxiao Shicb766862017-07-07 22:21:04 +000056 const std::string&
Junxiao Shia5a3a872017-07-08 12:42:11 +000057 getName() const final
Junxiao Shicb766862017-07-07 22:21:04 +000058 {
59 static const std::string STAGE_NAME("multicast discovery");
60 return STAGE_NAME;
61 }
Alexander Afanasyev2a655f72015-01-26 18:38:33 -080062
63private:
64 void
Junxiao Shia5a3a872017-07-08 12:42:11 +000065 doStart() final;
Junxiao Shia8891112016-12-06 21:11:33 +000066
67 void
Junxiao Shicb766862017-07-07 22:21:04 +000068 registerHubDiscoveryPrefix(const std::vector<nfd::FaceStatus>& dataset);
Alexander Afanasyev2a655f72015-01-26 18:38:33 -080069
70 void
Junxiao Shia5a3a872017-07-08 12:42:11 +000071 afterReg();
Alexander Afanasyev2a655f72015-01-26 18:38:33 -080072
73 void
74 setStrategy();
75
76 void
Alexander Afanasyev2a655f72015-01-26 18:38:33 -080077 requestHubData();
78
Alexander Afanasyev2a655f72015-01-26 18:38:33 -080079private:
Junxiao Shicb766862017-07-07 22:21:04 +000080 Face& m_face;
81 nfd::Controller& m_controller;
Junxiao Shia5a3a872017-07-08 12:42:11 +000082
83 int m_nRegs = 0;
84 int m_nRegSuccess = 0;
85 int m_nRegFailure = 0;
Alexander Afanasyev2a655f72015-01-26 18:38:33 -080086};
87
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040088} // namespace ndn::autoconfig
Alexander Afanasyev2a655f72015-01-26 18:38:33 -080089
90#endif // NFD_TOOLS_NDN_AUTOCONFIG_MULTICAST_DISCOVERY_HPP