ipCidrRouteTable_interface.c
上传用户:wxp200602
上传日期:2007-10-30
资源大小:4028k
文件大小:67k
源码类别:

SNMP编程

开发平台:

Unix_Linux

  1. /*
  2.  * Note: this file originally auto-generated by mib2c using
  3.  *       version : 1.42 $ of : mfd-interface.m2c,v $ 
  4.  *
  5.  * $Id: ipCidrRouteTable_interface.c,v 1.9.2.2 2005/09/06 20:26:02 rstory Exp $
  6.  */
  7. /*
  8.  * *********************************************************************
  9.  * *********************************************************************
  10.  * *********************************************************************
  11.  * ***                                                               ***
  12.  * ***  NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE  ***
  13.  * ***                                                               ***
  14.  * ***                                                               ***
  15.  * ***       THIS FILE DOES NOT CONTAIN ANY USER EDITABLE CODE.      ***
  16.  * ***                                                               ***
  17.  * ***                                                               ***
  18.  * ***       THE GENERATED CODE IS INTERNAL IMPLEMENTATION, AND      ***
  19.  * ***                                                               ***
  20.  * ***                                                               ***
  21.  * ***    IS SUBJECT TO CHANGE WITHOUT WARNING IN FUTURE RELEASES.   ***
  22.  * ***                                                               ***
  23.  * ***                                                               ***
  24.  * *********************************************************************
  25.  * *********************************************************************
  26.  * *********************************************************************
  27.  */
  28. /*
  29.  * standard Net-SNMP includes 
  30.  */
  31. #include <net-snmp/net-snmp-config.h>
  32. #include <net-snmp/net-snmp-includes.h>
  33. #include <net-snmp/agent/net-snmp-agent-includes.h>
  34. /*
  35.  * include our parent header 
  36.  */
  37. #include "ipCidrRouteTable.h"
  38. #include <net-snmp/library/container.h>
  39. #include "ipCidrRouteTable_interface.h"
  40. /**********************************************************************
  41.  **********************************************************************
  42.  ***
  43.  *** Table ipCidrRouteTable
  44.  ***
  45.  **********************************************************************
  46.  **********************************************************************/
  47. /*
  48.  * ipCidrRouteTable is subid 4 of ipForward.
  49.  * Its status is Deprecated.
  50.  * OID: .1.3.6.1.2.1.4.24.4, length: 9
  51.  */
  52. typedef struct ipCidrRouteTable_interface_ctx_s {
  53.     netsnmp_container *container;
  54.     netsnmp_cache  *cache;      /* optional cache */
  55.     ipCidrRouteTable_registration_ptr user_ctx;
  56.     netsnmp_table_registration_info tbl_info;
  57.     netsnmp_baby_steps_access_methods access_multiplexer;
  58. } ipCidrRouteTable_interface_ctx;
  59. static ipCidrRouteTable_interface_ctx ipCidrRouteTable_if_ctx;
  60. static void
  61.                 _ipCidrRouteTable_container_init(ipCidrRouteTable_interface_ctx * if_ctx);
  62. static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_pre_request;
  63. static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_post_request;
  64. static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_object_lookup;
  65. static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_get_values;
  66. static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_check_objects;
  67. static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_undo_setup;
  68. static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_set_values;
  69. static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_undo_cleanup;
  70. static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_undo_values;
  71. static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_commit;
  72. static Netsnmp_Node_Handler _mfd_ipCidrRouteTable_undo_commit;
  73. NETSNMP_STATIC_INLINE int
  74.                 _ipCidrRouteTable_undo_column(ipCidrRouteTable_rowreq_ctx * rowreq_ctx,
  75.                                               netsnmp_variable_list * var,
  76.                                               int column);
  77. NETSNMP_STATIC_INLINE int
  78.                 _ipCidrRouteTable_check_indexes(ipCidrRouteTable_rowreq_ctx * rowreq_ctx);
  79. /**
  80.  * @internal
  81.  * Initialize the table ipCidrRouteTable 
  82.  *    (Define its contents and how it's structured)
  83.  */
  84. void
  85. _ipCidrRouteTable_initialize_interface(ipCidrRouteTable_registration_ptr
  86.                                        reg_ptr, u_long flags)
  87. {
  88.     netsnmp_baby_steps_access_methods *access_multiplexer =
  89.         &ipCidrRouteTable_if_ctx.access_multiplexer;
  90.     netsnmp_table_registration_info *tbl_info =
  91.         &ipCidrRouteTable_if_ctx.tbl_info;
  92.     netsnmp_handler_registration *reginfo;
  93.     netsnmp_mib_handler *handler;
  94.     int             mfd_modes = 0;
  95.     DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_initialize_interface", "calledn"));
  96.     /*************************************************
  97.      *
  98.      * save interface context for ipCidrRouteTable
  99.      */
  100.     /*
  101.      * Setting up the table's definition
  102.      */
  103.     netsnmp_table_helper_add_indexes(tbl_info, ASN_IPADDRESS,
  104.                                                  /** index: ipCidrRouteDest */
  105.                                      ASN_IPADDRESS,
  106.                                                  /** index: ipCidrRouteMask */
  107.                                      ASN_INTEGER,
  108.                                                /** index: ipCidrRouteTos */
  109.                                      ASN_IPADDRESS,
  110.                                                  /** index: ipCidrRouteNextHop */
  111.                                      0);
  112.     /*
  113.      * Define the minimum and maximum accessible columns.  This
  114.      * optimizes retrival. 
  115.      */
  116.     tbl_info->min_column = IPCIDRROUTETABLE_MIN_COL;
  117.     tbl_info->max_column = IPCIDRROUTETABLE_MAX_COL;
  118.     /*
  119.      * save users context
  120.      */
  121.     ipCidrRouteTable_if_ctx.user_ctx = reg_ptr;
  122.     /*
  123.      * call data access initialization code
  124.      */
  125.     ipCidrRouteTable_init_data(reg_ptr);
  126.     /*
  127.      * set up the container
  128.      */
  129.     _ipCidrRouteTable_container_init(&ipCidrRouteTable_if_ctx);
  130.     if (NULL == ipCidrRouteTable_if_ctx.container) {
  131.         snmp_log(LOG_ERR,
  132.                  "could not initialize container for ipCidrRouteTablen");
  133.         return;
  134.     }
  135.     /*
  136.      * access_multiplexer: REQUIRED wrapper for get request handling
  137.      */
  138.     access_multiplexer->object_lookup =
  139.         _mfd_ipCidrRouteTable_object_lookup;
  140.     access_multiplexer->get_values = _mfd_ipCidrRouteTable_get_values;
  141.     /*
  142.      * no wrappers yet
  143.      */
  144.     access_multiplexer->pre_request = _mfd_ipCidrRouteTable_pre_request;
  145.     access_multiplexer->post_request = _mfd_ipCidrRouteTable_post_request;
  146.     /*
  147.      * REQUIRED wrappers for set request handling
  148.      */
  149.     access_multiplexer->object_syntax_checks =
  150.         _mfd_ipCidrRouteTable_check_objects;
  151.     access_multiplexer->undo_setup = _mfd_ipCidrRouteTable_undo_setup;
  152.     access_multiplexer->undo_cleanup = _mfd_ipCidrRouteTable_undo_cleanup;
  153.     access_multiplexer->set_values = _mfd_ipCidrRouteTable_set_values;
  154.     access_multiplexer->undo_sets = _mfd_ipCidrRouteTable_undo_values;
  155.     /*
  156.      * no wrappers yet
  157.      */
  158.     access_multiplexer->commit = _mfd_ipCidrRouteTable_commit;
  159.     access_multiplexer->undo_commit = _mfd_ipCidrRouteTable_undo_commit;
  160.     /*************************************************
  161.      *
  162.      * Create a registration, save our reg data, register table.
  163.      */
  164.     DEBUGMSGTL(("ipCidrRouteTable:init_ipCidrRouteTable",
  165.                 "Registering ipCidrRouteTable as a mibs-for-dummies table.n"));
  166.     handler =
  167.         netsnmp_baby_steps_access_multiplexer_get(access_multiplexer);
  168.     reginfo =
  169.         netsnmp_handler_registration_create("ipCidrRouteTable", handler,
  170.                                             ipCidrRouteTable_oid,
  171.                                             ipCidrRouteTable_oid_size,
  172.                                             HANDLER_CAN_BABY_STEP |
  173.                                             HANDLER_CAN_RONLY);
  174.     if (NULL == reginfo) {
  175.         snmp_log(LOG_ERR, "error registering table ipCidrRouteTablen");
  176.         return;
  177.     }
  178.     reginfo->my_reg_void = &ipCidrRouteTable_if_ctx;
  179.     /*************************************************
  180.      *
  181.      * set up baby steps handler, create it and inject it
  182.      */
  183.     if (access_multiplexer->object_lookup)
  184.         mfd_modes |= BABY_STEP_OBJECT_LOOKUP;
  185.     if (access_multiplexer->set_values)
  186.         mfd_modes |= BABY_STEP_SET_VALUES;
  187.     if (access_multiplexer->irreversible_commit)
  188.         mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT;
  189.     if (access_multiplexer->object_syntax_checks)
  190.         mfd_modes |= BABY_STEP_CHECK_OBJECT;
  191.     if (access_multiplexer->pre_request)
  192.         mfd_modes |= BABY_STEP_PRE_REQUEST;
  193.     if (access_multiplexer->post_request)
  194.         mfd_modes |= BABY_STEP_POST_REQUEST;
  195.     if (access_multiplexer->undo_setup)
  196.         mfd_modes |= BABY_STEP_UNDO_SETUP;
  197.     if (access_multiplexer->undo_cleanup)
  198.         mfd_modes |= BABY_STEP_UNDO_CLEANUP;
  199.     if (access_multiplexer->undo_sets)
  200.         mfd_modes |= BABY_STEP_UNDO_SETS;
  201.     if (access_multiplexer->row_creation)
  202.         mfd_modes |= BABY_STEP_ROW_CREATE;
  203.     if (access_multiplexer->consistency_checks)
  204.         mfd_modes |= BABY_STEP_CHECK_CONSISTENCY;
  205.     if (access_multiplexer->commit)
  206.         mfd_modes |= BABY_STEP_COMMIT;
  207.     if (access_multiplexer->undo_commit)
  208.         mfd_modes |= BABY_STEP_UNDO_COMMIT;
  209.     handler = netsnmp_baby_steps_handler_get(mfd_modes);
  210.     netsnmp_inject_handler(reginfo, handler);
  211.     /*************************************************
  212.      *
  213.      * inject row_merge helper with prefix rootoid_len + 2 (entry.col)
  214.      */
  215.     handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2);
  216.     netsnmp_inject_handler(reginfo, handler);
  217.     /*************************************************
  218.      *
  219.      * inject container_table helper
  220.      */
  221.     handler =
  222.         netsnmp_container_table_handler_get(tbl_info,
  223.                                             ipCidrRouteTable_if_ctx.
  224.                                             container,
  225.                                             TABLE_CONTAINER_KEY_NETSNMP_INDEX);
  226.     netsnmp_inject_handler(reginfo, handler);
  227.     /*************************************************
  228.      *
  229.      * inject cache helper
  230.      */
  231.     if (NULL != ipCidrRouteTable_if_ctx.cache) {
  232.         handler = netsnmp_cache_handler_get(ipCidrRouteTable_if_ctx.cache);
  233.         netsnmp_inject_handler(reginfo, handler);
  234.     }
  235.     /*
  236.      * register table
  237.      */
  238.     netsnmp_register_table(reginfo, tbl_info);
  239. }                               /* _ipCidrRouteTable_initialize_interface */
  240. void
  241. ipCidrRouteTable_valid_columns_set(netsnmp_column_info *vc)
  242. {
  243.     ipCidrRouteTable_if_ctx.tbl_info.valid_columns = vc;
  244. }                               /* ipCidrRouteTable_valid_columns_set */
  245. /**
  246.  * @internal
  247.  * convert the index component stored in the context to an oid
  248.  */
  249. int
  250. ipCidrRouteTable_index_to_oid(netsnmp_index * oid_idx,
  251.                               ipCidrRouteTable_mib_index * mib_idx)
  252. {
  253.     int             err = SNMP_ERR_NOERROR;
  254.     /*
  255.      * temp storage for parsing indexes
  256.      */
  257.     /*
  258.      * ipCidrRouteDest(1)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h
  259.      */
  260.     netsnmp_variable_list var_ipCidrRouteDest;
  261.     /*
  262.      * ipCidrRouteMask(2)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h
  263.      */
  264.     netsnmp_variable_list var_ipCidrRouteMask;
  265.     /*
  266.      * ipCidrRouteTos(3)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h
  267.      */
  268.     netsnmp_variable_list var_ipCidrRouteTos;
  269.     /*
  270.      * ipCidrRouteNextHop(4)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h
  271.      */
  272.     netsnmp_variable_list var_ipCidrRouteNextHop;
  273.     /*
  274.      * set up varbinds
  275.      */
  276.     memset(&var_ipCidrRouteDest, 0x00, sizeof(var_ipCidrRouteDest));
  277.     var_ipCidrRouteDest.type = ASN_PRIV_IMPLIED_OCTET_STR;
  278.     memset(&var_ipCidrRouteMask, 0x00, sizeof(var_ipCidrRouteMask));
  279.     var_ipCidrRouteMask.type = ASN_PRIV_IMPLIED_OCTET_STR;
  280.     memset(&var_ipCidrRouteTos, 0x00, sizeof(var_ipCidrRouteTos));
  281.     var_ipCidrRouteTos.type = ASN_INTEGER;
  282.     memset(&var_ipCidrRouteNextHop, 0x00, sizeof(var_ipCidrRouteNextHop));
  283.     var_ipCidrRouteNextHop.type = ASN_PRIV_IMPLIED_OCTET_STR;
  284.     /*
  285.      * chain temp index varbinds together
  286.      */
  287.     var_ipCidrRouteDest.next_variable = &var_ipCidrRouteMask;
  288.     var_ipCidrRouteMask.next_variable = &var_ipCidrRouteTos;
  289.     var_ipCidrRouteTos.next_variable = &var_ipCidrRouteNextHop;
  290.     var_ipCidrRouteNextHop.next_variable = NULL;
  291.     DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_index_to_oid",
  292.                 "calledn"));
  293.     /*
  294.      * ipCidrRouteDest(1)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h 
  295.      */
  296.     snmp_set_var_value(&var_ipCidrRouteDest,
  297.                        (u_char *) & mib_idx->ipCidrRouteDest,
  298.                        sizeof(mib_idx->ipCidrRouteDest));
  299.     /*
  300.      * ipCidrRouteMask(2)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h 
  301.      */
  302.     snmp_set_var_value(&var_ipCidrRouteMask,
  303.                        (u_char *) & mib_idx->ipCidrRouteMask,
  304.                        sizeof(mib_idx->ipCidrRouteMask));
  305.     /*
  306.      * ipCidrRouteTos(3)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h 
  307.      */
  308.     snmp_set_var_value(&var_ipCidrRouteTos,
  309.                        (u_char *) & mib_idx->ipCidrRouteTos,
  310.                        sizeof(mib_idx->ipCidrRouteTos));
  311.     /*
  312.      * ipCidrRouteNextHop(4)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h 
  313.      */
  314.     snmp_set_var_value(&var_ipCidrRouteNextHop,
  315.                        (u_char *) & mib_idx->ipCidrRouteNextHop,
  316.                        sizeof(mib_idx->ipCidrRouteNextHop));
  317.     err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len,
  318.                             NULL, 0, &var_ipCidrRouteDest);
  319.     if (err)
  320.         snmp_log(LOG_ERR, "error %d converting index to oidn", err);
  321.     /*
  322.      * parsing may have allocated memory. free it.
  323.      */
  324.     snmp_reset_var_buffers(&var_ipCidrRouteDest);
  325.     return err;
  326. }                               /* ipCidrRouteTable_index_to_oid */
  327. /**
  328.  * extract ipCidrRouteTable indexes from a netsnmp_index
  329.  *
  330.  * @retval SNMP_ERR_NOERROR  : no error
  331.  * @retval SNMP_ERR_GENERR   : error
  332.  */
  333. int
  334. ipCidrRouteTable_index_from_oid(netsnmp_index * oid_idx,
  335.                                 ipCidrRouteTable_mib_index * mib_idx)
  336. {
  337.     int             err = SNMP_ERR_NOERROR;
  338.     /*
  339.      * temp storage for parsing indexes
  340.      */
  341.     /*
  342.      * ipCidrRouteDest(1)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h
  343.      */
  344.     netsnmp_variable_list var_ipCidrRouteDest;
  345.     /*
  346.      * ipCidrRouteMask(2)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h
  347.      */
  348.     netsnmp_variable_list var_ipCidrRouteMask;
  349.     /*
  350.      * ipCidrRouteTos(3)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h
  351.      */
  352.     netsnmp_variable_list var_ipCidrRouteTos;
  353.     /*
  354.      * ipCidrRouteNextHop(4)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h
  355.      */
  356.     netsnmp_variable_list var_ipCidrRouteNextHop;
  357.     /*
  358.      * set up varbinds
  359.      */
  360.     memset(&var_ipCidrRouteDest, 0x00, sizeof(var_ipCidrRouteDest));
  361.     var_ipCidrRouteDest.type = ASN_IPADDRESS;
  362.     memset(&var_ipCidrRouteMask, 0x00, sizeof(var_ipCidrRouteMask));
  363.     var_ipCidrRouteMask.type = ASN_IPADDRESS;
  364.     memset(&var_ipCidrRouteTos, 0x00, sizeof(var_ipCidrRouteTos));
  365.     var_ipCidrRouteTos.type = ASN_INTEGER;
  366.     memset(&var_ipCidrRouteNextHop, 0x00, sizeof(var_ipCidrRouteNextHop));
  367.     var_ipCidrRouteNextHop.type = ASN_IPADDRESS;
  368.     /*
  369.      * chain temp index varbinds together
  370.      */
  371.     var_ipCidrRouteDest.next_variable = &var_ipCidrRouteMask;
  372.     var_ipCidrRouteMask.next_variable = &var_ipCidrRouteTos;
  373.     var_ipCidrRouteTos.next_variable = &var_ipCidrRouteNextHop;
  374.     var_ipCidrRouteNextHop.next_variable = NULL;
  375.     DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_index_from_oid",
  376.                 "calledn"));
  377.     /*
  378.      * parse the oid into the individual index components
  379.      */
  380.     err = parse_oid_indexes(oid_idx->oids, oid_idx->len,
  381.                             &var_ipCidrRouteDest);
  382.     if (err == SNMP_ERR_NOERROR) {
  383.         /*
  384.          * copy out values
  385.          */
  386.         mib_idx->ipCidrRouteDest =
  387.             *((u_long *) var_ipCidrRouteDest.val.string);
  388.         mib_idx->ipCidrRouteMask =
  389.             *((u_long *) var_ipCidrRouteMask.val.string);
  390.         mib_idx->ipCidrRouteTos =
  391.             *((long *) var_ipCidrRouteTos.val.string);
  392.         mib_idx->ipCidrRouteNextHop =
  393.             *((u_long *) var_ipCidrRouteNextHop.val.string);
  394.     }
  395.     /*
  396.      * parsing may have allocated memory. free it.
  397.      */
  398.     snmp_reset_var_buffers(&var_ipCidrRouteDest);
  399.     return err;
  400. }                               /* ipCidrRouteTable_index_from_oid */
  401. /*
  402.  *********************************************************************
  403.  * @internal
  404.  * allocate resources for a ipCidrRouteTable_rowreq_ctx
  405.  */
  406. ipCidrRouteTable_rowreq_ctx *
  407. ipCidrRouteTable_allocate_rowreq_ctx(ipCidrRouteTable_data * data)
  408. {
  409.     ipCidrRouteTable_rowreq_ctx *rowreq_ctx =
  410.         SNMP_MALLOC_TYPEDEF(ipCidrRouteTable_rowreq_ctx);
  411.     DEBUGMSGTL(("internal:ipCidrRouteTable:ipCidrRouteTable_allocate_rowreq_ctx", "calledn"));
  412.     if (NULL == rowreq_ctx) {
  413.         snmp_log(LOG_ERR, "Couldn't allocate memory for a "
  414.                  "ipCidrRouteTable_rowreq_ctx.n");
  415.     } else {
  416.         if (NULL != data) {
  417.             rowreq_ctx->data = data;
  418.         } else if (NULL ==
  419.                    (rowreq_ctx->data = ipCidrRouteTable_allocate_data())) {
  420.             SNMP_FREE(rowreq_ctx);
  421.             return NULL;
  422.         }
  423.     }
  424.     /*
  425.      * undo context will be allocated when needed (in *_undo_setup)
  426.      */
  427.     rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp;
  428.     rowreq_ctx->ipCidrRouteTable_data_list = NULL;
  429.     rowreq_ctx->ipCidrRouteTable_reg = ipCidrRouteTable_if_ctx.user_ctx;
  430.     return rowreq_ctx;
  431. }                               /* ipCidrRouteTable_allocate_rowreq_ctx */
  432. /*
  433.  * @internal
  434.  * release resources for a ipCidrRouteTable_rowreq_ctx
  435.  */
  436. void
  437. ipCidrRouteTable_release_rowreq_ctx(ipCidrRouteTable_rowreq_ctx *
  438.                                     rowreq_ctx)
  439. {
  440.     DEBUGMSGTL(("internal:ipCidrRouteTable:ipCidrRouteTable_release_rowreq_ctx", "calledn"));
  441.     netsnmp_assert(NULL != rowreq_ctx);
  442.     if (rowreq_ctx->data)
  443.         ipCidrRouteTable_release_data(rowreq_ctx->data);
  444.     if (rowreq_ctx->undo)
  445.         ipCidrRouteTable_release_data(rowreq_ctx->undo);
  446.     /*
  447.      * free index oid pointer
  448.      */
  449.     if (rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp)
  450.         free(rowreq_ctx->oid_idx.oids);
  451.     SNMP_FREE(rowreq_ctx);
  452. }                               /* ipCidrRouteTable_release_rowreq_ctx */
  453. /**
  454.  * @internal
  455.  * wrapper
  456.  */
  457. static int
  458. _mfd_ipCidrRouteTable_pre_request(netsnmp_mib_handler *handler,
  459.                                   netsnmp_handler_registration *reginfo,
  460.                                   netsnmp_agent_request_info *agtreq_info,
  461.                                   netsnmp_request_info *requests)
  462. {
  463.     int             rc =
  464.         ipCidrRouteTable_pre_request(ipCidrRouteTable_if_ctx.user_ctx);
  465.     if (MFD_SUCCESS != rc) {
  466.         /*
  467.          * nothing we can do about it but log it
  468.          */
  469.         DEBUGMSGTL(("internal:ipCidrRouteTable", "error %d from "
  470.                     "ipCidrRouteTable_pre_requestn", rc));
  471.         netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
  472.     }
  473.     return SNMP_ERR_NOERROR;
  474. }                               /* _mfd_ipCidrRouteTable_pre_request */
  475. /**
  476.  * @internal
  477.  * wrapper
  478.  */
  479. static int
  480. _mfd_ipCidrRouteTable_post_request(netsnmp_mib_handler *handler,
  481.                                    netsnmp_handler_registration *reginfo,
  482.                                    netsnmp_agent_request_info *agtreq_info,
  483.                                    netsnmp_request_info *requests)
  484. {
  485.     ipCidrRouteTable_rowreq_ctx *rowreq_ctx;
  486.     int             rc =
  487.         ipCidrRouteTable_post_request(ipCidrRouteTable_if_ctx.user_ctx);
  488.     if (MFD_SUCCESS != rc) {
  489.         /*
  490.          * nothing we can do about it but log it
  491.          */
  492.         DEBUGMSGTL(("internal:ipCidrRouteTable", "error %d from "
  493.                     "ipCidrRouteTable_post_requestn", rc));
  494.     }
  495.     /*
  496.      * if it was set, clear row created flag.
  497.      */
  498.     rowreq_ctx = netsnmp_container_table_row_extract(requests);
  499.     if ((NULL != rowreq_ctx)
  500.         && (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED))
  501.         rowreq_ctx->rowreq_flags &= ~MFD_ROW_CREATED;
  502.     return SNMP_ERR_NOERROR;
  503. }                               /* _mfd_ipCidrRouteTable_post_request */
  504. /**
  505.  * @internal
  506.  * wrapper
  507.  */
  508. static int
  509. _mfd_ipCidrRouteTable_object_lookup(netsnmp_mib_handler *handler,
  510.                                     netsnmp_handler_registration *reginfo,
  511.                                     netsnmp_agent_request_info
  512.                                     *agtreq_info,
  513.                                     netsnmp_request_info *requests)
  514. {
  515.     ipCidrRouteTable_rowreq_ctx *rowreq_ctx =
  516.         netsnmp_container_table_row_extract(requests);
  517.     DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_object_lookup", "calledn"));
  518.     /*
  519.      * get our context from mfd
  520.      * ipCidrRouteTable_interface_ctx *if_ctx =
  521.      *             (ipCidrRouteTable_interface_ctx *)reginfo->my_reg_void;
  522.      */
  523.     if (NULL == rowreq_ctx) {
  524.         int             rc = MFD_SUCCESS;
  525.         netsnmp_table_request_info *tblreq_info;
  526.         netsnmp_index   oid_idx;
  527.         ipCidrRouteTable_mib_index mib_idx;
  528.         tblreq_info = netsnmp_extract_table_info(requests);
  529.         if (NULL == tblreq_info) {
  530.             snmp_log(LOG_ERR, "request had no table infon");
  531.             return MFD_ERROR;
  532.         }
  533.         /*
  534.          * try to parse oid
  535.          */
  536.         oid_idx.oids = tblreq_info->index_oid;
  537.         oid_idx.len = tblreq_info->index_oid_len;
  538.         rc = ipCidrRouteTable_index_from_oid(&oid_idx, &mib_idx);
  539.         if (MFD_SUCCESS != rc) {
  540.             DEBUGMSGT(("ipCidrRouteTable", "error parsing indexn"));
  541.             netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
  542.         } else {
  543.             /*
  544.              * allocate new context
  545.              */
  546.             rowreq_ctx = ipCidrRouteTable_allocate_rowreq_ctx(NULL);
  547.             if (NULL == rowreq_ctx)
  548.                 return MFD_ERROR;       /* msg already logged */
  549.             memcpy(&rowreq_ctx->tbl_idx, &mib_idx, sizeof(mib_idx));
  550.             /*
  551.              * check indexes
  552.              */
  553.             rc = _ipCidrRouteTable_check_indexes(rowreq_ctx);
  554.             if (MFD_SUCCESS != rc) {
  555.                 netsnmp_assert((rc == SNMP_ERR_NOCREATION) ||
  556.                                (rc == SNMP_ERR_INCONSISTENTNAME));
  557.                 netsnmp_request_set_error_all(requests,
  558.                                               SNMP_VALIDATE_ERR(rc));
  559.                 ipCidrRouteTable_release_rowreq_ctx(rowreq_ctx);
  560.             } else {
  561.                 rowreq_ctx->rowreq_flags |= MFD_ROW_CREATED;
  562.                 netsnmp_container_table_row_insert(requests, rowreq_ctx);
  563.             }
  564.         }
  565.     } else {
  566.         ipCidrRouteTable_row_prep(rowreq_ctx);
  567.     }
  568.     return SNMP_ERR_NOERROR;
  569. }                               /* _mfd_ipCidrRouteTable_object_lookup */
  570. /***********************************************************************
  571.  *
  572.  * GET processing
  573.  *
  574.  ***********************************************************************/
  575. /*
  576.  * @internal
  577.  * Retrieve the value for a particular column
  578.  */
  579. NETSNMP_STATIC_INLINE int
  580. _ipCidrRouteTable_get_column(ipCidrRouteTable_rowreq_ctx * rowreq_ctx,
  581.                              netsnmp_variable_list * var, int column)
  582. {
  583.     int             rc = SNMPERR_SUCCESS;
  584.     DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_get_column", "calledn"));
  585.     netsnmp_assert(NULL != rowreq_ctx);
  586.     switch (column) {
  587.         /*
  588.          * (INDEX) ipCidrRouteDest(1)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h 
  589.          */
  590.     case COLUMN_IPCIDRROUTEDEST:
  591.         var->type = ASN_IPADDRESS;
  592.         var->val_len = sizeof(u_long);
  593.         (*var->val.integer) = rowreq_ctx->tbl_idx.ipCidrRouteDest;
  594.         break;
  595.         /*
  596.          * (INDEX) ipCidrRouteMask(2)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h 
  597.          */
  598.     case COLUMN_IPCIDRROUTEMASK:
  599.         var->type = ASN_IPADDRESS;
  600.         var->val_len = sizeof(u_long);
  601.         (*var->val.integer) = rowreq_ctx->tbl_idx.ipCidrRouteMask;
  602.         break;
  603.         /*
  604.          * (INDEX) ipCidrRouteTos(3)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h 
  605.          */
  606.     case COLUMN_IPCIDRROUTETOS:
  607.         var->type = ASN_INTEGER;
  608.         var->val_len = sizeof(long);
  609.         (*var->val.integer) = rowreq_ctx->tbl_idx.ipCidrRouteTos;
  610.         break;
  611.         /*
  612.          * (INDEX) ipCidrRouteNextHop(4)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h 
  613.          */
  614.     case COLUMN_IPCIDRROUTENEXTHOP:
  615.         var->type = ASN_IPADDRESS;
  616.         var->val_len = sizeof(u_long);
  617.         (*var->val.integer) = rowreq_ctx->tbl_idx.ipCidrRouteNextHop;
  618.         break;
  619.         /*
  620.          * ipCidrRouteIfIndex(5)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  621.          */
  622.     case COLUMN_IPCIDRROUTEIFINDEX:
  623.         var->val_len = sizeof(long);
  624.         var->type = ASN_INTEGER;
  625.         rc = ipCidrRouteIfIndex_get(rowreq_ctx, (long *) var->val.string);
  626.         break;
  627.         /*
  628.          * ipCidrRouteType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h 
  629.          */
  630.     case COLUMN_IPCIDRROUTETYPE:
  631.         var->val_len = sizeof(u_long);
  632.         var->type = ASN_INTEGER;
  633.         rc = ipCidrRouteType_get(rowreq_ctx, (u_long *) var->val.string);
  634.         break;
  635.         /*
  636.          * ipCidrRouteProto(7)/INTEGER/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h 
  637.          */
  638.     case COLUMN_IPCIDRROUTEPROTO:
  639.         var->val_len = sizeof(u_long);
  640.         var->type = ASN_INTEGER;
  641.         rc = ipCidrRouteProto_get(rowreq_ctx, (u_long *) var->val.string);
  642.         break;
  643.         /*
  644.          * ipCidrRouteAge(8)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/r/D/h 
  645.          */
  646.     case COLUMN_IPCIDRROUTEAGE:
  647.         var->val_len = sizeof(long);
  648.         var->type = ASN_INTEGER;
  649.         rc = ipCidrRouteAge_get(rowreq_ctx, (long *) var->val.string);
  650.         break;
  651.         /*
  652.          * ipCidrRouteInfo(9)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/A/W/e/r/d/h 
  653.          */
  654.     case COLUMN_IPCIDRROUTEINFO:
  655.         var->type = ASN_OBJECT_ID;
  656.         rc = ipCidrRouteInfo_get(rowreq_ctx, (oid **) & var->val.string,
  657.                                  &var->val_len);
  658.         break;
  659.         /*
  660.          * ipCidrRouteNextHopAS(10)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  661.          */
  662.     case COLUMN_IPCIDRROUTENEXTHOPAS:
  663.         var->val_len = sizeof(long);
  664.         var->type = ASN_INTEGER;
  665.         rc = ipCidrRouteNextHopAS_get(rowreq_ctx,
  666.                                       (long *) var->val.string);
  667.         break;
  668.         /*
  669.          * ipCidrRouteMetric1(11)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  670.          */
  671.     case COLUMN_IPCIDRROUTEMETRIC1:
  672.         var->val_len = sizeof(long);
  673.         var->type = ASN_INTEGER;
  674.         rc = ipCidrRouteMetric1_get(rowreq_ctx, (long *) var->val.string);
  675.         break;
  676.         /*
  677.          * ipCidrRouteMetric2(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  678.          */
  679.     case COLUMN_IPCIDRROUTEMETRIC2:
  680.         var->val_len = sizeof(long);
  681.         var->type = ASN_INTEGER;
  682.         rc = ipCidrRouteMetric2_get(rowreq_ctx, (long *) var->val.string);
  683.         break;
  684.         /*
  685.          * ipCidrRouteMetric3(13)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  686.          */
  687.     case COLUMN_IPCIDRROUTEMETRIC3:
  688.         var->val_len = sizeof(long);
  689.         var->type = ASN_INTEGER;
  690.         rc = ipCidrRouteMetric3_get(rowreq_ctx, (long *) var->val.string);
  691.         break;
  692.         /*
  693.          * ipCidrRouteMetric4(14)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  694.          */
  695.     case COLUMN_IPCIDRROUTEMETRIC4:
  696.         var->val_len = sizeof(long);
  697.         var->type = ASN_INTEGER;
  698.         rc = ipCidrRouteMetric4_get(rowreq_ctx, (long *) var->val.string);
  699.         break;
  700.         /*
  701.          * ipCidrRouteMetric5(15)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  702.          */
  703.     case COLUMN_IPCIDRROUTEMETRIC5:
  704.         var->val_len = sizeof(long);
  705.         var->type = ASN_INTEGER;
  706.         rc = ipCidrRouteMetric5_get(rowreq_ctx, (long *) var->val.string);
  707.         break;
  708.         /*
  709.          * ipCidrRouteStatus(16)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h 
  710.          */
  711.     case COLUMN_IPCIDRROUTESTATUS:
  712.         var->val_len = sizeof(u_long);
  713.         var->type = ASN_INTEGER;
  714.         rc = ipCidrRouteStatus_get(rowreq_ctx, (u_long *) var->val.string);
  715.         break;
  716.     default:
  717.         snmp_log(LOG_ERR,
  718.                  "unknown column %d in _ipCidrRouteTable_get_columnn",
  719.                  column);
  720.         break;
  721.     }
  722.     return rc;
  723. }                               /* _ipCidrRouteTable_get_column */
  724. int
  725. _mfd_ipCidrRouteTable_get_values(netsnmp_mib_handler *handler,
  726.                                  netsnmp_handler_registration *reginfo,
  727.                                  netsnmp_agent_request_info *agtreq_info,
  728.                                  netsnmp_request_info *requests)
  729. {
  730.     ipCidrRouteTable_rowreq_ctx *rowreq_ctx =
  731.         netsnmp_container_table_row_extract(requests);
  732.     netsnmp_table_request_info *tri;
  733.     u_char         *old_string;
  734.     void            (*dataFreeHook) (void *);
  735.     int             rc;
  736.     DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_get_values", "calledn"));
  737.     netsnmp_assert(NULL != rowreq_ctx);
  738.     for (; requests; requests = requests->next) {
  739.         /*
  740.          * save old pointer, so we can free it if replaced
  741.          */
  742.         old_string = requests->requestvb->val.string;
  743.         dataFreeHook = requests->requestvb->dataFreeHook;
  744.         if (NULL == requests->requestvb->val.string) {
  745.             requests->requestvb->val.string = requests->requestvb->buf;
  746.             requests->requestvb->val_len =
  747.                 sizeof(requests->requestvb->buf);
  748.         } else if (requests->requestvb->buf ==
  749.                    requests->requestvb->val.string) {
  750.             if (requests->requestvb->val_len !=
  751.                 sizeof(requests->requestvb->buf))
  752.                 requests->requestvb->val_len =
  753.                     sizeof(requests->requestvb->buf);
  754.         }
  755.         /*
  756.          * get column data
  757.          */
  758.         tri = netsnmp_extract_table_info(requests);
  759.         if (NULL == tri)
  760.             continue;
  761.         rc = _ipCidrRouteTable_get_column(rowreq_ctx, requests->requestvb,
  762.                                           tri->colnum);
  763.         if (rc) {
  764.             if (MFD_SKIP == rc) {
  765.                 requests->requestvb->type = ASN_PRIV_RETRY;
  766.                 rc = SNMP_ERR_NOERROR;
  767.             }
  768.         } else if (NULL == requests->requestvb->val.string) {
  769.             snmp_log(LOG_ERR, "NULL varbind data pointer!n");
  770.             rc = SNMP_ERR_GENERR;
  771.         }
  772.         if (rc)
  773.             netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc));
  774.         /*
  775.          * if the buffer wasn't used previously for the old data (i.e. it
  776.          * was allcoated memory)  and the get routine replaced the pointer,
  777.          * we need to free the previous pointer.
  778.          */
  779.         if (old_string && (old_string != requests->requestvb->buf) &&
  780.             (requests->requestvb->val.string != old_string)) {
  781.             if (dataFreeHook)
  782.                 (*dataFreeHook) (old_string);
  783.             else
  784.                 free(old_string);
  785.         }
  786.     }                           /* for results */
  787.     return SNMP_ERR_NOERROR;
  788. }                               /* _mfd_ipCidrRouteTable_get_values */
  789. /***********************************************************************
  790.  *
  791.  * SET processing
  792.  *
  793.  ***********************************************************************/
  794. /*----------------------------------------------------------------------
  795.  *
  796.  * SET: Syntax checks
  797.  *
  798.  *---------------------------------------------------------------------*/
  799. /*
  800.  * @internal
  801.  * Check the syntax for a particular column
  802.  */
  803. NETSNMP_STATIC_INLINE int
  804. _ipCidrRouteTable_check_column(ipCidrRouteTable_rowreq_ctx * rowreq_ctx,
  805.                                netsnmp_variable_list * var, int column)
  806. {
  807.     int             rc = SNMPERR_SUCCESS;
  808.     DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_check_column",
  809.                 "calledn"));
  810.     netsnmp_assert(NULL != rowreq_ctx);
  811.     switch (column) {
  812.         /*
  813.          * ipCidrRouteIfIndex(5)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  814.          */
  815.     case COLUMN_IPCIDRROUTEIFINDEX:
  816.         rc = netsnmp_check_vb_type(var, ASN_INTEGER);
  817.         /*
  818.          * yyy-rks: anything else we can do here? 
  819.          */
  820.         if (SNMPERR_SUCCESS == rc) {
  821.             rc = ipCidrRouteIfIndex_check_value(rowreq_ctx,
  822.                                                 *((long *) var->val.
  823.                                                   string));
  824.             if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
  825.                 && (MFD_NOT_VALID_NOW != rc)) {
  826.                 snmp_log(LOG_ERR,
  827.                          "bad rc %d from ipCidrRouteIfIndex_check_valuen",
  828.                          rc);
  829.                 rc = SNMP_ERR_GENERR;
  830.             }
  831.         }
  832.         break;
  833.         /*
  834.          * ipCidrRouteType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h 
  835.          */
  836.     case COLUMN_IPCIDRROUTETYPE:
  837.         rc = netsnmp_check_vb_type(var, ASN_INTEGER);
  838.         if (SNMPERR_SUCCESS == rc) {
  839.             /*
  840.              * check that the value is one of defined enums 
  841.              */
  842.             if (1 && (*var->val.integer != IPCIDRROUTETYPE_OTHER)
  843.                 && (*var->val.integer != IPCIDRROUTETYPE_REJECT)
  844.                 && (*var->val.integer != IPCIDRROUTETYPE_LOCAL)
  845.                 && (*var->val.integer != IPCIDRROUTETYPE_REMOTE)
  846.                 ) {
  847.                 rc = SNMP_ERR_WRONGVALUE;
  848.             }
  849.         }
  850.         if (SNMPERR_SUCCESS == rc) {
  851.             rc = ipCidrRouteType_check_value(rowreq_ctx,
  852.                                              *((u_long *) var->val.
  853.                                                string));
  854.             if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
  855.                 && (MFD_NOT_VALID_NOW != rc)) {
  856.                 snmp_log(LOG_ERR,
  857.                          "bad rc %d from ipCidrRouteType_check_valuen",
  858.                          rc);
  859.                 rc = SNMP_ERR_GENERR;
  860.             }
  861.         }
  862.         break;
  863.         /*
  864.          * ipCidrRouteInfo(9)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/A/W/e/r/d/h 
  865.          */
  866.     case COLUMN_IPCIDRROUTEINFO:
  867.         rc = netsnmp_check_vb_type(var, ASN_OBJECT_ID);
  868.         /*
  869.          * yyy-rks: anything else we can do here? 
  870.          */
  871.         if (SNMPERR_SUCCESS == rc) {
  872.             rc = ipCidrRouteInfo_check_value(rowreq_ctx,
  873.                                              (oid *) var->val.string,
  874.                                              var->val_len);
  875.             if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
  876.                 && (MFD_NOT_VALID_NOW != rc)) {
  877.                 snmp_log(LOG_ERR,
  878.                          "bad rc %d from ipCidrRouteInfo_check_valuen",
  879.                          rc);
  880.                 rc = SNMP_ERR_GENERR;
  881.             }
  882.         }
  883.         break;
  884.         /*
  885.          * ipCidrRouteNextHopAS(10)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  886.          */
  887.     case COLUMN_IPCIDRROUTENEXTHOPAS:
  888.         rc = netsnmp_check_vb_type(var, ASN_INTEGER);
  889.         /*
  890.          * yyy-rks: anything else we can do here? 
  891.          */
  892.         if (SNMPERR_SUCCESS == rc) {
  893.             rc = ipCidrRouteNextHopAS_check_value(rowreq_ctx,
  894.                                                   *((long *) var->val.
  895.                                                     string));
  896.             if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
  897.                 && (MFD_NOT_VALID_NOW != rc)) {
  898.                 snmp_log(LOG_ERR,
  899.                          "bad rc %d from ipCidrRouteNextHopAS_check_valuen",
  900.                          rc);
  901.                 rc = SNMP_ERR_GENERR;
  902.             }
  903.         }
  904.         break;
  905.         /*
  906.          * ipCidrRouteMetric1(11)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  907.          */
  908.     case COLUMN_IPCIDRROUTEMETRIC1:
  909.         rc = netsnmp_check_vb_type(var, ASN_INTEGER);
  910.         /*
  911.          * yyy-rks: anything else we can do here? 
  912.          */
  913.         if (SNMPERR_SUCCESS == rc) {
  914.             rc = ipCidrRouteMetric1_check_value(rowreq_ctx,
  915.                                                 *((long *) var->val.
  916.                                                   string));
  917.             if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
  918.                 && (MFD_NOT_VALID_NOW != rc)) {
  919.                 snmp_log(LOG_ERR,
  920.                          "bad rc %d from ipCidrRouteMetric1_check_valuen",
  921.                          rc);
  922.                 rc = SNMP_ERR_GENERR;
  923.             }
  924.         }
  925.         break;
  926.         /*
  927.          * ipCidrRouteMetric2(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  928.          */
  929.     case COLUMN_IPCIDRROUTEMETRIC2:
  930.         rc = netsnmp_check_vb_type(var, ASN_INTEGER);
  931.         /*
  932.          * yyy-rks: anything else we can do here? 
  933.          */
  934.         if (SNMPERR_SUCCESS == rc) {
  935.             rc = ipCidrRouteMetric2_check_value(rowreq_ctx,
  936.                                                 *((long *) var->val.
  937.                                                   string));
  938.             if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
  939.                 && (MFD_NOT_VALID_NOW != rc)) {
  940.                 snmp_log(LOG_ERR,
  941.                          "bad rc %d from ipCidrRouteMetric2_check_valuen",
  942.                          rc);
  943.                 rc = SNMP_ERR_GENERR;
  944.             }
  945.         }
  946.         break;
  947.         /*
  948.          * ipCidrRouteMetric3(13)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  949.          */
  950.     case COLUMN_IPCIDRROUTEMETRIC3:
  951.         rc = netsnmp_check_vb_type(var, ASN_INTEGER);
  952.         /*
  953.          * yyy-rks: anything else we can do here? 
  954.          */
  955.         if (SNMPERR_SUCCESS == rc) {
  956.             rc = ipCidrRouteMetric3_check_value(rowreq_ctx,
  957.                                                 *((long *) var->val.
  958.                                                   string));
  959.             if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
  960.                 && (MFD_NOT_VALID_NOW != rc)) {
  961.                 snmp_log(LOG_ERR,
  962.                          "bad rc %d from ipCidrRouteMetric3_check_valuen",
  963.                          rc);
  964.                 rc = SNMP_ERR_GENERR;
  965.             }
  966.         }
  967.         break;
  968.         /*
  969.          * ipCidrRouteMetric4(14)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  970.          */
  971.     case COLUMN_IPCIDRROUTEMETRIC4:
  972.         rc = netsnmp_check_vb_type(var, ASN_INTEGER);
  973.         /*
  974.          * yyy-rks: anything else we can do here? 
  975.          */
  976.         if (SNMPERR_SUCCESS == rc) {
  977.             rc = ipCidrRouteMetric4_check_value(rowreq_ctx,
  978.                                                 *((long *) var->val.
  979.                                                   string));
  980.             if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
  981.                 && (MFD_NOT_VALID_NOW != rc)) {
  982.                 snmp_log(LOG_ERR,
  983.                          "bad rc %d from ipCidrRouteMetric4_check_valuen",
  984.                          rc);
  985.                 rc = SNMP_ERR_GENERR;
  986.             }
  987.         }
  988.         break;
  989.         /*
  990.          * ipCidrRouteMetric5(15)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  991.          */
  992.     case COLUMN_IPCIDRROUTEMETRIC5:
  993.         rc = netsnmp_check_vb_type(var, ASN_INTEGER);
  994.         /*
  995.          * yyy-rks: anything else we can do here? 
  996.          */
  997.         if (SNMPERR_SUCCESS == rc) {
  998.             rc = ipCidrRouteMetric5_check_value(rowreq_ctx,
  999.                                                 *((long *) var->val.
  1000.                                                   string));
  1001.             if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
  1002.                 && (MFD_NOT_VALID_NOW != rc)) {
  1003.                 snmp_log(LOG_ERR,
  1004.                          "bad rc %d from ipCidrRouteMetric5_check_valuen",
  1005.                          rc);
  1006.                 rc = SNMP_ERR_GENERR;
  1007.             }
  1008.         }
  1009.         break;
  1010.         /*
  1011.          * ipCidrRouteStatus(16)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h 
  1012.          */
  1013.     case COLUMN_IPCIDRROUTESTATUS:
  1014.         rc = netsnmp_check_vb_rowstatus_value(var);
  1015.         if (SNMPERR_SUCCESS == rc) {
  1016.             rc = ipCidrRouteStatus_check_value(rowreq_ctx,
  1017.                                                *((u_long *) var->val.
  1018.                                                  string));
  1019.             if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
  1020.                 && (MFD_NOT_VALID_NOW != rc)) {
  1021.                 snmp_log(LOG_ERR,
  1022.                          "bad rc %d from ipCidrRouteStatus_check_valuen",
  1023.                          rc);
  1024.                 rc = SNMP_ERR_GENERR;
  1025.             }
  1026.         }
  1027.         break;
  1028.     default:   /** We shouldn't get here */
  1029.         rc = SNMP_ERR_GENERR;
  1030.         snmp_log(LOG_ERR,
  1031.                  "unknown column %d in _ipCidrRouteTable_check_columnn",
  1032.                  column);
  1033.     }
  1034.     return rc;
  1035. }                               /* _ipCidrRouteTable_check_column */
  1036. int
  1037. _mfd_ipCidrRouteTable_check_objects(netsnmp_mib_handler *handler,
  1038.                                     netsnmp_handler_registration *reginfo,
  1039.                                     netsnmp_agent_request_info
  1040.                                     *agtreq_info,
  1041.                                     netsnmp_request_info *requests)
  1042. {
  1043.     ipCidrRouteTable_rowreq_ctx *rowreq_ctx =
  1044.         netsnmp_container_table_row_extract(requests);
  1045.     int             rc;
  1046.     DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_check_objects", "calledn"));
  1047.     netsnmp_assert(NULL != rowreq_ctx);
  1048.     for (; requests; requests = requests->next) {
  1049.         /*
  1050.          * get column number from table request info, and check that column
  1051.          */
  1052.         netsnmp_table_request_info *tri;
  1053.         tri = netsnmp_extract_table_info(requests);
  1054.         if (NULL == tri)
  1055.             continue;
  1056.         rc = _ipCidrRouteTable_check_column(rowreq_ctx,
  1057.                                             requests->requestvb,
  1058.                                             tri->colnum);
  1059.         if (rc) {
  1060.             netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc));
  1061.             break;
  1062.         }
  1063.     }                           /* for results */
  1064.     return SNMP_ERR_NOERROR;
  1065. }                               /* _mfd_ipCidrRouteTable_check_objects */
  1066. NETSNMP_STATIC_INLINE int
  1067. _ipCidrRouteTable_check_indexes(ipCidrRouteTable_rowreq_ctx * rowreq_ctx)
  1068. {
  1069.     int             rc;
  1070.     DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_check_indexes", "calledn"));
  1071.     netsnmp_assert(NULL != rowreq_ctx);
  1072.     /*
  1073.      * (INDEX) ipCidrRouteDest(1)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h 
  1074.      */
  1075.     rc = ipCidrRouteDest_check_index(rowreq_ctx);
  1076.     if (MFD_SUCCESS != rc)
  1077.         return SNMP_ERR_NOCREATION;
  1078.     /*
  1079.      * (INDEX) ipCidrRouteMask(2)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h 
  1080.      */
  1081.     rc = ipCidrRouteMask_check_index(rowreq_ctx);
  1082.     if (MFD_SUCCESS != rc)
  1083.         return SNMP_ERR_NOCREATION;
  1084.     /*
  1085.      * (INDEX) ipCidrRouteTos(3)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h 
  1086.      */
  1087.     rc = ipCidrRouteTos_check_index(rowreq_ctx);
  1088.     if (MFD_SUCCESS != rc)
  1089.         return SNMP_ERR_NOCREATION;
  1090.     /*
  1091.      * (INDEX) ipCidrRouteNextHop(4)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h 
  1092.      */
  1093.     rc = ipCidrRouteNextHop_check_index(rowreq_ctx);
  1094.     if (MFD_SUCCESS != rc)
  1095.         return SNMP_ERR_NOCREATION;
  1096.     /*
  1097.      * if individual parts look ok, check them as a whole
  1098.      */
  1099.     return ipCidrRouteTable_validate_index(rowreq_ctx->
  1100.                                            ipCidrRouteTable_reg,
  1101.                                            rowreq_ctx);
  1102. }                               /* _ipCidrRouteTable_check_indexes */
  1103. /*----------------------------------------------------------------------
  1104.  *
  1105.  * SET: Undo setup
  1106.  *
  1107.  *---------------------------------------------------------------------*/
  1108. /*
  1109.  * @internal
  1110.  * Set the value for a particular column
  1111.  */
  1112. NETSNMP_STATIC_INLINE int
  1113. _ipCidrRouteTable_undo_setup_column(ipCidrRouteTable_rowreq_ctx *
  1114.                                     rowreq_ctx, int column)
  1115. {
  1116.     int             rc = SNMPERR_SUCCESS;
  1117.     DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_undo_setup_column", "calledn"));
  1118.     netsnmp_assert(NULL != rowreq_ctx);
  1119.     switch (column) {
  1120.         /*
  1121.          * ipCidrRouteIfIndex(5)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  1122.          */
  1123.     case COLUMN_IPCIDRROUTEIFINDEX:
  1124.         rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTEIFINDEX;
  1125.         rc = ipCidrRouteIfIndex_undo_setup(rowreq_ctx);
  1126.         break;
  1127.         /*
  1128.          * ipCidrRouteType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h 
  1129.          */
  1130.     case COLUMN_IPCIDRROUTETYPE:
  1131.         rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTETYPE;
  1132.         rc = ipCidrRouteType_undo_setup(rowreq_ctx);
  1133.         break;
  1134.         /*
  1135.          * ipCidrRouteInfo(9)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/A/W/e/r/d/h 
  1136.          */
  1137.     case COLUMN_IPCIDRROUTEINFO:
  1138.         rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTEINFO;
  1139.         rc = ipCidrRouteInfo_undo_setup(rowreq_ctx);
  1140.         break;
  1141.         /*
  1142.          * ipCidrRouteNextHopAS(10)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  1143.          */
  1144.     case COLUMN_IPCIDRROUTENEXTHOPAS:
  1145.         rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTENEXTHOPAS;
  1146.         rc = ipCidrRouteNextHopAS_undo_setup(rowreq_ctx);
  1147.         break;
  1148.         /*
  1149.          * ipCidrRouteMetric1(11)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  1150.          */
  1151.     case COLUMN_IPCIDRROUTEMETRIC1:
  1152.         rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTEMETRIC1;
  1153.         rc = ipCidrRouteMetric1_undo_setup(rowreq_ctx);
  1154.         break;
  1155.         /*
  1156.          * ipCidrRouteMetric2(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  1157.          */
  1158.     case COLUMN_IPCIDRROUTEMETRIC2:
  1159.         rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTEMETRIC2;
  1160.         rc = ipCidrRouteMetric2_undo_setup(rowreq_ctx);
  1161.         break;
  1162.         /*
  1163.          * ipCidrRouteMetric3(13)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  1164.          */
  1165.     case COLUMN_IPCIDRROUTEMETRIC3:
  1166.         rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTEMETRIC3;
  1167.         rc = ipCidrRouteMetric3_undo_setup(rowreq_ctx);
  1168.         break;
  1169.         /*
  1170.          * ipCidrRouteMetric4(14)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  1171.          */
  1172.     case COLUMN_IPCIDRROUTEMETRIC4:
  1173.         rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTEMETRIC4;
  1174.         rc = ipCidrRouteMetric4_undo_setup(rowreq_ctx);
  1175.         break;
  1176.         /*
  1177.          * ipCidrRouteMetric5(15)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  1178.          */
  1179.     case COLUMN_IPCIDRROUTEMETRIC5:
  1180.         rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTEMETRIC5;
  1181.         rc = ipCidrRouteMetric5_undo_setup(rowreq_ctx);
  1182.         break;
  1183.         /*
  1184.          * ipCidrRouteStatus(16)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h 
  1185.          */
  1186.     case COLUMN_IPCIDRROUTESTATUS:
  1187.         rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTESTATUS;
  1188.         rc = ipCidrRouteStatus_undo_setup(rowreq_ctx);
  1189.         break;
  1190.     default:
  1191.         snmp_log(LOG_ERR,
  1192.                  "unknown column %d in _ipCidrRouteTable_undo_setup_columnn",
  1193.                  column);
  1194.         break;
  1195.     }
  1196.     return rc;
  1197. }                               /* _ipCidrRouteTable_undo_setup_column */
  1198. /**
  1199.  * @internal
  1200.  * undo setup
  1201.  */
  1202. int
  1203. _mfd_ipCidrRouteTable_undo_setup(netsnmp_mib_handler *handler,
  1204.                                  netsnmp_handler_registration *reginfo,
  1205.                                  netsnmp_agent_request_info *agtreq_info,
  1206.                                  netsnmp_request_info *requests)
  1207. {
  1208.     int             rc;
  1209.     ipCidrRouteTable_rowreq_ctx *rowreq_ctx =
  1210.         netsnmp_container_table_row_extract(requests);
  1211.     DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_undo_setup", "calledn"));
  1212.     netsnmp_assert(NULL != rowreq_ctx);
  1213.     /*
  1214.      * allocate undo context
  1215.      */
  1216.     rowreq_ctx->undo = ipCidrRouteTable_allocate_data();
  1217.     if (NULL == rowreq_ctx->undo) {
  1218.         /** msg already logged */
  1219.         netsnmp_request_set_error_all(requests,
  1220.                                       SNMP_ERR_RESOURCEUNAVAILABLE);
  1221.         return SNMP_ERR_NOERROR;
  1222.     }
  1223.     /*
  1224.      * row undo setup
  1225.      */
  1226.     rowreq_ctx->column_set_flags = 0;
  1227.     rc = ipCidrRouteTable_undo_setup(rowreq_ctx);
  1228.     if (MFD_SUCCESS != rc) {
  1229.         DEBUGMSGTL(("verbose:ipCidrRouteTable:mfd", "error %d from "
  1230.                     "ipCidrRouteTable_undo_setupn", rc));
  1231.         netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
  1232.     } else {
  1233.         /*
  1234.          * column undo setup
  1235.          */
  1236.         netsnmp_table_request_info *tri;
  1237.         for (; requests; requests = requests->next) {
  1238.             /*
  1239.              * set column data
  1240.              */
  1241.             tri = netsnmp_extract_table_info(requests);
  1242.             if (NULL == tri)
  1243.                 continue;
  1244.             rc = _ipCidrRouteTable_undo_setup_column(rowreq_ctx,
  1245.                                                      tri->colnum);
  1246.             if (MFD_SUCCESS != rc) {
  1247.                 DEBUGMSGTL(("verbose:ipCidrRouteTable:mfd",
  1248.                             "error %d from "
  1249.                             "ipCidrRouteTable_undo_setup_columnn", rc));
  1250.                 netsnmp_set_request_error(agtreq_info, requests,
  1251.                                           SNMP_VALIDATE_ERR(rc));
  1252.             }
  1253.         }                       /* for results */
  1254.     }
  1255.     return SNMP_ERR_NOERROR;
  1256. }                               /* _mfd_ipCidrRouteTable_undo_setup */
  1257. /**
  1258.  * @internal
  1259.  * undo setup
  1260.  */
  1261. int
  1262. _mfd_ipCidrRouteTable_undo_cleanup(netsnmp_mib_handler *handler,
  1263.                                    netsnmp_handler_registration *reginfo,
  1264.                                    netsnmp_agent_request_info *agtreq_info,
  1265.                                    netsnmp_request_info *requests)
  1266. {
  1267.     ipCidrRouteTable_rowreq_ctx *rowreq_ctx =
  1268.         netsnmp_container_table_row_extract(requests);
  1269.     int             rc;
  1270.     DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_undo_cleanup", "calledn"));
  1271.     /*
  1272.      * failed row create in early stages has no rowreq_ctx
  1273.      */
  1274.     if (NULL == rowreq_ctx)
  1275.         return MFD_SUCCESS;
  1276.     /*
  1277.      * call user cleanup
  1278.      */
  1279.     rc = ipCidrRouteTable_undo_cleanup(rowreq_ctx);
  1280.     if (MFD_SUCCESS != rc) {
  1281.         /*
  1282.          * nothing we can do about it but log it
  1283.          */
  1284.         DEBUGMSGTL(("verbose:ipCidrRouteTable:mfd", "error %d from "
  1285.                     "ipCidrRouteTable_undo_cleanupn", rc));
  1286.     }
  1287.     /*
  1288.      * release undo context, if needed
  1289.      */
  1290.     if (rowreq_ctx->undo) {
  1291.         ipCidrRouteTable_release_data(rowreq_ctx->undo);
  1292.         rowreq_ctx->undo = NULL;
  1293.     }
  1294.     /*
  1295.      * clear set flags
  1296.      */
  1297.     rowreq_ctx->column_set_flags = 0;
  1298.     return SNMP_ERR_NOERROR;
  1299. }                               /* _mfd_ipCidrRouteTable_undo_cleanup */
  1300. /*----------------------------------------------------------------------
  1301.  *
  1302.  * SET: Set values
  1303.  *
  1304.  *---------------------------------------------------------------------*/
  1305. /*
  1306.  * @internal
  1307.  * Set the value for a particular column
  1308.  */
  1309. NETSNMP_STATIC_INLINE int
  1310. _ipCidrRouteTable_set_column(ipCidrRouteTable_rowreq_ctx * rowreq_ctx,
  1311.                              netsnmp_variable_list * var, int column)
  1312. {
  1313.     int             rc = SNMPERR_SUCCESS;
  1314.     DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_set_column",
  1315.                 "calledn"));
  1316.     netsnmp_assert(NULL != rowreq_ctx);
  1317.     switch (column) {
  1318.         /*
  1319.          * ipCidrRouteIfIndex(5)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  1320.          */
  1321.     case COLUMN_IPCIDRROUTEIFINDEX:
  1322.         if (var->val_len != sizeof(long)) {
  1323.             rc = SNMP_ERR_WRONGLENGTH;
  1324.             snmp_log(LOG_ERR,
  1325.                      "varbind size of %d does not match expected size %dn",
  1326.                      var->val_len, sizeof(long));
  1327.             break;
  1328.         }
  1329.         rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTEIFINDEX;
  1330.         rc = ipCidrRouteIfIndex_set(rowreq_ctx,
  1331.                                     *((long *) var->val.string));
  1332.         break;
  1333.         /*
  1334.          * ipCidrRouteType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h 
  1335.          */
  1336.     case COLUMN_IPCIDRROUTETYPE:
  1337.         if (var->val_len != sizeof(u_long)) {
  1338.             rc = SNMP_ERR_WRONGLENGTH;
  1339.             snmp_log(LOG_ERR,
  1340.                      "varbind size of %d does not match expected size %dn",
  1341.                      var->val_len, sizeof(u_long));
  1342.             break;
  1343.         }
  1344.         rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTETYPE;
  1345.         rc = ipCidrRouteType_set(rowreq_ctx,
  1346.                                  *((u_long *) var->val.string));
  1347.         break;
  1348.         /*
  1349.          * ipCidrRouteInfo(9)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/A/W/e/r/d/h 
  1350.          */
  1351.     case COLUMN_IPCIDRROUTEINFO:
  1352.         rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTEINFO;
  1353.         rc = ipCidrRouteInfo_set(rowreq_ctx, (oid *) var->val.string,
  1354.                                  var->val_len);
  1355.         break;
  1356.         /*
  1357.          * ipCidrRouteNextHopAS(10)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  1358.          */
  1359.     case COLUMN_IPCIDRROUTENEXTHOPAS:
  1360.         if (var->val_len != sizeof(long)) {
  1361.             rc = SNMP_ERR_WRONGLENGTH;
  1362.             snmp_log(LOG_ERR,
  1363.                      "varbind size of %d does not match expected size %dn",
  1364.                      var->val_len, sizeof(long));
  1365.             break;
  1366.         }
  1367.         rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTENEXTHOPAS;
  1368.         rc = ipCidrRouteNextHopAS_set(rowreq_ctx,
  1369.                                       *((long *) var->val.string));
  1370.         break;
  1371.         /*
  1372.          * ipCidrRouteMetric1(11)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  1373.          */
  1374.     case COLUMN_IPCIDRROUTEMETRIC1:
  1375.         if (var->val_len != sizeof(long)) {
  1376.             rc = SNMP_ERR_WRONGLENGTH;
  1377.             snmp_log(LOG_ERR,
  1378.                      "varbind size of %d does not match expected size %dn",
  1379.                      var->val_len, sizeof(long));
  1380.             break;
  1381.         }
  1382.         rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTEMETRIC1;
  1383.         rc = ipCidrRouteMetric1_set(rowreq_ctx,
  1384.                                     *((long *) var->val.string));
  1385.         break;
  1386.         /*
  1387.          * ipCidrRouteMetric2(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  1388.          */
  1389.     case COLUMN_IPCIDRROUTEMETRIC2:
  1390.         if (var->val_len != sizeof(long)) {
  1391.             rc = SNMP_ERR_WRONGLENGTH;
  1392.             snmp_log(LOG_ERR,
  1393.                      "varbind size of %d does not match expected size %dn",
  1394.                      var->val_len, sizeof(long));
  1395.             break;
  1396.         }
  1397.         rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTEMETRIC2;
  1398.         rc = ipCidrRouteMetric2_set(rowreq_ctx,
  1399.                                     *((long *) var->val.string));
  1400.         break;
  1401.         /*
  1402.          * ipCidrRouteMetric3(13)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  1403.          */
  1404.     case COLUMN_IPCIDRROUTEMETRIC3:
  1405.         if (var->val_len != sizeof(long)) {
  1406.             rc = SNMP_ERR_WRONGLENGTH;
  1407.             snmp_log(LOG_ERR,
  1408.                      "varbind size of %d does not match expected size %dn",
  1409.                      var->val_len, sizeof(long));
  1410.             break;
  1411.         }
  1412.         rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTEMETRIC3;
  1413.         rc = ipCidrRouteMetric3_set(rowreq_ctx,
  1414.                                     *((long *) var->val.string));
  1415.         break;
  1416.         /*
  1417.          * ipCidrRouteMetric4(14)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  1418.          */
  1419.     case COLUMN_IPCIDRROUTEMETRIC4:
  1420.         if (var->val_len != sizeof(long)) {
  1421.             rc = SNMP_ERR_WRONGLENGTH;
  1422.             snmp_log(LOG_ERR,
  1423.                      "varbind size of %d does not match expected size %dn",
  1424.                      var->val_len, sizeof(long));
  1425.             break;
  1426.         }
  1427.         rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTEMETRIC4;
  1428.         rc = ipCidrRouteMetric4_set(rowreq_ctx,
  1429.                                     *((long *) var->val.string));
  1430.         break;
  1431.         /*
  1432.          * ipCidrRouteMetric5(15)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  1433.          */
  1434.     case COLUMN_IPCIDRROUTEMETRIC5:
  1435.         if (var->val_len != sizeof(long)) {
  1436.             rc = SNMP_ERR_WRONGLENGTH;
  1437.             snmp_log(LOG_ERR,
  1438.                      "varbind size of %d does not match expected size %dn",
  1439.                      var->val_len, sizeof(long));
  1440.             break;
  1441.         }
  1442.         rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTEMETRIC5;
  1443.         rc = ipCidrRouteMetric5_set(rowreq_ctx,
  1444.                                     *((long *) var->val.string));
  1445.         break;
  1446.         /*
  1447.          * ipCidrRouteStatus(16)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h 
  1448.          */
  1449.     case COLUMN_IPCIDRROUTESTATUS:
  1450.         if (var->val_len != sizeof(u_long)) {
  1451.             rc = SNMP_ERR_WRONGLENGTH;
  1452.             snmp_log(LOG_ERR,
  1453.                      "varbind size of %d does not match expected size %dn",
  1454.                      var->val_len, sizeof(u_long));
  1455.             break;
  1456.         }
  1457.         rowreq_ctx->column_set_flags |= FLAG_IPCIDRROUTESTATUS;
  1458.         rc = ipCidrRouteStatus_set(rowreq_ctx,
  1459.                                    *((u_long *) var->val.string));
  1460.         break;
  1461.     default:
  1462.         snmp_log(LOG_ERR,
  1463.                  "unknown column %d in _ipCidrRouteTable_set_columnn",
  1464.                  column);
  1465.         break;
  1466.     }
  1467.     return rc;
  1468. }                               /* _ipCidrRouteTable_set_column */
  1469. int
  1470. _mfd_ipCidrRouteTable_set_values(netsnmp_mib_handler *handler,
  1471.                                  netsnmp_handler_registration *reginfo,
  1472.                                  netsnmp_agent_request_info *agtreq_info,
  1473.                                  netsnmp_request_info *requests)
  1474. {
  1475.     ipCidrRouteTable_rowreq_ctx *rowreq_ctx =
  1476.         netsnmp_container_table_row_extract(requests);
  1477.     netsnmp_table_request_info *tri;
  1478.     int             rc = SNMP_ERR_NOERROR;
  1479.     DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_set_values", "calledn"));
  1480.     netsnmp_assert(NULL != rowreq_ctx);
  1481.     rowreq_ctx->column_set_flags = 0;
  1482.     for (; requests; requests = requests->next) {
  1483.         /*
  1484.          * set column data
  1485.          */
  1486.         tri = netsnmp_extract_table_info(requests);
  1487.         if (NULL == tri)
  1488.             continue;
  1489.         rc = _ipCidrRouteTable_set_column(rowreq_ctx,
  1490.                                           requests->requestvb,
  1491.                                           tri->colnum);
  1492.         if (MFD_SUCCESS != rc) {
  1493.             DEBUGMSGTL(("verbose:ipCidrRouteTable:mfd", "error %d from "
  1494.                         "ipCidrRouteTable_set_columnn", rc));
  1495.             netsnmp_set_request_error(agtreq_info, requests,
  1496.                                       SNMP_VALIDATE_ERR(rc));
  1497.         }
  1498.     }                           /* for results */
  1499.     return SNMP_ERR_NOERROR;
  1500. }                               /* _mfd_ipCidrRouteTable_set_values */
  1501. /*----------------------------------------------------------------------
  1502.  *
  1503.  * SET: commit
  1504.  *
  1505.  *---------------------------------------------------------------------*/
  1506. /**
  1507.  * @internal
  1508.  * commit the values
  1509.  */
  1510. int
  1511. _mfd_ipCidrRouteTable_commit(netsnmp_mib_handler *handler,
  1512.                              netsnmp_handler_registration *reginfo,
  1513.                              netsnmp_agent_request_info *agtreq_info,
  1514.                              netsnmp_request_info *requests)
  1515. {
  1516.     int             rc;
  1517.     ipCidrRouteTable_rowreq_ctx *rowreq_ctx =
  1518.         netsnmp_container_table_row_extract(requests);
  1519.     DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_commit",
  1520.                 "calledn"));
  1521.     netsnmp_assert(NULL != rowreq_ctx);
  1522.     rc = ipCidrRouteTable_commit(rowreq_ctx);
  1523.     if (MFD_SUCCESS != rc) {
  1524.         DEBUGMSGTL(("verbose:ipCidrRouteTable:mfd", "error %d from "
  1525.                     "ipCidrRouteTable_commitn", rc));
  1526.         netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
  1527.     }
  1528.     return SNMP_ERR_NOERROR;
  1529. }
  1530. int
  1531. _mfd_ipCidrRouteTable_undo_commit(netsnmp_mib_handler *handler,
  1532.                                   netsnmp_handler_registration *reginfo,
  1533.                                   netsnmp_agent_request_info *agtreq_info,
  1534.                                   netsnmp_request_info *requests)
  1535. {
  1536.     int             rc;
  1537.     ipCidrRouteTable_rowreq_ctx *rowreq_ctx =
  1538.         netsnmp_container_table_row_extract(requests);
  1539.     DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_undo_commit", "calledn"));
  1540.     netsnmp_assert(NULL != rowreq_ctx);
  1541.     rc = ipCidrRouteTable_undo_commit(rowreq_ctx);
  1542.     if (MFD_SUCCESS != rc) {
  1543.         /*
  1544.          * nothing we can do about it but log it
  1545.          */
  1546.         DEBUGMSGTL(("verbose:ipCidrRouteTable:mfd", "error %d from "
  1547.                     "ipCidrRouteTable_undo_commitn", rc));
  1548.     }
  1549.     return SNMP_ERR_NOERROR;
  1550. }                               /* _mfd_ipCidrRouteTable_commit */
  1551. /*----------------------------------------------------------------------
  1552.  *
  1553.  * SET: Undo
  1554.  *
  1555.  *---------------------------------------------------------------------*/
  1556. /**
  1557.  * @internal
  1558.  * undo the value for a particular column
  1559.  */
  1560. NETSNMP_STATIC_INLINE int
  1561. _ipCidrRouteTable_undo_column(ipCidrRouteTable_rowreq_ctx * rowreq_ctx,
  1562.                               netsnmp_variable_list * var, int column)
  1563. {
  1564.     int             rc = SNMPERR_SUCCESS;
  1565.     DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_undo_column",
  1566.                 "calledn"));
  1567.     netsnmp_assert(NULL != rowreq_ctx);
  1568.     switch (column) {
  1569.         /*
  1570.          * ipCidrRouteIfIndex(5)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  1571.          */
  1572.     case COLUMN_IPCIDRROUTEIFINDEX:
  1573.         rc = ipCidrRouteIfIndex_undo(rowreq_ctx);
  1574.         break;
  1575.         /*
  1576.          * ipCidrRouteType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h 
  1577.          */
  1578.     case COLUMN_IPCIDRROUTETYPE:
  1579.         rc = ipCidrRouteType_undo(rowreq_ctx);
  1580.         break;
  1581.         /*
  1582.          * ipCidrRouteInfo(9)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/A/W/e/r/d/h 
  1583.          */
  1584.     case COLUMN_IPCIDRROUTEINFO:
  1585.         rc = ipCidrRouteInfo_undo(rowreq_ctx);
  1586.         break;
  1587.         /*
  1588.          * ipCidrRouteNextHopAS(10)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  1589.          */
  1590.     case COLUMN_IPCIDRROUTENEXTHOPAS:
  1591.         rc = ipCidrRouteNextHopAS_undo(rowreq_ctx);
  1592.         break;
  1593.         /*
  1594.          * ipCidrRouteMetric1(11)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  1595.          */
  1596.     case COLUMN_IPCIDRROUTEMETRIC1:
  1597.         rc = ipCidrRouteMetric1_undo(rowreq_ctx);
  1598.         break;
  1599.         /*
  1600.          * ipCidrRouteMetric2(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  1601.          */
  1602.     case COLUMN_IPCIDRROUTEMETRIC2:
  1603.         rc = ipCidrRouteMetric2_undo(rowreq_ctx);
  1604.         break;
  1605.         /*
  1606.          * ipCidrRouteMetric3(13)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  1607.          */
  1608.     case COLUMN_IPCIDRROUTEMETRIC3:
  1609.         rc = ipCidrRouteMetric3_undo(rowreq_ctx);
  1610.         break;
  1611.         /*
  1612.          * ipCidrRouteMetric4(14)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  1613.          */
  1614.     case COLUMN_IPCIDRROUTEMETRIC4:
  1615.         rc = ipCidrRouteMetric4_undo(rowreq_ctx);
  1616.         break;
  1617.         /*
  1618.          * ipCidrRouteMetric5(15)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h 
  1619.          */
  1620.     case COLUMN_IPCIDRROUTEMETRIC5:
  1621.         rc = ipCidrRouteMetric5_undo(rowreq_ctx);
  1622.         break;
  1623.         /*
  1624.          * ipCidrRouteStatus(16)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h 
  1625.          */
  1626.     case COLUMN_IPCIDRROUTESTATUS:
  1627.         rc = ipCidrRouteStatus_undo(rowreq_ctx);
  1628.         break;
  1629.     default:
  1630.         snmp_log(LOG_ERR,
  1631.                  "unknown column %d in _ipCidrRouteTable_undo_columnn",
  1632.                  column);
  1633.         break;
  1634.     }
  1635.     return rc;
  1636. }                               /* _ipCidrRouteTable_undo_column */
  1637. int
  1638. _mfd_ipCidrRouteTable_undo_values(netsnmp_mib_handler *handler,
  1639.                                   netsnmp_handler_registration *reginfo,
  1640.                                   netsnmp_agent_request_info *agtreq_info,
  1641.                                   netsnmp_request_info *requests)
  1642. {
  1643.     int             rc;
  1644.     ipCidrRouteTable_rowreq_ctx *rowreq_ctx =
  1645.         netsnmp_container_table_row_extract(requests);
  1646.     netsnmp_table_request_info *tri;
  1647.     DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_undo_values", "calledn"));
  1648.     netsnmp_assert(NULL != rowreq_ctx);
  1649.     for (; requests; requests = requests->next) {
  1650.         /*
  1651.          * set column data
  1652.          */
  1653.         tri = netsnmp_extract_table_info(requests);
  1654.         if (NULL == tri)
  1655.             continue;
  1656.         rc = _ipCidrRouteTable_undo_column(rowreq_ctx, requests->requestvb,
  1657.                                            tri->colnum);
  1658.         if (MFD_SUCCESS != rc) {
  1659.             /*
  1660.              * nothing we can do about it but log it
  1661.              */
  1662.             DEBUGMSGTL(("verbose:ipCidrRouteTable:mfd", "error %d from "
  1663.                         "ipCidrRouteTable_undo_columnn", rc));
  1664.         }
  1665.     }                           /* for results */
  1666.     return SNMP_ERR_NOERROR;
  1667. }                               /* _mfd_ipCidrRouteTable_undo_values */
  1668. /***********************************************************************
  1669.  *
  1670.  * DATA ACCESS
  1671.  *
  1672.  ***********************************************************************/
  1673. /**
  1674.  * @internal
  1675.  */
  1676. static int
  1677. _cache_load(netsnmp_cache * cache, void *vmagic)
  1678. {
  1679.     DEBUGMSGTL(("internal:ipCidrRouteTable:_cache_load", "calledn"));
  1680.     if ((NULL == cache) || (NULL == cache->magic)) {
  1681.         snmp_log(LOG_ERR,
  1682.                  "invalid cache for ipCidrRouteTable_cache_loadn");
  1683.         return -1;
  1684.     }
  1685.     /** should only be called for an invalid or expired cache */
  1686.     netsnmp_assert((0 == cache->valid) || (1 == cache->expired));
  1687.     /*
  1688.      * call user code
  1689.      */
  1690.     return ipCidrRouteTable_cache_load((netsnmp_container *) cache->magic);
  1691. }                               /* _cache_load */
  1692. /**
  1693.  * @internal
  1694.  */
  1695. static void
  1696. _cache_item_free(ipCidrRouteTable_rowreq_ctx * rowreq_ctx, void *context)
  1697. {
  1698.     DEBUGMSGTL(("internal:ipCidrRouteTable:_cache_item_free", "calledn"));
  1699.     if (NULL == rowreq_ctx)
  1700.         return;
  1701.     ipCidrRouteTable_release_rowreq_ctx(rowreq_ctx);
  1702. }                               /* _cache_item_free */
  1703. /**
  1704.  * @internal
  1705.  */
  1706. static void
  1707. _cache_free(netsnmp_cache * cache, void *magic)
  1708. {
  1709.     netsnmp_container *container;
  1710.     DEBUGMSGTL(("internal:ipCidrRouteTable:_cache_free", "calledn"));
  1711.     if ((NULL == cache) || (NULL == cache->magic)) {
  1712.         snmp_log(LOG_ERR,
  1713.                  "invalid cache in ipCidrRouteTable_cache_freen");
  1714.         return;
  1715.     }
  1716.     container = (netsnmp_container *) cache->magic;
  1717.     /*
  1718.      * call user code
  1719.      */
  1720.     ipCidrRouteTable_cache_free(container);
  1721.     /*
  1722.      * free all items. inefficient, but easy.
  1723.      */
  1724.     CONTAINER_CLEAR(container,
  1725.                     (netsnmp_container_obj_func *) _cache_item_free, NULL);
  1726. }                               /* _cache_free */
  1727. /**
  1728.  * @internal
  1729.  * initialize the iterator container with functions or wrappers
  1730.  */
  1731. void
  1732. _ipCidrRouteTable_container_init(ipCidrRouteTable_interface_ctx * if_ctx)
  1733. {
  1734.     DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_container_init", "calledn"));
  1735.     /*
  1736.      * set up the cache
  1737.      */
  1738.     if_ctx->cache = netsnmp_cache_create(30,    /* timeout in seconds */
  1739.                                          _cache_load, _cache_free,
  1740.                                          ipCidrRouteTable_oid,
  1741.                                          ipCidrRouteTable_oid_size);
  1742.     if (NULL == if_ctx->cache) {
  1743.         snmp_log(LOG_ERR, "error creating cache for ipCidrRouteTablen");
  1744.         return;
  1745.     }
  1746.     if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET;
  1747.     ipCidrRouteTable_container_init(&if_ctx->container, if_ctx->cache);
  1748.     if (NULL == if_ctx->container)
  1749.         if_ctx->container =
  1750.             netsnmp_container_find("ipCidrRouteTable:table_container");
  1751.     if (NULL == if_ctx->container) {
  1752.         snmp_log(LOG_ERR, "error creating container in "
  1753.                  "ipCidrRouteTable_container_initn");
  1754.         return;
  1755.     }
  1756.     if_ctx->cache->magic = (void *) if_ctx->container;
  1757. }                               /* _ipCidrRouteTable_container_init */