mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
merge fix
This commit is contained in:
@ -10,7 +10,6 @@
|
||||
|
||||
namespace sls {
|
||||
|
||||
|
||||
/**
|
||||
* @param data array of data values
|
||||
* @param nch number of channels
|
||||
@ -25,7 +24,6 @@ int readDataFile(std::ifstream &infile, short int *data, int nch,
|
||||
*/
|
||||
int readDataFile(std::string fname, short int *data, int nch);
|
||||
|
||||
|
||||
std::vector<char> readBinaryFile(const std::string &fname,
|
||||
const std::string &errorPrefix);
|
||||
|
||||
@ -47,7 +45,7 @@ int writeDataFile(std::string fname, int nch, short int *data);
|
||||
void mkdir_p(const std::string &path, std::string dir = "");
|
||||
|
||||
int getFileSize(std::ifstream &ifs);
|
||||
ssize_t getFileSize(FILE* fd, const std::string &prependErrorString);
|
||||
ssize_t getFileSize(FILE *fd, const std::string &prependErrorString);
|
||||
|
||||
std::string getFileNameFromFilePath(const std::string &fpath);
|
||||
}
|
||||
} // namespace sls
|
||||
|
@ -65,6 +65,8 @@
|
||||
#define DEFAULT_DET_MAC2 "00:aa:bb:cc:dd:ff"
|
||||
#define DEFAULT_DET_IP2 "129.129.202.46"
|
||||
|
||||
#define LOCALHOST_IP "127.0.0.1"
|
||||
|
||||
/** default maximum string length */
|
||||
#define MAX_STR_LENGTH 1000
|
||||
#define SHORT_STR_LENGTH 20
|
||||
@ -73,7 +75,7 @@
|
||||
|
||||
#define DEFAULT_STREAMING_TIMER_IN_MS 500
|
||||
|
||||
#define NUM_RX_THREAD_IDS 8
|
||||
#define NUM_RX_THREAD_IDS 9
|
||||
|
||||
#ifdef __cplusplus
|
||||
class slsDetectorDefs {
|
||||
@ -563,6 +565,8 @@ enum streamingInterface {
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
|
||||
// operators needed in ToString
|
||||
inline slsDetectorDefs::streamingInterface
|
||||
operator|(const slsDetectorDefs::streamingInterface &a,
|
||||
const slsDetectorDefs::streamingInterface &b) {
|
||||
@ -576,6 +580,7 @@ operator&(const slsDetectorDefs::streamingInterface &a,
|
||||
return slsDetectorDefs::streamingInterface(static_cast<int32_t>(a) &
|
||||
static_cast<int32_t>(b));
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -258,6 +258,9 @@ enum detFuncs {
|
||||
F_UPDATE_DETECTOR_SERVER,
|
||||
F_GET_UPDATE_MODE,
|
||||
F_SET_UPDATE_MODE,
|
||||
F_SET_MASTER,
|
||||
F_GET_TOP,
|
||||
F_SET_TOP,
|
||||
|
||||
NUM_DET_FUNCTIONS,
|
||||
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
|
||||
@ -361,6 +364,8 @@ enum detFuncs {
|
||||
F_SET_RECEIVER_STREAMING_HWM,
|
||||
F_RECEIVER_SET_ALL_THRESHOLD,
|
||||
F_RECEIVER_SET_DATASTREAM,
|
||||
F_GET_RECEIVER_ARPING,
|
||||
F_SET_RECEIVER_ARPING,
|
||||
|
||||
NUM_REC_FUNCTIONS
|
||||
};
|
||||
@ -617,6 +622,9 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
||||
case F_UPDATE_DETECTOR_SERVER: return "F_UPDATE_DETECTOR_SERVER";
|
||||
case F_GET_UPDATE_MODE: return "F_GET_UPDATE_MODE";
|
||||
case F_SET_UPDATE_MODE: return "F_SET_UPDATE_MODE";
|
||||
case F_SET_MASTER: return "F_SET_MASTER";
|
||||
case F_GET_TOP: return "F_GET_TOP";
|
||||
case F_SET_TOP: return "F_SET_TOP";
|
||||
|
||||
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
||||
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
||||
@ -720,6 +728,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
||||
case F_SET_RECEIVER_STREAMING_HWM: return "F_SET_RECEIVER_STREAMING_HWM";
|
||||
case F_RECEIVER_SET_ALL_THRESHOLD: return "F_RECEIVER_SET_ALL_THRESHOLD";
|
||||
case F_RECEIVER_SET_DATASTREAM: return "F_RECEIVER_SET_DATASTREAM";
|
||||
case F_GET_RECEIVER_ARPING: return "F_GET_RECEIVER_ARPING";
|
||||
case F_SET_RECEIVER_ARPING: return "F_SET_RECEIVER_ARPING";
|
||||
|
||||
case NUM_REC_FUNCTIONS: return "NUM_REC_FUNCTIONS";
|
||||
default: return "Unknown Function";
|
||||
|
@ -1,15 +1,14 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
/** API versions */
|
||||
#define GITBRANCH "developer"
|
||||
|
||||
#define APILIB 0x211125
|
||||
#define APIRECEIVER 0x211124
|
||||
#define APIGUI 0x211124
|
||||
#define APICTB 0x211126
|
||||
#define APIGOTTHARD 0x211126
|
||||
#define APIGOTTHARD2 0x211126
|
||||
#define APIJUNGFRAU 0x211126
|
||||
#define APIMYTHEN3 0x211126
|
||||
#define APIMOENCH 0x211126
|
||||
#define APIEIGER 0x211126
|
||||
#define GITBRANCH "developer"
|
||||
#define APILIB 0x211125
|
||||
#define APIRECEIVER 0x211124
|
||||
#define APIGUI 0x211124
|
||||
#define APICTB 0x220318
|
||||
#define APIGOTTHARD 0x220318
|
||||
#define APIGOTTHARD2 0x220318
|
||||
#define APIJUNGFRAU 0x220318
|
||||
#define APIMYTHEN3 0x220318
|
||||
#define APIMOENCH 0x220318
|
||||
#define APIEIGER 0x220318
|
||||
|
@ -67,7 +67,8 @@ std::vector<char> readBinaryFile(const std::string &fname,
|
||||
FILE *fp = fopen(fname.c_str(), "rb");
|
||||
if (fp == nullptr) {
|
||||
throw sls::RuntimeError(errorPrefix +
|
||||
std::string(" (Could not open file: ") + fname + std::string(")"));
|
||||
std::string(" (Could not open file: ") + fname +
|
||||
std::string(")"));
|
||||
}
|
||||
|
||||
// get file size to print progress
|
||||
@ -148,17 +149,19 @@ std::string getFileNameFromFilePath(const std::string &fpath) {
|
||||
return fname;
|
||||
}
|
||||
|
||||
ssize_t getFileSize(FILE* fd, const std::string &prependErrorString) {
|
||||
ssize_t getFileSize(FILE *fd, const std::string &prependErrorString) {
|
||||
if (fseek(fd, 0, SEEK_END) != 0) {
|
||||
throw RuntimeError(prependErrorString + std::string(" (Seek error in src file)"));
|
||||
throw RuntimeError(prependErrorString +
|
||||
std::string(" (Seek error in src file)"));
|
||||
}
|
||||
size_t fileSize = ftell(fd);
|
||||
if (fileSize <= 0) {
|
||||
throw RuntimeError(prependErrorString + std::string(" (Could not get length of source file)"));
|
||||
throw RuntimeError(
|
||||
prependErrorString +
|
||||
std::string(" (Could not get length of source file)"));
|
||||
}
|
||||
rewind(fd);
|
||||
return fileSize;
|
||||
}
|
||||
|
||||
|
||||
} // namespace sls
|
||||
|
@ -34,36 +34,42 @@
|
||||
namespace sls {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Modification 2021 Paul Scherrer Institut
|
||||
/**
|
||||
* Modification 2021 Paul Scherrer Institut
|
||||
* Macros exported from md5_local.h
|
||||
*/
|
||||
#define F(b,c,d) ((((c) ^ (d)) & (b)) ^ (d))
|
||||
#define G(b,c,d) ((((b) ^ (c)) & (d)) ^ (c))
|
||||
#define H(b,c,d) ((b) ^ (c) ^ (d))
|
||||
#define I(b,c,d) (((~(d)) | (b)) ^ (c))
|
||||
#define F(b, c, d) ((((c) ^ (d)) & (b)) ^ (d))
|
||||
#define G(b, c, d) ((((b) ^ (c)) & (d)) ^ (c))
|
||||
#define H(b, c, d) ((b) ^ (c) ^ (d))
|
||||
#define I(b, c, d) (((~(d)) | (b)) ^ (c))
|
||||
|
||||
#define R0(a,b,c,d,k,s,t) { \
|
||||
a+=((k)+(t)+F((b),(c),(d))); \
|
||||
a=ROTATE(a,s); \
|
||||
a+=b; };
|
||||
#define R0(a, b, c, d, k, s, t) \
|
||||
{ \
|
||||
a += ((k) + (t) + F((b), (c), (d))); \
|
||||
a = ROTATE(a, s); \
|
||||
a += b; \
|
||||
};
|
||||
|
||||
#define R1(a,b,c,d,k,s,t) { \
|
||||
a+=((k)+(t)+G((b),(c),(d))); \
|
||||
a=ROTATE(a,s); \
|
||||
a+=b; };
|
||||
|
||||
#define R2(a,b,c,d,k,s,t) { \
|
||||
a+=((k)+(t)+H((b),(c),(d))); \
|
||||
a=ROTATE(a,s); \
|
||||
a+=b; };
|
||||
|
||||
#define R3(a,b,c,d,k,s,t) { \
|
||||
a+=((k)+(t)+I((b),(c),(d))); \
|
||||
a=ROTATE(a,s); \
|
||||
a+=b; };
|
||||
#define R1(a, b, c, d, k, s, t) \
|
||||
{ \
|
||||
a += ((k) + (t) + G((b), (c), (d))); \
|
||||
a = ROTATE(a, s); \
|
||||
a += b; \
|
||||
};
|
||||
|
||||
#define R2(a, b, c, d, k, s, t) \
|
||||
{ \
|
||||
a += ((k) + (t) + H((b), (c), (d))); \
|
||||
a = ROTATE(a, s); \
|
||||
a += b; \
|
||||
};
|
||||
|
||||
#define R3(a, b, c, d, k, s, t) \
|
||||
{ \
|
||||
a += ((k) + (t) + I((b), (c), (d))); \
|
||||
a = ROTATE(a, s); \
|
||||
a += b; \
|
||||
};
|
||||
|
||||
/*
|
||||
* Implemented from RFC1321 The MD5 Message-Digest Algorithm
|
||||
@ -74,8 +80,7 @@ namespace sls {
|
||||
#define INIT_DATA_C (unsigned long)0x98badcfeL
|
||||
#define INIT_DATA_D (unsigned long)0x10325476L
|
||||
|
||||
int MD5_Init_SLS(MD5_CTX *c)
|
||||
{
|
||||
int MD5_Init_SLS(MD5_CTX *c) {
|
||||
memset(c, 0, sizeof(*c));
|
||||
c->A = INIT_DATA_A;
|
||||
c->B = INIT_DATA_B;
|
||||
@ -84,14 +89,13 @@ int MD5_Init_SLS(MD5_CTX *c)
|
||||
return 1;
|
||||
}
|
||||
|
||||
void md5_block_data_order(MD5_CTX *c, const void *data_, size_t num)
|
||||
{
|
||||
void md5_block_data_order(MD5_CTX *c, const void *data_, size_t num) {
|
||||
const unsigned char *data = data_;
|
||||
register unsigned MD32_REG_T A, B, C, D, l;
|
||||
/* See comment in crypto/sha/sha_local.h for details. */
|
||||
unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
|
||||
XX8, XX9, XX10, XX11, XX12, XX13, XX14, XX15;
|
||||
# define X(i) XX##i
|
||||
unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, XX8, XX9, XX10,
|
||||
XX11, XX12, XX13, XX14, XX15;
|
||||
#define X(i) XX##i
|
||||
|
||||
A = c->A;
|
||||
B = c->B;
|
||||
@ -207,12 +211,11 @@ void md5_block_data_order(MD5_CTX *c, const void *data_, size_t num)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Modification 2021 Paul Scherrer Institut
|
||||
* from md32_common.h
|
||||
/**
|
||||
* Modification 2021 Paul Scherrer Institut
|
||||
* from md32_common.h
|
||||
*/
|
||||
int HASH_UPDATE(HASH_CTX *c, const void *data_, size_t len)
|
||||
{
|
||||
int HASH_UPDATE(HASH_CTX *c, const void *data_, size_t len) {
|
||||
const unsigned char *data = data_;
|
||||
unsigned char *p;
|
||||
HASH_LONG l;
|
||||
@ -221,11 +224,11 @@ int HASH_UPDATE(HASH_CTX *c, const void *data_, size_t len)
|
||||
if (len == 0)
|
||||
return 1;
|
||||
|
||||
l = (c->Nl + (((HASH_LONG) len) << 3)) & 0xffffffffUL;
|
||||
if (l < c->Nl) /* overflow */
|
||||
l = (c->Nl + (((HASH_LONG)len) << 3)) & 0xffffffffUL;
|
||||
if (l < c->Nl) /* overflow */
|
||||
c->Nh++;
|
||||
c->Nh += (HASH_LONG) (len >> 29); /* might cause compiler warning on
|
||||
* 16-bit */
|
||||
c->Nh += (HASH_LONG)(len >> 29); /* might cause compiler warning on
|
||||
* 16-bit */
|
||||
c->Nl = l;
|
||||
|
||||
n = c->num;
|
||||
@ -269,16 +272,15 @@ int HASH_UPDATE(HASH_CTX *c, const void *data_, size_t len)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modification 2021 Paul Scherrer Institut
|
||||
* from md32_common.h
|
||||
/**
|
||||
* Modification 2021 Paul Scherrer Institut
|
||||
* from md32_common.h
|
||||
*/
|
||||
int HASH_FINAL(unsigned char *md, HASH_CTX *c)
|
||||
{
|
||||
int HASH_FINAL(unsigned char *md, HASH_CTX *c) {
|
||||
unsigned char *p = (unsigned char *)c->data;
|
||||
size_t n = c->num;
|
||||
|
||||
p[n] = 0x80; /* there is always room for one */
|
||||
p[n] = 0x80; /* there is always room for one */
|
||||
n++;
|
||||
|
||||
if (n > (HASH_CBLOCK - 8)) {
|
||||
@ -289,7 +291,7 @@ int HASH_FINAL(unsigned char *md, HASH_CTX *c)
|
||||
memset(p + n, 0, HASH_CBLOCK - 8 - n);
|
||||
|
||||
p += HASH_CBLOCK - 8;
|
||||
#if defined(DATA_ORDER_IS_BIG_ENDIAN)
|
||||
#if defined(DATA_ORDER_IS_BIG_ENDIAN)
|
||||
(void)HOST_l2c(c->Nh, p);
|
||||
(void)HOST_l2c(c->Nl, p);
|
||||
#elif defined(DATA_ORDER_IS_LITTLE_ENDIAN)
|
||||
@ -300,7 +302,7 @@ int HASH_FINAL(unsigned char *md, HASH_CTX *c)
|
||||
HASH_BLOCK_DATA_ORDER(c, p, 1);
|
||||
c->num = 0;
|
||||
// OPENSSL_cleanse(p, HASH_CBLOCK);
|
||||
//Erik: Since we don't do encryption secure cleaning is not needed
|
||||
// Erik: Since we don't do encryption secure cleaning is not needed
|
||||
memset(p, 0, HASH_CBLOCK);
|
||||
|
||||
HASH_MAKE_STRING(c, md);
|
||||
|
@ -115,7 +115,8 @@ TEST_CASE("Copy construct a MacAddr") {
|
||||
}
|
||||
|
||||
TEST_CASE("udp dst struct basic properties") {
|
||||
static_assert(sizeof(UdpDestination) == 36, "udpDestination struct size does not match");
|
||||
static_assert(sizeof(UdpDestination) == 36,
|
||||
"udpDestination struct size does not match");
|
||||
UdpDestination dst{};
|
||||
REQUIRE(dst.entry == 0);
|
||||
REQUIRE(dst.port == 0);
|
||||
|
Reference in New Issue
Block a user