driver_test.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268
  1. /*
  2. * hostapd / Driver interface for development testing
  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. #include <sys/un.h>
  16. #include <dirent.h>
  17. #include "hostapd.h"
  18. #include "driver.h"
  19. #include "sha1.h"
  20. #include "eloop.h"
  21. #include "ieee802_1x.h"
  22. #include "sta_info.h"
  23. #include "wpa.h"
  24. #include "accounting.h"
  25. #include "radius/radius.h"
  26. #include "l2_packet/l2_packet.h"
  27. #include "ieee802_11.h"
  28. #include "hw_features.h"
  29. #include "wps_hostapd.h"
  30. struct test_client_socket {
  31. struct test_client_socket *next;
  32. u8 addr[ETH_ALEN];
  33. struct sockaddr_un un;
  34. socklen_t unlen;
  35. struct test_driver_bss *bss;
  36. };
  37. struct test_driver_bss {
  38. struct test_driver_bss *next;
  39. char ifname[IFNAMSIZ + 1];
  40. u8 bssid[ETH_ALEN];
  41. u8 *ie;
  42. size_t ielen;
  43. u8 *wps_beacon_ie;
  44. size_t wps_beacon_ie_len;
  45. u8 *wps_probe_resp_ie;
  46. size_t wps_probe_resp_ie_len;
  47. u8 ssid[32];
  48. size_t ssid_len;
  49. int privacy;
  50. };
  51. struct test_driver_data {
  52. struct hostapd_data *hapd;
  53. struct test_client_socket *cli;
  54. int test_socket;
  55. struct test_driver_bss *bss;
  56. char *socket_dir;
  57. char *own_socket_path;
  58. };
  59. static void test_driver_free_bss(struct test_driver_bss *bss)
  60. {
  61. free(bss->ie);
  62. free(bss->wps_beacon_ie);
  63. free(bss->wps_probe_resp_ie);
  64. free(bss);
  65. }
  66. static void test_driver_free_priv(struct test_driver_data *drv)
  67. {
  68. struct test_driver_bss *bss, *prev;
  69. if (drv == NULL)
  70. return;
  71. bss = drv->bss;
  72. while (bss) {
  73. prev = bss;
  74. bss = bss->next;
  75. test_driver_free_bss(prev);
  76. }
  77. free(drv->own_socket_path);
  78. free(drv->socket_dir);
  79. free(drv);
  80. }
  81. static struct test_client_socket *
  82. test_driver_get_cli(struct test_driver_data *drv, struct sockaddr_un *from,
  83. socklen_t fromlen)
  84. {
  85. struct test_client_socket *cli = drv->cli;
  86. while (cli) {
  87. if (cli->unlen == fromlen &&
  88. strncmp(cli->un.sun_path, from->sun_path,
  89. fromlen - sizeof(cli->un.sun_family)) == 0)
  90. return cli;
  91. cli = cli->next;
  92. }
  93. return NULL;
  94. }
  95. static int test_driver_send_eapol(void *priv, const u8 *addr, const u8 *data,
  96. size_t data_len, int encrypt,
  97. const u8 *own_addr)
  98. {
  99. struct test_driver_data *drv = priv;
  100. struct test_client_socket *cli;
  101. struct msghdr msg;
  102. struct iovec io[3];
  103. struct l2_ethhdr eth;
  104. if (drv->test_socket < 0)
  105. return -1;
  106. cli = drv->cli;
  107. while (cli) {
  108. if (memcmp(cli->addr, addr, ETH_ALEN) == 0)
  109. break;
  110. cli = cli->next;
  111. }
  112. if (!cli) {
  113. wpa_printf(MSG_DEBUG, "%s: no destination client entry",
  114. __func__);
  115. return -1;
  116. }
  117. memcpy(eth.h_dest, addr, ETH_ALEN);
  118. memcpy(eth.h_source, own_addr, ETH_ALEN);
  119. eth.h_proto = htons(ETH_P_EAPOL);
  120. io[0].iov_base = "EAPOL ";
  121. io[0].iov_len = 6;
  122. io[1].iov_base = &eth;
  123. io[1].iov_len = sizeof(eth);
  124. io[2].iov_base = (u8 *) data;
  125. io[2].iov_len = data_len;
  126. memset(&msg, 0, sizeof(msg));
  127. msg.msg_iov = io;
  128. msg.msg_iovlen = 3;
  129. msg.msg_name = &cli->un;
  130. msg.msg_namelen = cli->unlen;
  131. return sendmsg(drv->test_socket, &msg, 0);
  132. }
  133. static int test_driver_send_ether(void *priv, const u8 *dst, const u8 *src,
  134. u16 proto, const u8 *data, size_t data_len)
  135. {
  136. struct test_driver_data *drv = priv;
  137. struct msghdr msg;
  138. struct iovec io[3];
  139. struct l2_ethhdr eth;
  140. char desttxt[30];
  141. struct sockaddr_un addr;
  142. struct dirent *dent;
  143. DIR *dir;
  144. int ret = 0, broadcast = 0, count = 0;
  145. if (drv->test_socket < 0 || drv->socket_dir == NULL) {
  146. wpa_printf(MSG_DEBUG, "%s: invalid parameters (sock=%d "
  147. "socket_dir=%p)",
  148. __func__, drv->test_socket, drv->socket_dir);
  149. return -1;
  150. }
  151. broadcast = memcmp(dst, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) == 0;
  152. snprintf(desttxt, sizeof(desttxt), MACSTR, MAC2STR(dst));
  153. memcpy(eth.h_dest, dst, ETH_ALEN);
  154. memcpy(eth.h_source, src, ETH_ALEN);
  155. eth.h_proto = htons(proto);
  156. io[0].iov_base = "ETHER ";
  157. io[0].iov_len = 6;
  158. io[1].iov_base = &eth;
  159. io[1].iov_len = sizeof(eth);
  160. io[2].iov_base = (u8 *) data;
  161. io[2].iov_len = data_len;
  162. memset(&msg, 0, sizeof(msg));
  163. msg.msg_iov = io;
  164. msg.msg_iovlen = 3;
  165. dir = opendir(drv->socket_dir);
  166. if (dir == NULL) {
  167. perror("test_driver: opendir");
  168. return -1;
  169. }
  170. while ((dent = readdir(dir))) {
  171. #ifdef _DIRENT_HAVE_D_TYPE
  172. /* Skip the file if it is not a socket. Also accept
  173. * DT_UNKNOWN (0) in case the C library or underlying file
  174. * system does not support d_type. */
  175. if (dent->d_type != DT_SOCK && dent->d_type != DT_UNKNOWN)
  176. continue;
  177. #endif /* _DIRENT_HAVE_D_TYPE */
  178. if (strcmp(dent->d_name, ".") == 0 ||
  179. strcmp(dent->d_name, "..") == 0)
  180. continue;
  181. memset(&addr, 0, sizeof(addr));
  182. addr.sun_family = AF_UNIX;
  183. snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%s",
  184. drv->socket_dir, dent->d_name);
  185. if (strcmp(addr.sun_path, drv->own_socket_path) == 0)
  186. continue;
  187. if (!broadcast && strstr(dent->d_name, desttxt) == NULL)
  188. continue;
  189. wpa_printf(MSG_DEBUG, "%s: Send ether frame to %s",
  190. __func__, dent->d_name);
  191. msg.msg_name = &addr;
  192. msg.msg_namelen = sizeof(addr);
  193. ret = sendmsg(drv->test_socket, &msg, 0);
  194. if (ret < 0)
  195. perror("driver_test: sendmsg");
  196. count++;
  197. }
  198. closedir(dir);
  199. if (!broadcast && count == 0) {
  200. wpa_printf(MSG_DEBUG, "%s: Destination " MACSTR " not found",
  201. __func__, MAC2STR(dst));
  202. return -1;
  203. }
  204. return ret;
  205. }
  206. static int test_driver_send_mgmt_frame(void *priv, const void *buf,
  207. size_t len, int flags)
  208. {
  209. struct test_driver_data *drv = priv;
  210. struct msghdr msg;
  211. struct iovec io[2];
  212. const u8 *dest;
  213. int ret = 0, broadcast = 0;
  214. char desttxt[30];
  215. struct sockaddr_un addr;
  216. struct dirent *dent;
  217. DIR *dir;
  218. struct ieee80211_hdr *hdr;
  219. u16 fc;
  220. if (drv->test_socket < 0 || len < 10 || drv->socket_dir == NULL) {
  221. wpa_printf(MSG_DEBUG, "%s: invalid parameters (sock=%d len=%lu"
  222. " socket_dir=%p)",
  223. __func__, drv->test_socket, (unsigned long) len,
  224. drv->socket_dir);
  225. return -1;
  226. }
  227. dest = buf;
  228. dest += 4;
  229. broadcast = memcmp(dest, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) == 0;
  230. snprintf(desttxt, sizeof(desttxt), MACSTR, MAC2STR(dest));
  231. io[0].iov_base = "MLME ";
  232. io[0].iov_len = 5;
  233. io[1].iov_base = (void *) buf;
  234. io[1].iov_len = len;
  235. memset(&msg, 0, sizeof(msg));
  236. msg.msg_iov = io;
  237. msg.msg_iovlen = 2;
  238. dir = opendir(drv->socket_dir);
  239. if (dir == NULL) {
  240. perror("test_driver: opendir");
  241. return -1;
  242. }
  243. while ((dent = readdir(dir))) {
  244. #ifdef _DIRENT_HAVE_D_TYPE
  245. /* Skip the file if it is not a socket. Also accept
  246. * DT_UNKNOWN (0) in case the C library or underlying file
  247. * system does not support d_type. */
  248. if (dent->d_type != DT_SOCK && dent->d_type != DT_UNKNOWN)
  249. continue;
  250. #endif /* _DIRENT_HAVE_D_TYPE */
  251. if (strcmp(dent->d_name, ".") == 0 ||
  252. strcmp(dent->d_name, "..") == 0)
  253. continue;
  254. memset(&addr, 0, sizeof(addr));
  255. addr.sun_family = AF_UNIX;
  256. snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%s",
  257. drv->socket_dir, dent->d_name);
  258. if (strcmp(addr.sun_path, drv->own_socket_path) == 0)
  259. continue;
  260. if (!broadcast && strstr(dent->d_name, desttxt) == NULL)
  261. continue;
  262. wpa_printf(MSG_DEBUG, "%s: Send management frame to %s",
  263. __func__, dent->d_name);
  264. msg.msg_name = &addr;
  265. msg.msg_namelen = sizeof(addr);
  266. ret = sendmsg(drv->test_socket, &msg, 0);
  267. if (ret < 0)
  268. perror("driver_test: sendmsg");
  269. }
  270. closedir(dir);
  271. hdr = (struct ieee80211_hdr *) buf;
  272. fc = le_to_host16(hdr->frame_control);
  273. ieee802_11_mgmt_cb(drv->hapd, (u8 *) buf, len, WLAN_FC_GET_STYPE(fc),
  274. ret >= 0);
  275. return ret;
  276. }
  277. static void test_driver_scan(struct test_driver_data *drv,
  278. struct sockaddr_un *from, socklen_t fromlen,
  279. char *data)
  280. {
  281. char buf[512], *pos, *end;
  282. int ret;
  283. struct test_driver_bss *bss;
  284. u8 sa[ETH_ALEN];
  285. u8 ie[512];
  286. size_t ielen;
  287. /* data: optional [ ' ' | STA-addr | ' ' | IEs(hex) ] */
  288. wpa_printf(MSG_DEBUG, "test_driver: SCAN");
  289. if (*data) {
  290. if (*data != ' ' ||
  291. hwaddr_aton(data + 1, sa)) {
  292. wpa_printf(MSG_DEBUG, "test_driver: Unexpected SCAN "
  293. "command format");
  294. return;
  295. }
  296. data += 18;
  297. while (*data == ' ')
  298. data++;
  299. ielen = os_strlen(data) / 2;
  300. if (ielen > sizeof(ie))
  301. ielen = sizeof(ie);
  302. if (hexstr2bin(data, ie, ielen) < 0)
  303. ielen = 0;
  304. wpa_printf(MSG_DEBUG, "test_driver: Scan from " MACSTR,
  305. MAC2STR(sa));
  306. wpa_hexdump(MSG_MSGDUMP, "test_driver: scan IEs", ie, ielen);
  307. hostapd_wps_probe_req_rx(drv->hapd, sa, ie, ielen);
  308. }
  309. for (bss = drv->bss; bss; bss = bss->next) {
  310. pos = buf;
  311. end = buf + sizeof(buf);
  312. /* reply: SCANRESP BSSID SSID IEs */
  313. ret = snprintf(pos, end - pos, "SCANRESP " MACSTR " ",
  314. MAC2STR(bss->bssid));
  315. if (ret < 0 || ret >= end - pos)
  316. return;
  317. pos += ret;
  318. pos += wpa_snprintf_hex(pos, end - pos,
  319. bss->ssid, bss->ssid_len);
  320. ret = snprintf(pos, end - pos, " ");
  321. if (ret < 0 || ret >= end - pos)
  322. return;
  323. pos += ret;
  324. pos += wpa_snprintf_hex(pos, end - pos, bss->ie, bss->ielen);
  325. pos += wpa_snprintf_hex(pos, end - pos, bss->wps_probe_resp_ie,
  326. bss->wps_probe_resp_ie_len);
  327. if (bss->privacy) {
  328. ret = snprintf(pos, end - pos, " PRIVACY");
  329. if (ret < 0 || ret >= end - pos)
  330. return;
  331. pos += ret;
  332. }
  333. sendto(drv->test_socket, buf, pos - buf, 0,
  334. (struct sockaddr *) from, fromlen);
  335. }
  336. }
  337. static struct hostapd_data * test_driver_get_hapd(struct test_driver_data *drv,
  338. struct test_driver_bss *bss)
  339. {
  340. struct hostapd_iface *iface = drv->hapd->iface;
  341. struct hostapd_data *hapd = NULL;
  342. size_t i;
  343. if (bss == NULL) {
  344. wpa_printf(MSG_DEBUG, "%s: bss == NULL", __func__);
  345. return NULL;
  346. }
  347. for (i = 0; i < iface->num_bss; i++) {
  348. hapd = iface->bss[i];
  349. if (memcmp(hapd->own_addr, bss->bssid, ETH_ALEN) == 0)
  350. break;
  351. }
  352. if (i == iface->num_bss) {
  353. wpa_printf(MSG_DEBUG, "%s: no matching interface entry found "
  354. "for BSSID " MACSTR, __func__, MAC2STR(bss->bssid));
  355. return NULL;
  356. }
  357. return hapd;
  358. }
  359. static int test_driver_new_sta(struct test_driver_data *drv,
  360. struct test_driver_bss *bss, const u8 *addr,
  361. const u8 *ie, size_t ielen)
  362. {
  363. struct hostapd_data *hapd;
  364. struct sta_info *sta;
  365. int new_assoc, res;
  366. hapd = test_driver_get_hapd(drv, bss);
  367. if (hapd == NULL)
  368. return -1;
  369. hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211,
  370. HOSTAPD_LEVEL_INFO, "associated");
  371. sta = ap_get_sta(hapd, addr);
  372. if (sta) {
  373. accounting_sta_stop(hapd, sta);
  374. } else {
  375. sta = ap_sta_add(hapd, addr);
  376. if (sta == NULL)
  377. return -1;
  378. }
  379. if (hapd->conf->wpa) {
  380. if (ie == NULL || ielen == 0) {
  381. printf("test_driver: no IE from STA\n");
  382. return -1;
  383. }
  384. if (sta->wpa_sm == NULL)
  385. sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth,
  386. sta->addr);
  387. if (sta->wpa_sm == NULL) {
  388. printf("test_driver: Failed to initialize WPA state "
  389. "machine\n");
  390. return -1;
  391. }
  392. res = wpa_validate_wpa_ie(hapd->wpa_auth, sta->wpa_sm,
  393. ie, ielen, NULL, 0);
  394. if (res != WPA_IE_OK) {
  395. printf("WPA/RSN information element rejected? "
  396. "(res %u)\n", res);
  397. return -1;
  398. }
  399. }
  400. new_assoc = (sta->flags & WLAN_STA_ASSOC) == 0;
  401. sta->flags |= WLAN_STA_AUTH | WLAN_STA_ASSOC;
  402. wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC);
  403. hostapd_new_assoc_sta(hapd, sta, !new_assoc);
  404. ieee802_1x_notify_port_enabled(sta->eapol_sm, 1);
  405. return 0;
  406. }
  407. static void test_driver_assoc(struct test_driver_data *drv,
  408. struct sockaddr_un *from, socklen_t fromlen,
  409. char *data)
  410. {
  411. struct test_client_socket *cli;
  412. u8 ie[256], ssid[32];
  413. size_t ielen, ssid_len = 0;
  414. char *pos, *pos2, cmd[50];
  415. struct test_driver_bss *bss;
  416. /* data: STA-addr SSID(hex) IEs(hex) */
  417. cli = os_zalloc(sizeof(*cli));
  418. if (cli == NULL)
  419. return;
  420. if (hwaddr_aton(data, cli->addr)) {
  421. printf("test_socket: Invalid MAC address '%s' in ASSOC\n",
  422. data);
  423. free(cli);
  424. return;
  425. }
  426. pos = data + 17;
  427. while (*pos == ' ')
  428. pos++;
  429. pos2 = strchr(pos, ' ');
  430. ielen = 0;
  431. if (pos2) {
  432. ssid_len = (pos2 - pos) / 2;
  433. if (hexstr2bin(pos, ssid, ssid_len) < 0) {
  434. wpa_printf(MSG_DEBUG, "%s: Invalid SSID", __func__);
  435. free(cli);
  436. return;
  437. }
  438. wpa_hexdump_ascii(MSG_DEBUG, "test_driver_assoc: SSID",
  439. ssid, ssid_len);
  440. pos = pos2 + 1;
  441. ielen = strlen(pos) / 2;
  442. if (ielen > sizeof(ie))
  443. ielen = sizeof(ie);
  444. if (hexstr2bin(pos, ie, ielen) < 0)
  445. ielen = 0;
  446. }
  447. for (bss = drv->bss; bss; bss = bss->next) {
  448. if (bss->ssid_len == ssid_len &&
  449. memcmp(bss->ssid, ssid, ssid_len) == 0)
  450. break;
  451. }
  452. if (bss == NULL) {
  453. wpa_printf(MSG_DEBUG, "%s: No matching SSID found from "
  454. "configured BSSes", __func__);
  455. free(cli);
  456. return;
  457. }
  458. cli->bss = bss;
  459. memcpy(&cli->un, from, sizeof(cli->un));
  460. cli->unlen = fromlen;
  461. cli->next = drv->cli;
  462. drv->cli = cli;
  463. wpa_hexdump_ascii(MSG_DEBUG, "test_socket: ASSOC sun_path",
  464. (const u8 *) cli->un.sun_path,
  465. cli->unlen - sizeof(cli->un.sun_family));
  466. snprintf(cmd, sizeof(cmd), "ASSOCRESP " MACSTR " 0",
  467. MAC2STR(bss->bssid));
  468. sendto(drv->test_socket, cmd, strlen(cmd), 0,
  469. (struct sockaddr *) from, fromlen);
  470. if (test_driver_new_sta(drv, bss, cli->addr, ie, ielen) < 0) {
  471. wpa_printf(MSG_DEBUG, "test_driver: failed to add new STA");
  472. }
  473. }
  474. static void test_driver_disassoc(struct test_driver_data *drv,
  475. struct sockaddr_un *from, socklen_t fromlen)
  476. {
  477. struct test_client_socket *cli;
  478. struct sta_info *sta;
  479. cli = test_driver_get_cli(drv, from, fromlen);
  480. if (!cli)
  481. return;
  482. hostapd_logger(drv->hapd, cli->addr, HOSTAPD_MODULE_IEEE80211,
  483. HOSTAPD_LEVEL_INFO, "disassociated");
  484. sta = ap_get_sta(drv->hapd, cli->addr);
  485. if (sta != NULL) {
  486. sta->flags &= ~WLAN_STA_ASSOC;
  487. wpa_auth_sm_event(sta->wpa_sm, WPA_DISASSOC);
  488. sta->acct_terminate_cause =
  489. RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST;
  490. ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
  491. ap_free_sta(drv->hapd, sta);
  492. }
  493. }
  494. static void test_driver_eapol(struct test_driver_data *drv,
  495. struct sockaddr_un *from, socklen_t fromlen,
  496. u8 *data, size_t datalen)
  497. {
  498. struct test_client_socket *cli;
  499. if (datalen > 14) {
  500. u8 *proto = data + 2 * ETH_ALEN;
  501. /* Skip Ethernet header */
  502. wpa_printf(MSG_DEBUG, "test_driver: dst=" MACSTR " src="
  503. MACSTR " proto=%04x",
  504. MAC2STR(data), MAC2STR(data + ETH_ALEN),
  505. WPA_GET_BE16(proto));
  506. data += 14;
  507. datalen -= 14;
  508. }
  509. cli = test_driver_get_cli(drv, from, fromlen);
  510. if (cli) {
  511. struct hostapd_data *hapd;
  512. hapd = test_driver_get_hapd(drv, cli->bss);
  513. if (hapd == NULL)
  514. return;
  515. ieee802_1x_receive(hapd, cli->addr, data, datalen);
  516. } else {
  517. wpa_printf(MSG_DEBUG, "test_socket: EAPOL from unknown "
  518. "client");
  519. }
  520. }
  521. static void test_driver_ether(struct test_driver_data *drv,
  522. struct sockaddr_un *from, socklen_t fromlen,
  523. u8 *data, size_t datalen)
  524. {
  525. struct l2_ethhdr *eth;
  526. if (datalen < sizeof(*eth))
  527. return;
  528. eth = (struct l2_ethhdr *) data;
  529. wpa_printf(MSG_DEBUG, "test_driver: RX ETHER dst=" MACSTR " src="
  530. MACSTR " proto=%04x",
  531. MAC2STR(eth->h_dest), MAC2STR(eth->h_source),
  532. be_to_host16(eth->h_proto));
  533. #ifdef CONFIG_IEEE80211R
  534. if (be_to_host16(eth->h_proto) == ETH_P_RRB) {
  535. wpa_ft_rrb_rx(drv->hapd->wpa_auth, eth->h_source,
  536. data + sizeof(*eth), datalen - sizeof(*eth));
  537. }
  538. #endif /* CONFIG_IEEE80211R */
  539. }
  540. static void test_driver_mlme(struct test_driver_data *drv,
  541. struct sockaddr_un *from, socklen_t fromlen,
  542. u8 *data, size_t datalen)
  543. {
  544. struct ieee80211_hdr *hdr;
  545. u16 fc;
  546. hdr = (struct ieee80211_hdr *) data;
  547. if (test_driver_get_cli(drv, from, fromlen) == NULL && datalen >= 16) {
  548. struct test_client_socket *cli;
  549. cli = os_zalloc(sizeof(*cli));
  550. if (cli == NULL)
  551. return;
  552. wpa_printf(MSG_DEBUG, "Adding client entry for " MACSTR,
  553. MAC2STR(hdr->addr2));
  554. memcpy(cli->addr, hdr->addr2, ETH_ALEN);
  555. memcpy(&cli->un, from, sizeof(cli->un));
  556. cli->unlen = fromlen;
  557. cli->next = drv->cli;
  558. drv->cli = cli;
  559. }
  560. wpa_hexdump(MSG_MSGDUMP, "test_driver_mlme: received frame",
  561. data, datalen);
  562. fc = le_to_host16(hdr->frame_control);
  563. if (WLAN_FC_GET_TYPE(fc) != WLAN_FC_TYPE_MGMT) {
  564. wpa_printf(MSG_ERROR, "%s: received non-mgmt frame",
  565. __func__);
  566. return;
  567. }
  568. ieee802_11_mgmt(drv->hapd, data, datalen, WLAN_FC_GET_STYPE(fc), NULL);
  569. }
  570. static void test_driver_receive_unix(int sock, void *eloop_ctx, void *sock_ctx)
  571. {
  572. struct test_driver_data *drv = eloop_ctx;
  573. char buf[2000];
  574. int res;
  575. struct sockaddr_un from;
  576. socklen_t fromlen = sizeof(from);
  577. res = recvfrom(sock, buf, sizeof(buf) - 1, 0,
  578. (struct sockaddr *) &from, &fromlen);
  579. if (res < 0) {
  580. perror("recvfrom(test_socket)");
  581. return;
  582. }
  583. buf[res] = '\0';
  584. wpa_printf(MSG_DEBUG, "test_driver: received %u bytes", res);
  585. if (strncmp(buf, "SCAN", 4) == 0) {
  586. test_driver_scan(drv, &from, fromlen, buf + 4);
  587. } else if (strncmp(buf, "ASSOC ", 6) == 0) {
  588. test_driver_assoc(drv, &from, fromlen, buf + 6);
  589. } else if (strcmp(buf, "DISASSOC") == 0) {
  590. test_driver_disassoc(drv, &from, fromlen);
  591. } else if (strncmp(buf, "EAPOL ", 6) == 0) {
  592. test_driver_eapol(drv, &from, fromlen, (u8 *) buf + 6,
  593. res - 6);
  594. } else if (strncmp(buf, "ETHER ", 6) == 0) {
  595. test_driver_ether(drv, &from, fromlen, (u8 *) buf + 6,
  596. res - 6);
  597. } else if (strncmp(buf, "MLME ", 5) == 0) {
  598. test_driver_mlme(drv, &from, fromlen, (u8 *) buf + 5, res - 5);
  599. } else {
  600. wpa_hexdump_ascii(MSG_DEBUG, "Unknown test_socket command",
  601. (u8 *) buf, res);
  602. }
  603. }
  604. static struct test_driver_bss *
  605. test_driver_get_bss(struct test_driver_data *drv, const char *ifname)
  606. {
  607. struct test_driver_bss *bss;
  608. for (bss = drv->bss; bss; bss = bss->next) {
  609. if (strcmp(bss->ifname, ifname) == 0)
  610. return bss;
  611. }
  612. return NULL;
  613. }
  614. static int test_driver_set_generic_elem(const char *ifname, void *priv,
  615. const u8 *elem, size_t elem_len)
  616. {
  617. struct test_driver_data *drv = priv;
  618. struct test_driver_bss *bss;
  619. bss = test_driver_get_bss(drv, ifname);
  620. if (bss == NULL)
  621. return -1;
  622. free(bss->ie);
  623. if (elem == NULL) {
  624. bss->ie = NULL;
  625. bss->ielen = 0;
  626. return 0;
  627. }
  628. bss->ie = malloc(elem_len);
  629. if (bss->ie == NULL) {
  630. bss->ielen = 0;
  631. return -1;
  632. }
  633. memcpy(bss->ie, elem, elem_len);
  634. bss->ielen = elem_len;
  635. return 0;
  636. }
  637. static int test_driver_set_wps_beacon_ie(const char *ifname, void *priv,
  638. const u8 *ie, size_t len)
  639. {
  640. struct test_driver_data *drv = priv;
  641. struct test_driver_bss *bss;
  642. wpa_hexdump(MSG_DEBUG, "test_driver: Beacon WPS IE", ie, len);
  643. bss = test_driver_get_bss(drv, ifname);
  644. if (bss == NULL)
  645. return -1;
  646. free(bss->wps_beacon_ie);
  647. if (ie == NULL) {
  648. bss->wps_beacon_ie = NULL;
  649. bss->wps_beacon_ie_len = 0;
  650. return 0;
  651. }
  652. bss->wps_beacon_ie = malloc(len);
  653. if (bss->wps_beacon_ie == NULL) {
  654. bss->wps_beacon_ie_len = 0;
  655. return -1;
  656. }
  657. memcpy(bss->wps_beacon_ie, ie, len);
  658. bss->wps_beacon_ie_len = len;
  659. return 0;
  660. }
  661. static int test_driver_set_wps_probe_resp_ie(const char *ifname, void *priv,
  662. const u8 *ie, size_t len)
  663. {
  664. struct test_driver_data *drv = priv;
  665. struct test_driver_bss *bss;
  666. wpa_hexdump(MSG_DEBUG, "test_driver: ProbeResp WPS IE", ie, len);
  667. bss = test_driver_get_bss(drv, ifname);
  668. if (bss == NULL)
  669. return -1;
  670. free(bss->wps_probe_resp_ie);
  671. if (ie == NULL) {
  672. bss->wps_probe_resp_ie = NULL;
  673. bss->wps_probe_resp_ie_len = 0;
  674. return 0;
  675. }
  676. bss->wps_probe_resp_ie = malloc(len);
  677. if (bss->wps_probe_resp_ie == NULL) {
  678. bss->wps_probe_resp_ie_len = 0;
  679. return -1;
  680. }
  681. memcpy(bss->wps_probe_resp_ie, ie, len);
  682. bss->wps_probe_resp_ie_len = len;
  683. return 0;
  684. }
  685. static int test_driver_sta_deauth(void *priv, const u8 *addr, int reason)
  686. {
  687. struct test_driver_data *drv = priv;
  688. struct test_client_socket *cli;
  689. if (drv->test_socket < 0)
  690. return -1;
  691. cli = drv->cli;
  692. while (cli) {
  693. if (memcmp(cli->addr, addr, ETH_ALEN) == 0)
  694. break;
  695. cli = cli->next;
  696. }
  697. if (!cli)
  698. return -1;
  699. return sendto(drv->test_socket, "DEAUTH", 6, 0,
  700. (struct sockaddr *) &cli->un, cli->unlen);
  701. }
  702. static int test_driver_sta_disassoc(void *priv, const u8 *addr, int reason)
  703. {
  704. struct test_driver_data *drv = priv;
  705. struct test_client_socket *cli;
  706. if (drv->test_socket < 0)
  707. return -1;
  708. cli = drv->cli;
  709. while (cli) {
  710. if (memcmp(cli->addr, addr, ETH_ALEN) == 0)
  711. break;
  712. cli = cli->next;
  713. }
  714. if (!cli)
  715. return -1;
  716. return sendto(drv->test_socket, "DISASSOC", 8, 0,
  717. (struct sockaddr *) &cli->un, cli->unlen);
  718. }
  719. static struct hostapd_hw_modes *
  720. test_driver_get_hw_feature_data(void *priv, u16 *num_modes, u16 *flags)
  721. {
  722. struct hostapd_hw_modes *modes;
  723. *num_modes = 3;
  724. *flags = 0;
  725. modes = os_zalloc(*num_modes * sizeof(struct hostapd_hw_modes));
  726. if (modes == NULL)
  727. return NULL;
  728. modes[0].mode = HOSTAPD_MODE_IEEE80211G;
  729. modes[0].num_channels = 1;
  730. modes[0].num_rates = 1;
  731. modes[0].channels = os_zalloc(sizeof(struct hostapd_channel_data));
  732. modes[0].rates = os_zalloc(sizeof(struct hostapd_rate_data));
  733. if (modes[0].channels == NULL || modes[0].rates == NULL) {
  734. hostapd_free_hw_features(modes, *num_modes);
  735. return NULL;
  736. }
  737. modes[0].channels[0].chan = 1;
  738. modes[0].channels[0].freq = 2412;
  739. modes[0].channels[0].flag = 0;
  740. modes[0].rates[0].rate = 10;
  741. modes[0].rates[0].flags = HOSTAPD_RATE_BASIC | HOSTAPD_RATE_SUPPORTED |
  742. HOSTAPD_RATE_CCK | HOSTAPD_RATE_MANDATORY;
  743. modes[1].mode = HOSTAPD_MODE_IEEE80211B;
  744. modes[1].num_channels = 1;
  745. modes[1].num_rates = 1;
  746. modes[1].channels = os_zalloc(sizeof(struct hostapd_channel_data));
  747. modes[1].rates = os_zalloc(sizeof(struct hostapd_rate_data));
  748. if (modes[1].channels == NULL || modes[1].rates == NULL) {
  749. hostapd_free_hw_features(modes, *num_modes);
  750. return NULL;
  751. }
  752. modes[1].channels[0].chan = 1;
  753. modes[1].channels[0].freq = 2412;
  754. modes[1].channels[0].flag = 0;
  755. modes[1].rates[0].rate = 10;
  756. modes[1].rates[0].flags = HOSTAPD_RATE_BASIC | HOSTAPD_RATE_SUPPORTED |
  757. HOSTAPD_RATE_CCK | HOSTAPD_RATE_MANDATORY;
  758. modes[2].mode = HOSTAPD_MODE_IEEE80211A;
  759. modes[2].num_channels = 1;
  760. modes[2].num_rates = 1;
  761. modes[2].channels = os_zalloc(sizeof(struct hostapd_channel_data));
  762. modes[2].rates = os_zalloc(sizeof(struct hostapd_rate_data));
  763. if (modes[2].channels == NULL || modes[2].rates == NULL) {
  764. hostapd_free_hw_features(modes, *num_modes);
  765. return NULL;
  766. }
  767. modes[2].channels[0].chan = 60;
  768. modes[2].channels[0].freq = 5300;
  769. modes[2].channels[0].flag = 0;
  770. modes[2].rates[0].rate = 60;
  771. modes[2].rates[0].flags = HOSTAPD_RATE_BASIC | HOSTAPD_RATE_SUPPORTED |
  772. HOSTAPD_RATE_MANDATORY;
  773. return modes;
  774. }
  775. static int test_driver_bss_add(void *priv, const char *ifname, const u8 *bssid)
  776. {
  777. struct test_driver_data *drv = priv;
  778. struct test_driver_bss *bss;
  779. wpa_printf(MSG_DEBUG, "%s(ifname=%s bssid=" MACSTR ")",
  780. __func__, ifname, MAC2STR(bssid));
  781. bss = os_zalloc(sizeof(*bss));
  782. if (bss == NULL)
  783. return -1;
  784. os_strlcpy(bss->ifname, ifname, IFNAMSIZ);
  785. memcpy(bss->bssid, bssid, ETH_ALEN);
  786. bss->next = drv->bss;
  787. drv->bss = bss;
  788. return 0;
  789. }
  790. static int test_driver_bss_remove(void *priv, const char *ifname)
  791. {
  792. struct test_driver_data *drv = priv;
  793. struct test_driver_bss *bss, *prev;
  794. struct test_client_socket *cli, *prev_c;
  795. wpa_printf(MSG_DEBUG, "%s(ifname=%s)", __func__, ifname);
  796. for (prev = NULL, bss = drv->bss; bss; prev = bss, bss = bss->next) {
  797. if (strcmp(bss->ifname, ifname) != 0)
  798. continue;
  799. if (prev)
  800. prev->next = bss->next;
  801. else
  802. drv->bss = bss->next;
  803. for (prev_c = NULL, cli = drv->cli; cli;
  804. prev_c = cli, cli = cli->next) {
  805. if (cli->bss != bss)
  806. continue;
  807. if (prev_c)
  808. prev_c->next = cli->next;
  809. else
  810. drv->cli = cli->next;
  811. free(cli);
  812. break;
  813. }
  814. test_driver_free_bss(bss);
  815. return 0;
  816. }
  817. return -1;
  818. }
  819. static int test_driver_if_add(const char *iface, void *priv,
  820. enum hostapd_driver_if_type type, char *ifname,
  821. const u8 *addr)
  822. {
  823. wpa_printf(MSG_DEBUG, "%s(iface=%s type=%d ifname=%s)",
  824. __func__, iface, type, ifname);
  825. return 0;
  826. }
  827. static int test_driver_if_update(void *priv, enum hostapd_driver_if_type type,
  828. char *ifname, const u8 *addr)
  829. {
  830. wpa_printf(MSG_DEBUG, "%s(type=%d ifname=%s)", __func__, type, ifname);
  831. return 0;
  832. }
  833. static int test_driver_if_remove(void *priv, enum hostapd_driver_if_type type,
  834. const char *ifname, const u8 *addr)
  835. {
  836. wpa_printf(MSG_DEBUG, "%s(type=%d ifname=%s)", __func__, type, ifname);
  837. return 0;
  838. }
  839. static int test_driver_valid_bss_mask(void *priv, const u8 *addr,
  840. const u8 *mask)
  841. {
  842. return 0;
  843. }
  844. static int test_driver_set_ssid(const char *ifname, void *priv, const u8 *buf,
  845. int len)
  846. {
  847. struct test_driver_data *drv = priv;
  848. struct test_driver_bss *bss;
  849. wpa_printf(MSG_DEBUG, "%s(ifname=%s)", __func__, ifname);
  850. wpa_hexdump_ascii(MSG_DEBUG, "test_driver_set_ssid: SSID", buf, len);
  851. for (bss = drv->bss; bss; bss = bss->next) {
  852. if (strcmp(bss->ifname, ifname) != 0)
  853. continue;
  854. if (len < 0 || (size_t) len > sizeof(bss->ssid))
  855. return -1;
  856. memcpy(bss->ssid, buf, len);
  857. bss->ssid_len = len;
  858. return 0;
  859. }
  860. return -1;
  861. }
  862. static int test_driver_set_privacy(const char *ifname, void *priv, int enabled)
  863. {
  864. struct test_driver_data *drv = priv;
  865. struct test_driver_bss *bss;
  866. wpa_printf(MSG_DEBUG, "%s(ifname=%s enabled=%d)",
  867. __func__, ifname, enabled);
  868. for (bss = drv->bss; bss; bss = bss->next) {
  869. if (strcmp(bss->ifname, ifname) != 0)
  870. continue;
  871. bss->privacy = enabled;
  872. return 0;
  873. }
  874. return -1;
  875. }
  876. static int test_driver_set_encryption(const char *iface, void *priv,
  877. const char *alg, const u8 *addr, int idx,
  878. const u8 *key, size_t key_len, int txkey)
  879. {
  880. wpa_printf(MSG_DEBUG, "%s(iface=%s alg=%s idx=%d txkey=%d)",
  881. __func__, iface, alg, idx, txkey);
  882. if (addr)
  883. wpa_printf(MSG_DEBUG, " addr=" MACSTR, MAC2STR(addr));
  884. if (key)
  885. wpa_hexdump_key(MSG_DEBUG, " key", key, key_len);
  886. return 0;
  887. }
  888. static int test_driver_set_sta_vlan(void *priv, const u8 *addr,
  889. const char *ifname, int vlan_id)
  890. {
  891. wpa_printf(MSG_DEBUG, "%s(addr=" MACSTR " ifname=%s vlan_id=%d)",
  892. __func__, MAC2STR(addr), ifname, vlan_id);
  893. return 0;
  894. }
  895. static int test_driver_sta_add(const char *ifname, void *priv, const u8 *addr,
  896. u16 aid, u16 capability, u8 *supp_rates,
  897. size_t supp_rates_len, int flags,
  898. u16 listen_interval)
  899. {
  900. struct test_driver_data *drv = priv;
  901. struct test_client_socket *cli;
  902. struct test_driver_bss *bss;
  903. wpa_printf(MSG_DEBUG, "%s(ifname=%s addr=" MACSTR " aid=%d "
  904. "capability=0x%x flags=0x%x listen_interval=%d)",
  905. __func__, ifname, MAC2STR(addr), aid, capability, flags,
  906. listen_interval);
  907. wpa_hexdump(MSG_DEBUG, "test_driver_sta_add - supp_rates",
  908. supp_rates, supp_rates_len);
  909. cli = drv->cli;
  910. while (cli) {
  911. if (memcmp(cli->addr, addr, ETH_ALEN) == 0)
  912. break;
  913. cli = cli->next;
  914. }
  915. if (!cli) {
  916. wpa_printf(MSG_DEBUG, "%s: no matching client entry",
  917. __func__);
  918. return -1;
  919. }
  920. for (bss = drv->bss; bss; bss = bss->next) {
  921. if (strcmp(ifname, bss->ifname) == 0)
  922. break;
  923. }
  924. if (bss == NULL) {
  925. wpa_printf(MSG_DEBUG, "%s: No matching interface found from "
  926. "configured BSSes", __func__);
  927. return -1;
  928. }
  929. cli->bss = bss;
  930. return 0;
  931. }
  932. static void * test_driver_init(struct hostapd_data *hapd)
  933. {
  934. struct test_driver_data *drv;
  935. struct sockaddr_un addr;
  936. drv = os_zalloc(sizeof(struct test_driver_data));
  937. if (drv == NULL) {
  938. printf("Could not allocate memory for test driver data\n");
  939. return NULL;
  940. }
  941. drv->bss = os_zalloc(sizeof(*drv->bss));
  942. if (drv->bss == NULL) {
  943. printf("Could not allocate memory for test driver BSS data\n");
  944. free(drv);
  945. return NULL;
  946. }
  947. drv->hapd = hapd;
  948. /* Generate a MAC address to help testing with multiple APs */
  949. hapd->own_addr[0] = 0x02; /* locally administered */
  950. sha1_prf((const u8 *) hapd->conf->iface, strlen(hapd->conf->iface),
  951. "hostapd test bssid generation",
  952. (const u8 *) hapd->conf->ssid.ssid, hapd->conf->ssid.ssid_len,
  953. hapd->own_addr + 1, ETH_ALEN - 1);
  954. os_strlcpy(drv->bss->ifname, hapd->conf->iface, IFNAMSIZ);
  955. memcpy(drv->bss->bssid, hapd->own_addr, ETH_ALEN);
  956. if (hapd->conf->test_socket) {
  957. if (strlen(hapd->conf->test_socket) >= sizeof(addr.sun_path)) {
  958. printf("Too long test_socket path\n");
  959. test_driver_free_priv(drv);
  960. return NULL;
  961. }
  962. if (strncmp(hapd->conf->test_socket, "DIR:", 4) == 0) {
  963. size_t len = strlen(hapd->conf->test_socket) + 30;
  964. drv->socket_dir = strdup(hapd->conf->test_socket + 4);
  965. drv->own_socket_path = malloc(len);
  966. if (drv->own_socket_path) {
  967. snprintf(drv->own_socket_path, len,
  968. "%s/AP-" MACSTR,
  969. hapd->conf->test_socket + 4,
  970. MAC2STR(hapd->own_addr));
  971. }
  972. } else {
  973. drv->own_socket_path = strdup(hapd->conf->test_socket);
  974. }
  975. if (drv->own_socket_path == NULL) {
  976. test_driver_free_priv(drv);
  977. return NULL;
  978. }
  979. drv->test_socket = socket(PF_UNIX, SOCK_DGRAM, 0);
  980. if (drv->test_socket < 0) {
  981. perror("socket(PF_UNIX)");
  982. test_driver_free_priv(drv);
  983. return NULL;
  984. }
  985. memset(&addr, 0, sizeof(addr));
  986. addr.sun_family = AF_UNIX;
  987. os_strlcpy(addr.sun_path, drv->own_socket_path,
  988. sizeof(addr.sun_path));
  989. if (bind(drv->test_socket, (struct sockaddr *) &addr,
  990. sizeof(addr)) < 0) {
  991. perror("bind(PF_UNIX)");
  992. close(drv->test_socket);
  993. unlink(drv->own_socket_path);
  994. test_driver_free_priv(drv);
  995. return NULL;
  996. }
  997. eloop_register_read_sock(drv->test_socket,
  998. test_driver_receive_unix, drv, NULL);
  999. } else
  1000. drv->test_socket = -1;
  1001. return drv;
  1002. }
  1003. static void test_driver_deinit(void *priv)
  1004. {
  1005. struct test_driver_data *drv = priv;
  1006. struct test_client_socket *cli, *prev;
  1007. cli = drv->cli;
  1008. while (cli) {
  1009. prev = cli;
  1010. cli = cli->next;
  1011. free(prev);
  1012. }
  1013. if (drv->test_socket >= 0) {
  1014. eloop_unregister_read_sock(drv->test_socket);
  1015. close(drv->test_socket);
  1016. unlink(drv->own_socket_path);
  1017. }
  1018. /* There should be only one BSS remaining at this point. */
  1019. if (drv->bss == NULL)
  1020. wpa_printf(MSG_ERROR, "%s: drv->bss == NULL", __func__);
  1021. else if (drv->bss->next)
  1022. wpa_printf(MSG_ERROR, "%s: drv->bss->next != NULL", __func__);
  1023. test_driver_free_priv(drv);
  1024. }
  1025. const struct wpa_driver_ops wpa_driver_test_ops = {
  1026. .name = "test",
  1027. .init = test_driver_init,
  1028. .deinit = test_driver_deinit,
  1029. .send_eapol = test_driver_send_eapol,
  1030. .send_mgmt_frame = test_driver_send_mgmt_frame,
  1031. .set_generic_elem = test_driver_set_generic_elem,
  1032. .sta_deauth = test_driver_sta_deauth,
  1033. .sta_disassoc = test_driver_sta_disassoc,
  1034. .get_hw_feature_data = test_driver_get_hw_feature_data,
  1035. .bss_add = test_driver_bss_add,
  1036. .bss_remove = test_driver_bss_remove,
  1037. .if_add = test_driver_if_add,
  1038. .if_update = test_driver_if_update,
  1039. .if_remove = test_driver_if_remove,
  1040. .valid_bss_mask = test_driver_valid_bss_mask,
  1041. .set_ssid = test_driver_set_ssid,
  1042. .set_privacy = test_driver_set_privacy,
  1043. .set_encryption = test_driver_set_encryption,
  1044. .set_sta_vlan = test_driver_set_sta_vlan,
  1045. .sta_add = test_driver_sta_add,
  1046. .send_ether = test_driver_send_ether,
  1047. .set_wps_beacon_ie = test_driver_set_wps_beacon_ie,
  1048. .set_wps_probe_resp_ie = test_driver_set_wps_probe_resp_ie,
  1049. };