diff --git a/slsDetectorSoftware/eigerDetectorServer/EigerBackEndFunctions.c b/slsDetectorSoftware/eigerDetectorServer/EigerBackEndFunctions.c new file mode 100644 index 000000000..be7a87aad --- /dev/null +++ b/slsDetectorSoftware/eigerDetectorServer/EigerBackEndFunctions.c @@ -0,0 +1,185 @@ + +/** + * @author Ian Johnson + * @version 1.0 + */ + + +#include +#include +#include +#include + + + +#include "slsDetectorServer_defs.h" //include port number + +struct sockaddr_in eiger_back_socket_addr; +int eiger_back_max_message_length = 1024; +char eiger_back_message[1024]; +int eiger_back_message_length = 0; +int eiger_back_ret_val=0; + + +int bit_mode=0; + +int EigerBackInit(){ + static int passed = 0; + + if(!passed){ + struct hostent *dst_host; + if((dst_host = gethostbyname("localhost")) == NULL){ //or look into getaddrinfo(3) + fprintf(stderr,"ERROR, no such host\n"); + return 0; + }else{ + //struct sockaddr_in eiger_back_socket_addr; + int port = BEB_PORT; + bzero((char *) &eiger_back_socket_addr, sizeof(eiger_back_socket_addr)); + eiger_back_socket_addr.sin_family = AF_INET; + bcopy((char *)dst_host->h_addr,(char *)&eiger_back_socket_addr.sin_addr.s_addr,dst_host->h_length); + eiger_back_socket_addr.sin_port = htons(port); + passed = 1; + } + } + + return passed; +} + + +int EigerBackSendCMD(){ + if(!EigerBackInit()||eiger_back_message_length<=0) return 0; + + int sockfd = socket(AF_INET,SOCK_STREAM,0); + if(sockfd<0){ + fprintf(stderr,"ERROR opening socket\n"); + return 0; + } + + if(connect(sockfd,(struct sockaddr *) &eiger_back_socket_addr,sizeof(eiger_back_socket_addr))<0){ + fprintf(stderr,"ERROR connecting\n"); + return 0; + } + + int n = write(sockfd,eiger_back_message,eiger_back_message_length); + int ret_length = read(sockfd,eiger_back_message,eiger_back_max_message_length); + + close(sockfd); + + if(n<0||ret_length<0) return 0; + + + //fprintf(stdout,"%s\n",eiger_back_message); + if(eiger_back_ret_val>0){ + int i=0; + eiger_back_message[1]='\0'; + if(atoi(eiger_back_message)!=0) return 0; + + for(i=2;i <1GbE(0) or 10GbE(1)> +int EigerSetupTableEntryLeft(int ipad, long long int macad, long long int detectormacadd, int detipad, int udpport){ + char src_mac[50], src_ip[50],dst_mac[50], dst_ip[50]; + + int src_port = 0xE185; + int dst_port = udpport; + sprintf(src_ip,"%d.%d.%d.%d",(detipad>>24)&0xff,(detipad>>16)&0xff,(detipad>>8)&0xff,(detipad)&0xff); + sprintf(dst_ip,"%d.%d.%d.%d",(ipad>>24)&0xff,(ipad>>16)&0xff,(ipad>>8)&0xff,(ipad)&0xff); + sprintf(src_mac,"%x:%x:%x:%x:%x:%x",(unsigned int)((detectormacadd>>40)&0xFF), + (unsigned int)((detectormacadd>>32)&0xFF), + (unsigned int)((detectormacadd>>24)&0xFF), + (unsigned int)((detectormacadd>>16)&0xFF), + (unsigned int)((detectormacadd>>8)&0xFF), + (unsigned int)((detectormacadd>>0)&0xFF)); + sprintf(dst_mac,"%x:%x:%x:%x:%x:%x",(unsigned int)((macad>>40)&0xFF), + (unsigned int)((macad>>32)&0xFF), + (unsigned int)((macad>>24)&0xFF), + (unsigned int)((macad>>16)&0xFF), + (unsigned int)((macad>>8)&0xFF), + (unsigned int)((macad>>0)&0xFF)); + + + printf("Seting up Table Entry Left:\n"); + printf("src_port:%d\n",src_port); + printf("dst_port:%d\n",dst_port); + printf("src_ip:%s\n",src_ip); + printf("dst_ip:%s\n",dst_ip); + printf("src_mac:%s\n",src_mac); + printf("dst_mac:%s\n\n",dst_mac); + + eiger_back_ret_val=0; + eiger_back_message_length = sprintf(eiger_back_message,"setuptableentry %d %d %d %s %s %d %s %s %d",1,0,0,src_mac,src_ip,src_port,dst_mac,dst_ip,dst_port); + return EigerBackSendCMD(); +} + + +int EigerSetupTableEntryRight(int ipad, long long int macad, long long int detectormacadd, int detipad, int udpport){ + char src_mac[50], src_ip[50],dst_mac[50], dst_ip[50]; + + int src_port = 0xE185; + int dst_port = udpport+1; + sprintf(src_ip,"%d.%d.%d.%d",(detipad>>24)&0xff,(detipad>>16)&0xff,(detipad>>8)&0xff,(detipad)&0xff); + sprintf(dst_ip,"%d.%d.%d.%d",(ipad>>24)&0xff,(ipad>>16)&0xff,(ipad>>8)&0xff,(ipad)&0xff); + sprintf(src_mac,"%x:%x:%x:%x:%x:%x",(unsigned int)((detectormacadd>>40)&0xFF), + (unsigned int)((detectormacadd>>32)&0xFF), + (unsigned int)((detectormacadd>>24)&0xFF), + (unsigned int)((detectormacadd>>16)&0xFF), + (unsigned int)((detectormacadd>>8)&0xFF), + (unsigned int)((detectormacadd>>0)&0xFF)); + sprintf(dst_mac,"%x:%x:%x:%x:%x:%x",(unsigned int)((macad>>40)&0xFF), + (unsigned int)((macad>>32)&0xFF), + (unsigned int)((macad>>24)&0xFF), + (unsigned int)((macad>>16)&0xFF), + (unsigned int)((macad>>8)&0xFF), + (unsigned int)((macad>>0)&0xFF)); + + + printf("Seting up Table Entry Right:\n"); + printf("src_port:%d\n",src_port); + printf("dst_port:%d\n",dst_port); + printf("src_ip:%s\n",src_ip); + printf("dst_ip:%s\n",dst_ip); + printf("src_mac:%s\n",src_mac); + printf("dst_mac:%s\n\n",dst_mac); + + eiger_back_ret_val=0; + eiger_back_message_length = sprintf(eiger_back_message,"setuptableentry %d %d %d %s %s %d %s %s %d",1,0,32,src_mac,src_ip,src_port,dst_mac,dst_ip,dst_port); + return EigerBackSendCMD(); +} + + + + +int RequestImages(){ + eiger_back_ret_val=0; + eiger_back_message_length = sprintf(eiger_back_message,"requestimages %d",0); + return EigerBackSendCMD(); +} + + + diff --git a/slsDetectorSoftware/eigerDetectorServer/bin/beb_debug b/slsDetectorSoftware/eigerDetectorServer/bin/beb_debug new file mode 100755 index 000000000..fe7f06f67 Binary files /dev/null and b/slsDetectorSoftware/eigerDetectorServer/bin/beb_debug differ diff --git a/slsDetectorSoftware/eigerDetectorServer/bin/feb_debug b/slsDetectorSoftware/eigerDetectorServer/bin/feb_debug new file mode 100755 index 000000000..51625242e Binary files /dev/null and b/slsDetectorSoftware/eigerDetectorServer/bin/feb_debug differ