]> git.meshlink.io Git - meshlink/blobdiff - src/discovery.c
Debugging for getifaddrs().
[meshlink] / src / discovery.c
index 18919745c2e01d783bf452e5f638c56cf6779e0a..8fc6895e671c8ec32a39d825e0bd25e6de8457c5 100644 (file)
@@ -434,6 +434,7 @@ static void addr_del(meshlink_handle_t *mesh, const discovery_address_t *addr) {
 
 void scan_ifaddrs(meshlink_handle_t *mesh) {
 #ifdef HAVE_GETIFADDRS
+       logger(mesh, MESHLINK_WARNING, "Calling getifaddrs()");
        struct ifaddrs *ifa = NULL;
 
        if(getifaddrs(&ifa) == -1) {
@@ -525,6 +526,13 @@ void scan_ifaddrs(meshlink_handle_t *mesh) {
                        addr.address.sa.sa_family = AF_UNKNOWN;
                }
 
+               if(addr.address.sa.sa_family != AF_UNKNOWN) {
+                       char *host = NULL;
+                       sockaddr2str(sa, &host, NULL);
+                       logger(mesh, MESHLINK_WARNING, "iface %d (%s) address %s", index, ifap->ifa_name, host);
+                       free(host);
+               }
+
                if(addr.address.sa.sa_family != AF_UNKNOWN) {
                        addr_add(mesh, &addr);
                }
@@ -532,7 +540,7 @@ void scan_ifaddrs(meshlink_handle_t *mesh) {
 
        freeifaddrs(ifa);
 #else
-       (void)mesh;
+       logger(mesh, MESHLINK_ERROR, "getifaddrs() not supported");
 #endif
 }