Revert "Revert "and added files""
[bcm963xx.git] / userapps / opensource / net-snmp / local / mib2c.create-dataset.conf
1 ## -*- c -*-
2 ######################################################################
3 ## Do the .h file
4 ######################################################################
5 @open ${name}.h@
6 /*
7  * Note: this file originally auto-generated by mib2c using
8  *  $Id: mib2c.create-dataset.conf,v 5.3 2002/12/05 00:29:45 hardaker Exp $
9  */
10 #ifndef $name.uc_H
11 #define $name.uc_H
12
13 /* function declarations */
14 void init_$name(void);
15 @foreach $i table@
16 void initialize_table_$i(void);
17 Netsnmp_Node_Handler ${i}_handler;
18 @end@
19 @foreach $i table@
20
21 /* column number definitions for table $i */
22     @foreach $c column@
23        #define COLUMN_$c.uc             $c.subid
24     @end@
25 @end@
26 #endif /* $name.uc_H */
27 ######################################################################
28 ## Do the .c file
29 ######################################################################
30 @open ${name}.c@
31 /*
32  * Note: this file originally auto-generated by mib2c using
33  *        $Id: mib2c.create-dataset.conf,v 5.3 2002/12/05 00:29:45 hardaker Exp $
34  */
35
36 #include <net-snmp/net-snmp-config.h>
37 #include <net-snmp/net-snmp-includes.h>
38 #include <net-snmp/agent/net-snmp-agent-includes.h>
39 #include "${name}.h"
40
41 @foreach $i table@
42 /** Initialize the $i table by defining its contents and how it's structured */
43 void
44 initialize_table_$i(void)
45 {
46     static oid ${i}_oid[] = {$i.commaoid};
47     size_t ${i}_oid_len = OID_LENGTH(${i}_oid);
48     netsnmp_table_data_set *table_set;
49
50     /* create the table structure itself */
51     table_set = netsnmp_create_table_data_set("$i");
52
53     /* comment this out or delete if you don't support creation of new rows */
54     table_set->allow_creation = 1;
55
56     /***************************************************
57      * Adding indexes
58      */
59     DEBUGMSGTL(("initialize_table_$i",
60                 "adding indexes to table $i\n"));
61     netsnmp_table_set_add_indexes(table_set,
62     @foreach $idx index@
63                            $idx.type,  /* index: $idx */
64     @end@
65                            0);
66
67     DEBUGMSGTL(("initialize_table_$i",
68                 "adding column types to table $i\n"));           
69     netsnmp_table_set_multi_add_default_row(table_set,
70     @foreach $c column@
71                                             COLUMN_$c.uc, $c.type, $c.settable,
72                                             NULL, 0,
73     @end@
74                               0);
75     
76     /* registering the table with the master agent */
77     /* note: if you don't need a subhandler to deal with any aspects
78        of the request, change ${i}_handler to "NULL" */
79     netsnmp_register_table_data_set(netsnmp_create_handler_registration("$i", ${i}_handler,
80                                                         ${i}_oid,
81                                                         ${i}_oid_len,
82                                                         HANDLER_CAN_RWRITE),
83                             table_set, NULL);
84 }
85 @end@
86
87 /** Initializes the $name module */
88 void
89 init_$name(void)
90 {
91
92   /* here we initialize all the tables we're planning on supporting */
93   @foreach $i table@
94     initialize_table_$i();
95   @end@
96 }
97 @foreach $i table@
98
99 /** handles requests for the $i table, if anything else needs to be done */
100 int
101 ${i}_handler(
102     netsnmp_mib_handler               *handler,
103     netsnmp_handler_registration      *reginfo,
104     netsnmp_agent_request_info        *reqinfo,
105     netsnmp_request_info              *requests) {
106     /* perform anything here that you need to do.  The requests have
107        already been processed by the master table_dataset handler, but
108        this gives you chance to act on the request in some other way
109        if need be. */
110     return SNMP_ERR_NOERROR;
111 }