mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 06:50:02 +02:00
wip
This commit is contained in:
parent
765e9895b9
commit
edbccd3661
Binary file not shown.
@ -10,8 +10,8 @@
|
||||
|
||||
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
|
||||
|
||||
struct BebInfo beb_infos[10];
|
||||
int bebInfoSize = 0;
|
||||
#define EMPTY_MAC_ADDRESS "00:00:00:00:00:00"
|
||||
#define EMPTY_IP_ADDRESS "000.000.000.000"
|
||||
|
||||
struct LocalLinkInterface ll_beb_local, *ll_beb;
|
||||
|
||||
@ -31,8 +31,6 @@ short Beb_bit_mode;
|
||||
int BEB_MMAP_SIZE = 0x1000;
|
||||
|
||||
int Beb_activated = 1;
|
||||
|
||||
uint32_t Beb_detid = 0;
|
||||
int Beb_top = 0;
|
||||
|
||||
uint64_t Beb_deactivatedNextFrameNumber = 0;
|
||||
@ -47,71 +45,8 @@ int Beb_deactivated_left_datastream = 1;
|
||||
int Beb_deactivated_right_datastream = 1;
|
||||
int Beb_deactivated_num_destinations = 1;
|
||||
|
||||
void BebInfo_BebInfo(struct BebInfo *bebInfo, unsigned int beb_num) {
|
||||
bebInfo->beb_number = beb_num;
|
||||
bebInfo->serial_address = 0;
|
||||
strcpy(bebInfo->src_mac_1GbE, "");
|
||||
strcpy(bebInfo->src_mac_10GbE, "");
|
||||
strcpy(bebInfo->src_ip_1GbE, "");
|
||||
strcpy(bebInfo->src_ip_10GbE, "");
|
||||
bebInfo->src_port_1GbE = bebInfo->src_port_10GbE = 0;
|
||||
}
|
||||
|
||||
int BebInfo_SetSerialAddress(struct BebInfo *bebInfo, unsigned int a) {
|
||||
// address pre shifted
|
||||
if (a > 0xff)
|
||||
return 0;
|
||||
bebInfo->serial_address = 0x04000000 | ((a & 0xff) << 16);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int BebInfo_SetHeaderInfo(struct BebInfo *bebInfo, int ten_gig, char *src_mac,
|
||||
char *src_ip, unsigned int src_port) {
|
||||
if (ten_gig) {
|
||||
strcpy(bebInfo->src_mac_10GbE, src_mac);
|
||||
strcpy(bebInfo->src_ip_10GbE, src_ip);
|
||||
bebInfo->src_port_10GbE = src_port;
|
||||
} else {
|
||||
strcpy(bebInfo->src_mac_1GbE, src_mac);
|
||||
strcpy(bebInfo->src_ip_1GbE, src_ip);
|
||||
bebInfo->src_port_1GbE = src_port;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned int BebInfo_GetBebNumber(struct BebInfo *bebInfo) {
|
||||
return bebInfo->beb_number;
|
||||
}
|
||||
unsigned int BebInfo_GetSerialAddress(struct BebInfo *bebInfo) {
|
||||
return bebInfo->serial_address;
|
||||
}
|
||||
char *BebInfo_GetSrcMAC(struct BebInfo *bebInfo, int ten_gig) {
|
||||
return ten_gig ? bebInfo->src_mac_10GbE : bebInfo->src_mac_1GbE;
|
||||
}
|
||||
char *BebInfo_GetSrcIP(struct BebInfo *bebInfo, int ten_gig) {
|
||||
return ten_gig ? bebInfo->src_ip_10GbE : bebInfo->src_ip_1GbE;
|
||||
}
|
||||
unsigned int BebInfo_GetSrcPort(struct BebInfo *bebInfo, int ten_gig) {
|
||||
return ten_gig ? bebInfo->src_port_10GbE : bebInfo->src_port_1GbE;
|
||||
}
|
||||
|
||||
void BebInfo_Print(struct BebInfo *bebInfo) {
|
||||
LOG(logINFO,
|
||||
("%d) Beb Info:\n"
|
||||
"\tSerial Add: 0x%x\n"
|
||||
"\tMAC 1GbE: %s\n"
|
||||
"\tIP 1GbE: %s\n"
|
||||
"\tPort 1GbE: %d\n"
|
||||
"\tMAC 10GbE: %s\n"
|
||||
"\tIP 10GbE: %s\n"
|
||||
"\tPort 10GbE: %d\n",
|
||||
bebInfo->beb_number, bebInfo->serial_address, bebInfo->src_mac_1GbE,
|
||||
bebInfo->src_ip_1GbE, bebInfo->src_port_1GbE, bebInfo->src_mac_10GbE,
|
||||
bebInfo->src_ip_10GbE, bebInfo->src_port_10GbE));
|
||||
}
|
||||
|
||||
void Beb_Beb(int id) {
|
||||
Beb_detid = id;
|
||||
void Beb_Beb() {
|
||||
Beb_send_ndata = 0;
|
||||
Beb_send_buffer_size = 1026;
|
||||
Beb_send_data_raw =
|
||||
@ -144,19 +79,149 @@ void Beb_Beb(int id) {
|
||||
{0x00, 0x00}, //{0x00, 0x11},
|
||||
{0x00, 0x00}};
|
||||
|
||||
if (!Beb_InitBebInfos())
|
||||
exit(1);
|
||||
|
||||
LOG(logDEBUG1, ("Printing Beb infos:\n"));
|
||||
for (unsigned int i = 1; i < bebInfoSize; i++)
|
||||
BebInfo_Print(&beb_infos[i]);
|
||||
Beb_ClearHeaderData(0);
|
||||
Beb_ClearHeaderData(1);
|
||||
|
||||
Beb_bit_mode = 4;
|
||||
}
|
||||
|
||||
// ll_beb = &ll_beb_local;
|
||||
// Local_LocalLinkInterface(ll_beb,XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR);
|
||||
void Beb_ClearHeaderData(int ten_gig) {
|
||||
for (int i = 0; i < MAX_UDP_DESTINATION; ++i) {
|
||||
if (!Beb_SetUpUDPHeader(i, ten_gig, EMPTY_MAC_ADDRESS, EMPTY_IP_ADDRESS, 0, EMPTY_MAC_ADDRESS, EMPTY_IP_ADDRESS, 0)) {
|
||||
LOG(logERROR, ("Could not clear header data for entry %d (tengiga:%d)\n", i, ten_gig));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Beb_SetByteOrder();
|
||||
|
||||
int Beb_SetUpUDPHeader(unsigned int header_number, int ten_gig, char *src_mac, char *src_ip, unsigned int src_port, char *dst_mac, char *dst_ip, unsigned int dst_port) {
|
||||
|
||||
if (!Beb_activated)
|
||||
return 1;
|
||||
|
||||
u_int32_t bram_phy_addr;
|
||||
u_int32_t *csp0base = 0;
|
||||
if (ten_gig)
|
||||
bram_phy_addr = 0xC6002000;
|
||||
else
|
||||
bram_phy_addr = 0xC6001000;
|
||||
|
||||
if (!Beb_SetHeaderData(src_mac, src_ip, src_port, dst_mac, dst_ip, dst_port))
|
||||
return 0;
|
||||
|
||||
int fd = Beb_open(&csp0base, bram_phy_addr);
|
||||
if (fd < 0) {
|
||||
LOG(logERROR, ("Set up UDP Header FAIL\n"));
|
||||
} else {
|
||||
// read data
|
||||
memcpy(csp0base + header_number * 16, &udp_header, sizeof(udp_header));
|
||||
// close file pointer
|
||||
Beb_close(fd, csp0base);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Beb_SetHeaderData(char *src_mac, char *src_ip, unsigned int src_port, char *dst_mac, char *dst_ip, unsigned int dst_port) {
|
||||
|
||||
if (!Beb_SetMAC(src_mac, &(udp_header.src_mac[0])))
|
||||
return 0;
|
||||
LOG(logINFO, ("Setting Source MAC to %s\n", src_mac));
|
||||
if (!Beb_SetIP(src_ip, &(udp_header.src_ip[0])))
|
||||
return 0;
|
||||
LOG(logINFO, ("Setting Source IP to %s\n", src_ip));
|
||||
if (!Beb_SetPortNumber(src_port, &(udp_header.src_port[0])))
|
||||
return 0;
|
||||
LOG(logINFO, ("Setting Source port to %d\n", src_port));
|
||||
|
||||
if (!Beb_SetMAC(dst_mac, &(udp_header.dst_mac[0])))
|
||||
return 0;
|
||||
LOG(logINFO, ("Setting Destination MAC to %s\n", dst_mac));
|
||||
if (!Beb_SetIP(dst_ip, &(udp_header.dst_ip[0])))
|
||||
return 0;
|
||||
LOG(logINFO, ("Setting Destination IP to %s\n", dst_ip));
|
||||
if (!Beb_SetPortNumber(dst_port, &(udp_header.dst_port[0])))
|
||||
return 0;
|
||||
LOG(logINFO, ("Setting Destination port to %d\n", dst_port));
|
||||
|
||||
Beb_AdjustIPChecksum(&udp_header);
|
||||
|
||||
unsigned int *base_ptr = (unsigned int *)&udp_header;
|
||||
unsigned int num_words = (sizeof(struct udp_header_type) + 3) / 4;
|
||||
for (unsigned int i = 0; i < num_words; i++)
|
||||
Beb_send_data[i + 2] = base_ptr[i];
|
||||
for (unsigned int i = num_words; i < 16; i++)
|
||||
Beb_send_data[i + 2] = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int Beb_SetMAC(char *mac, uint8_t *dst_ptr) {
|
||||
char macVal[50];
|
||||
strcpy(macVal, mac);
|
||||
|
||||
int i = 0;
|
||||
char *pch = strtok(macVal, ":");
|
||||
while (pch != NULL) {
|
||||
if (strlen(pch) != 2) {
|
||||
LOG(logERROR, ("Error: in mac address -> %s\n", macVal));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int itemp;
|
||||
sscanf(pch, "%x", &itemp);
|
||||
dst_ptr[i] = (u_int8_t)itemp;
|
||||
pch = strtok(NULL, ":");
|
||||
i++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Beb_SetIP(char *ip, uint8_t *dst_ptr) {
|
||||
char ipVal[50];
|
||||
strcpy(ipVal, ip);
|
||||
int i = 0;
|
||||
char *pch = strtok(ipVal, ".");
|
||||
while (pch != NULL) {
|
||||
if (((i != 3) && ((strlen(pch) > 3) || (strlen(pch) < 1))) ||
|
||||
((i == 3) && ((strlen(pch) < 1) || (strlen(pch) > 3)))) {
|
||||
LOG(logERROR, ("Error: in ip address -> %s\n", ipVal));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int itemp;
|
||||
sscanf(pch, "%d", &itemp);
|
||||
dst_ptr[i] = (u_int8_t)itemp;
|
||||
pch = strtok(NULL, ".");
|
||||
i++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Beb_SetPortNumber(unsigned int port_number, uint8_t *dst_ptr) {
|
||||
dst_ptr[0] = (port_number >> 8) & 0xff;
|
||||
dst_ptr[1] = port_number & 0xff;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Beb_AdjustIPChecksum(struct udp_header_type *ip) {
|
||||
unsigned char *cptr = (unsigned char *)ip->ver_headerlen;
|
||||
|
||||
ip->ip_header_checksum[0] = 0;
|
||||
ip->ip_header_checksum[1] = 0;
|
||||
ip->total_length[0] = 0;
|
||||
ip->total_length[1] = 28; // IP + UDP Header Length
|
||||
|
||||
// calc ip checksum
|
||||
unsigned int ip_checksum = 0;
|
||||
for (unsigned int i = 0; i < 10; i++) {
|
||||
ip_checksum += ((cptr[2 * i] << 8) + (cptr[2 * i + 1]));
|
||||
if (ip_checksum & 0x00010000)
|
||||
ip_checksum = (ip_checksum + 1) & 0x0000ffff;
|
||||
}
|
||||
|
||||
ip->ip_header_checksum[0] = (ip_checksum >> 8) & 0xff;
|
||||
ip->ip_header_checksum[1] = ip_checksum & 0xff;
|
||||
}
|
||||
|
||||
void Beb_GetModuleConfiguration(int *master, int *top, int *normal) {
|
||||
@ -817,301 +882,6 @@ void Beb_ResetFrameNumber() {
|
||||
}
|
||||
}
|
||||
|
||||
void Beb_ClearBebInfos() { bebInfoSize = 0; }
|
||||
|
||||
int Beb_InitBebInfos() { // file name at some point
|
||||
Beb_ClearBebInfos();
|
||||
|
||||
struct BebInfo b0;
|
||||
BebInfo_BebInfo(&b0, 0);
|
||||
if (BebInfo_SetSerialAddress(
|
||||
&b0,
|
||||
0xff)) { // all bebs for reset and possibly get request data?
|
||||
beb_infos[bebInfoSize] = b0;
|
||||
bebInfoSize++;
|
||||
}
|
||||
|
||||
int i0 = Beb_detid, i1 = 0;
|
||||
if (Beb_GetBebInfoIndex(i0)) {
|
||||
LOG(logERROR,
|
||||
("cant add beb. adding beb %d, beb number %d already added.\n",
|
||||
Beb_detid, i0));
|
||||
exit(0);
|
||||
}
|
||||
struct BebInfo b1;
|
||||
BebInfo_BebInfo(&b1, i0);
|
||||
BebInfo_SetSerialAddress(&b1, i1);
|
||||
BebInfo_SetHeaderInfo(&b1, 0, (char *)"00:50:c2:46:d9:34",
|
||||
(char *)"129.129.205.78", 42000 + i0);
|
||||
BebInfo_SetHeaderInfo(&b1, 1, (char *)"00:50:c2:46:d9:35",
|
||||
(char *)"10.0.26.1", 52000 + i0);
|
||||
beb_infos[bebInfoSize] = b1;
|
||||
bebInfoSize++;
|
||||
|
||||
/*
|
||||
//loop through file to fill vector.
|
||||
BebInfo* b = new BebInfo(26);
|
||||
b->SetSerialAddress(0); //0xc4000000
|
||||
b->SetHeaderInfo(0,"00:50:c2:46:d9:34","129.129.205.78",42000 + 26); // 1
|
||||
GbE, ip address can be acquire from the network "arp"
|
||||
b->SetHeaderInfo(1,"00:50:c2:46:d9:35","10.0.26.1",52000 + 26); //10 GbE,
|
||||
everything calculable/setable beb_infos.push_back(b);
|
||||
*/
|
||||
|
||||
return Beb_CheckSourceStuffBebInfo();
|
||||
}
|
||||
|
||||
int Beb_SetBebSrcHeaderInfos(unsigned int beb_number, int ten_gig,
|
||||
char *src_mac, char *src_ip,
|
||||
unsigned int src_port) {
|
||||
// so that the values can be reset externally for now....
|
||||
|
||||
unsigned int i = 1; /*Beb_GetBebInfoIndex(beb_number);*/
|
||||
/******* if (!i) return 0;****************************/ // i must be
|
||||
// greater than
|
||||
// 0, zero is
|
||||
// the global
|
||||
// send
|
||||
BebInfo_SetHeaderInfo(&beb_infos[i], ten_gig, src_mac, src_ip, src_port);
|
||||
|
||||
LOG(logINFO, ("Printing Beb info number (%d) :\n", i));
|
||||
BebInfo_Print(&beb_infos[i]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Beb_CheckSourceStuffBebInfo() {
|
||||
for (unsigned int i = 1; i < bebInfoSize;
|
||||
i++) { // header stuff always starts from 1
|
||||
if (!Beb_SetHeaderData(BebInfo_GetBebNumber(&beb_infos[i]), 0,
|
||||
"00:00:00:00:00:00", "10.0.0.1", 20000) ||
|
||||
!Beb_SetHeaderData(BebInfo_GetBebNumber(&beb_infos[i]), 1,
|
||||
"00:00:00:00:00:00", "10.0.0.1", 20000)) {
|
||||
LOG(logINFO, ("Error in BebInfo for module number %d.\n",
|
||||
BebInfo_GetBebNumber(&beb_infos[i])));
|
||||
BebInfo_Print(&beb_infos[i]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned int Beb_GetBebInfoIndex(unsigned int beb_numb) {
|
||||
for (unsigned int i = 1; i < bebInfoSize; i++)
|
||||
if (beb_numb == BebInfo_GetBebNumber(&beb_infos[i])) {
|
||||
LOG(logDEBUG1,
|
||||
("*****found beb index:%d, for beb number:%d\n", i, beb_numb));
|
||||
return i;
|
||||
}
|
||||
LOG(logDEBUG1, ("*****Returning 0\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Beb_WriteTo(unsigned int index) {
|
||||
|
||||
if (!Beb_activated)
|
||||
return 1;
|
||||
|
||||
if (index >= bebInfoSize) {
|
||||
LOG(logERROR, ("WriteTo index error.\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
Beb_send_data_raw[0] =
|
||||
0x90000000 | BebInfo_GetSerialAddress(&beb_infos[index]);
|
||||
if (Local_Write(ll_beb, 4, Beb_send_data_raw) != 4)
|
||||
return 0;
|
||||
|
||||
Beb_send_data_raw[0] = 0xc0000000;
|
||||
if ((Beb_send_ndata + 1) * 4 !=
|
||||
Local_Write(ll_beb, (Beb_send_ndata + 1) * 4, Beb_send_data_raw))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Beb_SwapDataFun(int little_endian, unsigned int n, unsigned int *d) {
|
||||
if (little_endian)
|
||||
for (unsigned int i = 0; i < n; i++)
|
||||
d[i] = (((d[i] & 0xff) << 24) | ((d[i] & 0xff00) << 8) |
|
||||
((d[i] & 0xff0000) >> 8) |
|
||||
((d[i] & 0xff000000) >> 24)); // little_endian
|
||||
else
|
||||
for (unsigned int i = 0; i < n; i++)
|
||||
d[i] = (((d[i] & 0xffff) << 16) | ((d[i] & 0xffff0000) >> 16));
|
||||
}
|
||||
|
||||
int Beb_SetByteOrder() { return 1; }
|
||||
|
||||
int Beb_SetUpUDPHeader(unsigned int beb_number, int ten_gig,
|
||||
unsigned int header_number, char *dst_mac, char *dst_ip,
|
||||
unsigned int dst_port) {
|
||||
|
||||
if (!Beb_activated)
|
||||
return 1;
|
||||
|
||||
u_int32_t bram_phy_addr;
|
||||
u_int32_t *csp0base = 0;
|
||||
/*u_int32_t* bram_ptr = NULL;*/
|
||||
if (ten_gig)
|
||||
bram_phy_addr = 0xC6002000;
|
||||
else
|
||||
bram_phy_addr = 0xC6001000;
|
||||
|
||||
if (!Beb_SetHeaderData(beb_number, ten_gig, dst_mac, dst_ip, dst_port))
|
||||
return 0;
|
||||
|
||||
int fd = Beb_open(&csp0base, bram_phy_addr);
|
||||
if (fd < 0) {
|
||||
LOG(logERROR, ("Set up UDP Header FAIL\n"));
|
||||
} else {
|
||||
// read data
|
||||
memcpy(csp0base + header_number * 16, &udp_header, sizeof(udp_header));
|
||||
// close file pointer
|
||||
Beb_close(fd, csp0base);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Beb_SetHeaderData(unsigned int beb_number, int ten_gig, char *dst_mac,
|
||||
char *dst_ip, unsigned int dst_port) {
|
||||
unsigned int i = 1; /*Beb_GetBebInfoIndex(beb_number);*/
|
||||
/***********************************if (!i) return 0;
|
||||
* *************************************///i must be greater than 0, zero is the global send
|
||||
return Beb_SetHeaderData1(BebInfo_GetSrcMAC(&beb_infos[i], ten_gig),
|
||||
BebInfo_GetSrcIP(&beb_infos[i], ten_gig),
|
||||
BebInfo_GetSrcPort(&beb_infos[i], ten_gig),
|
||||
dst_mac, dst_ip, dst_port);
|
||||
}
|
||||
|
||||
int Beb_SetHeaderData1(char *src_mac, char *src_ip, unsigned int src_port,
|
||||
char *dst_mac, char *dst_ip, unsigned int dst_port) {
|
||||
/* example header*/
|
||||
// static unsigned int* word_ptr = new unsigned int [16];
|
||||
/*static*/
|
||||
/*
|
||||
udp_header_type udp_header = {
|
||||
{0x00, 0x50, 0xc5, 0xb2, 0xcb, 0x46}, // DST MAC
|
||||
{0x00, 0x50, 0xc2, 0x46, 0xd9, 0x02}, // SRC MAC
|
||||
{0x08, 0x00},
|
||||
{0x45},
|
||||
{0x00},
|
||||
{0x00, 0x00},
|
||||
{0x00, 0x00},
|
||||
{0x40},
|
||||
{0x00},
|
||||
{0xff},
|
||||
{0x11},
|
||||
{0x00, 0x00},
|
||||
{129, 205, 205, 128}, // Src IP
|
||||
{129, 205, 205, 122}, // Dst IP
|
||||
{0x0f, 0xa1},
|
||||
{0x13, 0x89},
|
||||
{0x00, 0x00}, //{0x00, 0x11},
|
||||
{0x00, 0x00}
|
||||
};
|
||||
*/
|
||||
|
||||
if (!Beb_SetMAC(src_mac, &(udp_header.src_mac[0])))
|
||||
return 0;
|
||||
LOG(logINFO, ("Setting Source MAC to %s\n", src_mac));
|
||||
if (!Beb_SetIP(src_ip, &(udp_header.src_ip[0])))
|
||||
return 0;
|
||||
LOG(logINFO, ("Setting Source IP to %s\n", src_ip));
|
||||
if (!Beb_SetPortNumber(src_port, &(udp_header.src_port[0])))
|
||||
return 0;
|
||||
LOG(logINFO, ("Setting Source port to %d\n", src_port));
|
||||
|
||||
if (!Beb_SetMAC(dst_mac, &(udp_header.dst_mac[0])))
|
||||
return 0;
|
||||
LOG(logINFO, ("Setting Destination MAC to %s\n", dst_mac));
|
||||
if (!Beb_SetIP(dst_ip, &(udp_header.dst_ip[0])))
|
||||
return 0;
|
||||
LOG(logINFO, ("Setting Destination IP to %s\n", dst_ip));
|
||||
if (!Beb_SetPortNumber(dst_port, &(udp_header.dst_port[0])))
|
||||
return 0;
|
||||
LOG(logINFO, ("Setting Destination port to %d\n", dst_port));
|
||||
|
||||
Beb_AdjustIPChecksum(&udp_header);
|
||||
|
||||
unsigned int *base_ptr = (unsigned int *)&udp_header;
|
||||
unsigned int num_words = (sizeof(struct udp_header_type) + 3) / 4;
|
||||
for (unsigned int i = 0; i < num_words; i++)
|
||||
Beb_send_data[i + 2] = base_ptr[i];
|
||||
for (unsigned int i = num_words; i < 16; i++)
|
||||
Beb_send_data[i + 2] = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Beb_SetMAC(char *mac, uint8_t *dst_ptr) {
|
||||
char macVal[50];
|
||||
strcpy(macVal, mac);
|
||||
|
||||
int i = 0;
|
||||
char *pch = strtok(macVal, ":");
|
||||
while (pch != NULL) {
|
||||
if (strlen(pch) != 2) {
|
||||
LOG(logERROR, ("Error: in mac address -> %s\n", macVal));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int itemp;
|
||||
sscanf(pch, "%x", &itemp);
|
||||
dst_ptr[i] = (u_int8_t)itemp;
|
||||
pch = strtok(NULL, ":");
|
||||
i++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Beb_SetIP(char *ip, uint8_t *dst_ptr) {
|
||||
char ipVal[50];
|
||||
strcpy(ipVal, ip);
|
||||
int i = 0;
|
||||
char *pch = strtok(ipVal, ".");
|
||||
while (pch != NULL) {
|
||||
if (((i != 3) && ((strlen(pch) > 3) || (strlen(pch) < 1))) ||
|
||||
((i == 3) && ((strlen(pch) < 1) || (strlen(pch) > 3)))) {
|
||||
LOG(logERROR, ("Error: in ip address -> %s\n", ipVal));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int itemp;
|
||||
sscanf(pch, "%d", &itemp);
|
||||
dst_ptr[i] = (u_int8_t)itemp;
|
||||
pch = strtok(NULL, ".");
|
||||
i++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Beb_SetPortNumber(unsigned int port_number, uint8_t *dst_ptr) {
|
||||
dst_ptr[0] = (port_number >> 8) & 0xff;
|
||||
dst_ptr[1] = port_number & 0xff;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Beb_AdjustIPChecksum(struct udp_header_type *ip) {
|
||||
unsigned char *cptr = (unsigned char *)ip->ver_headerlen;
|
||||
|
||||
ip->ip_header_checksum[0] = 0;
|
||||
ip->ip_header_checksum[1] = 0;
|
||||
ip->total_length[0] = 0;
|
||||
ip->total_length[1] = 28; // IP + UDP Header Length
|
||||
|
||||
// calc ip checksum
|
||||
unsigned int ip_checksum = 0;
|
||||
for (unsigned int i = 0; i < 10; i++) {
|
||||
ip_checksum += ((cptr[2 * i] << 8) + (cptr[2 * i + 1]));
|
||||
if (ip_checksum & 0x00010000)
|
||||
ip_checksum = (ip_checksum + 1) & 0x0000ffff;
|
||||
}
|
||||
|
||||
ip->ip_header_checksum[0] = (ip_checksum >> 8) & 0xff;
|
||||
ip->ip_header_checksum[1] = ip_checksum & 0xff;
|
||||
}
|
||||
|
||||
int Beb_SetUpTransferParameters(short the_bit_mode) {
|
||||
if (the_bit_mode != 4 && the_bit_mode != 8 && the_bit_mode != 16 &&
|
||||
the_bit_mode != 32)
|
||||
@ -1560,7 +1330,7 @@ int Beb_SetNumberofDestinations(int value) {
|
||||
}
|
||||
if (!Beb_activated) {
|
||||
Beb_deactivated_num_destinations = value;
|
||||
return FAIL;
|
||||
return OK;
|
||||
}
|
||||
u_int32_t offset[2] = {LEFT_OFFSET + NUM_UDP_DEST_OFFSET,
|
||||
RIGHT_OFFSET + NUM_UDP_DEST_OFFSET};
|
||||
|
@ -4,34 +4,14 @@
|
||||
#include "slsDetectorServer_defs.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
struct BebInfo {
|
||||
unsigned int beb_number;
|
||||
unsigned int serial_address;
|
||||
char src_mac_1GbE[50];
|
||||
char src_mac_10GbE[50];
|
||||
char src_ip_1GbE[50];
|
||||
char src_ip_10GbE[50];
|
||||
unsigned int src_port_1GbE;
|
||||
unsigned int src_port_10GbE;
|
||||
};
|
||||
|
||||
void BebInfo_BebInfo(struct BebInfo *bebInfo, unsigned int beb_num);
|
||||
void BebInfo_BebDstInfo(struct BebInfo *bebInfo, unsigned int beb_num);
|
||||
int BebInfo_SetSerialAddress(struct BebInfo *bebInfo, unsigned int add);
|
||||
int BebInfo_SetHeaderInfo(
|
||||
struct BebInfo *bebInfo, int ten_gig, char *src_mac, char *src_ip,
|
||||
unsigned int
|
||||
src_port); // src_port fixed 42000+beb_number or 52000 + beb_number);
|
||||
unsigned int BebInfo_GetBebNumber(struct BebInfo *bebInfo);
|
||||
unsigned int BebInfo_GetSerialAddress(struct BebInfo *bebInfo);
|
||||
char *BebInfo_GetSrcMAC(struct BebInfo *bebInfo, int ten_gig);
|
||||
char *BebInfo_GetSrcIP(struct BebInfo *bebInfo, int ten_gig);
|
||||
unsigned int BebInfo_GetSrcPort(struct BebInfo *bebInfo, int ten_gig);
|
||||
void BebInfo_Print(struct BebInfo *bebInfo);
|
||||
void Beb_ClearBebInfos();
|
||||
int Beb_InitBebInfos();
|
||||
int Beb_CheckSourceStuffBebInfo();
|
||||
unsigned int Beb_GetBebInfoIndex(unsigned int beb_numb);
|
||||
void Beb_Beb();
|
||||
void Beb_ClearHeaderData(int ten_gig);
|
||||
int Beb_SetUpUDPHeader(unsigned int header_number, int ten_gig, char *src_mac, char *src_ip, unsigned int src_port, char *dst_mac, char *dst_ip, unsigned int dst_port);
|
||||
int Beb_SetHeaderData(char *src_mac, char *src_ip, unsigned int src_port, char *dst_mac, char *dst_ip, unsigned int dst_port);
|
||||
int Beb_SetMAC(char *mac, uint8_t *dst_ptr);
|
||||
int Beb_SetIP(char *ip, uint8_t *dst_ptr);
|
||||
int Beb_SetPortNumber(unsigned int port_number, uint8_t *dst_ptr);
|
||||
void Beb_AdjustIPChecksum(struct udp_header_type *ip);
|
||||
|
||||
void Beb_GetModuleConfiguration(int *master, int *top, int *normal);
|
||||
int Beb_IsTransmitting(int *retval, int tengiga, int waitForDelay);
|
||||
@ -44,7 +24,6 @@ int Beb_GetActivate(int *retval);
|
||||
int Beb_SetDataStream(enum portPosition port, int enable);
|
||||
int Beb_GetDataStream(enum portPosition port, int *retval);
|
||||
int Beb_Set32bitOverflow(int val);
|
||||
|
||||
int Beb_GetTenGigaFlowControl();
|
||||
int Beb_SetTenGigaFlowControl(int value);
|
||||
int Beb_GetTransmissionDelayFrame();
|
||||
@ -56,39 +35,13 @@ int Beb_SetTransmissionDelayRight(int value);
|
||||
|
||||
u_int32_t Beb_GetFirmwareRevision();
|
||||
u_int32_t Beb_GetFirmwareSoftwareAPIVersion();
|
||||
|
||||
void Beb_ResetFrameNumber();
|
||||
int Beb_WriteTo(unsigned int index);
|
||||
int Beb_SetMAC(char *mac, uint8_t *dst_ptr);
|
||||
int Beb_SetIP(char *ip, uint8_t *dst_ptr);
|
||||
int Beb_SetPortNumber(unsigned int port_number, uint8_t *dst_ptr);
|
||||
void Beb_AdjustIPChecksum(struct udp_header_type *ip);
|
||||
|
||||
int Beb_SetHeaderData(unsigned int beb_number, int ten_gig, char *dst_mac,
|
||||
char *dst_ip, unsigned int dst_port);
|
||||
int Beb_SetHeaderData1(char *src_mac, char *src_ip, unsigned int src_port,
|
||||
char *dst_mac, char *dst_ip, unsigned int dst_port);
|
||||
|
||||
void Beb_SwapDataFun(int little_endian, unsigned int n, unsigned int *d);
|
||||
int Beb_SetByteOrder();
|
||||
void Beb_Beb();
|
||||
int Beb_SetBebSrcHeaderInfos(unsigned int beb_number, int ten_gig,
|
||||
char *src_mac, char *src_ip,
|
||||
unsigned int src_port);
|
||||
int Beb_SetUpUDPHeader(unsigned int beb_number, int ten_gig,
|
||||
unsigned int header_number, char *dst_mac, char *dst_ip,
|
||||
unsigned int dst_port);
|
||||
|
||||
int Beb_StopAcquisition();
|
||||
int Beb_SetUpTransferParameters(short the_bit_mode);
|
||||
/*int Beb_RequestNImages(unsigned int beb_number, unsigned int left_right, int
|
||||
* ten_gig, unsigned int dst_number, unsigned int nimages, int
|
||||
* test_just_send_out_packets_no_wait=0); //all images go to the same
|
||||
* destination!*/
|
||||
int Beb_StopAcquisition();
|
||||
int Beb_RequestNImages(int ten_gig, unsigned int nimages,
|
||||
int test_just_send_out_packets_no_wait);
|
||||
|
||||
int Beb_GetBebFPGATemp();
|
||||
|
||||
void Beb_SetDetectorNumber(uint32_t detid);
|
||||
int Beb_SetQuad(int value);
|
||||
int Beb_GetQuad();
|
||||
@ -96,9 +49,7 @@ int *Beb_GetDetectorPosition();
|
||||
int Beb_SetDetectorPosition(int pos[]);
|
||||
int Beb_SetNextFrameNumber(uint64_t value);
|
||||
int Beb_GetNextFrameNumber(uint64_t *retval, int tengigaEnable);
|
||||
|
||||
void Beb_SetPartialReadout(int value);
|
||||
|
||||
int Beb_GetNumberofDestinations(int *retval);
|
||||
int Beb_SetNumberofDestinations(int value);
|
||||
|
||||
|
Binary file not shown.
@ -354,7 +354,7 @@ void initControlServer() {
|
||||
sharedMemory_unlockLocalLink();
|
||||
LOG(logDEBUG1, ("Control server: FEB Initialization done\n"));
|
||||
Beb_SetTopVariable(top);
|
||||
Beb_Beb(detid);
|
||||
Beb_Beb();
|
||||
Beb_SetDetectorNumber(getDetectorNumber());
|
||||
LOG(logDEBUG1, ("Control server: BEB Initialization done\n"));
|
||||
#endif
|
||||
@ -1535,7 +1535,7 @@ int configureMAC() {
|
||||
|
||||
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||
|
||||
for (int iRxEntry = 0; iRxEntry != numUdpDestinations; ++iRxEntry) {
|
||||
for (int iRxEntry = 0; iRxEntry != MAX_UDP_DESTINATION; ++iRxEntry) {
|
||||
uint32_t srcip = udpDetails[iRxEntry].srcip;
|
||||
uint32_t dstip = udpDetails[iRxEntry].dstip;
|
||||
uint64_t srcmac = udpDetails[iRxEntry].srcmac;
|
||||
@ -1551,16 +1551,18 @@ int configureMAC() {
|
||||
getIpAddressinString(src_ip, srcip);
|
||||
getIpAddressinString(dst_ip, dstip);
|
||||
|
||||
LOG(logINFOBLUE, ("\tEntry %d\n", iRxEntry));
|
||||
LOG(logINFO,
|
||||
("\tSource IP : %s\n"
|
||||
"\tSource MAC : %s\n"
|
||||
"\tSource Port : %d\n"
|
||||
"\tDest IP : %s\n"
|
||||
"\tDest MAC : %s\n"
|
||||
"\tDest Port : %d\n"
|
||||
"\tDest Port2 : %d\n",
|
||||
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport, dstport2));
|
||||
if (iRxEntry <= numUdpDestinations) {
|
||||
LOG(logINFOBLUE, ("\tEntry %d\n", iRxEntry));
|
||||
LOG(logINFO,
|
||||
("\tSource IP : %s\n"
|
||||
"\tSource MAC : %s\n"
|
||||
"\tSource Port : %d\n"
|
||||
"\tDest IP : %s\n"
|
||||
"\tDest MAC : %s\n"
|
||||
"\tDest Port : %d\n"
|
||||
"\tDest Port2 : %d\n",
|
||||
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport, dstport2));
|
||||
}
|
||||
|
||||
#ifdef VIRTUAL
|
||||
if (setUDPDestinationDetails(iRxEntry, 0, dst_ip, dstport) == FAIL) {
|
||||
@ -1583,10 +1585,7 @@ int configureMAC() {
|
||||
if (!top)
|
||||
dst_port = dstport2;
|
||||
|
||||
if (Beb_SetBebSrcHeaderInfos(beb_num, send_to_ten_gig, src_mac, src_ip,
|
||||
srcport) &&
|
||||
Beb_SetUpUDPHeader(beb_num, send_to_ten_gig, iRxEntry, dst_mac,
|
||||
dst_ip, dst_port)) {
|
||||
if (Beb_SetUpUDPHeader(iRxEntry, send_to_ten_gig, src_mac, src_ip, srcport, dst_mac, dst_ip, dst_port)) {
|
||||
LOG(logDEBUG1, ("\tset up left ok\n"));
|
||||
} else {
|
||||
return FAIL;
|
||||
@ -1596,12 +1595,8 @@ int configureMAC() {
|
||||
if (!top)
|
||||
dst_port = dstport;
|
||||
|
||||
if (Beb_SetBebSrcHeaderInfos(beb_num, send_to_ten_gig, src_mac, src_ip,
|
||||
srcport) &&
|
||||
Beb_SetUpUDPHeader(beb_num, send_to_ten_gig,
|
||||
iRxEntry + MAX_UDP_DESTINATION, dst_mac, dst_ip,
|
||||
dst_port)) {
|
||||
LOG(logDEBUG1, (" set up right ok\n"));
|
||||
if (Beb_SetUpUDPHeader(iRxEntry + MAX_UDP_DESTINATION, send_to_ten_gig, src_mac, src_ip, srcport, dst_mac, dst_ip, dst_port)) {
|
||||
LOG(logDEBUG1, ("\tset up right ok\n"));
|
||||
} else {
|
||||
return FAIL;
|
||||
}
|
||||
@ -1722,6 +1717,9 @@ int enableTenGigabitEthernet(int val) {
|
||||
send_to_ten_gig = 1;
|
||||
else
|
||||
send_to_ten_gig = 0;
|
||||
#ifndef VIRTUAL
|
||||
Beb_ClearHeaderData(send_to_ten_gig == 0 ? 1 : 0);
|
||||
#endif
|
||||
}
|
||||
return send_to_ten_gig;
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1419,6 +1419,9 @@ void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip,
|
||||
// total length is redefined in firmware
|
||||
|
||||
calcChecksum(udp);
|
||||
if (iRxEntry <= numUdpDestinations) {
|
||||
LOG(logINFO, ("\tIP checksum is 0x%lx\n", udp->ip_checksum));
|
||||
}
|
||||
}
|
||||
|
||||
void calcChecksum(udp_header *udp) {
|
||||
@ -1449,7 +1452,6 @@ void calcChecksum(udp_header *udp) {
|
||||
sum = (sum & 0xffff) + (sum >> 16); // Fold 32-bit sum to 16 bits
|
||||
long int checksum = sum & 0xffff;
|
||||
checksum += UDP_IP_HEADER_LENGTH_BYTES;
|
||||
LOG(logINFO, ("\tIP checksum is 0x%lx\n", checksum));
|
||||
udp->ip_checksum = checksum;
|
||||
}
|
||||
|
||||
@ -1463,7 +1465,7 @@ int configureMAC() {
|
||||
LOG(logINFO, ("\tInterface : %d %s\n\n", selInterface,
|
||||
(selInterface ? "Inner" : "Outer")));
|
||||
|
||||
for (int iRxEntry = 0; iRxEntry != numUdpDestinations; ++iRxEntry) {
|
||||
for (int iRxEntry = 0; iRxEntry != MAX_UDP_DESTINATION; ++iRxEntry) {
|
||||
uint32_t srcip = udpDetails[iRxEntry].srcip;
|
||||
uint32_t srcip2 = udpDetails[iRxEntry].srcip2;
|
||||
uint32_t dstip = udpDetails[iRxEntry].dstip;
|
||||
@ -1489,30 +1491,32 @@ int configureMAC() {
|
||||
getMacAddressinString(dst_mac2, 50, dstmac2);
|
||||
getIpAddressinString(src_ip2, srcip2);
|
||||
getIpAddressinString(dst_ip2, dstip2);
|
||||
LOG(logINFOBLUE, ("\tEntry %d\n", iRxEntry));
|
||||
|
||||
LOG(logINFO, ("\tOuter %s\n", (numInterfaces == 2)
|
||||
? "(Bottom)"
|
||||
: (selInterface ? "Not Used" : "Used")));
|
||||
LOG(logINFO, ("\tSource IP : %s\n"
|
||||
"\tSource MAC : %s\n"
|
||||
"\tSource Port : %d\n"
|
||||
"\tDest IP : %s\n"
|
||||
"\tDest MAC : %s\n"
|
||||
"\tDest Port : %d\n",
|
||||
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport));
|
||||
if (iRxEntry <= numUdpDestinations) {
|
||||
LOG(logINFOBLUE, ("\tEntry %d\n", iRxEntry));
|
||||
|
||||
LOG(logINFO, ("\tInner %s\n", (numInterfaces == 2)
|
||||
? "(Top)"
|
||||
: (selInterface ? "Used" : "Not Used")));
|
||||
LOG(logINFO, ("\tSource IP2 : %s\n"
|
||||
"\tSource MAC2 : %s\n"
|
||||
"\tSource Port2: %d\n"
|
||||
"\tDest IP2 : %s\n"
|
||||
"\tDest MAC2 : %s\n"
|
||||
"\tDest Port2 : %d\n",
|
||||
src_ip2, src_mac2, srcport2, dst_ip2, dst_mac2, dstport2));
|
||||
LOG(logINFO, ("\tOuter %s\n", (numInterfaces == 2)
|
||||
? "(Bottom)"
|
||||
: (selInterface ? "Not Used" : "Used")));
|
||||
LOG(logINFO, ("\tSource IP : %s\n"
|
||||
"\tSource MAC : %s\n"
|
||||
"\tSource Port : %d\n"
|
||||
"\tDest IP : %s\n"
|
||||
"\tDest MAC : %s\n"
|
||||
"\tDest Port : %d\n",
|
||||
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport));
|
||||
|
||||
LOG(logINFO, ("\tInner %s\n", (numInterfaces == 2)
|
||||
? "(Top)"
|
||||
: (selInterface ? "Used" : "Not Used")));
|
||||
LOG(logINFO, ("\tSource IP2 : %s\n"
|
||||
"\tSource MAC2 : %s\n"
|
||||
"\tSource Port2: %d\n"
|
||||
"\tDest IP2 : %s\n"
|
||||
"\tDest MAC2 : %s\n"
|
||||
"\tDest Port2 : %d\n",
|
||||
src_ip2, src_mac2, srcport2, dst_ip2, dst_mac2, dstport2));
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
if (setUDPDestinationDetails(iRxEntry, 0, dst_ip, dstport) == FAIL) {
|
||||
LOG(logERROR, ("could not set udp destination IP and port for "
|
||||
|
Binary file not shown.
Binary file not shown.
@ -84,12 +84,12 @@ void init_detector() {
|
||||
LOG(logINFO, ("This is a VIRTUAL detector\n"));
|
||||
#endif
|
||||
memset(udpDetails, 0, sizeof(udpDetails));
|
||||
for (int iRxEntry = 0; iRxEntry != MAX_UDP_DESTINATION; ++iRxEntry) {
|
||||
udpDetails[iRxEntry].srcport = DEFAULT_UDP_SRC_PORTNO;
|
||||
udpDetails[iRxEntry].srcport2 = DEFAULT_UDP_SRC_PORTNO + 1;
|
||||
}
|
||||
udpDetails[0].srcport = DEFAULT_UDP_SRC_PORTNO;
|
||||
udpDetails[0].dstport = DEFAULT_UDP_DST_PORTNO;
|
||||
#ifdef EIGERD
|
||||
udpDetails[0].dstport2 = DEFAULT_UDP_DST_PORTNO + 1;
|
||||
#endif
|
||||
|
||||
if (isControlServer) {
|
||||
basictests();
|
||||
initControlServer();
|
||||
@ -4945,8 +4945,7 @@ int check_detector_idle(const char *s) {
|
||||
}
|
||||
|
||||
int is_udp_configured() {
|
||||
for (int i = firstUDPDestination;
|
||||
i != firstUDPDestination + numUdpDestinations; ++i) {
|
||||
for (int i = 0; i != numUdpDestinations; ++i) {
|
||||
if (udpDetails[i].dstip == 0) {
|
||||
sprintf(configureMessage, "udp destination ip not configured [entry:%d]\n", i);
|
||||
LOG(logWARNING, ("%s", configureMessage));
|
||||
@ -5439,6 +5438,35 @@ int set_num_interfaces(int file_des) {
|
||||
} else if (check_detector_idle("configure mac") == OK) {
|
||||
if (getNumberofUDPInterfaces() != arg) {
|
||||
setNumberofUDPInterfaces(arg);
|
||||
for (int iRxEntry = 0; iRxEntry != numUdpDestinations; ++iRxEntry) {
|
||||
if (arg == 1) {
|
||||
udpDetails[iRxEntry].srcport2 = 0;
|
||||
udpDetails[iRxEntry].srcip2 = 0;
|
||||
udpDetails[iRxEntry].srcmac2 = 0;
|
||||
udpDetails[iRxEntry].dstport2 = 0;
|
||||
udpDetails[iRxEntry].dstip2 = 0;
|
||||
udpDetails[iRxEntry].dstmac2 = 0;
|
||||
} else {
|
||||
// if still 0, set defaults
|
||||
udpDetails[iRxEntry].srcport2 = DEFAULT_UDP_SRC_PORTNO + 1;
|
||||
if (udpDetails[iRxEntry].dstport2 == 0) {
|
||||
udpDetails[iRxEntry].dstport2 = 2 * iRxEntry + 1 + DEFAULT_UDP_DST_PORTNO;
|
||||
}
|
||||
// if still 0, copy from entry 0
|
||||
if (iRxEntry != 0) {
|
||||
if (udpDetails[iRxEntry].srcip2 == 0) {
|
||||
udpDetails[iRxEntry].srcip2 = udpDetails[0].srcip2;
|
||||
}
|
||||
if (udpDetails[iRxEntry].dstip2 == 0) {
|
||||
udpDetails[iRxEntry].dstip2 = udpDetails[0].dstip2;
|
||||
}
|
||||
if (udpDetails[iRxEntry].dstmac2 == 0) {
|
||||
udpDetails[iRxEntry].dstmac2 = udpDetails[0].dstmac2;
|
||||
}
|
||||
// srcmac2 will be set in configure_mac
|
||||
}
|
||||
}
|
||||
}
|
||||
calculate_and_set_position(); // aleady configures mac
|
||||
}
|
||||
}
|
||||
@ -9134,12 +9162,77 @@ int set_dest_udp_list(int file_des) {
|
||||
#endif
|
||||
else {
|
||||
if (check_detector_idle("set udp destination list entries") == OK) {
|
||||
udpDetails[entry].dstport = args[1];
|
||||
udpDetails[entry].dstport2 = args[2];
|
||||
udpDetails[entry].dstip = args[3];
|
||||
udpDetails[entry].dstip2 = args[4];
|
||||
udpDetails[entry].dstmac = args64[0];
|
||||
udpDetails[entry].dstmac2 = args64[1];
|
||||
udpDetails[entry].srcport = 0;
|
||||
udpDetails[entry].srcip = 0;
|
||||
udpDetails[entry].srcmac = 0;
|
||||
udpDetails[entry].dstport = 0;
|
||||
udpDetails[entry].dstip = 0;
|
||||
udpDetails[entry].dstmac = 0;
|
||||
udpDetails[entry].srcport2 = 0;
|
||||
udpDetails[entry].srcip2 = 0;
|
||||
udpDetails[entry].srcmac2 = 0;
|
||||
udpDetails[entry].dstport2 = 0;
|
||||
udpDetails[entry].dstip2 = 0;
|
||||
udpDetails[entry].dstmac2 = 0;
|
||||
|
||||
if (args[1] != 0) {
|
||||
udpDetails[entry].dstport = args[1];
|
||||
}
|
||||
if (args[2] != 0) {
|
||||
udpDetails[entry].dstport2 = args[2];
|
||||
}
|
||||
if (args[3] != 0) {
|
||||
udpDetails[entry].dstip = args[3];
|
||||
}
|
||||
if (args[4] != 0) {
|
||||
udpDetails[entry].dstip2 = args[4];
|
||||
}
|
||||
if (args64[0] != 0) {
|
||||
udpDetails[entry].dstmac = args64[0];
|
||||
}
|
||||
if (args64[1] != 0) {
|
||||
udpDetails[entry].dstmac2 = args64[1];
|
||||
}
|
||||
|
||||
// if still 0, set defaults
|
||||
int twoInterfaces = 0;
|
||||
#if defined(JUNGFRAUD) || defined(GOTTHARD2D)
|
||||
twoInterfaces = getNumberofUDPInterfaces() == 2 ? 1 : 0;
|
||||
#endif
|
||||
udpDetails[entry].srcport = DEFAULT_UDP_SRC_PORTNO;
|
||||
if (udpDetails[entry].dstport == 0) {
|
||||
udpDetails[entry].dstport = 2 * entry + DEFAULT_UDP_DST_PORTNO;
|
||||
}
|
||||
if (myDetectorType == EIGER || twoInterfaces) {
|
||||
udpDetails[entry].srcport2 = DEFAULT_UDP_SRC_PORTNO + 1;
|
||||
if (udpDetails[entry].dstport2 == 0) {
|
||||
udpDetails[entry].dstport2 = 2 * entry + 1 + DEFAULT_UDP_DST_PORTNO;
|
||||
}
|
||||
}
|
||||
// if still 0, copy from entry 0
|
||||
if (entry != 0) {
|
||||
if (udpDetails[entry].srcip == 0) {
|
||||
udpDetails[entry].srcip = udpDetails[0].srcip;
|
||||
}
|
||||
if (udpDetails[entry].dstip == 0) {
|
||||
udpDetails[entry].dstip = udpDetails[0].dstip;
|
||||
}
|
||||
if (udpDetails[entry].dstmac == 0) {
|
||||
udpDetails[entry].dstmac = udpDetails[0].dstmac;
|
||||
}
|
||||
if (twoInterfaces) {
|
||||
if (udpDetails[entry].srcip2 == 0) {
|
||||
udpDetails[entry].srcip2 = udpDetails[0].srcip2;
|
||||
}
|
||||
if (udpDetails[entry].dstip2 == 0) {
|
||||
udpDetails[entry].dstip2 = udpDetails[0].dstip2;
|
||||
}
|
||||
if (udpDetails[entry].dstmac2 == 0) {
|
||||
udpDetails[entry].dstmac2 = udpDetails[0].dstmac2;
|
||||
}
|
||||
}
|
||||
// srcmac and srcmac2 will be set in configure_mac
|
||||
}
|
||||
configure_mac();
|
||||
}
|
||||
}
|
||||
|
@ -1425,24 +1425,10 @@ defs::udpDestination CmdProxy::getUdpList() {
|
||||
port2 = StringTo<uint32_t>(value);
|
||||
}
|
||||
}
|
||||
// necessary arguments
|
||||
if (hasEntry && ip != 0 && mac != 0 && port != 0) {
|
||||
if (ip2 == 0 && mac2 == 0) {
|
||||
// default (no second interface)
|
||||
if (port2 == 0) {
|
||||
return defs::udpDestination(entry, port, ip, mac);
|
||||
}
|
||||
// eiger (second udp port)
|
||||
else {
|
||||
return defs::udpDestination(entry, port, ip, mac, port2);
|
||||
}
|
||||
}
|
||||
// jungfrau and gotthard2 (second interface)
|
||||
if (ip2 != 0 && mac2 != 0 && port2 != 0) {
|
||||
return defs::udpDestination(entry, port, ip, mac, port2, ip2, mac2);
|
||||
}
|
||||
if (!hasEntry) {
|
||||
throw sls::RuntimeError("Found no entry argument.");
|
||||
}
|
||||
throw sls::RuntimeError("Insufficient arguments");
|
||||
return defs::udpDestination(entry, port, ip, mac, port2, ip2, mac2);
|
||||
}
|
||||
|
||||
std::string CmdProxy::UDPDestinationList(int action) {
|
||||
|
@ -503,13 +503,8 @@ typedef struct {
|
||||
uint64_t mac_{};
|
||||
uint64_t mac2_{};
|
||||
udpDestination() {}
|
||||
udpDestination(uint32_t entry, uint32_t port, uint32_t ip, uint64_t mac)
|
||||
: entry_(entry), port_(port), ip_(ip), mac_(mac) {}
|
||||
udpDestination(uint32_t entry, uint32_t port, uint32_t ip, uint64_t mac,
|
||||
uint32_t port2)
|
||||
: entry_(entry), port_(port), port2_(port2), ip_(ip), mac_(mac) {}
|
||||
udpDestination(uint32_t entry, uint32_t port, uint32_t ip, uint64_t mac,
|
||||
uint32_t port2, uint32_t ip2, uint64_t mac2)
|
||||
udpDestination(uint32_t entry, uint32_t port = 0, uint32_t ip = 0, uint64_t mac = 0,
|
||||
uint32_t port2 = 0, uint32_t ip2 = 0, uint64_t mac2 = 0)
|
||||
: entry_(entry), port_(port), port2_(port2), ip_(ip), ip2_(ip2),
|
||||
mac_(mac), mac2_(mac2) {}
|
||||
|
||||
|
@ -6,10 +6,10 @@
|
||||
|
||||
|
||||
|
||||
#define APICTB 0x210826
|
||||
#define APIGOTTHARD 0x210826
|
||||
#define APIGOTTHARD2 0x210826
|
||||
#define APIJUNGFRAU 0x210826
|
||||
#define APIMYTHEN3 0x210826
|
||||
#define APIEIGER 0x210827
|
||||
#define APICTB 0x210827
|
||||
#define APIGOTTHARD 0x210827
|
||||
#define APIGOTTHARD2 0x210827
|
||||
#define APIJUNGFRAU 0x210827
|
||||
#define APIMYTHEN3 0x210827
|
||||
#define APIMOENCH 0x210826
|
||||
#define APIEIGER 0x210826
|
||||
|
Loading…
x
Reference in New Issue
Block a user