Commit 6cbba4d7 authored by Alessandro Rubini's avatar Alessandro Rubini

make state-{pclock,slave} more similar

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 386b5117
......@@ -17,6 +17,7 @@ int pp_pclock(struct pp_instance *ppi, unsigned char *pkt, int plen)
int d1, d2;
if (ppi->is_new_state) {
memset(&ppi->t1, 0, sizeof(ppi->t1));
pp_servo_init(ppi);
if (pp_hooks.new_slave)
......@@ -48,9 +49,12 @@ int pp_pclock(struct pp_instance *ppi, unsigned char *pkt, int plen)
e = st_com_slave_handle_followup(ppi, pkt, plen);
break;
case PPM_DELAY_REQ:
/* Being slave, we are not waiting for a delay request */
break;
case PPM_PDELAY_REQ:
e = (plen < PP_PDELAY_RESP_LENGTH);
if (e)
if (plen < PP_PDELAY_RESP_LENGTH)
break;
if (pp_hooks.handle_preq)
......@@ -60,17 +64,14 @@ int pp_pclock(struct pp_instance *ppi, unsigned char *pkt, int plen)
if (e)
goto out;
break;
case PPM_PDELAY_RESP:
e = st_com_peer_handle_pres(ppi, pkt, plen);
break;
case PPM_PDELAY_RESP_FOLLOW_UP:
e = (plen < PP_PDELAY_RESP_FOLLOW_UP_LENGTH);
if (e)
if (plen < PP_PDELAY_RESP_FOLLOW_UP_LENGTH)
break;
msg_unpack_pdelay_resp_follow_up(pkt, &respFllw);
......@@ -120,9 +121,16 @@ out:
DSPOR(ppi)->logMinDelayReqInterval);
}
if (e) {
switch(e) {
case PP_SEND_OK: /* 0 */
break;
case PP_SEND_ERROR:
ppi->next_state = PPS_FAULTY;
return 0;
break;
case PP_SEND_NO_STAMP:
/* nothing, just keep the ball rolling */
e = 0;
break;
}
/* Leaving this state */
......
......@@ -25,7 +25,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
if (e)
goto out;
ppi->flags &= ~PPI_FLAG_WAITING_FOR_F_UP;
ppi->flags &= ~PPI_FLAGS_WAITING;
pp_timeout_restart_annrec(ppi);
......@@ -55,10 +55,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
break;
case PPM_DELAY_RESP:
e = (plen < PP_DELAY_RESP_LENGTH);
if (e)
if (plen < PP_DELAY_RESP_LENGTH)
break;
msg_unpack_delay_resp(pkt, &resp);
......@@ -97,13 +94,6 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
break;
/*
* We are not supporting pdelay (not configured to, see
* 9.5.13.1, p 106), so all the code about pdelay is removed
* as a whole by one commit in our history. It can be recoverd
* and fixed if needed
*/
default:
/* disregard, nothing to do */
break;
......@@ -122,11 +112,6 @@ out:
/* Restart the timeout for next time */
pp_timeout_rand(ppi, PP_TO_DELAYREQ,
DSPOR(ppi)->logMinDelayReqInterval);
/* Add latency */
add_TimeInternal(&ppi->t3,
&ppi->t3,
&OPTS(ppi)->outbound_latency);
}
switch(e) {
......
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