B

mibcomp Output Formats

The default output of mibcomp 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 mibcomp to generate different kinds of output based on the information in the MIB description file.

Following is a sample input file to mibcomp, and the output generated by mibcomp with each command-line argument.

-- 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

Each of the following output-mode descriptions shows example output based on compiling the above sample input file.

-array

mibcomp -array -o array.out example.mib

The -array output mode generates a C-language output file, which can be used as both a header (.h) file and a C source (.c) file. The header file declares a C structure (called oidtab) that maps together an object name, its object-ID, the length of the object-ID, and the object type. It also declares an extern array of oidtab structures, named oids. Applications can search this table to translate object-IDs into human-readable names and vice-versa.

To use the file as an #include file, just use an ordinary C #include statement. To use it as a regular C source file, compile it with C_CODE defined as a constant. Most compilers allow a command-line argument -DC_CODE to do this, or you can write a two-line C file of the form:

#define            C_CODE 
#include            file.h

The generated file includes a reference to the file ids.h,which is assumed to have been created from the same input file(s) using the -man.h option, which is described in -man.h.


*   

NOTE: This is a fairly old, experimental format. No current Wind River Systems code uses the code produced by this output mode.

Here is an example of mibcomp output when given the -array option:

/************************************************************************ 
************************************************************************* 
**** 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

-leaf

mibcomp -leaf -o leaf.out example.mib

The -leaf output mode generates a C header file that #defines constants specifying the last component of every object's OID, any enumerated values associated with the object's SYNTAX, and any known bounds on the object's value.

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 OID provide symbolic names that you can use with the last_match parameter to a method routine, and the other constants are useful when checking bounds or writing switch( ) statements for enumerated integers.

Here is an example of mibcomp output when given the -leaf option:

/************************************************************************ 
************************************************************************* 
**** 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 
**** value of the VAL_xxx_yyy macro is the value associated with the 
**** named value. 
**** 
**** If the object's SYNTAX clause specified a set of range limitations 
**** for the value of the object, then there are one or more sets of 
**** MIN_xxx and MAX_xxx macros specifying the lower and upper bound of 
**** each range limitation. 
**** 
**** If the object's SYNTAX clause specified a set of size constraints 
**** for the value of the object, then there are one or more sets of 
**** MINSIZE_xxx and MAXSIZE_xxx macros specifying the lower and upper 
**** bound of each size constraint. (If the size constraint is a single 
**** value rather than a range then the MINSIZE_xxx and MAXSIZE_xxx 
**** macros are replaced by a single SIZE_xxx macro.) 
**** 
**** DO NOT MODIFY THIS FILE BY HAND. 
**** 
**** Last build date: Fri May 26 22:06:21 1995 
**** from files: 
**** example1.mib, example2.mib, examples.ctl 
************************************************************************* 
************************************************************************* 
*/ 
 
#define LEAF_ex1Obj1                        1 
#define VAL_ex1Obj1_one                            1L 
#define VAL_ex1Obj1_two                            2L 
#define LEAF_ex1Obj2                            2 
#define LEAF_ex2Obj1                            1 
#define VAL_ex2Obj1_one                            1L 
#define VAL_ex2Obj1_two                            2L 
#define LEAF_ex2Obj2                            2

-loadtree

mibcomp -loadtree -o loadtree.out example.mib

The -loadtree output mode generates a binary output file that a manager can use to look up object identifiers by name. This is essentially the same information that mibcomp generates in the -nametree, -numbers, and -readtree output modes. The only real difference is that this version is intended to be loaded at run-time by a manager that understands the binary format.

At present, Wind River Systems provides no tools that use this output format.

Please also see the descriptions of the output modes -readtree (-readtree) and -nametree (-nametree).

-man

mibcomp -man -o man.out example.mib

The -man output mode generates a file of C code which declares two C variables per MIB variable. The first C variable is an array of OIDC_T, and is initialized to the object identifier ofthe MIB variable. If the MIB variable is named fooBar, this first C variable is named ID_fooBar. The second C variable is an integer, initialized to the length of the object identifier. If theMIB variable is named fooBar, this second C variable is named len_fooBar.

The array which stores the object ID has extra space for an instance identifier. In most cases mibcomp can determine the maximum size ofthe instance identifier from the MIB, but there are two cases where the instance length is unbounded and this is not possible:

  1. For an index that includes an OBJECT IDENTIFIER, mibcomp allocates 23 OID components for the instance.

  1. For an index that includes an OCTET STRING without a size constraint, mibcomp allocates 65 OID components for the instance.

