📄 mibutils.c
字号:
/* mibutils.c - mibutils.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: mibutils.c,v $ * Revision 1.5 2003/01/15 14:05:05 josh * directory structure shifting * * Revision 1.4 2002/04/05 22:03:30 josh * std_next_async() needs to call nextproc_next_instance() on all * grouped varbinds, if they're grouped * * Revision 1.3 2001/11/06 21:50:48 josh * second (and hopefully final) pass of new path hacking * * Revision 1.2 2001/11/06 21:20:15 josh * revised new path hacking * * Revision 1.1.1.1 2001/11/05 17:47:43 tneale * Tornado shuffle * * Revision 9.5.4.3 2001/10/19 20:30:07 josh * fixing the fix for the broken gcc compiler -- need to make the * correct comparison * * Revision 9.5.4.2 2001/10/18 21:26:28 josh * the gcc compiler that ships with TAE 1.1 for MIPS has a bug in it, * so we need to rework our code slightly to get around it. * * Revision 9.5.4.1 2001/08/07 21:53:33 meister * reworked to use dynamic component configuration macros, to allow * separate vxworks agentx components * * Revision 9.5 2001/03/27 16:06:09 josh * std_next_async() needs to be more careful about which varbinds it * groups together. * * Revision 9.4 2001/01/19 22:22:22 paul * Update copyright. * * Revision 9.3 2000/03/17 00:19:09 meister * Update copyright message * * Revision 9.2 2000/02/04 21:56:14 josh * functions which are clearly static have been declared as such. * this makes the vxWorks compiler happy. * * Revision 9.1 1999/09/09 19:36:00 sar * Correct the field we use when cleaning up newnode on an alloc failure * * Revision 9.0 1998/10/16 22:11:43 sar * Update version stamp to match release * * Revision 8.4 1998/06/22 03:34:26 sar * Cast some things to unsigned ints to try and keep compilers happy * * Revision 8.3 1998/06/05 18:53:15 sra * "#include <foo.h>" => "#include <envoy/h/foo.h>". * * Revision 8.2 1998/05/24 04:32:09 sar * Fixed an error in the add_node code. We know handle adding a leaf * (instead of a branch) correctly. Previously we would lose a subid * * Revision 8.1 1998/02/25 04:52:05 sra * Update copyrights. * * Revision 8.0 1997/11/18 00:56:52 sar * Updated revision to 8.0 * * Revision 7.4 1997/10/22 03:10:22 sar * Modified the installation options for agentx and the older sub agent scheme * * Also moved the allocation of the locks into envoy_init (env_init.c), * so they can be initialized if necessary. * * Revision 7.3 1997/10/16 00:45:55 sar * Updated for agentx support, with most of the work in mibutils.c to deal * with interior leaves and the pdu processors to deal with agentx leaves, * especially their reference counts. * * Add a bug macro into the get_{read write}_lock calls to give the user * a chance if things start going wrong. * * Fixed a potential problem int the proxy code where we were trying to * stuff a 32 bit quantity into a pointer which may or may not work depending * on the platform. * * Revision 7.2 1997/03/20 06:49:00 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.2 1995/11/01 00:46:48 sar * Removed localio.h, buffer.h and decode.h * * Revision 6.1 1995/10/20 23:02:48 sar * changed party.h to view.h * removed nsapaddress, uinteger32 and bitstring types * removed no_pp stuff * rearranged the view code to so the rfc1445 view scheme for both v1 & v2 * if INSTALL_ENVOY_SNMP_RFC1445_VIEWS is installed or the old envoy * scheme if it isn't * * Revision 6.0 1995/05/31 21:47:32 sra * Release 6.0. * * Revision 5.6 1995/04/28 23:12:28 sar * Dropped the static/dynamice flag in the call to nextproc_next_instance * * Revision 5.5 1995/03/22 18:39:10 sar * Added parans around the access_type check to make compilers happy. * * Revision 5.4 1995/03/21 00:25:01 sar * Updated to use the new async system, the biggest effect is in the next * routines where we no longer call the nexproc routine, This has effects * on the way we deal with view checking and the use of the result object. * * Revision 5.3 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.2 1994/08/19 18:39:21 sar * Copy the entire target oid into the result field during find_next_obj * so that the sub agents can access the entire oid easily. This requires * allocating enough space for the oid as well. * * Revision 5.1 1994/08/04 22:04:16 sar * Added multiple mib tree capability * * Revision 5.0 1994/05/16 15:42:42 sar * Updated revision to 5.0 and copyright to include 1994 * * Revision 4.6 1994/05/11 17:28:52 sar * Removed the #if master_agent from around the find, add, and remove node * functions. * * Revision 4.5 1994/05/10 20:15:07 sar * Added some #if's and added some clauses to compile only what we need * for the sub agent. * * Revision 4.4 1994/05/09 21:03:44 sar * Added #if around a return statment so it should only be included when it * will be used (to avoid unreachable code warnings). * * Revision 4.3 1994/04/29 21:56:01 sar * Mostly mods dealing with the view check stuff, added a flag to * find_object_node to determine if the view check should be done, * add ifdefs to handle the sub agent and v1 using v2 view schemes. * Modified the calling sequence to find_node. * * Revision 4.2 1994/02/01 23:40:34 sar * Made the handling of oids more dynamic in the find next routines. * Added the routines Find, Add and Remove_Node for use with dynamic mib * manipulation. * * Revision 4.1 1993/10/06 19:49:43 sar * moved the version 2 view check to be at the beginning of find_object_node. * * Revision 4.0 1993/06/24 15:45:46 sar * Updated revision to 4.0 and copyright to 93 * * Revision 3.9 1993/06/17 23:33:44 sar * Modified view_check to be able to check the view before a next proc is * run (though it may need to be called again after the nextproc is run). * * Revision 3.8 1993/06/07 18:26:04 sar * Modified the find_next_objid (or whatever) and find_next_helper to * allocate the objids it uses dynamically, this allows them to grow * if neccesary and guarantees the method routines at least MAX_OID_COUNT * oids in the list handed to them. * * Revision 3.7 1993/06/02 23:09:24 dab * Changed #ifdef's to #if's for things from install.h * * Revision 3.6 1993/05/22 01:04:31 sar * Cleaned up some unused variables * * Revision 3.5 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.4 1993/04/20 19:53:27 sar * I had removed the read-only check during sets (for v2) so I put it back * and cleaned up the code around it, also gave mibuitls another error return * so we can coose between no access and no such. * * Revision 3.3 1993/03/20 00:25:43 sar * Updated some types for version two party type stuff (indicies, local * storage, status, mtu and privileges). * Also removed some unused break statements. * * Revision 3.2 1993/03/17 23:02:47 sar * added the view structure and the routines to use and manipulate it. * in mibutils and setpdu started using views. * * Revision 3.1 1993/02/17 21:05:50 sar * Removed #define then and uses of it, general rearrangement. * * Revision 3.0 92/04/03 19:52:37 dab * Release 3.0 * * Revision 2.102 91/10/30 20:42:04 dab * Directly include asn1conf.h, snmpdefs.h, and snmpstat.h (if needed). * * Revision 2.101 91/08/15 12:31:04 dab * Removed <libfuncs.h>. * * Revision 2.100 91/08/09 14:08:22 dab * Update version. * * Revision 1.1 91/07/30 02:23:45 romkey * Initial revision * * * Rev 2.0 31 Mar 1990 15:06:50 * Release 2.00 * * Rev 1.4 24 Sep 1989 22:06:38 * Renamed mib_root to mib_root_node to support the MIB compiler. * * Rev 1.3 27 Apr 1989 15:55:58 * Removed unused variables * * Rev 1.2 19 Sep 1988 17:26:34 * Made changes to make the Sun C compiler happy. * * Rev 1.1 14 Sep 1988 17:57:16 * Moved includes of system include files into libfuncs.h. * * Rev 1.0 12 Sep 1988 10:47:02 * Initial revision.*//* [clearcase]modification history-------------------01e,17feb06,job fix APIGEN markup01d,12may05,job fix apigen comments01c,18apr05,job update copyright notices01b,14feb05,job apigen for documented APIs01a,24nov03,job update copyright information*//*DESCRIPTIONThis library contains mibutils.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/mib.h>#include <wrn/wm/snmp/engine/objectid.h>#include <wrn/wm/snmp/engine/view.h>#include <wrn/wm/common/dyncfg.h>DYNCFG_VBL_DECLARE_EXTERN(agentx_master_component)/*lint -e715 *//*ARGSUSED*/int std_next(OIDC_T lastmatch, int tcount, OIDC_T * tlist, OIDC_T * rlist, char * cookie, SNMP_PKT_T * pktp){if (tcount > 0) return 0;else { *rlist = 0; return 1; }}void std_next_async(OIDC_T lastmatch, int tcount, OIDC_T * tlist, SNMP_PKT_T * pktp, VB_T * vbp){OIDC_T oidc = 0;VBL_T *vblp;VB_T *last_vbp, *tvbp, *group_vbp;if (tcount > 0) nextproc_no_next(pktp, vbp);else { /* this function just got a whole lot more ugly. The problem is * that if you were to issue a next on, say, foo and foo.0, where * foo is an object that uses std_next_async() as its nextproc, * and has a getproc that calls group_by_getproc_and_instance(), * the foo.0 object will be improperly handled. So, now we scan * through the varbind list for any varbinds that might cause * problems like this. */ for (vblp = &(pktp->pdu.std_pdu.std_vbl); vblp->vblp; vblp = vblp->vblp) ; for (last_vbp = &vblp->vblist[vblp->vbl_count], tvbp = vbp + 1; tvbp < last_vbp; tvbp++) { /* find varbinds with the same nextproc which aren't already * in use. Note that people who use the same getproc but * different nextprocs for their objects will lose horribly. */ if (tvbp->vb_ml.ml_leaf && ((tvbp->vb_flags & (VFLAG_SET_STARTED | VFLAG_SET_DONE | VFLAG_TEST_STARTED | VFLAG_TEST_DONE)) == 0) && (tvbp->vb_ml.ml_leaf->nextproc == std_next_async) && (tvbp->vb_ml.ml_remaining_objid.num_components != 0)) { nextproc_no_next(pktp, tvbp); } } for (group_vbp = vbp; group_vbp; group_vbp = group_vbp->vb_link) nextproc_next_instance(pktp, group_vbp, 1, &oidc); vbp->vb_ml.ml_leaf->getproc(lastmatch, 1, &oidc, pktp, vbp); }}/****************************************************************************\NOMANUALNAME: branch_freePURPOSE: Free any allocated memory when cleaning a partially allocated branch of the mib tree. Given two nodes, descend from the first one and free any allocated memory up to, but not including the second one.PARAMETERS: MIBNODE_T * Starting node MIBNODE_T * Ending nodeRETURNS: void****************************************************************************/void branch_free(MIBNODE_T *startnode, MIBNODE_T *endnode){MIBARC_T *ap;if (startnode == endnode) return;for(ap = startnode->arcs; (MIBNODE_T *)(ap->nodep) != 0; ap++) branch_free((MIBNODE_T *)(ap->nodep), endnode);if ((startnode->node_type & ARC_DYNAMIC) != 0) SNMP_memory_free((char *)(startnode->arcs));if ((startnode->node_type & NODE_DYNAMIC) != 0) SNMP_memory_free((char *)startnode);return;}/********************************************************************************* Find_Node_From_Root - locate the node at the specified point in the MIB tree* SYNOPSIS** \cs* INT_32_T Find_Node_From_Root* ( * MIBNODE_T * root, * OBJ_ID_T * objp, * MIBNODE_T ** npp * )* \ce** DESCRIPTION** This routine locates the node at the specified point in the specified MIB * tree. Use this routine when you are writing an SNMP agent or server rather * than in SNMP managers or clients.** PARAMETERS* \is* \i <*root>* Specify the MIB tree root. To specify the default MIB tree, set this value to * 0.* \i <*objp>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -