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

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: usmDHUserKeyTable_interface.c,v 1.8.2.1 2005/01/27 22:56:27 rstory Exp $
  6.  */
  7. /*
  8.  * *********************************************************************
  9.  * *********************************************************************
  10.  * *********************************************************************
  11.  * ***                                                               ***
  12.  * ***  NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE  ***
  13.  * ***                                                               ***
  14.  * ***                                                               ***
  15.  * ***       THIS FILE DOES NOT CONTAIN ANY USER EDITABLE CODE.      ***
  16.  * ***                                                               ***
  17.  * ***                                                               ***
  18.  * ***       THE GENERATED CODE IS INTERNAL IMPLEMENTATION, AND      ***
  19.  * ***                                                               ***
  20.  * ***                                                               ***
  21.  * ***    IS SUBJECT TO CHANGE WITHOUT WARNING IN FUTURE RELEASES.   ***
  22.  * ***                                                               ***
  23.  * ***                                                               ***
  24.  * *********************************************************************
  25.  * *********************************************************************
  26.  * *********************************************************************
  27.  */
  28. /*
  29.  * standard Net-SNMP includes 
  30.  */
  31. #include <net-snmp/net-snmp-config.h>
  32. #include <net-snmp/net-snmp-includes.h>
  33. #include <net-snmp/agent/net-snmp-agent-includes.h>
  34. /*
  35.  * include our parent header 
  36.  */
  37. #include "usmDHUserKeyTable.h"
  38. #include <net-snmp/library/container.h>
  39. #include "usmDHUserKeyTable_interface.h"
  40. /**********************************************************************
  41.  **********************************************************************
  42.  ***
  43.  *** Table usmDHUserKeyTable
  44.  ***
  45.  **********************************************************************
  46.  **********************************************************************/
  47. /*
  48.  * usmDHUserKeyTable is subid 2 of usmDHPublicObjects.
  49.  * Its status is Current.
  50.  * OID: .1.3.6.1.3.101.1.1.2, length: 9
  51.  */
  52. typedef struct usmDHUserKeyTable_interface_ctx_s {
  53.     netsnmp_container *container;
  54.     netsnmp_cache  *cache;      /* optional cache */
  55.     usmDHUserKeyTable_registration_ptr user_ctx;
  56.     netsnmp_table_registration_info tbl_info;
  57.     netsnmp_baby_steps_access_methods access_multiplexer;
  58. } usmDHUserKeyTable_interface_ctx;
  59. static usmDHUserKeyTable_interface_ctx usmDHUserKeyTable_if_ctx;
  60. static void
  61.                 _usmDHUserKeyTable_container_init(usmDHUserKeyTable_interface_ctx *
  62.                                                   if_ctx);
  63. static Netsnmp_Node_Handler _mfd_usmDHUserKeyTable_pre_request;
  64. static Netsnmp_Node_Handler _mfd_usmDHUserKeyTable_post_request;
  65. static Netsnmp_Node_Handler _mfd_usmDHUserKeyTable_object_lookup;
  66. static Netsnmp_Node_Handler _mfd_usmDHUserKeyTable_get_values;
  67. static Netsnmp_Node_Handler _mfd_usmDHUserKeyTable_check_objects;
  68. static Netsnmp_Node_Handler _mfd_usmDHUserKeyTable_undo_setup;
  69. static Netsnmp_Node_Handler _mfd_usmDHUserKeyTable_set_values;
  70. static Netsnmp_Node_Handler _mfd_usmDHUserKeyTable_undo_cleanup;
  71. static Netsnmp_Node_Handler _mfd_usmDHUserKeyTable_undo_values;
  72. static Netsnmp_Node_Handler _mfd_usmDHUserKeyTable_commit;
  73. static Netsnmp_Node_Handler _mfd_usmDHUserKeyTable_irreversible_commit;
  74. static Netsnmp_Node_Handler _mfd_usmDHUserKeyTable_undo_commit;
  75. static Netsnmp_Node_Handler _mfd_usmDHUserKeyTable_check_dependencies;
  76. NETSNMP_STATIC_INLINE int
  77.                 _usmDHUserKeyTable_undo_column(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx,
  78.                                                netsnmp_variable_list * var,
  79.                                                int column);
  80. /**
  81.  * @internal
  82.  * Initialize the table usmDHUserKeyTable 
  83.  *    (Define its contents and how it's structured)
  84.  */
  85. void
  86. _usmDHUserKeyTable_initialize_interface(usmDHUserKeyTable_registration_ptr
  87.                                         reg_ptr, u_long flags)
  88. {
  89.     netsnmp_baby_steps_access_methods *access_multiplexer =
  90.         &usmDHUserKeyTable_if_ctx.access_multiplexer;
  91.     netsnmp_table_registration_info *tbl_info =
  92.         &usmDHUserKeyTable_if_ctx.tbl_info;
  93.     netsnmp_handler_registration *reginfo;
  94.     netsnmp_mib_handler *handler;
  95.     int             mfd_modes = 0;
  96.     DEBUGMSGTL(("internal:usmDHUserKeyTable:_usmDHUserKeyTable_initialize_interface", "calledn"));
  97.     /*************************************************
  98.      *
  99.      * save interface context for usmDHUserKeyTable
  100.      */
  101.     /*
  102.      * Setting up the table's definition
  103.      */
  104.     netsnmp_table_helper_add_indexes(tbl_info, ASN_OCTET_STR,
  105.                                                  /** index: usmUserEngineID */
  106.                                      ASN_OCTET_STR,
  107.                                                  /** index: usmUserName */
  108.                                      0);
  109.     /*
  110.      * Define the minimum and maximum accessible columns.  This
  111.      * optimizes retrival. 
  112.      */
  113.     tbl_info->min_column = USMDHUSERKEYTABLE_MIN_COL;
  114.     tbl_info->max_column = USMDHUSERKEYTABLE_MAX_COL;
  115.     /*
  116.      * save users context
  117.      */
  118.     usmDHUserKeyTable_if_ctx.user_ctx = reg_ptr;
  119.     /*
  120.      * call data access initialization code
  121.      */
  122.     usmDHUserKeyTable_init_data(reg_ptr);
  123.     /*
  124.      * set up the container
  125.      */
  126.     _usmDHUserKeyTable_container_init(&usmDHUserKeyTable_if_ctx);
  127.     if (NULL == usmDHUserKeyTable_if_ctx.container) {
  128.         snmp_log(LOG_ERR,
  129.                  "could not initialize container for usmDHUserKeyTablen");
  130.         return;
  131.     }
  132.     /*
  133.      * access_multiplexer: REQUIRED wrapper for get request handling
  134.      */
  135.     access_multiplexer->object_lookup =
  136.         _mfd_usmDHUserKeyTable_object_lookup;
  137.     access_multiplexer->get_values = _mfd_usmDHUserKeyTable_get_values;
  138.     /*
  139.      * no wrappers yet
  140.      */
  141.     access_multiplexer->pre_request = _mfd_usmDHUserKeyTable_pre_request;
  142.     access_multiplexer->post_request = _mfd_usmDHUserKeyTable_post_request;
  143.     /*
  144.      * REQUIRED wrappers for set request handling
  145.      */
  146.     access_multiplexer->object_syntax_checks =
  147.         _mfd_usmDHUserKeyTable_check_objects;
  148.     access_multiplexer->undo_setup = _mfd_usmDHUserKeyTable_undo_setup;
  149.     access_multiplexer->undo_cleanup = _mfd_usmDHUserKeyTable_undo_cleanup;
  150.     access_multiplexer->set_values = _mfd_usmDHUserKeyTable_set_values;
  151.     access_multiplexer->undo_sets = _mfd_usmDHUserKeyTable_undo_values;
  152.     /*
  153.      * no wrappers yet
  154.      */
  155.     access_multiplexer->commit = _mfd_usmDHUserKeyTable_commit;
  156.     access_multiplexer->undo_commit = _mfd_usmDHUserKeyTable_undo_commit;
  157.     access_multiplexer->irreversible_commit =
  158.         _mfd_usmDHUserKeyTable_irreversible_commit;
  159.     /*
  160.      * REQUIRED for tables with dependencies
  161.      */
  162.     access_multiplexer->consistency_checks =
  163.         _mfd_usmDHUserKeyTable_check_dependencies;
  164.     /*************************************************
  165.      *
  166.      * Create a registration, save our reg data, register table.
  167.      */
  168.     DEBUGMSGTL(("usmDHUserKeyTable:init_usmDHUserKeyTable",
  169.                 "Registering usmDHUserKeyTable as a mibs-for-dummies table.n"));
  170.     handler =
  171.         netsnmp_baby_steps_access_multiplexer_get(access_multiplexer);
  172.     reginfo =
  173.         netsnmp_handler_registration_create("usmDHUserKeyTable", handler,
  174.                                             usmDHUserKeyTable_oid,
  175.                                             usmDHUserKeyTable_oid_size,
  176.                                             HANDLER_CAN_BABY_STEP |
  177.                                             HANDLER_CAN_RWRITE);
  178.     if (NULL == reginfo) {
  179.         snmp_log(LOG_ERR, "error registering table usmDHUserKeyTablen");
  180.         return;
  181.     }
  182.     reginfo->my_reg_void = &usmDHUserKeyTable_if_ctx;
  183.     /*************************************************
  184.      *
  185.      * set up baby steps handler, create it and inject it
  186.      */
  187.     if (access_multiplexer->object_lookup)
  188.         mfd_modes |= BABY_STEP_OBJECT_LOOKUP;
  189.     if (access_multiplexer->set_values)
  190.         mfd_modes |= BABY_STEP_SET_VALUES;
  191.     if (access_multiplexer->irreversible_commit)
  192.         mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT;
  193.     if (access_multiplexer->object_syntax_checks)
  194.         mfd_modes |= BABY_STEP_CHECK_OBJECT;
  195.     if (access_multiplexer->pre_request)
  196.         mfd_modes |= BABY_STEP_PRE_REQUEST;
  197.     if (access_multiplexer->post_request)
  198.         mfd_modes |= BABY_STEP_POST_REQUEST;
  199.     if (access_multiplexer->undo_setup)
  200.         mfd_modes |= BABY_STEP_UNDO_SETUP;
  201.     if (access_multiplexer->undo_cleanup)
  202.         mfd_modes |= BABY_STEP_UNDO_CLEANUP;
  203.     if (access_multiplexer->undo_sets)
  204.         mfd_modes |= BABY_STEP_UNDO_SETS;
  205.     if (access_multiplexer->row_creation)
  206.         mfd_modes |= BABY_STEP_ROW_CREATE;
  207.     if (access_multiplexer->consistency_checks)
  208.         mfd_modes |= BABY_STEP_CHECK_CONSISTENCY;
  209.     if (access_multiplexer->commit)
  210.         mfd_modes |= BABY_STEP_COMMIT;
  211.     if (access_multiplexer->undo_commit)
  212.         mfd_modes |= BABY_STEP_UNDO_COMMIT;
  213.     handler = netsnmp_baby_steps_handler_get(mfd_modes);
  214.     netsnmp_inject_handler(reginfo, handler);
  215.     /*************************************************
  216.      *
  217.      * inject row_merge helper with prefix rootoid_len + 2 (entry.col)
  218.      */
  219.     handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2);
  220.     netsnmp_inject_handler(reginfo, handler);
  221.     /*************************************************
  222.      *
  223.      * inject container_table helper
  224.      */
  225.     handler =
  226.         netsnmp_container_table_handler_get(tbl_info,
  227.                                             usmDHUserKeyTable_if_ctx.
  228.                                             container,
  229.                                             TABLE_CONTAINER_KEY_NETSNMP_INDEX);
  230.     netsnmp_inject_handler(reginfo, handler);
  231.     /*************************************************
  232.      *
  233.      * inject cache helper
  234.      */
  235.     if (NULL != usmDHUserKeyTable_if_ctx.cache) {
  236.         handler =
  237.             netsnmp_cache_handler_get(usmDHUserKeyTable_if_ctx.cache);
  238.         netsnmp_inject_handler(reginfo, handler);
  239.     }
  240.     /*
  241.      * register table
  242.      */
  243.     netsnmp_register_table(reginfo, tbl_info);
  244. }                               /* _usmDHUserKeyTable_initialize_interface */
  245. void
  246. usmDHUserKeyTable_valid_columns_set(netsnmp_column_info *vc)
  247. {
  248.     usmDHUserKeyTable_if_ctx.tbl_info.valid_columns = vc;
  249. }                               /* usmDHUserKeyTable_valid_columns_set */
  250. /**
  251.  * @internal
  252.  * convert the index component stored in the context to an oid
  253.  */
  254. int
  255. usmDHUserKeyTable_index_to_oid(netsnmp_index * oid_idx,
  256.                                usmDHUserKeyTable_mib_index * mib_idx)
  257. {
  258.     int             err = SNMP_ERR_NOERROR;
  259.     /*
  260.      * temp storage for parsing indexes
  261.      */
  262.     /*
  263.      * usmUserEngineID(1)/SnmpEngineID/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
  264.      */
  265.     netsnmp_variable_list var_usmUserEngineID;
  266.     /*
  267.      * usmUserName(2)/SnmpAdminString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H
  268.      */
  269.     netsnmp_variable_list var_usmUserName;
  270.     /*
  271.      * set up varbinds
  272.      */
  273.     memset(&var_usmUserEngineID, 0x00, sizeof(var_usmUserEngineID));
  274.     var_usmUserEngineID.type = ASN_OCTET_STR;
  275.     memset(&var_usmUserName, 0x00, sizeof(var_usmUserName));
  276.     var_usmUserName.type = ASN_OCTET_STR;
  277.     /*
  278.      * chain temp index varbinds together
  279.      */
  280.     var_usmUserEngineID.next_variable = &var_usmUserName;
  281.     var_usmUserName.next_variable = NULL;
  282.     DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_index_to_oid",
  283.                 "calledn"));
  284.     /*
  285.      * usmUserEngineID(1)/SnmpEngineID/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h 
  286.      */
  287.     snmp_set_var_value(&var_usmUserEngineID,
  288.                        (u_char *) & mib_idx->usmUserEngineID,
  289.                        mib_idx->usmUserEngineID_len *
  290.                        sizeof(mib_idx->usmUserEngineID[0]));
  291.     /*
  292.      * usmUserName(2)/SnmpAdminString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H 
  293.      */
  294.     snmp_set_var_value(&var_usmUserName, (u_char *) & mib_idx->usmUserName,
  295.                        mib_idx->usmUserName_len *
  296.                        sizeof(mib_idx->usmUserName[0]));
  297.     err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len,
  298.                             NULL, 0, &var_usmUserEngineID);
  299.     if (err)
  300.         snmp_log(LOG_ERR, "error %d converting index to oidn");
  301.     /*
  302.      * parsing may have allocated memory. free it.
  303.      */
  304.     snmp_reset_var_buffers(&var_usmUserEngineID);
  305.     return err;
  306. }                               /* usmDHUserKeyTable_index_to_oid */
  307. /**
  308.  * extract usmDHUserKeyTable indexes from a netsnmp_index
  309.  *
  310.  * @retval SNMP_ERR_NOERROR  : no error
  311.  * @retval SNMP_ERR_GENERR   : error
  312.  */
  313. int
  314. usmDHUserKeyTable_index_from_oid(netsnmp_index * oid_idx,
  315.                                  usmDHUserKeyTable_mib_index * mib_idx)
  316. {
  317.     int             err = SNMP_ERR_NOERROR;
  318.     /*
  319.      * temp storage for parsing indexes
  320.      */
  321.     /*
  322.      * usmUserEngineID(1)/SnmpEngineID/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
  323.      */
  324.     netsnmp_variable_list var_usmUserEngineID;
  325.     /*
  326.      * usmUserName(2)/SnmpAdminString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H
  327.      */
  328.     netsnmp_variable_list var_usmUserName;
  329.     /*
  330.      * set up varbinds
  331.      */
  332.     memset(&var_usmUserEngineID, 0x00, sizeof(var_usmUserEngineID));
  333.     var_usmUserEngineID.type = ASN_OCTET_STR;
  334.     memset(&var_usmUserName, 0x00, sizeof(var_usmUserName));
  335.     var_usmUserName.type = ASN_OCTET_STR;
  336.     /*
  337.      * chain temp index varbinds together
  338.      */
  339.     var_usmUserEngineID.next_variable = &var_usmUserName;
  340.     var_usmUserName.next_variable = NULL;
  341.     DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_index_from_oid", "calledn"));
  342.     /*
  343.      * parse the oid into the individual index components
  344.      */
  345.     err = parse_oid_indexes(oid_idx->oids, oid_idx->len,
  346.                             &var_usmUserEngineID);
  347.     if (err == SNMP_ERR_NOERROR) {
  348.         /*
  349.          * copy out values
  350.          */
  351.         /*
  352.          * NOTE: val_len is in bytes, usmUserEngineID_len might not be
  353.          */
  354.         if (var_usmUserEngineID.val_len > sizeof(mib_idx->usmUserEngineID))
  355.             err = SNMP_ERR_GENERR;
  356.         else {
  357.             memcpy(mib_idx->usmUserEngineID,
  358.                    var_usmUserEngineID.val.string,
  359.                    var_usmUserEngineID.val_len);
  360.             mib_idx->usmUserEngineID_len =
  361.                 var_usmUserEngineID.val_len /
  362.                 sizeof(mib_idx->usmUserEngineID[0]);
  363.         }
  364.         /*
  365.          * NOTE: val_len is in bytes, usmUserName_len might not be
  366.          */
  367.         if (var_usmUserName.val_len > sizeof(mib_idx->usmUserName))
  368.             err = SNMP_ERR_GENERR;
  369.         else {
  370.             memcpy(mib_idx->usmUserName, var_usmUserName.val.string,
  371.                    var_usmUserName.val_len);
  372.             mib_idx->usmUserName_len =
  373.                 var_usmUserName.val_len / sizeof(mib_idx->usmUserName[0]);
  374.         }
  375.     }
  376.     /*
  377.      * parsing may have allocated memory. free it.
  378.      */
  379.     snmp_reset_var_buffers(&var_usmUserEngineID);
  380.     return err;
  381. }                               /* usmDHUserKeyTable_index_from_oid */
  382. /*
  383.  *********************************************************************
  384.  * @internal
  385.  * allocate resources for a usmDHUserKeyTable_rowreq_ctx
  386.  */
  387. usmDHUserKeyTable_rowreq_ctx *
  388. usmDHUserKeyTable_allocate_rowreq_ctx(usmDHUserKeyTable_data * data)
  389. {
  390.     usmDHUserKeyTable_rowreq_ctx *rowreq_ctx =
  391.         SNMP_MALLOC_TYPEDEF(usmDHUserKeyTable_rowreq_ctx);
  392.     DEBUGMSGTL(("internal:usmDHUserKeyTable:usmDHUserKeyTable_allocate_rowreq_ctx", "calledn"));
  393.     if (NULL == rowreq_ctx) {
  394.         snmp_log(LOG_ERR, "Couldn't allocate memory for a "
  395.                  "usmDHUserKeyTable_rowreq_ctx.n");
  396.     } else {
  397.         if (NULL != data) {
  398.             /*
  399.              * for non-transient data, track when we got data from user
  400.              */
  401.             rowreq_ctx->rowreq_flags |= MFD_ROW_DATA_FROM_USER;
  402.             rowreq_ctx->data = data;
  403.         } else if (NULL ==
  404.                    (rowreq_ctx->data =
  405.                     usmDHUserKeyTable_allocate_data())) {
  406.             SNMP_FREE(rowreq_ctx);
  407.             return NULL;
  408.         }
  409.     }
  410.     /*
  411.      * undo context will be allocated when needed (in *_undo_setup)
  412.      */
  413.     rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp;
  414.     rowreq_ctx->usmDHUserKeyTable_data_list = NULL;
  415.     rowreq_ctx->usmDHUserKeyTable_reg = usmDHUserKeyTable_if_ctx.user_ctx;
  416.     return rowreq_ctx;
  417. }                               /* usmDHUserKeyTable_allocate_rowreq_ctx */
  418. /*
  419.  * @internal
  420.  * release resources for a usmDHUserKeyTable_rowreq_ctx
  421.  */
  422. void
  423. usmDHUserKeyTable_release_rowreq_ctx(usmDHUserKeyTable_rowreq_ctx *
  424.                                      rowreq_ctx)
  425. {
  426.     DEBUGMSGTL(("internal:usmDHUserKeyTable:usmDHUserKeyTable_release_rowreq_ctx", "calledn"));
  427.     netsnmp_assert(NULL != rowreq_ctx);
  428.     /*
  429.      * for non-transient data, don't free data we got from the user
  430.      */
  431.     if ((rowreq_ctx->data) &&
  432.         !(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER))
  433.         usmDHUserKeyTable_release_data(rowreq_ctx->data);
  434.     if (rowreq_ctx->undo) {
  435.         usmDHUserKeyTable_release_data(rowreq_ctx->undo);
  436.         rowreq_ctx->undo = NULL;
  437.     }
  438.     /*
  439.      * free index oid pointer
  440.      */
  441.     if (rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp)
  442.         free(rowreq_ctx->oid_idx.oids);
  443.     SNMP_FREE(rowreq_ctx);
  444. }                               /* usmDHUserKeyTable_release_rowreq_ctx */
  445. /**
  446.  * @internal
  447.  * wrapper
  448.  */
  449. static int
  450. _mfd_usmDHUserKeyTable_pre_request(netsnmp_mib_handler *handler,
  451.                                    netsnmp_handler_registration *reginfo,
  452.                                    netsnmp_agent_request_info *agtreq_info,
  453.                                    netsnmp_request_info *requests)
  454. {
  455.     int             rc =
  456.         usmDHUserKeyTable_pre_request(usmDHUserKeyTable_if_ctx.user_ctx);
  457.     if (MFD_SUCCESS != rc) {
  458.         /*
  459.          * nothing we can do about it but log it
  460.          */
  461.         DEBUGMSGTL(("internal:usmDHUserKeyTable", "error %d from "
  462.                     "usmDHUserKeyTable_pre_requestn", rc));
  463.         netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
  464.     }
  465.     return SNMP_ERR_NOERROR;
  466. }                               /* _mfd_usmDHUserKeyTable_pre_request */
  467. /**
  468.  * @internal
  469.  * wrapper
  470.  */
  471. static int
  472. _mfd_usmDHUserKeyTable_post_request(netsnmp_mib_handler *handler,
  473.                                     netsnmp_handler_registration *reginfo,
  474.                                     netsnmp_agent_request_info
  475.                                     *agtreq_info,
  476.                                     netsnmp_request_info *requests)
  477. {
  478.     usmDHUserKeyTable_rowreq_ctx *rowreq_ctx;
  479.     int             rc =
  480.         usmDHUserKeyTable_post_request(usmDHUserKeyTable_if_ctx.user_ctx);
  481.     if (MFD_SUCCESS != rc) {
  482.         /*
  483.          * nothing we can do about it but log it
  484.          */
  485.         DEBUGMSGTL(("internal:usmDHUserKeyTable", "error %d from "
  486.                     "usmDHUserKeyTable_post_requestn", rc));
  487.     }
  488.     /*
  489.      * if there are no errors, check for and handle row creation/deletion
  490.      */
  491.     rc = netsnmp_check_requests_error(requests);
  492.     if ((SNMP_ERR_NOERROR == rc) &&
  493.         (NULL !=
  494.          (rowreq_ctx = netsnmp_container_table_row_extract(requests)))) {
  495.         if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) {
  496.         rowreq_ctx->rowreq_flags &= ~MFD_ROW_CREATED;
  497.             CONTAINER_INSERT(usmDHUserKeyTable_if_ctx.container,
  498.                              rowreq_ctx);
  499.         } else if (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED) {
  500.             CONTAINER_REMOVE(usmDHUserKeyTable_if_ctx.container,
  501.                              rowreq_ctx);
  502.             usmDHUserKeyTable_release_rowreq_ctx(rowreq_ctx);
  503.         }
  504.     }
  505.     return SNMP_ERR_NOERROR;
  506. }                               /* _mfd_usmDHUserKeyTable_post_request */
  507. /**
  508.  * @internal
  509.  * wrapper
  510.  */
  511. static int
  512. _mfd_usmDHUserKeyTable_object_lookup(netsnmp_mib_handler *handler,
  513.                                      netsnmp_handler_registration *reginfo,
  514.                                      netsnmp_agent_request_info
  515.                                      *agtreq_info,
  516.                                      netsnmp_request_info *requests)
  517. {
  518.     usmDHUserKeyTable_rowreq_ctx *rowreq_ctx =
  519.         netsnmp_container_table_row_extract(requests);
  520.     DEBUGMSGTL(("internal:usmDHUserKeyTable:_mfd_usmDHUserKeyTable_object_lookup", "calledn"));
  521.     /*
  522.      * get our context from mfd
  523.      * usmDHUserKeyTable_interface_ctx *if_ctx =
  524.      *             (usmDHUserKeyTable_interface_ctx *)reginfo->my_reg_void;
  525.      */
  526.     if (NULL == rowreq_ctx) {
  527.         netsnmp_request_set_error_all(requests, SNMP_ERR_NOCREATION);
  528.     } else {
  529.         usmDHUserKeyTable_row_prep(rowreq_ctx);
  530.     }
  531.     return SNMP_ERR_NOERROR;
  532. }                               /* _mfd_usmDHUserKeyTable_object_lookup */
  533. /***********************************************************************
  534.  *
  535.  * GET processing
  536.  *
  537.  ***********************************************************************/
  538. /*
  539.  * @internal
  540.  * Retrieve the value for a particular column
  541.  */
  542. NETSNMP_STATIC_INLINE int
  543. _usmDHUserKeyTable_get_column(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx,
  544.                               netsnmp_variable_list * var, int column)
  545. {
  546.     int             rc = SNMPERR_SUCCESS;
  547.     DEBUGMSGTL(("internal:usmDHUserKeyTable:_mfd_usmDHUserKeyTable_get_column", "calledn"));
  548.     netsnmp_assert(NULL != rowreq_ctx);
  549.     switch (column) {
  550.         /*
  551.          * usmDHUserAuthKeyChange(1)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
  552.          */
  553.     case COLUMN_USMDHUSERAUTHKEYCHANGE:
  554.         var->type = ASN_OCTET_STR;
  555.         rc = usmDHUserAuthKeyChange_get(rowreq_ctx,
  556.                                         (char **) &var->val.string,
  557.                                         &var->val_len);
  558.         break;
  559.         /*
  560.          * usmDHUserOwnAuthKeyChange(2)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
  561.          */
  562.     case COLUMN_USMDHUSEROWNAUTHKEYCHANGE:
  563.         var->type = ASN_OCTET_STR;
  564.         rc = usmDHUserOwnAuthKeyChange_get(rowreq_ctx,
  565.                                            (char **) &var->val.string,
  566.                                            &var->val_len);
  567.         break;
  568.         /*
  569.          * usmDHUserPrivKeyChange(3)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
  570.          */
  571.     case COLUMN_USMDHUSERPRIVKEYCHANGE:
  572.         var->type = ASN_OCTET_STR;
  573.         rc = usmDHUserPrivKeyChange_get(rowreq_ctx,
  574.                                         (char **) &var->val.string,
  575.                                         &var->val_len);
  576.         break;
  577.         /*
  578.          * usmDHUserOwnPrivKeyChange(4)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
  579.          */
  580.     case COLUMN_USMDHUSEROWNPRIVKEYCHANGE:
  581.         var->type = ASN_OCTET_STR;
  582.         rc = usmDHUserOwnPrivKeyChange_get(rowreq_ctx,
  583.                                            (char **) &var->val.string,
  584.                                            &var->val_len);
  585.         break;
  586.     default:
  587.         snmp_log(LOG_ERR,
  588.                  "unknown column %d in _usmDHUserKeyTable_get_columnn",
  589.                  column);
  590.         break;
  591.     }
  592.     return rc;
  593. }                               /* _usmDHUserKeyTable_get_column */
  594. int
  595. _mfd_usmDHUserKeyTable_get_values(netsnmp_mib_handler *handler,
  596.                                   netsnmp_handler_registration *reginfo,
  597.                                   netsnmp_agent_request_info *agtreq_info,
  598.                                   netsnmp_request_info *requests)
  599. {
  600.     usmDHUserKeyTable_rowreq_ctx *rowreq_ctx =
  601.         netsnmp_container_table_row_extract(requests);
  602.     netsnmp_table_request_info *tri;
  603.     u_char         *old_string;
  604.     void            (*dataFreeHook) (void *);
  605.     int             rc;
  606.     DEBUGMSGTL(("internal:usmDHUserKeyTable:_mfd_usmDHUserKeyTable_get_values", "calledn"));
  607.     netsnmp_assert(NULL != rowreq_ctx);
  608.     for (; requests; requests = requests->next) {
  609.         /*
  610.          * save old pointer, so we can free it if replaced
  611.          */
  612.         old_string = requests->requestvb->val.string;
  613.         dataFreeHook = requests->requestvb->dataFreeHook;
  614.         if (NULL == requests->requestvb->val.string) {
  615.             requests->requestvb->val.string = requests->requestvb->buf;
  616.             requests->requestvb->val_len =
  617.                 sizeof(requests->requestvb->buf);
  618.         } else if (requests->requestvb->buf ==
  619.                    requests->requestvb->val.string) {
  620.             if (requests->requestvb->val_len !=
  621.                 sizeof(requests->requestvb->buf))
  622.                 requests->requestvb->val_len =
  623.                     sizeof(requests->requestvb->buf);
  624.         }
  625.         /*
  626.          * get column data
  627.          */
  628.         tri = netsnmp_extract_table_info(requests);
  629.         if (NULL == tri)
  630.             continue;
  631.         rc = _usmDHUserKeyTable_get_column(rowreq_ctx, requests->requestvb,
  632.                                            tri->colnum);
  633.         if (rc) {
  634.             if (MFD_SKIP == rc) {
  635.                 requests->requestvb->type = ASN_PRIV_RETRY;
  636.                 rc = SNMP_ERR_NOERROR;
  637.             }
  638.         } else if (NULL == requests->requestvb->val.string) {
  639.             snmp_log(LOG_ERR, "NULL varbind data pointer!n");
  640.             rc = SNMP_ERR_GENERR;
  641.         }
  642.         if (rc)
  643.             netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc));
  644.         /*
  645.          * if the buffer wasn't used previously for the old data (i.e. it
  646.          * was allcoated memory)  and the get routine replaced the pointer,
  647.          * we need to free the previous pointer.
  648.          */
  649.         if (old_string && (old_string != requests->requestvb->buf) &&
  650.             (requests->requestvb->val.string != old_string)) {
  651.             if (dataFreeHook)
  652.                 (*dataFreeHook) (old_string);
  653.             else
  654.                 free(old_string);
  655.         }
  656.     }                           /* for results */
  657.     return SNMP_ERR_NOERROR;
  658. }                               /* _mfd_usmDHUserKeyTable_get_values */
  659. /***********************************************************************
  660.  *
  661.  * SET processing
  662.  *
  663.  ***********************************************************************/
  664. /*----------------------------------------------------------------------
  665.  *
  666.  * SET: Syntax checks
  667.  *
  668.  *---------------------------------------------------------------------*/
  669. /*
  670.  * @internal
  671.  * Check the syntax for a particular column
  672.  */
  673. NETSNMP_STATIC_INLINE int
  674. _usmDHUserKeyTable_check_column(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx,
  675.                                 netsnmp_variable_list * var, int column)
  676. {
  677.     int             rc = SNMPERR_SUCCESS;
  678.     DEBUGMSGTL(("internal:usmDHUserKeyTable:_usmDHUserKeyTable_check_column", "calledn"));
  679.     netsnmp_assert(NULL != rowreq_ctx);
  680.     switch (column) {
  681.         /*
  682.          * usmDHUserAuthKeyChange(1)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
  683.          */
  684.     case COLUMN_USMDHUSERAUTHKEYCHANGE:
  685.         rc = netsnmp_check_vb_type(var, ASN_OCTET_STR);
  686.         /*
  687.          * yyy-rks: anything else we can do here? 
  688.          */
  689.         if (SNMPERR_SUCCESS == rc) {
  690.             rc = usmDHUserAuthKeyChange_check_value(rowreq_ctx,
  691.                                                     (char *) var->val.
  692.                                                     string, var->val_len);
  693.             if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
  694.                 && (MFD_NOT_VALID_NOW != rc)) {
  695.                 snmp_log(LOG_ERR,
  696.                          "bad rc %d from usmDHUserAuthKeyChange_check_valuen",
  697.                          rc);
  698.                 rc = SNMP_ERR_GENERR;
  699.             }
  700.         }
  701.         break;
  702.         /*
  703.          * usmDHUserOwnAuthKeyChange(2)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
  704.          */
  705.     case COLUMN_USMDHUSEROWNAUTHKEYCHANGE:
  706.         rc = netsnmp_check_vb_type(var, ASN_OCTET_STR);
  707.         /*
  708.          * yyy-rks: anything else we can do here? 
  709.          */
  710.         if (SNMPERR_SUCCESS == rc) {
  711.             rc = usmDHUserOwnAuthKeyChange_check_value(rowreq_ctx,
  712.                                                        (char *) var->val.
  713.                                                        string,
  714.                                                        var->val_len);
  715.             if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
  716.                 && (MFD_NOT_VALID_NOW != rc)) {
  717.                 snmp_log(LOG_ERR,
  718.                          "bad rc %d from usmDHUserOwnAuthKeyChange_check_valuen",
  719.                          rc);
  720.                 rc = SNMP_ERR_GENERR;
  721.             }
  722.         }
  723.         break;
  724.         /*
  725.          * usmDHUserPrivKeyChange(3)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
  726.          */
  727.     case COLUMN_USMDHUSERPRIVKEYCHANGE:
  728.         rc = netsnmp_check_vb_type(var, ASN_OCTET_STR);
  729.         /*
  730.          * yyy-rks: anything else we can do here? 
  731.          */
  732.         if (SNMPERR_SUCCESS == rc) {
  733.             rc = usmDHUserPrivKeyChange_check_value(rowreq_ctx,
  734.                                                     (char *) var->val.
  735.                                                     string, var->val_len);
  736.             if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
  737.                 && (MFD_NOT_VALID_NOW != rc)) {
  738.                 snmp_log(LOG_ERR,
  739.                          "bad rc %d from usmDHUserPrivKeyChange_check_valuen",
  740.                          rc);
  741.                 rc = SNMP_ERR_GENERR;
  742.             }
  743.         }
  744.         break;
  745.         /*
  746.          * usmDHUserOwnPrivKeyChange(4)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
  747.          */
  748.     case COLUMN_USMDHUSEROWNPRIVKEYCHANGE:
  749.         rc = netsnmp_check_vb_type(var, ASN_OCTET_STR);
  750.         /*
  751.          * yyy-rks: anything else we can do here? 
  752.          */
  753.         if (SNMPERR_SUCCESS == rc) {
  754.             rc = usmDHUserOwnPrivKeyChange_check_value(rowreq_ctx,
  755.                                                        (char *) var->val.
  756.                                                        string,
  757.                                                        var->val_len);
  758.             if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
  759.                 && (MFD_NOT_VALID_NOW != rc)) {
  760.                 snmp_log(LOG_ERR,
  761.                          "bad rc %d from usmDHUserOwnPrivKeyChange_check_valuen",
  762.                          rc);
  763.                 rc = SNMP_ERR_GENERR;
  764.             }
  765.         }
  766.         break;
  767.     default:   /** We shouldn't get here */
  768.         rc = SNMP_ERR_GENERR;
  769.         snmp_log(LOG_ERR,
  770.                  "unknown column %d in _usmDHUserKeyTable_check_columnn",
  771.                  column);
  772.     }
  773.     return rc;
  774. }                               /* _usmDHUserKeyTable_check_column */
  775. int
  776. _mfd_usmDHUserKeyTable_check_objects(netsnmp_mib_handler *handler,
  777.                                      netsnmp_handler_registration *reginfo,
  778.                                      netsnmp_agent_request_info
  779.                                      *agtreq_info,
  780.                                      netsnmp_request_info *requests)
  781. {
  782.     usmDHUserKeyTable_rowreq_ctx *rowreq_ctx =
  783.         netsnmp_container_table_row_extract(requests);
  784.     netsnmp_table_request_info *tri;
  785.     int             rc;
  786.     DEBUGMSGTL(("internal:usmDHUserKeyTable:_mfd_usmDHUserKeyTable_check_objects", "calledn"));
  787.     netsnmp_assert(NULL != rowreq_ctx);
  788.     for (; requests; requests = requests->next) {
  789.         /*
  790.          * get column number from table request info, and check that column
  791.          */
  792.         tri = netsnmp_extract_table_info(requests);
  793.         if (NULL == tri)
  794.             continue;
  795.         rc = _usmDHUserKeyTable_check_column(rowreq_ctx,
  796.                                              requests->requestvb,
  797.                                              tri->colnum);
  798.         if (rc) {
  799.             netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc));
  800.             break;
  801.         }
  802.     }                           /* for results */
  803.     return SNMP_ERR_NOERROR;
  804. }                               /* _mfd_usmDHUserKeyTable_check_objects */
  805. /*----------------------------------------------------------------------
  806.  *
  807.  * SET: check dependencies
  808.  *
  809.  *---------------------------------------------------------------------*/
  810. /*
  811.  * @internal
  812.  * Check dependencies wrapper
  813.  */
  814. static int
  815. _mfd_usmDHUserKeyTable_check_dependencies(netsnmp_mib_handler *handler, netsnmp_handler_registration
  816.                                           *reginfo, netsnmp_agent_request_info
  817.                                           *agtreq_info,
  818.                                           netsnmp_request_info *requests)
  819. {
  820.     int             rc;
  821.     usmDHUserKeyTable_rowreq_ctx *rowreq_ctx =
  822.         netsnmp_container_table_row_extract(requests);
  823.     DEBUGMSGTL(("internal:usmDHUserKeyTable:_mfd_usmDHUserKeyTable_check_dependencies", "calledn"));
  824.     netsnmp_assert(NULL != rowreq_ctx);
  825.     rc = usmDHUserKeyTable_check_dependencies(rowreq_ctx);
  826.     if (rc) {
  827.         DEBUGMSGTL(("verbose:usmDHUserKeyTable:mfd", "error %d from "
  828.                     "usmDHUserKeyTable_check_dependenciesn", rc));
  829.         netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
  830.     }
  831.     return SNMP_ERR_NOERROR;
  832. }                               /* _mfd_usmDHUserKeyTable_check_dependencies */
  833. /*----------------------------------------------------------------------
  834.  *
  835.  * SET: Undo setup
  836.  *
  837.  *---------------------------------------------------------------------*/
  838. /*
  839.  * @internal
  840.  * Set the value for a particular column
  841.  */
  842. NETSNMP_STATIC_INLINE int
  843. _usmDHUserKeyTable_undo_setup_column(usmDHUserKeyTable_rowreq_ctx *
  844.                                      rowreq_ctx, int column)
  845. {
  846.     int             rc = SNMPERR_SUCCESS;
  847.     DEBUGMSGTL(("internal:usmDHUserKeyTable:_usmDHUserKeyTable_undo_setup_column", "calledn"));
  848.     netsnmp_assert(NULL != rowreq_ctx);
  849.     switch (column) {
  850.         /*
  851.          * usmDHUserAuthKeyChange(1)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
  852.          */
  853.     case COLUMN_USMDHUSERAUTHKEYCHANGE:
  854.         rowreq_ctx->column_set_flags |= FLAG_USMDHUSERAUTHKEYCHANGE;
  855.         rc = usmDHUserAuthKeyChange_undo_setup(rowreq_ctx);
  856.         break;
  857.         /*
  858.          * usmDHUserOwnAuthKeyChange(2)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
  859.          */
  860.     case COLUMN_USMDHUSEROWNAUTHKEYCHANGE:
  861.         rowreq_ctx->column_set_flags |= FLAG_USMDHUSEROWNAUTHKEYCHANGE;
  862.         rc = usmDHUserOwnAuthKeyChange_undo_setup(rowreq_ctx);
  863.         break;
  864.         /*
  865.          * usmDHUserPrivKeyChange(3)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
  866.          */
  867.     case COLUMN_USMDHUSERPRIVKEYCHANGE:
  868.         rowreq_ctx->column_set_flags |= FLAG_USMDHUSERPRIVKEYCHANGE;
  869.         rc = usmDHUserPrivKeyChange_undo_setup(rowreq_ctx);
  870.         break;
  871.         /*
  872.          * usmDHUserOwnPrivKeyChange(4)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
  873.          */
  874.     case COLUMN_USMDHUSEROWNPRIVKEYCHANGE:
  875.         rowreq_ctx->column_set_flags |= FLAG_USMDHUSEROWNPRIVKEYCHANGE;
  876.         rc = usmDHUserOwnPrivKeyChange_undo_setup(rowreq_ctx);
  877.         break;
  878.     default:
  879.         snmp_log(LOG_ERR,
  880.                  "unknown column %d in _usmDHUserKeyTable_undo_setup_columnn",
  881.                  column);
  882.         break;
  883.     }
  884.     return rc;
  885. }                               /* _usmDHUserKeyTable_undo_setup_column */
  886. /**
  887.  * @internal
  888.  * undo setup
  889.  */
  890. int
  891. _mfd_usmDHUserKeyTable_undo_setup(netsnmp_mib_handler *handler,
  892.                                   netsnmp_handler_registration *reginfo,
  893.                                   netsnmp_agent_request_info *agtreq_info,
  894.                                   netsnmp_request_info *requests)
  895. {
  896.     int             rc;
  897.     usmDHUserKeyTable_rowreq_ctx *rowreq_ctx =
  898.         netsnmp_container_table_row_extract(requests);
  899.     DEBUGMSGTL(("internal:usmDHUserKeyTable:_mfd_usmDHUserKeyTable_undo_setup", "calledn"));
  900.     netsnmp_assert(NULL != rowreq_ctx);
  901.     /*
  902.      * allocate undo context
  903.      */
  904.     rowreq_ctx->undo = usmDHUserKeyTable_allocate_data();
  905.     if (NULL == rowreq_ctx->undo) {
  906.         /** msg already logged */
  907.         netsnmp_request_set_error_all(requests,
  908.                                       SNMP_ERR_RESOURCEUNAVAILABLE);
  909.         return SNMP_ERR_NOERROR;
  910.     }
  911.     /*
  912.      * row undo setup
  913.      */
  914.     rowreq_ctx->column_set_flags = 0;
  915.     rc = usmDHUserKeyTable_undo_setup(rowreq_ctx);
  916.     if (MFD_SUCCESS != rc) {
  917.         DEBUGMSGTL(("verbose:usmDHUserKeyTable:mfd", "error %d from "
  918.                     "usmDHUserKeyTable_undo_setupn", rc));
  919.         netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
  920.     } else {
  921.         /*
  922.          * column undo setup
  923.          */
  924.         netsnmp_table_request_info *tri;
  925.         for (; requests; requests = requests->next) {
  926.             /*
  927.              * set column data
  928.              */
  929.             tri = netsnmp_extract_table_info(requests);
  930.             if (NULL == tri)
  931.                 continue;
  932.             rc = _usmDHUserKeyTable_undo_setup_column(rowreq_ctx,
  933.                                                       tri->colnum);
  934.             if (MFD_SUCCESS != rc) {
  935.                 DEBUGMSGTL(("verbose:usmDHUserKeyTable:mfd",
  936.                             "error %d from "
  937.                             "usmDHUserKeyTable_undo_setup_columnn", rc));
  938.                 netsnmp_set_request_error(agtreq_info, requests,
  939.                                           SNMP_VALIDATE_ERR(rc));
  940.             }
  941.         }                       /* for results */
  942.     }
  943.     return SNMP_ERR_NOERROR;
  944. }                               /* _mfd_usmDHUserKeyTable_undo_setup */
  945. /**
  946.  * @internal
  947.  * undo setup
  948.  */
  949. int
  950. _mfd_usmDHUserKeyTable_undo_cleanup(netsnmp_mib_handler *handler,
  951.                                     netsnmp_handler_registration *reginfo,
  952.                                     netsnmp_agent_request_info
  953.                                     *agtreq_info,
  954.                                     netsnmp_request_info *requests)
  955. {
  956.     usmDHUserKeyTable_rowreq_ctx *rowreq_ctx =
  957.         netsnmp_container_table_row_extract(requests);
  958.     int             rc;
  959.     DEBUGMSGTL(("internal:usmDHUserKeyTable:_mfd_usmDHUserKeyTable_undo_cleanup", "calledn"));
  960.     /*
  961.      * failed row create in early stages has no rowreq_ctx
  962.      */
  963.     if (NULL == rowreq_ctx)
  964.         return MFD_SUCCESS;
  965.     /*
  966.      * call user cleanup
  967.      */
  968.     rc = usmDHUserKeyTable_undo_cleanup(rowreq_ctx);
  969.     if (MFD_SUCCESS != rc) {
  970.         /*
  971.          * nothing we can do about it but log it
  972.          */
  973.         DEBUGMSGTL(("verbose:usmDHUserKeyTable:mfd", "error %d from "
  974.                     "usmDHUserKeyTable_undo_cleanupn", rc));
  975.     }
  976.     /*
  977.      * release undo context, if needed
  978.      */
  979.     if (rowreq_ctx->undo) {
  980.         usmDHUserKeyTable_release_data(rowreq_ctx->undo);
  981.         rowreq_ctx->undo = NULL;
  982.     }
  983.     /*
  984.      * clear set flags
  985.      */
  986.     rowreq_ctx->column_set_flags = 0;
  987.     return SNMP_ERR_NOERROR;
  988. }                               /* _mfd_usmDHUserKeyTable_undo_cleanup */
  989. /*----------------------------------------------------------------------
  990.  *
  991.  * SET: Set values
  992.  *
  993.  *---------------------------------------------------------------------*/
  994. /*
  995.  * @internal
  996.  * Set the value for a particular column
  997.  */
  998. NETSNMP_STATIC_INLINE int
  999. _usmDHUserKeyTable_set_column(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx,
  1000.                               netsnmp_variable_list * var, int column)
  1001. {
  1002.     int             rc = SNMPERR_SUCCESS;
  1003.     DEBUGMSGTL(("internal:usmDHUserKeyTable:_usmDHUserKeyTable_set_column",
  1004.                 "calledn"));
  1005.     netsnmp_assert(NULL != rowreq_ctx);
  1006.     switch (column) {
  1007.         /*
  1008.          * usmDHUserAuthKeyChange(1)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
  1009.          */
  1010.     case COLUMN_USMDHUSERAUTHKEYCHANGE:
  1011.         rowreq_ctx->column_set_flags |= FLAG_USMDHUSERAUTHKEYCHANGE;
  1012.         rc = usmDHUserAuthKeyChange_set(rowreq_ctx,
  1013.                                         (char *) var->val.string,
  1014.                                         var->val_len);
  1015.         break;
  1016.         /*
  1017.          * usmDHUserOwnAuthKeyChange(2)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
  1018.          */
  1019.     case COLUMN_USMDHUSEROWNAUTHKEYCHANGE:
  1020.         rowreq_ctx->column_set_flags |= FLAG_USMDHUSEROWNAUTHKEYCHANGE;
  1021.         rc = usmDHUserOwnAuthKeyChange_set(rowreq_ctx,
  1022.                                            (char *) var->val.string,
  1023.                                            var->val_len);
  1024.         break;
  1025.         /*
  1026.          * usmDHUserPrivKeyChange(3)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
  1027.          */
  1028.     case COLUMN_USMDHUSERPRIVKEYCHANGE:
  1029.         rowreq_ctx->column_set_flags |= FLAG_USMDHUSERPRIVKEYCHANGE;
  1030.         rc = usmDHUserPrivKeyChange_set(rowreq_ctx,
  1031.                                         (char *) var->val.string,
  1032.                                         var->val_len);
  1033.         break;
  1034.         /*
  1035.          * usmDHUserOwnPrivKeyChange(4)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
  1036.          */
  1037.     case COLUMN_USMDHUSEROWNPRIVKEYCHANGE:
  1038.         rowreq_ctx->column_set_flags |= FLAG_USMDHUSEROWNPRIVKEYCHANGE;
  1039.         rc = usmDHUserOwnPrivKeyChange_set(rowreq_ctx,
  1040.                                            (char *) var->val.string,
  1041.                                            var->val_len);
  1042.         break;
  1043.     default:
  1044.         snmp_log(LOG_ERR,
  1045.                  "unknown column %d in _usmDHUserKeyTable_set_columnn",
  1046.                  column);
  1047.         break;
  1048.     }
  1049.     return rc;
  1050. }                               /* _usmDHUserKeyTable_set_column */
  1051. int
  1052. _mfd_usmDHUserKeyTable_set_values(netsnmp_mib_handler *handler,
  1053.                                   netsnmp_handler_registration *reginfo,
  1054.                                   netsnmp_agent_request_info *agtreq_info,
  1055.                                   netsnmp_request_info *requests)
  1056. {
  1057.     usmDHUserKeyTable_rowreq_ctx *rowreq_ctx =
  1058.         netsnmp_container_table_row_extract(requests);
  1059.     netsnmp_table_request_info *tri;
  1060.     int             rc = SNMP_ERR_NOERROR;
  1061.     DEBUGMSGTL(("internal:usmDHUserKeyTable:_mfd_usmDHUserKeyTable_set_values", "calledn"));
  1062.     netsnmp_assert(NULL != rowreq_ctx);
  1063.     rowreq_ctx->column_set_flags = 0;
  1064.     for (; requests; requests = requests->next) {
  1065.         /*
  1066.          * set column data
  1067.          */
  1068.         tri = netsnmp_extract_table_info(requests);
  1069.         if (NULL == tri)
  1070.             continue;
  1071.         rc = _usmDHUserKeyTable_set_column(rowreq_ctx,
  1072.                                            requests->requestvb,
  1073.                                            tri->colnum);
  1074.         if (MFD_SUCCESS != rc) {
  1075.             DEBUGMSGTL(("verbose:usmDHUserKeyTable:mfd", "error %d from "
  1076.                         "usmDHUserKeyTable_set_columnn", rc));
  1077.             netsnmp_set_request_error(agtreq_info, requests,
  1078.                                       SNMP_VALIDATE_ERR(rc));
  1079.         }
  1080.     }                           /* for results */
  1081.     return SNMP_ERR_NOERROR;
  1082. }                               /* _mfd_usmDHUserKeyTable_set_values */
  1083. /*----------------------------------------------------------------------
  1084.  *
  1085.  * SET: commit
  1086.  *
  1087.  *---------------------------------------------------------------------*/
  1088. /**
  1089.  * @internal
  1090.  * commit the values
  1091.  */
  1092. int
  1093. _mfd_usmDHUserKeyTable_commit(netsnmp_mib_handler *handler,
  1094.                               netsnmp_handler_registration *reginfo,
  1095.                               netsnmp_agent_request_info *agtreq_info,
  1096.                               netsnmp_request_info *requests)
  1097. {
  1098.     int             rc;
  1099.     usmDHUserKeyTable_rowreq_ctx *rowreq_ctx =
  1100.         netsnmp_container_table_row_extract(requests);
  1101.     DEBUGMSGTL(("internal:usmDHUserKeyTable:_mfd_usmDHUserKeyTable_commit",
  1102.                 "calledn"));
  1103.     netsnmp_assert(NULL != rowreq_ctx);
  1104.     rc = usmDHUserKeyTable_commit(rowreq_ctx);
  1105.     if (MFD_SUCCESS != rc) {
  1106.         DEBUGMSGTL(("verbose:usmDHUserKeyTable:mfd", "error %d from "
  1107.                     "usmDHUserKeyTable_commitn", rc));
  1108.         netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
  1109.     }
  1110.     return SNMP_ERR_NOERROR;
  1111. }
  1112. int
  1113. _mfd_usmDHUserKeyTable_undo_commit(netsnmp_mib_handler *handler,
  1114.                                    netsnmp_handler_registration *reginfo,
  1115.                                    netsnmp_agent_request_info *agtreq_info,
  1116.                                    netsnmp_request_info *requests)
  1117. {
  1118.     int             rc;
  1119.     usmDHUserKeyTable_rowreq_ctx *rowreq_ctx =
  1120.         netsnmp_container_table_row_extract(requests);
  1121.     DEBUGMSGTL(("internal:usmDHUserKeyTable:_mfd_usmDHUserKeyTable_undo_commit", "calledn"));
  1122.     netsnmp_assert(NULL != rowreq_ctx);
  1123.     rc = usmDHUserKeyTable_undo_commit(rowreq_ctx);
  1124.     if (MFD_SUCCESS != rc) {
  1125.         /*
  1126.          * nothing we can do about it but log it
  1127.          */
  1128.         DEBUGMSGTL(("verbose:usmDHUserKeyTable:mfd", "error %d from "
  1129.                     "usmDHUserKeyTable_undo_commitn", rc));
  1130.     }
  1131.     return SNMP_ERR_NOERROR;
  1132. }                               /* _mfd_usmDHUserKeyTable_commit */
  1133. /*----------------------------------------------------------------------
  1134.  *
  1135.  * SET: Undo
  1136.  *
  1137.  *---------------------------------------------------------------------*/
  1138. /**
  1139.  * @internal
  1140.  * undo the value for a particular column
  1141.  */
  1142. NETSNMP_STATIC_INLINE int
  1143. _usmDHUserKeyTable_undo_column(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx,
  1144.                                netsnmp_variable_list * var, int column)
  1145. {
  1146.     int             rc = SNMPERR_SUCCESS;
  1147.     DEBUGMSGTL(("internal:usmDHUserKeyTable:_usmDHUserKeyTable_undo_column", "calledn"));
  1148.     netsnmp_assert(NULL != rowreq_ctx);
  1149.     switch (column) {
  1150.         /*
  1151.          * usmDHUserAuthKeyChange(1)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
  1152.          */
  1153.     case COLUMN_USMDHUSERAUTHKEYCHANGE:
  1154.         rc = usmDHUserAuthKeyChange_undo(rowreq_ctx);
  1155.         break;
  1156.         /*
  1157.          * usmDHUserOwnAuthKeyChange(2)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
  1158.          */
  1159.     case COLUMN_USMDHUSEROWNAUTHKEYCHANGE:
  1160.         rc = usmDHUserOwnAuthKeyChange_undo(rowreq_ctx);
  1161.         break;
  1162.         /*
  1163.          * usmDHUserPrivKeyChange(3)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
  1164.          */
  1165.     case COLUMN_USMDHUSERPRIVKEYCHANGE:
  1166.         rc = usmDHUserPrivKeyChange_undo(rowreq_ctx);
  1167.         break;
  1168.         /*
  1169.          * usmDHUserOwnPrivKeyChange(4)/DHKeyChange/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h 
  1170.          */
  1171.     case COLUMN_USMDHUSEROWNPRIVKEYCHANGE:
  1172.         rc = usmDHUserOwnPrivKeyChange_undo(rowreq_ctx);
  1173.         break;
  1174.     default:
  1175.         snmp_log(LOG_ERR,
  1176.                  "unknown column %d in _usmDHUserKeyTable_undo_columnn",
  1177.                  column);
  1178.         break;
  1179.     }
  1180.     return rc;
  1181. }                               /* _usmDHUserKeyTable_undo_column */
  1182. int
  1183. _mfd_usmDHUserKeyTable_undo_values(netsnmp_mib_handler *handler,
  1184.                                    netsnmp_handler_registration *reginfo,
  1185.                                    netsnmp_agent_request_info *agtreq_info,
  1186.                                    netsnmp_request_info *requests)
  1187. {
  1188.     int             rc;
  1189.     usmDHUserKeyTable_rowreq_ctx *rowreq_ctx =
  1190.         netsnmp_container_table_row_extract(requests);
  1191.     netsnmp_table_request_info *tri;
  1192.     DEBUGMSGTL(("internal:usmDHUserKeyTable:_mfd_usmDHUserKeyTable_undo_values", "calledn"));
  1193.     netsnmp_assert(NULL != rowreq_ctx);
  1194.     for (; requests; requests = requests->next) {
  1195.         /*
  1196.          * set column data
  1197.          */
  1198.         tri = netsnmp_extract_table_info(requests);
  1199.         if (NULL == tri)
  1200.             continue;
  1201.         rc = _usmDHUserKeyTable_undo_column(rowreq_ctx,
  1202.                                             requests->requestvb,
  1203.                                             tri->colnum);
  1204.         if (MFD_SUCCESS != rc) {
  1205.             /*
  1206.              * nothing we can do about it but log it
  1207.              */
  1208.             DEBUGMSGTL(("verbose:usmDHUserKeyTable:mfd", "error %d from "
  1209.                         "usmDHUserKeyTable_undo_columnn", rc));
  1210.         }
  1211.     }                           /* for results */
  1212.     return SNMP_ERR_NOERROR;
  1213. }                               /* _mfd_usmDHUserKeyTable_undo_values */
  1214. /*----------------------------------------------------------------------
  1215.  *
  1216.  * SET: irreversible commit
  1217.  *
  1218.  *---------------------------------------------------------------------*/
  1219. /**
  1220.  * @internal
  1221.  * commit irreversible actions
  1222.  */
  1223. int
  1224. _mfd_usmDHUserKeyTable_irreversible_commit(netsnmp_mib_handler *handler, netsnmp_handler_registration
  1225.                                            *reginfo, netsnmp_agent_request_info
  1226.                                            *agtreq_info,
  1227.                                            netsnmp_request_info *requests)
  1228. {
  1229.     int             rc;
  1230.     usmDHUserKeyTable_rowreq_ctx *rowreq_ctx =
  1231.         netsnmp_container_table_row_extract(requests);
  1232.     DEBUGMSGTL(("internal:usmDHUserKeyTable:_mfd_usmDHUserKeyTable_irreversible:commit", "calledn"));
  1233.     netsnmp_assert(NULL != rowreq_ctx);
  1234.     rc = usmDHUserKeyTable_irreversible_commit(rowreq_ctx);
  1235.     if (MFD_SUCCESS != rc) {
  1236.         netsnmp_request_set_error_all(requests, SNMP_ERR_COMMITFAILED);
  1237.         DEBUGMSGTL(("verbose:usmDHUserKeyTable:mfd", "error %d from "
  1238.                     "usmDHUserKeyTable_irreversible_commitn", rc));
  1239.     }
  1240.     return SNMP_ERR_NOERROR;
  1241. }                               /* _mfd_usmDHUserKeyTable_irreversible_commit */
  1242. /***********************************************************************
  1243.  *
  1244.  * DATA ACCESS
  1245.  *
  1246.  ***********************************************************************/
  1247. /**
  1248.  * @internal
  1249.  */
  1250. static int
  1251. _cache_load(netsnmp_cache * cache, void *vmagic)
  1252. {
  1253.     DEBUGMSGTL(("internal:usmDHUserKeyTable:_cache_load", "calledn"));
  1254.     if ((NULL == cache) || (NULL == cache->magic)) {
  1255.         snmp_log(LOG_ERR,
  1256.                  "invalid cache for usmDHUserKeyTable_cache_loadn");
  1257.         return -1;
  1258.     }
  1259.     /** should only be called for an invalid or expired cache */
  1260.     netsnmp_assert((0 == cache->valid) || (1 == cache->expired));
  1261.     /*
  1262.      * call user code
  1263.      */
  1264.     return usmDHUserKeyTable_cache_load((netsnmp_container *) cache->
  1265.                                         magic);
  1266. }                               /* _cache_load */
  1267. /**
  1268.  * @internal
  1269.  */
  1270. static void
  1271. _cache_item_free(usmDHUserKeyTable_rowreq_ctx * rowreq_ctx, void *context)
  1272. {
  1273.     DEBUGMSGTL(("internal:usmDHUserKeyTable:_cache_item_free",
  1274.                 "calledn"));
  1275.     if (NULL == rowreq_ctx)
  1276.         return;
  1277.     usmDHUserKeyTable_release_rowreq_ctx(rowreq_ctx);
  1278. }                               /* _cache_item_free */
  1279. /**
  1280.  * @internal
  1281.  */
  1282. static void
  1283. _cache_free(netsnmp_cache * cache, void *magic)
  1284. {
  1285.     netsnmp_container *container;
  1286.     DEBUGMSGTL(("internal:usmDHUserKeyTable:_cache_free", "calledn"));
  1287.     if ((NULL == cache) || (NULL == cache->magic)) {
  1288.         snmp_log(LOG_ERR,
  1289.                  "invalid cache in usmDHUserKeyTable_cache_freen");
  1290.         return;
  1291.     }
  1292.     container = (netsnmp_container *) cache->magic;
  1293.     /*
  1294.      * call user code
  1295.      */
  1296.     usmDHUserKeyTable_cache_free(container);
  1297.     /*
  1298.      * free all items. inefficient, but easy.
  1299.      */
  1300.     CONTAINER_CLEAR(container,
  1301.                     (netsnmp_container_obj_func *) _cache_item_free, NULL);
  1302. }                               /* _cache_free */
  1303. /**
  1304.  * @internal
  1305.  * initialize the iterator container with functions or wrappers
  1306.  */
  1307. void
  1308. _usmDHUserKeyTable_container_init(usmDHUserKeyTable_interface_ctx * if_ctx)
  1309. {
  1310.     DEBUGMSGTL(("internal:usmDHUserKeyTable:_usmDHUserKeyTable_container_init", "calledn"));
  1311.     /*
  1312.      * set up the cache
  1313.      */
  1314.     if_ctx->cache = netsnmp_cache_create(30,    /* timeout in seconds */
  1315.                                          _cache_load, _cache_free,
  1316.                                          usmDHUserKeyTable_oid,
  1317.                                          usmDHUserKeyTable_oid_size);
  1318.     if (NULL == if_ctx->cache) {
  1319.         snmp_log(LOG_ERR, "error creating cache for usmDHUserKeyTablen");
  1320.         return;
  1321.     }
  1322.     if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET;
  1323.     usmDHUserKeyTable_container_init(&if_ctx->container, if_ctx->cache);
  1324.     if (NULL == if_ctx->container)
  1325.         if_ctx->container =
  1326.             netsnmp_container_find("usmDHUserKeyTable:table_container");
  1327.     if (NULL == if_ctx->container) {
  1328.         snmp_log(LOG_ERR, "error creating container in "
  1329.                  "usmDHUserKeyTable_container_initn");
  1330.         return;
  1331.     }
  1332.     if_ctx->cache->magic = (void *) if_ctx->container;
  1333. }                               /* _usmDHUserKeyTable_container_init */