From 9c9326d253997e369dc4cfa44ae95909852a7da0 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Sat, 12 Mar 2005 05:44:04 +0000 Subject: [PATCH] implement net_route_list --- src/os/solaris/solaris_sigar.c | 42 +++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/os/solaris/solaris_sigar.c b/src/os/solaris/solaris_sigar.c index 9e774aa4..722adf5e 100644 --- a/src/os/solaris/solaris_sigar.c +++ b/src/os/solaris/solaris_sigar.c @@ -1462,7 +1462,47 @@ int sigar_net_route_list_get(sigar_t *sigar, sigar_net_route_list_t *routelist) { - return SIGAR_ENOTIMPL; + char *data; + int len, rc; + struct opthdr *op; + + sigar_net_route_list_create(routelist); + + while ((rc = get_mib2(&sigar->mib2, &op, &data, &len)) == GET_MIB2_OK) { + mib2_ipRouteEntry_t *entry; + char *end; + + if (!((op->level == MIB2_IP) && (op->name == MIB2_IP_21))) { + continue; + } + + for (entry = (mib2_ipRouteEntry_t *)data, end = data + len; + (char *)entry < end; entry++) + { + sigar_net_route_t *route; + + SIGAR_NET_ROUTE_LIST_GROW(routelist); + route = &routelist->data[routelist->number++]; + + route->destination = entry->ipRouteDest; + route->gateway = entry->ipRouteNextHop; + route->mask = entry->ipRouteMask; + route->refcnt = entry->ipRouteInfo.re_ref; + route->irtt = entry->ipRouteInfo.re_rtt; + route->metric = entry->ipRouteMetric1; + + SIGAR_SSTRCPY(route->ifname, entry->ipRouteIfIndex.o_bytes); + + route->flags = route->use = route->window = route->mtu = + SIGAR_FIELD_NOTIMPL; /*XXX*/ + } + } + + if (rc != GET_MIB2_EOD) { + /*XXX*/ + } + + return SIGAR_OK; } #define kHME(v) kSTAT_uint(v, hme)