Skip to content
Permalink
Browse files

net: gptp: Fix sync follow up packets content

The issue was that the length field of the tlv extension in the sync
follow up packets was wrong. It is supposed to skip the length of the
header of that extension. The easiest fix was separating the header and
the actual contents into separate structs and that's what this commit
does.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
  • Loading branch information...
tgorochowik authored and jukkar committed May 8, 2018
1 parent cf272e6 commit b422d38650b265cad645471d89f200a18a4ca524
Showing with 6 additions and 3 deletions.
  1. +2 −2 subsys/net/l2/ethernet/gptp/gptp_md.c
  2. +4 −1 subsys/net/l2/ethernet/gptp/gptp_messages.h
@@ -61,8 +61,8 @@ static void gptp_md_follow_up_prepare(struct net_pkt *pkt,
fup->prec_orig_ts_nsecs =
htonl(sync_send->precise_orig_ts.nanosecond);

fup->tlv.type = htons(GPTP_TLV_ORGANIZATION_EXT);
fup->tlv.len = htons(sizeof(struct gptp_follow_up_tlv));
fup->tlv_hdr.type = htons(GPTP_TLV_ORGANIZATION_EXT);
fup->tlv_hdr.len = htons(sizeof(struct gptp_follow_up_tlv));
fup->tlv.org_id[0] = GPTP_FUP_TLV_ORG_ID_BYTE_0;
fup->tlv.org_id[1] = GPTP_FUP_TLV_ORG_ID_BYTE_1;
fup->tlv.org_id[2] = GPTP_FUP_TLV_ORG_ID_BYTE_2;
@@ -190,13 +190,15 @@ struct gptp_sync {
u8_t reserved[10];
} __packed;

struct gptp_follow_up_tlv {
struct gptp_follow_up_tlv_hdr {
/** TLV type: 0x3. */
u16_t type;

/** Length: 28. */
u16_t len;
} __packed;

struct gptp_follow_up_tlv {
/** Organization Id: 00-80-C2. */
u8_t org_id[3];

@@ -227,6 +229,7 @@ struct gptp_follow_up {
u32_t prec_orig_ts_nsecs;

/** Follow up TLV. */
struct gptp_follow_up_tlv_hdr tlv_hdr;
struct gptp_follow_up_tlv tlv;
} __packed;

0 comments on commit b422d38

Please sign in to comment.
You can’t perform that action at this time.