From 4d19f54b9419ec0497bf3bcc20da613d05f826f0 Mon Sep 17 00:00:00 2001 From: Matthew Kent Date: Tue, 4 Aug 2009 22:27:13 -0700 Subject: [PATCH] Finish support for IFF_SLAVE and add IFF_MASTER. Support both in ruby binding. --- bindings/ruby/rbsigar.c | 2 ++ include/sigar.h | 1 + src/sigar.c | 6 +++++- src/sigar_format.c | 6 ++++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/bindings/ruby/rbsigar.c b/bindings/ruby/rbsigar.c index 3030da8f..7bfc7a7d 100644 --- a/bindings/ruby/rbsigar.c +++ b/bindings/ruby/rbsigar.c @@ -682,6 +682,8 @@ static void Init_rbsigar_constants(VALUE rclass) RB_SIGAR_CONST_INT(IFF_PROMISC); RB_SIGAR_CONST_INT(IFF_ALLMULTI); RB_SIGAR_CONST_INT(IFF_MULTICAST); + RB_SIGAR_CONST_INT(IFF_SLAVE); + RB_SIGAR_CONST_INT(IFF_MASTER); RB_SIGAR_CONST_INT(NETCONN_CLIENT); RB_SIGAR_CONST_INT(NETCONN_SERVER); diff --git a/include/sigar.h b/include/sigar.h index 1de9dba5..a09ecebd 100644 --- a/include/sigar.h +++ b/include/sigar.h @@ -584,6 +584,7 @@ SIGAR_DECLARE(int) sigar_net_route_list_destroy(sigar_t *sigar, #define SIGAR_IFF_ALLMULTI 0x200 #define SIGAR_IFF_MULTICAST 0x800 #define SIGAR_IFF_SLAVE 0x1000 +#define SIGAR_IFF_MASTER 0x2000 #define SIGAR_NULL_HWADDR "00:00:00:00:00:00" diff --git a/src/sigar.c b/src/sigar.c index 114c98b5..9ab00450 100644 --- a/src/sigar.c +++ b/src/sigar.c @@ -1550,6 +1550,7 @@ int sigar_net_interface_config_get(sigar_t *sigar, const char *name, #ifdef __linux__ int is_mcast = flags & IFF_MULTICAST; int is_slave = flags & IFF_SLAVE; + int is_master = flags & IFF_MASTER; /* * XXX: should just define SIGAR_IFF_* * and test IFF_* bits on given platform. @@ -1557,13 +1558,16 @@ int sigar_net_interface_config_get(sigar_t *sigar, const char *name, * for the flags we care about. * */ - flags &= ~(IFF_MULTICAST|IFF_SLAVE); + flags &= ~(IFF_MULTICAST|IFF_SLAVE|IFF_MASTER); if (is_mcast) { flags |= SIGAR_IFF_MULTICAST; } if (is_slave) { flags |= SIGAR_IFF_SLAVE; } + if (is_master) { + flags |= SIGAR_IFF_MASTER; + } #endif ifconfig->flags = flags; } diff --git a/src/sigar_format.c b/src/sigar_format.c index b44c3a7f..ea7d5290 100644 --- a/src/sigar_format.c +++ b/src/sigar_format.c @@ -553,6 +553,12 @@ SIGAR_DECLARE(char *) sigar_net_interface_flags_to_string(sigar_uint64_t flags, if (flags & SIGAR_IFF_MULTICAST) { strcat(buf, "MULTICAST "); } + if (flags & SIGAR_IFF_SLAVE) { + strcat(buf, "SLAVE "); + } + if (flags & SIGAR_IFF_MASTER) { + strcat(buf, "MASTER "); + } return buf; }