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

SNMP编程

开发平台:

Unix_Linux

  1. /*
  2.  * Note: this file originally auto-generated by mib2c using
  3.  *       version : 1.42 $ of : mfd-interface.m2c,v $ 
  4.  *
  5.  * $Id: ifXTable_interface.c,v 1.11.2.2 2005/03/29 21:05:24 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 "ifXTable.h"
  38. #include <net-snmp/library/container.h>
  39. #include "ifXTable_interface.h"
  40. #include "if-mib/ifTable/ifTable_interface.h"
  41. /**********************************************************************
  42.  **********************************************************************
  43.  ***
  44.  *** Table ifXTable
  45.  ***
  46.  **********************************************************************
  47.  **********************************************************************/
  48. /*
  49.  * ifXTable is subid 1 of ifMIBObjects.
  50.  * Its status is Current.
  51.  * OID: .1.3.6.1.2.1.31.1.1, length: 9
  52.  */
  53. typedef struct ifXTable_interface_ctx_s {
  54.     netsnmp_container *container;
  55.     netsnmp_cache  *cache;      /* optional cache */
  56.     ifXTable_registration_ptr user_ctx;
  57.     netsnmp_table_registration_info tbl_info;
  58.     netsnmp_baby_steps_access_methods access_multiplexer;
  59. } ifXTable_interface_ctx;
  60. static ifXTable_interface_ctx ifXTable_if_ctx;
  61. static void     _ifXTable_container_init(ifXTable_interface_ctx * if_ctx);
  62. static Netsnmp_Node_Handler _mfd_ifXTable_pre_request;
  63. static Netsnmp_Node_Handler _mfd_ifXTable_post_request;
  64. static Netsnmp_Node_Handler _mfd_ifXTable_object_lookup;
  65. static Netsnmp_Node_Handler _mfd_ifXTable_get_values;
  66. static Netsnmp_Node_Handler _mfd_ifXTable_check_objects;
  67. static Netsnmp_Node_Handler _mfd_ifXTable_undo_setup;
  68. static Netsnmp_Node_Handler _mfd_ifXTable_set_values;
  69. static Netsnmp_Node_Handler _mfd_ifXTable_undo_cleanup;
  70. static Netsnmp_Node_Handler _mfd_ifXTable_undo_values;
  71. static Netsnmp_Node_Handler _mfd_ifXTable_commit;
  72. static Netsnmp_Node_Handler _mfd_ifXTable_undo_commit;
  73. static Netsnmp_Node_Handler _mfd_ifXTable_check_dependencies;
  74. NETSNMP_STATIC_INLINE int _ifXTable_undo_column(ifXTable_rowreq_ctx *
  75.                                                 rowreq_ctx,
  76.                                                 netsnmp_variable_list *
  77.                                                 var, int column);
  78. ifXTable_data  *ifXTable_allocate_data(void);
  79. /**
  80.  * @internal
  81.  * Initialize the table ifXTable 
  82.  *    (Define its contents and how it's structured)
  83.  */
  84. void
  85. _ifXTable_initialize_interface(ifXTable_registration_ptr reg_ptr,
  86.                                u_long flags)
  87. {
  88.     netsnmp_baby_steps_access_methods *access_multiplexer =
  89.         &ifXTable_if_ctx.access_multiplexer;
  90.     netsnmp_table_registration_info *tbl_info = &ifXTable_if_ctx.tbl_info;
  91.     netsnmp_handler_registration *reginfo;
  92.     netsnmp_mib_handler *handler;
  93.     int             mfd_modes = 0;
  94.     DEBUGMSGTL(("internal:ifXTable:_ifXTable_initialize_interface",
  95.                 "calledn"));
  96.     /*
  97.      * make sure the ifTable container has been initialized, since
  98.      * we use its container, and we can't guarantee that it has
  99.      * already been initialized.
  100.      */
  101.     (void)if_mib_container_init();
  102.     /*************************************************
  103.      *
  104.      * save interface context for ifXTable
  105.      */
  106.     /*
  107.      * Setting up the table's definition
  108.      */
  109.     netsnmp_table_helper_add_indexes(tbl_info, ASN_INTEGER,
  110.                                                /** index: ifIndex */
  111.                                      0);
  112.     /*
  113.      * Define the minimum and maximum accessible columns.  This
  114.      * optimizes retrival. 
  115.      */
  116.     tbl_info->min_column = IFXTABLE_MIN_COL;
  117.     tbl_info->max_column = IFXTABLE_MAX_COL;
  118.     /*
  119.      * save users context
  120.      */
  121.     ifXTable_if_ctx.user_ctx = reg_ptr;
  122.     /*
  123.      * call data access initialization code
  124.      */
  125.     ifXTable_init_data(reg_ptr);
  126.     /*
  127.      * set up the container
  128.      */
  129.     _ifXTable_container_init(&ifXTable_if_ctx);
  130.     if (NULL == ifXTable_if_ctx.container)
  131.         return; /* msg already logged */
  132.     /*
  133.      * access_multiplexer: REQUIRED wrapper for get request handling
  134.      */
  135.     access_multiplexer->object_lookup = _mfd_ifXTable_object_lookup;
  136.     access_multiplexer->get_values = _mfd_ifXTable_get_values;
  137.     /*
  138.      * no wrappers yet
  139.      */
  140.     access_multiplexer->pre_request = _mfd_ifXTable_pre_request;
  141.     access_multiplexer->post_request = _mfd_ifXTable_post_request;
  142.     /*
  143.      * REQUIRED wrappers for set request handling
  144.      */
  145.     access_multiplexer->object_syntax_checks = _mfd_ifXTable_check_objects;
  146.     access_multiplexer->undo_setup = _mfd_ifXTable_undo_setup;
  147.     access_multiplexer->undo_cleanup = _mfd_ifXTable_undo_cleanup;
  148.     access_multiplexer->set_values = _mfd_ifXTable_set_values;
  149.     access_multiplexer->undo_sets = _mfd_ifXTable_undo_values;
  150.     /*
  151.      * no wrappers yet
  152.      */
  153.     access_multiplexer->commit = _mfd_ifXTable_commit;
  154.     access_multiplexer->undo_commit = _mfd_ifXTable_undo_commit;
  155.     /*
  156.      * REQUIRED for tables with dependencies
  157.      */
  158.     access_multiplexer->consistency_checks =
  159.         _mfd_ifXTable_check_dependencies;
  160.     /*************************************************
  161.      *
  162.      * Create a registration, save our reg data, register table.
  163.      */
  164.     DEBUGMSGTL(("ifXTable:init_ifXTable",
  165.                 "Registering ifXTable as a mibs-for-dummies table.n"));
  166.     handler =
  167.         netsnmp_baby_steps_access_multiplexer_get(access_multiplexer);
  168.     reginfo =
  169.         netsnmp_handler_registration_create("ifXTable", handler,
  170.                                             ifXTable_oid,
  171.                                             ifXTable_oid_size,
  172.                                             HANDLER_CAN_BABY_STEP |
  173.                                             HANDLER_CAN_RWRITE);
  174.     if (NULL == reginfo) {
  175.         snmp_log(LOG_ERR, "error registering table ifXTablen");
  176.         return;
  177.     }
  178.     reginfo->my_reg_void = &ifXTable_if_ctx;
  179.     /*************************************************
  180.      *
  181.      * set up baby steps handler, create it and inject it
  182.      */
  183.     if (access_multiplexer->object_lookup)
  184.         mfd_modes |= BABY_STEP_OBJECT_LOOKUP;
  185.     if (access_multiplexer->set_values)
  186.         mfd_modes |= BABY_STEP_SET_VALUES;
  187.     if (access_multiplexer->irreversible_commit)
  188.         mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT;
  189.     if (access_multiplexer->object_syntax_checks)
  190.         mfd_modes |= BABY_STEP_CHECK_OBJECT;
  191.     if (access_multiplexer->pre_request)
  192.         mfd_modes |= BABY_STEP_PRE_REQUEST;
  193.     if (access_multiplexer->post_request)
  194.         mfd_modes |= BABY_STEP_POST_REQUEST;
  195.     if (access_multiplexer->undo_setup)
  196.         mfd_modes |= BABY_STEP_UNDO_SETUP;
  197.     if (access_multiplexer->undo_cleanup)
  198.         mfd_modes |= BABY_STEP_UNDO_CLEANUP;
  199.     if (access_multiplexer->undo_sets)
  200.         mfd_modes |= BABY_STEP_UNDO_SETS;
  201.     if (access_multiplexer->row_creation)
  202.         mfd_modes |= BABY_STEP_ROW_CREATE;
  203.     if (access_multiplexer->consistency_checks)
  204.         mfd_modes |= BABY_STEP_CHECK_CONSISTENCY;
  205.     if (access_multiplexer->commit)
  206.         mfd_modes |= BABY_STEP_COMMIT;
  207.     if (access_multiplexer->undo_commit)
  208.         mfd_modes |= BABY_STEP_UNDO_COMMIT;
  209.     handler = netsnmp_baby_steps_handler_get(mfd_modes);
  210.     netsnmp_inject_handler(reginfo, handler);
  211.     /*************************************************
  212.      *
  213.      * inject row_merge helper with prefix rootoid_len + 2 (entry.col)
  214.      */
  215.     handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2);
  216.     netsnmp_inject_handler(reginfo, handler);
  217.     /*************************************************
  218.      *
  219.      * inject container_table helper
  220.      */
  221.     handler =
  222.         netsnmp_container_table_handler_get(tbl_info,
  223.                                             ifXTable_if_ctx.container,
  224.                                             TABLE_CONTAINER_KEY_NETSNMP_INDEX);
  225.     netsnmp_inject_handler(reginfo, handler);
  226.     /*************************************************
  227.      *
  228.      * inject cache helper
  229.      */
  230.     if (NULL != ifXTable_if_ctx.cache) {
  231.         handler = netsnmp_cache_handler_get(ifXTable_if_ctx.cache);
  232.         netsnmp_inject_handler(reginfo, handler);
  233.     }
  234.     /*
  235.      * register table
  236.      */
  237.     netsnmp_register_table(reginfo, tbl_info);
  238. }                               /* _ifXTable_initialize_interface */
  239. void
  240. ifXTable_valid_columns_set(netsnmp_column_info *vc)
  241. {
  242.     ifXTable_if_ctx.tbl_info.valid_columns = vc;
  243. }                               /* ifXTable_valid_columns_set */
  244. /**
  245.  * @internal
  246.  * convert the index component stored in the context to an oid
  247.  */
  248. int
  249. ifXTable_index_to_oid(netsnmp_index * oid_idx,
  250.                       ifXTable_mib_index * mib_idx)
  251. {
  252.     int             err = SNMP_ERR_NOERROR;
  253.     /*
  254.      * temp storage for parsing indexes
  255.      */
  256.     /*
  257.      * ifIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/A/w/e/R/d/H
  258.      */
  259.     netsnmp_variable_list var_ifIndex;
  260.     /*
  261.      * set up varbinds
  262.      */
  263.     memset(&var_ifIndex, 0x00, sizeof(var_ifIndex));
  264.     var_ifIndex.type = ASN_INTEGER;
  265.     /*
  266.      * chain temp index varbinds together
  267.      */
  268.     var_ifIndex.next_variable = NULL;
  269.     DEBUGMSGTL(("verbose:ifXTable:ifXTable_index_to_oid", "calledn"));
  270.     /*
  271.      * ifIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/A/w/e/R/d/H 
  272.      */
  273.     snmp_set_var_value(&var_ifIndex, (u_char *) & mib_idx->ifIndex,
  274.                        sizeof(mib_idx->ifIndex));
  275.     err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len,
  276.                             NULL, 0, &var_ifIndex);
  277.     if (err)
  278.         snmp_log(LOG_ERR, "error %d converting index to oidn", err);
  279.     /*
  280.      * parsing may have allocated memory. free it.
  281.      */
  282.     snmp_reset_var_buffers(&var_ifIndex);
  283.     return err;
  284. }                               /* ifXTable_index_to_oid */
  285. /**
  286.  * extract ifXTable indexes from a netsnmp_index
  287.  *
  288.  * @retval SNMP_ERR_NOERROR  : no error
  289.  * @retval SNMP_ERR_GENERR   : error
  290.  */
  291. int
  292. ifXTable_index_from_oid(netsnmp_index * oid_idx,
  293.                         ifXTable_mib_index * mib_idx)
  294. {
  295.     int             err = SNMP_ERR_NOERROR;
  296.     /*
  297.      * temp storage for parsing indexes
  298.      */
  299.     /*
  300.      * ifIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/A/w/e/R/d/H
  301.      */
  302.     netsnmp_variable_list var_ifIndex;
  303.     /*
  304.      * set up varbinds
  305.      */
  306.     memset(&var_ifIndex, 0x00, sizeof(var_ifIndex));
  307.     var_ifIndex.type = ASN_INTEGER;
  308.     /*
  309.      * chain temp index varbinds together
  310.      */
  311.     var_ifIndex.next_variable = NULL;
  312.     DEBUGMSGTL(("verbose:ifXTable:ifXTable_index_from_oid", "calledn"));
  313.     /*
  314.      * parse the oid into the individual index components
  315.      */
  316.     err = parse_oid_indexes(oid_idx->oids, oid_idx->len, &var_ifIndex);
  317.     if (err == SNMP_ERR_NOERROR) {
  318.         /*
  319.          * copy out values
  320.          */
  321.         mib_idx->ifIndex = *((long *) var_ifIndex.val.string);
  322.     }
  323.     /*
  324.      * parsing may have allocated memory. free it.
  325.      */
  326.     snmp_reset_var_buffers(&var_ifIndex);
  327.     return err;
  328. }                               /* ifXTable_index_from_oid */
  329. /*
  330.  * ---------------------------------------------------------------------
  331.  * * TODO:200:r: Implement ifXTable data context functions.
  332.  */
  333. /*
  334.  * ifXTable_allocate_data
  335.  *
  336.  * Purpose: create new ifXTable_data.
  337.  */
  338. ifXTable_data  *
  339. ifXTable_allocate_data(void)
  340. {
  341.     /*
  342.      * TODO:201:r: |-> allocate memory for the ifXTable data context.
  343.      */
  344.     ifXTable_data  *rtn = SNMP_MALLOC_TYPEDEF(ifXTable_data);
  345.     DEBUGMSGTL(("verbose:ifXTable:ifXTable_allocate_data", "calledn"));
  346.     if (NULL == rtn) {
  347.         snmp_log(LOG_ERR, "unable to malloc memory for new "
  348.                  "ifXTable_data.n");
  349.     }
  350.     return rtn;
  351. }                               /* ifXTable_allocate_data */
  352. /*
  353.  * ifXTable_release_data
  354.  *
  355.  * Purpose: release ifXTable data.
  356.  */
  357. void
  358. ifXTable_release_data(ifXTable_data * data)
  359. {
  360.     DEBUGMSGTL(("verbose:ifXTable:ifXTable_release_data", "calledn"));
  361.     /*
  362.      * TODO:202:r: |-> release memory for the ifXTable data context.
  363.      */
  364.     free(data);
  365. }                               /* ifXTable_release_data */
  366. /**
  367.  * @internal
  368.  * wrapper
  369.  */
  370. static int
  371. _mfd_ifXTable_pre_request(netsnmp_mib_handler *handler,
  372.                           netsnmp_handler_registration *reginfo,
  373.                           netsnmp_agent_request_info *agtreq_info,
  374.                           netsnmp_request_info *requests)
  375. {
  376.     int             rc = ifXTable_pre_request(ifXTable_if_ctx.user_ctx);
  377.     if (MFD_SUCCESS != rc) {
  378.         /*
  379.          * nothing we can do about it but log it
  380.          */
  381.         DEBUGMSGTL(("internal:ifXTable", "error %d from "
  382.                     "ifXTable_pre_requestn", rc));
  383.         netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
  384.     }
  385.     return SNMP_ERR_NOERROR;
  386. }                               /* _mfd_ifXTable_pre_request */
  387. /**
  388.  * @internal
  389.  * wrapper
  390.  */
  391. static int
  392. _mfd_ifXTable_post_request(netsnmp_mib_handler *handler,
  393.                            netsnmp_handler_registration *reginfo,
  394.                            netsnmp_agent_request_info *agtreq_info,
  395.                            netsnmp_request_info *requests)
  396. {
  397.     ifXTable_rowreq_ctx *rowreq_ctx;
  398.     int             rc = ifXTable_post_request(ifXTable_if_ctx.user_ctx);
  399.     if (MFD_SUCCESS != rc) {
  400.         /*
  401.          * nothing we can do about it but log it
  402.          */
  403.         DEBUGMSGTL(("internal:ifXTable", "error %d from "
  404.                     "ifXTable_post_requestn", rc));
  405.     }
  406.     /*
  407.      * if it was set, clear row created flag.
  408.      */
  409.     rowreq_ctx = netsnmp_container_table_row_extract(requests);
  410.     if ((NULL != rowreq_ctx)
  411.         && (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED))
  412.         rowreq_ctx->rowreq_flags &= ~MFD_ROW_CREATED;
  413.     return SNMP_ERR_NOERROR;
  414. }                               /* _mfd_ifXTable_post_request */
  415. /**
  416.  * @internal
  417.  * wrapper
  418.  */
  419. static int
  420. _mfd_ifXTable_object_lookup(netsnmp_mib_handler *handler,
  421.                             netsnmp_handler_registration *reginfo,
  422.                             netsnmp_agent_request_info *agtreq_info,
  423.                             netsnmp_request_info *requests)
  424. {
  425.     ifXTable_rowreq_ctx *rowreq_ctx =
  426.         netsnmp_container_table_row_extract(requests);
  427.     DEBUGMSGTL(("internal:ifXTable:_mfd_ifXTable_object_lookup",
  428.                 "calledn"));
  429.     /*
  430.      * get our context from mfd
  431.      * ifXTable_interface_ctx *if_ctx =
  432.      *             (ifXTable_interface_ctx *)reginfo->my_reg_void;
  433.      */
  434.     if (NULL == rowreq_ctx) {
  435.         netsnmp_request_set_error_all(requests, SNMP_ERR_NOCREATION);
  436.     } else {
  437.         ifXTable_row_prep(rowreq_ctx);
  438.     }
  439.     return SNMP_ERR_NOERROR;
  440. }                               /* _mfd_ifXTable_object_lookup */
  441. /***********************************************************************
  442.  *
  443.  * GET processing
  444.  *
  445.  ***********************************************************************/
  446. /*
  447.  * @internal
  448.  * Retrieve the value for a particular column
  449.  */
  450. NETSNMP_STATIC_INLINE int
  451. _ifXTable_get_column(ifXTable_rowreq_ctx * rowreq_ctx,
  452.                      netsnmp_variable_list * var, int column)
  453. {
  454.     int             rc = SNMPERR_SUCCESS;
  455.     DEBUGMSGTL(("internal:ifXTable:_mfd_ifXTable_get_column", "calledn"));
  456.     netsnmp_assert(NULL != rowreq_ctx);
  457.     switch (column) {
  458.         /*
  459.          * ifName(1)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H 
  460.          */
  461.     case COLUMN_IFNAME:
  462.         var->type = ASN_OCTET_STR;
  463.         rc = ifName_get(rowreq_ctx, (char **) &var->val.string,
  464.                         &var->val_len);
  465.         break;
  466.         /*
  467.          * ifInMulticastPkts(2)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  468.          */
  469.     case COLUMN_IFINMULTICASTPKTS:
  470.         var->val_len = sizeof(u_long);
  471.         var->type = ASN_COUNTER;
  472.         rc = ifInMulticastPkts_get(rowreq_ctx, (u_long *) var->val.string);
  473.         break;
  474.         /*
  475.          * ifInBroadcastPkts(3)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  476.          */
  477.     case COLUMN_IFINBROADCASTPKTS:
  478.         var->val_len = sizeof(u_long);
  479.         var->type = ASN_COUNTER;
  480.         rc = ifInBroadcastPkts_get(rowreq_ctx, (u_long *) var->val.string);
  481.         break;
  482.         /*
  483.          * ifOutMulticastPkts(4)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  484.          */
  485.     case COLUMN_IFOUTMULTICASTPKTS:
  486.         var->val_len = sizeof(u_long);
  487.         var->type = ASN_COUNTER;
  488.         rc = ifOutMulticastPkts_get(rowreq_ctx,
  489.                                     (u_long *) var->val.string);
  490.         break;
  491.         /*
  492.          * ifOutBroadcastPkts(5)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h 
  493.          */
  494.     case COLUMN_IFOUTBROADCASTPKTS:
  495.         var->val_len = sizeof(u_long);
  496.         var->type = ASN_COUNTER;
  497.         rc = ifOutBroadcastPkts_get(rowreq_ctx,
  498.                                     (u_long *) var->val.string);
  499.         break;
  500.         /*
  501.          * ifHCInOctets(6)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h 
  502.          */
  503.     case COLUMN_IFHCINOCTETS:
  504.         var->val_len = sizeof(U64);
  505.         var->type = ASN_COUNTER64;
  506.         rc = ifHCInOctets_get(rowreq_ctx, (U64 *) var->val.string);
  507.         break;
  508.         /*
  509.          * ifHCInUcastPkts(7)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h 
  510.          */
  511.     case COLUMN_IFHCINUCASTPKTS:
  512.         var->val_len = sizeof(U64);
  513.         var->type = ASN_COUNTER64;
  514.         rc = ifHCInUcastPkts_get(rowreq_ctx, (U64 *) var->val.string);
  515.         break;
  516.         /*
  517.          * ifHCInMulticastPkts(8)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h 
  518.          */
  519.     case COLUMN_IFHCINMULTICASTPKTS:
  520.         var->val_len = sizeof(U64);
  521.         var->type = ASN_COUNTER64;
  522.         rc = ifHCInMulticastPkts_get(rowreq_ctx, (U64 *) var->val.string);
  523.         break;
  524.         /*
  525.          * ifHCInBroadcastPkts(9)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h 
  526.          */
  527.     case COLUMN_IFHCINBROADCASTPKTS:
  528.         var->val_len = sizeof(U64);
  529.         var->type = ASN_COUNTER64;
  530.         rc = ifHCInBroadcastPkts_get(rowreq_ctx, (U64 *) var->val.string);
  531.         break;
  532.         /*
  533.          * ifHCOutOctets(10)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h 
  534.          */
  535.     case COLUMN_IFHCOUTOCTETS:
  536.         var->val_len = sizeof(U64);
  537.         var->type = ASN_COUNTER64;
  538.         rc = ifHCOutOctets_get(rowreq_ctx, (U64 *) var->val.string);
  539.         break;
  540.         /*
  541.          * ifHCOutUcastPkts(11)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h 
  542.          */
  543.     case COLUMN_IFHCOUTUCASTPKTS:
  544.         var->val_len = sizeof(U64);
  545.         var->type = ASN_COUNTER64;
  546.         rc = ifHCOutUcastPkts_get(rowreq_ctx, (U64 *) var->val.string);
  547.         break;
  548.         /*
  549.          * ifHCOutMulticastPkts(12)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h 
  550.          */
  551.     case COLUMN_IFHCOUTMULTICASTPKTS:
  552.         var->val_len = sizeof(U64);
  553.         var->type = ASN_COUNTER64;
  554.         rc = ifHCOutMulticastPkts_get(rowreq_ctx, (U64 *) var->val.string);
  555.         break;
  556.         /*
  557.          * ifHCOutBroadcastPkts(13)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h 
  558.          */
  559.     case COLUMN_IFHCOUTBROADCASTPKTS:
  560.         var->val_len = sizeof(U64);
  561.         var->type = ASN_COUNTER64;
  562.         rc = ifHCOutBroadcastPkts_get(rowreq_ctx, (U64 *) var->val.string);
  563.         break;
  564.         /*
  565.          * ifLinkUpDownTrapEnable(14)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h 
  566.          */
  567.     case COLUMN_IFLINKUPDOWNTRAPENABLE:
  568.         var->val_len = sizeof(u_long);
  569.         var->type = ASN_INTEGER;
  570.         rc = ifLinkUpDownTrapEnable_get(rowreq_ctx,
  571.                                         (u_long *) var->val.string);
  572.         break;
  573.         /*
  574.          * ifHighSpeed(15)/GAUGE/ASN_GAUGE/u_long(u_long)//l/A/w/e/r/d/h 
  575.          */
  576.     case COLUMN_IFHIGHSPEED:
  577.         var->val_len = sizeof(u_long);
  578.         var->type = ASN_GAUGE;
  579.         rc = ifHighSpeed_get(rowreq_ctx, (u_long *) var->val.string);
  580.         break;
  581.         /*
  582.          * ifPromiscuousMode(16)/TruthValue/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h 
  583.          */
  584.     case COLUMN_IFPROMISCUOUSMODE:
  585.         var->val_len = sizeof(u_long);
  586.         var->type = ASN_INTEGER;
  587.         rc = ifPromiscuousMode_get(rowreq_ctx, (u_long *) var->val.string);
  588.         break;
  589.         /*
  590.          * ifConnectorPresent(17)/TruthValue/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h 
  591.          */
  592.     case COLUMN_IFCONNECTORPRESENT:
  593.         var->val_len = sizeof(u_long);
  594.         var->type = ASN_INTEGER;
  595.         rc = ifConnectorPresent_get(rowreq_ctx,
  596.                                     (u_long *) var->val.string);
  597.         break;
  598.         /*
  599.          * ifAlias(18)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H 
  600.          */
  601.     case COLUMN_IFALIAS:
  602.         var->type = ASN_OCTET_STR;
  603.         rc = ifAlias_get(rowreq_ctx, (char **) &var->val.string,
  604.                          &var->val_len);
  605.         break;
  606.         /*
  607.          * ifCounterDiscontinuityTime(19)/TimeStamp/ASN_TIMETICKS/u_long(u_long)//l/A/w/e/r/d/h 
  608.          */
  609.     case COLUMN_IFCOUNTERDISCONTINUITYTIME:
  610.         var->val_len = sizeof(u_long);
  611.         var->type = ASN_TIMETICKS;
  612.         rc = ifCounterDiscontinuityTime_get(rowreq_ctx,
  613.                                             (u_long *) var->val.string);
  614.         break;
  615.     default:
  616.         snmp_log(LOG_ERR, "unknown column %d in _ifXTable_get_columnn",
  617.                  column);
  618.         break;
  619.     }
  620.     return rc;
  621. }                               /* _ifXTable_get_column */
  622. int
  623. _mfd_ifXTable_get_values(netsnmp_mib_handler *handler,
  624.                          netsnmp_handler_registration *reginfo,
  625.                          netsnmp_agent_request_info *agtreq_info,
  626.                          netsnmp_request_info *requests)
  627. {
  628.     ifXTable_rowreq_ctx *rowreq_ctx =
  629.         netsnmp_container_table_row_extract(requests);
  630.     netsnmp_table_request_info *tri;
  631.     u_char         *old_string;
  632.     void            (*dataFreeHook) (void *);
  633.     int             rc;
  634.     DEBUGMSGTL(("internal:ifXTable:_mfd_ifXTable_get_values", "calledn"));
  635.     netsnmp_assert(NULL != rowreq_ctx);
  636.     for (; requests; requests = requests->next) {
  637.         /*
  638.          * save old pointer, so we can free it if replaced
  639.          */
  640.         old_string = requests->requestvb->val.string;
  641.         dataFreeHook = requests->requestvb->dataFreeHook;
  642.         if (NULL == requests->requestvb->val.string) {
  643.             requests->requestvb->val.string = requests->requestvb->buf;
  644.             requests->requestvb->val_len =
  645.                 sizeof(requests->requestvb->buf);
  646.         } else if (requests->requestvb->buf ==
  647.                    requests->requestvb->val.string) {
  648.             if (requests->requestvb->val_len !=
  649.                 sizeof(requests->requestvb->buf))
  650.                 requests->requestvb->val_len =
  651.                     sizeof(requests->requestvb->buf);
  652.         }
  653.         /*
  654.          * get column data
  655.          */
  656.         tri = netsnmp_extract_table_info(requests);
  657.         if (NULL == tri)
  658.             continue;
  659.         rc = _ifXTable_get_column(rowreq_ctx, requests->requestvb,
  660.                                   tri->colnum);
  661.         if (rc) {
  662.             if (MFD_SKIP == rc) {
  663.                 requests->requestvb->type = ASN_PRIV_RETRY;
  664.                 rc = SNMP_ERR_NOERROR;
  665.             }
  666.         } else if (NULL == requests->requestvb->val.string) {
  667.             snmp_log(LOG_ERR, "NULL varbind data pointer!n");
  668.             rc = SNMP_ERR_GENERR;
  669.         }
  670.         if (rc)
  671.             netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc));
  672.         /*
  673.          * if the buffer wasn't used previously for the old data (i.e. it
  674.          * was allcoated memory)  and the get routine replaced the pointer,
  675.          * we need to free the previous pointer.
  676.          */
  677.         if (old_string && (old_string != requests->requestvb->buf) &&
  678.             (requests->requestvb->val.string != old_string)) {
  679.             if (dataFreeHook)
  680.                 (*dataFreeHook) (old_string);
  681.             else
  682.                 free(old_string);
  683.         }
  684.     }                           /* for results */
  685.     return SNMP_ERR_NOERROR;
  686. }                               /* _mfd_ifXTable_get_values */
  687. /***********************************************************************
  688.  *
  689.  * SET processing
  690.  *
  691.  ***********************************************************************/
  692. /*----------------------------------------------------------------------
  693.  *
  694.  * SET: Syntax checks
  695.  *
  696.  *---------------------------------------------------------------------*/
  697. /*
  698.  * @internal
  699.  * Check the syntax for a particular column
  700.  */
  701. NETSNMP_STATIC_INLINE int
  702. _ifXTable_check_column(ifXTable_rowreq_ctx * rowreq_ctx,
  703.                        netsnmp_variable_list * var, int column)
  704. {
  705.     int             rc = SNMPERR_SUCCESS;
  706.     DEBUGMSGTL(("internal:ifXTable:_ifXTable_check_column", "calledn"));
  707.     netsnmp_assert(NULL != rowreq_ctx);
  708.     switch (column) {
  709.         /*
  710.          * ifLinkUpDownTrapEnable(14)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h 
  711.          */
  712.     case COLUMN_IFLINKUPDOWNTRAPENABLE:
  713.         rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER,
  714.                                             sizeof(rowreq_ctx->data.
  715.                                                    ifLinkUpDownTrapEnable));
  716.         if (SNMPERR_SUCCESS == rc) {
  717.             /*
  718.              * check that the value is one of defined enums 
  719.              */
  720.             if (1 && (*var->val.integer != IFLINKUPDOWNTRAPENABLE_ENABLED)
  721.                 && (*var->val.integer != IFLINKUPDOWNTRAPENABLE_DISABLED)
  722.                 ) {
  723.                 rc = SNMP_ERR_WRONGVALUE;
  724.             }
  725.         }
  726.         if (SNMPERR_SUCCESS == rc) {
  727.             rc = ifLinkUpDownTrapEnable_check_value(rowreq_ctx,
  728.                                                     *((u_long *) var->val.
  729.                                                       string));
  730.             if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
  731.                 && (MFD_NOT_VALID_NOW != rc)) {
  732.                 snmp_log(LOG_ERR,
  733.                          "bad rc %d from ifLinkUpDownTrapEnable_check_valuen",
  734.                          rc);
  735.                 rc = SNMP_ERR_GENERR;
  736.             }
  737.         }
  738.         break;
  739.         /*
  740.          * ifPromiscuousMode(16)/TruthValue/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h 
  741.          */
  742.     case COLUMN_IFPROMISCUOUSMODE:
  743.         rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER,
  744.                                             sizeof(rowreq_ctx->data.
  745.                                                    ifPromiscuousMode));
  746.         if (SNMPERR_SUCCESS == rc) {
  747.             /*
  748.              * check that the value is one of defined enums 
  749.              */
  750.             if (1 && (*var->val.integer != TRUTHVALUE_TRUE)
  751.                 && (*var->val.integer != TRUTHVALUE_FALSE)
  752.                 ) {
  753.                 rc = SNMP_ERR_WRONGVALUE;
  754.             }
  755.         }
  756.         if (SNMPERR_SUCCESS == rc) {
  757.             rc = ifPromiscuousMode_check_value(rowreq_ctx,
  758.                                                *((u_long *) var->val.
  759.                                                  string));
  760.             if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
  761.                 && (MFD_NOT_VALID_NOW != rc)) {
  762.                 snmp_log(LOG_ERR,
  763.                          "bad rc %d from ifPromiscuousMode_check_valuen",
  764.                          rc);
  765.                 rc = SNMP_ERR_GENERR;
  766.             }
  767.         }
  768.         break;
  769.         /*
  770.          * ifAlias(18)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H 
  771.          */
  772.     case COLUMN_IFALIAS:
  773.         rc = netsnmp_check_vb_type(var, ASN_OCTET_STR);
  774.         if (SNMPERR_SUCCESS == rc) {
  775.             /*
  776.              * check that the value is in the defined range(s); inefficent
  777.              * * but keeps rc value knowledge in libarary where it belongs. 
  778.              */
  779.             if (1
  780.                 && ((rc = netsnmp_check_vb_size_range(var, 0, 64)) !=
  781.                     SNMP_ERR_NOERROR)
  782.                 ) {
  783.                 ;               /* rc set in condition */
  784.             }
  785.         }
  786.         if (SNMPERR_SUCCESS == rc) {
  787.             rc = ifAlias_check_value(rowreq_ctx, (char *) var->val.string,
  788.                                      var->val_len);
  789.             if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
  790.                 && (MFD_NOT_VALID_NOW != rc)) {
  791.                 snmp_log(LOG_ERR, "bad rc %d from ifAlias_check_valuen",
  792.                          rc);
  793.                 rc = SNMP_ERR_GENERR;
  794.             }
  795.         }
  796.         break;
  797.     default: /** We shouldn't get here */
  798.         rc = SNMP_ERR_GENERR;
  799.         snmp_log(LOG_ERR, "unknown column %d in _ifXTable_check_columnn",
  800.                  column);
  801.     }
  802.     return rc;
  803. }                               /* _ifXTable_check_column */
  804. int
  805. _mfd_ifXTable_check_objects(netsnmp_mib_handler *handler,
  806.                             netsnmp_handler_registration *reginfo,
  807.                             netsnmp_agent_request_info *agtreq_info,
  808.                             netsnmp_request_info *requests)
  809. {
  810.     ifXTable_rowreq_ctx *rowreq_ctx =
  811.         netsnmp_container_table_row_extract(requests);
  812.     netsnmp_table_request_info *tri;
  813.     int             rc;
  814.     DEBUGMSGTL(("internal:ifXTable:_mfd_ifXTable_check_objects",
  815.                 "calledn"));
  816.     netsnmp_assert(NULL != rowreq_ctx);
  817.     for (; requests; requests = requests->next) {
  818.         /*
  819.          * get column number from table request info, and check that column
  820.          */
  821.         tri = netsnmp_extract_table_info(requests);
  822.         if (NULL == tri)
  823.             continue;
  824.         rc = _ifXTable_check_column(rowreq_ctx, requests->requestvb,
  825.                                     tri->colnum);
  826.         if (rc) {
  827.             netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc));
  828.             break;
  829.         }
  830.     }                           /* for results */
  831.     return SNMP_ERR_NOERROR;
  832. }                               /* _mfd_ifXTable_check_objects */
  833. /*----------------------------------------------------------------------
  834.  *
  835.  * SET: check dependencies
  836.  *
  837.  *---------------------------------------------------------------------*/
  838. /*
  839.  * @internal
  840.  * Check dependencies wrapper
  841.  */
  842. static int
  843. _mfd_ifXTable_check_dependencies(netsnmp_mib_handler *handler,
  844.                                  netsnmp_handler_registration *reginfo,
  845.                                  netsnmp_agent_request_info *agtreq_info,
  846.                                  netsnmp_request_info *requests)
  847. {
  848.     int             rc;
  849.     ifXTable_rowreq_ctx *rowreq_ctx =
  850.         netsnmp_container_table_row_extract(requests);
  851.     DEBUGMSGTL(("internal:ifXTable:_mfd_ifXTable_check_dependencies",
  852.                 "calledn"));
  853.     netsnmp_assert(NULL != rowreq_ctx);
  854.     rc = ifXTable_check_dependencies(rowreq_ctx);
  855.     if (rc) {
  856.         DEBUGMSGTL(("verbose:ifXTable:mfd", "error %d from "
  857.                     "ifXTable_check_dependenciesn", rc));
  858.         netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
  859.     }
  860.     return SNMP_ERR_NOERROR;
  861. }                               /* _mfd_ifXTable_check_dependencies */
  862. /*----------------------------------------------------------------------
  863.  *
  864.  * SET: Undo setup
  865.  *
  866.  *---------------------------------------------------------------------*/
  867. /*
  868.  * @internal
  869.  * Set the value for a particular column
  870.  */
  871. NETSNMP_STATIC_INLINE int
  872. _ifXTable_undo_setup_column(ifXTable_rowreq_ctx * rowreq_ctx, int column)
  873. {
  874.     int             rc = SNMPERR_SUCCESS;
  875.     DEBUGMSGTL(("internal:ifXTable:_ifXTable_undo_setup_column",
  876.                 "calledn"));
  877.     netsnmp_assert(NULL != rowreq_ctx);
  878.     switch (column) {
  879.         /*
  880.          * ifLinkUpDownTrapEnable(14)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h 
  881.          */
  882.     case COLUMN_IFLINKUPDOWNTRAPENABLE:
  883.         rowreq_ctx->column_set_flags |= FLAG_IFLINKUPDOWNTRAPENABLE;
  884.         rc = ifLinkUpDownTrapEnable_undo_setup(rowreq_ctx);
  885.         break;
  886.         /*
  887.          * ifPromiscuousMode(16)/TruthValue/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h 
  888.          */
  889.     case COLUMN_IFPROMISCUOUSMODE:
  890.         rowreq_ctx->column_set_flags |= FLAG_IFPROMISCUOUSMODE;
  891.         rc = ifPromiscuousMode_undo_setup(rowreq_ctx);
  892.         break;
  893.         /*
  894.          * ifAlias(18)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H 
  895.          */
  896.     case COLUMN_IFALIAS:
  897.         rowreq_ctx->column_set_flags |= FLAG_IFALIAS;
  898.         rc = ifAlias_undo_setup(rowreq_ctx);
  899.         break;
  900.     default:
  901.         snmp_log(LOG_ERR,
  902.                  "unknown column %d in _ifXTable_undo_setup_columnn",
  903.                  column);
  904.         break;
  905.     }
  906.     return rc;
  907. }                               /* _ifXTable_undo_setup_column */
  908. /**
  909.  * @internal
  910.  * undo setup
  911.  */
  912. int
  913. _mfd_ifXTable_undo_setup(netsnmp_mib_handler *handler,
  914.                          netsnmp_handler_registration *reginfo,
  915.                          netsnmp_agent_request_info *agtreq_info,
  916.                          netsnmp_request_info *requests)
  917. {
  918.     int             rc;
  919.     ifXTable_rowreq_ctx *rowreq_ctx =
  920.         netsnmp_container_table_row_extract(requests);
  921.     DEBUGMSGTL(("internal:ifXTable:_mfd_ifXTable_undo_setup", "calledn"));
  922.     netsnmp_assert(NULL != rowreq_ctx);
  923.     /*
  924.      * allocate undo context
  925.      */
  926.     rowreq_ctx->undo = ifXTable_allocate_data();
  927.     if (NULL == rowreq_ctx->undo) {
  928.         /** msg already logged */
  929.         netsnmp_request_set_error_all(requests,
  930.                                       SNMP_ERR_RESOURCEUNAVAILABLE);
  931.         return SNMP_ERR_NOERROR;
  932.     }
  933.     /*
  934.      * row undo setup
  935.      */
  936.     rowreq_ctx->column_set_flags = 0;
  937.     rc = ifXTable_undo_setup(rowreq_ctx);
  938.     if (MFD_SUCCESS != rc) {
  939.         DEBUGMSGTL(("verbose:ifXTable:mfd", "error %d from "
  940.                     "ifXTable_undo_setupn", rc));
  941.         netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
  942.     } else {
  943.         /*
  944.          * column undo setup
  945.          */
  946.         netsnmp_table_request_info *tri;
  947.         for (; requests; requests = requests->next) {
  948.             /*
  949.              * set column data
  950.              */
  951.             tri = netsnmp_extract_table_info(requests);
  952.             if (NULL == tri)
  953.                 continue;
  954.             rc = _ifXTable_undo_setup_column(rowreq_ctx, tri->colnum);
  955.             if (MFD_SUCCESS != rc) {
  956.                 DEBUGMSGTL(("verbose:ifXTable:mfd", "error %d from "
  957.                             "ifXTable_undo_setup_columnn", rc));
  958.                 netsnmp_set_request_error(agtreq_info, requests,
  959.                                           SNMP_VALIDATE_ERR(rc));
  960.             }
  961.         }                       /* for results */
  962.     }
  963.     return SNMP_ERR_NOERROR;
  964. }                               /* _mfd_ifXTable_undo_setup */
  965. /**
  966.  * @internal
  967.  * undo setup
  968.  */
  969. int
  970. _mfd_ifXTable_undo_cleanup(netsnmp_mib_handler *handler,
  971.                            netsnmp_handler_registration *reginfo,
  972.                            netsnmp_agent_request_info *agtreq_info,
  973.                            netsnmp_request_info *requests)
  974. {
  975.     ifXTable_rowreq_ctx *rowreq_ctx =
  976.         netsnmp_container_table_row_extract(requests);
  977.     int             rc;
  978.     DEBUGMSGTL(("internal:ifXTable:_mfd_ifXTable_undo_cleanup",
  979.                 "calledn"));
  980.     /*
  981.      * failed row create in early stages has no rowreq_ctx
  982.      */
  983.     if (NULL == rowreq_ctx)
  984.         return MFD_SUCCESS;
  985.     /*
  986.      * call user cleanup
  987.      */
  988.     rc = ifXTable_undo_cleanup(rowreq_ctx);
  989.     if (MFD_SUCCESS != rc) {
  990.         /*
  991.          * nothing we can do about it but log it
  992.          */
  993.         DEBUGMSGTL(("verbose:ifXTable:mfd", "error %d from "
  994.                     "ifXTable_undo_cleanupn", rc));
  995.     }
  996.     /*
  997.      * release undo context, if needed
  998.      */
  999.     if (rowreq_ctx->undo) {
  1000.         ifXTable_release_data(rowreq_ctx->undo);
  1001.         rowreq_ctx->undo = NULL;
  1002.     }
  1003.     /*
  1004.      * clear set flags
  1005.      */
  1006.     rowreq_ctx->column_set_flags = 0;
  1007.     return SNMP_ERR_NOERROR;
  1008. }                               /* _mfd_ifXTable_undo_cleanup */
  1009. /*----------------------------------------------------------------------
  1010.  *
  1011.  * SET: Set values
  1012.  *
  1013.  *---------------------------------------------------------------------*/
  1014. /*
  1015.  * @internal
  1016.  * Set the value for a particular column
  1017.  */
  1018. NETSNMP_STATIC_INLINE int
  1019. _ifXTable_set_column(ifXTable_rowreq_ctx * rowreq_ctx,
  1020.                      netsnmp_variable_list * var, int column)
  1021. {
  1022.     int             rc = SNMPERR_SUCCESS;
  1023.     DEBUGMSGTL(("internal:ifXTable:_ifXTable_set_column", "calledn"));
  1024.     netsnmp_assert(NULL != rowreq_ctx);
  1025.     switch (column) {
  1026.         /*
  1027.          * ifLinkUpDownTrapEnable(14)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h 
  1028.          */
  1029.     case COLUMN_IFLINKUPDOWNTRAPENABLE:
  1030.         if (var->val_len != sizeof(u_long)) {
  1031.             rc = SNMP_ERR_WRONGLENGTH;
  1032.             snmp_log(LOG_ERR,
  1033.                      "varbind size of %d does not match expected size %dn",
  1034.                      var->val_len, sizeof(u_long));
  1035.             break;
  1036.         }
  1037.         rowreq_ctx->column_set_flags |= FLAG_IFLINKUPDOWNTRAPENABLE;
  1038.         rc = ifLinkUpDownTrapEnable_set(rowreq_ctx,
  1039.                                         *((u_long *) var->val.string));
  1040.         break;
  1041.         /*
  1042.          * ifPromiscuousMode(16)/TruthValue/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h 
  1043.          */
  1044.     case COLUMN_IFPROMISCUOUSMODE:
  1045.         if (var->val_len != sizeof(u_long)) {
  1046.             rc = SNMP_ERR_WRONGLENGTH;
  1047.             snmp_log(LOG_ERR,
  1048.                      "varbind size of %d does not match expected size %dn",
  1049.                      var->val_len, sizeof(u_long));
  1050.             break;
  1051.         }
  1052.         rowreq_ctx->column_set_flags |= FLAG_IFPROMISCUOUSMODE;
  1053.         rc = ifPromiscuousMode_set(rowreq_ctx,
  1054.                                    *((u_long *) var->val.string));
  1055.         break;
  1056.         /*
  1057.          * ifAlias(18)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H 
  1058.          */
  1059.     case COLUMN_IFALIAS:
  1060.         rowreq_ctx->column_set_flags |= FLAG_IFALIAS;
  1061.         rc = ifAlias_set(rowreq_ctx, (char *) var->val.string,
  1062.                          var->val_len);
  1063.         break;
  1064.     default:
  1065.         snmp_log(LOG_ERR, "unknown column %d in _ifXTable_set_columnn",
  1066.                  column);
  1067.         break;
  1068.     }
  1069.     return rc;
  1070. }                               /* _ifXTable_set_column */
  1071. int
  1072. _mfd_ifXTable_set_values(netsnmp_mib_handler *handler,
  1073.                          netsnmp_handler_registration *reginfo,
  1074.                          netsnmp_agent_request_info *agtreq_info,
  1075.                          netsnmp_request_info *requests)
  1076. {
  1077.     ifXTable_rowreq_ctx *rowreq_ctx =
  1078.         netsnmp_container_table_row_extract(requests);
  1079.     netsnmp_table_request_info *tri;
  1080.     int             rc = SNMP_ERR_NOERROR;
  1081.     DEBUGMSGTL(("internal:ifXTable:_mfd_ifXTable_set_values", "calledn"));
  1082.     netsnmp_assert(NULL != rowreq_ctx);
  1083.     rowreq_ctx->column_set_flags = 0;
  1084.     for (; requests; requests = requests->next) {
  1085.         /*
  1086.          * set column data
  1087.          */
  1088.         tri = netsnmp_extract_table_info(requests);
  1089.         if (NULL == tri)
  1090.             continue;
  1091.         rc = _ifXTable_set_column(rowreq_ctx,
  1092.                                   requests->requestvb, tri->colnum);
  1093.         if (MFD_SUCCESS != rc) {
  1094.             DEBUGMSGTL(("verbose:ifXTable:mfd", "error %d from "
  1095.                         "ifXTable_set_columnn", rc));
  1096.             netsnmp_set_request_error(agtreq_info, requests,
  1097.                                       SNMP_VALIDATE_ERR(rc));
  1098.         }
  1099.     }                           /* for results */
  1100.     return SNMP_ERR_NOERROR;
  1101. }                               /* _mfd_ifXTable_set_values */
  1102. /*----------------------------------------------------------------------
  1103.  *
  1104.  * SET: commit
  1105.  *
  1106.  *---------------------------------------------------------------------*/
  1107. /**
  1108.  * @internal
  1109.  * commit the values
  1110.  */
  1111. int
  1112. _mfd_ifXTable_commit(netsnmp_mib_handler *handler,
  1113.                      netsnmp_handler_registration *reginfo,
  1114.                      netsnmp_agent_request_info *agtreq_info,
  1115.                      netsnmp_request_info *requests)
  1116. {
  1117.     int             rc;
  1118.     ifXTable_rowreq_ctx *rowreq_ctx =
  1119.         netsnmp_container_table_row_extract(requests);
  1120.     DEBUGMSGTL(("internal:ifXTable:_mfd_ifXTable_commit", "calledn"));
  1121.     netsnmp_assert(NULL != rowreq_ctx);
  1122.     rc = ifXTable_commit(rowreq_ctx);
  1123.     if (MFD_SUCCESS != rc) {
  1124.         DEBUGMSGTL(("verbose:ifXTable:mfd", "error %d from "
  1125.                     "ifXTable_commitn", rc));
  1126.         netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
  1127.     }
  1128.     return SNMP_ERR_NOERROR;
  1129. }
  1130. int
  1131. _mfd_ifXTable_undo_commit(netsnmp_mib_handler *handler,
  1132.                           netsnmp_handler_registration *reginfo,
  1133.                           netsnmp_agent_request_info *agtreq_info,
  1134.                           netsnmp_request_info *requests)
  1135. {
  1136.     int             rc;
  1137.     ifXTable_rowreq_ctx *rowreq_ctx =
  1138.         netsnmp_container_table_row_extract(requests);
  1139.     DEBUGMSGTL(("internal:ifXTable:_mfd_ifXTable_undo_commit",
  1140.                 "calledn"));
  1141.     netsnmp_assert(NULL != rowreq_ctx);
  1142.     rc = ifXTable_undo_commit(rowreq_ctx);
  1143.     if (MFD_SUCCESS != rc) {
  1144.         /*
  1145.          * nothing we can do about it but log it
  1146.          */
  1147.         DEBUGMSGTL(("verbose:ifXTable:mfd", "error %d from "
  1148.                     "ifXTable_undo_commitn", rc));
  1149.     }
  1150.     return SNMP_ERR_NOERROR;
  1151. }                               /* _mfd_ifXTable_commit */
  1152. /*----------------------------------------------------------------------
  1153.  *
  1154.  * SET: Undo
  1155.  *
  1156.  *---------------------------------------------------------------------*/
  1157. /**
  1158.  * @internal
  1159.  * undo the value for a particular column
  1160.  */
  1161. NETSNMP_STATIC_INLINE int
  1162. _ifXTable_undo_column(ifXTable_rowreq_ctx * rowreq_ctx,
  1163.                       netsnmp_variable_list * var, int column)
  1164. {
  1165.     int             rc = SNMPERR_SUCCESS;
  1166.     DEBUGMSGTL(("internal:ifXTable:_ifXTable_undo_column", "calledn"));
  1167.     netsnmp_assert(NULL != rowreq_ctx);
  1168.     switch (column) {
  1169.         /*
  1170.          * ifLinkUpDownTrapEnable(14)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h 
  1171.          */
  1172.     case COLUMN_IFLINKUPDOWNTRAPENABLE:
  1173.         rc = ifLinkUpDownTrapEnable_undo(rowreq_ctx);
  1174.         break;
  1175.         /*
  1176.          * ifPromiscuousMode(16)/TruthValue/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h 
  1177.          */
  1178.     case COLUMN_IFPROMISCUOUSMODE:
  1179.         rc = ifPromiscuousMode_undo(rowreq_ctx);
  1180.         break;
  1181.         /*
  1182.          * ifAlias(18)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H 
  1183.          */
  1184.     case COLUMN_IFALIAS:
  1185.         rc = ifAlias_undo(rowreq_ctx);
  1186.         break;
  1187.     default:
  1188.         snmp_log(LOG_ERR, "unknown column %d in _ifXTable_undo_columnn",
  1189.                  column);
  1190.         break;
  1191.     }
  1192.     return rc;
  1193. }                               /* _ifXTable_undo_column */
  1194. int
  1195. _mfd_ifXTable_undo_values(netsnmp_mib_handler *handler,
  1196.                           netsnmp_handler_registration *reginfo,
  1197.                           netsnmp_agent_request_info *agtreq_info,
  1198.                           netsnmp_request_info *requests)
  1199. {
  1200.     int             rc;
  1201.     ifXTable_rowreq_ctx *rowreq_ctx =
  1202.         netsnmp_container_table_row_extract(requests);
  1203.     netsnmp_table_request_info *tri;
  1204.     DEBUGMSGTL(("internal:ifXTable:_mfd_ifXTable_undo_values",
  1205.                 "calledn"));
  1206.     netsnmp_assert(NULL != rowreq_ctx);
  1207.     for (; requests; requests = requests->next) {
  1208.         /*
  1209.          * set column data
  1210.          */
  1211.         tri = netsnmp_extract_table_info(requests);
  1212.         if (NULL == tri)
  1213.             continue;
  1214.         rc = _ifXTable_undo_column(rowreq_ctx, requests->requestvb,
  1215.                                    tri->colnum);
  1216.         if (MFD_SUCCESS != rc) {
  1217.             /*
  1218.              * nothing we can do about it but log it
  1219.              */
  1220.             DEBUGMSGTL(("verbose:ifXTable:mfd", "error %d from "
  1221.                         "ifXTable_undo_columnn", rc));
  1222.         }
  1223.     }                           /* for results */
  1224.     return SNMP_ERR_NOERROR;
  1225. }                               /* _mfd_ifXTable_undo_values */
  1226. /***********************************************************************
  1227.  *
  1228.  * DATA ACCESS
  1229.  *
  1230.  ***********************************************************************/
  1231. /**
  1232.  * @internal
  1233.  * initialize the iterator container with functions or wrappers
  1234.  */
  1235. void
  1236. _ifXTable_container_init(ifXTable_interface_ctx * if_ctx)
  1237. {
  1238.     DEBUGMSGTL(("internal:ifXTable:_ifXTable_container_init", "calledn"));
  1239.     /*
  1240.      * set up the cache
  1241.      *
  1242.      * special case: sharing a cache
  1243.      */
  1244.     if_ctx->cache =
  1245.         netsnmp_cache_find_by_oid(ifTable_oid, ifTable_oid_size);
  1246.     if (NULL != if_ctx->cache) {
  1247.         if_ctx->container = (netsnmp_container *) if_ctx->cache->magic;
  1248.         return;
  1249.     } else {
  1250.         snmp_log(LOG_ERR, "error finding ifTable cachen");
  1251.     }
  1252. }
  1253. /*
  1254.  * allow direct access to container.
  1255.  */
  1256. netsnmp_container *
  1257. _ifXTable_container_get(void)
  1258. {
  1259.     return ifXTable_if_ctx.container;
  1260. }