blob: eef58fade221d2d92e265fc584d4bca5c572d716 [file] [log] [blame]
Steve DiBenedetto042bfe92014-01-30 15:05:08 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -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 *
10 * This file is part of NFD (Named Data Networking Forwarding Daemon).
11 * See AUTHORS.md for complete list of NFD authors and contributors.
12 *
13 * NFD is free software: you can redistribute it and/or modify it under the terms
14 * of the GNU General Public License as published by the Free Software Foundation,
15 * either version 3 of the License, or (at your option) any later version.
16 *
17 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
18 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
19 * PURPOSE. See the GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License along with
22 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
23 **/
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070024
25#ifndef NFD_MGMT_FIB_MANAGER_HPP
26#define NFD_MGMT_FIB_MANAGER_HPP
27
28#include "common.hpp"
29#include "face/face.hpp"
Steve DiBenedetto43cd0372014-02-01 17:05:07 -070030#include "mgmt/app-face.hpp"
31#include "fw/strategy.hpp"
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070032#include "mgmt/manager-base.hpp"
Steve DiBenedetto6214e562014-03-15 16:27:04 -060033#include "mgmt/fib-enumeration-publisher.hpp"
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070034
35namespace nfd {
36
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070037class Forwarder;
38class Fib;
39
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070040const std::string FIB_PRIVILEGE = "fib"; // config file privilege name
41
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070042class FibManager : public ManagerBase
43{
44public:
45
Steve DiBenedetto3970c892014-01-31 23:31:13 -070046 FibManager(Fib& fib,
47 function<shared_ptr<Face>(FaceId)> getFace,
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070048 shared_ptr<InternalFace> face);
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
114#endif // NFD_MGMT_FIB_MANAGER_HPP