summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas.abraitis@gmail.com>2021-11-25 17:50:37 +0200
committerDonatas Abraitis <donatas.abraitis@gmail.com>2021-11-25 17:50:37 +0200
commit5a6c232bf83f10a490890b3db8f01f44eee8aa9a (patch)
tree9f939974e1828d4d3be851a87c655caf90e229e7
parent92ef0078787337fbb7be53f9d39ece6ee06c5148 (diff)
ospf6d: Convert vty_out to vty_json for JSON
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
-rw-r--r--ospf6d/ospf6_area.c5
-rw-r--r--ospf6d/ospf6_asbr.c5
-rw-r--r--ospf6d/ospf6_gr_helper.c5
-rw-r--r--ospf6d/ospf6_interface.c25
-rw-r--r--ospf6d/ospf6_neighbor.c10
-rw-r--r--ospf6d/ospf6_route.c15
-rw-r--r--ospf6d/ospf6_top.c9
-rw-r--r--ospf6d/ospf6d.c10
8 files changed, 17 insertions, 67 deletions
diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c
index f35971ba8c..4f3c3e3203 100644
--- a/ospf6d/ospf6_area.c
+++ b/ospf6d/ospf6_area.c
@@ -1046,10 +1046,7 @@ static int ipv6_ospf6_spf_tree_common(struct vty *vty, struct ospf6 *ospf6,
}
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
}
return CMD_SUCCESS;
diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c
index cba455cff0..99f30a4a06 100644
--- a/ospf6d/ospf6_asbr.c
+++ b/ospf6d/ospf6_asbr.c
@@ -2545,10 +2545,7 @@ DEFUN(show_ipv6_ospf6_redistribute, show_ipv6_ospf6_redistribute_cmd,
if (uj) {
json_object_object_add(json, "routes",
json_array_routes);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
}
if (!all_vrf)
diff --git a/ospf6d/ospf6_gr_helper.c b/ospf6d/ospf6_gr_helper.c
index 4dc2d8af83..9f6661913f 100644
--- a/ospf6d/ospf6_gr_helper.c
+++ b/ospf6d/ospf6_gr_helper.c
@@ -1189,10 +1189,7 @@ DEFPY(show_ipv6_ospf6_gr_helper,
show_ospf6_gr_helper_details(vty, ospf6, json, uj, detail);
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
}
return CMD_SUCCESS;
diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c
index 487ecc4072..be5a7bb837 100644
--- a/ospf6d/ospf6_interface.c
+++ b/ospf6d/ospf6_interface.c
@@ -1277,10 +1277,7 @@ static int show_ospf6_interface_common(struct vty *vty, vrf_id_t vrf_id,
if (ifp == NULL) {
json_object_string_add(json, "noSuchInterface",
argv[idx_ifname]->arg);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
json_object_free(json_int);
return CMD_WARNING;
}
@@ -1294,10 +1291,7 @@ static int show_ospf6_interface_common(struct vty *vty, vrf_id_t vrf_id,
json_int);
}
}
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
} else {
if (argc == intf_idx) {
ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf_id);
@@ -1484,10 +1478,7 @@ static int ospf6_interface_show_traffic_common(struct vty *vty, int argc,
"No Such Interface");
json_object_string_add(json, "interface",
intf_name);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
return CMD_WARNING;
}
if (ifp->info == NULL) {
@@ -1496,10 +1487,7 @@ static int ospf6_interface_show_traffic_common(struct vty *vty, int argc,
"OSPF not enabled on this interface");
json_object_string_add(json, "interface",
intf_name);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
return 0;
}
} else {
@@ -1520,10 +1508,7 @@ static int ospf6_interface_show_traffic_common(struct vty *vty, int argc,
ospf6_interface_show_traffic(vty, ifp, display_once, json, uj, vrf_id);
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
}
return CMD_SUCCESS;
diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c
index 8ec916dba8..ad33c57db5 100644
--- a/ospf6d/ospf6_neighbor.c
+++ b/ospf6d/ospf6_neighbor.c
@@ -1073,10 +1073,7 @@ static void ospf6_neighbor_show_detail_common(struct vty *vty,
json_object_object_add(json, "neighbors", json_array);
else
json_object_free(json_array);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
}
}
@@ -1149,10 +1146,7 @@ static int ospf6_neighbor_show_common(struct vty *vty, int argc,
}
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
}
return CMD_SUCCESS;
diff --git a/ospf6d/ospf6_route.c b/ospf6d/ospf6_route.c
index 92fcbf71e8..880987b3f3 100644
--- a/ospf6d/ospf6_route.c
+++ b/ospf6d/ospf6_route.c
@@ -1611,10 +1611,7 @@ int ospf6_route_table_show(struct vty *vty, int argc_start, int argc,
if (summary) {
ospf6_route_show_table_summary(vty, table, json, use_json);
if (use_json) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
}
return CMD_SUCCESS;
}
@@ -1630,10 +1627,7 @@ int ospf6_route_table_show(struct vty *vty, int argc_start, int argc,
use_json);
if (use_json) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
}
return CMD_SUCCESS;
}
@@ -1648,10 +1642,7 @@ int ospf6_route_table_show(struct vty *vty, int argc_start, int argc,
ospf6_route_show_table(vty, detail, table, json, use_json);
if (use_json) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
}
return CMD_SUCCESS;
}
diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c
index d0540699fe..66313c1fbb 100644
--- a/ospf6d/ospf6_top.c
+++ b/ospf6d/ospf6_top.c
@@ -1496,10 +1496,7 @@ DEFUN(show_ipv6_ospf6_vrfs, show_ipv6_ospf6_vrfs_cmd,
json_object_object_add(json, "vrfs", json_vrfs);
json_object_int_add(json, "totalVrfs", count);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
} else {
if (count)
vty_out(vty, "\nTotal number of OSPF VRFs: %d\n",
@@ -2091,9 +2088,7 @@ DEFPY (show_ipv6_ospf6_external_aggregator,
}
if (uj) {
- vty_out(vty, "%s\n", json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
}
return CMD_SUCCESS;
diff --git a/ospf6d/ospf6d.c b/ospf6d/ospf6d.c
index 5e6dcde991..840c4c0848 100644
--- a/ospf6d/ospf6d.c
+++ b/ospf6d/ospf6d.c
@@ -292,10 +292,7 @@ static void ospf6_lsdb_show_wrapper(struct vty *vty,
json_object_array_add(json_array, json_obj);
json_object_object_add(json, "asScopedLinkStateDb", json_array);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
} else
vty_out(vty, "\n");
}
@@ -387,10 +384,7 @@ static void ospf6_lsdb_type_show_wrapper(struct vty *vty,
break;
}
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
} else
vty_out(vty, "\n");
}