Lines Matching +full:pn +full:- +full:retry +full:- +full:params
2 * hostapd / UNIX domain socket -based control interface
3 * Copyright (c) 2004-2018, Jouni Malinen <j@w1.fi>
93 return ctrl_iface_attach(&hapd->ctrl_dst, from, fromlen, input);
101 return ctrl_iface_detach(&hapd->ctrl_dst, from, fromlen);
110 return ctrl_iface_level(&hapd->ctrl_dst, from, fromlen, level);
123 return -1;
133 return -1;
151 return -1;
170 return -1;
206 return -1;
211 return -1;
220 ret = os_snprintf(buf, buflen, "FAIL-CHECKSUM\n");
222 return -1;
229 return -1;
245 return -1;
250 return -1;
253 return -1;
276 return -1;
280 return -1;
302 return -1;
335 return -1;
350 return -1;
358 return -1;
360 if (os_strcmp(pos, "WPS-CR") == 0)
365 return -1;
389 return -1;
395 return -1;
400 return -1;
405 return -1;
410 return -1;
413 return -1;
419 return -1;
426 return -1;
431 return -1;
439 ret = -1;
471 return -1;
478 return -1;
485 return -1;
493 return -1;
495 return -1;
499 return -1;
511 return -1;
538 return "Timed-out";
556 ret = os_snprintf(pos, end - pos, "PBC Status: %s\n",
557 pbc_status_str(hapd->wps_stats.pbc_status));
559 if (os_snprintf_error(end - pos, ret))
560 return pos - buf;
563 ret = os_snprintf(pos, end - pos, "Last WPS result: %s\n",
564 (hapd->wps_stats.status == WPS_STATUS_SUCCESS ?
566 (hapd->wps_stats.status == WPS_STATUS_FAILURE ?
569 if (os_snprintf_error(end - pos, ret))
570 return pos - buf;
573 /* If status == Failure - Add possible Reasons */
574 if(hapd->wps_stats.status == WPS_STATUS_FAILURE &&
575 hapd->wps_stats.failure_reason > 0) {
576 ret = os_snprintf(pos, end - pos,
578 wps_ei_str(hapd->wps_stats.failure_reason));
580 if (os_snprintf_error(end - pos, ret))
581 return pos - buf;
585 if (hapd->wps_stats.status) {
586 ret = os_snprintf(pos, end - pos, "Peer Address: " MACSTR "\n",
587 MAC2STR(hapd->wps_stats.peer_addr));
589 if (os_snprintf_error(end - pos, ret))
590 return pos - buf;
594 return pos - buf;
608 return -1;
614 return -1;
633 /* <STA MAC Addr> <Code(0/1)> <Re-auth-Delay(sec)> [URL] */
635 return -1;
639 return -1;
645 return -1;
658 return -1;
665 wpa_printf(MSG_DEBUG, "HS 2.0: Send WNM-Notification to " MACSTR
688 return -1;
694 return -1;
706 return -1;
712 return -1;
715 os_memcpy(hapd->conf->qos_map_set, qos_map_set, count);
716 hapd->conf->qos_map_set_len = count;
728 u8 *qos_map_set = hapd->conf->qos_map_set;
729 u8 qos_map_set_len = hapd->conf->qos_map_set_len;
734 return -1;
738 return -1;
745 return -1;
748 if (!sta->qos_map_enabled) {
751 return -1;
756 return -1;
766 ret = hostapd_drv_send_action(hapd, hapd->iface->freq, 0, addr,
788 return -1;
796 return -1;
801 return -1;
806 return -1;
825 WPA_ASSERT(hapd->conf->wpa_key_mgmt);
827 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_PSK) {
828 ret = os_snprintf(pos, end - pos, "WPA-PSK ");
829 if (os_snprintf_error(end - pos, ret))
830 return pos - buf;
833 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_IEEE8021X) {
834 ret = os_snprintf(pos, end - pos, "WPA-EAP ");
835 if (os_snprintf_error(end - pos, ret))
836 return pos - buf;
840 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_FT_PSK) {
841 ret = os_snprintf(pos, end - pos, "FT-PSK ");
842 if (os_snprintf_error(end - pos, ret))
843 return pos - buf;
846 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_FT_IEEE8021X) {
847 ret = os_snprintf(pos, end - pos, "FT-EAP ");
848 if (os_snprintf_error(end - pos, ret))
849 return pos - buf;
853 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_FT_IEEE8021X_SHA384) {
854 ret = os_snprintf(pos, end - pos, "FT-EAP-SHA384 ");
855 if (os_snprintf_error(end - pos, ret))
856 return pos - buf;
861 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_FT_SAE) {
862 ret = os_snprintf(pos, end - pos, "FT-SAE ");
863 if (os_snprintf_error(end - pos, ret))
864 return pos - buf;
867 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_FT_SAE_EXT_KEY) {
868 ret = os_snprintf(pos, end - pos, "FT-SAE-EXT-KEY ");
869 if (os_snprintf_error(end - pos, ret))
870 return pos - buf;
875 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_FT_FILS_SHA256) {
876 ret = os_snprintf(pos, end - pos, "FT-FILS-SHA256 ");
877 if (os_snprintf_error(end - pos, ret))
878 return pos - buf;
881 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_FT_FILS_SHA384) {
882 ret = os_snprintf(pos, end - pos, "FT-FILS-SHA384 ");
883 if (os_snprintf_error(end - pos, ret))
884 return pos - buf;
889 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_PSK_SHA256) {
890 ret = os_snprintf(pos, end - pos, "WPA-PSK-SHA256 ");
891 if (os_snprintf_error(end - pos, ret))
892 return pos - buf;
895 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_IEEE8021X_SHA256) {
896 ret = os_snprintf(pos, end - pos, "WPA-EAP-SHA256 ");
897 if (os_snprintf_error(end - pos, ret))
898 return pos - buf;
902 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_SAE) {
903 ret = os_snprintf(pos, end - pos, "SAE ");
904 if (os_snprintf_error(end - pos, ret))
905 return pos - buf;
908 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_SAE_EXT_KEY) {
909 ret = os_snprintf(pos, end - pos, "SAE-EXT-KEY ");
910 if (os_snprintf_error(end - pos, ret))
911 return pos - buf;
915 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_IEEE8021X_SUITE_B) {
916 ret = os_snprintf(pos, end - pos, "WPA-EAP-SUITE-B ");
917 if (os_snprintf_error(end - pos, ret))
918 return pos - buf;
921 if (hapd->conf->wpa_key_mgmt &
923 ret = os_snprintf(pos, end - pos,
924 "WPA-EAP-SUITE-B-192 ");
925 if (os_snprintf_error(end - pos, ret))
926 return pos - buf;
930 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_FILS_SHA256) {
931 ret = os_snprintf(pos, end - pos, "FILS-SHA256 ");
932 if (os_snprintf_error(end - pos, ret))
933 return pos - buf;
936 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_FILS_SHA384) {
937 ret = os_snprintf(pos, end - pos, "FILS-SHA384 ");
938 if (os_snprintf_error(end - pos, ret))
939 return pos - buf;
945 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_OWE) {
946 ret = os_snprintf(pos, end - pos, "OWE ");
947 if (os_snprintf_error(end - pos, ret))
948 return pos - buf;
954 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_DPP) {
955 ret = os_snprintf(pos, end - pos, "DPP ");
956 if (os_snprintf_error(end - pos, ret))
957 return pos - buf;
962 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_IEEE8021X_SHA384) {
963 ret = os_snprintf(pos, end - pos, "WPA-EAP-SHA384 ");
964 if (os_snprintf_error(end - pos, ret))
965 return pos - buf;
970 if (pos > buf && *(pos - 1) == ' ') {
971 *(pos - 1) = '\0';
972 pos--;
975 return pos - buf;
988 ret = os_snprintf(pos, end - pos, "bssid=" MACSTR "\n"
990 MAC2STR(hapd->own_addr),
991 wpa_ssid_txt(hapd->conf->ssid.ssid,
992 hapd->conf->ssid.ssid_len));
993 if (os_snprintf_error(end - pos, ret))
994 return pos - buf;
997 if ((hapd->conf->config_id)) {
998 ret = os_snprintf(pos, end - pos, "config_id=%s\n",
999 hapd->conf->config_id);
1000 if (os_snprintf_error(end - pos, ret))
1001 return pos - buf;
1006 ret = os_snprintf(pos, end - pos, "wps_state=%s\n",
1007 hapd->conf->wps_state == 0 ? "disabled" :
1008 (hapd->conf->wps_state == 1 ? "not configured" :
1010 if (os_snprintf_error(end - pos, ret))
1011 return pos - buf;
1014 if (hapd->conf->wps_state && hapd->conf->wpa &&
1015 hapd->conf->ssid.wpa_passphrase) {
1016 ret = os_snprintf(pos, end - pos, "passphrase=%s\n",
1017 hapd->conf->ssid.wpa_passphrase);
1018 if (os_snprintf_error(end - pos, ret))
1019 return pos - buf;
1023 if (hapd->conf->wps_state && hapd->conf->wpa &&
1024 hapd->conf->ssid.wpa_psk &&
1025 hapd->conf->ssid.wpa_psk->group) {
1028 hapd->conf->ssid.wpa_psk->psk, PMK_LEN);
1029 ret = os_snprintf(pos, end - pos, "psk=%s\n", hex);
1030 if (os_snprintf_error(end - pos, ret))
1031 return pos - buf;
1035 if (hapd->conf->multi_ap) {
1036 struct hostapd_ssid *ssid = &hapd->conf->multi_ap_backhaul_ssid;
1038 ret = os_snprintf(pos, end - pos, "multi_ap=%d\n",
1039 hapd->conf->multi_ap);
1040 if (os_snprintf_error(end - pos, ret))
1041 return pos - buf;
1044 if (ssid->ssid_len) {
1045 ret = os_snprintf(pos, end - pos,
1047 wpa_ssid_txt(ssid->ssid,
1048 ssid->ssid_len));
1049 if (os_snprintf_error(end - pos, ret))
1050 return pos - buf;
1054 if (hapd->conf->wps_state && hapd->conf->wpa &&
1055 ssid->wpa_passphrase) {
1056 ret = os_snprintf(pos, end - pos,
1058 ssid->wpa_passphrase);
1059 if (os_snprintf_error(end - pos, ret))
1060 return pos - buf;
1064 if (hapd->conf->wps_state && hapd->conf->wpa &&
1065 ssid->wpa_psk &&
1066 ssid->wpa_psk->group) {
1069 wpa_snprintf_hex(hex, sizeof(hex), ssid->wpa_psk->psk,
1071 ret = os_snprintf(pos, end - pos,
1075 if (os_snprintf_error(end - pos, ret))
1076 return pos - buf;
1082 if (hapd->conf->wpa) {
1083 ret = os_snprintf(pos, end - pos, "wpa=%d\n", hapd->conf->wpa);
1084 if (os_snprintf_error(end - pos, ret))
1085 return pos - buf;
1089 if (hapd->conf->wpa && hapd->conf->wpa_key_mgmt) {
1090 ret = os_snprintf(pos, end - pos, "key_mgmt=");
1091 if (os_snprintf_error(end - pos, ret))
1092 return pos - buf;
1095 pos += hostapd_ctrl_iface_get_key_mgmt(hapd, pos, end - pos);
1097 ret = os_snprintf(pos, end - pos, "\n");
1098 if (os_snprintf_error(end - pos, ret))
1099 return pos - buf;
1103 if (hapd->conf->wpa) {
1104 ret = os_snprintf(pos, end - pos, "group_cipher=%s\n",
1105 wpa_cipher_txt(hapd->conf->wpa_group));
1106 if (os_snprintf_error(end - pos, ret))
1107 return pos - buf;
1111 if ((hapd->conf->wpa & WPA_PROTO_RSN) && hapd->conf->rsn_pairwise) {
1112 ret = os_snprintf(pos, end - pos, "rsn_pairwise_cipher=");
1113 if (os_snprintf_error(end - pos, ret))
1114 return pos - buf;
1117 ret = wpa_write_ciphers(pos, end, hapd->conf->rsn_pairwise,
1120 return pos - buf;
1123 ret = os_snprintf(pos, end - pos, "\n");
1124 if (os_snprintf_error(end - pos, ret))
1125 return pos - buf;
1129 if ((hapd->conf->wpa & WPA_PROTO_WPA) && hapd->conf->wpa_pairwise) {
1130 ret = os_snprintf(pos, end - pos, "wpa_pairwise_cipher=");
1131 if (os_snprintf_error(end - pos, ret))
1132 return pos - buf;
1135 ret = wpa_write_ciphers(pos, end, hapd->conf->wpa_pairwise,
1138 return pos - buf;
1141 ret = os_snprintf(pos, end - pos, "\n");
1142 if (os_snprintf_error(end - pos, ret))
1143 return pos - buf;
1147 if (hapd->conf->wpa && hapd->conf->wpa_deny_ptk0_rekey) {
1148 ret = os_snprintf(pos, end - pos, "wpa_deny_ptk0_rekey=%d\n",
1149 hapd->conf->wpa_deny_ptk0_rekey);
1150 if (os_snprintf_error(end - pos, ret))
1151 return pos - buf;
1155 if ((hapd->conf->wpa & WPA_PROTO_RSN) && hapd->conf->extended_key_id) {
1156 ret = os_snprintf(pos, end - pos, "extended_key_id=%d\n",
1157 hapd->conf->extended_key_id);
1158 if (os_snprintf_error(end - pos, ret))
1159 return pos - buf;
1163 return pos - buf;
1187 return -1;
1208 return -1;
1218 ret = -1;
1223 wpa_printf(MSG_DEBUG, "WPS: Testing - force WPS "
1231 wpa_printf(MSG_DEBUG, "WPS: Testing - stub_cred=%d",
1235 wpa_printf(MSG_DEBUG, "WPS: Testing - wps_corrupt_pkhash=%d",
1240 hapd->ext_mgmt_frame_handling = atoi(value);
1242 hapd->ext_eapol_frame_io = atoi(value);
1244 hapd->force_backlog_bytes = atoi(value);
1247 os_free(hapd->dpp_config_obj_override);
1248 hapd->dpp_config_obj_override = os_strdup(value);
1250 os_free(hapd->dpp_discovery_override);
1251 hapd->dpp_discovery_override = os_strdup(value);
1253 os_free(hapd->dpp_groups_override);
1254 hapd->dpp_groups_override = os_strdup(value);
1257 hapd->dpp_ignore_netaccesskey_mismatch = atoi(value);
1268 if (!hapd->conf->mbo_enabled)
1269 return -1;
1273 return -1;
1275 hapd->mbo_assoc_disallow = val;
1276 ieee802_11_update_beacons(hapd->iface);
1285 os_free(hapd->dpp_configurator_params);
1286 hapd->dpp_configurator_params = os_strdup(value);
1288 dpp_controller_set_params(hapd->iface->interfaces->dpp, value);
1291 hapd->dpp_init_max_tries = atoi(value);
1293 hapd->dpp_init_retry_time = atoi(value);
1295 hapd->dpp_resp_wait_time = atoi(value);
1297 hapd->dpp_resp_max_tries = atoi(value);
1299 hapd->dpp_resp_retry_time = atoi(value);
1304 ret = hostapd_set_iface(hapd->iconf, hapd->conf, cmd, value);
1316 hapd->parameter_set_count++;
1317 if (ieee802_11_update_beacons(hapd->iface))
1323 if (hapd->started)
1324 hostapd_setup_sae_pt(hapd->conf);
1326 wpa_auth_set_transition_disable(hapd->wpa_auth,
1327 hapd->conf->transition_disable);
1332 wpa_auth_set_ft_rsnxe_used(hapd->wpa_auth,
1333 hapd->conf->ft_rsnxe_used);
1336 hapd->wpa_auth, WPA_AUTH_OCV_OVERRIDE_EAPOL_M3,
1340 hapd->wpa_auth, WPA_AUTH_OCV_OVERRIDE_EAPOL_G1,
1344 hapd->wpa_auth, WPA_AUTH_OCV_OVERRIDE_FT_ASSOC,
1348 hapd->wpa_auth,
1367 return -1;
1372 return -1;
1376 return -1;
1384 return -1;
1394 return -1;
1404 return -1;
1414 return -1;
1432 pmk = wpa_auth_get_pmk(sta->wpa_sm, &pmk_len);
1434 for (psk = hapd->conf->ssid.wpa_psk; pmk && psk; psk = psk->next) {
1436 os_memcmp(psk->psk, pmk, pmk_len) == 0;
1437 sta_match = psk->group == 0 &&
1438 ether_addr_equal(sta->addr, psk->addr);
1439 bss_match = psk->group == 1;
1446 " PSK/passphrase no longer valid - disconnect",
1447 MAC2STR(sta->addr));
1449 hostapd_drv_sta_deauth(hapd, sta->addr, reason);
1458 struct hostapd_bss_config *conf = hapd->conf;
1461 hostapd_config_clear_wpa_psk(&conf->ssid.wpa_psk);
1465 wpa_printf(MSG_ERROR, "Reloading WPA-PSK passwords failed: %d",
1467 return -1;
1486 struct hostapd_bss_config *conf = hapd->conf;
1491 for (r0kh = conf->r0kh_list; r0kh; r0kh=r0kh->next) {
1492 start_pos = pos - buf;
1493 ret = os_snprintf(pos, end - pos, "r0kh=" MACSTR " ",
1494 MAC2STR(r0kh->addr));
1495 if (os_snprintf_error(end - pos, ret))
1498 if (r0kh->id_len + 1 >= (size_t) (end - pos))
1500 os_memcpy(pos, r0kh->id, r0kh->id_len);
1501 pos += r0kh->id_len;
1503 pos += wpa_snprintf_hex(pos, end - pos, r0kh->key,
1504 sizeof(r0kh->key));
1505 ret = os_snprintf(pos, end - pos, "\n");
1506 if (os_snprintf_error(end - pos, ret))
1511 for (r1kh = conf->r1kh_list; r1kh; r1kh=r1kh->next) {
1512 start_pos = pos - buf;
1513 ret = os_snprintf(pos, end - pos, "r1kh=" MACSTR " " MACSTR " ",
1514 MAC2STR(r1kh->addr), MAC2STR(r1kh->id));
1515 if (os_snprintf_error(end - pos, ret))
1518 pos += wpa_snprintf_hex(pos, end - pos, r1kh->key,
1519 sizeof(r1kh->key));
1520 ret = os_snprintf(pos, end - pos, "\n");
1521 if (os_snprintf_error(end - pos, ret))
1526 return pos - buf;
1532 struct hostapd_bss_config *conf = hapd->conf;
1537 err = hostapd_config_read_rxkh_file(conf, conf->rxkh_file);
1541 return -1;
1564 return -1;
1569 else if (os_strcmp(cmd, "CAC-FINISHED") == 0)
1571 else if (os_strcmp(cmd, "CAC-ABORTED") == 0)
1573 else if (os_strcmp(cmd, "NOP-FINISHED") == 0)
1578 return -1;
1621 return -1;
1626 return -1;
1630 return -1;
1648 if (!hapd->ext_mgmt_frame_handling)
1649 return -1;
1670 return -1;
1675 return -1;
1681 return -1;
1690 hapd->ext_mgmt_frame_handling = 0;
1692 hapd->ext_mgmt_frame_handling = 1;
1709 if (!hapd->ext_mgmt_frame_handling)
1710 return -1;
1737 return -1;
1742 return -1;
1747 return -1;
1751 return -1;
1760 hapd->ext_mgmt_frame_handling = 0;
1762 hapd->ext_mgmt_frame_handling = 1;
1782 return -1;
1789 return -1;
1794 return -1;
1798 return -1;
1822 return -1;
1829 len = pos2 - pos;
1835 return -1;
1841 return -1;
1844 prev = hapd->ext_eapol_frame_io;
1845 hapd->ext_eapol_frame_io = 0;
1847 hapd->ext_eapol_frame_io = prev;
1871 #define HWSIM_IP_LEN (HWSIM_PACKETLEN - sizeof(struct ether_header))
1885 "test data: RX - ignore unexpected length %d",
1897 "test data: RX - ignore unexpected IP header");
1901 for (i = 0; i < ntohs(ip.ip_len) - sizeof(ip); i++) {
1904 "test data: RX - ignore mismatching payload");
1913 wpa_msg(hapd->msg_ctx, MSG_INFO, "DATA-TEST-RX " MACSTR " " MACSTR "%s",
1914 MAC2STR(eth->ether_dhost), MAC2STR(eth->ether_shost), extra);
1924 const u8 *addr = hapd->own_addr;
1927 if (hapd->l2_test) {
1928 l2_packet_deinit(hapd->l2_test);
1929 hapd->l2_test = NULL;
1930 wpa_dbg(hapd->msg_ctx, MSG_DEBUG,
1936 if (hapd->l2_test)
1943 ifname = hapd->conf->iface;
1946 if (hapd->conf->mld_ap)
1947 addr = hapd->mld->mld_addr;
1949 hapd->l2_test = l2_packet_init(ifname, addr,
1952 if (hapd->l2_test == NULL)
1953 return -1;
1955 wpa_dbg(hapd->msg_ctx, MSG_DEBUG, "test data: Enabled");
1975 if (hapd->l2_test == NULL)
1976 return -1;
1983 return -1;
1989 return -1;
1994 return -1;
2001 return -1;
2006 os_memcpy(eth->ether_dhost, dst, ETH_ALEN);
2007 os_memcpy(eth->ether_shost, src, ETH_ALEN);
2008 eth->ether_type = htons(ETHERTYPE_IP);
2011 ip->ip_hl = 5;
2012 ip->ip_v = 4;
2013 ip->ip_ttl = 64;
2014 ip->ip_tos = tos;
2015 ip->ip_len = htons(send_len);
2016 ip->ip_p = 1;
2017 ip->ip_src.s_addr = htonl(192U << 24 | 168 << 16 | 1 << 8 | 1);
2018 ip->ip_dst.s_addr = htonl(192U << 24 | 168 << 16 | 1 << 8 | 2);
2019 ip->ip_sum = ipv4_hdr_checksum(ip, sizeof(*ip));
2021 for (i = 0; i < send_len - sizeof(*ip); i++)
2024 if (l2_packet_send(hapd->l2_test, dst, ETHERTYPE_IP, &buf[2],
2026 return -1;
2028 wpa_dbg(hapd->msg_ctx, MSG_DEBUG, "test data: TX dst=" MACSTR
2043 int res = -1;
2044 const char *ifname = hapd->conf->iface;
2051 return -1;
2057 return -1;
2062 return -1;
2068 ethertype = ntohs(eth->ether_type);
2070 l2 = l2_packet_init(ifname, hapd->own_addr, ethertype,
2075 res = l2_packet_send(l2, eth->ether_dhost, ethertype, buf, len);
2076 wpa_dbg(hapd->msg_ctx, MSG_DEBUG, "test data: TX frame res=%d", res);
2082 return res < 0 ? -1 : 0;
2095 return -1;
2098 if (hapd->last_bigtk_alg == WPA_ALG_NONE)
2099 return -1;
2105 if (hostapd_drv_set_key(hapd->conf->iface, hapd,
2106 hapd->last_bigtk_alg,
2108 hapd->last_bigtk_key_idx, 0, 1, NULL, 0,
2109 zero, hapd->last_bigtk_len,
2111 return -1;
2114 return hostapd_drv_set_key(hapd->conf->iface, hapd,
2115 hapd->last_bigtk_alg,
2117 hapd->last_bigtk_key_idx, 0, 1, NULL,
2118 0, hapd->last_bigtk,
2119 hapd->last_bigtk_len,
2124 if (hapd->last_igtk_alg == WPA_ALG_NONE)
2125 return -1;
2131 if (hostapd_drv_set_key(hapd->conf->iface, hapd,
2132 hapd->last_igtk_alg,
2134 hapd->last_igtk_key_idx, 0, 1, NULL, 0,
2135 zero, hapd->last_igtk_len,
2137 return -1;
2140 return hostapd_drv_set_key(hapd->conf->iface, hapd,
2141 hapd->last_igtk_alg,
2143 hapd->last_igtk_key_idx, 0, 1, NULL,
2144 0, hapd->last_igtk,
2145 hapd->last_igtk_len,
2150 if (hapd->last_gtk_alg == WPA_ALG_NONE)
2151 return -1;
2153 wpa_printf(MSG_INFO, "TESTING: Reset PN for GTK");
2157 if (hostapd_drv_set_key(hapd->conf->iface, hapd,
2158 hapd->last_gtk_alg,
2160 hapd->last_gtk_key_idx, 0, 1, NULL, 0,
2161 zero, hapd->last_gtk_len,
2163 return -1;
2166 return hostapd_drv_set_key(hapd->conf->iface, hapd,
2167 hapd->last_gtk_alg,
2169 hapd->last_gtk_key_idx, 0, 1, NULL,
2170 0, hapd->last_gtk,
2171 hapd->last_gtk_len,
2177 return -1;
2179 if (sta->last_tk_alg == WPA_ALG_NONE)
2180 return -1;
2182 wpa_printf(MSG_INFO, "TESTING: Reset PN for " MACSTR,
2183 MAC2STR(sta->addr));
2187 if (hostapd_drv_set_key(hapd->conf->iface, hapd, sta->last_tk_alg,
2188 sta->addr, sta->last_tk_key_idx, 0, 1, NULL, 0,
2189 zero, sta->last_tk_len,
2191 return -1;
2194 return hostapd_drv_set_key(hapd->conf->iface, hapd, sta->last_tk_alg,
2195 sta->addr, sta->last_tk_key_idx, 0, 1, NULL,
2196 0, sta->last_tk, sta->last_tk_len,
2216 return -1;
2219 return -1;
2222 return -1;
2227 return -1;
2232 return -1;
2235 return -1;
2238 return -1;
2241 return -1;
2242 key_len = (os_strchr(pos, ' ') - pos) / 2;
2244 return -1;
2247 return -1;
2253 return -1;
2256 return hostapd_drv_set_key(hapd->conf->iface, hapd, alg, addr, idx, 0,
2267 MAC2STR(sta->addr));
2271 hostapd_drv_set_key(hapd->conf->iface, hapd, sta->last_tk_alg,
2272 sta->addr, sta->last_tk_key_idx, 0, 1, NULL, 0,
2273 sta->last_tk, sta->last_tk_len,
2285 return -1;
2288 if (!sta || !sta->wpa_sm)
2289 return -1;
2291 if (plain && sta->last_tk_alg == WPA_ALG_NONE)
2295 MAC2STR(sta->addr));
2296 hostapd_drv_set_key(hapd->conf->iface, hapd, WPA_ALG_NONE,
2297 sta->addr, sta->last_tk_key_idx, 0, 0, NULL,
2301 wpa_printf(MSG_INFO, "TESTING: Send M1 to " MACSTR, MAC2STR(sta->addr));
2302 return wpa_auth_resend_m1(sta->wpa_sm,
2303 os_strstr(cmd, "change-anonce") != NULL,
2315 return -1;
2318 if (!sta || !sta->wpa_sm)
2319 return -1;
2321 if (plain && sta->last_tk_alg == WPA_ALG_NONE)
2325 MAC2STR(sta->addr));
2326 hostapd_drv_set_key(hapd->conf->iface, hapd, WPA_ALG_NONE,
2327 sta->addr, sta->last_tk_key_idx, 0, 0, NULL,
2331 wpa_printf(MSG_INFO, "TESTING: Send M3 to " MACSTR, MAC2STR(sta->addr));
2332 return wpa_auth_resend_m3(sta->wpa_sm,
2345 return -1;
2348 if (!sta || !sta->wpa_sm)
2349 return -1;
2351 if (plain && sta->last_tk_alg == WPA_ALG_NONE)
2355 MAC2STR(sta->addr));
2356 hostapd_drv_set_key(hapd->conf->iface, hapd, WPA_ALG_NONE,
2357 sta->addr, sta->last_tk_key_idx, 0, 0, NULL,
2363 MACSTR, MAC2STR(sta->addr));
2364 return wpa_auth_resend_group_m1(sta->wpa_sm,
2375 return -1;
2378 if (!sta || !sta->wpa_sm)
2379 return -1;
2381 return wpa_auth_rekey_ptk(hapd->wpa_auth, sta->wpa_sm);
2390 pmksa = wpa_auth_pmksa_get(hapd->wpa_auth, addr, NULL);
2392 return -1;
2394 return wpa_snprintf_hex(buf, buflen, pmksa->pmk, pmksa->pmk_len);
2407 return -1;
2410 if (!sta || !sta->wpa_sm) {
2415 pmk = wpa_auth_get_pmk(sta->wpa_sm, &pmk_len);
2437 return -1;
2441 match_len = end - pos;
2447 return -1;
2457 static int hostapd_ctrl_check_freq_params(struct hostapd_freq_params *params,
2462 if (is_6ghz_freq(params->freq)) {
2467 params->he_enabled = 1;
2469 if (params->center_freq1) {
2470 if (params->freq == 5935)
2471 idx = (params->center_freq1 - 5925) / 5;
2473 idx = (params->center_freq1 - 5950) / 5;
2477 bw_idx[bw] != params->bandwidth)
2478 return -1;
2480 } else { /* Non-6 GHz channel */
2483 if (params->he_enabled || params->eht_enabled) {
2484 params->he_enabled = 1;
2487 * band as defined in IEEE Std 802.11ax-2021, 4.3.15a.
2490 if (IS_5GHZ(params->freq))
2491 params->vht_enabled = 1;
2493 params->ht_enabled = 1;
2497 switch (params->bandwidth) {
2500 /* fall-through */
2502 if (params->center_freq1 &&
2503 params->center_freq1 != params->freq)
2504 return -1;
2506 if (params->center_freq2 || params->sec_channel_offset)
2507 return -1;
2510 return -1;
2513 if (params->center_freq2 || !params->sec_channel_offset)
2514 return -1;
2517 return -1;
2519 if (!params->center_freq1)
2521 switch (params->sec_channel_offset) {
2523 if (params->freq + 10 != params->center_freq1)
2524 return -1;
2526 case -1:
2527 if (params->freq - 10 != params->center_freq1)
2528 return -1;
2531 return -1;
2535 if (!params->center_freq1 || !params->sec_channel_offset)
2538 switch (params->sec_channel_offset) {
2540 if (params->freq - 10 != params->center_freq1 &&
2541 params->freq + 30 != params->center_freq1)
2544 case -1:
2545 if (params->freq + 10 != params->center_freq1 &&
2546 params->freq - 30 != params->center_freq1)
2547 return -1;
2550 return -1;
2553 if (params->center_freq2 && punct_bitmap)
2554 return -1;
2557 if (params->center_freq2 &&
2558 params->center_freq1 - params->center_freq2 <= 80 &&
2559 params->center_freq2 - params->center_freq1 <= 80)
2563 if (!params->center_freq1 || params->center_freq2 ||
2564 !params->sec_channel_offset)
2565 return -1;
2567 switch (params->sec_channel_offset) {
2569 if (params->freq + 70 != params->center_freq1 &&
2570 params->freq + 30 != params->center_freq1 &&
2571 params->freq - 10 != params->center_freq1 &&
2572 params->freq - 50 != params->center_freq1)
2573 return -1;
2575 case -1:
2576 if (params->freq + 50 != params->center_freq1 &&
2577 params->freq + 10 != params->center_freq1 &&
2578 params->freq - 30 != params->center_freq1 &&
2579 params->freq - 70 != params->center_freq1)
2580 return -1;
2583 return -1;
2587 if (!params->center_freq1 || params->center_freq2 ||
2588 !params->sec_channel_offset)
2589 return -1;
2591 switch (params->sec_channel_offset) {
2593 if (params->freq + 150 != params->center_freq1 &&
2594 params->freq + 110 != params->center_freq1 &&
2595 params->freq + 70 != params->center_freq1 &&
2596 params->freq + 30 != params->center_freq1 &&
2597 params->freq - 10 != params->center_freq1 &&
2598 params->freq - 50 != params->center_freq1 &&
2599 params->freq - 90 != params->center_freq1 &&
2600 params->freq - 130 != params->center_freq1)
2601 return -1;
2603 case -1:
2604 if (params->freq + 130 != params->center_freq1 &&
2605 params->freq + 90 != params->center_freq1 &&
2606 params->freq + 50 != params->center_freq1 &&
2607 params->freq + 10 != params->center_freq1 &&
2608 params->freq - 30 != params->center_freq1 &&
2609 params->freq - 70 != params->center_freq1 &&
2610 params->freq - 110 != params->center_freq1 &&
2611 params->freq - 150 != params->center_freq1)
2612 return -1;
2617 return -1;
2623 if (!params->eht_enabled) {
2626 return -1;
2629 if (params->freq >= 2412 && params->freq <= 2484) {
2632 return -1;
2635 start_freq = params->center_freq1 - (params->bandwidth / 2);
2636 if (!is_punct_bitmap_valid(params->bandwidth,
2637 (params->freq - start_freq) / 20,
2640 return -1;
2665 settings.link_id = -1;
2667 if (iface->num_bss && iface->bss[0]->conf->mld_ap)
2668 settings.link_id = iface->bss[0]->mld_link_id;
2719 return -1;
2733 iface->is_ch_switch_dfs = true;
2738 for (i = 0; i < iface->num_bss; i++) {
2741 hostapd_chan_switch_config(iface->bss[i],
2744 err = hostapd_switch_channel(iface->bss[i], &settings);
2751 return (iface->num_bss == num_err) ? ret : 0;
2753 return -1;
2764 struct hostapd_data *hapd = iface->bss[0];
2774 return -1;
2777 /* Color value is expected to be [1-63]. If 0 comes, assumption is this
2781 if (iface->conf->he_op.he_bss_color_disabled) {
2784 return -1;
2787 iface->conf->he_op.he_bss_color_disabled = 1;
2789 for (i = 0; i < iface->num_bss; i++)
2790 ieee802_11_set_beacon(iface->bss[i]);
2795 if (color == iface->conf->he_op.he_bss_color) {
2796 if (!iface->conf->he_op.he_bss_color_disabled) {
2799 return -1;
2802 iface->conf->he_op.he_bss_color_disabled = 0;
2804 for (i = 0; i < iface->num_bss; i++)
2805 ieee802_11_set_beacon(iface->bss[i]);
2810 if (hapd->cca_in_progress) {
2813 return -1;
2816 iface->conf->he_op.he_bss_color_disabled = 0;
2818 for (i = 0; i < iface->num_bss; i++) {
2819 struct hostapd_data *bss = iface->bss[i];
2823 bss->cca_color = color;
2824 bss->cca_count = 10;
2845 return -1;
2862 if (sta->ht_capabilities && (sta->flags & WLAN_STA_HT)) {
2863 mcs_set = sta->ht_capabilities->supported_mcs_set;
2867 if (sta->vht_capabilities && (sta->flags & WLAN_STA_VHT)) {
2869 sta->vht_capabilities->vht_supported_mcs_set.rx_map);
2884 for (i = 7; i >= 0; i--) {
2909 ret = hostapd_drv_send_action(hapd, hapd->iface->freq, 0, addr,
2930 ret = hostapd_drv_send_action(hapd, hapd->iface->freq, 0, addr,
2948 if (is_6ghz_freq(hapd->iface->freq)) {
2950 return -1;
2954 hw_mode = hapd->iface->current_mode->mode;
2960 return -1;
2978 return -1;
2981 for (sta = hapd->sta_list; sta; sta = sta->next) {
2982 if ((sta->flags & WLAN_STA_VHT) && sta->vht_capabilities) {
2983 nss = hostapd_maxnss(hapd, sta) - 1;
2984 hostapd_ctrl_iface_notify_cw_vhtaction(hapd, sta->addr,
2990 if ((sta->flags & (WLAN_STA_HT | WLAN_STA_VHT)) ==
2991 WLAN_STA_HT && sta->ht_capabilities)
2992 hostapd_ctrl_iface_notify_cw_htaction(hapd, sta->addr,
3005 return radius_server_get_mib(hapd->radius_srv, reply,
3009 return -1;
3030 return -EINVAL;
3036 return -EINVAL;
3039 data_len = temp ? (size_t) (temp - pos) : os_strlen(pos);
3046 return -ENOBUFS;
3052 return -EINVAL;
3061 reply = wpabuf_alloc((buflen - 1) / 2);
3064 return -ENOBUFS;
3088 return -1;
3091 if (!sta || !sta->eapol_sm)
3092 return -1;
3094 eapol_auth_reauthenticate(sta->eapol_sm);
3106 return -1;
3111 return -1;
3115 if (!sta || !sta->eapol_sm)
3116 return -1;
3118 return eapol_auth_set_conf(sta->eapol_sm, param, pos);
3132 ret = os_snprintf(pos, end - pos, "Current level: %s\n"
3136 if (os_snprintf_error(end - pos, ret))
3156 return -1;
3172 struct hostapd_iface *iface = hapd->iface;
3177 if (!iface->num_sta_seen)
3186 dl_list_for_each_reverse(info, &iface->sta_seen,
3191 os_reltime_sub(&now, &info->last_seen, &age);
3192 ret = os_snprintf(pos, end - pos, MACSTR " %u %d\n",
3193 MAC2STR(info->addr), (unsigned int) age.sec,
3194 info->ssi_signal);
3195 if (os_snprintf_error(end - pos, ret))
3200 return pos - buf;
3212 return -1;
3230 "CTRL: REQ_RANGE - Bad destination address");
3231 return -1;
3236 return -1;
3240 return -1;
3244 return -1;
3248 return -1;
3255 return -1;
3261 return -1;
3269 "CTRL: REQ_RANGE - No FTM responder address");
3270 return -1;
3289 return -1;
3292 return -1;
3298 return -1;
3303 return -1;
3308 return -1;
3328 return -1;
3341 if (!(hapd->conf->radio_measurements[0] &
3345 return -1;
3360 int ret = -1;
3362 if (!(hapd->conf->radio_measurements[0] &
3366 return -1;
3371 return -1;
3378 return -1;
3382 return -1;
3388 return -1;
3399 return -1;
3473 return -1;
3482 return -1;
3497 (long long unsigned) iface->drv_flags);
3499 return -1;
3505 if (iface->drv_flags & (1LLU << i)) {
3506 ret = os_snprintf(pos, end - pos, "%s\n",
3508 if (os_snprintf_error(end - pos, ret))
3509 return -1;
3514 return pos - buf;
3525 (long long unsigned) iface->drv_flags2);
3527 return -1;
3533 if (iface->drv_flags2 & (1LLU << i)) {
3534 ret = os_snprintf(pos, end - pos, "%s\n",
3536 if (os_snprintf_error(end - pos, ret))
3537 return -1;
3542 return pos - buf;
3564 return -1;
3572 return -1;
3586 ret = -1;
3599 if (!iface || !iface->bss[0]->conf->mld_ap) {
3602 return -1;
3605 for (i = 0; i < iface->interfaces->count; ++i) {
3606 struct hostapd_iface *h_iface = iface->interfaces->iface[i];
3607 struct hostapd_data *h_hapd = h_iface->bss[0];
3609 if (!hostapd_is_ml_partner(h_hapd, iface->bss[0]))
3614 return -1;
3625 for (i = 0; i < iface->num_bss; i++)
3626 hostapd_bss_deinit_no_free(iface->bss[i]);
3634 if (!iface || !iface->bss[0]->conf->mld_ap) {
3637 return -1;
3643 for (i = 0; i < iface->interfaces->count; ++i) {
3644 struct hostapd_iface *h_iface = iface->interfaces->iface[i];
3645 struct hostapd_data *h_hapd = h_iface->bss[0];
3647 if (!hostapd_is_ml_partner(h_hapd, iface->bss[0]))
3654 for (i = 0; i < iface->interfaces->count; ++i) {
3655 struct hostapd_iface *h_iface = iface->interfaces->iface[i];
3656 struct hostapd_data *h_hapd = h_iface->bss[0];
3658 if (!hostapd_is_ml_partner(h_hapd, iface->bss[0]))
3663 return -1;
3685 ret = -1;
3703 struct nan_publish_params params;
3706 int ret = -1;
3709 os_memset(¶ms, 0, sizeof(params));
3711 params.unsolicited = true;
3712 params.solicited = true;
3714 params.fsd = true;
3723 params.ttl = atoi(token + 4);
3742 params.solicited = false;
3747 params.unsolicited = false;
3752 params.fsd = false;
3762 ssi, ¶ms);
3783 return -1;
3789 return -1;
3803 int ret = -1;
3840 struct nan_subscribe_params params;
3843 int ret = -1;
3846 os_memset(¶ms, 0, sizeof(params));
3855 params.active = true;
3860 params.ttl = atoi(token + 4);
3886 ¶ms);
3907 return -1;
3913 return -1;
3928 int ret = -1;
3941 return -1;
3998 reply_len = -1;
4006 } else if (os_strcmp(buf, "STATUS-DRIVER") == 0) {
4011 res = wpa_get_mib(hapd->wpa_auth, reply + reply_len,
4012 reply_size - reply_len);
4014 reply_len = -1;
4020 reply_size - reply_len);
4022 reply_len = -1;
4028 res = radius_client_get_mib(hapd->radius,
4030 reply_size - reply_len);
4032 reply_len = -1;
4040 } else if (os_strcmp(buf, "STA-FIRST") == 0) {
4046 } else if (os_strncmp(buf, "STA-NEXT ", 9) == 0) {
4051 reply_len = -1;
4054 reply_len = -1;
4057 reply_len = -1;
4061 reply_len = -1;
4064 reply_len = -1;
4067 reply_len = -1;
4070 reply_len = -1;
4078 reply_len = -1;
4081 reply_len = -1;
4085 reply_len = -1;
4090 reply_len = -1;
4096 reply_len = -1;
4099 reply_len = -1;
4105 reply_len = -1;
4112 reply_len = -1;
4124 reply_len = -1;
4130 reply_len = -1;
4133 reply_len = -1;
4138 reply_len = -1;
4141 reply_len = -1;
4146 reply_len = -1;
4149 reply_len = -1;
4152 reply_len = -1;
4155 reply_len = -1;
4162 reply_len = -1;
4167 if (hostapd_ctrl_iface_enable(hapd->iface))
4168 reply_len = -1;
4171 reply_len = -1;
4178 reply_len = -1;
4182 reply_len = -1;
4184 if (hostapd_reload_config(hapd->iface))
4185 reply_len = -1;
4187 if (hostapd_ctrl_iface_reload(hapd->iface))
4188 reply_len = -1;
4190 if (hostapd_ctrl_iface_disable(hapd->iface))
4191 reply_len = -1;
4194 reply_len = -1;
4198 reply_len = -1;
4201 reply_len = -1;
4205 reply_len = -1;
4208 reply_len = -1;
4211 reply_len = -1;
4214 reply_len = -1;
4217 reply_len = -1;
4220 reply_len = -1;
4223 reply_len = -1;
4226 reply_len = -1;
4231 reply_len = -1;
4236 reply_len = -1;
4239 reply_len = -1;
4242 reply_len = -1;
4245 reply_len = -1;
4248 reply_len = -1;
4251 reply_len = -1;
4253 if (wpa_auth_rekey_gtk(hapd->wpa_auth) < 0)
4254 reply_len = -1;
4260 reply_len = -1;
4263 if (hostapd_ctrl_iface_chan_switch(hapd->iface, buf + 12))
4264 reply_len = -1;
4267 if (hostapd_ctrl_iface_color_change(hapd->iface, buf + 13))
4268 reply_len = -1;
4272 reply_len = -1;
4279 radius_server_erp_flush(hapd->radius_srv);
4283 reply_len = -1;
4286 reply_len = -1;
4302 reply_len = -1;
4305 reply_len = -1;
4311 reply_len = -1;
4314 reply_len = -1;
4317 reply_len = -1;
4325 reply_len = hostapd_ctrl_driver_flags(hapd->iface, reply,
4328 reply_len = hostapd_ctrl_driver_flags2(hapd->iface, reply,
4335 &hapd->conf->accept_mac,
4336 &hapd->conf->num_accept_mac, buf + 19) ||
4338 reply_len = -1;
4341 &hapd->conf->accept_mac,
4342 &hapd->conf->num_accept_mac, buf + 19) ||
4345 reply_len = -1;
4348 hapd->conf->accept_mac,
4349 hapd->conf->num_accept_mac, reply, reply_size);
4352 &hapd->conf->accept_mac,
4353 &hapd->conf->num_accept_mac);
4356 reply_len = -1;
4358 reply_len = -1;
4363 &hapd->conf->deny_mac,
4364 &hapd->conf->num_deny_mac, buf + 17) ||
4367 reply_len = -1;
4370 &hapd->conf->deny_mac,
4371 &hapd->conf->num_deny_mac, buf + 17) ||
4373 reply_len = -1;
4376 hapd->conf->deny_mac,
4377 hapd->conf->num_deny_mac, reply, reply_size);
4380 &hapd->conf->deny_mac,
4381 &hapd->conf->num_deny_mac);
4383 reply_len = -1;
4385 reply_len = -1;
4391 reply_len = -1;
4395 reply_len = -1;
4400 reply_len = -1;
4404 reply_len = -1;
4409 reply_len = -1;
4413 reply_len = -1;
4418 reply_len = -1;
4422 reply_len = -1;
4425 res = dpp_bootstrap_gen(hapd->iface->interfaces->dpp, buf + 18);
4427 reply_len = -1;
4431 reply_len = -1;
4434 if (dpp_bootstrap_remove(hapd->iface->interfaces->dpp,
4436 reply_len = -1;
4440 uri = dpp_bootstrap_get_uri(hapd->iface->interfaces->dpp,
4443 reply_len = -1;
4447 reply_len = -1;
4450 reply_len = dpp_bootstrap_info(hapd->iface->interfaces->dpp,
4454 if (dpp_bootstrap_set(hapd->iface->interfaces->dpp,
4457 reply_len = -1;
4460 reply_len = -1;
4463 reply_len = -1;
4468 res = dpp_configurator_add(hapd->iface->interfaces->dpp,
4471 reply_len = -1;
4475 reply_len = -1;
4478 if (dpp_configurator_set(hapd->iface->interfaces->dpp,
4480 reply_len = -1;
4482 if (dpp_configurator_remove(hapd->iface->interfaces->dpp,
4484 reply_len = -1;
4487 reply_len = -1;
4490 hapd->iface->interfaces->dpp,
4496 reply_len = -1;
4500 reply_len = -1;
4504 reply_len = -1;
4508 reply_len = -1;
4511 reply_len = -1;
4513 dpp_controller_stop(hapd->iface->interfaces->dpp);
4516 reply_len = -1;
4521 reply_len = -1;
4528 reply_len = -1;
4531 reply_len = -1;
4540 reply_len = -1;
4543 reply_len = -1;
4549 reply_len = -1;
4552 reply_len = -1;
4556 if (radius_server_dac_request(hapd->radius_srv, buf + 12) < 0)
4557 reply_len = -1;
4564 reply_len = ptksa_cache_list(hapd->ptksa, reply, reply_size);
4573 if (hostapd_ctrl_iface_enable_mld(hapd->iface))
4574 reply_len = -1;
4576 if (hostapd_ctrl_iface_disable_mld(hapd->iface))
4577 reply_len = -1;
4582 reply_len = -1;
4615 res = recvfrom(sock, buf, sizeof(buf) - 1, 0,
4638 hapd->ctrl_iface_cookie,
4647 "CTRL: No cookie in the request - drop request");
4652 if (os_memcmp(hapd->ctrl_iface_cookie, lcookie,
4655 "CTRL: Invalid cookie in the request - drop request");
4691 if (hapd->conf->ctrl_interface == NULL)
4694 len = os_strlen(hapd->conf->ctrl_interface) +
4695 os_strlen(hapd->conf->iface) + 2;
4701 hapd->conf->ctrl_interface, hapd->conf->iface);
4702 buf[len - 1] = '\0';
4729 if (hapd->ctrl_sock > -1) {
4734 if (hapd->conf->ctrl_interface == NULL)
4737 pos = os_strstr(hapd->conf->ctrl_interface, "udp:");
4747 dl_list_init(&hapd->ctrl_dst);
4748 hapd->ctrl_sock = -1;
4749 os_get_random(hapd->ctrl_iface_cookie, CTRL_IFACE_COOKIE_LEN);
4771 hapd->ctrl_sock = socket(res->ai_family, res->ai_socktype,
4772 res->ai_protocol);
4773 if (hapd->ctrl_sock < 0) {
4778 if (bind(hapd->ctrl_sock, res->ai_addr, res->ai_addrlen) < 0) {
4779 port--;
4780 if ((HOSTAPD_CTRL_IFACE_PORT - port) <
4792 os_free(hapd->conf->ctrl_interface);
4793 hapd->conf->ctrl_interface = tmp;
4797 if (eloop_register_read_sock(hapd->ctrl_sock,
4801 return -1;
4804 hapd->msg_ctx = hapd;
4810 if (hapd->ctrl_sock >= 0)
4811 close(hapd->ctrl_sock);
4812 return -1;
4815 int s = -1;
4818 if (hapd->ctrl_sock > -1) {
4823 dl_list_init(&hapd->ctrl_dst);
4825 if (hapd->conf->ctrl_interface == NULL)
4828 if (mkdir(hapd->conf->ctrl_interface, S_IRWXU | S_IRWXG) < 0) {
4839 if (hapd->conf->ctrl_interface_gid_set &&
4840 lchown(hapd->conf->ctrl_interface, -1,
4841 hapd->conf->ctrl_interface_gid) < 0) {
4844 return -1;
4847 if (!hapd->conf->ctrl_interface_gid_set &&
4848 hapd->iface->interfaces->ctrl_iface_group &&
4849 lchown(hapd->conf->ctrl_interface, -1,
4850 hapd->iface->interfaces->ctrl_iface_group) < 0) {
4853 return -1;
4859 * directory without group access. This breaks things since Wi-Fi
4864 if (chmod(hapd->conf->ctrl_interface, S_IRWXU | S_IRWXG) < 0) {
4871 if (os_strlen(hapd->conf->ctrl_interface) + 1 +
4872 os_strlen(hapd->conf->iface) >= sizeof(addr.sun_path))
4895 " allow connections - assuming it was left"
4906 "hostapd-ctrl-iface: bind(PF_UNIX): %s",
4914 "be in use - cannot override it");
4923 if (hapd->conf->ctrl_interface_gid_set &&
4924 lchown(fname, -1, hapd->conf->ctrl_interface_gid) < 0) {
4930 if (!hapd->conf->ctrl_interface_gid_set &&
4931 hapd->iface->interfaces->ctrl_iface_group &&
4932 lchown(fname, -1, hapd->iface->interfaces->ctrl_iface_group) < 0) {
4945 hapd->ctrl_sock = s;
4949 return -1;
4951 hapd->msg_ctx = hapd;
4963 return -1;
4972 if (hapd->ctrl_sock > -1) {
4977 eloop_unregister_read_sock(hapd->ctrl_sock);
4978 close(hapd->ctrl_sock);
4979 hapd->ctrl_sock = -1;
4986 if (hapd->conf->ctrl_interface &&
4987 rmdir(hapd->conf->ctrl_interface) < 0) {
4990 "directory not empty - leaving it "
4995 hapd->conf->ctrl_interface,
5002 dl_list_for_each_safe(dst, prev, &hapd->ctrl_dst, struct wpa_ctrl_dst,
5007 l2_packet_deinit(hapd->l2_test);
5008 hapd->l2_test = NULL;
5018 return -1;
5029 return -1;
5039 return ctrl_iface_attach(&interfaces->global_ctrl_dst, from, fromlen,
5048 return ctrl_iface_detach(&interfaces->global_ctrl_dst, from, fromlen);
5074 dpp_global_clear(interfaces->dpp);
5076 interfaces->dpp_pb_bi = NULL;
5083 info = &interfaces->dpp_pb[i];
5084 info->rx_time.sec = 0;
5085 info->rx_time.usec = 0;
5107 if (hapd->iface->fst) {
5109 return -1;
5112 hapd->iface->fst = fst_attach(ifname, hapd->own_addr,
5114 if (hapd->iface->fst)
5119 return -EINVAL;
5134 hapd->iface->fst = NULL;
5135 hapd->iface->fst_ies = NULL;
5141 return -EINVAL;
5153 for (i = 0; i < interfaces->count; i++) {
5154 struct hostapd_iface *iface = interfaces->iface[i];
5156 for (j = 0; j < iface->num_bss; j++) {
5159 hapd = iface->bss[j];
5160 if (os_strcmp(ifname, hapd->conf->iface) == 0)
5186 src_hapd->conf->wpa);
5188 src_hapd->conf->wpa_key_mgmt) {
5194 src_hapd->conf->wpa_pairwise) {
5197 src_hapd->conf->wpa_pairwise, " ");
5201 src_hapd->conf->rsn_pairwise) {
5204 src_hapd->conf->rsn_pairwise, " ");
5208 src_hapd->conf->ssid.wpa_passphrase) {
5210 src_hapd->conf->ssid.wpa_passphrase);
5212 src_hapd->conf->ssid.wpa_psk_set) {
5214 src_hapd->conf->ssid.wpa_psk->psk, PMK_LEN);
5220 res = hostapd_set_iface(dst_hapd->iconf, dst_hapd->conf, param, value);
5228 return -1;
5249 for (i = 0; i < interfaces->count; i++) {
5250 iface = interfaces->iface[i];
5252 for (j = 0; j < iface->num_bss; j++) {
5255 conf = iface->conf->bss[j];
5257 res = os_snprintf(pos, end - pos,
5259 conf->iface,
5260 conf->ctrl_interface ?
5261 conf->ctrl_interface : "N/A");
5263 res = os_snprintf(pos, end - pos, "%s\n",
5264 conf->iface);
5265 if (os_snprintf_error(end - pos, res)) {
5267 return pos - reply;
5273 return pos - reply;
5290 return -1;
5298 return -1;
5306 return -1;
5314 return -1;
5335 res = os_snprintf(reply, reply_size, "FAIL-NO-IFNAME-MATCH\n");
5337 return -1;
5361 res = recvfrom(sock, buffer, sizeof(buffer) - 1, 0,
5388 interfaces->ctrl_iface_cookie,
5397 "CTRL: No cookie in the request - drop request");
5402 if (os_memcmp(interfaces->ctrl_iface_cookie, lcookie,
5405 "CTRL: Invalid cookie in the request - drop request");
5432 reply_len = -1;
5437 reply_len = -1;
5440 reply_len = -1;
5444 reply_len = -1;
5448 reply_len = -1;
5452 reply_len = -1;
5456 reply_len = -1;
5459 } else if (os_strncmp(buf, "FST-ATTACH ", 11) == 0) {
5463 reply_len = -1;
5464 } else if (os_strncmp(buf, "FST-DETACH ", 11) == 0) {
5468 reply_len = -1;
5469 } else if (os_strncmp(buf, "FST-MANAGER ", 12) == 0) {
5477 reply_len = -1;
5486 reply_len = -1;
5510 if (interface->global_iface_path == NULL)
5513 len = os_strlen(interface->global_iface_path) +
5514 os_strlen(interface->global_iface_name) + 2;
5519 os_snprintf(buf, len, "%s/%s", interface->global_iface_path,
5520 interface->global_iface_name);
5521 buf[len - 1] = '\0';
5536 if (interface->global_ctrl_sock > -1) {
5541 if (interface->global_iface_path == NULL)
5544 pos = os_strstr(interface->global_iface_path, "udp:");
5554 os_get_random(interface->ctrl_iface_cookie, CTRL_IFACE_COOKIE_LEN);
5576 interface->global_ctrl_sock = socket(res->ai_family, res->ai_socktype,
5577 res->ai_protocol);
5578 if (interface->global_ctrl_sock < 0) {
5583 if (bind(interface->global_ctrl_sock, res->ai_addr, res->ai_addrlen) <
5586 if ((port - HOSTAPD_GLOBAL_CTRL_IFACE_PORT) <
5597 if (eloop_register_read_sock(interface->global_ctrl_sock,
5601 return -1;
5609 if (interface->global_ctrl_sock >= 0)
5610 close(interface->global_ctrl_sock);
5611 return -1;
5614 int s = -1;
5617 if (interface->global_iface_path == NULL) {
5622 if (mkdir(interface->global_iface_path, S_IRWXU | S_IRWXG) < 0) {
5631 } else if (interface->ctrl_iface_group &&
5632 lchown(interface->global_iface_path, -1,
5633 interface->ctrl_iface_group) < 0) {
5639 if (os_strlen(interface->global_iface_path) + 1 +
5640 os_strlen(interface->global_iface_name) >= sizeof(addr.sun_path))
5663 " allow connections - assuming it was left"
5681 "be in use - cannot override it");
5690 if (interface->ctrl_iface_group &&
5691 lchown(fname, -1, interface->ctrl_iface_group) < 0) {
5704 interface->global_ctrl_sock = s;
5719 return -1;
5731 if (interfaces->global_ctrl_sock > -1) {
5732 eloop_unregister_read_sock(interfaces->global_ctrl_sock);
5733 close(interfaces->global_ctrl_sock);
5734 interfaces->global_ctrl_sock = -1;
5742 if (interfaces->global_iface_path &&
5743 rmdir(interfaces->global_iface_path) < 0) {
5746 "directory not empty - leaving it "
5751 interfaces->global_iface_path,
5758 os_free(interfaces->global_iface_path);
5759 interfaces->global_iface_path = NULL;
5761 dl_list_for_each_safe(dst, prev, &interfaces->global_ctrl_dst,
5774 return !!(dst->events & WPA_EVENT_RX_PROBE_REQUEST);
5819 if ((level >= dst->debug_level) &&
5822 &dst->addr, dst->addrlen);
5823 msg.msg_name = &dst->addr;
5824 msg.msg_namelen = dst->addrlen;
5828 "%d - %s",
5830 dst->errors++;
5831 if (dst->errors > 10 || _errno == ENOENT) {
5833 &dst->addr,
5834 dst->addrlen);
5837 dst->errors = 0;
5850 hapd->iface->interfaces->global_ctrl_sock,
5851 &hapd->iface->interfaces->global_ctrl_dst,
5853 NULL : hapd->conf->iface,
5859 hapd->ctrl_sock, &hapd->ctrl_dst,