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

📄 view_chk.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
字号:
/* *  Copyright 2000-2005 Wind River Systems, Inc. *  All rights reserved.  Provided under license only. *  Distribution or other use of this software is only *  permitted pursuant to the terms of a license agreement *  from Wind River Systems (and is otherwise prohibited). *  Refer to that license agreement for terms of use. *//* *  Copyright 1995-1997 Epilogue Technology Corporation. *  Copyright 1998 Integrated Systems, Inc. *  All rights reserved. *//* * $Log: view_chk.c,v $ * Revision 1.2  2001/11/06 21:20:35  josh * revised new path hacking * * Revision 1.1.1.1  2001/11/05 17:47:44  tneale * Tornado shuffle * * Revision 9.2  2001/01/19 22:22:31  paul * Update copyright. * * Revision 9.1  2000/03/17 00:19:34  meister * Update copyright message * * Revision 9.0  1998/10/16 22:12:44  sar * Update version stamp to match release * * Revision 8.4  1998/06/21 21:45:15  sar * Update the family finding routine to match the structures. * * Revision 8.3  1998/06/05 18:53:26  sra * "#include <foo.h>" => "#include <envoy/h/foo.h>". * * Revision 8.2  1998/05/24 04:28:03  sar * Added code for rfc2275 views and meshed it in with the code for rfc1445. * While the indexing is different the base match is similar so we share * code where possible.  In the view check code the function was split * to allow the family to be looked up only once per iteration of get, * next or bulk. * * Revision 8.1  1998/02/25 04:52:54  sra * Update copyrights. * * Revision 8.0  1997/11/18 00:57:06  sar * Updated revision to 8.0 * * Revision 7.2  1997/03/20 06:49:25  sra * DFARS-safe copyright text.  Zap! * * Revision 7.1  1997/02/25 10:49:26  sra * Update copyright notice, dust under the bed. * * Revision 7.0  1996/03/18 20:01:11  sar * Updated revision to 7.0 and copyright to 96 * * Revision 1.1  1995/11/11  00:07:30  sar * Initial revision * *//* [clearcase]modification history-------------------01b,18apr05,job  update copyright notices01a,24nov03,job  update copyright information*/#include <wrn/wm/snmp/engine/asn1conf.h>#include <wrn/wm/snmp/engine/asn1.h>#include <wrn/wm/snmp/engine/buffer.h>#include <wrn/wm/snmp/engine/objectid.h>#include <wrn/wm/snmp/engine/snmpdefs.h>#include <wrn/wm/snmp/engine/snmp.h>#include <wrn/wm/snmp/engine/view.h>VIEWINDEX_T *viewroot = 0;/****************************************************************************NAME: SNMP_View_Find_FamilyPURPOSE: Using the view information from pktp try and find the right	 view family.  If we find a family attach it to pktp->view_family,	 otherwise 0 that field.	 This routine has two options one if rfc1445 is installed,	 this uses a single integer as the index.  The other is if	 rfc2275 is installed and it uses a string as an index.PARAMETERS: 	SNMP_PKT_T * packet structure containing the view informationRETURNS:	int 0 if we found a view family, ****************************************************************************/int  SNMP_View_Find_Family(SNMP_PKT_T * pktp){VIEWINDEX_T *vindex;#if (INSTALL_ENVOY_SNMP_RFC1445_VIEWS)bits16_t indx;for(indx = pktp->view_index, vindex = viewroot;    vindex && (vindex->index <= indx);    vindex = vindex->next) {    if (vindex->index == indx) {        pktp->view_family = vindex;	return(0);        }    }#endif#if (INSTALL_ENVOY_SNMP_RFC2275_VIEWS)ALENGTH_T used;for(used = EBufferUsed(&pktp->view_name), vindex = viewroot;    vindex && (vindex->name_len <= used);    vindex = vindex->next) {    if ((vindex->name_len == used) &&	(MEMCMP(vindex->name, EBufferStart(&pktp->view_name), used) == 0)) {        pktp->view_family = vindex;	return(0);        }    }#endifpktp->view_family = 0;return(1);}/****************************************************************************NAME: SNMP_View_Family_CheckPURPOSE: Given a view family pointer and id (object id) determine	 if the object id is in the view.  If the determinate flag         is set then we return a yes or no answer about the given id,         if the indeterminate flag is set we return a yes, no or maybe.         Maybe indicates that there may be instances under the given         id that are yes and some that are no.PARAMETERS: 	SNMP_PKT_T  *	The packet containing the view information	OIDC_T      *	The id to check on	int		The length of the name	int		Determinate or indeterminate check.RETURNS: int	VIEW_INCLUDED      1 if the object is in the view		VIEW_EXCLUDED      2 if it isn't 		VIEW_INDETERMINATE 3 if are not sure, this will only be				     returned if the indeterminate flag				     was set in the arguments.****************************************************************************/int  SNMP_View_Family_Check(SNMP_PKT_T  *pktp,			 OIDC_T      *oidc,			 int	      oidclen,			 int	      option){VIEWLEAF_T  *view;int	     i, j, used, vc = 0;OIDC_T	    *testoidc, *subtree;bits8_t	    *mask;/* If we don't have an view index pointer everything is excluded */if (pktp->view_family == 0)    return(VIEW_EXCLUDED);/* Check the determinate flag, if we are doing a determinate check   we just step through the list until the id we are testing has at   least as many subids as the subtree's.   If we are doing an indeterminate check we have to check all of the   subtrees that are longer than the id to see if any of them    could be an instance of this id.  If some are we need to determine   if we know if all items under the id are the same (included or   excluded). */if (option == VIEW_CHECK_DET) {    for (view = pktp->view_family->masklist; 	(view != 0) && (oidclen < view->subtree.num_components);	 view = view->masknext)        /* no body */        ;    }else {    for (view = pktp->view_family->masklist; 	(view != 0) && (oidclen < view->subtree.num_components);	 view = view->masknext) {        if ((view->status != RS_ACTIVE) || (vc == 1))	    continue;	i = 0;	j = oidclen;	testoidc = oidc;	subtree = view->subtree.component_list;	mask = EBufferStart(&view->mask);	used = EBufferUsed(&view->mask) * 8;	while (i < j) {	    if (*testoidc != *subtree) {	        if (i < used) {		    if (mask[i/8] & (0x80 >> (i%8)))		        break;		    }		else		    break;	        }	    i++;	    testoidc++;	    subtree++;	    }	if (i == j) {	    if (vc == 0)	        vc = view->type;	    else	        if (vc != view->type)		    return(VIEW_INDETERMINATE);	    }        }    }/* so we have checked any views that may be under the subtree   now we check the id itself. */for (; view != 0; view = view->masknext) {    if (view->status != RS_ACTIVE)	continue;    i = 0;    j = view->subtree.num_components;    testoidc = oidc;    subtree = view->subtree.component_list;    mask = EBufferStart(&view->mask);    used = EBufferUsed(&view->mask) * 8;    while (i < j) {	if (*testoidc != *subtree) {	    if (i < used) {	        if (mask[i/8] & (0x80 >> (i%8)))		    break;	        }	    else	        break;	    }	i++;	testoidc++;	subtree++;	}    if (i == j) {        if ((vc == 0) || (vc == view->type))	    return(view->type);	return(VIEW_INDETERMINATE);        }    }if (vc == VIEW_INCLUDED)    return(VIEW_INDETERMINATE);return(VIEW_EXCLUDED);}/****************************************************************************NAME: SNMP_View_CheckPURPOSE: Given a view index and id (object id) find the corresponding	 leaf and determine if the object id is in the view.  If the	 determinate flag is set then we return a yes or no answer 	 about the given id, if the indeterminate flag is set we	 return a yes, no or maybe.  Maybe indicates that there may be	 instances under the given id that are yes and some that are	 no.PARAMETERS: 	SNMP_PKT_T *	The snmp packet structure 	OIDC_T     *	The id to check on	int		The length of the name	int		Determinate or indeterminate check.RETURNS: int	VIEW_INCLUDED      1 if the object is in the view		VIEW_EXCLUDED      2 if it isn't 		VIEW_INDETERMINATE 3 if are not sure, this will only be				     returned if the indeterminate flag				     was set in the arguments.****************************************************************************/int  SNMP_View_Check(SNMP_PKT_T *pktp,		  OIDC_T     *oidc,		  int	      oidclen,		  int	      option){if (SNMP_View_Find_Family(pktp))    return(VIEW_EXCLUDED);else    return(SNMP_View_Family_Check(pktp, oidc, oidclen, option));}

⌨️ 快捷键说明

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