Some bugfixes for lqmult in "same IP on different interfaces" situations.
authorHenning Rogge <hrogge@googlemail.com>
Sat, 5 Sep 2009 12:38:06 +0000 (14:38 +0200)
committerHenning Rogge <hrogge@googlemail.com>
Sat, 5 Sep 2009 12:38:06 +0000 (14:38 +0200)
Don't do this !

src/fpm.c
src/fpm.h
src/link_set.c
src/lq_plugin_default_ff.c

index 681f9a6..ad66a1a 100644 (file)
--- a/src/fpm.c
+++ b/src/fpm.c
 #ifndef NDEBUG
 
 fpm
-itofpm(int i)
+itofpm(sfpm i)
 {
-  fpm r;
-  assert(fpmtoi_def(FPM_MIN) <= i);
-  assert(i <= fpmtoi_def(FPM_INT_MAX));
-  r = (fpm) itofpm_def(i);
-  return r;
+  assert(FPM_MIN <= i && i <= FPM_MAX);
+  return itofpm_def(i);
 }
 
 fpm
index d471f82..5d6b5af 100644 (file)
--- a/src/fpm.h
+++ b/src/fpm.h
@@ -136,7 +136,7 @@ typedef unsigned long ufpm;
 
 #else /* NDEBUG */
 
-fpm itofpm(int i);
+fpm itofpm(sfpm i);
 fpm ftofpm(float f);
 int fpmtoi(fpm a);
 float fpmtof(fpm a);
index 9ff8fea..0fb4329 100644 (file)
@@ -42,6 +42,7 @@
 /*
  * Link sensing database for the OLSR routing daemon
  */
+#include <assert.h>
 
 #include "defs.h"
 #include "link_set.h"
@@ -290,7 +291,8 @@ set_loss_link_multiplier(struct link_entry *entry)
   struct ipaddr_str buf;
 
   /* find the interface for the link */
-  inter = if_ifwithaddr(&entry->local_iface_addr);
+  assert(entry->if_name);
+  inter = if_ifwithname(entry->if_name);
 
   /* find the interface configuration for the interface */
   for (cfg_inter = olsr_cnf->interfaces; cfg_inter; cfg_inter = cfg_inter->next) {
index bde7512..811d03f 100644 (file)
@@ -149,7 +149,7 @@ default_lq_ff_timer(void __attribute__ ((unused)) * context)
       tlq->lq.valueLq = 0;
     } else {
       // start with link-loss-factor
-      ratio = fpmidiv(itofpm(link->loss_link_multiplier), 65536);
+      ratio = fpmidiv(itofpm(link->loss_link_multiplier), LINK_LOSS_MULTIPLIER);
 
       // calculate received/(received + loss) factor
       ratio = fpmmuli(ratio, (int)received);