Discussion:
IEEE80211_IOC_STA_STATS broken?
(too old to reply)
Roy Marples
2008-10-28 16:10:57 UTC
Permalink
Hi List

I'm having a spot of bother getting the IEEE80211_IOC_STA_STATS ioctl
to work. For some reason it always returns Invalid Argument EINVAL.

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>

#include <net/if.h>
#include <net80211/ieee80211.h>
#include <net80211/ieee80211_ioctl.h>

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>

int main(void) {
struct ieee80211req ireq;
char buf[24*1024];
int s = socket(AF_INET, SOCK_DGRAM, 0);

memset(&ireq, 0, sizeof(ireq));
strlcpy(ireq.i_name, "iwi0", sizeof(ireq.i_name));
ireq.i_type = IEEE80211_IOC_STA_STATS;
ireq.i_data = buf;
ireq.i_len = sizeof(buf);
if(ioctl(s, SIOCG80211, &ireq) != 0)
perror("SIOCG80211");
else
printf ("ok\n");
return 0;
}

If someone could tell me what I'm doing wrong or it's it's a
NetBSD-4.99.73 bug I'd appreciate it.

Thanks

Roy

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
David Young
2008-10-28 17:42:16 UTC
Permalink
Post by Roy Marples
Hi List
I'm having a spot of bother getting the IEEE80211_IOC_STA_STATS ioctl
to work. For some reason it always returns Invalid Argument EINVAL.
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <net80211/ieee80211.h>
#include <net80211/ieee80211_ioctl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
int main(void) {
struct ieee80211req ireq;
char buf[24*1024];
int s = socket(AF_INET, SOCK_DGRAM, 0);
memset(&ireq, 0, sizeof(ireq));
strlcpy(ireq.i_name, "iwi0", sizeof(ireq.i_name));
ireq.i_type = IEEE80211_IOC_STA_STATS;
ireq.i_data = buf;
ireq.i_len = sizeof(buf);
if(ioctl(s, SIOCG80211, &ireq) != 0)
perror("SIOCG80211");
else
printf ("ok\n");
return 0;
}
If someone could tell me what I'm doing wrong or it's it's a
NetBSD-4.99.73 bug I'd appreciate it.
Apparently, i_data has to point at a STA's MAC address:

error = copyin(ireq->i_data, macaddr, IEEE80211_ADDR_LEN);
if (error != 0)
return error;
ni = ieee80211_find_node(&ic->ic_sta, macaddr);
if (ni == NULL)
return EINVAL; /* XXX */

Instead of EINVAL, it should return ENOENT, IMO.

Dave
--
David Young OJC Technologies
***@ojctech.com Urbana, IL * (217) 278-3933 ext 24

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
David Young
2008-10-28 17:43:46 UTC
Permalink
Post by David Young
Post by Roy Marples
Hi List
I'm having a spot of bother getting the IEEE80211_IOC_STA_STATS ioctl
to work. For some reason it always returns Invalid Argument EINVAL.
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <net80211/ieee80211.h>
#include <net80211/ieee80211_ioctl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
int main(void) {
struct ieee80211req ireq;
char buf[24*1024];
int s = socket(AF_INET, SOCK_DGRAM, 0);
memset(&ireq, 0, sizeof(ireq));
strlcpy(ireq.i_name, "iwi0", sizeof(ireq.i_name));
ireq.i_type = IEEE80211_IOC_STA_STATS;
ireq.i_data = buf;
ireq.i_len = sizeof(buf);
if(ioctl(s, SIOCG80211, &ireq) != 0)
perror("SIOCG80211");
else
printf ("ok\n");
return 0;
}
If someone could tell me what I'm doing wrong or it's it's a
NetBSD-4.99.73 bug I'd appreciate it.
error = copyin(ireq->i_data, macaddr, IEEE80211_ADDR_LEN);
if (error != 0)
return error;
ni = ieee80211_find_node(&ic->ic_sta, macaddr);
if (ni == NULL)
return EINVAL; /* XXX */
Instead of EINVAL, it should return ENOENT, IMO.
Also, I suggest pointing i_data at an ieee80211req_sta_stats.

Dave
--
David Young OJC Technologies
***@ojctech.com Urbana, IL * (217) 278-3933 ext 24

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Roy Marples
2008-11-07 09:25:48 UTC
Permalink
Post by David Young
Post by David Young
Post by Roy Marples
If someone could tell me what I'm doing wrong or it's it's a
NetBSD-4.99.73 bug I'd appreciate it.
error = copyin(ireq->i_data, macaddr, IEEE80211_ADDR_LEN);
if (error != 0)
return error;
ni = ieee80211_find_node(&ic->ic_sta, macaddr);
if (ni == NULL)
return EINVAL; /* XXX */
Instead of EINVAL, it should return ENOENT, IMO.
Also, I suggest pointing i_data at an ieee80211req_sta_stats.
OK, it works a little better now.
It things it works, but from the looks of it the data returned is
garbage. Attached is the program, here is the output.

