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

📄 snmpnat.c

📁 vxworks下ppp的实现源码
💻 C
📖 第 1 页 / 共 4 页
字号:
/* snmpnat.c  - SNMP NAT group method routines *//* Copyright 2000-2003 Wind River Systems, Inc */#include "copyright_wrs.h"/*modification history-------------------01e,04sep03,svk  Fix strlen warnings with diab01d,14jul03,vks  bug fix in natEntrySet01c,24apr03,zhu  updated copyright01b,06dec02,zhu  Fixed compiler warnings problems01a,27sep02,vvv  copied from the epilogue directory; updated for Envoy 9.3*//* includes */#include "wrn/wm/snmp/vxagent/snmpdLib.h"#include "wrn/wm/snmp/vxagent/mibhand.h"#include "wrn/wm/snmp/engine/auxfuncs.h"#include "wrn/nat/natMgmt.h"#include "wrn/nat/natSnmpLeaf.h"#define NAT_TRUE   1L#define NAT_FALSE  2L#define IP_ADDR_LEN                         4#define NAT_BINDTBL_INSTANCE_LEN            10#define NAT_SESSTBL_INSTANCE_LEN            10#define NAT_BINDTBL_REMOTE_ADDRESS_OFFSET   5#define NAT_BINDTBL_REMOTE_PORT_OFFSET      9#define NAT_SESSTBL_REMOTE_ADDRESS_OFFSET   5#define NAT_SESSTBL_REMOTE_PORT_OFFSET      9#define NAT_BIND_RW_OBJS                    2/* Externs */IMPORT MIBLEAF_T l_natBindAction;IMPORT MIBLEAF_T l_natBindProto;LOCAL void natEntryUndo (OIDC_T, int, OIDC_T *, SNMP_PKT_T *, VB_T *); /****************************************************************************** *  natEntryGetValue -  Routine to extract info from NAT_TBL_ENTRY 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_TBL_ENTRY structure containing the info required *                for this instance. * *  RETURNS: N/A */static int natEntryGetValue    (    OIDC_T      lastmatch,    SNMP_PKT_T *pktp,    VB_T       *vbp,    NAT_TBL_ENTRY *pData    )    {    switch(lastmatch) {        case LEAF_natIndex:            getproc_got_int32(pktp, vbp, pData->natIndex);                break;        case LEAF_natTypeMask:            getproc_got_int32(pktp, vbp, pData->natTypeMask);                break;        case LEAF_natType:            getproc_got_int32(pktp, vbp, pData->natType);                break;        case LEAF_natTotalBinds:            getproc_got_int32(pktp, vbp, pData->natTotalBinds);               break;        case LEAF_natMaxStaticBinds:            getproc_got_int32(pktp, vbp, pData->natMaxStaticBinds);               break;        case LEAF_natCurrStaticBinds:            getproc_got_int32(pktp, vbp, pData->natCurrStaticBinds);               break;        case LEAF_natCurrDynamicBinds:            getproc_got_int32(pktp, vbp, pData->natCurrDynamicBinds);               break;        case LEAF_natMaxStaticIpBinds:            getproc_got_int32(pktp, vbp, pData->natMaxStaticIpBinds);               break;        case LEAF_natCurrStaticIpBinds:            getproc_got_int32(pktp, vbp, pData->natCurrStaticIpBinds);               break;        case LEAF_natCurrDynamicIpBinds:            getproc_got_int32(pktp, vbp, pData->natCurrDynamicIpBinds);               break;        case LEAF_natMaxStaticTcpBinds:            getproc_got_int32(pktp, vbp, pData->natMaxStaticTcpBinds);               break;        case LEAF_natCurrStaticTcpBinds:            getproc_got_int32(pktp, vbp, pData->natCurrStaticTcpBinds);               break;        case LEAF_natCurrDynamicTcpBinds:            getproc_got_int32(pktp, vbp, pData->natCurrDynamicTcpBinds);              break;        case LEAF_natMaxStaticUdpBinds:            getproc_got_int32(pktp, vbp, pData->natMaxStaticUdpBinds);               break;        case LEAF_natCurrStaticUdpBinds:            getproc_got_int32(pktp, vbp, pData->natCurrStaticUdpBinds);               break;        case LEAF_natCurrDynamicUdpBinds:            getproc_got_int32(pktp, vbp, pData->natCurrDynamicUdpBinds);              break;        case LEAF_natSessionMaxIdleTime:            getproc_got_int32(pktp, vbp, pData->natSessionMaxIdleTime);              break;        case LEAF_natUdpSessionMaxIdleTime:            getproc_got_int32(pktp, vbp, pData->natUdpSessionMaxIdleTime);               break;        case LEAF_natIcmpSessionMaxIdleTime:            getproc_got_int32(pktp, vbp, pData->natIcmpSessionMaxIdleTime);               break;        case LEAF_natTcpUpSessionMaxIdleTime:            getproc_got_int32(pktp, vbp, pData->natTcpUpSessionMaxIdleTime);              break;        case LEAF_natTcpDiscSessionMaxIdleTime:            getproc_got_int32(pktp, vbp, pData->natTcpDiscSessionMaxIdleTime);                break;        case LEAF_natTcpClosingSessionMaxIdleTime:            getproc_got_int32(pktp, vbp, pData->natTcpClosingSessionMaxIdleTime);               break;        case LEAF_natTcpSyncSessionMaxIdleTime:            getproc_got_int32(pktp, vbp, pData->natTcpSyncSessionMaxIdleTime);            break;        case LEAF_natLogMask:            getproc_got_int32(pktp, vbp, pData->natLogMask);              break;        case LEAF_natEnable:            /* Values:             *  true(1)  = VAL_natEnable_true             *  false(2) = VAL_natEnable_false             */            getproc_got_int32(pktp, vbp, pData->natEnable);               break;        case LEAF_natDefXEnable:            /* Values:             *  true(1)  = VAL_natDefXEnable_true             *  false(2) = VAL_natDefXEnable_false             */            getproc_got_int32(pktp, vbp, pData->natDefXEnable);               break;        case LEAF_natGlobalAddrFilter:            /* Values:             *  true(1)  = VAL_natGlobalAddrFilter_true             *  false(2) = VAL_natGlobalAddrFilter_false             */            getproc_got_int32(pktp, vbp, pData->natGlobalAddrFilter);              break;        case LEAF_natStaticBindEnable:            /* Values:             *  true(1)  = VAL_natStaticBindEnable_true             *  false(2) = VAL_natStaticBindEnable_false             */            getproc_got_int32(pktp, vbp, pData->natStaticBindEnable);               break;        default:            return GEN_ERR;    }    return NO_ERROR;    }/*******************************************************************************  natEntryGet -   Get 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 natEntryGet    (    OIDC_T      lastmatch,    int         tcount,    OIDC_T     *tlist,    SNMP_PKT_T *pktp,    VB_T       *vbp    )    {    NAT_TBL_ENTRY data;                                int           error;    /* Check if we have the instance part */    if (tcount != NAT_TBL_INDEX_LEN)	{	for ( ; vbp ; vbp = vbp->vb_link)	    {	    getproc_nosuchins (pktp, vbp);	    }        return;	}    /* find all the varbinds that share the same getproc and instance */    group_by_getproc_and_instance(pktp, vbp, tcount, tlist);    /* use the instance (tcount and tlist) to look up the entry in the     * table.     */    bzero ((char *)&data, sizeof (data));    data.natIndex = *tlist;    if (m2NatTblEntryGet (&data, GET_VALUE) != OK) 	{        for ( ; vbp; vbp = vbp->vb_link)	    {            getproc_nosuchins(pktp, vbp);	    }        return;        }    else 	{        /* retrieve all the values from the same data structure */        for ( ; vbp; vbp = vbp->vb_link) 	    {            if ((error = natEntryGetValue (vbp->vb_ml.ml_last_match, pktp, vbp, &data)) != NO_ERROR)                getproc_error(pktp, vbp, error);            }        }    }/*******************************************************************************  natEntryNext -**  Next method routine for  nat 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 natEntryNext    (    OIDC_T      lastmatch,    int         tcount,    OIDC_T     *tlist,    SNMP_PKT_T *pktp,    VB_T       *vbp    )    {    OIDC_T     natIndex[NAT_TBL_INDEX_LEN];    NAT_TBL_ENTRY data;                        /* find all the varbinds that share the same getproc and instance */    group_by_getproc_and_instance(pktp, vbp, tcount, tlist);    /* Zero out the structure before doing anything else */    bzero ((char *)&data, sizeof (data));    *natIndex = (tlist != NULL) ? *tlist : 0;    data.natIndex = *natIndex + 1;    if ( m2NatTblEntryGet (&data, NEXT_VALUE ) != OK)	{	for ( ; vbp != NULL; vbp = vbp->vb_link)	    {	    snmpNextError (pktp, vbp);            }	    return;	}    /* Create oid sequence for nat index retrieved */    *natIndex = data.natIndex;    for (    ; vbp; vbp = vbp->vb_link)        {           /* install instance part of next instance found */        nextproc_next_instance (pktp, vbp, NAT_TBL_INDEX_LEN, natIndex);        natEntryGetValue (vbp->vb_ml.ml_last_match, pktp, vbp, &data);        }    }/*******************************************************************************  natEntryTest -  Test 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**  RETURN: N/A**/void natEntryTest    (    OIDC_T      lastmatch,    int         tcount,    OIDC_T     *tlist,    SNMP_PKT_T *pktp,    VB_T       *vbp    )    {    NAT_TBL_ENTRY *     pSetEntry = NULL;    int                 errorStatus;    if (tcount != 1)    {    errorStatus =  NO_SUCH_NAME;    goto errorReturn;    }    switch (lastmatch)        {        case LEAF_natSessionMaxIdleTime:	case LEAF_natUdpSessionMaxIdleTime:	case LEAF_natIcmpSessionMaxIdleTime:	case LEAF_natTcpUpSessionMaxIdleTime:	case LEAF_natTcpDiscSessionMaxIdleTime:	case LEAF_natTcpClosingSessionMaxIdleTime:	case LEAF_natTcpSyncSessionMaxIdleTime:	    if(vbp->value_u.v_number < 0)		{                errorStatus = WRONG_VALUE;                goto errorReturn;                }            break;        case LEAF_natLogMask:	    if (!((vbp->value_u.v_number >= MIN_natLogMask) &&	          (vbp->value_u.v_number <= MAX_natLogMask)))		{                errorStatus = WRONG_VALUE;                goto errorReturn;                }            break;        case LEAF_natEnable:        case LEAF_natDefXEnable:        case LEAF_natGlobalAddrFilter:        case LEAF_natStaticBindEnable:            switch (vbp->value_u.v_number) 	        {

⌨️ 快捷键说明

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