blob: d44c2eca041bf4e1c99f7882b8125695b8699b71 [file] [log] [blame]
Vince Lehman27f1add2014-10-16 17:14:46 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Nick Gordonc6a85222017-01-03 16:54:34 -06003 * Copyright (c) 2014-2017, The University of Memphis,
Junxiao Shi3e5120c2016-09-10 16:58:34 +00004 * Regents of the University of California,
5 * Arizona Board of Regents.
Vince Lehman27f1add2014-10-16 17:14:46 -05006 *
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 Lehman27f1add2014-10-16 17:14:46 -050020 **/
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 Shi3e5120c2016-09-10 16:58:34 +000026#include <ndn-cxx/mgmt/nfd/controller.hpp>
Vince Lehman27f1add2014-10-16 17:14:46 -050027
28namespace nlsr {
29namespace util {
30
31class FaceController : boost::noncopyable
32{
33public:
Junxiao Shi63bd0342016-08-17 16:57:14 +000034 typedef ndn::nfd::Controller::CommandSucceedCallback CommandSuccessCallback;
35 typedef ndn::nfd::Controller::CommandFailCallback CommandFailureCallback;
Vince Lehman27f1add2014-10-16 17:14:46 -050036
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
48private:
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
66private:
67 boost::asio::io_service& m_ioService;
68 ndn::nfd::Controller& m_controller;
69
70 static const uint32_t CANONIZE_ERROR_CODE = 408;
Vince Lehman27f1add2014-10-16 17:14:46 -050071};
72
73} // namespace util
74} // namespace nlsr
75
76#endif // NLSR_UTIL_FACE_CONTROLLER_HPP