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

📄 libfuncs.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: libfuncs.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:50  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:51  sar * Update version stamp to match release * * Revision 8.2  1998/06/05 18:53:28  sra * "#include <foo.h>" => "#include <envoy/h/foo.h>". * * Revision 8.1  1998/02/25 04:53:09  sra * Update copyrights. * * Revision 8.0  1997/11/18 00:57:08  sar * Updated revision to 8.0 * * Revision 7.2  1997/03/20 06:49:32  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:49:13  sra * Release 6.0. * * Revision 5.3  1995/05/05  23:08:18  sar * Added new routines using the async method routine api. * * Revision 5.2  1994/10/28  19:38:12  sar * Added a line to set the view_index to 1 while doing community validation. * * Revision 5.1  1994/07/19  19:29:32  sar * Modify some conditional code to use ENVOY_SNMP_GROUP_V[12] instead of SGRP. * * 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.1  1993/06/09  20:31:43  sar * updated for use with v2, also corrected call to get_centasecs * (it was using an unsigned int instaed of an oidc). * * Revision 3.0  1992/04/03  19:54:08  dab * Release 3.0 * * Revision 1.1  92/03/31  16:43:39  dab * Initial revision *  *  *    Rev 2.1   07 Jun 1990  0:24:20 * Put correct types on the get_string and get_ipaddress routines. *  *    Rev 2.0   31 Mar 1990 15:14:38 * Release 2.00 *  *    Rev 1.6   27 Apr 1989 15:56:36 * Removed unused variables *  *    Rev 1.5   17 Mar 1989 22:50:16 * Memory allocation now fails if an attempt is made to allocate zero bytes. *  *    Rev 1.4   17 Mar 1989 21:41:38 * Calls to memcpy/memset protected against zero lengths *  *    Rev 1.3   11 Jan 1989 13:24:32 *  *    Rev 1.2   10 Oct 1988 21:49:36 * Source reorganization *  *    Rev 1.1   14 Sep 1988 17:57:10 * Moved includes of system include files into libfuncs.h. *  *    Rev 1.0   12 Sep 1988 10:47:00 * 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/buffer.h>#include <wrn/wm/snmp/engine/objectid.h>#include <wrn/wm/snmp/engine/snmp.h>#include <wrn/wm/snmp/engine/snmpstat.h>#include <wrn/wm/snmp/engine/auxfuncs.h>#include <wrn/wm/snmp/engine/snmpdefs.h>#include "snmpvars.h"void gen_auth_fail_trap(void);UINT_32_T clicks_to_cents(unsigned long ticks);/********************************************************************** validate_SNMP_community -- Check an operation against the community name.	 Get class operations can use either the set or get community.	 Set operations may use only the set community.	 	 The parameters to this procedure are:		 SNMP_PKT_T *	The received packet (decoded format)		 SNMPADDR_T *	Source of the packet		 SNMPADDR_T *	Destination of the packet (most likely				the address of the machine on which this				code is running.)	This procedure should return 0 if happy with the community and	1 if not.	 This routine may hang additional data onto the "private" field of	 the packet structure.	 The user will be given the opportinity to release that memory via	 release_private(). **********************************************************************/int  validate_SNMP_community(SNMP_PKT_T *rp,			  SNMPADDR_T *pktsrc,			  SNMPADDR_T *pktdst){  static UINT_16_T  lcl_ident_source = 0;  unsigned int	pktcom_length;  rp->mib_view = 0xFF;  rp->lcl_ident = lcl_ident_source++;  rp->user_private = 0;  MEMCPY(&(rp->pkt_src), pktsrc, sizeof(SNMPADDR_T));  MEMCPY(&(rp->pkt_dst), pktdst, sizeof(SNMPADDR_T));  rp->view_index = 1;    pktcom_length = EBufferUsed(&(rp->community));  /* Give Get & GetNext pdus a chance at both the get and set communities */  if (rp->pdu_type != SET_REQUEST_PDU) { /* Check the "get" community */    if ((strlen(snmp_get_request_community) == pktcom_length) &&	(memcmp(snmp_get_request_community,		(char *)rp->community.start_bp, pktcom_length) == 0))      return 0;  }  /* Check the "set" community */  if ((strlen(snmp_set_request_community) == pktcom_length) &&      (memcmp(snmp_set_request_community, (char *)rp->community.start_bp,	      pktcom_length) == 0))    return 0;  /* Things just didn't work out... */#if (INSTALL_ENVOY_SNMP_GROUP_V1 || INSTALL_ENVOY_SNMP_GROUP_V2)  inc_counter(snmp_stats.snmpInBadCommunityNames);#endif  gen_auth_fail_trap();  return 1;}/********************************************************************** gen_auth_fail_trap -- Issue an authentication failure trap. **********************************************************************/void  gen_auth_fail_trap(){#if (INSTALL_ENVOY_SNMP_GROUP_V1)  inc_counter(snmp_stats.snmpOutPkts);#endif}/*********************************************************************** * *  Convert system "ticks" into hundredths of seconds. *  (On an IBM PC or PC/AT, ticks occur at the system clock rate of *  (approximately) 18.02 times per second.) * **********************************************************************/UINT_32_T  clicks_to_cents(unsigned long ticks){  /* Each tick is 55.4939 milliseconds or 5.43939 centaseconds */  /* The following is a crude computation, but it seems to have run less*/  /* than 2% fast.							*/  /* (ticks * 5) + (ticks >> 1)						*/  return ((ticks << 2) + ticks) + (ticks >> 1);}/*********************************************************************** * *  Gather a time value maintained by the system in clicks. * **********************************************************************/UINT_32_T  get_centasecs_from_clicks(OIDC_T	  lastmatch,			    int		  tcount,			    unsigned int *tlist,			    char	 *cookie){  return clicks_to_cents(*(unsigned long *)cookie);}void  get_centasecs_async(OIDC_T		 lastmatch,		      int		 tcount,		      OIDC_T		*tlist,		      SNMP_PKT_T	*pktp,		      VB_T		*vbp){/* Test the instance qualifier, we must have one subid   with a value of 0 */if ((tcount != 1) || (*tlist != 0))    getproc_nosuchins(pktp, vbp);else    getproc_got_uint32(pktp, vbp,		       clicks_to_cents(*(unsigned long*)VB_TO_COOKIE(vbp)),		       vbp->vb_ml.ml_leaf->expected_tag);return;}void  no_next_async(OIDC_T		 lastmatch,		int		 tcount,		OIDC_T		*tlist,		SNMP_PKT_T	*pktp,		VB_T		*vbp){nextproc_no_next(pktp, vbp);}

⌨️ 快捷键说明

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