Format debug output as a table.
authorThomas Lopatic <thomas@lopatic.de>
Mon, 8 Nov 2004 23:25:57 +0000 (23:25 +0000)
committerThomas Lopatic <thomas@lopatic.de>
Mon, 8 Nov 2004 23:25:57 +0000 (23:25 +0000)
src/generate_msg.c
src/link_set.c
src/lq_mpr.c
src/neighbor_table.c
src/two_hop_neighbor_table.c

index 13e97c6..40c5fc7 100644 (file)
@@ -19,7 +19,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * 
  * 
- * $Id: generate_msg.c,v 1.13 2004/11/08 00:17:05 tlopatic Exp $
+ * $Id: generate_msg.c,v 1.14 2004/11/08 23:25:57 tlopatic Exp $
  *
  */
 
@@ -38,6 +38,7 @@
 #include "duplicate_set.h"
 #include "neighbor_table.h"
 #include "link_set.h"
+#include "two_hop_neighbor_table.h"
 
 void
 generate_hello(void *p)
@@ -107,6 +108,9 @@ generate_tabledisplay(void *foo)
       olsr_print_link_set();
 #endif
       olsr_print_neighbor_table();
+#if defined USE_LINK_QUALITY
+      olsr_print_two_hop_neighbor_table();
+#endif
       
       if(olsr_cnf->debug_level > 1)
        {
index 132fd83..7a01ade 100644 (file)
@@ -19,7 +19,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * 
  * 
- * $Id: link_set.c,v 1.21 2004/11/08 00:57:58 tlopatic Exp $
+ * $Id: link_set.c,v 1.22 2004/11/08 23:25:57 tlopatic Exp $
  *
  */
 
@@ -910,7 +910,7 @@ void olsr_print_link_set(void)
 {
   struct link_entry *walker;
 
-  olsr_printf(1, "\nLINKS --------------------------------------------------\n\n");
+  olsr_printf(1, "\n-------------------------------------------------- LINKS\n\n");
   olsr_printf(1, "IP address       hyst   LQ     lost   total  NLQ\n");
 
   for (walker = link_set; walker != NULL; walker = walker->next)
index 2493100..9d6fa1b 100644 (file)
@@ -18,7 +18,7 @@
  * along with olsr.org; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: lq_mpr.c,v 1.3 2004/11/08 18:31:55 tlopatic Exp $
+ * $Id: lq_mpr.c,v 1.4 2004/11/08 23:25:57 tlopatic Exp $
  *
  */
 
@@ -97,10 +97,13 @@ void olsr_calculate_lq_mpr(void)
                 best = walker->full_link_quality;
               }
 
-          neigh->is_mpr = OLSR_TRUE;
-
-          if (neigh->is_mpr != neigh->was_mpr)
-            mpr_changes = OLSR_TRUE;
+          if (neigh != NULL)
+            {
+              neigh->is_mpr = OLSR_TRUE;
+          
+              if (neigh->is_mpr != neigh->was_mpr)
+                mpr_changes = OLSR_TRUE;
+            }
         }
     }
 
index d43f785..5e069b1 100644 (file)
@@ -19,7 +19,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * 
  * 
- * $Id: neighbor_table.c,v 1.10 2004/11/05 11:52:55 kattemat Exp $
+ * $Id: neighbor_table.c,v 1.11 2004/11/08 23:25:57 tlopatic Exp $
  *
  */
 
@@ -32,6 +32,7 @@
 #include "mpr.h"
 #include "olsr.h"
 #include "scheduler.h"
+#include "link_set.h"
 
 void
 olsr_init_neighbor_table()
