From: Marek Lindner <lindner_marek@yahoo.de>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Marek Lindner <lindner_marek@yahoo.de>
Subject: [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: allowing changing the routing algorithm via sysfs
Date: Tue, 29 Nov 2011 00:28:37 +0800 [thread overview]
Message-ID: <1322497717-21268-3-git-send-email-lindner_marek@yahoo.de> (raw)
In-Reply-To: <1322497717-21268-1-git-send-email-lindner_marek@yahoo.de>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
---
bat_sysfs.c | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/bat_sysfs.c b/bat_sysfs.c
index c25492f..5375600 100644
--- a/bat_sysfs.c
+++ b/bat_sysfs.c
@@ -272,6 +272,39 @@ static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr,
return count;
}
+static ssize_t show_bat_algo(struct kobject *kobj, struct attribute *attr,
+ char *buff)
+{
+ struct bat_priv *bat_priv = kobj_to_batpriv(kobj);
+ return sprintf(buff, "%s\n", bat_priv->bat_algo->name);
+}
+
+static ssize_t store_bat_algo(struct kobject *kobj, struct attribute *attr,
+ char *buff, size_t count)
+{
+ struct net_device *net_dev = kobj_to_netdev(kobj);
+ struct bat_priv *bat_priv = netdev_priv(net_dev);
+ int ret;
+
+ if (buff[count - 1] == '\n')
+ buff[count - 1] = '\0';
+ else
+ buff[count] = '\0';
+
+ if (strcmp(bat_priv->bat_algo->name, buff) == 0)
+ return count;
+
+ ret = bat_algo_select(bat_priv, buff);
+ if (ret < 0)
+ bat_info(net_dev,
+ "Invalid parameter for 'routing algorithm' setting "
+ "received: %s\n", buff);
+ else
+ bat_info(net_dev, "Changing routing algorithm to: %s\n", buff);
+
+ return count;
+}
+
static void post_gw_deselect(struct net_device *net_dev)
{
struct bat_priv *bat_priv = netdev_priv(net_dev);
@@ -382,6 +415,7 @@ BAT_ATTR_BOOL(bonding, S_IRUGO | S_IWUSR, NULL);
BAT_ATTR_BOOL(fragmentation, S_IRUGO | S_IWUSR, update_min_mtu);
BAT_ATTR_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL);
static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, show_vis_mode, store_vis_mode);
+static BAT_ATTR(routing_algo, S_IRUGO | S_IWUSR, show_bat_algo, store_bat_algo);
static BAT_ATTR(gw_mode, S_IRUGO | S_IWUSR, show_gw_mode, store_gw_mode);
BAT_ATTR_UINT(orig_interval, S_IRUGO | S_IWUSR, 2 * JITTER, INT_MAX, NULL);
BAT_ATTR_UINT(hop_penalty, S_IRUGO | S_IWUSR, 0, TQ_MAX_VALUE, NULL);
@@ -399,6 +433,7 @@ static struct bat_attribute *mesh_attrs[] = {
&bat_attr_fragmentation,
&bat_attr_ap_isolation,
&bat_attr_vis_mode,
+ &bat_attr_routing_algo,
&bat_attr_gw_mode,
&bat_attr_orig_interval,
&bat_attr_hop_penalty,
--
1.7.5.4
next prev parent reply other threads:[~2011-11-28 16:28 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-28 16:27 [B.A.T.M.A.N.] [RFC] batman-adv: switch routing algorithm at runtime Marek Lindner
2011-11-28 16:28 ` [B.A.T.M.A.N.] [PATCH 1/3] batman-adv: add infrastructure to change " Marek Lindner
2011-11-28 16:28 ` [B.A.T.M.A.N.] [PATCH 2/3] batman-adv: convert batman iv algorithm to use dynamic infrastructure Marek Lindner
2011-11-28 19:02 ` Andrew Lunn
2011-11-28 19:45 ` Marek Lindner
2011-11-29 6:09 ` Andrew Lunn
2011-11-29 6:35 ` Marek Lindner
2011-11-29 8:45 ` Andrew Lunn
2011-11-29 15:23 ` Simon Wunderlich
2011-12-04 20:00 ` Marek Lindner
2011-12-06 19:20 ` Simon Wunderlich
2011-11-28 16:28 ` Marek Lindner [this message]
2011-11-28 19:00 ` [B.A.T.M.A.N.] [PATCH 1/3] batman-adv: add infrastructure to change routing algorithm at runtime Andrew Lunn
2011-11-28 18:47 ` [B.A.T.M.A.N.] [RFC] batman-adv: switch " Andrew Lunn
2011-11-28 19:42 ` Marek Lindner
2011-11-29 6:18 ` Andrew Lunn
2011-11-29 6:34 ` Marek Lindner
2011-11-29 8:02 ` Andrew Lunn
2011-12-05 9:56 [B.A.T.M.A.N.] " Marek Lindner
2011-12-05 9:56 ` [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: allowing changing the routing algorithm via sysfs Marek Lindner
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=1322497717-21268-3-git-send-email-lindner_marek@yahoo.de \
--to=lindner_marek@yahoo.de \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).