make sure primary ip is used for net_interface_config
This commit is contained in:
parent
64be681de6
commit
ef0752391c
|
@ -2264,23 +2264,19 @@ sigar_net_interface_config_get(sigar_t *sigar,
|
||||||
|
|
||||||
if (status == SIGAR_OK) {
|
if (status == SIGAR_OK) {
|
||||||
char *addr;
|
char *addr;
|
||||||
if (adapter->CurrentIpAddress) {
|
IP_ADDR_STRING *ip = &adapter->IpAddressList;
|
||||||
addr = adapter->CurrentIpAddress->IpAddress.String;
|
|
||||||
|
/* last address in the list is the primary */
|
||||||
|
while (ip->Next) {
|
||||||
|
ip = ip->Next;
|
||||||
|
}
|
||||||
|
addr = ip->IpAddress.String;
|
||||||
sigar_net_address_set(ifconfig->address,
|
sigar_net_address_set(ifconfig->address,
|
||||||
inet_addr(addr));
|
inet_addr(addr));
|
||||||
addr = adapter->CurrentIpAddress->IpMask.String;
|
addr = ip->IpMask.String;
|
||||||
sigar_net_address_set(ifconfig->netmask,
|
sigar_net_address_set(ifconfig->netmask,
|
||||||
inet_addr(addr));
|
inet_addr(addr));
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
addr = adapter->IpAddressList.IpAddress.String;
|
|
||||||
sigar_net_address_set(ifconfig->address,
|
|
||||||
inet_addr(addr));
|
|
||||||
addr = adapter->IpAddressList.IpMask.String;
|
|
||||||
sigar_net_address_set(ifconfig->netmask,
|
|
||||||
inet_addr(addr));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* hack for MS_LOOPBACK_ADAPTER */
|
/* hack for MS_LOOPBACK_ADAPTER */
|
||||||
if (strnEQ(name, NETIF_LA, sizeof(NETIF_LA)-1)) {
|
if (strnEQ(name, NETIF_LA, sizeof(NETIF_LA)-1)) {
|
||||||
|
|
Loading…
Reference in New Issue