diff options
author | Hideki Yamane <henrich@debian.org> | 2013-04-11 10:21:22 +0900 |
---|---|---|
committer | Hideki Yamane <henrich@debian.org> | 2013-04-11 10:21:22 +0900 |
commit | e30beeedd5cbe6f72008c32122b3b8b617fd5ab2 (patch) | |
tree | 8bd5c28fc77a5a80d65cf70e2fd330b8af448c73 /local/mib2c.int_watch.conf | |
parent | 2ebfa94e6e1fe2b88bb061d26f20fef9c0b78536 (diff) | |
download | pkg-net-snmp-e30beeedd5cbe6f72008c32122b3b8b617fd5ab2.tar.gz |
Imported Upstream version 5.4.3~dfsgupstream/5.4.3_dfsg
Diffstat (limited to 'local/mib2c.int_watch.conf')
-rw-r--r-- | local/mib2c.int_watch.conf | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/local/mib2c.int_watch.conf b/local/mib2c.int_watch.conf new file mode 100644 index 0000000..5804a74 --- /dev/null +++ b/local/mib2c.int_watch.conf @@ -0,0 +1,107 @@ +## -*- 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 13957 2005-12-20 15:33:08Z tanders $ + */ +#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 13957 2005-12-20 15:33:08Z tanders $ + */ + +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> +#include "${name}.h" + +/* + * The variables we want to tie the relevant OIDs to. + * The agent will handle all GET and (if applicable) SET requests + * to these variables automatically, changing the values as needed. + */ + +@foreach $i scalar@ + @if !$i.needlength@ +$i.decl $i = 0; /* XXX: set default value */ + @end@ +@end@ + +/* + * Our initialization routine, called automatically by the agent + * (Note that the function name must match init_FILENAME()) + */ +void +init_${name}(void) +{ + netsnmp_handler_registration *reg; + netsnmp_watcher_info *winfo; + + @foreach $i scalar@ + @if !$i.needlength@ + static oid ${i}_oid[] = { $i.commaoid }; + @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")); + + + /* + * Register scalar watchers for each of the MIB objects. + * The ASN type and RO/RW status are taken from the MIB definition, + * but can be adjusted if needed. + * + * In most circumstances, the scalar watcher will handle all + * of the necessary processing. But the NULL parameter in the + * netsnmp_create_handler_registration() call can be used to + * supply a user-provided handler if necessary. + * + * This approach can also be used to handle Counter64, string- + * and OID-based watched scalars (although variable-sized writeable + * objects will need some more specialised initialisation). + */ + @foreach $i scalar@ + @if !$i.needlength@ + DEBUGMSGTL(("$name", + "Initializing $i scalar integer. Default value = %d\n", + $i)); + reg = netsnmp_create_handler_registration( + "$i", NULL, + ${i}_oid, OID_LENGTH(${i}_oid), + @if $i.settable@ + HANDLER_CAN_RWRITE); + @else@ + HANDLER_CAN_RONLY); + @end@ + winfo = netsnmp_create_watcher_info( + &$i, sizeof($i.decl), + $i.type, WATCHER_FIXED_SIZE); + if (netsnmp_register_watched_scalar( reg, winfo ) < 0 ) { + snmp_log( LOG_ERR, "Failed to register watched $i" ); + } + + @end@ + @end@ + + DEBUGMSGTL(("$name", + "Done initalizing $name module\n")); +} |