Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [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_MGMT_FIB_MANAGER_HPP |
| 8 | #define NFD_MGMT_FIB_MANAGER_HPP |
| 9 | |
| 10 | #include "common.hpp" |
| 11 | #include "face/face.hpp" |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 12 | #include "mgmt/app-face.hpp" |
| 13 | #include "fw/strategy.hpp" |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 14 | #include "mgmt/manager-base.hpp" |
| 15 | |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame^] | 16 | #include <ndn-cpp-dev/management/fib-management-options.hpp> |
| 17 | #include <ndn-cpp-dev/management/control-response.hpp> |
| 18 | |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 19 | namespace nfd { |
| 20 | |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 21 | class Forwarder; |
| 22 | class Fib; |
| 23 | |
| 24 | class FibManager : public ManagerBase |
| 25 | { |
| 26 | public: |
| 27 | |
Steve DiBenedetto | 3970c89 | 2014-01-31 23:31:13 -0700 | [diff] [blame] | 28 | FibManager(Fib& fib, |
| 29 | function<shared_ptr<Face>(FaceId)> getFace, |
| 30 | shared_ptr<AppFace> face); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 31 | |
| 32 | void |
| 33 | onFibRequest(const Interest& request); |
| 34 | |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 35 | private: |
| 36 | |
| 37 | void |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame^] | 38 | insertEntry(const ndn::FibManagementOptions& options, |
| 39 | ndn::ControlResponse& response); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 40 | |
| 41 | void |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame^] | 42 | deleteEntry(const ndn::FibManagementOptions& options, |
| 43 | ndn::ControlResponse& response); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 44 | |
| 45 | void |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame^] | 46 | addNextHop(const ndn::FibManagementOptions& options, |
| 47 | ndn::ControlResponse& response); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 48 | |
| 49 | void |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame^] | 50 | removeNextHop(const ndn::FibManagementOptions& options, |
| 51 | ndn::ControlResponse& response); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 52 | |
| 53 | void |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame^] | 54 | strategy(const ndn::FibManagementOptions& options, |
| 55 | ndn::ControlResponse& response); |
| 56 | |
| 57 | bool |
| 58 | extractOptions(const Interest& request, |
| 59 | ndn::FibManagementOptions& extractedOptions); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 60 | |
| 61 | // void |
| 62 | // onConfig(ConfigFile::Node section, bool isDryRun); |
| 63 | |
| 64 | private: |
| 65 | |
| 66 | Fib& m_managedFib; |
| 67 | function<shared_ptr<Face>(FaceId)> m_getFace; |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 68 | std::map<Name, shared_ptr<fw::Strategy> > m_namespaceToStrategyMap; |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 69 | |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 70 | typedef function<void(FibManager*, |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame^] | 71 | const ndn::FibManagementOptions&, |
| 72 | ndn::ControlResponse&)> VerbProcessor; |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 73 | |
| 74 | typedef std::map<Name::Component, VerbProcessor> VerbDispatchTable; |
| 75 | |
| 76 | typedef std::pair<Name::Component, VerbProcessor> VerbAndProcessor; |
| 77 | |
| 78 | |
| 79 | const VerbDispatchTable m_verbDispatch; |
| 80 | |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 81 | static const Name FIB_MANAGER_COMMAND_PREFIX; // /localhost/nfd/fib |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 82 | |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 83 | // number of components in an invalid, but not malformed, unsigned command. |
| 84 | // (/localhost/nfd/fib + verb + options) = 5 |
| 85 | static const size_t FIB_MANAGER_COMMAND_UNSIGNED_NCOMPS; |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 86 | |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 87 | // number of components in a valid signed Interest. |
| 88 | // 5 in mock (see UNSIGNED_NCOMPS), 8 with signed Interest support. |
| 89 | static const size_t FIB_MANAGER_COMMAND_SIGNED_NCOMPS; |
| 90 | |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 91 | static const VerbAndProcessor FIB_MANAGER_COMMAND_VERBS[]; |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 92 | |
| 93 | }; |
| 94 | |
| 95 | } // namespace nfd |
| 96 | |
| 97 | #endif // NFD_MGMT_FIB_MANAGER_HPP |