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

📄 attable.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 1988-1997 Epilogue Technology Corporation. *  Copyright 1998 Integrated Systems, Inc. *  All rights reserved. *//* * $Log: attable.c,v $ * Revision 1.2  2001/11/06 21:20:36  josh * revised new path hacking * * Revision 1.1.1.1  2001/11/05 17:47:45  tneale * Tornado shuffle * * Revision 9.2  2000/03/17 00:19:48  meister * Update copyright message * * Revision 9.1  1999/05/24 20:12:21  josh * 'compc' and 'compl' have been replaced by 'tcount' and 'tlist' * to avoid C++ compiler errors. * * Revision 9.0  1998/10/16 22:12:47  sar * Update version stamp to match release * * Revision 8.2  1998/06/05 18:53:27  sra * "#include <foo.h>" => "#include <envoy/h/foo.h>". * * Revision 8.1  1998/02/25 04:53:01  sra * Update copyrights. * * Revision 8.0  1997/11/18 00:57:07  sar * Updated revision to 8.0 * * Revision 7.2  1997/03/20 06:49:28  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:24:05  sar * Updated rev to 7.0 and copyright to 96 * * Revision 6.1  1995/11/01  00:38:58  sar * Removed definition of then * Added pp style argument lists * * Revision 6.0  1995/05/31  21:48:29  sra * Release 6.0. * * Revision 5.1  1995/05/05  23:06:58  sar * Added new routines using the async method routine api. * * Revision 5.0  1994/05/16  17:21:18  sar * Updated revision to 5.0 and copyright to include 1994 * * Revision 4.0  1993/06/24  17:53:56  sar * Updated rev to 4.0 and copyright to 93 * * Revision 3.0  1992/04/03  19:54:08  dab * Release 3.0 * * Revision 1.1  92/03/31  16:43:33  dab * Initial revision *  *  *    Rev 2.0   31 Mar 1990 15:14:26 * Release 2.00 *  *    Rev 1.1   27 Apr 1989 15:56:12 * Removed unused variables *  *    Rev 1.0   10 Oct 1988 21:48:46 * Initial revision.*//* [clearcase]modification history-------------------01b,19apr05,job  update copyright notices01a,24nov03,job  update copyright information*/#include <wrn/wm/snmp/engine/asn1.h>#include <wrn/wm/snmp/engine/decode.h>#include <wrn/wm/snmp/engine/snmp.h>#include <wrn/wm/snmp/engine/mib.h>#include "snmpvars.h"	/* for local definitions *//****************************************************************************     THIS MODULE CONTAINS ROUTINES TO ACCESS ADDRESS TRANSLATION TABLES****************************************************************************//**************************************************************************** ADDRESS TRANSLATION TABLE ACCESS ROUTINES The instance, given by parameters "tcount" and "tlist" consists of six object id components, i.1.a.b.c.d, of which i is the interface number and a.b.c.d the IP address of the target object.****************************************************************************//****************************************************************************NAME:  attable_testPURPOSE:  Test whether a given object exists in the address translation tablePARAMETERS:	int		TEST_SET or TEST_GET indicating what type of			access is intended.	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	char *		User's cookie, passed unchanged from the LEAF macro			in the mib.cRETURNS:  int		0 if the attribute is accessable.			-1 if the attribute is not accessable.****************************************************************************//*ARGSUSED*/int  attable_test(int     form,	   /* See TEST_SET & TEST_GET in mib.h	*/	       OIDC_T  last_match, /* Last component matched */	       int     tcount,	       OIDC_T *tlist,	       char   *cookie){/* There must be exactly 6 unused components */if (tcount != 6)   return -1;/* The second component must have the value of 1 */if (tlist[1] != 1)   return -1;return 0;}/****************************************************************************NAME:  attable_nextPURPOSE:  Locate the "next" object in the address translation tablePARAMETERS:	OIDC_T		Last component of the object id leading to 			the leaf node in the MIB.  This identifies			the particular "attribute" we want in the table.			The following values give an example:				1 - atIfIndex				2 - atPhysAddress				3 - atNetAddress	int		Number of components in the yet unused part of the			object identifier	OIDC_T *	Yet unused part of the object identifier	OIDC_T *	Start of an area in which the object instance part			of the name of the "next" object should be			constructed.	char *		User's cookie, passed unchanged from the LEAF macro			in the mib.cRETURNS:  int		>0 indicates how many object identifiers have			been placed in the result list.			0 if there is no "next" in the tableThis routine's job is to use the target object instance, representedby variables tcount and tlist, to ascertain whether there is a "next"entry in the table.  If there is, the object instance of that elementis constructed in the return list area (rlist) and the number of elementsreturned.  If there is no "next" a zero is returned.It is possible that the target object instance may be empty (i.e.tcount == 0) or incomplete (i.e. tcount < sizeof(normal object instance)).If tcount == 0, the first object in the table should be returned.The term "object instance" refers to that portion of an object identifierused by SNMP to identify a particular instance of a tabular variable.****************************************************************************//*ARGSUSED*/int  attable_next(OIDC_T  last_match,	       int     tcount,	       OIDC_T *tlist,	       OIDC_T *rlist,	       char   *cookie){return 0;}/****************************************************************************NAME:  attable_getintPURPOSE:  Obtain an Integer type parameter from the address translation table.	  The integer parameters in this table (and their lastmatch value)	  are:		1 - atIfIndex	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	char *		User's cookie, passed unchanged from the LEAF macro			in the mib.cRETURNS:  INT_32_T	The value of the parameter.****************************************************************************//*ARGSUSED*/INT_32_T  attable_getint(OIDC_T  last_match,		 int     tcount,		 OIDC_T *tlist,		 char   *cookie){return (INT_32_T)*((int *)cookie);	/* TEMPORARY */}/****************************************************************************NAME:  attable_getipaddrPURPOSE:  Obtain an IpAddress type parameter from the address translation	  table.	  The IpAddress parameters in this table (and their lastmatch value)	  are:		  3 - atNetAddress	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	char *		User's cookie, passed unchanged from the LEAF macro			in the mib.cRETURNS:  OCTET_T *	Pointer to a 4 byte long area in which the IP			address is found.  The address bytes must be in			standard network order.NOTE:	This routine should really retrieve arbitrary OCTET STRING values,	since there are other protocol stacks besides IP (the devil you say!).****************************************************************************//*ARGSUSED*/OCTET_T *  attable_getipaddr(OIDC_T  last_match,		    int     tcount,		    OIDC_T *tlist,		    char   *cookie){return (OCTET_T *)cookie;	/* TEMPORARY */}/****************************************************************************NAME:  attable_getstringPURPOSE:  Obtain an OCTET STRING type parameter from the address translation	  table.  The parameters of this type in this table (and their	  lastmatch value) are:		  2 - atPhysAddress	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	char *		User's cookie, passed unchanged from the LEAF macro			in the mib.c	int *		Receiver for the size of the resulting value, in			bytes.RETURNS:  OCTET_T *	Pointer to a static data area in which the resulting			value is to be found.****************************************************************************//*ARGSUSED*/OCTET_T *  attable_getstring(OIDC_T  last_match,		    int     tcount,		    OIDC_T *tlist,		    char   *cookie,		    int    *lengthp){*lengthp = (int)strlen((char *)cookie);return (OCTET_T *)cookie;	/* TEMPORARY */}/****************************************************************************NAME:  attable_setintPURPOSE:  Alter an Integer type parameter within the address translation table.	  The Integer parameters in this table (and their lastmatch value)	  are:		1 - atIfIndex	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	char *		User's cookie, passed unchanged from the LEAF macro			in the mib.c	INT_32_T	New value to be set.RETURNS:  None -- void procedure.****************************************************************************//*ARGSUSED*/void  attable_setint(OIDC_T    last_match,		 int       tcount,		 OIDC_T   *tlist,		 char     *cookie,		 INT_32_T  value){}/****************************************************************************NAME:  attable_setstringPURPOSE:  Alter an Octet string type parameter within the address translation	  table.  The parameters in this table of type Octet string (and their	  lastmatch value) are:		2 - atPhysAddress		3 - atNetAddressPARAMETERS:	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	char *		User's cookie, passed unchanged from the LEAF macro			in the mib.c	char *		Pointer to the new value to be assigned.	int		Length of the new value at the above pointer.RETURNS:  None -- void procedure.****************************************************************************//*ARGSUSED*/void  attable_setstring(OIDC_T  last_match,		    int	    tcount,		    OIDC_T *tlist,		    char   *cookie,		    char   *value,		    int	    length){switch(last_match)   {   case 2:	/* atPhysAddress */	break;   case 3:	/* atNetAddress */	break;  }}void  attable_test_async(OIDC_T	 lastmatch,		     int	 tcount,		     OIDC_T	*tlist,		     SNMP_PKT_T	*pktp,		     VB_T	*vbp){/* There must be exactly 6 unused component */if ((tcount != 6) || (tlist[1] != 1))    testproc_error(pktp, vbp, NO_CREATION);else    testproc_good(pktp, vbp);}void  attable_get_async(OIDC_T	 lastmatch,		    int		 tcount,		    OIDC_T	*tlist,		    SNMP_PKT_T	*pktp,		    VB_T	*vbp){/* There must be exactly 6 unused component */if ((tcount != 6) || (tlist[1] != 1)) {    getproc_nosuchins(pktp, vbp);    return;    }switch(lastmatch) {    case 1:	/* atifindex */	getproc_got_int32(pktp, vbp, *(INT_32_T *)(VB_TO_COOKIE(vbp)));	break;   case 2:	/* atPhysAddress */	getproc_got_string(pktp, vbp, strlen((char *)(VB_TO_COOKIE(vbp))),			   (bits8_t *)(VB_TO_COOKIE(vbp)), 0, 			   vbp->vb_ml.ml_leaf->expected_tag);	break;   case 3:	/* atNetAddress */	getproc_got_ip_address(pktp, vbp, *(UINT_32_T *)(VB_TO_COOKIE(vbp)));	break;    }}

⌨️ 快捷键说明

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