This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[Patch] SIOCGIFCONF Win95


Hi,

On Win95, the implementation of SIOCGIFCONF seems to be wrong. For Win95a
it seems to work, but Win95b and Win95c will onyl return the loopback 
device. Searching through the code, I found the reason in winsup/cygwin/net.c 

in get_95_ifconf, the registry is searched for the key HKLM/Enum/MSTCP/*
which seems to represent the TCP/IP configurations. The current 
implementaion then searches for each entry the keys in Bindings, which 
represent bindings to services as Client for Windows Networks or File
sharing. One of these keys is taken as reference to HKLM/System/
CurrentControlSet/Services/Class/Net/* where the network adapter is store.

This seems to work on Win95a, but does often fail on Win95c. The binding to 
a service has IMO nothing to do with the binding to a NIC, so the connection
to the NIC is stored in another way. Since there is a 1-to-1 relation between 
network cards and TCP configuration, no extra binding needs to be stored. 
The name for the adapter in HKLM/CurrentControlSet/.../Net is the same as
the key in HKLM/Enum/Net/*. 

I modified the function in net.c and the correct number of interfaces is 
reported for win95a and win95c.

I attached the patch. A patch cygwin1.dll is available at 
<http://www.tu-chemnitz.de/~goal/xfree/cygwin1.fixed-netdev.dll.bz2>

bye
	ago 

Please keep me CCed or CC to cygwin-xfree
-- 
 Alexander.Gottwald@informatik.tu-chemnitz.de 
 http://www.gotti.org           ICQ: 126018723
 phone: +49 3725 349 80 80	mobile: +49 172 7854017
--- cygwin-1.3.3-2/winsup/cygwin/net.cc	Wed Sep 12 07:31:56 2001
+++ cygwin-new/winsup/cygwin/net.cc	Wed Sep 26 21:12:47 2001
@@ -1905,7 +1905,7 @@
        ++i)
     {
       HKEY ifkey, subkey;
-      char driver[256], classname[256], bindname[256], netname[256];
+      char driver[256], classname[256], netname[256];
       char adapter[256], ip[256], np[256];
 
       if (res != ERROR_SUCCESS
@@ -1981,57 +1981,34 @@
 
       RegCloseKey (subkey);
 
-      if (RegOpenKeyEx (ifkey, "Bindings",
-			 0, KEY_READ, &subkey) != ERROR_SUCCESS)
-	{
-	  RegCloseKey (ifkey);
-	  --ifr;
-	  continue;
-	}
-
-      for (int j = 0;
-	   (res = RegEnumValue (subkey, j, bindname,
-				(size = sizeof bindname, &size),
-				0, NULL, NULL, NULL)) != ERROR_NO_MORE_ITEMS;
-	   ++j)
-	if (!strncasecmp (bindname, "VREDIR\\", 7))
-	  break;
+      strcpy (netname, "System\\CurrentControlSet\\Services\\Class\\Net\\");
+      strcat (netname, ifname);
 
+      if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, netname,
+                  0, KEY_READ, &subkey) != ERROR_SUCCESS)
+      {
+          RegCloseKey (ifkey);
+          --ifr;
+          continue;
+      }
+
+      if (RegQueryValueEx (subkey, "AdapterName", 0,
+                  NULL, (unsigned char *) adapter,
+                  (size = sizeof adapter, &size)) == ERROR_SUCCESS
+              && strcasematch (adapter, "MS$PPP"))
+      {
+          ++*ppp;
+          strcpy (ifr->ifr_name, "ppp");
+          strcat (ifr->ifr_name, ppp);
+      }
+      else
+      {
+          ++*eth;
+          strcpy (ifr->ifr_name, "eth");
+          strcat (ifr->ifr_name, eth);
+      }
+      
       RegCloseKey (subkey);
-
-      if (res == ERROR_SUCCESS)
-	{
-	  strcpy (netname, "System\\CurrentControlSet\\Services\\Class\\Net\\");
-	  strcat (netname, bindname + 7);
-
-	  if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, netname,
-			    0, KEY_READ, &subkey) != ERROR_SUCCESS)
-	    {
-	      RegCloseKey (ifkey);
-	      --ifr;
-	      continue;
-	    }
-
-	  if (RegQueryValueEx (subkey, "AdapterName", 0,
-			       NULL, (unsigned char *) adapter,
-			       (size = sizeof adapter, &size)) == ERROR_SUCCESS
-	      && strcasematch (adapter, "MS$PPP"))
-	    {
-	      ++*ppp;
-	      strcpy (ifr->ifr_name, "ppp");
-	      strcat (ifr->ifr_name, ppp);
-	    }
-	  else
-	    {
-	      ++*eth;
-	      strcpy (ifr->ifr_name, "eth");
-	      strcat (ifr->ifr_name, eth);
-	    }
-
-	  RegCloseKey (subkey);
-
-	}
-
       RegCloseKey (ifkey);
 
       ++cnt;
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]