| /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| /** |
| * Copyright (C) 2013 Regents of the University of California. |
| * See COPYING for copyright and distribution information. |
| */ |
| |
| #ifndef NDN_MANAGEMENT_NFD_CONTROL_HPP |
| #define NDN_MANAGEMENT_NFD_CONTROL_HPP |
| |
| #include "controller.hpp" |
| #include "../util/command-interest-generator.hpp" |
| |
| namespace ndn { |
| |
| namespace nfd { |
| |
| class FibManagementOptions; |
| class FaceManagementOptions; |
| |
| class Controller : public ndn::Controller |
| { |
| public: |
| typedef function<void(const FibManagementOptions&)> FibCommandSucceedCallback; |
| typedef function<void(const FaceManagementOptions&)> FaceCommandSucceedCallback; |
| |
| /** |
| * @brief Construct ndnd::Control object |
| */ |
| Controller(Face& face); |
| |
| virtual void |
| selfRegisterPrefix(const Name& prefixToRegister, |
| const SuccessCallback& onSuccess, |
| const FailCallback& onFail); |
| |
| virtual void |
| selfDeregisterPrefix(const Name& prefixToDeRegister, |
| const SuccessCallback& onSuccess, |
| const FailCallback& onFail); |
| |
| /** |
| * \brief Adds a nexthop to an existing or new FIB entry |
| * |
| * If FIB entry for the specified prefix does not exist, it will be automatically created. |
| * |
| * \param prefix Prefix of the FIB entry |
| * \param faceId ID of the face which should be added as a next hop for prefix FIB entry. |
| * If a nexthop of same FaceId exists on the FIB entry, its cost is updated. |
| * If FaceId is set to zero, it is implied as the face of the entity sending |
| * this command. |
| * \param cost Cost that should be associated with the next hop |
| * \param onSuccess Callback that will be called when operation succeeds |
| * \param onFail Callback that will be called when operation fails |
| */ |
| void |
| fibAddNextHop(const Name& prefix, uint64_t faceId, int cost, |
| const SuccessCallback& onSuccess, |
| const FailCallback& onFail); |
| |
| /** |
| * \brief Remove a nexthop from FIB entry |
| * |
| * If after removal of the nexthop FIB entry has zero next hops, this FIB entry will |
| * be automatically deleted. |
| * |
| * \param prefix Prefix of the FIB entry |
| * \param faceId ID of the face which should be removed FIB entry. |
| * If FaceId is set to zero, it is implied as the face of the entity sending |
| * this command. |
| * \param onSuccess Callback that will be called when operation succeeds |
| * \param onFail Callback that will be called when operation fails |
| */ |
| void |
| fibRemoveNextHop(const Name& prefix, uint64_t faceId, |
| const SuccessCallback& onSuccess, |
| const FailCallback& onFail); |
| |
| protected: |
| void |
| startFibCommand(const std::string& command, |
| const FibManagementOptions& options, |
| const FibCommandSucceedCallback& onSuccess, |
| const FailCallback& onFailure); |
| |
| void |
| startFaceCommand(const std::string& command, |
| const FaceManagementOptions& options, |
| const FaceCommandSucceedCallback& onSuccess, |
| const FailCallback& onFailure); |
| |
| private: |
| void |
| processFibCommandResponse(Data& data, |
| const FibCommandSucceedCallback& onSuccess, |
| const FailCallback& onFail); |
| |
| void |
| processFaceCommandResponse(Data& data, |
| const FaceCommandSucceedCallback& onSuccess, |
| const FailCallback& onFail); |
| |
| protected: |
| Face& m_face; |
| CommandInterestGenerator m_commandInterestGenerator; |
| }; |
| |
| } // namespace nfd |
| } // namespace ndn |
| |
| #endif // NDN_MANAGEMENT_NFD_CONTROL_HPP |