Created
August 19, 2014 16:48
-
-
Save rosenhouse/685e6c4c7f3b1332aa0f to your computer and use it in GitHub Desktop.
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
/* | |
Simple program to print out available wifi networks | |
Taken from http://stackoverflow.com/a/16752895/141084 | |
To build & run: | |
sudo apt-get install libiw-dev | |
gcc -liw test.c | |
./a.out | |
*/ | |
#include <stdio.h> | |
#include <time.h> | |
#include <iwlib.h> | |
int main(void) { | |
wireless_scan_head head; | |
wireless_scan *result; | |
iwrange range; | |
int sock; | |
/* Open socket to kernel */ | |
sock = iw_sockets_open(); | |
/* Get some metadata to use for scanning */ | |
if (iw_get_range_info(sock, "wlan0", &range) < 0) { | |
printf("Error during iw_get_range_info. Aborting.\n"); | |
exit(2); | |
} | |
/* Perform the scan */ | |
if (iw_scan(sock, "wlan0", range.we_version_compiled, &head) < 0) { | |
printf("Error during iw_scan. Aborting.\n"); | |
exit(2); | |
} | |
/* Traverse the results */ | |
result = head.result; | |
while (NULL != result) { | |
printf("%s\n", result->b.essid); | |
result = result->next; | |
} | |
exit(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
wifi password kaise pata kre kisi ka bhai