Last active
February 14, 2021 13:59
-
-
Save sepfy/02480d34bbd2d8be2f6072748e8d4b95 to your computer and use it in GitHub Desktop.
libwpa_client control example
This file contains hidden or 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 <stdlib.h> | |
#include <wpa_ctrl.h> | |
#define CTRL_INTERFACE_DIR "/var/run/wpa_supplicant/wlan0" | |
int main(int argc, char *argv[]) { | |
struct wpa_ctrl *ctrl_conn; | |
char cmd[] = "SCAN_RESULTS"; | |
size_t cmd_len = sizeof(cmd); | |
char reply[8192] = {0}; | |
size_t reply_len = sizeof(reply); | |
ctrl_conn = wpa_ctrl_open(CTRL_INTERFACE_DIR); | |
if(wpa_ctrl_request(ctrl_conn, cmd, cmd_len, reply, &reply_len, NULL) != 0) { | |
fprintf(stderr, "Request failed\n"); | |
return -1; | |
} | |
fprintf(stdout, "scan results = \n%s\n", reply); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment