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" |
| 12 | #include "mgmt/manager-base.hpp" |
| 13 | |
| 14 | namespace nfd { |
| 15 | |
| 16 | class AppFace; |
| 17 | class Face; |
| 18 | class Strategy; |
| 19 | class Forwarder; |
| 20 | class Fib; |
| 21 | |
| 22 | class FibManager : public ManagerBase |
| 23 | { |
| 24 | public: |
| 25 | |
| 26 | FibManager(Fib& fib, function<shared_ptr<Face>(FaceId)> getFace); |
| 27 | |
| 28 | void |
| 29 | onFibRequest(const Interest& request); |
| 30 | |
| 31 | const Name& |
| 32 | getRequestPrefix() const { return FIB_MANAGER_REQUEST_PREFIX; } |
| 33 | |
| 34 | private: |
| 35 | |
| 36 | void |
| 37 | fibInsert(const Interest& request); |
| 38 | |
| 39 | void |
| 40 | fibDelete(const Interest& request); |
| 41 | |
| 42 | void |
| 43 | fibAddNextHop(const Interest& request); |
| 44 | |
| 45 | void |
| 46 | fibRemoveNextHop(const Interest& request); |
| 47 | |
| 48 | void |
| 49 | fibStrategy(const Interest& request); |
| 50 | |
| 51 | // void |
| 52 | // onConfig(ConfigFile::Node section, bool isDryRun); |
| 53 | |
| 54 | private: |
| 55 | |
| 56 | Fib& m_managedFib; |
| 57 | function<shared_ptr<Face>(FaceId)> m_getFace; |
| 58 | std::map<Name, shared_ptr<Strategy> > m_namespaceToStrategyMap; |
| 59 | |
| 60 | |
| 61 | |
| 62 | typedef function<void(FibManager*, |
| 63 | const Interest&)> VerbProcessor; |
| 64 | |
| 65 | typedef std::map<Name::Component, VerbProcessor> VerbDispatchTable; |
| 66 | |
| 67 | typedef std::pair<Name::Component, VerbProcessor> VerbAndProcessor; |
| 68 | |
| 69 | |
| 70 | const VerbDispatchTable m_verbDispatch; |
| 71 | |
| 72 | static const Name FIB_MANAGER_REQUEST_PREFIX; |
| 73 | static const size_t FIB_MANAGER_REQUEST_COMMAND_MIN_NCOMPS; |
| 74 | static const size_t FIB_MANAGER_REQUEST_SIGNED_INTEREST_NCOMPS; |
| 75 | |
| 76 | static const Name::Component FIB_MANAGER_REQUEST_VERB_INSERT; |
| 77 | static const Name::Component FIB_MANAGER_REQUEST_VERB_DELETE; |
| 78 | static const Name::Component FIB_MANAGER_REQUEST_VERB_ADD_NEXTHOP; |
| 79 | static const Name::Component FIB_MANAGER_REQUEST_VERB_REMOVE_NEXTHOP; |
| 80 | static const Name::Component FIB_MANAGER_REQUEST_VERB_STRATEGY; |
| 81 | |
| 82 | static const VerbAndProcessor FIB_MANAGER_REQUEST_VERBS[]; |
| 83 | |
| 84 | }; |
| 85 | |
| 86 | } // namespace nfd |
| 87 | |
| 88 | #endif // NFD_MGMT_FIB_MANAGER_HPP |