Re-Added LQ/NLQ to dnsmasq/mapwrite, corrected txtinfo output for easier parser adapt...
authorSven-Ola Tuecke <sven-ola@gmx.de>
Sun, 13 Jul 2008 14:18:05 +0000 (16:18 +0200)
committerSven-Ola Tuecke <sven-ola@gmx.de>
Sun, 13 Jul 2008 14:18:05 +0000 (16:18 +0200)
13 files changed:
lib/httpinfo/src/olsrd_httpinfo.c
lib/nameservice/src/mapwrite.c
lib/txtinfo/src/olsrd_txtinfo.c
src/link_set.c
src/lq_plugin.c
src/lq_plugin.h
src/lq_plugin_default_ff.c
src/lq_plugin_default_ff.h
src/lq_plugin_default_float.c
src/lq_plugin_default_float.h
src/lq_plugin_default_fpm.c
src/lq_plugin_default_fpm.h
src/tc_set.c

index 00dc72f..19aa6e1 100644 (file)
@@ -991,7 +991,7 @@ static int build_neigh_body(char *buf, olsr_u32_t bufsize)
       struct lqtextbuffer lqbuffer1, lqbuffer2;
       size += snprintf(&buf[size], bufsize-size,
                        "<td align=\"right\">(%s) %s</td>",
-                       get_link_entry_text(link, &lqbuffer1),
+                       get_link_entry_text(link, '/', &lqbuffer1),
                        get_linkcost_text(link->linkcost, OLSR_FALSE, &lqbuffer2));
     }
     size += snprintf(&buf[size], bufsize-size, "</tr>\n");
@@ -1061,7 +1061,7 @@ static int build_topo_body(char *buf, olsr_u32_t bufsize)
             struct lqtextbuffer lqbuffer1, lqbuffer2;
               size += snprintf(&buf[size], bufsize-size,
                                "<td align=\"right\">(%s) %s</td>\n",
-                               get_tc_edge_entry_text(tc_edge, &lqbuffer1),
+                               get_tc_edge_entry_text(tc_edge, '/', &lqbuffer1),
                                get_linkcost_text(tc_edge->cost, OLSR_FALSE, &lqbuffer2));
           }
           size += snprintf(&buf[size], bufsize-size, "</tr>\n");
