A.6   How-To Guide

This section is a "how-to" guide to mibcomp. It lists uses for mibcomp and gives a short summary of instructions for each use.

A.6.1   Check a MIB for Errors

To use mibcomp as a MIB checker, specify the -check option instead of an output mode. For instance, to verify that foo.mib is syntactically correct:

mibcomp -check foo.mib

All real MIBs contain IMPORT statements. mibcomp has built-in knowledge of the set of standard MIB modules that make up the SNMPv1 SMI: RFC1155-SMI,RFC-1212, and RFC-1215. If foo.mib imports anything from any module not listed here, you must load that module before you can load foo.mib. If, for example, foo.mib imports the DisplayString textual convention from MIB-II (RFC1213-MIB, in the file rfc1213.mib), you would need to do:

mibcomp -check rfc1213.mib foo.mib{}

Note that the order of the file names on the command line is important: if you specify the files in the wrong order, mibcomp complains when it tries to process the IMPORT statement in foo.mib and fails to find RFC1213-MIB in its internal database.

A.6.2   Set Personal Options for mibcomp Use

To set options for your personal use of mibcomp, use the MIBCOMP environment variable. You can set any command-line arguments you want in this variable; they are processed before the actual command line itself is processed. You can even use automated response files in the variable.

Most users only specify a search path for their MIB files, the -quiet option and the -statistics option in their MIBCOMP environment variables. Please refer to your operating- system manual to find out how to set environment variables.

For a complete list of mibcomp's command line options, please see A.5 Running mibcomp.

A.6.3   Create Procedure Skeletons for Method Routines in an Agent

You can save yourself time when coding the get, set, test, and next method routines for MIB objects by having mibcomp generate skeletal procedures for these method routines. The skeletal procedures already have all the arguments and the return value declared, so you do not have to look these up and remember to specify them all. To generate skeletal procedures for the method routines functions, use the -skel or -stub option. Please see -skeland -stub, for more details.

A.6.4   Create Procedure Prototypes for Method Routines in an Agent

For consistency checking, you should have external declarations and procedure prototypes for all your MIB method routines. mibcomp can generate these for you, with the -skel.h flag. You can then use this file to cross-check consistency of argument usage between the arguments the target agent expects, the functions used in the mib.c file, and the functions you provide. Please see -skel.h, for more details.

A.6.5   Generate mib.rt for an SNMP Manager Utility

A .rt file can be used by an SNMP manager to facilitate parsing a known MIB tree. You can generate a new mib.rt file for an SNMP manager utility with mibcomp's -readtree output mode option. (.rt stands for readtree.) To generate a new mib.rt containing symbols from MIB-II, do:

mibcomp -readtree -o mib.rt rfc1213.mib

If mibcomp generates an error message instead of a useful mib.rt file, please see section A.6.1 Check a MIB for Errors.

A.6.6   Read Standard Input as an Input File

If you specify a single hyphen ("-") as an argument to mibcomp, mibcomp treats it as a request to use standard input as an input file.

A.6.7   Write mibcomp's Output to Standard Output

If you specify a single hyphen ("-") as the argument to the -o option, mibcomp treats it as a request to use standard output as the output file.

A.6.8   Get Around the MS-DOS Command Line Length Limit

MS-DOS has a command-line length limit of roughly 128 characters. To get around this limit, use an automated response file as an argument. Arguments that start with a "@" character are requests to mibcomp that it read from an automated response file. mibcomp reads the contents of the specified file as if they were on the command line. You may use several automated response files on one command line, and may mix them and regular options on the command line.

A.6.9   Windows NT Filename Case-Insensitive

Windows NT has the capability to access filenames longer than the standard MS-DOS 8x3. However, even though these filenames appear to be case-sensitive, they are accessed in a case-insensitive manner, such that the file MyFile.c is equivalent to myfile.c. While this is not a bug, it is something to keep in mind while working with Windows NT.

A.6.10   Put Comments in an Automated Response File

You may want to embed comments in an automated response file to explain what the file is doing. mibcomp ignores any line in an automated response file that starts with the number- (hash-) sign ("#"), a semicolon (";"), or two hyphens("--").

A.6.11   Read mibcomp Commands from Standard Input

mibcomp's support for automated response files is intended primarily to work around the short MS-DOS command-line length limit, as described in A.6.8 Get Around the MS-DOS Command Line Length Limit. However, you can also use this feature to read mibcomp commands from standard input. If you use "-" (a single hyphen character) as the name of an automated response file, mibcomp reads command line options from standard input. This could be useful if you are running mibcomp as part of a complicated UNIX pipeline sequence.