From 48f6a31cc3efde528a941116e1ce0591622cf42f Mon Sep 17 00:00:00 2001 From: Jiri Benc Date: Wed, 11 Jun 2014 21:35:18 +0200 Subject: [PATCH] pmc_common: easy way to set port and broadcast target Implement pmc_target_port to set a port number, leaving clock identity unchanged, and pmc_target_all to set clock identity and port number to all 1's. Signed-off-by: Jiri Benc --- pmc_common.c | 12 +++++++++++- pmc_common.h | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/pmc_common.c b/pmc_common.c index 2c75074..41385da 100644 --- a/pmc_common.c +++ b/pmc_common.c @@ -78,7 +78,7 @@ struct pmc *pmc_create(enum transport_type transport_type, const char *iface_nam goto failed; } pmc->port_identity.portNumber = 1; - memset(&pmc->target, 0xff, sizeof(pmc->target)); + pmc_target_all(pmc); pmc->boundary_hops = boundary_hops; pmc->domain_number = domain_number; @@ -325,3 +325,13 @@ int pmc_target(struct pmc *pmc, struct PortIdentity *pid) pmc->target = *pid; return 0; } + +void pmc_target_port(struct pmc *pmc, UInteger16 portNumber) +{ + pmc->target.portNumber = portNumber; +} + +void pmc_target_all(struct pmc *pmc) +{ + memset(&pmc->target, 0xff, sizeof(pmc->target)); +} diff --git a/pmc_common.h b/pmc_common.h index 9fcb51d..9adb9d1 100644 --- a/pmc_common.h +++ b/pmc_common.h @@ -41,5 +41,7 @@ int pmc_send_set_action(struct pmc *pmc, int id, void *data, int datasize); struct ptp_message *pmc_recv(struct pmc *pmc); int pmc_target(struct pmc *pmc, struct PortIdentity *pid); +void pmc_target_port(struct pmc *pmc, UInteger16 portNumber); +void pmc_target_all(struct pmc *pmc); #endif