Commit dfeb1890 authored by Alessandro Rubini's avatar Alessandro Rubini

proto-standard: trivial: merge common code

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 1c2b0811
...@@ -135,6 +135,18 @@ int st_com_slave_handle_sync(struct pp_instance *ppi, unsigned char *buf, ...@@ -135,6 +135,18 @@ int st_com_slave_handle_sync(struct pp_instance *ppi, unsigned char *buf,
return 0; return 0;
} }
static int presp_call_servo(struct pp_instance *ppi)
{
int ret = 0;
pp_timeout_set(ppi, PP_TO_FAULT);
if (pp_hooks.handle_presp)
ret = pp_hooks.handle_presp(ppi);
else
pp_servo_got_presp(ppi);
return ret;
}
int st_com_peer_handle_pres(struct pp_instance *ppi, unsigned char *buf, int st_com_peer_handle_pres(struct pp_instance *ppi, unsigned char *buf,
int len) int len)
{ {
...@@ -168,13 +180,8 @@ int st_com_peer_handle_pres(struct pp_instance *ppi, unsigned char *buf, ...@@ -168,13 +180,8 @@ int st_com_peer_handle_pres(struct pp_instance *ppi, unsigned char *buf,
memset(&ppi->t5, 0, sizeof(ppi->t5)); memset(&ppi->t5, 0, sizeof(ppi->t5));
} }
if (!(hdr->flagField[0] & PP_TWO_STEP_FLAG)) { if (!(hdr->flagField[0] & PP_TWO_STEP_FLAG))
pp_timeout_set(ppi, PP_TO_FAULT); e = presp_call_servo(ppi);
if (pp_hooks.handle_presp)
e = pp_hooks.handle_presp(ppi);
else
pp_servo_got_presp(ppi);
}
} else { } else {
pp_diag(ppi, frames, 2, "pp_pclock : " pp_diag(ppi, frames, 2, "pp_pclock : "
"PDelay Resp doesn't match PDelay Req\n"); "PDelay Resp doesn't match PDelay Req\n");
...@@ -204,11 +211,7 @@ int st_com_peer_handle_pres_followup(struct pp_instance *ppi, ...@@ -204,11 +211,7 @@ int st_com_peer_handle_pres_followup(struct pp_instance *ppi,
ppi->t5 = respFllw.responseOriginTimestamp; ppi->t5 = respFllw.responseOriginTimestamp;
pp_time_add(&ppi->t5, &hdr->cField); pp_time_add(&ppi->t5, &hdr->cField);
pp_timeout_set(ppi, PP_TO_FAULT); e = presp_call_servo(ppi);
if (pp_hooks.handle_presp)
e = pp_hooks.handle_presp(ppi);
else
pp_servo_got_presp(ppi);
} else { } else {
pp_diag(ppi, frames, 2, "%s: " pp_diag(ppi, frames, 2, "%s: "
"PDelay Resp F-up doesn't match PDelay Req\n", "PDelay Resp F-up doesn't match PDelay Req\n",
......
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