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

📄 v3mt_acc.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 5 页
字号:
		return;		}	    EBufferPreLoad(BFL_IS_STATIC, &tempaccess.readview,			   EBufferStart(&tvbp->value_u.v_string), nlen);	    break;        case LM_accessWrite:	    nlen = EBufferUsed(&tvbp->value_u.v_string);	    if (nlen > ETC_ACCESS_VIEW_MAX) {		testproc_error(pktp, tvbp, WRONG_LENGTH);		return;		}	    EBufferPreLoad(BFL_IS_STATIC, &tempaccess.writeview,			   EBufferStart(&tvbp->value_u.v_string), nlen);	    break;        case LM_accessNotify:	    nlen = EBufferUsed(&tvbp->value_u.v_string);	    if (nlen > ETC_ACCESS_VIEW_MAX) {		testproc_error(pktp, tvbp, WRONG_LENGTH);		return;		}	    EBufferPreLoad(BFL_IS_STATIC, &tempaccess.notifyview,			   EBufferStart(&tvbp->value_u.v_string), nlen);	    break;	case LM_accessStorage:	    value = tvbp->value_u.v_number; 	    if ((value < ETC_STO_OTHER)  ||		(value > ETC_STO_RONLY) ||                ((access != 0) && (value > ETC_STO_NONVOL)) ||		(SNMP_V3_Access_Get_Storage(&tempaccess) >= ETC_STO_PERM)) {		testproc_error(pktp, tvbp, WRONG_VALUE);		return;		}	    SNMP_V3_Access_Set_Storage(&tempaccess, (int)value);	    break;	case LM_accessStatus:	    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_NIS;		    break;		case ETC_RS_DESTROY:                    if (SNMP_V3_Access_Get_Storage(&tempaccess) >=                        ETC_STO_PERM) {                        testproc_error(pktp, tvbp, WRONG_VALUE);                        return;                        }		    break;		default:		    testproc_error(pktp, tvbp, WRONG_VALUE);		    return;	        }	    if (SNMP_V3_Access_Get_Status(&tempaccess) != ETC_RS_DESTROY)	        SNMP_V3_Access_Set_Status(&tempaccess, (int)value);	    break;	}    }    /* The values are ok  */if (SNMP_V3_Access_Get_Status(&tempaccess) == ETC_RS_DESTROY) {    if (access != 0) {	ptret = SNMP_V3_ACCESS_DESTROY_TEST(pktp, vbp, access, 0);	if (ptret != NO_ERROR) {	    testproc_error(pktp, vbp, ptret);	    }	else {	    vbp->vb_priv	 = (PTR_T)access;	    vbp->vb_free_priv = accesstable_destroy_cleanup;	    }        }    else {        /* We have a destroy request, but no access 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;    }    /* 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 we are   creating an entry mark the the views as having changed so they   will get copied */if (access) {    if ((SNMP_V3_Access_Get_Read(access) !=	 SNMP_V3_Access_Get_Read(&tempaccess)) &&	((SNMP_V3_Access_Get_Read_Len(access) != 	  SNMP_V3_Access_Get_Read_Len(&tempaccess)) ||	 MEMCMP_NULLOK(SNMP_V3_Access_Get_Read(access),		       SNMP_V3_Access_Get_Read(&tempaccess),		       SNMP_V3_Access_Get_Read_Len(access)))) {        rd_chg = 1;        }    if ((SNMP_V3_Access_Get_Write(access) !=	 SNMP_V3_Access_Get_Write(&tempaccess)) &&	((SNMP_V3_Access_Get_Write_Len(access) != 	  SNMP_V3_Access_Get_Write_Len(&tempaccess)) ||	 MEMCMP_NULLOK(SNMP_V3_Access_Get_Write(access),		       SNMP_V3_Access_Get_Write(&tempaccess),		       SNMP_V3_Access_Get_Write_Len(access)))) {        wr_chg = 1;        }    if ((SNMP_V3_Access_Get_Notify(access) !=	 SNMP_V3_Access_Get_Notify(&tempaccess)) &&	((SNMP_V3_Access_Get_Notify_Len(access) != 	  SNMP_V3_Access_Get_Notify_Len(&tempaccess)) ||	 MEMCMP_NULLOK(SNMP_V3_Access_Get_Notify(access),		       SNMP_V3_Access_Get_Notify(&tempaccess),		       SNMP_V3_Access_Get_Notify_Len(access)))) {        no_chg = 1;        }    if ((rd_chg == 0) && (wr_chg == 0) && (no_chg == 0) &&	(SNMP_V3_Access_Get_Prefix_Match(access) == 	 SNMP_V3_Access_Get_Prefix_Match(&tempaccess)) &&	(SNMP_V3_Access_Get_Status(access) == 	 SNMP_V3_Access_Get_Status(&tempaccess)) &&	(SNMP_V3_Access_Get_Storage(access) == 	 SNMP_V3_Access_Get_Storage(&tempaccess))) {        setproc_all_bits(pktp, vbp);	return;        }    }else {    rd_chg = 1;    wr_chg = 1;    no_chg = 1;    }/* Because of how we do the backout stuff we always allocate a new   access and set it up */newaccess = SNMP_V3_Access_Create();if (newaccess == 0) {    testproc_error(pktp, vbp, RESOURCE_UNAVAILABLE);    return;    }SNMP_V3_Access_Set_Prefix_Match(newaccess,				SNMP_V3_Access_Get_Prefix_Match(&tempaccess));SNMP_V3_Access_Set_Status(newaccess, SNMP_V3_Access_Get_Status(&tempaccess));SNMP_V3_Access_Set_Storage(newaccess, SNMP_V3_Access_Get_Storage(&tempaccess));if (rd_chg) {    if (EBufferClone(&tempaccess.readview, &newaccess->readview) != 0) {        SNMP_V3_Access_Destroy(newaccess);	testproc_error(pktp, vbp, RESOURCE_UNAVAILABLE);	return;        }    }else{    EBufferPreLoad(BFL_IS_STATIC, &newaccess->readview,		   SNMP_V3_Access_Get_Read(access),		   SNMP_V3_Access_Get_Read_Len(access));    }    if (wr_chg) {    if (EBufferClone(&tempaccess.writeview, &newaccess->writeview) != 0) {        SNMP_V3_Access_Destroy(newaccess);	testproc_error(pktp, vbp, RESOURCE_UNAVAILABLE);	return;        }    }else{    EBufferPreLoad(BFL_IS_STATIC, &newaccess->writeview,		   SNMP_V3_Access_Get_Write(access),		   SNMP_V3_Access_Get_Write_Len(access));    }    if (no_chg) {    if (EBufferClone(&tempaccess.notifyview, &newaccess->notifyview) != 0) {        SNMP_V3_Access_Destroy(newaccess);	testproc_error(pktp, vbp, RESOURCE_UNAVAILABLE);	return;        }    }else{    EBufferPreLoad(BFL_IS_STATIC, &newaccess->notifyview,		   SNMP_V3_Access_Get_Notify(access),		   SNMP_V3_Access_Get_Notify_Len(access));    }    /* if we are creating a new access we need to install it and run   the create test, if we are updating an old access we just   run the update test */if (access == 0) {    if (SNMP_V3_Access_Install(newaccess, grp_name, grp_namelen, name, namelen,			       (sbits32_t)tlist[2 + grp_namelen + namelen],			       (sbits32_t)tlist[3 + grp_namelen + namelen])) {	SNMP_V3_Access_Destroy(newaccess);	testproc_error(pktp, vbp, RESOURCE_UNAVAILABLE);	return;	}    ptret = SNMP_V3_ACCESS_CREATE_TEST(pktp, vbp, 0, newaccess);    if (ptret != NO_ERROR) {        SNMP_V3_Access_Deinstall(newaccess);	SNMP_V3_Access_Destroy(newaccess);	testproc_error(pktp, vbp, ptret);	return;	}    vbp->vb_free_priv = accesstable_create_cleanup;    }else {    ptret = SNMP_V3_ACCESS_UPDATE_TEST(pktp, vbp, access, newaccess);    if (ptret != NO_ERROR) {	SNMP_V3_Access_Destroy(newaccess);	testproc_error(pktp, vbp, ptret);	return;	}    newaccess->next = access;    vbp->vb_free_priv = accesstable_update_cleanup;    }if (cago)    SNMP_V3_Access_Set_Status(newaccess, ETC_RS_CAGO);vbp->vb_priv	= (PTR_T)newaccess;return;}/****************************************************************************NAME:  accesstable_setPURPOSE:  Perform the set of the access, by the time we get here the	  access struct has been built and filled in by the test function.	  For a destroy we remove the access from the list, but we	  don't destroy it yet, we keep it around in case we need	  to undo it.	  For a create we don't do much, we only need to call	  the create hook macro and set vb_priv to 0 so we	  don't destroy the access when we run the cleanup routine.	  For an update we need to copy the info from the new to	  the old one as well as saving the old info in case of	  an undo is required.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 processed.	VB_T	   *	Variable being processed.RETURNS: void****************************************************************************/void  accesstable_set(OIDC_T	 last_match,		  int		 tcount,		  OIDC_T	*tlist,		  SNMP_PKT_T	*pktp,		  VB_T		*vbp){SNMP_ACCESS_T *old_acc, *new_acc;bits16_t temp_value;EBUFFER_T temp_ebuf;new_acc = (SNMP_ACCESS_T *)vbp->vb_priv;if (vbp->vb_free_priv == accesstable_destroy_cleanup) {    SNMP_V3_ACCESS_DESTROY_SET(pktp, vbp, new_acc, 0);    SNMP_V3_Access_Deinstall(new_acc);    vbp->vb_free_priv = accesstable_set_cleanup;    undoproc_set(pktp, vbp, accesstable_destroy_undo);    }else if (vbp->vb_free_priv == accesstable_create_cleanup) {    if (SNMP_V3_Access_Get_Status(new_acc) == ETC_RS_CAGO)        SNMP_V3_Access_Set_Status(new_acc, ETC_RS_ACTIVE);    SNMP_V3_ACCESS_CREATE_SET(pktp, vbp, 0, new_acc);    undoproc_set(pktp, vbp, accesstable_create_undo);    }else {    old_acc = new_acc->next;    SNMP_V3_ACCESS_UPDATE_SET(pktp, vbp, old_acc, new_acc);    /* deal with status, storage and prefix information */    temp_value  = SNMP_V3_Access_Get_Status(old_acc);    SNMP_V3_Access_Set_Status(old_acc, SNMP_V3_Access_Get_Status(new_acc));     SNMP_V3_Access_Set_Status(new_acc, temp_value);    temp_value = SNMP_V3_Access_Get_Storage(old_acc);    SNMP_V3_Access_Set_Storage(old_acc, SNMP_V3_Access_Get_Storage(new_acc));     SNMP_V3_Access_Set_Storage(new_acc, temp_value);    temp_value = SNMP_V3_Access_Get_Prefix_Match(old_acc);    SNMP_V3_Access_Set_Prefix_Match(old_acc,				    SNMP_V3_Access_Get_Prefix_Match(new_acc));     SNMP_V3_Access_Set_Prefix_Match(new_acc, temp_value);    /* deal with the string info, if the two pointers are       equal we don't need to do anything, otherwise we need       to copy the buffer info around */    if (EBufferStart(&old_acc->readview) != EBufferStart(&new_acc->readview)) {        MEMCPY(&temp_ebuf, &old_acc->readview, sizeof(EBUFFER_T));	MEMCPY(&old_acc->readview, &new_acc->readview, sizeof(EBUFFER_T));	MEMCPY(&new_acc->readview, &temp_ebuf, sizeof(EBUFFER_T));        }    if (EBufferStart(&old_acc->writeview) !=	EBufferStart(&new_acc->writeview)) {        MEMCPY(&temp_ebuf, &old_acc->writeview, sizeof(EBUFFER_T));	MEMCPY(&old_acc->writeview, &new_acc->writeview, sizeof(EBUFFER_T));	MEMCPY(&new_acc->writeview, &temp_ebuf, sizeof(EBUFFER_T));        }    if (EBufferStart(&old_acc->notifyview) !=	EBufferStart(&new_acc->notifyview)) {        MEMCPY(&temp_ebuf, &old_acc->notifyview, sizeof(EBUFFER_T));	MEMCPY(&old_acc->notifyview, &new_acc->notifyview, sizeof(EBUFFER_T));	MEMCPY(&new_acc->notifyview, &temp_ebuf, sizeof(EBUFFER_T));        }    undoproc_set(pktp, vbp, accesstable_update_undo);    }vbp->vb_free_priv = accesstable_set_cleanup;setproc_good(pktp, vbp);return;}/*test:    do value & consistency checks    if failure return error    call test macros    if failure return error    save state for later use    set up cleanup routine (if neccessary (a create request) the cleanup			    routine may need to remove the struct for the list)set:   call set macros   if failure cleanup and return error   perform set (swap or remove data as necessary)   save state for undo   set up undo routine   set up cleanup routinecleanup: (destroy, create, update)    call finished macros    free saved stateundo:    swap or restore information    call undo macrosmacros:from test       from test cleanup  from set        from set    from undoname            pointer            name or pointer none        name or pointerdestroy_test -> destroy_backout -> destroy_hook -> finished -> destroy_undo                destroy_cleanupcreate_test  -> create_backout  -> create_hook              -> create_undo                backout_hookupdate_test  -> update_backout  -> update_hook              -> update_undo                                                    none       cur pointer     cur pointer        cur pointer                 sav pointernew pointer	new pointer	   new pointer                 cur pointergrp                ***             *                  *        *accname information will be available from the old pointer if it isn't 0or the new pointer if the old pointer is 0	test/set	  undo	 cur  new	cur  savdestroy  set   0	 0   setcreate    0   set       set   0update   set  set       set  set*/

⌨️ 快捷键说明

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