From e21280ef774bcee06ef6345bba94341003e72217 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Sun, 2 Dec 2012 08:53:54 +0100 Subject: [PATCH] Convert the parent data set TLV to and from host byte order. Signed-off-by: Richard Cochran --- tlv.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tlv.c b/tlv.c index 4921b4b..07da7be 100644 --- a/tlv.c +++ b/tlv.c @@ -42,6 +42,7 @@ static void mgt_post_recv(struct management_tlv *m) { struct defaultDS *dds; struct currentDS *cds; + struct parentDS *pds; struct time_status_np *tsn; switch (m->id) { case DEFAULT_DATA_SET: @@ -56,6 +57,17 @@ static void mgt_post_recv(struct management_tlv *m) cds->offsetFromMaster = net2host64(cds->offsetFromMaster); cds->meanPathDelay = net2host64(cds->meanPathDelay); break; + case PARENT_DATA_SET: + pds = (struct parentDS *) m->data; + pds->parentPortIdentity.portNumber = + ntohs(pds->parentPortIdentity.portNumber); + pds->observedParentOffsetScaledLogVariance = + ntohs(pds->observedParentOffsetScaledLogVariance); + pds->observedParentClockPhaseChangeRate = + ntohl(pds->observedParentClockPhaseChangeRate); + pds->grandmasterClockQuality.offsetScaledLogVariance = + ntohs(pds->grandmasterClockQuality.offsetScaledLogVariance); + break; case TIME_STATUS_NP: tsn = (struct time_status_np *) m->data; tsn->master_offset = net2host64(tsn->master_offset); @@ -73,6 +85,7 @@ static void mgt_pre_send(struct management_tlv *m) { struct defaultDS *dds; struct currentDS *cds; + struct parentDS *pds; struct time_status_np *tsn; switch (m->id) { case DEFAULT_DATA_SET: @@ -87,6 +100,17 @@ static void mgt_pre_send(struct management_tlv *m) cds->offsetFromMaster = host2net64(cds->offsetFromMaster); cds->meanPathDelay = host2net64(cds->meanPathDelay); break; + case PARENT_DATA_SET: + pds = (struct parentDS *) m->data; + pds->parentPortIdentity.portNumber = + htons(pds->parentPortIdentity.portNumber); + pds->observedParentOffsetScaledLogVariance = + htons(pds->observedParentOffsetScaledLogVariance); + pds->observedParentClockPhaseChangeRate = + htonl(pds->observedParentClockPhaseChangeRate); + pds->grandmasterClockQuality.offsetScaledLogVariance = + htons(pds->grandmasterClockQuality.offsetScaledLogVariance); + break; case TIME_STATUS_NP: tsn = (struct time_status_np *) m->data; tsn->master_offset = host2net64(tsn->master_offset);