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

📄 inetnettomediatable_interface.c

📁 开发snmp的开发包有两个开放的SNMP开发库
💻 C
📖 第 1 页 / 共 5 页
字号:
    return rc;}                               /* _inetNetToMediaTable_set_column */int_mfd_inetNetToMediaTable_set_values(netsnmp_mib_handler *handler,                                    netsnmp_handler_registration *reginfo,                                    netsnmp_agent_request_info                                    *agtreq_info,                                    netsnmp_request_info *requests){    inetNetToMediaTable_rowreq_ctx *rowreq_ctx =        netsnmp_container_table_row_extract(requests);    netsnmp_table_request_info *tri;    int             rc = SNMP_ERR_NOERROR;    DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_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 = _inetNetToMediaTable_set_column(rowreq_ctx,                                             requests->requestvb,                                             tri->colnum);        if (MFD_SUCCESS != rc) {            DEBUGMSGTL(("inetNetToMediaTable:mfd", "error %d from "                        "inetNetToMediaTable_set_column\n", rc));            netsnmp_set_request_error(agtreq_info, requests,                                      SNMP_VALIDATE_ERR(rc));        }    }                           /* for results */    return SNMP_ERR_NOERROR;}                               /* _mfd_inetNetToMediaTable_set_values *//*---------------------------------------------------------------------- * * SET: commit * *---------------------------------------------------------------------*//** * @internal * commit the values */int_mfd_inetNetToMediaTable_commit(netsnmp_mib_handler *handler,                                netsnmp_handler_registration *reginfo,                                netsnmp_agent_request_info *agtreq_info,                                netsnmp_request_info *requests){    int             rc;    inetNetToMediaTable_rowreq_ctx *rowreq_ctx =        netsnmp_container_table_row_extract(requests);    DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_commit", "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    rc = inetNetToMediaTable_commit(rowreq_ctx);    if (MFD_SUCCESS != rc) {        DEBUGMSGTL(("inetNetToMediaTable:mfd", "error %d from "                    "inetNetToMediaTable_commit\n", rc));        netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));    }    if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) {        /*         * if we successfully commited this row, set the dirty flag. Use the         * current value + 1 (i.e. dirty = # rows changed).         * this is checked in post_request...         */        inetNetToMediaTable_dirty_set(inetNetToMediaTable_dirty_get() + 1);     /* set table dirty flag */    }    return SNMP_ERR_NOERROR;}int_mfd_inetNetToMediaTable_undo_commit(netsnmp_mib_handler *handler,                                     netsnmp_handler_registration *reginfo,                                     netsnmp_agent_request_info                                     *agtreq_info,                                     netsnmp_request_info *requests){    int             rc;    inetNetToMediaTable_rowreq_ctx *rowreq_ctx =        netsnmp_container_table_row_extract(requests);    DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_undo_commit", "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) {        u_int           d = inetNetToMediaTable_dirty_get();        netsnmp_assert(d != 0);        if (d)            inetNetToMediaTable_dirty_set(d - 1);    }    rc = inetNetToMediaTable_undo_commit(rowreq_ctx);    if (MFD_SUCCESS != rc) {        /*         * nothing we can do about it but log it         */        DEBUGMSGTL(("inetNetToMediaTable:mfd", "error %d from "                    "inetNetToMediaTable_undo_commit\n", rc));    }    if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) {        snmp_log(LOG_WARNING,                 "inetNetToMediaTable row dirty flag still set after undo_commit\n");        rowreq_ctx->rowreq_flags &= ~MFD_ROW_DIRTY;    }    return SNMP_ERR_NOERROR;}                               /* _mfd_inetNetToMediaTable_commit *//*---------------------------------------------------------------------- * * SET: Undo * *---------------------------------------------------------------------*//** * @internal * undo the value for a particular column */NETSNMP_STATIC_INLINE int_inetNetToMediaTable_undo_column(inetNetToMediaTable_rowreq_ctx *                                 rowreq_ctx, netsnmp_variable_list * var,                                 int column){    int             rc = SNMPERR_SUCCESS;    DEBUGMSGTL(("internal:inetNetToMediaTable:_inetNetToMediaTable_undo_column", "called for %d\n", column));    netsnmp_assert(NULL != rowreq_ctx);    switch (column) {        /*         * inetNetToMediaPhysAddress(4)/PhysAddress/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H          */    case COLUMN_INETNETTOMEDIAPHYSADDRESS:        rc = inetNetToMediaPhysAddress_undo(rowreq_ctx);        break;        /*         * inetNetToMediaType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h          */    case COLUMN_INETNETTOMEDIATYPE:        rc = inetNetToMediaType_undo(rowreq_ctx);        break;        /*         * inetNetToMediaRowStatus(8)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h          */    case COLUMN_INETNETTOMEDIAROWSTATUS:        rc = inetNetToMediaRowStatus_undo(rowreq_ctx);        break;    default:        snmp_log(LOG_ERR,                 "unknown column %d in _inetNetToMediaTable_undo_column\n",                 column);        break;    }    return rc;}                               /* _inetNetToMediaTable_undo_column */int_mfd_inetNetToMediaTable_undo_values(netsnmp_mib_handler *handler,                                     netsnmp_handler_registration *reginfo,                                     netsnmp_agent_request_info                                     *agtreq_info,                                     netsnmp_request_info *requests){    int             rc;    inetNetToMediaTable_rowreq_ctx *rowreq_ctx =        netsnmp_container_table_row_extract(requests);    netsnmp_table_request_info *tri;    DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_undo_values", "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    rc = inetNetToMediaTable_undo(rowreq_ctx);    if (MFD_SUCCESS != rc) {        /*         * nothing we can do about it but log it         */        DEBUGMSGTL(("inetNetToMediaTable:mfd", "error %d from "                    "inetNetToMediaTable_undo\n", rc));    }    for (; requests; requests = requests->next) {        /*         * set column data         */        tri = netsnmp_extract_table_info(requests);        if (NULL == tri)            continue;        rc = _inetNetToMediaTable_undo_column(rowreq_ctx,                                              requests->requestvb,                                              tri->colnum);        if (MFD_SUCCESS != rc) {            /*             * nothing we can do about it but log it             */            DEBUGMSGTL(("inetNetToMediaTable:mfd", "error %d from "                        "inetNetToMediaTable_undo_column\n", rc));        }    }                           /* for results */    return SNMP_ERR_NOERROR;}                               /* _mfd_inetNetToMediaTable_undo_values *//*---------------------------------------------------------------------- * * SET: irreversible commit * *---------------------------------------------------------------------*//** * @internal * commit irreversible actions */int_mfd_inetNetToMediaTable_irreversible_commit(netsnmp_mib_handler *handler, netsnmp_handler_registration                                             *reginfo, netsnmp_agent_request_info                                             *agtreq_info, netsnmp_request_info                                             *requests){    inetNetToMediaTable_rowreq_ctx *rowreq_ctx =        netsnmp_container_table_row_extract(requests);    DEBUGMSGTL(("internal:inetNetToMediaTable:_mfd_inetNetToMediaTable_irreversible:commit", "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    /*     * check for and handle row creation/deletion     * and update column exist flags...     */    if (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED) {        if (!(rowreq_ctx->rowreq_flags & MFD_ROW_CREATED))            CONTAINER_REMOVE(inetNetToMediaTable_if_ctx.container, rowreq_ctx);    } else {        if (rowreq_ctx->column_set_flags) {            rowreq_ctx->column_set_flags = 0;        }        if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) {            rowreq_ctx->rowreq_flags &= ~MFD_ROW_CREATED;            CONTAINER_INSERT(inetNetToMediaTable_if_ctx.container,                             rowreq_ctx);        }    }    return SNMP_ERR_NOERROR;}                               /* _mfd_inetNetToMediaTable_irreversible_commit *//*********************************************************************** * * DATA ACCESS * ***********************************************************************/static void     _container_free(netsnmp_container *container);/** * @internal */static int_cache_load(netsnmp_cache * cache, void *vmagic){    DEBUGTRACE;    if ((NULL == cache) || (NULL == cache->magic)) {        snmp_log(LOG_ERR,                 "invalid cache for inetNetToMediaTable_cache_load\n");        return -1;    }    DEBUGMSGTL(("inetNetToMediaTable/cache", "inetNetToMedia_load %p/%p\n",                cache, cache->magic));    netsnmp_assert((0 == cache->valid) || (1 == cache->expired));    /*     * call user code     */    return inetNetToMediaTable_container_load((netsnmp_container *) cache->                                              magic);}                               /* _cache_load *//** * @internal */static void_cache_free(netsnmp_cache * cache, void *magic){    netsnmp_container *container;    DEBUGMSGTL(("internal:inetNetToMediaTable:_cache_free", "called\n"));    if ((NULL == cache) || (NULL == cache->magic)) {        snmp_log(LOG_ERR,                 "invalid cache in inetNetToMediaTable_cache_free\n");        return;    }    container = (netsnmp_container *) cache->magic;    _container_free(container);}                               /* _cache_free *//** * @internal */static void_container_item_free(inetNetToMediaTable_rowreq_ctx * rowreq_ctx,                     void *context){    DEBUGMSGTL(("internal:inetNetToMediaTable:_container_item_free",                "called\n"));    if (NULL == rowreq_ctx)        return;    inetNetToMediaTable_release_rowreq_ctx(rowreq_ctx);}                               /* _container_item_free *//** * @internal */static void_container_free(netsnmp_container *container){    DEBUGMSGTL(("internal:inetNetToMediaTable:_container_free",                "called\n"));    if (NULL == container) {        snmp_log(LOG_ERR,                 "invalid container in inetNetToMediaTable_container_free\n");        return;    }    /*     * call user code     */    inetNetToMediaTable_container_free(container);    /*     * free all items. inefficient, but easy.     */    CONTAINER_CLEAR(container,                    (netsnmp_container_obj_func *) _container_item_free,                    NULL);}                               /* _container_free *//** * @internal * initialize the container with functions or wrappers */void_inetNetToMediaTable_container_init(inetNetToMediaTable_interface_ctx *                                    if_ctx){    DEBUGMSGTL(("internal:inetNetToMediaTable:_inetNetToMediaTable_container_init", "called\n"));    /*     * cache init     */    if_ctx->cache = netsnmp_cache_create(30,    /* timeout in seconds */                                         _cache_load, _cache_free,                                    

⌨️ 快捷键说明

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