blob: c7b77935f41a1e7663cd8d742b17765f6ba96dbe [file] [log] [blame]
Steve DiBenedetto042bfe92014-01-30 15:05:08 -07001/* -*- 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 DiBenedetto43cd0372014-02-01 17:05:07 -070012#include "mgmt/app-face.hpp"
13#include "fw/strategy.hpp"
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070014#include "mgmt/manager-base.hpp"
15
Alexander Afanasyevd482fd32014-02-09 23:40:20 -080016#include <ndn-cpp-dev/management/nfd-fib-management-options.hpp>
Steve DiBenedetto0b73f442014-02-05 22:02:03 -070017
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070018namespace nfd {
19
Alexander Afanasyevd482fd32014-02-09 23:40:20 -080020using ndn::nfd::FibManagementOptions;
21
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070022class Forwarder;
23class Fib;
24
25class FibManager : public ManagerBase
26{
27public:
28
Steve DiBenedetto3970c892014-01-31 23:31:13 -070029 FibManager(Fib& fib,
30 function<shared_ptr<Face>(FaceId)> getFace,
31 shared_ptr<AppFace> face);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070032
33 void
34 onFibRequest(const Interest& request);
35
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070036private:
37
38 void
Alexander Afanasyevd482fd32014-02-09 23:40:20 -080039 insertEntry(const FibManagementOptions& options,
40 ControlResponse& response);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070041
42 void
Alexander Afanasyevd482fd32014-02-09 23:40:20 -080043 deleteEntry(const FibManagementOptions& options,
44 ControlResponse& response);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070045
46 void
Alexander Afanasyevd482fd32014-02-09 23:40:20 -080047 addNextHop(const FibManagementOptions& options,
48 ControlResponse& response);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070049
50 void
Alexander Afanasyevd482fd32014-02-09 23:40:20 -080051 removeNextHop(const FibManagementOptions& options,
52 ControlResponse& response);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070053
Steve DiBenedetto0b73f442014-02-05 22:02:03 -070054 bool
55 extractOptions(const Interest& request,
Alexander Afanasyevd482fd32014-02-09 23:40:20 -080056 FibManagementOptions& extractedOptions);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070057
58 // void
59 // onConfig(ConfigFile::Node section, bool isDryRun);
60
61private:
62
63 Fib& m_managedFib;
64 function<shared_ptr<Face>(FaceId)> m_getFace;
Steve DiBenedetto43cd0372014-02-01 17:05:07 -070065 std::map<Name, shared_ptr<fw::Strategy> > m_namespaceToStrategyMap;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070066
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070067 typedef function<void(FibManager*,
Alexander Afanasyevd482fd32014-02-09 23:40:20 -080068 const FibManagementOptions&,
69 ControlResponse&)> VerbProcessor;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070070
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 DiBenedetto80ddc212014-02-01 22:23:56 -070078 static const Name FIB_MANAGER_COMMAND_PREFIX; // /localhost/nfd/fib
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070079
Steve DiBenedetto80ddc212014-02-01 22:23:56 -070080 // 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 DiBenedetto042bfe92014-01-30 15:05:08 -070083
Steve DiBenedetto80ddc212014-02-01 22:23:56 -070084 // 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 DiBenedetto80ddc212014-02-01 22:23:56 -070088 static const VerbAndProcessor FIB_MANAGER_COMMAND_VERBS[];
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070089
90};
91
92} // namespace nfd
93
94#endif // NFD_MGMT_FIB_MANAGER_HPP