Ioctl() call fails
Hi
When I'm trying to use an ioctl()-call with a definition of the wireless extension (eg. SIOCGIWSTATS or SIOCGIWESSID) I allways get an errormessage saying "Operation not supported". But an outpout from /proc/net/wireless gives resonable results.
Furthermore, Iwpriv returns a list of private ioctls supported by my wavelan turbo 11Mb silver, so it doesn't seemt to be a driver problem?!
Anyone got an Idea what the pb is? Below is the code I use for testing.
\Henrik
//------------------ CODE ----------------------//
#include <stdio.h>
#include <string.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <linux/netdevice.h>
#include <linux/wireless.h>
#include <sys/ioctl.h>
struct iw_statistics stats;
static int skfd = 0;
int wlanStats()
{
struct iwreq wrq;
if(skfd == 0) {
if((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
perror("socket");
return -1;
}
}
wrq.u.data.pointer = (caddr_t) &stats;
wrq.u.data.length = 0;
wrq.u.data.flags = 1;
strncpy(wrq.ifr_name, "eth0", 16);
if(ioctl(skfd, SIOCGIWSTATS, &wrq) < 0) {
perror("iotcl call");
return -1;
}
return 0;
}
main() {
wlanStats();
}
|