📄 snmp1471.c
字号:
* The implementation is based on the stub output of mibcomp. * This explains the mixed notation: ptkp vs. pPkt and the use* of group_vbp in pppIpConfigEntryTest but not in pppIpConfigEntrySet.** RETURNS N/A*/void pppLinkConfigEntrySet ( OIDC_T lastmatch, /* leaf subindentifier */ int compc, /* should be 1 */ OIDC_T * compl, /* pointer to ifIndex */ SNMP_PKT_T * pktp, /* packet pointer */ VB_T * vbp /* varbind list head */ ) { PPP_LINK_CONFIG_ENTRY_DATA * pData; PPP_LINK_CONFIG_ENTRY_PRESET_DATA * pPresetData; VB_T * pGroupRepVarBind; PFW_STACK_STATUS stackStatus; OCTET_T * auxPOctet; ULONG auxULONG; /* we will use this auxiliary ULONG to translate to and * from external and internal ACCMap representations. */ int i; 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_LINK_CONFIG_ENTRY_PRESET_DATA *)(vbp->vb_priv); pData = &(pPresetData->referenceData); /* vbp->vb_priv points to a PPP_LINK_CONFIG_ENTRY_PRESET_DATA structure * with member a PPP_LINK_CONFIG_ENTRY_DATA structure */ /* 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 ((pfwStackStatusGet(pData->stackObj, &stackStatus) != OK) || (stackStatus != PFW_STACK_READY)) { error = TRUE; goto returnPoint; } for ( ; vbp; vbp = vbp->vb_link) { switch (vbp->vb_ml.ml_last_match) { case LEAF_pppLinkConfigInitialMRU: if ((*((pData->interface)-> pppLinkConfigInitialMRUSet)) (pData->state, (ULONG)VB_GET_INT32(vbp)) != OK) /* cast to ULONG */ { error = TRUE; goto returnPoint; } else { setproc_good(pktp, vbp); } break; case LEAF_pppLinkConfigReceiveACCMap: /* Ebuffer is a structure; EbufferUsed provided us with the * length of the used bytes in the buffer. Bytes beyond * the prescribed length are garbage. In our case we know * that we used exactly 4 bytes and we copy all those bytes * not as a string but byte by byte. */ auxPOctet = EBufferStart(VB_GET_STRING(vbp)); auxULONG = auxPOctet[0]; for (i=1; i<4; i++) { auxULONG <<= 8; auxULONG += auxPOctet[i]; } if ((*((pData->interface)-> pppLinkConfigReceiveACCMapSet)) (pData->state, auxULONG) != OK) { error = TRUE; goto returnPoint; } else { setproc_good(pktp, vbp); } break; case LEAF_pppLinkConfigTransmitACCMap: /* Ebuffer is a structure; EbufferUsed provided us with the * length of the used bytes in the buffer. Bytes beyond * the prescribed length are garbage. In our case we know * that we used exactly 4 bytes and we copy all those bytes * not as a string but byte by byte. */ auxPOctet = EBufferStart(VB_GET_STRING(vbp)); auxULONG = auxPOctet[0]; for (i=1; i<4; i++) { auxULONG <<= 8; auxULONG += auxPOctet[i]; } if ((*((pData->interface)-> pppLinkConfigTransmitACCMapSet)) (pData->state, auxULONG) != OK) { error = TRUE; goto returnPoint; } else { setproc_good(pktp, vbp); } break; case LEAF_pppLinkConfigMagicNumber: if ((*((pData->interface)-> pppLinkConfigMagicNumberSet)) (pData->state, (ULONG)VB_GET_INT32(vbp)) != OK) /* cast to ULONG */ { error = TRUE; goto returnPoint; } else { setproc_good(pktp, vbp); } break; case LEAF_pppLinkConfigFcsSize: if ((*((pData->interface)-> pppLinkConfigFcsSizeSet)) (pData->state, (ULONG)VB_GET_INT32(vbp)) != OK) /* cast to ULONG */ { error = TRUE; goto returnPoint; } else { setproc_good(pktp, vbp); } break; default: error = TRUE; 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 * pppIpConfigEntry instance. */ pGroupRepVarBind->undoproc = (UNDOPROC_T *) pppLinkConfigEntrySetUndo; 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); } } return; }/**************************************************************************** pppLinkConfigEntrySetUndo - Undo for pppLinkConfigEntry columnar objects** This function will be executed only ONCE for every group of varbinds * within the same SetPDU that refer to the same pppLinkConfigEntry instance. ** RETURNS N/A** NOMANUAL*/LOCAL void pppLinkConfigEntrySetUndo ( OIDC_T lastmatch, /* leaf subindentifier */ int compc, /* should be 1 */ OIDC_T * compl, /* pointer to ifIndex */ SNMP_PKT_T * pktp, /* packet pointer */ VB_T * vbp /* varbind list head */ ) { PPP_LINK_CONFIG_ENTRY_DATA * pData; PPP_LINK_CONFIG_ENTRY_PRESET_DATA * pPresetData; PFW_STACK_STATUS stackStatus; VB_T * pGroupRepVarBind; BOOL error; error = FALSE; /* 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_LINK_CONFIG_ENTRY_PRESET_DATA *)(vbp->vb_priv); pData = &(pPresetData->referenceData); /* vbp->vb_priv points to a PPP_IP_CONFIG_ENTRY_PRESET_DATA structure * with member a PPP_IPCP_ENTRY_DATA structure */ /* 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 of the corresponding set that we try to undo. */ if ((pfwStackStatusGet(pData->stackObj, &stackStatus) != OK) || (stackStatus != PFW_STACK_READY)) { error = TRUE; goto returnPoint; } for ( ; vbp; vbp = vbp->vb_link) { switch (vbp->vb_ml.ml_last_match) { case LEAF_pppLinkConfigInitialMRU: if ((*((pData->interface)-> pppLinkConfigInitialMRUSet)) (pData->state, pPresetData->previousPppLinkConfigInitialMRU) != OK) { error = TRUE; goto returnPoint; } else { undoproc_good(pktp, vbp); } break; case LEAF_pppLinkConfigReceiveACCMap: if ((*((pData->interface)-> pppLinkConfigReceiveACCMapSet)) (pData->state, pPresetData->previousPppLinkConfigReceiveACCMap) != OK) { error = TRUE; goto returnPoint; } else { undoproc_good(pktp, vbp); } break; case LEAF_pppLinkConfigTransmitACCMap: if ((*((pData->interface)-> pppLinkConfigTransmitACCMapSet)) (pData->state, pPresetData->previousPppLinkConfigTransmitACCMap) != OK) { error = TRUE; goto returnPoint; } else { undoproc_good(pktp, vbp); } break; case LEAF_pppLinkConfigMagicNumber: if ((*((pData->interface)-> pppLinkConfigMagicNumberSet)) (pData->state, pPresetData->previousPppLinkConfigMagicNumber) != OK) { error = TRUE; goto returnPoint; } else { undoproc_good(pktp, vbp); } break; case LEAF_pppLinkConfigFcsSize: if ((*((pData->interface)-> pppLinkConfigFcsSizeSet)) (pData->state, pPresetData->previousPppLinkConfigFcsSize) != OK) { error = TRUE; goto returnPoint; } else { undoproc_good(pktp, vbp); } break; default: error = TRUE; goto returnPoint; } } returnPoint: if (error) { /* we will mark ALL varbinds that share procedure and instance */ for (vbp = pGroupRepVarBind; vbp != NULL; vbp = vbp->vb_link) { undoproc_error (pktp, vbp, UNDO_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; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -