]> Pileus Git - ~andy/fetchmail/commitdiff
A step towards functioning with 2.2.
authorEric S. Raymond <esr@thyrsus.com>
Sat, 30 Jan 1999 23:07:20 +0000 (23:07 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Sat, 30 Jan 1999 23:07:20 +0000 (23:07 -0000)
svn path=/trunk/; revision=2357

interface.c

index ccccd505c77ef8ec40cd730fe742f61458e4e07c..9c01a0e99cebb6303808e002b3ebcd36b3216376 100644 (file)
@@ -41,6 +41,14 @@ struct interface_pair_s {
        struct in_addr interface_mask;
 } *interface_pair;
 
+#ifdef linux22
+/* Linux 2.2 /proc/net/dev format -- transmit packet count in 10th field */
+#define PROCNETDEV     "%d %d %*d %*d %*d %d %*d %*d %*d %*d %d %*d %d"
+#else
+/* pre-linux-2.2 format -- transmit packet count in 8th field */
+#define PROCNETDEV     "%d %d %*d %*d %*d %d %*d %d %*d %*d %*d %*d %d"
+#endif
+
 static int _get_ifinfo_(int socket_fd, FILE *stats_file, const char *ifname,
                ifinfo_t *ifinfo)
 /* get active network interface information - return non-zero upon success */
@@ -60,8 +68,8 @@ static int _get_ifinfo_(int socket_fd, FILE *stats_file, const char *ifname,
                if (!strncmp(cp, ifname, namelen) &&
                                cp[namelen] == ':') {
                        cp += namelen + 1;
-                       if (sscanf(cp, "%d %d %*d %*d %*d %d %*d %d %*d %*d"
-                              " %*d %*d %d",counts, counts+1, counts+2, 
+                       if (sscanf(cp, PROCNETDEV,
+                                  counts, counts+1, counts+2, 
                                   counts+3,&found)>4) { /* found = dummy */
                                /* newer kernel with byte counts */
                                ifinfo->rx_packets=counts[1];
@@ -264,6 +272,12 @@ int interface_approve(struct hostdata *hp)
                return(FALSE);
        }
 
+#ifdef ACTIVITY_DEBUG
+       error(0, 0, _("activity on %s was %d, is %d"),
+             hp->monitor, hp->monitor_io,
+             ifinfo.rx_packets + ifinfo.tx_packets);
+#endif
+
        return(TRUE);
 }
 #endif /* defined(linux) && !defined(INET6) */