]> Pileus Git - ~andy/fetchmail/commitdiff
Fix interface option.
authorEric S. Raymond <esr@thyrsus.com>
Mon, 20 Oct 1997 15:01:26 +0000 (15:01 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 20 Oct 1997 15:01:26 +0000 (15:01 -0000)
svn path=/trunk/; revision=1523

NEWS
interface.c

diff --git a/NEWS b/NEWS
index d6fdb521c593e9db06d18f6f06586baec8a26685..bb18a43a4aaf7ab553f3385df8cfe9737e8052c4 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@ fetchmail-4.3.2 ()
 * More slow-UIDL patches from Wolfgang Wander.
 * Yet another attempt to fix IMAP-K4.  This one, my beta-testers say, works.
 * Only re-poll on actual dispatches (not just fetches).
+* kwrohrer's patch for interface option on newer Linux kernels.
 
 There are 262 people on fetchmail-friends and 54 on fetchmail-announce.
 
index 266cf6ba7ff8ec2dc37ded7c5b0bd4a708ca40df..370d078d0ad6c6ce833a58d08c6e46cf91237083 100644 (file)
@@ -48,6 +48,7 @@ static int _get_ifinfo_(int socket_fd, FILE *stats_file, const char *ifname,
        struct ifreq request;
        char *cp, buffer[256];
        int found = 0;
+       int counts[4];
 
        /* initialize result */
        memset((char *) ifinfo, 0, sizeof(ifinfo_t));
@@ -58,8 +59,17 @@ static int _get_ifinfo_(int socket_fd, FILE *stats_file, const char *ifname,
                if (!strncmp(cp, ifname, namelen) &&
                                cp[namelen] == ':') {
                        cp += namelen + 1;
-                       sscanf(cp, "%d %*d %*d %*d %*d %d %*d %*d %*d %*d %*d",
-                               &ifinfo->rx_packets, &ifinfo->tx_packets);
+                       if (sscanf(cp, "%d %d %*d %*d %*d %d %*d %d %*d %*d"
+                              " %*d %*d %d",counts, counts+1, counts+2, 
+                                  counts+3,&found)>4) { /* found = dummy */
+                               /* newer kernel with byte counts */
+                               ifinfo->rx_packets=counts[1];
+                               ifinfo->tx_packets=counts[3];
+                       } else {
+                               /* older kernel, no byte counts */
+                               ifinfo->rx_packets=counts[0];
+                               ifinfo->tx_packets=counts[2];
+                       }
                         found = 1;
                }
        }