📄 v3mt_nfy.c
字号:
} break; default: testproc_error(pktp, tvbp, GEN_ERR); return; } }/* The values are ok */if (SNMP_Notify_Get_Status(&tempnotify) == ETC_RS_DESTROY) { if (notify != 0) { ptret = SNMP_V3_NOTIFY_DESTROY_TEST(pktp, vbp, notify, 0); if (ptret != NO_ERROR) { testproc_error(pktp, vbp, ptret); } else { vbp->vb_priv = (PTR_T)notify; vbp->vb_free_priv = notifytable_destroy_cleanup; } } else { /* We have a destroy request, but no target_addr so we don't have to do anything during the set and, if necessary, the undo phases so we mark vbp as set and undone */ setproc_all_bits(pktp, vbp); } return; }/* check on status */if ((notify == 0) || (SNMP_Notify_Get_Status(notify) == ETC_RS_NREADY)) { if (SNMP_Notify_Get_Status(&tempnotify) == ETC_RS_NREADY) SNMP_Notify_Set_Status(&tempnotify, ETC_RS_NIS); }/* See if anything actually changed, if it didn't we can mark the vbp as done and not have to do any more work. */if (notify) { if ((SNMP_Notify_Get_Tag(notify) != SNMP_Notify_Get_Tag(&tempnotify)) && ((SNMP_Notify_Get_Tag_Len(notify) != SNMP_Notify_Get_Tag_Len(&tempnotify)) || MEMCMP_NULLOK(SNMP_Notify_Get_Tag(notify), SNMP_Notify_Get_Tag(&tempnotify), SNMP_Notify_Get_Tag_Len(notify)))) { tag_chg = 1; } if ((tag_chg == 0) && (SNMP_Notify_Get_Type(notify) == SNMP_Notify_Get_Type(&tempnotify)) && (SNMP_Notify_Get_Storage(notify) == SNMP_Notify_Get_Storage(&tempnotify)) && (SNMP_Notify_Get_Status(notify) == SNMP_Notify_Get_Status(&tempnotify))) { setproc_all_bits(pktp, vbp); return; } }else tag_chg = 1;/* Because of how we do the backout stuff we always allocate a new target_addr and set it up */newnotify = SNMP_Notify_Create();if (newnotify == 0) { testproc_error(pktp, vbp, RESOURCE_UNAVAILABLE); return; }SNMP_Notify_Set_Flags(newnotify, SNMP_Notify_Get_Flags(&tempnotify));SNMP_Notify_Set_Status(newnotify, SNMP_Notify_Get_Status(&tempnotify));SNMP_Notify_Set_Storage(newnotify, SNMP_Notify_Get_Storage(&tempnotify));SNMP_Notify_Set_Type(newnotify, SNMP_Notify_Get_Type(&tempnotify));if (tag_chg) { if (EBufferClone(&tempnotify.notify_tag, &newnotify->notify_tag) != 0) { SNMP_Notify_Destroy(newnotify); testproc_error(pktp, vbp, RESOURCE_UNAVAILABLE); return; } }else{ EBufferPreLoad(BFL_IS_STATIC, &newnotify->notify_tag, SNMP_Notify_Get_Tag(notify), SNMP_Notify_Get_Tag_Len(notify)); }/* if we are creating a new target_addr we need to install it and run the create test, if we are updating an old target_addr we just run the update test */if (notify == 0) { if (SNMP_Notify_Install(newnotify, name, name_len)) { SNMP_Notify_Destroy(newnotify); testproc_error(pktp, vbp, RESOURCE_UNAVAILABLE); return; } ptret = SNMP_V3_NOTIFY_CREATE_TEST(pktp, vbp, 0, newnotify); if (ptret != NO_ERROR) { SNMP_Notify_Deinstall(newnotify); SNMP_Notify_Destroy(newnotify); testproc_error(pktp, vbp, ptret); return; } vbp->vb_free_priv = notifytable_create_cleanup; }else { ptret = SNMP_V3_NOTIFY_UPDATE_TEST(pktp, vbp, notify, newnotify); if (ptret != NO_ERROR) { SNMP_Notify_Destroy(newnotify); testproc_error(pktp, vbp, ptret); return; } newnotify->next = notify; vbp->vb_free_priv = notifytable_update_cleanup; }if (cago) SNMP_Notify_Set_Status(newnotify, ETC_RS_CAGO);vbp->vb_priv = (PTR_T)newnotify;return;}void snmpNotifyEntry_set(OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){SNMP_NOTIFY_T *old_notify, *new_notify;bits16_t temp_value;EBUFFER_T temp_ebuf;new_notify = (SNMP_NOTIFY_T *)vbp->vb_priv;if (vbp->vb_free_priv == notifytable_destroy_cleanup) { SNMP_V3_NOTIFY_DESTROY_SET(pktp, vbp, new_notify, 0); SNMP_Notify_Deinstall(new_notify); vbp->vb_free_priv = notifytable_set_cleanup; undoproc_set(pktp, vbp, notifytable_destroy_undo); }else if (vbp->vb_free_priv == notifytable_create_cleanup) { if (SNMP_Notify_Get_Status(new_notify) == ETC_RS_CAGO) SNMP_Notify_Set_Status(new_notify, ETC_RS_ACTIVE); SNMP_V3_NOTIFY_CREATE_SET(pktp, vbp, 0, new_notify); undoproc_set(pktp, vbp, notifytable_create_undo); }else { old_notify = new_notify->next; SNMP_V3_NOTIFY_UPDATE_SET(pktp, vbp, old_notify, new_notify); /* deal with status, storage and prefix information */ temp_value = SNMP_Notify_Get_Flags(old_notify); SNMP_Notify_Set_Flags(old_notify, SNMP_Notify_Get_Flags(new_notify)); SNMP_Notify_Set_Flags(new_notify, temp_value); temp_value = SNMP_Notify_Get_Status(old_notify); SNMP_Notify_Set_Status(old_notify, SNMP_Notify_Get_Status(new_notify)); SNMP_Notify_Set_Status(new_notify, temp_value); temp_value = SNMP_Notify_Get_Storage(old_notify); SNMP_Notify_Set_Storage(old_notify, SNMP_Notify_Get_Storage(new_notify)); SNMP_Notify_Set_Storage(new_notify, temp_value); temp_value = SNMP_Notify_Get_Type(old_notify); SNMP_Notify_Set_Type(old_notify, SNMP_Notify_Get_Type(new_notify)); SNMP_Notify_Set_Type(new_notify, temp_value); if (SNMP_Notify_Get_Tag(new_notify) != SNMP_Notify_Get_Tag(old_notify)) { MEMCPY(&temp_ebuf, &old_notify->notify_tag, sizeof(EBUFFER_T)); MEMCPY(&old_notify->notify_tag, &new_notify->notify_tag, sizeof(EBUFFER_T)); MEMCPY(&new_notify->notify_tag, &temp_ebuf, sizeof(EBUFFER_T)); } undoproc_set(pktp, vbp, notifytable_update_undo); }vbp->vb_free_priv = notifytable_set_cleanup;setproc_good(pktp, vbp);return;}/* * Method routines for the snmpNotifyFilterProfileTable: * * snmpNotifyFilterProfileName -- read-create * The name of the filter profile to be used when generating * notifications using the corresponding entry in the * snmpTargetAddrTable. * * snmpNotifyFilterProfileStorType -- read-create * The storage type of this conceptual row. * * snmpNotifyFilterProfileRowStatus -- 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 * snmpNotifyFilterProfileRowStatus column is 'notReady'. * * In particular, a newly created row cannot be made * active until the corresponding instance of * snmpNotifyFilterProfileName has been set. *//* An internal routine to retrieve the values of the variables, used * by the method routines snmpNotifyFilterProfileEntry_get and * snmpNotifyFilterProfileEntry_next. */static int snmpNotifyFilterProfileEntry_get_value(OIDC_T lastmatch, SNMP_PKT_T *pktp, VB_T *vbp, SNMP_NOTIFY_FILTER_PROFILE_T *profile){ switch(lastmatch) { case LEAF_snmpNotifyFilterProfileName: getproc_got_string(pktp, vbp, SNMP_Notify_Profile_Get_Profile_Len(profile), SNMP_Notify_Profile_Get_Profile(profile), 0, VT_STRING); break; case LEAF_snmpNotifyFilterProfileStorType: /* Values: * other(1) = VAL_snmpNotifyFilterProfileStorType_other * volatile(2) = VAL_snmpNotifyFilterProfileStorType_volatile * nonVolatile(3) = VAL_snmpNotifyFilterProfileStorType_nonVolatile * permanent(4) = VAL_snmpNotifyFilterProfileStorType_permanent * readOnly(5) = VAL_snmpNotifyFilterProfileStorType_readOnly */ getproc_got_int32(pktp, vbp, SNMP_Notify_Profile_Get_Storage(profile)); break; case LEAF_snmpNotifyFilterProfileRowStatus: /* Values: * active(1) = VAL_snmpNotifyFilterProfileRowStatus_active * notInService(2) = VAL_snmpNotifyFilterProfileRowStatus_notInService * notReady(3) = VAL_snmpNotifyFilterProfileRowStatus_notReady * createAndGo(4) = VAL_snmpNotifyFilterProfileRowStatus_createAndGo * createAndWait(5) = VAL_snmpNotifyFilterProfileRowStatus_createAndWait * destroy(6) = VAL_snmpNotifyFilterProfileRowStatus_destroy */ getproc_got_int32(pktp, vbp, SNMP_Notify_Profile_Get_Status(profile)); break; default: return GEN_ERR; } return NO_ERROR;}void snmpNotifyFilterProfileEntry_get(OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){SNMP_NOTIFY_FILTER_PROFILE_T *profile = 0;bits8_t name[ETC_TARGET_PARAMS_MAX];ALENGTH_T name_len = 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, &name_len, name, 1) == 0) && (name_len != 0)) profile = SNMP_Notify_Profile_Lookup(name, name_len);if (profile == 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 = snmpNotifyFilterProfileEntry_get_value(vbp->vb_ml.ml_last_match, pktp, vbp, profile)) != NO_ERROR) getproc_error(pktp, vbp, error); } }}void snmpNotifyFilterProfileEntry_next(OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){SNMP_NOTIFY_FILTER_PROFILE_T *profile;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);profile = SNMP_Notify_Profile_Next(tcount, tlist);if ((profile) && (error = string_to_oid(SNMP_Notify_Profile_Get_Params_Len(profile), SNMP_Notify_Profile_Get_Params(profile), ETC_NOTIFY_FILTER_PROFILE_MAX, best_inst, 1) == 0)) { for ( ; vbp ; vbp = vbp->vb_link ) { if ((error = snmpNotifyFilterProfileEntry_get_value(vbp->vb_ml.ml_last_match, pktp, vbp, profile)) == NO_ERROR) nextproc_next_instance(pktp, vbp, SNMP_Notify_Profile_Get_Params_Len(profile), 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: nproftable_destroy_cleanupPURPOSE: Cleanup after a notify_filter_profile 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 notify_filter_profile that we were going to delete, cast as a ptr_tRETURNS: Nothing****************************************************************************/static void nproftable_destroy_cleanup(ptr_t profileptr){SNMP_V3_NPROF_DESTROY_BACKOUT(((VB_T *)profileptr)->vb_priv, 0);}/****************************************************************************NAME: nproftable_create_cleanupPURPOSE: Cleanup after a notify_filter_profile 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 notify_filter_profile that we were going to create, cast as a ptr_tRETURNS: Nothing****************************************************************************/static void nproftable_create_cleanup(ptr_t profileptr){SNMP_NOTIFY_FILTER_PROFILE_T *profile;profile = (SNMP_NOTIFY_FILTER_PROFILE_T *)(((VB_T *)profileptr)->vb_priv);SNMP_V3_NPROF_CREATE_BACKOUT(0, profile);SNMP_Notify_Profile_Deinstall(profile);SNMP_Notify_Profile_Destroy(profile);}/****************************************************************************NAME: nproftable_update_cleanupPURPOSE: Cleanup after a notify_filter_profile 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 notify_filter_profile that contained the update information, cast as a ptr_tRETURNS: Nothing****************************************************************************/static void
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -