As machine byte order may vary. Ensure TLV_PORT_STATS_NP statistics use defined order.
As most of us use little endian hardware and to retain backward compatible with most of us, we decide to use little endian for the statistics. All other TLVs messages remain in network order. Signed-off-by: Erez Geva <erez.geva....@siemens.com> --- tlv.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tlv.c b/tlv.c index 98ef6e1..549f2b9 100644 --- a/tlv.c +++ b/tlv.c @@ -128,6 +128,7 @@ static int mgt_post_recv(struct management_tlv *m, uint16_t data_len, int extra_len = 0, len; uint8_t *buf; uint16_t u16; + int i; switch (m->id) { case TLV_CLOCK_DESCRIPTION: cd = &extra->cd; @@ -324,6 +325,10 @@ static int mgt_post_recv(struct management_tlv *m, uint16_t data_len, psn = (struct port_stats_np *)m->data; psn->portIdentity.portNumber = ntohs(psn->portIdentity.portNumber); + for (i = 0 ; i < MAX_MESSAGE_TYPES; i++) { + psn->stats.rxMsgType[i] = __le64_to_cpu(psn->stats.rxMsgType[i]); + psn->stats.txMsgType[i] = __le64_to_cpu(psn->stats.txMsgType[i]); + } extra_len = sizeof(struct port_stats_np); break; case TLV_SAVE_IN_NON_VOLATILE_STORAGE: @@ -349,6 +354,7 @@ bad_length: static void mgt_pre_send(struct management_tlv *m, struct tlv_extra *extra) { + int i; struct defaultDS *dds; struct currentDS *cds; struct parentDS *pds; @@ -436,6 +442,10 @@ static void mgt_pre_send(struct management_tlv *m, struct tlv_extra *extra) psn = (struct port_stats_np *)m->data; psn->portIdentity.portNumber = htons(psn->portIdentity.portNumber); + for (i = 0 ; i < MAX_MESSAGE_TYPES; i++) { + psn->stats.rxMsgType[i] = __cpu_to_le64(psn->stats.rxMsgType[i]); + psn->stats.txMsgType[i] = __cpu_to_le64(psn->stats.txMsgType[i]); + } break; } } -- 2.20.1 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel