binaries in

This commit is contained in:
maliakal_d 2021-09-07 16:44:35 +02:00
commit 9a22a1e530
31 changed files with 167 additions and 167 deletions

View File

@ -41,7 +41,7 @@ def list_to_bitmask(values):
return mask
def make_bitmask(args):
if isinstance(args, list):
if isinstance(args, (list,tuple)):
return list_to_bitmask(args)
elif isinstance(args, dict):
return {key: list_to_bitmask(value) for key, value in args.items()}

View File

@ -392,7 +392,7 @@ uint32_t getDetectorIP() {
#ifdef VIRTUAL
return 0;
#endif
char temp[50] = "";
char temp[INET_ADDRSTRLEN] = "";
uint32_t res = 0;
// execute and get address
char output[255];
@ -1525,10 +1525,10 @@ int configureMAC() {
int dstport = udpDetails[0].dstport;
LOG(logINFOBLUE, ("Configuring MAC\n"));
char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50],
dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, 50, srcmac);
getMacAddressinString(dst_mac, 50, dstmac);
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac);
getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac);
getIpAddressinString(src_ip, srcip);
getIpAddressinString(dst_ip, dstip);

View File

@ -283,7 +283,7 @@ u_int64_t getDetectorMAC() {
}
u_int32_t getDetectorIP() {
char temp[50] = "";
char temp[INET_ADDRSTRLEN] = "";
u_int32_t res = 0;
// execute and get address
char output[255];
@ -1545,10 +1545,10 @@ int configureMAC() {
int dstport = udpDetails[iRxEntry].dstport;
int dstport2 = udpDetails[iRxEntry].dstport2;
char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50],
dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, 50, srcmac);
getMacAddressinString(dst_mac, 50, dstmac);
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac);
getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac);
getIpAddressinString(src_ip, srcip);
getIpAddressinString(dst_ip, dstip);

View File

@ -323,7 +323,7 @@ u_int32_t getDetectorIP() {
#ifdef VIRTUAL
return 0;
#endif
char temp[50] = "";
char temp[INET_ADDRSTRLEN] = "";
u_int32_t res = 0;
// execute and get address
char output[255];
@ -1743,16 +1743,16 @@ int configureMAC() {
int dstport2 = udpDetails[0].dstport2;
LOG(logINFOBLUE, ("Configuring MAC\n"));
char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50],
dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, 50, srcmac);
getMacAddressinString(dst_mac, 50, dstmac);
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac);
getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac);
getIpAddressinString(src_ip, srcip);
getIpAddressinString(dst_ip, dstip);
char src_mac2[50], src_ip2[INET_ADDRSTRLEN], dst_mac2[50],
dst_ip2[INET_ADDRSTRLEN];
getMacAddressinString(src_mac2, 50, srcmac2);
getMacAddressinString(dst_mac2, 50, dstmac2);
char src_mac2[MAC_ADDRESS_SIZE], src_ip2[INET_ADDRSTRLEN],
dst_mac2[MAC_ADDRESS_SIZE], dst_ip2[INET_ADDRSTRLEN];
getMacAddressinString(src_mac2, MAC_ADDRESS_SIZE, srcmac2);
getMacAddressinString(dst_mac2, MAC_ADDRESS_SIZE, dstmac2);
getIpAddressinString(src_ip2, srcip2);
getIpAddressinString(dst_ip2, dstip2);

View File

@ -315,7 +315,7 @@ u_int32_t getDetectorIP() {
#ifdef VIRTUAL
return 0;
#endif
char temp[50] = "";
char temp[INET_ADDRSTRLEN] = "";
u_int32_t res = 0;
// execute and get address
char output[255];
@ -1340,10 +1340,10 @@ int configureMAC() {
int dstport = udpDetails[0].dstport;
LOG(logINFOBLUE, ("Configuring MAC\n"));
char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50],
dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, 50, srcmac);
getMacAddressinString(dst_mac, 50, dstmac);
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac);
getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac);
getIpAddressinString(src_ip, srcip);
getIpAddressinString(dst_ip, dstip);

View File

