fix
[oweals/gnunet.git] / src / util / os_network.c
index 4268772df5fd605324f91950419639c2aa112423..3b2254d58ce858614e4aa15b9233c086c207e7b0 100644 (file)
 
 /**
  * @brief Enumerate all network interfaces
- * @param callback the callback function
+ *
+ * @param proc the callback function
+ * @param proc_cls closure for proc
  */
 void
 GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc,
-                                   void *cls)
+                                   void *proc_cls)
 {
 #ifdef MINGW
   PMIB_IFTABLE pTable;
@@ -84,6 +86,7 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc,
               BYTE bPhysAddr[MAXLEN_PHYSADDR];
               char *pszIfName = NULL;
               char dst[INET_ADDRSTRLEN];
+              struct sockaddr_in sa;
 
               /* Get friendly interface name */
               pAdapterInfo =
@@ -145,11 +148,14 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc,
               if (pszIfName)
                 free (pszIfName);
 
+              sa.sin_family = AF_INET;
+              sa.sin_addr.S_un.S_addr = dwIP;
+
               if (GNUNET_OK !=
-                  proc (cls,
+                  proc (proc_cls,
                         szEntry,
                         pAddrTable->table[dwIfIdx].dwIndex == dwExternalNIC,
-                        NULL /* FIXME: pass actual IP address! */ ,
+                        &sa,
                         0))
                 break;
             }
@@ -163,13 +169,11 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc,
 #elif HAVE_GETIFADDRS && HAVE_FREEIFADDRS
 
   struct ifaddrs *ifa_first;
+  struct ifaddrs *ifa_ptr;
   socklen_t alen;
 
   if (getifaddrs (&ifa_first) == 0)
     {
-      struct ifaddrs *ifa_ptr;
-
-      ifa_ptr = ifa_first;
       for (ifa_ptr = ifa_first; ifa_ptr != NULL; ifa_ptr = ifa_ptr->ifa_next)
         {
           if (ifa_ptr->ifa_name != NULL &&
@@ -182,7 +186,7 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc,
                 alen = sizeof (struct sockaddr_in);
               else
                 alen = sizeof (struct sockaddr_in6);
-              if (GNUNET_OK != proc (cls,
+              if (GNUNET_OK != proc (proc_cls,
                                      ifa_ptr->ifa_name,
                                      0 == strcmp (ifa_ptr->ifa_name,
                                                   GNUNET_DEFAULT_INTERFACE),
@@ -255,7 +259,7 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc,
               a4.sin_family = AF_INET;
               a4.sin_addr = v4;
               if (GNUNET_OK !=
-                  proc (cls,
+                  proc (proc_cls,
                         ifc,
                         0 == strcmp (ifc, GNUNET_DEFAULT_INTERFACE),
                         (const struct sockaddr *) &a4, sizeof (a4)))
@@ -270,7 +274,7 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc,
               a6.sin6_addr = v6;
               fprintf (stderr, "procing %s\n", addrstr);
               if (GNUNET_OK !=
-                  proc (cls,
+                  proc (proc_cls,
                         ifc,
                         0 == strcmp (ifc, GNUNET_DEFAULT_INTERFACE),
                         (const struct sockaddr *) &a6, sizeof (a6)))