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

📄 ipaddresstable_interface.c

📁 snmp的源代码,已经在我的ubuntu下编译通过
💻 C
📖 第 1 页 / 共 4 页
字号:
            /*             * 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_int_range(var, 1, 2147483647))                      != SNMP_ERR_NOERROR)                ) {                ;               /* rc set in condition */            }        }        if (SNMPERR_SUCCESS == rc) {            rc = ipAddressIfIndex_check_value(rowreq_ctx,                                              *((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 ipAddressIfIndex_check_value\n",                         rc);                rc = SNMP_ERR_GENERR;            }        }        break;        /*         * ipAddressType(4)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h          */    case COLUMN_IPADDRESSTYPE:        rc = netsnmp_check_vb_type(var, ASN_INTEGER);        if (SNMPERR_SUCCESS == rc) {            /*             * check that the value is one of defined enums              */            if (1 && (*var->val.integer != IPADDRESSTYPE_UNICAST)                && (*var->val.integer != IPADDRESSTYPE_ANYCAST)                && (*var->val.integer != IPADDRESSTYPE_BROADCAST)                ) {                rc = SNMP_ERR_WRONGVALUE;            }        }        if (SNMPERR_SUCCESS == rc) {            rc = ipAddressType_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 ipAddressType_check_value\n", rc);                rc = SNMP_ERR_GENERR;            }        }        break;        /*         * ipAddressStatus(7)/IpAddressStatusTC/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h          */    case COLUMN_IPADDRESSSTATUS:        rc = netsnmp_check_vb_type(var, ASN_INTEGER);        if (SNMPERR_SUCCESS == rc) {            /*             * check that the value is one of defined enums              */            if (1 && (*var->val.integer != IPADDRESSSTATUSTC_PREFERRED)                && (*var->val.integer != IPADDRESSSTATUSTC_INVALID)                && (*var->val.integer != IPADDRESSSTATUSTC_INACCESSIBLE)                && (*var->val.integer != IPADDRESSSTATUSTC_UNKNOWN)                && (*var->val.integer != IPADDRESSSTATUSTC_TENTATIVE)                && (*var->val.integer != IPADDRESSSTATUSTC_DUPLICATE)                ) {                rc = SNMP_ERR_WRONGVALUE;            }        }        if (SNMPERR_SUCCESS == rc) {            rc = ipAddressStatus_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 ipAddressStatus_check_value\n",                         rc);                rc = SNMP_ERR_GENERR;            }        }        break;        /*         * ipAddressRowStatus(10)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h          */    case COLUMN_IPADDRESSROWSTATUS:        rc = netsnmp_check_vb_rowstatus_value(var);        if (SNMPERR_SUCCESS == rc) {            rc = ipAddressRowStatus_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 ipAddressRowStatus_check_value\n",                         rc);                rc = SNMP_ERR_GENERR;            }        }        break;        /*         * ipAddressStorageType(11)/StorageType/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h          */    case COLUMN_IPADDRESSSTORAGETYPE:        rc = netsnmp_check_vb_type(var, ASN_INTEGER);        if (SNMPERR_SUCCESS == rc) {            /*             * check that the value is one of defined enums              */            if (1 && (*var->val.integer != STORAGETYPE_OTHER)                && (*var->val.integer != STORAGETYPE_VOLATILE)                && (*var->val.integer != STORAGETYPE_NONVOLATILE)                && (*var->val.integer != STORAGETYPE_PERMANENT)                && (*var->val.integer != STORAGETYPE_READONLY)                ) {                rc = SNMP_ERR_WRONGVALUE;            }        }        if (SNMPERR_SUCCESS == rc) {            rc = ipAddressStorageType_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 ipAddressStorageType_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 _ipAddressTable_check_column\n",                 column);    }    return rc;}                               /* _ipAddressTable_check_column */int_mfd_ipAddressTable_check_objects(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;    DEBUGMSGTL(("internal:ipAddressTable:_mfd_ipAddressTable_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 = _ipAddressTable_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_ipAddressTable_check_objects */NETSNMP_STATIC_INLINE int_ipAddressTable_check_indexes(ipAddressTable_rowreq_ctx * rowreq_ctx){    int             rc;    DEBUGMSGTL(("internal:ipAddressTable:_ipAddressTable_check_indexes",                "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    /*     * (INDEX) ipAddressAddrType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h      */    rc = ipAddressAddrType_check_index(rowreq_ctx);    if (MFD_SUCCESS != rc)        return SNMP_ERR_NOCREATION;    /*     * (INDEX) ipAddressAddr(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h      */    rc = ipAddressAddr_check_index(rowreq_ctx);    if (MFD_SUCCESS != rc)        return SNMP_ERR_NOCREATION;    /*     * if individual parts look ok, check them as a whole     */    return ipAddressTable_validate_index(rowreq_ctx->ipAddressTable_reg,                                         rowreq_ctx);}                               /* _ipAddressTable_check_indexes *//*---------------------------------------------------------------------- * * SET: check dependencies * *---------------------------------------------------------------------*//* * @internal * Check dependencies wrapper */static int_mfd_ipAddressTable_check_dependencies(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_check_dependencies", "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    rc = ipAddressTable_check_dependencies(rowreq_ctx);    if (rc) {        DEBUGMSGTL(("verbose:ipAddressTable:mfd", "error %d from "                    "ipAddressTable_check_dependencies\n", rc));        netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));    }    return SNMP_ERR_NOERROR;}                               /* _mfd_ipAddressTable_check_dependencies *//*---------------------------------------------------------------------- * * SET: Undo setup * *---------------------------------------------------------------------*//* * @internal * Set the value for a particular column */NETSNMP_STATIC_INLINE int_ipAddressTable_undo_setup_column(ipAddressTable_rowreq_ctx * rowreq_ctx,                                  int column){    int             rc = SNMPERR_SUCCESS;    DEBUGMSGTL(("internal:ipAddressTable:_ipAddressTable_undo_setup_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:        rowreq_ctx->column_set_flags |= FLAG_IPADDRESSIFINDEX;        rc = ipAddressIfIndex_undo_setup(rowreq_ctx);        break;        /*         * ipAddressType(4)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h          */    case COLUMN_IPADDRESSTYPE:        rowreq_ctx->column_set_flags |= FLAG_IPADDRESSTYPE;        rc = ipAddressType_undo_setup(rowreq_ctx);        break;        /*         * ipAddressStatus(7)/IpAddressStatusTC/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h          */    case COLUMN_IPADDRESSSTATUS:        rowreq_ctx->column_set_flags |= FLAG_IPADDRESSSTATUS;        rc = ipAddressStatus_undo_setup(rowreq_ctx);        break;        /*         * ipAddressRowStatus(10)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h          */    case COLUMN_IPADDRESSROWSTATUS:        rowreq_ctx->column_set_flags |= FLAG_IPADDRESSROWSTATUS;        rc = ipAddressRowStatus_undo_setup(rowreq_ctx);        break;        /*         * ipAddressStorageType(11)/StorageType/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h          */    case COLUMN_IPADDRESSSTORAGETYPE:        rowreq_ctx->column_set_flags |= FLAG_IPADDRESSSTORAGETYPE;        rc = ipAddressStorageType_undo_setup(rowreq_ctx);        break;    default:        snmp_log(LOG_ERR,                 "unknown column %d in _ipAddressTable_undo_setup_column\n",                 column);        break;    }    return rc;}                               /* _ipAddressTable_undo_setup_column *//** * @internal * undo setup */int_mfd_ipAddressTable_undo_setup(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_setup",                "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    /*     * allocate undo context     */    rowreq_ctx->undo = ipAddressTable_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 = ipAddressTable_undo_setup(rowreq_ctx);    if (MFD_SUCCESS != rc) {        DEBUGMSGTL(("verbose:ipAddressTable:mfd", "error %d from "                    "ipAddressTable_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) {            /*             * set column data             */            tri = netsnmp_extract_table_info(requests);            if (NULL == tri)                continue;            rc = _ipAddressTable_undo_setup_column(rowreq_ctx,                                                   tri->colnum);            if (MFD_SUCCESS != rc) {                DEBUGMSGTL(("verbose:ipAddressTable:mfd", "error %d from "                            "ipAddressTable_undo_setup_column\n", rc));                netsnmp_set_request_error(agtreq_info, requests,                                          SNMP_VALIDATE_ERR(rc));            }        }                       /* for results */    }    return SNMP_ERR_NOERROR;}                               /* _mfd_ipAddressTable_undo_setup *//** * @internal * undo setup */int_mfd_ipAddressTable_undo_cleanup(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);    int             rc;    DEBUGMSGTL(("internal:ipAddressTable:_mfd_ipAddressTable_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 = ipAddressTable_undo_cleanup(rowreq_ctx);    if (MFD_SUCCESS != rc) {        /*         * nothing we can do about it but log it         */        DEBUGMSGTL(("verbose:ipAddressTable:mfd", "error %d from "                    "ipAddressTable_undo_cleanup\n", rc));    }    /*     * release undo context, if needed     */    if (rowreq_ctx->undo) {        ipAddressTable_release_data(rowreq_ctx->undo);        rowreq_ctx->undo = NULL;    }

⌨️ 快捷键说明

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