Subject: pr number 6389 (gnome-core modemlights)
To: None <netbsd-bugs@netbsd.org>
From: Clifford Wright <cliff@snipe444.org>
List: netbsd-bugs
Date: 11/01/1998 18:28:07
In reference to pr 6389 (package gnome-core) I have a better patch than the
one which I had given. This will allow the modemlights applet to compile and 
work under NetBSD 1.3.2.

--- modemlights.c.orig	Mon Sep 21 12:57:09 1998
+++ modemlights.c	Sun Nov  1 18:18:13 1998
@@ -18,6 +18,7 @@
 
 static unsigned long *isdn_stats = NULL;
 #endif
+#include <net/if_ppp.h>
 
 gint UPDATE_DELAY = 5;		/* status lights update interval in Hz (1 - 20) */
 gchar *lock_file;		/* the modem lock file */
@@ -218,21 +219,28 @@
 
 static int get_modem_stats(int *in, int *out)
 {
+#ifndef __NetBSD__
 	struct 	ifreq ifreq;
 	struct 	ppp_stats stats;
 
 	memset(&ifreq, 0, sizeof(ifreq));
-#ifndef __FreeBSD__
-	strncpy(ifreq.ifr_ifrn.ifrn_name, device_name, IFNAMSIZ);
 #else
+	struct ifpppstatsreq ifreq;
+#endif
+
+#if (defined(BSD) && BSD >= 199506) || defined(__NetBSD__)
 	strncpy(ifreq.ifr_name, device_name, IFNAMSIZ);
-#endif /* __FreeBSD__ */
+#else
+	strncpy(ifreq.ifr_ifrn.ifrn_name, device_name, IFNAMSIZ);
+#endif /* 4.4-BSD derived */
+#ifndef __NetBSD__
 	ifreq.ifr_ifru.ifru_data = (caddr_t)&stats;
-#ifndef __FreeBSD__
-	if ((ioctl(ip_socket,SIOCDEVPRIVATE,(caddr_t)&ifreq) < 0))
+#endif
+#if (defined(BSD) && BSD >= 199506) || defined(__NetBSD__)
+	if ((ioctl(ip_socket,SIOCGPPPSTATS,(caddr_t)&ifreq) < 0))
 #else
-		if ((ioctl(ip_socket,SIOCGPPPSTATS,(caddr_t)&ifreq) < 0))
-#endif /* __FreeBSD__ */
+	if ((ioctl(ip_socket,SIOCDEVPRIVATE,(caddr_t)&ifreq) < 0))
+#endif /* 4.4-BSD derived */
 			{
 				/* failure means ppp is not up */
 				*in = *out = 0;
@@ -240,8 +248,13 @@
 			}
 		else
 			{
+#ifndef __NetBSD__
 				*in = stats.p.ppp_ibytes;
 				*out = stats.p.ppp_obytes;
+#else
+				*in = ifreq.stats.p.ppp_ibytes;
+				*out = ifreq.stats.p.ppp_obytes;
+#endif
 				return TRUE;
 			}
 }