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

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: inetNetToMediaTable_interface.c,v 1.5.2.1 2005/03/29 21:05:25 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 "inetNetToMediaTable.h"
  38. #include <net-snmp/library/container.h>
  39. #include "inetNetToMediaTable_interface.h"
  40. /**********************************************************************
  41.  **********************************************************************
  42.  ***
  43.  *** Table inetNetToMediaTable
  44.  ***
  45.  **********************************************************************
  46.  **********************************************************************/
  47. /*
  48.  * inetNetToMediaTable is subid 35 of ip.
  49.  * Its status is Current.
  50.  * OID: .1.3.6.1.2.1.4.35, length: 8
  51.  */
  52. typedef struct inetNetToMediaTable_interface_ctx_s {
  53.     netsnmp_container *container;
  54.     netsnmp_cache  *cache;      /* optional cache */
  55.     inetNetToMediaTable_registration_ptr user_ctx;
  56.     netsnmp_table_registration_info tbl_info;
  57.     netsnmp_baby_steps_access_methods access_multiplexer;
  58. } inetNetToMediaTable_interface_ctx;
  59. static inetNetToMediaTable_interface_ctx inetNetToMediaTable_if_ctx;
  60. static void
  61.                 _inetNetToMediaTable_container_init(inetNetToMediaTable_interface_ctx *
  62.                                                     if_ctx);
  63. static Netsnmp_Node_Handler _mfd_inetNetToMediaTable_pre_request;
  64. static Netsnmp_Node_Handler _mfd_inetNetToMediaTable_post_request;
  65. static Netsnmp_Node_Handler _mfd_inetNetToMediaTable_object_lookup;
  66. static Netsnmp_Node_Handler _mfd_inetNetToMediaTable_get_values;
  67. static Netsnmp_Node_Handler _mfd_inetNetToMediaTable_check_objects;
  68. static Netsnmp_Node_Handler _mfd_inetNetToMediaTable_undo_setup;
  69. static Netsnmp_Node_Handler _mfd_inetNetToMediaTable_set_values;
  70. static Netsnmp_Node_Handler _mfd_inetNetToMediaTable_undo_cleanup;
  71. static Netsnmp_Node_Handler _mfd_inetNetToMediaTable_undo_values;
  72. static Netsnmp_Node_Handler _mfd_inetNetToMediaTable_commit;
  73. static Netsnmp_Node_Handler _mfd_inetNetToMediaTable_undo_commit;
  74. static Netsnmp_Node_Handler _mfd_inetNetToMediaTable_check_dependencies;
  75. NETSNMP_STATIC_INLINE int
  76.                 _inetNetToMediaTable_undo_column(inetNetToMediaTable_rowreq_ctx *
  77.                                                  rowreq_ctx,
  78.                                                  netsnmp_variable_list *
  79.                                                  var, int column);
  80. NETSNMP_STATIC_INLINE int
  81.                 _inetNetToMediaTable_check_indexes(inetNetToMediaTable_rowreq_ctx *
  82.                                                    rowreq_ctx);
  83. /**
  84.  * @internal
  85.  * Initialize the table inetNetToMediaTable 
  86.  *    (Define its contents and how it's structured)
  87.  */
  88. void
  89.     _inetNetToMediaTable_initialize_interface
  90.     (inetNetToMediaTable_registration_ptr reg_ptr, u_long flags) {
  91.     netsnmp_baby_steps_access_methods *access_multiplexer =
  92.         &inetNetToMediaTable_if_ctx.access_multiplexer;
  93.     netsnmp_table_registration_info *tbl_info =
  94.         &inetNetToMediaTable_if_ctx.tbl_info;
  95.     netsnmp_handler_registration *reginfo;
  96.     netsnmp_mib_handler *handler;
  97.     int             mfd_modes = 0;
  98.     DEBUGMSGTL(("internal:inetNetToMediaTable:_inetNetToMediaTable_initialize_interface", "calledn"));
  99.     /*************************************************
  100.      *
  101.      * save interface context for inetNetToMediaTable
  102.      */
  103.     /*
  104.      * Setting up the table's definition
  105.      */
  106.     netsnmp_table_helper_add_indexes(tbl_info, ASN_INTEGER,
  107.                                                /** index: inetNetToMediaIfIndex */
  108.                                      ASN_INTEGER,
  109.                                                /** index: inetNetToMediaNetAddressType */
  110.                                      ASN_OCTET_STR,
  111.                                                  /** index: inetNetToMediaNetAddress */
  112.                                      0);
  113.     /*
  114.      * Define the minimum and maximum accessible columns.  This
  115.      * optimizes retrival. 
  116.      */
  117.     tbl_info->min_column = INETNETTOMEDIATABLE_MIN_COL;
  118.     tbl_info->max_column = INETNETTOMEDIATABLE_MAX_COL;
  119.     /*
  120.      * save users context
  121.      */
  122.     inetNetToMediaTable_if_ctx.user_ctx = reg_ptr;
  123.     /*
  124.      * call data access initialization code
  125.      */
  126.     inetNetToMediaTable_init_data(reg_ptr);
  127.     /*
  128.      * set up the container
  129.      */
  130.     _inetNetToMediaTable_container_init(&inetNetToMediaTable_if_ctx);
  131.     if (NULL == inetNetToMediaTable_if_ctx.container) {
  132.         snmp_log(LOG_ERR,
  133.                  "could not initialize container for inetNetToMediaTablen");
  134.         return;
  135.     }
  136.     /*
  137.      * access_multiplexer: REQUIRED wrapper for get request handling
  138.      */
  139.     access_multiplexer->object_lookup =
  140.         _mfd_inetNetToMediaTable_object_lookup;
  141.     access_multiplexer->get_values = _mfd_inetNetToMediaTable_get_values;
  142.     /*
  143.      * no wrappers yet
  144.      */
  145.     access_multiplexer->pre_request = _mfd_inetNetToMediaTable_pre_request;
  146.     access_multiplexer->post_request =
  147.         _mfd_inetNetToMediaTable_post_request;
  148.     /*
  149.      * REQUIRED wrappers for set request handling
  150.      */
  151.     access_multiplexer->object_syntax_checks =
  152.         _mfd_inetNetToMediaTable_check_objects;
  153.     access_multiplexer->undo_setup = _mfd_inetNetToMediaTable_undo_setup;
  154.     access_multiplexer->undo_cleanup =
  155.         _mfd_inetNetToMediaTable_undo_cleanup;
  156.     access_multiplexer->set_values = _mfd_inetNetToMediaTable_set_values;
  157.     access_multiplexer->undo_sets = _mfd_inetNetToMediaTable_undo_values;
  158.     /*
  159.      * no wrappers yet
  160.      */
  161.     access_multiplexer->commit = _mfd_inetNetToMediaTable_commit;
  162.     access_multiplexer->undo_commit = _mfd_inetNetToMediaTable_undo_commit;
  163.     /*
  164.      * REQUIRED for tables with dependencies
  165.      */
  166.     access_multiplexer->consistency_checks =
  167.         _mfd_inetNetToMediaTable_check_dependencies;
  168.     /*************************************************
  169.      *
  170.      * Create a registration, save our reg data, register table.
  171.      */
  172.     DEBUGMSGTL(("inetNetToMediaTable:init_inetNetToMediaTable",
  173.                 "Registering inetNetToMediaTable as a mibs-for-dummies table.n"));
  174.     handler =
  175.         netsnmp_baby_steps_access_multiplexer_get(access_multiplexer);
  176.     reginfo =
  177.         netsnmp_handler_registration_create("inetNetToMediaTable", handler,
  178.                                             inetNetToMediaTable_oid,
  179.                                             inetNetToMediaTable_oid_size,
  180.                                             HANDLER_CAN_BABY_STEP |
  181.                                             HANDLER_CAN_RWRITE);
  182.     if (NULL == reginfo) {
  183.         snmp_log(LOG_ERR, "error registering table inetNetToMediaTablen");
  184.         return;
  185.     }
  186.     reginfo->my_reg_void = &inetNetToMediaTable_if_ctx;
  187.     /*************************************************
  188.      *
  189.      * set up baby steps handler, create it and inject it
  190.      */
  191.     if (access_multiplexer->object_lookup)
  192.         mfd_modes |= BABY_STEP_OBJECT_LOOKUP;
  193.     if (access_multiplexer->set_values)
  194.         mfd_modes |= BABY_STEP_SET_VALUES;
  195.     if (access_multiplexer->irreversible_commit)
  196.         mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT;
  197.     if (access_multiplexer->object_syntax_checks)
  198.         mfd_modes |= BABY_STEP_CHECK_OBJECT;
  199.     if (access_multiplexer->pre_request)
  200.         mfd_modes |= BABY_STEP_PRE_REQUEST;
  201.     if (access_multiplexer->post_request)
  202.         mfd_modes |= BABY_STEP_POST_REQUEST;
  203.     if (access_multiplexer->undo_setup)
  204.         mfd_modes |= BABY_STEP_UNDO_SETUP;
  205.     if (access_multiplexer->undo_cleanup)
  206.         mfd_modes |= BABY_STEP_UNDO_CLEANUP;
  207.     if (access_multiplexer->undo_sets)
  208.         mfd_modes |= BABY_STEP_UNDO_SETS;
  209.     if (access_multiplexer->row_creation)
  210.         mfd_modes |= BABY_STEP_ROW_CREATE;
  211.     if (access_multiplexer->consistency_checks)
  212.         mfd_modes |= BABY_STEP_CHECK_CONSISTENCY;
  213.     if (access_multiplexer->commit)
  214.         mfd_modes |= BABY_STEP_COMMIT;
  215.     if (access_multiplexer->undo_commit)
  216.         mfd_modes |= BABY_STEP_UNDO_COMMIT;
  217.     handler = netsnmp_baby_steps_handler_get(mfd_modes);
  218.     netsnmp_inject_handler(reginfo, handler);
  219.     /*************************************************
  220.      *
  221.      * inject row_merge helper with prefix rootoid_len + 2 (entry.col)
  222.      */
  223.     handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2);
  224.     netsnmp_inject_handler(reginfo, handler);
  225.     /*************************************************
  226.      *
  227.      * inject container_table helper
  228.      */
  229.     handler =
  230.         netsnmp_container_table_handler_get(tbl_info,
  231.                                             inetNetToMediaTable_if_ctx.
  232.                                             container,
  233.                                             TABLE_CONTAINER_KEY_NETSNMP_INDEX);
  234.     netsnmp_inject_handler(reginfo, handler);
  235.     /*************************************************
  236.      *
  237.      * inject cache helper
  238.      */
  239.     if (NULL != inetNetToMediaTable_if_ctx.cache) {
  240.         handler =
  241.             netsnmp_cache_handler_get(inetNetToMediaTable_if_ctx.cache);
  242.         netsnmp_inject_handler(reginfo, handler);
  243.     }
  244.     /*
  245.      * register table
  246.      */
  247.     netsnmp_register_table(reginfo, tbl_info);
  248. }                               /* _inetNetToMediaTable_initialize_interface */
  249. void
  250. inetNetToMediaTable_valid_columns_set(netsnmp_column_info *vc)
  251. {
  252.     inetNetToMediaTable_if_ctx.tbl_info.valid_columns = vc;
  253. }                               /* inetNetToMediaTable_valid_columns_set */
  254. /**
  255.  * @internal
  256.  * convert the index component stored in the context to an oid
  257.  */
  258. int
  259. inetNetToMediaTable_index_to_oid(netsnmp_index * oid_idx,
  260.                                  inetNetToMediaTable_mib_index * mib_idx)
  261. {
  262.     int             err = SNMP_ERR_NOERROR;
  263.     /*
  264.      * temp storage for parsing indexes
  265.      */
  266.     /*
  267.      * inetNetToMediaIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H
  268.      */
  269.     netsnmp_variable_list var_inetNetToMediaIfIndex;
  270.     /*
  271.      * inetNetToMediaNetAddressType(2)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
  272.      */
  273.     netsnmp_variable_list var_inetNetToMediaNetAddressType;
  274.     /*
  275.      * inetNetToMediaNetAddress(3)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
  276.      */
  277.     netsnmp_variable_list var_inetNetToMediaNetAddress;
  278.     /*
  279.      * set up varbinds
  280.      */
  281.     memset(&var_inetNetToMediaIfIndex, 0x00,
  282.            sizeof(var_inetNetToMediaIfIndex));
  283.     var_inetNetToMediaIfIndex.type = ASN_INTEGER;
  284.     memset(&var_inetNetToMediaNetAddressType, 0x00,
  285.            sizeof(var_inetNetToMediaNetAddressType));
  286.     var_inetNetToMediaNetAddressType.type = ASN_INTEGER;
  287.     memset(&var_inetNetToMediaNetAddress, 0x00,
  288.            sizeof(var_inetNetToMediaNetAddress));
  289.     var_inetNetToMediaNetAddress.type = ASN_OCTET_STR;
  290.     /*
  291.      * chain temp index varbinds together
  292.      */
  293.     var_inetNetToMediaIfIndex.next_variable =
  294.         &var_inetNetToMediaNetAddressType;
  295.     var_inetNetToMediaNetAddressType.next_variable =
  296.         &var_inetNetToMediaNetAddress;
  297.     var_inetNetToMediaNetAddress.next_variable = NULL;
  298.     DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_index_to_oid", "calledn"));
  299.     /*
  300.      * inetNetToMediaIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H 
  301.      */
  302.     snmp_set_var_value(&var_inetNetToMediaIfIndex,
  303.                        (u_char *) & mib_idx->inetNetToMediaIfIndex,
  304.                        sizeof(mib_idx->inetNetToMediaIfIndex));
  305.     /*
  306.      * inetNetToMediaNetAddressType(2)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h 
  307.      */
  308.     snmp_set_var_value(&var_inetNetToMediaNetAddressType,
  309.                        (u_char *) & mib_idx->inetNetToMediaNetAddressType,
  310.                        sizeof(mib_idx->inetNetToMediaNetAddressType));
  311.     /*
  312.      * inetNetToMediaNetAddress(3)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h 
  313.      */
  314.     snmp_set_var_value(&var_inetNetToMediaNetAddress,
  315.                        (u_char *) & mib_idx->inetNetToMediaNetAddress,
  316.                        mib_idx->inetNetToMediaNetAddress_len *
  317.                        sizeof(mib_idx->inetNetToMediaNetAddress[0]));
  318.     err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len,
  319.                             NULL, 0, &var_inetNetToMediaIfIndex);
  320.     if (err)
  321.         snmp_log(LOG_ERR, "error %d converting index to oidn", err);
  322.     /*
  323.      * parsing may have allocated memory. free it.
  324.      */
  325.     snmp_reset_var_buffers(&var_inetNetToMediaIfIndex);
  326.     return err;
  327. }                               /* inetNetToMediaTable_index_to_oid */
  328. /**
  329.  * extract inetNetToMediaTable indexes from a netsnmp_index
  330.  *
  331.  * @retval SNMP_ERR_NOERROR  : no error
  332.  * @retval SNMP_ERR_GENERR   : error
  333.  */
  334. int
  335. inetNetToMediaTable_index_from_oid(netsnmp_index * oid_idx,
  336.                                    inetNetToMediaTable_mib_index * mib_idx)
  337. {
  338.     int             err = SNMP_ERR_NOERROR;
  339.     /*
  340.      * temp storage for parsing indexes
  341.      */
  342.     /*
  343.      * inetNetToMediaIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H
  344.      */
  345.     netsnmp_variable_list var_inetNetToMediaIfIndex;
  346.     /*
  347.      * inetNetToMediaNetAddressType(2)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h
  348.      */
  349.     netsnmp_variable_list var_inetNetToMediaNetAddressType;
  350.     /*
  351.      * inetNetToMediaNetAddress(3)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h
  352.      */
  353.     netsnmp_variable_list var_inetNetToMediaNetAddress;
  354.     /*
  355.      * set up varbinds
  356.      */
  357.     memset(&var_inetNetToMediaIfIndex, 0x00,
  358.            sizeof(var_inetNetToMediaIfIndex));
  359.     var_inetNetToMediaIfIndex.type = ASN_INTEGER;
  360.     memset(&var_inetNetToMediaNetAddressType, 0x00,
  361.            sizeof(var_inetNetToMediaNetAddressType));
  362.     var_inetNetToMediaNetAddressType.type = ASN_INTEGER;
  363.     memset(&var_inetNetToMediaNetAddress, 0x00,
  364.            sizeof(var_inetNetToMediaNetAddress));
  365.     var_inetNetToMediaNetAddress.type = ASN_OCTET_STR;
  366.     /*
  367.      * chain temp index varbinds together
  368.      */
  369.     var_inetNetToMediaIfIndex.next_variable =
  370.         &var_inetNetToMediaNetAddressType;
  371.     var_inetNetToMediaNetAddressType.next_variable =
  372.         &var_inetNetToMediaNetAddress;
  373.     var_inetNetToMediaNetAddress.next_variable = NULL;
  374.     DEBUGMSGTL(("verbose:inetNetToMediaTable:inetNetToMediaTable_index_from_oid", "calledn"));
  375.     /*
  376.      * parse the oid into the individual index components
  377.      */
  378.     err = parse_oid_indexes(oid_idx->oids, oid_idx->len,
  379.                             &var_inetNetToMediaIfIndex);
  380.     if (err == SNMP_ERR_NOERROR) {
  381.         /*
  382.          * copy out values
  383.          */
  384.         mib_idx->inetNetToMediaIfIndex =
  385.             *((long *) var_inetNetToMediaIfIndex.val.string);
  386.         mib_idx->inetNetToMediaNetAddressType =
  387.             *((u_long *) var_inetNetToMediaNetAddressType.val.string);
  388.         /*
  389.          * NOTE: val_len is in bytes, inetNetToMediaNetAddress_len might not be
  390.          */
  391.         if (var_inetNetToMediaNetAddress.val_len >
  392.             sizeof(mib_idx->inetNetToMediaNetAddress))
  393.             err = SNMP_ERR_GENERR;
  394.         else {
  395.             memcpy(mib_idx->inetNetToMediaNetAddress,
  396.                    var_inetNetToMediaNetAddress.val.string,
  397.                    var_inetNetToMediaNetAddress.val_len);
  398.             mib_idx->inetNetToMediaNetAddress_len =
  399.                 var_inetNetToMediaNetAddress.val_len /
  400.                 sizeof(mib_idx->inetNetToMediaNetAddress[0]);
  401.         }
  402.     }
  403.     /*
  404.      * parsing may have allocated memory. free it.
  405.      */
  406.     snmp_reset_var_buffers(&var_inetNetToMediaIfIndex);
  407.     return err;
  408. }                               /* inetNetToMediaTable_index_from_oid */
  409. /*
  410.  *********************************************************************
  411.  * @internal
  412.  * allocate resources for a inetNetToMediaTable_rowreq_ctx
  413.  */
  414. inetNetToMediaTable_rowreq_ctx *
  415. inetNetToMediaTable_allocate_rowreq_ctx(inetNetToMediaTable_data * data)
  416. {
  417.     inetNetToMediaTable_rowreq_ctx *rowreq_ctx =
  418.         SNMP_MALLOC_TYPEDEF(inetNetToMediaTable_rowreq_ctx);
  419.     DEBUGMSGTL(("internal:inetNetToMediaTable:inetNetToMediaTable_allocate_rowreq_ctx", "calledn"));
  420.     if (NULL == rowreq_ctx) {
  421.         snmp_log(LOG_ERR, "Couldn't allocate memory for a "
  422.                  "inetNetToMediaTable_rowreq_ctx.n");
  423.     } else {
  424.         if (NULL != data) {
  425.             rowreq_ctx->data = data;
  426.         } else if (NULL ==
  427.                    (rowreq_ctx->data =
  428.                     inetNetToMediaTable_allocate_data())) {
  429.             SNMP_FREE(rowreq_ctx);
  430.             return NULL;
  431.         }
  432.     }
  433.     /*
  434.      * undo context will be allocated when needed (in *_undo_setup)
  435.      */
  436.     rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp;
  437.     rowreq_ctx->inetNetToMediaTable_data_list = NULL;
  438.     rowreq_ctx->inetNetToMediaTable_reg =
  439.         inetNetToMediaTable_if_ctx.user_ctx;
  440.     return rowreq_ctx;
  441. }                               /* inetNetToMediaTable_allocate_rowreq_ctx */
  442. /*
  443.  * @internal
  444.  * release resources for a inetNetToMediaTable_rowreq_ctx
  445.  */
  446. void
  447. inetNetToMediaTable_release_rowreq_ctx(inetNetToMediaTable_rowreq_ctx *
  448.                                        rowreq_ctx)
  449. {
  450.     DEBUGMSGTL(("internal:inetNetToMediaTable:inetNetToMediaTable_release_rowreq_ctx", "calledn"));
  451.     netsnmp_assert(NULL != rowreq_ctx);
  452.     if (rowreq_ctx->data)
  453.         inetNetToMediaTable_release_data(rowreq_ctx->data);
  454.     if (rowreq_ctx->undo)
  455.         inetNetToMediaTable_release_data(rowreq_ctx->undo);
  456.     /*
  457.      * free index oid pointer
  458.      */
  459.     if (rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp)
  460.         free(rowreq_ctx->oid_idx.oids);
  461.     SNMP_FREE(rowreq_ctx);
  462. }                               /* inetNetToMediaTable_release_rowreq_ctx */
  463. /**
  464.  * @internal
  465.  * wrapper
  466.  */
  467. static int
  468. _mfd_inetNetToMediaTable_pre_request(netsnmp_mib_handler *handler,
  469.                                      netsnmp_handler_registration *reginfo,
  470.                                      netsnmp_agent_request_info
  471.                                      *agtreq_info,
  472.                                      netsnmp_request_info *requests)
  473. {
  474.     int             rc =
  475.         inetNetToMediaTable_pre_request(inetNetToMediaTable_if_ctx.
  476.                                         user_ctx);
  477.     if (MFD_SUCCESS != rc) {
  478.         /*
  479.          * nothing we can do about it but log it
  480.          */
  481.         DEBUGMSGTL(("internal:inetNetToMediaTable", "error %d from "
  482.                     "inetNetToMediaTable_pre_requestn", rc));
  483.         netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
  484.     }
  485.     return SNMP_ERR_NOERROR;
  486. }                               /* _mfd_inetNetToMediaTable_pre_request */
  487. /**
  488.  * @internal
  489.  * wrapper
  490.  */
  491. static int
  492. _mfd_inetNetToMediaTable_post_request(netsnmp_mib_handler *handler, netsnmp_handler_registration
  493.                                       *reginfo, netsnmp_agent_request_info
  494.                                       *agtreq_info,
  495.                                       netsnmp_request_info *requests)
  496. {
  497.     inetNetToMediaTable_rowreq_ctx *rowreq_ctx;
  498.     int             rc =
  499.         inetNetToMediaTable_post_request(inetNetToMediaTable_if_ctx.
  500.                                          user_ctx);
  501.     if (MFD_SUCCESS != rc) {
  502.         /*
  503.          * nothing we can do about it but log it
  504.          */
  505.         DEBUGMSGTL(("internal:inetNetToMediaTable", "error %d from "
  506.                     "inetNetToMediaTable_post_requestn", rc));
  507.     }
  508.     /*
  509.      * if it was set, clear row created flag.
  510.      */
  511.     rowreq_ctx = netsnmp_container_table_row_extract(requests);
  512.     if ((NULL != rowreq_ctx)
  513.         && (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED))
  514.         rowreq_ctx->rowreq_flags &= ~MFD_ROW_CREATED;
  515.     return SNMP_ERR_NOERROR;
  516. }                               /* _mfd_inetNetToMediaTable_post_request */
  517. /**
  518.  * @internal
  519.  * wrapper
  520.  */
  521. static int
  522. _mfd_inetNetToMediaTable_object_lookup(netsnmp_mib_handler *handler, netsnmp_handler_registration
  523.                                        *reginfo, netsnmp_agent_request_info
  524.                                        *agtreq_info,
  525.                                        netsnmp_request_info *requests)
  526. {
  527.     inetNetToMediaTable_rowreq_ctx *rowreq_ctx =
  528.         netsnmp_container_table_row_extract(requests);
  529.     DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_object_lookup", "calledn"));
  530.     /*
  531.      * get our context from mfd
  532.      * inetNetToMediaTable_interface_ctx *if_ctx =
  533.      *             (inetNetToMediaTable_interface_ctx *)reginfo->my_reg_void;
  534.      */
  535.     if (NULL == rowreq_ctx) {
  536.         int             rc = MFD_SUCCESS;
  537.         netsnmp_table_request_info *tblreq_info;
  538.         netsnmp_index   oid_idx;
  539.         inetNetToMediaTable_mib_index mib_idx;
  540.         tblreq_info = netsnmp_extract_table_info(requests);
  541.         if (NULL == tblreq_info) {
  542.             snmp_log(LOG_ERR, "request had no table infon");
  543.             return MFD_ERROR;
  544.         }
  545.         /*
  546.          * try to parse oid
  547.          */
  548.         oid_idx.oids = tblreq_info->index_oid;
  549.         oid_idx.len = tblreq_info->index_oid_len;
  550.         rc = inetNetToMediaTable_index_from_oid(&oid_idx, &mib_idx);
  551.         if (MFD_SUCCESS != rc) {
  552.             DEBUGMSGT(("inetNetToMediaTable", "error parsing indexn"));
  553.             netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
  554.         } else {
  555.             /*
  556.              * allocate new context
  557.              */
  558.             rowreq_ctx = inetNetToMediaTable_allocate_rowreq_ctx(NULL);
  559.             if (NULL == rowreq_ctx)
  560.                 return MFD_ERROR;       /* msg already logged */
  561.             memcpy(&rowreq_ctx->tbl_idx, &mib_idx, sizeof(mib_idx));
  562.             /*
  563.              * check indexes
  564.              */
  565.             rc = _inetNetToMediaTable_check_indexes(rowreq_ctx);
  566.             if (MFD_SUCCESS != rc) {
  567.                 netsnmp_assert((rc == SNMP_ERR_NOCREATION) ||
  568.                                (rc == SNMP_ERR_INCONSISTENTNAME));
  569.                 netsnmp_request_set_error_all(requests,
  570.                                               SNMP_VALIDATE_ERR(rc));
  571.                 inetNetToMediaTable_release_rowreq_ctx(rowreq_ctx);
  572.             } else {
  573.                 rowreq_ctx->rowreq_flags |= MFD_ROW_CREATED;
  574.                 netsnmp_container_table_row_insert(requests, rowreq_ctx);
  575.             }
  576.         }
  577.     } else {
  578.         inetNetToMediaTable_row_prep(rowreq_ctx);
  579.     }
  580.     return SNMP_ERR_NOERROR;
  581. }                               /* _mfd_inetNetToMediaTable_object_lookup */
  582. /***********************************************************************
  583.  *
  584.  * GET processing
  585.  *
  586.  ***********************************************************************/
  587. /*
  588.  * @internal
  589.  * Retrieve the value for a particular column
  590.  */
  591. NETSNMP_STATIC_INLINE int
  592. _inetNetToMediaTable_get_column(inetNetToMediaTable_rowreq_ctx *
  593.                                 rowreq_ctx, netsnmp_variable_list * var,
  594.                                 int column)
  595. {
  596.     int             rc = SNMPERR_SUCCESS;
  597.     DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_get_column", "calledn"));
  598.     netsnmp_assert(NULL != rowreq_ctx);
  599.     switch (column) {
  600.         /*
  601.          * inetNetToMediaPhysAddress(4)/PhysAddress/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H 
  602.          */
  603.     case COLUMN_INETNETTOMEDIAPHYSADDRESS:
  604.         var->type = ASN_OCTET_STR;
  605.         rc = inetNetToMediaPhysAddress_get(rowreq_ctx,
  606.                                            (char **) &var->val.string,
  607.                                            &var->val_len);
  608.         break;
  609.         /*
  610.          * inetNetToMediaLastUpdated(5)/TimeStamp/ASN_TIMETICKS/u_long(u_long)//l/A/w/e/r/d/h 
  611.          */
  612.     case COLUMN_INETNETTOMEDIALASTUPDATED:
  613.         var->val_len = sizeof(u_long);
  614.         var->type = ASN_TIMETICKS;
  615.         rc = inetNetToMediaLastUpdated_get(rowreq_ctx,
  616.                                            (u_long *) var->val.string);
  617.         break;
  618.         /*
  619.          * inetNetToMediaType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h 
  620.          */
  621.     case COLUMN_INETNETTOMEDIATYPE:
  622.         var->val_len = sizeof(u_long);
  623.         var->type = ASN_INTEGER;
  624.         rc = inetNetToMediaType_get(rowreq_ctx,
  625.                                     (u_long *) var->val.string);
  626.         break;
  627.         /*
  628.          * inetNetToMediaState(7)/INTEGER/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h 
  629.          */
  630.     case COLUMN_INETNETTOMEDIASTATE:
  631.         var->val_len = sizeof(u_long);
  632.         var->type = ASN_INTEGER;
  633.         rc = inetNetToMediaState_get(rowreq_ctx,
  634.                                      (u_long *) var->val.string);
  635.         break;
  636.         /*
  637.          * inetNetToMediaRowStatus(8)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h 
  638.          */
  639.     case COLUMN_INETNETTOMEDIAROWSTATUS:
  640.         var->val_len = sizeof(u_long);
  641.         var->type = ASN_INTEGER;
  642.         rc = inetNetToMediaRowStatus_get(rowreq_ctx,
  643.                                          (u_long *) var->val.string);
  644.         break;
  645.     default:
  646.         snmp_log(LOG_ERR,
  647.                  "unknown column %d in _inetNetToMediaTable_get_columnn",
  648.                  column);
  649.         break;
  650.     }
  651.     return rc;
  652. }                               /* _inetNetToMediaTable_get_column */
  653. int
  654. _mfd_inetNetToMediaTable_get_values(netsnmp_mib_handler *handler,
  655.                                     netsnmp_handler_registration *reginfo,
  656.                                     netsnmp_agent_request_info
  657.                                     *agtreq_info,
  658.                                     netsnmp_request_info *requests)
  659. {
  660.     inetNetToMediaTable_rowreq_ctx *rowreq_ctx =
  661.         netsnmp_container_table_row_extract(requests);
  662.     netsnmp_table_request_info *tri;
  663.     u_char         *old_string;
  664.     void            (*dataFreeHook) (void *);
  665.     int             rc;
  666.     DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_get_values", "calledn"));
  667.     netsnmp_assert(NULL != rowreq_ctx);
  668.     for (; requests; requests = requests->next) {
  669.         /*
  670.          * save old pointer, so we can free it if replaced
  671.          */
  672.         old_string = requests->requestvb->val.string;
  673.         dataFreeHook = requests->requestvb->dataFreeHook;
  674.         if (NULL == requests->requestvb->val.string) {
  675.             requests->requestvb->val.string = requests->requestvb->buf;
  676.             requests->requestvb->val_len =
  677.                 sizeof(requests->requestvb->buf);
  678.         } else if (requests->requestvb->buf ==
  679.                    requests->requestvb->val.string) {
  680.             if (requests->requestvb->val_len !=
  681.                 sizeof(requests->requestvb->buf))
  682.                 requests->requestvb->val_len =
  683.                     sizeof(requests->requestvb->buf);
  684.         }
  685.         /*
  686.          * get column data
  687.          */
  688.         tri = netsnmp_extract_table_info(requests);
  689.         if (NULL == tri)
  690.             continue;
  691.         rc = _inetNetToMediaTable_get_column(rowreq_ctx,
  692.                                              requests->requestvb,
  693.                                              tri->colnum);
  694.         if (rc) {
  695.             if (MFD_SKIP == rc) {
  696.                 requests->requestvb->type = ASN_PRIV_RETRY;
  697.                 rc = SNMP_ERR_NOERROR;
  698.             }
  699.         } else if (NULL == requests->requestvb->val.string) {
  700.             snmp_log(LOG_ERR, "NULL varbind data pointer!n");
  701.             rc = SNMP_ERR_GENERR;
  702.         }
  703.         if (rc)
  704.             netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc));
  705.         /*
  706.          * if the buffer wasn't used previously for the old data (i.e. it
  707.          * was allcoated memory)  and the get routine replaced the pointer,
  708.          * we need to free the previous pointer.
  709.          */
  710.         if (old_string && (old_string != requests->requestvb->buf) &&
  711.             (requests->requestvb->val.string != old_string)) {
  712.             if (dataFreeHook)
  713.                 (*dataFreeHook) (old_string);
  714.             else
  715.                 free(old_string);
  716.         }
  717.     }                           /* for results */
  718.     return SNMP_ERR_NOERROR;
  719. }                               /* _mfd_inetNetToMediaTable_get_values */
  720. /***********************************************************************
  721.  *
  722.  * SET processing
  723.  *
  724.  ***********************************************************************/
  725. /*----------------------------------------------------------------------
  726.  *
  727.  * SET: Syntax checks
  728.  *
  729.  *---------------------------------------------------------------------*/
  730. /*
  731.  * @internal
  732.  * Check the syntax for a particular column
  733.  */
  734. NETSNMP_STATIC_INLINE int
  735. _inetNetToMediaTable_check_column(inetNetToMediaTable_rowreq_ctx *
  736.                                   rowreq_ctx, netsnmp_variable_list * var,
  737.                                   int column)
  738. {
  739.     int             rc = SNMPERR_SUCCESS;
  740.     DEBUGMSGTL(("internal:inetNetToMediaTable:_inetNetToMediaTable_check_column", "calledn"));
  741.     netsnmp_assert(NULL != rowreq_ctx);
  742.     switch (column) {
  743.         /*
  744.          * inetNetToMediaPhysAddress(4)/PhysAddress/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H 
  745.          */
  746.     case COLUMN_INETNETTOMEDIAPHYSADDRESS:
  747.         rc = netsnmp_check_vb_type(var, ASN_OCTET_STR);
  748.         if (SNMPERR_SUCCESS == rc) {
  749.             /*
  750.              * check that the value is in the defined range(s); inefficent
  751.              * * but keeps rc value knowledge in libarary where it belongs. 
  752.              */
  753.             if (1
  754.                 && ((rc = netsnmp_check_vb_size_range(var, 0, 65535)) !=
  755.                     SNMP_ERR_NOERROR)
  756.                 ) {
  757.                 ;               /* rc set in condition */
  758.             }
  759.         }
  760.         if (SNMPERR_SUCCESS == rc) {
  761.             rc = inetNetToMediaPhysAddress_check_value(rowreq_ctx,
  762.                                                        (char *) var->val.
  763.                                                        string,
  764.                                                        var->val_len);
  765.             if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
  766.                 && (MFD_NOT_VALID_NOW != rc)) {
  767.                 snmp_log(LOG_ERR,
  768.                          "bad rc %d from inetNetToMediaPhysAddress_check_valuen",
  769.                          rc);
  770.                 rc = SNMP_ERR_GENERR;
  771.             }
  772.         }
  773.         break;
  774.         /*
  775.          * inetNetToMediaType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h 
  776.          */
  777.     case COLUMN_INETNETTOMEDIATYPE:
  778.         rc = netsnmp_check_vb_type(var, ASN_INTEGER);
  779.         if (SNMPERR_SUCCESS == rc) {
  780.             /*
  781.              * check that the value is one of defined enums 
  782.              */
  783.             if (1 && (*var->val.integer != INETNETTOMEDIATYPE_OTHER)
  784.                 && (*var->val.integer != INETNETTOMEDIATYPE_INVALID)
  785.                 && (*var->val.integer != INETNETTOMEDIATYPE_DYNAMIC)
  786.                 && (*var->val.integer != INETNETTOMEDIATYPE_STATIC)
  787.                 && (*var->val.integer != INETNETTOMEDIATYPE_LOCAL)
  788.                 ) {
  789.                 rc = SNMP_ERR_WRONGVALUE;
  790.             }
  791.         }
  792.         if (SNMPERR_SUCCESS == rc) {
  793.             rc = inetNetToMediaType_check_value(rowreq_ctx,
  794.                                                 *((u_long *) var->val.
  795.                                                   string));
  796.             if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
  797.                 && (MFD_NOT_VALID_NOW != rc)) {
  798.                 snmp_log(LOG_ERR,
  799.                          "bad rc %d from inetNetToMediaType_check_valuen",
  800.                          rc);
  801.                 rc = SNMP_ERR_GENERR;
  802.             }
  803.         }
  804.         break;
  805.         /*
  806.          * inetNetToMediaRowStatus(8)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h 
  807.          */
  808.     case COLUMN_INETNETTOMEDIAROWSTATUS:
  809.         rc = netsnmp_check_vb_rowstatus_value(var);
  810.         if (SNMPERR_SUCCESS == rc) {
  811.             rc = inetNetToMediaRowStatus_check_value(rowreq_ctx,
  812.                                                      *((u_long *) var->val.
  813.                                                        string));
  814.             if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
  815.                 && (MFD_NOT_VALID_NOW != rc)) {
  816.                 snmp_log(LOG_ERR,
  817.                          "bad rc %d from inetNetToMediaRowStatus_check_valuen",
  818.                          rc);
  819.                 rc = SNMP_ERR_GENERR;
  820.             }
  821.         }
  822.         break;
  823.     default:   /** We shouldn't get here */
  824.         rc = SNMP_ERR_GENERR;
  825.         snmp_log(LOG_ERR,
  826.                  "unknown column %d in _inetNetToMediaTable_check_columnn",
  827.                  column);
  828.     }
  829.     return rc;
  830. }                               /* _inetNetToMediaTable_check_column */
  831. int
  832. _mfd_inetNetToMediaTable_check_objects(netsnmp_mib_handler *handler, netsnmp_handler_registration
  833.                                        *reginfo, netsnmp_agent_request_info
  834.                                        *agtreq_info,
  835.                                        netsnmp_request_info *requests)
  836. {
  837.     inetNetToMediaTable_rowreq_ctx *rowreq_ctx =
  838.         netsnmp_container_table_row_extract(requests);
  839.     netsnmp_table_request_info *tri;
  840.     int             rc;
  841.     DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_check_objects", "calledn"));
  842.     netsnmp_assert(NULL != rowreq_ctx);
  843.     for (; requests; requests = requests->next) {
  844.         /*
  845.          * get column number from table request info, and check that column
  846.          */
  847.         tri = netsnmp_extract_table_info(requests);
  848.         if (NULL == tri)
  849.             continue;
  850.         rc = _inetNetToMediaTable_check_column(rowreq_ctx,
  851.                                                requests->requestvb,
  852.                                                tri->colnum);
  853.         if (rc) {
  854.             netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc));
  855.             break;
  856.         }
  857.     }                           /* for results */
  858.     return SNMP_ERR_NOERROR;
  859. }                               /* _mfd_inetNetToMediaTable_check_objects */
  860. NETSNMP_STATIC_INLINE int
  861. _inetNetToMediaTable_check_indexes(inetNetToMediaTable_rowreq_ctx *
  862.                                    rowreq_ctx)
  863. {
  864.     int             rc;
  865.     DEBUGMSGTL(("internal:inetNetToMediaTable:_inetNetToMediaTable_check_indexes", "calledn"));
  866.     netsnmp_assert(NULL != rowreq_ctx);
  867.     /*
  868.      * (INDEX) inetNetToMediaIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H 
  869.      */
  870.     rc = inetNetToMediaIfIndex_check_index(rowreq_ctx);
  871.     if (MFD_SUCCESS != rc)
  872.         return SNMP_ERR_NOCREATION;
  873.     /*
  874.      * (INDEX) inetNetToMediaNetAddressType(2)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h 
  875.      */
  876.     rc = inetNetToMediaNetAddressType_check_index(rowreq_ctx);
  877.     if (MFD_SUCCESS != rc)
  878.         return SNMP_ERR_NOCREATION;
  879.     /*
  880.      * (INDEX) inetNetToMediaNetAddress(3)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h 
  881.      */
  882.     rc = inetNetToMediaNetAddress_check_index(rowreq_ctx);
  883.     if (MFD_SUCCESS != rc)
  884.         return SNMP_ERR_NOCREATION;
  885.     /*
  886.      * if individual parts look ok, check them as a whole
  887.      */
  888.     return inetNetToMediaTable_validate_index(rowreq_ctx->
  889.                                               inetNetToMediaTable_reg,
  890.                                               rowreq_ctx);
  891. }                               /* _inetNetToMediaTable_check_indexes */
  892. /*----------------------------------------------------------------------
  893.  *
  894.  * SET: check dependencies
  895.  *
  896.  *---------------------------------------------------------------------*/
  897. /*
  898.  * @internal
  899.  * Check dependencies wrapper
  900.  */
  901. static int
  902. _mfd_inetNetToMediaTable_check_dependencies(netsnmp_mib_handler *handler, netsnmp_handler_registration
  903.                                             *reginfo, netsnmp_agent_request_info
  904.                                             *agtreq_info,
  905.                                             netsnmp_request_info *requests)
  906. {
  907.     int             rc;
  908.     inetNetToMediaTable_rowreq_ctx *rowreq_ctx =
  909.         netsnmp_container_table_row_extract(requests);
  910.     DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_check_dependencies", "calledn"));
  911.     netsnmp_assert(NULL != rowreq_ctx);
  912.     rc = inetNetToMediaTable_check_dependencies(rowreq_ctx);
  913.     if (rc) {
  914.         DEBUGMSGTL(("verbose:inetNetToMediaTable:mfd", "error %d from "
  915.                     "inetNetToMediaTable_check_dependenciesn", rc));
  916.         netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
  917.     }
  918.     return SNMP_ERR_NOERROR;
  919. }                               /* _mfd_inetNetToMediaTable_check_dependencies */
  920. /*----------------------------------------------------------------------
  921.  *
  922.  * SET: Undo setup
  923.  *
  924.  *---------------------------------------------------------------------*/
  925. /*
  926.  * @internal
  927.  * Set the value for a particular column
  928.  */
  929. NETSNMP_STATIC_INLINE int
  930. _inetNetToMediaTable_undo_setup_column(inetNetToMediaTable_rowreq_ctx *
  931.                                        rowreq_ctx, int column)
  932. {
  933.     int             rc = SNMPERR_SUCCESS;
  934.     DEBUGMSGTL(("internal:inetNetToMediaTable:_inetNetToMediaTable_undo_setup_column", "calledn"));
  935.     netsnmp_assert(NULL != rowreq_ctx);
  936.     switch (column) {
  937.         /*
  938.          * inetNetToMediaPhysAddress(4)/PhysAddress/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H 
  939.          */
  940.     case COLUMN_INETNETTOMEDIAPHYSADDRESS:
  941.         rowreq_ctx->column_set_flags |= FLAG_INETNETTOMEDIAPHYSADDRESS;
  942.         rc = inetNetToMediaPhysAddress_undo_setup(rowreq_ctx);
  943.         break;
  944.         /*
  945.          * inetNetToMediaType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h 
  946.          */
  947.     case COLUMN_INETNETTOMEDIATYPE:
  948.         rowreq_ctx->column_set_flags |= FLAG_INETNETTOMEDIATYPE;
  949.         rc = inetNetToMediaType_undo_setup(rowreq_ctx);
  950.         break;
  951.         /*
  952.          * inetNetToMediaRowStatus(8)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h 
  953.          */
  954.     case COLUMN_INETNETTOMEDIAROWSTATUS:
  955.         rowreq_ctx->column_set_flags |= FLAG_INETNETTOMEDIAROWSTATUS;
  956.         rc = inetNetToMediaRowStatus_undo_setup(rowreq_ctx);
  957.         break;
  958.     default:
  959.         snmp_log(LOG_ERR,
  960.                  "unknown column %d in _inetNetToMediaTable_undo_setup_columnn",
  961.                  column);
  962.         break;
  963.     }
  964.     return rc;
  965. }                               /* _inetNetToMediaTable_undo_setup_column */
  966. /**
  967.  * @internal
  968.  * undo setup
  969.  */
  970. int
  971. _mfd_inetNetToMediaTable_undo_setup(netsnmp_mib_handler *handler,
  972.                                     netsnmp_handler_registration *reginfo,
  973.                                     netsnmp_agent_request_info
  974.                                     *agtreq_info,
  975.                                     netsnmp_request_info *requests)
  976. {
  977.     int             rc;
  978.     inetNetToMediaTable_rowreq_ctx *rowreq_ctx =
  979.         netsnmp_container_table_row_extract(requests);
  980.     DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_undo_setup", "calledn"));
  981.     netsnmp_assert(NULL != rowreq_ctx);
  982.     /*
  983.      * allocate undo context
  984.      */
  985.     rowreq_ctx->undo = inetNetToMediaTable_allocate_data();
  986.     if (NULL == rowreq_ctx->undo) {
  987.         /** msg already logged */
  988.         netsnmp_request_set_error_all(requests,
  989.                                       SNMP_ERR_RESOURCEUNAVAILABLE);
  990.         return SNMP_ERR_NOERROR;
  991.     }
  992.     /*
  993.      * row undo setup
  994.      */
  995.     rowreq_ctx->column_set_flags = 0;
  996.     rc = inetNetToMediaTable_undo_setup(rowreq_ctx);
  997.     if (MFD_SUCCESS != rc) {
  998.         DEBUGMSGTL(("verbose:inetNetToMediaTable:mfd", "error %d from "
  999.                     "inetNetToMediaTable_undo_setupn", rc));
  1000.         netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
  1001.     } else {
  1002.         /*
  1003.          * column undo setup
  1004.          */
  1005.         netsnmp_table_request_info *tri;
  1006.         for (; requests; requests = requests->next) {
  1007.             /*
  1008.              * set column data
  1009.              */
  1010.             tri = netsnmp_extract_table_info(requests);
  1011.             if (NULL == tri)
  1012.                 continue;
  1013.             rc = _inetNetToMediaTable_undo_setup_column(rowreq_ctx,
  1014.                                                         tri->colnum);
  1015.             if (MFD_SUCCESS != rc) {
  1016.                 DEBUGMSGTL(("verbose:inetNetToMediaTable:mfd",
  1017.                             "error %d from "
  1018.                             "inetNetToMediaTable_undo_setup_columnn",
  1019.                             rc));
  1020.                 netsnmp_set_request_error(agtreq_info, requests,
  1021.                                           SNMP_VALIDATE_ERR(rc));
  1022.             }
  1023.         }                       /* for results */
  1024.     }
  1025.     return SNMP_ERR_NOERROR;
  1026. }                               /* _mfd_inetNetToMediaTable_undo_setup */
  1027. /**
  1028.  * @internal
  1029.  * undo setup
  1030.  */
  1031. int
  1032. _mfd_inetNetToMediaTable_undo_cleanup(netsnmp_mib_handler *handler, netsnmp_handler_registration
  1033.                                       *reginfo, netsnmp_agent_request_info
  1034.                                       *agtreq_info,
  1035.                                       netsnmp_request_info *requests)
  1036. {
  1037.     inetNetToMediaTable_rowreq_ctx *rowreq_ctx =
  1038.         netsnmp_container_table_row_extract(requests);
  1039.     int             rc;
  1040.     DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_undo_cleanup", "calledn"));
  1041.     /*
  1042.      * failed row create in early stages has no rowreq_ctx
  1043.      */
  1044.     if (NULL == rowreq_ctx)
  1045.         return MFD_SUCCESS;
  1046.     /*
  1047.      * call user cleanup
  1048.      */
  1049.     rc = inetNetToMediaTable_undo_cleanup(rowreq_ctx);
  1050.     if (MFD_SUCCESS != rc) {
  1051.         /*
  1052.          * nothing we can do about it but log it
  1053.          */
  1054.         DEBUGMSGTL(("verbose:inetNetToMediaTable:mfd", "error %d from "
  1055.                     "inetNetToMediaTable_undo_cleanupn", rc));
  1056.     }
  1057.     /*
  1058.      * release undo context, if needed
  1059.      */
  1060.     if (rowreq_ctx->undo) {
  1061.         inetNetToMediaTable_release_data(rowreq_ctx->undo);
  1062.         rowreq_ctx->undo = NULL;
  1063.     }
  1064.     /*
  1065.      * clear set flags
  1066.      */
  1067.     rowreq_ctx->column_set_flags = 0;
  1068.     return SNMP_ERR_NOERROR;
  1069. }                               /* _mfd_inetNetToMediaTable_undo_cleanup */
  1070. /*----------------------------------------------------------------------
  1071.  *
  1072.  * SET: Set values
  1073.  *
  1074.  *---------------------------------------------------------------------*/
  1075. /*
  1076.  * @internal
  1077.  * Set the value for a particular column
  1078.  */
  1079. NETSNMP_STATIC_INLINE int
  1080. _inetNetToMediaTable_set_column(inetNetToMediaTable_rowreq_ctx *
  1081.                                 rowreq_ctx, netsnmp_variable_list * var,
  1082.                                 int column)
  1083. {
  1084.     int             rc = SNMPERR_SUCCESS;
  1085.     DEBUGMSGTL(("internal:inetNetToMediaTable:_inetNetToMediaTable_set_column", "calledn"));
  1086.     netsnmp_assert(NULL != rowreq_ctx);
  1087.     switch (column) {
  1088.         /*
  1089.          * inetNetToMediaPhysAddress(4)/PhysAddress/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H 
  1090.          */
  1091.     case COLUMN_INETNETTOMEDIAPHYSADDRESS:
  1092.         rowreq_ctx->column_set_flags |= FLAG_INETNETTOMEDIAPHYSADDRESS;
  1093.         rc = inetNetToMediaPhysAddress_set(rowreq_ctx,
  1094.                                            (char *) var->val.string,
  1095.                                            var->val_len);
  1096.         break;
  1097.         /*
  1098.          * inetNetToMediaType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h 
  1099.          */
  1100.     case COLUMN_INETNETTOMEDIATYPE:
  1101.         if (var->val_len != sizeof(u_long)) {
  1102.             rc = SNMP_ERR_WRONGLENGTH;
  1103.             snmp_log(LOG_ERR,
  1104.                      "varbind size of %d does not match expected size %dn",
  1105.                      var->val_len, sizeof(u_long));
  1106.             break;
  1107.         }
  1108.         rowreq_ctx->column_set_flags |= FLAG_INETNETTOMEDIATYPE;
  1109.         rc = inetNetToMediaType_set(rowreq_ctx,
  1110.                                     *((u_long *) var->val.string));
  1111.         break;
  1112.         /*
  1113.          * inetNetToMediaRowStatus(8)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h 
  1114.          */
  1115.     case COLUMN_INETNETTOMEDIAROWSTATUS:
  1116.         if (var->val_len != sizeof(u_long)) {
  1117.             rc = SNMP_ERR_WRONGLENGTH;
  1118.             snmp_log(LOG_ERR,
  1119.                      "varbind size of %d does not match expected size %dn",
  1120.                      var->val_len, sizeof(u_long));
  1121.             break;
  1122.         }
  1123.         rowreq_ctx->column_set_flags |= FLAG_INETNETTOMEDIAROWSTATUS;
  1124.         rc = inetNetToMediaRowStatus_set(rowreq_ctx,
  1125.                                          *((u_long *) var->val.string));
  1126.         break;
  1127.     default:
  1128.         snmp_log(LOG_ERR,
  1129.                  "unknown column %d in _inetNetToMediaTable_set_columnn",
  1130.                  column);
  1131.         break;
  1132.     }
  1133.     return rc;
  1134. }                               /* _inetNetToMediaTable_set_column */
  1135. int
  1136. _mfd_inetNetToMediaTable_set_values(netsnmp_mib_handler *handler,
  1137.                                     netsnmp_handler_registration *reginfo,
  1138.                                     netsnmp_agent_request_info
  1139.                                     *agtreq_info,
  1140.                                     netsnmp_request_info *requests)
  1141. {
  1142.     inetNetToMediaTable_rowreq_ctx *rowreq_ctx =
  1143.         netsnmp_container_table_row_extract(requests);
  1144.     netsnmp_table_request_info *tri;
  1145.     int             rc = SNMP_ERR_NOERROR;
  1146.     DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_set_values", "calledn"));
  1147.     netsnmp_assert(NULL != rowreq_ctx);
  1148.     rowreq_ctx->column_set_flags = 0;
  1149.     for (; requests; requests = requests->next) {
  1150.         /*
  1151.          * set column data
  1152.          */
  1153.         tri = netsnmp_extract_table_info(requests);
  1154.         if (NULL == tri)
  1155.             continue;
  1156.         rc = _inetNetToMediaTable_set_column(rowreq_ctx,
  1157.                                              requests->requestvb,
  1158.                                              tri->colnum);
  1159.         if (MFD_SUCCESS != rc) {
  1160.             DEBUGMSGTL(("verbose:inetNetToMediaTable:mfd", "error %d from "
  1161.                         "inetNetToMediaTable_set_columnn", rc));
  1162.             netsnmp_set_request_error(agtreq_info, requests,
  1163.                                       SNMP_VALIDATE_ERR(rc));
  1164.         }
  1165.     }                           /* for results */
  1166.     return SNMP_ERR_NOERROR;
  1167. }                               /* _mfd_inetNetToMediaTable_set_values */
  1168. /*----------------------------------------------------------------------
  1169.  *
  1170.  * SET: commit
  1171.  *
  1172.  *---------------------------------------------------------------------*/
  1173. /**
  1174.  * @internal
  1175.  * commit the values
  1176.  */
  1177. int
  1178. _mfd_inetNetToMediaTable_commit(netsnmp_mib_handler *handler,
  1179.                                 netsnmp_handler_registration *reginfo,
  1180.                                 netsnmp_agent_request_info *agtreq_info,
  1181.                                 netsnmp_request_info *requests)
  1182. {
  1183.     int             rc;
  1184.     inetNetToMediaTable_rowreq_ctx *rowreq_ctx =
  1185.         netsnmp_container_table_row_extract(requests);
  1186.     DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_commit", "calledn"));
  1187.     netsnmp_assert(NULL != rowreq_ctx);
  1188.     rc = inetNetToMediaTable_commit(rowreq_ctx);
  1189.     if (MFD_SUCCESS != rc) {
  1190.         DEBUGMSGTL(("verbose:inetNetToMediaTable:mfd", "error %d from "
  1191.                     "inetNetToMediaTable_commitn", rc));
  1192.         netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
  1193.     }
  1194.     return SNMP_ERR_NOERROR;
  1195. }
  1196. int
  1197. _mfd_inetNetToMediaTable_undo_commit(netsnmp_mib_handler *handler,
  1198.                                      netsnmp_handler_registration *reginfo,
  1199.                                      netsnmp_agent_request_info
  1200.                                      *agtreq_info,
  1201.                                      netsnmp_request_info *requests)
  1202. {
  1203.     int             rc;
  1204.     inetNetToMediaTable_rowreq_ctx *rowreq_ctx =
  1205.         netsnmp_container_table_row_extract(requests);
  1206.     DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_undo_commit", "calledn"));
  1207.     netsnmp_assert(NULL != rowreq_ctx);
  1208.     rc = inetNetToMediaTable_undo_commit(rowreq_ctx);
  1209.     if (MFD_SUCCESS != rc) {
  1210.         /*
  1211.          * nothing we can do about it but log it
  1212.          */
  1213.         DEBUGMSGTL(("verbose:inetNetToMediaTable:mfd", "error %d from "
  1214.                     "inetNetToMediaTable_undo_commitn", rc));
  1215.     }
  1216.     return SNMP_ERR_NOERROR;
  1217. }                               /* _mfd_inetNetToMediaTable_commit */
  1218. /*----------------------------------------------------------------------
  1219.  *
  1220.  * SET: Undo
  1221.  *
  1222.  *---------------------------------------------------------------------*/
  1223. /**
  1224.  * @internal
  1225.  * undo the value for a particular column
  1226.  */
  1227. NETSNMP_STATIC_INLINE int
  1228. _inetNetToMediaTable_undo_column(inetNetToMediaTable_rowreq_ctx *
  1229.                                  rowreq_ctx, netsnmp_variable_list * var,
  1230.                                  int column)
  1231. {
  1232.     int             rc = SNMPERR_SUCCESS;
  1233.     DEBUGMSGTL(("internal:inetNetToMediaTable:_inetNetToMediaTable_undo_column", "calledn"));
  1234.     netsnmp_assert(NULL != rowreq_ctx);
  1235.     switch (column) {
  1236.         /*
  1237.          * inetNetToMediaPhysAddress(4)/PhysAddress/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H 
  1238.          */
  1239.     case COLUMN_INETNETTOMEDIAPHYSADDRESS:
  1240.         rc = inetNetToMediaPhysAddress_undo(rowreq_ctx);
  1241.         break;
  1242.         /*
  1243.          * inetNetToMediaType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h 
  1244.          */
  1245.     case COLUMN_INETNETTOMEDIATYPE:
  1246.         rc = inetNetToMediaType_undo(rowreq_ctx);
  1247.         break;
  1248.         /*
  1249.          * inetNetToMediaRowStatus(8)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h 
  1250.          */
  1251.     case COLUMN_INETNETTOMEDIAROWSTATUS:
  1252.         rc = inetNetToMediaRowStatus_undo(rowreq_ctx);
  1253.         break;
  1254.     default:
  1255.         snmp_log(LOG_ERR,
  1256.                  "unknown column %d in _inetNetToMediaTable_undo_columnn",
  1257.                  column);
  1258.         break;
  1259.     }
  1260.     return rc;
  1261. }                               /* _inetNetToMediaTable_undo_column */
  1262. int
  1263. _mfd_inetNetToMediaTable_undo_values(netsnmp_mib_handler *handler,
  1264.                                      netsnmp_handler_registration *reginfo,
  1265.                                      netsnmp_agent_request_info
  1266.                                      *agtreq_info,
  1267.                                      netsnmp_request_info *requests)
  1268. {
  1269.     int             rc;
  1270.     inetNetToMediaTable_rowreq_ctx *rowreq_ctx =
  1271.         netsnmp_container_table_row_extract(requests);
  1272.     netsnmp_table_request_info *tri;
  1273.     DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_undo_values", "calledn"));
  1274.     netsnmp_assert(NULL != rowreq_ctx);
  1275.     for (; requests; requests = requests->next) {
  1276.         /*
  1277.          * set column data
  1278.          */
  1279.         tri = netsnmp_extract_table_info(requests);
  1280.         if (NULL == tri)
  1281.             continue;
  1282.         rc = _inetNetToMediaTable_undo_column(rowreq_ctx,
  1283.                                               requests->requestvb,
  1284.                                               tri->colnum);
  1285.         if (MFD_SUCCESS != rc) {
  1286.             /*
  1287.              * nothing we can do about it but log it
  1288.              */
  1289.             DEBUGMSGTL(("verbose:inetNetToMediaTable:mfd", "error %d from "
  1290.                         "inetNetToMediaTable_undo_columnn", rc));
  1291.         }
  1292.     }                           /* for results */
  1293.     return SNMP_ERR_NOERROR;
  1294. }                               /* _mfd_inetNetToMediaTable_undo_values */
  1295. /***********************************************************************
  1296.  *
  1297.  * DATA ACCESS
  1298.  *
  1299.  ***********************************************************************/
  1300. /**
  1301.  * @internal
  1302.  */
  1303. static int
  1304. _cache_load(netsnmp_cache * cache, void *vmagic)
  1305. {
  1306.     DEBUGTRACE;
  1307.     if ((NULL == cache) || (NULL == cache->magic)) {
  1308.         snmp_log(LOG_ERR,
  1309.                  "invalid cache for inetNetToMediaTable_cache_loadn");
  1310.         return -1;
  1311.     }
  1312.     DEBUGMSGTL(("inetNetToMediaTable/cache", "inetNetToMedia_load %p/%pn",
  1313.                 cache, cache->magic));
  1314.     netsnmp_assert((0 == cache->valid) || (1 == cache->expired));
  1315.     /*
  1316.      * call user code
  1317.      */
  1318.     return inetNetToMediaTable_cache_load((netsnmp_container *) cache->
  1319.                                           magic);
  1320. }                               /* _cache_load */
  1321. /**
  1322.  * @internal
  1323.  */
  1324. static void
  1325. _cache_item_free(inetNetToMediaTable_rowreq_ctx * rowreq_ctx,
  1326.                  void *context)
  1327. {
  1328.     DEBUGMSGTL(("internal:inetNetToMediaTable:_cache_item_free",
  1329.                 "calledn"));
  1330.     if (NULL == rowreq_ctx)
  1331.         return;
  1332.     inetNetToMediaTable_release_rowreq_ctx(rowreq_ctx);
  1333. }                               /* _cache_item_free */
  1334. /**
  1335.  * @internal
  1336.  */
  1337. static void
  1338. _cache_free(netsnmp_cache * cache, void *magic)
  1339. {
  1340.     netsnmp_container *container;
  1341.     DEBUGMSGTL(("internal:inetNetToMediaTable:_cache_free", "calledn"));
  1342.     if ((NULL == cache) || (NULL == cache->magic)) {
  1343.         snmp_log(LOG_ERR,
  1344.                  "invalid cache in inetNetToMediaTable_cache_freen");
  1345.         return;
  1346.     }
  1347.     container = (netsnmp_container *) cache->magic;
  1348.     /*
  1349.      * call user code
  1350.      */
  1351.     inetNetToMediaTable_cache_free(container);
  1352.     /*
  1353.      * free all items. inefficient, but easy.
  1354.      */
  1355.     CONTAINER_CLEAR(container,
  1356.                     (netsnmp_container_obj_func *) _cache_item_free, NULL);
  1357. }                               /* _cache_free */
  1358. /**
  1359.  * @internal
  1360.  * initialize the iterator container with functions or wrappers
  1361.  */
  1362. void
  1363. _inetNetToMediaTable_container_init(inetNetToMediaTable_interface_ctx *
  1364.                                     if_ctx)
  1365. {
  1366.     DEBUGMSGTL(("internal:inetNetToMediaTable:_inetNetToMediaTable_container_init", "calledn"));
  1367.     /*
  1368.      * set up the cache
  1369.      */
  1370.     if_ctx->cache = netsnmp_cache_create(30,    /* timeout in seconds */
  1371.                                          _cache_load, _cache_free,
  1372.                                          inetNetToMediaTable_oid,
  1373.                                          inetNetToMediaTable_oid_size);
  1374.     if (NULL == if_ctx->cache) {
  1375.         snmp_log(LOG_ERR,
  1376.                  "error creating cache for inetNetToMediaTablen");
  1377.         return;
  1378.     }
  1379.     if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET;
  1380.     inetNetToMediaTable_container_init(&if_ctx->container, if_ctx->cache);
  1381.     if (NULL == if_ctx->container)
  1382.         if_ctx->container =
  1383.             netsnmp_container_find("inetNetToMediaTable:table_container");
  1384.     if (NULL == if_ctx->container) {
  1385.         snmp_log(LOG_ERR, "error creating container in "
  1386.                  "inetNetToMediaTable_container_initn");
  1387.         return;
  1388.     }
  1389.     if_ctx->cache->magic = (void *) if_ctx->container;
  1390. }                               /* _inetNetToMediaTable_container_init */