Commit b03bc6c0 authored by Alessandro Rubini's avatar Alessandro Rubini

proto-standard: fix sent_seq to really be "sent"

By post-incrementing sent_seq we had a value that was not
really the "last sent" as the comment claims.  Thus, pre-increment
it instead, so readers find the "last sent" value and don't need
to subtract 1.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent e141bec0
......@@ -53,7 +53,6 @@ static inline int __send_and_log(struct pp_instance *ppi, int msglen,
ppi->last_snt_time.seconds,
ppi->last_snt_time.nanoseconds,
pp_msg_names[msgtype]);
ppi->sent_seq[msgtype]++; /* FIXME: fold in the send method too? */
return 0;
}
......
......@@ -173,7 +173,7 @@ void msg_pack_sync(struct pp_instance *ppi, Timestamp *orig_tstamp)
/* Table 19 */
*(UInteger16 *) (buf + 2) = htons(PP_SYNC_LENGTH);
*(UInteger16 *) (buf + 30) = htons(ppi->sent_seq[PPM_SYNC]);
*(UInteger16 *) (buf + 30) = htons(++(ppi->sent_seq[PPM_SYNC]));
*(UInteger8 *) (buf + 32) = 0x00;
/* Table 23 */
......@@ -215,7 +215,7 @@ int msg_pack_announce(struct pp_instance *ppi)
*(char *)(buf + 0) = *(char *)(buf + 0) | 0x0B;
/* Table 19 */
*(UInteger16 *) (buf + 2) = htons(PP_ANNOUNCE_LENGTH);
*(UInteger16 *) (buf + 30) = htons(ppi->sent_seq[PPM_ANNOUNCE]);
*(UInteger16 *) (buf + 30) = htons(++(ppi->sent_seq[PPM_ANNOUNCE]));
*(UInteger8 *) (buf + 32) = 0x05;
/* Table 23 */
*(Integer8 *) (buf + 33) = DSPOR(ppi)->logAnnounceInterval;
......@@ -281,7 +281,7 @@ void msg_pack_follow_up(struct pp_instance *ppi, Timestamp *prec_orig_tstamp)
/* Table 19 */
*(UInteger16 *) (buf + 2) = htons(PP_FOLLOW_UP_LENGTH);
*(UInteger16 *) (buf + 30) = htons(ppi->sent_seq[PPM_SYNC] - 1);
*(UInteger16 *) (buf + 30) = htons(ppi->sent_seq[PPM_SYNC]);
/* sentSyncSequenceId has already been incremented in msg_issue_sync */
*(UInteger8 *) (buf + 32) = 0x02;
......@@ -330,7 +330,7 @@ void msg_pack_delay_req(struct pp_instance *ppi, Timestamp *orig_tstamp)
/* Table 19 */
*(UInteger16 *) (buf + 2) = htons(PP_DELAY_REQ_LENGTH);
*(UInteger16 *) (buf + 30) = htons(ppi->sent_seq[PPM_DELAY_REQ]);
*(UInteger16 *) (buf + 30) = htons(++(ppi->sent_seq[PPM_DELAY_REQ]));
*(UInteger8 *) (buf + 32) = 0x01;
/* Table 23 */
......
......@@ -67,7 +67,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
if ((memcmp(DSPOR(ppi)->portIdentity.clockIdentity,
ppi->msg_tmp.resp.requestingPortIdentity.clockIdentity,
PP_CLOCK_IDENTITY_LENGTH) == 0) &&
((ppi->sent_seq[PPM_DELAY_REQ] - 1) ==
((ppi->sent_seq[PPM_DELAY_REQ]) ==
hdr->sequenceId) &&
(DSPOR(ppi)->portIdentity.portNumber ==
ppi->msg_tmp.resp.requestingPortIdentity.portNumber)
......
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