From 6c5b61a64c4bd31090703f1e24f89e140dc490d7 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Tue, 5 May 2020 12:36:44 -0700 Subject: [PATCH] pmc: Support getting and setting the local synchronization uncertain flag. Signed-off-by: Richard Cochran --- pmc.c | 5 +++++ pmc_common.c | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/pmc.c b/pmc.c index f074621..490c140 100644 --- a/pmc.c +++ b/pmc.c @@ -305,6 +305,11 @@ static void pmc_show(struct ptp_message *msg, FILE *fp) sen->duration, (sen->bitmask[0] & 1 << NOTIFY_PORT_STATE) ? "on" : "off"); break; + case TLV_SYNCHRONIZATION_UNCERTAIN_NP: + mtd = (struct management_tlv_datum *) mgt->data; + fprintf(fp, "SYNCHRONIZATION_UNCERTAIN_NP " + IFMT "uncertain %hhu", mtd->val); + break; case TLV_PORT_DATA_SET: p = (struct portDS *) mgt->data; if (p->portState > PS_SLAVE) { diff --git a/pmc_common.c b/pmc_common.c index 822dd6d..f07f6f6 100644 --- a/pmc_common.c +++ b/pmc_common.c @@ -110,6 +110,7 @@ struct management_id idtab[] = { { "TIME_STATUS_NP", TLV_TIME_STATUS_NP, do_get_action }, { "GRANDMASTER_SETTINGS_NP", TLV_GRANDMASTER_SETTINGS_NP, do_set_action }, { "SUBSCRIBE_EVENTS_NP", TLV_SUBSCRIBE_EVENTS_NP, do_set_action }, + { "SYNCHRONIZATION_UNCERTAIN_NP", TLV_SYNCHRONIZATION_UNCERTAIN_NP, do_set_action }, /* Port management ID values */ { "NULL_MANAGEMENT", TLV_NULL_MANAGEMENT, null_management }, { "CLOCK_DESCRIPTION", TLV_CLOCK_DESCRIPTION, do_get_action }, @@ -236,6 +237,27 @@ static void do_set_action(struct pmc *pmc, int action, int index, char *str) } pmc_send_set_action(pmc, code, &sen, sizeof(sen)); break; + case TLV_SYNCHRONIZATION_UNCERTAIN_NP: + cnt = sscanf(str, " %*s %*s %hhu", &mtd.val); + if (cnt != 1) { + fprintf(stderr, "%s SET needs 1 value\n", + idtab[index].name); + break; + } + switch (mtd.val) { + case SYNC_UNCERTAIN_DONTCARE: + case SYNC_UNCERTAIN_FALSE: + case SYNC_UNCERTAIN_TRUE: + pmc_send_set_action(pmc, code, &mtd, sizeof(mtd)); + break; + default: + fprintf(stderr, "\nusage: set SYNCHRONIZATION_UNCERTAIN_NP " + "%hhu (false), %hhu (true), or %hhu (don't care)\n\n", + SYNC_UNCERTAIN_FALSE, + SYNC_UNCERTAIN_TRUE, + SYNC_UNCERTAIN_DONTCARE); + } + break; case TLV_PORT_DATA_SET_NP: cnt = sscanf(str, " %*s %*s " "neighborPropDelayThresh %u "