diff options
-rw-r--r-- | netlink-notify.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/netlink-notify.c b/netlink-notify.c index 6570323..ef8a8be 100644 --- a/netlink-notify.c +++ b/netlink-notify.c @@ -234,9 +234,17 @@ int msg_handler (struct sockaddr_nl *nl, struct nlmsghdr *msg) { maxinterface++; if (verbose > 0) - printf("%s: Initializing interface %d.\n", program, maxinterface); + printf("%s: Initializing interface %d: ", program, maxinterface); + + /* get interface name and store it + * in case the interface does no longer exist this may fail, + * use static string '(unknown)' instead */ + if (if_indextoname(maxinterface, ifs[maxinterface].name) == NULL) + strcpy(ifs[maxinterface].name, "(unknown)"); + + if (verbose > 0) + printf("%s\n", ifs[maxinterface].name); - strcpy(ifs[maxinterface].name, "(unknown)"); ifs[maxinterface].state = -1; ifs[maxinterface].deleted = 0; |