Avoid deprecated ndn-cxx functions

Change-Id: I763368c2ea12902b4ea400f92c23b17ad5a5628e
This commit is contained in:
Davide Pesavento committed 2022-03-19 03:55:25 -04:00
1 parent d1f1df802c
commit e28d8756ce
17 files changed
+68 -91

No files matched your search

+2 -3
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2021, The University of Memphis,
* Copyright (c) 2014-2022, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -156,8 +156,7 @@ ConfParameter::initializeKey()
certificate->setFreshnessPeriod(365_days);
// set content
certificate->setContent(nlsrInstanceKey.getPublicKey().data(),
nlsrInstanceKey.getPublicKey().size());
certificate->setContent(nlsrInstanceKey.getPublicKey());
// set signature-info
ndn::SignatureInfo signatureInfo;
+6 -6
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2021, The University of Memphis,
* Copyright (c) 2014-2022, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -103,7 +103,7 @@ HelloProtocol::sendHelloInterest(const ndn::Name& neighbor)
ndn::Name interestName = adjacent->getName() ;
interestName.append(NLSR_COMPONENT);
interestName.append(INFO_COMPONENT);
interestName.append(m_confParam.getRouterPrefix().wireEncode());
interestName.append(ndn::tlv::GenericNameComponent, m_confParam.getRouterPrefix().wireEncode());
expressInterest(interestName, m_confParam.getInterestResendTime());
NLSR_LOG_DEBUG("Sending HELLO interest: " << interestName);
}
@@ -136,8 +136,8 @@ HelloProtocol::processInterest(const ndn::Name& name,
std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>();
data->setName(ndn::Name(interest.getName()).appendVersion());
data->setFreshnessPeriod(ndn::time::seconds(10)); // 10 sec
data->setContent(reinterpret_cast<const uint8_t*>(INFO_COMPONENT.c_str()),
INFO_COMPONENT.size());
data->setContent(ndn::make_span(reinterpret_cast<const uint8_t*>(INFO_COMPONENT.data()),
INFO_COMPONENT.size()));
m_keyChain.sign(*data, m_signingInfo);
@@ -156,7 +156,7 @@ HelloProtocol::processInterest(const ndn::Name& name,
ndn::Name interestName(neighbor);
interestName.append(NLSR_COMPONENT);
interestName.append(INFO_COMPONENT);
interestName.append(m_confParam.getRouterPrefix().wireEncode());
interestName.append(ndn::tlv::GenericNameComponent, m_confParam.getRouterPrefix().wireEncode());
expressInterest(interestName, m_confParam.getInterestResendTime());
}
}
@@ -186,7 +186,7 @@ HelloProtocol::processInterestTimedOut(const ndn::Interest& interest)
ndn::Name interestName(neighbor);
interestName.append(NLSR_COMPONENT);
interestName.append(INFO_COMPONENT);
interestName.append(m_confParam.getRouterPrefix().wireEncode());
interestName.append(ndn::tlv::GenericNameComponent, m_confParam.getRouterPrefix().wireEncode());
NLSR_LOG_DEBUG("Resending interest: " << interestName);
expressInterest(interestName, m_confParam.getInterestResendTime());
}
+5 -9
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2021, The University of Memphis,
* Copyright (c) 2014-2022, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -52,8 +52,7 @@ Lsa::wireEncode(ndn::EncodingImpl<TAG>& encoder) const
ndn::tlv::nlsr::ExpirationTime,
ndn::time::toString(m_expirationTimePoint));
totalLength += prependNonNegativeIntegerBlock(encoder, ndn::tlv::nlsr::SequenceNumber,
m_seqNo);
totalLength += prependNonNegativeIntegerBlock(encoder, ndn::tlv::nlsr::SequenceNumber, m_seqNo);
totalLength += m_originRouter.wireEncode(encoder);
@@ -105,18 +104,15 @@ std::ostream&
operator<<(std::ostream& os, const Lsa::Type& type)
{
switch (type) {
case nlsr::Lsa::Type::ADJACENCY:
case Lsa::Type::ADJACENCY:
os << "ADJACENCY";
break;
case nlsr::Lsa::Type::COORDINATE:
case Lsa::Type::COORDINATE:
os << "COORDINATE";
break;
case nlsr::Lsa::Type::NAME:
case Lsa::Type::NAME:
os << "NAME";
break;
default:
os << "BASE";
break;
+2 -2
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2020, Regents of the University of California,
* Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -128,7 +128,7 @@ IdentityManagementFixture::addCertificate(const ndn::security::Key& key,
certificate.setFreshnessPeriod(time::hours(1));
// set content
certificate.setContent(key.getPublicKey().data(), key.getPublicKey().size());
certificate.setContent(key.getPublicKey());
// set signature-info
ndn::SignatureInfo info;
+5 -9
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2020, The University of Memphis,
* Copyright (c) 2014-2022, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -26,13 +26,13 @@ namespace test {
BOOST_AUTO_TEST_SUITE(TestNexthop)
double
static double
getHyperbolicAdjustedDecimal(unsigned int i)
{
return static_cast<double>(i)/(10*NextHop::HYPERBOLIC_COST_ADJUSTMENT_FACTOR);
}
uint64_t
static uint64_t
applyHyperbolicFactorAndRound(double d)
{
return round(NextHop::HYPERBOLIC_COST_ADJUSTMENT_FACTOR*d);
@@ -117,17 +117,13 @@ BOOST_AUTO_TEST_CASE(NexthopEncode)
nexthops1.setConnectingFaceUri("/test/nexthop/tlv");
nexthops1.setRouteCost(1.65);
const ndn::Block& wire = nexthops1.wireEncode();
BOOST_REQUIRE_EQUAL_COLLECTIONS(NexthopData,
NexthopData + sizeof(NexthopData),
wire.begin(), wire.end());
BOOST_TEST(nexthops1.wireEncode() == NexthopData, boost::test_tools::per_element());
}
BOOST_AUTO_TEST_CASE(NexthopDecode)
{
NextHop nexthops1;
nexthops1.wireDecode(ndn::Block(NexthopData, sizeof(NexthopData)));
nexthops1.wireDecode(ndn::Block{NexthopData});
BOOST_REQUIRE_EQUAL(nexthops1.getConnectingFaceUri(), "/test/nexthop/tlv");
BOOST_REQUIRE_EQUAL(nexthops1.getRouteCost(), 1.65);
+8 -21
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2020, The University of Memphis,
* Copyright (c) 2014-2022, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -69,18 +69,13 @@ BOOST_AUTO_TEST_CASE(RoutingTableEntryEncodeWithNexthops)
nexthops2.setRouteCost(1.65);
rte.getNexthopList().addNextHop(nexthops2);
const ndn::Block& wire = rte.wireEncode();
BOOST_REQUIRE_EQUAL_COLLECTIONS(RoutingTableEntryWithNexthopsData,
RoutingTableEntryWithNexthopsData +
sizeof(RoutingTableEntryWithNexthopsData),
wire.begin(), wire.end());
BOOST_TEST(rte.wireEncode() == RoutingTableEntryWithNexthopsData,
boost::test_tools::per_element());
}
BOOST_AUTO_TEST_CASE(RoutingTableEntryDecodeWithNexthops)
{
RoutingTableEntry rte(ndn::Block(RoutingTableEntryWithNexthopsData,
sizeof(RoutingTableEntryWithNexthopsData)));
RoutingTableEntry rte(ndn::Block{RoutingTableEntryWithNexthopsData});
BOOST_CHECK_EQUAL(rte.getDestination(), "dest1");
BOOST_CHECK(rte.getNexthopList().size() != 0);
@@ -96,25 +91,17 @@ BOOST_AUTO_TEST_CASE(RoutingTableEntryDecodeWithNexthops)
BOOST_AUTO_TEST_CASE(RoutingTableEntryEncodeWithoutNexthops)
{
RoutingTableEntry rte(ndn::Name("dest1"));
auto wire = rte.wireEncode();
BOOST_REQUIRE_EQUAL_COLLECTIONS(RoutingTableEntryWithoutNexthopsData,
RoutingTableEntryWithoutNexthopsData +
sizeof(RoutingTableEntryWithoutNexthopsData),
wire.begin(), wire.end());
BOOST_TEST(rte.wireEncode() == RoutingTableEntryWithoutNexthopsData,
boost::test_tools::per_element());
}
BOOST_AUTO_TEST_CASE(RoutingTableEntryDecodeWithoutNexthops)
{
RoutingTableEntry rte(ndn::Block(RoutingTableEntryWithoutNexthopsData,
sizeof(RoutingTableEntryWithoutNexthopsData)));
RoutingTableEntry rte(ndn::Block{RoutingTableEntryWithoutNexthopsData});
BOOST_CHECK_EQUAL(rte.getDestination(), "dest1");
BOOST_CHECK(rte.getNexthopList().size() == 0);
BOOST_CHECK_EQUAL(rte.getNexthopList().size(), 0);
}
BOOST_AUTO_TEST_CASE(RoutingTableEntryClear)
{
RoutingTableEntry rte(ndn::Name("dest1"));
+2 -2
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2021, The University of Memphis,
* Copyright (c) 2014-2022, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -102,7 +102,7 @@ BOOST_FIXTURE_TEST_CASE(RoutingTableEncode2, RoutingTableFixture)
BOOST_FIXTURE_TEST_CASE(RoutingTableDecode1, RoutingTableFixture)
{
RoutingTableStatus rtStatus(ndn::Block(RoutingTableData1, sizeof(RoutingTableData1)));
RoutingTableStatus rtStatus(ndn::Block{RoutingTableData1});
auto it1 = rtStatus.m_rTable.begin();
+4 -5
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2021, The University of Memphis,
* Copyright (c) 2014-2022, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -24,10 +24,10 @@
#include "common.hpp"
#include "conf-parameter.hpp"
#include "identity-management-fixture.hpp"
#include "route/fib.hpp"
#include "boost-test.hpp"
#include "route/fib.hpp"
#include "identity-management-fixture.hpp"
#include <boost/asio.hpp>
@@ -132,7 +132,7 @@ public:
payload2.wireEncode(buffer);
payload1.wireEncode(buffer);
this->sendDatasetReply(prefix, buffer.buf(), buffer.size());
this->sendDatasetReply(prefix, buffer);
}
/** \brief send a payload in reply to StatusDataset request
@@ -186,7 +186,6 @@ public:
conf.setSiteName(siteName);
conf.setRouterName(routerName);
conf.buildRouterAndSyncUserPrefix();
conf.setSyncProtocol(protocol);
conf.setHyperbolicState(hyperbolicState);
}
+4 -4
View File
@@ -129,10 +129,10 @@ BOOST_AUTO_TEST_CASE(CheckHelloDataValidatedSignal) // # 5157
Adjacent::STATUS_INACTIVE, 0, 300);
adjList.insert(adj1);
ndn::Name dataName = adj1.getName() ;
dataName.append(nlsr::HelloProtocol::NLSR_COMPONENT);
dataName.append(nlsr::HelloProtocol::INFO_COMPONENT);
dataName.append(conf.getRouterPrefix().wireEncode());
ndn::Name dataName = adj1.getName();
dataName.append(HelloProtocol::NLSR_COMPONENT);
dataName.append(HelloProtocol::INFO_COMPONENT);
dataName.append(ndn::tlv::GenericNameComponent, conf.getRouterPrefix().wireEncode());
ndn::Data data(ndn::Name(dataName).appendVersion());
BOOST_CHECK_EQUAL(numOnInitialHelloDataValidates, 0);
+12 -13
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2021, The University of Memphis,
* Copyright (c) 2014-2022, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -31,10 +31,11 @@
namespace nlsr {
namespace test {
/*static void
printBytes(const uint8_t* buf, size_t size)
/*
static void
printBytes(ndn::span<const uint8_t> buf)
{
std::string hex = ndn::toHex(buf, size);
std::string hex = ndn::toHex(buf);
for (size_t i = 0; i < hex.size(); i++) {
if (i > 0 && i % 30 == 0)
@@ -49,7 +50,8 @@ printBytes(const uint8_t* buf, size_t size)
std::cout << "\n" << "};" << std::endl;
}
printBytes(wire.wire(), wire.size());*/
printBytes(block);
*/
BOOST_AUTO_TEST_SUITE(TestLsa)
@@ -90,8 +92,7 @@ BOOST_AUTO_TEST_CASE(NameLsaBasic)
ndn::Name s2{"name2"};
NamePrefixList npl1{s1, s2};
ndn::time::system_clock::TimePoint testTimePoint =
ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196014943));
auto testTimePoint = ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196014943));
// 3rd argument is seqNo
NameLsa nlsa1("router1", 12, testTimePoint, npl1);
@@ -172,8 +173,7 @@ BOOST_AUTO_TEST_CASE(AdjLsaBasic)
{
ndn::Name routerName("/ndn/site/router");
ndn::Name adjacencyName("/ndn/site/adjacency");
ndn::time::system_clock::TimePoint testTimePoint =
ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196014943));
auto testTimePoint = ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196014943));
uint32_t seqNo = 12;
// An AdjLsa initialized with ACTIVE adjacencies should copy the adjacencies
@@ -272,9 +272,8 @@ const uint8_t COORDINATE_LSA_DIFF_TS[] = {
BOOST_AUTO_TEST_CASE(CoordinateLsaBasic)
{
ndn::time::system_clock::TimePoint testTimePoint =
ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196014943));
std::vector<double> angles1 {30.0}, angles2 {30.0};
auto testTimePoint = ndn::time::fromUnixTimestamp(ndn::time::milliseconds(1585196014943));
std::vector<double> angles1{30.0}, angles2{30.0};
angles1.push_back(30.0);
angles2.push_back(30.0);
CoordinateLsa clsa1("router1", 12, testTimePoint, 2.5, angles1);
@@ -369,7 +368,7 @@ BOOST_AUTO_TEST_CASE(TestInitializeFromContent)
adjList.insert(adj1);
adjList.insert(adj2);
ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now();
auto testTimePoint = ndn::time::system_clock::now();
AdjLsa adjlsa1("router1", 1, testTimePoint, adjList.size(), adjList);
AdjLsa adjlsa2(adjlsa1.wireEncode());
+5 -3
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2021, The University of Memphis,
* Copyright (c) 2014-2022, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -48,10 +48,12 @@ public:
receiveHelloData(const ndn::Name& sender, const ndn::Name& receiver)
{
ndn::Name dataName(sender);
dataName.append("NLSR").append("INFO").append(receiver.wireEncode()).appendVersion();
dataName.append("NLSR")
.append("INFO")
.append(ndn::tlv::GenericNameComponent, receiver.wireEncode())
.appendVersion();
ndn::Data data(dataName);
nlsr.m_helloProtocol.onContentValidated(data);
}
+5 -4
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2021, The University of Memphis,
* Copyright (c) 2014-2022, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -20,11 +20,12 @@
*/
#include "statistics.hpp"
#include "test-common.hpp"
#include "hello-protocol.hpp"
#include "lsdb.hpp"
#include "nlsr.hpp"
#include "test-common.hpp"
#include <ndn-cxx/util/dummy-client-face.hpp>
#include <boost/lexical_cast.hpp>
@@ -158,7 +159,7 @@ BOOST_AUTO_TEST_CASE(SendHelloInterest)
ndn::Name otherName(other.getName());
otherName.append("NLSR");
otherName.append("INFO");
otherName.append(conf.getRouterPrefix().wireEncode());
otherName.append(ndn::tlv::GenericNameComponent, conf.getRouterPrefix().wireEncode());
hello.expressInterest(otherName, 1);
this->advanceClocks(ndn::time::milliseconds(1), 10);
@@ -168,7 +169,7 @@ BOOST_AUTO_TEST_CASE(SendHelloInterest)
ndn::Name thisName(conf.getRouterPrefix());
thisName.append("NLSR");
thisName.append("INFO");
thisName.append(other.getName().wireEncode());
thisName.append(ndn::tlv::GenericNameComponent, other.getName().wireEncode());
ndn::Interest interest(thisName);
hello.processInterest(ndn::Name(), interest);
+1 -1
View File
@@ -83,7 +83,7 @@ BOOST_AUTO_TEST_CASE(ReceiveAdvertiseInterest)
ndn::nfd::ControlParameters parameters;
parameters.setName("/prefix/to/advertise");
ndn::Name advertiseCommand("/localhost/nlsr/prefix-update/advertise");
advertiseCommand.append(parameters.wireEncode());
advertiseCommand.append(ndn::tlv::GenericNameComponent, parameters.wireEncode());
auto advertiseInterest = std::make_shared<ndn::Interest>(advertiseCommand);
face.receive(*advertiseInterest);
@@ -54,7 +54,7 @@ public:
void
sendCommand(ndn::Name prefix, const ndn::nfd::ControlParameters& parameters)
{
ndn::Interest interest(prefix.append(parameters.wireEncode()));
ndn::Interest interest(prefix.append(ndn::tlv::GenericNameComponent, parameters.wireEncode()));
face.receive(interest);
this->advanceClocks(ndn::time::milliseconds(10), 10);
}
@@ -161,7 +161,7 @@ BOOST_AUTO_TEST_CASE(Basic)
ndn::Name advertiseCommand("/localhost/nlsr/prefix-update/advertise");
// append /<control-parameters>
advertiseCommand.append(parameters.wireEncode());
advertiseCommand.append(ndn::tlv::GenericNameComponent, parameters.wireEncode());
ndn::security::InterestSigner signer(m_keyChain);
@@ -186,7 +186,7 @@ BOOST_AUTO_TEST_CASE(Basic)
// Withdraw
ndn::Name withdrawCommand("/localhost/nlsr/prefix-update/withdraw");
withdrawCommand.append(parameters.wireEncode());
withdrawCommand.append(ndn::tlv::GenericNameComponent, parameters.wireEncode());
auto withdrawInterest= signer.makeCommandInterest(withdrawCommand,
ndn::security::signingByIdentity(opIdentity));
+3 -3
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2021, The University of Memphis,
* Copyright (c) 2014-2022, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -144,11 +144,11 @@ public:
ndn::security::InterestSigner signer(m_keyChain);
// type true for advertise, else withdraw
if (type == "advertise") {
advertiseCommand.append(parameters.wireEncode());
advertiseCommand.append(ndn::tlv::GenericNameComponent, parameters.wireEncode());
return signer.makeCommandInterest(advertiseCommand, ndn::security::signingByIdentity(opIdentity));
}
else {
withdrawCommand.append(parameters.wireEncode());
withdrawCommand.append(ndn::tlv::GenericNameComponent, parameters.wireEncode());
return signer.makeCommandInterest(withdrawCommand, ndn::security::signingByIdentity(opIdentity));
}
}
+1 -3
View File
@@ -1,6 +1,6 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
"""
Copyright (c) 2014-2021, The University of Memphis,
Copyright (c) 2014-2022, The University of Memphis,
Regents of the University of California,
Arizona Board of Regents.
@@ -24,8 +24,6 @@ import os, subprocess
VERSION = "0.6.0"
APPNAME = "nlsr"
BUGREPORT = "https://redmine.named-data.net/projects/nlsr"
URL = "https://named-data.net/doc/NLSR/"
GIT_TAG_PREFIX = "NLSR-"
def options(opt):