summaryrefslogtreecommitdiffstats
path: root/if-bsd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-09-04 14:08:14 +0000
committerRoy Marples <roy@marples.name>2008-09-04 14:08:14 +0000
commit064dd58ee2542ff28fdc0e6615c434529c6c92a0 (patch)
treef2015bcd66b57205b609565fcf683fec43245229 /if-bsd.c
parent335b626a1731fed77776bae520a922435d94807a (diff)
downloaddhcpcd-064dd58ee2542ff28fdc0e6615c434529c6c92a0.tar.xz
Enable detection of addition and removal of interfaces on Linux.
Diffstat (limited to 'if-bsd.c')
-rw-r--r--if-bsd.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/if-bsd.c b/if-bsd.c
index 58aa10ff..53bf2d66 100644
--- a/if-bsd.c
+++ b/if-bsd.c
@@ -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;
}
}