Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -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 | |
| 7 | #ifndef NDN_MANAGEMENT_NFD_CONTROL_HPP |
| 8 | #define NDN_MANAGEMENT_NFD_CONTROL_HPP |
| 9 | |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 10 | #include "controller.hpp" |
| 11 | |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 12 | #include "../security/key-chain.hpp" |
| 13 | |
| 14 | namespace ndn { |
| 15 | |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 16 | namespace nfd { |
| 17 | |
| 18 | class FibManagementOptions; |
hilata | a99e37e | 2014-02-15 23:52:46 -0600 | [diff] [blame^] | 19 | class FaceManagementOptions; |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 20 | |
| 21 | class Controller : public ndn::Controller |
| 22 | { |
| 23 | public: |
| 24 | typedef function<void(const FibManagementOptions&)> FibCommandSucceedCallback; |
hilata | a99e37e | 2014-02-15 23:52:46 -0600 | [diff] [blame^] | 25 | typedef function<void(const FaceManagementOptions&)> FaceCommandSucceedCallback; |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 26 | |
| 27 | /** |
| 28 | * @brief Construct ndnd::Control object |
| 29 | */ |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 30 | Controller(Face& face); |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 31 | |
| 32 | virtual void |
| 33 | selfRegisterPrefix(const Name& prefixToRegister, |
| 34 | const SuccessCallback& onSuccess, |
| 35 | const FailCallback& onFail); |
| 36 | |
| 37 | virtual void |
| 38 | selfDeregisterPrefix(const Name& prefixToRegister, |
| 39 | const SuccessCallback& onSuccess, |
| 40 | const FailCallback& onFail); |
| 41 | |
hilata | a99e37e | 2014-02-15 23:52:46 -0600 | [diff] [blame^] | 42 | protected: |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 43 | void |
| 44 | startFibCommand(const std::string& command, |
| 45 | const FibManagementOptions& options, |
| 46 | const FibCommandSucceedCallback& onSuccess, |
| 47 | const FailCallback& onFailure); |
hilata | a99e37e | 2014-02-15 23:52:46 -0600 | [diff] [blame^] | 48 | |
| 49 | void |
| 50 | startFaceCommand(const std::string& command, |
| 51 | const FaceManagementOptions& options, |
| 52 | const FaceCommandSucceedCallback& onSuccess, |
| 53 | const FailCallback& onFailure); |
| 54 | |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 55 | private: |
| 56 | void |
| 57 | recordSelfRegisteredFaceId(const FibManagementOptions& entry, |
| 58 | const SuccessCallback& onSuccess); |
| 59 | |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 60 | void |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 61 | processFibCommandResponse(Data& data, |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 62 | const FibCommandSucceedCallback& onSuccess, |
| 63 | const FailCallback& onFail); |
hilata | a99e37e | 2014-02-15 23:52:46 -0600 | [diff] [blame^] | 64 | |
| 65 | void |
| 66 | processFaceCommandResponse(Data& data, |
| 67 | const FaceCommandSucceedCallback& onSuccess, |
| 68 | const FailCallback& onFail); |
| 69 | |
| 70 | protected: |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 71 | Face& m_face; |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 72 | KeyChain m_keyChain; |
| 73 | uint64_t m_faceId; // internal face ID (needed for prefix de-registration) |
| 74 | }; |
| 75 | |
| 76 | } // namespace nfd |
| 77 | } // namespace ndn |
| 78 | |
| 79 | #endif // NDN_MANAGEMENT_NFD_CONTROL_HPP |