add support for IFF_SLAVE flag (used by vmnic)

This commit is contained in:
Doug MacEachern 2005-11-18 18:26:52 +00:00
parent 583922f3d0
commit bb478479b2
3 changed files with 14 additions and 6 deletions

View File

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

View File

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

View File

@ -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 */