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

📄 v3mt_pxy.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 3 页
字号:
    )    {    SNMP_PROXY_T * pProxy;    pProxy = (SNMP_PROXY_T *) (((VB_T *)proxyPtr)->vb_priv);    SNMP_V3_PROXY_UPDATE_BACKOUT (pProxy->next, pProxy);    SNMP_Proxy_Destroy (pProxy);    }/***************************************************************************** proxyTableDestroyUndo - undo a destroy set* * This routine attempts to undo a previous destroy set.  It expects the old* information to be pointed to by vb_priv and tries to reinstall it.  If we* can't reinstall the proxy we leave the cleanup routine alone in order to get* the FINISHED macro to run.** RETURNS: N/A*/static void proxyTableDestroyUndo    (    OIDC_T	  last_match,    int		  tcount,    OIDC_T	* tlist,    SNMP_PKT_T 	* pktp,    VB_T	* vbp    )    {    SNMP_PROXY_T * pProxy;    bits8_t name [ETC_PROXY_NAME_MAX];    ALENGTH_T nameLen = ETC_PROXY_NAME_MAX;    /* assume things will go well and mark the vbp as done */    undoproc_good (pktp, vbp);    /* get the name info, no need to check as it's already been validated */    oid_to_string (tcount, tlist, &nameLen, name, 1);    /* find the state block we saved and then reset the vb_priv info */    /* so we don't have any accidents later */    pProxy      = (SNMP_PROXY_T *) vbp->vb_priv;    vbp->vb_priv = 0;    if (SNMP_Proxy_Install (pProxy, name, nameLen) == 0)        {#if defined(SNMP_V3_PROXY_DESTROY_UNDO)        if (SNMP_V3_PROXY_DESTROY_UNDO (pktp, vbp, 0, pProxy) == 0)            {            vbp->vb_free_priv = 0;            return;            }        else            SNMP_Proxy_Deinstall (pProxy);#else        vbp->vb_free_priv = 0;        return;#endif        }    SNMP_Proxy_Destroy (pProxy);    undoproc_error (pktp, vbp, UNDO_FAILED);    return;    }/***************************************************************************** proxyTableCreateUndo - undo a create set* * This routine attempts to undo a previous create set.  It expects the new* information to be pointed to by vb_priv and tries to deinstall and destroy* the entry.** RETURNS:  N/A*/static void proxyTableCreateUndo    (    OIDC_T 	  last_match,    int		  tcount,    OIDC_T	* tlist,    SNMP_PKT_T 	* pktp,    VB_T	* vbp    )    {    SNMP_PROXY_T * pProxy;    /* assume things will go well */    undoproc_good (pktp, vbp);    /* find the state block we saved and then reset the vb_priv info       so we don't have any accidents later */    pProxy = (SNMP_PROXY_T *)vbp->vb_priv;    vbp->vb_priv	  = 0;    vbp->vb_free_priv = 0;#if defined(SNMP_V3_PROXY_CREATE_UNDO)    if (SNMP_V3_PROXY_CREATE_UNDO (pktp, vbp, pProxy, 0))        {        undoproc_error (pktp, vbp, UNDO_FAILED);        return;        }#endif    SNMP_Proxy_Deinstall (pProxy);    SNMP_Proxy_Destroy (pProxy);    return;    }/***************************************************************************** proxyTableUpdateUndo - undo an update set** This routine attempts to undo a previous update set.  It expects the struct* pointed to by vb_priv to contain the old information and a pointer to the* new (installed) struct.** RETURNS:  N/A*/static void proxyTableUpdateUndo    (    OIDC_T	  last_match,    int		  tcount,    OIDC_T	* tlist,    SNMP_PKT_T 	* pktp,    VB_T       	* vbp    )    {    SNMP_PROXY_T * pCurProxy;    SNMP_PROXY_T * pSavProxy;    /* assume things will go well */    undoproc_good (pktp, vbp);    /* find the state block we saved and then reset the vb_priv info       so we don't have any accidents later */    pSavProxy = (SNMP_PROXY_T *)vbp->vb_priv;    vbp->vb_priv	  = 0;    vbp->vb_free_priv = 0;    pCurProxy = pSavProxy->next;#if defined(SNMP_V3_PROXY_UPDATE_UNDO)    if (SNMP_V3_PROXY_UPDATE_UNDO (pktp, vbp, pCurProxy, pSavProxy))        {        undoproc_error (pktp, vbp, UNDO_FAILED);        SNMP_Proxy_Destroy (pSavProxy);        return;        }#endif    /* swap the info from saved proxy back into current proxy, we only     * need to move strings if the names are different.  finally, free     * the saved block     */    SNMP_Proxy_Set_Proxy_Type (pCurProxy,                                SNMP_Proxy_Get_Proxy_Type (pSavProxy));    if (SNMP_Proxy_Get_Context_Engine_ID (pCurProxy) !=        SNMP_Proxy_Get_Context_Engine_ID (pSavProxy))        {        EBufferClean (&pCurProxy->context_engine_id);        MEMCPY (&pCurProxy->context_engine_id,                 &pSavProxy->context_engine_id,                 sizeof (EBUFFER_T));        EBufferInitialize (&pSavProxy->context_engine_id);        }    if (SNMP_Proxy_Get_Context_Name (pCurProxy) !=        SNMP_Proxy_Get_Context_Name (pSavProxy))        {        EBufferClean (&pCurProxy->context_name);        MEMCPY (&pCurProxy->context_name,                 &pSavProxy->context_name,                 sizeof (EBUFFER_T));        EBufferInitialize (&pSavProxy->context_name);        }    if (SNMP_Proxy_Get_Target_Params_In (pCurProxy) !=        SNMP_Proxy_Get_Target_Params_In (pSavProxy))        {        EBufferClean (&pCurProxy->target_params_in);        MEMCPY (&pCurProxy->target_params_in,                 &pSavProxy->target_params_in,                 sizeof (EBUFFER_T));        EBufferInitialize (&pSavProxy->target_params_in);        }    if (SNMP_Proxy_Get_Single_Target_Out (pCurProxy) !=        SNMP_Proxy_Get_Single_Target_Out (pSavProxy))        {        EBufferClean (&pCurProxy->single_target_out);        MEMCPY (&pCurProxy->single_target_out,                 &pSavProxy->single_target_out,                 sizeof (EBUFFER_T));        EBufferInitialize (&pSavProxy->single_target_out);        }    if (SNMP_Proxy_Get_Multiple_Target_Out (pCurProxy) !=        SNMP_Proxy_Get_Multiple_Target_Out (pSavProxy))        {        EBufferClean (&pCurProxy->multiple_target_out);        MEMCPY (&pCurProxy->multiple_target_out,                 &pSavProxy->multiple_target_out,                 sizeof (EBUFFER_T));        EBufferInitialize (&pSavProxy->multiple_target_out);        }    SNMP_Proxy_Set_Status (pCurProxy, SNMP_Proxy_Get_Status (pSavProxy));    SNMP_Proxy_Set_Storage (pCurProxy, SNMP_Proxy_Get_Storage (pSavProxy));    SNMP_Proxy_Destroy (pSavProxy);    return;    }/***************************************************************************** proxytable_set_finished - cleanup after a successful set** Free the saved proxy and indicate that we are finished.** RETURNS: N/A*/static void proxyTableSetFinished    (    ptr_t proxyPtr    )    {    if (((VB_T *)proxyPtr)->vb_priv)        {        if (((VB_T *)proxyPtr)->undoproc == proxyTableCreateUndo)            ((VB_T *)proxyPtr)->vb_priv = 0;        else            SNMP_Proxy_Destroy (((VB_T *)proxyPtr)->vb_priv);        }    SNMP_V3_PROXY_FINISHED();    }/**************************************************************************** snmpProxyEntry_test - the testproc for the snmpProxyTable** This function handles the test portion of set requests.  It is never* called directly, only by the Envoy engine.** Returns: N/A*/void  snmpProxyEntry_test    (    OIDC_T       lastmatch,    int          tcount,    OIDC_T     * tlist,    SNMP_PKT_T * pktp,    VB_T       * vbp)    {    SNMP_PROXY_T   tempProxy;    SNMP_PROXY_T * pProxy;    SNMP_PROXY_T * pNewProxy;    sbits32_t value;    ETC_STORAGE_T stoValue;    ETC_STATUS_T statValue;    sbits32_t ptRet;    int cago = 0;    int createRow = 0;    int ciChg = 0;    int cnChg = 0;    int tpiChg = 0;    int stoChg = 0;    int mtoChg = 0;    ALENGTH_T nLen = 0;    VB_T * pTVb = 0;    VB_T * pPtVb = 0;    VB_T * pCiVb = 0;    VB_T * pCnVb = 0;    VB_T * pTpiVb = 0;    VB_T * pStoVb = 0;    VB_T * pMtoVb = 0;    VB_T * pRsVb = 0;    bits8_t name [ETC_PROXY_NAME_MAX];    ALENGTH_T nameLen = ETC_PROXY_NAME_MAX;    /* get the list of var binds that may go into this structure then     *  mark all the vbs except the first one as having been tested,     *  set and done.  This means that vbp is taking responsibility     *  for all of the other vbs in the row.  Then mark vbp as having     *  it's test started & done so we don't have to worry about it     *  later.  We can do this because the routine will run to     *  completion     */    group_by_getproc_and_instance (pktp, vbp, tcount, tlist);    for (pTVb = vbp->vb_link; pTVb; pTVb = pTVb->vb_link)        setproc_all_bits (pktp, pTVb);    testproc_good (pktp, vbp);    /* gather the indexing information, the index will be of the form:     * <name>     *  first we do some minor checks then we attempt to find the proxy     */    if ((tcount > ETC_PROXY_NAME_MAX)                     ||        oid_to_string (tcount, tlist, &nameLen, name, 1)   ||        (nameLen == 0) || ((bits32_t)nameLen != (bits32_t) tcount))        {        testproc_error (pktp, vbp, NO_CREATION);        return;        }    pProxy = SNMP_Proxy_Lookup (name, nameLen);    /* is the leaf writable, (if it's read only it isn't writable) */    if (pProxy != 0)        {        if (SNMP_Proxy_Get_Storage (pProxy) == ETC_STO_RONLY)            {            testproc_error (pktp, vbp, NOT_WRITABLE);                  return;            }        MEMCPY (&tempProxy, pProxy, sizeof (SNMP_PROXY_T));        }    else        {        SNMP_Proxy_Set_Defaults (&tempProxy);        createRow = 1;        }        for (pTVb = vbp; pTVb; pTVb = pTVb->vb_link)        {        switch(pTVb->vb_ml.ml_last_match)            {            case LEAF_snmpProxyType:                value = pTVb->value_u.v_number;                if ((value < PROXY_TYPE_READ) || (value > PROXY_TYPE_INFORM))                    {                    testproc_error (pktp, pTVb, WRONG_VALUE);                    return;                    }                SNMP_Proxy_Set_Proxy_Type (&tempProxy, (bits32_t)value);                pPtVb = pTVb;                break;            case LEAF_snmpProxyContextEngineID:                nLen = EBufferUsed (&pTVb->value_u.v_string);                if ((nLen < MINSIZE_snmpProxyContextEngineID) ||                    (nLen > MAXSIZE_snmpProxyContextEngineID))                    {                    testproc_error (pktp, pTVb, WRONG_LENGTH);                    return;                    }                if ((nLen == v3_my_engine->id_len) &&                    (MEMCMP(v3_my_engine->id,                            EBufferStart(&pTVb->value_u.v_string),                            nLen) == 0))                    {                    testproc_error (pktp, pTVb, INCONSISTENT_VALUE);                    return;                    }                EBufferPreLoad (BFL_IS_STATIC, &tempProxy.context_engine_id,                                EBufferStart(&pTVb->value_u.v_string), nLen);                pCiVb = pTVb;                break;            case LEAF_snmpProxyContextName:                nLen = EBufferUsed (&pTVb->value_u.v_string);                if (nLen > MAXSIZE_snmpProxyContextName)                    {                    testproc_error(pktp, pTVb, WRONG_LENGTH);                    return;                    }                EBufferPreLoad (BFL_IS_STATIC, &tempProxy.context_name,                                EBufferStart (&pTVb->value_u.v_string), nLen);                pCnVb = pTVb;                break;            case LEAF_snmpProxyTargetParamsIn:                nLen = EBufferUsed (&pTVb->value_u.v_string);                if (nLen > MAXSIZE_snmpProxyTargetParamsIn)                    {                    testproc_error (pktp, pTVb, WRONG_LENGTH);                    return;                    }                EBufferPreLoad (BFL_IS_STATIC, &tempProxy.target_params_in,                                EBufferStart (&pTVb->value_u.v_string), nLen);                pTpiVb = pTVb;                break;            case LEAF_snmpProxySingleTargetOut:                nLen = EBufferUsed (&pTVb->value_u.v_string);                if (nLen > MAXSIZE_snmpProxySingleTargetOut)                    {                    testproc_error (pktp, pTVb, WRONG_LENGTH);                    return;                    }                EBufferPreLoad (BFL_IS_STATIC, &tempProxy.single_target_out,                                EBufferStart(&pTVb->value_u.v_string), nLen);                pStoVb = pTVb;                break;            case LEAF_snmpProxyMultipleTargetOut:                nLen = EBufferUsed (&pTVb->value_u.v_string);                if (nLen > MAXSIZE_snmpProxyMultipleTargetOut)                    {                    testproc_error (pktp, pTVb, WRONG_LENGTH);                    return;                    }                EBufferPreLoad (BFL_IS_STATIC, &tempProxy.multiple_target_out,                                EBufferStart (&pTVb->value_u.v_string), nLen);                pMtoVb = pTVb;                break;            case LEAF_snmpProxyStorageType:                stoValue = pTVb->value_u.v_number;                if ((stoValue < ETC_STO_OTHER) ||                    (stoValue > ETC_STO_RONLY) ||                    ((pProxy != 0) && (stoValue > ETC_STO_NONVOL)) ||                    (SNMP_Proxy_Get_Storage (&tempProxy) >= ETC_STO_PERM))                    {                    testproc_error (pktp, pTVb, WRONG_VALUE);                    return;                    }                SNMP_Proxy_Set_Storage (&tempProxy, stoValue);                break;            case LEAF_snmpProxyRowStatus:                statValue = pTVb->value_u.v_number;                switch (statValue)                    {                    case ETC_RS_ACTIVE:                    case ETC_RS_NIS:                        if (createRow != 0)                            {                            testproc_error (pktp, pTVb, INCONSISTENT_VALUE);                            return;                            }                        break;                    case ETC_RS_CAGO:                        if (createRow == 0)                            {                            testproc_error (pktp, pTVb, INCONSISTENT_VALUE);                            return;                            }                        statValue = ETC_RS_ACTIVE;

⌨️ 快捷键说明

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