always output VTIME validity time info
authorHans-Christoph Steiner <hans@eds.org>
Mon, 7 May 2012 01:49:30 +0000 (21:49 -0400)
committerHans-Christoph Steiner <hans@eds.org>
Wed, 9 May 2012 04:43:30 +0000 (00:43 -0400)
lib/jsoninfo/src/olsrd_jsoninfo.c
lib/jsoninfo/src/olsrd_jsoninfo.h

index c6869bf..7ffc277 100644 (file)
@@ -413,17 +413,11 @@ ipc_print_links(struct autobuf *abuf)
 
   struct link_entry *my_link = NULL;
 
-#ifdef ACTIVATE_VTIME_JSONINFO
   abuf_json_open_array(abuf, "links");
   //abuf_puts(abuf, "Table: Links\nLocal IP\tRemote IP\tVTime\tLQ\tNLQ\tCost\n");
-#else
-  abuf_json_open_array(abuf, "links");
-  //abuf_puts(abuf, "Table: Links\nLocal IP\tRemote IP\tHyst.\tLQ\tNLQ\tCost\n");
-#endif
 
   /* Link set */
   OLSR_FOR_ALL_LINK_ENTRIES(my_link) {
-#ifdef ACTIVATE_VTIME_JSONINFO
     int diff = (unsigned int)(my_link->link_timer->timer_clock - now_times);
 
     abuf_appendf(abuf,
@@ -433,14 +427,6 @@ ipc_print_links(struct autobuf *abuf)
                  diff/1000, abs(diff%1000),
                  get_link_entry_text(my_link, '\t', &lqbuffer1),
                  get_linkcost_text(my_link->linkcost, false, &lqbuffer2));
-#else
-    abuf_appendf(abuf,
-                 "%s\t%s\t0.00\t%s\t%s\t\n",
-                 olsr_ip_to_string(&buf1, &my_link->local_iface_addr),
-                 olsr_ip_to_string(&buf2, &my_link->neighbor_iface_addr),
-                 get_link_entry_text(my_link, '\t', &lqbuffer1),
-                 get_linkcost_text(my_link->linkcost, false, &lqbuffer2));
-#endif
   }
   OLSR_FOR_ALL_LINK_ENTRIES_END(my_link);
 
@@ -480,11 +466,7 @@ ipc_print_topology(struct autobuf *abuf)
   struct tc_entry *tc;
 
   abuf_json_open_array(abuf, "topology");
-#ifdef ACTIVATE_VTIME_JSONINFO
   //abuf_puts(abuf, "Table: Topology\nDest. IP\tLast hop IP\tLQ\tNLQ\tCost\tVTime\n");
-#else
-  //abuf_puts(abuf, "Table: Topology\nDest. IP\tLast hop IP\tLQ\tNLQ\tCost\n");
-#endif
 
   /* Topology */
   OLSR_FOR_ALL_TC_ENTRIES(tc) {
@@ -493,7 +475,6 @@ ipc_print_topology(struct autobuf *abuf)
       if (tc_edge->edge_inv) {
         struct ipaddr_str dstbuf, addrbuf;
         struct lqtextbuffer lqbuffer1, lqbuffer2;
-#ifdef ACTIVATE_VTIME_JSONINFO
         uint32_t vt = tc->validity_timer != NULL ? (tc->validity_timer->timer_clock - now_times) : 0;
         int diff = (int)(vt);
         abuf_appendf(abuf, "%s\t%s\t%s\t%s\t%d.%03d\n", olsr_ip_to_string(&dstbuf, &tc_edge->T_dest_addr),
@@ -501,14 +482,6 @@ ipc_print_topology(struct autobuf *abuf)
                      get_tc_edge_entry_text(tc_edge, '\t', &lqbuffer1),
                      get_linkcost_text(tc_edge->cost, false, &lqbuffer2),
                      diff/1000, diff%1000);
-#else
-        abuf_appendf(abuf,
-                     "%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, '\t', &lqbuffer1),
-                     get_linkcost_text(tc_edge->cost, false, &lqbuffer2));
-#endif
       }
     }
     OLSR_FOR_ALL_TC_EDGE_ENTRIES_END(tc, tc_edge);
@@ -527,11 +500,7 @@ ipc_print_hna(struct autobuf *abuf)
   struct ipaddr_str buf, mainaddrbuf;
 
   abuf_json_open_array(abuf, "hna");
-#ifdef ACTIVATE_VTIME_JSONINFO
   //abuf_puts(abuf, "Table: HNA\nDestination\tGateway\tVTime\n");
