The name 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 name, this patch adds an appropriate method.
Signed-off-by: Richard Cochran <richardcoch...@gmail.com> --- interface.c | 5 +++++ interface.h | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/interface.c b/interface.c index 662552d..3811679 100644 --- a/interface.c +++ b/interface.c @@ -27,3 +27,8 @@ const char *interface_name(struct interface *iface) { return iface->name; } + +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 371185d..5f449ae 100644 --- a/interface.h +++ b/interface.h @@ -53,5 +53,11 @@ const char *interface_label(struct interface *iface); */ const char *interface_name(struct interface *iface); -#endif +/** + * Set the name of a given interface. + * @param iface The interface of interest. + * @param name The desired name for the interface. + */ +void interface_set_name(struct interface *iface, const char *name); +#endif -- 2.20.1 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel