1 | /* |
---|
2 | * Note: this file originally auto-generated by mib2c using |
---|
3 | * version : 15899 $ of $ |
---|
4 | * |
---|
5 | * $Id:$ |
---|
6 | */ |
---|
7 | /* |
---|
8 | * ********************************************************************* |
---|
9 | * ********************************************************************* |
---|
10 | * ********************************************************************* |
---|
11 | * *** *** |
---|
12 | * *** NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE *** |
---|
13 | * *** *** |
---|
14 | * *** *** |
---|
15 | * *** THIS FILE DOES NOT CONTAIN ANY USER EDITABLE CODE. *** |
---|
16 | * *** *** |
---|
17 | * *** *** |
---|
18 | * *** THE GENERATED CODE IS INTERNAL IMPLEMENTATION, AND *** |
---|
19 | * *** *** |
---|
20 | * *** *** |
---|
21 | * *** IS SUBJECT TO CHANGE WITHOUT WARNING IN FUTURE RELEASES. *** |
---|
22 | * *** *** |
---|
23 | * *** *** |
---|
24 | * ********************************************************************* |
---|
25 | * ********************************************************************* |
---|
26 | * ********************************************************************* |
---|
27 | */ |
---|
28 | |
---|
29 | /* standard Net-SNMP includes */ |
---|
30 | #include <net-snmp/net-snmp-config.h> |
---|
31 | #include <net-snmp/net-snmp-includes.h> |
---|
32 | #include <net-snmp/agent/net-snmp-agent-includes.h> |
---|
33 | |
---|
34 | /* include our parent header */ |
---|
35 | #include "syn3StatisticsTable.h" |
---|
36 | |
---|
37 | |
---|
38 | #include <net-snmp/agent/table_container.h> |
---|
39 | #include <net-snmp/library/container.h> |
---|
40 | |
---|
41 | #include "syn3StatisticsTable_interface.h" |
---|
42 | |
---|
43 | #include <ctype.h> |
---|
44 | |
---|
45 | /********************************************************************** |
---|
46 | ********************************************************************** |
---|
47 | *** |
---|
48 | *** Table syn3StatisticsTable |
---|
49 | *** |
---|
50 | ********************************************************************** |
---|
51 | **********************************************************************/ |
---|
52 | /* |
---|
53 | * SYN3-MIB::syn3StatisticsTable is subid 1 of syn3Statistics. |
---|
54 | * Its status is Current. |
---|
55 | * OID: .1.3.6.1.4.1.31337.1.3.1, length: 10 |
---|
56 | */ |
---|
57 | typedef struct syn3StatisticsTable_interface_ctx_s { |
---|
58 | |
---|
59 | netsnmp_container *container; |
---|
60 | netsnmp_cache *cache; |
---|
61 | |
---|
62 | syn3StatisticsTable_registration * user_ctx; |
---|
63 | |
---|
64 | netsnmp_table_registration_info tbl_info; |
---|
65 | |
---|
66 | netsnmp_baby_steps_access_methods access_multiplexer; |
---|
67 | |
---|
68 | } syn3StatisticsTable_interface_ctx; |
---|
69 | |
---|
70 | static syn3StatisticsTable_interface_ctx syn3StatisticsTable_if_ctx; |
---|
71 | |
---|
72 | static void _syn3StatisticsTable_container_init( |
---|
73 | syn3StatisticsTable_interface_ctx *if_ctx); |
---|
74 | static void _syn3StatisticsTable_container_shutdown( |
---|
75 | syn3StatisticsTable_interface_ctx *if_ctx); |
---|
76 | |
---|
77 | |
---|
78 | netsnmp_container * |
---|
79 | syn3StatisticsTable_container_get( void ) |
---|
80 | { |
---|
81 | return syn3StatisticsTable_if_ctx.container; |
---|
82 | } |
---|
83 | |
---|
84 | syn3StatisticsTable_registration * |
---|
85 | syn3StatisticsTable_registration_get( void ) |
---|
86 | { |
---|
87 | return syn3StatisticsTable_if_ctx.user_ctx; |
---|
88 | } |
---|
89 | |
---|
90 | syn3StatisticsTable_registration * |
---|
91 | syn3StatisticsTable_registration_set( syn3StatisticsTable_registration * newreg ) |
---|
92 | { |
---|
93 | syn3StatisticsTable_registration * old = syn3StatisticsTable_if_ctx.user_ctx; |
---|
94 | syn3StatisticsTable_if_ctx.user_ctx = newreg; |
---|
95 | return old; |
---|
96 | } |
---|
97 | |
---|
98 | int |
---|
99 | syn3StatisticsTable_container_size( void ) |
---|
100 | { |
---|
101 | return CONTAINER_SIZE(syn3StatisticsTable_if_ctx.container); |
---|
102 | } |
---|
103 | |
---|
104 | /* |
---|
105 | * mfd multiplexer modes |
---|
106 | */ |
---|
107 | static Netsnmp_Node_Handler _mfd_syn3StatisticsTable_pre_request; |
---|
108 | static Netsnmp_Node_Handler _mfd_syn3StatisticsTable_post_request; |
---|
109 | static Netsnmp_Node_Handler _mfd_syn3StatisticsTable_object_lookup; |
---|
110 | static Netsnmp_Node_Handler _mfd_syn3StatisticsTable_get_values; |
---|
111 | /** |
---|
112 | * @internal |
---|
113 | * Initialize the table syn3StatisticsTable |
---|
114 | * (Define its contents and how it's structured) |
---|
115 | */ |
---|
116 | void |
---|
117 | _syn3StatisticsTable_initialize_interface(syn3StatisticsTable_registration * reg_ptr, u_long flags) |
---|
118 | { |
---|
119 | netsnmp_baby_steps_access_methods *access_multiplexer = |
---|
120 | &syn3StatisticsTable_if_ctx.access_multiplexer; |
---|
121 | netsnmp_table_registration_info *tbl_info = &syn3StatisticsTable_if_ctx.tbl_info; |
---|
122 | netsnmp_handler_registration *reginfo; |
---|
123 | netsnmp_mib_handler *handler; |
---|
124 | int mfd_modes = 0; |
---|
125 | |
---|
126 | DEBUGMSGTL(("internal:syn3StatisticsTable:_syn3StatisticsTable_initialize_interface","called\n")); |
---|
127 | |
---|
128 | |
---|
129 | /************************************************* |
---|
130 | * |
---|
131 | * save interface context for syn3StatisticsTable |
---|
132 | */ |
---|
133 | /* |
---|
134 | * Setting up the table's definition |
---|
135 | */ |
---|
136 | netsnmp_table_helper_add_indexes(tbl_info, |
---|
137 | ASN_OCTET_STR, /** index: syn3StatisticsName */ |
---|
138 | 0); |
---|
139 | |
---|
140 | /* Define the minimum and maximum accessible columns. This |
---|
141 | optimizes retrival. */ |
---|
142 | tbl_info->min_column = SYN3STATISTICSTABLE_MIN_COL; |
---|
143 | tbl_info->max_column = SYN3STATISTICSTABLE_MAX_COL; |
---|
144 | |
---|
145 | /* |
---|
146 | * save users context |
---|
147 | */ |
---|
148 | syn3StatisticsTable_if_ctx.user_ctx = reg_ptr; |
---|
149 | |
---|
150 | /* |
---|
151 | * call data access initialization code |
---|
152 | */ |
---|
153 | syn3StatisticsTable_init_data(reg_ptr); |
---|
154 | |
---|
155 | /* |
---|
156 | * set up the container |
---|
157 | */ |
---|
158 | _syn3StatisticsTable_container_init(&syn3StatisticsTable_if_ctx); |
---|
159 | if (NULL == syn3StatisticsTable_if_ctx.container) { |
---|
160 | snmp_log(LOG_ERR,"could not initialize container for syn3StatisticsTable\n"); |
---|
161 | return; |
---|
162 | } |
---|
163 | |
---|
164 | /* |
---|
165 | * access_multiplexer: REQUIRED wrapper for get request handling |
---|
166 | */ |
---|
167 | access_multiplexer->object_lookup = _mfd_syn3StatisticsTable_object_lookup; |
---|
168 | access_multiplexer->get_values = _mfd_syn3StatisticsTable_get_values; |
---|
169 | |
---|
170 | /* |
---|
171 | * no wrappers yet |
---|
172 | */ |
---|
173 | access_multiplexer->pre_request = _mfd_syn3StatisticsTable_pre_request; |
---|
174 | access_multiplexer->post_request = _mfd_syn3StatisticsTable_post_request; |
---|
175 | |
---|
176 | |
---|
177 | /************************************************* |
---|
178 | * |
---|
179 | * Create a registration, save our reg data, register table. |
---|
180 | */ |
---|
181 | DEBUGMSGTL(("syn3StatisticsTable:init_syn3StatisticsTable", |
---|
182 | "Registering syn3StatisticsTable as a mibs-for-dummies table.\n")); |
---|
183 | handler = netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); |
---|
184 | reginfo = netsnmp_handler_registration_create("syn3StatisticsTable", handler, |
---|
185 | syn3StatisticsTable_oid, |
---|
186 | syn3StatisticsTable_oid_size, |
---|
187 | HANDLER_CAN_BABY_STEP | |
---|
188 | HANDLER_CAN_RONLY |
---|
189 | ); |
---|
190 | if(NULL == reginfo) { |
---|
191 | snmp_log(LOG_ERR,"error registering table syn3StatisticsTable\n"); |
---|
192 | return; |
---|
193 | } |
---|
194 | reginfo->my_reg_void = &syn3StatisticsTable_if_ctx; |
---|
195 | |
---|
196 | /************************************************* |
---|
197 | * |
---|
198 | * set up baby steps handler, create it and inject it |
---|
199 | */ |
---|
200 | if( access_multiplexer->object_lookup ) |
---|
201 | mfd_modes |= BABY_STEP_OBJECT_LOOKUP; |
---|
202 | if( access_multiplexer->set_values ) |
---|
203 | mfd_modes |= BABY_STEP_SET_VALUES; |
---|
204 | if( access_multiplexer->irreversible_commit ) |
---|
205 | mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT; |
---|
206 | if( access_multiplexer->object_syntax_checks ) |
---|
207 | mfd_modes |= BABY_STEP_CHECK_OBJECT; |
---|
208 | |
---|
209 | if( access_multiplexer->pre_request ) |
---|
210 | mfd_modes |= BABY_STEP_PRE_REQUEST; |
---|
211 | if( access_multiplexer->post_request ) |
---|
212 | mfd_modes |= BABY_STEP_POST_REQUEST; |
---|
213 | |
---|
214 | if( access_multiplexer->undo_setup ) |
---|
215 | mfd_modes |= BABY_STEP_UNDO_SETUP; |
---|
216 | if( access_multiplexer->undo_cleanup ) |
---|
217 | mfd_modes |= BABY_STEP_UNDO_CLEANUP; |
---|
218 | if( access_multiplexer->undo_sets ) |
---|
219 | mfd_modes |= BABY_STEP_UNDO_SETS; |
---|
220 | |
---|
221 | if( access_multiplexer->row_creation ) |
---|
222 | mfd_modes |= BABY_STEP_ROW_CREATE; |
---|
223 | if( access_multiplexer->consistency_checks ) |
---|
224 | mfd_modes |= BABY_STEP_CHECK_CONSISTENCY; |
---|
225 | if( access_multiplexer->commit ) |
---|
226 | mfd_modes |= BABY_STEP_COMMIT; |
---|
227 | if( access_multiplexer->undo_commit ) |
---|
228 | mfd_modes |= BABY_STEP_UNDO_COMMIT; |
---|
229 | |
---|
230 | handler = netsnmp_baby_steps_handler_get(mfd_modes); |
---|
231 | netsnmp_inject_handler(reginfo, handler); |
---|
232 | |
---|
233 | /************************************************* |
---|
234 | * |
---|
235 | * inject row_merge helper with prefix rootoid_len + 2 (entry.col) |
---|
236 | */ |
---|
237 | handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2); |
---|
238 | netsnmp_inject_handler(reginfo, handler); |
---|
239 | |
---|
240 | /************************************************* |
---|
241 | * |
---|
242 | * inject container_table helper |
---|
243 | */ |
---|
244 | handler = |
---|
245 | netsnmp_container_table_handler_get(tbl_info, |
---|
246 | syn3StatisticsTable_if_ctx.container, |
---|
247 | TABLE_CONTAINER_KEY_NETSNMP_INDEX); |
---|
248 | netsnmp_inject_handler( reginfo, handler ); |
---|
249 | |
---|
250 | /************************************************* |
---|
251 | * |
---|
252 | * inject cache helper |
---|
253 | */ |
---|
254 | if(NULL != syn3StatisticsTable_if_ctx.cache) { |
---|
255 | handler = netsnmp_cache_handler_get(syn3StatisticsTable_if_ctx.cache); |
---|
256 | netsnmp_inject_handler( reginfo, handler ); |
---|
257 | } |
---|
258 | |
---|
259 | /* |
---|
260 | * register table |
---|
261 | */ |
---|
262 | netsnmp_register_table(reginfo, tbl_info); |
---|
263 | |
---|
264 | } /* _syn3StatisticsTable_initialize_interface */ |
---|
265 | |
---|
266 | /** |
---|
267 | * @internal |
---|
268 | * Shutdown the table syn3StatisticsTable |
---|
269 | */ |
---|
270 | void |
---|
271 | _syn3StatisticsTable_shutdown_interface(syn3StatisticsTable_registration * reg_ptr) |
---|
272 | { |
---|
273 | /* |
---|
274 | * shutdown the container |
---|
275 | */ |
---|
276 | _syn3StatisticsTable_container_shutdown(&syn3StatisticsTable_if_ctx); |
---|
277 | } |
---|
278 | |
---|
279 | void |
---|
280 | syn3StatisticsTable_valid_columns_set(netsnmp_column_info *vc) |
---|
281 | { |
---|
282 | syn3StatisticsTable_if_ctx.tbl_info.valid_columns = vc; |
---|
283 | } /* syn3StatisticsTable_valid_columns_set */ |
---|
284 | |
---|
285 | /** |
---|
286 | * @internal |
---|
287 | * convert the index component stored in the context to an oid |
---|
288 | */ |
---|
289 | int |
---|
290 | syn3StatisticsTable_index_to_oid(netsnmp_index *oid_idx, |
---|
291 | syn3StatisticsTable_mib_index *mib_idx) |
---|
292 | { |
---|
293 | int err = SNMP_ERR_NOERROR; |
---|
294 | |
---|
295 | /* |
---|
296 | * temp storage for parsing indexes |
---|
297 | */ |
---|
298 | /* |
---|
299 | * syn3StatisticsName(1)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H |
---|
300 | */ |
---|
301 | netsnmp_variable_list var_syn3StatisticsName; |
---|
302 | |
---|
303 | /* |
---|
304 | * set up varbinds |
---|
305 | */ |
---|
306 | memset( &var_syn3StatisticsName, 0x00, sizeof(var_syn3StatisticsName) ); |
---|
307 | var_syn3StatisticsName.type = ASN_OCTET_STR; |
---|
308 | |
---|
309 | /* |
---|
310 | * chain temp index varbinds together |
---|
311 | */ |
---|
312 | var_syn3StatisticsName.next_variable = NULL; |
---|
313 | |
---|
314 | |
---|
315 | DEBUGMSGTL(("verbose:syn3StatisticsTable:syn3StatisticsTable_index_to_oid","called\n")); |
---|
316 | |
---|
317 | /* syn3StatisticsName(1)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H */ |
---|
318 | snmp_set_var_value(&var_syn3StatisticsName, (u_char*)&mib_idx->syn3StatisticsName, |
---|
319 | mib_idx->syn3StatisticsName_len * sizeof(mib_idx->syn3StatisticsName[0])); |
---|
320 | |
---|
321 | |
---|
322 | err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len, |
---|
323 | NULL, 0, &var_syn3StatisticsName); |
---|
324 | if(err) |
---|
325 | snmp_log(LOG_ERR,"error %d converting index to oid\n", err); |
---|
326 | |
---|
327 | /* |
---|
328 | * parsing may have allocated memory. free it. |
---|
329 | */ |
---|
330 | snmp_reset_var_buffers( &var_syn3StatisticsName ); |
---|
331 | |
---|
332 | return err; |
---|
333 | } /* syn3StatisticsTable_index_to_oid */ |
---|
334 | |
---|
335 | /** |
---|
336 | * extract syn3StatisticsTable indexes from a netsnmp_index |
---|
337 | * |
---|
338 | * @retval SNMP_ERR_NOERROR : no error |
---|
339 | * @retval SNMP_ERR_GENERR : error |
---|
340 | */ |
---|
341 | int |
---|
342 | syn3StatisticsTable_index_from_oid(netsnmp_index *oid_idx, |
---|
343 | syn3StatisticsTable_mib_index *mib_idx) |
---|
344 | { |
---|
345 | int err = SNMP_ERR_NOERROR; |
---|
346 | |
---|
347 | /* |
---|
348 | * temp storage for parsing indexes |
---|
349 | */ |
---|
350 | /* |
---|
351 | * syn3StatisticsName(1)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H |
---|
352 | */ |
---|
353 | netsnmp_variable_list var_syn3StatisticsName; |
---|
354 | |
---|
355 | /* |
---|
356 | * set up varbinds |
---|
357 | */ |
---|
358 | memset( &var_syn3StatisticsName, 0x00, sizeof(var_syn3StatisticsName) ); |
---|
359 | var_syn3StatisticsName.type = ASN_OCTET_STR; |
---|
360 | |
---|
361 | /* |
---|
362 | * chain temp index varbinds together |
---|
363 | */ |
---|
364 | var_syn3StatisticsName.next_variable = NULL; |
---|
365 | |
---|
366 | |
---|
367 | DEBUGMSGTL(("verbose:syn3StatisticsTable:syn3StatisticsTable_index_from_oid","called\n")); |
---|
368 | |
---|
369 | /* |
---|
370 | * parse the oid into the individual index components |
---|
371 | */ |
---|
372 | err = parse_oid_indexes( oid_idx->oids, oid_idx->len, |
---|
373 | &var_syn3StatisticsName ); |
---|
374 | if (err == SNMP_ERR_NOERROR) { |
---|
375 | /* |
---|
376 | * copy out values |
---|
377 | */ |
---|
378 | /* |
---|
379 | * NOTE: val_len is in bytes, syn3StatisticsName_len might not be |
---|
380 | */ |
---|
381 | if(var_syn3StatisticsName.val_len > sizeof(mib_idx->syn3StatisticsName)) |
---|
382 | err = SNMP_ERR_GENERR; |
---|
383 | else { |
---|
384 | memcpy(mib_idx->syn3StatisticsName, var_syn3StatisticsName.val.string, var_syn3StatisticsName.val_len); |
---|
385 | mib_idx->syn3StatisticsName_len = var_syn3StatisticsName.val_len / sizeof(mib_idx->syn3StatisticsName[0]); |
---|
386 | } |
---|
387 | |
---|
388 | |
---|
389 | } |
---|
390 | |
---|
391 | /* |
---|
392 | * parsing may have allocated memory. free it. |
---|
393 | */ |
---|
394 | snmp_reset_var_buffers( &var_syn3StatisticsName ); |
---|
395 | |
---|
396 | return err; |
---|
397 | } /* syn3StatisticsTable_index_from_oid */ |
---|
398 | |
---|
399 | |
---|
400 | /* ********************************************************************* |
---|
401 | * @internal |
---|
402 | * allocate resources for a syn3StatisticsTable_rowreq_ctx |
---|
403 | */ |
---|
404 | syn3StatisticsTable_rowreq_ctx * |
---|
405 | syn3StatisticsTable_allocate_rowreq_ctx(void *user_init_ctx) |
---|
406 | { |
---|
407 | syn3StatisticsTable_rowreq_ctx *rowreq_ctx = |
---|
408 | SNMP_MALLOC_TYPEDEF(syn3StatisticsTable_rowreq_ctx); |
---|
409 | |
---|
410 | DEBUGMSGTL(("internal:syn3StatisticsTable:syn3StatisticsTable_allocate_rowreq_ctx","called\n")); |
---|
411 | |
---|
412 | if(NULL == rowreq_ctx) { |
---|
413 | snmp_log(LOG_ERR,"Couldn't allocate memory for a " |
---|
414 | "syn3StatisticsTable_rowreq_ctx.\n"); |
---|
415 | return NULL; |
---|
416 | } |
---|
417 | |
---|
418 | rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp; |
---|
419 | |
---|
420 | rowreq_ctx->syn3StatisticsTable_data_list = NULL; |
---|
421 | |
---|
422 | /* |
---|
423 | * if we allocated data, call init routine |
---|
424 | */ |
---|
425 | if (!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) { |
---|
426 | if(SNMPERR_SUCCESS != |
---|
427 | syn3StatisticsTable_rowreq_ctx_init(rowreq_ctx, user_init_ctx)) { |
---|
428 | syn3StatisticsTable_release_rowreq_ctx(rowreq_ctx); |
---|
429 | rowreq_ctx = NULL; |
---|
430 | } |
---|
431 | } |
---|
432 | |
---|
433 | return rowreq_ctx; |
---|
434 | } /* syn3StatisticsTable_allocate_rowreq_ctx */ |
---|
435 | |
---|
436 | /* |
---|
437 | * @internal |
---|
438 | * release resources for a syn3StatisticsTable_rowreq_ctx |
---|
439 | */ |
---|
440 | void |
---|
441 | syn3StatisticsTable_release_rowreq_ctx(syn3StatisticsTable_rowreq_ctx *rowreq_ctx) |
---|
442 | { |
---|
443 | DEBUGMSGTL(("internal:syn3StatisticsTable:syn3StatisticsTable_release_rowreq_ctx","called\n")); |
---|
444 | |
---|
445 | netsnmp_assert(NULL != rowreq_ctx); |
---|
446 | |
---|
447 | syn3StatisticsTable_rowreq_ctx_cleanup(rowreq_ctx); |
---|
448 | |
---|
449 | /* |
---|
450 | * free index oid pointer |
---|
451 | */ |
---|
452 | if(rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp) |
---|
453 | free(rowreq_ctx->oid_idx.oids); |
---|
454 | |
---|
455 | SNMP_FREE(rowreq_ctx); |
---|
456 | } /* syn3StatisticsTable_release_rowreq_ctx */ |
---|
457 | |
---|
458 | /** |
---|
459 | * @internal |
---|
460 | * wrapper |
---|
461 | */ |
---|
462 | static int |
---|
463 | _mfd_syn3StatisticsTable_pre_request(netsnmp_mib_handler *handler, |
---|
464 | netsnmp_handler_registration *reginfo, |
---|
465 | netsnmp_agent_request_info *agtreq_info, |
---|
466 | netsnmp_request_info *requests) |
---|
467 | { |
---|
468 | int rc; |
---|
469 | |
---|
470 | DEBUGMSGTL(("internal:syn3StatisticsTable:_mfd_syn3StatisticsTable_pre_request", |
---|
471 | "called\n")); |
---|
472 | |
---|
473 | if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) { |
---|
474 | DEBUGMSGTL(("internal:syn3StatisticsTable", |
---|
475 | "skipping additional pre_request\n")); |
---|
476 | return SNMP_ERR_NOERROR; |
---|
477 | } |
---|
478 | |
---|
479 | rc = syn3StatisticsTable_pre_request(syn3StatisticsTable_if_ctx.user_ctx); |
---|
480 | if (MFD_SUCCESS != rc) { |
---|
481 | /* |
---|
482 | * nothing we can do about it but log it |
---|
483 | */ |
---|
484 | DEBUGMSGTL(("syn3StatisticsTable","error %d from " |
---|
485 | "syn3StatisticsTable_pre_request\n", rc)); |
---|
486 | netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); |
---|
487 | } |
---|
488 | |
---|
489 | return SNMP_ERR_NOERROR; |
---|
490 | } /* _mfd_syn3StatisticsTable_pre_request */ |
---|
491 | |
---|
492 | /** |
---|
493 | * @internal |
---|
494 | * wrapper |
---|
495 | */ |
---|
496 | static int |
---|
497 | _mfd_syn3StatisticsTable_post_request(netsnmp_mib_handler *handler, |
---|
498 | netsnmp_handler_registration *reginfo, |
---|
499 | netsnmp_agent_request_info *agtreq_info, |
---|
500 | netsnmp_request_info *requests) |
---|
501 | { |
---|
502 | syn3StatisticsTable_rowreq_ctx *rowreq_ctx = |
---|
503 | netsnmp_container_table_row_extract(requests); |
---|
504 | int rc, packet_rc; |
---|
505 | |
---|
506 | DEBUGMSGTL(("internal:syn3StatisticsTable:_mfd_syn3StatisticsTable_post_request", |
---|
507 | "called\n")); |
---|
508 | |
---|
509 | /* |
---|
510 | * release row context, if deleted |
---|
511 | */ |
---|
512 | if (rowreq_ctx && (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED)) |
---|
513 | syn3StatisticsTable_release_rowreq_ctx(rowreq_ctx); |
---|
514 | |
---|
515 | /* |
---|
516 | * wait for last call before calling user |
---|
517 | */ |
---|
518 | if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) { |
---|
519 | DEBUGMSGTL(("internal:syn3StatisticsTable", |
---|
520 | "waiting for last post_request\n")); |
---|
521 | return SNMP_ERR_NOERROR; |
---|
522 | } |
---|
523 | |
---|
524 | packet_rc = netsnmp_check_all_requests_error(agtreq_info->asp, 0); |
---|
525 | rc = syn3StatisticsTable_post_request(syn3StatisticsTable_if_ctx.user_ctx,packet_rc); |
---|
526 | if (MFD_SUCCESS != rc) { |
---|
527 | /* |
---|
528 | * nothing we can do about it but log it |
---|
529 | */ |
---|
530 | DEBUGMSGTL(("syn3StatisticsTable","error %d from " |
---|
531 | "syn3StatisticsTable_post_request\n", rc)); |
---|
532 | } |
---|
533 | |
---|
534 | return SNMP_ERR_NOERROR; |
---|
535 | } /* _mfd_syn3StatisticsTable_post_request */ |
---|
536 | |
---|
537 | /** |
---|
538 | * @internal |
---|
539 | * wrapper |
---|
540 | */ |
---|
541 | static int |
---|
542 | _mfd_syn3StatisticsTable_object_lookup(netsnmp_mib_handler *handler, |
---|
543 | netsnmp_handler_registration *reginfo, |
---|
544 | netsnmp_agent_request_info *agtreq_info, |
---|
545 | netsnmp_request_info *requests) |
---|
546 | { |
---|
547 | int rc = SNMP_ERR_NOERROR; |
---|
548 | syn3StatisticsTable_rowreq_ctx *rowreq_ctx = |
---|
549 | netsnmp_container_table_row_extract(requests); |
---|
550 | |
---|
551 | DEBUGMSGTL(("internal:syn3StatisticsTable:_mfd_syn3StatisticsTable_object_lookup","called\n")); |
---|
552 | |
---|
553 | /* |
---|
554 | * get our context from mfd |
---|
555 | * syn3StatisticsTable_interface_ctx *if_ctx = |
---|
556 | * (syn3StatisticsTable_interface_ctx *)reginfo->my_reg_void; |
---|
557 | */ |
---|
558 | |
---|
559 | if(NULL == rowreq_ctx) { |
---|
560 | rc = SNMP_ERR_NOCREATION; |
---|
561 | } |
---|
562 | |
---|
563 | if (MFD_SUCCESS != rc) |
---|
564 | netsnmp_request_set_error_all(requests, rc); |
---|
565 | else |
---|
566 | syn3StatisticsTable_row_prep(rowreq_ctx); |
---|
567 | |
---|
568 | return SNMP_VALIDATE_ERR(rc); |
---|
569 | } /* _mfd_syn3StatisticsTable_object_lookup */ |
---|
570 | |
---|
571 | /*********************************************************************** |
---|
572 | * |
---|
573 | * GET processing |
---|
574 | * |
---|
575 | ***********************************************************************/ |
---|
576 | /* |
---|
577 | * @internal |
---|
578 | * Retrieve the value for a particular column |
---|
579 | */ |
---|
580 | NETSNMP_STATIC_INLINE int |
---|
581 | _syn3StatisticsTable_get_column( syn3StatisticsTable_rowreq_ctx *rowreq_ctx, |
---|
582 | netsnmp_variable_list *var, int column ) |
---|
583 | { |
---|
584 | int rc = SNMPERR_SUCCESS; |
---|
585 | |
---|
586 | DEBUGMSGTL(("internal:syn3StatisticsTable:_mfd_syn3StatisticsTable_get_column", |
---|
587 | "called for %d\n", column)); |
---|
588 | |
---|
589 | |
---|
590 | netsnmp_assert(NULL != rowreq_ctx); |
---|
591 | |
---|
592 | switch(column) { |
---|
593 | |
---|
594 | /* (INDEX) syn3StatisticsName(1)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H */ |
---|
595 | case COLUMN_SYN3STATISTICSNAME: |
---|
596 | var->type = ASN_OCTET_STR; |
---|
597 | /* |
---|
598 | * NOTE: val_len is in bytes, syn3StatisticsName_len might not be (e.g. oids) |
---|
599 | */ |
---|
600 | if (var->val_len < (rowreq_ctx->tbl_idx.syn3StatisticsName_len * |
---|
601 | sizeof(rowreq_ctx->tbl_idx.syn3StatisticsName[0]))) { |
---|
602 | var->val.string = malloc(rowreq_ctx->tbl_idx.syn3StatisticsName_len * |
---|
603 | sizeof(rowreq_ctx->tbl_idx.syn3StatisticsName[0])); |
---|
604 | } |
---|
605 | var->val_len = rowreq_ctx->tbl_idx.syn3StatisticsName_len * sizeof(rowreq_ctx->tbl_idx.syn3StatisticsName[0]); |
---|
606 | memcpy( var->val.string, rowreq_ctx->tbl_idx.syn3StatisticsName, var->val_len ); |
---|
607 | break; |
---|
608 | |
---|
609 | /* syn3StatisticsValue1(2)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ |
---|
610 | case COLUMN_SYN3STATISTICSVALUE1: |
---|
611 | var->val_len = sizeof(long); |
---|
612 | var->type = ASN_INTEGER; |
---|
613 | rc = syn3StatisticsValue1_get(rowreq_ctx, (long *)var->val.string ); |
---|
614 | break; |
---|
615 | |
---|
616 | /* syn3StatisticsValue2(3)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ |
---|
617 | case COLUMN_SYN3STATISTICSVALUE2: |
---|
618 | var->val_len = sizeof(long); |
---|
619 | var->type = ASN_INTEGER; |
---|
620 | rc = syn3StatisticsValue2_get(rowreq_ctx, (long *)var->val.string ); |
---|
621 | break; |
---|
622 | |
---|
623 | /* syn3StatisticsValue3(4)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ |
---|
624 | case COLUMN_SYN3STATISTICSVALUE3: |
---|
625 | var->val_len = sizeof(long); |
---|
626 | var->type = ASN_INTEGER; |
---|
627 | rc = syn3StatisticsValue3_get(rowreq_ctx, (long *)var->val.string ); |
---|
628 | break; |
---|
629 | |
---|
630 | /* syn3StatisticsValue4(5)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ |
---|
631 | case COLUMN_SYN3STATISTICSVALUE4: |
---|
632 | var->val_len = sizeof(long); |
---|
633 | var->type = ASN_INTEGER; |
---|
634 | rc = syn3StatisticsValue4_get(rowreq_ctx, (long *)var->val.string ); |
---|
635 | break; |
---|
636 | |
---|
637 | /* syn3StatisticsValue5(6)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ |
---|
638 | case COLUMN_SYN3STATISTICSVALUE5: |
---|
639 | var->val_len = sizeof(long); |
---|
640 | var->type = ASN_INTEGER; |
---|
641 | rc = syn3StatisticsValue5_get(rowreq_ctx, (long *)var->val.string ); |
---|
642 | break; |
---|
643 | |
---|
644 | default: |
---|
645 | if (SYN3STATISTICSTABLE_MIN_COL <= column && column <= SYN3STATISTICSTABLE_MAX_COL) { |
---|
646 | DEBUGMSGTL(("internal:syn3StatisticsTable:_mfd_syn3StatisticsTable_get_column", |
---|
647 | "assume column %d is reserved\n", column)); |
---|
648 | rc = MFD_SKIP; |
---|
649 | } else { |
---|
650 | snmp_log(LOG_ERR, |
---|
651 | "unknown column %d in _syn3StatisticsTable_get_column\n", column); |
---|
652 | } |
---|
653 | break; |
---|
654 | } |
---|
655 | |
---|
656 | return rc; |
---|
657 | } /* _syn3StatisticsTable_get_column */ |
---|
658 | |
---|
659 | int |
---|
660 | _mfd_syn3StatisticsTable_get_values(netsnmp_mib_handler *handler, |
---|
661 | netsnmp_handler_registration *reginfo, |
---|
662 | netsnmp_agent_request_info *agtreq_info, |
---|
663 | netsnmp_request_info *requests) |
---|
664 | { |
---|
665 | syn3StatisticsTable_rowreq_ctx *rowreq_ctx = |
---|
666 | netsnmp_container_table_row_extract(requests); |
---|
667 | netsnmp_table_request_info * tri; |
---|
668 | u_char * old_string; |
---|
669 | void (*dataFreeHook)(void *); |
---|
670 | int rc; |
---|
671 | |
---|
672 | DEBUGMSGTL(("internal:syn3StatisticsTable:_mfd_syn3StatisticsTable_get_values","called\n")); |
---|
673 | |
---|
674 | netsnmp_assert(NULL != rowreq_ctx); |
---|
675 | |
---|
676 | for(;requests; requests = requests->next) { |
---|
677 | /* |
---|
678 | * save old pointer, so we can free it if replaced |
---|
679 | */ |
---|
680 | old_string = requests->requestvb->val.string; |
---|
681 | dataFreeHook = requests->requestvb->dataFreeHook; |
---|
682 | if(NULL == requests->requestvb->val.string) { |
---|
683 | requests->requestvb->val.string = requests->requestvb->buf; |
---|
684 | requests->requestvb->val_len = sizeof(requests->requestvb->buf); |
---|
685 | } |
---|
686 | else if(requests->requestvb->buf == requests->requestvb->val.string) { |
---|
687 | if(requests->requestvb->val_len != sizeof(requests->requestvb->buf)) |
---|
688 | requests->requestvb->val_len = sizeof(requests->requestvb->buf); |
---|
689 | } |
---|
690 | |
---|
691 | /* |
---|
692 | * get column data |
---|
693 | */ |
---|
694 | tri = netsnmp_extract_table_info(requests); |
---|
695 | if(NULL == tri) |
---|
696 | continue; |
---|
697 | |
---|
698 | rc = _syn3StatisticsTable_get_column(rowreq_ctx, requests->requestvb, tri->colnum); |
---|
699 | if(rc) { |
---|
700 | if(MFD_SKIP == rc) { |
---|
701 | requests->requestvb->type = SNMP_NOSUCHINSTANCE; |
---|
702 | rc = SNMP_ERR_NOERROR; |
---|
703 | } |
---|
704 | } |
---|
705 | else if (NULL == requests->requestvb->val.string) { |
---|
706 | snmp_log(LOG_ERR,"NULL varbind data pointer!\n"); |
---|
707 | rc = SNMP_ERR_GENERR; |
---|
708 | } |
---|
709 | if(rc) |
---|
710 | netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); |
---|
711 | |
---|
712 | /* |
---|
713 | * if the buffer wasn't used previously for the old data (i.e. it |
---|
714 | * was allcoated memory) and the get routine replaced the pointer, |
---|
715 | * we need to free the previous pointer. |
---|
716 | */ |
---|
717 | if(old_string && (old_string != requests->requestvb->buf) && |
---|
718 | (requests->requestvb->val.string != old_string)) { |
---|
719 | if(dataFreeHook) |
---|
720 | (*dataFreeHook)(old_string); |
---|
721 | else |
---|
722 | free(old_string); |
---|
723 | } |
---|
724 | } /* for results */ |
---|
725 | |
---|
726 | return SNMP_ERR_NOERROR; |
---|
727 | } /* _mfd_syn3StatisticsTable_get_values */ |
---|
728 | |
---|
729 | |
---|
730 | /*********************************************************************** |
---|
731 | * |
---|
732 | * SET processing |
---|
733 | * |
---|
734 | ***********************************************************************/ |
---|
735 | |
---|
736 | /* |
---|
737 | * SET PROCESSING NOT APPLICABLE (per MIB or user setting) |
---|
738 | */ |
---|
739 | /*********************************************************************** |
---|
740 | * |
---|
741 | * DATA ACCESS |
---|
742 | * |
---|
743 | ***********************************************************************/ |
---|
744 | static void _container_free(netsnmp_container *container); |
---|
745 | |
---|
746 | /** |
---|
747 | * @internal |
---|
748 | */ |
---|
749 | static int |
---|
750 | _cache_load(netsnmp_cache *cache, void *vmagic) |
---|
751 | { |
---|
752 | DEBUGMSGTL(("internal:syn3StatisticsTable:_cache_load","called\n")); |
---|
753 | |
---|
754 | if((NULL == cache) || (NULL == cache->magic)) { |
---|
755 | snmp_log(LOG_ERR, "invalid cache for syn3StatisticsTable_cache_load\n"); |
---|
756 | return -1; |
---|
757 | } |
---|
758 | |
---|
759 | /** should only be called for an invalid or expired cache */ |
---|
760 | netsnmp_assert((0 == cache->valid) || (1 == cache->expired)); |
---|
761 | |
---|
762 | /* |
---|
763 | * call user code |
---|
764 | */ |
---|
765 | return syn3StatisticsTable_container_load((netsnmp_container*)cache->magic); |
---|
766 | } /* _cache_load */ |
---|
767 | |
---|
768 | /** |
---|
769 | * @internal |
---|
770 | */ |
---|
771 | static void |
---|
772 | _cache_free(netsnmp_cache *cache, void *magic) |
---|
773 | { |
---|
774 | netsnmp_container *container; |
---|
775 | |
---|
776 | DEBUGMSGTL(("internal:syn3StatisticsTable:_cache_free","called\n")); |
---|
777 | |
---|
778 | if((NULL == cache) || (NULL == cache->magic)) { |
---|
779 | snmp_log(LOG_ERR, "invalid cache in syn3StatisticsTable_cache_free\n"); |
---|
780 | return; |
---|
781 | } |
---|
782 | |
---|
783 | container = (netsnmp_container*)cache->magic; |
---|
784 | |
---|
785 | _container_free(container); |
---|
786 | } /* _cache_free */ |
---|
787 | |
---|
788 | /** |
---|
789 | * @internal |
---|
790 | */ |
---|
791 | static void |
---|
792 | _container_item_free(syn3StatisticsTable_rowreq_ctx *rowreq_ctx, void *context) |
---|
793 | { |
---|
794 | DEBUGMSGTL(("internal:syn3StatisticsTable:_container_item_free","called\n")); |
---|
795 | |
---|
796 | if(NULL == rowreq_ctx) |
---|
797 | return; |
---|
798 | |
---|
799 | syn3StatisticsTable_release_rowreq_ctx(rowreq_ctx); |
---|
800 | } /* _container_item_free */ |
---|
801 | |
---|
802 | /** |
---|
803 | * @internal |
---|
804 | */ |
---|
805 | static void |
---|
806 | _container_free(netsnmp_container *container) |
---|
807 | { |
---|
808 | DEBUGMSGTL(("internal:syn3StatisticsTable:_container_free","called\n")); |
---|
809 | |
---|
810 | if (NULL == container) { |
---|
811 | snmp_log(LOG_ERR, "invalid container in syn3StatisticsTable_container_free\n"); |
---|
812 | return; |
---|
813 | } |
---|
814 | |
---|
815 | /* |
---|
816 | * call user code |
---|
817 | */ |
---|
818 | syn3StatisticsTable_container_free(container); |
---|
819 | |
---|
820 | /* |
---|
821 | * free all items. inefficient, but easy. |
---|
822 | */ |
---|
823 | CONTAINER_CLEAR(container, |
---|
824 | (netsnmp_container_obj_func *)_container_item_free, |
---|
825 | NULL); |
---|
826 | } /* _container_free */ |
---|
827 | |
---|
828 | /** |
---|
829 | * @internal |
---|
830 | * initialize the container with functions or wrappers |
---|
831 | */ |
---|
832 | void |
---|
833 | _syn3StatisticsTable_container_init(syn3StatisticsTable_interface_ctx *if_ctx) |
---|
834 | { |
---|
835 | DEBUGMSGTL(("internal:syn3StatisticsTable:_syn3StatisticsTable_container_init","called\n")); |
---|
836 | |
---|
837 | /* |
---|
838 | * cache init |
---|
839 | */ |
---|
840 | if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */ |
---|
841 | _cache_load, _cache_free, |
---|
842 | syn3StatisticsTable_oid, |
---|
843 | syn3StatisticsTable_oid_size); |
---|
844 | |
---|
845 | if(NULL == if_ctx->cache) { |
---|
846 | snmp_log(LOG_ERR, "error creating cache for syn3StatisticsTable\n"); |
---|
847 | return; |
---|
848 | } |
---|
849 | |
---|
850 | if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; |
---|
851 | |
---|
852 | syn3StatisticsTable_container_init(&if_ctx->container, if_ctx->cache); |
---|
853 | if(NULL == if_ctx->container) |
---|
854 | if_ctx->container = netsnmp_container_find("syn3StatisticsTable:table_container"); |
---|
855 | if(NULL == if_ctx->container) { |
---|
856 | snmp_log(LOG_ERR,"error creating container in " |
---|
857 | "syn3StatisticsTable_container_init\n"); |
---|
858 | return; |
---|
859 | } |
---|
860 | |
---|
861 | if (NULL != if_ctx->cache) |
---|
862 | if_ctx->cache->magic = (void*)if_ctx->container; |
---|
863 | } /* _syn3StatisticsTable_container_init */ |
---|
864 | |
---|
865 | /** |
---|
866 | * @internal |
---|
867 | * shutdown the container with functions or wrappers |
---|
868 | */ |
---|
869 | void |
---|
870 | _syn3StatisticsTable_container_shutdown(syn3StatisticsTable_interface_ctx *if_ctx) |
---|
871 | { |
---|
872 | DEBUGMSGTL(("internal:syn3StatisticsTable:_syn3StatisticsTable_container_shutdown","called\n")); |
---|
873 | |
---|
874 | syn3StatisticsTable_container_shutdown(if_ctx->container); |
---|
875 | |
---|
876 | _container_free(if_ctx->container); |
---|
877 | |
---|
878 | } /* _syn3StatisticsTable_container_shutdown */ |
---|
879 | |
---|
880 | |
---|
881 | syn3StatisticsTable_rowreq_ctx * |
---|
882 | syn3StatisticsTable_row_find_by_mib_index(syn3StatisticsTable_mib_index *mib_idx) |
---|
883 | { |
---|
884 | syn3StatisticsTable_rowreq_ctx *rowreq_ctx; |
---|
885 | oid oid_tmp[MAX_OID_LEN]; |
---|
886 | netsnmp_index oid_idx; |
---|
887 | int rc; |
---|
888 | |
---|
889 | /* |
---|
890 | * set up storage for OID |
---|
891 | */ |
---|
892 | oid_idx.oids = oid_tmp; |
---|
893 | oid_idx.len = sizeof(oid_tmp)/sizeof(oid); |
---|
894 | |
---|
895 | /* |
---|
896 | * convert |
---|
897 | */ |
---|
898 | rc = syn3StatisticsTable_index_to_oid(&oid_idx, mib_idx); |
---|
899 | if (MFD_SUCCESS != rc) |
---|
900 | return NULL; |
---|
901 | |
---|
902 | rowreq_ctx = CONTAINER_FIND(syn3StatisticsTable_if_ctx.container, &oid_idx); |
---|
903 | |
---|
904 | return rowreq_ctx; |
---|
905 | } |
---|
906 | |
---|