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

📄 snmpnat.c

📁 vxworks下ppp的实现源码
💻 C
📖 第 1 页 / 共 4 页
字号:
                case NAT_TRUE:                case NAT_FALSE:                    break;                default:                    errorStatus = WRONG_VALUE;                    goto errorReturn;                }            break;        default:	    errorStatus = GEN_ERR;            goto errorReturn;	}	    /* Allocate 2 longs to save index and values of entry being       changed in case we need to undo */    vbp->vb_priv = snmpdMemoryAlloc (sizeof (NAT_TBL_ENTRY));    pSetEntry = (NAT_TBL_ENTRY *)vbp->vb_priv;    if (vbp->vb_priv == NULL)        {        errorStatus = RESOURCE_UNAVAILABLE;        goto errorReturn;        }    /* index of entry to get */    pSetEntry->natIndex = *tlist;    if (m2NatTblEntryGet (pSetEntry, GET_VALUE) != OK)        {        errorStatus = NO_SUCH_NAME;        goto errorReturn;        }    /* callback to free vb_priv memory */    vbp->vb_free_priv = (VBPRIVPROC_T *) snmpVbPrivFree;    testproc_good (pktp, vbp);    return;errorReturn:     testproc_error (pktp, vbp, errorStatus);    }/*******************************************************************************  natEntrySet -  Set method routine for natTable.**  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.**  NOMANUAL**  RETURNS: N/A*/void natEntrySet    (    OIDC_T      lastmatch,    int         tcount,    OIDC_T     *tlist,    SNMP_PKT_T *pktp,    VB_T       *vbp    )    {    NAT_TBL_ENTRY data;         int varToSet=0;    VB_T * pVbpSaved = vbp;        /* find all the varbinds that share the same getproc and instance */    group_by_getproc_and_instance(pktp, vbp, tcount, tlist);    /* Copy the data from the varbind fields */    bzero ((char *)&data, sizeof (NAT_TBL_ENTRY));    data.natIndex = *tlist;    for ( ; vbp; vbp = vbp->vb_link) 	{        switch (vbp->vb_ml.ml_last_match) 	    {            case LEAF_natSessionMaxIdleTime:                data.natSessionMaxIdleTime = vbp->value_u.v_number;                            varToSet |= NAT_SESS_MAX_IDLETIME;                break;            case LEAF_natUdpSessionMaxIdleTime:                data.natUdpSessionMaxIdleTime = vbp->value_u.v_number;                      varToSet |= NAT_UDP_SESS_MAX_IDLETIME;                break;            case LEAF_natIcmpSessionMaxIdleTime:                data.natIcmpSessionMaxIdleTime = vbp->value_u.v_number;                       varToSet |= NAT_ICMP_SESS_MAX_IDLETIME;                break;            case LEAF_natTcpUpSessionMaxIdleTime:                data.natTcpUpSessionMaxIdleTime = vbp->value_u.v_number;                        varToSet |= NAT_TCPUP_SESS_MAX_IDLETIME;                break;            case LEAF_natTcpDiscSessionMaxIdleTime:                data.natTcpDiscSessionMaxIdleTime = vbp->value_u.v_number;                       varToSet |= NAT_TCPDISC_SESS_MAX_IDLETIME;                break;            case LEAF_natTcpClosingSessionMaxIdleTime:                data.natTcpClosingSessionMaxIdleTime = vbp->value_u.v_number;                        varToSet |= NAT_TCPCLOS_SESS_MAX_IDLETIME;                break;            case LEAF_natTcpSyncSessionMaxIdleTime:                data.natTcpSyncSessionMaxIdleTime = vbp->value_u.v_number;                  varToSet |= NAT_TCPSYNC_SESS_MAX_IDLETIME;                break;            case LEAF_natLogMask:                data.natLogMask = vbp->value_u.v_number;                  varToSet |= NAT_LOG_MASK;                break;            case LEAF_natEnable:                data.natEnable = vbp->value_u.v_number;                    varToSet |= NAT_ENABLE;                break;            case LEAF_natDefXEnable:                data.natDefXEnable = vbp->value_u.v_number;                       varToSet |= NAT_DEF_X_ENABLE;                break;            case LEAF_natGlobalAddrFilter:                data.natGlobalAddrFilter = vbp->value_u.v_number;                    varToSet |= NAT_GLOBAL_ADDR_FILTER;                break;            case LEAF_natStaticBindEnable:                data.natStaticBindEnable = vbp->value_u.v_number;                   varToSet |= NAT_STATIC_BIND_ENABLE;                break;            default:                setproc_error(pktp, vbp, COMMIT_FAILED);                return;            }        setproc_good (pktp, vbp);        }                pVbpSaved->undoproc = (UNDOPROC_T *) natEntryUndo;    /* Call the m2 routine to do the commit */    if( m2NatTblEntrySet (&data , varToSet) != OK )        {        /*         * Commit failed so we should remove the undo buffer, else when         * the undo is done we might end up with an undo failed error         * instead of commit failed.         */        snmpVbPrivFree (pVbpSaved);        setproc_error (pktp, pVbpSaved, COMMIT_FAILED);        return;        }    }/*******************************************************************************  natEntryUndo -**  Undo routine for natEntry table **  Parameters to this routine are* *  <lastmatch> - the last oid component that was matched to get to this leaf.*  <tlist>     - 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*/LOCAL void natEntryUndo    (    OIDC_T              lastmatch,    int                 tcount,    OIDC_T *            tlist,    SNMP_PKT_T *        pktp,    VB_T *              vbp    )    {    NAT_TBL_ENTRY *     pSetEntry = (NAT_TBL_ENTRY *)vbp->vb_priv;    int varToSet = 0;    if (pSetEntry == NULL)        {        goto goodReturn;        }    varToSet = (NAT_SESS_MAX_IDLETIME |                NAT_UDP_SESS_MAX_IDLETIME |                NAT_ICMP_SESS_MAX_IDLETIME |         	NAT_TCPUP_SESS_MAX_IDLETIME |                NAT_TCPDISC_SESS_MAX_IDLETIME |                 NAT_TCPCLOS_SESS_MAX_IDLETIME |                 NAT_TCPSYNC_SESS_MAX_IDLETIME | 	        NAT_LOG_MASK | NAT_ENABLE |                 NAT_STATIC_BIND_ENABLE | 	        NAT_DEF_X_ENABLE | 	        NAT_GLOBAL_ADDR_FILTER );    if (m2NatTblEntrySet (pSetEntry , varToSet) != OK )        {        undoproc_error (pktp, vbp, UNDO_FAILED);        return;        }goodReturn:    undoproc_good (pktp, vbp);    return;    } /****************************************************************************** *  natDescGetValue -  Routine to extract info from NAT_SCALARS 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. *  <pData> - ptr to NAT_SCALARS structure containing the info required *                for this instance. * *  RETURNS: N/A */    static int natDescGetValue    (    OIDC_T       lastmatch,    SNMP_PKT_T  *pktp,    VB_T        *vbp,    NAT_SCALARS *pData    )    {    int         length;    OCTET_T    *pBuf;    switch(lastmatch)         {        case LEAF_natNumber:            getproc_got_int32(pktp, vbp, pData->natNumber);            break;        case LEAF_natSessionNumber:            getproc_got_int32(pktp, vbp, pData->natSessionNumber);               break;        case LEAF_natSwVersion:            length = strlen ((char*) pData->natSwVersion);            pBuf = SNMP_memory_alloc (length);	    if (pBuf == NULL)	        {	        getproc_error (pktp, vbp, GEN_ERR);	        return (GEN_ERR);	        }	    MEMCPY (pBuf, pData->natSwVersion, length);	    getproc_got_string (pktp, vbp, length, pBuf, BFL_IS_DYNAMIC,	                        VT_STRING );            break;            	case LEAF_natPrRealmType:            length = strlen ((char*) pData->natPrRealmType);            pBuf = SNMP_memory_alloc (length);	    if (pBuf == NULL)	        {	        getproc_error (pktp, vbp, GEN_ERR);	        return (GEN_ERR);	        }	    MEMCPY (pBuf, pData->natPrRealmType, length);	    getproc_got_string (pktp, vbp, length, pBuf, BFL_IS_DYNAMIC,	                        VT_STRING );            break;        case LEAF_natExtRealmType:            length = strlen ((char*) pData->natExtRealmType);            pBuf = SNMP_memory_alloc (length);	    if (pBuf == NULL)	        {	        getproc_error (pktp, vbp, GEN_ERR);	        return (GEN_ERR);	        }	    MEMCPY (pBuf, pData->natExtRealmType, length);	    getproc_got_string (pktp, vbp, length, pBuf, BFL_IS_DYNAMIC,	                        VT_STRING );            break;        default:            return GEN_ERR;    }    return NO_ERROR;    }/*******************************************************************************  natDescGet -   Get method routine for  natDescriptor.* *  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 natDescGet    (    OIDC_T      lastmatch,    int         tcount,    OIDC_T     *tlist,    SNMP_PKT_T *pktp,    VB_T       *vbp    )    {    NAT_SCALARS data;                                 int         error;    /* find all the varbinds that share the same getproc and instance */    group_by_getproc_and_instance (pktp, vbp, tcount, tlist);    /* check that the instance is exactly .0 */    if (!((tcount == 1) && (*tlist == 0)))        {        for ( ; vbp; vbp = vbp->vb_link)            {            getproc_nosuchins(pktp, vbp);	    }        return;        }    else        {        /* Zero out the structure */        bzero ((char *)&data, sizeof (data));        /* extract the values for all the objects in NAT_SCALARS */        if (m2NatScalarsGet (&data) != 0)     	    {            for ( ; vbp; vbp = vbp->vb_link)	        {                getproc_error(pktp, vbp, GEN_ERR);	        }            return;            }

⌨️ 快捷键说明

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