Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Mar 2006 23:45:19 GMT
From:      Shteryana Shopova <soc-shteryana@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 93892 for review
Message-ID:  <200603232345.k2NNjJFc021110@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=93892

Change 93892 by soc-shteryana@prometheus on 2006/03/23 23:44:26

	IFC	

Affected files ...

.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/FREEBSD-Xlist#3 integrate
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/NEWS#3 integrate
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/TODO#2 integrate
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/VERSION#3 integrate
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/gensnmptree/gensnmptree.1#3 integrate
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/gensnmptree/gensnmptree.c#4 integrate
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/lib/asn1.c#3 integrate
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/lib/asn1.h#3 integrate
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/lib/snmpclient.c#3 integrate
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/lib/support.h#2 integrate
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/oid-list#2 integrate
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmp_mibII/BEGEMOT-IP-MIB.txt#1 branch
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmp_mibII/BEGEMOT-MIB2-MIB.txt#1 branch
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmp_mibII/mibII.c#8 integrate
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmp_mibII/mibII.h#3 integrate
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmp_mibII/mibII_begemot.c#1 branch
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmp_mibII/mibII_interfaces.c#3 integrate
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmp_mibII/mibII_route.c#3 integrate
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmp_mibII/mibII_tcp.c#3 branch
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmp_mibII/mibII_tree.def#6 integrate
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmp_mibII/mibII_udp.c#3 branch
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmp_mibII/snmp_mibII.h#2 integrate
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmp_ntp/snmp_ntp.c#3 integrate
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmpd/bsnmpd.1#3 integrate
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmpd/config.c#3 integrate
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmpd/export.c#2 integrate
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmpd/main.c#5 integrate
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmpd/snmpd.config#5 integrate
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmpd/snmpmod.3#3 integrate
.. //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmpd/snmpmod.h#4 integrate
.. //depot/projects/soc2005/bsnmp/lib/Makefile#2 integrate
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/bsnmpd/Makefile#3 integrate
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/Makefile#7 integrate
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile#24 integrate
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c#12 integrate
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_diskstorage_tbl.c#14 integrate
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c#8 integrate
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_network_tbl.c#7 integrate
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_partition_tbl.c#6 integrate
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_printer_tbl.c#7 integrate
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_processor_tbl.c#5 integrate
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c#12 integrate
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.c#23 integrate
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.h#28 integrate
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c#12 integrate
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swinstalled_tbl.c#4 integrate
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swrun_tbl.c#8 integrate
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_tree.def#2 integrate
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/snmp_hostres.3#2 integrate
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile#5 integrate

Differences ...

==== //depot/projects/soc2005/bsnmp/contrib/bsnmp/FREEBSD-Xlist#3 (text+ko) ====

@@ -1,4 +1,4 @@
-#$FreeBSD: src/contrib/bsnmp/FREEBSD-Xlist,v 1.4 2005/10/04 14:53:06 harti Exp $
+#$FreeBSD: src/contrib/bsnmp/FREEBSD-Xlist,v 1.5 2006/03/13 09:30:26 harti Exp $
 */Makefile.in
 */acinclude.m4
 */aclocal.m4
@@ -10,6 +10,7 @@
 */gensnmptree/Makefile.in
 */lib/Makefile.in
 */snmp_mibII/Makefile.in
+*/snmp_mibII/tree.h
 */snmp_ntp/Makefile.in
 */snmpd/Makefile.in
 */snmpd/.gdbinit

==== //depot/projects/soc2005/bsnmp/contrib/bsnmp/NEWS#3 (text+ko) ====

@@ -1,3 +1,29 @@
+1.12
+	A couple of man page fixes from various submitters.
+
+	Make default communities NULL for security.
+
+	Fix a core dump when -d tracing suboption has no argument (thanks
+	to Shteryana Shopova).
+
+	Fix bug in parsing the include path in the daemon.
+
+	Fix an uninitialize structure field in gensnmptree (thanks to
+	jasone@freebsdorg)
+
+	64bit HC counters in the IF-MIB by polling the OS periodically.
+
+	Fix link traps to be more RFC conform (thanks to glebius@freebsd.org)
+
+	Add fallback definition for SA_SIZE() to support.h.
+
+	Move the porting definitions for U?INT32_{MIN,MAX} into support.h.
+
+	Include a sys/tree.h from FreeBSD-current and add autoconf
+	check for it.
+
+1.11a	Fix build of modules when stdint.h is included after asn1.h
+
 1.11	Make the Mib2 routing table use red-black tree. This vastly
 	reduces loading and access time. Load the table only every 10
 	minutes. In the meantime process message from the routing socket

==== //depot/projects/soc2005/bsnmp/contrib/bsnmp/TODO#2 (text+ko) ====

@@ -1,6 +1,3 @@
-snmpd_mibII:
-	- handle HC counters by periodically polling the kernel counters.
-
 snmpd:
 	- rethink transports a little bit: make them loadable and make
 	a private subtree for transports:

==== //depot/projects/soc2005/bsnmp/contrib/bsnmp/VERSION#3 (text+ko) ====

@@ -1,1 +1,1 @@
-1.11
+1.12

==== //depot/projects/soc2005/bsnmp/contrib/bsnmp/gensnmptree/gensnmptree.1#3 (text+ko) ====

@@ -26,9 +26,9 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $Begemot: bsnmp/gensnmptree/gensnmptree.1,v 1.5 2005/06/15 11:31:25 brandt_h Exp $
+.\" $Begemot: bsnmp/gensnmptree/gensnmptree.1,v 1.7 2006/02/27 09:52:08 brandt_h Exp $
 .\"
-.Dd June 14, 2005
+.Dd February 27, 2006
 .Dt GENSNMPTREE 1
 .Os
 .Sh NAME
@@ -45,7 +45,7 @@
 utility is used to either generate C language tables and header files from
 a MIB description or to numeric OIDs from MIB descriptions.
 The first form is used only for maintaining the
-.Xr snmpd 1
+.Xr bsnmpd 1
 daemon or for module writers.
 The second form may be used by SNMP client program writers.
 .Pp
@@ -57,7 +57,7 @@
 C-file
 .Ar prefix Ns tree.c
 containing a table used by
-.Xr snmpd 1
+.Xr bsnmpd 1
 during PDU processing
 and a header file
 .Ar prefix Ns tree.h
@@ -70,14 +70,19 @@
 .Nm
 expects MIB variable names (only the last component) on its command line.
 It reads a MIB specification from standard input and for each MIB variable
-name emits two C preprocessor defines on its standard output.
-One define
-.Va OID_ Ns Ar name
-can be used as an array initialized to initialize a
-.Va struct asn_oid .
-The other define
-.Va OIDLEN_ Ns Ar name
-contains the length of the OID.
+name emits three C preprocessor defines on its standard output:
+.Bl -tag -width ".Va OIDLEN_ Ns Ar Name"
+.It Va OIDX_ Ns Ar name
+This define can be used to initialize a
+.Va struct asn_oid
+in the following way:
+.Pp
+.Dl const struct asn_oid oid_sysDescr = OIDX_sysDescr;
+.It Va OIDLEN_ Ns Ar name
+is the length of the OID.
+.It Va OID_ Ns Ar name
+is the last component of the OID.
+.El
 .Pp
 The options are as follows:
 .Bl -tag -width ".Fl d Ar argument"
@@ -88,7 +93,7 @@
 .It Fl l
 Generate local preprocessor includes.
 This is used for bootstrapping
-.Xr snmpd 1 .
+.Xr bsnmpd 1 .
 .It Fl t
 Instead of normal output print the resulting tree.
 .It Fl p Ar prefix
@@ -187,6 +192,6 @@
 )
 .Ed
 .Sh SEE ALSO
-.Xr snmpd 1
+.Xr bsnmpd 1
 .Sh AUTHORS
 .An Hartmut Brandt Aq harti@freebsd.org

==== //depot/projects/soc2005/bsnmp/contrib/bsnmp/gensnmptree/gensnmptree.c#4 (text+ko) ====

@@ -30,7 +30,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Begemot: bsnmp/gensnmptree/gensnmptree.c,v 1.43 2005/10/04 11:21:29 brandt_h Exp $
+ * $Begemot: bsnmp/gensnmptree/gensnmptree.c,v 1.44 2006/02/14 09:04:17 brandt_h Exp $
  *
  * Generate OID table from table description.
  *
@@ -901,8 +901,6 @@
 	int opt;
 	struct node *root;
 	char fname[MAXPATHLEN + 1];
-	char include_fname[MAXPATHLEN + 128 +1];
-	int idx;
 	int tok;
 
 	while ((opt = getopt(argc, argv, "help:t")) != EOF)
@@ -960,24 +958,13 @@
 		return (0);
 	}
 	sprintf(fname, "%stree.h", file_prefix);
-	
-	/*prepare the ifndef directive*/
-	memset(include_fname,'\0',sizeof(include_fname));
-	snprintf(include_fname, MAXPATHLEN + 128, "_%sTREE_H_INCLUDED__",file_prefix);
-	for(idx = 0; idx < strlen(include_fname); idx++){
-		include_fname[idx] = toupper(include_fname[idx]);		
-	}
-			
 	if ((fp = fopen(fname, "w")) == NULL)
 		err(1, "%s: ", fname);
-	
-	fprintf(fp, "#ifndef %s\n",include_fname);
-	fprintf(fp, "#define %s\n",include_fname);		
 	gen_header(root, PREFIX_LEN, NULL);
 
 	fprintf(fp, "#define %sCTREE_SIZE %u\n", file_prefix, tree_size);
 	fprintf(fp, "extern const struct snmp_node %sctree[];\n", file_prefix);
