blob: d77a2f279c2e910fe0236dd71fb39d0309f32d00 [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
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070058 typedef function<void(FibManager*,
59 const Interest&)> VerbProcessor;
60
61 typedef std::map<Name::Component, VerbProcessor> VerbDispatchTable;
62
63 typedef std::pair<Name::Component, VerbProcessor> VerbAndProcessor;
64
65
66 const VerbDispatchTable m_verbDispatch;
67
Steve DiBenedetto80ddc212014-02-01 22:23:56 -070068 static const Name FIB_MANAGER_COMMAND_PREFIX; // /localhost/nfd/fib
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070069
Steve DiBenedetto80ddc212014-02-01 22:23:56 -070070 // number of components in an invalid, but not malformed, unsigned command.
71 // (/localhost/nfd/fib + verb + options) = 5
72 static const size_t FIB_MANAGER_COMMAND_UNSIGNED_NCOMPS;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070073
Steve DiBenedetto80ddc212014-02-01 22:23:56 -070074 // number of components in a valid signed Interest.
75 // 5 in mock (see UNSIGNED_NCOMPS), 8 with signed Interest support.
76 static const size_t FIB_MANAGER_COMMAND_SIGNED_NCOMPS;
77
Steve DiBenedetto80ddc212014-02-01 22:23:56 -070078 static const VerbAndProcessor FIB_MANAGER_COMMAND_VERBS[];
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070079
80};
81
82} // namespace nfd
83
84#endif // NFD_MGMT_FIB_MANAGER_HPP