[Simh] sim_ether and tun devices

Antal Ritter Antal.Ritter at hu.inter.net
Thu Oct 6 04:46:57 EDT 2005


Hi,

I hit the following problem: in 3.5 when I try to attach a tun device to
the xq device it fails with file open error. Looking at the code it turned
out that in sim_ether.c eth_open() tries to find a description for the
device name if it could not find an ethX device by name, so it fails if
the given device was not of the form ethX and was not a description
either. My tun1 fell  into his category...
Would it be possible to change this behaviour in the next release?
I'd suggest something like the patch at the end of my message.

Thanks for this great program!

                         Antal Ritter

--- sim_ether.c.orig    2005-10-05 16:22:07.000000000 +0200
+++ sim_ether.c 2005-10-06 10:41:59.000000000 +0200
@@ -425,6 +425,26 @@
   return 0;
 }
 
+char *eth_getname_byname( char * name, char *temp) {
+       ETH_LIST        list[ ETH_MAX_DEVICE];
+       int             count =  eth_devices(ETH_MAX_DEVICE, list);
+       register int    i, n, found;
+
+       n = strlen( name);
+       found = 0;
+       for( i=0; i<count && ! found; i++) {
+           if( strncasecmp( name, list[ i].name, n) == 0 ) {
+               found = 1;
+               strcpy( temp, list[ i].name); /* Only case might be 
different */
+           }
+       }
+       if( found) {
+           return name;
+       } else {
+           return 0;
+       }
+}
+
 void eth_zero(ETH_DEV* dev)
 {
   /* set all members to NULL OR 0 */
@@ -655,8 +675,12 @@
   } else {
     /* are they trying to use device description? */
     savname = eth_getname_bydesc(name, temp);
-    if (savname == 0) /* didn't translate */
-      return SCPE_OPENERR;
+    if (savname == 0) /* didn't translate */ {
+       /* probably it is not ethX and has no description? */
+       savname = eth_getname_byname( name, temp);
+       if (savname == 0) /* didn't translate */
+           return SCPE_OPENERR;
+    }
   }
 
   /* attempt to connect device */



More information about the Simh mailing list