From 43085ab741a9c07aff51dbefa597b5fabc76392f Mon Sep 17 00:00:00 2001 From: Vedang Patel Date: Thu, 28 Mar 2019 20:32:26 -0700 Subject: [PATCH] port: Separate unicast specific code from port_signaling_construct() Make port_signaling_construct() to create a generic signaling ptp_message. Move the unicast specific code to port_signaling_uc_construct(). This is done to support the creation of Message Interval Request TLV (as defined in 802.1AS Section 10.5.4.3). This TLV can be used to request change in Announce Interval, Sync Interval or Link Delay Interval on a remote system. [ RC - fix trivial rebase conflict on top of targetPortIdentity check. ] Signed-off-by: Vedang Patel Signed-off-by: Richard Cochran --- port_private.h | 6 +++--- port_signaling.c | 20 +++++++++++++++++--- unicast_client.c | 10 +++++----- unicast_service.c | 4 ++-- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/port_private.h b/port_private.h index b0b2a5d..1bc1c3f 100644 --- a/port_private.h +++ b/port_private.h @@ -169,9 +169,9 @@ int port_set_delay_tmo(struct port *p); int port_set_qualification_tmo(struct port *p); void port_show_transition(struct port *p, enum port_state next, enum fsm_event event); -struct ptp_message *port_signaling_construct(struct port *p, - struct address *address, - struct PortIdentity *tpid); +struct ptp_message *port_signaling_uc_construct(struct port *p, + struct address *address, + struct PortIdentity *tpid); int port_tx_announce(struct port *p, struct address *dst); int port_tx_sync(struct port *p, struct address *dst); int process_announce(struct port *p, struct ptp_message *m); diff --git a/port_signaling.c b/port_signaling.c index ec3ad87..09d4506 100644 --- a/port_signaling.c +++ b/port_signaling.c @@ -28,9 +28,8 @@ static struct PortIdentity wildcard = { .portNumber = 0xffff, }; -struct ptp_message *port_signaling_construct(struct port *p, - struct address *address, - struct PortIdentity *tpid) +static struct ptp_message *port_signaling_construct(struct port *p, + struct PortIdentity *tpid) { struct ptp_message *msg; @@ -48,6 +47,21 @@ struct ptp_message *port_signaling_construct(struct port *p, msg->header.control = CTL_OTHER; msg->header.logMessageInterval = 0x7F; msg->signaling.targetPortIdentity = *tpid; + + return msg; +} + +struct ptp_message *port_signaling_uc_construct(struct port *p, + struct address *address, + struct PortIdentity *tpid) +{ + struct ptp_message *msg; + + msg = port_signaling_construct(p, tpid); + if (!msg) { + return NULL; + } + msg->header.flagField[0] |= UNICAST; msg->address = *address; diff --git a/unicast_client.c b/unicast_client.c index 91b99ed..e997672 100644 --- a/unicast_client.c +++ b/unicast_client.c @@ -68,7 +68,7 @@ static int unicast_client_announce(struct port *p, struct ptp_message *msg; int err; - msg = port_signaling_construct(p, &dst->address, &dst->portIdentity); + msg = port_signaling_uc_construct(p, &dst->address, &dst->portIdentity); if (!msg) { return -1; } @@ -129,7 +129,7 @@ static int unicast_client_peer_renew(struct port *p) peer->renewal_tmo = 0; pr_debug("port %d: time to renew P2P unicast subscription", portnum(p)); - msg = port_signaling_construct(p, &peer->address, &peer->portIdentity); + msg = port_signaling_uc_construct(p, &peer->address, &peer->portIdentity); if (!msg) { return -1; } @@ -165,7 +165,7 @@ static int unicast_client_renew(struct port *p, dst->renewal_tmo = 0; pr_debug("port %d: time to renew unicast subscriptions", portnum(p)); - msg = port_signaling_construct(p, &dst->address, &dst->portIdentity); + msg = port_signaling_uc_construct(p, &dst->address, &dst->portIdentity); if (!msg) { return -1; } @@ -225,7 +225,7 @@ static int unicast_client_sydy(struct port *p, struct ptp_message *msg; int err; - msg = port_signaling_construct(p, &dst->address, &dst->portIdentity); + msg = port_signaling_uc_construct(p, &dst->address, &dst->portIdentity); if (!msg) { return -1; } @@ -285,7 +285,7 @@ int unicast_client_cancel(struct port *p, struct ptp_message *m, ucma->granted &= ~(1 << mtype); /* Respond with ACK. */ - msg = port_signaling_construct(p, &ucma->address, &ucma->portIdentity); + msg = port_signaling_uc_construct(p, &ucma->address, &ucma->portIdentity); if (!msg) { return -1; } diff --git a/unicast_service.c b/unicast_service.c index 9c9b95b..ec5ee6c 100644 --- a/unicast_service.c +++ b/unicast_service.c @@ -241,8 +241,8 @@ static int unicast_service_reply(struct port *p, struct ptp_message *dst, struct ptp_message *msg; int err; - msg = port_signaling_construct(p, &dst->address, - &dst->header.sourcePortIdentity); + msg = port_signaling_uc_construct(p, &dst->address, + &dst->header.sourcePortIdentity); if (!msg) { return -1; }