All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: John Linville <linville@tuxdriver.com>
Cc: linux-wireless@vger.kernel.org
Subject: [PATCH 14/15] cfg80211: add key threshold stuff
Date: Fri, 24 Aug 2007 14:27:19 +0200	[thread overview]
Message-ID: <20070824122912.305409000@sipsolutions.net> (raw)
In-Reply-To: 20070824122705.549190000@sipsolutions.net

This adds all requisites for key threshold setting and notification
to cfg80211/nl80211.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>

---
 include/linux/nl80211.h |   10 +++++++++-
 include/net/cfg80211.h  |   17 +++++++++++++++++
 net/wireless/Makefile   |    2 +-
 net/wireless/nl80211.c  |   13 +++++++++++++
 net/wireless/nl80211.h  |    1 +
 net/wireless/notify.c   |   39 +++++++++++++++++++++++++++++++++++++++
 6 files changed, 80 insertions(+), 2 deletions(-)

--- wireless-dev.orig/include/linux/nl80211.h	2007-08-24 13:03:00.549420431 +0200
+++ wireless-dev/include/linux/nl80211.h	2007-08-24 13:03:03.319420431 +0200
@@ -48,6 +48,8 @@
  * @NL80211_SET_DEFAULT_KEY: set the default key index
  * @NL80211_CMD_DEL_KEY: delete a key identified by %NL80211_ATTR_KEY_IDX
  *	or %NL80211_ATTR_MAC.
