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