Commit 60719ffd authored by Johannes Berg's avatar Johannes Berg Committed by John W. Linville

cfg80211: show interface type

This patch makes cfg80211 show the interface in the nl80211
information about a specific interface. API users are required
to keep the type updated (everything else is fairly complicated)
but you will get a warning if you fail to keep it updated.
Signed-off-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 133b8226
...@@ -363,11 +363,13 @@ struct wiphy; ...@@ -363,11 +363,13 @@ struct wiphy;
* wireless extensions but this is subject to reevaluation as soon as this * wireless extensions but this is subject to reevaluation as soon as this
* code is used more widely and we have a first user without wext. * code is used more widely and we have a first user without wext.
* *
* @add_virtual_intf: create a new virtual interface with the given name * @add_virtual_intf: create a new virtual interface with the given name,
* must set the struct wireless_dev's iftype.
* *
* @del_virtual_intf: remove the virtual interface determined by ifindex. * @del_virtual_intf: remove the virtual interface determined by ifindex.
* *
* @change_virtual_intf: change type of virtual interface * @change_virtual_intf: change type/configuration of virtual interface,
* keep the struct wireless_dev's iftype updated.
* *
* @add_key: add a key with the given parameters. @mac_addr will be %NULL * @add_key: add a key with the given parameters. @mac_addr will be %NULL
* when adding a group key. * when adding a group key.
......
...@@ -223,9 +223,11 @@ struct wiphy { ...@@ -223,9 +223,11 @@ struct wiphy {
* the netdev.) * the netdev.)
* *
* @wiphy: pointer to hardware description * @wiphy: pointer to hardware description
* @iftype: interface type
*/ */
struct wireless_dev { struct wireless_dev {
struct wiphy *wiphy; struct wiphy *wiphy;
enum nl80211_iftype iftype;
/* private to the generic wireless code */ /* private to the generic wireless code */
struct list_head list; struct list_head list;
......
...@@ -625,6 +625,7 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata, ...@@ -625,6 +625,7 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
/* and set some type-dependent values */ /* and set some type-dependent values */
sdata->vif.type = type; sdata->vif.type = type;
sdata->dev->hard_start_xmit = ieee80211_subif_start_xmit; sdata->dev->hard_start_xmit = ieee80211_subif_start_xmit;
sdata->wdev.iftype = type;
/* only monitor differs */ /* only monitor differs */
sdata->dev->type = ARPHRD_ETHER; sdata->dev->type = ARPHRD_ETHER;
......
...@@ -384,6 +384,8 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb, ...@@ -384,6 +384,8 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb,
rdev = wiphy_to_dev(dev->ieee80211_ptr->wiphy); rdev = wiphy_to_dev(dev->ieee80211_ptr->wiphy);
WARN_ON(dev->ieee80211_ptr->iftype == NL80211_IFTYPE_UNSPECIFIED);
switch (state) { switch (state) {
case NETDEV_REGISTER: case NETDEV_REGISTER:
mutex_lock(&rdev->devlist_mtx); mutex_lock(&rdev->devlist_mtx);
......
...@@ -299,7 +299,7 @@ static int nl80211_send_iface(struct sk_buff *msg, u32 pid, u32 seq, int flags, ...@@ -299,7 +299,7 @@ static int nl80211_send_iface(struct sk_buff *msg, u32 pid, u32 seq, int flags,
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex); NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex);
NLA_PUT_STRING(msg, NL80211_ATTR_IFNAME, dev->name); NLA_PUT_STRING(msg, NL80211_ATTR_IFNAME, dev->name);
/* TODO: interface type */ NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, dev->ieee80211_ptr->iftype);
return genlmsg_end(msg, hdr); return genlmsg_end(msg, hdr);
nla_put_failure: nla_put_failure:
...@@ -453,6 +453,10 @@ static int nl80211_set_interface(struct sk_buff *skb, struct genl_info *info) ...@@ -453,6 +453,10 @@ static int nl80211_set_interface(struct sk_buff *skb, struct genl_info *info)
&flags); &flags);
err = drv->ops->change_virtual_intf(&drv->wiphy, ifindex, err = drv->ops->change_virtual_intf(&drv->wiphy, ifindex,
type, err ? NULL : &flags, &params); type, err ? NULL : &flags, &params);
dev = __dev_get_by_index(&init_net, ifindex);
WARN_ON(!dev || (!err && dev->ieee80211_ptr->iftype != type));
rtnl_unlock(); rtnl_unlock();
unlock: unlock:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment