2 hostapd/driver_devicescape.c | 93 ++++++++++++++++++++++++++++++-------------
3 1 file changed, 67 insertions(+), 26 deletions(-)
5 --- hostap.orig/hostapd/driver_devicescape.c 2007-11-09 13:41:12.000000000 +0100
6 +++ hostap/hostapd/driver_devicescape.c 2007-11-09 13:41:13.000000000 +0100
7 @@ -150,38 +150,79 @@ static int i802_set_encryption(const cha
8 size_t key_len, int txkey)
10 struct i802_driver_data *drv = priv;
11 - struct prism2_hostapd_param *param;
19 - blen = sizeof(*param) + key_len;
20 - buf = os_zalloc(blen);
23 + msg = nlmsg_alloc();
27 - param = (struct prism2_hostapd_param *) buf;
28 - param->cmd = PRISM2_SET_ENCRYPTION;
30 - memset(param->sta_addr, 0xff, ETH_ALEN);
32 - memcpy(param->sta_addr, addr, ETH_ALEN);
33 - os_strlcpy((char *) param->u.crypt.alg, alg,
34 - HOSTAP_CRYPT_ALG_NAME_LEN);
35 - param->u.crypt.flags = txkey ? HOSTAP_CRYPT_FLAG_SET_TX_KEY : 0;
36 - param->u.crypt.idx = idx;
37 - param->u.crypt.key_len = key_len;
38 - memcpy(param->u.crypt.key, key, key_len);
39 + if (strcmp(alg, "none") == 0) {
40 + genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
41 + 0, NL80211_CMD_DEL_KEY, 0);
43 + genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
44 + 0, NL80211_CMD_NEW_KEY, 0);
45 + NLA_PUT(msg, NL80211_ATTR_KEY_DATA, key_len, key);
46 + if (strcmp(alg, "WEP") == 0) {
48 + NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER,
51 + NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER,
53 + } else if (strcmp(alg, "TKIP") == 0)
54 + NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER, 0x000FAC02);
55 + else if (strcmp(alg, "CCMP") == 0)
56 + NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER, 0x000FAC04);
61 - if (hostapd_ioctl_iface(iface, drv, param, blen) && errno != ENOENT) {
62 - printf("%s: Failed to set encryption to alg '%s' addr " MACSTR
64 - iface, alg, MAC2STR(param->sta_addr), errno);
67 + NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
68 + NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, idx);
69 + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(iface));
71 + if (nl_send_auto_complete(drv->nl_handle, msg) < 0 ||
72 + (err = nl_wait_for_ack(drv->nl_handle)) < 0) {
73 + if (err != -ENOENT) {
87 + msg = nlmsg_alloc();
91 + genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
92 + 0, NL80211_CMD_SET_KEY, 0);
93 + NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, idx);
94 + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(iface));
95 + NLA_PUT_FLAG(msg, NL80211_ATTR_KEY_DEFAULT);
97 + if (nl_send_auto_complete(drv->nl_handle, msg) < 0 ||
98 + (err = nl_wait_for_ack(drv->nl_handle)) < 0) {
99 + if (err != -ENOENT) {