encoding: add route origin for self-learning

Change-Id: I2f652ac889095ee9bb7c752e715cfecb41459fa4
refs: #4279
This commit is contained in:
Teng Liang committed 2018-04-29 18:29:03 -07:00
1 parent d89f002da8
commit c93c2ce269
3 files changed
+17 -10

No files matched your search

+6 -2
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2013-2017 Regents of the University of California.
/*
* Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -115,6 +115,8 @@ operator>>(std::istream& is, RouteOrigin& routeOrigin)
routeOrigin = ROUTE_ORIGIN_AUTOCONF;
else if (iequals(s, "nlsr"))
routeOrigin = ROUTE_ORIGIN_NLSR;
else if (iequals(s, "selflearning"))
routeOrigin = ROUTE_ORIGIN_SELFLEARNING;
else if (iequals(s, "static"))
routeOrigin = ROUTE_ORIGIN_STATIC;
else {
@@ -158,6 +160,8 @@ operator<<(std::ostream& os, RouteOrigin routeOrigin)
return os << "autoconf";
case ROUTE_ORIGIN_NLSR:
return os << "nlsr";
case ROUTE_ORIGIN_SELFLEARNING:
return os << "selflearning";
case ROUTE_ORIGIN_STATIC:
return os << "static";
}
+8 -7
View File
@@ -97,13 +97,14 @@ enum CsFlagBit {
/** \ingroup management
*/
enum RouteOrigin : uint16_t {
ROUTE_ORIGIN_NONE = std::numeric_limits<uint16_t>::max(),
ROUTE_ORIGIN_APP = 0,
ROUTE_ORIGIN_AUTOREG = 64,
ROUTE_ORIGIN_CLIENT = 65,
ROUTE_ORIGIN_AUTOCONF = 66,
ROUTE_ORIGIN_NLSR = 128,
ROUTE_ORIGIN_STATIC = 255,
ROUTE_ORIGIN_NONE = std::numeric_limits<uint16_t>::max(),
ROUTE_ORIGIN_APP = 0,
ROUTE_ORIGIN_AUTOREG = 64,
ROUTE_ORIGIN_CLIENT = 65,
ROUTE_ORIGIN_AUTOCONF = 66,
ROUTE_ORIGIN_NLSR = 128,
ROUTE_ORIGIN_SELFLEARNING = 129,
ROUTE_ORIGIN_STATIC = 255,
};
/** \brief extract RouteOrigin from stream
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2017 Regents of the University of California.
* Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -96,6 +96,7 @@ BOOST_AUTO_TEST_CASE(ParseRouteOrigin)
expectSuccess("Client", ROUTE_ORIGIN_CLIENT);
expectSuccess("AutoConf", ROUTE_ORIGIN_AUTOCONF);
expectSuccess("NLSR", ROUTE_ORIGIN_NLSR);
expectSuccess("SelfLearning", ROUTE_ORIGIN_SELFLEARNING);
expectSuccess("static", ROUTE_ORIGIN_STATIC);
expectSuccess("27", static_cast<RouteOrigin>(27));
@@ -118,6 +119,7 @@ BOOST_AUTO_TEST_CASE(PrintRouteOrigin)
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ROUTE_ORIGIN_CLIENT), "client");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ROUTE_ORIGIN_AUTOCONF), "autoconf");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ROUTE_ORIGIN_NLSR), "nlsr");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ROUTE_ORIGIN_SELFLEARNING), "selflearning");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ROUTE_ORIGIN_STATIC), "static");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<RouteOrigin>(27)), "27");
}