]> git.proxmox.com Git - mirror_frr.git/blame - bgpd/bgp_vty.c
BGP: Trigger IPv6 router advertisements upon config of unnumbered neighbor
[mirror_frr.git] / bgpd / bgp_vty.c
CommitLineData
718e3744 1/* BGP VTY interface.
2 Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
3
4This file is part of GNU Zebra.
5
6GNU Zebra is free software; you can redistribute it and/or modify it
7under the terms of the GNU General Public License as published by the
8Free Software Foundation; either version 2, or (at your option) any
9later version.
10
11GNU Zebra is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Zebra; see the file COPYING. If not, write to the Free
18Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1902111-1307, USA. */
20
21#include <zebra.h>
22
856ca177 23#include "lib/json.h"
718e3744 24#include "command.h"
25#include "prefix.h"
26#include "plist.h"
27#include "buffer.h"
28#include "linklist.h"
29#include "stream.h"
30#include "thread.h"
31#include "log.h"
3b8b1855 32#include "memory.h"
4bf6a362 33#include "hash.h"
3f9c7369 34#include "queue.h"
718e3744 35
36#include "bgpd/bgpd.h"
4bf6a362 37#include "bgpd/bgp_advertise.h"
718e3744 38#include "bgpd/bgp_attr.h"
39#include "bgpd/bgp_aspath.h"
40#include "bgpd/bgp_community.h"
4bf6a362
PJ
41#include "bgpd/bgp_ecommunity.h"
42#include "bgpd/bgp_damp.h"
718e3744 43#include "bgpd/bgp_debug.h"
e0701b79 44#include "bgpd/bgp_fsm.h"
718e3744 45#include "bgpd/bgp_mplsvpn.h"
4bf6a362 46#include "bgpd/bgp_nexthop.h"
718e3744 47#include "bgpd/bgp_open.h"
4bf6a362 48#include "bgpd/bgp_regex.h"
718e3744 49#include "bgpd/bgp_route.h"
50#include "bgpd/bgp_zebra.h"
fee0f4c6 51#include "bgpd/bgp_table.h"
94f2b392 52#include "bgpd/bgp_vty.h"
165b5fff 53#include "bgpd/bgp_mpath.h"
cb1faec9 54#include "bgpd/bgp_packet.h"
3f9c7369 55#include "bgpd/bgp_updgrp.h"
c43ed2e4 56#include "bgpd/bgp_bfd.h"
718e3744 57
20eb8864 58static struct peer_group *
59listen_range_exists (struct bgp *bgp, struct prefix *range, int exact);
60
718e3744 61/* Utility function to get address family from current node. */
62afi_t
63bgp_node_afi (struct vty *vty)
64{
25ffbdc1 65 if (vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE)
718e3744 66 return AFI_IP6;
67 return AFI_IP;
68}
69
70/* Utility function to get subsequent address family from current
71 node. */
72safi_t
73bgp_node_safi (struct vty *vty)
74{
75 if (vty->node == BGP_VPNV4_NODE)
76 return SAFI_MPLS_VPN;
25ffbdc1 77 if (vty->node == BGP_IPV4M_NODE || vty->node == BGP_IPV6M_NODE)
718e3744 78 return SAFI_MULTICAST;
79 return SAFI_UNICAST;
80}
81
94f2b392 82static int
6aeb9e78 83peer_address_self_check (struct bgp *bgp, union sockunion *su)
718e3744 84{
85 struct interface *ifp = NULL;
86
87 if (su->sa.sa_family == AF_INET)
6aeb9e78 88 ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr, bgp->vrf_id);
718e3744 89#ifdef HAVE_IPV6
90 else if (su->sa.sa_family == AF_INET6)
f2345335 91 ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr,
6aeb9e78 92 su->sin6.sin6_scope_id, bgp->vrf_id);
718e3744 93#endif /* HAVE IPV6 */
94
95 if (ifp)
96 return 1;
97
98 return 0;
99}
100
101/* Utility function for looking up peer from VTY. */
f14e6fdb
DS
102/* This is used only for configuration, so disallow if attempted on
103 * a dynamic neighbor.
104 */
94f2b392 105static struct peer *
fd79ac91 106peer_lookup_vty (struct vty *vty, const char *ip_str)
718e3744 107{
108 int ret;
109 struct bgp *bgp;
110 union sockunion su;
111 struct peer *peer;
112
113 bgp = vty->index;
114
115 ret = str2sockunion (ip_str, &su);
116 if (ret < 0)
117 {
a80beece
DS
118 peer = peer_lookup_by_conf_if (bgp, ip_str);
119 if (!peer)
120 {
04b6bdc0
DW
121 if ((peer = peer_lookup_by_hostname(bgp, ip_str)) == NULL)
122 {
123 vty_out (vty, "%% Malformed address or name: %s%s", ip_str, VTY_NEWLINE);
124 return NULL;
125 }
a80beece 126 }
718e3744 127 }
a80beece 128 else
718e3744 129 {
a80beece
DS
130 peer = peer_lookup (bgp, &su);
131 if (! peer)
132 {
133 vty_out (vty, "%% Specify remote-as or peer-group commands first%s",
134 VTY_NEWLINE);
135 return NULL;
136 }
f14e6fdb
DS
137 if (peer_dynamic_neighbor (peer))
138 {
139 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
140 VTY_NEWLINE);
141 return NULL;
142 }
143
718e3744 144 }
145 return peer;
146}
147
148/* Utility function for looking up peer or peer group. */
f14e6fdb
DS
149/* This is used only for configuration, so disallow if attempted on
150 * a dynamic neighbor.
151 */
c43ed2e4 152struct peer *
fd79ac91 153peer_and_group_lookup_vty (struct vty *vty, const char *peer_str)
718e3744 154{
155 int ret;
156 struct bgp *bgp;
157 union sockunion su;
f14e6fdb
DS
158 struct peer *peer = NULL;
159 struct peer_group *group = NULL;
718e3744 160
161 bgp = vty->index;
162
163 ret = str2sockunion (peer_str, &su);
164 if (ret == 0)
165 {
f14e6fdb 166 /* IP address, locate peer. */
718e3744 167 peer = peer_lookup (bgp, &su);
718e3744 168 }
169 else
170 {
f14e6fdb 171 /* Not IP, could match either peer configured on interface or a group. */
a80beece 172 peer = peer_lookup_by_conf_if (bgp, peer_str);
f14e6fdb
DS
173 if (!peer)
174 group = peer_group_lookup (bgp, peer_str);
175 }
a80beece 176
f14e6fdb
DS
177 if (peer)
178 {
179 if (peer_dynamic_neighbor (peer))
180 {
181 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
182 VTY_NEWLINE);
183 return NULL;
184 }
185
186 return peer;
718e3744 187 }
188
f14e6fdb
DS
189 if (group)
190 return group->conf;
191
718e3744 192 vty_out (vty, "%% Specify remote-as or peer-group commands first%s",
193 VTY_NEWLINE);
194
195 return NULL;
196}
197
c43ed2e4 198int
718e3744 199bgp_vty_return (struct vty *vty, int ret)
200{
fd79ac91 201 const char *str = NULL;
718e3744 202
203 switch (ret)
204 {
205 case BGP_ERR_INVALID_VALUE:
206 str = "Invalid value";
207 break;
208 case BGP_ERR_INVALID_FLAG:
209 str = "Invalid flag";
210 break;
718e3744 211 case BGP_ERR_PEER_GROUP_SHUTDOWN:
212 str = "Peer-group has been shutdown. Activate the peer-group first";
213 break;
718e3744 214 case BGP_ERR_PEER_FLAG_CONFLICT:
215 str = "Can't set override-capability and strict-capability-match at the same time";
216 break;
718e3744 217 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS:
218 str = "Specify remote-as or peer-group remote AS first";
219 break;
220 case BGP_ERR_PEER_GROUP_CANT_CHANGE:
221 str = "Cannot change the peer-group. Deconfigure first";
222 break;
223 case BGP_ERR_PEER_GROUP_MISMATCH:
4c48cf63 224 str = "Peer is not a member of this peer-group";
718e3744 225 break;
226 case BGP_ERR_PEER_FILTER_CONFLICT:
227 str = "Prefix/distribute list can not co-exist";
228 break;
229 case BGP_ERR_NOT_INTERNAL_PEER:
230 str = "Invalid command. Not an internal neighbor";
231 break;
232 case BGP_ERR_REMOVE_PRIVATE_AS:
5000f21c 233 str = "remove-private-AS cannot be configured for IBGP peers";
718e3744 234 break;
235 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP:
236 str = "Local-AS allowed only for EBGP peers";
237 break;
238 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS:
239 str = "Cannot have local-as same as BGP AS number";
240 break;
0df7c91f
PJ
241 case BGP_ERR_TCPSIG_FAILED:
242 str = "Error while applying TCP-Sig to session(s)";
243 break;
fa411a21
NH
244 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK:
245 str = "ebgp-multihop and ttl-security cannot be configured together";
246 break;
f5a4827d
SH
247 case BGP_ERR_NO_IBGP_WITH_TTLHACK:
248 str = "ttl-security only allowed for EBGP peers";
249 break;
c7122e14
DS
250 case BGP_ERR_AS_OVERRIDE:
251 str = "as-override cannot be configured for IBGP peers";
252 break;
f14e6fdb
DS
253 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT:
254 str = "Invalid limit for number of dynamic neighbors";
255 break;
256 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS:
257 str = "Dynamic neighbor listen range already exists";
258 break;
259 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER:
260 str = "Operation not allowed on a dynamic neighbor";
261 break;
718e3744 262 }
263 if (str)
264 {
265 vty_out (vty, "%% %s%s", str, VTY_NEWLINE);
266 return CMD_WARNING;
267 }
268 return CMD_SUCCESS;
269}
270
7aafcaca
DS
271/* BGP clear sort. */
272enum clear_sort
273{
274 clear_all,
275 clear_peer,
276 clear_group,
277 clear_external,
278 clear_as
279};
280
7aafcaca
DS
281static void
282bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi,
283 safi_t safi, int error)
284{
285 switch (error)
286 {
287 case BGP_ERR_AF_UNCONFIGURED:
288 vty_out (vty,
289 "%%BGP: Enable %s %s address family for the neighbor %s%s",
290 afi == AFI_IP6 ? "IPv6" : safi == SAFI_MPLS_VPN ? "VPNv4" : "IPv4",
291 safi == SAFI_MULTICAST ? "Multicast" : "Unicast",
292 peer->host, VTY_NEWLINE);
293 break;
294 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED:
295 vty_out (vty, "%%BGP: Inbound soft reconfig for %s not possible as it%s has neither refresh capability, nor inbound soft reconfig%s", peer->host, VTY_NEWLINE, VTY_NEWLINE);
296 break;
297 default:
298 break;
299 }
300}
301
302/* `clear ip bgp' functions. */
303static int
304bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
305 enum clear_sort sort,enum bgp_clear_type stype, const char *arg)
306{
307 int ret;
308 struct peer *peer;
309 struct listnode *node, *nnode;
310
311 /* Clear all neighbors. */
312 /*
313 * Pass along pointer to next node to peer_clear() when walking all nodes
314 * on the BGP instance as that may get freed if it is a doppelganger
315 */
316 if (sort == clear_all)
317 {
318 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
319 {
320 if (stype == BGP_CLEAR_SOFT_NONE)
321 ret = peer_clear (peer, &nnode);
322 else if (peer->afc[afi][safi])
323 ret = peer_clear_soft (peer, afi, safi, stype);
324 else
325 ret = 0;
326
327 if (ret < 0)
328 bgp_clear_vty_error (vty, peer, afi, safi, ret);
329 }
330
331 /* This is to apply read-only mode on this clear. */
332 if (stype == BGP_CLEAR_SOFT_NONE)
333 bgp->update_delay_over = 0;
334
335 return CMD_SUCCESS;
336 }
337
338 /* Clear specified neighbors. */
339 if (sort == clear_peer)
340 {
341 union sockunion su;
342 int ret;
343
344 /* Make sockunion for lookup. */
345 ret = str2sockunion (arg, &su);
346 if (ret < 0)
347 {
348 peer = peer_lookup_by_conf_if (bgp, arg);
349 if (!peer)
350 {
04b6bdc0
DW
351 peer = peer_lookup_by_hostname(bgp, arg);
352 if (!peer)
353 {
354 vty_out (vty, "Malformed address or name: %s%s", arg, VTY_NEWLINE);
355 return CMD_WARNING;
356 }
7aafcaca
DS
357 }
358 }
359 else
360 {
361 peer = peer_lookup (bgp, &su);
362 if (! peer)
363 {
364 vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE);
365 return CMD_WARNING;
366 }
367 }
368
369 if (stype == BGP_CLEAR_SOFT_NONE)
370 ret = peer_clear (peer, NULL);
371 else
372 ret = peer_clear_soft (peer, afi, safi, stype);
373
374 if (ret < 0)
375 bgp_clear_vty_error (vty, peer, afi, safi, ret);
376
377 return CMD_SUCCESS;
378 }
379
380 /* Clear all peer-group members. */
381 if (sort == clear_group)
382 {
383 struct peer_group *group;
384
385 group = peer_group_lookup (bgp, arg);
386 if (! group)
387 {
388 vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE);
389 return CMD_WARNING;
390 }
391
392 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
393 {
394 if (stype == BGP_CLEAR_SOFT_NONE)
395 {
396 ret = peer_clear (peer, NULL);
397 continue;
398 }
399
c8560b44 400 if (! peer->afc[afi][safi])
7aafcaca
DS
401 continue;
402
403 ret = peer_clear_soft (peer, afi, safi, stype);
404
405 if (ret < 0)
406 bgp_clear_vty_error (vty, peer, afi, safi, ret);
407 }
408 return CMD_SUCCESS;
409 }
410
411 if (sort == clear_external)
412 {
413 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
414 {
415 if (peer->sort == BGP_PEER_IBGP)
416 continue;
417
418 if (stype == BGP_CLEAR_SOFT_NONE)
419 ret = peer_clear (peer, &nnode);
420 else
421 ret = peer_clear_soft (peer, afi, safi, stype);
422
423 if (ret < 0)
424 bgp_clear_vty_error (vty, peer, afi, safi, ret);
425 }
426 return CMD_SUCCESS;
427 }
428
429 if (sort == clear_as)
430 {
431 as_t as;
432 int find = 0;
433
434 VTY_GET_INTEGER_RANGE ("AS", as, arg, 1, BGP_AS4_MAX);
435
436 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
437 {
438 if (peer->as != as)
439 continue;
440
441 find = 1;
442 if (stype == BGP_CLEAR_SOFT_NONE)
443 ret = peer_clear (peer, &nnode);
444 else
445 ret = peer_clear_soft (peer, afi, safi, stype);
446
447 if (ret < 0)
448 bgp_clear_vty_error (vty, peer, afi, safi, ret);
449 }
450 if (! find)
451 vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg,
452 VTY_NEWLINE);
453 return CMD_SUCCESS;
454 }
455
456 return CMD_SUCCESS;
457}
458
459static int
460bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi,
461 enum clear_sort sort, enum bgp_clear_type stype,
462 const char *arg)
463{
464 struct bgp *bgp;
465
466 /* BGP structure lookup. */
467 if (name)
468 {
469 bgp = bgp_lookup_by_name (name);
470 if (bgp == NULL)
471 {
6aeb9e78 472 vty_out (vty, "Can't find BGP instance %s%s", name, VTY_NEWLINE);
7aafcaca
DS
473 return CMD_WARNING;
474 }
475 }
476 else
477 {
478 bgp = bgp_get_default ();
479 if (bgp == NULL)
480 {
481 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
482 return CMD_WARNING;
483 }
484 }
485
486 return bgp_clear (vty, bgp, afi, safi, sort, stype, arg);
487}
488
489/* clear soft inbound */
490static void
491bgp_clear_star_soft_in (struct vty *vty)
492{
493 bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
494 BGP_CLEAR_SOFT_IN, NULL);
495#ifdef HAVE_IPV6
496 bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
497 BGP_CLEAR_SOFT_IN, NULL);
498#endif /* HAVE_IPV6 */
499}
500
501/* clear soft outbound */
502static void
503bgp_clear_star_soft_out (struct vty *vty)
504{
505 bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
506 BGP_CLEAR_SOFT_OUT, NULL);
507#ifdef HAVE_IPV6
508 bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
509 BGP_CLEAR_SOFT_OUT, NULL);
510#endif /* HAVE_IPV6 */
511}
512
513
718e3744 514/* BGP global configuration. */
515
516DEFUN (bgp_multiple_instance_func,
517 bgp_multiple_instance_cmd,
518 "bgp multiple-instance",
519 BGP_STR
520 "Enable bgp multiple instance\n")
521{
522 bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE);
523 return CMD_SUCCESS;
524}
525
526DEFUN (no_bgp_multiple_instance,
527 no_bgp_multiple_instance_cmd,
528 "no bgp multiple-instance",
529 NO_STR
530 BGP_STR
531 "BGP multiple instance\n")
532{
533 int ret;
534
535 ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE);
536 if (ret < 0)
537 {
538 vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE);
539 return CMD_WARNING;
540 }
541 return CMD_SUCCESS;
542}
543
544DEFUN (bgp_config_type,
545 bgp_config_type_cmd,
546 "bgp config-type (cisco|zebra)",
547 BGP_STR
548 "Configuration type\n"
549 "cisco\n"
550 "zebra\n")
551{
552 if (strncmp (argv[0], "c", 1) == 0)
553 bgp_option_set (BGP_OPT_CONFIG_CISCO);
554 else
555 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
556
557 return CMD_SUCCESS;
558}
559
560DEFUN (no_bgp_config_type,
561 no_bgp_config_type_cmd,
562 "no bgp config-type",
563 NO_STR
564 BGP_STR
565 "Display configuration type\n")
566{
567 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
568 return CMD_SUCCESS;
569}
570
813d4307
DW
571ALIAS (no_bgp_config_type,
572 no_bgp_config_type_val_cmd,
573 "no bgp config-type (cisco|zebra)",
574 NO_STR
575 BGP_STR
576 "Configuration type\n"
577 "cisco\n"
578 "zebra\n")
579
718e3744 580DEFUN (no_synchronization,
581 no_synchronization_cmd,
582 "no synchronization",
583 NO_STR
584 "Perform IGP synchronization\n")
585{
586 return CMD_SUCCESS;
587}
588
589DEFUN (no_auto_summary,
590 no_auto_summary_cmd,
591 "no auto-summary",
592 NO_STR
593 "Enable automatic network number summarization\n")
594{
595 return CMD_SUCCESS;
596}
3d515fd9 597
718e3744 598/* "router bgp" commands. */
599DEFUN (router_bgp,
600 router_bgp_cmd,
320da874 601 "router bgp " CMD_AS_RANGE,
718e3744 602 ROUTER_STR
603 BGP_STR
604 AS_STR)
605{
606 int ret;
607 as_t as;
608 struct bgp *bgp;
fd79ac91 609 const char *name = NULL;
ad4cbda1 610 enum bgp_instance_type inst_type;
718e3744 611
2385a876
DW
612 // "router bgp" without an ASN
613 if (argc < 1)
614 {
6aeb9e78 615 //Pending: Make VRF option available for ASN less config
2385a876 616 bgp = bgp_get_default();
718e3744 617
2385a876
DW
618 if (bgp == NULL)
619 {
620 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
621 return CMD_WARNING;
622 }
718e3744 623
2385a876
DW
624 if (listcount(bm->bgp) > 1)
625 {
626 vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE);
627 return CMD_WARNING;
628 }
629 }
630
631 // "router bgp X"
632 else
718e3744 633 {
2385a876
DW
634 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
635
ad4cbda1 636 inst_type = BGP_INSTANCE_TYPE_DEFAULT;
6aeb9e78 637 if (argc == 3)
ad4cbda1 638 {
639 name = argv[2];
640 if (!strcmp(argv[1], "vrf"))
641 inst_type = BGP_INSTANCE_TYPE_VRF;
642 else if (!strcmp(argv[1], "view"))
643 inst_type = BGP_INSTANCE_TYPE_VIEW;
644 }
2385a876 645
ad4cbda1 646 ret = bgp_get (&bgp, &as, name, inst_type);
2385a876
DW
647 switch (ret)
648 {
649 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET:
650 vty_out (vty, "Please specify 'bgp multiple-instance' first%s",
651 VTY_NEWLINE);
652 return CMD_WARNING;
653 case BGP_ERR_AS_MISMATCH:
654 vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE);
655 return CMD_WARNING;
656 case BGP_ERR_INSTANCE_MISMATCH:
6aeb9e78 657 vty_out (vty, "BGP instance name and AS number mismatch%s", VTY_NEWLINE);
2385a876
DW
658 vty_out (vty, "BGP instance is already running; AS is %u%s",
659 as, VTY_NEWLINE);
660 return CMD_WARNING;
661 }
6aeb9e78
DS
662
663 /* Pending: handle when user tries to change a view to vrf n vv. */
718e3744 664 }
665
666 vty->node = BGP_NODE;
667 vty->index = bgp;
668
669 return CMD_SUCCESS;
670}
671
672ALIAS (router_bgp,
6aeb9e78
DS
673 router_bgp_instance_cmd,
674 "router bgp " CMD_AS_RANGE " (view|vrf) WORD",
718e3744 675 ROUTER_STR
676 BGP_STR
677 AS_STR
6aeb9e78 678 "BGP view\nBGP VRF\n"
8386ac43 679 "View/VRF name\n")
6b0655a2 680
2385a876
DW
681ALIAS (router_bgp,
682 router_bgp_noasn_cmd,
683 "router bgp",
684 ROUTER_STR
685 BGP_STR)
686
718e3744 687/* "no router bgp" commands. */
688DEFUN (no_router_bgp,
689 no_router_bgp_cmd,
320da874 690 "no router bgp " CMD_AS_RANGE,
718e3744 691 NO_STR
692 ROUTER_STR
693 BGP_STR
694 AS_STR)
695{
696 as_t as;
697 struct bgp *bgp;
fd79ac91 698 const char *name = NULL;
718e3744 699
0b2aa3a0 700 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
718e3744 701
6aeb9e78
DS
702 if (argc == 3)
703 name = argv[2];
718e3744 704
705 /* Lookup bgp structure. */
706 bgp = bgp_lookup (as, name);
707 if (! bgp)
708 {
709 vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE);
710 return CMD_WARNING;
711 }
712
713 bgp_delete (bgp);
714
715 return CMD_SUCCESS;
716}
717
718ALIAS (no_router_bgp,
6aeb9e78
DS
719 no_router_bgp_instance_cmd,
720 "no router bgp " CMD_AS_RANGE " (view|vrf) WORD",
718e3744 721 NO_STR
722 ROUTER_STR
723 BGP_STR
724 AS_STR
6aeb9e78 725 "BGP view\nBGP VRF\n"
8386ac43 726 "View/VRF name\n")
6b0655a2 727
718e3744 728/* BGP router-id. */
729
730DEFUN (bgp_router_id,
731 bgp_router_id_cmd,
732 "bgp router-id A.B.C.D",
733 BGP_STR
734 "Override configured router identifier\n"
735 "Manually configured router identifier\n")
736{
737 int ret;
738 struct in_addr id;
739 struct bgp *bgp;
740
741 bgp = vty->index;
742
743 ret = inet_aton (argv[0], &id);
744 if (! ret)
745 {
746 vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE);
747 return CMD_WARNING;
748 }
749
c2d58d6d 750 if (IPV4_ADDR_SAME (&bgp->router_id_static, &id))
751 return CMD_SUCCESS;
752
18a6dce6 753 bgp->router_id_static = id;
718e3744 754 bgp_router_id_set (bgp, &id);
755
756 return CMD_SUCCESS;
757}
758
759DEFUN (no_bgp_router_id,
760 no_bgp_router_id_cmd,
761 "no bgp router-id",
762 NO_STR
763 BGP_STR
764 "Override configured router identifier\n")
765{
766 int ret;
767 struct in_addr id;
768 struct bgp *bgp;
769
770 bgp = vty->index;
771
772 if (argc == 1)
773 {
774 ret = inet_aton (argv[0], &id);
775 if (! ret)
776 {
777 vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE);
778 return CMD_WARNING;
779 }
780
18a6dce6 781 if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id))
718e3744 782 {
783 vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE);
784 return CMD_WARNING;
785 }
786 }
787
18a6dce6 788 bgp->router_id_static.s_addr = 0;
6aeb9e78 789 bgp_router_id_set (bgp, &bgp->router_id_zebra);
718e3744 790
791 return CMD_SUCCESS;
792}
793
794ALIAS (no_bgp_router_id,
795 no_bgp_router_id_val_cmd,
796 "no bgp router-id A.B.C.D",
797 NO_STR
798 BGP_STR
799 "Override configured router identifier\n"
800 "Manually configured router identifier\n")
6b0655a2 801
718e3744 802/* BGP Cluster ID. */
803
804DEFUN (bgp_cluster_id,
805 bgp_cluster_id_cmd,
806 "bgp cluster-id A.B.C.D",
807 BGP_STR
808 "Configure Route-Reflector Cluster-id\n"
809 "Route-Reflector Cluster-id in IP address format\n")
810{
811 int ret;
812 struct bgp *bgp;
813 struct in_addr cluster;
814
815 bgp = vty->index;
816
817 ret = inet_aton (argv[0], &cluster);
818 if (! ret)
819 {
820 vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
821 return CMD_WARNING;
822 }
823
824 bgp_cluster_id_set (bgp, &cluster);
7aafcaca 825 bgp_clear_star_soft_out (vty);
718e3744 826
827 return CMD_SUCCESS;
828}
829
830ALIAS (bgp_cluster_id,
831 bgp_cluster_id32_cmd,
832 "bgp cluster-id <1-4294967295>",
833 BGP_STR
834 "Configure Route-Reflector Cluster-id\n"
835 "Route-Reflector Cluster-id as 32 bit quantity\n")
836
837DEFUN (no_bgp_cluster_id,
838 no_bgp_cluster_id_cmd,
839 "no bgp cluster-id",
840 NO_STR
841 BGP_STR
842 "Configure Route-Reflector Cluster-id\n")
843{
844 int ret;
845 struct bgp *bgp;
846 struct in_addr cluster;
847
848 bgp = vty->index;
849
850 if (argc == 1)
851 {
852 ret = inet_aton (argv[0], &cluster);
853 if (! ret)
854 {
855 vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
856 return CMD_WARNING;
857 }
858 }
859
860 bgp_cluster_id_unset (bgp);
7aafcaca 861 bgp_clear_star_soft_out (vty);
718e3744 862
863 return CMD_SUCCESS;
864}
865
866ALIAS (no_bgp_cluster_id,
813d4307 867 no_bgp_cluster_id_ip_cmd,
718e3744 868 "no bgp cluster-id A.B.C.D",
869 NO_STR
870 BGP_STR
871 "Configure Route-Reflector Cluster-id\n"
872 "Route-Reflector Cluster-id in IP address format\n")
6b0655a2 873
813d4307
DW
874ALIAS (no_bgp_cluster_id,
875 no_bgp_cluster_id_decimal_cmd,
876 "no bgp cluster-id <1-4294967295>",
877 NO_STR
878 BGP_STR
879 "Configure Route-Reflector Cluster-id\n"
880 "Route-Reflector Cluster-id as 32 bit quantity\n")
881
718e3744 882DEFUN (bgp_confederation_identifier,
883 bgp_confederation_identifier_cmd,
320da874 884 "bgp confederation identifier " CMD_AS_RANGE,
718e3744 885 "BGP specific commands\n"
886 "AS confederation parameters\n"
887 "AS number\n"
888 "Set routing domain confederation AS\n")
889{
890 struct bgp *bgp;
891 as_t as;
892
893 bgp = vty->index;
894
0b2aa3a0 895 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
718e3744 896
897 bgp_confederation_id_set (bgp, as);
898
899 return CMD_SUCCESS;
900}
901
902DEFUN (no_bgp_confederation_identifier,
903 no_bgp_confederation_identifier_cmd,
904 "no bgp confederation identifier",
905 NO_STR
906 "BGP specific commands\n"
907 "AS confederation parameters\n"
908 "AS number\n")
909{
910 struct bgp *bgp;
718e3744 911
912 bgp = vty->index;
913
718e3744 914 bgp_confederation_id_unset (bgp);
915
916 return CMD_SUCCESS;
917}
918
919ALIAS (no_bgp_confederation_identifier,
920 no_bgp_confederation_identifier_arg_cmd,
320da874 921 "no bgp confederation identifier " CMD_AS_RANGE,
718e3744 922 NO_STR
923 "BGP specific commands\n"
924 "AS confederation parameters\n"
925 "AS number\n"
926 "Set routing domain confederation AS\n")
6b0655a2 927
718e3744 928DEFUN (bgp_confederation_peers,
929 bgp_confederation_peers_cmd,
320da874 930 "bgp confederation peers ." CMD_AS_RANGE,
718e3744 931 "BGP specific commands\n"
932 "AS confederation parameters\n"
933 "Peer ASs in BGP confederation\n"
934 AS_STR)
935{
936 struct bgp *bgp;
937 as_t as;
938 int i;
939
940 bgp = vty->index;
941
942 for (i = 0; i < argc; i++)
943 {
0b2aa3a0 944 VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX);
718e3744 945
946 if (bgp->as == as)
947 {
948 vty_out (vty, "%% Local member-AS not allowed in confed peer list%s",
949 VTY_NEWLINE);
950 continue;
951 }
952
953 bgp_confederation_peers_add (bgp, as);
954 }
955 return CMD_SUCCESS;
956}
957
958DEFUN (no_bgp_confederation_peers,
959 no_bgp_confederation_peers_cmd,
320da874 960 "no bgp confederation peers ." CMD_AS_RANGE,
718e3744 961 NO_STR
962 "BGP specific commands\n"
963 "AS confederation parameters\n"
964 "Peer ASs in BGP confederation\n"
965 AS_STR)
966{
967 struct bgp *bgp;
968 as_t as;
969 int i;
970
971 bgp = vty->index;
972
973 for (i = 0; i < argc; i++)
974 {
0b2aa3a0
PJ
975 VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX);
976
718e3744 977 bgp_confederation_peers_remove (bgp, as);
978 }
979 return CMD_SUCCESS;
980}
6b0655a2 981
5e242b0d
DS
982/**
983 * Central routine for maximum-paths configuration.
984 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
985 * @set: 1 for setting values, 0 for removing the max-paths config.
986 */
ffd0c037
DS
987static int
988bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths,
5e242b0d 989 u_int16_t options, int set)
165b5fff
JB
990{
991 struct bgp *bgp;
ffd0c037 992 u_int16_t maxpaths = 0;
165b5fff 993 int ret;
5e242b0d
DS
994 afi_t afi;
995 safi_t safi;
165b5fff
JB
996
997 bgp = vty->index;
5e242b0d
DS
998 afi = bgp_node_afi (vty);
999 safi = bgp_node_safi (vty);
165b5fff 1000
5e242b0d
DS
1001 if (set)
1002 {
73ac8160 1003 VTY_GET_INTEGER_RANGE ("maximum-paths", maxpaths, mpaths, 1,
5b964da3 1004 MULTIPATH_NUM);
5e242b0d
DS
1005 ret = bgp_maximum_paths_set (bgp, afi, safi, peer_type, maxpaths,
1006 options);
1007 }
1008 else
1009 ret = bgp_maximum_paths_unset (bgp, afi, safi, peer_type);
165b5fff 1010
165b5fff
JB
1011 if (ret < 0)
1012 {
1013 vty_out (vty,
5e242b0d
DS
1014 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u%s",
1015 (set == 1) ? "" : "un",
1016 (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp",
1017 maxpaths, afi, safi, VTY_NEWLINE);
165b5fff
JB
1018 return CMD_WARNING;
1019 }
1020
7aafcaca
DS
1021 bgp_recalculate_all_bestpaths (bgp);
1022
165b5fff
JB
1023 return CMD_SUCCESS;
1024}
1025
abc920f8
DS
1026DEFUN (bgp_maxmed_admin,
1027 bgp_maxmed_admin_cmd,
1028 "bgp max-med administrative ",
1029 BGP_STR
1030 "Advertise routes with max-med\n"
1031 "Administratively applied, for an indefinite period\n")
1032{
1033 struct bgp *bgp;
1034
1035 bgp = vty->index;
1036
1037 bgp->v_maxmed_admin = 1;
1038 bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT;
1039
1040 bgp_maxmed_update(bgp);
1041
1042 return CMD_SUCCESS;
1043}
1044
1045DEFUN (bgp_maxmed_admin_medv,
1046 bgp_maxmed_admin_medv_cmd,
1047 "bgp max-med administrative <0-4294967294>",
1048 BGP_STR
1049 "Advertise routes with max-med\n"
1050 "Administratively applied, for an indefinite period\n"
1051 "Max MED value to be used\n")
1052{
1053 struct bgp *bgp;
1054
1055 bgp = vty->index;
1056
1057 bgp->v_maxmed_admin = 1;
1058 VTY_GET_INTEGER ("max-med admin med-value", bgp->maxmed_admin_value, argv[0]);
1059
1060 bgp_maxmed_update(bgp);
1061
1062 return CMD_SUCCESS;
1063}
1064
1065DEFUN (no_bgp_maxmed_admin,
1066 no_bgp_maxmed_admin_cmd,
1067 "no bgp max-med administrative",
1068 NO_STR
1069 BGP_STR
1070 "Advertise routes with max-med\n"
1071 "Administratively applied, for an indefinite period\n")
1072{
1073 struct bgp *bgp;
1074
1075 bgp = vty->index;
1076
1077 bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED;
1078 bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT;
1079
1080 bgp_maxmed_update(bgp);
1081
1082 return CMD_SUCCESS;
1083}
1084
1085ALIAS (no_bgp_maxmed_admin,
1086 no_bgp_maxmed_admin_medv_cmd,
1087 "no bgp max-med administrative <0-4294967294>",
1088 NO_STR
1089 BGP_STR
1090 "Advertise routes with max-med\n"
1091 "Administratively applied, for an indefinite period\n"
1092 "Max MED value to be used\n")
1093
1094
1095DEFUN (bgp_maxmed_onstartup,
1096 bgp_maxmed_onstartup_cmd,
1097 "bgp max-med on-startup <5-86400>",
1098 BGP_STR
1099 "Advertise routes with max-med\n"
1100 "Effective on a startup\n"
1101 "Time (seconds) period for max-med\n")
1102{
1103 struct bgp *bgp;
1104
1105 bgp = vty->index;
1106
1107 if (argc != 1)
1108 {
1109 vty_out (vty, "%% Must supply max-med on-startup period");
1110 return CMD_WARNING;
1111 }
1112
1113 VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[0]);
1114 bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT;
1115
1116 bgp_maxmed_update(bgp);
1117
1118 return CMD_SUCCESS;
1119}
1120
1121DEFUN (bgp_maxmed_onstartup_medv,
1122 bgp_maxmed_onstartup_medv_cmd,
1123 "bgp max-med on-startup <5-86400> <0-4294967294>",
1124 BGP_STR
1125 "Advertise routes with max-med\n"
1126 "Effective on a startup\n"
1127 "Time (seconds) period for max-med\n"
1128 "Max MED value to be used\n")
1129{
1130 struct bgp *bgp;
1131
1132 bgp = vty->index;
1133
1134 if (argc != 2)
1135 {
1136 vty_out (vty, "%% Must supply max-med on-startup period and med value");
1137 return CMD_WARNING;
1138 }
1139
1140 VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[0]);
1141 VTY_GET_INTEGER ("max-med on-startup med-value", bgp->maxmed_onstartup_value, argv[1]);
1142
1143 bgp_maxmed_update(bgp);
1144
1145 return CMD_SUCCESS;
1146}
1147
1148DEFUN (no_bgp_maxmed_onstartup,
1149 no_bgp_maxmed_onstartup_cmd,
1150 "no bgp max-med on-startup",
1151 NO_STR
1152 BGP_STR
1153 "Advertise routes with max-med\n"
1154 "Effective on a startup\n")
1155{
1156 struct bgp *bgp;
1157
1158 bgp = vty->index;
1159
1160 /* Cancel max-med onstartup if its on */
1161 if (bgp->t_maxmed_onstartup)
1162 {
1163 THREAD_TIMER_OFF (bgp->t_maxmed_onstartup);
1164 bgp->maxmed_onstartup_over = 1;
1165 }
1166
1167 bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED;
1168 bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT;
1169
1170 bgp_maxmed_update(bgp);
1171
1172 return CMD_SUCCESS;
1173}
1174
1175ALIAS (no_bgp_maxmed_onstartup,
1176 no_bgp_maxmed_onstartup_period_cmd,
1177 "no bgp max-med on-startup <5-86400>",
1178 NO_STR
1179 BGP_STR
1180 "Advertise routes with max-med\n"
1181 "Effective on a startup\n"
1182 "Time (seconds) period for max-med\n")
1183
1184ALIAS (no_bgp_maxmed_onstartup,
1185 no_bgp_maxmed_onstartup_period_medv_cmd,
1186 "no bgp max-med on-startup <5-86400> <0-4294967294>",
1187 NO_STR
1188 BGP_STR
1189 "Advertise routes with max-med\n"
1190 "Effective on a startup\n"
1191 "Time (seconds) period for max-med\n"
1192 "Max MED value to be used\n")
1193
f188f2c4
DS
1194static int
1195bgp_update_delay_config_vty (struct vty *vty, const char *delay,
1196 const char *wait)
1197{
1198 struct bgp *bgp;
1199 u_int16_t update_delay;
1200 u_int16_t establish_wait;
1201
1202
1203 bgp = vty->index;
1204
1205 VTY_GET_INTEGER_RANGE ("update-delay", update_delay, delay,
1206 BGP_UPDATE_DELAY_MIN, BGP_UPDATE_DELAY_MAX);
1207
1208 if (!wait) /* update-delay <delay> */
1209 {
1210 bgp->v_update_delay = update_delay;
1211 bgp->v_establish_wait = bgp->v_update_delay;
1212 return CMD_SUCCESS;
1213 }
1214
1215 /* update-delay <delay> <establish-wait> */
1216 establish_wait = atoi (wait);
1217 if (update_delay < establish_wait)
1218 {
1219 vty_out (vty, "%%Failed: update-delay less than the establish-wait!%s",
1220 VTY_NEWLINE);
1221 return CMD_WARNING;
1222 }
1223
1224 bgp->v_update_delay = update_delay;
1225 bgp->v_establish_wait = establish_wait;
1226
1227 return CMD_SUCCESS;
1228}
1229
1230static int
1231bgp_update_delay_deconfig_vty (struct vty *vty)
1232{
1233 struct bgp *bgp;
1234
1235 bgp = vty->index;
1236
1237 bgp->v_update_delay = BGP_UPDATE_DELAY_DEF;
1238 bgp->v_establish_wait = bgp->v_update_delay;
1239
1240 return CMD_SUCCESS;
1241}
1242
1243int
1244bgp_config_write_update_delay (struct vty *vty, struct bgp *bgp)
1245{
1246 if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF)
1247 {
1248 vty_out (vty, " update-delay %d", bgp->v_update_delay);
1249 if (bgp->v_update_delay != bgp->v_establish_wait)
1250 vty_out (vty, " %d", bgp->v_establish_wait);
1251 vty_out (vty, "%s", VTY_NEWLINE);
1252 }
1253
1254 return 0;
1255}
1256
1257
1258/* Update-delay configuration */
1259DEFUN (bgp_update_delay,
1260 bgp_update_delay_cmd,
1261 "update-delay <0-3600>",
1262 "Force initial delay for best-path and updates\n"
1263 "Seconds\n")
1264{
1265 return bgp_update_delay_config_vty(vty, argv[0], NULL);
1266}
1267
1268DEFUN (bgp_update_delay_establish_wait,
1269 bgp_update_delay_establish_wait_cmd,
1270 "update-delay <0-3600> <1-3600>",
1271 "Force initial delay for best-path and updates\n"
1272 "Seconds\n"
1273 "Wait for peers to be established\n"
1274 "Seconds\n")
1275{
1276 return bgp_update_delay_config_vty(vty, argv[0], argv[1]);
1277}
1278
1279/* Update-delay deconfiguration */
1280DEFUN (no_bgp_update_delay,
1281 no_bgp_update_delay_cmd,
1282 "no update-delay <0-3600>",
1283 "Force initial delay for best-path and updates\n"
1284 "Seconds\n")
1285{
1286 return bgp_update_delay_deconfig_vty(vty);
1287}
1288
1289ALIAS (no_bgp_update_delay,
1290 no_bgp_update_delay_establish_wait_cmd,
1291 "no update-delay <0-3600> <1-3600>",
1292 "Force initial delay for best-path and updates\n"
1293 "Seconds\n"
1294 "Wait for peers to be established\n"
1295 "Seconds\n")
5e242b0d 1296
ffd0c037
DS
1297static int
1298bgp_wpkt_quanta_config_vty (struct vty *vty, const char *num, char set)
cb1faec9
DS
1299{
1300 struct bgp *bgp;
cb1faec9
DS
1301
1302 bgp = vty->index;
1303
1304 if (set)
1305 VTY_GET_INTEGER_RANGE ("write-quanta", bgp->wpkt_quanta, num,
4543bbb4 1306 1, 10000);
cb1faec9
DS
1307 else
1308 bgp->wpkt_quanta = BGP_WRITE_PACKET_MAX;
1309
1310 return CMD_SUCCESS;
1311}
1312
1313int
1314bgp_config_write_wpkt_quanta (struct vty *vty, struct bgp *bgp)
1315{
1316 if (bgp->wpkt_quanta != BGP_WRITE_PACKET_MAX)
1317 vty_out (vty, " write-quanta %d%s",
1318 bgp->wpkt_quanta, VTY_NEWLINE);
1319
1320 return 0;
1321}
1322
1323
1324/* Update-delay configuration */
1325DEFUN (bgp_wpkt_quanta,
1326 bgp_wpkt_quanta_cmd,
4543bbb4 1327 "write-quanta <1-10000>",
cb1faec9
DS
1328 "How many packets to write to peer socket per run\n"
1329 "Number of packets\n")
1330{
1331 return bgp_wpkt_quanta_config_vty(vty, argv[0], 1);
1332}
1333
1334/* Update-delay deconfiguration */
1335DEFUN (no_bgp_wpkt_quanta,
1336 no_bgp_wpkt_quanta_cmd,
4543bbb4 1337 "no write-quanta <1-10000>",
cb1faec9
DS
1338 "How many packets to write to peer socket per run\n"
1339 "Number of packets\n")
1340{
1341 return bgp_wpkt_quanta_config_vty(vty, argv[0], 0);
1342}
1343
ffd0c037 1344static int
3f9c7369
DS
1345bgp_coalesce_config_vty (struct vty *vty, const char *num, char set)
1346{
1347 struct bgp *bgp;
1348
1349 bgp = vty->index;
1350
1351 if (set)
1352 VTY_GET_INTEGER_RANGE ("coalesce-time", bgp->coalesce_time, num,
1353 0, 4294967295);
1354 else
1355 bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME;
1356
1357 return CMD_SUCCESS;
1358}
1359
1360int
1361bgp_config_write_coalesce_time (struct vty *vty, struct bgp *bgp)
1362{
1363 if (bgp->coalesce_time != BGP_DEFAULT_SUBGROUP_COALESCE_TIME)
1364 vty_out (vty, " coalesce-time %d%s",
1365 bgp->coalesce_time, VTY_NEWLINE);
1366
1367 return 0;
1368}
1369
1370
1371DEFUN (bgp_coalesce_time,
1372 bgp_coalesce_time_cmd,
1373 "coalesce-time <0-4294967295>",
1374 "Subgroup coalesce timer\n"
1375 "Subgroup coalesce timer value (in ms)\n")
1376{
1377 return bgp_coalesce_config_vty(vty, argv[0], 1);
1378}
1379
1380DEFUN (no_bgp_coalesce_time,
1381 no_bgp_coalesce_time_cmd,
1382 "no coalesce-time <0-4294967295>",
1383 "Subgroup coalesce timer\n"
1384 "Subgroup coalesce timer value (in ms)\n")
1385{
1386 return bgp_coalesce_config_vty(vty, argv[0], 0);
1387}
1388
5e242b0d
DS
1389/* Maximum-paths configuration */
1390DEFUN (bgp_maxpaths,
1391 bgp_maxpaths_cmd,
a565fbdd 1392 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM),
5e242b0d
DS
1393 "Forward packets over multiple paths\n"
1394 "Number of paths\n")
1395{
1396 return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, argv[0], 0, 1);
1397}
1398
165b5fff
JB
1399DEFUN (bgp_maxpaths_ibgp,
1400 bgp_maxpaths_ibgp_cmd,
a565fbdd 1401 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM),
165b5fff
JB
1402 "Forward packets over multiple paths\n"
1403 "iBGP-multipath\n"
1404 "Number of paths\n")
1405{
5e242b0d
DS
1406 return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[0], 0, 1);
1407}
165b5fff 1408
5e242b0d
DS
1409DEFUN (bgp_maxpaths_ibgp_cluster,
1410 bgp_maxpaths_ibgp_cluster_cmd,
a565fbdd 1411 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length",
5e242b0d
DS
1412 "Forward packets over multiple paths\n"
1413 "iBGP-multipath\n"
1414 "Number of paths\n"
1415 "Match the cluster length\n")
1416{
1417 return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[0],
1418 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1);
165b5fff
JB
1419}
1420
1421DEFUN (no_bgp_maxpaths,
1422 no_bgp_maxpaths_cmd,
1423 "no maximum-paths",
1424 NO_STR
1425 "Forward packets over multiple paths\n"
1426 "Number of paths\n")
1427{
5e242b0d 1428 return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0);
165b5fff
JB
1429}
1430
1431ALIAS (no_bgp_maxpaths,
1432 no_bgp_maxpaths_arg_cmd,
a565fbdd 1433 "no maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM),
165b5fff
JB
1434 NO_STR
1435 "Forward packets over multiple paths\n"
1436 "Number of paths\n")
1437
1438DEFUN (no_bgp_maxpaths_ibgp,
1439 no_bgp_maxpaths_ibgp_cmd,
1440 "no maximum-paths ibgp",
1441 NO_STR
1442 "Forward packets over multiple paths\n"
1443 "iBGP-multipath\n"
1444 "Number of paths\n")
1445{
5e242b0d 1446 return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0);
165b5fff
JB
1447}
1448
1449ALIAS (no_bgp_maxpaths_ibgp,
1450 no_bgp_maxpaths_ibgp_arg_cmd,
a565fbdd 1451 "no maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM),
165b5fff
JB
1452 NO_STR
1453 "Forward packets over multiple paths\n"
1454 "iBGP-multipath\n"
1455 "Number of paths\n")
1456
5e242b0d
DS
1457ALIAS (no_bgp_maxpaths_ibgp,
1458 no_bgp_maxpaths_ibgp_cluster_cmd,
a565fbdd 1459 "no maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length",
5e242b0d
DS
1460 NO_STR
1461 "Forward packets over multiple paths\n"
1462 "iBGP-multipath\n"
1463 "Number of paths\n"
1464 "Match the cluster length\n")
1465
165b5fff
JB
1466int
1467bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi,
1468 safi_t safi, int *write)
1469{
d5b77cc2 1470 if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM)
165b5fff
JB
1471 {
1472 bgp_config_write_family_header (vty, afi, safi, write);
0b960b4d 1473 vty_out (vty, " maximum-paths %d%s",
165b5fff
JB
1474 bgp->maxpaths[afi][safi].maxpaths_ebgp, VTY_NEWLINE);
1475 }
1476
d5b77cc2 1477 if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM)
165b5fff
JB
1478 {
1479 bgp_config_write_family_header (vty, afi, safi, write);
0b960b4d 1480 vty_out (vty, " maximum-paths ibgp %d",
5e242b0d
DS
1481 bgp->maxpaths[afi][safi].maxpaths_ibgp);
1482 if (CHECK_FLAG (bgp->maxpaths[afi][safi].ibgp_flags,
1483 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN))
1484 vty_out (vty, " equal-cluster-length");
1485 vty_out (vty, "%s", VTY_NEWLINE);
165b5fff
JB
1486 }
1487
1488 return 0;
1489}
6b0655a2 1490
718e3744 1491/* BGP timers. */
1492
1493DEFUN (bgp_timers,
1494 bgp_timers_cmd,
1495 "timers bgp <0-65535> <0-65535>",
1496 "Adjust routing timers\n"
1497 "BGP timers\n"
1498 "Keepalive interval\n"
1499 "Holdtime\n")
1500{
1501 struct bgp *bgp;
1502 unsigned long keepalive = 0;
1503 unsigned long holdtime = 0;
1504
1505 bgp = vty->index;
1506
1507 VTY_GET_INTEGER ("keepalive", keepalive, argv[0]);
1508 VTY_GET_INTEGER ("holdtime", holdtime, argv[1]);
1509
1510 /* Holdtime value check. */
1511 if (holdtime < 3 && holdtime != 0)
1512 {
1513 vty_out (vty, "%% hold time value must be either 0 or greater than 3%s",
1514 VTY_NEWLINE);
1515 return CMD_WARNING;
1516 }
1517
1518 bgp_timers_set (bgp, keepalive, holdtime);
1519
1520 return CMD_SUCCESS;
1521}
1522
1523DEFUN (no_bgp_timers,
1524 no_bgp_timers_cmd,
1525 "no timers bgp",
1526 NO_STR
1527 "Adjust routing timers\n"
1528 "BGP timers\n")
1529{
1530 struct bgp *bgp;
1531
1532 bgp = vty->index;
1533 bgp_timers_unset (bgp);
1534
1535 return CMD_SUCCESS;
1536}
1537
1538ALIAS (no_bgp_timers,
1539 no_bgp_timers_arg_cmd,
1540 "no timers bgp <0-65535> <0-65535>",
1541 NO_STR
1542 "Adjust routing timers\n"
1543 "BGP timers\n"
1544 "Keepalive interval\n"
1545 "Holdtime\n")
6b0655a2 1546
718e3744 1547DEFUN (bgp_client_to_client_reflection,
1548 bgp_client_to_client_reflection_cmd,
1549 "bgp client-to-client reflection",
1550 "BGP specific commands\n"
1551 "Configure client to client route reflection\n"
1552 "reflection of routes allowed\n")
1553{
1554 struct bgp *bgp;
1555
1556 bgp = vty->index;
1557 bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
7aafcaca
DS
1558 bgp_clear_star_soft_out (vty);
1559
718e3744 1560 return CMD_SUCCESS;
1561}
1562
1563DEFUN (no_bgp_client_to_client_reflection,
1564 no_bgp_client_to_client_reflection_cmd,
1565 "no bgp client-to-client reflection",
1566 NO_STR
1567 "BGP specific commands\n"
1568 "Configure client to client route reflection\n"
1569 "reflection of routes allowed\n")
1570{
1571 struct bgp *bgp;
1572
1573 bgp = vty->index;
1574 bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
7aafcaca
DS
1575 bgp_clear_star_soft_out (vty);
1576
718e3744 1577 return CMD_SUCCESS;
1578}
1579
1580/* "bgp always-compare-med" configuration. */
1581DEFUN (bgp_always_compare_med,
1582 bgp_always_compare_med_cmd,
1583 "bgp always-compare-med",
1584 "BGP specific commands\n"
1585 "Allow comparing MED from different neighbors\n")
1586{
1587 struct bgp *bgp;
1588
1589 bgp = vty->index;
1590 bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
7aafcaca
DS
1591 bgp_recalculate_all_bestpaths (bgp);
1592
718e3744 1593 return CMD_SUCCESS;
1594}
1595
1596DEFUN (no_bgp_always_compare_med,
1597 no_bgp_always_compare_med_cmd,
1598 "no bgp always-compare-med",
1599 NO_STR
1600 "BGP specific commands\n"
1601 "Allow comparing MED from different neighbors\n")
1602{
1603 struct bgp *bgp;
1604
1605 bgp = vty->index;
1606 bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
7aafcaca
DS
1607 bgp_recalculate_all_bestpaths (bgp);
1608
718e3744 1609 return CMD_SUCCESS;
1610}
6b0655a2 1611
718e3744 1612/* "bgp deterministic-med" configuration. */
1613DEFUN (bgp_deterministic_med,
1614 bgp_deterministic_med_cmd,
1615 "bgp deterministic-med",
1616 "BGP specific commands\n"
1617 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1618{
1619 struct bgp *bgp;
1620
1621 bgp = vty->index;
1475ac87
DW
1622
1623 if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED))
1624 {
1625 bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED);
1626 bgp_recalculate_all_bestpaths (bgp);
1627 }
7aafcaca 1628
718e3744 1629 return CMD_SUCCESS;
1630}
1631
1632DEFUN (no_bgp_deterministic_med,
1633 no_bgp_deterministic_med_cmd,
1634 "no bgp deterministic-med",
1635 NO_STR
1636 "BGP specific commands\n"
1637 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1638{
1639 struct bgp *bgp;
06370dac
DW
1640 int bestpath_per_as_used;
1641 afi_t afi;
1642 safi_t safi;
1643 struct peer *peer;
1644 struct listnode *node, *nnode;
718e3744 1645
1646 bgp = vty->index;
1475ac87
DW
1647
1648 if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED))
1649 {
06370dac
DW
1650 bestpath_per_as_used = 0;
1651
1652 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
1653 {
1654 for (afi = AFI_IP; afi < AFI_MAX; afi++)
1655 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
1656 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS))
1657 {
1658 bestpath_per_as_used = 1;
1659 break;
1660 }
1661
1662 if (bestpath_per_as_used)
1663 break;
1664 }
1665
1666 if (bestpath_per_as_used)
1667 {
1668 vty_out (vty, "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use%s",
1669 VTY_NEWLINE);
1670 return CMD_WARNING;
1671 }
1672 else
1673 {
1674 bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED);
1675 bgp_recalculate_all_bestpaths (bgp);
1676 }
1475ac87 1677 }
7aafcaca 1678
718e3744 1679 return CMD_SUCCESS;
1680}
538621f2 1681
1682/* "bgp graceful-restart" configuration. */
1683DEFUN (bgp_graceful_restart,
1684 bgp_graceful_restart_cmd,
1685 "bgp graceful-restart",
1686 "BGP specific commands\n"
1687 "Graceful restart capability parameters\n")
1688{
1689 struct bgp *bgp;
1690
1691 bgp = vty->index;
1692 bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART);
1693 return CMD_SUCCESS;
1694}
1695
1696DEFUN (no_bgp_graceful_restart,
1697 no_bgp_graceful_restart_cmd,
1698 "no bgp graceful-restart",
1699 NO_STR
1700 "BGP specific commands\n"
1701 "Graceful restart capability parameters\n")
1702{
1703 struct bgp *bgp;
1704
1705 bgp = vty->index;
1706 bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART);
1707 return CMD_SUCCESS;
1708}
1709
93406d87 1710DEFUN (bgp_graceful_restart_stalepath_time,
1711 bgp_graceful_restart_stalepath_time_cmd,
1712 "bgp graceful-restart stalepath-time <1-3600>",
1713 "BGP specific commands\n"
1714 "Graceful restart capability parameters\n"
1715 "Set the max time to hold onto restarting peer's stale paths\n"
1716 "Delay value (seconds)\n")
1717{
1718 struct bgp *bgp;
1719 u_int32_t stalepath;
1720
1721 bgp = vty->index;
1722 if (! bgp)
1723 return CMD_WARNING;
1724
1725 VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[0], 1, 3600);
1726 bgp->stalepath_time = stalepath;
1727 return CMD_SUCCESS;
1728}
1729
1730DEFUN (no_bgp_graceful_restart_stalepath_time,
1731 no_bgp_graceful_restart_stalepath_time_cmd,
1732 "no bgp graceful-restart stalepath-time",
1733 NO_STR
1734 "BGP specific commands\n"
1735 "Graceful restart capability parameters\n"
1736 "Set the max time to hold onto restarting peer's stale paths\n")
1737{
1738 struct bgp *bgp;
1739
1740 bgp = vty->index;
1741 if (! bgp)
1742 return CMD_WARNING;
1743
1744 bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME;
1745 return CMD_SUCCESS;
1746}
1747
1748ALIAS (no_bgp_graceful_restart_stalepath_time,
1749 no_bgp_graceful_restart_stalepath_time_val_cmd,
1750 "no bgp graceful-restart stalepath-time <1-3600>",
1751 NO_STR
1752 "BGP specific commands\n"
1753 "Graceful restart capability parameters\n"
1754 "Set the max time to hold onto restarting peer's stale paths\n"
1755 "Delay value (seconds)\n")
1756
718e3744 1757/* "bgp fast-external-failover" configuration. */
1758DEFUN (bgp_fast_external_failover,
1759 bgp_fast_external_failover_cmd,
1760 "bgp fast-external-failover",
1761 BGP_STR
1762 "Immediately reset session if a link to a directly connected external peer goes down\n")
1763{
1764 struct bgp *bgp;
1765
1766 bgp = vty->index;
1767 bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
1768 return CMD_SUCCESS;
1769}
1770
1771DEFUN (no_bgp_fast_external_failover,
1772 no_bgp_fast_external_failover_cmd,
1773 "no bgp fast-external-failover",
1774 NO_STR
1775 BGP_STR
1776 "Immediately reset session if a link to a directly connected external peer goes down\n")
1777{
1778 struct bgp *bgp;
1779
1780 bgp = vty->index;
1781 bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
1782 return CMD_SUCCESS;
1783}
6b0655a2 1784
718e3744 1785/* "bgp enforce-first-as" configuration. */
1786DEFUN (bgp_enforce_first_as,
1787 bgp_enforce_first_as_cmd,
1788 "bgp enforce-first-as",
1789 BGP_STR
1790 "Enforce the first AS for EBGP routes\n")
1791{
1792 struct bgp *bgp;
1793
1794 bgp = vty->index;
1795 bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
7aafcaca
DS
1796 bgp_clear_star_soft_in (vty);
1797
718e3744 1798 return CMD_SUCCESS;
1799}
1800
1801DEFUN (no_bgp_enforce_first_as,
1802 no_bgp_enforce_first_as_cmd,
1803 "no bgp enforce-first-as",
1804 NO_STR
1805 BGP_STR
1806 "Enforce the first AS for EBGP routes\n")
1807{
1808 struct bgp *bgp;
1809
1810 bgp = vty->index;
1811 bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
7aafcaca
DS
1812 bgp_clear_star_soft_in (vty);
1813
718e3744 1814 return CMD_SUCCESS;
1815}
6b0655a2 1816
718e3744 1817/* "bgp bestpath compare-routerid" configuration. */
1818DEFUN (bgp_bestpath_compare_router_id,
1819 bgp_bestpath_compare_router_id_cmd,
1820 "bgp bestpath compare-routerid",
1821 "BGP specific commands\n"
1822 "Change the default bestpath selection\n"
1823 "Compare router-id for identical EBGP paths\n")
1824{
1825 struct bgp *bgp;
1826
1827 bgp = vty->index;
1828 bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
7aafcaca
DS
1829 bgp_recalculate_all_bestpaths (bgp);
1830
718e3744 1831 return CMD_SUCCESS;
1832}
1833
1834DEFUN (no_bgp_bestpath_compare_router_id,
1835 no_bgp_bestpath_compare_router_id_cmd,
1836 "no bgp bestpath compare-routerid",
1837 NO_STR
1838 "BGP specific commands\n"
1839 "Change the default bestpath selection\n"
1840 "Compare router-id for identical EBGP paths\n")
1841{
1842 struct bgp *bgp;
1843
1844 bgp = vty->index;
1845 bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
7aafcaca
DS
1846 bgp_recalculate_all_bestpaths (bgp);
1847
718e3744 1848 return CMD_SUCCESS;
1849}
6b0655a2 1850
718e3744 1851/* "bgp bestpath as-path ignore" configuration. */
1852DEFUN (bgp_bestpath_aspath_ignore,
1853 bgp_bestpath_aspath_ignore_cmd,
1854 "bgp bestpath as-path ignore",
1855 "BGP specific commands\n"
1856 "Change the default bestpath selection\n"
1857 "AS-path attribute\n"
1858 "Ignore as-path length in selecting a route\n")
1859{
1860 struct bgp *bgp;
1861
1862 bgp = vty->index;
1863 bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE);
7aafcaca
DS
1864 bgp_recalculate_all_bestpaths (bgp);
1865
718e3744 1866 return CMD_SUCCESS;
1867}
1868
1869DEFUN (no_bgp_bestpath_aspath_ignore,
1870 no_bgp_bestpath_aspath_ignore_cmd,
1871 "no bgp bestpath as-path ignore",
1872 NO_STR
1873 "BGP specific commands\n"
1874 "Change the default bestpath selection\n"
1875 "AS-path attribute\n"
1876 "Ignore as-path length in selecting a route\n")
1877{
1878 struct bgp *bgp;
1879
1880 bgp = vty->index;
1881 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE);
7aafcaca
DS
1882 bgp_recalculate_all_bestpaths (bgp);
1883
718e3744 1884 return CMD_SUCCESS;
1885}
6b0655a2 1886
6811845b 1887/* "bgp bestpath as-path confed" configuration. */
1888DEFUN (bgp_bestpath_aspath_confed,
1889 bgp_bestpath_aspath_confed_cmd,
1890 "bgp bestpath as-path confed",
1891 "BGP specific commands\n"
1892 "Change the default bestpath selection\n"
1893 "AS-path attribute\n"
1894 "Compare path lengths including confederation sets & sequences in selecting a route\n")
1895{
1896 struct bgp *bgp;
1897
1898 bgp = vty->index;
1899 bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED);
7aafcaca
DS
1900 bgp_recalculate_all_bestpaths (bgp);
1901
6811845b 1902 return CMD_SUCCESS;
1903}
1904
1905DEFUN (no_bgp_bestpath_aspath_confed,
1906 no_bgp_bestpath_aspath_confed_cmd,
1907 "no bgp bestpath as-path confed",
1908 NO_STR
1909 "BGP specific commands\n"
1910 "Change the default bestpath selection\n"
1911 "AS-path attribute\n"
1912 "Compare path lengths including confederation sets & sequences in selecting a route\n")
1913{
1914 struct bgp *bgp;
1915
1916 bgp = vty->index;
1917 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED);
7aafcaca
DS
1918 bgp_recalculate_all_bestpaths (bgp);
1919
6811845b 1920 return CMD_SUCCESS;
1921}
6b0655a2 1922
2fdd455c
PM
1923/* "bgp bestpath as-path multipath-relax" configuration. */
1924DEFUN (bgp_bestpath_aspath_multipath_relax,
1925 bgp_bestpath_aspath_multipath_relax_cmd,
219178b6 1926 "bgp bestpath as-path multipath-relax {as-set|no-as-set}",
16fc1eec
DS
1927 "BGP specific commands\n"
1928 "Change the default bestpath selection\n"
1929 "AS-path attribute\n"
1930 "Allow load sharing across routes that have different AS paths (but same length)\n"
219178b6 1931 "Generate an AS_SET\n"
16fc1eec
DS
1932 "Do not generate an AS_SET\n")
1933{
1934 struct bgp *bgp;
1935
1936 bgp = vty->index;
1937 bgp_flag_set (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
219178b6
DW
1938
1939 /* no-as-set is now the default behavior so we can silently
1940 * ignore it */
1941 if (argv[0] != NULL && strncmp (argv[0], "a", 1) == 0)
1942 bgp_flag_set (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
1943 else
1944 bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET) ;
1945
7aafcaca
DS
1946 bgp_recalculate_all_bestpaths (bgp);
1947
16fc1eec
DS
1948 return CMD_SUCCESS;
1949}
1950
219178b6
DW
1951DEFUN (no_bgp_bestpath_aspath_multipath_relax,
1952 no_bgp_bestpath_aspath_multipath_relax_cmd,
1953 "no bgp bestpath as-path multipath-relax {as-set|no-as-set}",
16fc1eec
DS
1954 NO_STR
1955 "BGP specific commands\n"
1956 "Change the default bestpath selection\n"
1957 "AS-path attribute\n"
1958 "Allow load sharing across routes that have different AS paths (but same length)\n"
219178b6 1959 "Generate an AS_SET\n"
16fc1eec
DS
1960 "Do not generate an AS_SET\n")
1961{
1962 struct bgp *bgp;
1963
1964 bgp = vty->index;
1965 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
219178b6 1966 bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
7aafcaca
DS
1967 bgp_recalculate_all_bestpaths (bgp);
1968
2fdd455c
PM
1969 return CMD_SUCCESS;
1970}
6b0655a2 1971
848973c7 1972/* "bgp log-neighbor-changes" configuration. */
1973DEFUN (bgp_log_neighbor_changes,
1974 bgp_log_neighbor_changes_cmd,
1975 "bgp log-neighbor-changes",
1976 "BGP specific commands\n"
1977 "Log neighbor up/down and reset reason\n")
1978{
1979 struct bgp *bgp;
1980
1981 bgp = vty->index;
1982 bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
1983 return CMD_SUCCESS;
1984}
1985
1986DEFUN (no_bgp_log_neighbor_changes,
1987 no_bgp_log_neighbor_changes_cmd,
1988 "no bgp log-neighbor-changes",
1989 NO_STR
1990 "BGP specific commands\n"
1991 "Log neighbor up/down and reset reason\n")
1992{
1993 struct bgp *bgp;
1994
1995 bgp = vty->index;
1996 bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
1997 return CMD_SUCCESS;
1998}
6b0655a2 1999
718e3744 2000/* "bgp bestpath med" configuration. */
2001DEFUN (bgp_bestpath_med,
2002 bgp_bestpath_med_cmd,
2003 "bgp bestpath med (confed|missing-as-worst)",
2004 "BGP specific commands\n"
2005 "Change the default bestpath selection\n"
2006 "MED attribute\n"
2007 "Compare MED among confederation paths\n"
2008 "Treat missing MED as the least preferred one\n")
2009{
2010 struct bgp *bgp;
2011
2012 bgp = vty->index;
2013
2014 if (strncmp (argv[0], "confed", 1) == 0)
2015 bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
2016 else
2017 bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
2018
7aafcaca
DS
2019 bgp_recalculate_all_bestpaths (bgp);
2020
718e3744 2021 return CMD_SUCCESS;
2022}
2023
2024DEFUN (bgp_bestpath_med2,
2025 bgp_bestpath_med2_cmd,
2026 "bgp bestpath med confed missing-as-worst",
2027 "BGP specific commands\n"
2028 "Change the default bestpath selection\n"
2029 "MED attribute\n"
2030 "Compare MED among confederation paths\n"
2031 "Treat missing MED as the least preferred one\n")
2032{
2033 struct bgp *bgp;
2034
2035 bgp = vty->index;
2036 bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
2037 bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
7aafcaca
DS
2038 bgp_recalculate_all_bestpaths (bgp);
2039
718e3744 2040 return CMD_SUCCESS;
2041}
2042
2043ALIAS (bgp_bestpath_med2,
2044 bgp_bestpath_med3_cmd,
2045 "bgp bestpath med missing-as-worst confed",
2046 "BGP specific commands\n"
2047 "Change the default bestpath selection\n"
2048 "MED attribute\n"
2049 "Treat missing MED as the least preferred one\n"
2050 "Compare MED among confederation paths\n")
2051
2052DEFUN (no_bgp_bestpath_med,
2053 no_bgp_bestpath_med_cmd,
2054 "no bgp bestpath med (confed|missing-as-worst)",
2055 NO_STR
2056 "BGP specific commands\n"
2057 "Change the default bestpath selection\n"
2058 "MED attribute\n"
2059 "Compare MED among confederation paths\n"
2060 "Treat missing MED as the least preferred one\n")
2061{
2062 struct bgp *bgp;
2063
2064 bgp = vty->index;
2065
2066 if (strncmp (argv[0], "confed", 1) == 0)
2067 bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
2068 else
2069 bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
2070
7aafcaca
DS
2071 bgp_recalculate_all_bestpaths (bgp);
2072
718e3744 2073 return CMD_SUCCESS;
2074}
2075
2076DEFUN (no_bgp_bestpath_med2,
2077 no_bgp_bestpath_med2_cmd,
2078 "no bgp bestpath med confed missing-as-worst",
2079 NO_STR
2080 "BGP specific commands\n"
2081 "Change the default bestpath selection\n"
2082 "MED attribute\n"
2083 "Compare MED among confederation paths\n"
2084 "Treat missing MED as the least preferred one\n")
2085{
2086 struct bgp *bgp;
2087
2088 bgp = vty->index;
2089 bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
2090 bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
7aafcaca
DS
2091 bgp_recalculate_all_bestpaths (bgp);
2092
718e3744 2093 return CMD_SUCCESS;
2094}
2095
2096ALIAS (no_bgp_bestpath_med2,
2097 no_bgp_bestpath_med3_cmd,
2098 "no bgp bestpath med missing-as-worst confed",
2099 NO_STR
2100 "BGP specific commands\n"
2101 "Change the default bestpath selection\n"
2102 "MED attribute\n"
2103 "Treat missing MED as the least preferred one\n"
2104 "Compare MED among confederation paths\n")
6b0655a2 2105
718e3744 2106/* "no bgp default ipv4-unicast". */
2107DEFUN (no_bgp_default_ipv4_unicast,
2108 no_bgp_default_ipv4_unicast_cmd,
2109 "no bgp default ipv4-unicast",
2110 NO_STR
2111 "BGP specific commands\n"
2112 "Configure BGP defaults\n"
2113 "Activate ipv4-unicast for a peer by default\n")
2114{
2115 struct bgp *bgp;
2116
2117 bgp = vty->index;
2118 bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
2119 return CMD_SUCCESS;
2120}
2121
2122DEFUN (bgp_default_ipv4_unicast,
2123 bgp_default_ipv4_unicast_cmd,
2124 "bgp default ipv4-unicast",
2125 "BGP specific commands\n"
2126 "Configure BGP defaults\n"
2127 "Activate ipv4-unicast for a peer by default\n")
2128{
2129 struct bgp *bgp;
2130
2131 bgp = vty->index;
2132 bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
2133 return CMD_SUCCESS;
2134}
6b0655a2 2135
04b6bdc0
DW
2136/* Display hostname in certain command outputs */
2137DEFUN (bgp_default_show_hostname,
2138 bgp_default_show_hostname_cmd,
2139 "bgp default show-hostname",
2140 "BGP specific commands\n"
2141 "Configure BGP defaults\n"
2142 "Show hostname in certain command ouputs\n")
2143{
2144 struct bgp *bgp;
2145
2146 bgp = vty->index;
2147 bgp_flag_set (bgp, BGP_FLAG_SHOW_HOSTNAME);
2148 return CMD_SUCCESS;
2149}
2150
2151DEFUN (no_bgp_default_show_hostname,
2152 no_bgp_default_show_hostname_cmd,
2153 "no bgp default show-hostname",
2154 NO_STR
2155 "BGP specific commands\n"
2156 "Configure BGP defaults\n"
2157 "Show hostname in certain command ouputs\n")
2158{
2159 struct bgp *bgp;
2160
2161 bgp = vty->index;
2162 bgp_flag_unset (bgp, BGP_FLAG_SHOW_HOSTNAME);
2163 return CMD_SUCCESS;
2164}
2165
718e3744 2166/* "bgp import-check" configuration. */
2167DEFUN (bgp_network_import_check,
2168 bgp_network_import_check_cmd,
5623e905 2169 "bgp network import-check",
718e3744 2170 "BGP specific commands\n"
2171 "BGP network command\n"
5623e905 2172 "Check BGP network route exists in IGP\n")
718e3744 2173{
2174 struct bgp *bgp;
2175
2176 bgp = vty->index;
078430f6
DS
2177 if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK))
2178 {
2179 bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK);
5623e905 2180 bgp_static_redo_import_check(bgp);
078430f6
DS
2181 }
2182
718e3744 2183 return CMD_SUCCESS;
2184}
2185
2186DEFUN (no_bgp_network_import_check,
2187 no_bgp_network_import_check_cmd,
5623e905 2188 "no bgp network import-check",
718e3744 2189 NO_STR
2190 "BGP specific commands\n"
2191 "BGP network command\n"
2192 "Check BGP network route exists in IGP\n")
2193{
2194 struct bgp *bgp;
2195
2196 bgp = vty->index;
078430f6
DS
2197 if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK))
2198 {
2199 bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK);
078430f6
DS
2200 bgp_static_redo_import_check(bgp);
2201 }
5623e905 2202
718e3744 2203 return CMD_SUCCESS;
2204}
6b0655a2 2205
718e3744 2206DEFUN (bgp_default_local_preference,
2207 bgp_default_local_preference_cmd,
2208 "bgp default local-preference <0-4294967295>",
2209 "BGP specific commands\n"
2210 "Configure BGP defaults\n"
2211 "local preference (higher=more preferred)\n"
2212 "Configure default local preference value\n")
2213{
2214 struct bgp *bgp;
2215 u_int32_t local_pref;
2216
2217 bgp = vty->index;
2218
2219 VTY_GET_INTEGER ("local preference", local_pref, argv[0]);
2220
2221 bgp_default_local_preference_set (bgp, local_pref);
7aafcaca 2222 bgp_clear_star_soft_in (vty);
718e3744 2223
2224 return CMD_SUCCESS;
2225}
2226
2227DEFUN (no_bgp_default_local_preference,
2228 no_bgp_default_local_preference_cmd,
2229 "no bgp default local-preference",
2230 NO_STR
2231 "BGP specific commands\n"
2232 "Configure BGP defaults\n"
2233 "local preference (higher=more preferred)\n")
2234{
2235 struct bgp *bgp;
2236
2237 bgp = vty->index;
2238 bgp_default_local_preference_unset (bgp);
7aafcaca
DS
2239 bgp_clear_star_soft_in (vty);
2240
718e3744 2241 return CMD_SUCCESS;
2242}
2243
2244ALIAS (no_bgp_default_local_preference,
2245 no_bgp_default_local_preference_val_cmd,
2246 "no bgp default local-preference <0-4294967295>",
2247 NO_STR
2248 "BGP specific commands\n"
2249 "Configure BGP defaults\n"
2250 "local preference (higher=more preferred)\n"
2251 "Configure default local preference value\n")
6b0655a2 2252
3f9c7369
DS
2253DEFUN (bgp_default_subgroup_pkt_queue_max,
2254 bgp_default_subgroup_pkt_queue_max_cmd,
2255 "bgp default subgroup-pkt-queue-max <20-100>",
2256 "BGP specific commands\n"
2257 "Configure BGP defaults\n"
2258 "subgroup-pkt-queue-max\n"
2259 "Configure subgroup packet queue max\n")
8bd9d948 2260{
3f9c7369
DS
2261 struct bgp *bgp;
2262 u_int32_t max_size;
8bd9d948 2263
3f9c7369
DS
2264 bgp = vty->index;
2265
2266 VTY_GET_INTEGER ("subgroup packet queue max", max_size, argv[0]);
2267
2268 bgp_default_subgroup_pkt_queue_max_set (bgp, max_size);
2269
2270 return CMD_SUCCESS;
2271}
2272
2273DEFUN (no_bgp_default_subgroup_pkt_queue_max,
2274 no_bgp_default_subgroup_pkt_queue_max_cmd,
2275 "no bgp default subgroup-pkt-queue-max",
2276 NO_STR
2277 "BGP specific commands\n"
2278 "Configure BGP defaults\n"
2279 "subgroup-pkt-queue-max\n")
2280{
2281 struct bgp *bgp;
2282
2283 bgp = vty->index;
2284 bgp_default_subgroup_pkt_queue_max_unset (bgp);
2285 return CMD_SUCCESS;
8bd9d948
DS
2286}
2287
813d4307
DW
2288ALIAS (no_bgp_default_subgroup_pkt_queue_max,
2289 no_bgp_default_subgroup_pkt_queue_max_val_cmd,
2290 "no bgp default subgroup-pkt-queue-max <20-100>",
2291 NO_STR
2292 "BGP specific commands\n"
2293 "Configure BGP defaults\n"
2294 "subgroup-pkt-queue-max\n"
2295 "Configure subgroup packet queue max\n")
2296
8bd9d948
DS
2297DEFUN (bgp_rr_allow_outbound_policy,
2298 bgp_rr_allow_outbound_policy_cmd,
2299 "bgp route-reflector allow-outbound-policy",
2300 "BGP specific commands\n"
2301 "Allow modifications made by out route-map\n"
2302 "on ibgp neighbors\n")
2303{
2304 struct bgp *bgp;
8bd9d948
DS
2305
2306 bgp = vty->index;
2307
2308 if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY))
2309 {
2310 bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
3f9c7369 2311 update_group_announce_rrclients(bgp);
7aafcaca 2312 bgp_clear_star_soft_out (vty);
8bd9d948
DS
2313 }
2314
2315 return CMD_SUCCESS;
2316}
2317
2318DEFUN (no_bgp_rr_allow_outbound_policy,
2319 no_bgp_rr_allow_outbound_policy_cmd,
2320 "no bgp route-reflector allow-outbound-policy",
2321 NO_STR
2322 "BGP specific commands\n"
2323 "Allow modifications made by out route-map\n"
2324 "on ibgp neighbors\n")
2325{
2326 struct bgp *bgp;
8bd9d948
DS
2327
2328 bgp = vty->index;
2329
2330 if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY))
2331 {
2332 bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
3f9c7369 2333 update_group_announce_rrclients(bgp);
7aafcaca 2334 bgp_clear_star_soft_out (vty);
8bd9d948
DS
2335 }
2336
2337 return CMD_SUCCESS;
2338}
2339
f14e6fdb
DS
2340DEFUN (bgp_listen_limit,
2341 bgp_listen_limit_cmd,
2342 "bgp listen limit " DYNAMIC_NEIGHBOR_LIMIT_RANGE,
2343 "BGP specific commands\n"
2344 "Configure BGP defaults\n"
2345 "maximum number of BGP Dynamic Neighbors that can be created\n"
2346 "Configure Dynamic Neighbors listen limit value\n")
2347{
2348 struct bgp *bgp;
2349 int listen_limit;
2350
2351 bgp = vty->index;
2352
2353 VTY_GET_INTEGER_RANGE ("listen limit", listen_limit, argv[0],
2354 BGP_DYNAMIC_NEIGHBORS_LIMIT_MIN,
2355 BGP_DYNAMIC_NEIGHBORS_LIMIT_MAX);
2356
2357 bgp_listen_limit_set (bgp, listen_limit);
2358
2359 return CMD_SUCCESS;
2360}
2361
2362DEFUN (no_bgp_listen_limit,
2363 no_bgp_listen_limit_cmd,
2364 "no bgp listen limit",
2365 "BGP specific commands\n"
2366 "Configure BGP defaults\n"
2367 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2368 "Configure Dynamic Neighbors listen limit value to default\n")
2369{
2370 struct bgp *bgp;
2371
2372 bgp = vty->index;
2373 bgp_listen_limit_unset (bgp);
2374 return CMD_SUCCESS;
2375}
2376
813d4307
DW
2377ALIAS (no_bgp_listen_limit,
2378 no_bgp_listen_limit_val_cmd,
2379 "no bgp listen limit " DYNAMIC_NEIGHBOR_LIMIT_RANGE,
2380 NO_STR
2381 "BGP specific commands\n"
2382 "Configure BGP defaults\n"
2383 "maximum number of BGP Dynamic Neighbors that can be created\n"
2384 "Configure Dynamic Neighbors listen limit value\n")
f14e6fdb 2385
20eb8864 2386/*
2387 * Check if this listen range is already configured. Check for exact
2388 * match or overlap based on input.
2389 */
2390static struct peer_group *
2391listen_range_exists (struct bgp *bgp, struct prefix *range, int exact)
2392{
2393 struct listnode *node, *nnode;
2394 struct listnode *node1, *nnode1;
2395 struct peer_group *group;
2396 struct prefix *lr;
2397 afi_t afi;
2398 int match;
2399
2400 afi = family2afi(range->family);
2401 for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
2402 {
2403 for (ALL_LIST_ELEMENTS (group->listen_range[afi], node1,
2404 nnode1, lr))
2405 {
2406 if (exact)
2407 match = prefix_same (range, lr);
2408 else
2409 match = (prefix_match (range, lr) || prefix_match (lr, range));
2410 if (match)
2411 return group;
2412 }
2413 }
2414
2415 return NULL;
2416}
2417
f14e6fdb
DS
2418DEFUN (bgp_listen_range,
2419 bgp_listen_range_cmd,
2420 LISTEN_RANGE_CMD "peer-group WORD" ,
2421 "BGP specific commands\n"
2422 "Configure BGP Dynamic Neighbors\n"
2423 "add a listening range for Dynamic Neighbors\n"
2424 LISTEN_RANGE_ADDR_STR)
2425{
2426 struct bgp *bgp;
2427 struct prefix range;
20eb8864 2428 struct peer_group *group, *existing_group;
f14e6fdb
DS
2429 afi_t afi;
2430 int ret;
2431
2432 bgp = vty->index;
2433
2434 //VTY_GET_IPV4_PREFIX ("listen range", range, argv[0]);
2435
2436 /* Convert IP prefix string to struct prefix. */
2437 ret = str2prefix (argv[0], &range);
2438 if (! ret)
2439 {
2440 vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE);
2441 return CMD_WARNING;
2442 }
2443
2444 afi = family2afi(range.family);
2445
2446#ifdef HAVE_IPV6
2447 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6))
2448 {
2449 vty_out (vty, "%% Malformed listen range (link-local address)%s",
2450 VTY_NEWLINE);
2451 return CMD_WARNING;
2452 }
2453#endif /* HAVE_IPV6 */
2454
2455 apply_mask (&range);
2456
20eb8864 2457 /* Check if same listen range is already configured. */
2458 existing_group = listen_range_exists (bgp, &range, 1);
2459 if (existing_group)
2460 {
2461 if (strcmp (existing_group->name, argv[1]) == 0)
2462 return CMD_SUCCESS;
2463 else
2464 {
2465 vty_out (vty, "%% Same listen range is attached to peer-group %s%s",
2466 existing_group->name, VTY_NEWLINE);
2467 return CMD_WARNING;
2468 }
2469 }
2470
2471 /* Check if an overlapping listen range exists. */
2472 if (listen_range_exists (bgp, &range, 0))
2473 {
2474 vty_out (vty, "%% Listen range overlaps with existing listen range%s",
2475 VTY_NEWLINE);
2476 return CMD_WARNING;
2477 }
f14e6fdb
DS
2478
2479 group = peer_group_lookup (bgp, argv[1]);
2480 if (! group)
2481 {
2482 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
2483 return CMD_WARNING;
2484 }
2485
2486 ret = peer_group_listen_range_add(group, &range);
2487 return bgp_vty_return (vty, ret);
2488}
2489
2490DEFUN (no_bgp_listen_range,
2491 no_bgp_listen_range_cmd,
2492 "no bgp listen range A.B.C.D/M peer-group WORD" ,
2493 "BGP specific commands\n"
2494 "Configure BGP defaults\n"
2495 "delete a listening range for Dynamic Neighbors\n"
2496 "Remove Dynamic Neighbors listening range\n")
2497{
2498 struct bgp *bgp;
2499 struct prefix range;
2500 struct peer_group *group;
2501 afi_t afi;
2502 int ret;
2503
2504 bgp = vty->index;
2505
2506 // VTY_GET_IPV4_PREFIX ("listen range", range, argv[0]);
2507
2508 /* Convert IP prefix string to struct prefix. */
2509 ret = str2prefix (argv[0], &range);
2510 if (! ret)
2511 {
2512 vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE);
2513 return CMD_WARNING;
2514 }
2515
2516 afi = family2afi(range.family);
2517
2518#ifdef HAVE_IPV6
2519 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6))
2520 {
2521 vty_out (vty, "%% Malformed listen range (link-local address)%s",
2522 VTY_NEWLINE);
2523 return CMD_WARNING;
2524 }
2525#endif /* HAVE_IPV6 */
2526
2527 apply_mask (&range);
2528
2529
2530 group = peer_group_lookup (bgp, argv[1]);
2531 if (! group)
2532 {
2533 vty_out (vty, "%% Peer-group does not exist%s", VTY_NEWLINE);
2534 return CMD_WARNING;
2535 }
2536
2537 ret = peer_group_listen_range_del(group, &range);
2538 return bgp_vty_return (vty, ret);
2539}
2540
2541int
2542bgp_config_write_listen (struct vty *vty, struct bgp *bgp)
2543{
2544 struct peer_group *group;
2545 struct listnode *node, *nnode, *rnode, *nrnode;
2546 struct prefix *range;
2547 afi_t afi;
4690c7d7 2548 char buf[PREFIX2STR_BUFFER];
f14e6fdb
DS
2549
2550 if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT)
2551 vty_out (vty, " bgp listen limit %d%s",
2552 bgp->dynamic_neighbors_limit, VTY_NEWLINE);
2553
2554 for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
2555 {
2556 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2557 {
2558 for (ALL_LIST_ELEMENTS (group->listen_range[afi], rnode, nrnode, range))
2559 {
2560 prefix2str(range, buf, sizeof(buf));
2561 vty_out(vty, " bgp listen range %s peer-group %s%s",
2562 buf, group->name, VTY_NEWLINE);
2563 }
2564 }
2565 }
2566
2567 return 0;
2568}
2569
2570
907f92c8
DS
2571DEFUN (bgp_disable_connected_route_check,
2572 bgp_disable_connected_route_check_cmd,
2573 "bgp disable-ebgp-connected-route-check",
2574 "BGP specific commands\n"
2575 "Disable checking if nexthop is connected on ebgp sessions\n")
2576{
2577 struct bgp *bgp;
2578
2579 bgp = vty->index;
2580 bgp_flag_set (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
7aafcaca
DS
2581 bgp_clear_star_soft_in (vty);
2582
907f92c8
DS
2583 return CMD_SUCCESS;
2584}
2585
2586DEFUN (no_bgp_disable_connected_route_check,
2587 no_bgp_disable_connected_route_check_cmd,
2588 "no bgp disable-ebgp-connected-route-check",
2589 NO_STR
2590 "BGP specific commands\n"
2591 "Disable checking if nexthop is connected on ebgp sessions\n")
2592{
2593 struct bgp *bgp;
2594
2595 bgp = vty->index;
2596 bgp_flag_unset (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
7aafcaca
DS
2597 bgp_clear_star_soft_in (vty);
2598
907f92c8
DS
2599 return CMD_SUCCESS;
2600}
2601
2602
718e3744 2603static int
fd79ac91 2604peer_remote_as_vty (struct vty *vty, const char *peer_str,
2605 const char *as_str, afi_t afi, safi_t safi)
718e3744 2606{
2607 int ret;
2608 struct bgp *bgp;
2609 as_t as;
0299c004 2610 int as_type = AS_SPECIFIED;
718e3744 2611 union sockunion su;
2612
2613 bgp = vty->index;
2614
0299c004
DS
2615 if (strncmp(as_str, "internal", strlen("internal")) == 0)
2616 {
2617 as = 0;
2618 as_type = AS_INTERNAL;
2619 }
2620 else if (strncmp(as_str, "external", strlen("external")) == 0)
2621 {
2622 as = 0;
2623 as_type = AS_EXTERNAL;
2624 }
2625 else
2626 {
2627 /* Get AS number. */
2628 VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX);
2629 }
718e3744 2630
2631 /* If peer is peer group, call proper function. */
2632 ret = str2sockunion (peer_str, &su);
2633 if (ret < 0)
2634 {
a80beece 2635 /* Check for peer by interface */
0299c004 2636 ret = peer_remote_as (bgp, NULL, peer_str, &as, as_type, afi, safi);
718e3744 2637 if (ret < 0)
a80beece 2638 {
0299c004 2639 ret = peer_group_remote_as (bgp, peer_str, &as, as_type);
a80beece
DS
2640 if (ret < 0)
2641 {
2642 vty_out (vty, "%% Create the peer-group or interface first%s",
2643 VTY_NEWLINE);
2644 return CMD_WARNING;
2645 }
2646 return CMD_SUCCESS;
2647 }
718e3744 2648 }
a80beece 2649 else
718e3744 2650 {
6aeb9e78 2651 if (peer_address_self_check (bgp, &su))
a80beece
DS
2652 {
2653 vty_out (vty, "%% Can not configure the local system as neighbor%s",
2654 VTY_NEWLINE);
2655 return CMD_WARNING;
2656 }
0299c004 2657 ret = peer_remote_as (bgp, &su, NULL, &as, as_type, afi, safi);
718e3744 2658 }
2659
718e3744 2660 /* This peer belongs to peer group. */
2661 switch (ret)
2662 {
2663 case BGP_ERR_PEER_GROUP_MEMBER:
aea339f7 2664 vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTY_NEWLINE);
718e3744 2665 return CMD_WARNING;
718e3744 2666 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT:
aea339f7 2667 vty_out (vty, "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external%s", as, as_str, VTY_NEWLINE);
718e3744 2668 return CMD_WARNING;
718e3744 2669 }
2670 return bgp_vty_return (vty, ret);
2671}
2672
2673DEFUN (neighbor_remote_as,
2674 neighbor_remote_as_cmd,
0299c004 2675 NEIGHBOR_CMD2 "remote-as (" CMD_AS_RANGE "|external|internal)",
718e3744 2676 NEIGHBOR_STR
2677 NEIGHBOR_ADDR_STR2
2678 "Specify a BGP neighbor\n"
2679 AS_STR)
2680{
2681 return peer_remote_as_vty (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST);
2682}
6b0655a2 2683
4c48cf63
DW
2684static int
2685peer_conf_interface_get (struct vty *vty, const char *conf_if, afi_t afi,
2686 safi_t safi, int v6only, const char *peer_group_name)
a80beece 2687{
4c48cf63 2688 as_t as;
a80beece
DS
2689 struct bgp *bgp;
2690 struct peer *peer;
2691 struct peer_group *group;
4c48cf63
DW
2692 int ret = 0;
2693 union sockunion su;
a80beece
DS
2694
2695 bgp = vty->index;
4c48cf63
DW
2696 group = peer_group_lookup (bgp, conf_if);
2697
a80beece
DS
2698 if (group)
2699 {
2700 vty_out (vty, "%% Name conflict with peer-group %s", VTY_NEWLINE);
2701 return CMD_WARNING;
2702 }
2703
4c48cf63
DW
2704 peer = peer_lookup_by_conf_if (bgp, conf_if);
2705 if (!peer)
2706 {
2707 if (bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4)
2708 && afi == AFI_IP && safi == SAFI_UNICAST)
f813b13b 2709 peer = peer_create (NULL, conf_if, bgp, bgp->as, 0, AS_UNSPECIFIED, 0, 0, NULL);
4c48cf63 2710 else
f813b13b 2711 peer = peer_create (NULL, conf_if, bgp, bgp->as, 0, AS_UNSPECIFIED, afi, safi, NULL);
4c48cf63
DW
2712
2713 if (peer && v6only)
2714 SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY);
4a04e5f7 2715
2716 /* Request zebra to initiate IPv6 RAs on this interface. We do this
2717 * any unnumbered peer in order to not worry about run-time transitions
2718 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 address
2719 * gets deleted later etc.)
2720 */
2721 if (peer->ifp)
2722 bgp_zebra_initiate_radv (bgp, peer);
4c48cf63
DW
2723 }
2724 else if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) ||
2725 (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)))
2726 {
2727 if (v6only)
2728 SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY);
2729 else
2730 UNSET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY);
2731
2732 /* v6only flag changed. Reset bgp seesion */
2733 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status))
2734 {
2735 peer->last_reset = PEER_DOWN_V6ONLY_CHANGE;
2736 bgp_notify_send (peer, BGP_NOTIFY_CEASE,
2737 BGP_NOTIFY_CEASE_CONFIG_CHANGE);
2738 }
2739 else
2740 bgp_session_reset(peer);
2741 }
2742
a80beece
DS
2743 if (!peer)
2744 return CMD_WARNING;
2745
4c48cf63
DW
2746 if (peer_group_name)
2747 {
2748 group = peer_group_lookup (bgp, peer_group_name);
2749 if (! group)
2750 {
2751 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
2752 return CMD_WARNING;
2753 }
2754
2755 ret = peer_group_bind (bgp, &su, peer, group, &as);
2756 }
2757
2758 return bgp_vty_return (vty, ret);
a80beece
DS
2759}
2760
4c48cf63
DW
2761DEFUN (neighbor_interface_config,
2762 neighbor_interface_config_cmd,
2763 "neighbor WORD interface",
2764 NEIGHBOR_STR
2765 "Interface name or neighbor tag\n"
2766 "Enable BGP on interface\n")
2767{
2768 if (argc == 2)
2769 return peer_conf_interface_get (vty, argv[0], AFI_IP, SAFI_UNICAST, 0, argv[1]);
2770 else
2771 return peer_conf_interface_get (vty, argv[0], AFI_IP, SAFI_UNICAST, 0, NULL);
2772}
2773
2774ALIAS (neighbor_interface_config,
2775 neighbor_interface_config_peergroup_cmd,
2776 "neighbor WORD interface peer-group WORD",
2777 NEIGHBOR_STR
2778 "Interface name or neighbor tag\n"
2779 "Enable BGP on interface\n"
2780 "Member of the peer-group\n"
2781 "peer-group name\n")
2782
2783DEFUN (neighbor_interface_config_v6only,
2784 neighbor_interface_config_v6only_cmd,
2785 "neighbor WORD interface v6only",
2786 NEIGHBOR_STR
2787 "Interface name or neighbor tag\n"
2788 "Enable BGP on interface\n"
2789 "Enable BGP with v6 link-local only\n")
2790{
2791 if (argc == 2)
2792 return peer_conf_interface_get (vty, argv[0], AFI_IP, SAFI_UNICAST, 1, argv[1]);
2793 else
2794 return peer_conf_interface_get (vty, argv[0], AFI_IP, SAFI_UNICAST, 1, NULL);
2795}
2796
2797ALIAS (neighbor_interface_config_v6only,
2798 neighbor_interface_config_v6only_peergroup_cmd,
2799 "neighbor WORD interface v6only peer-group WORD",
2800 NEIGHBOR_STR
2801 "Interface name or neighbor tag\n"
2802 "Enable BGP on interface\n"
2803 "Enable BGP with v6 link-local only\n"
2804 "Member of the peer-group\n"
2805 "peer-group name\n")
a80beece 2806
718e3744 2807DEFUN (neighbor_peer_group,
2808 neighbor_peer_group_cmd,
2809 "neighbor WORD peer-group",
2810 NEIGHBOR_STR
a80beece 2811 "Interface name or neighbor tag\n"
718e3744 2812 "Configure peer-group\n")
2813{
2814 struct bgp *bgp;
a80beece 2815 struct peer *peer;
718e3744 2816 struct peer_group *group;
2817
2818 bgp = vty->index;
a80beece
DS
2819 peer = peer_lookup_by_conf_if (bgp, argv[0]);
2820 if (peer)
2821 {
2822 vty_out (vty, "%% Name conflict with interface: %s", VTY_NEWLINE);
2823 return CMD_WARNING;
2824 }
718e3744 2825
2826 group = peer_group_get (bgp, argv[0]);
2827 if (! group)
2828 return CMD_WARNING;
2829
2830 return CMD_SUCCESS;
2831}
2832
2833DEFUN (no_neighbor,
2834 no_neighbor_cmd,
2835 NO_NEIGHBOR_CMD2,
2836 NO_STR
2837 NEIGHBOR_STR
2838 NEIGHBOR_ADDR_STR2)
2839{
2840 int ret;
2841 union sockunion su;
2842 struct peer_group *group;
2843 struct peer *peer;
1ff9a340 2844 struct peer *other;
718e3744 2845
2846 ret = str2sockunion (argv[0], &su);
2847 if (ret < 0)
2848 {
a80beece
DS
2849 /* look up for neighbor by interface name config. */
2850 peer = peer_lookup_by_conf_if (vty->index, argv[0]);
2851 if (peer)
2852 {
4a04e5f7 2853 /* Request zebra to terminate IPv6 RAs on this interface. */
2854 if (peer->ifp)
2855 bgp_zebra_terminate_radv (peer->bgp, peer);
a80beece
DS
2856 peer_delete (peer);
2857 return CMD_SUCCESS;
2858 }
2859
718e3744 2860 group = peer_group_lookup (vty->index, argv[0]);
2861 if (group)
2862 peer_group_delete (group);
2863 else
2864 {
2865 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
2866 return CMD_WARNING;
2867 }
2868 }
2869 else
2870 {
2871 peer = peer_lookup (vty->index, &su);
2872 if (peer)
1ff9a340 2873 {
f14e6fdb
DS
2874 if (peer_dynamic_neighbor (peer))
2875 {
2876 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
2877 VTY_NEWLINE);
2878 return CMD_WARNING;
2879 }
2880
1ff9a340
DS
2881 other = peer->doppelganger;
2882 peer_delete (peer);
2883 if (other && other->status != Deleted)
2884 peer_delete(other);
2885 }
718e3744 2886 }
2887
2888 return CMD_SUCCESS;
2889}
2890
2891ALIAS (no_neighbor,
2892 no_neighbor_remote_as_cmd,
0299c004 2893 NO_NEIGHBOR_CMD "remote-as (" CMD_AS_RANGE "|internal|external)",
718e3744 2894 NO_STR
2895 NEIGHBOR_STR
2896 NEIGHBOR_ADDR_STR
2897 "Specify a BGP neighbor\n"
2898 AS_STR)
2899
a80beece
DS
2900DEFUN (no_neighbor_interface_config,
2901 no_neighbor_interface_config_cmd,
4c48cf63 2902 "no neighbor WORD interface",
a80beece
DS
2903 NO_STR
2904 NEIGHBOR_STR
2905 "Interface name\n"
2906 "Configure BGP on interface\n")
2907{
2908 struct peer *peer;
2909
2910 /* look up for neighbor by interface name config. */
2911 peer = peer_lookup_by_conf_if (vty->index, argv[0]);
2912 if (peer)
2913 {
4a04e5f7 2914 /* Request zebra to terminate IPv6 RAs on this interface. */
2915 if (peer->ifp)
2916 bgp_zebra_terminate_radv (peer->bgp, peer);
a80beece
DS
2917 peer_delete (peer);
2918 }
2919 else
2920 {
2921 vty_out (vty, "%% Create the bgp interface first%s", VTY_NEWLINE);
2922 return CMD_WARNING;
2923 }
2924 return CMD_SUCCESS;
2925}
2926
4c48cf63
DW
2927ALIAS (no_neighbor_interface_config,
2928 no_neighbor_interface_config_peergroup_cmd,
2929 "no neighbor WORD interface peer-group WORD",
2930 NO_STR
2931 NEIGHBOR_STR
2932 "Interface name\n"
2933 "Configure BGP on interface\n"
2934 "Member of the peer-group\n"
2935 "peer-group name\n")
2936
2937ALIAS (no_neighbor_interface_config,
2938 no_neighbor_interface_config_v6only_cmd,
2939 "no neighbor WORD interface v6only",
2940 NO_STR
2941 NEIGHBOR_STR
2942 "Interface name\n"
2943 "Configure BGP on interface\n"
2944 "Enable BGP with v6 link-local only\n")
2945
2946ALIAS (no_neighbor_interface_config,
2947 no_neighbor_interface_config_v6only_peergroup_cmd,
2948 "no neighbor WORD interface v6only peer-group WORD",
2949 NO_STR
2950 NEIGHBOR_STR
2951 "Interface name\n"
2952 "Configure BGP on interface\n"
2953 "Enable BGP with v6 link-local only\n"
2954 "Member of the peer-group\n"
2955 "peer-group name\n")
2956
2957
718e3744 2958DEFUN (no_neighbor_peer_group,
2959 no_neighbor_peer_group_cmd,
2960 "no neighbor WORD peer-group",
2961 NO_STR
2962 NEIGHBOR_STR
2963 "Neighbor tag\n"
2964 "Configure peer-group\n")
2965{
2966 struct peer_group *group;
2967
2968 group = peer_group_lookup (vty->index, argv[0]);
2969 if (group)
2970 peer_group_delete (group);
2971 else
2972 {
2973 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
2974 return CMD_WARNING;
2975 }
2976 return CMD_SUCCESS;
2977}
2978
a80beece
DS
2979DEFUN (no_neighbor_interface_peer_group_remote_as,
2980 no_neighbor_interface_peer_group_remote_as_cmd,
0299c004 2981 "no neighbor WORD remote-as (" CMD_AS_RANGE "|internal|external)",
718e3744 2982 NO_STR
2983 NEIGHBOR_STR
a80beece 2984 "Interface name or neighbor tag\n"
718e3744 2985 "Specify a BGP neighbor\n"
2986 AS_STR)
2987{
2988 struct peer_group *group;
a80beece
DS
2989 struct peer *peer;
2990
2991 /* look up for neighbor by interface name config. */
2992 peer = peer_lookup_by_conf_if (vty->index, argv[0]);
2993 if (peer)
2994 {
0299c004 2995 peer_as_change (peer, 0, AS_SPECIFIED);
a80beece
DS
2996 return CMD_SUCCESS;
2997 }
718e3744 2998
2999 group = peer_group_lookup (vty->index, argv[0]);
3000 if (group)
3001 peer_group_remote_as_delete (group);
3002 else
3003 {
a80beece 3004 vty_out (vty, "%% Create the peer-group or interface first%s", VTY_NEWLINE);
718e3744 3005 return CMD_WARNING;
3006 }
3007 return CMD_SUCCESS;
3008}
6b0655a2 3009
718e3744 3010DEFUN (neighbor_local_as,
3011 neighbor_local_as_cmd,
320da874 3012 NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
718e3744 3013 NEIGHBOR_STR
3014 NEIGHBOR_ADDR_STR2
3015 "Specify a local-as number\n"
3016 "AS number used as local AS\n")
3017{
3018 struct peer *peer;
3019 int ret;
3020
3021 peer = peer_and_group_lookup_vty (vty, argv[0]);
3022 if (! peer)
3023 return CMD_WARNING;
3024
9d3f9705 3025 ret = peer_local_as_set (peer, atoi (argv[1]), 0, 0);
718e3744 3026 return bgp_vty_return (vty, ret);
3027}
3028
3029DEFUN (neighbor_local_as_no_prepend,
3030 neighbor_local_as_no_prepend_cmd,
320da874 3031 NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
718e3744 3032 NEIGHBOR_STR
3033 NEIGHBOR_ADDR_STR2
3034 "Specify a local-as number\n"
3035 "AS number used as local AS\n"
3036 "Do not prepend local-as to updates from ebgp peers\n")
3037{
3038 struct peer *peer;
3039 int ret;
3040
3041 peer = peer_and_group_lookup_vty (vty, argv[0]);
3042 if (! peer)
3043 return CMD_WARNING;
3044
9d3f9705 3045 ret = peer_local_as_set (peer, atoi (argv[1]), 1, 0);
718e3744 3046 return bgp_vty_return (vty, ret);
3047}
3048
9d3f9705
AC
3049DEFUN (neighbor_local_as_no_prepend_replace_as,
3050 neighbor_local_as_no_prepend_replace_as_cmd,
3051 NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend replace-as",
3052 NEIGHBOR_STR
3053 NEIGHBOR_ADDR_STR2
3054 "Specify a local-as number\n"
3055 "AS number used as local AS\n"
3056 "Do not prepend local-as to updates from ebgp peers\n"
3057 "Do not prepend local-as to updates from ibgp peers\n")
3058{
3059 struct peer *peer;
3060 int ret;
3061
3062 peer = peer_and_group_lookup_vty (vty, argv[0]);
3063 if (! peer)
3064 return CMD_WARNING;
3065
3066 ret = peer_local_as_set (peer, atoi (argv[1]), 1, 1);
3067 return bgp_vty_return (vty, ret);
3068}
3069
3070
718e3744 3071DEFUN (no_neighbor_local_as,
3072 no_neighbor_local_as_cmd,
3073 NO_NEIGHBOR_CMD2 "local-as",
3074 NO_STR
3075 NEIGHBOR_STR
3076 NEIGHBOR_ADDR_STR2
3077 "Specify a local-as number\n")
3078{
3079 struct peer *peer;
3080 int ret;
3081
3082 peer = peer_and_group_lookup_vty (vty, argv[0]);
3083 if (! peer)
3084 return CMD_WARNING;
3085
3086 ret = peer_local_as_unset (peer);
3087 return bgp_vty_return (vty, ret);
3088}
3089
3090ALIAS (no_neighbor_local_as,
3091 no_neighbor_local_as_val_cmd,
320da874 3092 NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
718e3744 3093 NO_STR
3094 NEIGHBOR_STR
3095 NEIGHBOR_ADDR_STR2
3096 "Specify a local-as number\n"
3097 "AS number used as local AS\n")
3098
3099ALIAS (no_neighbor_local_as,
3100 no_neighbor_local_as_val2_cmd,
320da874 3101 NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
718e3744 3102 NO_STR
3103 NEIGHBOR_STR
3104 NEIGHBOR_ADDR_STR2
3105 "Specify a local-as number\n"
3106 "AS number used as local AS\n"
3107 "Do not prepend local-as to updates from ebgp peers\n")
9d3f9705
AC
3108
3109ALIAS (no_neighbor_local_as,
3110 no_neighbor_local_as_val3_cmd,
3111 NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend replace-as",
3112 NO_STR
3113 NEIGHBOR_STR
3114 NEIGHBOR_ADDR_STR2
3115 "Specify a local-as number\n"
3116 "AS number used as local AS\n"
3117 "Do not prepend local-as to updates from ebgp peers\n"
3118 "Do not prepend local-as to updates from ibgp peers\n")
6b0655a2 3119
3f9c7369
DS
3120DEFUN (neighbor_solo,
3121 neighbor_solo_cmd,
3122 NEIGHBOR_CMD2 "solo",
3123 NEIGHBOR_STR
3124 NEIGHBOR_ADDR_STR2
3125 "Solo peer - part of its own update group\n")
3126{
3127 struct peer *peer;
3128 int ret;
3129
3130 peer = peer_and_group_lookup_vty (vty, argv[0]);
3131 if (! peer)
3132 return CMD_WARNING;
3133
3134 ret = update_group_adjust_soloness(peer, 1);
3135 return bgp_vty_return (vty, ret);
3136}
3137
3138DEFUN (no_neighbor_solo,
3139 no_neighbor_solo_cmd,
3140 NO_NEIGHBOR_CMD2 "solo",
3141 NO_STR
3142 NEIGHBOR_STR
3143 NEIGHBOR_ADDR_STR2
3144 "Solo peer - part of its own update group\n")
3145{
3146 struct peer *peer;
3147 int ret;
3148
3149 peer = peer_and_group_lookup_vty (vty, argv[0]);
3150 if (! peer)
3151 return CMD_WARNING;
3152
3153 ret = update_group_adjust_soloness(peer, 0);
3154 return bgp_vty_return (vty, ret);
3155}
3156
0df7c91f
PJ
3157DEFUN (neighbor_password,
3158 neighbor_password_cmd,
3159 NEIGHBOR_CMD2 "password LINE",
3160 NEIGHBOR_STR
3161 NEIGHBOR_ADDR_STR2
3162 "Set a password\n"
3163 "The password\n")
3164{
3165 struct peer *peer;
3166 int ret;
3167
3168 peer = peer_and_group_lookup_vty (vty, argv[0]);
3169 if (! peer)
3170 return CMD_WARNING;
3171
3172 ret = peer_password_set (peer, argv[1]);
3173 return bgp_vty_return (vty, ret);
3174}
3175
3176DEFUN (no_neighbor_password,
3177 no_neighbor_password_cmd,
3178 NO_NEIGHBOR_CMD2 "password",
3179 NO_STR
3180 NEIGHBOR_STR
3181 NEIGHBOR_ADDR_STR2
3182 "Set a password\n")
3183{
3184 struct peer *peer;
3185 int ret;
3186
3187 peer = peer_and_group_lookup_vty (vty, argv[0]);
3188 if (! peer)
3189 return CMD_WARNING;
3190
3191 ret = peer_password_unset (peer);
3192 return bgp_vty_return (vty, ret);
3193}
6b0655a2 3194
813d4307
DW
3195ALIAS (no_neighbor_password,
3196 no_neighbor_password_val_cmd,
3197 NO_NEIGHBOR_CMD2 "password LINE",
3198 NO_STR
3199 NEIGHBOR_STR
3200 NEIGHBOR_ADDR_STR2
3201 "Set a password\n"
3202 "The password\n")
3203
718e3744 3204DEFUN (neighbor_activate,
3205 neighbor_activate_cmd,
3206 NEIGHBOR_CMD2 "activate",
3207 NEIGHBOR_STR
3208 NEIGHBOR_ADDR_STR2
3209 "Enable the Address Family for this Neighbor\n")
3210{
c8560b44 3211 int ret;
718e3744 3212 struct peer *peer;
3213
3214 peer = peer_and_group_lookup_vty (vty, argv[0]);
3215 if (! peer)
3216 return CMD_WARNING;
3217
c8560b44 3218 ret = peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
718e3744 3219
c8560b44
DW
3220 if (ret)
3221 return CMD_WARNING;
718e3744 3222 return CMD_SUCCESS;
3223}
3224
3225DEFUN (no_neighbor_activate,
3226 no_neighbor_activate_cmd,
3227 NO_NEIGHBOR_CMD2 "activate",
3228 NO_STR
3229 NEIGHBOR_STR
3230 NEIGHBOR_ADDR_STR2
3231 "Enable the Address Family for this Neighbor\n")
3232{
3233 int ret;
3234 struct peer *peer;
3235
3236 /* Lookup peer. */
3237 peer = peer_and_group_lookup_vty (vty, argv[0]);
3238 if (! peer)
3239 return CMD_WARNING;
3240
3241 ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
3242
c8560b44
DW
3243 if (ret)
3244 return CMD_WARNING;
3245 return CMD_SUCCESS;
718e3744 3246}
6b0655a2 3247
718e3744 3248DEFUN (neighbor_set_peer_group,
3249 neighbor_set_peer_group_cmd,
a80beece 3250 NEIGHBOR_CMD2 "peer-group WORD",
718e3744 3251 NEIGHBOR_STR
a80beece 3252 NEIGHBOR_ADDR_STR2
718e3744 3253 "Member of the peer-group\n"
3254 "peer-group name\n")
3255{
3256 int ret;
3257 as_t as;
3258 union sockunion su;
3259 struct bgp *bgp;
a80beece 3260 struct peer *peer;
718e3744 3261 struct peer_group *group;
3262
3263 bgp = vty->index;
a80beece 3264 peer = NULL;
718e3744 3265
3266 ret = str2sockunion (argv[0], &su);
3267 if (ret < 0)
3268 {
a80beece
DS
3269 peer = peer_lookup_by_conf_if (bgp, argv[0]);
3270 if (!peer)
3271 {
3272 vty_out (vty, "%% Malformed address or name: %s%s", argv[0], VTY_NEWLINE);
3273 return CMD_WARNING;
3274 }
3275 }
3276 else
3277 {
6aeb9e78 3278 if (peer_address_self_check (bgp, &su))
a80beece
DS
3279 {
3280 vty_out (vty, "%% Can not configure the local system as neighbor%s",
3281 VTY_NEWLINE);
3282 return CMD_WARNING;
3283 }
f14e6fdb
DS
3284
3285 /* Disallow for dynamic neighbor. */
3286 peer = peer_lookup (bgp, &su);
3287 if (peer && peer_dynamic_neighbor (peer))
3288 {
3289 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
3290 VTY_NEWLINE);
3291 return CMD_WARNING;
3292 }
718e3744 3293 }
3294
3295 group = peer_group_lookup (bgp, argv[1]);
3296 if (! group)
3297 {
3298 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
3299 return CMD_WARNING;
3300 }
3301
c8560b44 3302 ret = peer_group_bind (bgp, &su, peer, group, &as);
718e3744 3303
3304 if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT)
3305 {
aea339f7 3306 vty_out (vty, "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external%s", as, VTY_NEWLINE);
718e3744 3307 return CMD_WARNING;
3308 }
3309
3310 return bgp_vty_return (vty, ret);
3311}
3312
3313DEFUN (no_neighbor_set_peer_group,
3314 no_neighbor_set_peer_group_cmd,
a80beece 3315 NO_NEIGHBOR_CMD2 "peer-group WORD",
718e3744 3316 NO_STR
3317 NEIGHBOR_STR
a80beece 3318 NEIGHBOR_ADDR_STR2
718e3744 3319 "Member of the peer-group\n"
3320 "peer-group name\n")
3321{
3322 int ret;
3323 struct bgp *bgp;
3324 struct peer *peer;
3325 struct peer_group *group;
3326
3327 bgp = vty->index;
3328
3329 peer = peer_lookup_vty (vty, argv[0]);
3330 if (! peer)
3331 return CMD_WARNING;
3332
3333 group = peer_group_lookup (bgp, argv[1]);
3334 if (! group)
3335 {
3336 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
3337 return CMD_WARNING;
3338 }
3339
c8560b44 3340 ret = peer_group_unbind (bgp, peer, group);
718e3744 3341
3342 return bgp_vty_return (vty, ret);
3343}
6b0655a2 3344
94f2b392 3345static int
fd79ac91 3346peer_flag_modify_vty (struct vty *vty, const char *ip_str,
3347 u_int16_t flag, int set)
718e3744 3348{
3349 int ret;
3350 struct peer *peer;
3351
3352 peer = peer_and_group_lookup_vty (vty, ip_str);
3353 if (! peer)
3354 return CMD_WARNING;
3355
3356 if (set)
3357 ret = peer_flag_set (peer, flag);
3358 else
3359 ret = peer_flag_unset (peer, flag);
3360
3361 return bgp_vty_return (vty, ret);
3362}
3363
94f2b392 3364static int
fd79ac91 3365peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
718e3744 3366{
3367 return peer_flag_modify_vty (vty, ip_str, flag, 1);
3368}
3369
94f2b392 3370static int
fd79ac91 3371peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
718e3744 3372{
3373 return peer_flag_modify_vty (vty, ip_str, flag, 0);
3374}
3375
3376/* neighbor passive. */
3377DEFUN (neighbor_passive,
3378 neighbor_passive_cmd,
3379 NEIGHBOR_CMD2 "passive",
3380 NEIGHBOR_STR
3381 NEIGHBOR_ADDR_STR2
3382 "Don't send open messages to this neighbor\n")
3383{
3384 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_PASSIVE);
3385}
3386
3387DEFUN (no_neighbor_passive,
3388 no_neighbor_passive_cmd,
3389 NO_NEIGHBOR_CMD2 "passive",
3390 NO_STR
3391 NEIGHBOR_STR
3392 NEIGHBOR_ADDR_STR2
3393 "Don't send open messages to this neighbor\n")
3394{
3395 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_PASSIVE);
3396}
6b0655a2 3397
718e3744 3398/* neighbor shutdown. */
3399DEFUN (neighbor_shutdown,
3400 neighbor_shutdown_cmd,
3401 NEIGHBOR_CMD2 "shutdown",
3402 NEIGHBOR_STR
3403 NEIGHBOR_ADDR_STR2
3404 "Administratively shut down this neighbor\n")
3405{
3406 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
3407}
3408
3409DEFUN (no_neighbor_shutdown,
3410 no_neighbor_shutdown_cmd,
3411 NO_NEIGHBOR_CMD2 "shutdown",
3412 NO_STR
3413 NEIGHBOR_STR
3414 NEIGHBOR_ADDR_STR2
3415 "Administratively shut down this neighbor\n")
3416{
3417 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
3418}
6b0655a2 3419
718e3744 3420/* neighbor capability dynamic. */
3421DEFUN (neighbor_capability_dynamic,
3422 neighbor_capability_dynamic_cmd,
3423 NEIGHBOR_CMD2 "capability dynamic",
3424 NEIGHBOR_STR
3425 NEIGHBOR_ADDR_STR2
3426 "Advertise capability to the peer\n"
3427 "Advertise dynamic capability to this neighbor\n")
3428{
3429 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
3430}
3431
3432DEFUN (no_neighbor_capability_dynamic,
3433 no_neighbor_capability_dynamic_cmd,
3434 NO_NEIGHBOR_CMD2 "capability dynamic",
3435 NO_STR
3436 NEIGHBOR_STR
3437 NEIGHBOR_ADDR_STR2
3438 "Advertise capability to the peer\n"
3439 "Advertise dynamic capability to this neighbor\n")
3440{
3441 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
3442}
6b0655a2 3443
718e3744 3444/* neighbor dont-capability-negotiate */
3445DEFUN (neighbor_dont_capability_negotiate,
3446 neighbor_dont_capability_negotiate_cmd,
3447 NEIGHBOR_CMD2 "dont-capability-negotiate",
3448 NEIGHBOR_STR
3449 NEIGHBOR_ADDR_STR2
3450 "Do not perform capability negotiation\n")
3451{
3452 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
3453}
3454
3455DEFUN (no_neighbor_dont_capability_negotiate,
3456 no_neighbor_dont_capability_negotiate_cmd,
3457 NO_NEIGHBOR_CMD2 "dont-capability-negotiate",
3458 NO_STR
3459 NEIGHBOR_STR
3460 NEIGHBOR_ADDR_STR2
3461 "Do not perform capability negotiation\n")
3462{
3463 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
3464}
6b0655a2 3465
8a92a8a0
DS
3466/* neighbor capability extended next hop encoding */
3467DEFUN (neighbor_capability_enhe,
3468 neighbor_capability_enhe_cmd,
3469 NEIGHBOR_CMD2 "capability extended-nexthop",
3470 NEIGHBOR_STR
3471 NEIGHBOR_ADDR_STR2
3472 "Advertise capability to the peer\n"
3473 "Advertise extended next-hop capability to the peer\n")
3474{
3475 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_CAPABILITY_ENHE);
3476}
3477
3478DEFUN (no_neighbor_capability_enhe,
3479 no_neighbor_capability_enhe_cmd,
3480 NO_NEIGHBOR_CMD2 "capability extended-nexthop",
3481 NO_STR
3482 NEIGHBOR_STR
3483 NEIGHBOR_ADDR_STR2
3484 "Advertise capability to the peer\n"
3485 "Advertise extended next-hop capability to the peer\n")
3486{
3487 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_CAPABILITY_ENHE);
3488}
3489
94f2b392 3490static int
fd79ac91 3491peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi,
fee0f4c6 3492 safi_t safi, u_int32_t flag, int set)
718e3744 3493{
3494 int ret;
3495 struct peer *peer;
3496
3497 peer = peer_and_group_lookup_vty (vty, peer_str);
3498 if (! peer)
3499 return CMD_WARNING;
3500
3501 if (set)
3502 ret = peer_af_flag_set (peer, afi, safi, flag);
3503 else
3504 ret = peer_af_flag_unset (peer, afi, safi, flag);
3505
3506 return bgp_vty_return (vty, ret);
3507}
3508
94f2b392 3509static int
fd79ac91 3510peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi,
fee0f4c6 3511 safi_t safi, u_int32_t flag)
718e3744 3512{
3513 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1);
3514}
3515
94f2b392 3516static int
fd79ac91 3517peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi,
fee0f4c6 3518 safi_t safi, u_int32_t flag)
718e3744 3519{
3520 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0);
3521}
6b0655a2 3522
718e3744 3523/* neighbor capability orf prefix-list. */
3524DEFUN (neighbor_capability_orf_prefix,
3525 neighbor_capability_orf_prefix_cmd,
3526 NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
3527 NEIGHBOR_STR
3528 NEIGHBOR_ADDR_STR2
3529 "Advertise capability to the peer\n"
3530 "Advertise ORF capability to the peer\n"
3531 "Advertise prefixlist ORF capability to this neighbor\n"
3532 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3533 "Capability to RECEIVE the ORF from this neighbor\n"
3534 "Capability to SEND the ORF to this neighbor\n")
3535{
3536 u_int16_t flag = 0;
3537
3538 if (strncmp (argv[1], "s", 1) == 0)
3539 flag = PEER_FLAG_ORF_PREFIX_SM;
3540 else if (strncmp (argv[1], "r", 1) == 0)
3541 flag = PEER_FLAG_ORF_PREFIX_RM;
3542 else if (strncmp (argv[1], "b", 1) == 0)
3543 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
3544 else
3545 return CMD_WARNING;
3546
3547 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3548 bgp_node_safi (vty), flag);
3549}
3550
3551DEFUN (no_neighbor_capability_orf_prefix,
3552 no_neighbor_capability_orf_prefix_cmd,
3553 NO_NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
3554 NO_STR
3555 NEIGHBOR_STR
3556 NEIGHBOR_ADDR_STR2
3557 "Advertise capability to the peer\n"
3558 "Advertise ORF capability to the peer\n"
3559 "Advertise prefixlist ORF capability to this neighbor\n"
3560 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3561 "Capability to RECEIVE the ORF from this neighbor\n"
3562 "Capability to SEND the ORF to this neighbor\n")
3563{
3564 u_int16_t flag = 0;
3565
3566 if (strncmp (argv[1], "s", 1) == 0)
3567 flag = PEER_FLAG_ORF_PREFIX_SM;
3568 else if (strncmp (argv[1], "r", 1) == 0)
3569 flag = PEER_FLAG_ORF_PREFIX_RM;
3570 else if (strncmp (argv[1], "b", 1) == 0)
3571 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
3572 else
3573 return CMD_WARNING;
3574
3575 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3576 bgp_node_safi (vty), flag);
3577}
6b0655a2 3578
718e3744 3579/* neighbor next-hop-self. */
3580DEFUN (neighbor_nexthop_self,
3581 neighbor_nexthop_self_cmd,
a538debe 3582 NEIGHBOR_CMD2 "next-hop-self",
718e3744 3583 NEIGHBOR_STR
3584 NEIGHBOR_ADDR_STR2
a538debe 3585 "Disable the next hop calculation for this neighbor\n")
718e3744 3586{
a538debe
DS
3587 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3588 bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF);
3589}
9e7a53c1 3590
a538debe
DS
3591/* neighbor next-hop-self. */
3592DEFUN (neighbor_nexthop_self_force,
3593 neighbor_nexthop_self_force_cmd,
3594 NEIGHBOR_CMD2 "next-hop-self force",
3595 NEIGHBOR_STR
3596 NEIGHBOR_ADDR_STR2
3597 "Disable the next hop calculation for this neighbor\n"
3598 "Set the next hop to self for reflected routes\n")
3599{
3600 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3601 bgp_node_safi (vty),
88b8ed8d 3602 PEER_FLAG_FORCE_NEXTHOP_SELF);
718e3744 3603}
3604
3605DEFUN (no_neighbor_nexthop_self,
3606 no_neighbor_nexthop_self_cmd,
a538debe 3607 NO_NEIGHBOR_CMD2 "next-hop-self",
718e3744 3608 NO_STR
3609 NEIGHBOR_STR
3610 NEIGHBOR_ADDR_STR2
a538debe 3611 "Disable the next hop calculation for this neighbor\n")
718e3744 3612{
3613 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
9e7a53c1 3614 bgp_node_safi (vty),
88b8ed8d 3615 PEER_FLAG_NEXTHOP_SELF);
718e3744 3616}
6b0655a2 3617
88b8ed8d 3618DEFUN (no_neighbor_nexthop_self_force,
a538debe
DS
3619 no_neighbor_nexthop_self_force_cmd,
3620 NO_NEIGHBOR_CMD2 "next-hop-self force",
3621 NO_STR
3622 NEIGHBOR_STR
3623 NEIGHBOR_ADDR_STR2
3624 "Disable the next hop calculation for this neighbor\n"
3625 "Set the next hop to self for reflected routes\n")
88b8ed8d
DW
3626{
3627 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3628 bgp_node_safi (vty),
3629 PEER_FLAG_FORCE_NEXTHOP_SELF);
3630}
a538debe 3631
c7122e14
DS
3632/* neighbor as-override */
3633DEFUN (neighbor_as_override,
3634 neighbor_as_override_cmd,
3635 NEIGHBOR_CMD2 "as-override",
3636 NEIGHBOR_STR
3637 NEIGHBOR_ADDR_STR2
3638 "Override ASNs in outbound updates if aspath equals remote-as\n")
3639{
3640 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3641 bgp_node_safi (vty),
3642 PEER_FLAG_AS_OVERRIDE);
3643}
3644
3645DEFUN (no_neighbor_as_override,
3646 no_neighbor_as_override_cmd,
3647 NO_NEIGHBOR_CMD2 "as-override",
3648 NO_STR
3649 NEIGHBOR_STR
3650 NEIGHBOR_ADDR_STR2
3651 "Override ASNs in outbound updates if aspath equals remote-as\n")
3652{
3653 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3654 bgp_node_safi (vty),
3655 PEER_FLAG_AS_OVERRIDE);
3656}
3657
718e3744 3658/* neighbor remove-private-AS. */
3659DEFUN (neighbor_remove_private_as,
3660 neighbor_remove_private_as_cmd,
3661 NEIGHBOR_CMD2 "remove-private-AS",
3662 NEIGHBOR_STR
3663 NEIGHBOR_ADDR_STR2
5000f21c 3664 "Remove private ASNs in outbound updates\n")
718e3744 3665{
3666 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3667 bgp_node_safi (vty),
3668 PEER_FLAG_REMOVE_PRIVATE_AS);
3669}
3670
5000f21c
DS
3671DEFUN (neighbor_remove_private_as_all,
3672 neighbor_remove_private_as_all_cmd,
3673 NEIGHBOR_CMD2 "remove-private-AS all",
3674 NEIGHBOR_STR
3675 NEIGHBOR_ADDR_STR2
3676 "Remove private ASNs in outbound updates\n"
3677 "Apply to all AS numbers")
3678{
5000f21c
DS
3679 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3680 bgp_node_safi (vty),
5000f21c
DS
3681 PEER_FLAG_REMOVE_PRIVATE_AS_ALL);
3682}
3683
3684DEFUN (neighbor_remove_private_as_replace_as,
3685 neighbor_remove_private_as_replace_as_cmd,
3686 NEIGHBOR_CMD2 "remove-private-AS replace-AS",
3687 NEIGHBOR_STR
3688 NEIGHBOR_ADDR_STR2
3689 "Remove private ASNs in outbound updates\n"
3690 "Replace private ASNs with our ASN in outbound updates\n")
3691{
5000f21c
DS
3692 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3693 bgp_node_safi (vty),
5000f21c
DS
3694 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE);
3695}
3696
3697DEFUN (neighbor_remove_private_as_all_replace_as,
3698 neighbor_remove_private_as_all_replace_as_cmd,
3699 NEIGHBOR_CMD2 "remove-private-AS all replace-AS",
3700 NEIGHBOR_STR
3701 NEIGHBOR_ADDR_STR2
3702 "Remove private ASNs in outbound updates\n"
3703 "Apply to all AS numbers"
3704 "Replace private ASNs with our ASN in outbound updates\n")
3705{
3706 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3707 bgp_node_safi (vty),
88b8ed8d 3708 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE);
5000f21c
DS
3709}
3710
718e3744 3711DEFUN (no_neighbor_remove_private_as,
3712 no_neighbor_remove_private_as_cmd,
3713 NO_NEIGHBOR_CMD2 "remove-private-AS",
3714 NO_STR
3715 NEIGHBOR_STR
3716 NEIGHBOR_ADDR_STR2
5000f21c 3717 "Remove private ASNs in outbound updates\n")
718e3744 3718{
3719 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3720 bgp_node_safi (vty),
88b8ed8d 3721 PEER_FLAG_REMOVE_PRIVATE_AS);
718e3744 3722}
6b0655a2 3723
88b8ed8d 3724DEFUN (no_neighbor_remove_private_as_all,
5000f21c
DS
3725 no_neighbor_remove_private_as_all_cmd,
3726 NO_NEIGHBOR_CMD2 "remove-private-AS all",
3727 NO_STR
3728 NEIGHBOR_STR
3729 NEIGHBOR_ADDR_STR2
3730 "Remove private ASNs in outbound updates\n"
3731 "Apply to all AS numbers")
88b8ed8d
DW
3732{
3733 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3734 bgp_node_safi (vty),
3735 PEER_FLAG_REMOVE_PRIVATE_AS_ALL);
3736}
5000f21c 3737
88b8ed8d 3738DEFUN (no_neighbor_remove_private_as_replace_as,
5000f21c
DS
3739 no_neighbor_remove_private_as_replace_as_cmd,
3740 NO_NEIGHBOR_CMD2 "remove-private-AS replace-AS",
3741 NO_STR
3742 NEIGHBOR_STR
3743 NEIGHBOR_ADDR_STR2
3744 "Remove private ASNs in outbound updates\n"
3745 "Replace private ASNs with our ASN in outbound updates\n")
88b8ed8d
DW
3746{
3747 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3748 bgp_node_safi (vty),
3749 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE);
3750}
5000f21c 3751
88b8ed8d 3752DEFUN (no_neighbor_remove_private_as_all_replace_as,
5000f21c
DS
3753 no_neighbor_remove_private_as_all_replace_as_cmd,
3754 NO_NEIGHBOR_CMD2 "remove-private-AS all replace-AS",
3755 NO_STR
3756 NEIGHBOR_STR
3757 NEIGHBOR_ADDR_STR2
3758 "Remove private ASNs in outbound updates\n"
3759 "Apply to all AS numbers"
3760 "Replace private ASNs with our ASN in outbound updates\n")
88b8ed8d
DW
3761{
3762 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3763 bgp_node_safi (vty),
3764 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE);
3765}
5000f21c
DS
3766
3767
718e3744 3768/* neighbor send-community. */
3769DEFUN (neighbor_send_community,
3770 neighbor_send_community_cmd,
3771 NEIGHBOR_CMD2 "send-community",
3772 NEIGHBOR_STR
3773 NEIGHBOR_ADDR_STR2
3774 "Send Community attribute to this neighbor\n")
3775{
3776 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3777 bgp_node_safi (vty),
3778 PEER_FLAG_SEND_COMMUNITY);
3779}
3780
3781DEFUN (no_neighbor_send_community,
3782 no_neighbor_send_community_cmd,
3783 NO_NEIGHBOR_CMD2 "send-community",
3784 NO_STR
3785 NEIGHBOR_STR
3786 NEIGHBOR_ADDR_STR2
3787 "Send Community attribute to this neighbor\n")
3788{
3789 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3790 bgp_node_safi (vty),
3791 PEER_FLAG_SEND_COMMUNITY);
3792}
6b0655a2 3793
718e3744 3794/* neighbor send-community extended. */
3795DEFUN (neighbor_send_community_type,
3796 neighbor_send_community_type_cmd,
3797 NEIGHBOR_CMD2 "send-community (both|extended|standard)",
3798 NEIGHBOR_STR
3799 NEIGHBOR_ADDR_STR2
3800 "Send Community attribute to this neighbor\n"
3801 "Send Standard and Extended Community attributes\n"
3802 "Send Extended Community attributes\n"
3803 "Send Standard Community attributes\n")
3804{
3805 if (strncmp (argv[1], "s", 1) == 0)
3806 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3807 bgp_node_safi (vty),
3808 PEER_FLAG_SEND_COMMUNITY);
3809 if (strncmp (argv[1], "e", 1) == 0)
3810 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3811 bgp_node_safi (vty),
3812 PEER_FLAG_SEND_EXT_COMMUNITY);
3813
3814 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3815 bgp_node_safi (vty),
3816 (PEER_FLAG_SEND_COMMUNITY|
3817 PEER_FLAG_SEND_EXT_COMMUNITY));
3818}
3819
3820DEFUN (no_neighbor_send_community_type,
3821 no_neighbor_send_community_type_cmd,
3822 NO_NEIGHBOR_CMD2 "send-community (both|extended|standard)",
3823 NO_STR
3824 NEIGHBOR_STR
3825 NEIGHBOR_ADDR_STR2
3826 "Send Community attribute to this neighbor\n"
3827 "Send Standard and Extended Community attributes\n"
3828 "Send Extended Community attributes\n"
3829 "Send Standard Community attributes\n")
3830{
3831 if (strncmp (argv[1], "s", 1) == 0)
3832 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3833 bgp_node_safi (vty),
3834 PEER_FLAG_SEND_COMMUNITY);
3835 if (strncmp (argv[1], "e", 1) == 0)
3836 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3837 bgp_node_safi (vty),
3838 PEER_FLAG_SEND_EXT_COMMUNITY);
3839
3840 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3841 bgp_node_safi (vty),
3842 (PEER_FLAG_SEND_COMMUNITY |
3843 PEER_FLAG_SEND_EXT_COMMUNITY));
3844}
6b0655a2 3845
718e3744 3846/* neighbor soft-reconfig. */
3847DEFUN (neighbor_soft_reconfiguration,
3848 neighbor_soft_reconfiguration_cmd,
3849 NEIGHBOR_CMD2 "soft-reconfiguration inbound",
3850 NEIGHBOR_STR
3851 NEIGHBOR_ADDR_STR2
3852 "Per neighbor soft reconfiguration\n"
3853 "Allow inbound soft reconfiguration for this neighbor\n")
3854{
3855 return peer_af_flag_set_vty (vty, argv[0],
3856 bgp_node_afi (vty), bgp_node_safi (vty),
3857 PEER_FLAG_SOFT_RECONFIG);
3858}
3859
3860DEFUN (no_neighbor_soft_reconfiguration,
3861 no_neighbor_soft_reconfiguration_cmd,
3862 NO_NEIGHBOR_CMD2 "soft-reconfiguration inbound",
3863 NO_STR
3864 NEIGHBOR_STR
3865 NEIGHBOR_ADDR_STR2
3866 "Per neighbor soft reconfiguration\n"
3867 "Allow inbound soft reconfiguration for this neighbor\n")
3868{
3869 return peer_af_flag_unset_vty (vty, argv[0],
3870 bgp_node_afi (vty), bgp_node_safi (vty),
3871 PEER_FLAG_SOFT_RECONFIG);
3872}
6b0655a2 3873
718e3744 3874DEFUN (neighbor_route_reflector_client,
3875 neighbor_route_reflector_client_cmd,
3876 NEIGHBOR_CMD2 "route-reflector-client",
3877 NEIGHBOR_STR
3878 NEIGHBOR_ADDR_STR2
3879 "Configure a neighbor as Route Reflector client\n")
3880{
3881 struct peer *peer;
3882
3883
3884 peer = peer_and_group_lookup_vty (vty, argv[0]);
3885 if (! peer)
3886 return CMD_WARNING;
3887
3888 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3889 bgp_node_safi (vty),
3890 PEER_FLAG_REFLECTOR_CLIENT);
3891}
3892
3893DEFUN (no_neighbor_route_reflector_client,
3894 no_neighbor_route_reflector_client_cmd,
3895 NO_NEIGHBOR_CMD2 "route-reflector-client",
3896 NO_STR
3897 NEIGHBOR_STR
3898 NEIGHBOR_ADDR_STR2
3899 "Configure a neighbor as Route Reflector client\n")
3900{
3901 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3902 bgp_node_safi (vty),
3903 PEER_FLAG_REFLECTOR_CLIENT);
3904}
6b0655a2 3905
718e3744 3906/* neighbor route-server-client. */
3907DEFUN (neighbor_route_server_client,
3908 neighbor_route_server_client_cmd,
3909 NEIGHBOR_CMD2 "route-server-client",
3910 NEIGHBOR_STR
3911 NEIGHBOR_ADDR_STR2
3912 "Configure a neighbor as Route Server client\n")
3913{
2a3d5731
DW
3914 struct peer *peer;
3915
3916 peer = peer_and_group_lookup_vty (vty, argv[0]);
3917 if (! peer)
3918 return CMD_WARNING;
3919 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3920 bgp_node_safi (vty),
3921 PEER_FLAG_RSERVER_CLIENT);
718e3744 3922}
3923
3924DEFUN (no_neighbor_route_server_client,
3925 no_neighbor_route_server_client_cmd,
3926 NO_NEIGHBOR_CMD2 "route-server-client",
3927 NO_STR
3928 NEIGHBOR_STR
3929 NEIGHBOR_ADDR_STR2
3930 "Configure a neighbor as Route Server client\n")
fee0f4c6 3931{
2a3d5731
DW
3932 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3933 bgp_node_safi (vty),
3934 PEER_FLAG_RSERVER_CLIENT);
fee0f4c6 3935}
6b0655a2 3936
fee0f4c6 3937DEFUN (neighbor_nexthop_local_unchanged,
3938 neighbor_nexthop_local_unchanged_cmd,
3939 NEIGHBOR_CMD2 "nexthop-local unchanged",
3940 NEIGHBOR_STR
3941 NEIGHBOR_ADDR_STR2
3942 "Configure treatment of outgoing link-local nexthop attribute\n"
3943 "Leave link-local nexthop unchanged for this peer\n")
3944{
3945 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3946 bgp_node_safi (vty),
3947 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
3948}
6b0655a2 3949
fee0f4c6 3950DEFUN (no_neighbor_nexthop_local_unchanged,
3951 no_neighbor_nexthop_local_unchanged_cmd,
3952 NO_NEIGHBOR_CMD2 "nexthop-local unchanged",
3953 NO_STR
3954 NEIGHBOR_STR
3955 NEIGHBOR_ADDR_STR2
3956 "Configure treatment of outgoing link-local-nexthop attribute\n"
3957 "Leave link-local nexthop unchanged for this peer\n")
718e3744 3958{
3959 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3960 bgp_node_safi (vty),
fee0f4c6 3961 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
718e3744 3962}
6b0655a2 3963
718e3744 3964DEFUN (neighbor_attr_unchanged,
3965 neighbor_attr_unchanged_cmd,
3966 NEIGHBOR_CMD2 "attribute-unchanged",
3967 NEIGHBOR_STR
3968 NEIGHBOR_ADDR_STR2
3969 "BGP attribute is propagated unchanged to this neighbor\n")
3970{
3971 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3972 bgp_node_safi (vty),
3973 (PEER_FLAG_AS_PATH_UNCHANGED |
3974 PEER_FLAG_NEXTHOP_UNCHANGED |
3975 PEER_FLAG_MED_UNCHANGED));
3976}
3977
3978DEFUN (neighbor_attr_unchanged1,
3979 neighbor_attr_unchanged1_cmd,
3980 NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
3981 NEIGHBOR_STR
3982 NEIGHBOR_ADDR_STR2
3983 "BGP attribute is propagated unchanged to this neighbor\n"
3984 "As-path attribute\n"
3985 "Nexthop attribute\n"
3986 "Med attribute\n")
3987{
3988 u_int16_t flags = 0;
3989
3990 if (strncmp (argv[1], "as-path", 1) == 0)
3991 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
3992 else if (strncmp (argv[1], "next-hop", 1) == 0)
3993 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
3994 else if (strncmp (argv[1], "med", 1) == 0)
3995 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
3996
3997 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3998 bgp_node_safi (vty), flags);
3999}
4000
4001DEFUN (neighbor_attr_unchanged2,
4002 neighbor_attr_unchanged2_cmd,
4003 NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
4004 NEIGHBOR_STR
4005 NEIGHBOR_ADDR_STR2
4006 "BGP attribute is propagated unchanged to this neighbor\n"
4007 "As-path attribute\n"
4008 "Nexthop attribute\n"
4009 "Med attribute\n")
4010{
4011 u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
4012
4013 if (strncmp (argv[1], "next-hop", 1) == 0)
4014 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
4015 else if (strncmp (argv[1], "med", 1) == 0)
4016 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4017
4018 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
4019 bgp_node_safi (vty), flags);
4020
4021}
4022
4023DEFUN (neighbor_attr_unchanged3,
4024 neighbor_attr_unchanged3_cmd,
4025 NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
4026 NEIGHBOR_STR
4027 NEIGHBOR_ADDR_STR2
4028 "BGP attribute is propagated unchanged to this neighbor\n"
4029 "Nexthop attribute\n"
4030 "As-path attribute\n"
4031 "Med attribute\n")
4032{
4033 u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
4034
4035 if (strncmp (argv[1], "as-path", 1) == 0)
4036 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
4037 else if (strncmp (argv[1], "med", 1) == 0)
4038 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4039
4040 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
4041 bgp_node_safi (vty), flags);
4042}
4043
4044DEFUN (neighbor_attr_unchanged4,
4045 neighbor_attr_unchanged4_cmd,
4046 NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
4047 NEIGHBOR_STR
4048 NEIGHBOR_ADDR_STR2
4049 "BGP attribute is propagated unchanged to this neighbor\n"
4050 "Med attribute\n"
4051 "As-path attribute\n"
4052 "Nexthop attribute\n")
4053{
4054 u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
4055
4056 if (strncmp (argv[1], "as-path", 1) == 0)
4057 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
4058 else if (strncmp (argv[1], "next-hop", 1) == 0)
4059 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
4060
4061 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
4062 bgp_node_safi (vty), flags);
4063}
4064
4065ALIAS (neighbor_attr_unchanged,
4066 neighbor_attr_unchanged5_cmd,
4067 NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
4068 NEIGHBOR_STR
4069 NEIGHBOR_ADDR_STR2
4070 "BGP attribute is propagated unchanged to this neighbor\n"
4071 "As-path attribute\n"
4072 "Nexthop attribute\n"
4073 "Med attribute\n")
4074
4075ALIAS (neighbor_attr_unchanged,
4076 neighbor_attr_unchanged6_cmd,
4077 NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
4078 NEIGHBOR_STR
4079 NEIGHBOR_ADDR_STR2
4080 "BGP attribute is propagated unchanged to this neighbor\n"
4081 "As-path attribute\n"
4082 "Med attribute\n"
4083 "Nexthop attribute\n")
4084
4085ALIAS (neighbor_attr_unchanged,
4086 neighbor_attr_unchanged7_cmd,
4087 NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
4088 NEIGHBOR_STR
4089 NEIGHBOR_ADDR_STR2
4090 "BGP attribute is propagated unchanged to this neighbor\n"
4091 "Nexthop attribute\n"
4092 "Med attribute\n"
4093 "As-path attribute\n")
4094
4095ALIAS (neighbor_attr_unchanged,
4096 neighbor_attr_unchanged8_cmd,
4097 NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
4098 NEIGHBOR_STR
4099 NEIGHBOR_ADDR_STR2
4100 "BGP attribute is propagated unchanged to this neighbor\n"
4101 "Nexthop attribute\n"
4102 "As-path attribute\n"
4103 "Med attribute\n")
4104
4105ALIAS (neighbor_attr_unchanged,
4106 neighbor_attr_unchanged9_cmd,
4107 NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
4108 NEIGHBOR_STR
4109 NEIGHBOR_ADDR_STR2
4110 "BGP attribute is propagated unchanged to this neighbor\n"
4111 "Med attribute\n"
4112 "Nexthop attribute\n"
4113 "As-path attribute\n")
4114
4115ALIAS (neighbor_attr_unchanged,
4116 neighbor_attr_unchanged10_cmd,
4117 NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
4118 NEIGHBOR_STR
4119 NEIGHBOR_ADDR_STR2
4120 "BGP attribute is propagated unchanged to this neighbor\n"
4121 "Med attribute\n"
4122 "As-path attribute\n"
4123 "Nexthop attribute\n")
4124
4125DEFUN (no_neighbor_attr_unchanged,
4126 no_neighbor_attr_unchanged_cmd,
4127 NO_NEIGHBOR_CMD2 "attribute-unchanged",
4128 NO_STR
4129 NEIGHBOR_STR
4130 NEIGHBOR_ADDR_STR2
4131 "BGP attribute is propagated unchanged to this neighbor\n")
4132{
4133 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4134 bgp_node_safi (vty),
4135 (PEER_FLAG_AS_PATH_UNCHANGED |
4136 PEER_FLAG_NEXTHOP_UNCHANGED |
4137 PEER_FLAG_MED_UNCHANGED));
4138}
4139
4140DEFUN (no_neighbor_attr_unchanged1,
4141 no_neighbor_attr_unchanged1_cmd,
4142 NO_NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
4143 NO_STR
4144 NEIGHBOR_STR
4145 NEIGHBOR_ADDR_STR2
4146 "BGP attribute is propagated unchanged to this neighbor\n"
4147 "As-path attribute\n"
4148 "Nexthop attribute\n"
4149 "Med attribute\n")
4150{
4151 u_int16_t flags = 0;
4152
4153 if (strncmp (argv[1], "as-path", 1) == 0)
4154 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
4155 else if (strncmp (argv[1], "next-hop", 1) == 0)
4156 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
4157 else if (strncmp (argv[1], "med", 1) == 0)
4158 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4159
4160 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4161 bgp_node_safi (vty), flags);
4162}
4163
4164DEFUN (no_neighbor_attr_unchanged2,
4165 no_neighbor_attr_unchanged2_cmd,
4166 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
4167 NO_STR
4168 NEIGHBOR_STR
4169 NEIGHBOR_ADDR_STR2
4170 "BGP attribute is propagated unchanged to this neighbor\n"
4171 "As-path attribute\n"
4172 "Nexthop attribute\n"
4173 "Med attribute\n")
4174{
4175 u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
4176
4177 if (strncmp (argv[1], "next-hop", 1) == 0)
4178 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
4179 else if (strncmp (argv[1], "med", 1) == 0)
4180 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4181
4182 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4183 bgp_node_safi (vty), flags);
4184}
4185
4186DEFUN (no_neighbor_attr_unchanged3,
4187 no_neighbor_attr_unchanged3_cmd,
4188 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
4189 NO_STR
4190 NEIGHBOR_STR
4191 NEIGHBOR_ADDR_STR2
4192 "BGP attribute is propagated unchanged to this neighbor\n"
4193 "Nexthop attribute\n"
4194 "As-path attribute\n"
4195 "Med attribute\n")
4196{
4197 u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
4198
4199 if (strncmp (argv[1], "as-path", 1) == 0)
4200 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
4201 else if (strncmp (argv[1], "med", 1) == 0)
4202 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4203
4204 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4205 bgp_node_safi (vty), flags);
4206}
4207
4208DEFUN (no_neighbor_attr_unchanged4,
4209 no_neighbor_attr_unchanged4_cmd,
4210 NO_NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
4211 NO_STR
4212 NEIGHBOR_STR
4213 NEIGHBOR_ADDR_STR2
4214 "BGP attribute is propagated unchanged to this neighbor\n"
4215 "Med attribute\n"
4216 "As-path attribute\n"
4217 "Nexthop attribute\n")
4218{
4219 u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
4220
4221 if (strncmp (argv[1], "as-path", 1) == 0)
4222 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
4223 else if (strncmp (argv[1], "next-hop", 1) == 0)
4224 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
4225
4226 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4227 bgp_node_safi (vty), flags);
4228}
4229
4230ALIAS (no_neighbor_attr_unchanged,
4231 no_neighbor_attr_unchanged5_cmd,
4232 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
4233 NO_STR
4234 NEIGHBOR_STR
4235 NEIGHBOR_ADDR_STR2
4236 "BGP attribute is propagated unchanged to this neighbor\n"
4237 "As-path attribute\n"
4238 "Nexthop attribute\n"
4239 "Med attribute\n")
4240
4241ALIAS (no_neighbor_attr_unchanged,
4242 no_neighbor_attr_unchanged6_cmd,
4243 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
4244 NO_STR
4245 NEIGHBOR_STR
4246 NEIGHBOR_ADDR_STR2
4247 "BGP attribute is propagated unchanged to this neighbor\n"
4248 "As-path attribute\n"
4249 "Med attribute\n"
4250 "Nexthop attribute\n")
4251
4252ALIAS (no_neighbor_attr_unchanged,
4253 no_neighbor_attr_unchanged7_cmd,
4254 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
4255 NO_STR
4256 NEIGHBOR_STR
4257 NEIGHBOR_ADDR_STR2
4258 "BGP attribute is propagated unchanged to this neighbor\n"
4259 "Nexthop attribute\n"
4260 "Med attribute\n"
4261 "As-path attribute\n")
4262
4263ALIAS (no_neighbor_attr_unchanged,
4264 no_neighbor_attr_unchanged8_cmd,
4265 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
4266 NO_STR
4267 NEIGHBOR_STR
4268 NEIGHBOR_ADDR_STR2
4269 "BGP attribute is propagated unchanged to this neighbor\n"
4270 "Nexthop attribute\n"
4271 "As-path attribute\n"
4272 "Med attribute\n")
4273
4274ALIAS (no_neighbor_attr_unchanged,
4275 no_neighbor_attr_unchanged9_cmd,
4276 NO_NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
4277 NO_STR
4278 NEIGHBOR_STR
4279 NEIGHBOR_ADDR_STR2
4280 "BGP attribute is propagated unchanged to this neighbor\n"
4281 "Med attribute\n"
4282 "Nexthop attribute\n"
4283 "As-path attribute\n")
4284
4285ALIAS (no_neighbor_attr_unchanged,
4286 no_neighbor_attr_unchanged10_cmd,
4287 NO_NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
4288 NO_STR
4289 NEIGHBOR_STR
4290 NEIGHBOR_ADDR_STR2
4291 "BGP attribute is propagated unchanged to this neighbor\n"
4292 "Med attribute\n"
4293 "As-path attribute\n"
4294 "Nexthop attribute\n")
4295
718e3744 4296/* EBGP multihop configuration. */
94f2b392 4297static int
fd79ac91 4298peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str,
4299 const char *ttl_str)
718e3744 4300{
4301 struct peer *peer;
fd79ac91 4302 unsigned int ttl;
718e3744 4303
4304 peer = peer_and_group_lookup_vty (vty, ip_str);
4305 if (! peer)
4306 return CMD_WARNING;
4307
4308 if (! ttl_str)
9b1be336 4309 ttl = MAXTTL;
718e3744 4310 else
9b1be336 4311 VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, MAXTTL);
718e3744 4312
89b6d1f8 4313 return bgp_vty_return (vty, peer_ebgp_multihop_set (peer, ttl));
718e3744 4314}
4315
94f2b392 4316static int
fd79ac91 4317peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str)
718e3744 4318{
4319 struct peer *peer;
4320
4321 peer = peer_and_group_lookup_vty (vty, ip_str);
4322 if (! peer)
4323 return CMD_WARNING;
4324
89b6d1f8 4325 return bgp_vty_return (vty, peer_ebgp_multihop_unset (peer));
718e3744 4326}
4327
4328/* neighbor ebgp-multihop. */
4329DEFUN (neighbor_ebgp_multihop,
4330 neighbor_ebgp_multihop_cmd,
4331 NEIGHBOR_CMD2 "ebgp-multihop",
4332 NEIGHBOR_STR
4333 NEIGHBOR_ADDR_STR2
4334 "Allow EBGP neighbors not on directly connected networks\n")
4335{
4336 return peer_ebgp_multihop_set_vty (vty, argv[0], NULL);
4337}
4338
4339DEFUN (neighbor_ebgp_multihop_ttl,
4340 neighbor_ebgp_multihop_ttl_cmd,
9b1be336 4341 NEIGHBOR_CMD2 "ebgp-multihop " CMD_RANGE_STR(1, MAXTTL),
718e3744 4342 NEIGHBOR_STR
4343 NEIGHBOR_ADDR_STR2
4344 "Allow EBGP neighbors not on directly connected networks\n"
4345 "maximum hop count\n")
4346{
4347 return peer_ebgp_multihop_set_vty (vty, argv[0], argv[1]);
4348}
4349
4350DEFUN (no_neighbor_ebgp_multihop,
4351 no_neighbor_ebgp_multihop_cmd,
4352 NO_NEIGHBOR_CMD2 "ebgp-multihop",
4353 NO_STR
4354 NEIGHBOR_STR
4355 NEIGHBOR_ADDR_STR2
4356 "Allow EBGP neighbors not on directly connected networks\n")
4357{
4358 return peer_ebgp_multihop_unset_vty (vty, argv[0]);
4359}
4360
4361ALIAS (no_neighbor_ebgp_multihop,
4362 no_neighbor_ebgp_multihop_ttl_cmd,
9b1be336 4363 NO_NEIGHBOR_CMD2 "ebgp-multihop " CMD_RANGE_STR(1, MAXTTL),
718e3744 4364 NO_STR
4365 NEIGHBOR_STR
4366 NEIGHBOR_ADDR_STR2
4367 "Allow EBGP neighbors not on directly connected networks\n"
4368 "maximum hop count\n")
6b0655a2 4369
6ffd2079 4370/* disable-connected-check */
4371DEFUN (neighbor_disable_connected_check,
4372 neighbor_disable_connected_check_cmd,
4373 NEIGHBOR_CMD2 "disable-connected-check",
4374 NEIGHBOR_STR
4375 NEIGHBOR_ADDR_STR2
4376 "one-hop away EBGP peer using loopback address\n")
4377{
4378 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
4379}
4380
4381DEFUN (no_neighbor_disable_connected_check,
4382 no_neighbor_disable_connected_check_cmd,
4383 NO_NEIGHBOR_CMD2 "disable-connected-check",
4384 NO_STR
4385 NEIGHBOR_STR
4386 NEIGHBOR_ADDR_STR2
4387 "one-hop away EBGP peer using loopback address\n")
4388{
4389 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
4390}
4391
718e3744 4392/* Enforce multihop. */
6ffd2079 4393ALIAS (neighbor_disable_connected_check,
718e3744 4394 neighbor_enforce_multihop_cmd,
4395 NEIGHBOR_CMD2 "enforce-multihop",
4396 NEIGHBOR_STR
4397 NEIGHBOR_ADDR_STR2
e8e1946e 4398 "Enforce EBGP neighbors perform multihop\n")
718e3744 4399
6ffd2079 4400/* Enforce multihop. */
4401ALIAS (no_neighbor_disable_connected_check,
718e3744 4402 no_neighbor_enforce_multihop_cmd,
4403 NO_NEIGHBOR_CMD2 "enforce-multihop",
4404 NO_STR
4405 NEIGHBOR_STR
4406 NEIGHBOR_ADDR_STR2
e8e1946e 4407 "Enforce EBGP neighbors perform multihop\n")
6b0655a2 4408
718e3744 4409DEFUN (neighbor_description,
4410 neighbor_description_cmd,
4411 NEIGHBOR_CMD2 "description .LINE",
4412 NEIGHBOR_STR
4413 NEIGHBOR_ADDR_STR2
4414 "Neighbor specific description\n"
4415 "Up to 80 characters describing this neighbor\n")
4416{
4417 struct peer *peer;
718e3744 4418 char *str;
718e3744 4419
4420 peer = peer_and_group_lookup_vty (vty, argv[0]);
4421 if (! peer)
4422 return CMD_WARNING;
4423
4424 if (argc == 1)
4425 return CMD_SUCCESS;
4426
3b8b1855 4427 str = argv_concat(argv, argc, 1);
718e3744 4428
4429 peer_description_set (peer, str);
4430
3b8b1855 4431 XFREE (MTYPE_TMP, str);
718e3744 4432
4433 return CMD_SUCCESS;
4434}
4435
4436DEFUN (no_neighbor_description,
4437 no_neighbor_description_cmd,
4438 NO_NEIGHBOR_CMD2 "description",
4439 NO_STR
4440 NEIGHBOR_STR
4441 NEIGHBOR_ADDR_STR2
4442 "Neighbor specific description\n")
4443{
4444 struct peer *peer;
4445
4446 peer = peer_and_group_lookup_vty (vty, argv[0]);
4447 if (! peer)
4448 return CMD_WARNING;
4449
4450 peer_description_unset (peer);
4451
4452 return CMD_SUCCESS;
4453}
4454
4455ALIAS (no_neighbor_description,
4456 no_neighbor_description_val_cmd,
4457 NO_NEIGHBOR_CMD2 "description .LINE",
4458 NO_STR
4459 NEIGHBOR_STR
4460 NEIGHBOR_ADDR_STR2
4461 "Neighbor specific description\n"
4462 "Up to 80 characters describing this neighbor\n")
6b0655a2 4463
718e3744 4464/* Neighbor update-source. */
94f2b392 4465static int
fd79ac91 4466peer_update_source_vty (struct vty *vty, const char *peer_str,
4467 const char *source_str)
718e3744 4468{
4469 struct peer *peer;
718e3744 4470
4471 peer = peer_and_group_lookup_vty (vty, peer_str);
4472 if (! peer)
4473 return CMD_WARNING;
4474
a80beece
DS
4475 if (peer->conf_if)
4476 return CMD_WARNING;
4477
718e3744 4478 if (source_str)
4479 {
c63b83fe
JBD
4480 union sockunion su;
4481 int ret = str2sockunion (source_str, &su);
4482
4483 if (ret == 0)
4484 peer_update_source_addr_set (peer, &su);
718e3744 4485 else
4486 peer_update_source_if_set (peer, source_str);
4487 }
4488 else
4489 peer_update_source_unset (peer);
4490
4491 return CMD_SUCCESS;
4492}
4493
dcb52bd5
DS
4494#define BGP_UPDATE_SOURCE_STR "A.B.C.D|X:X::X:X|WORD"
4495#define BGP_UPDATE_SOURCE_REQ_STR "(" BGP_UPDATE_SOURCE_STR ")"
4496#define BGP_UPDATE_SOURCE_OPT_STR "{" BGP_UPDATE_SOURCE_STR "}"
369688c0
PJ
4497#define BGP_UPDATE_SOURCE_HELP_STR \
4498 "IPv4 address\n" \
9a1a331d
PJ
4499 "IPv6 address\n" \
4500 "Interface name (requires zebra to be running)\n"
369688c0 4501
718e3744 4502DEFUN (neighbor_update_source,
4503 neighbor_update_source_cmd,
dcb52bd5 4504 NEIGHBOR_CMD2 "update-source " BGP_UPDATE_SOURCE_REQ_STR,
718e3744 4505 NEIGHBOR_STR
4506 NEIGHBOR_ADDR_STR2
4507 "Source of routing updates\n"
369688c0 4508 BGP_UPDATE_SOURCE_HELP_STR)
718e3744 4509{
4510 return peer_update_source_vty (vty, argv[0], argv[1]);
4511}
4512
4513DEFUN (no_neighbor_update_source,
4514 no_neighbor_update_source_cmd,
dcb52bd5 4515 NO_NEIGHBOR_CMD2 "update-source " BGP_UPDATE_SOURCE_OPT_STR,
718e3744 4516 NO_STR
4517 NEIGHBOR_STR
4518 NEIGHBOR_ADDR_STR2
dcb52bd5
DS
4519 "Source of routing updates\n"
4520 BGP_UPDATE_SOURCE_HELP_STR)
718e3744 4521{
4522 return peer_update_source_vty (vty, argv[0], NULL);
4523}
6b0655a2 4524
94f2b392 4525static int
fd79ac91 4526peer_default_originate_set_vty (struct vty *vty, const char *peer_str,
4527 afi_t afi, safi_t safi,
4528 const char *rmap, int set)
718e3744 4529{
4530 int ret;
4531 struct peer *peer;
4532
4533 peer = peer_and_group_lookup_vty (vty, peer_str);
4534 if (! peer)
4535 return CMD_WARNING;
4536
4537 if (set)
4538 ret = peer_default_originate_set (peer, afi, safi, rmap);
4539 else
4540 ret = peer_default_originate_unset (peer, afi, safi);
4541
4542 return bgp_vty_return (vty, ret);
4543}
4544
4545/* neighbor default-originate. */
4546DEFUN (neighbor_default_originate,
4547 neighbor_default_originate_cmd,
4548 NEIGHBOR_CMD2 "default-originate",
4549 NEIGHBOR_STR
4550 NEIGHBOR_ADDR_STR2
4551 "Originate default route to this neighbor\n")
4552{
4553 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
4554 bgp_node_safi (vty), NULL, 1);
4555}
4556
4557DEFUN (neighbor_default_originate_rmap,
4558 neighbor_default_originate_rmap_cmd,
4559 NEIGHBOR_CMD2 "default-originate route-map WORD",
4560 NEIGHBOR_STR
4561 NEIGHBOR_ADDR_STR2
4562 "Originate default route to this neighbor\n"
4563 "Route-map to specify criteria to originate default\n"
4564 "route-map name\n")
4565{
4566 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
4567 bgp_node_safi (vty), argv[1], 1);
4568}
4569
4570DEFUN (no_neighbor_default_originate,
4571 no_neighbor_default_originate_cmd,
4572 NO_NEIGHBOR_CMD2 "default-originate",
4573 NO_STR
4574 NEIGHBOR_STR
4575 NEIGHBOR_ADDR_STR2
4576 "Originate default route to this neighbor\n")
4577{
4578 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
4579 bgp_node_safi (vty), NULL, 0);
4580}
4581
4582ALIAS (no_neighbor_default_originate,
4583 no_neighbor_default_originate_rmap_cmd,
4584 NO_NEIGHBOR_CMD2 "default-originate route-map WORD",
4585 NO_STR
4586 NEIGHBOR_STR
4587 NEIGHBOR_ADDR_STR2
4588 "Originate default route to this neighbor\n"
4589 "Route-map to specify criteria to originate default\n"
4590 "route-map name\n")
6b0655a2 4591
718e3744 4592/* Set neighbor's BGP port. */
94f2b392 4593static int
fd79ac91 4594peer_port_vty (struct vty *vty, const char *ip_str, int afi,
4595 const char *port_str)
718e3744 4596{
4597 struct peer *peer;
4598 u_int16_t port;
4599 struct servent *sp;
4600
4601 peer = peer_lookup_vty (vty, ip_str);
4602 if (! peer)
4603 return CMD_WARNING;
4604
4605 if (! port_str)
4606 {
4607 sp = getservbyname ("bgp", "tcp");
4608 port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port);
4609 }
4610 else
4611 {
4612 VTY_GET_INTEGER("port", port, port_str);
4613 }
4614
4615 peer_port_set (peer, port);
4616
4617 return CMD_SUCCESS;
4618}
4619
f418446b 4620/* Set specified peer's BGP port. */
718e3744 4621DEFUN (neighbor_port,
4622 neighbor_port_cmd,
4623 NEIGHBOR_CMD "port <0-65535>",
4624 NEIGHBOR_STR
4625 NEIGHBOR_ADDR_STR
4626 "Neighbor's BGP port\n"
4627 "TCP port number\n")
4628{
4629 return peer_port_vty (vty, argv[0], AFI_IP, argv[1]);
4630}
4631
4632DEFUN (no_neighbor_port,
4633 no_neighbor_port_cmd,
4634 NO_NEIGHBOR_CMD "port",
4635 NO_STR
4636 NEIGHBOR_STR
4637 NEIGHBOR_ADDR_STR
4638 "Neighbor's BGP port\n")
4639{
4640 return peer_port_vty (vty, argv[0], AFI_IP, NULL);
4641}
4642
4643ALIAS (no_neighbor_port,
4644 no_neighbor_port_val_cmd,
4645 NO_NEIGHBOR_CMD "port <0-65535>",
4646 NO_STR
4647 NEIGHBOR_STR
4648 NEIGHBOR_ADDR_STR
4649 "Neighbor's BGP port\n"
4650 "TCP port number\n")
6b0655a2 4651
718e3744 4652/* neighbor weight. */
94f2b392 4653static int
fd79ac91 4654peer_weight_set_vty (struct vty *vty, const char *ip_str,
4655 const char *weight_str)
718e3744 4656{
718e3744 4657 struct peer *peer;
4658 unsigned long weight;
4659
4660 peer = peer_and_group_lookup_vty (vty, ip_str);
4661 if (! peer)
4662 return CMD_WARNING;
4663
4664 VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535);
4665
ffd0c037 4666 peer_weight_set (peer, weight);
718e3744 4667
4668 return CMD_SUCCESS;
4669}
4670
94f2b392 4671static int
fd79ac91 4672peer_weight_unset_vty (struct vty *vty, const char *ip_str)
718e3744 4673{
4674 struct peer *peer;
4675
4676 peer = peer_and_group_lookup_vty (vty, ip_str);
4677 if (! peer)
4678 return CMD_WARNING;
4679
4680 peer_weight_unset (peer);
4681
4682 return CMD_SUCCESS;
4683}
4684
4685DEFUN (neighbor_weight,
4686 neighbor_weight_cmd,
4687 NEIGHBOR_CMD2 "weight <0-65535>",
4688 NEIGHBOR_STR
4689 NEIGHBOR_ADDR_STR2
4690 "Set default weight for routes from this neighbor\n"
4691 "default weight\n")
4692{
4693 return peer_weight_set_vty (vty, argv[0], argv[1]);
4694}
4695
4696DEFUN (no_neighbor_weight,
4697 no_neighbor_weight_cmd,
4698 NO_NEIGHBOR_CMD2 "weight",
4699 NO_STR
4700 NEIGHBOR_STR
4701 NEIGHBOR_ADDR_STR2
4702 "Set default weight for routes from this neighbor\n")
4703{
4704 return peer_weight_unset_vty (vty, argv[0]);
4705}
4706
4707ALIAS (no_neighbor_weight,
4708 no_neighbor_weight_val_cmd,
4709 NO_NEIGHBOR_CMD2 "weight <0-65535>",
4710 NO_STR
4711 NEIGHBOR_STR
4712 NEIGHBOR_ADDR_STR2
4713 "Set default weight for routes from this neighbor\n"
4714 "default weight\n")
6b0655a2 4715
718e3744 4716/* Override capability negotiation. */
4717DEFUN (neighbor_override_capability,
4718 neighbor_override_capability_cmd,
4719 NEIGHBOR_CMD2 "override-capability",
4720 NEIGHBOR_STR
4721 NEIGHBOR_ADDR_STR2
4722 "Override capability negotiation result\n")
4723{
4724 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
4725}
4726
4727DEFUN (no_neighbor_override_capability,
4728 no_neighbor_override_capability_cmd,
4729 NO_NEIGHBOR_CMD2 "override-capability",
4730 NO_STR
4731 NEIGHBOR_STR
4732 NEIGHBOR_ADDR_STR2
4733 "Override capability negotiation result\n")
4734{
4735 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
4736}
6b0655a2 4737
718e3744 4738DEFUN (neighbor_strict_capability,
4739 neighbor_strict_capability_cmd,
4740 NEIGHBOR_CMD "strict-capability-match",
4741 NEIGHBOR_STR
4742 NEIGHBOR_ADDR_STR
4743 "Strict capability negotiation match\n")
4744{
4745 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
4746}
4747
4748DEFUN (no_neighbor_strict_capability,
4749 no_neighbor_strict_capability_cmd,
4750 NO_NEIGHBOR_CMD "strict-capability-match",
4751 NO_STR
4752 NEIGHBOR_STR
4753 NEIGHBOR_ADDR_STR
4754 "Strict capability negotiation match\n")
4755{
4756 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
4757}
6b0655a2 4758
94f2b392 4759static int
fd79ac91 4760peer_timers_set_vty (struct vty *vty, const char *ip_str,
4761 const char *keep_str, const char *hold_str)
718e3744 4762{
4763 int ret;
4764 struct peer *peer;
4765 u_int32_t keepalive;
4766 u_int32_t holdtime;
4767
4768 peer = peer_and_group_lookup_vty (vty, ip_str);
4769 if (! peer)
4770 return CMD_WARNING;
4771
4772 VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535);
4773 VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535);
4774
4775 ret = peer_timers_set (peer, keepalive, holdtime);
4776
4777 return bgp_vty_return (vty, ret);
4778}
6b0655a2 4779
94f2b392 4780static int
fd79ac91 4781peer_timers_unset_vty (struct vty *vty, const char *ip_str)
718e3744 4782{
4783 int ret;
4784 struct peer *peer;
4785
0c412461 4786 peer = peer_and_group_lookup_vty (vty, ip_str);
718e3744 4787 if (! peer)
4788 return CMD_WARNING;
4789
4790 ret = peer_timers_unset (peer);
4791
4792 return bgp_vty_return (vty, ret);
4793}
4794
4795DEFUN (neighbor_timers,
4796 neighbor_timers_cmd,
4797 NEIGHBOR_CMD2 "timers <0-65535> <0-65535>",
4798 NEIGHBOR_STR
4799 NEIGHBOR_ADDR_STR2
4800 "BGP per neighbor timers\n"
4801 "Keepalive interval\n"
4802 "Holdtime\n")
4803{
4804 return peer_timers_set_vty (vty, argv[0], argv[1], argv[2]);
4805}
4806
4807DEFUN (no_neighbor_timers,
4808 no_neighbor_timers_cmd,
4809 NO_NEIGHBOR_CMD2 "timers",
4810 NO_STR
4811 NEIGHBOR_STR
4812 NEIGHBOR_ADDR_STR2
4813 "BGP per neighbor timers\n")
4814{
4815 return peer_timers_unset_vty (vty, argv[0]);
4816}
6b0655a2 4817
813d4307
DW
4818ALIAS (no_neighbor_timers,
4819 no_neighbor_timers_val_cmd,
4820 NO_NEIGHBOR_CMD2 "timers <0-65535> <0-65535>",
4821 NO_STR
4822 NEIGHBOR_STR
4823 NEIGHBOR_ADDR_STR2
4824 "BGP per neighbor timers\n"
4825 "Keepalive interval\n"
4826 "Holdtime\n")
4827
94f2b392 4828static int
fd79ac91 4829peer_timers_connect_set_vty (struct vty *vty, const char *ip_str,
4830 const char *time_str)
718e3744 4831{
4832 int ret;
4833 struct peer *peer;
4834 u_int32_t connect;
4835
966f821c 4836 peer = peer_and_group_lookup_vty (vty, ip_str);
718e3744 4837 if (! peer)
4838 return CMD_WARNING;
4839
4840 VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535);
4841
4842 ret = peer_timers_connect_set (peer, connect);
4843
966f821c 4844 return bgp_vty_return (vty, ret);
718e3744 4845}
4846
94f2b392 4847static int
fd79ac91 4848peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str)
718e3744 4849{
4850 int ret;
4851 struct peer *peer;
4852
4853 peer = peer_and_group_lookup_vty (vty, ip_str);
4854 if (! peer)
4855 return CMD_WARNING;
4856
4857 ret = peer_timers_connect_unset (peer);
4858
966f821c 4859 return bgp_vty_return (vty, ret);
718e3744 4860}
4861
4862DEFUN (neighbor_timers_connect,
4863 neighbor_timers_connect_cmd,
8e0d0089 4864 NEIGHBOR_CMD2 "timers connect <1-65535>",
718e3744 4865 NEIGHBOR_STR
966f821c 4866 NEIGHBOR_ADDR_STR2
718e3744 4867 "BGP per neighbor timers\n"
4868 "BGP connect timer\n"
4869 "Connect timer\n")
4870{
4871 return peer_timers_connect_set_vty (vty, argv[0], argv[1]);
4872}
4873
4874DEFUN (no_neighbor_timers_connect,
4875 no_neighbor_timers_connect_cmd,
966f821c 4876 NO_NEIGHBOR_CMD2 "timers connect",
718e3744 4877 NO_STR
4878 NEIGHBOR_STR
966f821c 4879 NEIGHBOR_ADDR_STR2
718e3744 4880 "BGP per neighbor timers\n"
4881 "BGP connect timer\n")
4882{
4883 return peer_timers_connect_unset_vty (vty, argv[0]);
4884}
4885
4886ALIAS (no_neighbor_timers_connect,
4887 no_neighbor_timers_connect_val_cmd,
8e0d0089 4888 NO_NEIGHBOR_CMD2 "timers connect <1-65535>",
718e3744 4889 NO_STR
4890 NEIGHBOR_STR
966f821c 4891 NEIGHBOR_ADDR_STR2
718e3744 4892 "BGP per neighbor timers\n"
4893 "BGP connect timer\n"
4894 "Connect timer\n")
6b0655a2 4895
94f2b392 4896static int
fd79ac91 4897peer_advertise_interval_vty (struct vty *vty, const char *ip_str,
4898 const char *time_str, int set)
718e3744 4899{
4900 int ret;
4901 struct peer *peer;
4902 u_int32_t routeadv = 0;
4903
966f821c 4904 peer = peer_and_group_lookup_vty (vty, ip_str);
718e3744 4905 if (! peer)
4906 return CMD_WARNING;
4907
4908 if (time_str)
4909 VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600);
4910
4911 if (set)
4912 ret = peer_advertise_interval_set (peer, routeadv);
4913 else
4914 ret = peer_advertise_interval_unset (peer);
4915
966f821c 4916 return bgp_vty_return (vty, ret);
718e3744 4917}
4918
4919DEFUN (neighbor_advertise_interval,
4920 neighbor_advertise_interval_cmd,
966f821c 4921 NEIGHBOR_CMD2 "advertisement-interval <0-600>",
718e3744 4922 NEIGHBOR_STR
966f821c 4923 NEIGHBOR_ADDR_STR2
718e3744 4924 "Minimum interval between sending BGP routing updates\n"
4925 "time in seconds\n")
4926{
4927 return peer_advertise_interval_vty (vty, argv[0], argv[1], 1);
4928}
4929
4930DEFUN (no_neighbor_advertise_interval,
4931 no_neighbor_advertise_interval_cmd,
966f821c 4932 NO_NEIGHBOR_CMD2 "advertisement-interval",
718e3744 4933 NO_STR
4934 NEIGHBOR_STR
966f821c 4935 NEIGHBOR_ADDR_STR2
718e3744 4936 "Minimum interval between sending BGP routing updates\n")
4937{
4938 return peer_advertise_interval_vty (vty, argv[0], NULL, 0);
4939}
4940
4941ALIAS (no_neighbor_advertise_interval,
4942 no_neighbor_advertise_interval_val_cmd,
966f821c 4943 NO_NEIGHBOR_CMD2 "advertisement-interval <0-600>",
718e3744 4944 NO_STR
4945 NEIGHBOR_STR
966f821c 4946 NEIGHBOR_ADDR_STR2
718e3744 4947 "Minimum interval between sending BGP routing updates\n"
4948 "time in seconds\n")
6b0655a2 4949
518f0eb1
DS
4950/* Time to wait before processing route-map updates */
4951DEFUN (bgp_set_route_map_delay_timer,
4952 bgp_set_route_map_delay_timer_cmd,
4953 "bgp route-map delay-timer <0-600>",
4954 SET_STR
4955 "BGP route-map delay timer\n"
4956 "Time in secs to wait before processing route-map changes\n"
f414725f 4957 "0 disables the timer, no route updates happen when route-maps change\n")
518f0eb1
DS
4958{
4959 u_int32_t rmap_delay_timer;
518f0eb1 4960
518f0eb1
DS
4961 if (argv[0])
4962 {
4963 VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[0], 0, 600);
5fe9f963 4964 bm->rmap_update_timer = rmap_delay_timer;
518f0eb1
DS
4965
4966 /* if the dynamic update handling is being disabled, and a timer is
4967 * running, stop the timer and act as if the timer has already fired.
4968 */
5fe9f963 4969 if (!rmap_delay_timer && bm->t_rmap_update )
518f0eb1 4970 {
5fe9f963 4971 BGP_TIMER_OFF(bm->t_rmap_update);
4972 thread_execute (bm->master, bgp_route_map_update_timer, NULL, 0);
518f0eb1
DS
4973 }
4974 return CMD_SUCCESS;
4975 }
4976 else
ffd0c037 4977 return CMD_WARNING;
518f0eb1
DS
4978}
4979
4980DEFUN (no_bgp_set_route_map_delay_timer,
4981 no_bgp_set_route_map_delay_timer_cmd,
4982 "no bgp route-map delay-timer",
4983 NO_STR
4984 "Default BGP route-map delay timer\n"
f414725f 4985 "Reset to default time to wait for processing route-map changes\n")
518f0eb1 4986{
518f0eb1 4987
5fe9f963 4988 bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER;
518f0eb1
DS
4989
4990 return CMD_SUCCESS;
4991}
4992
f414725f
DS
4993ALIAS (no_bgp_set_route_map_delay_timer,
4994 no_bgp_set_route_map_delay_timer_val_cmd,
4995 "no bgp route-map delay-timer <0-600>",
4996 NO_STR
4997 "Default BGP route-map delay timer\n"
4998 "Reset to default time to wait for processing route-map changes\n"
4999 "0 disables the timer, no route updates happen when route-maps change\n")
5000
718e3744 5001/* neighbor interface */
94f2b392 5002static int
fd79ac91 5003peer_interface_vty (struct vty *vty, const char *ip_str, const char *str)
718e3744 5004{
718e3744 5005 struct peer *peer;
5006
5007 peer = peer_lookup_vty (vty, ip_str);
a80beece 5008 if (! peer || peer->conf_if)
718e3744 5009 return CMD_WARNING;
5010
5011 if (str)
ffd0c037 5012 peer_interface_set (peer, str);
718e3744 5013 else
ffd0c037 5014 peer_interface_unset (peer);
718e3744 5015
5016 return CMD_SUCCESS;
5017}
5018
5019DEFUN (neighbor_interface,
5020 neighbor_interface_cmd,
5021 NEIGHBOR_CMD "interface WORD",
5022 NEIGHBOR_STR
5023 NEIGHBOR_ADDR_STR
5024 "Interface\n"
5025 "Interface name\n")
5026{
8ffedcea
DS
5027 if (argc == 3)
5028 return peer_interface_vty (vty, argv[0], argv[1]);
5029 else
5030 return peer_interface_vty (vty, argv[0], argv[1]);
718e3744 5031}
5032
5033DEFUN (no_neighbor_interface,
5034 no_neighbor_interface_cmd,
8ffedcea 5035 NO_NEIGHBOR_CMD2 "interface WORD",
718e3744 5036 NO_STR
5037 NEIGHBOR_STR
5038 NEIGHBOR_ADDR_STR
5039 "Interface\n"
5040 "Interface name\n")
5041{
5042 return peer_interface_vty (vty, argv[0], NULL);
5043}
6b0655a2 5044
718e3744 5045/* Set distribute list to the peer. */
94f2b392 5046static int
fd79ac91 5047peer_distribute_set_vty (struct vty *vty, const char *ip_str,
5048 afi_t afi, safi_t safi,
5049 const char *name_str, const char *direct_str)
718e3744 5050{
5051 int ret;
5052 struct peer *peer;
5053 int direct = FILTER_IN;
5054
5055 peer = peer_and_group_lookup_vty (vty, ip_str);
5056 if (! peer)
5057 return CMD_WARNING;
5058
5059 /* Check filter direction. */
5060 if (strncmp (direct_str, "i", 1) == 0)
5061 direct = FILTER_IN;
5062 else if (strncmp (direct_str, "o", 1) == 0)
5063 direct = FILTER_OUT;
5064
5065 ret = peer_distribute_set (peer, afi, safi, direct, name_str);
5066
5067 return bgp_vty_return (vty, ret);
5068}
5069
94f2b392 5070static int
fd79ac91 5071peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5072 safi_t safi, const char *direct_str)
718e3744 5073{
5074 int ret;
5075 struct peer *peer;
5076 int direct = FILTER_IN;
5077
5078 peer = peer_and_group_lookup_vty (vty, ip_str);
5079 if (! peer)
5080 return CMD_WARNING;
5081
5082 /* Check filter direction. */
5083 if (strncmp (direct_str, "i", 1) == 0)
5084 direct = FILTER_IN;
5085 else if (strncmp (direct_str, "o", 1) == 0)
5086 direct = FILTER_OUT;
5087
5088 ret = peer_distribute_unset (peer, afi, safi, direct);
5089
5090 return bgp_vty_return (vty, ret);
5091}
5092
5093DEFUN (neighbor_distribute_list,
5094 neighbor_distribute_list_cmd,
5095 NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
5096 NEIGHBOR_STR
5097 NEIGHBOR_ADDR_STR2
5098 "Filter updates to/from this neighbor\n"
5099 "IP access-list number\n"
5100 "IP access-list number (expanded range)\n"
5101 "IP Access-list name\n"
5102 "Filter incoming updates\n"
5103 "Filter outgoing updates\n")
5104{
5105 return peer_distribute_set_vty (vty, argv[0], bgp_node_afi (vty),
5106 bgp_node_safi (vty), argv[1], argv[2]);
5107}
5108
5109DEFUN (no_neighbor_distribute_list,
5110 no_neighbor_distribute_list_cmd,
5111 NO_NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
5112 NO_STR
5113 NEIGHBOR_STR
5114 NEIGHBOR_ADDR_STR2
5115 "Filter updates to/from this neighbor\n"
5116 "IP access-list number\n"
5117 "IP access-list number (expanded range)\n"
5118 "IP Access-list name\n"
5119 "Filter incoming updates\n"
5120 "Filter outgoing updates\n")
5121{
5122 return peer_distribute_unset_vty (vty, argv[0], bgp_node_afi (vty),
5123 bgp_node_safi (vty), argv[2]);
5124}
6b0655a2 5125
718e3744 5126/* Set prefix list to the peer. */
94f2b392 5127static int
fd79ac91 5128peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
5129 safi_t safi, const char *name_str,
5130 const char *direct_str)
718e3744 5131{
5132 int ret;
5133 struct peer *peer;
5134 int direct = FILTER_IN;
5135
5136 peer = peer_and_group_lookup_vty (vty, ip_str);
5137 if (! peer)
5138 return CMD_WARNING;
5139
5140 /* Check filter direction. */
5141 if (strncmp (direct_str, "i", 1) == 0)
5142 direct = FILTER_IN;
5143 else if (strncmp (direct_str, "o", 1) == 0)
5144 direct = FILTER_OUT;
5145
5146 ret = peer_prefix_list_set (peer, afi, safi, direct, name_str);
5147
5148 return bgp_vty_return (vty, ret);
5149}
5150
94f2b392 5151static int
fd79ac91 5152peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5153 safi_t safi, const char *direct_str)
718e3744 5154{
5155 int ret;
5156 struct peer *peer;
5157 int direct = FILTER_IN;
5158
5159 peer = peer_and_group_lookup_vty (vty, ip_str);
5160 if (! peer)
5161 return CMD_WARNING;
5162
5163 /* Check filter direction. */
5164 if (strncmp (direct_str, "i", 1) == 0)
5165 direct = FILTER_IN;
5166 else if (strncmp (direct_str, "o", 1) == 0)
5167 direct = FILTER_OUT;
5168
5169 ret = peer_prefix_list_unset (peer, afi, safi, direct);
5170
5171 return bgp_vty_return (vty, ret);
5172}
5173
5174DEFUN (neighbor_prefix_list,
5175 neighbor_prefix_list_cmd,
5176 NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
5177 NEIGHBOR_STR
5178 NEIGHBOR_ADDR_STR2
5179 "Filter updates to/from this neighbor\n"
5180 "Name of a prefix list\n"
5181 "Filter incoming updates\n"
5182 "Filter outgoing updates\n")
5183{
5184 return peer_prefix_list_set_vty (vty, argv[0], bgp_node_afi (vty),
5185 bgp_node_safi (vty), argv[1], argv[2]);
5186}
5187
5188DEFUN (no_neighbor_prefix_list,
5189 no_neighbor_prefix_list_cmd,
5190 NO_NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
5191 NO_STR
5192 NEIGHBOR_STR
5193 NEIGHBOR_ADDR_STR2
5194 "Filter updates to/from this neighbor\n"
5195 "Name of a prefix list\n"
5196 "Filter incoming updates\n"
5197 "Filter outgoing updates\n")
5198{
5199 return peer_prefix_list_unset_vty (vty, argv[0], bgp_node_afi (vty),
5200 bgp_node_safi (vty), argv[2]);
5201}
6b0655a2 5202
94f2b392 5203static int
fd79ac91 5204peer_aslist_set_vty (struct vty *vty, const char *ip_str,
5205 afi_t afi, safi_t safi,
5206 const char *name_str, const char *direct_str)
718e3744 5207{
5208 int ret;
5209 struct peer *peer;
5210 int direct = FILTER_IN;
5211
5212 peer = peer_and_group_lookup_vty (vty, ip_str);
5213 if (! peer)
5214 return CMD_WARNING;
5215
5216 /* Check filter direction. */
5217 if (strncmp (direct_str, "i", 1) == 0)
5218 direct = FILTER_IN;
5219 else if (strncmp (direct_str, "o", 1) == 0)
5220 direct = FILTER_OUT;
5221
5222 ret = peer_aslist_set (peer, afi, safi, direct, name_str);
5223
5224 return bgp_vty_return (vty, ret);
5225}
5226
94f2b392 5227static int
fd79ac91 5228peer_aslist_unset_vty (struct vty *vty, const char *ip_str,
5229 afi_t afi, safi_t safi,
5230 const char *direct_str)
718e3744 5231{
5232 int ret;
5233 struct peer *peer;
5234 int direct = FILTER_IN;
5235
5236 peer = peer_and_group_lookup_vty (vty, ip_str);
5237 if (! peer)
5238 return CMD_WARNING;
5239
5240 /* Check filter direction. */
5241 if (strncmp (direct_str, "i", 1) == 0)
5242 direct = FILTER_IN;
5243 else if (strncmp (direct_str, "o", 1) == 0)
5244 direct = FILTER_OUT;
5245
5246 ret = peer_aslist_unset (peer, afi, safi, direct);
5247
5248 return bgp_vty_return (vty, ret);
5249}
5250
5251DEFUN (neighbor_filter_list,
5252 neighbor_filter_list_cmd,
5253 NEIGHBOR_CMD2 "filter-list WORD (in|out)",
5254 NEIGHBOR_STR
5255 NEIGHBOR_ADDR_STR2
5256 "Establish BGP filters\n"
5257 "AS path access-list name\n"
5258 "Filter incoming routes\n"
5259 "Filter outgoing routes\n")
5260{
5261 return peer_aslist_set_vty (vty, argv[0], bgp_node_afi (vty),
5262 bgp_node_safi (vty), argv[1], argv[2]);
5263}
5264
5265DEFUN (no_neighbor_filter_list,
5266 no_neighbor_filter_list_cmd,
5267 NO_NEIGHBOR_CMD2 "filter-list WORD (in|out)",
5268 NO_STR
5269 NEIGHBOR_STR
5270 NEIGHBOR_ADDR_STR2
5271 "Establish BGP filters\n"
5272 "AS path access-list name\n"
5273 "Filter incoming routes\n"
5274 "Filter outgoing routes\n")
5275{
5276 return peer_aslist_unset_vty (vty, argv[0], bgp_node_afi (vty),
5277 bgp_node_safi (vty), argv[2]);
5278}
6b0655a2 5279
718e3744 5280/* Set route-map to the peer. */
94f2b392 5281static int
fd79ac91 5282peer_route_map_set_vty (struct vty *vty, const char *ip_str,
5283 afi_t afi, safi_t safi,
5284 const char *name_str, const char *direct_str)
718e3744 5285{
5286 int ret;
5287 struct peer *peer;
fee0f4c6 5288 int direct = RMAP_IN;
718e3744 5289
5290 peer = peer_and_group_lookup_vty (vty, ip_str);
5291 if (! peer)
5292 return CMD_WARNING;
5293
5294 /* Check filter direction. */
fee0f4c6 5295 if (strncmp (direct_str, "in", 2) == 0)
5296 direct = RMAP_IN;
718e3744 5297 else if (strncmp (direct_str, "o", 1) == 0)
fee0f4c6 5298 direct = RMAP_OUT;
718e3744 5299
5300 ret = peer_route_map_set (peer, afi, safi, direct, name_str);
5301
5302 return bgp_vty_return (vty, ret);
5303}
5304
94f2b392 5305static int
fd79ac91 5306peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5307 safi_t safi, const char *direct_str)
718e3744 5308{
5309 int ret;
5310 struct peer *peer;
fee0f4c6 5311 int direct = RMAP_IN;
718e3744 5312
5313 peer = peer_and_group_lookup_vty (vty, ip_str);
5314 if (! peer)
5315 return CMD_WARNING;
5316
5317 /* Check filter direction. */
fee0f4c6 5318 if (strncmp (direct_str, "in", 2) == 0)
5319 direct = RMAP_IN;
718e3744 5320 else if (strncmp (direct_str, "o", 1) == 0)
fee0f4c6 5321 direct = RMAP_OUT;
718e3744 5322
5323 ret = peer_route_map_unset (peer, afi, safi, direct);
5324
5325 return bgp_vty_return (vty, ret);
5326}
5327
5328DEFUN (neighbor_route_map,
5329 neighbor_route_map_cmd,
2a3d5731 5330 NEIGHBOR_CMD2 "route-map WORD (in|out)",
718e3744 5331 NEIGHBOR_STR
5332 NEIGHBOR_ADDR_STR2
5333 "Apply route map to neighbor\n"
5334 "Name of route map\n"
5335 "Apply map to incoming routes\n"
2a3d5731 5336 "Apply map to outbound routes\n")
718e3744 5337{
5338 return peer_route_map_set_vty (vty, argv[0], bgp_node_afi (vty),
5339 bgp_node_safi (vty), argv[1], argv[2]);
5340}
5341
5342DEFUN (no_neighbor_route_map,
5343 no_neighbor_route_map_cmd,
2a3d5731 5344 NO_NEIGHBOR_CMD2 "route-map WORD (in|out)",
718e3744 5345 NO_STR
5346 NEIGHBOR_STR
5347 NEIGHBOR_ADDR_STR2
5348 "Apply route map to neighbor\n"
5349 "Name of route map\n"
5350 "Apply map to incoming routes\n"
2a3d5731 5351 "Apply map to outbound routes\n")
718e3744 5352{
5353 return peer_route_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
5354 bgp_node_safi (vty), argv[2]);
5355}
6b0655a2 5356
718e3744 5357/* Set unsuppress-map to the peer. */
94f2b392 5358static int
fd79ac91 5359peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
5360 safi_t safi, const char *name_str)
718e3744 5361{
5362 int ret;
5363 struct peer *peer;
5364
5365 peer = peer_and_group_lookup_vty (vty, ip_str);
5366 if (! peer)
5367 return CMD_WARNING;
5368
5369 ret = peer_unsuppress_map_set (peer, afi, safi, name_str);
5370
5371 return bgp_vty_return (vty, ret);
5372}
5373
5374/* Unset route-map from the peer. */
94f2b392 5375static int
fd79ac91 5376peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
718e3744 5377 safi_t safi)
5378{
5379 int ret;
5380 struct peer *peer;
5381
5382 peer = peer_and_group_lookup_vty (vty, ip_str);
5383 if (! peer)
5384 return CMD_WARNING;
5385
5386 ret = peer_unsuppress_map_unset (peer, afi, safi);
5387
5388 return bgp_vty_return (vty, ret);
5389}
5390
5391DEFUN (neighbor_unsuppress_map,
5392 neighbor_unsuppress_map_cmd,
5393 NEIGHBOR_CMD2 "unsuppress-map WORD",
5394 NEIGHBOR_STR
5395 NEIGHBOR_ADDR_STR2
5396 "Route-map to selectively unsuppress suppressed routes\n"
5397 "Name of route map\n")
5398{
5399 return peer_unsuppress_map_set_vty (vty, argv[0], bgp_node_afi (vty),
5400 bgp_node_safi (vty), argv[1]);
5401}
5402
5403DEFUN (no_neighbor_unsuppress_map,
5404 no_neighbor_unsuppress_map_cmd,
5405 NO_NEIGHBOR_CMD2 "unsuppress-map WORD",
5406 NO_STR
5407 NEIGHBOR_STR
5408 NEIGHBOR_ADDR_STR2
5409 "Route-map to selectively unsuppress suppressed routes\n"
5410 "Name of route map\n")
5411{
5412 return peer_unsuppress_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
5413 bgp_node_safi (vty));
5414}
6b0655a2 5415
94f2b392 5416static int
fd79ac91 5417peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
5418 safi_t safi, const char *num_str,
0a486e5f 5419 const char *threshold_str, int warning,
5420 const char *restart_str)
718e3744 5421{
5422 int ret;
5423 struct peer *peer;
5424 u_int32_t max;
e0701b79 5425 u_char threshold;
0a486e5f 5426 u_int16_t restart;
718e3744 5427
5428 peer = peer_and_group_lookup_vty (vty, ip_str);
5429 if (! peer)
5430 return CMD_WARNING;
5431
e6ec1c36 5432 VTY_GET_INTEGER ("maximum number", max, num_str);
e0701b79 5433 if (threshold_str)
5434 threshold = atoi (threshold_str);
5435 else
5436 threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT;
718e3744 5437
0a486e5f 5438 if (restart_str)
5439 restart = atoi (restart_str);
5440 else
5441 restart = 0;
5442
5443 ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart);
718e3744 5444
5445 return bgp_vty_return (vty, ret);
5446}
5447
94f2b392 5448static int
fd79ac91 5449peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
718e3744 5450 safi_t safi)
5451{
5452 int ret;
5453 struct peer *peer;
5454
5455 peer = peer_and_group_lookup_vty (vty, ip_str);
5456 if (! peer)
5457 return CMD_WARNING;
5458
5459 ret = peer_maximum_prefix_unset (peer, afi, safi);
5460
5461 return bgp_vty_return (vty, ret);
5462}
5463
5464/* Maximum number of prefix configuration. prefix count is different
5465 for each peer configuration. So this configuration can be set for
5466 each peer configuration. */
5467DEFUN (neighbor_maximum_prefix,
5468 neighbor_maximum_prefix_cmd,
5469 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
5470 NEIGHBOR_STR
5471 NEIGHBOR_ADDR_STR2
5472 "Maximum number of prefix accept from this peer\n"
5473 "maximum no. of prefix limit\n")
5474{
5475 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
0a486e5f 5476 bgp_node_safi (vty), argv[1], NULL, 0,
5477 NULL);
718e3744 5478}
5479
e0701b79 5480DEFUN (neighbor_maximum_prefix_threshold,
5481 neighbor_maximum_prefix_threshold_cmd,
5482 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100>",
5483 NEIGHBOR_STR
5484 NEIGHBOR_ADDR_STR2
5485 "Maximum number of prefix accept from this peer\n"
5486 "maximum no. of prefix limit\n"
5487 "Threshold value (%) at which to generate a warning msg\n")
5488{
5489 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
0a486e5f 5490 bgp_node_safi (vty), argv[1], argv[2], 0,
5491 NULL);
5492}
e0701b79 5493
718e3744 5494DEFUN (neighbor_maximum_prefix_warning,
5495 neighbor_maximum_prefix_warning_cmd,
5496 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
5497 NEIGHBOR_STR
5498 NEIGHBOR_ADDR_STR2
5499 "Maximum number of prefix accept from this peer\n"
5500 "maximum no. of prefix limit\n"
5501 "Only give warning message when limit is exceeded\n")
5502{
5503 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
0a486e5f 5504 bgp_node_safi (vty), argv[1], NULL, 1,
5505 NULL);
718e3744 5506}
5507
e0701b79 5508DEFUN (neighbor_maximum_prefix_threshold_warning,
5509 neighbor_maximum_prefix_threshold_warning_cmd,
5510 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
5511 NEIGHBOR_STR
5512 NEIGHBOR_ADDR_STR2
5513 "Maximum number of prefix accept from this peer\n"
5514 "maximum no. of prefix limit\n"
5515 "Threshold value (%) at which to generate a warning msg\n"
5516 "Only give warning message when limit is exceeded\n")
5517{
5518 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
0a486e5f 5519 bgp_node_safi (vty), argv[1], argv[2], 1, NULL);
5520}
5521
5522DEFUN (neighbor_maximum_prefix_restart,
5523 neighbor_maximum_prefix_restart_cmd,
5524 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
5525 NEIGHBOR_STR
5526 NEIGHBOR_ADDR_STR2
5527 "Maximum number of prefix accept from this peer\n"
5528 "maximum no. of prefix limit\n"
5529 "Restart bgp connection after limit is exceeded\n"
5530 "Restart interval in minutes")
5531{
5532 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
5533 bgp_node_safi (vty), argv[1], NULL, 0, argv[2]);
5534}
5535
5536DEFUN (neighbor_maximum_prefix_threshold_restart,
5537 neighbor_maximum_prefix_threshold_restart_cmd,
5538 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
5539 NEIGHBOR_STR
5540 NEIGHBOR_ADDR_STR2
5541 "Maximum number of prefix accept from this peer\n"
5542 "maximum no. of prefix limit\n"
5543 "Threshold value (%) at which to generate a warning msg\n"
5544 "Restart bgp connection after limit is exceeded\n"
5545 "Restart interval in minutes")
5546{
5547 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
5548 bgp_node_safi (vty), argv[1], argv[2], 0, argv[3]);
5549}
e0701b79 5550
718e3744 5551DEFUN (no_neighbor_maximum_prefix,
5552 no_neighbor_maximum_prefix_cmd,
5553 NO_NEIGHBOR_CMD2 "maximum-prefix",
5554 NO_STR
5555 NEIGHBOR_STR
5556 NEIGHBOR_ADDR_STR2
5557 "Maximum number of prefix accept from this peer\n")
5558{
5559 return peer_maximum_prefix_unset_vty (vty, argv[0], bgp_node_afi (vty),
5560 bgp_node_safi (vty));
5561}
5562
5563ALIAS (no_neighbor_maximum_prefix,
5564 no_neighbor_maximum_prefix_val_cmd,
5565 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
5566 NO_STR
5567 NEIGHBOR_STR
5568 NEIGHBOR_ADDR_STR2
5569 "Maximum number of prefix accept from this peer\n"
5570 "maximum no. of prefix limit\n")
5571
5572ALIAS (no_neighbor_maximum_prefix,
0a486e5f 5573 no_neighbor_maximum_prefix_threshold_cmd,
813d4307 5574 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100>",
0a486e5f 5575 NO_STR
5576 NEIGHBOR_STR
5577 NEIGHBOR_ADDR_STR2
5578 "Maximum number of prefix accept from this peer\n"
5579 "maximum no. of prefix limit\n"
5580 "Threshold value (%) at which to generate a warning msg\n")
5581
5582ALIAS (no_neighbor_maximum_prefix,
5583 no_neighbor_maximum_prefix_warning_cmd,
5584 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
5585 NO_STR
5586 NEIGHBOR_STR
5587 NEIGHBOR_ADDR_STR2
5588 "Maximum number of prefix accept from this peer\n"
5589 "maximum no. of prefix limit\n"
e8e1946e 5590 "Only give warning message when limit is exceeded\n")
0a486e5f 5591
5592ALIAS (no_neighbor_maximum_prefix,
5593 no_neighbor_maximum_prefix_threshold_warning_cmd,
e0701b79 5594 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
5595 NO_STR
5596 NEIGHBOR_STR
5597 NEIGHBOR_ADDR_STR2
5598 "Maximum number of prefix accept from this peer\n"
5599 "maximum no. of prefix limit\n"
5600 "Threshold value (%) at which to generate a warning msg\n"
e8e1946e 5601 "Only give warning message when limit is exceeded\n")
e0701b79 5602
5603ALIAS (no_neighbor_maximum_prefix,
0a486e5f 5604 no_neighbor_maximum_prefix_restart_cmd,
5605 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
718e3744 5606 NO_STR
5607 NEIGHBOR_STR
5608 NEIGHBOR_ADDR_STR2
5609 "Maximum number of prefix accept from this peer\n"
5610 "maximum no. of prefix limit\n"
0a486e5f 5611 "Restart bgp connection after limit is exceeded\n"
5612 "Restart interval in minutes")
5613
5614ALIAS (no_neighbor_maximum_prefix,
5615 no_neighbor_maximum_prefix_threshold_restart_cmd,
5616 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
5617 NO_STR
5618 NEIGHBOR_STR
5619 NEIGHBOR_ADDR_STR2
5620 "Maximum number of prefix accept from this peer\n"
5621 "maximum no. of prefix limit\n"
5622 "Threshold value (%) at which to generate a warning msg\n"
5623 "Restart bgp connection after limit is exceeded\n"
5624 "Restart interval in minutes")
6b0655a2 5625
718e3744 5626/* "neighbor allowas-in" */
5627DEFUN (neighbor_allowas_in,
5628 neighbor_allowas_in_cmd,
5629 NEIGHBOR_CMD2 "allowas-in",
5630 NEIGHBOR_STR
5631 NEIGHBOR_ADDR_STR2
5632 "Accept as-path with my AS present in it\n")
5633{
5634 int ret;
5635 struct peer *peer;
fd79ac91 5636 unsigned int allow_num;
718e3744 5637
5638 peer = peer_and_group_lookup_vty (vty, argv[0]);
5639 if (! peer)
5640 return CMD_WARNING;
5641
5642 if (argc == 1)
5643 allow_num = 3;
5644 else
5645 VTY_GET_INTEGER_RANGE ("AS number", allow_num, argv[1], 1, 10);
5646
5647 ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty),
5648 allow_num);
5649
5650 return bgp_vty_return (vty, ret);
5651}
5652
5653ALIAS (neighbor_allowas_in,
5654 neighbor_allowas_in_arg_cmd,
5655 NEIGHBOR_CMD2 "allowas-in <1-10>",
5656 NEIGHBOR_STR
5657 NEIGHBOR_ADDR_STR2
5658 "Accept as-path with my AS present in it\n"
5659 "Number of occurances of AS number\n")
5660
5661DEFUN (no_neighbor_allowas_in,
5662 no_neighbor_allowas_in_cmd,
5663 NO_NEIGHBOR_CMD2 "allowas-in",
5664 NO_STR
5665 NEIGHBOR_STR
5666 NEIGHBOR_ADDR_STR2
5667 "allow local ASN appears in aspath attribute\n")
5668{
5669 int ret;
5670 struct peer *peer;
5671
5672 peer = peer_and_group_lookup_vty (vty, argv[0]);
5673 if (! peer)
5674 return CMD_WARNING;
5675
5676 ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty));
5677
5678 return bgp_vty_return (vty, ret);
5679}
6b0655a2 5680
813d4307
DW
5681ALIAS (no_neighbor_allowas_in,
5682 no_neighbor_allowas_in_val_cmd,
5683 NO_NEIGHBOR_CMD2 "allowas-in <1-10>",
5684 NO_STR
5685 NEIGHBOR_STR
5686 NEIGHBOR_ADDR_STR2
5687 "allow local ASN appears in aspath attribute\n"
5688 "Number of occurances of AS number\n")
5689
fa411a21
NH
5690DEFUN (neighbor_ttl_security,
5691 neighbor_ttl_security_cmd,
5692 NEIGHBOR_CMD2 "ttl-security hops <1-254>",
5693 NEIGHBOR_STR
5694 NEIGHBOR_ADDR_STR2
5695 "Specify the maximum number of hops to the BGP peer\n")
5696{
5697 struct peer *peer;
89b6d1f8 5698 int gtsm_hops;
fa411a21
NH
5699
5700 peer = peer_and_group_lookup_vty (vty, argv[0]);
5701 if (! peer)
5702 return CMD_WARNING;
5703
5704 VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[1], 1, 254);
5705
89b6d1f8 5706 return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, gtsm_hops));
fa411a21
NH
5707}
5708
5709DEFUN (no_neighbor_ttl_security,
5710 no_neighbor_ttl_security_cmd,
5711 NO_NEIGHBOR_CMD2 "ttl-security hops <1-254>",
5712 NO_STR
5713 NEIGHBOR_STR
5714 NEIGHBOR_ADDR_STR2
5715 "Specify the maximum number of hops to the BGP peer\n")
5716{
5717 struct peer *peer;
fa411a21
NH
5718
5719 peer = peer_and_group_lookup_vty (vty, argv[0]);
5720 if (! peer)
5721 return CMD_WARNING;
5722
89b6d1f8 5723 return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer));
fa411a21 5724}
6b0655a2 5725
adbac85e
DW
5726DEFUN (neighbor_addpath_tx_all_paths,
5727 neighbor_addpath_tx_all_paths_cmd,
5728 NEIGHBOR_CMD2 "addpath-tx-all-paths",
5729 NEIGHBOR_STR
5730 NEIGHBOR_ADDR_STR2
5731 "Use addpath to advertise all paths to a neighbor\n")
5732{
5733 struct peer *peer;
5734
adbac85e
DW
5735 peer = peer_and_group_lookup_vty (vty, argv[0]);
5736 if (! peer)
5737 return CMD_WARNING;
5738
5739 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
5740 bgp_node_safi (vty),
5741 PEER_FLAG_ADDPATH_TX_ALL_PATHS);
5742}
5743
5744DEFUN (no_neighbor_addpath_tx_all_paths,
5745 no_neighbor_addpath_tx_all_paths_cmd,
5746 NO_NEIGHBOR_CMD2 "addpath-tx-all-paths",
5747 NO_STR
5748 NEIGHBOR_STR
5749 NEIGHBOR_ADDR_STR2
5750 "Use addpath to advertise all paths to a neighbor\n")
5751{
5752 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
5753 bgp_node_safi (vty),
5754 PEER_FLAG_ADDPATH_TX_ALL_PATHS);
5755}
5756
06370dac
DW
5757DEFUN (neighbor_addpath_tx_bestpath_per_as,
5758 neighbor_addpath_tx_bestpath_per_as_cmd,
5759 NEIGHBOR_CMD2 "addpath-tx-bestpath-per-AS",
5760 NEIGHBOR_STR
5761 NEIGHBOR_ADDR_STR2
5762 "Use addpath to advertise the bestpath per each neighboring AS\n")
5763{
5764 struct peer *peer;
5765
5766 peer = peer_and_group_lookup_vty (vty, argv[0]);
5767 if (! peer)
5768 return CMD_WARNING;
5769
5770 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
5771 bgp_node_safi (vty),
5772 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS);
5773}
5774
5775DEFUN (no_neighbor_addpath_tx_bestpath_per_as,
5776 no_neighbor_addpath_tx_bestpath_per_as_cmd,
5777 NO_NEIGHBOR_CMD2 "addpath-tx-bestpath-per-AS",
5778 NO_STR
5779 NEIGHBOR_STR
5780 NEIGHBOR_ADDR_STR2
5781 "Use addpath to advertise the bestpath per each neighboring AS\n")
5782{
5783 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
5784 bgp_node_safi (vty),
5785 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS);
5786}
5787
5788
718e3744 5789/* Address family configuration. */
5790DEFUN (address_family_ipv4,
5791 address_family_ipv4_cmd,
5792 "address-family ipv4",
5793 "Enter Address Family command mode\n"
5794 "Address family\n")
5795{
5796 vty->node = BGP_IPV4_NODE;
5797 return CMD_SUCCESS;
5798}
5799
5800DEFUN (address_family_ipv4_safi,
5801 address_family_ipv4_safi_cmd,
5802 "address-family ipv4 (unicast|multicast)",
5803 "Enter Address Family command mode\n"
5804 "Address family\n"
5805 "Address Family modifier\n"
5806 "Address Family modifier\n")
5807{
5808 if (strncmp (argv[0], "m", 1) == 0)
5809 vty->node = BGP_IPV4M_NODE;
5810 else
5811 vty->node = BGP_IPV4_NODE;
5812
5813 return CMD_SUCCESS;
5814}
5815
25ffbdc1 5816DEFUN (address_family_ipv6,
5817 address_family_ipv6_cmd,
5818 "address-family ipv6",
718e3744 5819 "Enter Address Family command mode\n"
25ffbdc1 5820 "Address family\n")
718e3744 5821{
5822 vty->node = BGP_IPV6_NODE;
5823 return CMD_SUCCESS;
5824}
5825
25ffbdc1 5826DEFUN (address_family_ipv6_safi,
5827 address_family_ipv6_safi_cmd,
5828 "address-family ipv6 (unicast|multicast)",
718e3744 5829 "Enter Address Family command mode\n"
25ffbdc1 5830 "Address family\n"
5831 "Address Family modifier\n"
5832 "Address Family modifier\n")
5833{
5834 if (strncmp (argv[0], "m", 1) == 0)
5835 vty->node = BGP_IPV6M_NODE;
5836 else
5837 vty->node = BGP_IPV6_NODE;
5838
5839 return CMD_SUCCESS;
5840}
718e3744 5841
5842DEFUN (address_family_vpnv4,
5843 address_family_vpnv4_cmd,
5844 "address-family vpnv4",
5845 "Enter Address Family command mode\n"
5846 "Address family\n")
5847{
5848 vty->node = BGP_VPNV4_NODE;
5849 return CMD_SUCCESS;
5850}
5851
5852ALIAS (address_family_vpnv4,
5853 address_family_vpnv4_unicast_cmd,
5854 "address-family vpnv4 unicast",
5855 "Enter Address Family command mode\n"
5856 "Address family\n"
5857 "Address Family Modifier\n")
5858
5859DEFUN (exit_address_family,
5860 exit_address_family_cmd,
5861 "exit-address-family",
5862 "Exit from Address Family configuration mode\n")
5863{
a8a80d53 5864 if (vty->node == BGP_IPV4_NODE
5865 || vty->node == BGP_IPV4M_NODE
718e3744 5866 || vty->node == BGP_VPNV4_NODE
25ffbdc1 5867 || vty->node == BGP_IPV6_NODE
5868 || vty->node == BGP_IPV6M_NODE)
718e3744 5869 vty->node = BGP_NODE;
5870 return CMD_SUCCESS;
5871}
6b0655a2 5872
8ad7271d
DS
5873/* Recalculate bestpath and re-advertise a prefix */
5874static int
01080f7c 5875bgp_clear_prefix (struct vty *vty, const char *view_name, const char *ip_str,
8ad7271d
DS
5876 afi_t afi, safi_t safi, struct prefix_rd *prd)
5877{
5878 int ret;
5879 struct prefix match;
5880 struct bgp_node *rn;
5881 struct bgp_node *rm;
8ad7271d
DS
5882 struct bgp *bgp;
5883 struct bgp_table *table;
5884 struct bgp_table *rib;
5885
5886 /* BGP structure lookup. */
5887 if (view_name)
5888 {
5889 bgp = bgp_lookup_by_name (view_name);
5890 if (bgp == NULL)
5891 {
6aeb9e78 5892 vty_out (vty, "%% Can't find BGP instance %s%s", view_name, VTY_NEWLINE);
8ad7271d
DS
5893 return CMD_WARNING;
5894 }
5895 }
5896 else
5897 {
5898 bgp = bgp_get_default ();
5899 if (bgp == NULL)
5900 {
5901 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
5902 return CMD_WARNING;
5903 }
5904 }
5905
5906 /* Check IP address argument. */
5907 ret = str2prefix (ip_str, &match);
5908 if (! ret)
5909 {
5910 vty_out (vty, "%% address is malformed%s", VTY_NEWLINE);
5911 return CMD_WARNING;
5912 }
5913
5914 match.family = afi2family (afi);
5915 rib = bgp->rib[afi][safi];
5916
5917 if (safi == SAFI_MPLS_VPN)
5918 {
5919 for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn))
5920 {
5921 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
5922 continue;
5923
5924 if ((table = rn->info) != NULL)
5925 {
5926 if ((rm = bgp_node_match (table, &match)) != NULL)
5927 {
5928 if (rm->p.prefixlen == match.prefixlen)
5929 {
5930 SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR);
5931 bgp_process (bgp, rm, afi, safi);
5932 }
5933 bgp_unlock_node (rm);
5934 }
5935 }
5936 }
5937 }
5938 else
5939 {
5940 if ((rn = bgp_node_match (rib, &match)) != NULL)
5941 {
5942 if (rn->p.prefixlen == match.prefixlen)
5943 {
5944 SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR);
5945 bgp_process (bgp, rn, afi, safi);
5946 }
5947 bgp_unlock_node (rn);
5948 }
5949 }
5950
5951 return CMD_SUCCESS;
5952}
5953
718e3744 5954DEFUN (clear_ip_bgp_all,
5955 clear_ip_bgp_all_cmd,
5956 "clear ip bgp *",
5957 CLEAR_STR
5958 IP_STR
5959 BGP_STR
5960 "Clear all peers\n")
5961{
6aeb9e78
DS
5962 if (argc == 2)
5963 return bgp_clear_vty (vty, argv[1], 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
718e3744 5964
5965 return bgp_clear_vty (vty, NULL, 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
5966}
5967
01080f7c 5968ALIAS (clear_ip_bgp_all,
5969 clear_ip_bgp_instance_all_cmd,
5970 "clear ip bgp " BGP_INSTANCE_CMD " *",
5971 CLEAR_STR
5972 IP_STR
5973 BGP_STR
5974 BGP_INSTANCE_HELP_STR
5975 "Clear all peers\n")
5976
718e3744 5977ALIAS (clear_ip_bgp_all,
5978 clear_bgp_all_cmd,
5979 "clear bgp *",
5980 CLEAR_STR
5981 BGP_STR
5982 "Clear all peers\n")
5983
5984ALIAS (clear_ip_bgp_all,
01080f7c 5985 clear_bgp_instance_all_cmd,
5986 "clear bgp " BGP_INSTANCE_CMD " *",
718e3744 5987 CLEAR_STR
5988 BGP_STR
01080f7c 5989 BGP_INSTANCE_HELP_STR
718e3744 5990 "Clear all peers\n")
5991
5992ALIAS (clear_ip_bgp_all,
01080f7c 5993 clear_bgp_ipv6_all_cmd,
5994 "clear bgp ipv6 *",
718e3744 5995 CLEAR_STR
718e3744 5996 BGP_STR
01080f7c 5997 "Address family\n"
718e3744 5998 "Clear all peers\n")
5999
6000ALIAS (clear_ip_bgp_all,
01080f7c 6001 clear_bgp_instance_ipv6_all_cmd,
6002 "clear bgp " BGP_INSTANCE_CMD " ipv6 *",
718e3744 6003 CLEAR_STR
6004 BGP_STR
8386ac43 6005 BGP_INSTANCE_HELP_STR
01080f7c 6006 "Address family\n"
718e3744 6007 "Clear all peers\n")
6008
6009DEFUN (clear_ip_bgp_peer,
6010 clear_ip_bgp_peer_cmd,
a80beece 6011 "clear ip bgp (A.B.C.D|X:X::X:X|WORD)",
718e3744 6012 CLEAR_STR
6013 IP_STR
6014 BGP_STR
6015 "BGP neighbor IP address to clear\n"
a80beece
DS
6016 "BGP IPv6 neighbor to clear\n"
6017 "BGP neighbor on interface to clear\n")
718e3744 6018{
01080f7c 6019 if (argc == 3)
6020 return bgp_clear_vty (vty, argv[1], 0, 0, clear_peer, BGP_CLEAR_SOFT_NONE, argv[2]);
6021
718e3744 6022 return bgp_clear_vty (vty, NULL, 0, 0, clear_peer, BGP_CLEAR_SOFT_NONE, argv[0]);
6023}
6024
01080f7c 6025ALIAS (clear_ip_bgp_peer,
6026 clear_ip_bgp_instance_peer_cmd,
6027 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD)",
6028 CLEAR_STR
6029 IP_STR
6030 BGP_STR
6031 BGP_INSTANCE_HELP_STR
6032 "BGP neighbor IP address to clear\n"
6033 "BGP IPv6 neighbor to clear\n"
6034 "BGP neighbor on interface to clear\n")
6035
718e3744 6036ALIAS (clear_ip_bgp_peer,
6037 clear_bgp_peer_cmd,
a80beece 6038 "clear bgp (A.B.C.D|X:X::X:X|WORD)",
718e3744 6039 CLEAR_STR
6040 BGP_STR
6041 "BGP neighbor address to clear\n"
a80beece
DS
6042 "BGP IPv6 neighbor to clear\n"
6043 "BGP neighbor on interface to clear\n")
718e3744 6044
01080f7c 6045ALIAS (clear_ip_bgp_peer,
6046 clear_bgp_instance_peer_cmd,
6047 "clear bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD)",
6048 CLEAR_STR
6049 BGP_STR
6050 BGP_INSTANCE_HELP_STR
6051 "BGP neighbor IP address to clear\n"
6052 "BGP IPv6 neighbor to clear\n"
6053 "BGP neighbor on interface to clear\n")
6054
718e3744 6055ALIAS (clear_ip_bgp_peer,
6056 clear_bgp_ipv6_peer_cmd,
a80beece 6057 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD)",
718e3744 6058 CLEAR_STR
6059 BGP_STR
6060 "Address family\n"
6061 "BGP neighbor address to clear\n"
a80beece
DS
6062 "BGP IPv6 neighbor to clear\n"
6063 "BGP neighbor on interface to clear\n")
718e3744 6064
01080f7c 6065ALIAS (clear_ip_bgp_peer,
6066 clear_bgp_instance_ipv6_peer_cmd,
6067 "clear bgp " BGP_INSTANCE_CMD " ipv6 (A.B.C.D|X:X::X:X|WORD)",
6068 CLEAR_STR
6069 BGP_STR
6070 BGP_INSTANCE_HELP_STR
6071 "Address family\n"
6072 "BGP neighbor IP address to clear\n"
6073 "BGP IPv6 neighbor to clear\n"
6074 "BGP neighbor on interface to clear\n")
6075
718e3744 6076DEFUN (clear_ip_bgp_peer_group,
6077 clear_ip_bgp_peer_group_cmd,
6078 "clear ip bgp peer-group WORD",
6079 CLEAR_STR
6080 IP_STR
6081 BGP_STR
6082 "Clear all members of peer-group\n"
6083 "BGP peer-group name\n")
6084{
01080f7c 6085 if (argc == 3)
6086 return bgp_clear_vty (vty, argv[1], 0, 0, clear_group, BGP_CLEAR_SOFT_NONE, argv[2]);
6087
718e3744 6088 return bgp_clear_vty (vty, NULL, 0, 0, clear_group, BGP_CLEAR_SOFT_NONE, argv[0]);
6089}
6090
01080f7c 6091ALIAS (clear_ip_bgp_peer_group,
6092 clear_ip_bgp_instance_peer_group_cmd,
6093 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD",
6094 CLEAR_STR
6095 IP_STR
6096 BGP_STR
6097 BGP_INSTANCE_HELP_STR
6098 "Clear all members of peer-group\n"
6099 "BGP peer-group name\n")
6100
718e3744 6101ALIAS (clear_ip_bgp_peer_group,
6102 clear_bgp_peer_group_cmd,
6103 "clear bgp peer-group WORD",
6104 CLEAR_STR
6105 BGP_STR
6106 "Clear all members of peer-group\n"
6107 "BGP peer-group name\n")
6108
01080f7c 6109ALIAS (clear_ip_bgp_peer_group,
6110 clear_bgp_instance_peer_group_cmd,
6111 "clear bgp " BGP_INSTANCE_CMD " peer-group WORD",
6112 CLEAR_STR
6113 BGP_STR
6114 BGP_INSTANCE_HELP_STR
6115 "Clear all members of peer-group\n"
6116 "BGP peer-group name\n")
6117
718e3744 6118ALIAS (clear_ip_bgp_peer_group,
6119 clear_bgp_ipv6_peer_group_cmd,
6120 "clear bgp ipv6 peer-group WORD",
6121 CLEAR_STR
6122 BGP_STR
6123 "Address family\n"
6124 "Clear all members of peer-group\n"
6125 "BGP peer-group name\n")
6126
01080f7c 6127ALIAS (clear_ip_bgp_peer_group,
6128 clear_bgp_instance_ipv6_peer_group_cmd,
6129 "clear bgp " BGP_INSTANCE_CMD " ipv6 peer-group WORD",
6130 CLEAR_STR
6131 BGP_STR
6132 BGP_INSTANCE_HELP_STR
6133 "Address family\n"
6134 "Clear all members of peer-group\n"
6135 "BGP peer-group name\n")
6136
718e3744 6137DEFUN (clear_ip_bgp_external,
6138 clear_ip_bgp_external_cmd,
6139 "clear ip bgp external",
6140 CLEAR_STR
6141 IP_STR
6142 BGP_STR
6143 "Clear all external peers\n")
6144{
01080f7c 6145 if (argc == 2)
6146 return bgp_clear_vty (vty, argv[1], 0, 0, clear_external, BGP_CLEAR_SOFT_NONE, NULL);
6147
718e3744 6148 return bgp_clear_vty (vty, NULL, 0, 0, clear_external, BGP_CLEAR_SOFT_NONE, NULL);
6149}
6150
01080f7c 6151ALIAS (clear_ip_bgp_external,
6152 clear_ip_bgp_instance_external_cmd,
6153 "clear ip bgp " BGP_INSTANCE_CMD " external",
6154 CLEAR_STR
6155 IP_STR
6156 BGP_STR
6157 BGP_INSTANCE_HELP_STR
6158 "Clear all external peers\n")
6159
718e3744 6160ALIAS (clear_ip_bgp_external,
6161 clear_bgp_external_cmd,
6162 "clear bgp external",
6163 CLEAR_STR
6164 BGP_STR
6165 "Clear all external peers\n")
6166
01080f7c 6167ALIAS (clear_ip_bgp_external,
6168 clear_bgp_instance_external_cmd,
6169 "clear bgp " BGP_INSTANCE_CMD " external",
6170 CLEAR_STR
6171 BGP_STR
6172 BGP_INSTANCE_HELP_STR
6173 "Clear all external peers\n")
6174
718e3744 6175ALIAS (clear_ip_bgp_external,
6176 clear_bgp_ipv6_external_cmd,
6177 "clear bgp ipv6 external",
6178 CLEAR_STR
6179 BGP_STR
6180 "Address family\n"
6181 "Clear all external peers\n")
6182
01080f7c 6183ALIAS (clear_ip_bgp_external,
6184 clear_bgp_instance_ipv6_external_cmd,
6185 "clear bgp " BGP_INSTANCE_CMD " ipv6 external",
6186 CLEAR_STR
6187 BGP_STR
6188 BGP_INSTANCE_HELP_STR
6189 "Address family\n"
6190 "Clear all external peers\n")
6191
8ad7271d
DS
6192DEFUN (clear_ip_bgp_prefix,
6193 clear_ip_bgp_prefix_cmd,
6194 "clear ip bgp prefix A.B.C.D/M",
6195 CLEAR_STR
6196 IP_STR
6197 BGP_STR
6198 "Clear bestpath and re-advertise\n"
6199 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6200{
01080f7c 6201 if (argc == 3)
6202 return bgp_clear_prefix (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL);
6203
8ad7271d
DS
6204 return bgp_clear_prefix (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL);
6205}
6206
01080f7c 6207ALIAS (clear_ip_bgp_prefix,
6208 clear_ip_bgp_instance_prefix_cmd,
6209 "clear ip bgp " BGP_INSTANCE_CMD " prefix A.B.C.D/M",
6210 CLEAR_STR
6211 IP_STR
6212 BGP_STR
6213 BGP_INSTANCE_HELP_STR
6214 "Clear bestpath and re-advertise\n"
6215 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6216
8ad7271d
DS
6217ALIAS (clear_ip_bgp_prefix,
6218 clear_bgp_prefix_cmd,
6219 "clear bgp prefix A.B.C.D/M",
6220 CLEAR_STR
6221 BGP_STR
6222 "Clear bestpath and re-advertise\n"
6223 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6224
01080f7c 6225ALIAS (clear_ip_bgp_prefix,
6226 clear_bgp_instance_prefix_cmd,
6227 "clear bgp " BGP_INSTANCE_CMD " prefix A.B.C.D/M",
6228 CLEAR_STR
6229 BGP_STR
6230 BGP_INSTANCE_HELP_STR
6231 "Clear bestpath and re-advertise\n"
6232 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8ad7271d 6233
718e3744 6234DEFUN (clear_ip_bgp_as,
6235 clear_ip_bgp_as_cmd,
320da874 6236 "clear ip bgp " CMD_AS_RANGE,
718e3744 6237 CLEAR_STR
6238 IP_STR
6239 BGP_STR
6240 "Clear peers with the AS number\n")
6241{
01080f7c 6242 if (argc == 3)
6243 return bgp_clear_vty (vty, argv[1], 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[2]);
6244
718e3744 6245 return bgp_clear_vty (vty, NULL, 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[0]);
6246}
6247
01080f7c 6248ALIAS (clear_ip_bgp_as,
6249 clear_ip_bgp_instance_as_cmd,
6250 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE,
6251 CLEAR_STR
6252 IP_STR
6253 BGP_STR
6254 BGP_INSTANCE_HELP_STR
6255 "Clear peers with the AS number\n")
6256
718e3744 6257ALIAS (clear_ip_bgp_as,
6258 clear_bgp_as_cmd,
320da874 6259 "clear bgp " CMD_AS_RANGE,
718e3744 6260 CLEAR_STR
6261 BGP_STR
6262 "Clear peers with the AS number\n")
6263
01080f7c 6264ALIAS (clear_ip_bgp_as,
6265 clear_bgp_instance_as_cmd,
6266 "clear bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE,
6267 CLEAR_STR
6268 BGP_STR
6269 BGP_INSTANCE_HELP_STR
6270 "Clear peers with the AS number\n")
6271
718e3744 6272ALIAS (clear_ip_bgp_as,
6273 clear_bgp_ipv6_as_cmd,
320da874 6274 "clear bgp ipv6 " CMD_AS_RANGE,
718e3744 6275 CLEAR_STR
6276 BGP_STR
6277 "Address family\n"
6278 "Clear peers with the AS number\n")
6b0655a2 6279
01080f7c 6280ALIAS (clear_ip_bgp_as,
6281 clear_bgp_instance_ipv6_as_cmd,
6282 "clear bgp " BGP_INSTANCE_CMD " ipv6 " CMD_AS_RANGE,
6283 CLEAR_STR
6284 BGP_STR
6285 BGP_INSTANCE_HELP_STR
6286 "Address family\n"
6287 "Clear peers with the AS number\n")
6288
718e3744 6289/* Outbound soft-reconfiguration */
6290DEFUN (clear_ip_bgp_all_soft_out,
6291 clear_ip_bgp_all_soft_out_cmd,
6292 "clear ip bgp * soft out",
6293 CLEAR_STR
6294 IP_STR
6295 BGP_STR
6296 "Clear all peers\n"
e0bce756
DS
6297 BGP_SOFT_STR
6298 BGP_SOFT_OUT_STR)
718e3744 6299{
6aeb9e78
DS
6300 if (argc == 2)
6301 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all,
718e3744 6302 BGP_CLEAR_SOFT_OUT, NULL);
6303
6304 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6305 BGP_CLEAR_SOFT_OUT, NULL);
6306}
6307
01080f7c 6308ALIAS (clear_ip_bgp_all_soft_out,
6309 clear_ip_bgp_instance_all_soft_out_cmd,
6310 "clear ip bgp " BGP_INSTANCE_CMD " * soft out",
6311 CLEAR_STR
6312 IP_STR
6313 BGP_STR
6314 BGP_INSTANCE_HELP_STR
6315 "Clear all peers\n"
6316 BGP_SOFT_STR
6317 BGP_SOFT_OUT_STR)
6318
718e3744 6319ALIAS (clear_ip_bgp_all_soft_out,
6320 clear_ip_bgp_all_out_cmd,
6321 "clear ip bgp * out",
6322 CLEAR_STR
6323 IP_STR
6324 BGP_STR
6325 "Clear all peers\n"
e0bce756 6326 BGP_SOFT_OUT_STR)
718e3744 6327
6328ALIAS (clear_ip_bgp_all_soft_out,
01080f7c 6329 clear_ip_bgp_instance_all_out_cmd,
6330 "clear ip bgp " BGP_INSTANCE_CMD " * out",
718e3744 6331 CLEAR_STR
6332 IP_STR
6333 BGP_STR
8386ac43 6334 BGP_INSTANCE_HELP_STR
718e3744 6335 "Clear all peers\n"
e0bce756 6336 BGP_SOFT_OUT_STR)
718e3744 6337
6338DEFUN (clear_ip_bgp_all_ipv4_soft_out,
6339 clear_ip_bgp_all_ipv4_soft_out_cmd,
6340 "clear ip bgp * ipv4 (unicast|multicast) soft out",
6341 CLEAR_STR
6342 IP_STR
6343 BGP_STR
6344 "Clear all peers\n"
6345 "Address family\n"
6346 "Address Family modifier\n"
6347 "Address Family modifier\n"
e0bce756
DS
6348 BGP_SOFT_STR
6349 BGP_SOFT_OUT_STR)
718e3744 6350{
6351 if (strncmp (argv[0], "m", 1) == 0)
6352 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
6353 BGP_CLEAR_SOFT_OUT, NULL);
6354
6355 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6356 BGP_CLEAR_SOFT_OUT, NULL);
6357}
6358
01080f7c 6359DEFUN (clear_ip_bgp_instance_all_ipv4_soft_out,
6360 clear_ip_bgp_instance_all_ipv4_soft_out_cmd,
6361 "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) soft out",
6362 CLEAR_STR
6363 IP_STR
6364 BGP_STR
6365 BGP_INSTANCE_HELP_STR
6366 "Clear all peers\n"
6367 "Address family\n"
6368 "Address Family modifier\n"
6369 "Address Family modifier\n"
6370 BGP_SOFT_OUT_STR)
6371{
6372 if (strncmp (argv[2], "m", 1) == 0)
6373 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_all,
6374 BGP_CLEAR_SOFT_OUT, NULL);
6375
6376 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
6377 BGP_CLEAR_SOFT_OUT, NULL);
6378}
6379
718e3744 6380ALIAS (clear_ip_bgp_all_ipv4_soft_out,
6381 clear_ip_bgp_all_ipv4_out_cmd,
6382 "clear ip bgp * ipv4 (unicast|multicast) out",
6383 CLEAR_STR
6384 IP_STR
6385 BGP_STR
6386 "Clear all peers\n"
6387 "Address family\n"
6388 "Address Family modifier\n"
6389 "Address Family modifier\n"
e0bce756 6390 BGP_SOFT_OUT_STR)
718e3744 6391
01080f7c 6392ALIAS (clear_ip_bgp_instance_all_ipv4_soft_out,
6393 clear_ip_bgp_instance_all_ipv4_out_cmd,
6394 "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) out",
718e3744 6395 CLEAR_STR
6396 IP_STR
6397 BGP_STR
8386ac43 6398 BGP_INSTANCE_HELP_STR
718e3744 6399 "Clear all peers\n"
6400 "Address family\n"
6401 "Address Family modifier\n"
6402 "Address Family modifier\n"
e0bce756 6403 BGP_SOFT_OUT_STR)
718e3744 6404
6405DEFUN (clear_ip_bgp_all_vpnv4_soft_out,
6406 clear_ip_bgp_all_vpnv4_soft_out_cmd,
6407 "clear ip bgp * vpnv4 unicast soft out",
6408 CLEAR_STR
6409 IP_STR
6410 BGP_STR
6411 "Clear all peers\n"
6412 "Address family\n"
6413 "Address Family Modifier\n"
e0bce756
DS
6414 BGP_SOFT_STR
6415 BGP_SOFT_OUT_STR)
718e3744 6416{
6417 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
6418 BGP_CLEAR_SOFT_OUT, NULL);
6419}
6420
6421ALIAS (clear_ip_bgp_all_vpnv4_soft_out,
6422 clear_ip_bgp_all_vpnv4_out_cmd,
6423 "clear ip bgp * vpnv4 unicast out",
6424 CLEAR_STR
6425 IP_STR
6426 BGP_STR
6427 "Clear all peers\n"
6428 "Address family\n"
6429 "Address Family Modifier\n"
e0bce756 6430 BGP_SOFT_OUT_STR)
718e3744 6431
6432DEFUN (clear_bgp_all_soft_out,
6433 clear_bgp_all_soft_out_cmd,
6434 "clear bgp * soft out",
6435 CLEAR_STR
6436 BGP_STR
6437 "Clear all peers\n"
e0bce756
DS
6438 BGP_SOFT_STR
6439 BGP_SOFT_OUT_STR)
718e3744 6440{
6aeb9e78
DS
6441 if (argc == 2)
6442 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_all,
718e3744 6443 BGP_CLEAR_SOFT_OUT, NULL);
6444
6445 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
6446 BGP_CLEAR_SOFT_OUT, NULL);
6447}
6448
6449ALIAS (clear_bgp_all_soft_out,
6450 clear_bgp_instance_all_soft_out_cmd,
8386ac43 6451 "clear bgp " BGP_INSTANCE_CMD " * soft out",
718e3744 6452 CLEAR_STR
6453 BGP_STR
8386ac43 6454 BGP_INSTANCE_HELP_STR
718e3744 6455 "Clear all peers\n"
e0bce756
DS
6456 BGP_SOFT_STR
6457 BGP_SOFT_OUT_STR)
718e3744 6458
6459ALIAS (clear_bgp_all_soft_out,
6460 clear_bgp_all_out_cmd,
6461 "clear bgp * out",
6462 CLEAR_STR
6463 BGP_STR
6464 "Clear all peers\n"
e0bce756 6465 BGP_SOFT_OUT_STR)
718e3744 6466
01080f7c 6467ALIAS (clear_bgp_all_soft_out,
6468 clear_bgp_instance_all_out_cmd,
6469 "clear bgp " BGP_INSTANCE_CMD " * out",
6470 CLEAR_STR
6471 BGP_STR
6472 BGP_INSTANCE_HELP_STR
6473 "Clear all peers\n"
6474 BGP_SOFT_OUT_STR)
6475
718e3744 6476ALIAS (clear_bgp_all_soft_out,
6477 clear_bgp_ipv6_all_soft_out_cmd,
6478 "clear bgp ipv6 * soft out",
6479 CLEAR_STR
6480 BGP_STR
6481 "Address family\n"
6482 "Clear all peers\n"
e0bce756
DS
6483 BGP_SOFT_STR
6484 BGP_SOFT_OUT_STR)
718e3744 6485
01080f7c 6486ALIAS (clear_bgp_all_soft_out,
6487 clear_bgp_instance_ipv6_all_soft_out_cmd,
6488 "clear bgp " BGP_INSTANCE_CMD " ipv6 * soft out",
6489 CLEAR_STR
6490 BGP_STR
6491 BGP_INSTANCE_HELP_STR
6492 "Address family\n"
6493 "Clear all peers\n"
6494 BGP_SOFT_STR
6495 BGP_SOFT_OUT_STR)
6496
718e3744 6497ALIAS (clear_bgp_all_soft_out,
6498 clear_bgp_ipv6_all_out_cmd,
6499 "clear bgp ipv6 * out",
6500 CLEAR_STR
6501 BGP_STR
6502 "Address family\n"
6503 "Clear all peers\n"
e0bce756 6504 BGP_SOFT_OUT_STR)
718e3744 6505
01080f7c 6506ALIAS (clear_bgp_all_soft_out,
6507 clear_bgp_instance_ipv6_all_out_cmd,
6508 "clear bgp " BGP_INSTANCE_CMD " ipv6 * out",
6509 CLEAR_STR
6510 BGP_STR
6511 BGP_INSTANCE_HELP_STR
6512 "Address family\n"
6513 "Clear all peers\n"
6514 BGP_SOFT_OUT_STR)
6515
8ad7271d
DS
6516DEFUN (clear_bgp_ipv6_safi_prefix,
6517 clear_bgp_ipv6_safi_prefix_cmd,
6518 "clear bgp ipv6 (unicast|multicast) prefix X:X::X:X/M",
6519 CLEAR_STR
6520 BGP_STR
6521 "Address family\n"
6522 "Address Family Modifier\n"
6523 "Clear bestpath and re-advertise\n"
6524 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6525{
6526 if (strncmp (argv[0], "m", 1) == 0)
6527 return bgp_clear_prefix (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL);
6528 else
6529 return bgp_clear_prefix (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL);
6530}
6531
01080f7c 6532DEFUN (clear_bgp_instance_ipv6_safi_prefix,
6533 clear_bgp_instance_ipv6_safi_prefix_cmd,
6534 "clear bgp " BGP_INSTANCE_CMD " ipv6 (unicast|multicast) prefix X:X::X:X/M",
6535 CLEAR_STR
6536 BGP_STR
6537 BGP_INSTANCE_HELP_STR
6538 "Address family\n"
6539 "Address Family Modifier\n"
6540 "Clear bestpath and re-advertise\n"
6541 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6542{
6543 if (strncmp (argv[2], "m", 1) == 0)
6544 return bgp_clear_prefix (vty, argv[1], argv[3], AFI_IP6, SAFI_MULTICAST, NULL);
6545 else
6546 return bgp_clear_prefix (vty, argv[1], argv[3], AFI_IP6, SAFI_UNICAST, NULL);
6547}
6548
718e3744 6549DEFUN (clear_ip_bgp_peer_soft_out,
6550 clear_ip_bgp_peer_soft_out_cmd,
db64ea86 6551 "clear ip bgp (A.B.C.D|WORD) soft out",
718e3744 6552 CLEAR_STR
6553 IP_STR
6554 BGP_STR
6555 "BGP neighbor address to clear\n"
db64ea86 6556 "BGP neighbor on interface to clear\n"
e0bce756
DS
6557 BGP_SOFT_STR
6558 BGP_SOFT_OUT_STR)
718e3744 6559{
01080f7c 6560 if (argc == 3)
6561 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer,
6562 BGP_CLEAR_SOFT_OUT, argv[2]);
6563
718e3744 6564 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6565 BGP_CLEAR_SOFT_OUT, argv[0]);
6566}
6567
01080f7c 6568ALIAS (clear_ip_bgp_peer_soft_out,
6569 clear_ip_bgp_instance_peer_soft_out_cmd,
6570 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) soft out",
6571 CLEAR_STR
6572 IP_STR
6573 BGP_STR
6574 BGP_INSTANCE_HELP_STR
6575 "BGP neighbor address to clear\n"
6576 "BGP neighbor on interface to clear\n"
6577 BGP_SOFT_STR
6578 BGP_SOFT_OUT_STR)
6579
718e3744 6580ALIAS (clear_ip_bgp_peer_soft_out,
6581 clear_ip_bgp_peer_out_cmd,
db64ea86 6582 "clear ip bgp (A.B.C.D|WORD) out",
718e3744 6583 CLEAR_STR
6584 IP_STR
6585 BGP_STR
6586 "BGP neighbor address to clear\n"
db64ea86 6587 "BGP neighbor on interface to clear\n"
e0bce756 6588 BGP_SOFT_OUT_STR)
718e3744 6589
01080f7c 6590ALIAS (clear_ip_bgp_peer_soft_out,
6591 clear_ip_bgp_instance_peer_out_cmd,
6592 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) out",
6593 CLEAR_STR
6594 IP_STR
6595 BGP_STR
6596 BGP_INSTANCE_HELP_STR
6597 "BGP neighbor address to clear\n"
6598 "BGP neighbor on interface to clear\n"
6599 BGP_SOFT_OUT_STR)
6600
718e3744 6601DEFUN (clear_ip_bgp_peer_ipv4_soft_out,
6602 clear_ip_bgp_peer_ipv4_soft_out_cmd,
db64ea86 6603 "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) soft out",
718e3744 6604 CLEAR_STR
6605 IP_STR
6606 BGP_STR
6607 "BGP neighbor address to clear\n"
db64ea86 6608 "BGP neighbor on interface to clear\n"
718e3744 6609 "Address family\n"
6610 "Address Family modifier\n"
6611 "Address Family modifier\n"
e0bce756
DS
6612 BGP_SOFT_STR
6613 BGP_SOFT_OUT_STR)
718e3744 6614{
6615 if (strncmp (argv[1], "m", 1) == 0)
6616 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
6617 BGP_CLEAR_SOFT_OUT, argv[0]);
6618
6619 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6620 BGP_CLEAR_SOFT_OUT, argv[0]);
6621}
6622
01080f7c 6623DEFUN (clear_ip_bgp_instance_peer_ipv4_soft_out,
6624 clear_ip_bgp_instance_peer_ipv4_soft_out_cmd,
6625 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 (unicast|multicast) soft out",
6626 CLEAR_STR
6627 IP_STR
6628 BGP_STR
6629 BGP_INSTANCE_HELP_STR
6630 "BGP neighbor address to clear\n"
6631 "BGP neighbor on interface to clear\n"
6632 "Address family\n"
6633 "Address Family modifier\n"
6634 "Address Family modifier\n"
6635 BGP_SOFT_STR
6636 BGP_SOFT_OUT_STR)
6637{
6638 if (strncmp (argv[3], "m", 1) == 0)
6639 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_peer,
6640 BGP_CLEAR_SOFT_OUT, argv[2]);
6641
6642 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer,
6643 BGP_CLEAR_SOFT_OUT, argv[2]);
6644}
6645
718e3744 6646ALIAS (clear_ip_bgp_peer_ipv4_soft_out,
6647 clear_ip_bgp_peer_ipv4_out_cmd,
db64ea86 6648 "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) out",
718e3744 6649 CLEAR_STR
6650 IP_STR
6651 BGP_STR
6652 "BGP neighbor address to clear\n"
db64ea86 6653 "BGP neighbor on interface to clear\n"
718e3744 6654 "Address family\n"
6655 "Address Family modifier\n"
6656 "Address Family modifier\n"
e0bce756 6657 BGP_SOFT_OUT_STR)
718e3744 6658
01080f7c 6659ALIAS (clear_ip_bgp_instance_peer_ipv4_soft_out,
6660 clear_ip_bgp_instance_peer_ipv4_out_cmd,
6661 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 (unicast|multicast) out",
6662 CLEAR_STR
6663 IP_STR
6664 BGP_STR
6665 BGP_INSTANCE_HELP_STR
6666 "BGP neighbor address to clear\n"
6667 "BGP neighbor on interface to clear\n"
6668 "Address family\n"
6669 "Address Family modifier\n"
6670 "Address Family modifier\n"
6671 BGP_SOFT_OUT_STR)
6672
db64ea86 6673/* NOTE: WORD peers have not been tested for vpnv4 */
718e3744 6674DEFUN (clear_ip_bgp_peer_vpnv4_soft_out,
6675 clear_ip_bgp_peer_vpnv4_soft_out_cmd,
db64ea86 6676 "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast soft out",
718e3744 6677 CLEAR_STR
6678 IP_STR
6679 BGP_STR
6680 "BGP neighbor address to clear\n"
db64ea86 6681 "BGP neighbor on interface to clear\n"
718e3744 6682 "Address family\n"
6683 "Address Family Modifier\n"
e0bce756
DS
6684 BGP_SOFT_STR
6685 BGP_SOFT_OUT_STR)
718e3744 6686{
6687 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
6688 BGP_CLEAR_SOFT_OUT, argv[0]);
6689}
6690
6691ALIAS (clear_ip_bgp_peer_vpnv4_soft_out,
6692 clear_ip_bgp_peer_vpnv4_out_cmd,
db64ea86 6693 "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast out",
718e3744 6694 CLEAR_STR
6695 IP_STR
6696 BGP_STR
6697 "BGP neighbor address to clear\n"
db64ea86 6698 "BGP neighbor on interface to clear\n"
718e3744 6699 "Address family\n"
6700 "Address Family Modifier\n"
e0bce756 6701 BGP_SOFT_OUT_STR)
718e3744 6702
6703DEFUN (clear_bgp_peer_soft_out,
6704 clear_bgp_peer_soft_out_cmd,
a80beece 6705 "clear bgp (A.B.C.D|X:X::X:X|WORD) soft out",
718e3744 6706 CLEAR_STR
6707 BGP_STR
6708 "BGP neighbor address to clear\n"
6709 "BGP IPv6 neighbor to clear\n"
a80beece 6710 "BGP neighbor on interface to clear\n"
e0bce756
DS
6711 BGP_SOFT_STR
6712 BGP_SOFT_OUT_STR)
718e3744 6713{
01080f7c 6714 if (argc == 3)
6715 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_peer,
6716 BGP_CLEAR_SOFT_OUT, argv[2]);
6717
718e3744 6718 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
6719 BGP_CLEAR_SOFT_OUT, argv[0]);
6720}
6721
01080f7c 6722ALIAS (clear_bgp_peer_soft_out,
6723 clear_bgp_instance_peer_soft_out_cmd,
6724 "clear bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD) soft out",
6725 CLEAR_STR
6726 BGP_STR
6727 BGP_INSTANCE_HELP_STR
6728 "BGP neighbor address to clear\n"
6729 "BGP IPv6 neighbor to clear\n"
6730 "BGP neighbor on interface to clear\n"
6731 BGP_SOFT_STR
6732 BGP_SOFT_OUT_STR)
6733
718e3744 6734ALIAS (clear_bgp_peer_soft_out,
6735 clear_bgp_ipv6_peer_soft_out_cmd,
a80beece 6736 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) soft out",
718e3744 6737 CLEAR_STR
6738 BGP_STR
6739 "Address family\n"
6740 "BGP neighbor address to clear\n"
6741 "BGP IPv6 neighbor to clear\n"
a80beece 6742 "BGP neighbor on interface to clear\n"
e0bce756
DS
6743 BGP_SOFT_STR
6744 BGP_SOFT_OUT_STR)
718e3744 6745
01080f7c 6746ALIAS (clear_bgp_peer_soft_out,
6747 clear_bgp_instance_ipv6_peer_soft_out_cmd,
6748 "clear bgp " BGP_INSTANCE_CMD " ipv6 (A.B.C.D|X:X::X:X|WORD) soft out",
6749 CLEAR_STR
6750 BGP_STR
6751 BGP_INSTANCE_HELP_STR
6752 "Address family\n"
6753 "BGP neighbor address to clear\n"
6754 "BGP IPv6 neighbor to clear\n"
6755 "BGP neighbor on interface to clear\n"
6756 BGP_SOFT_STR
6757 BGP_SOFT_OUT_STR)
6758
718e3744 6759ALIAS (clear_bgp_peer_soft_out,
6760 clear_bgp_peer_out_cmd,
a80beece 6761 "clear bgp (A.B.C.D|X:X::X:X|WORD) out",
718e3744 6762 CLEAR_STR
6763 BGP_STR
6764 "BGP neighbor address to clear\n"
6765 "BGP IPv6 neighbor to clear\n"
a80beece 6766 "BGP neighbor on interface to clear\n"
e0bce756 6767 BGP_SOFT_OUT_STR)
718e3744 6768
01080f7c 6769ALIAS (clear_bgp_peer_soft_out,
6770 clear_bgp_instance_peer_out_cmd,
6771 "clear bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD) out",
6772 CLEAR_STR
6773 BGP_STR
6774 BGP_INSTANCE_HELP_STR
6775 "BGP neighbor address to clear\n"
6776 "BGP IPv6 neighbor to clear\n"
6777 "BGP neighbor on interface to clear\n"
6778 BGP_SOFT_OUT_STR)
6779
718e3744 6780ALIAS (clear_bgp_peer_soft_out,
6781 clear_bgp_ipv6_peer_out_cmd,
a80beece 6782 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) out",
718e3744 6783 CLEAR_STR
6784 BGP_STR
6785 "Address family\n"
6786 "BGP neighbor address to clear\n"
6787 "BGP IPv6 neighbor to clear\n"
a80beece 6788 "BGP neighbor on interface to clear\n"
e0bce756 6789 BGP_SOFT_OUT_STR)
718e3744 6790
01080f7c 6791ALIAS (clear_bgp_peer_soft_out,
6792 clear_bgp_instance_ipv6_peer_out_cmd,
6793 "clear bgp " BGP_INSTANCE_CMD " ipv6 (A.B.C.D|X:X::X:X|WORD) out",
6794 CLEAR_STR
6795 BGP_STR
6796 BGP_INSTANCE_HELP_STR
6797 "Address family\n"
6798 "BGP neighbor address to clear\n"
6799 "BGP IPv6 neighbor to clear\n"
6800 "BGP neighbor on interface to clear\n"
6801 BGP_SOFT_OUT_STR)
6802
718e3744 6803DEFUN (clear_ip_bgp_peer_group_soft_out,
6804 clear_ip_bgp_peer_group_soft_out_cmd,
6805 "clear ip bgp peer-group WORD soft out",
6806 CLEAR_STR
6807 IP_STR
6808 BGP_STR
6809 "Clear all members of peer-group\n"
6810 "BGP peer-group name\n"
e0bce756
DS
6811 BGP_SOFT_STR
6812 BGP_SOFT_OUT_STR)
718e3744 6813{
01080f7c 6814 if (argc == 3)
6815 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group,
6816 BGP_CLEAR_SOFT_OUT, argv[2]);
6817
718e3744 6818 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6819 BGP_CLEAR_SOFT_OUT, argv[0]);
6820}
6821
01080f7c 6822ALIAS (clear_ip_bgp_peer_group_soft_out,
6823 clear_ip_bgp_instance_peer_group_soft_out_cmd,
6824 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD soft out",
6825 CLEAR_STR
6826 IP_STR
6827 BGP_STR
6828 BGP_INSTANCE_HELP_STR
6829 "Clear all members of peer-group\n"
6830 "BGP peer-group name\n"
6831 BGP_SOFT_STR
6832 BGP_SOFT_OUT_STR)
6833
718e3744 6834ALIAS (clear_ip_bgp_peer_group_soft_out,
6835 clear_ip_bgp_peer_group_out_cmd,
6836 "clear ip bgp peer-group WORD out",
6837 CLEAR_STR
6838 IP_STR
6839 BGP_STR
6840 "Clear all members of peer-group\n"
6841 "BGP peer-group name\n"
e0bce756 6842 BGP_SOFT_OUT_STR)
718e3744 6843
01080f7c 6844ALIAS (clear_ip_bgp_peer_group_soft_out,
6845 clear_ip_bgp_instance_peer_group_out_cmd,
6846 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD out",
6847 CLEAR_STR
6848 IP_STR
6849 BGP_STR
6850 BGP_INSTANCE_HELP_STR
6851 "Clear all members of peer-group\n"
6852 "BGP peer-group name\n"
6853 BGP_SOFT_OUT_STR)
6854
718e3744 6855DEFUN (clear_ip_bgp_peer_group_ipv4_soft_out,
6856 clear_ip_bgp_peer_group_ipv4_soft_out_cmd,
6857 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft out",
6858 CLEAR_STR
6859 IP_STR
6860 BGP_STR
6861 "Clear all members of peer-group\n"
6862 "BGP peer-group name\n"
6863 "Address family\n"
6864 "Address Family modifier\n"
6865 "Address Family modifier\n"
e0bce756
DS
6866 BGP_SOFT_STR
6867 BGP_SOFT_OUT_STR)
718e3744 6868{
6869 if (strncmp (argv[1], "m", 1) == 0)
6870 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
6871 BGP_CLEAR_SOFT_OUT, argv[0]);
6872
6873 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6874 BGP_CLEAR_SOFT_OUT, argv[0]);
6875}
6876
01080f7c 6877DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft_out,
6878 clear_ip_bgp_instance_peer_group_ipv4_soft_out_cmd,
6879 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 (unicast|multicast) soft out",
6880 CLEAR_STR
6881 IP_STR
6882 BGP_STR
6883 BGP_INSTANCE_HELP_STR
6884 "Clear all members of peer-group\n"
6885 "BGP peer-group name\n"
6886 "Address family\n"
6887 "Address Family modifier\n"
6888 "Address Family modifier\n"
6889 BGP_SOFT_STR
6890 BGP_SOFT_OUT_STR)
6891{
6892 if (strncmp (argv[3], "m", 1) == 0)
6893 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_group,
6894 BGP_CLEAR_SOFT_OUT, argv[2]);
6895
6896 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group,
6897 BGP_CLEAR_SOFT_OUT, argv[2]);
6898}
6899
718e3744 6900ALIAS (clear_ip_bgp_peer_group_ipv4_soft_out,
6901 clear_ip_bgp_peer_group_ipv4_out_cmd,
6902 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) out",
6903 CLEAR_STR
6904 IP_STR
6905 BGP_STR
6906 "Clear all members of peer-group\n"
6907 "BGP peer-group name\n"
6908 "Address family\n"
6909 "Address Family modifier\n"
6910 "Address Family modifier\n"
e0bce756 6911 BGP_SOFT_OUT_STR)
718e3744 6912
01080f7c 6913ALIAS (clear_ip_bgp_instance_peer_group_ipv4_soft_out,
6914 clear_ip_bgp_instance_peer_group_ipv4_out_cmd,
6915 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 (unicast|multicast) out",
6916 CLEAR_STR
6917 IP_STR
6918 BGP_STR
6919 BGP_INSTANCE_HELP_STR
6920 "Clear all members of peer-group\n"
6921 "BGP peer-group name\n"
6922 "Address family\n"
6923 "Address Family modifier\n"
6924 "Address Family modifier\n"
6925 BGP_SOFT_OUT_STR)
6926
718e3744 6927DEFUN (clear_bgp_peer_group_soft_out,
6928 clear_bgp_peer_group_soft_out_cmd,
6929 "clear bgp peer-group WORD soft out",
6930 CLEAR_STR
6931 BGP_STR
6932 "Clear all members of peer-group\n"
6933 "BGP peer-group name\n"
e0bce756
DS
6934 BGP_SOFT_STR
6935 BGP_SOFT_OUT_STR)
718e3744 6936{
01080f7c 6937 if (argc == 3)
6938 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_group,
6939 BGP_CLEAR_SOFT_OUT, argv[2]);
6940
718e3744 6941 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
6942 BGP_CLEAR_SOFT_OUT, argv[0]);
6943}
6944
01080f7c 6945ALIAS (clear_bgp_peer_group_soft_out,
6946 clear_bgp_instance_peer_group_soft_out_cmd,
6947 "clear bgp " BGP_INSTANCE_CMD " peer-group WORD soft out",
6948 CLEAR_STR
6949 BGP_STR
6950 BGP_INSTANCE_HELP_STR
6951 "Clear all members of peer-group\n"
6952 "BGP peer-group name\n"
6953 BGP_SOFT_STR
6954 BGP_SOFT_OUT_STR)
6955
718e3744 6956ALIAS (clear_bgp_peer_group_soft_out,
6957 clear_bgp_ipv6_peer_group_soft_out_cmd,
6958 "clear bgp ipv6 peer-group WORD soft out",
6959 CLEAR_STR
6960 BGP_STR
6961 "Address family\n"
6962 "Clear all members of peer-group\n"
6963 "BGP peer-group name\n"
e0bce756
DS
6964 BGP_SOFT_STR
6965 BGP_SOFT_OUT_STR)
718e3744 6966
01080f7c 6967ALIAS (clear_bgp_peer_group_soft_out,
6968 clear_bgp_instance_ipv6_peer_group_soft_out_cmd,
6969 "clear bgp " BGP_INSTANCE_CMD " ipv6 peer-group WORD soft out",
6970 CLEAR_STR
6971 BGP_STR
6972 BGP_INSTANCE_HELP_STR
6973 "Address family\n"
6974 "Clear all members of peer-group\n"
6975 "BGP peer-group name\n"
6976 BGP_SOFT_STR
6977 BGP_SOFT_OUT_STR)
6978
718e3744 6979ALIAS (clear_bgp_peer_group_soft_out,
6980 clear_bgp_peer_group_out_cmd,
6981 "clear bgp peer-group WORD out",
6982 CLEAR_STR
6983 BGP_STR
6984 "Clear all members of peer-group\n"
6985 "BGP peer-group name\n"
e0bce756 6986 BGP_SOFT_OUT_STR)
718e3744 6987
01080f7c 6988ALIAS (clear_bgp_peer_group_soft_out,
6989 clear_bgp_instance_peer_group_out_cmd,
6990 "clear bgp " BGP_INSTANCE_CMD " peer-group WORD out",
6991 CLEAR_STR
6992 BGP_STR
6993 BGP_INSTANCE_HELP_STR
6994 "Clear all members of peer-group\n"
6995 "BGP peer-group name\n"
6996 BGP_SOFT_OUT_STR)
6997
718e3744 6998ALIAS (clear_bgp_peer_group_soft_out,
6999 clear_bgp_ipv6_peer_group_out_cmd,
7000 "clear bgp ipv6 peer-group WORD out",
7001 CLEAR_STR
7002 BGP_STR
7003 "Address family\n"
7004 "Clear all members of peer-group\n"
7005 "BGP peer-group name\n"
e0bce756 7006 BGP_SOFT_OUT_STR)
718e3744 7007
01080f7c 7008ALIAS (clear_bgp_peer_group_soft_out,
7009 clear_bgp_instance_ipv6_peer_group_out_cmd,
7010 "clear bgp " BGP_INSTANCE_CMD " ipv6 peer-group WORD out",
7011 CLEAR_STR
7012 BGP_STR
7013 BGP_INSTANCE_HELP_STR
7014 "Address family\n"
7015 "Clear all members of peer-group\n"
7016 "BGP peer-group name\n"
7017 BGP_SOFT_OUT_STR)
7018
718e3744 7019DEFUN (clear_ip_bgp_external_soft_out,
7020 clear_ip_bgp_external_soft_out_cmd,
7021 "clear ip bgp external soft out",
7022 CLEAR_STR
7023 IP_STR
7024 BGP_STR
7025 "Clear all external peers\n"
e0bce756
DS
7026 BGP_SOFT_STR
7027 BGP_SOFT_OUT_STR)
01080f7c 7028{
7029 if (argc == 2)
7030 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external,
7031 BGP_CLEAR_SOFT_OUT, NULL);
7032
7033 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7034 BGP_CLEAR_SOFT_OUT, NULL);
7035}
7036
7037ALIAS (clear_ip_bgp_external_soft_out,
7038 clear_ip_bgp_instance_external_soft_out_cmd,
7039 "clear ip bgp " BGP_INSTANCE_CMD " external soft out",
7040 CLEAR_STR
7041 IP_STR
7042 BGP_STR
7043 BGP_INSTANCE_HELP_STR
7044 "Clear all external peers\n"
7045 BGP_SOFT_STR
7046 BGP_SOFT_OUT_STR)
7047
7048ALIAS (clear_ip_bgp_external_soft_out,
7049 clear_ip_bgp_external_out_cmd,
7050 "clear ip bgp external out",
7051 CLEAR_STR
7052 IP_STR
7053 BGP_STR
7054 "Clear all external peers\n"
7055 BGP_SOFT_OUT_STR)
718e3744 7056
7057ALIAS (clear_ip_bgp_external_soft_out,
01080f7c 7058 clear_ip_bgp_instance_external_out_cmd,
7059 "clear ip bgp " BGP_INSTANCE_CMD " external out",
718e3744 7060 CLEAR_STR
7061 IP_STR
7062 BGP_STR
01080f7c 7063 BGP_INSTANCE_HELP_STR
718e3744 7064 "Clear all external peers\n"
e0bce756 7065 BGP_SOFT_OUT_STR)
718e3744 7066
7067DEFUN (clear_ip_bgp_external_ipv4_soft_out,
7068 clear_ip_bgp_external_ipv4_soft_out_cmd,
7069 "clear ip bgp external ipv4 (unicast|multicast) soft out",
7070 CLEAR_STR
7071 IP_STR
7072 BGP_STR
7073 "Clear all external peers\n"
7074 "Address family\n"
7075 "Address Family modifier\n"
7076 "Address Family modifier\n"
e0bce756
DS
7077 BGP_SOFT_STR
7078 BGP_SOFT_OUT_STR)
718e3744 7079{
7080 if (strncmp (argv[0], "m", 1) == 0)
7081 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
7082 BGP_CLEAR_SOFT_OUT, NULL);
7083
7084 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7085 BGP_CLEAR_SOFT_OUT, NULL);
7086}
7087
01080f7c 7088DEFUN (clear_ip_bgp_instance_external_ipv4_soft_out,
7089 clear_ip_bgp_instance_external_ipv4_soft_out_cmd,
7090 "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 (unicast|multicast) soft out",
7091 CLEAR_STR
7092 IP_STR
7093 BGP_STR
7094 BGP_INSTANCE_HELP_STR
7095 "Clear all external peers\n"
7096 "Address family\n"
7097 "Address Family modifier\n"
7098 "Address Family modifier\n"
7099 BGP_SOFT_STR
7100 BGP_SOFT_OUT_STR)
7101{
7102 if (strncmp (argv[2], "m", 1) == 0)
7103 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_external,
7104 BGP_CLEAR_SOFT_OUT, NULL);
7105
7106 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external,
7107 BGP_CLEAR_SOFT_OUT, NULL);
7108}
7109
718e3744 7110ALIAS (clear_ip_bgp_external_ipv4_soft_out,
7111 clear_ip_bgp_external_ipv4_out_cmd,
7112 "clear ip bgp external ipv4 (unicast|multicast) out",
7113 CLEAR_STR
7114 IP_STR
7115 BGP_STR
7116 "Clear all external peers\n"
7117 "Address family\n"
7118 "Address Family modifier\n"
7119 "Address Family modifier\n"
e0bce756 7120 BGP_SOFT_OUT_STR)
718e3744 7121
01080f7c 7122ALIAS (clear_ip_bgp_instance_external_ipv4_soft_out,
7123 clear_ip_bgp_instance_external_ipv4_out_cmd,
7124 "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 (unicast|multicast) out",
7125 CLEAR_STR
7126 IP_STR
7127 BGP_STR
7128 BGP_INSTANCE_HELP_STR
7129 "Clear all external peers\n"
7130 "Address family\n"
7131 "Address Family modifier\n"
7132 "Address Family modifier\n"
7133 BGP_SOFT_OUT_STR)
7134
718e3744 7135DEFUN (clear_bgp_external_soft_out,
7136 clear_bgp_external_soft_out_cmd,
7137 "clear bgp external soft out",
7138 CLEAR_STR
7139 BGP_STR
7140 "Clear all external peers\n"
e0bce756
DS
7141 BGP_SOFT_STR
7142 BGP_SOFT_OUT_STR)
718e3744 7143{
01080f7c 7144 if (argc == 2)
7145 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_external,
7146 BGP_CLEAR_SOFT_OUT, NULL);
7147
718e3744 7148 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
7149 BGP_CLEAR_SOFT_OUT, NULL);
7150}
7151
01080f7c 7152ALIAS (clear_bgp_external_soft_out,
7153 clear_bgp_instance_external_soft_out_cmd,
7154 "clear bgp " BGP_INSTANCE_CMD " external soft out",
7155 CLEAR_STR
7156 BGP_STR
7157 BGP_INSTANCE_HELP_STR
7158 "Clear all external peers\n"
7159 BGP_SOFT_STR
7160 BGP_SOFT_OUT_STR)
7161
718e3744 7162ALIAS (clear_bgp_external_soft_out,
7163 clear_bgp_ipv6_external_soft_out_cmd,
7164 "clear bgp ipv6 external soft out",
7165 CLEAR_STR
7166 BGP_STR
7167 "Address family\n"
7168 "Clear all external peers\n"
e0bce756
DS
7169 BGP_SOFT_STR
7170 BGP_SOFT_OUT_STR)
718e3744 7171
01080f7c 7172ALIAS (clear_bgp_external_soft_out,
7173 clear_bgp_instance_ipv6_external_soft_out_cmd,
7174 "clear bgp " BGP_INSTANCE_CMD " ipv6 external soft out",
7175 CLEAR_STR
7176 BGP_STR
7177 BGP_INSTANCE_HELP_STR
7178 "Address family\n"
7179 "Clear all external peers\n"
7180 BGP_SOFT_STR
7181 BGP_SOFT_OUT_STR)
7182
718e3744 7183ALIAS (clear_bgp_external_soft_out,
7184 clear_bgp_external_out_cmd,
7185 "clear bgp external out",
7186 CLEAR_STR
7187 BGP_STR
7188 "Clear all external peers\n"
e0bce756 7189 BGP_SOFT_OUT_STR)
718e3744 7190
01080f7c 7191ALIAS (clear_bgp_external_soft_out,
7192 clear_bgp_instance_external_out_cmd,
7193 "clear bgp " BGP_INSTANCE_CMD " external out",
7194 CLEAR_STR
7195 BGP_STR
7196 BGP_INSTANCE_HELP_STR
7197 "Clear all external peers\n"
7198 BGP_SOFT_OUT_STR)
7199
718e3744 7200ALIAS (clear_bgp_external_soft_out,
7201 clear_bgp_ipv6_external_out_cmd,
7202 "clear bgp ipv6 external WORD out",
7203 CLEAR_STR
7204 BGP_STR
7205 "Address family\n"
7206 "Clear all external peers\n"
e0bce756 7207 BGP_SOFT_OUT_STR)
718e3744 7208
01080f7c 7209ALIAS (clear_bgp_external_soft_out,
7210 clear_bgp_instance_ipv6_external_out_cmd,
7211 "clear bgp " BGP_INSTANCE_CMD " ipv6 external WORD out",
7212 CLEAR_STR
7213 BGP_STR
7214 BGP_INSTANCE_HELP_STR
7215 "Address family\n"
7216 "Clear all external peers\n"
7217 BGP_SOFT_OUT_STR)
7218
718e3744 7219DEFUN (clear_ip_bgp_as_soft_out,
7220 clear_ip_bgp_as_soft_out_cmd,
320da874 7221 "clear ip bgp " CMD_AS_RANGE " soft out",
718e3744 7222 CLEAR_STR
7223 IP_STR
7224 BGP_STR
7225 "Clear peers with the AS number\n"
e0bce756
DS
7226 BGP_SOFT_STR
7227 BGP_SOFT_OUT_STR)
718e3744 7228{
01080f7c 7229 if (argc == 3)
7230 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as,
7231 BGP_CLEAR_SOFT_OUT, argv[2]);
7232
718e3744 7233 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
7234 BGP_CLEAR_SOFT_OUT, argv[0]);
7235}
7236
01080f7c 7237ALIAS (clear_ip_bgp_as_soft_out,
7238 clear_ip_bgp_instance_as_soft_out_cmd,
7239 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " soft out",
7240 CLEAR_STR
7241 IP_STR
7242 BGP_STR
7243 BGP_INSTANCE_HELP_STR
7244 "Clear peers with the AS number\n"
7245 BGP_SOFT_STR
7246 BGP_SOFT_OUT_STR)
7247
718e3744 7248ALIAS (clear_ip_bgp_as_soft_out,
7249 clear_ip_bgp_as_out_cmd,
320da874 7250 "clear ip bgp " CMD_AS_RANGE " out",
718e3744 7251 CLEAR_STR
7252 IP_STR
7253 BGP_STR
7254 "Clear peers with the AS number\n"
e0bce756 7255 BGP_SOFT_OUT_STR)
718e3744 7256
01080f7c 7257ALIAS (clear_ip_bgp_as_soft_out,
7258 clear_ip_bgp_instance_as_out_cmd,
7259 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " out",
7260 CLEAR_STR
7261 IP_STR
7262 BGP_STR
7263 BGP_INSTANCE_HELP_STR
7264 "Clear peers with the AS number\n"
7265 BGP_SOFT_OUT_STR)
7266
718e3744 7267DEFUN (clear_ip_bgp_as_ipv4_soft_out,
7268 clear_ip_bgp_as_ipv4_soft_out_cmd,
320da874 7269 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft out",
718e3744 7270 CLEAR_STR
7271 IP_STR
7272 BGP_STR
7273 "Clear peers with the AS number\n"
7274 "Address family\n"
7275 "Address Family modifier\n"
7276 "Address Family modifier\n"
e0bce756
DS
7277 BGP_SOFT_STR
7278 BGP_SOFT_OUT_STR)
718e3744 7279{
7280 if (strncmp (argv[1], "m", 1) == 0)
7281 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
7282 BGP_CLEAR_SOFT_OUT, argv[0]);
7283
7284 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
7285 BGP_CLEAR_SOFT_OUT, argv[0]);
7286}
7287
01080f7c 7288DEFUN (clear_ip_bgp_instance_as_ipv4_soft_out,
7289 clear_ip_bgp_instance_as_ipv4_soft_out_cmd,
7290 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 (unicast|multicast) soft out",
7291 CLEAR_STR
7292 IP_STR
7293 BGP_STR
7294 BGP_INSTANCE_HELP_STR
7295 "Clear peers with the AS number\n"
7296 "Address family\n"
7297 "Address Family modifier\n"
7298 "Address Family modifier\n"
7299 BGP_SOFT_STR
7300 BGP_SOFT_OUT_STR)
7301{
7302 if (strncmp (argv[3], "m", 1) == 0)
7303 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_as,
7304 BGP_CLEAR_SOFT_OUT, argv[2]);
7305
7306 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as,
7307 BGP_CLEAR_SOFT_OUT, argv[2]);
7308}
7309
718e3744 7310ALIAS (clear_ip_bgp_as_ipv4_soft_out,
7311 clear_ip_bgp_as_ipv4_out_cmd,
320da874 7312 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) out",
718e3744 7313 CLEAR_STR
7314 IP_STR
7315 BGP_STR
7316 "Clear peers with the AS number\n"
7317 "Address family\n"
7318 "Address Family modifier\n"
7319 "Address Family modifier\n"
e0bce756 7320 BGP_SOFT_OUT_STR)
718e3744 7321
01080f7c 7322ALIAS (clear_ip_bgp_instance_as_ipv4_soft_out,
7323 clear_ip_bgp_instance_as_ipv4_out_cmd,
7324 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 (unicast|multicast) out",
7325 CLEAR_STR
7326 IP_STR
7327 BGP_STR
7328 BGP_INSTANCE_HELP_STR
7329 "Clear peers with the AS number\n"
7330 "Address family\n"
7331 "Address Family modifier\n"
7332 "Address Family modifier\n"
7333 BGP_SOFT_OUT_STR)
7334
718e3744 7335DEFUN (clear_ip_bgp_as_vpnv4_soft_out,
7336 clear_ip_bgp_as_vpnv4_soft_out_cmd,
320da874 7337 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft out",
718e3744 7338 CLEAR_STR
7339 IP_STR
7340 BGP_STR
7341 "Clear peers with the AS number\n"
7342 "Address family\n"
7343 "Address Family modifier\n"
e0bce756
DS
7344 BGP_SOFT_STR
7345 BGP_SOFT_OUT_STR)
718e3744 7346{
7347 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
7348 BGP_CLEAR_SOFT_OUT, argv[0]);
7349}
7350
7351ALIAS (clear_ip_bgp_as_vpnv4_soft_out,
7352 clear_ip_bgp_as_vpnv4_out_cmd,
320da874 7353 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast out",
718e3744 7354 CLEAR_STR
7355 IP_STR
7356 BGP_STR
7357 "Clear peers with the AS number\n"
7358 "Address family\n"
7359 "Address Family modifier\n"
e0bce756 7360 BGP_SOFT_OUT_STR)
718e3744 7361
7362DEFUN (clear_bgp_as_soft_out,
7363 clear_bgp_as_soft_out_cmd,
320da874 7364 "clear bgp " CMD_AS_RANGE " soft out",
718e3744 7365 CLEAR_STR
7366 BGP_STR
7367 "Clear peers with the AS number\n"
e0bce756
DS
7368 BGP_SOFT_STR
7369 BGP_SOFT_OUT_STR)
718e3744 7370{
01080f7c 7371 if (argc == 3)
7372 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_as,
7373 BGP_CLEAR_SOFT_OUT, argv[2]);
7374
718e3744 7375 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
7376 BGP_CLEAR_SOFT_OUT, argv[0]);
7377}
7378
01080f7c 7379ALIAS (clear_bgp_as_soft_out,
7380 clear_bgp_instance_as_soft_out_cmd,
7381 "clear bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " soft out",
7382 CLEAR_STR
7383 BGP_STR
7384 BGP_INSTANCE_HELP_STR
7385 "Clear peers with the AS number\n"
7386 BGP_SOFT_STR
7387 BGP_SOFT_OUT_STR)
7388
718e3744 7389ALIAS (clear_bgp_as_soft_out,
7390 clear_bgp_ipv6_as_soft_out_cmd,
320da874 7391 "clear bgp ipv6 " CMD_AS_RANGE " soft out",
718e3744 7392 CLEAR_STR
7393 BGP_STR
7394 "Address family\n"
7395 "Clear peers with the AS number\n"
e0bce756
DS
7396 BGP_SOFT_STR
7397 BGP_SOFT_OUT_STR)
718e3744 7398
01080f7c 7399ALIAS (clear_bgp_as_soft_out,
7400 clear_bgp_instance_ipv6_as_soft_out_cmd,
7401 "clear bgp " BGP_INSTANCE_CMD " ipv6 " CMD_AS_RANGE " soft out",
7402 CLEAR_STR
7403 BGP_STR
7404 BGP_INSTANCE_HELP_STR
7405 "Address family\n"
7406 "Clear peers with the AS number\n"
7407 BGP_SOFT_STR
7408 BGP_SOFT_OUT_STR)
7409
718e3744 7410ALIAS (clear_bgp_as_soft_out,
7411 clear_bgp_as_out_cmd,
320da874 7412 "clear bgp " CMD_AS_RANGE " out",
718e3744 7413 CLEAR_STR
7414 BGP_STR
7415 "Clear peers with the AS number\n"
e0bce756 7416 BGP_SOFT_OUT_STR)
718e3744 7417
01080f7c 7418ALIAS (clear_bgp_as_soft_out,
7419 clear_bgp_instance_as_out_cmd,
7420 "clear bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " out",
7421 CLEAR_STR
7422 BGP_STR
7423 BGP_INSTANCE_HELP_STR
7424 "Clear peers with the AS number\n"
7425 BGP_SOFT_OUT_STR)
7426
718e3744 7427ALIAS (clear_bgp_as_soft_out,
7428 clear_bgp_ipv6_as_out_cmd,
320da874 7429 "clear bgp ipv6 " CMD_AS_RANGE " out",
718e3744 7430 CLEAR_STR
7431 BGP_STR
7432 "Address family\n"
7433 "Clear peers with the AS number\n"
e0bce756 7434 BGP_SOFT_OUT_STR)
6b0655a2 7435
01080f7c 7436ALIAS (clear_bgp_as_soft_out,
7437 clear_bgp_instance_ipv6_as_out_cmd,
7438 "clear bgp " BGP_INSTANCE_CMD " ipv6 " CMD_AS_RANGE " out",
7439 CLEAR_STR
7440 BGP_STR
7441 BGP_INSTANCE_HELP_STR
7442 "Address family\n"
7443 "Clear peers with the AS number\n"
7444 BGP_SOFT_OUT_STR)
7445
718e3744 7446/* Inbound soft-reconfiguration */
7447DEFUN (clear_ip_bgp_all_soft_in,
7448 clear_ip_bgp_all_soft_in_cmd,
7449 "clear ip bgp * soft in",
7450 CLEAR_STR
7451 IP_STR
7452 BGP_STR
7453 "Clear all peers\n"
e0bce756
DS
7454 BGP_SOFT_STR
7455 BGP_SOFT_IN_STR)
718e3744 7456{
6aeb9e78
DS
7457 if (argc == 2)
7458 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all,
718e3744 7459 BGP_CLEAR_SOFT_IN, NULL);
7460
7461 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
7462 BGP_CLEAR_SOFT_IN, NULL);
7463}
7464
7465ALIAS (clear_ip_bgp_all_soft_in,
7466 clear_ip_bgp_instance_all_soft_in_cmd,
8386ac43 7467 "clear ip bgp " BGP_INSTANCE_CMD " * soft in",
718e3744 7468 CLEAR_STR
7469 IP_STR
7470 BGP_STR
8386ac43 7471 BGP_INSTANCE_HELP_STR
718e3744 7472 "Clear all peers\n"
e0bce756
DS
7473 BGP_SOFT_STR
7474 BGP_SOFT_IN_STR)
718e3744 7475
7476ALIAS (clear_ip_bgp_all_soft_in,
7477 clear_ip_bgp_all_in_cmd,
7478 "clear ip bgp * in",
7479 CLEAR_STR
7480 IP_STR
7481 BGP_STR
7482 "Clear all peers\n"
e0bce756 7483 BGP_SOFT_IN_STR)
718e3744 7484
01080f7c 7485ALIAS (clear_ip_bgp_all_soft_in,
7486 clear_ip_bgp_instance_all_in_cmd,
7487 "clear ip bgp " BGP_INSTANCE_CMD " * in",
7488 CLEAR_STR
7489 IP_STR
7490 BGP_STR
7491 BGP_INSTANCE_HELP_STR
7492 "Clear all peers\n"
7493 BGP_SOFT_IN_STR)
7494
718e3744 7495DEFUN (clear_ip_bgp_all_in_prefix_filter,
7496 clear_ip_bgp_all_in_prefix_filter_cmd,
7497 "clear ip bgp * in prefix-filter",
7498 CLEAR_STR
7499 IP_STR
7500 BGP_STR
7501 "Clear all peers\n"
e0bce756 7502 BGP_SOFT_IN_STR
718e3744 7503 "Push out prefix-list ORF and do inbound soft reconfig\n")
7504{
6aeb9e78
DS
7505 if (argc== 2)
7506 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all,
718e3744 7507 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7508
7509 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
7510 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7511}
7512
718e3744 7513DEFUN (clear_ip_bgp_all_ipv4_soft_in,
7514 clear_ip_bgp_all_ipv4_soft_in_cmd,
7515 "clear ip bgp * ipv4 (unicast|multicast) soft in",
7516 CLEAR_STR
7517 IP_STR
7518 BGP_STR
7519 "Clear all peers\n"
7520 "Address family\n"
7521 "Address Family modifier\n"
7522 "Address Family modifier\n"
e0bce756
DS
7523 BGP_SOFT_STR
7524 BGP_SOFT_IN_STR)
718e3744 7525{
7526 if (strncmp (argv[0], "m", 1) == 0)
7527 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
7528 BGP_CLEAR_SOFT_IN, NULL);
7529
7530 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
7531 BGP_CLEAR_SOFT_IN, NULL);
7532}
7533
718e3744 7534DEFUN (clear_ip_bgp_instance_all_ipv4_soft_in,
7535 clear_ip_bgp_instance_all_ipv4_soft_in_cmd,
8386ac43 7536 "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) soft in",
718e3744 7537 CLEAR_STR
7538 IP_STR
7539 BGP_STR
8386ac43 7540 BGP_INSTANCE_HELP_STR
718e3744 7541 "Clear all peers\n"
7542 "Address family\n"
7543 "Address Family modifier\n"
7544 "Address Family modifier\n"
e0bce756
DS
7545 BGP_SOFT_STR
7546 BGP_SOFT_IN_STR)
718e3744 7547{
6aeb9e78
DS
7548 if (strncmp (argv[2], "m", 1) == 0)
7549 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_all,
718e3744 7550 BGP_CLEAR_SOFT_IN, NULL);
7551
6aeb9e78 7552 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all,
718e3744 7553 BGP_CLEAR_SOFT_IN, NULL);
7554}
7555
01080f7c 7556ALIAS (clear_ip_bgp_all_ipv4_soft_in,
7557 clear_ip_bgp_all_ipv4_in_cmd,
7558 "clear ip bgp * ipv4 (unicast|multicast) in",
718e3744 7559 CLEAR_STR
7560 IP_STR
7561 BGP_STR
7562 "Clear all peers\n"
7563 "Address family\n"
7564 "Address Family modifier\n"
7565 "Address Family modifier\n"
01080f7c 7566 BGP_SOFT_IN_STR)
718e3744 7567
01080f7c 7568ALIAS (clear_ip_bgp_instance_all_ipv4_soft_in,
7569 clear_ip_bgp_instance_all_ipv4_in_cmd,
7570 "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) in",
7571 CLEAR_STR
7572 IP_STR
7573 BGP_STR
7574 BGP_INSTANCE_HELP_STR
7575 "Clear all peers\n"
7576 "Address family\n"
7577 "Address Family modifier\n"
7578 "Address Family modifier\n"
7579 BGP_SOFT_IN_STR)
718e3744 7580
01080f7c 7581DEFUN (clear_ip_bgp_all_ipv4_in_prefix_filter,
7582 clear_ip_bgp_all_ipv4_in_prefix_filter_cmd,
7583 "clear ip bgp * ipv4 (unicast|multicast) in prefix-filter",
718e3744 7584 CLEAR_STR
7585 IP_STR
7586 BGP_STR
7587 "Clear all peers\n"
7588 "Address family\n"
7589 "Address Family modifier\n"
7590 "Address Family modifier\n"
e0bce756 7591 BGP_SOFT_IN_STR
718e3744 7592 "Push out prefix-list ORF and do inbound soft reconfig\n")
7593{
01080f7c 7594 if (strncmp (argv[0], "m", 1) == 0)
7595 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
7596 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
718e3744 7597
01080f7c 7598 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
7599 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
718e3744 7600}
7601
7602DEFUN (clear_ip_bgp_all_vpnv4_soft_in,
7603 clear_ip_bgp_all_vpnv4_soft_in_cmd,
7604 "clear ip bgp * vpnv4 unicast soft in",
7605 CLEAR_STR
7606 IP_STR
7607 BGP_STR
7608 "Clear all peers\n"
7609 "Address family\n"
7610 "Address Family Modifier\n"
e0bce756
DS
7611 BGP_SOFT_STR
7612 BGP_SOFT_IN_STR)
718e3744 7613{
7614 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
7615 BGP_CLEAR_SOFT_IN, NULL);
7616}
7617
7618ALIAS (clear_ip_bgp_all_vpnv4_soft_in,
7619 clear_ip_bgp_all_vpnv4_in_cmd,
7620 "clear ip bgp * vpnv4 unicast in",
7621 CLEAR_STR
7622 IP_STR
7623 BGP_STR
7624 "Clear all peers\n"
7625 "Address family\n"
7626 "Address Family Modifier\n"
e0bce756 7627 BGP_SOFT_IN_STR)
718e3744 7628
7629DEFUN (clear_bgp_all_soft_in,
7630 clear_bgp_all_soft_in_cmd,
7631 "clear bgp * soft in",
7632 CLEAR_STR
7633 BGP_STR
7634 "Clear all peers\n"
e0bce756
DS
7635 BGP_SOFT_STR
7636 BGP_SOFT_IN_STR)
718e3744 7637{
6aeb9e78
DS
7638 if (argc == 2)
7639 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_all,
718e3744 7640 BGP_CLEAR_SOFT_IN, NULL);
7641
7642 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
7643 BGP_CLEAR_SOFT_IN, NULL);
7644}
7645
7646ALIAS (clear_bgp_all_soft_in,
7647 clear_bgp_instance_all_soft_in_cmd,
8386ac43 7648 "clear bgp " BGP_INSTANCE_CMD " * soft in",
718e3744 7649 CLEAR_STR
7650 BGP_STR
8386ac43 7651 BGP_INSTANCE_HELP_STR
718e3744 7652 "Clear all peers\n"
e0bce756
DS
7653 BGP_SOFT_STR
7654 BGP_SOFT_IN_STR)
718e3744 7655
7656ALIAS (clear_bgp_all_soft_in,
7657 clear_bgp_ipv6_all_soft_in_cmd,
7658 "clear bgp ipv6 * soft in",
7659 CLEAR_STR
7660 BGP_STR
7661 "Address family\n"
7662 "Clear all peers\n"
e0bce756
DS
7663 BGP_SOFT_STR
7664 BGP_SOFT_IN_STR)
718e3744 7665
01080f7c 7666ALIAS (clear_bgp_all_soft_in,
7667 clear_bgp_instance_ipv6_all_soft_in_cmd,
7668 "clear bgp " BGP_INSTANCE_CMD " ipv6 * soft in",
7669 CLEAR_STR
7670 BGP_STR
7671 BGP_INSTANCE_HELP_STR
7672 "Address family\n"
7673 "Clear all peers\n"
7674 BGP_SOFT_STR
7675 BGP_SOFT_IN_STR)
7676
718e3744 7677ALIAS (clear_bgp_all_soft_in,
7678 clear_bgp_all_in_cmd,
7679 "clear bgp * in",
7680 CLEAR_STR
7681 BGP_STR
7682 "Clear all peers\n"
e0bce756 7683 BGP_SOFT_IN_STR)
718e3744 7684
01080f7c 7685ALIAS (clear_bgp_all_soft_in,
7686 clear_bgp_instance_all_in_cmd,
7687 "clear bgp " BGP_INSTANCE_CMD " * in",
7688 CLEAR_STR
7689 BGP_STR
7690 BGP_INSTANCE_HELP_STR
7691 "Clear all peers\n"
7692 BGP_SOFT_IN_STR)
7693
718e3744 7694ALIAS (clear_bgp_all_soft_in,
7695 clear_bgp_ipv6_all_in_cmd,
7696 "clear bgp ipv6 * in",
7697 CLEAR_STR
7698 BGP_STR
7699 "Address family\n"
7700 "Clear all peers\n"
e0bce756 7701 BGP_SOFT_IN_STR)
718e3744 7702
01080f7c 7703ALIAS (clear_bgp_all_soft_in,
7704 clear_bgp_instance_ipv6_all_in_cmd,
7705 "clear bgp " BGP_INSTANCE_CMD " ipv6 * in",
7706 CLEAR_STR
7707 BGP_STR
7708 BGP_INSTANCE_HELP_STR
7709 "Address family\n"
7710 "Clear all peers\n"
7711 BGP_SOFT_IN_STR)
7712
718e3744 7713DEFUN (clear_bgp_all_in_prefix_filter,
7714 clear_bgp_all_in_prefix_filter_cmd,
7715 "clear bgp * in prefix-filter",
7716 CLEAR_STR
7717 BGP_STR
7718 "Clear all peers\n"
e0bce756 7719 BGP_SOFT_IN_STR
718e3744 7720 "Push out prefix-list ORF and do inbound soft reconfig\n")
7721{
7722 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
7723 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7724}
7725
7726ALIAS (clear_bgp_all_in_prefix_filter,
7727 clear_bgp_ipv6_all_in_prefix_filter_cmd,
7728 "clear bgp ipv6 * in prefix-filter",
7729 CLEAR_STR
7730 BGP_STR
7731 "Address family\n"
7732 "Clear all peers\n"
e0bce756 7733 BGP_SOFT_IN_STR
718e3744 7734 "Push out prefix-list ORF and do inbound soft reconfig\n")
7735
7736DEFUN (clear_ip_bgp_peer_soft_in,
7737 clear_ip_bgp_peer_soft_in_cmd,
db64ea86 7738 "clear ip bgp (A.B.C.D|WORD) soft in",
718e3744 7739 CLEAR_STR
7740 IP_STR
7741 BGP_STR
7742 "BGP neighbor address to clear\n"
db64ea86 7743 "BGP neighbor on interface to clear\n"
e0bce756
DS
7744 BGP_SOFT_STR
7745 BGP_SOFT_IN_STR)
718e3744 7746{
01080f7c 7747 if (argc == 3)
7748 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer,
7749 BGP_CLEAR_SOFT_IN, argv[2]);
7750
718e3744 7751 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
7752 BGP_CLEAR_SOFT_IN, argv[0]);
7753}
7754
01080f7c 7755ALIAS (clear_ip_bgp_peer_soft_in,
7756 clear_ip_bgp_instance_peer_soft_in_cmd,
7757 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) soft in",
7758 CLEAR_STR
7759 IP_STR
7760 BGP_STR
7761 BGP_INSTANCE_HELP_STR
7762 "BGP neighbor address to clear\n"
7763 "BGP neighbor on interface to clear\n"
7764 BGP_SOFT_STR
7765 BGP_SOFT_IN_STR)
7766
718e3744 7767ALIAS (clear_ip_bgp_peer_soft_in,
7768 clear_ip_bgp_peer_in_cmd,
db64ea86 7769 "clear ip bgp (A.B.C.D|WORD) in",
718e3744 7770 CLEAR_STR
7771 IP_STR
7772 BGP_STR
7773 "BGP neighbor address to clear\n"
db64ea86 7774 "BGP neighbor on interface to clear\n"
e0bce756 7775 BGP_SOFT_IN_STR)
01080f7c 7776
7777ALIAS (clear_ip_bgp_peer_soft_in,
7778 clear_ip_bgp_instance_peer_in_cmd,
7779 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) in",
7780 CLEAR_STR
7781 IP_STR
7782 BGP_STR
7783 BGP_INSTANCE_HELP_STR
7784 "BGP neighbor address to clear\n"
7785 "BGP neighbor on interface to clear\n"
7786 BGP_SOFT_IN_STR)
7787
718e3744 7788DEFUN (clear_ip_bgp_peer_in_prefix_filter,
7789 clear_ip_bgp_peer_in_prefix_filter_cmd,
db64ea86 7790 "clear ip bgp (A.B.C.D|WORD) in prefix-filter",
718e3744 7791 CLEAR_STR
7792 IP_STR
7793 BGP_STR
7794 "BGP neighbor address to clear\n"
db64ea86 7795 "BGP neighbor on interface to clear\n"
e0bce756 7796 BGP_SOFT_IN_STR
718e3744 7797 "Push out the existing ORF prefix-list\n")
7798{
7799 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
7800 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7801}
7802
7803DEFUN (clear_ip_bgp_peer_ipv4_soft_in,
7804 clear_ip_bgp_peer_ipv4_soft_in_cmd,
db64ea86 7805 "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) soft in",
718e3744 7806 CLEAR_STR
7807 IP_STR
7808 BGP_STR
7809 "BGP neighbor address to clear\n"
db64ea86 7810 "BGP neighbor on interface to clear\n"
718e3744 7811 "Address family\n"
7812 "Address Family modifier\n"
7813 "Address Family modifier\n"
e0bce756
DS
7814 BGP_SOFT_STR
7815 BGP_SOFT_IN_STR)
718e3744 7816{
7817 if (strncmp (argv[1], "m", 1) == 0)
7818 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
7819 BGP_CLEAR_SOFT_IN, argv[0]);
7820
7821 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
7822 BGP_CLEAR_SOFT_IN, argv[0]);
7823}
7824
01080f7c 7825DEFUN (clear_ip_bgp_instance_peer_ipv4_soft_in,
7826 clear_ip_bgp_instance_peer_ipv4_soft_in_cmd,
7827 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 (unicast|multicast) soft in",
7828 CLEAR_STR
7829 IP_STR
7830 BGP_STR
7831 BGP_INSTANCE_HELP_STR
7832 "BGP neighbor address to clear\n"
7833 "BGP neighbor on interface to clear\n"
7834 "Address family\n"
7835 "Address Family modifier\n"
7836 "Address Family modifier\n"
7837 BGP_SOFT_STR
7838 BGP_SOFT_IN_STR)
7839{
7840 if (strncmp (argv[3], "m", 1) == 0)
7841 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_peer,
7842 BGP_CLEAR_SOFT_IN, argv[2]);
7843
7844 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer,
7845 BGP_CLEAR_SOFT_IN, argv[2]);
7846}
7847
718e3744 7848ALIAS (clear_ip_bgp_peer_ipv4_soft_in,
7849 clear_ip_bgp_peer_ipv4_in_cmd,
db64ea86 7850 "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) in",
718e3744 7851 CLEAR_STR
7852 IP_STR
7853 BGP_STR
7854 "BGP neighbor address to clear\n"
db64ea86 7855 "BGP neighbor on interface to clear\n"
718e3744 7856 "Address family\n"
7857 "Address Family modifier\n"
7858 "Address Family modifier\n"
e0bce756 7859 BGP_SOFT_IN_STR)
718e3744 7860
01080f7c 7861ALIAS (clear_ip_bgp_instance_peer_ipv4_soft_in,
7862 clear_ip_bgp_instance_peer_ipv4_in_cmd,
7863 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 (unicast|multicast) in",
7864 CLEAR_STR
7865 IP_STR
7866 BGP_STR
7867 BGP_INSTANCE_HELP_STR
7868 "BGP neighbor address to clear\n"
7869 "BGP neighbor on interface to clear\n"
7870 "Address family\n"
7871 "Address Family modifier\n"
7872 "Address Family modifier\n"
7873 BGP_SOFT_IN_STR)
7874
718e3744 7875DEFUN (clear_ip_bgp_peer_ipv4_in_prefix_filter,
7876 clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd,
db64ea86 7877 "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) in prefix-filter",
718e3744 7878 CLEAR_STR
7879 IP_STR
7880 BGP_STR
7881 "BGP neighbor address to clear\n"
db64ea86 7882 "BGP neighbor on interface to clear\n"
718e3744 7883 "Address family\n"
7884 "Address Family modifier\n"
7885 "Address Family modifier\n"
e0bce756 7886 BGP_SOFT_IN_STR
718e3744 7887 "Push out the existing ORF prefix-list\n")
7888{
7889 if (strncmp (argv[1], "m", 1) == 0)
7890 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
7891 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7892
7893 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
7894 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7895}
7896
7897DEFUN (clear_ip_bgp_peer_vpnv4_soft_in,
7898 clear_ip_bgp_peer_vpnv4_soft_in_cmd,
db64ea86 7899 "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast soft in",
718e3744 7900 CLEAR_STR
7901 IP_STR
7902 BGP_STR
7903 "BGP neighbor address to clear\n"
db64ea86 7904 "BGP neighbor on interface to clear\n"
718e3744 7905 "Address family\n"
7906 "Address Family Modifier\n"
e0bce756
DS
7907 BGP_SOFT_STR
7908 BGP_SOFT_IN_STR)
718e3744 7909{
7910 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
7911 BGP_CLEAR_SOFT_IN, argv[0]);
7912}
7913
7914ALIAS (clear_ip_bgp_peer_vpnv4_soft_in,
7915 clear_ip_bgp_peer_vpnv4_in_cmd,
db64ea86 7916 "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast in",
718e3744 7917 CLEAR_STR
7918 IP_STR
7919 BGP_STR
7920 "BGP neighbor address to clear\n"
db64ea86 7921 "BGP neighbor on interface to clear\n"
718e3744 7922 "Address family\n"
7923 "Address Family Modifier\n"
e0bce756 7924 BGP_SOFT_IN_STR)
718e3744 7925
7926DEFUN (clear_bgp_peer_soft_in,
7927 clear_bgp_peer_soft_in_cmd,
a80beece 7928 "clear bgp (A.B.C.D|X:X::X:X|WORD) soft in",
718e3744 7929 CLEAR_STR
7930 BGP_STR
7931 "BGP neighbor address to clear\n"
7932 "BGP IPv6 neighbor to clear\n"
a80beece 7933 "BGP neighbor on interface to clear\n"
e0bce756
DS
7934 BGP_SOFT_STR
7935 BGP_SOFT_IN_STR)
718e3744 7936{
01080f7c 7937 if (argc == 3)
7938 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_peer,
7939 BGP_CLEAR_SOFT_IN, argv[2]);
7940
718e3744 7941 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
7942 BGP_CLEAR_SOFT_IN, argv[0]);
7943}
7944
01080f7c 7945ALIAS (clear_bgp_peer_soft_in,
7946 clear_bgp_instance_peer_soft_in_cmd,
7947 "clear bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD) soft in",
7948 CLEAR_STR
7949 BGP_STR
7950 BGP_INSTANCE_HELP_STR
7951 "BGP neighbor address to clear\n"
7952 "BGP IPv6 neighbor to clear\n"
7953 "BGP neighbor on interface to clear\n"
7954 BGP_SOFT_STR
7955 BGP_SOFT_IN_STR)
7956
718e3744 7957ALIAS (clear_bgp_peer_soft_in,
7958 clear_bgp_ipv6_peer_soft_in_cmd,
a80beece 7959 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) soft in",
718e3744 7960 CLEAR_STR
7961 BGP_STR
7962 "Address family\n"
7963 "BGP neighbor address to clear\n"
7964 "BGP IPv6 neighbor to clear\n"
a80beece 7965 "BGP neighbor on interface to clear\n"
e0bce756
DS
7966 BGP_SOFT_STR
7967 BGP_SOFT_IN_STR)
718e3744 7968
01080f7c 7969ALIAS (clear_bgp_peer_soft_in,
7970 clear_bgp_instance_ipv6_peer_soft_in_cmd,
7971 "clear bgp " BGP_INSTANCE_CMD " ipv6 (A.B.C.D|X:X::X:X|WORD) soft in",
7972 CLEAR_STR
7973 BGP_STR
7974 BGP_INSTANCE_HELP_STR
7975 "Address family\n"
7976 "BGP neighbor address to clear\n"
7977 "BGP IPv6 neighbor to clear\n"
7978 "BGP neighbor on interface to clear\n"
7979 BGP_SOFT_STR
7980 BGP_SOFT_IN_STR)
7981
718e3744 7982ALIAS (clear_bgp_peer_soft_in,
7983 clear_bgp_peer_in_cmd,
a80beece 7984 "clear bgp (A.B.C.D|X:X::X:X|WORD) in",
718e3744 7985 CLEAR_STR
7986 BGP_STR
7987 "BGP neighbor address to clear\n"
7988 "BGP IPv6 neighbor to clear\n"
a80beece 7989 "BGP neighbor on interface to clear\n"
e0bce756 7990 BGP_SOFT_IN_STR)
718e3744 7991
01080f7c 7992ALIAS (clear_bgp_peer_soft_in,
7993 clear_bgp_instance_peer_in_cmd,
7994 "clear bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD) in",
7995 CLEAR_STR
7996 BGP_STR
7997 BGP_INSTANCE_HELP_STR
7998 "BGP neighbor address to clear\n"
7999 "BGP IPv6 neighbor to clear\n"
8000 "BGP neighbor on interface to clear\n"
8001 BGP_SOFT_IN_STR)
8002
718e3744 8003ALIAS (clear_bgp_peer_soft_in,
8004 clear_bgp_ipv6_peer_in_cmd,
a80beece 8005 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) in",
718e3744 8006 CLEAR_STR
8007 BGP_STR
8008 "Address family\n"
8009 "BGP neighbor address to clear\n"
8010 "BGP IPv6 neighbor to clear\n"
a80beece 8011 "BGP neighbor on interface to clear\n"
e0bce756 8012 BGP_SOFT_IN_STR)
718e3744 8013
01080f7c 8014ALIAS (clear_bgp_peer_soft_in,
8015 clear_bgp_instance_ipv6_peer_in_cmd,
8016 "clear bgp " BGP_INSTANCE_CMD " ipv6 (A.B.C.D|X:X::X:X|WORD) in",
8017 CLEAR_STR
8018 BGP_STR
8019 BGP_INSTANCE_HELP_STR
8020 "Address family\n"
8021 "BGP neighbor address to clear\n"
8022 "BGP IPv6 neighbor to clear\n"
8023 "BGP neighbor on interface to clear\n"
8024 BGP_SOFT_IN_STR)
8025
718e3744 8026DEFUN (clear_bgp_peer_in_prefix_filter,
8027 clear_bgp_peer_in_prefix_filter_cmd,
a80beece 8028 "clear bgp (A.B.C.D|X:X::X:X|WORD) in prefix-filter",
718e3744 8029 CLEAR_STR
8030 BGP_STR
8031 "BGP neighbor address to clear\n"
8032 "BGP IPv6 neighbor to clear\n"
a80beece 8033 "BGP neighbor on interface to clear\n"
e0bce756 8034 BGP_SOFT_IN_STR
718e3744 8035 "Push out the existing ORF prefix-list\n")
8036{
8037 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
8038 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8039}
8040
8041ALIAS (clear_bgp_peer_in_prefix_filter,
8042 clear_bgp_ipv6_peer_in_prefix_filter_cmd,
a80beece 8043 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) in prefix-filter",
718e3744 8044 CLEAR_STR
8045 BGP_STR
8046 "Address family\n"
8047 "BGP neighbor address to clear\n"
8048 "BGP IPv6 neighbor to clear\n"
a80beece 8049 "BGP neighbor on interface to clear\n"
e0bce756 8050 BGP_SOFT_IN_STR
718e3744 8051 "Push out the existing ORF prefix-list\n")
8052
8053DEFUN (clear_ip_bgp_peer_group_soft_in,
8054 clear_ip_bgp_peer_group_soft_in_cmd,
8055 "clear ip bgp peer-group WORD soft in",
8056 CLEAR_STR
8057 IP_STR
8058 BGP_STR
8059 "Clear all members of peer-group\n"
8060 "BGP peer-group name\n"
e0bce756
DS
8061 BGP_SOFT_STR
8062 BGP_SOFT_IN_STR)
718e3744 8063{
01080f7c 8064 if (argc == 3)
8065 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group,
8066 BGP_CLEAR_SOFT_IN, argv[2]);
8067
718e3744 8068 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
8069 BGP_CLEAR_SOFT_IN, argv[0]);
8070}
8071
01080f7c 8072ALIAS (clear_ip_bgp_peer_group_soft_in,
8073 clear_ip_bgp_instance_peer_group_soft_in_cmd,
8074 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD soft in",
8075 CLEAR_STR
8076 IP_STR
8077 BGP_STR
8078 BGP_INSTANCE_HELP_STR
8079 "Clear all members of peer-group\n"
8080 "BGP peer-group name\n"
8081 BGP_SOFT_STR
8082 BGP_SOFT_IN_STR)
8083
718e3744 8084ALIAS (clear_ip_bgp_peer_group_soft_in,
8085 clear_ip_bgp_peer_group_in_cmd,
8086 "clear ip bgp peer-group WORD in",
8087 CLEAR_STR
8088 IP_STR
8089 BGP_STR
8090 "Clear all members of peer-group\n"
8091 "BGP peer-group name\n"
e0bce756 8092 BGP_SOFT_IN_STR)
718e3744 8093
01080f7c 8094ALIAS (clear_ip_bgp_peer_group_soft_in,
8095 clear_ip_bgp_instance_peer_group_in_cmd,
8096 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD in",
8097 CLEAR_STR
8098 IP_STR
8099 BGP_STR
8100 BGP_INSTANCE_HELP_STR
8101 "Clear all members of peer-group\n"
8102 "BGP peer-group name\n"
8103 BGP_SOFT_IN_STR)
8104
718e3744 8105DEFUN (clear_ip_bgp_peer_group_in_prefix_filter,
8106 clear_ip_bgp_peer_group_in_prefix_filter_cmd,
8107 "clear ip bgp peer-group WORD in prefix-filter",
8108 CLEAR_STR
8109 IP_STR
8110 BGP_STR
8111 "Clear all members of peer-group\n"
8112 "BGP peer-group name\n"
e0bce756 8113 BGP_SOFT_IN_STR
718e3744 8114 "Push out prefix-list ORF and do inbound soft reconfig\n")
8115{
8116 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
8117 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8118}
8119
8120DEFUN (clear_ip_bgp_peer_group_ipv4_soft_in,
8121 clear_ip_bgp_peer_group_ipv4_soft_in_cmd,
8122 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft in",
8123 CLEAR_STR
8124 IP_STR
8125 BGP_STR
8126 "Clear all members of peer-group\n"
8127 "BGP peer-group name\n"
8128 "Address family\n"
8129 "Address Family modifier\n"
8130 "Address Family modifier\n"
e0bce756
DS
8131 BGP_SOFT_STR
8132 BGP_SOFT_IN_STR)
718e3744 8133{
8134 if (strncmp (argv[1], "m", 1) == 0)
8135 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
8136 BGP_CLEAR_SOFT_IN, argv[0]);
8137
8138 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
8139 BGP_CLEAR_SOFT_IN, argv[0]);
8140}
8141
01080f7c 8142DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft_in,
8143 clear_ip_bgp_instance_peer_group_ipv4_soft_in_cmd,
8144 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 (unicast|multicast) soft in",
8145 CLEAR_STR
8146 IP_STR
8147 BGP_STR
8148 BGP_INSTANCE_HELP_STR
8149 "Clear all members of peer-group\n"
8150 "BGP peer-group name\n"
8151 "Address family\n"
8152 "Address Family modifier\n"
8153 "Address Family modifier\n"
8154 BGP_SOFT_STR
8155 BGP_SOFT_IN_STR)
8156{
8157 if (strncmp (argv[3], "m", 1) == 0)
8158 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_group,
8159 BGP_CLEAR_SOFT_IN, argv[2]);
8160
8161 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group,
8162 BGP_CLEAR_SOFT_IN, argv[2]);
8163}
8164
718e3744 8165ALIAS (clear_ip_bgp_peer_group_ipv4_soft_in,
8166 clear_ip_bgp_peer_group_ipv4_in_cmd,
8167 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in",
8168 CLEAR_STR
8169 IP_STR
8170 BGP_STR
8171 "Clear all members of peer-group\n"
8172 "BGP peer-group name\n"
8173 "Address family\n"
8174 "Address Family modifier\n"
8175 "Address Family modifier\n"
e0bce756 8176 BGP_SOFT_IN_STR)
718e3744 8177
01080f7c 8178ALIAS (clear_ip_bgp_instance_peer_group_ipv4_soft_in,
8179 clear_ip_bgp_instance_peer_group_ipv4_in_cmd,
8180 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 (unicast|multicast) in",
8181 CLEAR_STR
8182 IP_STR
8183 BGP_STR
8184 BGP_INSTANCE_HELP_STR
8185 "Clear all members of peer-group\n"
8186 "BGP peer-group name\n"
8187 "Address family\n"
8188 "Address Family modifier\n"
8189 "Address Family modifier\n"
8190 BGP_SOFT_IN_STR)
8191
718e3744 8192DEFUN (clear_ip_bgp_peer_group_ipv4_in_prefix_filter,
8193 clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd,
8194 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in prefix-filter",
8195 CLEAR_STR
8196 IP_STR
8197 BGP_STR
8198 "Clear all members of peer-group\n"
8199 "BGP peer-group name\n"
8200 "Address family\n"
8201 "Address Family modifier\n"
8202 "Address Family modifier\n"
e0bce756 8203 BGP_SOFT_IN_STR
718e3744 8204 "Push out prefix-list ORF and do inbound soft reconfig\n")
8205{
8206 if (strncmp (argv[1], "m", 1) == 0)
8207 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
8208 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8209
8210 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
8211 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8212}
8213
8214DEFUN (clear_bgp_peer_group_soft_in,
8215 clear_bgp_peer_group_soft_in_cmd,
8216 "clear bgp peer-group WORD soft in",
8217 CLEAR_STR
8218 BGP_STR
8219 "Clear all members of peer-group\n"
8220 "BGP peer-group name\n"
e0bce756
DS
8221 BGP_SOFT_STR
8222 BGP_SOFT_IN_STR)
718e3744 8223{
01080f7c 8224 if (argc == 3)
8225 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_group,
8226 BGP_CLEAR_SOFT_IN, argv[2]);
8227
718e3744 8228 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
8229 BGP_CLEAR_SOFT_IN, argv[0]);
8230}
8231
01080f7c 8232ALIAS (clear_bgp_peer_group_soft_in,
8233 clear_bgp_instance_peer_group_soft_in_cmd,
8234 "clear bgp " BGP_INSTANCE_CMD " peer-group WORD soft in",
8235 CLEAR_STR
8236 BGP_STR
8237 BGP_INSTANCE_HELP_STR
8238 "Clear all members of peer-group\n"
8239 "BGP peer-group name\n"
8240 BGP_SOFT_STR
8241 BGP_SOFT_IN_STR)
8242
718e3744 8243ALIAS (clear_bgp_peer_group_soft_in,
8244 clear_bgp_ipv6_peer_group_soft_in_cmd,
8245 "clear bgp ipv6 peer-group WORD soft in",
8246 CLEAR_STR
8247 BGP_STR
8248 "Address family\n"
8249 "Clear all members of peer-group\n"
8250 "BGP peer-group name\n"
e0bce756
DS
8251 BGP_SOFT_STR
8252 BGP_SOFT_IN_STR)
718e3744 8253
01080f7c 8254ALIAS (clear_bgp_peer_group_soft_in,
8255 clear_bgp_instance_ipv6_peer_group_soft_in_cmd,
8256 "clear bgp " BGP_INSTANCE_CMD " ipv6 peer-group WORD soft in",
8257 CLEAR_STR
8258 BGP_STR
8259 BGP_INSTANCE_HELP_STR
8260 "Address family\n"
8261 "Clear all members of peer-group\n"
8262 "BGP peer-group name\n"
8263 BGP_SOFT_STR
8264 BGP_SOFT_IN_STR)
8265
718e3744 8266ALIAS (clear_bgp_peer_group_soft_in,
8267 clear_bgp_peer_group_in_cmd,
8268 "clear bgp peer-group WORD in",
8269 CLEAR_STR
8270 BGP_STR
8271 "Clear all members of peer-group\n"
8272 "BGP peer-group name\n"
e0bce756 8273 BGP_SOFT_IN_STR)
718e3744 8274
01080f7c 8275ALIAS (clear_bgp_peer_group_soft_in,
8276 clear_bgp_instance_peer_group_in_cmd,
8277 "clear bgp " BGP_INSTANCE_CMD " peer-group WORD in",
8278 CLEAR_STR
8279 BGP_STR
8280 BGP_INSTANCE_HELP_STR
8281 "Clear all members of peer-group\n"
8282 "BGP peer-group name\n"
8283 BGP_SOFT_IN_STR)
8284
718e3744 8285ALIAS (clear_bgp_peer_group_soft_in,
8286 clear_bgp_ipv6_peer_group_in_cmd,
8287 "clear bgp ipv6 peer-group WORD in",
8288 CLEAR_STR
8289 BGP_STR
8290 "Address family\n"
8291 "Clear all members of peer-group\n"
8292 "BGP peer-group name\n"
e0bce756 8293 BGP_SOFT_IN_STR)
718e3744 8294
01080f7c 8295ALIAS (clear_bgp_peer_group_soft_in,
8296 clear_bgp_instance_ipv6_peer_group_in_cmd,
8297 "clear bgp " BGP_INSTANCE_CMD " ipv6 peer-group WORD in",
8298 CLEAR_STR
8299 BGP_STR
8300 BGP_INSTANCE_HELP_STR
8301 "Address family\n"
8302 "Clear all members of peer-group\n"
8303 "BGP peer-group name\n"
8304 BGP_SOFT_IN_STR)
8305
718e3744 8306DEFUN (clear_bgp_peer_group_in_prefix_filter,
8307 clear_bgp_peer_group_in_prefix_filter_cmd,
8308 "clear bgp peer-group WORD in prefix-filter",
8309 CLEAR_STR
8310 BGP_STR
8311 "Clear all members of peer-group\n"
8312 "BGP peer-group name\n"
e0bce756 8313 BGP_SOFT_IN_STR
718e3744 8314 "Push out prefix-list ORF and do inbound soft reconfig\n")
8315{
8316 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
8317 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8318}
8319
8320ALIAS (clear_bgp_peer_group_in_prefix_filter,
8321 clear_bgp_ipv6_peer_group_in_prefix_filter_cmd,
8322 "clear bgp ipv6 peer-group WORD in prefix-filter",
8323 CLEAR_STR
8324 BGP_STR
8325 "Address family\n"
8326 "Clear all members of peer-group\n"
8327 "BGP peer-group name\n"
e0bce756 8328 BGP_SOFT_IN_STR
718e3744 8329 "Push out prefix-list ORF and do inbound soft reconfig\n")
8330
8331DEFUN (clear_ip_bgp_external_soft_in,
8332 clear_ip_bgp_external_soft_in_cmd,
8333 "clear ip bgp external soft in",
8334 CLEAR_STR
8335 IP_STR
8336 BGP_STR
8337 "Clear all external peers\n"
e0bce756
DS
8338 BGP_SOFT_STR
8339 BGP_SOFT_IN_STR)
718e3744 8340{
01080f7c 8341 if (argc == 2)
8342 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external,
8343 BGP_CLEAR_SOFT_IN, NULL);
8344
718e3744 8345 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
8346 BGP_CLEAR_SOFT_IN, NULL);
8347}
8348
01080f7c 8349ALIAS (clear_ip_bgp_external_soft_in,
8350 clear_ip_bgp_instance_external_soft_in_cmd,
8351 "clear ip bgp " BGP_INSTANCE_CMD " external soft in",
8352 CLEAR_STR
8353 IP_STR
8354 BGP_STR
8355 BGP_INSTANCE_HELP_STR
8356 "Clear all external peers\n"
8357 BGP_SOFT_STR
8358 BGP_SOFT_IN_STR)
8359
718e3744 8360ALIAS (clear_ip_bgp_external_soft_in,
8361 clear_ip_bgp_external_in_cmd,
8362 "clear ip bgp external in",
8363 CLEAR_STR
8364 IP_STR
8365 BGP_STR
8366 "Clear all external peers\n"
e0bce756 8367 BGP_SOFT_IN_STR)
718e3744 8368
01080f7c 8369ALIAS (clear_ip_bgp_external_soft_in,
8370 clear_ip_bgp_instance_external_in_cmd,
8371 "clear ip bgp " BGP_INSTANCE_CMD " external in",
8372 CLEAR_STR
8373 IP_STR
8374 BGP_STR
8375 BGP_INSTANCE_HELP_STR
8376 "Clear all external peers\n"
8377 BGP_SOFT_IN_STR)
8378
718e3744 8379DEFUN (clear_ip_bgp_external_in_prefix_filter,
8380 clear_ip_bgp_external_in_prefix_filter_cmd,
8381 "clear ip bgp external in prefix-filter",
8382 CLEAR_STR
8383 IP_STR
8384 BGP_STR
8385 "Clear all external peers\n"
e0bce756 8386 BGP_SOFT_IN_STR
718e3744 8387 "Push out prefix-list ORF and do inbound soft reconfig\n")
8388{
8389 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
8390 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
8391}
8392
8393DEFUN (clear_ip_bgp_external_ipv4_soft_in,
8394 clear_ip_bgp_external_ipv4_soft_in_cmd,
8395 "clear ip bgp external ipv4 (unicast|multicast) soft in",
8396 CLEAR_STR
8397 IP_STR
8398 BGP_STR
8399 "Clear all external peers\n"
8400 "Address family\n"
8401 "Address Family modifier\n"
8402 "Address Family modifier\n"
e0bce756
DS
8403 BGP_SOFT_STR
8404 BGP_SOFT_IN_STR)
718e3744 8405{
8406 if (strncmp (argv[0], "m", 1) == 0)
8407 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
8408 BGP_CLEAR_SOFT_IN, NULL);
8409
8410 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
8411 BGP_CLEAR_SOFT_IN, NULL);
8412}
8413
01080f7c 8414DEFUN (clear_ip_bgp_instance_external_ipv4_soft_in,
8415 clear_ip_bgp_instance_external_ipv4_soft_in_cmd,
8416 "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 (unicast|multicast) soft in",
8417 CLEAR_STR
8418 IP_STR
8419 BGP_STR
8420 BGP_INSTANCE_HELP_STR
8421 "Clear all external peers\n"
8422 "Address family\n"
8423 "Address Family modifier\n"
8424 "Address Family modifier\n"
8425 BGP_SOFT_STR
8426 BGP_SOFT_IN_STR)
8427{
8428 if (strncmp (argv[2], "m", 1) == 0)
8429 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_external,
8430 BGP_CLEAR_SOFT_IN, NULL);
8431
8432 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external,
8433 BGP_CLEAR_SOFT_IN, NULL);
8434}
8435
718e3744 8436ALIAS (clear_ip_bgp_external_ipv4_soft_in,
8437 clear_ip_bgp_external_ipv4_in_cmd,
8438 "clear ip bgp external ipv4 (unicast|multicast) in",
8439 CLEAR_STR
8440 IP_STR
8441 BGP_STR
8442 "Clear all external peers\n"
8443 "Address family\n"
8444 "Address Family modifier\n"
8445 "Address Family modifier\n"
e0bce756 8446 BGP_SOFT_IN_STR)
718e3744 8447
01080f7c 8448ALIAS (clear_ip_bgp_instance_external_ipv4_soft_in,
8449 clear_ip_bgp_instance_external_ipv4_in_cmd,
8450 "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 (unicast|multicast) in",
8451 CLEAR_STR
8452 IP_STR
8453 BGP_STR
8454 BGP_INSTANCE_HELP_STR
8455 "Clear all external peers\n"
8456 "Address family\n"
8457 "Address Family modifier\n"
8458 "Address Family modifier\n"
8459 BGP_SOFT_IN_STR)
8460
718e3744 8461DEFUN (clear_ip_bgp_external_ipv4_in_prefix_filter,
8462 clear_ip_bgp_external_ipv4_in_prefix_filter_cmd,
8463 "clear ip bgp external ipv4 (unicast|multicast) in prefix-filter",
8464 CLEAR_STR
8465 IP_STR
8466 BGP_STR
8467 "Clear all external peers\n"
8468 "Address family\n"
8469 "Address Family modifier\n"
8470 "Address Family modifier\n"
e0bce756 8471 BGP_SOFT_IN_STR
718e3744 8472 "Push out prefix-list ORF and do inbound soft reconfig\n")
8473{
8474 if (strncmp (argv[0], "m", 1) == 0)
8475 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
8476 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
8477
8478 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
8479 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
8480}
8481
8482DEFUN (clear_bgp_external_soft_in,
8483 clear_bgp_external_soft_in_cmd,
8484 "clear bgp external soft in",
8485 CLEAR_STR
8486 BGP_STR
8487 "Clear all external peers\n"
e0bce756
DS
8488 BGP_SOFT_STR
8489 BGP_SOFT_IN_STR)
718e3744 8490{
01080f7c 8491 if (argc == 2)
8492 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_external,
8493 BGP_CLEAR_SOFT_IN, NULL);
8494
718e3744 8495 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
8496 BGP_CLEAR_SOFT_IN, NULL);
8497}
8498
01080f7c 8499ALIAS (clear_bgp_external_soft_in,
8500 clear_bgp_instance_external_soft_in_cmd,
8501 "clear bgp " BGP_INSTANCE_CMD " external soft in",
8502 CLEAR_STR
8503 BGP_STR
8504 BGP_INSTANCE_HELP_STR
8505 "Clear all external peers\n"
8506 BGP_SOFT_STR
8507 BGP_SOFT_IN_STR)
8508
718e3744 8509ALIAS (clear_bgp_external_soft_in,
8510 clear_bgp_ipv6_external_soft_in_cmd,
8511 "clear bgp ipv6 external soft in",
8512 CLEAR_STR
8513 BGP_STR
8514 "Address family\n"
8515 "Clear all external peers\n"
e0bce756
DS
8516 BGP_SOFT_STR
8517 BGP_SOFT_IN_STR)
718e3744 8518
01080f7c 8519ALIAS (clear_bgp_external_soft_in,
8520 clear_bgp_instance_ipv6_external_soft_in_cmd,
8521 "clear bgp " BGP_INSTANCE_CMD " ipv6 external soft in",
8522 CLEAR_STR
8523 BGP_STR
8524 BGP_INSTANCE_HELP_STR
8525 "Address family\n"
8526 "Clear all external peers\n"
8527 BGP_SOFT_STR
8528 BGP_SOFT_IN_STR)
8529
718e3744 8530ALIAS (clear_bgp_external_soft_in,
8531 clear_bgp_external_in_cmd,
8532 "clear bgp external in",
8533 CLEAR_STR
8534 BGP_STR
8535 "Clear all external peers\n"
e0bce756 8536 BGP_SOFT_IN_STR)
718e3744 8537
01080f7c 8538ALIAS (clear_bgp_external_soft_in,
8539 clear_bgp_instance_external_in_cmd,
8540 "clear bgp " BGP_INSTANCE_CMD " external in",
8541 CLEAR_STR
8542 BGP_STR
8543 BGP_INSTANCE_HELP_STR
8544 "Clear all external peers\n"
8545 BGP_SOFT_IN_STR)
8546
718e3744 8547ALIAS (clear_bgp_external_soft_in,
8548 clear_bgp_ipv6_external_in_cmd,
8549 "clear bgp ipv6 external WORD in",
8550 CLEAR_STR
8551 BGP_STR
8552 "Address family\n"
8553 "Clear all external peers\n"
e0bce756 8554 BGP_SOFT_IN_STR)
718e3744 8555
01080f7c 8556ALIAS (clear_bgp_external_soft_in,
8557 clear_bgp_instance_ipv6_external_in_cmd,
8558 "clear bgp " BGP_INSTANCE_CMD " ipv6 external WORD in",
8559 CLEAR_STR
8560 BGP_STR
8561 BGP_INSTANCE_HELP_STR
8562 "Address family\n"
8563 "Clear all external peers\n"
8564 BGP_SOFT_IN_STR)
8565
718e3744 8566DEFUN (clear_bgp_external_in_prefix_filter,
8567 clear_bgp_external_in_prefix_filter_cmd,
8568 "clear bgp external in prefix-filter",
8569 CLEAR_STR
8570 BGP_STR
8571 "Clear all external peers\n"
e0bce756 8572 BGP_SOFT_IN_STR
718e3744 8573 "Push out prefix-list ORF and do inbound soft reconfig\n")
8574{
8575 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
8576 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
8577}
8578
8579ALIAS (clear_bgp_external_in_prefix_filter,
8580 clear_bgp_ipv6_external_in_prefix_filter_cmd,
8581 "clear bgp ipv6 external in prefix-filter",
8582 CLEAR_STR
8583 BGP_STR
8584 "Address family\n"
8585 "Clear all external peers\n"
e0bce756 8586 BGP_SOFT_IN_STR
718e3744 8587 "Push out prefix-list ORF and do inbound soft reconfig\n")
8588
8589DEFUN (clear_ip_bgp_as_soft_in,
8590 clear_ip_bgp_as_soft_in_cmd,
320da874 8591 "clear ip bgp " CMD_AS_RANGE " soft in",
718e3744 8592 CLEAR_STR
8593 IP_STR
8594 BGP_STR
8595 "Clear peers with the AS number\n"
e0bce756
DS
8596 BGP_SOFT_STR
8597 BGP_SOFT_IN_STR)
718e3744 8598{
01080f7c 8599 if (argc == 3)
8600 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as,
8601 BGP_CLEAR_SOFT_IN, argv[2]);
8602
718e3744 8603 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
8604 BGP_CLEAR_SOFT_IN, argv[0]);
8605}
8606
8607ALIAS (clear_ip_bgp_as_soft_in,
01080f7c 8608 clear_ip_bgp_instance_as_soft_in_cmd,
8609 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " soft in",
8610 CLEAR_STR
8611 IP_STR
8612 BGP_STR
8613 BGP_INSTANCE_HELP_STR
8614 "Clear peers with the AS number\n"
8615 BGP_SOFT_STR
8616 BGP_SOFT_IN_STR)
8617
8618ALIAS (clear_ip_bgp_as_soft_in,
8619 clear_ip_bgp_as_in_cmd,
8620 "clear ip bgp " CMD_AS_RANGE " in",
8621 CLEAR_STR
8622 IP_STR
8623 BGP_STR
8624 "Clear peers with the AS number\n"
8625 BGP_SOFT_IN_STR)
8626
8627ALIAS (clear_ip_bgp_as_soft_in,
8628 clear_ip_bgp_instance_as_in_cmd,
8629 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " in",
718e3744 8630 CLEAR_STR
8631 IP_STR
8632 BGP_STR
01080f7c 8633 BGP_INSTANCE_HELP_STR
718e3744 8634 "Clear peers with the AS number\n"
e0bce756 8635 BGP_SOFT_IN_STR)
718e3744 8636
8637DEFUN (clear_ip_bgp_as_in_prefix_filter,
8638 clear_ip_bgp_as_in_prefix_filter_cmd,
320da874 8639 "clear ip bgp " CMD_AS_RANGE " in prefix-filter",
718e3744 8640 CLEAR_STR
8641 IP_STR
8642 BGP_STR
8643 "Clear peers with the AS number\n"
e0bce756 8644 BGP_SOFT_IN_STR
718e3744 8645 "Push out prefix-list ORF and do inbound soft reconfig\n")
8646{
8647 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
8648 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8649}
8650
8651DEFUN (clear_ip_bgp_as_ipv4_soft_in,
8652 clear_ip_bgp_as_ipv4_soft_in_cmd,
320da874 8653 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft in",
718e3744 8654 CLEAR_STR
8655 IP_STR
8656 BGP_STR
8657 "Clear peers with the AS number\n"
8658 "Address family\n"
8659 "Address Family modifier\n"
8660 "Address Family modifier\n"
e0bce756
DS
8661 BGP_SOFT_STR
8662 BGP_SOFT_IN_STR)
718e3744 8663{
8664 if (strncmp (argv[1], "m", 1) == 0)
8665 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
8666 BGP_CLEAR_SOFT_IN, argv[0]);
8667
8668 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
8669 BGP_CLEAR_SOFT_IN, argv[0]);
8670}
8671
01080f7c 8672DEFUN (clear_ip_bgp_instance_as_ipv4_soft_in,
8673 clear_ip_bgp_instance_as_ipv4_soft_in_cmd,
8674 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 (unicast|multicast) soft in",
8675 CLEAR_STR
8676 IP_STR
8677 BGP_STR
8678 BGP_INSTANCE_HELP_STR
8679 "Clear peers with the AS number\n"
8680 "Address family\n"
8681 "Address Family modifier\n"
8682 "Address Family modifier\n"
8683 BGP_SOFT_STR
8684 BGP_SOFT_IN_STR)
8685{
8686 if (strncmp (argv[3], "m", 1) == 0)
8687 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_as,
8688 BGP_CLEAR_SOFT_IN, argv[2]);
8689
8690 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as,
8691 BGP_CLEAR_SOFT_IN, argv[2]);
8692}
8693
718e3744 8694ALIAS (clear_ip_bgp_as_ipv4_soft_in,
8695 clear_ip_bgp_as_ipv4_in_cmd,
320da874 8696 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in",
718e3744 8697 CLEAR_STR
8698 IP_STR
8699 BGP_STR
8700 "Clear peers with the AS number\n"
8701 "Address family\n"
8702 "Address Family modifier\n"
8703 "Address Family modifier\n"
e0bce756 8704 BGP_SOFT_IN_STR)
718e3744 8705
01080f7c 8706ALIAS (clear_ip_bgp_instance_as_ipv4_soft_in,
8707 clear_ip_bgp_instance_as_ipv4_in_cmd,
8708 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 (unicast|multicast) in",
8709 CLEAR_STR
8710 IP_STR
8711 BGP_STR
8712 BGP_INSTANCE_HELP_STR
8713 "Clear peers with the AS number\n"
8714 "Address family\n"
8715 "Address Family modifier\n"
8716 "Address Family modifier\n"
8717 BGP_SOFT_IN_STR)
8718
718e3744 8719DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter,
8720 clear_ip_bgp_as_ipv4_in_prefix_filter_cmd,
320da874 8721 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in prefix-filter",
718e3744 8722 CLEAR_STR
8723 IP_STR
8724 BGP_STR
8725 "Clear peers with the AS number\n"
8726 "Address family\n"
8727 "Address Family modifier\n"
8728 "Address Family modifier\n"
e0bce756 8729 BGP_SOFT_IN_STR
718e3744 8730 "Push out prefix-list ORF and do inbound soft reconfig\n")
8731{
8732 if (strncmp (argv[1], "m", 1) == 0)
8733 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
8734 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8735
8736 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
8737 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8738}
8739
8740DEFUN (clear_ip_bgp_as_vpnv4_soft_in,
8741 clear_ip_bgp_as_vpnv4_soft_in_cmd,
320da874 8742 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft in",
718e3744 8743 CLEAR_STR
8744 IP_STR
8745 BGP_STR
8746 "Clear peers with the AS number\n"
8747 "Address family\n"
8748 "Address Family modifier\n"
e0bce756
DS
8749 BGP_SOFT_STR
8750 BGP_SOFT_IN_STR)
718e3744 8751{
8752 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
8753 BGP_CLEAR_SOFT_IN, argv[0]);
8754}
8755
8756ALIAS (clear_ip_bgp_as_vpnv4_soft_in,
8757 clear_ip_bgp_as_vpnv4_in_cmd,
320da874 8758 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast in",
718e3744 8759 CLEAR_STR
8760 IP_STR
8761 BGP_STR
8762 "Clear peers with the AS number\n"
8763 "Address family\n"
8764 "Address Family modifier\n"
e0bce756 8765 BGP_SOFT_IN_STR)
718e3744 8766
8767DEFUN (clear_bgp_as_soft_in,
8768 clear_bgp_as_soft_in_cmd,
320da874 8769 "clear bgp " CMD_AS_RANGE " soft in",
718e3744 8770 CLEAR_STR
8771 BGP_STR
8772 "Clear peers with the AS number\n"
e0bce756
DS
8773 BGP_SOFT_STR
8774 BGP_SOFT_IN_STR)
718e3744 8775{
01080f7c 8776 if (argc == 3)
8777 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_as,
8778 BGP_CLEAR_SOFT_IN, argv[2]);
8779
718e3744 8780 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
8781 BGP_CLEAR_SOFT_IN, argv[0]);
8782}
8783
01080f7c 8784ALIAS (clear_bgp_as_soft_in,
8785 clear_bgp_instance_as_soft_in_cmd,
8786 "clear bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " soft in",
8787 CLEAR_STR
8788 BGP_STR
8789 BGP_INSTANCE_HELP_STR
8790 "Clear peers with the AS number\n"
8791 BGP_SOFT_STR
8792 BGP_SOFT_IN_STR)
8793
718e3744 8794ALIAS (clear_bgp_as_soft_in,
8795 clear_bgp_ipv6_as_soft_in_cmd,
320da874 8796 "clear bgp ipv6 " CMD_AS_RANGE " soft in",
718e3744 8797 CLEAR_STR
8798 BGP_STR
8799 "Address family\n"
8800 "Clear peers with the AS number\n"
e0bce756
DS
8801 BGP_SOFT_STR
8802 BGP_SOFT_IN_STR)
718e3744 8803
01080f7c 8804ALIAS (clear_bgp_as_soft_in,
8805 clear_bgp_instance_ipv6_as_soft_in_cmd,
8806 "clear bgp " BGP_INSTANCE_CMD " ipv6 " CMD_AS_RANGE " soft in",
8807 CLEAR_STR
8808 BGP_STR
8809 BGP_INSTANCE_HELP_STR
8810 "Address family\n"
8811 "Clear peers with the AS number\n"
8812 BGP_SOFT_STR
8813 BGP_SOFT_IN_STR)
8814
718e3744 8815ALIAS (clear_bgp_as_soft_in,
8816 clear_bgp_as_in_cmd,
320da874 8817 "clear bgp " CMD_AS_RANGE " in",
718e3744 8818 CLEAR_STR
8819 BGP_STR
8820 "Clear peers with the AS number\n"
e0bce756 8821 BGP_SOFT_IN_STR)
718e3744 8822
01080f7c 8823ALIAS (clear_bgp_as_soft_in,
8824 clear_bgp_instance_as_in_cmd,
8825 "clear bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " in",
8826 CLEAR_STR
8827 BGP_STR
8828 BGP_INSTANCE_HELP_STR
8829 "Clear peers with the AS number\n"
8830 BGP_SOFT_IN_STR)
8831
718e3744 8832ALIAS (clear_bgp_as_soft_in,
8833 clear_bgp_ipv6_as_in_cmd,
320da874 8834 "clear bgp ipv6 " CMD_AS_RANGE " in",
718e3744 8835 CLEAR_STR
8836 BGP_STR
8837 "Address family\n"
8838 "Clear peers with the AS number\n"
e0bce756 8839 BGP_SOFT_IN_STR)
718e3744 8840
01080f7c 8841ALIAS (clear_bgp_as_soft_in,
8842 clear_bgp_instance_ipv6_as_in_cmd,
8843 "clear bgp " BGP_INSTANCE_CMD " ipv6 " CMD_AS_RANGE " in",
8844 CLEAR_STR
8845 BGP_STR
8846 BGP_INSTANCE_HELP_STR
8847 "Address family\n"
8848 "Clear peers with the AS number\n"
8849 BGP_SOFT_IN_STR)
8850
718e3744 8851DEFUN (clear_bgp_as_in_prefix_filter,
8852 clear_bgp_as_in_prefix_filter_cmd,
320da874 8853 "clear bgp " CMD_AS_RANGE " in prefix-filter",
718e3744 8854 CLEAR_STR
8855 BGP_STR
8856 "Clear peers with the AS number\n"
e0bce756 8857 BGP_SOFT_IN_STR
718e3744 8858 "Push out prefix-list ORF and do inbound soft reconfig\n")
8859{
8860 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
8861 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8862}
8863
8864ALIAS (clear_bgp_as_in_prefix_filter,
8865 clear_bgp_ipv6_as_in_prefix_filter_cmd,
320da874 8866 "clear bgp ipv6 " CMD_AS_RANGE " in prefix-filter",
718e3744 8867 CLEAR_STR
8868 BGP_STR
8869 "Address family\n"
8870 "Clear peers with the AS number\n"
e0bce756 8871 BGP_SOFT_IN_STR
718e3744 8872 "Push out prefix-list ORF and do inbound soft reconfig\n")
6b0655a2 8873
718e3744 8874/* Both soft-reconfiguration */
8875DEFUN (clear_ip_bgp_all_soft,
8876 clear_ip_bgp_all_soft_cmd,
8877 "clear ip bgp * soft",
8878 CLEAR_STR
8879 IP_STR
8880 BGP_STR
8881 "Clear all peers\n"
e0bce756 8882 BGP_SOFT_STR)
718e3744 8883{
6aeb9e78
DS
8884 if (argc == 2)
8885 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all,
718e3744 8886 BGP_CLEAR_SOFT_BOTH, NULL);
8887
8888 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
8889 BGP_CLEAR_SOFT_BOTH, NULL);
8890}
8891
8892ALIAS (clear_ip_bgp_all_soft,
8893 clear_ip_bgp_instance_all_soft_cmd,
8386ac43 8894 "clear ip bgp " BGP_INSTANCE_CMD " * soft",
718e3744 8895 CLEAR_STR
8896 IP_STR
8897 BGP_STR
8386ac43 8898 BGP_INSTANCE_HELP_STR
718e3744 8899 "Clear all peers\n"
e0bce756 8900 BGP_SOFT_STR)
718e3744 8901
8902
8903DEFUN (clear_ip_bgp_all_ipv4_soft,
8904 clear_ip_bgp_all_ipv4_soft_cmd,
8905 "clear ip bgp * ipv4 (unicast|multicast) soft",
8906 CLEAR_STR
8907 IP_STR
8908 BGP_STR
8909 "Clear all peers\n"
8910 "Address family\n"
8911 "Address Family Modifier\n"
8912 "Address Family Modifier\n"
e0bce756 8913 BGP_SOFT_STR)
718e3744 8914{
8915 if (strncmp (argv[0], "m", 1) == 0)
8916 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
8917 BGP_CLEAR_SOFT_BOTH, NULL);
8918
8919 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
8920 BGP_CLEAR_SOFT_BOTH, NULL);
8921}
8922
8923DEFUN (clear_ip_bgp_instance_all_ipv4_soft,
8924 clear_ip_bgp_instance_all_ipv4_soft_cmd,
8386ac43 8925 "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) soft",
718e3744 8926 CLEAR_STR
8927 IP_STR
8928 BGP_STR
8386ac43 8929 BGP_INSTANCE_HELP_STR
718e3744 8930 "Clear all peers\n"
8931 "Address family\n"
8932 "Address Family Modifier\n"
8933 "Address Family Modifier\n"
e0bce756 8934 BGP_SOFT_STR)
718e3744 8935{
6aeb9e78
DS
8936 if (strncmp (argv[2], "m", 1) == 0)
8937 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_all,
718e3744 8938 BGP_CLEAR_SOFT_BOTH, NULL);
8939
8940 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
8941 BGP_CLEAR_SOFT_BOTH, NULL);
8942}
8943
8944DEFUN (clear_ip_bgp_all_vpnv4_soft,
8945 clear_ip_bgp_all_vpnv4_soft_cmd,
8946 "clear ip bgp * vpnv4 unicast soft",
8947 CLEAR_STR
8948 IP_STR
8949 BGP_STR
8950 "Clear all peers\n"
8951 "Address family\n"
8952 "Address Family Modifier\n"
e0bce756 8953 BGP_SOFT_STR)
718e3744 8954{
8955 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
8956 BGP_CLEAR_SOFT_BOTH, argv[0]);
8957}
8958
8959DEFUN (clear_bgp_all_soft,
8960 clear_bgp_all_soft_cmd,
8961 "clear bgp * soft",
8962 CLEAR_STR
8963 BGP_STR
8964 "Clear all peers\n"
e0bce756 8965 BGP_SOFT_STR)
718e3744 8966{
6aeb9e78
DS
8967 if (argc == 2)
8968 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_all,
01080f7c 8969 BGP_CLEAR_SOFT_BOTH, NULL);
718e3744 8970
8971 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
01080f7c 8972 BGP_CLEAR_SOFT_BOTH, NULL);
718e3744 8973}
8974
8975ALIAS (clear_bgp_all_soft,
8976 clear_bgp_instance_all_soft_cmd,
8386ac43 8977 "clear bgp " BGP_INSTANCE_CMD " * soft",
718e3744 8978 CLEAR_STR
8979 BGP_STR
8386ac43 8980 BGP_INSTANCE_HELP_STR
718e3744 8981 "Clear all peers\n"
e0bce756 8982 BGP_SOFT_STR)
718e3744 8983
8984ALIAS (clear_bgp_all_soft,
8985 clear_bgp_ipv6_all_soft_cmd,
8986 "clear bgp ipv6 * soft",
8987 CLEAR_STR
8988 BGP_STR
8989 "Address family\n"
8990 "Clear all peers\n"
e0bce756 8991 BGP_SOFT_STR)
718e3744 8992
01080f7c 8993ALIAS (clear_bgp_all_soft,
8994 clear_bgp_instance_ipv6_all_soft_cmd,
8995 "clear bgp " BGP_INSTANCE_CMD " ipv6 * soft",
8996 CLEAR_STR
8997 BGP_STR
8998 BGP_INSTANCE_HELP_STR
8999 "Address family\n"
9000 "Clear all peers\n"
9001 BGP_SOFT_STR)
9002
718e3744 9003DEFUN (clear_ip_bgp_peer_soft,
9004 clear_ip_bgp_peer_soft_cmd,
db64ea86 9005 "clear ip bgp (A.B.C.D|WORD) soft",
718e3744 9006 CLEAR_STR
9007 IP_STR
9008 BGP_STR
9009 "BGP neighbor address to clear\n"
db64ea86 9010 "BGP neighbor on interface to clear\n"
e0bce756 9011 BGP_SOFT_STR)
718e3744 9012{
01080f7c 9013 if (argc == 3)
9014 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer,
9015 BGP_CLEAR_SOFT_BOTH, argv[2]);
9016
718e3744 9017 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
9018 BGP_CLEAR_SOFT_BOTH, argv[0]);
9019}
9020
01080f7c 9021ALIAS (clear_ip_bgp_peer_soft,
9022 clear_ip_bgp_instance_peer_soft_cmd,
9023 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) soft",
9024 CLEAR_STR
9025 IP_STR
9026 BGP_STR
9027 BGP_INSTANCE_HELP_STR
9028 "BGP neighbor address to clear\n"
9029 "BGP neighbor on interface to clear\n"
9030 BGP_SOFT_STR)
9031
718e3744 9032DEFUN (clear_ip_bgp_peer_ipv4_soft,
9033 clear_ip_bgp_peer_ipv4_soft_cmd,
db64ea86 9034 "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) soft",
718e3744 9035 CLEAR_STR
9036 IP_STR
9037 BGP_STR
9038 "BGP neighbor address to clear\n"
db64ea86 9039 "BGP neighbor on interface to clear\n"
718e3744 9040 "Address family\n"
9041 "Address Family Modifier\n"
9042 "Address Family Modifier\n"
e0bce756 9043 BGP_SOFT_STR)
718e3744 9044{
9045 if (strncmp (argv[1], "m", 1) == 0)
9046 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
9047 BGP_CLEAR_SOFT_BOTH, argv[0]);
9048
9049 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
9050 BGP_CLEAR_SOFT_BOTH, argv[0]);
9051}
9052
01080f7c 9053DEFUN (clear_ip_bgp_instance_peer_ipv4_soft,
9054 clear_ip_bgp_instance_peer_ipv4_soft_cmd,
9055 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 (unicast|multicast) soft",
9056 CLEAR_STR
9057 IP_STR
9058 BGP_STR
9059 BGP_INSTANCE_HELP_STR
9060 "BGP neighbor address to clear\n"
9061 "BGP neighbor on interface to clear\n"
9062 "Address family\n"
9063 "Address Family Modifier\n"
9064 "Address Family Modifier\n"
9065 BGP_SOFT_STR)
9066{
9067 if (strncmp (argv[3], "m", 1) == 0)
9068 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_peer,
9069 BGP_CLEAR_SOFT_BOTH, argv[2]);
9070
9071 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer,
9072 BGP_CLEAR_SOFT_BOTH, argv[2]);
9073}
9074
718e3744 9075DEFUN (clear_ip_bgp_peer_vpnv4_soft,
9076 clear_ip_bgp_peer_vpnv4_soft_cmd,
db64ea86 9077 "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast soft",
718e3744 9078 CLEAR_STR
9079 IP_STR
9080 BGP_STR
9081 "BGP neighbor address to clear\n"
db64ea86 9082 "BGP neighbor on interface to clear\n"
718e3744 9083 "Address family\n"
9084 "Address Family Modifier\n"
e0bce756 9085 BGP_SOFT_STR)
718e3744 9086{
9087 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
9088 BGP_CLEAR_SOFT_BOTH, argv[0]);
9089}
9090
9091DEFUN (clear_bgp_peer_soft,
9092 clear_bgp_peer_soft_cmd,
a80beece 9093 "clear bgp (A.B.C.D|X:X::X:X|WORD) soft",
718e3744 9094 CLEAR_STR
9095 BGP_STR
9096 "BGP neighbor address to clear\n"
9097 "BGP IPv6 neighbor to clear\n"
a80beece 9098 "BGP neighbor on interface to clear\n"
e0bce756 9099 BGP_SOFT_STR)
718e3744 9100{
01080f7c 9101 if (argc == 3)
9102 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_peer,
9103 BGP_CLEAR_SOFT_BOTH, argv[2]);
9104
718e3744 9105 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
9106 BGP_CLEAR_SOFT_BOTH, argv[0]);
9107}
9108
01080f7c 9109ALIAS (clear_bgp_peer_soft,
9110 clear_bgp_instance_peer_soft_cmd,
9111 "clear bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD) soft",
9112 CLEAR_STR
9113 BGP_STR
9114 BGP_INSTANCE_HELP_STR
9115 "BGP neighbor address to clear\n"
9116 "BGP IPv6 neighbor to clear\n"
9117 "BGP neighbor on interface to clear\n"
9118 BGP_SOFT_STR)
9119
718e3744 9120ALIAS (clear_bgp_peer_soft,
9121 clear_bgp_ipv6_peer_soft_cmd,
a80beece 9122 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) soft",
718e3744 9123 CLEAR_STR
9124 BGP_STR
9125 "Address family\n"
9126 "BGP neighbor address to clear\n"
9127 "BGP IPv6 neighbor to clear\n"
a80beece 9128 "BGP neighbor on interface to clear\n"
e0bce756 9129 BGP_SOFT_STR)
718e3744 9130
01080f7c 9131ALIAS (clear_bgp_peer_soft,
9132 clear_bgp_instance_ipv6_peer_soft_cmd,
9133 "clear bgp " BGP_INSTANCE_CMD " ipv6 (A.B.C.D|X:X::X:X|WORD) soft",
9134 CLEAR_STR
9135 BGP_STR
9136 BGP_INSTANCE_HELP_STR
9137 "Address family\n"
9138 "BGP neighbor address to clear\n"
9139 "BGP IPv6 neighbor to clear\n"
9140 "BGP neighbor on interface to clear\n"
9141 BGP_SOFT_STR)
9142
718e3744 9143DEFUN (clear_ip_bgp_peer_group_soft,
9144 clear_ip_bgp_peer_group_soft_cmd,
9145 "clear ip bgp peer-group WORD soft",
9146 CLEAR_STR
9147 IP_STR
9148 BGP_STR
9149 "Clear all members of peer-group\n"
9150 "BGP peer-group name\n"
e0bce756 9151 BGP_SOFT_STR)
718e3744 9152{
01080f7c 9153 if (argc == 3)
9154 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group,
9155 BGP_CLEAR_SOFT_BOTH, argv[2]);
9156
718e3744 9157 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
9158 BGP_CLEAR_SOFT_BOTH, argv[0]);
9159}
9160
01080f7c 9161ALIAS (clear_ip_bgp_peer_group_soft,
9162 clear_ip_bgp_instance_peer_group_soft_cmd,
9163 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD soft",
9164 CLEAR_STR
9165 IP_STR
9166 BGP_STR
9167 BGP_INSTANCE_HELP_STR
9168 "Clear all members of peer-group\n"
9169 "BGP peer-group name\n"
9170 BGP_SOFT_STR)
9171
718e3744 9172DEFUN (clear_ip_bgp_peer_group_ipv4_soft,
9173 clear_ip_bgp_peer_group_ipv4_soft_cmd,
9174 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft",
9175 CLEAR_STR
9176 IP_STR
9177 BGP_STR
9178 "Clear all members of peer-group\n"
9179 "BGP peer-group name\n"
9180 "Address family\n"
9181 "Address Family modifier\n"
9182 "Address Family modifier\n"
e0bce756 9183 BGP_SOFT_STR)
718e3744 9184{
9185 if (strncmp (argv[1], "m", 1) == 0)
9186 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
9187 BGP_CLEAR_SOFT_BOTH, argv[0]);
9188
9189 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
9190 BGP_CLEAR_SOFT_BOTH, argv[0]);
9191}
9192
01080f7c 9193DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft,
9194 clear_ip_bgp_instance_peer_group_ipv4_soft_cmd,
9195 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 (unicast|multicast) soft",
9196 CLEAR_STR
9197 IP_STR
9198 BGP_STR
9199 BGP_INSTANCE_HELP_STR
9200 "Clear all members of peer-group\n"
9201 "BGP peer-group name\n"
9202 "Address family\n"
9203 "Address Family modifier\n"
9204 "Address Family modifier\n"
9205 BGP_SOFT_STR)
9206{
9207 if (strncmp (argv[3], "m", 1) == 0)
9208 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_group,
9209 BGP_CLEAR_SOFT_BOTH, argv[2]);
9210
9211 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group,
9212 BGP_CLEAR_SOFT_BOTH, argv[2]);
9213}
9214
718e3744 9215DEFUN (clear_bgp_peer_group_soft,
9216 clear_bgp_peer_group_soft_cmd,
9217 "clear bgp peer-group WORD soft",
9218 CLEAR_STR
9219 BGP_STR
9220 "Clear all members of peer-group\n"
9221 "BGP peer-group name\n"
e0bce756 9222 BGP_SOFT_STR)
718e3744 9223{
01080f7c 9224 if (argc == 3)
9225 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_group,
9226 BGP_CLEAR_SOFT_BOTH, argv[2]);
9227
718e3744 9228 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
9229 BGP_CLEAR_SOFT_BOTH, argv[0]);
9230}
9231
01080f7c 9232ALIAS (clear_bgp_peer_group_soft,
9233 clear_bgp_instance_peer_group_soft_cmd,
9234 "clear bgp " BGP_INSTANCE_CMD " peer-group WORD soft",
9235 CLEAR_STR
9236 BGP_STR
9237 BGP_INSTANCE_HELP_STR
9238 "Clear all members of peer-group\n"
9239 "BGP peer-group name\n"
9240 BGP_SOFT_STR)
9241
718e3744 9242ALIAS (clear_bgp_peer_group_soft,
9243 clear_bgp_ipv6_peer_group_soft_cmd,
9244 "clear bgp ipv6 peer-group WORD soft",
9245 CLEAR_STR
9246 BGP_STR
9247 "Address family\n"
9248 "Clear all members of peer-group\n"
9249 "BGP peer-group name\n"
e0bce756 9250 BGP_SOFT_STR)
718e3744 9251
01080f7c 9252ALIAS (clear_bgp_peer_group_soft,
9253 clear_bgp_instance_ipv6_peer_group_soft_cmd,
9254 "clear bgp " BGP_INSTANCE_CMD " ipv6 peer-group WORD soft",
9255 CLEAR_STR
9256 BGP_STR
9257 BGP_INSTANCE_HELP_STR
9258 "Address family\n"
9259 "Clear all members of peer-group\n"
9260 "BGP peer-group name\n"
9261 BGP_SOFT_STR)
9262
718e3744 9263DEFUN (clear_ip_bgp_external_soft,
9264 clear_ip_bgp_external_soft_cmd,
9265 "clear ip bgp external soft",
9266 CLEAR_STR
9267 IP_STR
9268 BGP_STR
9269 "Clear all external peers\n"
e0bce756 9270 BGP_SOFT_STR)
718e3744 9271{
01080f7c 9272 if (argc == 2)
9273 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external,
9274 BGP_CLEAR_SOFT_BOTH, NULL);
9275
718e3744 9276 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
9277 BGP_CLEAR_SOFT_BOTH, NULL);
9278}
9279
01080f7c 9280ALIAS (clear_ip_bgp_external_soft,
9281 clear_ip_bgp_instance_external_soft_cmd,
9282 "clear ip bgp " BGP_INSTANCE_CMD " external soft",
9283 CLEAR_STR
9284 IP_STR
9285 BGP_STR
9286 BGP_INSTANCE_HELP_STR
9287 "Clear all external peers\n"
9288 BGP_SOFT_STR)
9289
718e3744 9290DEFUN (clear_ip_bgp_external_ipv4_soft,
9291 clear_ip_bgp_external_ipv4_soft_cmd,
9292 "clear ip bgp external ipv4 (unicast|multicast) soft",
9293 CLEAR_STR
9294 IP_STR
9295 BGP_STR
9296 "Clear all external peers\n"
9297 "Address family\n"
9298 "Address Family modifier\n"
9299 "Address Family modifier\n"
e0bce756 9300 BGP_SOFT_STR)
718e3744 9301{
9302 if (strncmp (argv[0], "m", 1) == 0)
9303 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
9304 BGP_CLEAR_SOFT_BOTH, NULL);
9305
9306 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
9307 BGP_CLEAR_SOFT_BOTH, NULL);
9308}
9309
01080f7c 9310DEFUN (clear_ip_bgp_instance_external_ipv4_soft,
9311 clear_ip_bgp_instance_external_ipv4_soft_cmd,
9312 "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 (unicast|multicast) soft",
9313 CLEAR_STR
9314 IP_STR
9315 BGP_STR
9316 BGP_INSTANCE_HELP_STR
9317 "Clear all external peers\n"
9318 "Address family\n"
9319 "Address Family modifier\n"
9320 "Address Family modifier\n"
9321 BGP_SOFT_STR)
9322{
9323 if (strncmp (argv[2], "m", 1) == 0)
9324 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_external,
9325 BGP_CLEAR_SOFT_BOTH, NULL);
9326
9327 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external,
9328 BGP_CLEAR_SOFT_BOTH, NULL);
9329}
9330
718e3744 9331DEFUN (clear_bgp_external_soft,
9332 clear_bgp_external_soft_cmd,
9333 "clear bgp external soft",
9334 CLEAR_STR
9335 BGP_STR
9336 "Clear all external peers\n"
e0bce756 9337 BGP_SOFT_STR)
718e3744 9338{
01080f7c 9339 if (argc == 2)
9340 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_external,
9341 BGP_CLEAR_SOFT_BOTH, NULL);
9342
718e3744 9343 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
9344 BGP_CLEAR_SOFT_BOTH, NULL);
9345}
9346
01080f7c 9347ALIAS (clear_bgp_external_soft,
9348 clear_bgp_instance_external_soft_cmd,
9349 "clear bgp " BGP_INSTANCE_CMD " external soft",
9350 CLEAR_STR
9351 BGP_STR
9352 BGP_INSTANCE_HELP_STR
9353 "Clear all external peers\n"
9354 BGP_SOFT_STR)
9355
718e3744 9356ALIAS (clear_bgp_external_soft,
9357 clear_bgp_ipv6_external_soft_cmd,
9358 "clear bgp ipv6 external soft",
9359 CLEAR_STR
9360 BGP_STR
9361 "Address family\n"
9362 "Clear all external peers\n"
e0bce756 9363 BGP_SOFT_STR)
718e3744 9364
01080f7c 9365ALIAS (clear_bgp_external_soft,
9366 clear_bgp_instance_ipv6_external_soft_cmd,
9367 "clear bgp " BGP_INSTANCE_CMD " ipv6 external soft",
9368 CLEAR_STR
9369 BGP_STR
9370 BGP_INSTANCE_HELP_STR
9371 "Address family\n"
9372 "Clear all external peers\n"
9373 BGP_SOFT_STR)
9374
718e3744 9375DEFUN (clear_ip_bgp_as_soft,
9376 clear_ip_bgp_as_soft_cmd,
320da874 9377 "clear ip bgp " CMD_AS_RANGE " soft",
718e3744 9378 CLEAR_STR
9379 IP_STR
9380 BGP_STR
9381 "Clear peers with the AS number\n"
e0bce756 9382 BGP_SOFT_STR)
718e3744 9383{
01080f7c 9384 if (argc == 3)
9385 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as,
9386 BGP_CLEAR_SOFT_BOTH, argv[2]);
9387
718e3744 9388 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
9389 BGP_CLEAR_SOFT_BOTH, argv[0]);
9390}
9391
01080f7c 9392ALIAS (clear_ip_bgp_as_soft,
9393 clear_ip_bgp_instance_as_soft_cmd,
9394 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " soft",
9395 CLEAR_STR
9396 IP_STR
9397 BGP_STR
9398 BGP_INSTANCE_HELP_STR
9399 "Clear peers with the AS number\n"
9400 BGP_SOFT_STR)
9401
718e3744 9402DEFUN (clear_ip_bgp_as_ipv4_soft,
9403 clear_ip_bgp_as_ipv4_soft_cmd,
320da874 9404 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft",
718e3744 9405 CLEAR_STR
9406 IP_STR
9407 BGP_STR
9408 "Clear peers with the AS number\n"
9409 "Address family\n"
9410 "Address Family Modifier\n"
9411 "Address Family Modifier\n"
e0bce756 9412 BGP_SOFT_STR)
718e3744 9413{
9414 if (strncmp (argv[1], "m", 1) == 0)
9415 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
9416 BGP_CLEAR_SOFT_BOTH, argv[0]);
9417
9418 return bgp_clear_vty (vty, NULL,AFI_IP, SAFI_UNICAST, clear_as,
9419 BGP_CLEAR_SOFT_BOTH, argv[0]);
9420}
9421
01080f7c 9422DEFUN (clear_ip_bgp_instance_as_ipv4_soft,
9423 clear_ip_bgp_instance_as_ipv4_soft_cmd,
9424 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 (unicast|multicast) soft",
9425 CLEAR_STR
9426 IP_STR
9427 BGP_STR
9428 BGP_INSTANCE_HELP_STR
9429 "Clear peers with the AS number\n"
9430 "Address family\n"
9431 "Address Family Modifier\n"
9432 "Address Family Modifier\n"
9433 BGP_SOFT_STR)
9434{
9435 if (strncmp (argv[3], "m", 1) == 0)
9436 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_as,
9437 BGP_CLEAR_SOFT_BOTH, argv[2]);
9438
9439 return bgp_clear_vty (vty, argv[1],AFI_IP, SAFI_UNICAST, clear_as,
9440 BGP_CLEAR_SOFT_BOTH, argv[2]);
9441}
9442
718e3744 9443DEFUN (clear_ip_bgp_as_vpnv4_soft,
9444 clear_ip_bgp_as_vpnv4_soft_cmd,
320da874 9445 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft",
718e3744 9446 CLEAR_STR
9447 IP_STR
9448 BGP_STR
9449 "Clear peers with the AS number\n"
9450 "Address family\n"
9451 "Address Family Modifier\n"
e0bce756 9452 BGP_SOFT_STR)
718e3744 9453{
9454 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
9455 BGP_CLEAR_SOFT_BOTH, argv[0]);
9456}
9457
9458DEFUN (clear_bgp_as_soft,
9459 clear_bgp_as_soft_cmd,
320da874 9460 "clear bgp " CMD_AS_RANGE " soft",
718e3744 9461 CLEAR_STR
9462 BGP_STR
9463 "Clear peers with the AS number\n"
e0bce756 9464 BGP_SOFT_STR)
718e3744 9465{
01080f7c 9466 if (argc == 3)
9467 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_as,
9468 BGP_CLEAR_SOFT_BOTH, argv[2]);
9469
718e3744 9470 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
9471 BGP_CLEAR_SOFT_BOTH, argv[0]);
9472}
9473
01080f7c 9474ALIAS (clear_bgp_as_soft,
9475 clear_bgp_instance_as_soft_cmd,
9476 "clear bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " soft",
9477 CLEAR_STR
9478 BGP_STR
9479 BGP_INSTANCE_HELP_STR
9480 "Clear peers with the AS number\n"
9481 BGP_SOFT_STR)
9482
718e3744 9483ALIAS (clear_bgp_as_soft,
9484 clear_bgp_ipv6_as_soft_cmd,
320da874 9485 "clear bgp ipv6 " CMD_AS_RANGE " soft",
718e3744 9486 CLEAR_STR
9487 BGP_STR
9488 "Address family\n"
9489 "Clear peers with the AS number\n"
e0bce756 9490 BGP_SOFT_STR)
6b0655a2 9491
01080f7c 9492ALIAS (clear_bgp_as_soft,
9493 clear_bgp_instance_ipv6_as_soft_cmd,
9494 "clear bgp " BGP_INSTANCE_CMD " ipv6 " CMD_AS_RANGE " soft",
9495 CLEAR_STR
9496 BGP_STR
9497 BGP_INSTANCE_HELP_STR
9498 "Address family\n"
9499 "Clear peers with the AS number\n"
9500 BGP_SOFT_STR)
9501
e0081f70
ML
9502DEFUN (show_bgp_views,
9503 show_bgp_views_cmd,
9504 "show bgp views",
9505 SHOW_STR
9506 BGP_STR
9507 "Show the defined BGP views\n")
9508{
9509 struct list *inst = bm->bgp;
9510 struct listnode *node;
9511 struct bgp *bgp;
9512
9513 if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
9514 {
8386ac43 9515 vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE);
e0081f70
ML
9516 return CMD_WARNING;
9517 }
9518
9519 vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE);
9520 for (ALL_LIST_ELEMENTS_RO(inst, node, bgp))
8386ac43 9521 {
9522 /* Skip VRFs. */
9523 if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF)
9524 continue;
9525 vty_out (vty, "\t%s (AS%u)%s",
9526 bgp->name ? bgp->name : "(null)",
9527 bgp->as, VTY_NEWLINE);
9528 }
e0081f70
ML
9529
9530 return CMD_SUCCESS;
9531}
9532
8386ac43 9533DEFUN (show_bgp_vrfs,
9534 show_bgp_vrfs_cmd,
9535 "show bgp vrfs {json}",
9536 SHOW_STR
9537 BGP_STR
9538 "Show BGP VRFs\n"
9539 "JavaScript Object Notation\n")
9540{
9541 struct list *inst = bm->bgp;
9542 struct listnode *node;
9543 struct bgp *bgp;
9544 u_char uj = use_json(argc, argv);
9545 json_object *json = NULL;
9546 json_object *json_vrfs = NULL;
9547 int count = 0;
9548 static char header[] = "Type Id RouterId #PeersCfg #PeersEstb Name";
9549
9550 if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
9551 {
9552 vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE);
9553 return CMD_WARNING;
9554 }
9555
9556 if (uj)
9557 {
9558 json = json_object_new_object();
9559 json_vrfs = json_object_new_object();
9560 }
9561
9562 for (ALL_LIST_ELEMENTS_RO(inst, node, bgp))
9563 {
9564 const char *name, *type;
9565 struct peer *peer;
9566 struct listnode *node, *nnode;
9567 int peers_cfg, peers_estb;
9568 json_object *json_vrf = NULL;
5c81a5f3 9569 int vrf_id_ui;
8386ac43 9570
9571 /* Skip Views. */
9572 if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW)
9573 continue;
9574
9575 count++;
9576 if (!uj && count == 1)
9577 vty_out (vty, "%s%s", header, VTY_NEWLINE);
9578
9579 peers_cfg = peers_estb = 0;
9580 if (uj)
9581 json_vrf = json_object_new_object();
9582
9583
9584 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
9585 {
9586 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
9587 continue;
9588 peers_cfg++;
9589 if (peer->status == Established)
9590 peers_estb++;
9591 }
9592
9593 if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
9594 {
9595 name = "Default";
9596 type = "DFLT";
9597 }
9598 else
9599 {
9600 name = bgp->name;
9601 type = "VRF";
9602 }
9603
5c81a5f3 9604 vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id;
8386ac43 9605 if (uj)
9606 {
9607 json_object_string_add(json_vrf, "type", type);
5c81a5f3 9608 json_object_int_add(json_vrf, "vrfId", vrf_id_ui);
8386ac43 9609 json_object_string_add(json_vrf, "routerId", inet_ntoa (bgp->router_id));
9610 json_object_int_add(json_vrf, "numConfiguredPeers", peers_cfg);
9611 json_object_int_add(json_vrf, "numEstablishedPeers", peers_estb);
9612
9613 json_object_object_add(json_vrfs, name, json_vrf);
9614 }
9615 else
5c81a5f3 9616 vty_out (vty, "%4s %-5d %-16s %9u %10u %s%s",
9617 type, vrf_id_ui, inet_ntoa (bgp->router_id),
8386ac43 9618 peers_cfg, peers_estb, name,
9619 VTY_NEWLINE);
9620 }
9621
9622 if (uj)
9623 {
9624 json_object_object_add(json, "vrfs", json_vrfs);
9625
9626 json_object_int_add(json, "totalVrfs", count);
9627
9628 vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
9629 json_object_free(json);
9630 }
9631 else
9632 {
9633 if (count)
9634 vty_out (vty, "%sTotal number of VRFs (including default): %d%s",
9635 VTY_NEWLINE, count, VTY_NEWLINE);
9636 }
9637
9638 return CMD_SUCCESS;
9639}
9640
4bf6a362
PJ
9641DEFUN (show_bgp_memory,
9642 show_bgp_memory_cmd,
9643 "show bgp memory",
9644 SHOW_STR
9645 BGP_STR
9646 "Global BGP memory statistics\n")
9647{
9648 char memstrbuf[MTYPE_MEMSTR_LEN];
9649 unsigned long count;
9650
9651 /* RIB related usage stats */
9652 count = mtype_stats_alloc (MTYPE_BGP_NODE);
9653 vty_out (vty, "%ld RIB nodes, using %s of memory%s", count,
9654 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9655 count * sizeof (struct bgp_node)),
9656 VTY_NEWLINE);
9657
9658 count = mtype_stats_alloc (MTYPE_BGP_ROUTE);
9659 vty_out (vty, "%ld BGP routes, using %s of memory%s", count,
9660 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9661 count * sizeof (struct bgp_info)),
9662 VTY_NEWLINE);
fb982c25
PJ
9663 if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA)))
9664 vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count,
9665 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9666 count * sizeof (struct bgp_info_extra)),
9667 VTY_NEWLINE);
4bf6a362
PJ
9668
9669 if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC)))
9670 vty_out (vty, "%ld Static routes, using %s of memory%s", count,
9671 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9672 count * sizeof (struct bgp_static)),
9673 VTY_NEWLINE);
3f9c7369
DS
9674
9675 if ((count = mtype_stats_alloc (MTYPE_BGP_PACKET)))
9676 vty_out (vty, "%ld Packets, using %s of memory%s", count,
9677 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9678 count * sizeof (struct bpacket)),
9679 VTY_NEWLINE);
4bf6a362
PJ
9680
9681 /* Adj-In/Out */
9682 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN)))
9683 vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count,
9684 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9685 count * sizeof (struct bgp_adj_in)),
9686 VTY_NEWLINE);
9687 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT)))
9688 vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count,
9689 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9690 count * sizeof (struct bgp_adj_out)),
9691 VTY_NEWLINE);
9692
9693 if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE)))
9694 vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count,
9695 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9696 count * sizeof (struct bgp_nexthop_cache)),
9697 VTY_NEWLINE);
9698
9699 if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO)))
9700 vty_out (vty, "%ld Dampening entries, using %s of memory%s", count,
9701 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9702 count * sizeof (struct bgp_damp_info)),
9703 VTY_NEWLINE);
9704
9705 /* Attributes */
9706 count = attr_count();
9707 vty_out (vty, "%ld BGP attributes, using %s of memory%s", count,
9708 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9709 count * sizeof(struct attr)),
9710 VTY_NEWLINE);
fb982c25
PJ
9711 if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA)))
9712 vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count,
9713 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9714 count * sizeof(struct attr_extra)),
9715 VTY_NEWLINE);
4bf6a362
PJ
9716
9717 if ((count = attr_unknown_count()))
9718 vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE);
9719
9720 /* AS_PATH attributes */
9721 count = aspath_count ();
9722 vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count,
9723 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9724 count * sizeof (struct aspath)),
9725 VTY_NEWLINE);
9726
9727 count = mtype_stats_alloc (MTYPE_AS_SEG);
9728 vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count,
9729 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9730 count * sizeof (struct assegment)),
9731 VTY_NEWLINE);
9732
9733 /* Other attributes */
9734 if ((count = community_count ()))
9735 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
9736 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9737 count * sizeof (struct community)),
9738 VTY_NEWLINE);
9739 if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY)))
9740 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
9741 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9742 count * sizeof (struct ecommunity)),
9743 VTY_NEWLINE);
9744
9745 if ((count = mtype_stats_alloc (MTYPE_CLUSTER)))
9746 vty_out (vty, "%ld Cluster lists, using %s of memory%s", count,
9747 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9748 count * sizeof (struct cluster_list)),
9749 VTY_NEWLINE);
9750
9751 /* Peer related usage */
9752 count = mtype_stats_alloc (MTYPE_BGP_PEER);
9753 vty_out (vty, "%ld peers, using %s of memory%s", count,
9754 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9755 count * sizeof (struct peer)),
9756 VTY_NEWLINE);
9757
6e919709 9758 if ((count = mtype_stats_alloc (MTYPE_BGP_PEER_GROUP)))
4bf6a362
PJ
9759 vty_out (vty, "%ld peer groups, using %s of memory%s", count,
9760 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9761 count * sizeof (struct peer_group)),
9762 VTY_NEWLINE);
9763
9764 /* Other */
9765 if ((count = mtype_stats_alloc (MTYPE_HASH)))
9766 vty_out (vty, "%ld hash tables, using %s of memory%s", count,
9767 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9768 count * sizeof (struct hash)),
9769 VTY_NEWLINE);
9770 if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET)))
9771 vty_out (vty, "%ld hash buckets, using %s of memory%s", count,
9772 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9773 count * sizeof (struct hash_backet)),
9774 VTY_NEWLINE);
9775 if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP)))
9776 vty_out (vty, "%ld compiled regexes, using %s of memory%s", count,
9777 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9778 count * sizeof (regex_t)),
9779 VTY_NEWLINE);
9780 return CMD_SUCCESS;
9781}
fee0f4c6 9782
718e3744 9783/* Show BGP peer's summary information. */
94f2b392 9784static int
b05a1c8b 9785bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi,
9f689658 9786 u_char use_json, json_object *json)
718e3744 9787{
9788 struct peer *peer;
1eb8ef25 9789 struct listnode *node, *nnode;
f14e6fdb
DS
9790 unsigned int count = 0, dn_count = 0;
9791 char timebuf[BGP_UPTIME_LEN], dn_flag[2];
718e3744 9792 int len;
ffd0c037
DS
9793 json_object *json_peer = NULL;
9794 json_object *json_peers = NULL;
718e3744 9795
9796 /* Header string for each address family. */
9797 static char header[] = "Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd";
47fc97cc 9798
b05a1c8b
DS
9799 if (use_json)
9800 {
9f689658
DD
9801 if (json == NULL)
9802 json = json_object_new_object();
9803
f1aa5d8a 9804 json_peers = json_object_new_object();
b05a1c8b
DS
9805 }
9806
1eb8ef25 9807 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
718e3744 9808 {
1ff9a340
DS
9809 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
9810 continue;
9811
718e3744 9812 if (peer->afc[afi][safi])
9813 {
b05a1c8b 9814 if (!count)
4bf6a362
PJ
9815 {
9816 unsigned long ents;
9817 char memstrbuf[MTYPE_MEMSTR_LEN];
5c81a5f3 9818 int vrf_id_ui;
9819
9820 vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id;
b05a1c8b 9821
4bf6a362 9822 /* Usage summary and header */
b05a1c8b
DS
9823 if (use_json)
9824 {
62d6dca0 9825 json_object_string_add(json, "routerId", inet_ntoa (bgp->router_id));
f1aa5d8a 9826 json_object_int_add(json, "as", bgp->as);
9f689658
DD
9827 json_object_int_add(json, "vrfId", vrf_id_ui);
9828 json_object_string_add(json, "vrfName",
9829 (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
9830 ? "Default" : bgp->name);
b05a1c8b
DS
9831 }
9832 else
9833 {
9834 vty_out (vty,
5c81a5f3 9835 "BGP router identifier %s, local AS number %u vrf-id %d",
9836 inet_ntoa (bgp->router_id), bgp->as, vrf_id_ui);
6aeb9e78 9837 vty_out (vty, "%s", VTY_NEWLINE);
b05a1c8b
DS
9838 }
9839
f188f2c4
DS
9840 if (bgp_update_delay_configured(bgp))
9841 {
b05a1c8b 9842 if (use_json)
f188f2c4 9843 {
62d6dca0 9844 json_object_int_add(json, "updateDelayLimit", bgp->v_update_delay);
b05a1c8b
DS
9845
9846 if (bgp->v_update_delay != bgp->v_establish_wait)
62d6dca0 9847 json_object_int_add(json, "updateDelayEstablishWait", bgp->v_establish_wait);
b05a1c8b
DS
9848
9849 if (bgp_update_delay_active(bgp))
9850 {
62d6dca0
DS
9851 json_object_string_add(json, "updateDelayFirstNeighbor", bgp->update_delay_begin_time);
9852 json_object_boolean_true_add(json, "updateDelayInProgress");
b05a1c8b
DS
9853 }
9854 else
9855 {
9856 if (bgp->update_delay_over)
9857 {
62d6dca0 9858 json_object_string_add(json, "updateDelayFirstNeighbor",
f1aa5d8a 9859 bgp->update_delay_begin_time);
62d6dca0 9860 json_object_string_add(json, "updateDelayBestpathResumed",
f1aa5d8a 9861 bgp->update_delay_end_time);
62d6dca0 9862 json_object_string_add(json, "updateDelayZebraUpdateResume",
f1aa5d8a 9863 bgp->update_delay_zebra_resume_time);
62d6dca0 9864 json_object_string_add(json, "updateDelayPeerUpdateResume",
f1aa5d8a 9865 bgp->update_delay_peers_resume_time);
b05a1c8b
DS
9866 }
9867 }
f188f2c4
DS
9868 }
9869 else
9870 {
b05a1c8b
DS
9871 vty_out (vty, "Read-only mode update-delay limit: %d seconds%s",
9872 bgp->v_update_delay, VTY_NEWLINE);
9873 if (bgp->v_update_delay != bgp->v_establish_wait)
9874 vty_out (vty, " Establish wait: %d seconds%s",
9875 bgp->v_establish_wait, VTY_NEWLINE);
9876
9877 if (bgp_update_delay_active(bgp))
f188f2c4
DS
9878 {
9879 vty_out (vty, " First neighbor established: %s%s",
9880 bgp->update_delay_begin_time, VTY_NEWLINE);
b05a1c8b
DS
9881 vty_out (vty, " Delay in progress%s", VTY_NEWLINE);
9882 }
9883 else
9884 {
9885 if (bgp->update_delay_over)
9886 {
9887 vty_out (vty, " First neighbor established: %s%s",
9888 bgp->update_delay_begin_time, VTY_NEWLINE);
9889 vty_out (vty, " Best-paths resumed: %s%s",
9890 bgp->update_delay_end_time, VTY_NEWLINE);
9891 vty_out (vty, " zebra update resumed: %s%s",
9892 bgp->update_delay_zebra_resume_time, VTY_NEWLINE);
9893 vty_out (vty, " peers update resumed: %s%s",
9894 bgp->update_delay_peers_resume_time, VTY_NEWLINE);
9895 }
f188f2c4
DS
9896 }
9897 }
9898 }
4bf6a362 9899
b05a1c8b
DS
9900 if (use_json)
9901 {
9902 if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active)
62d6dca0 9903 json_object_boolean_true_add(json, "maxMedOnStartup");
b05a1c8b 9904 if (bgp->v_maxmed_admin)
62d6dca0 9905 json_object_boolean_true_add(json, "maxMedAdministrative");
b05a1c8b 9906
62d6dca0 9907 json_object_int_add(json, "tableVersion", bgp_table_version(bgp->rib[afi][safi]));
b05a1c8b
DS
9908
9909 ents = bgp_table_count (bgp->rib[afi][safi]);
62d6dca0
DS
9910 json_object_int_add(json, "ribCount", ents);
9911 json_object_int_add(json, "ribMemory", ents * sizeof (struct bgp_node));
b05a1c8b
DS
9912
9913 ents = listcount (bgp->peer);
62d6dca0
DS
9914 json_object_int_add(json, "peerCount", ents);
9915 json_object_int_add(json, "peerMemory", ents * sizeof (struct peer));
b05a1c8b 9916
b05a1c8b
DS
9917 if ((ents = listcount (bgp->group)))
9918 {
62d6dca0
DS
9919 json_object_int_add(json, "peerGroupCount", ents);
9920 json_object_int_add(json, "peerGroupMemory", ents * sizeof (struct peer_group));
b05a1c8b 9921 }
3f9c7369 9922
b05a1c8b 9923 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
62d6dca0 9924 json_object_boolean_true_add(json, "dampeningEnabled");
b05a1c8b
DS
9925 }
9926 else
9927 {
9928 if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active)
9929 vty_out (vty, "Max-med on-startup active%s", VTY_NEWLINE);
9930 if (bgp->v_maxmed_admin)
9931 vty_out (vty, "Max-med administrative active%s", VTY_NEWLINE);
9932
ffd0c037 9933 vty_out(vty, "BGP table version %" PRIu64 "%s",
b05a1c8b
DS
9934 bgp_table_version(bgp->rib[afi][safi]), VTY_NEWLINE);
9935
9936 ents = bgp_table_count (bgp->rib[afi][safi]);
9937 vty_out (vty, "RIB entries %ld, using %s of memory%s", ents,
9938 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9939 ents * sizeof (struct bgp_node)),
9940 VTY_NEWLINE);
9941
9942 /* Peer related usage */
9943 ents = listcount (bgp->peer);
9944 vty_out (vty, "Peers %ld, using %s of memory%s",
9945 ents,
9946 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9947 ents * sizeof (struct peer)),
9948 VTY_NEWLINE);
9949
b05a1c8b
DS
9950 if ((ents = listcount (bgp->group)))
9951 vty_out (vty, "Peer groups %ld, using %s of memory%s", ents,
9952 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9953 ents * sizeof (struct peer_group)),
9954 VTY_NEWLINE);
9955
9956 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
9957 vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE);
9958 vty_out (vty, "%s", VTY_NEWLINE);
9959 vty_out (vty, "%s%s", header, VTY_NEWLINE);
9960 }
4bf6a362
PJ
9961 }
9962
b05a1c8b 9963 count++;
718e3744 9964
b05a1c8b
DS
9965 if (use_json)
9966 {
9967 json_peer = json_object_new_object();
f14e6fdb 9968
b05a1c8b 9969 if (peer_dynamic_neighbor(peer))
62d6dca0 9970 json_object_boolean_true_add(json_peer, "dynamicPeer");
b05a1c8b 9971
04b6bdc0
DW
9972 if (peer->hostname)
9973 json_object_string_add(json_peer, "hostname", peer->hostname);
9974
9975 if (peer->domainname)
9976 json_object_string_add(json_peer, "domainname", peer->domainname);
9977
62d6dca0 9978 json_object_int_add(json_peer, "remoteAs", peer->as);
f1aa5d8a 9979 json_object_int_add(json_peer, "version", 4);
62d6dca0 9980 json_object_int_add(json_peer, "msgRcvd",
f1aa5d8a
DS
9981 peer->open_in + peer->update_in + peer->keepalive_in
9982 + peer->notify_in + peer->refresh_in
9983 + peer->dynamic_cap_in);
62d6dca0 9984 json_object_int_add(json_peer, "msgSent",
f1aa5d8a
DS
9985 peer->open_out + peer->update_out + peer->keepalive_out
9986 + peer->notify_out + peer->refresh_out
9987 + peer->dynamic_cap_out);
9988
62d6dca0 9989 json_object_int_add(json_peer, "tableVersion", peer->version[afi][safi]);
f1aa5d8a
DS
9990 json_object_int_add(json_peer, "outq", peer->obuf->count);
9991 json_object_int_add(json_peer, "inq", 0);
856ca177 9992 peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, use_json, json_peer);
62d6dca0 9993 json_object_int_add(json_peer, "prefixReceivedCount", peer->pcount[afi][safi]);
b05a1c8b
DS
9994
9995 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
f1aa5d8a 9996 json_object_string_add(json_peer, "state", "Idle (Admin)");
b05a1c8b 9997 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
f1aa5d8a 9998 json_object_string_add(json_peer, "state", "Idle (PfxCt)");
b05a1c8b 9999 else
f1aa5d8a 10000 json_object_string_add(json_peer, "state", LOOKUP(bgp_status_msg, peer->status));
b05a1c8b 10001
f1aa5d8a 10002 if (peer->conf_if)
62d6dca0 10003 json_object_string_add(json_peer, "idType", "interface");
f1aa5d8a 10004 else if (peer->su.sa.sa_family == AF_INET)
62d6dca0 10005 json_object_string_add(json_peer, "idType", "ipv4");
f1aa5d8a 10006 else if (peer->su.sa.sa_family == AF_INET6)
62d6dca0 10007 json_object_string_add(json_peer, "idType", "ipv6");
b05a1c8b 10008
f1aa5d8a 10009 json_object_object_add(json_peers, peer->host, json_peer);
b05a1c8b
DS
10010 }
10011 else
10012 {
10013 memset(dn_flag, '\0', sizeof(dn_flag));
10014 if (peer_dynamic_neighbor(peer))
10015 {
10016 dn_count++;
10017 dn_flag[0] = '*';
10018 }
10019
04b6bdc0
DW
10020 if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME))
10021 len = vty_out (vty, "%s%s(%s)", dn_flag, peer->hostname,
10022 peer->host);
10023 else
10024 len = vty_out (vty, "%s%s", dn_flag, peer->host);
b05a1c8b
DS
10025 len = 16 - len;
10026
10027 if (len < 1)
10028 vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
10029 else
10030 vty_out (vty, "%*s", len, " ");
10031
10032 vty_out (vty, "4 ");
10033
ee046671 10034 vty_out (vty, "%5u %7d %7d %8" PRIu64 " %4d %4zd ",
b05a1c8b
DS
10035 peer->as,
10036 peer->open_in + peer->update_in + peer->keepalive_in
10037 + peer->notify_in + peer->refresh_in
10038 + peer->dynamic_cap_in,
10039 peer->open_out + peer->update_out + peer->keepalive_out
10040 + peer->notify_out + peer->refresh_out
10041 + peer->dynamic_cap_out,
10042 peer->version[afi][safi],
10043 0,
ffd0c037 10044 peer->obuf->count);
b05a1c8b 10045
f1aa5d8a 10046 vty_out (vty, "%-8s",
856ca177 10047 peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL));
b05a1c8b
DS
10048
10049 if (peer->status == Established)
10050 vty_out (vty, " %8ld", peer->pcount[afi][safi]);
10051 else
10052 {
10053 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
10054 vty_out (vty, " Idle (Admin)");
10055 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
10056 vty_out (vty, " Idle (PfxCt)");
10057 else
10058 vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, peer->status));
10059 }
10060 vty_out (vty, "%s", VTY_NEWLINE);
10061 }
718e3744 10062 }
10063 }
10064
b05a1c8b
DS
10065 if (use_json)
10066 {
10067 json_object_object_add(json, "peers", json_peers);
14151a32 10068
62d6dca0
DS
10069 json_object_int_add(json, "totalPeers", count);
10070 json_object_int_add(json, "dynamicPeers", dn_count);
14151a32 10071
b05a1c8b 10072 vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
f1aa5d8a 10073 json_object_free(json);
b05a1c8b
DS
10074 }
10075 else
f14e6fdb 10076 {
b05a1c8b
DS
10077 if (count)
10078 vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE,
10079 count, VTY_NEWLINE);
10080 else
9f689658
DD
10081 {
10082 if (use_json)
10083 vty_out(vty, "{\"error\": {\"message\": \"No %s neighbor configured\"}}%s",
10084 afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
10085 else
10086 vty_out (vty, "No %s neighbor is configured%s",
10087 afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
10088 }
b05a1c8b 10089
9f689658 10090 if (dn_count && ! use_json)
b05a1c8b
DS
10091 {
10092 vty_out(vty, "* - dynamic neighbor%s", VTY_NEWLINE);
10093 vty_out(vty,
10094 "%d dynamic neighbor(s), limit %d%s",
10095 dn_count, bgp->dynamic_neighbors_limit, VTY_NEWLINE);
10096 }
f14e6fdb
DS
10097 }
10098
718e3744 10099 return CMD_SUCCESS;
10100}
10101
47fc97cc
DS
10102static int
10103bgp_show_summary_vty (struct vty *vty, const char *name,
b05a1c8b 10104 afi_t afi, safi_t safi, u_char use_json)
718e3744 10105{
10106 struct bgp *bgp;
10107
10108 if (name)
10109 {
10110 bgp = bgp_lookup_by_name (name);
47fc97cc 10111
718e3744 10112 if (! bgp)
10113 {
47fc97cc 10114 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
718e3744 10115 return CMD_WARNING;
10116 }
10117
9f689658 10118 bgp_show_summary (vty, bgp, afi, safi, use_json, NULL);
718e3744 10119 return CMD_SUCCESS;
10120 }
47fc97cc 10121
718e3744 10122 bgp = bgp_get_default ();
10123
10124 if (bgp)
9f689658 10125 bgp_show_summary (vty, bgp, afi, safi, use_json, NULL);
47fc97cc 10126
718e3744 10127 return CMD_SUCCESS;
10128}
10129
f186de26 10130static void
10131bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi,
10132 u_char use_json)
10133{
10134 struct listnode *node, *nnode;
10135 struct bgp *bgp;
9f689658
DD
10136 json_object *json = NULL;
10137 int is_first = 1;
10138
10139 if (use_json)
10140 vty_out (vty, "{%s", VTY_NEWLINE);
f186de26 10141
10142 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
10143 {
9f689658
DD
10144 if (use_json)
10145 {
10146 if (!(json = json_object_new_object()))
10147 {
10148 zlog_err("Unable to allocate memory for JSON object");
10149 vty_out (vty,
10150 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s",
10151 VTY_NEWLINE);
10152 return;
10153 }
10154
10155 if (! is_first)
10156 vty_out (vty, ",%s", VTY_NEWLINE);
10157 else
10158 is_first = 0;
10159
10160 vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
10161 ? "Default" : bgp->name);
10162 }
10163 else
10164 {
10165 vty_out (vty, "%sInstance %s:%s",
10166 VTY_NEWLINE,
10167 (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
10168 ? "Default" : bgp->name, VTY_NEWLINE);
10169 }
10170 bgp_show_summary (vty, bgp, afi, safi, use_json, json);
f186de26 10171 }
9f689658
DD
10172
10173 if (use_json)
10174 vty_out (vty, "}%s", VTY_NEWLINE);
10175
f186de26 10176}
10177
718e3744 10178/* `show ip bgp summary' commands. */
47fc97cc 10179DEFUN (show_ip_bgp_summary,
718e3744 10180 show_ip_bgp_summary_cmd,
b05a1c8b 10181 "show ip bgp summary {json}",
47fc97cc
DS
10182 SHOW_STR
10183 IP_STR
10184 BGP_STR
b05a1c8b
DS
10185 "Summary of BGP neighbor status\n"
10186 "JavaScript Object Notation\n")
47fc97cc 10187{
db7c8528
DS
10188 u_char uj = use_json(argc, argv);
10189 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST, uj);
718e3744 10190}
10191
10192DEFUN (show_ip_bgp_instance_summary,
10193 show_ip_bgp_instance_summary_cmd,
8386ac43 10194 "show ip bgp " BGP_INSTANCE_CMD " summary {json}",
718e3744 10195 SHOW_STR
10196 IP_STR
10197 BGP_STR
8386ac43 10198 BGP_INSTANCE_HELP_STR
b05a1c8b
DS
10199 "Summary of BGP neighbor status\n"
10200 "JavaScript Object Notation\n")
718e3744 10201{
db7c8528 10202 u_char uj = use_json(argc, argv);
6aeb9e78 10203 return bgp_show_summary_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, uj);
718e3744 10204}
10205
f186de26 10206DEFUN (show_ip_bgp_instance_all_summary,
10207 show_ip_bgp_instance_all_summary_cmd,
10208 "show ip bgp " BGP_INSTANCE_ALL_CMD " summary {json}",
10209 SHOW_STR
10210 IP_STR
10211 BGP_STR
10212 BGP_INSTANCE_ALL_HELP_STR
10213 "Summary of BGP neighbor status\n"
10214 "JavaScript Object Notation\n")
10215{
10216 u_char uj = use_json(argc, argv);
10217
10218 bgp_show_all_instances_summary_vty (vty, AFI_IP, SAFI_UNICAST, uj);
10219 return CMD_SUCCESS;
10220}
10221
718e3744 10222DEFUN (show_ip_bgp_ipv4_summary,
10223 show_ip_bgp_ipv4_summary_cmd,
b05a1c8b 10224 "show ip bgp ipv4 (unicast|multicast) summary {json}",
718e3744 10225 SHOW_STR
10226 IP_STR
10227 BGP_STR
10228 "Address family\n"
10229 "Address Family modifier\n"
10230 "Address Family modifier\n"
b05a1c8b
DS
10231 "Summary of BGP neighbor status\n"
10232 "JavaScript Object Notation\n")
718e3744 10233{
db7c8528 10234 u_char uj = use_json(argc, argv);
718e3744 10235 if (strncmp (argv[0], "m", 1) == 0)
db7c8528 10236 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, uj);
718e3744 10237
db7c8528 10238 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST, uj);
718e3744 10239}
10240
95cbbd2a
ML
10241ALIAS (show_ip_bgp_ipv4_summary,
10242 show_bgp_ipv4_safi_summary_cmd,
b05a1c8b 10243 "show bgp ipv4 (unicast|multicast) summary {json}",
95cbbd2a
ML
10244 SHOW_STR
10245 BGP_STR
10246 "Address family\n"
10247 "Address Family modifier\n"
10248 "Address Family modifier\n"
10249 "Summary of BGP neighbor status\n")
10250
718e3744 10251DEFUN (show_ip_bgp_instance_ipv4_summary,
10252 show_ip_bgp_instance_ipv4_summary_cmd,
b05a1c8b 10253 "show ip bgp view WORD ipv4 (unicast|multicast) summary {json}",
718e3744 10254 SHOW_STR
10255 IP_STR
10256 BGP_STR
10257 "BGP view\n"
10258 "View name\n"
10259 "Address family\n"
10260 "Address Family modifier\n"
10261 "Address Family modifier\n"
b05a1c8b
DS
10262 "Summary of BGP neighbor status\n"
10263 "JavaScript Object Notation\n")
718e3744 10264{
db7c8528 10265 u_char uj = use_json(argc, argv);
718e3744 10266 if (strncmp (argv[1], "m", 1) == 0)
db7c8528 10267 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, uj);
718e3744 10268 else
db7c8528 10269 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, uj);
718e3744 10270}
10271
95cbbd2a
ML
10272ALIAS (show_ip_bgp_instance_ipv4_summary,
10273 show_bgp_instance_ipv4_safi_summary_cmd,
b05a1c8b 10274 "show bgp view WORD ipv4 (unicast|multicast) summary {json}",
95cbbd2a
ML
10275 SHOW_STR
10276 BGP_STR
10277 "BGP view\n"
10278 "View name\n"
10279 "Address family\n"
10280 "Address Family modifier\n"
10281 "Address Family modifier\n"
10282 "Summary of BGP neighbor status\n")
10283
718e3744 10284DEFUN (show_ip_bgp_vpnv4_all_summary,
10285 show_ip_bgp_vpnv4_all_summary_cmd,
b05a1c8b 10286 "show ip bgp vpnv4 all summary {json}",
718e3744 10287 SHOW_STR
10288 IP_STR
10289 BGP_STR
10290 "Display VPNv4 NLRI specific information\n"
10291 "Display information about all VPNv4 NLRIs\n"
b05a1c8b
DS
10292 "Summary of BGP neighbor status\n"
10293 "JavaScript Object Notation\n")
718e3744 10294{
db7c8528
DS
10295 u_char uj = use_json(argc, argv);
10296 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, uj);
718e3744 10297}
10298
10299DEFUN (show_ip_bgp_vpnv4_rd_summary,
10300 show_ip_bgp_vpnv4_rd_summary_cmd,
b05a1c8b 10301 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn summary {json}",
718e3744 10302 SHOW_STR
10303 IP_STR
10304 BGP_STR
10305 "Display VPNv4 NLRI specific information\n"
10306 "Display information for a route distinguisher\n"
10307 "VPN Route Distinguisher\n"
b05a1c8b
DS
10308 "Summary of BGP neighbor status\n"
10309 "JavaScript Object Notation\n")
718e3744 10310{
10311 int ret;
10312 struct prefix_rd prd;
db7c8528 10313 u_char uj = use_json(argc, argv);
718e3744 10314
10315 ret = str2prefix_rd (argv[0], &prd);
10316 if (! ret)
10317 {
10318 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
10319 return CMD_WARNING;
10320 }
10321
db7c8528 10322 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, uj);
718e3744 10323}
10324
10325#ifdef HAVE_IPV6
47fc97cc 10326DEFUN (show_bgp_summary,
718e3744 10327 show_bgp_summary_cmd,
b05a1c8b 10328 "show bgp summary {json}",
718e3744 10329 SHOW_STR
10330 BGP_STR
b05a1c8b
DS
10331 "Summary of BGP neighbor status\n"
10332 "JavaScript Object Notation\n")
718e3744 10333{
db7c8528 10334 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, use_json(argc, argv));
718e3744 10335}
10336
10337DEFUN (show_bgp_instance_summary,
10338 show_bgp_instance_summary_cmd,
8386ac43 10339 "show bgp " BGP_INSTANCE_CMD " summary {json}",
718e3744 10340 SHOW_STR
10341 BGP_STR
8386ac43 10342 BGP_INSTANCE_HELP_STR
b05a1c8b
DS
10343 "Summary of BGP neighbor status\n"
10344 "JavaScript Object Notation\n")
718e3744 10345{
6aeb9e78 10346 return bgp_show_summary_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, use_json(argc, argv));
718e3744 10347}
10348
f186de26 10349DEFUN (show_bgp_instance_all_summary,
10350 show_bgp_instance_all_summary_cmd,
10351 "show bgp " BGP_INSTANCE_ALL_CMD " summary {json}",
10352 SHOW_STR
10353 BGP_STR
10354 BGP_INSTANCE_ALL_HELP_STR
10355 "Summary of BGP neighbor status\n"
10356 "JavaScript Object Notation\n")
10357{
10358 u_char uj = use_json(argc, argv);
10359
10360 bgp_show_all_instances_summary_vty (vty, AFI_IP6, SAFI_UNICAST, uj);
10361 return CMD_SUCCESS;
10362}
10363
718e3744 10364ALIAS (show_bgp_summary,
10365 show_bgp_ipv6_summary_cmd,
b05a1c8b 10366 "show bgp ipv6 summary {json}",
718e3744 10367 SHOW_STR
10368 BGP_STR
10369 "Address family\n"
10370 "Summary of BGP neighbor status\n")
10371
10372ALIAS (show_bgp_instance_summary,
10373 show_bgp_instance_ipv6_summary_cmd,
8386ac43 10374 "show bgp " BGP_INSTANCE_CMD " ipv6 summary {json}",
718e3744 10375 SHOW_STR
10376 BGP_STR
8386ac43 10377 BGP_INSTANCE_HELP_STR
718e3744 10378 "Address family\n"
10379 "Summary of BGP neighbor status\n")
10380
95cbbd2a
ML
10381DEFUN (show_bgp_ipv6_safi_summary,
10382 show_bgp_ipv6_safi_summary_cmd,
b05a1c8b 10383 "show bgp ipv6 (unicast|multicast) summary {json}",
95cbbd2a
ML
10384 SHOW_STR
10385 BGP_STR
10386 "Address family\n"
10387 "Address Family modifier\n"
10388 "Address Family modifier\n"
b05a1c8b
DS
10389 "Summary of BGP neighbor status\n"
10390 "JavaScript Object Notation\n")
95cbbd2a 10391{
db7c8528 10392 u_char uj = use_json(argc, argv);
95cbbd2a 10393 if (strncmp (argv[0], "m", 1) == 0)
db7c8528 10394 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST, uj);
95cbbd2a 10395
db7c8528 10396 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, uj);
95cbbd2a
ML
10397}
10398
10399DEFUN (show_bgp_instance_ipv6_safi_summary,
10400 show_bgp_instance_ipv6_safi_summary_cmd,
8386ac43 10401 "show bgp " BGP_INSTANCE_CMD " ipv6 (unicast|multicast) summary {json}",
95cbbd2a
ML
10402 SHOW_STR
10403 BGP_STR
8386ac43 10404 BGP_INSTANCE_HELP_STR
95cbbd2a
ML
10405 "Address family\n"
10406 "Address Family modifier\n"
10407 "Address Family modifier\n"
b05a1c8b
DS
10408 "Summary of BGP neighbor status\n"
10409 "JavaScript Object Notation\n")
95cbbd2a 10410{
db7c8528 10411 u_char uj = use_json(argc, argv);
6aeb9e78
DS
10412 if (strncmp (argv[2], "m", 1) == 0)
10413 return bgp_show_summary_vty (vty, argv[1], AFI_IP6, SAFI_MULTICAST, uj);
95cbbd2a 10414
6aeb9e78 10415 return bgp_show_summary_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, uj);
95cbbd2a
ML
10416}
10417
718e3744 10418/* old command */
10419DEFUN (show_ipv6_bgp_summary,
10420 show_ipv6_bgp_summary_cmd,
b05a1c8b 10421 "show ipv6 bgp summary {json}",
718e3744 10422 SHOW_STR
10423 IPV6_STR
10424 BGP_STR
b05a1c8b
DS
10425 "Summary of BGP neighbor status\n"
10426 "JavaScript Object Notation\n")
718e3744 10427{
db7c8528
DS
10428 u_char uj = use_json(argc, argv);
10429 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, uj);
718e3744 10430}
10431
10432/* old command */
10433DEFUN (show_ipv6_mbgp_summary,
10434 show_ipv6_mbgp_summary_cmd,
b05a1c8b 10435 "show ipv6 mbgp summary {json}",
718e3744 10436 SHOW_STR
10437 IPV6_STR
10438 MBGP_STR
b05a1c8b
DS
10439 "Summary of BGP neighbor status\n"
10440 "JavaScript Object Notation\n")
718e3744 10441{
db7c8528
DS
10442 u_char uj = use_json(argc, argv);
10443 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST, uj);
718e3744 10444}
10445#endif /* HAVE_IPV6 */
6b0655a2 10446
fd79ac91 10447const char *
538621f2 10448afi_safi_print (afi_t afi, safi_t safi)
10449{
10450 if (afi == AFI_IP && safi == SAFI_UNICAST)
10451 return "IPv4 Unicast";
10452 else if (afi == AFI_IP && safi == SAFI_MULTICAST)
10453 return "IPv4 Multicast";
10454 else if (afi == AFI_IP && safi == SAFI_MPLS_VPN)
10455 return "VPNv4 Unicast";
10456 else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
10457 return "IPv6 Unicast";
10458 else if (afi == AFI_IP6 && safi == SAFI_MULTICAST)
10459 return "IPv6 Multicast";
10460 else
10461 return "Unknown";
10462}
10463
718e3744 10464/* Show BGP peer's information. */
10465enum show_type
10466{
10467 show_all,
10468 show_peer
10469};
10470
94f2b392 10471static void
856ca177
MS
10472bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p, afi_t afi, safi_t safi,
10473 u_int16_t adv_smcap, u_int16_t adv_rmcap, u_int16_t rcv_smcap,
10474 u_int16_t rcv_rmcap, u_char use_json, json_object *json_pref)
718e3744 10475{
10476 /* Send-Mode */
10477 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)
10478 || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
10479 {
856ca177
MS
10480 if (use_json)
10481 {
10482 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
10483 json_object_string_add(json_pref, "sendMode", "advertisedAndReceived");
10484 else if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
10485 json_object_string_add(json_pref, "sendMode", "advertised");
10486 else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
10487 json_object_string_add(json_pref, "sendMode", "received");
10488 }
10489 else
10490 {
10491 vty_out (vty, " Send-mode: ");
10492 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
10493 vty_out (vty, "advertised");
10494 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
10495 vty_out (vty, "%sreceived",
10496 CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ?
10497 ", " : "");
10498 vty_out (vty, "%s", VTY_NEWLINE);
10499 }
718e3744 10500 }
10501
10502 /* Receive-Mode */
10503 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)
10504 || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
10505 {
856ca177
MS
10506 if (use_json)
10507 {
10508 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
10509 json_object_string_add(json_pref, "recvMode", "advertisedAndReceived");
10510 else if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
10511 json_object_string_add(json_pref, "recvMode", "advertised");
10512 else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
10513 json_object_string_add(json_pref, "recvMode", "received");
10514 }
10515 else
10516 {
10517 vty_out (vty, " Receive-mode: ");
10518 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
10519 vty_out (vty, "advertised");
10520 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
10521 vty_out (vty, "%sreceived",
10522 CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ?
10523 ", " : "");
10524 vty_out (vty, "%s", VTY_NEWLINE);
10525 }
718e3744 10526 }
10527}
10528
94f2b392 10529static void
856ca177
MS
10530bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi,
10531 u_char use_json, json_object *json_neigh)
718e3744 10532{
10533 struct bgp_filter *filter;
3f9c7369 10534 struct peer_af *paf;
718e3744 10535 char orf_pfx_name[BUFSIZ];
10536 int orf_pfx_count;
856ca177
MS
10537 json_object *json_af = NULL;
10538 json_object *json_prefA = NULL;
10539 json_object *json_prefB = NULL;
10540 json_object *json_addr = NULL;
718e3744 10541
856ca177
MS
10542 if (use_json)
10543 {
10544 json_addr = json_object_new_object();
10545 json_af = json_object_new_object();
10546 json_prefA = json_object_new_object();
10547 json_prefB = json_object_new_object();
10548 filter = &p->filter[afi][safi];
718e3744 10549
c8560b44 10550 if (peer_group_active(p))
856ca177 10551 json_object_string_add(json_addr, "peerGroupMember", p->group->name);
538621f2 10552
856ca177
MS
10553 paf = peer_af_find(p, afi, safi);
10554 if (paf && PAF_SUBGRP(paf))
10555 {
10556 json_object_int_add(json_addr, "updateGroupId", PAF_UPDGRP(paf)->id);
10557 json_object_int_add(json_addr, "subGroupId", PAF_SUBGRP(paf)->id);
10558 json_object_int_add(json_addr, "packetQueueLength", bpacket_queue_virtual_length(paf));
10559 }
10560
10561 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
10562 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
10563 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
10564 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
10565 {
10566 json_object_int_add(json_af, "orfType", ORF_TYPE_PREFIX);
10567 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
10568 PEER_CAP_ORF_PREFIX_SM_ADV,
10569 PEER_CAP_ORF_PREFIX_RM_ADV,
10570 PEER_CAP_ORF_PREFIX_SM_RCV,
10571 PEER_CAP_ORF_PREFIX_RM_RCV, use_json, json_prefA);
10572 json_object_object_add(json_af, "orfPrefixList", json_prefA);
10573 }
10574
10575 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
10576 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
10577 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
10578 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
10579 {
10580 json_object_int_add(json_af, "orfOldType", ORF_TYPE_PREFIX_OLD);
10581 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
10582 PEER_CAP_ORF_PREFIX_SM_ADV,
10583 PEER_CAP_ORF_PREFIX_RM_ADV,
10584 PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
10585 PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, json_prefB);
10586 json_object_object_add(json_af, "orfOldPrefixList", json_prefB);
10587 }
10588
10589 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
10590 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
10591 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
10592 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
10593 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
10594 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
10595 json_object_object_add(json_addr, "afDependentCap", json_af);
10596
10597 sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
10598 orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json);
10599
10600 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
10601 || orf_pfx_count)
10602 {
10603 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
10604 json_object_boolean_true_add(json_neigh, "orfSent");
10605 if (orf_pfx_count)
10606 json_object_int_add(json_addr, "orfRecvCounter", orf_pfx_count);
10607 }
10608 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
10609 json_object_string_add(json_addr, "orfFirstUpdate", "deferredUntilORFOrRouteRefreshRecvd");
10610
10611 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
10612 json_object_boolean_true_add(json_addr, "routeReflectorClient");
10613 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
10614 json_object_boolean_true_add(json_addr, "routeServerClient");
10615 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
10616 json_object_boolean_true_add(json_addr, "inboundSoftConfigPermit");
10617
88b8ed8d
DW
10618 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE))
10619 json_object_boolean_true_add(json_addr, "privateAsNumsAllReplacedInUpdatesToNbr");
10620 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE))
856ca177 10621 json_object_boolean_true_add(json_addr, "privateAsNumsReplacedInUpdatesToNbr");
88b8ed8d
DW
10622 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL))
10623 json_object_boolean_true_add(json_addr, "privateAsNumsAllRemovedInUpdatesToNbr");
856ca177
MS
10624 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
10625 json_object_boolean_true_add(json_addr, "privateAsNumsRemovedInUpdatesToNbr");
10626
adbac85e
DW
10627 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS))
10628 json_object_boolean_true_add(json_addr, "addpathTxAllPaths");
10629
06370dac
DW
10630 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS))
10631 json_object_boolean_true_add(json_addr, "addpathTxBestpathPerAS");
10632
856ca177
MS
10633 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE))
10634 json_object_string_add(json_addr, "overrideASNsInOutboundUpdates", "ifAspathEqualRemoteAs");
10635
10636 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) ||
10637 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF))
10638 json_object_boolean_true_add(json_addr, "routerAlwaysNextHop");
10639 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
10640 json_object_boolean_true_add(json_addr, "unchangedAsPathPropogatedToNbr");
10641 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
10642 json_object_boolean_true_add(json_addr, "unchangedNextHopPropogatedToNbr");
10643 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
10644 json_object_boolean_true_add(json_addr, "unchangedMedPropogatedToNbr");
718e3744 10645 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
856ca177
MS
10646 || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
10647 {
10648 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
10649 && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
10650 json_object_string_add(json_addr, "commAttriSentToNbr", "extendedAndStandard");
10651 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
10652 json_object_string_add(json_addr, "commAttriSentToNbr", "extended");
10653 else
10654 json_object_string_add(json_addr, "commAttriSentToNbr", "standard");
10655 }
10656 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
10657 {
10658 if (p->default_rmap[afi][safi].name)
10659 json_object_string_add(json_addr, "defaultRouteMap", p->default_rmap[afi][safi].name);
10660
10661 if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE))
10662 json_object_boolean_true_add(json_addr, "defaultSent");
10663 else
10664 json_object_boolean_true_add(json_addr, "defaultNotSent");
10665 }
10666
10667 if (filter->plist[FILTER_IN].name
10668 || filter->dlist[FILTER_IN].name
10669 || filter->aslist[FILTER_IN].name
10670 || filter->map[RMAP_IN].name)
10671 json_object_boolean_true_add(json_addr, "inboundPathPolicyConfig");
10672 if (filter->plist[FILTER_OUT].name
10673 || filter->dlist[FILTER_OUT].name
10674 || filter->aslist[FILTER_OUT].name
10675 || filter->map[RMAP_OUT].name
10676 || filter->usmap.name)
10677 json_object_boolean_true_add(json_addr, "outboundPathPolicyConfig");
856ca177
MS
10678
10679 /* prefix-list */
10680 if (filter->plist[FILTER_IN].name)
10681 json_object_string_add(json_addr, "incomingUpdatePrefixFilterList", filter->plist[FILTER_IN].name);
10682 if (filter->plist[FILTER_OUT].name)
10683 json_object_string_add(json_addr, "outgoingUpdatePrefixFilterList", filter->plist[FILTER_OUT].name);
10684
10685 /* distribute-list */
10686 if (filter->dlist[FILTER_IN].name)
10687 json_object_string_add(json_addr, "incomingUpdateNetworkFilterList", filter->dlist[FILTER_IN].name);
10688 if (filter->dlist[FILTER_OUT].name)
10689 json_object_string_add(json_addr, "outgoingUpdateNetworkFilterList", filter->dlist[FILTER_OUT].name);
10690
10691 /* filter-list. */
10692 if (filter->aslist[FILTER_IN].name)
10693 json_object_string_add(json_addr, "incomingUpdateAsPathFilterList", filter->aslist[FILTER_IN].name);
10694 if (filter->aslist[FILTER_OUT].name)
10695 json_object_string_add(json_addr, "outgoingUpdateAsPathFilterList", filter->aslist[FILTER_OUT].name);
10696
10697 /* route-map. */
10698 if (filter->map[RMAP_IN].name)
10699 json_object_string_add(json_addr, "routeMapForIncomingAdvertisements", filter->map[RMAP_IN].name);
10700 if (filter->map[RMAP_OUT].name)
10701 json_object_string_add(json_addr, "routeMapForOutgoingAdvertisements", filter->map[RMAP_OUT].name);
856ca177
MS
10702
10703 /* unsuppress-map */
10704 if (filter->usmap.name)
10705 json_object_string_add(json_addr, "selectiveUnsuppressRouteMap", filter->usmap.name);
10706
10707 /* Receive prefix count */
10708 json_object_int_add(json_addr, "acceptedPrefixCounter", p->pcount[afi][safi]);
10709
10710 /* Maximum prefix */
10711 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
10712 {
10713 json_object_int_add(json_addr, "prefixAllowedMax", p->pmax[afi][safi]);
10714 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING))
10715 json_object_boolean_true_add(json_addr, "prefixAllowedMaxWarning");
10716 json_object_int_add(json_addr, "prefixAllowedWarningThresh", p->pmax_threshold[afi][safi]);
10717 if (p->pmax_restart[afi][safi])
10718 json_object_int_add(json_addr, "prefixAllowedRestartIntervalMsecs", p->pmax_restart[afi][safi] * 60000);
10719 }
10720 json_object_object_add(json_neigh, afi_safi_print (afi, safi), json_addr);
10721
10722 }
10723 else
10724 {
10725 filter = &p->filter[afi][safi];
10726
10727 vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi),
10728 VTY_NEWLINE);
10729
c8560b44 10730 if (peer_group_active(p))
856ca177
MS
10731 vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE);
10732
10733 paf = peer_af_find(p, afi, safi);
10734 if (paf && PAF_SUBGRP(paf))
10735 {
10736 vty_out (vty, " Update group %" PRIu64 ", subgroup %" PRIu64 "%s",
10737 PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id, VTY_NEWLINE);
10738 vty_out (vty, " Packet Queue length %d%s",
10739 bpacket_queue_virtual_length(paf), VTY_NEWLINE);
10740 }
718e3744 10741 else
856ca177
MS
10742 {
10743 vty_out(vty, " Not part of any update group%s", VTY_NEWLINE);
10744 }
10745 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
10746 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
10747 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
10748 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
10749 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
10750 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
10751 vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE);
10752
10753 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
10754 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
10755 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
10756 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
10757 {
10758 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
10759 ORF_TYPE_PREFIX, VTY_NEWLINE);
10760 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
10761 PEER_CAP_ORF_PREFIX_SM_ADV,
10762 PEER_CAP_ORF_PREFIX_RM_ADV,
10763 PEER_CAP_ORF_PREFIX_SM_RCV,
10764 PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL);
10765 }
10766 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
10767 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
10768 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
10769 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
10770 {
10771 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
10772 ORF_TYPE_PREFIX_OLD, VTY_NEWLINE);
10773 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
10774 PEER_CAP_ORF_PREFIX_SM_ADV,
10775 PEER_CAP_ORF_PREFIX_RM_ADV,
10776 PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
10777 PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL);
10778 }
718e3744 10779
856ca177
MS
10780 sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
10781 orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json);
718e3744 10782
856ca177
MS
10783 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
10784 || orf_pfx_count)
10785 {
10786 vty_out (vty, " Outbound Route Filter (ORF):");
10787 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
10788 vty_out (vty, " sent;");
10789 if (orf_pfx_count)
10790 vty_out (vty, " received (%d entries)", orf_pfx_count);
10791 vty_out (vty, "%s", VTY_NEWLINE);
10792 }
10793 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
10794 vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE);
10795
10796 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
10797 vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE);
10798 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
10799 vty_out (vty, " Route-Server Client%s", VTY_NEWLINE);
10800 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
10801 vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE);
10802
88b8ed8d
DW
10803 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE))
10804 vty_out (vty, " Private AS numbers (all) replaced in updates to this neighbor%s", VTY_NEWLINE);
10805 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE))
856ca177 10806 vty_out (vty, " Private AS numbers replaced in updates to this neighbor%s", VTY_NEWLINE);
88b8ed8d
DW
10807 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL))
10808 vty_out (vty, " Private AS numbers (all) removed in updates to this neighbor%s", VTY_NEWLINE);
856ca177
MS
10809 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
10810 vty_out (vty, " Private AS numbers removed in updates to this neighbor%s", VTY_NEWLINE);
10811
adbac85e
DW
10812 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS))
10813 vty_out (vty, " Advertise all paths via addpath%s", VTY_NEWLINE);
10814
06370dac
DW
10815 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS))
10816 vty_out (vty, " Advertise bestpath per AS via addpath%s", VTY_NEWLINE);
10817
856ca177
MS
10818 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE))
10819 vty_out (vty, " Override ASNs in outbound updates if aspath equals remote-as%s", VTY_NEWLINE);
10820
10821 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) ||
10822 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF))
10823 vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE);
10824 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
10825 vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE);
10826 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
10827 vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE);
10828 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
10829 vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE);
10830 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
10831 || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
10832 {
10833 vty_out (vty, " Community attribute sent to this neighbor");
10834 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
10835 && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
10836 vty_out (vty, "(both)%s", VTY_NEWLINE);
10837 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
10838 vty_out (vty, "(extended)%s", VTY_NEWLINE);
10839 else
10840 vty_out (vty, "(standard)%s", VTY_NEWLINE);
10841 }
10842 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
10843 {
10844 vty_out (vty, " Default information originate,");
10845
10846 if (p->default_rmap[afi][safi].name)
10847 vty_out (vty, " default route-map %s%s,",
10848 p->default_rmap[afi][safi].map ? "*" : "",
10849 p->default_rmap[afi][safi].name);
10850 if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE))
10851 vty_out (vty, " default sent%s", VTY_NEWLINE);
10852 else
10853 vty_out (vty, " default not sent%s", VTY_NEWLINE);
10854 }
718e3744 10855
856ca177
MS
10856 if (filter->plist[FILTER_IN].name
10857 || filter->dlist[FILTER_IN].name
10858 || filter->aslist[FILTER_IN].name
10859 || filter->map[RMAP_IN].name)
10860 vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE);
10861 if (filter->plist[FILTER_OUT].name
10862 || filter->dlist[FILTER_OUT].name
10863 || filter->aslist[FILTER_OUT].name
10864 || filter->map[RMAP_OUT].name
10865 || filter->usmap.name)
10866 vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE);
856ca177
MS
10867
10868 /* prefix-list */
10869 if (filter->plist[FILTER_IN].name)
10870 vty_out (vty, " Incoming update prefix filter list is %s%s%s",
10871 filter->plist[FILTER_IN].plist ? "*" : "",
10872 filter->plist[FILTER_IN].name,
10873 VTY_NEWLINE);
10874 if (filter->plist[FILTER_OUT].name)
10875 vty_out (vty, " Outgoing update prefix filter list is %s%s%s",
10876 filter->plist[FILTER_OUT].plist ? "*" : "",
10877 filter->plist[FILTER_OUT].name,
10878 VTY_NEWLINE);
10879
10880 /* distribute-list */
10881 if (filter->dlist[FILTER_IN].name)
10882 vty_out (vty, " Incoming update network filter list is %s%s%s",
10883 filter->dlist[FILTER_IN].alist ? "*" : "",
10884 filter->dlist[FILTER_IN].name,
10885 VTY_NEWLINE);
10886 if (filter->dlist[FILTER_OUT].name)
10887 vty_out (vty, " Outgoing update network filter list is %s%s%s",
10888 filter->dlist[FILTER_OUT].alist ? "*" : "",
10889 filter->dlist[FILTER_OUT].name,
10890 VTY_NEWLINE);
10891
10892 /* filter-list. */
10893 if (filter->aslist[FILTER_IN].name)
10894 vty_out (vty, " Incoming update AS path filter list is %s%s%s",
10895 filter->aslist[FILTER_IN].aslist ? "*" : "",
10896 filter->aslist[FILTER_IN].name,
10897 VTY_NEWLINE);
10898 if (filter->aslist[FILTER_OUT].name)
10899 vty_out (vty, " Outgoing update AS path filter list is %s%s%s",
10900 filter->aslist[FILTER_OUT].aslist ? "*" : "",
10901 filter->aslist[FILTER_OUT].name,
10902 VTY_NEWLINE);
10903
10904 /* route-map. */
10905 if (filter->map[RMAP_IN].name)
10906 vty_out (vty, " Route map for incoming advertisements is %s%s%s",
10907 filter->map[RMAP_IN].map ? "*" : "",
10908 filter->map[RMAP_IN].name,
10909 VTY_NEWLINE);
10910 if (filter->map[RMAP_OUT].name)
10911 vty_out (vty, " Route map for outgoing advertisements is %s%s%s",
10912 filter->map[RMAP_OUT].map ? "*" : "",
10913 filter->map[RMAP_OUT].name,
10914 VTY_NEWLINE);
856ca177
MS
10915
10916 /* unsuppress-map */
10917 if (filter->usmap.name)
10918 vty_out (vty, " Route map for selective unsuppress is %s%s%s",
10919 filter->usmap.map ? "*" : "",
10920 filter->usmap.name, VTY_NEWLINE);
10921
10922 /* Receive prefix count */
10923 vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE);
10924
10925 /* Maximum prefix */
10926 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
10927 {
10928 vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi],
10929 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)
10930 ? " (warning-only)" : "", VTY_NEWLINE);
10931 vty_out (vty, " Threshold for warning message %d%%",
10932 p->pmax_threshold[afi][safi]);
10933 if (p->pmax_restart[afi][safi])
10934 vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]);
10935 vty_out (vty, "%s", VTY_NEWLINE);
10936 }
718e3744 10937
0a486e5f 10938 vty_out (vty, "%s", VTY_NEWLINE);
718e3744 10939 }
718e3744 10940}
10941
94f2b392 10942static void
856ca177 10943bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *json, json_object *json_neigh)
718e3744 10944{
10945 struct bgp *bgp;
4690c7d7 10946 char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN];
718e3744 10947 char timebuf[BGP_UPTIME_LEN];
f14e6fdb 10948 char dn_flag[2];
3a8c7ba1
DW
10949 const char *subcode_str;
10950 const char *code_str;
538621f2 10951 afi_t afi;
10952 safi_t safi;
d6661008
DS
10953 u_int16_t i;
10954 u_char *msg;
718e3744 10955
10956 bgp = p->bgp;
10957
856ca177 10958 if (!use_json)
f14e6fdb 10959 {
856ca177
MS
10960 if (p->conf_if) /* Configured interface name. */
10961 vty_out (vty, "BGP neighbor on %s: %s, ", p->conf_if,
10962 BGP_PEER_SU_UNSPEC(p) ? "None" :
10963 sockunion2str (&p->su, buf, SU_ADDRSTRLEN));
10964 else /* Configured IP address. */
10965 {
10966 memset(dn_flag, '\0', sizeof(dn_flag));
10967 if (peer_dynamic_neighbor(p))
10968 dn_flag[0] = '*';
f14e6fdb 10969
856ca177
MS
10970 vty_out (vty, "BGP neighbor is %s%s, ", dn_flag, p->host);
10971 }
f14e6fdb
DS
10972 }
10973
856ca177
MS
10974 if (use_json)
10975 {
10976 if (p->conf_if && BGP_PEER_SU_UNSPEC(p))
10977 json_object_string_add(json_neigh, "bgpNeighborAddr", "none");
10978 else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p))
10979 json_object_string_add(json_neigh, "bgpNeighborAddr", sockunion2str (&p->su, buf, SU_ADDRSTRLEN));
10980
10981 json_object_int_add(json_neigh, "remoteAs", p->as);
10982
10983 if (p->change_local_as)
10984 json_object_int_add(json_neigh, "localAs", p->change_local_as);
10985 else
10986 json_object_int_add(json_neigh, "localAs", p->local_as);
10987
10988 if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND))
10989 json_object_boolean_true_add(json_neigh, "localAsNoPrepend");
66b199b2 10990
856ca177
MS
10991 if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS))
10992 json_object_boolean_true_add(json_neigh, "localAsReplaceAs");
10993 }
10994 else
10995 {
f8cfafda
DS
10996 if ((p->as_type == AS_SPECIFIED) ||
10997 (p->as_type == AS_EXTERNAL) ||
10998 (p->as_type == AS_INTERNAL))
10999 vty_out (vty, "remote AS %u, ", p->as);
11000 else
11001 vty_out (vty, "remote AS Unspecified, ");
856ca177
MS
11002 vty_out (vty, "local AS %u%s%s, ",
11003 p->change_local_as ? p->change_local_as : p->local_as,
11004 CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ?
11005 " no-prepend" : "",
11006 CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) ?
11007 " replace-as" : "");
11008 }
66b199b2
DS
11009 /* peer type internal, external, confed-internal or confed-external */
11010 if (p->as == p->local_as)
11011 {
856ca177
MS
11012 if (use_json)
11013 {
11014 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
11015 json_object_boolean_true_add(json_neigh, "nbrConfedInternalLink");
11016 else
11017 json_object_boolean_true_add(json_neigh, "nbrInternalLink");
11018 }
66b199b2 11019 else
856ca177
MS
11020 {
11021 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
11022 vty_out (vty, "confed-internal link%s", VTY_NEWLINE);
11023 else
11024 vty_out (vty, "internal link%s", VTY_NEWLINE);
11025 }
66b199b2
DS
11026 }
11027 else
11028 {
856ca177
MS
11029 if (use_json)
11030 {
11031 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
11032 json_object_boolean_true_add(json_neigh, "nbrConfedExternalLink");
11033 else
11034 json_object_boolean_true_add(json_neigh, "nbrExternalLink");
11035 }
66b199b2 11036 else
856ca177
MS
11037 {
11038 if (bgp_confederation_peers_check(bgp, p->as))
11039 vty_out (vty, "confed-external link%s", VTY_NEWLINE);
11040 else
11041 vty_out (vty, "external link%s", VTY_NEWLINE);
11042 }
66b199b2 11043 }
718e3744 11044
11045 /* Description. */
11046 if (p->desc)
856ca177
MS
11047 {
11048 if (use_json)
11049 json_object_string_add(json_neigh, "nbrDesc", p->desc);
11050 else
11051 vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE);
11052 }
6410e93a 11053
04b6bdc0
DW
11054 if (p->hostname)
11055 {
d1570739
DW
11056 if (use_json)
11057 {
11058 if (p->hostname)
11059 json_object_string_add(json_neigh, "hostname", p->hostname);
11060
11061 if (p->domainname)
11062 json_object_string_add(json_neigh, "domainname", p->domainname);
11063 }
04b6bdc0 11064 else
d1570739
DW
11065 {
11066 if (p->domainname && (p->domainname[0] != '\0'))
11067 vty_out(vty, "Hostname: %s.%s%s", p->hostname, p->domainname,
11068 VTY_NEWLINE);
11069 else
11070 vty_out(vty, "Hostname: %s%s", p->hostname, VTY_NEWLINE);
11071 }
11072
04b6bdc0
DW
11073 }
11074
c744aa9f 11075 /* Peer-group */
718e3744 11076 if (p->group)
f14e6fdb 11077 {
856ca177
MS
11078 if (use_json)
11079 {
11080 json_object_string_add(json_neigh, "peerGroup", p->group->name);
11081
11082 if (dn_flag[0])
11083 {
11084 struct prefix *prefix = NULL, *range = NULL;
f14e6fdb 11085
856ca177
MS
11086 prefix = sockunion2hostprefix(&(p->su));
11087 if (prefix)
11088 range = peer_group_lookup_dynamic_neighbor_range (p->group, prefix);
11089
11090 if (range)
11091 {
11092 prefix2str(range, buf1, sizeof(buf1));
11093 json_object_string_add(json_neigh, "peerSubnetRangeGroup", buf1);
11094 }
11095 }
11096 }
11097 else
f14e6fdb 11098 {
856ca177
MS
11099 vty_out (vty, " Member of peer-group %s for session parameters%s",
11100 p->group->name, VTY_NEWLINE);
f14e6fdb 11101
856ca177 11102 if (dn_flag[0])
f14e6fdb 11103 {
856ca177
MS
11104 struct prefix *prefix = NULL, *range = NULL;
11105
11106 prefix = sockunion2hostprefix(&(p->su));
11107 if (prefix)
11108 range = peer_group_lookup_dynamic_neighbor_range (p->group, prefix);
11109
11110 if (range)
11111 {
11112 prefix2str(range, buf1, sizeof(buf1));
11113 vty_out (vty, " Belongs to the subnet range group: %s%s", buf1, VTY_NEWLINE);
11114 }
f14e6fdb
DS
11115 }
11116 }
11117 }
718e3744 11118
856ca177
MS
11119 if (use_json)
11120 {
11121 /* Administrative shutdown. */
11122 if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
11123 json_object_boolean_true_add(json_neigh, "adminShutDown");
718e3744 11124
856ca177
MS
11125 /* BGP Version. */
11126 json_object_int_add(json_neigh, "bgpVersion", 4);
11127 json_object_string_add(json_neigh, "remoteRouterId", inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ));
718e3744 11128
856ca177
MS
11129 /* Confederation */
11130 if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) && bgp_confederation_peers_check (bgp, p->as))
11131 json_object_boolean_true_add(json_neigh, "nbrCommonAdmin");
11132
11133 /* Status. */
11134 json_object_string_add(json_neigh, "bgpState", LOOKUP (bgp_status_msg, p->status));
11135
11136 if (p->status == Established)
11137 {
11138 time_t uptime;
11139 struct tm *tm;
11140
11141 uptime = bgp_clock();
11142 uptime -= p->uptime;
11143 tm = gmtime(&uptime);
11144
11145 json_object_int_add(json_neigh, "bgpTimerUp", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
11146 }
11147
11148 else if (p->status == Active)
11149 {
11150 if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE))
11151 json_object_string_add(json_neigh, "bgpStateIs", "passive");
11152 else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT))
11153 json_object_string_add(json_neigh, "bgpStateIs", "passiveNSF");
11154 }
11155
11156 /* read timer */
11157 time_t uptime;
11158 struct tm *tm;
11159
11160 uptime = bgp_clock();
11161 uptime -= p->readtime;
11162 tm = gmtime(&uptime);
11163 json_object_int_add(json_neigh, "bgpTimerLastRead", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
11164
11165 uptime = bgp_clock();
11166 uptime -= p->last_write;
11167 tm = gmtime(&uptime);
11168 json_object_int_add(json_neigh, "bgpTimerLastRead", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
11169
11170 /* Configured timer values. */
11171 json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", p->v_holdtime * 1000);
11172 json_object_int_add(json_neigh, "bgpTimerKeepAliveIntervalMsecs", p->v_keepalive * 1000);
11173
11174 if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
11175 {
11176 json_object_int_add(json_neigh, "bgpTimerConfiguredHoldTimeMsecs", p->holdtime * 1000);
11177 json_object_int_add(json_neigh, "bgpTimerConfiguredKeepAliveIntervalMsecs", p->keepalive * 1000);
11178 }
93406d87 11179 }
856ca177
MS
11180 else
11181 {
11182 /* Administrative shutdown. */
11183 if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
11184 vty_out (vty, " Administratively shut down%s", VTY_NEWLINE);
11185
11186 /* BGP Version. */
11187 vty_out (vty, " BGP version 4");
11188 vty_out (vty, ", remote router ID %s%s", inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ),
11189 VTY_NEWLINE);
11190
11191 /* Confederation */
11192 if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION)
11193 && bgp_confederation_peers_check (bgp, p->as))
11194 vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE);
718e3744 11195
856ca177
MS
11196 /* Status. */
11197 vty_out (vty, " BGP state = %s", LOOKUP (bgp_status_msg, p->status));
718e3744 11198
856ca177
MS
11199 if (p->status == Established)
11200 vty_out (vty, ", up for %8s", peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL));
11201
11202 else if (p->status == Active)
11203 {
11204 if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE))
11205 vty_out (vty, " (passive)");
11206 else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT))
11207 vty_out (vty, " (NSF passive)");
11208 }
11209 vty_out (vty, "%s", VTY_NEWLINE);
93406d87 11210
856ca177
MS
11211 /* read timer */
11212 vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN, 0, NULL));
11213 vty_out (vty, ", Last write %s%s",
11214 peer_uptime (p->last_write, timebuf, BGP_UPTIME_LEN, 0, NULL), VTY_NEWLINE);
11215
11216 /* Configured timer values. */
11217 vty_out (vty, " Hold time is %d, keepalive interval is %d seconds%s",
11218 p->v_holdtime, p->v_keepalive, VTY_NEWLINE);
11219 if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
11220 {
11221 vty_out (vty, " Configured hold time is %d", p->holdtime);
11222 vty_out (vty, ", keepalive interval is %d seconds%s",
11223 p->keepalive, VTY_NEWLINE);
11224 }
11225 }
718e3744 11226 /* Capability. */
11227 if (p->status == Established)
11228 {
538621f2 11229 if (p->cap
718e3744 11230 || p->afc_adv[AFI_IP][SAFI_UNICAST]
11231 || p->afc_recv[AFI_IP][SAFI_UNICAST]
11232 || p->afc_adv[AFI_IP][SAFI_MULTICAST]
11233 || p->afc_recv[AFI_IP][SAFI_MULTICAST]
11234#ifdef HAVE_IPV6
11235 || p->afc_adv[AFI_IP6][SAFI_UNICAST]
11236 || p->afc_recv[AFI_IP6][SAFI_UNICAST]
11237 || p->afc_adv[AFI_IP6][SAFI_MULTICAST]
11238 || p->afc_recv[AFI_IP6][SAFI_MULTICAST]
11239#endif /* HAVE_IPV6 */
11240 || p->afc_adv[AFI_IP][SAFI_MPLS_VPN]
11241 || p->afc_recv[AFI_IP][SAFI_MPLS_VPN])
11242 {
856ca177
MS
11243 if (use_json)
11244 {
11245 json_object *json_cap = NULL;
11246
11247 json_cap = json_object_new_object();
11248
11249 /* AS4 */
11250 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)
11251 || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
11252 {
11253 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) && CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
11254 json_object_string_add(json_cap, "4byteAs", "advertisedAndReceived");
11255 else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
11256 json_object_string_add(json_cap, "4byteAs", "advertised");
11257 else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
11258 json_object_string_add(json_cap, "4byteAs", "received");
11259 }
11260
11261 /* AddPath */
11262 if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV)
11263 || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV))
11264 {
11265 json_object *json_add = NULL;
11266 const char *print_store;
718e3744 11267
856ca177 11268 json_add = json_object_new_object();
a82478b9 11269
856ca177
MS
11270 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11271 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11272 {
11273 json_object *json_sub = NULL;
11274 json_sub = json_object_new_object();
11275 print_store = afi_safi_print (afi, safi);
11276
11277 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ||
11278 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
11279 {
11280 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) && CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
11281 json_object_boolean_true_add(json_sub, "txAdvertisedAndReceived");
11282 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV))
11283 json_object_boolean_true_add(json_sub, "txAdvertised");
11284 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
11285 json_object_boolean_true_add(json_sub, "txReceived");
11286 }
11287
11288 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
11289 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
11290 {
11291 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) && CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
11292 json_object_boolean_true_add(json_sub, "rxAdvertisedAndReceived");
11293 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV))
11294 json_object_boolean_true_add(json_sub, "rxAdvertised");
11295 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
11296 json_object_boolean_true_add(json_sub, "rxReceived");
11297 }
11298
11299 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ||
11300 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV) ||
11301 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
11302 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
11303 json_object_object_add(json_add, print_store, json_sub);
11304 }
a82478b9 11305
856ca177
MS
11306 json_object_object_add(json_cap, "addPath", json_add);
11307 }
11308
11309 /* Dynamic */
11310 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
11311 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
11312 {
11313 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) && CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
11314 json_object_string_add(json_cap, "dynamic", "advertisedAndReceived");
11315 else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
11316 json_object_string_add(json_cap, "dynamic", "advertised");
11317 else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
11318 json_object_string_add(json_cap, "dynamic", "received");
11319 }
11320
11321 /* Extended nexthop */
11322 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)
11323 || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
11324 {
11325 json_object *json_nxt = NULL;
11326 const char *print_store;
11327
11328 json_nxt = json_object_new_object();
11329
11330 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) && CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
11331 json_object_string_add(json_cap, "extendedNexthop", "advertisedAndReceived");
11332 else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
11333 json_object_string_add(json_cap, "extendedNexthop", "advertised");
11334 else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
11335 json_object_string_add(json_cap, "extendedNexthop", "received");
11336
11337 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
11338 {
11339 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11340 {
11341 if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV))
11342 {
11343 print_store = afi_safi_print (AFI_IP, safi);
11344 json_object_string_add(json_nxt, print_store, "recieved");
11345 }
11346 }
11347 json_object_object_add(json_cap, "extendedNexthopFamililesByPeer", json_nxt);
11348 }
11349 }
11350
11351 /* Route Refresh */
11352 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
11353 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
11354 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
11355 {
11356 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) && (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)))
11357 {
11358 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV))
11359 json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOldNew");
11360 else
11361 {
11362 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
11363 json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOld");
11364 else
11365 json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedNew");
11366 }
11367 }
11368 else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
11369 json_object_string_add(json_cap, "routeRefresh", "advertised");
11370 else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
11371 json_object_string_add(json_cap, "routeRefresh", "received");
11372 }
11373
11374 /* Multiprotocol Extensions */
11375 json_object *json_multi = NULL;
11376 json_multi = json_object_new_object();
11377
11378 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11379 {
11380 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11381 {
11382 if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
11383 {
11384 json_object *json_exten = NULL;
11385 json_exten = json_object_new_object();
11386
11387 if (p->afc_adv[afi][safi] && p->afc_recv[afi][safi])
11388 json_object_boolean_true_add(json_exten, "advertisedAndReceived");
11389 else if (p->afc_adv[afi][safi])
11390 json_object_boolean_true_add(json_exten, "advertised");
11391 else if (p->afc_recv[afi][safi])
11392 json_object_boolean_true_add(json_exten, "received");
11393
11394 json_object_object_add(json_multi, afi_safi_print (afi, safi), json_exten);
11395 }
11396 }
11397 }
11398 json_object_object_add(json_cap, "multiprotocolExtensions", json_multi);
11399
11400 /* Gracefull Restart */
11401 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
11402 || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
11403 {
11404 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) && CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
11405 json_object_string_add(json_cap, "gracefulRestart", "advertisedAndReceived");
11406 else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
11407 json_object_string_add(json_cap, "gracefulRestartCapability", "advertised");
11408 else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
11409 json_object_string_add(json_cap, "gracefulRestartCapability", "received");
11410
11411 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
11412 {
11413 int restart_af_count = 0;
11414 json_object *json_restart = NULL;
11415 json_restart = json_object_new_object();
11416
11417 json_object_int_add(json_cap, "gracefulRestartRemoteTimerMsecs", p->v_gr_restart * 1000);
11418
11419 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11420 {
11421 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11422 {
11423 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
11424 {
11425 json_object *json_sub = NULL;
11426 json_sub = json_object_new_object();
11427
11428 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV))
11429 json_object_boolean_true_add(json_sub, "preserved");
11430 restart_af_count++;
11431 json_object_object_add(json_restart, afi_safi_print (afi, safi), json_sub);
11432 }
11433 }
11434 }
11435 if (! restart_af_count)
11436 json_object_string_add(json_cap, "addressFamiliesByPeer", "none");
11437 else
11438 json_object_object_add(json_cap, "addressFamiliesByPeer", json_restart);
11439 }
11440 }
11441 json_object_object_add(json_neigh, "neighborCapabilities", json_cap);
11442 }
11443 else
11444 {
11445 vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE);
11446
11447 /* AS4 */
11448 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)
11449 || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
11450 {
11451 vty_out (vty, " 4 Byte AS:");
11452 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
11453 vty_out (vty, " advertised");
11454 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
11455 vty_out (vty, " %sreceived",
11456 CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : "");
11457 vty_out (vty, "%s", VTY_NEWLINE);
11458 }
11459
11460 /* AddPath */
11461 if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV)
11462 || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV))
11463 {
11464 vty_out (vty, " AddPath:%s", VTY_NEWLINE);
a82478b9 11465
856ca177
MS
11466 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11467 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
a82478b9 11468 {
856ca177
MS
11469 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ||
11470 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
11471 {
11472 vty_out (vty, " %s: TX ", afi_safi_print (afi, safi));
a82478b9 11473
856ca177
MS
11474 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV))
11475 vty_out (vty, "advertised %s", afi_safi_print (afi, safi));
a82478b9 11476
856ca177
MS
11477 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
11478 vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ? " and " : "" );
a82478b9 11479
856ca177
MS
11480 vty_out (vty, "%s", VTY_NEWLINE);
11481 }
a82478b9 11482
856ca177 11483 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
a82478b9 11484 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
856ca177
MS
11485 {
11486 vty_out (vty, " %s: RX ", afi_safi_print (afi, safi));
a82478b9 11487
856ca177
MS
11488 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV))
11489 vty_out (vty, "advertised %s", afi_safi_print (afi, safi));
a82478b9 11490
856ca177
MS
11491 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
11492 vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ? " and " : "" );
a82478b9 11493
856ca177
MS
11494 vty_out (vty, "%s", VTY_NEWLINE);
11495 }
a82478b9 11496 }
856ca177 11497 }
a82478b9 11498
856ca177
MS
11499 /* Dynamic */
11500 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
11501 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
11502 {
11503 vty_out (vty, " Dynamic:");
11504 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
11505 vty_out (vty, " advertised");
11506 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
11507 vty_out (vty, " %sreceived",
11508 CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : "");
11509 vty_out (vty, "%s", VTY_NEWLINE);
11510 }
11511
11512 /* Extended nexthop */
11513 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)
11514 || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
11515 {
11516 vty_out (vty, " Extended nexthop:");
11517 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
11518 vty_out (vty, " advertised");
11519 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
11520 vty_out (vty, " %sreceived",
11521 CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) ? "and " : "");
11522 vty_out (vty, "%s", VTY_NEWLINE);
718e3744 11523
856ca177
MS
11524 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
11525 {
11526 vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE);
11527 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11528 if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV))
11529 vty_out (vty, " %s%s",
11530 afi_safi_print (AFI_IP, safi), VTY_NEWLINE);
11531 }
11532 }
8a92a8a0 11533
856ca177
MS
11534 /* Route Refresh */
11535 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
11536 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
11537 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
11538 {
11539 vty_out (vty, " Route refresh:");
11540 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
11541 vty_out (vty, " advertised");
11542 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
11543 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
11544 vty_out (vty, " %sreceived(%s)",
11545 CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "",
11546 (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)
11547 && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ?
11548 "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new");
8a92a8a0 11549
856ca177
MS
11550 vty_out (vty, "%s", VTY_NEWLINE);
11551 }
718e3744 11552
856ca177
MS
11553 /* Multiprotocol Extensions */
11554 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11555 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11556 if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
11557 {
11558 vty_out (vty, " Address family %s:", afi_safi_print (afi, safi));
11559 if (p->afc_adv[afi][safi])
11560 vty_out (vty, " advertised");
11561 if (p->afc_recv[afi][safi])
11562 vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : "");
11563 vty_out (vty, "%s", VTY_NEWLINE);
11564 }
538621f2 11565
04b6bdc0
DW
11566 /* Hostname capability */
11567 if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV) ||
11568 CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV))
11569 {
11570 vty_out (vty, " Hostname Capability:");
11571 if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV))
11572 vty_out (vty, " advertised");
11573 if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_RCV))
11574 vty_out (vty, " %sreceived",
11575 CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV) ? "and " : "");
11576 vty_out (vty, "%s", VTY_NEWLINE);
11577 }
11578
856ca177
MS
11579 /* Gracefull Restart */
11580 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
11581 || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
11582 {
11583 vty_out (vty, " Graceful Restart Capabilty:");
11584 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
538621f2 11585 vty_out (vty, " advertised");
856ca177
MS
11586 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
11587 vty_out (vty, " %sreceived",
11588 CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : "");
11589 vty_out (vty, "%s", VTY_NEWLINE);
538621f2 11590
856ca177
MS
11591 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
11592 {
11593 int restart_af_count = 0;
11594
11595 vty_out (vty, " Remote Restart timer is %d seconds%s",
11596 p->v_gr_restart, VTY_NEWLINE);
11597 vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE);
11598
11599 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11600 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11601 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
11602 {
11603 vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "",
11604 afi_safi_print (afi, safi),
11605 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ?
11606 "preserved" : "not preserved");
11607 restart_af_count++;
11608 }
11609 if (! restart_af_count)
11610 vty_out (vty, "none");
11611 vty_out (vty, "%s", VTY_NEWLINE);
11612 }
11613 }
11614 }
718e3744 11615 }
11616 }
11617
93406d87 11618 /* graceful restart information */
11619 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
11620 || p->t_gr_restart
11621 || p->t_gr_stale)
11622 {
856ca177
MS
11623 json_object *json_grace = NULL;
11624 json_object *json_grace_send = NULL;
11625 json_object *json_grace_recv = NULL;
93406d87 11626 int eor_send_af_count = 0;
11627 int eor_receive_af_count = 0;
11628
856ca177
MS
11629 if (use_json)
11630 {
11631 json_grace = json_object_new_object();
11632 json_grace_send = json_object_new_object();
11633 json_grace_recv = json_object_new_object();
11634
11635 if (p->status == Established)
11636 {
11637 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11638 {
11639 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11640 {
11641 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND))
11642 {
11643 json_object_boolean_true_add(json_grace_send, afi_safi_print (afi, safi));
11644 eor_send_af_count++;
11645 }
11646 }
11647 }
11648 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11649 {
11650 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11651 {
11652 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED))
11653 {
11654 json_object_boolean_true_add(json_grace_recv, afi_safi_print (afi, safi));
11655 eor_receive_af_count++;
11656 }
11657 }
11658 }
11659 }
11660
11661 json_object_object_add(json_grace, "endOfRibSend", json_grace_send);
11662 json_object_object_add(json_grace, "endOfRibRecv", json_grace_recv);
11663
11664 if (p->t_gr_restart)
11665 json_object_int_add(json_grace, "gracefulRestartTimerMsecs", thread_timer_remain_second (p->t_gr_restart) * 1000);
11666
11667 if (p->t_gr_stale)
11668 json_object_int_add(json_grace, "gracefulStalepathTimerMsecs", thread_timer_remain_second (p->t_gr_stale) * 1000);
11669
11670 json_object_object_add(json_neigh, "gracefulRestartInfo", json_grace);
11671 }
11672 else
11673 {
11674 vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE);
11675 if (p->status == Established)
11676 {
11677 vty_out (vty, " End-of-RIB send: ");
11678 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11679 {
11680 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11681 {
11682 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND))
11683 {
11684 vty_out (vty, "%s%s", eor_send_af_count ? ", " : "",
11685 afi_safi_print (afi, safi));
11686 eor_send_af_count++;
11687 }
11688 }
11689 }
11690 vty_out (vty, "%s", VTY_NEWLINE);
11691 vty_out (vty, " End-of-RIB received: ");
11692 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11693 {
11694 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11695 {
11696 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED))
11697 {
11698 vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "",
11699 afi_safi_print (afi, safi));
11700 eor_receive_af_count++;
11701 }
11702 }
11703 }
11704 vty_out (vty, "%s", VTY_NEWLINE);
11705 }
93406d87 11706
856ca177
MS
11707 if (p->t_gr_restart)
11708 vty_out (vty, " The remaining time of restart timer is %ld%s",
11709 thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE);
0b2aa3a0 11710
856ca177
MS
11711 if (p->t_gr_stale)
11712 vty_out (vty, " The remaining time of stalepath timer is %ld%s",
11713 thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE);
11714 }
11715 }
11716 if (use_json)
11717 {
11718 json_object *json_stat = NULL;
11719 json_stat = json_object_new_object();
11720 /* Packet counts. */
11721 json_object_int_add(json_stat, "depthInq", 0);
11722 json_object_int_add(json_stat, "depthOutq", (unsigned long) p->obuf->count);
11723 json_object_int_add(json_stat, "opensSent", p->open_out);
11724 json_object_int_add(json_stat, "opensRecv", p->open_in);
11725 json_object_int_add(json_stat, "notificationsSent", p->notify_out);
11726 json_object_int_add(json_stat, "notificationsRecv", p->notify_in);
11727 json_object_int_add(json_stat, "updatesSent", p->update_out);
11728 json_object_int_add(json_stat, "updatesRecv", p->update_in);
11729 json_object_int_add(json_stat, "keepalivesSent", p->keepalive_out);
11730 json_object_int_add(json_stat, "keepalivesRecv", p->keepalive_in);
11731 json_object_int_add(json_stat, "routeRefreshSent", p->refresh_out);
11732 json_object_int_add(json_stat, "routeRefreshRecv", p->refresh_in);
11733 json_object_int_add(json_stat, "capabilitySent", p->dynamic_cap_out);
11734 json_object_int_add(json_stat, "capabilityRecv", p->dynamic_cap_in);
11735 json_object_int_add(json_stat, "totalSent", p->open_out + p->notify_out + p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out);
11736 json_object_int_add(json_stat, "totalRecv", p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in + p->dynamic_cap_in);
11737 json_object_object_add(json_neigh, "messageStats", json_stat);
11738 }
11739 else
11740 {
11741 /* Packet counts. */
11742 vty_out (vty, " Message statistics:%s", VTY_NEWLINE);
11743 vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE);
11744 vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE);
11745 vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE);
11746 vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE);
11747 vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE);
11748 vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE);
11749 vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE);
11750 vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE);
11751 vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE);
11752 vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out +
11753 p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out,
11754 p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in +
11755 p->dynamic_cap_in, VTY_NEWLINE);
718e3744 11756 }
11757
856ca177
MS
11758 if (use_json)
11759 {
11760 /* advertisement-interval */
11761 json_object_int_add(json_neigh, "minBtwnAdvertisementRunsTimerMsecs", p->v_routeadv * 1000);
718e3744 11762
856ca177
MS
11763 /* Update-source. */
11764 if (p->update_if || p->update_source)
11765 {
11766 if (p->update_if)
11767 json_object_string_add(json_neigh, "updateSource", p->update_if);
11768 else if (p->update_source)
11769 json_object_string_add(json_neigh, "updateSource", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
11770 }
11771
11772 /* Default weight */
11773 if (CHECK_FLAG (p->config, PEER_CONFIG_WEIGHT))
11774 json_object_int_add(json_neigh, "defaultWeight", p->weight);
11775
11776 }
11777 else
11778 {
11779 /* advertisement-interval */
11780 vty_out (vty, " Minimum time between advertisement runs is %d seconds%s",
11781 p->v_routeadv, VTY_NEWLINE);
11782
11783 /* Update-source. */
11784 if (p->update_if || p->update_source)
11785 {
11786 vty_out (vty, " Update source is ");
11787 if (p->update_if)
11788 vty_out (vty, "%s", p->update_if);
11789 else if (p->update_source)
11790 vty_out (vty, "%s", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
11791 vty_out (vty, "%s", VTY_NEWLINE);
11792 }
11793
11794 /* Default weight */
11795 if (CHECK_FLAG (p->config, PEER_CONFIG_WEIGHT))
11796 vty_out (vty, " Default weight %d%s", p->weight, VTY_NEWLINE);
11797
11798 vty_out (vty, "%s", VTY_NEWLINE);
11799 }
718e3744 11800
11801 /* Address Family Information */
856ca177
MS
11802 json_object *json_hold = NULL;
11803
11804 if (use_json)
11805 json_hold = json_object_new_object();
11806
538621f2 11807 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11808 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11809 if (p->afc[afi][safi])
856ca177 11810 bgp_show_peer_afi (vty, p, afi, safi, use_json, json_hold);
718e3744 11811
856ca177
MS
11812 if (use_json)
11813 {
11814 json_object_int_add(json_hold, "connectionsEstablished", p->established);
11815 json_object_int_add(json_hold, "connectionsDropped", p->dropped);
11816 }
11817 else
11818 vty_out (vty, " Connections established %d; dropped %d%s", p->established, p->dropped,
11819 VTY_NEWLINE);
718e3744 11820
d6661008 11821 if (! p->last_reset)
856ca177
MS
11822 {
11823 if (use_json)
11824 json_object_string_add(json_hold, "lastReset", "never");
11825 else
11826 vty_out (vty, " Last reset never%s", VTY_NEWLINE);
11827 }
e0701b79 11828 else
d6661008 11829 {
856ca177
MS
11830 if (use_json)
11831 {
11832 time_t uptime;
11833 struct tm *tm;
11834
11835 uptime = bgp_clock();
11836 uptime -= p->resettime;
11837 tm = gmtime(&uptime);
11838 json_object_int_add(json_hold, "lastResetTimerMsecs", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
11839 json_object_string_add(json_hold, "lastResetDueTo", peer_down_str[(int) p->last_reset]);
11840 if (p->last_reset_cause_size)
11841 {
11842 msg = p->last_reset_cause;
11843 char adapter[BUFSIZ];
11844 sprintf(adapter, "%s", msg);
11845 json_object_string_add(json_hold, "messageReceivedThatCausedBgpNotification", adapter);
11846 }
11847 }
11848 else
d6661008 11849 {
3a8c7ba1
DW
11850 vty_out (vty, " Last reset %s, ",
11851 peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN, 0, NULL));
11852
11853 if (p->last_reset == PEER_DOWN_NOTIFY_SEND ||
11854 p->last_reset == PEER_DOWN_NOTIFY_RECEIVED)
11855 {
11856 code_str = bgp_notify_code_str(p->notify.code);
11857 subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode);
11858 vty_out (vty, "due to NOTIFICATION %s (%s%s)%s",
11859 p->last_reset == PEER_DOWN_NOTIFY_SEND ? "sent" : "received",
11860 code_str, subcode_str, VTY_NEWLINE);
11861 }
11862 else
11863 {
11864 vty_out (vty, "due to %s%s",
11865 peer_down_str[(int) p->last_reset], VTY_NEWLINE);
11866 }
856ca177
MS
11867
11868 if (p->last_reset_cause_size)
d6661008 11869 {
856ca177
MS
11870 msg = p->last_reset_cause;
11871 vty_out(vty, " Message received that caused BGP to send a NOTIFICATION:%s ", VTY_NEWLINE);
11872 for (i = 1; i <= p->last_reset_cause_size; i++)
11873 {
11874 vty_out(vty, "%02X", *msg++);
d6661008 11875
856ca177
MS
11876 if (i != p->last_reset_cause_size)
11877 {
11878 if (i % 16 == 0)
11879 {
11880 vty_out(vty, "%s ", VTY_NEWLINE);
11881 }
11882 else if (i % 4 == 0)
11883 {
11884 vty_out(vty, " ");
11885 }
11886 }
11887 }
11888 vty_out(vty, "%s", VTY_NEWLINE);
d6661008 11889 }
d6661008
DS
11890 }
11891 }
848973c7 11892
718e3744 11893 if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW))
11894 {
856ca177
MS
11895 if (use_json)
11896 json_object_boolean_true_add(json_hold, "prefixesConfigExceedMax");
11897 else
11898 vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE);
0a486e5f 11899
11900 if (p->t_pmax_restart)
856ca177
MS
11901 {
11902 if (use_json)
11903 {
11904 json_object_string_add(json_hold, "reducePrefixNumFrom", p->host);
11905 json_object_int_add(json_hold, "restartInTimerMsec", thread_timer_remain_second (p->t_pmax_restart) * 1000);
11906 }
11907 else
11908 vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s",
11909 p->host, thread_timer_remain_second (p->t_pmax_restart),
11910 VTY_NEWLINE);
11911 }
0a486e5f 11912 else
856ca177
MS
11913 {
11914 if (use_json)
11915 json_object_string_add(json_hold, "reducePrefixNumAndClearIpBgp", p->host);
11916 else
11917 vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s",
11918 p->host, VTY_NEWLINE);
11919 }
718e3744 11920 }
11921
856ca177
MS
11922 if (use_json)
11923 json_object_object_add(json_neigh, "addressFamilyInfo", json_hold);
11924
f5a4827d 11925 /* EBGP Multihop and GTSM */
6d85b15b 11926 if (p->sort != BGP_PEER_IBGP)
f5a4827d 11927 {
856ca177
MS
11928 if (use_json)
11929 {
11930 if (p->gtsm_hops > 0)
11931 json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->gtsm_hops);
11932 else if (p->ttl > 1)
11933 json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->ttl);
11934 }
11935 else
11936 {
11937 if (p->gtsm_hops > 0)
11938 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
11939 p->gtsm_hops, VTY_NEWLINE);
11940 else if (p->ttl > 1)
11941 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
11942 p->ttl, VTY_NEWLINE);
11943 }
f5a4827d 11944 }
5d804b43
PM
11945 else
11946 {
11947 if (p->gtsm_hops > 0)
856ca177
MS
11948 {
11949 if (use_json)
11950 json_object_int_add(json_neigh, "internalBgpNbrMaxHopsAway", p->gtsm_hops);
11951 else
11952 vty_out (vty, " Internal BGP neighbor may be up to %d hops away.%s",
11953 p->gtsm_hops, VTY_NEWLINE);
11954 }
5d804b43 11955 }
718e3744 11956
11957 /* Local address. */
11958 if (p->su_local)
11959 {
856ca177
MS
11960 if (use_json)
11961 {
11962 json_object_string_add(json_neigh, "hostLocal", sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN));
11963 json_object_int_add(json_neigh, "portLocal", ntohs (p->su_local->sin.sin_port));
11964 }
11965 else
11966 vty_out (vty, "Local host: %s, Local port: %d%s",
11967 sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN),
11968 ntohs (p->su_local->sin.sin_port),
11969 VTY_NEWLINE);
718e3744 11970 }
11971
11972 /* Remote address. */
11973 if (p->su_remote)
11974 {
856ca177
MS
11975 if (use_json)
11976 {
11977 json_object_string_add(json_neigh, "hostForeign", sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN));
11978 json_object_int_add(json_neigh, "portForeign", ntohs (p->su_remote->sin.sin_port));
11979 }
11980 else
11981 vty_out (vty, "Foreign host: %s, Foreign port: %d%s",
718e3744 11982 sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN),
11983 ntohs (p->su_remote->sin.sin_port),
11984 VTY_NEWLINE);
11985 }
11986
11987 /* Nexthop display. */
11988 if (p->su_local)
11989 {
856ca177
MS
11990 if (use_json)
11991 {
11992 json_object_string_add(json_neigh, "nexthop", inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ));
718e3744 11993#ifdef HAVE_IPV6
856ca177
MS
11994 json_object_string_add(json_neigh, "nexthopGlobal", inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ));
11995 json_object_string_add(json_neigh, "nexthopLocal", inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ));
11996 if (p->shared_network)
11997 json_object_string_add(json_neigh, "bgpConnection", "sharedNetwork");
11998 else
11999 json_object_string_add(json_neigh, "bgpConnection", "nonSharedNetwork");
12000#endif /* HAVE_IPV6 */
12001 }
12002 else
12003 {
12004 vty_out (vty, "Nexthop: %s%s",
12005 inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ),
12006 VTY_NEWLINE);
12007#ifdef HAVE_IPV6
12008 vty_out (vty, "Nexthop global: %s%s",
12009 inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ),
12010 VTY_NEWLINE);
12011 vty_out (vty, "Nexthop local: %s%s",
12012 inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ),
12013 VTY_NEWLINE);
12014 vty_out (vty, "BGP connection: %s%s",
12015 p->shared_network ? "shared network" : "non shared network",
12016 VTY_NEWLINE);
718e3744 12017#endif /* HAVE_IPV6 */
856ca177 12018 }
718e3744 12019 }
12020
12021 /* Timer information. */
856ca177
MS
12022 if (use_json)
12023 {
12024 if (p->t_start)
12025 json_object_int_add(json_neigh, "nextStartTimerDueInMsecs", thread_timer_remain_second (p->t_start) * 1000);
12026 if (p->t_connect)
12027 json_object_int_add(json_neigh, "nextConnectTimerDueInMsecs", thread_timer_remain_second (p->t_connect) * 1000);
12028 if (p->t_routeadv)
12029 {
12030 json_object_int_add(json_neigh, "mraiInterval", p->v_routeadv);
12031 json_object_int_add(json_neigh, "mraiTimerExpireInMsecs", thread_timer_remain_second (p->t_routeadv) * 1000);
12032 }
cb1faec9 12033
856ca177
MS
12034 if (p->t_read)
12035 json_object_string_add(json_neigh, "readThread", "on");
12036 else
12037 json_object_string_add(json_neigh, "readThread", "off");
12038 if (p->t_write)
12039 json_object_string_add(json_neigh, "writeThread", "on");
12040 else
12041 json_object_string_add(json_neigh, "writeThread", "off");
12042 }
12043 else
12044 {
12045 if (p->t_start)
12046 vty_out (vty, "Next start timer due in %ld seconds%s",
12047 thread_timer_remain_second (p->t_start), VTY_NEWLINE);
12048 if (p->t_connect)
12049 vty_out (vty, "Next connect timer due in %ld seconds%s",
12050 thread_timer_remain_second (p->t_connect), VTY_NEWLINE);
12051 if (p->t_routeadv)
12052 vty_out (vty, "MRAI (interval %u) timer expires in %ld seconds%s",
12053 p->v_routeadv, thread_timer_remain_second (p->t_routeadv),
12054 VTY_NEWLINE);
12055
12056 vty_out (vty, "Read thread: %s Write thread: %s%s",
12057 p->t_read ? "on" : "off",
12058 p->t_write ? "on" : "off",
12059 VTY_NEWLINE);
12060 }
718e3744 12061
12062 if (p->notify.code == BGP_NOTIFY_OPEN_ERR
12063 && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL)
856ca177
MS
12064 bgp_capability_vty_out (vty, p, use_json, json_neigh);
12065
12066 if (!use_json)
12067 vty_out (vty, "%s", VTY_NEWLINE);
c43ed2e4
DS
12068
12069 /* BFD information. */
856ca177
MS
12070 bgp_bfd_show_info(vty, p, use_json, json_neigh);
12071
12072 if (use_json)
12073 {
12074 if (p->conf_if) /* Configured interface name. */
12075 json_object_object_add(json, p->conf_if, json_neigh);
12076 else /* Configured IP address. */
12077 json_object_object_add(json, p->host, json_neigh);
12078 }
718e3744 12079}
12080
94f2b392 12081static int
856ca177
MS
12082bgp_show_neighbor (struct vty *vty, struct bgp *bgp, enum show_type type,
12083 union sockunion *su, const char *conf_if, u_char use_json, json_object *json)
718e3744 12084{
1eb8ef25 12085 struct listnode *node, *nnode;
718e3744 12086 struct peer *peer;
12087 int find = 0;
856ca177
MS
12088 json_object *json_neigh = NULL;
12089
12090 if (use_json)
12091 json_neigh = json_object_new_object();
718e3744 12092
1eb8ef25 12093 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
718e3744 12094 {
1ff9a340
DS
12095 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
12096 continue;
12097
718e3744 12098 switch (type)
856ca177
MS
12099 {
12100 case show_all:
12101 bgp_show_peer (vty, peer, use_json, json, json_neigh);
12102 break;
12103 case show_peer:
12104 if (conf_if)
12105 {
4873b3b9
DW
12106 if ((peer->conf_if && !strcmp(peer->conf_if, conf_if)) ||
12107 (peer->hostname && !strcmp(peer->hostname, conf_if)))
856ca177
MS
12108 {
12109 find = 1;
12110 bgp_show_peer (vty, peer, use_json, json, json_neigh);
12111 }
12112 }
12113 else
12114 {
12115 if (sockunion_same (&peer->su, su))
12116 {
12117 find = 1;
12118 bgp_show_peer (vty, peer, use_json, json, json_neigh);
12119 }
12120 }
12121 break;
718e3744 12122 }
12123 }
12124
12125 if (type == show_peer && ! find)
856ca177
MS
12126 {
12127 if (use_json)
12128 json_object_boolean_true_add(json, "bgpNoSuchNeighbor");
12129 else
12130 vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE);
12131 }
12132
12133 if (use_json)
12134 {
12135 vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
12136 json_object_free(json);
12137 }
12138 else
12139 {
12140 vty_out (vty, "%s", VTY_NEWLINE);
12141 }
12142
718e3744 12143 return CMD_SUCCESS;
12144}
12145
94f2b392 12146static int
fd79ac91 12147bgp_show_neighbor_vty (struct vty *vty, const char *name,
9f689658
DD
12148 enum show_type type, const char *ip_str, u_char use_json,
12149 json_object *json)
718e3744 12150{
12151 int ret;
12152 struct bgp *bgp;
12153 union sockunion su;
856ca177 12154
9f689658 12155 if (use_json && (json == NULL))
856ca177 12156 json = json_object_new_object();
718e3744 12157
718e3744 12158 if (name)
12159 {
12160 bgp = bgp_lookup_by_name (name);
718e3744 12161 if (! bgp)
12162 {
856ca177
MS
12163 if (use_json)
12164 {
12165 json_object_boolean_true_add(json, "bgpNoSuchInstance");
12166 vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
12167 json_object_free(json);
12168 }
12169 else
12170 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
12171
718e3744 12172 return CMD_WARNING;
12173 }
718e3744 12174 }
a80beece
DS
12175 else
12176 {
12177 bgp = bgp_get_default ();
12178 }
718e3744 12179
12180 if (bgp)
a80beece
DS
12181 {
12182 if (ip_str)
12183 {
12184 ret = str2sockunion (ip_str, &su);
12185 if (ret < 0)
856ca177 12186 bgp_show_neighbor (vty, bgp, type, NULL, ip_str, use_json, json);
a80beece 12187 else
856ca177 12188 bgp_show_neighbor (vty, bgp, type, &su, NULL, use_json, json);
a80beece
DS
12189 }
12190 else
12191 {
856ca177 12192 bgp_show_neighbor (vty, bgp, type, NULL, NULL, use_json, json);
a80beece
DS
12193 }
12194 }
718e3744 12195
12196 return CMD_SUCCESS;
12197}
12198
f186de26 12199static void
12200bgp_show_all_instances_neighbors_vty (struct vty *vty, u_char use_json)
12201{
12202 struct listnode *node, *nnode;
12203 struct bgp *bgp;
12204 json_object *json = NULL;
9f689658
DD
12205 int is_first = 1;
12206
12207 if (use_json)
12208 vty_out (vty, "{%s", VTY_NEWLINE);
f186de26 12209
12210 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
12211 {
f186de26 12212 if (use_json)
9f689658
DD
12213 {
12214 if (!(json = json_object_new_object()))
12215 {
12216 zlog_err("Unable to allocate memory for JSON object");
12217 vty_out (vty,
12218 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s",
12219 VTY_NEWLINE);
12220 return;
12221 }
12222
12223 json_object_int_add(json, "vrfId",
12224 (bgp->vrf_id == VRF_UNKNOWN)
12225 ? -1 : bgp->vrf_id);
12226 json_object_string_add(json, "vrfName",
12227 (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
12228 ? "Default" : bgp->name);
12229
12230 if (! is_first)
12231 vty_out (vty, ",%s", VTY_NEWLINE);
12232 else
12233 is_first = 0;
12234
12235 vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
12236 ? "Default" : bgp->name);
12237 }
12238 else
12239 {
12240 vty_out (vty, "%sInstance %s:%s",
12241 VTY_NEWLINE,
12242 (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
12243 ? "Default" : bgp->name,
12244 VTY_NEWLINE);
12245 }
f186de26 12246 bgp_show_neighbor (vty, bgp, show_all, NULL, NULL, use_json, json);
12247 }
9f689658
DD
12248
12249 if (use_json)
12250 vty_out (vty, "}%s", VTY_NEWLINE);
f186de26 12251}
12252
718e3744 12253/* "show ip bgp neighbors" commands. */
12254DEFUN (show_ip_bgp_neighbors,
12255 show_ip_bgp_neighbors_cmd,
856ca177 12256 "show ip bgp neighbors {json}",
718e3744 12257 SHOW_STR
12258 IP_STR
12259 BGP_STR
856ca177
MS
12260 "Detailed information on TCP and BGP neighbor connections\n"
12261 "JavaScript Object Notation\n")
718e3744 12262{
db7c8528 12263 u_char uj = use_json(argc, argv);
856ca177 12264
9f689658 12265 return bgp_show_neighbor_vty (vty, NULL, show_all, NULL, uj, NULL);
718e3744 12266}
12267
12268ALIAS (show_ip_bgp_neighbors,
12269 show_ip_bgp_ipv4_neighbors_cmd,
856ca177 12270 "show ip bgp ipv4 (unicast|multicast) neighbors {json}",
718e3744 12271 SHOW_STR
12272 IP_STR
12273 BGP_STR
12274 "Address family\n"
12275 "Address Family modifier\n"
12276 "Address Family modifier\n"
856ca177
MS
12277 "Detailed information on TCP and BGP neighbor connections\n"
12278 "JavaScript Object Notation\n")
718e3744 12279
12280ALIAS (show_ip_bgp_neighbors,
12281 show_ip_bgp_vpnv4_all_neighbors_cmd,
856ca177 12282 "show ip bgp vpnv4 all neighbors {json}",
718e3744 12283 SHOW_STR
12284 IP_STR
12285 BGP_STR
12286 "Display VPNv4 NLRI specific information\n"
12287 "Display information about all VPNv4 NLRIs\n"
856ca177
MS
12288 "Detailed information on TCP and BGP neighbor connections\n"
12289 "JavaScript Object Notation\n")
718e3744 12290
12291ALIAS (show_ip_bgp_neighbors,
12292 show_ip_bgp_vpnv4_rd_neighbors_cmd,
856ca177 12293 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors {json}",
718e3744 12294 SHOW_STR
12295 IP_STR
12296 BGP_STR
12297 "Display VPNv4 NLRI specific information\n"
12298 "Display information for a route distinguisher\n"
12299 "VPN Route Distinguisher\n"
856ca177
MS
12300 "Detailed information on TCP and BGP neighbor connections\n"
12301 "JavaScript Object Notation\n")
718e3744 12302
12303ALIAS (show_ip_bgp_neighbors,
12304 show_bgp_neighbors_cmd,
856ca177 12305 "show bgp neighbors {json}",
718e3744 12306 SHOW_STR
12307 BGP_STR
856ca177
MS
12308 "Detailed information on TCP and BGP neighbor connections\n"
12309 "JavaScript Object Notation\n")
718e3744 12310
12311ALIAS (show_ip_bgp_neighbors,
12312 show_bgp_ipv6_neighbors_cmd,
856ca177 12313 "show bgp ipv6 neighbors {json}",
718e3744 12314 SHOW_STR
12315 BGP_STR
12316 "Address family\n"
856ca177
MS
12317 "Detailed information on TCP and BGP neighbor connections\n"
12318 "JavaScript Object Notation\n")
718e3744 12319
12320DEFUN (show_ip_bgp_neighbors_peer,
12321 show_ip_bgp_neighbors_peer_cmd,
856ca177 12322 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
718e3744 12323 SHOW_STR
12324 IP_STR
12325 BGP_STR
12326 "Detailed information on TCP and BGP neighbor connections\n"
12327 "Neighbor to display information about\n"
a80beece 12328 "Neighbor to display information about\n"
856ca177
MS
12329 "Neighbor on bgp configured interface\n"
12330 "JavaScript Object Notation\n")
718e3744 12331{
db7c8528 12332 u_char uj = use_json(argc, argv);
856ca177 12333
9f689658 12334 return bgp_show_neighbor_vty (vty, NULL, show_peer, argv[argc - 2], uj, NULL);
718e3744 12335}
12336
12337ALIAS (show_ip_bgp_neighbors_peer,
12338 show_ip_bgp_ipv4_neighbors_peer_cmd,
856ca177 12339 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
718e3744 12340 SHOW_STR
12341 IP_STR
12342 BGP_STR
12343 "Address family\n"
12344 "Address Family modifier\n"
12345 "Address Family modifier\n"
12346 "Detailed information on TCP and BGP neighbor connections\n"
12347 "Neighbor to display information about\n"
a80beece 12348 "Neighbor to display information about\n"
856ca177
MS
12349 "Neighbor on bgp configured interface\n"
12350 "JavaScript Object Notation\n")
718e3744 12351
12352ALIAS (show_ip_bgp_neighbors_peer,
12353 show_ip_bgp_vpnv4_all_neighbors_peer_cmd,
856ca177 12354 "show ip bgp vpnv4 all neighbors A.B.C.D {json}",
718e3744 12355 SHOW_STR
12356 IP_STR
12357 BGP_STR
12358 "Display VPNv4 NLRI specific information\n"
12359 "Display information about all VPNv4 NLRIs\n"
12360 "Detailed information on TCP and BGP neighbor connections\n"
856ca177
MS
12361 "Neighbor to display information about\n"
12362 "JavaScript Object Notation\n")
718e3744 12363
12364ALIAS (show_ip_bgp_neighbors_peer,
12365 show_ip_bgp_vpnv4_rd_neighbors_peer_cmd,
856ca177 12366 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D {json}",
718e3744 12367 SHOW_STR
12368 IP_STR
12369 BGP_STR
12370 "Display VPNv4 NLRI specific information\n"
12371 "Display information about all VPNv4 NLRIs\n"
12372 "Detailed information on TCP and BGP neighbor connections\n"
856ca177
MS
12373 "Neighbor to display information about\n"
12374 "JavaScript Object Notation\n")
718e3744 12375
12376ALIAS (show_ip_bgp_neighbors_peer,
12377 show_bgp_neighbors_peer_cmd,
856ca177 12378 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
718e3744 12379 SHOW_STR
12380 BGP_STR
12381 "Detailed information on TCP and BGP neighbor connections\n"
12382 "Neighbor to display information about\n"
a80beece 12383 "Neighbor to display information about\n"
856ca177
MS
12384 "Neighbor on bgp configured interface\n"
12385 "JavaScript Object Notation\n")
718e3744 12386
12387ALIAS (show_ip_bgp_neighbors_peer,
12388 show_bgp_ipv6_neighbors_peer_cmd,
856ca177 12389 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
718e3744 12390 SHOW_STR
12391 BGP_STR
12392 "Address family\n"
12393 "Detailed information on TCP and BGP neighbor connections\n"
12394 "Neighbor to display information about\n"
a80beece 12395 "Neighbor to display information about\n"
856ca177
MS
12396 "Neighbor on bgp configured interface\n"
12397 "JavaScript Object Notation\n")
718e3744 12398
12399DEFUN (show_ip_bgp_instance_neighbors,
12400 show_ip_bgp_instance_neighbors_cmd,
8386ac43 12401 "show ip bgp " BGP_INSTANCE_CMD " neighbors {json}",
718e3744 12402 SHOW_STR
12403 IP_STR
12404 BGP_STR
8386ac43 12405 BGP_INSTANCE_HELP_STR
856ca177
MS
12406 "Detailed information on TCP and BGP neighbor connections\n"
12407 "JavaScript Object Notation\n")
718e3744 12408{
db7c8528 12409 u_char uj = use_json(argc, argv);
856ca177 12410
9f689658 12411 return bgp_show_neighbor_vty (vty, argv[1], show_all, NULL, uj, NULL);
718e3744 12412}
12413
f186de26 12414DEFUN (show_ip_bgp_instance_all_neighbors,
12415 show_ip_bgp_instance_all_neighbors_cmd,
12416 "show ip bgp " BGP_INSTANCE_ALL_CMD " neighbors {json}",
12417 SHOW_STR
12418 IP_STR
12419 BGP_STR
12420 BGP_INSTANCE_ALL_HELP_STR
12421 "Detailed information on TCP and BGP neighbor connections\n"
12422 "JavaScript Object Notation\n")
12423{
12424 u_char uj = use_json(argc, argv);
12425
12426 bgp_show_all_instances_neighbors_vty (vty, uj);
12427 return CMD_SUCCESS;
12428}
12429
bb46e94f 12430ALIAS (show_ip_bgp_instance_neighbors,
12431 show_bgp_instance_neighbors_cmd,
8386ac43 12432 "show bgp " BGP_INSTANCE_CMD " neighbors {json}",
bb46e94f 12433 SHOW_STR
12434 BGP_STR
8386ac43 12435 BGP_INSTANCE_HELP_STR
856ca177
MS
12436 "Detailed information on TCP and BGP neighbor connections\n"
12437 "JavaScript Object Notation\n")
bb46e94f 12438
12439ALIAS (show_ip_bgp_instance_neighbors,
12440 show_bgp_instance_ipv6_neighbors_cmd,
8386ac43 12441 "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors {json}",
bb46e94f 12442 SHOW_STR
12443 BGP_STR
8386ac43 12444 BGP_INSTANCE_HELP_STR
bb46e94f 12445 "Address family\n"
856ca177
MS
12446 "Detailed information on TCP and BGP neighbor connections\n"
12447 "JavaScript Object Notation\n")
bb46e94f 12448
718e3744 12449DEFUN (show_ip_bgp_instance_neighbors_peer,
12450 show_ip_bgp_instance_neighbors_peer_cmd,
8386ac43 12451 "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
718e3744 12452 SHOW_STR
12453 IP_STR
12454 BGP_STR
8386ac43 12455 BGP_INSTANCE_HELP_STR
718e3744 12456 "Detailed information on TCP and BGP neighbor connections\n"
12457 "Neighbor to display information about\n"
a80beece 12458 "Neighbor to display information about\n"
856ca177
MS
12459 "Neighbor on bgp configured interface\n"
12460 "JavaScript Object Notation\n")
718e3744 12461{
db7c8528 12462 u_char uj = use_json(argc, argv);
856ca177 12463
9f689658 12464 return bgp_show_neighbor_vty (vty, argv[1], show_peer, argv[2], uj, NULL);
718e3744 12465}
bb46e94f 12466
12467ALIAS (show_ip_bgp_instance_neighbors_peer,
12468 show_bgp_instance_neighbors_peer_cmd,
8386ac43 12469 "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
bb46e94f 12470 SHOW_STR
12471 BGP_STR
8386ac43 12472 BGP_INSTANCE_HELP_STR
bb46e94f 12473 "Detailed information on TCP and BGP neighbor connections\n"
12474 "Neighbor to display information about\n"
a80beece 12475 "Neighbor to display information about\n"
856ca177
MS
12476 "Neighbor on bgp configured interface\n"
12477 "JavaScript Object Notation\n")
bb46e94f 12478
12479ALIAS (show_ip_bgp_instance_neighbors_peer,
12480 show_bgp_instance_ipv6_neighbors_peer_cmd,
8386ac43 12481 "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
bb46e94f 12482 SHOW_STR
12483 BGP_STR
8386ac43 12484 BGP_INSTANCE_HELP_STR
bb46e94f 12485 "Address family\n"
12486 "Detailed information on TCP and BGP neighbor connections\n"
12487 "Neighbor to display information about\n"
a80beece 12488 "Neighbor to display information about\n"
856ca177
MS
12489 "Neighbor on bgp configured interface\n"
12490 "JavaScript Object Notation\n")
6b0655a2 12491
718e3744 12492/* Show BGP's AS paths internal data. There are both `show ip bgp
12493 paths' and `show ip mbgp paths'. Those functions results are the
12494 same.*/
12495DEFUN (show_ip_bgp_paths,
12496 show_ip_bgp_paths_cmd,
12497 "show ip bgp paths",
12498 SHOW_STR
12499 IP_STR
12500 BGP_STR
12501 "Path information\n")
12502{
12503 vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE);
12504 aspath_print_all_vty (vty);
12505 return CMD_SUCCESS;
12506}
12507
12508DEFUN (show_ip_bgp_ipv4_paths,
12509 show_ip_bgp_ipv4_paths_cmd,
12510 "show ip bgp ipv4 (unicast|multicast) paths",
12511 SHOW_STR
12512 IP_STR
12513 BGP_STR
12514 "Address family\n"
12515 "Address Family modifier\n"
12516 "Address Family modifier\n"
12517 "Path information\n")
12518{
12519 vty_out (vty, "Address Refcnt Path\r\n");
12520 aspath_print_all_vty (vty);
12521
12522 return CMD_SUCCESS;
12523}
6b0655a2 12524
718e3744 12525#include "hash.h"
12526
94f2b392 12527static void
718e3744 12528community_show_all_iterator (struct hash_backet *backet, struct vty *vty)
12529{
12530 struct community *com;
12531
12532 com = (struct community *) backet->data;
12533 vty_out (vty, "[%p] (%ld) %s%s", backet, com->refcnt,
12534 community_str (com), VTY_NEWLINE);
12535}
12536
12537/* Show BGP's community internal data. */
12538DEFUN (show_ip_bgp_community_info,
12539 show_ip_bgp_community_info_cmd,
12540 "show ip bgp community-info",
12541 SHOW_STR
12542 IP_STR
12543 BGP_STR
12544 "List all bgp community information\n")
12545{
12546 vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE);
12547
12548 hash_iterate (community_hash (),
12549 (void (*) (struct hash_backet *, void *))
12550 community_show_all_iterator,
12551 vty);
12552
12553 return CMD_SUCCESS;
12554}
12555
12556DEFUN (show_ip_bgp_attr_info,
12557 show_ip_bgp_attr_info_cmd,
12558 "show ip bgp attribute-info",
12559 SHOW_STR
12560 IP_STR
12561 BGP_STR
12562 "List all bgp attribute information\n")
12563{
12564 attr_show_all (vty);
12565 return CMD_SUCCESS;
12566}
6b0655a2 12567
8386ac43 12568static int bgp_show_update_groups(struct vty *vty, const char *name,
12569 int afi, int safi,
50ef26d4 12570 u_int64_t subgrp_id)
3f9c7369
DS
12571{
12572 struct bgp *bgp;
12573
8386ac43 12574 if (name)
12575 bgp = bgp_lookup_by_name (name);
12576 else
12577 bgp = bgp_get_default ();
12578
3f9c7369 12579 if (bgp)
8fe8a7f6 12580 update_group_show(bgp, afi, safi, vty, subgrp_id);
3f9c7369
DS
12581 return CMD_SUCCESS;
12582}
12583
f186de26 12584static void
12585bgp_show_all_instances_updgrps_vty (struct vty *vty, afi_t afi, safi_t safi)
12586{
12587 struct listnode *node, *nnode;
12588 struct bgp *bgp;
12589
12590 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
12591 {
12592 vty_out (vty, "%sInstance %s:%s",
12593 VTY_NEWLINE,
12594 (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? "Default" : bgp->name,
12595 VTY_NEWLINE);
12596 update_group_show(bgp, afi, safi, vty, 0);
12597 }
12598}
12599
8fe8a7f6
DS
12600DEFUN (show_ip_bgp_updgrps,
12601 show_ip_bgp_updgrps_cmd,
12602 "show ip bgp update-groups",
12603 SHOW_STR
12604 IP_STR
12605 BGP_STR
12606 "Detailed info about dynamic update groups\n")
12607{
8386ac43 12608 return (bgp_show_update_groups(vty, NULL, AFI_IP, SAFI_UNICAST, 0));
12609}
12610
12611DEFUN (show_ip_bgp_instance_updgrps,
12612 show_ip_bgp_instance_updgrps_cmd,
12613 "show ip bgp " BGP_INSTANCE_CMD " update-groups",
12614 SHOW_STR
12615 IP_STR
12616 BGP_STR
12617 BGP_INSTANCE_HELP_STR
12618 "Detailed info about dynamic update groups\n")
12619{
12620 return (bgp_show_update_groups(vty, argv[1], AFI_IP, SAFI_UNICAST, 0));
8fe8a7f6
DS
12621}
12622
f186de26 12623DEFUN (show_ip_bgp_instance_all_updgrps,
12624 show_ip_bgp_instance_all_updgrps_cmd,
12625 "show ip bgp " BGP_INSTANCE_ALL_CMD " update-groups",
12626 SHOW_STR
12627 IP_STR
12628 BGP_STR
12629 BGP_INSTANCE_ALL_HELP_STR
12630 "Detailed info about dynamic update groups\n")
12631{
12632 bgp_show_all_instances_updgrps_vty (vty, AFI_IP, SAFI_UNICAST);
12633 return CMD_SUCCESS;
12634}
12635
3f9c7369
DS
12636DEFUN (show_bgp_ipv6_updgrps,
12637 show_bgp_ipv6_updgrps_cmd,
8fe8a7f6 12638 "show bgp update-groups",
3f9c7369
DS
12639 SHOW_STR
12640 BGP_STR
8fe8a7f6 12641 "Detailed info about v6 dynamic update groups\n")
3f9c7369 12642{
8386ac43 12643 return (bgp_show_update_groups(vty, NULL, AFI_IP6, SAFI_UNICAST, 0));
12644}
12645
12646DEFUN (show_bgp_instance_ipv6_updgrps,
12647 show_bgp_instance_ipv6_updgrps_cmd,
12648 "show bgp " BGP_INSTANCE_CMD " update-groups",
12649 SHOW_STR
12650 BGP_STR
12651 BGP_INSTANCE_HELP_STR
12652 "Detailed info about v6 dynamic update groups\n")
12653{
12654 return (bgp_show_update_groups(vty, argv[1], AFI_IP6, SAFI_UNICAST, 0));
3f9c7369
DS
12655}
12656
f186de26 12657DEFUN (show_bgp_instance_all_ipv6_updgrps,
12658 show_bgp_instance_all_ipv6_updgrps_cmd,
12659 "show bgp " BGP_INSTANCE_ALL_CMD " update-groups",
12660 SHOW_STR
12661 BGP_STR
12662 BGP_INSTANCE_ALL_HELP_STR
12663 "Detailed info about v6 dynamic update groups\n")
12664{
12665 bgp_show_all_instances_updgrps_vty (vty, AFI_IP6, SAFI_UNICAST);
12666 return CMD_SUCCESS;
12667}
12668
3f9c7369
DS
12669DEFUN (show_bgp_updgrps,
12670 show_bgp_updgrps_cmd,
8fe8a7f6 12671 "show bgp (ipv4|ipv6) (unicast|multicast) update-groups",
3f9c7369
DS
12672 SHOW_STR
12673 BGP_STR
12674 "Address family\n"
12675 "Address family\n"
12676 "Address Family modifier\n"
12677 "Address Family modifier\n"
8fe8a7f6 12678 "Detailed info about dynamic update groups\n")
3f9c7369 12679{
3f9c7369
DS
12680 afi_t afi;
12681 safi_t safi;
12682
12683 afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6;
12684 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
8386ac43 12685 return (bgp_show_update_groups(vty, NULL, afi, safi, 0));
8fe8a7f6
DS
12686}
12687
12688DEFUN (show_ip_bgp_updgrps_s,
12689 show_ip_bgp_updgrps_s_cmd,
12690 "show ip bgp update-groups SUBGROUP-ID",
12691 SHOW_STR
12692 IP_STR
12693 BGP_STR
12694 "Detailed info about dynamic update groups\n"
12695 "Specific subgroup to display detailed info for\n")
12696{
12697 u_int64_t subgrp_id;
12698
12699 VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]);
8386ac43 12700 return (bgp_show_update_groups(vty, NULL, AFI_IP, SAFI_UNICAST, subgrp_id));
12701}
12702
12703DEFUN (show_ip_bgp_instance_updgrps_s,
12704 show_ip_bgp_instance_updgrps_s_cmd,
12705 "show ip bgp " BGP_INSTANCE_CMD " update-groups SUBGROUP-ID",
12706 SHOW_STR
12707 IP_STR
12708 BGP_STR
12709 BGP_INSTANCE_HELP_STR
12710 "Detailed info about dynamic update groups\n"
12711 "Specific subgroup to display detailed info for\n")
12712{
12713 u_int64_t subgrp_id;
12714
12715 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
12716 return (bgp_show_update_groups(vty, argv[1], AFI_IP, SAFI_UNICAST, subgrp_id));
8fe8a7f6
DS
12717}
12718
12719DEFUN (show_bgp_ipv6_updgrps_s,
12720 show_bgp_ipv6_updgrps_s_cmd,
12721 "show bgp update-groups SUBGROUP-ID",
12722 SHOW_STR
12723 BGP_STR
12724 "Detailed info about v6 dynamic update groups\n"
12725 "Specific subgroup to display detailed info for\n")
12726{
12727 u_int64_t subgrp_id;
12728
12729 VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]);
8386ac43 12730 return(bgp_show_update_groups(vty, NULL, AFI_IP6, SAFI_UNICAST, subgrp_id));
12731}
12732
12733DEFUN (show_bgp_instance_ipv6_updgrps_s,
12734 show_bgp_instance_ipv6_updgrps_s_cmd,
12735 "show bgp " BGP_INSTANCE_CMD " update-groups SUBGROUP-ID",
12736 SHOW_STR
12737 BGP_STR
12738 "Detailed info about v6 dynamic update groups\n"
12739 "Specific subgroup to display detailed info for\n")
12740{
12741 u_int64_t subgrp_id;
12742
12743 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
12744 return(bgp_show_update_groups(vty, argv[1], AFI_IP6, SAFI_UNICAST, subgrp_id));
8fe8a7f6
DS
12745}
12746
12747DEFUN (show_bgp_updgrps_s,
12748 show_bgp_updgrps_s_cmd,
12749 "show bgp (ipv4|ipv6) (unicast|multicast) update-groups SUBGROUP-ID",
12750 SHOW_STR
12751 BGP_STR
12752 "Address family\n"
12753 "Address family\n"
12754 "Address Family modifier\n"
12755 "Address Family modifier\n"
12756 "Detailed info about v6 dynamic update groups\n"
12757 "Specific subgroup to display detailed info for")
12758{
12759 afi_t afi;
12760 safi_t safi;
12761 u_int64_t subgrp_id;
12762
12763 afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6;
12764 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
12765
12766 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
8386ac43 12767 return(bgp_show_update_groups(vty, NULL, afi, safi, subgrp_id));
3f9c7369
DS
12768}
12769
12770DEFUN (show_bgp_updgrps_stats,
12771 show_bgp_updgrps_stats_cmd,
12772 "show bgp update-groups statistics",
12773 SHOW_STR
12774 BGP_STR
12775 "BGP update groups\n"
12776 "Statistics\n")
12777{
12778 struct bgp *bgp;
12779
12780 bgp = bgp_get_default();
12781 if (bgp)
12782 update_group_show_stats(bgp, vty);
12783
12784 return CMD_SUCCESS;
12785}
12786
8386ac43 12787DEFUN (show_bgp_instance_updgrps_stats,
12788 show_bgp_instance_updgrps_stats_cmd,
12789 "show bgp " BGP_INSTANCE_CMD " update-groups statistics",
12790 SHOW_STR
12791 BGP_STR
12792 BGP_INSTANCE_HELP_STR
12793 "BGP update groups\n"
12794 "Statistics\n")
12795{
12796 struct bgp *bgp;
12797
12798 bgp = bgp_lookup_by_name (argv[1]);
12799 if (bgp)
12800 update_group_show_stats(bgp, vty);
12801
12802 return CMD_SUCCESS;
12803}
12804
3f9c7369 12805static void
8386ac43 12806show_bgp_updgrps_adj_info_aux (struct vty *vty, const char *name,
12807 afi_t afi, safi_t safi,
3f9c7369
DS
12808 const char *what, u_int64_t subgrp_id)
12809{
12810 struct bgp *bgp;
8386ac43 12811
12812 if (name)
12813 bgp = bgp_lookup_by_name (name);
12814 else
12815 bgp = bgp_get_default ();
12816
3f9c7369
DS
12817 if (bgp)
12818 {
12819 if (!strcmp(what, "advertise-queue"))
12820 update_group_show_adj_queue(bgp, afi, safi, vty, subgrp_id);
12821 else if (!strcmp(what, "advertised-routes"))
12822 update_group_show_advertised(bgp, afi, safi, vty, subgrp_id);
12823 else if (!strcmp(what, "packet-queue"))
12824 update_group_show_packet_queue(bgp, afi, safi, vty, subgrp_id);
12825 }
12826}
12827
12828DEFUN (show_ip_bgp_updgrps_adj,
12829 show_ip_bgp_updgrps_adj_cmd,
12830 "show ip bgp update-groups (advertise-queue|advertised-routes|packet-queue)",
12831 SHOW_STR
12832 IP_STR
12833 BGP_STR
12834 "BGP update groups\n"
12835 "Advertisement queue\n"
12836 "Announced routes\n"
12837 "Packet queue\n")
8fe8a7f6 12838
3f9c7369 12839{
8386ac43 12840 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[0], 0);
12841 return CMD_SUCCESS;
12842}
12843
12844DEFUN (show_ip_bgp_instance_updgrps_adj,
12845 show_ip_bgp_instance_updgrps_adj_cmd,
12846 "show ip bgp " BGP_INSTANCE_CMD " update-groups (advertise-queue|advertised-routes|packet-queue)",
12847 SHOW_STR
12848 IP_STR
12849 BGP_STR
12850 BGP_INSTANCE_HELP_STR
12851 "BGP update groups\n"
12852 "Advertisement queue\n"
12853 "Announced routes\n"
12854 "Packet queue\n")
12855
12856{
12857 show_bgp_updgrps_adj_info_aux(vty, argv[1], AFI_IP, SAFI_UNICAST, argv[2], 0);
3f9c7369
DS
12858 return CMD_SUCCESS;
12859}
12860
12861DEFUN (show_bgp_updgrps_afi_adj,
12862 show_bgp_updgrps_afi_adj_cmd,
12863 "show bgp (ipv4|ipv6) (unicast|multicast) update-groups (advertise-queue|advertised-routes|packet-queue)",
12864 SHOW_STR
12865 BGP_STR
12866 "Address family\n"
12867 "Address family\n"
12868 "Address Family modifier\n"
12869 "Address Family modifier\n"
12870 "BGP update groups\n"
12871 "Advertisement queue\n"
12872 "Announced routes\n"
8fe8a7f6
DS
12873 "Packet queue\n"
12874 "Specific subgroup info wanted for\n")
3f9c7369
DS
12875{
12876 afi_t afi;
12877 safi_t safi;
12878
12879 afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6;
12880 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
8386ac43 12881 show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[2], 0);
8fe8a7f6 12882 return CMD_SUCCESS;
3f9c7369
DS
12883}
12884
12885DEFUN (show_bgp_updgrps_adj,
12886 show_bgp_updgrps_adj_cmd,
12887 "show bgp update-groups (advertise-queue|advertised-routes|packet-queue)",
12888 SHOW_STR
12889 BGP_STR
12890 "BGP update groups\n"
12891 "Advertisement queue\n"
12892 "Announced routes\n"
12893 "Packet queue\n")
12894{
8386ac43 12895 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[0], 0);
12896 return CMD_SUCCESS;
12897}
12898
12899DEFUN (show_bgp_instance_updgrps_adj,
12900 show_bgp_instance_updgrps_adj_cmd,
12901 "show bgp " BGP_INSTANCE_CMD " update-groups (advertise-queue|advertised-routes|packet-queue)",
12902 SHOW_STR
12903 BGP_STR
12904 BGP_INSTANCE_HELP_STR
12905 "BGP update groups\n"
12906 "Advertisement queue\n"
12907 "Announced routes\n"
12908 "Packet queue\n")
12909{
12910 show_bgp_updgrps_adj_info_aux(vty, argv[1], AFI_IP6, SAFI_UNICAST, argv[2], 0);
3f9c7369
DS
12911 return CMD_SUCCESS;
12912}
12913
12914DEFUN (show_ip_bgp_updgrps_adj_s,
8fe8a7f6 12915 show_ip_bgp_updgrps_adj_s_cmd,
3f9c7369
DS
12916 "show ip bgp update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
12917 SHOW_STR
12918 IP_STR
12919 BGP_STR
12920 "BGP update groups\n"
8fe8a7f6 12921 "Specific subgroup to display info for\n"
3f9c7369
DS
12922 "Advertisement queue\n"
12923 "Announced routes\n"
12924 "Packet queue\n")
3f9c7369 12925
3f9c7369 12926{
8fe8a7f6
DS
12927 u_int64_t subgrp_id;
12928
12929 VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]);
12930
8386ac43 12931 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[1], subgrp_id);
12932 return CMD_SUCCESS;
12933}
12934
12935DEFUN (show_ip_bgp_instance_updgrps_adj_s,
12936 show_ip_bgp_instance_updgrps_adj_s_cmd,
12937 "show ip bgp " BGP_INSTANCE_CMD " update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
12938 SHOW_STR
12939 IP_STR
12940 BGP_STR
12941 BGP_INSTANCE_HELP_STR
12942 "BGP update groups\n"
12943 "Specific subgroup to display info for\n"
12944 "Advertisement queue\n"
12945 "Announced routes\n"
12946 "Packet queue\n")
12947
12948{
12949 u_int64_t subgrp_id;
12950
12951 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
12952
12953 show_bgp_updgrps_adj_info_aux(vty, argv[1], AFI_IP, SAFI_UNICAST, argv[3], subgrp_id);
3f9c7369
DS
12954 return CMD_SUCCESS;
12955}
12956
8fe8a7f6
DS
12957DEFUN (show_bgp_updgrps_afi_adj_s,
12958 show_bgp_updgrps_afi_adj_s_cmd,
3f9c7369
DS
12959 "show bgp (ipv4|ipv6) (unicast|multicast) update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
12960 SHOW_STR
12961 BGP_STR
12962 "Address family\n"
12963 "Address family\n"
12964 "Address Family modifier\n"
12965 "Address Family modifier\n"
12966 "BGP update groups\n"
8fe8a7f6 12967 "Specific subgroup to display info for\n"
3f9c7369
DS
12968 "Advertisement queue\n"
12969 "Announced routes\n"
8fe8a7f6
DS
12970 "Packet queue\n"
12971 "Specific subgroup info wanted for\n")
3f9c7369
DS
12972{
12973 afi_t afi;
12974 safi_t safi;
8fe8a7f6 12975 u_int64_t subgrp_id;
3f9c7369
DS
12976
12977 afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6;
12978 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
8fe8a7f6
DS
12979 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
12980
8386ac43 12981 show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[3], subgrp_id);
8fe8a7f6 12982 return CMD_SUCCESS;
3f9c7369
DS
12983}
12984
8fe8a7f6
DS
12985DEFUN (show_bgp_updgrps_adj_s,
12986 show_bgp_updgrps_adj_s_cmd,
12987 "show bgp update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
12988 SHOW_STR
12989 BGP_STR
12990 "BGP update groups\n"
12991 "Specific subgroup to display info for\n"
12992 "Advertisement queue\n"
12993 "Announced routes\n"
12994 "Packet queue\n")
12995{
12996 u_int64_t subgrp_id;
12997
12998 VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]);
12999
8386ac43 13000 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[1], subgrp_id);
8fe8a7f6
DS
13001 return CMD_SUCCESS;
13002}
13003
8386ac43 13004DEFUN (show_bgp_instance_updgrps_adj_s,
13005 show_bgp_instance_updgrps_adj_s_cmd,
13006 "show bgp " BGP_INSTANCE_CMD " update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
13007 SHOW_STR
13008 BGP_STR
13009 BGP_INSTANCE_HELP_STR
13010 "BGP update groups\n"
13011 "Specific subgroup to display info for\n"
13012 "Advertisement queue\n"
13013 "Announced routes\n"
13014 "Packet queue\n")
13015{
13016 u_int64_t subgrp_id;
13017
13018 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
13019
13020 show_bgp_updgrps_adj_info_aux(vty, argv[1], AFI_IP6, SAFI_UNICAST, argv[3], subgrp_id);
13021 return CMD_SUCCESS;
13022}
13023
13024
8fe8a7f6 13025
f14e6fdb
DS
13026static int
13027bgp_show_one_peer_group (struct vty *vty, struct peer_group *group)
13028{
13029 struct listnode *node, *nnode;
13030 struct prefix *range;
13031 struct peer *conf;
13032 struct peer *peer;
4690c7d7 13033 char buf[PREFIX2STR_BUFFER];
f14e6fdb
DS
13034 afi_t afi;
13035 safi_t safi;
ffd0c037
DS
13036 const char *peer_status;
13037 const char *af_str;
f14e6fdb
DS
13038 int lr_count;
13039 int dynamic;
13040 int af_cfgd;
13041
13042 conf = group->conf;
13043
0299c004
DS
13044 if (conf->as_type == AS_SPECIFIED ||
13045 conf->as_type == AS_EXTERNAL) {
66b199b2 13046 vty_out (vty, "%sBGP peer-group %s, remote AS %d%s",
f14e6fdb 13047 VTY_NEWLINE, group->name, conf->as, VTY_NEWLINE);
0299c004 13048 } else if (conf->as_type == AS_INTERNAL) {
66b199b2 13049 vty_out (vty, "%sBGP peer-group %s, remote AS %d%s",
0299c004 13050 VTY_NEWLINE, group->name, group->bgp->as, VTY_NEWLINE);
66b199b2
DS
13051 } else {
13052 vty_out (vty, "%sBGP peer-group %s%s",
13053 VTY_NEWLINE, group->name, VTY_NEWLINE);
0299c004 13054 }
f14e6fdb 13055
0299c004 13056 if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL))
f14e6fdb
DS
13057 vty_out (vty, " Peer-group type is internal%s", VTY_NEWLINE);
13058 else
13059 vty_out (vty, " Peer-group type is external%s", VTY_NEWLINE);
13060
13061 /* Display AFs configured. */
13062 vty_out (vty, " Configured address-families:");
13063 for (afi = AFI_IP; afi < AFI_MAX; afi++)
13064 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
13065 {
13066 if (conf->afc[afi][safi])
13067 {
13068 af_cfgd = 1;
13069 vty_out (vty, " %s;", afi_safi_print(afi, safi));
13070 }
13071 }
13072 if (!af_cfgd)
13073 vty_out (vty, " none%s", VTY_NEWLINE);
13074 else
13075 vty_out (vty, "%s", VTY_NEWLINE);
13076
13077 /* Display listen ranges (for dynamic neighbors), if any */
13078 for (afi = AFI_IP; afi < AFI_MAX; afi++)
13079 {
13080 if (afi == AFI_IP)
13081 af_str = "IPv4";
13082 else if (afi == AFI_IP6)
13083 af_str = "IPv6";
13084 lr_count = listcount(group->listen_range[afi]);
13085 if (lr_count)
13086 {
13087 vty_out(vty,
13088 " %d %s listen range(s)%s",
13089 lr_count, af_str, VTY_NEWLINE);
13090
13091
13092 for (ALL_LIST_ELEMENTS (group->listen_range[afi], node,
13093 nnode, range))
13094 {
13095 prefix2str(range, buf, sizeof(buf));
13096 vty_out(vty, " %s%s", buf, VTY_NEWLINE);
13097 }
13098 }
13099 }
13100
13101 /* Display group members and their status */
13102 if (listcount(group->peer))
13103 {
13104 vty_out (vty, " Peer-group members:%s", VTY_NEWLINE);
13105 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
13106 {
13107 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
13108 peer_status = "Idle (Admin)";
13109 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
13110 peer_status = "Idle (PfxCt)";
13111 else
13112 peer_status = LOOKUP(bgp_status_msg, peer->status);
13113
13114 dynamic = peer_dynamic_neighbor(peer);
13115 vty_out (vty, " %s %s %s %s",
13116 peer->host, dynamic ? "(dynamic)" : "",
13117 peer_status, VTY_NEWLINE);
13118 }
13119 }
13120
13121 return CMD_SUCCESS;
13122}
13123
13124/* Show BGP peer group's information. */
13125enum show_group_type
13126{
13127 show_all_groups,
13128 show_peer_group
13129};
13130
13131static int
13132bgp_show_peer_group (struct vty *vty, struct bgp *bgp,
13133 enum show_group_type type, const char *group_name)
13134{
13135 struct listnode *node, *nnode;
13136 struct peer_group *group;
13137 int find = 0;
13138
13139 for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
13140 {
13141 switch (type)
13142 {
13143 case show_all_groups:
13144 bgp_show_one_peer_group (vty, group);
13145 break;
13146 case show_peer_group:
13147 if (group_name && (strcmp(group->name, group_name) == 0))
13148 {
13149 find = 1;
13150 bgp_show_one_peer_group (vty, group);
13151 }
13152 break;
13153 }
13154 }
13155
13156 if (type == show_peer_group && ! find)
13157 vty_out (vty, "%% No such peer-groupr%s", VTY_NEWLINE);
13158
13159 return CMD_SUCCESS;
13160}
13161
13162static int
13163bgp_show_peer_group_vty (struct vty *vty, const char *name,
13164 enum show_group_type type, const char *group_name)
13165{
13166 struct bgp *bgp;
13167 int ret = CMD_SUCCESS;
13168
13169 if (name)
8386ac43 13170 bgp = bgp_lookup_by_name (name);
13171 else
13172 bgp = bgp_get_default ();
f14e6fdb 13173
8386ac43 13174 if (! bgp)
13175 {
13176 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
13177 return CMD_WARNING;
f14e6fdb
DS
13178 }
13179
8386ac43 13180 ret = bgp_show_peer_group (vty, bgp, type, group_name);
f14e6fdb
DS
13181
13182 return ret;
13183}
13184
13185DEFUN (show_ip_bgp_peer_groups,
13186 show_ip_bgp_peer_groups_cmd,
13187 "show ip bgp peer-group",
13188 SHOW_STR
13189 IP_STR
13190 BGP_STR
13191 "Detailed information on all BGP peer groups\n")
13192{
13193 return bgp_show_peer_group_vty (vty, NULL, show_all_groups, NULL);
13194}
13195
13196DEFUN (show_ip_bgp_instance_peer_groups,
13197 show_ip_bgp_instance_peer_groups_cmd,
8386ac43 13198 "show ip bgp " BGP_INSTANCE_CMD " peer-group",
f14e6fdb
DS
13199 SHOW_STR
13200 IP_STR
13201 BGP_STR
8386ac43 13202 BGP_INSTANCE_HELP_STR
f14e6fdb
DS
13203 "Detailed information on all BGP peer groups\n")
13204{
8386ac43 13205 return bgp_show_peer_group_vty (vty, argv[1], show_all_groups, NULL);
f14e6fdb
DS
13206}
13207
13208DEFUN (show_ip_bgp_peer_group,
13209 show_ip_bgp_peer_group_cmd,
13210 "show ip bgp peer-group WORD",
13211 SHOW_STR
13212 IP_STR
13213 BGP_STR
13214 "BGP peer-group name\n"
13215 "Detailed information on a BGP peer group\n")
13216{
13217 return bgp_show_peer_group_vty (vty, NULL, show_peer_group, argv[0]);
13218}
13219
13220DEFUN (show_ip_bgp_instance_peer_group,
13221 show_ip_bgp_instance_peer_group_cmd,
8386ac43 13222 "show ip bgp " BGP_INSTANCE_CMD " peer-group WORD",
f14e6fdb
DS
13223 SHOW_STR
13224 IP_STR
13225 BGP_STR
8386ac43 13226 BGP_INSTANCE_HELP_STR
f14e6fdb
DS
13227 "BGP peer-group name\n"
13228 "Detailed information on a BGP peer group\n")
13229{
8386ac43 13230 return bgp_show_peer_group_vty (vty, argv[1], show_peer_group, argv[2]);
f14e6fdb 13231}
3f9c7369 13232
718e3744 13233/* Redistribute VTY commands. */
13234
718e3744 13235DEFUN (bgp_redistribute_ipv4,
13236 bgp_redistribute_ipv4_cmd,
e0ca5fde 13237 "redistribute " QUAGGA_IP_REDIST_STR_BGPD,
718e3744 13238 "Redistribute information from another routing protocol\n"
e0ca5fde 13239 QUAGGA_IP_REDIST_HELP_STR_BGPD)
718e3744 13240{
13241 int type;
13242
e0ca5fde
DL
13243 type = proto_redistnum (AFI_IP, argv[0]);
13244 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 13245 {
13246 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13247 return CMD_WARNING;
13248 }
7c8ff89e 13249 bgp_redist_add(vty->index, AFI_IP, type, 0);
6aeb9e78 13250 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
718e3744 13251}
13252
13253DEFUN (bgp_redistribute_ipv4_rmap,
13254 bgp_redistribute_ipv4_rmap_cmd,
e0ca5fde 13255 "redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD",
718e3744 13256 "Redistribute information from another routing protocol\n"
e0ca5fde 13257 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 13258 "Route map reference\n"
13259 "Pointer to route-map entries\n")
13260{
13261 int type;
7c8ff89e 13262 struct bgp_redist *red;
718e3744 13263
e0ca5fde
DL
13264 type = proto_redistnum (AFI_IP, argv[0]);
13265 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 13266 {
13267 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13268 return CMD_WARNING;
13269 }
13270
7c8ff89e
DS
13271 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
13272 bgp_redistribute_rmap_set (red, argv[1]);
6aeb9e78 13273 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
718e3744 13274}
13275
13276DEFUN (bgp_redistribute_ipv4_metric,
13277 bgp_redistribute_ipv4_metric_cmd,
e0ca5fde 13278 "redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295>",
718e3744 13279 "Redistribute information from another routing protocol\n"
e0ca5fde 13280 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 13281 "Metric for redistributed routes\n"
13282 "Default metric\n")
13283{
13284 int type;
13285 u_int32_t metric;
7c8ff89e 13286 struct bgp_redist *red;
718e3744 13287
e0ca5fde
DL
13288 type = proto_redistnum (AFI_IP, argv[0]);
13289 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 13290 {
13291 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13292 return CMD_WARNING;
13293 }
13294 VTY_GET_INTEGER ("metric", metric, argv[1]);
13295
7c8ff89e 13296 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
caf958b4 13297 bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
6aeb9e78 13298 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
718e3744 13299}
13300
13301DEFUN (bgp_redistribute_ipv4_rmap_metric,
13302 bgp_redistribute_ipv4_rmap_metric_cmd,
e0ca5fde 13303 "redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
718e3744 13304 "Redistribute information from another routing protocol\n"
e0ca5fde 13305 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 13306 "Route map reference\n"
13307 "Pointer to route-map entries\n"
13308 "Metric for redistributed routes\n"
13309 "Default metric\n")
13310{
13311 int type;
13312 u_int32_t metric;
7c8ff89e 13313 struct bgp_redist *red;
718e3744 13314
e0ca5fde
DL
13315 type = proto_redistnum (AFI_IP, argv[0]);
13316 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 13317 {
13318 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13319 return CMD_WARNING;
13320 }
13321 VTY_GET_INTEGER ("metric", metric, argv[2]);
13322
7c8ff89e
DS
13323 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
13324 bgp_redistribute_rmap_set (red, argv[1]);
caf958b4 13325 bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
6aeb9e78 13326 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
718e3744 13327}
13328
13329DEFUN (bgp_redistribute_ipv4_metric_rmap,
13330 bgp_redistribute_ipv4_metric_rmap_cmd,
e0ca5fde 13331 "redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
718e3744 13332 "Redistribute information from another routing protocol\n"
e0ca5fde 13333 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 13334 "Metric for redistributed routes\n"
13335 "Default metric\n"
13336 "Route map reference\n"
13337 "Pointer to route-map entries\n")
13338{
13339 int type;
13340 u_int32_t metric;
7c8ff89e 13341 struct bgp_redist *red;
718e3744 13342
e0ca5fde
DL
13343 type = proto_redistnum (AFI_IP, argv[0]);
13344 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 13345 {
13346 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13347 return CMD_WARNING;
13348 }
13349 VTY_GET_INTEGER ("metric", metric, argv[1]);
13350
7c8ff89e 13351 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
caf958b4 13352 bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
7c8ff89e 13353 bgp_redistribute_rmap_set (red, argv[2]);
6aeb9e78 13354 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
718e3744 13355}
13356
7c8ff89e
DS
13357DEFUN (bgp_redistribute_ipv4_ospf,
13358 bgp_redistribute_ipv4_ospf_cmd,
7a4bb9c5 13359 "redistribute (ospf|table) <1-65535>",
7c8ff89e
DS
13360 "Redistribute information from another routing protocol\n"
13361 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
13362 "Non-main Kernel Routing Table\n"
13363 "Instance ID/Table ID\n")
7c8ff89e
DS
13364{
13365 u_short instance;
7a4bb9c5 13366 u_short protocol;
7c8ff89e 13367
7a4bb9c5
DS
13368 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
13369
13370 if (strncmp(argv[0], "o", 1) == 0)
13371 protocol = ZEBRA_ROUTE_OSPF;
13372 else
13373 protocol = ZEBRA_ROUTE_TABLE;
13374
13375 bgp_redist_add(vty->index, AFI_IP, protocol, instance);
6aeb9e78 13376 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
7c8ff89e
DS
13377}
13378
13379DEFUN (bgp_redistribute_ipv4_ospf_rmap,
13380 bgp_redistribute_ipv4_ospf_rmap_cmd,
7a4bb9c5 13381 "redistribute (ospf|table) <1-65535> route-map WORD",
7c8ff89e
DS
13382 "Redistribute information from another routing protocol\n"
13383 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
13384 "Non-main Kernel Routing Table\n"
13385 "Instance ID/Table ID\n"
7c8ff89e
DS
13386 "Route map reference\n"
13387 "Pointer to route-map entries\n")
13388{
13389 struct bgp_redist *red;
13390 u_short instance;
7a4bb9c5 13391 int protocol;
7c8ff89e 13392
7a4bb9c5
DS
13393 if (strncmp(argv[0], "o", 1) == 0)
13394 protocol = ZEBRA_ROUTE_OSPF;
13395 else
13396 protocol = ZEBRA_ROUTE_TABLE;
13397
13398 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
13399 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
13400 bgp_redistribute_rmap_set (red, argv[2]);
6aeb9e78 13401 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
7c8ff89e
DS
13402}
13403
13404DEFUN (bgp_redistribute_ipv4_ospf_metric,
13405 bgp_redistribute_ipv4_ospf_metric_cmd,
7a4bb9c5 13406 "redistribute (ospf|table) <1-65535> metric <0-4294967295>",
7c8ff89e
DS
13407 "Redistribute information from another routing protocol\n"
13408 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
13409 "Non-main Kernel Routing Table\n"
13410 "Instance ID/Table ID\n"
7c8ff89e
DS
13411 "Metric for redistributed routes\n"
13412 "Default metric\n")
13413{
13414 u_int32_t metric;
13415 struct bgp_redist *red;
13416 u_short instance;
7a4bb9c5 13417 int protocol;
7c8ff89e 13418
7a4bb9c5
DS
13419 if (strncmp(argv[0], "o", 1) == 0)
13420 protocol = ZEBRA_ROUTE_OSPF;
13421 else
13422 protocol = ZEBRA_ROUTE_TABLE;
7c8ff89e 13423
7a4bb9c5
DS
13424 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
13425 VTY_GET_INTEGER ("metric", metric, argv[2]);
13426
13427 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
caf958b4 13428 bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
6aeb9e78 13429 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
7c8ff89e
DS
13430}
13431
13432DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric,
13433 bgp_redistribute_ipv4_ospf_rmap_metric_cmd,
7a4bb9c5 13434 "redistribute (ospf|table) <1-65535> route-map WORD metric <0-4294967295>",
7c8ff89e
DS
13435 "Redistribute information from another routing protocol\n"
13436 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
13437 "Non-main Kernel Routing Table\n"
13438 "Instance ID/Table ID\n"
7c8ff89e
DS
13439 "Route map reference\n"
13440 "Pointer to route-map entries\n"
13441 "Metric for redistributed routes\n"
13442 "Default metric\n")
13443{
13444 u_int32_t metric;
13445 struct bgp_redist *red;
13446 u_short instance;
7a4bb9c5 13447 int protocol;
7c8ff89e 13448
7a4bb9c5
DS
13449 if (strncmp(argv[0], "o", 1) == 0)
13450 protocol = ZEBRA_ROUTE_OSPF;
13451 else
13452 protocol = ZEBRA_ROUTE_TABLE;
7c8ff89e 13453
7a4bb9c5
DS
13454 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
13455 VTY_GET_INTEGER ("metric", metric, argv[3]);
13456
13457 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
13458 bgp_redistribute_rmap_set (red, argv[2]);
caf958b4 13459 bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
6aeb9e78 13460 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
7c8ff89e
DS
13461}
13462
13463DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap,
13464 bgp_redistribute_ipv4_ospf_metric_rmap_cmd,
7a4bb9c5 13465 "redistribute (ospf|table) <1-65535> metric <0-4294967295> route-map WORD",
7c8ff89e
DS
13466 "Redistribute information from another routing protocol\n"
13467 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
13468 "Non-main Kernel Routing Table\n"
13469 "Instance ID/Table ID\n"
7c8ff89e
DS
13470 "Metric for redistributed routes\n"
13471 "Default metric\n"
13472 "Route map reference\n"
13473 "Pointer to route-map entries\n")
13474{
13475 u_int32_t metric;
13476 struct bgp_redist *red;
13477 u_short instance;
7a4bb9c5 13478 int protocol;
7c8ff89e 13479
7a4bb9c5
DS
13480 if (strncmp(argv[0], "o", 1) == 0)
13481 protocol = ZEBRA_ROUTE_OSPF;
13482 else
13483 protocol = ZEBRA_ROUTE_TABLE;
7c8ff89e 13484
7a4bb9c5
DS
13485 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
13486 VTY_GET_INTEGER ("metric", metric, argv[2]);
13487
13488 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
caf958b4 13489 bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
7a4bb9c5 13490 bgp_redistribute_rmap_set (red, argv[3]);
6aeb9e78 13491 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
7c8ff89e
DS
13492}
13493
13494DEFUN (no_bgp_redistribute_ipv4_ospf,
13495 no_bgp_redistribute_ipv4_ospf_cmd,
7a4bb9c5 13496 "no redistribute (ospf|table) <1-65535>",
7c8ff89e
DS
13497 NO_STR
13498 "Redistribute information from another routing protocol\n"
13499 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
13500 "Non-main Kernel Routing Table\n"
13501 "Instance ID/Table ID\n")
7c8ff89e
DS
13502{
13503 u_short instance;
7a4bb9c5
DS
13504 int protocol;
13505
13506 if (strncmp(argv[0], "o", 1) == 0)
13507 protocol = ZEBRA_ROUTE_OSPF;
13508 else
13509 protocol = ZEBRA_ROUTE_TABLE;
7c8ff89e 13510
7a4bb9c5
DS
13511 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
13512 return bgp_redistribute_unset (vty->index, AFI_IP, protocol, instance);
7c8ff89e
DS
13513}
13514
13515ALIAS (no_bgp_redistribute_ipv4_ospf,
13516 no_bgp_redistribute_ipv4_ospf_rmap_cmd,
7a4bb9c5 13517 "no redistribute (ospf|table) <1-65535> route-map WORD",
7c8ff89e
DS
13518 NO_STR
13519 "Redistribute information from another routing protocol\n"
13520 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
13521 "Non-main Kernel Routing Table\n"
13522 "Instance ID/Table ID\n"
7c8ff89e
DS
13523 "Route map reference\n"
13524 "Pointer to route-map entries\n")
13525
13526ALIAS (no_bgp_redistribute_ipv4_ospf,
13527 no_bgp_redistribute_ipv4_ospf_metric_cmd,
7a4bb9c5 13528 "no redistribute (ospf|table) <1-65535> metric <0-4294967295>",
7c8ff89e
DS
13529 NO_STR
13530 "Redistribute information from another routing protocol\n"
13531 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
13532 "Non-main Kernel Routing Table\n"
13533 "Instance ID/Table ID\n"
7c8ff89e
DS
13534 "Metric for redistributed routes\n"
13535 "Default metric\n")
13536
13537ALIAS (no_bgp_redistribute_ipv4_ospf,
13538 no_bgp_redistribute_ipv4_ospf_rmap_metric_cmd,
7a4bb9c5 13539 "no redistribute (ospf|table) <1-65535> route-map WORD metric <0-4294967295>",
7c8ff89e
DS
13540 NO_STR
13541 "Redistribute information from another routing protocol\n"
13542 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
13543 "Non-main Kernel Routing Table\n"
13544 "Instance ID/Table ID\n"
7c8ff89e
DS
13545 "Route map reference\n"
13546 "Pointer to route-map entries\n"
13547 "Metric for redistributed routes\n"
13548 "Default metric\n")
13549
13550ALIAS (no_bgp_redistribute_ipv4_ospf,
13551 no_bgp_redistribute_ipv4_ospf_metric_rmap_cmd,
7a4bb9c5 13552 "no redistribute (ospf|table) <1-65535> metric <0-4294967295> route-map WORD",
7c8ff89e
DS
13553 NO_STR
13554 "Redistribute information from another routing protocol\n"
13555 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
13556 "Non-main Kernel Routing Table\n"
13557 "Instance ID/Table ID\n"
7c8ff89e
DS
13558 "Metric for redistributed routes\n"
13559 "Default metric\n"
13560 "Route map reference\n"
13561 "Pointer to route-map entries\n")
13562
718e3744 13563DEFUN (no_bgp_redistribute_ipv4,
13564 no_bgp_redistribute_ipv4_cmd,
e0ca5fde 13565 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD,
718e3744 13566 NO_STR
13567 "Redistribute information from another routing protocol\n"
e0ca5fde 13568 QUAGGA_IP_REDIST_HELP_STR_BGPD)
718e3744 13569{
13570 int type;
13571
e0ca5fde
DL
13572 type = proto_redistnum (AFI_IP, argv[0]);
13573 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 13574 {
13575 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13576 return CMD_WARNING;
13577 }
7c8ff89e 13578 return bgp_redistribute_unset (vty->index, AFI_IP, type, 0);
718e3744 13579}
13580
503006bc 13581ALIAS (no_bgp_redistribute_ipv4,
718e3744 13582 no_bgp_redistribute_ipv4_rmap_cmd,
e0ca5fde 13583 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD",
718e3744 13584 NO_STR
13585 "Redistribute information from another routing protocol\n"
e0ca5fde 13586 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 13587 "Route map reference\n"
13588 "Pointer to route-map entries\n")
718e3744 13589
503006bc 13590ALIAS (no_bgp_redistribute_ipv4,
718e3744 13591 no_bgp_redistribute_ipv4_metric_cmd,
e0ca5fde 13592 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295>",
718e3744 13593 NO_STR
13594 "Redistribute information from another routing protocol\n"
e0ca5fde 13595 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 13596 "Metric for redistributed routes\n"
13597 "Default metric\n")
718e3744 13598
503006bc 13599ALIAS (no_bgp_redistribute_ipv4,
718e3744 13600 no_bgp_redistribute_ipv4_rmap_metric_cmd,
e0ca5fde 13601 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
718e3744 13602 NO_STR
13603 "Redistribute information from another routing protocol\n"
e0ca5fde 13604 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 13605 "Route map reference\n"
13606 "Pointer to route-map entries\n"
13607 "Metric for redistributed routes\n"
13608 "Default metric\n")
718e3744 13609
503006bc 13610ALIAS (no_bgp_redistribute_ipv4,
718e3744 13611 no_bgp_redistribute_ipv4_metric_rmap_cmd,
e0ca5fde 13612 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
718e3744 13613 NO_STR
13614 "Redistribute information from another routing protocol\n"
e0ca5fde 13615 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 13616 "Metric for redistributed routes\n"
13617 "Default metric\n"
13618 "Route map reference\n"
13619 "Pointer to route-map entries\n")
6b0655a2 13620
718e3744 13621#ifdef HAVE_IPV6
13622DEFUN (bgp_redistribute_ipv6,
13623 bgp_redistribute_ipv6_cmd,
e0ca5fde 13624 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD,
718e3744 13625 "Redistribute information from another routing protocol\n"
e0ca5fde 13626 QUAGGA_IP6_REDIST_HELP_STR_BGPD)
718e3744 13627{
13628 int type;
13629
e0ca5fde
DL
13630 type = proto_redistnum (AFI_IP6, argv[0]);
13631 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 13632 {
13633 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13634 return CMD_WARNING;
13635 }
13636
7c8ff89e 13637 bgp_redist_add(vty->index, AFI_IP6, type, 0);
6aeb9e78 13638 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
718e3744 13639}
13640
13641DEFUN (bgp_redistribute_ipv6_rmap,
13642 bgp_redistribute_ipv6_rmap_cmd,
e0ca5fde 13643 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD",
718e3744 13644 "Redistribute information from another routing protocol\n"
e0ca5fde 13645 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 13646 "Route map reference\n"
13647 "Pointer to route-map entries\n")
13648{
13649 int type;
7c8ff89e 13650 struct bgp_redist *red;
718e3744 13651
e0ca5fde
DL
13652 type = proto_redistnum (AFI_IP6, argv[0]);
13653 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 13654 {
13655 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13656 return CMD_WARNING;
13657 }
13658
7c8ff89e
DS
13659 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
13660 bgp_redistribute_rmap_set (red, argv[1]);
6aeb9e78 13661 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
718e3744 13662}
13663
13664DEFUN (bgp_redistribute_ipv6_metric,
13665 bgp_redistribute_ipv6_metric_cmd,
e0ca5fde 13666 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295>",
718e3744 13667 "Redistribute information from another routing protocol\n"
e0ca5fde 13668 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 13669 "Metric for redistributed routes\n"
13670 "Default metric\n")
13671{
13672 int type;
13673 u_int32_t metric;
7c8ff89e 13674 struct bgp_redist *red;
718e3744 13675
e0ca5fde
DL
13676 type = proto_redistnum (AFI_IP6, argv[0]);
13677 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 13678 {
13679 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13680 return CMD_WARNING;
13681 }
13682 VTY_GET_INTEGER ("metric", metric, argv[1]);
13683
7c8ff89e 13684 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
caf958b4 13685 bgp_redistribute_metric_set(vty->index, red, AFI_IP6, type, metric);
6aeb9e78 13686 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
718e3744 13687}
13688
13689DEFUN (bgp_redistribute_ipv6_rmap_metric,
13690 bgp_redistribute_ipv6_rmap_metric_cmd,
e0ca5fde 13691 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
718e3744 13692 "Redistribute information from another routing protocol\n"
e0ca5fde 13693 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 13694 "Route map reference\n"
13695 "Pointer to route-map entries\n"
13696 "Metric for redistributed routes\n"
13697 "Default metric\n")
13698{
13699 int type;
13700 u_int32_t metric;
7c8ff89e 13701 struct bgp_redist *red;
718e3744 13702
e0ca5fde
DL
13703 type = proto_redistnum (AFI_IP6, argv[0]);
13704 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 13705 {
13706 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13707 return CMD_WARNING;
13708 }
13709 VTY_GET_INTEGER ("metric", metric, argv[2]);
13710
7c8ff89e
DS
13711 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
13712 bgp_redistribute_rmap_set (red, argv[1]);
caf958b4 13713 bgp_redistribute_metric_set(vty->index, red, AFI_IP6, type, metric);
6aeb9e78 13714 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
718e3744 13715}
13716
13717DEFUN (bgp_redistribute_ipv6_metric_rmap,
13718 bgp_redistribute_ipv6_metric_rmap_cmd,
e0ca5fde 13719 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
718e3744 13720 "Redistribute information from another routing protocol\n"
e0ca5fde 13721 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 13722 "Metric for redistributed routes\n"
13723 "Default metric\n"
13724 "Route map reference\n"
13725 "Pointer to route-map entries\n")
13726{
13727 int type;
13728 u_int32_t metric;
7c8ff89e 13729 struct bgp_redist *red;
718e3744 13730
e0ca5fde
DL
13731 type = proto_redistnum (AFI_IP6, argv[0]);
13732 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 13733 {
13734 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13735 return CMD_WARNING;
13736 }
13737 VTY_GET_INTEGER ("metric", metric, argv[1]);
13738
7c8ff89e 13739 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
caf958b4 13740 bgp_redistribute_metric_set(vty->index, red, AFI_IP6, SAFI_UNICAST, metric);
7c8ff89e 13741 bgp_redistribute_rmap_set (red, argv[2]);
6aeb9e78 13742 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
718e3744 13743}
13744
13745DEFUN (no_bgp_redistribute_ipv6,
13746 no_bgp_redistribute_ipv6_cmd,
e0ca5fde 13747 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD,
718e3744 13748 NO_STR
13749 "Redistribute information from another routing protocol\n"
e0ca5fde 13750 QUAGGA_IP6_REDIST_HELP_STR_BGPD)
718e3744 13751{
13752 int type;
13753
e0ca5fde
DL
13754 type = proto_redistnum (AFI_IP6, argv[0]);
13755 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 13756 {
13757 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13758 return CMD_WARNING;
13759 }
13760
7c8ff89e 13761 return bgp_redistribute_unset (vty->index, AFI_IP6, type, 0);
718e3744 13762}
13763
503006bc 13764ALIAS (no_bgp_redistribute_ipv6,
718e3744 13765 no_bgp_redistribute_ipv6_rmap_cmd,
e0ca5fde 13766 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD",
718e3744 13767 NO_STR
13768 "Redistribute information from another routing protocol\n"
e0ca5fde 13769 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 13770 "Route map reference\n"
13771 "Pointer to route-map entries\n")
718e3744 13772
503006bc 13773ALIAS (no_bgp_redistribute_ipv6,
718e3744 13774 no_bgp_redistribute_ipv6_metric_cmd,
e0ca5fde 13775 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295>",
718e3744 13776 NO_STR
13777 "Redistribute information from another routing protocol\n"
e0ca5fde 13778 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 13779 "Metric for redistributed routes\n"
13780 "Default metric\n")
718e3744 13781
503006bc 13782ALIAS (no_bgp_redistribute_ipv6,
718e3744 13783 no_bgp_redistribute_ipv6_rmap_metric_cmd,
e0ca5fde 13784 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
718e3744 13785 NO_STR
13786 "Redistribute information from another routing protocol\n"
e0ca5fde 13787 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 13788 "Route map reference\n"
13789 "Pointer to route-map entries\n"
13790 "Metric for redistributed routes\n"
13791 "Default metric\n")
718e3744 13792
503006bc 13793ALIAS (no_bgp_redistribute_ipv6,
718e3744 13794 no_bgp_redistribute_ipv6_metric_rmap_cmd,
e0ca5fde 13795 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
718e3744 13796 NO_STR
13797 "Redistribute information from another routing protocol\n"
e0ca5fde 13798 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 13799 "Metric for redistributed routes\n"
13800 "Default metric\n"
13801 "Route map reference\n"
13802 "Pointer to route-map entries\n")
13803#endif /* HAVE_IPV6 */
6b0655a2 13804
718e3744 13805int
13806bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi,
13807 safi_t safi, int *write)
13808{
13809 int i;
718e3744 13810
13811 /* Unicast redistribution only. */
13812 if (safi != SAFI_UNICAST)
13813 return 0;
13814
13815 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
13816 {
13817 /* Redistribute BGP does not make sense. */
7c8ff89e 13818 if (i != ZEBRA_ROUTE_BGP)
718e3744 13819 {
7c8ff89e
DS
13820 struct list *red_list;
13821 struct listnode *node;
13822 struct bgp_redist *red;
718e3744 13823
7c8ff89e
DS
13824 red_list = bgp->redist[afi][i];
13825 if (!red_list)
13826 continue;
718e3744 13827
7c8ff89e
DS
13828 for (ALL_LIST_ELEMENTS_RO(red_list, node, red))
13829 {
13830 /* Display "address-family" when it is not yet diplayed. */
13831 bgp_config_write_family_header (vty, afi, safi, write);
13832
13833 /* "redistribute" configuration. */
0b960b4d 13834 vty_out (vty, " redistribute %s", zebra_route_string(i));
7c8ff89e
DS
13835 if (red->instance)
13836 vty_out (vty, " %d", red->instance);
13837 if (red->redist_metric_flag)
13838 vty_out (vty, " metric %u", red->redist_metric);
13839 if (red->rmap.name)
13840 vty_out (vty, " route-map %s", red->rmap.name);
13841 vty_out (vty, "%s", VTY_NEWLINE);
13842 }
718e3744 13843 }
13844 }
13845 return *write;
13846}
6b0655a2 13847
718e3744 13848/* BGP node structure. */
7fc626de 13849static struct cmd_node bgp_node =
718e3744 13850{
13851 BGP_NODE,
13852 "%s(config-router)# ",
13853 1,
13854};
13855
7fc626de 13856static struct cmd_node bgp_ipv4_unicast_node =
718e3744 13857{
13858 BGP_IPV4_NODE,
13859 "%s(config-router-af)# ",
13860 1,
13861};
13862
7fc626de 13863static struct cmd_node bgp_ipv4_multicast_node =
718e3744 13864{
13865 BGP_IPV4M_NODE,
13866 "%s(config-router-af)# ",
13867 1,
13868};
13869
7fc626de 13870static struct cmd_node bgp_ipv6_unicast_node =
718e3744 13871{
13872 BGP_IPV6_NODE,
13873 "%s(config-router-af)# ",
13874 1,
13875};
13876
7fc626de 13877static struct cmd_node bgp_ipv6_multicast_node =
25ffbdc1 13878{
13879 BGP_IPV6M_NODE,
13880 "%s(config-router-af)# ",
13881 1,
13882};
13883
7fc626de 13884static struct cmd_node bgp_vpnv4_node =
718e3744 13885{
13886 BGP_VPNV4_NODE,
13887 "%s(config-router-af)# ",
13888 1
13889};
6b0655a2 13890
1f8ae70b 13891static void community_list_vty (void);
13892
718e3744 13893void
94f2b392 13894bgp_vty_init (void)
718e3744 13895{
718e3744 13896 /* Install bgp top node. */
13897 install_node (&bgp_node, bgp_config_write);
13898 install_node (&bgp_ipv4_unicast_node, NULL);
13899 install_node (&bgp_ipv4_multicast_node, NULL);
13900 install_node (&bgp_ipv6_unicast_node, NULL);
25ffbdc1 13901 install_node (&bgp_ipv6_multicast_node, NULL);
718e3744 13902 install_node (&bgp_vpnv4_node, NULL);
13903
13904 /* Install default VTY commands to new nodes. */
13905 install_default (BGP_NODE);
13906 install_default (BGP_IPV4_NODE);
13907 install_default (BGP_IPV4M_NODE);
13908 install_default (BGP_IPV6_NODE);
25ffbdc1 13909 install_default (BGP_IPV6M_NODE);
718e3744 13910 install_default (BGP_VPNV4_NODE);
13911
13912 /* "bgp multiple-instance" commands. */
13913 install_element (CONFIG_NODE, &bgp_multiple_instance_cmd);
13914 install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd);
13915
13916 /* "bgp config-type" commands. */
13917 install_element (CONFIG_NODE, &bgp_config_type_cmd);
813d4307 13918 install_element (CONFIG_NODE, &no_bgp_config_type_val_cmd);
718e3744 13919
5fe9f963 13920 /* bgp route-map delay-timer commands. */
13921 install_element (CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd);
13922 install_element (CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd);
13923 install_element (CONFIG_NODE, &no_bgp_set_route_map_delay_timer_val_cmd);
13924
718e3744 13925 /* Dummy commands (Currently not supported) */
13926 install_element (BGP_NODE, &no_synchronization_cmd);
13927 install_element (BGP_NODE, &no_auto_summary_cmd);
13928
13929 /* "router bgp" commands. */
13930 install_element (CONFIG_NODE, &router_bgp_cmd);
6aeb9e78 13931 install_element (CONFIG_NODE, &router_bgp_instance_cmd);
2385a876 13932 install_element (CONFIG_NODE, &router_bgp_noasn_cmd);
718e3744 13933
13934 /* "no router bgp" commands. */
13935 install_element (CONFIG_NODE, &no_router_bgp_cmd);
6aeb9e78 13936 install_element (CONFIG_NODE, &no_router_bgp_instance_cmd);
718e3744 13937
13938 /* "bgp router-id" commands. */
13939 install_element (BGP_NODE, &bgp_router_id_cmd);
13940 install_element (BGP_NODE, &no_bgp_router_id_cmd);
13941 install_element (BGP_NODE, &no_bgp_router_id_val_cmd);
13942
13943 /* "bgp cluster-id" commands. */
13944 install_element (BGP_NODE, &bgp_cluster_id_cmd);
13945 install_element (BGP_NODE, &bgp_cluster_id32_cmd);
13946 install_element (BGP_NODE, &no_bgp_cluster_id_cmd);
813d4307
DW
13947 install_element (BGP_NODE, &no_bgp_cluster_id_ip_cmd);
13948 install_element (BGP_NODE, &no_bgp_cluster_id_decimal_cmd);
718e3744 13949
13950 /* "bgp confederation" commands. */
13951 install_element (BGP_NODE, &bgp_confederation_identifier_cmd);
13952 install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd);
13953 install_element (BGP_NODE, &no_bgp_confederation_identifier_arg_cmd);
13954
13955 /* "bgp confederation peers" commands. */
13956 install_element (BGP_NODE, &bgp_confederation_peers_cmd);
13957 install_element (BGP_NODE, &no_bgp_confederation_peers_cmd);
13958
abc920f8
DS
13959 /* bgp max-med command */
13960 install_element (BGP_NODE, &bgp_maxmed_admin_cmd);
13961 install_element (BGP_NODE, &no_bgp_maxmed_admin_cmd);
13962 install_element (BGP_NODE, &bgp_maxmed_admin_medv_cmd);
13963 install_element (BGP_NODE, &no_bgp_maxmed_admin_medv_cmd);
13964 install_element (BGP_NODE, &bgp_maxmed_onstartup_cmd);
13965 install_element (BGP_NODE, &no_bgp_maxmed_onstartup_cmd);
13966 install_element (BGP_NODE, &no_bgp_maxmed_onstartup_period_cmd);
13967 install_element (BGP_NODE, &bgp_maxmed_onstartup_medv_cmd);
13968 install_element (BGP_NODE, &no_bgp_maxmed_onstartup_period_medv_cmd);
13969
907f92c8
DS
13970 /* bgp disable-ebgp-connected-nh-check */
13971 install_element (BGP_NODE, &bgp_disable_connected_route_check_cmd);
13972 install_element (BGP_NODE, &no_bgp_disable_connected_route_check_cmd);
13973
f188f2c4
DS
13974 /* bgp update-delay command */
13975 install_element (BGP_NODE, &bgp_update_delay_cmd);
13976 install_element (BGP_NODE, &no_bgp_update_delay_cmd);
13977 install_element (BGP_NODE, &bgp_update_delay_establish_wait_cmd);
13978 install_element (BGP_NODE, &no_bgp_update_delay_establish_wait_cmd);
13979
cb1faec9
DS
13980 install_element (BGP_NODE, &bgp_wpkt_quanta_cmd);
13981 install_element (BGP_NODE, &no_bgp_wpkt_quanta_cmd);
13982
3f9c7369
DS
13983 install_element (BGP_NODE, &bgp_coalesce_time_cmd);
13984 install_element (BGP_NODE, &no_bgp_coalesce_time_cmd);
13985
165b5fff
JB
13986 /* "maximum-paths" commands. */
13987 install_element (BGP_NODE, &bgp_maxpaths_cmd);
13988 install_element (BGP_NODE, &no_bgp_maxpaths_cmd);
13989 install_element (BGP_NODE, &no_bgp_maxpaths_arg_cmd);
13990 install_element (BGP_IPV4_NODE, &bgp_maxpaths_cmd);
13991 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_cmd);
13992 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_arg_cmd);
431aa9f9
DS
13993 install_element (BGP_IPV6_NODE, &bgp_maxpaths_cmd);
13994 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_cmd);
13995 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_arg_cmd);
165b5fff 13996 install_element (BGP_NODE, &bgp_maxpaths_ibgp_cmd);
5e242b0d 13997 install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
165b5fff
JB
13998 install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cmd);
13999 install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_arg_cmd);
5e242b0d 14000 install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cluster_cmd);
165b5fff 14001 install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd);
5e242b0d 14002 install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
165b5fff 14003 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd);
5e242b0d 14004 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cluster_cmd);
165b5fff 14005 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_arg_cmd);
431aa9f9 14006 install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd);
5e242b0d 14007 install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
431aa9f9
DS
14008 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd);
14009 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_arg_cmd);
5e242b0d 14010 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cluster_cmd);
165b5fff 14011
718e3744 14012 /* "timers bgp" commands. */
14013 install_element (BGP_NODE, &bgp_timers_cmd);
14014 install_element (BGP_NODE, &no_bgp_timers_cmd);
14015 install_element (BGP_NODE, &no_bgp_timers_arg_cmd);
14016
5fe9f963 14017 /* route-map delay-timer commands - per instance for backwards compat. */
518f0eb1
DS
14018 install_element (BGP_NODE, &bgp_set_route_map_delay_timer_cmd);
14019 install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd);
f414725f 14020 install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_val_cmd);
518f0eb1 14021
718e3744 14022 /* "bgp client-to-client reflection" commands */
14023 install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd);
14024 install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd);
14025
14026 /* "bgp always-compare-med" commands */
14027 install_element (BGP_NODE, &bgp_always_compare_med_cmd);
14028 install_element (BGP_NODE, &no_bgp_always_compare_med_cmd);
14029
14030 /* "bgp deterministic-med" commands */
14031 install_element (BGP_NODE, &bgp_deterministic_med_cmd);
14032 install_element (BGP_NODE, &no_bgp_deterministic_med_cmd);
538621f2 14033
538621f2 14034 /* "bgp graceful-restart" commands */
14035 install_element (BGP_NODE, &bgp_graceful_restart_cmd);
14036 install_element (BGP_NODE, &no_bgp_graceful_restart_cmd);
93406d87 14037 install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd);
14038 install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd);
14039 install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_val_cmd);
718e3744 14040
14041 /* "bgp fast-external-failover" commands */
14042 install_element (BGP_NODE, &bgp_fast_external_failover_cmd);
14043 install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd);
14044
14045 /* "bgp enforce-first-as" commands */
14046 install_element (BGP_NODE, &bgp_enforce_first_as_cmd);
14047 install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd);
14048
14049 /* "bgp bestpath compare-routerid" commands */
14050 install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd);
14051 install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd);
14052
14053 /* "bgp bestpath as-path ignore" commands */
14054 install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd);
14055 install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd);
14056
6811845b 14057 /* "bgp bestpath as-path confed" commands */
14058 install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd);
14059 install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd);
14060
2fdd455c
PM
14061 /* "bgp bestpath as-path multipath-relax" commands */
14062 install_element (BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd);
14063 install_element (BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd);
14064
848973c7 14065 /* "bgp log-neighbor-changes" commands */
14066 install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd);
14067 install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd);
14068
718e3744 14069 /* "bgp bestpath med" commands */
14070 install_element (BGP_NODE, &bgp_bestpath_med_cmd);
14071 install_element (BGP_NODE, &bgp_bestpath_med2_cmd);
14072 install_element (BGP_NODE, &bgp_bestpath_med3_cmd);
14073 install_element (BGP_NODE, &no_bgp_bestpath_med_cmd);
14074 install_element (BGP_NODE, &no_bgp_bestpath_med2_cmd);
14075 install_element (BGP_NODE, &no_bgp_bestpath_med3_cmd);
14076
14077 /* "no bgp default ipv4-unicast" commands. */
14078 install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd);
14079 install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd);
14080
14081 /* "bgp network import-check" commands. */
14082 install_element (BGP_NODE, &bgp_network_import_check_cmd);
14083 install_element (BGP_NODE, &no_bgp_network_import_check_cmd);
14084
14085 /* "bgp default local-preference" commands. */
14086 install_element (BGP_NODE, &bgp_default_local_preference_cmd);
14087 install_element (BGP_NODE, &no_bgp_default_local_preference_cmd);
14088 install_element (BGP_NODE, &no_bgp_default_local_preference_val_cmd);
14089
04b6bdc0
DW
14090 /* bgp default show-hostname */
14091 install_element (BGP_NODE, &bgp_default_show_hostname_cmd);
14092 install_element (BGP_NODE, &no_bgp_default_show_hostname_cmd);
14093
3f9c7369
DS
14094 /* "bgp default subgroup-pkt-queue-max" commands. */
14095 install_element (BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd);
14096 install_element (BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd);
813d4307 14097 install_element (BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_val_cmd);
3f9c7369 14098
8bd9d948
DS
14099 /* bgp ibgp-allow-policy-mods command */
14100 install_element (BGP_NODE, &bgp_rr_allow_outbound_policy_cmd);
14101 install_element (BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd);
14102
f14e6fdb
DS
14103 /* "bgp listen limit" commands. */
14104 install_element (BGP_NODE, &bgp_listen_limit_cmd);
14105 install_element (BGP_NODE, &no_bgp_listen_limit_cmd);
813d4307 14106 install_element (BGP_NODE, &no_bgp_listen_limit_val_cmd);
f14e6fdb
DS
14107
14108 /* "bgp listen range" commands. */
14109 install_element (BGP_NODE, &bgp_listen_range_cmd);
14110 install_element (BGP_NODE, &no_bgp_listen_range_cmd);
14111
718e3744 14112 /* "neighbor remote-as" commands. */
14113 install_element (BGP_NODE, &neighbor_remote_as_cmd);
a80beece 14114 install_element (BGP_NODE, &neighbor_interface_config_cmd);
4c48cf63
DW
14115 install_element (BGP_NODE, &neighbor_interface_config_v6only_cmd);
14116 install_element (BGP_NODE, &neighbor_interface_config_peergroup_cmd);
14117 install_element (BGP_NODE, &neighbor_interface_config_v6only_peergroup_cmd);
718e3744 14118 install_element (BGP_NODE, &no_neighbor_cmd);
14119 install_element (BGP_NODE, &no_neighbor_remote_as_cmd);
a80beece 14120 install_element (BGP_NODE, &no_neighbor_interface_config_cmd);
4c48cf63
DW
14121 install_element (BGP_NODE, &no_neighbor_interface_config_v6only_cmd);
14122 install_element (BGP_NODE, &no_neighbor_interface_config_peergroup_cmd);
14123 install_element (BGP_NODE, &no_neighbor_interface_config_v6only_peergroup_cmd);
718e3744 14124
14125 /* "neighbor peer-group" commands. */
14126 install_element (BGP_NODE, &neighbor_peer_group_cmd);
14127 install_element (BGP_NODE, &no_neighbor_peer_group_cmd);
a80beece 14128 install_element (BGP_NODE, &no_neighbor_interface_peer_group_remote_as_cmd);
718e3744 14129
14130 /* "neighbor local-as" commands. */
14131 install_element (BGP_NODE, &neighbor_local_as_cmd);
14132 install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd);
9d3f9705 14133 install_element (BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd);
718e3744 14134 install_element (BGP_NODE, &no_neighbor_local_as_cmd);
14135 install_element (BGP_NODE, &no_neighbor_local_as_val_cmd);
14136 install_element (BGP_NODE, &no_neighbor_local_as_val2_cmd);
9d3f9705 14137 install_element (BGP_NODE, &no_neighbor_local_as_val3_cmd);
718e3744 14138
3f9c7369
DS
14139 /* "neighbor solo" commands. */
14140 install_element (BGP_NODE, &neighbor_solo_cmd);
14141 install_element (BGP_NODE, &no_neighbor_solo_cmd);
14142
0df7c91f
PJ
14143 /* "neighbor password" commands. */
14144 install_element (BGP_NODE, &neighbor_password_cmd);
14145 install_element (BGP_NODE, &no_neighbor_password_cmd);
813d4307 14146 install_element (BGP_NODE, &no_neighbor_password_val_cmd);
0df7c91f 14147
718e3744 14148 /* "neighbor activate" commands. */
14149 install_element (BGP_NODE, &neighbor_activate_cmd);
14150 install_element (BGP_IPV4_NODE, &neighbor_activate_cmd);
14151 install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd);
14152 install_element (BGP_IPV6_NODE, &neighbor_activate_cmd);
25ffbdc1 14153 install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd);
718e3744 14154 install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd);
14155
14156 /* "no neighbor activate" commands. */
14157 install_element (BGP_NODE, &no_neighbor_activate_cmd);
14158 install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd);
14159 install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd);
14160 install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd);
25ffbdc1 14161 install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd);
718e3744 14162 install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd);
14163
c8560b44
DW
14164 /* "neighbor peer-group" set commands.
14165 * Long term we should only accept this command under BGP_NODE and not all of
14166 * the afi/safi sub-contexts. For now though we need to accept it for backwards
14167 * compatibility. This changed when we stopped requiring that peers be assigned
14168 * to their peer-group under each address-family sub-context.
14169 */
718e3744 14170 install_element (BGP_NODE, &neighbor_set_peer_group_cmd);
14171 install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_cmd);
14172 install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_cmd);
14173 install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd);
25ffbdc1 14174 install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_cmd);
a58545bb 14175 install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_cmd);
c8560b44 14176
718e3744 14177 /* "no neighbor peer-group unset" commands. */
14178 install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd);
14179 install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd);
14180 install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_cmd);
14181 install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd);
25ffbdc1 14182 install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_cmd);
a58545bb 14183 install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_cmd);
14184
718e3744 14185 /* "neighbor softreconfiguration inbound" commands.*/
14186 install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd);
14187 install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd);
14188 install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd);
14189 install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
14190 install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd);
14191 install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd);
14192 install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd);
14193 install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
25ffbdc1 14194 install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd);
14195 install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd);
a58545bb 14196 install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd);
14197 install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
718e3744 14198
14199 /* "neighbor attribute-unchanged" commands. */
14200 install_element (BGP_NODE, &neighbor_attr_unchanged_cmd);
14201 install_element (BGP_NODE, &neighbor_attr_unchanged1_cmd);
14202 install_element (BGP_NODE, &neighbor_attr_unchanged2_cmd);
14203 install_element (BGP_NODE, &neighbor_attr_unchanged3_cmd);
14204 install_element (BGP_NODE, &neighbor_attr_unchanged4_cmd);
14205 install_element (BGP_NODE, &neighbor_attr_unchanged5_cmd);
14206 install_element (BGP_NODE, &neighbor_attr_unchanged6_cmd);
14207 install_element (BGP_NODE, &neighbor_attr_unchanged7_cmd);
14208 install_element (BGP_NODE, &neighbor_attr_unchanged8_cmd);
14209 install_element (BGP_NODE, &neighbor_attr_unchanged9_cmd);
14210 install_element (BGP_NODE, &neighbor_attr_unchanged10_cmd);
14211 install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd);
14212 install_element (BGP_NODE, &no_neighbor_attr_unchanged1_cmd);
14213 install_element (BGP_NODE, &no_neighbor_attr_unchanged2_cmd);
14214 install_element (BGP_NODE, &no_neighbor_attr_unchanged3_cmd);
14215 install_element (BGP_NODE, &no_neighbor_attr_unchanged4_cmd);
14216 install_element (BGP_NODE, &no_neighbor_attr_unchanged5_cmd);
14217 install_element (BGP_NODE, &no_neighbor_attr_unchanged6_cmd);
14218 install_element (BGP_NODE, &no_neighbor_attr_unchanged7_cmd);
14219 install_element (BGP_NODE, &no_neighbor_attr_unchanged8_cmd);
14220 install_element (BGP_NODE, &no_neighbor_attr_unchanged9_cmd);
14221 install_element (BGP_NODE, &no_neighbor_attr_unchanged10_cmd);
14222 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd);
14223 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged1_cmd);
14224 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged2_cmd);
14225 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged3_cmd);
14226 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged4_cmd);
14227 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged5_cmd);
14228 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged6_cmd);
14229 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged7_cmd);
14230 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged8_cmd);
14231 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged9_cmd);
14232 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged10_cmd);
14233 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd);
14234 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged1_cmd);
14235 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged2_cmd);
14236 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged3_cmd);
14237 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged4_cmd);
14238 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged5_cmd);
14239 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged6_cmd);
14240 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged7_cmd);
14241 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged8_cmd);
14242 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged9_cmd);
14243 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged10_cmd);
14244 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd);
14245 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged1_cmd);
14246 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged2_cmd);
14247 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged3_cmd);
14248 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged4_cmd);
14249 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged5_cmd);
14250 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged6_cmd);
14251 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged7_cmd);
14252 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged8_cmd);
14253 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged9_cmd);
14254 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged10_cmd);
14255 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd);
14256 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged1_cmd);
14257 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged2_cmd);
14258 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged3_cmd);
14259 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged4_cmd);
14260 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged5_cmd);
14261 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged6_cmd);
14262 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged7_cmd);
14263 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged8_cmd);
14264 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged9_cmd);
14265 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged10_cmd);
14266 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd);
14267 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged1_cmd);
14268 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged2_cmd);
14269 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged3_cmd);
14270 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged4_cmd);
14271 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged5_cmd);
14272 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged6_cmd);
14273 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged7_cmd);
14274 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged8_cmd);
14275 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged9_cmd);
14276 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged10_cmd);
14277 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd);
14278 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged1_cmd);
14279 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged2_cmd);
14280 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged3_cmd);
14281 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged4_cmd);
14282 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged5_cmd);
14283 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged6_cmd);
14284 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged7_cmd);
14285 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged8_cmd);
14286 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged9_cmd);
14287 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged10_cmd);
25ffbdc1 14288 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd);
14289 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged1_cmd);
14290 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged2_cmd);
14291 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged3_cmd);
14292 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged4_cmd);
14293 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged5_cmd);
14294 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged6_cmd);
14295 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged7_cmd);
14296 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged8_cmd);
14297 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged9_cmd);
14298 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged10_cmd);
14299 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd);
14300 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged1_cmd);
14301 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged2_cmd);
14302 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged3_cmd);
14303 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged4_cmd);
14304 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged5_cmd);
14305 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged6_cmd);
14306 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged7_cmd);
14307 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged8_cmd);
14308 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged9_cmd);
14309 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged10_cmd);
718e3744 14310 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd);
14311 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged1_cmd);
14312 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged2_cmd);
14313 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged3_cmd);
14314 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged4_cmd);
14315 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged5_cmd);
14316 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged6_cmd);
14317 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged7_cmd);
14318 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged8_cmd);
14319 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged9_cmd);
14320 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged10_cmd);
14321 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd);
14322 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged1_cmd);
14323 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged2_cmd);
14324 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged3_cmd);
14325 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged4_cmd);
14326 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged5_cmd);
14327 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged6_cmd);
14328 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged7_cmd);
14329 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged8_cmd);
14330 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged9_cmd);
14331 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged10_cmd);
14332
fee0f4c6 14333 /* "nexthop-local unchanged" commands */
14334 install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd);
14335 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd);
14336
718e3744 14337 /* "neighbor next-hop-self" commands. */
14338 install_element (BGP_NODE, &neighbor_nexthop_self_cmd);
14339 install_element (BGP_NODE, &no_neighbor_nexthop_self_cmd);
14340 install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd);
14341 install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd);
14342 install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd);
14343 install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd);
14344 install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd);
14345 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd);
25ffbdc1 14346 install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd);
14347 install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd);
718e3744 14348 install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd);
14349 install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd);
14350
a538debe
DS
14351 /* "neighbor next-hop-self force" commands. */
14352 install_element (BGP_NODE, &neighbor_nexthop_self_force_cmd);
14353 install_element (BGP_NODE, &no_neighbor_nexthop_self_force_cmd);
14354 install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd);
14355 install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd);
14356 install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd);
14357 install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd);
14358 install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd);
14359 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd);
14360 install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd);
14361 install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd);
14362 install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd);
14363 install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd);
14364
c7122e14
DS
14365 /* "neighbor as-override" commands. */
14366 install_element (BGP_NODE, &neighbor_as_override_cmd);
14367 install_element (BGP_NODE, &no_neighbor_as_override_cmd);
14368 install_element (BGP_IPV4_NODE, &neighbor_as_override_cmd);
14369 install_element (BGP_IPV4_NODE, &no_neighbor_as_override_cmd);
14370 install_element (BGP_IPV4M_NODE, &neighbor_as_override_cmd);
14371 install_element (BGP_IPV4M_NODE, &no_neighbor_as_override_cmd);
14372 install_element (BGP_IPV6_NODE, &neighbor_as_override_cmd);
14373 install_element (BGP_IPV6_NODE, &no_neighbor_as_override_cmd);
14374 install_element (BGP_IPV6M_NODE, &neighbor_as_override_cmd);
14375 install_element (BGP_IPV6M_NODE, &no_neighbor_as_override_cmd);
14376 install_element (BGP_VPNV4_NODE, &neighbor_as_override_cmd);
14377 install_element (BGP_VPNV4_NODE, &no_neighbor_as_override_cmd);
14378
718e3744 14379 /* "neighbor remove-private-AS" commands. */
14380 install_element (BGP_NODE, &neighbor_remove_private_as_cmd);
14381 install_element (BGP_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
14382 install_element (BGP_NODE, &neighbor_remove_private_as_all_cmd);
14383 install_element (BGP_NODE, &no_neighbor_remove_private_as_all_cmd);
14384 install_element (BGP_NODE, &neighbor_remove_private_as_replace_as_cmd);
14385 install_element (BGP_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
14386 install_element (BGP_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
14387 install_element (BGP_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 14388 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd);
14389 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
14390 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd);
14391 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd);
14392 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_replace_as_cmd);
14393 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
14394 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
14395 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 14396 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd);
14397 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
14398 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd);
14399 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd);
14400 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_replace_as_cmd);
14401 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
14402 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
14403 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 14404 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd);
14405 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
14406 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd);
14407 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd);
14408 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_replace_as_cmd);
14409 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
14410 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
14411 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
25ffbdc1 14412 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd);
14413 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
14414 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd);
14415 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd);
14416 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_replace_as_cmd);
14417 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
14418 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
14419 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 14420 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd);
14421 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
14422 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd);
14423 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd);
14424 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_replace_as_cmd);
14425 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
14426 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
14427 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 14428
14429 /* "neighbor send-community" commands.*/
14430 install_element (BGP_NODE, &neighbor_send_community_cmd);
14431 install_element (BGP_NODE, &neighbor_send_community_type_cmd);
14432 install_element (BGP_NODE, &no_neighbor_send_community_cmd);
14433 install_element (BGP_NODE, &no_neighbor_send_community_type_cmd);
14434 install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd);
14435 install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd);
14436 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd);
14437 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd);
14438 install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd);
14439 install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd);
14440 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd);
14441 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd);
14442 install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd);
14443 install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd);
14444 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd);
14445 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd);
25ffbdc1 14446 install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd);
14447 install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd);
14448 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd);
14449 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd);
718e3744 14450 install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd);
14451 install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd);
14452 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd);
14453 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd);
14454
14455 /* "neighbor route-reflector" commands.*/
14456 install_element (BGP_NODE, &neighbor_route_reflector_client_cmd);
14457 install_element (BGP_NODE, &no_neighbor_route_reflector_client_cmd);
14458 install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd);
14459 install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd);
14460 install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd);
14461 install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd);
14462 install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd);
14463 install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd);
25ffbdc1 14464 install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd);
14465 install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd);
718e3744 14466 install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd);
14467 install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd);
14468
14469 /* "neighbor route-server" commands.*/
14470 install_element (BGP_NODE, &neighbor_route_server_client_cmd);
14471 install_element (BGP_NODE, &no_neighbor_route_server_client_cmd);
14472 install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd);
14473 install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd);
14474 install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd);
14475 install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd);
14476 install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd);
14477 install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd);
25ffbdc1 14478 install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd);
14479 install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd);
718e3744 14480 install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd);
14481 install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd);
14482
adbac85e
DW
14483 /* "neighbor addpath-tx-all-paths" commands.*/
14484 install_element (BGP_NODE, &neighbor_addpath_tx_all_paths_cmd);
14485 install_element (BGP_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
14486 install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd);
14487 install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
14488 install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd);
14489 install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
14490 install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd);
14491 install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
14492 install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd);
14493 install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
14494 install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd);
14495 install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
14496
06370dac
DW
14497 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
14498 install_element (BGP_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14499 install_element (BGP_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
14500 install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14501 install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
14502 install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14503 install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
14504 install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14505 install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
14506 install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14507 install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
14508 install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14509 install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
14510
718e3744 14511 /* "neighbor passive" commands. */
14512 install_element (BGP_NODE, &neighbor_passive_cmd);
14513 install_element (BGP_NODE, &no_neighbor_passive_cmd);
14514
d5a5c8f0 14515
718e3744 14516 /* "neighbor shutdown" commands. */
14517 install_element (BGP_NODE, &neighbor_shutdown_cmd);
14518 install_element (BGP_NODE, &no_neighbor_shutdown_cmd);
14519
8a92a8a0
DS
14520 /* "neighbor capability extended-nexthop" commands.*/
14521 install_element (BGP_NODE, &neighbor_capability_enhe_cmd);
14522 install_element (BGP_NODE, &no_neighbor_capability_enhe_cmd);
14523
718e3744 14524 /* "neighbor capability orf prefix-list" commands.*/
14525 install_element (BGP_NODE, &neighbor_capability_orf_prefix_cmd);
14526 install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_cmd);
14527 install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd);
14528 install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd);
14529 install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd);
14530 install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd);
14531 install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd);
14532 install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd);
25ffbdc1 14533 install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd);
14534 install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd);
718e3744 14535
14536 /* "neighbor capability dynamic" commands.*/
14537 install_element (BGP_NODE, &neighbor_capability_dynamic_cmd);
14538 install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd);
14539
14540 /* "neighbor dont-capability-negotiate" commands. */
14541 install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd);
14542 install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd);
14543
14544 /* "neighbor ebgp-multihop" commands. */
14545 install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd);
14546 install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd);
14547 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd);
14548 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_ttl_cmd);
14549
6ffd2079 14550 /* "neighbor disable-connected-check" commands. */
14551 install_element (BGP_NODE, &neighbor_disable_connected_check_cmd);
14552 install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd);
718e3744 14553 install_element (BGP_NODE, &neighbor_enforce_multihop_cmd);
14554 install_element (BGP_NODE, &no_neighbor_enforce_multihop_cmd);
14555
14556 /* "neighbor description" commands. */
14557 install_element (BGP_NODE, &neighbor_description_cmd);
14558 install_element (BGP_NODE, &no_neighbor_description_cmd);
14559 install_element (BGP_NODE, &no_neighbor_description_val_cmd);
14560
14561 /* "neighbor update-source" commands. "*/
14562 install_element (BGP_NODE, &neighbor_update_source_cmd);
14563 install_element (BGP_NODE, &no_neighbor_update_source_cmd);
14564
14565 /* "neighbor default-originate" commands. */
14566 install_element (BGP_NODE, &neighbor_default_originate_cmd);
14567 install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd);
14568 install_element (BGP_NODE, &no_neighbor_default_originate_cmd);
14569 install_element (BGP_NODE, &no_neighbor_default_originate_rmap_cmd);
14570 install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd);
14571 install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd);
14572 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd);
14573 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_rmap_cmd);
14574 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd);
14575 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd);
14576 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd);
14577 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_rmap_cmd);
14578 install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd);
14579 install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd);
14580 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd);
14581 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_rmap_cmd);
25ffbdc1 14582 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd);
14583 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd);
14584 install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd);
14585 install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_rmap_cmd);
718e3744 14586
14587 /* "neighbor port" commands. */
14588 install_element (BGP_NODE, &neighbor_port_cmd);
14589 install_element (BGP_NODE, &no_neighbor_port_cmd);
14590 install_element (BGP_NODE, &no_neighbor_port_val_cmd);
14591
14592 /* "neighbor weight" commands. */
14593 install_element (BGP_NODE, &neighbor_weight_cmd);
14594 install_element (BGP_NODE, &no_neighbor_weight_cmd);
14595 install_element (BGP_NODE, &no_neighbor_weight_val_cmd);
14596
14597 /* "neighbor override-capability" commands. */
14598 install_element (BGP_NODE, &neighbor_override_capability_cmd);
14599 install_element (BGP_NODE, &no_neighbor_override_capability_cmd);
14600
14601 /* "neighbor strict-capability-match" commands. */
14602 install_element (BGP_NODE, &neighbor_strict_capability_cmd);
14603 install_element (BGP_NODE, &no_neighbor_strict_capability_cmd);
14604
14605 /* "neighbor timers" commands. */
14606 install_element (BGP_NODE, &neighbor_timers_cmd);
14607 install_element (BGP_NODE, &no_neighbor_timers_cmd);
813d4307 14608 install_element (BGP_NODE, &no_neighbor_timers_val_cmd);
718e3744 14609
14610 /* "neighbor timers connect" commands. */
14611 install_element (BGP_NODE, &neighbor_timers_connect_cmd);
14612 install_element (BGP_NODE, &no_neighbor_timers_connect_cmd);
14613 install_element (BGP_NODE, &no_neighbor_timers_connect_val_cmd);
14614
14615 /* "neighbor advertisement-interval" commands. */
14616 install_element (BGP_NODE, &neighbor_advertise_interval_cmd);
14617 install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd);
14618 install_element (BGP_NODE, &no_neighbor_advertise_interval_val_cmd);
14619
718e3744 14620 /* "neighbor interface" commands. */
14621 install_element (BGP_NODE, &neighbor_interface_cmd);
14622 install_element (BGP_NODE, &no_neighbor_interface_cmd);
14623
14624 /* "neighbor distribute" commands. */
14625 install_element (BGP_NODE, &neighbor_distribute_list_cmd);
14626 install_element (BGP_NODE, &no_neighbor_distribute_list_cmd);
14627 install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd);
14628 install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd);
14629 install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd);
14630 install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd);
14631 install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd);
14632 install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd);
25ffbdc1 14633 install_element (BGP_IPV6M_NODE, &neighbor_distribute_list_cmd);
14634 install_element (BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd);
718e3744 14635 install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd);
14636 install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd);
14637
14638 /* "neighbor prefix-list" commands. */
14639 install_element (BGP_NODE, &neighbor_prefix_list_cmd);
14640 install_element (BGP_NODE, &no_neighbor_prefix_list_cmd);
14641 install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd);
14642 install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd);
14643 install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd);
14644 install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd);
14645 install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd);
14646 install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd);
25ffbdc1 14647 install_element (BGP_IPV6M_NODE, &neighbor_prefix_list_cmd);
14648 install_element (BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd);
718e3744 14649 install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd);
14650 install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd);
14651
14652 /* "neighbor filter-list" commands. */
14653 install_element (BGP_NODE, &neighbor_filter_list_cmd);
14654 install_element (BGP_NODE, &no_neighbor_filter_list_cmd);
14655 install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd);
14656 install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd);
14657 install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd);
14658 install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd);
14659 install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd);
14660 install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd);
25ffbdc1 14661 install_element (BGP_IPV6M_NODE, &neighbor_filter_list_cmd);
14662 install_element (BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd);
718e3744 14663 install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd);
14664 install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd);
14665
14666 /* "neighbor route-map" commands. */
14667 install_element (BGP_NODE, &neighbor_route_map_cmd);
14668 install_element (BGP_NODE, &no_neighbor_route_map_cmd);
14669 install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd);
14670 install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd);
14671 install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd);
14672 install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd);
14673 install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd);
14674 install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd);
25ffbdc1 14675 install_element (BGP_IPV6M_NODE, &neighbor_route_map_cmd);
14676 install_element (BGP_IPV6M_NODE, &no_neighbor_route_map_cmd);
718e3744 14677 install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd);
14678 install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd);
14679
14680 /* "neighbor unsuppress-map" commands. */
14681 install_element (BGP_NODE, &neighbor_unsuppress_map_cmd);
14682 install_element (BGP_NODE, &no_neighbor_unsuppress_map_cmd);
14683 install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd);
14684 install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd);
14685 install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd);
14686 install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd);
14687 install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd);
14688 install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd);
25ffbdc1 14689 install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd);
14690 install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd);
a58545bb 14691 install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd);
14692 install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd);
718e3744 14693
14694 /* "neighbor maximum-prefix" commands. */
14695 install_element (BGP_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 14696 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 14697 install_element (BGP_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 14698 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 14699 install_element (BGP_NODE, &neighbor_maximum_prefix_restart_cmd);
14700 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 14701 install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd);
14702 install_element (BGP_NODE, &no_neighbor_maximum_prefix_val_cmd);
0a486e5f 14703 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
14704 install_element (BGP_NODE, &no_neighbor_maximum_prefix_warning_cmd);
14705 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
14706 install_element (BGP_NODE, &no_neighbor_maximum_prefix_restart_cmd);
14707 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 14708 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 14709 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 14710 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 14711 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 14712 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd);
14713 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 14714 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd);
14715 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
0a486e5f 14716 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
14717 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
14718 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
14719 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
14720 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 14721 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 14722 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 14723 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 14724 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 14725 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd);
14726 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 14727 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd);
14728 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_val_cmd);
0a486e5f 14729 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
14730 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_warning_cmd);
14731 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
14732 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_restart_cmd);
14733 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 14734 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 14735 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 14736 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 14737 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 14738 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd);
14739 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 14740 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd);
14741 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_val_cmd);
0a486e5f 14742 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
14743 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_warning_cmd);
14744 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
14745 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_restart_cmd);
14746 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
25ffbdc1 14747 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd);
14748 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd);
14749 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd);
14750 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
14751 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd);
14752 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
14753 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd);
14754 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_val_cmd);
14755 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
14756 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_warning_cmd);
14757 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
14758 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_restart_cmd);
14759 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 14760 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 14761 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 14762 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 14763 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 14764 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd);
14765 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 14766 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd);
14767 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
0a486e5f 14768 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
14769 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
14770 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
14771 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
14772 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 14773
14774 /* "neighbor allowas-in" */
14775 install_element (BGP_NODE, &neighbor_allowas_in_cmd);
14776 install_element (BGP_NODE, &neighbor_allowas_in_arg_cmd);
14777 install_element (BGP_NODE, &no_neighbor_allowas_in_cmd);
813d4307 14778 install_element (BGP_NODE, &no_neighbor_allowas_in_val_cmd);
718e3744 14779 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd);
14780 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_arg_cmd);
14781 install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd);
813d4307 14782 install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_val_cmd);
718e3744 14783 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd);
14784 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_arg_cmd);
14785 install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd);
813d4307 14786 install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_val_cmd);
718e3744 14787 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd);
14788 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_arg_cmd);
14789 install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd);
813d4307 14790 install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_val_cmd);
25ffbdc1 14791 install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd);
14792 install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_arg_cmd);
14793 install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd);
813d4307 14794 install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_val_cmd);
718e3744 14795 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd);
14796 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_arg_cmd);
14797 install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd);
813d4307 14798 install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_val_cmd);
718e3744 14799
14800 /* address-family commands. */
14801 install_element (BGP_NODE, &address_family_ipv4_cmd);
14802 install_element (BGP_NODE, &address_family_ipv4_safi_cmd);
14803#ifdef HAVE_IPV6
14804 install_element (BGP_NODE, &address_family_ipv6_cmd);
25ffbdc1 14805 install_element (BGP_NODE, &address_family_ipv6_safi_cmd);
718e3744 14806#endif /* HAVE_IPV6 */
14807 install_element (BGP_NODE, &address_family_vpnv4_cmd);
14808 install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd);
14809
14810 /* "exit-address-family" command. */
14811 install_element (BGP_IPV4_NODE, &exit_address_family_cmd);
14812 install_element (BGP_IPV4M_NODE, &exit_address_family_cmd);
14813 install_element (BGP_IPV6_NODE, &exit_address_family_cmd);
25ffbdc1 14814 install_element (BGP_IPV6M_NODE, &exit_address_family_cmd);
718e3744 14815 install_element (BGP_VPNV4_NODE, &exit_address_family_cmd);
14816
14817 /* "clear ip bgp commands" */
14818 install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd);
14819 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_cmd);
14820 install_element (ENABLE_NODE, &clear_ip_bgp_as_cmd);
01080f7c 14821 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_cmd);
718e3744 14822 install_element (ENABLE_NODE, &clear_ip_bgp_peer_cmd);
01080f7c 14823 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_cmd);
718e3744 14824 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_cmd);
01080f7c 14825 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_cmd);
718e3744 14826 install_element (ENABLE_NODE, &clear_ip_bgp_external_cmd);
01080f7c 14827 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_cmd);
14828
718e3744 14829 install_element (ENABLE_NODE, &clear_bgp_all_cmd);
14830 install_element (ENABLE_NODE, &clear_bgp_instance_all_cmd);
14831 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_cmd);
01080f7c 14832 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_all_cmd);
718e3744 14833 install_element (ENABLE_NODE, &clear_bgp_peer_cmd);
01080f7c 14834 install_element (ENABLE_NODE, &clear_bgp_instance_peer_cmd);
718e3744 14835 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_cmd);
01080f7c 14836 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_cmd);
718e3744 14837 install_element (ENABLE_NODE, &clear_bgp_peer_group_cmd);
01080f7c 14838 install_element (ENABLE_NODE, &clear_bgp_instance_peer_group_cmd);
718e3744 14839 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_cmd);
01080f7c 14840 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_group_cmd);
718e3744 14841 install_element (ENABLE_NODE, &clear_bgp_external_cmd);
01080f7c 14842 install_element (ENABLE_NODE, &clear_bgp_instance_external_cmd);
718e3744 14843 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_cmd);
01080f7c 14844 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_external_cmd);
718e3744 14845 install_element (ENABLE_NODE, &clear_bgp_as_cmd);
01080f7c 14846 install_element (ENABLE_NODE, &clear_bgp_instance_as_cmd);
718e3744 14847 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_cmd);
01080f7c 14848 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_as_cmd);
718e3744 14849
14850 /* "clear ip bgp neighbor soft in" */
14851 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_in_cmd);
14852 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_in_cmd);
14853 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_cmd);
01080f7c 14854 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_in_cmd);
718e3744 14855 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_prefix_filter_cmd);
718e3744 14856 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_in_cmd);
01080f7c 14857 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_soft_in_cmd);
718e3744 14858 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_cmd);
01080f7c 14859 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_in_cmd);
718e3744 14860 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_prefix_filter_cmd);
14861 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_in_cmd);
01080f7c 14862 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_soft_in_cmd);
718e3744 14863 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_cmd);
01080f7c 14864 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_in_cmd);
718e3744 14865 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_prefix_filter_cmd);
14866 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_in_cmd);
01080f7c 14867 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_soft_in_cmd);
718e3744 14868 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_cmd);
01080f7c 14869 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_in_cmd);
718e3744 14870 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_prefix_filter_cmd);
14871 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_in_cmd);
01080f7c 14872 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_soft_in_cmd);
718e3744 14873 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_cmd);
01080f7c 14874 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_in_cmd);
718e3744 14875 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_prefix_filter_cmd);
14876 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_in_cmd);
14877 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_in_cmd);
14878 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_cmd);
01080f7c 14879 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_in_cmd);
718e3744 14880 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_prefix_filter_cmd);
718e3744 14881 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_in_cmd);
01080f7c 14882 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_ipv4_soft_in_cmd);
718e3744 14883 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_cmd);
01080f7c 14884 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_ipv4_in_cmd);
718e3744 14885 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd);
14886 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_in_cmd);
01080f7c 14887 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_ipv4_soft_in_cmd);
718e3744 14888 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_cmd);
01080f7c 14889 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_ipv4_in_cmd);
718e3744 14890 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd);
14891 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_in_cmd);
01080f7c 14892 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_soft_in_cmd);
718e3744 14893 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_cmd);
01080f7c 14894 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_in_cmd);
718e3744 14895 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_prefix_filter_cmd);
14896 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_in_cmd);
01080f7c 14897 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_soft_in_cmd);
718e3744 14898 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_cmd);
01080f7c 14899 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_in_cmd);
718e3744 14900 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_prefix_filter_cmd);
14901 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_in_cmd);
14902 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_in_cmd);
14903 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_in_cmd);
14904 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_in_cmd);
14905 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_in_cmd);
14906 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_in_cmd);
01080f7c 14907
718e3744 14908 install_element (ENABLE_NODE, &clear_bgp_all_soft_in_cmd);
14909 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_in_cmd);
14910 install_element (ENABLE_NODE, &clear_bgp_all_in_cmd);
01080f7c 14911 install_element (ENABLE_NODE, &clear_bgp_instance_all_in_cmd);
718e3744 14912 install_element (ENABLE_NODE, &clear_bgp_all_in_prefix_filter_cmd);
14913 install_element (ENABLE_NODE, &clear_bgp_peer_soft_in_cmd);
01080f7c 14914 install_element (ENABLE_NODE, &clear_bgp_instance_peer_soft_in_cmd);
718e3744 14915 install_element (ENABLE_NODE, &clear_bgp_peer_in_cmd);
01080f7c 14916 install_element (ENABLE_NODE, &clear_bgp_instance_peer_in_cmd);
718e3744 14917 install_element (ENABLE_NODE, &clear_bgp_peer_in_prefix_filter_cmd);
14918 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_in_cmd);
01080f7c 14919 install_element (ENABLE_NODE, &clear_bgp_instance_peer_group_soft_in_cmd);
718e3744 14920 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_cmd);
01080f7c 14921 install_element (ENABLE_NODE, &clear_bgp_instance_peer_group_in_cmd);
718e3744 14922 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_prefix_filter_cmd);
14923 install_element (ENABLE_NODE, &clear_bgp_external_soft_in_cmd);
01080f7c 14924 install_element (ENABLE_NODE, &clear_bgp_instance_external_soft_in_cmd);
718e3744 14925 install_element (ENABLE_NODE, &clear_bgp_external_in_cmd);
01080f7c 14926 install_element (ENABLE_NODE, &clear_bgp_instance_external_in_cmd);
718e3744 14927 install_element (ENABLE_NODE, &clear_bgp_external_in_prefix_filter_cmd);
14928 install_element (ENABLE_NODE, &clear_bgp_as_soft_in_cmd);
01080f7c 14929 install_element (ENABLE_NODE, &clear_bgp_instance_as_soft_in_cmd);
718e3744 14930 install_element (ENABLE_NODE, &clear_bgp_as_in_cmd);
01080f7c 14931 install_element (ENABLE_NODE, &clear_bgp_instance_as_in_cmd);
718e3744 14932 install_element (ENABLE_NODE, &clear_bgp_as_in_prefix_filter_cmd);
14933 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_in_cmd);
01080f7c 14934 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_all_soft_in_cmd);
718e3744 14935 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_cmd);
01080f7c 14936 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_all_in_cmd);
718e3744 14937 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_prefix_filter_cmd);
14938 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_in_cmd);
01080f7c 14939 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_soft_in_cmd);
718e3744 14940 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_cmd);
01080f7c 14941 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_in_cmd);
718e3744 14942 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_prefix_filter_cmd);
14943 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_in_cmd);
01080f7c 14944 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_group_soft_in_cmd);
718e3744 14945 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_cmd);
01080f7c 14946 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_group_in_cmd);
718e3744 14947 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_prefix_filter_cmd);
14948 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_in_cmd);
01080f7c 14949 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_external_soft_in_cmd);
718e3744 14950 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_cmd);
01080f7c 14951 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_external_in_cmd);
718e3744 14952 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_prefix_filter_cmd);
14953 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_in_cmd);
01080f7c 14954 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_as_soft_in_cmd);
718e3744 14955 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_cmd);
01080f7c 14956 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_as_in_cmd);
718e3744 14957 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_prefix_filter_cmd);
718e3744 14958
8ad7271d
DS
14959 /* clear ip bgp prefix */
14960 install_element (ENABLE_NODE, &clear_ip_bgp_prefix_cmd);
01080f7c 14961 install_element (ENABLE_NODE, &clear_ip_bgp_instance_prefix_cmd);
8ad7271d 14962 install_element (ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd);
01080f7c 14963 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd);
8ad7271d 14964
718e3744 14965 /* "clear ip bgp neighbor soft out" */
14966 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_out_cmd);
14967 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_out_cmd);
14968 install_element (ENABLE_NODE, &clear_ip_bgp_all_out_cmd);
01080f7c 14969 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_out_cmd);
718e3744 14970 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_out_cmd);
01080f7c 14971 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_soft_out_cmd);
718e3744 14972 install_element (ENABLE_NODE, &clear_ip_bgp_peer_out_cmd);
01080f7c 14973 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_out_cmd);
718e3744 14974 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_out_cmd);
01080f7c 14975 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_soft_out_cmd);
718e3744 14976 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_out_cmd);
01080f7c 14977 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_out_cmd);
718e3744 14978 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_out_cmd);
01080f7c 14979 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_soft_out_cmd);
718e3744 14980 install_element (ENABLE_NODE, &clear_ip_bgp_external_out_cmd);
01080f7c 14981 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_out_cmd);
718e3744 14982 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_out_cmd);
01080f7c 14983 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_soft_out_cmd);
718e3744 14984 install_element (ENABLE_NODE, &clear_ip_bgp_as_out_cmd);
01080f7c 14985 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_out_cmd);
718e3744 14986 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_out_cmd);
14987 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_out_cmd);
14988 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_out_cmd);
01080f7c 14989 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_out_cmd);
718e3744 14990 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_out_cmd);
01080f7c 14991 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_ipv4_soft_out_cmd);
718e3744 14992 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_out_cmd);
01080f7c 14993 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_ipv4_out_cmd);
718e3744 14994 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_out_cmd);
01080f7c 14995 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_ipv4_soft_out_cmd);
718e3744 14996 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_out_cmd);
01080f7c 14997 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_ipv4_out_cmd);
718e3744 14998 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_out_cmd);
01080f7c 14999 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_soft_out_cmd);
718e3744 15000 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_out_cmd);
01080f7c 15001 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_out_cmd);
718e3744 15002 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_out_cmd);
01080f7c 15003 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_soft_out_cmd);
718e3744 15004 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_out_cmd);
01080f7c 15005 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_out_cmd);
718e3744 15006 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_out_cmd);
15007 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_out_cmd);
15008 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_out_cmd);
15009 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_out_cmd);
15010 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_out_cmd);
15011 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_out_cmd);
01080f7c 15012
718e3744 15013 install_element (ENABLE_NODE, &clear_bgp_all_soft_out_cmd);
15014 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_out_cmd);
15015 install_element (ENABLE_NODE, &clear_bgp_all_out_cmd);
01080f7c 15016 install_element (ENABLE_NODE, &clear_bgp_instance_all_out_cmd);
718e3744 15017 install_element (ENABLE_NODE, &clear_bgp_peer_soft_out_cmd);
01080f7c 15018 install_element (ENABLE_NODE, &clear_bgp_instance_peer_soft_out_cmd);
718e3744 15019 install_element (ENABLE_NODE, &clear_bgp_peer_out_cmd);
01080f7c 15020 install_element (ENABLE_NODE, &clear_bgp_instance_peer_out_cmd);
718e3744 15021 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_out_cmd);
01080f7c 15022 install_element (ENABLE_NODE, &clear_bgp_instance_peer_group_soft_out_cmd);
718e3744 15023 install_element (ENABLE_NODE, &clear_bgp_peer_group_out_cmd);
01080f7c 15024 install_element (ENABLE_NODE, &clear_bgp_instance_peer_group_out_cmd);
718e3744 15025 install_element (ENABLE_NODE, &clear_bgp_external_soft_out_cmd);
01080f7c 15026 install_element (ENABLE_NODE, &clear_bgp_instance_external_soft_out_cmd);
718e3744 15027 install_element (ENABLE_NODE, &clear_bgp_external_out_cmd);
01080f7c 15028 install_element (ENABLE_NODE, &clear_bgp_instance_external_out_cmd);
718e3744 15029 install_element (ENABLE_NODE, &clear_bgp_as_soft_out_cmd);
01080f7c 15030 install_element (ENABLE_NODE, &clear_bgp_instance_as_soft_out_cmd);
718e3744 15031 install_element (ENABLE_NODE, &clear_bgp_as_out_cmd);
01080f7c 15032 install_element (ENABLE_NODE, &clear_bgp_instance_as_out_cmd);
718e3744 15033 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_out_cmd);
01080f7c 15034 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_all_soft_out_cmd);
718e3744 15035 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_out_cmd);
01080f7c 15036 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_all_out_cmd);
718e3744 15037 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_out_cmd);
01080f7c 15038 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_soft_out_cmd);
718e3744 15039 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_out_cmd);
01080f7c 15040 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_out_cmd);
718e3744 15041 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_out_cmd);
01080f7c 15042 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_group_soft_out_cmd);
718e3744 15043 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_out_cmd);
01080f7c 15044 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_group_out_cmd);
718e3744 15045 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_out_cmd);
01080f7c 15046 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_external_soft_out_cmd);
718e3744 15047 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_out_cmd);
01080f7c 15048 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_external_out_cmd);
718e3744 15049 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_out_cmd);
01080f7c 15050 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_as_soft_out_cmd);
718e3744 15051 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_out_cmd);
01080f7c 15052 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_as_out_cmd);
718e3744 15053
15054 /* "clear ip bgp neighbor soft" */
15055 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_cmd);
15056 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_cmd);
15057 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_cmd);
01080f7c 15058 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_soft_cmd);
718e3744 15059 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_cmd);
01080f7c 15060 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_soft_cmd);
718e3744 15061 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_cmd);
01080f7c 15062 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_soft_cmd);
718e3744 15063 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_cmd);
01080f7c 15064 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_soft_cmd);
718e3744 15065 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_cmd);
15066 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_cmd);
15067 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_cmd);
01080f7c 15068 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_ipv4_soft_cmd);
718e3744 15069 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_cmd);
01080f7c 15070 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_ipv4_soft_cmd);
718e3744 15071 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_cmd);
01080f7c 15072 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_soft_cmd);
718e3744 15073 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_cmd);
01080f7c 15074 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_soft_cmd);
718e3744 15075 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_cmd);
15076 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_cmd);
15077 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_cmd);
01080f7c 15078
718e3744 15079 install_element (ENABLE_NODE, &clear_bgp_all_soft_cmd);
15080 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_cmd);
15081 install_element (ENABLE_NODE, &clear_bgp_peer_soft_cmd);
01080f7c 15082 install_element (ENABLE_NODE, &clear_bgp_instance_peer_soft_cmd);
718e3744 15083 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_cmd);
01080f7c 15084 install_element (ENABLE_NODE, &clear_bgp_instance_peer_group_soft_cmd);
718e3744 15085 install_element (ENABLE_NODE, &clear_bgp_external_soft_cmd);
01080f7c 15086 install_element (ENABLE_NODE, &clear_bgp_instance_external_soft_cmd);
718e3744 15087 install_element (ENABLE_NODE, &clear_bgp_as_soft_cmd);
01080f7c 15088 install_element (ENABLE_NODE, &clear_bgp_instance_as_soft_cmd);
718e3744 15089 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_cmd);
01080f7c 15090 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_all_soft_cmd);
718e3744 15091 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_cmd);
01080f7c 15092 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_soft_cmd);
718e3744 15093 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_cmd);
01080f7c 15094 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_group_soft_cmd);
718e3744 15095 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_cmd);
01080f7c 15096 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_external_soft_cmd);
718e3744 15097 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_cmd);
01080f7c 15098 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_as_soft_cmd);
718e3744 15099
15100 /* "show ip bgp summary" commands. */
15101 install_element (VIEW_NODE, &show_ip_bgp_summary_cmd);
3f9c7369 15102 install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd);
8386ac43 15103 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_cmd);
f186de26 15104 install_element (VIEW_NODE, &show_ip_bgp_instance_all_updgrps_cmd);
3f9c7369
DS
15105 install_element (VIEW_NODE, &show_bgp_updgrps_cmd);
15106 install_element (VIEW_NODE, &show_bgp_ipv6_updgrps_cmd);
8386ac43 15107 install_element (VIEW_NODE, &show_bgp_instance_ipv6_updgrps_cmd);
f186de26 15108 install_element (VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd);
8fe8a7f6 15109 install_element (VIEW_NODE, &show_ip_bgp_updgrps_s_cmd);
8386ac43 15110 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_s_cmd);
8fe8a7f6
DS
15111 install_element (VIEW_NODE, &show_bgp_updgrps_s_cmd);
15112 install_element (VIEW_NODE, &show_bgp_ipv6_updgrps_s_cmd);
8386ac43 15113 install_element (VIEW_NODE, &show_bgp_instance_ipv6_updgrps_s_cmd);
3f9c7369 15114 install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd);
8386ac43 15115 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd);
3f9c7369 15116 install_element (VIEW_NODE, &show_bgp_updgrps_adj_cmd);
8386ac43 15117 install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd);
3f9c7369 15118 install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd);
8fe8a7f6 15119 install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd);
8386ac43 15120 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd);
8fe8a7f6 15121 install_element (VIEW_NODE, &show_bgp_updgrps_adj_s_cmd);
8386ac43 15122 install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd);
8fe8a7f6 15123 install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd);
718e3744 15124 install_element (VIEW_NODE, &show_ip_bgp_instance_summary_cmd);
f186de26 15125 install_element (VIEW_NODE, &show_ip_bgp_instance_all_summary_cmd);
718e3744 15126 install_element (VIEW_NODE, &show_ip_bgp_ipv4_summary_cmd);
95cbbd2a 15127 install_element (VIEW_NODE, &show_bgp_ipv4_safi_summary_cmd);
718e3744 15128 install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
95cbbd2a 15129 install_element (VIEW_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
718e3744 15130 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
15131 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
15132#ifdef HAVE_IPV6
15133 install_element (VIEW_NODE, &show_bgp_summary_cmd);
15134 install_element (VIEW_NODE, &show_bgp_instance_summary_cmd);
f186de26 15135 install_element (VIEW_NODE, &show_bgp_instance_all_summary_cmd);
718e3744 15136 install_element (VIEW_NODE, &show_bgp_ipv6_summary_cmd);
95cbbd2a 15137 install_element (VIEW_NODE, &show_bgp_ipv6_safi_summary_cmd);
718e3744 15138 install_element (VIEW_NODE, &show_bgp_instance_ipv6_summary_cmd);
95cbbd2a 15139 install_element (VIEW_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
62687ff1
PJ
15140#endif /* HAVE_IPV6 */
15141 install_element (RESTRICTED_NODE, &show_ip_bgp_summary_cmd);
3f9c7369 15142 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_cmd);
8386ac43 15143 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_updgrps_cmd);
f186de26 15144 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_all_updgrps_cmd);
3f9c7369
DS
15145 install_element (RESTRICTED_NODE, &show_bgp_updgrps_cmd);
15146 install_element (RESTRICTED_NODE, &show_bgp_ipv6_updgrps_cmd);
8386ac43 15147 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_updgrps_cmd);
f186de26 15148 install_element (RESTRICTED_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd);
8fe8a7f6 15149 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_s_cmd);
8386ac43 15150 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_updgrps_s_cmd);
8fe8a7f6
DS
15151 install_element (RESTRICTED_NODE, &show_bgp_updgrps_s_cmd);
15152 install_element (RESTRICTED_NODE, &show_bgp_ipv6_updgrps_s_cmd);
8386ac43 15153 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_updgrps_s_cmd);
3f9c7369 15154 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_adj_cmd);
8386ac43 15155 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_updgrps_adj_cmd);
3f9c7369 15156 install_element (RESTRICTED_NODE, &show_bgp_updgrps_adj_cmd);
8386ac43 15157 install_element (RESTRICTED_NODE, &show_bgp_instance_updgrps_adj_cmd);
3f9c7369 15158 install_element (RESTRICTED_NODE, &show_bgp_updgrps_afi_adj_cmd);
8fe8a7f6 15159 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_adj_s_cmd);
8386ac43 15160 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd);
8fe8a7f6 15161 install_element (RESTRICTED_NODE, &show_bgp_updgrps_adj_s_cmd);
8386ac43 15162 install_element (RESTRICTED_NODE, &show_bgp_instance_updgrps_adj_s_cmd);
8fe8a7f6 15163 install_element (RESTRICTED_NODE, &show_bgp_updgrps_afi_adj_s_cmd);
62687ff1 15164 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_summary_cmd);
f186de26 15165 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_all_summary_cmd);
62687ff1 15166 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_summary_cmd);
95cbbd2a 15167 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_summary_cmd);
62687ff1 15168 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
95cbbd2a 15169 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
62687ff1
PJ
15170 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
15171 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
15172#ifdef HAVE_IPV6
15173 install_element (RESTRICTED_NODE, &show_bgp_summary_cmd);
15174 install_element (RESTRICTED_NODE, &show_bgp_instance_summary_cmd);
f186de26 15175 install_element (RESTRICTED_NODE, &show_bgp_instance_all_summary_cmd);
62687ff1 15176 install_element (RESTRICTED_NODE, &show_bgp_ipv6_summary_cmd);
95cbbd2a 15177 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_summary_cmd);
62687ff1 15178 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_summary_cmd);
95cbbd2a 15179 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
718e3744 15180#endif /* HAVE_IPV6 */
15181 install_element (ENABLE_NODE, &show_ip_bgp_summary_cmd);
3f9c7369 15182 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_cmd);
8386ac43 15183 install_element (ENABLE_NODE, &show_ip_bgp_instance_updgrps_cmd);
f186de26 15184 install_element (ENABLE_NODE, &show_ip_bgp_instance_all_updgrps_cmd);
3f9c7369
DS
15185 install_element (ENABLE_NODE, &show_bgp_updgrps_cmd);
15186 install_element (ENABLE_NODE, &show_bgp_ipv6_updgrps_cmd);
8386ac43 15187 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_updgrps_cmd);
f186de26 15188 install_element (ENABLE_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd);
8fe8a7f6 15189 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_s_cmd);
8386ac43 15190 install_element (ENABLE_NODE, &show_ip_bgp_instance_updgrps_s_cmd);
8fe8a7f6
DS
15191 install_element (ENABLE_NODE, &show_bgp_updgrps_s_cmd);
15192 install_element (ENABLE_NODE, &show_bgp_ipv6_updgrps_s_cmd);
8386ac43 15193 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_updgrps_s_cmd);
3f9c7369 15194 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_adj_cmd);
8386ac43 15195 install_element (ENABLE_NODE, &show_ip_bgp_instance_updgrps_adj_cmd);
3f9c7369 15196 install_element (ENABLE_NODE, &show_bgp_updgrps_adj_cmd);
8386ac43 15197 install_element (ENABLE_NODE, &show_bgp_instance_updgrps_adj_cmd);
3f9c7369 15198 install_element (ENABLE_NODE, &show_bgp_updgrps_afi_adj_cmd);
8fe8a7f6 15199 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_adj_s_cmd);
8386ac43 15200 install_element (ENABLE_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd);
8fe8a7f6 15201 install_element (ENABLE_NODE, &show_bgp_updgrps_adj_s_cmd);
8386ac43 15202 install_element (ENABLE_NODE, &show_bgp_instance_updgrps_adj_s_cmd);
8fe8a7f6 15203 install_element (ENABLE_NODE, &show_bgp_updgrps_afi_adj_s_cmd);
718e3744 15204 install_element (ENABLE_NODE, &show_ip_bgp_instance_summary_cmd);
f186de26 15205 install_element (ENABLE_NODE, &show_ip_bgp_instance_all_summary_cmd);
718e3744 15206 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_summary_cmd);
95cbbd2a 15207 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_summary_cmd);
718e3744 15208 install_element (ENABLE_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
95cbbd2a 15209 install_element (ENABLE_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
718e3744 15210 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
15211 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
15212#ifdef HAVE_IPV6
15213 install_element (ENABLE_NODE, &show_bgp_summary_cmd);
15214 install_element (ENABLE_NODE, &show_bgp_instance_summary_cmd);
f186de26 15215 install_element (ENABLE_NODE, &show_bgp_instance_all_summary_cmd);
718e3744 15216 install_element (ENABLE_NODE, &show_bgp_ipv6_summary_cmd);
95cbbd2a 15217 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_summary_cmd);
718e3744 15218 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_summary_cmd);
95cbbd2a 15219 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
718e3744 15220#endif /* HAVE_IPV6 */
15221
15222 /* "show ip bgp neighbors" commands. */
15223 install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd);
15224 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
15225 install_element (VIEW_NODE, &show_ip_bgp_neighbors_peer_cmd);
15226 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
15227 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd);
15228 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd);
15229 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
15230 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
15231 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_cmd);
f186de26 15232 install_element (VIEW_NODE, &show_ip_bgp_instance_all_neighbors_cmd);
718e3744 15233 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
62687ff1
PJ
15234 install_element (RESTRICTED_NODE, &show_ip_bgp_neighbors_peer_cmd);
15235 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
15236 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
15237 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
15238 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
718e3744 15239 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_cmd);
15240 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
15241 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_peer_cmd);
15242 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
15243 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd);
15244 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd);
15245 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
15246 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
15247 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_cmd);
f186de26 15248 install_element (ENABLE_NODE, &show_ip_bgp_instance_all_neighbors_cmd);
718e3744 15249 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
15250
15251#ifdef HAVE_IPV6
15252 install_element (VIEW_NODE, &show_bgp_neighbors_cmd);
15253 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_cmd);
15254 install_element (VIEW_NODE, &show_bgp_neighbors_peer_cmd);
15255 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
bb46e94f 15256 install_element (VIEW_NODE, &show_bgp_instance_neighbors_cmd);
15257 install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
15258 install_element (VIEW_NODE, &show_bgp_instance_neighbors_peer_cmd);
15259 install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
62687ff1
PJ
15260 install_element (RESTRICTED_NODE, &show_bgp_neighbors_peer_cmd);
15261 install_element (RESTRICTED_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
15262 install_element (RESTRICTED_NODE, &show_bgp_instance_neighbors_peer_cmd);
15263 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
718e3744 15264 install_element (ENABLE_NODE, &show_bgp_neighbors_cmd);
15265 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_cmd);
15266 install_element (ENABLE_NODE, &show_bgp_neighbors_peer_cmd);
15267 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
bb46e94f 15268 install_element (ENABLE_NODE, &show_bgp_instance_neighbors_cmd);
15269 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
15270 install_element (ENABLE_NODE, &show_bgp_instance_neighbors_peer_cmd);
15271 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
718e3744 15272
15273 /* Old commands. */
15274 install_element (VIEW_NODE, &show_ipv6_bgp_summary_cmd);
15275 install_element (VIEW_NODE, &show_ipv6_mbgp_summary_cmd);
15276 install_element (ENABLE_NODE, &show_ipv6_bgp_summary_cmd);
15277 install_element (ENABLE_NODE, &show_ipv6_mbgp_summary_cmd);
15278#endif /* HAVE_IPV6 */
fee0f4c6 15279
f14e6fdb
DS
15280 /* "show ip bgp peer-group" commands. */
15281 install_element (VIEW_NODE, &show_ip_bgp_peer_groups_cmd);
15282 install_element (VIEW_NODE, &show_ip_bgp_instance_peer_groups_cmd);
15283 install_element (VIEW_NODE, &show_ip_bgp_peer_group_cmd);
15284 install_element (VIEW_NODE, &show_ip_bgp_instance_peer_group_cmd);
15285 install_element (ENABLE_NODE, &show_ip_bgp_peer_groups_cmd);
15286 install_element (ENABLE_NODE, &show_ip_bgp_instance_peer_groups_cmd);
15287 install_element (ENABLE_NODE, &show_ip_bgp_peer_group_cmd);
15288 install_element (ENABLE_NODE, &show_ip_bgp_instance_peer_group_cmd);
15289
718e3744 15290 /* "show ip bgp paths" commands. */
15291 install_element (VIEW_NODE, &show_ip_bgp_paths_cmd);
15292 install_element (VIEW_NODE, &show_ip_bgp_ipv4_paths_cmd);
15293 install_element (ENABLE_NODE, &show_ip_bgp_paths_cmd);
15294 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_paths_cmd);
15295
15296 /* "show ip bgp community" commands. */
15297 install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd);
15298 install_element (ENABLE_NODE, &show_ip_bgp_community_info_cmd);
15299
15300 /* "show ip bgp attribute-info" commands. */
15301 install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd);
15302 install_element (ENABLE_NODE, &show_ip_bgp_attr_info_cmd);
15303
15304 /* "redistribute" commands. */
15305 install_element (BGP_NODE, &bgp_redistribute_ipv4_cmd);
15306 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_cmd);
15307 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_cmd);
15308 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_cmd);
15309 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_cmd);
15310 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_cmd);
15311 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd);
15312 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd);
15313 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_metric_cmd);
15314 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_rmap_cmd);
7c8ff89e
DS
15315 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_cmd);
15316 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_cmd);
15317 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd);
15318 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_cmd);
15319 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd);
15320 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_metric_cmd);
15321 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
15322 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
15323 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
15324 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
919e0666
DW
15325 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd);
15326 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd);
15327 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd);
15328 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_rmap_cmd);
15329 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd);
15330 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_metric_cmd);
15331 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd);
15332 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd);
15333 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_rmap_metric_cmd);
15334 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_metric_rmap_cmd);
15335 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd);
15336 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd);
15337 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd);
15338 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_cmd);
15339 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd);
15340 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_metric_cmd);
15341 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
15342 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
15343 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
15344 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
718e3744 15345#ifdef HAVE_IPV6
15346 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd);
15347 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd);
15348 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd);
15349 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_cmd);
15350 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd);
15351 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_cmd);
15352 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd);
15353 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd);
15354 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_metric_cmd);
15355 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_rmap_cmd);
15356#endif /* HAVE_IPV6 */
15357
fa411a21
NH
15358 /* ttl_security commands */
15359 install_element (BGP_NODE, &neighbor_ttl_security_cmd);
15360 install_element (BGP_NODE, &no_neighbor_ttl_security_cmd);
15361
4bf6a362
PJ
15362 /* "show bgp memory" commands. */
15363 install_element (VIEW_NODE, &show_bgp_memory_cmd);
62687ff1 15364 install_element (RESTRICTED_NODE, &show_bgp_memory_cmd);
4bf6a362
PJ
15365 install_element (ENABLE_NODE, &show_bgp_memory_cmd);
15366
e0081f70
ML
15367 /* "show bgp views" commands. */
15368 install_element (VIEW_NODE, &show_bgp_views_cmd);
15369 install_element (RESTRICTED_NODE, &show_bgp_views_cmd);
15370 install_element (ENABLE_NODE, &show_bgp_views_cmd);
15371
8386ac43 15372 /* "show bgp vrfs" commands. */
15373 install_element (VIEW_NODE, &show_bgp_vrfs_cmd);
15374 install_element (RESTRICTED_NODE, &show_bgp_vrfs_cmd);
15375 install_element (ENABLE_NODE, &show_bgp_vrfs_cmd);
15376
718e3744 15377 /* Community-list. */
15378 community_list_vty ();
15379}
6b0655a2 15380
718e3744 15381#include "memory.h"
15382#include "bgp_regex.h"
15383#include "bgp_clist.h"
15384#include "bgp_ecommunity.h"
15385
15386/* VTY functions. */
15387
15388/* Direction value to string conversion. */
94f2b392 15389static const char *
718e3744 15390community_direct_str (int direct)
15391{
15392 switch (direct)
15393 {
15394 case COMMUNITY_DENY:
15395 return "deny";
718e3744 15396 case COMMUNITY_PERMIT:
15397 return "permit";
718e3744 15398 default:
15399 return "unknown";
718e3744 15400 }
15401}
15402
15403/* Display error string. */
94f2b392 15404static void
718e3744 15405community_list_perror (struct vty *vty, int ret)
15406{
15407 switch (ret)
15408 {
15409 case COMMUNITY_LIST_ERR_CANT_FIND_LIST:
b729294c 15410 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
718e3744 15411 break;
15412 case COMMUNITY_LIST_ERR_MALFORMED_VAL:
15413 vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE);
15414 break;
15415 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT:
15416 vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE);
15417 break;
15418 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT:
15419 vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE);
15420 break;
15421 }
15422}
15423
15424/* VTY interface for community_set() function. */
94f2b392 15425static int
fd79ac91 15426community_list_set_vty (struct vty *vty, int argc, const char **argv,
15427 int style, int reject_all_digit_name)
718e3744 15428{
15429 int ret;
15430 int direct;
15431 char *str;
15432
15433 /* Check the list type. */
15434 if (strncmp (argv[1], "p", 1) == 0)
15435 direct = COMMUNITY_PERMIT;
15436 else if (strncmp (argv[1], "d", 1) == 0)
15437 direct = COMMUNITY_DENY;
15438 else
15439 {
15440 vty_out (vty, "%% Matching condition must be permit or deny%s",
15441 VTY_NEWLINE);
15442 return CMD_WARNING;
15443 }
15444
15445 /* All digit name check. */
15446 if (reject_all_digit_name && all_digit (argv[0]))
15447 {
15448 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
15449 return CMD_WARNING;
15450 }
15451
15452 /* Concat community string argument. */
15453 if (argc > 1)
15454 str = argv_concat (argv, argc, 2);
15455 else
15456 str = NULL;
15457
15458 /* When community_list_set() return nevetive value, it means
15459 malformed community string. */
15460 ret = community_list_set (bgp_clist, argv[0], str, direct, style);
15461
15462 /* Free temporary community list string allocated by
15463 argv_concat(). */
15464 if (str)
15465 XFREE (MTYPE_TMP, str);
15466
15467 if (ret < 0)
15468 {
15469 /* Display error string. */
15470 community_list_perror (vty, ret);
15471 return CMD_WARNING;
15472 }
15473
15474 return CMD_SUCCESS;
15475}
15476
718e3744 15477/* Communiyt-list entry delete. */
94f2b392 15478static int
fee6e4e4 15479community_list_unset_vty (struct vty *vty, int argc, const char **argv,
813d4307 15480 int style, int delete_all)
718e3744 15481{
15482 int ret;
fee6e4e4 15483 int direct = 0;
15484 char *str = NULL;
718e3744 15485
fee6e4e4 15486 if (argc > 1)
718e3744 15487 {
fee6e4e4 15488 /* Check the list direct. */
15489 if (strncmp (argv[1], "p", 1) == 0)
15490 direct = COMMUNITY_PERMIT;
15491 else if (strncmp (argv[1], "d", 1) == 0)
15492 direct = COMMUNITY_DENY;
15493 else
15494 {
15495 vty_out (vty, "%% Matching condition must be permit or deny%s",
15496 VTY_NEWLINE);
15497 return CMD_WARNING;
15498 }
718e3744 15499
fee6e4e4 15500 /* Concat community string argument. */
15501 str = argv_concat (argv, argc, 2);
15502 }
718e3744 15503
15504 /* Unset community list. */
813d4307 15505 ret = community_list_unset (bgp_clist, argv[0], str, direct, style, delete_all);
718e3744 15506
15507 /* Free temporary community list string allocated by
15508 argv_concat(). */
fee6e4e4 15509 if (str)
15510 XFREE (MTYPE_TMP, str);
718e3744 15511
15512 if (ret < 0)
15513 {
15514 community_list_perror (vty, ret);
15515 return CMD_WARNING;
15516 }
15517
15518 return CMD_SUCCESS;
15519}
15520
15521/* "community-list" keyword help string. */
15522#define COMMUNITY_LIST_STR "Add a community list entry\n"
718e3744 15523
718e3744 15524DEFUN (ip_community_list_standard,
15525 ip_community_list_standard_cmd,
15526 "ip community-list <1-99> (deny|permit) .AA:NN",
15527 IP_STR
15528 COMMUNITY_LIST_STR
15529 "Community list number (standard)\n"
15530 "Specify community to reject\n"
15531 "Specify community to accept\n"
15532 COMMUNITY_VAL_STR)
15533{
15534 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
15535}
15536
15537ALIAS (ip_community_list_standard,
15538 ip_community_list_standard2_cmd,
15539 "ip community-list <1-99> (deny|permit)",
15540 IP_STR
15541 COMMUNITY_LIST_STR
15542 "Community list number (standard)\n"
15543 "Specify community to reject\n"
15544 "Specify community to accept\n")
15545
15546DEFUN (ip_community_list_expanded,
15547 ip_community_list_expanded_cmd,
fee6e4e4 15548 "ip community-list <100-500> (deny|permit) .LINE",
718e3744 15549 IP_STR
15550 COMMUNITY_LIST_STR
15551 "Community list number (expanded)\n"
15552 "Specify community to reject\n"
15553 "Specify community to accept\n"
15554 "An ordered list as a regular-expression\n")
15555{
15556 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
15557}
15558
15559DEFUN (ip_community_list_name_standard,
15560 ip_community_list_name_standard_cmd,
15561 "ip community-list standard WORD (deny|permit) .AA:NN",
15562 IP_STR
15563 COMMUNITY_LIST_STR
15564 "Add a standard community-list entry\n"
15565 "Community list name\n"
15566 "Specify community to reject\n"
15567 "Specify community to accept\n"
15568 COMMUNITY_VAL_STR)
15569{
15570 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
15571}
15572
15573ALIAS (ip_community_list_name_standard,
15574 ip_community_list_name_standard2_cmd,
15575 "ip community-list standard WORD (deny|permit)",
15576 IP_STR
15577 COMMUNITY_LIST_STR
15578 "Add a standard community-list entry\n"
15579 "Community list name\n"
15580 "Specify community to reject\n"
15581 "Specify community to accept\n")
15582
15583DEFUN (ip_community_list_name_expanded,
15584 ip_community_list_name_expanded_cmd,
15585 "ip community-list expanded WORD (deny|permit) .LINE",
15586 IP_STR
15587 COMMUNITY_LIST_STR
15588 "Add an expanded community-list entry\n"
15589 "Community list name\n"
15590 "Specify community to reject\n"
15591 "Specify community to accept\n"
15592 "An ordered list as a regular-expression\n")
15593{
15594 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
15595}
15596
fee6e4e4 15597DEFUN (no_ip_community_list_standard_all,
15598 no_ip_community_list_standard_all_cmd,
15599 "no ip community-list <1-99>",
15600 NO_STR
15601 IP_STR
15602 COMMUNITY_LIST_STR
15603 "Community list number (standard)\n")
15604{
813d4307
DW
15605 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
15606}
15607
15608DEFUN (no_ip_community_list_standard_direction,
15609 no_ip_community_list_standard_direction_cmd,
15610 "no ip community-list <1-99> (deny|permit)",
15611 NO_STR
15612 IP_STR
15613 COMMUNITY_LIST_STR
15614 "Community list number (standard)\n"
15615 "Specify community to reject\n"
15616 "Specify community to accept\n")
15617{
15618 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
fee6e4e4 15619}
15620
813d4307 15621
fee6e4e4 15622DEFUN (no_ip_community_list_expanded_all,
15623 no_ip_community_list_expanded_all_cmd,
15624 "no ip community-list <100-500>",
718e3744 15625 NO_STR
15626 IP_STR
15627 COMMUNITY_LIST_STR
718e3744 15628 "Community list number (expanded)\n")
15629{
813d4307 15630 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
718e3744 15631}
15632
fee6e4e4 15633DEFUN (no_ip_community_list_name_standard_all,
15634 no_ip_community_list_name_standard_all_cmd,
15635 "no ip community-list standard WORD",
718e3744 15636 NO_STR
15637 IP_STR
15638 COMMUNITY_LIST_STR
15639 "Add a standard community-list entry\n"
718e3744 15640 "Community list name\n")
15641{
813d4307 15642 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
718e3744 15643}
15644
fee6e4e4 15645DEFUN (no_ip_community_list_name_expanded_all,
15646 no_ip_community_list_name_expanded_all_cmd,
15647 "no ip community-list expanded WORD",
718e3744 15648 NO_STR
15649 IP_STR
15650 COMMUNITY_LIST_STR
fee6e4e4 15651 "Add an expanded community-list entry\n"
15652 "Community list name\n")
718e3744 15653{
813d4307 15654 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
718e3744 15655}
15656
15657DEFUN (no_ip_community_list_standard,
15658 no_ip_community_list_standard_cmd,
15659 "no ip community-list <1-99> (deny|permit) .AA:NN",
15660 NO_STR
15661 IP_STR
15662 COMMUNITY_LIST_STR
15663 "Community list number (standard)\n"
15664 "Specify community to reject\n"
15665 "Specify community to accept\n"
15666 COMMUNITY_VAL_STR)
15667{
813d4307 15668 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
718e3744 15669}
15670
15671DEFUN (no_ip_community_list_expanded,
15672 no_ip_community_list_expanded_cmd,
fee6e4e4 15673 "no ip community-list <100-500> (deny|permit) .LINE",
718e3744 15674 NO_STR
15675 IP_STR
15676 COMMUNITY_LIST_STR
15677 "Community list number (expanded)\n"
15678 "Specify community to reject\n"
15679 "Specify community to accept\n"
15680 "An ordered list as a regular-expression\n")
15681{
813d4307 15682 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
718e3744 15683}
15684
15685DEFUN (no_ip_community_list_name_standard,
15686 no_ip_community_list_name_standard_cmd,
15687 "no ip community-list standard WORD (deny|permit) .AA:NN",
15688 NO_STR
15689 IP_STR
15690 COMMUNITY_LIST_STR
15691 "Specify a standard community-list\n"
15692 "Community list name\n"
15693 "Specify community to reject\n"
15694 "Specify community to accept\n"
15695 COMMUNITY_VAL_STR)
15696{
813d4307
DW
15697 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
15698}
15699
15700DEFUN (no_ip_community_list_name_standard_brief,
15701 no_ip_community_list_name_standard_brief_cmd,
15702 "no ip community-list standard WORD (deny|permit)",
15703 NO_STR
15704 IP_STR
15705 COMMUNITY_LIST_STR
15706 "Specify a standard community-list\n"
15707 "Community list name\n"
15708 "Specify community to reject\n"
15709 "Specify community to accept\n")
15710{
15711 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
718e3744 15712}
15713
15714DEFUN (no_ip_community_list_name_expanded,
15715 no_ip_community_list_name_expanded_cmd,
15716 "no ip community-list expanded WORD (deny|permit) .LINE",
15717 NO_STR
15718 IP_STR
15719 COMMUNITY_LIST_STR
15720 "Specify an expanded community-list\n"
15721 "Community list name\n"
15722 "Specify community to reject\n"
15723 "Specify community to accept\n"
15724 "An ordered list as a regular-expression\n")
15725{
813d4307 15726 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
718e3744 15727}
15728
94f2b392 15729static void
718e3744 15730community_list_show (struct vty *vty, struct community_list *list)
15731{
15732 struct community_entry *entry;
15733
15734 for (entry = list->head; entry; entry = entry->next)
15735 {
15736 if (entry == list->head)
15737 {
15738 if (all_digit (list->name))
15739 vty_out (vty, "Community %s list %s%s",
15740 entry->style == COMMUNITY_LIST_STANDARD ?
15741 "standard" : "(expanded) access",
15742 list->name, VTY_NEWLINE);
15743 else
15744 vty_out (vty, "Named Community %s list %s%s",
15745 entry->style == COMMUNITY_LIST_STANDARD ?
15746 "standard" : "expanded",
15747 list->name, VTY_NEWLINE);
15748 }
15749 if (entry->any)
15750 vty_out (vty, " %s%s",
15751 community_direct_str (entry->direct), VTY_NEWLINE);
15752 else
15753 vty_out (vty, " %s %s%s",
15754 community_direct_str (entry->direct),
15755 entry->style == COMMUNITY_LIST_STANDARD
15756 ? community_str (entry->u.com) : entry->config,
15757 VTY_NEWLINE);
15758 }
15759}
15760
15761DEFUN (show_ip_community_list,
15762 show_ip_community_list_cmd,
15763 "show ip community-list",
15764 SHOW_STR
15765 IP_STR
15766 "List community-list\n")
15767{
15768 struct community_list *list;
15769 struct community_list_master *cm;
15770
fee6e4e4 15771 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
718e3744 15772 if (! cm)
15773 return CMD_SUCCESS;
15774
15775 for (list = cm->num.head; list; list = list->next)
15776 community_list_show (vty, list);
15777
15778 for (list = cm->str.head; list; list = list->next)
15779 community_list_show (vty, list);
15780
15781 return CMD_SUCCESS;
15782}
15783
15784DEFUN (show_ip_community_list_arg,
15785 show_ip_community_list_arg_cmd,
fee6e4e4 15786 "show ip community-list (<1-500>|WORD)",
718e3744 15787 SHOW_STR
15788 IP_STR
15789 "List community-list\n"
15790 "Community-list number\n"
15791 "Community-list name\n")
15792{
15793 struct community_list *list;
15794
fee6e4e4 15795 list = community_list_lookup (bgp_clist, argv[0], COMMUNITY_LIST_MASTER);
718e3744 15796 if (! list)
15797 {
b729294c 15798 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
718e3744 15799 return CMD_WARNING;
15800 }
15801
15802 community_list_show (vty, list);
15803
15804 return CMD_SUCCESS;
15805}
6b0655a2 15806
94f2b392 15807static int
fd79ac91 15808extcommunity_list_set_vty (struct vty *vty, int argc, const char **argv,
15809 int style, int reject_all_digit_name)
718e3744 15810{
15811 int ret;
15812 int direct;
15813 char *str;
15814
15815 /* Check the list type. */
15816 if (strncmp (argv[1], "p", 1) == 0)
15817 direct = COMMUNITY_PERMIT;
15818 else if (strncmp (argv[1], "d", 1) == 0)
15819 direct = COMMUNITY_DENY;
15820 else
15821 {
15822 vty_out (vty, "%% Matching condition must be permit or deny%s",
15823 VTY_NEWLINE);
15824 return CMD_WARNING;
15825 }
15826
15827 /* All digit name check. */
15828 if (reject_all_digit_name && all_digit (argv[0]))
15829 {
15830 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
15831 return CMD_WARNING;
15832 }
15833
15834 /* Concat community string argument. */
15835 if (argc > 1)
15836 str = argv_concat (argv, argc, 2);
15837 else
15838 str = NULL;
15839
15840 ret = extcommunity_list_set (bgp_clist, argv[0], str, direct, style);
15841
15842 /* Free temporary community list string allocated by
15843 argv_concat(). */
15844 if (str)
15845 XFREE (MTYPE_TMP, str);
15846
15847 if (ret < 0)
15848 {
15849 community_list_perror (vty, ret);
15850 return CMD_WARNING;
15851 }
15852 return CMD_SUCCESS;
15853}
15854
94f2b392 15855static int
fee6e4e4 15856extcommunity_list_unset_vty (struct vty *vty, int argc, const char **argv,
813d4307 15857 int style, int delete_all)
718e3744 15858{
15859 int ret;
fee6e4e4 15860 int direct = 0;
15861 char *str = NULL;
718e3744 15862
fee6e4e4 15863 if (argc > 1)
718e3744 15864 {
fee6e4e4 15865 /* Check the list direct. */
15866 if (strncmp (argv[1], "p", 1) == 0)
15867 direct = COMMUNITY_PERMIT;
15868 else if (strncmp (argv[1], "d", 1) == 0)
15869 direct = COMMUNITY_DENY;
15870 else
15871 {
15872 vty_out (vty, "%% Matching condition must be permit or deny%s",
15873 VTY_NEWLINE);
15874 return CMD_WARNING;
15875 }
718e3744 15876
fee6e4e4 15877 /* Concat community string argument. */
15878 str = argv_concat (argv, argc, 2);
718e3744 15879 }
15880
718e3744 15881 /* Unset community list. */
813d4307 15882 ret = extcommunity_list_unset (bgp_clist, argv[0], str, direct, style, delete_all);
718e3744 15883
15884 /* Free temporary community list string allocated by
15885 argv_concat(). */
fee6e4e4 15886 if (str)
15887 XFREE (MTYPE_TMP, str);
718e3744 15888
15889 if (ret < 0)
15890 {
15891 community_list_perror (vty, ret);
15892 return CMD_WARNING;
15893 }
15894
15895 return CMD_SUCCESS;
15896}
15897
15898/* "extcommunity-list" keyword help string. */
15899#define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
15900#define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
15901
15902DEFUN (ip_extcommunity_list_standard,
15903 ip_extcommunity_list_standard_cmd,
15904 "ip extcommunity-list <1-99> (deny|permit) .AA:NN",
15905 IP_STR
15906 EXTCOMMUNITY_LIST_STR
15907 "Extended Community list number (standard)\n"
15908 "Specify community to reject\n"
15909 "Specify community to accept\n"
15910 EXTCOMMUNITY_VAL_STR)
15911{
15912 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
15913}
15914
15915ALIAS (ip_extcommunity_list_standard,
15916 ip_extcommunity_list_standard2_cmd,
15917 "ip extcommunity-list <1-99> (deny|permit)",
15918 IP_STR
15919 EXTCOMMUNITY_LIST_STR
15920 "Extended Community list number (standard)\n"
15921 "Specify community to reject\n"
15922 "Specify community to accept\n")
15923
15924DEFUN (ip_extcommunity_list_expanded,
15925 ip_extcommunity_list_expanded_cmd,
fee6e4e4 15926 "ip extcommunity-list <100-500> (deny|permit) .LINE",
718e3744 15927 IP_STR
15928 EXTCOMMUNITY_LIST_STR
15929 "Extended Community list number (expanded)\n"
15930 "Specify community to reject\n"
15931 "Specify community to accept\n"
15932 "An ordered list as a regular-expression\n")
15933{
15934 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
15935}
15936
15937DEFUN (ip_extcommunity_list_name_standard,
15938 ip_extcommunity_list_name_standard_cmd,
15939 "ip extcommunity-list standard WORD (deny|permit) .AA:NN",
15940 IP_STR
15941 EXTCOMMUNITY_LIST_STR
15942 "Specify standard extcommunity-list\n"
15943 "Extended Community list name\n"
15944 "Specify community to reject\n"
15945 "Specify community to accept\n"
15946 EXTCOMMUNITY_VAL_STR)
15947{
15948 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
15949}
15950
15951ALIAS (ip_extcommunity_list_name_standard,
15952 ip_extcommunity_list_name_standard2_cmd,
15953 "ip extcommunity-list standard WORD (deny|permit)",
15954 IP_STR
15955 EXTCOMMUNITY_LIST_STR
15956 "Specify standard extcommunity-list\n"
15957 "Extended Community list name\n"
15958 "Specify community to reject\n"
15959 "Specify community to accept\n")
15960
15961DEFUN (ip_extcommunity_list_name_expanded,
15962 ip_extcommunity_list_name_expanded_cmd,
15963 "ip extcommunity-list expanded WORD (deny|permit) .LINE",
15964 IP_STR
15965 EXTCOMMUNITY_LIST_STR
15966 "Specify expanded extcommunity-list\n"
15967 "Extended Community list name\n"
15968 "Specify community to reject\n"
15969 "Specify community to accept\n"
15970 "An ordered list as a regular-expression\n")
15971{
15972 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
15973}
15974
fee6e4e4 15975DEFUN (no_ip_extcommunity_list_standard_all,
15976 no_ip_extcommunity_list_standard_all_cmd,
15977 "no ip extcommunity-list <1-99>",
15978 NO_STR
15979 IP_STR
15980 EXTCOMMUNITY_LIST_STR
15981 "Extended Community list number (standard)\n")
15982{
813d4307
DW
15983 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
15984}
15985
15986DEFUN (no_ip_extcommunity_list_standard_direction,
15987 no_ip_extcommunity_list_standard_direction_cmd,
15988 "no ip extcommunity-list <1-99> (deny|permit)",
15989 NO_STR
15990 IP_STR
15991 EXTCOMMUNITY_LIST_STR
15992 "Extended Community list number (standard)\n"
15993 "Specify community to reject\n"
15994 "Specify community to accept\n")
15995{
15996 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
fee6e4e4 15997}
15998
15999DEFUN (no_ip_extcommunity_list_expanded_all,
16000 no_ip_extcommunity_list_expanded_all_cmd,
16001 "no ip extcommunity-list <100-500>",
718e3744 16002 NO_STR
16003 IP_STR
16004 EXTCOMMUNITY_LIST_STR
718e3744 16005 "Extended Community list number (expanded)\n")
16006{
813d4307 16007 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
718e3744 16008}
16009
fee6e4e4 16010DEFUN (no_ip_extcommunity_list_name_standard_all,
16011 no_ip_extcommunity_list_name_standard_all_cmd,
16012 "no ip extcommunity-list standard WORD",
718e3744 16013 NO_STR
16014 IP_STR
16015 EXTCOMMUNITY_LIST_STR
16016 "Specify standard extcommunity-list\n"
fee6e4e4 16017 "Extended Community list name\n")
16018{
813d4307 16019 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
fee6e4e4 16020}
16021
16022DEFUN (no_ip_extcommunity_list_name_expanded_all,
16023 no_ip_extcommunity_list_name_expanded_all_cmd,
16024 "no ip extcommunity-list expanded WORD",
16025 NO_STR
16026 IP_STR
16027 EXTCOMMUNITY_LIST_STR
718e3744 16028 "Specify expanded extcommunity-list\n"
16029 "Extended Community list name\n")
16030{
813d4307 16031 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
718e3744 16032}
16033
16034DEFUN (no_ip_extcommunity_list_standard,
16035 no_ip_extcommunity_list_standard_cmd,
16036 "no ip extcommunity-list <1-99> (deny|permit) .AA:NN",
16037 NO_STR
16038 IP_STR
16039 EXTCOMMUNITY_LIST_STR
16040 "Extended Community list number (standard)\n"
16041 "Specify community to reject\n"
16042 "Specify community to accept\n"
16043 EXTCOMMUNITY_VAL_STR)
16044{
813d4307 16045 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
718e3744 16046}
16047
16048DEFUN (no_ip_extcommunity_list_expanded,
16049 no_ip_extcommunity_list_expanded_cmd,
fee6e4e4 16050 "no ip extcommunity-list <100-500> (deny|permit) .LINE",
718e3744 16051 NO_STR
16052 IP_STR
16053 EXTCOMMUNITY_LIST_STR
16054 "Extended Community list number (expanded)\n"
16055 "Specify community to reject\n"
16056 "Specify community to accept\n"
16057 "An ordered list as a regular-expression\n")
16058{
813d4307 16059 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
718e3744 16060}
16061
16062DEFUN (no_ip_extcommunity_list_name_standard,
16063 no_ip_extcommunity_list_name_standard_cmd,
16064 "no ip extcommunity-list standard WORD (deny|permit) .AA:NN",
16065 NO_STR
16066 IP_STR
16067 EXTCOMMUNITY_LIST_STR
16068 "Specify standard extcommunity-list\n"
16069 "Extended Community list name\n"
16070 "Specify community to reject\n"
16071 "Specify community to accept\n"
16072 EXTCOMMUNITY_VAL_STR)
16073{
813d4307
DW
16074 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
16075}
16076
16077DEFUN (no_ip_extcommunity_list_name_standard_brief,
16078 no_ip_extcommunity_list_name_standard_brief_cmd,
16079 "no ip extcommunity-list standard WORD (deny|permit)",
16080 NO_STR
16081 IP_STR
16082 EXTCOMMUNITY_LIST_STR
16083 "Specify standard extcommunity-list\n"
16084 "Extended Community list name\n"
16085 "Specify community to reject\n"
16086 "Specify community to accept\n")
16087{
16088 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
718e3744 16089}
16090
16091DEFUN (no_ip_extcommunity_list_name_expanded,
16092 no_ip_extcommunity_list_name_expanded_cmd,
16093 "no ip extcommunity-list expanded WORD (deny|permit) .LINE",
16094 NO_STR
16095 IP_STR
16096 EXTCOMMUNITY_LIST_STR
16097 "Specify expanded extcommunity-list\n"
16098 "Community list name\n"
16099 "Specify community to reject\n"
16100 "Specify community to accept\n"
16101 "An ordered list as a regular-expression\n")
16102{
813d4307 16103 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
718e3744 16104}
16105
94f2b392 16106static void
718e3744 16107extcommunity_list_show (struct vty *vty, struct community_list *list)
16108{
16109 struct community_entry *entry;
16110
16111 for (entry = list->head; entry; entry = entry->next)
16112 {
16113 if (entry == list->head)
16114 {
16115 if (all_digit (list->name))
16116 vty_out (vty, "Extended community %s list %s%s",
16117 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
16118 "standard" : "(expanded) access",
16119 list->name, VTY_NEWLINE);
16120 else
16121 vty_out (vty, "Named extended community %s list %s%s",
16122 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
16123 "standard" : "expanded",
16124 list->name, VTY_NEWLINE);
16125 }
16126 if (entry->any)
16127 vty_out (vty, " %s%s",
16128 community_direct_str (entry->direct), VTY_NEWLINE);
16129 else
16130 vty_out (vty, " %s %s%s",
16131 community_direct_str (entry->direct),
16132 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
16133 entry->u.ecom->str : entry->config,
16134 VTY_NEWLINE);
16135 }
16136}
16137
16138DEFUN (show_ip_extcommunity_list,
16139 show_ip_extcommunity_list_cmd,
16140 "show ip extcommunity-list",
16141 SHOW_STR
16142 IP_STR
16143 "List extended-community list\n")
16144{
16145 struct community_list *list;
16146 struct community_list_master *cm;
16147
fee6e4e4 16148 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
718e3744 16149 if (! cm)
16150 return CMD_SUCCESS;
16151
16152 for (list = cm->num.head; list; list = list->next)
16153 extcommunity_list_show (vty, list);
16154
16155 for (list = cm->str.head; list; list = list->next)
16156 extcommunity_list_show (vty, list);
16157
16158 return CMD_SUCCESS;
16159}
16160
16161DEFUN (show_ip_extcommunity_list_arg,
16162 show_ip_extcommunity_list_arg_cmd,
fee6e4e4 16163 "show ip extcommunity-list (<1-500>|WORD)",
718e3744 16164 SHOW_STR
16165 IP_STR
16166 "List extended-community list\n"
16167 "Extcommunity-list number\n"
16168 "Extcommunity-list name\n")
16169{
16170 struct community_list *list;
16171
fee6e4e4 16172 list = community_list_lookup (bgp_clist, argv[0], EXTCOMMUNITY_LIST_MASTER);
718e3744 16173 if (! list)
16174 {
b729294c 16175 vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE);
718e3744 16176 return CMD_WARNING;
16177 }
16178
16179 extcommunity_list_show (vty, list);
16180
16181 return CMD_SUCCESS;
16182}
6b0655a2 16183
718e3744 16184/* Return configuration string of community-list entry. */
fd79ac91 16185static const char *
718e3744 16186community_list_config_str (struct community_entry *entry)
16187{
fd79ac91 16188 const char *str;
718e3744 16189
16190 if (entry->any)
16191 str = "";
16192 else
16193 {
16194 if (entry->style == COMMUNITY_LIST_STANDARD)
16195 str = community_str (entry->u.com);
16196 else
16197 str = entry->config;
16198 }
16199 return str;
16200}
16201
16202/* Display community-list and extcommunity-list configuration. */
94f2b392 16203static int
718e3744 16204community_list_config_write (struct vty *vty)
16205{
16206 struct community_list *list;
16207 struct community_entry *entry;
16208 struct community_list_master *cm;
16209 int write = 0;
16210
16211 /* Community-list. */
fee6e4e4 16212 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
718e3744 16213
16214 for (list = cm->num.head; list; list = list->next)
16215 for (entry = list->head; entry; entry = entry->next)
16216 {
fee6e4e4 16217 vty_out (vty, "ip community-list %s %s %s%s",
16218 list->name, community_direct_str (entry->direct),
16219 community_list_config_str (entry),
16220 VTY_NEWLINE);
718e3744 16221 write++;
16222 }
16223 for (list = cm->str.head; list; list = list->next)
16224 for (entry = list->head; entry; entry = entry->next)
16225 {
16226 vty_out (vty, "ip community-list %s %s %s %s%s",
16227 entry->style == COMMUNITY_LIST_STANDARD
16228 ? "standard" : "expanded",
16229 list->name, community_direct_str (entry->direct),
16230 community_list_config_str (entry),
16231 VTY_NEWLINE);
16232 write++;
16233 }
16234
16235 /* Extcommunity-list. */
fee6e4e4 16236 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
718e3744 16237
16238 for (list = cm->num.head; list; list = list->next)
16239 for (entry = list->head; entry; entry = entry->next)
16240 {
fee6e4e4 16241 vty_out (vty, "ip extcommunity-list %s %s %s%s",
16242 list->name, community_direct_str (entry->direct),
16243 community_list_config_str (entry), VTY_NEWLINE);
718e3744 16244 write++;
16245 }
16246 for (list = cm->str.head; list; list = list->next)
16247 for (entry = list->head; entry; entry = entry->next)
16248 {
16249 vty_out (vty, "ip extcommunity-list %s %s %s %s%s",
16250 entry->style == EXTCOMMUNITY_LIST_STANDARD
16251 ? "standard" : "expanded",
16252 list->name, community_direct_str (entry->direct),
16253 community_list_config_str (entry), VTY_NEWLINE);
16254 write++;
16255 }
16256 return write;
16257}
16258
7fc626de 16259static struct cmd_node community_list_node =
718e3744 16260{
16261 COMMUNITY_LIST_NODE,
16262 "",
16263 1 /* Export to vtysh. */
16264};
16265
94f2b392 16266static void
16267community_list_vty (void)
718e3744 16268{
16269 install_node (&community_list_node, community_list_config_write);
16270
16271 /* Community-list. */
718e3744 16272 install_element (CONFIG_NODE, &ip_community_list_standard_cmd);
16273 install_element (CONFIG_NODE, &ip_community_list_standard2_cmd);
16274 install_element (CONFIG_NODE, &ip_community_list_expanded_cmd);
16275 install_element (CONFIG_NODE, &ip_community_list_name_standard_cmd);
16276 install_element (CONFIG_NODE, &ip_community_list_name_standard2_cmd);
16277 install_element (CONFIG_NODE, &ip_community_list_name_expanded_cmd);
fee6e4e4 16278 install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd);
813d4307 16279 install_element (CONFIG_NODE, &no_ip_community_list_standard_direction_cmd);
fee6e4e4 16280 install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd);
16281 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_all_cmd);
16282 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_all_cmd);
718e3744 16283 install_element (CONFIG_NODE, &no_ip_community_list_standard_cmd);
16284 install_element (CONFIG_NODE, &no_ip_community_list_expanded_cmd);
16285 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_cmd);
813d4307 16286 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_brief_cmd);
718e3744 16287 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_cmd);
16288 install_element (VIEW_NODE, &show_ip_community_list_cmd);
16289 install_element (VIEW_NODE, &show_ip_community_list_arg_cmd);
16290 install_element (ENABLE_NODE, &show_ip_community_list_cmd);
16291 install_element (ENABLE_NODE, &show_ip_community_list_arg_cmd);
16292
16293 /* Extcommunity-list. */
16294 install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd);
16295 install_element (CONFIG_NODE, &ip_extcommunity_list_standard2_cmd);
16296 install_element (CONFIG_NODE, &ip_extcommunity_list_expanded_cmd);
16297 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard_cmd);
16298 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard2_cmd);
16299 install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd);
fee6e4e4 16300 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd);
813d4307 16301 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_direction_cmd);
fee6e4e4 16302 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd);
16303 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_all_cmd);
16304 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_all_cmd);
718e3744 16305 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_cmd);
16306 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_cmd);
16307 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_cmd);
813d4307 16308 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_brief_cmd);
718e3744 16309 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_cmd);
16310 install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd);
16311 install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd);
16312 install_element (ENABLE_NODE, &show_ip_extcommunity_list_cmd);
16313 install_element (ENABLE_NODE, &show_ip_extcommunity_list_arg_cmd);
16314}