make ipwcontrol work

Andreas Hauser andy at splashground.de
Tue Jun 28 03:29:36 PDT 2005


Hoi,

something like that


Index: usr.sbin/ipwcontrol/ipwcontrol.c
===================================================================
RCS file: /home/dcvs/src/usr.sbin/ipwcontrol/ipwcontrol.c,v
retrieving revision 1.1
diff -u -p -r1.1 ipwcontrol.c
--- usr.sbin/ipwcontrol/ipwcontrol.c	6 Mar 2005 18:25:14 -0000	1.1
+++ usr.sbin/ipwcontrol/ipwcontrol.c	28 Jun 2005 12:20:49 -0000
@@ -55,8 +55,8 @@ static void usage(void);
 static int do_req(const char *, unsigned long, void *);
 static void load_firmware(const char *, const char *);
 static void kill_firmware(const char *);
-static void get_radio_state(void);
-static void get_statistics(void);
+static void get_radio_state(const char *);
+static void get_statistics(const char *);
 
 int
 main(int argc, char **argv)
@@ -91,7 +91,7 @@ main(int argc, char **argv)
 			return EX_OK;
 
 		case 'r':
-			get_radio_state();
+			get_radio_state(iface);
 			return EX_OK;
 
 		default:
@@ -99,7 +99,7 @@ main(int argc, char **argv)
 		}
 	}
 
-	get_statistics();
+	get_statistics(iface);
 
 	return EX_OK;
 }
@@ -169,12 +169,14 @@ kill_firmware(const char *iface)
 }
 
 static void
-get_radio_state()
+get_radio_state(const char *iface)
 {
 	int radio, len;
+        char sysctl_name[24];
 
+        sprintf(sysctl_name,"hw.%s.radio", __DECONST(char *,iface));
 	len = sizeof radio;
-	if (sysctlbyname("dev.ipw.0.radio", &radio, &len, NULL, 0) == -1)
+	if (sysctlbyname(sysctl_name, &radio, &len, NULL, 0) == -1)
 		err(EX_OSERR, "Could not get radio transmitter state");
 
 	(void)printf("Radio is %s\n", radio ? "ON" : "OFF");
@@ -369,14 +371,16 @@ static const struct statistic tbl[] = {
 };
 
 static void
-get_statistics()
+get_statistics(const char *iface)
 {
 	static u_int32_t stats[256];
 	const struct statistic *st;
 	int len;
+        char sysctl_name[24];
 
+        sprintf(sysctl_name,"hw.%s.stats", __DECONST(char *,iface));
 	len = sizeof stats;
-	if (sysctlbyname("dev.ipw.0.stats", stats, &len, NULL, 0) == -1)
+	if (sysctlbyname(sysctl_name, stats, &len, NULL, 0) == -1)
 		err(EX_OSERR, "Can't retrieve statistics");
 
 	for (st = tbl; st->index != 0; st++) {





More information about the Submit mailing list