convert net_interface_config to use sigar_net_address_t

This commit is contained in:
Doug MacEachern 2006-07-04 17:44:13 +00:00
parent 4c0b9565f8
commit 972f3855dd
1 changed files with 11 additions and 6 deletions

View File

@ -1615,26 +1615,31 @@ int sigar_net_interface_config_get(sigar_t *sigar, const char *name,
((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr
if (!ioctl(sock, SIOCGIFADDR, &ifr)) { if (!ioctl(sock, SIOCGIFADDR, &ifr)) {
ifconfig->address = ifr_s_addr(ifr); sigar_net_address_set(ifconfig->address,
ifr_s_addr(ifr));
} }
if (!ioctl(sock, SIOCGIFNETMASK, &ifr)) { if (!ioctl(sock, SIOCGIFNETMASK, &ifr)) {
ifconfig->netmask = ifr_s_addr(ifr); sigar_net_address_set(ifconfig->netmask,
ifr_s_addr(ifr));
} }
if (ifconfig->flags & IFF_LOOPBACK) { if (ifconfig->flags & IFF_LOOPBACK) {
ifconfig->destination = ifconfig->address; sigar_net_address_set(ifconfig->destination,
ifconfig->broadcast = 0; ifconfig->address.addr.in);
sigar_net_address_set(ifconfig->broadcast, 0);
SIGAR_SSTRCPY(ifconfig->type, SIGAR_SSTRCPY(ifconfig->type,
SIGAR_NIC_LOOPBACK); SIGAR_NIC_LOOPBACK);
} }
else { else {
if (!ioctl(sock, SIOCGIFDSTADDR, &ifr)) { if (!ioctl(sock, SIOCGIFDSTADDR, &ifr)) {
ifconfig->destination = ifr_s_addr(ifr); sigar_net_address_set(ifconfig->destination,
ifr_s_addr(ifr));
} }
if (!ioctl(sock, SIOCGIFBRDADDR, &ifr)) { if (!ioctl(sock, SIOCGIFBRDADDR, &ifr)) {
ifconfig->broadcast = ifr_s_addr(ifr); sigar_net_address_set(ifconfig->broadcast,
ifr_s_addr(ifr));
} }
SIGAR_SSTRCPY(ifconfig->type, SIGAR_SSTRCPY(ifconfig->type,
SIGAR_NIC_ETHERNET); SIGAR_NIC_ETHERNET);