示例#1
0
static ssize_t store_rate_ctrl_alg(struct class_device *dev,
				   const char *buf, size_t len)
{
	struct ieee80211_local *local = to_ieee80211_local(dev);
	int res;

	if (!capable(CAP_NET_ADMIN))
		return -EPERM;
	res = rtnl_lock_local(local);
	if (res)
		return res;
	res = ieee80211_init_rate_ctrl_alg(local, buf);
	rtnl_unlock();
	return res < 0 ? res : len;
}
示例#2
0
static ssize_t store_remove_iface(struct class_device *dev,
				  const char *buf, size_t len)
{
	struct ieee80211_local *local = to_ieee80211_local(dev);
	int res;

	if (!capable(CAP_NET_ADMIN))
		return -EPERM;
	if (len > IFNAMSIZ)
		return -EINVAL;
	res = rtnl_lock_local(local);
	if (res)
		return res;
	res = ieee80211_if_remove(local->mdev, buf, -1);
	rtnl_unlock();
	return res < 0 ? res : len;
}
示例#3
0
static ssize_t ieee80211_stats_show(struct class_device *dev, char *buf,
		ssize_t (*format)(struct ieee80211_low_level_stats *, char *))
{
	struct ieee80211_local *local = to_ieee80211_local(dev);
	struct ieee80211_low_level_stats stats;
	ssize_t ret = -EINVAL;

	if (!local->ops->get_stats)
		return -EOPNOTSUPP;
	ret = rtnl_lock_local(local);
	if (ret)
		return ret;
	ret = local->ops->get_stats(local_to_hw(local), &stats);
	rtnl_unlock();
	if (!ret)
		ret = (*format)(&stats, buf);
	return ret;
}
示例#4
0
static ssize_t store_add_iface(struct class_device *dev,
			       const char *buf, size_t len)
{
	struct ieee80211_local *local = to_ieee80211_local(dev);
	struct net_device *new_dev;
	int res;

	if (!capable(CAP_NET_ADMIN))
		return -EPERM;
	if (len > IFNAMSIZ)
		return -EINVAL;
	res = rtnl_lock_local(local);
	if (res)
		return res;
	res = ieee80211_if_add(local->mdev, buf, 0, &new_dev);
	if (res == 0)
		ieee80211_if_set_type(new_dev, IEEE80211_IF_TYPE_STA);
	rtnl_unlock();
	return res < 0 ? res : len;
}
示例#5
0
文件: debugfs.c 项目: maraz/linux-2.6
static ssize_t format_devstat_counter(struct ieee80211_local *local,
	char __user *userbuf,
	size_t count, loff_t *ppos,
	int (*printvalue)(struct ieee80211_low_level_stats *stats, char *buf,
			  int buflen))
{
	struct ieee80211_low_level_stats stats;
	char buf[20];
	int res;

	if (!local->ops->get_stats)
		return -EOPNOTSUPP;

	res = rtnl_lock_local(local);
	if (res)
		return res;

	res = local->ops->get_stats(local_to_hw(local), &stats);
	rtnl_unlock();
	if (!res)
		res = printvalue(&stats, buf, sizeof(buf));
	return simple_read_from_buffer(userbuf, count, ppos, buf, res);
}