aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/transport
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/transport')
-rw-r--r--host/lib/transport/CMakeLists.txt1
-rw-r--r--host/lib/transport/adapter.cpp24
-rw-r--r--host/lib/transport/udp_boost_asio_link.cpp13
3 files changed, 33 insertions, 5 deletions
diff --git a/host/lib/transport/CMakeLists.txt b/host/lib/transport/CMakeLists.txt
index 003beeee4..dd83164bf 100644
--- a/host/lib/transport/CMakeLists.txt
+++ b/host/lib/transport/CMakeLists.txt
@@ -124,6 +124,7 @@ LIBUHD_APPEND_SOURCES(
${CMAKE_CURRENT_SOURCE_DIR}/muxed_zero_copy_if.cpp
${CMAKE_CURRENT_SOURCE_DIR}/zero_copy_flow_ctrl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/inline_io_service.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/adapter.cpp
)
if(ENABLE_X300)
diff --git a/host/lib/transport/adapter.cpp b/host/lib/transport/adapter.cpp
new file mode 100644
index 000000000..247b33868
--- /dev/null
+++ b/host/lib/transport/adapter.cpp
@@ -0,0 +1,24 @@
+//
+// Copyright 2019 Ettus Research, a National Instruments Brand
+//
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+
+#include <uhd/exception.hpp>
+#include <uhdlib/transport/adapter.hpp>
+
+using namespace uhd::transport;
+
+adapter_id_t adapter_ctx::register_adapter(adapter_info& info)
+{
+ std::lock_guard<std::mutex> lock(_mutex);
+ auto key = info.to_string();
+ if (_id_map.count(key) > 0) {
+ return _id_map.at(key);
+ } else {
+ adapter_id_t id = _id_map.size() + 1;
+ _id_map.emplace(std::make_pair(key, id));
+ return id;
+ }
+}
+
diff --git a/host/lib/transport/udp_boost_asio_link.cpp b/host/lib/transport/udp_boost_asio_link.cpp
index 95d68ba91..2d4a4f640 100644
--- a/host/lib/transport/udp_boost_asio_link.cpp
+++ b/host/lib/transport/udp_boost_asio_link.cpp
@@ -5,6 +5,7 @@
//
#include <uhd/utils/log.hpp>
+#include <uhdlib/transport/adapter.hpp>
#include <uhdlib/transport/udp_boost_asio_link.hpp>
#include <boost/format.hpp>
@@ -39,10 +40,13 @@ udp_boost_asio_link::udp_boost_asio_link(
_socket = open_udp_socket(addr, port, _io_service);
_sock_fd = _socket->native_handle();
- UHD_LOGGER_TRACE("UDP")
- << boost::format("Created UDP link to %s:%s") % addr % port;
+ auto info = udp_boost_asio_adapter_info(*_socket);
+ auto& ctx = adapter_ctx::get();
+ _adapter_id = ctx.register_adapter(info);
+
+ UHD_LOGGER_TRACE("UDP") << boost::format("Created UDP link to %s:%s") % addr % port;
UHD_LOGGER_TRACE("UDP") << boost::format("Local UDP socket endpoint: %s:%s")
- % get_local_addr() % get_local_port();
+ % get_local_addr() % get_local_port();
}
uint16_t udp_boost_asio_link::get_local_port() const
@@ -91,8 +95,7 @@ udp_boost_asio_link::sptr udp_boost_asio_link::make(const std::string& addr,
}
#endif
- udp_boost_asio_link::sptr link(
- new udp_boost_asio_link(addr, port, params));
+ udp_boost_asio_link::sptr link(new udp_boost_asio_link(addr, port, params));
// call the helper to resize send and recv buffers