Subject: wiconfig vs non-wifi interfaces
To: None <tech-net@netbsd.org>
From: Stephen Borrill <netbsd@precedence.co.uk>
List: tech-net
Date: 06/07/2007 17:01:50
PR 23774 which was committed as rev. 1.39 of wiconfig.c broke the output 
of wiconfig on non-wifi interfaces. Prior to this, you got exit status 1 
and a short "Inappropriate ioctl for device" message. With this change you 
get such a warning for every value attempted to be read and exit status 0.

I found wiconfig as useful a tool as any to differentiate between wireless 
and non-wireless interfaces. A patch is below. I've not commited this yet 
as I thought I'd ask if there was a better value wi_type to use than 
WI_RID_WEP_AVAIL, i.e. can we assume that WI_RID_WEP_AVAIL will always be 
available on a wireless interface. I picked WI_RID_WEP_AVAIL simply 
because it was being used already.

Index: wiconfig.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/wiconfig/wiconfig.c,v
retrieving revision 1.39
diff -u -r1.39 wiconfig.c
--- wiconfig.c	7 Oct 2006 00:47:18 -0000	1.39
+++ wiconfig.c	7 Jun 2007 15:55:18 -0000
@@ -650,7 +650,14 @@
  	wreq.wi_len = WI_MAX_DATALEN;
  	wreq.wi_type = WI_RID_WEP_AVAIL;

-	wi_getval(iface, &wreq);
+	/* 
+	 * If we get an error from this, assume interface isn't
+	 * wireless and bail. wi_getval() will have already given the
+	 * user an error message
+	 */
+	if(wi_getval(iface, &wreq))
+		exit(1);
+
  	has_wep = le16toh(wreq.wi_val[0]);

  	w = wi_table;

-- 
Stephen