smi_config(3)
π smi_config(3) β SMI Management Information Library π
okay so bestie, this is the smi_config(3) page from the SMI Management Information Library, and it's basically the setup-and-tune-up department for libsmi. Pull up a chair, we're doing configuration β¨
π NAME π
smiInit, smiExit, smiSetErrorLevel, smiGetFlags, smiSetFlags, smiLoadModule, smiGetPath, smiSetPath, smiReadConfig β these are the SMI library configuration routines.
β¨ SYNOPSIS β¨
#include <smi.h>
int smiInit(const char *tag);
int smiExit();
void smiSetErrorLevel(int level);
int smiGetFlags();
void smiSetFlags(int userflags);
char *smiLoadModule(char *module);
int smiIsLoaded(char *module);
char *smiGetPath();
int smiSetPath(char *path);
int smiSetSeverity(char *pattern, int severity);
int smiReadConfig(char *filename, const char *tag);
void smiSetErrorHandler(SmiErrorHandler *smiErrorHandler);
typedef void (SmiErrorHandler) (char *path, int line,
int severity, char *msg, char *tag);
π¦ DESCRIPTION π¦
These functions are the initialization and adjustment squad for the SMI library. Like, they get it ready and let you poke at its settings π
smiInit()β bestie, this should be the first SMI function your application calls. It initializes internal structures. Iftagis notNULL, 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 (atag:prefix) that matches thetagargument are executed β see also CONFIGURATION FILES below. IftagisNULL, no configuration files are read, leaving full control to the application.smiInit()returns zero on success, or otherwise a negative value.
It can also be used to support multiple different sets of loaded MIB modules. In this case, the tag argument consists of the tag followed by a colon and a name to differentiate the loaded MIB module data sets. Any library function call subsequent to an smiInit("tag:dataset") call is using the most recently selected data set.
smiExit()β call this when the application no longer needs any SMI information, so it can release any allocated SMI resources. Cleanup era π§ΉsmiSetErrorLevel()β 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 to3should 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 is0, since usually only MIB checkers want to tune a higher level.smiGetFlags()andsmiSetFlags()β allow you to fetch, modify, and set some userflags that control the SMI library's behaviour. The flag tea is:- If
SMI_FLAG_ERRORSis not set, no error messages are printed at all to keep the SMI library totally quiet, which might be mandatory for some applications. - If
SMI_FLAG_STATSis set, the library prints some module statistics. - If
SMI_FLAG_RECURSIVEis set, the library also complains about errors in modules that are read due to import statements. - If
SMI_FLAG_NODESCRis 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.
- If
smiSetSeverity()β allows you to set the severity of all errors that have a name prefixed bypatternto the valueseverity.smiLoadModule()β specifies an additional MIB module 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.smiLoadModule()returns the name of the loaded module, orNULLif it could not be loaded.smiIsLoaded()β returns a positive value if the module namedmoduleis already loaded, or zero otherwise.smiGetPath()andsmiSetPath()β allow you to fetch, modify, and set the path that is used to search MIB modules.smiGetPath()returns a copy of the current search path in the form"DIR1:DIR2:...", orNULLif no path is set. The application should free this string if it is no longer needed.smiSetPath()sets the search path topath.smiReadConfig()β reads the configuration filefilename. All global statements in the configuration file and those statements with a tag (atag:prefix) that matches thetagargument, if present, are executed.smiSetErrorHandler()β allows you to set a callback function that is called by the MIB parsers deviating from the builtin default error handler, which prints error messages tostderr. The error handler has to comply with theSmiErrorHandlerfunction type. Thepath,line,severity,msg, andtagarguments 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.
πΈ 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 smiLoadModule() 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 correspondent file (either SMIv1/2 or SMIng) is searched along a path.
This path is initialized with:
/usr/share/libsmi/mibs/ietf:/usr/share/libsmi/mibs/iana:/usr/share/libsmi/mibs/irtf:/usr/share/libsmi/mibs/site:/usr/share/libsmi/mibs/jacobs:/usr/share/libsmi/mibs/tubs:/usr/share/libsmi/pibs/ietf:/usr/share/libsmi/pibs/site:/usr/share/libsmi/pibs/tubs:/usr/share/libsmi/yang/ietf:/usr/share/libsmi/yang/iana:/usr/share/libsmi/yang/site
Afterwards the optional global and user configuration files are parsed for path commands, and finally the optional SMIPATH 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 smiGetPath() and smiSetPath() 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. Iconic, honestly π«Ά
π CONFIGURATION FILES π
SMI library configuration files read at initialization and on demand by smiReadConfig() 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 commands are:
loadβ used to preload a given MIB module. If multiple modules shall be preloaded, multipleloadcommands must be used.pathβ allows you to prepend or append components to the MIB module search path or to modify it completely (see also MODULE LOCATIONS above).cacheβ allows you 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.levelβ sets the error level.hideβ allows you to tune the list of errors that are reported. It raises all errors with names prefixed by the given pattern to severity level9.
tiny aside from the original: [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
π¦ FILES π¦
/etc/smi.confβ global configuration file$HOME/.smircβ user configuration file${prefix}/include/smi.hβ SMI library header file/usr/share/libsmi/mibs/β SMI module repository directory
π SEE ALSO π
libsmi(3), smi.h
π AUTHOR π
(C) 1999-2001 Frank Strauss, TU Braunschweig, Germany <strauss@ibr.cs.tu-bs.de>
okay that's the whole page, bestie! source/version tag IBR, dated August 22, 2001, and it's all smi_config(3) β byeee π
β¨
π¦ where this page comes from
- alpine 3.24: libsmi-doc 0.5.0-r5 Β· BSD-3-Clause AND MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms