Lines Matching +full:switch +full:- +full:freq +full:- +full:select
2 * WPA Supplicant - privilege separated driver interface
3 * Copyright (c) 2007-2009, Jouni Malinen <j@w1.fi>
34 res = sendto(drv->priv_socket, &cmd, sizeof(cmd), 0, in wpa_priv_reg_cmd()
35 (struct sockaddr *) &drv->priv_addr, in wpa_priv_reg_cmd()
36 sizeof(drv->priv_addr)); in wpa_priv_reg_cmd()
39 return res < 0 ? -1 : 0; in wpa_priv_reg_cmd()
58 msg.msg_name = &drv->priv_addr; in wpa_priv_cmd()
59 msg.msg_namelen = sizeof(drv->priv_addr); in wpa_priv_cmd()
61 if (sendmsg(drv->cmd_socket, &msg, 0) < 0) { in wpa_priv_cmd()
64 return -1; in wpa_priv_cmd()
73 FD_SET(drv->cmd_socket, &rfds); in wpa_priv_cmd()
76 res = select(drv->cmd_socket + 1, &rfds, NULL, NULL, &tv); in wpa_priv_cmd()
78 wpa_printf(MSG_ERROR, "select: %s", strerror(errno)); in wpa_priv_cmd()
79 return -1; in wpa_priv_cmd()
82 if (FD_ISSET(drv->cmd_socket, &rfds)) { in wpa_priv_cmd()
83 res = recv(drv->cmd_socket, reply, *reply_len, 0); in wpa_priv_cmd()
87 return -1; in wpa_priv_cmd()
93 return -1; in wpa_priv_cmd()
110 scan.num_ssids = params->num_ssids; in wpa_driver_privsep_scan()
111 for (i = 0; i < params->num_ssids; i++) { in wpa_driver_privsep_scan()
112 if (!params->ssids[i].ssid) in wpa_driver_privsep_scan()
114 scan.ssid_lens[i] = params->ssids[i].ssid_len; in wpa_driver_privsep_scan()
115 os_memcpy(scan.ssids[i], params->ssids[i].ssid, in wpa_driver_privsep_scan()
120 params->freqs && params->freqs[i]; i++) in wpa_driver_privsep_scan()
121 scan.freqs[i] = params->freqs[i]; in wpa_driver_privsep_scan()
173 results->res = os_calloc(num, sizeof(struct wpa_scan_res *)); in wpa_driver_privsep_get_scan_results2()
174 if (results->res == NULL) { in wpa_driver_privsep_get_scan_results2()
180 while (results->num < (size_t) num && end - pos > (int) sizeof(int)) { in wpa_driver_privsep_get_scan_results2()
184 if (len < 0 || len > 10000 || len > end - pos) in wpa_driver_privsep_get_scan_results2()
191 if (sizeof(*r) + r->ie_len + r->beacon_ie_len > (size_t) len) { in wpa_driver_privsep_get_scan_results2()
194 (int) sizeof(*r), (int) r->ie_len, in wpa_driver_privsep_get_scan_results2()
195 (int) r->beacon_ie_len, len); in wpa_driver_privsep_get_scan_results2()
200 results->res[results->num++] = r; in wpa_driver_privsep_get_scan_results2()
213 enum wpa_alg alg = params->alg; in wpa_driver_privsep_set_key()
214 const u8 *addr = params->addr; in wpa_driver_privsep_set_key()
215 int key_idx = params->key_idx; in wpa_driver_privsep_set_key()
216 int set_tx = params->set_tx; in wpa_driver_privsep_set_key()
217 const u8 *seq = params->seq; in wpa_driver_privsep_set_key()
218 size_t seq_len = params->seq_len; in wpa_driver_privsep_set_key()
219 const u8 *key = params->key; in wpa_driver_privsep_set_key()
220 size_t key_len = params->key_len; in wpa_driver_privsep_set_key()
233 cmd.key_flag = params->key_flag; in wpa_driver_privsep_set_key()
257 wpa_printf(MSG_DEBUG, "%s: priv=%p freq=%d bssid=" MACSTR in wpa_driver_privsep_authenticate()
259 __func__, priv, params->freq, MAC2STR(params->bssid), in wpa_driver_privsep_authenticate()
260 params->auth_alg, params->local_state_change, params->p2p); in wpa_driver_privsep_authenticate()
262 buflen = sizeof(*data) + params->ie_len + params->auth_data_len; in wpa_driver_privsep_authenticate()
265 return -1; in wpa_driver_privsep_authenticate()
267 data->freq = params->freq; in wpa_driver_privsep_authenticate()
268 os_memcpy(data->bssid, params->bssid, ETH_ALEN); in wpa_driver_privsep_authenticate()
269 os_memcpy(data->ssid, params->ssid, params->ssid_len); in wpa_driver_privsep_authenticate()
270 data->ssid_len = params->ssid_len; in wpa_driver_privsep_authenticate()
271 data->auth_alg = params->auth_alg; in wpa_driver_privsep_authenticate()
272 data->ie_len = params->ie_len; in wpa_driver_privsep_authenticate()
274 if (params->wep_key[i]) in wpa_driver_privsep_authenticate()
275 os_memcpy(data->wep_key[i], params->wep_key[i], in wpa_driver_privsep_authenticate()
276 params->wep_key_len[i]); in wpa_driver_privsep_authenticate()
277 data->wep_key_len[i] = params->wep_key_len[i]; in wpa_driver_privsep_authenticate()
279 data->wep_tx_keyidx = params->wep_tx_keyidx; in wpa_driver_privsep_authenticate()
280 data->local_state_change = params->local_state_change; in wpa_driver_privsep_authenticate()
281 data->p2p = params->p2p; in wpa_driver_privsep_authenticate()
283 if (params->ie_len) { in wpa_driver_privsep_authenticate()
284 os_memcpy(pos, params->ie, params->ie_len); in wpa_driver_privsep_authenticate()
285 pos += params->ie_len; in wpa_driver_privsep_authenticate()
287 if (params->auth_data_len) in wpa_driver_privsep_authenticate()
288 os_memcpy(pos, params->auth_data, params->auth_data_len); in wpa_driver_privsep_authenticate()
306 wpa_printf(MSG_DEBUG, "%s: priv=%p freq=%d pairwise_suite=%d " in wpa_driver_privsep_associate()
308 __func__, priv, params->freq.freq, params->pairwise_suite, in wpa_driver_privsep_associate()
309 params->group_suite, params->key_mgmt_suite, in wpa_driver_privsep_associate()
310 params->auth_alg, params->mode); in wpa_driver_privsep_associate()
312 buflen = sizeof(*data) + params->wpa_ie_len; in wpa_driver_privsep_associate()
315 return -1; in wpa_driver_privsep_associate()
317 if (params->bssid) in wpa_driver_privsep_associate()
318 os_memcpy(data->bssid, params->bssid, ETH_ALEN); in wpa_driver_privsep_associate()
319 os_memcpy(data->ssid, params->ssid, params->ssid_len); in wpa_driver_privsep_associate()
320 data->ssid_len = params->ssid_len; in wpa_driver_privsep_associate()
321 data->hwmode = params->freq.mode; in wpa_driver_privsep_associate()
322 data->freq = params->freq.freq; in wpa_driver_privsep_associate()
323 data->channel = params->freq.channel; in wpa_driver_privsep_associate()
324 data->pairwise_suite = params->pairwise_suite; in wpa_driver_privsep_associate()
325 data->group_suite = params->group_suite; in wpa_driver_privsep_associate()
326 data->key_mgmt_suite = params->key_mgmt_suite; in wpa_driver_privsep_associate()
327 data->auth_alg = params->auth_alg; in wpa_driver_privsep_associate()
328 data->mode = params->mode; in wpa_driver_privsep_associate()
329 data->wpa_ie_len = params->wpa_ie_len; in wpa_driver_privsep_associate()
330 if (params->wpa_ie) in wpa_driver_privsep_associate()
331 os_memcpy(data + 1, params->wpa_ie, params->wpa_ie_len); in wpa_driver_privsep_associate()
350 return -1; in wpa_driver_privsep_get_bssid()
364 return -1; in wpa_driver_privsep_get_ssid()
369 return -1; in wpa_driver_privsep_get_ssid()
382 wpa_printf(MSG_DEBUG, "%s - TODO", __func__); in wpa_driver_privsep_deauthenticate()
396 if (len < sizeof(*auth) + auth->ies_len) in wpa_driver_privsep_event_auth()
399 os_memcpy(data.auth.peer, auth->peer, ETH_ALEN); in wpa_driver_privsep_event_auth()
400 os_memcpy(data.auth.bssid, auth->bssid, ETH_ALEN); in wpa_driver_privsep_event_auth()
401 data.auth.auth_type = auth->auth_type; in wpa_driver_privsep_event_auth()
402 data.auth.auth_transaction = auth->auth_transaction; in wpa_driver_privsep_event_auth()
403 data.auth.status_code = auth->status_code; in wpa_driver_privsep_event_auth()
404 if (auth->ies_len) { in wpa_driver_privsep_event_auth()
406 data.auth.ies_len = auth->ies_len; in wpa_driver_privsep_event_auth()
427 if (end - pos < (int) sizeof(int)) in wpa_driver_privsep_event_assoc()
431 if (ie_len < 0 || ie_len > end - pos) in wpa_driver_privsep_event_assoc()
451 len - sizeof(int) > sizeof(data.interface_status.ifname)) in wpa_driver_privsep_event_interface_status()
459 len - sizeof(int)); in wpa_driver_privsep_event_interface_status()
504 data.ft_ies.ies_len = len - sizeof(int) - ETH_ALEN; in wpa_driver_privsep_event_ft_response()
513 drv_event_eapol_rx(ctx, buf, buf + ETH_ALEN, len - ETH_ALEN); in wpa_driver_privsep_event_rx_eapol()
550 event_len = res - sizeof(int); in wpa_driver_privsep_receive()
555 switch (e) { in wpa_driver_privsep_receive()
557 wpa_supplicant_event(drv->ctx, EVENT_SCAN_RESULTS, NULL); in wpa_driver_privsep_receive()
560 wpa_supplicant_event(drv->ctx, EVENT_SCAN_STARTED, NULL); in wpa_driver_privsep_receive()
563 wpa_driver_privsep_event_assoc(drv->ctx, EVENT_ASSOC, in wpa_driver_privsep_receive()
567 wpa_supplicant_event(drv->ctx, EVENT_DISASSOC, NULL); in wpa_driver_privsep_receive()
570 wpa_driver_privsep_event_assoc(drv->ctx, EVENT_ASSOCINFO, in wpa_driver_privsep_receive()
575 drv->ctx, event_buf, event_len); in wpa_driver_privsep_receive()
578 wpa_driver_privsep_event_interface_status(drv->ctx, event_buf, in wpa_driver_privsep_receive()
582 wpa_driver_privsep_event_pmkid_candidate(drv->ctx, event_buf, in wpa_driver_privsep_receive()
586 wpa_driver_privsep_event_ft_response(drv->ctx, event_buf, in wpa_driver_privsep_receive()
590 wpa_driver_privsep_event_rx_eapol(drv->ctx, event_buf, in wpa_driver_privsep_receive()
594 wpa_driver_privsep_event_auth(drv->ctx, event_buf, event_len); in wpa_driver_privsep_receive()
609 drv->ctx = ctx; in wpa_driver_privsep_init()
610 drv->priv_socket = -1; in wpa_driver_privsep_init()
611 drv->cmd_socket = -1; in wpa_driver_privsep_init()
612 os_strlcpy(drv->ifname, ifname, sizeof(drv->ifname)); in wpa_driver_privsep_init()
622 if (drv->priv_socket >= 0) { in wpa_driver_privsep_deinit()
624 eloop_unregister_read_sock(drv->priv_socket); in wpa_driver_privsep_deinit()
625 close(drv->priv_socket); in wpa_driver_privsep_deinit()
628 if (drv->own_socket_path) { in wpa_driver_privsep_deinit()
629 unlink(drv->own_socket_path); in wpa_driver_privsep_deinit()
630 os_free(drv->own_socket_path); in wpa_driver_privsep_deinit()
633 if (drv->cmd_socket >= 0) { in wpa_driver_privsep_deinit()
634 eloop_unregister_read_sock(drv->cmd_socket); in wpa_driver_privsep_deinit()
635 close(drv->cmd_socket); in wpa_driver_privsep_deinit()
638 if (drv->own_cmd_path) { in wpa_driver_privsep_deinit()
639 unlink(drv->own_cmd_path); in wpa_driver_privsep_deinit()
640 os_free(drv->own_cmd_path); in wpa_driver_privsep_deinit()
665 return -1; in wpa_driver_privsep_set_param()
672 return -1; in wpa_driver_privsep_set_param()
684 return -1; in wpa_driver_privsep_set_param()
693 return -1; in wpa_driver_privsep_set_param()
698 drv->own_socket_path = os_malloc(len); in wpa_driver_privsep_set_param()
699 if (drv->own_socket_path == NULL) { in wpa_driver_privsep_set_param()
702 return -1; in wpa_driver_privsep_set_param()
704 os_snprintf(drv->own_socket_path, len, "%s/wpa_privsep-%d-%d", in wpa_driver_privsep_set_param()
708 drv->own_cmd_path = os_malloc(len); in wpa_driver_privsep_set_param()
709 if (drv->own_cmd_path == NULL) { in wpa_driver_privsep_set_param()
710 os_free(drv->own_socket_path); in wpa_driver_privsep_set_param()
711 drv->own_socket_path = NULL; in wpa_driver_privsep_set_param()
714 return -1; in wpa_driver_privsep_set_param()
716 os_snprintf(drv->own_cmd_path, len, "%s/wpa_privsep-%d-%d", in wpa_driver_privsep_set_param()
721 drv->priv_addr.sun_family = AF_UNIX; in wpa_driver_privsep_set_param()
722 os_snprintf(drv->priv_addr.sun_path, sizeof(drv->priv_addr.sun_path), in wpa_driver_privsep_set_param()
723 "%s/%s", priv_dir, drv->ifname); in wpa_driver_privsep_set_param()
726 drv->priv_socket = socket(PF_UNIX, SOCK_DGRAM, 0); in wpa_driver_privsep_set_param()
727 if (drv->priv_socket < 0) { in wpa_driver_privsep_set_param()
729 os_free(drv->own_socket_path); in wpa_driver_privsep_set_param()
730 drv->own_socket_path = NULL; in wpa_driver_privsep_set_param()
731 return -1; in wpa_driver_privsep_set_param()
736 os_strlcpy(addr.sun_path, drv->own_socket_path, sizeof(addr.sun_path)); in wpa_driver_privsep_set_param()
737 if (bind(drv->priv_socket, (struct sockaddr *) &addr, sizeof(addr)) < in wpa_driver_privsep_set_param()
740 "privsep-set-params priv-sock: bind(PF_UNIX): %s", in wpa_driver_privsep_set_param()
742 close(drv->priv_socket); in wpa_driver_privsep_set_param()
743 drv->priv_socket = -1; in wpa_driver_privsep_set_param()
744 unlink(drv->own_socket_path); in wpa_driver_privsep_set_param()
745 os_free(drv->own_socket_path); in wpa_driver_privsep_set_param()
746 drv->own_socket_path = NULL; in wpa_driver_privsep_set_param()
747 return -1; in wpa_driver_privsep_set_param()
750 eloop_register_read_sock(drv->priv_socket, wpa_driver_privsep_receive, in wpa_driver_privsep_set_param()
753 drv->cmd_socket = socket(PF_UNIX, SOCK_DGRAM, 0); in wpa_driver_privsep_set_param()
754 if (drv->cmd_socket < 0) { in wpa_driver_privsep_set_param()
756 os_free(drv->own_cmd_path); in wpa_driver_privsep_set_param()
757 drv->own_cmd_path = NULL; in wpa_driver_privsep_set_param()
758 return -1; in wpa_driver_privsep_set_param()
763 os_strlcpy(addr.sun_path, drv->own_cmd_path, sizeof(addr.sun_path)); in wpa_driver_privsep_set_param()
764 if (bind(drv->cmd_socket, (struct sockaddr *) &addr, sizeof(addr)) < 0) in wpa_driver_privsep_set_param()
767 "privsep-set-params cmd-sock: bind(PF_UNIX): %s", in wpa_driver_privsep_set_param()
769 close(drv->cmd_socket); in wpa_driver_privsep_set_param()
770 drv->cmd_socket = -1; in wpa_driver_privsep_set_param()
771 unlink(drv->own_cmd_path); in wpa_driver_privsep_set_param()
772 os_free(drv->own_cmd_path); in wpa_driver_privsep_set_param()
773 drv->own_cmd_path = NULL; in wpa_driver_privsep_set_param()
774 return -1; in wpa_driver_privsep_set_param()
779 return -1; in wpa_driver_privsep_set_param()
795 return -1; in wpa_driver_privsep_get_capa()
797 capa->extended_capa = NULL; in wpa_driver_privsep_get_capa()
798 capa->extended_capa_mask = NULL; in wpa_driver_privsep_get_capa()
799 capa->extended_capa_len = 0; in wpa_driver_privsep_get_capa()
801 capa->flags &= ~WPA_DRIVER_FLAGS_CONTROL_PORT; in wpa_driver_privsep_get_capa()
810 return drv->own_addr; in wpa_driver_privsep_get_mac_addr()