Skip to content

Commit

Permalink
interface: Introduce a method to initialize the time stamping label.
Browse files Browse the repository at this point in the history
In many cases, the time stamping label will be the same as the name of
the interface.  In order to prevent users from open coding the logic that
initializes the label from the interface name, this patch add an
appropriate method.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
  • Loading branch information
richardcochran committed Mar 4, 2020
1 parent 6d73e75 commit b802e3b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
*/
#include "interface.h"

void interface_ensure_tslabel(struct interface *iface)
{
if (!iface->ts_label[0]) {
strncpy(iface->ts_label, iface->name, MAX_IFNAME_SIZE);
}
}

int interface_get_tsinfo(struct interface *iface)
{
return sk_get_ts_info(iface->ts_label, &iface->ts_info);
Expand Down
6 changes: 6 additions & 0 deletions interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ struct interface {
struct sk_ts_info ts_info;
};

/**
* Ensures that an interface has a proper time stamping label.
* @param iface The interface of interest.
*/
void interface_ensure_tslabel(struct interface *iface);

/**
* Populate the time stamping information of a given interface.
* @param iface The interface of interest.
Expand Down

0 comments on commit b802e3b

Please sign in to comment.