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 | f8b5bcd | 2016-08-11 15:06:50 -0500 | [diff] [blame] | 3 | * Copyright (c) 2014-2016, The University of Memphis, |
| 4 | * Regents of the University of California |
Vince Lehman | 27f1add | 2014-10-16 17:14:46 -0500 | [diff] [blame] | 5 | * |
| 6 | * This file is part of NLSR (Named-data Link State Routing). |
| 7 | * See AUTHORS.md for complete list of NLSR authors and contributors. |
| 8 | * |
| 9 | * NLSR is free software: you can redistribute it and/or modify it under the terms |
| 10 | * of the GNU General Public License as published by the Free Software Foundation, |
| 11 | * either version 3 of the License, or (at your option) any later version. |
| 12 | * |
| 13 | * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 14 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 15 | * PURPOSE. See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along with |
| 18 | * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 19 | * |
| 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> |
| 26 | #include <ndn-cxx/management/nfd-controller.hpp> |
| 27 | |
| 28 | namespace nlsr { |
| 29 | namespace util { |
| 30 | |
| 31 | class FaceController : boost::noncopyable |
| 32 | { |
| 33 | public: |
| 34 | typedef ndn::function<void(const ndn::nfd::ControlParameters&)> CommandSuccessCallback; |
| 35 | typedef ndn::function<void(uint32_t,const std::string&)> CommandFailureCallback; |
| 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; |
| 71 | static const ndn::time::seconds TIME_ALLOWED_FOR_CANONIZATION; |
| 72 | }; |
| 73 | |
| 74 | } // namespace util |
| 75 | } // namespace nlsr |
| 76 | |
| 77 | #endif // NLSR_UTIL_FACE_CONTROLLER_HPP |