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

📄 serial.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: serial.c,v $ * Revision 1.2  2001/11/06 21:20:27  josh * revised new path hacking * * Revision 1.1.1.1  2001/11/05 17:47:43  tneale * Tornado shuffle * * Revision 9.3  2001/01/19 22:22:26  paul * Update copyright. * * Revision 9.2  2000/03/17 00:19:23  meister * Update copyright message * * Revision 9.1  1999/10/26 19:58:37  sar * Modify the handling of cleanups for sub agents that timeout. * We now use the infrastructure lock to mediate access to the * cookies, group lists, groups and handles by the query and timeout * code for the epilogue sub agent scheme.  This allows the cleanups * to occur more quickly than previously and be interleaved with * the queries more. * * Revision 9.0  1998/10/16 22:12:12  sar * Update version stamp to match release * * Revision 8.2  1998/06/05 18:53:21  sra * "#include <foo.h>" => "#include <envoy/h/foo.h>". * * Revision 8.1  1998/02/25 04:52:33  sra * Update copyrights. * * Revision 8.0  1997/11/18 00:56:59  sar * Updated revision to 8.0 * * Revision 7.3  1997/10/22 03:20:04  sar * Modified the installation options for the older sub agent scheme * * Revision 7.2  1997/03/20 06:49:16  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 6.0  1995/05/31  21:48:05  sra * Release 6.0. * * Revision 1.1  1995/04/28  22:46:09  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/snmpdefs.h>#include <wrn/wm/snmp/engine/snmp.h>#if (INSTALL_ENVOY_SNMP_SERIALIZE)INT_32_T Gate_Readers = 0;INT_32_T Gate_Writers = 0;INT_32_T Gate_Running = 0;typedef struct GATEKEEPER_S	{	INT_16_T	     opflag; /* the op type that was deferred */	PTR_T		     data;   /* snmp packet or sub agent reg info */		struct GATEKEEPER_S *next;   /* the next entry in the chain */	GATE_CONTINUE_T	    *rtn;    /* routine to run to start the op */	} GATEKEEPER_T;GATEKEEPER_T *gateroot = 0;/****************************************************************************NAME:  GateKeeper_TestPURPOSE:   Determine if there are any outstanding requests (if readers	   or writers is non zero).  This routine may be used to determine	   if it is safe to modify the database.PARAMETERS: noneRETURNS:    int	 0 Perform the operation		 1 The operation should be deferred****************************************************************************/int  GateKeeper_Test(void){if (Gate_Writers || Gate_Readers)    return(1);return(0);}/****************************************************************************NAME:  GateKeeper_AddPURPOSE:   Determine if the requested operation should be carried out	   immediately or deferred until other operations already under	   way are completed.  If the op is deferred it is attached to	   the deferred list.  If the op is for a snmp packet and isn't	   deferred then a counter (readers or writers) is incremented	   to keep tracke of outstanding operations.  These counters	   must be decremented when the operation completes.	  PARAMETERS:	INT_16_T	request type, snmp packet, sub agent				registration or sub agent cleanup.		PTR_T		Pointer to the data for the operation				snmp packet or sub agent block.RETURNS:	int	 0 Perform the operation			 1 The operation should be deferred			-1 Internal failure****************************************************************************/int  GateKeeper_Add(INT_16_T opflag,		 PTR_T    data,		 GATE_CONTINUE_T *rtn){SNMP_PKT_T *pktp = (SNMP_PKT_T *)data;GATEKEEPER_T *gateentry, **gatep;switch(pktp->pdu_type) {   case GET_REQUEST_PDU:   case GET_NEXT_REQUEST_PDU:   case GET_BULK_REQUEST_PDU:	if (Gate_Writers == 0) {	    pktp->gate_decr = 1;	    Gate_Readers++;	    return(0);	    }	break;    case SET_REQUEST_PDU:	if ((Gate_Writers == 0) && (Gate_Readers == 0)) {	    pktp->gate_decr = 1;	    Gate_Writers++;	    return(0);	    }	break;    }/* Defer the operation */gateentry = (GATEKEEPER_T *)SNMP_memory_alloc(sizeof(GATEKEEPER_T));if (gateentry == 0)    return(-1);gateentry->opflag = opflag;gateentry->data = data;gateentry->rtn = rtn;for (gatep = &gateroot; *gatep; gatep = &(*gatep)->next)    ;gateentry->next = *gatep;*gatep = gateentry;return(1);}/****************************************************************************NAME:  GateRunDeferredsPURPOSE:   Start up any deferred operations	  PARAMETERS: voidRETURNS: void****************************************************************************/void  GateRunDeferreds(void){SNMP_PKT_T *pktp;GATEKEEPER_T *gateentry;if (Gate_Running || Gate_Writers || Gate_Readers)    return;Gate_Running = 1;gateentry = gateroot;while(gateentry) {    if (gateentry->opflag == GATE_SNMP) {	pktp = (SNMP_PKT_T *)gateentry->data;        	switch(pktp->pdu_type) {	    case GET_REQUEST_PDU:	    case GET_NEXT_REQUEST_PDU:	    case GET_BULK_REQUEST_PDU:		if (Gate_Writers) {		    Gate_Running = 0;		    return;		    }		Gate_Readers++;		pktp->gate_decr = 1;		gateentry->rtn(gateentry->data);		break;	    case SET_REQUEST_PDU:		if (Gate_Writers || Gate_Readers) {		    Gate_Running = 0;		    return;		    }		Gate_Writers++;		pktp->gate_decr = 1;		gateentry->rtn(gateentry->data);		break;	    }	}    else {	if (Gate_Writers || Gate_Readers) {	    Gate_Running = 0;	    return;	    }	gateentry->rtn(gateentry->data);	}    gateroot = gateentry->next;    SNMP_memory_free(gateentry);    gateentry = gateroot;    }Gate_Running = 0;return;}/****************************************************************************NAME:  GateDecrementPURPOSE:  Decrement the reader or writer counters when processing of a packet	  completes	  PARAMETERS: SNMP_PKT_T * The packet we are finishingRETURNS: void****************************************************************************/void  GateDecrement(SNMP_PKT_T *pktp){if (pktp->gate_decr) {    if (Gate_Writers)	Gate_Writers = 0;    if (Gate_Readers)	Gate_Readers--;    }}#endif /* (INSTALL_ENVOY_SNMP_SERIALIZE) */

⌨️ 快捷键说明

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