Signed-off-by: Richard Cochran <[email protected]>
---
port.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/port.c b/port.c
index a1ad6f6..4f91dfd 100644
--- a/port.c
+++ b/port.c
@@ -72,6 +72,10 @@ struct port {
struct fdarray fda;
int fault_fd;
int phc_index;
+
+ int (*dispatch)(struct port *p, enum fsm_event event, int mdiff);
+ enum fsm_event (*event)(struct port *p, int fd_index);
+
int jbod;
struct foreign_clock *best;
enum syfu_state syfu;
@@ -2134,6 +2138,11 @@ static void port_p2p_transition(struct port *p, enum
port_state next)
int port_dispatch(struct port *p, enum fsm_event event, int mdiff)
{
+ return p->dispatch(p, event, mdiff);
+}
+
+static int bc_dispatch(struct port *p, enum fsm_event event, int mdiff)
+{
enum port_state next;
struct fault_interval i;
int fri_asap = 0;
@@ -2197,6 +2206,11 @@ int port_dispatch(struct port *p, enum fsm_event event,
int mdiff)
enum fsm_event port_event(struct port *p, int fd_index)
{
+ return p->event(p, fd_index);
+}
+
+static enum fsm_event bc_event(struct port *p, int fd_index)
+{
enum fsm_event event = EV_NONE;
struct ptp_message *msg;
int cnt, fd = p->fda.fd[fd_index], err;
@@ -2545,6 +2559,7 @@ struct port *port_open(int phc_index,
struct interface *interface,
struct clock *clock)
{
+ enum clock_type type = clock_type(clock);
struct config *cfg = clock_config(clock);
struct port *p = malloc(sizeof(*p));
enum transport_type transport;
@@ -2555,6 +2570,18 @@ struct port *port_open(int phc_index,
memset(p, 0, sizeof(*p));
+ switch (type) {
+ case CLOCK_TYPE_ORDINARY:
+ case CLOCK_TYPE_BOUNDARY:
+ p->dispatch = bc_dispatch;
+ p->event = bc_event;
+ break;
+ case CLOCK_TYPE_P2P:
+ case CLOCK_TYPE_E2E:
+ case CLOCK_TYPE_MANAGEMENT:
+ return NULL;
+ }
+
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");
--
2.1.4
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel