Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /** |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 3 | * Copyright (c) 2013-2014, Regents of the University of California. |
| 4 | * All rights reserved. |
| 5 | * |
| 6 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
| 7 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
| 8 | * |
| 9 | * This file licensed under New BSD License. See COPYING for detailed information about |
| 10 | * ndn-cxx library copyright, permissions, and redistribution restrictions. |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 11 | */ |
| 12 | |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 13 | #ifndef NDN_MANAGEMENT_NDND_CONTROLLER_HPP |
| 14 | #define NDN_MANAGEMENT_NDND_CONTROLLER_HPP |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 15 | |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 16 | #include "controller.hpp" |
| 17 | |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 18 | namespace ndn { |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 19 | namespace ndnd { |
| 20 | |
| 21 | class FaceInstance; |
| 22 | class ForwardingEntry; |
| 23 | |
| 24 | /* |
| 25 | * @brief Class implementing Face and Prefix management operations for ndnd-tlv |
| 26 | * |
| 27 | * ndnd::Control should be used when connecting to ndnd-tlv daemon |
| 28 | */ |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 29 | class Controller : public ndn::Controller |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 30 | { |
| 31 | public: |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 32 | typedef function<void(const ForwardingEntry&)> PrefixOperationSucceedCallback; |
| 33 | typedef function<void(const FaceInstance&)> FaceOperationSucceedCallback; |
| 34 | |
| 35 | /** |
| 36 | * @brief Construct ndnd::Control object |
| 37 | */ |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 38 | Controller(Face& face); |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 39 | |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 40 | virtual void |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 41 | selfRegisterPrefix(const Name& prefixToRegister, |
| 42 | const SuccessCallback& onSuccess, |
| 43 | const FailCallback& onFail); |
| 44 | |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 45 | virtual void |
Yingdi Yu | e66bf2a | 2014-04-28 17:07:36 -0700 | [diff] [blame^] | 46 | selfRegisterPrefix(const Name& prefixToRegister, |
| 47 | const SuccessCallback& onSuccess, |
| 48 | const FailCallback& onFail, |
| 49 | const IdentityCertificate& certificate) |
| 50 | { |
| 51 | selfRegisterPrefix(prefixToRegister, onSuccess, onFail); |
| 52 | } |
| 53 | |
| 54 | virtual void |
| 55 | selfRegisterPrefix(const Name& prefixToRegister, |
| 56 | const SuccessCallback& onSuccess, |
| 57 | const FailCallback& onFail, |
| 58 | const Name& identity) |
| 59 | { |
| 60 | selfRegisterPrefix(prefixToRegister, onSuccess, onFail); |
| 61 | } |
| 62 | |
| 63 | virtual void |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 64 | selfDeregisterPrefix(const Name& prefixToRegister, |
| 65 | const SuccessCallback& onSuccess, |
| 66 | const FailCallback& onFail); |
| 67 | |
Yingdi Yu | e66bf2a | 2014-04-28 17:07:36 -0700 | [diff] [blame^] | 68 | virtual void |
| 69 | selfDeregisterPrefix(const Name& prefixToRegister, |
| 70 | const SuccessCallback& onSuccess, |
| 71 | const FailCallback& onFail, |
| 72 | const IdentityCertificate& certificate) |
| 73 | { |
| 74 | selfDeregisterPrefix(prefixToRegister, onSuccess, onFail); |
| 75 | } |
| 76 | |
| 77 | virtual void |
| 78 | selfDeregisterPrefix(const Name& prefixToRegister, |
| 79 | const SuccessCallback& onSuccess, |
| 80 | const FailCallback& onFail, |
| 81 | const Name& identity) |
| 82 | { |
| 83 | selfDeregisterPrefix(prefixToRegister, onSuccess, onFail); |
| 84 | } |
| 85 | |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 86 | protected: |
| 87 | void |
| 88 | startFaceAction(const FaceInstance& entry, |
| 89 | const FaceOperationSucceedCallback& onSuccess, |
| 90 | const FailCallback& onFailure); |
| 91 | |
| 92 | void |
| 93 | startPrefixAction(const ForwardingEntry& entry, |
| 94 | const PrefixOperationSucceedCallback& onSuccess, |
| 95 | const FailCallback& onFailure); |
| 96 | |
| 97 | private: |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 98 | void |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 99 | onNdnidFetched(const Interest& interest, Data& data); |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 100 | |
| 101 | void |
| 102 | recordSelfRegisteredFaceId(const ForwardingEntry& entry, |
| 103 | const SuccessCallback& onSuccess); |
| 104 | |
| 105 | void |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 106 | processFaceActionResponse(Data& data, |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 107 | const FaceOperationSucceedCallback& onSuccess, |
| 108 | const FailCallback& onFail); |
| 109 | |
| 110 | void |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 111 | processPrefixActionResponse(Data& data, |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 112 | const PrefixOperationSucceedCallback& onSuccess, |
| 113 | const FailCallback& onFail); |
| 114 | |
| 115 | private: |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 116 | Face& m_face; |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 117 | Block m_ndndId; |
| 118 | int64_t m_faceId; // internal face ID (needed for prefix de-registration) |
| 119 | |
| 120 | struct FilterRequest |
| 121 | { |
| 122 | FilterRequest(const Name& prefixToRegister, |
| 123 | const SuccessCallback& onSuccess, |
| 124 | const FailCallback& onFailure) |
| 125 | : m_prefixToRegister(prefixToRegister) |
| 126 | , m_onSuccess(onSuccess) |
| 127 | , m_onFailure(onFailure) |
| 128 | { |
| 129 | } |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 130 | |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 131 | Name m_prefixToRegister; |
| 132 | SuccessCallback m_onSuccess; |
| 133 | FailCallback m_onFailure; |
| 134 | }; |
| 135 | |
| 136 | typedef std::list<FilterRequest> FilterRequestList; |
| 137 | FilterRequestList m_filterRequests; |
| 138 | }; |
| 139 | |
| 140 | } // namespace ndnd |
| 141 | } // namespace ndn |
| 142 | |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 143 | #endif // NDN_MANAGEMENT_NDND_CONTROLLER_HPP |