## -*- c -*- ###################################################################### ## Do the .h file ###################################################################### @open -@ *** Warning: only generating code for nodes of MIB type INTEGER @open ${name}.h@ /* * Note: this file originally auto-generated by mib2c using * $Id: mib2c.int_watch.conf,v 1.2 2002/07/17 14:41:53 dts12 Exp $ */ #ifndef $name.uc_H #define $name.uc_H /* function declarations */ void init_$name(void); #endif /* $name.uc_H */ ###################################################################### ## Do the .c file ###################################################################### @open ${name}.c@ /* * Note: this file originally auto-generated by mib2c using * $Id: mib2c.int_watch.conf,v 1.2 2002/07/17 14:41:53 dts12 Exp $ */ #include #include #include #include "${name}.h" /* the variable we want to tie an OID to. The agent will handle all * GET and SET requests to this variable changing its value as needed. */ @foreach $i scalar@ @if $i.type eq "ASN_INTEGER"@ static int $i = 0; /* XXX: set default value */ @end@ @end@ /* * our initialization routine, automatically called by the agent * (to get called, the function name must match init_FILENAME()) */ void init_${name}(void) { @foreach $i scalar@ @if $i.type eq "ASN_INTEGER"@ static oid ${i}_oid[] = { $i.commaoid, 0 }; @end@ @end@ /* * a debugging statement. Run the agent with -D$name to see * the output of this debugging statement. */ DEBUGMSGTL(("$name", "Initializing the $name module\n")); /* * the line below registers our variables defined above as * accessible and makes them writable. A read only version of any * of these registrations would merely call * register_read_only_int_instance() instead. The functions * called below should be consistent with your MIB, however. * * If you wanted a callback when the value was retrieved or set * (even though the details of doing this are handled for you), * you could change the NULL pointer below to a valid handler * function. */ @foreach $i scalar@ @if $i.type eq "ASN_INTEGER"@ DEBUGMSGTL(("$name", "Initializing $i scalar integer. Default value = %d\n", $i)); @if $i.settable@ netsnmp_register_int_instance("$i", ${i}_oid, OID_LENGTH(${i}_oid), &$i, NULL); @end@ @if !$i.settable@ netsnmp_register_read_only_int_instance("$i", ${i}_oid, OID_LENGTH(${i}_oid), &$i, NULL); @end@ @end@ @end@ DEBUGMSGTL(("$name", "Done initalizing $name module\n")); }