This is where I'm going with fwcontrol

Dieter freebsd at sopwith.solgatos.com
Fri Aug 29 16:28:33 UTC 2008


I looked at the changes NetBSD made to fwcontrol.c
with the idea of tweaking FreeBSD's version so it would
compile on both OSes.  Below is a patch that might be enough.
They made more changes than this.  Some are clearly not essential
(whitespace, putting the usage message into alphabetical order, ...),
some I'm not sure about so I left them out for now.  The full set
of changes they did can be viewed by diffing FreeBSD cvs 1.23
with NetBSD cvs 1.7.  It still compiles fine on FreeBSD 7.0 amd64,
(and the getprogname() thing works) I haven't tried NetBSD yet.

===================================================================
RCS file: RCS/fwcontrol.c,v
retrieving revision 1.2.2.2
diff -u -r1.2.2.2 fwcontrol.c
--- fwcontrol.c	2008/08/29 15:50:16	1.2.2.2
+++ fwcontrol.c	2008/08/29 16:00:48
@@ -32,8 +32,10 @@
  * SUCH DAMAGE.
  */
 
+#if defined(__FreeBSD__)
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/usr.sbin/fwcontrol/fwcontrol.c,v 1.23.2.1 2008/05/02 06:15:58 simokawa Exp $");
+#endif
 
 #include <sys/param.h>
 #include <sys/malloc.h>
@@ -42,11 +44,22 @@
 #include <sys/socket.h>
 #include <sys/ioctl.h>
 #include <sys/errno.h>
+#if defined(__FreeBSD__)
 #include <sys/eui64.h>
 #include <dev/firewire/firewire.h>
 #include <dev/firewire/iec13213.h>
 #include <dev/firewire/fwphyreg.h>
 #include <dev/firewire/iec68113.h>
+#elif defined(__NetBSD__)
+#include "eui64.h"
+#include <dev/ieee1394/firewire.h>
+#include <dev/ieee1394/iec13213.h>
+#include <dev/ieee1394/fwphyreg.h>
+#include <dev/ieee1394/iec68113.h>
+#else
+#warning "You need to add support for your OS"
+#endif
+
 
 #include <netinet/in.h>
 #include <fcntl.h>
@@ -66,7 +79,7 @@
 usage(void)
 {
 	fprintf(stderr,
-		"fwcontrol [-u bus_num] [-prt] [-c node] [-d node] [-o node] [-s node]\n"
+		"%s [-u bus_num] [-prt] [-c node] [-d node] [-o node] [-s node]\n"
 		"\t  [-l file] [-g gap_count] [-f force_root ] [-b pri_req]\n"
 		"\t  [-M mode] [-R filename] [-S filename] [-m EUI64 | hostname]\n"
 		"\t-u: specify bus number\n"
@@ -84,7 +97,8 @@
 		"\t-M: specify dv or mpeg\n"
 		"\t-R: Receive DV or MPEG TS stream\n"
 		"\t-S: Send DV stream\n"
-		"\t-m: set fwmem target\n");
+		"\t-m: set fwmem target\n"
+		, getprogname() );
 	exit(EX_USAGE);
 }
 
@@ -981,8 +995,16 @@
 	if (set_fwmem_target) {
 		eui.hi = ntohl(*(u_int32_t*)&(target.octet[0]));
 		eui.lo = ntohl(*(u_int32_t*)&(target.octet[4]));
+#if defined(__FreeBSD__)
 		sysctl_set_int("hw.firewire.fwmem.eui64_hi", eui.hi);
 		sysctl_set_int("hw.firewire.fwmem.eui64_lo", eui.lo);
+#elif defined(__NetBSD__)
+		sysctl_set_int("hw.fwmem.eui64_hi", eui.hi);
+		sysctl_set_int("hw.fwmem.eui64_lo", eui.lo);
+#else
+#warning "You need to add support for your OS"
+#endif
+
 	}
 
 	/*


More information about the freebsd-firewire mailing list