SnmpKit.SnmpLib.Security.EngineCache (snmpkit v2.0.1)

Remembers what the manager has learned about remote SNMPv3 engines: the authoritative engine id of each {host, port} and its boots/time, so a request does not need a discovery round trip and a time synchronisation every time.

Entries are refreshed whenever an agent answers with a usmStatsNotInTimeWindows or usmStatsUnknownEngineIDs report.

Summary

Functions

Returns a specification to start this module under a supervisor.

Forgets one engine or, with no argument, every engine.

The agent's engine time as of now, from a cached entry.

The cached entry for {host, port}, or nil.

Stores the engine id and current boots/time of {host, port}.

Types

entry()

@type entry() :: %{
  engine_id: binary(),
  engine_boots: non_neg_integer(),
  time_offset: integer(),
  learned_at: integer()
}

key()

@type key() :: {:inet.ip_address() | String.t(), :inet.port_number()}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

clear(key \\ nil)

@spec clear(key() | nil) :: :ok

Forgets one engine or, with no argument, every engine.

current_time(map)

@spec current_time(entry()) :: non_neg_integer()

The agent's engine time as of now, from a cached entry.

lookup(key)

@spec lookup(key()) :: entry() | nil

The cached entry for {host, port}, or nil.

start_link(opts \\ [])

store(key, engine_id, engine_boots, engine_time)

@spec store(key(), binary(), non_neg_integer(), non_neg_integer()) :: :ok

Stores the engine id and current boots/time of {host, port}.