ctrl_iface.c 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186
  1. /*
  2. * hostapd / UNIX domain socket -based control interface
  3. * Copyright (c) 2004-2010, Jouni Malinen <j@w1.fi>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * Alternatively, this software may be distributed under the terms of BSD
  10. * license.
  11. *
  12. * See README and COPYING for more details.
  13. */
  14. #include "utils/includes.h"
  15. #ifndef CONFIG_NATIVE_WINDOWS
  16. #include <sys/un.h>
  17. #include <sys/stat.h>
  18. #include <stddef.h>
  19. #include "utils/common.h"
  20. #include "utils/eloop.h"
  21. #include "common/version.h"
  22. #include "common/ieee802_11_defs.h"
  23. #include "drivers/driver.h"
  24. #include "radius/radius_client.h"
  25. #include "ap/hostapd.h"
  26. #include "ap/ap_config.h"
  27. #include "ap/ieee802_1x.h"
  28. #include "ap/wpa_auth.h"
  29. #include "ap/ieee802_11.h"
  30. #include "ap/sta_info.h"
  31. #include "ap/wps_hostapd.h"
  32. #include "ap/ctrl_iface_ap.h"
  33. #include "ap/ap_drv_ops.h"
  34. #include "wps/wps_defs.h"
  35. #include "wps/wps.h"
  36. #include "ctrl_iface.h"
  37. struct wpa_ctrl_dst {
  38. struct wpa_ctrl_dst *next;
  39. struct sockaddr_un addr;
  40. socklen_t addrlen;
  41. int debug_level;
  42. int errors;
  43. };
  44. static void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level,
  45. const char *buf, size_t len);
  46. static int hostapd_ctrl_iface_attach(struct hostapd_data *hapd,
  47. struct sockaddr_un *from,
  48. socklen_t fromlen)
  49. {
  50. struct wpa_ctrl_dst *dst;
  51. dst = os_zalloc(sizeof(*dst));
  52. if (dst == NULL)
  53. return -1;
  54. os_memcpy(&dst->addr, from, sizeof(struct sockaddr_un));
  55. dst->addrlen = fromlen;
  56. dst->debug_level = MSG_INFO;
  57. dst->next = hapd->ctrl_dst;
  58. hapd->ctrl_dst = dst;
  59. wpa_hexdump(MSG_DEBUG, "CTRL_IFACE monitor attached",
  60. (u8 *) from->sun_path,
  61. fromlen - offsetof(struct sockaddr_un, sun_path));
  62. return 0;
  63. }
  64. static int hostapd_ctrl_iface_detach(struct hostapd_data *hapd,
  65. struct sockaddr_un *from,
  66. socklen_t fromlen)
  67. {
  68. struct wpa_ctrl_dst *dst, *prev = NULL;
  69. dst = hapd->ctrl_dst;
  70. while (dst) {
  71. if (fromlen == dst->addrlen &&
  72. os_memcmp(from->sun_path, dst->addr.sun_path,
  73. fromlen - offsetof(struct sockaddr_un, sun_path))
  74. == 0) {
  75. if (prev == NULL)
  76. hapd->ctrl_dst = dst->next;
  77. else
  78. prev->next = dst->next;
  79. os_free(dst);
  80. wpa_hexdump(MSG_DEBUG, "CTRL_IFACE monitor detached",
  81. (u8 *) from->sun_path,
  82. fromlen -
  83. offsetof(struct sockaddr_un, sun_path));
  84. return 0;
  85. }
  86. prev = dst;
  87. dst = dst->next;
  88. }
  89. return -1;
  90. }
  91. static int hostapd_ctrl_iface_level(struct hostapd_data *hapd,
  92. struct sockaddr_un *from,
  93. socklen_t fromlen,
  94. char *level)
  95. {
  96. struct wpa_ctrl_dst *dst;
  97. wpa_printf(MSG_DEBUG, "CTRL_IFACE LEVEL %s", level);
  98. dst = hapd->ctrl_dst;
  99. while (dst) {
  100. if (fromlen == dst->addrlen &&
  101. os_memcmp(from->sun_path, dst->addr.sun_path,
  102. fromlen - offsetof(struct sockaddr_un, sun_path))
  103. == 0) {
  104. wpa_hexdump(MSG_DEBUG, "CTRL_IFACE changed monitor "
  105. "level", (u8 *) from->sun_path, fromlen -
  106. offsetof(struct sockaddr_un, sun_path));
  107. dst->debug_level = atoi(level);
  108. return 0;
  109. }
  110. dst = dst->next;
  111. }
  112. return -1;
  113. }
  114. static int hostapd_ctrl_iface_new_sta(struct hostapd_data *hapd,
  115. const char *txtaddr)
  116. {
  117. u8 addr[ETH_ALEN];
  118. struct sta_info *sta;
  119. wpa_printf(MSG_DEBUG, "CTRL_IFACE NEW_STA %s", txtaddr);
  120. if (hwaddr_aton(txtaddr, addr))
  121. return -1;
  122. sta = ap_get_sta(hapd, addr);
  123. if (sta)
  124. return 0;
  125. wpa_printf(MSG_DEBUG, "Add new STA " MACSTR " based on ctrl_iface "
  126. "notification", MAC2STR(addr));
  127. sta = ap_sta_add(hapd, addr);
  128. if (sta == NULL)
  129. return -1;
  130. hostapd_new_assoc_sta(hapd, sta, 0);
  131. return 0;
  132. }
  133. #ifdef CONFIG_P2P_MANAGER
  134. static int p2p_manager_disconnect(struct hostapd_data *hapd, u16 stype,
  135. u8 minor_reason_code, const u8 *addr)
  136. {
  137. struct ieee80211_mgmt *mgmt;
  138. int ret;
  139. u8 *pos;
  140. if (hapd->driver->send_frame == NULL)
  141. return -1;
  142. mgmt = os_zalloc(sizeof(*mgmt) + 100);
  143. if (mgmt == NULL)
  144. return -1;
  145. wpa_dbg(hapd->msg_ctx, MSG_DEBUG, "P2P: Disconnect STA " MACSTR
  146. " with minor reason code %u (stype=%u)",
  147. MAC2STR(addr), minor_reason_code, stype);
  148. mgmt->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT, stype);
  149. os_memcpy(mgmt->da, addr, ETH_ALEN);
  150. os_memcpy(mgmt->sa, hapd->own_addr, ETH_ALEN);
  151. os_memcpy(mgmt->bssid, hapd->own_addr, ETH_ALEN);
  152. if (stype == WLAN_FC_STYPE_DEAUTH) {
  153. mgmt->u.deauth.reason_code =
  154. host_to_le16(WLAN_REASON_PREV_AUTH_NOT_VALID);
  155. pos = (u8 *) (&mgmt->u.deauth.reason_code + 1);
  156. } else {
  157. mgmt->u.disassoc.reason_code =
  158. host_to_le16(WLAN_REASON_PREV_AUTH_NOT_VALID);
  159. pos = (u8 *) (&mgmt->u.disassoc.reason_code + 1);
  160. }
  161. *pos++ = WLAN_EID_VENDOR_SPECIFIC;
  162. *pos++ = 4 + 3 + 1;
  163. WPA_PUT_BE24(pos, OUI_WFA);
  164. pos += 3;
  165. *pos++ = P2P_OUI_TYPE;
  166. *pos++ = P2P_ATTR_MINOR_REASON_CODE;
  167. WPA_PUT_LE16(pos, 1);
  168. pos += 2;
  169. *pos++ = minor_reason_code;
  170. ret = hapd->driver->send_frame(hapd->drv_priv, (u8 *) mgmt,
  171. pos - (u8 *) mgmt, 1);
  172. os_free(mgmt);
  173. return ret < 0 ? -1 : 0;
  174. }
  175. #endif /* CONFIG_P2P_MANAGER */
  176. static int hostapd_ctrl_iface_deauthenticate(struct hostapd_data *hapd,
  177. const char *txtaddr)
  178. {
  179. u8 addr[ETH_ALEN];
  180. struct sta_info *sta;
  181. const char *pos;
  182. wpa_dbg(hapd->msg_ctx, MSG_DEBUG, "CTRL_IFACE DEAUTHENTICATE %s",
  183. txtaddr);
  184. if (hwaddr_aton(txtaddr, addr))
  185. return -1;
  186. pos = os_strstr(txtaddr, " test=");
  187. if (pos) {
  188. struct ieee80211_mgmt mgmt;
  189. int encrypt;
  190. if (hapd->driver->send_frame == NULL)
  191. return -1;
  192. pos += 6;
  193. encrypt = atoi(pos);
  194. os_memset(&mgmt, 0, sizeof(mgmt));
  195. mgmt.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
  196. WLAN_FC_STYPE_DEAUTH);
  197. os_memcpy(mgmt.da, addr, ETH_ALEN);
  198. os_memcpy(mgmt.sa, hapd->own_addr, ETH_ALEN);
  199. os_memcpy(mgmt.bssid, hapd->own_addr, ETH_ALEN);
  200. mgmt.u.deauth.reason_code =
  201. host_to_le16(WLAN_REASON_PREV_AUTH_NOT_VALID);
  202. if (hapd->driver->send_frame(hapd->drv_priv, (u8 *) &mgmt,
  203. IEEE80211_HDRLEN +
  204. sizeof(mgmt.u.deauth),
  205. encrypt) < 0)
  206. return -1;
  207. return 0;
  208. }
  209. #ifdef CONFIG_P2P_MANAGER
  210. pos = os_strstr(txtaddr, " p2p=");
  211. if (pos) {
  212. return p2p_manager_disconnect(hapd, WLAN_FC_STYPE_DEAUTH,
  213. atoi(pos + 5), addr);
  214. }
  215. #endif /* CONFIG_P2P_MANAGER */
  216. hostapd_drv_sta_deauth(hapd, addr, WLAN_REASON_PREV_AUTH_NOT_VALID);
  217. sta = ap_get_sta(hapd, addr);
  218. if (sta)
  219. ap_sta_deauthenticate(hapd, sta,
  220. WLAN_REASON_PREV_AUTH_NOT_VALID);
  221. else if (addr[0] == 0xff)
  222. hostapd_free_stas(hapd);
  223. return 0;
  224. }
  225. static int hostapd_ctrl_iface_disassociate(struct hostapd_data *hapd,
  226. const char *txtaddr)
  227. {
  228. u8 addr[ETH_ALEN];
  229. struct sta_info *sta;
  230. const char *pos;
  231. wpa_dbg(hapd->msg_ctx, MSG_DEBUG, "CTRL_IFACE DISASSOCIATE %s",
  232. txtaddr);
  233. if (hwaddr_aton(txtaddr, addr))
  234. return -1;
  235. pos = os_strstr(txtaddr, " test=");
  236. if (pos) {
  237. struct ieee80211_mgmt mgmt;
  238. int encrypt;
  239. if (hapd->driver->send_frame == NULL)
  240. return -1;
  241. pos += 6;
  242. encrypt = atoi(pos);
  243. os_memset(&mgmt, 0, sizeof(mgmt));
  244. mgmt.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
  245. WLAN_FC_STYPE_DISASSOC);
  246. os_memcpy(mgmt.da, addr, ETH_ALEN);
  247. os_memcpy(mgmt.sa, hapd->own_addr, ETH_ALEN);
  248. os_memcpy(mgmt.bssid, hapd->own_addr, ETH_ALEN);
  249. mgmt.u.disassoc.reason_code =
  250. host_to_le16(WLAN_REASON_PREV_AUTH_NOT_VALID);
  251. if (hapd->driver->send_frame(hapd->drv_priv, (u8 *) &mgmt,
  252. IEEE80211_HDRLEN +
  253. sizeof(mgmt.u.deauth),
  254. encrypt) < 0)
  255. return -1;
  256. return 0;
  257. }
  258. #ifdef CONFIG_P2P_MANAGER
  259. pos = os_strstr(txtaddr, " p2p=");
  260. if (pos) {
  261. return p2p_manager_disconnect(hapd, WLAN_FC_STYPE_DISASSOC,
  262. atoi(pos + 5), addr);
  263. }
  264. #endif /* CONFIG_P2P_MANAGER */
  265. hostapd_drv_sta_disassoc(hapd, addr, WLAN_REASON_PREV_AUTH_NOT_VALID);
  266. sta = ap_get_sta(hapd, addr);
  267. if (sta)
  268. ap_sta_disassociate(hapd, sta,
  269. WLAN_REASON_PREV_AUTH_NOT_VALID);
  270. else if (addr[0] == 0xff)
  271. hostapd_free_stas(hapd);
  272. return 0;
  273. }
  274. #ifdef CONFIG_IEEE80211W
  275. #ifdef NEED_AP_MLME
  276. static int hostapd_ctrl_iface_sa_query(struct hostapd_data *hapd,
  277. const char *txtaddr)
  278. {
  279. u8 addr[ETH_ALEN];
  280. u8 trans_id[WLAN_SA_QUERY_TR_ID_LEN];
  281. wpa_printf(MSG_DEBUG, "CTRL_IFACE SA_QUERY %s", txtaddr);
  282. if (hwaddr_aton(txtaddr, addr) ||
  283. os_get_random(trans_id, WLAN_SA_QUERY_TR_ID_LEN) < 0)
  284. return -1;
  285. ieee802_11_send_sa_query_req(hapd, addr, trans_id);
  286. return 0;
  287. }
  288. #endif /* NEED_AP_MLME */
  289. #endif /* CONFIG_IEEE80211W */
  290. #ifdef CONFIG_WPS
  291. static int hostapd_ctrl_iface_wps_pin(struct hostapd_data *hapd, char *txt)
  292. {
  293. char *pin = os_strchr(txt, ' ');
  294. char *timeout_txt;
  295. int timeout;
  296. u8 addr_buf[ETH_ALEN], *addr = NULL;
  297. char *pos;
  298. if (pin == NULL)
  299. return -1;
  300. *pin++ = '\0';
  301. timeout_txt = os_strchr(pin, ' ');
  302. if (timeout_txt) {
  303. *timeout_txt++ = '\0';
  304. timeout = atoi(timeout_txt);
  305. pos = os_strchr(timeout_txt, ' ');
  306. if (pos) {
  307. *pos++ = '\0';
  308. if (hwaddr_aton(pos, addr_buf) == 0)
  309. addr = addr_buf;
  310. }
  311. } else
  312. timeout = 0;
  313. return hostapd_wps_add_pin(hapd, addr, txt, pin, timeout);
  314. }
  315. static int hostapd_ctrl_iface_wps_check_pin(
  316. struct hostapd_data *hapd, char *cmd, char *buf, size_t buflen)
  317. {
  318. char pin[9];
  319. size_t len;
  320. char *pos;
  321. int ret;
  322. wpa_hexdump_ascii_key(MSG_DEBUG, "WPS_CHECK_PIN",
  323. (u8 *) cmd, os_strlen(cmd));
  324. for (pos = cmd, len = 0; *pos != '\0'; pos++) {
  325. if (*pos < '0' || *pos > '9')
  326. continue;
  327. pin[len++] = *pos;
  328. if (len == 9) {
  329. wpa_printf(MSG_DEBUG, "WPS: Too long PIN");
  330. return -1;
  331. }
  332. }
  333. if (len != 4 && len != 8) {
  334. wpa_printf(MSG_DEBUG, "WPS: Invalid PIN length %d", (int) len);
  335. return -1;
  336. }
  337. pin[len] = '\0';
  338. if (len == 8) {
  339. unsigned int pin_val;
  340. pin_val = atoi(pin);
  341. if (!wps_pin_valid(pin_val)) {
  342. wpa_printf(MSG_DEBUG, "WPS: Invalid checksum digit");
  343. ret = os_snprintf(buf, buflen, "FAIL-CHECKSUM\n");
  344. if (ret < 0 || (size_t) ret >= buflen)
  345. return -1;
  346. return ret;
  347. }
  348. }
  349. ret = os_snprintf(buf, buflen, "%s", pin);
  350. if (ret < 0 || (size_t) ret >= buflen)
  351. return -1;
  352. return ret;
  353. }
  354. #ifdef CONFIG_WPS_OOB
  355. static int hostapd_ctrl_iface_wps_oob(struct hostapd_data *hapd, char *txt)
  356. {
  357. char *path, *method, *name;
  358. path = os_strchr(txt, ' ');
  359. if (path == NULL)
  360. return -1;
  361. *path++ = '\0';
  362. method = os_strchr(path, ' ');
  363. if (method == NULL)
  364. return -1;
  365. *method++ = '\0';
  366. name = os_strchr(method, ' ');
  367. if (name != NULL)
  368. *name++ = '\0';
  369. return hostapd_wps_start_oob(hapd, txt, path, method, name);
  370. }
  371. #endif /* CONFIG_WPS_OOB */
  372. static int hostapd_ctrl_iface_wps_ap_pin(struct hostapd_data *hapd, char *txt,
  373. char *buf, size_t buflen)
  374. {
  375. int timeout = 300;
  376. char *pos;
  377. const char *pin_txt;
  378. pos = os_strchr(txt, ' ');
  379. if (pos)
  380. *pos++ = '\0';
  381. if (os_strcmp(txt, "disable") == 0) {
  382. hostapd_wps_ap_pin_disable(hapd);
  383. return os_snprintf(buf, buflen, "OK\n");
  384. }
  385. if (os_strcmp(txt, "random") == 0) {
  386. if (pos)
  387. timeout = atoi(pos);
  388. pin_txt = hostapd_wps_ap_pin_random(hapd, timeout);
  389. if (pin_txt == NULL)
  390. return -1;
  391. return os_snprintf(buf, buflen, "%s", pin_txt);
  392. }
  393. if (os_strcmp(txt, "get") == 0) {
  394. pin_txt = hostapd_wps_ap_pin_get(hapd);
  395. if (pin_txt == NULL)
  396. return -1;
  397. return os_snprintf(buf, buflen, "%s", pin_txt);
  398. }
  399. if (os_strcmp(txt, "set") == 0) {
  400. char *pin;
  401. if (pos == NULL)
  402. return -1;
  403. pin = pos;
  404. pos = os_strchr(pos, ' ');
  405. if (pos) {
  406. *pos++ = '\0';
  407. timeout = atoi(pos);
  408. }
  409. if (os_strlen(pin) > buflen)
  410. return -1;
  411. if (hostapd_wps_ap_pin_set(hapd, pin, timeout) < 0)
  412. return -1;
  413. return os_snprintf(buf, buflen, "%s", pin);
  414. }
  415. return -1;
  416. }
  417. static int hostapd_ctrl_iface_wps_config(struct hostapd_data *hapd, char *txt)
  418. {
  419. char *pos;
  420. char *ssid, *auth, *encr = NULL, *key = NULL;
  421. ssid = txt;
  422. pos = os_strchr(txt, ' ');
  423. if (!pos)
  424. return -1;
  425. *pos++ = '\0';
  426. auth = pos;
  427. pos = os_strchr(pos, ' ');
  428. if (pos) {
  429. *pos++ = '\0';
  430. encr = pos;
  431. pos = os_strchr(pos, ' ');
  432. if (pos) {
  433. *pos++ = '\0';
  434. key = pos;
  435. }
  436. }
  437. return hostapd_wps_config_ap(hapd, ssid, auth, encr, key);
  438. }
  439. #endif /* CONFIG_WPS */
  440. static int hostapd_ctrl_iface_ess_disassoc(struct hostapd_data *hapd,
  441. const char *cmd)
  442. {
  443. u8 addr[ETH_ALEN];
  444. const char *url;
  445. u8 buf[1000], *pos;
  446. struct ieee80211_mgmt *mgmt;
  447. size_t url_len;
  448. if (hwaddr_aton(cmd, addr))
  449. return -1;
  450. url = cmd + 17;
  451. if (*url != ' ')
  452. return -1;
  453. url++;
  454. url_len = os_strlen(url);
  455. if (url_len > 255)
  456. return -1;
  457. os_memset(buf, 0, sizeof(buf));
  458. mgmt = (struct ieee80211_mgmt *) buf;
  459. mgmt->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
  460. WLAN_FC_STYPE_ACTION);
  461. os_memcpy(mgmt->da, addr, ETH_ALEN);
  462. os_memcpy(mgmt->sa, hapd->own_addr, ETH_ALEN);
  463. os_memcpy(mgmt->bssid, hapd->own_addr, ETH_ALEN);
  464. mgmt->u.action.category = WLAN_ACTION_WNM;
  465. mgmt->u.action.u.bss_tm_req.action = WNM_BSS_TRANS_MGMT_REQ;
  466. mgmt->u.action.u.bss_tm_req.dialog_token = 1;
  467. mgmt->u.action.u.bss_tm_req.req_mode =
  468. WNM_BSS_TM_REQ_ESS_DISASSOC_IMMINENT;
  469. mgmt->u.action.u.bss_tm_req.disassoc_timer = host_to_le16(0);
  470. mgmt->u.action.u.bss_tm_req.validity_interval = 0;
  471. pos = mgmt->u.action.u.bss_tm_req.variable;
  472. /* Session Information URL */
  473. *pos++ = url_len;
  474. os_memcpy(pos, url, url_len);
  475. pos += url_len;
  476. if (hostapd_drv_send_mlme(hapd, buf, pos - buf, 0) < 0) {
  477. wpa_printf(MSG_DEBUG, "Failed to send BSS Transition "
  478. "Management Request frame");
  479. return -1;
  480. }
  481. return 0;
  482. }
  483. static int hostapd_ctrl_iface_get_config(struct hostapd_data *hapd,
  484. char *buf, size_t buflen)
  485. {
  486. int ret;
  487. char *pos, *end;
  488. pos = buf;
  489. end = buf + buflen;
  490. ret = os_snprintf(pos, end - pos, "bssid=" MACSTR "\n"
  491. "ssid=%s\n",
  492. MAC2STR(hapd->own_addr),
  493. hapd->conf->ssid.ssid);
  494. if (ret < 0 || ret >= end - pos)
  495. return pos - buf;
  496. pos += ret;
  497. #ifdef CONFIG_WPS
  498. ret = os_snprintf(pos, end - pos, "wps_state=%s\n",
  499. hapd->conf->wps_state == 0 ? "disabled" :
  500. (hapd->conf->wps_state == 1 ? "not configured" :
  501. "configured"));
  502. if (ret < 0 || ret >= end - pos)
  503. return pos - buf;
  504. pos += ret;
  505. if (hapd->conf->wps_state && hapd->conf->wpa &&
  506. hapd->conf->ssid.wpa_passphrase) {
  507. ret = os_snprintf(pos, end - pos, "passphrase=%s\n",
  508. hapd->conf->ssid.wpa_passphrase);
  509. if (ret < 0 || ret >= end - pos)
  510. return pos - buf;
  511. pos += ret;
  512. }
  513. if (hapd->conf->wps_state && hapd->conf->wpa &&
  514. hapd->conf->ssid.wpa_psk &&
  515. hapd->conf->ssid.wpa_psk->group) {
  516. char hex[PMK_LEN * 2 + 1];
  517. wpa_snprintf_hex(hex, sizeof(hex),
  518. hapd->conf->ssid.wpa_psk->psk, PMK_LEN);
  519. ret = os_snprintf(pos, end - pos, "psk=%s\n", hex);
  520. if (ret < 0 || ret >= end - pos)
  521. return pos - buf;
  522. pos += ret;
  523. }
  524. #endif /* CONFIG_WPS */
  525. if (hapd->conf->wpa && hapd->conf->wpa_key_mgmt) {
  526. ret = os_snprintf(pos, end - pos, "key_mgmt=");
  527. if (ret < 0 || ret >= end - pos)
  528. return pos - buf;
  529. pos += ret;
  530. if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_PSK) {
  531. ret = os_snprintf(pos, end - pos, "WPA-PSK ");
  532. if (ret < 0 || ret >= end - pos)
  533. return pos - buf;
  534. pos += ret;
  535. }
  536. if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_IEEE8021X) {
  537. ret = os_snprintf(pos, end - pos, "WPA-EAP ");
  538. if (ret < 0 || ret >= end - pos)
  539. return pos - buf;
  540. pos += ret;
  541. }
  542. #ifdef CONFIG_IEEE80211R
  543. if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_FT_PSK) {
  544. ret = os_snprintf(pos, end - pos, "FT-PSK ");
  545. if (ret < 0 || ret >= end - pos)
  546. return pos - buf;
  547. pos += ret;
  548. }
  549. if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_FT_IEEE8021X) {
  550. ret = os_snprintf(pos, end - pos, "FT-EAP ");
  551. if (ret < 0 || ret >= end - pos)
  552. return pos - buf;
  553. pos += ret;
  554. }
  555. #endif /* CONFIG_IEEE80211R */
  556. #ifdef CONFIG_IEEE80211W
  557. if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_PSK_SHA256) {
  558. ret = os_snprintf(pos, end - pos, "WPA-PSK-SHA256 ");
  559. if (ret < 0 || ret >= end - pos)
  560. return pos - buf;
  561. pos += ret;
  562. }
  563. if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_IEEE8021X_SHA256) {
  564. ret = os_snprintf(pos, end - pos, "WPA-EAP-SHA256 ");
  565. if (ret < 0 || ret >= end - pos)
  566. return pos - buf;
  567. pos += ret;
  568. }
  569. #endif /* CONFIG_IEEE80211W */
  570. ret = os_snprintf(pos, end - pos, "\n");
  571. if (ret < 0 || ret >= end - pos)
  572. return pos - buf;
  573. pos += ret;
  574. }
  575. if (hapd->conf->wpa && hapd->conf->wpa_group == WPA_CIPHER_CCMP) {
  576. ret = os_snprintf(pos, end - pos, "group_cipher=CCMP\n");
  577. if (ret < 0 || ret >= end - pos)
  578. return pos - buf;
  579. pos += ret;
  580. } else if (hapd->conf->wpa &&
  581. hapd->conf->wpa_group == WPA_CIPHER_TKIP) {
  582. ret = os_snprintf(pos, end - pos, "group_cipher=TKIP\n");
  583. if (ret < 0 || ret >= end - pos)
  584. return pos - buf;
  585. pos += ret;
  586. }
  587. if ((hapd->conf->wpa & WPA_PROTO_RSN) && hapd->conf->rsn_pairwise) {
  588. ret = os_snprintf(pos, end - pos, "rsn_pairwise_cipher=");
  589. if (ret < 0 || ret >= end - pos)
  590. return pos - buf;
  591. pos += ret;
  592. if (hapd->conf->rsn_pairwise & WPA_CIPHER_CCMP) {
  593. ret = os_snprintf(pos, end - pos, "CCMP ");
  594. if (ret < 0 || ret >= end - pos)
  595. return pos - buf;
  596. pos += ret;
  597. }
  598. if (hapd->conf->rsn_pairwise & WPA_CIPHER_TKIP) {
  599. ret = os_snprintf(pos, end - pos, "TKIP ");
  600. if (ret < 0 || ret >= end - pos)
  601. return pos - buf;
  602. pos += ret;
  603. }
  604. ret = os_snprintf(pos, end - pos, "\n");
  605. if (ret < 0 || ret >= end - pos)
  606. return pos - buf;
  607. pos += ret;
  608. }
  609. if ((hapd->conf->wpa & WPA_PROTO_WPA) && hapd->conf->wpa_pairwise) {
  610. ret = os_snprintf(pos, end - pos, "wpa_pairwise_cipher=");
  611. if (ret < 0 || ret >= end - pos)
  612. return pos - buf;
  613. pos += ret;
  614. if (hapd->conf->wpa_pairwise & WPA_CIPHER_CCMP) {
  615. ret = os_snprintf(pos, end - pos, "CCMP ");
  616. if (ret < 0 || ret >= end - pos)
  617. return pos - buf;
  618. pos += ret;
  619. }
  620. if (hapd->conf->wpa_pairwise & WPA_CIPHER_TKIP) {
  621. ret = os_snprintf(pos, end - pos, "TKIP ");
  622. if (ret < 0 || ret >= end - pos)
  623. return pos - buf;
  624. pos += ret;
  625. }
  626. ret = os_snprintf(pos, end - pos, "\n");
  627. if (ret < 0 || ret >= end - pos)
  628. return pos - buf;
  629. pos += ret;
  630. }
  631. return pos - buf;
  632. }
  633. static int hostapd_ctrl_iface_set(struct hostapd_data *hapd, char *cmd)
  634. {
  635. char *value;
  636. int ret = 0;
  637. value = os_strchr(cmd, ' ');
  638. if (value == NULL)
  639. return -1;
  640. *value++ = '\0';
  641. wpa_printf(MSG_DEBUG, "CTRL_IFACE SET '%s'='%s'", cmd, value);
  642. if (0) {
  643. #ifdef CONFIG_WPS_TESTING
  644. } else if (os_strcasecmp(cmd, "wps_version_number") == 0) {
  645. long int val;
  646. val = strtol(value, NULL, 0);
  647. if (val < 0 || val > 0xff) {
  648. ret = -1;
  649. wpa_printf(MSG_DEBUG, "WPS: Invalid "
  650. "wps_version_number %ld", val);
  651. } else {
  652. wps_version_number = val;
  653. wpa_printf(MSG_DEBUG, "WPS: Testing - force WPS "
  654. "version %u.%u",
  655. (wps_version_number & 0xf0) >> 4,
  656. wps_version_number & 0x0f);
  657. hostapd_wps_update_ie(hapd);
  658. }
  659. } else if (os_strcasecmp(cmd, "wps_testing_dummy_cred") == 0) {
  660. wps_testing_dummy_cred = atoi(value);
  661. wpa_printf(MSG_DEBUG, "WPS: Testing - dummy_cred=%d",
  662. wps_testing_dummy_cred);
  663. #endif /* CONFIG_WPS_TESTING */
  664. } else {
  665. ret = -1;
  666. }
  667. return ret;
  668. }
  669. static int hostapd_ctrl_iface_get(struct hostapd_data *hapd, char *cmd,
  670. char *buf, size_t buflen)
  671. {
  672. int res;
  673. wpa_printf(MSG_DEBUG, "CTRL_IFACE GET '%s'", cmd);
  674. if (os_strcmp(cmd, "version") == 0) {
  675. res = os_snprintf(buf, buflen, "%s", VERSION_STR);
  676. if (res < 0 || (unsigned int) res >= buflen)
  677. return -1;
  678. return res;
  679. }
  680. return -1;
  681. }
  682. static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx,
  683. void *sock_ctx)
  684. {
  685. struct hostapd_data *hapd = eloop_ctx;
  686. char buf[256];
  687. int res;
  688. struct sockaddr_un from;
  689. socklen_t fromlen = sizeof(from);
  690. char *reply;
  691. const int reply_size = 4096;
  692. int reply_len;
  693. int level = MSG_DEBUG;
  694. res = recvfrom(sock, buf, sizeof(buf) - 1, 0,
  695. (struct sockaddr *) &from, &fromlen);
  696. if (res < 0) {
  697. perror("recvfrom(ctrl_iface)");
  698. return;
  699. }
  700. buf[res] = '\0';
  701. if (os_strcmp(buf, "PING") == 0)
  702. level = MSG_EXCESSIVE;
  703. wpa_hexdump_ascii(level, "RX ctrl_iface", (u8 *) buf, res);
  704. reply = os_malloc(reply_size);
  705. if (reply == NULL) {
  706. sendto(sock, "FAIL\n", 5, 0, (struct sockaddr *) &from,
  707. fromlen);
  708. return;
  709. }
  710. os_memcpy(reply, "OK\n", 3);
  711. reply_len = 3;
  712. if (os_strcmp(buf, "PING") == 0) {
  713. os_memcpy(reply, "PONG\n", 5);
  714. reply_len = 5;
  715. } else if (os_strncmp(buf, "RELOG", 5) == 0) {
  716. if (wpa_debug_reopen_file() < 0)
  717. reply_len = -1;
  718. } else if (os_strcmp(buf, "MIB") == 0) {
  719. reply_len = ieee802_11_get_mib(hapd, reply, reply_size);
  720. if (reply_len >= 0) {
  721. res = wpa_get_mib(hapd->wpa_auth, reply + reply_len,
  722. reply_size - reply_len);
  723. if (res < 0)
  724. reply_len = -1;
  725. else
  726. reply_len += res;
  727. }
  728. if (reply_len >= 0) {
  729. res = ieee802_1x_get_mib(hapd, reply + reply_len,
  730. reply_size - reply_len);
  731. if (res < 0)
  732. reply_len = -1;
  733. else
  734. reply_len += res;
  735. }
  736. #ifndef CONFIG_NO_RADIUS
  737. if (reply_len >= 0) {
  738. res = radius_client_get_mib(hapd->radius,
  739. reply + reply_len,
  740. reply_size - reply_len);
  741. if (res < 0)
  742. reply_len = -1;
  743. else
  744. reply_len += res;
  745. }
  746. #endif /* CONFIG_NO_RADIUS */
  747. } else if (os_strcmp(buf, "STA-FIRST") == 0) {
  748. reply_len = hostapd_ctrl_iface_sta_first(hapd, reply,
  749. reply_size);
  750. } else if (os_strncmp(buf, "STA ", 4) == 0) {
  751. reply_len = hostapd_ctrl_iface_sta(hapd, buf + 4, reply,
  752. reply_size);
  753. } else if (os_strncmp(buf, "STA-NEXT ", 9) == 0) {
  754. reply_len = hostapd_ctrl_iface_sta_next(hapd, buf + 9, reply,
  755. reply_size);
  756. } else if (os_strcmp(buf, "ATTACH") == 0) {
  757. if (hostapd_ctrl_iface_attach(hapd, &from, fromlen))
  758. reply_len = -1;
  759. } else if (os_strcmp(buf, "DETACH") == 0) {
  760. if (hostapd_ctrl_iface_detach(hapd, &from, fromlen))
  761. reply_len = -1;
  762. } else if (os_strncmp(buf, "LEVEL ", 6) == 0) {
  763. if (hostapd_ctrl_iface_level(hapd, &from, fromlen,
  764. buf + 6))
  765. reply_len = -1;
  766. } else if (os_strncmp(buf, "NEW_STA ", 8) == 0) {
  767. if (hostapd_ctrl_iface_new_sta(hapd, buf + 8))
  768. reply_len = -1;
  769. } else if (os_strncmp(buf, "DEAUTHENTICATE ", 15) == 0) {
  770. if (hostapd_ctrl_iface_deauthenticate(hapd, buf + 15))
  771. reply_len = -1;
  772. } else if (os_strncmp(buf, "DISASSOCIATE ", 13) == 0) {
  773. if (hostapd_ctrl_iface_disassociate(hapd, buf + 13))
  774. reply_len = -1;
  775. #ifdef CONFIG_IEEE80211W
  776. #ifdef NEED_AP_MLME
  777. } else if (os_strncmp(buf, "SA_QUERY ", 9) == 0) {
  778. if (hostapd_ctrl_iface_sa_query(hapd, buf + 9))
  779. reply_len = -1;
  780. #endif /* NEED_AP_MLME */
  781. #endif /* CONFIG_IEEE80211W */
  782. #ifdef CONFIG_WPS
  783. } else if (os_strncmp(buf, "WPS_PIN ", 8) == 0) {
  784. if (hostapd_ctrl_iface_wps_pin(hapd, buf + 8))
  785. reply_len = -1;
  786. } else if (os_strncmp(buf, "WPS_CHECK_PIN ", 14) == 0) {
  787. reply_len = hostapd_ctrl_iface_wps_check_pin(
  788. hapd, buf + 14, reply, reply_size);
  789. } else if (os_strcmp(buf, "WPS_PBC") == 0) {
  790. if (hostapd_wps_button_pushed(hapd, NULL))
  791. reply_len = -1;
  792. #ifdef CONFIG_WPS_OOB
  793. } else if (os_strncmp(buf, "WPS_OOB ", 8) == 0) {
  794. if (hostapd_ctrl_iface_wps_oob(hapd, buf + 8))
  795. reply_len = -1;
  796. #endif /* CONFIG_WPS_OOB */
  797. } else if (os_strncmp(buf, "WPS_AP_PIN ", 11) == 0) {
  798. reply_len = hostapd_ctrl_iface_wps_ap_pin(hapd, buf + 11,
  799. reply, reply_size);
  800. } else if (os_strncmp(buf, "WPS_CONFIG ", 11) == 0) {
  801. if (hostapd_ctrl_iface_wps_config(hapd, buf + 11) < 0)
  802. reply_len = -1;
  803. #endif /* CONFIG_WPS */
  804. } else if (os_strncmp(buf, "ESS_DISASSOC ", 13) == 0) {
  805. if (hostapd_ctrl_iface_ess_disassoc(hapd, buf + 13))
  806. reply_len = -1;
  807. } else if (os_strcmp(buf, "GET_CONFIG") == 0) {
  808. reply_len = hostapd_ctrl_iface_get_config(hapd, reply,
  809. reply_size);
  810. } else if (os_strncmp(buf, "SET ", 4) == 0) {
  811. if (hostapd_ctrl_iface_set(hapd, buf + 4))
  812. reply_len = -1;
  813. } else if (os_strncmp(buf, "GET ", 4) == 0) {
  814. reply_len = hostapd_ctrl_iface_get(hapd, buf + 4, reply,
  815. reply_size);
  816. } else {
  817. os_memcpy(reply, "UNKNOWN COMMAND\n", 16);
  818. reply_len = 16;
  819. }
  820. if (reply_len < 0) {
  821. os_memcpy(reply, "FAIL\n", 5);
  822. reply_len = 5;
  823. }
  824. sendto(sock, reply, reply_len, 0, (struct sockaddr *) &from, fromlen);
  825. os_free(reply);
  826. }
  827. static char * hostapd_ctrl_iface_path(struct hostapd_data *hapd)
  828. {
  829. char *buf;
  830. size_t len;
  831. if (hapd->conf->ctrl_interface == NULL)
  832. return NULL;
  833. len = os_strlen(hapd->conf->ctrl_interface) +
  834. os_strlen(hapd->conf->iface) + 2;
  835. buf = os_malloc(len);
  836. if (buf == NULL)
  837. return NULL;
  838. os_snprintf(buf, len, "%s/%s",
  839. hapd->conf->ctrl_interface, hapd->conf->iface);
  840. buf[len - 1] = '\0';
  841. return buf;
  842. }
  843. static void hostapd_ctrl_iface_msg_cb(void *ctx, int level,
  844. const char *txt, size_t len)
  845. {
  846. struct hostapd_data *hapd = ctx;
  847. if (hapd == NULL)
  848. return;
  849. hostapd_ctrl_iface_send(hapd, level, txt, len);
  850. }
  851. int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
  852. {
  853. struct sockaddr_un addr;
  854. int s = -1;
  855. char *fname = NULL;
  856. hapd->ctrl_sock = -1;
  857. if (hapd->conf->ctrl_interface == NULL)
  858. return 0;
  859. if (mkdir(hapd->conf->ctrl_interface, S_IRWXU | S_IRWXG) < 0) {
  860. if (errno == EEXIST) {
  861. wpa_printf(MSG_DEBUG, "Using existing control "
  862. "interface directory.");
  863. } else {
  864. perror("mkdir[ctrl_interface]");
  865. goto fail;
  866. }
  867. }
  868. if (hapd->conf->ctrl_interface_gid_set &&
  869. chown(hapd->conf->ctrl_interface, 0,
  870. hapd->conf->ctrl_interface_gid) < 0) {
  871. perror("chown[ctrl_interface]");
  872. return -1;
  873. }
  874. if (os_strlen(hapd->conf->ctrl_interface) + 1 +
  875. os_strlen(hapd->conf->iface) >= sizeof(addr.sun_path))
  876. goto fail;
  877. s = socket(PF_UNIX, SOCK_DGRAM, 0);
  878. if (s < 0) {
  879. perror("socket(PF_UNIX)");
  880. goto fail;
  881. }
  882. os_memset(&addr, 0, sizeof(addr));
  883. #ifdef __FreeBSD__
  884. addr.sun_len = sizeof(addr);
  885. #endif /* __FreeBSD__ */
  886. addr.sun_family = AF_UNIX;
  887. fname = hostapd_ctrl_iface_path(hapd);
  888. if (fname == NULL)
  889. goto fail;
  890. os_strlcpy(addr.sun_path, fname, sizeof(addr.sun_path));
  891. if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
  892. wpa_printf(MSG_DEBUG, "ctrl_iface bind(PF_UNIX) failed: %s",
  893. strerror(errno));
  894. if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
  895. wpa_printf(MSG_DEBUG, "ctrl_iface exists, but does not"
  896. " allow connections - assuming it was left"
  897. "over from forced program termination");
  898. if (unlink(fname) < 0) {
  899. perror("unlink[ctrl_iface]");
  900. wpa_printf(MSG_ERROR, "Could not unlink "
  901. "existing ctrl_iface socket '%s'",
  902. fname);
  903. goto fail;
  904. }
  905. if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) <
  906. 0) {
  907. perror("bind(PF_UNIX)");
  908. goto fail;
  909. }
  910. wpa_printf(MSG_DEBUG, "Successfully replaced leftover "
  911. "ctrl_iface socket '%s'", fname);
  912. } else {
  913. wpa_printf(MSG_INFO, "ctrl_iface exists and seems to "
  914. "be in use - cannot override it");
  915. wpa_printf(MSG_INFO, "Delete '%s' manually if it is "
  916. "not used anymore", fname);
  917. os_free(fname);
  918. fname = NULL;
  919. goto fail;
  920. }
  921. }
  922. if (hapd->conf->ctrl_interface_gid_set &&
  923. chown(fname, 0, hapd->conf->ctrl_interface_gid) < 0) {
  924. perror("chown[ctrl_interface/ifname]");
  925. goto fail;
  926. }
  927. if (chmod(fname, S_IRWXU | S_IRWXG) < 0) {
  928. perror("chmod[ctrl_interface/ifname]");
  929. goto fail;
  930. }
  931. os_free(fname);
  932. hapd->ctrl_sock = s;
  933. eloop_register_read_sock(s, hostapd_ctrl_iface_receive, hapd,
  934. NULL);
  935. hapd->msg_ctx = hapd;
  936. wpa_msg_register_cb(hostapd_ctrl_iface_msg_cb);
  937. return 0;
  938. fail:
  939. if (s >= 0)
  940. close(s);
  941. if (fname) {
  942. unlink(fname);
  943. os_free(fname);
  944. }
  945. return -1;
  946. }
  947. void hostapd_ctrl_iface_deinit(struct hostapd_data *hapd)
  948. {
  949. struct wpa_ctrl_dst *dst, *prev;
  950. if (hapd->ctrl_sock > -1) {
  951. char *fname;
  952. eloop_unregister_read_sock(hapd->ctrl_sock);
  953. close(hapd->ctrl_sock);
  954. hapd->ctrl_sock = -1;
  955. fname = hostapd_ctrl_iface_path(hapd);
  956. if (fname)
  957. unlink(fname);
  958. os_free(fname);
  959. if (hapd->conf->ctrl_interface &&
  960. rmdir(hapd->conf->ctrl_interface) < 0) {
  961. if (errno == ENOTEMPTY) {
  962. wpa_printf(MSG_DEBUG, "Control interface "
  963. "directory not empty - leaving it "
  964. "behind");
  965. } else {
  966. perror("rmdir[ctrl_interface]");
  967. }
  968. }
  969. }
  970. dst = hapd->ctrl_dst;
  971. while (dst) {
  972. prev = dst;
  973. dst = dst->next;
  974. os_free(prev);
  975. }
  976. }
  977. static void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level,
  978. const char *buf, size_t len)
  979. {
  980. struct wpa_ctrl_dst *dst, *next;
  981. struct msghdr msg;
  982. int idx;
  983. struct iovec io[2];
  984. char levelstr[10];
  985. dst = hapd->ctrl_dst;
  986. if (hapd->ctrl_sock < 0 || dst == NULL)
  987. return;
  988. os_snprintf(levelstr, sizeof(levelstr), "<%d>", level);
  989. io[0].iov_base = levelstr;
  990. io[0].iov_len = os_strlen(levelstr);
  991. io[1].iov_base = (char *) buf;
  992. io[1].iov_len = len;
  993. os_memset(&msg, 0, sizeof(msg));
  994. msg.msg_iov = io;
  995. msg.msg_iovlen = 2;
  996. idx = 0;
  997. while (dst) {
  998. next = dst->next;
  999. if (level >= dst->debug_level) {
  1000. wpa_hexdump(MSG_DEBUG, "CTRL_IFACE monitor send",
  1001. (u8 *) dst->addr.sun_path, dst->addrlen -
  1002. offsetof(struct sockaddr_un, sun_path));
  1003. msg.msg_name = &dst->addr;
  1004. msg.msg_namelen = dst->addrlen;
  1005. if (sendmsg(hapd->ctrl_sock, &msg, 0) < 0) {
  1006. int _errno = errno;
  1007. wpa_printf(MSG_INFO, "CTRL_IFACE monitor[%d]: "
  1008. "%d - %s",
  1009. idx, errno, strerror(errno));
  1010. dst->errors++;
  1011. if (dst->errors > 10 || _errno == ENOENT) {
  1012. hostapd_ctrl_iface_detach(
  1013. hapd, &dst->addr,
  1014. dst->addrlen);
  1015. }
  1016. } else
  1017. dst->errors = 0;
  1018. }
  1019. idx++;
  1020. dst = next;
  1021. }
  1022. }
  1023. #endif /* CONFIG_NATIVE_WINDOWS */