2 hostapd/driver_devicescape.c | 96 ++++++++++++++++++++++++++++++++++---------
3 1 file changed, 76 insertions(+), 20 deletions(-)
5 --- hostap.orig/hostapd/driver_devicescape.c 2007-11-09 13:41:13.000000000 +0100
6 +++ hostap/hostapd/driver_devicescape.c 2007-11-09 13:41:14.000000000 +0100
7 @@ -228,33 +228,89 @@ static int i802_set_encryption(const cha
11 +static inline int min_int(int a, int b)
18 +static int get_key_handler(struct nl_msg *msg, void *arg)
20 + struct nlattr *tb[NL80211_ATTR_MAX];
21 + struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
23 + nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
24 + genlmsg_attrlen(gnlh, 0), NULL);
27 + * TODO: validate the key index and mac address!
28 + * Otherwise, there's a race condition as soon as
29 + * the kernel starts sending key notifications.
32 + if (tb[NL80211_ATTR_KEY_SEQ])
33 + memcpy(arg, nla_data(tb[NL80211_ATTR_KEY_SEQ]),
34 + min_int(nla_len(tb[NL80211_ATTR_KEY_SEQ]), 6));
38 +static int ack_wait_handler(struct nl_msg *msg, void *arg)
40 + int *finished = arg;
46 static int i802_get_seqnum(const char *iface, void *priv, const u8 *addr,
49 struct i802_driver_data *drv = priv;
50 - struct prism2_hostapd_param *param;
54 + struct nl_cb *cb = NULL;
59 - param_len = sizeof(struct prism2_hostapd_param) + 32;
60 - param = os_zalloc(param_len);
63 + msg = nlmsg_alloc();
67 - param->cmd = PRISM2_GET_ENCRYPTION;
69 - memset(param->sta_addr, 0xff, ETH_ALEN);
71 - memcpy(param->sta_addr, addr, ETH_ALEN);
72 - param->u.crypt.idx = idx;
74 - ret = hostapd_ioctl_iface(iface, drv, param, param_len);
76 - memcpy(seq, param->u.crypt.seq_counter,
77 - HOSTAP_SEQ_COUNTER_SIZE);
80 + genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
81 + 0, NL80211_CMD_GET_KEY, 0);
84 + NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
85 + NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, idx);
86 + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(iface));
88 + cb = nl_cb_alloc(NL_CB_CUSTOM);
94 + if (nl_send_auto_complete(drv->nl_handle, msg) < 0)
97 + nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, get_key_handler, seq);
98 + nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_wait_handler, &finished);
100 + err = nl_recvmsgs(drv->nl_handle, cb);
103 + err = nl_wait_for_ack(drv->nl_handle);