Debian Codegraph @

agent/mibgroup/ip-mib/ipIfStatsTable/ipIfStatsTable_interface.c

raw
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 /*
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 "ipIfStatsTable.h"
41
42
43 #include <net-snmp/agent/table_container.h>
44 #include <net-snmp/library/container.h>
45
46 #include "ipIfStatsTable_interface.h"
47
48 #include <ctype.h>
49
50 netsnmp_feature_child_of(ipIfStatsTable_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(ipIfStatsTable_container_size, ipIfStatsTable_external_access);
58 netsnmp_feature_child_of(ipIfStatsTable_registration_set, ipIfStatsTable_external_access);
59 netsnmp_feature_child_of(ipIfStatsTable_registration_get, ipIfStatsTable_external_access);
60 netsnmp_feature_child_of(ipIfStatsTable_container_get, ipIfStatsTable_external_access);
61
62 /**********************************************************************
63 **********************************************************************
64 ***
65 *** Table ipIfStatsTable
66 ***
67 **********************************************************************
68 **********************************************************************/
69 /*
70 * IP-MIB::ipIfStatsTable is subid 3 of ipTrafficStats.
71 * Its status is Current.
72 * OID: .1.3.6.1.2.1.4.31.3, length: 9
73 */
74 typedef struct ipIfStatsTable_interface_ctx_s {
75
76 netsnmp_container *container;
77 netsnmp_cache *cache;
78
79 ipIfStatsTable_registration *user_ctx;
80
81 netsnmp_table_registration_info tbl_info;
82
83 netsnmp_baby_steps_access_methods access_multiplexer;
84
85 u_long last_changed;
86
87 } ipIfStatsTable_interface_ctx;
88
89 static ipIfStatsTable_interface_ctx ipIfStatsTable_if_ctx;
90
91 static void _ipIfStatsTable_container_init(ipIfStatsTable_interface_ctx
92 * if_ctx);
93 static void
94 _ipIfStatsTable_container_shutdown(ipIfStatsTable_interface_ctx * if_ctx);
95
96 #ifndef NETSNMP_FEATURE_REMOVE_IPIFSTATSTABLE_CONTAINER_GET
97 netsnmp_container *
98 ipIfStatsTable_container_get(void)
99 {
100 return ipIfStatsTable_if_ctx.container;
101 }
102 #endif /* NETSNMP_FEATURE_REMOVE_IPIFSTATSTABLE_CONTAINER_GET */
103
104 #ifndef NETSNMP_FEATURE_REMOVE_IPIFSTATSTABLE_REGISTRATION_GET
105 ipIfStatsTable_registration *
106 ipIfStatsTable_registration_get(void)
107 {
108 return ipIfStatsTable_if_ctx.user_ctx;
109 }
110 #endif /* NETSNMP_FEATURE_REMOVE_IPIFSTATSTABLE_REGISTRATION_GET */
111
112 #ifndef NETSNMP_FEATURE_REMOVE_IPIFSTATSTABLE_REGISTRATION_SET
113 ipIfStatsTable_registration *
114 ipIfStatsTable_registration_set(ipIfStatsTable_registration * newreg)
115 {
116 ipIfStatsTable_registration *old = ipIfStatsTable_if_ctx.user_ctx;
117 ipIfStatsTable_if_ctx.user_ctx = newreg;
118 return old;
119 }
120 #endif /* NETSNMP_FEATURE_REMOVE_IPIFSTATSTABLE_REGISTRATION_SET */
121
122 #ifndef NETSNMP_FEATURE_REMOVE_IPIFSTATSTABLE_CONTAINER_SIZE
123 int
124 ipIfStatsTable_container_size(void)
125 {
126 return CONTAINER_SIZE(ipIfStatsTable_if_ctx.container);
127 }
128 #endif /* NETSNMP_FEATURE_REMOVE_IPIFSTATSTABLE_CONTAINER_SIZE */
129
130 /*
131 * ipIfStatsTableLastChanged, which is the last time that a row in
132 * the table was changed or the last time a row was added/deleted from the
133 * table.
134 */
135 void
136 ipIfStatsTable_lastChange_set(u_long table_changed)
137 {
138 DEBUGMSGTL(("ipIfStatsTable:lastChanged_set",
139 "called. was %ld, now %ld\n",
140 ipIfStatsTable_if_ctx.last_changed, table_changed));
141 ipIfStatsTable_if_ctx.last_changed = table_changed;
142 }
143
144 /*
145 * mfd multiplexer modes
146 */
147 static Netsnmp_Node_Handler _mfd_ipIfStatsTable_pre_request;
148 static Netsnmp_Node_Handler _mfd_ipIfStatsTable_post_request;
149 static Netsnmp_Node_Handler _mfd_ipIfStatsTable_object_lookup;
150 static Netsnmp_Node_Handler _mfd_ipIfStatsTable_get_values;
151 /**
152 * @internal
153 * Initialize the table ipIfStatsTable
154 * (Define its contents and how it's structured)
155 */
156 void
157 _ipIfStatsTable_initialize_interface(ipIfStatsTable_registration * reg_ptr,
158 u_long flags)
159 {
160 netsnmp_baby_steps_access_methods *access_multiplexer =
161 &ipIfStatsTable_if_ctx.access_multiplexer;
162 netsnmp_table_registration_info *tbl_info =
163 &ipIfStatsTable_if_ctx.tbl_info;
164 netsnmp_handler_registration *reginfo;
165 netsnmp_mib_handler *handler;
166 int mfd_modes = 0;
167
168 DEBUGMSGTL(("internal:ipIfStatsTable:_ipIfStatsTable_initialize_interface", "called\n"));
169
170
171 /*************************************************
172 *
173 * save interface context for ipIfStatsTable
174 */
175 /*
176 * Setting up the table's definition
177 */
178 netsnmp_table_helper_add_indexes(tbl_info, ASN_INTEGER,
179 /** index: ipIfStatsIPVersion */
180 ASN_INTEGER,
181 /** index: ipIfStatsIfIndex */
182 0);
183
184 /*
185 * Define the minimum and maximum accessible columns. This
186 * optimizes retrieval.
187 */
188 tbl_info->min_column = IPIFSTATSTABLE_MIN_COL;
189 tbl_info->max_column = IPIFSTATSTABLE_MAX_COL;
190
191 /*
192 * save users context
193 */
194 ipIfStatsTable_if_ctx.user_ctx = reg_ptr;
195
196 /*
197 * call data access initialization code
198 */
199 ipIfStatsTable_init_data(reg_ptr);
200
201 /*
202 * set up the container
203 */
204 _ipIfStatsTable_container_init(&ipIfStatsTable_if_ctx);
205 if (NULL == ipIfStatsTable_if_ctx.container) {
206 snmp_log(LOG_ERR,
207 "could not initialize container for ipIfStatsTable\n");
208 return;
209 }
210
211 /*
212 * access_multiplexer: REQUIRED wrapper for get request handling
213 */
214 access_multiplexer->object_lookup = _mfd_ipIfStatsTable_object_lookup;
215 access_multiplexer->get_values = _mfd_ipIfStatsTable_get_values;
216
217 /*
218 * no wrappers yet
219 */
220 access_multiplexer->pre_request = _mfd_ipIfStatsTable_pre_request;
221 access_multiplexer->post_request = _mfd_ipIfStatsTable_post_request;
222
223
224 /*************************************************
225 *
226 * Create a registration, save our reg data, register table.
227 */
228 DEBUGMSGTL(("ipIfStatsTable:init_ipIfStatsTable",
229 "Registering ipIfStatsTable as a mibs-for-dummies table.\n"));
230 handler =
231 netsnmp_baby_steps_access_multiplexer_get(access_multiplexer);
232 reginfo =
233 netsnmp_handler_registration_create("ipIfStatsTable", handler,
234 ipIfStatsTable_oid,
235 ipIfStatsTable_oid_size,
236 HANDLER_CAN_BABY_STEP |
237 HANDLER_CAN_RONLY);
238 if (NULL == reginfo) {
239 snmp_log(LOG_ERR, "error registering table ipIfStatsTable\n");
240 return;
241 }
242 reginfo->my_reg_void = &ipIfStatsTable_if_ctx;
243
244 /*************************************************
245 *
246 * set up baby steps handler, create it and inject it
247 */
248 if (access_multiplexer->object_lookup)
249 mfd_modes |= BABY_STEP_OBJECT_LOOKUP;
250
251 if (access_multiplexer->pre_request)
252 mfd_modes |= BABY_STEP_PRE_REQUEST;
253 if (access_multiplexer->post_request)
254 mfd_modes |= BABY_STEP_POST_REQUEST;
255
256 #ifndef NETSNMP_NO_WRITE_SUPPORT
257 if (access_multiplexer->set_values)
258 mfd_modes |= BABY_STEP_SET_VALUES;
259 if (access_multiplexer->irreversible_commit)
260 mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT;
261 if (access_multiplexer->object_syntax_checks)
262 mfd_modes |= BABY_STEP_CHECK_OBJECT;
263
264 if (access_multiplexer->undo_setup)
265 mfd_modes |= BABY_STEP_UNDO_SETUP;
266 if (access_multiplexer->undo_cleanup)
267 mfd_modes |= BABY_STEP_UNDO_CLEANUP;
268 if (access_multiplexer->undo_sets)
269 mfd_modes |= BABY_STEP_UNDO_SETS;
270
271 if (access_multiplexer->row_creation)
272 mfd_modes |= BABY_STEP_ROW_CREATE;
273 if (access_multiplexer->consistency_checks)
274 mfd_modes |= BABY_STEP_CHECK_CONSISTENCY;
275 if (access_multiplexer->commit)
276 mfd_modes |= BABY_STEP_COMMIT;
277 if (access_multiplexer->undo_commit)
278 mfd_modes |= BABY_STEP_UNDO_COMMIT;
279 #endif /* !NETSNMP_NO_WRITE_SUPPORT */
280
281 handler = netsnmp_baby_steps_handler_get(mfd_modes);
282 netsnmp_inject_handler(reginfo, handler);
283
284 /*************************************************
285 *
286 * inject row_merge helper with prefix rootoid_len + 2 (entry.col)
287 */
288 handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2);
289 netsnmp_inject_handler(reginfo, handler);
290
291 /*************************************************
292 *
293 * inject container_table helper
294 */
295 handler =
296 netsnmp_container_table_handler_get(tbl_info,
297 ipIfStatsTable_if_ctx.
298 container,
299 TABLE_CONTAINER_KEY_NETSNMP_INDEX);
300 netsnmp_inject_handler(reginfo, handler);
301
302 /*************************************************
303 *
304 * inject cache helper
305 */
306 if (NULL != ipIfStatsTable_if_ctx.cache) {
307 handler = netsnmp_cache_handler_get(ipIfStatsTable_if_ctx.cache);
308 netsnmp_inject_handler(reginfo, handler);
309 }
310
311 /*
312 * register table
313 */
314 netsnmp_register_table(reginfo, tbl_info);
315
316 /*
317 * register LastChanged
318 */
319 {
320 oid lc_oid[] = { IPIFSTATSTABLELASTCHANGE_OID };
321 netsnmp_register_watched_scalar2(netsnmp_create_handler_registration
322 ("ipIfStatsTableLastChanged", NULL,
323 lc_oid, OID_LENGTH(lc_oid),
324 HANDLER_CAN_RONLY),
325 netsnmp_create_watcher_info((void
326 *)
327 &ipIfStatsTable_if_ctx.
328 last_changed,
329 sizeof
330 (u_long),
331 ASN_TIMETICKS,
332 WATCHER_FIXED_SIZE));
333 }
334 } /* _ipIfStatsTable_initialize_interface */
335
336 /**
337 * @internal
338 * Shutdown the table ipIfStatsTable
339 */
340 void
341 _ipIfStatsTable_shutdown_interface(ipIfStatsTable_registration * reg_ptr)
342 {
343 /*
344 * shutdown the container
345 */
346 _ipIfStatsTable_container_shutdown(&ipIfStatsTable_if_ctx);
347 }
348
349 void
350 ipIfStatsTable_valid_columns_set(netsnmp_column_info *vc)
351 {
352 ipIfStatsTable_if_ctx.tbl_info.valid_columns = vc;
353 } /* ipIfStatsTable_valid_columns_set */
354
355 /**
356 * @internal
357 * convert the index component stored in the context to an oid
358 */
359 int
360 ipIfStatsTable_index_to_oid(netsnmp_index * oid_idx,
361 ipIfStatsTable_mib_index * mib_idx)
362 {
363 int err = SNMP_ERR_NOERROR;
364
365 /*
366 * temp storage for parsing indexes
367 */
368 /*
369 * ipIfStatsIPVersion(1)/InetVersion/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
370 */
371 netsnmp_variable_list var_ipIfStatsIPVersion;
372 /*
373 * ipIfStatsIfIndex(2)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H
374 */
375 netsnmp_variable_list var_ipIfStatsIfIndex;
376
377 /*
378 * set up varbinds
379 */
380 memset(&var_ipIfStatsIPVersion, 0x00, sizeof(var_ipIfStatsIPVersion));
381 var_ipIfStatsIPVersion.type = ASN_INTEGER;
382 memset(&var_ipIfStatsIfIndex, 0x00, sizeof(var_ipIfStatsIfIndex));
383 var_ipIfStatsIfIndex.type = ASN_INTEGER;
384
385 /*
386 * chain temp index varbinds together
387 */
388 var_ipIfStatsIPVersion.next_variable = &var_ipIfStatsIfIndex;
389 var_ipIfStatsIfIndex.next_variable = NULL;
390
391
392 DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsTable_index_to_oid",
393 "called\n"));
394
395 /*
396 * ipIfStatsIPVersion(1)/InetVersion/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
397 */
398 snmp_set_var_value(&var_ipIfStatsIPVersion,
399 (u_char *) & mib_idx->ipIfStatsIPVersion,
400 sizeof(mib_idx->ipIfStatsIPVersion));
401
402 /*
403 * ipIfStatsIfIndex(2)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H
404 */
405 snmp_set_var_value(&var_ipIfStatsIfIndex,
406 (u_char *) & mib_idx->ipIfStatsIfIndex,
407 sizeof(mib_idx->ipIfStatsIfIndex));
408
409
410 err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len,
411 NULL, 0, &var_ipIfStatsIPVersion);
412 if (err)
413 snmp_log(LOG_ERR, "error %d converting index to oid\n", err);
414
415 /*
416 * parsing may have allocated memory. free it.
417 */
418 snmp_reset_var_buffers(&var_ipIfStatsIPVersion);
419
420 return err;
421 } /* ipIfStatsTable_index_to_oid */
422
423 /**
424 * extract ipIfStatsTable indexes from a netsnmp_index
425 *
426 * @retval SNMP_ERR_NOERROR : no error
427 * @retval SNMP_ERR_GENERR : error
428 */
429 int
430 ipIfStatsTable_index_from_oid(netsnmp_index * oid_idx,
431 ipIfStatsTable_mib_index * mib_idx)
432 {
433 int err = SNMP_ERR_NOERROR;
434
435 /*
436 * temp storage for parsing indexes
437 */
438 /*
439 * ipIfStatsIPVersion(1)/InetVersion/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
440 */
441 netsnmp_variable_list var_ipIfStatsIPVersion;
442 /*
443 * ipIfStatsIfIndex(2)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H
444 */
445 netsnmp_variable_list var_ipIfStatsIfIndex;
446
447 /*
448 * set up varbinds
449 */
450 memset(&var_ipIfStatsIPVersion, 0x00, sizeof(var_ipIfStatsIPVersion));
451 var_ipIfStatsIPVersion.type = ASN_INTEGER;
452 memset(&var_ipIfStatsIfIndex, 0x00, sizeof(var_ipIfStatsIfIndex));
453 var_ipIfStatsIfIndex.type = ASN_INTEGER;
454
455 /*
456 * chain temp index varbinds together
457 */
458 var_ipIfStatsIPVersion.next_variable = &var_ipIfStatsIfIndex;
459 var_ipIfStatsIfIndex.next_variable = NULL;
460
461
462 DEBUGMSGTL(("verbose:ipIfStatsTable:ipIfStatsTable_index_from_oid",
463 "called\n"));
464
465 /*
466 * parse the oid into the individual index components
467 */
468 err = parse_oid_indexes(oid_idx->oids, oid_idx->len,
469 &var_ipIfStatsIPVersion);
470 if (err == SNMP_ERR_NOERROR) {
471 /*
472 * copy out values
473 */
474 mib_idx->ipIfStatsIPVersion =
475 *((u_long *) var_ipIfStatsIPVersion.val.string);
476 mib_idx->ipIfStatsIfIndex =
477 *((long *) var_ipIfStatsIfIndex.val.string);
478
479
480 }
481
482 /*
483 * parsing may have allocated memory. free it.
484 */
485 snmp_reset_var_buffers(&var_ipIfStatsIPVersion);
486
487 return err;
488 } /* ipIfStatsTable_index_from_oid */
489
490
491 /*
492 *********************************************************************
493 * @internal
494 * allocate resources for a ipIfStatsTable_rowreq_ctx
495 */
496 ipIfStatsTable_rowreq_ctx *
497 ipIfStatsTable_allocate_rowreq_ctx(ipIfStatsTable_data * data,
498 void *user_init_ctx)
499 {
500 ipIfStatsTable_rowreq_ctx *rowreq_ctx =
501 SNMP_MALLOC_TYPEDEF(ipIfStatsTable_rowreq_ctx);
502
503 DEBUGMSGTL(("internal:ipIfStatsTable:ipIfStatsTable_allocate_rowreq_ctx", "called\n"));
504
505 if (NULL == rowreq_ctx) {
506 snmp_log(LOG_ERR, "Couldn't allocate memory for a "
507 "ipIfStatsTable_rowreq_ctx.\n");
508 return NULL;
509 } else {
510 if (NULL != data) {
511 /*
512 * track if we got data from user
513 */
514 rowreq_ctx->rowreq_flags |= MFD_ROW_DATA_FROM_USER;
515 rowreq_ctx->data = data;
516 } else if (NULL ==
517 (rowreq_ctx->data = ipIfStatsTable_allocate_data())) {
518 SNMP_FREE(rowreq_ctx);
519 return NULL;
520 }
521 }
522
523 /*
524 * undo context will be allocated when needed (in *_undo_setup)
525 */
526
527 rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp;
528
529 rowreq_ctx->ipIfStatsTable_data_list = NULL;
530
531 /*
532 * if we allocated data, call init routine
533 */
534 if (!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) {
535 if (SNMPERR_SUCCESS !=
536 ipIfStatsTable_rowreq_ctx_init(rowreq_ctx, user_init_ctx)) {
537 ipIfStatsTable_release_rowreq_ctx(rowreq_ctx);
538 rowreq_ctx = NULL;
539 }
540 }
541
542 return rowreq_ctx;
543 } /* ipIfStatsTable_allocate_rowreq_ctx */
544
545 /*
546 * @internal
547 * release resources for a ipIfStatsTable_rowreq_ctx
548 */
549 void
550 ipIfStatsTable_release_rowreq_ctx(ipIfStatsTable_rowreq_ctx * rowreq_ctx)
551 {
552 DEBUGMSGTL(("internal:ipIfStatsTable:ipIfStatsTable_release_rowreq_ctx", "called\n"));
553
554 netsnmp_assert(NULL != rowreq_ctx);
555
556 ipIfStatsTable_rowreq_ctx_cleanup(rowreq_ctx);
557
558 /*
559 * for non-transient data, don't free data we got from the user
560 */
561 if ((rowreq_ctx->data) &&
562 !(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER))
563 ipIfStatsTable_release_data(rowreq_ctx->data);
564
565 /*
566 * free index oid pointer
567 */
568 if (rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp)
569 free(rowreq_ctx->oid_idx.oids);
570
571 SNMP_FREE(rowreq_ctx);
572 } /* ipIfStatsTable_release_rowreq_ctx */
573
574 /**
575 * @internal
576 * wrapper
577 */
578 static int
579 _mfd_ipIfStatsTable_pre_request(netsnmp_mib_handler *handler,
580 netsnmp_handler_registration *reginfo,
581 netsnmp_agent_request_info *agtreq_info,
582 netsnmp_request_info *requests)
583 {
584 int rc;
585
586 DEBUGMSGTL(("internal:ipIfStatsTable:_mfd_ipIfStatsTable_pre_request",
587 "called\n"));
588
589 if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) {
590 DEBUGMSGTL(("internal:ipIfStatsTable",
591 "skipping additional pre_request\n"));
592 return SNMP_ERR_NOERROR;
593 }
594
595 rc = ipIfStatsTable_pre_request(ipIfStatsTable_if_ctx.user_ctx);
596 if (MFD_SUCCESS != rc) {
597 /*
598 * nothing we can do about it but log it
599 */
600 DEBUGMSGTL(("ipIfStatsTable", "error %d from "
601 "ipIfStatsTable_pre_request\n", rc));
602 netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
603 }
604
605 return SNMP_ERR_NOERROR;
606 } /* _mfd_ipIfStatsTable_pre_request */
607
608 /**
609 * @internal
610 * wrapper
611 */
612 static int
613 _mfd_ipIfStatsTable_post_request(netsnmp_mib_handler *handler,
614 netsnmp_handler_registration *reginfo,
615 netsnmp_agent_request_info *agtreq_info,
616 netsnmp_request_info *requests)
617 {
618 ipIfStatsTable_rowreq_ctx *rowreq_ctx = (ipIfStatsTable_rowreq_ctx*)
619 netsnmp_container_table_row_extract(requests);
620 int rc, packet_rc;
621
622 DEBUGMSGTL(("internal:ipIfStatsTable:_mfd_ipIfStatsTable_post_request",
623 "called\n"));
624
625 /*
626 * release row context, if deleted
627 */
628 if (rowreq_ctx && (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED))
629 ipIfStatsTable_release_rowreq_ctx(rowreq_ctx);
630
631 /*
632 * wait for last call before calling user
633 */
634 if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) {
635 DEBUGMSGTL(("internal:ipIfStatsTable",
636 "waiting for last post_request\n"));
637 return SNMP_ERR_NOERROR;
638 }
639
640 packet_rc = netsnmp_check_all_requests_error(agtreq_info->asp, 0);
641 rc = ipIfStatsTable_post_request(ipIfStatsTable_if_ctx.user_ctx,
642 packet_rc);
643 if (MFD_SUCCESS != rc) {
644 /*
645 * nothing we can do about it but log it
646 */
647 DEBUGMSGTL(("ipIfStatsTable", "error %d from "
648 "ipIfStatsTable_post_request\n", rc));
649 }
650
651 return SNMP_ERR_NOERROR;
652 } /* _mfd_ipIfStatsTable_post_request */
653
654 /**
655 * @internal
656 * wrapper
657 */
658 static int
659 _mfd_ipIfStatsTable_object_lookup(netsnmp_mib_handler *handler,
660 netsnmp_handler_registration *reginfo,
661 netsnmp_agent_request_info *agtreq_info,
662 netsnmp_request_info *requests)
663 {
664 int rc = SNMP_ERR_NOERROR;
665 ipIfStatsTable_rowreq_ctx *rowreq_ctx = (ipIfStatsTable_rowreq_ctx*)
666 netsnmp_container_table_row_extract(requests);
667
668 DEBUGMSGTL(("internal:ipIfStatsTable:_mfd_ipIfStatsTable_object_lookup", "called\n"));
669
670 /*
671 * get our context from mfd
672 * ipIfStatsTable_interface_ctx *if_ctx =
673 * (ipIfStatsTable_interface_ctx *)reginfo->my_reg_void;
674 */
675
676 if (NULL == rowreq_ctx) {
677 rc = SNMP_ERR_NOCREATION;
678 }
679
680 if (MFD_SUCCESS != rc)
681 netsnmp_request_set_error_all(requests, rc);
682 else
683 ipIfStatsTable_row_prep(rowreq_ctx);
684
685 return SNMP_VALIDATE_ERR(rc);
686 } /* _mfd_ipIfStatsTable_object_lookup */
687
688 /***********************************************************************
689 *
690 * GET processing
691 *
692 ***********************************************************************/
693 /*
694 * @internal
695 * Retrieve the value for a particular column
696 */
697 NETSNMP_STATIC_INLINE int
698 _ipIfStatsTable_get_column(ipIfStatsTable_rowreq_ctx * rowreq_ctx,
699 netsnmp_variable_list * var, int column)
700 {
701 int rc = SNMPERR_SUCCESS;
702
703 DEBUGMSGTL(("internal:ipIfStatsTable:_mfd_ipIfStatsTable_get_column",
704 "called for %d\n", column));
705
706
707 netsnmp_assert(NULL != rowreq_ctx);
708
709 switch (column) {
710
711 /*
712 * ipIfStatsInReceives(3)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
713 */
714 case COLUMN_IPIFSTATSINRECEIVES:
715 var->val_len = sizeof(u_long);
716 var->type = ASN_COUNTER;
717 rc = ipIfStatsInReceives_get(rowreq_ctx,
718 (u_long *) var->val.string);
719 break;
720
721 /*
722 * ipIfStatsHCInReceives(4)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
723 */
724 case COLUMN_IPIFSTATSHCINRECEIVES:
725 var->val_len = sizeof(struct counter64);
726 var->type = ASN_COUNTER64;
727 rc = ipIfStatsHCInReceives_get(rowreq_ctx,
728 (struct counter64 *) var->val.string);
729 break;
730
731 /*
732 * ipIfStatsInOctets(5)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
733 */
734 case COLUMN_IPIFSTATSINOCTETS:
735 var->val_len = sizeof(u_long);
736 var->type = ASN_COUNTER;
737 rc = ipIfStatsInOctets_get(rowreq_ctx, (u_long *) var->val.string);
738 break;
739
740 /*
741 * ipIfStatsHCInOctets(6)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
742 */
743 case COLUMN_IPIFSTATSHCINOCTETS:
744 var->val_len = sizeof(struct counter64);
745 var->type = ASN_COUNTER64;
746 rc = ipIfStatsHCInOctets_get(rowreq_ctx, (struct counter64 *) var->val.string);
747 break;
748
749 /*
750 * ipIfStatsInHdrErrors(7)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
751 */
752 case COLUMN_IPIFSTATSINHDRERRORS:
753 var->val_len = sizeof(u_long);
754 var->type = ASN_COUNTER;
755 rc = ipIfStatsInHdrErrors_get(rowreq_ctx,
756 (u_long *) var->val.string);
757 break;
758
759 /*
760 * ipIfStatsInNoRoutes(8)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
761 */
762 case COLUMN_IPIFSTATSINNOROUTES:
763 var->val_len = sizeof(u_long);
764 var->type = ASN_COUNTER;
765 rc = ipIfStatsInNoRoutes_get(rowreq_ctx,
766 (u_long *) var->val.string);
767 break;
768
769 /*
770 * ipIfStatsInAddrErrors(9)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
771 */
772 case COLUMN_IPIFSTATSINADDRERRORS:
773 var->val_len = sizeof(u_long);
774 var->type = ASN_COUNTER;
775 rc = ipIfStatsInAddrErrors_get(rowreq_ctx,
776 (u_long *) var->val.string);
777 break;
778
779 /*
780 * ipIfStatsInUnknownProtos(10)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
781 */
782 case COLUMN_IPIFSTATSINUNKNOWNPROTOS:
783 var->val_len = sizeof(u_long);
784 var->type = ASN_COUNTER;
785 rc = ipIfStatsInUnknownProtos_get(rowreq_ctx,
786 (u_long *) var->val.string);
787 break;
788
789 /*
790 * ipIfStatsInTruncatedPkts(11)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
791 */
792 case COLUMN_IPIFSTATSINTRUNCATEDPKTS:
793 var->val_len = sizeof(u_long);
794 var->type = ASN_COUNTER;
795 rc = ipIfStatsInTruncatedPkts_get(rowreq_ctx,
796 (u_long *) var->val.string);
797 break;
798
799 /*
800 * ipIfStatsInForwDatagrams(12)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
801 */
802 case COLUMN_IPIFSTATSINFORWDATAGRAMS:
803 var->val_len = sizeof(u_long);
804 var->type = ASN_COUNTER;
805 rc = ipIfStatsInForwDatagrams_get(rowreq_ctx,
806 (u_long *) var->val.string);
807 break;
808
809 /*
810 * ipIfStatsHCInForwDatagrams(13)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
811 */
812 case COLUMN_IPIFSTATSHCINFORWDATAGRAMS:
813 var->val_len = sizeof(struct counter64);
814 var->type = ASN_COUNTER64;
815 rc = ipIfStatsHCInForwDatagrams_get(rowreq_ctx,
816 (struct counter64 *) var->val.string);
817 break;
818
819 /*
820 * ipIfStatsReasmReqds(14)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
821 */
822 case COLUMN_IPIFSTATSREASMREQDS:
823 var->val_len = sizeof(u_long);
824 var->type = ASN_COUNTER;
825 rc = ipIfStatsReasmReqds_get(rowreq_ctx,
826 (u_long *) var->val.string);
827 break;
828
829 /*
830 * ipIfStatsReasmOKs(15)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
831 */
832 case COLUMN_IPIFSTATSREASMOKS:
833 var->val_len = sizeof(u_long);
834 var->type = ASN_COUNTER;
835 rc = ipIfStatsReasmOKs_get(rowreq_ctx, (u_long *) var->val.string);
836 break;
837
838 /*
839 * ipIfStatsReasmFails(16)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
840 */
841 case COLUMN_IPIFSTATSREASMFAILS:
842 var->val_len = sizeof(u_long);
843 var->type = ASN_COUNTER;
844 rc = ipIfStatsReasmFails_get(rowreq_ctx,
845 (u_long *) var->val.string);
846 break;
847
848 /*
849 * ipIfStatsInDiscards(17)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
850 */
851 case COLUMN_IPIFSTATSINDISCARDS:
852 var->val_len = sizeof(u_long);
853 var->type = ASN_COUNTER;
854 rc = ipIfStatsInDiscards_get(rowreq_ctx,
855 (u_long *) var->val.string);
856 break;
857
858 /*
859 * ipIfStatsInDelivers(18)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
860 */
861 case COLUMN_IPIFSTATSINDELIVERS:
862 var->val_len = sizeof(u_long);
863 var->type = ASN_COUNTER;
864 rc = ipIfStatsInDelivers_get(rowreq_ctx,
865 (u_long *) var->val.string);
866 break;
867
868 /*
869 * ipIfStatsHCInDelivers(19)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
870 */
871 case COLUMN_IPIFSTATSHCINDELIVERS:
872 var->val_len = sizeof(struct counter64);
873 var->type = ASN_COUNTER64;
874 rc = ipIfStatsHCInDelivers_get(rowreq_ctx,
875 (struct counter64 *) var->val.string);
876 break;
877
878 /*
879 * ipIfStatsOutRequests(20)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
880 */
881 case COLUMN_IPIFSTATSOUTREQUESTS:
882 var->val_len = sizeof(u_long);
883 var->type = ASN_COUNTER;
884 rc = ipIfStatsOutRequests_get(rowreq_ctx,
885 (u_long *) var->val.string);
886 break;
887
888 /*
889 * ipIfStatsHCOutRequests(21)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
890 */
891 case COLUMN_IPIFSTATSHCOUTREQUESTS:
892 var->val_len = sizeof(struct counter64);
893 var->type = ASN_COUNTER64;
894 rc = ipIfStatsHCOutRequests_get(rowreq_ctx,
895 (struct counter64 *) var->val.string);
896 break;
897
898 /*
899 * ipIfStatsOutForwDatagrams(23)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
900 */
901 case COLUMN_IPIFSTATSOUTFORWDATAGRAMS:
902 var->val_len = sizeof(u_long);
903 var->type = ASN_COUNTER;
904 rc = ipIfStatsOutForwDatagrams_get(rowreq_ctx,
905 (u_long *) var->val.string);
906 break;
907
908 /*
909 * ipIfStatsHCOutForwDatagrams(24)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
910 */
911 case COLUMN_IPIFSTATSHCOUTFORWDATAGRAMS:
912 var->val_len = sizeof(struct counter64);
913 var->type = ASN_COUNTER64;
914 rc = ipIfStatsHCOutForwDatagrams_get(rowreq_ctx,
915 (struct counter64 *) var->val.string);
916 break;
917
918 /*
919 * ipIfStatsOutDiscards(25)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
920 */
921 case COLUMN_IPIFSTATSOUTDISCARDS:
922 var->val_len = sizeof(u_long);
923 var->type = ASN_COUNTER;
924 rc = ipIfStatsOutDiscards_get(rowreq_ctx,
925 (u_long *) var->val.string);
926 break;
927
928 /*
929 * ipIfStatsOutFragReqds(26)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
930 */
931 case COLUMN_IPIFSTATSOUTFRAGREQDS:
932 var->val_len = sizeof(u_long);
933 var->type = ASN_COUNTER;
934 rc = ipIfStatsOutFragReqds_get(rowreq_ctx,
935 (u_long *) var->val.string);
936 break;
937
938 /*
939 * ipIfStatsOutFragOKs(27)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
940 */
941 case COLUMN_IPIFSTATSOUTFRAGOKS:
942 var->val_len = sizeof(u_long);
943 var->type = ASN_COUNTER;
944 rc = ipIfStatsOutFragOKs_get(rowreq_ctx,
945 (u_long *) var->val.string);
946 break;
947
948 /*
949 * ipIfStatsOutFragFails(28)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
950 */
951 case COLUMN_IPIFSTATSOUTFRAGFAILS:
952 var->val_len = sizeof(u_long);
953 var->type = ASN_COUNTER;
954 rc = ipIfStatsOutFragFails_get(rowreq_ctx,
955 (u_long *) var->val.string);
956 break;
957
958 /*
959 * ipIfStatsOutFragCreates(29)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
960 */
961 case COLUMN_IPIFSTATSOUTFRAGCREATES:
962 var->val_len = sizeof(u_long);
963 var->type = ASN_COUNTER;
964 rc = ipIfStatsOutFragCreates_get(rowreq_ctx,
965 (u_long *) var->val.string);
966 break;
967
968 /*
969 * ipIfStatsOutTransmits(30)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
970 */
971 case COLUMN_IPIFSTATSOUTTRANSMITS:
972 var->val_len = sizeof(u_long);
973 var->type = ASN_COUNTER;
974 rc = ipIfStatsOutTransmits_get(rowreq_ctx,
975 (u_long *) var->val.string);
976 break;
977
978 /*
979 * ipIfStatsHCOutTransmits(31)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
980 */
981 case COLUMN_IPIFSTATSHCOUTTRANSMITS:
982 var->val_len = sizeof(struct counter64);
983 var->type = ASN_COUNTER64;
984 rc = ipIfStatsHCOutTransmits_get(rowreq_ctx,
985 (struct counter64 *) var->val.string);
986 break;
987
988 /*
989 * ipIfStatsOutOctets(32)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
990 */
991 case COLUMN_IPIFSTATSOUTOCTETS:
992 var->val_len = sizeof(u_long);
993 var->type = ASN_COUNTER;
994 rc = ipIfStatsOutOctets_get(rowreq_ctx,
995 (u_long *) var->val.string);
996 break;
997
998 /*
999 * ipIfStatsHCOutOctets(33)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
1000 */
1001 case COLUMN_IPIFSTATSHCOUTOCTETS:
1002 var->val_len = sizeof(struct counter64);
1003 var->type = ASN_COUNTER64;
1004 rc = ipIfStatsHCOutOctets_get(rowreq_ctx, (struct counter64 *) var->val.string);
1005 break;
1006
1007 /*
1008 * ipIfStatsInMcastPkts(34)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
1009 */
1010 case COLUMN_IPIFSTATSINMCASTPKTS:
1011 var->val_len = sizeof(u_long);
1012 var->type = ASN_COUNTER;
1013 rc = ipIfStatsInMcastPkts_get(rowreq_ctx,
1014 (u_long *) var->val.string);
1015 break;
1016
1017 /*
1018 * ipIfStatsHCInMcastPkts(35)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
1019 */
1020 case COLUMN_IPIFSTATSHCINMCASTPKTS:
1021 var->val_len = sizeof(struct counter64);
1022 var->type = ASN_COUNTER64;
1023 rc = ipIfStatsHCInMcastPkts_get(rowreq_ctx,
1024 (struct counter64 *) var->val.string);
1025 break;
1026
1027 /*
1028 * ipIfStatsInMcastOctets(36)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
1029 */
1030 case COLUMN_IPIFSTATSINMCASTOCTETS:
1031 var->val_len = sizeof(u_long);
1032 var->type = ASN_COUNTER;
1033 rc = ipIfStatsInMcastOctets_get(rowreq_ctx,
1034 (u_long *) var->val.string);
1035 break;
1036
1037 /*
1038 * ipIfStatsHCInMcastOctets(37)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
1039 */
1040 case COLUMN_IPIFSTATSHCINMCASTOCTETS:
1041 var->val_len = sizeof(struct counter64);
1042 var->type = ASN_COUNTER64;
1043 rc = ipIfStatsHCInMcastOctets_get(rowreq_ctx,
1044 (struct counter64 *) var->val.string);
1045 break;
1046
1047 /*
1048 * ipIfStatsOutMcastPkts(38)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
1049 */
1050 case COLUMN_IPIFSTATSOUTMCASTPKTS:
1051 var->val_len = sizeof(u_long);
1052 var->type = ASN_COUNTER;
1053 rc = ipIfStatsOutMcastPkts_get(rowreq_ctx,
1054 (u_long *) var->val.string);
1055 break;
1056
1057 /*
1058 * ipIfStatsHCOutMcastPkts(39)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
1059 */
1060 case COLUMN_IPIFSTATSHCOUTMCASTPKTS:
1061 var->val_len = sizeof(struct counter64);
1062 var->type = ASN_COUNTER64;
1063 rc = ipIfStatsHCOutMcastPkts_get(rowreq_ctx,
1064 (struct counter64 *) var->val.string);
1065 break;
1066
1067 /*
1068 * ipIfStatsOutMcastOctets(40)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
1069 */
1070 case COLUMN_IPIFSTATSOUTMCASTOCTETS:
1071 var->val_len = sizeof(u_long);
1072 var->type = ASN_COUNTER;
1073 rc = ipIfStatsOutMcastOctets_get(rowreq_ctx,
1074 (u_long *) var->val.string);
1075 break;
1076
1077 /*
1078 * ipIfStatsHCOutMcastOctets(41)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
1079 */
1080 case COLUMN_IPIFSTATSHCOUTMCASTOCTETS:
1081 var->val_len = sizeof(struct counter64);
1082 var->type = ASN_COUNTER64;
1083 rc = ipIfStatsHCOutMcastOctets_get(rowreq_ctx,
1084 (struct counter64 *) var->val.string);
1085 break;
1086
1087 /*
1088 * ipIfStatsInBcastPkts(42)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
1089 */
1090 case COLUMN_IPIFSTATSINBCASTPKTS:
1091 var->val_len = sizeof(u_long);
1092 var->type = ASN_COUNTER;
1093 rc = ipIfStatsInBcastPkts_get(rowreq_ctx,
1094 (u_long *) var->val.string);
1095 break;
1096
1097 /*
1098 * ipIfStatsHCInBcastPkts(43)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
1099 */
1100 case COLUMN_IPIFSTATSHCINBCASTPKTS:
1101 var->val_len = sizeof(struct counter64);
1102 var->type = ASN_COUNTER64;
1103 rc = ipIfStatsHCInBcastPkts_get(rowreq_ctx,
1104 (struct counter64 *) var->val.string);
1105 break;
1106
1107 /*
1108 * ipIfStatsOutBcastPkts(44)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h
1109 */
1110 case COLUMN_IPIFSTATSOUTBCASTPKTS:
1111 var->val_len = sizeof(u_long);
1112 var->type = ASN_COUNTER;
1113 rc = ipIfStatsOutBcastPkts_get(rowreq_ctx,
1114 (u_long *) var->val.string);
1115 break;
1116
1117 /*
1118 * ipIfStatsHCOutBcastPkts(45)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h
1119 */
1120 case COLUMN_IPIFSTATSHCOUTBCASTPKTS:
1121 var->val_len = sizeof(struct counter64);
1122 var->type = ASN_COUNTER64;
1123 rc = ipIfStatsHCOutBcastPkts_get(rowreq_ctx,
1124 (struct counter64 *) var->val.string);
1125 break;
1126
1127 /*
1128 * ipIfStatsDiscontinuityTime(46)/TimeStamp/ASN_TIMETICKS/u_long(u_long)//l/A/w/e/r/d/h
1129 */
1130 case COLUMN_IPIFSTATSDISCONTINUITYTIME:
1131 var->val_len = sizeof(u_long);
1132 var->type = ASN_TIMETICKS;
1133 rc = ipIfStatsDiscontinuityTime_get(rowreq_ctx,
1134 (u_long *) var->val.string);
1135 break;
1136
1137 /*
1138 * ipIfStatsRefreshRate(47)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/h
1139 */
1140 case COLUMN_IPIFSTATSREFRESHRATE:
1141 var->val_len = sizeof(u_long);
1142 var->type = ASN_UNSIGNED;
1143 rc = ipIfStatsRefreshRate_get(rowreq_ctx,
1144 (u_long *) var->val.string);
1145 break;
1146
1147 default:
1148 if (IPIFSTATSTABLE_MIN_COL <= column
1149 && column <= IPIFSTATSTABLE_MAX_COL) {
1150 DEBUGMSGTL(("internal:ipIfStatsTable:_mfd_ipIfStatsTable_get_column", "assume column %d is reserved\n", column));
1151 rc = MFD_SKIP;
1152 } else {
1153 snmp_log(LOG_ERR,
1154 "unknown column %d in _ipIfStatsTable_get_column\n",
1155 column);
1156 }
1157 break;
1158 }
1159
1160 return rc;
1161 } /* _ipIfStatsTable_get_column */
1162
1163 int
1164 _mfd_ipIfStatsTable_get_values(netsnmp_mib_handler *handler,
1165 netsnmp_handler_registration *reginfo,
1166 netsnmp_agent_request_info *agtreq_info,
1167 netsnmp_request_info *requests)
1168 {
1169 ipIfStatsTable_rowreq_ctx *rowreq_ctx = (ipIfStatsTable_rowreq_ctx*)
1170 netsnmp_container_table_row_extract(requests);
1171 netsnmp_table_request_info *tri;
1172 u_char *old_string;
1173 void (*dataFreeHook) (void *);
1174 int rc;
1175
1176 DEBUGMSGTL(("internal:ipIfStatsTable:_mfd_ipIfStatsTable_get_values",
1177 "called\n"));
1178
1179 netsnmp_assert(NULL != rowreq_ctx);
1180
1181 for (; requests; requests = requests->next) {
1182 /*
1183 * save old pointer, so we can free it if replaced
1184 */
1185 old_string = requests->requestvb->val.string;
1186 dataFreeHook = requests->requestvb->dataFreeHook;
1187 if (NULL == requests->requestvb->val.string) {
1188 requests->requestvb->val.string = requests->requestvb->buf;
1189 requests->requestvb->val_len =
1190 sizeof(requests->requestvb->buf);
1191 } else if (requests->requestvb->buf ==
1192 requests->requestvb->val.string) {
1193 if (requests->requestvb->val_len !=
1194 sizeof(requests->requestvb->buf))
1195 requests->requestvb->val_len =
1196 sizeof(requests->requestvb->buf);
1197 }
1198
1199 /*
1200 * get column data
1201 */
1202 tri = netsnmp_extract_table_info(requests);
1203 if (NULL == tri)
1204 continue;
1205
1206 rc = _ipIfStatsTable_get_column(rowreq_ctx, requests->requestvb,
1207 tri->colnum);
1208 if (rc) {
1209 if (MFD_SKIP == rc) {
1210 requests->requestvb->type = SNMP_NOSUCHINSTANCE;
1211 rc = SNMP_ERR_NOERROR;
1212 }
1213 } else if (NULL == requests->requestvb->val.string) {
1214 snmp_log(LOG_ERR, "NULL varbind data pointer!\n");
1215 rc = SNMP_ERR_GENERR;
1216 }
1217 if (rc)
1218 netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc));
1219
1220 /*
1221 * if the buffer wasn't used previously for the old data (i.e. it
1222 * was allocated memory) and the get routine replaced the pointer,
1223 * we need to free the previous pointer.
1224 */
1225 if (old_string && (old_string != requests->requestvb->buf) &&
1226 (requests->requestvb->val.string != old_string)) {
1227 if (dataFreeHook)
1228 (*dataFreeHook) (old_string);
1229 else
1230 free(old_string);
1231 }
1232 } /* for results */
1233
1234 return SNMP_ERR_NOERROR;
1235 } /* _mfd_ipIfStatsTable_get_values */
1236
1237
1238 /***********************************************************************
1239 *
1240 * SET processing
1241 *
1242 ***********************************************************************/
1243
1244 /*
1245 * SET PROCESSING NOT APPLICABLE (per MIB or user setting)
1246 */
1247 /***********************************************************************
1248 *
1249 * DATA ACCESS
1250 *
1251 ***********************************************************************/
1252 static void _container_free(netsnmp_container * container);
1253
1254 /**
1255 * @internal
1256 */
1257 static int
1258 _cache_load(netsnmp_cache * cache, void *vmagic)
1259 {
1260 DEBUGMSGTL(("internal:ipIfStatsTable:_cache_load", "called\n"));
1261
1262 if ((NULL == cache) || (NULL == cache->magic)) {
1263 snmp_log(LOG_ERR, "invalid cache for ipIfStatsTable_cache_load\n");
1264 return -1;
1265 }
1266
1267 /** should only be called for an invalid or expired cache */
1268 netsnmp_assert((0 == cache->valid) || (1 == cache->expired));
1269
1270 /*
1271 * call user code
1272 */
1273 return ipIfStatsTable_container_load((netsnmp_container *) cache->
1274 magic);
1275 } /* _cache_load */
1276
1277 /**
1278 * @internal
1279 */
1280 static void
1281 _cache_free(netsnmp_cache * cache, void *magic)
1282 {
1283 netsnmp_container *container;
1284
1285 DEBUGMSGTL(("internal:ipIfStatsTable:_cache_free", "called\n"));
1286
1287 if ((NULL == cache) || (NULL == cache->magic)) {
1288 snmp_log(LOG_ERR, "invalid cache in ipIfStatsTable_cache_free\n");
1289 return;
1290 }
1291
1292 container = (netsnmp_container *) cache->magic;
1293
1294 _container_free(container);
1295 } /* _cache_free */
1296
1297 /**
1298 * @internal
1299 */
1300 static void
1301 _container_item_free(void *rowreq_ctx, void *context)
1302 {
1303 DEBUGMSGTL(("internal:ipIfStatsTable:_container_item_free",
1304 "called\n"));
1305
1306 if (NULL == rowreq_ctx)
1307 return;
1308
1309 ipIfStatsTable_release_rowreq_ctx(rowreq_ctx);
1310 } /* _container_item_free */
1311
1312 /**
1313 * @internal
1314 */
1315 static void
1316 _container_free(netsnmp_container * container)
1317 {
1318 DEBUGMSGTL(("internal:ipIfStatsTable:_container_free", "called\n"));
1319
1320 if (NULL == container) {
1321 snmp_log(LOG_ERR,
1322 "invalid container in ipIfStatsTable_container_free\n");
1323 return;
1324 }
1325
1326 /*
1327 * call user code
1328 */
1329 ipIfStatsTable_container_free(container);
1330
1331 /*
1332 * free all items. inefficient, but easy.
1333 */
1334 CONTAINER_CLEAR(container, _container_item_free, NULL);
1335 } /* _container_free */
1336
1337 /**
1338 * @internal
1339 * initialize the container with functions or wrappers
1340 */
1341 void
1342 _ipIfStatsTable_container_init(ipIfStatsTable_interface_ctx * if_ctx)
1343 {
1344 DEBUGMSGTL(("internal:ipIfStatsTable:_ipIfStatsTable_container_init",
1345 "called\n"));
1346
1347 /*
1348 * cache init
1349 */
1350 if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */
1351 _cache_load, _cache_free,
1352 ipIfStatsTable_oid,
1353 ipIfStatsTable_oid_size);
1354
1355 if (NULL == if_ctx->cache) {
1356 snmp_log(LOG_ERR, "error creating cache for ipIfStatsTable\n");
1357 return;
1358 }
1359
1360 if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET;
1361
1362 ipIfStatsTable_container_init(&if_ctx->container, if_ctx->cache);
1363 if (NULL == if_ctx->container)
1364 if_ctx->container =
1365 netsnmp_container_find("ipIfStatsTable:table_container");
1366 if (NULL == if_ctx->container) {
1367 snmp_log(LOG_ERR, "error creating container in "
1368 "ipIfStatsTable_container_init\n");
1369 return;
1370 }
1371
1372 if (NULL != if_ctx->cache)
1373 if_ctx->cache->magic = (void *) if_ctx->container;
1374 } /* _ipIfStatsTable_container_init */
1375
1376 /**
1377 * @internal
1378 * shutdown the container with functions or wrappers
1379 */
1380 void
1381 _ipIfStatsTable_container_shutdown(ipIfStatsTable_interface_ctx * if_ctx)
1382 {
1383 DEBUGMSGTL(("internal:ipIfStatsTable:_ipIfStatsTable_container_shutdown", "called\n"));
1384
1385 ipIfStatsTable_container_shutdown(if_ctx->container);
1386
1387 _container_free(if_ctx->container);
1388
1389 } /* _ipIfStatsTable_container_shutdown */
1390
1391
1392 #ifndef NETSNMP_FEATURE_REMOVE_IPIFSTATSTABLE_EXTERNAL_ACCESS
1393 ipIfStatsTable_rowreq_ctx *
1394 ipIfStatsTable_row_find_by_mib_index(ipIfStatsTable_mib_index * mib_idx)
1395 {
1396 ipIfStatsTable_rowreq_ctx *rowreq_ctx;
1397 oid oid_tmp[MAX_OID_LEN];
1398 netsnmp_index oid_idx;
1399 int rc;
1400
1401 /*
1402 * set up storage for OID
1403 */
1404 oid_idx.oids = oid_tmp;
1405 oid_idx.len = sizeof(oid_tmp) / sizeof(oid);
1406
1407 /*
1408 * convert
1409 */
1410 rc = ipIfStatsTable_index_to_oid(&oid_idx, mib_idx);
1411 if (MFD_SUCCESS != rc)
1412 return NULL;
1413
1414 rowreq_ctx = (ipIfStatsTable_rowreq_ctx*)CONTAINER_FIND(ipIfStatsTable_if_ctx.container, &oid_idx);
1415
1416 return rowreq_ctx;
1417 }
1418 #endif /* NETSNMP_FEATURE_REMOVE_IPIFSTATSTABLE_EXTERNAL_ACCESS */