[tcpdump] About smiInit() parameter

Guy Harris gharris at sonic.net
Mon Mar 30 13:55:26 EDT 2020



> On Mar 30, 2020, at 10:24 AM, Francois-Xavier Le Bail <devel.fx.lebail at orange.fr> wrote:
> 
> Hi Guy,
> 
> We have:
> $ git grep -n '"tcpdump"'
> netdissect.c:72:        smiInit("tcpdump");
> 
> netdissect.c is a part of libnetdissect.
> 
> Should we use
> smiInit("libnetdissect");
> or something else to separate the lib and the tool ?

The man page at

	https://www.ibr.cs.tu-bs.de/projects/libsmi/smi_config.html

says:

	int smiInit(const char *tag);

		...

	The smiInit() function should be the first SMI function called in an application.  It initializes its internal structures. If tag is not NULL, the global configuration file and (on UNIX systems) a user configuration file are read implicitly, if existent.  All global statements and those statements with  a tag (a ``tag: '' prefix) that matches the tag argument are executed.  (see also CONFIGURATION FILES below).  

I don't know if anybody's actually *using* that particular libsmi feature, but smiInit has been called with "tcpdump" as an argument since at least tcpdump 0.7.  For what it's worth, the configuration file example they give in the man page *does* have a "tcpdump:" statement in it:

	Example configuration:

	  #
	  # $HOME/.smirc
	  #

	 # add a private directory
	  path :/usr/home/strauss/lib/mibs

	 # don’t show any errors by default
	  level 0

	 # preload some basic modules
	  load SNMPv2-SMI
	  load SNMPv2-TC
	  load SNMPv2-CONF

	 # want to make smilint shout
	  smilint: level 8

	 # but please don’t claim about
	  # any names longer than 32 chars
	  smilint: hide namelength-32

	 tcpdump: load DISMAN-SCRIPT-MIB

	 smiquery: load IF-MIB
	  smiquery: load DISMAN-SCRIPT-MIB

so there might be some who have "tcpdump:" statements in libsmi configuration files.

So either

	1) we should consider leaving "tcpdump" there

or

	2) we should make the tag an argument to nd_init and pass it "tcpdump" from tcpdump

although the latter means that any new program using libnetdissect might dissect SNMP packets differently from tcpdump, whether that's a bug or a feature.


More information about the tcpdump-workers mailing list