All of lore.kernel.org
 help / color / mirror / Atom feed
From: Antonio Quartulli <ordex@autistici.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Antonio Quartulli <antonio@open-mesh.com>
Subject: [B.A.T.M.A.N.] [RFC 04/10] batman-adv: add bat_get_metric API function
Date: Wed, 29 May 2013 00:20:43 +0200	[thread overview]
Message-ID: <1369779649-2537-5-git-send-email-ordex@autistici.org> (raw)
In-Reply-To: <1369779649-2537-1-git-send-email-ordex@autistici.org>

From: Antonio Quartulli <antonio@open-mesh.com>

Each routing algorithm may store its metric value in a
different place, therefore a new API function is needed in
order to ask the algorithm to return the metric of a given
originator

Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
---
 bat_iv_ogm.c | 9 +++++++++
 main.c       | 3 ++-
 types.h      | 1 +
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
index 87005f7..abf4cd3 100644
--- a/bat_iv_ogm.c
+++ b/bat_iv_ogm.c
@@ -1433,6 +1433,14 @@ next:
 		seq_puts(seq, "No batman nodes in range ...\n");
 }
 
+static uint32_t batadv_iv_ogm_metric_get(struct batadv_neigh_node *neigh_node)
+{
+	if (!neigh_node)
+		return 0;
+
+	return neigh_node->bat_iv.tq_avg;
+}
+
 static struct batadv_algo_ops batadv_batman_iv __read_mostly = {
 	.name = "BATMAN_IV",
 	.bat_iface_enable = batadv_iv_ogm_iface_enable,
@@ -1441,6 +1449,7 @@ static struct batadv_algo_ops batadv_batman_iv __read_mostly = {
 	.bat_primary_iface_set = batadv_iv_ogm_primary_iface_set,
 	.bat_ogm_schedule = batadv_iv_ogm_schedule,
 	.bat_ogm_emit = batadv_iv_ogm_emit,
+	.bat_metric_get = batadv_iv_ogm_metric_get,
 	.bat_orig_print = batadv_iv_ogm_orig_print,
 };
 
diff --git a/main.c b/main.c
index e99c66b..e87105b 100644
--- a/main.c
+++ b/main.c
@@ -444,7 +444,8 @@ int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops)
 	    !bat_algo_ops->bat_iface_update_mac ||
 	    !bat_algo_ops->bat_primary_iface_set ||
 	    !bat_algo_ops->bat_ogm_schedule ||
-	    !bat_algo_ops->bat_ogm_emit) {
+	    !bat_algo_ops->bat_ogm_emit ||
+	    !bat_algo_ops->bat_metric_get) {
 		pr_info("Routing algo '%s' does not implement required ops\n",
 			bat_algo_ops->name);
 		ret = -EINVAL;
diff --git a/types.h b/types.h
index d75c77a..815d52d 100644
--- a/types.h
+++ b/types.h
@@ -993,6 +993,7 @@ struct batadv_algo_ops {
 	void (*bat_primary_iface_set)(struct batadv_hard_iface *hard_iface);
 	void (*bat_ogm_schedule)(struct batadv_hard_iface *hard_iface);
 	void (*bat_ogm_emit)(struct batadv_forw_packet *forw_packet);
+	uint32_t (*bat_metric_get)(struct batadv_neigh_node *neigh_node);
 	/* orig_node handling API */
 	void (*bat_orig_print)(struct batadv_priv *priv, struct seq_file *seq);
 };
-- 
1.8.1.5


  parent reply	other threads:[~2013-05-28 22:20 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-28 22:20 [B.A.T.M.A.N.] [RFC 00/10] Improving the routing protocol abstraction Antonio Quartulli
2013-05-28 22:20 ` [B.A.T.M.A.N.] [RFC 01/10] batman-adv: make struct batadv_neigh_node algorithm agnostic Antonio Quartulli
2013-05-28 22:20 ` [B.A.T.M.A.N.] [RFC 02/10] batman-adv: make struct batadv_orig_node " Antonio Quartulli
2013-05-29 14:09   ` Simon Wunderlich
2013-05-29 14:12     ` Antonio Quartulli
2013-05-28 22:20 ` [B.A.T.M.A.N.] [RFC 03/10] batman-adv: add bat_orig_print function API Antonio Quartulli
2013-05-28 22:20 ` Antonio Quartulli [this message]
2013-05-29 14:17   ` [B.A.T.M.A.N.] [RFC 04/10] batman-adv: add bat_get_metric API function Simon Wunderlich
2013-05-29 14:29     ` Antonio Quartulli
2013-05-28 22:20 ` [B.A.T.M.A.N.] [RFC 04/10] batman-adv: add bat_metric_get " Antonio Quartulli
2013-05-28 22:20 ` [B.A.T.M.A.N.] [RFC 05/10] batman-adv: add bat_metric_is_similar " Antonio Quartulli
2013-05-29 14:16   ` Simon Wunderlich
2013-05-29 14:28     ` Antonio Quartulli
2013-05-29 14:55       ` Simon Wunderlich
2013-05-29 14:57         ` Antonio Quartulli
2013-06-26  8:59           ` Antonio Quartulli
2013-05-28 22:20 ` [B.A.T.M.A.N.] [RFC 06/10] batman-adv: add bat_metric_compare " Antonio Quartulli
2013-05-28 22:20 ` [B.A.T.M.A.N.] [RFC 07/10] batman-adv: adapt bonding to use the new API functions Antonio Quartulli
2013-05-28 22:20 ` [B.A.T.M.A.N.] [RFC 08/10] batman-adv: adapt the gateway feature " Antonio Quartulli
2013-05-29 14:32   ` Simon Wunderlich
2013-05-29 14:48     ` Antonio Quartulli
2013-05-30 11:29       ` Antonio Quartulli
2013-05-28 22:20 ` [B.A.T.M.A.N.] [RFC 09/10] batman-adv: adapt the neighbor purging routine " Antonio Quartulli
2013-05-28 22:23 ` [B.A.T.M.A.N.] [RFC 00/10] Improving the routing protocol abstraction Antonio Quartulli
2013-05-28 23:19 ` [B.A.T.M.A.N.] [RFC 10/10] batman-adv: provide orig_node routing API Antonio Quartulli
2013-05-29  6:20 ` [B.A.T.M.A.N.] [RFC 00/10] Improving the routing protocol abstraction Martin Hundebøll
2013-05-29  7:08   ` Antonio Quartulli

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=1369779649-2537-5-git-send-email-ordex@autistici.org \
    --to=ordex@autistici.org \
    --cc=antonio@open-mesh.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.