mibc

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mibc compiles SMIv1/SMIv2 MIB modules into the agent's SNMP manifests and trap profiles (INF-014, INF-015, gap G-20), so a vendor MIB can be polled and its traps named without hand-written YAML. It is our own small parser: it reads the subset of the MIB grammar that names objects (OBJECT IDENTIFIER, OBJECT-TYPE, NOTIFICATION-TYPE, TRAP-TYPE and the other macro invocations that assign an OID), textual conventions and type assignments. MACRO bodies are skipped.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Compiler

type Compiler struct {
	// contains filtered or unexported fields
}

Compiler resolves names across every module added to it.

func New

func New() *Compiler

New returns an empty compiler.

func (*Compiler) Add

func (c *Compiler) Add(mods ...*Module)

Add registers parsed modules. A later definition of a name replaces an earlier one.

func (*Compiler) AddFile

func (c *Compiler) AddFile(path string) ([]string, error)

AddFile parses and adds one MIB file.

func (*Compiler) Compile

func (c *Compiler) Compile(module string) (Result, error)

Compile turns one added module into a manifest (its tables and numeric scalars) and a trap profile file (its NOTIFICATION-TYPE and TRAP-TYPE definitions).

func (*Compiler) OID

func (c *Compiler) OID(name string) (string, error)

OID resolves a name to its dotted OID.

type Module

type Module struct {
	Name    string
	Objects []*Object
	Types   map[string]TypeDef
}

Module is one parsed MIB module.

func Parse

func Parse(src string) ([]*Module, error)

Parse reads every module in src.

type Object

type Object struct {
	Name, Module string
	Macro        string // OBJECT-TYPE, NOTIFICATION-TYPE, TRAP-TYPE, OBJECT IDENTIFIER, ...
	Parent       string // first component of the OID value
	Sub          []int  // the numeric components after Parent
	Syntax       string // base type name, e.g. Counter64, INTEGER, DisplayString
	SequenceOf   string // SYNTAX SEQUENCE OF <entry type>: this object is a table
	Enum         map[int]string
	Units        string
	Access       string
	Index        []string
	Augments     string
	Objects      []string // NOTIFICATION-TYPE OBJECTS, TRAP-TYPE VARIABLES
	Enterprise   string   // TRAP-TYPE ENTERPRISE
	Description  string
	Line         int
}

Object is one named node of a module.

type Result

type Result struct {
	Manifest snmp.Manifest
	Traps    snmp.TrapProfileFile
	Warnings []string
}

Result is what one module compiles to.

type TypeDef

type TypeDef struct {
	Base string
	Enum map[int]string
}

TypeDef is a textual convention or a type assignment.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL