diff --git a/slsDetectorServers/slsDetectorServer/include/DetectorServer.h b/slsDetectorServers/slsDetectorServer/include/DetectorServer.h index 644bcb440..d48baf099 100644 --- a/slsDetectorServers/slsDetectorServer/include/DetectorServer.h +++ b/slsDetectorServers/slsDetectorServer/include/DetectorServer.h @@ -66,14 +66,24 @@ template class DetectorServer { ReturnCode get_source_udp_mac(ServerInterface &socket) const; + ReturnCode set_source_udp_mac(ServerInterface &socket); + ReturnCode get_source_udp_ip(ServerInterface &socket) const; + ReturnCode set_source_udp_ip(ServerInterface &socket); + ReturnCode get_source_udp_port(ServerInterface &socket) const; + ReturnCode set_destination_udp_mac(ServerInterface &socket); + ReturnCode get_destination_udp_mac(ServerInterface &socket) const; + ReturnCode set_destination_udp_ip(ServerInterface &socket); + ReturnCode get_destination_udp_ip(ServerInterface &socket) const; + ReturnCode set_destination_udp_port(ServerInterface &socket); + ReturnCode get_destination_udp_port(ServerInterface &socket) const; }; @@ -109,16 +119,27 @@ ReturnCode DetectorServer::processFunction( ->get_num_udp_interfaces(socket); case detFuncs::F_GET_UPDATE_MODE: return get_update_mode(socket); + case detFuncs::F_SET_SOURCE_UDP_MAC: + return set_source_udp_mac(socket); case detFuncs::F_GET_SOURCE_UDP_MAC: return get_source_udp_mac(socket); + case detFuncs::F_SET_SOURCE_UDP_IP: + return set_source_udp_ip(socket); case detFuncs::F_GET_SOURCE_UDP_IP: return get_source_udp_ip(socket); + case detFuncs::F_SET_DEST_UDP_MAC: + return set_destination_udp_mac(socket); case detFuncs::F_GET_DEST_UDP_MAC: return get_destination_udp_mac(socket); + case detFuncs::F_SET_DEST_UDP_IP: + return set_destination_udp_ip(socket); case detFuncs::F_GET_DEST_UDP_IP: return get_destination_udp_ip(socket); + case detFuncs::F_SET_DEST_UDP_PORT: + return set_destination_udp_port(socket); case detFuncs::F_GET_DEST_UDP_PORT: return get_destination_udp_port(socket); + default: LOG(logDEBUG) << "Checking specific server functions for function ID: " << function_id; @@ -150,12 +171,51 @@ ReturnCode DetectorServer::get_update_mode( socket.sendResult(static_cast(updateMode))); } +template +ReturnCode DetectorServer::set_source_udp_mac( + ServerInterface &socket) { + uint64_t newsrcudpMac; + int ret = socket.Receive(newsrcudpMac); + + try { + int ret = socket.Receive(newsrcudpMac); + } catch (const SocketError &e) { + LOG(logERROR) << "Failed to receive new source UDP MAC address: " + << e.what(); + return ReturnCode::FAIL; + } + if (ret != static_cast(sizeof(newsrcudpMac))) { + return ReturnCode::FAIL; + } + + udpDetails[0].srcmac = newSrcMac; + return ReturnCode::OK; +} + template ReturnCode DetectorServer::get_source_udp_mac( ServerInterface &socket) const { return static_cast(socket.sendResult(udpDetails[0].srcmac)); } +template +ReturnCode DetectorServer::set_source_udp_ip( + ServerInterface &socket) { + uint32_t newSrcIp; + int ret = socket.Receive(newSrcIp); + + try { + int ret = socket.Receive(newSrcIp); + } catch (const SocketError &e) { + LOG(logERROR) << "Failed to receive new source UDP IP address: " + << e.what(); + return ReturnCode::FAIL; + } + + udpDetails[0].srcip = newSrcIp; + return ReturnCode::OK; +} + template ReturnCode DetectorServer::get_source_udp_ip( ServerInterface &socket) const { @@ -169,18 +229,69 @@ ReturnCode DetectorServer::get_source_udp_port( socket.sendResult(static_cast(udpDetails[0].srcport))); } +template +ReturnCode DetectorServer::set_destination_udp_mac( + ServerInterface &socket) { + uint64_t newDstMac; + int ret = socket.Receive(newDstMac); + try { + int ret = socket.Receive(newDstMac); + } catch (const SocketError &e) { + LOG(logERROR) << "Failed to receive new destination UDP MAC address: " + << e.what(); + return ReturnCode::FAIL; + } + + udpDetails[0].dstmac = newDstMac; + return ReturnCode::OK; +} + template ReturnCode DetectorServer::get_destination_udp_mac( ServerInterface &socket) const { return static_cast(socket.sendResult(udpDetails[0].dstmac)); } +template +ReturnCode DetectorServer::set_destination_udp_ip( + ServerInterface &socket) { + uint32_t newDstIp; + int ret = socket.Receive(newDstIp); + try { + int ret = socket.Receive(newDstIp); + } catch (const SocketError &e) { + LOG(logERROR) << "Failed to receive new destination UDP IP address: " + << e.what(); + return ReturnCode::FAIL; + } + + udpDetails[0].dstip = newDstIp; + return ReturnCode::OK; +} + template ReturnCode DetectorServer::get_destination_udp_ip( ServerInterface &socket) const { return static_cast(socket.sendResult(udpDetails[0].dstip)); } +template +ReturnCode DetectorServer::set_destination_udp_port( + ServerInterface &socket) { + uint16_t newDstPort; + int ret = socket.Receive(newDstPort); + try { + int ret = socket.Receive(newDstPort); + } catch (const SocketError &e) { + LOG(logERROR) << "Failed to receive new destination UDP port number: " + << e.what(); + return ReturnCode::FAIL; + } + + udpDetails[0].dstport = newDstPort; + return ReturnCode::OK; +} + template ReturnCode DetectorServer::get_destination_udp_port( ServerInterface &socket) const {