UDP struct uses IpAddr and MacAddr

This commit is contained in:
Erik Frojdh
2021-09-07 15:16:03 +02:00
parent 9d744deb4a
commit ba52bfb65e
6 changed files with 55 additions and 86 deletions

View File

@ -1388,34 +1388,34 @@ UdpDestination CmdProxy::getUdpEntry() {
std::string key = it.substr(0, pos);
std::string value = it.substr(pos + 1);
if (key == "entry") {
udpDestination.setEntry(StringTo<int>(value));
udpDestination.entry = StringTo<int>(value);
hasEntry = true;
} else if (key == "ip") {
if (value == "auto") {
auto val = getIpFromAuto();
LOG(logINFO) << "Setting udp_dstip of detector " << det_id
<< " to " << val;
udpDestination.setIp(val);
udpDestination.ip = val;
} else {
udpDestination.setIp(IpAddr(value));
udpDestination.ip = IpAddr(value);
}
} else if (key == "ip2") {
if (value == "auto") {
auto val = getIpFromAuto();
LOG(logINFO) << "Setting udp_dstip2 of detector " << det_id
<< " to " << val;
udpDestination.setIp2(val);
udpDestination.ip2 = val;
} else {
udpDestination.setIp2(IpAddr(value));
udpDestination.ip2 = IpAddr(value);
}
} else if (key == "mac") {
udpDestination.setMac(MacAddr(value));
udpDestination.mac = MacAddr(value);
} else if (key == "mac2") {
udpDestination.setMac2(MacAddr(value));
udpDestination.mac2 = MacAddr(value);
} else if (key == "port") {
udpDestination.setPort(StringTo<uint32_t>(value));
udpDestination.port = StringTo<uint32_t>(value);
} else if (key == "port2") {
udpDestination.setPort2(StringTo<uint32_t>(value));
udpDestination.port2 = StringTo<uint32_t>(value);
}
}
if (!hasEntry) {

View File

@ -945,24 +945,24 @@ sls::UdpDestination Module::getDestinationUDPList(const uint32_t entry) const {
void Module::setDestinationUDPList(const sls::UdpDestination dest) {
// set them in the default way so the receivers are also set up
if (dest.getEntry() == 0) {
if (dest.getPort() != 0) {
setDestinationUDPPort(dest.getPort());
if (dest.entry == 0) {
if (dest.port != 0) {
setDestinationUDPPort(dest.port);
}
if (dest.getIp() != 0) {
setDestinationUDPIP(IpAddr(dest.getIp()));
if (dest.ip != 0) {
setDestinationUDPIP(dest.ip);
}
if (dest.getMac() != 0) {
setDestinationUDPMAC(MacAddr(dest.getMac()));
if (dest.mac != 0) {
setDestinationUDPMAC(dest.mac);
}
if (dest.getPort2() != 0) {
setDestinationUDPPort2(dest.getPort2());
if (dest.port2 != 0) {
setDestinationUDPPort2(dest.port2);
}
if (dest.getIp2() != 0) {
setDestinationUDPIP2(IpAddr(dest.getIp2()));
if (dest.ip2 != 0) {
setDestinationUDPIP2(dest.ip2);
}
if (dest.getMac2() != 0) {
setDestinationUDPMAC2(MacAddr(dest.getMac2()));
if (dest.mac2 != 0) {
setDestinationUDPMAC2(dest.mac2);
}
} else {
sendToDetector(F_SET_DEST_UDP_LIST, dest, nullptr);