blob: 4591088341f006ab8fabab01bd0a4b97660e79dc [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
Alexander Afanasyev613e2a92014-04-15 13:36:58 -070025#ifndef NFD_DAEMON_MGMT_FIB_MANAGER_HPP
26#define NFD_DAEMON_MGMT_FIB_MANAGER_HPP
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070027
28#include "common.hpp"
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070029#include "mgmt/manager-base.hpp"
Steve DiBenedetto6214e562014-03-15 16:27:04 -060030#include "mgmt/fib-enumeration-publisher.hpp"
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070031
32namespace nfd {
33
Davide Pesavento52a18f92014-04-10 00:55:01 +020034class Face;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070035class Forwarder;
36class Fib;
37
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070038const std::string FIB_PRIVILEGE = "fib"; // config file privilege name
39
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070040class FibManager : public ManagerBase
41{
42public:
43
Steve DiBenedetto3970c892014-01-31 23:31:13 -070044 FibManager(Fib& fib,
45 function<shared_ptr<Face>(FaceId)> getFace,
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070046 shared_ptr<InternalFace> face);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070047
Steve DiBenedettod030cfc2014-03-10 20:04:47 -060048 virtual
49 ~FibManager();
50
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070051 void
52 onFibRequest(const Interest& request);
53
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070054private:
55
56 void
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070057 onValidatedFibRequest(const shared_ptr<const Interest>& request);
58
59 void
Steve DiBenedetto7564d972014-03-24 14:28:46 -060060 addNextHop(ControlParameters& parameters,
Alexander Afanasyevd482fd32014-02-09 23:40:20 -080061 ControlResponse& response);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070062
63 void
Steve DiBenedetto7564d972014-03-24 14:28:46 -060064 removeNextHop(ControlParameters& parameters,
Alexander Afanasyevd482fd32014-02-09 23:40:20 -080065 ControlResponse& response);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070066
Steve DiBenedetto6214e562014-03-15 16:27:04 -060067 void
68 listEntries(const Interest& request);
69
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070070private:
71
72 Fib& m_managedFib;
73 function<shared_ptr<Face>(FaceId)> m_getFace;
Steve DiBenedetto6214e562014-03-15 16:27:04 -060074 FibEnumerationPublisher m_fibEnumerationPublisher;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070075
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070076 typedef function<void(FibManager*,
Steve DiBenedetto7564d972014-03-24 14:28:46 -060077 ControlParameters&,
Steve DiBenedetto6214e562014-03-15 16:27:04 -060078 ControlResponse&)> SignedVerbProcessor;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070079
Steve DiBenedetto6214e562014-03-15 16:27:04 -060080 typedef std::map<Name::Component, SignedVerbProcessor> SignedVerbDispatchTable;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070081
Steve DiBenedetto6214e562014-03-15 16:27:04 -060082 typedef std::pair<Name::Component, SignedVerbProcessor> SignedVerbAndProcessor;
83
84 typedef function<void(FibManager*, const Interest&)> UnsignedVerbProcessor;
85
86 typedef std::map<Name::Component, UnsignedVerbProcessor> UnsignedVerbDispatchTable;
87 typedef std::pair<Name::Component, UnsignedVerbProcessor> UnsignedVerbAndProcessor;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070088
89
Steve DiBenedetto6214e562014-03-15 16:27:04 -060090 const SignedVerbDispatchTable m_signedVerbDispatch;
91 const UnsignedVerbDispatchTable m_unsignedVerbDispatch;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070092
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070093 static const Name COMMAND_PREFIX; // /localhost/nfd/fib
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070094
Steve DiBenedetto80ddc212014-02-01 22:23:56 -070095 // number of components in an invalid, but not malformed, unsigned command.
Steve DiBenedetto7564d972014-03-24 14:28:46 -060096 // (/localhost/nfd/fib + verb + parameters) = 5
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070097 static const size_t COMMAND_UNSIGNED_NCOMPS;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070098
Steve DiBenedetto80ddc212014-02-01 22:23:56 -070099 // number of components in a valid signed Interest.
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700100 // UNSIGNED_NCOMPS + 4 command Interest components = 9
101 static const size_t COMMAND_SIGNED_NCOMPS;
Steve DiBenedetto80ddc212014-02-01 22:23:56 -0700102
Steve DiBenedetto6214e562014-03-15 16:27:04 -0600103 static const SignedVerbAndProcessor SIGNED_COMMAND_VERBS[];
104 static const UnsignedVerbAndProcessor UNSIGNED_COMMAND_VERBS[];
Steve DiBenedetto042bfe92014-01-30 15:05:08 -0700105
Steve DiBenedetto6214e562014-03-15 16:27:04 -0600106 static const Name LIST_COMMAND_PREFIX;
107 static const size_t LIST_COMMAND_NCOMPS;
Steve DiBenedetto042bfe92014-01-30 15:05:08 -0700108};
109
110} // namespace nfd
111
Alexander Afanasyev613e2a92014-04-15 13:36:58 -0700112#endif // NFD_DAEMON_MGMT_FIB_MANAGER_HPP