summaryrefslogtreecommitdiff
path: root/sysdep/linux
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2010-11-11 10:03:02 +0100
committerOndrej Zajicek <santiago@crfreenet.org>2010-11-11 10:03:02 +0100
commitf25cb0ef9f6341648513e793a3162b32fc250d2b (patch)
tree393dbeeecd58fdb1cfcbafd26ce771f20376bf15 /sysdep/linux
parent5cdf264f937687aff194574f5fe2badb087337b8 (diff)
Implements link state detection.
Also changes some symbol names (IFF_ADMIN_DOWN -> IFF_SHUTDOWN, IFF_LINK_UP -> IFF_ADMIN_UP).
Diffstat (limited to 'sysdep/linux')
-rw-r--r--sysdep/linux/netlink/netlink.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/sysdep/linux/netlink/netlink.c b/sysdep/linux/netlink/netlink.c
index 2dd0359b..79f7210a 100644
--- a/sysdep/linux/netlink/netlink.c
+++ b/sysdep/linux/netlink/netlink.c
@@ -8,7 +8,6 @@
#include <stdio.h>
#include <fcntl.h>
-#include <net/if.h>
#include <sys/socket.h>
#include <sys/uio.h>
#include <errno.h>
@@ -27,6 +26,7 @@
#include "conf/conf.h"
#include <asm/types.h>
+#include <linux/if.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
@@ -34,6 +34,10 @@
#define MSG_TRUNC 0x20
#endif
+#ifndef IFF_LOWER_UP
+#define IFF_LOWER_UP 0x10000
+#endif
+
/*
* Synchronous Netlink interface
*/
@@ -281,6 +285,8 @@ nl_parse_link(struct nlmsghdr *h, int scan)
u32 mtu;
unsigned int fl;
+ debug("nl_parse_link %d\n", new);
+
if (!(i = nl_checkin(h, sizeof(*i))) || !nl_parse_attrs(IFLA_RTA(i), a, sizeof(a)))
return;
if (!a[IFLA_IFNAME] || RTA_PAYLOAD(a[IFLA_IFNAME]) < 2 ||
@@ -293,6 +299,8 @@ nl_parse_link(struct nlmsghdr *h, int scan)
name = RTA_DATA(a[IFLA_IFNAME]);
memcpy(&mtu, RTA_DATA(a[IFLA_MTU]), sizeof(u32));
+ debug("nl_parse_link name %s index %d flags %x\n", name, i->ifi_index, i->ifi_flags);
+
ifi = if_find_by_index(i->ifi_index);
if (!new)
{
@@ -300,7 +308,7 @@ nl_parse_link(struct nlmsghdr *h, int scan)
if (ifi && !scan)
{
memcpy(&f, ifi, sizeof(struct iface));
- f.flags |= IF_ADMIN_DOWN;
+ f.flags |= IF_SHUTDOWN;
if_update(&f);
}
}
@@ -319,6 +327,8 @@ nl_parse_link(struct nlmsghdr *h, int scan)
f.flags = 0;
fl = i->ifi_flags;
if (fl & IFF_UP)
+ f.flags |= IF_ADMIN_UP;
+ if (fl & IFF_LOWER_UP)
f.flags |= IF_LINK_UP;
if (fl & IFF_LOOPBACK) /* Loopback */
f.flags |= IF_MULTIACCESS | IF_LOOPBACK | IF_IGNORE;