set net_info.default_gateway

This commit is contained in:
Doug MacEachern 2005-07-14 01:01:32 +00:00
parent cc4f93cf8f
commit 962c8cfd1b
1 changed files with 26 additions and 0 deletions

View File

@ -836,6 +836,30 @@ int sigar_who_list_get(sigar_t *sigar,
return SIGAR_OK; return SIGAR_OK;
} }
static int sigar_get_default_gateway(sigar_t *sigar,
char *gateway)
{
int status, i;
sigar_net_route_list_t routelist;
status = sigar_net_route_list_get(sigar, &routelist);
if (status != SIGAR_OK) {
return status;
}
for (i=0; i<routelist.number; i++) {
if (routelist.data[i].flags & SIGAR_RTF_GATEWAY) {
sigar_inet_ntoa(sigar,
routelist.data[i].gateway, gateway);
break;
}
}
sigar_net_route_list_destroy(sigar, &routelist);
return SIGAR_OK;
}
int sigar_net_info_get(sigar_t *sigar, int sigar_net_info_get(sigar_t *sigar,
sigar_net_info_t *netinfo) sigar_net_info_t *netinfo)
{ {
@ -891,6 +915,8 @@ int sigar_net_info_get(sigar_t *sigar,
netinfo->domain_name[0] = '\0'; netinfo->domain_name[0] = '\0';
} }
sigar_get_default_gateway(sigar, netinfo->default_gateway);
return SIGAR_OK; return SIGAR_OK;
} }