On 22/03/2021 16:31, Erez Geva wrote:
> According to IEEE 1588 The slave only flag in the SLAVE_ONLY TLV
>   is bit 0 and not bit 1 as in the DEFAULT_DATA_SET TLV.
> 
> To retain backward compatibility and as bit 1 in SLAVE_ONLY
>   is not used anyway. Read and set both bits with same value.
> ---
>   clock.c | 2 +-
>   pmc.c   | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/clock.c b/clock.c
> index f88df58..410a5df 100644
> --- a/clock.c
> +++ b/clock.c
> @@ -404,7 +404,7 @@ static int clock_management_fill_response(struct clock 
> *c, struct port *p,
>               break;
>       case TLV_SLAVE_ONLY:
>               mtd = (struct management_tlv_datum *) tlv->data;
> -             mtd->val = c->dds.flags & DDS_SLAVE_ONLY;
> +             mtd->val = c->dds.flags & DDS_SLAVE_ONLY ? 0x3 : 0;
>               datalen = sizeof(*mtd);
>               break;
>       case TLV_CLOCK_ACCURACY:
> diff --git a/pmc.c b/pmc.c
> index 1e569b5..680c244 100644
> --- a/pmc.c
> +++ b/pmc.c
> @@ -315,7 +315,7 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
>       case TLV_SLAVE_ONLY:
>               mtd = (struct management_tlv_datum *) mgt->data;
>               fprintf(fp, "SLAVE_ONLY "
> -                     IFMT "slaveOnly %d", mtd->val & DDS_SLAVE_ONLY ? 1 : 0);
> +                     IFMT "slaveOnly %d", mtd->val > 0 ? 1 : 0);

On a second thought, we should and bitwise here too:
                        IFMT "slaveOnly %d", (mtd->val & 0x3) > 0 ? 1 : 0);

>               break;
>       case TLV_CLOCK_ACCURACY:
>               mtd = (struct management_tlv_datum *) mgt->data;
> 

_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to