Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Aug 2015 21:54:48 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r287313 - head/tools/tools/iwn/iwnstats
Message-ID:  <201508302154.t7ULsmY9070510@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: adrian
Date: Sun Aug 30 21:54:47 2015
New Revision: 287313
URL: https://svnweb.freebsd.org/changeset/base/287313

Log:
  Convert this over to use the new cdev based ioctl path.

Modified:
  head/tools/tools/iwn/iwnstats/Makefile
  head/tools/tools/iwn/iwnstats/iwn_ioctl.c
  head/tools/tools/iwn/iwnstats/iwn_ioctl.h
  head/tools/tools/iwn/iwnstats/iwnstats.h
  head/tools/tools/iwn/iwnstats/main.c

Modified: head/tools/tools/iwn/iwnstats/Makefile
==============================================================================
--- head/tools/tools/iwn/iwnstats/Makefile	Sun Aug 30 21:54:33 2015	(r287312)
+++ head/tools/tools/iwn/iwnstats/Makefile	Sun Aug 30 21:54:47 2015	(r287313)
@@ -9,6 +9,8 @@ MAN=
 CFLAGS+=-I${.CURDIR}/../../../../sys/dev/iwn/
 CFLAGS+=-I${.CURDIR}/../../../../sys/
 
+CFLAGS+=	-g -ggdb -O0
+
 PROG=	iwnstats
 
 # Because of a clang preprocessor parser limitation causing this

Modified: head/tools/tools/iwn/iwnstats/iwn_ioctl.c
==============================================================================
--- head/tools/tools/iwn/iwnstats/iwn_ioctl.c	Sun Aug 30 21:54:33 2015	(r287312)
+++ head/tools/tools/iwn/iwnstats/iwn_ioctl.c	Sun Aug 30 21:54:47 2015	(r287313)
@@ -63,28 +63,24 @@
 #include "iwn_ioctl.h"
 
 void
-iwn_setifname(struct iwnstats *is, const char *ifname)
-{
-
-	strncpy(is->ifr.ifr_name, ifname, sizeof (is->ifr.ifr_name));
-}
-
-void
 iwn_zerostats(struct iwnstats *is)
 {
 
-	if (ioctl(is->s, SIOCZIWNSTATS, &is->ifr) < 0)
-		err(-1, "ioctl: %s", is->ifr.ifr_name);
+	if (ioctl(is->s, SIOCZIWNSTATS, NULL) < 0)
+		err(-1, "ioctl");
 }
 
 int
 iwn_collect(struct iwnstats *is)
 {
 	int err;
+	struct iwn_ioctl_data d;
 
-	is->ifr.ifr_data = (caddr_t) &is->st;
-	err = ioctl(is->s, SIOCGIWNSTATS, &is->ifr);
+	printf("st: %p\n", &is->st);
+	d.dst_addr = &is->st;
+	d.dst_len = sizeof(is->st);
+	err = ioctl(is->s, SIOCGIWNSTATS, (caddr_t) &d);
 	if (err < 0)
-		warn("ioctl: %s", is->ifr.ifr_name);
+		warn("ioctl");
 	return (err);
 }

Modified: head/tools/tools/iwn/iwnstats/iwn_ioctl.h
==============================================================================
--- head/tools/tools/iwn/iwnstats/iwn_ioctl.h	Sun Aug 30 21:54:33 2015	(r287312)
+++ head/tools/tools/iwn/iwnstats/iwn_ioctl.h	Sun Aug 30 21:54:47 2015	(r287313)
@@ -31,7 +31,6 @@
 #ifndef	__IWN_IOCTL_H__
 #define	__IWN_IOCTL_H__
 
-extern	void iwn_setifname(struct iwnstats *is, const char *ifname);
 extern	void iwn_zerostats(struct iwnstats *is);
 extern	int iwn_collect(struct iwnstats *is);
 

Modified: head/tools/tools/iwn/iwnstats/iwnstats.h
==============================================================================
--- head/tools/tools/iwn/iwnstats/iwnstats.h	Sun Aug 30 21:54:33 2015	(r287312)
+++ head/tools/tools/iwn/iwnstats/iwnstats.h	Sun Aug 30 21:54:47 2015	(r287313)
@@ -33,7 +33,6 @@
 
 struct iwnstats {
 	int s;
-	struct ifreq ifr;
 	struct iwn_stats st;
 };
 

Modified: head/tools/tools/iwn/iwnstats/main.c
==============================================================================
--- head/tools/tools/iwn/iwnstats/main.c	Sun Aug 30 21:54:33 2015	(r287312)
+++ head/tools/tools/iwn/iwnstats/main.c	Sun Aug 30 21:54:47 2015	(r287313)
@@ -33,6 +33,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <signal.h>
+#include <fcntl.h>
 #include <unistd.h>
 #include <string.h>
 #include <err.h>
@@ -50,22 +51,23 @@
 #include "iwnstats.h"
 #include "iwn_ioctl.h"
 
-#define	IWN_DEFAULT_IF		"wlan0"
+#define	IWN_DEFAULT_IF		"iwn0"
 
 static struct iwnstats *
 iwnstats_new(const char *ifname)
 {
 	struct iwnstats *is;
+	char buf[128];
 
 	is = calloc(1, sizeof(struct iwnstats));
 	if (is == NULL)
 		return (NULL);
 
-	is->s = socket(AF_INET, SOCK_DGRAM, 0);
+	snprintf(buf, sizeof(buf), "/dev/%s", ifname);
+	is->s = open(buf, O_RDWR);
 	if (is->s < 0)
-		err(1, "socket");
+		err(1, "open");
 
-	iwn_setifname(is, ifname);
 	return (is);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201508302154.t7ULsmY9070510>