Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Alexander Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 3 | * 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 DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 24 | |
| 25 | #include "fib-manager.hpp" |
| 26 | |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 27 | #include "core/logger.hpp" |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 28 | #include "table/fib.hpp" |
| 29 | #include "fw/forwarder.hpp" |
| 30 | #include "mgmt/internal-face.hpp" |
| 31 | #include "mgmt/app-face.hpp" |
| 32 | |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 33 | #include <ndn-cpp-dev/encoding/tlv.hpp> |
| 34 | |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 35 | namespace nfd { |
| 36 | |
| 37 | NFD_LOG_INIT("FibManager"); |
| 38 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 39 | const Name FibManager::COMMAND_PREFIX = "/localhost/nfd/fib"; |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 40 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 41 | const size_t FibManager::COMMAND_UNSIGNED_NCOMPS = |
| 42 | FibManager::COMMAND_PREFIX.size() + |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 43 | 1 + // verb |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 44 | 1; // verb parameters |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 45 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 46 | const size_t FibManager::COMMAND_SIGNED_NCOMPS = |
| 47 | FibManager::COMMAND_UNSIGNED_NCOMPS + |
| 48 | 4; // (timestamp, nonce, signed info tlv, signature tlv) |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 49 | |
Steve DiBenedetto | 6214e56 | 2014-03-15 16:27:04 -0600 | [diff] [blame] | 50 | const FibManager::SignedVerbAndProcessor FibManager::SIGNED_COMMAND_VERBS[] = |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 51 | { |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 52 | |
Steve DiBenedetto | 6214e56 | 2014-03-15 16:27:04 -0600 | [diff] [blame] | 53 | SignedVerbAndProcessor( |
| 54 | Name::Component("add-nexthop"), |
| 55 | &FibManager::addNextHop |
| 56 | ), |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 57 | |
Steve DiBenedetto | 6214e56 | 2014-03-15 16:27:04 -0600 | [diff] [blame] | 58 | SignedVerbAndProcessor( |
| 59 | Name::Component("remove-nexthop"), |
| 60 | &FibManager::removeNextHop |
| 61 | ), |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 62 | |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 63 | }; |
| 64 | |
Steve DiBenedetto | 6214e56 | 2014-03-15 16:27:04 -0600 | [diff] [blame] | 65 | const FibManager::UnsignedVerbAndProcessor FibManager::UNSIGNED_COMMAND_VERBS[] = |
| 66 | { |
| 67 | UnsignedVerbAndProcessor( |
| 68 | Name::Component("list"), |
| 69 | &FibManager::listEntries |
| 70 | ), |
| 71 | }; |
| 72 | |
| 73 | const Name FibManager::LIST_COMMAND_PREFIX("/localhost/nfd/fib/list"); |
| 74 | const size_t FibManager::LIST_COMMAND_NCOMPS = LIST_COMMAND_PREFIX.size(); |
| 75 | |
| 76 | |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 77 | FibManager::FibManager(Fib& fib, |
Steve DiBenedetto | 3970c89 | 2014-01-31 23:31:13 -0700 | [diff] [blame] | 78 | function<shared_ptr<Face>(FaceId)> getFace, |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 79 | shared_ptr<InternalFace> face) |
Steve DiBenedetto | 6214e56 | 2014-03-15 16:27:04 -0600 | [diff] [blame] | 80 | : ManagerBase(face, FIB_PRIVILEGE) |
| 81 | , m_managedFib(fib) |
| 82 | , m_getFace(getFace) |
| 83 | , m_fibEnumerationPublisher(fib, face, LIST_COMMAND_PREFIX) |
| 84 | , m_signedVerbDispatch(SIGNED_COMMAND_VERBS, |
| 85 | SIGNED_COMMAND_VERBS + |
| 86 | (sizeof(SIGNED_COMMAND_VERBS) / sizeof(SignedVerbAndProcessor))) |
| 87 | , m_unsignedVerbDispatch(UNSIGNED_COMMAND_VERBS, |
| 88 | UNSIGNED_COMMAND_VERBS + |
| 89 | (sizeof(UNSIGNED_COMMAND_VERBS) / sizeof(UnsignedVerbAndProcessor))) |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 90 | { |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 91 | face->setInterestFilter("/localhost/nfd/fib", |
| 92 | bind(&FibManager::onFibRequest, this, _2)); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 93 | } |
| 94 | |
Steve DiBenedetto | d030cfc | 2014-03-10 20:04:47 -0600 | [diff] [blame] | 95 | FibManager::~FibManager() |
| 96 | { |
| 97 | |
| 98 | } |
| 99 | |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 100 | void |
| 101 | FibManager::onFibRequest(const Interest& request) |
| 102 | { |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 103 | const Name& command = request.getName(); |
| 104 | const size_t commandNComps = command.size(); |
Steve DiBenedetto | 6214e56 | 2014-03-15 16:27:04 -0600 | [diff] [blame] | 105 | const Name::Component& verb = command.get(COMMAND_PREFIX.size()); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 106 | |
Steve DiBenedetto | 6214e56 | 2014-03-15 16:27:04 -0600 | [diff] [blame] | 107 | UnsignedVerbDispatchTable::const_iterator unsignedVerbProcessor = m_unsignedVerbDispatch.find(verb); |
| 108 | if (unsignedVerbProcessor != m_unsignedVerbDispatch.end()) |
| 109 | { |
Alexander Afanasyev | bf9edee | 2014-03-31 23:05:27 -0700 | [diff] [blame] | 110 | NFD_LOG_DEBUG("command result: processing verb: " << verb); |
Steve DiBenedetto | 6214e56 | 2014-03-15 16:27:04 -0600 | [diff] [blame] | 111 | (unsignedVerbProcessor->second)(this, boost::cref(request)); |
| 112 | } |
| 113 | else if (COMMAND_UNSIGNED_NCOMPS <= commandNComps && |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 114 | commandNComps < COMMAND_SIGNED_NCOMPS) |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 115 | { |
Alexander Afanasyev | bf9edee | 2014-03-31 23:05:27 -0700 | [diff] [blame] | 116 | NFD_LOG_DEBUG("command result: unsigned verb: " << command); |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 117 | sendResponse(command, 401, "Signature required"); |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 118 | } |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 119 | else if (commandNComps < COMMAND_SIGNED_NCOMPS || |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 120 | !COMMAND_PREFIX.isPrefixOf(command)) |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 121 | { |
Alexander Afanasyev | bf9edee | 2014-03-31 23:05:27 -0700 | [diff] [blame] | 122 | NFD_LOG_DEBUG("command result: malformed"); |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 123 | sendResponse(command, 400, "Malformed command"); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 124 | } |
Steve DiBenedetto | 6214e56 | 2014-03-15 16:27:04 -0600 | [diff] [blame] | 125 | else |
| 126 | { |
| 127 | validate(request, |
| 128 | bind(&FibManager::onValidatedFibRequest, this, _1), |
| 129 | bind(&ManagerBase::onCommandValidationFailed, this, _1, _2)); |
| 130 | } |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | void |
| 134 | FibManager::onValidatedFibRequest(const shared_ptr<const Interest>& request) |
| 135 | { |
| 136 | const Name& command = request->getName(); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 137 | const Name::Component& verb = command[COMMAND_PREFIX.size()]; |
| 138 | const Name::Component& parameterComponent = command[COMMAND_PREFIX.size() + 1]; |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 139 | |
Alexander Afanasyev | 20d3144 | 2014-04-19 17:00:53 -0700 | [diff] [blame^] | 140 | SignedVerbDispatchTable::const_iterator verbProcessor = m_signedVerbDispatch.find(verb); |
| 141 | if (verbProcessor != m_signedVerbDispatch.end()) |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 142 | { |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 143 | ControlParameters parameters; |
Steve DiBenedetto | 51d242a | 2014-03-31 13:46:43 -0600 | [diff] [blame] | 144 | if (!extractParameters(parameterComponent, parameters) || !parameters.hasFaceId()) |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 145 | { |
Alexander Afanasyev | bf9edee | 2014-03-31 23:05:27 -0700 | [diff] [blame] | 146 | NFD_LOG_DEBUG("command result: malformed verb: " << verb); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 147 | sendResponse(command, 400, "Malformed command"); |
| 148 | return; |
| 149 | } |
| 150 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 151 | if (parameters.getFaceId() == 0) |
| 152 | { |
| 153 | parameters.setFaceId(request->getIncomingFaceId()); |
| 154 | } |
| 155 | |
Alexander Afanasyev | bf9edee | 2014-03-31 23:05:27 -0700 | [diff] [blame] | 156 | NFD_LOG_DEBUG("command result: processing verb: " << verb); |
Alexander Afanasyev | d482fd3 | 2014-02-09 23:40:20 -0800 | [diff] [blame] | 157 | ControlResponse response; |
Alexander Afanasyev | 20d3144 | 2014-04-19 17:00:53 -0700 | [diff] [blame^] | 158 | (verbProcessor->second)(this, parameters, response); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 159 | sendResponse(command, response); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 160 | } |
| 161 | else |
| 162 | { |
Alexander Afanasyev | bf9edee | 2014-03-31 23:05:27 -0700 | [diff] [blame] | 163 | NFD_LOG_DEBUG("command result: unsupported verb: " << verb); |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 164 | sendResponse(command, 501, "Unsupported command"); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 165 | } |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 166 | } |
| 167 | |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 168 | void |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 169 | FibManager::addNextHop(ControlParameters& parameters, |
Alexander Afanasyev | d482fd3 | 2014-02-09 23:40:20 -0800 | [diff] [blame] | 170 | ControlResponse& response) |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 171 | { |
Steve DiBenedetto | 51d242a | 2014-03-31 13:46:43 -0600 | [diff] [blame] | 172 | ndn::nfd::FibAddNextHopCommand command; |
| 173 | |
| 174 | if (!validateParameters(command, parameters)) |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 175 | { |
Alexander Afanasyev | bf9edee | 2014-03-31 23:05:27 -0700 | [diff] [blame] | 176 | NFD_LOG_DEBUG("add-nexthop result: FAIL reason: malformed"); |
Steve DiBenedetto | 51d242a | 2014-03-31 13:46:43 -0600 | [diff] [blame] | 177 | setResponse(response, 400, "Malformed command"); |
| 178 | return; |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 179 | } |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 180 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 181 | const Name& prefix = parameters.getName(); |
| 182 | FaceId faceId = parameters.getFaceId(); |
| 183 | uint64_t cost = parameters.getCost(); |
| 184 | |
Alexander Afanasyev | bf9edee | 2014-03-31 23:05:27 -0700 | [diff] [blame] | 185 | NFD_LOG_TRACE("add-nexthop prefix: " << prefix |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 186 | << " faceid: " << faceId |
| 187 | << " cost: " << cost); |
| 188 | |
| 189 | shared_ptr<Face> nextHopFace = m_getFace(faceId); |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 190 | if (static_cast<bool>(nextHopFace)) |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 191 | { |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 192 | shared_ptr<fib::Entry> entry = m_managedFib.insert(prefix).first; |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 193 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 194 | entry->addNextHop(nextHopFace, cost); |
Steve DiBenedetto | d030cfc | 2014-03-10 20:04:47 -0600 | [diff] [blame] | 195 | |
Alexander Afanasyev | bf9edee | 2014-03-31 23:05:27 -0700 | [diff] [blame] | 196 | NFD_LOG_DEBUG("add-nexthop result: OK" |
| 197 | << " prefix:" << prefix |
| 198 | << " faceid: " << faceId |
| 199 | << " cost: " << cost); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 200 | |
| 201 | setResponse(response, 200, "Success", parameters.wireEncode()); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 202 | } |
| 203 | else |
| 204 | { |
Alexander Afanasyev | bf9edee | 2014-03-31 23:05:27 -0700 | [diff] [blame] | 205 | NFD_LOG_DEBUG("add-nexthop result: FAIL reason: unknown-faceid: " << faceId); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 206 | setResponse(response, 410, "Face not found"); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 207 | } |
| 208 | } |
| 209 | |
| 210 | void |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 211 | FibManager::removeNextHop(ControlParameters& parameters, |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 212 | ControlResponse& response) |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 213 | { |
Steve DiBenedetto | 51d242a | 2014-03-31 13:46:43 -0600 | [diff] [blame] | 214 | ndn::nfd::FibRemoveNextHopCommand command; |
| 215 | if (!validateParameters(command, parameters)) |
| 216 | { |
Alexander Afanasyev | bf9edee | 2014-03-31 23:05:27 -0700 | [diff] [blame] | 217 | NFD_LOG_DEBUG("remove-nexthop result: FAIL reason: malformed"); |
Steve DiBenedetto | 51d242a | 2014-03-31 13:46:43 -0600 | [diff] [blame] | 218 | setResponse(response, 400, "Malformed command"); |
| 219 | return; |
| 220 | } |
| 221 | |
Alexander Afanasyev | bf9edee | 2014-03-31 23:05:27 -0700 | [diff] [blame] | 222 | NFD_LOG_TRACE("remove-nexthop prefix: " << parameters.getName() |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 223 | << " faceid: " << parameters.getFaceId()); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 224 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 225 | shared_ptr<Face> faceToRemove = m_getFace(parameters.getFaceId()); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 226 | if (static_cast<bool>(faceToRemove)) |
| 227 | { |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 228 | shared_ptr<fib::Entry> entry = m_managedFib.findExactMatch(parameters.getName()); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 229 | if (static_cast<bool>(entry)) |
| 230 | { |
| 231 | entry->removeNextHop(faceToRemove); |
Alexander Afanasyev | bf9edee | 2014-03-31 23:05:27 -0700 | [diff] [blame] | 232 | NFD_LOG_DEBUG("remove-nexthop result: OK prefix: " << parameters.getName() |
| 233 | << " faceid: " << parameters.getFaceId()); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 234 | |
Steve DiBenedetto | d030cfc | 2014-03-10 20:04:47 -0600 | [diff] [blame] | 235 | if (!entry->hasNextHops()) |
| 236 | { |
| 237 | m_managedFib.erase(*entry); |
| 238 | } |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 239 | } |
Alexander Afanasyev | bf9edee | 2014-03-31 23:05:27 -0700 | [diff] [blame] | 240 | else |
| 241 | { |
| 242 | NFD_LOG_DEBUG("remove-nexthop result: OK, but entry for face id " |
| 243 | << parameters.getFaceId() << " not found"); |
| 244 | } |
| 245 | } |
| 246 | else |
| 247 | { |
| 248 | NFD_LOG_DEBUG("remove-nexthop result: OK, but face id " |
| 249 | << parameters.getFaceId() << " not found"); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 250 | } |
Steve DiBenedetto | 51d242a | 2014-03-31 13:46:43 -0600 | [diff] [blame] | 251 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 252 | setResponse(response, 200, "Success", parameters.wireEncode()); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 253 | } |
| 254 | |
Steve DiBenedetto | 6214e56 | 2014-03-15 16:27:04 -0600 | [diff] [blame] | 255 | void |
| 256 | FibManager::listEntries(const Interest& request) |
| 257 | { |
| 258 | const Name& command = request.getName(); |
| 259 | const size_t commandNComps = command.size(); |
| 260 | |
| 261 | if (commandNComps < LIST_COMMAND_NCOMPS || |
| 262 | !LIST_COMMAND_PREFIX.isPrefixOf(command)) |
| 263 | { |
Alexander Afanasyev | bf9edee | 2014-03-31 23:05:27 -0700 | [diff] [blame] | 264 | NFD_LOG_DEBUG("command result: malformed"); |
Steve DiBenedetto | 6214e56 | 2014-03-15 16:27:04 -0600 | [diff] [blame] | 265 | sendResponse(command, 400, "Malformed command"); |
| 266 | return; |
| 267 | } |
| 268 | |
| 269 | m_fibEnumerationPublisher.publish(); |
| 270 | } |
| 271 | |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 272 | } // namespace nfd |