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

📄 expobjecttable.c

📁 snmp的源代码,已经在我的ubuntu下编译通过
💻 C
📖 第 1 页 / 共 3 页
字号:
        break;    case ACTION:        /*         * The variable has been stored in long_ret for         * you to use, and you have just been asked to do something with         * it.  Note that anything done here must be reversable in the UNDO case          */        tmpvar = StorageTmp->expObjectDiscontinuityIDType;        StorageTmp->expObjectDiscontinuityIDType = *((long *) var_val);        break;    case UNDO:        /*         * Back out any changes made in the ACTION case          */        StorageTmp->expObjectDiscontinuityIDType = tmpvar;        break;    case COMMIT:        /*         * Things are working well, so it's now safe to make the change         * permanently.  Make sure that anything done here can't fail!          */        break;    }    return SNMP_ERR_NOERROR;}intwrite_expObjectConditional(int action,                           u_char * var_val,                           u_char var_val_type,                           size_t var_val_len,                           u_char * statP, oid * name, size_t name_len){    static oid     *tmpvar;    struct expObjectTable_data *StorageTmp = NULL;    static size_t   tmplen;    size_t          newlen =        name_len - (sizeof(expObjectTable_variables_oid) / sizeof(oid) +                    3 - 1);    DEBUGMSGTL(("expObjectTable",                "write_expObjectConditional entering action=%d...  \n",                action));    if ((StorageTmp =         header_complex(expObjectTableStorage, NULL,                        &name[sizeof(expObjectTable_variables_oid) /                              sizeof(oid) + 3 - 1], &newlen, 1, NULL,                        NULL)) == NULL)        return SNMP_ERR_NOSUCHNAME;     /* remove if you support creation here */    switch (action) {    case RESERVE1:        if (var_val_type != ASN_OBJECT_ID) {            snmp_log(LOG_ERR,                     "write to expObjectConditional not ASN_OBJECT_ID\n");            return SNMP_ERR_WRONGTYPE;        }        if (StorageTmp->storageType != ST_NONVOLATILE)            return SNMP_ERR_NOTWRITABLE;        break;    case RESERVE2:        /*         * memory reseveration, final preparation...          */        break;    case FREE:        /*         * Release any resources that have been allocated          */        break;    case ACTION:        /*         * The variable has been stored in objid for         * you to use, and you have just been asked to do something with         * it.  Note that anything done here must be reversable in the UNDO case          */        tmpvar = StorageTmp->expObjectConditional;        tmplen = StorageTmp->expObjectConditionalLen;        memdup((u_char **) & StorageTmp->expObjectConditional, var_val,               var_val_len);        StorageTmp->expObjectConditionalLen = var_val_len / sizeof(oid);        break;    case UNDO:        /*         * Back out any changes made in the ACTION case          */        SNMP_FREE(StorageTmp->expObjectConditional);        StorageTmp->expObjectConditional = tmpvar;        StorageTmp->expObjectConditionalLen = tmplen;        break;    case COMMIT:        /*         * Things are working well, so it's now safe to make the change         * permanently.  Make sure that anything done here can't fail!          */        /*         * XXX: if the valueID has actually changed, shouldn't we dump any         * previous values, as these are from a different object?           */        SNMP_FREE(tmpvar);        break;    }    return SNMP_ERR_NOERROR;}intwrite_expObjectConditionalWildcard(int action,                                   u_char * var_val,                                   u_char var_val_type,                                   size_t var_val_len,                                   u_char * statP,                                   oid * name, size_t name_len){    static int      tmpvar;    struct expObjectTable_data *StorageTmp = NULL;    size_t          newlen =        name_len - (sizeof(expObjectTable_variables_oid) / sizeof(oid) +                    3 - 1);    DEBUGMSGTL(("expObjectTable",                "write_expObjectConditionalWildcard entering action=%d...  \n",                action));    if ((StorageTmp =         header_complex(expObjectTableStorage, NULL,                        &name[sizeof(expObjectTable_variables_oid) /                              sizeof(oid) + 3 - 1], &newlen, 1, NULL,                        NULL)) == NULL)        return SNMP_ERR_NOSUCHNAME;     /* remove if you support creation here */    switch (action) {    case RESERVE1:        if (var_val_type != ASN_INTEGER) {            snmp_log(LOG_ERR,                     "write to expObjectConditionalWildcard not ASN_INTEGER\n");            return SNMP_ERR_WRONGTYPE;        }        if (StorageTmp->storageType != ST_NONVOLATILE)            return SNMP_ERR_NOTWRITABLE;        break;    case RESERVE2:        /*         * memory reseveration, final preparation...          */        break;    case FREE:        /*         * Release any resources that have been allocated          */        break;    case ACTION:        /*         * The variable has been stored in long_ret for         * you to use, and you have just been asked to do something with         * it.  Note that anything done here must be reversable in the UNDO case          */        tmpvar = StorageTmp->expObjectConditionalWildcard;        StorageTmp->expObjectConditionalWildcard = *((long *) var_val);        break;    case UNDO:        /*         * Back out any changes made in the ACTION case          */        StorageTmp->expObjectConditionalWildcard = tmpvar;        break;    case COMMIT:        /*         * Things are working well, so it's now safe to make the change         * permanently.  Make sure that anything done here can't fail!          */        break;    }    return SNMP_ERR_NOERROR;}intwrite_expObjectEntryStatus(int action,                           u_char * var_val,                           u_char var_val_type,                           size_t var_val_len,                           u_char * statP, oid * name, size_t name_len){    struct expObjectTable_data *StorageTmp = NULL;    static struct expObjectTable_data *StorageNew, *StorageDel;    size_t          newlen =        name_len - (sizeof(expObjectTable_variables_oid) / sizeof(oid) +                    3 - 1);    static int      old_value;    int             set_value;    static netsnmp_variable_list *vars, *vp;    struct header_complex_index *hciptr;    StorageTmp =        header_complex(expObjectTableStorage, NULL,                       &name[sizeof(expObjectTable_variables_oid) /                             sizeof(oid) + 3 - 1], &newlen, 1, NULL, NULL);    if (var_val_type != ASN_INTEGER || var_val == NULL) {        snmp_log(LOG_ERR,                 "write to expObjectEntryStatus not ASN_INTEGER\n");        return SNMP_ERR_WRONGTYPE;    }    set_value = *((long *) var_val);    /*     * check legal range, and notReady is reserved for us, not a user      */    if (set_value < 1 || set_value > 6 || set_value == RS_NOTREADY)        return SNMP_ERR_INCONSISTENTVALUE;    switch (action) {    case RESERVE1:        /*         * stage one: test validity          */        if (StorageTmp == NULL) {            /*             * create the row now?              */            /*             * ditch illegal values now              */            if (set_value == RS_ACTIVE || set_value == RS_NOTINSERVICE)                return SNMP_ERR_INCONSISTENTVALUE;            /*             * destroying a non-existent row is actually legal              */            if (set_value == RS_DESTROY) {                return SNMP_ERR_NOERROR;            }            /*             * illegal creation values              */            if (set_value == RS_ACTIVE || set_value == RS_NOTINSERVICE) {                return SNMP_ERR_INCONSISTENTVALUE;            }        } else {            /*             * row exists.  Check for a valid state change              */            if (set_value == RS_CREATEANDGO                || set_value == RS_CREATEANDWAIT) {                /*                 * can't create a row that exists                  */                return SNMP_ERR_INCONSISTENTVALUE;            }            if (StorageTmp->expObjectEntryStatus == RS_ACTIVE &&                set_value != RS_DESTROY) {                /*                 * "Once made active an entry may not be modified except to                  * delete it."  XXX: doesn't this in fact apply to ALL                 * columns of the table and not just this one?                   */                return SNMP_ERR_INCONSISTENTVALUE;            }            if (StorageTmp->storageType != ST_NONVOLATILE)                return SNMP_ERR_NOTWRITABLE;        }        break;    case RESERVE2:        /*         * memory reseveration, final preparation...          */        if (StorageTmp == NULL) {            /*             * creation              */            vars = NULL;            snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, NULL, 0);  /* expExpressionOwner */            snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, NULL, 0);  /* expExpressionName */            snmp_varlist_add_variable(&vars, NULL, 0, ASN_UNSIGNED, NULL, 0);   /* expObjectIndex */            if (header_complex_parse_oid                (&                 (name                  [sizeof(expObjectTable_variables_oid) / sizeof(oid) +                   2]), newlen, vars) != SNMPERR_SUCCESS) {                /*                 * XXX: free, zero vars                  */                return SNMP_ERR_INCONSISTENTNAME;            }            vp = vars;            StorageNew = create_expObjectTable_data();            StorageNew->expExpressionOwner = malloc(vp->val_len + 1);            memcpy(StorageNew->expExpressionOwner, vp->val.string,                   vp->val_len);            StorageNew->expExpressionOwner[vp->val_len] = '\0';            StorageNew->expExpressionOwnerLen = vp->val_len;            vp = vp->next_variable;            StorageNew->expExpressionName = malloc(vp->val_len + 1);            memcpy(StorageNew->expExpressionName, vp->val.string,                   vp->val_len);            StorageNew->expExpressionName[vp->val_len] = '\0';            StorageNew->expExpressionNameLen = vp->val_len;            vp = vp->next_variable;            StorageNew->expObjectIndex = *vp->val.integer;            StorageNew->expObjectEntryStatus = set_value;        }        break;    case FREE:        /*         * XXX: free, zero vars          */        /*         * Release any resources that have been allocated          */        break;    case ACTION:        /*         * The variable has been stored in set_value for you to         * use, and you have just been asked to do something with         * it.  Note that anything done here must be reversable in         * the UNDO case          */        if (StorageTmp == NULL) {            /*             * row creation, so add it              */            if (StorageNew != NULL)                expObjectTable_add(StorageNew);            /*             * XXX: ack, and if it is NULL?              */        } else if (set_value != RS_DESTROY) {            /*             * set the flag?              */            old_value = StorageTmp->expObjectEntryStatus;            StorageTmp->expObjectEntryStatus = *((long *) var_val);        } else {            /*             * destroy...  extract it for now              */            hciptr =                header_complex_find_entry(expObjectTableStorage,                                          StorageTmp);            StorageDel =                header_complex_extract_entry(&expObjectTableStorage,                                             hciptr);        }        break;    case UNDO:        /*         * Back out any changes made in the ACTION case          */        if (StorageTmp == NULL) {            /*             * row creation, so remove it again              */            hciptr =                header_complex_find_entry(expObjectTableStorage,                                          StorageTmp);            StorageDel =                header_complex_extract_entry(&expObjectTableStorage,                                             hciptr);            /*             * XXX: free it              */        } else if (StorageDel != NULL) {            /*             * row deletion, so add it again              */            expObjectTable_add(StorageDel);        } else {            StorageTmp->expObjectEntryStatus = old_value;        }        break;    case COMMIT:        /*         * Things are working well, so it's now safe to make the change         * permanently.  Make sure that anything done here can't fail!          */        if (StorageDel != NULL) {            StorageDel = 0;            /*             * XXX: free it, its dead              */        } else {            if (StorageTmp                && StorageTmp->expObjectEntryStatus == RS_CREATEANDGO) {                StorageTmp->expObjectEntryStatus = RS_ACTIVE;            } else if (StorageTmp &&                       StorageTmp->expObjectEntryStatus ==                       RS_CREATEANDWAIT) {                StorageTmp->expObjectEntryStatus = RS_NOTINSERVICE;            }        }        break;    }    return SNMP_ERR_NOERROR;}

⌨️ 快捷键说明

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