Skip to content

Commit

Permalink
Fixes the same issue as reported in riebl#181
Browse files Browse the repository at this point in the history
  • Loading branch information
khevessy committed Nov 7, 2023
1 parent 57de6d8 commit d34db54
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
10 changes: 8 additions & 2 deletions tools/socktap/autotalks_link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<vanetza::EthernetHeader> 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)
Expand Down
3 changes: 2 additions & 1 deletion tools/socktap/autotalks_link.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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<vanetza::ByteBuffer, layers_> buffers_;
boost::asio::io_service& io_;
};


Expand Down
2 changes: 1 addition & 1 deletion tools/socktap/link_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit d34db54

Please sign in to comment.