diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c index 7c65c6bf0..e7f57a896 100644 --- a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c @@ -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); diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c index c76366ddd..60cd9210c 100644 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c @@ -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); diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index fc09b7763..127dc370f 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -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); diff --git a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c index 453493943..895042dd6 100644 --- a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c @@ -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); diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index 75d5117fe..07b33448d 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -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); diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c index 45bda6da6..bdda08571 100644 --- a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c @@ -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); diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c index 47ea022c4..9180efeef 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -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); diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index f9c14f38a..ced82bf64 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -52,6 +52,7 @@ typedef struct udpStruct_s { uint32_t dstip; uint32_t dstip2; } udpStruct; +#define MAC_ADDRESS_SIZE 18 // basic tests int isInitCheckDone(); diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index c31e1d8a2..54baf5a59 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -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();