SnmpKit.SnmpMgr.MIB (snmpkit v2.0.0)
MIB compilation and symbolic name resolution.
This module provides MIB compilation with SnmpKit's own parser (no Erlang :snmpc), and includes a built-in registry of standard MIB objects for basic operations.
Summary
Functions
Returns a specification to start this module under a supervisor.
Gets the children of an OID node.
Compiles a MIB file using SnmpKit.MIB.Compiler pure Elixir implementation.
Compiles all .mib files in a directory with SnmpKit.MIB.Compiler.
Loads a compiled MIB file using SnmpKit.MIB.load_compiled with fallback.
Compiles a MIB file and registers its objects in one step, so they resolve
through resolve/1, reverse_lookup/1 and object_info/1.
Loads standard MIBs that are built into the library.
Names of the MIB modules registered at runtime (via load/1 or
load_and_integrate_mib/2), oldest first. The built-in table is not listed.
Returns enriched MIB metadata for an object by name or OID.
Batch variant of object_info/1. Returns {:ok, list_of_maps} or {:error, reason} if any lookup fails.
Gets the parent of an OID node.
Parses MIB content string using SnmpKit.MIB.Parser.
Parses a MIB file to extract object definitions using SnmpKit.MIB.Parser.
Resolves a symbolic name to an OID.
Enhanced MIB object resolution with parsed MIB data integration.
Performs reverse lookup from OID to symbolic name.
Alias for object_info/1 to match proposal naming.
Reverse lookup that also returns the object's metadata (syntax base,
textual convention, DISPLAY-HINT, enumerations) in one call. Used by the
formatter; {:ok, name, meta} where meta may be nil.
Starts the MIB registry GenServer.
Column names and INDEX descriptions of a table, for SnmpKit.SnmpMgr.Table
named rows. table is the table's OID (list or string) or name.
Walks the MIB tree starting from a root OID.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Gets the children of an OID node.
Compiles a MIB file using SnmpKit.MIB.Compiler pure Elixir implementation.
Enhanced to use SnmpKit.MIB.Compiler for improved compilation with better error handling.
Examples
iex> SnmpKit.SnmpMgr.MIB.compile("SNMPv2-MIB.mib")
{:ok, "SNMPv2-MIB.bin"}
iex> SnmpKit.SnmpMgr.MIB.compile("nonexistent.mib")
{:error, :file_not_found}
Compiles all .mib files in a directory with SnmpKit.MIB.Compiler.
Loads a compiled MIB file using SnmpKit.MIB.load_compiled with fallback.
Compiles a MIB file and registers its objects in one step, so they resolve
through resolve/1, reverse_lookup/1 and object_info/1.
Loads standard MIBs that are built into the library.
@spec loaded_mibs() :: [String.t()]
Names of the MIB modules registered at runtime (via load/1 or
load_and_integrate_mib/2), oldest first. The built-in table is not listed.
Returns enriched MIB metadata for an object by name or OID.
Input may be a dotted OID string (with or without instance), an OID list, or a base name (optionally with an instance suffix like "ifDescr.6").
Returns a map with at least: name (base symbol), base oid, and optional instance fields when input includes an instance. Includes curated syntax metadata for a subset of high-value IF-MIB objects as a stopgap until full compiler metadata is wired in.
Batch variant of object_info/1. Returns {:ok, list_of_maps} or {:error, reason} if any lookup fails.
Gets the parent of an OID node.
Parses MIB content string using SnmpKit.MIB.Parser.
Examples
iex> content = "sysDescr OBJECT-TYPE SYNTAX DisplayString ACCESS read-only STATUS mandatory"
iex> SnmpKit.SnmpMgr.MIB.parse_mib_content(content)
{:ok, %{tokens: [...], parsed_objects: [...]}}
Parses a MIB file to extract object definitions using SnmpKit.MIB.Parser.
This provides enhanced MIB analysis without requiring compilation.
Examples
iex> SnmpKit.SnmpMgr.MIB.parse_mib_file("SNMPv2-MIB.mib")
{:ok, %{objects: [...], imports: [...], exports: [...]}}
Resolves a symbolic name to an OID.
Examples
iex> SnmpKit.SnmpMgr.MIB.resolve("sysDescr.0")
{:ok, [1, 3, 6, 1, 2, 1, 1, 1, 0]}
iex> SnmpKit.SnmpMgr.MIB.resolve("sysDescr")
{:ok, [1, 3, 6, 1, 2, 1, 1, 1]}
iex> SnmpKit.SnmpMgr.MIB.resolve("unknownName")
{:error, :not_found}
Enhanced MIB object resolution with parsed MIB data integration.
Returns enriched object information including OID, syntax, module, and more. Leverages both standard MIBs and any loaded/parsed MIB files for comprehensive resolution.
Examples
iex> SnmpKit.SnmpMgr.MIB.resolve_enhanced("sysDescr")
{:ok, %{name: "sysDescr", oid: [1, 3, 6, 1, 2, 1, 1, 1], module: "SNMPv2-MIB", syntax: %{...}}}
iex> SnmpKit.SnmpMgr.MIB.resolve_enhanced("sysDescr.0")
{:ok, %{name: "sysDescr", oid: [1, 3, 6, 1, 2, 1, 1, 1], instance_oid: [1, 3, 6, 1, 2, 1, 1, 1, 0], ...}}
Performs reverse lookup from OID to symbolic name.
Examples
iex> SnmpKit.SnmpMgr.MIB.reverse_lookup([1, 3, 6, 1, 2, 1, 1, 1, 0])
{:ok, "sysDescr.0"}
iex> SnmpKit.SnmpMgr.MIB.reverse_lookup([1, 3, 6, 1, 2, 1, 1, 1])
{:ok, "sysDescr"}
Alias for object_info/1 to match proposal naming.
@spec reverse_lookup_with_meta([non_neg_integer()] | String.t()) :: {:ok, String.t(), map() | nil} | {:error, term()}
Reverse lookup that also returns the object's metadata (syntax base,
textual convention, DISPLAY-HINT, enumerations) in one call. Used by the
formatter; {:ok, name, meta} where meta may be nil.
Starts the MIB registry GenServer.
@spec table_layout([non_neg_integer()] | String.t()) :: {:ok, map()} | {:error, term()}
Column names and INDEX descriptions of a table, for SnmpKit.SnmpMgr.Table
named rows. table is the table's OID (list or string) or name.
{:ok, %{entry: "ifEntry", columns: %{1 => "ifIndex", 2 => "ifDescr", ...},
indexes: [%{name: "ifIndex", base: :integer, size: nil, implied: false}]}}
Walks the MIB tree starting from a root OID.