driver_test.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275
  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. sta->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS);
  380. if (hapd->conf->wpa) {
  381. if (ie == NULL || ielen == 0) {
  382. if (hapd->conf->wps_state) {
  383. sta->flags |= WLAN_STA_WPS;
  384. goto skip_wpa_check;
  385. }
  386. printf("test_driver: no IE from STA\n");
  387. return -1;
  388. }
  389. if (sta->wpa_sm == NULL)
  390. sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth,
  391. sta->addr);
  392. if (sta->wpa_sm == NULL) {
  393. printf("test_driver: Failed to initialize WPA state "
  394. "machine\n");
  395. return -1;
  396. }
  397. res = wpa_validate_wpa_ie(hapd->wpa_auth, sta->wpa_sm,
  398. ie, ielen, NULL, 0);
  399. if (res != WPA_IE_OK) {
  400. printf("WPA/RSN information element rejected? "
  401. "(res %u)\n", res);
  402. return -1;
  403. }
  404. }
  405. skip_wpa_check:
  406. new_assoc = (sta->flags & WLAN_STA_ASSOC) == 0;
  407. sta->flags |= WLAN_STA_AUTH | WLAN_STA_ASSOC;
  408. wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC);
  409. hostapd_new_assoc_sta(hapd, sta, !new_assoc);
  410. ieee802_1x_notify_port_enabled(sta->eapol_sm, 1);
  411. return 0;
  412. }
  413. static void test_driver_assoc(struct test_driver_data *drv,
  414. struct sockaddr_un *from, socklen_t fromlen,
  415. char *data)
  416. {
  417. struct test_client_socket *cli;
  418. u8 ie[256], ssid[32];
  419. size_t ielen, ssid_len = 0;
  420. char *pos, *pos2, cmd[50];
  421. struct test_driver_bss *bss;
  422. /* data: STA-addr SSID(hex) IEs(hex) */
  423. cli = os_zalloc(sizeof(*cli));
  424. if (cli == NULL)
  425. return;
  426. if (hwaddr_aton(data, cli->addr)) {
  427. printf("test_socket: Invalid MAC address '%s' in ASSOC\n",
  428. data);
  429. free(cli);
  430. return;
  431. }
  432. pos = data + 17;
  433. while (*pos == ' ')
  434. pos++;
  435. pos2 = strchr(pos, ' ');
  436. ielen = 0;
  437. if (pos2) {
  438. ssid_len = (pos2 - pos) / 2;
  439. if (hexstr2bin(pos, ssid, ssid_len) < 0) {
  440. wpa_printf(MSG_DEBUG, "%s: Invalid SSID", __func__);
  441. free(cli);
  442. return;
  443. }
  444. wpa_hexdump_ascii(MSG_DEBUG, "test_driver_assoc: SSID",
  445. ssid, ssid_len);
  446. pos = pos2 + 1;
  447. ielen = strlen(pos) / 2;
  448. if (ielen > sizeof(ie))
  449. ielen = sizeof(ie);
  450. if (hexstr2bin(pos, ie, ielen) < 0)
  451. ielen = 0;
  452. }
  453. for (bss = drv->bss; bss; bss = bss->next) {
  454. if (bss->ssid_len == ssid_len &&
  455. memcmp(bss->ssid, ssid, ssid_len) == 0)
  456. break;
  457. }
  458. if (bss == NULL) {
  459. wpa_printf(MSG_DEBUG, "%s: No matching SSID found from "
  460. "configured BSSes", __func__);
  461. free(cli);
  462. return;
  463. }
  464. cli->bss = bss;
  465. memcpy(&cli->un, from, sizeof(cli->un));
  466. cli->unlen = fromlen;
  467. cli->next = drv->cli;
  468. drv->cli = cli;
  469. wpa_hexdump_ascii(MSG_DEBUG, "test_socket: ASSOC sun_path",
  470. (const u8 *) cli->un.sun_path,
  471. cli->unlen - sizeof(cli->un.sun_family));
  472. snprintf(cmd, sizeof(cmd), "ASSOCRESP " MACSTR " 0",
  473. MAC2STR(bss->bssid));
  474. sendto(drv->test_socket, cmd, strlen(cmd), 0,
  475. (struct sockaddr *) from, fromlen);
  476. if (test_driver_new_sta(drv, bss, cli->addr, ie, ielen) < 0) {
  477. wpa_printf(MSG_DEBUG, "test_driver: failed to add new STA");
  478. }
  479. }
  480. static void test_driver_disassoc(struct test_driver_data *drv,
  481. struct sockaddr_un *from, socklen_t fromlen)
  482. {
  483. struct test_client_socket *cli;
  484. struct sta_info *sta;
  485. cli = test_driver_get_cli(drv, from, fromlen);
  486. if (!cli)
  487. return;
  488. hostapd_logger(drv->hapd, cli->addr, HOSTAPD_MODULE_IEEE80211,
  489. HOSTAPD_LEVEL_INFO, "disassociated");
  490. sta = ap_get_sta(drv->hapd, cli->addr);
  491. if (sta != NULL) {
  492. sta->flags &= ~WLAN_STA_ASSOC;
  493. wpa_auth_sm_event(sta->wpa_sm, WPA_DISASSOC);
  494. sta->acct_terminate_cause =
  495. RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST;
  496. ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
  497. ap_free_sta(drv->hapd, sta);
  498. }
  499. }
  500. static void test_driver_eapol(struct test_driver_data *drv,
  501. struct sockaddr_un *from, socklen_t fromlen,
  502. u8 *data, size_t datalen)
  503. {
  504. struct test_client_socket *cli;
  505. if (datalen > 14) {
  506. u8 *proto = data + 2 * ETH_ALEN;
  507. /* Skip Ethernet header */
  508. wpa_printf(MSG_DEBUG, "test_driver: dst=" MACSTR " src="
  509. MACSTR " proto=%04x",
  510. MAC2STR(data), MAC2STR(data + ETH_ALEN),
  511. WPA_GET_BE16(proto));
  512. data += 14;
  513. datalen -= 14;
  514. }
  515. cli = test_driver_get_cli(drv, from, fromlen);
  516. if (cli) {
  517. struct hostapd_data *hapd;
  518. hapd = test_driver_get_hapd(drv, cli->bss);
  519. if (hapd == NULL)
  520. return;
  521. ieee802_1x_receive(hapd, cli->addr, data, datalen);
  522. } else {
  523. wpa_printf(MSG_DEBUG, "test_socket: EAPOL from unknown "
  524. "client");
  525. }
  526. }
  527. static void test_driver_ether(struct test_driver_data *drv,
  528. struct sockaddr_un *from, socklen_t fromlen,
  529. u8 *data, size_t datalen)
  530. {
  531. struct l2_ethhdr *eth;
  532. if (datalen < sizeof(*eth))
  533. return;
  534. eth = (struct l2_ethhdr *) data;
  535. wpa_printf(MSG_DEBUG, "test_driver: RX ETHER dst=" MACSTR " src="
  536. MACSTR " proto=%04x",
  537. MAC2STR(eth->h_dest), MAC2STR(eth->h_source),
  538. be_to_host16(eth->h_proto));
  539. #ifdef CONFIG_IEEE80211R
  540. if (be_to_host16(eth->h_proto) == ETH_P_RRB) {
  541. wpa_ft_rrb_rx(drv->hapd->wpa_auth, eth->h_source,
  542. data + sizeof(*eth), datalen - sizeof(*eth));
  543. }
  544. #endif /* CONFIG_IEEE80211R */
  545. }
  546. static void test_driver_mlme(struct test_driver_data *drv,
  547. struct sockaddr_un *from, socklen_t fromlen,
  548. u8 *data, size_t datalen)
  549. {
  550. struct ieee80211_hdr *hdr;
  551. u16 fc;
  552. hdr = (struct ieee80211_hdr *) data;
  553. if (test_driver_get_cli(drv, from, fromlen) == NULL && datalen >= 16) {
  554. struct test_client_socket *cli;
  555. cli = os_zalloc(sizeof(*cli));
  556. if (cli == NULL)
  557. return;
  558. wpa_printf(MSG_DEBUG, "Adding client entry for " MACSTR,
  559. MAC2STR(hdr->addr2));
  560. memcpy(cli->addr, hdr->addr2, ETH_ALEN);
  561. memcpy(&cli->un, from, sizeof(cli->un));
  562. cli->unlen = fromlen;
  563. cli->next = drv->cli;
  564. drv->cli = cli;
  565. }
  566. wpa_hexdump(MSG_MSGDUMP, "test_driver_mlme: received frame",
  567. data, datalen);
  568. fc = le_to_host16(hdr->frame_control);
  569. if (WLAN_FC_GET_TYPE(fc) != WLAN_FC_TYPE_MGMT) {
  570. wpa_printf(MSG_ERROR, "%s: received non-mgmt frame",
  571. __func__);
  572. return;
  573. }
  574. ieee802_11_mgmt(drv->hapd, data, datalen, WLAN_FC_GET_STYPE(fc), NULL);
  575. }
  576. static void test_driver_receive_unix(int sock, void *eloop_ctx, void *sock_ctx)
  577. {
  578. struct test_driver_data *drv = eloop_ctx;
  579. char buf[2000];
  580. int res;
  581. struct sockaddr_un from;
  582. socklen_t fromlen = sizeof(from);
  583. res = recvfrom(sock, buf, sizeof(buf) - 1, 0,
  584. (struct sockaddr *) &from, &fromlen);
  585. if (res < 0) {
  586. perror("recvfrom(test_socket)");
  587. return;
  588. }
  589. buf[res] = '\0';
  590. wpa_printf(MSG_DEBUG, "test_driver: received %u bytes", res);
  591. if (strncmp(buf, "SCAN", 4) == 0) {
  592. test_driver_scan(drv, &from, fromlen, buf + 4);
  593. } else if (strncmp(buf, "ASSOC ", 6) == 0) {
  594. test_driver_assoc(drv, &from, fromlen, buf + 6);
  595. } else if (strcmp(buf, "DISASSOC") == 0) {
  596. test_driver_disassoc(drv, &from, fromlen);
  597. } else if (strncmp(buf, "EAPOL ", 6) == 0) {
  598. test_driver_eapol(drv, &from, fromlen, (u8 *) buf + 6,
  599. res - 6);
  600. } else if (strncmp(buf, "ETHER ", 6) == 0) {
  601. test_driver_ether(drv, &from, fromlen, (u8 *) buf + 6,
  602. res - 6);
  603. } else if (strncmp(buf, "MLME ", 5) == 0) {
  604. test_driver_mlme(drv, &from, fromlen, (u8 *) buf + 5, res - 5);
  605. } else {
  606. wpa_hexdump_ascii(MSG_DEBUG, "Unknown test_socket command",
  607. (u8 *) buf, res);
  608. }
  609. }
  610. static struct test_driver_bss *
  611. test_driver_get_bss(struct test_driver_data *drv, const char *ifname)
  612. {
  613. struct test_driver_bss *bss;
  614. for (bss = drv->bss; bss; bss = bss->next) {
  615. if (strcmp(bss->ifname, ifname) == 0)
  616. return bss;
  617. }
  618. return NULL;
  619. }
  620. static int test_driver_set_generic_elem(const char *ifname, void *priv,
  621. const u8 *elem, size_t elem_len)
  622. {
  623. struct test_driver_data *drv = priv;
  624. struct test_driver_bss *bss;
  625. bss = test_driver_get_bss(drv, ifname);
  626. if (bss == NULL)
  627. return -1;
  628. free(bss->ie);
  629. if (elem == NULL) {
  630. bss->ie = NULL;
  631. bss->ielen = 0;
  632. return 0;
  633. }
  634. bss->ie = malloc(elem_len);
  635. if (bss->ie == NULL) {
  636. bss->ielen = 0;
  637. return -1;
  638. }
  639. memcpy(bss->ie, elem, elem_len);
  640. bss->ielen = elem_len;
  641. return 0;
  642. }
  643. static int test_driver_set_wps_beacon_ie(const char *ifname, void *priv,
  644. const u8 *ie, size_t len)
  645. {
  646. struct test_driver_data *drv = priv;
  647. struct test_driver_bss *bss;
  648. wpa_hexdump(MSG_DEBUG, "test_driver: Beacon WPS IE", ie, len);
  649. bss = test_driver_get_bss(drv, ifname);
  650. if (bss == NULL)
  651. return -1;
  652. free(bss->wps_beacon_ie);
  653. if (ie == NULL) {
  654. bss->wps_beacon_ie = NULL;
  655. bss->wps_beacon_ie_len = 0;
  656. return 0;
  657. }
  658. bss->wps_beacon_ie = malloc(len);
  659. if (bss->wps_beacon_ie == NULL) {
  660. bss->wps_beacon_ie_len = 0;
  661. return -1;
  662. }
  663. memcpy(bss->wps_beacon_ie, ie, len);
  664. bss->wps_beacon_ie_len = len;
  665. return 0;
  666. }
  667. static int test_driver_set_wps_probe_resp_ie(const char *ifname, void *priv,
  668. const u8 *ie, size_t len)
  669. {
  670. struct test_driver_data *drv = priv;
  671. struct test_driver_bss *bss;
  672. wpa_hexdump(MSG_DEBUG, "test_driver: ProbeResp WPS IE", ie, len);
  673. bss = test_driver_get_bss(drv, ifname);
  674. if (bss == NULL)
  675. return -1;
  676. free(bss->wps_probe_resp_ie);
  677. if (ie == NULL) {
  678. bss->wps_probe_resp_ie = NULL;
  679. bss->wps_probe_resp_ie_len = 0;
  680. return 0;
  681. }
  682. bss->wps_probe_resp_ie = malloc(len);
  683. if (bss->wps_probe_resp_ie == NULL) {
  684. bss->wps_probe_resp_ie_len = 0;
  685. return -1;
  686. }
  687. memcpy(bss->wps_probe_resp_ie, ie, len);
  688. bss->wps_probe_resp_ie_len = len;
  689. return 0;
  690. }
  691. static int test_driver_sta_deauth(void *priv, const u8 *addr, int reason)
  692. {
  693. struct test_driver_data *drv = priv;
  694. struct test_client_socket *cli;
  695. if (drv->test_socket < 0)
  696. return -1;
  697. cli = drv->cli;
  698. while (cli) {
  699. if (memcmp(cli->addr, addr, ETH_ALEN) == 0)
  700. break;
  701. cli = cli->next;
  702. }
  703. if (!cli)
  704. return -1;
  705. return sendto(drv->test_socket, "DEAUTH", 6, 0,
  706. (struct sockaddr *) &cli->un, cli->unlen);
  707. }
  708. static int test_driver_sta_disassoc(void *priv, const u8 *addr, int reason)
  709. {
  710. struct test_driver_data *drv = priv;
  711. struct test_client_socket *cli;
  712. if (drv->test_socket < 0)
  713. return -1;
  714. cli = drv->cli;
  715. while (cli) {
  716. if (memcmp(cli->addr, addr, ETH_ALEN) == 0)
  717. break;
  718. cli = cli->next;
  719. }
  720. if (!cli)
  721. return -1;
  722. return sendto(drv->test_socket, "DISASSOC", 8, 0,
  723. (struct sockaddr *) &cli->un, cli->unlen);
  724. }
  725. static struct hostapd_hw_modes *
  726. test_driver_get_hw_feature_data(void *priv, u16 *num_modes, u16 *flags)
  727. {
  728. struct hostapd_hw_modes *modes;
  729. *num_modes = 3;
  730. *flags = 0;
  731. modes = os_zalloc(*num_modes * sizeof(struct hostapd_hw_modes));
  732. if (modes == NULL)
  733. return NULL;
  734. modes[0].mode = HOSTAPD_MODE_IEEE80211G;
  735. modes[0].num_channels = 1;
  736. modes[0].num_rates = 1;
  737. modes[0].channels = os_zalloc(sizeof(struct hostapd_channel_data));
  738. modes[0].rates = os_zalloc(sizeof(struct hostapd_rate_data));
  739. if (modes[0].channels == NULL || modes[0].rates == NULL) {
  740. hostapd_free_hw_features(modes, *num_modes);
  741. return NULL;
  742. }
  743. modes[0].channels[0].chan = 1;
  744. modes[0].channels[0].freq = 2412;
  745. modes[0].channels[0].flag = 0;
  746. modes[0].rates[0].rate = 10;
  747. modes[0].rates[0].flags = HOSTAPD_RATE_BASIC | HOSTAPD_RATE_SUPPORTED |
  748. HOSTAPD_RATE_CCK | HOSTAPD_RATE_MANDATORY;
  749. modes[1].mode = HOSTAPD_MODE_IEEE80211B;
  750. modes[1].num_channels = 1;
  751. modes[1].num_rates = 1;
  752. modes[1].channels = os_zalloc(sizeof(struct hostapd_channel_data));
  753. modes[1].rates = os_zalloc(sizeof(struct hostapd_rate_data));
  754. if (modes[1].channels == NULL || modes[1].rates == NULL) {
  755. hostapd_free_hw_features(modes, *num_modes);
  756. return NULL;
  757. }
  758. modes[1].channels[0].chan = 1;
  759. modes[1].channels[0].freq = 2412;
  760. modes[1].channels[0].flag = 0;
  761. modes[1].rates[0].rate = 10;
  762. modes[1].rates[0].flags = HOSTAPD_RATE_BASIC | HOSTAPD_RATE_SUPPORTED |
  763. HOSTAPD_RATE_CCK | HOSTAPD_RATE_MANDATORY;
  764. modes[2].mode = HOSTAPD_MODE_IEEE80211A;
  765. modes[2].num_channels = 1;
  766. modes[2].num_rates = 1;
  767. modes[2].channels = os_zalloc(sizeof(struct hostapd_channel_data));
  768. modes[2].rates = os_zalloc(sizeof(struct hostapd_rate_data));
  769. if (modes[2].channels == NULL || modes[2].rates == NULL) {
  770. hostapd_free_hw_features(modes, *num_modes);
  771. return NULL;
  772. }
  773. modes[2].channels[0].chan = 60;
  774. modes[2].channels[0].freq = 5300;
  775. modes[2].channels[0].flag = 0;
  776. modes[2].rates[0].rate = 60;
  777. modes[2].rates[0].flags = HOSTAPD_RATE_BASIC | HOSTAPD_RATE_SUPPORTED |
  778. HOSTAPD_RATE_MANDATORY;
  779. return modes;
  780. }
  781. static int test_driver_bss_add(void *priv, const char *ifname, const u8 *bssid)
  782. {
  783. struct test_driver_data *drv = priv;
  784. struct test_driver_bss *bss;
  785. wpa_printf(MSG_DEBUG, "%s(ifname=%s bssid=" MACSTR ")",
  786. __func__, ifname, MAC2STR(bssid));
  787. bss = os_zalloc(sizeof(*bss));
  788. if (bss == NULL)
  789. return -1;
  790. os_strlcpy(bss->ifname, ifname, IFNAMSIZ);
  791. memcpy(bss->bssid, bssid, ETH_ALEN);
  792. bss->next = drv->bss;
  793. drv->bss = bss;
  794. return 0;
  795. }
  796. static int test_driver_bss_remove(void *priv, const char *ifname)
  797. {
  798. struct test_driver_data *drv = priv;
  799. struct test_driver_bss *bss, *prev;
  800. struct test_client_socket *cli, *prev_c;
  801. wpa_printf(MSG_DEBUG, "%s(ifname=%s)", __func__, ifname);
  802. for (prev = NULL, bss = drv->bss; bss; prev = bss, bss = bss->next) {
  803. if (strcmp(bss->ifname, ifname) != 0)
  804. continue;
  805. if (prev)
  806. prev->next = bss->next;
  807. else
  808. drv->bss = bss->next;
  809. for (prev_c = NULL, cli = drv->cli; cli;
  810. prev_c = cli, cli = cli->next) {
  811. if (cli->bss != bss)
  812. continue;
  813. if (prev_c)
  814. prev_c->next = cli->next;
  815. else
  816. drv->cli = cli->next;
  817. free(cli);
  818. break;
  819. }
  820. test_driver_free_bss(bss);
  821. return 0;
  822. }
  823. return -1;
  824. }
  825. static int test_driver_if_add(const char *iface, void *priv,
  826. enum hostapd_driver_if_type type, char *ifname,
  827. const u8 *addr)
  828. {
  829. wpa_printf(MSG_DEBUG, "%s(iface=%s type=%d ifname=%s)",
  830. __func__, iface, type, ifname);
  831. return 0;
  832. }
  833. static int test_driver_if_update(void *priv, enum hostapd_driver_if_type type,
  834. 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_if_remove(void *priv, enum hostapd_driver_if_type type,
  840. const char *ifname, const u8 *addr)
  841. {
  842. wpa_printf(MSG_DEBUG, "%s(type=%d ifname=%s)", __func__, type, ifname);
  843. return 0;
  844. }
  845. static int test_driver_valid_bss_mask(void *priv, const u8 *addr,
  846. const u8 *mask)
  847. {
  848. return 0;
  849. }
  850. static int test_driver_set_ssid(const char *ifname, void *priv, const u8 *buf,
  851. int len)
  852. {
  853. struct test_driver_data *drv = priv;
  854. struct test_driver_bss *bss;
  855. wpa_printf(MSG_DEBUG, "%s(ifname=%s)", __func__, ifname);
  856. wpa_hexdump_ascii(MSG_DEBUG, "test_driver_set_ssid: SSID", buf, len);
  857. for (bss = drv->bss; bss; bss = bss->next) {
  858. if (strcmp(bss->ifname, ifname) != 0)
  859. continue;
  860. if (len < 0 || (size_t) len > sizeof(bss->ssid))
  861. return -1;
  862. memcpy(bss->ssid, buf, len);
  863. bss->ssid_len = len;
  864. return 0;
  865. }
  866. return -1;
  867. }
  868. static int test_driver_set_privacy(const char *ifname, void *priv, int enabled)
  869. {
  870. struct test_driver_data *drv = priv;
  871. struct test_driver_bss *bss;
  872. wpa_printf(MSG_DEBUG, "%s(ifname=%s enabled=%d)",
  873. __func__, ifname, enabled);
  874. for (bss = drv->bss; bss; bss = bss->next) {
  875. if (strcmp(bss->ifname, ifname) != 0)
  876. continue;
  877. bss->privacy = enabled;
  878. return 0;
  879. }
  880. return -1;
  881. }
  882. static int test_driver_set_encryption(const char *iface, void *priv,
  883. const char *alg, const u8 *addr, int idx,
  884. const u8 *key, size_t key_len, int txkey)
  885. {
  886. wpa_printf(MSG_DEBUG, "%s(iface=%s alg=%s idx=%d txkey=%d)",
  887. __func__, iface, alg, idx, txkey);
  888. if (addr)
  889. wpa_printf(MSG_DEBUG, " addr=" MACSTR, MAC2STR(addr));
  890. if (key)
  891. wpa_hexdump_key(MSG_DEBUG, " key", key, key_len);
  892. return 0;
  893. }
  894. static int test_driver_set_sta_vlan(void *priv, const u8 *addr,
  895. const char *ifname, int vlan_id)
  896. {
  897. wpa_printf(MSG_DEBUG, "%s(addr=" MACSTR " ifname=%s vlan_id=%d)",
  898. __func__, MAC2STR(addr), ifname, vlan_id);
  899. return 0;
  900. }
  901. static int test_driver_sta_add(const char *ifname, void *priv, const u8 *addr,
  902. u16 aid, u16 capability, u8 *supp_rates,
  903. size_t supp_rates_len, int flags,
  904. u16 listen_interval)
  905. {
  906. struct test_driver_data *drv = priv;
  907. struct test_client_socket *cli;
  908. struct test_driver_bss *bss;
  909. wpa_printf(MSG_DEBUG, "%s(ifname=%s addr=" MACSTR " aid=%d "
  910. "capability=0x%x flags=0x%x listen_interval=%d)",
  911. __func__, ifname, MAC2STR(addr), aid, capability, flags,
  912. listen_interval);
  913. wpa_hexdump(MSG_DEBUG, "test_driver_sta_add - supp_rates",
  914. supp_rates, supp_rates_len);
  915. cli = drv->cli;
  916. while (cli) {
  917. if (memcmp(cli->addr, addr, ETH_ALEN) == 0)
  918. break;
  919. cli = cli->next;
  920. }
  921. if (!cli) {
  922. wpa_printf(MSG_DEBUG, "%s: no matching client entry",
  923. __func__);
  924. return -1;
  925. }
  926. for (bss = drv->bss; bss; bss = bss->next) {
  927. if (strcmp(ifname, bss->ifname) == 0)
  928. break;
  929. }
  930. if (bss == NULL) {
  931. wpa_printf(MSG_DEBUG, "%s: No matching interface found from "
  932. "configured BSSes", __func__);
  933. return -1;
  934. }
  935. cli->bss = bss;
  936. return 0;
  937. }
  938. static void * test_driver_init(struct hostapd_data *hapd)
  939. {
  940. struct test_driver_data *drv;
  941. struct sockaddr_un addr;
  942. drv = os_zalloc(sizeof(struct test_driver_data));
  943. if (drv == NULL) {
  944. printf("Could not allocate memory for test driver data\n");
  945. return NULL;
  946. }
  947. drv->bss = os_zalloc(sizeof(*drv->bss));
  948. if (drv->bss == NULL) {
  949. printf("Could not allocate memory for test driver BSS data\n");
  950. free(drv);
  951. return NULL;
  952. }
  953. drv->hapd = hapd;
  954. /* Generate a MAC address to help testing with multiple APs */
  955. hapd->own_addr[0] = 0x02; /* locally administered */
  956. sha1_prf((const u8 *) hapd->conf->iface, strlen(hapd->conf->iface),
  957. "hostapd test bssid generation",
  958. (const u8 *) hapd->conf->ssid.ssid, hapd->conf->ssid.ssid_len,
  959. hapd->own_addr + 1, ETH_ALEN - 1);
  960. os_strlcpy(drv->bss->ifname, hapd->conf->iface, IFNAMSIZ);
  961. memcpy(drv->bss->bssid, hapd->own_addr, ETH_ALEN);
  962. if (hapd->conf->test_socket) {
  963. if (strlen(hapd->conf->test_socket) >= sizeof(addr.sun_path)) {
  964. printf("Too long test_socket path\n");
  965. test_driver_free_priv(drv);
  966. return NULL;
  967. }
  968. if (strncmp(hapd->conf->test_socket, "DIR:", 4) == 0) {
  969. size_t len = strlen(hapd->conf->test_socket) + 30;
  970. drv->socket_dir = strdup(hapd->conf->test_socket + 4);
  971. drv->own_socket_path = malloc(len);
  972. if (drv->own_socket_path) {
  973. snprintf(drv->own_socket_path, len,
  974. "%s/AP-" MACSTR,
  975. hapd->conf->test_socket + 4,
  976. MAC2STR(hapd->own_addr));
  977. }
  978. } else {
  979. drv->own_socket_path = strdup(hapd->conf->test_socket);
  980. }
  981. if (drv->own_socket_path == NULL) {
  982. test_driver_free_priv(drv);
  983. return NULL;
  984. }
  985. drv->test_socket = socket(PF_UNIX, SOCK_DGRAM, 0);
  986. if (drv->test_socket < 0) {
  987. perror("socket(PF_UNIX)");
  988. test_driver_free_priv(drv);
  989. return NULL;
  990. }
  991. memset(&addr, 0, sizeof(addr));
  992. addr.sun_family = AF_UNIX;
  993. os_strlcpy(addr.sun_path, drv->own_socket_path,
  994. sizeof(addr.sun_path));
  995. if (bind(drv->test_socket, (struct sockaddr *) &addr,
  996. sizeof(addr)) < 0) {
  997. perror("bind(PF_UNIX)");
  998. close(drv->test_socket);
  999. unlink(drv->own_socket_path);
  1000. test_driver_free_priv(drv);
  1001. return NULL;
  1002. }
  1003. eloop_register_read_sock(drv->test_socket,
  1004. test_driver_receive_unix, drv, NULL);
  1005. } else
  1006. drv->test_socket = -1;
  1007. return drv;
  1008. }
  1009. static void test_driver_deinit(void *priv)
  1010. {
  1011. struct test_driver_data *drv = priv;
  1012. struct test_client_socket *cli, *prev;
  1013. cli = drv->cli;
  1014. while (cli) {
  1015. prev = cli;
  1016. cli = cli->next;
  1017. free(prev);
  1018. }
  1019. if (drv->test_socket >= 0) {
  1020. eloop_unregister_read_sock(drv->test_socket);
  1021. close(drv->test_socket);
  1022. unlink(drv->own_socket_path);
  1023. }
  1024. /* There should be only one BSS remaining at this point. */
  1025. if (drv->bss == NULL)
  1026. wpa_printf(MSG_ERROR, "%s: drv->bss == NULL", __func__);
  1027. else if (drv->bss->next)
  1028. wpa_printf(MSG_ERROR, "%s: drv->bss->next != NULL", __func__);
  1029. test_driver_free_priv(drv);
  1030. }
  1031. const struct wpa_driver_ops wpa_driver_test_ops = {
  1032. .name = "test",
  1033. .init = test_driver_init,
  1034. .deinit = test_driver_deinit,
  1035. .send_eapol = test_driver_send_eapol,
  1036. .send_mgmt_frame = test_driver_send_mgmt_frame,
  1037. .set_generic_elem = test_driver_set_generic_elem,
  1038. .sta_deauth = test_driver_sta_deauth,
  1039. .sta_disassoc = test_driver_sta_disassoc,
  1040. .get_hw_feature_data = test_driver_get_hw_feature_data,
  1041. .bss_add = test_driver_bss_add,
  1042. .bss_remove = test_driver_bss_remove,
  1043. .if_add = test_driver_if_add,
  1044. .if_update = test_driver_if_update,
  1045. .if_remove = test_driver_if_remove,
  1046. .valid_bss_mask = test_driver_valid_bss_mask,
  1047. .set_ssid = test_driver_set_ssid,
  1048. .set_privacy = test_driver_set_privacy,
  1049. .set_encryption = test_driver_set_encryption,
  1050. .set_sta_vlan = test_driver_set_sta_vlan,
  1051. .sta_add = test_driver_sta_add,
  1052. .send_ether = test_driver_send_ether,
  1053. .set_wps_beacon_ie = test_driver_set_wps_beacon_ie,
  1054. .set_wps_probe_resp_ie = test_driver_set_wps_probe_resp_ie,
  1055. };