summaryrefslogtreecommitdiffstats
path: root/net/batman-adv/bat_iv_ogm.c
diff options
context:
space:
mode:
authorAntonio Quartulli2013-09-02 12:15:04 +0200
committerAntonio Quartulli2013-10-23 15:33:10 +0200
commita3285a8f20dace536ecc6a2f349150ea1d0bb391 (patch)
treed4cd1de827c780d4226d5f9b2f5018d5edd6a4ed /net/batman-adv/bat_iv_ogm.c
parentbatman-adv: add bat_orig_print API function (diff)
downloadkernel-qcow2-linux-a3285a8f20dace536ecc6a2f349150ea1d0bb391.tar.gz
kernel-qcow2-linux-a3285a8f20dace536ecc6a2f349150ea1d0bb391.tar.xz
kernel-qcow2-linux-a3285a8f20dace536ecc6a2f349150ea1d0bb391.zip
batman-adv: add bat_neigh_cmp API function
This new API allows to compare the two neighbours based on the metric avoiding the user to deal with any routing algorithm specific detail Signed-off-by: Antonio Quartulli <antonio@open-mesh.com> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv/bat_iv_ogm.c')
-rw-r--r--net/batman-adv/bat_iv_ogm.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 4aabd554ca75..b288d90855d1 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -1475,6 +1475,25 @@ next:
seq_puts(seq, "No batman nodes in range ...\n");
}
+/**
+ * batadv_iv_ogm_neigh_cmp - compare the metrics of two neighbors
+ * @neigh1: the first neighbor object of the comparison
+ * @neigh2: the second neighbor object of the comparison
+ *
+ * Returns a value less, equal to or greater than 0 if the metric via neigh1 is
+ * lower, the same as or higher than the metric via neigh2
+ */
+static int batadv_iv_ogm_neigh_cmp(struct batadv_neigh_node *neigh1,
+ struct batadv_neigh_node *neigh2)
+{
+ uint8_t tq1, tq2;
+
+ tq1 = neigh1->bat_iv.tq_avg;
+ tq2 = neigh2->bat_iv.tq_avg;
+
+ return tq1 - tq2;
+}
+
static struct batadv_algo_ops batadv_batman_iv __read_mostly = {
.name = "BATMAN_IV",
.bat_iface_enable = batadv_iv_ogm_iface_enable,
@@ -1483,6 +1502,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_neigh_cmp = batadv_iv_ogm_neigh_cmp,
.bat_orig_print = batadv_iv_ogm_orig_print,
};