[ndnSIM] More intrusive changes removing use of boost::asio::io_service
Use of either removed or replaced with defunct DummyIoService for API
compatibility.
Change-Id: I9f99a944bf5cd082180e3f0ebccf977d5bf73f26
diff --git a/src/transport/stream-transport-impl.hpp b/src/transport/stream-transport-impl.hpp
deleted file mode 100644
index c8f1527..0000000
--- a/src/transport/stream-transport-impl.hpp
+++ /dev/null
@@ -1,283 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2013-2017 Regents of the University of California.
- *
- * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
- *
- * ndn-cxx library is free software: you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later version.
- *
- * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- *
- * You should have received copies of the GNU General Public License and GNU Lesser
- * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
- */
-
-#ifndef NDN_TRANSPORT_STREAM_TRANSPORT_IMPL_HPP
-#define NDN_TRANSPORT_STREAM_TRANSPORT_IMPL_HPP
-
-#include "transport.hpp"
-
-#include <boost/asio/deadline_timer.hpp>
-#include <boost/asio/write.hpp>
-
-#include <list>
-
-namespace ndn {
-
-/** \brief implementation detail of a Boost.Asio-based stream-oriented transport
- * \tparam BaseTransport a subclass of Transport
- * \tparam Protocol a Boost.Asio stream-oriented protocol, including boost::asio::ip::tcp
- * and boost::asio::local::stream_protocol
- */
-template<typename BaseTransport, typename Protocol>
-class StreamTransportImpl : public enable_shared_from_this<StreamTransportImpl<BaseTransport, Protocol>>
-{
-public:
- typedef StreamTransportImpl<BaseTransport, Protocol> Impl;
- typedef std::list<Block> BlockSequence;
- typedef std::list<BlockSequence> TransmissionQueue;
-
- StreamTransportImpl(BaseTransport& transport, boost::asio::io_service& ioService)
- : m_transport(transport)
- , m_socket(ioService)
- , m_inputBufferSize(0)
- , m_isConnecting(false)
- , m_connectTimer(ioService)
- {
- }
-
- void
- connect(const typename Protocol::endpoint& endpoint)
- {
- if (!m_isConnecting) {
- m_isConnecting = true;
-
- // Wait at most 4 seconds to connect
- /// @todo Decide whether this number should be configurable
- m_connectTimer.expires_from_now(boost::posix_time::seconds(4));
- m_connectTimer.async_wait(bind(&Impl::connectTimeoutHandler, this->shared_from_this(), _1));
-
- m_socket.open();
- m_socket.async_connect(endpoint, bind(&Impl::connectHandler, this->shared_from_this(), _1));
- }
- }
-
- void
- close()
- {
- m_isConnecting = false;
-
- boost::system::error_code error; // to silently ignore all errors
- m_connectTimer.cancel(error);
- m_socket.cancel(error);
- m_socket.close(error);
-
- m_transport.m_isConnected = false;
- m_transport.m_isReceiving = false;
- m_transmissionQueue.clear();
- }
-
- void
- pause()
- {
- if (m_isConnecting)
- return;
-
- if (m_transport.m_isReceiving) {
- m_transport.m_isReceiving = false;
- m_socket.cancel();
- }
- }
-
- void
- resume()
- {
- if (m_isConnecting)
- return;
-
- if (!m_transport.m_isReceiving) {
- m_transport.m_isReceiving = true;
- m_inputBufferSize = 0;
- asyncReceive();
- }
- }
-
- void
- send(const Block& wire)
- {
- BlockSequence sequence;
- sequence.push_back(wire);
- send(std::move(sequence));
- }
-
- void
- send(const Block& header, const Block& payload)
- {
- BlockSequence sequence;
- sequence.push_back(header);
- sequence.push_back(payload);
- send(std::move(sequence));
- }
-
-protected:
- void
- connectHandler(const boost::system::error_code& error)
- {
- m_isConnecting = false;
- m_connectTimer.cancel();
-
- if (!error) {
- m_transport.m_isConnected = true;
-
- if (!m_transmissionQueue.empty()) {
- resume();
- asyncWrite();
- }
- }
- else {
- m_transport.m_isConnected = false;
- m_transport.close();
- BOOST_THROW_EXCEPTION(Transport::Error(error, "error while connecting to the forwarder"));
- }
- }
-
- void
- connectTimeoutHandler(const boost::system::error_code& error)
- {
- if (error) // e.g., cancelled timer
- return;
-
- m_transport.close();
- BOOST_THROW_EXCEPTION(Transport::Error(error, "error while connecting to the forwarder"));
- }
-
- void
- send(BlockSequence&& sequence)
- {
- m_transmissionQueue.emplace_back(sequence);
-
- if (m_transport.m_isConnected && m_transmissionQueue.size() == 1) {
- asyncWrite();
- }
-
- // if not connected or there is transmission in progress (m_transmissionQueue.size() > 1),
- // next write will be scheduled either in connectHandler or in asyncWriteHandler
- }
-
- void
- asyncWrite()
- {
- BOOST_ASSERT(!m_transmissionQueue.empty());
- boost::asio::async_write(m_socket, m_transmissionQueue.front(),
- bind(&Impl::handleAsyncWrite, this->shared_from_this(), _1, m_transmissionQueue.begin()));
- }
-
- void
- handleAsyncWrite(const boost::system::error_code& error, TransmissionQueue::iterator queueItem)
- {
- if (error) {
- if (error == boost::system::errc::operation_canceled) {
- // async receive has been explicitly cancelled (e.g., socket close)
- return;
- }
-
- m_transport.close();
- BOOST_THROW_EXCEPTION(Transport::Error(error, "error while sending data to socket"));
- }
-
- if (!m_transport.m_isConnected) {
- return; // queue has been already cleared
- }
-
- m_transmissionQueue.erase(queueItem);
-
- if (!m_transmissionQueue.empty()) {
- asyncWrite();
- }
- }
-
- void
- asyncReceive()
- {
- m_socket.async_receive(boost::asio::buffer(m_inputBuffer + m_inputBufferSize,
- MAX_NDN_PACKET_SIZE - m_inputBufferSize), 0,
- bind(&Impl::handleAsyncReceive, this->shared_from_this(), _1, _2));
- }
-
- void
- handleAsyncReceive(const boost::system::error_code& error, std::size_t nBytesRecvd)
- {
- if (error) {
- if (error == boost::system::errc::operation_canceled) {
- // async receive has been explicitly cancelled (e.g., socket close)
- return;
- }
-
- m_transport.close();
- BOOST_THROW_EXCEPTION(Transport::Error(error, "error while receiving data from socket"));
- }
-
- m_inputBufferSize += nBytesRecvd;
- // do magic
-
- std::size_t offset = 0;
- bool hasProcessedSome = processAllReceived(m_inputBuffer, offset, m_inputBufferSize);
- if (!hasProcessedSome && m_inputBufferSize == MAX_NDN_PACKET_SIZE && offset == 0) {
- m_transport.close();
- BOOST_THROW_EXCEPTION(Transport::Error(boost::system::error_code(),
- "input buffer full, but a valid TLV cannot be "
- "decoded"));
- }
-
- if (offset > 0) {
- if (offset != m_inputBufferSize) {
- std::copy(m_inputBuffer + offset, m_inputBuffer + m_inputBufferSize, m_inputBuffer);
- m_inputBufferSize -= offset;
- }
- else {
- m_inputBufferSize = 0;
- }
- }
-
- asyncReceive();
- }
-
- bool
- processAllReceived(uint8_t* buffer, size_t& offset, size_t nBytesAvailable)
- {
- while (offset < nBytesAvailable) {
- bool isOk = false;
- Block element;
- std::tie(isOk, element) = Block::fromBuffer(buffer + offset, nBytesAvailable - offset);
- if (!isOk)
- return false;
-
- m_transport.receive(element);
- offset += element.size();
- }
- return true;
- }
-
-protected:
- BaseTransport& m_transport;
-
- typename Protocol::socket m_socket;
- uint8_t m_inputBuffer[MAX_NDN_PACKET_SIZE];
- size_t m_inputBufferSize;
-
- TransmissionQueue m_transmissionQueue;
- bool m_isConnecting;
-
- boost::asio::deadline_timer m_connectTimer;
-};
-
-} // namespace ndn
-
-#endif // NDN_TRANSPORT_STREAM_TRANSPORT_IMPL_HPP
diff --git a/src/transport/stream-transport-with-resolver-impl.hpp b/src/transport/stream-transport-with-resolver-impl.hpp
deleted file mode 100644
index b9150d8..0000000
--- a/src/transport/stream-transport-with-resolver-impl.hpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2013-2017 Regents of the University of California.
- *
- * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
- *
- * ndn-cxx library is free software: you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later version.
- *
- * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- *
- * You should have received copies of the GNU General Public License and GNU Lesser
- * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
- */
-
-#ifndef NDN_TRANSPORT_STREAM_TRANSPORT_WITH_RESOLVER_IMPL_HPP
-#define NDN_TRANSPORT_STREAM_TRANSPORT_WITH_RESOLVER_IMPL_HPP
-
-#include "stream-transport-impl.hpp"
-
-namespace ndn {
-
-/** \brief implementation detail of a Boost.Asio-based stream-oriented transport
- * with resolver support
- */
-template<typename BaseTransport, typename Protocol>
-class StreamTransportWithResolverImpl : public StreamTransportImpl<BaseTransport, Protocol>
-{
-public:
- using Impl = StreamTransportWithResolverImpl<BaseTransport,Protocol>;
-
- StreamTransportWithResolverImpl(BaseTransport& transport, boost::asio::io_service& ioService)
- : StreamTransportImpl<BaseTransport, Protocol>(transport, ioService)
- {
- }
-
- void
- connect(const typename Protocol::resolver::query& query)
- {
- if (this->m_isConnecting) {
- return;
- }
-
- this->m_isConnecting = true;
-
- // Wait at most 4 seconds to connect
- /// @todo Decide whether this number should be configurable
- this->m_connectTimer.expires_from_now(boost::posix_time::seconds(4));
- this->m_connectTimer.async_wait(bind(&Impl::connectTimeoutHandler, this->shared_from_this(), _1));
-
- auto resolver = make_shared<typename Protocol::resolver>(ref(this->m_socket.get_io_service()));
- resolver->async_resolve(query, bind(&Impl::resolveHandler, this->shared_from_base(), _1, _2, resolver));
- }
-
-protected:
- void
- resolveHandler(const boost::system::error_code& error,
- typename Protocol::resolver::iterator endpoint,
- const shared_ptr<typename Protocol::resolver>&)
- {
- if (error) {
- if (error == boost::system::errc::operation_canceled)
- return;
-
- BOOST_THROW_EXCEPTION(Transport::Error(error, "Error during resolution of host or port"));
- }
-
- typename Protocol::resolver::iterator end;
- if (endpoint == end) {
- this->m_transport.close();
- BOOST_THROW_EXCEPTION(Transport::Error(error, "Unable to resolve host or port"));
- }
-
- this->m_socket.async_connect(*endpoint, bind(&Impl::connectHandler, this->shared_from_this(), _1));
- }
-
-private:
- shared_ptr<Impl>
- shared_from_base()
- {
- return static_pointer_cast<Impl>(this->shared_from_this());
- }
-};
-
-
-} // namespace ndn
-
-#endif // NDN_TRANSPORT_STREAM_TRANSPORT_WITH_RESOLVER_IMPL_HPP
diff --git a/src/transport/tcp-transport.cpp b/src/transport/tcp-transport.cpp
deleted file mode 100644
index 8b99f3e..0000000
--- a/src/transport/tcp-transport.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2013-2017 Regents of the University of California.
- *
- * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
- *
- * ndn-cxx library is free software: you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later version.
- *
- * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- *
- * You should have received copies of the GNU General Public License and GNU Lesser
- * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
- */
-
-#include "tcp-transport.hpp"
-#include "stream-transport-with-resolver-impl.hpp"
-#include "net/face-uri.hpp"
-#include "util/logger.hpp"
-
-NDN_LOG_INIT(ndn.TcpTransport);
-// DEBUG level: connect, close, pause, resume.
-
-namespace ndn {
-
-TcpTransport::TcpTransport(const std::string& host, const std::string& port/* = "6363"*/)
- : m_host(host)
- , m_port(port)
-{
-}
-
-TcpTransport::~TcpTransport() = default;
-
-shared_ptr<TcpTransport>
-TcpTransport::create(const std::string& uri)
-{
- const auto hostAndPort(getSocketHostAndPortFromUri(uri));
- return make_shared<TcpTransport>(hostAndPort.first, hostAndPort.second);
-}
-
-std::pair<std::string, std::string>
-TcpTransport::getSocketHostAndPortFromUri(const std::string& uriString)
-{
- std::string host = "localhost";
- std::string port = "6363";
-
- if (uriString.empty()) {
- return {host, port};
- }
-
- try {
- const FaceUri uri(uriString);
-
- const std::string scheme = uri.getScheme();
- if (scheme != "tcp" && scheme != "tcp4" && scheme != "tcp6") {
- BOOST_THROW_EXCEPTION(Error("Cannot create TcpTransport from \"" + scheme + "\" URI"));
- }
-
- if (!uri.getHost().empty()) {
- host = uri.getHost();
- }
-
- if (!uri.getPort().empty()) {
- port = uri.getPort();
- }
- }
- catch (const FaceUri::Error& error) {
- BOOST_THROW_EXCEPTION(Error(error.what()));
- }
-
- return {host, port};
-}
-
-void
-TcpTransport::connect(boost::asio::io_service& ioService,
- const ReceiveCallback& receiveCallback)
-{
- NDN_LOG_DEBUG("connect host=" << m_host << " port=" << m_port);
-
- if (m_impl == nullptr) {
- Transport::connect(ioService, receiveCallback);
-
- m_impl = make_shared<Impl>(ref(*this), ref(ioService));
- }
-
- boost::asio::ip::tcp::resolver::query query(m_host, m_port);
- m_impl->connect(query);
-}
-
-void
-TcpTransport::send(const Block& wire)
-{
- BOOST_ASSERT(m_impl != nullptr);
- m_impl->send(wire);
-}
-
-void
-TcpTransport::send(const Block& header, const Block& payload)
-{
- BOOST_ASSERT(m_impl != nullptr);
- m_impl->send(header, payload);
-}
-
-void
-TcpTransport::close()
-{
- BOOST_ASSERT(m_impl != nullptr);
- NDN_LOG_DEBUG("close");
- m_impl->close();
- m_impl.reset();
-}
-
-void
-TcpTransport::pause()
-{
- if (m_impl != nullptr) {
- NDN_LOG_DEBUG("pause");
- m_impl->pause();
- }
-}
-
-void
-TcpTransport::resume()
-{
- BOOST_ASSERT(m_impl != nullptr);
- NDN_LOG_DEBUG("resume");
- m_impl->resume();
-}
-
-} // namespace ndn
diff --git a/src/transport/tcp-transport.hpp b/src/transport/tcp-transport.hpp
deleted file mode 100644
index 6e8977f..0000000
--- a/src/transport/tcp-transport.hpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2013-2017 Regents of the University of California.
- *
- * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
- *
- * ndn-cxx library is free software: you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later version.
- *
- * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- *
- * You should have received copies of the GNU General Public License and GNU Lesser
- * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
- */
-
-#ifndef NDN_TRANSPORT_TCP_TRANSPORT_HPP
-#define NDN_TRANSPORT_TCP_TRANSPORT_HPP
-
-#include "transport.hpp"
-#include "../util/config-file.hpp"
-
-#include <boost/asio/ip/tcp.hpp>
-
-namespace ndn {
-
-template<typename BaseTransport, typename Protocol>
-class StreamTransportImpl;
-
-template<typename BaseTransport, typename Protocol>
-class StreamTransportWithResolverImpl;
-
-/** \brief a transport using TCP socket
- */
-class TcpTransport : public Transport
-{
-public:
- explicit
- TcpTransport(const std::string& host, const std::string& port = "6363");
-
- ~TcpTransport() override;
-
- void
- connect(boost::asio::io_service& ioService, const ReceiveCallback& receiveCallback) override;
-
- void
- close() override;
-
- void
- pause() override;
-
- void
- resume() override;
-
- void
- send(const Block& wire) override;
-
- void
- send(const Block& header, const Block& payload) override;
-
- /** \brief Create transport with parameters defined in URI
- * \throw Transport::Error incorrect URI or unsupported protocol is specified
- */
- static shared_ptr<TcpTransport>
- create(const std::string& uri);
-
-NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
- static std::pair<std::string, std::string>
- getSocketHostAndPortFromUri(const std::string& uri);
-
-private:
- std::string m_host;
- std::string m_port;
-
- using Impl = StreamTransportWithResolverImpl<TcpTransport, boost::asio::ip::tcp>;
- friend class StreamTransportImpl<TcpTransport, boost::asio::ip::tcp>;
- friend Impl;
- shared_ptr<Impl> m_impl;
-};
-
-} // namespace ndn
-
-#endif // NDN_TRANSPORT_TCP_TRANSPORT_HPP
diff --git a/src/transport/transport.cpp b/src/transport/transport.cpp
index 0ea5bee..7cca3a2 100644
--- a/src/transport/transport.cpp
+++ b/src/transport/transport.cpp
@@ -34,19 +34,16 @@
}
Transport::Transport()
- : m_ioService(nullptr)
- , m_isConnected(false)
+ : m_isConnected(false)
, m_isReceiving(false)
{
}
void
-Transport::connect(boost::asio::io_service& ioService,
- const ReceiveCallback& receiveCallback)
+Transport::connect(const ReceiveCallback& receiveCallback)
{
BOOST_ASSERT(receiveCallback != nullptr);
- m_ioService = &ioService;
m_receiveCallback = receiveCallback;
}
diff --git a/src/transport/transport.hpp b/src/transport/transport.hpp
index b177fad..f5b76dd 100644
--- a/src/transport/transport.hpp
+++ b/src/transport/transport.hpp
@@ -53,12 +53,11 @@
~Transport() = default;
/** \brief asynchronously open the connection
- * \param ioService io_service to create socket on
* \param receiveCallback callback function when a TLV block is received; must not be empty
* \throw boost::system::system_error connection cannot be established
*/
virtual void
- connect(boost::asio::io_service& ioService, const ReceiveCallback& receiveCallback);
+ connect(const ReceiveCallback& receiveCallback);
/** \brief Close the connection.
*/
@@ -113,7 +112,6 @@
receive(const Block& wire);
protected:
- boost::asio::io_service* m_ioService;
bool m_isConnected;
bool m_isReceiving;
ReceiveCallback m_receiveCallback;
diff --git a/src/transport/unix-transport.cpp b/src/transport/unix-transport.cpp
deleted file mode 100644
index 34ccf83..0000000
--- a/src/transport/unix-transport.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2013-2017 Regents of the University of California.
- *
- * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
- *
- * ndn-cxx library is free software: you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later version.
- *
- * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- *
- * You should have received copies of the GNU General Public License and GNU Lesser
- * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
- */
-
-#include "unix-transport.hpp"
-#include "stream-transport-impl.hpp"
-
-#include "../face.hpp"
-#include "net/face-uri.hpp"
-#include "util/logger.hpp"
-
-NDN_LOG_INIT(ndn.UnixTransport);
-// DEBUG level: connect, close, pause, resume.
-
-namespace ndn {
-
-UnixTransport::UnixTransport(const std::string& unixSocket)
- : m_unixSocket(unixSocket)
-{
-}
-
-UnixTransport::~UnixTransport() = default;
-
-std::string
-UnixTransport::getSocketNameFromUri(const std::string& uriString)
-{
- // Assume the default nfd.sock location.
- std::string path = "/var/run/nfd.sock";
-
- if (uriString.empty()) {
- return path;
- }
-
- try {
- const FaceUri uri(uriString);
-
- if (uri.getScheme() != "unix") {
- BOOST_THROW_EXCEPTION(Error("Cannot create UnixTransport from \"" +
- uri.getScheme() + "\" URI"));
- }
-
- if (!uri.getPath().empty()) {
- path = uri.getPath();
- }
- }
- catch (const FaceUri::Error& error) {
- BOOST_THROW_EXCEPTION(Error(error.what()));
- }
-
- return path;
-}
-
-shared_ptr<UnixTransport>
-UnixTransport::create(const std::string& uri)
-{
- return make_shared<UnixTransport>(getSocketNameFromUri(uri));
-}
-
-void
-UnixTransport::connect(boost::asio::io_service& ioService,
- const ReceiveCallback& receiveCallback)
-{
- NDN_LOG_DEBUG("connect path=" << m_unixSocket);
-
- if (m_impl == nullptr) {
- Transport::connect(ioService, receiveCallback);
-
- m_impl = make_shared<Impl>(ref(*this), ref(ioService));
- }
-
- m_impl->connect(boost::asio::local::stream_protocol::endpoint(m_unixSocket));
-}
-
-void
-UnixTransport::send(const Block& wire)
-{
- BOOST_ASSERT(m_impl != nullptr);
- m_impl->send(wire);
-}
-
-void
-UnixTransport::send(const Block& header, const Block& payload)
-{
- BOOST_ASSERT(m_impl != nullptr);
- m_impl->send(header, payload);
-}
-
-void
-UnixTransport::close()
-{
- BOOST_ASSERT(m_impl != nullptr);
- NDN_LOG_DEBUG("close");
- m_impl->close();
- m_impl.reset();
-}
-
-void
-UnixTransport::pause()
-{
- if (m_impl != nullptr) {
- NDN_LOG_DEBUG("pause");
- m_impl->pause();
- }
-}
-
-void
-UnixTransport::resume()
-{
- BOOST_ASSERT(m_impl != nullptr);
- NDN_LOG_DEBUG("resume");
- m_impl->resume();
-}
-
-} // namespace ndn
diff --git a/src/transport/unix-transport.hpp b/src/transport/unix-transport.hpp
deleted file mode 100644
index d337252..0000000
--- a/src/transport/unix-transport.hpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2013-2017 Regents of the University of California.
- *
- * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
- *
- * ndn-cxx library is free software: you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later version.
- *
- * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- *
- * You should have received copies of the GNU General Public License and GNU Lesser
- * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
- */
-
-#ifndef NDN_TRANSPORT_UNIX_TRANSPORT_HPP
-#define NDN_TRANSPORT_UNIX_TRANSPORT_HPP
-
-#include "transport.hpp"
-#include "../util/config-file.hpp"
-
-#include <boost/asio/local/stream_protocol.hpp>
-
-namespace ndn {
-
-template<typename BaseTransport, typename Protocol>
-class StreamTransportImpl;
-
-/** \brief a transport using Unix stream socket
- */
-class UnixTransport : public Transport
-{
-public:
- explicit
- UnixTransport(const std::string& unixSocket);
-
- ~UnixTransport() override;
-
- void
- connect(boost::asio::io_service& ioService,
- const ReceiveCallback& receiveCallback) override;
-
- void
- close() override;
-
- void
- pause() override;
-
- void
- resume() override;
-
- void
- send(const Block& wire) override;
-
- void
- send(const Block& header, const Block& payload) override;
-
- /** \brief Create transport with parameters defined in URI
- * \throw Transport::Error incorrect URI or unsupported protocol is specified
- */
- static shared_ptr<UnixTransport>
- create(const std::string& uri);
-
-NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
- static std::string
- getSocketNameFromUri(const std::string& uri);
-
-private:
- std::string m_unixSocket;
-
- using Impl = StreamTransportImpl<UnixTransport, boost::asio::local::stream_protocol>;
- friend Impl;
- shared_ptr<Impl> m_impl;
-};
-
-} // namespace ndn
-
-#endif // NDN_TRANSPORT_UNIX_TRANSPORT_HPP