Alexander Afanasyev | 4a77136 | 2014-04-24 21:29:33 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 2 | /** |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 3 | * Copyright (c) 2014-2015, 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 | * The University of Memphis. |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 10 | * |
Alexander Afanasyev | 4a77136 | 2014-04-24 21:29:33 -0700 | [diff] [blame] | 11 | * This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 12 | * See AUTHORS.md for complete list of NFD authors and contributors. |
| 13 | * |
| 14 | * NFD is free software: you can redistribute it and/or modify it under the terms |
| 15 | * of the GNU General Public License as published by the Free Software Foundation, |
| 16 | * either version 3 of the License, or (at your option) any later version. |
| 17 | * |
| 18 | * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 19 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 | * PURPOSE. See the GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License along with |
| 23 | * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 24 | * |
| 25 | * @author Jerald Paul Abraham <jeraldabraham@email.arizona.edu> |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 26 | */ |
| 27 | |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 28 | #include "version.hpp" |
| 29 | |
Alexander Afanasyev | 4a77136 | 2014-04-24 21:29:33 -0700 | [diff] [blame] | 30 | #include <ndn-cxx/face.hpp> |
| 31 | #include <ndn-cxx/name.hpp> |
| 32 | #include <ndn-cxx/interest.hpp> |
Alexander Afanasyev | b3893c9 | 2014-05-15 01:49:54 -0700 | [diff] [blame] | 33 | #include <ndn-cxx/encoding/buffer-stream.hpp> |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 34 | |
Alexander Afanasyev | 4a77136 | 2014-04-24 21:29:33 -0700 | [diff] [blame] | 35 | #include <ndn-cxx/management/nfd-forwarder-status.hpp> |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 36 | #include <ndn-cxx/management/nfd-channel-status.hpp> |
| 37 | #include <ndn-cxx/management/nfd-face-status.hpp> |
| 38 | #include <ndn-cxx/management/nfd-fib-entry.hpp> |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 39 | #include <ndn-cxx/management/nfd-rib-entry.hpp> |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 40 | #include <ndn-cxx/management/nfd-strategy-choice.hpp> |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 41 | #include <ndn-cxx/util/segment-fetcher.hpp> |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 42 | |
Alexander Afanasyev | b3893c9 | 2014-05-15 01:49:54 -0700 | [diff] [blame] | 43 | #include <boost/algorithm/string/replace.hpp> |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 44 | #include <list> |
Alexander Afanasyev | b3893c9 | 2014-05-15 01:49:54 -0700 | [diff] [blame] | 45 | |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 46 | namespace ndn { |
| 47 | |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 48 | using util::SegmentFetcher; |
| 49 | |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 50 | class NfdStatus |
| 51 | { |
| 52 | public: |
Alexander Afanasyev | 7b7dfdd | 2014-03-21 13:57:54 -0700 | [diff] [blame] | 53 | explicit |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 54 | NfdStatus(char* toolName) |
| 55 | : m_toolName(toolName) |
| 56 | , m_needVersionRetrieval(false) |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 57 | , m_needChannelStatusRetrieval(false) |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 58 | , m_needFaceStatusRetrieval(false) |
| 59 | , m_needFibEnumerationRetrieval(false) |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 60 | , m_needRibStatusRetrieval(false) |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 61 | , m_needStrategyChoiceRetrieval(false) |
| 62 | , m_isOutputXml(false) |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 63 | { |
| 64 | } |
| 65 | |
| 66 | void |
| 67 | usage() |
| 68 | { |
Alexander Afanasyev | 60a7ba5 | 2014-03-23 11:23:06 -0700 | [diff] [blame] | 69 | std::cout << "Usage: \n " << m_toolName << " [options]\n\n" |
| 70 | "Show NFD version and status information\n\n" |
| 71 | "Options:\n" |
| 72 | " [-h] - print this help message\n" |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 73 | " [-v] - retrieve version information\n" |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 74 | " [-c] - retrieve channel status information\n" |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 75 | " [-f] - retrieve face status information\n" |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 76 | " [-b] - retrieve FIB information\n" |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 77 | " [-r] - retrieve RIB information\n" |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 78 | " [-s] - retrieve configured strategy choice for NDN namespaces\n" |
Chengyu Fan | ee92fc7 | 2014-06-21 14:58:19 -0600 | [diff] [blame] | 79 | " [-x] - output NFD status information in XML format\n" |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 80 | "\n" |
| 81 | " [-V] - show version information of nfd-status and exit\n" |
| 82 | "\n" |
Alexander Afanasyev | 60a7ba5 | 2014-03-23 11:23:06 -0700 | [diff] [blame] | 83 | "If no options are provided, all information is retrieved.\n" |
Chengyu Fan | ee92fc7 | 2014-06-21 14:58:19 -0600 | [diff] [blame] | 84 | "If -x is provided, other options(-v, -c, etc.) are ignored, and all information is printed in XML format.\n" |
Alexander Afanasyev | 60a7ba5 | 2014-03-23 11:23:06 -0700 | [diff] [blame] | 85 | ; |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | void |
| 89 | enableVersionRetrieval() |
| 90 | { |
| 91 | m_needVersionRetrieval = true; |
| 92 | } |
| 93 | |
| 94 | void |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 95 | enableChannelStatusRetrieval() |
| 96 | { |
| 97 | m_needChannelStatusRetrieval = true; |
| 98 | } |
| 99 | |
| 100 | void |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 101 | enableFaceStatusRetrieval() |
| 102 | { |
| 103 | m_needFaceStatusRetrieval = true; |
| 104 | } |
| 105 | |
| 106 | void |
| 107 | enableFibEnumerationRetrieval() |
| 108 | { |
| 109 | m_needFibEnumerationRetrieval = true; |
| 110 | } |
| 111 | |
| 112 | void |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 113 | enableStrategyChoiceRetrieval() |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 114 | { |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 115 | m_needStrategyChoiceRetrieval = true; |
| 116 | } |
| 117 | |
| 118 | void |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 119 | enableRibStatusRetrieval() |
| 120 | { |
| 121 | m_needRibStatusRetrieval = true; |
| 122 | } |
| 123 | |
| 124 | void |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 125 | enableXmlOutput() |
| 126 | { |
| 127 | m_isOutputXml = true; |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | void |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 131 | onTimeout() |
| 132 | { |
| 133 | std::cerr << "Request timed out" << std::endl; |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 134 | |
| 135 | runNextStep(); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 136 | } |
| 137 | |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 138 | |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 139 | void |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 140 | onErrorFetch(uint32_t errorCode, const std::string& errorMsg) |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 141 | { |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 142 | std::cerr << "Error code:" << errorCode << ", message:" << errorMsg << std::endl; |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 143 | |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 144 | runNextStep(); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 145 | } |
| 146 | |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 147 | void |
| 148 | escapeSpecialCharacters(std::string *data) |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 149 | { |
| 150 | using boost::algorithm::replace_all; |
| 151 | replace_all(*data, "&", "&"); |
| 152 | replace_all(*data, "\"", """); |
| 153 | replace_all(*data, "\'", "'"); |
| 154 | replace_all(*data, "<", "<"); |
| 155 | replace_all(*data, ">", ">"); |
| 156 | } |
| 157 | |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 158 | ////////////////////////////////////////////////////////////////////////////////// |
| 159 | ////////////////////////////////////////////////////////////////////////////////// |
| 160 | |
| 161 | void |
| 162 | fetchVersionInformation() |
| 163 | { |
| 164 | Interest interest("/localhost/nfd/status"); |
| 165 | interest.setChildSelector(1); |
| 166 | interest.setMustBeFresh(true); |
| 167 | m_face.expressInterest( |
| 168 | interest, |
| 169 | bind(&NfdStatus::afterFetchedVersionInformation, this, _2), |
| 170 | bind(&NfdStatus::onTimeout, this)); |
| 171 | } |
| 172 | |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 173 | void |
| 174 | afterFetchedVersionInformation(const Data& data) |
| 175 | { |
Junxiao Shi | 88d6937 | 2014-03-28 11:52:39 -0700 | [diff] [blame] | 176 | nfd::ForwarderStatus status(data.getContent()); |
Chengyu Fan | 8a53caf | 2014-08-01 14:08:37 -0600 | [diff] [blame] | 177 | std::string nfdId; |
| 178 | if (data.getSignature().hasKeyLocator()) |
| 179 | { |
| 180 | const ndn::KeyLocator& locator = data.getSignature().getKeyLocator(); |
| 181 | if (locator.getType() == KeyLocator::KeyLocator_Name) |
| 182 | nfdId = locator.getName().toUri(); |
| 183 | //todo: KeyDigest supporting |
| 184 | } |
| 185 | |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 186 | if (m_isOutputXml) |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 187 | { |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 188 | std::cout << "<generalStatus>"; |
Chengyu Fan | 8a53caf | 2014-08-01 14:08:37 -0600 | [diff] [blame] | 189 | std::cout << "<nfdId>" |
| 190 | << nfdId << "</nfdId>"; |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 191 | std::cout << "<version>" |
| 192 | << status.getNfdVersion() << "</version>"; |
| 193 | std::cout << "<startTime>" |
| 194 | << time::toString(status.getStartTimestamp(), "%Y-%m-%dT%H:%M:%S%F") |
| 195 | << "</startTime>"; |
| 196 | std::cout << "<currentTime>" |
| 197 | << time::toString(status.getCurrentTimestamp(), "%Y-%m-%dT%H:%M:%S%F") |
| 198 | << "</currentTime>"; |
| 199 | std::cout << "<uptime>PT" |
| 200 | << time::duration_cast<time::seconds>(status.getCurrentTimestamp() |
| 201 | - status.getStartTimestamp()).count() |
| 202 | << "S</uptime>"; |
| 203 | std::cout << "<nNameTreeEntries>" << status.getNNameTreeEntries() |
| 204 | << "</nNameTreeEntries>"; |
| 205 | std::cout << "<nFibEntries>" << status.getNFibEntries() |
| 206 | << "</nFibEntries>"; |
| 207 | std::cout << "<nPitEntries>" << status.getNPitEntries() |
| 208 | << "</nPitEntries>"; |
| 209 | std::cout << "<nMeasurementsEntries>" << status.getNMeasurementsEntries() |
| 210 | << "</nMeasurementsEntries>"; |
| 211 | std::cout << "<nCsEntries>" << status.getNCsEntries() |
| 212 | << "</nCsEntries>"; |
| 213 | std::cout << "<packetCounters>"; |
| 214 | std::cout << "<incomingPackets>"; |
| 215 | std::cout << "<nInterests>" << status.getNInInterests() |
| 216 | << "</nInterests>"; |
| 217 | std::cout << "<nDatas>" << status.getNInDatas() |
| 218 | << "</nDatas>"; |
| 219 | std::cout << "</incomingPackets>"; |
| 220 | std::cout << "<outgoingPackets>"; |
| 221 | std::cout << "<nInterests>" << status.getNOutInterests() |
| 222 | << "</nInterests>"; |
| 223 | std::cout << "<nDatas>" << status.getNOutDatas() |
| 224 | << "</nDatas>"; |
| 225 | std::cout << "</outgoingPackets>"; |
| 226 | std::cout << "</packetCounters>"; |
| 227 | std::cout << "</generalStatus>"; |
| 228 | } |
| 229 | else |
| 230 | { |
| 231 | std::cout << "General NFD status:" << std::endl; |
Chengyu Fan | 8a53caf | 2014-08-01 14:08:37 -0600 | [diff] [blame] | 232 | std::cout << " nfdId=" |
| 233 | << nfdId << std::endl; |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 234 | std::cout << " version=" |
| 235 | << status.getNfdVersion() << std::endl; |
| 236 | std::cout << " startTime=" |
| 237 | << time::toIsoString(status.getStartTimestamp()) << std::endl; |
| 238 | std::cout << " currentTime=" |
| 239 | << time::toIsoString(status.getCurrentTimestamp()) << std::endl; |
| 240 | std::cout << " uptime=" |
| 241 | << time::duration_cast<time::seconds>(status.getCurrentTimestamp() |
| 242 | - status.getStartTimestamp()) << std::endl; |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 243 | |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 244 | std::cout << " nNameTreeEntries=" << status.getNNameTreeEntries() << std::endl; |
| 245 | std::cout << " nFibEntries=" << status.getNFibEntries() << std::endl; |
| 246 | std::cout << " nPitEntries=" << status.getNPitEntries() << std::endl; |
| 247 | std::cout << " nMeasurementsEntries=" << status.getNMeasurementsEntries() << std::endl; |
| 248 | std::cout << " nCsEntries=" << status.getNCsEntries() << std::endl; |
| 249 | std::cout << " nInInterests=" << status.getNInInterests() << std::endl; |
| 250 | std::cout << " nOutInterests=" << status.getNOutInterests() << std::endl; |
| 251 | std::cout << " nInDatas=" << status.getNInDatas() << std::endl; |
| 252 | std::cout << " nOutDatas=" << status.getNOutDatas() << std::endl; |
| 253 | } |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 254 | |
| 255 | runNextStep(); |
| 256 | } |
| 257 | |
| 258 | ////////////////////////////////////////////////////////////////////////////////// |
| 259 | ////////////////////////////////////////////////////////////////////////////////// |
| 260 | |
| 261 | void |
| 262 | fetchChannelStatusInformation() |
| 263 | { |
| 264 | m_buffer = make_shared<OBufferStream>(); |
| 265 | |
| 266 | Interest interest("/localhost/nfd/faces/channels"); |
| 267 | interest.setChildSelector(1); |
| 268 | interest.setMustBeFresh(true); |
| 269 | |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 270 | SegmentFetcher::fetch(m_face, interest, |
| 271 | util::DontVerifySegment(), |
| 272 | bind(&NfdStatus::afterFetchedChannelStatusInformation, this, _1), |
| 273 | bind(&NfdStatus::onErrorFetch, this, _1, _2)); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | void |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 277 | afterFetchedChannelStatusInformation(const ConstBufferPtr& dataset) |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 278 | { |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 279 | if (m_isOutputXml) { |
| 280 | std::cout << "<channels>"; |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 281 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 282 | size_t offset = 0; |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 283 | while (offset < dataset->size()) { |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 284 | bool isOk = false; |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 285 | Block block; |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 286 | std::tie(isOk, block) = Block::fromBuffer(dataset, offset); |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 287 | if (!isOk) { |
| 288 | std::cerr << "ERROR: cannot decode ChannelStatus TLV" << std::endl; |
| 289 | break; |
| 290 | } |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 291 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 292 | offset += block.size(); |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 293 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 294 | nfd::ChannelStatus channelStatus(block); |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 295 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 296 | std::cout << "<channel>"; |
| 297 | std::string localUri(channelStatus.getLocalUri()); |
| 298 | escapeSpecialCharacters(&localUri); |
| 299 | std::cout << "<localUri>" << localUri << "</localUri>"; |
| 300 | std::cout << "</channel>"; |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 301 | } |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 302 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 303 | std::cout << "</channels>"; |
| 304 | } |
| 305 | else { |
| 306 | std::cout << "Channels:" << std::endl; |
| 307 | |
| 308 | size_t offset = 0; |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 309 | while (offset < dataset->size()) { |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 310 | bool isOk = false; |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 311 | Block block; |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 312 | std::tie(isOk, block) = Block::fromBuffer(dataset, offset); |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 313 | if (!isOk) { |
| 314 | std::cerr << "ERROR: cannot decode ChannelStatus TLV" << std::endl; |
| 315 | break; |
| 316 | } |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 317 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 318 | offset += block.size(); |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 319 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 320 | nfd::ChannelStatus channelStatus(block); |
| 321 | std::cout << " " << channelStatus.getLocalUri() << std::endl; |
| 322 | } |
| 323 | } |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 324 | |
| 325 | runNextStep(); |
| 326 | } |
| 327 | |
| 328 | ////////////////////////////////////////////////////////////////////////////////// |
| 329 | ////////////////////////////////////////////////////////////////////////////////// |
| 330 | |
| 331 | void |
| 332 | fetchFaceStatusInformation() |
| 333 | { |
| 334 | m_buffer = make_shared<OBufferStream>(); |
| 335 | |
| 336 | Interest interest("/localhost/nfd/faces/list"); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 337 | interest.setChildSelector(1); |
| 338 | interest.setMustBeFresh(true); |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 339 | |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 340 | SegmentFetcher::fetch(m_face, interest, |
| 341 | util::DontVerifySegment(), |
| 342 | bind(&NfdStatus::afterFetchedFaceStatusInformation, this, _1), |
| 343 | bind(&NfdStatus::onErrorFetch, this, _1, _2)); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | void |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 347 | afterFetchedFaceStatusInformation(const ConstBufferPtr& dataset) |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 348 | { |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 349 | if (m_isOutputXml) { |
| 350 | std::cout << "<faces>"; |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 351 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 352 | size_t offset = 0; |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 353 | while (offset < dataset->size()) { |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 354 | bool isOk = false; |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 355 | Block block; |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 356 | std::tie(isOk, block) = Block::fromBuffer(dataset, offset); |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 357 | if (!isOk) { |
| 358 | std::cerr << "ERROR: cannot decode FaceStatus TLV" << std::endl; |
| 359 | break; |
| 360 | } |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 361 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 362 | offset += block.size(); |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 363 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 364 | nfd::FaceStatus faceStatus(block); |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 365 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 366 | std::cout << "<face>"; |
| 367 | std::cout << "<faceId>" << faceStatus.getFaceId() << "</faceId>"; |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 368 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 369 | std::string remoteUri(faceStatus.getRemoteUri()); |
| 370 | escapeSpecialCharacters(&remoteUri); |
| 371 | std::cout << "<remoteUri>" << remoteUri << "</remoteUri>"; |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 372 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 373 | std::string localUri(faceStatus.getLocalUri()); |
| 374 | escapeSpecialCharacters(&localUri); |
| 375 | std::cout << "<localUri>" << localUri << "</localUri>"; |
Alexander Afanasyev | 40c61f7 | 2014-06-30 17:21:01 -0700 | [diff] [blame] | 376 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 377 | if (faceStatus.hasExpirationPeriod()) { |
| 378 | std::cout << "<expirationPeriod>PT" |
| 379 | << time::duration_cast<time::seconds>(faceStatus.getExpirationPeriod()) |
| 380 | .count() << "S" |
| 381 | << "</expirationPeriod>"; |
| 382 | } |
Alexander Afanasyev | 40c61f7 | 2014-06-30 17:21:01 -0700 | [diff] [blame] | 383 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 384 | std::cout << "<faceScope>" << faceStatus.getFaceScope() |
| 385 | << "</faceScope>"; |
| 386 | std::cout << "<facePersistency>" << faceStatus.getFacePersistency() |
| 387 | << "</facePersistency>"; |
| 388 | std::cout << "<linkType>" << faceStatus.getLinkType() |
| 389 | << "</linkType>"; |
Chengyu Fan | 27d570a | 2014-10-09 11:52:17 -0600 | [diff] [blame] | 390 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 391 | std::cout << "<packetCounters>"; |
| 392 | std::cout << "<incomingPackets>"; |
| 393 | std::cout << "<nInterests>" << faceStatus.getNInInterests() |
| 394 | << "</nInterests>"; |
| 395 | std::cout << "<nDatas>" << faceStatus.getNInDatas() |
| 396 | << "</nDatas>"; |
| 397 | std::cout << "</incomingPackets>"; |
| 398 | std::cout << "<outgoingPackets>"; |
| 399 | std::cout << "<nInterests>" << faceStatus.getNOutInterests() |
| 400 | << "</nInterests>"; |
| 401 | std::cout << "<nDatas>" << faceStatus.getNOutDatas() |
| 402 | << "</nDatas>"; |
| 403 | std::cout << "</outgoingPackets>"; |
| 404 | std::cout << "</packetCounters>"; |
Alexander Afanasyev | d3967a2 | 2014-06-30 12:22:10 -0700 | [diff] [blame] | 405 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 406 | std::cout << "<byteCounters>"; |
| 407 | std::cout << "<incomingBytes>" << faceStatus.getNInBytes() |
| 408 | << "</incomingBytes>"; |
| 409 | std::cout << "<outgoingBytes>" << faceStatus.getNOutBytes() |
| 410 | << "</outgoingBytes>"; |
| 411 | std::cout << "</byteCounters>"; |
Chengyu Fan | 3331cfa | 2014-07-25 17:36:31 -0600 | [diff] [blame] | 412 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 413 | std::cout << "</face>"; |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 414 | } |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 415 | std::cout << "</faces>"; |
| 416 | } |
| 417 | else { |
| 418 | std::cout << "Faces:" << std::endl; |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 419 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 420 | size_t offset = 0; |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 421 | while (offset < dataset->size()) { |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 422 | bool isOk = false; |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 423 | Block block; |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 424 | std::tie(isOk, block) = Block::fromBuffer(dataset, offset); |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 425 | if (!isOk) { |
| 426 | std::cerr << "ERROR: cannot decode FaceStatus TLV" << std::endl; |
| 427 | break; |
| 428 | } |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 429 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 430 | offset += block.size(); |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 431 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 432 | nfd::FaceStatus faceStatus(block); |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 433 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 434 | std::cout << " faceid=" << faceStatus.getFaceId() |
| 435 | << " remote=" << faceStatus.getRemoteUri() |
| 436 | << " local=" << faceStatus.getLocalUri(); |
| 437 | if (faceStatus.hasExpirationPeriod()) { |
| 438 | std::cout << " expires=" |
| 439 | << time::duration_cast<time::seconds>(faceStatus.getExpirationPeriod()) |
| 440 | .count() << "s"; |
| 441 | } |
| 442 | std::cout << " counters={" |
| 443 | << "in={" << faceStatus.getNInInterests() << "i " |
| 444 | << faceStatus.getNInDatas() << "d " |
| 445 | << faceStatus.getNInBytes() << "B}" |
| 446 | << " out={" << faceStatus.getNOutInterests() << "i " |
| 447 | << faceStatus.getNOutDatas() << "d " |
| 448 | << faceStatus.getNOutBytes() << "B}" |
| 449 | << "}"; |
| 450 | std::cout << " " << faceStatus.getFaceScope() |
| 451 | << " " << faceStatus.getFacePersistency() |
| 452 | << " " << faceStatus.getLinkType(); |
| 453 | std::cout << std::endl; |
| 454 | } |
| 455 | } |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 456 | |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 457 | runNextStep(); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 458 | } |
| 459 | |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 460 | ////////////////////////////////////////////////////////////////////////////////// |
| 461 | ////////////////////////////////////////////////////////////////////////////////// |
| 462 | |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 463 | void |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 464 | fetchFibEnumerationInformation() |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 465 | { |
| 466 | m_buffer = make_shared<OBufferStream>(); |
| 467 | |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 468 | Interest interest("/localhost/nfd/fib/list"); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 469 | interest.setChildSelector(1); |
| 470 | interest.setMustBeFresh(true); |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 471 | |
| 472 | SegmentFetcher::fetch(m_face, interest, |
| 473 | util::DontVerifySegment(), |
| 474 | bind(&NfdStatus::afterFetchedFibEnumerationInformation, this, _1), |
| 475 | bind(&NfdStatus::onErrorFetch, this, _1, _2)); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | void |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 479 | afterFetchedFibEnumerationInformation(const ConstBufferPtr& dataset) |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 480 | { |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 481 | if (m_isOutputXml) { |
| 482 | std::cout << "<fib>"; |
Alexander Afanasyev | 7b7dfdd | 2014-03-21 13:57:54 -0700 | [diff] [blame] | 483 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 484 | size_t offset = 0; |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 485 | while (offset < dataset->size()) { |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 486 | bool isOk = false; |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 487 | Block block; |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 488 | std::tie(isOk, block) = Block::fromBuffer(dataset, offset); |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 489 | if (!isOk) { |
| 490 | std::cerr << "ERROR: cannot decode FibEntry TLV"; |
| 491 | break; |
| 492 | } |
| 493 | offset += block.size(); |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 494 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 495 | nfd::FibEntry fibEntry(block); |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 496 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 497 | std::cout << "<fibEntry>"; |
| 498 | std::string prefix(fibEntry.getPrefix().toUri()); |
| 499 | escapeSpecialCharacters(&prefix); |
| 500 | std::cout << "<prefix>" << prefix << "</prefix>"; |
| 501 | std::cout << "<nextHops>"; |
| 502 | for (const nfd::NextHopRecord& nextHop : fibEntry.getNextHopRecords()) { |
| 503 | std::cout << "<nextHop>" ; |
| 504 | std::cout << "<faceId>" << nextHop.getFaceId() << "</faceId>"; |
| 505 | std::cout << "<cost>" << nextHop.getCost() << "</cost>"; |
| 506 | std::cout << "</nextHop>"; |
| 507 | } |
| 508 | std::cout << "</nextHops>"; |
| 509 | std::cout << "</fibEntry>"; |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 510 | } |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 511 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 512 | std::cout << "</fib>"; |
| 513 | } |
| 514 | else { |
| 515 | std::cout << "FIB:" << std::endl; |
| 516 | |
| 517 | size_t offset = 0; |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 518 | while (offset < dataset->size()) { |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 519 | bool isOk = false; |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 520 | Block block; |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 521 | std::tie(isOk, block) = Block::fromBuffer(dataset, offset); |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 522 | if (!isOk) { |
| 523 | std::cerr << "ERROR: cannot decode FibEntry TLV" << std::endl; |
| 524 | break; |
| 525 | } |
| 526 | offset += block.size(); |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 527 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 528 | nfd::FibEntry fibEntry(block); |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 529 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 530 | std::cout << " " << fibEntry.getPrefix() << " nexthops={"; |
| 531 | bool isFirst = true; |
| 532 | for (const nfd::NextHopRecord& nextHop : fibEntry.getNextHopRecords()) { |
| 533 | if (isFirst) |
| 534 | isFirst = false; |
| 535 | else |
| 536 | std::cout << ", "; |
| 537 | |
| 538 | std::cout << "faceid=" << nextHop.getFaceId() |
| 539 | << " (cost=" << nextHop.getCost() << ")"; |
| 540 | } |
| 541 | std::cout << "}" << std::endl; |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 542 | } |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 543 | } |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 544 | |
| 545 | runNextStep(); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 546 | } |
| 547 | |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 548 | ////////////////////////////////////////////////////////////////////////////////// |
| 549 | ////////////////////////////////////////////////////////////////////////////////// |
| 550 | |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 551 | void |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 552 | fetchStrategyChoiceInformation() |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 553 | { |
| 554 | m_buffer = make_shared<OBufferStream>(); |
| 555 | |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 556 | Interest interest("/localhost/nfd/strategy-choice/list"); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 557 | interest.setChildSelector(1); |
| 558 | interest.setMustBeFresh(true); |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 559 | |
| 560 | SegmentFetcher::fetch(m_face, interest, |
| 561 | util::DontVerifySegment(), |
| 562 | bind(&NfdStatus::afterFetchedStrategyChoiceInformationInformation, this, _1), |
| 563 | bind(&NfdStatus::onErrorFetch, this, _1, _2)); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 564 | } |
| 565 | |
| 566 | void |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 567 | afterFetchedStrategyChoiceInformationInformation(const ConstBufferPtr& dataset) |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 568 | { |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 569 | if (m_isOutputXml) { |
| 570 | std::cout << "<strategyChoices>"; |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 571 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 572 | size_t offset = 0; |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 573 | while (offset < dataset->size()) { |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 574 | bool isOk = false; |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 575 | Block block; |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 576 | std::tie(isOk, block) = Block::fromBuffer(dataset, offset); |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 577 | if (!isOk) { |
| 578 | std::cerr << "ERROR: cannot decode StrategyChoice TLV"; |
| 579 | break; |
| 580 | } |
| 581 | offset += block.size(); |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 582 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 583 | nfd::StrategyChoice strategyChoice(block); |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 584 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 585 | std::cout << "<strategyChoice>"; |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 586 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 587 | std::string name(strategyChoice.getName().toUri()); |
| 588 | escapeSpecialCharacters(&name); |
| 589 | std::cout << "<namespace>" << name << "</namespace>"; |
| 590 | std::cout << "<strategy>"; |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 591 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 592 | std::string strategy(strategyChoice.getStrategy().toUri()); |
| 593 | escapeSpecialCharacters(&strategy); |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 594 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 595 | std::cout << "<name>" << strategy << "</name>"; |
| 596 | std::cout << "</strategy>"; |
| 597 | std::cout << "</strategyChoice>"; |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 598 | } |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 599 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 600 | std::cout << "</strategyChoices>"; |
| 601 | } |
| 602 | else { |
| 603 | std::cout << "Strategy choices:" << std::endl; |
| 604 | |
| 605 | size_t offset = 0; |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 606 | while (offset < dataset->size()) { |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 607 | bool isOk = false; |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 608 | Block block; |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 609 | std::tie(isOk, block) = Block::fromBuffer(dataset, offset); |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 610 | if (!isOk) { |
| 611 | std::cerr << "ERROR: cannot decode StrategyChoice TLV" << std::endl; |
| 612 | break; |
| 613 | } |
| 614 | offset += block.size(); |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 615 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 616 | nfd::StrategyChoice strategyChoice(block); |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 617 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 618 | std::cout << " " << strategyChoice.getName() |
| 619 | << " strategy=" << strategyChoice.getStrategy() << std::endl; |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 620 | } |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 621 | } |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 622 | |
| 623 | runNextStep(); |
| 624 | } |
| 625 | |
| 626 | void |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 627 | fetchRibStatusInformation() |
| 628 | { |
| 629 | m_buffer = make_shared<OBufferStream>(); |
| 630 | |
| 631 | Interest interest("/localhost/nfd/rib/list"); |
| 632 | interest.setChildSelector(1); |
| 633 | interest.setMustBeFresh(true); |
| 634 | |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 635 | SegmentFetcher::fetch(m_face, interest, |
| 636 | util::DontVerifySegment(), |
| 637 | bind(&NfdStatus::afterFetchedRibStatusInformation, this, _1), |
| 638 | bind(&NfdStatus::onErrorFetch, this, _1, _2)); |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 639 | } |
| 640 | |
| 641 | void |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 642 | afterFetchedRibStatusInformation(const ConstBufferPtr& dataset) |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 643 | { |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 644 | if (m_isOutputXml) { |
| 645 | std::cout << "<rib>"; |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 646 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 647 | size_t offset = 0; |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 648 | while (offset < dataset->size()) { |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 649 | bool isOk = false; |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 650 | Block block; |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 651 | std::tie(isOk, block) = Block::fromBuffer(dataset, offset); |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 652 | if (!isOk) { |
| 653 | std::cerr << "ERROR: cannot decode RibEntry TLV"; |
| 654 | break; |
| 655 | } |
| 656 | offset += block.size(); |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 657 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 658 | nfd::RibEntry ribEntry(block); |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 659 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 660 | std::cout << "<ribEntry>"; |
| 661 | std::string prefix(ribEntry.getName().toUri()); |
| 662 | escapeSpecialCharacters(&prefix); |
| 663 | std::cout << "<prefix>" << prefix << "</prefix>"; |
| 664 | std::cout << "<routes>"; |
| 665 | for (const nfd::Route& nextRoute : ribEntry) { |
| 666 | std::cout << "<route>" ; |
| 667 | std::cout << "<faceId>" << nextRoute.getFaceId() << "</faceId>"; |
| 668 | std::cout << "<origin>" << nextRoute.getOrigin() << "</origin>"; |
| 669 | std::cout << "<cost>" << nextRoute.getCost() << "</cost>"; |
Chengyu Fan | 1c630ba | 2014-08-20 13:27:58 -0500 | [diff] [blame] | 670 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 671 | std::cout << "<flags>"; |
| 672 | if (nextRoute.isChildInherit()) |
| 673 | std::cout << "<childInherit/>"; |
| 674 | if (nextRoute.isRibCapture()) |
| 675 | std::cout << "<ribCapture/>"; |
| 676 | std::cout << "</flags>"; |
Chengyu Fan | 1c630ba | 2014-08-20 13:27:58 -0500 | [diff] [blame] | 677 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 678 | if (!nextRoute.hasInfiniteExpirationPeriod()) { |
| 679 | std::cout << "<expirationPeriod>PT" |
| 680 | << time::duration_cast<time::seconds>(nextRoute.getExpirationPeriod()) |
| 681 | .count() << "S" |
| 682 | << "</expirationPeriod>"; |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 683 | } |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 684 | std::cout << "</route>"; |
| 685 | } |
| 686 | std::cout << "</routes>"; |
| 687 | std::cout << "</ribEntry>"; |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 688 | } |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 689 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 690 | std::cout << "</rib>"; |
| 691 | } |
| 692 | else { |
| 693 | std::cout << "RIB:" << std::endl; |
| 694 | |
| 695 | size_t offset = 0; |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 696 | while (offset < dataset->size()) { |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 697 | bool isOk = false; |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 698 | Block block; |
Yukai Tu | 971d3c2 | 2015-06-21 12:32:03 +0800 | [diff] [blame] | 699 | std::tie(isOk, block) = Block::fromBuffer(dataset, offset); |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 700 | if (!isOk) { |
| 701 | std::cerr << "ERROR: cannot decode RibEntry TLV" << std::endl; |
| 702 | break; |
| 703 | } |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 704 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 705 | offset += block.size(); |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 706 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 707 | nfd::RibEntry ribEntry(block); |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 708 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 709 | std::cout << " " << ribEntry.getName().toUri() << " route={"; |
| 710 | bool isFirst = true; |
| 711 | for (const nfd::Route& nextRoute : ribEntry) { |
| 712 | if (isFirst) |
| 713 | isFirst = false; |
| 714 | else |
| 715 | std::cout << ", "; |
Chengyu Fan | 1c630ba | 2014-08-20 13:27:58 -0500 | [diff] [blame] | 716 | |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 717 | std::cout << "faceid=" << nextRoute.getFaceId() |
| 718 | << " (origin=" << nextRoute.getOrigin() |
| 719 | << " cost=" << nextRoute.getCost(); |
| 720 | if (!nextRoute.hasInfiniteExpirationPeriod()) { |
| 721 | std::cout << " expires=" |
| 722 | << time::duration_cast<time::seconds>(nextRoute.getExpirationPeriod()) |
| 723 | .count() << "s"; |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 724 | } |
Junxiao Shi | 78926c9 | 2015-02-28 22:56:06 -0700 | [diff] [blame] | 725 | |
| 726 | if (nextRoute.isChildInherit()) |
| 727 | std::cout << " ChildInherit"; |
| 728 | if (nextRoute.isRibCapture()) |
| 729 | std::cout << " RibCapture"; |
| 730 | |
| 731 | std::cout << ")"; |
| 732 | } |
| 733 | std::cout << "}" << std::endl; |
| 734 | } |
| 735 | } |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 736 | |
| 737 | runNextStep(); |
| 738 | } |
| 739 | |
| 740 | |
| 741 | void |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 742 | fetchInformation() |
| 743 | { |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 744 | if (m_isOutputXml || |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 745 | (!m_needVersionRetrieval && |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 746 | !m_needChannelStatusRetrieval && |
| 747 | !m_needFaceStatusRetrieval && |
| 748 | !m_needFibEnumerationRetrieval && |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 749 | !m_needRibStatusRetrieval && |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 750 | !m_needStrategyChoiceRetrieval)) |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 751 | { |
| 752 | enableVersionRetrieval(); |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 753 | enableChannelStatusRetrieval(); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 754 | enableFaceStatusRetrieval(); |
| 755 | enableFibEnumerationRetrieval(); |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 756 | enableRibStatusRetrieval(); |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 757 | enableStrategyChoiceRetrieval(); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 758 | } |
| 759 | |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 760 | if (m_isOutputXml) |
| 761 | m_fetchSteps.push_back(bind(&NfdStatus::printXmlHeader, this)); |
| 762 | |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 763 | if (m_needVersionRetrieval) |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 764 | m_fetchSteps.push_back(bind(&NfdStatus::fetchVersionInformation, this)); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 765 | |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 766 | if (m_needChannelStatusRetrieval) |
| 767 | m_fetchSteps.push_back(bind(&NfdStatus::fetchChannelStatusInformation, this)); |
| 768 | |
| 769 | if (m_needFaceStatusRetrieval) |
| 770 | m_fetchSteps.push_back(bind(&NfdStatus::fetchFaceStatusInformation, this)); |
| 771 | |
| 772 | if (m_needFibEnumerationRetrieval) |
| 773 | m_fetchSteps.push_back(bind(&NfdStatus::fetchFibEnumerationInformation, this)); |
| 774 | |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 775 | if (m_needRibStatusRetrieval) |
| 776 | m_fetchSteps.push_back(bind(&NfdStatus::fetchRibStatusInformation, this)); |
| 777 | |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 778 | if (m_needStrategyChoiceRetrieval) |
| 779 | m_fetchSteps.push_back(bind(&NfdStatus::fetchStrategyChoiceInformation, this)); |
| 780 | |
| 781 | if (m_isOutputXml) |
| 782 | m_fetchSteps.push_back(bind(&NfdStatus::printXmlFooter, this)); |
| 783 | |
| 784 | runNextStep(); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 785 | m_face.processEvents(); |
| 786 | } |
| 787 | |
| 788 | private: |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 789 | void |
| 790 | printXmlHeader() |
| 791 | { |
| 792 | std::cout << "<?xml version=\"1.0\"?>"; |
| 793 | std::cout << "<nfdStatus xmlns=\"ndn:/localhost/nfd/status/1\">"; |
| 794 | |
| 795 | runNextStep(); |
| 796 | } |
| 797 | |
| 798 | void |
| 799 | printXmlFooter() |
| 800 | { |
| 801 | std::cout << "</nfdStatus>"; |
| 802 | |
| 803 | runNextStep(); |
| 804 | } |
| 805 | |
| 806 | void |
| 807 | runNextStep() |
| 808 | { |
| 809 | if (m_fetchSteps.empty()) |
| 810 | return; |
| 811 | |
| 812 | function<void()> nextStep = m_fetchSteps.front(); |
| 813 | m_fetchSteps.pop_front(); |
| 814 | nextStep(); |
| 815 | } |
| 816 | |
| 817 | private: |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 818 | std::string m_toolName; |
| 819 | bool m_needVersionRetrieval; |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 820 | bool m_needChannelStatusRetrieval; |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 821 | bool m_needFaceStatusRetrieval; |
| 822 | bool m_needFibEnumerationRetrieval; |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 823 | bool m_needRibStatusRetrieval; |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 824 | bool m_needStrategyChoiceRetrieval; |
| 825 | bool m_isOutputXml; |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 826 | Face m_face; |
| 827 | |
| 828 | shared_ptr<OBufferStream> m_buffer; |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 829 | |
| 830 | std::deque<function<void()> > m_fetchSteps; |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 831 | }; |
| 832 | |
| 833 | } |
| 834 | |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 835 | int main(int argc, char* argv[]) |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 836 | { |
| 837 | int option; |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 838 | ndn::NfdStatus nfdStatus(argv[0]); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 839 | |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 840 | while ((option = getopt(argc, argv, "hvcfbrsxV")) != -1) { |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 841 | switch (option) { |
| 842 | case 'h': |
| 843 | nfdStatus.usage(); |
Alexander Afanasyev | 60a7ba5 | 2014-03-23 11:23:06 -0700 | [diff] [blame] | 844 | return 0; |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 845 | case 'v': |
| 846 | nfdStatus.enableVersionRetrieval(); |
| 847 | break; |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 848 | case 'c': |
| 849 | nfdStatus.enableChannelStatusRetrieval(); |
| 850 | break; |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 851 | case 'f': |
| 852 | nfdStatus.enableFaceStatusRetrieval(); |
| 853 | break; |
| 854 | case 'b': |
| 855 | nfdStatus.enableFibEnumerationRetrieval(); |
| 856 | break; |
Chengyu Fan | 30aa207 | 2014-07-20 13:52:32 -0600 | [diff] [blame] | 857 | case 'r': |
| 858 | nfdStatus.enableRibStatusRetrieval(); |
| 859 | break; |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 860 | case 's': |
| 861 | nfdStatus.enableStrategyChoiceRetrieval(); |
| 862 | break; |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 863 | case 'x': |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 864 | nfdStatus.enableXmlOutput(); |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 865 | break; |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 866 | case 'V': |
| 867 | std::cout << NFD_VERSION_BUILD_STRING << std::endl; |
| 868 | return 0; |
Alexander Afanasyev | 7b7dfdd | 2014-03-21 13:57:54 -0700 | [diff] [blame] | 869 | default: |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 870 | nfdStatus.usage(); |
| 871 | return 1; |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 872 | } |
| 873 | } |
| 874 | |
| 875 | try { |
| 876 | nfdStatus.fetchInformation(); |
| 877 | } |
Alexander Afanasyev | 7b7dfdd | 2014-03-21 13:57:54 -0700 | [diff] [blame] | 878 | catch (std::exception& e) { |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 879 | std::cerr << "ERROR: " << e.what() << std::endl; |
| 880 | return 2; |
| 881 | } |
| 882 | |
| 883 | return 0; |
| 884 | } |