Convert the current data set TLV to and from host byte order.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
92c6c9149d
commit
7da00ec089
2
ds.h
2
ds.h
|
@ -51,7 +51,7 @@ struct currentDS {
|
||||||
UInteger16 stepsRemoved;
|
UInteger16 stepsRemoved;
|
||||||
TimeInterval offsetFromMaster;
|
TimeInterval offsetFromMaster;
|
||||||
TimeInterval meanPathDelay;
|
TimeInterval meanPathDelay;
|
||||||
};
|
} PACKED;
|
||||||
|
|
||||||
struct parentDS {
|
struct parentDS {
|
||||||
struct PortIdentity parentPortIdentity;
|
struct PortIdentity parentPortIdentity;
|
||||||
|
|
28
tlv.c
28
tlv.c
|
@ -37,6 +37,32 @@ static void scaled_ns_h2n(ScaledNs *sns)
|
||||||
sns->fractional_nanoseconds = htons(sns->fractional_nanoseconds);
|
sns->fractional_nanoseconds = htons(sns->fractional_nanoseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void mgt_post_recv(struct management_tlv *m)
|
||||||
|
{
|
||||||
|
struct currentDS *cds;
|
||||||
|
switch (m->id) {
|
||||||
|
case CURRENT_DATA_SET:
|
||||||
|
cds = (struct currentDS *) m->data;
|
||||||
|
cds->stepsRemoved = ntohs(cds->stepsRemoved);
|
||||||
|
cds->offsetFromMaster = net2host64(cds->offsetFromMaster);
|
||||||
|
cds->meanPathDelay = net2host64(cds->meanPathDelay);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mgt_pre_send(struct management_tlv *m)
|
||||||
|
{
|
||||||
|
struct currentDS *cds;
|
||||||
|
switch (m->id) {
|
||||||
|
case CURRENT_DATA_SET:
|
||||||
|
cds = (struct currentDS *) m->data;
|
||||||
|
cds->stepsRemoved = htons(cds->stepsRemoved);
|
||||||
|
cds->offsetFromMaster = host2net64(cds->offsetFromMaster);
|
||||||
|
cds->meanPathDelay = host2net64(cds->meanPathDelay);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void org_post_recv(struct organization_tlv *org)
|
static void org_post_recv(struct organization_tlv *org)
|
||||||
{
|
{
|
||||||
struct follow_up_info_tlv *f;
|
struct follow_up_info_tlv *f;
|
||||||
|
@ -87,6 +113,7 @@ void tlv_post_recv(struct TLV *tlv)
|
||||||
case TLV_MANAGEMENT:
|
case TLV_MANAGEMENT:
|
||||||
mgt = (struct management_tlv *) tlv;
|
mgt = (struct management_tlv *) tlv;
|
||||||
mgt->id = ntohs(mgt->id);
|
mgt->id = ntohs(mgt->id);
|
||||||
|
mgt_post_recv(mgt);
|
||||||
break;
|
break;
|
||||||
case TLV_MANAGEMENT_ERROR_STATUS:
|
case TLV_MANAGEMENT_ERROR_STATUS:
|
||||||
mes = (struct management_error_status *) tlv;
|
mes = (struct management_error_status *) tlv;
|
||||||
|
@ -125,6 +152,7 @@ void tlv_pre_send(struct TLV *tlv)
|
||||||
switch (tlv->type) {
|
switch (tlv->type) {
|
||||||
case TLV_MANAGEMENT:
|
case TLV_MANAGEMENT:
|
||||||
mgt = (struct management_tlv *) tlv;
|
mgt = (struct management_tlv *) tlv;
|
||||||
|
mgt_pre_send(mgt);
|
||||||
mgt->id = htons(mgt->id);
|
mgt->id = htons(mgt->id);
|
||||||
break;
|
break;
|
||||||
case TLV_MANAGEMENT_ERROR_STATUS:
|
case TLV_MANAGEMENT_ERROR_STATUS:
|
||||||
|
|
Loading…
Reference in New Issue