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

📄 ipaddresstable_interface.c

📁 snmp的源代码,已经在我的ubuntu下编译通过
💻 C
📖 第 1 页 / 共 4 页
字号:
    /*     * clear set flags     */    rowreq_ctx->column_set_flags = 0;    return SNMP_ERR_NOERROR;}                               /* _mfd_ipAddressTable_undo_cleanup *//*---------------------------------------------------------------------- * * SET: Set values * *---------------------------------------------------------------------*//* * @internal * Set the value for a particular column */NETSNMP_STATIC_INLINE int_ipAddressTable_set_column(ipAddressTable_rowreq_ctx * rowreq_ctx,                           netsnmp_variable_list * var, int column){    int             rc = SNMPERR_SUCCESS;    DEBUGMSGTL(("internal:ipAddressTable:_ipAddressTable_set_column",                "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    switch (column) {        /*         * ipAddressIfIndex(3)/InterfaceIndex/ASN_INTEGER/long(long)//l/A/W/e/R/d/H          */    case COLUMN_IPADDRESSIFINDEX:        if (var->val_len != sizeof(long)) {            rc = SNMP_ERR_WRONGLENGTH;            snmp_log(LOG_ERR,                     "varbind size of %d does not match expected size %d\n",                     var->val_len, sizeof(long));            break;        }        rowreq_ctx->column_set_flags |= FLAG_IPADDRESSIFINDEX;        rc = ipAddressIfIndex_set(rowreq_ctx, *((long *) var->val.string));        break;        /*         * ipAddressType(4)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h          */    case COLUMN_IPADDRESSTYPE:        if (var->val_len != sizeof(u_long)) {            rc = SNMP_ERR_WRONGLENGTH;            snmp_log(LOG_ERR,                     "varbind size of %d does not match expected size %d\n",                     var->val_len, sizeof(u_long));            break;        }        rowreq_ctx->column_set_flags |= FLAG_IPADDRESSTYPE;        rc = ipAddressType_set(rowreq_ctx, *((u_long *) var->val.string));        break;        /*         * ipAddressStatus(7)/IpAddressStatusTC/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h          */    case COLUMN_IPADDRESSSTATUS:        if (var->val_len != sizeof(u_long)) {            rc = SNMP_ERR_WRONGLENGTH;            snmp_log(LOG_ERR,                     "varbind size of %d does not match expected size %d\n",                     var->val_len, sizeof(u_long));            break;        }        rowreq_ctx->column_set_flags |= FLAG_IPADDRESSSTATUS;        rc = ipAddressStatus_set(rowreq_ctx,                                 *((u_long *) var->val.string));        break;        /*         * ipAddressRowStatus(10)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h          */    case COLUMN_IPADDRESSROWSTATUS:        if (var->val_len != sizeof(u_long)) {            rc = SNMP_ERR_WRONGLENGTH;            snmp_log(LOG_ERR,                     "varbind size of %d does not match expected size %d\n",                     var->val_len, sizeof(u_long));            break;        }        rowreq_ctx->column_set_flags |= FLAG_IPADDRESSROWSTATUS;        rc = ipAddressRowStatus_set(rowreq_ctx,                                    *((u_long *) var->val.string));        break;        /*         * ipAddressStorageType(11)/StorageType/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h          */    case COLUMN_IPADDRESSSTORAGETYPE:        if (var->val_len != sizeof(u_long)) {            rc = SNMP_ERR_WRONGLENGTH;            snmp_log(LOG_ERR,                     "varbind size of %d does not match expected size %d\n",                     var->val_len, sizeof(u_long));            break;        }        rowreq_ctx->column_set_flags |= FLAG_IPADDRESSSTORAGETYPE;        rc = ipAddressStorageType_set(rowreq_ctx,                                      *((u_long *) var->val.string));        break;    default:        snmp_log(LOG_ERR,                 "unknown column %d in _ipAddressTable_set_column\n",                 column);        break;    }    return rc;}                               /* _ipAddressTable_set_column */int_mfd_ipAddressTable_set_values(netsnmp_mib_handler *handler,                               netsnmp_handler_registration *reginfo,                               netsnmp_agent_request_info *agtreq_info,                               netsnmp_request_info *requests){    ipAddressTable_rowreq_ctx *rowreq_ctx =        netsnmp_container_table_row_extract(requests);    netsnmp_table_request_info *tri;    int             rc = SNMP_ERR_NOERROR;    DEBUGMSGTL(("internal:ipAddressTable:_mfd_ipAddressTable_set_values",                "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    rowreq_ctx->column_set_flags = 0;    for (; requests; requests = requests->next) {        /*         * set column data         */        tri = netsnmp_extract_table_info(requests);        if (NULL == tri)            continue;        rc = _ipAddressTable_set_column(rowreq_ctx,                                        requests->requestvb, tri->colnum);        if (MFD_SUCCESS != rc) {            DEBUGMSGTL(("verbose:ipAddressTable:mfd", "error %d from "                        "ipAddressTable_set_column\n", rc));            netsnmp_set_request_error(agtreq_info, requests,                                      SNMP_VALIDATE_ERR(rc));        }    }                           /* for results */    return SNMP_ERR_NOERROR;}                               /* _mfd_ipAddressTable_set_values *//*---------------------------------------------------------------------- * * SET: commit * *---------------------------------------------------------------------*//** * @internal * commit the values */int_mfd_ipAddressTable_commit(netsnmp_mib_handler *handler,                           netsnmp_handler_registration *reginfo,                           netsnmp_agent_request_info *agtreq_info,                           netsnmp_request_info *requests){    int             rc;    ipAddressTable_rowreq_ctx *rowreq_ctx =        netsnmp_container_table_row_extract(requests);    DEBUGMSGTL(("internal:ipAddressTable:_mfd_ipAddressTable_commit",                "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    rc = ipAddressTable_commit(rowreq_ctx);    if (MFD_SUCCESS != rc) {        DEBUGMSGTL(("verbose:ipAddressTable:mfd", "error %d from "                    "ipAddressTable_commit\n", rc));        netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));    }    return SNMP_ERR_NOERROR;}int_mfd_ipAddressTable_undo_commit(netsnmp_mib_handler *handler,                                netsnmp_handler_registration *reginfo,                                netsnmp_agent_request_info *agtreq_info,                                netsnmp_request_info *requests){    int             rc;    ipAddressTable_rowreq_ctx *rowreq_ctx =        netsnmp_container_table_row_extract(requests);    DEBUGMSGTL(("internal:ipAddressTable:_mfd_ipAddressTable_undo_commit",                "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    rc = ipAddressTable_undo_commit(rowreq_ctx);    if (MFD_SUCCESS != rc) {        /*         * nothing we can do about it but log it         */        DEBUGMSGTL(("verbose:ipAddressTable:mfd", "error %d from "                    "ipAddressTable_undo_commit\n", rc));    }    return SNMP_ERR_NOERROR;}                               /* _mfd_ipAddressTable_commit *//*---------------------------------------------------------------------- * * SET: Undo * *---------------------------------------------------------------------*//** * @internal * undo the value for a particular column */NETSNMP_STATIC_INLINE int_ipAddressTable_undo_column(ipAddressTable_rowreq_ctx * rowreq_ctx,                            netsnmp_variable_list * var, int column){    int             rc = SNMPERR_SUCCESS;    DEBUGMSGTL(("internal:ipAddressTable:_ipAddressTable_undo_column",                "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    switch (column) {        /*         * ipAddressIfIndex(3)/InterfaceIndex/ASN_INTEGER/long(long)//l/A/W/e/R/d/H          */    case COLUMN_IPADDRESSIFINDEX:        rc = ipAddressIfIndex_undo(rowreq_ctx);        break;        /*         * ipAddressType(4)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h          */    case COLUMN_IPADDRESSTYPE:        rc = ipAddressType_undo(rowreq_ctx);        break;        /*         * ipAddressStatus(7)/IpAddressStatusTC/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h          */    case COLUMN_IPADDRESSSTATUS:        rc = ipAddressStatus_undo(rowreq_ctx);        break;        /*         * ipAddressRowStatus(10)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h          */    case COLUMN_IPADDRESSROWSTATUS:        rc = ipAddressRowStatus_undo(rowreq_ctx);        break;        /*         * ipAddressStorageType(11)/StorageType/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h          */    case COLUMN_IPADDRESSSTORAGETYPE:        rc = ipAddressStorageType_undo(rowreq_ctx);        break;    default:        snmp_log(LOG_ERR,                 "unknown column %d in _ipAddressTable_undo_column\n",                 column);        break;    }    return rc;}                               /* _ipAddressTable_undo_column */int_mfd_ipAddressTable_undo_values(netsnmp_mib_handler *handler,                                netsnmp_handler_registration *reginfo,                                netsnmp_agent_request_info *agtreq_info,                                netsnmp_request_info *requests){    int             rc;    ipAddressTable_rowreq_ctx *rowreq_ctx =        netsnmp_container_table_row_extract(requests);    netsnmp_table_request_info *tri;    DEBUGMSGTL(("internal:ipAddressTable:_mfd_ipAddressTable_undo_values",                "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    for (; requests; requests = requests->next) {        /*         * set column data         */        tri = netsnmp_extract_table_info(requests);        if (NULL == tri)            continue;        rc = _ipAddressTable_undo_column(rowreq_ctx, requests->requestvb,                                         tri->colnum);        if (MFD_SUCCESS != rc) {            /*             * nothing we can do about it but log it             */            DEBUGMSGTL(("verbose:ipAddressTable:mfd", "error %d from "                        "ipAddressTable_undo_column\n", rc));        }    }                           /* for results */    return SNMP_ERR_NOERROR;}                               /* _mfd_ipAddressTable_undo_values *//*********************************************************************** * * DATA ACCESS * ***********************************************************************//** * @internal */static int_cache_load(netsnmp_cache * cache, void *vmagic){    DEBUGMSGTL(("internal:ipAddressTable:_cache_load", "called\n"));    if ((NULL == cache) || (NULL == cache->magic)) {        snmp_log(LOG_ERR, "invalid cache for ipAddressTable_cache_load\n");        return -1;    }    /** should only be called for an invalid or expired cache */    netsnmp_assert((0 == cache->valid) || (1 == cache->expired));    /*     * call user code     */    return ipAddressTable_cache_load((netsnmp_container *) cache->magic);}                               /* _cache_load *//** * @internal */static void_cache_item_free(ipAddressTable_rowreq_ctx * rowreq_ctx, void *context){    DEBUGMSGTL(("internal:ipAddressTable:_cache_item_free", "called\n"));    if (NULL == rowreq_ctx)        return;    ipAddressTable_release_rowreq_ctx(rowreq_ctx);}                               /* _cache_item_free *//** * @internal */static void_cache_free(netsnmp_cache * cache, void *magic){    netsnmp_container *container;    DEBUGMSGTL(("internal:ipAddressTable:_cache_free", "called\n"));    if ((NULL == cache) || (NULL == cache->magic)) {        snmp_log(LOG_ERR, "invalid cache in ipAddressTable_cache_free\n");        return;    }    container = (netsnmp_container *) cache->magic;    /*     * call user code     */    ipAddressTable_cache_free(container);    /*     * free all items. inefficient, but easy.     */    CONTAINER_CLEAR(container,                    (netsnmp_container_obj_func *) _cache_item_free, NULL);}                               /* _cache_free *//** * @internal * initialize the iterator container with functions or wrappers */void_ipAddressTable_container_init(ipAddressTable_interface_ctx * if_ctx){    DEBUGMSGTL(("internal:ipAddressTable:_ipAddressTable_container_init",                "called\n"));    /*     * set up the cache     */    if_ctx->cache = netsnmp_cache_create(30,    /* timeout in seconds */                                         _cache_load, _cache_free,                                         ipAddressTable_oid,                                         ipAddressTable_oid_size);    if (NULL == if_ctx->cache) {        snmp_log(LOG_ERR, "error creating cache for ipAddressTable\n");        return;    }    if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET;    ipAddressTable_container_init(&if_ctx->container, if_ctx->cache);    if (NULL == if_ctx->container)        if_ctx->container =            netsnmp_container_find("ipAddressTable:table_container");    if (NULL == if_ctx->container) {        snmp_log(LOG_ERR, "error creating container in "                 "ipAddressTable_container_init\n");        return;    }    if_ctx->cache->magic = (void *) if_ctx->container;}                               /* _ipAddressTable_container_init */

⌨️ 快捷键说明

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