xref: /freebsd/contrib/wpa/wpa_supplicant/libwpa_test.c (revision e6bfd18d21b225af6a0ed67ceeaf1293b7b9eba5)
1 /*
2  * libwpa_test - Test program for libwpa_client.* library linking
3  * Copyright (c) 2015, Jouni Malinen <j@w1.fi>
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  */
8 
9 #include "includes.h"
10 
11 #include "common/wpa_ctrl.h"
12 
13 int main(int argc, char *argv[])
14 {
15 	struct wpa_ctrl *ctrl;
16 
17 	ctrl = wpa_ctrl_open("foo");
18 	if (!ctrl)
19 		return -1;
20 	if (wpa_ctrl_attach(ctrl) == 0)
21 		wpa_ctrl_detach(ctrl);
22 	if (wpa_ctrl_pending(ctrl)) {
23 		char buf[10];
24 		size_t len;
25 
26 		len = sizeof(buf);
27 		wpa_ctrl_recv(ctrl, buf, &len);
28 	}
29 	wpa_ctrl_close(ctrl);
30 
31 	return 0;
32 }
33