.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "SNMP::MIB::Compiler 3pm" .TH SNMP::MIB::Compiler 3pm "2019-07-22" "perl v5.28.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SNMP::MIB::Compiler \- a MIB Compiler supporting SMIv1 and SMIv2 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use SNMP::MIB::Compiler; \& \& my $mib = new SNMP::MIB::Compiler; \& \& # search MIBs there... \& $mib\->add_path(\*(Aq./mibs\*(Aq, \*(Aq/foo/bar/mibs\*(Aq); \& \& # possibly using these extensions... \& $mib\->add_extension(\*(Aq\*(Aq, \*(Aq.mib\*(Aq, \*(Aq.my\*(Aq); \& \& # store the compiled MIBs there.. \& $mib\->repository(\*(Aq./out\*(Aq); \& \& # only accept SMIv2 MIBs \& $mib\->{\*(Aqaccept_smiv1\*(Aq} = 0; \& $mib\->{\*(Aqaccept_smiv2\*(Aq} = 1; \& \& # no debug \& $mib\->{\*(Aqdebug_lexer\*(Aq} = 0; \& $mib\->{\*(Aqdebug_recursive\*(Aq} = 0; \& \& # store compiled MIBs into files \& $mib\->{\*(Aqmake_dump\*(Aq} = 1; \& # read compiled MIBs \& $mib\->{\*(Aquse_dump\*(Aq} = 1; \& # follow IMPORTS clause while compiling \& $mib\->{\*(Aqdo_imports\*(Aq} = 1; \& \& # load a precompiled MIB \& $mib\->load(\*(AqSNMPv2\-MIB\*(Aq); \& \& # compile a new MIB \& $mib\->compile(\*(AqIF\-MIB\*(Aq); \& \& print $mib\->resolve_oid(\*(AqifInOctets\*(Aq), "\en"; \& print $mib\->convert_oid(\*(Aq1.3.6.1.2.1.31.1.1.1.10\*(Aq), "\en"; \& print $mib\->tree(\*(AqifMIB\*(Aq); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" .Vb 5 \& SNMP::MIB::Compiler is a MIB compiler that fully supports \& both SMI(v1) and SMIv2. This module can be use to compile \& MIBs (recursively or not) or load already compiled MIBs for \& later use. \& Some tasks can be performed by the resulting object such as : \& \& \- resolution of object names into object identifiers (OIDs). \& e.g. ifInOctets => 1.3.6.1.2.1.2.2.1.10 \& \& \- convertion of OIDs. \& e.g. 1.3.6.1.2.1.2.1 => \& iso.org.dod.internet.mgmt.mib\-2.interfaces.ifNumber \& \& \- drawing MIB trees. \& e.g. ifTestTable => ifTestTable \& | \& +\-\- \-\-\- ifTestEntry(1) \& | \& +\-\- \-rw Integer ifTestId(1) \& +\-\- \-rw Integer ifTestStatus(2) \& +\-\- \-rw ObjectID ifTestType(3) \& +\-\- \-r\- Integer ifTestResult(4) \& +\-\- \-r\- ObjectID ifTestCode(5) \& +\-\- \-rw String ifTestOwner(6) \& \& \& The MIB to be compiled requires no modification. Everything legal \& according to SMIs is accepted, including MACRO definitions (which \& are parsed but ignored). \& \& This module is shipped with the basic MIBs usually needed by IMPORTS \& clauses. A lot of IETF MIBs has been successfully tested as well as \& some private ones. .Ve .SH "Methods" .IX Header "Methods" .ie n .IP """new""" 5 .el .IP "\f(CWnew\fR" 5 .IX Item "new" \&\f(CW\*(C`SNMP::MIB::Compiler::new()\*(C'\fR \fIclass method\fR .Sp To create a new \s-1MIB,\s0 send a \fBnew()\fR message to the SNMP::MIB::Compiler class. For example: .Sp .Vb 1 \& my $mib = new SNMP::MIB::Compiler; .Ve .Sp This will create an empty \s-1MIB\s0 ready to accept both SMIv1 and SMIv2 MIBs. A lot of attributes can be (des)activated to obtain a more or less strict and verbose compiler. The created object is returned. .ie n .IP """add_path""" 5 .el .IP "\f(CWadd_path\fR" 5 .IX Item "add_path" \&\f(CW\*(C`SNMP::MIB::Compiler::add_path(p1[,p2[,p3]])\*(C'\fR \fIobject method\fR .Sp Add one or more directories to the search path. This path is used to locate a \s-1MIB\s0 file when the 'compile' method is invoqued. The current list of paths is returned. .Sp Example: .Sp .Vb 3 \& # search MIBs in the "mibs" directory (relative \& # to cwd) and in "/foo/bar/mibs" (absolute path) \& $mib\->add_path(\*(Aq./mibs\*(Aq, \*(Aq/foo/bar/mibs\*(Aq); .Ve .ie n .IP """add_extension""" 5 .el .IP "\f(CWadd_extension\fR" 5 .IX Item "add_extension" \&\f(CW\*(C`SNMP::MIB::Compiler::add_extension(e1[,e2[,e3]])\*(C'\fR \fIobject method\fR .Sp Add one or more extensions to the extension list. These extensions are used to locate a \s-1MIB\s0 file when the 'compile' method is invoqued. All extensions are tested for each directory specified by the \fBadd_path()\fR method until one match. The current list of extensions is returned. .Sp Example: .Sp .Vb 3 \& $mib\->add_path(\*(Aq./mibs\*(Aq, \*(Aq/foo/bar/mibs\*(Aq); \& $mib\->add_extension(\*(Aq\*(Aq, \*(Aq.mib\*(Aq); \& $mib\->compile(\*(AqFOO\*(Aq); \& \& The order is "./mibs/FOO", "./mibs/FOO.mib", "/foo/bar/mibs/FOO" \& and "/foo/bar/mibs/FOO.mib". .Ve .ie n .IP """repository""" 5 .el .IP "\f(CWrepository\fR" 5 .IX Item "repository" \&\f(CW\*(C`SNMP::MIB::Compiler::repository([dir])\*(C'\fR \fIobject method\fR .Sp If 'dir' is defined, set the directory where compiled MIBs will be stored (using the \fBcompile()\fR method) or loaded (using the \fBload()\fR method). The repository \s-1MUST\s0 be initialized before a \s-1MIB\s0 can be compiled or loaded. The current repository is returned. .Sp Example: .Sp .Vb 2 \& $mib\->repository(\*(Aq./out\*(Aq); \& print "Current repository is ", $mib\->repository, "\en"; .Ve .ie n .IP """compile""" 5 .el .IP "\f(CWcompile\fR" 5 .IX Item "compile" \&\f(CW\*(C`SNMP::MIB::Compiler::compile(mib)\*(C'\fR \fIobject method\fR .Sp Compile a \s-1MIB\s0 given its name. All information contained in this \s-1MIB\s0 is inserted into the current object and is stored into a file in the repository (see the 'make_dump' attribute). The choosen name is the same as the real \s-1MIB\s0 name (defined in the \s-1MIB\s0 itself). If a precompiled \s-1MIB\s0 already exists in the repository and is newer than the given file, it is used instead of a real compilation (see the 'use_dump' attribute). The compiler can be recursive if \s-1IMPORTS\s0 clauses are followed (see the 'do_imports' attribute) and in that case, uncompiled \&\s-1MIB\s0 names must be explict according to paths and extensions critaeria (see \fBadd_path()\fR and \fBadd_extensions()\fR methods). The current object is returned. .ie n .IP """load""" 5 .el .IP "\f(CWload\fR" 5 .IX Item "load" \&\f(CW\*(C`SNMP::MIB::Compiler::load(mib)\*(C'\fR \fIobject method\fR .Sp Load a precompiled \s-1MIB\s0 given its name. All information contained in this \s-1MIB\s0 is inserted into the current object. The file is searched in the repository which \s-1MUST\s0 be initialized. In case of success, returns 1 else returns 0. .Sp Example: .Sp .Vb 2 \& $mib\->load(\*(AqSNMPv2\-SMI\*(Aq); \& $mib\->load(\*(AqSNMPv2\-MIB\*(Aq); .Ve .ie n .IP """resolve_oid""" 5 .el .IP "\f(CWresolve_oid\fR" 5 .IX Item "resolve_oid" \&\f(CW\*(C`SNMP::MIB::Compiler::resolve_oid(node)\*(C'\fR \fIobject method\fR .Sp Example: .Sp .Vb 1 \& print $mib\->resolve_oid(\*(AqifInOctets\*(Aq), "\en"; .Ve .ie n .IP """convert_oid""" 5 .el .IP "\f(CWconvert_oid\fR" 5 .IX Item "convert_oid" \&\f(CW\*(C`SNMP::MIB::Compiler::convert_oid(oid)\*(C'\fR \fIobject method\fR .Sp Example: .Sp .Vb 1 \& print $mib\->convert_oid(\*(Aq1.3.6.1.2.1.31.1.1.1.10\*(Aq), "\en"; .Ve .ie n .IP """tree""" 5 .el .IP "\f(CWtree\fR" 5 .IX Item "tree" \&\f(CW\*(C`SNMP::MIB::Compiler::tree(node)\*(C'\fR \fIobject method\fR .Sp Example: .Sp .Vb 1 \& print $mib\->tree(\*(AqifMIB\*(Aq); .Ve .SH "Attributes" .IX Header "Attributes" .ie n .IP """do_imports""" 5 .el .IP "\f(CWdo_imports\fR" 5 .IX Item "do_imports" .PD 0 .ie n .IP """accept_smiv1""" 5 .el .IP "\f(CWaccept_smiv1\fR" 5 .IX Item "accept_smiv1" .ie n .IP """accept_smiv2""" 5 .el .IP "\f(CWaccept_smiv2\fR" 5 .IX Item "accept_smiv2" .ie n .IP """allow_underscore""" 5 .el .IP "\f(CWallow_underscore\fR" 5 .IX Item "allow_underscore" .ie n .IP """allow_lowcase_hstrings""" 5 .el .IP "\f(CWallow_lowcase_hstrings\fR" 5 .IX Item "allow_lowcase_hstrings" .ie n .IP """allow_lowcase_bstrings""" 5 .el .IP "\f(CWallow_lowcase_bstrings\fR" 5 .IX Item "allow_lowcase_bstrings" .ie n .IP """make_dump""" 5 .el .IP "\f(CWmake_dump\fR" 5 .IX Item "make_dump" .ie n .IP """dumpext""" 5 .el .IP "\f(CWdumpext\fR" 5 .IX Item "dumpext" .ie n .IP """use_dump""" 5 .el .IP "\f(CWuse_dump\fR" 5 .IX Item "use_dump" .ie n .IP """debug_lexer""" 5 .el .IP "\f(CWdebug_lexer\fR" 5 .IX Item "debug_lexer" .ie n .IP """debug_recursive""" 5 .el .IP "\f(CWdebug_recursive\fR" 5 .IX Item "debug_recursive" .PD .SH "BUGS" .IX Header "BUGS" Currently, it is more a \s-1TODO\s0 list than a bug list. .PP \&\- not enough documentation .PP \&\- not enough methods .PP \&\- not enough test scripts .PP \&\- find a better name for compiled MIBs than 'dump's.. even if they are no more than dumps. .PP If your MIBs can't be compiled by this module, please, double check their syntax. If you really think that they are correct, send them to me including their \*(L"uncommon\*(R" dependencies. .SH "AUTHOR" .IX Header "AUTHOR" Fabien Tassin (fta@oleane.net) .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright 1998, 1999, Fabien Tassin. All rights reserved. It may be used and modified freely, but I do request that this copyright notice remain attached to the file. You may modify this module as you wish, but if you redistribute a modified version, please attach a note listing the modifications you have made.