changed the setClientIP function and included 2 header files for IP validation

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@81 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d 2012-01-10 09:31:52 +00:00
parent 0fd14ad113
commit 1a85d9f691
2 changed files with 13 additions and 5 deletions

View File

@ -3,7 +3,8 @@
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/socket.h>
#include <arpa/inet.h>
int slsDetector::initSharedMemory(detectorType type, int id) {
@ -4915,8 +4916,15 @@ int slsDetector::getScanPrecision(int iscan){
}
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");
else
sprintf(thisDetector->clientIP,clientIP.c_str());
return thisDetector->clientIP;
};

View File

@ -446,8 +446,8 @@ typedef struct sharedSlsDetector {
char* getClientIP() {return thisDetector->clientIP;};
/** returns the client MAC address for gotthard \sa sharedSlsDetector */
char* getClientMAC() {return thisDetector->clientMAC;};
/** sets the client IP address for gotthard \sa sharedSlsDetector */
char* setClientIP(string clientIP) {sprintf(thisDetector->clientIP,clientIP.c_str()); return thisDetector->clientIP;};
/** 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;};