Blob Blame History Raw
.\" $Id: 4432 2006-05-29 16:21:11Z strauss $
.TH smi_config 3  "August 22, 2001" "IBR" "SMI Management Information Library"
\- SMI library
configuration routines
.B #include <smi.h>
.BI "int smiInit(const char *" tag );
.B "int smiExit();"
.BI "void smiSetErrorLevel(int " level );
.BI "int smiGetFlags();"
.BI "void smiSetFlags(int " userflags );
.BI "char *smiLoadModule(char *" module );
.BI "int smiIsLoaded(char *" module );
.BI "char *smiGetPath();"
.BI "int smiSetPath(char *" path );
.BI "int smiSetSeverity(char *" pattern ", int " severity );
.BI "int smiReadConfig(char *" filename ", const char *" tag );
.BI "void smiSetErrorHandler(SmiErrorHandler *" smiErrorHandler );

typedef void (SmiErrorHandler) (char *path, int line,
				int severity, char *msg, char *tag);

These functions provide some initialization and adjustment operations
for the SMI library.
The \fBsmiInit()\fP function should be the first SMI function called
in an application. It initializes its internal structures. If \fItag\fP 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 \fBtag\fP argument are executed. 
(see also CONFIGURATION FILES below).
\fBsmiInit()\fP returns zero on success, or otherwise a negative value.
The \fBsmiInit()\fP function can also be used to support multiple sets
of MIB data. In this case, the \fBtag\fP argument may be prepended by
a colon and a name to differentiate the data sets. Any library
function call subsequent to an \fBsmiInit("tag:dataset")\fP call is
using the specified data set.
The \fBsmiExit()\fP function should be called when the application
no longer needs any SMI information to release any allocated SMI
The \fBsmiSetErrorLevel()\fP function sets the pedantic level (0-9) of
the SMI parsers of the SMI library, currently SMIv1/v2 and SMIng.
The higher the level, the louder it complains. Values up to 3
should be regarded as errors, higher level could be interpreted as
warnings.  But note that this classification is some kind of personal
taste.  The default level is 0, since usually only MIB checkers want
to tune a higher level.
The \fBsmiGetFlags()\fP and \fBsmiSetFlags()\fP functions allow to
fetch, modify, and set some \fIuserflags\fP that control the SMI
library's behaviour.  If \fBSMI_FLAG_ERRORS\fP is not set, no error messages
are printed at all to keep the SMI library totally quiet, which might
be mandatory for some applications. If \fBSMI_FLAG_STATS\fP is set, the
library prints some module statistics. If \fBSMI_FLAG_RECURSIVE\fP is set,
the library also complains about errors in modules that are read due
to import statements. If \fBSMI_FLAG_NODESCR\fP is set, no description
and references strings are stored in memory. This may save a huge amount
of memory in case of applications that do not need this information.
The \fBsmiSetSeverity()\fP function allows to set the severity of
all error that have name prefixed by \fBpattern\fP to the value \fBseverity\fP.
The \fBsmiLoadModule()\fP function specifies an additional MIB \fImodule\fP
that the application claims to know or an additional file path to read.
Only after a
module is made known through this function, iterating retrieval
functions and retrieval functions without fully qualified identifiers
will return results from this module. \fBsmiLoadModule()\fP returns the
name of the loaded module, of NULL if it could not be loaded.
The \fBsmiIsLoaded()\fP function returns a positive value if the
module named \fImodule\fP is already loaded, or zero otherwise.
The \fBsmiGetPath()\fP and \fBsmiSetPath()\fP functions allow to
fetch, modify, and set the path that is used to search MIB modules.
\fBsmiGetPath()\fP returns a copy of the current search path in the
form "DIR1:DIR2:...", or NULL if no path is set.
The application should free this string if it is
no longer needed. \fBsmiSetPath()\fP sets the search path to
The \fBsmiReadConfig()\fP function reads the configuration file \fIfilename\fP.
All global statements in the configuration file and those statements with
a tag (a ``tag: '' prefix) that matches the \fBtag\fP argument, if present,
are executed.
The \fBsmiSetErrorHandler()\fP function allows to set a callback function
that is called by the MIB parsers deviating from the builtin default
error handler, that prints error messages to stderr. The error handler
has to comply with the \fBSmiErrorHandler\fP function type. The \fBpath\fP,
\fBline\fP, \fBseverity\fP, \fBmsg\fP, and \fPtag\fP arguements carry the
module's pathname, the line number within the module, the error severity
level, a textual error message, and a short error name of the error being
The SMI library may retrieve MIB modules from different kinds of
resources. Currently, SMIv1/v2 and SMIng module files are supported.
If in an \fBsmiLoadModule()\fP function call a module is specified by
a path name (identified by containing at least one dot or slash character),
is assumed to be the exact file to read. Otherwise, if a module is identified
by its plain module name, the correspondant file (either SMIv1/2 or
SMIng) is searched along a path. This path is initialized with /usr/local/share/mibs/ietf:/usr/local/share/mibs/iana:/usr/local/share/mibs/irtf:/usr/local/share/mibs/site:/usr/local/share/mibs/tubs:/usr/local/share/pibs/ietf:/usr/local/share/pibs/site:/usr/local/share/pibs/tubs.
Afterwards the optional global and user configuration files are parsed for
`path' commands, and finally the optional \fBSMIPATH\fP environment variable
is evaluated. The `path' command argument and the environment variable
either start with a path separator character (`:' on UNIX-like systems, `;'
on MS-Windows systems) to append
to the path, or end with a path separator character to prepend to the path,
or otherwise completely replace the path.
The path can also be controlled by the \fBsmiGetPath()\fP 
and \fBsmiSetPath()\fP functions (see above).
When files are searched by a given module name, they might have no
extension or one of the extensions `.my', `.smiv2', `.sming', `.mib',
or `.txt'. However, the
MIB module language is identified by the file's content, not by its
file name extension.
SMI library configuration files read at initialization and on demand
by \fBsmiReadConfig()\fP have a simple line oriented syntax. Empty lines
and those starting with `#' are ignored. Other lines start with an optional
tag (prepended by a colon),
followed by a command and options dependent on the command. Tags
are used to limit the scope of a command to those applications that are
using this tag. 
The \fBload\fP command is used to preload a given MIB module. If multiple
modules shall be preloaded, multiple \fBload\fP commands must be used.
The \fBpath\fP command allows to prepend or append components to the
MIB module search path or to modify it completely (see 
The \fBcache\fP command allows to add an additional directory for
MIB module lookup as a last resort. The first argument specifies the
directory and the rest of the line starting from the second argument
specifies the caching method, which is invoked with the MIB module
name appended if the module is found neither in one of the regular directories
nor in the cache directory beforehand.
The \fBlevel\fP command sets the error level.
The \fBhide\fP command allows to tune the list of errors that are reported.
It raises all errors with names prefixed by the given pattern to severity
level 9. [Currently, there is no way to list the error names. RTFS: error.c.]
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
${prefix}/etc/smi.conf    global configuration file
$HOME/.smirc               user configuration file
${prefix}/include/smi.h   SMI library header file
/usr/local/share/mibs/     SMI module repository directory
.BR libsmi "(3), "
.BR smi.h
(C) 1999-2001 Frank Strauss, TU Braunschweig, Germany <>