2 * hostapd / UNIX domain socket -based control interface
3 * Copyright (c) 2004-2013, Jouni Malinen <j@w1.fi>
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
9 #include "utils/includes.h"
11 #ifndef CONFIG_NATIVE_WINDOWS
17 #include "utils/common.h"
18 #include "utils/eloop.h"
19 #include "common/version.h"
20 #include "common/ieee802_11_defs.h"
21 #include "drivers/driver.h"
22 #include "radius/radius_client.h"
23 #include "ap/hostapd.h"
24 #include "ap/ap_config.h"
25 #include "ap/ieee802_1x.h"
26 #include "ap/wpa_auth.h"
27 #include "ap/ieee802_11.h"
28 #include "ap/sta_info.h"
29 #include "ap/wps_hostapd.h"
30 #include "ap/ctrl_iface_ap.h"
31 #include "ap/ap_drv_ops.h"
32 #include "ap/wnm_ap.h"
33 #include "ap/wpa_auth.h"
34 #include "wps/wps_defs.h"
36 #include "config_file.h"
37 #include "ctrl_iface.h"
41 struct wpa_ctrl_dst *next;
42 struct sockaddr_un addr;
49 static void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level,
50 const char *buf, size_t len);
53 static int hostapd_ctrl_iface_attach(struct hostapd_data *hapd,
54 struct sockaddr_un *from,
57 struct wpa_ctrl_dst *dst;
59 dst = os_zalloc(sizeof(*dst));
62 os_memcpy(&dst->addr, from, sizeof(struct sockaddr_un));
63 dst->addrlen = fromlen;
64 dst->debug_level = MSG_INFO;
65 dst->next = hapd->ctrl_dst;
67 wpa_hexdump(MSG_DEBUG, "CTRL_IFACE monitor attached",
68 (u8 *) from->sun_path,
69 fromlen - offsetof(struct sockaddr_un, sun_path));
74 static int hostapd_ctrl_iface_detach(struct hostapd_data *hapd,
75 struct sockaddr_un *from,
78 struct wpa_ctrl_dst *dst, *prev = NULL;
82 if (fromlen == dst->addrlen &&
83 os_memcmp(from->sun_path, dst->addr.sun_path,
84 fromlen - offsetof(struct sockaddr_un, sun_path))
86 wpa_hexdump(MSG_DEBUG, "CTRL_IFACE monitor detached",
87 (u8 *) from->sun_path,
89 offsetof(struct sockaddr_un, sun_path));
91 hapd->ctrl_dst = dst->next;
93 prev->next = dst->next;
104 static int hostapd_ctrl_iface_level(struct hostapd_data *hapd,
105 struct sockaddr_un *from,
109 struct wpa_ctrl_dst *dst;
111 wpa_printf(MSG_DEBUG, "CTRL_IFACE LEVEL %s", level);
113 dst = hapd->ctrl_dst;
115 if (fromlen == dst->addrlen &&
116 os_memcmp(from->sun_path, dst->addr.sun_path,
117 fromlen - offsetof(struct sockaddr_un, sun_path))
119 wpa_hexdump(MSG_DEBUG, "CTRL_IFACE changed monitor "
120 "level", (u8 *) from->sun_path, fromlen -
121 offsetof(struct sockaddr_un, sun_path));
122 dst->debug_level = atoi(level);
132 static int hostapd_ctrl_iface_new_sta(struct hostapd_data *hapd,
136 struct sta_info *sta;
138 wpa_printf(MSG_DEBUG, "CTRL_IFACE NEW_STA %s", txtaddr);
140 if (hwaddr_aton(txtaddr, addr))
143 sta = ap_get_sta(hapd, addr);
147 wpa_printf(MSG_DEBUG, "Add new STA " MACSTR " based on ctrl_iface "
148 "notification", MAC2STR(addr));
149 sta = ap_sta_add(hapd, addr);
153 hostapd_new_assoc_sta(hapd, sta, 0);
158 #ifdef CONFIG_IEEE80211W
160 static int hostapd_ctrl_iface_sa_query(struct hostapd_data *hapd,
164 u8 trans_id[WLAN_SA_QUERY_TR_ID_LEN];
166 wpa_printf(MSG_DEBUG, "CTRL_IFACE SA_QUERY %s", txtaddr);
168 if (hwaddr_aton(txtaddr, addr) ||
169 os_get_random(trans_id, WLAN_SA_QUERY_TR_ID_LEN) < 0)
172 ieee802_11_send_sa_query_req(hapd, addr, trans_id);
176 #endif /* NEED_AP_MLME */
177 #endif /* CONFIG_IEEE80211W */
181 static int hostapd_ctrl_iface_wps_pin(struct hostapd_data *hapd, char *txt)
183 char *pin = os_strchr(txt, ' ');
186 u8 addr_buf[ETH_ALEN], *addr = NULL;
193 timeout_txt = os_strchr(pin, ' ');
195 *timeout_txt++ = '\0';
196 timeout = atoi(timeout_txt);
197 pos = os_strchr(timeout_txt, ' ');
200 if (hwaddr_aton(pos, addr_buf) == 0)
206 return hostapd_wps_add_pin(hapd, addr, txt, pin, timeout);
210 static int hostapd_ctrl_iface_wps_check_pin(
211 struct hostapd_data *hapd, char *cmd, char *buf, size_t buflen)
218 wpa_hexdump_ascii_key(MSG_DEBUG, "WPS_CHECK_PIN",
219 (u8 *) cmd, os_strlen(cmd));
220 for (pos = cmd, len = 0; *pos != '\0'; pos++) {
221 if (*pos < '0' || *pos > '9')
225 wpa_printf(MSG_DEBUG, "WPS: Too long PIN");
229 if (len != 4 && len != 8) {
230 wpa_printf(MSG_DEBUG, "WPS: Invalid PIN length %d", (int) len);
236 unsigned int pin_val;
238 if (!wps_pin_valid(pin_val)) {
239 wpa_printf(MSG_DEBUG, "WPS: Invalid checksum digit");
240 ret = os_snprintf(buf, buflen, "FAIL-CHECKSUM\n");
241 if (ret < 0 || (size_t) ret >= buflen)
247 ret = os_snprintf(buf, buflen, "%s", pin);
248 if (ret < 0 || (size_t) ret >= buflen)
255 #ifdef CONFIG_WPS_NFC
256 static int hostapd_ctrl_iface_wps_nfc_tag_read(struct hostapd_data *hapd,
263 len = os_strlen(pos);
268 buf = wpabuf_alloc(len);
271 if (hexstr2bin(pos, wpabuf_put(buf, len), len) < 0) {
276 ret = hostapd_wps_nfc_tag_read(hapd, buf);
283 static int hostapd_ctrl_iface_wps_nfc_config_token(struct hostapd_data *hapd,
284 char *cmd, char *reply,
291 if (os_strcmp(cmd, "WPS") == 0)
293 else if (os_strcmp(cmd, "NDEF") == 0)
298 buf = hostapd_wps_nfc_config_token(hapd, ndef);
302 res = wpa_snprintf_hex_uppercase(reply, max_len, wpabuf_head(buf),
313 static int hostapd_ctrl_iface_wps_nfc_token_gen(struct hostapd_data *hapd,
314 char *reply, size_t max_len,
320 buf = hostapd_wps_nfc_token_gen(hapd, ndef);
324 res = wpa_snprintf_hex_uppercase(reply, max_len, wpabuf_head(buf),
335 static int hostapd_ctrl_iface_wps_nfc_token(struct hostapd_data *hapd,
336 char *cmd, char *reply,
339 if (os_strcmp(cmd, "WPS") == 0)
340 return hostapd_ctrl_iface_wps_nfc_token_gen(hapd, reply,
343 if (os_strcmp(cmd, "NDEF") == 0)
344 return hostapd_ctrl_iface_wps_nfc_token_gen(hapd, reply,
347 if (os_strcmp(cmd, "enable") == 0)
348 return hostapd_wps_nfc_token_enable(hapd);
350 if (os_strcmp(cmd, "disable") == 0) {
351 hostapd_wps_nfc_token_disable(hapd);
359 static int hostapd_ctrl_iface_nfc_get_handover_sel(struct hostapd_data *hapd,
360 char *cmd, char *reply,
368 pos = os_strchr(cmd, ' ');
373 if (os_strcmp(cmd, "WPS") == 0)
375 else if (os_strcmp(cmd, "NDEF") == 0)
380 if (os_strcmp(pos, "WPS-CR") == 0)
381 buf = hostapd_wps_nfc_hs_cr(hapd, ndef);
387 res = wpa_snprintf_hex_uppercase(reply, max_len, wpabuf_head(buf),
398 static int hostapd_ctrl_iface_nfc_report_handover(struct hostapd_data *hapd,
402 * Since NFC connection handover provided full WPS Credential, there is
403 * no need for additional operations within hostapd. Just report this in
406 wpa_printf(MSG_DEBUG, "NFC: Connection handover reported: %s", cmd);
410 #endif /* CONFIG_WPS_NFC */
413 static int hostapd_ctrl_iface_wps_ap_pin(struct hostapd_data *hapd, char *txt,
414 char *buf, size_t buflen)
420 pos = os_strchr(txt, ' ');
424 if (os_strcmp(txt, "disable") == 0) {
425 hostapd_wps_ap_pin_disable(hapd);
426 return os_snprintf(buf, buflen, "OK\n");
429 if (os_strcmp(txt, "random") == 0) {
432 pin_txt = hostapd_wps_ap_pin_random(hapd, timeout);
435 return os_snprintf(buf, buflen, "%s", pin_txt);
438 if (os_strcmp(txt, "get") == 0) {
439 pin_txt = hostapd_wps_ap_pin_get(hapd);
442 return os_snprintf(buf, buflen, "%s", pin_txt);
445 if (os_strcmp(txt, "set") == 0) {
450 pos = os_strchr(pos, ' ');
455 if (os_strlen(pin) > buflen)
457 if (hostapd_wps_ap_pin_set(hapd, pin, timeout) < 0)
459 return os_snprintf(buf, buflen, "%s", pin);
466 static int hostapd_ctrl_iface_wps_config(struct hostapd_data *hapd, char *txt)
469 char *ssid, *auth, *encr = NULL, *key = NULL;
472 pos = os_strchr(txt, ' ');
478 pos = os_strchr(pos, ' ');
482 pos = os_strchr(pos, ' ');
489 return hostapd_wps_config_ap(hapd, ssid, auth, encr, key);
493 static const char * pbc_status_str(enum pbc_status status)
496 case WPS_PBC_STATUS_DISABLE:
498 case WPS_PBC_STATUS_ACTIVE:
500 case WPS_PBC_STATUS_TIMEOUT:
502 case WPS_PBC_STATUS_OVERLAP:
510 static int hostapd_ctrl_iface_wps_get_status(struct hostapd_data *hapd,
511 char *buf, size_t buflen)
519 ret = os_snprintf(pos, end - pos, "PBC Status: %s\n",
520 pbc_status_str(hapd->wps_stats.pbc_status));
522 if (ret < 0 || ret >= end - pos)
526 ret = os_snprintf(pos, end - pos, "Last WPS result: %s\n",
527 (hapd->wps_stats.status == WPS_STATUS_SUCCESS ?
529 (hapd->wps_stats.status == WPS_STATUS_FAILURE ?
530 "Failed" : "None")));
532 if (ret < 0 || ret >= end - pos)
536 /* If status == Failure - Add possible Reasons */
537 if(hapd->wps_stats.status == WPS_STATUS_FAILURE &&
538 hapd->wps_stats.failure_reason > 0) {
539 ret = os_snprintf(pos, end - pos,
540 "Failure Reason: %s\n",
541 wps_ei_str(hapd->wps_stats.failure_reason));
543 if (ret < 0 || ret >= end - pos)
548 if (hapd->wps_stats.status) {
549 ret = os_snprintf(pos, end - pos, "Peer Address: " MACSTR "\n",
550 MAC2STR(hapd->wps_stats.peer_addr));
552 if (ret < 0 || ret >= end - pos)
560 #endif /* CONFIG_WPS */
563 #ifdef CONFIG_INTERWORKING
565 static int hostapd_ctrl_iface_set_qos_map_set(struct hostapd_data *hapd,
568 u8 qos_map_set[16 + 2 * 21], count = 0;
569 const char *pos = cmd;
573 if (count == sizeof(qos_map_set)) {
574 wpa_printf(MSG_ERROR, "Too many qos_map_set parameters");
579 if (val < 0 || val > 255) {
580 wpa_printf(MSG_INFO, "Invalid QoS Map Set");
584 qos_map_set[count++] = val;
585 pos = os_strchr(pos, ',');
591 if (count < 16 || count & 1) {
592 wpa_printf(MSG_INFO, "Invalid QoS Map Set");
596 ret = hostapd_drv_set_qos_map(hapd, qos_map_set, count);
598 wpa_printf(MSG_INFO, "Failed to set QoS Map Set");
602 os_memcpy(hapd->conf->qos_map_set, qos_map_set, count);
603 hapd->conf->qos_map_set_len = count;
609 static int hostapd_ctrl_iface_send_qos_map_conf(struct hostapd_data *hapd,
613 struct sta_info *sta;
615 u8 *qos_map_set = hapd->conf->qos_map_set;
616 u8 qos_map_set_len = hapd->conf->qos_map_set_len;
619 if (!qos_map_set_len) {
620 wpa_printf(MSG_INFO, "QoS Map Set is not set");
624 if (hwaddr_aton(cmd, addr))
627 sta = ap_get_sta(hapd, addr);
629 wpa_printf(MSG_DEBUG, "Station " MACSTR " not found "
630 "for QoS Map Configuration message",
635 if (!sta->qos_map_enabled) {
636 wpa_printf(MSG_DEBUG, "Station " MACSTR " did not indicate "
637 "support for QoS Map", MAC2STR(addr));
641 buf = wpabuf_alloc(2 + 2 + qos_map_set_len);
645 wpabuf_put_u8(buf, WLAN_ACTION_QOS);
646 wpabuf_put_u8(buf, QOS_QOS_MAP_CONFIG);
648 /* QoS Map Set Element */
649 wpabuf_put_u8(buf, WLAN_EID_QOS_MAP_SET);
650 wpabuf_put_u8(buf, qos_map_set_len);
651 wpabuf_put_data(buf, qos_map_set, qos_map_set_len);
653 ret = hostapd_drv_send_action(hapd, hapd->iface->freq, 0, addr,
654 wpabuf_head(buf), wpabuf_len(buf));
660 #endif /* CONFIG_INTERWORKING */
665 static int hostapd_ctrl_iface_disassoc_imminent(struct hostapd_data *hapd,
670 struct ieee80211_mgmt *mgmt;
673 if (hwaddr_aton(cmd, addr))
677 disassoc_timer = atoi(cmd + 17);
679 os_memset(buf, 0, sizeof(buf));
680 mgmt = (struct ieee80211_mgmt *) buf;
681 mgmt->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
682 WLAN_FC_STYPE_ACTION);
683 os_memcpy(mgmt->da, addr, ETH_ALEN);
684 os_memcpy(mgmt->sa, hapd->own_addr, ETH_ALEN);
685 os_memcpy(mgmt->bssid, hapd->own_addr, ETH_ALEN);
686 mgmt->u.action.category = WLAN_ACTION_WNM;
687 mgmt->u.action.u.bss_tm_req.action = WNM_BSS_TRANS_MGMT_REQ;
688 mgmt->u.action.u.bss_tm_req.dialog_token = 1;
689 mgmt->u.action.u.bss_tm_req.req_mode =
690 WNM_BSS_TM_REQ_DISASSOC_IMMINENT;
691 mgmt->u.action.u.bss_tm_req.disassoc_timer =
692 host_to_le16(disassoc_timer);
693 mgmt->u.action.u.bss_tm_req.validity_interval = 0;
695 pos = mgmt->u.action.u.bss_tm_req.variable;
697 if (hostapd_drv_send_mlme(hapd, buf, pos - buf, 0) < 0) {
698 wpa_printf(MSG_DEBUG, "Failed to send BSS Transition "
699 "Management Request frame");
707 static int hostapd_ctrl_iface_ess_disassoc(struct hostapd_data *hapd,
711 const char *url, *timerstr;
713 struct sta_info *sta;
715 if (hwaddr_aton(cmd, addr))
718 sta = ap_get_sta(hapd, addr);
720 wpa_printf(MSG_DEBUG, "Station " MACSTR
721 " not found for ESS disassociation imminent message",
727 if (*timerstr != ' ')
730 disassoc_timer = atoi(timerstr);
731 if (disassoc_timer < 0 || disassoc_timer > 65535)
734 url = os_strchr(timerstr, ' ');
739 return wnm_send_ess_disassoc_imminent(hapd, sta, url, disassoc_timer);
742 #endif /* CONFIG_WNM */
745 static int hostapd_ctrl_iface_get_config(struct hostapd_data *hapd,
746 char *buf, size_t buflen)
754 ret = os_snprintf(pos, end - pos, "bssid=" MACSTR "\n"
756 MAC2STR(hapd->own_addr),
757 wpa_ssid_txt(hapd->conf->ssid.ssid,
758 hapd->conf->ssid.ssid_len));
759 if (ret < 0 || ret >= end - pos)
764 ret = os_snprintf(pos, end - pos, "wps_state=%s\n",
765 hapd->conf->wps_state == 0 ? "disabled" :
766 (hapd->conf->wps_state == 1 ? "not configured" :
768 if (ret < 0 || ret >= end - pos)
772 if (hapd->conf->wps_state && hapd->conf->wpa &&
773 hapd->conf->ssid.wpa_passphrase) {
774 ret = os_snprintf(pos, end - pos, "passphrase=%s\n",
775 hapd->conf->ssid.wpa_passphrase);
776 if (ret < 0 || ret >= end - pos)
781 if (hapd->conf->wps_state && hapd->conf->wpa &&
782 hapd->conf->ssid.wpa_psk &&
783 hapd->conf->ssid.wpa_psk->group) {
784 char hex[PMK_LEN * 2 + 1];
785 wpa_snprintf_hex(hex, sizeof(hex),
786 hapd->conf->ssid.wpa_psk->psk, PMK_LEN);
787 ret = os_snprintf(pos, end - pos, "psk=%s\n", hex);
788 if (ret < 0 || ret >= end - pos)
792 #endif /* CONFIG_WPS */
794 if (hapd->conf->wpa && hapd->conf->wpa_key_mgmt) {
795 ret = os_snprintf(pos, end - pos, "key_mgmt=");
796 if (ret < 0 || ret >= end - pos)
800 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_PSK) {
801 ret = os_snprintf(pos, end - pos, "WPA-PSK ");
802 if (ret < 0 || ret >= end - pos)
806 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_IEEE8021X) {
807 ret = os_snprintf(pos, end - pos, "WPA-EAP ");
808 if (ret < 0 || ret >= end - pos)
812 #ifdef CONFIG_IEEE80211R
813 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_FT_PSK) {
814 ret = os_snprintf(pos, end - pos, "FT-PSK ");
815 if (ret < 0 || ret >= end - pos)
819 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_FT_IEEE8021X) {
820 ret = os_snprintf(pos, end - pos, "FT-EAP ");
821 if (ret < 0 || ret >= end - pos)
825 #endif /* CONFIG_IEEE80211R */
826 #ifdef CONFIG_IEEE80211W
827 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_PSK_SHA256) {
828 ret = os_snprintf(pos, end - pos, "WPA-PSK-SHA256 ");
829 if (ret < 0 || ret >= end - pos)
833 if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_IEEE8021X_SHA256) {
834 ret = os_snprintf(pos, end - pos, "WPA-EAP-SHA256 ");
835 if (ret < 0 || ret >= end - pos)
839 #endif /* CONFIG_IEEE80211W */
841 ret = os_snprintf(pos, end - pos, "\n");
842 if (ret < 0 || ret >= end - pos)
847 if (hapd->conf->wpa) {
848 ret = os_snprintf(pos, end - pos, "group_cipher=%s\n",
849 wpa_cipher_txt(hapd->conf->wpa_group));
850 if (ret < 0 || ret >= end - pos)
855 if ((hapd->conf->wpa & WPA_PROTO_RSN) && hapd->conf->rsn_pairwise) {
856 ret = os_snprintf(pos, end - pos, "rsn_pairwise_cipher=");
857 if (ret < 0 || ret >= end - pos)
861 ret = wpa_write_ciphers(pos, end, hapd->conf->rsn_pairwise,
867 ret = os_snprintf(pos, end - pos, "\n");
868 if (ret < 0 || ret >= end - pos)
873 if ((hapd->conf->wpa & WPA_PROTO_WPA) && hapd->conf->wpa_pairwise) {
874 ret = os_snprintf(pos, end - pos, "wpa_pairwise_cipher=");
875 if (ret < 0 || ret >= end - pos)
879 ret = wpa_write_ciphers(pos, end, hapd->conf->rsn_pairwise,
885 ret = os_snprintf(pos, end - pos, "\n");
886 if (ret < 0 || ret >= end - pos)
895 static int hostapd_ctrl_iface_set(struct hostapd_data *hapd, char *cmd)
900 value = os_strchr(cmd, ' ');
905 wpa_printf(MSG_DEBUG, "CTRL_IFACE SET '%s'='%s'", cmd, value);
907 #ifdef CONFIG_WPS_TESTING
908 } else if (os_strcasecmp(cmd, "wps_version_number") == 0) {
910 val = strtol(value, NULL, 0);
911 if (val < 0 || val > 0xff) {
913 wpa_printf(MSG_DEBUG, "WPS: Invalid "
914 "wps_version_number %ld", val);
916 wps_version_number = val;
917 wpa_printf(MSG_DEBUG, "WPS: Testing - force WPS "
919 (wps_version_number & 0xf0) >> 4,
920 wps_version_number & 0x0f);
921 hostapd_wps_update_ie(hapd);
923 } else if (os_strcasecmp(cmd, "wps_testing_dummy_cred") == 0) {
924 wps_testing_dummy_cred = atoi(value);
925 wpa_printf(MSG_DEBUG, "WPS: Testing - dummy_cred=%d",
926 wps_testing_dummy_cred);
927 #endif /* CONFIG_WPS_TESTING */
928 #ifdef CONFIG_INTERWORKING
929 } else if (os_strcasecmp(cmd, "gas_frag_limit") == 0) {
930 int val = atoi(value);
934 hapd->gas_frag_limit = val;
935 #endif /* CONFIG_INTERWORKING */
936 #ifdef CONFIG_TESTING_OPTIONS
937 } else if (os_strcasecmp(cmd, "ext_mgmt_frame_handling") == 0) {
938 hapd->ext_mgmt_frame_handling = atoi(value);
939 #endif /* CONFIG_TESTING_OPTIONS */
941 ret = hostapd_set_iface(hapd->iconf, hapd->conf, cmd, value);
948 static int hostapd_ctrl_iface_get(struct hostapd_data *hapd, char *cmd,
949 char *buf, size_t buflen)
953 wpa_printf(MSG_DEBUG, "CTRL_IFACE GET '%s'", cmd);
955 if (os_strcmp(cmd, "version") == 0) {
956 res = os_snprintf(buf, buflen, "%s", VERSION_STR);
957 if (res < 0 || (unsigned int) res >= buflen)
966 static int hostapd_ctrl_iface_enable(struct hostapd_iface *iface)
968 if (hostapd_enable_iface(iface) < 0) {
969 wpa_printf(MSG_ERROR, "Enabling of interface failed");
976 static int hostapd_ctrl_iface_reload(struct hostapd_iface *iface)
978 if (hostapd_reload_iface(iface) < 0) {
979 wpa_printf(MSG_ERROR, "Reloading of interface failed");
986 static int hostapd_ctrl_iface_disable(struct hostapd_iface *iface)
988 if (hostapd_disable_iface(iface) < 0) {
989 wpa_printf(MSG_ERROR, "Disabling of interface failed");
996 #ifdef CONFIG_TESTING_OPTIONS
998 static int hostapd_ctrl_iface_radar(struct hostapd_data *hapd, char *cmd)
1000 union wpa_event_data data;
1002 enum wpa_event_type event;
1004 wpa_printf(MSG_DEBUG, "RADAR TEST: %s", cmd);
1006 os_memset(&data, 0, sizeof(data));
1008 param = os_strchr(cmd, ' ');
1013 if (os_strcmp(cmd, "DETECTED") == 0)
1014 event = EVENT_DFS_RADAR_DETECTED;
1015 else if (os_strcmp(cmd, "CAC-FINISHED") == 0)
1016 event = EVENT_DFS_CAC_FINISHED;
1017 else if (os_strcmp(cmd, "CAC-ABORTED") == 0)
1018 event = EVENT_DFS_CAC_ABORTED;
1019 else if (os_strcmp(cmd, "NOP-FINISHED") == 0)
1020 event = EVENT_DFS_NOP_FINISHED;
1022 wpa_printf(MSG_DEBUG, "Unsupported RADAR test command: %s",
1027 pos = os_strstr(param, "freq=");
1029 data.dfs_event.freq = atoi(pos + 5);
1031 pos = os_strstr(param, "ht_enabled=1");
1033 data.dfs_event.ht_enabled = 1;
1035 pos = os_strstr(param, "chan_offset=");
1037 data.dfs_event.chan_offset = atoi(pos + 12);
1039 pos = os_strstr(param, "chan_width=");
1041 data.dfs_event.chan_width = atoi(pos + 11);
1043 pos = os_strstr(param, "cf1=");
1045 data.dfs_event.cf1 = atoi(pos + 4);
1047 pos = os_strstr(param, "cf2=");
1049 data.dfs_event.cf2 = atoi(pos + 4);
1051 wpa_supplicant_event(hapd, event, &data);
1057 static int hostapd_ctrl_iface_mgmt_tx(struct hostapd_data *hapd, char *cmd)
1063 wpa_printf(MSG_DEBUG, "External MGMT TX: %s", cmd);
1065 len = os_strlen(cmd);
1070 buf = os_malloc(len);
1074 if (hexstr2bin(cmd, buf, len) < 0) {
1079 res = hostapd_drv_send_mlme(hapd, buf, len, 0);
1084 #endif /* CONFIG_TESTING_OPTIONS */
1087 static int hostapd_ctrl_iface_chan_switch(struct hostapd_data *hapd, char *pos)
1090 struct csa_settings settings;
1091 int ret = hostapd_parse_csa_settings(pos, &settings);
1096 return hostapd_switch_channel(hapd, &settings);
1097 #else /* NEED_AP_MLME */
1099 #endif /* NEED_AP_MLME */
1103 static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx,
1106 struct hostapd_data *hapd = eloop_ctx;
1109 struct sockaddr_un from;
1110 socklen_t fromlen = sizeof(from);
1112 const int reply_size = 4096;
1114 int level = MSG_DEBUG;
1116 res = recvfrom(sock, buf, sizeof(buf) - 1, 0,
1117 (struct sockaddr *) &from, &fromlen);
1119 perror("recvfrom(ctrl_iface)");
1123 if (os_strcmp(buf, "PING") == 0)
1124 level = MSG_EXCESSIVE;
1125 wpa_hexdump_ascii(level, "RX ctrl_iface", (u8 *) buf, res);
1127 reply = os_malloc(reply_size);
1128 if (reply == NULL) {
1129 sendto(sock, "FAIL\n", 5, 0, (struct sockaddr *) &from,
1134 os_memcpy(reply, "OK\n", 3);
1137 if (os_strcmp(buf, "PING") == 0) {
1138 os_memcpy(reply, "PONG\n", 5);
1140 } else if (os_strncmp(buf, "RELOG", 5) == 0) {
1141 if (wpa_debug_reopen_file() < 0)
1143 } else if (os_strcmp(buf, "STATUS") == 0) {
1144 reply_len = hostapd_ctrl_iface_status(hapd, reply,
1146 } else if (os_strcmp(buf, "MIB") == 0) {
1147 reply_len = ieee802_11_get_mib(hapd, reply, reply_size);
1148 if (reply_len >= 0) {
1149 res = wpa_get_mib(hapd->wpa_auth, reply + reply_len,
1150 reply_size - reply_len);
1156 if (reply_len >= 0) {
1157 res = ieee802_1x_get_mib(hapd, reply + reply_len,
1158 reply_size - reply_len);
1164 #ifndef CONFIG_NO_RADIUS
1165 if (reply_len >= 0) {
1166 res = radius_client_get_mib(hapd->radius,
1168 reply_size - reply_len);
1174 #endif /* CONFIG_NO_RADIUS */
1175 } else if (os_strcmp(buf, "STA-FIRST") == 0) {
1176 reply_len = hostapd_ctrl_iface_sta_first(hapd, reply,
1178 } else if (os_strncmp(buf, "STA ", 4) == 0) {
1179 reply_len = hostapd_ctrl_iface_sta(hapd, buf + 4, reply,
1181 } else if (os_strncmp(buf, "STA-NEXT ", 9) == 0) {
1182 reply_len = hostapd_ctrl_iface_sta_next(hapd, buf + 9, reply,
1184 } else if (os_strcmp(buf, "ATTACH") == 0) {
1185 if (hostapd_ctrl_iface_attach(hapd, &from, fromlen))
1187 } else if (os_strcmp(buf, "DETACH") == 0) {
1188 if (hostapd_ctrl_iface_detach(hapd, &from, fromlen))
1190 } else if (os_strncmp(buf, "LEVEL ", 6) == 0) {
1191 if (hostapd_ctrl_iface_level(hapd, &from, fromlen,
1194 } else if (os_strncmp(buf, "NEW_STA ", 8) == 0) {
1195 if (hostapd_ctrl_iface_new_sta(hapd, buf + 8))
1197 } else if (os_strncmp(buf, "DEAUTHENTICATE ", 15) == 0) {
1198 if (hostapd_ctrl_iface_deauthenticate(hapd, buf + 15))
1200 } else if (os_strncmp(buf, "DISASSOCIATE ", 13) == 0) {
1201 if (hostapd_ctrl_iface_disassociate(hapd, buf + 13))
1203 #ifdef CONFIG_IEEE80211W
1205 } else if (os_strncmp(buf, "SA_QUERY ", 9) == 0) {
1206 if (hostapd_ctrl_iface_sa_query(hapd, buf + 9))
1208 #endif /* NEED_AP_MLME */
1209 #endif /* CONFIG_IEEE80211W */
1211 } else if (os_strncmp(buf, "WPS_PIN ", 8) == 0) {
1212 if (hostapd_ctrl_iface_wps_pin(hapd, buf + 8))
1214 } else if (os_strncmp(buf, "WPS_CHECK_PIN ", 14) == 0) {
1215 reply_len = hostapd_ctrl_iface_wps_check_pin(
1216 hapd, buf + 14, reply, reply_size);
1217 } else if (os_strcmp(buf, "WPS_PBC") == 0) {
1218 if (hostapd_wps_button_pushed(hapd, NULL))
1220 } else if (os_strcmp(buf, "WPS_CANCEL") == 0) {
1221 if (hostapd_wps_cancel(hapd))
1223 } else if (os_strncmp(buf, "WPS_AP_PIN ", 11) == 0) {
1224 reply_len = hostapd_ctrl_iface_wps_ap_pin(hapd, buf + 11,
1226 } else if (os_strncmp(buf, "WPS_CONFIG ", 11) == 0) {
1227 if (hostapd_ctrl_iface_wps_config(hapd, buf + 11) < 0)
1229 } else if (os_strncmp(buf, "WPS_GET_STATUS", 13) == 0) {
1230 reply_len = hostapd_ctrl_iface_wps_get_status(hapd, reply,
1232 #ifdef CONFIG_WPS_NFC
1233 } else if (os_strncmp(buf, "WPS_NFC_TAG_READ ", 17) == 0) {
1234 if (hostapd_ctrl_iface_wps_nfc_tag_read(hapd, buf + 17))
1236 } else if (os_strncmp(buf, "WPS_NFC_CONFIG_TOKEN ", 21) == 0) {
1237 reply_len = hostapd_ctrl_iface_wps_nfc_config_token(
1238 hapd, buf + 21, reply, reply_size);
1239 } else if (os_strncmp(buf, "WPS_NFC_TOKEN ", 14) == 0) {
1240 reply_len = hostapd_ctrl_iface_wps_nfc_token(
1241 hapd, buf + 14, reply, reply_size);
1242 } else if (os_strncmp(buf, "NFC_GET_HANDOVER_SEL ", 21) == 0) {
1243 reply_len = hostapd_ctrl_iface_nfc_get_handover_sel(
1244 hapd, buf + 21, reply, reply_size);
1245 } else if (os_strncmp(buf, "NFC_REPORT_HANDOVER ", 20) == 0) {
1246 if (hostapd_ctrl_iface_nfc_report_handover(hapd, buf + 20))
1248 #endif /* CONFIG_WPS_NFC */
1249 #endif /* CONFIG_WPS */
1250 #ifdef CONFIG_INTERWORKING
1251 } else if (os_strncmp(buf, "SET_QOS_MAP_SET ", 16) == 0) {
1252 if (hostapd_ctrl_iface_set_qos_map_set(hapd, buf + 16))
1254 } else if (os_strncmp(buf, "SEND_QOS_MAP_CONF ", 18) == 0) {
1255 if (hostapd_ctrl_iface_send_qos_map_conf(hapd, buf + 18))
1257 #endif /* CONFIG_INTERWORKING */
1259 } else if (os_strncmp(buf, "DISASSOC_IMMINENT ", 18) == 0) {
1260 if (hostapd_ctrl_iface_disassoc_imminent(hapd, buf + 18))
1262 } else if (os_strncmp(buf, "ESS_DISASSOC ", 13) == 0) {
1263 if (hostapd_ctrl_iface_ess_disassoc(hapd, buf + 13))
1265 #endif /* CONFIG_WNM */
1266 } else if (os_strcmp(buf, "GET_CONFIG") == 0) {
1267 reply_len = hostapd_ctrl_iface_get_config(hapd, reply,
1269 } else if (os_strncmp(buf, "SET ", 4) == 0) {
1270 if (hostapd_ctrl_iface_set(hapd, buf + 4))
1272 } else if (os_strncmp(buf, "GET ", 4) == 0) {
1273 reply_len = hostapd_ctrl_iface_get(hapd, buf + 4, reply,
1275 } else if (os_strncmp(buf, "ENABLE", 6) == 0) {
1276 if (hostapd_ctrl_iface_enable(hapd->iface))
1278 } else if (os_strncmp(buf, "RELOAD", 6) == 0) {
1279 if (hostapd_ctrl_iface_reload(hapd->iface))
1281 } else if (os_strncmp(buf, "DISABLE", 7) == 0) {
1282 if (hostapd_ctrl_iface_disable(hapd->iface))
1284 #ifdef CONFIG_TESTING_OPTIONS
1285 } else if (os_strncmp(buf, "RADAR ", 6) == 0) {
1286 if (hostapd_ctrl_iface_radar(hapd, buf + 6))
1288 } else if (os_strncmp(buf, "MGMT_TX ", 8) == 0) {
1289 if (hostapd_ctrl_iface_mgmt_tx(hapd, buf + 8))
1291 #endif /* CONFIG_TESTING_OPTIONS */
1292 } else if (os_strncmp(buf, "CHAN_SWITCH ", 12) == 0) {
1293 if (hostapd_ctrl_iface_chan_switch(hapd, buf + 12))
1296 os_memcpy(reply, "UNKNOWN COMMAND\n", 16);
1300 if (reply_len < 0) {
1301 os_memcpy(reply, "FAIL\n", 5);
1304 sendto(sock, reply, reply_len, 0, (struct sockaddr *) &from, fromlen);
1309 static char * hostapd_ctrl_iface_path(struct hostapd_data *hapd)
1314 if (hapd->conf->ctrl_interface == NULL)
1317 len = os_strlen(hapd->conf->ctrl_interface) +
1318 os_strlen(hapd->conf->iface) + 2;
1319 buf = os_malloc(len);
1323 os_snprintf(buf, len, "%s/%s",
1324 hapd->conf->ctrl_interface, hapd->conf->iface);
1325 buf[len - 1] = '\0';
1330 static void hostapd_ctrl_iface_msg_cb(void *ctx, int level, int global,
1331 const char *txt, size_t len)
1333 struct hostapd_data *hapd = ctx;
1336 hostapd_ctrl_iface_send(hapd, level, txt, len);
1340 int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
1342 struct sockaddr_un addr;
1346 if (hapd->ctrl_sock > -1) {
1347 wpa_printf(MSG_DEBUG, "ctrl_iface already exists!");
1351 if (hapd->conf->ctrl_interface == NULL)
1354 if (mkdir(hapd->conf->ctrl_interface, S_IRWXU | S_IRWXG) < 0) {
1355 if (errno == EEXIST) {
1356 wpa_printf(MSG_DEBUG, "Using existing control "
1357 "interface directory.");
1359 perror("mkdir[ctrl_interface]");
1364 if (hapd->conf->ctrl_interface_gid_set &&
1365 chown(hapd->conf->ctrl_interface, -1,
1366 hapd->conf->ctrl_interface_gid) < 0) {
1367 perror("chown[ctrl_interface]");
1371 if (!hapd->conf->ctrl_interface_gid_set &&
1372 hapd->iface->interfaces->ctrl_iface_group &&
1373 chown(hapd->conf->ctrl_interface, -1,
1374 hapd->iface->interfaces->ctrl_iface_group) < 0) {
1375 perror("chown[ctrl_interface]");
1381 * Android is using umask 0077 which would leave the control interface
1382 * directory without group access. This breaks things since Wi-Fi
1383 * framework assumes that this directory can be accessed by other
1384 * applications in the wifi group. Fix this by adding group access even
1385 * if umask value would prevent this.
1387 if (chmod(hapd->conf->ctrl_interface, S_IRWXU | S_IRWXG) < 0) {
1388 wpa_printf(MSG_ERROR, "CTRL: Could not chmod directory: %s",
1390 /* Try to continue anyway */
1392 #endif /* ANDROID */
1394 if (os_strlen(hapd->conf->ctrl_interface) + 1 +
1395 os_strlen(hapd->conf->iface) >= sizeof(addr.sun_path))
1398 s = socket(PF_UNIX, SOCK_DGRAM, 0);
1400 perror("socket(PF_UNIX)");
1404 os_memset(&addr, 0, sizeof(addr));
1406 addr.sun_len = sizeof(addr);
1407 #endif /* __FreeBSD__ */
1408 addr.sun_family = AF_UNIX;
1409 fname = hostapd_ctrl_iface_path(hapd);
1412 os_strlcpy(addr.sun_path, fname, sizeof(addr.sun_path));
1413 if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
1414 wpa_printf(MSG_DEBUG, "ctrl_iface bind(PF_UNIX) failed: %s",
1416 if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
1417 wpa_printf(MSG_DEBUG, "ctrl_iface exists, but does not"
1418 " allow connections - assuming it was left"
1419 "over from forced program termination");
1420 if (unlink(fname) < 0) {
1421 perror("unlink[ctrl_iface]");
1422 wpa_printf(MSG_ERROR, "Could not unlink "
1423 "existing ctrl_iface socket '%s'",
1427 if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) <
1429 perror("hostapd-ctrl-iface: bind(PF_UNIX)");
1432 wpa_printf(MSG_DEBUG, "Successfully replaced leftover "
1433 "ctrl_iface socket '%s'", fname);
1435 wpa_printf(MSG_INFO, "ctrl_iface exists and seems to "
1436 "be in use - cannot override it");
1437 wpa_printf(MSG_INFO, "Delete '%s' manually if it is "
1438 "not used anymore", fname);
1445 if (hapd->conf->ctrl_interface_gid_set &&
1446 chown(fname, -1, hapd->conf->ctrl_interface_gid) < 0) {
1447 perror("chown[ctrl_interface/ifname]");
1451 if (!hapd->conf->ctrl_interface_gid_set &&
1452 hapd->iface->interfaces->ctrl_iface_group &&
1453 chown(fname, -1, hapd->iface->interfaces->ctrl_iface_group) < 0) {
1454 perror("chown[ctrl_interface/ifname]");
1458 if (chmod(fname, S_IRWXU | S_IRWXG) < 0) {
1459 perror("chmod[ctrl_interface/ifname]");
1464 hapd->ctrl_sock = s;
1465 eloop_register_read_sock(s, hostapd_ctrl_iface_receive, hapd,
1467 hapd->msg_ctx = hapd;
1468 wpa_msg_register_cb(hostapd_ctrl_iface_msg_cb);
1483 void hostapd_ctrl_iface_deinit(struct hostapd_data *hapd)
1485 struct wpa_ctrl_dst *dst, *prev;
1487 if (hapd->ctrl_sock > -1) {
1489 eloop_unregister_read_sock(hapd->ctrl_sock);
1490 close(hapd->ctrl_sock);
1491 hapd->ctrl_sock = -1;
1492 fname = hostapd_ctrl_iface_path(hapd);
1497 if (hapd->conf->ctrl_interface &&
1498 rmdir(hapd->conf->ctrl_interface) < 0) {
1499 if (errno == ENOTEMPTY) {
1500 wpa_printf(MSG_DEBUG, "Control interface "
1501 "directory not empty - leaving it "
1504 wpa_printf(MSG_ERROR,
1505 "rmdir[ctrl_interface=%s]: %s",
1506 hapd->conf->ctrl_interface,
1512 dst = hapd->ctrl_dst;
1521 static int hostapd_ctrl_iface_add(struct hapd_interfaces *interfaces,
1524 if (hostapd_add_iface(interfaces, buf) < 0) {
1525 wpa_printf(MSG_ERROR, "Adding interface %s failed", buf);
1532 static int hostapd_ctrl_iface_remove(struct hapd_interfaces *interfaces,
1535 if (hostapd_remove_iface(interfaces, buf) < 0) {
1536 wpa_printf(MSG_ERROR, "Removing interface %s failed", buf);
1543 static void hostapd_global_ctrl_iface_receive(int sock, void *eloop_ctx,
1546 void *interfaces = eloop_ctx;
1549 struct sockaddr_un from;
1550 socklen_t fromlen = sizeof(from);
1554 res = recvfrom(sock, buf, sizeof(buf) - 1, 0,
1555 (struct sockaddr *) &from, &fromlen);
1557 perror("recvfrom(ctrl_iface)");
1561 wpa_printf(MSG_DEBUG, "Global ctrl_iface command: %s", buf);
1563 os_memcpy(reply, "OK\n", 3);
1566 if (os_strcmp(buf, "PING") == 0) {
1567 os_memcpy(reply, "PONG\n", 5);
1569 } else if (os_strncmp(buf, "RELOG", 5) == 0) {
1570 if (wpa_debug_reopen_file() < 0)
1572 } else if (os_strncmp(buf, "ADD ", 4) == 0) {
1573 if (hostapd_ctrl_iface_add(interfaces, buf + 4) < 0)
1575 } else if (os_strncmp(buf, "REMOVE ", 7) == 0) {
1576 if (hostapd_ctrl_iface_remove(interfaces, buf + 7) < 0)
1579 wpa_printf(MSG_DEBUG, "Unrecognized global ctrl_iface command "
1584 if (reply_len < 0) {
1585 os_memcpy(reply, "FAIL\n", 5);
1589 sendto(sock, reply, reply_len, 0, (struct sockaddr *) &from, fromlen);
1593 static char * hostapd_global_ctrl_iface_path(struct hapd_interfaces *interface)
1598 if (interface->global_iface_path == NULL)
1601 len = os_strlen(interface->global_iface_path) +
1602 os_strlen(interface->global_iface_name) + 2;
1603 buf = os_malloc(len);
1607 os_snprintf(buf, len, "%s/%s", interface->global_iface_path,
1608 interface->global_iface_name);
1609 buf[len - 1] = '\0';
1614 int hostapd_global_ctrl_iface_init(struct hapd_interfaces *interface)
1616 struct sockaddr_un addr;
1620 if (interface->global_iface_path == NULL) {
1621 wpa_printf(MSG_DEBUG, "ctrl_iface not configured!");
1625 if (mkdir(interface->global_iface_path, S_IRWXU | S_IRWXG) < 0) {
1626 if (errno == EEXIST) {
1627 wpa_printf(MSG_DEBUG, "Using existing control "
1628 "interface directory.");
1630 perror("mkdir[ctrl_interface]");
1633 } else if (interface->ctrl_iface_group &&
1634 chown(interface->global_iface_path, -1,
1635 interface->ctrl_iface_group) < 0) {
1636 perror("chown[ctrl_interface]");
1640 if (os_strlen(interface->global_iface_path) + 1 +
1641 os_strlen(interface->global_iface_name) >= sizeof(addr.sun_path))
1644 s = socket(PF_UNIX, SOCK_DGRAM, 0);
1646 perror("socket(PF_UNIX)");
1650 os_memset(&addr, 0, sizeof(addr));
1652 addr.sun_len = sizeof(addr);
1653 #endif /* __FreeBSD__ */
1654 addr.sun_family = AF_UNIX;
1655 fname = hostapd_global_ctrl_iface_path(interface);
1658 os_strlcpy(addr.sun_path, fname, sizeof(addr.sun_path));
1659 if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
1660 wpa_printf(MSG_DEBUG, "ctrl_iface bind(PF_UNIX) failed: %s",
1662 if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
1663 wpa_printf(MSG_DEBUG, "ctrl_iface exists, but does not"
1664 " allow connections - assuming it was left"
1665 "over from forced program termination");
1666 if (unlink(fname) < 0) {
1667 perror("unlink[ctrl_iface]");
1668 wpa_printf(MSG_ERROR, "Could not unlink "
1669 "existing ctrl_iface socket '%s'",
1673 if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) <
1675 perror("bind(PF_UNIX)");
1678 wpa_printf(MSG_DEBUG, "Successfully replaced leftover "
1679 "ctrl_iface socket '%s'", fname);
1681 wpa_printf(MSG_INFO, "ctrl_iface exists and seems to "
1682 "be in use - cannot override it");
1683 wpa_printf(MSG_INFO, "Delete '%s' manually if it is "
1684 "not used anymore", fname);
1691 if (interface->ctrl_iface_group &&
1692 chown(fname, -1, interface->ctrl_iface_group) < 0) {
1693 perror("chown[ctrl_interface]");
1697 if (chmod(fname, S_IRWXU | S_IRWXG) < 0) {
1698 perror("chmod[ctrl_interface/ifname]");
1703 interface->global_ctrl_sock = s;
1704 eloop_register_read_sock(s, hostapd_global_ctrl_iface_receive,
1720 void hostapd_global_ctrl_iface_deinit(struct hapd_interfaces *interfaces)
1724 if (interfaces->global_ctrl_sock > -1) {
1725 eloop_unregister_read_sock(interfaces->global_ctrl_sock);
1726 close(interfaces->global_ctrl_sock);
1727 interfaces->global_ctrl_sock = -1;
1728 fname = hostapd_global_ctrl_iface_path(interfaces);
1734 if (interfaces->global_iface_path &&
1735 rmdir(interfaces->global_iface_path) < 0) {
1736 if (errno == ENOTEMPTY) {
1737 wpa_printf(MSG_DEBUG, "Control interface "
1738 "directory not empty - leaving it "
1741 wpa_printf(MSG_ERROR,
1742 "rmdir[ctrl_interface=%s]: %s",
1743 interfaces->global_iface_path,
1747 os_free(interfaces->global_iface_path);
1748 interfaces->global_iface_path = NULL;
1753 static void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level,
1754 const char *buf, size_t len)
1756 struct wpa_ctrl_dst *dst, *next;
1762 dst = hapd->ctrl_dst;
1763 if (hapd->ctrl_sock < 0 || dst == NULL)
1766 os_snprintf(levelstr, sizeof(levelstr), "<%d>", level);
1767 io[0].iov_base = levelstr;
1768 io[0].iov_len = os_strlen(levelstr);
1769 io[1].iov_base = (char *) buf;
1770 io[1].iov_len = len;
1771 os_memset(&msg, 0, sizeof(msg));
1778 if (level >= dst->debug_level) {
1779 wpa_hexdump(MSG_DEBUG, "CTRL_IFACE monitor send",
1780 (u8 *) dst->addr.sun_path, dst->addrlen -
1781 offsetof(struct sockaddr_un, sun_path));
1782 msg.msg_name = &dst->addr;
1783 msg.msg_namelen = dst->addrlen;
1784 if (sendmsg(hapd->ctrl_sock, &msg, 0) < 0) {
1786 wpa_printf(MSG_INFO, "CTRL_IFACE monitor[%d]: "
1788 idx, errno, strerror(errno));
1790 if (dst->errors > 10 || _errno == ENOENT) {
1791 hostapd_ctrl_iface_detach(
1803 #endif /* CONFIG_NATIVE_WINDOWS */