mibcomp generates an output file based on a MIB description file whose name you must specify on the mibcomp command line. The output file contains the C code that declares the MIB tree to the target agent. If you do not specify a name for the output file, mibcomp uses the name OUTPUT. You can specify options on the command line to modify mibcomp's default behavior.
The general form of an mibcomp command is:
mibcomp [ -ansi ] [ -array ] [ -check ] [ -exclude module-name.object-name ] [ -inst_oid_len length ] [ -inst_str_len length ] [ -k_and_r ] [ -l MIB-search-path ]
Square brackets indicate optional arguments. The only argument that mibcomp absolutely requires is the name of an input file. You can specify multiple input files on the command line. If a MIB depends on objects or textual conventions defined in another MIB, be sure to list the other MIB first on the command line.
The options -array, -check, -leaf, -loadtree, -man, -man.h, -mib.c, -numbers, -partial, -partialm, -readtree, -skel, -skel.h, and -stub specify output modes, and are described in detail in B. mibcomp Output Formats. No more than one output format option can be selected for a particular run of mibcomp. If you do not select any of these options, mibcomp uses -mib.c as its default output mode.
|
NOTE: The -ansi and -k_and_r options are mutually exclusive. For use with VxWorks, only the -ansi option should be used. |
Most of mibcomp's command line options do not take effect until after mibcomp has finished processing the command line; however, the options -lowmem, -nowarn, and -quiet options are processed immediately when mibcomp encounters them on the command line, as are the names of input files. This means that the order of these options and of input-file names on the command line matters: if you want to suppress warnings that mibcomp generates when it reads a particular file, you must specify -nowarn before the filename. Similarly, -lowmem is only useful if you specify it before any filenames.
You can specify that mibcomp should read arguments from a file (an automated response file). Many MS-DOS programs support automated response files in order to circumvent MS-DOS' 128-character command-line limit. To instruct mibcomp to read commands from a file, use a "@" character immediately followed by the filename. For instance:
mibcomp @cmds.arf
You can use automated response files and other command-line arguments at the same time. mibcomp supports automated response files on all systems, not just MS-DOS.
Commands in an automated response file may be written one to a line, or may be separated by spaces on one or more lines. Lines may be up to 512 characters long. mibcomp treats the sequences ";", "--", and "#" as comment characters; you may use them to embed comments in your automated response files. For instance:
; This is an automated response file. rfc1213.mib -o mib_ii.c
You may customize options to mibcomp by setting the environment variable MIBCOMP. UNIX and MS-DOS systems both support environment variables. Set the MIBCOMP variable to a list of arguments you want to give to mibcomp. mibcomp executes these arguments before it processes its command line. The most common options generally used with the MIBCOMP environment variable are: -l, -lowmem, -quiet, and -statistics.
Assume that you want to build an agent that supports MIB-II, that you keep your MIBs in a standard directory, that you have included that directory in a default search path via the MIBCOMP environment variable, and that the control file for your project is in the current directory under the name control.mib. To generate the C code that a WindNet SNMPv1/v2c-based agent uses to represent the MIB tree, leaving the output in a file called mib.c, do:
You can modify a makefile to do this automatically by adding the following lines to your makefile:
After adding these lines to your makefile, you can use the make utility to generate mib.c automatically:
If your makefile also has rules that use mib.c as a source, you should be able to just build your program normally, letting make build mib.c for you when necessary. For an example of makefile construction, see $WIND_BASE/target/src/snmpv1/agent/Makefile.
Whether you create mib.c manually or with the make utility, you should be able to compile it without error using the same compiler switches that you use to compile the target agent. If mib.c does not compile, there is probably something wrong with your control file (control.mib in this example).
1: K&R" stands for "Kernighan and Ritchie C," named after the authors of the original C language reference.