📄 v3_eng.c
字号:
/* v3_eng.c - v3_eng.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 1998 Integrated Systems, Inc. * All rights reserved. *//* * $Log: v3_eng.c,v $ * Revision 1.2 2001/11/06 21:20:31 josh * revised new path hacking * * Revision 1.1.1.1 2001/11/05 17:47:44 tneale * Tornado shuffle * * Revision 9.9 2001/04/11 20:42:58 josh * merge from the kingfisher branch * * Revision 9.8 2001/01/19 22:22:29 paul * Update copyright. * * Revision 9.7 2000/07/12 20:09:25 josh * moving SNMP_Find_Matching_Engine_ID() from sendntfy.c to v3_eng.c * * Revision 9.6 2000/06/09 13:55:09 josh * changing of installation option-related builds. Moved certain glue * functions to v3_ber.c from sendntfy.c so they get built even when * ENVOY_SNMP_V3_NOTIFY isn't installed * * Revision 9.5.2.2 2001/03/12 22:08:30 tneale * Updated copyright * * Revision 9.5.2.1 2000/09/20 21:46:59 josh * bringing branch up to currency with the root tree * * Revision 9.5 2000/03/17 00:19:29 meister * Update copyright message * * Revision 9.4 1999/11/09 17:56:41 josh * fixing memory leaks and initialization issues * * Revision 9.3 1999/11/04 21:14:06 josh * fixing Purify-related bugs * * Revision 9.2 1999/10/07 23:43:47 josh * some extra checking in SNMP_Engine_Set_Address() -- make sure that * the same address can't be associated with two different EngineIDs * * Revision 9.1 1999/09/27 21:11:47 josh * fixing nits, rewriting engine id <--> address code, adding installation * option * * Revision 9.0 1998/10/16 22:12:34 sar * Update version stamp to match release * * Revision 1.9 1998/08/12 04:44:02 sar * Move the initialization routines around some in order to minimize * the amount of code that gets pulled in for init purposes. * * Revision 1.8 1998/08/04 02:00:13 sar * Modified some of the routines that allocate longer term * storage (table structures and indexing information) to * user SNMP_memory_{alloc free}_lt in preparation for * possibly allocating them from a different pool then the * short term structures. * * Revision 1.7 1998/07/20 01:59:58 sar * Add () to SNMP_Engine_Get_My_* and ENVOY_TIME calls * Modify the timestamp installs so they are all the same, * installing ENVOY_TIME() - timestamp * * Revision 1.6 1998/07/06 00:55:01 sar * Correct test in comparison, use == instead of = * * Revision 1.5 1998/07/03 16:51:33 sar * Removed the many engine option and moved this engine's boots and time * informtaion into an engine entry * * Revision 1.4 1998/06/18 04:32:33 sar * Update the type info for bflags in an ebuffer and make * everybody match it. * * Revision 1.3 1998/05/30 03:20:03 sar * Modified the names for the max string length macros for clarity * Update user_lookup * * Revision 1.2 1998/05/27 20:52:27 sar * Added comments and header information, added size checks where appropriate * * Revision 1.1 1998/05/24 04:14:49 sar * Support for processing SNMPv3 packets. * acc = access and group structure control functions * auth & prive = authentication and privacy code (not including the * actual digest or encryption routines) * ber = routines for encoding and decoding v3 packets * eng = engine sructure control functions * user = user structure control functions * *//* [clearcase]modification history-------------------01e,12may05,job fix apigen comments01d,18apr05,job update copyright notices01c,04mar05,job apigen update01b,18feb05,job apigen for documented APIs01a,24nov03,job update copyright information*//*DESCRIPTIONThis library contains v3_eng.c routines.INCLUDE FILES: snmp.h*/#include <wrn/wm/snmp/engine/asn1.h>#include <wrn/wm/snmp/engine/snmp.h>#include <wrn/wm/snmp/engine/snmpdefs.h>#include <wrn/wm/snmp/engine/vbdefs.h>#include <wrn/wm/snmp/engine/buffer.h>#include <wrn/wm/snmp/engine/objectid.h>#include <wrn/wm/snmp/engine/v3_eng.h>/* This file manages the engine information we must maintain. The v3_* items are for our engine, the list is for any other engines we know about. The engine sructures are ordered by the length of the engine id, shortest to longest, within a given length the entries aren't sorted. */extern sbits32_t v3_snmpEngineMaxMessageSize;/********************************************************************************* SNMP_Engine_Set_My_Info - initialize this entity\抯 own engine information* SYNOPSIS** \cs* int SNMP_Engine_Set_My_Info * ( * bits8_t * id, * ALENGTH_T id_length, * bits32_t boots, * sbits32_t timestamp * )* \ce** DESCRIPTION** This routine initializes this entity\抯 own engine information. Each time you * call this routine, the existing information is overwritten.** PARAMETERS* \is* \i <*id>* Point to an engine id.* \i <id_length>* Specify the length in bytes of the engine id.* \i <timestamp>* Indicate the number of seconds since the agent\抯 last reboot. If you update * the boots field, set the value of timestamp to zero.* \ie** RETURNS: If successful, this routine returns a 0. If there is an allocation * error, if the length specified was 0, or if the length was too long, it * returns 1.** ERRNO: N/A** SEE ALSO: SNMP_Engine_Get_Boots(), SNMP_Engine_Get_Time(), * SNMP_Engine_Install(), SNMP_Engine_Lookup(), SNMP_Engine_Set_Address(), * SNMP_Engine_Set_Info()*/int SNMP_Engine_Set_My_Info(bits8_t *id, ALENGTH_T len, bits32_t boots, sbits32_t offset){if ((len == 0) || (len > ETC_ENGINE_ENGINE_MAX)) return(1);if (v3_my_engine) { if (len > v3_my_engine->id_len){ SNMP_memory_free_lt(v3_my_engine); v3_my_engine = SNMP_memory_alloc_lt(sizeof(ENGINE_LEAF_T) + len); v3_my_engine->id = ((bits8_t *)v3_my_engine) + sizeof(ENGINE_LEAF_T); } }else { v3_my_engine = SNMP_memory_alloc_lt(sizeof(ENGINE_LEAF_T) + len); v3_my_engine->id = ((bits8_t *)v3_my_engine) + sizeof(ENGINE_LEAF_T); }if (v3_my_engine == 0) return(1);MEMCPY(v3_my_engine->id, id, len); v3_my_engine->id_len = len;v3_my_engine->boots = boots;v3_my_engine->offset = ENVOY_TIME() - offset;#if INSTALL_ENVOY_SNMP_V3_TARGETv3_my_engine->tdomain.num_components = 0;v3_my_engine->tdomain.component_list = 0;EBufferInitialize(&v3_my_engine->taddress);#endifreturn(0);}/********************************************************************************* SNMP_Engine_Lookup - find a specified entry* SYNOPSIS** \cs* ENGINE_LEAF_T * SNMP_Engine_Lookup * ( * bits8_t * id, * ALENGTH_T id_length * )* \ce** DESCRIPTION** This routine finds the entry named by <id>, which is <id_length> bytes long.** \&NOTE: Most applications do not need to use this routine.** PARAMETERS* \is* \i <*id>* Point to an engine id.* \i <id_length>* Specify the length in bytes of the engine id.* \ie** RETURNS: If an entry with the given name is found, this routine returns a * pointer to the entry. Otherwise, this routine returns 0.** ERRNO: N/A** SEE ALSO: SNMP_Engine_Get_Boots(), SNMP_Engine_Get_Time(), * SNMP_Engine_Install(), SNMP_Engine_Set_Address(), SNMP_Engine_Set_Info(), * SNMP_Engine_Set_My_Info()*/ENGINE_LEAF_T * SNMP_Engine_Lookup(bits8_t *id, ALENGTH_T len){ENGINE_LEAF_T *engine;if (v3_my_engine && (v3_my_engine->id_len == len) && (MEMCMP(id, v3_my_engine->id, len) == 0)) return(v3_my_engine);for(engine = root_engine; engine && (engine->id_len <= len); engine = engine->next) { if ((engine->id_len == len) && (MEMCMP(id, engine->id, len) == 0)) return(engine); }return(0);}#if INSTALL_ENVOY_SNMP_V3_TARGET/****************************************************************************\NOMANUALNAME: SNMP_Find_Matching_Engine_IDPURPOSE: Given a TAddress and a TDomain, try to find an EngineID we know about that corresponds to it.PARAMETERS: RETURNS: nothing****************************************************************************/void SNMP_Find_Matching_Engine_ID(OBJ_ID_T *tdomain, EBUFFER_T *taddress, bits8_t **engine_id, ALENGTH_T *engine_id_len){ENGINE_LEAF_T *engine;OIDC_T snmpUDPDomain[] = { 1, 3, 6, 1, 6, 1, 1 };OIDC_T snmpUDPDomainV6[] = { 1, 3, 6, 1, 2, 1, 100, 1, 2 };for (engine = root_engine; engine; engine = engine->next) { if ((EBufferUsed(taddress) == EBufferUsed(&(engine->taddress))) && (oidcmp(tdomain->num_components, tdomain->component_list, engine->tdomain.num_components, engine->tdomain.component_list) == 1) && ((MEMCMP(EBufferStart(taddress), EBufferStart(&(engine->taddress)), EBufferUsed(taddress)) == 0) || /* this check will allow us to ignore port numbers when * searching for a match */ ((oidcmp(tdomain->num_components, tdomain->component_list, sizeof(snmpUDPDomain)/sizeof(OIDC_T), snmpUDPDomain) == 1) && (MEMCMP(EBufferStart(taddress), EBufferStart(&(engine->taddress)), 4) == 0)) || ((oidcmp(tdomain->num_components,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -