ibss_rsn.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. /*
  2. * wpa_supplicant - IBSS RSN
  3. * Copyright (c) 2009, 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 "common.h"
  16. #include "l2_packet/l2_packet.h"
  17. #include "rsn_supp/wpa.h"
  18. #include "rsn_supp/wpa_ie.h"
  19. #include "ap/wpa_auth.h"
  20. #include "wpa_supplicant_i.h"
  21. #include "driver_i.h"
  22. #include "ibss_rsn.h"
  23. static void ibss_rsn_free(struct ibss_rsn_peer *peer)
  24. {
  25. wpa_auth_sta_deinit(peer->auth);
  26. wpa_sm_deinit(peer->supp);
  27. os_free(peer);
  28. }
  29. static void supp_set_state(void *ctx, enum wpa_states state)
  30. {
  31. struct ibss_rsn_peer *peer = ctx;
  32. peer->supp_state = state;
  33. }
  34. static enum wpa_states supp_get_state(void *ctx)
  35. {
  36. struct ibss_rsn_peer *peer = ctx;
  37. return peer->supp_state;
  38. }
  39. static int supp_ether_send(void *ctx, const u8 *dest, u16 proto, const u8 *buf,
  40. size_t len)
  41. {
  42. struct ibss_rsn_peer *peer = ctx;
  43. struct wpa_supplicant *wpa_s = peer->ibss_rsn->wpa_s;
  44. wpa_printf(MSG_DEBUG, "SUPP: %s(dest=" MACSTR " proto=0x%04x "
  45. "len=%lu)",
  46. __func__, MAC2STR(dest), proto, (unsigned long) len);
  47. if (wpa_s->l2)
  48. return l2_packet_send(wpa_s->l2, dest, proto, buf, len);
  49. return wpa_drv_send_eapol(wpa_s, dest, proto, buf, len);
  50. }
  51. static u8 * supp_alloc_eapol(void *ctx, u8 type, const void *data,
  52. u16 data_len, size_t *msg_len, void **data_pos)
  53. {
  54. struct ieee802_1x_hdr *hdr;
  55. wpa_printf(MSG_DEBUG, "SUPP: %s(type=%d data_len=%d)",
  56. __func__, type, data_len);
  57. *msg_len = sizeof(*hdr) + data_len;
  58. hdr = os_malloc(*msg_len);
  59. if (hdr == NULL)
  60. return NULL;
  61. hdr->version = 2;
  62. hdr->type = type;
  63. hdr->length = host_to_be16(data_len);
  64. if (data)
  65. os_memcpy(hdr + 1, data, data_len);
  66. else
  67. os_memset(hdr + 1, 0, data_len);
  68. if (data_pos)
  69. *data_pos = hdr + 1;
  70. return (u8 *) hdr;
  71. }
  72. static int supp_get_beacon_ie(void *ctx)
  73. {
  74. struct ibss_rsn_peer *peer = ctx;
  75. wpa_printf(MSG_DEBUG, "SUPP: %s", __func__);
  76. /* TODO: get correct RSN IE */
  77. return wpa_sm_set_ap_rsn_ie(peer->supp,
  78. (u8 *) "\x30\x14\x01\x00"
  79. "\x00\x0f\xac\x04"
  80. "\x01\x00\x00\x0f\xac\x04"
  81. "\x01\x00\x00\x0f\xac\x02"
  82. "\x00\x00", 22);
  83. }
  84. static int supp_set_key(void *ctx, enum wpa_alg alg,
  85. const u8 *addr, int key_idx, int set_tx,
  86. const u8 *seq, size_t seq_len,
  87. const u8 *key, size_t key_len)
  88. {
  89. struct ibss_rsn_peer *peer = ctx;
  90. wpa_printf(MSG_DEBUG, "SUPP: %s(alg=%d addr=" MACSTR " key_idx=%d "
  91. "set_tx=%d)",
  92. __func__, alg, MAC2STR(addr), key_idx, set_tx);
  93. wpa_hexdump(MSG_DEBUG, "SUPP: set_key - seq", seq, seq_len);
  94. wpa_hexdump_key(MSG_DEBUG, "SUPP: set_key - key", key, key_len);
  95. if (key_idx == 0) {
  96. /*
  97. * In IBSS RSN, the pairwise key from the 4-way handshake
  98. * initiated by the peer with highest MAC address is used.
  99. */
  100. if (os_memcmp(peer->ibss_rsn->wpa_s->own_addr, peer->addr,
  101. ETH_ALEN) > 0) {
  102. wpa_printf(MSG_DEBUG, "SUPP: Do not use this PTK");
  103. return 0;
  104. }
  105. }
  106. if (is_broadcast_ether_addr(addr) && peer->addr)
  107. addr = peer->addr;
  108. return wpa_drv_set_key(peer->ibss_rsn->wpa_s, alg, addr, key_idx,
  109. set_tx, seq, seq_len, key, key_len);
  110. }
  111. static void * supp_get_network_ctx(void *ctx)
  112. {
  113. struct ibss_rsn_peer *peer = ctx;
  114. return wpa_supplicant_get_ssid(peer->ibss_rsn->wpa_s);
  115. }
  116. static int supp_mlme_setprotection(void *ctx, const u8 *addr,
  117. int protection_type, int key_type)
  118. {
  119. wpa_printf(MSG_DEBUG, "SUPP: %s(addr=" MACSTR " protection_type=%d "
  120. "key_type=%d)",
  121. __func__, MAC2STR(addr), protection_type, key_type);
  122. return 0;
  123. }
  124. static void supp_cancel_auth_timeout(void *ctx)
  125. {
  126. wpa_printf(MSG_DEBUG, "SUPP: %s", __func__);
  127. }
  128. static void supp_deauthenticate(void * ctx, int reason_code)
  129. {
  130. wpa_printf(MSG_DEBUG, "SUPP: %s (TODO)", __func__);
  131. }
  132. int ibss_rsn_supp_init(struct ibss_rsn_peer *peer, const u8 *own_addr,
  133. const u8 *psk)
  134. {
  135. struct wpa_sm_ctx *ctx = os_zalloc(sizeof(*ctx));
  136. if (ctx == NULL)
  137. return -1;
  138. ctx->ctx = peer;
  139. ctx->msg_ctx = peer->ibss_rsn->wpa_s;
  140. ctx->set_state = supp_set_state;
  141. ctx->get_state = supp_get_state;
  142. ctx->ether_send = supp_ether_send;
  143. ctx->get_beacon_ie = supp_get_beacon_ie;
  144. ctx->alloc_eapol = supp_alloc_eapol;
  145. ctx->set_key = supp_set_key;
  146. ctx->get_network_ctx = supp_get_network_ctx;
  147. ctx->mlme_setprotection = supp_mlme_setprotection;
  148. ctx->cancel_auth_timeout = supp_cancel_auth_timeout;
  149. ctx->deauthenticate = supp_deauthenticate;
  150. peer->supp = wpa_sm_init(ctx);
  151. if (peer->supp == NULL) {
  152. wpa_printf(MSG_DEBUG, "SUPP: wpa_sm_init() failed");
  153. return -1;
  154. }
  155. wpa_sm_set_own_addr(peer->supp, own_addr);
  156. wpa_sm_set_param(peer->supp, WPA_PARAM_RSN_ENABLED, 1);
  157. wpa_sm_set_param(peer->supp, WPA_PARAM_PROTO, WPA_PROTO_RSN);
  158. wpa_sm_set_param(peer->supp, WPA_PARAM_PAIRWISE, WPA_CIPHER_CCMP);
  159. wpa_sm_set_param(peer->supp, WPA_PARAM_GROUP, WPA_CIPHER_CCMP);
  160. wpa_sm_set_param(peer->supp, WPA_PARAM_KEY_MGMT, WPA_KEY_MGMT_PSK);
  161. wpa_sm_set_pmk(peer->supp, psk, PMK_LEN);
  162. peer->supp_ie_len = sizeof(peer->supp_ie);
  163. if (wpa_sm_set_assoc_wpa_ie_default(peer->supp, peer->supp_ie,
  164. &peer->supp_ie_len) < 0) {
  165. wpa_printf(MSG_DEBUG, "SUPP: wpa_sm_set_assoc_wpa_ie_default()"
  166. " failed");
  167. return -1;
  168. }
  169. wpa_sm_notify_assoc(peer->supp, peer->addr);
  170. return 0;
  171. }
  172. static void auth_logger(void *ctx, const u8 *addr, logger_level level,
  173. const char *txt)
  174. {
  175. if (addr)
  176. wpa_printf(MSG_DEBUG, "AUTH: " MACSTR " - %s",
  177. MAC2STR(addr), txt);
  178. else
  179. wpa_printf(MSG_DEBUG, "AUTH: %s", txt);
  180. }
  181. static const u8 * auth_get_psk(void *ctx, const u8 *addr, const u8 *prev_psk)
  182. {
  183. struct ibss_rsn *ibss_rsn = ctx;
  184. wpa_printf(MSG_DEBUG, "AUTH: %s (addr=" MACSTR " prev_psk=%p)",
  185. __func__, MAC2STR(addr), prev_psk);
  186. if (prev_psk)
  187. return NULL;
  188. return ibss_rsn->psk;
  189. }
  190. static int auth_send_eapol(void *ctx, const u8 *addr, const u8 *data,
  191. size_t data_len, int encrypt)
  192. {
  193. struct ibss_rsn *ibss_rsn = ctx;
  194. struct wpa_supplicant *wpa_s = ibss_rsn->wpa_s;
  195. wpa_printf(MSG_DEBUG, "AUTH: %s(addr=" MACSTR " data_len=%lu "
  196. "encrypt=%d)",
  197. __func__, MAC2STR(addr), (unsigned long) data_len, encrypt);
  198. if (wpa_s->l2)
  199. return l2_packet_send(wpa_s->l2, addr, ETH_P_EAPOL, data,
  200. data_len);
  201. return wpa_drv_send_eapol(wpa_s, addr, ETH_P_EAPOL, data, data_len);
  202. }
  203. static int auth_set_key(void *ctx, int vlan_id, enum wpa_alg alg,
  204. const u8 *addr, int idx, u8 *key, size_t key_len)
  205. {
  206. struct ibss_rsn *ibss_rsn = ctx;
  207. u8 seq[6];
  208. os_memset(seq, 0, sizeof(seq));
  209. if (addr) {
  210. wpa_printf(MSG_DEBUG, "AUTH: %s(alg=%d addr=" MACSTR
  211. " key_idx=%d)",
  212. __func__, alg, MAC2STR(addr), idx);
  213. } else {
  214. wpa_printf(MSG_DEBUG, "AUTH: %s(alg=%d key_idx=%d)",
  215. __func__, alg, idx);
  216. }
  217. wpa_hexdump_key(MSG_DEBUG, "AUTH: set_key - key", key, key_len);
  218. if (idx == 0) {
  219. /*
  220. * In IBSS RSN, the pairwise key from the 4-way handshake
  221. * initiated by the peer with highest MAC address is used.
  222. */
  223. if (addr == NULL ||
  224. os_memcmp(ibss_rsn->wpa_s->own_addr, addr, ETH_ALEN) < 0) {
  225. wpa_printf(MSG_DEBUG, "AUTH: Do not use this PTK");
  226. return 0;
  227. }
  228. }
  229. if (ibss_rsn->init_in_progress && key_len <=
  230. sizeof(ibss_rsn->init_gtk)) {
  231. wpa_printf(MSG_DEBUG, "AUTH: Delay setting of initial TX GTK "
  232. "until RSN IBSS is connected");
  233. ibss_rsn->init_gtk_idx = idx;
  234. os_memcpy(ibss_rsn->init_gtk, key, key_len);
  235. return 0;
  236. }
  237. return wpa_drv_set_key(ibss_rsn->wpa_s, alg, addr, idx,
  238. 1, seq, 6, key, key_len);
  239. }
  240. static int auth_for_each_sta(void *ctx, int (*cb)(struct wpa_state_machine *sm,
  241. void *ctx),
  242. void *cb_ctx)
  243. {
  244. struct ibss_rsn *ibss_rsn = ctx;
  245. struct ibss_rsn_peer *peer;
  246. wpa_printf(MSG_DEBUG, "AUTH: for_each_sta");
  247. for (peer = ibss_rsn->peers; peer; peer = peer->next) {
  248. if (peer->auth && cb(peer->auth, cb_ctx))
  249. return 1;
  250. }
  251. return 0;
  252. }
  253. static int ibss_rsn_auth_init_group(struct ibss_rsn *ibss_rsn,
  254. const u8 *own_addr)
  255. {
  256. struct wpa_auth_config conf;
  257. struct wpa_auth_callbacks cb;
  258. wpa_printf(MSG_DEBUG, "AUTH: Initializing group state machine");
  259. os_memset(&conf, 0, sizeof(conf));
  260. conf.wpa = 2;
  261. conf.wpa_key_mgmt = WPA_KEY_MGMT_PSK;
  262. conf.wpa_pairwise = WPA_CIPHER_CCMP;
  263. conf.rsn_pairwise = WPA_CIPHER_CCMP;
  264. conf.wpa_group = WPA_CIPHER_CCMP;
  265. conf.eapol_version = 2;
  266. conf.wpa_group_rekey = 600;
  267. os_memset(&cb, 0, sizeof(cb));
  268. cb.ctx = ibss_rsn;
  269. cb.logger = auth_logger;
  270. cb.send_eapol = auth_send_eapol;
  271. cb.get_psk = auth_get_psk;
  272. cb.set_key = auth_set_key;
  273. cb.for_each_sta = auth_for_each_sta;
  274. ibss_rsn->init_in_progress = 1;
  275. ibss_rsn->auth_group = wpa_init(own_addr, &conf, &cb);
  276. ibss_rsn->init_in_progress = 0;
  277. if (ibss_rsn->auth_group == NULL) {
  278. wpa_printf(MSG_DEBUG, "AUTH: wpa_init() failed");
  279. return -1;
  280. }
  281. return 0;
  282. }
  283. static int ibss_rsn_auth_init(struct ibss_rsn *ibss_rsn,
  284. struct ibss_rsn_peer *peer)
  285. {
  286. peer->auth = wpa_auth_sta_init(ibss_rsn->auth_group, peer->addr);
  287. if (peer->auth == NULL) {
  288. wpa_printf(MSG_DEBUG, "AUTH: wpa_auth_sta_init() failed");
  289. return -1;
  290. }
  291. /* TODO: get peer RSN IE with Probe Request */
  292. if (wpa_validate_wpa_ie(ibss_rsn->auth_group, peer->auth,
  293. (u8 *) "\x30\x14\x01\x00"
  294. "\x00\x0f\xac\x04"
  295. "\x01\x00\x00\x0f\xac\x04"
  296. "\x01\x00\x00\x0f\xac\x02"
  297. "\x00\x00", 22, NULL, 0) !=
  298. WPA_IE_OK) {
  299. wpa_printf(MSG_DEBUG, "AUTH: wpa_validate_wpa_ie() failed");
  300. return -1;
  301. }
  302. if (wpa_auth_sm_event(peer->auth, WPA_ASSOC))
  303. return -1;
  304. if (wpa_auth_sta_associated(ibss_rsn->auth_group, peer->auth))
  305. return -1;
  306. return 0;
  307. }
  308. int ibss_rsn_start(struct ibss_rsn *ibss_rsn, const u8 *addr)
  309. {
  310. struct ibss_rsn_peer *peer;
  311. for (peer = ibss_rsn->peers; peer; peer = peer->next) {
  312. if (os_memcmp(addr, peer->addr, ETH_ALEN) == 0) {
  313. wpa_printf(MSG_DEBUG, "RSN: IBSS Authenticator and "
  314. "Supplicant for peer " MACSTR " already "
  315. "running", MAC2STR(addr));
  316. return 0;
  317. }
  318. }
  319. wpa_printf(MSG_DEBUG, "RSN: Starting IBSS Authenticator and "
  320. "Supplicant for peer " MACSTR, MAC2STR(addr));
  321. peer = os_zalloc(sizeof(*peer));
  322. if (peer == NULL)
  323. return -1;
  324. peer->ibss_rsn = ibss_rsn;
  325. os_memcpy(peer->addr, addr, ETH_ALEN);
  326. if (ibss_rsn_supp_init(peer, ibss_rsn->wpa_s->own_addr, ibss_rsn->psk)
  327. < 0) {
  328. ibss_rsn_free(peer);
  329. return -1;
  330. }
  331. if (ibss_rsn_auth_init(ibss_rsn, peer) < 0) {
  332. ibss_rsn_free(peer);
  333. return -1;
  334. }
  335. peer->next = ibss_rsn->peers;
  336. ibss_rsn->peers = peer;
  337. return 0;
  338. }
  339. void ibss_rsn_stop(struct ibss_rsn *ibss_rsn, const u8 *peermac)
  340. {
  341. struct ibss_rsn_peer *peer, *prev;
  342. if (ibss_rsn == NULL)
  343. return;
  344. if (peermac == NULL) {
  345. /* remove all peers */
  346. wpa_printf(MSG_DEBUG, "%s: Remove all peers", __func__);
  347. peer = ibss_rsn->peers;
  348. while (peer) {
  349. prev = peer;
  350. peer = peer->next;
  351. ibss_rsn_free(prev);
  352. ibss_rsn->peers = peer;
  353. }
  354. } else {
  355. /* remove specific peer */
  356. wpa_printf(MSG_DEBUG, "%s: Remove specific peer " MACSTR,
  357. __func__, MAC2STR(peermac));
  358. for (prev = NULL, peer = ibss_rsn->peers; peer != NULL;
  359. prev = peer, peer = peer->next) {
  360. if (os_memcmp(peermac, peer->addr, ETH_ALEN) == 0) {
  361. if (prev == NULL)
  362. ibss_rsn->peers = peer->next;
  363. else
  364. prev->next = peer->next;
  365. ibss_rsn_free(peer);
  366. wpa_printf(MSG_DEBUG, "%s: Successfully "
  367. "removed a specific peer",
  368. __func__);
  369. break;
  370. }
  371. }
  372. }
  373. }
  374. struct ibss_rsn * ibss_rsn_init(struct wpa_supplicant *wpa_s)
  375. {
  376. struct ibss_rsn *ibss_rsn;
  377. ibss_rsn = os_zalloc(sizeof(*ibss_rsn));
  378. if (ibss_rsn == NULL)
  379. return NULL;
  380. ibss_rsn->wpa_s = wpa_s;
  381. if (ibss_rsn_auth_init_group(ibss_rsn, wpa_s->own_addr) < 0) {
  382. ibss_rsn_deinit(ibss_rsn);
  383. return NULL;
  384. }
  385. return ibss_rsn;
  386. }
  387. void ibss_rsn_deinit(struct ibss_rsn *ibss_rsn)
  388. {
  389. struct ibss_rsn_peer *peer, *prev;
  390. if (ibss_rsn == NULL)
  391. return;
  392. peer = ibss_rsn->peers;
  393. while (peer) {
  394. prev = peer;
  395. peer = peer->next;
  396. ibss_rsn_free(prev);
  397. }
  398. wpa_deinit(ibss_rsn->auth_group);
  399. os_free(ibss_rsn);
  400. }
  401. static int ibss_rsn_eapol_dst_supp(const u8 *buf, size_t len)
  402. {
  403. const struct ieee802_1x_hdr *hdr;
  404. const struct wpa_eapol_key *key;
  405. u16 key_info;
  406. size_t plen;
  407. /* TODO: Support other EAPOL packets than just EAPOL-Key */
  408. if (len < sizeof(*hdr) + sizeof(*key))
  409. return -1;
  410. hdr = (const struct ieee802_1x_hdr *) buf;
  411. key = (const struct wpa_eapol_key *) (hdr + 1);
  412. plen = be_to_host16(hdr->length);
  413. if (hdr->version < EAPOL_VERSION) {
  414. /* TODO: backwards compatibility */
  415. }
  416. if (hdr->type != IEEE802_1X_TYPE_EAPOL_KEY) {
  417. wpa_printf(MSG_DEBUG, "RSN: EAPOL frame (type %u) discarded, "
  418. "not a Key frame", hdr->type);
  419. return -1;
  420. }
  421. if (plen > len - sizeof(*hdr) || plen < sizeof(*key)) {
  422. wpa_printf(MSG_DEBUG, "RSN: EAPOL frame payload size %lu "
  423. "invalid (frame size %lu)",
  424. (unsigned long) plen, (unsigned long) len);
  425. return -1;
  426. }
  427. if (key->type != EAPOL_KEY_TYPE_RSN) {
  428. wpa_printf(MSG_DEBUG, "RSN: EAPOL-Key type (%d) unknown, "
  429. "discarded", key->type);
  430. return -1;
  431. }
  432. key_info = WPA_GET_BE16(key->key_info);
  433. return !!(key_info & WPA_KEY_INFO_ACK);
  434. }
  435. static int ibss_rsn_process_rx_eapol(struct ibss_rsn *ibss_rsn,
  436. struct ibss_rsn_peer *peer,
  437. const u8 *buf, size_t len)
  438. {
  439. int supp;
  440. u8 *tmp;
  441. supp = ibss_rsn_eapol_dst_supp(buf, len);
  442. if (supp < 0)
  443. return -1;
  444. tmp = os_malloc(len);
  445. if (tmp == NULL)
  446. return -1;
  447. os_memcpy(tmp, buf, len);
  448. if (supp) {
  449. wpa_printf(MSG_DEBUG, "RSN: IBSS RX EAPOL for Supplicant");
  450. wpa_sm_rx_eapol(peer->supp, peer->addr, tmp, len);
  451. } else {
  452. wpa_printf(MSG_DEBUG, "RSN: IBSS RX EAPOL for Authenticator");
  453. wpa_receive(ibss_rsn->auth_group, peer->auth, tmp, len);
  454. }
  455. os_free(tmp);
  456. return 1;
  457. }
  458. int ibss_rsn_rx_eapol(struct ibss_rsn *ibss_rsn, const u8 *src_addr,
  459. const u8 *buf, size_t len)
  460. {
  461. struct ibss_rsn_peer *peer;
  462. for (peer = ibss_rsn->peers; peer; peer = peer->next) {
  463. if (os_memcmp(src_addr, peer->addr, ETH_ALEN) == 0)
  464. return ibss_rsn_process_rx_eapol(ibss_rsn, peer,
  465. buf, len);
  466. }
  467. if (ibss_rsn_eapol_dst_supp(buf, len) > 0) {
  468. /*
  469. * Create new IBSS peer based on an EAPOL message from the peer
  470. * Authenticator.
  471. */
  472. if (ibss_rsn_start(ibss_rsn, src_addr) < 0)
  473. return -1;
  474. return ibss_rsn_process_rx_eapol(ibss_rsn, ibss_rsn->peers,
  475. buf, len);
  476. }
  477. return 0;
  478. }
  479. void ibss_rsn_set_psk(struct ibss_rsn *ibss_rsn, const u8 *psk)
  480. {
  481. os_memcpy(ibss_rsn->psk, psk, PMK_LEN);
  482. }
  483. void ibss_rsn_connected(struct ibss_rsn *ibss_rsn)
  484. {
  485. u8 seq[6];
  486. wpa_printf(MSG_DEBUG, "RSN: IBSS connected notification");
  487. if (ibss_rsn->init_gtk_idx) {
  488. wpa_printf(MSG_DEBUG, "RSN: Set initial IBSS TX GTK");
  489. os_memset(seq, 0, sizeof(seq));
  490. if (wpa_drv_set_key(ibss_rsn->wpa_s, WPA_ALG_CCMP,
  491. broadcast_ether_addr,
  492. ibss_rsn->init_gtk_idx,
  493. 1, seq, sizeof(seq), ibss_rsn->init_gtk,
  494. 16) < 0)
  495. wpa_printf(MSG_INFO, "RSN: Failed to set IBSS TX GTK");
  496. ibss_rsn->init_gtk_idx = 0;
  497. os_memset(ibss_rsn->init_gtk, 0, sizeof(ibss_rsn->init_gtk));
  498. }
  499. }