From 2722b8587d07b83a62ebb22521ab38c4295431e5 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Sat, 1 Dec 2012 08:27:45 +0100 Subject: [PATCH] Convert the default data set TLV to and from host byte order. Signed-off-by: Richard Cochran --- tlv.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tlv.c b/tlv.c index f93947e..4921b4b 100644 --- a/tlv.c +++ b/tlv.c @@ -40,9 +40,16 @@ static void scaled_ns_h2n(ScaledNs *sns) static void mgt_post_recv(struct management_tlv *m) { + struct defaultDS *dds; struct currentDS *cds; struct time_status_np *tsn; switch (m->id) { + case DEFAULT_DATA_SET: + dds = (struct defaultDS *) m->data; + dds->numberPorts = ntohs(dds->numberPorts); + dds->clockQuality.offsetScaledLogVariance = + ntohs(dds->clockQuality.offsetScaledLogVariance); + break; case CURRENT_DATA_SET: cds = (struct currentDS *) m->data; cds->stepsRemoved = ntohs(cds->stepsRemoved); @@ -64,9 +71,16 @@ static void mgt_post_recv(struct management_tlv *m) static void mgt_pre_send(struct management_tlv *m) { + struct defaultDS *dds; struct currentDS *cds; struct time_status_np *tsn; switch (m->id) { + case DEFAULT_DATA_SET: + dds = (struct defaultDS *) m->data; + dds->numberPorts = htons(dds->numberPorts); + dds->clockQuality.offsetScaledLogVariance = + htons(dds->clockQuality.offsetScaledLogVariance); + break; case CURRENT_DATA_SET: cds = (struct currentDS *) m->data; cds->stepsRemoved = htons(cds->stepsRemoved);