convert net_route to use net_address_t

This commit is contained in:
Doug MacEachern 2006-07-04 19:22:05 +00:00
parent 972f3855dd
commit ee37d10b2c
5 changed files with 25 additions and 17 deletions

View File

@ -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'
},

View File

@ -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;

View File

@ -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);

View File

@ -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;
}

View File

@ -1045,10 +1045,11 @@ static int sigar_get_default_gateway(sigar_t *sigar,
for (i=0; i<routelist.number; i++) {
if ((routelist.data[i].flags & SIGAR_RTF_GATEWAY) &&
(routelist.data[i].destination == 0))
(routelist.data[i].destination.addr.in == 0))
{
sigar_inet_ntoa(sigar,
routelist.data[i].gateway, gateway);
sigar_net_address_to_string(sigar,
&routelist.data[i].gateway,
gateway);
break;
}
}