Merge pull request #378 from slsdetectorgroup/localhost

localhostMac
This commit is contained in:
Dhanya Thattil 2022-02-15 12:07:40 +01:00 committed by GitHub
commit e5ec218e5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 9 deletions

View File

@ -1675,7 +1675,7 @@ int setReadNRows(int value) {
} }
if (isHardwareVersion2()) { if (isHardwareVersion2()) {
LOG(logERROR, ("Could not set number of rows. Only available for " 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; return FAIL;
} }
@ -2175,7 +2175,7 @@ int getFlipRows() {
void setFlipRows(int arg) { void setFlipRows(int arg) {
if (isHardwareVersion2()) { if (isHardwareVersion2()) {
LOG(logERROR, ("Could not set flip rows. Only available for " LOG(logERROR, ("Could not set flip rows. Only available for "
"Hardware Board version 2.0.\n")); "Hardware Board version 2.0.\n"));
return; return;
} }
if (arg >= 0) { if (arg >= 0) {

View File

@ -37,6 +37,8 @@ const enum detectorType myDetectorType = GOTTHARD2;
const enum detectorType myDetectorType = GENERIC; const enum detectorType myDetectorType = GENERIC;
#endif #endif
#define LOCALHOSTIP_INT 2130706433
// Global variables from communication_funcs // Global variables from communication_funcs
extern int lockStatus; extern int lockStatus;
extern uint32_t lastClientIP; extern uint32_t lastClientIP;
@ -119,10 +121,11 @@ int printSocketReadError() {
} }
void init_detector() { void init_detector() {
memset(udpDetails, 0, sizeof(udpDetails));
#ifdef VIRTUAL #ifdef VIRTUAL
LOG(logINFO, ("This is a VIRTUAL detector\n")); LOG(logINFO, ("This is a VIRTUAL detector\n"));
udpDetails[0].srcip = LOCALHOSTIP_INT;
#endif #endif
memset(udpDetails, 0, sizeof(udpDetails));
udpDetails[0].srcport = DEFAULT_UDP_SRC_PORTNO; udpDetails[0].srcport = DEFAULT_UDP_SRC_PORTNO;
udpDetails[0].dstport = DEFAULT_UDP_DST_PORTNO; udpDetails[0].dstport = DEFAULT_UDP_DST_PORTNO;
#ifdef EIGERD #ifdef EIGERD
@ -4855,12 +4858,14 @@ int is_udp_configured() {
LOG(logWARNING, ("%s", configureMessage)); LOG(logWARNING, ("%s", configureMessage));
return FAIL; return FAIL;
} }
#ifndef VIRTUAL
if (udpDetails[i].dstmac == 0) { if (udpDetails[i].dstmac == 0) {
sprintf(configureMessage, sprintf(configureMessage,
"udp destination mac not configured [entry:%d]\n", i); "udp destination mac not configured [entry:%d]\n", i);
LOG(logWARNING, ("%s", configureMessage)); LOG(logWARNING, ("%s", configureMessage));
return FAIL; return FAIL;
} }
#endif
#if defined(JUNGFRAUD) || defined(GOTTHARD2D) #if defined(JUNGFRAUD) || defined(GOTTHARD2D)
if (getNumberofUDPInterfaces() == 2) { if (getNumberofUDPInterfaces() == 2) {
if (udpDetails[i].srcip2 == 0) { if (udpDetails[i].srcip2 == 0) {
@ -4881,12 +4886,14 @@ int is_udp_configured() {
LOG(logWARNING, ("%s", configureMessage)); LOG(logWARNING, ("%s", configureMessage));
return FAIL; return FAIL;
} }
#ifndef VIRTUAL
if (udpDetails[i].dstmac2 == 0) { if (udpDetails[i].dstmac2 == 0) {
sprintf(configureMessage, sprintf(configureMessage,
"udp destination mac2 not configured [entry:%d]\n", i); "udp destination mac2 not configured [entry:%d]\n", i);
LOG(logWARNING, ("%s", configureMessage)); LOG(logWARNING, ("%s", configureMessage));
return FAIL; return FAIL;
} }
#endif
} }
#endif #endif
} }

View File

@ -1046,6 +1046,10 @@ void Module::setDestinationUDPIP(const IpAddr ip) {
if (ip == 0) { if (ip == 0) {
throw RuntimeError("Invalid destination udp ip address"); throw RuntimeError("Invalid destination udp ip address");
} }
if (ip.str() == LOCALHOST_IP && !isVirtualDetectorServer()) {
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); sendToDetector(F_SET_DEST_UDP_IP, ip, nullptr);
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {
sls::MacAddr retval(0LU); sls::MacAddr retval(0LU);
@ -1065,7 +1069,10 @@ void Module::setDestinationUDPIP2(const IpAddr ip) {
if (ip == 0) { if (ip == 0) {
throw RuntimeError("Invalid destination udp ip address2"); throw RuntimeError("Invalid destination udp ip address2");
} }
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); sendToDetector(F_SET_DEST_UDP_IP2, ip, nullptr);
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {
sls::MacAddr retval(0LU); sls::MacAddr retval(0LU);

View File

@ -1410,7 +1410,7 @@ sls::MacAddr ClientInterface::setUdpIp(sls::IpAddr arg) {
// get mac address // get mac address
auto retval = sls::InterfaceNameToMac(eth); 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:" + throw RuntimeError("Failed to get udp mac adddress to listen to (eth:" +
eth + ", ip:" + arg.str() + ")\n"); eth + ", ip:" + arg.str() + ")\n");
} }
@ -1445,7 +1445,7 @@ sls::MacAddr ClientInterface::setUdpIp2(sls::IpAddr arg) {
// get mac address // get mac address
auto retval = sls::InterfaceNameToMac(eth); auto retval = sls::InterfaceNameToMac(eth);
if (retval == 0) { if (retval == 0 && arg.str() != LOCALHOST_IP) {
throw RuntimeError( throw RuntimeError(
"Failed to get udp mac adddress2 to listen to (eth:" + eth + "Failed to get udp mac adddress2 to listen to (eth:" + eth +
", ip:" + arg.str() + ")\n"); ", ip:" + arg.str() + ")\n");

View File

@ -65,6 +65,8 @@
#define DEFAULT_DET_MAC2 "00:aa:bb:cc:dd:ff" #define DEFAULT_DET_MAC2 "00:aa:bb:cc:dd:ff"
#define DEFAULT_DET_IP2 "129.129.202.46" #define DEFAULT_DET_IP2 "129.129.202.46"
#define LOCALHOST_IP "127.0.0.1"
/** default maximum string length */ /** default maximum string length */
#define MAX_STR_LENGTH 1000 #define MAX_STR_LENGTH 1000
#define SHORT_STR_LENGTH 20 #define SHORT_STR_LENGTH 20
@ -564,7 +566,7 @@ enum streamingInterface {
#ifdef __cplusplus #ifdef __cplusplus
}; };
//operators needed in ToString // operators needed in ToString
inline slsDetectorDefs::streamingInterface inline slsDetectorDefs::streamingInterface
operator|(const slsDetectorDefs::streamingInterface &a, operator|(const slsDetectorDefs::streamingInterface &a,
const slsDetectorDefs::streamingInterface &b) { const slsDetectorDefs::streamingInterface &b) {
@ -579,8 +581,6 @@ operator&(const slsDetectorDefs::streamingInterface &a,
static_cast<int32_t>(b)); static_cast<int32_t>(b));
}; };
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus