mirror of
https://github.com/rsmarples/dhcpcd.git
synced 2024-11-24 10:35:03 +08:00
Fix compile on Linux.
This commit is contained in:
parent
1abffd5ba5
commit
a89ac9ad96
4
dhcpcd.c
4
dhcpcd.c
@ -35,6 +35,10 @@ const char copyright[] = "Copyright (c) 2006-2009 Roy Marples";
|
||||
#include <arpa/inet.h>
|
||||
#include <net/route.h>
|
||||
|
||||
#ifdef __linux__
|
||||
# include <linux/rtnetlink.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
|
29
if-linux.c
29
if-linux.c
@ -63,10 +63,6 @@
|
||||
|
||||
#define BUFFERLEN 256
|
||||
|
||||
static void (*nl_carrier)(const char *);
|
||||
static void (*nl_add)(const char *);
|
||||
static void (*nl_remove)(const char *);
|
||||
|
||||
static int sock_fd;
|
||||
static struct sockaddr_nl sock_nl;
|
||||
|
||||
@ -253,30 +249,17 @@ link_netlink(struct nlmsghdr *nlm)
|
||||
}
|
||||
rta = RTA_NEXT(rta, len);
|
||||
}
|
||||
if (nlm->nlmsg_type == RTM_NEWLINK) {
|
||||
if (ifi->ifi_change == ~0U) {
|
||||
if (nl_add)
|
||||
nl_add(ifn);
|
||||
} else {
|
||||
if (nl_carrier)
|
||||
nl_carrier(ifn);
|
||||
}
|
||||
} else {
|
||||
if (nl_remove)
|
||||
nl_remove(ifn);
|
||||
}
|
||||
if (nlm->nlmsg_type == RTM_NEWLINK)
|
||||
len = ifi->ifi_change == ~0U ? 1 : 0;
|
||||
else
|
||||
len = -1;
|
||||
handle_interface(len, ifn);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
manage_link(int fd,
|
||||
void (*if_carrier)(const char *),
|
||||
void (*if_add)(const char *),
|
||||
void (*if_remove)(const char *))
|
||||
manage_link(int fd)
|
||||
{
|
||||
nl_carrier = if_carrier;
|
||||
nl_add = if_add;
|
||||
nl_remove = if_remove;
|
||||
return get_netlink(fd, MSG_DONTWAIT, &link_netlink);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user