Last active
December 23, 2015 04:19
-
-
Save zonque/6579314 to your computer and use it in GitHub Desktop.
Test case to tigger a mwifiex command timeout bug.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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