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.