From 64dcf257e33dc7f52e523ea2c80c1d9c6cb9a2af Mon Sep 17 00:00:00 2001 From: Jacob Keller Date: Mon, 20 Aug 2012 10:56:18 -0700 Subject: [PATCH] ptp4l: pass struct interface directly instead of passing it's sub arguments the port_open function takes a large number of command options, a few of which are actually all values of struct interface. This patch modifies the port_open call to take a struct interface value instead of all the other values. This simplifies the overall work necessary and allows for adding new port configuration values by appending them to the struct interface Signed-off-by: Jacob Keller --- clock.c | 3 +-- port.c | 12 +++++------- port.h | 16 +++++++--------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/clock.c b/clock.c index af49d7b..16a6ba2 100644 --- a/clock.c +++ b/clock.c @@ -267,8 +267,7 @@ struct clock *clock_create(int phc_index, struct interface *iface, int count, c->fault_timeout = FAULT_RESET_SECONDS; for (i = 0; i < count; i++) { - c->port[i] = port_open(pod, phc_index, iface[i].name, iface[i].transport, - timestamping, 1+i, iface[i].dm, c); + c->port[i] = port_open(pod, phc_index, timestamping, 1+i, &iface[i], c); if (!c->port[i]) { pr_err("failed to open port %s", iface[i].name); return NULL; diff --git a/port.c b/port.c index ba80478..563c844 100644 --- a/port.c +++ b/port.c @@ -1539,11 +1539,9 @@ struct ptp_message *port_management_reply(struct PortIdentity pid, struct port *port_open(struct port_defaults *pod, int phc_index, - char *name, - enum transport_type transport, enum timestamp_type timestamping, int number, - enum delay_mechanism dm, + struct interface *interface, struct clock *clock) { struct port *p = malloc(sizeof(*p)); @@ -1554,7 +1552,7 @@ struct port *port_open(struct port_defaults *pod, memset(p, 0, sizeof(*p)); - if (sk_interface_phc(name, &checked_phc_index)) + if (sk_interface_phc(interface->name, &checked_phc_index)) pr_warning("port %d: get_ts_info not supported", number); else if (phc_index >= 0 && phc_index != checked_phc_index) { pr_err("port %d: PHC device mismatch", number); @@ -1564,9 +1562,9 @@ struct port *port_open(struct port_defaults *pod, } p->pod = *pod; - p->name = name; + p->name = interface->name; p->clock = clock; - p->trp = transport_create(transport); + p->trp = transport_create(interface->transport); if (!p->trp) { free(p); return NULL; @@ -1575,7 +1573,7 @@ struct port *port_open(struct port_defaults *pod, p->portIdentity.clockIdentity = clock_identity(clock); p->portIdentity.portNumber = number; p->state = PS_INITIALIZING; - p->delayMechanism = dm; + p->delayMechanism = interface->dm; p->versionNumber = PTP_VERSION; p->avg_delay = mave_create(PORT_MAVE_LENGTH); diff --git a/port.h b/port.h index 3e2b1c7..d4c2075 100644 --- a/port.h +++ b/port.h @@ -25,7 +25,9 @@ #include "fsm.h" #include "transport.h" -struct clock; /*forward declaration*/ +/* forward declarations */ +struct interface; +struct clock; /** Opaque type. */ struct port; @@ -128,21 +130,17 @@ struct ptp_message *port_management_reply(struct PortIdentity pid, * Open a network port. * @param pod A pointer to a default port data set for this port. * @param phc_index The PHC device index for the network device. - * @param name The name of the network interface. - * @param transport The network transport type to use on this port. - * @param timestamping The flavor of time stamping to use on this port. - * @param number An arbitrary port number for this port. - * @param dm Which delay mechanism to use on this port. + * @param timestamping The timestamping mode for this port. + * @param number An arbitrary number assigned to this port. + * @param interface The interface data * @param clock A pointer to the system PTP clock. * @return A pointer to an open port on success, or NULL otherwise. */ struct port *port_open(struct port_defaults *pod, int phc_index, - char *name, - enum transport_type transport, enum timestamp_type timestamping, int number, - enum delay_mechanism dm, + struct interface *interface, struct clock *clock); /**