From owner-svn-src-all@freebsd.org Sun Aug 30 21:54:50 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 05A249C69B8; Sun, 30 Aug 2015 21:54:50 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EA7561D61; Sun, 30 Aug 2015 21:54:49 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7ULsnHw070518; Sun, 30 Aug 2015 21:54:49 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7ULsmY9070510; Sun, 30 Aug 2015 21:54:48 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201508302154.t7ULsmY9070510@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Sun, 30 Aug 2015 21:54:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r287313 - head/tools/tools/iwn/iwnstats X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Aug 2015 21:54:50 -0000 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 #include #include +#include #include #include #include @@ -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); }