TLV_PORT_PROPERTIES_NP carries, among other attributes, a timestamp type used for that port. In order to make it possible to format the value for user consumption, introduce a new function ts_str().
Signed-off-by: Petr Machata <pe...@mellanox.com> --- util.c | 18 ++++++++++++++++++ util.h | 7 +++++++ 2 files changed, 25 insertions(+) diff --git a/util.c b/util.c index 833f1a5..e64a93d 100644 --- a/util.c +++ b/util.c @@ -70,6 +70,24 @@ const char *ev_str[] = { "RS_PASSIVE", }; +const char *ts_str(enum timestamp_type ts) +{ + switch (ts) { + case TS_SOFTWARE: + return "SOFTWARE"; + case TS_HARDWARE: + return "HARDWARE"; + case TS_LEGACY_HW: + return "LEGACY_HW"; + case TS_ONESTEP: + return "ONESTEP"; + case TS_P2P1STEP: + return "P2P1STEP"; + } + + return "???"; +} + int addreq(enum transport_type type, struct address *a, struct address *b) { void *bufa, *bufb; diff --git a/util.h b/util.h index 9d3f227..60d28ac 100644 --- a/util.h +++ b/util.h @@ -41,6 +41,13 @@ extern const char *ps_str[]; */ extern const char *ev_str[]; +/** + * Gets a human-readable string for a given timestamp type. + * @param ts Timestamp type. + * @return Human-readable rendering if TS is valid, otherwise "???". + */ +const char *ts_str(enum timestamp_type ts); + /** * Compares two binary addresses for equality. * @param type One of the enumerated transport types. -- 2.20.1 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel