Convert the port data set TLV to and from host byte order.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2012-12-02 20:34:44 +01:00
parent c101dafb18
commit 28c08dfac6
2 changed files with 25 additions and 0 deletions

13
ds.h
View File

@ -88,6 +88,19 @@ struct timePropertiesDS {
Enumeration8 timeSource; Enumeration8 timeSource;
} PACKED; } 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 { struct port_defaults {
Integer8 logAnnounceInterval; Integer8 logAnnounceInterval;
Integer8 logSyncInterval; Integer8 logSyncInterval;

12
tlv.c
View File

@ -44,6 +44,7 @@ static void mgt_post_recv(struct management_tlv *m)
struct currentDS *cds; struct currentDS *cds;
struct parentDS *pds; struct parentDS *pds;
struct timePropertiesDS *tp; struct timePropertiesDS *tp;
struct portDS *p;
struct time_status_np *tsn; struct time_status_np *tsn;
switch (m->id) { switch (m->id) {
case DEFAULT_DATA_SET: case DEFAULT_DATA_SET:
@ -73,6 +74,11 @@ static void mgt_post_recv(struct management_tlv *m)
tp = (struct timePropertiesDS *) m->data; tp = (struct timePropertiesDS *) m->data;
tp->currentUtcOffset = ntohs(tp->currentUtcOffset); tp->currentUtcOffset = ntohs(tp->currentUtcOffset);
break; 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: case TIME_STATUS_NP:
tsn = (struct time_status_np *) m->data; tsn = (struct time_status_np *) m->data;
tsn->master_offset = net2host64(tsn->master_offset); tsn->master_offset = net2host64(tsn->master_offset);
@ -92,6 +98,7 @@ static void mgt_pre_send(struct management_tlv *m)
struct currentDS *cds; struct currentDS *cds;
struct parentDS *pds; struct parentDS *pds;
struct timePropertiesDS *tp; struct timePropertiesDS *tp;
struct portDS *p;
struct time_status_np *tsn; struct time_status_np *tsn;
switch (m->id) { switch (m->id) {
case DEFAULT_DATA_SET: case DEFAULT_DATA_SET:
@ -121,6 +128,11 @@ static void mgt_pre_send(struct management_tlv *m)
tp = (struct timePropertiesDS *) m->data; tp = (struct timePropertiesDS *) m->data;
tp->currentUtcOffset = htons(tp->currentUtcOffset); tp->currentUtcOffset = htons(tp->currentUtcOffset);
break; 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: case TIME_STATUS_NP:
tsn = (struct time_status_np *) m->data; tsn = (struct time_status_np *) m->data;
tsn->master_offset = host2net64(tsn->master_offset); tsn->master_offset = host2net64(tsn->master_offset);