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 |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 46 | selfDeregisterPrefix(const Name& prefixToRegister, |
| 47 | const SuccessCallback& onSuccess, |
| 48 | const FailCallback& onFail); |
| 49 | |
| 50 | protected: |
| 51 | void |
| 52 | startFaceAction(const FaceInstance& entry, |
| 53 | const FaceOperationSucceedCallback& onSuccess, |
| 54 | const FailCallback& onFailure); |
| 55 | |
| 56 | void |
| 57 | startPrefixAction(const ForwardingEntry& entry, |
| 58 | const PrefixOperationSucceedCallback& onSuccess, |
| 59 | const FailCallback& onFailure); |
| 60 | |
| 61 | private: |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 62 | void |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 63 | onNdnidFetched(const Interest& interest, Data& data); |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 64 | |
| 65 | void |
| 66 | recordSelfRegisteredFaceId(const ForwardingEntry& entry, |
| 67 | const SuccessCallback& onSuccess); |
| 68 | |
| 69 | void |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 70 | processFaceActionResponse(Data& data, |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 71 | const FaceOperationSucceedCallback& onSuccess, |
| 72 | const FailCallback& onFail); |
| 73 | |
| 74 | void |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 75 | processPrefixActionResponse(Data& data, |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 76 | const PrefixOperationSucceedCallback& onSuccess, |
| 77 | const FailCallback& onFail); |
| 78 | |
| 79 | private: |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 80 | Face& m_face; |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 81 | Block m_ndndId; |
| 82 | int64_t m_faceId; // internal face ID (needed for prefix de-registration) |
| 83 | |
| 84 | struct FilterRequest |
| 85 | { |
| 86 | FilterRequest(const Name& prefixToRegister, |
| 87 | const SuccessCallback& onSuccess, |
| 88 | const FailCallback& onFailure) |
| 89 | : m_prefixToRegister(prefixToRegister) |
| 90 | , m_onSuccess(onSuccess) |
| 91 | , m_onFailure(onFailure) |
| 92 | { |
| 93 | } |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 94 | |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 95 | Name m_prefixToRegister; |
| 96 | SuccessCallback m_onSuccess; |
| 97 | FailCallback m_onFailure; |
| 98 | }; |
| 99 | |
| 100 | typedef std::list<FilterRequest> FilterRequestList; |
| 101 | FilterRequestList m_filterRequests; |
| 102 | }; |
| 103 | |
| 104 | } // namespace ndnd |
| 105 | } // namespace ndn |
| 106 | |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 107 | #endif // NDN_MANAGEMENT_NDND_CONTROLLER_HPP |