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

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2012-12-01 08:27:45 +01:00
parent 71c4bf203c
commit 2722b8587d
1 changed files with 14 additions and 0 deletions

14
tlv.c
View File

@ -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);