@@ -457,37 +458,40 @@ olsr_time_out_neighborhood_tables()
 void
 olsr_print_neighbor_table()
 {
-  olsr_u8_t                    index;
-  struct neighbor_entry        *neighbor_table_tmp;
-  struct neighbor_2_list_entry *list_2;
-
-
+  int i;
+  struct neighbor_entry *neigh;
+#if defined USE_LINK_QUALITY
+  struct link_entry *link;
+#endif
+  double best_lq, inv_best_lq, total_lq;
 
-  olsr_printf(1, "Neighbor list(%02d:%02d:%02d.%06lu):\n", 
-             nowtm->tm_hour, 
-             nowtm->tm_min, 
-             nowtm->tm_sec, 
-             now.tv_usec);
+  olsr_printf(1, "\n---------------------------------------------- NEIGHBORS\n\n");
+  olsr_printf(1, "IP address       LQ     NLQ    TLQ    SYM  MPR  will\n");
 
-  for(index=0;index<HASHSIZE;index++)
+  for (i = 0; i < HASHSIZE; i++)
     {
-    
-      for(neighbor_table_tmp = neighbortable[index].next;
-         neighbor_table_tmp != &neighbortable[index];
-         neighbor_table_tmp = neighbor_table_tmp->next)
+      for(neigh = neighbortable[i].next; neigh != &neighbortable[i];
+         neigh = neigh->next)
        {
-         olsr_printf(1, "%s:l=%d:m=%d:w=%d[2hlist:", 
-                     olsr_ip_to_string(&neighbor_table_tmp->neighbor_main_addr),
-                     neighbor_table_tmp->status, neighbor_table_tmp->is_mpr, neighbor_table_tmp->willingness);
-
-         for(list_2 = neighbor_table_tmp->neighbor_2_list.next;
-             list_2 != &neighbor_table_tmp->neighbor_2_list;
-             list_2 = list_2->next)
-           {
-             olsr_printf(1, "%s:", olsr_ip_to_string(&list_2->neighbor_2->neighbor_2_addr));
-           }
-         olsr_printf(1, "]\n");
-
+#if defined USE_LINK_QUALITY
+          link = olsr_neighbor_best_link(&neigh->neighbor_main_addr);
+          best_lq = link->neigh_link_quality;
+
+          link = olsr_neighbor_best_inverse_link(&neigh->neighbor_main_addr);
+          inv_best_lq = link->loss_link_quality;
+#else
+          best_lq = 0.0;
+          inv_best_lq = 0.0;
+#endif
+
+          total_lq = best_lq * inv_best_lq;
+
+          olsr_printf(1, "%-15s  %5.3f  %5.3f  %5.3f  %s  %s  %d\n",
+                      olsr_ip_to_string(&neigh->neighbor_main_addr),
+                      best_lq, inv_best_lq, total_lq,
+                      (neigh->status == SYM) ? "SYM" : "   ",
+                      neigh->is_mpr ? "MPR" : "   ",
+                      neigh->willingness);
        }
     }
 }
index 959744b..5d1c61b 100644 (file)
@@ -19,7 +19,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * 
  * 
- * $Id: two_hop_neighbor_table.c,v 1.6 2004/09/21 19:08:58 kattemat Exp $
+ * $Id: two_hop_neighbor_table.c,v 1.7 2004/11/08 23:25:57 tlopatic Exp $
  *
  */
 
@@ -228,33 +228,47 @@ olsr_lookup_two_hop_neighbor_table_mid(union olsr_ip_addr *dest)
 void
 olsr_print_two_hop_neighbor_table()
 {
-  olsr_u8_t                  index;
-  struct neighbor_2_entry    *neighbor_2;
+  int i;
+  struct neighbor_2_entry *neigh2;
+  struct neighbor_list_entry *entry;
+  struct neighbor_entry *neigh;
+  olsr_bool first;
+  double total_lq;
 
-  struct neighbor_list_entry *list_1=NULL;
+  olsr_printf(1, "\n-------------------------------------- TWO-HOP NEIGHBORS\n\n");
+  olsr_printf(1, "IP addr (2-hop)  IP addr (1-hop)  TLQ\n");
 
-  printf("THE TWO HOP NEIGHBORS\n");
-
-  for(index=0;index<HASHSIZE;index++)
+  for (i = 0; i < HASHSIZE; i++)
     {
-
-      for(neighbor_2 = two_hop_neighbortable[index].next;
-         neighbor_2 != &two_hop_neighbortable[index];
-         neighbor_2 = neighbor_2->next)
+      for (neigh2 = two_hop_neighbortable[i].next;
+           neigh2 != &two_hop_neighbortable[i]; neigh2 = neigh2->next)
        {
-         
-         printf("ADDRESS TWO HOP NEIGHBORS\n");
-         printf("%s \n", olsr_ip_to_string(&neighbor_2->neighbor_2_addr)); 
-         printf("---------------------\n");
-         
-         printf("POINTED BY\n");
-         for(list_1 = neighbor_2->neighbor_2_nblist.next;
-             list_1 != &neighbor_2->neighbor_2_nblist;
-             list_1 = list_1->next)
-           {         
-             printf("%s \n", olsr_ip_to_string(&list_1->neighbor->neighbor_main_addr));
-           }
-         printf("---------------------\n");
+          first = OLSR_TRUE;
+
+         for (entry = neigh2->neighbor_2_nblist.next;
+               entry != &neigh2->neighbor_2_nblist; entry = entry->next)
+           {
+              neigh = entry->neighbor;
+
+              if (first)
+                {
+                  olsr_printf(1, "%-15s  ",
+                              olsr_ip_to_string(&neigh2->neighbor_2_addr));
+                  first = OLSR_FALSE;
+                }
+
+              else
+                olsr_printf(1, "                 ");
+
+#if defined USE_LINK_QUALITY
+              total_lq = entry->full_link_quality;
+#else
+              total_lq = 0.0;
+#endif
+              olsr_printf(1, "%-15s  %5.3f\n",
+                          olsr_ip_to_string(&neigh->neighbor_main_addr),
+                          total_lq);
+            }
        }
     }
 }