From bcca99e38c602bb4c8b0da1030d5aa01910abefa Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Wed, 9 Feb 2022 11:30:34 +0100 Subject: [PATCH 1/4] clearer exceptions to help user fix the issue of localhost not getting mac address --- slsDetectorSoftware/src/Module.cpp | 15 +++++++++++---- slsReceiverSoftware/src/ClientInterface.cpp | 8 ++++++++ slsSupportLib/include/sls/sls_detector_defs.h | 6 +++--- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index ef2c1633c..596ce25de 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -1021,6 +1021,10 @@ void Module::setDestinationUDPIP(const IpAddr ip) { if (ip == 0) { throw RuntimeError("Invalid destination udp ip address"); } + if (ip.str() == LOCALHOST_IP) { + throw RuntimeError("Invalid destination udp ip. Change rx_hostname " + "from localhost or change udp_dstip from auto?"); + } sendToDetector(F_SET_DEST_UDP_IP, ip, nullptr); if (shm()->useReceiverFlag) { sls::MacAddr retval(0LU); @@ -1040,7 +1044,10 @@ void Module::setDestinationUDPIP2(const IpAddr ip) { if (ip == 0) { throw RuntimeError("Invalid destination udp ip address2"); } - + if (ip.str() == LOCALHOST_IP) { + throw RuntimeError("Invalid destination udp ip. Change rx_hostname " + "from localhost or change udp_dstip from auto?"); + } sendToDetector(F_SET_DEST_UDP_IP2, ip, nullptr); if (shm()->useReceiverFlag) { sls::MacAddr retval(0LU); @@ -3330,9 +3337,9 @@ sls_detector_module Module::interpolateTrim(sls_detector_module *a, dacs_to_copy.end(), {E_SVP, E_SVN, E_VTGSTV, E_RXB_RB, E_RXB_LB, E_VCN, E_VIS}); // interpolate vrf, vcmp, vcp - dacs_to_interpolate.insert( - dacs_to_interpolate.end(), - {E_VTR, E_VRF, E_VCMP_LL, E_VCMP_LR, E_VCMP_RL, E_VCMP_RR, E_VCP, E_VRS}); + dacs_to_interpolate.insert(dacs_to_interpolate.end(), + {E_VTR, E_VRF, E_VCMP_LL, E_VCMP_LR, + E_VCMP_RL, E_VCMP_RR, E_VCP, E_VRS}); } else { dacs_to_copy.insert(dacs_to_copy.end(), {M_VCASSH, M_VRSHAPER, M_VRSHAPER_N, M_VIPRE_OUT, diff --git a/slsReceiverSoftware/src/ClientInterface.cpp b/slsReceiverSoftware/src/ClientInterface.cpp index 44677a8f6..55979eeec 100644 --- a/slsReceiverSoftware/src/ClientInterface.cpp +++ b/slsReceiverSoftware/src/ClientInterface.cpp @@ -1388,6 +1388,10 @@ int ClientInterface::set_read_n_rows(Interface &socket) { } sls::MacAddr ClientInterface::setUdpIp(sls::IpAddr arg) { + if (arg.str() == LOCALHOST_IP) { + throw RuntimeError("Invalid destination udp ip. Change rx_hostname " + "from localhost or change udp_dstip from auto?"); + } LOG(logINFO) << "Received UDP IP: " << arg; // getting eth std::string eth = sls::IpToInterfaceName(arg.str()); @@ -1426,6 +1430,10 @@ int ClientInterface::set_udp_ip(Interface &socket) { } sls::MacAddr ClientInterface::setUdpIp2(sls::IpAddr arg) { + if (arg.str() == LOCALHOST_IP) { + throw RuntimeError("Invalid destination udp ip. Change rx_hostname " + "from localhost or change udp_dstip from auto?"); + } LOG(logINFO) << "Received UDP IP2: " << arg; // getting eth std::string eth = sls::IpToInterfaceName(arg.str()); diff --git a/slsSupportLib/include/sls/sls_detector_defs.h b/slsSupportLib/include/sls/sls_detector_defs.h index 06203310f..b4ceced11 100644 --- a/slsSupportLib/include/sls/sls_detector_defs.h +++ b/slsSupportLib/include/sls/sls_detector_defs.h @@ -65,6 +65,8 @@ #define DEFAULT_DET_MAC2 "00:aa:bb:cc:dd:ff" #define DEFAULT_DET_IP2 "129.129.202.46" +#define LOCALHOST_IP "127.0.0.1" + /** default maximum string length */ #define MAX_STR_LENGTH 1000 #define SHORT_STR_LENGTH 20 @@ -564,7 +566,7 @@ enum streamingInterface { #ifdef __cplusplus }; -//operators needed in ToString +// operators needed in ToString inline slsDetectorDefs::streamingInterface operator|(const slsDetectorDefs::streamingInterface &a, const slsDetectorDefs::streamingInterface &b) { @@ -579,8 +581,6 @@ operator&(const slsDetectorDefs::streamingInterface &a, static_cast(b)); }; - - #endif #ifdef __cplusplus From 83a65f85abbfbc8a5e5b00338261de975e6e3420 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Mon, 14 Feb 2022 10:25:34 +0100 Subject: [PATCH 2/4] allowing localhost for virtual server --- slsDetectorSoftware/src/Module.cpp | 6 +++--- slsReceiverSoftware/src/ClientInterface.cpp | 12 ++---------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index b5133d8b0..e36f69c1c 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -1046,7 +1046,7 @@ void Module::setDestinationUDPIP(const IpAddr ip) { if (ip == 0) { throw RuntimeError("Invalid destination udp ip address"); } - if (ip.str() == LOCALHOST_IP) { + if (ip.str() == LOCALHOST_IP && !isVirtualDetectorServer()) { throw RuntimeError("Invalid destination udp ip. Change rx_hostname " "from localhost or change udp_dstip from auto?"); } @@ -1069,8 +1069,8 @@ void Module::setDestinationUDPIP2(const IpAddr ip) { if (ip == 0) { throw RuntimeError("Invalid destination udp ip address2"); } - if (ip.str() == LOCALHOST_IP) { - throw RuntimeError("Invalid destination udp ip. Change rx_hostname " + if (ip.str() == LOCALHOST_IP && !isVirtualDetectorServer()) { + throw RuntimeError("Invalid destination udp ip2. Change rx_hostname " "from localhost or change udp_dstip from auto?"); } sendToDetector(F_SET_DEST_UDP_IP2, ip, nullptr); diff --git a/slsReceiverSoftware/src/ClientInterface.cpp b/slsReceiverSoftware/src/ClientInterface.cpp index 55979eeec..9fa919359 100644 --- a/slsReceiverSoftware/src/ClientInterface.cpp +++ b/slsReceiverSoftware/src/ClientInterface.cpp @@ -1388,10 +1388,6 @@ int ClientInterface::set_read_n_rows(Interface &socket) { } sls::MacAddr ClientInterface::setUdpIp(sls::IpAddr arg) { - if (arg.str() == LOCALHOST_IP) { - throw RuntimeError("Invalid destination udp ip. Change rx_hostname " - "from localhost or change udp_dstip from auto?"); - } LOG(logINFO) << "Received UDP IP: " << arg; // getting eth std::string eth = sls::IpToInterfaceName(arg.str()); @@ -1414,7 +1410,7 @@ sls::MacAddr ClientInterface::setUdpIp(sls::IpAddr arg) { // get mac address auto retval = sls::InterfaceNameToMac(eth); - if (retval == 0) { + if (retval == 0 && arg.str() != LOCALHOST_IP) { throw RuntimeError("Failed to get udp mac adddress to listen to (eth:" + eth + ", ip:" + arg.str() + ")\n"); } @@ -1430,10 +1426,6 @@ int ClientInterface::set_udp_ip(Interface &socket) { } sls::MacAddr ClientInterface::setUdpIp2(sls::IpAddr arg) { - if (arg.str() == LOCALHOST_IP) { - throw RuntimeError("Invalid destination udp ip. Change rx_hostname " - "from localhost or change udp_dstip from auto?"); - } LOG(logINFO) << "Received UDP IP2: " << arg; // getting eth std::string eth = sls::IpToInterfaceName(arg.str()); @@ -1453,7 +1445,7 @@ sls::MacAddr ClientInterface::setUdpIp2(sls::IpAddr arg) { // get mac address auto retval = sls::InterfaceNameToMac(eth); - if (retval == 0) { + if (retval == 0 && arg.str() != LOCALHOST_IP) { throw RuntimeError( "Failed to get udp mac adddress2 to listen to (eth:" + eth + ", ip:" + arg.str() + ")\n"); From faa9ecf97ce395115a429c55c997cb4455d57e51 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Tue, 15 Feb 2022 10:16:22 +0100 Subject: [PATCH 3/4] allowing virtual servers to also have mac 0 --- .../slsDetectorServer/src/slsDetectorServer_funcs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 9450d01f5..360d2435a 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -4855,12 +4855,14 @@ int is_udp_configured() { LOG(logWARNING, ("%s", configureMessage)); return FAIL; } +#ifndef VIRTUAL if (udpDetails[i].dstmac == 0) { sprintf(configureMessage, "udp destination mac not configured [entry:%d]\n", i); LOG(logWARNING, ("%s", configureMessage)); return FAIL; } +#endif #if defined(JUNGFRAUD) || defined(GOTTHARD2D) if (getNumberofUDPInterfaces() == 2) { if (udpDetails[i].srcip2 == 0) { @@ -4881,12 +4883,14 @@ int is_udp_configured() { LOG(logWARNING, ("%s", configureMessage)); return FAIL; } +#ifndef VIRTUAL if (udpDetails[i].dstmac2 == 0) { sprintf(configureMessage, "udp destination mac2 not configured [entry:%d]\n", i); LOG(logWARNING, ("%s", configureMessage)); return FAIL; } +#endif } #endif } From c38f292613c9ea1b1927442f4ef29308aa1d695c Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Tue, 15 Feb 2022 10:48:14 +0100 Subject: [PATCH 4/4] udp_srcip defaulted to 127.0.0.1 for virtual servers --- .../jungfrauDetectorServer/slsDetectorFunctionList.c | 4 ++-- .../slsDetectorServer/src/slsDetectorServer_funcs.c | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index 7fba144aa..dc8e1ea28 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -1675,7 +1675,7 @@ int setReadNRows(int value) { } if (isHardwareVersion2()) { LOG(logERROR, ("Could not set number of rows. Only available for " - "Hardware Board version 2.0.\n")); + "Hardware Board version 2.0.\n")); return FAIL; } @@ -2175,7 +2175,7 @@ int getFlipRows() { void setFlipRows(int arg) { if (isHardwareVersion2()) { LOG(logERROR, ("Could not set flip rows. Only available for " - "Hardware Board version 2.0.\n")); + "Hardware Board version 2.0.\n")); return; } if (arg >= 0) { diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 360d2435a..80c7e003c 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -37,6 +37,8 @@ const enum detectorType myDetectorType = GOTTHARD2; const enum detectorType myDetectorType = GENERIC; #endif +#define LOCALHOSTIP_INT 2130706433 + // Global variables from communication_funcs extern int lockStatus; extern uint32_t lastClientIP; @@ -119,10 +121,11 @@ int printSocketReadError() { } void init_detector() { + memset(udpDetails, 0, sizeof(udpDetails)); #ifdef VIRTUAL LOG(logINFO, ("This is a VIRTUAL detector\n")); + udpDetails[0].srcip = LOCALHOSTIP_INT; #endif - memset(udpDetails, 0, sizeof(udpDetails)); udpDetails[0].srcport = DEFAULT_UDP_SRC_PORTNO; udpDetails[0].dstport = DEFAULT_UDP_DST_PORTNO; #ifdef EIGERD