⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mfd-interface.m2c

📁 snmp的源代码,已经在我的ubuntu下编译通过
💻 M2C
📖 第 1 页 / 共 3 页
字号:
#############################################################  -*- c -*-## generic include for XXX. Do not use directly.#### $Id: mfd-interface.m2c,v 1.43.2.2 2005/01/03 00:50:29 rstory Exp $########################################################################@if $m2c_mark_boundary == 1@/** START code generated by $RCSfile: mfd-interface.m2c,v $ $Revision: 1.43.2.2 $ */@end@##################################################################################################################################################@open ${name}_interface.h@@eval $hack = "Id"@/* * Note: this file originally auto-generated by mib2c using *       version $Revision: 1.43.2.2 $ of $RCSfile: mfd-interface.m2c,v $ * * $$hack:$ *//** @defgroup interface: Routines to interface to Net-SNMP * * \warning This code should not be modified, called directly, *          or used to interpret functionality. It is subject to *          change at any time. *  * @{ */@include m2c-internal-warning.m2i@##@eval $m2c_save = "$name"@@eval $name = "${name}_INTERFACE"@@include generic-header-top.m2i@@eval $name = $m2c_save@#include "${name}.h"/* ******************************************************************** * Table declarations */@foreach $table table@@    include m2c_setup_table.m2i@/* PUBLIC interface initialization routine */void _${context}_initialize_interface(${context}_registration_ptr user_ctx,                                    u_long flags);@   if $m2c_data_allocate == 1@@      eval $m2c_tmp = "${context}_data *"@@      if $m2c_data_init == 1@@         eval $m2c_tmp = "$m2c_tmp, void *"@@      @end@@   elsif $m2c_data_init == 1@@      eval $m2c_tmp = "void *"@@   else@@      eval $m2c_tmp = "void"@@   end@    ${context}_rowreq_ctx * ${context}_allocate_rowreq_ctx($m2c_tmp);void ${context}_release_rowreq_ctx(${context}_rowreq_ctx *rowreq_ctx);int ${context}_index_to_oid(netsnmp_index *oid_idx,                            ${context}_mib_index *mib_idx);int ${context}_index_from_oid(netsnmp_index *oid_idx,                              ${context}_mib_index *mib_idx);/* * access to certain internals. use with caution! */void ${context}_valid_columns_set(netsnmp_column_info *vc);@end@ # for each@eval $m2c_save = "$name"@@eval $name = "${name}_INTERFACE"@@include generic-header-bottom.m2i@@eval $name = $m2c_save@##########################################################################@open ${name}_interface.c@/* * Note: this file originally auto-generated by mib2c using *       version $Revision: 1.43.2.2 $ of $RCSfile: mfd-interface.m2c,v $  * * $$hack:$ */@include m2c-internal-warning.m2i@@include generic-source-includes.m2i@#include <net-snmp/library/container.h>#include "${name}_interface.h"@eval $m2c_processing_type = 'i'@@foreach $table table@@   include m2c_setup_table.m2i@@   include details-table.m2i@########################################################################typedef struct ${context}_interface_ctx_s {   netsnmp_container              *container;   netsnmp_cache                  *cache; /* optional cache */   ${context}_registration_ptr      user_ctx;      netsnmp_table_registration_info  tbl_info;   netsnmp_baby_steps_access_methods access_multiplexer;} ${context}_interface_ctx;static ${context}_interface_ctx ${context}_if_ctx;static void _${context}_container_init(    ${context}_interface_ctx *if_ctx);static Netsnmp_Node_Handler _mfd_${context}_pre_request;static Netsnmp_Node_Handler _mfd_${context}_post_request;static Netsnmp_Node_Handler _mfd_${context}_object_lookup;static Netsnmp_Node_Handler _mfd_${context}_get_values;@   if $m2c_table_settable@static Netsnmp_Node_Handler _mfd_${context}_check_objects;static Netsnmp_Node_Handler _mfd_${context}_undo_setup;static Netsnmp_Node_Handler _mfd_${context}_set_values;static Netsnmp_Node_Handler _mfd_${context}_undo_cleanup;static Netsnmp_Node_Handler _mfd_${context}_undo_values;static Netsnmp_Node_Handler _mfd_${context}_commit;static Netsnmp_Node_Handler _mfd_${context}_undo_commit;@      if $m2c_irreversible_commit == 1@static Netsnmp_Node_Handler _mfd_${context}_irreversible_commit;@      end@@      if $m2c_table_dependencies == 1@static Netsnmp_Node_Handler _mfd_${context}_check_dependencies;@      end@NETSNMP_STATIC_INLINE int _${context}_undo_column( ${context}_rowreq_ctx *rowreq_ctx,                                                   netsnmp_variable_list *var, int column );@if $m2c_table_row_creation == 1@NETSNMP_STATIC_INLINE int _${context}_check_indexes(${context}_rowreq_ctx * rowreq_ctx);@end@@   end@ # writable@   if ("$m2c_data_context" eq "generated") && (($m2c_undo_embed == 0) || ($m2c_data_allocate == 1))@${context}_data *${context}_allocate_data(void);@   end@/** * @internal * Initialize the table $context  *    (Define its contents and how it's structured) */void_${context}_initialize_interface(${context}_registration_ptr reg_ptr,  u_long flags){    netsnmp_baby_steps_access_methods *access_multiplexer =        &${context}_if_ctx.access_multiplexer;    netsnmp_table_registration_info *tbl_info = &${context}_if_ctx.tbl_info;    netsnmp_handler_registration *reginfo;    netsnmp_mib_handler *handler;    int    mfd_modes = 0;    DEBUGMSGTL(("internal:${context}:_${context}_initialize_interface","called\n"));    /*************************************************     *     * save interface context for ${context}     */    /*     * Setting up the table's definition     */    netsnmp_table_helper_add_indexes(tbl_info,    @foreach $tabledx index@                                  $tabledx.type, /** index: $tabledx */    @end@                             0);    /*  Define the minimum and maximum accessible columns.  This        optimizes retrival. */    tbl_info->min_column = $context.uc_MIN_COL;    tbl_info->max_column = $context.uc_MAX_COL;    /*     * save users context     */    ${context}_if_ctx.user_ctx = reg_ptr;    /*     * call data access initialization code     */    ${context}_init_data(reg_ptr);    /*     * set up the container     */    _${context}_container_init(&${context}_if_ctx);    if (NULL == ${context}_if_ctx.container) {        snmp_log(LOG_ERR,"could not initialize container for ${context}\n");        return;    }        /*     * access_multiplexer: REQUIRED wrapper for get request handling     */    access_multiplexer->object_lookup = _mfd_${context}_object_lookup;    access_multiplexer->get_values = _mfd_${context}_get_values;    /*     * no wrappers yet     */    access_multiplexer->pre_request = _mfd_${context}_pre_request;    access_multiplexer->post_request = _mfd_${context}_post_request;##@   if $m2c_table_settable@    /*     * REQUIRED wrappers for set request handling     */    access_multiplexer->object_syntax_checks = _mfd_${context}_check_objects;    access_multiplexer->undo_setup = _mfd_${context}_undo_setup;    access_multiplexer->undo_cleanup = _mfd_${context}_undo_cleanup;    access_multiplexer->set_values = _mfd_${context}_set_values;    access_multiplexer->undo_sets = _mfd_${context}_undo_values;    /*     * no wrappers yet     */    access_multiplexer->commit = _mfd_${context}_commit;    access_multiplexer->undo_commit = _mfd_${context}_undo_commit;@   if $m2c_irreversible_commit == 1@    access_multiplexer->irreversible_commit = _mfd_${context}_irreversible_commit;@   end@##@      if $m2c_table_dependencies == 1@        /*     * REQUIRED for tables with dependencies     */    access_multiplexer->consistency_checks = _mfd_${context}_check_dependencies;@      end@@   end@ # writable    /*************************************************     *     * Create a registration, save our reg data, register table.     */    DEBUGMSGTL(("$name:init_$context",                "Registering $context as a mibs-for-dummies table.\n"));		     handler = netsnmp_baby_steps_access_multiplexer_get(access_multiplexer);    reginfo = netsnmp_handler_registration_create("${context}", handler,                                                  ${context}_oid,                                                  ${context}_oid_size,                                                  HANDLER_CAN_BABY_STEP |@if $m2c_table_settable == 1@                                                  HANDLER_CAN_RWRITE@else@                                                  HANDLER_CAN_RONLY@end@                                                  );    if(NULL == reginfo) {        snmp_log(LOG_ERR,"error registering table ${context}\n");        return;    }    reginfo->my_reg_void = &${context}_if_ctx;    /*************************************************     *     * set up baby steps handler, create it and inject it     */    if( access_multiplexer->object_lookup )        mfd_modes |= BABY_STEP_OBJECT_LOOKUP;    if( access_multiplexer->set_values )        mfd_modes |= BABY_STEP_SET_VALUES;    if( access_multiplexer->irreversible_commit )        mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT;    if( access_multiplexer->object_syntax_checks )        mfd_modes |= BABY_STEP_CHECK_OBJECT;    if( access_multiplexer->pre_request )        mfd_modes |= BABY_STEP_PRE_REQUEST;    if( access_multiplexer->post_request )        mfd_modes |= BABY_STEP_POST_REQUEST;        if( access_multiplexer->undo_setup )        mfd_modes |= BABY_STEP_UNDO_SETUP;    if( access_multiplexer->undo_cleanup )        mfd_modes |= BABY_STEP_UNDO_CLEANUP;    if( access_multiplexer->undo_sets )        mfd_modes |= BABY_STEP_UNDO_SETS;        if( access_multiplexer->row_creation )        mfd_modes |= BABY_STEP_ROW_CREATE;    if( access_multiplexer->consistency_checks )        mfd_modes |= BABY_STEP_CHECK_CONSISTENCY;    if( access_multiplexer->commit )        mfd_modes |= BABY_STEP_COMMIT;    if( access_multiplexer->undo_commit )        mfd_modes |= BABY_STEP_UNDO_COMMIT;        handler = netsnmp_baby_steps_handler_get(mfd_modes);    netsnmp_inject_handler(reginfo, handler);    /*************************************************     *     * inject row_merge helper with prefix rootoid_len + 2 (entry.col)     */    handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2);    netsnmp_inject_handler(reginfo, handler);    /*************************************************     *     * inject container_table helper     */    handler =        netsnmp_container_table_handler_get(tbl_info,                                            ${context}_if_ctx.container,                                            TABLE_CONTAINER_KEY_NETSNMP_INDEX);    netsnmp_inject_handler( reginfo, handler );    /*************************************************     *     * inject cache helper     */    if(NULL != ${context}_if_ctx.cache) {        handler = netsnmp_cache_handler_get(${context}_if_ctx.cache);        netsnmp_inject_handler( reginfo, handler );    }    /*     * register table     */    netsnmp_register_table(reginfo, tbl_info);} /* _${context}_initialize_interface */void${context}_valid_columns_set(netsnmp_column_info *vc){    ${context}_if_ctx.tbl_info.valid_columns = vc;} /* ${context}_valid_columns_set */@include generic-table-indexes-to-oid.m2i@@include generic-table-indexes-from-oid.m2i@##########################################################################@    if (($m2c_data_allocate == 1) || ($m2c_undo_embed == 0)) && ("$m2c_data_context" eq "generated")@@        eval $m2c_gda_todo_supress = 1@ # no todo comments@        include generic-data-allocate.m2i@@    end@########################################################################/* ********************************************************************* * @internal * allocate resources for a ${context}_rowreq_ctx */${context}_rowreq_ctx *@if $m2c_data_allocate == 1@@   eval $m2c_tmp = "${context}_data *data"@@   if $m2c_data_init == 1@@     eval $m2c_tmp = "$m2c_tmp, void *user_init_ctx"@@   end@@elsif $m2c_data_init == 1@@   eval $m2c_tmp = "void *user_init_ctx"@@else@@   eval $m2c_tmp = "void"@@end@${context}_allocate_rowreq_ctx($m2c_tmp){    ${context}_rowreq_ctx *rowreq_ctx =                  SNMP_MALLOC_TYPEDEF(${context}_rowreq_ctx);    DEBUGMSGTL(("internal:${context}:${context}_allocate_rowreq_ctx","called\n"));    if(NULL == rowreq_ctx) {        snmp_log(LOG_ERR,"Couldn't allocate memory for a "                 "${context}_rowreq_ctx.\n");    }@if $m2c_data_allocate == 1@    else {        if(NULL != data) {@   if $m2c_data_transient == 0@            /*             * for non-transient data, track when we got data from user             */            rowreq_ctx->rowreq_flags |= MFD_ROW_DATA_FROM_USER;@   end@            rowreq_ctx->data = data;        }        else if (NULL == (rowreq_ctx->data = ${context}_allocate_data())) {            SNMP_FREE(rowreq_ctx);            return NULL;        }    }    /*     * undo context will be allocated when needed (in *_undo_setup)     */@end@    rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp;    rowreq_ctx->${context}_data_list = NULL;    rowreq_ctx->${context}_reg = ${context}_if_ctx.user_ctx;@if $m2c_data_init == 1@    if(SNMPERR_SUCCESS !=        ${context}_rowreq_ctx_init(rowreq_ctx, user_init_ctx)) {       ${context}_release_rowreq_ctx(rowreq_ctx);       rowreq_ctx = NULL;    }@end@    return rowreq_ctx;} /* ${context}_allocate_rowreq_ctx *//* * @internal * release resources for a ${context}_rowreq_ctx */void${context}_release_rowreq_ctx(${context}_rowreq_ctx *rowreq_ctx){    DEBUGMSGTL(("internal:${context}:${context}_release_rowreq_ctx","called\n"));    netsnmp_assert(NULL != rowreq_ctx);    @if $m2c_data_init == 1@    ${context}_rowreq_ctx_cleanup(rowreq_ctx);@end@@if $m2c_data_allocate == 1@@   if $m2c_data_transient == 0@    /*     * for non-transient data, don't free data we got from the user     */    if ((rowreq_ctx->data) &&        !(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER))@   else@    if (rowreq_ctx->data)@   end@ # // transient        ${context}_release_data(rowreq_ctx->data); @end@ @if $m2c_undo_embed == 0@    if(rowreq_ctx->undo)        ${context}_release_data(rowreq_ctx->undo); @end@     /*     * free index oid pointer     */    if(rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp)        free(rowreq_ctx->oid_idx.oids);    SNMP_FREE(rowreq_ctx);} /* ${context}_release_rowreq_ctx */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -