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