From 07075ccdf646e51ad8bc00755a270ca8e6bb4d66 Mon Sep 17 00:00:00 2001 From: adrian Date: Sun, 30 Aug 2015 21:54:47 +0000 Subject: Convert this over to use the new cdev based ioctl path. --- tools/tools/iwn/iwnstats/Makefile | 2 ++ tools/tools/iwn/iwnstats/iwn_ioctl.c | 20 ++++++++------------ tools/tools/iwn/iwnstats/iwn_ioctl.h | 1 - tools/tools/iwn/iwnstats/iwnstats.h | 1 - tools/tools/iwn/iwnstats/main.c | 10 ++++++---- 5 files changed, 16 insertions(+), 18 deletions(-) diff --git a/tools/tools/iwn/iwnstats/Makefile b/tools/tools/iwn/iwnstats/Makefile index b35530c..6813832 100644 --- a/tools/tools/iwn/iwnstats/Makefile +++ b/tools/tools/iwn/iwnstats/Makefile @@ -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 diff --git a/tools/tools/iwn/iwnstats/iwn_ioctl.c b/tools/tools/iwn/iwnstats/iwn_ioctl.c index 97b2a91..4446886 100644 --- a/tools/tools/iwn/iwnstats/iwn_ioctl.c +++ b/tools/tools/iwn/iwnstats/iwn_ioctl.c @@ -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); } diff --git a/tools/tools/iwn/iwnstats/iwn_ioctl.h b/tools/tools/iwn/iwnstats/iwn_ioctl.h index b07ddb5..bc368ee 100644 --- a/tools/tools/iwn/iwnstats/iwn_ioctl.h +++ b/tools/tools/iwn/iwnstats/iwn_ioctl.h @@ -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); diff --git a/tools/tools/iwn/iwnstats/iwnstats.h b/tools/tools/iwn/iwnstats/iwnstats.h index 6443ca1..372a2aa 100644 --- a/tools/tools/iwn/iwnstats/iwnstats.h +++ b/tools/tools/iwn/iwnstats/iwnstats.h @@ -33,7 +33,6 @@ struct iwnstats { int s; - struct ifreq ifr; struct iwn_stats st; }; diff --git a/tools/tools/iwn/iwnstats/main.c b/tools/tools/iwn/iwnstats/main.c index 89582aa..b047e11 100644 --- a/tools/tools/iwn/iwnstats/main.c +++ b/tools/tools/iwn/iwnstats/main.c @@ -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); } -- cgit v1.1