Search documentation of snmpkit

# SnmpKit.SnmpSim.OIDTree (snmpkit v1.2.0)

Optimized OID tree for fast lookups and lexicographic traversal. Supports GETNEXT operations and GETBULK bulk retrieval.

Uses a radix tree structure optimized for OID operations with:

- Fast O(log n) lookups and insertions
- Efficient lexicographic traversal for GETNEXT
- Memory-efficient storage for 10K+ OIDs
- Optimized bulk operations

# Summary

## Functions

bulk_walk(tree, start_oid, max_repetitions, non_repeaters \\ 0)

Perform a bulk walk operation starting from the given OID. Used for GETBULK operations with proper handling of non-repeaters and max-repetitions.

empty?(tree)

Check if the tree is empty.

get(tree, oid_string)

Get the value for an exact OID match.

get_next(tree, oid_string)

Get the next OID in lexicographic order (GETNEXT operation). Returns the next OID after the given OID, or :end_of_mib if no more OIDs exist.

insert(tree, oid_string, value, behavior_info \\ nil)

Insert an OID with its value and behavior information into the tree. Maintains lexicographic ordering for efficient GETNEXT operations.

list_oids(tree)

Get all OIDs in the tree in lexicographic order. Useful for debugging and full tree traversal.

new()

Create a new empty OID tree.

size(tree)

Get the size of the tree (number of OIDs).

# Functions

# bulk_walk(tree, start_oid, max_repetitions, non_repeaters \\ 0)

Perform a bulk walk operation starting from the given OID. Used for GETBULK operations with proper handling of non-repeaters and max-repetitions.

## Examples

    results = SnmpKit.SnmpSim.OIDTree.bulk_walk(tree, "1.3.6.1.2.1.2.2.1", 10, 0)

# empty?(tree)

Check if the tree is empty.

## Examples

    empty? = SnmpKit.SnmpSim.OIDTree.empty?(tree)

# get(tree, oid_string)

Get the value for an exact OID match.

## Examples

    {:ok, value, behavior} = SnmpKit.SnmpSim.OIDTree.get(tree, "1.3.6.1.2.1.1.1.0")
    :not_found = SnmpKit.SnmpSim.OIDTree.get(tree, "1.3.6.1.2.1.1.1.999")

# get_next(tree, oid_string)

Get the next OID in lexicographic order (GETNEXT operation). Returns the next OID after the given OID, or :end_of_mib if no more OIDs exist.

## Examples

    {:ok, next_oid, value, behavior} = SnmpKit.SnmpSim.OIDTree.get_next(tree, "1.3.6.1.2.1.1.1.0")
    :end_of_mib = SnmpKit.SnmpSim.OIDTree.get_next(tree, "1.3.6.1.9.9.9.9.9")

# insert(tree, oid_string, value, behavior_info \\ nil)

Insert an OID with its value and behavior information into the tree. Maintains lexicographic ordering for efficient GETNEXT operations.

## Examples

    tree = SnmpKit.SnmpSim.OIDTree.new()
    tree = SnmpKit.SnmpSim.OIDTree.insert(tree, "1.3.6.1.2.1.1.1.0", "System Description", nil)

# list_oids(tree)

Get all OIDs in the tree in lexicographic order. Useful for debugging and full tree traversal.

## Examples

    oids = SnmpKit.SnmpSim.OIDTree.list_oids(tree)

# new()

Create a new empty OID tree.

## Examples

    tree = SnmpKit.SnmpSim.OIDTree.new()

# size(tree)

Get the size of the tree (number of OIDs).

## Examples

    size = SnmpKit.SnmpSim.OIDTree.size(tree)