LRN: Fix automake deps to allow -j* builds again
[oweals/gnunet.git] / src / util / os_network.c
index c78dc71c56c7cb37e4b34fbe7c69446657829b05..ccf326c05e8a64c962ef7783467ef20c8834a984 100644 (file)
  * @brief Enumerate all network interfaces
  *
  * @param proc the callback function
- * @param cls closure for proc
+ * @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;
@@ -64,7 +64,6 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc,
         {
           char szEntry[1001];
           DWORD dwIP = 0;
-          int iItm;
           PIP_ADAPTER_INFO pAdapterInfo;
           PIP_ADAPTER_INFO pAdapter = NULL;
           DWORD dwRetVal = 0;
@@ -86,6 +85,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 =
@@ -147,12 +147,18 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc,
               if (pszIfName)
                 free (pszIfName);
 
+              sa.sin_family = AF_INET;
+#if HAVE_SOCKADDR_IN_SIN_LEN
+             sa.sin_len = (u_char) sizeof (struct sockaddr_in);
+#endif
+              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! */ ,
-                        0))
+                        pTable->table[dwIfIdx].dwIndex == dwExternalNIC,
+                        (const struct sockaddr *) &sa,
+                        sizeof (sa)))
                 break;
             }
         }
@@ -160,7 +166,7 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc,
       GlobalFree (pTable);
     }
 
-  return GNUNET_YES;
+  return;
 
 #elif HAVE_GETIFADDRS && HAVE_FREEIFADDRS
 
@@ -182,7 +188,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),
@@ -253,9 +259,12 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc,
             {
               memset (&a4, 0, sizeof (a4));
               a4.sin_family = AF_INET;
+#if HAVE_SOCKADDR_IN_SIN_LEN
+             a4.sin_len = (u_char) sizeof (struct sockaddr_in);
+#endif
               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)))
@@ -267,10 +276,12 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc,
             {
               memset (&a6, 0, sizeof (a6));
               a6.sin6_family = AF_INET6;
+#if HAVE_SOCKADDR_IN_SIN_LEN
+             a6.sin6_len = (u_char) sizeof (struct sockaddr_in6);
+#endif
               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)))