📄 v3mt_tgt.c
字号:
* * snmpTargetParamsStorageType -- read-create * The storage type for this conceptual row. * * snmpTargetParamsRowStatus -- read-create * The status of this conceptual row. * * To create a row in this table, a manager must * set this object to either createAndGo(4) or * createAndWait(5). * * Until instances of all corresponding columns are * appropriately configured, the value of the * corresponding instance of the snmpTargetParamsRowStatus * column is 'notReady'. * * In particular, a newly created row cannot be made * active until the corresponding * snmpTargetParamsMPModel, * snmpTargetParamsSecurityModel, * snmpTargetParamsSecurityName, * and snmpTargetParamsSecurityLevel have all been set. * The following objects may not be modified while the * value of this object is active(1): * - snmpTargetParamsMPModel * - snmpTargetParamsSecurityModel * - snmpTargetParamsSecurityName * - snmpTargetParamsSecurityLevel * An attempt to set these objects while the value of * snmpTargetParamsRowStatus is active(1) will result in * an inconsistentValue error. *//* An internal routine to retrieve the values of the variables, used * by the method routines snmpTargetParamsEntry_get and * snmpTargetParamsEntry_next. */static int snmpTargetParamsEntry_get_value(OIDC_T lastmatch, SNMP_PKT_T *pktp, VB_T *vbp, SNMP_TARGET_PARAMS_T *tparam){switch(lastmatch) { case LEAF_snmpTargetParamsMPModel: getproc_got_int32(pktp, vbp, SNMP_Target_Params_Get_MP_Model(tparam)); break; case LEAF_snmpTargetParamsSecurityModel: getproc_got_int32(pktp, vbp, SNMP_Target_Params_Get_Sec_Model(tparam)); break; case LEAF_snmpTargetParamsSecurityName: getproc_got_string(pktp, vbp, SNMP_Target_Params_Get_Sec_Name_Len(tparam), SNMP_Target_Params_Get_Sec_Name(tparam), 0, VT_STRING); break; case LEAF_snmpTargetParamsSecurityLevel: /* Values: * noAuthNoPriv(1) = VAL_snmpTargetParamsSecurityLevel_noAuthNoPriv * authNoPriv(2) = VAL_snmpTargetParamsSecurityLevel_authNoPriv * authPriv(3) = VAL_snmpTargetParamsSecurityLevel_authPriv */ getproc_got_int32(pktp, vbp, SNMP_Target_Params_Get_Sec_Level(tparam)); break; case LEAF_snmpTargetParamsStorageType: /* Values: * other(1) = VAL_snmpTargetParamsStorageType_other * volatile(2) = VAL_snmpTargetParamsStorageType_volatile * nonVolatile(3) = VAL_snmpTargetParamsStorageType_nonVolatile * permanent(4) = VAL_snmpTargetParamsStorageType_permanent * readOnly(5) = VAL_snmpTargetParamsStorageType_readOnly */ getproc_got_int32(pktp, vbp, SNMP_Target_Params_Get_Storage(tparam)); break; case LEAF_snmpTargetParamsRowStatus: /* Values: * active(1) = VAL_snmpTargetParamsRowStatus_active * notInService(2) = VAL_snmpTargetParamsRowStatus_notInService * notReady(3) = VAL_snmpTargetParamsRowStatus_notReady * createAndGo(4) = VAL_snmpTargetParamsRowStatus_createAndGo * createAndWait(5) = VAL_snmpTargetParamsRowStatus_createAndWait * destroy(6) = VAL_snmpTargetParamsRowStatus_destroy */ getproc_got_int32(pktp, vbp, SNMP_Target_Params_Get_Status(tparam)); break; default: return GEN_ERR; }return NO_ERROR;}void snmpTargetParamsEntry_get(OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){SNMP_TARGET_PARAMS_T *tparam = 0;bits8_t name[ETC_TARGET_PARAMS_MAX];ALENGTH_T namelen = ETC_TARGET_PARAMS_MAX;int error;/* find all the varbinds that share the same getproc and instance */group_by_getproc_and_instance(pktp, vbp, tcount, tlist);/* use the instance (tcount and tlist) to look up the entry in the * table. */if ((oid_to_string(tcount, tlist, &namelen, name, 1) == 0) && (namelen != 0)) tparam = SNMP_Target_Params_Lookup(name, namelen);if (tparam == 0) { 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) { if ((error = snmpTargetParamsEntry_get_value(vbp->vb_ml.ml_last_match, pktp, vbp, tparam)) != NO_ERROR) getproc_error(pktp, vbp, error); } }}void snmpTargetParamsEntry_next(OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){SNMP_TARGET_PARAMS_T *tparm;OIDC_T best_inst[ETC_TARGET_PARAMS_MAX];int error;/* find all the varbinds that share the same getproc and instance */group_by_getproc_and_instance(pktp, vbp, tcount, tlist);tparm = SNMP_Target_Params_Next(tcount, tlist);if ((tparm) && ((error = string_to_oid(SNMP_Target_Params_Get_Name_Len(tparm), SNMP_Target_Params_Get_Name(tparm), ETC_TARGET_PARAMS_MAX, best_inst, 1)) == 0)) { for ( ; vbp ; vbp = vbp->vb_link ) { if ((error = snmpTargetParamsEntry_get_value(vbp->vb_ml.ml_last_match, pktp, vbp, tparm)) == NO_ERROR) nextproc_next_instance(pktp, vbp, SNMP_Target_Params_Get_Name_Len(tparm), best_inst); else nextproc_error(pktp, vbp, error); } }else /* there's no more in this table */ for ( ; vbp ; vbp = vbp->vb_link ) nextproc_no_next(pktp, vbp);}/****************************************************************************NAME: tparmtable_destroy_cleanupPURPOSE: Cleanup after a target_param test (delete) succeeded but some other test failed. We merely call the DESTROY_BACKOUT macro to allow the customer to restore any changed state. Expects the pointer to point to a VB_TPARAMETERS: ptr_t A pointer to the vb that points to the target_param that we were going to delete, cast as a ptr_tRETURNS: Nothing****************************************************************************/static void tparamtable_destroy_cleanup(ptr_t tparamptr){SNMP_V3_TPARAM_DESTROY_BACKOUT(((VB_T *)tparamptr)->vb_priv, 0);}/****************************************************************************NAME: tparamtable_create_cleanupPURPOSE: Cleanup after a target_param create test succeeded but some other test failed. As this is a create the state pointer points to a structure that is installed, we need to deinstall it, call the backout routine, and cleanup the state. Expects the pointer to point to a VB_TPARAMETERS: ptr_t A pointer to the vb that points to the target_param that we were going to create, cast as a ptr_tRETURNS: Nothing****************************************************************************/static void tparamtable_create_cleanup(ptr_t tparamptr){SNMP_TARGET_PARAMS_T *tparam;tparam = (SNMP_TARGET_PARAMS_T *)(((VB_T *)tparamptr)->vb_priv);SNMP_V3_TPARAM_CREATE_BACKOUT(0, tparam);SNMP_Target_Params_Deinstall(tparam);SNMP_Target_Params_Destroy(tparam);}/****************************************************************************NAME: tparamtable_update_cleanupPURPOSE: Cleanup after a target_param update test succeeded but some other test failed. As this is an update the state pointer points to a structure that isn't installed. The next pointer of that structure points to the installed copy. We call the backout routine and cleanup the state.PARAMETERS: ptr_t A pointer to the vb that points to the target_param that contained the update information, cast as a ptr_tRETURNS: Nothing****************************************************************************/static void tparamtable_update_cleanup(ptr_t tparamptr){SNMP_TARGET_PARAMS_T *tparam;tparam = (SNMP_TARGET_PARAMS_T *)(((VB_T *)tparamptr)->vb_priv);SNMP_V3_TPARAM_UPDATE_BACKOUT(tparam->next, tparam);SNMP_Target_Params_Destroy(tparam);}/****************************************************************************NAME: tparamtable_destroy_undoPURPOSE: This routine attempts to undo a previous destroy set. It expects the old information to be pointed to by vb_priv and tries to reinstall it. If we can't reinstall the target_param we leave the cleanup routine alone in order to get the FINISHED macro to run.PARAMETERS: OIDC_T Last component of the object id leading to the leaf node in the MIB. This is usually the identifier for the particular attribute in the table. int Number of components in the unused part of the object identifier OIDC_T * Unused part of the object identifier SNMP_PKT_T * SNMP packet currently being processsed. VB_T * Variable being processed.RETURNS: void****************************************************************************//*ARGSUSED*/static void tparamtable_destroy_undo(OIDC_T last_match, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){SNMP_TARGET_PARAMS_T *tparam;bits8_t name[ETC_TARGET_PARAMS_MAX];ALENGTH_T name_len = ETC_TARGET_PARAMS_MAX;/* assume things will go well and mark the vbp as done */undoproc_good(pktp, vbp);/* get the name info, no need to check as it's already been validated */oid_to_string(tcount, tlist, &name_len, name, 1);/* find the state block we saved and then reset the vb_priv info so we don't have any accidents later */tparam = (SNMP_TARGET_PARAMS_T *)vbp->vb_priv;vbp->vb_priv = 0;if (SNMP_Target_Params_Install(tparam, name, name_len) == 0) {#if defined(SNMP_V3_TPARAM_DESTROY_UNDO) if (SNMP_V3_TPARAM_DESTROY_UNDO(pktp, vbp, 0, tparam) == 0) { vbp->vb_free_priv = 0; return; } else SNMP_Target_Params_Deinstall(tparam);#else vbp->vb_free_priv = 0; return;#endif }SNMP_Target_Params_Destroy(tparam);undoproc_error(pktp, vbp, UNDO_FAILED);return;}/****************************************************************************NAME: tparamtable_create_undoPURPOSE: This routine attempts to undo a previous create set. It expects the new information to be pointed to by vb_priv and tries to deinstall and destroy the entry.PARAMETERS: OIDC_T Last component of the object id leading to the leaf node in the MIB. This is usually the identifier for the particular attribute in the table. int Number of components in the unused part of the object identifier OIDC_T * Unused part of the object identifier SNMP_PKT_T * SNMP packet currently being processsed. VB_T * Variable being processed.RETURNS: void****************************************************************************//*ARGSUSED*/static void tparamtable_create_undo(OIDC_T last_match, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){SNMP_TARGET_PARAMS_T *tparam;/* assume things will go well */undoproc_good(pktp, vbp);/* find the state block we saved and then reset the vb_priv info so we don't have any accidents later */tparam = (SNMP_TARGET_PARAMS_T *)vbp->vb_priv;vbp->vb_priv = 0;vbp->vb_free_priv = 0;#if defined(SNMP_V3_TPARAM_CREATE_UNDO)if (SNMP_V3_TPARAM_CREATE_UNDO(pktp, vbp, tparam, 0)) { undoproc_error(pktp, vbp, UNDO_FAILED); return; }#endifSNMP_Target_Params_Deinstall(tparam);SNMP_Target_Params_Destroy(tparam);return;}/****************************************************************************NAME: tparamtable_update_undoPURPOSE: This routine attempts to undo a previous update set. It expects the struct pointed to by vb_priv to contain the old information and a pointer to the new (installed) struct.PARAMETERS: OIDC_T Last component of the object id leading to the leaf node in the MIB. This is usually the identifier for the particular attribute in the table. int Number of components in the unused part of the object identifier
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -