From bb478479b28ea2a5b2ed538faf383b16493a394e Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Fri, 18 Nov 2005 18:26:52 +0000 Subject: [PATCH] add support for IFF_SLAVE flag (used by vmnic) --- bindings/java/src/net/hyperic/sigar/NetFlags.java | 4 ++++ include/sigar.h | 1 + src/sigar.c | 15 +++++++++------ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/bindings/java/src/net/hyperic/sigar/NetFlags.java b/bindings/java/src/net/hyperic/sigar/NetFlags.java index b0cef61a..210a7eb5 100644 --- a/bindings/java/src/net/hyperic/sigar/NetFlags.java +++ b/bindings/java/src/net/hyperic/sigar/NetFlags.java @@ -67,6 +67,8 @@ public class NetFlags { */ public final static int IFF_MULTICAST = 0x800; + public final static int IFF_SLAVE = 0x1000; + public static final int RTF_UP = 0x1; public static final int RTF_GATEWAY = 0x2; @@ -150,6 +152,8 @@ public class NetFlags { retval += "PROMISC "; if ((flags & IFF_ALLMULTI) > 0) retval += "ALLMULTI "; + if ((flags & IFF_SLAVE) > 0) + retval += "SLAVE "; if ((flags & IFF_MULTICAST) > 0) retval += "MULTICAST "; diff --git a/include/sigar.h b/include/sigar.h index 6f95d2ba..8a08a578 100644 --- a/include/sigar.h +++ b/include/sigar.h @@ -448,6 +448,7 @@ SIGAR_DECLARE(int) sigar_net_route_list_destroy(sigar_t *sigar, #define SIGAR_IFF_PROMISC 0x100 #define SIGAR_IFF_ALLMULTI 0x200 #define SIGAR_IFF_MULTICAST 0x800 +#define SIGAR_IFF_SLAVE 0x1000 #define SIGAR_NULL_HWADDR "00:00:00:00:00:00" diff --git a/src/sigar.c b/src/sigar.c index ad0824d6..7b392736 100644 --- a/src/sigar.c +++ b/src/sigar.c @@ -1212,8 +1212,10 @@ int sigar_net_interface_config_get(sigar_t *sigar, const char *name, } if (!ioctl(sock, SIOCGIFFLAGS, &ifr)) { - ifconfig->flags = ifr.ifr_flags; + sigar_uint64_t flags = ifr.ifr_flags; #ifdef __linux__ + int is_mcast = flags & IFF_MULTICAST; + int is_slave = flags & IFF_SLAVE; /* * XXX: should just define SIGAR_IFF_* * and test IFF_* bits on given platform. @@ -1221,14 +1223,15 @@ int sigar_net_interface_config_get(sigar_t *sigar, const char *name, * for the flags we care about. * */ - if (ifconfig->flags & IFF_MULTICAST) { - ifconfig->flags |= SIGAR_IFF_MULTICAST; + flags &= ~(IFF_MULTICAST|IFF_SLAVE); + if (is_mcast) { + flags |= SIGAR_IFF_MULTICAST; } - else { - /* 0x800 == IFF_SLAVE on linux */ - ifconfig->flags &= ~SIGAR_IFF_MULTICAST; + if (is_slave) { + flags |= SIGAR_IFF_SLAVE; } #endif + ifconfig->flags = flags; } else { /* should always be able to get flags for existing device */