Fix delay response message format.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2011-12-27 17:31:36 +01:00
parent e96d26f13f
commit 39f5b2c449
2 changed files with 19 additions and 8 deletions

16
msg.c
View File

@ -111,11 +111,11 @@ static void timestamp_post_recv(struct ptp_message *m, struct Timestamp *ts)
m->ts.pdu.nsec = ntohl(ts->nanoseconds);
}
static void timestamp_pre_send(struct ptp_message *m, struct Timestamp *ts)
static void timestamp_pre_send(struct Timestamp *ts)
{
ts->seconds_lsb = htonl(m->ts.pdu.sec);
ts->seconds_msb = htons(0);
ts->nanoseconds = htonl(m->ts.pdu.nsec);
ts->seconds_lsb = htonl(ts->seconds_lsb);
ts->seconds_msb = htons(ts->seconds_msb);
ts->nanoseconds = htonl(ts->nanoseconds);
}
/* public methods */
@ -207,12 +207,18 @@ int msg_pre_send(struct ptp_message *m)
case SYNC:
return -1;
case DELAY_REQ:
timestamp_pre_send(m, &m->delay_req.originTimestamp);
break;
case PDELAY_REQ:
case PDELAY_RESP:
return -1;
case FOLLOW_UP:
timestamp_pre_send(&m->follow_up.preciseOriginTimestamp);
break;
case DELAY_RESP:
timestamp_pre_send(&m->delay_resp.receiveTimestamp);
m->delay_resp.requestingPortIdentity.portNumber =
htons(m->delay_resp.requestingPortIdentity.portNumber);
break;
case PDELAY_RESP_FOLLOW_UP:
return -1;
case ANNOUNCE:

11
port.c
View File

@ -158,6 +158,13 @@ static void fc_prune(struct foreign_clock *fc)
}
}
static void ts_to_timestamp(struct timespec *src, struct Timestamp *dst)
{
dst->seconds_lsb = src->tv_sec;
dst->seconds_msb = 0;
dst->nanoseconds = src->tv_nsec;
}
/*
* Returns non-zero if the announce message is different than last.
*/
@ -510,9 +517,7 @@ static int process_delay_req(struct port *p, struct ptp_message *m)
msg->header.control = CTL_DELAY_RESP;
msg->header.logMessageInterval = p->logMinDelayReqInterval;
msg->delay_resp.receiveTimestamp.seconds_lsb = htonl(m->hwts.ts.tv_sec);
msg->delay_resp.receiveTimestamp.seconds_msb = htons(0);
msg->delay_resp.receiveTimestamp.nanoseconds = htonl(m->hwts.ts.tv_nsec);
ts_to_timestamp(&m->hwts.ts, &msg->delay_resp.receiveTimestamp);
msg->delay_resp.requestingPortIdentity = m->header.sourcePortIdentity;