binaries in after merge

This commit is contained in:
maliakal_d 2021-09-09 10:46:59 +02:00
commit 49e40ae8f2
31 changed files with 168 additions and 179 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -52,9 +52,6 @@ int detPos[4] = {};
int chipVersion = 10; // (1.0) int chipVersion = 10; // (1.0)
int chipConfigured = 0; int chipConfigured = 0;
// until firmware is done
int temp_readNRows = 512;
int isInitCheckDone() { return initCheckDone; } int isInitCheckDone() { return initCheckDone; }
int getInitResult(char **mess) { int getInitResult(char **mess) {
@ -337,7 +334,7 @@ u_int32_t getDetectorIP() {
#ifdef VIRTUAL #ifdef VIRTUAL
return 0; return 0;
#endif #endif
char temp[50] = ""; char temp[INET_ADDRSTRLEN] = "";
u_int32_t res = 0; u_int32_t res = 0;
// execute and get address // execute and get address
char output[255]; char output[255];
@ -1480,16 +1477,16 @@ int configureMAC() {
int dstport = udpDetails[iRxEntry].dstport; int dstport = udpDetails[iRxEntry].dstport;
int dstport2 = udpDetails[iRxEntry].dstport2; int dstport2 = udpDetails[iRxEntry].dstport2;
char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50], char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
dst_ip[INET_ADDRSTRLEN]; dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, 50, srcmac); getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac);
getMacAddressinString(dst_mac, 50, dstmac); getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac);
getIpAddressinString(src_ip, srcip); getIpAddressinString(src_ip, srcip);
getIpAddressinString(dst_ip, dstip); getIpAddressinString(dst_ip, dstip);
char src_mac2[50], src_ip2[INET_ADDRSTRLEN], dst_mac2[50], char src_mac2[MAC_ADDRESS_SIZE], src_ip2[INET_ADDRSTRLEN],
dst_ip2[INET_ADDRSTRLEN]; dst_mac2[MAC_ADDRESS_SIZE], dst_ip2[INET_ADDRSTRLEN];
getMacAddressinString(src_mac2, 50, srcmac2); getMacAddressinString(src_mac2, MAC_ADDRESS_SIZE, srcmac2);
getMacAddressinString(dst_mac2, 50, dstmac2); getMacAddressinString(dst_mac2, MAC_ADDRESS_SIZE, dstmac2);
getIpAddressinString(src_ip2, srcip2); getIpAddressinString(src_ip2, srcip2);
getIpAddressinString(dst_ip2, dstip2); getIpAddressinString(dst_ip2, dstip2);
@ -1642,11 +1639,6 @@ int setReadNRows(int value) {
return FAIL; return FAIL;
} }
// will be replaced when firmware is fixed
LOG(logWARNING, ("Setting number of rows: %d (Not implemented in firmware yet)\n", value));
temp_readNRows = value;
return OK;
// regval is numpackets - 1 // regval is numpackets - 1
int regval = (value / READ_N_ROWS_MULTIPLE) - 1; int regval = (value / READ_N_ROWS_MULTIPLE) - 1;
uint32_t addr = READ_N_ROWS_REG; uint32_t addr = READ_N_ROWS_REG;
@ -1665,10 +1657,6 @@ int setReadNRows(int value) {
} }
int getReadNRows() { int getReadNRows() {
// will be replaced when firmware is fixed
return temp_readNRows;
int enable = (bus_r(READ_N_ROWS_REG) & READ_N_ROWS_ENBL_MSK); int enable = (bus_r(READ_N_ROWS_REG) & READ_N_ROWS_ENBL_MSK);
int regval = ((bus_r(READ_N_ROWS_REG) & READ_N_ROWS_NUM_ROWS_MSK) >> READ_N_ROWS_NUM_ROWS_OFST); int regval = ((bus_r(READ_N_ROWS_REG) & READ_N_ROWS_NUM_ROWS_MSK) >> READ_N_ROWS_NUM_ROWS_OFST);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1117,7 +1117,7 @@ class CmdProxy {
std::string Trigger(int action); std::string Trigger(int action);
/* Network Configuration (Detector<->Receiver) */ /* Network Configuration (Detector<->Receiver) */
IpAddr getIpFromAuto(); IpAddr getIpFromAuto();
slsDetectorDefs::udpDestination getUdpList(); UdpDestination getUdpEntry();
std::string UDPDestinationList(int action); std::string UDPDestinationList(int action);
std::string UDPDestinationIP(int action); std::string UDPDestinationIP(int action);
std::string UDPDestinationIP2(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); pimpl->Parallel(&Module::setSourceUDPMAC2, pos, mac);
} }
Result<defs::udpDestination> Result<UdpDestination> Detector::getDestinationUDPList(const uint32_t entry,
Detector::getDestinationUDPList(const uint32_t entry, Positions pos) const { Positions pos) const {
return pimpl->Parallel(&Module::getDestinationUDPList, pos, entry); return pimpl->Parallel(&Module::getDestinationUDPList, pos, entry);
} }
void Detector::setDestinationUDPList(const defs::udpDestination dest, void Detector::setDestinationUDPList(const UdpDestination dest,
const int module_id) { const int module_id) {
if (module_id == -1 && size() > 1) { if (module_id == -1 && size() > 1) {
throw sls::RuntimeError("Cannot set this parameter at detector level."); 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); sendToDetector(F_SET_SOURCE_UDP_MAC2, mac, nullptr);
} }
slsDetectorDefs::udpDestination sls::UdpDestination Module::getDestinationUDPList(const uint32_t entry) const {
Module::getDestinationUDPList(const uint32_t entry) const { return sendToDetector<sls::UdpDestination>(F_GET_DEST_UDP_LIST, entry);
return sendToDetector<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 // set them in the default way so the receivers are also set up
if (dest.entry_ == 0) { if (dest.entry == 0) {
if (dest.port_ != 0) { if (dest.port != 0) {
setDestinationUDPPort(dest.port_); setDestinationUDPPort(dest.port);
} }
if (dest.ip_ != 0) { if (dest.ip != 0) {
setDestinationUDPIP(IpAddr(dest.ip_)); setDestinationUDPIP(dest.ip);
} }
if (dest.mac_ != 0) { if (dest.mac != 0) {
setDestinationUDPMAC(MacAddr(dest.mac_)); setDestinationUDPMAC(dest.mac);
} }
if (dest.port2_ != 0) { if (dest.port2 != 0) {
setDestinationUDPPort2(dest.port2_); setDestinationUDPPort2(dest.port2);
} }
if (dest.ip2_ != 0) { if (dest.ip2 != 0) {
setDestinationUDPIP2(IpAddr(dest.ip2_)); setDestinationUDPIP2(dest.ip2);
} }
if (dest.mac2_ != 0) { if (dest.mac2 != 0) {
setDestinationUDPMAC2(MacAddr(dest.mac2_)); setDestinationUDPMAC2(dest.mac2);
} }
} else { } else {
sendToDetector(F_SET_DEST_UDP_LIST, dest, nullptr); 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); void setSourceUDPMAC(const sls::MacAddr mac);
sls::MacAddr getSourceUDPMAC2() const; sls::MacAddr getSourceUDPMAC2() const;
void setSourceUDPMAC2(const sls::MacAddr mac); void setSourceUDPMAC2(const sls::MacAddr mac);
udpDestination getDestinationUDPList(const uint32_t entry) const; sls::UdpDestination getDestinationUDPList(const uint32_t entry) const;
void setDestinationUDPList(const defs::udpDestination dest); void setDestinationUDPList(const sls::UdpDestination dest);
int getNumberofUDPDestinations() const; int getNumberofUDPDestinations() const;
void setNumberofUDPDestinations(const int value); void setNumberofUDPDestinations(const int value);
int getFirstUDPDestination() const; int getFirstUDPDestination() const;

View File

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

View File

@ -30,7 +30,7 @@ class IpAddr {
return addr_ != other; return addr_ != other;
} }
constexpr uint32_t uint32() const noexcept { return addr_; } constexpr uint32_t uint32() const noexcept { return addr_; }
}; } __attribute__((packed));
class MacAddr { class MacAddr {
private: private:
@ -57,13 +57,33 @@ class MacAddr {
return addr_ != other; return addr_ != other;
} }
constexpr uint64_t uint64() const noexcept { return addr_; } 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); IpAddr HostnameToIp(const char *hostname);
std::string IpToInterfaceName(const std::string &ip); std::string IpToInterfaceName(const std::string &ip);
MacAddr InterfaceNameToMac(const std::string &inf); MacAddr InterfaceNameToMac(const std::string &inf);
IpAddr InterfaceNameToIp(const std::string &ifn); 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 } // namespace sls

View File

@ -494,28 +494,6 @@ typedef struct {
} }
} __attribute__((packed)); } __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 * structure to udpate receiver
*/ */

View File

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

View File

@ -148,31 +148,6 @@ std::ostream &operator<<(std::ostream &os,
return os << ToString(r); 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) { std::string ToString(const defs::runStatus s) {
switch (s) { switch (s) {
case defs::ERROR: 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 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) { std::ostream &operator<<(std::ostream &out, const IpAddr &addr) {
return out << addr.str(); return out << addr.str();
} }
@ -77,6 +97,10 @@ std::ostream &operator<<(std::ostream &out, const MacAddr &addr) {
return out << addr.str(); return out << addr.str();
} }
std::ostream &operator<<(std::ostream &out, const UdpDestination &dest) {
return out << dest.str();
}
IpAddr HostnameToIp(const char *hostname) { IpAddr HostnameToIp(const char *hostname) {
addrinfo hints; addrinfo hints;
addrinfo *result = nullptr; addrinfo *result = nullptr;

View File

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

View File

@ -112,4 +112,19 @@ TEST_CASE("Copy construct a MacAddr") {
CHECK(addr == addr2); 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 // TODO!(Erik) Look up a real hostname and verify the IP