Debian Codegraph @

agent/mibgroup/ip-forward-mib/ipCidrRouteTable/ipCidrRouteTable_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 "ipCidrRouteTable.h"
41
42
43 #include <net-snmp/agent/table_container.h>
44 #include <net-snmp/library/container.h>
45
46 #include "ipCidrRouteTable_interface.h"
47
48 #include <ctype.h>
49
50 netsnmp_feature_child_of(ipCidrRouteTable_external_access, libnetsnmpmibs);
51 netsnmp_feature_require(row_merge);
52 netsnmp_feature_require(baby_steps);
53 netsnmp_feature_require(table_container_row_insert);
54 netsnmp_feature_require(check_all_requests_error);
55
56
57 netsnmp_feature_child_of(ipCidrRouteTable_container_size, ipCidrRouteTable_external_access);
58 netsnmp_feature_child_of(ipCidrRouteTable_registration_set, ipCidrRouteTable_external_access);
59 netsnmp_feature_child_of(ipCidrRouteTable_registration_get, ipCidrRouteTable_external_access);
60 netsnmp_feature_child_of(ipCidrRouteTable_container_get, ipCidrRouteTable_external_access);
61 /**********************************************************************
62 **********************************************************************
63 ***
64 *** Table ipCidrRouteTable
65 ***
66 **********************************************************************
67 **********************************************************************/
68 /*
69 * IP-FORWARD-MIB::ipCidrRouteTable is subid 4 of ipForward.
70 * Its status is Deprecated.
71 * OID: .1.3.6.1.2.1.4.24.4, length: 9
72 */
73 typedef struct ipCidrRouteTable_interface_ctx_s {
74
75 netsnmp_container *container;
76 netsnmp_cache *cache;
77
78 ipCidrRouteTable_registration *user_ctx;
79
80 netsnmp_table_registration_info tbl_info;
81
82 netsnmp_baby_steps_access_methods access_multiplexer;
83
84 u_int table_dirty;
85
86 } ipCidrRouteTable_interface_ctx;
87
88 static ipCidrRouteTable_interface_ctx ipCidrRouteTable_if_ctx;
89
90 static void
91 _ipCidrRouteTable_container_init(ipCidrRouteTable_interface_ctx * if_ctx);
92 static void
93 _ipCidrRouteTable_container_shutdown(ipCidrRouteTable_interface_ctx *
94 if_ctx);
95
96 #ifndef NETSNMP_FEATURE_REMOVE_IPCIDRROUTETABLE_CONTAINER_GET
97 netsnmp_container *
98 ipCidrRouteTable_container_get(void)
99 {
100 return ipCidrRouteTable_if_ctx.container;
101 }
102 #endif /* NETSNMP_FEATURE_REMOVE_IPCIDRROUTETABLE_CONTAINER_GET */
103
104 #ifndef NETSNMP_FEATURE_REMOVE_IPCIDRROUTETABLE_REGISTRATION_GET
105 ipCidrRouteTable_registration *
106 ipCidrRouteTable_registration_get(void)
107 {
108 return ipCidrRouteTable_if_ctx.user_ctx;
109 }
110 #endif /* NETSNMP_FEATURE_REMOVE_IPCIDRROUTETABLE_REGISTRATION_GET */
111
112 #ifndef NETSNMP_FEATURE_REMOVE_IPCIDRROUTETABLE_REGISTRATION_SET
113 ipCidrRouteTable_registration *
114 ipCidrRouteTable_registration_set(ipCidrRouteTable_registration * newreg)
115 {
116 ipCidrRouteTable_registration *old = ipCidrRouteTable_if_ctx.user_ctx;
117 ipCidrRouteTable_if_ctx.user_ctx = newreg;
118 return old;
119 }
120 #endif /* NETSNMP_FEATURE_REMOVE_IPCIDRROUTETABLE_REGISTRATION_SET */
121
122 #ifndef NETSNMP_FEATURE_REMOVE_IPCIDRROUTETABLE_CONTAINER_SIZE
123 int
124 ipCidrRouteTable_container_size(void)
125 {
126 return CONTAINER_SIZE(ipCidrRouteTable_if_ctx.container);
127 }
128 #endif /* NETSNMP_FEATURE_REMOVE_IPCIDRROUTETABLE_CONTAINER_SIZE */
129
130 u_int
131 ipCidrRouteTable_dirty_get(void)
132 {
133 return ipCidrRouteTable_if_ctx.table_dirty;
134 }
135
136 void
137 ipCidrRouteTable_dirty_set(u_int status)
138 {
139 DEBUGMSGTL(("ipCidrRouteTable:ipCidrRouteTable_dirty_set",
140 "called. was %d, now %d\n",
141 ipCidrRouteTable_if_ctx.table_dirty, status));
142 ipCidrRouteTable_if_ctx.table_dirty = status;
143 }
144
145 /*
146 * mfd multiplexer modes
147 */
148 static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_pre_request;
149 static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_post_request;
150 static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_object_lookup;
151 static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_get_values;
152 #if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT))
153 static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_check_objects;
154 static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_undo_setup;
155 static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_set_values;
156 static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_undo_cleanup;
157 static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_undo_values;
158 static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_commit;
159 static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_undo_commit;
160 static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_irreversible_commit;
161
162 NETSNMP_STATIC_INLINE int
163 _ipCidrRouteTable_undo_column(ipCidrRouteTable_rowreq_ctx * rowreq_ctx,
164 netsnmp_variable_list * var,
165 int column);
166 #endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */
167
168 NETSNMP_STATIC_INLINE int
169 _ipCidrRouteTable_check_indexes(ipCidrRouteTable_rowreq_ctx * rowreq_ctx);
170
171 /**
172 * @internal
173 * Initialize the table ipCidrRouteTable
174 * (Define its contents and how it's structured)
175 */
176 void
177 _ipCidrRouteTable_initialize_interface(ipCidrRouteTable_registration *
178 reg_ptr, u_long flags)
179 {
180 netsnmp_baby_steps_access_methods *access_multiplexer =
181 &ipCidrRouteTable_if_ctx.access_multiplexer;
182 netsnmp_table_registration_info *tbl_info =
183 &ipCidrRouteTable_if_ctx.tbl_info;
184 netsnmp_handler_registration *reginfo;
185 netsnmp_mib_handler *handler;
186 int mfd_modes = 0;
187
188 DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_initialize_interface", "called\n"));
189
190
191 /*************************************************
192 *
193 * save interface context for ipCidrRouteTable
194 */
195 /*
196 * Setting up the table's definition
197 */
198 netsnmp_table_helper_add_indexes(tbl_info, ASN_IPADDRESS,
199 /** index: ipCidrRouteDest */
200 ASN_IPADDRESS,
201 /** index: ipCidrRouteMask */
202 ASN_INTEGER,
203 /** index: ipCidrRouteTos */
204 ASN_IPADDRESS,
205 /** index: ipCidrRouteNextHop */
206 0);
207
208 /*
209 * Define the minimum and maximum accessible columns. This
210 * optimizes retrieval.
211 */
212 tbl_info->min_column = IPCIDRROUTETABLE_MIN_COL;
213 tbl_info->max_column = IPCIDRROUTETABLE_MAX_COL;
214
215 /*
216 * save users context
217 */
218 ipCidrRouteTable_if_ctx.user_ctx = reg_ptr;
219
220 /*
221 * call data access initialization code
222 */
223 ipCidrRouteTable_init_data(reg_ptr);
224
225 /*
226 * set up the container
227 */
228 _ipCidrRouteTable_container_init(&ipCidrRouteTable_if_ctx);
229 if (NULL == ipCidrRouteTable_if_ctx.container) {
230 snmp_log(LOG_ERR,
231 "could not initialize container for ipCidrRouteTable\n");
232 return;
233 }
234
235 /*
236 * access_multiplexer: REQUIRED wrapper for get request handling
237 */
238 access_multiplexer->object_lookup =
239 _mfd_ipCidrRouteTable_object_lookup;
240 access_multiplexer->get_values = _mfd_ipCidrRouteTable_get_values;
241
242 /*
243 * no wrappers yet
244 */
245 access_multiplexer->pre_request = _mfd_ipCidrRouteTable_pre_request;
246 access_multiplexer->post_request = _mfd_ipCidrRouteTable_post_request;
247
248
249 #if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT))
250 /*
251 * REQUIRED wrappers for set request handling
252 */
253 access_multiplexer->object_syntax_checks =
254 _mfd_ipCidrRouteTable_check_objects;
255 access_multiplexer->undo_setup = _mfd_ipCidrRouteTable_undo_setup;
256 access_multiplexer->undo_cleanup = _mfd_ipCidrRouteTable_undo_cleanup;
257 access_multiplexer->set_values = _mfd_ipCidrRouteTable_set_values;
258 access_multiplexer->undo_sets = _mfd_ipCidrRouteTable_undo_values;
259
260 /*
261 * no wrappers yet
262 */
263 access_multiplexer->commit = _mfd_ipCidrRouteTable_commit;
264 access_multiplexer->undo_commit = _mfd_ipCidrRouteTable_undo_commit;
265 access_multiplexer->irreversible_commit =
266 _mfd_ipCidrRouteTable_irreversible_commit;
267 #endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */
268
269 /*************************************************
270 *
271 * Create a registration, save our reg data, register table.
272 */
273 DEBUGMSGTL(("ipCidrRouteTable:init_ipCidrRouteTable",
274 "Registering ipCidrRouteTable as a mibs-for-dummies table.\n"));
275 handler =
276 netsnmp_baby_steps_access_multiplexer_get(access_multiplexer);
277 reginfo =
278 netsnmp_handler_registration_create("ipCidrRouteTable", handler,
279 ipCidrRouteTable_oid,
280 ipCidrRouteTable_oid_size,
281 HANDLER_CAN_BABY_STEP |
282 HANDLER_CAN_RONLY);
283 if (NULL == reginfo) {
284 snmp_log(LOG_ERR, "error registering table ipCidrRouteTable\n");
285 return;
286 }
287 reginfo->my_reg_void = &ipCidrRouteTable_if_ctx;
288
289 /*************************************************
290 *
291 * set up baby steps handler, create it and inject it
292 */
293 if (access_multiplexer->object_lookup)
294 mfd_modes |= BABY_STEP_OBJECT_LOOKUP;
295 if (access_multiplexer->pre_request)
296 mfd_modes |= BABY_STEP_PRE_REQUEST;
297 if (access_multiplexer->post_request)
298 mfd_modes |= BABY_STEP_POST_REQUEST;
299
300 #if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT))
301 if (access_multiplexer->set_values)
302 mfd_modes |= BABY_STEP_SET_VALUES;
303 if (access_multiplexer->irreversible_commit)
304 mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT;
305 if (access_multiplexer->object_syntax_checks)
306 mfd_modes |= BABY_STEP_CHECK_OBJECT;
307
308 if (access_multiplexer->undo_setup)
309 mfd_modes |= BABY_STEP_UNDO_SETUP;
310 if (access_multiplexer->undo_cleanup)
311 mfd_modes |= BABY_STEP_UNDO_CLEANUP;
312 if (access_multiplexer->undo_sets)
313 mfd_modes |= BABY_STEP_UNDO_SETS;
314
315 if (access_multiplexer->row_creation)
316 mfd_modes |= BABY_STEP_ROW_CREATE;
317 if (access_multiplexer->consistency_checks)
318 mfd_modes |= BABY_STEP_CHECK_CONSISTENCY;
319 if (access_multiplexer->commit)
320 mfd_modes |= BABY_STEP_COMMIT;
321 if (access_multiplexer->undo_commit)
322 mfd_modes |= BABY_STEP_UNDO_COMMIT;
323 #endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */
324
325 handler = netsnmp_baby_steps_handler_get(mfd_modes);
326 netsnmp_inject_handler(reginfo, handler);
327
328 /*************************************************
329 *
330 * inject row_merge helper with prefix rootoid_len + 2 (entry.col)
331 */
332 handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2);
333 netsnmp_inject_handler(reginfo, handler);
334
335 /*************************************************
336 *
337 * inject container_table helper
338 */
339 handler =
340 netsnmp_container_table_handler_get(tbl_info,
341 ipCidrRouteTable_if_ctx.
342 container,
343 TABLE_CONTAINER_KEY_NETSNMP_INDEX);
344 netsnmp_inject_handler(reginfo, handler);
345
346 /*************************************************
347 *
348 * inject cache helper
349 */
350 if (NULL != ipCidrRouteTable_if_ctx.cache) {
351 handler = netsnmp_cache_handler_get(ipCidrRouteTable_if_ctx.cache);
352 netsnmp_inject_handler(reginfo, handler);
353 }
354
355 /*
356 * register table
357 */
358 netsnmp_register_table(reginfo, tbl_info);
359
360 } /* _ipCidrRouteTable_initialize_interface */
361
362 /**
363 * @internal
364 * Shutdown the table ipCidrRouteTable
365 */
366 void
367 _ipCidrRouteTable_shutdown_interface(ipCidrRouteTable_registration *
368 reg_ptr)
369 {
370 /*
371 * shutdown the container
372 */
373 _ipCidrRouteTable_container_shutdown(&ipCidrRouteTable_if_ctx);
374 }
375
376 void
377 ipCidrRouteTable_valid_columns_set(netsnmp_column_info *vc)
378 {
379 ipCidrRouteTable_if_ctx.tbl_info.valid_columns = vc;
380 } /* ipCidrRouteTable_valid_columns_set */
381
382 /**
383 * @internal
384 * convert the index component stored in the context to an oid
385 */
386 int
387 ipCidrRouteTable_index_to_oid(netsnmp_index * oid_idx,
388 ipCidrRouteTable_mib_index * mib_idx)
389 {
390 int err = SNMP_ERR_NOERROR;
391
392 /*
393 * temp storage for parsing indexes
394 */
395 /*
396 * ipCidrRouteDest(1)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h
397 */
398 netsnmp_variable_list var_ipCidrRouteDest;
399 /*
400 * ipCidrRouteMask(2)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h
401 */
402 netsnmp_variable_list var_ipCidrRouteMask;
403 /*
404 * ipCidrRouteTos(3)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h
405 */
406 netsnmp_variable_list var_ipCidrRouteTos;
407 /*
408 * ipCidrRouteNextHop(4)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h
409 */
410 netsnmp_variable_list var_ipCidrRouteNextHop;
411
412 /*
413 * set up varbinds
414 */
415 memset(&var_ipCidrRouteDest, 0x00, sizeof(var_ipCidrRouteDest));
416 var_ipCidrRouteDest.type = ASN_PRIV_IMPLIED_OCTET_STR;
417 memset(&var_ipCidrRouteMask, 0x00, sizeof(var_ipCidrRouteMask));
418 var_ipCidrRouteMask.type = ASN_PRIV_IMPLIED_OCTET_STR;
419 memset(&var_ipCidrRouteTos, 0x00, sizeof(var_ipCidrRouteTos));
420 var_ipCidrRouteTos.type = ASN_INTEGER;
421 memset(&var_ipCidrRouteNextHop, 0x00, sizeof(var_ipCidrRouteNextHop));
422 var_ipCidrRouteNextHop.type = ASN_PRIV_IMPLIED_OCTET_STR;
423
424 /*
425 * chain temp index varbinds together
426 */
427 var_ipCidrRouteDest.next_variable = &var_ipCidrRouteMask;
428 var_ipCidrRouteMask.next_variable = &var_ipCidrRouteTos;
429 var_ipCidrRouteTos.next_variable = &var_ipCidrRouteNextHop;
430 var_ipCidrRouteNextHop.next_variable = NULL;
431
432
433 DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_index_to_oid",
434 "called\n"));
435
436 /*
437 * ipCidrRouteDest(1)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h
438 */
439 snmp_set_var_value(&var_ipCidrRouteDest,
440 (u_char *) & mib_idx->ipCidrRouteDest,
441 sizeof(mib_idx->ipCidrRouteDest));
442
443 /*
444 * ipCidrRouteMask(2)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h
445 */
446 snmp_set_var_value(&var_ipCidrRouteMask,
447 (u_char *) & mib_idx->ipCidrRouteMask,
448 sizeof(mib_idx->ipCidrRouteMask));
449
450 /*
451 * ipCidrRouteTos(3)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h
452 */
453 snmp_set_var_value(&var_ipCidrRouteTos,
454 (u_char *) & mib_idx->ipCidrRouteTos,
455 sizeof(mib_idx->ipCidrRouteTos));
456
457 /*
458 * ipCidrRouteNextHop(4)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h
459 */
460 snmp_set_var_value(&var_ipCidrRouteNextHop,
461 (u_char *) & mib_idx->ipCidrRouteNextHop,
462 sizeof(mib_idx->ipCidrRouteNextHop));
463
464
465 err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len,
466 NULL, 0, &var_ipCidrRouteDest);
467 if (err)
468 snmp_log(LOG_ERR, "error %d converting index to oid\n", err);
469
470 /*
471 * parsing may have allocated memory. free it.
472 */
473 snmp_reset_var_buffers(&var_ipCidrRouteDest);
474
475 return err;
476 } /* ipCidrRouteTable_index_to_oid */
477
478 /**
479 * extract ipCidrRouteTable indexes from a netsnmp_index
480 *
481 * @retval SNMP_ERR_NOERROR : no error
482 * @retval SNMP_ERR_GENERR : error
483 */
484 int
485 ipCidrRouteTable_index_from_oid(netsnmp_index * oid_idx,
486 ipCidrRouteTable_mib_index * mib_idx)
487 {
488 int err = SNMP_ERR_NOERROR;
489
490 /*
491 * temp storage for parsing indexes
492 */
493 /*
494 * ipCidrRouteDest(1)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h
495 */
496 netsnmp_variable_list var_ipCidrRouteDest;
497 /*
498 * ipCidrRouteMask(2)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h
499 */
500 netsnmp_variable_list var_ipCidrRouteMask;
501 /*
502 * ipCidrRouteTos(3)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h
503 */
504 netsnmp_variable_list var_ipCidrRouteTos;
505 /*
506 * ipCidrRouteNextHop(4)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h
507 */
508 netsnmp_variable_list var_ipCidrRouteNextHop;
509
510 /*
511 * set up varbinds
512 */
513 memset(&var_ipCidrRouteDest, 0x00, sizeof(var_ipCidrRouteDest));
514 var_ipCidrRouteDest.type = ASN_IPADDRESS;
515 memset(&var_ipCidrRouteMask, 0x00, sizeof(var_ipCidrRouteMask));
516 var_ipCidrRouteMask.type = ASN_IPADDRESS;
517 memset(&var_ipCidrRouteTos, 0x00, sizeof(var_ipCidrRouteTos));
518 var_ipCidrRouteTos.type = ASN_INTEGER;
519 memset(&var_ipCidrRouteNextHop, 0x00, sizeof(var_ipCidrRouteNextHop));
520 var_ipCidrRouteNextHop.type = ASN_IPADDRESS;
521
522 /*
523 * chain temp index varbinds together
524 */
525 var_ipCidrRouteDest.next_variable = &var_ipCidrRouteMask;
526 var_ipCidrRouteMask.next_variable = &var_ipCidrRouteTos;
527 var_ipCidrRouteTos.next_variable = &var_ipCidrRouteNextHop;
528 var_ipCidrRouteNextHop.next_variable = NULL;
529
530
531 DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_index_from_oid",
532 "called\n"));
533
534 /*
535 * parse the oid into the individual index components
536 */
537 err = parse_oid_indexes(oid_idx->oids, oid_idx->len,
538 &var_ipCidrRouteDest);
539 if (err == SNMP_ERR_NOERROR) {
540 /*
541 * copy out values
542 */
543 mib_idx->ipCidrRouteDest =
544 *((u_long *) var_ipCidrRouteDest.val.string);
545 mib_idx->ipCidrRouteMask =
546 *((u_long *) var_ipCidrRouteMask.val.string);
547 mib_idx->ipCidrRouteTos =
548 *((long *) var_ipCidrRouteTos.val.string);
549 mib_idx->ipCidrRouteNextHop =
550 *((u_long *) var_ipCidrRouteNextHop.val.string);
551
552
553 }
554
555 /*
556 * parsing may have allocated memory. free it.
557 */
558 snmp_reset_var_buffers(&var_ipCidrRouteDest);
559
560 return err;
561 } /* ipCidrRouteTable_index_from_oid */
562
563
564 /*
565 *********************************************************************
566 * @internal
567 * allocate resources for a ipCidrRouteTable_rowreq_ctx
568 */
569 ipCidrRouteTable_rowreq_ctx *
570 ipCidrRouteTable_allocate_rowreq_ctx(ipCidrRouteTable_data * data,
571 void *user_init_ctx)
572 {
573 ipCidrRouteTable_rowreq_ctx *rowreq_ctx =
574 SNMP_MALLOC_TYPEDEF(ipCidrRouteTable_rowreq_ctx);
575
576 DEBUGMSGTL(("internal:ipCidrRouteTable:ipCidrRouteTable_allocate_rowreq_ctx", "called\n"));
577
578 if (NULL == rowreq_ctx) {
579 snmp_log(LOG_ERR, "Couldn't allocate memory for a "
580 "ipCidrRouteTable_rowreq_ctx.\n");
581 return NULL;
582 } else {
583 if (NULL != data) {
584 /*
585 * track if we got data from user
586 */
587 rowreq_ctx->rowreq_flags |= MFD_ROW_DATA_FROM_USER;
588 rowreq_ctx->data = data;
589 } else if (NULL ==
590 (rowreq_ctx->data = ipCidrRouteTable_allocate_data())) {
591 SNMP_FREE(rowreq_ctx);
592 return NULL;
593 }
594 }
595
596 /*
597 * undo context will be allocated when needed (in *_undo_setup)
598 */
599
600 rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp;
601
602 rowreq_ctx->ipCidrRouteTable_data_list = NULL;
603
604 /*
605 * if we allocated data, call init routine
606 */
607 if (!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) {
608 if (SNMPERR_SUCCESS !=
609 ipCidrRouteTable_rowreq_ctx_init(rowreq_ctx, user_init_ctx)) {
610 ipCidrRouteTable_release_rowreq_ctx(rowreq_ctx);
611 rowreq_ctx = NULL;
612 }
613 }
614
615 return rowreq_ctx;
616 } /* ipCidrRouteTable_allocate_rowreq_ctx */
617
618 /*
619 * @internal
620 * release resources for a ipCidrRouteTable_rowreq_ctx
621 */
622 void
623 ipCidrRouteTable_release_rowreq_ctx(ipCidrRouteTable_rowreq_ctx *
624 rowreq_ctx)
625 {
626 DEBUGMSGTL(("internal:ipCidrRouteTable:ipCidrRouteTable_release_rowreq_ctx", "called\n"));
627
628 netsnmp_assert(NULL != rowreq_ctx);
629
630 ipCidrRouteTable_rowreq_ctx_cleanup(rowreq_ctx);
631
632 /*
633 * for non-transient data, don't free data we got from the user
634 */
635 if ((rowreq_ctx->data) &&
636 !(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER))
637 ipCidrRouteTable_release_data(rowreq_ctx->data);
638
639 if (rowreq_ctx->undo)
640 ipCidrRouteTable_release_data(rowreq_ctx->undo);
641
642 /*
643 * free index oid pointer
644 */
645 if (rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp)
646 free(rowreq_ctx->oid_idx.oids);
647
648 SNMP_FREE(rowreq_ctx);
649 } /* ipCidrRouteTable_release_rowreq_ctx */
650
651 /**
652 * @internal
653 * wrapper
654 */
655 static int
656 _mfd_ipCidrRouteTable_pre_request(netsnmp_mib_handler *handler,
657 netsnmp_handler_registration *reginfo,
658 netsnmp_agent_request_info *agtreq_info,
659 netsnmp_request_info *requests)
660 {
661 int rc;
662
663 DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_pre_request", "called\n"));
664
665 if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) {
666 DEBUGMSGTL(("internal:ipCidrRouteTable",
667 "skipping additional pre_request\n"));
668 return SNMP_ERR_NOERROR;
669 }
670
671 rc = ipCidrRouteTable_pre_request(ipCidrRouteTable_if_ctx.user_ctx);
672 if (MFD_SUCCESS != rc) {
673 /*
674 * nothing we can do about it but log it
675 */
676 DEBUGMSGTL(("ipCidrRouteTable", "error %d from "
677 "ipCidrRouteTable_pre_request\n", rc));
678 netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
679 }
680
681 return SNMP_ERR_NOERROR;
682 } /* _mfd_ipCidrRouteTable_pre_request */
683
684 /**
685 * @internal
686 * wrapper
687 */
688 static int
689 _mfd_ipCidrRouteTable_post_request(netsnmp_mib_handler *handler,
690 netsnmp_handler_registration *reginfo,
691 netsnmp_agent_request_info *agtreq_info,
692 netsnmp_request_info *requests)
693 {
694 ipCidrRouteTable_rowreq_ctx *rowreq_ctx = (ipCidrRouteTable_rowreq_ctx*)
695 netsnmp_container_table_row_extract(requests);
696 int rc, packet_rc;
697
698 DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_post_request", "called\n"));
699
700 /*
701 * release row context, if deleted
702 */
703 if (rowreq_ctx && (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED))
704 ipCidrRouteTable_release_rowreq_ctx(rowreq_ctx);
705
706 /*
707 * wait for last call before calling user
708 */
709 if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) {
710 DEBUGMSGTL(("internal:ipCidrRouteTable",
711 "waiting for last post_request\n"));
712 return SNMP_ERR_NOERROR;
713 }
714
715 packet_rc = netsnmp_check_all_requests_error(agtreq_info->asp, 0);
716 if ((MFD_SUCCESS != packet_rc) && ipCidrRouteTable_dirty_get()) {
717 /*
718 * we shouldn't get here. the undo steps should also clear
719 * the dirty flags.
720 */
721 snmp_log(LOG_WARNING,
722 "ipCidrRouteTable dirty flag set in post_request "
723 "but status != SUCCESS.\n");
724 }
725
726 rc = ipCidrRouteTable_post_request(ipCidrRouteTable_if_ctx.user_ctx,
727 packet_rc);
728 if (MFD_SUCCESS != rc) {
729 /*
730 * nothing we can do about it but log it
731 */
732 DEBUGMSGTL(("ipCidrRouteTable", "error %d from "
733 "ipCidrRouteTable_post_request\n", rc));
734 }
735
736 return SNMP_ERR_NOERROR;
737 } /* _mfd_ipCidrRouteTable_post_request */
738
739 /**
740 * @internal
741 * wrapper
742 */
743 static ipCidrRouteTable_rowreq_ctx *
744 _mfd_ipCidrRouteTable_rowreq_from_index(netsnmp_index * oid_idx,
745 int *rc_ptr)
746 {
747 ipCidrRouteTable_rowreq_ctx *rowreq_ctx;
748 ipCidrRouteTable_mib_index mib_idx;
749 int rc;
750
751 DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_rowreq_from_index", "called\n"));
752
753 if (NULL == rc_ptr)
754 rc_ptr = &rc;
755 *rc_ptr = MFD_SUCCESS;
756
757 memset(&mib_idx, 0x0, sizeof(mib_idx));
758
759 /*
760 * try to parse oid
761 */
762 *rc_ptr = ipCidrRouteTable_index_from_oid(oid_idx, &mib_idx);
763 if (MFD_SUCCESS != *rc_ptr) {
764 DEBUGMSGT(("ipCidrRouteTable", "error parsing index\n"));
765 return NULL;
766 }
767
768 /*
769 * allocate new context
770 */
771 rowreq_ctx = ipCidrRouteTable_allocate_rowreq_ctx(NULL, NULL);
772 if (NULL == rowreq_ctx) {
773 *rc_ptr = MFD_ERROR;
774 return NULL; /* msg already logged */
775 }
776
777 memcpy(&rowreq_ctx->tbl_idx, &mib_idx, sizeof(mib_idx));
778
779 /*
780 * check indexes
781 */
782 *rc_ptr = _ipCidrRouteTable_check_indexes(rowreq_ctx);
783 if (MFD_SUCCESS != *rc_ptr) {
784 netsnmp_assert((*rc_ptr == SNMP_ERR_NOCREATION) ||
785 (*rc_ptr == SNMP_ERR_INCONSISTENTNAME));
786 ipCidrRouteTable_release_rowreq_ctx(rowreq_ctx);
787 return NULL;
788 }
789
790 /*
791 * copy indexes
792 */
793 rowreq_ctx->oid_idx.len = oid_idx->len;
794 memcpy(rowreq_ctx->oid_idx.oids, oid_idx->oids,
795 oid_idx->len * sizeof(oid));
796
797 return rowreq_ctx;
798 } /* _mfd_ipCidrRouteTable_rowreq_from_index */
799
800
801 /**
802 * @internal
803 * wrapper
804 */
805 static int
806 _mfd_ipCidrRouteTable_object_lookup(netsnmp_mib_handler *handler,
807 netsnmp_handler_registration *reginfo,
808 netsnmp_agent_request_info
809 *agtreq_info,
810 netsnmp_request_info *requests)
811 {
812 int rc = SNMP_ERR_NOERROR;
813 ipCidrRouteTable_rowreq_ctx *rowreq_ctx = (ipCidrRouteTable_rowreq_ctx*)
814 netsnmp_container_table_row_extract(requests);
815
816 DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_object_lookup", "called\n"));
817
818 /*
819 * get our context from mfd
820 * ipCidrRouteTable_interface_ctx *if_ctx =
821 * (ipCidrRouteTable_interface_ctx *)reginfo->my_reg_void;
822 */
823
824 if (NULL == rowreq_ctx) {
825 netsnmp_table_request_info *tblreq_info;
826 netsnmp_index oid_idx;
827
828 tblreq_info = netsnmp_extract_table_info(requests);
829 if (NULL == tblreq_info) {
830 snmp_log(LOG_ERR, "request had no table info\n");
831 return MFD_ERROR;
832 }
833
834 /*
835 * try create rowreq
836 */
837 oid_idx.oids = tblreq_info->index_oid;
838 oid_idx.len = tblreq_info->index_oid_len;
839
840 rowreq_ctx =
841 _mfd_ipCidrRouteTable_rowreq_from_index(&oid_idx, &rc);
842 if (MFD_SUCCESS == rc) {
843 netsnmp_assert(NULL != rowreq_ctx);
844 rowreq_ctx->rowreq_flags |= MFD_ROW_CREATED;
845 /*
846 * add rowreq_ctx to request data lists
847 */
848 netsnmp_container_table_row_insert(requests, (netsnmp_index *)
849 rowreq_ctx);
850 }
851 }
852
853 if (MFD_SUCCESS != rc)
854 netsnmp_request_set_error_all(requests, rc);
855 else
856 ipCidrRouteTable_row_prep(rowreq_ctx);
857
858 return SNMP_VALIDATE_ERR(rc);
859 } /* _mfd_ipCidrRouteTable_object_lookup */
860
861 /***********************************************************************
862 *
863 * GET processing
864 *
865 ***********************************************************************/
866 /*
867 * @internal
868 * Retrieve the value for a particular column
869 */
870 NETSNMP_STATIC_INLINE int
871 _ipCidrRouteTable_get_column(ipCidrRouteTable_rowreq_ctx * rowreq_ctx,
872 netsnmp_variable_list * var, int column)
873 {
874 int rc = SNMPERR_SUCCESS;
875
876 DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_get_column", "called for %d\n", column));
877
878
879 netsnmp_assert(NULL != rowreq_ctx);
880
881 switch (column) {
882
883 /*
884 * (INDEX) ipCidrRouteDest(1)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h
885 */
886 case COLUMN_IPCIDRROUTEDEST:
887 var->type = ASN_IPADDRESS;
888 var->val_len = sizeof(in_addr_t);
889 memcpy(var->val.integer, &rowreq_ctx->tbl_idx.ipCidrRouteDest, sizeof(in_addr_t));
890 break;
891
892 /*
893 * (INDEX) ipCidrRouteMask(2)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h
894 */
895 case COLUMN_IPCIDRROUTEMASK:
896 var->type = ASN_IPADDRESS;
897 var->val_len = sizeof(in_addr_t);
898 memcpy(var->val.integer, &rowreq_ctx->tbl_idx.ipCidrRouteMask, sizeof(in_addr_t));
899 break;
900
901 /*
902 * (INDEX) ipCidrRouteTos(3)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h
903 */
904 case COLUMN_IPCIDRROUTETOS:
905 var->type = ASN_INTEGER;
906 var->val_len = sizeof(long);
907 (*var->val.integer) = rowreq_ctx->tbl_idx.ipCidrRouteTos;
908 break;
909
910 /*
911 * (INDEX) ipCidrRouteNextHop(4)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h
912 */
913 case COLUMN_IPCIDRROUTENEXTHOP:
914 var->type = ASN_IPADDRESS;
915 var->val_len = sizeof(in_addr_t);
916 memcpy(var->val.integer, &rowreq_ctx->tbl_idx.ipCidrRouteNextHop, sizeof(in_addr_t));
917 break;
918
919 /*
920 * ipCidrRouteIfIndex(5)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
921 */
922 case COLUMN_IPCIDRROUTEIFINDEX:
923 var->val_len = sizeof(long);
924 var->type = ASN_INTEGER;
925 rc = ipCidrRouteIfIndex_get(rowreq_ctx, (long *) var->val.string);
926 break;
927
928 /*
929 * ipCidrRouteType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h
930 */
931 case COLUMN_IPCIDRROUTETYPE:
932 var->val_len = sizeof(u_long);
933 var->type = ASN_INTEGER;
934 rc = ipCidrRouteType_get(rowreq_ctx, (u_long *) var->val.string);
935 break;
936
937 /*
938 * ipCidrRouteProto(7)/INTEGER/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h
939 */
940 case COLUMN_IPCIDRROUTEPROTO:
941 var->val_len = sizeof(u_long);
942 var->type = ASN_INTEGER;
943 rc = ipCidrRouteProto_get(rowreq_ctx, (u_long *) var->val.string);
944 break;
945
946 /*
947 * ipCidrRouteAge(8)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/r/D/h
948 */
949 case COLUMN_IPCIDRROUTEAGE:
950 var->val_len = sizeof(long);
951 var->type = ASN_INTEGER;
952 rc = ipCidrRouteAge_get(rowreq_ctx, (long *) var->val.string);
953 break;
954
955 /*
956 * ipCidrRouteInfo(9)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/A/W/e/r/d/h
957 */
958 case COLUMN_IPCIDRROUTEINFO:
959 var->type = ASN_OBJECT_ID;
960 rc = ipCidrRouteInfo_get(rowreq_ctx, (oid **) & var->val.string,
961 &var->val_len);
962 break;
963
964 /*
965 * ipCidrRouteNextHopAS(10)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
966 */
967 case COLUMN_IPCIDRROUTENEXTHOPAS:
968 var->val_len = sizeof(long);
969 var->type = ASN_INTEGER;
970 rc = ipCidrRouteNextHopAS_get(rowreq_ctx,
971 (long *) var->val.string);
972 break;
973
974 /*
975 * ipCidrRouteMetric1(11)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
976 */
977 case COLUMN_IPCIDRROUTEMETRIC1:
978 var->val_len = sizeof(long);
979 var->type = ASN_INTEGER;
980 rc = ipCidrRouteMetric1_get(rowreq_ctx, (long *) var->val.string);
981 break;
982
983 /*
984 * ipCidrRouteMetric2(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
985 */
986 case COLUMN_IPCIDRROUTEMETRIC2:
987 var->val_len = sizeof(long);
988 var->type = ASN_INTEGER;
989 rc = ipCidrRouteMetric2_get(rowreq_ctx, (long *) var->val.string);
990 break;
991
992 /*
993 * ipCidrRouteMetric3(13)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
994 */
995 case COLUMN_IPCIDRROUTEMETRIC3:
996 var->val_len = sizeof(long);
997 var->type = ASN_INTEGER;
998 rc = ipCidrRouteMetric3_get(rowreq_ctx, (long *) var->val.string);
999 break;
1000
1001 /*
1002 * ipCidrRouteMetric4(14)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
1003 */
1004 case COLUMN_IPCIDRROUTEMETRIC4:
1005 var->val_len = sizeof(long);
1006 var->type = ASN_INTEGER;
1007 rc = ipCidrRouteMetric4_get(rowreq_ctx, (long *) var->val.string);
1008 break;
1009
1010 /*
1011 * ipCidrRouteMetric5(15)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
1012 */
1013 case COLUMN_IPCIDRROUTEMETRIC5:
1014 var->val_len = sizeof(long);
1015 var->type = ASN_INTEGER;
1016 rc = ipCidrRouteMetric5_get(rowreq_ctx, (long *) var->val.string);
1017 break;
1018
1019 /*
1020 * ipCidrRouteStatus(16)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h
1021 */
1022 case COLUMN_IPCIDRROUTESTATUS:
1023 var->val_len = sizeof(u_long);
1024 var->type = ASN_INTEGER;
1025 rc = ipCidrRouteStatus_get(rowreq_ctx, (u_long *) var->val.string);
1026 break;
1027
1028 default:
1029 snmp_log(LOG_ERR,
1030 "unknown column %d in _ipCidrRouteTable_get_column\n",
1031 column);
1032 break;
1033 }
1034
1035 return rc;
1036 } /* _ipCidrRouteTable_get_column */
1037
1038 int
1039 _mfd_ipCidrRouteTable_get_values(netsnmp_mib_handler *handler,
1040 netsnmp_handler_registration *reginfo,
1041 netsnmp_agent_request_info *agtreq_info,
1042 netsnmp_request_info *requests)
1043 {
1044 ipCidrRouteTable_rowreq_ctx *rowreq_ctx = (ipCidrRouteTable_rowreq_ctx*)
1045 netsnmp_container_table_row_extract(requests);
1046 netsnmp_table_request_info *tri;
1047 u_char *old_string;
1048 void (*dataFreeHook) (void *);
1049 int rc;
1050
1051 DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_get_values", "called\n"));
1052
1053 netsnmp_assert(NULL != rowreq_ctx);
1054
1055 for (; requests; requests = requests->next) {
1056 /*
1057 * save old pointer, so we can free it if replaced
1058 */
1059 old_string = requests->requestvb->val.string;
1060 dataFreeHook = requests->requestvb->dataFreeHook;
1061 if (NULL == requests->requestvb->val.string) {
1062 requests->requestvb->val.string = requests->requestvb->buf;
1063 requests->requestvb->val_len =
1064 sizeof(requests->requestvb->buf);
1065 } else if (requests->requestvb->buf ==
1066 requests->requestvb->val.string) {
1067 if (requests->requestvb->val_len !=
1068 sizeof(requests->requestvb->buf))
1069 requests->requestvb->val_len =
1070 sizeof(requests->requestvb->buf);
1071 }
1072
1073 /*
1074 * get column data
1075 */
1076 tri = netsnmp_extract_table_info(requests);
1077 if (NULL == tri)
1078 continue;
1079
1080 rc = _ipCidrRouteTable_get_column(rowreq_ctx, requests->requestvb,
1081 tri->colnum);
1082 if (rc) {
1083 if (MFD_SKIP == rc) {
1084 requests->requestvb->type = SNMP_NOSUCHINSTANCE;
1085 rc = SNMP_ERR_NOERROR;
1086 }
1087 } else if (NULL == requests->requestvb->val.string) {
1088 snmp_log(LOG_ERR, "NULL varbind data pointer!\n");
1089 rc = SNMP_ERR_GENERR;
1090 }
1091 if (rc)
1092 netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc));
1093
1094 /*
1095 * if the buffer wasn't used previously for the old data (i.e. it
1096 * was allocated memory) and the get routine replaced the pointer,
1097 * we need to free the previous pointer.
1098 */
1099 if (old_string && (old_string != requests->requestvb->buf) &&
1100 (requests->requestvb->val.string != old_string)) {
1101 if (dataFreeHook)
1102 (*dataFreeHook) (old_string);
1103 else
1104 free(old_string);
1105 }
1106 } /* for results */
1107
1108 return SNMP_ERR_NOERROR;
1109 } /* _mfd_ipCidrRouteTable_get_values */
1110
1111 NETSNMP_STATIC_INLINE int
1112 _ipCidrRouteTable_check_indexes(ipCidrRouteTable_rowreq_ctx * rowreq_ctx)
1113 {
1114 int rc = SNMPERR_SUCCESS;
1115
1116 DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_check_indexes", "called\n"));
1117
1118 netsnmp_assert(NULL != rowreq_ctx);
1119
1120
1121 /*
1122 * (INDEX) ipCidrRouteDest(1)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h
1123 */
1124 if (MFD_SUCCESS != rc)
1125 return rc;
1126 rc = ipCidrRouteDest_check_index(rowreq_ctx);
1127 if (MFD_SUCCESS != rc)
1128 return SNMP_ERR_NOCREATION;
1129
1130 /*
1131 * (INDEX) ipCidrRouteMask(2)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h
1132 */
1133 if (MFD_SUCCESS != rc)
1134 return rc;
1135 rc = ipCidrRouteMask_check_index(rowreq_ctx);
1136 if (MFD_SUCCESS != rc)
1137 return SNMP_ERR_NOCREATION;
1138
1139 /*
1140 * (INDEX) ipCidrRouteTos(3)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h
1141 */
1142 /*
1143 * check defined range(s).
1144 */
1145 if ((SNMPERR_SUCCESS == rc)
1146 && ((rowreq_ctx->tbl_idx.ipCidrRouteTos < 0)
1147 || (rowreq_ctx->tbl_idx.ipCidrRouteTos > 2147483647))
1148 ) {
1149 rc = SNMP_ERR_WRONGVALUE;
1150 }
1151 if (MFD_SUCCESS != rc)
1152 return rc;
1153 rc = ipCidrRouteTos_check_index(rowreq_ctx);
1154 if (MFD_SUCCESS != rc)
1155 return SNMP_ERR_NOCREATION;
1156
1157 /*
1158 * (INDEX) ipCidrRouteNextHop(4)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h
1159 */
1160 if (MFD_SUCCESS != rc)
1161 return rc;
1162 rc = ipCidrRouteNextHop_check_index(rowreq_ctx);
1163 if (MFD_SUCCESS != rc)
1164 return SNMP_ERR_NOCREATION;
1165
1166 /*
1167 * if individual parts look ok, check them as a whole
1168 */
1169 return ipCidrRouteTable_validate_index(ipCidrRouteTable_if_ctx.
1170 user_ctx, rowreq_ctx);
1171 } /* _ipCidrRouteTable_check_indexes */
1172
1173 #if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT))
1174 /***********************************************************************
1175 *
1176 * SET processing
1177 *
1178 ***********************************************************************/
1179
1180 /*----------------------------------------------------------------------
1181 *
1182 * SET: Syntax checks
1183 *
1184 *---------------------------------------------------------------------*/
1185 /*
1186 * @internal
1187 * Check the syntax for a particular column
1188 */
1189 NETSNMP_STATIC_INLINE int
1190 _ipCidrRouteTable_check_column(ipCidrRouteTable_rowreq_ctx * rowreq_ctx,
1191 netsnmp_variable_list * var, int column)
1192 {
1193 int rc = SNMPERR_SUCCESS;
1194
1195 DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_check_column",
1196 "called for %d\n", column));
1197
1198 netsnmp_assert(NULL != rowreq_ctx);
1199
1200 switch (column) {
1201 /*
1202 * (INDEX) ipCidrRouteDest(1)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h
1203 */
1204 case COLUMN_IPCIDRROUTEDEST:
1205 rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */
1206 break;
1207 /*
1208 * (INDEX) ipCidrRouteMask(2)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h
1209 */
1210 case COLUMN_IPCIDRROUTEMASK:
1211 rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */
1212 break;
1213 /*
1214 * (INDEX) ipCidrRouteTos(3)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h
1215 */
1216 case COLUMN_IPCIDRROUTETOS:
1217 rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */
1218 break;
1219 /*
1220 * (INDEX) ipCidrRouteNextHop(4)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h
1221 */
1222 case COLUMN_IPCIDRROUTENEXTHOP:
1223 rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */
1224 break;
1225
1226 /*
1227 * ipCidrRouteIfIndex(5)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
1228 */
1229 case COLUMN_IPCIDRROUTEIFINDEX:
1230 rc = netsnmp_check_vb_type(var, ASN_INTEGER);
1231 if (SNMPERR_SUCCESS != rc) {
1232 DEBUGMSGTL(("ipCidrRouteTable:_ipCidrRouteTable_check_column:ipCidrRouteIfIndex", "varbind validation failed (eg bad type or size)\n"));
1233 } else {
1234 rc = ipCidrRouteIfIndex_check_value(rowreq_ctx,
1235 *((long *) var->val.
1236 string));
1237 if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
1238 && (MFD_NOT_VALID_NOW != rc)) {
1239 snmp_log(LOG_ERR,
1240 "bad rc %d from ipCidrRouteIfIndex_check_value\n",
1241 rc);
1242 rc = SNMP_ERR_GENERR;
1243 }
1244 }
1245 break;
1246
1247 /*
1248 * ipCidrRouteType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h
1249 */
1250 case COLUMN_IPCIDRROUTETYPE:
1251 rc = netsnmp_check_vb_type(var, ASN_INTEGER);
1252 /*
1253 * check that the value is one of defined enums
1254 */
1255 if ((SNMPERR_SUCCESS == rc)
1256 && (*var->val.integer != IPCIDRROUTETYPE_OTHER)
1257 && (*var->val.integer != IPCIDRROUTETYPE_REJECT)
1258 && (*var->val.integer != IPCIDRROUTETYPE_LOCAL)
1259 && (*var->val.integer != IPCIDRROUTETYPE_REMOTE)
1260 ) {
1261 rc = SNMP_ERR_WRONGVALUE;
1262 }
1263 if (SNMPERR_SUCCESS != rc) {
1264 DEBUGMSGTL(("ipCidrRouteTable:_ipCidrRouteTable_check_column:ipCidrRouteType", "varbind validation failed (eg bad type or size)\n"));
1265 } else {
1266 rc = ipCidrRouteType_check_value(rowreq_ctx,
1267 *((u_long *) var->val.
1268 string));
1269 if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
1270 && (MFD_NOT_VALID_NOW != rc)) {
1271 snmp_log(LOG_ERR,
1272 "bad rc %d from ipCidrRouteType_check_value\n",
1273 rc);
1274 rc = SNMP_ERR_GENERR;
1275 }
1276 }
1277 break;
1278
1279 /*
1280 * ipCidrRouteProto(7)/INTEGER/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h
1281 */
1282 case COLUMN_IPCIDRROUTEPROTO:
1283 rc = SNMP_ERR_NOTWRITABLE;
1284 break;
1285
1286 /*
1287 * ipCidrRouteAge(8)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/r/D/h
1288 */
1289 case COLUMN_IPCIDRROUTEAGE:
1290 rc = SNMP_ERR_NOTWRITABLE;
1291 break;
1292
1293 /*
1294 * ipCidrRouteInfo(9)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/A/W/e/r/d/h
1295 */
1296 case COLUMN_IPCIDRROUTEINFO:
1297 rc = netsnmp_check_vb_type(var, ASN_OBJECT_ID);
1298 if (SNMPERR_SUCCESS != rc) {
1299 DEBUGMSGTL(("ipCidrRouteTable:_ipCidrRouteTable_check_column:ipCidrRouteInfo", "varbind validation failed (eg bad type or size)\n"));
1300 } else {
1301 rc = ipCidrRouteInfo_check_value(rowreq_ctx,
1302 (oid *) var->val.string,
1303 var->val_len);
1304 if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
1305 && (MFD_NOT_VALID_NOW != rc)) {
1306 snmp_log(LOG_ERR,
1307 "bad rc %d from ipCidrRouteInfo_check_value\n",
1308 rc);
1309 rc = SNMP_ERR_GENERR;
1310 }
1311 }
1312 break;
1313
1314 /*
1315 * ipCidrRouteNextHopAS(10)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
1316 */
1317 case COLUMN_IPCIDRROUTENEXTHOPAS:
1318 rc = netsnmp_check_vb_type(var, ASN_INTEGER);
1319 if (SNMPERR_SUCCESS != rc) {
1320 DEBUGMSGTL(("ipCidrRouteTable:_ipCidrRouteTable_check_column:ipCidrRouteNextHopAS", "varbind validation failed (eg bad type or size)\n"));
1321 } else {
1322 rc = ipCidrRouteNextHopAS_check_value(rowreq_ctx,
1323 *((long *) var->val.
1324 string));
1325 if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
1326 && (MFD_NOT_VALID_NOW != rc)) {
1327 snmp_log(LOG_ERR,
1328 "bad rc %d from ipCidrRouteNextHopAS_check_value\n",
1329 rc);
1330 rc = SNMP_ERR_GENERR;
1331 }
1332 }
1333 break;
1334
1335 /*
1336 * ipCidrRouteMetric1(11)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
1337 */
1338 case COLUMN_IPCIDRROUTEMETRIC1:
1339 rc = netsnmp_check_vb_type(var, ASN_INTEGER);
1340 if (SNMPERR_SUCCESS != rc) {
1341 DEBUGMSGTL(("ipCidrRouteTable:_ipCidrRouteTable_check_column:ipCidrRouteMetric1", "varbind validation failed (eg bad type or size)\n"));
1342 } else {
1343 rc = ipCidrRouteMetric1_check_value(rowreq_ctx,
1344 *((long *) var->val.
1345 string));
1346 if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
1347 && (MFD_NOT_VALID_NOW != rc)) {
1348 snmp_log(LOG_ERR,
1349 "bad rc %d from ipCidrRouteMetric1_check_value\n",
1350 rc);
1351 rc = SNMP_ERR_GENERR;
1352 }
1353 }
1354 break;
1355
1356 /*
1357 * ipCidrRouteMetric2(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
1358 */
1359 case COLUMN_IPCIDRROUTEMETRIC2:
1360 rc = netsnmp_check_vb_type(var, ASN_INTEGER);
1361 if (SNMPERR_SUCCESS != rc) {
1362 DEBUGMSGTL(("ipCidrRouteTable:_ipCidrRouteTable_check_column:ipCidrRouteMetric2", "varbind validation failed (eg bad type or size)\n"));
1363 } else {
1364 rc = ipCidrRouteMetric2_check_value(rowreq_ctx,
1365 *((long *) var->val.
1366 string));
1367 if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
1368 && (MFD_NOT_VALID_NOW != rc)) {
1369 snmp_log(LOG_ERR,
1370 "bad rc %d from ipCidrRouteMetric2_check_value\n",
1371 rc);
1372 rc = SNMP_ERR_GENERR;
1373 }
1374 }
1375 break;
1376
1377 /*
1378 * ipCidrRouteMetric3(13)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
1379 */
1380 case COLUMN_IPCIDRROUTEMETRIC3:
1381 rc = netsnmp_check_vb_type(var, ASN_INTEGER);
1382 if (SNMPERR_SUCCESS != rc) {
1383 DEBUGMSGTL(("ipCidrRouteTable:_ipCidrRouteTable_check_column:ipCidrRouteMetric3", "varbind validation failed (eg bad type or size)\n"));
1384 } else {
1385 rc = ipCidrRouteMetric3_check_value(rowreq_ctx,
1386 *((long *) var->val.
1387 string));
1388 if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
1389 && (MFD_NOT_VALID_NOW != rc)) {
1390 snmp_log(LOG_ERR,
1391 "bad rc %d from ipCidrRouteMetric3_check_value\n",
1392 rc);
1393 rc = SNMP_ERR_GENERR;
1394 }
1395 }
1396 break;
1397
1398 /*
1399 * ipCidrRouteMetric4(14)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
1400 */
1401 case COLUMN_IPCIDRROUTEMETRIC4:
1402 rc = netsnmp_check_vb_type(var, ASN_INTEGER);
1403 if (SNMPERR_SUCCESS != rc) {
1404 DEBUGMSGTL(("ipCidrRouteTable:_ipCidrRouteTable_check_column:ipCidrRouteMetric4", "varbind validation failed (eg bad type or size)\n"));
1405 } else {
1406 rc = ipCidrRouteMetric4_check_value(rowreq_ctx,
1407 *((long *) var->val.
1408 string));
1409 if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
1410 && (MFD_NOT_VALID_NOW != rc)) {
1411 snmp_log(LOG_ERR,
1412 "bad rc %d from ipCidrRouteMetric4_check_value\n",
1413 rc);
1414 rc = SNMP_ERR_GENERR;
1415 }
1416 }
1417 break;
1418
1419 /*
1420 * ipCidrRouteMetric5(15)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
1421 */
1422 case COLUMN_IPCIDRROUTEMETRIC5:
1423 rc = netsnmp_check_vb_type(var, ASN_INTEGER);
1424 if (SNMPERR_SUCCESS != rc) {
1425 DEBUGMSGTL(("ipCidrRouteTable:_ipCidrRouteTable_check_column:ipCidrRouteMetric5", "varbind validation failed (eg bad type or size)\n"));
1426 } else {
1427 rc = ipCidrRouteMetric5_check_value(rowreq_ctx,
1428 *((long *) var->val.
1429 string));
1430 if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
1431 && (MFD_NOT_VALID_NOW != rc)) {
1432 snmp_log(LOG_ERR,
1433 "bad rc %d from ipCidrRouteMetric5_check_value\n",
1434 rc);
1435 rc = SNMP_ERR_GENERR;
1436 }
1437 }
1438 break;
1439
1440 /*
1441 * ipCidrRouteStatus(16)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h
1442 */
1443 case COLUMN_IPCIDRROUTESTATUS:
1444 rc = netsnmp_check_vb_rowstatus_value(var);
1445 if (SNMPERR_SUCCESS != rc) {
1446 DEBUGMSGTL(("ipCidrRouteTable:_ipCidrRouteTable_check_column:ipCidrRouteStatus", "varbind validation failed (eg bad type or size)\n"));
1447 } else {
1448 rc = ipCidrRouteStatus_check_value(rowreq_ctx,
1449 *((u_long *) var->val.
1450 string));
1451 if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
1452 && (MFD_NOT_VALID_NOW != rc)) {
1453 snmp_log(LOG_ERR,
1454 "bad rc %d from ipCidrRouteStatus_check_value\n",
1455 rc);
1456 rc = SNMP_ERR_GENERR;
1457 }
1458 }
1459 break;
1460
1461 default: /** We shouldn't get here */
1462 rc = SNMP_ERR_GENERR;
1463 snmp_log(LOG_ERR,
1464 "unknown column %d in _ipCidrRouteTable_check_column\n",
1465 column);
1466 }
1467
1468 return rc;
1469 } /* _ipCidrRouteTable_check_column */
1470
1471 int
1472 _mfd_ipCidrRouteTable_check_objects(netsnmp_mib_handler *handler,
1473 netsnmp_handler_registration *reginfo,
1474 netsnmp_agent_request_info
1475 *agtreq_info,
1476 netsnmp_request_info *requests)
1477 {
1478 ipCidrRouteTable_rowreq_ctx *rowreq_ctx = (ipCidrRouteTable_rowreq_ctx*)
1479 netsnmp_container_table_row_extract(requests);
1480 int rc;
1481
1482 DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_check_objects", "called\n"));
1483
1484 netsnmp_assert(NULL != rowreq_ctx);
1485
1486 for (; requests; requests = requests->next) {
1487
1488 /*
1489 * get column number from table request info, and check that column
1490 */
1491 netsnmp_table_request_info *tri;
1492 tri = netsnmp_extract_table_info(requests);
1493 if (NULL == tri)
1494 continue;
1495
1496 rc = _ipCidrRouteTable_check_column(rowreq_ctx,
1497 requests->requestvb,
1498 tri->colnum);
1499 if (rc) {
1500 netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc));
1501 break;
1502 }
1503
1504 } /* for results */
1505
1506 return SNMP_ERR_NOERROR;
1507 } /* _mfd_ipCidrRouteTable_check_objects */
1508
1509
1510 /*----------------------------------------------------------------------
1511 *
1512 * SET: Undo setup
1513 *
1514 *---------------------------------------------------------------------*/
1515 /*
1516 * @internal
1517 * Set the value for a particular column
1518 */
1519 NETSNMP_STATIC_INLINE int
1520 _ipCidrRouteTable_undo_setup_column(ipCidrRouteTable_rowreq_ctx *
1521 rowreq_ctx, int column)
1522 {
1523 int rc = SNMPERR_SUCCESS;
1524
1525 DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_undo_setup_column", "called for %d\n", column));
1526
1527 netsnmp_assert(NULL != rowreq_ctx);
1528
1529 switch (column) {
1530
1531 /*
1532 * ipCidrRouteIfIndex(5)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
1533 */
1534 case COLUMN_IPCIDRROUTEIFINDEX:
1535 rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEIFINDEX_FLAG;
1536 rc = ipCidrRouteIfIndex_undo_setup(rowreq_ctx);
1537 break;
1538
1539 /*
1540 * ipCidrRouteType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h
1541 */
1542 case COLUMN_IPCIDRROUTETYPE:
1543 rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTETYPE_FLAG;
1544 rc = ipCidrRouteType_undo_setup(rowreq_ctx);
1545 break;
1546
1547 /*
1548 * ipCidrRouteInfo(9)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/A/W/e/r/d/h
1549 */
1550 case COLUMN_IPCIDRROUTEINFO:
1551 rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEINFO_FLAG;
1552 rc = ipCidrRouteInfo_undo_setup(rowreq_ctx);
1553 break;
1554
1555 /*
1556 * ipCidrRouteNextHopAS(10)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
1557 */
1558 case COLUMN_IPCIDRROUTENEXTHOPAS:
1559 rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTENEXTHOPAS_FLAG;
1560 rc = ipCidrRouteNextHopAS_undo_setup(rowreq_ctx);
1561 break;
1562
1563 /*
1564 * ipCidrRouteMetric1(11)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
1565 */
1566 case COLUMN_IPCIDRROUTEMETRIC1:
1567 rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC1_FLAG;
1568 rc = ipCidrRouteMetric1_undo_setup(rowreq_ctx);
1569 break;
1570
1571 /*
1572 * ipCidrRouteMetric2(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
1573 */
1574 case COLUMN_IPCIDRROUTEMETRIC2:
1575 rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC2_FLAG;
1576 rc = ipCidrRouteMetric2_undo_setup(rowreq_ctx);
1577 break;
1578
1579 /*
1580 * ipCidrRouteMetric3(13)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
1581 */
1582 case COLUMN_IPCIDRROUTEMETRIC3:
1583 rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC3_FLAG;
1584 rc = ipCidrRouteMetric3_undo_setup(rowreq_ctx);
1585 break;
1586
1587 /*
1588 * ipCidrRouteMetric4(14)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
1589 */
1590 case COLUMN_IPCIDRROUTEMETRIC4:
1591 rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC4_FLAG;
1592 rc = ipCidrRouteMetric4_undo_setup(rowreq_ctx);
1593 break;
1594
1595 /*
1596 * ipCidrRouteMetric5(15)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
1597 */
1598 case COLUMN_IPCIDRROUTEMETRIC5:
1599 rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC5_FLAG;
1600 rc = ipCidrRouteMetric5_undo_setup(rowreq_ctx);
1601 break;
1602
1603 /*
1604 * ipCidrRouteStatus(16)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h
1605 */
1606 case COLUMN_IPCIDRROUTESTATUS:
1607 rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTESTATUS_FLAG;
1608 rc = ipCidrRouteStatus_undo_setup(rowreq_ctx);
1609 break;
1610
1611 default:
1612 snmp_log(LOG_ERR,
1613 "unknown column %d in _ipCidrRouteTable_undo_setup_column\n",
1614 column);
1615 break;
1616 }
1617
1618 return rc;
1619 } /* _ipCidrRouteTable_undo_setup_column */
1620
1621
1622 /**
1623 * @internal
1624 * undo setup
1625 */
1626 int
1627 _mfd_ipCidrRouteTable_undo_setup(netsnmp_mib_handler *handler,
1628 netsnmp_handler_registration *reginfo,
1629 netsnmp_agent_request_info *agtreq_info,
1630 netsnmp_request_info *requests)
1631 {
1632 int rc;
1633 ipCidrRouteTable_rowreq_ctx *rowreq_ctx = (ipCidrRouteTable_rowreq_ctx*)
1634 netsnmp_container_table_row_extract(requests);
1635
1636 DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_undo_setup", "called\n"));
1637
1638 netsnmp_assert(NULL != rowreq_ctx);
1639
1640 /*
1641 * allocate undo context
1642 */
1643 rowreq_ctx->undo = ipCidrRouteTable_allocate_data();
1644 if (NULL == rowreq_ctx->undo) {
1645 /** msg already logged */
1646 netsnmp_request_set_error_all(requests,
1647 SNMP_ERR_RESOURCEUNAVAILABLE);
1648 return SNMP_ERR_NOERROR;
1649 }
1650
1651 /*
1652 * row undo setup
1653 */
1654 rowreq_ctx->column_set_flags = 0;
1655 rc = ipCidrRouteTable_undo_setup(rowreq_ctx);
1656 if (MFD_SUCCESS != rc) {
1657 DEBUGMSGTL(("ipCidrRouteTable:mfd", "error %d from "
1658 "ipCidrRouteTable_undo_setup\n", rc));
1659 netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
1660 } else {
1661 /*
1662 * column undo setup
1663 */
1664 netsnmp_table_request_info *tri;
1665 for (; requests; requests = requests->next) {
1666 /*
1667 * set column data
1668 */
1669 tri = netsnmp_extract_table_info(requests);
1670 if (NULL == tri)
1671 continue;
1672
1673 rc = _ipCidrRouteTable_undo_setup_column(rowreq_ctx,
1674 tri->colnum);
1675 if (MFD_SUCCESS != rc) {
1676 DEBUGMSGTL(("ipCidrRouteTable:mfd", "error %d from "
1677 "ipCidrRouteTable_undo_setup_column\n", rc));
1678 netsnmp_set_request_error(agtreq_info, requests,
1679 SNMP_VALIDATE_ERR(rc));
1680 }
1681 } /* for results */
1682 }
1683
1684 return SNMP_ERR_NOERROR;
1685 } /* _mfd_ipCidrRouteTable_undo_setup */
1686
1687 /**
1688 * @internal
1689 * undo setup
1690 */
1691 int
1692 _mfd_ipCidrRouteTable_undo_cleanup(netsnmp_mib_handler *handler,
1693 netsnmp_handler_registration *reginfo,
1694 netsnmp_agent_request_info *agtreq_info,
1695 netsnmp_request_info *requests)
1696 {
1697 ipCidrRouteTable_rowreq_ctx *rowreq_ctx = (ipCidrRouteTable_rowreq_ctx*)
1698 netsnmp_container_table_row_extract(requests);
1699 int rc;
1700
1701 DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_undo_cleanup", "called\n"));
1702
1703 /*
1704 * failed row create in early stages has no rowreq_ctx
1705 */
1706 if (NULL == rowreq_ctx)
1707 return MFD_SUCCESS;
1708
1709 /*
1710 * call user cleanup
1711 */
1712 rc = ipCidrRouteTable_undo_cleanup(rowreq_ctx);
1713 if (MFD_SUCCESS != rc) {
1714 /*
1715 * nothing we can do about it but log it
1716 */
1717 DEBUGMSGTL(("ipCidrRouteTable:mfd", "error %d from "
1718 "ipCidrRouteTable_undo_cleanup\n", rc));
1719 }
1720
1721 /*
1722 * release undo context, if needed
1723 */
1724 if (rowreq_ctx->undo) {
1725 ipCidrRouteTable_release_data(rowreq_ctx->undo);
1726 rowreq_ctx->undo = NULL;
1727 }
1728
1729
1730 return SNMP_ERR_NOERROR;
1731 } /* _mfd_ipCidrRouteTable_undo_cleanup */
1732
1733 /*----------------------------------------------------------------------
1734 *
1735 * SET: Set values
1736 *
1737 *---------------------------------------------------------------------*/
1738 /*
1739 * @internal
1740 * Set the value for a particular column
1741 */
1742 NETSNMP_STATIC_INLINE int
1743 _ipCidrRouteTable_set_column(ipCidrRouteTable_rowreq_ctx * rowreq_ctx,
1744 netsnmp_variable_list * var, int column)
1745 {
1746 int rc = SNMPERR_SUCCESS;
1747
1748 DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_set_column",
1749 "called for %d\n", column));
1750
1751 netsnmp_assert(NULL != rowreq_ctx);
1752
1753 switch (column) {
1754
1755 /*
1756 * ipCidrRouteIfIndex(5)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
1757 */
1758 case COLUMN_IPCIDRROUTEIFINDEX:
1759 rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEIFINDEX_FLAG;
1760 rc = ipCidrRouteIfIndex_set(rowreq_ctx,
1761 *((long *) var->val.string));
1762 break;
1763
1764 /*
1765 * ipCidrRouteType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h
1766 */
1767 case COLUMN_IPCIDRROUTETYPE:
1768 rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTETYPE_FLAG;
1769 rc = ipCidrRouteType_set(rowreq_ctx,
1770 *((u_long *) var->val.string));
1771 break;
1772
1773 /*
1774 * ipCidrRouteInfo(9)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/A/W/e/r/d/h
1775 */
1776 case COLUMN_IPCIDRROUTEINFO:
1777 rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEINFO_FLAG;
1778 rc = ipCidrRouteInfo_set(rowreq_ctx, (oid *) var->val.string,
1779 var->val_len);
1780 break;
1781
1782 /*
1783 * ipCidrRouteNextHopAS(10)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
1784 */
1785 case COLUMN_IPCIDRROUTENEXTHOPAS:
1786 rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTENEXTHOPAS_FLAG;
1787 rc = ipCidrRouteNextHopAS_set(rowreq_ctx,
1788 *((long *) var->val.string));
1789 break;
1790
1791 /*
1792 * ipCidrRouteMetric1(11)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
1793 */
1794 case COLUMN_IPCIDRROUTEMETRIC1:
1795 rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC1_FLAG;
1796 rc = ipCidrRouteMetric1_set(rowreq_ctx,
1797 *((long *) var->val.string));
1798 break;
1799
1800 /*
1801 * ipCidrRouteMetric2(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
1802 */
1803 case COLUMN_IPCIDRROUTEMETRIC2:
1804 rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC2_FLAG;
1805 rc = ipCidrRouteMetric2_set(rowreq_ctx,
1806 *((long *) var->val.string));
1807 break;
1808
1809 /*
1810 * ipCidrRouteMetric3(13)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
1811 */
1812 case COLUMN_IPCIDRROUTEMETRIC3:
1813 rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC3_FLAG;
1814 rc = ipCidrRouteMetric3_set(rowreq_ctx,
1815 *((long *) var->val.string));
1816 break;
1817
1818 /*
1819 * ipCidrRouteMetric4(14)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
1820 */
1821 case COLUMN_IPCIDRROUTEMETRIC4:
1822 rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC4_FLAG;
1823 rc = ipCidrRouteMetric4_set(rowreq_ctx,
1824 *((long *) var->val.string));
1825 break;
1826
1827 /*
1828 * ipCidrRouteMetric5(15)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
1829 */
1830 case COLUMN_IPCIDRROUTEMETRIC5:
1831 rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC5_FLAG;
1832 rc = ipCidrRouteMetric5_set(rowreq_ctx,
1833 *((long *) var->val.string));
1834 break;
1835
1836 /*
1837 * ipCidrRouteStatus(16)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h
1838 */
1839 case COLUMN_IPCIDRROUTESTATUS:
1840 rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTESTATUS_FLAG;
1841 rc = ipCidrRouteStatus_set(rowreq_ctx,
1842 *((u_long *) var->val.string));
1843 break;
1844
1845 default:
1846 snmp_log(LOG_ERR,
1847 "unknown column %d in _ipCidrRouteTable_set_column\n",
1848 column);
1849 rc = SNMP_ERR_GENERR;
1850 break;
1851 }
1852
1853 return rc;
1854 } /* _ipCidrRouteTable_set_column */
1855
1856 int
1857 _mfd_ipCidrRouteTable_set_values(netsnmp_mib_handler *handler,
1858 netsnmp_handler_registration *reginfo,
1859 netsnmp_agent_request_info *agtreq_info,
1860 netsnmp_request_info *requests)
1861 {
1862 ipCidrRouteTable_rowreq_ctx *rowreq_ctx = (ipCidrRouteTable_rowreq_ctx*)
1863 netsnmp_container_table_row_extract(requests);
1864 netsnmp_table_request_info *tri;
1865 int rc = SNMP_ERR_NOERROR;
1866
1867 DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_set_values", "called\n"));
1868
1869 netsnmp_assert(NULL != rowreq_ctx);
1870
1871 rowreq_ctx->column_set_flags = 0;
1872 for (; requests; requests = requests->next) {
1873 /*
1874 * set column data
1875 */
1876 tri = netsnmp_extract_table_info(requests);
1877 if (NULL == tri)
1878 continue;
1879
1880 rc = _ipCidrRouteTable_set_column(rowreq_ctx,
1881 requests->requestvb,
1882 tri->colnum);
1883 if (MFD_SUCCESS != rc) {
1884 DEBUGMSGTL(("ipCidrRouteTable:mfd", "error %d from "
1885 "ipCidrRouteTable_set_column\n", rc));
1886 netsnmp_set_request_error(agtreq_info, requests,
1887 SNMP_VALIDATE_ERR(rc));
1888 }
1889 } /* for results */
1890
1891 return SNMP_ERR_NOERROR;
1892 } /* _mfd_ipCidrRouteTable_set_values */
1893
1894 /*----------------------------------------------------------------------
1895 *
1896 * SET: commit
1897 *
1898 *---------------------------------------------------------------------*/
1899 /**
1900 * @internal
1901 * commit the values
1902 */
1903 int
1904 _mfd_ipCidrRouteTable_commit(netsnmp_mib_handler *handler,
1905 netsnmp_handler_registration *reginfo,
1906 netsnmp_agent_request_info *agtreq_info,
1907 netsnmp_request_info *requests)
1908 {
1909 int rc;
1910 ipCidrRouteTable_rowreq_ctx *rowreq_ctx = (ipCidrRouteTable_rowreq_ctx*)
1911 netsnmp_container_table_row_extract(requests);
1912
1913 DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_commit",
1914 "called\n"));
1915
1916 netsnmp_assert(NULL != rowreq_ctx);
1917
1918 rc = ipCidrRouteTable_commit(rowreq_ctx);
1919 if (MFD_SUCCESS != rc) {
1920 DEBUGMSGTL(("ipCidrRouteTable:mfd", "error %d from "
1921 "ipCidrRouteTable_commit\n", rc));
1922 netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
1923 }
1924
1925 if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) {
1926 /*
1927 * if we successfully committed this row, set the dirty flag. Use the
1928 * current value + 1 (i.e. dirty = # rows changed).
1929 * this is checked in post_request...
1930 */
1931 ipCidrRouteTable_dirty_set(ipCidrRouteTable_dirty_get() + 1); /* set table dirty flag */
1932 }
1933
1934 return SNMP_ERR_NOERROR;
1935 }
1936
1937 int
1938 _mfd_ipCidrRouteTable_undo_commit(netsnmp_mib_handler *handler,
1939 netsnmp_handler_registration *reginfo,
1940 netsnmp_agent_request_info *agtreq_info,
1941 netsnmp_request_info *requests)
1942 {
1943 int rc;
1944 ipCidrRouteTable_rowreq_ctx *rowreq_ctx = (ipCidrRouteTable_rowreq_ctx*)
1945 netsnmp_container_table_row_extract(requests);
1946
1947 DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_undo_commit", "called\n"));
1948
1949 netsnmp_assert(NULL != rowreq_ctx);
1950
1951 if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) {
1952 u_int d = ipCidrRouteTable_dirty_get();
1953
1954 netsnmp_assert(d != 0);
1955 if (d)
1956 ipCidrRouteTable_dirty_set(d - 1);
1957 }
1958
1959 rc = ipCidrRouteTable_undo_commit(rowreq_ctx);
1960 if (MFD_SUCCESS != rc) {
1961 /*
1962 * nothing we can do about it but log it
1963 */
1964 DEBUGMSGTL(("ipCidrRouteTable:mfd", "error %d from "
1965 "ipCidrRouteTable_undo_commit\n", rc));
1966 }
1967
1968 if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) {
1969 snmp_log(LOG_WARNING,
1970 "ipCidrRouteTable row dirty flag still set after undo_commit\n");
1971 rowreq_ctx->rowreq_flags &= ~MFD_ROW_DIRTY;
1972 }
1973
1974 return SNMP_ERR_NOERROR;
1975 } /* _mfd_ipCidrRouteTable_commit */
1976
1977 /*----------------------------------------------------------------------
1978 *
1979 * SET: Undo
1980 *
1981 *---------------------------------------------------------------------*/
1982 /**
1983 * @internal
1984 * undo the value for a particular column
1985 */
1986 NETSNMP_STATIC_INLINE int
1987 _ipCidrRouteTable_undo_column(ipCidrRouteTable_rowreq_ctx * rowreq_ctx,
1988 netsnmp_variable_list * var, int column)
1989 {
1990 int rc = SNMPERR_SUCCESS;
1991
1992 DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_undo_column",
1993 "called for %d\n", column));
1994
1995 netsnmp_assert(NULL != rowreq_ctx);
1996
1997 switch (column) {
1998
1999 /*
2000 * ipCidrRouteIfIndex(5)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
2001 */
2002 case COLUMN_IPCIDRROUTEIFINDEX:
2003 rc = ipCidrRouteIfIndex_undo(rowreq_ctx);
2004 break;
2005
2006 /*
2007 * ipCidrRouteType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h
2008 */
2009 case COLUMN_IPCIDRROUTETYPE:
2010 rc = ipCidrRouteType_undo(rowreq_ctx);
2011 break;
2012
2013 /*
2014 * ipCidrRouteInfo(9)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/A/W/e/r/d/h
2015 */
2016 case COLUMN_IPCIDRROUTEINFO:
2017 rc = ipCidrRouteInfo_undo(rowreq_ctx);
2018 break;
2019
2020 /*
2021 * ipCidrRouteNextHopAS(10)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
2022 */
2023 case COLUMN_IPCIDRROUTENEXTHOPAS:
2024 rc = ipCidrRouteNextHopAS_undo(rowreq_ctx);
2025 break;
2026
2027 /*
2028 * ipCidrRouteMetric1(11)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
2029 */
2030 case COLUMN_IPCIDRROUTEMETRIC1:
2031 rc = ipCidrRouteMetric1_undo(rowreq_ctx);
2032 break;
2033
2034 /*
2035 * ipCidrRouteMetric2(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
2036 */
2037 case COLUMN_IPCIDRROUTEMETRIC2:
2038 rc = ipCidrRouteMetric2_undo(rowreq_ctx);
2039 break;
2040
2041 /*
2042 * ipCidrRouteMetric3(13)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
2043 */
2044 case COLUMN_IPCIDRROUTEMETRIC3:
2045 rc = ipCidrRouteMetric3_undo(rowreq_ctx);
2046 break;
2047
2048 /*
2049 * ipCidrRouteMetric4(14)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
2050 */
2051 case COLUMN_IPCIDRROUTEMETRIC4:
2052 rc = ipCidrRouteMetric4_undo(rowreq_ctx);
2053 break;
2054
2055 /*
2056 * ipCidrRouteMetric5(15)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h
2057 */
2058 case COLUMN_IPCIDRROUTEMETRIC5:
2059 rc = ipCidrRouteMetric5_undo(rowreq_ctx);
2060 break;
2061
2062 /*
2063 * ipCidrRouteStatus(16)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h
2064 */
2065 case COLUMN_IPCIDRROUTESTATUS:
2066 rc = ipCidrRouteStatus_undo(rowreq_ctx);
2067 break;
2068
2069 default:
2070 snmp_log(LOG_ERR,
2071 "unknown column %d in _ipCidrRouteTable_undo_column\n",
2072 column);
2073 break;
2074 }
2075
2076 return rc;
2077 } /* _ipCidrRouteTable_undo_column */
2078
2079 int
2080 _mfd_ipCidrRouteTable_undo_values(netsnmp_mib_handler *handler,
2081 netsnmp_handler_registration *reginfo,
2082 netsnmp_agent_request_info *agtreq_info,
2083 netsnmp_request_info *requests)
2084 {
2085 int rc;
2086 ipCidrRouteTable_rowreq_ctx *rowreq_ctx = (ipCidrRouteTable_rowreq_ctx*)
2087 netsnmp_container_table_row_extract(requests);
2088 netsnmp_table_request_info *tri;
2089
2090 DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_undo_values", "called\n"));
2091
2092 netsnmp_assert(NULL != rowreq_ctx);
2093
2094 rc = ipCidrRouteTable_undo(rowreq_ctx);
2095 if (MFD_SUCCESS != rc) {
2096 /*
2097 * nothing we can do about it but log it
2098 */
2099 DEBUGMSGTL(("ipCidrRouteTable:mfd", "error %d from "
2100 "ipCidrRouteTable_undo\n", rc));
2101 }
2102
2103 for (; requests; requests = requests->next) {
2104 /*
2105 * set column data
2106 */
2107 tri = netsnmp_extract_table_info(requests);
2108 if (NULL == tri)
2109 continue;
2110
2111 rc = _ipCidrRouteTable_undo_column(rowreq_ctx, requests->requestvb,
2112 tri->colnum);
2113 if (MFD_SUCCESS != rc) {
2114 /*
2115 * nothing we can do about it but log it
2116 */
2117 DEBUGMSGTL(("ipCidrRouteTable:mfd", "error %d from "
2118 "ipCidrRouteTable_undo_column\n", rc));
2119 }
2120 } /* for results */
2121
2122 return SNMP_ERR_NOERROR;
2123 } /* _mfd_ipCidrRouteTable_undo_values */
2124
2125 /*----------------------------------------------------------------------
2126 *
2127 * SET: irreversible commit
2128 *
2129 *---------------------------------------------------------------------*/
2130 /**
2131 * @internal
2132 * commit irreversible actions
2133 */
2134 int
2135 _mfd_ipCidrRouteTable_irreversible_commit(netsnmp_mib_handler *handler, netsnmp_handler_registration
2136 *reginfo, netsnmp_agent_request_info
2137 *agtreq_info,
2138 netsnmp_request_info *requests)
2139 {
2140 ipCidrRouteTable_rowreq_ctx *rowreq_ctx = (ipCidrRouteTable_rowreq_ctx*)
2141 netsnmp_container_table_row_extract(requests);
2142
2143 DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_irreversible:commit", "called\n"));
2144
2145 netsnmp_assert(NULL != rowreq_ctx);
2146
2147 /*
2148 * check for and handle row creation/deletion
2149 * and update column exist flags...
2150 */
2151 if (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED) {
2152 if (!(rowreq_ctx->rowreq_flags & MFD_ROW_CREATED))
2153 CONTAINER_REMOVE(ipCidrRouteTable_if_ctx.container, rowreq_ctx);
2154 } else {
2155 if (rowreq_ctx->column_set_flags) {
2156 rowreq_ctx->column_set_flags = 0;
2157 }
2158 if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) {
2159 rowreq_ctx->rowreq_flags &= ~MFD_ROW_CREATED;
2160 CONTAINER_INSERT(ipCidrRouteTable_if_ctx.container,
2161 rowreq_ctx);
2162 }
2163 }
2164
2165 return SNMP_ERR_NOERROR;
2166 } /* _mfd_ipCidrRouteTable_irreversible_commit */
2167 #endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */
2168
2169 /***********************************************************************
2170 *
2171 * DATA ACCESS
2172 *
2173 ***********************************************************************/
2174 static void _container_free(netsnmp_container *container);
2175
2176 /**
2177 * @internal
2178 */
2179 static int
2180 _cache_load(netsnmp_cache * cache, void *vmagic)
2181 {
2182 DEBUGMSGTL(("internal:ipCidrRouteTable:_cache_load", "called\n"));
2183
2184 if ((NULL == cache) || (NULL == cache->magic)) {
2185 snmp_log(LOG_ERR,
2186 "invalid cache for ipCidrRouteTable_cache_load\n");
2187 return -1;
2188 }
2189
2190 /** should only be called for an invalid or expired cache */
2191 netsnmp_assert((0 == cache->valid) || (1 == cache->expired));
2192
2193 /*
2194 * call user code
2195 */
2196 return ipCidrRouteTable_container_load((netsnmp_container *) cache->
2197 magic);
2198 } /* _cache_load */
2199
2200 /**
2201 * @internal
2202 */
2203 static void
2204 _cache_free(netsnmp_cache * cache, void *magic)
2205 {
2206 netsnmp_container *container;
2207
2208 DEBUGMSGTL(("internal:ipCidrRouteTable:_cache_free", "called\n"));
2209
2210 if ((NULL == cache) || (NULL == cache->magic)) {
2211 snmp_log(LOG_ERR,
2212 "invalid cache in ipCidrRouteTable_cache_free\n");
2213 return;
2214 }
2215
2216 container = (netsnmp_container *) cache->magic;
2217
2218 _container_free(container);
2219 } /* _cache_free */
2220
2221 /**
2222 * @internal
2223 */
2224 static void
2225 _container_item_free(void *rowreq_ctx, void *context)
2226 {
2227 DEBUGMSGTL(("internal:ipCidrRouteTable:_container_item_free",
2228 "called\n"));
2229
2230 if (NULL == rowreq_ctx)
2231 return;
2232
2233 ipCidrRouteTable_release_rowreq_ctx(rowreq_ctx);
2234 } /* _container_item_free */
2235
2236 /**
2237 * @internal
2238 */
2239 static void
2240 _container_free(netsnmp_container *container)
2241 {
2242 DEBUGMSGTL(("internal:ipCidrRouteTable:_container_free", "called\n"));
2243
2244 if (NULL == container) {
2245 snmp_log(LOG_ERR,
2246 "invalid container in ipCidrRouteTable_container_free\n");
2247 return;
2248 }
2249
2250 /*
2251 * call user code
2252 */
2253 ipCidrRouteTable_container_free(container);
2254
2255 /*
2256 * free all items. inefficient, but easy.
2257 */
2258 CONTAINER_CLEAR(container, _container_item_free, NULL);
2259 } /* _container_free */
2260
2261 /**
2262 * @internal
2263 * initialize the container with functions or wrappers
2264 */
2265 void
2266 _ipCidrRouteTable_container_init(ipCidrRouteTable_interface_ctx * if_ctx)
2267 {
2268 DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_container_init", "called\n"));
2269
2270 /*
2271 * cache init
2272 */
2273 if_ctx->cache = netsnmp_cache_create(IPCIDRROUTETABLE_CACHE_TIMEOUT,
2274 _cache_load, _cache_free,
2275 ipCidrRouteTable_oid,
2276 ipCidrRouteTable_oid_size);
2277
2278 if (NULL == if_ctx->cache) {
2279 snmp_log(LOG_ERR, "error creating cache for ipCidrRouteTable\n");
2280 return;
2281 }
2282
2283 if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET;
2284
2285 ipCidrRouteTable_container_init(&if_ctx->container, if_ctx->cache);
2286 if (NULL == if_ctx->container) {
2287 if_ctx->container =
2288 netsnmp_container_find("ipCidrRouteTable:table_container");
2289 if (NULL == if_ctx->container) {
2290 snmp_log(LOG_ERR, "error creating container in "
2291 "ipCidrRouteTable_container_init\n");
2292 return;
2293 }
2294 }
2295
2296 if_ctx->container->container_name = strdup("ipCidrRouteTable");
2297
2298 /* set allow duplicates this makes insert O(1) */
2299 netsnmp_binary_array_options_set(if_ctx->container, 1,
2300 CONTAINER_KEY_ALLOW_DUPLICATES);
2301
2302 if (NULL != if_ctx->cache)
2303 if_ctx->cache->magic = (void *) if_ctx->container;
2304 } /* _ipCidrRouteTable_container_init */
2305
2306 /**
2307 * @internal
2308 * shutdown the container with functions or wrappers
2309 */
2310 void
2311 _ipCidrRouteTable_container_shutdown(ipCidrRouteTable_interface_ctx *
2312 if_ctx)
2313 {
2314 DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_container_shutdown", "called\n"));
2315
2316 ipCidrRouteTable_container_shutdown(if_ctx->container);
2317
2318 _container_free(if_ctx->container);
2319
2320 } /* _ipCidrRouteTable_container_shutdown */
2321
2322
2323 #ifndef NETSNMP_FEATURE_REMOVE_IPCIDRROUTETABLE_EXTERNAL_ACCESS
2324 ipCidrRouteTable_rowreq_ctx *
2325 ipCidrRouteTable_row_find_by_mib_index(ipCidrRouteTable_mib_index *
2326 mib_idx)
2327 {
2328 ipCidrRouteTable_rowreq_ctx *rowreq_ctx;
2329 oid oid_tmp[MAX_OID_LEN];
2330 netsnmp_index oid_idx;
2331 int rc;
2332
2333 /*
2334 * set up storage for OID
2335 */
2336 oid_idx.oids = oid_tmp;
2337 oid_idx.len = sizeof(oid_tmp) / sizeof(oid);
2338
2339 /*
2340 * convert
2341 */
2342 rc = ipCidrRouteTable_index_to_oid(&oid_idx, mib_idx);
2343 if (MFD_SUCCESS != rc)
2344 return NULL;
2345
2346 rowreq_ctx = (ipCidrRouteTable_rowreq_ctx*)
2347 CONTAINER_FIND(ipCidrRouteTable_if_ctx.container, &oid_idx);
2348
2349 return rowreq_ctx;
2350 }
2351 #endif /* NETSNMP_FEATURE_REMOVE_IPCIDRROUTETABLE_EXTERNAL_ACCESS */