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