for (ifa = ifp; ifa; ifa=ifa->ifa_next){
+ printlog(LOG_DEBUG, "get_local_ip: checking new addr.\n");
if (ifa->ifa_addr->sa_family == AF_INET){
salen = sizeof(struct sockaddr_in);
} else if( ifa->ifa_addr->sa_family == AF_INET6){
/* is it MSB first? */
/* We don't want to choose the loopback. */
- if (addrbyte == 127)
+ if (addrbyte == 127) {
+ printlog(LOG_DEBUG, "get_local_ip: ignoring the loopback.\n");
continue;
+ }
+
+ printlog(LOG_DEBUG, "get_local_ip: found address starting with %hhu\n", addrbyte);
/* If there's a non-local address, use that. */
if ((addrbyte != 192) && (addrbyte != 172) && (addrbyte != 10)){
if (localip != NULL) {
free(localip);
}
+ printlog(LOG_DEBUG, "get_local_ip: returning routable address %s\n", ip);
return(ip); /* for now return the IP address */
} else {
if (localip == NULL) {
freeifaddrs(ifp);
free(ip);
- if (localip != NULL)
+ if (localip != NULL) {
+ printlog(LOG_DEBUG, "get_local_ip: returning local address %s\n", localip);
return localip;
+ }
else
return(NULL);
}