📄 snmp1473.c
字号:
/* now check validity of the value fields of each varbind */ for (group_vbp = vbp; group_vbp != NULL; group_vbp = group_vbp->vb_link) { switch (group_vbp->vb_ml.ml_last_match) { case LEAF_pppIpConfigAdminStatus: switch (VB_GET_INT32(group_vbp)) { case VAL_pppIpConfigAdminStatus_open: case VAL_pppIpConfigAdminStatus_close: break; default: testproc_error(pktp, group_vbp, WRONG_VALUE); continue; } testproc_good(pktp, group_vbp); break; case LEAF_pppIpConfigCompression: switch (VB_GET_INT32(group_vbp)) { case VAL_pppIpConfigCompression_none: case VAL_pppIpConfigCompression_vj_tcp: break; default: testproc_error(pktp, group_vbp, WRONG_VALUE); continue; } testproc_good(pktp, group_vbp); break; default: testproc_error(pktp, group_vbp, GEN_ERR); return; } } return; }/**************************************************************************** pppIpConfigEntrySet - Set routine for pppIpconfigEntry columnar objects** 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 pppIpEntry) and the * leaf subindentifier. In our case the table pppIpTable is indexed by* only one index, the index being ifIndex which is not a leaf value.* 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.** A change of pppIpConfigCompression will be in effect only after the* next close-open cycle. Hence, the value of pppIpConfigCompression that* the SNMP agent would provide as a response to an SNMP manager's GetPDU* may not be the one currently in use.** Setting pppIpConfigAdminStatus to open(1) or close(2) via SNMP * may not result to the desired status even though the agent may report* to the manager status reflecting the last set.** In order to be able to set pppIpConfigCompression we should have already* configured compression parameters. One way to do this is using* pfwProfileSet before the stack is created.** 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 pppIpConfigEntrySet ( 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_IPCP_ENTRY_DATA * pData; PPP_IP_CONFIG_ENTRY_PRESET_DATA * pPresetData; VB_T * pGroupRepVarBind; PFW_STACK_STATUS stackStatus; 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_IP_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. */ 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_pppIpConfigAdminStatus: if ((*((pData->interface)-> ipcpConfigAdminStatusSet)) (pData->state, VB_GET_INT32(vbp)) != OK) { error = TRUE; goto returnPoint; } else { setproc_good(pktp, vbp); } break; case LEAF_pppIpConfigCompression: if ((*((pData->interface)-> ipcpConfigCompressionSet)) (pData->state, VB_GET_INT32(vbp)) != OK) { 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 *) pppIpConfigEntrySetUndo; 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; }/**************************************************************************** pppIpConfigEntrySetUndo - Undo routine for pppIpConfigEntry columnar objects** This function will be executed only ONCE for every group of varbinds * within the same SetPDU that refer to the same pppIpConfigEntry instance. ** RETURNS N/A** NOMANUAL*/LOCAL void pppIpConfigEntrySetUndo ( 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_IPCP_ENTRY_DATA * pData; PPP_IP_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_IP_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_pppIpConfigAdminStatus: if ((*((pData->interface)-> ipcpConfigAdminStatusSet)) (pData->state, pPresetData->previousPppIpConfigAdminStatus) != OK) { error = TRUE; goto returnPoint; } else { undoproc_good (pktp, vbp); } break; case LEAF_pppIpConfigCompression: if ((*((pData->interface)-> ipcpConfigCompressionSet)) (pData->state, pPresetData->previousPppIpConfigCompression) != 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); } } return; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -