From 7a30f1e4a2df85ab1cc1918fccca508956c47aa4 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Tue, 15 Sep 2009 14:53:30 -0700 Subject: [PATCH] (SIGAR-182) use mib2_ip_t.ipRouteEntrySize to determine mib2_ipRouteEntry_t size --- src/os/solaris/solaris_sigar.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/os/solaris/solaris_sigar.c b/src/os/solaris/solaris_sigar.c index ca159ae6..5c7f0f85 100644 --- a/src/os/solaris/solaris_sigar.c +++ b/src/os/solaris/solaris_sigar.c @@ -1848,13 +1848,8 @@ int sigar_net_route_list_get(sigar_t *sigar, char *data; int len, rc; struct opthdr *op; - size_t nread=0, size=sizeof(mib2_ipRouteEntry_t); - - if (sigar->solaris_version >= 10) { - size += /* bincompat for new solaris 10 fields */ - sizeof(DeviceName) + - sizeof(IpAddress); - } + size_t nread=0, size=0; + const char *size_from; sigar_net_route_list_create(routelist); @@ -1862,10 +1857,33 @@ int sigar_net_route_list_get(sigar_t *sigar, mib2_ipRouteEntry_t *entry; char *end; - if (!((op->level == MIB2_IP) && (op->name == MIB2_IP_21))) { + if (op->level != MIB2_IP) { continue; } + if (op->name == 0) { + /* we want to use this size for bincompat */ + size = ((mib2_ip_t *)data)->ipRouteEntrySize; + continue; + } + else if (op->name != MIB2_IP_21) { + continue; + } + + if (size == 0) { + size_from = "sizeof"; + size = sizeof(*entry); + } + else { + size_from = "mib2_ip"; + } + + if (SIGAR_LOG_IS_DEBUG(sigar)) { + sigar_log_printf(sigar, SIGAR_LOG_DEBUG, + "[route_list] ipRouteEntrySize=%d (from %s)", + size, size_from); + } + for (entry = (mib2_ipRouteEntry_t *)data, end = data + len; (char *)entry < end; entry = (mib2_ipRouteEntry_t *)((char *)data+nread), nread+=size)