blob: 31658fe762002a47ac45960f8026b8433f001531 [file] [log] [blame]
## -*- c -*-
######################################################################
## Do the .h file
######################################################################
@open ${name}.h@
/*
* Note: this file originally auto-generated by mib2c using
* $Id$
*/
#ifndef $name.uc_H
#define $name.uc_H
/* function declarations */
void init_$name(void);
@foreach $i table@
void initialize_table_$i(void);
NodeHandler ${i}_handler;
@end@
@foreach $i table@
/* column number definitions for table $i */
@foreach $c column@
#define COLUMN_$c.uc $c.subid
@end@
@end@
#endif /* $name.uc_H */
######################################################################
## Do the .c file
######################################################################
@open ${name}.c@
/*
* Note: this file originally auto-generated by mib2c using
* $Id$
*/
@foreach $i table@
/** Initialize the $i table by defining it's contents and how it's structured */
void
initialize_table_$i(void)
{
static oid ${i}_oid[] = {$i.commaoid};
size_t ${i}_oid_len = OID_LENGTH(${i}_oid);
table_data_set *table_set;
/* create the table structure itself */
table_set = create_table_data_set("$i");
/***************************************************
* Adding indexes
*/
@foreach $idx index@
/*
* declaring the $idx index
*/
DEBUGMSGTL(("initialize_table_$i",
"adding index $idx.label of type $idx.type to table $i\n"));
table_dataset_add_index(table_set, $idx.type);
@end@
@foreach $c column@
/* adding column $c of type $c.type and access of $c.access */
DEBUGMSGTL(("initialize_table_$i",
"adding column $c.label (#$c.subid) of type $c.type to table $i\n"));
table_set_add_default_row(table_set, COLUMN_$c.uc, $c.type, $c.settable);
@end@
/* registering the table with the master agent */
/* note: if you don't need a subhandler to deal with any aspects
of the request, change ${i}_handler to "NULL" */
register_table_data_set(create_handler_registration("$i", ${i}_handler,
${i}_oid,
${i}_oid_len,
HANDLER_CAN_RWRITE),
table_set, NULL);
}
@end@
/** Initialzies the $name module */
void
init_$name(void)
{
/* here we initialize all the tables we're planning on supporting */
@foreach $i table@
initialize_table_$i();
@end@
}
@foreach $i table@
/** handles requests for the $i table, if anything else needs to be done */
int
${i}_handler(
mib_handler *handler,
handler_registration *reginfo,
agent_request_info *reqinfo,
request_info *requests) {
/* perform anything here that you need to do. The requests have
already been processed by the master table_dataset handler, but
this gives you chance to act on the request in some other way
if need be. */
return SNMP_ERR_NOERROR;
}