rib+tools: use ndn::nfd::RouteOrigin instead of uint64_t
Change-Id: Ic8cbe95491a41e1d34b66d406da8637aeb5fd9e3
Refs: #3903
diff --git a/tools/nfd-autoreg.cpp b/tools/nfd-autoreg.cpp
index 1ecd6e5..ca52e9b 100644
--- a/tools/nfd-autoreg.cpp
+++ b/tools/nfd-autoreg.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+ * Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -41,17 +41,12 @@
#include "core/network.hpp"
using namespace ndn::nfd;
-using ndn::Face;
-using ndn::KeyChain;
-using ndn::nfd::FaceEventNotification;
using ndn::util::FaceUri;
using ::nfd::Network;
namespace ndn {
namespace nfd_autoreg {
-namespace po = boost::program_options;
-
class AutoregServer : boost::noncopyable
{
public:
@@ -123,10 +118,9 @@
}
void
- registerPrefixesForFace(uint64_t faceId,
- const std::vector<ndn::Name>& prefixes)
+ registerPrefixesForFace(uint64_t faceId, const std::vector<Name>& prefixes)
{
- for (std::vector<ndn::Name>::const_iterator prefix = prefixes.begin();
+ for (std::vector<Name>::const_iterator prefix = prefixes.begin();
prefix != prefixes.end();
++prefix)
{
@@ -179,37 +173,35 @@
}
}
-
void
signalHandler()
{
m_face.shutdown();
}
-
void
usage(std::ostream& os,
- const po::options_description& optionDesciption,
+ const boost::program_options::options_description& desc,
const char* programName)
{
os << "Usage:\n"
<< " " << programName << " --prefix=</autoreg/prefix> [--prefix=/another/prefix] ...\n"
<< "\n";
- os << optionDesciption;
+ os << desc;
}
void
startProcessing()
{
std::cerr << "AUTOREG prefixes: " << std::endl;
- for (std::vector<ndn::Name>::const_iterator prefix = m_autoregPrefixes.begin();
+ for (std::vector<Name>::const_iterator prefix = m_autoregPrefixes.begin();
prefix != m_autoregPrefixes.end();
++prefix)
{
std::cout << " " << *prefix << std::endl;
}
std::cerr << "ALL-FACES-AUTOREG prefixes: " << std::endl;
- for (std::vector<ndn::Name>::const_iterator prefix = m_allFacesPrefixes.begin();
+ for (std::vector<Name>::const_iterator prefix = m_allFacesPrefixes.begin();
prefix != m_allFacesPrefixes.end();
++prefix)
{
@@ -248,8 +240,8 @@
startFetchingFaceStatusDataset()
{
m_controller.fetch<FaceDataset>(
- [this] (const std::vector<ndn::nfd::FaceStatus>& faces) {
- for (const ndn::nfd::FaceStatus& faceStatus : faces) {
+ [this] (const std::vector<FaceStatus>& faces) {
+ for (const auto& faceStatus : faces) {
registerPrefixesIfNeeded(faceStatus.getFaceId(), FaceUri(faceStatus.getRemoteUri()),
faceStatus.getFacePersistency());
}
@@ -260,20 +252,22 @@
int
main(int argc, char* argv[])
{
+ namespace po = boost::program_options;
+
po::options_description optionDesciption;
optionDesciption.add_options()
("help,h", "produce help message")
- ("prefix,i", po::value<std::vector<ndn::Name> >(&m_autoregPrefixes)->composing(),
+ ("prefix,i", po::value<std::vector<Name>>(&m_autoregPrefixes)->composing(),
"prefix that should be automatically registered when new a remote non-local face is "
"established")
- ("all-faces-prefix,a", po::value<std::vector<ndn::Name> >(&m_allFacesPrefixes)->composing(),
+ ("all-faces-prefix,a", po::value<std::vector<Name>>(&m_allFacesPrefixes)->composing(),
"prefix that should be automatically registered for all TCP and UDP non-local faces "
"(blacklists and whitelists do not apply to this prefix)")
("cost,c", po::value<uint64_t>(&m_cost)->default_value(255),
"FIB cost which should be assigned to autoreg nexthops")
- ("whitelist,w", po::value<std::vector<Network> >(&m_whiteList)->composing(),
+ ("whitelist,w", po::value<std::vector<Network>>(&m_whiteList)->composing(),
"Whitelisted network, e.g., 192.168.2.0/24 or ::1/128")
- ("blacklist,b", po::value<std::vector<Network> >(&m_blackList)->composing(),
+ ("blacklist,b", po::value<std::vector<Network>>(&m_blackList)->composing(),
"Blacklisted network, e.g., 192.168.2.32/30 or ::1/128")
("version,V", "show version and exit")
;
@@ -284,7 +278,7 @@
po::store(po::command_line_parser(argc, argv).options(optionDesciption).run(), options);
po::notify(options);
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
std::cerr << "ERROR: " << e.what() << std::endl << std::endl;
usage(std::cerr, optionDesciption, argv[0]);
@@ -323,7 +317,7 @@
startFetchingFaceStatusDataset();
startProcessing();
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
std::cerr << "ERROR: " << e.what() << std::endl;
return 2;
@@ -337,8 +331,8 @@
KeyChain m_keyChain;
Controller m_controller;
FaceMonitor m_faceMonitor;
- std::vector<ndn::Name> m_autoregPrefixes;
- std::vector<ndn::Name> m_allFacesPrefixes;
+ std::vector<Name> m_autoregPrefixes;
+ std::vector<Name> m_allFacesPrefixes;
uint64_t m_cost;
std::vector<Network> m_whiteList;
std::vector<Network> m_blackList;