Skip to content

Commit

Permalink
[Core/Submodule] Updated Udpcap to 2.0 (fixes lost-datagram-issues) (#…
Browse files Browse the repository at this point in the history
…1396)

There has been an API break, but the code is still compatible with Udpcap 1 by using preprocessor checks. However, you will get a deprecation warning.
  • Loading branch information
FlorianReimold committed Feb 27, 2024
1 parent dd6ee2d commit d149780
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
30 changes: 30 additions & 0 deletions ecal/core/src/io/udp/sendreceive/udp_receiver_npcap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include <iostream>

#include <udpcap/udpcap_version.h>

namespace IO
{
namespace UDP
Expand Down Expand Up @@ -110,6 +112,12 @@ namespace IO
{
Udpcap::HostAddress source_address;
uint16_t source_port;

#if UDPCAP_VERSION_MAJOR == 1
// Show a compiler deprecation warning
// TODO: Remove for eCAL6
[[deprecated("Udpcap 1.x is deprecated and prone to data-loss. Please update udpcap to 2.x.")]]

bytes_received = m_socket.receiveDatagram(buf_, len_, static_cast<unsigned long>(timeout_), &source_address, &source_port);

if (bytes_received && source_address.isValid())
Expand All @@ -119,10 +127,32 @@ namespace IO
address_->sin_port = source_port;
memset(&(address_->sin_zero), 0, 8);
}
#else // Udpcap 2.x
Udpcap::Error error(Udpcap::Error::GENERIC_ERROR);
bytes_received = m_socket.receiveDatagram(buf_, len_, timeout_, &source_address, &source_port, error);

if (!error)
{
address_->sin_addr.s_addr = source_address.toInt();
address_->sin_family = AF_INET;
address_->sin_port = source_port;
memset(&(address_->sin_zero), 0, 8);
}
#endif

}
else
{
#if UDPCAP_VERSION_MAJOR == 1
// Show a compiler deprecation warning
// TODO: Remove for eCAL6
[[deprecated("Udpcap 1.x is deprecated and prone to data-loss. Please update udpcap to 2.x.")]]

bytes_received = m_socket.receiveDatagram(buf_, len_, static_cast<unsigned long>(timeout_));
#else // Udpcap 2.x
Udpcap::Error error(Udpcap::Error::GENERIC_ERROR);
bytes_received = m_socket.receiveDatagram(buf_, len_, timeout_, error);
#endif
}
return bytes_received;
}
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/udpcap/udpcap
Submodule udpcap updated 36 files
+67 βˆ’0 .clang-tidy
+2 βˆ’2 .github/workflows/build-windows.yml
+21 βˆ’0 CMakeLists.txt
+17 βˆ’5 README.md
+14 βˆ’16 samples/asio_sender_multicast/CMakeLists.txt
+21 βˆ’24 samples/asio_sender_multicast/src/main.cpp
+14 βˆ’16 samples/asio_sender_unicast/CMakeLists.txt
+17 βˆ’20 samples/asio_sender_unicast/src/main.cpp
+14 βˆ’16 samples/udpcap_receiver_multicast/CMakeLists.txt
+32 βˆ’28 samples/udpcap_receiver_multicast/src/main.cpp
+14 βˆ’16 samples/udpcap_receiver_unicast/CMakeLists.txt
+31 βˆ’27 samples/udpcap_receiver_unicast/src/main.cpp
+44 βˆ’0 tests/udpcap_test/CMakeLists.txt
+205 βˆ’0 tests/udpcap_test/src/atomic_signalable.h
+966 βˆ’0 tests/udpcap_test/src/udpcap_test.cpp
+33 βˆ’0 thirdparty/GTest/GTest_make_available.cmake
+1 βˆ’0 thirdparty/GTest/Modules/FindGTest.cmake
+1 βˆ’1 thirdparty/npcap/Modules/Findnpcap.cmake
+1 βˆ’1 thirdparty/pcapplusplus/Modules/Findpcapplusplus.cmake
+21 βˆ’20 udpcap/CMakeLists.txt
+1 βˆ’1 udpcap/cmake/udpcapConfig-shared.cmake.in
+4 βˆ’3 udpcap/cmake/udpcapConfig-static.cmake.in
+116 βˆ’0 udpcap/include/udpcap/error.h
+18 βˆ’20 udpcap/include/udpcap/host_address.h
+17 βˆ’18 udpcap/include/udpcap/npcap_helpers.h
+91 βˆ’51 udpcap/include/udpcap/udpcap_socket.h
+0 βˆ’12 udpcap/sourcetree.cmake
+23 βˆ’25 udpcap/src/host_address.cpp
+25 βˆ’23 udpcap/src/ip_reassembly.cpp
+17 βˆ’21 udpcap/src/ip_reassembly.h
+14 βˆ’17 udpcap/src/log_debug.h
+71 βˆ’72 udpcap/src/npcap_helpers.cpp
+28 βˆ’25 udpcap/src/udpcap_socket.cpp
+325 βˆ’349 udpcap/src/udpcap_socket_private.cpp
+41 βˆ’60 udpcap/src/udpcap_socket_private.h
+2 βˆ’2 udpcap/version.cmake

0 comments on commit d149780

Please sign in to comment.