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

📄 snmpip.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 4 页
字号:
/* snmpIp.c - snmp v1 ip 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-------------------01e,19apr05,job  update copyright notices01d,01dec03,job  update copyright information01c,21oct98,ann  corrected syntax for ipAdEntBcastAddr (SPR# 9117)01b,10sep98,ann  corrected parameter in call to ipAddrEntryInfoGet (SPR# 20179)01a,10mar96,rjc  written*//* * $Log: snmpip.c,v $ * Revision 1.9  2002/09/07 20:35:02  markadam * Fixed SPR 80626. Enabled write access to ipRouteMask. * * Revision 1.8  2002/06/28 21:17:56  josh * a fix that both Diab and gcc will like * * Revision 1.7  2002/06/24 20:24:23  josh * fix call to ip_to_llist() to eliminate compiler warnings * * Revision 1.6  2002/06/20 15:21:05  meister * Fixed some function storage class compiler warnings * (static/non-static inconsistencies) * * Revision 1.5  2002/06/07 15:59:48  josh * fix setproc for ipRouteTable * * 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:35  meister * rework pathnames * * Revision 1.1.1.1  2001/11/05 17:47:49  tneale * Tornado shuffle * * Revision 1.8  2001/04/27 21:08:41  josh * some slightly cleaner handling of sets in the ipRouteTable * * Revision 1.7  2001/04/24 17:44:11  josh * updating vxWorks agent with modifications carried over * from Windnet/SNMP agent * * Revision 1.6  2001/04/16 19:38:43  josh * merging the kingfisher branch onto the trunk * * Revision 1.5  2001/01/19 22:25:05  paul * Update copyright. * * Revision 1.4.2.3  2001/03/12 22:11:34  tneale * Updated copyright * * Revision 1.4.2.2  2001/03/06 18:09:42  josh * A workaround method routine to fix a bug in the ipNetToMediaEntry * access routines. * * Revision 1.4.2.1  2001/02/06 20:39:06  josh * fixing a bug in the nextproc for the ipAddrTable * * 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 IP_ADDR_LEN               4               /* Num of oid components in                                                      ip address */#define IP_NET_TO_MEDIA_INDEX_LEN (1+IP_ADDR_LEN) /* Num of oid components in                                                      netToMediatable index */#define IP_MAX_TTL               255          /* max possible value for ttl*//* locals *//* max possible values for some table indexes */LOCAL  const OIDC_T maxNetToMediaIndex [] = { 0xffffffff, 0xff, 0xff, 0xff,                                              0xff };LOCAL  const OIDC_T maxIpAddr []          = { 0xff, 0xff, 0xff, 0xff };/* forward declarations */LOCAL void ipRouteEntryInfoGet (OIDC_T, SNMP_PKT_T *, VB_T *, M2_IPROUTETBL *);LOCAL void ipAddrEntryInfoGet (OIDC_T, SNMP_PKT_T *, VB_T *, M2_IPADDRTBL *);LOCAL void ipNetToMediaEntryInfoGet (OIDC_T , SNMP_PKT_T *, VB_T *,                                      M2_IPATRANSTBL *);void ipRouteEntryUndo (OIDC_T, int, OIDC_T *, SNMP_PKT_T *, VB_T * );LOCAL void ipUndo (OIDC_T, int, OIDC_T *, SNMP_PKT_T *, VB_T * );LOCAL void ipNetToMediaEntryUndo (OIDC_T, int, OIDC_T *, SNMP_PKT_T *, VB_T * );    /*******************************************************************************  ipRouteEntryGet -   Get method routine for  ipRouteTable.*  *  Parameters to this routine are *  *  <lastmatch> - the last oid component that was matched to get to this leaf.*  <compc>     - count of components remaining in the unmatched portion i.e.*                the length of the instance portion.*  <compl>     - 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.**  NOMANUAL**  RETURNS: N/A*/    void ipRouteEntryGet    (    OIDC_T              lastmatch,    int                 compc,    OIDC_T *             compl,    SNMP_PKT_T *         pktp,    VB_T *               vbp    )    {    M2_IPROUTETBL       rteEntry;        /* Group together all varbinds which have the same getproc and instance */    snmpdGroupByGetprocAndInstance (pktp, vbp, compc, compl);    /* check for valid ip address  and whether  route entry exists */    if ((compc != IP_ADDR_LEN) ||         snmpOidToIpHostOrder (IP_ADDR_LEN, compl, &rteEntry.ipRouteDest) ||        (m2IpRouteTblEntryGet (M2_EXACT_VALUE, &rteEntry) != OK ))        {        for ( ; vbp != NULL; vbp = vbp->vb_link)            {            getproc_nosuchins (pktp, vbp);            }        return;        }    for (  ; vbp; vbp = vbp->vb_link)        {        /* Next step is to extract the values from the rteEntry struct         * and install it in the output pkt         */        ipRouteEntryInfoGet (vbp->vb_ml.ml_last_match, pktp, vbp, &rteEntry);        }    }        /*******************************************************************************  ipRouteEntryInfoGet -  Routine to extract info from M2_ROUTETBL structure *  *  <lastmatch> - the last oid component that was matched to get to this leaf.*  <pktp>      - ptr to internal representation of the snmp pkt.*  <vbp>       - ptr to var bind being processed.*  <pRteEntry> - ptr to M2_IPROUTETBL structure containing the info required*                for this instance.**  RETURNS: N/A*/        LOCAL void ipRouteEntryInfoGet     (    OIDC_T               lastmatch,    SNMP_PKT_T *         pktp,    VB_T *               vbp,    M2_IPROUTETBL *      pRteEntry    )    {    switch (lastmatch)         {        case LEAF_ipRouteDest:            getproc_got_ip_address (pktp, vbp, htonl (pRteEntry->ipRouteDest));            break;        case LEAF_ipRouteIfIndex:            getproc_got_int32 (pktp, vbp, pRteEntry->ipRouteIfIndex);            break;        case LEAF_ipRouteMetric1:             getproc_got_int32 (pktp, vbp, pRteEntry->ipRouteMetric1);             break;        case LEAF_ipRouteMetric2:             getproc_got_int32 (pktp, vbp, pRteEntry->ipRouteMetric2);             break;        case LEAF_ipRouteMetric3:              getproc_got_int32 (pktp, vbp, pRteEntry->ipRouteMetric3);             break;        case LEAF_ipRouteMetric4:             getproc_got_int32 (pktp, vbp, pRteEntry->ipRouteMetric4);             break;        case LEAF_ipRouteNextHop:             getproc_got_ip_address (pktp, vbp,                                      htonl (pRteEntry->ipRouteNextHop));             break;        case LEAF_ipRouteType:             getproc_got_int32 (pktp, vbp, pRteEntry->ipRouteType);             break;        case LEAF_ipRouteProto:             getproc_got_int32 (pktp, vbp, pRteEntry->ipRouteProto);             break;        case LEAF_ipRouteAge:             getproc_got_int32 (pktp, vbp, pRteEntry->ipRouteAge);             break;        case LEAF_ipRouteMask:             getproc_got_ip_address (pktp, vbp, htonl (pRteEntry->ipRouteMask));             break;        case LEAF_ipRouteMetric5:             getproc_got_int32 (pktp, vbp, pRteEntry->ipRouteMetric5);             break;        case LEAF_ipRouteInfo:             getproc_got_object_id (pktp, vbp, pRteEntry->ipRouteInfo.idLength,                                     (OIDC_T *)pRteEntry->                                              ipRouteInfo.idArray, 0);             break;        default:             getproc_error (pktp, vbp, GEN_ERR);             break;                  }    }    /*******************************************************************************  ipRouteEntryNext -  Next method routine for ipRouteTable.**  Parameters to this routine are *  *  <lastmatch> - the last oid component that was matched to get to this leaf.*  <compc>     - count of components remaining in the unmatched portion i.e.*                the length of the instance portion.*  <compl>     - 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.**  NOMANUAL**  RETURNS: N/A*/    void ipRouteEntryNext    (    OIDC_T              lastmatch,    int                 compc,    OIDC_T *             compl,    SNMP_PKT_T *         pktp,    VB_T *               vbp    )    {    M2_IPROUTETBL       rteEntry;               /* routing table entry */    OIDC_T              addr [IP_ADDR_LEN];     /* buffer for ip address in oid                                                   form */        snmpdGroupByGetprocAndInstance (pktp, vbp, compc, compl);    /* Increment instance part by 1  */    if (snmpNextIndex (compc, compl, addr, maxIpAddr, IP_ADDR_LEN))        {        /* Instance part was already >= max possible index */         for ( ; vbp != NULL; vbp = vbp->vb_link)            {            nextproc_no_next (pktp, vbp);            }        return;        }    else         {        /* extract destn ip address, which is the index for the route table */        (void) snmpOidToIpHostOrder (IP_ADDR_LEN, addr, &rteEntry.ipRouteDest);        if (m2IpRouteTblEntryGet (M2_NEXT_VALUE, &rteEntry) == OK )            {            /* convert ip address to oid form, for output pkt */            (void) ip_to_rlist (htonl (rteEntry.ipRouteDest), addr);            for (   ; vbp; vbp = vbp->vb_link)                {                nextproc_next_instance (pktp, vbp, IP_ADDR_LEN, addr);                ipRouteEntryInfoGet (vbp->vb_ml.ml_last_match, pktp, vbp,                                      &rteEntry);                }            return;            }        else            {            /* Either there is no next instance or else some error              * occurred             */            for ( ; vbp != NULL; vbp = vbp->vb_link)                {                snmpNextError (pktp, vbp);                }            return;            }        }    }        /*******************************************************************************  ipRouteEntryTest -  Test method routine for system group for ipRouteTable.**  Parameters to this routine are *  *  <lastmatch> - the last oid component that was matched to get to this leaf.*  <compc>     - count of components remaining in the unmatched portion i.e.*                the length of the instance portion.*  <compl>     - 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.**  NOMANUAL*  *  RETURNS: N/A*/    void ipRouteEntryTest     (    OIDC_T              lastmatch,    int      	        compc,    OIDC_T *            compl,    SNMP_PKT_T *        pktp,    VB_T *              vbp    )    {    M2_IPROUTETBL *     pRteEntry;            /* route entry ptr */    BOOL                entryExists = TRUE;   /* existing route entry or not */    int                 errorStatus;          /* error status value */     BOOL                nextHopFlag = FALSE;  /* To check if nextHop field is                                                  present */    VB_T *              pVbpSaved = vbp;    unsigned long       addr;    vbp->vb_priv = snmpdMemoryAlloc (sizeof (M2_IPROUTETBL));    pRteEntry = (M2_IPROUTETBL *) vbp->vb_priv;    if  ( pRteEntry == NULL )        {        errorStatus =   RESOURCE_UNAVAILABLE;        goto errorReturn;        }       /* callback rtn for freeing vb_priv memory */    vbp->vb_free_priv = (VBPRIVPROC_T *) snmpVbPrivFree;    /* check for valid instance */    if (compc != IP_ADDR_LEN ||           snmpOidToIpHostOrder (IP_ADDR_LEN, compl, &pRteEntry->ipRouteDest))        {        errorStatus = NO_SUCH_NAME;        goto errorReturn;        }    if (m2IpRouteTblEntryGet (M2_EXACT_VALUE, pRteEntry) != OK)        {        /* new row is to be created, so undo action is to delete it */        pRteEntry->ipRouteType = M2_ipRouteType_invalid;        entryExists =  FALSE;         }    /* Group together all varbinds which have the same getproc and instance */    for (snmpdGroupByGetprocAndInstance (pktp, vbp, compc, compl); vbp; vbp =                vbp->vb_link)        {        switch (vbp->vb_ml.ml_last_match)            {            case LEAF_ipRouteIfIndex:                if (vbp->value_u.v_number != pRteEntry->ipRouteIfIndex)                    {                    errorStatus = INCONSISTENT_VALUE;                    goto errorReturn;                    }                break;                                case LEAF_ipRouteMetric1:                if (vbp->value_u.v_number != pRteEntry->ipRouteMetric1)                    {                    errorStatus = INCONSISTENT_VALUE;                    goto errorReturn;                    }                break;                            case LEAF_ipRouteMetric2:                if (vbp->value_u.v_number != pRteEntry->ipRouteMetric2)                    {                    errorStatus = INCONSISTENT_VALUE;                    goto errorReturn;                    }                break;                            case LEAF_ipRouteMetric3:                if (vbp->value_u.v_number != pRteEntry->ipRouteMetric3)                    {                    errorStatus = INCONSISTENT_VALUE;                    goto errorReturn;                    }                break;                            case LEAF_ipRouteMetric4:                if (vbp->value_u.v_number != pRteEntry->ipRouteMetric4)                    {                    errorStatus = INCONSISTENT_VALUE;                    goto errorReturn;                    }                break;                            case LEAF_ipRouteMetric5:                if (vbp->value_u.v_number != pRteEntry->ipRouteMetric5)                    {                    errorStatus = INCONSISTENT_VALUE;                    goto errorReturn;                    }                break;                            case LEAF_ipRouteAge:                if (vbp->value_u.v_number != pRteEntry->ipRouteAge)                    {                    errorStatus = INCONSISTENT_VALUE;                    goto errorReturn;                    }                break;                                                    case LEAF_ipRouteMask:#ifndef M2_IP_ROUTE_MASK                        /* If the m2lib does not support SETs for this object,                           and if the value in the varbind does not match the                           current value return an error. */                memcpy (&addr, vbp->value_u.v_network_address, IP_ADDR_LEN);

⌨️ 快捷键说明

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