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

📄 ipaddresstable.c

📁 snmp的源代码,已经在我的ubuntu下编译通过
💻 C
📖 第 1 页 / 共 5 页
字号:
/* * Note: this file originally auto-generated by mib2c using *       version : 1.32 $ of : mfd-top.m2c,v $  * * $Id: ipAddressTable.c,v 1.12 2004/10/19 21:04:24 rstory Exp $ *//** \mainpage MFD helper for ipAddressTable * * \section intro Introduction * Introductory text. * *//* * 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 <net-snmp/data_access/interface.h>/* * include our parent header  */#include "ipAddressTable.h"#include <net-snmp/agent/mib_modules.h>#include "ipAddressTable_interface.h"oid             ipAddressTable_oid[] = { IPADDRESSTABLE_OID };int             ipAddressTable_oid_size = OID_LENGTH(ipAddressTable_oid);void            initialize_table_ipAddressTable(void);/** * Initializes the ipAddressTable module */voidinit_ipAddressTable(void){    DEBUGMSGTL(("verbose:ipAddressTable:init_ipAddressTable", "called\n"));    /*     * TODO:300:o: Perform ipAddressTable one-time module initialization.     */    /*     * here we initialize all the tables we're planning on supporting     */    if (should_init("ipAddressTable"))        initialize_table_ipAddressTable();}                               /* init_ipAddressTable *//** * Initialize the table ipAddressTable  *    (Define its contents and how it's structured) */voidinitialize_table_ipAddressTable(void){    ipAddressTable_registration_ptr user_context;    u_long          flags;    DEBUGMSGTL(("verbose:ipAddressTable:initialize_table_ipAddressTable",                "called\n"));    /*     * TODO:301:o: Perform ipAddressTable one-time table initialization.     */    /*     * TODO:302:o: |->Initialize ipAddressTable user context     * if you'd like to pass in a pointer to some data for this     * table, allocate or set it up here.     */    user_context = NULL;    /*     * No support for any flags yet, but in the future you would     * set any flags here.     */    flags = 0;    /*     * call interface initialization code     */    _ipAddressTable_initialize_interface(user_context, flags);}                               /* initialize_table_ipAddressTable *//** * pre-request callback * * * @retval MFD_SUCCESS              : success. * @retval MFD_ERROR                : other error */intipAddressTable_pre_request(ipAddressTable_registration_ptr user_context){    DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_pre_request",                "called\n"));    /*     * TODO:510:o: Perform ipAddressTable pre-request actions.     */    return MFD_SUCCESS;}                               /* ipAddressTable_pre_request *//** * post-request callback * * * @retval MFD_SUCCESS : success. * @retval MFD_ERROR   : other error (ignored) */intipAddressTable_post_request(ipAddressTable_registration_ptr user_context){    DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_post_request",                "called\n"));    /*     * TODO:511:o: Perform ipAddressTable pos-request actions.     */    return MFD_SUCCESS;}                               /* ipAddressTable_post_request *//********************************************************************** ********************************************************************** *** *** Table ipAddressTable *** ********************************************************************** **********************************************************************//* * ipAddressTable is subid 34 of ip. * Its status is Current. * OID: .1.3.6.1.2.1.4.34, length: 8 *//* * --------------------------------------------------------------------- * * TODO:200:r: Implement ipAddressTable data context functions. *//* * ipAddressTable_allocate_data * * Purpose: create new ipAddressTable_data. */ipAddressTable_data *ipAddressTable_allocate_data(void){    /*     * TODO:201:r: |-> allocate memory for the ipAddressTable data context.     */    ipAddressTable_data *rtn = netsnmp_access_ipaddress_entry_create();    DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_allocate_data",                "called\n"));    if (NULL == rtn) {        snmp_log(LOG_ERR, "unable to malloc memory for new "                 "ipAddressTable_data.\n");    }    return rtn;}                               /* ipAddressTable_allocate_data *//* * ipAddressTable_release_data * * Purpose: release ipAddressTable data. */voidipAddressTable_release_data(ipAddressTable_data * data){    DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_release_data",                "called\n"));    /*     * TODO:202:r: |-> release memory for the ipAddressTable data context.     */    netsnmp_access_ipaddress_entry_free(data);}                               /* ipAddressTable_release_data *//*--------------------------------------------------------------------- * IP-MIB::ipAddressEntry.ipAddressAddrType * ipAddressAddrType is subid 1 of ipAddressEntry. * Its status is Current, and its access level is NoAccess. * OID: .1.3.6.1.2.1.4.34.1.1 * Description:The address type of ipAddressAddr. * * Attributes: *   accessible 0     isscalar 0     enums  1      hasdefval 0 *   readable   0     iscolumn 1     ranges 0      hashint   0 *   settable   0 * * Enum range: 5/8. Values:  unknown(0), ipv4(1), ipv6(2), ipv4z(3), ipv6z(4), dns(16) * * Its syntax is InetAddressType (based on perltype INTEGER) * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) * * * * NOTE: NODE ipAddressAddrType IS NOT ACCESSIBLE * * *//** * map a value from its original native format to the MIB format. * * @retval MFD_SUCCESS         : success * @retval MFD_ERROR           : Any other error * * @note parameters follow the memset convention (dest, src). * * @note generation and use of this function can be turned off by re-running * mib2c after adding the following line to the file * default-node-ipAddressAddrType.m2d : *   @eval $m2c_node_skip_mapping = 1@ * * @remark *  If the values for your data type don't exactly match the *  possible values defined by the mib, you should map them here. *  Otherwise, just do a direct copy. */intipAddressAddrType_map(u_long * mib_ipAddressAddrType_val_ptr,                      u_long raw_ipAddressAddrType_val){    netsnmp_assert(NULL != mib_ipAddressAddrType_val_ptr);    DEBUGMSGTL(("verbose:ipAddressTable:ipAddressAddrType_map",                "called\n"));    /*     * TODO:241:o: |-> Implement ipAddressAddrType enum mapping.     * uses INTERNAL_* macros defined in the header files     */    switch (raw_ipAddressAddrType_val) {    case INTERNAL_IPADDRESSADDRTYPE_IPV4:        *mib_ipAddressAddrType_val_ptr = INETADDRESSTYPE_IPV4;        break;    case INTERNAL_IPADDRESSADDRTYPE_IPV6:        *mib_ipAddressAddrType_val_ptr = INETADDRESSTYPE_IPV6;        break;    default:        snmp_log(LOG_ERR, "couldn't map value %d for ipAddressAddrType\n",                 raw_ipAddressAddrType_val);        *mib_ipAddressAddrType_val_ptr = INETADDRESSTYPE_UNKNOWN;    }    return MFD_SUCCESS;}                               /* ipAddressAddrType_map *//** * set mib index(es) * * @param tbl_idx mib index structure * * @retval MFD_SUCCESS     : success. * @retval MFD_ERROR       : other error. * * @remark *  This convenience function is useful for setting all the MIB index *  components with a single function call. It is assume that the C values *  have already been mapped from their native/rawformat to the MIB format. */intipAddressTable_indexes_set_tbl_idx(ipAddressTable_mib_index * tbl_idx,                                   u_long ipAddressAddrType_val,                                   char *ipAddressAddr_val_ptr,                                   size_t ipAddressAddr_val_ptr_len){    DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_indexes_set_tbl_idx", "called\n"));    /*     * ipAddressAddrType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h      */    /** WARNING: this code might not work for netsnmp_ipaddress_entry */    ipAddressAddrType_map(&tbl_idx->ipAddressAddrType,                          ipAddressAddrType_val);    /*     * ipAddressAddr(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h      */    tbl_idx->ipAddressAddr_len = sizeof(tbl_idx->ipAddressAddr);    /** WARNING: this code might not work for netsnmp_ipaddress_entry */    /*     * make sure there is enough space for ipAddressAddr data     */    if (tbl_idx->ipAddressAddr_len < ipAddressAddr_val_ptr_len) {        snmp_log(LOG_ERR, "not enough space for value\n");        return MFD_ERROR;    }    tbl_idx->ipAddressAddr_len = ipAddressAddr_val_ptr_len;    memcpy(tbl_idx->ipAddressAddr, ipAddressAddr_val_ptr,           tbl_idx->ipAddressAddr_len * sizeof(tbl_idx->ipAddressAddr[0]));    return MFD_SUCCESS;}                               /* ipAddressTable_indexes_set_tbl_idx *//** * @internal * set row context indexes * * @param reqreq_ctx the row context that needs updated indexes * * @retval MFD_SUCCESS     : success. * @retval MFD_ERROR       : other error. * * @remark *  This function sets the mib indexs, then updates the oid indexs *  from the mib index. */intipAddressTable_indexes_set(ipAddressTable_rowreq_ctx * rowreq_ctx,                           u_long ipAddressAddrType_val,                           char *ipAddressAddr_val_ptr,                           size_t ipAddressAddr_val_ptr_len){    DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_indexes_set",                "called\n"));    if (MFD_SUCCESS !=        ipAddressTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx,                                           ipAddressAddrType_val,                                           ipAddressAddr_val_ptr,                                           ipAddressAddr_val_ptr_len))        return MFD_ERROR;    /*     * convert mib index to oid index     */    rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid);    if (0 != ipAddressTable_index_to_oid(&rowreq_ctx->oid_idx,                                         &rowreq_ctx->tbl_idx)) {        return MFD_ERROR;    }    return MFD_SUCCESS;}                               /* ipAddressTable_indexes_set *//*--------------------------------------------------------------------- * IP-MIB::ipAddressEntry.ipAddressIfIndex * ipAddressIfIndex is subid 3 of ipAddressEntry. * Its status is Current, and its access level is Create. * OID: .1.3.6.1.2.1.4.34.1.3 * Description:The index value which uniquely identifies the interface to            which this entry is applicable.  The interface identified by            a particular value of this index is the same interface as            identified by the same value of the IF-MIB's ifIndex. * * Attributes: *   accessible 1     isscalar 0     enums  0      hasdefval 0 *   readable   1     iscolumn 1     ranges 1      hashint   1 *   settable   1 *   hint: d * * Ranges:  1 - 2147483647; * * Its syntax is InterfaceIndex (based on perltype INTEGER32) * The net-snmp type is ASN_INTEGER. The C type decl is long (long) *//** * Extract the current value of the ipAddressIfIndex data. * * Set a value using the data context for the row. * * @param rowreq_ctx *        Pointer to the row request context. * @param ipAddressIfIndex_val_ptr *        Pointer to storage for a long variable * * @retval MFD_SUCCESS         : success * @retval MFD_SKIP            : skip this node (no value for now) * @retval MFD_ERROR           : Any other error */intipAddressIfIndex_get(ipAddressTable_rowreq_ctx * rowreq_ctx,                     long *ipAddressIfIndex_val_ptr){   /** we should have a non-NULL pointer */    netsnmp_assert(NULL != ipAddressIfIndex_val_ptr);

⌨️ 快捷键说明

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