all pdu defined
authorLaurent Mazet <mazet@softndesign.org>
Tue, 8 Apr 2025 22:15:09 +0000 (00:15 +0200)
committerLaurent Mazet <mazet@softndesign.org>
Tue, 8 Apr 2025 22:15:09 +0000 (00:15 +0200)
16 files changed:
morep_valid.c
parse.h
pdu_channel.c [new file with mode: 0644]
pdu_channel.h
pdu_clear_data.c
pdu_clear_data.h
pdu_encrypted_data.c [new file with mode: 0644]
pdu_encrypted_data.h
pdu_key.c [new file with mode: 0644]
pdu_key.h
pdu_prng_param.c [new file with mode: 0644]
pdu_prng_param.h
pdu_raw_data.c
pdu_raw_data.h
pdu_status.c [new file with mode: 0644]
pdu_status.h

index 51e97365b5995de5c5a5cfc307c7f8d5063d0982..bfd84ad9aca2c3e88afab0b7c6edc9fa0cc9b550 100644 (file)
@@ -14,8 +14,8 @@
 
 /* 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>
@@ -29,7 +29,7 @@
 #include "parse.h"
 #include "verbose.h"
 
-#include "raw_data.h"
+#include "pdu_raw_data.h"
 
 char *progname = NULL;
 
diff --git a/parse.h b/parse.h
index 53c6a3287fda19d11eac83d197e4dc56102264d0..d2e3046912eea03cfff2858aa4f83d39c39c8eed 100644 (file)
--- a/parse.h
+++ b/parse.h
@@ -121,6 +121,19 @@ __BEGIN_DECLS
             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
 
@@ -191,6 +204,20 @@ __BEGIN_DECLS
         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
 
@@ -220,34 +247,34 @@ __BEGIN_DECLS
    @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;                                                                 \
     }
 
 /**
@@ -258,26 +285,26 @@ __BEGIN_DECLS
    @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;                                                                 \
     }
 
 /**
@@ -288,14 +315,30 @@ __BEGIN_DECLS
    @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;                                                     \
     }
 
 /**
@@ -303,7 +346,7 @@ __BEGIN_DECLS
 
    End of serialisation section
 */
-#define END_SERIAL()         \
+#define END_SERIAL() \
     return len;
 
 /**
@@ -325,7 +368,7 @@ __BEGIN_DECLS
    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)) {                                                    \
@@ -363,7 +406,7 @@ __BEGIN_DECLS
    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)) {                                                    \
@@ -387,13 +430,32 @@ __BEGIN_DECLS
         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) {                                                  \
@@ -405,6 +467,7 @@ __BEGIN_DECLS
         ptr += field##_len;                                                  \
     } else {                                                                 \
         VERBOSE (morep, WARNING, PRINTF ("no data for field '%s'\n", name)); \
+        ptr = end + 1;                                                       \
     }
 
 /**
diff --git a/pdu_channel.c b/pdu_channel.c
new file mode 100644 (file)
index 0000000..39162ee
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+  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: */
index 4a7eb793261651a6631b4935894b26d1a0a25be1..3f15847d4a51d4b2359850dd1a40da0998c17c74 100644 (file)
@@ -1,12 +1,12 @@
 /*
-  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
@@ -71,11 +71,11 @@ int serial_channel (CHANNEL_t *in, uint8_t *buffer, int maxlen);
    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
 
index f5840bcfb61db4a8708fbed0bb8d25dafdd047e4..4a64fabe830c3734b33986c13f5f2d6a70ff54ee 100644 (file)
 
 #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: */
index 29da2f9737d0958ad79288c2a4d50f4237f37f6a..18021566aaf5c09f860c0bef5f63093abc1c930b 100644 (file)
@@ -1,12 +1,12 @@
 /*
-  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
@@ -74,11 +74,11 @@ int serial_clear_data (CLEAR_DATA_t *in, uint8_t *buffer, int maxlen);
    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
 
diff --git a/pdu_encrypted_data.c b/pdu_encrypted_data.c
new file mode 100644 (file)
index 0000000..7382220
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+  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: */
index f4780a2b27fe5190a79a0e7714d929d26b189759..6cc93d012025fa452e59a1a44ebbab165b92dbb1 100644 (file)
@@ -1,19 +1,19 @@
 /*
-  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>
@@ -27,62 +27,62 @@ __BEGIN_DECLS
 */
 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: */
diff --git a/pdu_key.c b/pdu_key.c
new file mode 100644 (file)
index 0000000..d5089aa
--- /dev/null
+++ b/pdu_key.c
@@ -0,0 +1,57 @@
+/*
+  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: */
index 560fc9cb90fc97a549000963dff0701a026d959d..fb23468d247065691c1aaa149fc6075acc5f30c5 100644 (file)
--- a/pdu_key.h
+++ b/pdu_key.h
@@ -1,19 +1,19 @@
 /*
-  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>
@@ -26,6 +26,7 @@ __BEGIN_DECLS
    Key type
 */
 typedef struct {
+    uint8_t key_id; /**< key id */
     uint16_t key_len; /**< key length */
     uint8_t key[1495]; /**< raw key */
 } KEY_t;
@@ -33,52 +34,52 @@ typedef struct {
 /**
    @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: */
diff --git a/pdu_prng_param.c b/pdu_prng_param.c
new file mode 100644 (file)
index 0000000..9425bbd
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+  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: */
index 79335cdbdc7a220e78ac2fe8d8941cf162b0ba33..319d901ab4e1018fa7e5408afa2e6b7fd76c0c97 100644 (file)
@@ -1,19 +1,19 @@
 /*
-  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>
@@ -34,52 +34,52 @@ typedef struct {
 /**
    @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: */
index b9c6ec20844db24d8ff169acb9baec363bd25c54..8a7878902f4b96a72f5a41238ac09535399aec3a 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "parse.h"
 
-#include "raw_data.h"
+#include "pdu_raw_data.h"
 
 int parse_raw_data (char *line, RAW_DATA_t *out)
 {
@@ -39,9 +39,9 @@ int serial_raw_data (RAW_DATA_t *in, uint8_t *buffer, int maxlen)
     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 ()
 }
index 1153888616dda48a56be15a23f3fbc2dbebef25d..cf525cd19554e61b5585abebbe0c52c5556f7cd4 100644 (file)
@@ -1,12 +1,12 @@
 /*
-  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
@@ -71,11 +71,11 @@ int serial_raw_data (RAW_DATA_t *in, uint8_t *buffer, int maxlen);
    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
 
diff --git a/pdu_status.c b/pdu_status.c
new file mode 100644 (file)
index 0000000..ba17b23
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+  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: */
index 5b3d32683b046b16db287e7350758c181bb1e111..218620f1b48700ad515cf93a7241398ed95c1fa5 100644 (file)
@@ -1,19 +1,19 @@
 /*
-  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>
@@ -32,52 +32,52 @@ typedef struct {
 /**
    @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: */