LQ bug fixes.
authorThomas Lopatic <thomas@lopatic.de>
Mon, 8 Nov 2004 00:15:46 +0000 (00:15 +0000)
committerThomas Lopatic <thomas@lopatic.de>
Mon, 8 Nov 2004 00:15:46 +0000 (00:15 +0000)
src/link_set.c
src/lq_packet.c

index d234038..c0e0fe8 100644 (file)
@@ -19,7 +19,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * 
  * 
- * $Id: link_set.c,v 1.19 2004/11/07 20:09:11 tlopatic Exp $
+ * $Id: link_set.c,v 1.20 2004/11/08 00:15:46 tlopatic Exp $
  *
  */
 
@@ -910,15 +910,14 @@ void olsr_print_link_set(void)
 {
   struct link_entry *walker;
 
-  olsr_printf(1, "LINK SET --------------------------------------\n");
-  olsr_printf(1, "IP address      hyst  LQ    lost  total  NLQ\n");
+  olsr_printf(1, "\nLINKS --------------------------------------------------\n\n");
+  olsr_printf(1, "IP address       hyst   LQ     lost   total  NLQ\n");
 
   for (walker = link_set; walker != NULL; walker = walker->next)
-    olsr_printf(1, "%15s %5.3f %5.3f %3d   %3d    %5.3f\n",
+    olsr_printf(1, "%-15s  %5.3f  %5.3f  %-3d    %-3d    %5.3f\n",
                 olsr_ip_to_string(&walker->neighbor_iface_addr),
                 walker->L_link_quality, walker->loss_link_quality,
                 walker->lost_packets, walker->total_packets);
-  olsr_printf(1, "-----------------------------------------------\n");
 }
 
 static void update_packet_loss_worker(struct link_entry *entry, int lost)
@@ -1086,7 +1085,7 @@ double olsr_neighbor_best_link_quality(union olsr_ip_addr *main)
       // whether the link's (bidirectional = forth x back) quality
       // is better than what we have
 
-      if(COMP_IP(&main, &walker->neighbor->neighbor_main_addr) &&
+      if(COMP_IP(main, &walker->neighbor->neighbor_main_addr) &&
          walker->loss_link_quality * walker->neigh_link_quality >= res)
         res = walker->loss_link_quality;
     }
@@ -1107,7 +1106,7 @@ struct link_entry *olsr_neighbor_best_link(union olsr_ip_addr *main)
     // check whether it's a link to the requested neighbor and
     // whether the link's quality is better than what we have
 
-    if(COMP_IP(&main, &walker->neighbor->neighbor_main_addr) &&
+    if(COMP_IP(main, &walker->neighbor->neighbor_main_addr) &&
        walker->neigh_link_quality >= best)
     {
       best = walker->loss_link_quality;
@@ -1131,7 +1130,7 @@ struct link_entry *olsr_neighbor_best_inverse_link(union olsr_ip_addr *main)
     // check whether it's a link to the requested neighbor and
     // whether the link's quality is better than what we have
 
-    if(COMP_IP(&main, &walker->neighbor->neighbor_main_addr) &&
+    if(COMP_IP(main, &walker->neighbor->neighbor_main_addr) &&
        walker->loss_link_quality >= best)
     {
       best = walker->loss_link_quality;
index 92550ac..c862018 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * 
  * 
- * $Id: lq_packet.c,v 1.4 2004/11/07 20:09:11 tlopatic Exp $
+ * $Id: lq_packet.c,v 1.5 2004/11/08 00:15:46 tlopatic Exp $
  *
  */
 
@@ -239,6 +239,8 @@ static void serialize_common(struct olsr_common *comm)
       olsr_head_v4->ttl = comm->ttl;
       olsr_head_v4->hops = comm->hops;
       olsr_head_v4->seqno = htons(comm->seqno);
+
+      return;
     }
 
   // serialize an IPv6 OLSR message header
@@ -386,8 +388,8 @@ serialize_lq_hello(struct lq_hello_message *lq_hello, struct interface *outif)
 
               // add the corresponding link quality
 
-              buff[size++] = (unsigned char)(neigh->link_quality * 256);
-              buff[size++] = (unsigned char)(neigh->neigh_link_quality * 256);
+              buff[size++] = (unsigned char)(neigh->link_quality * 255);
+              buff[size++] = (unsigned char)(neigh->neigh_link_quality * 255);
 
               // pad
 
@@ -496,8 +498,8 @@ serialize_lq_tc(struct lq_tc_message *lq_tc, struct interface *outif)
 
       // add the corresponding link quality
 
-      buff[size++] = (unsigned char)(neigh->link_quality * 256);
-      buff[size++] = (unsigned char)(neigh->neigh_link_quality * 256);
+      buff[size++] = (unsigned char)(neigh->link_quality * 255);
+      buff[size++] = (unsigned char)(neigh->neigh_link_quality * 255);
 
       // pad
 
@@ -579,6 +581,8 @@ deserialize_lq_hello(struct lq_hello_message *lq_hello, void *ser)
   lq_hello->htime = me_to_double(head->htime);
   lq_hello->will = head->will;
 
+  lq_hello->neigh = NULL;
+
   curr = (unsigned char *)(head + 1);
 
   while (curr < limit)
@@ -591,14 +595,14 @@ deserialize_lq_hello(struct lq_hello_message *lq_hello, void *ser)
       
       while (curr < limit2)
         {
-          neigh = olsr_malloc(sizeof (struct lq_tc_neighbor),
+          neigh = olsr_malloc(sizeof (struct lq_hello_neighbor),
                               "LQ_HELLO deserialization");
 
           COPY_IP(&neigh->addr, curr);
           curr += ipsize;
 
-          neigh->link_quality = (double)*curr++ / 256.0;
-          neigh->neigh_link_quality = (double)*curr++ / 256.0;
+          neigh->link_quality = (double)*curr++ / 255.0;
+          neigh->neigh_link_quality = (double)*curr++ / 255.0;
 
           curr += 2;
 
@@ -643,6 +647,8 @@ deserialize_lq_tc(struct lq_tc_message *lq_tc, void *ser,
 
   lq_tc->ansn =  ntohs(head->ansn);
 
+  lq_tc->neigh = NULL;
+
   curr = (unsigned char *)(head + 1);
 
   while (curr < limit)
@@ -653,8 +659,8 @@ deserialize_lq_tc(struct lq_tc_message *lq_tc, void *ser,
       COPY_IP(&neigh->main, curr);
       curr += ipsize;
 
-      neigh->link_quality = (double)*curr++ / 256.0;
-      neigh->neigh_link_quality = (double)*curr++ / 256.0;
+      neigh->link_quality = (double)*curr++ / 255.0;
+      neigh->neigh_link_quality = (double)*curr++ / 255.0;
 
       curr += 2;
 
@@ -759,6 +765,8 @@ process_lq_hello(struct lq_hello_message *lq_hello, struct interface *inif,
   hello.ttl = lq_hello->comm.ttl;
   hello.willingness = lq_hello->will;
 
+  hello.neighbors = NULL;
+
   // move all LQ_HELLO neighbours to HELLO
 
   for (neigh = lq_hello->neigh; neigh != NULL; neigh = neigh->next)
@@ -773,6 +781,7 @@ process_lq_hello(struct lq_hello_message *lq_hello, struct interface *inif,
       new_neigh->status = neigh->neigh_type;
       new_neigh->link = neigh->link_type;
       new_neigh->link_quality = neigh->link_quality;
+      new_neigh->neigh_link_quality = neigh->neigh_link_quality;
 
       COPY_IP(&new_neigh->address, &neigh->addr);
 
@@ -807,6 +816,8 @@ process_lq_tc(struct lq_tc_message *lq_tc, struct interface *inif,
   tc.ttl = lq_tc->comm.ttl;
   tc.ansn = lq_tc->ansn;
 
+  tc.multipoint_relay_selector_address = NULL;
+
   // move all LQ_TC neighbours to TC
 
   for (neigh = lq_tc->neigh; neigh != NULL; neigh = neigh->next)