Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tools/socktap/dcc_passthrough.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <vanetza/net/chunk_packet.hpp>
#include <boost/asio/generic/raw_protocol.hpp>
#include <iostream>
#include <sstream>

#ifdef SOCKTAP_WITH_COHDA_LLC
#include "cohda.hpp"
Expand Down Expand Up @@ -43,7 +44,9 @@ void DccPassthrough::request(const dcc::DataRequest& request, std::unique_ptr<Ch
const_buffers[i] = asio::buffer(buffers_[i]);
}
auto bytes_sent = socket_.send(const_buffers);
std::cout << "sent packet to " << request.destination << " (" << bytes_sent << " bytes)\n";
std::ostringstream ostream;
ostream << "sent packet to " << request.destination << " (" << bytes_sent << " bytes)\n";
std::cout << ostream.str();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this beneficial? From my point of view, this causes an additional memory allocation and thus this should be justifiable.

@glmax glmax Feb 26, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When Vanetza shares stdout with other threads that manipulate the flags for stdout, it can happen (although rarely and unpredictable) that the std::hex flag set in the streaming operator overload of MacAddress is not properly cleared. One could probably move the special treatment to the streaming operator overload.

If you don't see that as a problem Socktap/Vanetza should care about, feel free to omit this commit.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, but socktap is not multi-threaded ;-) If this is going to change, we will need some more sophisticated logging anyway.

}

void DccPassthrough::allow_packet_flow(bool allow)
Expand Down
10 changes: 8 additions & 2 deletions tools/socktap/router_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <boost/asio/generic/raw_protocol.hpp>
#include <boost/optional/optional.hpp>
#include <iostream>
#include <sstream>
#include <vanetza/common/byte_order.hpp>

#ifdef SOCKTAP_WITH_COHDA_LLC
Expand Down Expand Up @@ -47,7 +48,9 @@ RouterContext::~RouterContext()
void RouterContext::log_packet_drop(geonet::Router::PacketDropReason reason)
{
auto reason_string = stringify(reason);
std::cout << "Router dropped packet because of " << reason_string << " (" << static_cast<int>(reason) << ")\n";
std::ostringstream ostream;
ostream << "Router dropped packet because of " << reason_string << " (" << static_cast<int>(reason) << ")\n";
std::cout << ostream.str();
}

void RouterContext::do_receive()
Expand Down Expand Up @@ -84,7 +87,10 @@ void RouterContext::pass_up(CohesivePacket&& packet)
EthernetHeader hdr = decode_ethernet_header(link_range.begin(), link_range.end());
#endif
if (hdr.source != mib_.itsGnLocalGnAddr.mid() && hdr.type == access::ethertype::GeoNetworking) {
std::cout << "received packet from " << hdr.source << " (" << packet.size() << " bytes)\n";
std::ostringstream ostream;
ostream << "received packet from " << hdr.source << " (" << packet.size() << " bytes)\n";
std::cout << ostream.str();

std::unique_ptr<PacketVariant> up { new PacketVariant(std::move(packet)) };
trigger_.schedule(); // ensure the clock is up-to-date for the security entity
router_.indicate(std::move(up), hdr.source, hdr.destination);
Expand Down