jsoninfo: move local HNA set in olsrd.conf from the "hna" to the "config" section
authorHans-Christoph Steiner <hans@eds.org>
Wed, 4 Jul 2012 20:49:42 +0000 (16:49 -0400)
committerHans-Christoph Steiner <hans@eds.org>
Wed, 4 Jul 2012 20:51:33 +0000 (16:51 -0400)
lib/jsoninfo/src/olsrd_jsoninfo.c

index 98686e1..551739b 100644 (file)
@@ -682,37 +682,12 @@ ipc_print_topology(struct autobuf *abuf)
 static void
 ipc_print_hna(struct autobuf *abuf)
 {
-  struct ip_prefix_list *hna;
   struct hna_entry *tmp_hna;
   struct hna_net *tmp_net;
   struct ipaddr_str buf, mainaddrbuf;
 
   abuf_json_open_array(abuf, "hna");
 
-  /* Announced HNA entries */
-  if (olsr_cnf->ip_version == AF_INET) {
-    for (hna = olsr_cnf->hna_entries; hna != NULL; hna = hna->next) {
-      abuf_json_open_array_entry(abuf);
-      abuf_json_string(abuf, "destination",
-                       olsr_ip_to_string(&buf, &hna->net.prefix));
-      abuf_json_int(abuf, "genmask", hna->net.prefix_len);
-      abuf_json_string(abuf, "gateway",
-                       olsr_ip_to_string(&mainaddrbuf, &olsr_cnf->main_addr));
-      abuf_json_close_array_entry(abuf);
-    }
-  } else {
-    for (hna = olsr_cnf->hna_entries; hna != NULL; hna = hna->next) {
-      abuf_json_open_array_entry(abuf);
-      abuf_json_string(abuf, "destination",
-                       olsr_ip_to_string(&buf, &hna->net.prefix));
-      abuf_json_int(abuf, "genmask", hna->net.prefix_len);
-      abuf_json_string(abuf, "gateway",
-                       olsr_ip_to_string(&mainaddrbuf, &olsr_cnf->main_addr));
-      abuf_json_close_array_entry(abuf);
-    }
-  }
-
-  /* HNA entries */
   OLSR_FOR_ALL_HNA_ENTRIES(tmp_hna) {
 
     /* Check all networks */
@@ -879,7 +854,8 @@ ipc_print_plugins(struct autobuf *abuf)
 static void
 ipc_print_config(struct autobuf *abuf)
 {
-  struct ipaddr_str mainaddrbuf;
+  struct ip_prefix_list *hna;
+  struct ipaddr_str buf, mainaddrbuf;
   struct ip_prefix_list *ipcn;
   struct olsr_lq_mult *mult;
   char ipv6_buf[INET6_ADDRSTRLEN];                  /* buffer for IPv6 inet_htop */
@@ -952,6 +928,18 @@ ipc_print_config(struct autobuf *abuf)
   }
   abuf_json_close_array(abuf);
 
+  abuf_json_open_array(abuf, "hna");
+  for (hna = olsr_cnf->hna_entries; hna != NULL; hna = hna->next) {
+    abuf_json_open_array_entry(abuf);
+    abuf_json_string(abuf, "destination",
+                     olsr_ip_to_string(&buf, &hna->net.prefix));
+    abuf_json_int(abuf, "genmask", hna->net.prefix_len);
+    abuf_json_string(abuf, "gateway",
+                     olsr_ip_to_string(&mainaddrbuf, &olsr_cnf->main_addr));
+    abuf_json_close_array_entry(abuf);
+  }
+  abuf_json_close_array(abuf);
+
   abuf_json_int(abuf, "totalIpcConnectionsAllowed", olsr_cnf->ipc_connections);
   abuf_json_open_array(abuf, "ipcAllowedAddresses");
   if (olsr_cnf->ipc_connections) {