The module
This index is used to separate the implementation of the SNMP ordering from the actual implementation of the table. The SNMP ordering, that is implementation of GET NEXT, is implemented in this module.
For example, suppose there is an SNMP table, which is best implemented in Erlang as one process per SNMP table row. Suppose further that the INDEX in the SNMP table is an OCTET STRING. The index structure would be created as follows:
snmp_index:new(string)
For each new process we create, we insert an item in an
Pid = start_process(),
NewSnmpIndex =
snmp_index:insert(SnmpIndex, Name, Pid),
<...>
]]>
With this structure, we can now map an OBJECT IDENTIFIER in e.g. a GET NEXT request, to the correct process:
get_next_pid(Oid, SnmpIndex) ->
{ok, {_, Pid}} = snmp_index:get_next(SnmpIndex, Oid),
Pid.
The following data types are used in the functions below:
The
The
The
The
If the INDEX column is of type INTEGER, or derived from
INTEGER, the corresponding type should be
For example, if the SNMP table has two INDEX columns, the first
one an OCTET STRING with size 2, and the second one an OBJECT
IDENTIFER, the corresponding
The
In the example above, valid
All API functions that update the index return a
The implementation using ets tables introduces a semantic incompatibility with older implementations. In those older implementations, using pure Erlang terms, the index was garbage collected like any other Erlang term and did not have to be deleted when discarded. An ets table is deleted only when the process creating it explicitly deletes it or when the creating process terminates.
A new interface
As an snmp adaption usually keeps the index for the whole of the systems lifetime, this is rarely a problem.
Deletes a complete index structure (i.e. the ets table
holding the index). The index can no longer be referenced
after this call. See the
Deletes a key and its value from the index structure. Returns a new structure.
Gets the item with key
Gets the last item in the index structure.
Gets the next item in the SNMP lexicographic ordering,
after
Inserts a new key value tuple into the index structure. If
an item with the same key already exists, the new
Converts
Creates a new snmp index structure. The