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. 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. If tag is NULL, 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 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.
  • smiGetFlags() and smiSetFlags() β€” allow you to fetch, modify, and set some userflags that control the SMI library's behaviour. The flag tea is:
    • If SMI_FLAG_ERRORS 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 SMI_FLAG_STATS is set, the library prints some module statistics.
    • If SMI_FLAG_RECURSIVE is set, the library also complains about errors in modules that are read due to import statements.
    • If SMI_FLAG_NODESCR 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.
  • smiSetSeverity() β€” allows you to set the severity of all errors that have a name prefixed by pattern to the value severity.
  • 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, or NULL if it could not be loaded.
  • smiIsLoaded() β€” returns a positive value if the module named module is already loaded, or zero otherwise.
  • smiGetPath() and smiSetPath() β€” 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:...", or NULL if no path is set. The application should free this string if it is no longer needed. smiSetPath() sets the search path to path.
  • smiReadConfig() β€” reads the configuration file filename. All global statements in the configuration file and those statements with a tag (a tag: prefix) that matches the tag argument, 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 to stderr. The error handler has to comply with the SmiErrorHandler function type. The path, line, severity, msg, and tag arguments 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, multiple load commands 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 level 9.
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