learn neighbours interface alias adress from received hellos
authorMarkus Kittenberger <Markus.Kittenberger@gmx.at>
Wed, 4 Nov 2009 16:42:18 +0000 (17:42 +0100)
committerMarkus Kittenberger <Markus.Kittenberger@gmx.at>
Wed, 4 Nov 2009 16:42:18 +0000 (17:42 +0100)
src/mid_set.c
src/process_package.c

index f663972..202891f 100644 (file)
@@ -109,8 +109,12 @@ olsr_expire_mid_entry(void *context)
 static void
 olsr_set_mid_timer(struct mid_entry *mid, olsr_reltime rel_timer)
 {
-
-  olsr_set_timer(&mid->mid_timer, rel_timer, OLSR_MID_JITTER, OLSR_TIMER_ONESHOT, &olsr_expire_mid_entry, mid, 0);
+  int32_t willFireIn = -1;
+  if (mid->mid_timer != NULL) willFireIn = olsr_getTimeDue(mid->mid_timer->timer_clock);
+  
+  if (willFireIn < 0 || (olsr_reltime)willFireIn < rel_timer) {
+    olsr_set_timer(&mid->mid_timer, rel_timer, OLSR_MID_JITTER, OLSR_TIMER_ONESHOT, &olsr_expire_mid_entry, mid, 0);
+  }
 }
 
 /**
index 16ffc20..bb701db 100644 (file)
@@ -417,6 +417,28 @@ olsr_hello_tap(struct hello_message *message, struct interface *in_if, const uni
    */
   struct link_entry *lnk = update_link_entry(&in_if->ip_addr, from_addr, message, in_if);
 
+  /*check alias message->source_addr*/
+  if (!ipequal(&message->source_addr,from_addr)){
+    /*new alias of new neighbour are thrown in the mid table to speed up routing*/
+    if (olsr_validate_address(from_addr)) {
+      union olsr_ip_addr * main_addr = mid_lookup_main_addr(from_addr);
+      if ((main_addr==NULL)||(ipequal(&message->source_addr, main_addr))){
+        /*struct ipaddr_str srcbuf, origbuf;
+        olsr_syslog(OLSR_LOG_INFO, "got hello from unknown alias ip of direct neighbour: ip: %s main-ip: %s",
+                    olsr_ip_to_string(&origbuf,&message->source_addr),
+                    olsr_ip_to_string(&srcbuf,from_addr));*/
+        insert_mid_alias(&message->source_addr, from_addr, message->vtime);
+      }
+      else
+      {
+        struct ipaddr_str srcbuf, origbuf;
+        olsr_syslog(OLSR_LOG_INFO, "got hello with invalid from and originator adress pair (%s, %s) Duplicate Ips?\n",
+                    olsr_ip_to_string(&origbuf,&message->source_addr),
+                    olsr_ip_to_string(&srcbuf,from_addr));
+      }
+    }
+  }
+
   if (olsr_cnf->lq_level > 0) {
     struct hello_neighbor *walker;
     /* just in case our neighbor has changed its HELLO interval */