This commit is contained in:
Erik Fröjdh
2025-05-30 16:57:16 +02:00
parent e14d307a42
commit 5093472aa1
5 changed files with 36 additions and 31 deletions

View File

@ -29,7 +29,6 @@ target_link_libraries(slsDetectorObject
slsProjectOptions slsProjectOptions
slsSupportStatic slsSupportStatic
pthread pthread
rt
PRIVATE PRIVATE
slsProjectWarnings slsProjectWarnings
) )
@ -99,8 +98,6 @@ if(SLS_USE_TEXTCLIENT)
target_link_libraries(${val1} target_link_libraries(${val1}
slsDetectorStatic slsDetectorStatic
pthread
rt
) )
SET_SOURCE_FILES_PROPERTIES( src/Caller.cpp PROPERTIES COMPILE_FLAGS "-Wno-unused-variable -Wno-unused-but-set-variable") SET_SOURCE_FILES_PROPERTIES( src/Caller.cpp PROPERTIES COMPILE_FLAGS "-Wno-unused-variable -Wno-unused-but-set-variable")

View File

@ -1203,7 +1203,7 @@ void Module::setDestinationUDPIP(const IpAddr ip) {
} }
sendToDetector(F_SET_DEST_UDP_IP, ip, nullptr); sendToDetector(F_SET_DEST_UDP_IP, ip, nullptr);
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {
MacAddr retval(0LU); MacAddr retval{uint64_t(0)};
sendToReceiver(F_SET_RECEIVER_UDP_IP, ip, retval); sendToReceiver(F_SET_RECEIVER_UDP_IP, ip, retval);
LOG(logINFO) << "Setting destination udp mac of Module " << moduleIndex LOG(logINFO) << "Setting destination udp mac of Module " << moduleIndex
<< " to " << retval; << " to " << retval;
@ -1226,7 +1226,7 @@ void Module::setDestinationUDPIP2(const IpAddr ip) {
} }
sendToDetector(F_SET_DEST_UDP_IP2, ip, nullptr); sendToDetector(F_SET_DEST_UDP_IP2, ip, nullptr);
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {
MacAddr retval(0LU); MacAddr retval{uint64_t(0)};
sendToReceiver(F_SET_RECEIVER_UDP_IP2, ip, retval); sendToReceiver(F_SET_RECEIVER_UDP_IP2, ip, retval);
LOG(logINFO) << "Setting destination udp mac2 of Module " << moduleIndex LOG(logINFO) << "Setting destination udp mac2 of Module " << moduleIndex
<< " to " << retval; << " to " << retval;

View File

@ -25,8 +25,12 @@
#include <unistd.h> #include <unistd.h>
namespace sls { namespace sls {
#ifdef __APPLE__
#define SHM_DETECTOR_PREFIX "/slsDetectorPackage_detector_" // On macOS SHM_NAME_MAX is 31 so we need the shortest possible prefix
#define SHM_DETECTOR_PREFIX "/sls_"
#else
#define SHM_DETECTOR_PREFIX "/slsDetectorPackage_detector_"
#endif
#define SHM_MODULE_PREFIX "_module_" #define SHM_MODULE_PREFIX "_module_"
#define SHM_ENV_NAME "SLSDETNAME" #define SHM_ENV_NAME "SLSDETNAME"
@ -203,6 +207,11 @@ template <typename T> class SharedMemory {
throw SharedMemoryError(msg); throw SharedMemoryError(msg);
} }
#ifdef __APPLE__
// On macOS, fstat returns the allocated size and not the requested size.
// This means we can't check for size since we always get for example 16384 bytes.
return;
#endif
auto actual_size = static_cast<size_t>(sb.st_size); auto actual_size = static_cast<size_t>(sb.st_size);
auto expected_size = sizeof(T); auto expected_size = sizeof(T);
if (actual_size != expected_size) { if (actual_size != expected_size) {

View File

@ -15,7 +15,7 @@
#include <netdb.h> #include <netdb.h>
#include <sstream> #include <sstream>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/prctl.h> // #include <sys/prctl.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
@ -178,30 +178,30 @@ IpAddr InterfaceNameToIp(const std::string &ifn) {
MacAddr InterfaceNameToMac(const std::string &inf) { MacAddr InterfaceNameToMac(const std::string &inf) {
// TODO! Copied from genericSocket needs to be refactored! // TODO! Copied from genericSocket needs to be refactored!
struct ifreq ifr; // struct ifreq ifr;
char mac[32]; // char mac[32];
const int mac_len = sizeof(mac); // const int mac_len = sizeof(mac);
memset(mac, 0, mac_len); // memset(mac, 0, mac_len);
int sock = socket(PF_INET, SOCK_STREAM, 0); // int sock = socket(PF_INET, SOCK_STREAM, 0);
strncpy(ifr.ifr_name, inf.c_str(), sizeof(ifr.ifr_name) - 1); // strncpy(ifr.ifr_name, inf.c_str(), sizeof(ifr.ifr_name) - 1);
ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0'; // ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
if (-1 == ioctl(sock, SIOCGIFHWADDR, &ifr)) { // if (-1 == ioctl(sock, SIOCGIFHWADDR, &ifr)) {
perror("ioctl(SIOCGIFHWADDR) "); // perror("ioctl(SIOCGIFHWADDR) ");
return MacAddr{}; // return MacAddr{};
} // }
for (int j = 0, k = 0; j < 6; j++) { // for (int j = 0, k = 0; j < 6; j++) {
k += snprintf( // k += snprintf(
mac + k, mac_len - k - 1, j ? ":%02X" : "%02X", // mac + k, mac_len - k - 1, j ? ":%02X" : "%02X",
(int)(unsigned int)(unsigned char)ifr.ifr_hwaddr.sa_data[j]); // (int)(unsigned int)(unsigned char)ifr.ifr_hwaddr.sa_data[j]);
} // }
mac[mac_len - 1] = '\0'; // mac[mac_len - 1] = '\0';
if (sock != 1) { // if (sock != 1) {
close(sock); // close(sock);
} // }
return MacAddr(mac); return MacAddr();
} }
void validatePortNumber(uint16_t port) { void validatePortNumber(uint16_t port) {

View File

@ -25,7 +25,6 @@ target_link_libraries(tests
slsProjectOptions slsProjectOptions
slsSupportStatic slsSupportStatic
pthread pthread
rt
PRIVATE PRIVATE
slsProjectWarnings slsProjectWarnings
) )