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" |
Steve DiBenedetto | 6214e56 | 2014-03-15 16:27:04 -0600 | [diff] [blame] | 15 | #include "mgmt/fib-enumeration-publisher.hpp" |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 16 | |
| 17 | namespace nfd { |
| 18 | |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 19 | class Forwarder; |
| 20 | class Fib; |
| 21 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 22 | const std::string FIB_PRIVILEGE = "fib"; // config file privilege name |
| 23 | |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 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, |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 30 | shared_ptr<InternalFace> face); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 31 | |
Steve DiBenedetto | d030cfc | 2014-03-10 20:04:47 -0600 | [diff] [blame] | 32 | virtual |
| 33 | ~FibManager(); |
| 34 | |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 35 | void |
| 36 | onFibRequest(const Interest& request); |
| 37 | |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 38 | private: |
| 39 | |
| 40 | void |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 41 | onValidatedFibRequest(const shared_ptr<const Interest>& request); |
| 42 | |
| 43 | void |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame^] | 44 | addNextHop(ControlParameters& parameters, |
Alexander Afanasyev | d482fd3 | 2014-02-09 23:40:20 -0800 | [diff] [blame] | 45 | ControlResponse& response); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 46 | |
| 47 | void |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame^] | 48 | removeNextHop(ControlParameters& parameters, |
Alexander Afanasyev | d482fd3 | 2014-02-09 23:40:20 -0800 | [diff] [blame] | 49 | ControlResponse& response); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 50 | |
Steve DiBenedetto | 6214e56 | 2014-03-15 16:27:04 -0600 | [diff] [blame] | 51 | void |
| 52 | listEntries(const Interest& request); |
| 53 | |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 54 | private: |
| 55 | |
| 56 | Fib& m_managedFib; |
| 57 | function<shared_ptr<Face>(FaceId)> m_getFace; |
Steve DiBenedetto | 6214e56 | 2014-03-15 16:27:04 -0600 | [diff] [blame] | 58 | FibEnumerationPublisher m_fibEnumerationPublisher; |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 59 | |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 60 | typedef function<void(FibManager*, |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame^] | 61 | ControlParameters&, |
Steve DiBenedetto | 6214e56 | 2014-03-15 16:27:04 -0600 | [diff] [blame] | 62 | ControlResponse&)> SignedVerbProcessor; |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 63 | |
Steve DiBenedetto | 6214e56 | 2014-03-15 16:27:04 -0600 | [diff] [blame] | 64 | typedef std::map<Name::Component, SignedVerbProcessor> SignedVerbDispatchTable; |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 65 | |
Steve DiBenedetto | 6214e56 | 2014-03-15 16:27:04 -0600 | [diff] [blame] | 66 | typedef std::pair<Name::Component, SignedVerbProcessor> SignedVerbAndProcessor; |
| 67 | |
| 68 | typedef function<void(FibManager*, const Interest&)> UnsignedVerbProcessor; |
| 69 | |
| 70 | typedef std::map<Name::Component, UnsignedVerbProcessor> UnsignedVerbDispatchTable; |
| 71 | typedef std::pair<Name::Component, UnsignedVerbProcessor> UnsignedVerbAndProcessor; |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 72 | |
| 73 | |
Steve DiBenedetto | 6214e56 | 2014-03-15 16:27:04 -0600 | [diff] [blame] | 74 | const SignedVerbDispatchTable m_signedVerbDispatch; |
| 75 | const UnsignedVerbDispatchTable m_unsignedVerbDispatch; |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 76 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 77 | static const Name COMMAND_PREFIX; // /localhost/nfd/fib |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 78 | |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 79 | // number of components in an invalid, but not malformed, unsigned command. |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame^] | 80 | // (/localhost/nfd/fib + verb + parameters) = 5 |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 81 | static const size_t COMMAND_UNSIGNED_NCOMPS; |
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 a valid signed Interest. |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 84 | // UNSIGNED_NCOMPS + 4 command Interest components = 9 |
| 85 | static const size_t COMMAND_SIGNED_NCOMPS; |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 86 | |
Steve DiBenedetto | 6214e56 | 2014-03-15 16:27:04 -0600 | [diff] [blame] | 87 | static const SignedVerbAndProcessor SIGNED_COMMAND_VERBS[]; |
| 88 | static const UnsignedVerbAndProcessor UNSIGNED_COMMAND_VERBS[]; |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 89 | |
Steve DiBenedetto | 6214e56 | 2014-03-15 16:27:04 -0600 | [diff] [blame] | 90 | static const Name LIST_COMMAND_PREFIX; |
| 91 | static const size_t LIST_COMMAND_NCOMPS; |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | } // namespace nfd |
| 95 | |
| 96 | #endif // NFD_MGMT_FIB_MANAGER_HPP |