aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorcolin@cozybit.com <colin@cozybit.com>2008-10-21 15:03:48 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-10-31 19:00:39 -0400
commit93da9cc17c5ae8a751886fd4732db89ad5e9bdb9 (patch)
tree5c8c16eaeca4c6e4555682a4ab1b448cdbe21595 /net
parent4a68ec535ef1043319928f601d633f78e650a16f (diff)
Add nl80211 commands to get and set o11s mesh networking parameters
The two new commands are NL80211_CMD_GET_MESH_PARAMS and NL80211_CMD_SET_MESH_PARAMS. There is a new attribute enum, NL80211_ATTR_MESH_PARAMS, which enumerates the various mesh configuration parameters. Moved struct mesh_config from mac80211/ieee80211_i.h to net/cfg80211.h. nl80211_get_mesh_params and nl80211_set_mesh_params unpack the netlink messages and ask the driver to get or set the configuration. This is done via two new function stubs, get_mesh_params and set_mesh_params, in struct cfg80211_ops. Signed-off-by: Colin McCabe <colin@cozybit.com> Acked-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net')
-rw-r--r--net/mac80211/cfg.c68
-rw-r--r--net/mac80211/ieee80211_i.h21
-rw-r--r--net/wireless/nl80211.c191
3 files changed, 260 insertions, 20 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 55e3a26510ed..91f56a48e2b4 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -951,6 +951,72 @@ static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
951 rcu_read_unlock(); 951 rcu_read_unlock();
952 return 0; 952 return 0;
953} 953}
954
955static int ieee80211_get_mesh_params(struct wiphy *wiphy,
956 struct net_device *dev,
957 struct mesh_config *conf)
958{
959 struct ieee80211_sub_if_data *sdata;
960 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
961
962 if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
963 return -ENOTSUPP;
964 memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
965 return 0;
966}
967
968static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask)
969{
970 return (mask >> (parm-1)) & 0x1;
971}
972
973static int ieee80211_set_mesh_params(struct wiphy *wiphy,
974 struct net_device *dev,
975 const struct mesh_config *nconf, u32 mask)
976{
977 struct mesh_config *conf;
978 struct ieee80211_sub_if_data *sdata;
979 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
980
981 if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
982 return -ENOTSUPP;
983
984 /* Set the config options which we are interested in setting */
985 conf = &(sdata->u.mesh.mshcfg);
986 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
987 conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout;
988 if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask))
989 conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout;
990 if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask))
991 conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout;
992 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask))
993 conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks;
994 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask))
995 conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries;
996 if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask))
997 conf->dot11MeshTTL = nconf->dot11MeshTTL;
998 if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask))
999 conf->auto_open_plinks = nconf->auto_open_plinks;
1000 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask))
1001 conf->dot11MeshHWMPmaxPREQretries =
1002 nconf->dot11MeshHWMPmaxPREQretries;
1003 if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask))
1004 conf->path_refresh_time = nconf->path_refresh_time;
1005 if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask))
1006 conf->min_discovery_timeout = nconf->min_discovery_timeout;
1007 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask))
1008 conf->dot11MeshHWMPactivePathTimeout =
1009 nconf->dot11MeshHWMPactivePathTimeout;
1010 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask))
1011 conf->dot11MeshHWMPpreqMinInterval =
1012 nconf->dot11MeshHWMPpreqMinInterval;
1013 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
1014 mask))
1015 conf->dot11MeshHWMPnetDiameterTraversalTime =
1016 nconf->dot11MeshHWMPnetDiameterTraversalTime;
1017 return 0;
1018}
1019
954#endif 1020#endif
955 1021
956static int ieee80211_change_bss(struct wiphy *wiphy, 1022static int ieee80211_change_bss(struct wiphy *wiphy,
@@ -1007,6 +1073,8 @@ struct cfg80211_ops mac80211_config_ops = {
1007 .change_mpath = ieee80211_change_mpath, 1073 .change_mpath = ieee80211_change_mpath,
1008 .get_mpath = ieee80211_get_mpath, 1074 .get_mpath = ieee80211_get_mpath,
1009 .dump_mpath = ieee80211_dump_mpath, 1075 .dump_mpath = ieee80211_dump_mpath,
1076 .set_mesh_params = ieee80211_set_mesh_params,
1077 .get_mesh_params = ieee80211_get_mesh_params,
1010#endif 1078#endif
1011 .change_bss = ieee80211_change_bss, 1079 .change_bss = ieee80211_change_bss,
1012}; 1080};
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index fe4efdd4253d..2c91108e3901 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -23,6 +23,7 @@
23#include <linux/types.h> 23#include <linux/types.h>
24#include <linux/spinlock.h> 24#include <linux/spinlock.h>
25#include <linux/etherdevice.h> 25#include <linux/etherdevice.h>
26#include <net/cfg80211.h>
26#include <net/wireless.h> 27#include <net/wireless.h>
27#include <net/iw_handler.h> 28#include <net/iw_handler.h>
28#include <net/mac80211.h> 29#include <net/mac80211.h>
@@ -247,26 +248,6 @@ struct mesh_preq_queue {
247 u8 flags; 248 u8 flags;
248}; 249};
249 250
250struct mesh_config {
251 /* Timeouts in ms */
252 /* Mesh plink management parameters */
253 u16 dot11MeshRetryTimeout;
254 u16 dot11MeshConfirmTimeout;
255 u16 dot11MeshHoldingTimeout;
256 u16 dot11MeshMaxPeerLinks;
257 u8 dot11MeshMaxRetries;
258 u8 dot11MeshTTL;
259 bool auto_open_plinks;
260 /* HWMP parameters */
261 u8 dot11MeshHWMPmaxPREQretries;
262 u32 path_refresh_time;
263 u16 min_discovery_timeout;
264 u32 dot11MeshHWMPactivePathTimeout;
265 u16 dot11MeshHWMPpreqMinInterval;
266 u16 dot11MeshHWMPnetDiameterTraversalTime;
267};
268
269
270/* flags used in struct ieee80211_if_sta.flags */ 251/* flags used in struct ieee80211_if_sta.flags */
271#define IEEE80211_STA_SSID_SET BIT(0) 252#define IEEE80211_STA_SSID_SET BIT(0)
272#define IEEE80211_STA_BSSID_SET BIT(1) 253#define IEEE80211_STA_BSSID_SET BIT(1)
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 2b87aec231ea..9a16e9e6c5ca 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -96,6 +96,8 @@ static struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] __read_mostly = {
96 [NL80211_ATTR_BSS_SHORT_PREAMBLE] = { .type = NLA_U8 }, 96 [NL80211_ATTR_BSS_SHORT_PREAMBLE] = { .type = NLA_U8 },
97 [NL80211_ATTR_BSS_SHORT_SLOT_TIME] = { .type = NLA_U8 }, 97 [NL80211_ATTR_BSS_SHORT_SLOT_TIME] = { .type = NLA_U8 },
98 98
99 [NL80211_ATTR_MESH_PARAMS] = { .type = NLA_NESTED },
100
99 [NL80211_ATTR_HT_CAPABILITY] = { .type = NLA_BINARY, 101 [NL80211_ATTR_HT_CAPABILITY] = { .type = NLA_BINARY,
100 .len = NL80211_HT_CAPABILITY_LEN }, 102 .len = NL80211_HT_CAPABILITY_LEN },
101}; 103};
@@ -1698,6 +1700,183 @@ static int nl80211_req_set_reg(struct sk_buff *skb, struct genl_info *info)
1698 return r; 1700 return r;
1699} 1701}
1700 1702
1703static int nl80211_get_mesh_params(struct sk_buff *skb,
1704 struct genl_info *info)
1705{
1706 struct cfg80211_registered_device *drv;
1707 struct mesh_config cur_params;
1708 int err;
1709 struct net_device *dev;
1710 void *hdr;
1711 struct nlattr *pinfoattr;
1712 struct sk_buff *msg;
1713
1714 /* Look up our device */
1715 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1716 if (err)
1717 return err;
1718
1719 /* Get the mesh params */
1720 rtnl_lock();
1721 err = drv->ops->get_mesh_params(&drv->wiphy, dev, &cur_params);
1722 rtnl_unlock();
1723 if (err)
1724 goto out;
1725
1726 /* Draw up a netlink message to send back */
1727 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
1728 if (!msg) {
1729 err = -ENOBUFS;
1730 goto out;
1731 }
1732 hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0,
1733 NL80211_CMD_GET_MESH_PARAMS);
1734 if (!hdr)
1735 goto nla_put_failure;
1736 pinfoattr = nla_nest_start(msg, NL80211_ATTR_MESH_PARAMS);
1737 if (!pinfoattr)
1738 goto nla_put_failure;
1739 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex);
1740 NLA_PUT_U16(msg, NL80211_MESHCONF_RETRY_TIMEOUT,
1741 cur_params.dot11MeshRetryTimeout);
1742 NLA_PUT_U16(msg, NL80211_MESHCONF_CONFIRM_TIMEOUT,
1743 cur_params.dot11MeshConfirmTimeout);
1744 NLA_PUT_U16(msg, NL80211_MESHCONF_HOLDING_TIMEOUT,
1745 cur_params.dot11MeshHoldingTimeout);
1746 NLA_PUT_U16(msg, NL80211_MESHCONF_MAX_PEER_LINKS,
1747 cur_params.dot11MeshMaxPeerLinks);
1748 NLA_PUT_U8(msg, NL80211_MESHCONF_MAX_RETRIES,
1749 cur_params.dot11MeshMaxRetries);
1750 NLA_PUT_U8(msg, NL80211_MESHCONF_TTL,
1751 cur_params.dot11MeshTTL);
1752 NLA_PUT_U8(msg, NL80211_MESHCONF_AUTO_OPEN_PLINKS,
1753 cur_params.auto_open_plinks);
1754 NLA_PUT_U8(msg, NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES,
1755 cur_params.dot11MeshHWMPmaxPREQretries);
1756 NLA_PUT_U32(msg, NL80211_MESHCONF_PATH_REFRESH_TIME,
1757 cur_params.path_refresh_time);
1758 NLA_PUT_U16(msg, NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT,
1759 cur_params.min_discovery_timeout);
1760 NLA_PUT_U32(msg, NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT,
1761 cur_params.dot11MeshHWMPactivePathTimeout);
1762 NLA_PUT_U16(msg, NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL,
1763 cur_params.dot11MeshHWMPpreqMinInterval);
1764 NLA_PUT_U16(msg, NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
1765 cur_params.dot11MeshHWMPnetDiameterTraversalTime);
1766 nla_nest_end(msg, pinfoattr);
1767 genlmsg_end(msg, hdr);
1768 err = genlmsg_unicast(msg, info->snd_pid);
1769 goto out;
1770
1771nla_put_failure:
1772 genlmsg_cancel(msg, hdr);
1773 err = -EMSGSIZE;
1774out:
1775 /* Cleanup */
1776 cfg80211_put_dev(drv);
1777 dev_put(dev);
1778 return err;
1779}
1780
1781#define FILL_IN_MESH_PARAM_IF_SET(table, cfg, param, mask, attr_num, nla_fn) \
1782do {\
1783 if (table[attr_num]) {\
1784 cfg.param = nla_fn(table[attr_num]); \
1785 mask |= (1 << (attr_num - 1)); \
1786 } \
1787} while (0);\
1788
1789static struct nla_policy
1790nl80211_meshconf_params_policy[NL80211_MESHCONF_ATTR_MAX+1] __read_mostly = {
1791 [NL80211_MESHCONF_RETRY_TIMEOUT] = { .type = NLA_U16 },
1792 [NL80211_MESHCONF_CONFIRM_TIMEOUT] = { .type = NLA_U16 },
1793 [NL80211_MESHCONF_HOLDING_TIMEOUT] = { .type = NLA_U16 },
1794 [NL80211_MESHCONF_MAX_PEER_LINKS] = { .type = NLA_U16 },
1795 [NL80211_MESHCONF_MAX_RETRIES] = { .type = NLA_U8 },
1796 [NL80211_MESHCONF_TTL] = { .type = NLA_U8 },
1797 [NL80211_MESHCONF_AUTO_OPEN_PLINKS] = { .type = NLA_U8 },
1798
1799 [NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES] = { .type = NLA_U8 },
1800 [NL80211_MESHCONF_PATH_REFRESH_TIME] = { .type = NLA_U32 },
1801 [NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT] = { .type = NLA_U16 },
1802 [NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT] = { .type = NLA_U32 },
1803 [NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL] = { .type = NLA_U16 },
1804 [NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME] = { .type = NLA_U16 },
1805};
1806
1807static int nl80211_set_mesh_params(struct sk_buff *skb, struct genl_info *info)
1808{
1809 int err;
1810 u32 mask;
1811 struct cfg80211_registered_device *drv;
1812 struct net_device *dev;
1813 struct mesh_config cfg;
1814 struct nlattr *tb[NL80211_MESHCONF_ATTR_MAX + 1];
1815 struct nlattr *parent_attr;
1816
1817 parent_attr = info->attrs[NL80211_ATTR_MESH_PARAMS];
1818 if (!parent_attr)
1819 return -EINVAL;
1820 if (nla_parse_nested(tb, NL80211_MESHCONF_ATTR_MAX,
1821 parent_attr, nl80211_meshconf_params_policy))
1822 return -EINVAL;
1823
1824 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1825 if (err)
1826 return err;
1827
1828 /* This makes sure that there aren't more than 32 mesh config
1829 * parameters (otherwise our bitfield scheme would not work.) */
1830 BUILD_BUG_ON(NL80211_MESHCONF_ATTR_MAX > 32);
1831
1832 /* Fill in the params struct */
1833 mask = 0;
1834 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshRetryTimeout,
1835 mask, NL80211_MESHCONF_RETRY_TIMEOUT, nla_get_u16);
1836 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshConfirmTimeout,
1837 mask, NL80211_MESHCONF_CONFIRM_TIMEOUT, nla_get_u16);
1838 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHoldingTimeout,
1839 mask, NL80211_MESHCONF_HOLDING_TIMEOUT, nla_get_u16);
1840 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshMaxPeerLinks,
1841 mask, NL80211_MESHCONF_MAX_PEER_LINKS, nla_get_u16);
1842 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshMaxRetries,
1843 mask, NL80211_MESHCONF_MAX_RETRIES, nla_get_u8);
1844 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshTTL,
1845 mask, NL80211_MESHCONF_TTL, nla_get_u8);
1846 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, auto_open_plinks,
1847 mask, NL80211_MESHCONF_AUTO_OPEN_PLINKS, nla_get_u8);
1848 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPmaxPREQretries,
1849 mask, NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES,
1850 nla_get_u8);
1851 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, path_refresh_time,
1852 mask, NL80211_MESHCONF_PATH_REFRESH_TIME, nla_get_u32);
1853 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, min_discovery_timeout,
1854 mask, NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT,
1855 nla_get_u16);
1856 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPactivePathTimeout,
1857 mask, NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT,
1858 nla_get_u32);
1859 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPpreqMinInterval,
1860 mask, NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL,
1861 nla_get_u16);
1862 FILL_IN_MESH_PARAM_IF_SET(tb, cfg,
1863 dot11MeshHWMPnetDiameterTraversalTime,
1864 mask, NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
1865 nla_get_u16);
1866
1867 /* Apply changes */
1868 rtnl_lock();
1869 err = drv->ops->set_mesh_params(&drv->wiphy, dev, &cfg, mask);
1870 rtnl_unlock();
1871
1872 /* cleanup */
1873 cfg80211_put_dev(drv);
1874 dev_put(dev);
1875 return err;
1876}
1877
1878#undef FILL_IN_MESH_PARAM_IF_SET
1879
1701static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info) 1880static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info)
1702{ 1881{
1703 struct nlattr *tb[NL80211_REG_RULE_ATTR_MAX + 1]; 1882 struct nlattr *tb[NL80211_REG_RULE_ATTR_MAX + 1];
@@ -1915,6 +2094,18 @@ static struct genl_ops nl80211_ops[] = {
1915 .policy = nl80211_policy, 2094 .policy = nl80211_policy,
1916 .flags = GENL_ADMIN_PERM, 2095 .flags = GENL_ADMIN_PERM,
1917 }, 2096 },
2097 {
2098 .cmd = NL80211_CMD_GET_MESH_PARAMS,
2099 .doit = nl80211_get_mesh_params,
2100 .policy = nl80211_policy,
2101 /* can be retrieved by unprivileged users */
2102 },
2103 {
2104 .cmd = NL80211_CMD_SET_MESH_PARAMS,
2105 .doit = nl80211_set_mesh_params,
2106 .policy = nl80211_policy,
2107 .flags = GENL_ADMIN_PERM,
2108 },
1918}; 2109};
1919 2110
1920/* multicast groups */ 2111/* multicast groups */