"Display route and more specific routes\n"
JSON_STR)
{
- vrf_id_t vrf = VRF_DEFAULT;
afi_t afi = AFI_IP6;
safi_t safi = SAFI_UNICAST;
int exact_match = 0;
struct bgp *bgp = NULL;
int idx = 0;
- bgp_vty_find_and_parse_afi_safi_vrf (vty, argv, argc, &idx, &afi, &safi, &vrf);
+ bgp_vty_find_and_parse_afi_safi_bgp (vty, argv, argc, &idx, &afi, &safi, &bgp);
if (!idx)
return CMD_WARNING;
int uj = use_json (argc, argv);
if (uj) argc--;
- bgp = bgp_lookup_by_vrf_id (vrf);
- if (bgp == NULL)
- {
- if (vrf == VRF_DEFAULT)
- vty_out (vty, "Can't find BGP instance (default)%s", VTY_NEWLINE);
- else
- vty_out (vty, "Can't find BGP instance %d%s", vrf, VTY_NEWLINE);
- return CMD_WARNING;
- }
-
if (argv_find(argv, argc, "cidr-only", &idx))
return bgp_show (vty, bgp, afi, safi, bgp_show_type_cidr_only, NULL, uj);
afi_t afi = AFI_IP6;
safi_t safi = SAFI_UNICAST;
- vrf_id_t vrf = VRF_DEFAULT;;
+ // vrf_id_t vrf = VRF_DEFAULT;;
char *prefix = NULL;
struct bgp *bgp = NULL;
enum bgp_path_type path_type;
int idx = 0;
- bgp_vty_find_and_parse_afi_safi_vrf (vty, argv, argc, &idx, &afi, &safi, &vrf);
+ bgp_vty_find_and_parse_afi_safi_bgp (vty, argv, argc, &idx, &afi, &safi, &bgp);
if (!idx)
return CMD_WARNING;
- if (vrf != VRF_ALL)
- {
- bgp = bgp_lookup_by_vrf_id (vrf);
- if (bgp == NULL)
- {
- vty_out (vty, "Can't find BGP instance %s%s", argv[5]->arg, VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- else
+ if (!bgp)
{
vty_out (vty, "Specified 'all' vrf's but this command currently only works per view/vrf%s", VTY_NEWLINE);
return CMD_WARNING;
"Display routes matching the AS path regular expression\n"
"A regular-expression to match the BGP AS paths\n")
{
- vrf_id_t vrf = VRF_DEFAULT;
afi_t afi = AFI_IP6;
safi_t safi = SAFI_UNICAST;
+ struct bgp *bgp = NULL;
int idx = 0;
- bgp_vty_find_and_parse_afi_safi_vrf (vty, argv, argc, &idx, &afi, &safi, &vrf);
+ bgp_vty_find_and_parse_afi_safi_bgp (vty, argv, argc, &idx, &afi, &safi, &bgp);
if (!idx)
return CMD_WARNING;
BGP_SAFI_HELP_STR
JSON_STR)
{
- vrf_id_t vrf = VRF_DEFAULT;
afi_t afi = AFI_IP;
safi_t safi = SAFI_UNICAST;
+ struct bgp *bgp = NULL;
int idx = 0;
- bgp_vty_find_and_parse_afi_safi_vrf (vty, argv, argc, &idx, &afi, &safi, &vrf);
+ bgp_vty_find_and_parse_afi_safi_bgp (vty, argv, argc, &idx, &afi, &safi, &bgp);
if (!idx)
return CMD_WARNING;
"Display detailed prefix count information\n"
JSON_STR)
{
- vrf_id_t vrf = VRF_DEFAULT;
afi_t afi = AFI_IP6;
safi_t safi = SAFI_UNICAST;
struct peer *peer;
int idx = 0;
struct bgp *bgp = NULL;
- bgp_vty_find_and_parse_afi_safi_vrf (vty, argv, argc, &idx, &afi, &safi, &vrf);
+ bgp_vty_find_and_parse_afi_safi_bgp (vty, argv, argc, &idx, &afi, &safi, &bgp);
if (!idx)
return CMD_WARNING;
int uj = use_json (argc, argv);
if (uj) argc--;
- if (vrf != VRF_ALL)
- {
- bgp = bgp_lookup_by_vrf_id (vrf);
- if (bgp == NULL)
- {
- if (uj)
- {
- json_object *json_no = NULL;
- json_no = json_object_new_object();
- json_object_string_add(json_no, "warning", "Can't find BGP view");
- vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE);
- json_object_free(json_no);
- }
- else
- vty_out (vty, "Can't find BGP instance %s%s", argv[5]->arg, VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- else
- bgp = NULL;
-
argv_find (argv, argc, "neighbors", &idx);
peer = peer_lookup_in_view (vty, bgp, argv[idx+1]->arg, uj);
if (! peer)
"Name of the route map\n"
JSON_STR)
{
- vrf_id_t vrf = VRF_DEFAULT;
afi_t afi = AFI_IP6;
safi_t safi = SAFI_UNICAST;
char *rmap_name = NULL;
int idx = 0;
- bgp_vty_find_and_parse_afi_safi_vrf (vty, argv, argc, &idx, &afi, &safi, &vrf);
+ bgp_vty_find_and_parse_afi_safi_bgp (vty, argv, argc, &idx, &afi, &safi, &bgp);
if (!idx)
return CMD_WARNING;
int uj = use_json (argc, argv);
if (uj) argc--;
- bgp = bgp_lookup_by_vrf_id (vrf);
- if (bgp == NULL)
- {
- if (uj)
- {
- json_object *json_no = NULL;
- json_no = json_object_new_object();
- json_object_string_add(json_no, "warning", "Can't find BGP view");
- vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE);
- json_object_free(json_no);
- }
- else
- vty_out (vty, "Can't find BGP instance %s%s", argv[5]->arg, VTY_NEWLINE);
- return CMD_WARNING;
- }
-
/* neighbors <A.B.C.D|X:X::X:X|WORD> */
argv_find (argv, argc, "neighbors", &idx);
peerstr = argv[++idx]->arg;
"Display routes learned from neighbor\n"
JSON_STR)
{
- vrf_id_t vrf = VRF_DEFAULT;
char *peerstr = NULL;
struct bgp *bgp = NULL;
afi_t afi = AFI_IP6;
int idx = 0;
- bgp_vty_find_and_parse_afi_safi_vrf (vty, argv, argc, &idx, &afi, &safi, &vrf);
+ bgp_vty_find_and_parse_afi_safi_bgp (vty, argv, argc, &idx, &afi, &safi, &bgp);
if (!idx)
return CMD_WARNING;
int uj = use_json (argc, argv);
if (uj) argc--;
- if (vrf != VRF_ALL)
- {
- bgp = bgp_lookup_by_vrf_id (vrf);
- if (bgp == NULL)
- {
- if (uj)
- {
- json_object *json_no = NULL;
- json_no = json_object_new_object();
- json_object_string_add(json_no, "warning", "Can't find BGP view");
- vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE);
- json_object_free(json_no);
- }
- else
- vty_out (vty, "Can't find BGP instance %s%s", argv[5]->arg, VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- else
- bgp = NULL;
-
/* neighbors <A.B.C.D|X:X::X:X|WORD> */
argv_find (argv, argc, "neighbors", &idx);
peerstr = argv[++idx]->arg;
}
/*
- * bgp_vty_find_and_parse_afi_safi_vrf
+ * bgp_vty_find_and_parse_afi_safi_bgp
*
- * For a given 'show ...' command, correctly parse the afi/safi/vrf out from it
- * This function *assumes* that the calling function pre-sets the afi/safi/vrf
+ * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
+ * This function *assumes* that the calling function pre-sets the afi/safi/bgp
* to appropriate values for the calling function. This is to allow the
* calling function to make decisions appropriate for the show command
* that is being parsed.
* idx -> The current place in the command, generally should be 0 for this function
* afi -> The parsed afi if it was included in the show command, returned here
* safi -> The parsed safi if it was included in the show command, returned here
- * vrf -> The parsed vrf id if it was included in the show command, returned here
+ * bgp -> Pointer to the bgp data structure we need to fill in.
*
* The function returns the correct location in the parse tree for the
* last token found.
* it found the last token.
*/
int
-bgp_vty_find_and_parse_afi_safi_vrf (struct vty *vty, struct cmd_token **argv, int argc, int *idx,
- afi_t *afi, safi_t *safi, vrf_id_t *vrf)
+bgp_vty_find_and_parse_afi_safi_bgp (struct vty *vty, struct cmd_token **argv, int argc, int *idx,
+ afi_t *afi, safi_t *safi, struct bgp **bgp)
{
char *vrf_name = NULL;
assert (afi);
assert (safi);
- assert (vrf && *vrf != VRF_UNKNOWN);
+ assert (bgp);
if (argv_find (argv, argc, "ip", idx))
*afi = AFI_IP;
{
vrf_name = argv[*idx + 1]->arg;
*idx += 2;
- }
-
- if (argv_find_and_parse_afi (argv, argc, idx, afi))
- argv_find_and_parse_safi (argv, argc, idx, safi);
- if (vrf_name)
- {
- if (strmatch(vrf_name, "all"))
- *vrf = VRF_ALL;
+ if (strmatch (vrf_name, "all"))
+ *bgp = NULL;
else
- *vrf = vrf_name_to_id (vrf_name);
+ {
+ *bgp = bgp_lookup_by_name (vrf_name);
+ if (!*bgp)
+ {
+ vty_out (vty, "View/Vrf specified is unknown: %s%s", vrf_name, VTY_NEWLINE);
+ *idx = 0;
+ return 0;
+ }
+ }
}
-
- if (*vrf == VRF_UNKNOWN)
+ else
{
- vty_out (vty, "View/Vrf specified is unknown: %s", vrf_name);
- *idx = 0;
- return 0;
+ *bgp = bgp_get_default ();
+ if (!*bgp)
+ {
+ vty_out (vty, "Unable to find default BGP instance%s", VTY_NEWLINE);
+ *idx = 0;
+ return 0;
+ }
}
+ if (argv_find_and_parse_afi (argv, argc, idx, afi))
+ argv_find_and_parse_safi (argv, argc, idx, safi);
+
*idx += 1;
return *idx;
}