/* depend: */
/* cflags: */
-/* linker: morep.o parse.o payload.o raw_data.o */
-/* winlnk: morep.o parse.o payload.o raw_data.o */
+/* linker: morep.o parse.o pdu_raw_data.o */
+/* winlnk: morep.o parse.o pdu_raw_data.o */
#include <errno.h>
#include <signal.h>
#include "parse.h"
#include "verbose.h"
-#include "raw_data.h"
+#include "pdu_raw_data.h"
char *progname = NULL;
buf##_len = parse_array (val, buf, sizeof (buf)); \
}
+/**
+ @ingroup MESSAGES
+
+ Parsing macro for fix table size field
+
+ @param name field name
+ @param buf preallocated storage
+*/
+#define PARSE_TAB(name, buf) \
+ else if (strcmp (var, name) == 0) { \
+ parse_array (val, buf, sizeof (buf)); \
+ }
+
/**
@ingroup MESSAGES
VERBOSE (morep, WARNING, PRINTF ("field '%s' too large\n", #field)); \
}
+/**
+ @ingroup MESSAGES
+
+ Format an fix table size field
+
+ @param name field name
+ @param field data from structure
+*/
+#define FORMAT_TAB(name, field) \
+ len += snprint_array (_buffer, _maxlen - len, field, sizeof (field)); \
+ if (len == _maxlen) { \
+ VERBOSE (morep, WARNING, PRINTF ("field '%s' too large\n", #field)); \
+ }
+
/**
@ingroup MESSAGES
@param name field name
@param field data from structure
*/
-#define SERIAL_INT(name, field) \
- switch (sizeof (field)) { \
- case 1: \
- if (len < _maxlen) { \
- _buffer[len++] = field; \
- } else { \
- VERBOSE (morep, WARNING, PRINTF ("field '%s' too large\n", name)); \
- len = _maxlen; \
- } \
- break; \
- case 2: \
- if (len + 1 < _maxlen) { \
- *((uint16_t *)(_buffer + len)) = htons ((uint16_t)field); \
- len += 2; \
- } else { \
- VERBOSE (morep, WARNING, PRINTF ("field '%s' too large\n", name)); \
- len = _maxlen; \
- } \
- break; \
- case 4: \
- if (len + 3 < _maxlen) { \
- *((uint32_t *)(_buffer + len)) = htonl ((uint32_t)field); \
- len += 4; \
- } else { \
- VERBOSE (morep, WARNING, PRINTF ("field '%s' too large\n", name)); \
- len = _maxlen; \
- } \
- break; \
+#define SERIAL_INT(name, field) \
+ switch (sizeof (field)) { \
+ case 1: \
+ if (len < _maxlen) { \
+ _buffer[len++] = field; \
+ } else { \
+ VERBOSE (morep, WARNING, PRINTF ("field '%s' too large\n", name)); \
+ len = _maxlen; \
+ } \
+ break; \
+ case 2: \
+ if (len + 1 < _maxlen) { \
+ *((uint16_t *)(_buffer + len)) = htons ((uint16_t)field); \
+ len += 2; \
+ } else { \
+ VERBOSE (morep, WARNING, PRINTF ("field '%s' too large\n", name)); \
+ len = _maxlen; \
+ } \
+ break; \
+ case 4: \
+ if (len + 3 < _maxlen) { \
+ *((uint32_t *)(_buffer + len)) = htonl ((uint32_t)field); \
+ len += 4; \
+ } else { \
+ VERBOSE (morep, WARNING, PRINTF ("field '%s' too large\n", name)); \
+ len = _maxlen; \
+ } \
+ break; \
}
/**
@param name field name
@param field data from structure
*/
-#define SERIAL_DOUBLE(name, field) \
- switch (sizeof (field)) { \
- case 4: \
- if (len + 3 < _maxlen) { \
- *((float *)(_buffer + len)) = field; \
- len += 4; \
- } else { \
- VERBOSE (morep, WARNING, PRINTF ("field '%s' too large\n", name)); \
- len = _maxlen; \
- } \
- break; \
- case 8: \
- if (len + 7 < _maxlen) { \
- *((double *)(_buffer + len)) = field; \
- len += 8; \
- } else { \
- VERBOSE (morep, WARNING, PRINTF ("field '%s' too large\n", name)); \
- len = _maxlen; \
- } \
- break; \
+#define SERIAL_DOUBLE(name, field) \
+ switch (sizeof (field)) { \
+ case 4: \
+ if (len + 3 < _maxlen) { \
+ *((float *)(_buffer + len)) = field; \
+ len += 4; \
+ } else { \
+ VERBOSE (morep, WARNING, PRINTF ("field '%s' too large\n", name)); \
+ len = _maxlen; \
+ } \
+ break; \
+ case 8: \
+ if (len + 7 < _maxlen) { \
+ *((double *)(_buffer + len)) = field; \
+ len += 8; \
+ } else { \
+ VERBOSE (morep, WARNING, PRINTF ("field '%s' too large\n", name)); \
+ len = _maxlen; \
+ } \
+ break; \
}
/**
@param name field name
@param field data from structure
*/
-#define SERIAL_ARRAY(name, field) \
- { \
- int _l = (field##_len < _maxlen - len) ? field##_len : _maxlen - len; \
- memcpy (_buffer + len, field, _l); \
- len += _l; \
- } \
- if (len == _maxlen) { \
- VERBOSE (morep, WARNING, PRINTF ("field '%s' too large\n", name)); \
+#define SERIAL_ARRAY(name, field) \
+ if (field##_len < _maxlen - len) { \
+ memcpy (_buffer + len, field, field##_len); \
+ len += field##_len; \
+ } else { \
+ VERBOSE (morep, WARNING, PRINTF ("field '%s' too large\n", name)); \
+ len = _maxlen; \
+ }
+
+/**
+ @ingroup MESSAGES
+
+ Serialyze an fix table size field
+
+ @param name field name
+ @param field data from structure
+*/
+#define SERIAL_TAB(name, field) \
+ if (sizeof (field) < _maxlen - len) { \
+ memcpy (_buffer + len, field, sizeof (field)); \
+ len += sizeof (field); \
+ } else { \
+ VERBOSE (morep, WARNING, PRINTF ("field '%s' too large\n", name)); \
+ len = _maxlen; \
}
/**
End of serialisation section
*/
-#define END_SERIAL() \
+#define END_SERIAL() \
return len;
/**
Deserialyze to an integer field
@param name field name
- @param field data from structure
+ @param field structure storage
*/
#define DESERIAL_INT(name, field) \
switch (sizeof (field)) { \
Deserialyze to a floating point field
@param name field name
- @param field data from structure
+ @param field structure storage
*/
#define DESERIAL_DOUBLE(name, field) \
switch (sizeof (field)) { \
break; \
}
+/**
+ @ingroup MESSAGES
+
+ Deserialyze to a fix size table field
+
+ @param name field name
+ @param field structure storage
+ @param len table length
+*/
+#define DESERIAL_TAB(name, field) \
+ if (sizeof (field) < end - ptr) { \
+ memcpy (field, ptr, sizeof (field)); \
+ field##_len = sizeof (field); \
+ ptr += field##_len; \
+ } else { \
+ VERBOSE (morep, WARNING, PRINTF ("no data for field '%s'\n", name)); \
+ ptr = end + 1; \
+ }
+
/**
@ingroup MESSAGES
Deserialyze to an array field
@param name field name
- @param field data from structure
+ @param field structure storage
*/
#define DESERIAL_ARRAY(name, field) \
if (field##_len == 0) { \
ptr += field##_len; \
} else { \
VERBOSE (morep, WARNING, PRINTF ("no data for field '%s'\n", name)); \
+ ptr = end + 1; \
}
/**
--- /dev/null
+/*
+ File name : pdu_channel.c
+ Projet : MERLIN
+ Date of creation : 2025/04/08
+ Version : 1.0
+ Copyright : Thales SIX
+ Author : Laurent Mazet <laurent.mazet@thalesgroup.com>
+
+ Description : This file contains functions for channel pdu
+
+ History :
+ - initial version
+*/
+
+#include <stdint.h>
+
+#include "parse.h"
+
+#include "pdu_channel.h"
+
+int parse_channel (char *line, CHANNEL_t *out)
+{
+ BEGIN_PARSE (line)
+ PARSE_INT ("CHANNELID", out->channel_id)
+ PARSE_INT ("KEYID", out->key_id)
+ END_PARSE ()
+}
+
+int format_channel (CHANNEL_t *in, char *buffer, int maxlen)
+{
+ BEGIN_FORMAT (buffer, maxlen)
+ FORMAT_INT ("CHANNELID", in->channel_id)
+ FORMAT_INT ("KEYID", in->key_id)
+ END_FORMAT ()
+}
+
+int serial_channel (CHANNEL_t *in, uint8_t *buffer, int maxlen)
+{
+ BEGIN_SERIAL (buffer, maxlen)
+ SERIAL_INT ("CHANNELID", in->channel_id)
+ SERIAL_INT ("KEYID", in->key_id)
+ END_SERIAL ()
+}
+
+int deserial_channel (uint8_t *buffer, int len, CHANNEL_t *out)
+{
+ BEGIN_DESERIAL (buffer, len)
+ DESERIAL_INT ("CHANNELID", out->channel_id)
+ DESERIAL_INT ("KEYID", out->key_id)
+ END_DESERIAL ()
+}
+
+/* vim: set ts=4 sw=4 si et: */
/*
- File name : channel.h
+ File name : pdu_channel.h
Projet : MERLIN
Date of creation : 2025/04/08
Version : 1.0
Copyright : Thales SIX
Author : Laurent Mazet <laurent.mazet@thalesgroup.com>
- Description : This file contains message definition
+ Description : This file contains functions for channel pdu
History :
- initial version
Deserial channel type fields from a network stream
@param buffer network stream
- @param maxlen buffer limit
+ @param len buffer length
@param out output structure
@return 0 on success
*/
-int deserial_channel (uint8_t *buffer, int maxlen, CHANNEL_t *out);
+int deserial_channel (uint8_t *buffer, int len, CHANNEL_t *out);
__END_DECLS
#include "parse.h"
-#include "clear_data.h"
+#include "pdu_clear_data.h"
int parse_clear_data (char *line, CLEAR_DATA_t *out)
{
BEGIN_PARSE (line)
PARSE_INT ("CHANNEL", out->channel_id)
- PARSE_INT ("BYPASS", out->bypass)
+ PARSE_INT ("BYPASSLEN", out->bypass_len)
+ PARSE_ARRAY ("BYPASS", out->bypass)
PARSE_ARRAY ("DATA", out->data)
END_PARSE ()
}
int format_clear_data (CLEAR_DATA_t *in, char *buffer, int maxlen)
{
- BEGIN_FORMAT (buffer, maxlen);
- FORMAT_INT ("CHANNEL", out->channel_id)
- FORMAT_INT ("BYPASS", out->bypass)
- FORMAT_ARRAY ("DATA", out->data)
+ BEGIN_FORMAT (buffer, maxlen)
+ FORMAT_INT ("CHANNEL", in->channel_id)
+ FORMAT_INT ("BYPASSLEN", in->bypass_len)
+ FORMAT_ARRAY ("BYPASS", in->bypass)
+ FORMAT_ARRAY ("DATA", in->data)
END_FORMAT ()
}
int serial_clear_data (CLEAR_DATA_t *in, uint8_t *buffer, int maxlen)
{
- BEGIN_SERIAL (buffer, maxlen);
- SERIAL_INT (out->channel_id)
- SERIAL_INT (out->bypass)
- SERIAL_ARRAY (out->data)
+ BEGIN_SERIAL (buffer, maxlen)
+ SERIAL_INT ("CHANNEL", in->channel_id)
+ SERIAL_INT ("BYPASSLEN", in->bypass_len)
+ SERIAL_ARRAY ("BYPASS", in->bypass)
+ SERIAL_ARRAY ("DATA", in->data)
END_SERIAL ()
}
+int deserial_clear_data (uint8_t *buffer, int len, CLEAR_DATA_t *out)
+{
+ BEGIN_DESERIAL (buffer, len)
+ DESERIAL_INT ("CHANNEL", out->channel)
+ DESERIAL_INT ("BYPASSLEN", out->bypass_len)
+ DESERIAL_ARRAY ("BYPASS", out->bypass)
+ DESERIAL_ARRAY ("DATA", out->data)
+ END_DESERIAL ()
+}
+
/* vim: set ts=4 sw=4 si et: */
/*
- File name : clear_data.h
+ File name : pdu_clear_data.h
Projet : MERLIN
Date of creation : 2025/04/07
Version : 1.0
Copyright : Thales SIX
Author : Laurent Mazet <laurent.mazet@thalesgroup.com>
- Description : This file contains definition of clear data type
+ Description : This file contains functions for clear data pdu
History :
- initial version
Deserial clear data type fields from a network stream
@param buffer network stream
- @param maxlen buffer limit
+ @param len buffer length
@param out output structure
@return 0 on success
*/
-int deserial_clear_data (uint8_t *buffer, int maxlen, CLEAR_DATA_t *out);
+int deserial_clear_data (uint8_t *buffer, int len, CLEAR_DATA_t *out);
__END_DECLS
--- /dev/null
+/*
+ File name : encrypted_data.c
+ Projet : MERLIN
+ Date of creation : 2025/04/08
+ Version : 1.0
+ Copyright : Thales SIX
+ Author : Laurent Mazet <laurent.mazet@thalesgroup.com>
+
+ Description : This file contains definition of encrypted data type
+
+ History :
+ - initial version
+*/
+
+#include <stdint.h>
+
+#include "parse.h"
+
+#include "pdu_encrypted_data.h"
+
+int parse_encrypted_data (char *line, ENCRYPTED_DATA_t *out)
+{
+ BEGIN_PARSE (line)
+ PARSE_INT ("CHANNEL", out->channel_id)
+ PARSE_TAB ("IV", out->iv)
+ PARSE_INT ("BYPASSLEN", out->bypass_len)
+ PARSE_ARRAY ("BYPASS", out->bypass)
+ PARSE_ARRAY ("DATA", out->data)
+ END_PARSE ()
+}
+
+int format_encrypted_data (ENCRYPTED_DATA_t *in, char *buffer, int maxlen)
+{
+ BEGIN_FORMAT (buffer, maxlen)
+ FORMAT_INT ("CHANNEL", in->channel_id)
+ FORMAT_TAB ("IV", in->iv)
+ FORMAT_INT ("BYPASSLEN", in->bypass_len)
+ FORMAT_ARRAY ("BYPASS", in->bypass)
+ FORMAT_ARRAY ("DATA", in->data)
+ END_FORMAT ()
+}
+
+int serial_encrypted_data (ENCRYPTED_DATA_t *in, uint8_t *buffer, int maxlen)
+{
+ BEGIN_SERIAL (buffer, maxlen)
+ SERIAL_INT ("CHANNEL", in->channel_id)
+ SERIAL_TAB ("IV", in->iv)
+ SERIAL_INT ("BYPASSLEN", in->bypass_len)
+ SERIAL_ARRAY ("BYPASS", in->bypass)
+ SERIAL_ARRAY ("DATA", in->data)
+ END_SERIAL ()
+}
+
+int deserial_encrypted_data (uint8_t *buffer, int len, ENCRYPTED_DATA_t *out)
+{
+ BEGIN_DESERIAL (buffer, len)
+ DESERIAL_INT ("CHANNEL", out->channel)
+ DESERIAL_TAB ("IV", out->iv)
+ DESERIAL_INT ("BYPASSLEN", out->bypass_len)
+ DESERIAL_ARRAY ("BYPASS", out->bypass)
+ DESERIAL_ARRAY ("DATA", out->data)
+ END_DESERIAL ()
+}
+
+/* vim: set ts=4 sw=4 si et: */
/*
- File name : message.h
+ File name : pdu_encrypted_data.h
Projet : MERLIN
- Date of creation : 2025/04/03
+ Date of creation : 2025/04/08
Version : 1.0
Copyright : Thales SIX
Author : Laurent Mazet <laurent.mazet@thalesgroup.com>
- Description : This file contains message definition
+ Description : This file contains functions for encrypted data pdu
History :
- initial version
*/
-#ifndef __MESSAGE_H__
-#define __MESSAGE_H__
+#ifndef __ENCRYPTED_DATA_H__
+#define __ENCRYPTED_DATA_H__
#include <stdint.h>
#include <sys/cdefs.h>
*/
typedef struct {
uint8_t channel_id; /**< channel index */
+ uint8_t iv[12]; /**< initial vector */
uint8_t bypass_len; /**< attached bypass message length */
uint8_t bypass_msg[255]; /**< attached bypass message */
uint8_t data_len; /**< data length (must be aligned to 16 bytes) */
uint8_t data[1472]; /**< data message */
- uint8_t iv[12]; /**< initial vector */
} ENCRYPTED_DATA_t;
/**
@ingroup MESSAGES
- Parse a string containing some clear data type fields
+ Parse a string containing some encrypted data type fields
@param line string to analyse
@param out output structure
@return 0 on success
*/
-int parse_clear_data (char *line, CLEAR_DATA_t *out);
+int parse_encrypted_data (char *line, ENCRYPTED_DATA_t *out);
/**
@ingroup MESSAGES
- Format clear data type fields into a string
+ Format encrypted data type fields into a string
@param in input structure
@param buffer output string
@param maxlen buffer limit
@return 0 on success
*/
-int format_clear_data (CLEAR_DATA_t *in, char *buffer, int maxlen);
+int format_encrypted_data (ENCRYPTED_DATA_t *in, char *buffer, int maxlen);
/**
@ingroup MESSAGES
- Serial clear data type fields into a network stream
+ Serial encrypted data type fields into a network stream
@param in input structure
@param buffer network stream
@param maxlen buffer limit
@return buffer length
*/
-int serial_clear_data (CLEAR_DATA_t *in, uint8_t *buffer, int maxlen);
+int serial_encrypted_data (ENCRYPTED_DATA_t *in, uint8_t *buffer, int maxlen);
/**
@ingroup MESSAGES
- Deserial clear data type fields from a network stream
+ Deserial encrypted data type fields from a network stream
@param buffer network stream
- @param maxlen buffer limit
+ @param len buffer length
@param out output structure
@return 0 on success
*/
-int deserial_clear_data (uint8_t *buffer, int maxlen, CLEAR_DATA_t *out);
+int deserial_encrypted_data (uint8_t *buffer, int len, ENCRYPTED_DATA_t *out);
__END_DECLS
-#endif /* __MESSAGE_H__ */
+#endif /* __ENCRYPTED_DATA_H__ */
/* vim: set ts=4 sw=4 si et: */
--- /dev/null
+/*
+ File name : pdu_key.c
+ Projet : MERLIN
+ Date of creation : 2025/04/08
+ Version : 1.0
+ Copyright : Thales SIX
+ Author : Laurent Mazet <laurent.mazet@thalesgroup.com>
+
+ Description : This file contains functions for key pdu
+
+ History :
+ - initial version
+*/
+
+#include <stdint.h>
+
+#include "parse.h"
+
+#include "pdu_key.h"
+
+int parse_key (char *line, KEY_t *out)
+{
+ BEGIN_PARSE (line)
+ PARSE_INT ("KEYID", out->key_id)
+ PARSE_INT ("KEYLEN", out->key_len)
+ PARSE_ARRAY ("KEY", out->key)
+ END_PARSE ()
+}
+
+int format_key (KEY_t *in, char *buffer, int maxlen)
+{
+ BEGIN_FORMAT (buffer, maxlen)
+ FORMAT_INT ("KEYID", in->key_id)
+ FORMAT_INT ("KEYLEN", in->key_len)
+ FORMAT_ARRAY ("KEY", in->key)
+ END_FORMAT ()
+}
+
+int serial_key (KEY_t *in, uint8_t *buffer, int maxlen)
+{
+ BEGIN_SERIAL (buffer, maxlen)
+ SERIAL_INT ("KEYID", in->key_id)
+ SERIAL_INT ("KEYLEN", in->key_len)
+ SERIAL_ARRAY ("KEY", in->key)
+ END_SERIAL ()
+}
+
+int deserial_key (uint8_t *buffer, int len, KEY_t *out)
+{
+ BEGIN_DESERIAL (buffer, len)
+ DESERIAL_INT ("KEYID", out->key_id)
+ DESERIAL_INT ("KEYLEN", out->key_len)
+ DESERIAL_ARRAY ("KEY", out->key)
+ END_DESERIAL ()
+}
+
+/* vim: set ts=4 sw=4 si et: */
/*
- File name : message.h
+ File name : pdu_key.h
Projet : MERLIN
- Date of creation : 2025/04/03
+ Date of creation : 2025/04/08
Version : 1.0
Copyright : Thales SIX
Author : Laurent Mazet <laurent.mazet@thalesgroup.com>
- Description : This file contains message definition
+ Description : This file contains functions for key pdu
History :
- initial version
*/
-#ifndef __MESSAGE_H__
-#define __MESSAGE_H__
+#ifndef __KEY_H__
+#define __KEY_H__
#include <stdint.h>
#include <sys/cdefs.h>
Key type
*/
typedef struct {
+ uint8_t key_id; /**< key id */
uint16_t key_len; /**< key length */
uint8_t key[1495]; /**< raw key */
} KEY_t;
/**
@ingroup MESSAGES
- Parse a string containing some clear data type fields
+ Parse a string containing some key type fields
@param line string to analyse
@param out output structure
@return 0 on success
*/
-int parse_clear_data (char *line, CLEAR_DATA_t *out);
+int parse_key (char *line, KEY_t *out);
/**
@ingroup MESSAGES
- Format clear data type fields into a string
+ Format key type fields into a string
@param in input structure
@param buffer output string
@param maxlen buffer limit
@return 0 on success
*/
-int format_clear_data (CLEAR_DATA_t *in, char *buffer, int maxlen);
+int format_key (KEY_t *in, char *buffer, int maxlen);
/**
@ingroup MESSAGES
- Serial clear data type fields into a network stream
+ Serial key type fields into a network stream
@param in input structure
@param buffer network stream
@param maxlen buffer limit
@return buffer length
*/
-int serial_clear_data (CLEAR_DATA_t *in, uint8_t *buffer, int maxlen);
+int serial_key (KEY_t *in, uint8_t *buffer, int maxlen);
/**
@ingroup MESSAGES
- Deserial clear data type fields from a network stream
+ Deserial key type fields from a network stream
@param buffer network stream
- @param maxlen buffer limit
+ @param len buffer length
@param out output structure
@return 0 on success
*/
-int deserial_clear_data (uint8_t *buffer, int maxlen, CLEAR_DATA_t *out);
+int deserial_key (uint8_t *buffer, int len, KEY_t *out);
__END_DECLS
-#endif /* __MESSAGE_H__ */
+#endif /* __KEY_H__ */
/* vim: set ts=4 sw=4 si et: */
--- /dev/null
+/*
+ File name : pdu_prng_param.c
+ Projet : MERLIN
+ Date of creation : 2025/04/08
+ Version : 1.0
+ Copyright : Thales SIX
+ Author : Laurent Mazet <laurent.mazet@thalesgroup.com>
+
+ Description : This file contains functions for PRNG parameter pdu
+
+ History :
+ - initial version
+*/
+
+#include <stdint.h>
+
+#include "parse.h"
+
+#include "pdu_key.h"
+
+int parse_prng_param (char *line, PRNG_PARAM_t *out)
+{
+ BEGIN_PARSE (line)
+ PARSE_INT ("PRNGID", out->prng_id)
+ PARSE_INT ("SEEDLEN", out->seed_len)
+ PARSE_ARRAY ("SEED", out->seed)
+ END_PARSE ()
+}
+
+int format_prng_param (PRNG_PARAM_t *in, char *buffer, int maxlen)
+{
+ BEGIN_FORMAT (buffer, maxlen)
+ FORMAT_INT ("PRNGID", in->prng_id)
+ FORMAT_INT ("SEEDLEN", in->seed_len)
+ FORMAT_ARRAY ("SEED", in->seed)
+ END_FORMAT ()
+}
+
+int serial_prng_param (PRNG_PARAM_t *in, uint8_t *buffer, int maxlen)
+{
+ BEGIN_SERIAL (buffer, maxlen)
+ SERIAL_INT ("PRNGID", in->prng_id)
+ SERIAL_INT ("SEEDLEN", in->seed_len)
+ SERIAL_ARRAY ("SEED", in->seed)
+ END_SERIAL ()
+}
+
+int deserial_prng_param (uint8_t *buffer, int len, PRNG_PARAM_t *out)
+{
+ BEGIN_DESERIAL (buffer, len)
+ DESERIAL_INT ("PRNGID", out->prng_id)
+ DESERIAL_INT ("SEEDLEN", out->seed_len)
+ DESERIAL_ARRAY ("SEED", out->seed)
+ END_DESERIAL ()
+}
+
+/* vim: set ts=4 sw=4 si et: */
/*
- File name : message.h
+ File name : pdu_prng_param.h
Projet : MERLIN
- Date of creation : 2025/04/03
+ Date of creation : 2025/04/08
Version : 1.0
Copyright : Thales SIX
Author : Laurent Mazet <laurent.mazet@thalesgroup.com>
- Description : This file contains message definition
+ Description : This file contains functions for PRNG parameter PDU
History :
- initial version
*/
-#ifndef __MESSAGE_H__
-#define __MESSAGE_H__
+#ifndef __PRNG_PARAM_H__
+#define __PRNG_PARAM_H__
#include <stdint.h>
#include <sys/cdefs.h>
/**
@ingroup MESSAGES
- Parse a string containing some clear data type fields
+ Parse a string containing some PRNG parameter type fields
@param line string to analyse
@param out output structure
@return 0 on success
*/
-int parse_clear_data (char *line, CLEAR_DATA_t *out);
+int parse_prng_param (char *line, PRNG_PARAM_t *out);
/**
@ingroup MESSAGES
- Format clear data type fields into a string
+ Format PRNG parameter type fields into a string
@param in input structure
@param buffer output string
@param maxlen buffer limit
@return 0 on success
*/
-int format_clear_data (CLEAR_DATA_t *in, char *buffer, int maxlen);
+int format_prng_param (PRNG_PARAM_t *in, char *buffer, int maxlen);
/**
@ingroup MESSAGES
- Serial clear data type fields into a network stream
+ Serial PRNG parameter type fields into a network stream
@param in input structure
@param buffer network stream
@param maxlen buffer limit
@return buffer length
*/
-int serial_clear_data (CLEAR_DATA_t *in, uint8_t *buffer, int maxlen);
+int serial_prng_param (PRNG_PARAM_t *in, uint8_t *buffer, int maxlen);
/**
@ingroup MESSAGES
- Deserial clear data type fields from a network stream
+ Deserial PRNG parameter type fields from a network stream
@param buffer network stream
- @param maxlen buffer limit
+ @param len buffer length
@param out output structure
@return 0 on success
*/
-int deserial_clear_data (uint8_t *buffer, int maxlen, CLEAR_DATA_t *out);
+int deserial_prng_param (uint8_t *buffer, int len, PRNG_PARAM_t *out);
__END_DECLS
-#endif /* __MESSAGE_H__ */
+#endif /* __PRNG_PARAM_H__ */
/* vim: set ts=4 sw=4 si et: */
#include "parse.h"
-#include "raw_data.h"
+#include "pdu_raw_data.h"
int parse_raw_data (char *line, RAW_DATA_t *out)
{
END_SERIAL ()
}
-int deserial_raw_data (uint8_t *buffer, int maxlen, RAW_DATA_t *out)
+int deserial_raw_data (uint8_t *buffer, int len, RAW_DATA_t *out)
{
- BEGIN_DESERIAL (buffer, maxlen)
+ BEGIN_DESERIAL (buffer, len)
DESERIAL_ARRAY ("DATA", out->data)
END_DESERIAL ()
}
/*
- File name : raw_data.h
+ File name : pdu_raw_data.h
Projet : MERLIN
Date of creation : 2025/04/07
Version : 1.0
Copyright : Thales SIX
Author : Laurent Mazet <laurent.mazet@thalesgroup.com>
- Description : This file contains definition of raw data type
+ Description : This file contains functions for raw data pdu
History :
- initial version
Deserial raw data type fields from a network stream
@param buffer network stream
- @param maxlen buffer limit
+ @param len buffer length
@param out output structure
@return 0 on success
*/
-int deserial_raw_data (uint8_t *buffer, int maxlen, RAW_DATA_t *out);
+int deserial_raw_data (uint8_t *buffer, int len, RAW_DATA_t *out);
__END_DECLS
--- /dev/null
+/*
+ File name : pdu_status.c
+ Projet : MERLIN
+ Date of creation : 2025/04/08
+ Version : 1.0
+ Copyright : Thales SIX
+ Author : Laurent Mazet <laurent.mazet@thalesgroup.com>
+
+ Description : This file contains functions for status pdu
+
+ History :
+ - initial version
+*/
+
+#include <stdint.h>
+
+#include "parse.h"
+
+#include "pdu_status.h"
+
+int parse_status (char *line, STATUS_t *out)
+{
+ BEGIN_PARSE (line)
+ PARSE_INT ("STATUS", out->status)
+ END_PARSE ()
+}
+
+int format_status (STATUS_t *in, char *buffer, int maxlen)
+{
+ BEGIN_FORMAT (buffer, maxlen)
+ FORMAT_INT ("STATUS", in->status)
+ END_FORMAT ()
+}
+
+int serial_status (STATUS_t *in, uint8_t *buffer, int maxlen)
+{
+ BEGIN_SERIAL (buffer, maxlen)
+ SERIAL_INT ("STATUS", in->status)
+ END_SERIAL ()
+}
+
+int deserial_status (uint8_t *buffer, int len, STATUS_t *out)
+{
+ BEGIN_DESERIAL (buffer, len)
+ DESERIAL_INT ("STATUS", out->status)
+ END_DESERIAL ()
+}
+
+/* vim: set ts=4 sw=4 si et: */
/*
- File name : message.h
+ File name : pdu_status.h
Projet : MERLIN
- Date of creation : 2025/04/03
+ Date of creation : 2025/04/08
Version : 1.0
Copyright : Thales SIX
Author : Laurent Mazet <laurent.mazet@thalesgroup.com>
- Description : This file contains message definition
+ Description : This file contains functions for status pdu
History :
- initial version
*/
-#ifndef __MESSAGE_H__
-#define __MESSAGE_H__
+#ifndef __STATUS_H__
+#define __STATUS_H__
#include <stdint.h>
#include <sys/cdefs.h>
/**
@ingroup MESSAGES
- Parse a string containing some clear data type fields
+ Parse a string containing some status type fields
@param line string to analyse
@param out output structure
@return 0 on success
*/
-int parse_clear_data (char *line, CLEAR_DATA_t *out);
+int parse_status (char *line, STATUS_t *out);
/**
@ingroup MESSAGES
- Format clear data type fields into a string
+ Format status type fields into a string
@param in input structure
@param buffer output string
@param maxlen buffer limit
@return 0 on success
*/
-int format_clear_data (CLEAR_DATA_t *in, char *buffer, int maxlen);
+int format_status (STATUS_t *in, char *buffer, int maxlen);
/**
@ingroup MESSAGES
- Serial clear data type fields into a network stream
+ Serial status type fields into a network stream
@param in input structure
@param buffer network stream
@param maxlen buffer limit
@return buffer length
*/
-int serial_clear_data (CLEAR_DATA_t *in, uint8_t *buffer, int maxlen);
+int serial_status (STATUS_t *in, uint8_t *buffer, int maxlen);
/**
@ingroup MESSAGES
- Deserial clear data type fields from a network stream
+ Deserial status type fields from a network stream
@param buffer network stream
- @param maxlen buffer limit
+ @param len buffer length
@param out output structure
@return 0 on success
*/
-int deserial_clear_data (uint8_t *buffer, int maxlen, CLEAR_DATA_t *out);
+int deserial_status (uint8_t *buffer, int len, STATUS_t *out);
__END_DECLS
-#endif /* __MESSAGE_H__ */
+#endif /* __STATUS_H__ */
/* vim: set ts=4 sw=4 si et: */