version 1.71, 2015/02/08 04:25:56 |
version 1.72, 2015/02/09 12:25:03 |
|
|
struct if_msghdr ifm; |
struct if_msghdr ifm; |
int mib[6] = { CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, 0 }; |
int mib[6] = { CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, 0 }; |
char name[IFNAMSIZ + 1]; /* + 1 for the '*' */ |
char name[IFNAMSIZ + 1]; /* + 1 for the '*' */ |
char *buf, *next, *lim, *cp; |
char *buf = NULL, *next, *lim, *cp; |
struct rt_msghdr *rtm; |
struct rt_msghdr *rtm; |
struct ifa_msghdr *ifam; |
struct ifa_msghdr *ifam; |
struct if_data *ifd; |
struct if_data *ifd; |
|
|
return; |
return; |
} |
} |
|
|
if (sysctl(mib, 6, NULL, &len, NULL, 0) == -1) |
len = get_sysctl(mib, 6, &buf); |
err(1, "sysctl"); |
|
if ((buf = malloc(len)) == NULL) |
|
err(1, NULL); |
|
if (sysctl(mib, 6, buf, &len, NULL, 0) == -1) |
|
err(1, "sysctl"); |
|
|
|
printf("%-7.7s %-5.5s %-11.11s %-17.17s ", |
printf("%-7.7s %-5.5s %-11.11s %-17.17s ", |
"Name", "Mtu", "Network", "Address"); |
"Name", "Mtu", "Network", "Address"); |
|
|
int takeit = 0; |
int takeit = 0; |
int foundone = 0; |
int foundone = 0; |
|
|
if (sysctl(mib, 6, NULL, &len, NULL, 0) == -1) |
len = get_sysctl(mib, 6, &buf); |
err(1, "sysctl"); |
|
if ((buf = malloc(len)) == NULL) |
|
err(1, NULL); |
|
if (sysctl(mib, 6, buf, &len, NULL, 0) == -1) |
|
err(1, "sysctl"); |
|
|
|
memset(&ip_cur, 0, sizeof(ip_cur)); |
memset(&ip_cur, 0, sizeof(ip_cur)); |
lim = buf + len; |
lim = buf + len; |