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

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2012-12-02 15:44:59 +01:00
parent aa6708d09a
commit 49a98c1fcf
1 changed files with 10 additions and 0 deletions

10
tlv.c
View File

@ -43,6 +43,7 @@ static void mgt_post_recv(struct management_tlv *m)
struct defaultDS *dds; struct defaultDS *dds;
struct currentDS *cds; struct currentDS *cds;
struct parentDS *pds; struct parentDS *pds;
struct timePropertiesDS *tp;
struct time_status_np *tsn; struct time_status_np *tsn;
switch (m->id) { switch (m->id) {
case DEFAULT_DATA_SET: case DEFAULT_DATA_SET:
@ -68,6 +69,10 @@ static void mgt_post_recv(struct management_tlv *m)
pds->grandmasterClockQuality.offsetScaledLogVariance = pds->grandmasterClockQuality.offsetScaledLogVariance =
ntohs(pds->grandmasterClockQuality.offsetScaledLogVariance); ntohs(pds->grandmasterClockQuality.offsetScaledLogVariance);
break; break;
case TIME_PROPERTIES_DATA_SET:
tp = (struct timePropertiesDS *) m->data;
tp->currentUtcOffset = ntohs(tp->currentUtcOffset);
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);
@ -86,6 +91,7 @@ static void mgt_pre_send(struct management_tlv *m)
struct defaultDS *dds; struct defaultDS *dds;
struct currentDS *cds; struct currentDS *cds;
struct parentDS *pds; struct parentDS *pds;
struct timePropertiesDS *tp;
struct time_status_np *tsn; struct time_status_np *tsn;
switch (m->id) { switch (m->id) {
case DEFAULT_DATA_SET: case DEFAULT_DATA_SET:
@ -111,6 +117,10 @@ static void mgt_pre_send(struct management_tlv *m)
pds->grandmasterClockQuality.offsetScaledLogVariance = pds->grandmasterClockQuality.offsetScaledLogVariance =
htons(pds->grandmasterClockQuality.offsetScaledLogVariance); htons(pds->grandmasterClockQuality.offsetScaledLogVariance);
break; break;
case TIME_PROPERTIES_DATA_SET:
tp = (struct timePropertiesDS *) m->data;
tp->currentUtcOffset = htons(tp->currentUtcOffset);
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);