/* Ethernet-VPN Packet and vty Processing File
- Copyright (C) 2017 6WIND
-
-This file is part of Free Range Routing
-
-Free Range Routing is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
-
-Free Range Routing is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Free Range Routing; see the file COPYING. If not, write to the Free
-Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA. */
+ * Copyright (C) 2017 6WIND
+ *
+ * This file is part of FRRouting
+ *
+ * FRRouting is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * FRRouting is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
#include <zebra.h>
#include "command.h"
struct bgp_info *ri;
int rd_header;
int header = 1;
- char v4_header[] =
- " Network Next Hop Metric LocPrf Weight Path%s";
- char v4_header_tag[] =
- " Network Next Hop In tag/Out tag%s";
- char v4_header_overlay[] =
- " Network Next Hop EthTag Overlay Index RouterMac%s";
unsigned long output_count = 0;
unsigned long total_count = 0;
bgp = bgp_get_default();
if (bgp == NULL) {
if (!use_json)
- vty_out(vty, "No BGP process is configured%s",
- VTY_NEWLINE);
+ vty_out (vty,"No BGP process is configured\n");
return CMD_WARNING;
}
} else {
if (option ==
SHOW_DISPLAY_TAGS)
- vty_out(vty,
- v4_header_tag,
- VTY_NEWLINE);
+ vty_out(vty, V4_HEADER_TAG);
else if (option ==
SHOW_DISPLAY_OVERLAY)
- vty_out(vty,
- v4_header_overlay,
- VTY_NEWLINE);
+ vty_out(vty, V4_HEADER_OVERLAY);
else {
- vty_out(vty,
- "BGP table version is 0, local router ID is %s%s",
- inet_ntoa
- (bgp->
- router_id),
- VTY_NEWLINE);
- vty_out(vty,
- "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s",
- VTY_NEWLINE);
- vty_out(vty,
- "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s",
- VTY_NEWLINE,
- VTY_NEWLINE);
- vty_out(vty,
- v4_header,
- VTY_NEWLINE);
+ vty_out (vty,
+ "BGP table version is 0, local router ID is %s\n",
+ inet_ntoa(bgp->router_id));
+ vty_out (vty,
+ "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal\n");
+ vty_out (vty,
+ "Origin codes: i - IGP, e - EGP, ? - incomplete%s\n",
+ VTYNL);
+ vty_out(vty, V4_HEADER);
}
}
header = 0;
ip),
rd_ip.
val);
- vty_out(vty, "%s",
- VTY_NEWLINE);
+ vty_out (vty, "\n\n");
}
rd_header = 0;
}
}
}
if (output_count == 0)
- vty_out(vty, "No prefixes displayed, %ld exist%s", total_count,
- VTY_NEWLINE);
+ vty_out (vty, "No prefixes displayed, %ld exist\n",
+ total_count);
else
- vty_out(vty, "%sDisplayed %ld out of %ld total prefixes%s",
- VTY_NEWLINE, output_count, total_count, VTY_NEWLINE);
+ vty_out (vty, "%sDisplayed %ld out of %ld total prefixes\n",
+ VTYNL, output_count, total_count);
return CMD_SUCCESS;
}
"Display information for a route distinguisher\n"
"VPN Route Distinguisher\n" JSON_STR)
{
- int idx_ext_community = 6;
+ int idx_ext_community = 0;
int ret;
struct prefix_rd prd;
+ argv_find (argv, argc, "ASN:nn_or_IP-address:nn", &idx_ext_community);
+
ret = str2prefix_rd(argv[idx_ext_community]->arg, &prd);
if (!ret) {
- vty_out(vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
+ vty_out (vty, "%% Malformed Route Distinguisher\n");
return CMD_WARNING;
}
return bgp_show_ethernet_vpn(vty, &prd, bgp_show_type_normal, NULL, 0,
"Display information for a route distinguisher\n"
"VPN Route Distinguisher\n" "Display BGP tags for prefixes\n")
{
- int idx_ext_community = 6;
+ int idx_ext_community = 0;
int ret;
struct prefix_rd prd;
+ argv_find (argv, argc, "ASN:nn_or_IP-address:nn", &idx_ext_community);
+
ret = str2prefix_rd(argv[idx_ext_community]->arg, &prd);
if (!ret) {
- vty_out(vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
+ vty_out (vty, "%% Malformed Route Distinguisher\n");
return CMD_WARNING;
}
return bgp_show_ethernet_vpn(vty, &prd, bgp_show_type_normal, NULL, 1,
"Neighbor to display information about\n"
"Display routes learned from neighbor\n" JSON_STR)
{
- int idx_ipv4 = 6;
+ int idx_ipv4 = 0;
union sockunion su;
struct peer *peer;
int ret;
u_char uj = use_json(argc, argv);
+ argv_find (argv, argc, "A.B.C.D", &idx_ipv4);
+
ret = str2sockunion(argv[idx_ipv4]->arg, &su);
if (ret < 0) {
if (uj) {
json_no = json_object_new_object();
json_object_string_add(json_no, "warning",
"Malformed address");
- vty_out(vty, "%s%s",
- json_object_to_json_string(json_no),
- VTY_NEWLINE);
+ vty_out (vty, "%s\n",
+ json_object_to_json_string(json_no));
json_object_free(json_no);
} else
- vty_out(vty, "Malformed address: %s%s",
- argv[idx_ipv4]->arg, VTY_NEWLINE);
+ vty_out (vty, "Malformed address: %s\n",
+ argv[idx_ipv4]->arg);
return CMD_WARNING;
}
json_no = json_object_new_object();
json_object_string_add(json_no, "warning",
"No such neighbor or address family");
- vty_out(vty, "%s%s",
- json_object_to_json_string(json_no),
- VTY_NEWLINE);
+ vty_out (vty, "%s\n",
+ json_object_to_json_string(json_no));
json_object_free(json_no);
} else
- vty_out(vty, "%% No such neighbor or address family%s",
- VTY_NEWLINE);
+ vty_out (vty,
+ "%% No such neighbor or address family\n");
return CMD_WARNING;
}
"Neighbor to display information about\n"
"Display routes learned from neighbor\n" JSON_STR)
{
- int idx_ext_community = 6;
- int idx_ipv4 = 8;
+ int idx_ext_community = 0;
+ int idx_ipv4 = 0;
int ret;
union sockunion su;
struct peer *peer;
struct prefix_rd prd;
u_char uj = use_json(argc, argv);
+ argv_find (argv, argc, "ASN:nn_or_IP-address:nn", &idx_ext_community);
+ argv_find (argv, argc, "A.B.C.D", &idx_ipv4);
+
ret = str2prefix_rd(argv[idx_ext_community]->arg, &prd);
if (!ret) {
if (uj) {
json_no = json_object_new_object();
json_object_string_add(json_no, "warning",
"Malformed Route Distinguisher");
- vty_out(vty, "%s%s",
- json_object_to_json_string(json_no),
- VTY_NEWLINE);
+ vty_out (vty, "%s\n",
+ json_object_to_json_string(json_no));
json_object_free(json_no);
} else
- vty_out(vty, "%% Malformed Route Distinguisher%s",
- VTY_NEWLINE);
+ vty_out (vty,"%% Malformed Route Distinguisher\n");
return CMD_WARNING;
}
json_no = json_object_new_object();
json_object_string_add(json_no, "warning",
"Malformed address");
- vty_out(vty, "%s%s",
- json_object_to_json_string(json_no),
- VTY_NEWLINE);
+ vty_out (vty, "%s\n",
+ json_object_to_json_string(json_no));
json_object_free(json_no);
} else
- vty_out(vty, "Malformed address: %s%s",
- argv[idx_ext_community]->arg, VTY_NEWLINE);
+ vty_out (vty, "Malformed address: %s\n",
+ argv[idx_ext_community]->arg);
return CMD_WARNING;
}
json_no = json_object_new_object();
json_object_string_add(json_no, "warning",
"No such neighbor or address family");
- vty_out(vty, "%s%s",
- json_object_to_json_string(json_no),
- VTY_NEWLINE);
+ vty_out (vty, "%s\n",
+ json_object_to_json_string(json_no));
json_object_free(json_no);
} else
- vty_out(vty, "%% No such neighbor or address family%s",
- VTY_NEWLINE);
+ vty_out (vty,
+ "%% No such neighbor or address family\n");
return CMD_WARNING;
}
"Neighbor to display information about\n"
"Display the routes advertised to a BGP neighbor\n" JSON_STR)
{
- int idx_ipv4 = 7;
+ int idx_ipv4 = 0;
int ret;
struct peer *peer;
union sockunion su;
u_char uj = use_json(argc, argv);
+ argv_find (argv, argc, "A.B.C.D", &idx_ipv4);
+
ret = str2sockunion(argv[idx_ipv4]->arg, &su);
if (ret < 0) {
if (uj) {
json_no = json_object_new_object();
json_object_string_add(json_no, "warning",
"Malformed address");
- vty_out(vty, "%s%s",
- json_object_to_json_string(json_no),
- VTY_NEWLINE);
+ vty_out (vty, "%s\n",
+ json_object_to_json_string(json_no));
json_object_free(json_no);
} else
- vty_out(vty, "Malformed address: %s%s",
- argv[idx_ipv4]->arg, VTY_NEWLINE);
+ vty_out (vty, "Malformed address: %s\n",
+ argv[idx_ipv4]->arg);
return CMD_WARNING;
}
peer = peer_lookup(NULL, &su);
json_no = json_object_new_object();
json_object_string_add(json_no, "warning",
"No such neighbor or address family");
- vty_out(vty, "%s%s",
- json_object_to_json_string(json_no),
- VTY_NEWLINE);
+ vty_out (vty, "%s\n",
+ json_object_to_json_string(json_no));
json_object_free(json_no);
} else
- vty_out(vty, "%% No such neighbor or address family%s",
- VTY_NEWLINE);
+ vty_out (vty,
+ "%% No such neighbor or address family\n");
return CMD_WARNING;
}
"Neighbor to display information about\n"
"Display the routes advertised to a BGP neighbor\n" JSON_STR)
{
- int idx_ext_community = 6;
- int idx_ipv4 = 8;
+ int idx_ext_community = 0;
+ int idx_ipv4 = 0;
int ret;
struct peer *peer;
struct prefix_rd prd;
union sockunion su;
u_char uj = use_json(argc, argv);
+ argv_find (argv, argc, "ASN:nn_or_IP-address:nn", &idx_ext_community);
+ argv_find (argv, argc, "A.B.C.D", &idx_ipv4);
+
ret = str2sockunion(argv[idx_ipv4]->arg, &su);
if (ret < 0) {
if (uj) {
json_no = json_object_new_object();
json_object_string_add(json_no, "warning",
"Malformed address");
- vty_out(vty, "%s%s",
- json_object_to_json_string(json_no),
- VTY_NEWLINE);
+ vty_out (vty, "%s\n",
+ json_object_to_json_string(json_no));
json_object_free(json_no);
} else
- vty_out(vty, "Malformed address: %s%s",
- argv[idx_ext_community]->arg, VTY_NEWLINE);
+ vty_out (vty, "Malformed address: %s\n",
+ argv[idx_ext_community]->arg);
return CMD_WARNING;
}
peer = peer_lookup(NULL, &su);
json_no = json_object_new_object();
json_object_string_add(json_no, "warning",
"No such neighbor or address family");
- vty_out(vty, "%s%s",
- json_object_to_json_string(json_no),
- VTY_NEWLINE);
+ vty_out (vty, "%s\n",
+ json_object_to_json_string(json_no));
json_object_free(json_no);
} else
- vty_out(vty, "%% No such neighbor or address family%s",
- VTY_NEWLINE);
+ vty_out (vty,
+ "%% No such neighbor or address family\n");
return CMD_WARNING;
}
json_no = json_object_new_object();
json_object_string_add(json_no, "warning",
"Malformed Route Distinguisher");
- vty_out(vty, "%s%s",
- json_object_to_json_string(json_no),
- VTY_NEWLINE);
+ vty_out (vty, "%s\n",
+ json_object_to_json_string(json_no));
json_object_free(json_no);
} else
- vty_out(vty, "%% Malformed Route Distinguisher%s",
- VTY_NEWLINE);
+ vty_out (vty,"%% Malformed Route Distinguisher\n");
return CMD_WARNING;
}
"VPN Route Distinguisher\n"
"Display BGP Overlay Information for prefixes\n")
{
- int idx_ext_community = 6;
+ int idx_ext_community = 0;
int ret;
struct prefix_rd prd;
+ argv_find (argv, argc, "ASN:nn_or_IP-address:nn", &idx_ext_community);
+
ret = str2prefix_rd(argv[idx_ext_community]->arg, &prd);
if (!ret) {
- vty_out(vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
+ vty_out (vty, "%% Malformed Route Distinguisher\n");
return CMD_WARNING;
}
return bgp_show_ethernet_vpn(vty, &prd, bgp_show_type_normal, NULL,
"Gateway IP ( A.B.C.D )\n"
"Gateway IPv6 ( X:X::X:X )\n"
"Router Mac Ext Comm\n"
- "Router Mac address Value ( aa:bb:cc:dd:ee:ff format)\n")
+ "Router Mac address Value ( aa:bb:cc:dd:ee:ff format)\n"
+ "Route-map to modify the attributes\n"
+ "Name of the route map\n")
{
int idx_ipv4_prefixlen = 1;
int idx_ext_community = 3;
int idx_ethtag = 5;
int idx_routermac = 13;
int idx_rmap = 15;
- return bgp_static_set_safi(SAFI_EVPN, vty,
+ return bgp_static_set_safi(AFI_L2VPN, SAFI_EVPN, vty,
argv[idx_ipv4_prefixlen]->arg,
argv[idx_ext_community]->arg,
argv[idx_word]->arg,
int idx_ethtag = 6;
int idx_esi = 10;
int idx_gwip = 12;
- return bgp_static_unset_safi(SAFI_EVPN, vty,
+ return bgp_static_unset_safi(AFI_L2VPN, SAFI_EVPN, vty,
argv[idx_ipv4_prefixlen]->arg,
argv[idx_ext_community]->arg,
argv[idx_label]->arg, EVPN_IP_PREFIX,