Reading the IEC 61375-2-3 spec, it is clear that the payload size of all teh packets is always a multiple of 4 bytes. Furthmore all the fields that exceed the 4-byte boundary in size are properly aligned and possibly
If I understand correctly, structs marked with GNU_PACKED can be sent as payload of TRDP packets.
When a field of a GNU_PACKED struct is of the type TRDP_LABEL_T, the correct alignment is lost. This because TRDP_LABEL_T is 17 bytes long since it is defined like this (in trdp_types.h and iec-61375-2-3.h):
#define TRDP_MAX_LABEL_LEN 16u
typedef CHAR8 TRDP_LABEL_T[TRDP_MAX_LABEL_LEN + 1]
I propose to define another type, i.e. TRDP_PACKED_LABEL_T to be used in the GNU_PACKED structs:
typedef CHAR8 TRDP_PACKED_LABEL_T[TRDP_MAX_LABEL_LEN]
This together with a pair of functions to copy data from TRDP_LABEL_T to TRDP_PACKED_LABEL_T and vice-versa without overflow.
Please evaluate the attached patch.
Sorry, I don't know why I cannot edit my post. The correct and complete version of the initial sentences is:
Yes, you're right - the packets defined in the utility functions will be corrected.