$ ./x
ok
00:13:49:a0:1d:48
00:13:49:a0:1d:48
1024
SIOCG80211: Operation not permitted
$ sudo ./x
ok
00:13:49:a0:1d:48
00:13:49:a0:1d:48
1024
ok
00:00:00:00:00:00
0 0 0

The last 3 numbers are data length, frequency and rssi.
Questions

1) Why is superuser required to obtain such simple information such as
rssi of the AP associated to?
2) What is going wrong? It's quite hard as I can find no sample code for
this ioctl and I don't understand much kernel code.
3) Is there an easier way to do this?

This is purely to try and get the wavelan panel plugin on XFCE working
with my iwi0 card.

Thanks

Roy

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Roy Marples
2008-11-07 09:26:04 UTC
Permalink
Post by David Young
Post by David Young
Post by Roy Marples
If someone could tell me what I'm doing wrong or it's it's a
NetBSD-4.99.73 bug I'd appreciate it.
error = copyin(ireq->i_data, macaddr, IEEE80211_ADDR_LEN);
if (error != 0)
return error;
ni = ieee80211_find_node(&ic->ic_sta, macaddr);
if (ni == NULL)
return EINVAL; /* XXX */
Instead of EINVAL, it should return ENOENT, IMO.
Also, I suggest pointing i_data at an ieee80211req_sta_stats.
OK, it works a little better now.
It things it works, but from the looks of it the data returned is
garbage. Attached is the program, here is the output.

$ ./x
ok
00:13:49:a0:1d:48
00:13:49:a0:1d:48
1024
SIOCG80211: Operation not permitted
$ sudo ./x
ok
00:13:49:a0:1d:48
00:13:49:a0:1d:48
1024
ok
00:00:00:00:00:00
0 0 0

The last 3 numbers are data length, frequency and rssi.
Questions

1) Why is superuser required to obtain such simple information such as
rssi of the AP associated to?
2) What is going wrong? It's quite hard as I can find no sample code for
this ioctl and I don't understand much kernel code.
3) Is there an easier way to do this?

This is purely to try and get the wavelan panel plugin on XFCE working
with my iwi0 card.

Thanks

Roy
David Young
2008-11-07 20:42:52 UTC
Permalink
Post by Roy Marples
Post by David Young
Post by David Young
Post by Roy Marples
If someone could tell me what I'm doing wrong or it's it's a
NetBSD-4.99.73 bug I'd appreciate it.
error = copyin(ireq->i_data, macaddr, IEEE80211_ADDR_LEN);
if (error != 0)
return error;
ni = ieee80211_find_node(&ic->ic_sta, macaddr);
if (ni == NULL)
return EINVAL; /* XXX */
Instead of EINVAL, it should return ENOENT, IMO.
Also, I suggest pointing i_data at an ieee80211req_sta_stats.
OK, it works a little better now.
It things it works, but from the looks of it the data returned is
garbage. Attached is the program, here is the output.
$ ./x
ok
00:13:49:a0:1d:48
00:13:49:a0:1d:48
1024
SIOCG80211: Operation not permitted
$ sudo ./x
ok
00:13:49:a0:1d:48
00:13:49:a0:1d:48
1024
ok
00:00:00:00:00:00
0 0 0
The last 3 numbers are data length, frequency and rssi.
Questions
1) Why is superuser required to obtain such simple information such as
rssi of the AP associated to?
2) What is going wrong? It's quite hard as I can find no sample code for
this ioctl and I don't understand much kernel code.
3) Is there an easier way to do this?
You can use the sysctl interface that I use in wlanctl. Apparently,
it is more full-featured.

I think that the problem you see is that the AP (aka "BSS") node is
not in the list of stations, ic_sta, but the only link to it is ic_bss,
and net80211 does not visit ic_bss when it iterates over the 802.11 nodes.

Dave
--
David Young OJC Technologies
***@ojctech.com Urbana, IL * (217) 278-3933 ext 24

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Roy Marples
2008-11-07 20:56:40 UTC
Permalink
Post by David Young
You can use the sysctl interface that I use in wlanctl. Apparently,
it is more full-featured.
I think that the problem you see is that the AP (aka "BSS") node is
not in the list of stations, ic_sta, but the only link to it is ic_bss,
and net80211 does not visit ic_bss when it iterates over the 802.11 nodes.
Wonderful.

So NetBSD, OpenBSD and FreeBSD all have very different interfaces for
getting the same information.

OK, I'll go the sysctl route and make a mental note never to visit
wireless again.

Thanks anyway

Roy

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Loading...