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

SNMP编程

开发平台:

Unix_Linux

  1. /*
  2.  * Note: this file originally auto-generated by mib2c using
  3.  *       version : 1.43 $ of : mfd-interface.m2c,v $ 
  4.  *
  5.  * $Id: ipSystemStatsTable_interface.c,v 1.4.2.1 2005/03/29 21:05:26 nba 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 "ipSystemStatsTable.h"
  38. #include <net-snmp/library/container.h>
  39. #include "ipSystemStatsTable_interface.h"
  40. /**********************************************************************
  41.  **********************************************************************
  42.  ***
  43.  *** Table ipSystemStatsTable
  44.  ***
  45.  **********************************************************************
  46.  **********************************************************************/
  47. /*
  48.  * ipSystemStatsTable is subid 1 of ipTrafficStats.
  49.  * Its status is Current.
  50.  * OID: .1.3.6.1.2.1.4.31.1, length: 9
  51.  */
  52. typedef struct ipSystemStatsTable_interface_ctx_s {
  53.     netsnmp_container *container;
  54.     netsnmp_cache  *cache;      /* optional cache */
  55.     ipSystemStatsTable_registration_ptr user_ctx;
  56.     netsnmp_table_registration_info tbl_info;
  57.     netsnmp_baby_steps_access_methods access_multiplexer;
  58. } ipSystemStatsTable_interface_ctx;
  59. static ipSystemStatsTable_interface_ctx ipSystemStatsTable_if_ctx;
  60. static void
  61.                 _ipSystemStatsTable_container_init(ipSystemStatsTable_interface_ctx *
  62.                                                    if_ctx);
  63. static Netsnmp_Node_Handler _mfd_ipSystemStatsTable_pre_request;
  64. static Netsnmp_Node_Handler _mfd_ipSystemStatsTable_post_request;
  65. static Netsnmp_Node_Handler _mfd_ipSystemStatsTable_object_lookup;
  66. static Netsnmp_Node_Handler _mfd_ipSystemStatsTable_get_values;
  67. /**
  68.  * @internal
  69.  * Initialize the table ipSystemStatsTable 
  70.  *    (Define its contents and how it's structured)
  71.  */
  72. void
  73.     _ipSystemStatsTable_initialize_interface
  74.     (ipSystemStatsTable_registration_ptr reg_ptr, u_long flags) {
  75.     netsnmp_baby_steps_access_methods *access_multiplexer =
  76.         &ipSystemStatsTable_if_ctx.access_multiplexer;
  77.     netsnmp_table_registration_info *tbl_info =
  78.         &ipSystemStatsTable_if_ctx.tbl_info;
  79.     netsnmp_handler_registration *reginfo;
  80.     netsnmp_mib_handler *handler;
  81.     int             mfd_modes = 0;
  82.     DEBUGMSGTL(("internal:ipSystemStatsTable:_ipSystemStatsTable_initialize_interface", "calledn"));
  83.     /*************************************************
  84.      *
  85.      * save interface context for ipSystemStatsTable
  86.      */
  87.     /*
  88.      * Setting up the table's definition
  89.      */
  90.     netsnmp_table_helper_add_indexes(tbl_info, ASN_INTEGER,
  91.                                                /** index: ipSystemStatsIPVersion */
  92.                                      0);
  93.     /*
  94.      * Define the minimum and maximum accessible columns.  This
  95.      * optimizes retrival. 
  96.      */
  97.     tbl_info->min_column = IPSYSTEMSTATSTABLE_MIN_COL;
  98.     tbl_info->max_column = IPSYSTEMSTATSTABLE_MAX_COL;
  99.     /*
  100.      * save users context
  101.      */
  102.     ipSystemStatsTable_if_ctx.user_ctx = reg_ptr;
  103.     /*
  104.      * call data access initialization code
  105.      */
  106.     ipSystemStatsTable_init_data(reg_ptr);
  107.     /*
  108.      * set up the container
  109.      */
  110.     _ipSystemStatsTable_container_init(&ipSystemStatsTable_if_ctx);
  111.     if (NULL == ipSystemStatsTable_if_ctx.container) {
  112.         snmp_log(LOG_ERR,
  113.                  "could not initialize container for ipSystemStatsTablen");
  114.         return;
  115.     }
  116.     /*
  117.      * access_multiplexer: REQUIRED wrapper for get request handling
  118.      */
  119.     access_multiplexer->object_lookup =
  120.         _mfd_ipSystemStatsTable_object_lookup;
  121.     access_multiplexer->get_values = _mfd_ipSystemStatsTable_get_values;
  122.     /*
  123.      * no wrappers yet
  124.      */
  125.     access_multiplexer->pre_request = _mfd_ipSystemStatsTable_pre_request;
  126.     access_multiplexer->post_request =
  127.         _mfd_ipSystemStatsTable_post_request;
  128.     /*************************************************
  129.      *
  130.      * Create a registration, save our reg data, register table.
  131.      */
  132.     DEBUGMSGTL(("ipSystemStatsTable:init_ipSystemStatsTable",
  133.                 "Registering ipSystemStatsTable as a mibs-for-dummies table.n"));
  134.     handler =
  135.         netsnmp_baby_steps_access_multiplexer_get(access_multiplexer);
  136.     reginfo =
  137.         netsnmp_handler_registration_create("ipSystemStatsTable", handler,
  138.                                             ipSystemStatsTable_oid,
  139.                                             ipSystemStatsTable_oid_size,
  140.                                             HANDLER_CAN_BABY_STEP |
  141.                                             HANDLER_CAN_RONLY);
  142.     if (NULL == reginfo) {
  143.         snmp_log(LOG_ERR, "error registering table ipSystemStatsTablen");
  144.         return;
  145.     }
  146.     reginfo->my_reg_void = &ipSystemStatsTable_if_ctx;
  147.     /*************************************************
  148.      *
  149.      * set up baby steps handler, create it and inject it
  150.      */
  151.     if (access_multiplexer->object_lookup)
  152.         mfd_modes |= BABY_STEP_OBJECT_LOOKUP;
  153.     if (access_multiplexer->set_values)
  154.         mfd_modes |= BABY_STEP_SET_VALUES;
  155.     if (access_multiplexer->irreversible_commit)
  156.         mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT;
  157.     if (access_multiplexer->object_syntax_checks)
  158.         mfd_modes |= BABY_STEP_CHECK_OBJECT;
  159.     if (access_multiplexer->pre_request)
  160.         mfd_modes |= BABY_STEP_PRE_REQUEST;
  161.     if (access_multiplexer->post_request)
  162.         mfd_modes |= BABY_STEP_POST_REQUEST;
  163.     if (access_multiplexer->undo_setup)
  164.         mfd_modes |= BABY_STEP_UNDO_SETUP;
  165.     if (access_multiplexer->undo_cleanup)
  166.         mfd_modes |= BABY_STEP_UNDO_CLEANUP;
  167.     if (access_multiplexer->undo_sets)
  168.         mfd_modes |= BABY_STEP_UNDO_SETS;
  169.     if (access_multiplexer->row_creation)
  170.         mfd_modes |= BABY_STEP_ROW_CREATE;
  171.     if (access_multiplexer->consistency_checks)
  172.         mfd_modes |= BABY_STEP_CHECK_CONSISTENCY;
  173.     if (access_multiplexer->commit)
  174.         mfd_modes |= BABY_STEP_COMMIT;
  175.     if (access_multiplexer->undo_commit)
  176.         mfd_modes |= BABY_STEP_UNDO_COMMIT;
  177.     handler = netsnmp_baby_steps_handler_get(mfd_modes);
  178.     netsnmp_inject_handler(reginfo, handler);
  179.     /*************************************************
  180.      *
  181.      * inject row_merge helper with prefix rootoid_len + 2 (entry.col)
  182.      */
  183.     handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2);
  184.     netsnmp_inject_handler(reginfo, handler);
  185.     /*************************************************
  186.      *
  187.      * inject container_table helper
  188.      */
  189.     handler =
  190.         netsnmp_container_table_handler_get(tbl_info,
  191.                                             ipSystemStatsTable_if_ctx.
  192.                                             container,
  193.                                             TABLE_CONTAINER_KEY_NETSNMP_INDEX);
  194.     netsnmp_inject_handler(reginfo, handler);
  195.     /*************************************************
  196.      *
  197.      * inject cache helper
  198.      */
  199.     if (NULL != ipSystemStatsTable_if_ctx.cache) {
  200.         handler =
  201.             netsnmp_cache_handler_get(ipSystemStatsTable_if_ctx.cache);
  202.         netsnmp_inject_handler(reginfo, handler);
  203.     }
  204.     /*
  205.      * register table
  206.      */
  207.     netsnmp_register_table(reginfo, tbl_info);
  208. }                               /* _ipSystemStatsTable_initialize_interface */
  209. void
  210. ipSystemStatsTable_valid_columns_set(netsnmp_column_info *vc)
  211. {
  212.     ipSystemStatsTable_if_ctx.tbl_info.valid_columns = vc;
  213. }                               /* ipSystemStatsTable_valid_columns_set */
  214. /**
  215.  * @internal
  216.  * convert the index component stored in the context to an oid
  217.  */
  218. int
  219. ipSystemStatsTable_index_to_oid(netsnmp_index * oid_idx,
  220.                                 ipSystemStatsTable_mib_index * mib_idx)
  221. {
  222.     int             err = SNMP_ERR_NOERROR;
  223.     /*
  224.      * temp storage for parsing indexes
  225.      */
  226.     /*
  227.      * ipSystemStatsIPVersion(1)/InetVersion/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
  228.      */
  229.     netsnmp_variable_list var_ipSystemStatsIPVersion;
  230.     /*
  231.      * set up varbinds
  232.      */
  233.     memset(&var_ipSystemStatsIPVersion, 0x00,
  234.            sizeof(var_ipSystemStatsIPVersion));
  235.     var_ipSystemStatsIPVersion.type = ASN_INTEGER;
  236.     /*
  237.      * chain temp index varbinds together
  238.      */
  239.     var_ipSystemStatsIPVersion.next_variable = NULL;
  240.     DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsTable_index_to_oid", "calledn"));
  241.     /*
  242.      * ipSystemStatsIPVersion(1)/InetVersion/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h 
  243.      */
  244.     snmp_set_var_value(&var_ipSystemStatsIPVersion,
  245.                        (u_char *) & mib_idx->ipSystemStatsIPVersion,
  246.                        sizeof(mib_idx->ipSystemStatsIPVersion));
  247.     err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len,
  248.                             NULL, 0, &var_ipSystemStatsIPVersion);
  249.     if (err)
  250.         snmp_log(LOG_ERR, "error %d converting index to oidn", err);
  251.     /*
  252.      * parsing may have allocated memory. free it.
  253.      */
  254.     snmp_reset_var_buffers(&var_ipSystemStatsIPVersion);
  255.     return err;
  256. }                               /* ipSystemStatsTable_index_to_oid */
  257. /**
  258.  * extract ipSystemStatsTable indexes from a netsnmp_index
  259.  *
  260.  * @retval SNMP_ERR_NOERROR  : no error
  261.  * @retval SNMP_ERR_GENERR   : error
  262.  */
  263. int
  264. ipSystemStatsTable_index_from_oid(netsnmp_index * oid_idx,
  265.                                   ipSystemStatsTable_mib_index * mib_idx)
  266. {
  267.     int             err = SNMP_ERR_NOERROR;
  268.     /*
  269.      * temp storage for parsing indexes
  270.      */
  271.     /*
  272.      * ipSystemStatsIPVersion(1)/InetVersion/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
  273.      */
  274.     netsnmp_variable_list var_ipSystemStatsIPVersion;
  275.     /*
  276.      * set up varbinds
  277.      */
  278.     memset(&var_ipSystemStatsIPVersion, 0x00,
  279.            sizeof(var_ipSystemStatsIPVersion));
  280.     var_ipSystemStatsIPVersion.type = ASN_INTEGER;
  281.     /*
  282.      * chain temp index varbinds together
  283.      */
  284.     var_ipSystemStatsIPVersion.next_variable = NULL;
  285.     DEBUGMSGTL(("verbose:ipSystemStatsTable:ipSystemStatsTable_index_from_oid", "calledn"));
  286.     /*
  287.      * parse the oid into the individual index components
  288.      */
  289.     err = parse_oid_indexes(oid_idx->oids, oid_idx->len,
  290.                             &var_ipSystemStatsIPVersion);
  291.     if (err == SNMP_ERR_NOERROR) {
  292.         /*
  293.          * copy out values
  294.          */
  295.         mib_idx->ipSystemStatsIPVersion =
  296.             *((u_long *) var_ipSystemStatsIPVersion.val.string);
  297.     }
  298.     /*
  299.      * parsing may have allocated memory. free it.
  300.      */
  301.     snmp_reset_var_buffers(&var_ipSystemStatsIPVersion);
  302.     return err;
  303. }                               /* ipSystemStatsTable_index_from_oid */
  304. /*
  305.  *********************************************************************
  306.  * @internal
  307.  * allocate resources for a ipSystemStatsTable_rowreq_ctx
  308.  */
  309. ipSystemStatsTable_rowreq_ctx *
  310. ipSystemStatsTable_allocate_rowreq_ctx(ipSystemStatsTable_data * data)
  311. {
  312.     ipSystemStatsTable_rowreq_ctx *rowreq_ctx =
  313.         SNMP_MALLOC_TYPEDEF(ipSystemStatsTable_rowreq_ctx);
  314.     DEBUGMSGTL(("internal:ipSystemStatsTable:ipSystemStatsTable_allocate_rowreq_ctx", "calledn"));
  315.     if (NULL == rowreq_ctx) {
  316.         snmp_log(LOG_ERR, "Couldn't allocate memory for a "
  317.                  "ipSystemStatsTable_rowreq_ctx.n");
  318.     } else {
  319.         if (NULL != data) {
  320.             rowreq_ctx->data = data;
  321.         } else if (NULL ==
  322.                    (rowreq_ctx->data =
  323.                     ipSystemStatsTable_allocate_data())) {
  324.             SNMP_FREE(rowreq_ctx);
  325.             return NULL;
  326.         }
  327.     }
  328.     /*
  329.      * undo context will be allocated when needed (in *_undo_setup)
  330.      */
  331.     rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp;
  332.     rowreq_ctx->ipSystemStatsTable_data_list = NULL;
  333.     rowreq_ctx->ipSystemStatsTable_reg =
  334.         ipSystemStatsTable_if_ctx.user_ctx;
  335.     return rowreq_ctx;
  336. }                               /* ipSystemStatsTable_allocate_rowreq_ctx */
  337. /*
  338.  * @internal
  339.  * release resources for a ipSystemStatsTable_rowreq_ctx
  340.  */
  341. void
  342. ipSystemStatsTable_release_rowreq_ctx(ipSystemStatsTable_rowreq_ctx *
  343.                                       rowreq_ctx)
  344. {
  345.     DEBUGMSGTL(("internal:ipSystemStatsTable:ipSystemStatsTable_release_rowreq_ctx", "calledn"));
  346.     netsnmp_assert(NULL != rowreq_ctx);
  347.     if (rowreq_ctx->data)
  348.         ipSystemStatsTable_release_data(rowreq_ctx->data);
  349.     /*
  350.      * free index oid pointer
  351.      */
  352.     if (rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp)
  353.         free(rowreq_ctx->oid_idx.oids);
  354.     SNMP_FREE(rowreq_ctx);
  355. }                               /* ipSystemStatsTable_release_rowreq_ctx */
  356. /**
  357.  * @internal
  358.  * wrapper
  359.  */
  360. static int
  361. _mfd_ipSystemStatsTable_pre_request(netsnmp_mib_handler *handler,
  362.                                     netsnmp_handler_registration *reginfo,
  363.                                     netsnmp_agent_request_info
  364.                                     *agtreq_info,
  365.                                     netsnmp_request_info *requests)
  366. {
  367.     int             rc =
  368.         ipSystemStatsTable_pre_request(ipSystemStatsTable_if_ctx.user_ctx);
  369.     if (MFD_SUCCESS != rc) {
  370.         /*
  371.          * nothing we can do about it but log it
  372.          */
  373.         DEBUGMSGTL(("internal:ipSystemStatsTable", "error %d from "
  374.                     "ipSystemStatsTable_pre_requestn", rc));
  375.         netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
  376.     }
  377.     return SNMP_ERR_NOERROR;
  378. }                               /* _mfd_ipSystemStatsTable_pre_request */
  379. /**
  380.  * @internal
  381.  * wrapper
  382.  */
  383. static int
  384. _mfd_ipSystemStatsTable_post_request(netsnmp_mib_handler *handler,
  385.                                      netsnmp_handler_registration *reginfo,
  386.                                      netsnmp_agent_request_info
  387.                                      *agtreq_info,
  388.                                      netsnmp_request_info *requests)
  389. {
  390.     ipSystemStatsTable_rowreq_ctx *rowreq_ctx;
  391.     int             rc =
  392.         ipSystemStatsTable_post_request(ipSystemStatsTable_if_ctx.
  393.                                         user_ctx);
  394.     if (MFD_SUCCESS != rc) {
  395.         /*
  396.          * nothing we can do about it but log it
  397.          */
  398.         DEBUGMSGTL(("internal:ipSystemStatsTable", "error %d from "
  399.                     "ipSystemStatsTable_post_requestn", rc));
  400.     }
  401.     /*
  402.      * if it was set, clear row created flag.
  403.      */
  404.     rowreq_ctx = netsnmp_container_table_row_extract(requests);
  405.     if ((NULL != rowreq_ctx)
  406.         && (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED))
  407.         rowreq_ctx->rowreq_flags &= ~MFD_ROW_CREATED;
  408.     return SNMP_ERR_NOERROR;
  409. }                               /* _mfd_ipSystemStatsTable_post_request */
  410. /**
  411.  * @internal
  412.  * wrapper
  413.  */
  414. static int
  415. _mfd_ipSystemStatsTable_object_lookup(netsnmp_mib_handler *handler, netsnmp_handler_registration
  416.                                       *reginfo, netsnmp_agent_request_info
  417.                                       *agtreq_info,
  418.                                       netsnmp_request_info *requests)
  419. {
  420.     ipSystemStatsTable_rowreq_ctx *rowreq_ctx =
  421.         netsnmp_container_table_row_extract(requests);
  422.     DEBUGMSGTL(("internal:ipSystemStatsTable:_mfd_ipSystemStatsTable_object_lookup", "calledn"));
  423.     /*
  424.      * get our context from mfd
  425.      * ipSystemStatsTable_interface_ctx *if_ctx =
  426.      *             (ipSystemStatsTable_interface_ctx *)reginfo->my_reg_void;
  427.      */
  428.     if (NULL == rowreq_ctx) {
  429.         netsnmp_request_set_error_all(requests, SNMP_ERR_NOCREATION);
  430.     } else {
  431.         ipSystemStatsTable_row_prep(rowreq_ctx);
  432.     }
  433.     return SNMP_ERR_NOERROR;
  434. }                               /* _mfd_ipSystemStatsTable_object_lookup */
  435. /***********************************************************************
  436.  *
  437.  * GET processing
  438.  *
  439.  ***********************************************************************/
  440. /*
  441.  * @internal
  442.  * Retrieve the value for a particular column
  443.  */
  444. NETSNMP_STATIC_INLINE int
  445. _ipSystemStatsTable_get_column(ipSystemStatsTable_rowreq_ctx * rowreq_ctx,
  446.                                netsnmp_variable_list * var, int column)
  447. {
  448.     int             rc = SNMPERR_SUCCESS;
  449.     DEBUGMSGTL(("internal:ipSystemStatsTable:_mfd_ipSystemStatsTable_get_column", "calledn"));
  450.     netsnmp_assert(NULL != rowreq_ctx);
  451.     switch (column) {
  452.         /*
  453.          * ipSystemStatsInReceives(3)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  454.          */
  455.     case COLUMN_IPSYSTEMSTATSINRECEIVES:
  456.         var->val_len = sizeof(u_long);
  457.         var->type = ASN_COUNTER;
  458.         rc = ipSystemStatsInReceives_get(rowreq_ctx,
  459.                                          (u_long *) var->val.string);
  460.         break;
  461.         /*
  462.          * ipSystemStatsHCInReceives(4)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h 
  463.          */
  464.     case COLUMN_IPSYSTEMSTATSHCINRECEIVES:
  465.         var->val_len = sizeof(U64);
  466.         var->type = ASN_COUNTER64;
  467.         rc = ipSystemStatsHCInReceives_get(rowreq_ctx,
  468.                                            (U64 *) var->val.string);
  469.         break;
  470.         /*
  471.          * ipSystemStatsInOctets(5)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  472.          */
  473.     case COLUMN_IPSYSTEMSTATSINOCTETS:
  474.         var->val_len = sizeof(u_long);
  475.         var->type = ASN_COUNTER;
  476.         rc = ipSystemStatsInOctets_get(rowreq_ctx,
  477.                                        (u_long *) var->val.string);
  478.         break;
  479.         /*
  480.          * ipSystemStatsHCInOctets(6)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h 
  481.          */
  482.     case COLUMN_IPSYSTEMSTATSHCINOCTETS:
  483.         var->val_len = sizeof(U64);
  484.         var->type = ASN_COUNTER64;
  485.         rc = ipSystemStatsHCInOctets_get(rowreq_ctx,
  486.                                          (U64 *) var->val.string);
  487.         break;
  488.         /*
  489.          * ipSystemStatsInHdrErrors(7)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  490.          */
  491.     case COLUMN_IPSYSTEMSTATSINHDRERRORS:
  492.         var->val_len = sizeof(u_long);
  493.         var->type = ASN_COUNTER;
  494.         rc = ipSystemStatsInHdrErrors_get(rowreq_ctx,
  495.                                           (u_long *) var->val.string);
  496.         break;
  497.         /*
  498.          * ipSystemStatsInNoRoutes(8)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  499.          */
  500.     case COLUMN_IPSYSTEMSTATSINNOROUTES:
  501.         var->val_len = sizeof(u_long);
  502.         var->type = ASN_COUNTER;
  503.         rc = ipSystemStatsInNoRoutes_get(rowreq_ctx,
  504.                                          (u_long *) var->val.string);
  505.         break;
  506.         /*
  507.          * ipSystemStatsInAddrErrors(9)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  508.          */
  509.     case COLUMN_IPSYSTEMSTATSINADDRERRORS:
  510.         var->val_len = sizeof(u_long);
  511.         var->type = ASN_COUNTER;
  512.         rc = ipSystemStatsInAddrErrors_get(rowreq_ctx,
  513.                                            (u_long *) var->val.string);
  514.         break;
  515.         /*
  516.          * ipSystemStatsInUnknownProtos(10)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  517.          */
  518.     case COLUMN_IPSYSTEMSTATSINUNKNOWNPROTOS:
  519.         var->val_len = sizeof(u_long);
  520.         var->type = ASN_COUNTER;
  521.         rc = ipSystemStatsInUnknownProtos_get(rowreq_ctx,
  522.                                               (u_long *) var->val.string);
  523.         break;
  524.         /*
  525.          * ipSystemStatsInTruncatedPkts(11)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  526.          */
  527.     case COLUMN_IPSYSTEMSTATSINTRUNCATEDPKTS:
  528.         var->val_len = sizeof(u_long);
  529.         var->type = ASN_COUNTER;
  530.         rc = ipSystemStatsInTruncatedPkts_get(rowreq_ctx,
  531.                                               (u_long *) var->val.string);
  532.         break;
  533.         /*
  534.          * ipSystemStatsInForwDatagrams(12)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  535.          */
  536.     case COLUMN_IPSYSTEMSTATSINFORWDATAGRAMS:
  537.         var->val_len = sizeof(u_long);
  538.         var->type = ASN_COUNTER;
  539.         rc = ipSystemStatsInForwDatagrams_get(rowreq_ctx,
  540.                                               (u_long *) var->val.string);
  541.         break;
  542.         /*
  543.          * ipSystemStatsHCInForwDatagrams(13)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h 
  544.          */
  545.     case COLUMN_IPSYSTEMSTATSHCINFORWDATAGRAMS:
  546.         var->val_len = sizeof(U64);
  547.         var->type = ASN_COUNTER64;
  548.         rc = ipSystemStatsHCInForwDatagrams_get(rowreq_ctx,
  549.                                                 (U64 *) var->val.string);
  550.         break;
  551.         /*
  552.          * ipSystemStatsReasmReqds(14)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  553.          */
  554.     case COLUMN_IPSYSTEMSTATSREASMREQDS:
  555.         var->val_len = sizeof(u_long);
  556.         var->type = ASN_COUNTER;
  557.         rc = ipSystemStatsReasmReqds_get(rowreq_ctx,
  558.                                          (u_long *) var->val.string);
  559.         break;
  560.         /*
  561.          * ipSystemStatsReasmOKs(15)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  562.          */
  563.     case COLUMN_IPSYSTEMSTATSREASMOKS:
  564.         var->val_len = sizeof(u_long);
  565.         var->type = ASN_COUNTER;
  566.         rc = ipSystemStatsReasmOKs_get(rowreq_ctx,
  567.                                        (u_long *) var->val.string);
  568.         break;
  569.         /*
  570.          * ipSystemStatsReasmFails(16)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  571.          */
  572.     case COLUMN_IPSYSTEMSTATSREASMFAILS:
  573.         var->val_len = sizeof(u_long);
  574.         var->type = ASN_COUNTER;
  575.         rc = ipSystemStatsReasmFails_get(rowreq_ctx,
  576.                                          (u_long *) var->val.string);
  577.         break;
  578.         /*
  579.          * ipSystemStatsInDiscards(17)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  580.          */
  581.     case COLUMN_IPSYSTEMSTATSINDISCARDS:
  582.         var->val_len = sizeof(u_long);
  583.         var->type = ASN_COUNTER;
  584.         rc = ipSystemStatsInDiscards_get(rowreq_ctx,
  585.                                          (u_long *) var->val.string);
  586.         break;
  587.         /*
  588.          * ipSystemStatsInDelivers(18)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  589.          */
  590.     case COLUMN_IPSYSTEMSTATSINDELIVERS:
  591.         var->val_len = sizeof(u_long);
  592.         var->type = ASN_COUNTER;
  593.         rc = ipSystemStatsInDelivers_get(rowreq_ctx,
  594.                                          (u_long *) var->val.string);
  595.         break;
  596.         /*
  597.          * ipSystemStatsHCInDelivers(19)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h 
  598.          */
  599.     case COLUMN_IPSYSTEMSTATSHCINDELIVERS:
  600.         var->val_len = sizeof(U64);
  601.         var->type = ASN_COUNTER64;
  602.         rc = ipSystemStatsHCInDelivers_get(rowreq_ctx,
  603.                                            (U64 *) var->val.string);
  604.         break;
  605.         /*
  606.          * ipSystemStatsOutRequests(20)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  607.          */
  608.     case COLUMN_IPSYSTEMSTATSOUTREQUESTS:
  609.         var->val_len = sizeof(u_long);
  610.         var->type = ASN_COUNTER;
  611.         rc = ipSystemStatsOutRequests_get(rowreq_ctx,
  612.                                           (u_long *) var->val.string);
  613.         break;
  614.         /*
  615.          * ipSystemStatsHCOutRequests(21)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h 
  616.          */
  617.     case COLUMN_IPSYSTEMSTATSHCOUTREQUESTS:
  618.         var->val_len = sizeof(U64);
  619.         var->type = ASN_COUNTER64;
  620.         rc = ipSystemStatsHCOutRequests_get(rowreq_ctx,
  621.                                             (U64 *) var->val.string);
  622.         break;
  623.         /*
  624.          * ipSystemStatsOutNoRoutes(22)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  625.          */
  626.     case COLUMN_IPSYSTEMSTATSOUTNOROUTES:
  627.         var->val_len = sizeof(u_long);
  628.         var->type = ASN_COUNTER;
  629.         rc = ipSystemStatsOutNoRoutes_get(rowreq_ctx,
  630.                                           (u_long *) var->val.string);
  631.         break;
  632.         /*
  633.          * ipSystemStatsOutForwDatagrams(23)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  634.          */
  635.     case COLUMN_IPSYSTEMSTATSOUTFORWDATAGRAMS:
  636.         var->val_len = sizeof(u_long);
  637.         var->type = ASN_COUNTER;
  638.         rc = ipSystemStatsOutForwDatagrams_get(rowreq_ctx,
  639.                                                (u_long *) var->val.string);
  640.         break;
  641.         /*
  642.          * ipSystemStatsHCOutForwDatagrams(24)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h 
  643.          */
  644.     case COLUMN_IPSYSTEMSTATSHCOUTFORWDATAGRAMS:
  645.         var->val_len = sizeof(U64);
  646.         var->type = ASN_COUNTER64;
  647.         rc = ipSystemStatsHCOutForwDatagrams_get(rowreq_ctx,
  648.                                                  (U64 *) var->val.string);
  649.         break;
  650.         /*
  651.          * ipSystemStatsOutDiscards(25)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  652.          */
  653.     case COLUMN_IPSYSTEMSTATSOUTDISCARDS:
  654.         var->val_len = sizeof(u_long);
  655.         var->type = ASN_COUNTER;
  656.         rc = ipSystemStatsOutDiscards_get(rowreq_ctx,
  657.                                           (u_long *) var->val.string);
  658.         break;
  659.         /*
  660.          * ipSystemStatsOutFragReqds(26)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  661.          */
  662.     case COLUMN_IPSYSTEMSTATSOUTFRAGREQDS:
  663.         var->val_len = sizeof(u_long);
  664.         var->type = ASN_COUNTER;
  665.         rc = ipSystemStatsOutFragReqds_get(rowreq_ctx,
  666.                                            (u_long *) var->val.string);
  667.         break;
  668.         /*
  669.          * ipSystemStatsOutFragOKs(27)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  670.          */
  671.     case COLUMN_IPSYSTEMSTATSOUTFRAGOKS:
  672.         var->val_len = sizeof(u_long);
  673.         var->type = ASN_COUNTER;
  674.         rc = ipSystemStatsOutFragOKs_get(rowreq_ctx,
  675.                                          (u_long *) var->val.string);
  676.         break;
  677.         /*
  678.          * ipSystemStatsOutFragFails(28)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  679.          */
  680.     case COLUMN_IPSYSTEMSTATSOUTFRAGFAILS:
  681.         var->val_len = sizeof(u_long);
  682.         var->type = ASN_COUNTER;
  683.         rc = ipSystemStatsOutFragFails_get(rowreq_ctx,
  684.                                            (u_long *) var->val.string);
  685.         break;
  686.         /*
  687.          * ipSystemStatsOutFragCreates(29)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  688.          */
  689.     case COLUMN_IPSYSTEMSTATSOUTFRAGCREATES:
  690.         var->val_len = sizeof(u_long);
  691.         var->type = ASN_COUNTER;
  692.         rc = ipSystemStatsOutFragCreates_get(rowreq_ctx,
  693.                                              (u_long *) var->val.string);
  694.         break;
  695.         /*
  696.          * ipSystemStatsOutTransmits(30)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  697.          */
  698.     case COLUMN_IPSYSTEMSTATSOUTTRANSMITS:
  699.         var->val_len = sizeof(u_long);
  700.         var->type = ASN_COUNTER;
  701.         rc = ipSystemStatsOutTransmits_get(rowreq_ctx,
  702.                                            (u_long *) var->val.string);
  703.         break;
  704.         /*
  705.          * ipSystemStatsHCOutTransmits(31)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h 
  706.          */
  707.     case COLUMN_IPSYSTEMSTATSHCOUTTRANSMITS:
  708.         var->val_len = sizeof(U64);
  709.         var->type = ASN_COUNTER64;
  710.         rc = ipSystemStatsHCOutTransmits_get(rowreq_ctx,
  711.                                              (U64 *) var->val.string);
  712.         break;
  713.         /*
  714.          * ipSystemStatsOutOctets(32)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  715.          */
  716.     case COLUMN_IPSYSTEMSTATSOUTOCTETS:
  717.         var->val_len = sizeof(u_long);
  718.         var->type = ASN_COUNTER;
  719.         rc = ipSystemStatsOutOctets_get(rowreq_ctx,
  720.                                         (u_long *) var->val.string);
  721.         break;
  722.         /*
  723.          * ipSystemStatsHCOutOctets(33)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h 
  724.          */
  725.     case COLUMN_IPSYSTEMSTATSHCOUTOCTETS:
  726.         var->val_len = sizeof(U64);
  727.         var->type = ASN_COUNTER64;
  728.         rc = ipSystemStatsHCOutOctets_get(rowreq_ctx,
  729.                                           (U64 *) var->val.string);
  730.         break;
  731.         /*
  732.          * ipSystemStatsInMcastPkts(34)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  733.          */
  734.     case COLUMN_IPSYSTEMSTATSINMCASTPKTS:
  735.         var->val_len = sizeof(u_long);
  736.         var->type = ASN_COUNTER;
  737.         rc = ipSystemStatsInMcastPkts_get(rowreq_ctx,
  738.                                           (u_long *) var->val.string);
  739.         break;
  740.         /*
  741.          * ipSystemStatsHCInMcastPkts(35)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h 
  742.          */
  743.     case COLUMN_IPSYSTEMSTATSHCINMCASTPKTS:
  744.         var->val_len = sizeof(U64);
  745.         var->type = ASN_COUNTER64;
  746.         rc = ipSystemStatsHCInMcastPkts_get(rowreq_ctx,
  747.                                             (U64 *) var->val.string);
  748.         break;
  749.         /*
  750.          * ipSystemStatsInMcastOctets(36)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  751.          */
  752.     case COLUMN_IPSYSTEMSTATSINMCASTOCTETS:
  753.         var->val_len = sizeof(u_long);
  754.         var->type = ASN_COUNTER;
  755.         rc = ipSystemStatsInMcastOctets_get(rowreq_ctx,
  756.                                             (u_long *) var->val.string);
  757.         break;
  758.         /*
  759.          * ipSystemStatsHCInMcastOctets(37)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h 
  760.          */
  761.     case COLUMN_IPSYSTEMSTATSHCINMCASTOCTETS:
  762.         var->val_len = sizeof(U64);
  763.         var->type = ASN_COUNTER64;
  764.         rc = ipSystemStatsHCInMcastOctets_get(rowreq_ctx,
  765.                                               (U64 *) var->val.string);
  766.         break;
  767.         /*
  768.          * ipSystemStatsOutMcastPkts(38)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  769.          */
  770.     case COLUMN_IPSYSTEMSTATSOUTMCASTPKTS:
  771.         var->val_len = sizeof(u_long);
  772.         var->type = ASN_COUNTER;
  773.         rc = ipSystemStatsOutMcastPkts_get(rowreq_ctx,
  774.                                            (u_long *) var->val.string);
  775.         break;
  776.         /*
  777.          * ipSystemStatsHCOutMcastPkts(39)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h 
  778.          */
  779.     case COLUMN_IPSYSTEMSTATSHCOUTMCASTPKTS:
  780.         var->val_len = sizeof(U64);
  781.         var->type = ASN_COUNTER64;
  782.         rc = ipSystemStatsHCOutMcastPkts_get(rowreq_ctx,
  783.                                              (U64 *) var->val.string);
  784.         break;
  785.         /*
  786.          * ipSystemStatsOutMcastOctets(40)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  787.          */
  788.     case COLUMN_IPSYSTEMSTATSOUTMCASTOCTETS:
  789.         var->val_len = sizeof(u_long);
  790.         var->type = ASN_COUNTER;
  791.         rc = ipSystemStatsOutMcastOctets_get(rowreq_ctx,
  792.                                              (u_long *) var->val.string);
  793.         break;
  794.         /*
  795.          * ipSystemStatsHCOutMcastOctets(41)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h 
  796.          */
  797.     case COLUMN_IPSYSTEMSTATSHCOUTMCASTOCTETS:
  798.         var->val_len = sizeof(U64);
  799.         var->type = ASN_COUNTER64;
  800.         rc = ipSystemStatsHCOutMcastOctets_get(rowreq_ctx,
  801.                                                (U64 *) var->val.string);
  802.         break;
  803.         /*
  804.          * ipSystemStatsInBcastPkts(42)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  805.          */
  806.     case COLUMN_IPSYSTEMSTATSINBCASTPKTS:
  807.         var->val_len = sizeof(u_long);
  808.         var->type = ASN_COUNTER;
  809.         rc = ipSystemStatsInBcastPkts_get(rowreq_ctx,
  810.                                           (u_long *) var->val.string);
  811.         break;
  812.         /*
  813.          * ipSystemStatsHCInBcastPkts(43)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h 
  814.          */
  815.     case COLUMN_IPSYSTEMSTATSHCINBCASTPKTS:
  816.         var->val_len = sizeof(U64);
  817.         var->type = ASN_COUNTER64;
  818.         rc = ipSystemStatsHCInBcastPkts_get(rowreq_ctx,
  819.                                             (U64 *) var->val.string);
  820.         break;
  821.         /*
  822.          * ipSystemStatsOutBcastPkts(44)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  823.          */
  824.     case COLUMN_IPSYSTEMSTATSOUTBCASTPKTS:
  825.         var->val_len = sizeof(u_long);
  826.         var->type = ASN_COUNTER;
  827.         rc = ipSystemStatsOutBcastPkts_get(rowreq_ctx,
  828.                                            (u_long *) var->val.string);
  829.         break;
  830.         /*
  831.          * ipSystemStatsHCOutBcastPkts(45)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h 
  832.          */
  833.     case COLUMN_IPSYSTEMSTATSHCOUTBCASTPKTS:
  834.         var->val_len = sizeof(U64);
  835.         var->type = ASN_COUNTER64;
  836.         rc = ipSystemStatsHCOutBcastPkts_get(rowreq_ctx,
  837.                                              (U64 *) var->val.string);
  838.         break;
  839.         /*
  840.          * ipSystemStatsDiscontinuityTime(46)/TimeStamp/ASN_TIMETICKS/u_long(u_long)//l/A/w/e/r/d/h 
  841.          */
  842.     case COLUMN_IPSYSTEMSTATSDISCONTINUITYTIME:
  843.         var->val_len = sizeof(u_long);
  844.         var->type = ASN_TIMETICKS;
  845.         rc = ipSystemStatsDiscontinuityTime_get(rowreq_ctx,
  846.                                                 (u_long *) var->val.
  847.                                                 string);
  848.         break;
  849.         /*
  850.          * ipSystemStatsRefreshRate(47)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/h 
  851.          */
  852.     case COLUMN_IPSYSTEMSTATSREFRESHRATE:
  853.         var->val_len = sizeof(u_long);
  854.         var->type = ASN_UNSIGNED;
  855.         rc = ipSystemStatsRefreshRate_get(rowreq_ctx,
  856.                                           (u_long *) var->val.string);
  857.         break;
  858.     default:
  859.         snmp_log(LOG_ERR,
  860.                  "unknown column %d in _ipSystemStatsTable_get_columnn",
  861.                  column);
  862.         break;
  863.     }
  864.     return rc;
  865. }                               /* _ipSystemStatsTable_get_column */
  866. int
  867. _mfd_ipSystemStatsTable_get_values(netsnmp_mib_handler *handler,
  868.                                    netsnmp_handler_registration *reginfo,
  869.                                    netsnmp_agent_request_info *agtreq_info,
  870.                                    netsnmp_request_info *requests)
  871. {
  872.     ipSystemStatsTable_rowreq_ctx *rowreq_ctx =
  873.         netsnmp_container_table_row_extract(requests);
  874.     netsnmp_table_request_info *tri;
  875.     u_char         *old_string;
  876.     void            (*dataFreeHook) (void *);
  877.     int             rc;
  878.     DEBUGMSGTL(("internal:ipSystemStatsTable:_mfd_ipSystemStatsTable_get_values", "calledn"));
  879.     netsnmp_assert(NULL != rowreq_ctx);
  880.     for (; requests; requests = requests->next) {
  881.         /*
  882.          * save old pointer, so we can free it if replaced
  883.          */
  884.         old_string = requests->requestvb->val.string;
  885.         dataFreeHook = requests->requestvb->dataFreeHook;
  886.         if (NULL == requests->requestvb->val.string) {
  887.             requests->requestvb->val.string = requests->requestvb->buf;
  888.             requests->requestvb->val_len =
  889.                 sizeof(requests->requestvb->buf);
  890.         } else if (requests->requestvb->buf ==
  891.                    requests->requestvb->val.string) {
  892.             if (requests->requestvb->val_len !=
  893.                 sizeof(requests->requestvb->buf))
  894.                 requests->requestvb->val_len =
  895.                     sizeof(requests->requestvb->buf);
  896.         }
  897.         /*
  898.          * get column data
  899.          */
  900.         tri = netsnmp_extract_table_info(requests);
  901.         if (NULL == tri)
  902.             continue;
  903.         rc = _ipSystemStatsTable_get_column(rowreq_ctx,
  904.                                             requests->requestvb,
  905.                                             tri->colnum);
  906.         if (rc) {
  907.             if (MFD_SKIP == rc) {
  908.                 requests->requestvb->type = ASN_PRIV_RETRY;
  909.                 rc = SNMP_ERR_NOERROR;
  910.             }
  911.         } else if (NULL == requests->requestvb->val.string) {
  912.             snmp_log(LOG_ERR, "NULL varbind data pointer!n");
  913.             rc = SNMP_ERR_GENERR;
  914.         }
  915.         if (rc)
  916.             netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc));
  917.         /*
  918.          * if the buffer wasn't used previously for the old data (i.e. it
  919.          * was allcoated memory)  and the get routine replaced the pointer,
  920.          * we need to free the previous pointer.
  921.          */
  922.         if (old_string && (old_string != requests->requestvb->buf) &&
  923.             (requests->requestvb->val.string != old_string)) {
  924.             if (dataFreeHook)
  925.                 (*dataFreeHook) (old_string);
  926.             else
  927.                 free(old_string);
  928.         }
  929.     }                           /* for results */
  930.     return SNMP_ERR_NOERROR;
  931. }                               /* _mfd_ipSystemStatsTable_get_values */
  932. /***********************************************************************
  933.  *
  934.  * SET processing
  935.  *
  936.  ***********************************************************************/
  937. /*
  938.  * NOT APPLICABLE (per MIB or user setting)
  939.  */
  940. /***********************************************************************
  941.  *
  942.  * DATA ACCESS
  943.  *
  944.  ***********************************************************************/
  945. /**
  946.  * @internal
  947.  */
  948. static int
  949. _cache_load(netsnmp_cache * cache, void *vmagic)
  950. {
  951.     DEBUGMSGTL(("internal:ipSystemStatsTable:_cache_load", "calledn"));
  952.     if ((NULL == cache) || (NULL == cache->magic)) {
  953.         snmp_log(LOG_ERR,
  954.                  "invalid cache for ipSystemStatsTable_cache_loadn");
  955.         return -1;
  956.     }
  957.     /** should only be called for an invalid or expired cache */
  958.     netsnmp_assert((0 == cache->valid) || (1 == cache->expired));
  959.     /*
  960.      * call user code
  961.      */
  962.     return ipSystemStatsTable_cache_load((netsnmp_container *) cache->
  963.                                          magic);
  964. }                               /* _cache_load */
  965. /**
  966.  * @internal
  967.  */
  968. static void
  969. _cache_item_free(ipSystemStatsTable_rowreq_ctx * rowreq_ctx, void *context)
  970. {
  971.     DEBUGMSGTL(("internal:ipSystemStatsTable:_cache_item_free",
  972.                 "calledn"));
  973.     if (NULL == rowreq_ctx)
  974.         return;
  975.     ipSystemStatsTable_release_rowreq_ctx(rowreq_ctx);
  976. }                               /* _cache_item_free */
  977. /**
  978.  * @internal
  979.  */
  980. static void
  981. _cache_free(netsnmp_cache * cache, void *magic)
  982. {
  983.     netsnmp_container *container;
  984.     DEBUGMSGTL(("internal:ipSystemStatsTable:_cache_free", "calledn"));
  985.     if ((NULL == cache) || (NULL == cache->magic)) {
  986.         snmp_log(LOG_ERR,
  987.                  "invalid cache in ipSystemStatsTable_cache_freen");
  988.         return;
  989.     }
  990.     container = (netsnmp_container *) cache->magic;
  991.     /*
  992.      * call user code
  993.      */
  994.     ipSystemStatsTable_cache_free(container);
  995.     /*
  996.      * free all items. inefficient, but easy.
  997.      */
  998.     CONTAINER_CLEAR(container,
  999.                     (netsnmp_container_obj_func *) _cache_item_free, NULL);
  1000. }                               /* _cache_free */
  1001. /**
  1002.  * @internal
  1003.  * initialize the iterator container with functions or wrappers
  1004.  */
  1005. void
  1006. _ipSystemStatsTable_container_init(ipSystemStatsTable_interface_ctx *
  1007.                                    if_ctx)
  1008. {
  1009.     DEBUGMSGTL(("internal:ipSystemStatsTable:_ipSystemStatsTable_container_init", "calledn"));
  1010.     /*
  1011.      * set up the cache
  1012.      */
  1013.     if_ctx->cache = netsnmp_cache_create(30,    /* timeout in seconds */
  1014.                                          _cache_load, _cache_free,
  1015.                                          ipSystemStatsTable_oid,
  1016.                                          ipSystemStatsTable_oid_size);
  1017.     if (NULL == if_ctx->cache) {
  1018.         snmp_log(LOG_ERR, "error creating cache for ipSystemStatsTablen");
  1019.         return;
  1020.     }
  1021.     if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET;
  1022.     ipSystemStatsTable_container_init(&if_ctx->container, if_ctx->cache);
  1023.     if (NULL == if_ctx->container)
  1024.         if_ctx->container =
  1025.             netsnmp_container_find("ipSystemStatsTable:table_container");
  1026.     if (NULL == if_ctx->container) {
  1027.         snmp_log(LOG_ERR, "error creating container in "
  1028.                  "ipSystemStatsTable_container_initn");
  1029.         return;
  1030.     }
  1031.     if_ctx->cache->magic = (void *) if_ctx->container;
  1032. }                               /* _ipSystemStatsTable_container_init */