From patchwork Mon Nov 28 16:28:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 1393 Return-Path: Received: from nm9-vm0.bullet.mail.ukl.yahoo.com (nm9-vm0.bullet.mail.ukl.yahoo.com [217.146.183.240]) by open-mesh.org (Postfix) with SMTP id 800C660086D for ; Mon, 28 Nov 2011 17:30:13 +0100 (CET) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@yahoo.de; dkim-adsp=none Received: from [217.146.183.208] by nm9.bullet.mail.ukl.yahoo.com with NNFMP; 28 Nov 2011 16:30:13 -0000 Received: from [77.238.184.57] by tm1.bullet.mail.ukl.yahoo.com with NNFMP; 28 Nov 2011 16:30:13 -0000 Received: from [127.0.0.1] by smtp126.mail.ukl.yahoo.com with NNFMP; 28 Nov 2011 16:30:13 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1322497813; bh=MvLFv4XRLM71xsakChcmRSmu9m1O5VzmPGngeNM+kFs=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=1n+06ZUti3YxowuSLJNmqWBEk7HgucBWS5s+wZ98cmIq4gBqCUOFpcoPhsYFm6pMbquWXyXUjYZtmJYcTYFxF1xjurDbxjNcSVJsheNeGfknF+8LOO4o1dquRaZiA6Njk2ngs7CWI3MjGDypnPpYMt4R7eIFqUsiA5rhGslKoww= X-Yahoo-Newman-Id: 265855.50725.bm@smtp126.mail.ukl.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: RlcRN6gVM1miC7spPqghOLoh4Nnrs__7m530Kuqz.fTz17R g2C8kPGzvzy4S9eh3VjR0ocjnH_Hqc62A21eC_cI5wVNRUY1WXVTM71FAYAY LhJ.2YSKSWxvixboJfYPpUP2iADmOp6qfokOiqimYthxW8eSW0JBdhIRGqwI Y.5iOhf_j3QW1ddcU2FMIMC6ekWJjH8bl0pd2YZORpHtJ4p3.EevFkC8_zeZ ldI5hmCvoVg1zPNIEPaGw3eJdaaCCDFkpWDyFIYRmwhaZVSyy.aCRe8WVUJz 4EIPakkdc_2JE7.52cxbYFsjjvlZSptr5uxAUM6qwa5MzONKOjlUnr8YZBI2 cIhmgAONLL75aX7B8W1u68veFI.MDzfNVcyrO2T.Gh_JnaoM- X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- Received: from localhost (lindner_marek@210.177.7.38 with plain) by smtp126.mail.ukl.yahoo.com with SMTP; 28 Nov 2011 16:30:02 +0000 GMT From: Marek Lindner To: b.a.t.m.a.n@lists.open-mesh.org Date: Tue, 29 Nov 2011 00:28:37 +0800 Message-Id: <1322497717-21268-3-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1322497717-21268-1-git-send-email-lindner_marek@yahoo.de> References: <201111290028.01655.lindner_marek@yahoo.de> <1322497717-21268-1-git-send-email-lindner_marek@yahoo.de> Cc: Marek Lindner Subject: [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: allowing changing the routing algorithm via sysfs X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Nov 2011 16:30:13 -0000 Signed-off-by: Marek Lindner --- 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,