-	fprintf(fp, "#endif /* %s */\n",include_fname);
+
 	fclose(fp);
 
 	sprintf(fname, "%stree.c", file_prefix);

==== //depot/projects/soc2005/bsnmp/contrib/bsnmp/lib/asn1.c#3 (text+ko) ====

@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Begemot: bsnmp/lib/asn1.c,v 1.29 2005/10/04 11:21:31 brandt_h Exp $
+ * $Begemot: bsnmp/lib/asn1.c,v 1.31 2005/10/06 07:14:58 brandt_h Exp $
  *
  * ASN.1 for SNMP.
  */
@@ -41,18 +41,10 @@
 #include <inttypes.h>
 #endif
 #include <assert.h>
+
+#include "support.h"
 #include "asn1.h"
 
-#if !defined(INT32_MIN)
-#define	INT32_MIN	(-0x7fffffff-1)
-#endif
-#if !defined(INT32_MAX)
-#define	INT32_MAX	(0x7fffffff)
-#endif
-#if !defined(UINT32_MAX)
-#define	UINT32_MAX	(0xffffffff)
-#endif
-
 static void asn_error_func(const struct asn_buf *, const char *, ...);
 
 void (*asn_error)(const struct asn_buf *, const char *, ...) = asn_error_func;

==== //depot/projects/soc2005/bsnmp/contrib/bsnmp/lib/asn1.h#3 (text+ko) ====

@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Begemot: bsnmp/lib/asn1.h,v 1.19 2005/10/04 11:21:31 brandt_h Exp $
+ * $Begemot: bsnmp/lib/asn1.h,v 1.20 2005/10/05 16:43:11 brandt_h Exp $
  *
  * ASN.1 for SNMP
  */

==== //depot/projects/soc2005/bsnmp/contrib/bsnmp/lib/snmpclient.c#3 (text+ko) ====

@@ -30,7 +30,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Begemot: bsnmp/lib/snmpclient.c,v 1.34 2005/10/04 14:32:42 brandt_h Exp $
+ * $Begemot: bsnmp/lib/snmpclient.c,v 1.36 2005/10/06 07:14:58 brandt_h Exp $
  *
  * Support functions for SNMP clients.
  */
@@ -64,14 +64,6 @@
 #include "snmpclient.h"
 #include "snmppriv.h"
 
-#if !defined(INT32_MAX)
-#define	INT32_MAX	(0x7fffffff)
-#endif
-#if !defined(UINT32_MAX)
-#define	UINT32_MAX	(0xffffffff)
-#endif
-
-
 /* global context */
 struct snmp_client snmp_client;
 

==== //depot/projects/soc2005/bsnmp/contrib/bsnmp/lib/support.h#2 (text+ko) ====

@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004
+ * Copyright (C) 2004-2005
  *	Hartmut Brandt.
  *	All rights reserved.
  *
@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Begemot: bsnmp/lib/support.h,v 1.1 2004/08/06 08:47:59 brandt Exp $
+ * $Begemot: bsnmp/lib/support.h,v 1.2 2005/10/06 07:14:59 brandt_h Exp $
  *
  * Functions that are missing on certain systems. This header file is not
  * to be installed.
@@ -68,4 +68,29 @@
 
 #endif
 
+/*
+ * For systems with missing stdint.h or inttypes.h
+ */
+#if !defined(INT32_MIN)
+#define	INT32_MIN	(-0x7fffffff-1)
+#endif
+#if !defined(INT32_MAX)
+#define	INT32_MAX	(0x7fffffff)
+#endif
+#if !defined(UINT32_MAX)
+#define	UINT32_MAX	(0xffffffff)
+#endif
+
+/*
+ * Systems missing SA_SIZE(). Taken from FreeBSD net/route.h:1.63
+ */
+#ifndef SA_SIZE
+
+#define SA_SIZE(sa)						\
+    (  (!(sa) || ((struct sockaddr *)(sa))->sa_len == 0) ?	\
+	sizeof(long)		:				\
+	1 + ( (((struct sockaddr *)(sa))->sa_len - 1) | (sizeof(long) - 1) ) )
+
+#endif
+
 #endif

==== //depot/projects/soc2005/bsnmp/contrib/bsnmp/oid-list#2 (text+ko) ====

@@ -1,4 +1,4 @@
-$Begemot: bsnmp/oid-list,v 1.3 2005/05/23 09:03:22 brandt_h Exp $
+$Begemot: bsnmp/oid-list,v 1.5 2006/02/27 09:55:45 brandt_h Exp $
 
 This file documents the OID assignments under BSNMP's private OID.
 
@@ -11,10 +11,12 @@
     1		BEGEMOT
       1		BEGEMOT-SNMPD
       2		BEGEMOT-NETGRAPH	snmpd netgraph module
+      3		BEGEMOT-IP		snmpd IP related stuff.
       100	BEGEMOT-ILMID		snmpd ILMID module
       101	BEGEMOT-ATM		snmpd ATM module
       200	BEGEMOT-PF		snmpd PF module (phillip@freebsd.org)
       201	BEGEMOT-NTP		snmpd NTP module
+      202	BEGEMOT-HOSTRES		snmpd HOSTRES module private stuff
       300	BEGEMOT-ACM		DLR ACM project
 
 If you need an OID and don't know where to stuck it in, I can assign you one -

==== //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmp_mibII/mibII.c#8 (text+ko) ====

@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Begemot: bsnmp/snmp_mibII/mibII.c,v 1.23 2005/06/09 12:36:52 brandt_h Exp $
+ * $Begemot: bsnmp/snmp_mibII/mibII.c,v 1.24 2006/02/14 09:04:18 brandt_h Exp $
  *
  * Implementation of the standard interfaces and ip MIB.
  */
@@ -34,9 +34,6 @@
 #include "mibII_oid.h"
 #include <net/if_types.h>
 
-/*just a prototype below*/
-u_int 
-mib2_getIfIndex(const char* dev_name);
 
 /*****************************/
 
@@ -57,8 +54,8 @@
 /* OR registrations */
 static u_int ifmib_reg;
 static u_int ipmib_reg;
-
-
+static u_int tcpmib_reg;
+static u_int udpmib_reg;
 static u_int ipForward_reg;
 
 /*****************************/
@@ -108,10 +105,24 @@
 /* list of all New if registrations */
 static struct newifreg_list newifreg_list = TAILQ_HEAD_INITIALIZER(newifreg_list);
 
+/* baud rate of fastest interface */
+uint64_t mibif_maxspeed;
+
+/* user-forced update interval */
+u_int mibif_force_hc_update_interval;
+
+/* current update interval */
+u_int mibif_hc_update_interval;
+
+/* HC update timer handle */
+static void *hc_update_timer;
+
 /*****************************/
 
 static const struct asn_oid oid_ifMIB = OIDX_ifMIB;
 static const struct asn_oid oid_ipMIB = OIDX_ipMIB;
+static const struct asn_oid oid_tcpMIB = OIDX_tcpMIB;
+static const struct asn_oid oid_udpMIB = OIDX_udpMIB;
 static const struct asn_oid oid_ipForward = OIDX_ipForward;
 static const struct asn_oid oid_linkDown = OIDX_linkDown;
 static const struct asn_oid oid_linkUp = OIDX_linkUp;
@@ -281,16 +292,15 @@
 	    (struct snmp_value *)NULL);
 }
 
-/*
- * Fetch new MIB data.
+/**
+ * Fetch the GENERIC IFMIB and update the HC counters
  */
-int
-mib_fetch_ifmib(struct mibif *ifp)
+static int
+fetch_generic_mib(struct mibif *ifp, const struct ifmibdata *old)
 {
 	int name[6];
 	size_t len;
-	void *newmib;
-	struct ifmibdata oldmib = ifp->mib;
+	struct mibif_private *p = ifp->private;
 
 	name[0] = CTL_NET;
 	name[1] = PF_LINK;
@@ -307,26 +317,144 @@
 		return (-1);
 	}
 
