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

📄 mib_fon.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
字号:
/* *  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: mib_fon.c,v $ * Revision 1.4  2003/01/15 14:05:05  josh * directory structure shifting * * Revision 1.3  2001/11/06 21:50:47  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:42  tneale * Tornado shuffle * * Revision 9.2.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.2.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.2.4.1  2001/08/07 21:53:32  meister * reworked to use dynamic component configuration macros, to allow * separate vxworks agentx components * * Revision 9.2  2001/01/19 22:22:22  paul * Update copyright. * * Revision 9.1  2000/03/17 00:19:08  meister * Update copyright message * * Revision 9.0  1998/10/16 22:11:40  sar * Update version stamp to match release * * Revision 8.3  1998/06/05 18:53:14  sra * "#include <foo.h>" => "#include <envoy/h/foo.h>". * * Revision 8.2  1998/05/24 04:47:17  sar * Change the ifdef code to depend on DYNAMIC_VIEWS instead of RFC1445_VIEWS. * also modified the view_check call to use view_family_check this means * the routine that called the mib routines must also have set up the * view family. * * Revision 8.1  1998/02/25 04:51:58  sra * Update copyrights. * * Revision 8.0  1997/11/18 00:56:51  sar * Updated revision to 8.0 * * Revision 1.2  1997/10/22 03:10:21  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 1.1  1997/10/16 00:35:06  sar * Result of the break up of the mibutils.c file.  These were broken * out to allow for better granularity and smaller size for customers * that weren't using all of the functions in mibutils.c * *//* [clearcase]modification history-------------------01b,18apr05,job  update copyright notices01a,24nov03,job  update copyright information*//* moved find_object_node here from mibutils.c (where most of the   revision log is) to allow for better granularity of code. */#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)/****************************************************************************NAME:  find_object_nodePURPOSE:  Locate a node in the MIB tree corresponding to a given object id.          The search terminates sucessfully when all the object identifer          components have been consumed or a leaf node is encountered.          (One of the status flags in the MIBLOC_T structure indicates          whether the search terminated at an inner node or a leaf.)          The search terminates unsucessfully (return code -1) if an          object identifier component does not match those available at          a given inner node.PARAMETERS:        OBJ_ID_T *      Object ID to be used        SNMP_PKT_T *    The received packet        int             Do the view check (1) or not (0)RETURNS:  int           Zero if node located                        vbp->vb_ml structure will be filled in with lots                        of information about the found object.                          -1 if nothing located (MIBLOC_T is not valid)                          -2 if we found something but it was outside                             of our view.			  -3 if we had a more general error ****************************************************************************/int  find_object_node(VB_T       * vbp,                   SNMP_PKT_T * pktp,                   int          check_flag){OBJ_ID_T  *objp;MIBLOC_T  *mlp;MIBNODE_T *np;MIBARC_T  *ap;OIDC_T    *compp;         /* Current object id component of interest */int        comp_num;      /* Index of current object id component    */#if (INSTALL_ENVOY_AGENTX_MASTER)MIBLEAF_T *ax_np = 0;OIDC_T     ax_last_match = 0, *ax_compp = 0;int        ax_comp_num = 0;#endifobjp = &(vbp->vb_obj_id);mlp = &(vbp->vb_ml);/* The user can choose (at compile time) to use the old Epilogue   view mask system, or to use the view scheme described in rfc1445.   The user will be forced to choose the rfc1445 scheme if they choose   to use the master agent code. *//* We can do the check here for this scheme because we only need the   object id, in the old v1 scheme we need the actual node to examine   the view masks so we have to wait until after the tree lookup.  */#if (INSTALL_ENVOY_MAIN_AGENT && INSTALL_ENVOY_SNMP_DYNAMIC_VIEWS)if (check_flag) {    if (SNMP_View_Family_Check(pktp, objp->component_list,			       objp->num_components,			       VIEW_CHECK_DET) == VIEW_EXCLUDED)        return (-2);    }#endif /* (INSTALL_ENVOY_MAIN_AGENT && INSTALL_ENVOY_SNMP_DYNAMIC_VIEWS) *//* find the proper root of the tree */if (pktp->mib_root)    np = pktp->mib_root;else     np = &(ENVOY_MIB_ROOT_NODE);/* if agentx is installed see if the root node has a leaf, if so   save some information about it */#if (INSTALL_ENVOY_AGENTX_MASTER)DYNCFG_IFCFGVBL_BEGIN(agentx_master_component)if (np && ((np->node_type & NODE_TYPE) == INNER_NODE) && np->leaf) {    ax_np         = np->leaf;    ax_last_match = 0;    ax_comp_num   = objp->num_components;    ax_compp      = objp->component_list;    }DYNCFG_IFCFGVBL_END(agentx_master_component)#endif /* INSTALL_ENVOY_AGENTX_MASTER */for(comp_num = objp->num_components, compp = objp->component_list;    ((np->node_type & NODE_TYPE) == INNER_NODE) && (comp_num > 0);    comp_num--, compp++)   {   for(ap = np->arcs; (MIBNODE_T *)(ap->nodep) != 0; ap++) {      if (ap->id == *compp)           break;      }   if ((MIBNODE_T *)(ap->nodep) == 0) {       /* If we fall through the arcs, then there is no terminating leaf,          if agentx is installed we see if we have an interior leaf */#if (INSTALL_ENVOY_AGENTX_MASTER)       DYNCFG_IFCFGVBL_BEGIN(agentx_master_component)           if (np->leaf) {               /* adjust the leaf information */               np = (MIBNODE_T *)np->leaf;               break;               }           else if (ax_np) {               /* adjust the leaf, comp num and last match information */               np                 = (MIBNODE_T *)ax_np;               mlp->ml_last_match = ax_last_match;               comp_num           = ax_comp_num;               compp              = ax_compp;               break;               }       DYNCFG_IFCFGVBL_END(agentx_master_component)#endif /* INSTALL_ENVOY_AGENTX_MASTER */       return (-1);       }   /* if agentx is installed see if this inner node also has a leaf,      if it does we save some information so we can get back to it      later if necessary */#if (INSTALL_ENVOY_AGENTX_MASTER)   DYNCFG_IFCFGVBL_BEGIN(agentx_master_component)   if (np->leaf) {       ax_np         = np->leaf;       ax_last_match = *compp;       ax_comp_num   = comp_num - 1;       ax_compp      = compp + 1;       }   DYNCFG_IFCFGVBL_END(agentx_master_component)#endif /* INSTALL_ENVOY_AGENTX_MASTER */   /* Save the value of the matched arc so that later, when we call     */   /* the procs for the various objects we can tell them the last arc   */   /* matched.  This will allow the routines which access tabular       */   /* objects to know which column (attribute) of the table is being    */   /* used.                                                             */   mlp->ml_last_match = *compp;   np = (MIBNODE_T *)(ap->nodep);   }/* Here we have either run out of object identifiers or we have hit        *//* a leaf node (in which case there may be zero or more identifers left.)  *//* If agentx is installed we may need to adjust the node that we   are using.  If the current node is an inner node we try to   find a leaf, either from the current node or that we saved earlier.   If the current node is an inactive leaf we check the saved information */#if (INSTALL_ENVOY_AGENTX_MASTER)DYNCFG_IFCFGVBL_BEGIN(agentx_master_component)if ((np->node_type & NODE_TYPE) == INNER_NODE) {    if (np->leaf)        np = (MIBNODE_T *)np->leaf;    else if (ax_np) {        /* adjust the leaf, comp num and last match information */        np                 = (MIBNODE_T *)ax_np;	mlp->ml_last_match = ax_last_match;	comp_num           = ax_comp_num;	compp              = ax_compp;        }    }if (np->node_type & LEAF_INACTIVE) {    /* if agentx is installed see if we have a saved leaf */    if (ax_np) {        /* adjust the leaf, comp num and last match information */        np                 = (MIBNODE_T *)ax_np;	mlp->ml_last_match = ax_last_match;	comp_num           = ax_comp_num;	compp              = ax_compp;        }    else         return (-1);    }DYNCFG_IFCFGVBL_END(agentx_master_component)# if INSTALL_COMMON_DYNAMIC_COMP_CONFIG     DYNCFG_IFNOTCFGVBL_BEGIN(agentx_master_component)    /* If agentx isn't an installed component,       installed inactive leaves are errors */    if (np->node_type & LEAF_INACTIVE)        return (-1);    DYNCFG_IFNOTCFGVBL_END(agentx_master_component)# endif /* INSTALL_COMMON_DYNAMIC_COMP_CONFIG */#else/* If agentx isn't installed inactive leaves are errors */if (np->node_type & LEAF_INACTIVE)    return (-1);#endif /* INSTALL_ENVOY_AGENTX_MASTER */if ((np->node_type & NODE_TYPE) == LEAF_NODE) {    /* We now have the node and can start doing various checks        The first one is to determine if the type is acceptable.       In the case that we have both v1 installed and aren't allowing       v2_types we may have objects that have types that shouldn't be used       in a v1 setting.  We need to test for that case (v1 && !v2_types)       and skip any objects that have v2 types if this is a v1 packet */#if (INSTALL_ENVOY_SNMP_VERSION_1 && !(INSTALL_ENVOY_SNMP_USE_V2_TYPES))    if ((pktp->snmp_version == SNMP_VERSION_1) &&        (((MIBLEAF_T *)np)->expected_tag == VT_COUNTER64))        return(-1);#endif    /* Now we have the node we can do the old envoy view check.       It will only be required if rfc1445 views aren't installed       and the sub agent isn't installed.  (The sub agent doesn't do       view checks and the rfc1445 view check must be installed if       the master agent is also installed) */#if (INSTALL_ENVOY_MAIN_AGENT && !(INSTALL_ENVOY_SNMP_DYNAMIC_VIEWS))    if ((check_flag) && ((((MIBLEAF_T *)np)->view_mask & pktp->mib_view) == 0))        return (-2);#endif /* (INSTALL_ENVOY_MAIN_AGENT && !(INSTALL_ENVOY_SNMP_DYNAMIC_VIEWS)) */    mlp->ml_flags = ML_IS_LEAF;    }else    mlp->ml_flags = 0;#if (INSTALL_ENVOY_AGENTX_MASTER)DYNCFG_IFCFGVBL_BEGIN(agentx_master_component)/* If agentx is installed we need to reference count agentx leaves */if (np->node_type & AGENTX_LEAF) {    if (((MIBLEAF_T *)np)->ref_count == AX_MAX_REF_COUNT)        return (-3);    else         ((MIBLEAF_T *)np)->ref_count++;    }DYNCFG_IFCFGVBL_END(agentx_master_component)#endif /* INSTALL_ENVOY_AGENTX_MASTER */mlp->ml_remaining_objid.num_components = comp_num;mlp->ml_remaining_objid.component_list = compp;mlp->ml_node = np;return(0);}

⌨️ 快捷键说明

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