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

📄 snmpif.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 5 页
字号:
/* snmpIf.c  - snmp v1 interface group method routines *//* *  Copyright 1984-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. */#include "copyright_wrs.h"/*modification history-------------------01f,19apr05,job  update copyright notices01e,01dec03,job  update copyright information01d,06oct98,ann  Removed unused variable snmpNumInterfaces (SPR #21720)01c,06oct97,rjc  Added missing comma in function call.01b,21aug97,ann  Updated comments to include non ip interfaces01a,10mar96,rjc  written*//* * $Log: snmpif.c,v $ * Revision 1.10  2002/12/02 21:11:33  josh * change nextproc_no_next() calling loops to properly mark all varbinds * * Revision 1.9  2002/08/26 20:31:07  josh * modifications to the code to eliminate warnings from Diab compiler * * Revision 1.8  2002/06/20 15:21:05  meister * Fixed some function storage class compiler warnings * (static/non-static inconsistencies) * * Revision 1.7  2002/01/14 18:59:54  tneale * Initialize local variable in ifRcvAddrEntryNext, to avoid compiler warning * * Revision 1.6  2002/01/09 19:39:22  tneale * Made the new prototypes conditional on RFC2233, as they should be * * Revision 1.5  2002/01/04 22:41:48  tneale * Added forward declarations for ifStackEntryInfoGet, ifRcvAddrInfoGet, and ifRcvAddrEntryBuildInstance * * Revision 1.4  2001/11/09 17:30:25  tneale * Another adjustment for generated header files * * Revision 1.3  2001/11/09 14:54:08  tneale * Fixed paths for generated files mibhand.h and mibleaf.h * * Revision 1.2  2001/11/08 22:18:34  meister * rework pathnames * * Revision 1.1.1.1  2001/11/05 17:47:49  tneale * Tornado shuffle * * Revision 1.8.4.2  2001/10/31 21:51:31  josh * patching RFC2233 method routines so that they'll pass the IWL * tests, within the limits of the capabilities of the method routines. * * Revision 1.8.4.1  2001/10/18 21:29:03  josh * some bounds-checking so we don't try to copy a 100 byte string * into 16 bytes * * Revision 1.8  2001/06/21 21:28:16  josh * and the fun just keeps on leaving... * * Revision 1.7  2001/06/21 17:45:15  josh * Make sure all objects are properly handled -- we shouldn't be * generating GEN_ERRs while doing a tree walk * * Revision 1.6  2001/06/18 20:02:36  tneale * Added rfc2233.ctl.  Also modified snmpif.c and makefile.cfg for support of * rfc2233, controlled by installation option ENVOY_RFC2233 * * Revision 1.5  2001/01/19 22:25:05  paul * Update copyright. * * Revision 1.4  2000/03/09 17:42:26  josh * setting up prototypes and includes where appropriate to eliminate * build warnings * * Revision 1.3  2000/03/07 21:17:27  josh * fixing log comments * * Revision 1.2  2000/03/07 20:58:36  josh * putting CVS headers and logs into files that were lacking * *//* includes */#include <wrn/wm/snmp/vxagent/snmpdLib.h>#include "m2Lib.h"#include <wrn/wm/snmp/vxagent/mibleaf.h>#include <wrn/wm/snmp/vxagent/mibhand.h>#include <wrn/wm/snmp/engine/auxfuncs.h>/* defines */#define IF_INDEX_LEN     1           /* Num of oid components in interface                                         table index */#if (INSTALL_ENVOY_VXWORKS_RFC2233)#define IF_STACKTBL_INDEX_LEN  2    /* Num of oid components in stack table                                     * index                                     */#endif /* #if (INSTALL_ENVOY_VXWORKS_RFC2233) *//* locals */LOCAL  const OIDC_T maxIfIndex []   = { 0xffffffff };  /* max possible value                                                           for interface index *//* externs *//* forward declarations */LOCAL void ifEntryUndo (OIDC_T, int, OIDC_T *, SNMP_PKT_T *, VB_T *);#if (INSTALL_ENVOY_VXWORKS_RFC2233)LOCAL void interfacesInfoGet (OIDC_T, SNMP_PKT_T *, VB_T *, M2_INTERFACE *);LOCAL void ifEntryInfoGet (OIDC_T, SNMP_PKT_T*, VB_T *, M2_DATA*);LOCAL void ifXEntryInfoGet (OIDC_T, SNMP_PKT_T *, VB_T *, M2_DATA *);LOCAL int check_nvt (OCTET_T *, size_t);void ifStackEntryInfoGet ( OIDC_T, SNMP_PKT_T *, VB_T *, M2_IFSTACKTBL *);void ifRcvAddrInfoGet ( OIDC_T, SNMP_PKT_T *, VB_T *, M2_IFRCVADDRTBL *);int ifRcvAddrEntryBuildInstance ( int, M2_IFRCVADDRTBL *, OIDC_T *);#else /* #if (INSTALL_ENVOY_VXWORKS_RFC2233) */LOCAL void ifEntryInfoGet (OIDC_T, SNMP_PKT_T*, VB_T *, M2_INTERFACETBL*);#endif /* #if (INSTALL_ENVOY_VXWORKS_RFC2233) *//* 			Support for non ip interfaces** The routines provided in this file to access the interface tables are confined* to the ip interfaces installed in the default vxWorks ip stack. In case you* wish to incorporate non ip interfaces into your snmp tables the following* modifications will need to be made to these routines.* * First decide what will be the maximum number of ip interfaces added to * your system, say maxIpIf.This value represents the maximum no of ip interfaces* added to your system irrespective of whether they are deleted or not. In other* words deleting an ip interface does not reduce the value of maxIpIf.* Then the various m2IfLib functions will use the range  1 to maxIpIf* as the snmp ifIndex values used to identify the interfaces. You may therefore* use values in the range maxIfIp + 1 (or some larger value) to 0xffff as the * index values for non ip interfaces. It is important that these ranges do not * overlap.  In addition to this the routines to access the interfaces will have to * change. * * Look below in the get and next routines for further information. */    /*******************************************************************************  interfacesGet**  Get method routine for interfaces group scalars**  Parameters to this routine are *  *  <lastmatch> - the last oid component that was matched to get to this leaf.*  <tcount>     - count of components remaining in the unmatched portion i.e.*                the length of the instance portion.*  <tlist>     - ptr to the oid sequence remaining, i.e. the instance portion.*  <pktp>      - ptr to internal representation of the snmp pkt.*  <vbp>       - ptr to var bind being processed.**  RETURNS: N/A*/    void interfacesGet    (    OIDC_T              lastmatch,    int	                tcount,    OIDC_T *            tlist,    SNMP_PKT_T *        pktp,    VB_T *              vbp    )    {    M2_INTERFACE        interfacesVar;      if ((tcount != 1) || (*tlist != 0))        {        for ( ; vbp != NULL; vbp = vbp->vb_link)            {            getproc_nosuchins (pktp, vbp);            }        return;        }     /* Only scalar in interfaces group is ifNumber */#if (INSTALL_ENVOY_VXWORKS_RFC2233)    if (m2IfGroupInfoGet (&interfacesVar) != OK)        {        for ( ; vbp != NULL; vbp = vbp->vb_link)             {             getproc_error (pktp, vbp, GEN_ERR);             }        return;        }    for (   ; vbp; vbp = vbp->vb_link)        {        interfacesInfoGet (vbp->vb_ml.ml_last_match, pktp, vbp,                                                 &interfacesVar);        }    #else /* #if (INSTALL_ENVOY_VXWORKS_RFC2233) */    if ((lastmatch != LEAF_ifNumber) ||         (m2IfGroupInfoGet (&interfacesVar) != OK))        {        for ( ; vbp != NULL; vbp = vbp->vb_link)             {             getproc_error (pktp, vbp, GEN_ERR);             }        return;        }    getproc_got_int32 (pktp, vbp, (INT_32_T)interfacesVar.ifNumber);#endif /* #if (INSTALL_ENVOY_VXWORKS_RFC2233) */    }    #if (INSTALL_ENVOY_VXWORKS_RFC2233)/******************************************************************************** interfacesInfoGet - Bind the scalar variables of the interfaces group**/LOCAL void interfacesInfoGet    (    OIDC_T              lastmatch,    SNMP_PKT_T *        pktp,    VB_T *              vbp,    M2_INTERFACE *      pIfData        )    {    switch (lastmatch)        {        case LEAF_ifNumber:            getproc_got_int32 (pktp, vbp, (INT_32_T)pIfData->ifNumber);            break;        case LEAF_ifTableLastChange:            getproc_got_uint32 (pktp, vbp, pIfData->ifTableLastChange,                                                          VT_TIMETICKS);            break;        case LEAF_ifStackLastChange:            getproc_got_uint32 (pktp, vbp, pIfData->ifStackLastChange,                                                          VT_TIMETICKS);            break;        default:            getproc_error (pktp, vbp, GEN_ERR);            return;        }    }    /******************************************************************************* ifEntryGet **  Get method routine for interfaces group tabular variables.**  Parameters to this routine are *  *  <lastmatch> - the last oid component that was matched to get to this leaf.*  <tcount>     - count of components remaining in the unmatched portion i.e.*                the length of the instance portion.*  <tlist>     - ptr to the oid sequence remaining, i.e. the instance portion.*  <pktp>      - ptr to internal representation of the snmp pkt.*  <vbp>       - ptr to var bind being processed.**  RETURNS: N/A*/    void ifEntryGet    (    OIDC_T              lastmatch,    int	                tcount,    OIDC_T *            tlist,    SNMP_PKT_T *        pktp,    VB_T *              vbp    )    {    M2_DATA             ifData;        /* Group together all varbinds which have the same getproc and instance */    snmpdGroupByGetprocAndInstance(pktp, vbp, tcount, tlist);     if (tcount != 1)        {        for ( ; vbp != NULL; vbp = vbp->vb_link)            {            getproc_nosuchins (pktp, vbp);            }        return;        }    /* Extract the interface index for indexing into the interface table */    ifData.mibIfTbl.ifIndex = *tlist;    /* Support for non ip interfaces: Your code to test the value of ifIndex     *  could go in here. Based on the value, you should decide wether to index     *  into the ip or the non ip interface tables. If ifIndex > maxIpIf then the     *  m2IfTblEntryGet routine should be bypassed and the search should be carried     *  out in the non ip interface table.    */      if (m2IfTblEntryGet (M2_EXACT_VALUE, &ifData) != OK)        {        for ( ; vbp != NULL; vbp = vbp->vb_link)            {            getproc_nosuchins (pktp, vbp);            }        return;        }    for (   ; vbp; vbp = vbp->vb_link)        {        ifEntryInfoGet (vbp->vb_ml.ml_last_match, pktp, vbp, &ifData);        }    }            /*******************************************************************************  ifEntryNext**  Next method routine for interfaces group tabular variables.**  Parameters to this routine are *  *  <lastmatch> - the last oid component that was matched to get to this leaf.*  <tcount>     - count of components remaining in the unmatched portion i.e.*                the length of the instance portion.*  <tlist>     - ptr to the oid sequence remaining, i.e. the instance portion.*  <pktp>      - ptr to internal representation of the snmp pkt.*  <vbp>       - ptr to var bind being processed.***  RETURNS: N/A*  */    void ifEntryNext    (    OIDC_T              lastmatch,    int	                tcount,    OIDC_T *            tlist,    SNMP_PKT_T *        pktp,    VB_T *              vbp    )    {    OIDC_T              ifIndex [IF_INDEX_LEN];    /* Oid sequence for                                                       interface index */    M2_DATA             ifData;    /* Group together all varbinds which have the same getproc and instance */    snmpdGroupByGetprocAndInstance (pktp, vbp, tcount, tlist);    *ifIndex = (tlist != NULL) ? *tlist : 0;#if 0    /*     This is the way we normally process a next request for a table entry.    However in the case of the interfaces table using the M2_NEXT_VALUE    flag with m2IfTblEntryGet returns the instance which is lexi greater    than the argument while other m2 functions return the lexi greater    *or equal* value. Therefore we bypass the increment of the index    in this case. Ideally the m2IfTblEntryGet should be changed to be     consistent but that could break existing code.    */    if (snmpNextIndex (tcount, tlist, ifIndex, maxIfIndex, IF_INDEX_LEN))        {        for ( ; vbp != NULL; vbp = vbp->vb_link)            {            nextproc_no_next (pktp, vbp);            }        return;        }#endif    ifData.mibIfTbl.ifIndex = *ifIndex;    /*    *  Support for non ip interfaces: You can test the value of ifIndex here.     *  Depending on the value of the ifIndex, you might have to search both the     *  ip and non ip interface tables.    *     *  If ifIndex > maxIpIf then bypass the m2IfTblEntryGet routine and restrict    *  your search to the non ip interface table. If ifIndex <= maxIpIf then    *  use the m2IfTblEntryGet routine. However, if this is unsuccessful, then     *  you will have to search the non ip interface table because the next     *  interface is non ip.    */      if (m2IfTblEntryGet (M2_NEXT_VALUE, &ifData) != OK)        {        for ( ; vbp != NULL; vbp = vbp->vb_link)            {                      nextproc_no_next (pktp, vbp);             }        return;        }    /* Create oid sequence for interface index retrieved */    *ifIndex = ifData.mibIfTbl.ifIndex;    for (    ; vbp; vbp = vbp->vb_link)        {            /* install instance part of next instance found */            nextproc_next_instance (pktp, vbp, IF_INDEX_LEN, ifIndex);

⌨️ 快捷键说明

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