diff --git a/tools/socktap/autotalks_link.cpp b/tools/socktap/autotalks_link.cpp index a59dda40d..abf092548 100644 --- a/tools/socktap/autotalks_link.cpp +++ b/tools/socktap/autotalks_link.cpp @@ -4,7 +4,8 @@ const unsigned SendBufferSize = 2000; -AutotalksLink::AutotalksLink(void) +AutotalksLink::AutotalksLink(boost::asio::io_service& io) + : io_(io) { vanetza::autotalks::autotalks_device_init(); vanetza::autotalks::init_rx(this); @@ -43,7 +44,12 @@ void AutotalksLink::data_received(uint8_t* pBuf, uint16_t size, v2x_receive_para vanetza::CohesivePacket packet(std::move(buffer), vanetza::OsiLayer::Physical); boost::optional eth = vanetza::autotalks::strip_autotalks_rx_header(packet, rx_params); if (callback_ && eth) - callback_(std::move(packet), *eth); + { + boost::asio::post(io_, [this, packet = std::move(packet), eth]() mutable + { + callback_(std::move(packet), *eth); + }); + } } void AutotalksLink::indicate(IndicationCallback cb) diff --git a/tools/socktap/autotalks_link.hpp b/tools/socktap/autotalks_link.hpp index 0bbace232..ddb48bd2c 100644 --- a/tools/socktap/autotalks_link.hpp +++ b/tools/socktap/autotalks_link.hpp @@ -11,7 +11,7 @@ class AutotalksLink : public LinkLayer /* * Constructor used for device and thread initialization. */ - AutotalksLink(void); + AutotalksLink(boost::asio::io_service&); /* * Destructor used for deinitialization. @@ -25,6 +25,7 @@ class AutotalksLink : public LinkLayer static constexpr std::size_t layers_ = num_osi_layers(vanetza::OsiLayer::Physical, vanetza::OsiLayer::Application); IndicationCallback callback_; std::array buffers_; + boost::asio::io_service& io_; }; diff --git a/tools/socktap/link_layer.cpp b/tools/socktap/link_layer.cpp index 389e8f726..768ffb07f 100644 --- a/tools/socktap/link_layer.cpp +++ b/tools/socktap/link_layer.cpp @@ -92,7 +92,7 @@ create_link_layer(boost::asio::io_service& io_service, const EthernetDevice& dev } else if (name == "autotalks") { #ifdef SOCKTAP_WITH_AUTOTALKS - link_layer.reset(new AutotalksLink { }); + link_layer.reset(new AutotalksLink { io_service }); #endif }