hilata | 198cadb | 2014-02-15 23:46:19 -0600 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2014 Named Data Networking Project |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #ifndef NFD_TOOLS_NFDC_HPP |
| 8 | #define NFD_TOOLS_NFDC_HPP |
| 9 | |
| 10 | #include <ndn-cpp-dev/face.hpp> |
| 11 | #include <ndn-cpp-dev/management/controller.hpp> |
| 12 | #include <ndn-cpp-dev/management/nfd-controller.hpp> |
| 13 | #include <ndn-cpp-dev/management/nfd-fib-management-options.hpp> |
| 14 | #include <ndn-cpp-dev/management/nfd-face-management-options.hpp> |
hilata | 141eaae | 2014-03-13 19:54:47 -0500 | [diff] [blame^] | 15 | #include <ndn-cpp-dev/management/nfd-strategy-choice-options.hpp> |
hilata | 198cadb | 2014-02-15 23:46:19 -0600 | [diff] [blame] | 16 | #include <vector> |
| 17 | |
| 18 | namespace nfdc { |
| 19 | |
| 20 | class Controller : public ndn::nfd::Controller |
| 21 | { |
| 22 | public: |
| 23 | struct Error : public std::runtime_error |
| 24 | { |
| 25 | Error(const std::string& what) : std::runtime_error(what) {} |
| 26 | }; |
| 27 | |
| 28 | explicit |
| 29 | Controller(ndn::Face& face); |
| 30 | |
| 31 | ~Controller(); |
| 32 | |
| 33 | bool |
| 34 | dispatch(const std::string& cmd, |
| 35 | const char* cmdOptions[], |
| 36 | int nOptions); |
| 37 | /** |
hilata | dc947ec | 2014-03-10 12:48:31 -0500 | [diff] [blame] | 38 | * \brief Adds a nexthop to a FIB entry. |
| 39 | * |
| 40 | * If the FIB entry does not exist, it is inserted automatically |
hilata | 198cadb | 2014-02-15 23:46:19 -0600 | [diff] [blame] | 41 | * |
| 42 | * cmd format: |
| 43 | * name |
| 44 | * |
| 45 | * @param cmdOptions add command without leading 'insert' component |
| 46 | */ |
| 47 | void |
hilata | 198cadb | 2014-02-15 23:46:19 -0600 | [diff] [blame] | 48 | fibAddNextHop(const char* cmdOptions[], bool hasCost); |
| 49 | /** |
hilata | dc947ec | 2014-03-10 12:48:31 -0500 | [diff] [blame] | 50 | * \brief Removes a nexthop from an existing FIB entry |
hilata | 198cadb | 2014-02-15 23:46:19 -0600 | [diff] [blame] | 51 | * |
hilata | dc947ec | 2014-03-10 12:48:31 -0500 | [diff] [blame] | 52 | * If the last nexthop record in a FIB entry is removed, the FIB entry is also deleted |
hilata | 198cadb | 2014-02-15 23:46:19 -0600 | [diff] [blame] | 53 | * |
| 54 | * cmd format: |
| 55 | * name faceId |
| 56 | * |
| 57 | * @param cmdOptions delNext command without leading 'remove-nexthop' component |
| 58 | */ |
| 59 | void |
hilata | 141eaae | 2014-03-13 19:54:47 -0500 | [diff] [blame^] | 60 | fibRemoveNextHop(const char* cmdOptions[]); |
hilata | 198cadb | 2014-02-15 23:46:19 -0600 | [diff] [blame] | 61 | /** |
| 62 | * \brief create new face |
| 63 | * |
hilata | dc947ec | 2014-03-10 12:48:31 -0500 | [diff] [blame] | 64 | * This command allows creation of UDP unicast and TCP faces only. |
hilata | 198cadb | 2014-02-15 23:46:19 -0600 | [diff] [blame] | 65 | * |
| 66 | * cmd format: |
| 67 | * uri |
| 68 | * |
| 69 | * @param cmdOptions create command without leading 'create' component |
| 70 | */ |
| 71 | void |
| 72 | faceCreate(const char* cmdOptions[]); |
| 73 | /** |
| 74 | * \brief destroy a face |
| 75 | * |
| 76 | * cmd format: |
| 77 | * faceId |
| 78 | * |
| 79 | * @param cmdOptions destroy command without leading 'destroy' component |
| 80 | */ |
| 81 | void |
| 82 | faceDestroy(const char* cmdOptions[]); |
hilata | 141eaae | 2014-03-13 19:54:47 -0500 | [diff] [blame^] | 83 | /** |
| 84 | * \brief Set the strategy for a namespace |
| 85 | * |
| 86 | * |
| 87 | * cmd format: |
| 88 | * name strategy |
| 89 | * |
| 90 | * @param cmdOptions Set command without leading 'Unset' component |
| 91 | */ |
| 92 | void |
| 93 | strategyChoiceSet(const char* cmdOptions[]); |
| 94 | /** |
| 95 | * \brief Unset the strategy for a namespace |
| 96 | * |
| 97 | * |
| 98 | * cmd format: |
| 99 | * name strategy |
| 100 | * |
| 101 | * @param cmdOptions Unset command without leading 'Unset' component |
| 102 | */ |
| 103 | void |
| 104 | strategyChoiceUnset(const char* cmdOptions[]); |
| 105 | |
hilata | 198cadb | 2014-02-15 23:46:19 -0600 | [diff] [blame] | 106 | private: |
| 107 | void |
hilata | 141eaae | 2014-03-13 19:54:47 -0500 | [diff] [blame^] | 108 | onFibSuccess(const ndn::nfd::FibManagementOptions& fibOptions, |
| 109 | const std::string& message); |
hilata | 198cadb | 2014-02-15 23:46:19 -0600 | [diff] [blame] | 110 | |
| 111 | void |
hilata | 141eaae | 2014-03-13 19:54:47 -0500 | [diff] [blame^] | 112 | onFaceSuccess(const ndn::nfd::FaceManagementOptions& faceOptions, |
| 113 | const std::string& message); |
hilata | 198cadb | 2014-02-15 23:46:19 -0600 | [diff] [blame] | 114 | |
| 115 | void |
hilata | 141eaae | 2014-03-13 19:54:47 -0500 | [diff] [blame^] | 116 | onSetStrategySuccess(const ndn::nfd::StrategyChoiceOptions& resp, |
| 117 | const std::string& message); |
| 118 | void |
hilata | 198cadb | 2014-02-15 23:46:19 -0600 | [diff] [blame] | 119 | onError(const std::string& error, const std::string& message); |
| 120 | |
| 121 | public: |
| 122 | const char* m_programName; |
| 123 | }; |
| 124 | |
hilata | 141eaae | 2014-03-13 19:54:47 -0500 | [diff] [blame^] | 125 | } // namespace nfdc |
hilata | 198cadb | 2014-02-15 23:46:19 -0600 | [diff] [blame] | 126 | |
| 127 | #endif // NFD_TOOLS_NFDC_HPP |
| 128 | |