summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authoradrian <adrian@FreeBSD.org>2015-08-30 21:54:47 +0000
committeradrian <adrian@FreeBSD.org>2015-08-30 21:54:47 +0000
commit07075ccdf646e51ad8bc00755a270ca8e6bb4d66 (patch)
treeba98e2884be95159c13d7aca87930b5def8ed309 /tools
parent4c1a6bea7c3705292c9e58b66186252e7371a461 (diff)
downloadFreeBSD-src-07075ccdf646e51ad8bc00755a270ca8e6bb4d66.zip
FreeBSD-src-07075ccdf646e51ad8bc00755a270ca8e6bb4d66.tar.gz
Convert this over to use the new cdev based ioctl path.
Diffstat (limited to 'tools')
-rw-r--r--tools/tools/iwn/iwnstats/Makefile2
-rw-r--r--tools/tools/iwn/iwnstats/iwn_ioctl.c20
-rw-r--r--tools/tools/iwn/iwnstats/iwn_ioctl.h1
-rw-r--r--tools/tools/iwn/iwnstats/iwnstats.h1
-rw-r--r--tools/tools/iwn/iwnstats/main.c10
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 <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);
}
OpenPOWER on IntegriCloud