-	if (ifp->trap_enable) {
-		if (!(oldmib.ifmd_flags & IFF_UP)) {
-			if (ifp->mib.ifmd_flags & IFF_UP)
-				link_trap(ifp, 1);
+	/*
+	 * Assume that one of the two following compounds is optimized away
+	 */
+	if (ULONG_MAX >= 0xffffffffffffffffULL) {
+		p->hc_inoctets = ifp->mib.ifmd_data.ifi_ibytes;
+		p->hc_outoctets = ifp->mib.ifmd_data.ifi_obytes;
+		p->hc_omcasts = ifp->mib.ifmd_data.ifi_omcasts;
+		p->hc_opackets = ifp->mib.ifmd_data.ifi_opackets;
+		p->hc_imcasts = ifp->mib.ifmd_data.ifi_imcasts;
+		p->hc_ipackets = ifp->mib.ifmd_data.ifi_ipackets;
+
+	} else if (ULONG_MAX >= 0xffffffff) {
+
+#define	UPDATE(HC, MIB)							\
+		if (old->ifmd_data.MIB > ifp->mib.ifmd_data.MIB)	\
+			p->HC += (0x100000000ULL +			\
+			    ifp->mib.ifmd_data.MIB) -			\
+			    old->ifmd_data.MIB;				\
+		else							\
+			p->HC += ifp->mib.ifmd_data.MIB -		\
+			    old->ifmd_data.MIB;
+
+		UPDATE(hc_inoctets, ifi_ibytes)
+		UPDATE(hc_outoctets, ifi_obytes)
+		UPDATE(hc_omcasts, ifi_omcasts)
+		UPDATE(hc_opackets, ifi_opackets)
+		UPDATE(hc_imcasts, ifi_imcasts)
+		UPDATE(hc_ipackets, ifi_ipackets)
+
+#undef	UPDATE
+	} else
+		abort();
+	return (0);
+}
+
+/**
+ * Update the 64-bit interface counters
+ */
+static void
+update_hc_counters(void *arg __unused)
+{
+	struct mibif *ifp;
+	struct ifmibdata oldmib;
+
+	TAILQ_FOREACH(ifp, &mibif_list, link) {
+		oldmib = ifp->mib;
+		(void)fetch_generic_mib(ifp, &oldmib);
+	}
+}
+
+/**
+ * Recompute the poll timer for the HC counters
+ */
+void
+mibif_reset_hc_timer(void)
+{
+	u_int ticks;
+
+	if ((ticks = mibif_force_hc_update_interval) == 0) {
+		if (mibif_maxspeed <= 10000000) {
+			/* at 10Mbps overflow needs 3436 seconds */
+			ticks = 3000 * 100;	/* 50 minutes */
+		} else if (mibif_maxspeed <= 100000000) {
+			/* at 100Mbps overflow needs 343 seconds */
+			ticks = 300 * 100;	/* 5 minutes */
+		} else if (mibif_maxspeed < 650000000) {
+			/* at 622Mbps overflow needs 53 seconds */
+			ticks = 40 * 100;	/* 40 seconds */
+		} else if (mibif_maxspeed <= 1000000000) {
+			/* at 1Gbps overflow needs  34 seconds */
+			ticks = 20 * 100;	/* 20 seconds */
 		} else {
-			if (!(ifp->mib.ifmd_flags & IFF_UP))
-				link_trap(ifp, 0);
+			/* at 10Gbps overflow needs 3.4 seconds */
+			ticks = 100;		/* 1 seconds */
 		}
 	}
 
+	if (ticks == mibif_hc_update_interval)
+		return;
+
+	if (hc_update_timer != NULL) {
+		timer_stop(hc_update_timer);
+		hc_update_timer = NULL;
+	}
+	update_hc_counters(NULL);
+	if ((hc_update_timer = timer_start_repeat(ticks * 10, ticks * 10,
+	    update_hc_counters, NULL, module)) == NULL) {
+		syslog(LOG_ERR, "timer_start(%u): %m", ticks);
+		return;
+	}
+	mibif_hc_update_interval = ticks;
+}
+
+/*
+ * Fetch new MIB data.
+ */
+int
+mib_fetch_ifmib(struct mibif *ifp)
+{
+	int name[6];
+	size_t len;
+	void *newmib;
+	struct ifmibdata oldmib = ifp->mib;
+
+	if (fetch_generic_mib(ifp, &oldmib) == -1)
+		return (-1);
+
+	/*
+	 * Quoting RFC2863, 3.1.15: "... LinkUp and linkDown traps are
+	 * generated just after ifOperStatus leaves, or just before it
+	 * enters, the down state, respectively;"
+	 */
+	if (ifp->trap_enable && ifp->mib.ifmd_data.ifi_link_state !=
+	    oldmib.ifmd_data.ifi_link_state &&
+	    (ifp->mib.ifmd_data.ifi_link_state == LINK_STATE_DOWN ||
+	    oldmib.ifmd_data.ifi_link_state == LINK_STATE_DOWN))
+		link_trap(ifp, ifp->mib.ifmd_data.ifi_link_state ==
+		    LINK_STATE_UP ? 1 : 0);
+
 	ifp->flags &= ~(MIBIF_HIGHSPEED | MIBIF_VERYHIGHSPEED);
 	if (ifp->mib.ifmd_data.ifi_baudrate > 20000000) {
 		ifp->flags |= MIBIF_HIGHSPEED;
 		if (ifp->mib.ifmd_data.ifi_baudrate > 650000000)
 			ifp->flags |= MIBIF_VERYHIGHSPEED;
 	}
+	if (ifp->mib.ifmd_data.ifi_baudrate > mibif_maxspeed) {
+		mibif_maxspeed = ifp->mib.ifmd_data.ifi_baudrate;
+		mibif_reset_hc_timer();
+	}
 
 	/*
 	 * linkspecific MIB
 	 */
+	name[0] = CTL_NET;
+	name[1] = PF_LINK;
+	name[2] = NETLINK_GENERIC;
+	name[3] = IFMIB_IFDATA;
+	name[4] = ifp->sysindex;
 	name[5] = IFDATA_LINKSPECIFIC;
 	if (sysctl(name, 6, NULL, &len, NULL, 0) == -1) {
 		syslog(LOG_WARNING, "sysctl linkmib estimate (%s): %m",
@@ -518,6 +646,7 @@
 static void
 mibif_free(struct mibif *ifp)
 {
+	struct mibif *ifp1;
 	struct mibindexmap *map;
 	struct mibifa *ifa, *ifa1;
 	struct mibrcvaddr *rcv, *rcv1;
@@ -530,6 +659,18 @@
 	(void)mib_ifstack_delete(NULL, ifp);
 
 	TAILQ_REMOVE(&mibif_list, ifp, link);
+
+	/* if this was the fastest interface - recompute this */
+	if (ifp->mib.ifmd_data.ifi_baudrate == mibif_maxspeed) {
+		mibif_maxspeed = ifp->mib.ifmd_data.ifi_baudrate;
+		TAILQ_FOREACH(ifp1, &mibif_list, link)
+			if (ifp1->mib.ifmd_data.ifi_baudrate > mibif_maxspeed)
+				mibif_maxspeed =
+				    ifp1->mib.ifmd_data.ifi_baudrate;
+		mibif_reset_hc_timer();
+	}
+
+	free(ifp->private);
 	if (ifp->physaddr != NULL)
 		free(ifp->physaddr);
 	if (ifp->specmib != NULL)
@@ -588,6 +729,13 @@
 		return (NULL);
 	}
 	memset(ifp, 0, sizeof(*ifp));
+	if ((ifp->private = malloc(sizeof(struct mibif_private))) == NULL) {
+		syslog(LOG_WARNING, "%s: %m", __func__);
+		free(ifp);
+		return (NULL);
+	}
+	memset(ifp->private, 0, sizeof(struct mibif_private));
+
 	ifp->sysindex = sysindex;
 	strcpy(ifp->name, name);
 	strcpy(ifp->descr, name);
@@ -626,6 +774,7 @@
 		ifp->counter_disc = get_ticks();
 	}
 	ifp->index = map->ifindex;
+	ifp->mib.ifmd_data.ifi_link_state = LINK_STATE_UNKNOWN;
 
 	INSERT_OBJECT_INT(ifp, &mibif_list);
 	mib_if_number++;
@@ -1514,7 +1663,12 @@
 	   "The MIB module for managing IP and ICMP implementations, but "
 	   "excluding their management of IP routes.", module);
 
+	tcpmib_reg = or_register(&oid_tcpMIB,
+	   "The MIB module for managing TCP implementations.", module);
 
+	udpmib_reg = or_register(&oid_udpMIB,
+	   "The MIB module for managing UDP implementations.", module);
+
 	ipForward_reg = or_register(&oid_ipForward,
 	   "The MIB module for the display of CIDR multipath IP Routes.",
 	   module);
@@ -1570,6 +1724,8 @@
 	/* XXX free memory */
 
 	or_unregister(ipForward_reg);
+	or_unregister(udpmib_reg);
+	or_unregister(tcpmib_reg);
 	or_unregister(ipmib_reg);
 	or_unregister(ifmib_reg);
 
@@ -1631,19 +1787,3 @@
 	ifp->xnotify_data = NULL;
 	ifp->xnotify_mod = NULL;
 }
-
-
-/*
- * Get the MIB II ifIndex for the device with
- * the name passed as argument (ie "rl0")
- */
-u_int 
-mib2_getIfIndex(const char* dev_name){
-	struct mibindexmap *map;
-	
-	STAILQ_FOREACH(map, &mibindexmap_list, link)
-		if (strcmp(map->name, dev_name) == 0) {
-			return map->ifindex;
-		}
-	return 0;	
-}	

==== //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmp_mibII/mibII.h#3 (text+ko) ====

@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Begemot: bsnmp/snmp_mibII/mibII.h,v 1.15 2005/06/09 12:36:53 brandt_h Exp $
+ * $Begemot: bsnmp/snmp_mibII/mibII.h,v 1.16 2006/02/14 09:04:19 brandt_h Exp $
  *
  * Implementation of the interfaces and IP groups of MIB-II.
  */
@@ -56,7 +56,6 @@
 #include "snmp_mibII.h"
 #include "mibII_tree.h"
 
-
 /*
  * Interface list and flags.
  */
@@ -66,12 +65,19 @@
 	MIBIF_HIGHSPEED		= 0x0002,
 	MIBIF_VERYHIGHSPEED	= 0x0004,
 };
