harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r805331 - /harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/netif.c
Date Tue, 18 Aug 2009 09:31:45 GMT
Author: hindessm
Date: Tue Aug 18 09:31:44 2009
New Revision: 805331

URL: http://svn.apache.org/viewvc?rev=805331&view=rev
Log:
Applying patch from "[#HARMONY-6309] [classlib][luni] glibc from
java.net.NetworkInterface.getNetworkInterfacesImpl()".

Modified:
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/netif.c

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/netif.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/netif.c?rev=805331&r1=805330&r2=805331&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/netif.c
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/netif.c
Tue Aug 18 09:31:44 2009
@@ -1024,52 +1024,59 @@
 #endif
 /* now get the addresses */
               currentIPAddressIndex = 0;
-              lastName = ifc.ifc_req[counter].ifr_name;
 
-              for (;;)
+              /* go through addresses again to find ones with similar names */
+              for (counter2 = counter; counter2 < totalInterfaces; counter2++)
                 {
-                  if (ifc.ifc_req[counter].ifr_addr.sa_family == AF_INET)
+            	  if (strncmp (ifc.ifc_req[counter].ifr_name,
+            	  			   ifc.ifc_req[counter2].ifr_name, IFNAMSIZ) == 0)
                     {
-                      interfaces[currentAdapterIndex].
-                        addresses[currentIPAddressIndex].addr.inAddr.s_addr =
-                        ((struct sockaddr_in *) (&ifc.ifc_req[counter].
+                      if (ifc.ifc_req[counter2].ifr_addr.sa_family == AF_INET)
+                        {
+                          interfaces[currentAdapterIndex].
+                            addresses[currentIPAddressIndex].addr.inAddr.s_addr =
+                            ((struct sockaddr_in *) (&ifc.ifc_req[counter2].
                                                  ifr_addr))->sin_addr.s_addr;
-                      interfaces[currentAdapterIndex].
-                        addresses[currentIPAddressIndex].length =
-                        sizeof (struct in_addr);
-                      interfaces[currentAdapterIndex].
-                        addresses[currentIPAddressIndex].scope = 0;
-                      currentIPAddressIndex++;
-                    }
+                          interfaces[currentAdapterIndex].
+                            addresses[currentIPAddressIndex].length =
+                            sizeof (struct in_addr);
+                          interfaces[currentAdapterIndex].
+                            addresses[currentIPAddressIndex].scope = 0;
+                          currentIPAddressIndex++;
+                        }
 #if defined(IPv6_FUNCTION_SUPPORT)
-                  else if (ifc.ifc_req[counter].ifr_addr.sa_family ==
+                      else if (ifc.ifc_req[counter2].ifr_addr.sa_family ==
                            AF_INET6)
-                    {
-                      memcpy (interfaces[currentAdapterIndex].
+                        {
+                          memcpy (interfaces[currentAdapterIndex].
                               addresses[currentIPAddressIndex].addr.bytes,
                               &(((struct sockaddr_in6 *) (&ifc.
-                                                          ifc_req[counter].
+                                                          ifc_req[counter2].
                                                           ifr_addr))->
                                 sin6_addr), sizeof (struct in6_addr));
-                      interfaces[currentAdapterIndex].
-                        addresses[currentIPAddressIndex].length =
-                        sizeof (struct in6_addr);
-                      interfaces[currentAdapterIndex].
-                        addresses[currentIPAddressIndex].scope =
-                        ((struct sockaddr_in6 *) (&ifc.ifc_req[counter].
+                          interfaces[currentAdapterIndex].
+                            addresses[currentIPAddressIndex].length =
+                            sizeof (struct in6_addr);
+                          interfaces[currentAdapterIndex].
+                            addresses[currentIPAddressIndex].scope =
+                            ((struct sockaddr_in6 *) (&ifc.ifc_req[counter2].
                                                     ifr_addr))->
-                          sin6_scope_id;
-                      currentIPAddressIndex++;
-                    }
+                              sin6_scope_id;
+                          currentIPAddressIndex++;
+                        }
+#endif
+                    } /* end if aliased address */
+                } /* end for all interfaces */
 
-	      if ((ipv6 = fopen("/proc/net/if_inet6", "r"))) {
+              if ((ipv6 = fopen("/proc/net/if_inet6", "r"))) {
                 while(fscanf(ipv6, "%4x%4x%4x%4x%4x%4x%4x%4x %x %x %x %x %s\n", &oct6[0],
&oct6[1], &oct6[2], &oct6[3], &oct6[4], &oct6[5], &oct6[6], &oct6[7],
                              &index6, &other, &scope, &other, ifname6) !=
EOF) {
                   if(strncmp(ifc.ifc_req[counter].ifr_name, ifname6, IFNAMSIZ) == 0) {
                     sprintf(addr6, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x", oct6[0], oct6[1],
oct6[2], oct6[3], oct6[4], oct6[5], oct6[6], oct6[7]);
-                    inet_pton(AF_INET6, addr6, 
+#if defined(IPv6_FUNCTION_SUPPORT)
+                    inet_pton(AF_INET6, addr6,
                               (void *)(&interfaces[currentAdapterIndex].addresses[currentIPAddressIndex].addr.in6Addr));
-
+#endif
                     interfaces[currentAdapterIndex].
                       addresses[currentIPAddressIndex].length = sizeof (struct in6_addr);
                     interfaces[currentAdapterIndex].addresses[currentIPAddressIndex].scope
= scope;
@@ -1078,24 +1085,9 @@
                 }
                 fclose(ipv6);
               }
-
-#endif
-/* we mean to increment the outside counter here as we want to skip the next entry as it
is for the same interface
-					   as we are currently working on */
-                  if ((counter + 1 < totalInterfaces)
-                      &&
-                      (strncmp
-                       (ifc.ifc_req[counter + 1].ifr_name, lastName,
-                        IFNAMSIZ) == 0))
-                    {
-                      counter++;
-                    }
-                  else
-                    {
-                      break;
-                    }
-
-                }
+              
+	          /* update lastName variable and increment loop index */
+              lastName = ifc.ifc_req[counter].ifr_name;
               currentAdapterIndex++;
             }
         }



Mime
View raw message