jsoninfo: review of /hna
authorFerry Huberts <ferry.huberts@pelagic.nl>
Mon, 4 Jan 2016 10:32:14 +0000 (11:32 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Mon, 4 Jan 2016 11:14:20 +0000 (12:14 +0100)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/jsoninfo/src/olsrd_jsoninfo.c

index cae71d1..f854ffc 100644 (file)
@@ -306,23 +306,24 @@ void ipc_print_topology(struct autobuf *abuf) {
 
 void ipc_print_hna(struct autobuf *abuf) {
   struct hna_entry *tmp_hna;
-  struct hna_net *tmp_net;
-  struct ipaddr_str buf, mainaddrbuf;
 
   abuf_json_mark_object(true, true, abuf, "hna");
 
   OLSR_FOR_ALL_HNA_ENTRIES(tmp_hna)
         {
+          struct hna_net *tmp_net;
 
           /* Check all networks */
           for (tmp_net = tmp_hna->networks.next; tmp_net != &tmp_hna->networks; tmp_net = tmp_net->next) {
-            uint32_t vt = tmp_net->hna_net_timer != NULL ? (tmp_net->hna_net_timer->timer_clock - now_times) : 0;
-            int diff = (int) (vt);
+            struct ipaddr_str mainaddrbuf;
+            struct ipaddr_str prefixbuf;
+            uint32_t vt = tmp_net->hna_net_timer ? (tmp_net->hna_net_timer->timer_clock - now_times) : 0;
+
             abuf_json_mark_array_entry(true, abuf);
-            abuf_json_string(abuf, "destination", olsr_ip_to_string(&buf, &tmp_net->hna_prefix.prefix)), abuf_json_int(abuf, "genmask",
-                tmp_net->hna_prefix.prefix_len);
             abuf_json_string(abuf, "gateway", olsr_ip_to_string(&mainaddrbuf, &tmp_hna->A_gateway_addr));
-            abuf_json_int(abuf, "validityTime", diff);
+            abuf_json_string(abuf, "destination", olsr_ip_to_string(&prefixbuf, &tmp_net->hna_prefix.prefix));
+            abuf_json_int(abuf, "genmask", tmp_net->hna_prefix.prefix_len);
+            abuf_json_int(abuf, "validityTime", (long) vt);
             abuf_json_mark_array_entry(false, abuf);
           }
         }OLSR_FOR_ALL_HNA_ENTRIES_END(tmp_hna);