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

📄 v3mt_acc.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 5 页
字号:
	 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 group		that we were going to create, cast as a ptr_tRETURNS: Nothing****************************************************************************/static void  grouptable_create_cleanup(ptr_t groupptr){SNMP_GROUP_T *group;group = (SNMP_GROUP_T *)(((VB_T *)groupptr)->vb_priv);SNMP_V3_GROUP_CREATE_BACKOUT(0, group);SNMP_Group_Deinstall(group);SNMP_Group_Destroy(group);}/****************************************************************************NAME: grouptable_update_cleanupPURPOSE: Cleanup after a group 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 group	        that contained the update information,		cast as a ptr_tRETURNS: Nothing****************************************************************************/static void  grouptable_update_cleanup(ptr_t groupptr){SNMP_GROUP_T *group;group = (SNMP_GROUP_T *)(((VB_T *)groupptr)->vb_priv);SNMP_V3_GROUP_UPDATE_BACKOUT(group->next, group);SNMP_Group_Destroy(group);}/****************************************************************************NAME:  grouptable_destory_undoPURPOSE:  This routine attempts to undo a previous destory set.  It expects	  the old information to be pointed to by vb_priv and tries to	  reinstall it.  If we can't reinstall the group 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  grouptable_destroy_undo(OIDC_T	 last_match,			  int		 tcount,			  OIDC_T	*tlist,			  SNMP_PKT_T 	*pktp,			  VB_T		*vbp){SNMP_GROUP_T *group;ALENGTH_T namelen = ETC_ACCESS_GROUP_MAX;bits8_t name[ETC_ACCESS_GROUP_MAX];/* reaquire the name */ (void) oid_to_string(tcount - 1, tlist + 1, &namelen, name, 0);/* assume things will go well and mark the vbp as done */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 */group        = (SNMP_GROUP_T *)vbp->vb_priv;vbp->vb_priv = 0;if (SNMP_Group_Install(group, (sbits32_t)tlist[0], name, namelen) == 0) {#if defined(SNMP_V3_GROUP_DESTROY_UNDO)     if (SNMP_V3_GROUP_DESTROY_UNDO(pktp, vbp, 0, group) == 0) {        vbp->vb_free_priv = 0;        return;        }    else         SNMP_Group_Deinstall(group);#else    vbp->vb_free_priv = 0;    return;#endif    }SNMP_Group_Destroy(group);undoproc_error(pktp, vbp, UNDO_FAILED);return;}/****************************************************************************NAME:  grouptable_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  grouptable_create_undo(OIDC_T	 	 last_match,			 int		 tcount,			 OIDC_T		*tlist,			 SNMP_PKT_T 	*pktp,			 VB_T		*vbp){SNMP_GROUP_T *group;/* 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 */group = (SNMP_GROUP_T *)vbp->vb_priv;vbp->vb_priv	  = 0;vbp->vb_free_priv = 0;#if defined(SNMP_V3_GROUP_CREATE_UNDO)if (SNMP_V3_GROUP_CREATE_UNDO(pktp, vbp, group, 0)) {    undoproc_error(pktp, vbp, UNDO_FAILED);    return;    }#endifSNMP_Group_Deinstall(group);SNMP_Group_Destroy(group);return;}/****************************************************************************NAME:  grouptable_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  grouptable_update_undo(OIDC_T		 last_match,			 int		 tcount,			 OIDC_T		*tlist,			 SNMP_PKT_T 	*pktp,			 VB_T		*vbp){SNMP_GROUP_T *curgroup, *savgroup;/* 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 */savgroup = (SNMP_GROUP_T *)vbp->vb_priv;vbp->vb_priv	  = 0;vbp->vb_free_priv = 0;curgroup = savgroup->next;#if defined(SNMP_V3_GROUP_UPDATE_UNDO)if (SNMP_V3_GROUP_UPDATE_UNDO(pktp, vbp, curgroup, savgroup)) {    /* we had an undo failure indicate that to our       caller and get rid of the saved group */    undoproc_error(pktp, vbp, UNDO_FAILED);    SNMP_Group_Destroy(savgroup);    return;    }#endif/* swap the info from saved group back into current group and then free   the saved block.  */SNMP_Group_Set_Status(curgroup, SNMP_Group_Get_Status(savgroup));SNMP_Group_Set_Storage(curgroup, SNMP_Group_Get_Storage(savgroup));/* We only need to move stuff if the names are different */if (EBufferStart(&savgroup->grp_name) != EBufferStart(&curgroup->grp_name)) {    EBufferClean(&curgroup->grp_name);    MEMCPY(&curgroup->grp_name, &savgroup->grp_name, sizeof(EBUFFER_T));    EBufferInitialize(&savgroup->grp_name);    }SNMP_Group_Destroy(savgroup);return;}/****************************************************************************NAME: grouptable_set_cleanupPURPOSE: Free the saved group and indicate that we are finished.PARAMETERS: 	ptr_t   A pointer to the vb that points to the group	        that contained the update information,		cast as a ptr_tRETURNS: Nothing****************************************************************************/static void  grouptable_set_cleanup(ptr_t groupptr){if (((VB_T *)groupptr)->vb_priv) {    if (((VB_T *)groupptr)->undoproc == grouptable_create_undo)        ((VB_T *)groupptr)->vb_priv = 0;    else        SNMP_Group_Destroy(((VB_T *)groupptr)->vb_priv);    }SNMP_V3_GROUP_FINISHED();}/****************************************************************************NAME:  grouptable_testPURPOSE:  This routine collects all of the var binds that want to be set	  in a row and does value and consistency checking on those	  varbinds before trying to allocate any space. 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*/void  grouptable_test(OIDC_T	 last_match,		  int		 tcount,		  OIDC_T	*tlist,		  SNMP_PKT_T 	*pktp,		  VB_T		*vbp){SNMP_GROUP_T *grp, tempgrp, *newgrp;sbits32_t value, ptret;int cago = 0, create_row = 0, grp_changed = 0;ALENGTH_T nlen = 0, namelen = ETC_ACCESS_GROUP_MAX;VB_T *tvbp, *rs_vbp = 0, *vg_vbp = 0;bits8_t name[ETC_ACCESS_GROUP_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 haing 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);/* The index will be of the form <model> <len> <name>   first we see if the name will work then we try and find the group */if ((tcount < 3) ||    (tlist[0] == 0) ||    (tlist[0] > 0x80000000L) ||    (tlist[1] < 1) ||    (oid_to_string(tcount - 1, tlist + 1, &namelen, name, 0)) ||    ((bits32_t)namelen != (bits32_t)(tcount - 2))) {    testproc_error(pktp, vbp, NO_CREATION);    return;    }grp = SNMP_Group_Lookup((sbits32_t)tlist[0], name, namelen);/*sar*/ /* need to update this comment *//* Note that the check for status is simpler than the general case as    this table has few objects and all but status have defvals.  This    means that several conditions can't occur.  So create and go is always   acceptable and is almost the same as create and wait, active and not in   service are also similiar. *//* is the leaf writable, (if it's read only it isn't writable) */if (grp != 0) {    if (SNMP_Group_Get_Storage(grp) == ETC_STO_RONLY) {	testproc_error(pktp, vbp, NOT_WRITABLE);      	return;	}    MEMCPY(&tempgrp, grp, sizeof(SNMP_GROUP_T));    }else {    SNMP_Group_Set_Defaults(&tempgrp);    create_row = 1;    }    for (tvbp = vbp; tvbp; tvbp = tvbp->vb_link) {    switch (tvbp->vb_ml.ml_last_match) {        case LM_groupName:	    nlen = EBufferUsed(&tvbp->value_u.v_string);	    if ((nlen == 0) || (nlen > ETC_ACCESS_GROUP_MAX)) {		testproc_error(pktp, tvbp, WRONG_LENGTH);		return;		}	    EBufferPreLoad(BFL_IS_STATIC, &tempgrp.grp_name,			   EBufferStart(&tvbp->value_u.v_string), nlen);            vg_vbp = tvbp;	    break;	case LM_groupStorage:	    value = tvbp->value_u.v_number; 	    if ((value < ETC_STO_OTHER)  ||		(value > ETC_STO_RONLY) ||                ((grp != 0) && (value > ETC_STO_NONVOL)) ||		(SNMP_Group_Get_Storage(&tempgrp) > ETC_STO_NONVOL)) {		testproc_error(pktp, tvbp, WRONG_VALUE);		return;		}	    SNMP_Group_Set_Storage(&tempgrp, (int)value);	    break;	case LM_groupStatus:	    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_Group_Get_Storage(&tempgrp) >= ETC_STO_PERM) {                        testproc_error(pktp, tvbp, WRONG_VALUE);                        return;                        }		    break;		default:		    testproc_error(pktp, tvbp, WRONG_VALUE);		    return;	        }	    if (SNMP_Group_Get_Status(&tempgrp) != ETC_RS_DESTROY)	        SNMP_Group_Set_Status(&tempgrp, (int)value);            rs_vbp = tvbp;	    break;	}    }

⌨️ 快捷键说明

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