From 5f9d36c76a0118fa757d21d047fd1dbcacbad335 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Sun, 9 Feb 2020 14:55:34 -0800 Subject: [PATCH] interface: Introduce a method to set the time stamping label. The ts_label field of the interface is set in different ways by different callers. In order to prevent users from open coding the logic that sets the label, this patch adds an appropriate method. Signed-off-by: Richard Cochran Reviewed-by: Jacob Keller --- interface.c | 5 +++++ interface.h | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/interface.c b/interface.c index 38116794..d7eeb419 100644 --- a/interface.c +++ b/interface.c @@ -28,6 +28,11 @@ const char *interface_name(struct interface *iface) return iface->name; } +void interface_set_label(struct interface *iface, const char *label) +{ + strncpy(iface->ts_label, label, MAX_IFNAME_SIZE); +} + void interface_set_name(struct interface *iface, const char *name) { strncpy(iface->name, name, MAX_IFNAME_SIZE); diff --git a/interface.h b/interface.h index 5f449ae7..f416b244 100644 --- a/interface.h +++ b/interface.h @@ -53,6 +53,13 @@ const char *interface_label(struct interface *iface); */ const char *interface_name(struct interface *iface); +/** + * Set the time stamping label of a given interface. + * @param iface The interface of interest. + * @param name The desired label for the interface. + */ +void interface_set_label(struct interface *iface, const char *label); + /** * Set the name of a given interface. * @param iface The interface of interest.