📄 snmp_e.c
字号:
/* snmp_e.c - snmp_e.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: snmp_e.c,v $ * Revision 1.6 2003/01/15 14:05:08 josh * directory structure shifting * * Revision 1.5 2002/06/04 17:53:55 josh * refer to calculate PDU length which hasn't been put into the PDU yet * * Revision 1.4 2002/05/13 20:46:17 josh * encoding process now checks for 16-bit overflows in * calculating packet sizes * * Revision 1.3 2001/11/06 21:50:51 josh * second (and hopefully final) pass of new path hacking * * Revision 1.2 2001/11/06 21:20:29 josh * revised new path hacking * * Revision 1.1.1.1 2001/11/05 17:47:43 tneale * Tornado shuffle * * Revision 9.3.4.2 2001/09/27 01:13:10 meister * dynamic config rototill * * Revision 9.3.4.1 2001/08/06 20:05:40 meister * Added dynamic component configuration macros to V3 conditional code * * Revision 9.3 2001/01/19 22:22:27 paul * Update copyright. * * Revision 9.2 2000/03/17 00:19:25 meister * Update copyright message * * Revision 9.1 1999/04/09 20:37:12 josh * Obsoleting ENVOY_SNMP_VERSON_USEC and ENVOY_40_VB_FREE_COMPAT * * Revision 9.0 1998/10/16 22:12:22 sar * Update version stamp to match release * * Revision 8.6 1998/06/28 21:51:20 sar * Added some installation options to avoid buidling unneeded code * * Revision 8.5 1998/06/16 05:23:52 sar * Clean up some type stuff via some casts * * Revision 8.4 1998/06/05 18:53:23 sra * "#include <foo.h>" => "#include <envoy/h/foo.h>". * * Revision 8.3 1998/05/29 04:31:13 sar * Add and use defines for v2 types and v2 protocol pieces. This allows * us to include the types and pieces for other versions, such as v3, * without having to touch all of the seperate files that use the * types or pieces. * * Revision 8.2 1998/05/24 04:39:16 sar * Add code to make calls to process (size, encode, decode) SNMPv3 packets. * Also moved code around to make it clearer. * * Revision 8.1 1998/02/25 04:52:44 sra * Update copyrights. * * Revision 8.0 1997/11/18 00:57:04 sar * Updated revision to 8.0 * * Revision 7.2 1997/03/20 06:49:21 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.3 1996/01/10 16:34:47 sar * In snmp_encode_packet figure out what the packet size will be * before calling snmp_user_get_encode_buffer * Usec updates - mostly doing the authentication if needed. * * Revision 6.2 1995/11/01 00:46:48 sar * added ifdefs to the version switch for pdu types * arranged to leave out the v1 trap code if we aren't compiling v1 * * Revision 6.1 1995/10/20 23:02:48 sar * removed no_pp stuff & v2 party code * * Revision 6.0 1995/05/31 21:48:16 sra * Release 6.0. * * Revision 5.4 1995/05/08 20:32:04 sar * Removed a garbage character. * * Revision 5.3 1995/03/21 00:30:26 sar * Switched to using for & loc to name parties * Removed the proxy code. * * Revision 5.2 1994/09/29 18:37:21 sar * If we aren't using the v2 types remove the code to handle them mostly * this means ifdef the code. In mibutils.c and snmp_d.c we need to * examine the version of the packet in some cases to reject v2 types for * a v1 packet when both v1 and v2 are installed. * * Revision 5.1 1994/08/03 19:32:32 sar * We were using SizeOfInt() on the time ticks field when calculting the * size of a trap packet, we now use SizeOfUnsignedInt. * * 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.13 1993/06/23 00:04:16 sar * Made ENABLE_PROXY be just PROXY in the install defs * * Revision 3.12 1993/06/02 23:09:24 dab * Changed #ifdef's to #if's for things from install.h * * Revision 3.11 1993/05/19 20:26:47 sar * Tidied up types to make compilers happy (mostly int and unsigned int to * ALENGTH_T). * * Revision 3.10 1993/05/03 17:16:12 sar * Added routines for local time, removed {party context} oids from packet * structure, added asn1len to {party context} structures and * SNMP_{Party Context}_Name where needed to lookup the name for a given * {Party Context}. * * Revision 3.9 1993/04/30 22:54:08 sar * Added mechanism for minimial proxies and coarse grained locks. The * latter required the addition of routines to get the name of a leaf given * a pointer to the leaf. * * Revision 3.8 1993/04/26 20:37:09 sar * Added ifdefs to allow clean makes of version 1 and 2, added bit strings, * arrange for deletion of acls with the party or context they refer to * is deleted. * * Revision 3.7 1993/04/22 20:06:36 sar * Much updating of macros and install options, mostly we now use * ISNTALL_ENVOY_SNMP_VERSION_1 or _2, VERSION_RFCXXXX is now SNMP_VERSION_2 * and other similiar items. * * Revision 3.6 1993/04/19 18:28:34 sar * cleanup, mostly some correcting some non-ansi misspellings and adding * static defs. * * Revision 3.5 1993/03/25 21:18:09 sar * Added routines to encode/decode 64 bit integers/counter64s * * Revision 3.4 1993/03/20 00:25:43 sar * Removed some unused break statements. * * Revision 3.3 1993/03/05 03:58:02 dab * fixed up types * * Revision 3.2 1993/02/24 01:02:41 sar * Changed many call to use OIDC_T/lenght pairs instead of OBJ_ID_T as now * we don't need to specifically allocate the OBJ_ID_T. * Removed the name objid from the PARTYLEAF_T as the name may be determined from * the tree itself. For efficiency purposes put the dest/src party names into * the pkt so we don't have to look them up frequently. * * Revision 3.1 1993/02/17 21:13:28 sar * Removed #define then and uses of it. * Moved code around to be more in line with it's use. * Modified the high level routines to check for v1 or v2 and call the * correct lower level routines. (Yes it's has compile time flags). * Added bufsize_for_party_packet, and encode_party_packet. * * Revision 3.0 92/04/03 19:52:37 dab * Release 3.0 * * Revision 2.106 92/01/30 14:03:40 dab * No longer have to define the macro SNMP_user_get_encode_buffer. To not * use this function leave macro undefined insteaed of define as 0. This * gets rid of warnings from some compilers and results, potentially, in * slightly better code. * * Revision 2.105 91/12/12 09:16:24 dab * Added macro call to SNMP_user_get_encode_buffer to allow the user to * supply the buffer to encode the SNMP packet into. * * Revision 2.104 91/11/07 09:35:36 dab * Removed the authenticated encoding stuff. * * Revision 2.103 91/10/30 20:42:13 dab * Directly include asn1conf.h, snmpdefs.h, and snmpstat.h (if needed). * * Revision 2.102 91/09/18 12:32:40 dab * Updated to use new macros from <asn1conf.h> and <snmpconf.h>. * * Revision 2.101 91/08/15 12:31:13 dab * Removed <libfuncs.h>. * * Revision 2.100 91/08/09 14:08:27 dab * Update version. * * Revision 1.1 91/07/30 02:23:56 romkey * Initial revision * * * Rev 2.1 17 May 1990 16:02:44 * On traps, the timestamp was being mis-encoded as an integer rather than * as an unsigned integer. * * Rev 2.0 31 Mar 1990 15:06:58 * Release 2.00 * * Rev 1.6 27 Apr 1989 15:56:08 * Removed unused variables * * Rev 1.5 19 Sep 1988 17:26:46 * Made changes to make the Sun C compiler happy. * * Rev 1.4 17 Sep 1988 16:53:42 * The agent-addr and time-stamp fields in trap pdus were being assigned * an incorrect ASN.1 tag. * * Rev 1.3 16 Sep 1988 15:23:28 * Had "then" where "else" should have been! * * Rev 1.2 15 Sep 1988 18:48:06 * Removed comment block for a non-existant procedure. * * Rev 1.1 14 Sep 1988 17:55:00 * Removed redundant + signs that older C compilers complain about. * Also moved includes of system includes into libfunc.h. * * Rev 1.0 12 Sep 1988 10:47:08 * Initial revision.*//* [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 snmp_e.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/localio.h>#include <wrn/wm/snmp/engine/buffer.h>#include <wrn/wm/snmp/engine/encode.h>#include <wrn/wm/snmp/engine/snmpdefs.h>#include <wrn/wm/snmp/engine/snmp.h>#include <wrn/wm/common/dyncfg.h>DYNCFG_VBL_DECLARE_EXTERN(envoy_use_v2_types)DYNCFG_VBL_DECLARE_EXTERN(snmpv3_component)/* In many of the following computations, the length of various tag and length fields are given as constants. This is possible because the tag values are always low enough to fit into one octet. And for various data types, in particular integers, the length field will always occupy one octet. */#if INSTALL_ENVOY_SNMP_VERSION_3DYNCFG_EXTERN_FUNCPTR1(bufsize_for_v3_pkt,ALENGTH_T,SNMP_PKT_T *)DYNCFG_EXTERN_FUNCPTR2(encode_snmp_v3,int,SNMP_PKT_T *,EBUFFER_T *)extern ALENGTH_T bufsize_for_v3_pkt __((SNMP_PKT_T *));extern int encode_snmp_v3 __((SNMP_PKT_T *, EBUFFER_T *));#endif /* #if INSTALL_ENVOY_SNMP_VERSION_3 *//****************************************************************************\NOMANUALNAME: vbsizePURPOSE: Compute and set the internal length of a var bindPARAMETERS: VB_T * The VarBind to be sized.RETURNS: ALENGTH_T The number of octets the Var Bind would use if ASN.1 encoded, including the var bind sequence****************************************************************************/bits32_t vbsize(VB_T * vbp){ bits32_t vb_size; /* Accumulator of size of VarBind sequence */ bits32_t obj_size; obj_size = A_SizeOfObjectId(&(vbp->vb_obj_id)); vb_size = 1 /* The object ID tag is always 1 octet long */ + A_SizeOfLength(obj_size) + obj_size; switch (vbp->vb_data_flags_n_type) { case VT_NUMBER: vbp->vb_data_length = A_SizeOfInt(vbp->value_u.v_number); break; case VT_COUNTER: case VT_GAUGE: case VT_TIMETICKS: vbp->vb_data_length = A_SizeOfUnsignedInt(vbp->value_u.v_counter); break; case VT_STRING: case VT_OPAQUE: { ALENGTH_T used;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -