📄 tcptable.c
字号:
/* * Copyright 2000-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. *//* * Copyright 1988-1997 Epilogue Technology Corporation. * Copyright 1998 Integrated Systems, Inc. * All rights reserved. *//* * $Log: tcptable.c,v $ * Revision 1.2 2001/11/06 21:20:38 josh * revised new path hacking * * Revision 1.1.1.1 2001/11/05 17:47:45 tneale * Tornado shuffle * * Revision 9.2 2000/03/17 00:19:54 meister * Update copyright message * * Revision 9.1 1999/05/24 20:12:23 josh * 'compc' and 'compl' have been replaced by 'tcount' and 'tlist' * to avoid C++ compiler errors. * * Revision 9.0 1998/10/16 22:12:58 sar * Update version stamp to match release * * Revision 8.2 1998/06/05 18:53:32 sra * "#include <foo.h>" => "#include <envoy/h/foo.h>". * * Revision 8.1 1998/02/25 04:53:32 sra * Update copyrights. * * Revision 8.0 1997/11/18 00:57:13 sar * Updated revision to 8.0 * * Revision 7.2 1997/03/20 06:49:43 sra * DFARS-safe copyright text. Zap! * * Revision 7.1 1997/02/25 10:49:26 sra * Update copyright notice, dust under the bed. * * Revision 7.0 1996/03/18 20:24:05 sar * Updated rev to 7.0 and copyright to 96 * * Revision 6.1 1995/11/01 00:38:58 sar * removed localio.h, buffer.h and decode.h * added pp style argument lists * * Revision 6.0 1995/05/31 21:49:28 sra * Release 6.0. * * Revision 5.1 1995/05/05 23:06:58 sar * Added new routines using the async method routine api. * * Revision 5.0 1994/05/16 17:21:18 sar * Updated revision to 5.0 and copyright to include 1994 * * Revision 4.0 1993/06/24 17:53:56 sar * Updated rev to 4.0 and copyright to 93 * * Revision 3.0 1992/04/03 19:54:08 dab * Release 3.0 * * Revision 1.1 92/03/31 16:43:44 dab * Initial revision * * * Rev 2.0 31 Mar 1990 15:14:36 * Release 2.00 * * Rev 1.2 14 Dec 1989 16:01:02 * Added support for Borland Turbo C compiler * * Rev 1.1 27 Apr 1989 15:56:20 * Removed unused variables * * Rev 1.0 10 Oct 1988 21:48:50 * Initial revision.*//* [clearcase]modification history-------------------01b,19apr05,job update copyright notices01a,24nov03,job update copyright information*/#include <wrn/wm/snmp/engine/asn1.h>#include <wrn/wm/snmp/engine/snmp.h>#include <wrn/wm/snmp/engine/mib.h>#include "snmpvars.h" /* for local definitions *//**************************************************************************** THIS MODULE CONTAINS ROUTINES TO ACCESS TCP CONNECTION TABLE****************************************************************************//**************************************************************************** TCP CONNECTION TABLE ACCESS ROUTINES The instance, given by parameters "tcount" and "tlist" consists of ten object id components, a.b.c.d.e.f.g.h.i.j, of which a.b.c.d is the source IP address, e is the source port number, f.g.h.i is the destination IP address, and j is the destination port number.****************************************************************************//****************************************************************************NAME: tcptable_testPURPOSE: Test whether a given object exists in the TCP connection tablePARAMETERS: int TEST_SET or TEST_GET indicating what type of access is intended. OIDC_T Last component of the object id leading to the leaf node in the MIB. This is usually the identifier for the particular attribute in the table. int Number of components in the unused part of the object identifier OIDC_T * Unused part of the object identifier char * User's cookie, passed unchanged from the LEAF macro in the mib.cRETURNS: int 0 if the attribute is accessable. -1 if the attribute is not accessable.****************************************************************************//*ARGSUSED*//*lint -e715 */int tcptable_test(int form, /* See TEST_SET & TEST_GET in mib.h */ OIDC_T last_match, /* Last component matched */ int tcount, OIDC_T *tlist, char *cookie){/* There must be exactly 10 unused components */if (tcount != 10) return -1;return 0;}/*lint +e715 *//****************************************************************************NAME: tcptable_nextPURPOSE: Locate the "next" object in the TCP connection tablePARAMETERS: OIDC_T Last component of the object id leading to the leaf node in the MIB. This identifies the particular "attribute" we want in the table. The following values give an example: 1 - tcpConnState 2 - tcpConnLocalAddress 3 - tcpConnLocalPort 4 - tcpConnRemAddress 5 - tcpConnRemPort int Number of components in the yet unused part of the object identifier OIDC_T * Yet unused part of the object identifier OIDC_T * Start of an area in which the object instance part of the name of the "next" object should be constructed. char * User's cookie, passed unchanged from the LEAF macro in the mib.cRETURNS: int >0 indicates how many object identifiers have been placed in the result list. 0 if there is no "next" in the tableThis routine's job is to use the target object instance, representedby variables tcount and tlist, to ascertain whether there is a "next"entry in the table. If there is, the object instance of that elementis constructed in the return list area (rlist) and the number of elementsreturned. If there is no "next" a zero is returned.It is possible that the target object instance may be empty (i.e.tcount == 0) or incomplete (i.e. tcount < sizeof(normal object instance)).If tcount == 0, the first object in the table should be returned.The term "object instance" refers to that portion of an object identifierused by SNMP to identify a particular instance of a tabular variable.****************************************************************************//*ARGSUSED*//*lint -e715 */int tcptable_next(OIDC_T last_match, /* Last component matched */ int tcount, OIDC_T *tlist, OIDC_T *rlist, char *cookie){return 0;}/*lint +e715 *//****************************************************************************NAME: tcptable_getintPURPOSE: Obtain an Integer type parameter from the TCP connection table. The integer parameters in this table (and their lastmatch value) are: 1 - tcpConnState 3 - tcpConnLocalPort 5 - tcpConnRemPort PARAMETERS: OIDC_T Last component of the object id leading to the leaf node in the MIB. This is usually the identifier for the particular attribute in the table. int Number of components in the unused part of the object identifier OIDC_T * Unused part of the object identifier char * User's cookie, passed unchanged from the LEAF macro in the mib.cRETURNS: INT_32_T The value of the parameter.****************************************************************************//*ARGSUSED*//*lint -e715 */INT_32_T tcptable_getint(OIDC_T last_match, int tcount, OIDC_T *tlist, char *cookie){switch(last_match) { case 1: /* tcpConnState */ case 3: /* tcpConnLocalPort */ case 5: /* tcpConnRemPort */ return (INT_32_T)*((int *)cookie); /* TEMPORARY */ }return 0;}/*lint +e715 *//****************************************************************************NAME: tcptable_getipaddrPURPOSE: Obtain an IpAddress type parameter from the TCP connection table. The IpAddress parameters in this table (and their lastmatch value) are: 2 - tcpConnLocalAddress 4 - tcpConnRemAddress PARAMETERS: OIDC_T Last component of the object id leading to the leaf node in the MIB. This is usually the identifier for the particular attribute in the table. int Number of components in the unused part of the object identifier OIDC_T * Unused part of the object identifier char * User's cookie, passed unchanged from the LEAF macro in the mib.cRETURNS: OCTET_T * Pointer to a 4 byte long area in which the IP address is found. The address bytes must be in standard network order.****************************************************************************//*ARGSUSED*//*lint -e715 */OCTET_T * tcptable_getipaddr(OIDC_T last_match, int tcount, OIDC_T *tlist, char *cookie){switch(last_match) { case 2: /* tcpConnLocalAddress */ case 4: /* tcpConnRemAddress */ return (OCTET_T *)cookie; /* TEMPORARY */ }return (OCTET_T *)cookie;}void tcptable_test_async(OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){/* There must be exactly 10 unused component */if (tcount != 10) testproc_error(pktp, vbp, NO_CREATION);else testproc_good(pktp, vbp);}void tcptable_get_async(OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){/* There must be exactly 6 unused component */if ((tcount != 6) || (tlist[1] != 1)) { getproc_nosuchins(pktp, vbp); return; }switch(lastmatch) { case 1: /* tcpconnstate */ case 3: /* tcpconnlocalport */ case 5: /* tcpconnremoteport */ getproc_got_int32(pktp, vbp, *(INT_32_T *)(VB_TO_COOKIE(vbp))); break; case 2: /* tcpconnlocaladdress */ case 4: /* tcpconnremoteaddress */ getproc_got_ip_address(pktp, vbp, *(UINT_32_T *)(VB_TO_COOKIE(vbp))); break; }}/*lint +e715 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -