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

📄 ipv4interfacetable_interface.c

📁 开发snmp的开发包有两个开放的SNMP开发库
💻 C
📖 第 1 页 / 共 3 页
字号:
            }        }                       /* for results */    }    return SNMP_ERR_NOERROR;}                               /* _mfd_ipv4InterfaceTable_undo_setup *//** * @internal * undo setup */int_mfd_ipv4InterfaceTable_undo_cleanup(netsnmp_mib_handler *handler,                                     netsnmp_handler_registration *reginfo,                                     netsnmp_agent_request_info                                     *agtreq_info,                                     netsnmp_request_info *requests){    ipv4InterfaceTable_rowreq_ctx *rowreq_ctx =        netsnmp_container_table_row_extract(requests);    int             rc;    DEBUGMSGTL(("internal:ipv4InterfaceTable:_mfd_ipv4InterfaceTable_undo_cleanup", "called\n"));    /*     * failed row create in early stages has no rowreq_ctx     */    if (NULL == rowreq_ctx)        return MFD_SUCCESS;    /*     * call user cleanup     */    rc = ipv4InterfaceTable_undo_cleanup(rowreq_ctx);    if (MFD_SUCCESS != rc) {        /*         * nothing we can do about it but log it         */        DEBUGMSGTL(("ipv4InterfaceTable:mfd", "error %d from "                    "ipv4InterfaceTable_undo_cleanup\n", rc));    }    /*     * release undo context, if needed     */    _mfd_ifTable_undo_setup_release(rowreq_ctx);    return SNMP_ERR_NOERROR;}                               /* _mfd_ipv4InterfaceTable_undo_cleanup *//*---------------------------------------------------------------------- * * SET: Set values * *---------------------------------------------------------------------*//* * @internal * Set the value for a particular column */NETSNMP_STATIC_INLINE int_ipv4InterfaceTable_set_column(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx,                               netsnmp_variable_list * var, int column){    int             rc = SNMPERR_SUCCESS;    DEBUGMSGTL(("internal:ipv4InterfaceTable:_ipv4InterfaceTable_set_column", "called for %d\n", column));    netsnmp_assert(NULL != rowreq_ctx);    switch (column) {        /*         * ipv4InterfaceEnableStatus(3)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h          */    case COLUMN_IPV4INTERFACEENABLESTATUS:        rowreq_ctx->column_set_flags |=            COLUMN_IPV4INTERFACEENABLESTATUS_FLAG;        rc = ipv4InterfaceEnableStatus_set(rowreq_ctx,                                           *((u_long *) var->val.string));        break;    default:        snmp_log(LOG_ERR,                 "unknown column %d in _ipv4InterfaceTable_set_column\n",                 column);        rc = SNMP_ERR_GENERR;        break;    }    return rc;}                               /* _ipv4InterfaceTable_set_column */int_mfd_ipv4InterfaceTable_set_values(netsnmp_mib_handler *handler,                                   netsnmp_handler_registration *reginfo,                                   netsnmp_agent_request_info *agtreq_info,                                   netsnmp_request_info *requests){    ipv4InterfaceTable_rowreq_ctx *rowreq_ctx =        netsnmp_container_table_row_extract(requests);    netsnmp_table_request_info *tri;    int             rc = SNMP_ERR_NOERROR;    DEBUGMSGTL(("internal:ipv4InterfaceTable:_mfd_ipv4InterfaceTable_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 = _ipv4InterfaceTable_set_column(rowreq_ctx,                                            requests->requestvb,                                            tri->colnum);        if (MFD_SUCCESS != rc) {            DEBUGMSGTL(("ipv4InterfaceTable:mfd", "error %d from "                        "ipv4InterfaceTable_set_column\n", rc));            netsnmp_set_request_error(agtreq_info, requests,                                      SNMP_VALIDATE_ERR(rc));        }    }                           /* for results */    return SNMP_ERR_NOERROR;}                               /* _mfd_ipv4InterfaceTable_set_values *//*---------------------------------------------------------------------- * * SET: commit * *---------------------------------------------------------------------*//** * @internal * commit the values */int_mfd_ipv4InterfaceTable_commit(netsnmp_mib_handler *handler,                               netsnmp_handler_registration *reginfo,                               netsnmp_agent_request_info *agtreq_info,                               netsnmp_request_info *requests){    int             rc;    ipv4InterfaceTable_rowreq_ctx *rowreq_ctx =        netsnmp_container_table_row_extract(requests);    DEBUGMSGTL(("internal:ipv4InterfaceTable:_mfd_ipv4InterfaceTable_commit", "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    rc = ipv4InterfaceTable_commit(rowreq_ctx);    if (MFD_SUCCESS != rc) {        DEBUGMSGTL(("ipv4InterfaceTable:mfd", "error %d from "                    "ipv4InterfaceTable_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...         */        ipv4InterfaceTable_dirty_set(ipv4InterfaceTable_dirty_get() + 1);       /* set table dirty flag */    }    return SNMP_ERR_NOERROR;}int_mfd_ipv4InterfaceTable_undo_commit(netsnmp_mib_handler *handler,                                    netsnmp_handler_registration *reginfo,                                    netsnmp_agent_request_info                                    *agtreq_info,                                    netsnmp_request_info *requests){    int             rc;    ipv4InterfaceTable_rowreq_ctx *rowreq_ctx =        netsnmp_container_table_row_extract(requests);    DEBUGMSGTL(("internal:ipv4InterfaceTable:_mfd_ipv4InterfaceTable_undo_commit", "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) {        u_int           d = ipv4InterfaceTable_dirty_get();        netsnmp_assert(d != 0);        if (d)            ipv4InterfaceTable_dirty_set(d - 1);    }    rc = ipv4InterfaceTable_undo_commit(rowreq_ctx);    if (MFD_SUCCESS != rc) {        /*         * nothing we can do about it but log it         */        DEBUGMSGTL(("ipv4InterfaceTable:mfd", "error %d from "                    "ipv4InterfaceTable_undo_commit\n", rc));    }    if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) {        snmp_log(LOG_WARNING,                 "ipv4InterfaceTable row dirty flag still set after undo_commit\n");        rowreq_ctx->rowreq_flags &= ~MFD_ROW_DIRTY;    }    return SNMP_ERR_NOERROR;}                               /* _mfd_ipv4InterfaceTable_commit *//*---------------------------------------------------------------------- * * SET: Undo * *---------------------------------------------------------------------*//** * @internal * undo the value for a particular column */NETSNMP_STATIC_INLINE int_ipv4InterfaceTable_undo_column(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx,                                netsnmp_variable_list * var, int column){    int             rc = SNMPERR_SUCCESS;    DEBUGMSGTL(("internal:ipv4InterfaceTable:_ipv4InterfaceTable_undo_column", "called for %d\n", column));    netsnmp_assert(NULL != rowreq_ctx);    switch (column) {        /*         * ipv4InterfaceEnableStatus(3)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h          */    case COLUMN_IPV4INTERFACEENABLESTATUS:        rc = ipv4InterfaceEnableStatus_undo(rowreq_ctx);        break;    default:        snmp_log(LOG_ERR,                 "unknown column %d in _ipv4InterfaceTable_undo_column\n",                 column);        break;    }    return rc;}                               /* _ipv4InterfaceTable_undo_column */int_mfd_ipv4InterfaceTable_undo_values(netsnmp_mib_handler *handler,                                    netsnmp_handler_registration *reginfo,                                    netsnmp_agent_request_info                                    *agtreq_info,                                    netsnmp_request_info *requests){    int             rc;    ipv4InterfaceTable_rowreq_ctx *rowreq_ctx =        netsnmp_container_table_row_extract(requests);    netsnmp_table_request_info *tri;    DEBUGMSGTL(("internal:ipv4InterfaceTable:_mfd_ipv4InterfaceTable_undo_values", "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    rc = ipv4InterfaceTable_undo(rowreq_ctx);    if (MFD_SUCCESS != rc) {        /*         * nothing we can do about it but log it         */        DEBUGMSGTL(("ipv4InterfaceTable:mfd", "error %d from "                    "ipv4InterfaceTable_undo\n", rc));    }    for (; requests; requests = requests->next) {        /*         * set column data         */        tri = netsnmp_extract_table_info(requests);        if (NULL == tri)            continue;        rc = _ipv4InterfaceTable_undo_column(rowreq_ctx,                                             requests->requestvb,                                             tri->colnum);        if (MFD_SUCCESS != rc) {            /*             * nothing we can do about it but log it             */            DEBUGMSGTL(("ipv4InterfaceTable:mfd", "error %d from "                        "ipv4InterfaceTable_undo_column\n", rc));        }    }                           /* for results */    return SNMP_ERR_NOERROR;}                               /* _mfd_ipv4InterfaceTable_undo_values *//*---------------------------------------------------------------------- * * SET: irreversible commit * *---------------------------------------------------------------------*//** * @internal * commit irreversible actions */int_mfd_ipv4InterfaceTable_irreversible_commit(netsnmp_mib_handler *handler, netsnmp_handler_registration                                            *reginfo, netsnmp_agent_request_info                                            *agtreq_info,                                            netsnmp_request_info *requests){    ipv4InterfaceTable_rowreq_ctx *rowreq_ctx =        netsnmp_container_table_row_extract(requests);    DEBUGMSGTL(("internal:ipv4InterfaceTable:_mfd_ipv4InterfaceTable_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) {        CONTAINER_REMOVE(ipv4InterfaceTable_if_ctx.container, rowreq_ctx);    } else {        if (rowreq_ctx->column_set_flags) {            rowreq_ctx->column_set_flags = 0;        }    }    return SNMP_ERR_NOERROR;}                               /* _mfd_ipv4InterfaceTable_irreversible_commit *//*********************************************************************** * * DATA ACCESS * ***********************************************************************//** * @internal *//** * @internal */static void_container_free(netsnmp_container *container){    DEBUGMSGTL(("internal:ipv4InterfaceTable:_container_free",                "called\n"));    if (NULL == container) {        snmp_log(LOG_ERR,                 "invalid container in ipv4InterfaceTable_container_free\n");        return;    }    /*     * call user code     */    ipv4InterfaceTable_container_free(container);}                               /* _container_free *//** * @internal * initialize the container with functions or wrappers */void_ipv4InterfaceTable_container_init(ipv4InterfaceTable_interface_ctx *                                   if_ctx){    DEBUGMSGTL(("internal:ipv4InterfaceTable:_ipv4InterfaceTable_container_init", "called\n"));    /*     * container init     */    ipv4InterfaceTable_container_init(&if_ctx->container);    if (NULL == if_ctx->container)        if_ctx->container =            netsnmp_container_find("ipv4InterfaceTable:table_container");    if (NULL == if_ctx->container) {        snmp_log(LOG_ERR, "error creating container in "                 "ipv4InterfaceTable_container_init\n");        return;    }}                               /* _ipv4InterfaceTable_container_init *//** * @internal * shutdown the container with functions or wrappers */void_ipv4InterfaceTable_container_shutdown(ipv4InterfaceTable_interface_ctx *                                       if_ctx){    DEBUGMSGTL(("internal:ipv4InterfaceTable:_ipv4InterfaceTable_container_shutdown", "called\n"));    ipv4InterfaceTable_container_shutdown(if_ctx->container);    _container_free(if_ctx->container);}                               /* _ipv4InterfaceTable_container_shutdown */ipv4InterfaceTable_rowreq_ctx *ipv4InterfaceTable_row_find_by_mib_index(ipv4InterfaceTable_mib_index *                                         mib_idx){    ipv4InterfaceTable_rowreq_ctx *rowreq_ctx;    oid             oid_tmp[MAX_OID_LEN];    netsnmp_index   oid_idx;    int             rc;    /*     * set up storage for OID     */    oid_idx.oids = oid_tmp;    oid_idx.len = sizeof(oid_tmp) / sizeof(oid);    /*     * convert     */    rc = ifTable_index_to_oid(&oid_idx, mib_idx);    if (MFD_SUCCESS != rc)        return NULL;    rowreq_ctx =        CONTAINER_FIND(ipv4InterfaceTable_if_ctx.container, &oid_idx);    return rowreq_ctx;}

⌨️ 快捷键说明

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