Blame local/mib2c.create-dataset.conf

Packit fcad23
## -*- c -*-
Packit fcad23
######################################################################
Packit fcad23
## Do the .h file
Packit fcad23
######################################################################
Packit fcad23
@open ${name}.h@
Packit fcad23
/*
Packit fcad23
 * Note: this file originally auto-generated by mib2c
Packit fcad23
 * using mib2c.create-dataset.conf
Packit fcad23
 */
Packit fcad23
#ifndef $name.uc_H
Packit fcad23
#define $name.uc_H
Packit fcad23
Packit fcad23
/* function declarations */
Packit fcad23
void init_$name(void);
Packit fcad23
@foreach $i table@
Packit fcad23
void initialize_table_$i(void);
Packit fcad23
Netsnmp_Node_Handler ${i}_handler;
Packit fcad23
@end@
Packit fcad23
@foreach $i table@
Packit fcad23
Packit fcad23
/* column number definitions for table $i */
Packit fcad23
    @foreach $c column@
Packit fcad23
       #define COLUMN_$c.uc		$c.subid
Packit fcad23
    @end@
Packit fcad23
@end@
Packit fcad23
#endif /* $name.uc_H */
Packit fcad23
######################################################################
Packit fcad23
## Do the .c file
Packit fcad23
######################################################################
Packit fcad23
@open ${name}.c@
Packit fcad23
/*
Packit fcad23
 * Note: this file originally auto-generated by mib2c
Packit fcad23
 * using mib2c.create-dataset.conf
Packit fcad23
 */
Packit fcad23
Packit fcad23
#include <net-snmp/net-snmp-config.h>
Packit fcad23
#include <net-snmp/net-snmp-includes.h>
Packit fcad23
#include <net-snmp/agent/net-snmp-agent-includes.h>
Packit fcad23
#include "${name}.h"
Packit fcad23
Packit fcad23
@foreach $i table@
Packit fcad23
/** Initialize the $i table by defining its contents and how it's structured */
Packit fcad23
void
Packit fcad23
initialize_table_$i(void)
Packit fcad23
{
Packit fcad23
    const oid ${i}_oid[] = {$i.commaoid};
Packit fcad23
    netsnmp_table_data_set *table_set;
Packit fcad23
Packit fcad23
    /* create the table structure itself */
Packit fcad23
    table_set = netsnmp_create_table_data_set("$i");
Packit fcad23
Packit fcad23
    /* comment this out or delete if you don't support creation of new rows */
Packit fcad23
    table_set->allow_creation = 1;
Packit fcad23
Packit fcad23
    /***************************************************
Packit fcad23
     * Adding indexes
Packit fcad23
     */
Packit fcad23
    DEBUGMSGTL(("initialize_table_$i",
Packit fcad23
                "adding indexes to table $i\n"));
Packit fcad23
    netsnmp_table_set_add_indexes(table_set,
Packit fcad23
    @foreach $idx index@
Packit fcad23
                           $idx.type,  /* index: $idx */
Packit fcad23
    @end@
Packit fcad23
                           0);
Packit fcad23
Packit fcad23
    DEBUGMSGTL(("initialize_table_$i",
Packit fcad23
                "adding column types to table $i\n"));		 
Packit fcad23
    netsnmp_table_set_multi_add_default_row(table_set,
Packit fcad23
    @foreach $c column@
Packit fcad23
                                            COLUMN_$c.uc, $c.type, $c.settable,
Packit fcad23
                                            NULL, 0,
Packit fcad23
    @end@
Packit fcad23
                              0);
Packit fcad23
    
Packit fcad23
    /* registering the table with the master agent */
Packit fcad23
    /* note: if you don't need a subhandler to deal with any aspects
Packit fcad23
       of the request, change ${i}_handler to "NULL" */
Packit fcad23
    netsnmp_register_table_data_set(netsnmp_create_handler_registration("$i", ${i}_handler,
Packit fcad23
                                                        ${i}_oid,
Packit fcad23
                                                        OID_LENGTH(${i}_oid),
Packit fcad23
                                                        HANDLER_CAN_RWRITE),
Packit fcad23
                            table_set, NULL);
Packit fcad23
}
Packit fcad23
@end@
Packit fcad23
Packit fcad23
/** Initializes the $name module */
Packit fcad23
void
Packit fcad23
init_$name(void)
Packit fcad23
{
Packit fcad23
Packit fcad23
  /* here we initialize all the tables we're planning on supporting */
Packit fcad23
  @foreach $i table@
Packit fcad23
    initialize_table_$i();
Packit fcad23
  @end@
Packit fcad23
}
Packit fcad23
@foreach $i table@
Packit fcad23
Packit fcad23
/** handles requests for the $i table, if anything else needs to be done */
Packit fcad23
int
Packit fcad23
${i}_handler(
Packit fcad23
    netsnmp_mib_handler               *handler,
Packit fcad23
    netsnmp_handler_registration      *reginfo,
Packit fcad23
    netsnmp_agent_request_info        *reqinfo,
Packit fcad23
    netsnmp_request_info              *requests) {
Packit fcad23
    /* perform anything here that you need to do.  The requests have
Packit fcad23
       already been processed by the master table_dataset handler, but
Packit fcad23
       this gives you chance to act on the request in some other way
Packit fcad23
       if need be. */
Packit fcad23
    return SNMP_ERR_NOERROR;
Packit fcad23
}
Packit fcad23
@end@