From: Antonio Quartulli <antonio(a)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(a)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 605c954..32e0321 100644
--- a/bat_iv_ogm.c
+++ b/bat_iv_ogm.c
@@ -1457,6 +1457,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,
@@ -1465,6 +1473,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 46adf68..cc75126 100644
--- a/main.c
+++ b/main.c
@@ -445,7 +445,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 bff1668..e994fe0 100644
--- a/types.h
+++ b/types.h
@@ -1002,6 +1002,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