Lines Matching +full:- +full:- +full:retry +full:- +full:failed
5 * SPDX-License-Identifier: Apache-2.0
185 return get_default_context()->supplicant; in zephyr_get_default_supplicant_context()
190 return &get_default_context()->iface_wq; in get_workq()
202 if (ctx->event_socketpair[1] < 0) { in zephyr_wifi_send_event()
203 ret = -ENOENT; in zephyr_wifi_send_event()
207 fds[0].fd = ctx->event_socketpair[0]; in zephyr_wifi_send_event()
213 ret = -errno; in zephyr_wifi_send_event()
218 ret = zsock_send(ctx->event_socketpair[1], msg, sizeof(*msg), 0); in zephyr_wifi_send_event()
220 ret = -errno; in zephyr_wifi_send_event()
221 LOG_WRN("Event send failed (%d)", ret); in zephyr_wifi_send_event()
226 ret = -EMSGSIZE; in zephyr_wifi_send_event()
259 wpa_s = wpa_supplicant_get_iface(ctx->supplicant, ifname); in zephyr_get_handle_by_ifname()
274 hapd = hostapd_get_iface(&ctx->hostapd, ifname); in zephyr_get_hapd_handle_by_ifname()
280 return hapd->iface; in zephyr_get_hapd_handle_by_ifname()
290 for (wpa_s = ctx->supplicant->ifaces; wpa_s; wpa_s = wpa_s->next) { in get_iface_count()
301 int ret, retry = 0, count = IFACE_NOTIFY_TIMEOUT_MS / IFACE_NOTIFY_RETRY_MS; in add_interface() local
303 ret = net_if_get_name(iface, ifname, sizeof(ifname) - 1); in add_interface()
314 LOG_ERR("Failed to add interface %s", ifname); in add_interface()
318 while (retry++ < count && !wpa_supplicant_get_iface(ctx->supplicant, ifname)) { in add_interface()
322 wpa_s = wpa_supplicant_get_iface(ctx->supplicant, ifname); in add_interface()
324 LOG_ERR("Failed to add iface %s", ifname); in add_interface()
328 wpa_s->conf->filter_ssids = 1; in add_interface()
329 wpa_s->conf->ap_scan = 1; in add_interface()
333 ctx->iface = iface; in add_interface()
334 net_if_get_name(iface, ctx->if_name, CONFIG_NET_INTERFACE_NAME_LEN); in add_interface()
339 LOG_ERR("Failed to initialize supplicant control interface"); in add_interface()
347 LOG_ERR("Failed to register mgd iface with native stack %s (%d)", in add_interface()
372 int ret, retry = 0, count = IFACE_NOTIFY_TIMEOUT_MS / IFACE_NOTIFY_RETRY_MS; in del_interface() local
375 ret = net_if_get_name(iface, ifname, sizeof(ifname) - 1); in del_interface()
385 ret = -ENOMEM; in del_interface()
386 LOG_ERR("Failed to allocate event data"); in del_interface()
390 wpa_s = wpa_supplicant_get_iface(ctx->supplicant, ifname); in del_interface()
392 ret = -ENOENT; in del_interface()
393 LOG_ERR("Failed to get wpa_s handle for %s", ifname); in del_interface()
399 if (sizeof(event->interface_status.ifname) < strlen(ifname)) { in del_interface()
401 ifname, sizeof(event->interface_status.ifname)); in del_interface()
405 os_memcpy(event->interface_status.ifname, ifname, strlen(ifname)); in del_interface()
406 event->interface_status.ievent = EVENT_INTERFACE_REMOVED; in del_interface()
409 msg.ctx = ctx->supplicant; in del_interface()
415 /* We failed notify WPA supplicant about interface removal. in del_interface()
419 wpa_printf(MSG_ERROR, "Failed to send event: %d", ret); in del_interface()
423 while (retry++ < count && wpa_s->wpa_state != WPA_INTERFACE_DISABLED) { in del_interface()
427 if (wpa_s->wpa_state != WPA_INTERFACE_DISABLED) { in del_interface()
428 LOG_ERR("Failed to notify remove interface %s", ifname); in del_interface()
429 supplicant_generate_state_event(ifname, NET_EVENT_SUPPLICANT_CMD_IFACE_REMOVED, -1); in del_interface()
437 LOG_ERR("Failed to remove interface %s", ifname); in del_interface()
439 -EINVAL); in del_interface()
445 LOG_ERR("Failed to unregister mgd iface %s with native stack (%d)", in del_interface()
472 ret = (*ctx->iface_handler)(ctx, ctx->iface); in iface_work_handler()
474 LOG_ERR("Interface %d (%p) handler failed (%d)", in iface_work_handler()
475 net_if_get_by_iface(ctx->iface), ctx->iface, ret); in iface_work_handler()
487 ctx->iface_handler = handler; in submit_iface_work()
489 k_work_submit_to_queue(&ctx->iface_wq, &ctx->iface_work); in submit_iface_work()
548 net_mgmt_init_event_callback(&ctx->cb, interface_handler, in setup_interface_monitoring()
550 net_mgmt_add_event_callback(&ctx->cb); in setup_interface_monitoring()
568 LOG_ERR("Failed to recv the message (%d)", -errno); in event_socket_handler()
595 os_free((char *)data->auth.ies); in event_socket_handler()
597 os_free((char *)data->rx_mgmt.frame); in event_socket_handler()
599 os_free((char *)data->tx_status.data); in event_socket_handler()
601 os_free((char *)data->assoc_info.addr); in event_socket_handler()
602 os_free((char *)data->assoc_info.req_ies); in event_socket_handler()
603 os_free((char *)data->assoc_info.resp_ies); in event_socket_handler()
604 os_free((char *)data->assoc_info.resp_frame); in event_socket_handler()
606 os_free((char *)data->assoc_reject.bssid); in event_socket_handler()
607 os_free((char *)data->assoc_reject.resp_ies); in event_socket_handler()
609 os_free((char *)data->deauth_info.addr); in event_socket_handler()
610 os_free((char *)data->deauth_info.ie); in event_socket_handler()
612 os_free((char *)data->disassoc_info.addr); in event_socket_handler()
613 os_free((char *)data->disassoc_info.ie); in event_socket_handler()
615 os_free((char *)data->unprot_deauth.sa); in event_socket_handler()
616 os_free((char *)data->unprot_deauth.da); in event_socket_handler()
618 os_free((char *)data->unprot_disassoc.sa); in event_socket_handler()
619 os_free((char *)data->unprot_disassoc.da); in event_socket_handler()
630 ret = socketpair(AF_UNIX, SOCK_STREAM, 0, ctx->event_socketpair); in register_supplicant_event_socket()
632 ret = -errno; in register_supplicant_event_socket()
633 LOG_ERR("Failed to initialize socket (%d)", ret); in register_supplicant_event_socket()
637 eloop_register_read_sock(ctx->event_socketpair[0], event_socket_handler, NULL, ctx); in register_supplicant_event_socket()
649 return ctx->hostapd.iface[0]; in hostapd_get_interface()
655 hostapd_event_eapol_rx(ctx, src_addr, buf, len, FRAME_ENCRYPTION_UNKNOWN, -1); in hostapd_event_eapol_rx_cb()
662 wpa_printf(MSG_DEBUG, "Enable interface %s", hapd_iface->conf->bss[0]->iface); in hostapd_enable_iface_cb()
664 bss = hapd_iface->bss[0]; in hostapd_enable_iface_cb()
666 bss->conf->start_disabled = 0; in hostapd_enable_iface_cb()
668 if (hostapd_config_check(hapd_iface->conf, 1) < 0) { in hostapd_enable_iface_cb()
669 wpa_printf(MSG_INFO, "Invalid configuration - cannot enable"); in hostapd_enable_iface_cb()
670 return -1; in hostapd_enable_iface_cb()
673 l2_packet_deinit(bss->l2); in hostapd_enable_iface_cb()
674 bss->l2 = l2_packet_init(bss->conf->iface, bss->conf->bssid, ETH_P_EAPOL, in hostapd_enable_iface_cb()
676 if (bss->l2 == NULL) { in hostapd_enable_iface_cb()
677 wpa_printf(MSG_ERROR, "Failed to initialize l2 for hostapd interface"); in hostapd_enable_iface_cb()
678 return -1; in hostapd_enable_iface_cb()
682 wpa_printf(MSG_ERROR, "Failed to initialize hostapd interface"); in hostapd_enable_iface_cb()
683 return -1; in hostapd_enable_iface_cb()
694 wpa_msg(hapd_iface->bss[0]->msg_ctx, MSG_INFO, AP_EVENT_DISABLED); in hostapd_disable_iface_cb()
696 hapd_iface->driver_ap_teardown = !!(hapd_iface->drv_flags in hostapd_disable_iface_cb()
700 for (j = 0; j < hapd_iface->num_bss; j++) { in hostapd_disable_iface_cb()
701 hostapd_cleanup_cs_params(hapd_iface->bss[j]); in hostapd_disable_iface_cb()
708 for (j = 0; j < hapd_iface->num_bss; j++) { in hostapd_disable_iface_cb()
709 hapd = hapd_iface->bss[j]; in hostapd_disable_iface_cb()
718 wpa_printf(MSG_DEBUG, "Interface %s disabled", hapd_iface->bss[0]->conf->iface); in hostapd_disable_iface_cb()
723 hostapd_config_free(hapd_iface->conf); in hostapd_disable_iface_cb()
724 hapd_iface->conf = hapd_iface->interfaces->config_read_cb(hapd_iface->config_fname); in hostapd_disable_iface_cb()
725 for (j = 0; j < hapd_iface->num_bss; j++) { in hostapd_disable_iface_cb()
726 hapd = hapd_iface->bss[j]; in hostapd_disable_iface_cb()
727 hapd->iconf = hapd_iface->conf; in hostapd_disable_iface_cb()
728 hapd->conf = hapd_iface->conf->bss[j]; in hostapd_disable_iface_cb()
729 hapd->driver = hapd_iface->conf->driver; in hostapd_disable_iface_cb()
742 wpa_printf(MSG_ERROR, "Failed to register EAP methods"); in hostapd_global_init()
743 return -1; in hostapd_global_init()
746 interfaces->eloop_initialized = 1; in hostapd_global_init()
754 return -1; in hostapd_global_init()
758 return -1; in hostapd_global_init()
768 struct hostapd_data *hapd = iface->bss[0]; in hostapd_driver_init()
769 struct hostapd_bss_config *conf = hapd->conf; in hostapd_driver_init()
770 u8 *b = conf->bssid; in hostapd_driver_init()
773 if (hapd->driver == NULL || hapd->driver->hapd_init == NULL) { in hostapd_driver_init()
775 return -1; in hostapd_driver_init()
785 if (wpa_drivers[i] != hapd->driver) in hostapd_driver_init()
788 if (hglobal.drv_priv[i] == NULL && wpa_drivers[i]->global_init) { in hostapd_driver_init()
789 hglobal.drv_priv[i] = wpa_drivers[i]->global_init(iface->interfaces); in hostapd_driver_init()
791 wpa_printf(MSG_ERROR, "Failed to initialize driver '%s'", in hostapd_driver_init()
792 wpa_drivers[i]->name); in hostapd_driver_init()
793 return -1; in hostapd_driver_init()
802 params.ifname = hapd->conf->iface; in hostapd_driver_init()
803 params.driver_params = hapd->iconf->driver_params; in hostapd_driver_init()
804 params.use_pae_group_addr = hapd->conf->use_pae_group_addr; in hostapd_driver_init()
805 params.num_bridge = hapd->iface->num_bss; in hostapd_driver_init()
806 params.bridge = os_calloc(hapd->iface->num_bss, sizeof(char *)); in hostapd_driver_init()
808 return -1; in hostapd_driver_init()
810 for (i = 0; i < hapd->iface->num_bss; i++) { in hostapd_driver_init()
811 struct hostapd_data *bss = hapd->iface->bss[i]; in hostapd_driver_init()
813 if (bss->conf->bridge[0]) { in hostapd_driver_init()
814 params.bridge[i] = bss->conf->bridge; in hostapd_driver_init()
818 params.own_addr = hapd->own_addr; in hostapd_driver_init()
820 hapd->drv_priv = hapd->driver->hapd_init(hapd, ¶ms); in hostapd_driver_init()
822 if (hapd->drv_priv == NULL) { in hostapd_driver_init()
823 wpa_printf(MSG_ERROR, "%s driver initialization failed.", in hostapd_driver_init()
824 hapd->driver->name); in hostapd_driver_init()
825 hapd->driver = NULL; in hostapd_driver_init()
826 return -1; in hostapd_driver_init()
829 if (hapd->driver->get_capa && hapd->driver->get_capa(hapd->drv_priv, &capa) == 0) { in hostapd_driver_init()
832 iface->drv_flags = capa.flags; in hostapd_driver_init()
833 iface->drv_flags2 = capa.flags2; in hostapd_driver_init()
834 iface->probe_resp_offloads = capa.probe_resp_offloads; in hostapd_driver_init()
836 * Use default extended capa values from per-radio information in hostapd_driver_init()
838 iface->extended_capa = capa.extended_capa; in hostapd_driver_init()
839 iface->extended_capa_mask = capa.extended_capa_mask; in hostapd_driver_init()
840 iface->extended_capa_len = capa.extended_capa_len; in hostapd_driver_init()
841 iface->drv_max_acl_mac_addrs = capa.max_acl_mac_addrs; in hostapd_driver_init()
844 * Override extended capa with per-interface type (AP), if in hostapd_driver_init()
849 triggs = wpa_get_wowlan_triggers(conf->wowlan_triggers, &capa); in hostapd_driver_init()
850 if (triggs && hapd->driver->set_wowlan) { in hostapd_driver_init()
851 if (hapd->driver->set_wowlan(hapd->drv_priv, triggs)) { in hostapd_driver_init()
852 wpa_printf(MSG_ERROR, "set_wowlan failed"); in hostapd_driver_init()
872 struct hostapd_wmm_ac_params ac_be = {aCWmin, aCWmax - 4, 5, 0, 0}; in hostapd_config_read2()
874 struct hostapd_wmm_ac_params ac_vi = {aCWmin - 1, aCWmin, 3, in hostapd_config_read2()
877 struct hostapd_wmm_ac_params ac_vo = {aCWmin - 2, aCWmin - 1, 3, in hostapd_config_read2()
881 strncpy(ifname, dev->name, IFNAMSIZ); in hostapd_config_read2()
889 conf->wmm_ac_params[0] = ac_be; in hostapd_config_read2()
890 conf->wmm_ac_params[1] = ac_bk; in hostapd_config_read2()
891 conf->wmm_ac_params[2] = ac_vi; in hostapd_config_read2()
892 conf->wmm_ac_params[3] = ac_vo; in hostapd_config_read2()
895 conf->driver = wpa_drivers[0]; in hostapd_config_read2()
896 if (conf->driver == NULL) { in hostapd_config_read2()
901 conf->last_bss = conf->bss[0]; in hostapd_config_read2()
904 bss = conf->last_bss; in hostapd_config_read2()
905 bss->start_disabled = 1; in hostapd_config_read2()
906 bss->max_num_sta = CONFIG_WIFI_MGMT_AP_MAX_NUM_STA; in hostapd_config_read2()
907 bss->dtim_period = 1; in hostapd_config_read2()
908 os_strlcpy(conf->bss[0]->iface, ifname, sizeof(conf->bss[0]->iface)); in hostapd_config_read2()
909 bss->logger_stdout_level = HOSTAPD_LEVEL_INFO; in hostapd_config_read2()
910 bss->logger_stdout = 0xffff; in hostapd_config_read2()
911 bss->nas_identifier = os_strdup("ap.example.com"); in hostapd_config_read2()
912 os_memcpy(conf->country, "US ", 3); in hostapd_config_read2()
913 conf->hw_mode = HOSTAPD_MODE_IEEE80211G; in hostapd_config_read2()
914 bss->wps_state = WPS_STATE_CONFIGURED; in hostapd_config_read2()
915 bss->eap_server = 1; in hostapd_config_read2()
917 bss->ap_setup_locked = 1; in hostapd_config_read2()
919 conf->channel = 1; in hostapd_config_read2()
920 conf->acs = conf->channel == 0; in hostapd_config_read2()
922 conf->acs_num_scans = 1; in hostapd_config_read2()
924 conf->ieee80211n = 1; in hostapd_config_read2()
925 conf->ieee80211h = 0; in hostapd_config_read2()
926 conf->ieee80211d = 1; in hostapd_config_read2()
927 conf->acs_exclude_dfs = 1; in hostapd_config_read2()
928 conf->ht_capab |= HT_CAP_INFO_SHORT_GI20MHZ; in hostapd_config_read2()
929 bss->auth_algs = 1; in hostapd_config_read2()
930 bss->okc = 1; in hostapd_config_read2()
931 conf->no_pri_sec_switch = 1; in hostapd_config_read2()
932 conf->ht_op_mode_fixed = 1; in hostapd_config_read2()
933 conf->ieee80211ac = 1; in hostapd_config_read2()
934 conf->vht_oper_chwidth = CHANWIDTH_USE_HT; in hostapd_config_read2()
935 conf->vht_capab |= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MAX; in hostapd_config_read2()
937 conf->ieee80211ax = 1; in hostapd_config_read2()
938 conf->he_oper_chwidth = CHANWIDTH_USE_HT; in hostapd_config_read2()
939 conf->he_phy_capab.he_su_beamformer = 0; in hostapd_config_read2()
940 conf->he_phy_capab.he_su_beamformee = 1; in hostapd_config_read2()
941 conf->he_phy_capab.he_mu_beamformer = 0; in hostapd_config_read2()
942 conf->he_op.he_bss_color = 1; in hostapd_config_read2()
943 conf->he_op.he_default_pe_duration = 0; in hostapd_config_read2()
944 /* Set default basic MCS/NSS set to single stream MCS 0-7 */ in hostapd_config_read2()
945 conf->he_op.he_basic_mcs_nss_set = 0xfffc; in hostapd_config_read2()
948 for (i = 0; i < conf->num_bss; i++) { in hostapd_config_read2()
949 hostapd_set_security_params(conf->bss[i], 1); in hostapd_config_read2()
982 os_strlcpy(iface->conf->bss[0]->iface, if_name, in hostapd_interface_init()
983 sizeof(iface->conf->bss[0]->iface)); in hostapd_interface_init()
986 iface->interfaces = interfaces; in hostapd_interface_init()
989 if (iface->bss[0]->conf->logger_stdout_level > 0) { in hostapd_interface_init()
990 iface->bss[0]->conf->logger_stdout_level--; in hostapd_interface_init()
994 if (iface->conf->bss[0]->iface[0] == '\0' && in hostapd_interface_init()
995 !hostapd_drv_none(iface->bss[0])) { in hostapd_interface_init()
997 "Interface name not specified in %s, nor by '-i' parameter", in hostapd_interface_init()
1003 iface->bss[0]->is_hostapd = 1; in hostapd_interface_init()
1010 struct hapd_interfaces *interfaces = &ctx->hostapd; in zephyr_hostapd_init()
1023 interfaces->reload_config = hostapd_reload_config; in zephyr_hostapd_init()
1024 interfaces->config_read_cb = hostapd_config_read2; in zephyr_hostapd_init()
1025 interfaces->for_each_interface = hostapd_for_each_interface; in zephyr_hostapd_init()
1026 interfaces->driver_init = hostapd_driver_init; in zephyr_hostapd_init()
1027 interfaces->global_ctrl_sock = -1; in zephyr_hostapd_init()
1028 dl_list_init(&interfaces->global_ctrl_dst); in zephyr_hostapd_init()
1032 interfaces->dpp = dpp_global_init(&dpp_conf); in zephyr_hostapd_init()
1033 if (!interfaces->dpp) { in zephyr_hostapd_init()
1038 interfaces->count = 1; in zephyr_hostapd_init()
1039 if (interfaces->count || num_bss_configs) { in zephyr_hostapd_init()
1040 interfaces->iface = os_calloc(interfaces->count + num_bss_configs, in zephyr_hostapd_init()
1042 if (interfaces->iface == NULL) { in zephyr_hostapd_init()
1043 wpa_printf(MSG_ERROR, "malloc failed"); in zephyr_hostapd_init()
1049 wpa_printf(MSG_ERROR, "Failed to initialize global context"); in zephyr_hostapd_init()
1057 ret = net_if_get_name(iface, ifname, sizeof(ifname) - 1); in zephyr_hostapd_init()
1063 for (i = 0; i < interfaces->count; i++) { in zephyr_hostapd_init()
1064 interfaces->iface[i] = hostapd_interface_init(interfaces, ifname, in zephyr_hostapd_init()
1066 if (!interfaces->iface[i]) { in zephyr_hostapd_init()
1067 wpa_printf(MSG_ERROR, "Failed to initialize interface"); in zephyr_hostapd_init()
1071 interfaces->iface[i]->need_to_start_in_sync = 0; in zephyr_hostapd_init()
1079 * co-ex scans, ACS, or DFS are needed to determine channel parameters. in zephyr_hostapd_init()
1083 interfaces->terminate_on_error = 0; in zephyr_hostapd_init()
1084 for (i = 0; i < interfaces->count; i++) { in zephyr_hostapd_init()
1085 if (hostapd_driver_init(interfaces->iface[i])) { in zephyr_hostapd_init()
1089 interfaces->iface[i]->enable_iface_cb = hostapd_enable_iface_cb; in zephyr_hostapd_init()
1090 interfaces->iface[i]->disable_iface_cb = hostapd_disable_iface_cb; in zephyr_hostapd_init()
1091 zephyr_hostapd_ctrl_init((void *)interfaces->iface[i]->bss[0]); in zephyr_hostapd_init()
1107 return wpa_s->ifname; in zephyr_hostap_msg_ifname_cb()
1112 if (hapd && hapd->conf) { in zephyr_hostap_msg_ifname_cb()
1113 return hapd->conf->iface; in zephyr_hostap_msg_ifname_cb()
1140 /* Needed for crypto operation as default is no-op and fails */ in handler()
1150 k_work_queue_init(&ctx->iface_wq); in handler()
1151 k_work_queue_start(&ctx->iface_wq, iface_wq_stack, in handler()
1156 k_work_init(&ctx->iface_work, iface_work_handler); in handler()
1161 ctx->supplicant = wpa_supplicant_init(¶ms); in handler()
1162 if (ctx->supplicant == NULL) { in handler()
1163 LOG_ERR("Failed to initialize %s", "wpa_supplicant"); in handler()
1170 LOG_ERR("Failed to initialize %s", "FST"); in handler()
1176 LOG_WRN("Failed to add CLI FST ctrl"); in handler()
1190 (void)wpa_supplicant_run(ctx->supplicant); in handler()
1192 supplicant_generate_state_event(ctx->if_name, NET_EVENT_SUPPLICANT_CMD_NOT_READY, 0); in handler()
1194 eloop_unregister_read_sock(ctx->event_socketpair[0]); in handler()
1201 wpa_supplicant_deinit(ctx->supplicant); in handler()
1203 zsock_close(ctx->event_socketpair[0]); in handler()
1204 zsock_close(ctx->event_socketpair[1]); in handler()