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 <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
master
Richard Cochran 2020-02-09 14:55:34 -08:00
parent d471a57aa8
commit 5f9d36c76a
2 changed files with 12 additions and 0 deletions

View File

@ -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);

View File

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