📄 mib.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: mib.c,v $ * Revision 1.2 2001/11/06 21:20:37 josh * revised new path hacking * * Revision 1.1.1.1 2001/11/05 17:47:45 tneale * Tornado shuffle * * Revision 9.1 2000/03/17 00:19:50 meister * Update copyright message * * Revision 9.0 1998/10/16 22:12:52 sar * Update version stamp to match release * * Revision 8.2 1998/06/05 18:53:29 sra * "#include <foo.h>" => "#include <envoy/h/foo.h>". * * Revision 8.1 1998/02/25 04:53:13 sra * Update copyrights. * * Revision 8.0 1997/11/18 00:57:10 sar * Updated revision to 8.0 * * Revision 7.3 1997/11/05 01:09:12 sar * Changed the access type macros from two characters to full names. * * Revision 7.2 1997/03/20 06:49:34 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.2 1996/01/25 19:28:21 sar * Added a [0] to the test_string and test_ipaddr constructs to try * and get the construct to be more portable. * * Revision 6.1 1995/11/01 00:38:58 sar * Removed deprecated v2 types * * Revision 6.0 1995/05/31 21:49:17 sra * Release 6.0. * * Revision 5.4 1995/05/08 20:34:52 sar * Removed some defs as they are now included in .h files. * * Revision 5.3 1995/05/05 23:08:18 sar * Updated the mib to use the compatibility macros defined in mib.h. * * Revision 5.2 1994/09/29 18:23:27 sar * Check the install option before using v2 types in a v1 setting. * * Revision 5.1 1994/07/19 19:29:32 sar * Added the nodes and arcs to support a test group to cover most of the * types. This includes modifing the epilogue and enterprise nodes and arcs. * * 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:40 dab * Initial revision * * * Rev 2.0 31 Mar 1990 15:14:30 * Release 2.00 * * Rev 1.8 24 Sep 1989 22:06:34 * Renamed mib_root to mib_root_node to support the MIB compiler. * * Rev 1.7 26 Aug 1989 16:49:24 * Moved ipForwarding into the ip_stats structure. * * Rev 1.6 25 Jan 1989 13:26:48 * Added a dummy numeric variable to act as a dummy reference for numeric * leaf nodes. * The user is expected to provide correct references during the porting * effort. After which this dummy variable, dummyval, may be removed. * * Rev 1.5 25 Jan 1989 12:34:20 * Added a character string to be used as a dummy cookie for VT_STRING * leaves in the distribution. This eliminates a null pointer situation * should someone use the distribution mib without inserting pointers to * the real variables. This new string, dummystr, is intended to be removed * by the user after the porting is complete. * * Rev 1.4 10 Oct 1988 21:49:38 * Source reorganization * * Rev 1.3 22 Sep 1988 1:28:00 * Added missing level of tables, attable, under at_node. * * Rev 1.2 22 Sep 1988 0:48:42 * Corrected error in atentry_arcs. * * Rev 1.1 21 Sep 1988 16:34:24 * Revised spelling to conform to the usage "MGMT" in the MIB. * * Rev 1.0 12 Sep 1988 10:47:02 * Initial revision.*//* [clearcase]modification history-------------------01b,19apr05,job update copyright notices01a,24nov03,job update copyright information*//**************************************************************************** * THIS MIB CORRESPONDS TO RFC1065 AND RFC1066 ****************************************************************************/#include <wrn/wm/snmp/engine/asn1.h>#include <wrn/wm/snmp/engine/snmp.h>#include <wrn/wm/snmp/engine/mib.h>#include "snmpvars.h"#define STATIC staticextern int no_var_here();extern int force_next();#define set_ip_address set_stringextern int get_centasecs_from_clicks();extern int iftable_test();extern int iftable_next();extern int iftable_getint();extern int iftable_getstring();extern int iftable_setint();extern int attable_test();extern int attable_next();extern int attable_getint();extern int attable_getipaddr();extern int attable_getstring();extern int attable_setint();extern int attable_setstring();extern int ip_addrtable_test();extern int ip_addrtable_next();extern int ip_addrtable_getint();extern int ip_addrtable_getipaddr();extern int ip_routetable_test();extern int ip_routetable_next();extern int ip_routetable_getint();extern int ip_routetable_getipaddr();extern int ip_routetable_setint();extern int ip_routetable_setipaddr();extern int tcptable_test();extern int tcptable_next();extern int tcptable_getint();extern int tcptable_getipaddr();/********************************************************************** Dummy string This string is used only in the distribution sources to provide an address for string and opaque leaf node cookies. This variable may be removed after porting once real pointers are placed in those leaves. **********************************************************************/static char dummystr[] = "DUMMY STRING";/********************************************************************** Dummy value This value is used only in the distribution sources to provide an value for numeric leaf node cookies. This variable may be removed after porting once real pointers are placed in those leaves. **********************************************************************/static unsigned long dummyval = 0;/****************************************************************************NAME: Mib_TreePURPOSE: The following data structure represents the Management Information Base (MIB) tree.****************************************************************************/#if defined(_DUMMY_NODE)LEAF_COMS(dn,dn_crs,"DUMMY NODE",VT_NUMBER,0,0,no_var_here, null_get_proc,null_set_proc,force_next,&dummyval,0,0xff,0xff);#endif/********************************************************************** THE SYSTEM GROUP **********************************************************************/LEAF_COMS(sysdescr_leaf, sysdescr_crs, "sysDescr", VT_STRING, READ_ACCESS, 0, it_exists, get_string, null_set_proc, std_next, snmp_system_description, 0, 0xff, 0xff);LEAF_COMS(sysobjectid_leaf, sysobjectid_crs, "sysObjectID", VT_OBJECT, READ_ACCESS, 0, it_exists, get_object_identifier, null_set_proc, std_next, &snmp_system_object_id, 0, 0xff, 0xff);LEAF_COMS(sysuptime_leaf, sysuptime_crs, "sysUpTime", VT_TIMETICKS, READ_ACCESS, 0, it_exists, get_centasecs_from_clicks, null_set_proc, std_next, (char *)&system_clicks, 0, 0xff, 0xff);/* The SYSTEM node */MIBARC_T system_arcs[] = {ARC(1, sysdescr_leaf), ARC(2, sysobjectid_leaf), ARC(3, sysuptime_leaf), END_OF_ARC_LIST};STATICMIBNODE_T system_node = NODE("system", system_arcs);/********************************************************************** THE INTERFACES GROUP **********************************************************************//* The INTERFACES node */LEAF_COMS(ifnumber_leaf, ifnumber_crs, "ifNumber", VT_NUMBER, READ_ACCESS, 0, it_exists, get_int, null_set_proc, std_next, &if_number, 0, 0xff, 0xff);/* The Interfaces Table */LEAF_COMS(ifindex_leaf, ifindex_crs, "ifIndex", VT_NUMBER, READ_ACCESS, 0, iftable_test, iftable_getint, null_set_proc, iftable_next, &dummyval, 0, 0xff, 0xff);LEAF_COMS(ifdescr_leaf, ifdescr_crs, "ifDescr", VT_STRING, READ_ACCESS, 0, iftable_test, iftable_getstring, null_set_proc, iftable_next, dummystr, 0, 0xff, 0xff);LEAF_COMS(iftype_leaf, iftype_crs, "ifType", VT_NUMBER, READ_ACCESS, 0, iftable_test, iftable_getint, null_set_proc, iftable_next, &dummyval, 0, 0xff, 0xff);LEAF_COMS(ifmtu_leaf, ifmtu_crs, "ifMtu", VT_NUMBER, READ_ACCESS, 0, iftable_test, iftable_getint, null_set_proc, iftable_next, &dummyval, 0, 0xff, 0xff);LEAF_COMS(ifspeed_leaf, ifspeed_crs, "ifSpeed", VT_GAUGE, READ_ACCESS, 0, iftable_test, iftable_getint, null_set_proc, iftable_next, &dummyval, 0, 0xff, 0xff);LEAF_COMS(ifphysaddress_leaf, ifphysaddress, "ifPhysAddress", VT_STRING, READ_ACCESS, 0, iftable_test, iftable_getstring, null_set_proc, iftable_next, dummystr, 0, 0xff, 0xff);LEAF_COMS(ifadminstatus_leaf, ifadminstatus_crs, "ifAdminStatus", VT_NUMBER, READ_WRITE_ACCESS, 0, iftable_test, iftable_getint, iftable_setint, iftable_next, &dummyval, 0, 0xff, 0xff);LEAF_COMS(ifoperstatus_leaf, ifoperstatus_crs, "ifOperStatus", VT_NUMBER, READ_ACCESS, 0, iftable_test, iftable_getint, null_set_proc, iftable_next, &dummyval, 0, 0xff, 0xff);LEAF_COMS(iflastchange_leaf, iflastchange_crs, "ifLastChange", VT_TIMETICKS, READ_ACCESS, 0, iftable_test, iftable_getint, null_set_proc, iftable_next, &dummyval, 0, 0xff, 0xff);LEAF_COMS(ifinoctets_leaf, ifinoctets_crs, "ifInOctets", VT_COUNTER, READ_ACCESS, 0, iftable_test, iftable_getint, null_set_proc, iftable_next, &dummyval, 0, 0xff, 0xff);LEAF_COMS(ifinucastpkts_leaf, ifinucastpkts_crs, "ifInUcastPkts", VT_COUNTER, READ_ACCESS, 0, iftable_test, iftable_getint, null_set_proc, iftable_next, &dummyval, 0, 0xff, 0xff);LEAF_COMS(ifinnucastpkts_leaf, ifinnucastpkts_cr, "ifInNUcastPkts", VT_COUNTER, READ_ACCESS, 0, iftable_test, iftable_getint, null_set_proc, iftable_next, &dummyval, 0, 0xff, 0xff);LEAF_COMS(ifindiscards_leaf, ifindiscards_crs, "ifInDiscards", VT_COUNTER, READ_ACCESS, 0, iftable_test, iftable_getint, null_set_proc, iftable_next, &dummyval, 0, 0xff, 0xff);LEAF_COMS(ifinerrors_leaf, ifinerrors_crs, "ifInErrors", VT_COUNTER, READ_ACCESS, 0, iftable_test, iftable_getint, null_set_proc, iftable_next, &dummyval, 0, 0xff, 0xff);LEAF_COMS(ifinunknownprotos_leaf, ifinunknownprotos_crs, "ifInUnknownProtos", VT_COUNTER, READ_ACCESS, 0, iftable_test, iftable_getint, null_set_proc, iftable_next, &dummyval, 0, 0xff, 0xff);LEAF_COMS(ifoutoctets_leaf, ifoutoctets_crs, "ifOutOctets", VT_COUNTER, READ_ACCESS, 0, iftable_test, iftable_getint, null_set_proc, iftable_next, &dummyval, 0, 0xff, 0xff);LEAF_COMS(ifoutucastpkts_leaf, ifoutucastpkts_cr, "ifOutUcastPkts", VT_COUNTER, READ_ACCESS, 0, iftable_test, iftable_getint, null_set_proc, iftable_next, &dummyval, 0, 0xff, 0xff);LEAF_COMS(ifoutnucastpkts_leaf, ifoutnucastpkts_crs, "ifOutNUcastPkts", VT_COUNTER, READ_ACCESS, 0, iftable_test, iftable_getint, null_set_proc, iftable_next, &dummyval, 0, 0xff, 0xff);LEAF_COMS(ifoutdiscards_leaf, ifoutdiscards_crs, "ifOutDiscards", VT_COUNTER, READ_ACCESS, 0, iftable_test, iftable_getint, null_set_proc, iftable_next, &dummyval, 0, 0xff, 0xff);LEAF_COMS(ifouterrors_leaf, ifouterrors_crs, "ifOutErrors", VT_COUNTER, READ_ACCESS, 0, iftable_test, iftable_getint, null_set_proc, iftable_next, &dummyval, 0, 0xff, 0xff);LEAF_COMS(ifoutqlen_leaf, ifoutqlen_crs, "ifOutQLen", VT_GAUGE, READ_ACCESS, 0, iftable_test, iftable_getint, null_set_proc, iftable_next, &dummyval, 0, 0xff, 0xff);STATICMIBARC_T ifentry_arcs[] = {ARC(1, ifindex_leaf), ARC(2, ifdescr_leaf), ARC(3, iftype_leaf), ARC(4, ifmtu_leaf), ARC(5, ifspeed_leaf), ARC(6, ifphysaddress_leaf), ARC(7, ifadminstatus_leaf), ARC(8, ifoperstatus_leaf),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -