📄 x-mibcomp4.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title> The MIB Compiler User's Guide </title></head><body bgcolor="FFFFFF"><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a></a><a href="x-mibcomp.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="x-mibcomp3.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="x-mibcomp5.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h3 class="H2"><i><a name="83478">A.4 MIB Input File Format</a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="83479"> </a>If you are already familiar with how MIBs are written, you can probably skip most of this section. However, you should still read the descriptions of the extended keywords <b class="symbol_UC">DEFAULT</b>, <b class="symbol_UC">EXCLUDE</b>, and <b class="symbol_UC">FORCE-INCLUDE</b>, which are specific to this implementation of a MIB compiler.</p><dd><p class="Body"><a name="83480"> </a>This section describes the format of the description file used as input by <b class="command">mibcomp</b>. This form is described more completely and generally in the SMI documents cited in <a href="x-mibcomp3.html#83451"><i class="title">A.3 Theory of Operation</i></a> of this manual.</p><dd><p class="Body"><a name="83484"> </a><b class="command">mibcomp</b> does not provide a general-purpose ASN.1 parser. Instead, <b class="command">mibcomp</b> implements a subset of the ASN.1 macro language, tailored to MIB specifications as they appear in the Internet community.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="83485">A.4.1 General Layout</a></i></h4></font><dl class="margin"><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="83486">Module Name</a></i></h5></font><dl class="margin"><dd><p class="Body"><a name="83487"> </a>A MIB description begins with the MIB's module name, a list of all the objects and textual conventions that the MIB exports to other MIBs, and a list of any objects, textual conventions, or ASN.1 macros that the MIB imports from other MIB modules. The MIB's module name must be unique; this includes MIB modules that are actually <b class="command">mibcomp</b> control files. If there is no list of exports, all objects and textual conventions in the MIB are implicitly exported.</p><dl class="margin"><dd><pre class="Code2"><b><a name="83488">EXAMPLE-MIB DEFINITIONS ::= BEGIN</a></b><dd> <b><a name="83489"> EXPORTS examples;</a></b><dd> <b><a name="83490"> IMPORTS enterprises</a></b><dd> <b><a name="83491"> FROM RFC1155-SMI;</a></b></pre></dl><dd><p class="Body"><a name="83492"> </a>All MIBs import at least a few ASN.1 macros, for example, the <b class="symbol_UC">OBJECT-TYPE</b> macro from one of the SMIs. Most MIBs import at least a few more object identifiers and textual conventions. For instance, <b class="symbol_lc">mgmt</b> is an object identifier that many MIBs import from the appropriate SMI (RFC1155-SMI for SNMPv1). <b class="symbol_lc">DisplayString</b> is a textual convention that many MIBs import (from the RFC1213-MIB module for SNMPv1 MIBs---note that this implies that an SNMPv1 MIB which uses <b class="symbol_lc">DisplayString</b> cannot be processed by <b class="command">mibcomp</b> unless you first load RFC1213-MIB from <b class="symbol_lc">rfc1213.mib</b>).</p></dl><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="83493">Object Identifiers</a></i></h5></font><dl class="margin"><dd><p class="Body"><a name="83494"> </a>Most MIBs then define any object identifiers they need. A MIB can define an object identifier anywhere in its body, but by convention they are usually defined at the beginning of the MIB. Many MIBs are broken into groups of variables; the groups are usually defined as object identifiers, and the actual variables then placed in the groups when they are later defined using <b class="symbol_UC">OBJECT-TYPE</b>.</p><dl class="margin"><dd><pre class="Code2"><b><a name="83495">-- WRS private enterprises MIB extensions wrs OBJECT IDENTIFIER ::= { enterprises 731 } -- examples MIB examples OBJECT IDENTIFIER ::= { wrs 7 }</a></b></pre></dl></dl><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="83496">Textual Conventions</a></i></h5></font><dl class="margin"><dd><p class="Body"><a name="83497"> </a>Most MIBs then define any textual conventions that they use later. A textual convention is a way of defining a new type based on other types. Note that SNMP does not allow aggregate types; you may not define a new type to be an ASN.1 SEQUENCE. Textual conventions are mostly used to provide clarity in a MIB as to how a type is being used.</p><dl class="margin"><dd><pre class="Code2"><b><a name="83498">-- Make a textual convention</a></b><dd> <b><a name="83499">ExampleType ::= INTEGER { one(1), two(2) }</a></b></pre></dl></dl><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="83500">NMS-Manageable Objects</a></i></h5></font><dl class="margin"><dd><p class="Body"><a name="83501"> </a>After defining textual conventions, MIBs usually define the objects that a network management station can access. These objects are defined using <b class="symbol_UC">OBJECT-TYPE</b>.</p><dl class="margin"><dd><pre class="Code2"><b><a name="83502">-- define a couple of objects exFirstObject OBJECT-TYPE SYNTAX ExampleType ACCESS read-write STATUS mandatory DESCRIPTION "First example object." REFERENCE "EXAMPLE MIB SPECIFICATION VERSION 0.0" DEFVAL { 1 } ::= { examples 1 }</a></b></pre></dl><dd><p class="Body"><a name="83503"> </a>Every <b class="symbol_UC">OBJECT-TYPE</b> invocation has several clauses:</p></dl><dl class="margin"><dd><div class="Item"><a name="83504"> </a><b class="symbol_UC">SYNTAX</b> </div><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent3"><a name="84023"> </a>An object's <b class="symbol_UC">SYNTAX</b> is its data type. This clause must be present for each object.</><br><dd><div class="Indent3"><a name="84056"> </a>In addition to textual conventions defined in a MIB, <b class="command">mibcomp</b> accepts the following basic data types:</><br></dl></dl></dl><dd><div class="Item"><a name="84057"> </a><b class="symbol_UC">INTEGER</b> </div><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent3"><a name="84058"> </a>This is one of ASN.1's fundamental data types. SNMPv1 restricts <b class="symbol_UC">INTEGER</b> variables to the range from -2<sup>31</sup> to 2<sup>31</sup>-1.</><br><dd><div class="Indent3"><a name="83507"> </a>You can use <b class="symbol_UC">INTEGER</b> with ASN.1 sub-typing to create variables that have a more restrictive range. You can also create <b class="symbol_UC">INTEGER</b> variables with "named-number enumerations" like the ones used in the <b class="symbol_lc">ExampleType</b> textual convention shown above.</><br></dl></dl></dl><dd><div class="Item"><a name="83508"> </a><b class="symbol_UC">OCTET STRING <br></b></div><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent3"><a name="84025"> </a>A string of octets (bytes), usually used to hold binary data or character strings. This is one of ASN.1's fundamental data types.</><br></dl></dl></dl><dd><div class="Item"><a name="83509"> </a><b class="symbol_UC">OBJECT IDENTIFIER</b> <br></div><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent3"><a name="84026"> </a>A list of unsigned integers used to identify an object. This is one of ASN.1's fundamental data types.</><br></dl></dl></dl><dd><div class="Item"><a name="83510"> </a><b class="symbol_lc">Timeticks</b></div><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent3"><a name="84027"> </a>An unsigned integer expressing a time value in <sup>1</sup>/100's of a second, with a range from 0 to 2<sup>32</sup>-1.</><br></dl></dl></dl><dd><div class="Item"><a name="83511"> </a><b class="symbol_lc">Gauge</b></div><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent3"><a name="84030"> </a>An unsigned integer with a range from 0 to 2<sup>32</sup>-1, which pins at its maximum value rather than wrapping. Contrast with <b class="symbol_lc">Counter</b>.</><br></dl></dl></dl><dd><div class="Item"><a name="84032"> </a><b class="symbol_lc">Counter</b></div><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent3"><a name="84035"> </a>A monotonically-increasing unsigned integer with a range from 0 to 2<sup>32-</sup>1, which wraps to 0 when it reaches its maximum value rather than pinning. Contrast with <b class="symbol_lc">Gauge</b>.</><br></dl></dl></dl><dd><div class="Item"><a name="83515"> </a><b class="symbol_lc">NetworkAddress</b> <br></div><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent3"><a name="84036"> </a>An IP address represented as a protocol identifier (always 1 for IP) followed by four integers, based on <b class="symbol_UC">OCTET STRING</b>. This type has not proven to be particularly useful.</><br></dl></dl></dl><dd><div class="Item"><a name="83516"> </a><b class="symbol_lc">IpAddress</b> <br></div><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent3"><a name="84037"> </a>An IP address represented as four integers, based on <b class="symbol_UC">OCTET STRING</b>.</><br></dl></dl></dl><dd><div class="Item"><a name="83517"> </a><b class="symbol_UC">ACCESS</b> </div><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent3"><a name="84038"> </a>An object's <b class="symbol_lc">ACCESS</b> clause specifies the legal access modes for the object. This clause must be present for every object in a SNMPv1 MIB. It may take on the values <b class="symbol_lc">read-only</b>, <b class="symbol_lc">read-write</b>, or <b class="symbol_lc">not-accessible</b>.</><br></dl></dl></dl><dd><div class="Item"><a name="83518"> </a><b class="symbol_UC">STATUS</b> </div><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent3"><a name="84040"> </a>An object's <b class="symbol_UC">STATUS</b> clause indicates whether the object must be present for an implementation to conform to the MIB. This clause must be present for every object. Allowed values are: <b class="symbol_lc">mandatory</b>, <b class="symbol_lc">optional</b>, or <b class="symbol_lc">deprecated</b>.</><br></dl></dl></dl><dd><div class="Item"><a name="83519"> </a><b class="symbol_UC">DESCRIPTION <br></b></div><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent3"><a name="84042"> </a>An object's <b class="symbol_UC">DESCRIPTION</b> is a simple text string describing the object. The string must be enclosed in quotation marks ("<b class="symbol_lc">...</b>"). This clause should be present for every object, but is not required in the SNMPv1 SMI.</><br></dl></dl></dl><dd><div class="Item"><a name="84052"> </a><b class="symbol_UC">REFERENCE</b> <br></div><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent3"><a name="84053"> </a>An object's <b class="symbol_UC">REFERENCE</b> is a simple text string listing other documents that are useful references for this object. This clause should be present for every object, but is not required.</><br></dl></dl></dl><dd><div class="Item"><a name="83521"> </a><b class="symbol_UC">DEFVAL</b> </div><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent3"><a name="84046"> </a>An object may have a default value. This clause may be present for most objects, but is not required.</><br><dd><div class="Indent3"><a name="83522"> </a>You cannot assign a default value to a variable whose <b class="symbol_UC">SYNTAX</b> is of the type <b class="symbol_lc">Counter</b>.</><br><dd><div class="Indent3"><a name="83523"> </a><b class="command">mibcomp</b> does not make any use of the default value.</><br></dl>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -