blob: 8e72b9a37b561a114249645564ceb736a2ae7bd3 [file] [log] [blame]
Yanbiao Li73860e32015-08-19 16:30:16 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Eric Newberry2642cd22017-07-13 21:34:53 -04002/*
Davide Pesavento2c9d2ca2024-01-27 16:36:51 -05003 * Copyright (c) 2014-2024, Regents of the University of California,
Yanbiao Li73860e32015-08-19 16:30:16 -07004 * 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_DAEMON_MGMT_FACE_MANAGER_HPP
27#define NFD_DAEMON_MGMT_FACE_MANAGER_HPP
28
Davide Pesavento78ddcab2019-02-28 22:00:03 -050029#include "manager-base.hpp"
Davide Pesaventocb425e82019-07-14 21:48:22 -040030#include "face/face.hpp"
Junxiao Shib8590312016-12-29 21:22:25 +000031#include "face/face-system.hpp"
Davide Pesaventocfb1a312018-03-01 01:30:56 -050032
Davide Pesavento2c9d2ca2024-01-27 16:36:51 -050033#include <map>
34
Yanbiao Li73860e32015-08-19 16:30:16 -070035namespace nfd {
36
Yanbiao Li73860e32015-08-19 16:30:16 -070037/**
Davide Pesavento78ddcab2019-02-28 22:00:03 -050038 * @brief Implements the Face Management of NFD Management Protocol.
Alexander Afanasyev635bf202017-03-09 21:57:34 +000039 * @sa https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt
Yanbiao Li73860e32015-08-19 16:30:16 -070040 */
Davide Pesavento3db98072021-03-09 23:03:27 -050041class FaceManager final : public ManagerBase
Yanbiao Li73860e32015-08-19 16:30:16 -070042{
43public:
Junxiao Shiea47bde2017-01-26 17:49:16 +000044 FaceManager(FaceSystem& faceSystem,
Davide Pesavento78ddcab2019-02-28 22:00:03 -050045 Dispatcher& dispatcher, CommandAuthenticator& authenticator);
Yanbiao Li73860e32015-08-19 16:30:16 -070046
Davide Pesavento28181322018-11-08 16:44:50 -050047private: // ControlCommand
Yanbiao Li73860e32015-08-19 16:30:16 -070048 void
Davide Pesavento28181322018-11-08 16:44:50 -050049 createFace(const ControlParameters& parameters,
50 const ndn::mgmt::CommandContinuation& done);
51
52 void
53 updateFace(const Interest& interest,
Yanbiao Li73860e32015-08-19 16:30:16 -070054 const ControlParameters& parameters,
55 const ndn::mgmt::CommandContinuation& done);
56
57 void
Davide Pesavento28181322018-11-08 16:44:50 -050058 destroyFace(const ControlParameters& parameters,
Yanbiao Li73860e32015-08-19 16:30:16 -070059 const ndn::mgmt::CommandContinuation& done);
60
Davide Pesavento28181322018-11-08 16:44:50 -050061private: // helpers for ControlCommand
Yanbiao Li73860e32015-08-19 16:30:16 -070062 void
Davide Pesavento28181322018-11-08 16:44:50 -050063 afterCreateFaceSuccess(const shared_ptr<Face>& face,
64 const ControlParameters& parameters,
Yanbiao Li73860e32015-08-19 16:30:16 -070065 const ndn::mgmt::CommandContinuation& done);
66
Davide Pesavento28181322018-11-08 16:44:50 -050067private: // StatusDataset
Yanbiao Li73860e32015-08-19 16:30:16 -070068 void
Davide Pesavento28181322018-11-08 16:44:50 -050069 listFaces(ndn::mgmt::StatusDatasetContext& context);
Yanbiao Li73860e32015-08-19 16:30:16 -070070
71 void
Davide Pesavento28181322018-11-08 16:44:50 -050072 listChannels(ndn::mgmt::StatusDatasetContext& context);
Yanbiao Li73860e32015-08-19 16:30:16 -070073
74 void
Davide Pesavento28181322018-11-08 16:44:50 -050075 queryFaces(const Interest& interest, ndn::mgmt::StatusDatasetContext& context);
Junxiao Shida93f1f2015-11-11 06:13:16 -070076
Yanbiao Li73860e32015-08-19 16:30:16 -070077private: // NotificationStream
78 void
Eric Newberry1b4ba052016-10-07 23:04:07 -070079 notifyFaceEvent(const Face& face, ndn::nfd::FaceEventKind kind);
Yanbiao Li73860e32015-08-19 16:30:16 -070080
81 void
Eric Newberry1b4ba052016-10-07 23:04:07 -070082 connectFaceStateChangeSignal(const Face& face);
Yanbiao Li73860e32015-08-19 16:30:16 -070083
Davide Pesaventob5eee202017-09-21 23:59:22 -040084private:
Junxiao Shiea47bde2017-01-26 17:49:16 +000085 FaceSystem& m_faceSystem;
Eric Newberryb5aa7f52016-09-03 20:36:12 -070086 FaceTable& m_faceTable;
Junxiao Shiae04d342016-07-19 13:20:22 +000087 ndn::mgmt::PostNotification m_postNotification;
Yanbiao Li73860e32015-08-19 16:30:16 -070088 signal::ScopedConnection m_faceAddConn;
89 signal::ScopedConnection m_faceRemoveConn;
Davide Pesavento3cf75dc2018-03-17 00:38:03 -040090
Davide Pesavento264af772021-02-09 21:48:24 -050091NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
Davide Pesavento3cf75dc2018-03-17 00:38:03 -040092 std::map<FaceId, signal::ScopedConnection> m_faceStateChangeConn;
Yanbiao Li73860e32015-08-19 16:30:16 -070093};
94
95} // namespace nfd
96
97#endif // NFD_DAEMON_MGMT_FACE_MANAGER_HPP