Commit f5dbcdd3 authored by Davide Ciminaghi's avatar Davide Ciminaghi Committed by Alessandro Rubini

proto-standard/state-initializing.c: initialize parentDS

Before this commit, ANNOUNCE messages were sent with grandmaster-related
fields equal to 0. Values for such fields were taken from the parentDS data
set, which did not look properly initialized.

Paragraphs 8.2.3.2 to 8.2.3.9 of the ieee1588 standard specify
initialization values for the parentDS data set.
Many such values come from the defaultDS, so care must be taken to
initialize the parent data set __after__ the default data set.
We do this in pp-initializing().
Signed-off-by: Davide Ciminaghi's avatarDavide Ciminaghi <ciminaghi@gnudd.com>
parent fea217df
......@@ -8,6 +8,30 @@
#include <ppsi/ppsi.h>
/*
* Initialize parentDS
*/
static void init_parent_ds(struct pp_instance *ppi)
{
/* 8.2.3.2 */
DSPAR(ppi)->parentPortIdentity.clockIdentity =
DSDEF(ppi)->clockIdentity;
/* FIXME: portNumber ? */
/* 8.2.3.3 skipped (parentStats is not used) */
/* 8.2.3.4 */
DSPAR(ppi)->observedParentOffsetScaledLogVariance = 0xffff;
/* 8.2.3.5 */
DSPAR(ppi)->observedParentClockPhaseChangeRate = 0x7fffffffUL;
/* 8.2.3.6 */
DSPAR(ppi)->grandmasterIdentity = DSDEF(ppi)->clockIdentity;
/* 8.2.3.7 */
DSPAR(ppi)->grandmasterClockQuality = DSDEF(ppi)->clockQuality;
/* 8.2.3.8 */
DSPAR(ppi)->grandmasterPriority1 = DSDEF(ppi)->priority1;
/* 8.2.3.9 */
DSPAR(ppi)->grandmasterPriority2 = DSDEF(ppi)->priority2;
}
/*
* Initializes network and other stuff
*/
......@@ -22,6 +46,8 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen)
if (ppi->n_ops->init(ppi) < 0) /* it must handle being called twice */
goto failure;
init_parent_ds(ppi);
/* Clock identity comes from mac address with 0xff:0xfe intermixed */
id = (unsigned char *)&DSDEF(ppi)->clockIdentity;
mac = ppi->ch[PP_NP_GEN].addr;
......
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