static void bgp_show_bgp_path_info_flags(uint32_t flags, json_object *json)
{
json_object *json_flags = NULL;
+
if (!json)
return;
json_object_object_add(
json, (afi == AFI_IP) ? "ipv4" : "ipv6",
json_afi);
-
return;
}
{
struct bgp *bgp;
- if (name && strcmp(name, VRF_DEFAULT_NAME) != 0)
+ if (name && !strmatch(name, VRF_DEFAULT_NAME))
bgp = bgp_lookup_by_name(name);
else
bgp = bgp_get_default();
}
}
-DEFUN (show_ip_bgp_nexthop,
+#include "bgpd/bgp_nexthop_clippy.c"
+
+DEFPY (show_ip_bgp_nexthop,
show_ip_bgp_nexthop_cmd,
- "show [ip] bgp [<view|vrf> VIEWVRFNAME] nexthop [<A.B.C.D|X:X::X:X>] [detail] [json]",
+ "show [ip] bgp [<view|vrf> VIEWVRFNAME$vrf] nexthop [<A.B.C.D|X:X::X:X>$nhop] [<ipv4$afi [A.B.C.D$nhop]|ipv6$afi [X:X::X:X$nhop]>] [detail$detail] [json$uj]",
SHOW_STR
IP_STR
BGP_STR
"BGP nexthop table\n"
"IPv4 nexthop address\n"
"IPv6 nexthop address\n"
+ "BGP nexthop IPv4 table\n"
+ "IPv4 nexthop address\n"
+ "BGP nexthop IPv6 table\n"
+ "IPv6 nexthop address\n"
"Show detailed information\n"
JSON_STR)
{
int rc = 0;
- int idx = 0;
- int nh_idx = 0;
- char *vrf = NULL;
- char *nhop_ip = NULL;
json_object *json = NULL;
- bool uj = use_json(argc, argv);
- bool detail = false;
+ afi_t afiz = AFI_UNSPEC;
if (uj)
json = json_object_new_object();
- if (argv_find(argv, argc, "view", &idx)
- || argv_find(argv, argc, "vrf", &idx))
- vrf = argv[++idx]->arg;
-
- if (argv_find(argv, argc, "A.B.C.D", &nh_idx)
- || argv_find(argv, argc, "X:X::X:X", &nh_idx))
- nhop_ip = argv[nh_idx]->arg;
+ if (afi)
+ afiz = bgp_vty_afi_from_str(afi);
- if (argv_find(argv, argc, "detail", &idx))
- detail = true;
-
- rc = show_ip_bgp_nexthop_table(vty, vrf, nhop_ip, false, json,
- AFI_UNSPEC, detail);
+ rc = show_ip_bgp_nexthop_table(vty, vrf, nhop_str, false, json, afiz,
+ detail);
if (uj)
vty_json(vty, json);
+
return rc;
}
-DEFUN (show_ip_bgp_import_check,
+DEFPY (show_ip_bgp_import_check,
show_ip_bgp_import_check_cmd,
- "show [ip] bgp [<view|vrf> VIEWVRFNAME] import-check-table [detail] [json]",
+ "show [ip] bgp [<view|vrf> VIEWVRFNAME$vrf] import-check-table [detail$detail] [json$uj]",
SHOW_STR
IP_STR
BGP_STR
JSON_STR)
{
int rc = 0;
- int idx = 0;
- char *vrf = NULL;
json_object *json = NULL;
- bool uj = use_json(argc, argv);
- bool detail = false;
if (uj)
json = json_object_new_object();
- if (argv_find(argv, argc, "view", &idx)
- || argv_find(argv, argc, "vrf", &idx))
- vrf = argv[++idx]->arg;
-
- if (argv_find(argv, argc, "detail", &idx))
- detail = true;
-
rc = show_ip_bgp_nexthop_table(vty, vrf, NULL, true, json, AFI_UNSPEC,
detail);
if (uj)
vty_json(vty, json);
+
return rc;
}
-DEFUN (show_ip_bgp_instance_all_nexthop,
+DEFPY (show_ip_bgp_instance_all_nexthop,
show_ip_bgp_instance_all_nexthop_cmd,
- "show [ip] bgp <view|vrf> all nexthop [json]",
+ "show [ip] bgp <view|vrf> all nexthop [<ipv4|ipv6>$afi] [detail$detail] [json$uj]",
SHOW_STR
IP_STR
BGP_STR
BGP_INSTANCE_ALL_HELP_STR
"BGP nexthop table\n"
+ "BGP IPv4 nexthop table\n"
+ "BGP IPv6 nexthop table\n"
+ "Show detailed information\n"
JSON_STR)
{
json_object *json = NULL;
- bool uj = use_json(argc, argv);
- int idx = 0;
- afi_t afi = AFI_UNSPEC;
- bool detail = false;
+ afi_t afiz = AFI_UNSPEC;
if (uj)
json = json_object_new_object();
- argv_find_and_parse_afi(argv, argc, &idx, &afi);
-
- if (argv_find(argv, argc, "detail", &idx))
- detail = true;
+ if (afi)
+ afiz = bgp_vty_afi_from_str(afi);
- bgp_show_all_instances_nexthops_vty(vty, json, afi, detail);
+ bgp_show_all_instances_nexthops_vty(vty, json, afiz, detail);
if (uj)
vty_json(vty, json);
+
return CMD_SUCCESS;
}