Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Nick Gordon | c6a8522 | 2017-01-03 16:54:34 -0600 | [diff] [blame] | 3 | * Copyright (c) 2014-2017, The University of Memphis, |
Junxiao Shi | 3e5120c | 2016-09-10 16:58:34 +0000 | [diff] [blame] | 4 | * Regents of the University of California, |
| 5 | * Arizona Board of Regents. |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 6 | * |
| 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 Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 20 | **/ |
| 21 | |
| 22 | #ifndef NLSR_TEST_CONTROL_COMMANDS_HPP |
| 23 | #define NLSR_TEST_CONTROL_COMMANDS_HPP |
| 24 | |
| 25 | #include <ndn-cxx/interest.hpp> |
Junxiao Shi | 3e5120c | 2016-09-10 16:58:34 +0000 | [diff] [blame] | 26 | #include <ndn-cxx/mgmt/nfd/control-parameters.hpp> |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 27 | |
| 28 | namespace nlsr { |
| 29 | namespace test { |
| 30 | |
| 31 | inline void |
| 32 | extractParameters(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 | |
| 45 | inline void |
| 46 | extractRibCommandParameters(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 Lehman | 27f1add | 2014-10-16 17:14:46 -0500 | [diff] [blame] | 52 | inline void |
| 53 | extractFaceCommandParameters(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 Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 59 | } // namespace test |
| 60 | } // namespace nlsr |
| 61 | |
| 62 | #endif // NLSR_TEST_CONTROL_COMMANDS_HPP |