Commit e0c2c1e7 authored by Alessandro Rubini's avatar Alessandro Rubini

protocol code: merge issue_sync and issue_fup

We always send them in pair, so use a single function to do it.
This simplifies the code a little, but most of al it allows
later interoduction of mandated masters on multiple vlans.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <>
parent b88106b3
......@@ -356,8 +356,7 @@ extern void msg_unpack_delay_resp(void *buf, MsgDelayResp *resp);
/* each of them returns 0 if no error and -1 in case of error in send */
extern int msg_issue_announce(struct pp_instance *ppi);
extern int msg_issue_sync(struct pp_instance *ppi);
extern int msg_issue_followup(struct pp_instance *ppi, TimeInternal *time);
extern int msg_issue_sync_followup(struct pp_instance *ppi);
extern int msg_issue_delay_req(struct pp_instance *ppi);
extern int msg_issue_delay_resp(struct pp_instance *ppi, TimeInternal *time);
......@@ -355,26 +355,25 @@ int msg_issue_announce(struct pp_instance *ppi)
/* Pack and send on event multicast ip adress a Sync message */
int msg_issue_sync(struct pp_instance *ppi)
int msg_issue_sync_followup(struct pp_instance *ppi)
Timestamp orig_tstamp;
TimeInternal now;
ppi->t_ops->get(ppi, &now);
from_TimeInternal(&now, &orig_tstamp);
msg_pack_sync(ppi, &orig_tstamp);
return __send_and_log(ppi, PP_SYNC_LENGTH, PPM_SYNC, PP_NP_EVT);
/* Pack and send on general multicast ip address a FollowUp message */
int msg_issue_followup(struct pp_instance *ppi, TimeInternal *time)
Timestamp prec_orig_tstamp;
from_TimeInternal(time, &prec_orig_tstamp);
msg_pack_follow_up(ppi, &prec_orig_tstamp);
Timestamp tstamp;
TimeInternal now, *time_snt;
int e;
/* Send sync on the event channel with the "current" timestamp */
ppi->t_ops->get(ppi, &now);
from_TimeInternal(&now, &tstamp);
msg_pack_sync(ppi, &tstamp);
e = __send_and_log(ppi, PP_SYNC_LENGTH, PPM_SYNC, PP_NP_EVT);
if (e) return e;
/* Send followup on general channel with sent-stamp of sync */
time_snt = &ppi->last_snt_time;
add_TimeInternal(time_snt, time_snt,
from_TimeInternal(time_snt, &tstamp);
msg_pack_follow_up(ppi, &tstamp);
return __send_and_log(ppi, PP_FOLLOW_UP_LENGTH, PPM_FOLLOW_UP,
......@@ -11,7 +11,6 @@
int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
TimeInternal *time_snt;
int msgtype, d1, d2;
int e = 0; /* error var, to check errors in msg handling */
......@@ -26,13 +25,7 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
if (pp_timeout_z(ppi, PP_TO_SYNC)) {
if ((e = msg_issue_sync(ppi) < 0))
goto out;
time_snt = &ppi->last_snt_time;
add_TimeInternal(time_snt, time_snt,
if ((e = msg_issue_followup(ppi, time_snt)))
if ((e = msg_issue_sync_followup(ppi) < 0))
goto out;
/* Restart the timeout for next time */
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