Convert this over to use the new cdev based ioctl path.
This commit is contained in:
parent
4823a7500b
commit
267e3cf98d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=287313
@ -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
|
||||
|
@ -62,29 +62,25 @@
|
||||
|
||||
#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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -33,7 +33,6 @@
|
||||
|
||||
struct iwnstats {
|
||||
int s;
|
||||
struct ifreq ifr;
|
||||
struct iwn_stats st;
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user