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 | |
Alexander Afanasyev | 26c24d2 | 2014-03-20 09:31:21 -0700 | [diff] [blame] | 7 | #ifndef NDN_MANAGEMENT_NFD_CONTROLLER_HPP |
| 8 | #define NDN_MANAGEMENT_NFD_CONTROLLER_HPP |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 9 | |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 10 | #include "controller.hpp" |
Alexander Afanasyev | 884280c | 2014-03-07 09:40:39 +0000 | [diff] [blame] | 11 | #include "../util/command-interest-generator.hpp" |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 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; |
hilata | 7d160f2 | 2014-03-13 19:51:42 -0500 | [diff] [blame] | 19 | class StrategyChoiceOptions; |
| 20 | |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 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; |
hilata | 7d160f2 | 2014-03-13 19:51:42 -0500 | [diff] [blame] | 26 | typedef function<void(const StrategyChoiceOptions&)> StrategyChoiceCommandSucceedCallback; |
| 27 | |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 28 | /** |
| 29 | * @brief Construct ndnd::Control object |
| 30 | */ |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 31 | Controller(Face& face); |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 32 | |
| 33 | virtual void |
| 34 | selfRegisterPrefix(const Name& prefixToRegister, |
| 35 | const SuccessCallback& onSuccess, |
| 36 | const FailCallback& onFail); |
| 37 | |
| 38 | virtual void |
Alexander Afanasyev | 884280c | 2014-03-07 09:40:39 +0000 | [diff] [blame] | 39 | selfDeregisterPrefix(const Name& prefixToDeRegister, |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 40 | const SuccessCallback& onSuccess, |
| 41 | const FailCallback& onFail); |
| 42 | |
Alexander Afanasyev | 884280c | 2014-03-07 09:40:39 +0000 | [diff] [blame] | 43 | /** |
| 44 | * \brief Adds a nexthop to an existing or new FIB entry |
| 45 | * |
| 46 | * If FIB entry for the specified prefix does not exist, it will be automatically created. |
| 47 | * |
| 48 | * \param prefix Prefix of the FIB entry |
| 49 | * \param faceId ID of the face which should be added as a next hop for prefix FIB entry. |
| 50 | * If a nexthop of same FaceId exists on the FIB entry, its cost is updated. |
| 51 | * If FaceId is set to zero, it is implied as the face of the entity sending |
| 52 | * this command. |
| 53 | * \param cost Cost that should be associated with the next hop |
| 54 | * \param onSuccess Callback that will be called when operation succeeds |
| 55 | * \param onFail Callback that will be called when operation fails |
| 56 | */ |
| 57 | void |
| 58 | fibAddNextHop(const Name& prefix, uint64_t faceId, int cost, |
Obaid | 6e7f5f1 | 2014-03-11 14:46:10 -0500 | [diff] [blame] | 59 | const FibCommandSucceedCallback& onSuccess, |
| 60 | const FailCallback& onFail); |
Alexander Afanasyev | 884280c | 2014-03-07 09:40:39 +0000 | [diff] [blame] | 61 | |
| 62 | /** |
| 63 | * \brief Remove a nexthop from FIB entry |
| 64 | * |
| 65 | * If after removal of the nexthop FIB entry has zero next hops, this FIB entry will |
| 66 | * be automatically deleted. |
| 67 | * |
| 68 | * \param prefix Prefix of the FIB entry |
| 69 | * \param faceId ID of the face which should be removed FIB entry. |
| 70 | * If FaceId is set to zero, it is implied as the face of the entity sending |
| 71 | * this command. |
| 72 | * \param onSuccess Callback that will be called when operation succeeds |
| 73 | * \param onFail Callback that will be called when operation fails |
| 74 | */ |
| 75 | void |
| 76 | fibRemoveNextHop(const Name& prefix, uint64_t faceId, |
Obaid | 6e7f5f1 | 2014-03-11 14:46:10 -0500 | [diff] [blame] | 77 | const FibCommandSucceedCallback& onSuccess, |
| 78 | const FailCallback& onFail); |
Alexander Afanasyev | 884280c | 2014-03-07 09:40:39 +0000 | [diff] [blame] | 79 | |
hilata | a99e37e | 2014-02-15 23:52:46 -0600 | [diff] [blame] | 80 | protected: |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 81 | void |
| 82 | startFibCommand(const std::string& command, |
| 83 | const FibManagementOptions& options, |
| 84 | const FibCommandSucceedCallback& onSuccess, |
| 85 | const FailCallback& onFailure); |
hilata | a99e37e | 2014-02-15 23:52:46 -0600 | [diff] [blame] | 86 | |
| 87 | void |
| 88 | startFaceCommand(const std::string& command, |
| 89 | const FaceManagementOptions& options, |
| 90 | const FaceCommandSucceedCallback& onSuccess, |
| 91 | const FailCallback& onFailure); |
| 92 | |
hilata | 7d160f2 | 2014-03-13 19:51:42 -0500 | [diff] [blame] | 93 | void |
| 94 | startStrategyChoiceCommand(const std::string& command, |
| 95 | const StrategyChoiceOptions& options, |
| 96 | const StrategyChoiceCommandSucceedCallback& onSuccess, |
| 97 | const FailCallback& onFailure); |
| 98 | |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 99 | private: |
| 100 | void |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 101 | processFibCommandResponse(Data& data, |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 102 | const FibCommandSucceedCallback& onSuccess, |
| 103 | const FailCallback& onFail); |
hilata | a99e37e | 2014-02-15 23:52:46 -0600 | [diff] [blame] | 104 | |
| 105 | void |
| 106 | processFaceCommandResponse(Data& data, |
| 107 | const FaceCommandSucceedCallback& onSuccess, |
| 108 | const FailCallback& onFail); |
| 109 | |
hilata | 7d160f2 | 2014-03-13 19:51:42 -0500 | [diff] [blame] | 110 | void |
| 111 | processStrategyChoiceCommandResponse(Data& data, |
| 112 | const StrategyChoiceCommandSucceedCallback& onSuccess, |
| 113 | const FailCallback& onFail); |
| 114 | |
hilata | a99e37e | 2014-02-15 23:52:46 -0600 | [diff] [blame] | 115 | protected: |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 116 | Face& m_face; |
Alexander Afanasyev | 884280c | 2014-03-07 09:40:39 +0000 | [diff] [blame] | 117 | CommandInterestGenerator m_commandInterestGenerator; |
Alexander Afanasyev | e289b53 | 2014-02-09 22:14:44 -0800 | [diff] [blame] | 118 | }; |
| 119 | |
| 120 | } // namespace nfd |
| 121 | } // namespace ndn |
| 122 | |
Alexander Afanasyev | 26c24d2 | 2014-03-20 09:31:21 -0700 | [diff] [blame] | 123 | #endif // NDN_MANAGEMENT_NFD_CONTROLLER_HPP |