SnmpKit.MIB.TableIndex (snmpkit v2.0.1)
Decodes the instance sub-identifiers of a conceptual row into the values of the table's INDEX objects (RFC 2578 section 7.7).
Each index object is described by %{name, base, size, implied}:
integer-like bases (
:integer,:gauge32,:counter32,:timeticks) take one sub-identifier;:ip_addresstakes four and yields a tuple;:octet_stringwith a fixed size takes that many, otherwise a length sub-identifier followed by the octets (or the rest whenimplied);:object_identifierlikewise takes a length then the sub-identifiers (or the rest whenimplied).iex> SnmpKit.MIB.TableIndex.decode([10, 0, 0, 1, 7], [ ...> %{name: "ipAdEntAddr", base: :ip_address}, ...> %{name: "slot", base: :integer} ...> ]) {:ok, %{"ipAdEntAddr" => {10, 0, 0, 1}, "slot" => 7}}
Summary
Functions
Decodes sub_ids with specs; {:error, reason} when they do not fit.
Types
@type index_spec() :: %{ :name => String.t(), :base => atom() | nil, optional(:size) => {non_neg_integer(), non_neg_integer()} | nil, optional(:implied) => boolean() }
Functions
@spec decode([non_neg_integer()], [index_spec()]) :: {:ok, %{required(String.t()) => term()}} | {:error, term()}
Decodes sub_ids with specs; {:error, reason} when they do not fit.