diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 157087487..f15f5a41f 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -4920,13 +4920,27 @@ char* slsDetector::setClientIP(string clientIP){ struct sockaddr_in sa; int result = inet_pton(AF_INET, clientIP.c_str(), &(sa.sin_addr)); if((!result)||(clientIP.length()>15)) - sprintf(thisDetector->clientIP,"IP Address should be VALID and in xxx.xxx.xxx.xxx format"); + return ("IP Address should be VALID and in xxx.xxx.xxx.xxx format"); else sprintf(thisDetector->clientIP,clientIP.c_str()); return thisDetector->clientIP; }; +char* slsDetector::setClientMAC(string clientMAC){ + if(clientMAC.length()==17){ + if((clientMAC[2]==':')&&(clientMAC[5]==':')&&(clientMAC[8]==':')&& + (clientMAC[11]==':')&&(clientMAC[14]==':')) + sprintf(thisDetector->clientMAC,clientMAC.c_str()); + else + return("MAC Address should be in xx:xx:xx:xx:xx:xx format"); + } + else + return("MAC Address should be in xx:xx:xx:xx:xx:xx format"); + + return thisDetector->clientMAC; +}; + string slsDetector::executeLine(int narg, char *args[], int action) { diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index 50fa9ee29..4bec9e84a 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -448,8 +448,8 @@ typedef struct sharedSlsDetector { char* getClientMAC() {return thisDetector->clientMAC;}; /** validates and sets the client IP address for gotthard \sa sharedSlsDetector */ char* setClientIP(string clientIP); - /** sets the client MAC address for gotthard \sa sharedSlsDetector */ - char* setClientMAC(string clientMAC) {sprintf(thisDetector->clientMAC,clientMAC.c_str());return thisDetector->clientMAC;}; + /** validates the format of client MAC address and sets it for gotthard \sa sharedSlsDetector */ + char* setClientMAC(string clientMAC); /* I/O */