#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <sys/ioctl.h>
-#include <ifaddrs.h>
#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__Darwin__)
#include <fcntl.h>
#if defined(SOLARIS)
#include <sys/sockio.h>
+#include <net/if.h>
+#else
+#include <ifaddrs.h>
#endif
/* netinet/ip.h may not define the following (See RFCs 791 and 1349) */
int rtnerr;
const struct sockaddr_in *sin;
#endif /* BSD_OR_LINUX */
- struct in_addr best_addr = { 0, };
+ struct in_addr best_addr;
int best_score = -100;
+ memset(&best_addr, 0, sizeof(best_addr));
#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__linux__) || defined(__Darwin__)
rtnerr = getifaddrs(&ifaphead);
for (ifr = (struct lifreq *)buf, x = 0; x < ifn.lifn_count; ifr++, x++) {
sa = (struct sockaddr_in *)&(ifr->lifr_addr);
- score_address(sin, &best_addr, &best_score);
+ score_address(sa, &best_addr, &best_score);
res = 0;
if (best_score == 0)