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