Vince Lehman | 27f1add | 2014-10-16 17:14:46 -0500 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Nick Gordon | c6a8522 | 2017-01-03 16:54:34 -0600 | [diff] [blame] | 3 | * Copyright (c) 2014-2017, The University of Memphis, |
Junxiao Shi | 3e5120c | 2016-09-10 16:58:34 +0000 | [diff] [blame] | 4 | * Regents of the University of California, |
| 5 | * Arizona Board of Regents. |
Vince Lehman | 27f1add | 2014-10-16 17:14:46 -0500 | [diff] [blame] | 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/>. |
Vince Lehman | 27f1add | 2014-10-16 17:14:46 -0500 | [diff] [blame] | 20 | **/ |
| 21 | |
| 22 | #ifndef NLSR_UTIL_FACE_CONTROLLER_HPP |
| 23 | #define NLSR_UTIL_FACE_CONTROLLER_HPP |
| 24 | |
| 25 | #include <ndn-cxx/util/face-uri.hpp> |
Junxiao Shi | 3e5120c | 2016-09-10 16:58:34 +0000 | [diff] [blame] | 26 | #include <ndn-cxx/mgmt/nfd/controller.hpp> |
Vince Lehman | 27f1add | 2014-10-16 17:14:46 -0500 | [diff] [blame] | 27 | |
| 28 | namespace nlsr { |
| 29 | namespace util { |
| 30 | |
| 31 | class FaceController : boost::noncopyable |
| 32 | { |
| 33 | public: |
Junxiao Shi | 63bd034 | 2016-08-17 16:57:14 +0000 | [diff] [blame] | 34 | typedef ndn::nfd::Controller::CommandSucceedCallback CommandSuccessCallback; |
| 35 | typedef ndn::nfd::Controller::CommandFailCallback CommandFailureCallback; |
Vince Lehman | 27f1add | 2014-10-16 17:14:46 -0500 | [diff] [blame] | 36 | |
| 37 | FaceController(boost::asio::io_service& io, ndn::nfd::Controller& controller) |
| 38 | : m_ioService(io) |
| 39 | , m_controller(controller) |
| 40 | { |
| 41 | } |
| 42 | |
| 43 | void |
| 44 | createFace(const std::string& request, |
| 45 | const CommandSuccessCallback& onSuccess, |
| 46 | const CommandFailureCallback& onFailure); |
| 47 | |
| 48 | private: |
| 49 | void |
| 50 | createFaceInNfd(const ndn::util::FaceUri& uri, |
| 51 | const CommandSuccessCallback& onSuccess, |
| 52 | const CommandFailureCallback& onFailure); |
| 53 | |
| 54 | void |
| 55 | onCanonizeSuccess(const ndn::util::FaceUri& uri, |
| 56 | const CommandSuccessCallback& onSuccess, |
| 57 | const CommandFailureCallback& onFailure, |
| 58 | const ndn::util::FaceUri& request); |
| 59 | |
| 60 | void |
| 61 | onCanonizeFailure(const std::string& reason, |
| 62 | const CommandSuccessCallback& onSuccess, |
| 63 | const CommandFailureCallback& onFailure, |
| 64 | const ndn::util::FaceUri& request); |
| 65 | |
| 66 | private: |
| 67 | boost::asio::io_service& m_ioService; |
| 68 | ndn::nfd::Controller& m_controller; |
| 69 | |
| 70 | static const uint32_t CANONIZE_ERROR_CODE = 408; |
Vince Lehman | 27f1add | 2014-10-16 17:14:46 -0500 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | } // namespace util |
| 74 | } // namespace nlsr |
| 75 | |
| 76 | #endif // NLSR_UTIL_FACE_CONTROLLER_HPP |