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

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

.fi
.SH DESCRIPTION
These functions provide some initialization and adjustment operations
for the SMI library.
.PP
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.
.PP
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.
.PP
The \fBsmiExit()\fP function should be called when the application
no longer needs any SMI information to release any allocated SMI
resources.
.PP
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.
.PP
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.
.PP
The \fBsmiSetSeverity()\fP function allows to set the severity of
all error that have name prefixed by \fBpattern\fP to the value \fBseverity\fP.
.PP
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.
.PP
The \fBsmiIsLoaded()\fP function returns a positive value if the
module named \fImodule\fP is already loaded, or zero otherwise.
.PP
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
\fIpath\fP.
.PP
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.
.PP
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
reported.
.SH "MODULE LOCATIONS"
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),
this
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 @smipath@.
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).
.PP
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.
.SH "CONFIGURATION FILES"
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. 
.PP
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.
.PP
The \fBpath\fP command allows to prepend or append components to the
MIB module search path or to modify it completely (see 
also MODULE LOCATIONS above).
.PP
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.
.PP
The \fBlevel\fP command sets the error level.
.PP
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.]
.PP
Example configuration:
.nf

  #
  # $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
.fi
.SH "FILES"
.nf
@sysconfdir@/smi.conf    global configuration file
$HOME/.smirc               user configuration file
@includedir@/smi.h   SMI library header file
@mibdir@/     SMI module repository directory
.fi
.SH "SEE ALSO"
.BR libsmi "(3), "
.BR smi.h
.SH "AUTHOR"
(C) 1999-2001 Frank Strauss, TU Braunschweig, Germany <strauss@ibr.cs.tu-bs.de>
.br