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 | /** |
Alexander Afanasyev | 4a77136 | 2014-04-24 21:29:33 -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 | * 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> |
| 39 | #include <ndn-cxx/management/nfd-strategy-choice.hpp> |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 40 | |
Alexander Afanasyev | b3893c9 | 2014-05-15 01:49:54 -0700 | [diff] [blame] | 41 | #include <boost/algorithm/string/replace.hpp> |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 42 | #include <list> |
Alexander Afanasyev | b3893c9 | 2014-05-15 01:49:54 -0700 | [diff] [blame] | 43 | |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 44 | namespace ndn { |
| 45 | |
| 46 | class NfdStatus |
| 47 | { |
| 48 | public: |
Alexander Afanasyev | 7b7dfdd | 2014-03-21 13:57:54 -0700 | [diff] [blame] | 49 | explicit |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 50 | NfdStatus(char* toolName) |
| 51 | : m_toolName(toolName) |
| 52 | , m_needVersionRetrieval(false) |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 53 | , m_needChannelStatusRetrieval(false) |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 54 | , m_needFaceStatusRetrieval(false) |
| 55 | , m_needFibEnumerationRetrieval(false) |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 56 | , m_needStrategyChoiceRetrieval(false) |
| 57 | , m_isOutputXml(false) |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 58 | { |
| 59 | } |
| 60 | |
| 61 | void |
| 62 | usage() |
| 63 | { |
Alexander Afanasyev | 60a7ba5 | 2014-03-23 11:23:06 -0700 | [diff] [blame] | 64 | std::cout << "Usage: \n " << m_toolName << " [options]\n\n" |
| 65 | "Show NFD version and status information\n\n" |
| 66 | "Options:\n" |
| 67 | " [-h] - print this help message\n" |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 68 | " [-v] - retrieve version information\n" |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 69 | " [-c] - retrieve channel status information\n" |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 70 | " [-f] - retrieve face status information\n" |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 71 | " [-b] - retrieve FIB information\n" |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 72 | " [-s] - retrieve configured strategy choice for NDN namespaces\n" |
Chengyu Fan | ee92fc7 | 2014-06-21 14:58:19 -0600 | [diff] [blame] | 73 | " [-x] - output NFD status information in XML format\n" |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 74 | "\n" |
| 75 | " [-V] - show version information of nfd-status and exit\n" |
| 76 | "\n" |
Alexander Afanasyev | 60a7ba5 | 2014-03-23 11:23:06 -0700 | [diff] [blame] | 77 | "If no options are provided, all information is retrieved.\n" |
Chengyu Fan | ee92fc7 | 2014-06-21 14:58:19 -0600 | [diff] [blame] | 78 | "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] | 79 | ; |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | void |
| 83 | enableVersionRetrieval() |
| 84 | { |
| 85 | m_needVersionRetrieval = true; |
| 86 | } |
| 87 | |
| 88 | void |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 89 | enableChannelStatusRetrieval() |
| 90 | { |
| 91 | m_needChannelStatusRetrieval = true; |
| 92 | } |
| 93 | |
| 94 | void |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 95 | enableFaceStatusRetrieval() |
| 96 | { |
| 97 | m_needFaceStatusRetrieval = true; |
| 98 | } |
| 99 | |
| 100 | void |
| 101 | enableFibEnumerationRetrieval() |
| 102 | { |
| 103 | m_needFibEnumerationRetrieval = true; |
| 104 | } |
| 105 | |
| 106 | void |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 107 | enableStrategyChoiceRetrieval() |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 108 | { |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 109 | m_needStrategyChoiceRetrieval = true; |
| 110 | } |
| 111 | |
| 112 | void |
| 113 | enableXmlOutput() |
| 114 | { |
| 115 | m_isOutputXml = true; |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | void |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 119 | onTimeout() |
| 120 | { |
| 121 | std::cerr << "Request timed out" << std::endl; |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 122 | |
| 123 | runNextStep(); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | void |
| 127 | fetchSegments(const Data& data, void (NfdStatus::*onDone)()) |
| 128 | { |
| 129 | m_buffer->write((const char*)data.getContent().value(), |
| 130 | data.getContent().value_size()); |
| 131 | |
| 132 | uint64_t currentSegment = data.getName().get(-1).toSegment(); |
| 133 | |
| 134 | const name::Component& finalBlockId = data.getMetaInfo().getFinalBlockId(); |
| 135 | if (finalBlockId.empty() || |
| 136 | finalBlockId.toSegment() > currentSegment) |
| 137 | { |
| 138 | m_face.expressInterest(data.getName().getPrefix(-1).appendSegment(currentSegment+1), |
| 139 | bind(&NfdStatus::fetchSegments, this, _2, onDone), |
| 140 | bind(&NfdStatus::onTimeout, this)); |
| 141 | } |
| 142 | else |
| 143 | { |
| 144 | return (this->*onDone)(); |
| 145 | } |
| 146 | } |
| 147 | |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 148 | void |
| 149 | escapeSpecialCharacters(std::string *data) |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 150 | { |
| 151 | using boost::algorithm::replace_all; |
| 152 | replace_all(*data, "&", "&"); |
| 153 | replace_all(*data, "\"", """); |
| 154 | replace_all(*data, "\'", "'"); |
| 155 | replace_all(*data, "<", "<"); |
| 156 | replace_all(*data, ">", ">"); |
| 157 | } |
| 158 | |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 159 | ////////////////////////////////////////////////////////////////////////////////// |
| 160 | ////////////////////////////////////////////////////////////////////////////////// |
| 161 | |
| 162 | void |
| 163 | fetchVersionInformation() |
| 164 | { |
| 165 | Interest interest("/localhost/nfd/status"); |
| 166 | interest.setChildSelector(1); |
| 167 | interest.setMustBeFresh(true); |
| 168 | m_face.expressInterest( |
| 169 | interest, |
| 170 | bind(&NfdStatus::afterFetchedVersionInformation, this, _2), |
| 171 | bind(&NfdStatus::onTimeout, this)); |
| 172 | } |
| 173 | |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 174 | void |
| 175 | afterFetchedVersionInformation(const Data& data) |
| 176 | { |
Junxiao Shi | 88d6937 | 2014-03-28 11:52:39 -0700 | [diff] [blame] | 177 | nfd::ForwarderStatus status(data.getContent()); |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 178 | if (m_isOutputXml) |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 179 | { |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 180 | std::cout << "<generalStatus>"; |
| 181 | std::cout << "<version>" |
| 182 | << status.getNfdVersion() << "</version>"; |
| 183 | std::cout << "<startTime>" |
| 184 | << time::toString(status.getStartTimestamp(), "%Y-%m-%dT%H:%M:%S%F") |
| 185 | << "</startTime>"; |
| 186 | std::cout << "<currentTime>" |
| 187 | << time::toString(status.getCurrentTimestamp(), "%Y-%m-%dT%H:%M:%S%F") |
| 188 | << "</currentTime>"; |
| 189 | std::cout << "<uptime>PT" |
| 190 | << time::duration_cast<time::seconds>(status.getCurrentTimestamp() |
| 191 | - status.getStartTimestamp()).count() |
| 192 | << "S</uptime>"; |
| 193 | std::cout << "<nNameTreeEntries>" << status.getNNameTreeEntries() |
| 194 | << "</nNameTreeEntries>"; |
| 195 | std::cout << "<nFibEntries>" << status.getNFibEntries() |
| 196 | << "</nFibEntries>"; |
| 197 | std::cout << "<nPitEntries>" << status.getNPitEntries() |
| 198 | << "</nPitEntries>"; |
| 199 | std::cout << "<nMeasurementsEntries>" << status.getNMeasurementsEntries() |
| 200 | << "</nMeasurementsEntries>"; |
| 201 | std::cout << "<nCsEntries>" << status.getNCsEntries() |
| 202 | << "</nCsEntries>"; |
| 203 | std::cout << "<packetCounters>"; |
| 204 | std::cout << "<incomingPackets>"; |
| 205 | std::cout << "<nInterests>" << status.getNInInterests() |
| 206 | << "</nInterests>"; |
| 207 | std::cout << "<nDatas>" << status.getNInDatas() |
| 208 | << "</nDatas>"; |
| 209 | std::cout << "</incomingPackets>"; |
| 210 | std::cout << "<outgoingPackets>"; |
| 211 | std::cout << "<nInterests>" << status.getNOutInterests() |
| 212 | << "</nInterests>"; |
| 213 | std::cout << "<nDatas>" << status.getNOutDatas() |
| 214 | << "</nDatas>"; |
| 215 | std::cout << "</outgoingPackets>"; |
| 216 | std::cout << "</packetCounters>"; |
| 217 | std::cout << "</generalStatus>"; |
| 218 | } |
| 219 | else |
| 220 | { |
| 221 | std::cout << "General NFD status:" << std::endl; |
| 222 | std::cout << " version=" |
| 223 | << status.getNfdVersion() << std::endl; |
| 224 | std::cout << " startTime=" |
| 225 | << time::toIsoString(status.getStartTimestamp()) << std::endl; |
| 226 | std::cout << " currentTime=" |
| 227 | << time::toIsoString(status.getCurrentTimestamp()) << std::endl; |
| 228 | std::cout << " uptime=" |
| 229 | << time::duration_cast<time::seconds>(status.getCurrentTimestamp() |
| 230 | - status.getStartTimestamp()) << std::endl; |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 231 | |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 232 | std::cout << " nNameTreeEntries=" << status.getNNameTreeEntries() << std::endl; |
| 233 | std::cout << " nFibEntries=" << status.getNFibEntries() << std::endl; |
| 234 | std::cout << " nPitEntries=" << status.getNPitEntries() << std::endl; |
| 235 | std::cout << " nMeasurementsEntries=" << status.getNMeasurementsEntries() << std::endl; |
| 236 | std::cout << " nCsEntries=" << status.getNCsEntries() << std::endl; |
| 237 | std::cout << " nInInterests=" << status.getNInInterests() << std::endl; |
| 238 | std::cout << " nOutInterests=" << status.getNOutInterests() << std::endl; |
| 239 | std::cout << " nInDatas=" << status.getNInDatas() << std::endl; |
| 240 | std::cout << " nOutDatas=" << status.getNOutDatas() << std::endl; |
| 241 | } |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 242 | |
| 243 | runNextStep(); |
| 244 | } |
| 245 | |
| 246 | ////////////////////////////////////////////////////////////////////////////////// |
| 247 | ////////////////////////////////////////////////////////////////////////////////// |
| 248 | |
| 249 | void |
| 250 | fetchChannelStatusInformation() |
| 251 | { |
| 252 | m_buffer = make_shared<OBufferStream>(); |
| 253 | |
| 254 | Interest interest("/localhost/nfd/faces/channels"); |
| 255 | interest.setChildSelector(1); |
| 256 | interest.setMustBeFresh(true); |
| 257 | |
| 258 | m_face.expressInterest(interest, |
| 259 | bind(&NfdStatus::fetchSegments, this, _2, |
| 260 | &NfdStatus::afterFetchedChannelStatusInformation), |
| 261 | bind(&NfdStatus::onTimeout, this)); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | void |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 265 | afterFetchedChannelStatusInformation() |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 266 | { |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 267 | ConstBufferPtr buf = m_buffer->buf(); |
| 268 | if (m_isOutputXml) |
| 269 | { |
| 270 | std::cout << "<channels>"; |
| 271 | |
| 272 | Block block; |
| 273 | size_t offset = 0; |
| 274 | while (offset < buf->size()) |
| 275 | { |
| 276 | bool ok = Block::fromBuffer(buf, offset, block); |
| 277 | if (!ok) |
| 278 | { |
| 279 | std::cerr << "ERROR: cannot decode ChannelStatus TLV" << std::endl; |
| 280 | break; |
| 281 | } |
| 282 | |
| 283 | offset += block.size(); |
| 284 | |
| 285 | nfd::ChannelStatus channelStatus(block); |
| 286 | |
| 287 | std::cout << "<channel>"; |
| 288 | |
| 289 | std::string localUri(channelStatus.getLocalUri()); |
| 290 | escapeSpecialCharacters(&localUri); |
| 291 | std::cout << "<localUri>" << localUri << "</localUri>"; |
| 292 | std::cout << "</channel>"; |
| 293 | } |
| 294 | std::cout << "</channels>"; |
| 295 | } |
| 296 | else |
| 297 | { |
| 298 | std::cout << "Channels:" << std::endl; |
| 299 | |
| 300 | Block block; |
| 301 | size_t offset = 0; |
| 302 | while (offset < buf->size()) |
| 303 | { |
| 304 | bool ok = Block::fromBuffer(buf, offset, block); |
| 305 | if (!ok) |
| 306 | { |
| 307 | std::cerr << "ERROR: cannot decode ChannelStatus TLV" << std::endl; |
| 308 | break; |
| 309 | } |
| 310 | |
| 311 | offset += block.size(); |
| 312 | |
| 313 | nfd::ChannelStatus channelStatus(block); |
| 314 | std::cout << " " << channelStatus.getLocalUri() << std::endl; |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | runNextStep(); |
| 319 | } |
| 320 | |
| 321 | ////////////////////////////////////////////////////////////////////////////////// |
| 322 | ////////////////////////////////////////////////////////////////////////////////// |
| 323 | |
| 324 | void |
| 325 | fetchFaceStatusInformation() |
| 326 | { |
| 327 | m_buffer = make_shared<OBufferStream>(); |
| 328 | |
| 329 | Interest interest("/localhost/nfd/faces/list"); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 330 | interest.setChildSelector(1); |
| 331 | interest.setMustBeFresh(true); |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 332 | |
| 333 | m_face.expressInterest(interest, |
| 334 | bind(&NfdStatus::fetchSegments, this, _2, |
| 335 | &NfdStatus::afterFetchedFaceStatusInformation), |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 336 | bind(&NfdStatus::onTimeout, this)); |
| 337 | } |
| 338 | |
| 339 | void |
| 340 | afterFetchedFaceStatusInformation() |
| 341 | { |
Alexander Afanasyev | 7b7dfdd | 2014-03-21 13:57:54 -0700 | [diff] [blame] | 342 | ConstBufferPtr buf = m_buffer->buf(); |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 343 | if (m_isOutputXml) |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 344 | { |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 345 | std::cout << "<faces>"; |
| 346 | |
| 347 | Block block; |
| 348 | size_t offset = 0; |
| 349 | while (offset < buf->size()) |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 350 | { |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 351 | bool ok = Block::fromBuffer(buf, offset, block); |
| 352 | if (!ok) |
| 353 | { |
| 354 | std::cerr << "ERROR: cannot decode FaceStatus TLV" << std::endl; |
| 355 | break; |
| 356 | } |
| 357 | |
| 358 | offset += block.size(); |
| 359 | |
| 360 | nfd::FaceStatus faceStatus(block); |
| 361 | |
| 362 | std::cout << "<face>"; |
| 363 | std::cout << "<faceId>" << faceStatus.getFaceId() << "</faceId>"; |
| 364 | |
| 365 | std::string remoteUri(faceStatus.getRemoteUri()); |
| 366 | escapeSpecialCharacters(&remoteUri); |
| 367 | std::cout << "<remoteUri>" << remoteUri << "</remoteUri>"; |
| 368 | |
| 369 | std::string localUri(faceStatus.getLocalUri()); |
| 370 | escapeSpecialCharacters(&localUri); |
| 371 | std::cout << "<localUri>" << localUri << "</localUri>"; |
Alexander Afanasyev | 40c61f7 | 2014-06-30 17:21:01 -0700 | [diff] [blame^] | 372 | |
| 373 | if (faceStatus.hasExpirationPeriod()) { |
| 374 | std::cout << "<expirationPeriod>PT" |
| 375 | << time::duration_cast<time::seconds>(faceStatus.getExpirationPeriod()) |
| 376 | .count() << "S" |
| 377 | << "</expirationPeriod>"; |
| 378 | } |
| 379 | |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 380 | std::cout << "<packetCounters>"; |
| 381 | std::cout << "<incomingPackets>"; |
| 382 | std::cout << "<nInterests>" << faceStatus.getNInInterests() |
| 383 | << "</nInterests>"; |
| 384 | std::cout << "<nDatas>" << faceStatus.getNInInterests() |
| 385 | << "</nDatas>"; |
| 386 | std::cout << "</incomingPackets>"; |
| 387 | std::cout << "<outgoingPackets>"; |
| 388 | std::cout << "<nInterests>" << faceStatus.getNOutInterests() |
| 389 | << "</nInterests>"; |
| 390 | std::cout << "<nDatas>" << faceStatus.getNOutInterests() |
| 391 | << "</nDatas>"; |
| 392 | std::cout << "</outgoingPackets>"; |
| 393 | std::cout << "</packetCounters>"; |
Alexander Afanasyev | d3967a2 | 2014-06-30 12:22:10 -0700 | [diff] [blame] | 394 | |
| 395 | if (faceStatus.getFlags() != 0) { |
| 396 | std::cout << "<flags>"; |
| 397 | if (faceStatus.isLocal()) { |
| 398 | std::cout << "<local/>"; |
| 399 | } |
| 400 | if (faceStatus.isOnDemand()) { |
| 401 | std::cout << "<on-demand/>"; |
| 402 | } |
| 403 | std::cout << "</flags>"; |
| 404 | } |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 405 | std::cout << "</face>"; |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 406 | } |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 407 | std::cout << "</faces>"; |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 408 | } |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 409 | else |
| 410 | { |
| 411 | std::cout << "Faces:" << std::endl; |
| 412 | |
| 413 | Block block; |
| 414 | size_t offset = 0; |
| 415 | while (offset < buf->size()) |
| 416 | { |
| 417 | bool ok = Block::fromBuffer(buf, offset, block); |
| 418 | if (!ok) |
| 419 | { |
| 420 | std::cerr << "ERROR: cannot decode FaceStatus TLV" << std::endl; |
| 421 | break; |
| 422 | } |
| 423 | |
| 424 | offset += block.size(); |
| 425 | |
| 426 | nfd::FaceStatus faceStatus(block); |
| 427 | |
| 428 | std::cout << " faceid=" << faceStatus.getFaceId() |
| 429 | << " remote=" << faceStatus.getRemoteUri() |
Alexander Afanasyev | 40c61f7 | 2014-06-30 17:21:01 -0700 | [diff] [blame^] | 430 | << " local=" << faceStatus.getLocalUri(); |
| 431 | if (faceStatus.hasExpirationPeriod()) { |
| 432 | std::cout << " expires=" |
| 433 | << time::duration_cast<time::seconds>(faceStatus.getExpirationPeriod()) |
| 434 | .count() << "s"; |
| 435 | } |
| 436 | std::cout << " counters={" |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 437 | << "in={" << faceStatus.getNInInterests() << "i " |
| 438 | << faceStatus.getNInDatas() << "d}" |
| 439 | << " out={" << faceStatus.getNOutInterests() << "i " |
| 440 | << faceStatus.getNOutDatas() << "d}" |
Alexander Afanasyev | d3967a2 | 2014-06-30 12:22:10 -0700 | [diff] [blame] | 441 | << "}"; |
| 442 | if (faceStatus.isLocal()) |
| 443 | std::cout << " local"; |
| 444 | if (faceStatus.isOnDemand()) |
| 445 | std::cout << " on-demand"; |
| 446 | std::cout << std::endl; |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 447 | } |
| 448 | } |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 449 | |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 450 | runNextStep(); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 451 | } |
| 452 | |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 453 | ////////////////////////////////////////////////////////////////////////////////// |
| 454 | ////////////////////////////////////////////////////////////////////////////////// |
| 455 | |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 456 | void |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 457 | fetchFibEnumerationInformation() |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 458 | { |
| 459 | m_buffer = make_shared<OBufferStream>(); |
| 460 | |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 461 | Interest interest("/localhost/nfd/fib/list"); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 462 | interest.setChildSelector(1); |
| 463 | interest.setMustBeFresh(true); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 464 | m_face.expressInterest(interest, |
| 465 | bind(&NfdStatus::fetchSegments, this, _2, |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 466 | &NfdStatus::afterFetchedFibEnumerationInformation), |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 467 | bind(&NfdStatus::onTimeout, this)); |
| 468 | } |
| 469 | |
| 470 | void |
| 471 | afterFetchedFibEnumerationInformation() |
| 472 | { |
Alexander Afanasyev | 7b7dfdd | 2014-03-21 13:57:54 -0700 | [diff] [blame] | 473 | ConstBufferPtr buf = m_buffer->buf(); |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 474 | if (m_isOutputXml) |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 475 | { |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 476 | std::cout << "<fib>"; |
Alexander Afanasyev | 7b7dfdd | 2014-03-21 13:57:54 -0700 | [diff] [blame] | 477 | |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 478 | Block block; |
| 479 | size_t offset = 0; |
| 480 | while (offset < buf->size()) |
Alexander Afanasyev | 7b7dfdd | 2014-03-21 13:57:54 -0700 | [diff] [blame] | 481 | { |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 482 | bool ok = Block::fromBuffer(buf, offset, block); |
| 483 | if (!ok) |
| 484 | { |
| 485 | std::cerr << "ERROR: cannot decode FibEntry TLV"; |
| 486 | break; |
| 487 | } |
| 488 | offset += block.size(); |
| 489 | |
| 490 | nfd::FibEntry fibEntry(block); |
| 491 | |
| 492 | std::cout << "<fibEntry>"; |
| 493 | std::string prefix(fibEntry.getPrefix().toUri()); |
| 494 | escapeSpecialCharacters(&prefix); |
| 495 | std::cout << "<prefix>" << prefix << "</prefix>"; |
| 496 | std::cout << "<nextHops>"; |
| 497 | for (std::list<nfd::NextHopRecord>::const_iterator |
| 498 | nextHop = fibEntry.getNextHopRecords().begin(); |
| 499 | nextHop != fibEntry.getNextHopRecords().end(); |
| 500 | ++nextHop) |
| 501 | { |
| 502 | std::cout << "<nextHop>" ; |
| 503 | std::cout << "<faceId>" << nextHop->getFaceId() << "</faceId>"; |
| 504 | std::cout << "<cost>" << nextHop->getCost() << "</cost>"; |
| 505 | std::cout << "</nextHop>"; |
| 506 | } |
| 507 | std::cout << "</nextHops>"; |
| 508 | std::cout << "</fibEntry>"; |
Alexander Afanasyev | 7b7dfdd | 2014-03-21 13:57:54 -0700 | [diff] [blame] | 509 | } |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 510 | |
| 511 | std::cout << "</fib>"; |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 512 | } |
| 513 | else |
| 514 | { |
| 515 | std::cout << "FIB:" << std::endl; |
| 516 | |
| 517 | Block block; |
| 518 | size_t offset = 0; |
| 519 | while (offset < buf->size()) |
| 520 | { |
| 521 | bool ok = Block::fromBuffer(buf, offset, block); |
| 522 | if (!ok) |
| 523 | { |
| 524 | std::cerr << "ERROR: cannot decode FibEntry TLV" << std::endl; |
| 525 | break; |
| 526 | } |
| 527 | offset += block.size(); |
| 528 | |
| 529 | nfd::FibEntry fibEntry(block); |
| 530 | |
| 531 | std::cout << " " << fibEntry.getPrefix() << " nexthops={"; |
| 532 | for (std::list<nfd::NextHopRecord>::const_iterator |
| 533 | nextHop = fibEntry.getNextHopRecords().begin(); |
| 534 | nextHop != fibEntry.getNextHopRecords().end(); |
| 535 | ++nextHop) |
| 536 | { |
| 537 | if (nextHop != fibEntry.getNextHopRecords().begin()) |
| 538 | std::cout << ", "; |
| 539 | std::cout << "faceid=" << nextHop->getFaceId() |
| 540 | << " (cost=" << nextHop->getCost() << ")"; |
| 541 | } |
| 542 | std::cout << "}" << std::endl; |
| 543 | } |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 544 | } |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 545 | |
| 546 | runNextStep(); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 547 | } |
| 548 | |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 549 | ////////////////////////////////////////////////////////////////////////////////// |
| 550 | ////////////////////////////////////////////////////////////////////////////////// |
| 551 | |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 552 | void |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 553 | fetchStrategyChoiceInformation() |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 554 | { |
| 555 | m_buffer = make_shared<OBufferStream>(); |
| 556 | |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 557 | Interest interest("/localhost/nfd/strategy-choice/list"); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 558 | interest.setChildSelector(1); |
| 559 | interest.setMustBeFresh(true); |
| 560 | m_face.expressInterest(interest, |
| 561 | bind(&NfdStatus::fetchSegments, this, _2, |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 562 | &NfdStatus::afterFetchedStrategyChoiceInformationInformation), |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 563 | bind(&NfdStatus::onTimeout, this)); |
| 564 | } |
| 565 | |
| 566 | void |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 567 | afterFetchedStrategyChoiceInformationInformation() |
| 568 | { |
| 569 | ConstBufferPtr buf = m_buffer->buf(); |
| 570 | if (m_isOutputXml) |
| 571 | { |
| 572 | std::cout << "<strategyChoices>"; |
| 573 | |
| 574 | Block block; |
| 575 | size_t offset = 0; |
| 576 | while (offset < buf->size()) |
| 577 | { |
| 578 | bool ok = Block::fromBuffer(buf, offset, block); |
| 579 | if (!ok) |
| 580 | { |
| 581 | std::cerr << "ERROR: cannot decode StrategyChoice TLV"; |
| 582 | break; |
| 583 | } |
| 584 | offset += block.size(); |
| 585 | |
| 586 | nfd::StrategyChoice strategyChoice(block); |
| 587 | |
| 588 | std::cout << "<strategyChoice>"; |
| 589 | |
| 590 | std::string name(strategyChoice.getName().toUri()); |
| 591 | escapeSpecialCharacters(&name); |
| 592 | std::cout << "<namespace>" << name << "</namespace>"; |
| 593 | std::cout << "<strategy>"; |
| 594 | |
| 595 | std::string strategy(strategyChoice.getStrategy().toUri()); |
| 596 | escapeSpecialCharacters(&strategy); |
| 597 | |
| 598 | std::cout << "<name>" << strategy << "</name>"; |
| 599 | std::cout << "</strategy>"; |
| 600 | std::cout << "</strategyChoice>"; |
| 601 | } |
| 602 | |
| 603 | std::cout << "</strategyChoices>"; |
| 604 | } |
| 605 | else |
| 606 | { |
| 607 | std::cout << "Strategy choices:" << std::endl; |
| 608 | |
| 609 | Block block; |
| 610 | size_t offset = 0; |
| 611 | while (offset < buf->size()) |
| 612 | { |
| 613 | bool ok = Block::fromBuffer(buf, offset, block); |
| 614 | if (!ok) |
| 615 | { |
| 616 | std::cerr << "ERROR: cannot decode StrategyChoice TLV" << std::endl; |
| 617 | break; |
| 618 | } |
| 619 | offset += block.size(); |
| 620 | |
| 621 | nfd::StrategyChoice strategyChoice(block); |
| 622 | |
| 623 | std::cout << " " << strategyChoice.getName() |
| 624 | << " strategy=" << strategyChoice.getStrategy() << std::endl; |
| 625 | } |
| 626 | } |
| 627 | |
| 628 | runNextStep(); |
| 629 | } |
| 630 | |
| 631 | void |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 632 | fetchInformation() |
| 633 | { |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 634 | if (m_isOutputXml || |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 635 | (!m_needVersionRetrieval && |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 636 | !m_needChannelStatusRetrieval && |
| 637 | !m_needFaceStatusRetrieval && |
| 638 | !m_needFibEnumerationRetrieval && |
| 639 | !m_needStrategyChoiceRetrieval)) |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 640 | { |
| 641 | enableVersionRetrieval(); |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 642 | enableChannelStatusRetrieval(); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 643 | enableFaceStatusRetrieval(); |
| 644 | enableFibEnumerationRetrieval(); |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 645 | enableStrategyChoiceRetrieval(); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 646 | } |
| 647 | |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 648 | if (m_isOutputXml) |
| 649 | m_fetchSteps.push_back(bind(&NfdStatus::printXmlHeader, this)); |
| 650 | |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 651 | if (m_needVersionRetrieval) |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 652 | m_fetchSteps.push_back(bind(&NfdStatus::fetchVersionInformation, this)); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 653 | |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 654 | if (m_needChannelStatusRetrieval) |
| 655 | m_fetchSteps.push_back(bind(&NfdStatus::fetchChannelStatusInformation, this)); |
| 656 | |
| 657 | if (m_needFaceStatusRetrieval) |
| 658 | m_fetchSteps.push_back(bind(&NfdStatus::fetchFaceStatusInformation, this)); |
| 659 | |
| 660 | if (m_needFibEnumerationRetrieval) |
| 661 | m_fetchSteps.push_back(bind(&NfdStatus::fetchFibEnumerationInformation, this)); |
| 662 | |
| 663 | if (m_needStrategyChoiceRetrieval) |
| 664 | m_fetchSteps.push_back(bind(&NfdStatus::fetchStrategyChoiceInformation, this)); |
| 665 | |
| 666 | if (m_isOutputXml) |
| 667 | m_fetchSteps.push_back(bind(&NfdStatus::printXmlFooter, this)); |
| 668 | |
| 669 | runNextStep(); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 670 | m_face.processEvents(); |
| 671 | } |
| 672 | |
| 673 | private: |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 674 | void |
| 675 | printXmlHeader() |
| 676 | { |
| 677 | std::cout << "<?xml version=\"1.0\"?>"; |
| 678 | std::cout << "<nfdStatus xmlns=\"ndn:/localhost/nfd/status/1\">"; |
| 679 | |
| 680 | runNextStep(); |
| 681 | } |
| 682 | |
| 683 | void |
| 684 | printXmlFooter() |
| 685 | { |
| 686 | std::cout << "</nfdStatus>"; |
| 687 | |
| 688 | runNextStep(); |
| 689 | } |
| 690 | |
| 691 | void |
| 692 | runNextStep() |
| 693 | { |
| 694 | if (m_fetchSteps.empty()) |
| 695 | return; |
| 696 | |
| 697 | function<void()> nextStep = m_fetchSteps.front(); |
| 698 | m_fetchSteps.pop_front(); |
| 699 | nextStep(); |
| 700 | } |
| 701 | |
| 702 | private: |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 703 | std::string m_toolName; |
| 704 | bool m_needVersionRetrieval; |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 705 | bool m_needChannelStatusRetrieval; |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 706 | bool m_needFaceStatusRetrieval; |
| 707 | bool m_needFibEnumerationRetrieval; |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 708 | bool m_needStrategyChoiceRetrieval; |
| 709 | bool m_isOutputXml; |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 710 | Face m_face; |
| 711 | |
| 712 | shared_ptr<OBufferStream> m_buffer; |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 713 | |
| 714 | std::deque<function<void()> > m_fetchSteps; |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 715 | }; |
| 716 | |
| 717 | } |
| 718 | |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 719 | int main(int argc, char* argv[]) |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 720 | { |
| 721 | int option; |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 722 | ndn::NfdStatus nfdStatus(argv[0]); |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 723 | |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 724 | while ((option = getopt(argc, argv, "hvcfbsxV")) != -1) { |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 725 | switch (option) { |
| 726 | case 'h': |
| 727 | nfdStatus.usage(); |
Alexander Afanasyev | 60a7ba5 | 2014-03-23 11:23:06 -0700 | [diff] [blame] | 728 | return 0; |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 729 | case 'v': |
| 730 | nfdStatus.enableVersionRetrieval(); |
| 731 | break; |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 732 | case 'c': |
| 733 | nfdStatus.enableChannelStatusRetrieval(); |
| 734 | break; |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 735 | case 'f': |
| 736 | nfdStatus.enableFaceStatusRetrieval(); |
| 737 | break; |
| 738 | case 'b': |
| 739 | nfdStatus.enableFibEnumerationRetrieval(); |
| 740 | break; |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 741 | case 's': |
| 742 | nfdStatus.enableStrategyChoiceRetrieval(); |
| 743 | break; |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 744 | case 'x': |
Alexander Afanasyev | 0417d2a | 2014-06-08 10:56:43 +0300 | [diff] [blame] | 745 | nfdStatus.enableXmlOutput(); |
Chengyu Fan | 514ed5e | 2014-04-17 13:07:30 -0600 | [diff] [blame] | 746 | break; |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 747 | case 'V': |
| 748 | std::cout << NFD_VERSION_BUILD_STRING << std::endl; |
| 749 | return 0; |
Alexander Afanasyev | 7b7dfdd | 2014-03-21 13:57:54 -0700 | [diff] [blame] | 750 | default: |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 751 | nfdStatus.usage(); |
| 752 | return 1; |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 753 | } |
| 754 | } |
| 755 | |
| 756 | try { |
| 757 | nfdStatus.fetchInformation(); |
| 758 | } |
Alexander Afanasyev | 7b7dfdd | 2014-03-21 13:57:54 -0700 | [diff] [blame] | 759 | catch (std::exception& e) { |
jeraldabraham | b6dde38 | 2014-03-19 18:58:09 -0700 | [diff] [blame] | 760 | std::cerr << "ERROR: " << e.what() << std::endl; |
| 761 | return 2; |
| 762 | } |
| 763 | |
| 764 | return 0; |
| 765 | } |