@ -337,7 +337,7 @@ u_int32_t getDetectorIP() {
#ifdef VIRTUAL
return 0;
#endif
char temp[50] = "";
char temp[INET_ADDRSTRLEN] = "";
u_int32_t res = 0;
// execute and get address
char output[255];
@ -1480,16 +1480,16 @@ int configureMAC() {
int dstport = udpDetails[iRxEntry].dstport;
int dstport2 = udpDetails[iRxEntry].dstport2;
char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50],
dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, 50, srcmac);
getMacAddressinString(dst_mac, 50, dstmac);
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac);
getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac);
getIpAddressinString(src_ip, srcip);
getIpAddressinString(dst_ip, dstip);
char src_mac2[50], src_ip2[INET_ADDRSTRLEN], dst_mac2[50],
dst_ip2[INET_ADDRSTRLEN];
getMacAddressinString(src_mac2, 50, srcmac2);
getMacAddressinString(dst_mac2, 50, dstmac2);
char src_mac2[MAC_ADDRESS_SIZE], src_ip2[INET_ADDRSTRLEN],
dst_mac2[MAC_ADDRESS_SIZE], dst_ip2[INET_ADDRSTRLEN];
getMacAddressinString(src_mac2, MAC_ADDRESS_SIZE, srcmac2);
getMacAddressinString(dst_mac2, MAC_ADDRESS_SIZE, dstmac2);
getIpAddressinString(src_ip2, srcip2);
getIpAddressinString(dst_ip2, dstip2);

View File

@ -389,7 +389,7 @@ uint32_t getDetectorIP() {
#ifdef VIRTUAL
return 0;
#endif
char temp[50] = "";
char temp[INET_ADDRSTRLEN] = "";
uint32_t res = 0;
// execute and get address
char output[255];
@ -1190,10 +1190,10 @@ int configureMAC() {
int dstport = udpDetails[0].dstport;
LOG(logINFOBLUE, ("Configuring MAC\n"));
char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50],
dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, 50, srcmac);
getMacAddressinString(dst_mac, 50, dstmac);
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac);
getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac);
getIpAddressinString(src_ip, srcip);
getIpAddressinString(dst_ip, dstip);

View File

@ -323,7 +323,7 @@ u_int32_t getDetectorIP() {
#ifdef VIRTUAL
return 0;
#endif
char temp[50] = "";
char temp[INET_ADDRSTRLEN] = "";
u_int32_t res = 0;
// execute and get address
char output[255];
@ -1731,10 +1731,10 @@ int configureMAC() {
int dstport = udpDetails[0].dstport;
LOG(logINFOBLUE, ("Configuring MAC\n"));
char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50],
dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, 50, srcmac);
getMacAddressinString(dst_mac, 50, dstmac);
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac);
getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac);
getIpAddressinString(src_ip, srcip);
getIpAddressinString(dst_ip, dstip);

View File

@ -52,6 +52,7 @@ typedef struct udpStruct_s {
uint32_t dstip;
uint32_t dstip2;
} udpStruct;
#define MAC_ADDRESS_SIZE 18
// basic tests
int isInitCheckDone();

View File

