blob: c8c21ea87c508878c4d5d18f2d04f65a5f5bb82e [file] [log] [blame]
Steve DiBenedetto042bfe92014-01-30 15:05:08 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Vince Lehman5144f822014-07-23 15:12:56 -07003 * Copyright (c) 2014, Regents of the University of California,
4 * Arizona Board of Regents,
5 * Colorado State University,
6 * University Pierre & Marie Curie, Sorbonne University,
7 * Washington University in St. Louis,
8 * Beijing Institute of Technology,
9 * The University of Memphis
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070010 *
11 * This file is part of NFD (Named Data Networking Forwarding Daemon).
12 * See AUTHORS.md for complete list of NFD authors and contributors.
13 *
14 * NFD is free software: you can redistribute it and/or modify it under the terms
15 * of the GNU General Public License as published by the Free Software Foundation,
16 * either version 3 of the License, or (at your option) any later version.
17 *
18 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 * PURPOSE. See the GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along with
23 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
Vince Lehman5144f822014-07-23 15:12:56 -070024 */
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070025
Alexander Afanasyev613e2a92014-04-15 13:36:58 -070026#ifndef NFD_DAEMON_MGMT_FIB_MANAGER_HPP
27#define NFD_DAEMON_MGMT_FIB_MANAGER_HPP
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070028
29#include "common.hpp"
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070030#include "mgmt/manager-base.hpp"
Steve DiBenedetto6214e562014-03-15 16:27:04 -060031#include "mgmt/fib-enumeration-publisher.hpp"
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070032
33namespace nfd {
34
Davide Pesavento52a18f92014-04-10 00:55:01 +020035class Face;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070036class Forwarder;
37class Fib;
38
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070039const std::string FIB_PRIVILEGE = "fib"; // config file privilege name
40
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070041class FibManager : public ManagerBase
42{
43public:
44
Steve DiBenedetto3970c892014-01-31 23:31:13 -070045 FibManager(Fib& fib,
46 function<shared_ptr<Face>(FaceId)> getFace,
Vince Lehman5144f822014-07-23 15:12:56 -070047 shared_ptr<InternalFace> face,
48 ndn::KeyChain& keyChain);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070049
Steve DiBenedettod030cfc2014-03-10 20:04:47 -060050 virtual
51 ~FibManager();
52
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070053 void
54 onFibRequest(const Interest& request);
55
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070056private:
57
58 void
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070059 onValidatedFibRequest(const shared_ptr<const Interest>& request);
60
61 void
Steve DiBenedetto7564d972014-03-24 14:28:46 -060062 addNextHop(ControlParameters& parameters,
Alexander Afanasyevd482fd32014-02-09 23:40:20 -080063 ControlResponse& response);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070064
65 void
Steve DiBenedetto7564d972014-03-24 14:28:46 -060066 removeNextHop(ControlParameters& parameters,
Alexander Afanasyevd482fd32014-02-09 23:40:20 -080067 ControlResponse& response);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070068
Steve DiBenedetto6214e562014-03-15 16:27:04 -060069 void
70 listEntries(const Interest& request);
71
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070072private:
73
74 Fib& m_managedFib;
75 function<shared_ptr<Face>(FaceId)> m_getFace;
Steve DiBenedetto6214e562014-03-15 16:27:04 -060076 FibEnumerationPublisher m_fibEnumerationPublisher;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070077
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070078 typedef function<void(FibManager*,
Steve DiBenedetto7564d972014-03-24 14:28:46 -060079 ControlParameters&,
Steve DiBenedetto6214e562014-03-15 16:27:04 -060080 ControlResponse&)> SignedVerbProcessor;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070081
Steve DiBenedetto6214e562014-03-15 16:27:04 -060082 typedef std::map<Name::Component, SignedVerbProcessor> SignedVerbDispatchTable;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070083
Steve DiBenedetto6214e562014-03-15 16:27:04 -060084 typedef std::pair<Name::Component, SignedVerbProcessor> SignedVerbAndProcessor;
85
86 typedef function<void(FibManager*, const Interest&)> UnsignedVerbProcessor;
87
88 typedef std::map<Name::Component, UnsignedVerbProcessor> UnsignedVerbDispatchTable;
89 typedef std::pair<Name::Component, UnsignedVerbProcessor> UnsignedVerbAndProcessor;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070090
91
Steve DiBenedetto6214e562014-03-15 16:27:04 -060092 const SignedVerbDispatchTable m_signedVerbDispatch;
93 const UnsignedVerbDispatchTable m_unsignedVerbDispatch;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070094
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070095 static const Name COMMAND_PREFIX; // /localhost/nfd/fib
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070096
Steve DiBenedetto80ddc212014-02-01 22:23:56 -070097 // number of components in an invalid, but not malformed, unsigned command.
Steve DiBenedetto7564d972014-03-24 14:28:46 -060098 // (/localhost/nfd/fib + verb + parameters) = 5
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070099 static const size_t COMMAND_UNSIGNED_NCOMPS;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -0700100
Steve DiBenedetto80ddc212014-02-01 22:23:56 -0700101 // number of components in a valid signed Interest.
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700102 // UNSIGNED_NCOMPS + 4 command Interest components = 9
103 static const size_t COMMAND_SIGNED_NCOMPS;
Steve DiBenedetto80ddc212014-02-01 22:23:56 -0700104
Steve DiBenedetto6214e562014-03-15 16:27:04 -0600105 static const SignedVerbAndProcessor SIGNED_COMMAND_VERBS[];
106 static const UnsignedVerbAndProcessor UNSIGNED_COMMAND_VERBS[];
Steve DiBenedetto042bfe92014-01-30 15:05:08 -0700107
Steve DiBenedetto6214e562014-03-15 16:27:04 -0600108 static const Name LIST_COMMAND_PREFIX;
109 static const size_t LIST_COMMAND_NCOMPS;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -0700110};
111
112} // namespace nfd
113
Alexander Afanasyev613e2a92014-04-15 13:36:58 -0700114#endif // NFD_DAEMON_MGMT_FIB_MANAGER_HPP