Debian Codegraph @

agent/mibgroup/ip-mib/ipSystemStatsTable/ipSystemStatsTable_interface.c

raw
1 /*
2 * Note: this file originally auto-generated by mib2c using
3 * version : 1.67 $ of : mfd-interface.m2c,v $
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 /*
30 * standard Net-SNMP includes
31 */
32 #include <net-snmp/net-snmp-config.h>
33 #include <net-snmp/net-snmp-features.h>
34 #include <net-snmp/net-snmp-includes.h>
35 #include <net-snmp/agent/net-snmp-agent-includes.h>
36
37 /*
38 * include our parent header
39 */
40 #include "ipSystemStatsTable.h"
41
42
43 #include <net-snmp/agent/table_container.h>
44 #include <net-snmp/library/container.h>
45
46 #include "ipSystemStatsTable_interface.h"
47
48 #include <ctype.h>
49
50 netsnmp_feature_child_of(ipSystemStatsTable_external_access, libnetsnmpmibs);
51
52 netsnmp_feature_require(row_merge);
53 netsnmp_feature_require(baby_steps);
54 netsnmp_feature_require(check_all_requests_error);
55
56
57 netsnmp_feature_child_of(ipSystemStatsTable_container_size, ipSystemStatsTable_external_access);
58 netsnmp_feature_child_of(ipSystemStatsTable_registration_set, ipSystemStatsTable_external_access);
59 netsnmp_feature_child_of(ipSystemStatsTable_registration_get, ipSystemStatsTable_external_access);
60 netsnmp_feature_child_of(ipSystemStatsTable_container_get, ipSystemStatsTable_external_access);
61
62 /**********************************************************************
63 **********************************************************************
64 ***
65 *** Table ipSystemStatsTable
66 ***
67 **********************************************************************
68 **********************************************************************/
69 /*
70 * IP-MIB::ipSystemStatsTable is subid 1 of ipTrafficStats.
71 * Its status is Current.
72 * OID: .1.3.6.1.2.1.4.31.1, length: 9
73 */
74 typedef struct ipSystemStatsTable_interface_ctx_s {
75
76 netsnmp_container *container;
77 netsnmp_cache *cache;
78
79 ipSystemStatsTable_registration *user_ctx;
80
81 netsnmp_table_registration_info tbl_info;
82
83 netsnmp_baby_steps_access_methods access_multiplexer;
84
85 } ipSystemStatsTable_interface_ctx;
86
87 static ipSystemStatsTable_interface_ctx ipSystemStatsTable_if_ctx;
88
89 static void
90 _ipSystemStatsTable_container_init(ipSystemStatsTable_interface_ctx *
91 if_ctx);
92 static void
93 _ipSystemStatsTable_container_shutdown(ipSystemStatsTable_interface_ctx *
94 if_ctx);
95
96 #ifndef NETSNMP_FEATURE_REMOVE_IPSYSTEMSTATSTABLE_CONTAINER_GET
97 netsnmp_container *
98 ipSystemStatsTable_container_get(void)
99 {
100 return ipSystemStatsTable_if_ctx.container;
101 }
102 #endif /* NETSNMP_FEATURE_REMOVE_IPSYSTEMSTATSTABLE_CONTAINER_GET */
103
104 #ifndef NETSNMP_FEATURE_REMOVE_IPSYSTEMSTATSTABLE_REGISTRATION_GET
105 ipSystemStatsTable_registration *
106 ipSystemStatsTable_registration_get(void)
107 {
108 return ipSystemStatsTable_if_ctx.user_ctx;
109 }
110 #endif /* NETSNMP_FEATURE_REMOVE_IPSYSTEMSTATSTABLE_REGISTRATION_GET */
111
112 #ifndef NETSNMP_FEATURE_REMOVE_IPSYSTEMSTATSTABLE_REGISTRATION_SET
113 ipSystemStatsTable_registration *
114 ipSystemStatsTable_registration_set(ipSystemStatsTable_registration *
115 newreg)
116 {
117 ipSystemStatsTable_registration *old =
118 ipSystemStatsTable_if_ctx.user_ctx;
119 ipSystemStatsTable_if_ctx.user_ctx = newreg;
120 return old;
121 }
122 #endif /* NETSNMP_FEATURE_REMOVE_IPSYSTEMSTATSTABLE_REGISTRATION_SET */
123
124 #ifndef NETSNMP_FEATURE_REMOVE_IPSYSTEMSTATSTABLE_CONTAINER_SIZE
125 int
126 ipSystemStatsTable_container_size(void)
127 {
128 return CONTAINER_SIZE(ipSystemStatsTable_if_ctx.container);
129 }
130 #endif /* NETSNMP_FEATURE_REMOVE_IPSYSTEMSTATSTABLE_CONTAINER_SIZE */
131
132 /*
133 * mfd multiplexer modes
134 */
135 static Netsnmp_Node_Handler _mfd_ipSystemStatsTable_pre_request;
136 static Netsnmp_Node_Handler _mfd_ipSystemStatsTable_post_request;
137 static Netsnmp_Node_Handler _mfd_ipSystemStatsTable_object_lookup;
138 static Netsnmp_Node_Handler _mfd_ipSystemStatsTable_get_values;
139 /**
140 * @internal
141 * Initialize the table ipSystemStatsTable
142 * (Define its contents and how it's structured)
143 */
144 void
145 _ipSystemStatsTable_initialize_interface(ipSystemStatsTable_registration *
146 reg_ptr, u_long flags)
147 {
148 netsnmp_baby_steps_access_methods *access_multiplexer =
149 &ipSystemStatsTable_if_ctx.access_multiplexer;
150 netsnmp_table_registration_info *tbl_info =
151 &ipSystemStatsTable_if_ctx.tbl_info;
152 netsnmp_handler_registration *reginfo;
153 netsnmp_mib_handler *handler;
154 int mfd_modes = 0;
155
156 DEBUGMSGTL(("internal:ipSystemStatsTable:_ipSystemStatsTable_initialize_interface", "called\n"));
157
158
159 /*************************************************
160 *
161 * save interface context for ipSystemStatsTable
162 */
163 /*
164 * Setting up the table's definition
165 */
166 netsnmp_table_helper_add_indexes(tbl_info, ASN_INTEGER,
167 /** index: ipSystemStatsIPVersion */
168 0);
169
170 /*
171 * Define the minimum and maximum accessible columns. This
172 * optimizes retrieval.
173 */
174 tbl_info->min_column = IPSYSTEMSTATSTABLE_MIN_COL;
175 tbl_info->max_column = IPSYSTEMSTATSTABLE_MAX_COL;
176
177 /*
178 * save users context
179 */
180 ipSystemStatsTable_if_ctx.user_ctx = reg_ptr;
181
182 /*
183 * call data access initialization code
184 */
185 ipSystemStatsTable_init_data(reg_ptr);
186
187 /*
188 * set up the container
189 */
190 _ipSystemStatsTable_container_init(&ipSystemStatsTable_if_ctx);
191 if (NULL == ipSystemStatsTable_if_ctx.container) {
192 snmp_log(LOG_ERR,
193 "could not initialize container for ipSystemStatsTable\n");
194 return;
195 }
196
197 /*
198 * access_multiplexer: REQUIRED wrapper for get request handling
199 */
200 access_multiplexer->object_lookup =
201 _mfd_ipSystemStatsTable_object_lookup;
202 access_multiplexer->get_values = _mfd_ipSystemStatsTable_get_values;
203
204 /*
205 * no wrappers yet
206 */
207 access_multiplexer->pre_request = _mfd_ipSystemStatsTable_pre_request;
208 access_multiplexer->post_request =
209 _mfd_ipSystemStatsTable_post_request;
210
211
212 /*************************************************
213 *
214 * Create a registration, save our reg data, register table.
215 */
216 DEBUGMSGTL(("ipSystemStatsTable:init_ipSystemStatsTable",
217 "Registering ipSystemStatsTable as a mibs-for-dummies table.\n"));
218 handler =
219 netsnmp_baby_steps_access_multiplexer_get(access_multiplexer);
220 reginfo =
221 netsnmp_handler_registration_create("ipSystemStatsTable", handler,
222 ipSystemStatsTable_oid,
223 ipSystemStatsTable_oid_size,
224 HANDLER_CAN_BABY_STEP |
225 HANDLER_CAN_RONLY);
226 if (NULL == reginfo) {
227 snmp_log(LOG_ERR, "error registering table ipSystemStatsTable\n");
228 return;
229 }
230 reginfo->my_reg_void = &ipSystemStatsTable_if_ctx;
231
232 /*************************************************
233 *
234 * set up baby steps handler, create it and inject it
235 */
236 if (access_multiplexer->object_lookup)
237 mfd_modes |= BABY_STEP_OBJECT_LOOKUP;
238 if (access_multiplexer->pre_request)
239 mfd_modes |= BABY_STEP_PRE_REQUEST;
240 if (access_multiplexer->post_request)
241 mfd_modes |= BABY_STEP_POST_REQUEST;
242
243 #if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT))
244 /* XXX - are these actually necessary? */
245 if (access_multiplexer->set_values)
246 mfd_modes |= BABY_STEP_SET_VALUES;
247 if (access_multiplexer->irreversible_commit)
248 mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT;
249 if (access_multiplexer->object_syntax_checks)
250 mfd_modes |= BABY_STEP_CHECK_OBJECT;
251
252 if (access_multiplexer->undo_setup)
253 mfd_modes |= BABY_STEP_UNDO_SETUP;
254 if (access_multiplexer->undo_cleanup)
255 mfd_modes |= BABY_STEP_UNDO_CLEANUP;
256 if (access_multiplexer->undo_sets)
257 mfd_modes |= BABY_STEP_UNDO_SETS;
258
259 if (access_multiplexer->row_creation)
260 mfd_modes |= BABY_STEP_ROW_CREATE;
261 if (access_multiplexer->consistency_checks)
262 mfd_modes |= BABY_STEP_CHECK_CONSISTENCY;
263 if (access_multiplexer->commit)
264 mfd_modes |= BABY_STEP_COMMIT;
265 if (access_multiplexer->undo_commit)
266 mfd_modes |= BABY_STEP_UNDO_COMMIT;
267 #endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */
268
269 handler = netsnmp_baby_steps_handler_get(mfd_modes);
270 netsnmp_inject_handler(reginfo, handler);
271
272 /*************************************************
273 *
274 * inject row_merge helper with prefix rootoid_len + 2 (entry.col)
275 */
276 handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2);
277 netsnmp_inject_handler(reginfo, handler);
278
279 /*************************************************
280 *
281 * inject container_table helper
282 */
283 handler =
284 netsnmp_container_table_handler_get(tbl_info,
285 ipSystemStatsTable_if_ctx.
286 container,
287 TABLE_CONTAINER_KEY_NETSNMP_INDEX);
288 netsnmp_inject_handler(reginfo, handler);
289
290 /*************************************************
291 *
292 * inject cache helper
293 */
294 if (NULL != ipSystemStatsTable_if_ctx.cache) {
295 handler =
296 netsnmp_cache_handler_get(ipSystemStatsTable_if_ctx.cache);
297 netsnmp_inject_handler(reginfo, handler);
298 }
299
300 /*
301 * register table
302 */
303 netsnmp_register_table(reginfo, tbl_info);
304
305 } /* _ipSystemStatsTable_initialize_interface */
306
307 /**
308 * @internal
309 * Shutdown the table ipSystemStatsTable
310 */
311 void
312 _ipSystemStatsTable_shutdown_interface(ipSystemStatsTable_registration *
313 reg_ptr)
314 {
315 /*
316 * shutdown the container
317 */
318 _ipSystemStatsTable_container_shutdown(&ipSystemStatsTable_if_ctx);
319 }
320
321 void
322 ipSystemStatsTable_valid_columns_set(netsnmp_column_info *vc)
323 {
324 ipSystemStatsTable_if_ctx.tbl_info.valid_columns = vc;
325 } /* ipSystemStatsTable_valid_columns_set */
326
327 /**
328 * @internal
329 * convert the index component stored in the context to an oid
330 */
331 int
332 ipSystemStatsTable_index_to_oid(netsnmp_index * oid_idx,
333 ipSystemStatsTable_mib_index * mib_idx)
334 {
335 int err = SNMP_ERR_NOERROR;
336
337 /*
338 * temp storage for parsing indexes
339 */
340 /*
341 * ipSystemStatsIPVersion(1)/InetVersion/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
342 */
343 netsnmp_variable_list var_ipSystemStatsIPVersion;
344
345 /*
346 * set up varbinds
347 */
348 memset(&var_ipSystemStatsIPVersion, 0x00,
349 sizeof(var_ipSystemStatsIPVersion));
350 var_ipSystemStatsIPVersion.type = ASN_INTEGER;
351
352 /*
353 * chain temp index varbinds together
354 */
355 var_ipSystemStatsIPVersion.next_variable = NULL;
356
357
358 DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsTable_index_to_oid", "called\n"));
359
360 /*
361 * ipSystemStatsIPVersion(1)/InetVersion/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
362 */
363 snmp_set_var_value(&var_ipSystemStatsIPVersion,
364 (u_char *) & mib_idx->ipSystemStatsIPVersion,
365 sizeof(mib_idx->ipSystemStatsIPVersion));
366
367
368 err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len,
369 NULL, 0, &var_ipSystemStatsIPVersion);
370 if (err)
371 snmp_log(LOG_ERR, "error %d converting index to oid\n", err);
372
373 /*
374 * parsing may have allocated memory. free it.
375 */
376 snmp_reset_var_buffers(&var_ipSystemStatsIPVersion);
377
378 return err;
379 } /* ipSystemStatsTable_index_to_oid */
380
381 /**
382 * extract ipSystemStatsTable indexes from a netsnmp_index
383 *
384 * @retval SNMP_ERR_NOERROR : no error
385 * @retval SNMP_ERR_GENERR : error
386 */
387 int
388 ipSystemStatsTable_index_from_oid(netsnmp_index * oid_idx,
389 ipSystemStatsTable_mib_index * mib_idx)
390 {
391 int err = SNMP_ERR_NOERROR;
392
393 /*
394 * temp storage for parsing indexes
395 */
396 /*
397 * ipSystemStatsIPVersion(1)/InetVersion/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
398 */
399 netsnmp_variable_list var_ipSystemStatsIPVersion;
400
401 /*
402 * set up varbinds
403 */
404 memset(&var_ipSystemStatsIPVersion, 0x00,
405 sizeof(var_ipSystemStatsIPVersion));
406 var_ipSystemStatsIPVersion.type = ASN_INTEGER;
407
408 /*
409 * chain temp index varbinds together
410 */
411 var_ipSystemStatsIPVersion.next_variable = NULL;
412
413
414 DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsTable_index_from_oid", "called\n"));
415
416 /*
417 * parse the oid into the individual index components
418 */
419 err = parse_oid_indexes(oid_idx->oids, oid_idx->len,
420 &var_ipSystemStatsIPVersion);
421 if (err == SNMP_ERR_NOERROR) {
422 /*
423 * copy out values
424 */
425 mib_idx->ipSystemStatsIPVersion =
426 *((u_long *) var_ipSystemStatsIPVersion.val.string);
427
428
429 }
430
431 /*
432 * parsing may have allocated memory. free it.
433 */
434 snmp_reset_var_buffers(&var_ipSystemStatsIPVersion);
435
436 return err;
437 } /* ipSystemStatsTable_index_from_oid */
438
439
440 /*
441 *********************************************************************
442 * @internal
443 * allocate resources for a ipSystemStatsTable_rowreq_ctx
444 */
445 ipSystemStatsTable_rowreq_ctx *
446 ipSystemStatsTable_allocate_rowreq_ctx(ipSystemStatsTable_data * data,
447 void *user_init_ctx)
448 {
449 ipSystemStatsTable_rowreq_ctx *rowreq_ctx =
450 SNMP_MALLOC_TYPEDEF(ipSystemStatsTable_rowreq_ctx);
451
452 DEBUGMSGTL(("internal:ipSystemStatsTable:ipSystemStatsTable_allocate_rowreq_ctx", "called\n"));
453
454 if (NULL == rowreq_ctx) {
455 snmp_log(LOG_ERR, "Couldn't allocate memory for a "
456 "ipSystemStatsTable_rowreq_ctx.\n");
457 return NULL;
458 } else {
459 if (NULL != data) {
460 /*
461 * track if we got data from user
462 */
463 rowreq_ctx->rowreq_flags |= MFD_ROW_DATA_FROM_USER;
464 rowreq_ctx->data = data;
465 } else if (NULL ==
466 (rowreq_ctx->data =
467 ipSystemStatsTable_allocate_data())) {
468 SNMP_FREE(rowreq_ctx);
469 return NULL;
470 }
471 }
472
473 /*
474 * undo context will be allocated when needed (in *_undo_setup)
475 */
476
477 rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp;
478
479 rowreq_ctx->ipSystemStatsTable_data_list = NULL;
480
481 /*
482 * if we allocated data, call init routine
483 */
484 if (!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) {
485 if (SNMPERR_SUCCESS !=
486 ipSystemStatsTable_rowreq_ctx_init(rowreq_ctx,
487 user_init_ctx)) {
488 ipSystemStatsTable_release_rowreq_ctx(rowreq_ctx);
489 rowreq_ctx = NULL;
490 }
491 }
492
493 return rowreq_ctx;
494 } /* ipSystemStatsTable_allocate_rowreq_ctx */
495
496 /*
497 * @internal
498 * release resources for a ipSystemStatsTable_rowreq_ctx
499 */
500 void
501 ipSystemStatsTable_release_rowreq_ctx(ipSystemStatsTable_rowreq_ctx *
502 rowreq_ctx)
503 {
504 DEBUGMSGTL(("internal:ipSystemStatsTable:ipSystemStatsTable_release_rowreq_ctx", "called\n"));
505
506 netsnmp_assert(NULL != rowreq_ctx);
507
508 ipSystemStatsTable_rowreq_ctx_cleanup(rowreq_ctx);
509
510 /*
511 * for non-transient data, don't free data we got from the user
512 */
513 if ((rowreq_ctx->data) &&
514 !(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER))
515 ipSystemStatsTable_release_data(rowreq_ctx->data);
516
517 /*
518 * free index oid pointer
519 */
520 if (rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp)
521 free(rowreq_ctx->oid_idx.oids);
522
523 SNMP_FREE(rowreq_ctx);
524 } /* ipSystemStatsTable_release_rowreq_ctx */
525
526 /**
527 * @internal
528 * wrapper
529 */
530 static int
531 _mfd_ipSystemStatsTable_pre_request(netsnmp_mib_handler *handler,
532 netsnmp_handler_registration *reginfo,
533 netsnmp_agent_request_info
534 *agtreq_info,
535 netsnmp_request_info *requests)
536 {
537 int rc;
538
539 DEBUGMSGTL(("internal:ipSystemStatsTable:_mfd_ipSystemStatsTable_pre_request", "called\n"));
540
541 if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) {
542 DEBUGMSGTL(("internal:ipSystemStatsTable",
543 "skipping additional pre_request\n"));
544 return SNMP_ERR_NOERROR;
545 }
546
547 rc = ipSystemStatsTable_pre_request(ipSystemStatsTable_if_ctx.
548 user_ctx);
549 if (MFD_SUCCESS != rc) {
550 /*
551 * nothing we can do about it but log it
552 */
553 DEBUGMSGTL(("ipSystemStatsTable", "error %d from "
554 "ipSystemStatsTable_pre_request\n", rc));
555 netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
556 }
557
558 return SNMP_ERR_NOERROR;
559 } /* _mfd_ipSystemStatsTable_pre_request */
560
561 /**
562 * @internal
563 * wrapper
564 */
565 static int
566 _mfd_ipSystemStatsTable_post_request(netsnmp_mib_handler *handler,
567 netsnmp_handler_registration *reginfo,
568 netsnmp_agent_request_info
569 *agtreq_info,
570 netsnmp_request_info *requests)
571 {
572 ipSystemStatsTable_rowreq_ctx *rowreq_ctx = (ipSystemStatsTable_rowreq_ctx*)
573 netsnmp_container_table_row_extract(requests);
574 int rc, packet_rc;
575
576 DEBUGMSGTL(("internal:ipSystemStatsTable:_mfd_ipSystemStatsTable_post_request", "called\n"));
577
578 /*
579 * release row context, if deleted
580 */
581 if (rowreq_ctx && (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED))
582 ipSystemStatsTable_release_rowreq_ctx(rowreq_ctx);
583
584 /*
585 * wait for last call before calling user
586 */
587 if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) {
588 DEBUGMSGTL(("internal:ipSystemStatsTable",
589 "waiting for last post_request\n"));
590 return SNMP_ERR_NOERROR;
591 }
592
593 packet_rc = netsnmp_check_all_requests_error(agtreq_info->asp, 0);
594 rc = ipSystemStatsTable_post_request(ipSystemStatsTable_if_ctx.
595 user_ctx, packet_rc);
596 if (MFD_SUCCESS != rc) {
597 /*
598 * nothing we can do about it but log it
599 */
600 DEBUGMSGTL(("ipSystemStatsTable", "error %d from "
601 "ipSystemStatsTable_post_request\n", rc));
602 }
603
604 return SNMP_ERR_NOERROR;
605 } /* _mfd_ipSystemStatsTable_post_request */
606
607 /**
608 * @internal
609 * wrapper
610 */
611 static int
612 _mfd_ipSystemStatsTable_object_lookup(netsnmp_mib_handler *handler, netsnmp_handler_registration
613 *reginfo, netsnmp_agent_request_info
614 *agtreq_info,
615 netsnmp_request_info *requests)
616 {
617 int rc = SNMP_ERR_NOERROR;
618 ipSystemStatsTable_rowreq_ctx *rowreq_ctx = (ipSystemStatsTable_rowreq_ctx*)
619 netsnmp_container_table_row_extract(requests);
620
621 DEBUGMSGTL(("internal:ipSystemStatsTable:_mfd_ipSystemStatsTable_object_lookup", "called\n"));
622
623 /*
624 * get our context from mfd
625 * ipSystemStatsTable_interface_ctx *if_ctx =
626 * (ipSystemStatsTable_interface_ctx *)reginfo->my_reg_void;
627 */
628
629 if (NULL == rowreq_ctx) {
630 rc = SNMP_ERR_NOCREATION;
631 }
632
633 if (MFD_SUCCESS != rc)
634 netsnmp_request_set_error_all(requests, rc);
635 else
636 ipSystemStatsTable_row_prep(rowreq_ctx);
637
638 return SNMP_VALIDATE_ERR(rc);
639 } /* _mfd_ipSystemStatsTable_object_lookup */
640
641 /***********************************************************************
642 *
643 * GET processing
644 *
645 ***********************************************************************/
646 /*
647 * @internal
648 * Retrieve the value for a particular column
649 */
650 NETSNMP_STATIC_INLINE int
651 _ipSystemStatsTable_get_column(ipSystemStatsTable_rowreq_ctx * rowreq_ctx,
652 netsnmp_variable_list * var, int column)
653 {
654 int rc = SNMPERR_SUCCESS;
655
656 DEBUGMSGTL(("internal:ipSystemStatsTable:_mfd_ipSystemStatsTable_get_column", "called for %d\n", column));
657
658
659 netsnmp_assert(NULL != rowreq_ctx);
660
661 switch (column) {
662
663 /*
664 * ipSystemStatsInReceives(3)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
665 */
666 case COLUMN_IPSYSTEMSTATSINRECEIVES:
667 var->val_len = sizeof(u_long);
668 var->type = ASN_COUNTER;
669 rc = ipSystemStatsInReceives_get(rowreq_ctx,
670 (u_long *) var->val.string);
671 break;
672
673 /*
674 * ipSystemStatsHCInReceives(4)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
675 */
676 case COLUMN_IPSYSTEMSTATSHCINRECEIVES:
677 var->val_len = sizeof(struct counter64);
678 var->type = ASN_COUNTER64;
679 rc = ipSystemStatsHCInReceives_get(rowreq_ctx,
680 (struct counter64 *) var->val.string);
681 break;
682
683 /*
684 * ipSystemStatsInOctets(5)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
685 */
686 case COLUMN_IPSYSTEMSTATSINOCTETS:
687 var->val_len = sizeof(u_long);
688 var->type = ASN_COUNTER;
689 rc = ipSystemStatsInOctets_get(rowreq_ctx,
690 (u_long *) var->val.string);
691 break;
692
693 /*
694 * ipSystemStatsHCInOctets(6)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
695 */
696 case COLUMN_IPSYSTEMSTATSHCINOCTETS:
697 var->val_len = sizeof(struct counter64);
698 var->type = ASN_COUNTER64;
699 rc = ipSystemStatsHCInOctets_get(rowreq_ctx,
700 (struct counter64 *) var->val.string);
701 break;
702
703 /*
704 * ipSystemStatsInHdrErrors(7)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
705 */
706 case COLUMN_IPSYSTEMSTATSINHDRERRORS:
707 var->val_len = sizeof(u_long);
708 var->type = ASN_COUNTER;
709 rc = ipSystemStatsInHdrErrors_get(rowreq_ctx,
710 (u_long *) var->val.string);
711 break;
712
713 /*
714 * ipSystemStatsInNoRoutes(8)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
715 */
716 case COLUMN_IPSYSTEMSTATSINNOROUTES:
717 var->val_len = sizeof(u_long);
718 var->type = ASN_COUNTER;
719 rc = ipSystemStatsInNoRoutes_get(rowreq_ctx,
720 (u_long *) var->val.string);
721 break;
722
723 /*
724 * ipSystemStatsInAddrErrors(9)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
725 */
726 case COLUMN_IPSYSTEMSTATSINADDRERRORS:
727 var->val_len = sizeof(u_long);
728 var->type = ASN_COUNTER;
729 rc = ipSystemStatsInAddrErrors_get(rowreq_ctx,
730 (u_long *) var->val.string);
731 break;
732
733 /*
734 * ipSystemStatsInUnknownProtos(10)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
735 */
736 case COLUMN_IPSYSTEMSTATSINUNKNOWNPROTOS:
737 var->val_len = sizeof(u_long);
738 var->type = ASN_COUNTER;
739 rc = ipSystemStatsInUnknownProtos_get(rowreq_ctx,
740 (u_long *) var->val.string);
741 break;
742
743 /*
744 * ipSystemStatsInTruncatedPkts(11)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
745 */
746 case COLUMN_IPSYSTEMSTATSINTRUNCATEDPKTS:
747 var->val_len = sizeof(u_long);
748 var->type = ASN_COUNTER;
749 rc = ipSystemStatsInTruncatedPkts_get(rowreq_ctx,
750 (u_long *) var->val.string);
751 break;
752
753 /*
754 * ipSystemStatsInForwDatagrams(12)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
755 */
756 case COLUMN_IPSYSTEMSTATSINFORWDATAGRAMS:
757 var->val_len = sizeof(u_long);
758 var->type = ASN_COUNTER;
759 rc = ipSystemStatsInForwDatagrams_get(rowreq_ctx,
760 (u_long *) var->val.string);
761 break;
762
763 /*
764 * ipSystemStatsHCInForwDatagrams(13)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
765 */
766 case COLUMN_IPSYSTEMSTATSHCINFORWDATAGRAMS:
767 var->val_len = sizeof(struct counter64);
768 var->type = ASN_COUNTER64;
769 rc = ipSystemStatsHCInForwDatagrams_get(rowreq_ctx,
770 (struct counter64 *) var->val.string);
771 break;
772
773 /*
774 * ipSystemStatsReasmReqds(14)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
775 */
776 case COLUMN_IPSYSTEMSTATSREASMREQDS:
777 var->val_len = sizeof(u_long);
778 var->type = ASN_COUNTER;
779 rc = ipSystemStatsReasmReqds_get(rowreq_ctx,
780 (u_long *) var->val.string);
781 break;
782
783 /*
784 * ipSystemStatsReasmOKs(15)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
785 */
786 case COLUMN_IPSYSTEMSTATSREASMOKS:
787 var->val_len = sizeof(u_long);
788 var->type = ASN_COUNTER;
789 rc = ipSystemStatsReasmOKs_get(rowreq_ctx,
790 (u_long *) var->val.string);
791 break;
792
793 /*
794 * ipSystemStatsReasmFails(16)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
795 */
796 case COLUMN_IPSYSTEMSTATSREASMFAILS:
797 var->val_len = sizeof(u_long);
798 var->type = ASN_COUNTER;
799 rc = ipSystemStatsReasmFails_get(rowreq_ctx,
800 (u_long *) var->val.string);
801 break;
802
803 /*
804 * ipSystemStatsInDiscards(17)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
805 */
806 case COLUMN_IPSYSTEMSTATSINDISCARDS:
807 var->val_len = sizeof(u_long);
808 var->type = ASN_COUNTER;
809 rc = ipSystemStatsInDiscards_get(rowreq_ctx,
810 (u_long *) var->val.string);
811 break;
812
813 /*
814 * ipSystemStatsInDelivers(18)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
815 */
816 case COLUMN_IPSYSTEMSTATSINDELIVERS:
817 var->val_len = sizeof(u_long);
818 var->type = ASN_COUNTER;
819 rc = ipSystemStatsInDelivers_get(rowreq_ctx,
820 (u_long *) var->val.string);
821 break;
822
823 /*
824 * ipSystemStatsHCInDelivers(19)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
825 */
826 case COLUMN_IPSYSTEMSTATSHCINDELIVERS:
827 var->val_len = sizeof(struct counter64);
828 var->type = ASN_COUNTER64;
829 rc = ipSystemStatsHCInDelivers_get(rowreq_ctx,
830 (struct counter64 *) var->val.string);
831 break;
832
833 /*
834 * ipSystemStatsOutRequests(20)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
835 */
836 case COLUMN_IPSYSTEMSTATSOUTREQUESTS:
837 var->val_len = sizeof(u_long);
838 var->type = ASN_COUNTER;
839 rc = ipSystemStatsOutRequests_get(rowreq_ctx,
840 (u_long *) var->val.string);
841 break;
842
843 /*
844 * ipSystemStatsHCOutRequests(21)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
845 */
846 case COLUMN_IPSYSTEMSTATSHCOUTREQUESTS:
847 var->val_len = sizeof(struct counter64);
848 var->type = ASN_COUNTER64;
849 rc = ipSystemStatsHCOutRequests_get(rowreq_ctx,
850 (struct counter64 *) var->val.string);
851 break;
852
853 /*
854 * ipSystemStatsOutNoRoutes(22)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
855 */
856 case COLUMN_IPSYSTEMSTATSOUTNOROUTES:
857 var->val_len = sizeof(u_long);
858 var->type = ASN_COUNTER;
859 rc = ipSystemStatsOutNoRoutes_get(rowreq_ctx,
860 (u_long *) var->val.string);
861 break;
862
863 /*
864 * ipSystemStatsOutForwDatagrams(23)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
865 */
866 case COLUMN_IPSYSTEMSTATSOUTFORWDATAGRAMS:
867 var->val_len = sizeof(u_long);
868 var->type = ASN_COUNTER;
869 rc = ipSystemStatsOutForwDatagrams_get(rowreq_ctx,
870 (u_long *) var->val.string);
871 break;
872
873 /*
874 * ipSystemStatsHCOutForwDatagrams(24)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
875 */
876 case COLUMN_IPSYSTEMSTATSHCOUTFORWDATAGRAMS:
877 var->val_len = sizeof(struct counter64);
878 var->type = ASN_COUNTER64;
879 rc = ipSystemStatsHCOutForwDatagrams_get(rowreq_ctx,
880 (struct counter64 *) var->val.string);
881 break;
882
883 /*
884 * ipSystemStatsOutDiscards(25)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
885 */
886 case COLUMN_IPSYSTEMSTATSOUTDISCARDS:
887 var->val_len = sizeof(u_long);
888 var->type = ASN_COUNTER;
889 rc = ipSystemStatsOutDiscards_get(rowreq_ctx,
890 (u_long *) var->val.string);
891 break;
892
893 /*
894 * ipSystemStatsOutFragReqds(26)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
895 */
896 case COLUMN_IPSYSTEMSTATSOUTFRAGREQDS:
897 var->val_len = sizeof(u_long);
898 var->type = ASN_COUNTER;
899 rc = ipSystemStatsOutFragReqds_get(rowreq_ctx,
900 (u_long *) var->val.string);
901 break;
902
903 /*
904 * ipSystemStatsOutFragOKs(27)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
905 */
906 case COLUMN_IPSYSTEMSTATSOUTFRAGOKS:
907 var->val_len = sizeof(u_long);
908 var->type = ASN_COUNTER;
909 rc = ipSystemStatsOutFragOKs_get(rowreq_ctx,
910 (u_long *) var->val.string);
911 break;
912
913 /*
914 * ipSystemStatsOutFragFails(28)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
915 */
916 case COLUMN_IPSYSTEMSTATSOUTFRAGFAILS:
917 var->val_len = sizeof(u_long);
918 var->type = ASN_COUNTER;
919 rc = ipSystemStatsOutFragFails_get(rowreq_ctx,
920 (u_long *) var->val.string);
921 break;
922
923 /*
924 * ipSystemStatsOutFragCreates(29)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
925 */
926 case COLUMN_IPSYSTEMSTATSOUTFRAGCREATES:
927 var->val_len = sizeof(u_long);
928 var->type = ASN_COUNTER;
929 rc = ipSystemStatsOutFragCreates_get(rowreq_ctx,
930 (u_long *) var->val.string);
931 break;
932
933 /*
934 * ipSystemStatsOutTransmits(30)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
935 */
936 case COLUMN_IPSYSTEMSTATSOUTTRANSMITS:
937 var->val_len = sizeof(u_long);
938 var->type = ASN_COUNTER;
939 rc = ipSystemStatsOutTransmits_get(rowreq_ctx,
940 (u_long *) var->val.string);
941 break;
942
943 /*
944 * ipSystemStatsHCOutTransmits(31)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
945 */
946 case COLUMN_IPSYSTEMSTATSHCOUTTRANSMITS:
947 var->val_len = sizeof(struct counter64);
948 var->type = ASN_COUNTER64;
949 rc = ipSystemStatsHCOutTransmits_get(rowreq_ctx,
950 (struct counter64 *) var->val.string);
951 break;
952
953 /*
954 * ipSystemStatsOutOctets(32)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
955 */
956 case COLUMN_IPSYSTEMSTATSOUTOCTETS:
957 var->val_len = sizeof(u_long);
958 var->type = ASN_COUNTER;
959 rc = ipSystemStatsOutOctets_get(rowreq_ctx,
960 (u_long *) var->val.string);
961 break;
962
963 /*
964 * ipSystemStatsHCOutOctets(33)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
965 */
966 case COLUMN_IPSYSTEMSTATSHCOUTOCTETS:
967 var->val_len = sizeof(struct counter64);
968 var->type = ASN_COUNTER64;
969 rc = ipSystemStatsHCOutOctets_get(rowreq_ctx,
970 (struct counter64 *) var->val.string);
971 break;
972
973 /*
974 * ipSystemStatsInMcastPkts(34)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
975 */
976 case COLUMN_IPSYSTEMSTATSINMCASTPKTS:
977 var->val_len = sizeof(u_long);
978 var->type = ASN_COUNTER;
979 rc = ipSystemStatsInMcastPkts_get(rowreq_ctx,
980 (u_long *) var->val.string);
981 break;
982
983 /*
984 * ipSystemStatsHCInMcastPkts(35)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
985 */
986 case COLUMN_IPSYSTEMSTATSHCINMCASTPKTS:
987 var->val_len = sizeof(struct counter64);
988 var->type = ASN_COUNTER64;
989 rc = ipSystemStatsHCInMcastPkts_get(rowreq_ctx,
990 (struct counter64 *) var->val.string);
991 break;
992
993 /*
994 * ipSystemStatsInMcastOctets(36)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
995 */
996 case COLUMN_IPSYSTEMSTATSINMCASTOCTETS:
997 var->val_len = sizeof(u_long);
998 var->type = ASN_COUNTER;
999 rc = ipSystemStatsInMcastOctets_get(rowreq_ctx,
1000 (u_long *) var->val.string);
1001 break;
1002
1003 /*
1004 * ipSystemStatsHCInMcastOctets(37)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
1005 */
1006 case COLUMN_IPSYSTEMSTATSHCINMCASTOCTETS:
1007 var->val_len = sizeof(struct counter64);
1008 var->type = ASN_COUNTER64;
1009 rc = ipSystemStatsHCInMcastOctets_get(rowreq_ctx,
1010 (struct counter64 *) var->val.string);
1011 break;
1012
1013 /*
1014 * ipSystemStatsOutMcastPkts(38)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
1015 */
1016 case COLUMN_IPSYSTEMSTATSOUTMCASTPKTS:
1017 var->val_len = sizeof(u_long);
1018 var->type = ASN_COUNTER;
1019 rc = ipSystemStatsOutMcastPkts_get(rowreq_ctx,
1020 (u_long *) var->val.string);
1021 break;
1022
1023 /*
1024 * ipSystemStatsHCOutMcastPkts(39)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
1025 */
1026 case COLUMN_IPSYSTEMSTATSHCOUTMCASTPKTS:
1027 var->val_len = sizeof(struct counter64);
1028 var->type = ASN_COUNTER64;
1029 rc = ipSystemStatsHCOutMcastPkts_get(rowreq_ctx,
1030 (struct counter64 *) var->val.string);
1031 break;
1032
1033 /*
1034 * ipSystemStatsOutMcastOctets(40)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
1035 */
1036 case COLUMN_IPSYSTEMSTATSOUTMCASTOCTETS:
1037 var->val_len = sizeof(u_long);
1038 var->type = ASN_COUNTER;
1039 rc = ipSystemStatsOutMcastOctets_get(rowreq_ctx,
1040 (u_long *) var->val.string);
1041 break;
1042
1043 /*
1044 * ipSystemStatsHCOutMcastOctets(41)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
1045 */
1046 case COLUMN_IPSYSTEMSTATSHCOUTMCASTOCTETS:
1047 var->val_len = sizeof(struct counter64);
1048 var->type = ASN_COUNTER64;
1049 rc = ipSystemStatsHCOutMcastOctets_get(rowreq_ctx,
1050 (struct counter64 *) var->val.string);
1051 break;
1052
1053 /*
1054 * ipSystemStatsInBcastPkts(42)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
1055 */
1056 case COLUMN_IPSYSTEMSTATSINBCASTPKTS:
1057 var->val_len = sizeof(u_long);
1058 var->type = ASN_COUNTER;
1059 rc = ipSystemStatsInBcastPkts_get(rowreq_ctx,
1060 (u_long *) var->val.string);
1061 break;
1062
1063 /*
1064 * ipSystemStatsHCInBcastPkts(43)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
1065 */
1066 case COLUMN_IPSYSTEMSTATSHCINBCASTPKTS:
1067 var->val_len = sizeof(struct counter64);
1068 var->type = ASN_COUNTER64;
1069 rc = ipSystemStatsHCInBcastPkts_get(rowreq_ctx,
1070 (struct counter64 *) var->val.string);
1071 break;
1072
1073 /*
1074 * ipSystemStatsOutBcastPkts(44)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
1075 */
1076 case COLUMN_IPSYSTEMSTATSOUTBCASTPKTS:
1077 var->val_len = sizeof(u_long);
1078 var->type = ASN_COUNTER;
1079 rc = ipSystemStatsOutBcastPkts_get(rowreq_ctx,
1080 (u_long *) var->val.string);
1081 break;
1082
1083 /*
1084 * ipSystemStatsHCOutBcastPkts(45)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
1085 */
1086 case COLUMN_IPSYSTEMSTATSHCOUTBCASTPKTS:
1087 var->val_len = sizeof(struct counter64);
1088 var->type = ASN_COUNTER64;
1089 rc = ipSystemStatsHCOutBcastPkts_get(rowreq_ctx,
1090 (struct counter64 *) var->val.string);
1091 break;
1092
1093 /*
1094 * ipSystemStatsDiscontinuityTime(46)/TimeStamp/ASN_TIMETICKS/u_long(u_long)//l/A/w/e/r/d/h
1095 */
1096 case COLUMN_IPSYSTEMSTATSDISCONTINUITYTIME:
1097 var->val_len = sizeof(u_long);
1098 var->type = ASN_TIMETICKS;
1099 rc = ipSystemStatsDiscontinuityTime_get(rowreq_ctx,
1100 (u_long *) var->val.
1101 string);
1102 break;
1103
1104 /*
1105 * ipSystemStatsRefreshRate(47)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/h
1106 */
1107 case COLUMN_IPSYSTEMSTATSREFRESHRATE:
1108 var->val_len = sizeof(u_long);
1109 var->type = ASN_UNSIGNED;
1110 rc = ipSystemStatsRefreshRate_get(rowreq_ctx,
1111 (u_long *) var->val.string);
1112 break;
1113
1114 default:
1115 snmp_log(LOG_ERR,
1116 "unknown column %d in _ipSystemStatsTable_get_column\n",
1117 column);
1118 break;
1119 }
1120
1121 return rc;
1122 } /* _ipSystemStatsTable_get_column */
1123
1124 int
1125 _mfd_ipSystemStatsTable_get_values(netsnmp_mib_handler *handler,
1126 netsnmp_handler_registration *reginfo,
1127 netsnmp_agent_request_info *agtreq_info,
1128 netsnmp_request_info *requests)
1129 {
1130 ipSystemStatsTable_rowreq_ctx *rowreq_ctx = (ipSystemStatsTable_rowreq_ctx*)
1131 netsnmp_container_table_row_extract(requests);
1132 netsnmp_table_request_info *tri;
1133 u_char *old_string;
1134 void (*dataFreeHook) (void *);
1135 int rc;
1136
1137 DEBUGMSGTL(("internal:ipSystemStatsTable:_mfd_ipSystemStatsTable_get_values", "called\n"));
1138
1139 netsnmp_assert(NULL != rowreq_ctx);
1140
1141 for (; requests; requests = requests->next) {
1142 /*
1143 * save old pointer, so we can free it if replaced
1144 */
1145 old_string = requests->requestvb->val.string;
1146 dataFreeHook = requests->requestvb->dataFreeHook;
1147 if (NULL == requests->requestvb->val.string) {
1148 requests->requestvb->val.string = requests->requestvb->buf;
1149 requests->requestvb->val_len =
1150 sizeof(requests->requestvb->buf);
1151 } else if (requests->requestvb->buf ==
1152 requests->requestvb->val.string) {
1153 if (requests->requestvb->val_len !=
1154 sizeof(requests->requestvb->buf))
1155 requests->requestvb->val_len =
1156 sizeof(requests->requestvb->buf);
1157 }
1158
1159 /*
1160 * get column data
1161 */
1162 tri = netsnmp_extract_table_info(requests);
1163 if (NULL == tri)
1164 continue;
1165
1166 rc = _ipSystemStatsTable_get_column(rowreq_ctx,
1167 requests->requestvb,
1168 tri->colnum);
1169 if (rc) {
1170 if (MFD_SKIP == rc) {
1171 requests->requestvb->type = SNMP_NOSUCHINSTANCE;
1172 rc = SNMP_ERR_NOERROR;
1173 }
1174 } else if (NULL == requests->requestvb->val.string) {
1175 snmp_log(LOG_ERR, "NULL varbind data pointer!\n");
1176 rc = SNMP_ERR_GENERR;
1177 }
1178 if (rc)
1179 netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc));
1180
1181 /*
1182 * if the buffer wasn't used previously for the old data (i.e. it
1183 * was allocated memory) and the get routine replaced the pointer,
1184 * we need to free the previous pointer.
1185 */
1186 if (old_string && (old_string != requests->requestvb->buf) &&
1187 (requests->requestvb->val.string != old_string)) {
1188 if (dataFreeHook)
1189 (*dataFreeHook) (old_string);
1190 else
1191 free(old_string);
1192 }
1193 } /* for results */
1194
1195 return SNMP_ERR_NOERROR;
1196 } /* _mfd_ipSystemStatsTable_get_values */
1197
1198
1199 #if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT))
1200 /***********************************************************************
1201 *
1202 * SET processing
1203 *
1204 ***********************************************************************/
1205
1206 /*
1207 * SET PROCESSING NOT APPLICABLE (per MIB or user setting)
1208 */
1209 #endif
1210
1211 /***********************************************************************
1212 *
1213 * DATA ACCESS
1214 *
1215 ***********************************************************************/
1216 static void _container_free(netsnmp_container *container);
1217
1218 /**
1219 * @internal
1220 */
1221 static int
1222 _cache_load(netsnmp_cache * cache, void *vmagic)
1223 {
1224 DEBUGMSGTL(("internal:ipSystemStatsTable:_cache_load", "called\n"));
1225
1226 if ((NULL == cache) || (NULL == cache->magic)) {
1227 snmp_log(LOG_ERR,
1228 "invalid cache for ipSystemStatsTable_cache_load\n");
1229 return -1;
1230 }
1231
1232 /** should only be called for an invalid or expired cache */
1233 netsnmp_assert((0 == cache->valid) || (1 == cache->expired));
1234
1235 /*
1236 * call user code
1237 */
1238 return ipSystemStatsTable_container_load((netsnmp_container *) cache->
1239 magic);
1240 } /* _cache_load */
1241
1242 /**
1243 * @internal
1244 */
1245 static void
1246 _cache_free(netsnmp_cache * cache, void *magic)
1247 {
1248 netsnmp_container *container;
1249
1250 DEBUGMSGTL(("internal:ipSystemStatsTable:_cache_free", "called\n"));
1251
1252 if ((NULL == cache) || (NULL == cache->magic)) {
1253 snmp_log(LOG_ERR,
1254 "invalid cache in ipSystemStatsTable_cache_free\n");
1255 return;
1256 }
1257
1258 container = (netsnmp_container *) cache->magic;
1259
1260 _container_free(container);
1261 } /* _cache_free */
1262
1263 /**
1264 * @internal
1265 */
1266 static void
1267 _container_item_free(void *rowreq_ctx,
1268 void *context)
1269 {
1270 DEBUGMSGTL(("internal:ipSystemStatsTable:_container_item_free",
1271 "called\n"));
1272
1273 if (NULL == rowreq_ctx)
1274 return;
1275
1276 ipSystemStatsTable_release_rowreq_ctx(rowreq_ctx);
1277 } /* _container_item_free */
1278
1279 /**
1280 * @internal
1281 */
1282 static void
1283 _container_free(netsnmp_container *container)
1284 {
1285 DEBUGMSGTL(("internal:ipSystemStatsTable:_container_free",
1286 "called\n"));
1287
1288 if (NULL == container) {
1289 snmp_log(LOG_ERR,
1290 "invalid container in ipSystemStatsTable_container_free\n");
1291 return;
1292 }
1293
1294 /*
1295 * call user code
1296 */
1297 ipSystemStatsTable_container_free(container);
1298
1299 /*
1300 * free all items. inefficient, but easy.
1301 */
1302 CONTAINER_CLEAR(container, _container_item_free, NULL);
1303 } /* _container_free */
1304
1305 /**
1306 * @internal
1307 * initialize the container with functions or wrappers
1308 */
1309 void
1310 _ipSystemStatsTable_container_init(ipSystemStatsTable_interface_ctx *
1311 if_ctx)
1312 {
1313 DEBUGMSGTL(("internal:ipSystemStatsTable:_ipSystemStatsTable_container_init", "called\n"));
1314
1315 /*
1316 * cache init
1317 */
1318 if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */
1319 _cache_load, _cache_free,
1320 ipSystemStatsTable_oid,
1321 ipSystemStatsTable_oid_size);
1322
1323 if (NULL == if_ctx->cache) {
1324 snmp_log(LOG_ERR, "error creating cache for ipSystemStatsTable\n");
1325 return;
1326 }
1327
1328 if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET;
1329
1330 ipSystemStatsTable_container_init(&if_ctx->container, if_ctx->cache);
1331 if (NULL == if_ctx->container)
1332 if_ctx->container =
1333 netsnmp_container_find("ipSystemStatsTable:table_container");
1334 if (NULL == if_ctx->container) {
1335 snmp_log(LOG_ERR, "error creating container in "
1336 "ipSystemStatsTable_container_init\n");
1337 return;
1338 }
1339
1340 if (NULL != if_ctx->cache)
1341 if_ctx->cache->magic = (void *) if_ctx->container;
1342 } /* _ipSystemStatsTable_container_init */
1343
1344 /**
1345 * @internal
1346 * shutdown the container with functions or wrappers
1347 */
1348 void
1349 _ipSystemStatsTable_container_shutdown(ipSystemStatsTable_interface_ctx *
1350 if_ctx)
1351 {
1352 DEBUGMSGTL(("internal:ipSystemStatsTable:_ipSystemStatsTable_container_shutdown", "called\n"));
1353
1354 ipSystemStatsTable_container_shutdown(if_ctx->container);
1355
1356 _container_free(if_ctx->container);
1357
1358 } /* _ipSystemStatsTable_container_shutdown */
1359
1360
1361 #ifndef NETSNMP_FEATURE_REMOVE_IPSYSTEMSTATSTABLE_EXTERNAL_ACCESS
1362 ipSystemStatsTable_rowreq_ctx *
1363 ipSystemStatsTable_row_find_by_mib_index(ipSystemStatsTable_mib_index *
1364 mib_idx)
1365 {
1366 ipSystemStatsTable_rowreq_ctx *rowreq_ctx;
1367 oid oid_tmp[MAX_OID_LEN];
1368 netsnmp_index oid_idx;
1369 int rc;
1370
1371 /*
1372 * set up storage for OID
1373 */
1374 oid_idx.oids = oid_tmp;
1375 oid_idx.len = sizeof(oid_tmp) / sizeof(oid);
1376
1377 /*
1378 * convert
1379 */
1380 rc = ipSystemStatsTable_index_to_oid(&oid_idx, mib_idx);
1381 if (MFD_SUCCESS != rc)
1382 return NULL;
1383
1384 rowreq_ctx = (ipSystemStatsTable_rowreq_ctx*)
1385 CONTAINER_FIND(ipSystemStatsTable_if_ctx.container, &oid_idx);
1386
1387 return rowreq_ctx;
1388 }
1389 #endif /* NETSNMP_FEATURE_REMOVE_IPSYSTEMSTATSTABLE_EXTERNAL_ACCESS */