Finish support for IFF_SLAVE and add IFF_MASTER.

Support both in ruby binding.
This commit is contained in:
Matthew Kent 2009-08-04 22:27:13 -07:00
parent 48f9f8cc65
commit 4d19f54b94
4 changed files with 14 additions and 1 deletions

View File

@ -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);

View File

@ -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"

View File

@ -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;
}

View File

@ -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;
}