From 28c08dfac6932fc5c9313a51e32a9e5bf3d9da2c Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Sun, 2 Dec 2012 20:34:44 +0100 Subject: [PATCH] Convert the port data set TLV to and from host byte order. Signed-off-by: Richard Cochran --- ds.h | 13 +++++++++++++ tlv.c | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/ds.h b/ds.h index c216616..e96afaf 100644 --- a/ds.h +++ b/ds.h @@ -88,6 +88,19 @@ struct timePropertiesDS { Enumeration8 timeSource; } PACKED; +struct portDS { + struct PortIdentity portIdentity; + Enumeration8 portState; + Integer8 logMinDelayReqInterval; + TimeInterval peerMeanPathDelay; + Integer8 logAnnounceInterval; + UInteger8 announceReceiptTimeout; + Integer8 logSyncInterval; + Enumeration8 delayMechanism; + Integer8 logMinPdelayReqInterval; + UInteger8 versionNumber; +} PACKED; + struct port_defaults { Integer8 logAnnounceInterval; Integer8 logSyncInterval; diff --git a/tlv.c b/tlv.c index b5ac4c7..7b19969 100644 --- a/tlv.c +++ b/tlv.c @@ -44,6 +44,7 @@ static void mgt_post_recv(struct management_tlv *m) struct currentDS *cds; struct parentDS *pds; struct timePropertiesDS *tp; + struct portDS *p; struct time_status_np *tsn; switch (m->id) { case DEFAULT_DATA_SET: @@ -73,6 +74,11 @@ static void mgt_post_recv(struct management_tlv *m) tp = (struct timePropertiesDS *) m->data; tp->currentUtcOffset = ntohs(tp->currentUtcOffset); break; + case PORT_DATA_SET: + p = (struct portDS *) m->data; + p->portIdentity.portNumber = ntohs(p->portIdentity.portNumber); + p->peerMeanPathDelay = net2host64(p->peerMeanPathDelay); + break; case TIME_STATUS_NP: tsn = (struct time_status_np *) m->data; tsn->master_offset = net2host64(tsn->master_offset); @@ -92,6 +98,7 @@ static void mgt_pre_send(struct management_tlv *m) struct currentDS *cds; struct parentDS *pds; struct timePropertiesDS *tp; + struct portDS *p; struct time_status_np *tsn; switch (m->id) { case DEFAULT_DATA_SET: @@ -121,6 +128,11 @@ static void mgt_pre_send(struct management_tlv *m) tp = (struct timePropertiesDS *) m->data; tp->currentUtcOffset = htons(tp->currentUtcOffset); break; + case PORT_DATA_SET: + p = (struct portDS *) m->data; + p->portIdentity.portNumber = htons(p->portIdentity.portNumber); + p->peerMeanPathDelay = host2net64(p->peerMeanPathDelay); + break; case TIME_STATUS_NP: tsn = (struct time_status_np *) m->data; tsn->master_offset = host2net64(tsn->master_offset);