Skip to content

Instantly share code, notes, and snippets.

@zonque
Last active December 23, 2015 04:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zonque/6579314 to your computer and use it in GitHub Desktop.
Save zonque/6579314 to your computer and use it in GitHub Desktop.
Test case to tigger a mwifiex command timeout bug.
#include <stdio.h>
#include <string.h>
#include <ifaddrs.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <linux/wireless.h>
static void get_signal_strength(const char *ifname)
{
int ret, fd;
struct iwreq wrq;
struct iw_statistics stats;
memset(&stats, 0, sizeof(stats));
wrq.u.data.pointer = &stats;
wrq.u.data.length = sizeof(stats);
wrq.u.data.flags = 1;
strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
fd = socket(PF_INET, SOCK_DGRAM, 0);
ret = ioctl(fd, SIOCGIWSTATS, &wrq);
close(fd);
if (ret < 0)
fprintf(stderr, "ioctl() returned %d (%m)\n", ret);
}
int main(int argc, char **argv)
{
if (argc < 2) {
fprintf(stderr, "Usage: %s <ifname>\n", argv[0]);
return 1;
}
for (;;)
get_signal_strength(argv[1]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment