From ec33010f56c675256511e1e63d45bf0773581fca Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Tue, 14 Feb 2017 16:51:04 +0100 Subject: [PATCH] port: 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 --- port.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/port.c b/port.c index 454c60d..627fbb2 100644 --- a/port.c +++ b/port.c @@ -106,6 +106,7 @@ struct port { unsigned int multiple_pdr_detected; enum port_state (*state_machine)(enum port_state state, enum fsm_event event, int mdiff); + int (*dscmp)(struct dataset *a, struct dataset *b); /* portDS */ struct PortIdentity portIdentity; enum port_state state; /*portState*/ @@ -2279,7 +2280,7 @@ struct foreign_clock *port_compute_best(struct port *p) if (!p->best) p->best = fc; - else if (dscmp(&fc->dataset, &p->best->dataset) > 0) + else if (p->dscmp(&fc->dataset, &p->best->dataset) > 0) p->best = fc; else fc_clear(fc); @@ -2860,6 +2861,7 @@ struct port *port_open(int phc_index, memset(p, 0, sizeof(*p)); p->state_machine = clock_slave_only(clock) ? ptp_slave_fsm : ptp_fsm; + p->dscmp = dscmp; p->phc_index = phc_index; p->jbod = config_get_int(cfg, interface->name, "boundary_clock_jbod"); transport = config_get_int(cfg, interface->name, "network_transport");