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

📄 snmp1472.c

📁 这是全套的PPP协议的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
        }    }/**************************************************************************** pppSecurityConfigEntryGet - Get routine for pppSecurityConfigTable** 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 pppSecurityConfigEntry) and * the leaf subindentifier. In our case the table pppSecurityConfigTable* is indexed by pppSecurityConfigLink and pppSecurityConfigPreference.* 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.** RETURNS N/A*/void pppSecurityConfigEntryGet    (    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_CONFIG_ENTRY_DATA data;    /* find all the varbinds that share the same getproc and instance */    snmpdGroupByGetprocAndInstance(pktp, vbp, compc, compl);    if  ((compc < 1) || (compc > 2) || (NULL == compl))        {        for ( ; vbp; vbp = vbp->vb_link)            {            getproc_nosuchins(pktp, vbp);            }        return;        }    if  (m2pppSecurityConfigEntryLookup(compc,                                         /* from unsigned long * to UINT32 *                                         * since OIDC_T is bits32_t which                                         * is unsigned long                                         */                                         (UINT32 *) compl,                                         &data,                                         M2_PPP_ENTRY_EXACT_MATCH)          /* use the instance (compc and compl) to look up the entry */         != OK)         {        for ( ; vbp; vbp = vbp->vb_link)            {            getproc_nosuchins(pktp, vbp);            }        }    else         {        /* retrieve all the values from the same data structure */        for ( ; vbp; vbp = vbp->vb_link)             {            pppSecurityConfigEntryInfoGet(vbp->vb_ml.ml_last_match,                                           pktp,                                           vbp,                                           &data);            }        }    return;    }/**************************************************************************** pppSecurityConfigEntryNext - GetNext routine for pppSecurityConfigTable** 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 pppSecurityConfigEntry) and  * the leaf subindentifier.  In our case the table pppSecurityConfigTable* is indexed by pppSecurityConfigLink and pppSecurityConfigPreference.* 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.** RETURNS N/A*/void pppSecurityConfigEntryNext    (    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_CONFIG_ENTRY_DATA data;    OIDC_T nextInstance[2];    /* find all the varbinds that share the same getproc and instance */    snmpdGroupByGetprocAndInstance(pktp, vbp, compc, compl);    if  (m2pppSecurityConfigEntryLookup(compc,                                         /* from unsigned long * to UINT32 *                                         * since OIDC_T is bits32_t which                                         * is unsigned long                                         */                                         (UINT32 *) compl,                                         &data,                                         M2_PPP_ENTRY_NEXT_MATCH)          /* use the instance (compc and compl) to look up the entry */         != OK)         {        for ( ; vbp; vbp = vbp->vb_link)            {            nextproc_no_next(pktp, vbp);            }        }    else         {        /* retrieve all the values from the same data structure */        for ( ; vbp; vbp = vbp->vb_link)             {            pppSecurityConfigEntryInfoGet(vbp->vb_ml.ml_last_match,                                           pktp,                                           vbp,                                           &data);            nextInstance[0] = (OIDC_T)data.link;            nextInstance[1] = (OIDC_T)data.preference;            nextproc_next_instance(pktp,                                    vbp,                                    pppSecurityConfigEntry_INSTANCE_LEN,                                    nextInstance);            nextproc_good(pktp, vbp);            }        }    return;    }/**************************************************************************** pppSecurityConfigEntryTest - Test routine for pppSecurityConfigEntry** RETURNS: N/A*/void pppSecurityConfigEntryTest    (    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                   */    )    {    VB_T * group_vbp;                       /* introduced by mibcomp    */    VB_T * pGroupRepVarBind;                /* introduced by programmer */    PPP_SECURITY_CONFIG_ENTRY_PRESET_DATA * pPresetData;    INT_32_T value;    OIDC_T * pOID;    BOOL entryDoesNotExist = TRUE;    pGroupRepVarBind = vbp;    /* find all the varbinds that share the same getproc and instance */    snmpdGroupByGetprocAndInstance(pktp, vbp, compc, compl);    pPresetData = (PPP_SECURITY_CONFIG_ENTRY_PRESET_DATA *)                  snmpdMemoryAlloc                  (sizeof(PPP_SECURITY_CONFIG_ENTRY_PRESET_DATA));    pPresetData->pGroupHead = pGroupRepVarBind = vbp;    if  ((compc < 1) || (compc > 2) || (NULL == compl))        {        for (group_vbp = pGroupRepVarBind;              group_vbp != NULL;              group_vbp = group_vbp->vb_link)             {            testproc_error(pktp, group_vbp, NO_SUCH_NAME);;            }        return;        }    if  (m2pppSecurityConfigEntryLookup(compc,                                          /* from unsigned long * to UINT32 *                                          * since OIDC_T is bits32_t which                                          * is unsigned long                                          */                                          (UINT32 *) compl,                                          &(pPresetData->referenceData),                                          M2_PPP_ENTRY_EXACT_MATCH)          /* use the instance (compc and compl) to look up the entry */         != OK)        {        for (group_vbp = pGroupRepVarBind;              group_vbp != NULL;              group_vbp = group_vbp->vb_link)             {            testproc_error(pktp, group_vbp, NO_SUCH_NAME);            }        return;        }    else         {        /* m2pppSecurityConfigEntryLookup will return OK if the link is valid          * and it will populate link, preference, protocol and status if the         * (link, preference) indexed entry does exist. If the link is valid         * but the (link, preference) entry does not exist it will only          * mark the status as PPP_SECURITY_SECRETS_STATUS_INVALID. In that         * case we should populate link, preference, using implicit information         * and mark protocol as PPP_SECURITY_UNDEFINED_PROTOCOL.         */        if  (PPP_SECURITY_SECRETS_STATUS_INVALID ==              (pPresetData->referenceData).status)            {            entryDoesNotExist = TRUE;            (pPresetData->referenceData).link = (UINT32)compl[0];            (pPresetData->referenceData).preference = (UINT32)compl[1];            (pPresetData->referenceData).protocol =             PPP_SECURITY_UNDEFINED_PROTOCOL;            (pPresetData->referenceData).status =             PPP_SECURITY_SECRETS_STATUS_VALID;            }        else            {            entryDoesNotExist = FALSE;            }        pPresetData->previousPppSecurityConfigLink =        (pPresetData->referenceData).link;        pPresetData->previousPppSecurityConfigPreference =        (pPresetData->referenceData).preference;        pPresetData->previousPppSecurityConfigProtocol =        (pPresetData->referenceData).protocol;        pPresetData->previousPppSecurityConfigStatus =        (pPresetData->referenceData).status;        /* assign to all relative varbinds the same private data */        for (group_vbp = pGroupRepVarBind;              group_vbp != NULL;              group_vbp = group_vbp->vb_link)            {            group_vbp->vb_priv = (PTR_T) pPresetData;            }        /* but only to one assign memory management */        pGroupRepVarBind->vb_free_priv = (VBPRIVPROC_T *) snmpVbPrivFree;        }    /* now check validity of the value fields of each varbind */    for (group_vbp = pGroupRepVarBind;          group_vbp != NULL;          group_vbp = group_vbp->vb_link)         {        switch (group_vbp->vb_ml.ml_last_match)             {            case LEAF_pppSecurityConfigLink:                value = VB_GET_INT32(group_vbp);                /* These are the ranges from the MIB.                   * Modify if your implementation differs.                  */                if  ((!((value >= MIN_pppSecurityConfigLink) &&                     (value <= MAX_pppSecurityConfigLink)))  ||                     (value != compl[0]))                    {                    testproc_error(pktp, group_vbp, WRONG_VALUE);                    return;                    }                else                    {                    (pPresetData->referenceData).link = value;                    testproc_good(pktp, group_vbp);                    }                break;            case LEAF_pppSecurityConfigPreference:                value = VB_GET_INT32(group_vbp);                /* These are the ranges from the MIB.                   * Modify if your implementation differs.                  */                if  ((!((value >= MIN_pppSecurityConfigPreference) &&                     (value <= MAX_pppSecurityConfigPreference))) ||                     (value != compl[1]))                     {                    testproc_error(pktp, group_vbp, WRONG_VALUE);                    return;                    }                else                    {                    (pPresetData->referenceData).preference = value;                    testproc_good(pktp, group_vbp);                    }                break;            case LEAF_pppSecurityConfigProtocol:                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->referenceData).protocol =                     PPP_SECURITY_PAP_PROTOCOL;                    testproc_good(pktp, group_vbp);                    }                else if (2 == pOID[10])                    {                    (pPresetData->referenceData).protocol =                     PPP_SECURITY_CHAP_MD5_PROTOCOL;                    testproc_good(pktp, group_vbp);                    }                else                    {                    testproc_error(pktp, group_vbp, WRONG_VALUE);                    return;                    }                break;            case LEAF_pppSecurityConfigStatus:                /* modify this switch to give an error for                  * values your implementation doesn't allow                  */

⌨️ 快捷键说明

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