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

📄 snmpif.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 5 页
字号:
                                            tmpInstLen, bestInst) < 0)))            {            MEMCPY (&bestRcvAddr, &rcvAddr, sizeof (M2_IFRCVADDRTBL));            MEMCPY (bestInst, tmpInst, tmpInstLen * sizeof (OIDC_T));            bestInstLen = tmpInstLen;            bestExists = 1;            }        }    if (bestExists == 1)        {        for (    ; vbp; vbp = vbp->vb_link)            {            nextproc_next_instance (pktp, vbp, bestInstLen, bestInst);            ifRcvAddrInfoGet (vbp->vb_ml.ml_last_match, pktp,                              vbp, &bestRcvAddr);            }        }    else        for ( ; vbp ; vbp = vbp->vb_link )            nextproc_no_next (pktp, vbp);    }/******************************************************************************* IfRcvaddrEntryTest **  Test 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 ifRcvAddrEntryTest    (    OIDC_T              lastmatch,    int	                tcount,    OIDC_T*             tlist,    SNMP_PKT_T*	        pktp,    VB_T*               vbp    )    {        if ((tcount < 2) || (tcount != tlist[1] + 2) ||         (tcount > MAXIFPHYADDR + 2))        {        testproc_error (pktp, vbp, NO_SUCH_NAME);        return;        }    snmpdGroupByGetprocAndInstance (pktp, vbp, tcount, tlist);            vbp->vb_priv = (M2_IFRCVADDRTBL *) snmpdMemoryAlloc                                        (sizeof (M2_IFRCVADDRTBL));    if (!vbp->vb_priv)        {        testproc_error(pktp, vbp, GEN_ERR);        return;        }    vbp->vb_free_priv = (VBPRIVPROC_T *) snmpVbPrivFree;    bzero (vbp->vb_priv, sizeof (M2_IFRCVADDRTBL));    for ( ; vbp ; vbp = vbp->vb_link)        {        switch (lastmatch)            {            case LEAF_ifRcvAddressStatus:                switch (vbp->value_u.v_number)                    {                    case VAL_ifRcvAddressStatus_active:                    case VAL_ifRcvAddressStatus_notInService:                    case VAL_ifRcvAddressStatus_notReady:                    case VAL_ifRcvAddressStatus_createAndGo:                    case VAL_ifRcvAddressStatus_createAndWait:                    case VAL_ifRcvAddressStatus_destroy:                        break;                    default:                        testproc_error(pktp, vbp, WRONG_VALUE);                        return;                    }                break;                             case LEAF_ifRcvAddressType:                switch (vbp->value_u.v_number)                    {                    case VAL_ifRcvAddressType_other:                    case VAL_ifRcvAddressType_volatile:                    case VAL_ifRcvAddressType_nonVolatile:                        break;                    default:                        testproc_error(pktp, vbp, WRONG_VALUE);                        return;                    }                            break;                             default:                testproc_error(pktp, vbp, GEN_ERR);                return;                   }        testproc_good (pktp, vbp);        }        return;    }/******************************************************************************* ifRcvAddrEntrySet **  Set 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 ifRcvAddrEntrySet    (    OIDC_T              lastmatch,    int	                tcount,    OIDC_T *            tlist,    SNMP_PKT_T *        pktp,    VB_T*               vbp            )    {    int                 index;    int                 varToSet = 0;    M2_IFRCVADDRTBL     rcvAddr;    int                 i;        if ((tcount < 2) || (tcount != tlist[1] + 2) ||        (tcount > MAXIFPHYADDR + 2))        {        for ( ; vbp != NULL; vbp = vbp->vb_link)            {            getproc_nosuchins (pktp, vbp);            }        return;                    }    index = *tlist;    for (i = 2; i < tcount; i++)        rcvAddr.ifRcvAddrAddr.phyAddress[i-2] = *(tlist + i);    rcvAddr.ifRcvAddrAddr.addrLength = tcount - 2;    switch (lastmatch)        {        case LEAF_ifRcvAddressStatus:            rcvAddr.ifRcvAddrStatus = vbp->value_u.v_number;            varToSet |= M2_IFRCVADDRSTATUS;            break;                        case LEAF_ifRcvAddressType:            rcvAddr.ifRcvAddrType = vbp->value_u.v_number;            varToSet |= M2_IFRCVADDRTYPE;            break;                    default:            setproc_error(pktp, vbp, COMMIT_FAILED);            return;                      }    if (m2IfRcvAddrEntrySet (varToSet, index, &rcvAddr) != OK)        {        snmpVbPrivFree (vbp);        setproc_error (pktp, vbp, COMMIT_FAILED);        return;        }    setproc_good (pktp, vbp);    }/* check NVT compliance.  Return 0 if good. */static int check_nvt    (    OCTET_T *cp,    size_t len    )    {    while (len--)        {        if ((*cp & 0200) != 0)            return -1;        if (*cp++ == '\r')            {            if (len-- == 0)                return -1;            if ((*cp == '\n') || (*cp == 0))                cp++;            else                return -1;            }        }    return 0;    }#else /* #if (INSTALL_ENVOY_VXWORKS_RFC2233) *//******************************************************************************* 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_INTERFACETBL     ifEntry;        /* 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 */    ifEntry.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, &ifEntry) != 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, &ifEntry);        }    }        /*******************************************************************************  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_INTERFACETBL     ifEntry;    /* 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    ifEntry.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, &ifEntry) != OK)        {        for ( ; vbp != NULL; vbp = vbp->vb_link)            {                      nextproc_no_next (pktp, vbp);             }        return;        }    /* Create oid sequence for interface index retrieved */    *ifIndex = ifEntry.ifIndex;    for (    ; vbp; vbp = vbp->vb_link)        {            /* install instance part of next instance found */            nextproc_next_instance (pktp, vbp, IF_INDEX_LEN, ifIndex);        ifEntryInfoGet (vbp->vb_ml.ml_last_match, pktp, vbp, &ifEntry);        }    }        /******************************************************************************* ifEntryTest **  Test 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 ifEntryTest    (    OIDC_T              lastmatch,    int	                tcount,    OIDC_T*             tlist,    SNMP_PKT_T*	        pktp,    VB_T*               vbp    )    {    M2_INTERFACETBL     ifEntry;    int                 errorStatus;    if (tcount != 1)        {        errorStatus =  NO_SUCH_NAME;        goto errorReturn;        }    if (lastmatch != LEAF_ifAdminStatus)        {        errorStatus = GEN_ERR;        goto errorReturn;        }     /* Allocate 2 longs to save index and interface

⌨️ 快捷键说明

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