1 #ifdef BRCM_SNMP_MIB_SUPPORT
3 * Note: this file originally auto-generated by mib2c
6 #include <net-snmp/net-snmp-config.h>
7 #include <net-snmp/net-snmp-includes.h>
8 #include <net-snmp/agent/net-snmp-agent-includes.h>
10 #include <net-snmp/agent/table.h>
11 #include <net-snmp/agent/table_iterator.h>
12 #include "nsTransactionTable.h"
14 /** Initialize the nsTransactionTable table by defining it's contents
15 and how it's structured */
17 initialize_table_nsTransactionTable(void)
19 static oid nsTransactionTable_oid[] =
20 { 1, 3, 6, 1, 4, 1, 8072, 1, 8, 1 };
21 size_t nsTransactionTable_oid_len =
22 OID_LENGTH(nsTransactionTable_oid);
23 netsnmp_table_registration_info *table_info;
24 netsnmp_handler_registration *my_handler;
25 netsnmp_iterator_info *iinfo;
28 * create the table structure itself
30 table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
31 iinfo = SNMP_MALLOC_TYPEDEF(netsnmp_iterator_info);
34 * if your table is read only, it's easiest to change the
35 * HANDLER_CAN_RWRITE definition below to HANDLER_CAN_RONLY
37 my_handler = netsnmp_create_handler_registration("nsTransactionTable",
38 nsTransactionTable_handler,
39 nsTransactionTable_oid,
40 nsTransactionTable_oid_len,
43 if (!my_handler || !table_info || !iinfo)
44 return; /* mallocs failed */
46 /***************************************************
47 * Setting up the table's definition
49 netsnmp_table_helper_add_index(table_info, ASN_INTEGER); /* index:
53 table_info->min_column = 2;
54 table_info->max_column = 2;
55 iinfo->get_first_data_point = nsTransactionTable_get_first_data_point;
56 iinfo->get_next_data_point = nsTransactionTable_get_next_data_point;
57 iinfo->table_reginfo = table_info;
59 /***************************************************
60 * registering the table with the master agent
62 DEBUGMSGTL(("initialize_table_nsTransactionTable",
63 "Registering table nsTransactionTable as a table iterator\n"));
64 netsnmp_register_table_iterator(my_handler, iinfo);
67 /** Initialzies the nsTransactionTable module */
69 init_nsTransactionTable(void)
73 * here we initialize all the tables we're planning on supporting
75 initialize_table_nsTransactionTable();
78 /** returns the first data point within the nsTransactionTable table data.
80 Set the my_loop_context variable to the first data point structure
81 of your choice (from which you can find the next one). This could
82 be anything from the first node in a linked list, to an integer
83 pointer containing the beginning of an array variable.
85 Set the my_data_context variable to something to be returned to
86 you later that will provide you with the data to return in a given
87 row. This could be the same pointer as what my_loop_context is
88 set to, or something different.
90 The put_index_data variable contains a list of snmp variable
91 bindings, one for each index in your table. Set the values of
92 each appropriately according to the data matching the first row
93 and return the put_index_data variable at the end of the function.
95 extern netsnmp_agent_session *agent_delegated_list;
97 netsnmp_variable_list *
98 nsTransactionTable_get_first_data_point(void **my_loop_context,
99 void **my_data_context,
100 netsnmp_variable_list
102 netsnmp_iterator_info *iinfo)
105 netsnmp_variable_list *vptr;
107 if (!agent_delegated_list)
110 *my_loop_context = (void *) agent_delegated_list;
111 *my_data_context = (void *) agent_delegated_list;
113 vptr = put_index_data;
115 snmp_set_var_value(vptr,
116 (u_char *) & agent_delegated_list->pdu->transid,
117 sizeof(agent_delegated_list->pdu->transid));
118 return put_index_data;
121 /** functionally the same as nsTransactionTable_get_first_data_point, but
122 my_loop_context has already been set to a previous value and should
123 be updated to the next in the list. For example, if it was a
124 linked list, you might want to cast it and the return
125 my_loop_context->next. The my_data_context pointer should be set
126 to something you need later and the indexes in put_index_data
129 netsnmp_variable_list *
130 nsTransactionTable_get_next_data_point(void **my_loop_context,
131 void **my_data_context,
132 netsnmp_variable_list
134 netsnmp_iterator_info *iinfo)
137 netsnmp_variable_list *vptr;
138 netsnmp_agent_session *alist = (netsnmp_agent_session *)
146 *my_loop_context = (void *) alist;
147 *my_data_context = (void *) alist;
149 vptr = put_index_data;
151 snmp_set_var_value(vptr, (u_char *) & alist->pdu->transid,
152 sizeof(alist->pdu->transid));
153 return put_index_data;
156 /** handles requests for the nsTransactionTable table, if anything
157 else needs to be done */
159 nsTransactionTable_handler(netsnmp_mib_handler *handler,
160 netsnmp_handler_registration *reginfo,
161 netsnmp_agent_request_info *reqinfo,
162 netsnmp_request_info *requests)
165 netsnmp_table_request_info *table_info;
166 netsnmp_variable_list *var;
167 netsnmp_agent_session *asp;
170 var = requests->requestvb;
171 if (requests->processed != 0)
175 * perform anything here that you need to do. The requests have
176 * already been processed by the master table_dataset handler, but
177 * this gives you chance to act on the request in some other way if
182 * the following extracts the my_data_context pointer set in the
183 * loop functions above. You can then use the results to help
184 * return data for the columns of the nsTransactionTable table in
188 (netsnmp_agent_session *)
189 netsnmp_extract_iterator_context(requests);
191 netsnmp_set_request_error(reqinfo, requests,
192 SNMP_NOSUCHINSTANCE);
196 * extracts the information about the table from the request
198 table_info = netsnmp_extract_table_info(requests);
201 * table_info->colnum contains the column number requested
204 * table_info->indexes contains a linked list of snmp variable
205 * bindings for the indexes of the table. Values in the list have
206 * been set corresponding to the indexes of the request
208 if (table_info == NULL) {
209 requests = requests->next;
213 switch (reqinfo->mode) {
215 * the table_iterator helper should change all GETNEXTs into
216 * GETs for you automatically, so you don't have to worry
217 * about the GETNEXT case. Only GETs and SETs need to be
221 switch (table_info->colnum) {
223 case COLUMN_NSTRANSACTIONMODE:
224 snmp_set_var_typed_value(var, ASN_INTEGER,
225 (u_char *) & asp->mode,
231 * We shouldn't get here
234 "problem encountered in nsTransactionTable_handler: unknown column\n");
240 "problem encountered in nsTransactionTable_handler: unsupported mode\n");
242 requests = requests->next;
244 return SNMP_ERR_NOERROR;
246 #endif /* BRCM_SNMP_MIB_SUPPORT */