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 | |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 10 | #include "controller.hpp" |
| 11 | |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 12 | namespace ndn { |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 13 | namespace ndnd { |
| 14 | |
| 15 | class FaceInstance; |
| 16 | class ForwardingEntry; |
| 17 | |
| 18 | /* |
| 19 | * @brief Class implementing Face and Prefix management operations for ndnd-tlv |
| 20 | * |
| 21 | * ndnd::Control should be used when connecting to ndnd-tlv daemon |
| 22 | */ |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 23 | class Controller : public ndn::Controller |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 24 | { |
| 25 | public: |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 26 | typedef function<void(const ForwardingEntry&)> PrefixOperationSucceedCallback; |
| 27 | typedef function<void(const FaceInstance&)> FaceOperationSucceedCallback; |
| 28 | |
| 29 | /** |
| 30 | * @brief Construct ndnd::Control object |
| 31 | */ |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame^] | 32 | Controller(Face& face); |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 33 | |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 34 | virtual void |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 35 | selfRegisterPrefix(const Name& prefixToRegister, |
| 36 | const SuccessCallback& onSuccess, |
| 37 | const FailCallback& onFail); |
| 38 | |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 39 | virtual void |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 40 | selfDeregisterPrefix(const Name& prefixToRegister, |
| 41 | const SuccessCallback& onSuccess, |
| 42 | const FailCallback& onFail); |
| 43 | |
| 44 | protected: |
| 45 | void |
| 46 | startFaceAction(const FaceInstance& entry, |
| 47 | const FaceOperationSucceedCallback& onSuccess, |
| 48 | const FailCallback& onFailure); |
| 49 | |
| 50 | void |
| 51 | startPrefixAction(const ForwardingEntry& entry, |
| 52 | const PrefixOperationSucceedCallback& onSuccess, |
| 53 | const FailCallback& onFailure); |
| 54 | |
| 55 | private: |
| 56 | void |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame^] | 57 | onNdnidFetched(const Interest& interest, Data& data); |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 58 | |
| 59 | void |
| 60 | recordSelfRegisteredFaceId(const ForwardingEntry& entry, |
| 61 | const SuccessCallback& onSuccess); |
| 62 | |
| 63 | void |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame^] | 64 | processFaceActionResponse(Data& data, |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 65 | const FaceOperationSucceedCallback& onSuccess, |
| 66 | const FailCallback& onFail); |
| 67 | |
| 68 | void |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame^] | 69 | processPrefixActionResponse(Data& data, |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 70 | const PrefixOperationSucceedCallback& onSuccess, |
| 71 | const FailCallback& onFail); |
| 72 | |
| 73 | private: |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame^] | 74 | Face& m_face; |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 75 | Block m_ndndId; |
| 76 | int64_t m_faceId; // internal face ID (needed for prefix de-registration) |
| 77 | |
| 78 | struct FilterRequest |
| 79 | { |
| 80 | FilterRequest(const Name& prefixToRegister, |
| 81 | const SuccessCallback& onSuccess, |
| 82 | const FailCallback& onFailure) |
| 83 | : m_prefixToRegister(prefixToRegister) |
| 84 | , m_onSuccess(onSuccess) |
| 85 | , m_onFailure(onFailure) |
| 86 | { |
| 87 | } |
| 88 | |
| 89 | Name m_prefixToRegister; |
| 90 | SuccessCallback m_onSuccess; |
| 91 | FailCallback m_onFailure; |
| 92 | }; |
| 93 | |
| 94 | typedef std::list<FilterRequest> FilterRequestList; |
| 95 | FilterRequestList m_filterRequests; |
| 96 | }; |
| 97 | |
| 98 | } // namespace ndnd |
| 99 | } // namespace ndn |
| 100 | |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 101 | #endif // NDN_MANAGEMENT_NDND_CONTROLLER_HPP |