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 <richardcochran@gmail.com>
master
Richard Cochran 2015-10-03 11:27:02 +02:00
parent fd2eb9411f
commit 948d511550
3 changed files with 9 additions and 11 deletions

View File

@ -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)

View File

@ -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.

7
port.c
View File

@ -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: