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

📄 bindstr.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
字号:
/* bindstr.c - bindstr.c routines *//* *  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: bindstr.c,v $ * Revision 1.2  2001/11/06 21:20:05  josh * revised new path hacking * * Revision 1.1.1.1  2001/11/05 17:47:41  tneale * Tornado shuffle * * Revision 9.4  2001/01/19 22:22:18  paul * Update copyright. * * Revision 9.3  2000/03/17 00:18:59  meister * Update copyright message * * Revision 9.2  1999/09/14 19:10:28  josh * SNMP_Bind_*() functions are now just shells that call newly-written * VBL_Bind_*() functions -- they allow you to use a VarBindList (VBL_T) * instead of an SNMP Packet (SNMP_PKT_T) * * Revision 9.1  1999/05/24 20:12:16  josh * 'compc' and 'compl' have been replaced by 'tcount' and 'tlist' * to avoid C++ compiler errors. * * Revision 9.0  1998/10/16 22:11:05  sar * Update version stamp to match release * * Revision 8.2  1998/06/05 18:53:08  sra * "#include <foo.h>" => "#include <envoy/h/foo.h>". * * Revision 8.1  1998/02/25 04:51:25  sra * Update copyrights. * * Revision 8.0  1997/11/18 00:56:43  sar * Updated revision to 8.0 * * Revision 7.2  1997/03/20 06:48:41  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.1  1995/10/20  22:59:09  sar * removed no_pp stuff & casts of 0 * modified memcpy to MEMCPY * * Revision 6.0  1995/05/31  21:47:11  sra * Release 6.0. * * Revision 5.0  1994/05/16  15:42:42  sar * Updated revision to 5.0 and copyright to include 1994 * * Revision 4.0  1993/06/24  15:45:46  sar * Updated revision to 4.0 and copyright to 93 * * Revision 3.1  1993/04/27  21:10:00  sar * Replace locate_vb with index_to_vbp, so we can have only one copy of them. * * Revision 3.0  1992/04/03  19:52:37  dab * Release 3.0 * * Revision 2.104  91/10/30  20:41:39  dab * Directly include asn1conf.h, snmpdefs.h, and snmpstat.h (if needed). *  * Revision 2.103  91/09/18  12:31:36  dab * Updated to use new macros from <asn1conf.h> and <snmpconf.h>. *  * Revision 2.102  91/08/15  12:30:46  dab * Removed <libfuncs.h>. *  * Revision 2.101  91/08/12  12:47:33  dab * Cast arguments to memcpy() and memset() to PTR_T. *  * Revision 2.100  91/08/09  14:08:16  dab * Update version. *  * Revision 1.1  91/07/30  02:23:26  romkey * Initial revision *  *  *    Rev 2.0   31 Mar 1990 15:06:38 * Release 2.00 *  *    Rev 1.2   17 Mar 1989 23:00:34 * Handling of zero length strings was modified so that they are treated * as if they were statically allocated, but at address zero. *  *    Rev 1.1   17 Mar 1989 21:41:54 * Calls to memcpy/memset protected against zero lengths *  *    Rev 1.0   11 Jan 1989 12:11:58 * Initial revision. * * Separated from buildpkt.c on January 11, 1989.*//* [clearcase]modification history-------------------01d,12may05,job  fix apigen comments01c,18apr05,job  update copyright notices01b,16feb05,job  apigen for documented APIs01a,24nov03,job  update copyright information*//*DESCRIPTIONThis library contains bindstr.c routines.INCLUDE FILES: snmp.h*/#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/snmp.h>#include <wrn/wm/snmp/engine/objectid.h>#include <wrn/wm/snmp/engine/buildpkt.h>/********************************************************************************* SNMP_Bind_Opaque - bind an opaque value into a 'VarBind'* SYNOPSIS** \cs* int SNMP_Bind_Opaque*     ( *     SNMP_PKT_T    *  pktp,*     int              index,*     int              tcount,*     OIDC_T        *  tlist,*     int              leng,*     OCTET_T       *  strp,*     int              statflg*     )* \ce** DESCRIPTION** This routine binds an opaque value into a 'VarBind' in the 'VarBindList' of * an SNMP packet structure created by either SNMP_Create_Request2(), * SNMP_Create_Request_V3(), or SNMP_Create_Trap().** PARAMETERS* \is* \i <*pktp>* Reference the packet being constructed.* \i <index>* Specify the zero-based index that indicates which 'VarBind' entry to use.* \i <tcount>* Specify the component count of the object identifier of the 'VarBind' being * bound.* \i <*tlist>* Specify the components of the object identifier of the 'VarBind' being bound.* \i <leng>* Specify the length of the string to be bound.* \i <*strp>* Specify the address of the string to be bound.* \i <statflg>* Indicate whether the string must be copied (0) or may be used as is in its * current location(1).* \ie** RETURNS: If successful, this routine returns 0. Otherwise, it returns -1.** ERRNO: N/A** SEE ALSO: SNMP_Bind_String(), SNMP_Bind_Unsigned_Integer(), * SNMP_Create_Request2(), SNMP_Create_Request_V3(), SNMP_Create_Trap()*//********************************************************************************* SNMP_Bind_String - bind an octet string value into a 'VarBind'* SYNOPSIS** \cs* int SNMP_Bind_String*     ( *     SNMP_PKT_T  *  pktp, *     int            index, *     int            tcount, *     OIDC_T      *  tlist, *     OCTET_T        flags_n_type, *     int            leng, *     OCTET_T     *  strp, *     int            statflg *     )* \ce** DESCRIPTION** This routine binds an octet string value into a 'VarBind' in the * 'VarBindList' of an SNMP packet structure created by either * SNMP_Create_Request2(), SNMP_Create_Request_V3(), or SNMP_Create_Trap().** \&NOTE: It may be more convenient to use SNMP_Bind_Opaque().** PARAMETERS* \is* \i <*pktp>* Reference the packet being constructed.* \i <index>* Specify the zero-based index that indicates which 'VarBind' entry to use.* \i <tcount>* Specify the component count of the object identifier of the 'VarBind' being * bound.* \i <*tlist>* Specify the components of the object identifier of the 'VarBind' being bound.* \i <flags_n_type>* Specify one of the 'VarBindType' constants 'VT_STRING' or 'VT_OPAQUE', which * are defined in the file 'vbdefs.h'.* \i <leng>* Specify the length of the string to be bound.* \i <*strp>* Specify the address of the string to be bound.* \i <statflg>* Indicate whether the string must be copied (0) or may be used as is in its * current location(1).* \ie** RETURNS: If successful, this routine returns 0. Otherwise, it returns -1.** ERRNO: N/A** SEE ALSO: SNMP_Bind_Opaque(), SNMP_Create_Request2(), * SNMP_Create_Request_V3(), SNMP_Create_Trap()*/int  SNMP_Bind_String(SNMP_PKT_T *pktp,		   int	       indx,		   int	       tcount,		   OIDC_T     *tlist,		   OCTET_T     flags_n_type,		   int	       leng,		   OCTET_T    *strp,		   int	       statflg){VBL_T	*vblp;#if INSTALL_ENVOY_SNMP_VERSION_1if (pktp->pdu_type == TRAP_PDU)    vblp = &(pktp->pdu.trap_pdu.trap_vbl);  else#endif    vblp = &(pktp->pdu.std_pdu.std_vbl);return(VBL_Bind_String(vblp, indx, tcount, tlist, flags_n_type, 		       leng, strp, statflg));}/********************************************************************************* VBL_Bind_Opaque - bind an opaque value into a 'VarBind'* SYNOPSIS** \cs* int VBL_Bind_Opaque *     ( *     VBL_T        *  vblp,*     int             index,*     int             tcount,*    OIDC_T       *  tlist,*     int             leng,*     OCTET_T      *  strp,*     int             statflg*     )* \ce** DESCRIPTION** This routine binds an opaque value into a 'VarBind' in the 'VBL_T' structure * (<vblp>) created by VBList_Allocate().** PARAMETERS* \is* \i <*vblp>* Reference the 'VBL_T' structure.* \i <index>* Specify the zero-based index that indicates which 'VarBind' entry to use.* \i <tcount>* Specify the component count of the object identifier of the 'VarBind' being * bound.* \i <*tlist>* Specify the components of the object identifier of the 'VarBind' being bound.* \i <leng>* Specify the length of the string to be bound.* \i <*strp>* Specify the address of the string to be bound.* \i <statflg>* Indicate whether the string must be copied (0) or may be used as is in its * current location (1).* \ie** RETURNS: If successful, this routine returns 0. Otherwise, it returns -1.** ERRNO: N/A** SEE ALSO: VBL_Bind_Counter(), VBL_Bind_Gauge(), VBL_Bind_Integer(), * VBL_Bind_IP_Address(), VBL_Bind_Null(), VBL_Bind_Object_ID(), * VBL_Bind_String(), VBL_Bind_64_Unsigned_Integer(), VBL_Bind_Timeticks(), * VBL_Bind_Unsigned_Integer(), VBList_Allocate()*//********************************************************************************* VBL_Bind_String - bind an octet string value into a 'VarBind'* SYNOPSIS** \cs* int VBL_Bind_String *     (  *     VBL_T       *  vblp, *     int            index, *     int            tcount, *     OIDC_T      *  tlist, *     OCTET_T        flags_n_type, *     int            leng, *     OCTET_T     *  strp, *     int            statflg *     )* \ce** DESCRIPTION** This routine binds an octet string value into a 'VarBind' in the 'VBL_T' * structure (<vblp>) created by VBList_Allocate().** \&NOTE: It may be more convenient to use VBL_Bind_Opaque().** PARAMETERS* \is* \i <*vblp>* Reference the 'VBL_T' structure.* \i <index>* Specify the zero-based index that indicates which 'VarBind' entry to use.* \i <tcount>* Specify the component count of the object identifier of the 'VarBind' being * bound.* \i <*tlist>* Specify the components of the object identifier of the 'VarBind' being bound.* \i <flags_n_type>* Specify one of the 'VarBindType' constants 'VT_STRING' or 'VT_OPAQUE,' which * are defined in the file 'vbdefs.h'.* \i <leng>* Specify the length of the string to be bound.* \i <*strp>* Specify the address of the string to be bound.* \i <statflg>* Indicate whether the string must be copied (0) or may be used as is in its * current location (1).* \ie** RETURNS: If successful, this routine returns 0. Otherwise, it returns -1.** ERRNO: N/A** SEE ALSO: VBL_Bind_Counter(), VBL_Bind_Gauge(), VBL_Bind_Integer(), * VBL_Bind_IP_Address(), VBL_Bind_Null(), VBL_Bind_Object_ID(), * VBL_Bind_Opaque(), VBL_Bind_String(), VBL_Bind_64_Unsigned_Integer(), * VBL_Bind_Timeticks(), VBL_Bind_Unsigned_Integer(), VBList_Allocate()*/int  VBL_Bind_String(VBL_T     *vblp,		  int	     indx,		  int	     tcount,		  OIDC_T    *tlist,		  OCTET_T    flags_n_type,		  int	     leng,		  OCTET_T   *strp,		  int	     statflg){VB_T	*vbp;OCTET_T	*buffp;if ((vbp = vblp_index_to_vbp(vblp, indx)) == 0)    return -1;if (build_object_id(tcount, tlist, &(vbp->vb_obj_id)) == -1)    return -1;if ((statflg == 0) && (leng != 0)){    if ((buffp = (OCTET_T *)SNMP_memory_alloc((unsigned int)leng)) == 0) {	Clean_Obj_ID(&(vbp->vb_obj_id));	return -1;	}    (void) MEMCPY((PTR_T)buffp, (PTR_T)strp,		  (unsigned int)leng); /* Length known to be != zero */    EBufferPreLoad(BFL_IS_DYNAMIC, &(vbp->value_u.v_string), buffp, leng);    } else { /* Buffer is either static or has zero length */    EBufferPreLoad(BFL_IS_STATIC, &(vbp->value_u.v_string),		   leng != 0 ? strp : 0, leng);    }vbp->vb_data_flags_n_type = flags_n_type;return 0;}

⌨️ 快捷键说明

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