Skip to content

Commit

Permalink
Some clean-ups and documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
dreibh committed Oct 13, 2024
1 parent 3c32206 commit 5337383
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/iomodule-udp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,20 @@ unsigned int UDPModule::sendRequest(const DestinationInfo& destination,
}

// ====== Message scatter/gather array ===================================
#if defined(IP_HDRINCL) && defined(IPV6_HDRINCL)
const std::array<boost::asio::const_buffer, 3> buffer {
SourceAddress.is_v6() ? boost::asio::buffer(ipv6Header.data(), ipv6Header.size()) :
boost::asio::buffer(ipv4Header.data(), ipv4Header.size()),
boost::asio::buffer(udpHeader.data(), udpHeader.size()),
boost::asio::buffer(tsHeader.data(), tsHeader.size())
};
#else
// NOTE:
// IP_HDRINCL and/or IPV6_HDRINCL is not available: This means that it is
// not possible to explicitly set the source IP address in the header here.
// This includes the UDP Pseudo Header for the checksum computation!
// Therefore, the UDPSocketEndpoint must be bound to a fixed IP address.
// (by option: --source <address>)
std::vector<boost::asio::const_buffer> buffer;
if(SourceAddress.is_v6()) {
buffer = {
Expand All @@ -244,9 +258,10 @@ unsigned int UDPModule::sendRequest(const DestinationInfo& destination,
};
#if !defined(IPV6_HDRINCL)
if(localEndpoint.address() != UDPSocketEndpoint.address()) {
HPCT_LOG(warning) << "Cannot set source IPv6 address without IPV6_HDRINCL! Explicitly set source address!\n"
<< "localEndpoint=" << localEndpoint.address() << "\n"
<< "UDPSocketEndpoint=" << UDPSocketEndpoint.address() << "\n";
HPCT_LOG(error) << "Cannot set source IPv6 address without IPV6_HDRINCL! Explicitly set source address!\n"
<< "localEndpoint=" << localEndpoint.address() << "\n"
<< "UDPSocketEndpoint=" << UDPSocketEndpoint.address() << "\n";
return 0;
}
#endif
}
Expand All @@ -260,12 +275,14 @@ unsigned int UDPModule::sendRequest(const DestinationInfo& destination,
};
#if !defined(IP_HDRINCL)
if(localEndpoint.address() != UDPSocketEndpoint.address()) {
HPCT_LOG(warning) << "Cannot set source IPv4 address without IP_HDRINCL! Explicitly set source address!\n"
<< "localEndpoint=" << localEndpoint.address() << "\n"
<< "UDPSocketEndpoint=" << UDPSocketEndpoint.address() << "\n";
HPCT_LOG(error) << "Cannot set source IPv4 address without IP_HDRINCL! Explicitly set source address!\n"
<< "localEndpoint=" << localEndpoint.address() << "\n"
<< "UDPSocketEndpoint=" << UDPSocketEndpoint.address() << "\n";
return 0;
}
#endif
}
#endif

// ====== Prepare ResultEntry array ======================================
const unsigned int entries = (1 + (toRound -fromRound)) * (1 + (fromTTL -toTTL));
Expand Down

0 comments on commit 5337383

Please sign in to comment.