Skip to content

Commit

Permalink
Merge pull request #32 from eclipse-ecal/sync-eclipse-ecal-2024-02-27
Browse files Browse the repository at this point in the history
sync with eclipse ecal
  • Loading branch information
rex-schilasky authored Feb 27, 2024
2 parents 127aa49 + 4c80388 commit b719abd
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ecal/core/include/ecal/msg/subscriber.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ namespace eCAL

protected:
// We cannot make it pure virtual, as it would break a bunch of implementations, who are not (yet) implementing this function
virtual struct SDataTypeInformation GetDataTypeInformation() const { return SDataTypeInformation{}; }
virtual SDataTypeInformation GetDataTypeInformation() const { return SDataTypeInformation{}; }
virtual bool Deserialize(T& msg_, const void* buffer_, size_t size_) const = 0;

private:
Expand Down
15 changes: 8 additions & 7 deletions ecal/core/src/ecalc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,10 @@ extern "C"
// Publisher
/////////////////////////////////////////////////////////
#if ECAL_CORE_PUBLISHER
static std::recursive_mutex g_pub_callback_mtx;
static std::recursive_mutex g_pub_event_callback_mtx;
static void g_pub_event_callback(const char* topic_name_, const struct eCAL::SPubEventCallbackData* data_, const PubEventCallbackCT callback_, void* par_)
{
const std::lock_guard<std::recursive_mutex> lock(g_pub_callback_mtx);
const std::lock_guard<std::recursive_mutex> lock(g_pub_event_callback_mtx);
SPubEventCallbackDataC data{};
data.type = data_->type;
data.time = data_->time;
Expand Down Expand Up @@ -474,10 +474,10 @@ extern "C"
// Subscriber
/////////////////////////////////////////////////////////
#if ECAL_CORE_SUBSCRIBER
static std::recursive_mutex g_sub_callback_mtx;
static std::recursive_mutex g_sub_receive_callback_mtx;
static void g_sub_receive_callback(const char* topic_name_, const struct eCAL::SReceiveCallbackData* data_, const ReceiveCallbackCT callback_, void* par_)
{
const std::lock_guard<std::recursive_mutex> lock(g_sub_callback_mtx);
const std::lock_guard<std::recursive_mutex> lock(g_sub_receive_callback_mtx);
SReceiveCallbackDataC data{};
data.buf = data_->buf;
data.size = data_->size;
Expand All @@ -487,9 +487,10 @@ static void g_sub_receive_callback(const char* topic_name_, const struct eCAL::S
callback_(topic_name_, &data, par_);
}

static std::recursive_mutex g_sub_event_callback_mtx;
static void g_sub_event_callback(const char* topic_name_, const struct eCAL::SSubEventCallbackData* data_, const SubEventCallbackCT callback_, void* par_)
{
const std::lock_guard<std::recursive_mutex> lock(g_sub_callback_mtx);
const std::lock_guard<std::recursive_mutex> lock(g_sub_event_callback_mtx);
SSubEventCallbackDataC data{};
data.type = data_->type;
data.time = data_->time;
Expand Down Expand Up @@ -820,10 +821,10 @@ extern "C"
#if ECAL_CORE_SERVICE
extern "C"
{
static std::recursive_mutex g_request_callback_mtx;
static std::recursive_mutex g_method_callback_mtx;
static int g_method_callback(const std::string& method_, const std::string& req_type_, const std::string& resp_type_, const std::string& request_, std::string& response_, MethodCallbackCT callback_, void* par_)
{
const std::lock_guard<std::recursive_mutex> lock(g_request_callback_mtx);
const std::lock_guard<std::recursive_mutex> lock(g_method_callback_mtx);
void* response(nullptr);
int response_len(ECAL_ALLOCATE_4ME);
const int ret_state = callback_(method_.c_str(), req_type_.c_str(), resp_type_.c_str(), request_.c_str(), static_cast<int>(request_.size()), &response, &response_len, par_);
Expand Down
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 34 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
+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 b719abd

Please sign in to comment.