server side done

This commit is contained in:
maliakal_d 2022-01-06 09:20:29 +01:00
parent 22c820771a
commit 1e309b67ef
7 changed files with 34 additions and 24 deletions

View File

@ -1492,6 +1492,8 @@ enum timingMode getTiming() {
/* configure mac */ /* configure mac */
int getNumberofUDPInterfaces() { return 1; }
void calcChecksum(udp_header *udp) { void calcChecksum(udp_header *udp) {
int count = IP_HEADER_SIZE; int count = IP_HEADER_SIZE;
long int sum = 0; long int sum = 0;

View File

@ -1500,6 +1500,7 @@ enum timingMode getTiming() {
} }
/* configure mac */ /* configure mac */
int getNumberofUDPInterfaces() { return 2; }
int getNumberofDestinations(int *retval) { int getNumberofDestinations(int *retval) {
#ifdef VIRTUAL #ifdef VIRTUAL

View File

@ -1299,6 +1299,8 @@ int getExtSignal(int signalIndex) {
/* configure mac */ /* configure mac */
int getNumberofUDPInterfaces() { return 1; }
void calcChecksum(mac_conf *mac, int sourceip, int destip) { void calcChecksum(mac_conf *mac, int sourceip, int destip) {
mac->ip.ip_ver = 0x4; mac->ip.ip_ver = 0x4;
mac->ip.ip_ihl = 0x5; mac->ip.ip_ihl = 0x5;

View File

@ -1157,6 +1157,8 @@ enum timingMode getTiming() {
/* configure mac */ /* configure mac */
int getNumberofUDPInterfaces() { return 1; }
void calcChecksum(udp_header *udp) { void calcChecksum(udp_header *udp) {
int count = IP_HEADER_SIZE; int count = IP_HEADER_SIZE;
long int sum = 0; long int sum = 0;

View File

@ -1719,6 +1719,8 @@ int getExtSignal(int signalIndex) {
} }
} }
int getNumberofUDPInterfaces() { return 1; }
int configureMAC() { int configureMAC() {
uint32_t srcip = udpDetails[0].srcip; uint32_t srcip = udpDetails[0].srcip;

View File

@ -387,8 +387,8 @@ void calcChecksum(mac_conf *mac, int sourceip, int destip);
#endif #endif
#if defined(JUNGFRAUD) || defined(GOTTHARD2D) #if defined(JUNGFRAUD) || defined(GOTTHARD2D)
void setNumberofUDPInterfaces(int val); void setNumberofUDPInterfaces(int val);
int getNumberofUDPInterfaces();
#endif #endif
int getNumberofUDPInterfaces();
#if defined(JUNGFRAUD) || defined(EIGERD) #if defined(JUNGFRAUD) || defined(EIGERD)
int getNumberofDestinations(int *retval); int getNumberofDestinations(int *retval);

View File

@ -4725,19 +4725,23 @@ void calculate_and_set_position() {
LOG(logERROR, (mess)); LOG(logERROR, (mess));
return; return;
} }
int maxy = maxydet;
// position does not change for gotthard2 (2 interfaces) // calculating new position
#ifdef JUNGFRAUD int numInterfaces = getNumberofUDPInterfaces();
maxy *= getNumberofUDPInterfaces(); int modulePorts[2] = {1, 1};
// position does change for eiger and jungfrau (2 interfaces)
#if defined(EIGERD)
modulePorts[1] = numInterfaces; // horz
#elif defined(JUNGFRAUD)
modulePorts[0] = numInterfaces; // vert
#endif #endif
int maxy = maxydet * modulePorts[0];
int pos[2] = {0, 0}; int pos[2] = {0, 0};
// row // row
pos[0] = (detectorId % maxy); pos[0] = (detectorId % maxy);
// col for horiz. udp ports // col for horiz. udp ports
pos[1] = (detectorId / maxy); pos[1] = (detectorId / maxy) * modulePorts[1];
#ifdef EIGERD
pos[1] *= 2;
#endif
LOG(logDEBUG, ("Setting Positions (%d,%d)\n", pos[0], pos[1])); LOG(logDEBUG, ("Setting Positions (%d,%d)\n", pos[0], pos[1]));
if (setDetectorPosition(pos) == FAIL) { if (setDetectorPosition(pos) == FAIL) {
ret = FAIL; ret = FAIL;
@ -4854,7 +4858,6 @@ int is_udp_configured() {
LOG(logWARNING, ("%s", configureMessage)); LOG(logWARNING, ("%s", configureMessage));
return FAIL; return FAIL;
} }
#if defined(JUNGFRAUD) || defined(GOTTHARD2D)
if (getNumberofUDPInterfaces() == 2) { if (getNumberofUDPInterfaces() == 2) {
if (udpDetails[i].srcip2 == 0) { if (udpDetails[i].srcip2 == 0) {
sprintf(configureMessage, sprintf(configureMessage,
@ -4881,7 +4884,6 @@ int is_udp_configured() {
return FAIL; return FAIL;
} }
} }
#endif
} }
return OK; return OK;
} }
@ -5320,7 +5322,16 @@ int set_num_interfaces(int file_des) {
LOG(logINFO, ("Setting number of interfaces: %d\n", arg)); LOG(logINFO, ("Setting number of interfaces: %d\n", arg));
#if !defined(JUNGFRAUD) && !defined(GOTTHARD2D) #if !defined(JUNGFRAUD) && !defined(GOTTHARD2D)
functionNotImplemented(); // fixed number of udp interfaces
int num_interfaces = getNumberofUDPInterfaces();
if (arg != num_interfaces) {
ret = FAIL;
sprintf(mess,
"Could not set number of interfaces. Invalid value: %d. Must "
"be %d\n",
arg, num_interfaces);
LOG(logERROR, (mess));
}
#else #else
// only set // only set
if (Server_VerifyLock() == OK) { if (Server_VerifyLock() == OK) {
@ -5380,12 +5391,9 @@ int get_num_interfaces(int file_des) {
int retval = -1; int retval = -1;
LOG(logDEBUG1, ("Getting number of udp interfaces\n")); LOG(logDEBUG1, ("Getting number of udp interfaces\n"));
#if !defined(JUNGFRAUD) && !defined(GOTTHARD2D)
retval = 1;
#else
// get only // get only
retval = getNumberofUDPInterfaces(); retval = getNumberofUDPInterfaces();
#endif
LOG(logDEBUG1, ("Number of udp interfaces retval: %u\n", retval)); LOG(logDEBUG1, ("Number of udp interfaces retval: %u\n", retval));
return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
} }
@ -6883,11 +6891,7 @@ int get_receiver_parameters(int file_des) {
// sending real detector parameters // sending real detector parameters
// udp interfaces // udp interfaces
#if defined(JUNGFRAUD) || defined(GOTTHARD2D)
i32 = getNumberofUDPInterfaces(); i32 = getNumberofUDPInterfaces();
#else
i32 = 1;
#endif
n += sendData(file_des, &i32, sizeof(i32), INT32); n += sendData(file_des, &i32, sizeof(i32), INT32);
if (n < 0) if (n < 0)
return printSocketReadError(); return printSocketReadError();
@ -9025,10 +9029,7 @@ int set_dest_udp_list(int file_des) {
} }
// if still 0, set defaults // if still 0, set defaults
int twoInterfaces = 0; int twoInterfaces = getNumberofUDPInterfaces() == 2 ? 1 : 0;
#if defined(JUNGFRAUD) || defined(GOTTHARD2D)
twoInterfaces = getNumberofUDPInterfaces() == 2 ? 1 : 0;
#endif
udpDetails[entry].srcport = DEFAULT_UDP_SRC_PORTNO; udpDetails[entry].srcport = DEFAULT_UDP_SRC_PORTNO;
if (udpDetails[entry].dstport == 0) { if (udpDetails[entry].dstport == 0) {
udpDetails[entry].dstport = udpDetails[entry].dstport =