From b05991dbb85f2f60051f06581f9280b90cf18420 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Tue, 14 Feb 2017 16:52:38 +0100 Subject: [PATCH] clock: Make the data set comparison algorithm into a function variable. This will allow adding alternative algorithms as defined in PTP profiles. Signed-off-by: Richard Cochran --- clock.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clock.c b/clock.c index 97f1188..9f0d3be 100644 --- a/clock.c +++ b/clock.c @@ -80,6 +80,7 @@ struct clock { clockid_t clkid; struct servo *servo; enum servo_type servo_type; + int (*dscmp)(struct dataset *a, struct dataset *b); struct defaultDS dds; struct dataset default_dataset; struct currentDS cur; @@ -1051,6 +1052,7 @@ struct clock *clock_create(enum clock_type type, struct config *config, } c->servo_state = SERVO_UNLOCKED; c->servo_type = servo; + c->dscmp = dscmp; c->tsproc = tsproc_create(config_get_int(config, NULL, "tsproc_mode"), config_get_int(config, NULL, "delay_filter"), config_get_int(config, NULL, "delay_filter_length")); @@ -1686,7 +1688,7 @@ static void handle_state_decision_event(struct clock *c) fc = port_compute_best(piter); if (!fc) continue; - if (!best || dscmp(&fc->dataset, &best->dataset) > 0) + if (!best || c->dscmp(&fc->dataset, &best->dataset) > 0) best = fc; }