@ -1753,8 +1753,8 @@ int acquire(int blocking, int file_des) {
if (udpDetails[0].srcmac != getDetectorMAC()) {
ret = FAIL;
uint64_t sourcemac = getDetectorMAC();
char src_mac[50];
getMacAddressinString(src_mac, 50, sourcemac);
char src_mac[MAC_ADDRESS_SIZE];
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, sourcemac);
sprintf(mess,
"Invalid udp source mac address for this detector. Must be "
"same as hardware detector mac address %s\n",
@ -4866,8 +4866,8 @@ void calculate_and_set_position() {
else {
// create detector mac from x and y
if (udpDetails[0].srcmac == 0) {
char dmac[50];
memset(dmac, 0, 50);
char dmac[MAC_ADDRESS_SIZE];
memset(dmac, 0, MAC_ADDRESS_SIZE);
sprintf(dmac, "aa:bb:cc:dd:%02x:%02x", pos[0] & 0xFF,
pos[1] & 0xFF);
LOG(logINFO, ("Udp source mac address created: %s\n", dmac));
@ -4886,8 +4886,8 @@ void calculate_and_set_position() {
#if defined(JUNGFRAUD) || defined(GOTTHARD2D)
if (getNumberofUDPInterfaces() > 1) {
if (udpDetails[0].srcmac2 == 0) {
char dmac2[50];
memset(dmac2, 0, 50);
char dmac2[MAC_ADDRESS_SIZE];
memset(dmac2, 0, MAC_ADDRESS_SIZE);
sprintf(dmac2, "aa:bb:cc:dd:%02x:%02x", (pos[0] + 1) & 0xFF,
pos[1] & 0xFF);
LOG(logINFO, ("Udp source mac address2 created: %s\n", dmac2));
@ -9090,9 +9090,9 @@ int get_dest_udp_list(int file_des) {
char ip[INET_ADDRSTRLEN], ip2[INET_ADDRSTRLEN];
getIpAddressinString(ip, retvals[3]);
getIpAddressinString(ip2, retvals[4]);
char mac[50], mac2[50];
getMacAddressinString(mac, 50, retvals64[0]);
getMacAddressinString(mac2, 50, retvals64[1]);
char mac[MAC_ADDRESS_SIZE], mac2[MAC_ADDRESS_SIZE];
getMacAddressinString(mac, MAC_ADDRESS_SIZE, retvals64[0]);
getMacAddressinString(mac2, MAC_ADDRESS_SIZE, retvals64[1]);
LOG(logDEBUG1,
("Udp Dest. retval [%d]: [port %d, port2 %d, ip %s, ip2 %s, "
"mac %s, mac2 %s]\n",
@ -9126,9 +9126,9 @@ int set_dest_udp_list(int file_des) {
char ip[INET_ADDRSTRLEN], ip2[INET_ADDRSTRLEN];
getIpAddressinString(ip, args[3]);
getIpAddressinString(ip2, args[4]);
char mac[50], mac2[50];
getMacAddressinString(mac, 50, args64[0]);
getMacAddressinString(mac2, 50, args64[1]);
char mac[MAC_ADDRESS_SIZE], mac2[MAC_ADDRESS_SIZE];
getMacAddressinString(mac, MAC_ADDRESS_SIZE, args64[0]);
getMacAddressinString(mac2, MAC_ADDRESS_SIZE, args64[1]);
#if !defined(EIGERD) && !defined(JUNGFRAUD)
functionNotImplemented();

View File

@ -666,10 +666,10 @@ class Detector {
/** [Jungfrau] bottom half [Gotthard2] veto debugging */
void setSourceUDPMAC2(const MacAddr mac, Positions pos = {});
Result<defs::udpDestination>
getDestinationUDPList(const uint32_t entry, Positions pos = {}) const;
Result<UdpDestination> getDestinationUDPList(const uint32_t entry,
Positions pos = {}) const;
void setDestinationUDPList(const defs::udpDestination, const int module_id);
void setDestinationUDPList(const UdpDestination, const int module_id);
/** [Jungfrau][Eiger] */
Result<int> getNumberofUDPDestinations(Positions pos = {}) const;

View File

@ -1379,15 +1379,8 @@ IpAddr CmdProxy::getIpFromAuto() {
return val;
}
defs::udpDestination CmdProxy::getUdpList() {
uint32_t entry{};
uint32_t port{};
uint32_t port2{};
uint32_t ip{};
uint32_t ip2{};
uint64_t mac{};
uint64_t mac2{};
UdpDestination CmdProxy::getUdpEntry() {
UdpDestination udpDestination{};
bool hasEntry = false;
for (auto it : args) {
@ -1395,40 +1388,40 @@ defs::udpDestination CmdProxy::getUdpList() {
std::string key = it.substr(0, pos);
std::string value = it.substr(pos + 1);
if (key == "entry") {
entry = 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;
ip = val.uint32();
udpDestination.ip = val;
} else {
ip = IpAddr(value).uint32();
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;
ip2 = val.uint32();
udpDestination.ip2 = val;
} else {
ip2 = IpAddr(value).uint32();
udpDestination.ip2 = IpAddr(value);
}
} else if (key == "mac") {
mac = MacAddr(value).uint64();
udpDestination.mac = MacAddr(value);
} else if (key == "mac2") {
mac2 = MacAddr(value).uint64();
udpDestination.mac2 = MacAddr(value);
} else if (key == "port") {
port = StringTo<uint32_t>(value);
udpDestination.port = StringTo<uint32_t>(value);
} else if (key == "port2") {
port2 = StringTo<uint32_t>(value);
udpDestination.port2 = StringTo<uint32_t>(value);
}
}
if (!hasEntry) {
throw sls::RuntimeError("Found no entry argument.");
}
return defs::udpDestination(entry, port, ip, mac, port2, ip2, mac2);
return udpDestination;
}
std::string CmdProxy::UDPDestinationList(int action) {
@ -1454,7 +1447,7 @@ std::string CmdProxy::UDPDestinationList(int action) {
if (args.empty()) {
WrongNumberOfParameters(1);
}
auto t = getUdpList();
auto t = getUdpEntry();
det->setDestinationUDPList(t, det_id);
os << ToString(args) << std::endl;
} else {

View File

@ -1117,7 +1117,7 @@ class CmdProxy {
std::string Trigger(int action);
/* Network Configuration (Detector<->Receiver) */
IpAddr getIpFromAuto();
slsDetectorDefs::udpDestination getUdpList();
UdpDestination getUdpEntry();
std::string UDPDestinationList(int action);
std::string UDPDestinationIP(int action);
std::string UDPDestinationIP2(int action);

View File

@ -908,12 +908,12 @@ void Detector::setSourceUDPMAC2(const MacAddr mac, Positions pos) {
pimpl->Parallel(&Module::setSourceUDPMAC2, pos, mac);
}
Result<defs::udpDestination>
Detector::getDestinationUDPList(const uint32_t entry, Positions pos) const {
Result<UdpDestination> Detector::getDestinationUDPList(const uint32_t entry,
Positions pos) const {
return pimpl->Parallel(&Module::getDestinationUDPList, pos, entry);
}
void Detector::setDestinationUDPList(const defs::udpDestination dest,
void Detector::setDestinationUDPList(const UdpDestination dest,
const int module_id) {
if (module_id == -1 && size() > 1) {
throw sls::RuntimeError("Cannot set this parameter at detector level.");

View File

@ -939,31 +939,30 @@ void Module::setSourceUDPMAC2(const sls::MacAddr mac) {
sendToDetector(F_SET_SOURCE_UDP_MAC2, mac, nullptr);
}
slsDetectorDefs::udpDestination
Module::getDestinationUDPList(const uint32_t entry) const {
return sendToDetector<udpDestination>(F_GET_DEST_UDP_LIST, entry);
sls::UdpDestination Module::getDestinationUDPList(const uint32_t entry) const {
return sendToDetector<sls::UdpDestination>(F_GET_DEST_UDP_LIST, entry);
}
void Module::setDestinationUDPList(const slsDetectorDefs::udpDestination dest) {
void Module::setDestinationUDPList(const sls::UdpDestination dest) {
// set them in the default way so the receivers are also set up
if (dest.entry_ == 0) {
if (dest.port_ != 0) {
setDestinationUDPPort(dest.port_);
if (dest.entry == 0) {
if (dest.port != 0) {
setDestinationUDPPort(dest.port);
}
if (dest.ip_ != 0) {
setDestinationUDPIP(IpAddr(dest.ip_));
if (dest.ip != 0) {
setDestinationUDPIP(dest.ip);
}
if (dest.mac_ != 0) {
setDestinationUDPMAC(MacAddr(dest.mac_));
if (dest.mac != 0) {
setDestinationUDPMAC(dest.mac);
}
if (dest.port2_ != 0) {
setDestinationUDPPort2(dest.port2_);
if (dest.port2 != 0) {
setDestinationUDPPort2(dest.port2);
}
if (dest.ip2_ != 0) {
setDestinationUDPIP2(IpAddr(dest.ip2_));
if (dest.ip2 != 0) {
setDestinationUDPIP2(dest.ip2);
}
if (dest.mac2_ != 0) {
setDestinationUDPMAC2(MacAddr(dest.mac2_));
if (dest.mac2 != 0) {
setDestinationUDPMAC2(dest.mac2);
}
} else {
sendToDetector(F_SET_DEST_UDP_LIST, dest, nullptr);

View File

@ -222,8 +222,8 @@ class Module : public virtual slsDetectorDefs {
void setSourceUDPMAC(const sls::MacAddr mac);
sls::MacAddr getSourceUDPMAC2() const;
void setSourceUDPMAC2(const sls::MacAddr mac);
udpDestination getDestinationUDPList(const uint32_t entry) const;
void setDestinationUDPList(const defs::udpDestination dest);
sls::UdpDestination getDestinationUDPList(const uint32_t entry) const;
void setDestinationUDPList(const sls::UdpDestination dest);
int getNumberofUDPDestinations() const;
void setNumberofUDPDestinations(const int value);
int getFirstUDPDestination() const;

View File

@ -55,9 +55,6 @@ std::ostream &operator<<(std::ostream &os,
std::string ToString(const slsDetectorDefs::currentSrcParameters &r);
std::ostream &operator<<(std::ostream &os,
const slsDetectorDefs::currentSrcParameters &r);
std::string ToString(const slsDetectorDefs::udpDestination &r);
std::ostream &operator<<(std::ostream &os,
const slsDetectorDefs::udpDestination &r);
const std::string &ToString(const std::string &s);
/** Convert std::chrono::duration with specified output unit */

View File

@ -30,7 +30,7 @@ class IpAddr {
return addr_ != other;
}
constexpr uint32_t uint32() const noexcept { return addr_; }
};
} __attribute__((packed));
class MacAddr {
private:
@ -57,13 +57,33 @@ class MacAddr {
return addr_ != other;
}
constexpr uint64_t uint64() const noexcept { return addr_; }
};
} __attribute__((packed));
struct UdpDestination {
uint32_t entry{};
uint32_t port{};
uint32_t port2{};
IpAddr ip;
IpAddr ip2;
MacAddr mac;
MacAddr mac2;
std::string str() const;
constexpr bool operator==(const UdpDestination &other) const {
return ((entry == other.entry) && (port == other.port) &&
(port2 == other.port2) && (ip== other.ip) &&
(ip2 == other.ip2) && (mac == other.mac) &&
(mac2 == other.mac2));
}
} __attribute__((packed));
std::ostream &operator<<(std::ostream &out, const IpAddr &addr);
std::ostream &operator<<(std::ostream &out, const MacAddr &addr);
std::ostream &operator<<(std::ostream &out, const UdpDestination &dest);
IpAddr HostnameToIp(const char *hostname);
std::string IpToInterfaceName(const std::string &ip);
MacAddr InterfaceNameToMac(const std::string &inf);
IpAddr InterfaceNameToIp(const std::string &ifn);
std::ostream &operator<<(std::ostream &out, const IpAddr &addr);
std::ostream &operator<<(std::ostream &out, const MacAddr &addr);
} // namespace sls

View File

@ -494,28 +494,6 @@ typedef struct {
}
} __attribute__((packed));
struct udpDestination {
uint32_t entry_{};
uint32_t port_{};
uint32_t port2_{};
uint32_t ip_{};
uint32_t ip2_{};
uint64_t mac_{};
uint64_t mac2_{};
udpDestination() {}
udpDestination(uint32_t entry, uint32_t port = 0, uint32_t ip = 0, uint64_t mac = 0,
uint32_t port2 = 0, uint32_t ip2 = 0, uint64_t mac2 = 0)
: entry_(entry), port_(port), port2_(port2), ip_(ip), ip2_(ip2),
mac_(mac), mac2_(mac2) {}
bool operator==(const udpDestination &other) const {
return ((entry_ == other.entry_) && (port_ == other.port_) &&
(port2_ == other.port2_) && (ip_ == other.ip_) &&
(ip2_ == other.ip2_) && (mac_ == other.mac_) &&
(mac2_ == other.mac2_));
}
} __attribute__((packed));
/**
* structure to udpate receiver
*/

View File

@ -1,15 +1,13 @@
/** API versions */
#define GITBRANCH "roundrobin"
#define APILIB 0x210831
#define APIRECEIVER 0x210831
#define APIGUI 0x210819
#define APICTB 0x210831
#define APIGOTTHARD 0x210831
#define APIGOTTHARD2 0x210831
#define APIMYTHEN3 0x210831
#define APIMOENCH 0x210831
#define APIEIGER 0x210831
#define APIJUNGFRAU 0x210831
#define APICTB 0x210907
#define APIGOTTHARD 0x210907
#define APIGOTTHARD2 0x210907
#define APIJUNGFRAU 0x210907
#define APIMYTHEN3 0x210907
#define APIMOENCH 0x210907
#define APIEIGER 0x210907

View File

@ -148,31 +148,6 @@ std::ostream &operator<<(std::ostream &os,
return os << ToString(r);
}
std::string ToString(const slsDetectorDefs::udpDestination &r) {
std::ostringstream oss;
oss << '[' << std::endl
<< "entry " << r.entry_ << std::endl
<< "ip " << IpAddr(r.ip_) << std::endl
<< "mac " << MacAddr(r.mac_) << std::endl
<< "port " << r.port_ << std::endl;
if (r.port2_ != 0) {
oss << "port2 " << r.port2_ << std::endl;
}
if (r.ip2_ != 0) {
oss << "ip2 " << IpAddr(r.ip2_) << std::endl;
}
if (r.mac2_ != 0) {
oss << "mac2 " << MacAddr(r.mac2_) << std::endl;
}
oss << ']';
return oss.str();
}
std::ostream &operator<<(std::ostream &os,
const slsDetectorDefs::udpDestination &r) {
return os << ToString(r);
}
std::string ToString(const defs::runStatus s) {
switch (s) {
case defs::ERROR:

View File

@ -69,6 +69,26 @@ std::string MacAddr::str() const { return to_hex(':'); }
std::string MacAddr::hex() const { return to_hex(); }
std::string UdpDestination::str() const {
std::ostringstream oss;
oss << '[' << std::endl
<< "entry " << entry << std::endl
<< "ip " << ip << std::endl
<< "mac " << mac << std::endl
<< "port " << port << std::endl;
if (port2 != 0) {
oss << "port2 " << port2 << std::endl;
}
if (ip2 != 0) {
oss << "ip2 " << ip2 << std::endl;
}
if (mac2 != 0) {
oss << "mac2 " << mac2 << std::endl;
}
oss << ']';
return oss.str();
}
std::ostream &operator<<(std::ostream &out, const IpAddr &addr) {
return out << addr.str();
}
@ -77,6 +97,10 @@ std::ostream &operator<<(std::ostream &out, const MacAddr &addr) {
return out << addr.str();
}
std::ostream &operator<<(std::ostream &out, const UdpDestination &dest) {
return out << dest.str();
}
IpAddr HostnameToIp(const char *hostname) {
addrinfo hints;
addrinfo *result = nullptr;

View File

@ -9,7 +9,7 @@ TEST_CASE("Get size of empty file") {
char fname[] = "temfile_XXXXXX";
std::ifstream ifs(fname);
auto size = sls::getFileSize(ifs);
REQUIRE(size == 0);
REQUIRE(size <= 0); // -1 or zero
}
TEST_CASE("Get size of file with data") {

View File

@ -112,4 +112,19 @@ TEST_CASE("Copy construct a MacAddr") {
CHECK(addr == addr2);
}
TEST_CASE("udp dst struct basic properties"){
static_assert(sizeof(UdpDestination) == 36);
UdpDestination dst{};
REQUIRE(dst.entry == 0);
REQUIRE(dst.port == 0);
REQUIRE(dst.port2 == 0);
REQUIRE(dst.ip == 0);
REQUIRE(dst.ip2 == 0);
REQUIRE(dst.mac == 0);
REQUIRE(dst.mac2 == 0);
}
// TODO!(Erik) Look up a real hostname and verify the IP