Files
m241Neelima/vxworks-6.9/target/src/wrn/wm/snmp/engine/binduint.c
T
2026-07-30 11:19:44 +05:30

545 lines
15 KiB
C

/* binduint.c - binduint.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: binduint.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:42 tneale
* Tornado shuffle
*
* Revision 9.4 2001/01/19 22:22:19 paul
* Update copyright.
*
* Revision 9.3 2000/03/17 00:19:00 meister
* Update copyright message
*
* Revision 9.2 1999/09/14 19:10:29 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:17 josh
* 'compc' and 'compl' have been replaced by 'tcount' and 'tlist'
* to avoid C++ compiler errors.
*
* Revision 9.0 1998/10/16 22:11:07 sar
* Update version stamp to match release
*
* Revision 8.2 1998/06/05 18:53:09 sra
* "#include <foo.h>" => "#include <envoy/h/foo.h>".
*
* Revision 8.1 1998/02/25 04:51:27 sra
* Update copyrights.
*
* Revision 8.0 1997/11/18 00:56:44 sar
* Updated revision to 8.0
*
* Revision 7.2 1997/03/20 06:48:43 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 uinteger32 & no_pp stuff
*
* Revision 6.0 1995/05/31 21:47:13 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.2 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.1 1993/02/17 21:00:51 sar
* Added data type VT_UINTEGER32
*
* Revision 3.0 92/04/03 19:52:37 dab
* Release 3.0
*
* Revision 2.102 91/10/30 20:41:40 dab
* Directly include asn1conf.h, snmpdefs.h, and snmpstat.h (if needed).
*
* Revision 2.101 91/08/15 12:30:46 dab
* Removed <libfuncs.h>.
*
* Revision 2.100 91/08/09 14:08:16 dab
* Update version.
*
* Revision 1.1 91/07/30 02:23:27 romkey
* Initial revision
*
*
* Rev 2.0 31 Mar 1990 15:06:38
* Release 2.00
*
* Rev 1.0 11 Jan 1989 12:11:52
* Initial revision.
*
* Separated from buildpkt.c on January 11, 1989.
*/
/* [clearcase]
modification history
-------------------
01d,12may05,job fix apigen comments
01c,18apr05,job update copyright notices
01b,16feb05,job apigen for documented APIs
01a,24nov03,job update copyright information
*/
/*
DESCRIPTION
This library contains binduint.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/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_Counter - bind a counter value into a 'VarBind'
* SYNOPSIS
*
* \cs
* int SNMP_Bind_Counter
* (
* SNMP_PKT_T * pktp,
* int index,
* int tcount,
* OIDC_T * tlist,
* UINT_32_T value
* )
* \ce
*
* DESCRIPTION
*
* This routine binds a counter value into a 'VarBind' in a '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 <value>
* Specify the integer value to be bound.
* \ie
*
* RETURNS: If successful, this routine returns 0. Otherwise, it returns -1.
*
* ERRNO: N/A
*
* SEE ALSO: SNMP_Bind_Unsigned_Integer(), SNMP_Create_Request2(),
* SNMP_Create_Request_V3(), SNMP_Create_Trap()
*/
/*******************************************************************************
*
* SNMP_Bind_Gauge - bind a gauge value into a 'VarBind'
* SYNOPSIS
*
* \cs
* int SNMP_Bind_Gauge
* (
* SNMP_PKT_T * pktp,
* int index,
* int tcount,
* OIDC_T * tlist,
* UINT_32_T value
* )
* \ce
*
* DESCRIPTION
*
* This routine binds a gauge 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 <value>
* Specify the integer value to be bound.
* \ie
*
* RETURNS: If successful, this routine returns 0. Otherwise, it returns -1.
*
* ERRNO: N/A
*
* SEE ALSO: SNMP_Bind_Unsigned_Integer(), SNMP_Create_Request2(),
* SNMP_Create_Request_V3(), SNMP_Create_Trap()
*/
/*******************************************************************************
*
* SNMP_Bind_Timeticks - bind a timetick value into a 'VarBind'
* SYNOPSIS
*
* \cs
* int SNMP_Bind_timeticks
* (
* SNMP_PKT_T * pktp,
* int index,
* int tcount,
* OIDC_T * tlist,
* UINT_32_T value
* )
* \ce
*
* DESCRIPTION
*
* This routine binds a timetick 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 <value>
* Specify the integer value to be bound.
* \ie
*
* RETURNS: If successful, this routine returns 0. Otherwise, it returns -1.
*
* ERRNO: N/A
*
* SEE ALSO: SNMP_Bind_Unsigned_Integer(), SNMP_Create_Request2(),
* SNMP_Create_Request_V3(), SNMP_Create_Trap()
*/
/*******************************************************************************
*
* SNMP_Bind_Unsigned_Integer - bind an unsigned integer value into a 'VarBind'
* SYNOPSIS
*
* \cs
* int SNMP_Bind_Unsigned_Integer
* (
* SNMP_PKT_T * pktp,
* int index,
* int tcount,
* OIDC_T * tlist,
* OCTET_T flags_n_type,
* UINT_32_T value
* )
* \ce
*
* DESCRIPTION
*
* This routine binds an unsigned integer 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 one of the following:
* SNMP_Bind_Gauge(), SNMP_Bind_Timeticks(), or SNMP_Bind_Counter().
*
* 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 of the 'VarBindType' constants 'VT_COUNTER', 'VT_GAUGE' or
* 'VT_TIMETICKS', which are defined in the file 'vbdefs.h'.
* \i <value>
* Specify the integer value to be bound.
* \ie
*
* RETURNS: If successful, this routine returns 0. Otherwise, it returns -1.
*
* ERRNO: N/A
*
* SEE ALSO: SNMP_Bind_Counter(). SNMP_Bind_Gauge(). SNMP_Bind_Gauge(),
* SNMP_Create_Request2(), SNMP_Create_Request_V3(), SNMP_Create_Trap()
*/
int
SNMP_Bind_Unsigned_Integer(SNMP_PKT_T *pktp,
int indx,
int tcount,
OIDC_T *tlist,
OCTET_T flags_n_type,
UINT_32_T value)
{
VBL_T *vblp;
#if INSTALL_ENVOY_SNMP_VERSION_1
if (pktp->pdu_type == TRAP_PDU)
vblp = &(pktp->pdu.trap_pdu.trap_vbl);
else
#endif
vblp = &(pktp->pdu.std_pdu.std_vbl);
return(VBL_Bind_Unsigned_Integer(vblp, indx, tcount, tlist,
flags_n_type, value));
}
/*******************************************************************************
*
* VBL_Bind_Counter - bind a counter value into a 'VarBind'
* SYNOPSIS
*
* \cs
* int VBL_Bind_Counter
* (
* VBL_T * pktp,
* int index,
* int tcount,
* OIDC_T * tlist,
* UINT_32_T value
* )
* \ce
*
* DESCRIPTION
*
* This routine binds a counter 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 <value>
* Specify the integer value to be bound.
* \ie
*
* RETURNS: If successful, this routine returns 0. Otherwise, it returns -1.
*
* ERRNO: N/A
*
* SEE ALSO: 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()
*/
/*******************************************************************************
*
* VBL_Bind_Gauge - bind a gauge value into a 'VarBind'
* SYNOPSIS
*
* \cs
* int VBL_Bind_Gauge
* (
* VBL_T * pktp,
* int index,
* int tcount,
* OIDC_T * tlist,
* UINT_32_T value
* )
* \ce
*
* DESCRIPTION
*
* This routine binds a gauge 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 <value>
* Specify the integer value to be bound.
* \ie
*
* RETURNS: If successful, this routine returns 0. Otherwise, it returns -1.
*
* ERRNO: N/A
*
* SEE ALSO: VBL_Bind_Counter(), 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()
*/
/*******************************************************************************
*
* VBL_Bind_Timeticks - bind a timetick <value> into a 'VarBind'
* SYNOPSIS
*
* \cs
* int VBL_Bind_Timeticks
* (
* VBL_T * pktp,
* int index,
* int tcount,
* OIDC_T * tlist,
* UINT_32_T value
* )
* \ce
*
* DESCRIPTION
*
* This routine binds a time ticks 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 <value>
* Specify the integer value to be bound.
* \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()
*/
/*******************************************************************************
*
* VBL_Bind_Unsigned_Integer - bind an unsigned integer <value> into a 'VarBind'
* SYNOPSIS
*
* \cs
* int VBL_Bind_Unsigned_Integer
* (
* VBL_T * vblp,
* int index,
* int tcount,
* OIDC_T * tlist,
* OCTET_T flags_n_type,
* UINT_32_T value
* )
* \ce
*
* DESCRIPTION
*
* This routine binds an unsigned integer value into a 'VarBind' in the 'VBL_T'
* structure (<vblp>) created by VBList_Allocate().
*
* \&NOTE: It may be more convenient to use one of the following macros:
* VBL_Bind_Gauge(), VBL_Bind_Timeticks(), or VBL_Bind_Counter().
*
* 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 of the 'VarBindType' constants 'VT_COUNTER', 'VT_GAUGE' or
* 'VT_TIMETICKS', which are defined in the file 'vbdefs.h'.
* \i <value>
* Specify the integer <value> to be bound.
* \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_Unsigned_Integer(VBL_T *vblp,
int indx,
int tcount,
OIDC_T *tlist,
OCTET_T flags_n_type,
UINT_32_T value)
{
VB_T *vbp;
if (!((flags_n_type == VT_COUNTER) || (flags_n_type == VT_GAUGE) ||
(flags_n_type == VT_TIMETICKS)))
return -1;
if ((vbp = vblp_index_to_vbp(vblp, indx)) == 0)
return -1;
if (build_object_id(tcount, tlist, &(vbp->vb_obj_id)) == -1)
return -1;
vbp->vb_data_flags_n_type = flags_n_type;
vbp->value_u.v_counter = value;
return 0;
}