SnmpKit.SnmpLib.MIB.AST (snmpkit v0.6.6)
Abstract Syntax Tree definitions for MIB compilation.
Faithfully ported from Erlang OTP snmpc_mib_gram.yrl and related structures. Provides the complete AST representation needed for SNMP MIB compilation.
Summary
Functions
Build an OID tree from definitions for fast lookups.
Determine SNMP version based on MIB content.
Create a new import statement.
Create a new MIB AST node.
Create a new object identity definition.
Create a new object type definition.
Pretty print AST node for debugging.
Validate AST node structure.
Types
@type access_level() ::
:not_accessible
| :accessible_for_notify
| :read_only
| :read_write
| :read_create
| :write_only
@type agent_capabilities() :: %{ __type__: :agent_capabilities, name: binary(), product_release: binary(), status: status(), description: binary(), reference: binary() | nil, modules: [capability_module()], oid: oid(), line: line_number() }
@type capability_module() :: %{ module_name: binary(), includes: [binary()], variations: [object_variation()] }
@type compliance_module() :: %{ module_name: binary(), mandatory_groups: [binary()], compliance_objects: [compliance_object()] }
@type compliance_object() :: %{ object: binary(), syntax: syntax() | nil, write_syntax: syntax() | nil, access: access_level() | nil, description: binary() | nil }
@type constraint() :: {:size, size_constraint()} | {:range, range_constraint()} | {:named_values, [named_value()]} | {:contained_subtype, syntax()}
@type constraints() :: [constraint()]
@type constructed_syntax() :: {:sequence, [sequence_element()]} | {:sequence_of, syntax()} | {:choice, [choice_element()]} | {:bit_string, [named_bit()]}
@type definition() :: object_type() | object_identity() | object_group() | notification_type() | notification_group() | module_identity() | module_compliance() | agent_capabilities() | textual_convention() | trap_type() | object_identifier_assignment()
@type import() :: %{ __type__: :import, symbols: [binary()], from_module: binary(), line: line_number() }
@type index_spec() :: {:index, [index_element()]} | {:implied, [index_element()]}
@type line_number() :: integer()
@type module_compliance() :: %{ __type__: :module_compliance, name: binary(), status: status(), description: binary(), reference: binary() | nil, modules: [compliance_module()], oid: oid(), line: line_number() }
@type object_identifier_assignment() :: %{ __type__: :object_identifier_assignment, name: binary(), oid: oid(), line: line_number() }
@type object_type() :: %{ __type__: :object_type, name: binary(), syntax: syntax(), units: binary() | nil, max_access: access_level(), status: status(), description: binary(), reference: binary() | nil, index: index_spec() | nil, augments: binary() | nil, defval: default_value() | nil, oid: oid(), line: line_number() }
@type object_variation() :: %{ object: binary(), syntax: syntax() | nil, write_syntax: syntax() | nil, access: access_level() | nil, creation: boolean(), defval: default_value() | nil, description: binary() }
@type oid() :: [integer()] | [oid_element()]
@type primitive_syntax() :: :integer | :octet_string | :object_identifier | :null | :real | {:integer, constraints()} | {:octet_string, constraints()} | {:object_identifier, constraints()}
@type range_constraint() :: {integer(), integer()} | [range_spec()]
@type revision() :: %{ __type__: :revision, date: binary(), description: binary(), line: line_number() }
@type sequence_element() :: %{ name: binary(), syntax: syntax(), optional: boolean(), default: default_value() | nil }
@type size_constraint() :: integer() | {integer(), integer()} | [size_range()]
@type status() :: :current | :deprecated | :obsolete | :mandatory
@type syntax() :: primitive_syntax() | constructed_syntax() | named_syntax()
@type tag() :: integer()
Functions
@spec build_oid_tree([definition()]) :: :ets.tid()
Build an OID tree from definitions for fast lookups.
@spec determine_snmp_version([definition()]) :: :v1 | :v2c
Determine SNMP version based on MIB content.
Per Erlang implementation: presence of MODULE-IDENTITY indicates SNMPv2.
@spec new_import([binary()], binary(), line_number()) :: import()
Create a new import statement.
Create a new MIB AST node.
@spec new_object_identity( binary(), keyword() ) :: object_identity()
Create a new object identity definition.
@spec new_object_type( binary(), keyword() ) :: object_type()
Create a new object type definition.
Pretty print AST node for debugging.
Validate AST node structure.