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

📄 asy_util.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 2 页
字号:
/* *  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: asy_util.c,v $ * Revision 1.2  2001/11/06 21:20:01  josh * revised new path hacking * * Revision 1.1.1.1  2001/11/05 17:47:41  tneale * Tornado shuffle * * Revision 9.5  2001/04/11 20:42:57  josh * merge from the kingfisher branch * * Revision 9.4  2001/01/19 22:22:15  paul * Update copyright. * * Revision 9.3  2000/06/13 21:03:03  josh * minor patch to include lists * * Revision 9.2.2.3  2001/03/12 22:08:06  tneale * Updated copyright * * Revision 9.2.2.2  2001/02/21 21:27:10  josh * updating the error index in the function equivalents of *_error() * * Revision 9.2.2.1  2000/09/20 20:07:42  josh * adding an include file to make the build clean * * Revision 9.2  2000/03/17 00:18:50  meister * Update copyright message * * Revision 9.1  2000/03/08 20:06:14  josh * adding functions to Envoy that replace getproc_got_*() macros. * * Revision 9.0  1998/10/16 22:10:42  sar * Update version stamp to match release * * Revision 8.7  1998/09/04 14:33:12  sar * Added some casts to try and keep compilers happy * * Revision 8.6  1998/06/22 03:34:25  sar * Cast some things to unsigned ints to try and keep compilers happy * * Revision 8.5  1998/06/17 02:01:56  sar * Hnadle 0 length strings * * Revision 8.4  1998/06/09 21:46:35  sar * Cleaned up some code that might have called alloc or memcmp with * 0 lenght strings * * Revision 8.3  1998/06/05 18:53:05  sra * "#include <foo.h>" => "#include <envoy/h/foo.h>". * * Revision 8.2  1998/05/24 04:30:13  sar * added nextproc_next_instance_string to make putting strings into * oids more efficient * * Revision 8.1  1998/02/25 04:51:04  sra * Update copyrights. * * Revision 8.0  1997/11/18 00:56:36  sar * Updated revision to 8.0 * * Revision 7.3  1997/10/16 23:49:22  sar * created testproc_error to allow for changing which error * to return depending on the type of the packet * * Revision 7.2  1997/03/20 06:48:35  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:47:01  sra * Release 6.0. * * Revision 1.4  1995/05/08  20:32:04  sar * changed the args to nextproc_next_instance & getproc_got_object_id * to make compilers happier. * * Revision 1.3  1995/04/28  23:12:28  sar * Dropped the static/dynamice flag in the call to nextproc_next_instance * * Revision 1.2  1995/04/18  21:13:44  sar * Removed an unnecessary break. * * Revision 1.1  1995/03/21  00:09:23  sar * Initial revision * * Initial revision. *//* [clearcase]modification history-------------------01c,18apr05,job  update copyright notices01b,02jul04,job  add getproc_got_octet_string() function01a,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/snmpdefs.h>#include <wrn/wm/snmp/engine/vbdefs.h>#include <wrn/wm/snmp/engine/snmp.h>#include <wrn/wm/snmp/engine/objectid.h>#if !(INSTALL_ENVOY_SNMP_UTIL_MACROS)/****************************************************************************NAME:  getproc_started PURPOSE:  Indicate that getproc for the specified varbind          has been started and should not be started again.PARAMETERS:      SNMP_PKT_T *    the SNMP packet      VB_T *          the varbind being processedRETURNS:  Nothing****************************************************************************/void   getproc_started(SNMP_PKT_T *pktp,                  VB_T       *vbp) {vbp->vb_flags |= VFLAG_GET_STARTED;}/****************************************************************************NAME:  getproc_good PURPOSE:  Indicates successful completion of a getproc.PARAMETERS:      SNMP_PKT_T *    the SNMP packet      VB_T *          the varbind being processedRETURNS:  Nothing****************************************************************************/void   getproc_good(SNMP_PKT_T *  pktp,               VB_T *        vbp){vbp->vb_flags |= VFLAG_GET_DONE;}/****************************************************************************NAME:  getproc_error PURPOSE:  Indicates that a getproc encountered an error.PARAMETERS:      SNMP_PKT_T *    the SNMP packet      VB_T *          the varbind being processed      bits32_t        the error codeRETURNS:  Nothing****************************************************************************/void   getproc_error(SNMP_PKT_T *pktp,		VB_T       *vbp,		INT_32_T    error){pktp->pdu.std_pdu.error_status = error;pktp->pdu.std_pdu.error_index = vbp_to_index_error(pktp, vbp, 1);vbp->vb_flags |= VFLAG_GET_DONE;}#endif /* INSTALL_ENVOY_SNMP_UTIL_MACROS */ /****************************************************************************NAME:  getproc_nosuchinsPURPOSE:  Routine to tag a variable as either a nosuchins exception in v2	  or a nosuchobject error in v1.PARAMETERS:	SNMP_PKT_T *	The decoded NEXT/BULK PDU	VB_T	   *	The var bind to attach the string toRETURNS: void****************************************************************************/void  getproc_nosuchins(SNMP_PKT_T	*pktp,		    VB_T	*vbp){if (pktp->snmp_version == SNMP_VERSION_1) {    pktp->pdu.std_pdu.error_status = NO_SUCH_NAME;    pktp->pdu.std_pdu.error_index = vbp_to_index(pktp, vbp) + 1;    }else    vbp->vb_data_flags_n_type = VT_NOSUCHINS;vbp->vb_flags |= VFLAG_GET_DONE;}/****************************************************************************NAME:  getproc_got_object_idPURPOSE:  Routine to attache an object id to a var bind.PARAMETERS:	SNMP_PKT_T *	The decoded NEXT/BULK PDU	VB_T	   *	The var bind to attach the string to	size_t		The length of the string	OIDC_T	   *	The string to attach	int		The dynamic flag static (0), dynamic (1)RETURNS: void****************************************************************************/void  getproc_got_object_id(SNMP_PKT_T	*pktp,			VB_T		*vbp,			int		 sz,			OIDC_T		*oidc,			int		 dynamic){vbp->vb_flags |= VFLAG_GET_DONE;vbp->vb_data_flags_n_type = VT_OBJECT;if (dynamic) {    vbp->value_u.v_object.num_components = sz;    vbp->value_u.v_object.component_list = oidc;    }else {    if (build_object_id(sz, oidc, &(vbp->value_u.v_object)))	/* An error occurred trying to copy the object id, probably	   we couldn't allocate memory, so we set up for an error return */	pktp->pdu.std_pdu.error_status = GEN_ERR;    }}#if !(INSTALL_ENVOY_SNMP_UTIL_MACROS)/****************************************************************************NAME:  nextproc_started PURPOSE:  Indicates nextproc has begun for the specified varbind.PARAMETERS:      SNMP_PKT_T *    the SNMP packet      VB_T *          the varbind being processedRETURNS:  Nothing****************************************************************************/void   nextproc_started(SNMP_PKT_T *pktp,		   VB_T       *vbp){vbp->vb_flags |= VFLAG_NEXT_STARTED;}/****************************************************************************NAME:  nextproc_good PURPOSE:  Indicates nextproc has successfully completed.PARAMETERS:      SNMP_PKT_T *    the SNMP packet      VB_T *          the varbind being processedRETURNS:  Nothing****************************************************************************/void   nextproc_good(SNMP_PKT_T  *pktp,		VB_T        *vbp){vbp->vb_flags |= VFLAG_NEXT_DONE;}/****************************************************************************NAME:  nextproc_no_nextPURPOSE:  Indicates there exists no next instance.PARAMETERS:      SNMP_PKT_T *    the SNMP packet      VB_T *          the varbind being processedRETURNS:  Nothing****************************************************************************/void   nextproc_no_next(SNMP_PKT_T *pktp,		   VB_T       *vbp){vbp->vb_flags |= (VFLAG_NEXT_DONE | VFLAG_NEXT_REDO);}/****************************************************************************NAME:  nextproc_errorPURPOSE:  Indicates nexproc encountered an error and cannot retrieve          a next instance for the requested varbind.PARAMETERS:      SNMP_PKT_T *    the SNMP packet      VB_T *          the varbind being processed      INT_32_T        errorRETURNS:  Nothing****************************************************************************/void   nextproc_error(SNMP_PKT_T *pktp,		 VB_T       *vbp,		 INT_32_T    error){pktp->pdu.std_pdu.error_status = error;pktp->pdu.std_pdu.error_index = vbp_to_index_error(pktp, vbp, 1);vbp->vb_flags |= VFLAG_NEXT_DONE;}#endif /* INSTALL_ENVOY_SNMP_UTIL_MACROS *//****************************************************************************NAME:  nextproc_next_instancePURPOSE:  Routine to attache a string to a var bind.	  This routine assumes that the remaining object information	  in the mib_loc structure has been filled in (done by	  find_next_object).  It further assumes that the oidc pointed	  to by the remaining block is a part of the  oidc in the	  vb_obj_id block.  So if the new id is shorter or equal to	  the remaining oid we don't need to allocate anything	  otherwise we need to allocate space and copy the old object	  and the new instance into that space then attache it correctly	  and clean up.	  PARAMETERS:	SNMP_PKT_T *	The decoded NEXT/BULK PDU	VB_T	   *	The var bind to attach the string to	size_t		The length of the string	OIDC_T	   *	The string to attachRETURNS: void****************************************************************************/void  nextproc_next_instance(SNMP_PKT_T	*pktp,			 VB_T		*vbp,			 int		 sz,			 OIDC_T		*oidc){int nlen, olen;OIDC_T *noidc;OBJ_ID_T *robj;if (sz == 0)    return;robj = &vbp->vb_ml.ml_remaining_objid;olen = vbp->vb_obj_id.num_components - robj->num_components;nlen = olen + sz;if (sz > robj->num_components) {    if ((noidc = (OIDC_T *)SNMP_memory_alloc((unsigned int)					     (nlen * sizeof(OIDC_T)))) == 0) {	pktp->pdu.std_pdu.error_status = GEN_ERR;	vbp->vb_flags |= VFLAG_NEXT_DONE;	return;        }    MEMCPY(noidc, vbp->vb_obj_id.component_list, olen * sizeof(OIDC_T));    Clean_Obj_ID(&vbp->vb_obj_id);    vbp->vb_obj_id.component_list = noidc;    robj->component_list = noidc + olen;    }MEMCPY(robj->component_list, oidc, sz * sizeof(OIDC_T));robj->num_components = sz;vbp->vb_obj_id.num_components = nlen;}/****************************************************************************NAME:  nextproc_next_instance_stringPURPOSE:  Routine to attach instance info to an object id,	  the instance info is in the form of a string and	  is converted to an object id on the fly.	  This routine assumes that the remaining object information	  in the mib_loc structure has been filled in (done by	  find_next_object).  It further assumes that the oidc pointed	  to by the remaining block is a part of the  oidc in the	  vb_obj_id block.  So if the new id is shorter or equal to	  the remaining oid we don't need to allocate anything	  otherwise we need to allocate space and copy the old object	  and the new instance into that space then attache it correctly	  and clean up.	  PARAMETERS:	SNMP_PKT_T *	The decoded NEXT/BULK PDU	VB_T	   *	The var bind to attach the string to	ALENGTH_T 	The length of the string	bits8_T	   *	The string to attach	int		implied flag - 0 means that the string length			should be placed in the first elementRETURNS: void****************************************************************************/void  nextproc_next_instance_string(SNMP_PKT_T	*pktp,				VB_T		*vbp,				ALENGTH_T       str_len,				bits8_t        *str_buf,				int             imp_flag){int nlen, olen;OIDC_T *noidc;OBJ_ID_T *robj;if ((str_len == 0) && imp_flag)    return;/* if we have a non-implied instance bump the str_len by 1   for the length, don't foget to reset it before we write   the string itself */if (imp_flag == 0)    str_len++;robj = &vbp->vb_ml.ml_remaining_objid;olen = vbp->vb_obj_id.num_components - robj->num_components;nlen = olen + str_len;if ((sbits32_t)str_len > (sbits32_t)robj->num_components) {    if ((noidc = (OIDC_T *)SNMP_memory_alloc((unsigned int)					     (nlen * sizeof(OIDC_T)))) == 0) {	pktp->pdu.std_pdu.error_status = GEN_ERR;	vbp->vb_flags |= VFLAG_NEXT_DONE;	return;        }    MEMCPY(noidc, vbp->vb_obj_id.component_list, olen * sizeof(OIDC_T));    Clean_Obj_ID(&vbp->vb_obj_id);    vbp->vb_obj_id.component_list = noidc;    robj->component_list = noidc + olen;    }noidc = robj->component_list;robj->num_components = str_len;/* if we have a non-implied instance we reset str_len and stash   it into the first subid */if (imp_flag == 0) {    str_len--;    *noidc++ = str_len;    }for(; str_len; str_len--, noidc++, str_buf++)    *noidc = *str_buf;vbp->vb_obj_id.num_components = nlen;}#if !(INSTALL_ENVOY_SNMP_UTIL_MACROS) /****************************************************************************NAME: testproc_startedPURPOSE:  Indicates that the testproc has been started for this varbind. PARAMETERS:      SNMP_PKT_T *    the SNMP packet      VB_T *          the varbind being processedRETURNS:  Nothing****************************************************************************/void   testproc_started(SNMP_PKT_T *pktp,		   VB_T       *vbp){vbp->vb_flags |= VFLAG_TEST_STARTED;}

⌨️ 快捷键说明

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