The purpose of libsmi's core, the library libsmi, is to
The library interface allows an application to access all information shown in the diagram below, either through explicitly named identifiers, e.g. IF-MIB::ifTable or 1.3.6.1.2.1.2.2, or through iterating functions that retrieve definitions the application does not know in advance, e.g. for MIB browsers.
| Area | Functions | Manual page |
|---|---|---|
| Initialization, configuration, module path, error handling | smiInit(), smiExit(), smiLoadModule(), smiSetPath(), smiReadConfig(), smiSetErrorLevel(), smiSetErrorHandler() | smi_config(3) |
| Modules, imports, revisions | smiGetModule(), smiGetFirstModule(), smiGetFirstImport(), smiGetFirstRevision(), smiIsImported() | smi_module(3) |
| Types, ranges, named numbers | smiGetType(), smiGetFirstType(), smiGetParentType(), smiGetFirstRange(), smiGetFirstNamedNumber() | smi_type(3) |
| Nodes of the OID tree, tables, groups, compliances | smiGetNode(), smiGetNodeByOID(), smiGetFirstNode(), smiGetFirstChildNode(), smiGetParentNode(), smiGetRelatedNode(), smiGetFirstElement(), smiGetNodeType() | smi_node(3) |
| Macros, identities | smiGetMacro(), smiGetIdentity() | smi_macro(3), smi_identity(3) |
| Rendering of values, OIDs and types | smiRenderOID(), smiRenderValue(), smiRenderNode(), smiRenderType() | smi_render(3) |
| Utilities: sizes of types, memory helpers | smiGetMinSize(), smiGetMaxSize(), smiFree() | smi_util(3) |
| YANG modules and statements | yangGetModule(), yangGetFirstChildNode(), yangGetNextChildNode(), yangIsModule() | yang_node(3) |
An overview of all functions is in libsmi(3). Applications include <smi.h> and link with -lsmi; pkg-config --cflags --libs libsmi gives the flags, and CMake projects use find_package(libsmi) and the target libsmi::smi. A small complete program is shown in the example.
Modules are searched along a path of directories that is compiled into the library (by default all directories of the bundled modules) and can be changed in the global configuration file smi.conf, in the user's ~/.smirc, with the SMIPATH environment variable and by the application (smiSetPath()). Configuration files can hold options per application, e.g. to preload modules or to hide certain error messages. Module files are named after the module, optionally with an extension such as .mib, .txt or .yang; YANG modules may carry a revision (name@2018-02-20.yang). Details are in smi_config(3).