Commit ec54c4ce authored by Adam Wujek's avatar Adam Wujek 💬

Merge branch 'rubi-math-cleanup'

Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parents ebd03f57 e6e7b5e6
......@@ -113,7 +113,7 @@ typedef struct MsgHeader {
UInteger16 messageLength;
UInteger8 domainNumber;
Octet flagField[2];
struct pp_time cField;;
struct pp_time cField;
PortIdentity sourcePortIdentity;
UInteger16 sequenceId;
/* UInteger8 controlField; -- receiver must ignore it */
......
......@@ -150,8 +150,7 @@ struct pp_instance {
/* Times, for the various offset computations */
struct pp_time t1, t2, t3, t4, t5, t6; /* *the* stamps */
Integer32 t4_cf, t6_cf; /* peer delay */
struct pp_time cField; /* transp. clocks */
uint64_t syncCF; /* transp. clocks */
struct pp_time last_rcv_time, last_snt_time; /* two temporaries */
/* Page 85: each port shall maintain an implementation-specific
......
......@@ -161,8 +161,7 @@ struct pp_ext_hooks {
void (*s1)(struct pp_instance *ppi, MsgHeader *hdr, MsgAnnounce *ann);
int (*execute_slave)(struct pp_instance *ppi);
int (*handle_announce)(struct pp_instance *ppi);
int (*handle_followup)(struct pp_instance *ppi, struct pp_time *orig,
struct pp_time *correction_field);
int (*handle_followup)(struct pp_instance *ppi, struct pp_time *orig);
int (*handle_preq) (struct pp_instance * ppi);
int (*handle_presp) (struct pp_instance * ppi);
int (*pack_announce)(struct pp_instance *ppi);
......@@ -394,6 +393,7 @@ extern int msg_issue_pdelay_resp_followup(struct pp_instance *ppi,
extern int msg_issue_pdelay_resp(struct pp_instance *ppi, struct pp_time *time);
/* Functions for time math */
extern void normalize_pp_time(struct pp_time *t);
extern void pp_time_add(struct pp_time *t1, struct pp_time *t2);
extern void pp_time_sub(struct pp_time *t1, struct pp_time *t2);
extern void pp_time_div2(struct pp_time *t);
......
......@@ -71,18 +71,9 @@ static int wr_listening(struct pp_instance *ppi, unsigned char *pkt, int plen)
return 0;
}
static int wr_handle_preq(struct pp_instance *ppi)
{
/* FIXME: why do we save this fractional part? */
clear_time(&ppi->cField);
ppi->cField.scaled_nsecs = ppi->last_rcv_time.scaled_nsecs & 0xffff;
return 0;
}
static int wr_master_msg(struct pp_instance *ppi, unsigned char *pkt, int plen,
int msgtype)
{
MsgHeader *hdr = &ppi->received_ptp_header;
MsgSignaling wrsig_msg;
struct pp_time *time = &ppi->last_rcv_time;
......@@ -93,16 +84,12 @@ static int wr_master_msg(struct pp_instance *ppi, unsigned char *pkt, int plen,
/* This case is modified from the default one */
case PPM_DELAY_REQ:
/* there is no cField now, we pp_time includes it all */
clear_time(&hdr->cField);
msg_issue_delay_resp(ppi, time); /* no error check */
msgtype = PPM_NO_MESSAGE;
break;
case PPM_PDELAY_REQ:
if (CONFIG_HAS_P2P)
wr_handle_preq(ppi);
/* normal management continues */
/* nothing to do */
break;
/* This is missing in the standard protocol */
......@@ -202,8 +189,7 @@ static int wr_handle_announce(struct pp_instance *ppi)
}
static int wr_handle_followup(struct pp_instance *ppi,
struct pp_time *precise_orig_timestamp,
struct pp_time *correction_field)
struct pp_time *precise_orig_timestamp)
{
pp_diag(ppi, ext, 2, "hook: %s\n", __func__);
if (!WR_DSPOR(ppi)->wrModeOn)
......@@ -285,7 +271,6 @@ struct pp_ext_hooks pp_hooks = {
.handle_announce = wr_handle_announce,
.handle_followup = wr_handle_followup,
#if CONFIG_HAS_P2P
.handle_preq = wr_handle_preq,
.handle_presp = wr_handle_presp,
#endif
.pack_announce = wr_pack_announce,
......
......@@ -11,7 +11,8 @@
/* Please increment WRS_PPSI_SHMEM_VERSION if you change any exported data
* structure */
#define WRS_PPSI_SHMEM_VERSION 19 /* Reorder fields in struct wr_servo_state */
#define WRS_PPSI_SHMEM_VERSION 20 /* Replace cField, t4_cf and t6_cf with
syncCF */
/* Don't include the Following when this file is included in assembler. */
#ifndef __ASSEMBLY__
......
......@@ -214,7 +214,6 @@ int wr_servo_got_delay(struct pp_instance *ppi)
s->t3 = ppi->t3;
/* s->t3.phase = 0; */
s->t4 = ppi->t4;
/* FIXME: verify that cField is already merged */
if (CONFIG_HAS_P2P && ppi->mech == PP_P2P_MECH) {
s->t5 = ppi->t5;
......
The correctionField makes me mad. We used to have ppi->cField, that
nobody knows which frame it refers to. I now keep it for reference,
associated to the sync message, so we know what the overall TC delay is.
####################################### E2E
Characters:
T1 T2 T3 T4 The real timestamps
I1 I2 I3 I4 Integer-nano part
F1 F2 F3 F4 Fractional part
P1 P2 P3 P4 The time variables in ppsi (ppi->t1 etc)
Tsyn Tfup Treq Trep The stamps as send in the frames
Csyn Cfup Creq Crep The correctionFields
TCsyn ... Delay added by TC on the syn path
I ignore the "asymmetry" part of the cFields, because if the standard
adds/subtract them, conflating them with the other values, it means the
sign of the result matches.
The master sends T1 split with the integer part in the timestamp and
the fractional part in cField: Csyn = F1 (it is zero for WR). The
slave receives as that (whether there is a f-up or not is irrelevant:
one-step puts the fractional part in Csyn, two step in Cfup; TC
devices are mandated to turn one-step into two-step and modify the
Cfup.
Tfup = I1 (or Tsyn if one-step)
Csyn + Cfup = F1 + TCsyn
And ppsi saves the sum of all three. Remember T1 = I1 + F1
P1 = Tfup + Csyn + Cfup
P1 = T1 + TCsyn
On transmission, of delay-request nothing happens, and Creq is 0.
P2 = T2
P3 = T3
The correction-field arrives with the TC delay inside (TCreq). The
master copies Creq to Crep and *subtracts* the fractional part of the
timestamp it collected (NOTE: we always added)
Trep = I4
Crep = TCreq - F4
So, in ppsi I just subtract this:
P4 = Trep - Crep
P4 = T4 - TCreq
The Crep is received unmodified, because TCs only act on event messages.
Finally, the round trip time is clearly to be calculated as
T4 - T1 - (T3 - T2) - TC
If I do it with ppsi internal stamps:
P4 - P1 - (P3 - P2)
T4 - Tcreq - T1 -TCsyn - (T3 - T2)
T4 - T1 - (T3 - T2) - (TCsyn + TCreq)
So this actually works as expected.
The unreadable doc says in 11.3, in a 4-line expression, that round-trip is:
T2 - T3 + (I4 - I1) - Csyn - Cfup - Crep
By expanding the cFields, this means:
T2 - T3 + (I4 - I1) - F1 - TCsyn - TCreq + F4
T4 - T1 - (T3 - T2) - (TCsyn + TCreq)
QED. So my simplified calculation is correct, and I can merge the
cField in the timestamp as soon as the frame arrives.
#### Bug since the origin of time
Our code has always used Crep = F4 (positive), and *added* the cField
to the received timestamp (though only later, not at frame rx time).
Which means that it worked as long as there were no TC in the path,
that it was interoperable with anybody having no fractional part,
and obviously it worked with itself.
But the code is wrong. And if I fix it (by subtracting instead of
adding) it will not be compatible with itself, with the error being
up to two clock cycles.
So I suggest we keep it bugged, well marked in the code, so
somebody else will try to do better in the final HA implementation.
####################################### P2P
Peer-to-peer is a little more tricky, because it has several
options. Also note that code does not use T1,T2,T3,T4, because T1 and
T2 are already used for sync events. We use T3,T4,T5,T6, but this is
different from the standard. Here I use T1..4 according to the
standard, and P3..6 for the ppsi-internal variables
For sync and f-up the same as above applies, so P1 includes
the correction factors, that I add at recv time.
Then we look at pdelay. By definition, no transparent clock is there
(if it was there, we would be talking with it). So the correction
factors only include the fractional parts. I still call the nodes
master and slave, because the link-delay is only used by the slave -
we lack transparent clock in the code. Correction fields are called
Cpreq, Cprep, Cpfup.
The slave sends pdelay-request with cfield as zero. Retrieves T1 on tx.
P3 = T1
The one-step master (node-B) copies the cField (zero) and adds
the difference T3 - T2; the slave saves T4 locally.
Cprep = T3 - T2
P6 = T4
For two step clocks, there are two options. The master can send
0 in pdelay-response and "T3 - T2" in the response-fup; or it can
send the complete T2 and T3. We do that, because we want to show the
actual timestamps in diagnostic messages and this is the case
I dissect, but the result is the same (exercise for the reader).
Clearly a transparent clock where the absolute time is irrelevant
may prefer to just send 0 and the difference.
So the response and follow-up are
Tprep = I2
Cprep = -F2
Tpfup = I3
Cpfup = Cpreq + F3 (I ignore Cpreq here below, as it is asymmetry)
In ppsi, I should subtract and add in the same way:
P4 = Tprep - Cprep
P5 = Tpfup + Cpfup
Then, the standard calculates the round trip time like this
T4 - T1 - (Tpfup - Tprep) - Cprep - Cpfup
T4 - T1 - (I3 - I2) + F2 - F3
T4 - T1 - (I3 - I2 - F2 + F3)
T4 - T1 - (T3 - T2)
I do it in the usual way, with my own numbering of ppi->tX
P6 - P3 - (P5 - P4)
T4 - T1 - (Tpfup + Cpfup - Tprep + Cprep)
Which is exactly the line mandate by the standard, that reduces
to T4 - T1 - (T3 - T2).
#### Bug
As for E2E, we add fractional times instead of subtracting them.
The same considerations apply, but in the case there is no installed
base yet.
......@@ -9,7 +9,7 @@
#include <limits.h>
#include <ppsi/ppsi.h>
static void normalize_pp_time(struct pp_time *t)
void normalize_pp_time(struct pp_time *t)
{
/* no 64b division please, we'll rather loop a few times */
#define SNS_PER_S ((1000LL * 1000 * 1000) << 16)
......
......@@ -107,19 +107,22 @@ int st_com_slave_handle_sync(struct pp_instance *ppi, unsigned char *buf,
if (!(ppi->flags & PPI_FLAG_FROM_CURRENT_PARENT))
return 0;
/* t2 may be overriden by follow-up, cField is always valid */
/* t2 may be overriden by follow-up, save it immediately */
ppi->t2 = ppi->last_rcv_time;
/* FIXME: merge cField here? */
ppi->cField = hdr->cField;
msg_unpack_sync(buf, &sync);
if ((hdr->flagField[0] & PP_TWO_STEP_FLAG) != 0) {
ppi->flags |= PPI_FLAG_WAITING_FOR_F_UP;
ppi->recv_sync_sequence_id = hdr->sequenceId;
/* for two-step, the stamp comes later */
ppi->t1 = hdr->cField; /* most likely 0 */
return 0;
}
msg_unpack_sync(buf, &sync);
/* one-step folllows */
ppi->flags &= ~PPI_FLAG_WAITING_FOR_F_UP;
ppi->t1 = sync.originTimestamp;
pp_time_add(&ppi->t1, &hdr->cField);
ppi->syncCF = 0;
if (CONFIG_HAS_P2P && ppi->mech == PP_P2P_MECH)
pp_servo_got_psync(ppi);
else
......@@ -147,6 +150,7 @@ int st_com_peer_handle_pres(struct pp_instance *ppi, unsigned char *buf,
ppi->t4 = resp.requestReceiptTimestamp;
pp_time_add(&ppi->t4, &hdr->cField);
/* WARNING: should be "sub" (see README-cfield::BUG) */
ppi->t6 = ppi->last_rcv_time;
if ((hdr->flagField[0] & PP_TWO_STEP_FLAG) != 0)
ppi->flags |= PPI_FLAG_WAITING_FOR_RF_UP;
......@@ -192,11 +196,7 @@ int st_com_peer_handle_pres_followup(struct pp_instance *ppi,
(ppi->flags & PPI_FLAG_FROM_CURRENT_PARENT)) {
ppi->t5 = respFllw.responseOriginTimestamp;
/*
* Add correctionField of pdelay_resp_followup to
* cf of pdelay_resp (see 11.4.3 d 4)
*/
pp_time_add(&ppi->t4, &hdr->cField);
pp_time_add(&ppi->t5, &hdr->cField);
if (pp_hooks.handle_presp)
e = pp_hooks.handle_presp(ppi);
......@@ -255,14 +255,14 @@ int st_com_slave_handle_followup(struct pp_instance *ppi, unsigned char *buf,
msg_unpack_follow_up(buf, &follow);
ppi->flags &= ~PPI_FLAG_WAITING_FOR_F_UP;
ppi->t1 = follow.preciseOriginTimestamp;
/* Add correctionField in follow-up to sync correctionField, see 11.2 */
pp_time_add(&ppi->cField, &hdr->cField); /* FIXME: check this cField */
/* t1 for calculations is T1 + Csyn + Cful -- see README-cfield */
pp_time_add(&ppi->t1, &follow.preciseOriginTimestamp);
pp_time_add(&ppi->t1, &hdr->cField);
ppi->syncCF = hdr->cField.scaled_nsecs; /* for diag about TC */
/* Call the extension; it may do it all and ask to return */
if (pp_hooks.handle_followup)
ret = pp_hooks.handle_followup(ppi, &ppi->t1, &ppi->cField);
ret = pp_hooks.handle_followup(ppi, &ppi->t1);
if (ret == 1)
return 0;
if (ret < 0)
......
......@@ -127,6 +127,7 @@ void msg_unpack_sync(void *buf, MsgSync *sync)
secs |= htonl(*(UInteger32 *) (buf + 36));
nsecs = htonl(*(UInteger32 *) (buf + 40));
/* The cField is added in the caller according to 1-step vs. 2-step */
sync->originTimestamp.secs = secs;
sync->originTimestamp.scaled_nsecs = nsecs << 16;
}
......@@ -231,6 +232,9 @@ static int msg_pack_follow_up(struct pp_instance *ppi,
*(UInteger16 *)(buf + 34) = htons(prec_orig_tstamp->secs >> 32);
*(UInteger32 *)(buf + 36) = htonl(prec_orig_tstamp->secs);
*(UInteger32 *)(buf + 40) = htonl(prec_orig_tstamp->scaled_nsecs >> 16);
/* Fractional part in cField */
*(UInteger32 *)(buf + 12) =
htonl(prec_orig_tstamp->scaled_nsecs & 0xffff);
return len;
}
......@@ -244,9 +248,13 @@ static int msg_pack_pdelay_resp_follow_up(struct pp_instance *ppi,
/* Header */
*(UInteger8 *) (buf + 4) = hdr->domainNumber; /* FIXME: why? */
/* copy the correction field, 11.4.3 c.3) */
/* We should copy the correction field and add our fractional part */
hdr->cField.scaled_nsecs
+= htonl(prec_orig_tstamp->scaled_nsecs & 0xffff);
normalize_pp_time(&hdr->cField);
*(Integer32 *) (buf + 8) = htonl(hdr->cField.scaled_nsecs >> 32);
*(Integer32 *) (buf + 12) = htonl((int)hdr->cField.scaled_nsecs);
*(UInteger16 *) (buf + 30) = htons(hdr->sequenceId);
/* requestReceiptTimestamp */
......@@ -271,6 +279,7 @@ void msg_unpack_follow_up(void *buf, MsgFollowUp *flwup)
secs |= htonl(*(UInteger32 *) (buf + 36));
nsecs = htonl(*(UInteger32 *) (buf + 40));
/* cField add1ed by the caller, from already-converted header */
flwup->preciseOriginTimestamp.secs = secs;
flwup->preciseOriginTimestamp.scaled_nsecs = nsecs << 16;
}
......@@ -286,6 +295,7 @@ void msg_unpack_pdelay_resp_follow_up(void *buf,
secs |= htonl(*(UInteger32 *) (buf + 36));
nsecs = htonl(*(UInteger32 *) (buf + 40));
/* cField added by the caller, as it's already converted */
pdelay_resp_flwup->responseOriginTimestamp.secs = secs;
pdelay_resp_flwup->responseOriginTimestamp.scaled_nsecs =
nsecs << 16;
......@@ -298,7 +308,7 @@ void msg_unpack_pdelay_resp_follow_up(void *buf,
/* pack DelayReq message into out buffer of ppi */
static int msg_pack_delay_req(struct pp_instance *ppi,
struct pp_time *orig_tstamp)
struct pp_time *now)
{
void *buf = ppi->tx_ptp;
int len = __msg_pack_header(ppi, PPM_DELAY_REQ);
......@@ -307,16 +317,16 @@ static int msg_pack_delay_req(struct pp_instance *ppi,
/* Header */
*(UInteger16 *) (buf + 30) = htons(ppi->sent_seq[PPM_DELAY_REQ]);
/* Delay_req message */
*(UInteger16 *) (buf + 34) = htons(orig_tstamp->secs >> 32);
*(UInteger32 *) (buf + 36) = htonl(orig_tstamp->secs);
*(UInteger32 *) (buf + 40) = htonl(orig_tstamp->scaled_nsecs >> 16);
/* Delay_req message - we may send zero instead */
*(UInteger16 *) (buf + 34) = htons(now->secs >> 32);
*(UInteger32 *) (buf + 36) = htonl(now->secs);
*(UInteger32 *) (buf + 40) = htonl(now->scaled_nsecs >> 16);
return len;
}
/* pack DelayReq message into out buffer of ppi */
static int msg_pack_pdelay_req(struct pp_instance *ppi,
struct pp_time *orig_tstamp)
struct pp_time *now)
{
void *buf = ppi->tx_ptp;
int len = __msg_pack_header(ppi, PPM_PDELAY_REQ);
......@@ -325,10 +335,10 @@ static int msg_pack_pdelay_req(struct pp_instance *ppi,
/* Header */
*(UInteger16 *) (buf + 30) = htons(ppi->sent_seq[PPM_PDELAY_REQ]);
/* PDelay_req message */
*(UInteger16 *) (buf + 34) = htons(orig_tstamp->secs >> 32);
*(UInteger32 *) (buf + 36) = htonl(orig_tstamp->secs);
*(UInteger32 *) (buf + 40) = htonl(orig_tstamp->scaled_nsecs >> 16);
/* PDelay_req message - we may send zero instead */
*(UInteger16 *) (buf + 34) = htons(now->secs >> 32);
*(UInteger32 *) (buf + 36) = htonl(now->secs);
*(UInteger32 *) (buf + 40) = htonl(now->scaled_nsecs >> 16);
memset(buf + 44, 0, 10); /* reserved to match pdelay_resp length */
return len;
}
......@@ -345,6 +355,10 @@ static int msg_pack_pdelay_resp(struct pp_instance *ppi,
flags8[0] = PP_TWO_STEP_FLAG; /* Table 20) */
*(UInteger16 *) (buf + 30) = htons(hdr->sequenceId);
/* cField: shdould be the fractional negated (see README-cfield) */
*(UInteger32 *) (buf + 12)
= htonl(rcv_tstamp->scaled_nsecs & 0xffff);
/* requestReceiptTimestamp */
*(UInteger16 *) (buf + 34) = htons(rcv_tstamp->secs >> 32);
*(UInteger32 *) (buf + 36) = htonl(rcv_tstamp->secs);
......@@ -365,7 +379,10 @@ static int msg_pack_delay_resp(struct pp_instance *ppi,
int len = __msg_pack_header(ppi, PPM_DELAY_RESP);
/* Header */
/* Copy correctionField of delayReqMessage */
/*
* We should copy the cField of the request, and then subract
* our fractional part. However, we add it (see README-cfield::BUG)
*/
*(Integer32 *) (buf + 8) = 0;
*(Integer32 *) (buf + 12) = htonl(rcv_tstamp->scaled_nsecs & 0xffff);
*(UInteger16 *) (buf + 30) = htons(hdr->sequenceId);
......@@ -420,6 +437,7 @@ void msg_unpack_delay_resp(void *buf, MsgDelayResp *resp)
secs |= htonl(*(UInteger32 *) (buf + 36));
nsecs = htonl(*(UInteger32 *) (buf + 40));
/* cfield added in the caller */
resp->receiveTimestamp.secs = secs;
resp->receiveTimestamp.scaled_nsecs = nsecs << 16;
......@@ -434,11 +452,12 @@ void msg_unpack_pdelay_resp(void *buf, MsgPDelayResp * presp)
{
int64_t secs, nsecs;
secs = htons(*(UInteger16 *) (buf + 34));
secs = ntohs(*(UInteger16 *) (buf + 34));
secs <<= 32;
secs |= htonl(*(UInteger32 *) (buf + 36));
nsecs = htonl(*(UInteger32 *) (buf + 40));
secs |= ntohl(*(UInteger32 *) (buf + 36));
nsecs = ntohl(*(UInteger32 *) (buf + 40));
/* cfield added in the caller */
presp->requestReceiptTimestamp.secs = secs;
presp->requestReceiptTimestamp.scaled_nsecs = nsecs << 16;
......
......@@ -61,16 +61,11 @@ void pp_servo_got_sync(struct pp_instance *ppi)
struct pp_time *m_to_s_dly = &SRV(ppi)->m_to_s_dly;
/*
* calc 'master_to_slave_delay', removing the correction field
* added by transparent clocks in the path.
* cField contains the sum of sync and followup messages
* correctionField(s)
* calc 'master_to_slave_delay'; no correction field
* appears in the formulas because it's already merged with t1
*/
*m_to_s_dly = ppi->t2;
pp_time_sub(m_to_s_dly, &ppi->t1);
pp_time_sub(m_to_s_dly, &ppi->cField); /* FIXME: check cField */
pp_diag(ppi, servo, 3, "correction field 1: %s\n",
fmt_ppt(&ppi->cField));
}
/* Called by slave and uncalib when we have t1 and t2 */
......@@ -85,14 +80,11 @@ void pp_servo_got_psync(struct pp_instance *ppi)
pp_diag(ppi, servo, 2, "T2: %s\n", fmt_ppt(&ppi->t2));
/*
* calc 'master_to_slave_delay', removing the correction field
* added by transparent clocks in the path.
* calc 'master_to_slave_delay'; no correction field
* appears in the formulas because it's already merged with t1
*/
*m_to_s_dly = ppi->t2;
pp_time_sub(m_to_s_dly, &ppi->t1);
pp_time_sub(m_to_s_dly, &ppi->cField); /* FIXME: check cField */
pp_diag(ppi, servo, 3, "correction field 1: %s\n",
fmt_ppt(&ppi->cField));
/* update 'offsetFromMaster' and possibly jump in time */
if (pp_servo_offset_master(ppi, mpd, ofm, m_to_s_dly))
......@@ -136,9 +128,6 @@ void pp_servo_got_resp(struct pp_instance *ppi)
*/
*s_to_m_dly = ppi->t4;
pp_time_sub(s_to_m_dly, &ppi->t3);
pp_time_sub(s_to_m_dly, &ppi->cField); /* FIXME: cField check */
pp_diag(ppi, servo, 3, "correction field 2: %s\n",
fmt_ppt(&ppi->cField));
pp_diag(ppi, servo, 2, "T1: %s\n", fmt_ppt(&ppi->t1));
pp_diag(ppi, servo, 2, "T2: %s\n", fmt_ppt(&ppi->t2));
......@@ -193,9 +182,6 @@ void pp_servo_got_presp(struct pp_instance *ppi)
*/
*s_to_m_dly = ppi->t6;
pp_time_sub(s_to_m_dly, &ppi->t5);
pp_time_sub(s_to_m_dly, &ppi->cField); /* FIXME: check cField */
pp_diag(ppi, servo, 3, "correction field 2: %s\n",
fmt_ppt(&ppi->cField));
*m_to_s_dly = ppi->t4;
pp_time_sub(m_to_s_dly, &ppi->t3);
......
......@@ -53,7 +53,7 @@ static int slave_handle_response(struct pp_instance *ppi, unsigned char *pkt,
ppi->t4 = resp.receiveTimestamp;
pp_time_add(&ppi->t4, &hdr->cField);
/* NOTE: older code was adding cField later, in hooks.handle_resp */
/* WARNING: should be "sub" (see README-cfield::BUG) */
if (pp_hooks.handle_resp)
e = pp_hooks.handle_resp(ppi);
......
......@@ -173,6 +173,7 @@ static void dump_payload(char *prefix, void *pl, int len)
int donelen = 34; /* packet length before tlv */
int version = h->versionPTP_and_reserved & 0xf;
int messageType = h->type_and_transport_specific & 0xf;
char *cfptr = (void *)&h->correctionField;
if (version != 2) {
printf("%sVERSION: unsupported (%i)\n", prefix, version);
......@@ -181,8 +182,11 @@ static void dump_payload(char *prefix, void *pl, int len)
printf("%sVERSION: %i (type %i, len %i, domain %i)\n", prefix,
version, messageType,
ntohs(h->messageLength), h->domainNumber);
printf("%sFLAGS: 0x%04x (correction %08lu)\n", prefix, h->flagField,
(unsigned long)h->correctionField);
printf("%sFLAGS: 0x%04x (correction 0x%08x:%08x %08u)\n",
prefix, h->flagField,
ntohl(*(int *)cfptr),
ntohl(*(int *)(cfptr + 4)),
ntohl(*(int *)(cfptr + 4)));
dump_1port(prefix, "PORT: ", h->sourcePortIdentity);
printf("%sREST: seq %i, ctrl %i, log-interval %i\n", prefix,
ntohs(h->sequenceId), h->controlField, h->logMessageInterval);
......
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