From c1fac7cdb709e86ea88d8064f0213484dc233614 Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Thu, 16 Jan 2020 16:31:11 +0100 Subject: [PATCH] fixed conversion for IpAddr --- slsDetectorSoftware/src/slsDetector.cpp | 12 ++++++------ slsReceiverSoftware/src/ClientInterface.cpp | 4 ++-- slsReceiverSoftware/src/Implementation.cpp | 2 +- slsSupportLib/include/network_utils.h | 4 ++-- slsSupportLib/src/ServerSocket.cpp | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/slsDetectorSoftware/src/slsDetector.cpp b/slsDetectorSoftware/src/slsDetector.cpp index b28b0a611..48638c401 100755 --- a/slsDetectorSoftware/src/slsDetector.cpp +++ b/slsDetectorSoftware/src/slsDetector.cpp @@ -343,8 +343,8 @@ void slsDetector::initializeDetectorStructure(detectorType type) { (detId * ((shm()->myDetectorType == EIGER) ? 2 : 1)); shm()->rxUpstream = false; shm()->rxReadFreq = 1; - shm()->zmqip = 0U; - shm()->rxZmqip = 0U; + shm()->zmqip = IpAddr{}; + shm()->rxZmqip = IpAddr{}; shm()->gappixels = 0U; memset(shm()->rxAdditionalJsonHeader, 0, MAX_STR_LENGTH); shm()->rxFrameDiscardMode = NO_DISCARD; @@ -690,7 +690,7 @@ bool slsDetector::lockServer(int lock) { } sls::IpAddr slsDetector::getLastClientIP() { - sls::IpAddr retval = 0U; + sls::IpAddr retval; FILE_LOG(logDEBUG1) << "Getting last client ip to detector server"; sendToDetector(F_GET_LAST_CLIENT_IP, nullptr, retval); FILE_LOG(logDEBUG1) << "Last client IP to detector: " << retval; @@ -1908,7 +1908,7 @@ void slsDetector::updateRxDestinationUDPIP() { auto ip = getDestinationUDPIP(); if (ip == 0) { // Hostname could be ip try to decode otherwise look up the hostname - ip = shm()->rxHostname; + ip = sls::IpAddr{shm()->rxHostname}; if (ip == 0) { ip = HostnameToIp(shm()->rxHostname); } @@ -1944,7 +1944,7 @@ void slsDetector::updateRxDestinationUDPIP2() { auto ip = getDestinationUDPIP2(); if (ip == 0) { // Hostname could be ip try to decode otherwise look up the hostname - ip = shm()->rxHostname; + ip = sls::IpAddr{shm()->rxHostname}; if (ip == 0) { ip = HostnameToIp(shm()->rxHostname); } @@ -2116,7 +2116,7 @@ void slsDetector::updateReceiverStreamingIP() { auto ip = getReceiverStreamingIP(); if (ip == 0) { // Hostname could be ip try to decode otherwise look up the hostname - ip = shm()->rxHostname; + ip = sls::IpAddr{shm()->rxHostname}; if (ip == 0) { ip = HostnameToIp(shm()->rxHostname); } diff --git a/slsReceiverSoftware/src/ClientInterface.cpp b/slsReceiverSoftware/src/ClientInterface.cpp index 15e0bbb18..b0d9006e7 100755 --- a/slsReceiverSoftware/src/ClientInterface.cpp +++ b/slsReceiverSoftware/src/ClientInterface.cpp @@ -320,7 +320,7 @@ int ClientInterface::send_update(Interface &socket) { int64_t i64 = -1; char cstring[MAX_STR_LENGTH]{}; - sls::IpAddr ip = 0u; + sls::IpAddr ip; ip = server->getLastClient(); n += socket.Send(&ip, sizeof(ip)); @@ -920,7 +920,7 @@ int ClientInterface::set_streaming_port(Interface &socket) { } int ClientInterface::set_streaming_source_ip(Interface &socket) { - sls::IpAddr arg = 0u; + sls::IpAddr arg; socket.Receive(arg); verifyIdle(socket); FILE_LOG(logDEBUG1) << "Setting streaming source ip:" << arg; diff --git a/slsReceiverSoftware/src/Implementation.cpp b/slsReceiverSoftware/src/Implementation.cpp index 55e0c4fb4..f9aaf3882 100755 --- a/slsReceiverSoftware/src/Implementation.cpp +++ b/slsReceiverSoftware/src/Implementation.cpp @@ -90,7 +90,7 @@ void Implementation::InitializeMembers() { streamingFrequency = 1; streamingTimerInMs = DEFAULT_STREAMING_TIMER_IN_MS; streamingPort = 0; - streamingSrcIP = 0u; + streamingSrcIP = sls::IpAddr{}; additionalJsonHeader = ""; // detector parameters diff --git a/slsSupportLib/include/network_utils.h b/slsSupportLib/include/network_utils.h index 82ac96b2f..faa2f3625 100755 --- a/slsSupportLib/include/network_utils.h +++ b/slsSupportLib/include/network_utils.h @@ -12,8 +12,8 @@ class IpAddr { public: constexpr IpAddr() noexcept = default; explicit constexpr IpAddr(uint32_t address) noexcept : addr_{address} {} - IpAddr(const std::string &address); - IpAddr(const char *address); + explicit IpAddr(const std::string &address); + explicit IpAddr(const char *address); std::string str() const; std::string hex() const; std::array arr() const; diff --git a/slsSupportLib/src/ServerSocket.cpp b/slsSupportLib/src/ServerSocket.cpp index ea7c831f1..93c9398da 100755 --- a/slsSupportLib/src/ServerSocket.cpp +++ b/slsSupportLib/src/ServerSocket.cpp @@ -48,7 +48,7 @@ ServerInterface2 ServerSocket::accept() { } char tc[INET_ADDRSTRLEN]{}; inet_ntop(AF_INET, &(clientAddr.sin_addr), tc, INET_ADDRSTRLEN); - thisClient = tc; + thisClient = IpAddr{tc}; return ServerInterface2(newSocket); }