]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/plist.c
Merge pull request #10110 from idryzhov/if-yang-remove-vrf
[mirror_frr.git] / lib / plist.c
index 2f9f06f43b707ee8cb78fb0491f834fc88113905..046ccadc0998a794730d769516b3c970d6f1a500 100644 (file)
@@ -1010,7 +1010,6 @@ static void vty_show_prefix_entry(struct vty *vty, json_object *json, afi_t afi,
 
                        if (json) {
                                json_object *json_entry;
-                               char buf[BUFSIZ];
 
                                json_entry = json_object_new_object();
                                json_object_array_add(json_entries, json_entry);
@@ -1021,10 +1020,9 @@ static void vty_show_prefix_entry(struct vty *vty, json_object *json, afi_t afi,
                                json_object_string_add(
                                        json_entry, "type",
                                        prefix_list_type_str(pentry));
-                               json_object_string_add(
-                                       json_entry, "prefix",
-                                       prefix2str(&pentry->prefix, buf,
-                                                  sizeof(buf)));
+                               json_object_string_addf(json_entry, "prefix",
+                                                       "%pFX",
+                                                       &pentry->prefix);
 
                                if (pentry->ge)
                                        json_object_int_add(
@@ -1127,14 +1125,7 @@ static int vty_show_prefix_list(struct vty *vty, afi_t afi, const char *name,
                                              master, dtype, seqnum);
        }
 
-       if (uj) {
-               vty_out(vty, "%s\n",
-                       json_object_to_json_string_ext(
-                               json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
-       }
-
-       return CMD_SUCCESS;
+       return vty_json(vty, json);
 }
 
 static int vty_show_prefix_list_prefix(struct vty *vty, afi_t afi,
@@ -1592,9 +1583,7 @@ int prefix_bgp_show_prefix_list(struct vty *vty, afi_t afi, char *name,
                        json_object_object_add(json, "ipv6PrefixList",
                                               json_prefix);
 
-               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, "ip%s prefix-list %s: %d entries\n",
                        afi == AFI_IP ? "" : "v6", plist->name, plist->count);
@@ -1668,6 +1657,8 @@ static const struct cmd_variable_handler plist_var_handlers[] = {
        {/* "prefix-list WORD" */
         .varname = "prefix_list",
         .completions = plist_autocomplete},
+       {.tokenname = "PREFIXLIST_NAME",
+        .completions = plist_autocomplete},
        {.completions = NULL}};