Debian Codegraph @

agent/mibgroup/ip-forward-mib/inetCidrRouteTable/inetCidrRouteTable_data_access.c

raw
1 /*
2 * Note: this file originally auto-generated by mib2c using
3 * version : 1.17 $ of : mfd-data-access.m2c,v $
4 *
5 * $Id$
6 */
7 /*
8 * standard Net-SNMP includes
9 */
10 #include <net-snmp/net-snmp-config.h>
11 #include <net-snmp/net-snmp-includes.h>
12 #include <net-snmp/agent/net-snmp-agent-includes.h>
13
14 /*
15 * include our parent header
16 */
17 #include "inetCidrRouteTable.h"
18
19
20 #include "inetCidrRouteTable_data_access.h"
21
22 /** @ingroup interface
23 * @addtogroup data_access data_access: Routines to access data
24 *
25 * These routines are used to locate the data used to satisfy
26 * requests.
27 *
28 * @{
29 */
30 /**********************************************************************
31 **********************************************************************
32 ***
33 *** Table inetCidrRouteTable
34 ***
35 **********************************************************************
36 **********************************************************************/
37 /*
38 * IP-FORWARD-MIB::inetCidrRouteTable is subid 7 of ipForward.
39 * Its status is Current.
40 * OID: .1.3.6.1.2.1.4.24.7, length: 9
41 */
42
43 /**
44 * initialization for inetCidrRouteTable data access
45 *
46 * This function is called during startup to allow you to
47 * allocate any resources you need for the data table.
48 *
49 * @param inetCidrRouteTable_reg
50 * Pointer to inetCidrRouteTable_registration
51 *
52 * @retval MFD_SUCCESS : success.
53 * @retval MFD_ERROR : unrecoverable error.
54 */
55 int
56 inetCidrRouteTable_init_data(inetCidrRouteTable_registration *
57 inetCidrRouteTable_reg)
58 {
59 DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_init_data",
60 "called\n"));
61
62 /*
63 * TODO:303:o: Initialize inetCidrRouteTable data.
64 */
65
66 return MFD_SUCCESS;
67 } /* inetCidrRouteTable_init_data */
68
69 /**
70 * container overview
71 *
72 */
73
74 /**
75 * container initialization
76 *
77 * @param container_ptr_ptr A pointer to a container pointer. If you
78 * create a custom container, use this parameter to return it
79 * to the MFD helper. If set to NULL, the MFD helper will
80 * allocate a container for you.
81 * @param cache A pointer to a cache structure. You can set the timeout
82 * and other cache flags using this pointer.
83 *
84 * This function is called at startup to allow you to customize certain
85 * aspects of the access method. For the most part, it is for advanced
86 * users. The default code should suffice for most cases. If no custom
87 * container is allocated, the MFD code will create one for your.
88 *
89 * This is also the place to set up cache behavior. The default, to
90 * simply set the cache timeout, will work well with the default
91 * container. If you are using a custom container, you may want to
92 * look at the cache helper documentation to see if there are any
93 * flags you want to set.
94 *
95 * @remark
96 * This would also be a good place to do any initialization needed
97 * for you data source. For example, opening a connection to another
98 * process that will supply the data, opening a database, etc.
99 */
100 void
101 inetCidrRouteTable_container_init(netsnmp_container **container_ptr_ptr,
102 netsnmp_cache * cache)
103 {
104 DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_container_init", "called\n"));
105
106 if (NULL == container_ptr_ptr) {
107 snmp_log(LOG_ERR,
108 "bad container param to inetCidrRouteTable_container_init\n");
109 return;
110 }
111
112 /*
113 * For advanced users, you can use a custom container. If you
114 * do not create one, one will be created for you.
115 */
116 *container_ptr_ptr = NULL;
117
118 if (NULL == cache) {
119 snmp_log(LOG_ERR,
120 "bad cache param to inetCidrRouteTable_container_init\n");
121 return;
122 }
123
124 /*
125 * TODO:345:A: Set up inetCidrRouteTable cache properties.
126 *
127 * Also for advanced users, you can set parameters for the
128 * cache. Do not change the magic pointer, as it is used
129 * by the MFD helper. To completely disable caching, set
130 * cache->enabled to 0.
131 */
132 cache->timeout = INETCIDRROUTETABLE_CACHE_TIMEOUT; /* seconds */
133 } /* inetCidrRouteTable_container_init */
134
135 /**
136 * check entry for update
137 */
138 static void
139 _snarf_route_entry(void *p, void *q)
140 {
141 netsnmp_route_entry *route_entry = p;
142 netsnmp_container *container = q;
143 inetCidrRouteTable_rowreq_ctx *rowreq_ctx;
144
145 netsnmp_assert(NULL != route_entry);
146 netsnmp_assert(NULL != container);
147
148 /*
149 * per inetCidrRouteType:
150 *
151 * Routes which do not result in traffic forwarding or
152 * rejection should not be displayed even if the
153 * implementation keeps them stored internally.
154 */
155 if (route_entry->rt_type == 0) { /* set when route not up */
156 DEBUGMSGT(("verbose:inetCidrRouteTable:inetCidrRouteTable_cache_load", "skipping route\n"));
157 netsnmp_access_route_entry_free(route_entry);
158 return;
159 }
160
161 /*
162 * allocate an row context and set the index(es), then add it to
163 * the container
164 */
165 rowreq_ctx = inetCidrRouteTable_allocate_rowreq_ctx(route_entry, NULL);
166 if ((NULL != rowreq_ctx) &&
167 (MFD_SUCCESS == inetCidrRouteTable_indexes_set
168 (rowreq_ctx, route_entry->rt_dest_type,
169 (char *) route_entry->rt_dest, route_entry->rt_dest_len,
170 route_entry->rt_pfx_len,
171 route_entry->rt_policy, route_entry->rt_policy_len,
172 route_entry->rt_nexthop_type,
173 (char *) route_entry->rt_nexthop, route_entry->rt_nexthop_len))) {
174 CONTAINER_INSERT(container, rowreq_ctx);
175 rowreq_ctx->row_status = ROWSTATUS_ACTIVE;
176 } else {
177 if (rowreq_ctx) {
178 snmp_log(LOG_ERR, "error setting index while loading "
179 "inetCidrRoute cache.\n");
180 inetCidrRouteTable_release_rowreq_ctx(rowreq_ctx);
181 } else
182 netsnmp_access_route_entry_free(route_entry);
183 }
184 }
185
186 /**
187 * container shutdown
188 *
189 * @param container_ptr A pointer to the container.
190 *
191 * This function is called at shutdown to allow you to customize certain
192 * aspects of the access method. For the most part, it is for advanced
193 * users. The default code should suffice for most cases.
194 *
195 * This function is called before inetCidrRouteTable_container_free().
196 *
197 * @remark
198 * This would also be a good place to do any cleanup needed
199 * for you data source. For example, closing a connection to another
200 * process that supplied the data, closing a database, etc.
201 */
202 void
203 inetCidrRouteTable_container_shutdown(netsnmp_container *container_ptr)
204 {
205 DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_container_shutdown", "called\n"));
206
207 if (NULL == container_ptr) {
208 snmp_log(LOG_ERR,
209 "bad params to inetCidrRouteTable_container_shutdown\n");
210 return;
211 }
212
213 } /* inetCidrRouteTable_container_shutdown */
214
215 /**
216 * load initial data
217 *
218 * TODO:350:M: Implement inetCidrRouteTable data load
219 * This function will also be called by the cache helper to load
220 * the container again (after the container free function has been
221 * called to free the previous contents).
222 *
223 * @param container container to which items should be inserted
224 *
225 * @retval MFD_SUCCESS : success.
226 * @retval MFD_RESOURCE_UNAVAILABLE : Can't access data source
227 * @retval MFD_ERROR : other error.
228 *
229 * This function is called to load the index(es) (and data, optionally)
230 * for the every row in the data set.
231 *
232 * @remark
233 * While loading the data, the only important thing is the indexes.
234 * If access to your data is cheap/fast (e.g. you have a pointer to a
235 * structure in memory), it would make sense to update the data here.
236 * If, however, the accessing the data involves more work (e.g. parsing
237 * some other existing data, or performing calculations to derive the data),
238 * then you can limit yourself to setting the indexes and saving any
239 * information you will need later. Then use the saved information in
240 * inetCidrRouteTable_row_prep() for populating data.
241 *
242 * @note
243 * If you need consistency between rows (like you want statistics
244 * for each row to be from the same time frame), you should set all
245 * data here.
246 *
247 */
248 int
249 inetCidrRouteTable_container_load(netsnmp_container *container)
250 {
251 netsnmp_container *route_container;
252
253 DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_container_load", "called\n"));
254
255 /*
256 * TODO:351:M: |-> Load/update data in the inetCidrRouteTable container.
257 * loop over your inetCidrRouteTable data, allocate a rowreq context,
258 * set the index(es) [and data, optionally] and insert into
259 * the container.
260 *
261 * we use the netsnmp data access api to get the data
262 */
263 route_container =
264 netsnmp_access_route_container_load(NULL,
265 NETSNMP_ACCESS_ROUTE_LOAD_NOFLAGS);
266
267 if (NULL == route_container)
268 return MFD_RESOURCE_UNAVAILABLE; /* msg already logged */
269
270 DEBUGMSGT(("verbose:inetCidrRouteTable:inetCidrRouteTable_cache_load",
271 "%d records\n", (int)CONTAINER_SIZE(route_container)));
272
273 /*
274 * we just got a fresh copy of route data. snarf data
275 */
276 CONTAINER_FOR_EACH(route_container, _snarf_route_entry, container);
277
278 /*
279 * free the container. we've either claimed each ifentry, or released it,
280 * so the dal function doesn't need to clear the container.
281 */
282 netsnmp_access_route_container_free(route_container,
283 NETSNMP_ACCESS_ROUTE_FREE_DONT_CLEAR);
284
285 DEBUGMSGT(("verbose:inetCidrRouteTable:inetCidrRouteTable_cache_load",
286 "%d records\n", (int)CONTAINER_SIZE(container)));
287
288 return MFD_SUCCESS;
289 } /* inetCidrRouteTable_container_load */
290
291 /**
292 * container clean up
293 *
294 * @param container container with all current items
295 *
296 * This optional callback is called prior to all
297 * item's being removed from the container. If you
298 * need to do any processing before that, do it here.
299 *
300 * @note
301 * The MFD helper will take care of releasing all the row contexts.
302 *
303 */
304 void
305 inetCidrRouteTable_container_free(netsnmp_container *container)
306 {
307 DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_container_free", "called\n"));
308
309 /*
310 * TODO:380:M: Free inetCidrRouteTable container data.
311 */
312 } /* inetCidrRouteTable_container_free */
313
314 /**
315 * prepare row for processing.
316 *
317 * When the agent has located the row for a request, this function is
318 * called to prepare the row for processing. If you fully populated
319 * the data context during the index setup phase, you may not need to
320 * do anything.
321 *
322 * @param rowreq_ctx pointer to a context.
323 *
324 * @retval MFD_SUCCESS : success.
325 * @retval MFD_ERROR : other error.
326 */
327 int
328 inetCidrRouteTable_row_prep(inetCidrRouteTable_rowreq_ctx * rowreq_ctx)
329 {
330 DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_row_prep",
331 "called\n"));
332
333 netsnmp_assert(NULL != rowreq_ctx);
334
335 /*
336 * TODO:390:o: Prepare row for request.
337 * If populating row data was delayed, this is the place to
338 * fill in the row for this request.
339 */
340 if (MFD_ROW_CREATED & rowreq_ctx->rowreq_flags) {
341 memcpy(rowreq_ctx->data->rt_dest,
342 rowreq_ctx->tbl_idx.inetCidrRouteDest,
343 rowreq_ctx->tbl_idx.inetCidrRouteDest_len);
344 rowreq_ctx->data->rt_dest_len =
345 rowreq_ctx->tbl_idx.inetCidrRouteDest_len;
346 rowreq_ctx->data->rt_dest_type =
347 rowreq_ctx->tbl_idx.inetCidrRouteDestType;
348
349 memcpy(rowreq_ctx->data->rt_nexthop,
350 rowreq_ctx->tbl_idx.inetCidrRouteNextHop,
351 rowreq_ctx->tbl_idx.inetCidrRouteNextHop_len);
352 rowreq_ctx->data->rt_nexthop_len =
353 rowreq_ctx->tbl_idx.inetCidrRouteNextHop_len;
354 rowreq_ctx->data->rt_nexthop_type =
355 rowreq_ctx->tbl_idx.inetCidrRouteNextHopType;
356
357 rowreq_ctx->data->rt_pfx_len =
358 rowreq_ctx->tbl_idx.inetCidrRoutePfxLen;
359
360 rowreq_ctx->data->rt_policy_len =
361 rowreq_ctx->tbl_idx.inetCidrRoutePolicy_len;
362 rowreq_ctx->data->rt_policy =
363 rowreq_ctx->tbl_idx.inetCidrRoutePolicy;
364 /*
365 * policy pointing to rowreq array, set flag so
366 * it won't be freed
367 */
368 rowreq_ctx->data->flags |= NETSNMP_ACCESS_ROUTE_POLICY_STATIC;
369 }
370
371
372 return MFD_SUCCESS;
373 } /* inetCidrRouteTable_row_prep */
374
375 /*
376 * TODO:420:r: Implement inetCidrRouteTable index validation.
377 */
378 /*---------------------------------------------------------------------
379 * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteDestType
380 * inetCidrRouteDestType is subid 1 of inetCidrRouteEntry.
381 * Its status is Current, and its access level is NoAccess.
382 * OID: .1.3.6.1.2.1.4.24.7.1.1
383 * Description:
384 The type of the inetCidrRouteDest address, as defined
385 in the InetAddress MIB.
386
387 Only those address types that may appear in an actual
388 routing table are allowed as values of this object.
389 *
390 * Attributes:
391 * accessible 0 isscalar 0 enums 1 hasdefval 0
392 * readable 0 iscolumn 1 ranges 0 hashint 0
393 * settable 0
394 *
395 * Enum range: 5/8. Values: unknown(0), ipv4(1), ipv6(2), ipv4z(3), ipv6z(4), dns(16)
396 *
397 * Its syntax is InetAddressType (based on perltype INTEGER)
398 * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long)
399 *
400 *
401 *
402 * NOTE: NODE inetCidrRouteDestType IS NOT ACCESSIBLE
403 *
404 *
405 */
406 /**
407 * check validity of inetCidrRouteDestType index portion
408 *
409 * @retval MFD_SUCCESS : the incoming value is legal
410 * @retval MFD_ERROR : the incoming value is NOT legal
411 *
412 * @note this is not the place to do any checks for the sanity
413 * of multiple indexes. Those types of checks should be done in the
414 * inetCidrRouteTable_validate_index() function.
415 *
416 * @note Also keep in mind that if the index refers to a row in this or
417 * some other table, you can't check for that row here to make
418 * decisions, since that row might not be created yet, but may
419 * be created during the processing this request. If you have
420 * such checks, they should be done in the check_dependencies
421 * function, because any new/deleted/changed rows should be
422 * available then.
423 *
424 * The following checks have already been done for you:
425 * The value is one of unknown(0), ipv4(1), ipv6(2), ipv4z(3), ipv6z(4), dns(16)
426 *
427 * If there a no other checks you need to do, simply return MFD_SUCCESS.
428 */
429 int
430 inetCidrRouteDestType_check_index(inetCidrRouteTable_rowreq_ctx *
431 rowreq_ctx)
432 {
433 DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteDestType_check_index", "called\n"));
434
435 netsnmp_assert(NULL != rowreq_ctx);
436
437 /*
438 * TODO:426:M: |-> Check inetCidrRouteTable index inetCidrRouteDestType.
439 * check that index value in the table context is legal.
440 * (rowreq_ctx->tbl_index.inetCidrRouteDestType)
441 */
442 /*
443 * we don't support all types
444 */
445 switch (rowreq_ctx->tbl_idx.inetCidrRouteDestType) {
446
447 case INETADDRESSTYPE_IPV4:
448 case INETADDRESSTYPE_IPV6:
449 break;
450
451 case INETADDRESSTYPE_UNKNOWN:
452 case INETADDRESSTYPE_IPV4Z:
453 case INETADDRESSTYPE_IPV6Z:
454 case INETADDRESSTYPE_DNS:
455 /*
456 * fall through
457 */
458
459 default:
460 return MFD_ERROR;
461 }
462
463 return MFD_SUCCESS; /* inetCidrRouteDestType index ok */
464 } /* inetCidrRouteDestType_check_index */
465
466 /*---------------------------------------------------------------------
467 * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteDest
468 * inetCidrRouteDest is subid 2 of inetCidrRouteEntry.
469 * Its status is Current, and its access level is NoAccess.
470 * OID: .1.3.6.1.2.1.4.24.7.1.2
471 * Description:
472 The destination IP address of this route.
473
474 The type of this address is determined by the value of
475 the inetCidrRouteDestType object.
476
477 The values for the index objects inetCidrRouteDest and
478 inetCidrRoutePfxLen must be consistent. When the value
479 of inetCidrRouteDest (excluding the zone index, if one
480 is present) is x, then the bitwise logical-AND
481 of x with the value of the mask formed from the
482 corresponding index object inetCidrRoutePfxLen MUST be
483 equal to x. If not, then the index pair is not
484 consistent and an inconsistentName error must be
485 returned on SET or CREATE requests.
486 *
487 * Attributes:
488 * accessible 0 isscalar 0 enums 0 hasdefval 0
489 * readable 0 iscolumn 1 ranges 1 hashint 0
490 * settable 0
491 *
492 * Ranges: 0 - 255;
493 *
494 * Its syntax is InetAddress (based on perltype OCTETSTR)
495 * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char)
496 * This data type requires a length. (Max 255)
497 *
498 *
499 *
500 * NOTE: NODE inetCidrRouteDest IS NOT ACCESSIBLE
501 *
502 *
503 */
504 /**
505 * check validity of inetCidrRouteDest index portion
506 *
507 * @retval MFD_SUCCESS : the incoming value is legal
508 * @retval MFD_ERROR : the incoming value is NOT legal
509 *
510 * @note this is not the place to do any checks for the sanity
511 * of multiple indexes. Those types of checks should be done in the
512 * inetCidrRouteTable_validate_index() function.
513 *
514 * @note Also keep in mind that if the index refers to a row in this or
515 * some other table, you can't check for that row here to make
516 * decisions, since that row might not be created yet, but may
517 * be created during the processing this request. If you have
518 * such checks, they should be done in the check_dependencies
519 * function, because any new/deleted/changed rows should be
520 * available then.
521 *
522 * The following checks have already been done for you:
523 * The length is in (one of) the range set(s): 0 - 255
524 *
525 * If there a no other checks you need to do, simply return MFD_SUCCESS.
526 */
527 int
528 inetCidrRouteDest_check_index(inetCidrRouteTable_rowreq_ctx * rowreq_ctx)
529 {
530 DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteDest_check_index",
531 "called\n"));
532
533 netsnmp_assert(NULL != rowreq_ctx);
534
535 /*
536 * TODO:426:M: |-> Check inetCidrRouteTable index inetCidrRouteDest.
537 * check that index value in the table context is legal.
538 * (rowreq_ctx->tbl_index.inetCidrRouteDest)
539 */
540
541 return MFD_SUCCESS; /* inetCidrRouteDest index ok */
542 } /* inetCidrRouteDest_check_index */
543
544 /*---------------------------------------------------------------------
545 * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRoutePfxLen
546 * inetCidrRoutePfxLen is subid 3 of inetCidrRouteEntry.
547 * Its status is Current, and its access level is NoAccess.
548 * OID: .1.3.6.1.2.1.4.24.7.1.3
549 * Description:
550 Indicates the number of leading one bits which form the
551 mask to be logical-ANDed with the destination address
552 before being compared to the value in the
553 inetCidrRouteDest field.
554
555 The values for the index objects inetCidrRouteDest and
556 inetCidrRoutePfxLen must be consistent. When the value
557 of inetCidrRouteDest (excluding the zone index, if one
558 is present) is x, then the bitwise logical-AND
559 of x with the value of the mask formed from the
560 corresponding index object inetCidrRoutePfxLen MUST be
561 equal to x. If not, then the index pair is not
562 consistent and an inconsistentName error must be
563 returned on SET or CREATE requests.
564 *
565 * Attributes:
566 * accessible 0 isscalar 0 enums 0 hasdefval 0
567 * readable 0 iscolumn 1 ranges 1 hashint 1
568 * settable 0
569 * hint: d
570 *
571 * Ranges: 0 - 2040;
572 *
573 * Its syntax is InetAddressPrefixLength (based on perltype UNSIGNED32)
574 * The net-snmp type is ASN_UNSIGNED. The C type decl is u_long (u_long)
575 *
576 *
577 *
578 * NOTE: NODE inetCidrRoutePfxLen IS NOT ACCESSIBLE
579 *
580 *
581 */
582 /**
583 * check validity of inetCidrRoutePfxLen index portion
584 *
585 * @retval MFD_SUCCESS : the incoming value is legal
586 * @retval MFD_ERROR : the incoming value is NOT legal
587 *
588 * @note this is not the place to do any checks for the sanity
589 * of multiple indexes. Those types of checks should be done in the
590 * inetCidrRouteTable_validate_index() function.
591 *
592 * @note Also keep in mind that if the index refers to a row in this or
593 * some other table, you can't check for that row here to make
594 * decisions, since that row might not be created yet, but may
595 * be created during the processing this request. If you have
596 * such checks, they should be done in the check_dependencies
597 * function, because any new/deleted/changed rows should be
598 * available then.
599 *
600 * The following checks have already been done for you:
601 * The value is in (one of) the range set(s): 0 - 2040
602 *
603 * If there a no other checks you need to do, simply return MFD_SUCCESS.
604 */
605 int
606 inetCidrRoutePfxLen_check_index(inetCidrRouteTable_rowreq_ctx * rowreq_ctx)
607 {
608 DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRoutePfxLen_check_index", "called\n"));
609
610 netsnmp_assert(NULL != rowreq_ctx);
611
612 /*
613 * TODO:426:M: |-> Check inetCidrRouteTable index inetCidrRoutePfxLen.
614 * check that index value in the table context is legal.
615 * (rowreq_ctx->tbl_index.inetCidrRoutePfxLen)
616 */
617
618 return MFD_SUCCESS; /* inetCidrRoutePfxLen index ok */
619 } /* inetCidrRoutePfxLen_check_index */
620
621 /*---------------------------------------------------------------------
622 * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRoutePolicy
623 * inetCidrRoutePolicy is subid 4 of inetCidrRouteEntry.
624 * Its status is Current, and its access level is NoAccess.
625 * OID: .1.3.6.1.2.1.4.24.7.1.4
626 * Description:
627 This object is an opaque object without any defined
628 semantics. Its purpose is to serve as an additional
629 index which may delineate between multiple entries to
630 the same destination. The value { 0 0 } shall be used
631 as the default value for this object.
632 *
633 * Attributes:
634 * accessible 0 isscalar 0 enums 0 hasdefval 0
635 * readable 0 iscolumn 1 ranges 0 hashint 0
636 * settable 0
637 *
638 *
639 * Its syntax is OBJECTID (based on perltype OBJECTID)
640 * The net-snmp type is ASN_OBJECT_ID. The C type decl is oid (oid)
641 * This data type requires a length. (Max 2040)
642 *
643 *
644 *
645 * NOTE: NODE inetCidrRoutePolicy IS NOT ACCESSIBLE
646 *
647 *
648 */
649 /**
650 * check validity of inetCidrRoutePolicy index portion
651 *
652 * @retval MFD_SUCCESS : the incoming value is legal
653 * @retval MFD_ERROR : the incoming value is NOT legal
654 *
655 * @note this is not the place to do any checks for the sanity
656 * of multiple indexes. Those types of checks should be done in the
657 * inetCidrRouteTable_validate_index() function.
658 *
659 * @note Also keep in mind that if the index refers to a row in this or
660 * some other table, you can't check for that row here to make
661 * decisions, since that row might not be created yet, but may
662 * be created during the processing this request. If you have
663 * such checks, they should be done in the check_dependencies
664 * function, because any new/deleted/changed rows should be
665 * available then.
666 *
667 * The following checks have already been done for you:
668 *
669 * If there a no other checks you need to do, simply return MFD_SUCCESS.
670 */
671 int
672 inetCidrRoutePolicy_check_index(inetCidrRouteTable_rowreq_ctx * rowreq_ctx)
673 {
674 DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRoutePolicy_check_index", "called\n"));
675
676 netsnmp_assert(NULL != rowreq_ctx);
677
678 /*
679 * TODO:426:M: |-> Check inetCidrRouteTable index inetCidrRoutePolicy.
680 * check that index value in the table context is legal.
681 * (rowreq_ctx->tbl_index.inetCidrRoutePolicy)
682 */
683
684 return MFD_SUCCESS; /* inetCidrRoutePolicy index ok */
685 } /* inetCidrRoutePolicy_check_index */
686
687 /*---------------------------------------------------------------------
688 * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteNextHopType
689 * inetCidrRouteNextHopType is subid 5 of inetCidrRouteEntry.
690 * Its status is Current, and its access level is NoAccess.
691 * OID: .1.3.6.1.2.1.4.24.7.1.5
692 * Description:
693 The type of the inetCidrRouteNextHop address, as
694 defined in the InetAddress MIB.
695
696 Value should be set to unknown(0) for non-remote
697 routes.
698
699 Only those address types that may appear in an actual
700 routing table are allowed as values of this object.
701 *
702 * Attributes:
703 * accessible 0 isscalar 0 enums 1 hasdefval 0
704 * readable 0 iscolumn 1 ranges 0 hashint 0
705 * settable 0
706 *
707 * Enum range: 5/8. Values: unknown(0), ipv4(1), ipv6(2), ipv4z(3), ipv6z(4), dns(16)
708 *
709 * Its syntax is InetAddressType (based on perltype INTEGER)
710 * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long)
711 *
712 *
713 *
714 * NOTE: NODE inetCidrRouteNextHopType IS NOT ACCESSIBLE
715 *
716 *
717 */
718 /**
719 * check validity of inetCidrRouteNextHopType index portion
720 *
721 * @retval MFD_SUCCESS : the incoming value is legal
722 * @retval MFD_ERROR : the incoming value is NOT legal
723 *
724 * @note this is not the place to do any checks for the sanity
725 * of multiple indexes. Those types of checks should be done in the
726 * inetCidrRouteTable_validate_index() function.
727 *
728 * @note Also keep in mind that if the index refers to a row in this or
729 * some other table, you can't check for that row here to make
730 * decisions, since that row might not be created yet, but may
731 * be created during the processing this request. If you have
732 * such checks, they should be done in the check_dependencies
733 * function, because any new/deleted/changed rows should be
734 * available then.
735 *
736 * The following checks have already been done for you:
737 * The value is one of unknown(0), ipv4(1), ipv6(2), ipv4z(3), ipv6z(4), dns(16)
738 *
739 * If there a no other checks you need to do, simply return MFD_SUCCESS.
740 */
741 int
742 inetCidrRouteNextHopType_check_index(inetCidrRouteTable_rowreq_ctx *
743 rowreq_ctx)
744 {
745 DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteNextHopType_check_index", "called\n"));
746
747 netsnmp_assert(NULL != rowreq_ctx);
748
749 /*
750 * TODO:426:M: |-> Check inetCidrRouteTable index inetCidrRouteNextHopType.
751 * check that index value in the table context is legal.
752 * (rowreq_ctx->tbl_index.inetCidrRouteNextHopType)
753 */
754 /*
755 * we don't support all types
756 */
757 switch (rowreq_ctx->tbl_idx.inetCidrRouteDestType) {
758
759 case INETADDRESSTYPE_IPV4:
760 case INETADDRESSTYPE_IPV6:
761 break;
762
763 case INETADDRESSTYPE_UNKNOWN:
764 case INETADDRESSTYPE_IPV4Z:
765 case INETADDRESSTYPE_IPV6Z:
766 case INETADDRESSTYPE_DNS:
767 /*
768 * fall through
769 */
770
771 default:
772 return MFD_ERROR;
773 }
774
775 return MFD_SUCCESS; /* inetCidrRouteNextHopType index ok */
776 } /* inetCidrRouteNextHopType_check_index */
777
778 /*---------------------------------------------------------------------
779 * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteNextHop
780 * inetCidrRouteNextHop is subid 6 of inetCidrRouteEntry.
781 * Its status is Current, and its access level is NoAccess.
782 * OID: .1.3.6.1.2.1.4.24.7.1.6
783 * Description:
784 On remote routes, the address of the next system en
785 route. For non-remote routes, a zero length string.
786
787 The type of this address is determined by the value of
788 the inetCidrRouteNextHopType object.
789 *
790 * Attributes:
791 * accessible 0 isscalar 0 enums 0 hasdefval 0
792 * readable 0 iscolumn 1 ranges 1 hashint 0
793 * settable 0
794 *
795 * Ranges: 0 - 255;
796 *
797 * Its syntax is InetAddress (based on perltype OCTETSTR)
798 * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char)
799 * This data type requires a length. (Max 255)
800 *
801 *
802 *
803 * NOTE: NODE inetCidrRouteNextHop IS NOT ACCESSIBLE
804 *
805 *
806 */
807 /**
808 * check validity of inetCidrRouteNextHop index portion
809 *
810 * @retval MFD_SUCCESS : the incoming value is legal
811 * @retval MFD_ERROR : the incoming value is NOT legal
812 *
813 * @note this is not the place to do any checks for the sanity
814 * of multiple indexes. Those types of checks should be done in the
815 * inetCidrRouteTable_validate_index() function.
816 *
817 * @note Also keep in mind that if the index refers to a row in this or
818 * some other table, you can't check for that row here to make
819 * decisions, since that row might not be created yet, but may
820 * be created during the processing this request. If you have
821 * such checks, they should be done in the check_dependencies
822 * function, because any new/deleted/changed rows should be
823 * available then.
824 *
825 * The following checks have already been done for you:
826 * The length is in (one of) the range set(s): 0 - 255
827 *
828 * If there a no other checks you need to do, simply return MFD_SUCCESS.
829 */
830 int
831 inetCidrRouteNextHop_check_index(inetCidrRouteTable_rowreq_ctx *
832 rowreq_ctx)
833 {
834 DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteNextHop_check_index", "called\n"));
835
836 netsnmp_assert(NULL != rowreq_ctx);
837
838 /*
839 * TODO:426:M: |-> Check inetCidrRouteTable index inetCidrRouteNextHop.
840 * check that index value in the table context is legal.
841 * (rowreq_ctx->tbl_index.inetCidrRouteNextHop)
842 */
843
844 return MFD_SUCCESS; /* inetCidrRouteNextHop index ok */
845 } /* inetCidrRouteNextHop_check_index */
846
847 /**
848 * verify specified index is valid.
849 *
850 * This check is independent of whether or not the values specified for
851 * the columns of the new row are valid. Column values and row consistency
852 * will be checked later. At this point, only the index values should be
853 * checked.
854 *
855 * All of the individual index validation functions have been called, so this
856 * is the place to make sure they are valid as a whole when combined. If
857 * you only have one index, then you probably don't need to do anything else
858 * here.
859 *
860 * @note Keep in mind that if the indexes refer to a row in this or
861 * some other table, you can't check for that row here to make
862 * decisions, since that row might not be created yet, but may
863 * be created during the processing this request. If you have
864 * such checks, they should be done in the check_dependencies
865 * function, because any new/deleted/changed rows should be
866 * available then.
867 *
868 *
869 * @param inetCidrRouteTable_reg
870 * Pointer to the user registration data
871 * @param rowreq_ctx
872 * Pointer to the users context.
873 * @retval MFD_SUCCESS : success
874 * @retval MFD_CANNOT_CREATE_NOW : index not valid right now
875 * @retval MFD_CANNOT_CREATE_EVER : index never valid
876 */
877 int
878 inetCidrRouteTable_validate_index(inetCidrRouteTable_registration *
879 inetCidrRouteTable_reg,
880 inetCidrRouteTable_rowreq_ctx *
881 rowreq_ctx)
882 {
883 int rc = MFD_SUCCESS;
884
885 DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_validate_index", "called\n"));
886
887 /** we should have a non-NULL pointer */
888 netsnmp_assert(NULL != rowreq_ctx);
889
890 /*
891 * TODO:430:M: |-> Validate potential inetCidrRouteTable index.
892 */
893 if (rowreq_ctx->tbl_idx.inetCidrRouteDestType !=
894 rowreq_ctx->tbl_idx.inetCidrRouteNextHopType) {
895 DEBUGMSGTL(("inetCidrRouteTable:validate_index",
896 "ipv4/v6 cross routing not supported\n"));
897 return MFD_CANNOT_CREATE_EVER;
898 }
899
900 /*
901 * InetAddress
902 */
903 if (((INETADDRESSTYPE_IPV4 ==
904 rowreq_ctx->tbl_idx.inetCidrRouteDestType)
905 && (4 != rowreq_ctx->tbl_idx.inetCidrRouteDest_len))
906 ||
907 ((INETADDRESSTYPE_IPV6 ==
908 rowreq_ctx->tbl_idx.inetCidrRouteDestType)
909 && (16 != rowreq_ctx->tbl_idx.inetCidrRouteDest_len))) {
910 DEBUGMSGTL(("inetCidrRouteTable:validate_index",
911 "dest addr type/size mismatch\n"));
912 return MFD_CANNOT_CREATE_EVER;
913 }
914 /*
915 * InetAddress
916 */
917 if (((INETADDRESSTYPE_IPV4 ==
918 rowreq_ctx->tbl_idx.inetCidrRouteNextHopType)
919 && (4 != rowreq_ctx->tbl_idx.inetCidrRouteNextHop_len))
920 ||
921 ((INETADDRESSTYPE_IPV6 ==
922 rowreq_ctx->tbl_idx.inetCidrRouteNextHopType)
923 && (16 != rowreq_ctx->tbl_idx.inetCidrRouteNextHop_len))) {
924 DEBUGMSGTL(("inetCidrRouteTable:validate_index",
925 "next hop addr type/size mismatch\n"));
926 return MFD_CANNOT_CREATE_EVER;
927 }
928
929 return rc;
930 } /* inetCidrRouteTable_validate_index */
931
932 /** @} */