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