Ethereal-dev: Re: [ethereal-dev] packet-snmp.c and libsmi

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

From: Juergen Schoenwaelder <schoenw@xxxxxxxxxxxxxxx>
Date: Mon, 26 Jun 2000 18:32:53 +0200
>>>>> Juergen Schoenwaelder writes:

Juergen> I think it is the job of a proper configure script to figure
Juergen> out whether the libsmi version found is suitable or not.

To follow up on this, here is the latest and greatest configure code
I have written for testing for a suitable libsmi:

dnl Check if we can use the libsmi MIB parser library.
AC_CHECK_HEADERS(smi.h)
AC_CHECK_LIB(smi, smiInit)
AC_MSG_CHECKING([whether to enable libsmi])
        AC_TRY_RUN([ /* libsmi available check */
#include <smi.h>
main()
{
  int current, revision, age, n;
  const int required = 2;
  if (smiInit("")) 
    exit(1);
  if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
    exit(2);
  n = sscanf(smi_library_version, "%d:%d:%d", &current, &revision, &age);
  if (n != 3)
    exit(3);
  if (required < current - age || required > current)
    exit(4);
  exit(0);
}
],
[ AC_MSG_RESULT(yes)
  AC_DEFINE(HAVE_LIBSMI)
  libsmi=yes],
[ AC_MSG_RESULT(no)
  libsmi=no],
[ AC_MSG_RESULT(not when cross-compiling)
  libsmi=no]
)

I think this does a proper check on the ABI version number. In
addition, it verifies that the headers match the library version
(which hopefully helps to avoid nasty questions from folks who have
screwed up their header files).

Note that this test defines HAVE_LIBSMI in addition to HAVE_LIBSMI_H.

/js

-- 
Juergen Schoenwaelder      Technical University Braunschweig
<schoenw@xxxxxxxxxxxxxxx>  Dept. Operating Systems & Computer Networks
Phone: +49 531 391 3289    Bueltenweg 74/75, 38106 Braunschweig, Germany
Fax:   +49 531 391 5936    <URL:http://www.ibr.cs.tu-bs.de/~schoenw/>