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

📄 snmp1472.c

📁 这是全套的PPP协议的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
            {            case LEAF_pppSecuritySecretsLink:                value = VB_GET_INT32(group_vbp);                /* These are the ranges from the MIB.                   * Modify if your implementation differs.                  */                if  ((!((value >= MIN_pppSecuritySecretsLink) &&                     (value <= MAX_pppSecuritySecretsLink)))  ||                     (value != compl[0]))                    {                    testproc_error(pktp, group_vbp, WRONG_VALUE);                    return;                    }                else                    {                    pPresetData->newPppSecuritySecretsLink = value;                    testproc_good(pktp, group_vbp);                    }                break;             case LEAF_pppSecuritySecretsIdIndex:                value = VB_GET_INT32(group_vbp);                /* These are the ranges from the MIB.                   * Modify if your implementation differs.                  */                if  ((!((value >= MIN_pppSecuritySecretsIdIndex) &&                     (value <= MAX_pppSecuritySecretsIdIndex)))  ||                     (value != compl[1]))                    {                    testproc_error(pktp, group_vbp, WRONG_VALUE);                    return;                    }                else                    {                    pPresetData->newPppSecuritySecretsIdIndex = value;                    testproc_good(pktp, group_vbp);                    }                break;            case LEAF_pppSecuritySecretsDirection:                /* modify this switch to give an error for                  * values your implementation doesn't allow                  */                pPresetData->pNewTransferDirection =                &(pPresetData->newPppSecuritySecretsDirection);                switch (VB_GET_INT32(group_vbp))                     {                    case VAL_pppSecuritySecretsDirection_local_to_remote:                        pPresetData->newPppSecuritySecretsDirection =                         PPP_SECURITY_SECRETS_DIRECTION_LOCAL_TO_REMOTE;                        break;                    case VAL_pppSecuritySecretsDirection_remote_to_local:                        pPresetData->newPppSecuritySecretsDirection =                         PPP_SECURITY_SECRETS_DIRECTION_LOCAL_TO_REMOTE;                        break;                    default:                        testproc_error(pktp, group_vbp, WRONG_VALUE);                        return;                    }                testproc_good(pktp, group_vbp);                break;            case LEAF_pppSecuritySecretsProtocol:                pPresetData->pNewTransferProtocol =                &(pPresetData->newPppSecuritySecretsProtocol);                pOID = (VB_GET_OBJECT_ID(group_vbp))->component_list;                if  (11 != (VB_GET_OBJECT_ID(group_vbp))->num_components)                    {                    testproc_error(pktp, group_vbp, WRONG_VALUE);                    return;                    }                else if ((pOID[ 0] !=  1) ||                         (pOID[ 1] !=  3) ||                         (pOID[ 2] !=  6) ||                         (pOID[ 3] !=  1) ||                         (pOID[ 4] !=  2) ||                         (pOID[ 5] !=  1) ||                         (pOID[ 6] != 10) ||                         (pOID[ 7] != 23) ||                         (pOID[ 8] !=  2) ||                         (pOID[ 9] !=  1))                    {                    testproc_error(pktp, group_vbp, WRONG_VALUE);                    return;                    }                else if (1 == pOID[10])                    {                    pPresetData->newPppSecuritySecretsProtocol =                     PPP_SECURITY_PAP_PROTOCOL;                    testproc_good(pktp, group_vbp);                    }                else if (2 == pOID[10])                    {                    pPresetData->newPppSecuritySecretsProtocol =                     PPP_SECURITY_CHAP_MD5_PROTOCOL;                    testproc_good(pktp, group_vbp);                    }                else                    {                    testproc_error(pktp, group_vbp, WRONG_VALUE);                    return;                    }                break;            case LEAF_pppSecuritySecretsIdentity:                length = EBufferUsed(VB_GET_STRING(group_vbp));                   /* !!! These are the lengths from the MIB.                      * Modify if your implementation differs.                     */                if (!(/*(length >= MINSIZE_pppSecuritySecretsIdentity) &&*/                    (length <= MAXSIZE_pppSecuritySecretsIdentity)))                    {                    testproc_error(pktp, group_vbp, WRONG_VALUE);                    }                else                    {                    pPresetData->pNewTransferIdentity =                    pPresetData->newPppSecuritySecretsIdentity;                    strncpy(pPresetData->newPppSecuritySecretsIdentity,                            (char *)(EBufferStart(VB_GET_STRING(group_vbp))),                            length);                    pPresetData->newPppSecuritySecretsIdentity[length] = '\0';                    testproc_good(pktp, group_vbp);                    }                break;            case LEAF_pppSecuritySecretsSecret:                length = EBufferUsed(VB_GET_STRING(group_vbp));                   /* !!! These are the lengths from the MIB.                      * Modify if your implementation differs.                     */                if (!(/*(length >= MINSIZE_pppSecuritySecretsSecret) &&*/                    (length <= MAXSIZE_pppSecuritySecretsSecret)))                     {                    testproc_error(pktp, group_vbp, WRONG_VALUE);                    }                else                    {                    pPresetData->pNewTransferSecret =                    pPresetData->newPppSecuritySecretsSecret;                    strncpy(pPresetData->newPppSecuritySecretsSecret,                            (char *)(EBufferStart(VB_GET_STRING(group_vbp))),                            length);                    pPresetData->newPppSecuritySecretsSecret[length] = '\0';                    testproc_good(pktp, group_vbp);                    }                break;            case LEAF_pppSecuritySecretsStatus:                /* modify this switch to give an error for                  * values your implementation doesn't allow                  */                switch (VB_GET_INT32(group_vbp))                     {                    case VAL_pppSecuritySecretsStatus_invalid:                        pPresetData->newPppSecuritySecretsStatus =                         PPP_SECURITY_SECRETS_STATUS_INVALID;                        break;                    case VAL_pppSecuritySecretsStatus_valid:                        pPresetData->newPppSecuritySecretsStatus =                         PPP_SECURITY_SECRETS_STATUS_VALID;                        break;                    default:                        testproc_error(pktp, group_vbp, WRONG_VALUE);                        return;                    }                testproc_good(pktp, group_vbp);                break;            default:                testproc_error(pktp, group_vbp, GEN_ERR);                return;            }        }    return;    }/**************************************************************************** pppSecuritySecretsEntrySet - Set routine for pppSecuritysecretsEntry ** A columnar object instance is identified by an instance identifier.* An instance identifier consists of the object identifier and the sequence of* index values. The object identifier consists of the object identifier* of the tabular entry (in this case the OID for pppSecuritySecretsEntry) and  * the leaf subindentifier.  In our case the table pppSecuritySecretsTable* is indexed by pppSecuritySecretsLink and pppSecuritySecretsIdIndex.* OIDC stands for Object Identifier Component. Compc stands for component* count and it counts the number of components that comprise the index* values part of the instance identifier. Compl stands for components left * and it is the index values array.** Our implementation requires that each link has an pppSecuritySecretsEntry* with preference equal to zero. To support this implicit promotion is used* and subsequently the undo operation is not supported.** RETURNS N/A*/void pppSecuritySecretsEntrySet    (    OIDC_T          lastmatch,  /* leaf subindentifier                 */    int             compc,      /* number of instance OID_T components */    OIDC_T *        compl,      /* pointer to OID_T variable array     */    SNMP_PKT_T *    pktp,       /* packet pointer                      */    VB_T *          vbp         /* varbind list head                   */    )    {    PPP_SECURITY_SECRETS_ENTRY_PRESET_DATA * pPresetData;    VB_T * pGroupRepVarBind;    BOOL error;        error = FALSE;       /* Part of the input for the set operation is pointed by vbp->vb_priv;     * It is expected (and we have implemented it above) that in testproc     * we entered the same pointer in all varbinds of the same group.      */    pPresetData = (PPP_SECURITY_SECRETS_ENTRY_PRESET_DATA *)(vbp->vb_priv);    /* It is our understanding that the Group Representative would     * be the same for both calls of test and set and it would be the head     * of the list of varbinds sharing procedure and instance and no clean     * up will occur (i.e. vb_free_priv will not be called) before or while     * undoproc is executed. BUT following defensive programming guidelines     * we save the group representative pointer and we make certain that     * we always start from the head of the list.     */    pGroupRepVarBind = vbp = pPresetData->pGroupHead;        /* snmpdGroupByGetprocAndInstance(pktp, vbp, compc, compl) was executed     * in testproc.     */    if  (m2pppSecretsEntryAgentSet(pPresetData->newPppSecuritySecretsLink,                                   pPresetData->newPppSecuritySecretsIdIndex,                                   pPresetData->pNewTransferDirection,                                   pPresetData->pNewTransferProtocol,                                   pPresetData->pNewTransferIdentity,                                   pPresetData->pNewTransferSecret,                                   pPresetData->newPppSecuritySecretsStatus)         != OK)        {        error = TRUE;        goto returnPoint;        }        else        {        error = FALSE;        goto returnPoint;        }        returnPoint:    /* we place the function pointer necessary to undo the set only on one     * member of the group of the same SetPDU varbinds that share the same     * pppSecuritySecretsEntry instance.      */    pGroupRepVarBind->undoproc = (UNDOPROC_T *) pppSecuritySecretsEntrySetUndo;    if  (error)        {        /* we will mark ALL varbinds that share procedure and instance */        for (vbp = pGroupRepVarBind;              vbp != NULL;              vbp = vbp->vb_link)             {            setproc_error(pktp, vbp, COMMIT_FAILED);            }        }    else        {        /* we will mark ALL varbinds that share procedure and instance */        for (vbp = pGroupRepVarBind;              vbp != NULL;              vbp = vbp->vb_link)             {            setproc_good(pktp, vbp);            }        }    return;    }/**************************************************************************** pppSecuritySecretsEntrySetUndo - Undo for pppSecuritySecretsEntry ** This function will be executed only ONCE for every group of varbinds * within the same SetPDU that refer to the same pppLinkSecretsEntry instance. ** We support implicit deletion of entries in order to maintain database* integrity that requires uniqueness of both SNMP and internal keys.* Due to complexity we do not support pppSecuritySecretsEntrySetUndo.** However, we have designed pppSecuritySecretsEntrySetUndo including* the required core Security Secrets database code changes and* we anticipate its implementation in the near future.** RETURNS N/A*/LOCAL void pppSecuritySecretsEntrySetUndo    (    OIDC_T          lastmatch,     int             compc,    OIDC_T *        compl,    SNMP_PKT_T *    pktp,     VB_T *          vbp       )    {    PPP_SECURITY_SECRETS_ENTRY_PRESET_DATA * pPresetData;    VB_T * pGroupRepVarBind;    /* Part of the input for the undo operation is pointed by vbp->vb_priv;     * It is expected (and we have implemented it above) that in testproc     * we entered the same pointer in all varbinds of the same group.      */    pPresetData = (PPP_SECURITY_SECRETS_ENTRY_PRESET_DATA *)(vbp->vb_priv);    /* It is our understanding that the Group Representative would     * be the same for both calls of test and set and it would be the head     * of the list of varbinds sharing procedure and instance and no clean     * up will occur (i.e. vb_free_priv will not be called) before or while     * undoproc is executed. BUT following defensive programming guidelines     * we save the group representative pointer and we make certain that     * we always start from the head of the list.     */    pGroupRepVarBind = vbp = pPresetData->pGroupHead;        for (vbp = pGroupRepVarBind;              vbp != NULL;              vbp = vbp->vb_link)             {            undoproc_error(pktp, vbp, UNDO_FAILED);            }    return;    }

⌨️ 快捷键说明

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