-#define hc_inoctets	mib.ifmd_data.ifi_ibytes
-#define hc_outoctets	mib.ifmd_data.ifi_obytes
-#define hc_omcasts	mib.ifmd_data.ifi_omcasts
-#define hc_opackets	mib.ifmd_data.ifi_opackets
-#define hc_imcasts	mib.ifmd_data.ifi_imcasts
-#define hc_ipackets	mib.ifmd_data.ifi_ipackets
+
+/*
+ * Private mibif data - hang off from the mibif.
+ */
+struct mibif_private {
+	uint64_t	hc_inoctets;
+	uint64_t	hc_outoctets;
+	uint64_t	hc_omcasts;
+	uint64_t	hc_opackets;
+	uint64_t	hc_imcasts;
+	uint64_t	hc_ipackets;
+};
+#define	MIBIF_PRIV(IFP) ((struct mibif_private *)((IFP)->private))
 
 /*
  * Interface addresses.
@@ -193,6 +199,18 @@
 /* info on system clocks */
 extern struct clockinfo clockinfo;
 
+/* baud rate of fastest interface */
+extern uint64_t mibif_maxspeed;
+
+/* user-forced update interval */
+extern u_int mibif_force_hc_update_interval;
+
+/* current update interval */
+extern u_int mibif_hc_update_interval;
+
+/* re-compute update interval */
+void mibif_reset_hc_timer(void);
+
 /* get interfaces and interface addresses. */
 void mib_fetch_interfaces(void);
 

