From 948d5115502e48b798bbd29ca0816d9551071762 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Sat, 3 Oct 2015 11:27:02 +0200 Subject: [PATCH] clock: offer a method to get the type rather than the number of ports. The port code is not interested in the number of ports but rather the clock type. Since the polymorphic clock object will be able to report its own type, this patch changes the clock interface accordingly. Signed-off-by: Richard Cochran --- clock.c | 7 +++++-- clock.h | 6 +++--- port.c | 7 +------ 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/clock.c b/clock.c index 8154087..d8a2616 100644 --- a/clock.c +++ b/clock.c @@ -1628,9 +1628,12 @@ struct clock_description *clock_description(struct clock *c) return &c->desc; } -int clock_num_ports(struct clock *c) +enum clock_type clock_type(struct clock *c) { - return c->nports; + if (c->nports > 1) { + return CLOCK_TYPE_BOUNDARY; + } + return CLOCK_TYPE_ORDINARY; } void clock_check_ts(struct clock *c, struct timespec ts) diff --git a/clock.h b/clock.h index d866762..47863dc 100644 --- a/clock.h +++ b/clock.h @@ -267,11 +267,11 @@ void clock_update_time_properties(struct clock *c, struct timePropertiesDS tds); struct clock_description *clock_description(struct clock *c); /** - * Obtain the number of ports a clock has, excluding the UDS port. + * Obtain the type of a clock. * @param c The clock instance. - * @return The number of ports. + * @return One of the @ref clock_type enumeration values. */ -int clock_num_ports(struct clock *c); +enum clock_type clock_type(struct clock *c); /** * Perform a sanity check on a time stamp made by a clock. diff --git a/port.c b/port.c index 93a79b1..161157c 100644 --- a/port.c +++ b/port.c @@ -706,12 +706,7 @@ static int port_management_fill_response(struct port *target, buf = tlv->data; cd->clockType = (UInteger16 *) buf; buf += sizeof(*cd->clockType); - if (clock_num_ports(target->clock) > 1) { - *cd->clockType = CLOCK_TYPE_BOUNDARY; - } else { - *cd->clockType = CLOCK_TYPE_ORDINARY; - } - + *cd->clockType = clock_type(target->clock); cd->physicalLayerProtocol = (struct PTPText *) buf; switch(transport_type(target->trp)) { case TRANS_UDP_IPV4: