Commit 33d63f5a authored by Alessandro Rubini's avatar Alessandro Rubini

handle_prequest: fix hook handling, remove duplications

Currently, only the slave sends pdelay_request, so only the master
is handling them.  However, only the slave called pp_hooks.handle_preq()
-- thus it was never called.

Waiting for a test session about this assignment to correctionfield
done by wr_handle_preq(), this removes a little duplication and ensures
the hook is always called.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 9e5ebbd4
......@@ -73,14 +73,9 @@ static int wr_listening(struct pp_instance *ppi, unsigned char *pkt, int plen)
static int wr_handle_preq(struct pp_instance *ppi)
{
ppi->received_ptp_header.correctionfield.msb = 0;
ppi->received_ptp_header.correctionfield.lsb =
phase_to_cf_units(ppi->last_rcv_time.phase);
msg_issue_pdelay_resp(ppi, &ppi->last_rcv_time);
msg_issue_pdelay_resp_followup(ppi, &ppi->last_snt_time);
return 0;
}
......
......@@ -230,9 +230,16 @@ int st_com_peer_handle_pres(struct pp_instance *ppi, unsigned char *buf,
int st_com_peer_handle_preq(struct pp_instance *ppi, unsigned char *buf,
int len)
{
int e = 0;
if (len < PP_PDELAY_REQ_LENGTH)
return -1;
if (pp_hooks.handle_preq)
e = pp_hooks.handle_preq(ppi);
if (e)
return e;
msg_issue_pdelay_resp(ppi, &ppi->last_rcv_time);
msg_issue_pdelay_resp_followup(ppi, &ppi->last_snt_time);
......
......@@ -98,16 +98,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
break;
case PPM_PDELAY_REQ:
if (plen < PP_PDELAY_RESP_LENGTH)
break;
if (pp_hooks.handle_preq)
e = pp_hooks.handle_preq(ppi);
else
e = st_com_peer_handle_preq(ppi, pkt, plen);
if (e)
goto out;
break;
case PPM_PDELAY_RESP:
......
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