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

📄 snmptcp.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 2 页
字号:
/* snmpTcp.c snmpv1  method routines for tcp group*//* *  Copyright 1984-2005 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. */#include "copyright_wrs.h"/*modification history-------------------01b,19apr05,job  update copyright notices01a,01dec03,job  update copyright information01a,10mar96,rjc  written*//* * $Log: snmptcp.c,v $ * Revision 1.5  2001/12/04 19:42:41  josh * byteswapping for little-endian processors in tcpRemoteAddress * * Revision 1.4  2001/11/09 17:30:26  tneale * Another adjustment for generated header files * * Revision 1.3  2001/11/09 14:54:09  tneale * Fixed paths for generated files mibhand.h and mibleaf.h * * Revision 1.2  2001/11/08 22:18:35  meister * rework pathnames * * Revision 1.1.1.1  2001/11/05 17:47:50  tneale * Tornado shuffle * * Revision 1.5  2001/01/19 22:25:07  paul * Update copyright. * * Revision 1.4  2000/03/09 17:42:27  josh * setting up prototypes and includes where appropriate to eliminate * build warnings * * Revision 1.3  2000/03/07 21:17:31  josh * fixing log comments * * Revision 1.2  2000/03/07 20:58:37  josh * putting CVS headers and logs into files that were lacking * *//* includes */#include <wrn/wm/snmp/vxagent/snmpdLib.h>#include <m2Lib.h>#include <wrn/wm/snmp/vxagent/mibleaf.h>#include <wrn/wm/snmp/vxagent/mibhand.h>#include <wrn/wm/snmp/engine/auxfuncs.h>/* defines */#define IP_ADDR_LEN               4    /* Num of oid components in ip address */#define TCP_PORT_LEN              1    /* Num of oid components in tcp port */#define MAX_TCP_PORT              0xffff    /* max value for udp port */#define TCP_REMOTE_ADDR_OFFSET    (IP_ADDR_LEN + TCP_PORT_LEN)#define TCP_REMOTE_PORT_OFFSET    (2 * IP_ADDR_LEN + TCP_PORT_LEN)#define TCP_TBL_INDEX_LEN         (2 * (IP_ADDR_LEN + TCP_PORT_LEN))/* locals *//* max possible values for some table indexes */LOCAL  const OIDC_T maxTcpConnIndex []    = { 0xff, 0xff, 0xff, 0xff, 0xffff,                                               0xff , 0xff, 0xff, 0xff, 0xffff };LOCAL  const OIDC_T maxIpAddr []          = { 0xff, 0xff, 0xff, 0xff };/* forward declarations */LOCAL void tcpConnEntryInfoGet (OIDC_T, SNMP_PKT_T*, VB_T*, M2_TCPCONNTBL*);            /******************************************************************************* tcpConnEntryInfoGet  **  Extract tcp connection table entry info from the m2 structure.**  Parameters to this routine are *  *  <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.*  <pTcpConnEntry> - ptr to struct containing tcp table entry.**/    LOCAL void tcpConnEntryInfoGet    (    OIDC_T              lastmatch,    SNMP_PKT_T*	        pktp,    VB_T*               vbp,    M2_TCPCONNTBL *     pTcpConnEntry    )    {    switch (lastmatch)        {        case LEAF_tcpConnState:            getproc_got_int32 (pktp, vbp,                                (INT_32_T) pTcpConnEntry->tcpConnState);            return;        case LEAF_tcpConnLocalAddress:            getproc_got_ip_address (pktp, vbp,                                     htonl (pTcpConnEntry->tcpConnLocalAddress));            return;        case LEAF_tcpConnLocalPort:            getproc_got_int32 (pktp, vbp,                                (INT_32_T) pTcpConnEntry->tcpConnLocalPort);            return;        case LEAF_tcpConnRemAddress:            getproc_got_ip_address (pktp, vbp,                                     htonl (pTcpConnEntry->tcpConnRemAddress));            return;        case LEAF_tcpConnRemPort:            getproc_got_int32 (pktp, vbp,                                (INT_32_T) pTcpConnEntry->tcpConnRemPort);            return;        default:            getproc_error (pktp, vbp, GEN_ERR);            return;         }    }                            /********************************************************************************  tcpConnEntryTest**  Test method routine for tcp Connection table.*  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 **  RETURNS: N/A*/               void tcpConnEntryTest    (    OIDC_T              lastmatch,    int	                compc,    OIDC_T*             compl,    SNMP_PKT_T*	        pktp,    VB_T*               vbp    )    {    M2_TCPCONNTBL       tcpConnEntry;    int                 errorStatus;    /* Check for a valid index length then for valid ip address and     * valid port no (for both local and remote ends)     * Then check if column to set is the tcpConnState column     * since that is the only permissible one for a set in the tcp group.     * If these are good then get table entry     */    if ((compc !=  TCP_TBL_INDEX_LEN) ||         snmpOidToIpHostOrder (IP_ADDR_LEN, compl,                               &tcpConnEntry.tcpConnLocalAddress) ||         ((tcpConnEntry.tcpConnLocalPort = *(compl + IP_ADDR_LEN)) >          MAX_TCP_PORT) ||         snmpOidToIpHostOrder (IP_ADDR_LEN, compl + TCP_REMOTE_ADDR_OFFSET,                               &tcpConnEntry.tcpConnRemAddress) ||         ((tcpConnEntry.tcpConnRemPort = *(compl + TCP_REMOTE_PORT_OFFSET)) >          MAX_TCP_PORT) ||         (lastmatch != LEAF_tcpConnState))        {        errorStatus = NO_SUCH_NAME;        goto errorReturn;        }    if (m2TcpConnEntryGet (M2_EXACT_VALUE, & tcpConnEntry) != OK)        {        errorStatus = NO_SUCH_NAME;                 goto errorReturn;        }    /* Only good value for set is delete tcb */    if ( vbp->value_u.v_number != M2_tcpConnState_deleteTCB)        {        errorStatus = WRONG_VALUE;        goto errorReturn;        }    testproc_good (pktp, vbp);    return;errorReturn:    testproc_error (pktp, vbp, errorStatus);    return;    }                /*******************************************************************************  tcpConnEntrySet**  Set method routine for tcp connection table**  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.***/    void tcpConnEntrySet    (    OIDC_T              lastmatch,    int	                compc,    OIDC_T*             compl,    SNMP_PKT_T*	        pktp,    VB_T*               vbp    )    {    M2_TCPCONNTBL       tcpConnEntry;        snmpOidToIpHostOrder (IP_ADDR_LEN, compl,                           &tcpConnEntry.tcpConnLocalAddress);    tcpConnEntry.tcpConnLocalPort = *(compl + IP_ADDR_LEN);    snmpOidToIpHostOrder (IP_ADDR_LEN, compl + TCP_REMOTE_ADDR_OFFSET,                           &tcpConnEntry.tcpConnRemAddress);    tcpConnEntry.tcpConnRemPort = *(compl + TCP_REMOTE_PORT_OFFSET);

⌨️ 快捷键说明

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