With ports being able to be non-local if the PMC agent is using a non-UDS transport, it is useful to have a unique way of identifying them. Choose the clock ID as being that unique identifier and export a function that retrieves the identity of the clock we're connected to.
Signed-off-by: Vladimir Oltean <olte...@gmail.com> --- pmc_agent.c | 10 ++++++++++ pmc_agent.h | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/pmc_agent.c b/pmc_agent.c index b617d12f5287..e1c513fe10da 100644 --- a/pmc_agent.c +++ b/pmc_agent.c @@ -293,6 +293,16 @@ int pmc_agent_get_number_ports(struct pmc_agent *node) return node->dds.numberPorts; } +int pmc_agent_get_clock_identity(struct pmc_agent *node, + struct ClockIdentity *cid) +{ + if (!node->dds_valid) + return -1; + + *cid = node->dds.clockIdentity; + return 0; +} + int pmc_agent_query_dds(struct pmc_agent *node, int timeout) { struct ptp_message *msg; diff --git a/pmc_agent.h b/pmc_agent.h index feffac6f1b64..9dc85e300f9e 100644 --- a/pmc_agent.h +++ b/pmc_agent.h @@ -72,6 +72,18 @@ int pmc_agent_get_leap(struct pmc_agent *agent); */ int pmc_agent_get_number_ports(struct pmc_agent *agent); +/** + * Gets the clock identity from the default data set. Users + * should first call pmc_agent_query_dds() before invoking this + * function. + * + * @param agent Pointer to a PMC instance obtained via @ref pmc_agent_create(). + * @param cid Pointer to the return storage for the clock identity. + * @return 0 on success, or -1 if unknown. + */ +int pmc_agent_get_clock_identity(struct pmc_agent *node, + struct ClockIdentity *cid); + /** * Gets the TAI-UTC offset. * @param agent Pointer to a PMC instance obtained via @ref pmc_agent_create(). -- 2.25.1 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel