From 60ea8187c9db60694d15d5abbd292b3b6016f9c0 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 9 Jan 2011 19:54:50 +0200 Subject: [PATCH] nl80211: Set NL80211_ATTR_KEY_DEFAULT_TYPES based on set_key addr This allows mac80211 to configure default keys properly for RSN IBSS mode. --- src/drivers/driver_nl80211.c | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 8197fdbcd..acb8f3359 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -2649,6 +2649,19 @@ static int wpa_driver_nl80211_set_key(const char *ifname, void *priv, NLA_PUT_U32(msg, NL80211_ATTR_KEY_TYPE, NL80211_KEYTYPE_GROUP); } + } else if (addr && is_broadcast_ether_addr(addr)) { + struct nl_msg *types; + int err; + wpa_printf(MSG_DEBUG, " broadcast key"); + types = nlmsg_alloc(); + if (!types) + goto nla_put_failure; + NLA_PUT_FLAG(types, NL80211_KEY_DEFAULT_TYPE_MULTICAST); + err = nla_put_nested(msg, NL80211_ATTR_KEY_DEFAULT_TYPES, + types); + nlmsg_free(types); + if (err) + goto nla_put_failure; } NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, key_idx); NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifindex); @@ -2682,6 +2695,31 @@ static int wpa_driver_nl80211_set_key(const char *ifname, void *priv, NLA_PUT_FLAG(msg, NL80211_ATTR_KEY_DEFAULT_MGMT); else NLA_PUT_FLAG(msg, NL80211_ATTR_KEY_DEFAULT); + if (addr && is_broadcast_ether_addr(addr)) { + struct nl_msg *types; + int err; + types = nlmsg_alloc(); + if (!types) + goto nla_put_failure; + NLA_PUT_FLAG(types, NL80211_KEY_DEFAULT_TYPE_MULTICAST); + err = nla_put_nested(msg, NL80211_ATTR_KEY_DEFAULT_TYPES, + types); + nlmsg_free(types); + if (err) + goto nla_put_failure; + } else if (addr) { + struct nl_msg *types; + int err; + types = nlmsg_alloc(); + if (!types) + goto nla_put_failure; + NLA_PUT_FLAG(types, NL80211_KEY_DEFAULT_TYPE_UNICAST); + err = nla_put_nested(msg, NL80211_ATTR_KEY_DEFAULT_TYPES, + types); + nlmsg_free(types); + if (err) + goto nla_put_failure; + } ret = send_and_recv_msgs(drv, msg, NULL, NULL); if (ret == -ENOENT)