+ * @NL80211_CMD_KEY_THRESHOLD_REACHED: notification from kernel that the
+ *	key threshold for a specific key has been reached.
  * @__NL80211_CMD_AFTER_LAST: internal use
  */
 enum nl80211_commands {
@@ -86,7 +88,7 @@ enum nl80211_commands {
 	NL80211_CMD_AP_UPDATE_STA,
 	NL80211_CMD_AP_GET_STA_INFO,
 	NL80211_CMD_AP_SET_RATESETS,
-	/* %input: ifindex, key_cipher, key_data, {key_idx, mac} */
+	/* %input: ifindex, key_cipher, key_data, {key_threshold,key_idx,mac}*/
 	NL80211_CMD_ADD_KEY,
 	/* %input: ifindex, key_idx|mac */
 	NL80211_CMD_DEL_KEY,
@@ -94,6 +96,7 @@ enum nl80211_commands {
 	NL80211_CMD_SET_DEFAULT_KEY,
 
 	/* add commands here */
+	NL80211_CMD_KEY_THRESHOLD_REACHED,
 
 	/* used to define NL80211_CMD_MAX below */
 	__NL80211_CMD_AFTER_LAST
@@ -141,6 +144,8 @@ enum nl80211_commands {
  * @NL80211_ATTR_MAC: MAC address (various uses)
  * @NL80211_ATTR_KEY_CIPHER: key cipher suite (u32, as defined by IEEE 802.11
  *	section 7.3.2.25.1, e.g. 0x000FAC04)
+ * @NL80211_ATTR_KEY_THRESHOLD: key threshold, the kernel will generate a key
+ *	threshold notification when a key has been used this many times
  * @__NL80211_ATTR_AFTER_LAST: internal use
  */
 enum nl80211_attrs {
@@ -192,6 +197,9 @@ enum nl80211_attrs {
 	NL80211_ATTR_BEACON_HEAD,
 	NL80211_ATTR_BEACON_TAIL,
 
+	/* %type: u32 */
+	NL80211_ATTR_KEY_THRESHOLD,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	/* used to define NL80211_ATTR_MAX below */
--- wireless-dev.orig/net/wireless/nl80211.c	2007-08-24 13:03:00.559420431 +0200
+++ wireless-dev/net/wireless/nl80211.c	2007-08-24 13:03:03.329420431 +0200
@@ -103,6 +103,7 @@ static struct nla_policy nl80211_policy[
 	[NL80211_ATTR_KEY_IDX] = { .type = NLA_U8 },
 	[NL80211_ATTR_MAC] = { .type = NLA_BINARY, .len = ETH_ALEN },
 	[NL80211_ATTR_KEY_CIPHER] = { .type = NLA_U32 },
+	[NL80211_ATTR_KEY_THRESHOLD] = { .type = NLA_U32 },
 };
 
 /* netlink command implementations */
@@ -761,6 +762,10 @@ static int nl80211_add_key(struct sk_buf
 	if (info->attrs[NL80211_ATTR_MAC])
 		params.macaddress = nla_data(info->attrs[NL80211_ATTR_MAC]);
 
+	if (info->attrs[NL80211_ATTR_KEY_THRESHOLD])
+		params.threshold =
+			nla_get_u32(info->attrs[NL80211_ATTR_KEY_THRESHOLD]);
+
 	if (params.key_idx > 3)
 		return -EINVAL;
 
@@ -1045,6 +1050,10 @@ static struct genl_multicast_group nl802
 	.name = "config",
 };
 
+struct genl_multicast_group nl80211_notify_mcgrp = {
+	.name = "notification",
+};
+
 /* notification functions */
 
 void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev)
@@ -1088,6 +1097,10 @@ int nl80211_init(void)
 	if (err)
 		goto err_out;
 
+	err = genl_register_mc_group(&nl80211_fam, &nl80211_notify_mcgrp);
+	if (err)
+		goto err_out;
+
 	return 0;
  err_out:
 	genl_unregister_family(&nl80211_fam);
--- wireless-dev.orig/include/net/cfg80211.h	2007-08-24 13:03:00.559420431 +0200
+++ wireless-dev/include/net/cfg80211.h	2007-08-24 13:03:03.329420431 +0200
@@ -73,12 +73,16 @@ struct association_params {
  * @key_idx: key index (0-3)
  * @macaddress: MAC address (for a pairwise key) or %NULL
  * @cipher: cipher suite selector
+ * @threshold: key threshold, notify userspace that a key has
+ *	been used this many times if possible by calling
+ *	the cfg80211_key_threshold_notify() function
  */
 struct key_params {
 	u8 *key;
 	u8 *macaddress;
 	int key_len;
 	u32 cipher;
+	u32 threshold;
 	u8 key_idx;
 };
 
@@ -193,6 +197,19 @@ struct cfg80211_ops {
 				   u8 key_idx);
 };
 
+/* notification functions */
+/**
+ * cfg80211_key_threshold_notify - notify about key threshold
+ *
+ * Use this function to notify userspace that the key threshold
+ * for a specific key has been reached.
+ *
+ * @dev: the netdevice the key is associated with
+ * @keyidx: the key index of the key
+ * @mac: the MAC address for a pairwise key or %NULL
+ */
+void cfg80211_key_threshold_notify(struct net_device *dev,
+				   u8 keyidx, u8 *mac);
 
 /* helper functions specific to nl80211 */
 extern void *nl80211hdr_put(struct sk_buff *skb, u32 pid,
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ wireless-dev/net/wireless/notify.c	2007-08-24 13:03:03.329420431 +0200
@@ -0,0 +1,39 @@
+/*
+ * This is the new netlink-based wireless notification interface.
+ *
+ * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
+ */
+
+#include <linux/nl80211.h>
+#include <linux/rtnetlink.h>
+#include <net/genetlink.h>
+#include <net/cfg80211.h>
+#include "core.h"
+#include "nl80211.h"
+
+void cfg80211_key_threshold_notify(struct net_device *dev,
+				   u8 keyidx, u8 *mac)
+{
+#ifdef CONFIG_NL80211
+	struct sk_buff *msg;
+	void *hdr;
+
+	hdr = nl80211msg_new(&msg, 0, 0, 0, NL80211_CMD_KEY_THRESHOLD_REACHED);
+	if (IS_ERR(hdr))
+		return;
+
+	NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex);
+	if (mac)
+		NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac);
+	NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, keyidx);
+
+	genlmsg_end(msg, hdr);
+	genlmsg_multicast(msg, 0, nl80211_notify_mcgrp.id, GFP_KERNEL);
+
+	return;
+
+ nla_put_failure:
+	nlmsg_free(msg);
+#endif
+}
+EXPORT_SYMBOL(cfg80211_key_threshold_notify);
--- wireless-dev.orig/net/wireless/Makefile	2007-08-24 13:02:47.619420431 +0200
+++ wireless-dev/net/wireless/Makefile	2007-08-24 13:03:03.329420431 +0200
@@ -1,5 +1,5 @@
 obj-$(CONFIG_WIRELESS_EXT) += wext.o
 obj-$(CONFIG_CFG80211) += cfg80211.o
 
-cfg80211-y += core.o sysfs.o radiotap.o
+cfg80211-y += core.o sysfs.o radiotap.o notify.o
 cfg80211-$(CONFIG_NL80211) += nl80211.o
--- wireless-dev.orig/net/wireless/nl80211.h	2007-08-24 13:02:47.699420431 +0200
+++ wireless-dev/net/wireless/nl80211.h	2007-08-24 13:03:03.329420431 +0200
@@ -7,6 +7,7 @@
 extern int nl80211_init(void);
 extern void nl80211_exit(void);
 extern void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev);
+extern struct genl_multicast_group nl80211_notify_mcgrp;
 #else
 static inline int nl80211_init(void)
 {

-- 


  parent reply	other threads:[~2007-08-24 12:32 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-24 12:27 [PATCH 00/15] more key handling updates Johannes Berg
2007-08-24 12:27 ` [PATCH 01/15] mac80211: improve key selection comment Johannes Berg
2007-08-24 12:27 ` [PATCH 02/15] mac80211: rework hardware crypto flags Johannes Berg
2007-08-24 12:27 ` [PATCH 03/15] mac80211: remove set_key_idx callback Johannes Berg
2007-08-24 12:27 ` [PATCH 04/15] mac80211: some more documentation Johannes Berg
2007-08-24 12:27 ` [PATCH 05/15] mac80211: remove HW_KEY_IDX_INVALID Johannes Berg
2007-08-24 17:14   ` Larry Finger
2007-08-24 21:21     ` Michael Buesch
2007-08-24 19:33   ` Larry Finger
2007-08-27 11:00     ` Johannes Berg
2007-08-27 15:10       ` Larry Finger
2007-08-28  8:41         ` Johannes Berg
2007-08-24 12:27 ` [PATCH 06/15] mac80211: remove TKIP mixing for hw accel again Johannes Berg
2007-08-24 21:17   ` Michael Buesch
2007-08-24 12:27 ` [PATCH 07/15] mac80211: ignore key index on pairwise key (WEP only) Johannes Berg
2007-08-24 12:27 ` [PATCH 08/15] cfg80211: clean up key add/remove interface Johannes Berg
2007-08-24 18:55   ` Larry Finger
2007-08-25  7:57     ` Johannes Berg
2007-08-27 11:02     ` Johannes Berg
2007-08-27 15:27       ` Larry Finger
2007-08-28  8:43         ` Johannes Berg
2007-08-24 12:27 ` [PATCH 09/15] mac80211: rename ieee80211_cfg.c to cfg.c Johannes Berg
2007-08-24 12:27 ` [PATCH 10/15] mac80211: support adding/removing keys via cfg80211 Johannes Berg
2007-08-24 12:27 ` [PATCH 11/15] cfg80211: add hook for changing default key index Johannes Berg
2007-08-24 12:27 ` [PATCH 12/15] mac80211: support changing default key index via cfg80211 Johannes Berg
2007-08-24 12:27 ` [PATCH 13/15] mac80211: remove key threshold stuff Johannes Berg
2007-08-24 12:27 ` Johannes Berg [this message]
2007-08-24 12:27 ` [PATCH 15/15] mac80211: make use of the new cfg80211 key threshold notification Johannes Berg
2007-08-24 12:46 ` [PATCH 00/15] more key handling updates Johannes Berg
2007-08-27 14:45 ` Johannes Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070824122912.305409000@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.