blob: 60b238542ce2f3565f668d6856fa4395075b88ad [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
16namespace nfd {
17
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070018class Forwarder;
19class Fib;
20
21class FibManager : public ManagerBase
22{
23public:
24
Steve DiBenedetto3970c892014-01-31 23:31:13 -070025 FibManager(Fib& fib,
26 function<shared_ptr<Face>(FaceId)> getFace,
27 shared_ptr<AppFace> face);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070028
29 void
30 onFibRequest(const Interest& request);
31
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070032private:
33
34 void
35 fibInsert(const Interest& request);
36
37 void
38 fibDelete(const Interest& request);
39
40 void
41 fibAddNextHop(const Interest& request);
42
43 void
44 fibRemoveNextHop(const Interest& request);
45
46 void
47 fibStrategy(const Interest& request);
48
49 // void
50 // onConfig(ConfigFile::Node section, bool isDryRun);
51
52private:
53
54 Fib& m_managedFib;
55 function<shared_ptr<Face>(FaceId)> m_getFace;
Steve DiBenedetto43cd0372014-02-01 17:05:07 -070056 std::map<Name, shared_ptr<fw::Strategy> > m_namespaceToStrategyMap;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070057
58
59
60 typedef function<void(FibManager*,
61 const Interest&)> VerbProcessor;
62
63 typedef std::map<Name::Component, VerbProcessor> VerbDispatchTable;
64
65 typedef std::pair<Name::Component, VerbProcessor> VerbAndProcessor;
66
67
68 const VerbDispatchTable m_verbDispatch;
69
Steve DiBenedetto80ddc212014-02-01 22:23:56 -070070 static const Name FIB_MANAGER_COMMAND_PREFIX; // /localhost/nfd/fib
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070071
Steve DiBenedetto80ddc212014-02-01 22:23:56 -070072 // number of components in an invalid, but not malformed, unsigned command.
73 // (/localhost/nfd/fib + verb + options) = 5
74 static const size_t FIB_MANAGER_COMMAND_UNSIGNED_NCOMPS;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070075
Steve DiBenedetto80ddc212014-02-01 22:23:56 -070076 // number of components in a valid signed Interest.
77 // 5 in mock (see UNSIGNED_NCOMPS), 8 with signed Interest support.
78 static const size_t FIB_MANAGER_COMMAND_SIGNED_NCOMPS;
79
80 static const Name::Component FIB_MANAGER_COMMAND_VERB_INSERT;
81 static const Name::Component FIB_MANAGER_COMMAND_VERB_DELETE;
82 static const Name::Component FIB_MANAGER_COMMAND_VERB_ADD_NEXTHOP;
83 static const Name::Component FIB_MANAGER_COMMAND_VERB_REMOVE_NEXTHOP;
84 static const Name::Component FIB_MANAGER_COMMAND_VERB_STRATEGY;
85
86 static const VerbAndProcessor FIB_MANAGER_COMMAND_VERBS[];
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070087
88};
89
90} // namespace nfd
91
92#endif // NFD_MGMT_FIB_MANAGER_HPP