SnmpKit.SnmpSim.Device.OidHandler (snmpkit v2.0.0)

OID handling and value generation for SNMP device simulation. Handles dynamic OID value generation, interface statistics, and MIB walking.

Summary

Functions

Extracts OID from SNMP PDU variable binding.

Extracts type and value from SNMP variable binding.

Gets dynamic OID value based on device state and OID.

Finds the next OID in lexicographic order for SNMP GetNext operations.

Gets OID value based on device state and OID.

Converts OID list to string representation.

Converts string OID to list of integers.

Walks OID values for SNMP MIB walking.

Functions

extract_oid(varbind)

Extracts OID from SNMP PDU variable binding.

Parameters

  • varbind - SNMP variable binding containing OID and value

Returns

  • oid - Successfully extracted OID

extract_type_and_value(value)

Extracts type and value from SNMP variable binding.

Parameters

  • varbind - SNMP variable binding

Returns

  • {type, value} - Tuple containing SNMP type and value

get_dynamic_oid_value(oid, state)

Gets dynamic OID value based on device state and OID.

Parameters

  • oid - OID as string
  • state - Device state containing configuration and counters

Returns

  • {:ok, {type, value}} - Successfully retrieved OID value with type
  • {:error, reason} - Failed to retrieve OID value

get_next_oid_value(device_type, oid, state)

Finds the next OID in lexicographic order for SNMP GetNext operations.

Parameters

  • oid - Starting OID as list of integers
  • state - Device state

Returns

  • {:ok, {next_oid, type, value}} - Next OID with its type and value
  • {:error, :end_of_mib} - No more OIDs available

get_oid_value(oid, state)

Gets OID value based on device state and OID.

Parameters

  • oid - OID as list of integers or binary string
  • state - Device state containing configuration and counters or device type

Returns

  • {:ok, value} - Successfully retrieved OID value
  • {:error, reason} - Failed to retrieve OID value

oid_to_string(oid)

Converts OID list to string representation.

Parameters

  • oid - List of integers representing OID

Returns

  • String representation of OID (e.g., "1.3.6.1.2.1.1.1.0")

string_to_oid_list(oid_string)

Converts string OID to list of integers.

Parameters

  • oid_string - String representation of OID

Returns

  • List of integers representing OID

walk_oid_recursive(oid, root_oid, state, acc)

walk_oid_values(oid, state)

Walks OID values for SNMP MIB walking.

Parameters

  • oid - Starting OID as list of integers
  • state - Device state

Returns

  • {:ok, oid_values} - List of OID values