From 5ec635a1b4689b85165d09aa0c5628476052ee36 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Thu, 5 Apr 2007 15:41:43 +0000 Subject: [PATCH] change sigar_net_interface_config_get to return sigar_net_interface_config_primary_get if name == NULL --- src/os/darwin/darwin_sigar.c | 4 ++++ src/os/netware/netware_sigar.c | 4 ++++ src/os/win32/win32_sigar.c | 4 ++++ src/sigar.c | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/src/os/darwin/darwin_sigar.c b/src/os/darwin/darwin_sigar.c index 2ef2bbf1..7f99d3de 100644 --- a/src/os/darwin/darwin_sigar.c +++ b/src/os/darwin/darwin_sigar.c @@ -1824,6 +1824,10 @@ int sigar_net_interface_config_get(sigar_t *sigar, const char *name, struct sockaddr_dl *sdl; struct ifreq ifr; + if (!name) { + return sigar_net_interface_config_primary_get(sigar, ifconfig); + } + if (sigar->ifconf_len == 0) { if ((status = sigar_ifmsg_init(sigar)) != SIGAR_OK) { return status; diff --git a/src/os/netware/netware_sigar.c b/src/os/netware/netware_sigar.c index 1f70f2a1..479f7f36 100644 --- a/src/os/netware/netware_sigar.c +++ b/src/os/netware/netware_sigar.c @@ -542,6 +542,10 @@ sigar_net_interface_config_get(sigar_t *sigar, INTERFACE_INFO *if_info = NULL; u_long flags; + if (!name) { + return sigar_net_interface_config_primary_get(sigar, ifconfig); + } + /* win32 lacks socket ioctls to query given interface. * so we loop through the list to find our made up ifname. */ diff --git a/src/os/win32/win32_sigar.c b/src/os/win32/win32_sigar.c index 8c40d14c..d7050c87 100644 --- a/src/os/win32/win32_sigar.c +++ b/src/os/win32/win32_sigar.c @@ -2446,6 +2446,10 @@ sigar_net_interface_config_get(sigar_t *sigar, MIB_IPADDRROW *ipaddr; int status; + if (!name) { + return sigar_net_interface_config_primary_get(sigar, ifconfig); + } + status = get_mib_ifrow(sigar, name, &ifr); if (status != SIGAR_OK) { return status; diff --git a/src/sigar.c b/src/sigar.c index e261349f..c68c5a40 100644 --- a/src/sigar.c +++ b/src/sigar.c @@ -1468,6 +1468,10 @@ int sigar_net_interface_config_get(sigar_t *sigar, const char *name, int sock; struct ifreq ifr; + if (!name) { + return sigar_net_interface_config_primary_get(sigar, ifconfig); + } + SIGAR_ZERO(ifconfig); if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {