From eac18a6b4e6b336805adced6d2289e3769eda77d Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Sun, 17 Jan 2010 22:24:50 -0800 Subject: [PATCH] (SIGAR-181) fill-in sigar_net_route_t.ifname on HPUX --- src/os/hpux/hpux_sigar.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/os/hpux/hpux_sigar.c b/src/os/hpux/hpux_sigar.c index f72a9463..ecf3678e 100644 --- a/src/os/hpux/hpux_sigar.c +++ b/src/os/hpux/hpux_sigar.c @@ -768,6 +768,32 @@ static int sigar_get_physical_stat(sigar_t *sigar, int *count) } } +#define SIGAR_IF_NAMESIZE 16 +/* hpux if_indextoname() does not work as advertised in 11.11 */ +static int sigar_if_indextoname(sigar_t *sigar, + char *name, + int index) +{ + int i, status, count; + nmapi_phystat *stat; + + if ((status = sigar_get_physical_stat(sigar, &count) != SIGAR_OK)) { + return status; + } + + for (i=0, stat = (nmapi_phystat *)sigar->ifconf_buf; + iif_entry.ifIndex == index) { + strncpy(name, stat->nm_device, SIGAR_IF_NAMESIZE); + return SIGAR_OK; + } + } + + return ENXIO; +} + int sigar_net_route_list_get(sigar_t *sigar, sigar_net_route_list_t *routelist) { @@ -819,6 +845,8 @@ int sigar_net_route_list_get(sigar_t *sigar, sigar_net_address_set(route->gateway, ent->NextHop); + sigar_if_indextoname(sigar, route->ifname, ent->IfIndex); + route->flags = SIGAR_RTF_UP; if ((ent->Dest == 0) && (ent->Mask == 0))