ctrl_iface.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. /*
  2. * hostapd / UNIX domain socket -based control interface
  3. * Copyright (c) 2004-2008, 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 "includes.h"
  15. #ifndef CONFIG_NATIVE_WINDOWS
  16. #include <sys/un.h>
  17. #include <sys/stat.h>
  18. #include <stddef.h>
  19. #include "hostapd.h"
  20. #include "eloop.h"
  21. #include "config.h"
  22. #include "ieee802_1x.h"
  23. #include "wpa.h"
  24. #include "radius/radius_client.h"
  25. #include "ieee802_11.h"
  26. #include "ctrl_iface.h"
  27. #include "sta_info.h"
  28. #include "accounting.h"
  29. #include "wps_hostapd.h"
  30. #include "drivers/driver.h"
  31. struct wpa_ctrl_dst {
  32. struct wpa_ctrl_dst *next;
  33. struct sockaddr_un addr;
  34. socklen_t addrlen;
  35. int debug_level;
  36. int errors;
  37. };
  38. static void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level,
  39. const char *buf, size_t len);
  40. static int hostapd_ctrl_iface_attach(struct hostapd_data *hapd,
  41. struct sockaddr_un *from,
  42. socklen_t fromlen)
  43. {
  44. struct wpa_ctrl_dst *dst;
  45. dst = os_zalloc(sizeof(*dst));
  46. if (dst == NULL)
  47. return -1;
  48. os_memcpy(&dst->addr, from, sizeof(struct sockaddr_un));
  49. dst->addrlen = fromlen;
  50. dst->debug_level = MSG_INFO;
  51. dst->next = hapd->ctrl_dst;
  52. hapd->ctrl_dst = dst;
  53. wpa_hexdump(MSG_DEBUG, "CTRL_IFACE monitor attached",
  54. (u8 *) from->sun_path,
  55. fromlen - offsetof(struct sockaddr_un, sun_path));
  56. return 0;
  57. }
  58. static int hostapd_ctrl_iface_detach(struct hostapd_data *hapd,
  59. struct sockaddr_un *from,
  60. socklen_t fromlen)
  61. {
  62. struct wpa_ctrl_dst *dst, *prev = NULL;
  63. dst = hapd->ctrl_dst;
  64. while (dst) {
  65. if (fromlen == dst->addrlen &&
  66. os_memcmp(from->sun_path, dst->addr.sun_path,
  67. fromlen - offsetof(struct sockaddr_un, sun_path))
  68. == 0) {
  69. if (prev == NULL)
  70. hapd->ctrl_dst = dst->next;
  71. else
  72. prev->next = dst->next;
  73. os_free(dst);
  74. wpa_hexdump(MSG_DEBUG, "CTRL_IFACE monitor detached",
  75. (u8 *) from->sun_path,
  76. fromlen -
  77. offsetof(struct sockaddr_un, sun_path));
  78. return 0;
  79. }
  80. prev = dst;
  81. dst = dst->next;
  82. }
  83. return -1;
  84. }
  85. static int hostapd_ctrl_iface_level(struct hostapd_data *hapd,
  86. struct sockaddr_un *from,
  87. socklen_t fromlen,
  88. char *level)
  89. {
  90. struct wpa_ctrl_dst *dst;
  91. wpa_printf(MSG_DEBUG, "CTRL_IFACE LEVEL %s", level);
  92. dst = hapd->ctrl_dst;
  93. while (dst) {
  94. if (fromlen == dst->addrlen &&
  95. os_memcmp(from->sun_path, dst->addr.sun_path,
  96. fromlen - offsetof(struct sockaddr_un, sun_path))
  97. == 0) {
  98. wpa_hexdump(MSG_DEBUG, "CTRL_IFACE changed monitor "
  99. "level", (u8 *) from->sun_path, fromlen -
  100. offsetof(struct sockaddr_un, sun_path));
  101. dst->debug_level = atoi(level);
  102. return 0;
  103. }
  104. dst = dst->next;
  105. }
  106. return -1;
  107. }
  108. static int hostapd_ctrl_iface_sta_mib(struct hostapd_data *hapd,
  109. struct sta_info *sta,
  110. char *buf, size_t buflen)
  111. {
  112. int len, res, ret;
  113. if (sta == NULL) {
  114. ret = os_snprintf(buf, buflen, "FAIL\n");
  115. if (ret < 0 || (size_t) ret >= buflen)
  116. return 0;
  117. return ret;
  118. }
  119. len = 0;
  120. ret = os_snprintf(buf + len, buflen - len, MACSTR "\n",
  121. MAC2STR(sta->addr));
  122. if (ret < 0 || (size_t) ret >= buflen - len)
  123. return len;
  124. len += ret;
  125. res = ieee802_11_get_mib_sta(hapd, sta, buf + len, buflen - len);
  126. if (res >= 0)
  127. len += res;
  128. res = wpa_get_mib_sta(sta->wpa_sm, buf + len, buflen - len);
  129. if (res >= 0)
  130. len += res;
  131. res = ieee802_1x_get_mib_sta(hapd, sta, buf + len, buflen - len);
  132. if (res >= 0)
  133. len += res;
  134. return len;
  135. }
  136. static int hostapd_ctrl_iface_sta_first(struct hostapd_data *hapd,
  137. char *buf, size_t buflen)
  138. {
  139. return hostapd_ctrl_iface_sta_mib(hapd, hapd->sta_list, buf, buflen);
  140. }
  141. static int hostapd_ctrl_iface_sta(struct hostapd_data *hapd,
  142. const char *txtaddr,
  143. char *buf, size_t buflen)
  144. {
  145. u8 addr[ETH_ALEN];
  146. int ret;
  147. if (hwaddr_aton(txtaddr, addr)) {
  148. ret = os_snprintf(buf, buflen, "FAIL\n");
  149. if (ret < 0 || (size_t) ret >= buflen)
  150. return 0;
  151. return ret;
  152. }
  153. return hostapd_ctrl_iface_sta_mib(hapd, ap_get_sta(hapd, addr),
  154. buf, buflen);
  155. }
  156. static int hostapd_ctrl_iface_sta_next(struct hostapd_data *hapd,
  157. const char *txtaddr,
  158. char *buf, size_t buflen)
  159. {
  160. u8 addr[ETH_ALEN];
  161. struct sta_info *sta;
  162. int ret;
  163. if (hwaddr_aton(txtaddr, addr) ||
  164. (sta = ap_get_sta(hapd, addr)) == NULL) {
  165. ret = os_snprintf(buf, buflen, "FAIL\n");
  166. if (ret < 0 || (size_t) ret >= buflen)
  167. return 0;
  168. return ret;
  169. }
  170. return hostapd_ctrl_iface_sta_mib(hapd, sta->next, buf, buflen);
  171. }
  172. static int hostapd_ctrl_iface_new_sta(struct hostapd_data *hapd,
  173. const char *txtaddr)
  174. {
  175. u8 addr[ETH_ALEN];
  176. struct sta_info *sta;
  177. wpa_printf(MSG_DEBUG, "CTRL_IFACE NEW_STA %s", txtaddr);
  178. if (hwaddr_aton(txtaddr, addr))
  179. return -1;
  180. sta = ap_get_sta(hapd, addr);
  181. if (sta)
  182. return 0;
  183. wpa_printf(MSG_DEBUG, "Add new STA " MACSTR " based on ctrl_iface "
  184. "notification", MAC2STR(addr));
  185. sta = ap_sta_add(hapd, addr);
  186. if (sta == NULL)
  187. return -1;
  188. hostapd_new_assoc_sta(hapd, sta, 0);
  189. return 0;
  190. }
  191. #ifdef CONFIG_IEEE80211W
  192. #ifdef NEED_AP_MLME
  193. static int hostapd_ctrl_iface_sa_query(struct hostapd_data *hapd,
  194. const char *txtaddr)
  195. {
  196. u8 addr[ETH_ALEN];
  197. u8 trans_id[WLAN_SA_QUERY_TR_ID_LEN];
  198. wpa_printf(MSG_DEBUG, "CTRL_IFACE SA_QUERY %s", txtaddr);
  199. if (hwaddr_aton(txtaddr, addr))
  200. return -1;
  201. os_get_random(trans_id, WLAN_SA_QUERY_TR_ID_LEN);
  202. ieee802_11_send_sa_query_req(hapd, addr, trans_id);
  203. return 0;
  204. }
  205. #endif /* NEED_AP_MLME */
  206. #endif /* CONFIG_IEEE80211W */
  207. #ifdef CONFIG_WPS
  208. static int hostapd_ctrl_iface_wps_pin(struct hostapd_data *hapd, char *txt)
  209. {
  210. char *pin = os_strchr(txt, ' ');
  211. char *timeout_txt;
  212. int timeout;
  213. if (pin == NULL)
  214. return -1;
  215. *pin++ = '\0';
  216. timeout_txt = os_strchr(pin, ' ');
  217. if (timeout_txt) {
  218. *timeout_txt++ = '\0';
  219. timeout = atoi(timeout_txt);
  220. } else
  221. timeout = 0;
  222. return hostapd_wps_add_pin(hapd, txt, pin, timeout);
  223. }
  224. #ifdef CONFIG_WPS_OOB
  225. static int hostapd_ctrl_iface_wps_oob(struct hostapd_data *hapd, char *txt)
  226. {
  227. char *path, *method, *name;
  228. path = os_strchr(txt, ' ');
  229. if (path == NULL)
  230. return -1;
  231. *path++ = '\0';
  232. method = os_strchr(path, ' ');
  233. if (method == NULL)
  234. return -1;
  235. *method++ = '\0';
  236. name = os_strchr(method, ' ');
  237. if (name != NULL)
  238. *name++ = '\0';
  239. return hostapd_wps_start_oob(hapd, txt, path, method, name);
  240. }
  241. #endif /* CONFIG_WPS_OOB */
  242. #endif /* CONFIG_WPS */
  243. static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx,
  244. void *sock_ctx)
  245. {
  246. struct hostapd_data *hapd = eloop_ctx;
  247. char buf[256];
  248. int res;
  249. struct sockaddr_un from;
  250. socklen_t fromlen = sizeof(from);
  251. char *reply;
  252. const int reply_size = 4096;
  253. int reply_len;
  254. res = recvfrom(sock, buf, sizeof(buf) - 1, 0,
  255. (struct sockaddr *) &from, &fromlen);
  256. if (res < 0) {
  257. perror("recvfrom(ctrl_iface)");
  258. return;
  259. }
  260. buf[res] = '\0';
  261. wpa_hexdump_ascii(MSG_DEBUG, "RX ctrl_iface", (u8 *) buf, res);
  262. reply = os_malloc(reply_size);
  263. if (reply == NULL) {
  264. sendto(sock, "FAIL\n", 5, 0, (struct sockaddr *) &from,
  265. fromlen);
  266. return;
  267. }
  268. os_memcpy(reply, "OK\n", 3);
  269. reply_len = 3;
  270. if (os_strcmp(buf, "PING") == 0) {
  271. os_memcpy(reply, "PONG\n", 5);
  272. reply_len = 5;
  273. } else if (os_strcmp(buf, "MIB") == 0) {
  274. reply_len = ieee802_11_get_mib(hapd, reply, reply_size);
  275. if (reply_len >= 0) {
  276. res = wpa_get_mib(hapd->wpa_auth, reply + reply_len,
  277. reply_size - reply_len);
  278. if (res < 0)
  279. reply_len = -1;
  280. else
  281. reply_len += res;
  282. }
  283. if (reply_len >= 0) {
  284. res = ieee802_1x_get_mib(hapd, reply + reply_len,
  285. reply_size - reply_len);
  286. if (res < 0)
  287. reply_len = -1;
  288. else
  289. reply_len += res;
  290. }
  291. if (reply_len >= 0) {
  292. res = radius_client_get_mib(hapd->radius,
  293. reply + reply_len,
  294. reply_size - reply_len);
  295. if (res < 0)
  296. reply_len = -1;
  297. else
  298. reply_len += res;
  299. }
  300. } else if (os_strcmp(buf, "STA-FIRST") == 0) {
  301. reply_len = hostapd_ctrl_iface_sta_first(hapd, reply,
  302. reply_size);
  303. } else if (os_strncmp(buf, "STA ", 4) == 0) {
  304. reply_len = hostapd_ctrl_iface_sta(hapd, buf + 4, reply,
  305. reply_size);
  306. } else if (os_strncmp(buf, "STA-NEXT ", 9) == 0) {
  307. reply_len = hostapd_ctrl_iface_sta_next(hapd, buf + 9, reply,
  308. reply_size);
  309. } else if (os_strcmp(buf, "ATTACH") == 0) {
  310. if (hostapd_ctrl_iface_attach(hapd, &from, fromlen))
  311. reply_len = -1;
  312. } else if (os_strcmp(buf, "DETACH") == 0) {
  313. if (hostapd_ctrl_iface_detach(hapd, &from, fromlen))
  314. reply_len = -1;
  315. } else if (os_strncmp(buf, "LEVEL ", 6) == 0) {
  316. if (hostapd_ctrl_iface_level(hapd, &from, fromlen,
  317. buf + 6))
  318. reply_len = -1;
  319. } else if (os_strncmp(buf, "NEW_STA ", 8) == 0) {
  320. if (hostapd_ctrl_iface_new_sta(hapd, buf + 8))
  321. reply_len = -1;
  322. #ifdef CONFIG_IEEE80211W
  323. #ifdef NEED_AP_MLME
  324. } else if (os_strncmp(buf, "SA_QUERY ", 9) == 0) {
  325. if (hostapd_ctrl_iface_sa_query(hapd, buf + 9))
  326. reply_len = -1;
  327. #endif /* NEED_AP_MLME */
  328. #endif /* CONFIG_IEEE80211W */
  329. #ifdef CONFIG_WPS
  330. } else if (os_strncmp(buf, "WPS_PIN ", 8) == 0) {
  331. if (hostapd_ctrl_iface_wps_pin(hapd, buf + 8))
  332. reply_len = -1;
  333. } else if (os_strcmp(buf, "WPS_PBC") == 0) {
  334. if (hostapd_wps_button_pushed(hapd))
  335. reply_len = -1;
  336. #ifdef CONFIG_WPS_OOB
  337. } else if (os_strncmp(buf, "WPS_OOB ", 8) == 0) {
  338. if (hostapd_ctrl_iface_wps_oob(hapd, buf + 8))
  339. reply_len = -1;
  340. #endif /* CONFIG_WPS_OOB */
  341. #endif /* CONFIG_WPS */
  342. } else {
  343. os_memcpy(reply, "UNKNOWN COMMAND\n", 16);
  344. reply_len = 16;
  345. }
  346. if (reply_len < 0) {
  347. os_memcpy(reply, "FAIL\n", 5);
  348. reply_len = 5;
  349. }
  350. sendto(sock, reply, reply_len, 0, (struct sockaddr *) &from, fromlen);
  351. os_free(reply);
  352. }
  353. static char * hostapd_ctrl_iface_path(struct hostapd_data *hapd)
  354. {
  355. char *buf;
  356. size_t len;
  357. if (hapd->conf->ctrl_interface == NULL)
  358. return NULL;
  359. len = os_strlen(hapd->conf->ctrl_interface) +
  360. os_strlen(hapd->conf->iface) + 2;
  361. buf = os_malloc(len);
  362. if (buf == NULL)
  363. return NULL;
  364. os_snprintf(buf, len, "%s/%s",
  365. hapd->conf->ctrl_interface, hapd->conf->iface);
  366. buf[len - 1] = '\0';
  367. return buf;
  368. }
  369. static void hostapd_ctrl_iface_msg_cb(void *ctx, int level,
  370. const char *txt, size_t len)
  371. {
  372. struct hostapd_data *hapd = ctx;
  373. if (hapd == NULL)
  374. return;
  375. hostapd_ctrl_iface_send(hapd, level, txt, len);
  376. }
  377. int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
  378. {
  379. struct sockaddr_un addr;
  380. int s = -1;
  381. char *fname = NULL;
  382. hapd->ctrl_sock = -1;
  383. if (hapd->conf->ctrl_interface == NULL)
  384. return 0;
  385. if (mkdir(hapd->conf->ctrl_interface, S_IRWXU | S_IRWXG) < 0) {
  386. if (errno == EEXIST) {
  387. wpa_printf(MSG_DEBUG, "Using existing control "
  388. "interface directory.");
  389. } else {
  390. perror("mkdir[ctrl_interface]");
  391. goto fail;
  392. }
  393. }
  394. if (hapd->conf->ctrl_interface_gid_set &&
  395. chown(hapd->conf->ctrl_interface, 0,
  396. hapd->conf->ctrl_interface_gid) < 0) {
  397. perror("chown[ctrl_interface]");
  398. return -1;
  399. }
  400. if (os_strlen(hapd->conf->ctrl_interface) + 1 +
  401. os_strlen(hapd->conf->iface) >= sizeof(addr.sun_path))
  402. goto fail;
  403. s = socket(PF_UNIX, SOCK_DGRAM, 0);
  404. if (s < 0) {
  405. perror("socket(PF_UNIX)");
  406. goto fail;
  407. }
  408. os_memset(&addr, 0, sizeof(addr));
  409. #ifdef __FreeBSD__
  410. addr.sun_len = sizeof(addr);
  411. #endif /* __FreeBSD__ */
  412. addr.sun_family = AF_UNIX;
  413. fname = hostapd_ctrl_iface_path(hapd);
  414. if (fname == NULL)
  415. goto fail;
  416. os_strlcpy(addr.sun_path, fname, sizeof(addr.sun_path));
  417. if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
  418. wpa_printf(MSG_DEBUG, "ctrl_iface bind(PF_UNIX) failed: %s",
  419. strerror(errno));
  420. if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
  421. wpa_printf(MSG_DEBUG, "ctrl_iface exists, but does not"
  422. " allow connections - assuming it was left"
  423. "over from forced program termination");
  424. if (unlink(fname) < 0) {
  425. perror("unlink[ctrl_iface]");
  426. wpa_printf(MSG_ERROR, "Could not unlink "
  427. "existing ctrl_iface socket '%s'",
  428. fname);
  429. goto fail;
  430. }
  431. if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) <
  432. 0) {
  433. perror("bind(PF_UNIX)");
  434. goto fail;
  435. }
  436. wpa_printf(MSG_DEBUG, "Successfully replaced leftover "
  437. "ctrl_iface socket '%s'", fname);
  438. } else {
  439. wpa_printf(MSG_INFO, "ctrl_iface exists and seems to "
  440. "be in use - cannot override it");
  441. wpa_printf(MSG_INFO, "Delete '%s' manually if it is "
  442. "not used anymore", fname);
  443. os_free(fname);
  444. fname = NULL;
  445. goto fail;
  446. }
  447. }
  448. if (hapd->conf->ctrl_interface_gid_set &&
  449. chown(fname, 0, hapd->conf->ctrl_interface_gid) < 0) {
  450. perror("chown[ctrl_interface/ifname]");
  451. goto fail;
  452. }
  453. if (chmod(fname, S_IRWXU | S_IRWXG) < 0) {
  454. perror("chmod[ctrl_interface/ifname]");
  455. goto fail;
  456. }
  457. os_free(fname);
  458. hapd->ctrl_sock = s;
  459. eloop_register_read_sock(s, hostapd_ctrl_iface_receive, hapd,
  460. NULL);
  461. wpa_msg_register_cb(hostapd_ctrl_iface_msg_cb);
  462. return 0;
  463. fail:
  464. if (s >= 0)
  465. close(s);
  466. if (fname) {
  467. unlink(fname);
  468. os_free(fname);
  469. }
  470. return -1;
  471. }
  472. void hostapd_ctrl_iface_deinit(struct hostapd_data *hapd)
  473. {
  474. struct wpa_ctrl_dst *dst, *prev;
  475. if (hapd->ctrl_sock > -1) {
  476. char *fname;
  477. eloop_unregister_read_sock(hapd->ctrl_sock);
  478. close(hapd->ctrl_sock);
  479. hapd->ctrl_sock = -1;
  480. fname = hostapd_ctrl_iface_path(hapd);
  481. if (fname)
  482. unlink(fname);
  483. os_free(fname);
  484. if (hapd->conf->ctrl_interface &&
  485. rmdir(hapd->conf->ctrl_interface) < 0) {
  486. if (errno == ENOTEMPTY) {
  487. wpa_printf(MSG_DEBUG, "Control interface "
  488. "directory not empty - leaving it "
  489. "behind");
  490. } else {
  491. perror("rmdir[ctrl_interface]");
  492. }
  493. }
  494. }
  495. dst = hapd->ctrl_dst;
  496. while (dst) {
  497. prev = dst;
  498. dst = dst->next;
  499. os_free(prev);
  500. }
  501. }
  502. static void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level,
  503. const char *buf, size_t len)
  504. {
  505. struct wpa_ctrl_dst *dst, *next;
  506. struct msghdr msg;
  507. int idx;
  508. struct iovec io[2];
  509. char levelstr[10];
  510. dst = hapd->ctrl_dst;
  511. if (hapd->ctrl_sock < 0 || dst == NULL)
  512. return;
  513. os_snprintf(levelstr, sizeof(levelstr), "<%d>", level);
  514. io[0].iov_base = levelstr;
  515. io[0].iov_len = os_strlen(levelstr);
  516. io[1].iov_base = (char *) buf;
  517. io[1].iov_len = len;
  518. os_memset(&msg, 0, sizeof(msg));
  519. msg.msg_iov = io;
  520. msg.msg_iovlen = 2;
  521. idx = 0;
  522. while (dst) {
  523. next = dst->next;
  524. if (level >= dst->debug_level) {
  525. wpa_hexdump(MSG_DEBUG, "CTRL_IFACE monitor send",
  526. (u8 *) dst->addr.sun_path, dst->addrlen -
  527. offsetof(struct sockaddr_un, sun_path));
  528. msg.msg_name = &dst->addr;
  529. msg.msg_namelen = dst->addrlen;
  530. if (sendmsg(hapd->ctrl_sock, &msg, 0) < 0) {
  531. int _errno = errno;
  532. wpa_printf(MSG_INFO, "CTRL_IFACE monitor[%d]: "
  533. "%d - %s",
  534. idx, errno, strerror(errno));
  535. dst->errors++;
  536. if (dst->errors > 10 || _errno == ENOENT) {
  537. hostapd_ctrl_iface_detach(
  538. hapd, &dst->addr,
  539. dst->addrlen);
  540. }
  541. } else
  542. dst->errors = 0;
  543. }
  544. idx++;
  545. dst = next;
  546. }
  547. }
  548. #endif /* CONFIG_NATIVE_WINDOWS */