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

📄 v3mt_nfy.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 5 页
字号:
  nproftable_update_cleanup(ptr_t profileptr){SNMP_NOTIFY_FILTER_PROFILE_T *profile;profile = (SNMP_NOTIFY_FILTER_PROFILE_T *)(((VB_T *)profileptr)->vb_priv);SNMP_V3_NPROF_UPDATE_BACKOUT(profile->next, profile);SNMP_Notify_Profile_Destroy(profile);}/****************************************************************************NAME:  nproftable_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	  notify_filter_profile 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  nproftable_destroy_undo(OIDC_T	 last_match,			  int		 tcount,			  OIDC_T	*tlist,			  SNMP_PKT_T 	*pktp,			  VB_T		*vbp){SNMP_NOTIFY_FILTER_PROFILE_T *profile;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 */profile      = (SNMP_NOTIFY_FILTER_PROFILE_T *)vbp->vb_priv;vbp->vb_priv = 0;if (SNMP_Notify_Profile_Install(profile, name, name_len) == 0) {#if defined(SNMP_V3_NPROF_DESTROY_UNDO)    if (SNMP_V3_NPROF_DESTROY_UNDO(pktp, vbp, 0, profile) == 0) {        vbp->vb_free_priv = 0;	return;        }    else        SNMP_Notify_Profile_Deinstall(profile);#else    vbp->vb_free_priv = 0;    return;#endif    }SNMP_Notify_Profile_Destroy(profile);undoproc_error(pktp, vbp, UNDO_FAILED);return;}/****************************************************************************NAME:  nproftable_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  nproftable_create_undo(OIDC_T 	 last_match,			 int		 tcount,			 OIDC_T	        *tlist,			 SNMP_PKT_T 	*pktp,			 VB_T		*vbp){SNMP_NOTIFY_FILTER_PROFILE_T *profile;/* 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 */profile = (SNMP_NOTIFY_FILTER_PROFILE_T *)vbp->vb_priv;vbp->vb_priv	  = 0;vbp->vb_free_priv = 0;#if defined(SNMP_V3_NPROF_CREATE_UNDO)if (SNMP_V3_NPROF_CREATE_UNDO(pktp, vbp, profile, 0)) {    undoproc_error(pktp, vbp, UNDO_FAILED);    return;    }#endifSNMP_Notify_Profile_Deinstall(profile);SNMP_Notify_Profile_Destroy(profile);return;}/****************************************************************************NAME:  nproftable_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	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  nproftable_update_undo(OIDC_T	         last_match,			 int		 tcount,			 OIDC_T	        *tlist,			 SNMP_PKT_T 	*pktp,			 VB_T		*vbp){SNMP_NOTIFY_FILTER_PROFILE_T *cur_profile, *sav_profile;/* 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 */sav_profile = (SNMP_NOTIFY_FILTER_PROFILE_T *)vbp->vb_priv;vbp->vb_priv	  = 0;vbp->vb_free_priv = 0;cur_profile = sav_profile->next;#if defined(SNMP_V3_NPROF_UPDATE_UNDO)if (SNMP_V3_NPROF_UPDATE_UNDO(pktp, vbp, cur_profile, sav_profile)) {    undoproc_error(pktp, vbp, UNDO_FAILED);    SNMP_Notify_Profile_Destroy(sav_profile);    return;    }#endif/* swap the info from saved notify back into current notify, we only   need to move strings if the names are different finally free the   saved block */if (SNMP_Notify_Profile_Get_Profile(cur_profile) !=    SNMP_Notify_Profile_Get_Profile(sav_profile)) {    EBufferClean(&cur_profile->profile_name);    MEMCPY(&cur_profile->profile_name, &sav_profile->profile_name, 	   sizeof(EBUFFER_T));    EBufferInitialize(&sav_profile->profile_name);    }SNMP_Notify_Profile_Set_Storage(cur_profile,				SNMP_Notify_Profile_Get_Storage(sav_profile));SNMP_Notify_Profile_Set_Status(cur_profile,			       SNMP_Notify_Profile_Get_Status(sav_profile));SNMP_Notify_Profile_Set_Flags(cur_profile,			      SNMP_Notify_Profile_Get_Flags(sav_profile));SNMP_Notify_Profile_Destroy(sav_profile);return;}/****************************************************************************NAME: nproftable_set_cleanupPURPOSE: Free the saved notify_filter_profile and indicate that we are         finished.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  nproftable_set_cleanup(ptr_t profileptr){if (((VB_T *)profileptr)->vb_priv) {    if (((VB_T *)profileptr)->undoproc == nproftable_create_undo)        ((VB_T *)profileptr)->vb_priv = 0;    else        SNMP_Notify_Profile_Destroy(((VB_T *)profileptr)->vb_priv);    }SNMP_V3_NPROF_FINISHED();}void  snmpNotifyFilterProfileEntry_test(OIDC_T      lastmatch,                                    int         tcount,                                    OIDC_T     *tlist,                                    SNMP_PKT_T *pktp,                                    VB_T       *vbp){SNMP_NOTIFY_FILTER_PROFILE_T *profile, tempprofile, *newprofile;sbits32_t value, ptret;int cago = 0, create_row = 0, pf_chg = 0;ALENGTH_T nlen = 0;VB_T *tvbp, *pn_vbp = 0, *rs_vbp = 0;bits8_t name[ETC_TARGET_PARAMS_MAX];ALENGTH_T name_len = ETC_TARGET_PARAMS_MAX;/* get the list of var binds that may go into this structure   then mark all the vbs except the first one as having been   tested, set and done.  This means that vbp is taking   responsibility for all of the other vbs in the row.  Then   mark vbp as having it's test started & done so we don't   have to worry about it later.  We can do this because   the routine will run to completion */group_by_getproc_and_instance(pktp, vbp, tcount, tlist);for(tvbp = vbp->vb_link; tvbp; tvbp = tvbp->vb_link)    setproc_all_bits(pktp, tvbp);testproc_good(pktp, vbp);/* gather the indexing information, the index will be of the form:   <name>   first we do some minor checks then we attempt to find the user */if ((tcount > ETC_NOTIFY_FILTER_PROFILE_MAX)           ||    oid_to_string(tcount, tlist, &name_len, name, 1)   ||    (name_len == 0) || ((bits32_t)name_len != (bits32_t) tcount)) {    testproc_error(pktp, vbp, NO_CREATION);    return;    }profile = SNMP_Notify_Profile_Lookup(name, name_len);/* is the leaf writable, (if it's read only it isn't writable) */if (profile != 0) {    if (SNMP_Notify_Profile_Get_Storage(profile) == ETC_STO_RONLY) {	testproc_error(pktp, vbp, NOT_WRITABLE);      	return;	}    MEMCPY(&tempprofile, profile, sizeof(SNMP_NOTIFY_FILTER_PROFILE_T));    }else {    SNMP_Notify_Profile_Set_Defaults(&tempprofile);    create_row = 1;    }    for (tvbp = vbp; tvbp; tvbp = tvbp->vb_link) {    switch(tvbp->vb_ml.ml_last_match) {        case LEAF_snmpNotifyFilterProfileName:	    nlen = EBufferUsed(&tvbp->value_u.v_string);	    if ((nlen < MINSIZE_snmpNotifyFilterProfileName) ||		(nlen > MAXSIZE_snmpNotifyFilterProfileName)) {	        testproc_error(pktp, tvbp, WRONG_LENGTH);		return;	        }	    EBufferPreLoad(BFL_IS_STATIC, &tempprofile.profile_name,			   EBufferStart(&tvbp->value_u.v_string), nlen);	    pn_vbp = tvbp;	    break;        case LEAF_snmpNotifyFilterProfileStorType:	    value = tvbp->value_u.v_number;	    if ((value < ETC_STO_OTHER) ||		(value > ETC_STO_RONLY) ||                ((profile != 0) && (value > ETC_STO_NONVOL)) ||		(SNMP_Notify_Profile_Get_Storage(&tempprofile) 		 >= ETC_STO_PERM)) {	        testproc_error(pktp, tvbp, WRONG_VALUE);		return;	        }	    SNMP_Notify_Profile_Set_Storage(&tempprofile, (bits16_t)value);	    break;        case LEAF_snmpNotifyFilterProfileRowStatus:	    value = tvbp->value_u.v_number;	    switch (value) {		case ETC_RS_ACTIVE:		case ETC_RS_NIS:		    if (create_row) {			testproc_error(pktp, tvbp, INCONSISTENT_VALUE);			return;			}		    break;		case ETC_RS_CAGO:		    if (create_row == 0) {			testproc_error(pktp, tvbp, INCONSISTENT_VALUE);			return;			}		    value = ETC_RS_ACTIVE;		    cago = 1;		    break;		case ETC_RS_CAWAIT:		    if (create_row == 0) {			testproc_error(pktp, tvbp, INCONSISTENT_VALUE);			return;			}		    value = ETC_RS_NREADY;		    break;		case ETC_RS_DESTROY:                    if (SNMP_Notify_Profile_Get_Storage(&tempprofile) >=                        ETC_STO_PERM) {                        testproc_error(pktp, tvbp, WRONG_VALUE);                        return;                        }		    break;		default:		    testproc_error(pktp, tvbp, WRONG_VALUE);		    return;	        }	    if (SNMP_Notify_Profile_Get_Status(&tempprofile) 		!= ETC_RS_DESTROY) {	        SNMP_Notify_Profile_Set_Status(&tempprofile, (bits16_t)value);		rs_vbp = tvbp;                }	    break;        default:	    testproc_error(pktp, tvbp, GEN_ERR);	    return;        }    }/* The values are ok  */if (SNMP_Notify_Profile_Get_Status(&tempprofile) == ETC_RS_DESTROY) {    if (profile != 0) {	ptret = SNMP_V3_NPROF_DESTROY_TEST(pktp, vbp, profile, 0);	if (ptret != NO_ERROR) {	    testproc_error(pktp, vbp, ptret);	    }	else {	    vbp->vb_priv	 = (PTR_T)profile;	    vbp->vb_free_priv = nproftable_destroy_cleanup;	    }        }    else {        /* We have a destroy request, but no notify_filter_profile 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;    }/* do consistency checks */if (pn_vbp)    tempprofile.flags |= ETC_NPROF_PROFILE;/* check on status */if ((rs_vbp) && (rs_vbp->value_u.v_number != ETC_RS_CAWAIT)) {    if (((cago) ||	 ((profile) &&	  (SNMP_Notify_Profile_Get_Status(profile) == ETC_RS_NREADY))) &&	((tempprofile.flags & ETC_NPROF_ALL_FLAGS) != ETC_NPROF_ALL_FLAGS)) {        testproc_error(pktp, rs_vbp, INCONSISTENT_VALUE);	return;        }    }else {    if ((SNMP_Notify_Profile_Get_Status(&tempprofile) == ETC_RS_NREADY) &&	((tempprofile.flags & ETC_NPROF_ALL_FLAGS) == ETC_NPROF_ALL_FLAGS))        SNMP_Notify_Profile_Set_Status(&tempprofile, 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 (profile) {    if ((SNMP_Notify_Profile_Get_Profile(profile) !=	 SNMP_Notify_Profile_Get_Profile(&tempprofile)) &&	((SNMP_Notify_Profile_Get_Profile_Len(profile) !=	  SNMP_Notify_Profile_Get_Profile_Len(&tempprofile)) ||	 MEMCMP_NULLOK(SNMP_Notify_Profile_Get_Profile(profile),		       SNMP_Notify_Profile_Get_Profile(&tempprofile),		       SNMP_Notify_Profile_Get_Profile_Len(profile)))) {        pf_chg = 1;

⌨️ 快捷键说明

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