diff options
| author | Roy Marples <roy@marples.name> | 2008-09-04 14:08:14 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2008-09-04 14:08:14 +0000 |
| commit | 064dd58ee2542ff28fdc0e6615c434529c6c92a0 (patch) | |
| tree | f2015bcd66b57205b609565fcf683fec43245229 /if-bsd.c | |
| parent | 335b626a1731fed77776bae520a922435d94807a (diff) | |
| download | dhcpcd-064dd58ee2542ff28fdc0e6615c434529c6c92a0.tar.xz | |
Enable detection of addition and removal of interfaces on Linux.
Diffstat (limited to 'if-bsd.c')
| -rw-r--r-- | if-bsd.c | 22 |
1 files changed, 8 insertions, 14 deletions
@@ -196,12 +196,13 @@ open_link_socket(void) #define BUFFER_LEN 2048 int -manage_link(int fd, struct interface *ifaces, - void (*if_carrier)(struct interface *), +manage_link(int fd, + void (*if_carrier)(const char *), void (*if_add)(const char *), - void (*if_remove)(struct interface *)) + void (*if_remove)(const char *)) { char buffer[2048], *p; + char ifname[IFNAMSIZ + 1]; ssize_t bytes; struct rt_msghdr *rtm; struct if_announcemsghdr *ifa; @@ -230,21 +231,14 @@ manage_link(int fd, struct interface *ifaces, if_add(ifa->ifan_name); break; case IFAN_DEPARTURE: - for (iface = ifaces; iface; iface = iface->next) - if (strcmp(ifa->ifan_name, iface->name) == 0) { - if_remove(iface); - break; - } + if_remove(ifa->ifan_name); break; - } break; case RTM_IFINFO: ifm = (struct if_msghdr *)p; - for (iface = ifaces; iface; iface = iface->next) - if (ifm->ifm_index == if_nametoindex(iface->name)) { - if_carrier(iface); - break; - } + memset(ifname, 0, sizeof(ifname)); + if (if_indextoname(ifm->ifm_index, ifname)) + if_carrier(ifname); break; } } |
