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

📄 ipaddresstable_interface.c

📁 snmp的源代码,已经在我的ubuntu下编译通过
💻 C
📖 第 1 页 / 共 4 页
字号:
/* * Note: this file originally auto-generated by mib2c using *       version : 1.43 $ of : mfd-interface.m2c,v $  * * $Id: ipAddressTable_interface.c,v 1.10 2004/10/18 03:53:20 rstory Exp $ *//* * ********************************************************************* * ********************************************************************* * ********************************************************************* * ***                                                               *** * ***  NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE  *** * ***                                                               *** * ***                                                               *** * ***       THIS FILE DOES NOT CONTAIN ANY USER EDITABLE CODE.      *** * ***                                                               *** * ***                                                               *** * ***       THE GENERATED CODE IS INTERNAL IMPLEMENTATION, AND      *** * ***                                                               *** * ***                                                               *** * ***    IS SUBJECT TO CHANGE WITHOUT WARNING IN FUTURE RELEASES.   *** * ***                                                               *** * ***                                                               *** * ********************************************************************* * ********************************************************************* * ********************************************************************* *//* * standard Net-SNMP includes  */#include <net-snmp/net-snmp-config.h>#include <net-snmp/net-snmp-includes.h>#include <net-snmp/agent/net-snmp-agent-includes.h>/* * include our parent header  */#include "ipAddressTable.h"#include <net-snmp/library/container.h>#include "ipAddressTable_interface.h"/********************************************************************** ********************************************************************** *** *** Table ipAddressTable *** ********************************************************************** **********************************************************************//* * ipAddressTable is subid 34 of ip. * Its status is Current. * OID: .1.3.6.1.2.1.4.34, length: 8 */typedef struct ipAddressTable_interface_ctx_s {    netsnmp_container *container;    netsnmp_cache  *cache;      /* optional cache */    ipAddressTable_registration_ptr user_ctx;    netsnmp_table_registration_info tbl_info;    netsnmp_baby_steps_access_methods access_multiplexer;} ipAddressTable_interface_ctx;static ipAddressTable_interface_ctx ipAddressTable_if_ctx;static void     _ipAddressTable_container_init(ipAddressTable_interface_ctx                                               * if_ctx);static Netsnmp_Node_Handler _mfd_ipAddressTable_pre_request;static Netsnmp_Node_Handler _mfd_ipAddressTable_post_request;static Netsnmp_Node_Handler _mfd_ipAddressTable_object_lookup;static Netsnmp_Node_Handler _mfd_ipAddressTable_get_values;static Netsnmp_Node_Handler _mfd_ipAddressTable_check_objects;static Netsnmp_Node_Handler _mfd_ipAddressTable_undo_setup;static Netsnmp_Node_Handler _mfd_ipAddressTable_set_values;static Netsnmp_Node_Handler _mfd_ipAddressTable_undo_cleanup;static Netsnmp_Node_Handler _mfd_ipAddressTable_undo_values;static Netsnmp_Node_Handler _mfd_ipAddressTable_commit;static Netsnmp_Node_Handler _mfd_ipAddressTable_undo_commit;static Netsnmp_Node_Handler _mfd_ipAddressTable_check_dependencies;NETSNMP_STATIC_INLINE int                _ipAddressTable_undo_column(ipAddressTable_rowreq_ctx * rowreq_ctx,                                            netsnmp_variable_list * var,                                            int column);NETSNMP_STATIC_INLINE int                _ipAddressTable_check_indexes(ipAddressTable_rowreq_ctx * rowreq_ctx);/** * @internal * Initialize the table ipAddressTable  *    (Define its contents and how it's structured) */void_ipAddressTable_initialize_interface(ipAddressTable_registration_ptr                                     reg_ptr, u_long flags){    netsnmp_baby_steps_access_methods *access_multiplexer =        &ipAddressTable_if_ctx.access_multiplexer;    netsnmp_table_registration_info *tbl_info =        &ipAddressTable_if_ctx.tbl_info;    netsnmp_handler_registration *reginfo;    netsnmp_mib_handler *handler;    int             mfd_modes = 0;    DEBUGMSGTL(("internal:ipAddressTable:_ipAddressTable_initialize_interface", "called\n"));    /*************************************************     *     * save interface context for ipAddressTable     */    /*     * Setting up the table's definition     */    netsnmp_table_helper_add_indexes(tbl_info, ASN_INTEGER,                                               /** index: ipAddressAddrType */                                     ASN_OCTET_STR,                                                 /** index: ipAddressAddr */                                     0);    /*     * Define the minimum and maximum accessible columns.  This     * optimizes retrival.      */    tbl_info->min_column = IPADDRESSTABLE_MIN_COL;    tbl_info->max_column = IPADDRESSTABLE_MAX_COL;    /*     * save users context     */    ipAddressTable_if_ctx.user_ctx = reg_ptr;    /*     * call data access initialization code     */    ipAddressTable_init_data(reg_ptr);    /*     * set up the container     */    _ipAddressTable_container_init(&ipAddressTable_if_ctx);    if (NULL == ipAddressTable_if_ctx.container) {        snmp_log(LOG_ERR,                 "could not initialize container for ipAddressTable\n");        return;    }    /*     * access_multiplexer: REQUIRED wrapper for get request handling     */    access_multiplexer->object_lookup = _mfd_ipAddressTable_object_lookup;    access_multiplexer->get_values = _mfd_ipAddressTable_get_values;    /*     * no wrappers yet     */    access_multiplexer->pre_request = _mfd_ipAddressTable_pre_request;    access_multiplexer->post_request = _mfd_ipAddressTable_post_request;    /*     * REQUIRED wrappers for set request handling     */    access_multiplexer->object_syntax_checks =        _mfd_ipAddressTable_check_objects;    access_multiplexer->undo_setup = _mfd_ipAddressTable_undo_setup;    access_multiplexer->undo_cleanup = _mfd_ipAddressTable_undo_cleanup;    access_multiplexer->set_values = _mfd_ipAddressTable_set_values;    access_multiplexer->undo_sets = _mfd_ipAddressTable_undo_values;    /*     * no wrappers yet     */    access_multiplexer->commit = _mfd_ipAddressTable_commit;    access_multiplexer->undo_commit = _mfd_ipAddressTable_undo_commit;    /*     * REQUIRED for tables with dependencies     */    access_multiplexer->consistency_checks =        _mfd_ipAddressTable_check_dependencies;    /*************************************************     *     * Create a registration, save our reg data, register table.     */    DEBUGMSGTL(("ipAddressTable:init_ipAddressTable",                "Registering ipAddressTable as a mibs-for-dummies table.\n"));    handler =        netsnmp_baby_steps_access_multiplexer_get(access_multiplexer);    reginfo =        netsnmp_handler_registration_create("ipAddressTable", handler,                                            ipAddressTable_oid,                                            ipAddressTable_oid_size,                                            HANDLER_CAN_BABY_STEP |                                            HANDLER_CAN_RWRITE);    if (NULL == reginfo) {        snmp_log(LOG_ERR, "error registering table ipAddressTable\n");        return;    }    reginfo->my_reg_void = &ipAddressTable_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,                                            ipAddressTable_if_ctx.                                            container,                                            TABLE_CONTAINER_KEY_NETSNMP_INDEX);    netsnmp_inject_handler(reginfo, handler);    /*************************************************     *     * inject cache helper     */    if (NULL != ipAddressTable_if_ctx.cache) {        handler = netsnmp_cache_handler_get(ipAddressTable_if_ctx.cache);        netsnmp_inject_handler(reginfo, handler);    }    /*     * register table     */    netsnmp_register_table(reginfo, tbl_info);}                               /* _ipAddressTable_initialize_interface */voidipAddressTable_valid_columns_set(netsnmp_column_info *vc){    ipAddressTable_if_ctx.tbl_info.valid_columns = vc;}                               /* ipAddressTable_valid_columns_set *//** * @internal * convert the index component stored in the context to an oid */intipAddressTable_index_to_oid(netsnmp_index * oid_idx,                            ipAddressTable_mib_index * mib_idx){    int             err = SNMP_ERR_NOERROR;    /*     * temp storage for parsing indexes     */    /*     * ipAddressAddrType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h     */    netsnmp_variable_list var_ipAddressAddrType;    /*     * ipAddressAddr(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h     */    netsnmp_variable_list var_ipAddressAddr;    /*     * set up varbinds     */    memset(&var_ipAddressAddrType, 0x00, sizeof(var_ipAddressAddrType));    var_ipAddressAddrType.type = ASN_INTEGER;    memset(&var_ipAddressAddr, 0x00, sizeof(var_ipAddressAddr));    var_ipAddressAddr.type = ASN_OCTET_STR;    /*     * chain temp index varbinds together     */    var_ipAddressAddrType.next_variable = &var_ipAddressAddr;    var_ipAddressAddr.next_variable = NULL;    DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_index_to_oid",                "called\n"));    /*     * ipAddressAddrType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h      */    snmp_set_var_value(&var_ipAddressAddrType,                       (u_char *) & mib_idx->ipAddressAddrType,                       sizeof(mib_idx->ipAddressAddrType));    /*     * ipAddressAddr(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h      */    snmp_set_var_value(&var_ipAddressAddr,                       (u_char *) & mib_idx->ipAddressAddr,                       mib_idx->ipAddressAddr_len *                       sizeof(mib_idx->ipAddressAddr[0]));    err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len,                            NULL, 0, &var_ipAddressAddrType);    if (err)        snmp_log(LOG_ERR, "error %d converting index to oid\n");    /*     * parsing may have allocated memory. free it.     */    snmp_reset_var_buffers(&var_ipAddressAddrType);    return err;}                               /* ipAddressTable_index_to_oid *//** * extract ipAddressTable indexes from a netsnmp_index * * @retval SNMP_ERR_NOERROR  : no error * @retval SNMP_ERR_GENERR   : error */intipAddressTable_index_from_oid(netsnmp_index * oid_idx,                              ipAddressTable_mib_index * mib_idx){    int             err = SNMP_ERR_NOERROR;    /*     * temp storage for parsing indexes     */    /*     * ipAddressAddrType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h     */    netsnmp_variable_list var_ipAddressAddrType;    /*     * ipAddressAddr(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h     */    netsnmp_variable_list var_ipAddressAddr;    /*     * set up varbinds     */    memset(&var_ipAddressAddrType, 0x00, sizeof(var_ipAddressAddrType));    var_ipAddressAddrType.type = ASN_INTEGER;    memset(&var_ipAddressAddr, 0x00, sizeof(var_ipAddressAddr));    var_ipAddressAddr.type = ASN_OCTET_STR;    /*     * chain temp index varbinds together     */    var_ipAddressAddrType.next_variable = &var_ipAddressAddr;    var_ipAddressAddr.next_variable = NULL;    DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_index_from_oid",                "called\n"));    /*     * parse the oid into the individual index components     */    err = parse_oid_indexes(oid_idx->oids, oid_idx->len,                            &var_ipAddressAddrType);    if (err == SNMP_ERR_NOERROR) {        /*         * copy out values         */        mib_idx->ipAddressAddrType =            *((u_long *) var_ipAddressAddrType.val.string);        /*         * NOTE: val_len is in bytes, ipAddressAddr_len might not be         */        if (var_ipAddressAddr.val_len > sizeof(mib_idx->ipAddressAddr))            err = SNMP_ERR_GENERR;        else {            memcpy(mib_idx->ipAddressAddr, var_ipAddressAddr.val.string,                   var_ipAddressAddr.val_len);            mib_idx->ipAddressAddr_len =                var_ipAddressAddr.val_len /                sizeof(mib_idx->ipAddressAddr[0]);        }    }    /*     * parsing may have allocated memory. free it.     */    snmp_reset_var_buffers(&var_ipAddressAddrType);

⌨️ 快捷键说明

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