use ndn::ip::address(V6)FromString for scope-id aware conversion
Change-Id: Ifdc31771b8a990867c0a79ba42b71c87a97bcd56
Refs: #1428
diff --git a/core/network.cpp b/core/network.cpp
index 3360e62..19d6f50 100644
--- a/core/network.cpp
+++ b/core/network.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,
@@ -21,10 +21,11 @@
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
+ */
#include "network.hpp"
+#include <ndn-cxx/net/address-converter.hpp>
#include <boost/utility/value_init.hpp>
#include <algorithm>
@@ -105,11 +106,11 @@
size_t position = networkStr.find('/');
if (position == std::string::npos) {
- network.m_minAddress = ip::address::from_string(networkStr);
- network.m_maxAddress = ip::address::from_string(networkStr);
+ network.m_minAddress = ndn::ip::addressFromString(networkStr);
+ network.m_maxAddress = ndn::ip::addressFromString(networkStr);
}
else {
- ip::address address = ip::address::from_string(networkStr.substr(0, position));
+ ip::address address = ndn::ip::addressFromString(networkStr.substr(0, position));
size_t mask = boost::lexical_cast<size_t>(networkStr.substr(position+1));
if (address.is_v4()) {
diff --git a/daemon/face/tcp-factory.cpp b/daemon/face/tcp-factory.cpp
index 8214969..1546d24 100644
--- a/daemon/face/tcp-factory.cpp
+++ b/daemon/face/tcp-factory.cpp
@@ -25,6 +25,8 @@
#include "tcp-factory.hpp"
+#include <ndn-cxx/net/address-converter.hpp>
+
namespace nfd {
namespace face {
@@ -143,7 +145,7 @@
return;
}
- tcp::Endpoint endpoint(ip::address::from_string(params.remoteUri.getHost()),
+ tcp::Endpoint endpoint(ndn::ip::addressFromString(params.remoteUri.getHost()),
boost::lexical_cast<uint16_t>(params.remoteUri.getPort()));
// a canonical tcp4/tcp6 FaceUri cannot have a multicast address
@@ -184,7 +186,7 @@
shared_ptr<TcpChannel>
TcpFactory::createChannel(const std::string& localIp, const std::string& localPort)
{
- tcp::Endpoint endpoint(ip::address::from_string(localIp),
+ tcp::Endpoint endpoint(ndn::ip::addressFromString(localIp),
boost::lexical_cast<uint16_t>(localPort));
return createChannel(endpoint);
}
diff --git a/daemon/face/udp-factory.cpp b/daemon/face/udp-factory.cpp
index f44e4e9..57be339 100644
--- a/daemon/face/udp-factory.cpp
+++ b/daemon/face/udp-factory.cpp
@@ -27,6 +27,8 @@
#include "generic-link-service.hpp"
#include "multicast-udp-transport.hpp"
#include "core/global-io.hpp"
+
+#include <ndn-cxx/net/address-converter.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm/copy.hpp>
@@ -227,7 +229,7 @@
return;
}
- udp::Endpoint endpoint(ip::address::from_string(params.remoteUri.getHost()),
+ udp::Endpoint endpoint(ndn::ip::addressFromString(params.remoteUri.getHost()),
boost::lexical_cast<uint16_t>(params.remoteUri.getPort()));
if (endpoint.address().is_multicast()) {
@@ -286,7 +288,7 @@
UdpFactory::createChannel(const std::string& localIp, const std::string& localPort,
time::nanoseconds idleTimeout)
{
- udp::Endpoint endpoint(ip::address::from_string(localIp),
+ udp::Endpoint endpoint(ndn::ip::addressFromString(localIp),
boost::lexical_cast<uint16_t>(localPort));
return createChannel(endpoint, idleTimeout);
}
@@ -387,9 +389,9 @@
const std::string& multicastPort,
const std::string& networkInterfaceName)
{
- udp::Endpoint localEndpoint(ip::address::from_string(localIp),
+ udp::Endpoint localEndpoint(ndn::ip::addressFromString(localIp),
boost::lexical_cast<uint16_t>(multicastPort));
- udp::Endpoint multicastEndpoint(ip::address::from_string(multicastIp),
+ udp::Endpoint multicastEndpoint(ndn::ip::addressFromString(multicastIp),
boost::lexical_cast<uint16_t>(multicastPort));
return createMulticastFace(localEndpoint, multicastEndpoint, networkInterfaceName);
}
diff --git a/daemon/face/websocket-factory.cpp b/daemon/face/websocket-factory.cpp
index 9572216..6a87563 100644
--- a/daemon/face/websocket-factory.cpp
+++ b/daemon/face/websocket-factory.cpp
@@ -25,6 +25,8 @@
#include "websocket-factory.hpp"
+#include <ndn-cxx/net/address-converter.hpp>
+
namespace nfd {
namespace face {
@@ -141,7 +143,7 @@
shared_ptr<WebSocketChannel>
WebSocketFactory::createChannel(const std::string& localIp, const std::string& localPort)
{
- websocket::Endpoint endpoint(ip::address::from_string(localIp),
+ websocket::Endpoint endpoint(ndn::ip::addressFromString(localIp),
boost::lexical_cast<uint16_t>(localPort));
return createChannel(endpoint);
}
diff --git a/tests/other/face-benchmark.cpp b/tests/other/face-benchmark.cpp
index 2734e31..3532bdb 100644
--- a/tests/other/face-benchmark.cpp
+++ b/tests/other/face-benchmark.cpp
@@ -29,6 +29,7 @@
#include "face/tcp-channel.hpp"
#include "face/udp-channel.hpp"
+#include <ndn-cxx/net/address-converter.hpp>
#include <fstream>
#include <iostream>
@@ -124,7 +125,7 @@
}
// create the right face
- auto addr = boost::asio::ip::address::from_string(uriR.getHost());
+ auto addr = ndn::ip::addressFromString(uriR.getHost());
auto port = boost::lexical_cast<uint16_t>(uriR.getPort());
if (uriR.getScheme() == "tcp4") {
m_tcpChannel.connect(tcp::Endpoint(addr, port),
diff --git a/tools/nfd-autoreg.cpp b/tools/nfd-autoreg.cpp
index cb0bdd2..5c7473f 100644
--- a/tools/nfd-autoreg.cpp
+++ b/tools/nfd-autoreg.cpp
@@ -32,6 +32,7 @@
#include <ndn-cxx/mgmt/nfd/controller.hpp>
#include <ndn-cxx/mgmt/nfd/face-monitor.hpp>
#include <ndn-cxx/mgmt/nfd/face-status.hpp>
+#include <ndn-cxx/net/address-converter.hpp>
#include <ndn-cxx/net/face-uri.hpp>
#include <ndn-cxx/security/key-chain.hpp>
@@ -123,7 +124,7 @@
{
if (hasAllowedSchema(uri)) {
boost::system::error_code ec;
- boost::asio::ip::address address = boost::asio::ip::address::from_string(uri.getHost(), ec);
+ boost::asio::ip::address address = ndn::ip::addressFromString(uri.getHost(), ec);
if (!address.is_multicast()) {
// register all-face prefixes