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

📄 snmpnat.c

📁 vxworks下ppp的实现源码
💻 C
📖 第 1 页 / 共 4 页
字号:
        else            {            /* retrieve all the values from the same data structure */            for ( ; vbp; vbp = vbp->vb_link)	        {                if ((error = natDescGetValue (vbp->vb_ml.ml_last_match, pktp, vbp, &data)) != NO_ERROR)	            {                    getproc_error(pktp, vbp, error);	            }                }            }        }    } /****************************************************************************** *  natBindEntryGetValue -  Routine to extract info from natBind Table * *  <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_BINDTBL_ENTRY structure containing the info  *                required for this instance. * *  RETURNS: N/A */static int natBindEntryGetValue    (    OIDC_T            lastmatch,    SNMP_PKT_T        *pktp,    VB_T              *vbp,    NAT_BINDTBL_ENTRY *pData    )    {    int         length;    OCTET_T    *pBuf;    switch(lastmatch)        {        case LEAF_natBindStatic:            /* Values:             *  true(1)  = VAL_natBindStatic_true             *  false(2) = VAL_natBindStatic_false             */            getproc_got_int32(pktp, vbp, pData->natBindStatic);               break;        case LEAF_natBindType:            /* Values:             *  address(1)   = VAL_natBindType_address             *  transport(2) = VAL_natBindType_transport             */            getproc_got_int32(pktp, vbp, pData->natBindType);               break;        case LEAF_natBindLocalAddress:            getproc_got_ip_address(pktp, vbp, pData->natBindLocalAddress);                break;        case LEAF_natBindLocalPort:            getproc_got_int32(pktp, vbp, pData->natBindLocalPort);               break;        case LEAF_natBindRemAddress:            getproc_got_ip_address(pktp, vbp, pData->natBindRemAddress);                break;        case LEAF_natBindRemPort:            getproc_got_int32(pktp, vbp, pData->natBindRemPort);                break;        case LEAF_natBindMaxLeaseTime:            getproc_got_int32(pktp, vbp, pData->natBindMaxLeaseTime);                break;        case LEAF_natBindLeaseLeft:            getproc_got_int32(pktp, vbp, pData->natBindLeaseLeft);                break;        case LEAF_natBindMaxIdle:            getproc_got_int32(pktp, vbp, pData->natBindMaxIdle);                break;        case LEAF_natBindCurrIdle:            getproc_got_int32(pktp, vbp, pData->natBindCurrIdle);               break;        case LEAF_natBindDirection:            /* Values:             *  unidirectional(1) = VAL_natBindDirection_unidirectional             *  bidirectional(2)  = VAL_natBindDirection_bidirectional             */            getproc_got_int32(pktp, vbp, pData->natBindDirection);                break;        case LEAF_natBindLocalIfNumber:            getproc_got_int32(pktp, vbp, pData->natBindLocalIfNumber);                break;        case LEAF_natBindExtIfNumber:            getproc_got_int32(pktp, vbp, pData->natBindExtIfNumber);                break;        case LEAF_natBindLocalIfName:            length = strlen ((char*) pData->natBindLocalIfName);            pBuf = SNMP_memory_alloc (length);	    if (pBuf == NULL)	        {	        getproc_error (pktp, vbp, GEN_ERR);	        return (GEN_ERR);	        }	    MEMCPY (pBuf, pData->natBindLocalIfName, length);	    getproc_got_string (pktp, vbp, length, pBuf, BFL_IS_DYNAMIC,	                        VT_STRING );            break;        case LEAF_natBindExtIfName:            length = strlen ((char*) pData->natBindExtIfName);            pBuf = SNMP_memory_alloc (length);	    if (pBuf == NULL)	        {	        getproc_error (pktp, vbp, GEN_ERR);	        return (GEN_ERR);	        }	    MEMCPY (pBuf, pData->natBindExtIfName, length);	    getproc_got_string (pktp, vbp, length, pBuf, BFL_IS_DYNAMIC,	                        VT_STRING );            break;        case LEAF_natBindProto:            /* Values:             *  tcp(1)  = VAL_natBindProto_tcp             *  udp(2)  = VAL_natBindProto_udp             *  icmp(3) = VAL_natBindProto_icmp             */            getproc_got_int32(pktp, vbp, pData->natBindProto);                break;        case LEAF_natBindAction:            /* Values:             *  active(1)        = VAL_natBindAction_active             *  notInService(2)  = VAL_natBindAction_notInService             *  notReady(3)      = VAL_natBindAction_notReady             *  createAndGo(4)   = VAL_natBindAction_createAndGo             *  createAndWait(5) = VAL_natBindAction_createAndWait             *  destroy(6)       = VAL_natBindAction_destroy             */            getproc_got_int32(pktp, vbp, pData->natBindAction);                break;        case LEAF_natBindContrAgent:            getproc_got_int32(pktp, vbp, pData->natBindContrAgent);                break;        default:            return GEN_ERR;        }    return NO_ERROR;    }/*******************************************************************************  natBindEntryGet -   Get method routine for  natBindTable.* *  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 natBindEntryGet    (    OIDC_T      lastmatch,    int         tcount,    OIDC_T     *tlist,    SNMP_PKT_T *pktp,    VB_T       *vbp    )    {    NAT_BINDTBL_ENTRY data;                                int               error;    if (tcount != NAT_BINDTBL_INSTANCE_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.natBindLocalPort = *(tlist + IP_ADDR_LEN);    data.natBindRemPort = *(tlist + NAT_BINDTBL_REMOTE_PORT_OFFSET);        if ( snmpOidToIpHostOrder (IP_ADDR_LEN, tlist , &data.natBindLocalAddress) ||        snmpOidToIpHostOrder (IP_ADDR_LEN, tlist +                               NAT_BINDTBL_REMOTE_ADDRESS_OFFSET,                                &data.natBindRemAddress) ||         (m2NatBindTblEntryGet (&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 = natBindEntryGetValue (vbp->vb_ml.ml_last_match, pktp,                                                vbp, &data)) != NO_ERROR)                getproc_error(pktp, vbp, error);            }        }    }                    /*******************************************************************************  natBindEntryNext -**  Next method routine for  nat bind 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 natBindEntryNext    (    OIDC_T      lastmatch,    int         tcount,    OIDC_T     *tlist,    SNMP_PKT_T *pktp,    VB_T       *vbp    )    {    OIDC_T            natBindIndex[NAT_BINDTBL_INDEX_LEN];    NAT_BINDTBL_ENTRY data;                         /* find all the varbinds that share the same getproc and instance */    group_by_getproc_and_instance(pktp, vbp, tcount, tlist);        if (tcount == 0 )        {        bzero((char *)&data, sizeof(data));        }    else        {        snmpOidToIpHostOrder (IP_ADDR_LEN, tlist , &data.natBindLocalAddress);        data.natBindLocalPort = *(tlist + IP_ADDR_LEN);        snmpOidToIpHostOrder (IP_ADDR_LEN, tlist +                               NAT_BINDTBL_REMOTE_ADDRESS_OFFSET,                               &data.natBindRemAddress);        data.natBindRemPort = *(tlist + NAT_BINDTBL_REMOTE_PORT_OFFSET);        }    if ( m2NatBindTblEntryGet (&data, NEXT_VALUE ) != OK)	{	for ( ; vbp != NULL; vbp = vbp->vb_link)	    {	    snmpNextError (pktp, vbp);            }	    return;	}    /*      * Create oid sequence for nat index retrieved. This ip_to_rlist routine     * expects to see the IP address in the network byte order. We have anyway     * done a htonl in m2NatBindTblEntryGet.     */        (void) ip_to_rlist (data.natBindLocalAddress, natBindIndex);    (void) ip_to_rlist (data.natBindRemAddress,                         natBindIndex + NAT_BINDTBL_REMOTE_ADDRESS_OFFSET);    *(natBindIndex + IP_ADDR_LEN) = data.natBindLocalPort;    *(natBindIndex + NAT_BINDTBL_REMOTE_PORT_OFFSET) = data.natBindRemPort;    for (    ; vbp; vbp = vbp->vb_link)        {           /* install instance part of next instance found */        nextproc_next_instance (pktp, vbp, NAT_BINDTBL_INDEX_LEN, natBindIndex);        natBindEntryGetValue (vbp->vb_ml.ml_last_match, pktp, vbp, &data);        }    }/*******************************************************************************  natBindEntryTest -  Test method routine for natBindTable.**  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 natBindEntryTest    (    OIDC_T      lastmatch,    int         tcount,    OIDC_T     *tlist,    SNMP_PKT_T *pktp,    VB_T       *vbp    )    {    NAT_BINDTBL_ENTRY data;    int               errorStatus;    VB_T *            pVbpTemp = vbp;    struct create_row rowObjs[] =                                   {                                      {&l_natBindAction, 0x01},                                      {&l_natBindProto, 0x01}                                  };     /*      * Check for a valid index length then for valid ip address and     * valid port no (for both local and remote ends)     */    bzero ((char *)&data, sizeof (data));    data.natBindLocalPort = *(tlist + IP_ADDR_LEN);    data.natBindRemPort = *(tlist + NAT_BINDTBL_REMOTE_PORT_OFFSET);    if ( (tcount != NAT_BINDTBL_INDEX_LEN) ||          (snmpOidToIpHostOrder (IP_ADDR_LEN, tlist, &data.natBindLocalAddress)) ||         (snmpOidToIpHostOrder (IP_ADDR_LEN, tlist +                                 NAT_BINDTBL_REMOTE_ADDRESS_OFFSET,                                 &data.natBindRemAddress)) )        {        errorStatus = NO_SUCH_NAME;        goto errorReturn;        }    /* Get the entry from our internal NAT tables */    m2NatBindTblEntryGet (&data, GET_VALUE);    pVbpTemp = vb_extract_row (pktp, vbp_to_index(pktp, vbp), tcount, tlist,                                     NAT_BIND_RW_OBJS, rowObjs);    for ( ; pVbpTemp; pVbpTemp = pVbpTemp->vb_link)        {        switch (pVbpTemp->vb_ml.ml_last_match)            {            case LEAF_natBindProto:                switch (VB_GET_INT32(pVbpTemp))                     {                    case VAL_natBindProto_tcp:                    case VAL_natBindProto_udp:                    case VAL_natBindProto_icmp:                        break;

⌨️ 快捷键说明

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