You can change these settings by using the -inst_oid_len and -inst_str_len options (see A. The MIB Compiler User's Guide). In both of these cases, mibcomp writes a warning comment into the -man output to remind you that the instance-length it used did not come from the MIB and thus may be incorrect.

The value of the length variable (len_fooBar) does not include the extra space for the instance identifier.

This is a fairly old, experimental format, intended for possible use by a manager application (hence the name man). None of Wind River Systems' current code uses the code produced by this output mode.

Here is an example of mibcomp output when given the -man option:

/************************************************************************ 
************************************************************************* 
**** This file was automatically generated by Wind River Systems' 
**** mibcomp SNMP MIB Compiler. 
**** This file was generated using the -man switch. 
**** 
**** This file contains C data structures representing ASN.1 object IDs. 
**** The -man.h switch generates a corresponding header file declaring 
**** these data structures for use in your program. 
**** 
**** DO NOT MODIFY THIS FILE BY HAND. 
**** 
**** Last build date: Fri May 26 22:06:21 1995 
**** from files: 
**** example1.mib, example2.mib, examples.ctl 
************************************************************************* 
************************************************************************* 
*/ 
#include <h/snmp/asn1.h> 
 
OIDC_T ID_ex1Obj1[] = { 1, 3, 6, 1, 4, 1, 731, 8, 1, 1, 1, 0 }; 
unsigned int len_ex1Obj1 = 11; 
 
OIDC_T ID_ex1Obj2[] = { 1, 3, 6, 1, 4, 1, 731, 8, 1, 1, 2, 0 }; 
unsigned int len_ex1Obj2 = 11; 
 
OIDC_T ID_ex2Obj1[] = { 1, 3, 6, 1, 4, 1, 731, 8, 2, 1, 1, 0 }; 
unsigned int len_ex2Obj1 = 11; 
 
OIDC_T ID_ex2Obj2[] = { 1, 3, 6, 1, 4, 1, 731, 8, 2, 1, 2, 0 }; 
unsigned int len_ex2Obj2 = 11;

-man.h

mibcomp -man.h -o manh.out example.mib

The -man.h output mode generates a C language header file corresponding to the C file generated by the -man option, as described in -man. This header file has extern declarations for each variable in the file produced by -man.

This header file is also used by the file that mibcomp generates whengiven the -array switch. For details, see -array.

Here is an example of mibcomp output when given the -man.h option:

/************************************************************************ 
************************************************************************* 
**** This file was automatically generated by Wind River Systems' 
**** mibcomp SNMP MIB Compiler. 
**** This file was generated using the -man.h switch. 
**** 
**** This file contains declarations for C data structures containing 
**** representations of ASN.1 object identifiers. Running mibcomp 
**** with the -man switch will produce the corresponding C file. 
**** 
**** DO NOT MODIFY THIS FILE BY HAND. 
**** 
**** Last build date: Fri May 26 22:06:22 1995 
**** from files: 
**** example1.mib, example2.mib, examples.ctl 
************************************************************************* 
************************************************************************* 
*/ 
 
#include <h/snmp/asn1.h> 
 
extern OIDC_T ID_ex1Obj1[]; 
extern unsigned int len_ex1Obj1; 
 
extern OIDC_T ID_ex1Obj2[]; 
extern unsigned int len_ex1Obj2; 
 
extern OIDC_T ID_ex2Obj1[]; 
extern unsigned int len_ex2Obj1; 
 
extern OIDC_T ID_ex2Obj2[]; 
extern unsigned int len_ex2Obj2;

-mib.c

mibcomp -mib.c -o mibc.out example.mib
or

mibcomp -o mibc.out example.mib

The -mib.c output mode generates a file of C code which defines the MIB tree for a WindNet SNMPv1/v2c-based SNMP agent. This is the default mibcomp output mode.

Each accessible object in the MIB tree must have several method routines associated with it. These associations are set with the DEFAULT keyword in MIB specifications. For more information, see The DEFAULT Keyword.

Here is an example of mibcomp output when given the -mib.c option:

/************************************************************************ 
************************************************************************* 
**** This file was automatically generated by Wind River Systems' 
**** mibcomp SNMP MIB Compiler. 
**** This file was generated using the -mib.c switch. 
**** 
**** This file contains a representation of a MIB tree suitable 
**** for use by a WindNet SNMPv1 agent. 
**** 
**** DO NOT EDIT THIS FILE BY HAND. 
**** 
**** Last build date: Fri May 26 22:06:22 1995 
**** from files: 
**** example1.mib, example2.mib, examples.ctl 
************************************************************************* 
************************************************************************* 
*/ 
 
#define _MIB 1 
#include "example.h" 
#ifndef STATIC 
#define STATIC static 
#endif 
 
STATIC 
MIBARC_T            directory_arcs[] = { 
                    END_OF_ARC_LIST }; 
 
STATIC 
MIBNODE_T            directory_node = NODE("directory", 
                    directory_arcs); 
 
STATIC 
MIBARC_T            mgmt_arcs[] = { 
                    END_OF_ARC_LIST }; 
 
STATIC 
MIBNODE_T            mgmt_node = NODE("mgmt", 
                    mgmt_arcs); 
 
STATIC 
MIBARC_T            experimental_arcs[] = { 
                    END_OF_ARC_LIST }; 
 
STATIC 
MIBNODE_T            experimental_node = NODE("experimental", 
                    experimental_arcs); 
 
LEAF_COMS(        ex1Obj1_leaf, ex1Obj1_leaf_crs, "ex1Obj1",VT_NUMBER, 
                    RW, SCALAR, it_exists, 
                    get_ex1Obj1, set_ex1Obj1, std_next, 
                    (char *) &var_ex1Obj1, 
                    0x0000, ((bits32_t) 0xFFFFFFFFL), 0x1F); 
 
LEAF_COMS(        ex1Obj2_leaf, ex1Obj2_leaf_crs, "ex1Obj2", VT_STRING, 
                    RO, SCALAR, it_exists, 
                    get_ex1Obj2, null_set_proc, std_next, 
                    (char *) &var_ex1Obj2, 
                    0x0000, ((bits32_t) 0xFFFFFFFFL), 0x1F); 
 
STATIC 
MIBARC_T            ex1Objs_arcs[] = { 
                    ARC(1, ex1Obj1_leaf), 
                    ARC(2, ex1Obj2_leaf), 
                    END_OF_ARC_LIST }; 
 
STATIC 
MIBNODE_T            ex1Objs_node = NODE("ex1Objs", 
                    ex1Objs_arcs); 
 
STATIC 
MIBARC_T            ex1_arcs[] = { 
                    ARC(1, ex1Objs_node), 
                    END_OF_ARC_LIST }; 
 
STATIC 
MIBNODE_T            ex1_node = NODE("ex1", 
                    ex1_arcs); 
 
LEAF_COMS(        ex2Obj1_leaf, ex2Obj1_leaf_crs, "ex2Obj1", VT_NUMBER, 
                    RW, SCALAR, it_exists, 
                    get_ex2Obj1, set_ex2Obj1, std_next, 
                    (char *) &var_ex2Obj1, 
                    0x0000, 0xDEADBEEF, 0xFF); 
 
LEAF_COMS(        ex2Obj2_leaf, ex2Obj2_leaf_crs, "ex2Obj2", VT_STRING, 
                    RO, SCALAR, it_exists, 
                    get_ex2Obj2, null_set_proc, std_next, 
                    ((void *) 0), 
                    0x0000, 0xDEADBEEF, 0xFF); 
 
STATIC 
MIBARC_T            ex2Objs_arcs[] = { 
                    ARC(1, ex2Obj1_leaf), 
                    ARC(2, ex2Obj2_leaf), 
                    END_OF_ARC_LIST }; 
 
STATIC 
MIBNODE_T            ex2Objs_node = NODE("ex2Objs", 
                    ex2Objs_arcs); 
 
STATIC 
MIBARC_T            ex2Trap_arcs[] = { 
                    END_OF_ARC_LIST ; 
 
STATIC 
MIBNODE_T            ex2Trap_node = NODE("ex2Trap", 
                    ex2Trap_arcs); 
 
 
STATIC 
MIBARC_T            ex2Traps_arcs[] = { 
                    ARC(1, ex2Trap_node), 
                    END_OF_ARC_LIST ; 
 
STATIC 
MIBNODE_T            ex2Traps_node = NODE("ex2Traps", 
                    ex2Traps_arcs); 
 
STATIC 
MIBARC_T            ex2_arcs[] = { 
                    ARC(1, ex2Objs_node), 
                    ARC(2, ex2Traps_node), 
                    END_OF_ARC_LIST }; 
 
STATIC 
MIBNODE_T            ex2_node = NODE("ex2", 
                    ex2_arcs); 
 
STATIC 
MIBARC_T            examples_arcs[] = { 
                    ARC(1, ex1_node), 
                    ARC(2, ex2_node), 
                    END_OF_ARC_LIST }; 
 
STATIC 
MIBNODE_T            examples_node = NODE("examples", 
                    examples_arcs); 
 
STATIC 
MIBARC_T            wrs_arcs[] = { 
                    ARC(8, examples_node), 
                    END_OF_ARC_LIST }; 
 
STATIC 
MIBNODE_T            wrs_node = NODE("wrs", 
                    wrs_arcs); 
 
STATIC 
MIBARC_T            enterprises_arcs[] = { 
                    ARC(731, wrs_node), 
END_OF_ARC_LIST ; 
 
STATIC 
MIBNODE_T            enterprises_node = NODE("enterprises", 
                    enterprises_arcs); 
 
STATIC 
MIBARC_T            private_arcs[] = { 
                    ARC(1, enterprises_node), 
                    END_OF_ARC_LIST }; 
 
STATIC 
MIBNODE_T            private_node = NODE("private", 
                    private_arcs); 
 
STATIC 
MIBARC_T            internet_arcs[] = { 
                    ARC(1, directory_node), 
                    ARC(2, mgmt_node), 
                    ARC(3, experimental_node), 
                    ARC(4, private_node), 
                    END_OF_ARC_LIST }; 
 
STATIC 
MIBNODE_T            internet_node = NODE("internet", 
                    internet_arcs); 
 
STATIC 
MIBARC_T            dod_arcs[] = { 
                    ARC(1, internet_node), 
                    END_OF_ARC_LIST }; 
 
STATIC 
MIBNODE_T            dod_node = NODE("dod", 
                    dod_arcs); 
 
STATIC 
MIBARC_T            org_arcs[] = { 
                    ARC(6, dod_node), 
                    END_OF_ARC_LIST } 
 
STATIC 
MIBNODE_T            org_node = NODE("org", 
                    org_arcs); 
 
STATIC 
MIBARC_T            iso_arcs[] = { 
                    ARC(3, org_node), 
                    END_OF_ARC_LIST }; 
 
STATIC 
MIBNODE_T            iso_node = NODE("iso", 
                    iso_arcs); 
 
STATIC 
MIBARC_T            mib_root_arcs[] = { 
                    ARC(1, iso_node), 
                    END_OF_ARC_LIST }; 
 
MIBNODE_T            mib_root_node = NODE("mib_root", 
                    mib_root_arcs);

-nametree

mibcomp -nametree -o nametree.out example.mib

The -nametree output mode generates C code that defines an array of C structures that an SNMP manager can use to look up object identifiers by name. This is essentially the same information that mibcomp generates in the -loadtree, -numbers, and -readtree output modes. The only real difference is that this output format version is intended to be compiled into a manager.

This is a fairly old, experimental format, intended for possible use by a manager application. None of Wind River Systems' current code uses the code produced by this output mode.

Please also see the descriptions of the output modes -loadtree (-loadtree) and -readtree (-readtree).

Here is an example of mibcomp output when given the -nametree option:

/************************************************************************ 
************************************************************************* 
**** This file was automatically generated by Wind River Systems' 
**** mibcomp SNMP MIB Compiler. 
**** This file was generated using the -nametree switch. 
**** 
**** This file contains a MIB tree for use by managers programs to 
**** translate from object IDs to names and back. 
**** 
**** DO NOT MODIFY THIS FILE BY HAND. 
**** 
**** Last build date: Fri May 26 22:06:22 1995 
**** from files: 
**** example1.mib, example2.mib, examples.ctl ****************************************************************************** 
****************************************************************************** 
*/ 
 
struct                 nametree { 
unsigned long                 number; 
struct nametree                 *parent; 
struct nametree                 *sibling; 
struct nametree                *children; 
char                *name; 
unsigned char                type; 
}; 
 
extern struct nametree mibt[]; 
extern int mibt_entries; 
 
#if defined(C_CODE) 
struct nametree mibt[] = { 
/* asn # parent    siblings   children    name                 type */ 
/* 0 */ 
{    1,             0,             0,    &mibt[  1],    "iso",                                            0 }, 
{    3,    &mibt[  0],             0,    &mibt[  2],    "org",                                            0 }, 
{    6,    &mibt[  1],             0,    &mibt[  3],    "dod",                                            0 }, 
{    1,    &mibt[  2],             0,    &mibt[  4],    "internet",                                            0 }, 
{    1,    &mibt[  3],    &mibt[  5],             0,    "directory",                                            0 }, 
{    2,    &mibt[  3],    &mibt[  6],             0,    "mgmt",                                            0 }, 
{    3,    &mibt[  3],    &mibt[  7],             0,    "experimental",                                            0 }, 
{    4,    &mibt[  3],             0,    &mibt[  8],    "private",                                            0 }, 
{    1,    &mibt[  7],             0,    &mibt[  9],    "enterprises",                                            0 }, 
{    731,    &mibt[  8],             0,    &mibt[ 10],    "wrs",                                            0 }, 
/* 10 */ 
{    8,    &mibt[  9],             0,    &mibt[ 11],    "examples",                                            0 }, 
{    1,    &mibt[ 10],    &mibt[ 17],    &mibt[ 12],    "ex1",                                            0 }, 
{    1,    &mibt[ 11],             0,    &mibt[ 13],    "ex1Objs",                                            0 }, 
{    1,    &mibt[ 12],    &mibt[ 16],    &mibt[ 14],    "ex1Obj1",                                    VT_NUMBER }, 
{    1,    &mibt[ 13],    &mibt[ 15],             0,    "one",                                            0 }, 
{    2,    &mibt[ 14],             0,             0,    "two",                                            0 }, 
{    2,    &mibt[ 12],             0,             0,    "ex1Obj2",                                    VT_STRING }, 
{    2,    &mibt[ 10],             0,    &mibt[ 18],    "ex2",                                            0 }, 
{    1,    &mibt[ 17],    &mibt[ 23],    &mibt[ 19],    "ex2Objs",                                            0 }, 
{    1,    &mibt[ 18],    &mibt[ 22],    &mibt[ 20],    "ex2Obj1",                                    VT_NUMBER }, 
/* 20 */ 
{    1,    &mibt[ 19],    &mibt[ 21],             0,    "one",                                            0 }, 
{    2,    &mibt[ 20],             0,             0,    "two",                                            0 }, 
{    2,    &mibt[ 18],             0,             0,    "ex2Obj2",                                    VT_STRING }, 
{    2,    &mibt[ 17],             0,    &mibt[ 24],    "ex2Traps",                                            0 }, 
{    1,    &mibt[ 23],             0,             0,    "ex2Trap",                                            0 }, 
}; 
 
int mibt_entries = sizeof(mibt)/sizeof(struct nametree); 
 
#endif /* CODE */

-numbers

mibcomp -numbers -o numbers.out example.mib

The -numbers option generates a listing of every node in the MIB tree, along with each node's object identifier OBJECT IDENTIFIER and, if the node is a leaf, the SYNTAX of theMIB object that occupies this leaf. The -numbers output is intended as a reference and as an aid in debugging; it is not intended for use as input to another program.

If you are looking for a machine-parsable representation of a MIB, please see the descriptions of the -readtree, -loadtree, and -nametree output modes, in -readtree,-loadtree, and -nametree, respectively.

Here is an example of mibcomp output when given the -numbers option:

; This file was automatically generated by Wind River Systems' 
; mibcomp SNMP MIB Compiler. 
; Listing of MIB nodes and leaves generated using the -numbers switch. 
; 
; Last build date: Fri May 26 22:06:22 1995; from files: 
; example1.mib, example2.mib, examples.ctl 
1                        iso                NODE 
1.3                        org                NODE 
1.3.6                        dod                NODE 
1.3.6.1                        internet                NODE 
1.3.6.1.1                        directory                NODE 
1.3.6.1.2                        mgmt                NODE 
1.3.6.1.3                        experimental                NODE 
1.3.6.1.4                        private                NODE 
1.3.6.1.4.1                        enterprises                NODE 
1.3.6.1.4.1.731                        wrs                NODE 
1.3.6.1.4.1.731.8                        examples                NODE 
1.3.6.1.4.1.731.8.1                        ex1                NODE 
1.3.6.1.4.1.731.8.1.1                        ex1Objs                NODE 
1.3.6.1.4.1.731.8.1.1.1                        ex1Obj1                LEAF        ExampleType 
1.3.6.1.4.1.731.8.1.1.2                        ex1Obj2                LEAF        OCTET STRING 
1.3.6.1.4.1.731.8.2                        ex2                NODE 
1.3.6.1.4.1.731.8.2.1                        ex2Objs                NODE 
1.3.6.1.4.1.731.8.2.1.1                        ex2Obj1                LEAF        ExampleType 
1.3.6.1.4.1.731.8.2.1.2                        ex2Obj2                LEAF        OCTET STRING 
1.3.6.1.4.1.731.8.2.2                        ex2Traps                NODE 
1.3.6.1.4.1.731.8.2.2.1                        ex2Trap                NODE

-partial

mibcomp -partial -o partial.out example.mib

The -partial output mode generates a new skeletal MIB file,suitable for compilation by mibcomp. The new file consists of OBJECT-TYPE macros for every object in the MIB, even ones thatare not accessible. This file is meant to be used as the basis of a control file with FORCE-INCLUDE, EXCLUDE and DEFAULT keywords in it to control the implementation of the MIB.

An alternate version of this mode, -partialm, is described in -partialm.

Here is an example of mibcomp output when given the -partial option:

-- This file was automatically generated by Wind River Systems' 
-- mibcomp SNMP MIB Compiler. 
-- This file was generated using the -partial switch. 
-- 
-- YOU MAY MODIFY THIS FILE BUT BEWARE ACCIDENTALLY OVERWRITING IT 
-- BY REGENERATING IT WITH THE MIB COMPILER. 
-- 
-- Last build date: Fri May 26 22:06:22 1995 
-- from files: 
-- example1.mib, example2.mib, examples.ctl 
 
partial-out-A 
 
-- put your FORCE-INCLUDE's here 
-- 
-- put your global DEFAULT's here 
-- 
-- put your EXCLUDE's here 
-- 
 
DEFINITIONS ::= BEGIN 
 
IMPORTS 
        OBJECT-TYPE 
                FROM SNMPv2-SMI; 
 
-- Below is an OBJECT-TYPE entry for every object in the input MIBs. 
-- You may position DEFAULT statements at any point in the MIB tree 
-- by putting them inside the appropriate OBJECT-TYPE declaration. 
-- You need not modify any to which you don't want to add DEFAULTs. 
-- (Or, you may remove any OBJECT-TYPE declaration to which you 
-- don't add DEFAULT statements, as long as you don't add DEFAULT 
-- statements to any of its descendants that reference its 
-- descriptor, directly or indirectly.) 
 
org OBJECT-TYPE 
        ::= { iso 3 } 
 
dod OBJECT-TYPE 
         { org 6 } 
 
internet OBJECT-TYPE 
         { dod 1 } 
 
directory OBJECT-TYPE 
         { internet 1 } 
 
mgmt OBJECT-TYPE 
         { internet 2 } 
 
experimental OBJECT-TYPE 
         { internet 3 } 
 
private OBJECT-TYPE 
         { internet 4 } 
 
enterprises OBJECT-TYPE 
         { private 1 } 
 
wrs OBJECT-TYPE 
         { enterprises 731 } 
 
examples OBJECT-TYPE 
         { wrs 3 } 
 
ex1 OBJECT-TYPE 
         { examples 1 } 
 
ex1Objs OBJECT-TYPE 
         { ex1 1 } 
 
ex1Obj1 OBJECT-TYPE 
         { ex1Objs 1 } 
 
ex1Obj2 OBJECT-TYPE 
         { ex1Objs 2 } 
 
ex2 OBJECT-TYPE 
         { examples 2 } 
 
ex2Objs OBJECT-TYPE 
         { ex2 1 } 
 
ex2Obj1 OBJECT-TYPE 
         { ex2Objs 1 } 
 
ex2Obj2 OBJECT-TYPE 
         { ex2Objs 2 } 
 
ex2Traps OBJECT-TYPE 
         { ex2 2 } 
 
ex2Trap OBJECT-TYPE 
         { ex2Traps 1 } 
 
END

-partialm

mibcomp -partialm EXAMPLE-SNMPv1-MIB -o partialm.out example.mib

The -partialm output mode generates a new skeletal MIB file,suitable for compilation by mibcomp. The new file consists of empty OBJECT-TYPE macros for every object in the specified MIB module (EXAMPLE-MIB in this example). This file is meant to be used as the basis of a control file with FORCE-INCLUDE, EXCLUDE and DEFAULT keywords in it to control the implementation of the MIB (see A.4.2 mibcomp Extensions).

If any DEFAULT statements are present in the input files and apply to the specified MIB module, they are included in the -partialm output.

An alternate version of this output mode, -partial, is described in -partial.

Here is an example of mibcomp output when given the -partialm option:

-- This file was automatically generated by Wind River Systems' 
-- mibcomp SNMP MIB Compiler. 
-- This file was generated using the -partialm switch. 
-- 
-- YOU MAY MODIFY THIS FILE BUT BEWARE ACCIDENTALLY OVERWRITING IT 
-- BY REGENERATING IT WITH THE MIB COMPILER. 
-- 
-- Last build date: Fri May 26 22:06:23 1995 
-- from files: 
-- example1.mib, example2.mib, examples.ctl 
 
EXAMPLE-SNMPv2-MIB-A 
 
-- put your FORCE-INCLUDE's here 
- 
-- put your global DEFAULT's here 
-- 
-- put your EXCLUDE's here 
-- 
 
DEFINITIONS ::= BEGIN 
 
IMPORTS 
        enterprises, OBJECT-TYPE 
                FROM SNMPv2-SMI; 
 
-- Below is an OBJECT-TYPE entry for every object in the 
-- EXAMPLE-SNMPv2-MIB MIB module. 
-- You may position DEFAULT statements at any point in the MIB tree 
-- by putting them inside the appropriate OBJECT-TYPE declaration. 
-- You need not modify any to which you don't want to add DEFAULTs. 
-- (Or, you may remove any OBJECT-TYPE declaration to which you 
-- don't add DEFAULT statements, as long as you don't add DEFAULT 
-- statements to any of its descendants that reference its 
-- descriptor, directly or indirectly.) 
 
wrs OBJECT-TYPE  
        ::= { enterprises 731 } 
 
examples OBJECT-TYPE 
        DEFAULT test-function it_exists 
        DEFAULT get-function get_%n 
        DEFAULT set-function set_%n 
        DEFAULT next-function std_next 
        DEFAULT cookie (char *) &var_%n 
        ::= { wrs 8 } 
 
ex2 OBJECT-TYPE 
        DEFAULT view-mask 0xDEADBEEF 
        ::= { examples 2 } 
 
ex2Objs OBJECT-TYPE 
        ::= { ex2 1 } 
 
ex2Obj1 OBJECT-TYPE 
        ::= { ex2Objs 1 } 
 
ex2Obj2 OBJECT-TYPE 
        DEFAULT cookie ((void *) 0) 
        ::= { ex2Objs 2 } 
 
ex2Traps OBJECT-TYPE 
        ::= { ex2 2 } 
 
ex2Trap OBJECT-TYPE 
        ::= { ex2Traps 1 } 
 
END

-readtree

mibcomp -readtree -o readtree.out example.mib

The -readtree output mode generates an ASCII text file that a manager can load at run-time to look up object identifiers by name.This is essentially the same information that mibcomp generates inthe -loadtree, -nametree, and -numbers output modes. The only real difference is that this version is intended to be loaded at run-time by a manager that understands the text format.

The -readtree output contains four kinds of lines:

  1. Comment lines, which begin with a semicolon character(;).

  1. MIB object lines, which consist of the $obj token, the object's OID, the name of the object, and a token indicating the object's data type (unknown or useless types are represented by "0").

  1. Enumeration lines for enumerated integers, which consist of the $enum token, the object's OID, and the name and value of the enumerated value in the standard MIB format.

  1. Index lines for conceptual row objects, which consist of the $indx token, the OID of the conceptual row object, and the OID of the object that is an index for the conceptual row; these lines are only present if you installed the MIBCOMP_READTREE_INDX option when you built mibcomp.

All fields are separated by horizontal whitespace (one or more SPACE or TAB characters).

This format is intended to be simple enough that it can be parsed by ageneral purpose text processor such as the UNIX awk utility.

If you're looking for a human-readable ASCII text representation of a MIB, please see the -numbers output mode described in -numbers. For a binary representation of the same information, see the descriptions of the output modes -loadtree (-loadtree) and -nametree (-nametree).

Here is an example of mibcomp output when given the -readtree option:

; This file was automatically generated by Wind River Systems' 
; mibcomp SNMP MIB Compiler. 
; This MIB schema file was generated using the -readtree switch. 
; 
; This file contains a listing of object identifiers and 
; enumerated integers suitable for loading into an SNMP manager 
; at run-time. 
; 
; DO NOT MODIFY THIS FILE BY HAND. 
; 
; Last build date: Fri May 26 22:06:23 1995; from files: 
; example1.mib, example2.mib, examples.ctl 
$obj 1                             iso            0 
$obj 1.3                             org             0 
$obj 1.3.6                             dod             0 
$obj 1.3.6.1                             internet             0 
$obj 1.3.6.1.1                             directory             0 
$obj 1.3.6.1.2                             mgmt             0 
$obj 1.3.6.1.3                             experimental            0 
$obj 1.3.6.1.4                             private             0 
$obj 1.3.6.1.4.1                             enterprises            0 
$obj 1.3.6.1.4.1.731                            wrs            0 
$obj 1.3.6.1.4.1.731.8                             examples             0 
$obj 1.3.6.1.4.1.731.8.1                             ex1             0 
$obj 1.3.6.1.4.1.731.8.1.1                             ex1Objs             0 
$obj 1.3.6.1.4.1.731.8.1.1.1                             ex1Obj1             VT_NUMBER  
        $enum 1.3.6.1.4.1.731.8.1.1.1    one(1)  
        $enum 1.3.6.1.4.1.731.8.1.1.1    two(2) 
$obj 1.3.6.1.4.1.731.8.1.1.2                             ex1Obj2             VT_STRING 
$obj 1.3.6.1.4.1.731.8.2                             ex2             0 
$obj 1.3.6.1.4.1.731.8.2.1                             ex2Objs             0 
$obj 1.3.6.1.4.1.731.8.2.1.1                             ex2Obj1             VT_NUMBER  
        $enum 1.3.6.1.4.1.731.8.2.1.1                             one(1)  
        $enum 1.3.6.1.4.1.731.8.2.1.1                             two(2) 
$obj 1.3.6.1.4.1.731.8.2.1.2                             ex2Obj2             VT_STRING 
$obj 1.3.6.1.4.1.731.8.2.2                             ex2Traps             0 
$obj 1.3.6.1.4.1.731.8.2.2.1                             ex2Trap             0

-skel

mibcomp -skel -o skel.out example.mib

The -skel output mode generates C code containing empty definitions for all the method routines that would be referenced in the output generated by a run of mibcomp with the -mib.c option and the same input files. Such skeleton functions may be useful as a starting point when writing your method routines.

If you use this output mode, you will probably want to use the -skel.h output mode as well, as described in -skel.h.

Since the -skel output format, unlike most mibcomp output formats, is intended for use as a starting point for code that you write, you almost certainly do not want to run mibcomp in this output mode very often. When you do run mibcomp in this output mode, be careful to make sure you do not accidently overwrite a modified version of the output from a previous run.

Here is an example of mibcomp output when given the -skel option:

/************************************************************************ 
************************************************************************* 
**** This file was automatically generated by Wind River Systems' 
**** mibcomp SNMP MIB Compiler. 
**** This file was generated using the -skel switch. 
**** 
**** This file contains stub function declarations to aid in building 
**** the agent MIB interface. It defines all the MIB get, set, test and 
**** next method routines that you will need to supply. 
**** Filling in the skeletal function with useful code is up to you. 
**** 
**** YOU MAY MODIFY THIS FILE BUT BEWARE ACCIDENTALLY OVERWRITING IT 
**** BY REGENERATING IT WITH THE MIB COMPILER. 
**** 
**** Last build date: Fri May 26 22:06:23 1995 
**** from files: 
**** example1.mib, example2.mib, examples.ctl ************************************************************************* 
************************************************************************* 
*/ 
 
#include "example.h" 
 
INT_32_T get_ex1Obj1( 
        OIDC_T                lastmatch, 
        int                compc, 
        OIDC_T*                compl, 
        char*                cookie, 
        SNMP_PKT_T*                pktp) 
{ 
} 
 
void set_ex1Obj1( 
        OIDC_T                lastmatch, 
        int                compc, 
        OIDC_T*                compl, 
        char*                cookie, 
        INT_32_T                value, 
        SNMP_PKT_T*                pktp, 
        int                indx) 
{ 
} 
 
OCTET_T* get_ex1Obj2( 
        OIDC_T                lastmatch, 
        int                compc, 
        OIDC_T*                compl, 
        char*                cookie, 
        int*                len, 
        SNMP_PKT_T*                pktp, 
        int*                dynamic) 
{ 
} 
 
INT_32_T get_ex2Obj1( 
        OIDC_T                lastmatch, 
        int                compc, 
        OIDC_T*                compl, 
        char*                cookie, 
        SNMP_PKT_T*                pktp) 
{ 
} 
 
void set_ex2Obj1( 
        OIDC_T                lastmatch, 
        int                compc, 
        OIDC_T*                compl, 
        char*                cookie, 
        INT_32_T                value, 
        SNMP_PKT_T*                pktp, 
        int                indx) 
{ 
} 
 
OCTET_T* get_ex2Obj2( 
        OIDC_T                lastmatch, 
        int                compc, 
        OIDC_T*                compl, 
        char*                cookie, 
        int*                len, 
        SNMP_PKT_T*                pktp, 
        int*                dynamic) 
{ 
}

-skel.h

mibcomp -skel.h -o skelh.out example.mib

The -skel.h output mode generates a C header file that declares all the functions that would be defined in the C code generated by mibcomp running with the -skel option (-skel) and the same input files. This is the same set of functions that would be referenced by the C code generated by mibcomp running with the -mib.c option and the same input files.

Here is an example of mibcomp output when given the -skel.h option:

/************************************************************************ 
****************************************************************************** 
**** This file was automatically generated by Wind River Systems' 
**** mibcomp SNMP MIB Compiler. 
**** This file was generated using the -skel.h switch. 
**** 
**** This file contains declarations of stub functions to aid in building 
**** the agent MIB interface. It declares all the MIB get, set, test and 
**** next method routines that you will need to supply. You'll probably 
**** want to FORCE-INCLUDE this file when using the -mib.c output mode. 
**** 
**** To generate the skeletal stub functions themselves, run mibcomp 
**** with the -skel switch. **** 
**** YOU MAY MODIFY THIS FILE BUT BEWARE ACCIDENTALLY OVERWRITING IT 
**** BY REGENERATING IT WITH THE MIB COMPILER. **** 
**** Last build date: Fri May 26 22:06:23 1995 
**** from files:  
**** example1.mib, example2.mib, examples.ctl 
************************************************************************* 
************************************************************************* 
*/ 
 
INT_32_T get_ex1Obj1(OIDC_T, int, OIDC_T*, char*, SNMP_PKT_T*); 
void set_ex1Obj1(OIDC_T, int, OIDC_T*, char*, INT_32_T,  
            SNMP_PKT_T*, int); 
OCTET_T* get_ex1Obj2(OIDC_T, int, OIDC_T*, char*, int*,  
            SNMP_PKT_T*, int*); 
INT_32_T get_ex2Obj1(OIDC_T, int, OIDC_T*, char*, SNMP_PKT_T*); 
void set_ex2Obj1(OIDC_T, int, OIDC_T*, char*, INT_32_T,  
            SNMP_PKT_T*, int); 
OCTET_T* get_ex2Obj2(OIDC_T, int, OIDC_T*, char*, int*,  
            SNMP_PKT_T*, int*);

-stub

mibcomp -stub -o stub.c example.mib

The -stub output mode attempts to write your method routines for you. It cannot know how your data structures are set up, so it's only a start, but it's a start that can save you a lot of typing.

First, the -stub output makes some assumptions about how to group MIB variables. It considers any variables which possess a common parent a group. For instance, all the variables in the system group of MIB-II, which all have the parent node system, are considered a group. Also, all the variables which form the columns of a table are considered a group.

Then, for each group of variables the -stub output writes out up to five routines. These are the four method routines for the SNMP agent and an internal routine, shared by the getproc( ) and nextproc( ) routines, that retrieves the values of variables. If none of the variables in the group is writable, the testproc( ) and setproc( ) routines ore omitted and if none of the variables are readable, the getproc( ) and nextproc( ) routines are omitted.

Now you need to modify the method routines to fit your system. mibcomp includes a comment of the form /* !!! */ on each line we think you might want to consider modifying. mibcomp also includes substantial comments to guide you through the code so you can understand what it is trying to do.

The generated output #includes the file mibleaf.h, which should be generated by the MIB compiler using the -leaf option. The constants defined in there are used through the code to make it more readable.

The -stub output mode understands the -start command line option, which lets it write out only part of the MIBs that were read in from the command line.

To get the -mib.c output mode to use the same function names, it is not necessary to specify them explicitly in your control file. If you set the method routine names to "-stub", then -mib.c uses the same names that -stub would choose. If all of your MIBs are handled by method routines which follow the -stub names, then you do not need to set the method routine names in your control file at all. In fact, you may not even need a control file.

Since the -stub output format, unlike most mibcomp output formats, is intended for use as a starting point for code that you write, you almost certainly will not run mibcomp in this output mode very often. When you do run mibcomp in this output mode, be careful to make sure you do not accidentally overwrite a modified version of the output from a previous run.

Here is an example of mibcomp output when given the -stub option:

/************************************************************************ 
************************************************************************* 
**** This file was automatically generated by Wind River Systems' 
**** mibcomp SNMP MIB Compiler. 
**** This file was generated using the -stub switch. 
****  
**** This file contains stub function declarations to aid in building 
**** the agent MIB interface.  It creates all the MIB get, set, test, and 
**** next method routines that you will need to supply.  However, 
**** since it doesn't know your system, several things are left to you. 
**** Look for comments containing \Q!!!' for places you're likely to want 
**** to change for your system.  Also, while the layout of the method 
**** routines is a commonly useful one, it does not fit all data  
**** structures and systems.  Look at this output as a guide to how to  
**** write your method routines; a guide that, in most cases,  
**** significantly reduces the amount of typing you need to do. 
****  
**** The code here assumes you've created a file called \Qmibleaf.h' with 
**** the -leaf option to the mibcompiler. 
****  
**** YOU WILL PROBABLY MODIFY THIS FILE BUT BEWARE ACCIDENTALLY 
**** OVERWRITING IT BY REGENERATING IT WITH THE MIB COMPILER. 
****  
**** Last build date: Mon Mar 18 15:45:02 1996 
**** from files: example1.mib, example2.mib, examples.ctl 
************************************************************************* 
************************************************************************* 
*/ 
 
#include <h/snmp/asn1conf.h> 
#include <h/snmp/asn1.h> 
#include <h/snmp/buffer.h> 
#include <h/snmp/mib.h> 
#include <h/snmp/localio.h> 
#include <h/snmp/snmpdefs.h> 
#include <h/snmp/snmp.h> 
#include <h/snmp/auxfuncs.h> 
#include "mibleaf.h" 
 
/* 
 * Method routines for the ex1Objs variables: 
 * 
 *    ex1Obj1 -- read-write 
 * First example object. 
 * 
 *    ex1Obj2 -- read-only 
 * Second example object. 
 */ 
 
/* An internal routine to retrieve the values of the variables, used 
 * by the method routines ex1Objs_get and ex1Objs_next. 
 * You need to replace the type STRUCT_ex1Objs with something 
 * appropriate to your system. */ 
static int 
    ex1Objs_get_value(OIDC_T                                lastmatch, 
                    SNMP_PKT_T                *pktp, 
                    VB_T                *vbp, 
                    STRUCT_ex1Objs                *data)                /* !!! */ 
{ 
    switch(lastmatch) { 
    case LEAF_ex1Obj1: 
        /* Values: 
         *    one(1) = VAL_ex1Obj1_one 
         *    two(2) = VAL_ex1Obj1_two 
         */ 
        getproc_got_int32(pktp, vbp, data->ex1Obj1);                                            /* !!! */ 
        break; 
    case LEAF_ex1Obj2: 
        /* if the data being returned is in dynamic storage and needs 
         * to be free'd, change the 0 argument to a 1. */ 
        getproc_got_string(pktp, vbp, string_length(data->ex1Obj2), 
                            data->ex1Obj2, 0, VT_STRING);                                /* !!! */ 
        break; 
    default: 
        return GEN_ERR; 
    } 
    return NO_ERROR; 
} 
 
void 
    ex1Objs_get(OIDC_T                        lastmatch, 
                int            compc, 
                OIDC_T            *compl, 
                VB_T            *vbp, 
                SNMP_PKT_T            *pktp) 
{ 
    STRUCT_ex1Objs data;                            /* !!! */ 
    int error; 
 
    /* find all the varbinds that share the same getproc and instance */ 
    group_by_getproc_and_instance(pktp, vbp, compc, compl); 
 
    /* check that the instance is exactly .0 */ 
    if (!((compc == 1) && (*compl == 0))) 
        for ( ; vbp; vbp = vbp->vb_link) 
            getproc_nosuchins(pktp, vbp); 
    /* grab the actual data for this variable. this lookup routine will 
     * probably have to be changed for your system. for scalar variables 
     * there might not even be any lookup routine. */ 
    else if (ex1Objs_lookup(&data) != 0)                                            /* !!! */ 
        for ( ; vbp; vbp = vbp->vb_link) 
            getproc_error(pktp, vbp, GEN_ERR); 
    else { 
        /* retrieve all the values from the same data structure */ 
        for ( ; vbp; vbp = vbp->vb_link) { 
        if ((error = ex1Objs_get_value(vbp->vb_ml.ml_last_match, 
            pktp, vbp, &data)) != NO_ERROR) 
            getproc_error(pktp, vbp, error); 
            } 
  } 
} 
 
void 
  ex1Objs_next(OIDC_T      lastmatch, 
               int         compc, 
               OIDC_T     *compl, 
               VB_T       *vbp, 
               SNMP_PKT_T *pktp) 
{ 
  STRUCT_ex1Objs data;           /* !!! */ 
  OIDC_T instance = 0; 
 
  /* the only time there's a next for a scalar is if we're given 
   * no instance at all. */ 
  if (compc != 0) 
    nextproc_no_next(pktp, vbp); 
  /* grab the data for these variables.  you'll probably have to change 
   * this lookup routine for your system.  for scalar variables there 
   * might not even be any lookup routine. */ 
  else if (ex1Objs_lookup(&data));               /* !!! */ 
    getproc_error(pktp, vbp, GEN_ERR); 
  else { 
    /* find all the varbinds in this group and retrieve their 
     * values from the same data structure */ 
    for (group_by_getproc_and_instance(pktp, vbp, compc, compl); 
     vbp; vbp = vbp->vb_link) { 
      nextproc_next_instance(pktp, vbp, 1, &instance); 
      ex1Objs_get_value(vbp->vb_ml.ml_last_match, pktp, vbp, &data); 
    } 
  } 
} 
 
void 
  ex1Objs_test(OIDC_T      lastmatch, 
               int         compc, 
               OIDC_T     *compl, 
               VB_T       *vbp, 
               SNMP_PKT_T *pktp) 
{ 
  VB_T *group_vbp; 
 
  /* Only scalar variables here, check for .0 */ 
  if (!((compc == 1) && (*compl == 0))) { 
    testproc_error(pktp, vbp, NO_SUCH_NAME); 
    return; 
  } 
 
  /* find all the varbinds that share the same getproc and instance and 
   * group them together. */ 
  group_by_getproc_and_instance(pktp, vbp, compc, compl); 
 
  /* now check each varbind */ 
  for (group_vbp = vbp; 
       group_vbp; 
       group_vbp = group_vbp->vb_link) { 
    /* !!! Add any value checking you wish to do. */ 
    switch (group_vbp->vb_ml.ml_last_match) { 
    case LEAF_ex1Obj1: 
      /* !!! modify this switch to give an error for values your 
       * implementation doesn't allow */ 
      switch (VB_GET_INT32(group_vbp)) { 
      case VAL_ex1Obj1_one: 
      case VAL_ex1Obj1_two: 
        break; 
      default: 
        testproc_error(pktp, group_vbp, WRONG_VALUE); 
        continue; 
      } 
      testproc_good(pktp, group_vbp); 
      break; 
    default: 
      testproc_error(pktp, group_vbp, GEN_ERR); 
      return; 
    } 
  } 
} 
 
void 
  ex1Objs_set(OIDC_T      lastmatch, 
              int         compc, 
              OIDC_T     *compl, 
              VB_T       *vbp, 
              SNMP_PKT_T *pktp) 
{ 
  for ( ; vbp; vbp = vbp->vb_link) { 
    switch (vbp->vb_ml.ml_last_match) { 
    case LEAF_ex1Obj1: 
      ex1Obj1 = VB_GET_INT32(vbp);                   /* !!! */ 
      setproc_good(pktp, vbp); 
      break; 
    default: 
      setproc_error(pktp, vbp, COMMIT_FAILED); 
      return; 
    } 
  } 
} 
 
/* 
 * Method routines for the ex2Objs variables: 
 * 
 *   ex2Obj1 -- read-write 
 * First example object. 
 * 
 *   ex2Obj2 -- read-only 
 * Second example object. 
 */ 
 
/* An internal routine to retrieve the values of the variables, used 
 * by the method routines ex2Objs_get and ex2Objs_next. 
 * You need to replace the type STRUCT_ex2Objs with something 
 * appropriate to your system. */ 
static int 
  ex2Objs_get_value(OIDC_T      lastmatch, 
                    SNMP_PKT_T *pktp, 
                    VB_T       *vbp, 
                    STRUCT_ex2Objs *data)     /* !!! */ 
{ 
  switch(lastmatch) { 
  case LEAF_ex2Obj1: 
    /* Values: 
     *  one(1) = VAL_ex2Obj1_one 
     *  two(2) = VAL_ex2Obj1_two 
     */ 
    getproc_got_int32(pktp, vbp, data->ex2Obj1);    /* !!! */ 
    break; 
  case LEAF_ex2Obj2: 
    /* if the data being returned is in dynamic storage and needs 
     * to be free'd, change the 0 argument to a 1. */ 
    getproc_got_string(pktp, vbp, string_length(data->ex2Obj2), 
                       data->ex2Obj2, 0, VT_STRING);    /* !!! */ 
    break; 
  default: 
    return GEN_ERR; 
  } 
  return NO_ERROR; 
} 
 
void 
  ex2Objs_get(OIDC_T      lastmatch, 
              int         compc, 
              OIDC_T     *compl, 
              VB_T       *vbp, 
              SNMP_PKT_T *pktp) 
{ 
  STRUCT_ex2Objs data;                             /* !!! */ 
  int error; 
 
  /* find all the varbinds that share the same getproc and instance */ 
  group_by_getproc_and_instance(pktp, vbp, compc, compl); 
 
  /* check that the instance is exactly .0 */ 
  if (!((compc == 1) && (*compl == 0))) 
    for ( ; vbp; vbp = vbp->vb_link) 
      getproc_nosuchins(pktp, vbp); 
  /* grab the actual data for this variable.  this lookup routine will 
   * probably have to be changed for your system.  for scalar variables 
   * there might not even be any lookup routine. */ 
  else if (ex2Objs_lookup(&data) != 0)            /* !!! */ 
    for ( ; vbp; vbp = vbp->vb_link) 
      getproc_error(pktp, vbp, GEN_ERR); 
  else { 
    /* retrieve all the values from the same data structure */ 
    for ( ; vbp; vbp = vbp->vb_link) { 
      if ((error = ex2Objs_get_value(vbp->vb_ml.ml_last_match, 
                                     pktp, vbp, &data)) != NO_ERROR) 
        getproc_error(pktp, vbp, error); 
    } 
  } 
} 
 
void 
  ex2Objs_next(OIDC_T      lastmatch, 
               int         compc, 
               OIDC_T     *compl, 
               VB_T       *vbp, 
               SNMP_PKT_T *pktp) 
{ 
  STRUCT_ex2Objs data;           /* !!! */ 
  OIDC_T instance = 0; 
 
  /* the only time there's a next for a scalar is if we're given 
   * no instance at all. */ 
  if (compc != 0) 
    nextproc_no_next(pktp, vbp); 
  /* grab the data for these variables.  you'll probably have to change 
   * this lookup routine for your system.  for scalar variables there 
   * might not even be any lookup routine. */ 
  else if (ex2Objs_lookup(&data));               /* !!! */ 
    getproc_error(pktp, vbp, GEN_ERR); 
  else { 
    /* find all the varbinds in this group and retrieve their 
     * values from the same data structure */ 
    for (group_by_getproc_and_instance(pktp, vbp, compc, compl); 
     vbp; vbp = vbp->vb_link) { 
      nextproc_next_instance(pktp, vbp, 1, &instance); 
      ex2Objs_get_value(vbp->vb_ml.ml_last_match, pktp, vbp, &data); 
    } 
  } 
} 
 
void 
  ex2Objs_test(OIDC_T      lastmatch, 
               int         compc, 
               OIDC_T     *compl, 
               VB_T       *vbp, 
               SNMP_PKT_T *pktp) 
{ 
  VB_T *group_vbp; 
 
  /* Only scalar variables here, check for .0 */ 
  if (!((compc == 1) && (*compl == 0))) { 
    testproc_error(pktp, vbp, NO_SUCH_NAME); 
    return; 
  } 
 
  /* find all the varbinds that share the same getproc and instance and 
   * group them together. */ 
  group_by_getproc_and_instance(pktp, vbp, compc, compl); 
 
  /* now check each varbind */ 
  for (group_vbp = vbp; 
       group_vbp; 
       group_vbp = group_vbp->vb_link) { 
    /* !!! Add any value checking you wish to do. */ 
    switch (group_vbp->vb_ml.ml_last_match) { 
    case LEAF_ex2Obj1: 
      /* !!! modify this switch to give an error for values your 
       * implementation doesn't allow */ 
      switch (VB_GET_INT32(group_vbp)) { 
      case VAL_ex2Obj1_one: 
      case VAL_ex2Obj1_two: 
        break; 
      default: 
        testproc_error(pktp, group_vbp, WRONG_VALUE); 
        continue; 
      } 
      testproc_good(pktp, group_vbp); 
      break; 
    default: 
      testproc_error(pktp, group_vbp, GEN_ERR); 
      return; 
    } 
  } 
} 
 
void 
  ex2Objs_set(OIDC_T      lastmatch, 
              int         compc, 
              OIDC_T     *compl, 
              VB_T       *vbp, 
              SNMP_PKT_T *pktp) 
{ 
  for ( ; vbp; vbp = vbp->vb_link) { 
    switch (vbp->vb_ml.ml_last_match) { 
    case LEAF_ex2Obj1: 
      ex2Obj1 = VB_GET_INT32(vbp);                   /* !!! */ 
      setproc_good(pktp, vbp); 
      break; 
    default: 
      setproc_error(pktp, vbp, COMMIT_FAILED); 
      return; 
    } 
  } 
}