summaryrefslogtreecommitdiff
path: root/net/net-snmp/patches/patch-ap
blob: bd11de734394a2ae2a6ad9f13259e1dc1771250e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
$NetBSD: patch-ap,v 1.1 2009/03/10 18:30:44 apb Exp $

Some systems define ifnet.if_lastchange as struct timespec (with a
tv_nsec field measured in nanoseconds), while other systems define it
as struct timeval (with a tv_usec field measured in microseconds).
Both variants have a tv_sec field for integer seconds.

--- agent/mibgroup/mibII/interfaces.c.orig	2008-06-05 23:11:53.000000000 +0200
+++ agent/mibgroup/mibII/interfaces.c
@@ -830,15 +830,25 @@ var_ifEntry(struct variable *vp,
          * * this is fixed, thus the 199607 comparison.
          */
         if (ifnet.if_lastchange.tv_sec == 0 &&
-            ifnet.if_lastchange.tv_usec == 0)
+#if STRUCT_IFNET_HAS_IF_LASTCHANGE_TV_NSEC
+            ifnet.if_lastchange.tv_nsec == 0
+#else
+            ifnet.if_lastchange.tv_usec == 0
+#endif
+	)
             long_return = 0;
         else if (ifnet.if_lastchange.tv_sec < starttime.tv_sec)
             long_return = 0;
         else {
             long_return = (u_long)
                 ((ifnet.if_lastchange.tv_sec - starttime.tv_sec) * 100
-                 + (ifnet.if_lastchange.tv_usec -
-                    starttime.tv_usec) / 10000);
+                 + (
+#if STRUCT_IFNET_HAS_IF_LASTCHANGE_TV_NSEC
+		    ifnet.if_lastchange.tv_nsec / 1000
+#else
+		    ifnet.if_lastchange.tv_usec
+#endif
+		    - starttime.tv_usec) / 10000);
         }
 #else
 #if NETSNMP_NO_DUMMY_VALUES