ip utils: return proper structure on Linux
Change-Id: I316c2aefa8fb1042645d03e0bc316c11731bd6ef
diff --git a/src/ip_utils.cpp b/src/ip_utils.cpp
index 3bcf38c..ad03123 100644
--- a/src/ip_utils.cpp
+++ b/src/ip_utils.cpp
@@ -87,10 +87,6 @@
p = inet_ntop(AF_INET, &localAddr.sin_addr, tempstr, sizeof(tempstr));
if (p)
ret.address = p;
- else
- return {};
- } else {
- return {};
}
#elif (defined(BSD) && BSD >= 199306) || defined(__FreeBSD_kernel__)
struct ifaddrs* ifap;
@@ -124,7 +120,6 @@
}
}
freeifaddrs(ifap);
- return ret;
#else
struct ifconf ifConf;
struct ifreq ifReq;
@@ -170,18 +165,17 @@
}
ret.interface = pifReq->ifr_name;
p = inet_ntop(pifReq->ifr_addr.sa_family,
- (sockaddr_in*)&pifReq->ifr_addr,
+ &((sockaddr_in*)&pifReq->ifr_addr)->sin_addr,
tempstr,
sizeof(tempstr));
if (p)
ret.address = p;
-
}
j++; // Increment j if we found an address which is not loopback and is up.
}
close(localSock);
#endif
- return {};
+ return ret;
}
std::string