-#else
-  //abuf_puts(abuf, "Table: HNA\nDestination\tGateway\n");
-#endif /*vtime jsoninfo*/
 
   /* Announced HNA entries */
   if (olsr_cnf->ip_version == AF_INET) {
@@ -557,7 +526,6 @@ ipc_print_hna(struct autobuf *abuf)
 
     /* Check all networks */
     for (tmp_net = tmp_hna->networks.next; tmp_net != &tmp_hna->networks; tmp_net = tmp_net->next) {
-#ifdef ACTIVATE_VTIME_JSONINFO
       uint32_t vt = tmp_net->hna_net_timer != NULL ? (tmp_net->hna_net_timer->timer_clock - now_times) : 0;
       int diff = (int)(vt);
       abuf_appendf(abuf,
@@ -566,13 +534,6 @@ ipc_print_hna(struct autobuf *abuf)
                    tmp_net->hna_prefix.prefix_len,
                    olsr_ip_to_string(&mainaddrbuf, &tmp_hna->A_gateway_addr),
                    diff/1000, abs(diff%1000));
-#else
-      abuf_appendf(abuf,
-                   "%s/%d\t%s\n",
-                   olsr_ip_to_string(&buf, &tmp_net->hna_prefix.prefix),
-                   tmp_net->hna_prefix.prefix_len,
-                   olsr_ip_to_string(&mainaddrbuf, &tmp_hna->A_gateway_addr));
-#endif /*vtime jsoninfo*/
     }
   }
   OLSR_FOR_ALL_HNA_ENTRIES_END(tmp_hna);
@@ -589,28 +550,18 @@ ipc_print_mid(struct autobuf *abuf)
   struct mid_address *alias;
 
   abuf_json_open_array(abuf, "mid");
-#ifdef ACTIVATE_VTIME_JSONINFO
   //abuf_puts(abuf, "Table: MID\nIP address\tAlias\tVTime\n");
-#else
-  //abuf_puts(abuf, "Table: MID\nIP address\tAliases\n");
-#endif /*vtime jsoninfo*/
 
   /* MID */
   for (idx = 0; idx < HASHSIZE; idx++) {
     entry = mid_set[idx].next;
 
     while (entry != &mid_set[idx]) {
-#ifdef ACTIVATE_VTIME_JSONINFO
       struct ipaddr_str buf, buf2;
-#else
-      struct ipaddr_str buf;
-      abuf_puts(abuf, olsr_ip_to_string(&buf, &entry->main_addr));
-#endif /*vtime jsoninfo*/
       alias = entry->aliases;
       is_first = 1;
 
       while (alias) {
-#ifdef ACTIVATE_VTIME_JSONINFO
         uint32_t vt = alias->vtime - now_times;
         int diff = (int)(vt);
 
@@ -618,19 +569,10 @@ ipc_print_mid(struct autobuf *abuf)
                      olsr_ip_to_string(&buf, &entry->main_addr),
                      olsr_ip_to_string(&buf2, &alias->alias),
                      diff/1000, abs(diff%1000));
-#else
-        abuf_appendf(abuf,
-                     "%s%s",
-                     (is_first ? "\t" : ";"),
-                     olsr_ip_to_string(&buf, &alias->alias));
-#endif /*vtime jsoninfo*/
         alias = alias->next_alias;
         is_first = 0;
       }
       entry = entry->next;
-#ifndef ACTIVATE_VTIME_JSONINFO
-      abuf_puts(abuf,"\n");
-#endif /*vtime jsoninfo*/
     }
   }
   abuf_json_close_array(abuf);
@@ -640,7 +582,7 @@ static void
 ipc_print_gateways(struct autobuf *abuf)
 {
 #ifndef linux
-  abuf_puts(abuf, "Gateway mode is only supported in linux\n");
+  abuf_json_key_string(abuf, "error", "Gateway mode is only supported in Linux");
 #else
   static const char IPV4[] = "ipv4";
   static const char IPV4_NAT[] = "ipv4(n)";
index 7e86f47..a254ba4 100644 (file)
@@ -51,9 +51,6 @@
 #include "olsrd_plugin.h"
 #include "plugin_util.h"
 
-/* uncomment this to include VTime values into Link/Topology command */
-/* #define ACTIVATE_VTIME_JSONINFO */
-
 /* uncomment this to allow connections from 127.0.0.1 regardless of olsrd.conf (useful to allow externel ip/network + localhost) (ipv4 only)*/
 /* #define JSONINFO_ALLOW_LOCALHOST */