==== //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmp_mibII/mibII_interfaces.c#3 (text+ko) ====

@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Begemot: bsnmp/snmp_mibII/mibII_interfaces.c,v 1.16 2005/11/02 12:07:40 brandt_h Exp $
+ * $Begemot: bsnmp/snmp_mibII/mibII_interfaces.c,v 1.17 2006/02/14 09:04:19 brandt_h Exp $
  *
  * Interfaces group.
  */
@@ -463,19 +463,20 @@
 	  case LEAF_ifHCInOctets:
 		if (!(ifp->flags & MIBIF_HIGHSPEED))
 			goto again;
-		value->v.counter64 = ifp->hc_inoctets;
+		value->v.counter64 = MIBIF_PRIV(ifp)->hc_inoctets;
 		break;
 
 	  case LEAF_ifHCInUcastPkts:
 		if (!(ifp->flags & (MIBIF_VERYHIGHSPEED|MIBIF_HIGHSPEED)))
 			goto again;
-		value->v.counter64 = ifp->hc_ipackets - ifp->hc_imcasts;
+		value->v.counter64 = MIBIF_PRIV(ifp)->hc_ipackets -
+		    MIBIF_PRIV(ifp)->hc_imcasts;
 		break;
 
 	  case LEAF_ifHCInMulticastPkts:
 		if (!(ifp->flags & (MIBIF_VERYHIGHSPEED|MIBIF_HIGHSPEED)))
 			goto again;
-		value->v.counter64 = ifp->hc_imcasts;
+		value->v.counter64 = MIBIF_PRIV(ifp)->hc_imcasts;
 		break;
 
 	  case LEAF_ifHCInBroadcastPkts:
@@ -487,19 +488,20 @@
 	  case LEAF_ifHCOutOctets:
 		if (!(ifp->flags & MIBIF_HIGHSPEED))
 			goto again;
-		value->v.counter64 = ifp->hc_outoctets;
+		value->v.counter64 = MIBIF_PRIV(ifp)->hc_outoctets;
 		break;
 
 	  case LEAF_ifHCOutUcastPkts:
 		if (!(ifp->flags & (MIBIF_VERYHIGHSPEED|MIBIF_HIGHSPEED)))
 			goto again;
-		value->v.counter64 = ifp->hc_opackets - ifp->hc_omcasts;
+		value->v.counter64 = MIBIF_PRIV(ifp)->hc_opackets -
+		    MIBIF_PRIV(ifp)->hc_omcasts;
 		break;
 
 	  case LEAF_ifHCOutMulticastPkts:
 		if (!(ifp->flags & (MIBIF_VERYHIGHSPEED|MIBIF_HIGHSPEED)))
 			goto again;
-		value->v.counter64 = ifp->hc_omcasts;
+		value->v.counter64 = MIBIF_PRIV(ifp)->hc_omcasts;
 		break;
 
 	  case LEAF_ifHCOutBroadcastPkts:

==== //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmp_mibII/mibII_route.c#3 (text+ko) ====

@@ -26,11 +26,18 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Begemot: bsnmp/snmp_mibII/mibII_route.c,v 1.7 2005/06/09 12:36:53 brandt_h Exp $
+ * $Begemot: bsnmp/snmp_mibII/mibII_route.c,v 1.9 2005/10/06 07:15:00 brandt_h Exp $
  *
  * Routing table
  */
+#include "support.h"
+
+#ifdef HAVE_SYS_TREE_H
 #include <sys/tree.h>
+#else
+#include "tree.h"
+#endif
+
 #include "mibII.h"
 #include "mibII_oid.h"
 

==== //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmp_mibII/mibII_tree.def#6 (text+ko) ====

@@ -26,7 +26,7 @@
 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 #
-# $Begemot: bsnmp/snmp_mibII/mibII_tree.def,v 1.12 2004/08/06 08:47:05 brandt Exp $
+# $Begemot: bsnmp/snmp_mibII/mibII_tree.def,v 1.13 2006/02/14 09:04:19 brandt_h Exp $
 #
 # Definition of the standard interfaces and ip trees.
 #
@@ -148,6 +148,41 @@
         (25 icmpOutAddrMasks COUNTER op_icmpstat GET)
         (26 icmpOutAddrMaskReps COUNTER op_icmpstat GET)
       )