index a339104..8e90f71 100644 (file)
@@ -176,14 +176,15 @@ void mapwrite_work(FILE* fmap)
     char* llb = lookup_position_latlon(&tc_edge->T_dest_addr);
     if (NULL != lla && NULL != llb)
     {
-      struct lqtextbuffer lqbuffer;
+      struct lqtextbuffer lqbuffer, lqbuffer2;
       
       /*
        * To speed up processing, Links with both positions are named PLink()
        */
-      if (0 > fprintf(fmap, "PLink('%s','%s',%s,%s,%s);\n", 
+      if (0 > fprintf(fmap, "PLink('%s','%s',%s,%s,%s,%s);\n", 
             olsr_ip_to_string(&strbuf1, &tc_edge->T_dest_addr),
             olsr_ip_to_string(&strbuf2, &tc->addr), 
+            get_tc_edge_entry_text(tc_edge, ',', &lqbuffer2),
             get_linkcost_text(tc_edge->cost, OLSR_FALSE, &lqbuffer),
             lla, llb))
       {
@@ -192,14 +193,15 @@ void mapwrite_work(FILE* fmap)
     }
     else
     {
-      struct lqtextbuffer lqbuffer;
+      struct lqtextbuffer lqbuffer, lqbuffer2;
       
       /*
        * If one link end pos is unkown, only send Link()
        */
-      if (0 > fprintf(fmap, "Link('%s','%s',%s);\n", 
+      if (0 > fprintf(fmap, "Link('%s','%s',%s,%s);\n", 
             olsr_ip_to_string(&strbuf1, &tc_edge->T_dest_addr),
             olsr_ip_to_string(&strbuf2, &tc->addr), 
+            get_tc_edge_entry_text(tc_edge, ',', &lqbuffer2),
             get_linkcost_text(tc_edge->cost, OLSR_FALSE, &lqbuffer)))
       {
         return;
index 9252f03..4c692c2 100644 (file)
@@ -321,7 +321,7 @@ static void ipc_print_neigh(void)
     struct neighbor_2_list_entry *list_2;
     int thop_cnt;
 
-    ipc_sendf("\nTable: Neighbors\nIP address\tSYM\tMPR\tMPRS\tWillingness\t2 Hop Neighbors\n");
+    ipc_sendf("\nTable: Neighbors\nIP address\tSYM\tMPR\tMPRS\tWill.\t2 Hop Neighbors\n");
 
     /* Neighbors */
     OLSR_FOR_ALL_NBR_ENTRIES(neigh) {
@@ -352,7 +352,7 @@ static void ipc_print_link(void)
 
     struct link_entry *link = NULL;
 
-    ipc_sendf("Table: Links\nLocal IP\tremote IP\tHysteresis\tLinkcost\n");
+    ipc_sendf("Table: Links\nLocal IP\tRemote IP\tHyst.\tLQ\tNLQ\tCost\n");
 
     /* Link set */
     OLSR_FOR_ALL_LINK_ENTRIES(link) {
@@ -360,7 +360,7 @@ static void ipc_print_link(void)
                    olsr_ip_to_string(&buf1, &link->local_iface_addr),
                    olsr_ip_to_string(&buf2, &link->neighbor_iface_addr),
                    link->L_link_quality, 
-                   get_link_entry_text(link, &lqbuffer1),
+                   get_link_entry_text(link, '\t', &lqbuffer1),
                    get_linkcost_text(link->linkcost, OLSR_FALSE, &lqbuffer2));
     } OLSR_FOR_ALL_LINK_ENTRIES_END(link);
 
@@ -373,7 +373,7 @@ static void ipc_print_routes(void)
     struct rt_entry *rt;
     struct lqtextbuffer lqbuffer;
     
-    ipc_sendf("Table: Routes\nDestination\tGateway\tMetric\tETX\tInterface\n");
+    ipc_sendf("Table: Routes\nDestination\tGateway IP\tMetric\tETX\tInterface\n");
 
     /* Walk the route table */
     OLSR_FOR_ALL_RT_ENTRIES(rt) {
@@ -394,7 +394,7 @@ static void ipc_print_topology(void)
 {
     struct tc_entry *tc;
     
-    ipc_sendf("Table: Topology\nDestination IP\tLast hop IP\tLinkcost\n");
+    ipc_sendf("Table: Topology\nDest. IP\tLast hop IP\tLQ\tNLQ\tCost\n");
 
     /* Topology */  
     OLSR_FOR_ALL_TC_ENTRIES(tc) {
@@ -406,7 +406,7 @@ static void ipc_print_topology(void)
             ipc_sendf( "%s\t%s\t%s\t%s\n", 
                        olsr_ip_to_string(&dstbuf, &tc_edge->T_dest_addr),
                        olsr_ip_to_string(&addrbuf, &tc->addr), 
-                       get_tc_edge_entry_text(tc_edge, &lqbuffer1),
+                       get_tc_edge_entry_text(tc_edge, '\t', &lqbuffer1),
                        get_linkcost_text(tc_edge->cost, OLSR_FALSE, &lqbuffer2));
                }
         } OLSR_FOR_ALL_TC_EDGE_ENTRIES_END(tc, tc_edge);
@@ -425,13 +425,13 @@ static void ipc_print_hna(void)
 
     size = 0;
 
-    ipc_sendf("Table: HNA\nNetwork\tNetmask\tGateway\n");
+    ipc_sendf("Table: HNA\nDestination\tGateway\n");
 
     /* Announced HNA entries */
     if (olsr_cnf->ip_version == AF_INET) {
         for(hna = olsr_cnf->hna_entries; hna != NULL; hna = hna->next) {
             struct ipaddr_str addrbuf, mainaddrbuf;
-            ipc_sendf("%s\t%d\t%s\n",
+            ipc_sendf("%s/%d\t%s\n",
                       olsr_ip_to_string(&addrbuf, &hna->net.prefix),
                       hna->net.prefix_len,
                       olsr_ip_to_string(&mainaddrbuf, &olsr_cnf->main_addr));
@@ -439,7 +439,7 @@ static void ipc_print_hna(void)
     } else {
         for(hna = olsr_cnf->hna_entries; hna != NULL; hna = hna->next) {
             struct ipaddr_str addrbuf, mainaddrbuf;
-            ipc_sendf("%s\t%d\t%s\n",
+            ipc_sendf("%s/%d\t%s\n",
                       olsr_ip_to_string(&addrbuf, &hna->net.prefix),
                       hna->net.prefix_len,
                       olsr_ip_to_string(&mainaddrbuf, &olsr_cnf->main_addr));
@@ -454,7 +454,7 @@ static void ipc_print_hna(void)
              tmp_net != &tmp_hna->networks;
              tmp_net = tmp_net->next) {
 
-            ipc_sendf("%s\t%d\t%s\n",
+            ipc_sendf("%s/%d\t%s\n",
                       olsr_ip_to_string(&addrbuf, &tmp_net->A_network_addr),
                       tmp_net->prefixlen,
                       olsr_ip_to_string(&mainaddrbuf, &tmp_hna->A_gateway_addr));
@@ -471,7 +471,7 @@ static void ipc_print_mid(void)
     struct mid_entry *entry;
     struct mid_address *alias;
 
-    ipc_sendf("Table: MID\nIP\tAliases\n");
+    ipc_sendf("Table: MID\nIP address\tAliases\n");
 
     /* MID */
     for(index = 0; index < HASHSIZE; index++) {
index 8c9dc37..13fa451 100644 (file)
@@ -806,7 +806,7 @@ olsr_print_link_set(void)
     OLSR_PRINTF(1, "%-*s  %5.3f  %-14s %s\n",
                addrsize, olsr_ip_to_string(&buf, &walker->neighbor_iface_addr),
                walker->L_link_quality,
-               get_link_entry_text(walker, &lqbuffer1),
+               get_link_entry_text(walker, '/', &lqbuffer1),
                get_linkcost_text(walker->linkcost, OLSR_FALSE, &lqbuffer2));
   } OLSR_FOR_ALL_LINK_ENTRIES_END(walker);
 #endif
index 210d6da..0c2f685 100644 (file)
@@ -277,13 +277,14 @@ olsr_memorize_foreign_hello_lq(struct link_entry *local,
  * value in the same context (a single printf command for example).
  * 
  * @param pointer to link_entry
+ * @param char separator between LQ and NLQ 
  * @param buffer for output
  * @return pointer to a buffer with the text representation
  */
 const char *
-get_link_entry_text(struct link_entry *entry, struct lqtextbuffer *buffer)
+get_link_entry_text(struct link_entry *entry, char separator, struct lqtextbuffer *buffer)
 {
-  return active_lq_handler->print_hello_lq(entry->linkquality, buffer);
+  return active_lq_handler->print_hello_lq(entry->linkquality, separator, buffer);
 }
 
 /*
@@ -294,13 +295,14 @@ get_link_entry_text(struct link_entry *entry, struct lqtextbuffer *buffer)
  * value in the same context (a single printf command for example).
  * 
  * @param pointer to tc_edge_entry
+ * @param char separator between LQ and NLQ 
  * @param pointer to buffer
  * @return pointer to the buffer with the text representation
  */
 const char *
-get_tc_edge_entry_text(struct tc_edge_entry *entry, struct lqtextbuffer *buffer)
+get_tc_edge_entry_text(struct tc_edge_entry *entry, char separator, struct lqtextbuffer *buffer)
 {
-  return active_lq_handler->print_tc_lq(entry->linkquality, buffer);
+  return active_lq_handler->print_tc_lq(entry->linkquality, separator, buffer);
 }
 
 /*
index 84cb133..a3e26bd 100644 (file)
@@ -84,8 +84,8 @@ struct lq_handler {
   void (*deserialize_hello_lq) (const olsr_u8_t ** curr, void *lq);
   void (*deserialize_tc_lq) (const olsr_u8_t ** curr, void *lq);
 
-  const char *(*print_hello_lq) (void *ptr, struct lqtextbuffer * buffer);
-  const char *(*print_tc_lq) (void *ptr, struct lqtextbuffer * buffer);
+  const char *(*print_hello_lq) (void *ptr, char separator, struct lqtextbuffer * buffer);
+  const char *(*print_tc_lq) (void *ptr, char separator, struct lqtextbuffer * buffer);
   const char *(*print_cost) (olsr_linkcost cost, struct lqtextbuffer * buffer);
 
   size_t hello_lq_size;
@@ -131,8 +131,10 @@ void olsr_memorize_foreign_hello_lq(struct link_entry *local,
                                    struct hello_neighbor *foreign);
 
 const char *get_link_entry_text(struct link_entry *entry,
+                               char separator,
                                struct lqtextbuffer *buffer);
 const char *get_tc_edge_entry_text(struct tc_edge_entry *entry,
+                                  char separator,
                                   struct lqtextbuffer *buffer);
 const char *get_linkcost_text(olsr_linkcost cost, olsr_bool route,
                              struct lqtextbuffer *buffer);
index edbd2ff..35e7798 100644 (file)
@@ -256,10 +256,13 @@ void default_lq_clear_ff_hello(void *target) {
   }
 }
 
-const char *default_lq_print_ff(void *ptr, struct lqtextbuffer *buffer) {
+const char *default_lq_print_ff(void *ptr, char separator, struct lqtextbuffer *buffer) {
   struct default_lq_ff *lq = ptr;
 
-  sprintf(buffer->buf, "%s/%s", fpmtoa(fpmidiv(itofpm((int)lq->valueLq), 255)), fpmtoa(fpmidiv(itofpm((int)lq->valueNlq), 255)));
+  sprintf(buffer->buf, "%s%x%s",
+      fpmtoa(fpmidiv(itofpm((int)lq->valueLq), 255)),
+      separator,
+      fpmtoa(fpmidiv(itofpm((int)lq->valueNlq), 255)));
   return buffer->buf;
 }
 
index 8d3a7a1..2c94e0c 100644 (file)
@@ -82,7 +82,7 @@ void default_lq_copy_link2tc_ff(void *target, void *source);
 void default_lq_clear_ff(void *target);
 void default_lq_clear_ff_hello(void *target);
 
-const char *default_lq_print_ff(void *ptr, struct lqtextbuffer *buffer);
+const char *default_lq_print_ff(void *ptr, char separator, struct lqtextbuffer *buffer);
 const char *default_lq_print_cost_ff(olsr_linkcost cost, struct lqtextbuffer *buffer);
 
 extern struct lq_handler lq_etx_ff_handler;
index 7d243c3..e22cf2d 100644 (file)
@@ -185,10 +185,13 @@ void default_lq_clear_float(void *target) {
   memset(target, 0, sizeof(struct default_lq_float));
 }
 
-const char *default_lq_print_float(void *ptr, struct lqtextbuffer *buffer) {
+const char *default_lq_print_float(void *ptr, char separator, struct lqtextbuffer *buffer) {
   struct default_lq_float *lq = ptr;
   
-  sprintf(buffer->buf, "%2.3f/%2.3f", lq->lq, lq->nlq);
+  sprintf(buffer->buf, "%2.3f%c%2.3f",
+      lq->lq,
+      separator,
+      lq->nlq);
   return buffer->buf;
 }
 
index 5538131..4f426cc 100644 (file)
@@ -70,7 +70,7 @@ void default_lq_deserialize_tc_lq_pair_float(const olsr_u8_t **curr, void *lq);
 void default_lq_copy_link2tc_float(void *target, void *source);
 void default_lq_clear_float(void *target);
 
-const char *default_lq_print_float(void *ptr, struct lqtextbuffer *buffer);
+const char *default_lq_print_float(void *ptr, char separator, struct lqtextbuffer *buffer);
 const char *default_lq_print_cost_float(olsr_linkcost cost, struct lqtextbuffer *buffer);
 
 extern struct lq_handler lq_etx_float_handler;
index f57122b..ef077ba 100644 (file)
@@ -198,11 +198,12 @@ void default_lq_clear_fpm(void *target) {
   memset(target, 0, sizeof(struct default_lq_fpm));
 }
 
-const char *default_lq_print_fpm(void *ptr, struct lqtextbuffer *buffer) {
+const char *default_lq_print_fpm(void *ptr, char separator, struct lqtextbuffer *buffer) {
   struct default_lq_fpm *lq = ptr;
   
-  sprintf(buffer->buf, "%0.3f/%0.3f",
+  sprintf(buffer->buf, "%0.3f%c%0.3f",
       (float)(lq->valueLq) / 255.0,
+      separator,
       (float)(lq->valueNlq) / 255.0);
   return buffer->buf;
 }
index b49e76f..38d7015 100644 (file)
@@ -76,7 +76,7 @@ void default_lq_deserialize_tc_lq_pair_fpm(const olsr_u8_t **curr, void *lq);
 void default_lq_copy_link2tc_fpm(void *target, void *source);
 void default_lq_clear_fpm(void *target);
 
-const char *default_lq_print_fpm(void *ptr, struct lqtextbuffer *buffer);
+const char *default_lq_print_fpm(void *ptr, char separator, struct lqtextbuffer *buffer);
 const char *default_lq_print_cost_fpm(olsr_linkcost cost, struct lqtextbuffer *buffer);
 
 extern struct lq_handler lq_etx_fpm_handler;
index 6408dd4..89cc554 100644 (file)
@@ -354,7 +354,7 @@ olsr_tc_edge_to_string(struct tc_edge_entry *tc_edge)
           "%s > %s, cost (%6s) %s",
           olsr_ip_to_string(&addrbuf, &tc->addr),
           olsr_ip_to_string(&dstbuf, &tc_edge->T_dest_addr),
-          get_tc_edge_entry_text(tc_edge, &lqbuffer1),
+          get_tc_edge_entry_text(tc_edge, '/', &lqbuffer1),
           get_linkcost_text(tc_edge->cost, OLSR_FALSE, &lqbuffer2));
 
   return buf;
@@ -723,7 +723,7 @@ olsr_print_tc_table(void)
                  ipwidth, olsr_ip_to_string(&addrbuf, &tc->addr),
                  ipwidth, olsr_ip_to_string(&dstaddrbuf,
                                             &tc_edge->T_dest_addr),
-                 get_tc_edge_entry_text(tc_edge, &lqbuffer1),
+                 get_tc_edge_entry_text(tc_edge, '/', &lqbuffer1),
                  get_linkcost_text(tc_edge->cost, OLSR_FALSE, &lqbuffer2));
 
     } OLSR_FOR_ALL_TC_EDGE_ENTRIES_END(tc, tc_edge);