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

📄 pxy3_chk.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 5 页
字号:
/* *  Copyright 2000-2006 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. *//* pxy3_chk.c - code to handle forwarding of SNMPv3 proxies *//*modification history--------------------01g,14mar06,jbl  fix a deadlock issue01f,18apr05,job  update copyright notices01e,24nov03,job  update copyright information01d,28aug03,job  select multiple proxy objects for notification forwarding01c,31jul03,job  correct a few errors in the previous fix01b,16jul03,job  coexistence processing fix01a,18apr03,job  make sure error code and index make it into return PDU$Log: pxy3_chk.c,v $Revision 1.8  2003/01/15 14:05:06  joshdirectory structure shiftingRevision 1.7  2002/08/26 20:31:05  joshmodifications to the code to eliminate warnings from Diab compilerRevision 1.6  2002/05/17 18:46:50  joshimprove use of MMS in PDU processingRevision 1.5  2002/01/15 21:42:03  joshcleaning up the code a bit...ritual purificationRevision 1.4  2002/01/10 15:44:22  joshwhen proxying a GetBulkRequest-PDU, the non-reps and max-reps valuesare pulled from error_status and error_index.Revision 1.3  2001/11/06 21:50:48  joshsecond (and hopefully final) pass of new path hackingRevision 1.2  2001/11/06 21:20:20  joshrevised new path hackingRevision 1.1.1.1  2001/11/05 17:47:43  tnealeTornado shuffleRevision 9.2.2.8  2001/09/24 16:45:06  joshwarning cleanupRevision 9.2.2.7  2001/09/21 20:52:29  joshextra cleanup for various combinations of installation optionsRevision 9.2.2.6  2001/09/21 19:29:48  joshcoexistence support for SNMPv3 proxiesRevision 9.2.2.5  2001/08/31 17:02:21  joshclean up a few nitsRevision 9.2.2.4  2001/08/30 21:16:07  joshfinal logic for SNMPv3 proxiesRevision 9.2.2.3  2001/08/24 14:40:22  joshrewrite of process_packet_one() and general rearrangement of codeto accomodate proxiesRevision 9.2.2.2  2001/07/16 18:02:14  josha first-round commit adding infrastructure supportfor the SNMPv3 Coexistence RFC (2576)Revision 9.2.2.1  2001/06/28 18:22:58  joshSeeding the Cormorant branch with the code from the oldcormorant branchRevision 9.1.2.1  2001/04/11 19:35:41  joshmoving cormorant-specific files onto the specialcormorant branch so they don't get in kingfisher's wayRevision 9.1  2001/01/19 22:22:24  paulUpdate copyright.Revision 9.0  2000/07/12 21:22:36  joshupdating version stampRevision 1.1  2000/07/12 21:21:53  joshcode to handle proxy forwarding, initial checkin*//*DESCRIPTIONThis module contains the functions called byt he PDU processing code todetermine whether and where to forward packets.INCLUDE FILES:  asn1.h, snmp.h, buffer.h, etimer.h, objectid.h,                v3_proxy.h, snmpdefs.h, ntfy_chk.h, bug.h *//* includes */#include <wrn/wm/snmp/engine/asn1.h>#include <wrn/wm/snmp/engine/snmp.h>#include <wrn/wm/snmp/engine/buffer.h>#include <wrn/wm/snmp/engine/etimer.h>#include <wrn/wm/snmp/engine/objectid.h>#include <wrn/wm/snmp/engine/ntfy_chk.h>#include <wrn/wm/snmp/engine/v3_eng.h>#include <wrn/wm/snmp/engine/v3_proxy.h>#include <wrn/wm/snmp/engine/v3_comm.h>#include <wrn/wm/snmp/engine/snmpdefs.h>#include <wrn/wm/snmp/engine/wkobj.h>#include <wrn/wm/common/bug.h>#if INSTALL_ENVOY_SNMP_COEXISTENCE#define sizeof_snmpUDPDomain 7static OIDC_T snmpUDPDomain[] = { 1, 3, 6, 1, 6, 1, 1 };#endif#ifndef ENVOY_SET_PROXY_MSGID#define ENVOY_SET_PROXY_MSGID(PCB) \    (PCB)->msgID = (*(root_proxy_block.nextMsgID))++#endifstatic void proxy_timer_exp(ENVOY_TIMER_T *, void *);/***************************************************************************** proxyBlockClean - clean a proxy block, freeing any associated memory** This function will go through a proxy block, freeing any* associated memory, and then free the proxy block itself.** RETURNS:  Nothing.**/static void proxyBlockClean    (    SNMP_PROXY_CB_T *proxyBlock    )    {    TARGET_LIST_T *targetList;    TARGET_LIST_T *nextTargetList;        EBufferClean (&proxyBlock->contextEngineID);    EBufferClean (&proxyBlock->contextName);    EBufferClean (&proxyBlock->secName);    EBufferClean (&proxyBlock->communityString);    if (proxyBlock->originalPkt != 0)        {        (proxyBlock->originalPkt->error_complete)            (&proxyBlock->originalPkt->pkt_src,             &proxyBlock->originalPkt->pkt_dst,             1, proxyBlock->originalPkt->async_cookie);        SNMP_Free (proxyBlock->originalPkt);        }    for (targetList = proxyBlock->targetList; targetList != 0;         targetList = nextTargetList)        {        nextTargetList = targetList->next;        if (targetList->pktp != 0)             {            if ((proxyBlock->flags & SNMP_PROXY_FLAGS_VBLIST_COPIED) == 0)                MEMSET (&(targetList->pktp->pdu.std_pdu.std_vbl),                        0, sizeof (VBL_T));            SNMP_Free (targetList->pktp);            targetList->pktp = 0;            }        targetList->next = 0;        clean_target_list (targetList);        }    SNMP_memory_free (proxyBlock);    }            /***************************************************************************** NAME: proxy_timer_update** PURPOSE: Walk the proxy block list and determine whether the proxy*          timer needs to be set (or reset).  This call is always made*          with the list locked, so care should be exercised...* * RETURNS: nothing*/static void proxy_timer_update    (    void    )    {    SNMP_PROXY_CB_T * pPcb;        if (root_proxy_block.timer.handler == 0)        root_proxy_block.timer.handler = proxy_timer_exp;    for (pPcb = root_proxy_block.pcb; pPcb != 0; pPcb = pPcb->next)        {        if (((pPcb->flags & (SNMP_PROXY_FLAGS_EXPIRED |                             SNMP_PROXY_FLAGS_RESPONDED)) != 0) ||            (pPcb->expires != 0))            break;        }    if (pPcb != 0)        {        envoy_tm_set (&root_proxy_block.timer,                      min(PROXY_SWEEP_TIME,                          (root_proxy_block.timer.expire - ENVOY_NOW())));        }    else        envoy_tm_cancel (&root_proxy_block.timer);    }/***************************************************************************** NAME: proxy_timer_exp** Handler for when the proxy timer expires.  Walk through* the proxy block list and expire any packets that have* timed out.* * RETURNS: nothing*/static void proxy_timer_exp    (    ENVOY_TIMER_T * timer,    void          * cookie    )    {    SNMP_PROXY_CB_T ** ppPcb;    SNMP_PROXY_CB_T ** ppNextPcb;    SNMP_PROXY_CB_T *  pDeadPcb;    #if INSTALL_ENVOY_SNMP_LOCK    ENVOY_SNMP_GET_WRITE_LOCK(SNMP_V3_Retrans_Lock);#endif    for (ppPcb = &root_proxy_block.pcb; *ppPcb != 0; ppPcb = ppNextPcb)        {        ppNextPcb = &(*ppPcb)->next;        /*         * We're checking for two things:         * 1. Blocks marked with an EXPIRED or ACKED flag         * 2. New blocks that have completely expired         */        if ((((*ppPcb)->flags &             (SNMP_PROXY_FLAGS_EXPIRED |              SNMP_PROXY_FLAGS_RESPONDED)) != 0) ||            (((*ppPcb)->expires != 0) &&             ((*ppPcb)->expires <= ENVOY_NOW())))            {            pDeadPcb = *ppPcb;            *ppPcb = (*ppPcb)->next;            ppNextPcb = ppPcb;            proxyBlockClean (pDeadPcb);            }        }        /* kick the timer */    proxy_timer_update();#if INSTALL_ENVOY_SNMP_LOCK    ENVOY_SNMP_RELEASE_WRITE_LOCK(SNMP_V3_Retrans_Lock);#endif    }/***************************************************************************** snmpProxyV3Request - determine whether a given PDU should be forwarded*                      according to proxy rules** This function will scan the proxy object list to determine whether* the passed-in Request-PDU should be forwarded according to the rules* of RFC 2573.** RETURNS:  ENVOY_ERR_NOERR if a proper target was found*           ENVOY_ERR_NO_TARGET if no valid target was found*           ENVOY_ERR_INSUFFICIENT_MEMORY if an allocation error occurred*           ENVOY_ERR_LOCK_FAILED if a locking error occurred**/envoy_err_t snmpProxyV3Request    (    SNMP_PKT_T  * pPkt    )    {    SNMP_PKT_T           * pNewPkt;    SNMP_PROXY_T         * pProxy;    SNMP_TARGET_ADDR_T   * pTaddr;    SNMP_TARGET_PARAMS_T * pParams;    TARGET_LIST_T        * pTargList;    SNMP_PROXY_CB_T      * pProxyBlock;    EBUFFER_T              contextEngineID;    EBUFFER_T              contextName;    bits8_t                msgFlags;    bits32_t               mpModel;    sbits32_t              secModel;    bits32_t               secLevel;    EBUFFER_T              secName;    bits8_t              * secID;    ALENGTH_T              secIDLen;    SNMPADDR_T             locAddr;#if INSTALL_ENVOY_SNMP_COEXISTENCE    SNMP_COMMUNITY_T     * pCommunity;    EBUFFER_T              communityString;    VB_T                 * pVb;    int                    vbCount;#endif        EBufferInitialize (&contextEngineID);    EBufferInitialize (&contextName);    EBufferInitialize (&secName);#if INSTALL_ENVOY_SNMP_COEXISTENCE    EBufferInitialize (&communityString);#endif        /*     * We load information into local variables for the sake of     * coexistence     */    switch (pPkt->snmp_version)        {#if INSTALL_ENVOY_SNMP_COEXISTENCE        case SNMP_VERSION_1:        case SNMP_VERSION_2:            pCommunity =                SNMP_Community_Lookup (EBufferStart (&pPkt->comm_entry),                                       EBufferUsed (&pPkt->comm_entry));            if (pCommunity == 0)                return (ENVOY_ERR_NO_TARGET);            EBufferAllocateLoad (BFL_IS_ALLOC, &contextEngineID,                                 SNMP_Community_Get_Con_ID (pCommunity),                                 SNMP_Community_Get_Con_ID_Len (pCommunity));            EBufferAllocateLoad (BFL_IS_ALLOC, &contextName,                                 SNMP_Community_Get_Con_Name (pCommunity),                                 SNMP_Community_Get_Con_Name_Len (pCommunity));            mpModel = pPkt->snmp_version;            secModel = ((pPkt->snmp_version == SNMP_VERSION_1) ?                        ETC_SEC_MODEL_V1 : ETC_SEC_MODEL_V2);            EBufferAllocateLoad (BFL_IS_ALLOC, &secName,                                 SNMP_Community_Get_Sec_Name (pCommunity),                                 SNMP_Community_Get_Sec_Name_Len (pCommunity));            secLevel = ETC_SEC_LEVEL_NONE;            EBufferAllocateLoad (BFL_IS_STATIC, &communityString,                                 EBufferStart (&pPkt->community),                                 EBufferUsed (&pPkt->community));            break;#endif        case SNMP_VERSION_3:            EBufferAllocateLoad (BFL_IS_STATIC, &contextEngineID,                                 EBufferStart (&pPkt->msg_con_id),                                 EBufferUsed (&pPkt->msg_con_id));            EBufferAllocateLoad (BFL_IS_STATIC, &contextName,                                 EBufferStart (&pPkt->community),

⌨️ 快捷键说明

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