Make port_signaling_construct() to create a generic signaling
ptp_message. Move the unicast specific options to
port_unicast_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.

Signed-off-by: Vedang Patel <vedang.pa...@intel.com>
---
 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 e114c4c85209..0bcfb4ae6cab 100644
--- a/port_private.h
+++ b/port_private.h
@@ -168,9 +168,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_unicast_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 f845d36f6e61..d4f1939b8bea 100644
--- a/port_signaling.c
+++ b/port_signaling.c
@@ -21,9 +21,8 @@
 #include "unicast_client.h"
 #include "unicast_service.h"
 
-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;
 
@@ -41,6 +40,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_unicast_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 de5eee9f4574..5c57c1873315 100644
--- a/unicast_client.c
+++ b/unicast_client.c
@@ -75,7 +75,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_unicast_construct(p, &dst->address, &dst->portIdentity);
        if (!msg) {
                return -1;
        }
@@ -140,7 +140,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_unicast_construct(p, &peer->address, &peer->portIdentity);
        if (!msg) {
                return -1;
        }
@@ -176,7 +176,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_unicast_construct(p, &dst->address, &dst->portIdentity);
        if (!msg) {
                return -1;
        }
@@ -236,7 +236,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_unicast_construct(p, &dst->address, &dst->portIdentity);
        if (!msg) {
                return -1;
        }
@@ -296,7 +296,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_unicast_construct(p, &ucma->address, &ucma->portIdentity);
        if (!msg) {
                return -1;
        }
diff --git a/unicast_service.c b/unicast_service.c
index 9c9b95b05187..cf93f321acc6 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_unicast_construct(p, &dst->address,
+                                    &dst->header.sourcePortIdentity);
        if (!msg) {
                return -1;
        }
-- 
2.7.3



_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to