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 | |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 54 | bool |
| 55 | extractOptions(const Interest& request, |
Alexander Afanasyev | d482fd3 | 2014-02-09 23:40:20 -0800 | [diff] [blame] | 56 | FibManagementOptions& extractedOptions); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 57 | |
| 58 | // void |
| 59 | // onConfig(ConfigFile::Node section, bool isDryRun); |
| 60 | |
| 61 | private: |
| 62 | |
| 63 | Fib& m_managedFib; |
| 64 | function<shared_ptr<Face>(FaceId)> m_getFace; |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 65 | std::map<Name, shared_ptr<fw::Strategy> > m_namespaceToStrategyMap; |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 66 | |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 67 | typedef function<void(FibManager*, |
Alexander Afanasyev | d482fd3 | 2014-02-09 23:40:20 -0800 | [diff] [blame] | 68 | const FibManagementOptions&, |
| 69 | ControlResponse&)> VerbProcessor; |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 70 | |
| 71 | typedef std::map<Name::Component, VerbProcessor> VerbDispatchTable; |
| 72 | |
| 73 | typedef std::pair<Name::Component, VerbProcessor> VerbAndProcessor; |
| 74 | |
| 75 | |
| 76 | const VerbDispatchTable m_verbDispatch; |
| 77 | |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 78 | static const Name FIB_MANAGER_COMMAND_PREFIX; // /localhost/nfd/fib |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 79 | |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 80 | // number of components in an invalid, but not malformed, unsigned command. |
| 81 | // (/localhost/nfd/fib + verb + options) = 5 |
| 82 | static const size_t FIB_MANAGER_COMMAND_UNSIGNED_NCOMPS; |
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 a valid signed Interest. |
| 85 | // 5 in mock (see UNSIGNED_NCOMPS), 8 with signed Interest support. |
| 86 | static const size_t FIB_MANAGER_COMMAND_SIGNED_NCOMPS; |
| 87 | |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 88 | static const VerbAndProcessor FIB_MANAGER_COMMAND_VERBS[]; |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 89 | |
| 90 | }; |
| 91 | |
| 92 | } // namespace nfd |
| 93 | |
| 94 | #endif // NFD_MGMT_FIB_MANAGER_HPP |