Commit dfaa73ac authored by Alessandro Rubini's avatar Alessandro Rubini

state-listening: send pdelay request if P2P_MECH

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 71e9342c
......@@ -12,14 +12,31 @@
int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen)
{
int e = 0; /* error var, to check errors in msg handling */
MsgHeader *hdr = &ppi->received_ptp_header;
MsgPDelayRespFollowUp respFllw;
if (pp_hooks.listening)
e = pp_hooks.listening(ppi, pkt, plen);
if (e)
goto out;
if (ppi->is_new_state)
if (ppi->is_new_state) {
pp_timeout_restart_annrec(ppi);
pp_timeout_rand(ppi, PP_TO_REQUEST,
DSPOR(ppi)->logMinDelayReqInterval);
}
/* when the clock is using peer-delay, listening must send it too */
if (ppi->glbs->delay_mech == PP_P2P_MECH
&& pp_timeout_z(ppi, PP_TO_REQUEST)) {
e = msg_issue_request(ppi);
ppi->t3 = ppi->last_snt_time;
/* Restart the timeout for next time */
pp_timeout_rand(ppi, PP_TO_REQUEST,
DSPOR(ppi)->logMinDelayReqInterval);
}
if (plen == 0)
goto out;
......@@ -34,6 +51,47 @@ int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen)
e = st_com_master_handle_sync(ppi, pkt, plen);
break;
case PPM_PDELAY_REQ:
st_com_peer_handle_preq(ppi, pkt, plen);
break;
case PPM_PDELAY_RESP:
e = st_com_peer_handle_pres(ppi, pkt, plen);
break;
case PPM_PDELAY_RESP_FOLLOW_UP:
if (plen < PP_PDELAY_RESP_FOLLOW_UP_LENGTH)
break;
msg_unpack_pdelay_resp_follow_up(pkt, &respFllw);
if ((memcmp(&DSPOR(ppi)->portIdentity.clockIdentity,
&respFllw.requestingPortIdentity.clockIdentity,
PP_CLOCK_IDENTITY_LENGTH) == 0) &&
((ppi->sent_seq[PPM_PDELAY_REQ]) ==
hdr->sequenceId) &&
(DSPOR(ppi)->portIdentity.portNumber ==
respFllw.requestingPortIdentity.portNumber) &&
(ppi->flags & PPI_FLAG_FROM_CURRENT_PARENT)) {
to_TimeInternal(&ppi->t5,
&respFllw.responseOriginTimestamp);
ppi->flags |= PPI_FLAG_WAITING_FOR_RF_UP;
if (pp_hooks.handle_presp)
e = pp_hooks.handle_presp(ppi);
else
pp_servo_got_presp(ppi);
if (e)
goto out;
} else {
pp_diag(ppi, frames, 2, "%s: "
"PDelay Resp F-up doesn't match PDelay Req\n",
__func__);
}
break;
default:
/* disregard, nothing to do */
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment