jsoninfo: use the new ip address helper in /sgw printing
authorFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 3 Dec 2015 10:34:34 +0000 (11:34 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 3 Dec 2015 12:24:48 +0000 (13:24 +0100)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/jsoninfo/src/olsrd_jsoninfo.c

index 67f163d..e344071 100644 (file)
@@ -447,14 +447,9 @@ static void sgw_ipvx(struct autobuf *abuf, bool ipv6) {
       {
         struct tc_entry* tc = olsr_lookup_tc_entry(&gw->originator);
 
-        struct ipaddr_str originatorStr;
-        const char * originator = olsr_ip_to_string(&originatorStr, &gw->originator);
-        struct ipaddr_str prefixIpStr;
-        const char * prefix = olsr_ip_to_string(&prefixIpStr, &gw->external_prefix.prefix);
-
         abuf_json_boolean(abuf, "selected", current_gw && (current_gw == gw));
-        abuf_json_string(abuf, "originator", originator);
-        abuf_json_string(abuf, "prefix", prefix);
+        abuf_json_ip_address(abuf, "originator", &gw->originator);
+        abuf_json_ip_address(abuf, "prefix", &gw->external_prefix.prefix);
         abuf_json_int(abuf, "prefixLen", gw->external_prefix.prefix_len);
         abuf_json_int(abuf, "uplink", gw->uplink);
         abuf_json_int(abuf, "downlink", gw->downlink);
@@ -463,7 +458,7 @@ static void sgw_ipvx(struct autobuf *abuf, bool ipv6) {
         abuf_json_boolean(abuf, "IPv4-NAT", gw->ipv4nat);
         abuf_json_boolean(abuf, "IPv6", gw->ipv6);
         abuf_json_string(abuf, "tunnel", node->name);
-        abuf_json_string(abuf, "destination", originator);
+        abuf_json_ip_address(abuf, "destination", &gw->originator);
         abuf_json_int(abuf, "cost", gw->path_cost);
         abuf_json_int(abuf, "tableNr", node->tableNr);
         abuf_json_int(abuf, "ruleNr", node->ruleNr);