Ethereal-dev: [Ethereal-dev] Patch: Simplified interface specification for tethereal on Win32

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: "Graham Bloice" <graham.bloice@xxxxxxxxxxxxx>
Date: Fri, 5 Sep 2003 14:33:50 +0100
The attached patch modifies tethereal on win32 so that the -D option prints
a number before each interface, and the -i option accepts the same number in
lieu of the long "/Device/Packet_..." string.  Docs also updated.

Regards,

Graham Bloice
Index: ethereal/tethereal.c
===================================================================
RCS file: /cvsroot/ethereal/tethereal.c,v
retrieving revision 1.192
diff -u -b -r1.192 tethereal.c
--- ethereal/tethereal.c	3 Sep 2003 10:49:02 -0000	1.192
+++ ethereal/tethereal.c	5 Sep 2003 12:51:05 -0000
@@ -929,9 +929,16 @@
             }
             exit(2);
         }
+#ifdef _WIN32
+        i = 1;  /* Interface id number */
+#endif
         for (if_entry = g_list_first(if_list); if_entry != NULL;
 		if_entry = g_list_next(if_entry))
+#ifdef _WIN32
+          printf("%d. %s\n", i++, (char *)if_entry->data);
+#else
           printf("%s\n", (char *)if_entry->data);
+#endif
         free_interface_list(if_list);
         exit(0);
 #else
@@ -964,7 +971,20 @@
         break;
       case 'i':        /* Use interface xxx */
 #ifdef HAVE_LIBPCAP
+#ifdef _WIN32
+        i = atoi(optarg);
+        if_list = get_interface_list(&err, err_str);
+        if (i > 0 && if_list) {
+          if_text = (char *)g_list_nth_data(if_list, i - 1);
+          if_text = strchr(if_text, '\\');
+          cfile.iface = g_strdup(if_text);
+        }
+        else
+          cfile.iface = g_strdup(optarg);
+        free_interface_list(if_list);
+#else
         cfile.iface = g_strdup(optarg);
+#endif
 #else
         capture_option_specified = TRUE;
         arg_error = TRUE;
Index: ethereal/doc/tethereal.pod.template
===================================================================
RCS file: /cvsroot/ethereal/doc/tethereal.pod.template,v
retrieving revision 1.98
diff -u -b -r1.98 tethereal.pod.template
--- ethereal/doc/tethereal.pod.template	4 Sep 2003 23:37:44 -0000	1.98
+++ ethereal/doc/tethereal.pod.template	5 Sep 2003 13:19:28 -0000
@@ -206,7 +206,9 @@
 that device to do a live capture; if, on your system, a program doing a
 network capture must be run from an account with special privileges (for
 example, as root), then, if B<Tethereal> is run with the B<-D> flag and
-is not run from such an account, it will not list any interfaces.
+is not run from such an account, it will not list any interfaces.  On
+Windows, the interfaces are given a number which can be used to specify
+the interface to capture on, rather than the long "\Device\Packet_..." string.
 
 =item -f
 
@@ -226,9 +228,11 @@
 capture. 
 
 Network interface names should match one of the names listed in
-"B<tethereal -D>" (described above).  If you're using Unix, "B<netstat
--i>" or "B<ifconfig -a>" might also work to list interface names,
-although not all versions of Unix support the B<-a> flag to B<ifconfig>.
+"B<tethereal -D>" (described above), or on Windows the interface can also
+be specified by it's number as reported by "B<tethereal -D>".
+If you're using Unix, "B<netstat -i>" or "B<ifconfig -a>" might also work
+to list interface names, although not all versions of Unix support the
+B<-a> flag to B<ifconfig>.
 If no interface is specified, B<Tethereal> searches the list of
 interfaces, choosing the first non-loopback interface if there are any
 non-loopback interfaces, and choosing the first loopback interface if