nl/cfg80211: add the NL80211_CMD_SET_MCAST_RATE command
authorAntonio Quartulli <ordex@autistici.org>
Fri, 2 Nov 2012 12:27:48 +0000 (13:27 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 5 Nov 2012 14:54:45 +0000 (15:54 +0100)
This command triggers a new callback: set_mcast_rate(). It enables
the user to change the rate used to send multicast frames for vif
configured as IBSS or MESH_POINT

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/net/cfg80211.h
include/uapi/linux/nl80211.h
net/wireless/nl80211.c

index 8034a4268fcb4440279c2c1ebcc0e46a4a41d650..cee791fd4cffefa79b3b7208f2a45af995c18ba4 100644 (file)
@@ -1545,6 +1545,9 @@ struct cfg80211_gtk_rekey_data {
  *     to a merge.
  * @leave_ibss: Leave the IBSS.
  *
+ * @set_mcast_rate: Set the specified multicast rate (only if vif is in ADHOC or
+ *     MESH mode)
+ *
  * @set_wiphy_params: Notify that wiphy parameters have changed;
  *     @changed bitfield (see &enum wiphy_params_flags) describes which values
  *     have changed. The actual parameter values are available in
@@ -1749,6 +1752,9 @@ struct cfg80211_ops {
                             struct cfg80211_ibss_params *params);
        int     (*leave_ibss)(struct wiphy *wiphy, struct net_device *dev);
 
+       int     (*set_mcast_rate)(struct wiphy *wiphy, struct net_device *dev,
+                                 int rate[IEEE80211_NUM_BANDS]);
+
        int     (*set_wiphy_params)(struct wiphy *wiphy, u32 changed);
 
        int     (*set_tx_power)(struct wiphy *wiphy, struct wireless_dev *wdev,
index 4c5f6748ed7d37b3ea21cdd49c1aad9371f10026..cbd2d6bb907a5b92f992cec43e0b791b85ffda46 100644 (file)
  *     station, due to particular reason. %NL80211_ATTR_CONN_FAILED_REASON
  *     is used for this.
  *
+ * @NL80211_CMD_SET_MCAST_RATE: Change the rate used to send multicast frames
+ *     for IBSS or MESH vif.
+ *
  * @NL80211_CMD_MAX: highest used command number
  * @__NL80211_CMD_AFTER_LAST: internal use
  */
@@ -726,6 +729,8 @@ enum nl80211_commands {
 
        NL80211_CMD_CONN_FAILED,
 
+       NL80211_CMD_SET_MCAST_RATE,
+
        /* add new commands above here */
 
        /* used to define NL80211_CMD_MAX below */
index 87d4670ee53ad30885ac797b09b82f2838be898c..9b0a3b8fd20a890f38209c69e43733b221bb18d5 100644 (file)
@@ -1110,6 +1110,7 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flag
                        goto nla_put_failure;
        }
        CMD(start_p2p_device, START_P2P_DEVICE);
+       CMD(set_mcast_rate, SET_MCAST_RATE);
 
 #ifdef CONFIG_NL80211_TESTMODE
        CMD(testmode_cmd, TESTMODE);
@@ -5448,6 +5449,36 @@ static int nl80211_leave_ibss(struct sk_buff *skb, struct genl_info *info)
        return cfg80211_leave_ibss(rdev, dev, false);
 }
 
+static int nl80211_set_mcast_rate(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];
+       int mcast_rate[IEEE80211_NUM_BANDS];
+       u32 nla_rate;
+       int err;
+
+       if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_ADHOC &&
+           dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT)
+               return -EOPNOTSUPP;
+
+       if (!rdev->ops->set_mcast_rate)
+               return -EOPNOTSUPP;
+
+       memset(mcast_rate, 0, sizeof(mcast_rate));
+
+       if (!info->attrs[NL80211_ATTR_MCAST_RATE])
+               return -EINVAL;
+
+       nla_rate = nla_get_u32(info->attrs[NL80211_ATTR_MCAST_RATE]);
+       if (!nl80211_parse_mcast_rate(rdev, mcast_rate, nla_rate))
+               return -EINVAL;
+
+       err = rdev->ops->set_mcast_rate(&rdev->wiphy, dev, mcast_rate);
+
+       return err;
+}
+
+
 #ifdef CONFIG_NL80211_TESTMODE
 static struct genl_multicast_group nl80211_testmode_mcgrp = {
        .name = "testmode",
@@ -7629,6 +7660,14 @@ static struct genl_ops nl80211_ops[] = {
                .internal_flags = NL80211_FLAG_NEED_WDEV_UP |
                                  NL80211_FLAG_NEED_RTNL,
        },
+       {
+               .cmd = NL80211_CMD_SET_MCAST_RATE,
+               .doit = nl80211_set_mcast_rate,
+               .policy = nl80211_policy,
+               .flags = GENL_ADMIN_PERM,
+               .internal_flags = NL80211_FLAG_NEED_NETDEV |
+                                 NL80211_FLAG_NEED_RTNL,
+       },
 };
 
 static struct genl_multicast_group nl80211_mlme_mcgrp = {