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

📄 ifxtable_interface.c

📁 snmp的源代码,已经在我的ubuntu下编译通过
💻 C
📖 第 1 页 / 共 4 页
字号:
        netsnmp_container_table_row_extract(requests);    netsnmp_table_request_info *tri;    u_char         *old_string;    void            (*dataFreeHook) (void *);    int             rc;    DEBUGMSGTL(("internal:ifXTable:_mfd_ifXTable_get_values", "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    for (; requests; requests = requests->next) {        /*         * save old pointer, so we can free it if replaced         */        old_string = requests->requestvb->val.string;        dataFreeHook = requests->requestvb->dataFreeHook;        if (NULL == requests->requestvb->val.string) {            requests->requestvb->val.string = requests->requestvb->buf;            requests->requestvb->val_len =                sizeof(requests->requestvb->buf);        } else if (requests->requestvb->buf ==                   requests->requestvb->val.string) {            if (requests->requestvb->val_len !=                sizeof(requests->requestvb->buf))                requests->requestvb->val_len =                    sizeof(requests->requestvb->buf);        }        /*         * get column data         */        tri = netsnmp_extract_table_info(requests);        if (NULL == tri)            continue;        rc = _ifXTable_get_column(rowreq_ctx, requests->requestvb,                                  tri->colnum);        if (rc) {            if (MFD_SKIP == rc) {                requests->requestvb->type = ASN_PRIV_RETRY;                rc = SNMP_ERR_NOERROR;            }        } else if (NULL == requests->requestvb->val.string) {            snmp_log(LOG_ERR, "NULL varbind data pointer!\n");            rc = SNMP_ERR_GENERR;        }        if (rc)            netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc));        /*         * if the buffer wasn't used previously for the old data (i.e. it         * was allcoated memory)  and the get routine replaced the pointer,         * we need to free the previous pointer.         */        if (old_string && (old_string != requests->requestvb->buf) &&            (requests->requestvb->val.string != old_string)) {            if (dataFreeHook)                (*dataFreeHook) (old_string);            else                free(old_string);        }    }                           /* for results */    return SNMP_ERR_NOERROR;}                               /* _mfd_ifXTable_get_values *//*********************************************************************** * * SET processing * ***********************************************************************//*---------------------------------------------------------------------- * * SET: Syntax checks * *---------------------------------------------------------------------*//* * @internal * Check the syntax for a particular column */NETSNMP_STATIC_INLINE int_ifXTable_check_column(ifXTable_rowreq_ctx * rowreq_ctx,                       netsnmp_variable_list * var, int column){    int             rc = SNMPERR_SUCCESS;    DEBUGMSGTL(("internal:ifXTable:_ifXTable_check_column", "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    switch (column) {        /*         * ifLinkUpDownTrapEnable(14)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h          */    case COLUMN_IFLINKUPDOWNTRAPENABLE:        rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER,                                            sizeof(rowreq_ctx->data.                                                   ifLinkUpDownTrapEnable));        if (SNMPERR_SUCCESS == rc) {            /*             * check that the value is one of defined enums              */            if (1 && (*var->val.integer != IFLINKUPDOWNTRAPENABLE_ENABLED)                && (*var->val.integer != IFLINKUPDOWNTRAPENABLE_DISABLED)                ) {                rc = SNMP_ERR_WRONGVALUE;            }        }        if (SNMPERR_SUCCESS == rc) {            rc = ifLinkUpDownTrapEnable_check_value(rowreq_ctx,                                                    *((u_long *) var->val.                                                      string));            if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)                && (MFD_NOT_VALID_NOW != rc)) {                snmp_log(LOG_ERR,                         "bad rc %d from ifLinkUpDownTrapEnable_check_value\n",                         rc);                rc = SNMP_ERR_GENERR;            }        }        break;        /*         * ifPromiscuousMode(16)/TruthValue/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h          */    case COLUMN_IFPROMISCUOUSMODE:        rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER,                                            sizeof(rowreq_ctx->data.                                                   ifPromiscuousMode));        if (SNMPERR_SUCCESS == rc) {            /*             * check that the value is one of defined enums              */            if (1 && (*var->val.integer != TRUTHVALUE_TRUE)                && (*var->val.integer != TRUTHVALUE_FALSE)                ) {                rc = SNMP_ERR_WRONGVALUE;            }        }        if (SNMPERR_SUCCESS == rc) {            rc = ifPromiscuousMode_check_value(rowreq_ctx,                                               *((u_long *) var->val.                                                 string));            if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)                && (MFD_NOT_VALID_NOW != rc)) {                snmp_log(LOG_ERR,                         "bad rc %d from ifPromiscuousMode_check_value\n",                         rc);                rc = SNMP_ERR_GENERR;            }        }        break;        /*         * ifAlias(18)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H          */    case COLUMN_IFALIAS:        rc = netsnmp_check_vb_type(var, ASN_OCTET_STR);        if (SNMPERR_SUCCESS == rc) {            /*             * check that the value is in the defined range(s); inefficent             * * but keeps rc value knowledge in libarary where it belongs.              */            if (1                && ((rc = netsnmp_check_vb_size_range(var, 0, 64)) !=                    SNMP_ERR_NOERROR)                ) {                ;               /* rc set in condition */            }        }        if (SNMPERR_SUCCESS == rc) {            rc = ifAlias_check_value(rowreq_ctx, (char *) var->val.string,                                     var->val_len);            if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)                && (MFD_NOT_VALID_NOW != rc)) {                snmp_log(LOG_ERR, "bad rc %d from ifAlias_check_value\n",                         rc);                rc = SNMP_ERR_GENERR;            }        }        break;    default: /** We shouldn't get here */        rc = SNMP_ERR_GENERR;        snmp_log(LOG_ERR, "unknown column %d in _ifXTable_check_column\n",                 column);    }    return rc;}                               /* _ifXTable_check_column */int_mfd_ifXTable_check_objects(netsnmp_mib_handler *handler,                            netsnmp_handler_registration *reginfo,                            netsnmp_agent_request_info *agtreq_info,                            netsnmp_request_info *requests){    ifXTable_rowreq_ctx *rowreq_ctx =        netsnmp_container_table_row_extract(requests);    netsnmp_table_request_info *tri;    int             rc;    DEBUGMSGTL(("internal:ifXTable:_mfd_ifXTable_check_objects",                "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    for (; requests; requests = requests->next) {        /*         * get column number from table request info, and check that column         */        tri = netsnmp_extract_table_info(requests);        if (NULL == tri)            continue;        rc = _ifXTable_check_column(rowreq_ctx, requests->requestvb,                                    tri->colnum);        if (rc) {            netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc));            break;        }    }                           /* for results */    return SNMP_ERR_NOERROR;}                               /* _mfd_ifXTable_check_objects *//*---------------------------------------------------------------------- * * SET: check dependencies * *---------------------------------------------------------------------*//* * @internal * Check dependencies wrapper */static int_mfd_ifXTable_check_dependencies(netsnmp_mib_handler *handler,                                 netsnmp_handler_registration *reginfo,                                 netsnmp_agent_request_info *agtreq_info,                                 netsnmp_request_info *requests){    int             rc;    ifXTable_rowreq_ctx *rowreq_ctx =        netsnmp_container_table_row_extract(requests);    DEBUGMSGTL(("internal:ifXTable:_mfd_ifXTable_check_dependencies",                "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    rc = ifXTable_check_dependencies(rowreq_ctx);    if (rc) {        DEBUGMSGTL(("verbose:ifXTable:mfd", "error %d from "                    "ifXTable_check_dependencies\n", rc));        netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));    }    return SNMP_ERR_NOERROR;}                               /* _mfd_ifXTable_check_dependencies *//*---------------------------------------------------------------------- * * SET: Undo setup * *---------------------------------------------------------------------*//* * @internal * Set the value for a particular column */NETSNMP_STATIC_INLINE int_ifXTable_undo_setup_column(ifXTable_rowreq_ctx * rowreq_ctx, int column){    int             rc = SNMPERR_SUCCESS;    DEBUGMSGTL(("internal:ifXTable:_ifXTable_undo_setup_column",                "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    switch (column) {        /*         * ifLinkUpDownTrapEnable(14)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h          */    case COLUMN_IFLINKUPDOWNTRAPENABLE:        rowreq_ctx->column_set_flags |= FLAG_IFLINKUPDOWNTRAPENABLE;        rc = ifLinkUpDownTrapEnable_undo_setup(rowreq_ctx);        break;        /*         * ifPromiscuousMode(16)/TruthValue/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h          */    case COLUMN_IFPROMISCUOUSMODE:        rowreq_ctx->column_set_flags |= FLAG_IFPROMISCUOUSMODE;        rc = ifPromiscuousMode_undo_setup(rowreq_ctx);        break;        /*         * ifAlias(18)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H          */    case COLUMN_IFALIAS:        rowreq_ctx->column_set_flags |= FLAG_IFALIAS;        rc = ifAlias_undo_setup(rowreq_ctx);        break;    default:        snmp_log(LOG_ERR,                 "unknown column %d in _ifXTable_undo_setup_column\n",                 column);        break;    }    return rc;}                               /* _ifXTable_undo_setup_column *//** * @internal * undo setup */int_mfd_ifXTable_undo_setup(netsnmp_mib_handler *handler,                         netsnmp_handler_registration *reginfo,                         netsnmp_agent_request_info *agtreq_info,                         netsnmp_request_info *requests){    int             rc;    ifXTable_rowreq_ctx *rowreq_ctx =        netsnmp_container_table_row_extract(requests);    DEBUGMSGTL(("internal:ifXTable:_mfd_ifXTable_undo_setup", "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    /*     * allocate undo context     */    rowreq_ctx->undo = ifXTable_allocate_data();    if (NULL == rowreq_ctx->undo) {        /** msg already logged */        netsnmp_request_set_error_all(requests,                                      SNMP_ERR_RESOURCEUNAVAILABLE);        return SNMP_ERR_NOERROR;    }    /*     * row undo setup     */    rowreq_ctx->column_set_flags = 0;    rc = ifXTable_undo_setup(rowreq_ctx);    if (MFD_SUCCESS != rc) {        DEBUGMSGTL(("verbose:ifXTable:mfd", "error %d from "                    "ifXTable_undo_setup\n", rc));        netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));    } else {        /*         * column undo setup         */        netsnmp_table_request_info *tri;        for (; requests; requests = requests->next) {            /*

⌨️ 快捷键说明

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