Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2013 Regents of the University of California. |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame^] | 7 | #ifndef NDN_MANAGEMENT_NDND_CONTROLLER_HPP |
| 8 | #define NDN_MANAGEMENT_NDND_CONTROLLER_HPP |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 9 | |
| 10 | #include "../common.hpp" |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame^] | 11 | #include "controller.hpp" |
| 12 | |
| 13 | #include "../name.hpp" |
| 14 | #include "../interest.hpp" |
| 15 | #include "../data.hpp" |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 16 | |
| 17 | namespace ndn { |
| 18 | |
| 19 | class Node; |
| 20 | |
| 21 | namespace ndnd { |
| 22 | |
| 23 | class FaceInstance; |
| 24 | class ForwardingEntry; |
| 25 | |
| 26 | /* |
| 27 | * @brief Class implementing Face and Prefix management operations for ndnd-tlv |
| 28 | * |
| 29 | * ndnd::Control should be used when connecting to ndnd-tlv daemon |
| 30 | */ |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame^] | 31 | class Controller : public ndn::Controller |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 32 | { |
| 33 | public: |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 34 | typedef function<void(const ForwardingEntry&)> PrefixOperationSucceedCallback; |
| 35 | typedef function<void(const FaceInstance&)> FaceOperationSucceedCallback; |
| 36 | |
| 37 | /** |
| 38 | * @brief Construct ndnd::Control object |
| 39 | */ |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame^] | 40 | Controller(Node& face); |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 41 | |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame^] | 42 | virtual void |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 43 | selfRegisterPrefix(const Name& prefixToRegister, |
| 44 | const SuccessCallback& onSuccess, |
| 45 | const FailCallback& onFail); |
| 46 | |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame^] | 47 | virtual void |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 48 | selfDeregisterPrefix(const Name& prefixToRegister, |
| 49 | const SuccessCallback& onSuccess, |
| 50 | const FailCallback& onFail); |
| 51 | |
| 52 | protected: |
| 53 | void |
| 54 | startFaceAction(const FaceInstance& entry, |
| 55 | const FaceOperationSucceedCallback& onSuccess, |
| 56 | const FailCallback& onFailure); |
| 57 | |
| 58 | void |
| 59 | startPrefixAction(const ForwardingEntry& entry, |
| 60 | const PrefixOperationSucceedCallback& onSuccess, |
| 61 | const FailCallback& onFailure); |
| 62 | |
| 63 | private: |
| 64 | void |
| 65 | onNdnidFetched(const shared_ptr<const Interest>& interest, |
| 66 | const shared_ptr<Data>& data); |
| 67 | |
| 68 | |
| 69 | void |
| 70 | recordSelfRegisteredFaceId(const ForwardingEntry& entry, |
| 71 | const SuccessCallback& onSuccess); |
| 72 | |
| 73 | void |
| 74 | processFaceActionResponse(const shared_ptr<Data>& data, |
| 75 | const FaceOperationSucceedCallback& onSuccess, |
| 76 | const FailCallback& onFail); |
| 77 | |
| 78 | void |
| 79 | processPrefixActionResponse(const shared_ptr<Data>& data, |
| 80 | const PrefixOperationSucceedCallback& onSuccess, |
| 81 | const FailCallback& onFail); |
| 82 | |
| 83 | private: |
| 84 | Node& m_face; |
| 85 | Block m_ndndId; |
| 86 | int64_t m_faceId; // internal face ID (needed for prefix de-registration) |
| 87 | |
| 88 | struct FilterRequest |
| 89 | { |
| 90 | FilterRequest(const Name& prefixToRegister, |
| 91 | const SuccessCallback& onSuccess, |
| 92 | const FailCallback& onFailure) |
| 93 | : m_prefixToRegister(prefixToRegister) |
| 94 | , m_onSuccess(onSuccess) |
| 95 | , m_onFailure(onFailure) |
| 96 | { |
| 97 | } |
| 98 | |
| 99 | Name m_prefixToRegister; |
| 100 | SuccessCallback m_onSuccess; |
| 101 | FailCallback m_onFailure; |
| 102 | }; |
| 103 | |
| 104 | typedef std::list<FilterRequest> FilterRequestList; |
| 105 | FilterRequestList m_filterRequests; |
| 106 | }; |
| 107 | |
| 108 | } // namespace ndnd |
| 109 | } // namespace ndn |
| 110 | |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame^] | 111 | #endif // NDN_MANAGEMENT_NDND_CONTROLLER_HPP |