Signed-off-by: Mykola Zhuravel <[email protected]>
---
 pmc.c  | 15 +++++++++++++++
 util.c |  7 +++++++
 util.h |  5 +++++
 3 files changed, 27 insertions(+)

diff --git a/pmc.c b/pmc.c
index af9cc63..a991880 100644
--- a/pmc.c
+++ b/pmc.c
@@ -107,6 +107,7 @@ struct management_id idtab[] = {
        { "DELAY_MECHANISM", TLV_DELAY_MECHANISM, do_get_action },
        { "LOG_MIN_PDELAY_REQ_INTERVAL", TLV_LOG_MIN_PDELAY_REQ_INTERVAL, 
do_get_action },
        { "PORT_DATA_SET_NP", TLV_PORT_DATA_SET_NP, do_set_action },
+       { "PORT_PROPERTIES_NP", TLV_PORT_PROPERTIES_NP, do_get_action },
 };
 
 static const char *action_string[] = {
@@ -196,6 +197,7 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
        struct mgmt_clock_description *cd;
        struct portDS *p;
        struct port_ds_np *pnp;
+       struct port_properties_np *ppnp;
        if (msg_type(msg) != MANAGEMENT) {
                return;
        }
@@ -477,6 +479,19 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
                fprintf(fp, "LOG_MIN_PDELAY_REQ_INTERVAL "
                        IFMT "logMinPdelayReqInterval %hhd", mtd->val);
                break;
+       case TLV_PORT_PROPERTIES_NP:
+               ppnp = (struct port_properties_np *) mgt->data;
+               if (ppnp->port_state > PS_SLAVE) {
+                       ppnp->port_state = 0;
+               }
+               fprintf(fp, "PORT_PROPERTIES_NP "
+                       IFMT "portIdentity            %s"
+                       IFMT "portState               %s"
+                       IFMT "timestamping            %s"
+                       IFMT "interface               %s",
+                       pid2str(&ppnp->portIdentity), ps_str[ppnp->port_state],
+                       ts_str[ppnp->timestamping], text2str(&ppnp->interface));
+               break;
        }
 out:
        fprintf(fp, "\n");
diff --git a/util.c b/util.c
index 2b880ff..5f439fd 100644
--- a/util.c
+++ b/util.c
@@ -34,6 +34,13 @@
 
 static int running = 1;
 
+const char *ts_str[] = {
+    "SOFTWARE",
+    "HARDWARE",
+    "LEGACY HARDWARE",
+    "ONESTEP",
+};
+
 const char *ps_str[] = {
        "NONE",
        "INITIALIZING",
diff --git a/util.h b/util.h
index 0c1a357..9b41d89 100644
--- a/util.h
+++ b/util.h
@@ -26,6 +26,11 @@
 #include "ether.h"
 
 /**
+ * Table of human readable strings, one for each type of time stamp.
+ */
+extern const char *ts_str[];
+
+/**
  * Table of human readable strings, one for each port state.
  */
 extern const char *ps_str[];
-- 
2.8.4

-----Original Message-----
From: Richard Cochran [mailto:[email protected]] 
Sent: Tuesday, July 18, 2017 3:55 PM
To: Mykola Zhuravel <[email protected]>
Cc: [email protected]; Eilon Greenstein 
<[email protected]>; Amit Nishry <[email protected]>
Subject: Re: [Linuxptp-devel] [PATCH] pmc: support getting the port properties 
np.

On Tue, Jul 18, 2017 at 12:14:54PM +0000, Mykola Zhuravel wrote:
> Will printout below be a good example?
> 
> [admin@arc-switch120 ~]# pmc -u -d 127 'GET PORT_PROPERTIES_NP'          
> sending: GET PORT_PROPERTIES_NP                                          
>         e41d2d.fffe.446581-1 seq 0 RESPONSE MANAGEMENT PORT_PROPERTIES_NP
>                 Port Identity:           e41d2d.fffe.446581-1             
>                 Port State:                MASTER                           
>                 Time Stamping:       1                                
>                 Interface:                  eth11.0   

The time stamping field originates from an enumerated type.  You can let the 
pmc program print the corresponding human readable string:

                 Port Identity:       e41d2d.fffe.446581-1             
                 Port State:          MASTER                           
                 Time Stamping:       hardware
                 Interface:           eth11.0   

Thanks,
Richard


------------------------------------------------------------------------------
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

Reply via email to