On Wed, Jul 13, 2022 at 09:30:19AM +0300, Magnus Armholt wrote:
> Strip the IEC62439-3 PRP trailer if it is present
> to support PTP over PRP.
> The implementation is very pedantic about
> trailing bytes and will indicate bad message if the
> PRP trailer bytes are present when parsing the PTP message.
> +static int has_prp_trailer(unsigned char *ptr, int cnt)
> +{
> + unsigned short suffix_id, lane_size_field, lsdu_size;
> +
> + if (cnt < PRP_TRAILER_LEN)
> + return -1;
I thought the function would also cast ptr to ptp_header and check
that the PTP message length is equal to cnt - PRP_TRAILER_LEN before
looking at the trailer in order to avoid false positives causing
corruption of non-PRP frames.
> + /* verify also that the size in the RCT matches */
> + lane_size_field = ntohs(*(unsigned short*)(ptr + (cnt - 4)));
> + // size is lower 12 bits
This is a C++-style comment.
> + lsdu_size = (lane_size_field & 0x0FFF);
> + if (lsdu_size == cnt)
> + return 0;
> +
> + return -1;
A function which has "has" in its name should return 0 (false) or 1
(true), instead of success (0) or error (-1).
--
Miroslav Lichvar
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel