diff --git a/bindings/java/src/jni/generate.pl b/bindings/java/src/jni/generate.pl index 9de9d15b..729b7662 100644 --- a/bindings/java/src/jni/generate.pl +++ b/bindings/java/src/jni/generate.pl @@ -597,12 +597,12 @@ my %classes = ( ], NetRoute => [ { - name => 'destination', type => 'NetAddr', + name => 'destination', type => 'NetAddress', desc => '', plat => 'HLW' }, { - name => 'gateway', type => 'NetAddr', + name => 'gateway', type => 'NetAddress', desc => '', plat => 'HLW' }, @@ -627,7 +627,7 @@ my %classes = ( plat => 'L' }, { - name => 'mask', type => 'NetAddr', + name => 'mask', type => 'NetAddress', desc => '', plat => 'HL' }, diff --git a/include/sigar.h b/include/sigar.h index edd838ec..25cc2975 100644 --- a/include/sigar.h +++ b/include/sigar.h @@ -431,14 +431,14 @@ sigar_net_info_get(sigar_t *sigar, #define SIGAR_RTF_HOST 0x4 typedef struct { + sigar_net_address_t destination; + sigar_net_address_t gateway; + sigar_net_address_t mask; sigar_uint64_t - destination, - gateway, flags, refcnt, use, metric, - mask, mtu, window, irtt; diff --git a/src/os/linux/linux_sigar.c b/src/os/linux/linux_sigar.c index ae92ccd2..71f7715d 100644 --- a/src/os/linux/linux_sigar.c +++ b/src/os/linux/linux_sigar.c @@ -1613,9 +1613,10 @@ int sigar_net_route_list_get(sigar_t *sigar, } route->flags = flags; - route->destination = hex2int(net_addr, HEX_ENT_LEN); - route->gateway = hex2int(gate_addr, HEX_ENT_LEN); - route->mask = hex2int(mask_addr, HEX_ENT_LEN); + + sigar_net_address_set(route->destination, hex2int(net_addr, HEX_ENT_LEN)); + sigar_net_address_set(route->gateway, hex2int(gate_addr, HEX_ENT_LEN)); + sigar_net_address_set(route->mask, hex2int(mask_addr, HEX_ENT_LEN)); } fclose(fp); diff --git a/src/os/solaris/solaris_sigar.c b/src/os/solaris/solaris_sigar.c index bcf09e06..1babca5a 100644 --- a/src/os/solaris/solaris_sigar.c +++ b/src/os/solaris/solaris_sigar.c @@ -1633,9 +1633,15 @@ int sigar_net_route_list_get(sigar_t *sigar, SIGAR_NET_ROUTE_LIST_GROW(routelist); route = &routelist->data[routelist->number++]; - route->destination = entry->ipRouteDest; - route->gateway = entry->ipRouteNextHop; - route->mask = entry->ipRouteMask; + sigar_net_address_set(route->destination, + entry->ipRouteDest); + + sigar_net_address_set(route->gateway, + entry->ipRouteNextHop); + + sigar_net_address_set(route->mask, + entry->ipRouteMask); + route->refcnt = entry->ipRouteInfo.re_ref; route->irtt = entry->ipRouteInfo.re_rtt; route->metric = entry->ipRouteMetric1; @@ -1643,8 +1649,8 @@ int sigar_net_route_list_get(sigar_t *sigar, SIGAR_SSTRCPY(route->ifname, entry->ipRouteIfIndex.o_bytes); route->flags = RTF_UP; - if ((route->destination == 0) && - (route->mask == 0)) + if ((route->destination.addr.in == 0) && + (route->mask.addr.in == 0)) { route->flags |= RTF_GATEWAY; } diff --git a/src/sigar.c b/src/sigar.c index ecc67f69..d287e216 100644 --- a/src/sigar.c +++ b/src/sigar.c @@ -1045,10 +1045,11 @@ static int sigar_get_default_gateway(sigar_t *sigar, for (i=0; i