+      (6 tcp
+        (1 tcpRtoAlgorithm INTEGER op_tcp GET)
+        (2 tcpRtoMin INTEGER32 op_tcp GET)
+        (3 tcpRtoMax INTEGER32 op_tcp GET)
+        (4 tcpMaxConn INTEGER32 op_tcp GET)
+        (5 tcpActiveOpens COUNTER op_tcp GET)
+        (6 tcpPassiveOpens COUNTER op_tcp GET)
+        (7 tcpAttemptFails COUNTER op_tcp GET)
+        (8 tcpEstabResets COUNTER op_tcp GET)
+        (9 tcpCurrEstab GAUGE op_tcp GET)
+        (10 tcpInSegs COUNTER op_tcp GET)
+        (11 tcpOutSegs COUNTER op_tcp GET)
+        (12 tcpRetransSegs COUNTER op_tcp GET)
+        (13 tcpConnTable
+          (1 tcpConnEntry : IPADDRESS INTEGER IPADDRESS INTEGER op_tcpconn
+            (1 tcpConnState INTEGER GET)
+            (2 tcpConnLocalAddress IPADDRESS GET)
+            (3 tcpConnLocalPort INTEGER GET)
+            (4 tcpConnRemAddress IPADDRESS GET)
+            (5 tcpConnRemPort INTEGER GET)
+        ))
+        (14 tcpInErrs COUNTER op_tcp GET)
+        (15 tcpOutRsts COUNTER op_tcp)		# don't know
+      )
+      (7 udp
+        (1 udpInDatagrams COUNTER op_udp GET)
+        (2 udpNoPorts COUNTER op_udp GET)
+        (3 udpInErrors COUNTER op_udp GET)
+        (4 udpOutDatagrams COUNTER op_udp GET)
+        (5 udpTable
+          (1 udpEntry : IPADDRESS INTEGER op_udptable
+            (1 udpLocalAddress IPADDRESS GET)
+            (2 udpLocalPort INTEGER GET)
+        ))
+      )
       (31 ifMIB
         (1 ifMIBObjects
           (1 ifXTable
@@ -190,7 +225,28 @@
       )
       (48 ipMIB
       )
+      (49 tcpMIB
+      )
+      (50 udpMIB
+      )
   ))
+  (4 private
+    (1 enterprises
+      (12325 fokus
+        (1 begemot
+	  (3 begemotIp
+	    (1 begemotIpObjects
+	      (1 begemotMib2
+		(1 begemotIfMaxspeed COUNTER64 op_begemot_mibII GET)
+		(2 begemotIfPoll TIMETICKS op_begemot_mibII GET)
+		(3 begemotIfForcePoll TIMETICKS op_begemot_mibII GET SET)
+	      )
+	    )
+	  )
+        )
+      )
+    )
+  )
   (6 snmpV2
     (3 snmpModules
       (1 snmpMIB

==== //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmp_mibII/snmp_mibII.h#2 (text+ko) ====

@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Begemot: bsnmp/snmp_mibII/snmp_mibII.h,v 1.17 2005/05/23 09:03:43 brandt_h Exp $
+ * $Begemot: bsnmp/snmp_mibII/snmp_mibII.h,v 1.18 2006/02/14 09:04:19 brandt_h Exp $
  *
  * Implementation of the interfaces and IP groups of MIB-II.
  */
@@ -79,6 +79,9 @@
 
 	/* to be set by ifType specific modules. This is ifSpecific. */
 	struct asn_oid	spec_oid;
+
+	/* private data - don't touch */
+	void		*private;
 };
 
 /*

==== //depot/projects/soc2005/bsnmp/contrib/bsnmp/snmp_ntp/snmp_ntp.c#3 (text+ko) ====

@@ -27,7 +27,7 @@
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $Begemot: bsnmp/snmp_ntp/snmp_ntp.c,v 1.7 2005/10/04 11:21:36 brandt_h Exp $
+ * $Begemot: bsnmp/snmp_ntp/snmp_ntp.c,v 1.9 2005/10/06 07:15:01 brandt_h Exp $
  *
  * NTP interface for SNMPd.
  */
@@ -51,20 +51,11 @@
 #include <syslog.h>
 #include <unistd.h>
 
+#include "support.h"
 #include "snmpmod.h"
 #include "ntp_tree.h"
 #include "ntp_oid.h"
 
-#if !defined(INT32_MIN)
-#define	INT32_MIN	(-0x7fffffff-1)
-#endif
-#if !defined(INT32_MAX)
-#define	INT32_MAX	(0x7fffffff)
-#endif
-#if !defined(UINT32_MAX)
-#define	UINT32_MAX	(0xffffffff)
-#endif
-
 #define	NTPC_MAX	576
 #define	NTPC_VERSION	3

>>> TRUNCATED FOR MAIL (1000 lines) <<<



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200603232345.k2NNjJFc021110>