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

SNMP编程

开发平台:

Unix_Linux

  1. /*
  2.  * Note: this file originally auto-generated by mib2c using
  3.  *        : mib2c.iterate_access.conf$
  4.  */
  5. #include <net-snmp/net-snmp-config.h>
  6. #include "route_headers.h"
  7. #include <net-snmp/net-snmp-includes.h>
  8. #include <net-snmp/agent/net-snmp-agent-includes.h>
  9. #include "ipCidrRouteTable.h"
  10. #include "ipCidrRouteTable_checkfns.h"
  11. #include "ipCidrRouteTable_access.h"
  12. #include "var_route.h"
  13. static netsnmp_oid_stash_node *undoStorage;
  14. struct undoInfo {
  15.     void           *ptr;
  16.     size_t          len;
  17. };
  18. void
  19. free_undoInfo(void *vp)
  20. {
  21.     struct undoInfo *ui = (struct undoInfo *) vp;
  22.     if (!ui)
  23.         return;
  24.     SNMP_FREE(ui->ptr);
  25.     SNMP_FREE(ui);
  26. }
  27. /** Initialize the ipCidrRouteTable table by defining its contents and how it's structured */
  28. void
  29. initialize_table_ipCidrRouteTable(void)
  30. {
  31.     static oid      ipCidrRouteTable_oid[] =
  32.         { 1, 3, 6, 1, 2, 1, 4, 24, 4 };
  33.     netsnmp_table_registration_info *table_info;
  34.     netsnmp_handler_registration *my_handler;
  35.     netsnmp_iterator_info *iinfo;
  36.     /** create the table registration information structures */
  37.     table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
  38.     iinfo = SNMP_MALLOC_TYPEDEF(netsnmp_iterator_info);
  39.     /** if your table is read only, it's easiest to change the
  40.         HANDLER_CAN_RWRITE definition below to HANDLER_CAN_RONLY */
  41.     my_handler = netsnmp_create_handler_registration("ipCidrRouteTable",
  42.                                                      ipCidrRouteTable_handler,
  43.                                                      ipCidrRouteTable_oid,
  44.                                                      OID_LENGTH
  45.                                                      (ipCidrRouteTable_oid),
  46.                                                      HANDLER_CAN_RWRITE);
  47.     if (!my_handler || !table_info || !iinfo) {
  48.         snmp_log(LOG_ERR,
  49.                  "malloc failed in initialize_table_ipCidrRouteTable");
  50.         return; /** Serious error. */
  51.     }
  52.     /***************************************************
  53.      * Setting up the table's definition
  54.      */
  55.     netsnmp_table_helper_add_indexes(table_info, ASN_IPADDRESS,
  56.                                                  /** index: ipCidrRouteDest */
  57.                                      ASN_IPADDRESS,
  58.                                                  /** index: ipCidrRouteMask */
  59.                                      ASN_INTEGER,
  60.                                                /** index: ipCidrRouteTos */
  61.                                      ASN_IPADDRESS,
  62.                                                  /** index: ipCidrRouteNextHop */
  63.                                      0);
  64.     /** Define the minimum and maximum accessible columns.  This
  65.         optimizes retrival. */
  66.     table_info->min_column = 1;
  67.     table_info->max_column = 16;
  68.     /** iterator access routines */
  69.     iinfo->get_first_data_point = ipCidrRouteTable_get_first_data_point;
  70.     iinfo->get_next_data_point = ipCidrRouteTable_get_next_data_point;
  71.     /** you may wish to set these as well */
  72. #ifdef MAYBE_USE_THESE
  73.     iinfo->make_data_context = ipCidrRouteTable_context_convert_function;
  74.     iinfo->free_data_context = ipCidrRouteTable_data_free;
  75.     /** pick *only* one of these if you use them */
  76.     iinfo->free_loop_context = ipCidrRouteTable_loop_free;
  77.     iinfo->free_loop_context_at_end = ipCidrRouteTable_loop_free;
  78. #endif
  79.     /** tie the two structures together */
  80.     iinfo->table_reginfo = table_info;
  81.     /***************************************************
  82.      * registering the table with the master agent
  83.      */
  84.     DEBUGMSGTL(("initialize_table_ipCidrRouteTable",
  85.                 "Registering table ipCidrRouteTable as a table iteratorn"));
  86.     netsnmp_register_table_iterator(my_handler, iinfo);
  87. }
  88. /** Initializes the ipCidrRouteTable module */
  89. void
  90. init_ipCidrRouteTable(void)
  91. {
  92.   /** here we initialize all the tables we're planning on supporting */
  93.     initialize_table_ipCidrRouteTable();
  94. }
  95. /* globals */
  96. static size_t rtsize;
  97. static RTENTRY **rthead;
  98. netsnmp_variable_list *
  99. ipCidrRouteTable_set_indexes(RTENTRY *ourroute,
  100.                              netsnmp_variable_list *put_index_data) {
  101.     netsnmp_variable_list *vptr;
  102.     /** ipCidrRouteDest */
  103.     vptr = put_index_data;
  104.     snmp_set_var_value(vptr, (u_char *) &((struct sockaddr_in *) (&ourroute->rt_dst))->sin_addr.s_addr,
  105.                        sizeof(((struct sockaddr_in *) (&ourroute->rt_dst))->sin_addr));
  106.     /** ipCidrRouteMask */
  107.     vptr = vptr->next_variable;
  108.     snmp_set_var_value(vptr, (u_char *) &((struct sockaddr_in *) (&ourroute->rt_genmask))->sin_addr.s_addr,
  109.                        sizeof(((struct sockaddr_in *) (&ourroute->rt_genmask))->sin_addr));
  110.     /** ipCidrRouteTos */
  111.     vptr = vptr->next_variable;
  112.     snmp_set_var_value(vptr, (u_char *) &ourroute->rt_tos,
  113.                        sizeof(ourroute->rt_tos));
  114.     vptr = vptr->next_variable;
  115.     /** ipCidrRouteNextHop */
  116.     snmp_set_var_value(vptr,
  117.                        (u_char *) &((struct sockaddr_in *) (&ourroute->rt_gateway))->sin_addr.s_addr,
  118.                        sizeof(((struct sockaddr_in *) (&ourroute->rt_gateway))->sin_addr));
  119.     return put_index_data;
  120. }
  121. /** returns the first data point within the ipCidrRouteTable table data.
  122.     Set the my_loop_context variable to the first data point structure
  123.     of your choice (from which you can find the next one).  This could
  124.     be anything from the first node in a linked list, to an integer
  125.     pointer containing the beginning of an array variable.
  126.     Set the my_data_context variable to something to be returned to
  127.     you later that will provide you with the data to return in a given
  128.     row.  This could be the same pointer as what my_loop_context is
  129.     set to, or something different.
  130.     The put_index_data variable contains a list of snmp variable
  131.     bindings, one for each index in your table.  Set the values of
  132.     each appropriately according to the data matching the first row
  133.     and return the put_index_data variable at the end of the function.
  134. */
  135. netsnmp_variable_list *
  136. ipCidrRouteTable_get_first_data_point(void **my_loop_context,
  137.                                       void **my_data_context,
  138.                                       netsnmp_variable_list *
  139.                                       put_index_data,
  140.                                       netsnmp_iterator_info *mydata)
  141. {
  142.     int *position;
  143.     /* we could do this with a file-static variable, but for learning
  144.        purposes we'll use memory allocation to demonstrate simplistic
  145.        freeing of a loop_context */
  146.     position = malloc(sizeof(position));
  147.     if (!position)
  148.         return NULL;
  149.     /* read the routing table into the route array. This function is
  150.        defined in var_route.c, but is sorted incorrectly for this
  151.        table. By using a table_iterator we don't do any sorting
  152.        ourselves and the table_iterator handles it all for us, so we
  153.        don't resort with different criteria. */
  154.     rthead = netsnmp_get_routes(&rtsize);
  155.     if (!rthead) {
  156.         snmp_log(LOG_ERR,"ipCidrRouteTable: failed to get routesn");
  157.         free(position);
  158.         return NULL;
  159.     }
  160.     /* We use the positinonal count as our loop context */
  161.     *position = 0;
  162.     *my_loop_context = position;
  163.     /* our data context is the individual array element, in this case
  164.        it's the first. */
  165.     *my_data_context = rthead[*position];
  166.     /* now, save the index data into the passed in (linked list) pointer */
  167.     return ipCidrRouteTable_set_indexes(rthead[*position], put_index_data);
  168. }
  169. /** functionally the same as ipCidrRouteTable_get_first_data_point, but
  170.    my_loop_context has already been set to a previous value and should
  171.    be updated to the next in the list.  For example, if it was a
  172.    linked list, you might want to cast it and the return
  173.    my_loop_context->next.  The my_data_context pointer should be set
  174.    to something you need later and the indexes in put_index_data
  175.    updated again. */
  176. netsnmp_variable_list *
  177. ipCidrRouteTable_get_next_data_point(void **my_loop_context,
  178.                                      void **my_data_context,
  179.                                      netsnmp_variable_list *
  180.                                      put_index_data,
  181.                                      netsnmp_iterator_info *mydata)
  182. {
  183.     int *position = (int *) *my_loop_context;
  184.     /* make sure we were called correctly */
  185.     if (!position)
  186.         return NULL;
  187.     
  188.     /* go to the next route in the list */
  189.     (*position)++;
  190.     /* Are we beyond the end? */
  191.     if (*position >= rtsize) {
  192.         /* End of routes.  stop here by returning NULL */
  193.         SNMP_FREE(position);
  194.         *my_loop_context = NULL;
  195.         *my_data_context = NULL;
  196.         return NULL;
  197.     }
  198.     /* our data context is the individual array element, in this case
  199.        it's the first. */
  200.     *my_data_context = rthead[*position];
  201.     /* now, save the index data into the passed in (linked list) pointer */
  202.     return ipCidrRouteTable_set_indexes(rthead[*position], put_index_data);
  203. }
  204. /** handles requests for the ipCidrRouteTable table, if anything else
  205.    needs to be done */
  206. int
  207. ipCidrRouteTable_handler(netsnmp_mib_handler *handler,
  208.                          netsnmp_handler_registration *reginfo,
  209.                          netsnmp_agent_request_info *reqinfo,
  210.                          netsnmp_request_info *requests)
  211. {
  212.     netsnmp_request_info *request;
  213.     netsnmp_table_request_info *table_info;
  214.     netsnmp_variable_list *var;
  215.     void           *data_context;
  216.     oid            *suffix;
  217.     size_t          suffix_len;
  218.     /** column and row index encoded portion */
  219.     suffix = requests->requestvb->name + reginfo->rootoid_len + 1;
  220.     suffix_len = requests->requestvb->name_length -
  221.         (reginfo->rootoid_len + 1);
  222.     for (request = requests; request; request = request->next) {
  223.         var = request->requestvb;
  224.         if (request->processed != 0)
  225.             continue;
  226.         data_context = netsnmp_extract_iterator_context(request);
  227.         if (data_context == NULL) {
  228.             if (reqinfo->mode == MODE_GET) {
  229.                 netsnmp_set_request_error(reqinfo, request,
  230.                                           SNMP_NOSUCHINSTANCE);
  231.                 continue;
  232.             }
  233.             /** XXX: no row existed, if you support creation and this is a
  234.                set, start dealing with it here, else continue */
  235.         }
  236.         /** extracts the information about the table from the request */
  237.         table_info = netsnmp_extract_table_info(request);
  238.         /** table_info->colnum contains the column number requested */
  239.         /** table_info->indexes contains a linked list of snmp variable
  240.            bindings for the indexes of the table.  Values in the list
  241.            have been set corresponding to the indexes of the
  242.            request */
  243.         if (table_info == NULL) {
  244.             continue;
  245.         }
  246.         switch (reqinfo->mode) {
  247.         case MODE_GET:
  248.             switch (table_info->colnum) {
  249.             case COLUMN_IPCIDRROUTEDEST:
  250.                 {
  251.                     u_long         *retval;
  252.                     size_t          retval_len = 0;
  253.                     retval =
  254.                         get_ipCidrRouteDest(data_context, &retval_len);
  255.                     snmp_set_var_typed_value(var, ASN_IPADDRESS,
  256.                                              (const u_char *) retval,
  257.                                              retval_len);
  258.                 }
  259.                 break;
  260.             case COLUMN_IPCIDRROUTEMASK:
  261.                 {
  262.                     u_long         *retval;
  263.                     size_t          retval_len = 0;
  264.                     retval =
  265.                         get_ipCidrRouteMask(data_context, &retval_len);
  266.                     snmp_set_var_typed_value(var, ASN_IPADDRESS,
  267.                                              (const u_char *) retval,
  268.                                              retval_len);
  269.                 }
  270.                 break;
  271.             case COLUMN_IPCIDRROUTETOS:
  272.                 {
  273.                     long           *retval;
  274.                     size_t          retval_len = 0;
  275.                     retval = get_ipCidrRouteTos(data_context, &retval_len);
  276.                     snmp_set_var_typed_value(var, ASN_INTEGER,
  277.                                              (const u_char *) retval,
  278.                                              retval_len);
  279.                 }
  280.                 break;
  281.             case COLUMN_IPCIDRROUTENEXTHOP:
  282.                 {
  283.                     u_long         *retval;
  284.                     size_t          retval_len = 0;
  285.                     retval =
  286.                         get_ipCidrRouteNextHop(data_context, &retval_len);
  287.                     snmp_set_var_typed_value(var, ASN_IPADDRESS,
  288.                                              (const u_char *) retval,
  289.                                              retval_len);
  290.                 }
  291.                 break;
  292.             case COLUMN_IPCIDRROUTEIFINDEX:
  293.                 {
  294.                     long           *retval;
  295.                     size_t          retval_len = 0;
  296.                     retval =
  297.                         get_ipCidrRouteIfIndex(data_context, &retval_len);
  298.                     snmp_set_var_typed_value(var, ASN_INTEGER,
  299.                                              (const u_char *) retval,
  300.                                              retval_len);
  301.                 }
  302.                 break;
  303.             case COLUMN_IPCIDRROUTETYPE:
  304.                 {
  305.                     long           *retval;
  306.                     size_t          retval_len = 0;
  307.                     retval =
  308.                         get_ipCidrRouteType(data_context, &retval_len);
  309.                     snmp_set_var_typed_value(var, ASN_INTEGER,
  310.                                              (const u_char *) retval,
  311.                                              retval_len);
  312.                 }
  313.                 break;
  314.             case COLUMN_IPCIDRROUTEPROTO:
  315.                 {
  316.                     long           *retval;
  317.                     size_t          retval_len = 0;
  318.                     retval =
  319.                         get_ipCidrRouteProto(data_context, &retval_len);
  320.                     snmp_set_var_typed_value(var, ASN_INTEGER,
  321.                                              (const u_char *) retval,
  322.                                              retval_len);
  323.                 }
  324.                 break;
  325.             case COLUMN_IPCIDRROUTEAGE:
  326.                 {
  327.                     long           *retval;
  328.                     size_t          retval_len = 0;
  329.                     retval = get_ipCidrRouteAge(data_context, &retval_len);
  330.                     snmp_set_var_typed_value(var, ASN_INTEGER,
  331.                                              (const u_char *) retval,
  332.                                              retval_len);
  333.                 }
  334.                 break;
  335.             case COLUMN_IPCIDRROUTEINFO:
  336.                 {
  337.                     oid            *retval;
  338.                     size_t          retval_len = 0;
  339.                     retval =
  340.                         get_ipCidrRouteInfo(data_context, &retval_len);
  341.                     snmp_set_var_typed_value(var, ASN_OBJECT_ID,
  342.                                              (const u_char *) retval,
  343.                                              retval_len);
  344.                 }
  345.                 break;
  346.             case COLUMN_IPCIDRROUTENEXTHOPAS:
  347.                 {
  348.                     long           *retval;
  349.                     size_t          retval_len = 0;
  350.                     retval =
  351.                         get_ipCidrRouteNextHopAS(data_context,
  352.                                                  &retval_len);
  353.                     snmp_set_var_typed_value(var, ASN_INTEGER,
  354.                                              (const u_char *) retval,
  355.                                              retval_len);
  356.                 }
  357.                 break;
  358.             case COLUMN_IPCIDRROUTEMETRIC1:
  359.                 {
  360.                     long           *retval;
  361.                     size_t          retval_len = 0;
  362.                     retval =
  363.                         get_ipCidrRouteMetric1(data_context, &retval_len);
  364.                     snmp_set_var_typed_value(var, ASN_INTEGER,
  365.                                              (const u_char *) retval,
  366.                                              retval_len);
  367.                 }
  368.                 break;
  369.             case COLUMN_IPCIDRROUTEMETRIC2:
  370.                 {
  371.                     long           *retval;
  372.                     size_t          retval_len = 0;
  373.                     retval =
  374.                         get_ipCidrRouteMetric2(data_context, &retval_len);
  375.                     snmp_set_var_typed_value(var, ASN_INTEGER,
  376.                                              (const u_char *) retval,
  377.                                              retval_len);
  378.                 }
  379.                 break;
  380.             case COLUMN_IPCIDRROUTEMETRIC3:
  381.                 {
  382.                     long           *retval;
  383.                     size_t          retval_len = 0;
  384.                     retval =
  385.                         get_ipCidrRouteMetric3(data_context, &retval_len);
  386.                     snmp_set_var_typed_value(var, ASN_INTEGER,
  387.                                              (const u_char *) retval,
  388.                                              retval_len);
  389.                 }
  390.                 break;
  391.             case COLUMN_IPCIDRROUTEMETRIC4:
  392.                 {
  393.                     long           *retval;
  394.                     size_t          retval_len = 0;
  395.                     retval =
  396.                         get_ipCidrRouteMetric4(data_context, &retval_len);
  397.                     snmp_set_var_typed_value(var, ASN_INTEGER,
  398.                                              (const u_char *) retval,
  399.                                              retval_len);
  400.                 }
  401.                 break;
  402.             case COLUMN_IPCIDRROUTEMETRIC5:
  403.                 {
  404.                     long           *retval;
  405.                     size_t          retval_len = 0;
  406.                     retval =
  407.                         get_ipCidrRouteMetric5(data_context, &retval_len);
  408.                     snmp_set_var_typed_value(var, ASN_INTEGER,
  409.                                              (const u_char *) retval,
  410.                                              retval_len);
  411.                 }
  412.                 break;
  413.             case COLUMN_IPCIDRROUTESTATUS:
  414.                 {
  415.                     long           *retval;
  416.                     size_t          retval_len = 0;
  417.                     retval =
  418.                         get_ipCidrRouteStatus(data_context, &retval_len);
  419.                     snmp_set_var_typed_value(var, ASN_INTEGER,
  420.                                              (const u_char *) retval,
  421.                                              retval_len);
  422.                 }
  423.                 break;
  424.             default:
  425.                         /** We shouldn't get here */
  426.                 snmp_log(LOG_ERR,
  427.                          "problem encountered in ipCidrRouteTable_handler: unknown columnn");
  428.             }
  429.             break;
  430.         case MODE_SET_RESERVE1:
  431.                 /** mib2cXXX: clear out old undo info if we have any.  Remove if
  432.                    table_iterator becomes un-serialized */
  433.             netsnmp_oid_stash_free(&undoStorage, free_undoInfo);
  434.             switch (table_info->colnum) {
  435.             case COLUMN_IPCIDRROUTEIFINDEX:
  436.                 {
  437.                     int             ret =
  438.                         check_ipCidrRouteIfIndex(request->requestvb->type,
  439.                                                  (long *) request->
  440.                                                  requestvb->val.string,
  441.                                                  request->requestvb->
  442.                                                  val_len);
  443.                     if (ret != 0) {
  444.                         netsnmp_set_request_error(reqinfo, requests, ret);
  445.                     }
  446.                 }
  447.                 break;
  448.             case COLUMN_IPCIDRROUTETYPE:
  449.                 {
  450.                     int             ret =
  451.                         check_ipCidrRouteType(request->requestvb->type,
  452.                                               (long *) request->requestvb->
  453.                                               val.string,
  454.                                               request->requestvb->val_len);
  455.                     if (ret != 0) {
  456.                         netsnmp_set_request_error(reqinfo, requests, ret);
  457.                     }
  458.                 }
  459.                 break;
  460.             case COLUMN_IPCIDRROUTEINFO:
  461.                 {
  462.                     int             ret =
  463.                         check_ipCidrRouteInfo(request->requestvb->type,
  464.                                               (oid *) request->requestvb->
  465.                                               val.string,
  466.                                               request->requestvb->val_len);
  467.                     if (ret != 0) {
  468.                         netsnmp_set_request_error(reqinfo, requests, ret);
  469.                     }
  470.                 }
  471.                 break;
  472.             case COLUMN_IPCIDRROUTENEXTHOPAS:
  473.                 {
  474.                     int             ret =
  475.                         check_ipCidrRouteNextHopAS(request->requestvb->
  476.                                                    type,
  477.                                                    (long *) request->
  478.                                                    requestvb->val.string,
  479.                                                    request->requestvb->
  480.                                                    val_len);
  481.                     if (ret != 0) {
  482.                         netsnmp_set_request_error(reqinfo, requests, ret);
  483.                     }
  484.                 }
  485.                 break;
  486.             case COLUMN_IPCIDRROUTEMETRIC1:
  487.                 {
  488.                     int             ret =
  489.                         check_ipCidrRouteMetric1(request->requestvb->type,
  490.                                                  (long *) request->
  491.                                                  requestvb->val.string,
  492.                                                  request->requestvb->
  493.                                                  val_len);
  494.                     if (ret != 0) {
  495.                         netsnmp_set_request_error(reqinfo, requests, ret);
  496.                     }
  497.                 }
  498.                 break;
  499.             case COLUMN_IPCIDRROUTEMETRIC2:
  500.                 {
  501.                     int             ret =
  502.                         check_ipCidrRouteMetric2(request->requestvb->type,
  503.                                                  (long *) request->
  504.                                                  requestvb->val.string,
  505.                                                  request->requestvb->
  506.                                                  val_len);
  507.                     if (ret != 0) {
  508.                         netsnmp_set_request_error(reqinfo, requests, ret);
  509.                     }
  510.                 }
  511.                 break;
  512.             case COLUMN_IPCIDRROUTEMETRIC3:
  513.                 {
  514.                     int             ret =
  515.                         check_ipCidrRouteMetric3(request->requestvb->type,
  516.                                                  (long *) request->
  517.                                                  requestvb->val.string,
  518.                                                  request->requestvb->
  519.                                                  val_len);
  520.                     if (ret != 0) {
  521.                         netsnmp_set_request_error(reqinfo, requests, ret);
  522.                     }
  523.                 }
  524.                 break;
  525.             case COLUMN_IPCIDRROUTEMETRIC4:
  526.                 {
  527.                     int             ret =
  528.                         check_ipCidrRouteMetric4(request->requestvb->type,
  529.                                                  (long *) request->
  530.                                                  requestvb->val.string,
  531.                                                  request->requestvb->
  532.                                                  val_len);
  533.                     if (ret != 0) {
  534.                         netsnmp_set_request_error(reqinfo, requests, ret);
  535.                     }
  536.                 }
  537.                 break;
  538.             case COLUMN_IPCIDRROUTEMETRIC5:
  539.                 {
  540.                     int             ret =
  541.                         check_ipCidrRouteMetric5(request->requestvb->type,
  542.                                                  (long *) request->
  543.                                                  requestvb->val.string,
  544.                                                  request->requestvb->
  545.                                                  val_len);
  546.                     if (ret != 0) {
  547.                         netsnmp_set_request_error(reqinfo, requests, ret);
  548.                     }
  549.                 }
  550.                 break;
  551.             case COLUMN_IPCIDRROUTESTATUS:
  552.                 {
  553.                     int             ret =
  554.                         check_ipCidrRouteStatus(request->requestvb->type,
  555.                                                 (long *) request->
  556.                                                 requestvb->val.string,
  557.                                                 request->requestvb->
  558.                                                 val_len);
  559.                     if (ret != 0) {
  560.                         netsnmp_set_request_error(reqinfo, requests, ret);
  561.                     }
  562.                 }
  563.                 break;
  564.             default:
  565.                 netsnmp_set_request_error(reqinfo, requests,
  566.                                           SNMP_ERR_NOTWRITABLE);
  567.                 break;
  568.             }
  569.             break;
  570.         case MODE_SET_RESERVE2:
  571.                 /** save a variable copy */
  572.             switch (table_info->colnum) {
  573.             case COLUMN_IPCIDRROUTEIFINDEX:
  574.                 {
  575.                     long           *retval;
  576.                     size_t          retval_len = 0;
  577.                     struct undoInfo *ui;
  578.                     retval =
  579.                         get_ipCidrRouteIfIndex(data_context, &retval_len);
  580.                     if (retval) {
  581.                         ui = SNMP_MALLOC_STRUCT(undoInfo);
  582.                         ui->len = retval_len;
  583.                         memdup((u_char **) & ui->ptr,
  584.                                (u_char *) retval, ui->len);
  585.                         netsnmp_oid_stash_add_data(&undoStorage,
  586.                                                    suffix, suffix_len, ui);
  587.                     }
  588.                 }
  589.                 break;
  590.             case COLUMN_IPCIDRROUTETYPE:
  591.                 {
  592.                     long           *retval;
  593.                     size_t          retval_len = 0;
  594.                     struct undoInfo *ui;
  595.                     retval =
  596.                         get_ipCidrRouteType(data_context, &retval_len);
  597.                     if (retval) {
  598.                         ui = SNMP_MALLOC_STRUCT(undoInfo);
  599.                         ui->len = retval_len;
  600.                         memdup((u_char **) & ui->ptr,
  601.                                (u_char *) retval, ui->len);
  602.                         netsnmp_oid_stash_add_data(&undoStorage,
  603.                                                    suffix, suffix_len, ui);
  604.                     }
  605.                 }
  606.                 break;
  607.             case COLUMN_IPCIDRROUTEINFO:
  608.                 {
  609.                     oid            *retval;
  610.                     size_t          retval_len = 0;
  611.                     struct undoInfo *ui;
  612.                     retval =
  613.                         get_ipCidrRouteInfo(data_context, &retval_len);
  614.                     if (retval) {
  615.                         ui = SNMP_MALLOC_STRUCT(undoInfo);
  616.                         ui->len = retval_len;
  617.                         memdup((u_char **) & ui->ptr,
  618.                                (u_char *) retval, ui->len);
  619.                         netsnmp_oid_stash_add_data(&undoStorage,
  620.                                                    suffix, suffix_len, ui);
  621.                     }
  622.                 }
  623.                 break;
  624.             case COLUMN_IPCIDRROUTENEXTHOPAS:
  625.                 {
  626.                     long           *retval;
  627.                     size_t          retval_len = 0;
  628.                     struct undoInfo *ui;
  629.                     retval =
  630.                         get_ipCidrRouteNextHopAS(data_context,
  631.                                                  &retval_len);
  632.                     if (retval) {
  633.                         ui = SNMP_MALLOC_STRUCT(undoInfo);
  634.                         ui->len = retval_len;
  635.                         memdup((u_char **) & ui->ptr,
  636.                                (u_char *) retval, ui->len);
  637.                         netsnmp_oid_stash_add_data(&undoStorage,
  638.                                                    suffix, suffix_len, ui);
  639.                     }
  640.                 }
  641.                 break;
  642.             case COLUMN_IPCIDRROUTEMETRIC1:
  643.                 {
  644.                     long           *retval;
  645.                     size_t          retval_len = 0;
  646.                     struct undoInfo *ui;
  647.                     retval =
  648.                         get_ipCidrRouteMetric1(data_context, &retval_len);
  649.                     if (retval) {
  650.                         ui = SNMP_MALLOC_STRUCT(undoInfo);
  651.                         ui->len = retval_len;
  652.                         memdup((u_char **) & ui->ptr,
  653.                                (u_char *) retval, ui->len);
  654.                         netsnmp_oid_stash_add_data(&undoStorage,
  655.                                                    suffix, suffix_len, ui);
  656.                     }
  657.                 }
  658.                 break;
  659.             case COLUMN_IPCIDRROUTEMETRIC2:
  660.                 {
  661.                     long           *retval;
  662.                     size_t          retval_len = 0;
  663.                     struct undoInfo *ui;
  664.                     retval =
  665.                         get_ipCidrRouteMetric2(data_context, &retval_len);
  666.                     if (retval) {
  667.                         ui = SNMP_MALLOC_STRUCT(undoInfo);
  668.                         ui->len = retval_len;
  669.                         memdup((u_char **) & ui->ptr,
  670.                                (u_char *) retval, ui->len);
  671.                         netsnmp_oid_stash_add_data(&undoStorage,
  672.                                                    suffix, suffix_len, ui);
  673.                     }
  674.                 }
  675.                 break;
  676.             case COLUMN_IPCIDRROUTEMETRIC3:
  677.                 {
  678.                     long           *retval;
  679.                     size_t          retval_len = 0;
  680.                     struct undoInfo *ui;
  681.                     retval =
  682.                         get_ipCidrRouteMetric3(data_context, &retval_len);
  683.                     if (retval) {
  684.                         ui = SNMP_MALLOC_STRUCT(undoInfo);
  685.                         ui->len = retval_len;
  686.                         memdup((u_char **) & ui->ptr,
  687.                                (u_char *) retval, ui->len);
  688.                         netsnmp_oid_stash_add_data(&undoStorage,
  689.                                                    suffix, suffix_len, ui);
  690.                     }
  691.                 }
  692.                 break;
  693.             case COLUMN_IPCIDRROUTEMETRIC4:
  694.                 {
  695.                     long           *retval;
  696.                     size_t          retval_len = 0;
  697.                     struct undoInfo *ui;
  698.                     retval =
  699.                         get_ipCidrRouteMetric4(data_context, &retval_len);
  700.                     if (retval) {
  701.                         ui = SNMP_MALLOC_STRUCT(undoInfo);
  702.                         ui->len = retval_len;
  703.                         memdup((u_char **) & ui->ptr,
  704.                                (u_char *) retval, ui->len);
  705.                         netsnmp_oid_stash_add_data(&undoStorage,
  706.                                                    suffix, suffix_len, ui);
  707.                     }
  708.                 }
  709.                 break;
  710.             case COLUMN_IPCIDRROUTEMETRIC5:
  711.                 {
  712.                     long           *retval;
  713.                     size_t          retval_len = 0;
  714.                     struct undoInfo *ui;
  715.                     retval =
  716.                         get_ipCidrRouteMetric5(data_context, &retval_len);
  717.                     if (retval) {
  718.                         ui = SNMP_MALLOC_STRUCT(undoInfo);
  719.                         ui->len = retval_len;
  720.                         memdup((u_char **) & ui->ptr,
  721.                                (u_char *) retval, ui->len);
  722.                         netsnmp_oid_stash_add_data(&undoStorage,
  723.                                                    suffix, suffix_len, ui);
  724.                     }
  725.                 }
  726.                 break;
  727.             case COLUMN_IPCIDRROUTESTATUS:
  728.                 {
  729.                     long           *retval;
  730.                     size_t          retval_len = 0;
  731.                     struct undoInfo *ui;
  732.                     retval =
  733.                         get_ipCidrRouteStatus(data_context, &retval_len);
  734.                     if (retval) {
  735.                         ui = SNMP_MALLOC_STRUCT(undoInfo);
  736.                         ui->len = retval_len;
  737.                         memdup((u_char **) & ui->ptr,
  738.                                (u_char *) retval, ui->len);
  739.                         netsnmp_oid_stash_add_data(&undoStorage,
  740.                                                    suffix, suffix_len, ui);
  741.                     }
  742.                 }
  743.                 break;
  744.             }
  745.             break;
  746.         case MODE_SET_FREE:
  747.                 /** Forget undo data, if exists */
  748.             netsnmp_oid_stash_free(&undoStorage, free_undoInfo);
  749.             break;
  750.         case MODE_SET_ACTION:
  751.                 /** save a variable copy */
  752.             switch (table_info->colnum) {
  753.             case COLUMN_IPCIDRROUTEIFINDEX:
  754.                 {
  755.                     int             ret =
  756.                         set_ipCidrRouteIfIndex(data_context,
  757.                                                (long *) request->
  758.                                                requestvb->val.string,
  759.                                                request->requestvb->
  760.                                                val_len);
  761.                     if (ret) {
  762.                         netsnmp_set_request_error(reqinfo, requests, ret);
  763.                     }
  764.                 }
  765.                 break;
  766.             case COLUMN_IPCIDRROUTETYPE:
  767.                 {
  768.                     int             ret = set_ipCidrRouteType(data_context,
  769.                                                               (long *)
  770.                                                               request->
  771.                                                               requestvb->
  772.                                                               val.string,
  773.                                                               request->
  774.                                                               requestvb->
  775.                                                               val_len);
  776.                     if (ret) {
  777.                         netsnmp_set_request_error(reqinfo, requests, ret);
  778.                     }
  779.                 }
  780.                 break;
  781.             case COLUMN_IPCIDRROUTEINFO:
  782.                 {
  783.                     int             ret = set_ipCidrRouteInfo(data_context,
  784.                                                               (oid *)
  785.                                                               request->
  786.                                                               requestvb->
  787.                                                               val.string,
  788.                                                               request->
  789.                                                               requestvb->
  790.                                                               val_len);
  791.                     if (ret) {
  792.                         netsnmp_set_request_error(reqinfo, requests, ret);
  793.                     }
  794.                 }
  795.                 break;
  796.             case COLUMN_IPCIDRROUTENEXTHOPAS:
  797.                 {
  798.                     int             ret =
  799.                         set_ipCidrRouteNextHopAS(data_context,
  800.                                                  (long *) request->
  801.                                                  requestvb->val.string,
  802.                                                  request->requestvb->
  803.                                                  val_len);
  804.                     if (ret) {
  805.                         netsnmp_set_request_error(reqinfo, requests, ret);
  806.                     }
  807.                 }
  808.                 break;
  809.             case COLUMN_IPCIDRROUTEMETRIC1:
  810.                 {
  811.                     int             ret =
  812.                         set_ipCidrRouteMetric1(data_context,
  813.                                                (long *) request->
  814.                                                requestvb->val.string,
  815.                                                request->requestvb->
  816.                                                val_len);
  817.                     if (ret) {
  818.                         netsnmp_set_request_error(reqinfo, requests, ret);
  819.                     }
  820.                 }
  821.                 break;
  822.             case COLUMN_IPCIDRROUTEMETRIC2:
  823.                 {
  824.                     int             ret =
  825.                         set_ipCidrRouteMetric2(data_context,
  826.                                                (long *) request->
  827.                                                requestvb->val.string,
  828.                                                request->requestvb->
  829.                                                val_len);
  830.                     if (ret) {
  831.                         netsnmp_set_request_error(reqinfo, requests, ret);
  832.                     }
  833.                 }
  834.                 break;
  835.             case COLUMN_IPCIDRROUTEMETRIC3:
  836.                 {
  837.                     int             ret =
  838.                         set_ipCidrRouteMetric3(data_context,
  839.                                                (long *) request->
  840.                                                requestvb->val.string,
  841.                                                request->requestvb->
  842.                                                val_len);
  843.                     if (ret) {
  844.                         netsnmp_set_request_error(reqinfo, requests, ret);
  845.                     }
  846.                 }
  847.                 break;
  848.             case COLUMN_IPCIDRROUTEMETRIC4:
  849.                 {
  850.                     int             ret =
  851.                         set_ipCidrRouteMetric4(data_context,
  852.                                                (long *) request->
  853.                                                requestvb->val.string,
  854.                                                request->requestvb->
  855.                                                val_len);
  856.                     if (ret) {
  857.                         netsnmp_set_request_error(reqinfo, requests, ret);
  858.                     }
  859.                 }
  860.                 break;
  861.             case COLUMN_IPCIDRROUTEMETRIC5:
  862.                 {
  863.                     int             ret =
  864.                         set_ipCidrRouteMetric5(data_context,
  865.                                                (long *) request->
  866.                                                requestvb->val.string,
  867.                                                request->requestvb->
  868.                                                val_len);
  869.                     if (ret) {
  870.                         netsnmp_set_request_error(reqinfo, requests, ret);
  871.                     }
  872.                 }
  873.                 break;
  874.             case COLUMN_IPCIDRROUTESTATUS:
  875.                 {
  876.                     int             ret =
  877.                         set_ipCidrRouteStatus(data_context,
  878.                                               (long *) request->requestvb->
  879.                                               val.string,
  880.                                               request->requestvb->val_len);
  881.                     if (ret) {
  882.                         netsnmp_set_request_error(reqinfo, requests, ret);
  883.                     }
  884.                 }
  885.                 break;
  886.             }
  887.             break;
  888.         case MODE_SET_COMMIT:
  889.                 /** answers were all good.  Forget undo data */
  890.             netsnmp_oid_stash_free(&undoStorage, free_undoInfo);
  891.                 /** mib2cXXX: call commit hook */
  892.             break;
  893.         case MODE_SET_UNDO:
  894.                 /** save a variable copy */
  895.             switch (table_info->colnum) {
  896.             case COLUMN_IPCIDRROUTEIFINDEX:
  897.                 {
  898.                     int             retval;
  899.                     struct undoInfo *ui;
  900.                     ui = netsnmp_oid_stash_get_data(undoStorage,
  901.                                                     suffix, suffix_len);
  902.                     retval =
  903.                         set_ipCidrRouteIfIndex(data_context, ui->ptr,
  904.                                                ui->len);
  905.                     if (retval) {
  906.                         netsnmp_set_request_error(reqinfo, requests,
  907.                                                   SNMP_ERR_UNDOFAILED);
  908.                     }
  909.                 }
  910.                 break;
  911.             case COLUMN_IPCIDRROUTETYPE:
  912.                 {
  913.                     int             retval;
  914.                     struct undoInfo *ui;
  915.                     ui = netsnmp_oid_stash_get_data(undoStorage,
  916.                                                     suffix, suffix_len);
  917.                     retval =
  918.                         set_ipCidrRouteType(data_context, ui->ptr,
  919.                                             ui->len);
  920.                     if (retval) {
  921.                         netsnmp_set_request_error(reqinfo, requests,
  922.                                                   SNMP_ERR_UNDOFAILED);
  923.                     }
  924.                 }
  925.                 break;
  926.             case COLUMN_IPCIDRROUTEINFO:
  927.                 {
  928.                     int             retval;
  929.                     struct undoInfo *ui;
  930.                     ui = netsnmp_oid_stash_get_data(undoStorage,
  931.                                                     suffix, suffix_len);
  932.                     retval =
  933.                         set_ipCidrRouteInfo(data_context, ui->ptr,
  934.                                             ui->len);
  935.                     if (retval) {
  936.                         netsnmp_set_request_error(reqinfo, requests,
  937.                                                   SNMP_ERR_UNDOFAILED);
  938.                     }
  939.                 }
  940.                 break;
  941.             case COLUMN_IPCIDRROUTENEXTHOPAS:
  942.                 {
  943.                     int             retval;
  944.                     struct undoInfo *ui;
  945.                     ui = netsnmp_oid_stash_get_data(undoStorage,
  946.                                                     suffix, suffix_len);
  947.                     retval =
  948.                         set_ipCidrRouteNextHopAS(data_context, ui->ptr,
  949.                                                  ui->len);
  950.                     if (retval) {
  951.                         netsnmp_set_request_error(reqinfo, requests,
  952.                                                   SNMP_ERR_UNDOFAILED);
  953.                     }
  954.                 }
  955.                 break;
  956.             case COLUMN_IPCIDRROUTEMETRIC1:
  957.                 {
  958.                     int             retval;
  959.                     struct undoInfo *ui;
  960.                     ui = netsnmp_oid_stash_get_data(undoStorage,
  961.                                                     suffix, suffix_len);
  962.                     retval =
  963.                         set_ipCidrRouteMetric1(data_context, ui->ptr,
  964.                                                ui->len);
  965.                     if (retval) {
  966.                         netsnmp_set_request_error(reqinfo, requests,
  967.                                                   SNMP_ERR_UNDOFAILED);
  968.                     }
  969.                 }
  970.                 break;
  971.             case COLUMN_IPCIDRROUTEMETRIC2:
  972.                 {
  973.                     int             retval;
  974.                     struct undoInfo *ui;
  975.                     ui = netsnmp_oid_stash_get_data(undoStorage,
  976.                                                     suffix, suffix_len);
  977.                     retval =
  978.                         set_ipCidrRouteMetric2(data_context, ui->ptr,
  979.                                                ui->len);
  980.                     if (retval) {
  981.                         netsnmp_set_request_error(reqinfo, requests,
  982.                                                   SNMP_ERR_UNDOFAILED);
  983.                     }
  984.                 }
  985.                 break;
  986.             case COLUMN_IPCIDRROUTEMETRIC3:
  987.                 {
  988.                     int             retval;
  989.                     struct undoInfo *ui;
  990.                     ui = netsnmp_oid_stash_get_data(undoStorage,
  991.                                                     suffix, suffix_len);
  992.                     retval =
  993.                         set_ipCidrRouteMetric3(data_context, ui->ptr,
  994.                                                ui->len);
  995.                     if (retval) {
  996.                         netsnmp_set_request_error(reqinfo, requests,
  997.                                                   SNMP_ERR_UNDOFAILED);
  998.                     }
  999.                 }
  1000.                 break;
  1001.             case COLUMN_IPCIDRROUTEMETRIC4:
  1002.                 {
  1003.                     int             retval;
  1004.                     struct undoInfo *ui;
  1005.                     ui = netsnmp_oid_stash_get_data(undoStorage,
  1006.                                                     suffix, suffix_len);
  1007.                     retval =
  1008.                         set_ipCidrRouteMetric4(data_context, ui->ptr,
  1009.                                                ui->len);
  1010.                     if (retval) {
  1011.                         netsnmp_set_request_error(reqinfo, requests,
  1012.                                                   SNMP_ERR_UNDOFAILED);
  1013.                     }
  1014.                 }
  1015.                 break;
  1016.             case COLUMN_IPCIDRROUTEMETRIC5:
  1017.                 {
  1018.                     int             retval;
  1019.                     struct undoInfo *ui;
  1020.                     ui = netsnmp_oid_stash_get_data(undoStorage,
  1021.                                                     suffix, suffix_len);
  1022.                     retval =
  1023.                         set_ipCidrRouteMetric5(data_context, ui->ptr,
  1024.                                                ui->len);
  1025.                     if (retval) {
  1026.                         netsnmp_set_request_error(reqinfo, requests,
  1027.                                                   SNMP_ERR_UNDOFAILED);
  1028.                     }
  1029.                 }
  1030.                 break;
  1031.             case COLUMN_IPCIDRROUTESTATUS:
  1032.                 {
  1033.                     int             retval;
  1034.                     struct undoInfo *ui;
  1035.                     ui = netsnmp_oid_stash_get_data(undoStorage,
  1036.                                                     suffix, suffix_len);
  1037.                     retval =
  1038.                         set_ipCidrRouteStatus(data_context, ui->ptr,
  1039.                                               ui->len);
  1040.                     if (retval) {
  1041.                         netsnmp_set_request_error(reqinfo, requests,
  1042.                                                   SNMP_ERR_UNDOFAILED);
  1043.                     }
  1044.                 }
  1045.                 break;
  1046.             }
  1047.                 /** mib2cXXX: remove cache!  hard to do when serialized, however */
  1048.             break;
  1049.         default:
  1050.             snmp_log(LOG_ERR,
  1051.                      "problem encountered in ipCidrRouteTable_handler: unsupported moden");
  1052.         }
  1053.     }
  1054.     return SNMP_ERR_NOERROR;
  1055. }