📄 x-mibcompout.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title> <b class="command"></b> mibcomp Output Formats </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><img border="0" src="icons/blank.gif"><a href="x-mibcomp6.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="x-snmpErrors.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h1 class="H1num" align="right"><i><a name="83417">B</a></i></h1></font><font face="Helvetica, sans-serif" class="sans"><h1 class="H1name" align="right"><i><a name="83419"> mibcomp Output Formats</a></i></h1></font><dl class="margin"></dl><h4 class="Subtitle" align="right"><font face="Helvetica, sans-serif" size="-1" class="sans"><i></i></font></h4><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84412"> </a></p><dd><p class="Body"><a name="84418"> </a></p><dd><p class="Body"><a name="84419"> </a>The default output of <b class="command">mibcomp</b> is C code that declares the MIB tree to a WindNet SNMPv1/v2c-based SNMP agent. You can specify options on the command line to cause <b class="command">mibcomp</b> to generate different kinds of output based on the information in the MIB description file.</p><dd><p class="Body"><a name="83424"> </a>Following is a sample input file to <b class="command">mibcomp</b>, and the output generated by <b class="command">mibcomp</b> with each command-line argument.</p></dl><dl class="margin"><dd><pre class="Code"><b><a name="83425">-- This is the example control file that was used to generate the -- output examples in the mibcomp documentation. EXAMPLE-CONTROL-FILE -- Force the -mib.c output mode to generate an include statement -- for "example.h" FORCE-INCLUDE "example.h" -- Modify mibcomp's default for the view-mask. DEFAULT view-mask ((bits32_t) 0xFFFFFFFFL) -- Suppress stuff from the "security" and "snmpV2" branches of the -- built-in SMIs, to keep the output examples short. EXCLUDE security EXCLUDE snmpV2 DEFINITIONS ::= BEGIN IMPORTS enterprises FROM RFC1155-SMI OBJECT-TYPE FROM RFC-1212; examples OBJECT-TYPE DEFAULT get-function get_%n DEFAULT set-function set_%n DEFAULT test-function it_exists DEFAULT next-function std_next DEFAULT cookie (char *) &var_%n ::= { enterprises wrs(731) 8 } ex1 OBJECT-TYPE DEFAULT write-mask 0x1F ::= { examples 1 } ex2 OBJECT-TYPE DEFAULT view-mask 0xDEADBEEF ::= { examples 2 } ex2Obj2 OBJECT-TYPE DEFAULT cookie ((void *) 0) ::= { ex2 ex2Objs(1) 2 } END</a></b></pre></dl><dl class="margin"><dd><p class="Body"><a name="83426"> </a>Each of the following output-mode descriptions shows example output based on compiling the above sample input file.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="83428"><b class="command">-array</b> </a></i></h4></font><dl class="margin"><dl class="margin"><dd><pre class="Code"><b><a name="83429">mibcomp -array -o array.out example.mib</a></b></pre></dl><dl class="margin"><dd><p class="Body"><a name="83430"> </a>The <b class="command">-array</b> output mode generates a C-language output file, which can be used as both a header (<b class="file">.h</b>) file and a C source (<b class="file">.c</b>) file. The header file declares a C structure (called <b class="symbol_lc">oidtab</b>) that maps together an object name, its object-ID, the length of the object-ID, and the object type. It also declares an <b class="symbol_lc">extern</b> array of <b class="symbol_lc">oidtab</b> structures, named <b class="symbol_lc">oids</b>. Applications can search this table to translate object-IDs into human-readable names and vice-versa.</p><dd><p class="Body"><a name="83431"> </a>To use the file as an <b class="symbol_lc">#include</b> file, just use an ordinary C <b class="symbol_lc">#include</b> statement. To use it as a regular C source file, compile it with <b class="symbol_UC">C_CODE</b> defined as a constant. Most compilers allow a command-line argument <b class="symbol_UC">-DC_CODE</b> to do this, or you can write a two-line C file of the form:</p><dl class="margin"><dd><pre class="Code2"><b><a name="83432">#define C_CODE #include <i class="textVariable">file.h</i></a></b></pre></dl><dd><p class="Body"><a name="83433"> </a>The generated file includes a reference to the file <b class="file">ids.h</b>,which is assumed to have been created from the same input file(s) using the <b class="command">-man.h</b> option, which is described in <a href="x-mibcompOut.html#84031"><i class="title">-man.h</i></a>.</p></dl></dl><dl class="margin"><dd><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><a name="83437"><br></a><img border="0" alt="*" src="icons/note.gif"> </td><td><div class="Note"><hr><b class="symbol_UC">NOTE: </b>This is a fairly old, experimental format. No current Wind River Systems code uses the code produced by this output mode.<hr></div></td></tr></table><dl class="margin"><dd><p class="Body"><a name="83438"> </a>Here is an example of <b class="command">mibcomp</b> output when given the <b class="command">-array</b> option:</p></dl><dl class="margin"><dd><pre class="Code"><b><a name="83439">/************************************************************************ ************************************************************************* **** This file was automatically generated by Wind River Systems' **** mibcomp SNMP MIB Compiler. **** This file was generated using the -array switch. **** **** This file defines an array of oidtab structures that associate **** a MIB object's name, object identifier, object identifier length, **** and object type. It references the file "ids.h" which must be **** separately generated by the MIB compiler using the -man.h switch. **** **** This file can be used as either a C header (.h) file, or a C **** source (.c) file, depending on whether or not the macro C_CODE **** is defined when the file is compiled. **** **** DO NOT MODIFY THIS FILE BY HAND. **** **** Last build date: Fri May 26 22:06:20 1995 **** from files: **** example1.mib, example2.mib, examples.ctl ************************************************************************* ************************************************************************* */ #include <h/snmp/asn1.h> #include <h/snmp/snmp.h> #include <h/snmp/mib.h> #include "ids.h" /* Generated with -man.h */ struct oidtab { OIDC_T *oid; char *name; int len; int type; }; #define TYPE_INTEGER 0 #define TYPE_OBJECT_IDENTIFIER 1 #define TYPE_BIT_STRING 2 #define TYPE_OCTET_STRING 3 #define TYPE_ObjectName 4 #define TYPE_NetworkAddress 5 #define TYPE_IpAddress 6 #define TYPE_Counter 7 #define TYPE_Gauge 8 #define TYPE_TimeTicks 9 #define TYPE_Opaque 10 #define TYPE_ObjectName 11 #define TYPE_Integer32 12 #define TYPE_IpAddress 13 #define TYPE_Counter32 14 #define TYPE_Gauge32 15 #define TYPE_TimeTicks 16 #define TYPE_Opaque 17 #define TYPE_NsapAddress 18 #define TYPE_Counter64 19 #define TYPE_UInteger32 20 #define TYPE_Unsigned32 21 #define TYPE_DisplayString 22 #define TYPE_PhysAddress 23 #define TYPE_MacAddress 24 #define TYPE_TruthValue 25 #define TYPE_TestAndIncr 26 #define TYPE_AutonomousType 27 #define TYPE_InstancePointer 28 #define TYPE_VariablePointer 29 #define TYPE_RowPointer 30 #define TYPE_RowStatus 31 #define TYPE_TimeStamp 32 #define TYPE_TimeInterval 33 #define TYPE_DateAndTime 34 #define TYPE_SnmpUDPAddress 35 #define TYPE_SnmpOSIAddress 36 #define TYPE_SnmpNBPAddress 37 #define TYPE_SnmpIPXAddress 38 #define TYPE_ExampleType 39 #define TYPE_ExampleType 40 #ifdef C_CODE struct oidtab oids[] = { { ID_ex1Obj1, "ex1Obj1", 11, TYPE_ExampleType }, { ID_ex1Obj2, "ex1Obj2", 11, TYPE_OCTET_STRING }, { ID_ex2Obj1, "ex2Obj1", 11, TYPE_ExampleType }, { ID_ex2Obj2, "ex2Obj2", 11, TYPE_OCTET_STRING }, { 0, 0, 0, 0 } }; #else extern struct oidtab oids[]; #endif</a></b></pre></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="83441"><b class="command">-leaf</b> </a></i></h4></font><dl class="margin"><dl class="margin"><dd><pre class="Code"><b><a name="83442">mibcomp -leaf -o leaf.out example.mib</a></b></pre></dl><dl class="margin"><dd><p class="Body"><a name="83443"> </a>The <b class="command">-leaf</b> output mode generates a C header file that <b class="symbol_lc">#define</b>s constants specifying the last component of every object's <b class="symbol_UC">OID</b>, any enumerated values associated with the object's <b class="symbol_UC">SYNTAX</b>, and any known bounds on the object's value.</p><dd><p class="Body"><a name="83444"> </a>You will probably find this output mode to be most useful when writing method routines for a large MIB. The constants defining the last component of the <b class="symbol_UC">OID</b> provide symbolic names that you can use with the <b class="symbol_lc">last_match</b> parameter to a method routine, and the other constants are useful when checking bounds or writing <b class="routine"><i class="routine">switch</i></b><b>( )</b> statements for enumerated integers.</p><dd><p class="Body"><a name="83445"> </a>Here is an example of <b class="command">mibcomp</b> output when given the <b class="command">-leaf</b> option:</p></dl><dl class="margin"><dd><pre class="Code"><b><a name="83446">/************************************************************************ ************************************************************************* **** This file was automatically generated by Wind River Systems' **** mibcomp SNMP MIB Compiler. **** This file was generated using the -leaf switch. **** **** This file #defines C preprocessor macros providing a variety of **** information for the leaf objects in the MIB. **** **** The file includes a LEAF_xxx macro for each leaf object in the **** MIB (xxx is replaced by the object's name). The value of the **** LEAF_xxx macro is the final component of the object's object **** identifier. **** **** If the object's SYNTAX clause included named INTEGER values, **** then there is a VAL_xxx_yyy macro for each named value (xxx is **** replaced by the object's name and yyy by the value's name). The
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -