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

📄 iftable.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: iftable.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:49  meister * Update copyright message * * Revision 9.1  1999/05/24 20:12:22  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:04  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:29  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 localio.h, buffer.h and decode.h * added pp style argument lists * * Revision 6.0  1995/05/31  21:48:31  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:37  dab * Initial revision *  *  *    Rev 2.0   31 Mar 1990 15:14:26 * Release 2.00 *  *    Rev 1.2   14 Dec 1989 16:00:56 * Added support for Borland Turbo C compiler *  *    Rev 1.1   27 Apr 1989 15:56:16 * Removed unused variables *  *    Rev 1.0   10 Oct 1988 21:48:48 * 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/snmp.h>#include <wrn/wm/snmp/engine/mib.h>#include "snmpvars.h"	/* for local definitions *//****************************************************************************     THIS MODULE CONTAINS ROUTINES TO ACCESS THE INTERFACE TABLE****************************************************************************//**************************************************************************** INTERFACE TABLE ACCESS ROUTINES The instance, given by parameters "tcount" and "tlist" consists of one object id component, i, where i is the interface number of the target object.****************************************************************************//****************************************************************************NAME:  iftable_testPURPOSE:  Test whether a given object exists in the interface 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*//*lint -e715	*/int  iftable_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 1 unused component */if (tcount != 1)     return -1;return 0;}/*lint +e715	*//****************************************************************************NAME:  iftable_nextPURPOSE:  Locate the "next" object in the interface 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 - ifIndex				 2 - ifDescr				 3 - ifType				 4 - ifMtu				 5 - ifSpeed				 6 - ifPhysAddress				 7 - ifAdminStatus				 8 - ifOperStatus				 9 - ifLastChange				10 - ifInOctets				11 - ifInUcastPkts				12 - ifInNUcastPkts				13 - ifInDiscards				14 - ifInErrors				15 - ifInUnknownProtos				16 - ifOutOctets				17 - ifOutUcastPkts				18 - ifOutNUcastPkts				19 - ifOutDiscards				20 - ifOutErrors				21 - ifOutQLen	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*//*lint -e715	*/intiftable_next(OIDC_T   last_match, /* Last component matched */	     int      tcount,	     OIDC_T  *tlist,	     OIDC_T  *rlist,	     char    *cookie){return 0;}/*lint +e715	*//****************************************************************************NAME:  iftable_getintPURPOSE:  Obtain an Integer type parameter from the interface table.	  The Integer parameters in this table (and their lastmatch value)	  are:		 1 - ifIndex		 3 - ifType		 4 - ifMtu		 5 - ifSpeed		 7 - ifAdminStatus		 8 - ifOperStatus		 9 - ifLastChange		10 - ifInOctets		11 - ifInUcastPkts		12 - ifInNUcastPkts		13 - ifInDiscards		14 - ifInErrors		15 - ifInUnknownProtos		16 - ifOutOctets		17 - ifOutUcastPkts		18 - ifOutNUcastPkts		19 - ifOutDiscards		20 - ifOutErrors		21 - ifOutQLen	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*//*lint -e715	*/INT_32_T  iftable_getint(OIDC_T	 last_match,		 int	 tcount,		 OIDC_T	*tlist,		 char	*cookie){switch(last_match)   {   case  1:	/* ifIndex */   case  3:	/* ifType */   case  4:	/* ifMtu */   case  5:	/* ifSpeed */   case  7:	/* ifAdminStatus */   case  8:	/* ifOperStatus */   case  9:	/* ifLastChange */   case 10:	/* ifInOctets */   case 11:	/* ifInUcastPkts */   case 12:	/* ifInNUcastPkts */   case 13:	/* ifInDiscards */   case 14:	/* ifInErrors */   case 15:	/* ifInUnknownProtos */   case 16:	/* ifOutOctets */   case 17:	/* ifOutUcastPkts */   case 18:	/* ifOutNUcastPkts */   case 19:	/* ifOutDiscards */   case 20:	/* ifOutErrors */   case 21:	/* ifOutQLen */	return (INT_32_T)*((int *)cookie);	/* TEMPORARY */   	}return 0;}/*lint +e715	*//****************************************************************************NAME:  iftable_getstringPURPOSE:  Obtain an OCTET STRING type parameter from the interface	  table.  The parameters of this type in this table (and their	  lastmatch value) are:		 2 - ifDescr		 6 - ifPhysAddress	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*//*lint -e715	*/OCTET_T *  iftable_getstring(OIDC_T  last_match,		    int	    tcount,		    OIDC_T *tlist,		    char   *cookie,		    int	   *lengthp){switch(last_match)   {   case 2:	/* ifDescr */   case 6:	/* ifPhysAddress */       *lengthp = (int)strlen((char *)cookie);       return (OCTET_T *)cookie;	/* TEMPORARY */   }*lengthp = 0;return 0;}/*lint +e715	*//****************************************************************************NAME:  iftable_setintPURPOSE:  Alter an Integer type parameter within the interface table.	  The Integer parameters in this table (and their lastmatch value)	  are:		 7 - ifAdminStatus	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*//*lint -e715	*/void  iftable_setint(OIDC_T	    last_match,		 int	    tcount,		 OIDC_T	   *tlist,		 char	   *cookie,		 INT_32_T   value){switch(last_match)   {   case  7:	/* ifAdminStatus */       break;   }}void  iftable_test_async(OIDC_T	 lastmatch,		     int	 tcount,		     OIDC_T	*tlist,		     SNMP_PKT_T	*pktp,		     VB_T	*vbp){/* There must be exactly 1 unused component */if (tcount != 1)    testproc_error(pktp, vbp, NO_CREATION);else    testproc_good(pktp, vbp);}void  iftable_get_async(OIDC_T	 lastmatch,		    int		 tcount,		    OIDC_T	*tlist,		    SNMP_PKT_T	*pktp,		    VB_T	*vbp){/* There must be exactly 1 unused component */if (tcount != 1) {    getproc_nosuchins(pktp, vbp);    return;    }switch(lastmatch)   {    case  1:	/* ifIndex */    case  3:	/* ifType */    case  4:	/* ifMtu */    case  5:	/* ifSpeed */    case  7:	/* ifAdminStatus */    case  8:	/* ifOperStatus */    case  9:	/* ifLastChange */    case 10:	/* ifInOctets */    case 11:	/* ifInUcastPkts */    case 12:	/* ifInNUcastPkts */    case 13:	/* ifInDiscards */    case 14:	/* ifInErrors */    case 15:	/* ifInUnknownProtos */    case 16:	/* ifOutOctets */    case 17:	/* ifOutUcastPkts */    case 18:	/* ifOutNUcastPkts */    case 19:	/* ifOutDiscards */    case 20:	/* ifOutErrors */    case 21:	/* ifOutQLen */	getproc_got_int32(pktp, vbp, *(INT_32_T *)(VB_TO_COOKIE(vbp)));	break;    case 2:	/* ifDescr */    case 6:	/* ifPhysAddress */	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;    }}/*lint +e715	*/

⌨️ 快捷键说明

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