blob: 5ce6e86f0dfa68fd8a6cf829565d25130cf50156 [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"
Steve DiBenedetto6214e562014-03-15 16:27:04 -060015#include "mgmt/fib-enumeration-publisher.hpp"
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070016
17namespace nfd {
18
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070019class Forwarder;
20class Fib;
21
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070022const std::string FIB_PRIVILEGE = "fib"; // config file privilege name
23
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070024class FibManager : public ManagerBase
25{
26public:
27
Steve DiBenedetto3970c892014-01-31 23:31:13 -070028 FibManager(Fib& fib,
29 function<shared_ptr<Face>(FaceId)> getFace,
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070030 shared_ptr<InternalFace> face);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070031
Steve DiBenedettod030cfc2014-03-10 20:04:47 -060032 virtual
33 ~FibManager();
34
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070035 void
36 onFibRequest(const Interest& request);
37
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070038private:
39
40 void
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070041 onValidatedFibRequest(const shared_ptr<const Interest>& request);
42
43 void
Steve DiBenedetto7564d972014-03-24 14:28:46 -060044 addNextHop(ControlParameters& parameters,
Alexander Afanasyevd482fd32014-02-09 23:40:20 -080045 ControlResponse& response);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070046
47 void
Steve DiBenedetto7564d972014-03-24 14:28:46 -060048 removeNextHop(ControlParameters& parameters,
Alexander Afanasyevd482fd32014-02-09 23:40:20 -080049 ControlResponse& response);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070050
Steve DiBenedetto6214e562014-03-15 16:27:04 -060051 void
52 listEntries(const Interest& request);
53
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070054private:
55
56 Fib& m_managedFib;
57 function<shared_ptr<Face>(FaceId)> m_getFace;
Steve DiBenedetto6214e562014-03-15 16:27:04 -060058 FibEnumerationPublisher m_fibEnumerationPublisher;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070059
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070060 typedef function<void(FibManager*,
Steve DiBenedetto7564d972014-03-24 14:28:46 -060061 ControlParameters&,
Steve DiBenedetto6214e562014-03-15 16:27:04 -060062 ControlResponse&)> SignedVerbProcessor;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070063
Steve DiBenedetto6214e562014-03-15 16:27:04 -060064 typedef std::map<Name::Component, SignedVerbProcessor> SignedVerbDispatchTable;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070065
Steve DiBenedetto6214e562014-03-15 16:27:04 -060066 typedef std::pair<Name::Component, SignedVerbProcessor> SignedVerbAndProcessor;
67
68 typedef function<void(FibManager*, const Interest&)> UnsignedVerbProcessor;
69
70 typedef std::map<Name::Component, UnsignedVerbProcessor> UnsignedVerbDispatchTable;
71 typedef std::pair<Name::Component, UnsignedVerbProcessor> UnsignedVerbAndProcessor;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070072
73
Steve DiBenedetto6214e562014-03-15 16:27:04 -060074 const SignedVerbDispatchTable m_signedVerbDispatch;
75 const UnsignedVerbDispatchTable m_unsignedVerbDispatch;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070076
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070077 static const Name COMMAND_PREFIX; // /localhost/nfd/fib
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070078
Steve DiBenedetto80ddc212014-02-01 22:23:56 -070079 // number of components in an invalid, but not malformed, unsigned command.
Steve DiBenedetto7564d972014-03-24 14:28:46 -060080 // (/localhost/nfd/fib + verb + parameters) = 5
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070081 static const size_t COMMAND_UNSIGNED_NCOMPS;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070082
Steve DiBenedetto80ddc212014-02-01 22:23:56 -070083 // number of components in a valid signed Interest.
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070084 // UNSIGNED_NCOMPS + 4 command Interest components = 9
85 static const size_t COMMAND_SIGNED_NCOMPS;
Steve DiBenedetto80ddc212014-02-01 22:23:56 -070086
Steve DiBenedetto6214e562014-03-15 16:27:04 -060087 static const SignedVerbAndProcessor SIGNED_COMMAND_VERBS[];
88 static const UnsignedVerbAndProcessor UNSIGNED_COMMAND_VERBS[];
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070089
Steve DiBenedetto6214e562014-03-15 16:27:04 -060090 static const Name LIST_COMMAND_PREFIX;
91 static const size_t LIST_COMMAND_NCOMPS;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070092};
93
94} // namespace nfd
95
96#endif // NFD_MGMT_FIB_MANAGER_HPP