msg: Use the TLV list on transmit.
Now that the list is in place and is used on all transmit paths, simply iterate through the list when converting to network byte order. Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
e0005dac94
commit
a061256bbd
23
msg.c
23
msg.c
|
@ -221,18 +221,14 @@ static int suffix_post_recv(struct ptp_message *msg, uint8_t *ptr, int len)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void suffix_pre_send(uint8_t *ptr, int cnt, struct tlv_extra *last)
|
||||
static void suffix_pre_send(struct ptp_message *msg)
|
||||
{
|
||||
int i;
|
||||
struct tlv_extra *extra;
|
||||
struct TLV *tlv;
|
||||
|
||||
if (!ptr)
|
||||
return;
|
||||
|
||||
for (i = 0; i < cnt; i++) {
|
||||
tlv = (struct TLV *) ptr;
|
||||
tlv_pre_send(tlv, i == cnt - 1 ? last : NULL);
|
||||
ptr += sizeof(struct TLV) + tlv->length;
|
||||
TAILQ_FOREACH(extra, &msg->tlv_list, list) {
|
||||
tlv = extra->tlv;
|
||||
tlv_pre_send(tlv, extra);
|
||||
tlv->type = htons(tlv->type);
|
||||
tlv->length = htons(tlv->length);
|
||||
}
|
||||
|
@ -406,7 +402,6 @@ int msg_post_recv(struct ptp_message *m, int cnt)
|
|||
int msg_pre_send(struct ptp_message *m)
|
||||
{
|
||||
int type;
|
||||
uint8_t *suffix = NULL;
|
||||
|
||||
if (hdr_pre_send(&m->header))
|
||||
return -1;
|
||||
|
@ -426,34 +421,28 @@ int msg_pre_send(struct ptp_message *m)
|
|||
break;
|
||||
case FOLLOW_UP:
|
||||
timestamp_pre_send(&m->follow_up.preciseOriginTimestamp);
|
||||
suffix = m->follow_up.suffix;
|
||||
break;
|
||||
case DELAY_RESP:
|
||||
timestamp_pre_send(&m->delay_resp.receiveTimestamp);
|
||||
m->delay_resp.requestingPortIdentity.portNumber =
|
||||
htons(m->delay_resp.requestingPortIdentity.portNumber);
|
||||
suffix = m->delay_resp.suffix;
|
||||
break;
|
||||
case PDELAY_RESP_FOLLOW_UP:
|
||||
timestamp_pre_send(&m->pdelay_resp_fup.responseOriginTimestamp);
|
||||
port_id_pre_send(&m->pdelay_resp_fup.requestingPortIdentity);
|
||||
suffix = m->pdelay_resp_fup.suffix;
|
||||
break;
|
||||
case ANNOUNCE:
|
||||
announce_pre_send(&m->announce);
|
||||
suffix = m->announce.suffix;
|
||||
break;
|
||||
case SIGNALING:
|
||||
suffix = m->signaling.suffix;
|
||||
break;
|
||||
case MANAGEMENT:
|
||||
port_id_pre_send(&m->management.targetPortIdentity);
|
||||
suffix = m->management.suffix;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
suffix_pre_send(suffix, m->tlv_count, m->last_tlv);
|
||||
suffix_pre_send(m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue