Alexander Afanasyev | 2a655f7 | 2015-01-26 18:38:33 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Junxiao Shi | f748a4e | 2017-07-05 23:41:48 +0000 | [diff] [blame] | 2 | /* |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 3 | * Copyright (c) 2014-2022, Regents of the University of California, |
Alexander Afanasyev | 2a655f7 | 2015-01-26 18:38:33 -0800 | [diff] [blame] | 4 | * 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 Shi | f748a4e | 2017-07-05 23:41:48 +0000 | [diff] [blame] | 29 | #include "stage.hpp" |
Junxiao Shi | cb76686 | 2017-07-07 22:21:04 +0000 | [diff] [blame] | 30 | #include <ndn-cxx/face.hpp> |
| 31 | #include <ndn-cxx/mgmt/nfd/controller.hpp> |
| 32 | #include <ndn-cxx/mgmt/nfd/face-status.hpp> |
Alexander Afanasyev | 2a655f7 | 2015-01-26 18:38:33 -0800 | [diff] [blame] | 33 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 34 | namespace ndn::autoconfig { |
Alexander Afanasyev | 2a655f7 | 2015-01-26 18:38:33 -0800 | [diff] [blame] | 35 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 36 | /** \brief Multicast discovery stage. |
Alexander Afanasyev | 2a655f7 | 2015-01-26 18:38:33 -0800 | [diff] [blame] | 37 | * |
Junxiao Shi | a5a3a87 | 2017-07-08 12:42:11 +0000 | [diff] [blame] | 38 | * 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 Afanasyev | 2a655f7 | 2015-01-26 18:38:33 -0800 | [diff] [blame] | 42 | * |
Junxiao Shi | a5a3a87 | 2017-07-08 12:42:11 +0000 | [diff] [blame] | 43 | * 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 Afanasyev | 2a655f7 | 2015-01-26 18:38:33 -0800 | [diff] [blame] | 47 | * |
Junxiao Shi | a5a3a87 | 2017-07-08 12:42:11 +0000 | [diff] [blame] | 48 | * Signature on this Data is currently not verified. This stage succeeds when the Data is |
| 49 | * successfully decoded. |
Alexander Afanasyev | 2a655f7 | 2015-01-26 18:38:33 -0800 | [diff] [blame] | 50 | */ |
Junxiao Shi | f748a4e | 2017-07-05 23:41:48 +0000 | [diff] [blame] | 51 | class MulticastDiscovery : public Stage |
Alexander Afanasyev | 2a655f7 | 2015-01-26 18:38:33 -0800 | [diff] [blame] | 52 | { |
| 53 | public: |
Junxiao Shi | cb76686 | 2017-07-07 22:21:04 +0000 | [diff] [blame] | 54 | MulticastDiscovery(Face& face, nfd::Controller& controller); |
Alexander Afanasyev | 2a655f7 | 2015-01-26 18:38:33 -0800 | [diff] [blame] | 55 | |
Junxiao Shi | cb76686 | 2017-07-07 22:21:04 +0000 | [diff] [blame] | 56 | const std::string& |
Junxiao Shi | a5a3a87 | 2017-07-08 12:42:11 +0000 | [diff] [blame] | 57 | getName() const final |
Junxiao Shi | cb76686 | 2017-07-07 22:21:04 +0000 | [diff] [blame] | 58 | { |
| 59 | static const std::string STAGE_NAME("multicast discovery"); |
| 60 | return STAGE_NAME; |
| 61 | } |
Alexander Afanasyev | 2a655f7 | 2015-01-26 18:38:33 -0800 | [diff] [blame] | 62 | |
| 63 | private: |
| 64 | void |
Junxiao Shi | a5a3a87 | 2017-07-08 12:42:11 +0000 | [diff] [blame] | 65 | doStart() final; |
Junxiao Shi | a889111 | 2016-12-06 21:11:33 +0000 | [diff] [blame] | 66 | |
| 67 | void |
Junxiao Shi | cb76686 | 2017-07-07 22:21:04 +0000 | [diff] [blame] | 68 | registerHubDiscoveryPrefix(const std::vector<nfd::FaceStatus>& dataset); |
Alexander Afanasyev | 2a655f7 | 2015-01-26 18:38:33 -0800 | [diff] [blame] | 69 | |
| 70 | void |
Junxiao Shi | a5a3a87 | 2017-07-08 12:42:11 +0000 | [diff] [blame] | 71 | afterReg(); |
Alexander Afanasyev | 2a655f7 | 2015-01-26 18:38:33 -0800 | [diff] [blame] | 72 | |
| 73 | void |
| 74 | setStrategy(); |
| 75 | |
| 76 | void |
Alexander Afanasyev | 2a655f7 | 2015-01-26 18:38:33 -0800 | [diff] [blame] | 77 | requestHubData(); |
| 78 | |
Alexander Afanasyev | 2a655f7 | 2015-01-26 18:38:33 -0800 | [diff] [blame] | 79 | private: |
Junxiao Shi | cb76686 | 2017-07-07 22:21:04 +0000 | [diff] [blame] | 80 | Face& m_face; |
| 81 | nfd::Controller& m_controller; |
Junxiao Shi | a5a3a87 | 2017-07-08 12:42:11 +0000 | [diff] [blame] | 82 | |
| 83 | int m_nRegs = 0; |
| 84 | int m_nRegSuccess = 0; |
| 85 | int m_nRegFailure = 0; |
Alexander Afanasyev | 2a655f7 | 2015-01-26 18:38:33 -0800 | [diff] [blame] | 86 | }; |
| 87 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 88 | } // namespace ndn::autoconfig |
Alexander Afanasyev | 2a655f7 | 2015-01-26 18:38:33 -0800 | [diff] [blame] | 89 | |
| 90 | #endif // NFD_TOOLS_NDN_AUTOCONFIG_MULTICAST_DISCOVERY_HPP |