All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: linux-wireless@vger.kernel.org
Cc: Javier Cardona <javier@cozybit.com>,
	Steve Derosier <steve@cozybit.com>,
	devel@lists.open80211s.org
Subject: [RFC 4/5] nl80211: refactor mesh parameter parsing
Date: Wed, 01 Dec 2010 21:59:43 +0100	[thread overview]
Message-ID: <20101201210225.939307280@sipsolutions.net> (raw)
In-Reply-To: 20101201205939.009530439@sipsolutions.net

From: Johannes Berg <johannes.berg@intel.com>

I'm going to need this in a new place later.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 net/wireless/nl80211.c |   42 ++++++++++++++++++++++++++++--------------
 1 file changed, 28 insertions(+), 14 deletions(-)

--- wireless-testing.orig/net/wireless/nl80211.c	2010-12-01 21:36:43.000000000 +0100
+++ wireless-testing/net/wireless/nl80211.c	2010-12-01 21:39:52.000000000 +0100
@@ -2614,7 +2614,7 @@ static int nl80211_get_mesh_params(struc
 #define FILL_IN_MESH_PARAM_IF_SET(table, cfg, param, mask, attr_num, nla_fn) \
 do {\
 	if (table[attr_num]) {\
-		cfg.param = nla_fn(table[attr_num]); \
+		cfg->param = nla_fn(table[attr_num]); \
 		mask |= (1 << (attr_num - 1)); \
 	} \
 } while (0);\
@@ -2636,31 +2636,25 @@ static const struct nla_policy nl80211_m
 	[NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME] = { .type = NLA_U16 },
 };
 
-static int nl80211_set_mesh_params(struct sk_buff *skb, struct genl_info *info)
+static int nl80211_parse_mesh_params(struct genl_info *info,
+				     struct mesh_config *cfg,
+				     u32 *mask_out)
 {
-	u32 mask;
-	struct cfg80211_registered_device *rdev = info->user_ptr[0];
-	struct net_device *dev = info->user_ptr[1];
-	struct mesh_config cfg;
 	struct nlattr *tb[NL80211_MESHCONF_ATTR_MAX + 1];
-	struct nlattr *parent_attr;
+	u32 mask = 0;
 
-	parent_attr = info->attrs[NL80211_ATTR_MESH_PARAMS];
-	if (!parent_attr)
+	if (!info->attrs[NL80211_ATTR_MESH_PARAMS])
 		return -EINVAL;
 	if (nla_parse_nested(tb, NL80211_MESHCONF_ATTR_MAX,
-			parent_attr, nl80211_meshconf_params_policy))
+			     info->attrs[NL80211_ATTR_MESH_PARAMS],
+			     nl80211_meshconf_params_policy))
 		return -EINVAL;
 
-	if (!rdev->ops->set_mesh_params)
-		return -EOPNOTSUPP;
-
 	/* This makes sure that there aren't more than 32 mesh config
 	 * parameters (otherwise our bitfield scheme would not work.) */
 	BUILD_BUG_ON(NL80211_MESHCONF_ATTR_MAX > 32);
 
 	/* Fill in the params struct */
-	mask = 0;
 	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshRetryTimeout,
 			mask, NL80211_MESHCONF_RETRY_TIMEOUT, nla_get_u16);
 	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshConfirmTimeout,
@@ -2698,6 +2692,26 @@ static int nl80211_set_mesh_params(struc
 			NL80211_MESHCONF_HWMP_ROOTMODE,
 			nla_get_u8);
 
+	if (mask_out)
+		*mask_out = mask;
+	return 0;
+}
+
+static int nl80211_set_mesh_params(struct sk_buff *skb, struct genl_info *info)
+{
+	struct cfg80211_registered_device *rdev = info->user_ptr[0];
+	struct net_device *dev = info->user_ptr[1];
+	struct mesh_config cfg;
+	u32 mask;
+	int err;
+
+	if (!rdev->ops->set_mesh_params)
+		return -EOPNOTSUPP;
+
+	err = nl80211_parse_mesh_params(info, &cfg, &mask);
+	if (err)
+		return err;
+
 	/* Apply changes */
 	return rdev->ops->set_mesh_params(&rdev->wiphy, dev, &cfg, mask);
 }



  parent reply	other threads:[~2010-12-01 21:03 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-01 20:59 [RFC 0/5] mesh join/leave API Johannes Berg
2010-12-01 20:59 ` [RFC 1/5] mac80211: use configured mesh TTL Johannes Berg
2010-12-01 20:59 ` [RFC 2/5] mac80211: move mesh filter adjusting Johannes Berg
2010-12-01 20:59 ` [RFC 3/5] cfg80211: require add_virtual_intf to return new dev Johannes Berg
2010-12-01 20:59 ` Johannes Berg [this message]
2010-12-02  8:34   ` [RFC 4/5 v2] nl80211: refactor mesh parameter parsing Johannes Berg
2010-12-01 20:59 ` [RFC 5/5] cfg80211/mac80211: add mesh join/leave commands Johannes Berg
2010-12-01 21:15   ` Johannes Berg
2010-12-02  0:23   ` Javier Cardona
2010-12-02  6:57     ` Johannes Berg
2010-12-02  8:45   ` [RFC 5/5 v2] " Johannes Berg
2010-12-02 20:09     ` Javier Cardona
2010-12-02 20:14       ` Johannes Berg
2010-12-02 21:24         ` Javier Cardona
2010-12-02 21:38           ` Johannes Berg
2010-12-02 23:08             ` Javier Cardona
2010-12-03  8:13               ` 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=20101201210225.939307280@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=devel@lists.open80211s.org \
    --cc=javier@cozybit.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=steve@cozybit.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.