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