Subject: pkg/26001: wm/icewm NetStatus taskbar app does not work for NetBSD (patch included)
To: None <gnats-bugs@gnats.netbsd.org>
From: Iain Hibbert <plunky@rya-online.net>
List: pkgsrc-bugs
Date: 06/21/2004 20:49:26
>Number:         26001
>Category:       pkg
>Synopsis:       wm/icewm NetStatus taskbar app does not work for NetBSD
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 21 20:27:03 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Iain Hibbert
>Release:        NetBSD 1.6.1
>Organization:
	
>Environment:
	
	
System: NetBSD galant 1.6.1 NetBSD 1.6.1 (GALANT) #8: Tue Jun 1 19:54:19 BST 2004 plunky@galant:/usr/home/plunky/src/sys/arch/i386/compile/GALANT i386
Architecture: i386
Machine: i386
>Description:
IceWM has a few features that do not work on NetBSD because its written by Linux geeks. This
is one of those cases, the taskbar NetStatus app does not work on NetBSD because its not
done in the right way.
	
>How-To-Repeat:
Just build it and use it.
	
>Fix:
	
The patch below creates patch/patch-ae and patches/patch-af which add the required functionality
and turn on the application for NetBSD and lo, it works!

--- /dev/null	Mon Jun 21 20:36:28 2004
+++ patches/patch-ae	Sun Jun 20 19:37:59 2004
@@ -0,0 +1,24 @@
+$NetBSD: patch-ae,v 1.0 2004/06/20 17:04:45 plunky $
+
+Turn on HAVE_NET_STATUS for NetBSD
+ 
+--- src/apppstatus.h.orig	Sat Sep 27 08:54:45 2003
++++ src/apppstatus.h	Sun Jun 20 18:19:04 2004
+@@ -9,7 +9,7 @@
+ #define NETSTATUS_H
+ 
+ #ifdef CONFIG_APPLET_NET_STATUS
+-#if defined(linux) || defined(__FreeBSD__)
++#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__)
+ 
+ #define HAVE_NET_STATUS 1
+ 
+@@ -61,7 +61,7 @@
+ };
+ 
+ 
+-#else // linux || __FreeBSD__
++#else // linux || __FreeBSD__ || __NetBSD__
+ #undef CONFIG_APPLET_NET_STATUS
+ #endif
+ #endif // CONFIG_APPLET_NET_STATUS
--- /dev/null	Mon Jun 21 20:36:28 2004
+++ patches/patch-af	Sun Jun 20 20:46:11 2004
@@ -0,0 +1,65 @@
+$NetBSD: patch-af,v 1.0 2004/06/20 20:03:00 plunky $
+
+Add some code for NetBSD to
+   a) check if an interface is up, and
+   b) get the in/out character count for that interface
+
+--- src/apppstatus.cc.orig	Sat Sep 27 08:54:45 2003
++++ src/apppstatus.cc	Sun Jun 20 20:45:26 2004
+@@ -363,6 +363,26 @@
+         return isUpIsdn();
+ #endif
+ 
++#ifdef __NetBSD__
++    struct ifreq ifr;
++
++    if (fNetDev == 0)
++        return false;
++
++    int s = socket(AF_INET, SOCK_DGRAM, 0);
++
++    if( s != -1 ) {
++	strncpy(ifr.ifr_name, fNetDev, sizeof(ifr.ifr_name));
++	if( ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) != -1 ) {
++	    if( ifr.ifr_flags & IFF_UP ) {
++		close(s);
++		return true;
++	    }
++	}
++	close(s);
++    }
++    return false;
++#else
+     char buffer[32 * sizeof(struct ifreq)];
+     struct ifconf ifc;
+     struct ifreq *ifr;
+@@ -395,6 +415,7 @@
+ 
+     close(s);
+     return false;
++#endif // __NetBSD__
+ #endif // if 0
+ }
+ 
+@@ -522,6 +543,21 @@
+         }
+     }
+ #endif //FreeBSD
++#ifdef __NetBSD__
++    struct ifdatareq ifdr;
++    struct if_data * const ifi = &ifdr.ifdr_data;
++    int s;
++    
++    s = socket(AF_INET, SOCK_DGRAM, 0);
++    if( s != -1 ) {
++	strncpy(ifdr.ifdr_name, fNetDev, sizeof(ifdr.ifdr_name));
++	if (ioctl(s, SIOCGIFDATA, &ifdr) != -1) {
++	    cur_ibytes = ifi->ifi_ibytes;
++	    cur_obytes = ifi->ifi_obytes;
++	}
++	close(s);
++    }
++#endif //__NetBSD__
+ 
+     // correct the values and look for overflows
+     //msg("w/o corrections: ibytes: %lld, prev_ibytes; %lld, offset: %lld", cur_ibytes, prev_ibytes, offset_ibytes);
>Release-Note:
>Audit-Trail:
>Unformatted: