blob: 3b36aeb116585087c67a0a78b99106d3073f7bb6 [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
Steve DiBenedetto0b73f442014-02-05 22:02:03 -070016#include <ndn-cpp-dev/management/fib-management-options.hpp>
17#include <ndn-cpp-dev/management/control-response.hpp>
18
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070019namespace nfd {
20
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070021class Forwarder;
22class Fib;
23
24class FibManager : public ManagerBase
25{
26public:
27
Steve DiBenedetto3970c892014-01-31 23:31:13 -070028 FibManager(Fib& fib,
29 function<shared_ptr<Face>(FaceId)> getFace,
30 shared_ptr<AppFace> face);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070031
32 void
33 onFibRequest(const Interest& request);
34
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070035private:
36
37 void
Steve DiBenedetto0b73f442014-02-05 22:02:03 -070038 insertEntry(const ndn::FibManagementOptions& options,
39 ndn::ControlResponse& response);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070040
41 void
Steve DiBenedetto0b73f442014-02-05 22:02:03 -070042 deleteEntry(const ndn::FibManagementOptions& options,
43 ndn::ControlResponse& response);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070044
45 void
Steve DiBenedetto0b73f442014-02-05 22:02:03 -070046 addNextHop(const ndn::FibManagementOptions& options,
47 ndn::ControlResponse& response);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070048
49 void
Steve DiBenedetto0b73f442014-02-05 22:02:03 -070050 removeNextHop(const ndn::FibManagementOptions& options,
51 ndn::ControlResponse& response);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070052
53 void
Steve DiBenedetto0b73f442014-02-05 22:02:03 -070054 strategy(const ndn::FibManagementOptions& options,
55 ndn::ControlResponse& response);
56
57 bool
58 extractOptions(const Interest& request,
59 ndn::FibManagementOptions& extractedOptions);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070060
61 // void
62 // onConfig(ConfigFile::Node section, bool isDryRun);
63
64private:
65
66 Fib& m_managedFib;
67 function<shared_ptr<Face>(FaceId)> m_getFace;
Steve DiBenedetto43cd0372014-02-01 17:05:07 -070068 std::map<Name, shared_ptr<fw::Strategy> > m_namespaceToStrategyMap;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070069
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070070 typedef function<void(FibManager*,
Steve DiBenedetto0b73f442014-02-05 22:02:03 -070071 const ndn::FibManagementOptions&,
72 ndn::ControlResponse&)> VerbProcessor;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070073
74 typedef std::map<Name::Component, VerbProcessor> VerbDispatchTable;
75
76 typedef std::pair<Name::Component, VerbProcessor> VerbAndProcessor;
77
78
79 const VerbDispatchTable m_verbDispatch;
80
Steve DiBenedetto80ddc212014-02-01 22:23:56 -070081 static const Name FIB_MANAGER_COMMAND_PREFIX; // /localhost/nfd/fib
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070082
Steve DiBenedetto80ddc212014-02-01 22:23:56 -070083 // number of components in an invalid, but not malformed, unsigned command.
84 // (/localhost/nfd/fib + verb + options) = 5
85 static const size_t FIB_MANAGER_COMMAND_UNSIGNED_NCOMPS;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070086
Steve DiBenedetto80ddc212014-02-01 22:23:56 -070087 // number of components in a valid signed Interest.
88 // 5 in mock (see UNSIGNED_NCOMPS), 8 with signed Interest support.
89 static const size_t FIB_MANAGER_COMMAND_SIGNED_NCOMPS;
90
Steve DiBenedetto80ddc212014-02-01 22:23:56 -070091 static const VerbAndProcessor FIB_MANAGER_COMMAND_VERBS[];
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070092
93};
94
95} // namespace nfd
96
97#endif // NFD_MGMT_FIB_MANAGER_HPP