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

📄 snmpnotifyfiltertable_interface.c

📁 开发snmp的开发包有两个开放的SNMP开发库
💻 C
📖 第 1 页 / 共 5 页
字号:
    DEBUGMSGTL(("internal:snmpNotifyFilterTable:_mfd_snmpNotifyFilterTable_rowreq_from_index", "called\n"));    if (NULL == rc_ptr)        rc_ptr = &rc;    *rc_ptr = MFD_SUCCESS;    memset(&mib_idx, 0x0, sizeof(mib_idx));    /*     * try to parse oid     */    *rc_ptr = snmpNotifyFilterTable_index_from_oid(oid_idx, &mib_idx);    if (MFD_SUCCESS != *rc_ptr) {        DEBUGMSGT(("snmpNotifyFilterTable", "error parsing index\n"));        return NULL;    }    /*     * allocate new context     */    rowreq_ctx = snmpNotifyFilterTable_allocate_rowreq_ctx(NULL);    if (NULL == rowreq_ctx) {        *rc_ptr = MFD_ERROR;        return NULL;            /* msg already logged */    }    memcpy(&rowreq_ctx->tbl_idx, &mib_idx, sizeof(mib_idx));    /*     * check indexes     */    *rc_ptr = _snmpNotifyFilterTable_check_indexes(rowreq_ctx);    if (MFD_SUCCESS != *rc_ptr) {        netsnmp_assert((*rc_ptr == SNMP_ERR_NOCREATION) ||                       (*rc_ptr == SNMP_ERR_INCONSISTENTNAME));        snmpNotifyFilterTable_release_rowreq_ctx(rowreq_ctx);        return NULL;    }    /*     * copy indexes     */    rowreq_ctx->oid_idx.len = oid_idx->len;    memcpy(rowreq_ctx->oid_idx.oids, oid_idx->oids,           oid_idx->len * sizeof(oid));    return rowreq_ctx;}                               /* _mfd_snmpNotifyFilterTable_rowreq_from_index *//** * @internal * wrapper */static int_mfd_snmpNotifyFilterTable_object_lookup(netsnmp_mib_handler *handler, netsnmp_handler_registration                                         *reginfo, netsnmp_agent_request_info                                         *agtreq_info,                                         netsnmp_request_info *requests){    int             rc = SNMP_ERR_NOERROR;    snmpNotifyFilterTable_rowreq_ctx *rowreq_ctx =        netsnmp_container_table_row_extract(requests);    DEBUGMSGTL(("internal:snmpNotifyFilterTable:_mfd_snmpNotifyFilterTable_object_lookup", "called\n"));    /*     * get our context from mfd     * snmpNotifyFilterTable_interface_ctx *if_ctx =     *             (snmpNotifyFilterTable_interface_ctx *)reginfo->my_reg_void;     */    if (NULL == rowreq_ctx) {        netsnmp_table_request_info *tblreq_info;        netsnmp_index   oid_idx;        tblreq_info = netsnmp_extract_table_info(requests);        if (NULL == tblreq_info) {            snmp_log(LOG_ERR, "request had no table info\n");            return MFD_ERROR;        }        /*         * try create rowreq         */        oid_idx.oids = tblreq_info->index_oid;        oid_idx.len = tblreq_info->index_oid_len;        rowreq_ctx =            _mfd_snmpNotifyFilterTable_rowreq_from_index(&oid_idx, &rc);        if (MFD_SUCCESS == rc) {            netsnmp_assert(NULL != rowreq_ctx);            rowreq_ctx->rowreq_flags |= MFD_ROW_CREATED;            /*             * add rowreq_ctx to request data lists             */            netsnmp_container_table_row_insert(requests, (netsnmp_index *)                                               rowreq_ctx);        }    }    if (MFD_SUCCESS != rc)        netsnmp_request_set_error_all(requests, rc);    else        snmpNotifyFilterTable_row_prep(rowreq_ctx);    return SNMP_VALIDATE_ERR(rc);}                               /* _mfd_snmpNotifyFilterTable_object_lookup *//*********************************************************************** * * GET processing * ***********************************************************************//* * @internal * Retrieve the value for a particular column */NETSNMP_STATIC_INLINE int_snmpNotifyFilterTable_get_column(snmpNotifyFilterTable_rowreq_ctx *                                  rowreq_ctx, netsnmp_variable_list * var,                                  int column){    int             rc = SNMPERR_SUCCESS;    DEBUGMSGTL(("internal:snmpNotifyFilterTable:_mfd_snmpNotifyFilterTable_get_column", "called for %d\n", column));    netsnmp_assert(NULL != rowreq_ctx);    switch (column) {        /*         * snmpNotifyFilterMask(2)/OCTETSTR/ASN_OCTET_STR/char(char)//L/A/W/e/R/D/h          */    case COLUMN_SNMPNOTIFYFILTERMASK:        var->type = ASN_OCTET_STR;        rc = snmpNotifyFilterMask_get(rowreq_ctx,                                      (char **) &var->val.string,                                      &var->val_len);        break;        /*         * snmpNotifyFilterType(3)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h          */    case COLUMN_SNMPNOTIFYFILTERTYPE:        var->val_len = sizeof(u_long);        var->type = ASN_INTEGER;        rc = snmpNotifyFilterType_get(rowreq_ctx,                                      (u_long *) var->val.string);        break;        /*         * snmpNotifyFilterStorageType(4)/StorageType/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h          */    case COLUMN_SNMPNOTIFYFILTERSTORAGETYPE:        var->val_len = sizeof(u_long);        var->type = ASN_INTEGER;        rc = snmpNotifyFilterStorageType_get(rowreq_ctx,                                             (u_long *) var->val.string);        break;        /*         * snmpNotifyFilterRowStatus(5)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h          */    case COLUMN_SNMPNOTIFYFILTERROWSTATUS:        var->val_len = sizeof(u_long);        var->type = ASN_INTEGER;        rc = snmpNotifyFilterRowStatus_get(rowreq_ctx,                                           (u_long *) var->val.string);        break;    default:        snmp_log(LOG_ERR,                 "unknown column %d in _snmpNotifyFilterTable_get_column\n",                 column);        break;    }    return rc;}                               /* _snmpNotifyFilterTable_get_column */int_mfd_snmpNotifyFilterTable_get_values(netsnmp_mib_handler *handler, netsnmp_handler_registration                                      *reginfo, netsnmp_agent_request_info                                      *agtreq_info,                                      netsnmp_request_info *requests){    snmpNotifyFilterTable_rowreq_ctx *rowreq_ctx =        netsnmp_container_table_row_extract(requests);    netsnmp_table_request_info *tri;    u_char         *old_string;    void            (*dataFreeHook) (void *);    int             rc;    DEBUGMSGTL(("internal:snmpNotifyFilterTable:_mfd_snmpNotifyFilterTable_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 = _snmpNotifyFilterTable_get_column(rowreq_ctx,                                               requests->requestvb,                                               tri->colnum);        if (rc) {            if (MFD_SKIP == rc) {                requests->requestvb->type = SNMP_NOSUCHINSTANCE;                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_snmpNotifyFilterTable_get_values */NETSNMP_STATIC_INLINE int_snmpNotifyFilterTable_check_indexes(snmpNotifyFilterTable_rowreq_ctx *                                     rowreq_ctx){    int             rc = SNMPERR_SUCCESS;    DEBUGMSGTL(("internal:snmpNotifyFilterTable:_snmpNotifyFilterTable_check_indexes", "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    /*     * check that the corresponding EXTERNAL row exists     */    /*     * (INDEX) snmpNotifyFilterProfileName(1)/SnmpAdminString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H      */    rc = snmpNotifyFilterTable_snmpNotifyFilterProfileName_check_index        (rowreq_ctx);    if (MFD_SUCCESS != rc)        return SNMP_ERR_NOCREATION;    /*     * (INDEX) snmpNotifyFilterSubtree(1)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/a/w/e/r/d/h      */    if (MFD_SUCCESS != rc)        return rc;    rc = snmpNotifyFilterSubtree_check_index(rowreq_ctx);    if (MFD_SUCCESS != rc)        return SNMP_ERR_NOCREATION;    /*     * if individual parts look ok, check them as a whole     */    return        snmpNotifyFilterTable_validate_index(snmpNotifyFilterTable_if_ctx.                                             user_ctx, rowreq_ctx);}                               /* _snmpNotifyFilterTable_check_indexes *//*********************************************************************** * * SET processing * ***********************************************************************//*---------------------------------------------------------------------- * * SET: Syntax checks * *---------------------------------------------------------------------*//* * @internal * Check the syntax for a particular column */NETSNMP_STATIC_INLINE int_snmpNotifyFilterTable_check_column(snmpNotifyFilterTable_rowreq_ctx *                                    rowreq_ctx,                                    netsnmp_variable_list * var,                                    int column){    int             rc = SNMPERR_SUCCESS;    DEBUGMSGTL(("internal:snmpNotifyFilterTable:_snmpNotifyFilterTable_check_column", "called for %d\n", column));    netsnmp_assert(NULL != rowreq_ctx);    switch (column) {        /*         * (INDEX) snmpNotifyFilterSubtree(1)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/a/w/e/r/d/h          */    case COLUMN_SNMPNOTIFYFILTERSUBTREE:        rc = SNMP_ERR_NOTWRITABLE;      /* can not change index of active row */        break;        /*         * snmpNotifyFilterMask(2)/OCTETSTR/ASN_OCTET_STR/char(char)//L/A/W/e/R/D/h          */    case COLUMN_SNMPNOTIFYFILTERMASK:        rc = netsnmp_check_vb_type_and_max_size(var, ASN_OCTET_STR,                                                sizeof(rowreq_ctx->data.                                                       snmpNotifyFilterMask));        /*         * check defined range(s).          */        if ((SNMPERR_SUCCESS == rc)            && ((var->val_len < 0) || (var->val_len > 16))            ) {            rc = SNMP_ERR_WRONGLENGTH;        }        if (SNMPERR_SUCCESS != rc) {            DEBUGMSGTL(("snmpNotifyFilterTable:_snmpNotifyFilterTable_check_column:snmpNotifyFilterMask", "varbind validation failed (eg bad type or size)\n"));        } else {            rc = snmpNotifyFilterMask_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 snmpNotifyFilterMask_check_value\n",                         rc);                rc = SNMP_ERR_GENERR;            }        }        break;        /*         * snmpNotifyFilterType(3)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/D/h          */    case COLUMN_SNMPNOTIFYFILTERTYPE:        rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER,                                            sizeof(rowreq_ctx->data.                                                   snmpNotifyFilterType));        /*         * check that the value is one of defined enums          */        if ((SNMPERR_SUCCESS == rc)            && (*var->val.integer != SNMPNOTIFYFILTERTYPE_INCLUDED)            && (*var->val.integer != SNMPNOTIFYFILTERTYPE_EXCLUDED)            ) {            rc = SNMP_ERR_WRONGVALUE;        }        if (SNMPERR_SUCCESS != rc) {            DEBUGMSGTL(("snmpNotifyFilterTable:_snmpNotifyFilterTable_check_column:snmpNotifyFilterType", "varbind validation failed (eg bad type or size)\n"));        } else {            rc = snmpNotifyFilterType_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 snmpNotifyFilterType_check_value\n",

⌨️ 快捷键说明

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