blob: 4215c89326cfcbf3d44bf3631d8d82fd00b57f43 [file] [log] [blame]
Vince Lehman942eb7b2014-10-02 10:09:27 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Nick Gordonc6a85222017-01-03 16:54:34 -06003 * Copyright (c) 2014-2017, The University of Memphis,
Junxiao Shi3e5120c2016-09-10 16:58:34 +00004 * Regents of the University of California,
5 * Arizona Board of Regents.
Vince Lehman942eb7b2014-10-02 10:09:27 -05006 *
7 * This file is part of NLSR (Named-data Link State Routing).
8 * See AUTHORS.md for complete list of NLSR authors and contributors.
9 *
10 * NLSR is free software: you can redistribute it and/or modify it under the terms
11 * of the GNU General Public License as published by the Free Software Foundation,
12 * either version 3 of the License, or (at your option) any later version.
13 *
14 * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 * PURPOSE. See the GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along with
19 * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
Vince Lehman942eb7b2014-10-02 10:09:27 -050020 **/
21
22#ifndef NLSR_TEST_CONTROL_COMMANDS_HPP
23#define NLSR_TEST_CONTROL_COMMANDS_HPP
24
25#include <ndn-cxx/interest.hpp>
Junxiao Shi3e5120c2016-09-10 16:58:34 +000026#include <ndn-cxx/mgmt/nfd/control-parameters.hpp>
Vince Lehman942eb7b2014-10-02 10:09:27 -050027
28namespace nlsr {
29namespace test {
30
31inline void
32extractParameters(const ndn::Interest& interest,
33 ndn::Name::Component& verb,
34 ndn::nfd::ControlParameters& extractedParameters,
35 const ndn::Name& commandPrefix)
36{
37 const ndn::Name& name = interest.getName();
38 verb = name[commandPrefix.size()];
39 const ndn::Name::Component& parameterComponent = name[commandPrefix.size() + 1];
40
41 ndn::Block rawParameters = parameterComponent.blockFromValue();
42 extractedParameters.wireDecode(rawParameters);
43}
44
45inline void
46extractRibCommandParameters(const ndn::Interest& interest, ndn::Name::Component& verb,
47 ndn::nfd::ControlParameters& extractedParameters)
48{
49 extractParameters(interest, verb, extractedParameters, ndn::Name("/localhost/nfd/rib"));
50}
51
Vince Lehman27f1add2014-10-16 17:14:46 -050052inline void
53extractFaceCommandParameters(const ndn::Interest& interest, ndn::Name::Component& verb,
54 ndn::nfd::ControlParameters& extractedParameters)
55{
56 extractParameters(interest, verb, extractedParameters, ndn::Name("/localhost/nfd/faces"));
57}
58
Vince Lehman942eb7b2014-10-02 10:09:27 -050059} // namespace test
60} // namespace nlsr
61
62#endif // NLSR_TEST_CONTROL_COMMANDS_HPP