Ethereal-users: Re: [Ethereal-users] WinXP Problem

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

From: "Martin Regner" <martin.regner@xxxxxxxxx>
Date: Sun, 6 Jul 2003 09:50:36 +0200
Guy Harris wrote:

>On Wed, Jul 02, 2003 at 04:31:11PM +0200, martin.regner@xxxxxxxxx wrote:
>> Might be a NET-SNMP related problem 
>
>Recent versions of Ethereal *should* be setting the MIBDIRS environment
>variable to get the MIB files from the directory in which Ethereal is
>installed; is the problem that
>
> 1) that code (in "proto_register_snmp()" in packet-snmp.c) isn't
>    working;
>
> 2) it's working, but because MIBDIRS is already set it can't
>    override the settings;
>
> 3) it's working, but some *other* environment variable is set to
>    point to the bad MIB files, so it's not getting the right MIB
>    files?

When I look in the current code it seems that the MIBDIRS environment variable is only set by Ethereal if the
MIBDIRS variable isn't already set (on Windows at least).

#ifdef WIN32 /* Set MIBDIRS so that the SNMP library can find its mibs. */
     /* XXX - Should we set MIBS or MIBFILES as well? */
       mib_path = g_malloc (strlen(get_datafile_dir()) + strlen(MIB_PATH_APPEND) + 20);
       sprintf (mib_path, "MIBDIRS=%s\\%s", get_datafile_dir(), MIB_PATH_APPEND);
      /* Amazingly enough, Windows does not provide setenv(). */
      if (getenv("MIBDIRS") == NULL)  _putenv(mib_path); 
      g_free(mib_path);
#endif /* WIN32 */

If you have for example have the Enterasys NetSight Element Manager installed the MIBDIRS environment varaible may already be set and then Ethereal will use the MIBS in the Enterasys directory
http://www.ethereal.com/lists/ethereal-users/200304/msg00083.html

I think that it can be good to be able to configure Ethereal to use another directory than the directory where Ethereal installs MIBs - so I like the idea that Geral Combs suggested to add an own ETHEREAL_MIBDIRS environment variable.
If the ETHEREAL_MIBDIRS environment variable is defined then Ethereal could set the MIBDIRS environment variable to point to
the directories specified by ETHEREAL_MIBDIRS, and otherwise set it to the Ethereal installation directory with "snmp/mibs" added at
the end:
http://www.ethereal.com/lists/ethereal-users/200304/msg00123.html

Maybe something like the following code could be used (probably needs to be cleaned up a bit, checked and tested - which
I probably can do in a few days):

#ifdef WIN32 /* Set MIBDIRS so that the SNMP library can find its mibs. */
     /* XXX - Should we set MIBS or MIBFILES as well? */
             /* Amazingly enough, Windows does not provide setenv(). */
      if (getenv("ETHEREAL_MIBDIRS") == NULL) {
         mib_path = g_malloc (strlen(get_datafile_dir()) + strlen(MIB_PATH_APPEND) + 20);
         sprintf (mib_path, "MIBDIRS=%s\\%s", get_datafile_dir(), MIB_PATH_APPEND);
          _putenv(mib_path); 
      }
      else {
          mib_path = g_malloc (strlen(getenv("ETHEREAL_MIBDIRS")) + 20);
          sprintf (mib_path, "MIBDIRS=%s", getenv("ETHEREAL_MIBDIRS"));
           _putenv(mib_path); 
      }
      g_free(mib_path);
#endif /* WIN32 */