Search documentation of snmpkit

# SnmpKit.SnmpMgr.MIB (snmpkit v1.2.0)

MIB compilation and symbolic name resolution.

This module provides MIB compilation using Erlang's :snmpc when available, and includes a built-in registry of standard MIB objects for basic operations.

# Summary

## Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

children(oid)

Gets the children of an OID node.

compile(mib_file, opts \\ [])

Compiles a MIB file using SnmpKit.SnmpLib.MIB pure Elixir implementation.

compile_dir(directory, opts \\ [])

Compiles all MIB files in a directory using enhanced SnmpKit.SnmpLib.MIB capabilities.

load(compiled_mib_path)

Loads a compiled MIB file using SnmpKit.SnmpLib.MIB.load_compiled with fallback.

load_and_integrate_mib(mib_file, opts \\ [])

Loads and parses a MIB file, integrating it into the name resolution system.

load_standard_mibs()

Loads standard MIBs that are built into the library.

object_info(name_or_oid)

Returns enriched MIB metadata for an object by name or OID.

object_info_many(list)

Batch variant of object_info/1. Returns {:ok, list_of_maps} or {:error, reason} if any lookup fails.

parent(oid)

Gets the parent of an OID node.

parse_mib_content(content, opts \\ [])

Parses MIB content string using SnmpKit.SnmpLib.MIB.Parser.

parse_mib_file(mib_file, opts \\ [])

Parses a MIB file to extract object definitions using SnmpKit.SnmpLib.MIB.Parser.

resolve(name)

Resolves a symbolic name to an OID.

resolve_enhanced(name, opts \\ [])

Enhanced MIB object resolution with parsed MIB data integration.

reverse_lookup(oid)

Performs reverse lookup from OID to symbolic name.

reverse_lookup_enriched(name_or_oid)

Alias for object_info/1 to match proposal naming.

start_link(opts \\ [])

Starts the MIB registry GenServer.

walk_tree(root_oid, opts \\ [])

Walks the MIB tree starting from a root OID.

# Functions

# child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# children(oid)

Gets the children of an OID node.

# compile(mib_file, opts \\ [])

Compiles a MIB file using SnmpKit.SnmpLib.MIB pure Elixir implementation.

Enhanced to use SnmpKit.SnmpLib.MIB 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}

# compile_dir(directory, opts \\ [])

Compiles all MIB files in a directory using enhanced SnmpKit.SnmpLib.MIB capabilities.

# load(compiled_mib_path)

Loads a compiled MIB file using SnmpKit.SnmpLib.MIB.load_compiled with fallback.

# load_and_integrate_mib(mib_file, opts \\ [])

Loads and parses a MIB file, integrating it into the name resolution system.

This combines compilation/loading with parsing for comprehensive MIB support.

# load_standard_mibs()

Loads standard MIBs that are built into the library.

# object_info(name_or_oid)

    @spec object_info(String.t() | [integer()]) :: {:ok, map()} | {:error, term()}

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.

# object_info_many(list)

    @spec object_info_many([String.t() | [integer()]]) ::
      {:ok, [map()]} | {:error, term()}

Batch variant of object_info/1. Returns {:ok, list_of_maps} or {:error, reason} if any lookup fails.

# parent(oid)

Gets the parent of an OID node.

# parse_mib_content(content, opts \\ [])

Parses MIB content string using SnmpKit.SnmpLib.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: [...]}}

# parse_mib_file(mib_file, opts \\ [])

Parses a MIB file to extract object definitions using SnmpKit.SnmpLib.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: [...]}}

# resolve(name)

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}

# resolve_enhanced(name, opts \\ [])

Enhanced MIB object resolution with parsed MIB data integration.

Leverages both standard MIBs and any loaded/parsed MIB files for comprehensive name resolution.

# reverse_lookup(oid)

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"}

# reverse_lookup_enriched(name_or_oid)

    @spec reverse_lookup_enriched(String.t() | [integer()]) ::
      {:ok, map()} | {:error, term()}

Alias for object_info/1 to match proposal naming.

# start_link(opts \\ [])

Starts the MIB registry GenServer.

# walk_tree(root_oid, opts \\ [])

Walks the MIB tree starting from a root OID.