blob: 79be0941f7ab6fb8cb12de1d21d99a799190bb02 [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
54 void
Alexander Afanasyevd482fd32014-02-09 23:40:20 -080055 strategy(const FibManagementOptions& options,
56 ControlResponse& response);
Steve DiBenedetto0b73f442014-02-05 22:02:03 -070057
58 bool
59 extractOptions(const Interest& request,
Alexander Afanasyevd482fd32014-02-09 23:40:20 -080060 FibManagementOptions& extractedOptions);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070061
62 // void
63 // onConfig(ConfigFile::Node section, bool isDryRun);
64
65private:
66
67 Fib& m_managedFib;
68 function<shared_ptr<Face>(FaceId)> m_getFace;
Steve DiBenedetto43cd0372014-02-01 17:05:07 -070069 std::map<Name, shared_ptr<fw::Strategy> > m_namespaceToStrategyMap;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070070
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070071 typedef function<void(FibManager*,
Alexander Afanasyevd482fd32014-02-09 23:40:20 -080072 const FibManagementOptions&,
73 ControlResponse&)> VerbProcessor;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070074
75 typedef std::map<Name::Component, VerbProcessor> VerbDispatchTable;
76
77 typedef std::pair<Name::Component, VerbProcessor> VerbAndProcessor;
78
79
80 const VerbDispatchTable m_verbDispatch;
81
Steve DiBenedetto80ddc212014-02-01 22:23:56 -070082 static const Name FIB_MANAGER_COMMAND_PREFIX; // /localhost/nfd/fib
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070083
Steve DiBenedetto80ddc212014-02-01 22:23:56 -070084 // number of components in an invalid, but not malformed, unsigned command.
85 // (/localhost/nfd/fib + verb + options) = 5
86 static const size_t FIB_MANAGER_COMMAND_UNSIGNED_NCOMPS;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070087
Steve DiBenedetto80ddc212014-02-01 22:23:56 -070088 // number of components in a valid signed Interest.
89 // 5 in mock (see UNSIGNED_NCOMPS), 8 with signed Interest support.
90 static const size_t FIB_MANAGER_COMMAND_SIGNED_NCOMPS;
91
Steve DiBenedetto80ddc212014-02-01 22:23:56 -070092 static const VerbAndProcessor FIB_MANAGER_COMMAND_VERBS[];
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070093
94};
95
96} // namespace nfd
97
98#endif // NFD_MGMT_FIB_MANAGER_HPP