--- /dev/null
+/*
+ File name : def.h
+ Projet : MERLIN
+ Date of creation : 2025/04/11
+ Version : 1.0
+ Copyright : Thales SIX
+ Author : Laurent Mazet <laurent.mazet@thalesgroup.com>
+
+ Description : Global defined constants
+
+ History :
+ - initial version
+*/
+
+#ifndef __DEF_H__
+#define __DEF_H__
+
+#define MOREP_PAYLOAD 1496
+//#define MOREP_PAYLOAD (1496 * 16 - 1)
+
+#endif /* __DEF_H__ */
+
+/* vim: set ts=4 sw=4 si et: */
#include <string.h>
#include <unistd.h>
+#include "def.h"
#include "morep.h"
#include "parse.h"
#include "pdu_channel.h"
}
/* send message */
- uint8_t payload[1496] = {0};
+ uint8_t payload[MOREP_PAYLOAD] = {0};
switch (pdu) {
case channel_e:
len = serial_channel (&pdu_channel, payload, sizeof (payload));
message_t *exp_msg = msg;
uint8_t msgtype = 0;
- uint8_t payload[1496] = {0};
+ uint8_t payload[MOREP_PAYLOAD] = {0};
seqnum = MOREP_Receive (comm->morep, &msgtype, payload, &len);
printf("msgtype: %d\n", msgtype);
if (log) {
fprintf (log, "%c:%s[%s] [SEG=%d MSG=%d LEN=%d PDU=%d] %s", mode ? 'T' : 'R',
serv->name, comm->etype, seqnum, msg->msgtype, len, pdu, msg->name);
- char buffer[1496 * 3 + 256] = {0};
+ char buffer[MOREP_PAYLOAD * 3 + 256] = {0};
switch (pdu) {
case nopdu_e:
break;
#include "morep.h"
#include "verbose.h"
+#define MOREP_PAYLOAD 1496
+
char *progname = NULL;
int stop = 0;
uint8_t rxmsgtype = 0;
int rxmsglen = 0;
- uint8_t rxbuffer[1496 * 16] = {0};
+ uint8_t rxbuffer[MOREP_PAYLOAD * 16] = {0};
int rxseqnum = MOREP_Receive (morep, &rxmsgtype, rxbuffer, &rxmsglen);
VERBOSE (morep, INFO, PRINTF ("rx %d bytes (msgid %d) [%d]\n", rxmsglen, rxmsgtype, rxseqnum));
VERBOSE (morep, TRACE, PRINTF ("rx msg: '"); fwrite ((char *)rxbuffer, 1, rxmsglen, stdout); printf ("'\n"));
}
while (!feof (fid)) {
- int txmsglen = 1496;
- uint8_t txbuffer[1496] = {0};
+ int txmsglen = MOREP_PAYLOAD;
+ uint8_t txbuffer[MOREP_PAYLOAD] = {0};
int i = 0;
do {
fread (txbuffer + i, 1, 1, fid);
uint8_t rxmsgtype = 0;
int rxmsglen = 0;
- uint8_t rxbuffer[1496] = {0};
+ uint8_t rxbuffer[MOREP_PAYLOAD] = {0};
int rxseqnum = MOREP_Receive (morep, &rxmsgtype, rxbuffer, &rxmsglen);
VERBOSE (morep, INFO, PRINTF ("rx %d bytes (msgid %d) [%d]\n", rxmsglen, rxmsgtype, rxseqnum));
VERBOSE (morep, TRACE, PRINTF ("rx msg: '"); fwrite ((char *)rxbuffer, 1, rxmsglen, stdout); printf ("'\n"));
uint8_t *txbuffer = buffer;
while (len > 0) {
- int txmsglen = 1496 * 16 - 1;
+ int txmsglen = MOREP_PAYLOAD * 16 - 1;
if (len < txmsglen) {
txmsglen = len;
}
uint8_t rxmsgtype = 0;
int rxmsglen = 0;
- uint8_t rxbuffer[1496 * 16] = {0};
+ uint8_t rxbuffer[MOREP_PAYLOAD * 16] = {0};
int rxseqnum = MOREP_Receive (morep, &rxmsgtype, rxbuffer, &rxmsglen);
VERBOSE (morep, INFO, PRINTF ("rx %d bytes (msgid %d) [%d]\n", rxmsglen, rxmsgtype, rxseqnum));
VERBOSE (morep, TRACE, PRINTF ("rx msg: '"); fwrite ((char *)rxbuffer, 1, rxmsglen, stdout); printf ("'\n"));
#include <string.h>
#include <unistd.h>
+#include "def.h"
#include "morep.h"
#include "parse.h"
#include "verbose.h"
}
} else { /* receive */
uint8_t rxmsgtype = 0;
- uint8_t rxpayload[1496 * 16 - 1] = {0};
+ uint8_t rxpayload[MOREP_PAYLOAD] = {0};
int rxlen = -1;
int seqnum = MOREP_Receive (comm->morep, &rxmsgtype, rxpayload, &rxlen);
#include <stdint.h>
#include <sys/cdefs.h>
+#include "def.h"
+
__BEGIN_DECLS
/**
#include <stdint.h>
#include <sys/cdefs.h>
+#include "def.h"
+
__BEGIN_DECLS
/**
*/
typedef struct {
uint8_t channel_id; /**< channel index */
- int bypass_len; /**< attached bypass message length */
+ uint8_t bypass_len; /**< attached bypass message length */
uint8_t bypass[255]; /**< attached bypass message */
- int data_len; /**< data length (must be aligned to 16 bytes) */
- uint8_t data[1472]; /**< data message */
+ uint16_t data_len; /**< data length (must be aligned to 16 bytes) */
+ uint8_t data[16 * ((MOREP_PAYLOAD - 14) / 16)]; /**< data message */
} CLEAR_DATA_t;
/**
#include <stdint.h>
#include <sys/cdefs.h>
+#include "def.h"
+
__BEGIN_DECLS
/**
uint8_t bypass_len; /**< attached bypass message length */
uint8_t bypass[255]; /**< attached bypass message */
uint16_t data_len; /**< data length (must be aligned to 16 bytes) */
- uint8_t data[1472]; /**< data message */
+ uint8_t data[16 * ((MOREP_PAYLOAD - 14) / 16)]; /**< data message */
} ENCRYPTED_DATA_t;
/**
#include <stdint.h>
#include <sys/cdefs.h>
+#include "def.h"
+
__BEGIN_DECLS
/**
typedef struct {
uint8_t key_id; /**< key id */
uint16_t key_len; /**< key length */
- uint8_t key[1495]; /**< raw key */
+ uint8_t key[MOREP_PAYLOAD - 1]; /**< raw key */
} KEY_t;
/**
#include <stdint.h>
#include <sys/cdefs.h>
+#include "def.h"
+
__BEGIN_DECLS
/**
uint8_t prng_id; /**< algorithm index */
uint16_t seq_len; /**< requested PRNG sequence length */
uint8_t seed_len; /**< seed length */
- uint8_t seed[1495]; /**< seed */
+ uint8_t seed[MOREP_PAYLOAD - 1]; /**< seed */
} PRNG_PARAM_t;
/**
#include <stdint.h>
#include <sys/cdefs.h>
+#include "def.h"
+
__BEGIN_DECLS
/**
Raw data type
*/
typedef struct {
- int data_len; /**< data length*/
- uint8_t data[1496]; /**< data message */
+ uint16_t data_len; /**< data length*/
+ uint8_t data[MOREP_PAYLOAD]; /**< data message */
} RAW_DATA_t;
/**
#include <stdint.h>
#include <sys/cdefs.h>
+#include "def.h"
+
__BEGIN_DECLS
/**
/*
- File name : simulator.10
+ File name : simulator.h
Projet : MERLIN
Date of creation : 2025/04/10
Version : 1.0