]> git.proxmox.com Git - mirror_frr.git/blame - bgpd/bgp_vty.c
Expand #defines in command strings
[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
23#include "command.h"
afec25d9 24#include "lib/json.h"
718e3744 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"
fc7948fa 33#include "memory_vty.h"
4bf6a362 34#include "hash.h"
3f9c7369 35#include "queue.h"
039f3a34 36#include "filter.h"
718e3744 37
38#include "bgpd/bgpd.h"
4bf6a362 39#include "bgpd/bgp_advertise.h"
718e3744 40#include "bgpd/bgp_attr.h"
41#include "bgpd/bgp_aspath.h"
42#include "bgpd/bgp_community.h"
4bf6a362
PJ
43#include "bgpd/bgp_ecommunity.h"
44#include "bgpd/bgp_damp.h"
718e3744 45#include "bgpd/bgp_debug.h"
e0701b79 46#include "bgpd/bgp_fsm.h"
718e3744 47#include "bgpd/bgp_mplsvpn.h"
4bf6a362 48#include "bgpd/bgp_nexthop.h"
718e3744 49#include "bgpd/bgp_open.h"
4bf6a362 50#include "bgpd/bgp_regex.h"
718e3744 51#include "bgpd/bgp_route.h"
52#include "bgpd/bgp_zebra.h"
fee0f4c6 53#include "bgpd/bgp_table.h"
94f2b392 54#include "bgpd/bgp_vty.h"
165b5fff 55#include "bgpd/bgp_mpath.h"
cb1faec9 56#include "bgpd/bgp_packet.h"
3f9c7369 57#include "bgpd/bgp_updgrp.h"
c43ed2e4 58#include "bgpd/bgp_bfd.h"
718e3744 59
20eb8864 60static struct peer_group *
61listen_range_exists (struct bgp *bgp, struct prefix *range, int exact);
62
718e3744 63/* Utility function to get address family from current node. */
64afi_t
65bgp_node_afi (struct vty *vty)
66{
4e851f1f
LB
67 afi_t afi;
68 switch (vty->node)
69 {
70 case BGP_IPV6_NODE:
71 case BGP_IPV6M_NODE:
72 case BGP_VPNV6_NODE:
73 case BGP_ENCAPV6_NODE:
74 afi = AFI_IP6;
75 break;
76 default:
77 afi = AFI_IP;
78 break;
79 }
80 return afi;
718e3744 81}
82
83/* Utility function to get subsequent address family from current
84 node. */
85safi_t
86bgp_node_safi (struct vty *vty)
87{
4e851f1f
LB
88 safi_t safi;
89 switch (vty->node)
90 {
91 case BGP_ENCAP_NODE:
92 case BGP_ENCAPV6_NODE:
93 safi = SAFI_ENCAP;
94 break;
95 case BGP_VPNV4_NODE:
96 case BGP_VPNV6_NODE:
97 safi = SAFI_MPLS_VPN;
98 break;
99 case BGP_IPV4M_NODE:
100 case BGP_IPV6M_NODE:
101 safi = SAFI_MULTICAST;
102 break;
103 default:
104 safi = SAFI_UNICAST;
105 break;
106 }
107 return safi;
718e3744 108}
109
8b1fb8be
LB
110int
111bgp_parse_afi(const char *str, afi_t *afi)
112{
113 if (!strcmp(str, "ipv4")) {
114 *afi = AFI_IP;
115 return 0;
116 }
117#ifdef HAVE_IPV6
118 if (!strcmp(str, "ipv6")) {
119 *afi = AFI_IP6;
120 return 0;
121 }
122#endif /* HAVE_IPV6 */
123 return -1;
124}
125
126int
127bgp_parse_safi(const char *str, safi_t *safi)
128{
129 if (!strcmp(str, "encap")) {
130 *safi = SAFI_ENCAP;
131 return 0;
132 }
133 if (!strcmp(str, "multicast")) {
134 *safi = SAFI_MULTICAST;
135 return 0;
136 }
137 if (!strcmp(str, "unicast")) {
138 *safi = SAFI_UNICAST;
139 return 0;
140 }
141 if (!strcmp(str, "vpn")) {
142 *safi = SAFI_MPLS_VPN;
143 return 0;
144 }
145 return -1;
146}
147
94f2b392 148static int
6aeb9e78 149peer_address_self_check (struct bgp *bgp, union sockunion *su)
718e3744 150{
151 struct interface *ifp = NULL;
152
153 if (su->sa.sa_family == AF_INET)
6aeb9e78 154 ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr, bgp->vrf_id);
718e3744 155#ifdef HAVE_IPV6
156 else if (su->sa.sa_family == AF_INET6)
f2345335 157 ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr,
6aeb9e78 158 su->sin6.sin6_scope_id, bgp->vrf_id);
718e3744 159#endif /* HAVE IPV6 */
160
161 if (ifp)
162 return 1;
163
164 return 0;
165}
166
167/* Utility function for looking up peer from VTY. */
f14e6fdb
DS
168/* This is used only for configuration, so disallow if attempted on
169 * a dynamic neighbor.
170 */
94f2b392 171static struct peer *
fd79ac91 172peer_lookup_vty (struct vty *vty, const char *ip_str)
718e3744 173{
174 int ret;
175 struct bgp *bgp;
176 union sockunion su;
177 struct peer *peer;
178
179 bgp = vty->index;
180
181 ret = str2sockunion (ip_str, &su);
182 if (ret < 0)
183 {
a80beece
DS
184 peer = peer_lookup_by_conf_if (bgp, ip_str);
185 if (!peer)
186 {
04b6bdc0
DW
187 if ((peer = peer_lookup_by_hostname(bgp, ip_str)) == NULL)
188 {
189 vty_out (vty, "%% Malformed address or name: %s%s", ip_str, VTY_NEWLINE);
190 return NULL;
191 }
a80beece 192 }
718e3744 193 }
a80beece 194 else
718e3744 195 {
a80beece
DS
196 peer = peer_lookup (bgp, &su);
197 if (! peer)
198 {
199 vty_out (vty, "%% Specify remote-as or peer-group commands first%s",
200 VTY_NEWLINE);
201 return NULL;
202 }
f14e6fdb
DS
203 if (peer_dynamic_neighbor (peer))
204 {
205 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
206 VTY_NEWLINE);
207 return NULL;
208 }
209
718e3744 210 }
211 return peer;
212}
213
214/* Utility function for looking up peer or peer group. */
f14e6fdb
DS
215/* This is used only for configuration, so disallow if attempted on
216 * a dynamic neighbor.
217 */
c43ed2e4 218struct peer *
fd79ac91 219peer_and_group_lookup_vty (struct vty *vty, const char *peer_str)
718e3744 220{
221 int ret;
222 struct bgp *bgp;
223 union sockunion su;
f14e6fdb
DS
224 struct peer *peer = NULL;
225 struct peer_group *group = NULL;
718e3744 226
227 bgp = vty->index;
228
229 ret = str2sockunion (peer_str, &su);
230 if (ret == 0)
231 {
f14e6fdb 232 /* IP address, locate peer. */
718e3744 233 peer = peer_lookup (bgp, &su);
718e3744 234 }
235 else
236 {
f14e6fdb 237 /* Not IP, could match either peer configured on interface or a group. */
a80beece 238 peer = peer_lookup_by_conf_if (bgp, peer_str);
f14e6fdb
DS
239 if (!peer)
240 group = peer_group_lookup (bgp, peer_str);
241 }
a80beece 242
f14e6fdb
DS
243 if (peer)
244 {
245 if (peer_dynamic_neighbor (peer))
246 {
247 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
248 VTY_NEWLINE);
249 return NULL;
250 }
251
252 return peer;
718e3744 253 }
254
f14e6fdb
DS
255 if (group)
256 return group->conf;
257
718e3744 258 vty_out (vty, "%% Specify remote-as or peer-group commands first%s",
259 VTY_NEWLINE);
260
261 return NULL;
262}
263
c43ed2e4 264int
718e3744 265bgp_vty_return (struct vty *vty, int ret)
266{
fd79ac91 267 const char *str = NULL;
718e3744 268
269 switch (ret)
270 {
271 case BGP_ERR_INVALID_VALUE:
272 str = "Invalid value";
273 break;
274 case BGP_ERR_INVALID_FLAG:
275 str = "Invalid flag";
276 break;
718e3744 277 case BGP_ERR_PEER_GROUP_SHUTDOWN:
278 str = "Peer-group has been shutdown. Activate the peer-group first";
279 break;
718e3744 280 case BGP_ERR_PEER_FLAG_CONFLICT:
281 str = "Can't set override-capability and strict-capability-match at the same time";
282 break;
718e3744 283 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS:
284 str = "Specify remote-as or peer-group remote AS first";
285 break;
286 case BGP_ERR_PEER_GROUP_CANT_CHANGE:
287 str = "Cannot change the peer-group. Deconfigure first";
288 break;
289 case BGP_ERR_PEER_GROUP_MISMATCH:
4c48cf63 290 str = "Peer is not a member of this peer-group";
718e3744 291 break;
292 case BGP_ERR_PEER_FILTER_CONFLICT:
293 str = "Prefix/distribute list can not co-exist";
294 break;
295 case BGP_ERR_NOT_INTERNAL_PEER:
296 str = "Invalid command. Not an internal neighbor";
297 break;
298 case BGP_ERR_REMOVE_PRIVATE_AS:
5000f21c 299 str = "remove-private-AS cannot be configured for IBGP peers";
718e3744 300 break;
301 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP:
302 str = "Local-AS allowed only for EBGP peers";
303 break;
304 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS:
305 str = "Cannot have local-as same as BGP AS number";
306 break;
0df7c91f
PJ
307 case BGP_ERR_TCPSIG_FAILED:
308 str = "Error while applying TCP-Sig to session(s)";
309 break;
fa411a21
NH
310 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK:
311 str = "ebgp-multihop and ttl-security cannot be configured together";
312 break;
f5a4827d
SH
313 case BGP_ERR_NO_IBGP_WITH_TTLHACK:
314 str = "ttl-security only allowed for EBGP peers";
315 break;
c7122e14
DS
316 case BGP_ERR_AS_OVERRIDE:
317 str = "as-override cannot be configured for IBGP peers";
318 break;
f14e6fdb
DS
319 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT:
320 str = "Invalid limit for number of dynamic neighbors";
321 break;
322 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS:
323 str = "Dynamic neighbor listen range already exists";
324 break;
325 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER:
326 str = "Operation not allowed on a dynamic neighbor";
327 break;
63fa10b5
QY
328 case BGP_ERR_INVALID_FOR_DIRECT_PEER:
329 str = "Operation not allowed on a directly connected neighbor";
330 break;
718e3744 331 }
332 if (str)
333 {
334 vty_out (vty, "%% %s%s", str, VTY_NEWLINE);
335 return CMD_WARNING;
336 }
337 return CMD_SUCCESS;
338}
339
7aafcaca
DS
340/* BGP clear sort. */
341enum clear_sort
342{
343 clear_all,
344 clear_peer,
345 clear_group,
346 clear_external,
347 clear_as
348};
349
7aafcaca
DS
350static void
351bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi,
352 safi_t safi, int error)
353{
354 switch (error)
355 {
356 case BGP_ERR_AF_UNCONFIGURED:
357 vty_out (vty,
358 "%%BGP: Enable %s %s address family for the neighbor %s%s",
359 afi == AFI_IP6 ? "IPv6" : safi == SAFI_MPLS_VPN ? "VPNv4" : "IPv4",
360 safi == SAFI_MULTICAST ? "Multicast" : "Unicast",
361 peer->host, VTY_NEWLINE);
362 break;
363 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED:
364 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);
365 break;
366 default:
367 break;
368 }
369}
370
371/* `clear ip bgp' functions. */
372static int
373bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
374 enum clear_sort sort,enum bgp_clear_type stype, const char *arg)
375{
376 int ret;
377 struct peer *peer;
378 struct listnode *node, *nnode;
379
380 /* Clear all neighbors. */
381 /*
382 * Pass along pointer to next node to peer_clear() when walking all nodes
383 * on the BGP instance as that may get freed if it is a doppelganger
384 */
385 if (sort == clear_all)
386 {
387 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
388 {
389 if (stype == BGP_CLEAR_SOFT_NONE)
390 ret = peer_clear (peer, &nnode);
391 else if (peer->afc[afi][safi])
392 ret = peer_clear_soft (peer, afi, safi, stype);
393 else
394 ret = 0;
395
396 if (ret < 0)
397 bgp_clear_vty_error (vty, peer, afi, safi, ret);
398 }
399
400 /* This is to apply read-only mode on this clear. */
401 if (stype == BGP_CLEAR_SOFT_NONE)
402 bgp->update_delay_over = 0;
403
404 return CMD_SUCCESS;
405 }
406
407 /* Clear specified neighbors. */
408 if (sort == clear_peer)
409 {
410 union sockunion su;
411 int ret;
412
413 /* Make sockunion for lookup. */
414 ret = str2sockunion (arg, &su);
415 if (ret < 0)
416 {
417 peer = peer_lookup_by_conf_if (bgp, arg);
418 if (!peer)
419 {
04b6bdc0
DW
420 peer = peer_lookup_by_hostname(bgp, arg);
421 if (!peer)
422 {
423 vty_out (vty, "Malformed address or name: %s%s", arg, VTY_NEWLINE);
424 return CMD_WARNING;
425 }
7aafcaca
DS
426 }
427 }
428 else
429 {
430 peer = peer_lookup (bgp, &su);
431 if (! peer)
432 {
433 vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE);
434 return CMD_WARNING;
435 }
436 }
437
438 if (stype == BGP_CLEAR_SOFT_NONE)
439 ret = peer_clear (peer, NULL);
440 else
441 ret = peer_clear_soft (peer, afi, safi, stype);
442
443 if (ret < 0)
444 bgp_clear_vty_error (vty, peer, afi, safi, ret);
445
446 return CMD_SUCCESS;
447 }
448
449 /* Clear all peer-group members. */
450 if (sort == clear_group)
451 {
452 struct peer_group *group;
453
454 group = peer_group_lookup (bgp, arg);
455 if (! group)
456 {
457 vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE);
458 return CMD_WARNING;
459 }
460
461 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
462 {
463 if (stype == BGP_CLEAR_SOFT_NONE)
464 {
18f1dc06 465 peer_clear (peer, NULL);
7aafcaca
DS
466 continue;
467 }
468
c8560b44 469 if (! peer->afc[afi][safi])
7aafcaca
DS
470 continue;
471
472 ret = peer_clear_soft (peer, afi, safi, stype);
473
474 if (ret < 0)
475 bgp_clear_vty_error (vty, peer, afi, safi, ret);
476 }
477 return CMD_SUCCESS;
478 }
479
480 if (sort == clear_external)
481 {
482 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
483 {
484 if (peer->sort == BGP_PEER_IBGP)
485 continue;
486
487 if (stype == BGP_CLEAR_SOFT_NONE)
488 ret = peer_clear (peer, &nnode);
489 else
490 ret = peer_clear_soft (peer, afi, safi, stype);
491
492 if (ret < 0)
493 bgp_clear_vty_error (vty, peer, afi, safi, ret);
494 }
495 return CMD_SUCCESS;
496 }
497
498 if (sort == clear_as)
499 {
500 as_t as;
501 int find = 0;
502
503 VTY_GET_INTEGER_RANGE ("AS", as, arg, 1, BGP_AS4_MAX);
504
505 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
506 {
507 if (peer->as != as)
508 continue;
509
510 find = 1;
511 if (stype == BGP_CLEAR_SOFT_NONE)
512 ret = peer_clear (peer, &nnode);
513 else
514 ret = peer_clear_soft (peer, afi, safi, stype);
515
516 if (ret < 0)
517 bgp_clear_vty_error (vty, peer, afi, safi, ret);
518 }
519 if (! find)
520 vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg,
521 VTY_NEWLINE);
522 return CMD_SUCCESS;
523 }
524
525 return CMD_SUCCESS;
526}
527
528static int
529bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi,
530 enum clear_sort sort, enum bgp_clear_type stype,
531 const char *arg)
532{
533 struct bgp *bgp;
534
535 /* BGP structure lookup. */
536 if (name)
537 {
538 bgp = bgp_lookup_by_name (name);
539 if (bgp == NULL)
540 {
6aeb9e78 541 vty_out (vty, "Can't find BGP instance %s%s", name, VTY_NEWLINE);
7aafcaca
DS
542 return CMD_WARNING;
543 }
544 }
545 else
546 {
f31fa004 547 bgp = bgp_get_default ();
7aafcaca
DS
548 if (bgp == NULL)
549 {
550 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
551 return CMD_WARNING;
552 }
553 }
554
555 return bgp_clear (vty, bgp, afi, safi, sort, stype, arg);
556}
557
558/* clear soft inbound */
559static void
f31fa004 560bgp_clear_star_soft_in (struct vty *vty, const char *name)
7aafcaca 561{
f31fa004 562 bgp_clear_vty (vty,name, AFI_IP, SAFI_UNICAST, clear_all,
7aafcaca 563 BGP_CLEAR_SOFT_IN, NULL);
f31fa004 564 bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all,
7aafcaca 565 BGP_CLEAR_SOFT_IN, NULL);
7aafcaca
DS
566}
567
568/* clear soft outbound */
569static void
f31fa004 570bgp_clear_star_soft_out (struct vty *vty, const char *name)
7aafcaca 571{
f31fa004 572 bgp_clear_vty (vty, name, AFI_IP, SAFI_UNICAST, clear_all,
7aafcaca 573 BGP_CLEAR_SOFT_OUT, NULL);
f31fa004 574 bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all,
7aafcaca 575 BGP_CLEAR_SOFT_OUT, NULL);
7aafcaca
DS
576}
577
578
718e3744 579/* BGP global configuration. */
580
581DEFUN (bgp_multiple_instance_func,
582 bgp_multiple_instance_cmd,
583 "bgp multiple-instance",
584 BGP_STR
585 "Enable bgp multiple instance\n")
586{
587 bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE);
588 return CMD_SUCCESS;
589}
590
591DEFUN (no_bgp_multiple_instance,
592 no_bgp_multiple_instance_cmd,
593 "no bgp multiple-instance",
594 NO_STR
595 BGP_STR
596 "BGP multiple instance\n")
597{
598 int ret;
599
600 ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE);
601 if (ret < 0)
602 {
603 vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE);
604 return CMD_WARNING;
605 }
606 return CMD_SUCCESS;
607}
608
609DEFUN (bgp_config_type,
610 bgp_config_type_cmd,
6147e2c6 611 "bgp config-type <cisco|zebra>",
718e3744 612 BGP_STR
613 "Configuration type\n"
614 "cisco\n"
615 "zebra\n")
616{
c500ae40
DW
617 int idx_vendor = 2;
618 if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0)
718e3744 619 bgp_option_set (BGP_OPT_CONFIG_CISCO);
620 else
621 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
622
623 return CMD_SUCCESS;
624}
625
626DEFUN (no_bgp_config_type,
627 no_bgp_config_type_cmd,
838758ac 628 "no bgp config-type [cisco|zebra]",
718e3744 629 NO_STR
630 BGP_STR
838758ac
DW
631 "Display configuration type\n"
632 "cisco\n"
633 "zebra\n")
718e3744 634{
635 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
636 return CMD_SUCCESS;
637}
638
813d4307 639
718e3744 640DEFUN (no_synchronization,
641 no_synchronization_cmd,
642 "no synchronization",
643 NO_STR
644 "Perform IGP synchronization\n")
645{
646 return CMD_SUCCESS;
647}
648
649DEFUN (no_auto_summary,
650 no_auto_summary_cmd,
651 "no auto-summary",
652 NO_STR
653 "Enable automatic network number summarization\n")
654{
655 return CMD_SUCCESS;
656}
3d515fd9 657
718e3744 658/* "router bgp" commands. */
f412b39a
DW
659/*
660 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
661 * "router bgp",
662 * ROUTER_STR
663 * BGP_STR
664 *
9ccf14f7 665 * "router bgp (1-4294967295) (view|vrf) WORD",
f412b39a
DW
666 * ROUTER_STR
667 * BGP_STR
668 * AS_STR
669 * "BGP view\nBGP VRF\n"
670 * "View/VRF name\n"
671 *
672 */
673DEFUN (router_bgp,
674 router_bgp_cmd,
9ccf14f7 675 "router bgp (1-4294967295)",
718e3744 676 ROUTER_STR
677 BGP_STR
678 AS_STR)
679{
c500ae40 680 int idx_number = 2;
718e3744 681 int ret;
682 as_t as;
683 struct bgp *bgp;
fd79ac91 684 const char *name = NULL;
ad4cbda1 685 enum bgp_instance_type inst_type;
718e3744 686
2385a876
DW
687 // "router bgp" without an ASN
688 if (argc < 1)
689 {
6aeb9e78 690 //Pending: Make VRF option available for ASN less config
2385a876 691 bgp = bgp_get_default();
718e3744 692
2385a876
DW
693 if (bgp == NULL)
694 {
695 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
696 return CMD_WARNING;
697 }
718e3744 698
2385a876
DW
699 if (listcount(bm->bgp) > 1)
700 {
701 vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE);
702 return CMD_WARNING;
703 }
704 }
705
706 // "router bgp X"
707 else
718e3744 708 {
c500ae40 709 VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX);
2385a876 710
ad4cbda1 711 inst_type = BGP_INSTANCE_TYPE_DEFAULT;
6aeb9e78 712 if (argc == 3)
ad4cbda1 713 {
afec25d9
DW
714 name = argv[4]->arg;
715 if (!strcmp(argv[3]->arg, "vrf"))
ad4cbda1 716 inst_type = BGP_INSTANCE_TYPE_VRF;
afec25d9 717 else if (!strcmp(argv[3]->arg, "view"))
ad4cbda1 718 inst_type = BGP_INSTANCE_TYPE_VIEW;
719 }
2385a876 720
ad4cbda1 721 ret = bgp_get (&bgp, &as, name, inst_type);
2385a876
DW
722 switch (ret)
723 {
724 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET:
725 vty_out (vty, "Please specify 'bgp multiple-instance' first%s",
726 VTY_NEWLINE);
727 return CMD_WARNING;
728 case BGP_ERR_AS_MISMATCH:
729 vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE);
730 return CMD_WARNING;
731 case BGP_ERR_INSTANCE_MISMATCH:
6aeb9e78 732 vty_out (vty, "BGP instance name and AS number mismatch%s", VTY_NEWLINE);
2385a876
DW
733 vty_out (vty, "BGP instance is already running; AS is %u%s",
734 as, VTY_NEWLINE);
735 return CMD_WARNING;
736 }
6aeb9e78
DS
737
738 /* Pending: handle when user tries to change a view to vrf n vv. */
718e3744 739 }
740
741 vty->node = BGP_NODE;
742 vty->index = bgp;
743
744 return CMD_SUCCESS;
745}
746
718e3744 747/* "no router bgp" commands. */
f412b39a
DW
748/*
749 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
750 * "no router bgp",
751 * NO_STR
752 * ROUTER_STR
753 * BGP_STR
754 *
9ccf14f7 755 * "no router bgp (1-4294967295) (view|vrf) WORD",
f412b39a
DW
756 * NO_STR
757 * ROUTER_STR
758 * BGP_STR
759 * AS_STR
760 * "BGP view\nBGP VRF\n"
761 * "View/VRF name\n"
762 *
763 */
718e3744 764DEFUN (no_router_bgp,
765 no_router_bgp_cmd,
9ccf14f7 766 "no router bgp (1-4294967295)",
718e3744 767 NO_STR
768 ROUTER_STR
769 BGP_STR
770 AS_STR)
771{
c500ae40 772 int idx_number = 3;
718e3744 773 as_t as;
774 struct bgp *bgp;
fd79ac91 775 const char *name = NULL;
718e3744 776
718e3744 777
7fb21a9f
QY
778 // "no router bgp" without an ASN
779 if (argc < 1)
780 {
781 //Pending: Make VRF option available for ASN less config
782 bgp = bgp_get_default();
718e3744 783
7fb21a9f
QY
784 if (bgp == NULL)
785 {
786 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
787 return CMD_WARNING;
788 }
789
790 if (listcount(bm->bgp) > 1)
791 {
792 vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE);
793 return CMD_WARNING;
794 }
795 }
796 else
718e3744 797 {
c500ae40 798 VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX);
7fb21a9f
QY
799
800 if (argc == 3)
afec25d9 801 name = argv[5]->arg;
7fb21a9f
QY
802
803 /* Lookup bgp structure. */
804 bgp = bgp_lookup (as, name);
805 if (! bgp)
806 {
807 vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE);
808 return CMD_WARNING;
809 }
718e3744 810 }
811
812 bgp_delete (bgp);
813
814 return CMD_SUCCESS;
815}
816
6b0655a2 817
7fb21a9f 818
718e3744 819/* BGP router-id. */
820
821DEFUN (bgp_router_id,
822 bgp_router_id_cmd,
823 "bgp router-id A.B.C.D",
824 BGP_STR
825 "Override configured router identifier\n"
826 "Manually configured router identifier\n")
827{
c500ae40 828 int idx_ipv4 = 2;
718e3744 829 int ret;
830 struct in_addr id;
831 struct bgp *bgp;
832
833 bgp = vty->index;
834
c500ae40 835 ret = inet_aton (argv[idx_ipv4]->arg, &id);
718e3744 836 if (! ret)
837 {
838 vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE);
839 return CMD_WARNING;
840 }
841
0e6cb743 842 bgp_router_id_static_set (bgp, id);
718e3744 843
844 return CMD_SUCCESS;
845}
846
f412b39a
DW
847/*
848 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
849 * "no bgp router-id A.B.C.D",
850 * NO_STR
851 * BGP_STR
852 * "Override configured router identifier\n"
853 * "Manually configured router identifier\n"
854 *
855 */
718e3744 856DEFUN (no_bgp_router_id,
857 no_bgp_router_id_cmd,
858 "no bgp router-id",
859 NO_STR
860 BGP_STR
861 "Override configured router identifier\n")
862{
863 int ret;
864 struct in_addr id;
865 struct bgp *bgp;
866
867 bgp = vty->index;
868
869 if (argc == 1)
870 {
afec25d9 871 ret = inet_aton (argv[3]->arg, &id);
718e3744 872 if (! ret)
e018c7cc
SK
873 {
874 vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE);
875 return CMD_WARNING;
876 }
718e3744 877
18a6dce6 878 if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id))
e018c7cc
SK
879 {
880 vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE);
881 return CMD_WARNING;
882 }
718e3744 883 }
884
0e6cb743
DL
885 id.s_addr = 0;
886 bgp_router_id_static_set (bgp, id);
718e3744 887
888 return CMD_SUCCESS;
889}
890
6b0655a2 891
718e3744 892/* BGP Cluster ID. */
718e3744 893DEFUN (bgp_cluster_id,
894 bgp_cluster_id_cmd,
838758ac 895 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
718e3744 896 BGP_STR
897 "Configure Route-Reflector Cluster-id\n"
838758ac
DW
898 "Route-Reflector Cluster-id in IP address format\n"
899 "Route-Reflector Cluster-id as 32 bit quantity\n")
718e3744 900{
c500ae40 901 int idx_ipv4 = 2;
718e3744 902 int ret;
903 struct bgp *bgp;
904 struct in_addr cluster;
905
906 bgp = vty->index;
907
c500ae40 908 ret = inet_aton (argv[idx_ipv4]->arg, &cluster);
718e3744 909 if (! ret)
910 {
911 vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
912 return CMD_WARNING;
913 }
914
915 bgp_cluster_id_set (bgp, &cluster);
f31fa004 916 bgp_clear_star_soft_out (vty, bgp->name);
718e3744 917
918 return CMD_SUCCESS;
919}
920
718e3744 921DEFUN (no_bgp_cluster_id,
922 no_bgp_cluster_id_cmd,
838758ac 923 "no bgp cluster-id [A.B.C.D|(1-4294967295)]",
718e3744 924 NO_STR
925 BGP_STR
838758ac
DW
926 "Configure Route-Reflector Cluster-id\n"
927 "Route-Reflector Cluster-id in IP address format\n"
928 "Route-Reflector Cluster-id as 32 bit quantity\n")
718e3744 929{
718e3744 930 struct bgp *bgp;
718e3744 931
932 bgp = vty->index;
718e3744 933 bgp_cluster_id_unset (bgp);
f31fa004 934 bgp_clear_star_soft_out (vty, bgp->name);
718e3744 935
936 return CMD_SUCCESS;
937}
938
718e3744 939DEFUN (bgp_confederation_identifier,
940 bgp_confederation_identifier_cmd,
9ccf14f7 941 "bgp confederation identifier (1-4294967295)",
718e3744 942 "BGP specific commands\n"
943 "AS confederation parameters\n"
944 "AS number\n"
945 "Set routing domain confederation AS\n")
946{
c500ae40 947 int idx_number = 3;
718e3744 948 struct bgp *bgp;
949 as_t as;
950
951 bgp = vty->index;
952
c500ae40 953 VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX);
718e3744 954
955 bgp_confederation_id_set (bgp, as);
956
957 return CMD_SUCCESS;
958}
959
960DEFUN (no_bgp_confederation_identifier,
961 no_bgp_confederation_identifier_cmd,
838758ac 962 "no bgp confederation identifier [(1-4294967295)]",
718e3744 963 NO_STR
964 "BGP specific commands\n"
965 "AS confederation parameters\n"
966 "AS number\n")
967{
968 struct bgp *bgp;
718e3744 969
970 bgp = vty->index;
718e3744 971 bgp_confederation_id_unset (bgp);
972
973 return CMD_SUCCESS;
974}
975
718e3744 976DEFUN (bgp_confederation_peers,
977 bgp_confederation_peers_cmd,
9ccf14f7 978 "bgp confederation peers . (1-4294967295)",
718e3744 979 "BGP specific commands\n"
980 "AS confederation parameters\n"
981 "Peer ASs in BGP confederation\n"
982 AS_STR)
983{
984 struct bgp *bgp;
985 as_t as;
986 int i;
987
988 bgp = vty->index;
989
990 for (i = 0; i < argc; i++)
991 {
afec25d9 992 VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX);
718e3744 993
994 if (bgp->as == as)
995 {
996 vty_out (vty, "%% Local member-AS not allowed in confed peer list%s",
997 VTY_NEWLINE);
998 continue;
999 }
1000
1001 bgp_confederation_peers_add (bgp, as);
1002 }
1003 return CMD_SUCCESS;
1004}
1005
1006DEFUN (no_bgp_confederation_peers,
1007 no_bgp_confederation_peers_cmd,
9ccf14f7 1008 "no bgp confederation peers . (1-4294967295)",
718e3744 1009 NO_STR
1010 "BGP specific commands\n"
1011 "AS confederation parameters\n"
1012 "Peer ASs in BGP confederation\n"
1013 AS_STR)
1014{
1015 struct bgp *bgp;
1016 as_t as;
1017 int i;
1018
1019 bgp = vty->index;
1020
1021 for (i = 0; i < argc; i++)
1022 {
afec25d9 1023 VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX);
0b2aa3a0 1024
718e3744 1025 bgp_confederation_peers_remove (bgp, as);
1026 }
1027 return CMD_SUCCESS;
1028}
6b0655a2 1029
5e242b0d
DS
1030/**
1031 * Central routine for maximum-paths configuration.
1032 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1033 * @set: 1 for setting values, 0 for removing the max-paths config.
1034 */
ffd0c037
DS
1035static int
1036bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths,
5e242b0d 1037 u_int16_t options, int set)
165b5fff
JB
1038{
1039 struct bgp *bgp;
ffd0c037 1040 u_int16_t maxpaths = 0;
165b5fff 1041 int ret;
5e242b0d
DS
1042 afi_t afi;
1043 safi_t safi;
165b5fff
JB
1044
1045 bgp = vty->index;
5e242b0d
DS
1046 afi = bgp_node_afi (vty);
1047 safi = bgp_node_safi (vty);
165b5fff 1048
5e242b0d
DS
1049 if (set)
1050 {
73ac8160 1051 VTY_GET_INTEGER_RANGE ("maximum-paths", maxpaths, mpaths, 1,
5b964da3 1052 MULTIPATH_NUM);
5e242b0d
DS
1053 ret = bgp_maximum_paths_set (bgp, afi, safi, peer_type, maxpaths,
1054 options);
1055 }
1056 else
1057 ret = bgp_maximum_paths_unset (bgp, afi, safi, peer_type);
165b5fff 1058
165b5fff
JB
1059 if (ret < 0)
1060 {
1061 vty_out (vty,
5e242b0d
DS
1062 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u%s",
1063 (set == 1) ? "" : "un",
1064 (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp",
1065 maxpaths, afi, safi, VTY_NEWLINE);
165b5fff
JB
1066 return CMD_WARNING;
1067 }
1068
7aafcaca
DS
1069 bgp_recalculate_all_bestpaths (bgp);
1070
165b5fff
JB
1071 return CMD_SUCCESS;
1072}
1073
abc920f8
DS
1074DEFUN (bgp_maxmed_admin,
1075 bgp_maxmed_admin_cmd,
1076 "bgp max-med administrative ",
1077 BGP_STR
1078 "Advertise routes with max-med\n"
1079 "Administratively applied, for an indefinite period\n")
1080{
1081 struct bgp *bgp;
1082
1083 bgp = vty->index;
1084
1085 bgp->v_maxmed_admin = 1;
1086 bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT;
1087
1088 bgp_maxmed_update(bgp);
1089
1090 return CMD_SUCCESS;
1091}
1092
1093DEFUN (bgp_maxmed_admin_medv,
1094 bgp_maxmed_admin_medv_cmd,
6147e2c6 1095 "bgp max-med administrative (0-4294967294)",
abc920f8
DS
1096 BGP_STR
1097 "Advertise routes with max-med\n"
1098 "Administratively applied, for an indefinite period\n"
1099 "Max MED value to be used\n")
1100{
c500ae40 1101 int idx_number = 3;
abc920f8
DS
1102 struct bgp *bgp;
1103
1104 bgp = vty->index;
1105
1106 bgp->v_maxmed_admin = 1;
c500ae40 1107 VTY_GET_INTEGER ("max-med admin med-value", bgp->maxmed_admin_value, argv[idx_number]->arg);
abc920f8
DS
1108
1109 bgp_maxmed_update(bgp);
1110
1111 return CMD_SUCCESS;
1112}
1113
1114DEFUN (no_bgp_maxmed_admin,
1115 no_bgp_maxmed_admin_cmd,
8334fd5a 1116 "no bgp max-med administrative [(0-4294967294)]",
abc920f8
DS
1117 NO_STR
1118 BGP_STR
1119 "Advertise routes with max-med\n"
838758ac
DW
1120 "Administratively applied, for an indefinite period\n"
1121 "Max MED value to be used\n")
abc920f8
DS
1122{
1123 struct bgp *bgp;
1124
1125 bgp = vty->index;
abc920f8
DS
1126 bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED;
1127 bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT;
abc920f8
DS
1128 bgp_maxmed_update(bgp);
1129
1130 return CMD_SUCCESS;
1131}
1132
abc920f8
DS
1133DEFUN (bgp_maxmed_onstartup,
1134 bgp_maxmed_onstartup_cmd,
6147e2c6 1135 "bgp max-med on-startup (5-86400)",
abc920f8
DS
1136 BGP_STR
1137 "Advertise routes with max-med\n"
1138 "Effective on a startup\n"
1139 "Time (seconds) period for max-med\n")
1140{
c500ae40 1141 int idx_number = 3;
abc920f8
DS
1142 struct bgp *bgp;
1143
1144 bgp = vty->index;
1145
1146 if (argc != 1)
1147 {
1148 vty_out (vty, "%% Must supply max-med on-startup period");
1149 return CMD_WARNING;
1150 }
1151
c500ae40 1152 VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg);
abc920f8
DS
1153 bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT;
1154
1155 bgp_maxmed_update(bgp);
1156
1157 return CMD_SUCCESS;
1158}
1159
1160DEFUN (bgp_maxmed_onstartup_medv,
1161 bgp_maxmed_onstartup_medv_cmd,
6147e2c6 1162 "bgp max-med on-startup (5-86400) (0-4294967294)",
abc920f8
DS
1163 BGP_STR
1164 "Advertise routes with max-med\n"
1165 "Effective on a startup\n"
1166 "Time (seconds) period for max-med\n"
1167 "Max MED value to be used\n")
1168{
c500ae40
DW
1169 int idx_number = 3;
1170 int idx_number_2 = 4;
abc920f8
DS
1171 struct bgp *bgp;
1172
1173 bgp = vty->index;
1174
1175 if (argc != 2)
1176 {
1177 vty_out (vty, "%% Must supply max-med on-startup period and med value");
1178 return CMD_WARNING;
1179 }
1180
c500ae40
DW
1181 VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg);
1182 VTY_GET_INTEGER ("max-med on-startup med-value", bgp->maxmed_onstartup_value, argv[idx_number_2]->arg);
abc920f8
DS
1183
1184 bgp_maxmed_update(bgp);
1185
1186 return CMD_SUCCESS;
1187}
1188
1189DEFUN (no_bgp_maxmed_onstartup,
1190 no_bgp_maxmed_onstartup_cmd,
8334fd5a 1191 "no bgp max-med on-startup [(5-86400) [(0-4294967294)]]",
abc920f8
DS
1192 NO_STR
1193 BGP_STR
1194 "Advertise routes with max-med\n"
838758ac
DW
1195 "Effective on a startup\n"
1196 "Time (seconds) period for max-med\n"
1197 "Max MED value to be used\n")
abc920f8
DS
1198{
1199 struct bgp *bgp;
1200
1201 bgp = vty->index;
1202
1203 /* Cancel max-med onstartup if its on */
1204 if (bgp->t_maxmed_onstartup)
1205 {
1206 THREAD_TIMER_OFF (bgp->t_maxmed_onstartup);
1207 bgp->maxmed_onstartup_over = 1;
1208 }
1209
1210 bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED;
1211 bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT;
1212
1213 bgp_maxmed_update(bgp);
1214
1215 return CMD_SUCCESS;
1216}
1217
f188f2c4
DS
1218static int
1219bgp_update_delay_config_vty (struct vty *vty, const char *delay,
1220 const char *wait)
1221{
1222 struct bgp *bgp;
1223 u_int16_t update_delay;
1224 u_int16_t establish_wait;
1225
1226
1227 bgp = vty->index;
1228
1229 VTY_GET_INTEGER_RANGE ("update-delay", update_delay, delay,
1230 BGP_UPDATE_DELAY_MIN, BGP_UPDATE_DELAY_MAX);
1231
1232 if (!wait) /* update-delay <delay> */
1233 {
1234 bgp->v_update_delay = update_delay;
1235 bgp->v_establish_wait = bgp->v_update_delay;
1236 return CMD_SUCCESS;
1237 }
1238
1239 /* update-delay <delay> <establish-wait> */
1240 establish_wait = atoi (wait);
1241 if (update_delay < establish_wait)
1242 {
1243 vty_out (vty, "%%Failed: update-delay less than the establish-wait!%s",
1244 VTY_NEWLINE);
1245 return CMD_WARNING;
1246 }
1247
1248 bgp->v_update_delay = update_delay;
1249 bgp->v_establish_wait = establish_wait;
1250
1251 return CMD_SUCCESS;
1252}
1253
1254static int
1255bgp_update_delay_deconfig_vty (struct vty *vty)
1256{
1257 struct bgp *bgp;
1258
1259 bgp = vty->index;
1260
1261 bgp->v_update_delay = BGP_UPDATE_DELAY_DEF;
1262 bgp->v_establish_wait = bgp->v_update_delay;
1263
1264 return CMD_SUCCESS;
1265}
1266
1267int
1268bgp_config_write_update_delay (struct vty *vty, struct bgp *bgp)
1269{
1270 if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF)
1271 {
1272 vty_out (vty, " update-delay %d", bgp->v_update_delay);
1273 if (bgp->v_update_delay != bgp->v_establish_wait)
1274 vty_out (vty, " %d", bgp->v_establish_wait);
1275 vty_out (vty, "%s", VTY_NEWLINE);
1276 }
1277
1278 return 0;
1279}
1280
1281
1282/* Update-delay configuration */
1283DEFUN (bgp_update_delay,
1284 bgp_update_delay_cmd,
6147e2c6 1285 "update-delay (0-3600)",
f188f2c4
DS
1286 "Force initial delay for best-path and updates\n"
1287 "Seconds\n")
1288{
c500ae40
DW
1289 int idx_number = 1;
1290 return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL);
f188f2c4
DS
1291}
1292
1293DEFUN (bgp_update_delay_establish_wait,
1294 bgp_update_delay_establish_wait_cmd,
6147e2c6 1295 "update-delay (0-3600) (1-3600)",
f188f2c4
DS
1296 "Force initial delay for best-path and updates\n"
1297 "Seconds\n"
1298 "Wait for peers to be established\n"
1299 "Seconds\n")
1300{
c500ae40
DW
1301 int idx_number = 1;
1302 int idx_number_2 = 2;
1303 return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, argv[idx_number_2]->arg);
f188f2c4
DS
1304}
1305
1306/* Update-delay deconfiguration */
1307DEFUN (no_bgp_update_delay,
1308 no_bgp_update_delay_cmd,
838758ac
DW
1309 "no update-delay [(0-3600) [(1-3600)]]",
1310 NO_STR
f188f2c4 1311 "Force initial delay for best-path and updates\n"
838758ac
DW
1312 "Seconds\n"
1313 "Wait for peers to be established\n")
f188f2c4
DS
1314{
1315 return bgp_update_delay_deconfig_vty(vty);
1316}
1317
5e242b0d 1318
ffd0c037
DS
1319static int
1320bgp_wpkt_quanta_config_vty (struct vty *vty, const char *num, char set)
cb1faec9
DS
1321{
1322 struct bgp *bgp;
cb1faec9
DS
1323
1324 bgp = vty->index;
1325
1326 if (set)
1327 VTY_GET_INTEGER_RANGE ("write-quanta", bgp->wpkt_quanta, num,
4543bbb4 1328 1, 10000);
cb1faec9
DS
1329 else
1330 bgp->wpkt_quanta = BGP_WRITE_PACKET_MAX;
1331
1332 return CMD_SUCCESS;
1333}
1334
1335int
1336bgp_config_write_wpkt_quanta (struct vty *vty, struct bgp *bgp)
1337{
1338 if (bgp->wpkt_quanta != BGP_WRITE_PACKET_MAX)
1339 vty_out (vty, " write-quanta %d%s",
1340 bgp->wpkt_quanta, VTY_NEWLINE);
1341
1342 return 0;
1343}
1344
1345
1346/* Update-delay configuration */
1347DEFUN (bgp_wpkt_quanta,
1348 bgp_wpkt_quanta_cmd,
6147e2c6 1349 "write-quanta (1-10000)",
cb1faec9
DS
1350 "How many packets to write to peer socket per run\n"
1351 "Number of packets\n")
1352{
c500ae40
DW
1353 int idx_number = 1;
1354 return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1);
cb1faec9
DS
1355}
1356
1357/* Update-delay deconfiguration */
1358DEFUN (no_bgp_wpkt_quanta,
1359 no_bgp_wpkt_quanta_cmd,
6147e2c6 1360 "no write-quanta (1-10000)",
cb1faec9
DS
1361 "How many packets to write to peer socket per run\n"
1362 "Number of packets\n")
1363{
c500ae40
DW
1364 int idx_number = 2;
1365 return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0);
cb1faec9
DS
1366}
1367
ffd0c037 1368static int
3f9c7369
DS
1369bgp_coalesce_config_vty (struct vty *vty, const char *num, char set)
1370{
1371 struct bgp *bgp;
1372
1373 bgp = vty->index;
1374
1375 if (set)
1376 VTY_GET_INTEGER_RANGE ("coalesce-time", bgp->coalesce_time, num,
1377 0, 4294967295);
1378 else
1379 bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME;
1380
1381 return CMD_SUCCESS;
1382}
1383
1384int
1385bgp_config_write_coalesce_time (struct vty *vty, struct bgp *bgp)
1386{
1387 if (bgp->coalesce_time != BGP_DEFAULT_SUBGROUP_COALESCE_TIME)
1388 vty_out (vty, " coalesce-time %d%s",
1389 bgp->coalesce_time, VTY_NEWLINE);
1390
1391 return 0;
1392}
1393
1394
1395DEFUN (bgp_coalesce_time,
1396 bgp_coalesce_time_cmd,
6147e2c6 1397 "coalesce-time (0-4294967295)",
3f9c7369
DS
1398 "Subgroup coalesce timer\n"
1399 "Subgroup coalesce timer value (in ms)\n")
1400{
c500ae40
DW
1401 int idx_number = 1;
1402 return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 1);
3f9c7369
DS
1403}
1404
1405DEFUN (no_bgp_coalesce_time,
1406 no_bgp_coalesce_time_cmd,
6147e2c6 1407 "no coalesce-time (0-4294967295)",
3f9c7369
DS
1408 "Subgroup coalesce timer\n"
1409 "Subgroup coalesce timer value (in ms)\n")
1410{
c500ae40
DW
1411 int idx_number = 2;
1412 return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 0);
3f9c7369
DS
1413}
1414
5e242b0d
DS
1415/* Maximum-paths configuration */
1416DEFUN (bgp_maxpaths,
1417 bgp_maxpaths_cmd,
9ccf14f7 1418 "maximum-paths (1-255)",
5e242b0d
DS
1419 "Forward packets over multiple paths\n"
1420 "Number of paths\n")
1421{
c500ae40
DW
1422 int idx_number = 1;
1423 return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, argv[idx_number]->arg, 0, 1);
5e242b0d
DS
1424}
1425
165b5fff
JB
1426DEFUN (bgp_maxpaths_ibgp,
1427 bgp_maxpaths_ibgp_cmd,
9ccf14f7 1428 "maximum-paths ibgp (1-255)",
165b5fff
JB
1429 "Forward packets over multiple paths\n"
1430 "iBGP-multipath\n"
1431 "Number of paths\n")
1432{
c500ae40
DW
1433 int idx_number = 2;
1434 return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, 0, 1);
5e242b0d 1435}
165b5fff 1436
5e242b0d
DS
1437DEFUN (bgp_maxpaths_ibgp_cluster,
1438 bgp_maxpaths_ibgp_cluster_cmd,
9ccf14f7 1439 "maximum-paths ibgp (1-255) equal-cluster-length",
5e242b0d
DS
1440 "Forward packets over multiple paths\n"
1441 "iBGP-multipath\n"
1442 "Number of paths\n"
1443 "Match the cluster length\n")
1444{
c500ae40
DW
1445 int idx_number = 2;
1446 return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg,
5e242b0d 1447 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1);
165b5fff
JB
1448}
1449
1450DEFUN (no_bgp_maxpaths,
1451 no_bgp_maxpaths_cmd,
9ccf14f7 1452 "no maximum-paths [(1-255)]",
165b5fff
JB
1453 NO_STR
1454 "Forward packets over multiple paths\n"
1455 "Number of paths\n")
1456{
5e242b0d 1457 return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0);
165b5fff
JB
1458}
1459
165b5fff
JB
1460DEFUN (no_bgp_maxpaths_ibgp,
1461 no_bgp_maxpaths_ibgp_cmd,
9ccf14f7 1462 "no maximum-paths ibgp [(1-255) [equal-cluster-length]]",
165b5fff
JB
1463 NO_STR
1464 "Forward packets over multiple paths\n"
1465 "iBGP-multipath\n"
838758ac
DW
1466 "Number of paths\n"
1467 "Match the cluster length\n")
165b5fff 1468{
5e242b0d 1469 return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0);
165b5fff
JB
1470}
1471
165b5fff
JB
1472int
1473bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi,
1474 safi_t safi, int *write)
1475{
d5b77cc2 1476 if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM)
165b5fff
JB
1477 {
1478 bgp_config_write_family_header (vty, afi, safi, write);
0b960b4d 1479 vty_out (vty, " maximum-paths %d%s",
165b5fff
JB
1480 bgp->maxpaths[afi][safi].maxpaths_ebgp, VTY_NEWLINE);
1481 }
1482
d5b77cc2 1483 if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM)
165b5fff
JB
1484 {
1485 bgp_config_write_family_header (vty, afi, safi, write);
0b960b4d 1486 vty_out (vty, " maximum-paths ibgp %d",
5e242b0d
DS
1487 bgp->maxpaths[afi][safi].maxpaths_ibgp);
1488 if (CHECK_FLAG (bgp->maxpaths[afi][safi].ibgp_flags,
1489 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN))
1490 vty_out (vty, " equal-cluster-length");
1491 vty_out (vty, "%s", VTY_NEWLINE);
165b5fff
JB
1492 }
1493
1494 return 0;
1495}
6b0655a2 1496
718e3744 1497/* BGP timers. */
1498
1499DEFUN (bgp_timers,
1500 bgp_timers_cmd,
6147e2c6 1501 "timers bgp (0-65535) (0-65535)",
718e3744 1502 "Adjust routing timers\n"
1503 "BGP timers\n"
1504 "Keepalive interval\n"
1505 "Holdtime\n")
1506{
c500ae40
DW
1507 int idx_number = 2;
1508 int idx_number_2 = 3;
718e3744 1509 struct bgp *bgp;
1510 unsigned long keepalive = 0;
1511 unsigned long holdtime = 0;
1512
1513 bgp = vty->index;
1514
c500ae40
DW
1515 VTY_GET_INTEGER ("keepalive", keepalive, argv[idx_number]->arg);
1516 VTY_GET_INTEGER ("holdtime", holdtime, argv[idx_number_2]->arg);
718e3744 1517
1518 /* Holdtime value check. */
1519 if (holdtime < 3 && holdtime != 0)
1520 {
1521 vty_out (vty, "%% hold time value must be either 0 or greater than 3%s",
1522 VTY_NEWLINE);
1523 return CMD_WARNING;
1524 }
1525
1526 bgp_timers_set (bgp, keepalive, holdtime);
1527
1528 return CMD_SUCCESS;
1529}
1530
1531DEFUN (no_bgp_timers,
1532 no_bgp_timers_cmd,
838758ac 1533 "no timers bgp [(0-65535) (0-65535)]",
718e3744 1534 NO_STR
1535 "Adjust routing timers\n"
838758ac
DW
1536 "BGP timers\n"
1537 "Keepalive interval\n"
1538 "Holdtime\n")
718e3744 1539{
1540 struct bgp *bgp;
1541
1542 bgp = vty->index;
1543 bgp_timers_unset (bgp);
1544
1545 return CMD_SUCCESS;
1546}
1547
6b0655a2 1548
718e3744 1549DEFUN (bgp_client_to_client_reflection,
1550 bgp_client_to_client_reflection_cmd,
1551 "bgp client-to-client reflection",
1552 "BGP specific commands\n"
1553 "Configure client to client route reflection\n"
1554 "reflection of routes allowed\n")
1555{
1556 struct bgp *bgp;
1557
1558 bgp = vty->index;
1559 bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
f31fa004 1560 bgp_clear_star_soft_out (vty, bgp->name);
7aafcaca 1561
718e3744 1562 return CMD_SUCCESS;
1563}
1564
1565DEFUN (no_bgp_client_to_client_reflection,
1566 no_bgp_client_to_client_reflection_cmd,
1567 "no bgp client-to-client reflection",
1568 NO_STR
1569 "BGP specific commands\n"
1570 "Configure client to client route reflection\n"
1571 "reflection of routes allowed\n")
1572{
1573 struct bgp *bgp;
1574
1575 bgp = vty->index;
1576 bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
f31fa004 1577 bgp_clear_star_soft_out (vty, bgp->name);
7aafcaca 1578
718e3744 1579 return CMD_SUCCESS;
1580}
1581
1582/* "bgp always-compare-med" configuration. */
1583DEFUN (bgp_always_compare_med,
1584 bgp_always_compare_med_cmd,
1585 "bgp always-compare-med",
1586 "BGP specific commands\n"
1587 "Allow comparing MED from different neighbors\n")
1588{
1589 struct bgp *bgp;
1590
1591 bgp = vty->index;
1592 bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
7aafcaca
DS
1593 bgp_recalculate_all_bestpaths (bgp);
1594
718e3744 1595 return CMD_SUCCESS;
1596}
1597
1598DEFUN (no_bgp_always_compare_med,
1599 no_bgp_always_compare_med_cmd,
1600 "no bgp always-compare-med",
1601 NO_STR
1602 "BGP specific commands\n"
1603 "Allow comparing MED from different neighbors\n")
1604{
1605 struct bgp *bgp;
1606
1607 bgp = vty->index;
1608 bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
7aafcaca
DS
1609 bgp_recalculate_all_bestpaths (bgp);
1610
718e3744 1611 return CMD_SUCCESS;
1612}
6b0655a2 1613
718e3744 1614/* "bgp deterministic-med" configuration. */
1615DEFUN (bgp_deterministic_med,
1616 bgp_deterministic_med_cmd,
1617 "bgp deterministic-med",
1618 "BGP specific commands\n"
1619 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1620{
1621 struct bgp *bgp;
1622
1623 bgp = vty->index;
1475ac87
DW
1624
1625 if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED))
1626 {
1627 bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED);
1628 bgp_recalculate_all_bestpaths (bgp);
1629 }
7aafcaca 1630
718e3744 1631 return CMD_SUCCESS;
1632}
1633
1634DEFUN (no_bgp_deterministic_med,
1635 no_bgp_deterministic_med_cmd,
1636 "no bgp deterministic-med",
1637 NO_STR
1638 "BGP specific commands\n"
1639 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1640{
1641 struct bgp *bgp;
06370dac
DW
1642 int bestpath_per_as_used;
1643 afi_t afi;
1644 safi_t safi;
1645 struct peer *peer;
1646 struct listnode *node, *nnode;
718e3744 1647
1648 bgp = vty->index;
1475ac87
DW
1649
1650 if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED))
1651 {
06370dac
DW
1652 bestpath_per_as_used = 0;
1653
1654 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
1655 {
1656 for (afi = AFI_IP; afi < AFI_MAX; afi++)
1657 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
1658 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS))
1659 {
1660 bestpath_per_as_used = 1;
1661 break;
1662 }
1663
1664 if (bestpath_per_as_used)
1665 break;
1666 }
1667
1668 if (bestpath_per_as_used)
1669 {
1670 vty_out (vty, "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use%s",
1671 VTY_NEWLINE);
1672 return CMD_WARNING;
1673 }
1674 else
1675 {
1676 bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED);
1677 bgp_recalculate_all_bestpaths (bgp);
1678 }
1475ac87 1679 }
7aafcaca 1680
718e3744 1681 return CMD_SUCCESS;
1682}
538621f2 1683
1684/* "bgp graceful-restart" configuration. */
1685DEFUN (bgp_graceful_restart,
1686 bgp_graceful_restart_cmd,
1687 "bgp graceful-restart",
1688 "BGP specific commands\n"
1689 "Graceful restart capability parameters\n")
1690{
1691 struct bgp *bgp;
1692
1693 bgp = vty->index;
1694 bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART);
1695 return CMD_SUCCESS;
1696}
1697
1698DEFUN (no_bgp_graceful_restart,
1699 no_bgp_graceful_restart_cmd,
1700 "no bgp graceful-restart",
1701 NO_STR
1702 "BGP specific commands\n"
1703 "Graceful restart capability parameters\n")
1704{
1705 struct bgp *bgp;
1706
1707 bgp = vty->index;
1708 bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART);
1709 return CMD_SUCCESS;
1710}
1711
93406d87 1712DEFUN (bgp_graceful_restart_stalepath_time,
1713 bgp_graceful_restart_stalepath_time_cmd,
6147e2c6 1714 "bgp graceful-restart stalepath-time (1-3600)",
93406d87 1715 "BGP specific commands\n"
1716 "Graceful restart capability parameters\n"
1717 "Set the max time to hold onto restarting peer's stale paths\n"
1718 "Delay value (seconds)\n")
1719{
c500ae40 1720 int idx_number = 3;
93406d87 1721 struct bgp *bgp;
1722 u_int32_t stalepath;
1723
1724 bgp = vty->index;
1725 if (! bgp)
1726 return CMD_WARNING;
1727
c500ae40 1728 VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[idx_number]->arg, 1, 3600);
93406d87 1729 bgp->stalepath_time = stalepath;
1730 return CMD_SUCCESS;
1731}
1732
eb6f1b41
PG
1733DEFUN (bgp_graceful_restart_restart_time,
1734 bgp_graceful_restart_restart_time_cmd,
6147e2c6 1735 "bgp graceful-restart restart-time (1-3600)",
eb6f1b41
PG
1736 "BGP specific commands\n"
1737 "Graceful restart capability parameters\n"
1738 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1739 "Delay value (seconds)\n")
1740{
c500ae40 1741 int idx_number = 3;
eb6f1b41
PG
1742 struct bgp *bgp;
1743 u_int32_t restart;
1744
1745 bgp = vty->index;
1746 if (! bgp)
1747 return CMD_WARNING;
1748
c500ae40 1749 VTY_GET_INTEGER_RANGE ("restart-time", restart, argv[idx_number]->arg, 1, 3600);
eb6f1b41
PG
1750 bgp->restart_time = restart;
1751 return CMD_SUCCESS;
1752}
1753
93406d87 1754DEFUN (no_bgp_graceful_restart_stalepath_time,
1755 no_bgp_graceful_restart_stalepath_time_cmd,
838758ac 1756 "no bgp graceful-restart stalepath-time [(1-3600)]",
93406d87 1757 NO_STR
1758 "BGP specific commands\n"
1759 "Graceful restart capability parameters\n"
838758ac
DW
1760 "Set the max time to hold onto restarting peer's stale paths\n"
1761 "Delay value (seconds)\n")
93406d87 1762{
1763 struct bgp *bgp;
1764
1765 bgp = vty->index;
1766 if (! bgp)
1767 return CMD_WARNING;
1768
1769 bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME;
1770 return CMD_SUCCESS;
1771}
1772
eb6f1b41
PG
1773DEFUN (no_bgp_graceful_restart_restart_time,
1774 no_bgp_graceful_restart_restart_time_cmd,
838758ac 1775 "no bgp graceful-restart restart-time [(1-3600)]",
eb6f1b41
PG
1776 NO_STR
1777 "BGP specific commands\n"
1778 "Graceful restart capability parameters\n"
838758ac
DW
1779 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1780 "Delay value (seconds)\n")
eb6f1b41
PG
1781{
1782 struct bgp *bgp;
1783
1784 bgp = vty->index;
1785 if (! bgp)
1786 return CMD_WARNING;
1787
1788 bgp->restart_time = BGP_DEFAULT_RESTART_TIME;
1789 return CMD_SUCCESS;
1790}
1791
718e3744 1792/* "bgp fast-external-failover" configuration. */
1793DEFUN (bgp_fast_external_failover,
1794 bgp_fast_external_failover_cmd,
1795 "bgp fast-external-failover",
1796 BGP_STR
1797 "Immediately reset session if a link to a directly connected external peer goes down\n")
1798{
1799 struct bgp *bgp;
1800
1801 bgp = vty->index;
1802 bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
1803 return CMD_SUCCESS;
1804}
1805
1806DEFUN (no_bgp_fast_external_failover,
1807 no_bgp_fast_external_failover_cmd,
1808 "no bgp fast-external-failover",
1809 NO_STR
1810 BGP_STR
1811 "Immediately reset session if a link to a directly connected external peer goes down\n")
1812{
1813 struct bgp *bgp;
1814
1815 bgp = vty->index;
1816 bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
1817 return CMD_SUCCESS;
1818}
6b0655a2 1819
718e3744 1820/* "bgp enforce-first-as" configuration. */
1821DEFUN (bgp_enforce_first_as,
1822 bgp_enforce_first_as_cmd,
1823 "bgp enforce-first-as",
1824 BGP_STR
1825 "Enforce the first AS for EBGP routes\n")
1826{
1827 struct bgp *bgp;
1828
1829 bgp = vty->index;
1830 bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
f31fa004 1831 bgp_clear_star_soft_in (vty, bgp->name);
7aafcaca 1832
718e3744 1833 return CMD_SUCCESS;
1834}
1835
1836DEFUN (no_bgp_enforce_first_as,
1837 no_bgp_enforce_first_as_cmd,
1838 "no bgp enforce-first-as",
1839 NO_STR
1840 BGP_STR
1841 "Enforce the first AS for EBGP routes\n")
1842{
1843 struct bgp *bgp;
1844
1845 bgp = vty->index;
1846 bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
f31fa004 1847 bgp_clear_star_soft_in (vty, bgp->name);
7aafcaca 1848
718e3744 1849 return CMD_SUCCESS;
1850}
6b0655a2 1851
718e3744 1852/* "bgp bestpath compare-routerid" configuration. */
1853DEFUN (bgp_bestpath_compare_router_id,
1854 bgp_bestpath_compare_router_id_cmd,
1855 "bgp bestpath compare-routerid",
1856 "BGP specific commands\n"
1857 "Change the default bestpath selection\n"
1858 "Compare router-id for identical EBGP paths\n")
1859{
1860 struct bgp *bgp;
1861
1862 bgp = vty->index;
1863 bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
7aafcaca
DS
1864 bgp_recalculate_all_bestpaths (bgp);
1865
718e3744 1866 return CMD_SUCCESS;
1867}
1868
1869DEFUN (no_bgp_bestpath_compare_router_id,
1870 no_bgp_bestpath_compare_router_id_cmd,
1871 "no bgp bestpath compare-routerid",
1872 NO_STR
1873 "BGP specific commands\n"
1874 "Change the default bestpath selection\n"
1875 "Compare router-id for identical EBGP paths\n")
1876{
1877 struct bgp *bgp;
1878
1879 bgp = vty->index;
1880 bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
7aafcaca
DS
1881 bgp_recalculate_all_bestpaths (bgp);
1882
718e3744 1883 return CMD_SUCCESS;
1884}
6b0655a2 1885
718e3744 1886/* "bgp bestpath as-path ignore" configuration. */
1887DEFUN (bgp_bestpath_aspath_ignore,
1888 bgp_bestpath_aspath_ignore_cmd,
1889 "bgp bestpath as-path ignore",
1890 "BGP specific commands\n"
1891 "Change the default bestpath selection\n"
1892 "AS-path attribute\n"
1893 "Ignore as-path length in selecting a route\n")
1894{
1895 struct bgp *bgp;
1896
1897 bgp = vty->index;
1898 bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE);
7aafcaca
DS
1899 bgp_recalculate_all_bestpaths (bgp);
1900
718e3744 1901 return CMD_SUCCESS;
1902}
1903
1904DEFUN (no_bgp_bestpath_aspath_ignore,
1905 no_bgp_bestpath_aspath_ignore_cmd,
1906 "no bgp bestpath as-path ignore",
1907 NO_STR
1908 "BGP specific commands\n"
1909 "Change the default bestpath selection\n"
1910 "AS-path attribute\n"
1911 "Ignore as-path length in selecting a route\n")
1912{
1913 struct bgp *bgp;
1914
1915 bgp = vty->index;
1916 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE);
7aafcaca
DS
1917 bgp_recalculate_all_bestpaths (bgp);
1918
718e3744 1919 return CMD_SUCCESS;
1920}
6b0655a2 1921
6811845b 1922/* "bgp bestpath as-path confed" configuration. */
1923DEFUN (bgp_bestpath_aspath_confed,
1924 bgp_bestpath_aspath_confed_cmd,
1925 "bgp bestpath as-path confed",
1926 "BGP specific commands\n"
1927 "Change the default bestpath selection\n"
1928 "AS-path attribute\n"
1929 "Compare path lengths including confederation sets & sequences in selecting a route\n")
1930{
1931 struct bgp *bgp;
1932
1933 bgp = vty->index;
1934 bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED);
7aafcaca
DS
1935 bgp_recalculate_all_bestpaths (bgp);
1936
6811845b 1937 return CMD_SUCCESS;
1938}
1939
1940DEFUN (no_bgp_bestpath_aspath_confed,
1941 no_bgp_bestpath_aspath_confed_cmd,
1942 "no bgp bestpath as-path confed",
1943 NO_STR
1944 "BGP specific commands\n"
1945 "Change the default bestpath selection\n"
1946 "AS-path attribute\n"
1947 "Compare path lengths including confederation sets & sequences in selecting a route\n")
1948{
1949 struct bgp *bgp;
1950
1951 bgp = vty->index;
1952 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED);
7aafcaca
DS
1953 bgp_recalculate_all_bestpaths (bgp);
1954
6811845b 1955 return CMD_SUCCESS;
1956}
6b0655a2 1957
2fdd455c
PM
1958/* "bgp bestpath as-path multipath-relax" configuration. */
1959DEFUN (bgp_bestpath_aspath_multipath_relax,
1960 bgp_bestpath_aspath_multipath_relax_cmd,
6147e2c6 1961 "bgp bestpath as-path multipath-relax [as-set|no-as-set]",
16fc1eec
DS
1962 "BGP specific commands\n"
1963 "Change the default bestpath selection\n"
1964 "AS-path attribute\n"
1965 "Allow load sharing across routes that have different AS paths (but same length)\n"
219178b6 1966 "Generate an AS_SET\n"
16fc1eec
DS
1967 "Do not generate an AS_SET\n")
1968{
c500ae40 1969 int idx_as_set = 4;
16fc1eec
DS
1970 struct bgp *bgp;
1971
1972 bgp = vty->index;
1973 bgp_flag_set (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
219178b6
DW
1974
1975 /* no-as-set is now the default behavior so we can silently
1976 * ignore it */
c500ae40 1977 if (argv[idx_as_set]->arg != NULL && strncmp (argv[idx_as_set]->arg, "a", 1) == 0)
219178b6
DW
1978 bgp_flag_set (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
1979 else
1980 bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET) ;
1981
7aafcaca
DS
1982 bgp_recalculate_all_bestpaths (bgp);
1983
16fc1eec
DS
1984 return CMD_SUCCESS;
1985}
1986
219178b6
DW
1987DEFUN (no_bgp_bestpath_aspath_multipath_relax,
1988 no_bgp_bestpath_aspath_multipath_relax_cmd,
6147e2c6 1989 "no bgp bestpath as-path multipath-relax [as-set|no-as-set]",
16fc1eec
DS
1990 NO_STR
1991 "BGP specific commands\n"
1992 "Change the default bestpath selection\n"
1993 "AS-path attribute\n"
1994 "Allow load sharing across routes that have different AS paths (but same length)\n"
219178b6 1995 "Generate an AS_SET\n"
16fc1eec
DS
1996 "Do not generate an AS_SET\n")
1997{
1998 struct bgp *bgp;
1999
2000 bgp = vty->index;
2001 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
219178b6 2002 bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
7aafcaca
DS
2003 bgp_recalculate_all_bestpaths (bgp);
2004
2fdd455c
PM
2005 return CMD_SUCCESS;
2006}
6b0655a2 2007
848973c7 2008/* "bgp log-neighbor-changes" configuration. */
2009DEFUN (bgp_log_neighbor_changes,
2010 bgp_log_neighbor_changes_cmd,
2011 "bgp log-neighbor-changes",
2012 "BGP specific commands\n"
2013 "Log neighbor up/down and reset reason\n")
2014{
2015 struct bgp *bgp;
2016
2017 bgp = vty->index;
2018 bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
2019 return CMD_SUCCESS;
2020}
2021
2022DEFUN (no_bgp_log_neighbor_changes,
2023 no_bgp_log_neighbor_changes_cmd,
2024 "no bgp log-neighbor-changes",
2025 NO_STR
2026 "BGP specific commands\n"
2027 "Log neighbor up/down and reset reason\n")
2028{
2029 struct bgp *bgp;
2030
2031 bgp = vty->index;
2032 bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
2033 return CMD_SUCCESS;
2034}
6b0655a2 2035
718e3744 2036/* "bgp bestpath med" configuration. */
2037DEFUN (bgp_bestpath_med,
2038 bgp_bestpath_med_cmd,
6147e2c6 2039 "bgp bestpath med <confed|missing-as-worst>",
718e3744 2040 "BGP specific commands\n"
2041 "Change the default bestpath selection\n"
2042 "MED attribute\n"
2043 "Compare MED among confederation paths\n"
2044 "Treat missing MED as the least preferred one\n")
2045{
c500ae40 2046 int idx_med_knob = 3;
718e3744 2047 struct bgp *bgp;
2048
2049 bgp = vty->index;
2050
c500ae40 2051 if (strncmp (argv[idx_med_knob]->arg, "confed", 1) == 0)
718e3744 2052 bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
2053 else
2054 bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
2055
7aafcaca
DS
2056 bgp_recalculate_all_bestpaths (bgp);
2057
718e3744 2058 return CMD_SUCCESS;
2059}
2060
2061DEFUN (bgp_bestpath_med2,
2062 bgp_bestpath_med2_cmd,
8334fd5a 2063 "bgp bestpath med <confed missing-as-worst|missing-as-worst confed>",
718e3744 2064 "BGP specific commands\n"
2065 "Change the default bestpath selection\n"
2066 "MED attribute\n"
2067 "Compare MED among confederation paths\n"
838758ac
DW
2068 "Treat missing MED as the least preferred one\n"
2069 "Treat missing MED as the least preferred one\n"
2070 "Compare MED among confederation paths\n")
718e3744 2071{
2072 struct bgp *bgp;
2073
2074 bgp = vty->index;
2075 bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
2076 bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
7aafcaca
DS
2077 bgp_recalculate_all_bestpaths (bgp);
2078
718e3744 2079 return CMD_SUCCESS;
2080}
2081
718e3744 2082
2083DEFUN (no_bgp_bestpath_med,
2084 no_bgp_bestpath_med_cmd,
6147e2c6 2085 "no bgp bestpath med <confed|missing-as-worst>",
718e3744 2086 NO_STR
2087 "BGP specific commands\n"
2088 "Change the default bestpath selection\n"
2089 "MED attribute\n"
2090 "Compare MED among confederation paths\n"
2091 "Treat missing MED as the least preferred one\n")
2092{
c500ae40 2093 int idx_med_knob = 4;
718e3744 2094 struct bgp *bgp;
2095
2096 bgp = vty->index;
2097
c500ae40 2098 if (strncmp (argv[idx_med_knob]->arg, "confed", 1) == 0)
718e3744 2099 bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
2100 else
2101 bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
2102
7aafcaca
DS
2103 bgp_recalculate_all_bestpaths (bgp);
2104
718e3744 2105 return CMD_SUCCESS;
2106}
2107
2108DEFUN (no_bgp_bestpath_med2,
2109 no_bgp_bestpath_med2_cmd,
838758ac 2110 "no bgp bestpath med [confed] missing-as-worst",
718e3744 2111 NO_STR
2112 "BGP specific commands\n"
2113 "Change the default bestpath selection\n"
2114 "MED attribute\n"
2115 "Compare MED among confederation paths\n"
2116 "Treat missing MED as the least preferred one\n")
2117{
2118 struct bgp *bgp;
2119
2120 bgp = vty->index;
2121 bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
2122 bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
7aafcaca
DS
2123 bgp_recalculate_all_bestpaths (bgp);
2124
718e3744 2125 return CMD_SUCCESS;
2126}
2127
718e3744 2128/* "no bgp default ipv4-unicast". */
2129DEFUN (no_bgp_default_ipv4_unicast,
2130 no_bgp_default_ipv4_unicast_cmd,
2131 "no bgp default ipv4-unicast",
2132 NO_STR
2133 "BGP specific commands\n"
2134 "Configure BGP defaults\n"
2135 "Activate ipv4-unicast for a peer by default\n")
2136{
2137 struct bgp *bgp;
2138
2139 bgp = vty->index;
2140 bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
2141 return CMD_SUCCESS;
2142}
2143
2144DEFUN (bgp_default_ipv4_unicast,
2145 bgp_default_ipv4_unicast_cmd,
2146 "bgp default ipv4-unicast",
2147 "BGP specific commands\n"
2148 "Configure BGP defaults\n"
2149 "Activate ipv4-unicast for a peer by default\n")
2150{
2151 struct bgp *bgp;
2152
2153 bgp = vty->index;
2154 bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
2155 return CMD_SUCCESS;
2156}
6b0655a2 2157
04b6bdc0
DW
2158/* Display hostname in certain command outputs */
2159DEFUN (bgp_default_show_hostname,
2160 bgp_default_show_hostname_cmd,
2161 "bgp default show-hostname",
2162 "BGP specific commands\n"
2163 "Configure BGP defaults\n"
2164 "Show hostname in certain command ouputs\n")
2165{
2166 struct bgp *bgp;
2167
2168 bgp = vty->index;
2169 bgp_flag_set (bgp, BGP_FLAG_SHOW_HOSTNAME);
2170 return CMD_SUCCESS;
2171}
2172
2173DEFUN (no_bgp_default_show_hostname,
2174 no_bgp_default_show_hostname_cmd,
2175 "no bgp default show-hostname",
2176 NO_STR
2177 "BGP specific commands\n"
2178 "Configure BGP defaults\n"
2179 "Show hostname in certain command ouputs\n")
2180{
2181 struct bgp *bgp;
2182
2183 bgp = vty->index;
2184 bgp_flag_unset (bgp, BGP_FLAG_SHOW_HOSTNAME);
2185 return CMD_SUCCESS;
2186}
2187
8233ef81 2188/* "bgp network import-check" configuration. */
718e3744 2189DEFUN (bgp_network_import_check,
2190 bgp_network_import_check_cmd,
5623e905 2191 "bgp network import-check",
718e3744 2192 "BGP specific commands\n"
2193 "BGP network command\n"
5623e905 2194 "Check BGP network route exists in IGP\n")
718e3744 2195{
2196 struct bgp *bgp;
2197
2198 bgp = vty->index;
078430f6
DS
2199 if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK))
2200 {
2201 bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK);
5623e905 2202 bgp_static_redo_import_check(bgp);
078430f6
DS
2203 }
2204
718e3744 2205 return CMD_SUCCESS;
2206}
2207
8233ef81
DW
2208ALIAS_HIDDEN (bgp_network_import_check,
2209 bgp_network_import_check_exact_cmd,
2210 "bgp network import-check exact",
2211 "BGP specific commands\n"
2212 "BGP network command\n"
2213 "Check BGP network route exists in IGP\n"
2214 "Match route precisely\n")
2215
718e3744 2216DEFUN (no_bgp_network_import_check,
2217 no_bgp_network_import_check_cmd,
5623e905 2218 "no bgp network import-check",
718e3744 2219 NO_STR
2220 "BGP specific commands\n"
2221 "BGP network command\n"
2222 "Check BGP network route exists in IGP\n")
2223{
2224 struct bgp *bgp;
2225
2226 bgp = vty->index;
078430f6
DS
2227 if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK))
2228 {
2229 bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK);
078430f6
DS
2230 bgp_static_redo_import_check(bgp);
2231 }
5623e905 2232
718e3744 2233 return CMD_SUCCESS;
2234}
6b0655a2 2235
718e3744 2236DEFUN (bgp_default_local_preference,
2237 bgp_default_local_preference_cmd,
6147e2c6 2238 "bgp default local-preference (0-4294967295)",
718e3744 2239 "BGP specific commands\n"
2240 "Configure BGP defaults\n"
2241 "local preference (higher=more preferred)\n"
2242 "Configure default local preference value\n")
2243{
c500ae40 2244 int idx_number = 3;
718e3744 2245 struct bgp *bgp;
2246 u_int32_t local_pref;
2247
2248 bgp = vty->index;
2249
c500ae40 2250 VTY_GET_INTEGER ("local preference", local_pref, argv[idx_number]->arg);
718e3744 2251
2252 bgp_default_local_preference_set (bgp, local_pref);
f31fa004 2253 bgp_clear_star_soft_in (vty, bgp->name);
718e3744 2254
2255 return CMD_SUCCESS;
2256}
2257
2258DEFUN (no_bgp_default_local_preference,
2259 no_bgp_default_local_preference_cmd,
838758ac 2260 "no bgp default local-preference [(0-4294967295)]",
718e3744 2261 NO_STR
2262 "BGP specific commands\n"
2263 "Configure BGP defaults\n"
838758ac
DW
2264 "local preference (higher=more preferred)\n"
2265 "Configure default local preference value\n")
718e3744 2266{
2267 struct bgp *bgp;
2268
2269 bgp = vty->index;
2270 bgp_default_local_preference_unset (bgp);
f31fa004 2271 bgp_clear_star_soft_in (vty, bgp->name);
7aafcaca 2272
718e3744 2273 return CMD_SUCCESS;
2274}
2275
6b0655a2 2276
3f9c7369
DS
2277DEFUN (bgp_default_subgroup_pkt_queue_max,
2278 bgp_default_subgroup_pkt_queue_max_cmd,
6147e2c6 2279 "bgp default subgroup-pkt-queue-max (20-100)",
3f9c7369
DS
2280 "BGP specific commands\n"
2281 "Configure BGP defaults\n"
2282 "subgroup-pkt-queue-max\n"
2283 "Configure subgroup packet queue max\n")
8bd9d948 2284{
c500ae40 2285 int idx_number = 3;
3f9c7369
DS
2286 struct bgp *bgp;
2287 u_int32_t max_size;
8bd9d948 2288
3f9c7369
DS
2289 bgp = vty->index;
2290
c500ae40 2291 VTY_GET_INTEGER ("subgroup packet queue max", max_size, argv[idx_number]->arg);
3f9c7369
DS
2292
2293 bgp_default_subgroup_pkt_queue_max_set (bgp, max_size);
2294
2295 return CMD_SUCCESS;
2296}
2297
2298DEFUN (no_bgp_default_subgroup_pkt_queue_max,
2299 no_bgp_default_subgroup_pkt_queue_max_cmd,
838758ac 2300 "no bgp default subgroup-pkt-queue-max [(20-100)]",
3f9c7369
DS
2301 NO_STR
2302 "BGP specific commands\n"
2303 "Configure BGP defaults\n"
838758ac
DW
2304 "subgroup-pkt-queue-max\n"
2305 "Configure subgroup packet queue max\n")
3f9c7369
DS
2306{
2307 struct bgp *bgp;
2308
2309 bgp = vty->index;
2310 bgp_default_subgroup_pkt_queue_max_unset (bgp);
2311 return CMD_SUCCESS;
8bd9d948
DS
2312}
2313
813d4307 2314
8bd9d948
DS
2315DEFUN (bgp_rr_allow_outbound_policy,
2316 bgp_rr_allow_outbound_policy_cmd,
2317 "bgp route-reflector allow-outbound-policy",
2318 "BGP specific commands\n"
2319 "Allow modifications made by out route-map\n"
2320 "on ibgp neighbors\n")
2321{
2322 struct bgp *bgp;
8bd9d948
DS
2323
2324 bgp = vty->index;
2325
2326 if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY))
2327 {
2328 bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
3f9c7369 2329 update_group_announce_rrclients(bgp);
f31fa004 2330 bgp_clear_star_soft_out (vty, bgp->name);
8bd9d948
DS
2331 }
2332
2333 return CMD_SUCCESS;
2334}
2335
2336DEFUN (no_bgp_rr_allow_outbound_policy,
2337 no_bgp_rr_allow_outbound_policy_cmd,
2338 "no bgp route-reflector allow-outbound-policy",
2339 NO_STR
2340 "BGP specific commands\n"
2341 "Allow modifications made by out route-map\n"
2342 "on ibgp neighbors\n")
2343{
2344 struct bgp *bgp;
8bd9d948
DS
2345
2346 bgp = vty->index;
2347
2348 if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY))
2349 {
2350 bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
3f9c7369 2351 update_group_announce_rrclients(bgp);
f31fa004 2352 bgp_clear_star_soft_out (vty, bgp->name);
8bd9d948
DS
2353 }
2354
2355 return CMD_SUCCESS;
2356}
2357
f14e6fdb
DS
2358DEFUN (bgp_listen_limit,
2359 bgp_listen_limit_cmd,
9ccf14f7 2360 "bgp listen limit (1-5000)",
f14e6fdb
DS
2361 "BGP specific commands\n"
2362 "Configure BGP defaults\n"
2363 "maximum number of BGP Dynamic Neighbors that can be created\n"
2364 "Configure Dynamic Neighbors listen limit value\n")
2365{
c500ae40 2366 int idx_number = 3;
f14e6fdb
DS
2367 struct bgp *bgp;
2368 int listen_limit;
2369
2370 bgp = vty->index;
2371
c500ae40 2372 VTY_GET_INTEGER_RANGE ("listen limit", listen_limit, argv[idx_number]->arg,
f14e6fdb
DS
2373 BGP_DYNAMIC_NEIGHBORS_LIMIT_MIN,
2374 BGP_DYNAMIC_NEIGHBORS_LIMIT_MAX);
2375
2376 bgp_listen_limit_set (bgp, listen_limit);
2377
2378 return CMD_SUCCESS;
2379}
2380
2381DEFUN (no_bgp_listen_limit,
2382 no_bgp_listen_limit_cmd,
838758ac 2383 "no bgp listen limit [(1-5000)]",
f14e6fdb
DS
2384 "BGP specific commands\n"
2385 "Configure BGP defaults\n"
2386 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
838758ac
DW
2387 "Configure Dynamic Neighbors listen limit value to default\n"
2388 "Configure Dynamic Neighbors listen limit value\n")
f14e6fdb
DS
2389{
2390 struct bgp *bgp;
2391
2392 bgp = vty->index;
2393 bgp_listen_limit_unset (bgp);
2394 return CMD_SUCCESS;
2395}
2396
2397
20eb8864 2398/*
2399 * Check if this listen range is already configured. Check for exact
2400 * match or overlap based on input.
2401 */
2402static struct peer_group *
2403listen_range_exists (struct bgp *bgp, struct prefix *range, int exact)
2404{
2405 struct listnode *node, *nnode;
2406 struct listnode *node1, *nnode1;
2407 struct peer_group *group;
2408 struct prefix *lr;
2409 afi_t afi;
2410 int match;
2411
2412 afi = family2afi(range->family);
2413 for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
2414 {
2415 for (ALL_LIST_ELEMENTS (group->listen_range[afi], node1,
2416 nnode1, lr))
2417 {
2418 if (exact)
2419 match = prefix_same (range, lr);
2420 else
2421 match = (prefix_match (range, lr) || prefix_match (lr, range));
2422 if (match)
2423 return group;
2424 }
2425 }
2426
2427 return NULL;
2428}
2429
f14e6fdb
DS
2430DEFUN (bgp_listen_range,
2431 bgp_listen_range_cmd,
9ccf14f7 2432 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
f14e6fdb
DS
2433 "BGP specific commands\n"
2434 "Configure BGP Dynamic Neighbors\n"
2435 "add a listening range for Dynamic Neighbors\n"
2436 LISTEN_RANGE_ADDR_STR)
2437{
c500ae40
DW
2438 int idx_ipv4_ipv6_prefixlen = 3;
2439 int idx_word = 5;
f14e6fdb
DS
2440 struct bgp *bgp;
2441 struct prefix range;
20eb8864 2442 struct peer_group *group, *existing_group;
f14e6fdb
DS
2443 afi_t afi;
2444 int ret;
2445
2446 bgp = vty->index;
2447
c500ae40 2448 //VTY_GET_IPV4_PREFIX ("listen range", range, argv[idx_ipv4_ipv6_prefixlen]->arg);
f14e6fdb
DS
2449
2450 /* Convert IP prefix string to struct prefix. */
c500ae40 2451 ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, &range);
f14e6fdb
DS
2452 if (! ret)
2453 {
2454 vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE);
2455 return CMD_WARNING;
2456 }
2457
2458 afi = family2afi(range.family);
2459
2460#ifdef HAVE_IPV6
2461 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6))
2462 {
2463 vty_out (vty, "%% Malformed listen range (link-local address)%s",
2464 VTY_NEWLINE);
2465 return CMD_WARNING;
2466 }
2467#endif /* HAVE_IPV6 */
2468
2469 apply_mask (&range);
2470
20eb8864 2471 /* Check if same listen range is already configured. */
2472 existing_group = listen_range_exists (bgp, &range, 1);
2473 if (existing_group)
2474 {
c500ae40 2475 if (strcmp (existing_group->name, argv[idx_word]->arg) == 0)
20eb8864 2476 return CMD_SUCCESS;
2477 else
2478 {
2479 vty_out (vty, "%% Same listen range is attached to peer-group %s%s",
2480 existing_group->name, VTY_NEWLINE);
2481 return CMD_WARNING;
2482 }
2483 }
2484
2485 /* Check if an overlapping listen range exists. */
2486 if (listen_range_exists (bgp, &range, 0))
2487 {
2488 vty_out (vty, "%% Listen range overlaps with existing listen range%s",
2489 VTY_NEWLINE);
2490 return CMD_WARNING;
2491 }
f14e6fdb 2492
c500ae40 2493 group = peer_group_lookup (bgp, argv[idx_word]->arg);
f14e6fdb
DS
2494 if (! group)
2495 {
2496 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
2497 return CMD_WARNING;
2498 }
2499
2500 ret = peer_group_listen_range_add(group, &range);
2501 return bgp_vty_return (vty, ret);
2502}
2503
2504DEFUN (no_bgp_listen_range,
2505 no_bgp_listen_range_cmd,
9ccf14f7 2506 "no bgp listen range A.B.C.D/M peer-group WORD",
f14e6fdb
DS
2507 "BGP specific commands\n"
2508 "Configure BGP defaults\n"
2509 "delete a listening range for Dynamic Neighbors\n"
2510 "Remove Dynamic Neighbors listening range\n")
2511{
c500ae40
DW
2512 int idx_ipv4_prefixlen = 4;
2513 int idx_word = 6;
f14e6fdb
DS
2514 struct bgp *bgp;
2515 struct prefix range;
2516 struct peer_group *group;
2517 afi_t afi;
2518 int ret;
2519
2520 bgp = vty->index;
2521
c500ae40 2522 // VTY_GET_IPV4_PREFIX ("listen range", range, argv[idx_ipv4_prefixlen]->arg);
f14e6fdb
DS
2523
2524 /* Convert IP prefix string to struct prefix. */
c500ae40 2525 ret = str2prefix (argv[idx_ipv4_prefixlen]->arg, &range);
f14e6fdb
DS
2526 if (! ret)
2527 {
2528 vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE);
2529 return CMD_WARNING;
2530 }
2531
2532 afi = family2afi(range.family);
2533
2534#ifdef HAVE_IPV6
2535 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6))
2536 {
2537 vty_out (vty, "%% Malformed listen range (link-local address)%s",
2538 VTY_NEWLINE);
2539 return CMD_WARNING;
2540 }
2541#endif /* HAVE_IPV6 */
2542
2543 apply_mask (&range);
2544
2545
c500ae40 2546 group = peer_group_lookup (bgp, argv[idx_word]->arg);
f14e6fdb
DS
2547 if (! group)
2548 {
2549 vty_out (vty, "%% Peer-group does not exist%s", VTY_NEWLINE);
2550 return CMD_WARNING;
2551 }
2552
2553 ret = peer_group_listen_range_del(group, &range);
2554 return bgp_vty_return (vty, ret);
2555}
2556
2557int
2558bgp_config_write_listen (struct vty *vty, struct bgp *bgp)
2559{
2560 struct peer_group *group;
2561 struct listnode *node, *nnode, *rnode, *nrnode;
2562 struct prefix *range;
2563 afi_t afi;
4690c7d7 2564 char buf[PREFIX2STR_BUFFER];
f14e6fdb
DS
2565
2566 if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT)
2567 vty_out (vty, " bgp listen limit %d%s",
2568 bgp->dynamic_neighbors_limit, VTY_NEWLINE);
2569
2570 for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
2571 {
2572 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2573 {
2574 for (ALL_LIST_ELEMENTS (group->listen_range[afi], rnode, nrnode, range))
2575 {
2576 prefix2str(range, buf, sizeof(buf));
2577 vty_out(vty, " bgp listen range %s peer-group %s%s",
2578 buf, group->name, VTY_NEWLINE);
2579 }
2580 }
2581 }
2582
2583 return 0;
2584}
2585
2586
907f92c8
DS
2587DEFUN (bgp_disable_connected_route_check,
2588 bgp_disable_connected_route_check_cmd,
2589 "bgp disable-ebgp-connected-route-check",
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_set (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
f31fa004 2597 bgp_clear_star_soft_in (vty, bgp->name);
7aafcaca 2598
907f92c8
DS
2599 return CMD_SUCCESS;
2600}
2601
2602DEFUN (no_bgp_disable_connected_route_check,
2603 no_bgp_disable_connected_route_check_cmd,
2604 "no bgp disable-ebgp-connected-route-check",
2605 NO_STR
2606 "BGP specific commands\n"
2607 "Disable checking if nexthop is connected on ebgp sessions\n")
2608{
2609 struct bgp *bgp;
2610
2611 bgp = vty->index;
2612 bgp_flag_unset (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
f31fa004 2613 bgp_clear_star_soft_in (vty, bgp->name);
7aafcaca 2614
907f92c8
DS
2615 return CMD_SUCCESS;
2616}
2617
2618
718e3744 2619static int
fd79ac91 2620peer_remote_as_vty (struct vty *vty, const char *peer_str,
2621 const char *as_str, afi_t afi, safi_t safi)
718e3744 2622{
2623 int ret;
2624 struct bgp *bgp;
2625 as_t as;
0299c004 2626 int as_type = AS_SPECIFIED;
718e3744 2627 union sockunion su;
2628
2629 bgp = vty->index;
2630
0299c004
DS
2631 if (strncmp(as_str, "internal", strlen("internal")) == 0)
2632 {
2633 as = 0;
2634 as_type = AS_INTERNAL;
2635 }
2636 else if (strncmp(as_str, "external", strlen("external")) == 0)
2637 {
2638 as = 0;
2639 as_type = AS_EXTERNAL;
2640 }
2641 else
2642 {
2643 /* Get AS number. */
2644 VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX);
2645 }
718e3744 2646
2647 /* If peer is peer group, call proper function. */
2648 ret = str2sockunion (peer_str, &su);
2649 if (ret < 0)
2650 {
a80beece 2651 /* Check for peer by interface */
0299c004 2652 ret = peer_remote_as (bgp, NULL, peer_str, &as, as_type, afi, safi);
718e3744 2653 if (ret < 0)
a80beece 2654 {
0299c004 2655 ret = peer_group_remote_as (bgp, peer_str, &as, as_type);
a80beece
DS
2656 if (ret < 0)
2657 {
2658 vty_out (vty, "%% Create the peer-group or interface first%s",
2659 VTY_NEWLINE);
2660 return CMD_WARNING;
2661 }
2662 return CMD_SUCCESS;
2663 }
718e3744 2664 }
a80beece 2665 else
718e3744 2666 {
6aeb9e78 2667 if (peer_address_self_check (bgp, &su))
a80beece
DS
2668 {
2669 vty_out (vty, "%% Can not configure the local system as neighbor%s",
2670 VTY_NEWLINE);
2671 return CMD_WARNING;
2672 }
0299c004 2673 ret = peer_remote_as (bgp, &su, NULL, &as, as_type, afi, safi);
718e3744 2674 }
2675
718e3744 2676 /* This peer belongs to peer group. */
2677 switch (ret)
2678 {
2679 case BGP_ERR_PEER_GROUP_MEMBER:
aea339f7 2680 vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTY_NEWLINE);
718e3744 2681 return CMD_WARNING;
718e3744 2682 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT:
aea339f7 2683 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 2684 return CMD_WARNING;
718e3744 2685 }
2686 return bgp_vty_return (vty, ret);
2687}
2688
2689DEFUN (neighbor_remote_as,
2690 neighbor_remote_as_cmd,
9ccf14f7 2691 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|external|internal>",
718e3744 2692 NEIGHBOR_STR
2693 NEIGHBOR_ADDR_STR2
2694 "Specify a BGP neighbor\n"
2695 AS_STR)
2696{
c500ae40
DW
2697 int idx_peer = 1;
2698 int idx_remote_as = 3;
2699 return peer_remote_as_vty (vty, argv[idx_peer]->arg, argv[idx_remote_as]->arg, AFI_IP, SAFI_UNICAST);
718e3744 2700}
6b0655a2 2701
4c48cf63
DW
2702static int
2703peer_conf_interface_get (struct vty *vty, const char *conf_if, afi_t afi,
b3a39dc5
DD
2704 safi_t safi, int v6only, const char *peer_group_name,
2705 const char *as_str)
a80beece 2706{
b3a39dc5
DD
2707 as_t as = 0;
2708 int as_type = AS_UNSPECIFIED;
a80beece
DS
2709 struct bgp *bgp;
2710 struct peer *peer;
2711 struct peer_group *group;
4c48cf63
DW
2712 int ret = 0;
2713 union sockunion su;
a80beece
DS
2714
2715 bgp = vty->index;
4c48cf63
DW
2716 group = peer_group_lookup (bgp, conf_if);
2717
a80beece
DS
2718 if (group)
2719 {
2720 vty_out (vty, "%% Name conflict with peer-group %s", VTY_NEWLINE);
2721 return CMD_WARNING;
2722 }
2723
b3a39dc5
DD
2724 if (as_str)
2725 {
2726 if (strncmp(as_str, "internal", strlen("internal")) == 0)
2727 {
2728 as_type = AS_INTERNAL;
2729 }
2730 else if (strncmp(as_str, "external", strlen("external")) == 0)
2731 {
2732 as_type = AS_EXTERNAL;
2733 }
2734 else
2735 {
2736 /* Get AS number. */
2737 VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX);
2738 as_type = AS_SPECIFIED;
2739 }
2740 }
2741
4c48cf63
DW
2742 peer = peer_lookup_by_conf_if (bgp, conf_if);
2743 if (!peer)
2744 {
2745 if (bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4)
2746 && afi == AFI_IP && safi == SAFI_UNICAST)
b3a39dc5
DD
2747 peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, 0, 0,
2748 NULL);
4c48cf63 2749 else
b3a39dc5
DD
2750 peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, afi, safi,
2751 NULL);
4c48cf63
DW
2752
2753 if (peer && v6only)
2754 SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY);
4a04e5f7 2755
2756 /* Request zebra to initiate IPv6 RAs on this interface. We do this
2757 * any unnumbered peer in order to not worry about run-time transitions
2758 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 address
2759 * gets deleted later etc.)
2760 */
2761 if (peer->ifp)
b3a39dc5
DD
2762 {
2763 bgp_zebra_initiate_radv (bgp, peer);
2764 }
2765 peer_flag_set (peer, PEER_FLAG_CAPABILITY_ENHE);
4c48cf63
DW
2766 }
2767 else if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) ||
2768 (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)))
2769 {
2770 if (v6only)
2771 SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY);
2772 else
2773 UNSET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY);
2774
2775 /* v6only flag changed. Reset bgp seesion */
2776 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status))
2777 {
2778 peer->last_reset = PEER_DOWN_V6ONLY_CHANGE;
2779 bgp_notify_send (peer, BGP_NOTIFY_CEASE,
2780 BGP_NOTIFY_CEASE_CONFIG_CHANGE);
2781 }
2782 else
2783 bgp_session_reset(peer);
2784 }
2785
a80beece
DS
2786 if (!peer)
2787 return CMD_WARNING;
2788
4c48cf63
DW
2789 if (peer_group_name)
2790 {
2791 group = peer_group_lookup (bgp, peer_group_name);
2792 if (! group)
2793 {
2794 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
2795 return CMD_WARNING;
2796 }
2797
2798 ret = peer_group_bind (bgp, &su, peer, group, &as);
2799 }
2800
2801 return bgp_vty_return (vty, ret);
a80beece
DS
2802}
2803
f412b39a
DW
2804/*
2805 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
2806 * "neighbor WORD interface peer-group WORD",
2807 * NEIGHBOR_STR
2808 * "Interface name or neighbor tag\n"
2809 * "Enable BGP on interface\n"
2810 * "Member of the peer-group\n"
2811 * "peer-group name\n"
2812 *
2813 */
4c48cf63
DW
2814DEFUN (neighbor_interface_config,
2815 neighbor_interface_config_cmd,
2816 "neighbor WORD interface",
2817 NEIGHBOR_STR
2818 "Interface name or neighbor tag\n"
2819 "Enable BGP on interface\n")
2820{
c500ae40 2821 int idx_word = 1;
4c48cf63 2822 if (argc == 2)
c500ae40 2823 return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0,
afec25d9 2824 argv[3]->arg, NULL);
4c48cf63 2825 else
c500ae40 2826 return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0,
b3a39dc5 2827 NULL, NULL);
4c48cf63
DW
2828}
2829
4c48cf63 2830
f412b39a
DW
2831/*
2832 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
2833 * "neighbor WORD interface v6only peer-group WORD",
2834 * NEIGHBOR_STR
2835 * "Interface name or neighbor tag\n"
2836 * "Enable BGP on interface\n"
2837 * "Enable BGP with v6 link-local only\n"
2838 * "Member of the peer-group\n"
2839 * "peer-group name\n"
2840 *
2841 */
4c48cf63
DW
2842DEFUN (neighbor_interface_config_v6only,
2843 neighbor_interface_config_v6only_cmd,
2844 "neighbor WORD interface v6only",
2845 NEIGHBOR_STR
2846 "Interface name or neighbor tag\n"
2847 "Enable BGP on interface\n"
2848 "Enable BGP with v6 link-local only\n")
2849{
c500ae40
DW
2850 int idx_word = 1;
2851 return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1,
afec25d9 2852 argv[5]->arg, NULL);
4c48cf63
DW
2853}
2854
a80beece 2855
b3a39dc5
DD
2856DEFUN (neighbor_interface_config_remote_as,
2857 neighbor_interface_config_remote_as_cmd,
9ccf14f7 2858 "neighbor WORD interface remote-as <(1-4294967295)|external|internal>",
b3a39dc5
DD
2859 NEIGHBOR_STR
2860 "Interface name or neighbor tag\n"
2861 "Enable BGP on interface\n"
2862 AS_STR)
2863{
c500ae40
DW
2864 int idx_word = 1;
2865 int idx_remote_as = 4;
2866 return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0,
2867 NULL, argv[idx_remote_as]->arg);
b3a39dc5
DD
2868}
2869
2870DEFUN (neighbor_interface_v6only_config_remote_as,
2871 neighbor_interface_v6only_config_remote_as_cmd,
9ccf14f7 2872 "neighbor WORD interface v6only remote-as <(1-4294967295)|external|internal>",
b3a39dc5
DD
2873 NEIGHBOR_STR
2874 "Interface name or neighbor tag\n"
2875 "Enable BGP on interface\n"
2876 AS_STR)
2877{
c500ae40
DW
2878 int idx_word = 1;
2879 int idx_remote_as = 5;
2880 return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1,
2881 NULL, argv[idx_remote_as]->arg);
b3a39dc5
DD
2882}
2883
718e3744 2884DEFUN (neighbor_peer_group,
2885 neighbor_peer_group_cmd,
2886 "neighbor WORD peer-group",
2887 NEIGHBOR_STR
a80beece 2888 "Interface name or neighbor tag\n"
718e3744 2889 "Configure peer-group\n")
2890{
c500ae40 2891 int idx_word = 1;
718e3744 2892 struct bgp *bgp;
a80beece 2893 struct peer *peer;
718e3744 2894 struct peer_group *group;
2895
2896 bgp = vty->index;
c500ae40 2897 peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg);
a80beece
DS
2898 if (peer)
2899 {
2900 vty_out (vty, "%% Name conflict with interface: %s", VTY_NEWLINE);
2901 return CMD_WARNING;
2902 }
718e3744 2903
c500ae40 2904 group = peer_group_get (bgp, argv[idx_word]->arg);
718e3744 2905 if (! group)
2906 return CMD_WARNING;
2907
2908 return CMD_SUCCESS;
2909}
2910
f412b39a
DW
2911/*
2912 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
3ce54f78 2913 * "no neighbor <A.B.C.D|X:X::X:X> remote-as ((1-4294967295)|internal|external)",
f412b39a
DW
2914 * NO_STR
2915 * NEIGHBOR_STR
2916 * NEIGHBOR_ADDR_STR
2917 * "Specify a BGP neighbor\n"
2918 * AS_STR
2919 *
2920 */
718e3744 2921DEFUN (no_neighbor,
2922 no_neighbor_cmd,
9ccf14f7 2923 "no neighbor <A.B.C.D|X:X::X:X|WORD>",
718e3744 2924 NO_STR
2925 NEIGHBOR_STR
2926 NEIGHBOR_ADDR_STR2)
2927{
c500ae40 2928 int idx_peer = 2;
718e3744 2929 int ret;
2930 union sockunion su;
2931 struct peer_group *group;
2932 struct peer *peer;
1ff9a340 2933 struct peer *other;
718e3744 2934
c500ae40 2935 ret = str2sockunion (argv[idx_peer]->arg, &su);
718e3744 2936 if (ret < 0)
2937 {
a80beece 2938 /* look up for neighbor by interface name config. */
c500ae40 2939 peer = peer_lookup_by_conf_if (vty->index, argv[idx_peer]->arg);
a80beece
DS
2940 if (peer)
2941 {
4a04e5f7 2942 /* Request zebra to terminate IPv6 RAs on this interface. */
2943 if (peer->ifp)
2944 bgp_zebra_terminate_radv (peer->bgp, peer);
a80beece
DS
2945 peer_delete (peer);
2946 return CMD_SUCCESS;
2947 }
2948
c500ae40 2949 group = peer_group_lookup (vty->index, argv[idx_peer]->arg);
718e3744 2950 if (group)
2951 peer_group_delete (group);
2952 else
2953 {
2954 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
2955 return CMD_WARNING;
2956 }
2957 }
2958 else
2959 {
2960 peer = peer_lookup (vty->index, &su);
2961 if (peer)
1ff9a340 2962 {
f14e6fdb
DS
2963 if (peer_dynamic_neighbor (peer))
2964 {
2965 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
2966 VTY_NEWLINE);
2967 return CMD_WARNING;
2968 }
2969
1ff9a340
DS
2970 other = peer->doppelganger;
2971 peer_delete (peer);
2972 if (other && other->status != Deleted)
2973 peer_delete(other);
2974 }
718e3744 2975 }
2976
2977 return CMD_SUCCESS;
2978}
2979
718e3744 2980
f412b39a
DW
2981/*
2982 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9ccf14f7 2983 * "no neighbor WORD interface remote-as ((1-4294967295)|internal|external)",
f412b39a
DW
2984 * NO_STR
2985 * NEIGHBOR_STR
2986 * "Interface name\n"
2987 * "Configure BGP on interface\n"
2988 * AS_STR
2989 *
2990 * "no neighbor WORD interface v6only peer-group WORD",
2991 * NO_STR
2992 * NEIGHBOR_STR
2993 * "Interface name\n"
2994 * "Configure BGP on interface\n"
2995 * "Enable BGP with v6 link-local only\n"
2996 * "Member of the peer-group\n"
2997 * "peer-group name\n"
2998 *
9ccf14f7 2999 * "no neighbor WORD interface v6only remote-as ((1-4294967295)|internal|external)",
f412b39a
DW
3000 * NO_STR
3001 * NEIGHBOR_STR
3002 * "Interface name\n"
3003 * "Configure BGP on interface\n"
3004 * "Enable BGP with v6 link-local only\n"
3005 * AS_STR
3006 *
3007 * "no neighbor WORD interface v6only",
3008 * NO_STR
3009 * NEIGHBOR_STR
3010 * "Interface name\n"
3011 * "Configure BGP on interface\n"
3012 * "Enable BGP with v6 link-local only\n"
3013 *
3014 * "no neighbor WORD interface peer-group WORD",
3015 * NO_STR
3016 * NEIGHBOR_STR
3017 * "Interface name\n"
3018 * "Configure BGP on interface\n"
3019 * "Member of the peer-group\n"
3020 * "peer-group name\n"
3021 *
3022 */
a80beece
DS
3023DEFUN (no_neighbor_interface_config,
3024 no_neighbor_interface_config_cmd,
4c48cf63 3025 "no neighbor WORD interface",
a80beece
DS
3026 NO_STR
3027 NEIGHBOR_STR
3028 "Interface name\n"
3029 "Configure BGP on interface\n")
3030{
c500ae40 3031 int idx_word = 2;
a80beece
DS
3032 struct peer *peer;
3033
3034 /* look up for neighbor by interface name config. */
c500ae40 3035 peer = peer_lookup_by_conf_if (vty->index, argv[idx_word]->arg);
a80beece
DS
3036 if (peer)
3037 {
4a04e5f7 3038 /* Request zebra to terminate IPv6 RAs on this interface. */
3039 if (peer->ifp)
3040 bgp_zebra_terminate_radv (peer->bgp, peer);
a80beece
DS
3041 peer_delete (peer);
3042 }
3043 else
3044 {
3045 vty_out (vty, "%% Create the bgp interface first%s", VTY_NEWLINE);
3046 return CMD_WARNING;
3047 }
3048 return CMD_SUCCESS;
3049}
3050
718e3744 3051DEFUN (no_neighbor_peer_group,
3052 no_neighbor_peer_group_cmd,
3053 "no neighbor WORD peer-group",
3054 NO_STR
3055 NEIGHBOR_STR
3056 "Neighbor tag\n"
3057 "Configure peer-group\n")
3058{
c500ae40 3059 int idx_word = 2;
718e3744 3060 struct peer_group *group;
3061
c500ae40 3062 group = peer_group_lookup (vty->index, argv[idx_word]->arg);
718e3744 3063 if (group)
3064 peer_group_delete (group);
3065 else
3066 {
3067 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
3068 return CMD_WARNING;
3069 }
3070 return CMD_SUCCESS;
3071}
3072
a80beece
DS
3073DEFUN (no_neighbor_interface_peer_group_remote_as,
3074 no_neighbor_interface_peer_group_remote_as_cmd,
9ccf14f7 3075 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
718e3744 3076 NO_STR
3077 NEIGHBOR_STR
a80beece 3078 "Interface name or neighbor tag\n"
718e3744 3079 "Specify a BGP neighbor\n"
3080 AS_STR)
3081{
c500ae40 3082 int idx_word = 2;
718e3744 3083 struct peer_group *group;
a80beece
DS
3084 struct peer *peer;
3085
3086 /* look up for neighbor by interface name config. */
c500ae40 3087 peer = peer_lookup_by_conf_if (vty->index, argv[idx_word]->arg);
a80beece
DS
3088 if (peer)
3089 {
0299c004 3090 peer_as_change (peer, 0, AS_SPECIFIED);
a80beece
DS
3091 return CMD_SUCCESS;
3092 }
718e3744 3093
c500ae40 3094 group = peer_group_lookup (vty->index, argv[idx_word]->arg);
718e3744 3095 if (group)
3096 peer_group_remote_as_delete (group);
3097 else
3098 {
a80beece 3099 vty_out (vty, "%% Create the peer-group or interface first%s", VTY_NEWLINE);
718e3744 3100 return CMD_WARNING;
3101 }
3102 return CMD_SUCCESS;
3103}
6b0655a2 3104
718e3744 3105DEFUN (neighbor_local_as,
3106 neighbor_local_as_cmd,
9ccf14f7 3107 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
718e3744 3108 NEIGHBOR_STR
3109 NEIGHBOR_ADDR_STR2
3110 "Specify a local-as number\n"
3111 "AS number used as local AS\n")
3112{
c500ae40
DW
3113 int idx_peer = 1;
3114 int idx_number = 3;
718e3744 3115 struct peer *peer;
3116 int ret;
3117
c500ae40 3118 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
718e3744 3119 if (! peer)
3120 return CMD_WARNING;
3121
c500ae40 3122 ret = peer_local_as_set (peer, atoi (argv[idx_number]->arg), 0, 0);
718e3744 3123 return bgp_vty_return (vty, ret);
3124}
3125
3126DEFUN (neighbor_local_as_no_prepend,
3127 neighbor_local_as_no_prepend_cmd,
9ccf14f7 3128 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
718e3744 3129 NEIGHBOR_STR
3130 NEIGHBOR_ADDR_STR2
3131 "Specify a local-as number\n"
3132 "AS number used as local AS\n"
3133 "Do not prepend local-as to updates from ebgp peers\n")
3134{
c500ae40
DW
3135 int idx_peer = 1;
3136 int idx_number = 3;
718e3744 3137 struct peer *peer;
3138 int ret;
3139
c500ae40 3140 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
718e3744 3141 if (! peer)
3142 return CMD_WARNING;
3143
c500ae40 3144 ret = peer_local_as_set (peer, atoi (argv[idx_number]->arg), 1, 0);
718e3744 3145 return bgp_vty_return (vty, ret);
3146}
3147
9d3f9705
AC
3148DEFUN (neighbor_local_as_no_prepend_replace_as,
3149 neighbor_local_as_no_prepend_replace_as_cmd,
9ccf14f7 3150 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
9d3f9705
AC
3151 NEIGHBOR_STR
3152 NEIGHBOR_ADDR_STR2
3153 "Specify a local-as number\n"
3154 "AS number used as local AS\n"
3155 "Do not prepend local-as to updates from ebgp peers\n"
3156 "Do not prepend local-as to updates from ibgp peers\n")
3157{
c500ae40
DW
3158 int idx_peer = 1;
3159 int idx_number = 3;
9d3f9705
AC
3160 struct peer *peer;
3161 int ret;
3162
c500ae40 3163 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
9d3f9705
AC
3164 if (! peer)
3165 return CMD_WARNING;
3166
c500ae40 3167 ret = peer_local_as_set (peer, atoi (argv[idx_number]->arg), 1, 1);
9d3f9705
AC
3168 return bgp_vty_return (vty, ret);
3169}
3170
3171
f412b39a
DW
3172/*
3173 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
3ce54f78 3174 * "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
f412b39a
DW
3175 * NO_STR
3176 * NEIGHBOR_STR
3177 * NEIGHBOR_ADDR_STR2
3178 * "Specify a local-as number\n"
3179 * "AS number used as local AS\n"
3180 *
3ce54f78 3181 * "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
f412b39a
DW
3182 * NO_STR
3183 * NEIGHBOR_STR
3184 * NEIGHBOR_ADDR_STR2
3185 * "Specify a local-as number\n"
3186 * "AS number used as local AS\n"
3187 * "Do not prepend local-as to updates from ebgp peers\n"
3188 *
3ce54f78 3189 * "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
f412b39a
DW
3190 * NO_STR
3191 * NEIGHBOR_STR
3192 * NEIGHBOR_ADDR_STR2
3193 * "Specify a local-as number\n"
3194 * "AS number used as local AS\n"
3195 * "Do not prepend local-as to updates from ebgp peers\n"
3196 * "Do not prepend local-as to updates from ibgp peers\n"
3197 *
3198 */
718e3744 3199DEFUN (no_neighbor_local_as,
3200 no_neighbor_local_as_cmd,
9ccf14f7 3201 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as",
718e3744 3202 NO_STR
3203 NEIGHBOR_STR
3204 NEIGHBOR_ADDR_STR2
3205 "Specify a local-as number\n")
3206{
c500ae40 3207 int idx_peer = 2;
718e3744 3208 struct peer *peer;
3209 int ret;
3210
c500ae40 3211 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
718e3744 3212 if (! peer)
3213 return CMD_WARNING;
3214
3215 ret = peer_local_as_unset (peer);
3216 return bgp_vty_return (vty, ret);
3217}
3218
718e3744 3219
9d3f9705 3220
6b0655a2 3221
3f9c7369
DS
3222DEFUN (neighbor_solo,
3223 neighbor_solo_cmd,
9ccf14f7 3224 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3f9c7369
DS
3225 NEIGHBOR_STR
3226 NEIGHBOR_ADDR_STR2
3227 "Solo peer - part of its own update group\n")
3228{
c500ae40 3229 int idx_peer = 1;
3f9c7369
DS
3230 struct peer *peer;
3231 int ret;
3232
c500ae40 3233 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
3f9c7369
DS
3234 if (! peer)
3235 return CMD_WARNING;
3236
3237 ret = update_group_adjust_soloness(peer, 1);
3238 return bgp_vty_return (vty, ret);
3239}
3240
3241DEFUN (no_neighbor_solo,
3242 no_neighbor_solo_cmd,
9ccf14f7 3243 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3f9c7369
DS
3244 NO_STR
3245 NEIGHBOR_STR
3246 NEIGHBOR_ADDR_STR2
3247 "Solo peer - part of its own update group\n")
3248{
c500ae40 3249 int idx_peer = 2;
3f9c7369
DS
3250 struct peer *peer;
3251 int ret;
3252
c500ae40 3253 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
3f9c7369
DS
3254 if (! peer)
3255 return CMD_WARNING;
3256
3257 ret = update_group_adjust_soloness(peer, 0);
3258 return bgp_vty_return (vty, ret);
3259}
3260
0df7c91f
PJ
3261DEFUN (neighbor_password,
3262 neighbor_password_cmd,
9ccf14f7 3263 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
0df7c91f
PJ
3264 NEIGHBOR_STR
3265 NEIGHBOR_ADDR_STR2
3266 "Set a password\n"
3267 "The password\n")
3268{
c500ae40
DW
3269 int idx_peer = 1;
3270 int idx_line = 3;
0df7c91f
PJ
3271 struct peer *peer;
3272 int ret;
3273
c500ae40 3274 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
0df7c91f
PJ
3275 if (! peer)
3276 return CMD_WARNING;
3277
c500ae40 3278 ret = peer_password_set (peer, argv[idx_line]->arg);
0df7c91f
PJ
3279 return bgp_vty_return (vty, ret);
3280}
3281
f412b39a
DW
3282/*
3283 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
3ce54f78 3284 * "no neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
f412b39a
DW
3285 * NO_STR
3286 * NEIGHBOR_STR
3287 * NEIGHBOR_ADDR_STR2
3288 * "Set a password\n"
3289 * "The password\n"
3290 *
3291 */
0df7c91f
PJ
3292DEFUN (no_neighbor_password,
3293 no_neighbor_password_cmd,
9ccf14f7 3294 "no neighbor <A.B.C.D|X:X::X:X|WORD> password",
0df7c91f
PJ
3295 NO_STR
3296 NEIGHBOR_STR
3297 NEIGHBOR_ADDR_STR2
3298 "Set a password\n")
3299{
c500ae40 3300 int idx_peer = 2;
0df7c91f
PJ
3301 struct peer *peer;
3302 int ret;
3303
c500ae40 3304 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
0df7c91f
PJ
3305 if (! peer)
3306 return CMD_WARNING;
3307
3308 ret = peer_password_unset (peer);
3309 return bgp_vty_return (vty, ret);
3310}
6b0655a2 3311
813d4307 3312
718e3744 3313DEFUN (neighbor_activate,
3314 neighbor_activate_cmd,
9ccf14f7 3315 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
718e3744 3316 NEIGHBOR_STR
3317 NEIGHBOR_ADDR_STR2
3318 "Enable the Address Family for this Neighbor\n")
3319{
c500ae40 3320 int idx_peer = 1;
c8560b44 3321 int ret;
718e3744 3322 struct peer *peer;
3323
c500ae40 3324 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
718e3744 3325 if (! peer)
3326 return CMD_WARNING;
3327
c8560b44 3328 ret = peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
718e3744 3329
c8560b44
DW
3330 if (ret)
3331 return CMD_WARNING;
718e3744 3332 return CMD_SUCCESS;
3333}
3334
3335DEFUN (no_neighbor_activate,
3336 no_neighbor_activate_cmd,
9ccf14f7 3337 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
718e3744 3338 NO_STR
3339 NEIGHBOR_STR
3340 NEIGHBOR_ADDR_STR2
3341 "Enable the Address Family for this Neighbor\n")
3342{
c500ae40 3343 int idx_peer = 2;
718e3744 3344 int ret;
3345 struct peer *peer;
3346
3347 /* Lookup peer. */
c500ae40 3348 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
718e3744 3349 if (! peer)
3350 return CMD_WARNING;
3351
3352 ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
3353
c8560b44
DW
3354 if (ret)
3355 return CMD_WARNING;
3356 return CMD_SUCCESS;
718e3744 3357}
6b0655a2 3358
718e3744 3359DEFUN (neighbor_set_peer_group,
3360 neighbor_set_peer_group_cmd,
9ccf14f7 3361 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
718e3744 3362 NEIGHBOR_STR
a80beece 3363 NEIGHBOR_ADDR_STR2
718e3744 3364 "Member of the peer-group\n"
3365 "peer-group name\n")
3366{
c500ae40
DW
3367 int idx_peer = 1;
3368 int idx_word = 3;
718e3744 3369 int ret;
3370 as_t as;
3371 union sockunion su;
3372 struct bgp *bgp;
a80beece 3373 struct peer *peer;
718e3744 3374 struct peer_group *group;
3375
3376 bgp = vty->index;
a80beece 3377 peer = NULL;
718e3744 3378
c500ae40 3379 ret = str2sockunion (argv[idx_peer]->arg, &su);
718e3744 3380 if (ret < 0)
3381 {
c500ae40 3382 peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg);
a80beece
DS
3383 if (!peer)
3384 {
c500ae40 3385 vty_out (vty, "%% Malformed address or name: %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
a80beece
DS
3386 return CMD_WARNING;
3387 }
3388 }
3389 else
3390 {
6aeb9e78 3391 if (peer_address_self_check (bgp, &su))
a80beece
DS
3392 {
3393 vty_out (vty, "%% Can not configure the local system as neighbor%s",
3394 VTY_NEWLINE);
3395 return CMD_WARNING;
3396 }
f14e6fdb
DS
3397
3398 /* Disallow for dynamic neighbor. */
3399 peer = peer_lookup (bgp, &su);
3400 if (peer && peer_dynamic_neighbor (peer))
3401 {
3402 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
3403 VTY_NEWLINE);
3404 return CMD_WARNING;
3405 }
718e3744 3406 }
3407
c500ae40 3408 group = peer_group_lookup (bgp, argv[idx_word]->arg);
718e3744 3409 if (! group)
3410 {
3411 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
3412 return CMD_WARNING;
3413 }
3414
c8560b44 3415 ret = peer_group_bind (bgp, &su, peer, group, &as);
718e3744 3416
3417 if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT)
3418 {
aea339f7 3419 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 3420 return CMD_WARNING;
3421 }
3422
3423 return bgp_vty_return (vty, ret);
3424}
3425
3426DEFUN (no_neighbor_set_peer_group,
3427 no_neighbor_set_peer_group_cmd,
9ccf14f7 3428 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
718e3744 3429 NO_STR
3430 NEIGHBOR_STR
a80beece 3431 NEIGHBOR_ADDR_STR2
718e3744 3432 "Member of the peer-group\n"
3433 "peer-group name\n")
3434{
c500ae40
DW
3435 int idx_peer = 2;
3436 int idx_word = 4;
718e3744 3437 int ret;
3438 struct bgp *bgp;
3439 struct peer *peer;
3440 struct peer_group *group;
3441
3442 bgp = vty->index;
3443
c500ae40 3444 peer = peer_lookup_vty (vty, argv[idx_peer]->arg);
718e3744 3445 if (! peer)
3446 return CMD_WARNING;
3447
c500ae40 3448 group = peer_group_lookup (bgp, argv[idx_word]->arg);
718e3744 3449 if (! group)
3450 {
3451 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
3452 return CMD_WARNING;
3453 }
3454
c8560b44 3455 ret = peer_group_unbind (bgp, peer, group);
718e3744 3456
3457 return bgp_vty_return (vty, ret);
3458}
6b0655a2 3459
94f2b392 3460static int
fd79ac91 3461peer_flag_modify_vty (struct vty *vty, const char *ip_str,
3462 u_int16_t flag, int set)
718e3744 3463{
3464 int ret;
3465 struct peer *peer;
3466
3467 peer = peer_and_group_lookup_vty (vty, ip_str);
3468 if (! peer)
3469 return CMD_WARNING;
3470
8cdabf90
SK
3471 /*
3472 * If 'neighbor <interface>', then this is for directly connected peers,
3473 * we should not accept disable-connected-check.
3474 */
3475 if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) {
3476 vty_out (vty, "%s is directly connected peer, cannot accept disable-"
3477 "connected-check%s", ip_str, VTY_NEWLINE);
3478 return CMD_WARNING;
3479 }
3480
718e3744 3481 if (set)
3482 ret = peer_flag_set (peer, flag);
3483 else
3484 ret = peer_flag_unset (peer, flag);
3485
3486 return bgp_vty_return (vty, ret);
3487}
3488
94f2b392 3489static int
fd79ac91 3490peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
718e3744 3491{
3492 return peer_flag_modify_vty (vty, ip_str, flag, 1);
3493}
3494
94f2b392 3495static int
fd79ac91 3496peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
718e3744 3497{
3498 return peer_flag_modify_vty (vty, ip_str, flag, 0);
3499}
3500
3501/* neighbor passive. */
3502DEFUN (neighbor_passive,
3503 neighbor_passive_cmd,
9ccf14f7 3504 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
718e3744 3505 NEIGHBOR_STR
3506 NEIGHBOR_ADDR_STR2
3507 "Don't send open messages to this neighbor\n")
3508{
c500ae40
DW
3509 int idx_peer = 1;
3510 return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE);
718e3744 3511}
3512
3513DEFUN (no_neighbor_passive,
3514 no_neighbor_passive_cmd,
9ccf14f7 3515 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
718e3744 3516 NO_STR
3517 NEIGHBOR_STR
3518 NEIGHBOR_ADDR_STR2
3519 "Don't send open messages to this neighbor\n")
3520{
c500ae40
DW
3521 int idx_peer = 2;
3522 return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE);
718e3744 3523}
6b0655a2 3524
718e3744 3525/* neighbor shutdown. */
3526DEFUN (neighbor_shutdown,
3527 neighbor_shutdown_cmd,
9ccf14f7 3528 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
718e3744 3529 NEIGHBOR_STR
3530 NEIGHBOR_ADDR_STR2
3531 "Administratively shut down this neighbor\n")
3532{
c500ae40
DW
3533 int idx_peer = 1;
3534 return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN);
718e3744 3535}
3536
3537DEFUN (no_neighbor_shutdown,
3538 no_neighbor_shutdown_cmd,
9ccf14f7 3539 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
718e3744 3540 NO_STR
3541 NEIGHBOR_STR
3542 NEIGHBOR_ADDR_STR2
3543 "Administratively shut down this neighbor\n")
3544{
c500ae40
DW
3545 int idx_peer = 2;
3546 return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN);
718e3744 3547}
6b0655a2 3548
718e3744 3549/* neighbor capability dynamic. */
3550DEFUN (neighbor_capability_dynamic,
3551 neighbor_capability_dynamic_cmd,
9ccf14f7 3552 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
718e3744 3553 NEIGHBOR_STR
3554 NEIGHBOR_ADDR_STR2
3555 "Advertise capability to the peer\n"
3556 "Advertise dynamic capability to this neighbor\n")
3557{
c500ae40
DW
3558 int idx_peer = 1;
3559 return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY);
718e3744 3560}
3561
3562DEFUN (no_neighbor_capability_dynamic,
3563 no_neighbor_capability_dynamic_cmd,
9ccf14f7 3564 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
718e3744 3565 NO_STR
3566 NEIGHBOR_STR
3567 NEIGHBOR_ADDR_STR2
3568 "Advertise capability to the peer\n"
3569 "Advertise dynamic capability to this neighbor\n")
3570{
c500ae40
DW
3571 int idx_peer = 2;
3572 return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY);
718e3744 3573}
6b0655a2 3574
718e3744 3575/* neighbor dont-capability-negotiate */
3576DEFUN (neighbor_dont_capability_negotiate,
3577 neighbor_dont_capability_negotiate_cmd,
9ccf14f7 3578 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
718e3744 3579 NEIGHBOR_STR
3580 NEIGHBOR_ADDR_STR2
3581 "Do not perform capability negotiation\n")
3582{
c500ae40
DW
3583 int idx_peer = 1;
3584 return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY);
718e3744 3585}
3586
3587DEFUN (no_neighbor_dont_capability_negotiate,
3588 no_neighbor_dont_capability_negotiate_cmd,
9ccf14f7 3589 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
718e3744 3590 NO_STR
3591 NEIGHBOR_STR
3592 NEIGHBOR_ADDR_STR2
3593 "Do not perform capability negotiation\n")
3594{
c500ae40
DW
3595 int idx_peer = 2;
3596 return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY);
718e3744 3597}
6b0655a2 3598
8a92a8a0
DS
3599/* neighbor capability extended next hop encoding */
3600DEFUN (neighbor_capability_enhe,
3601 neighbor_capability_enhe_cmd,
9ccf14f7 3602 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
8a92a8a0
DS
3603 NEIGHBOR_STR
3604 NEIGHBOR_ADDR_STR2
3605 "Advertise capability to the peer\n"
3606 "Advertise extended next-hop capability to the peer\n")
3607{
c500ae40
DW
3608 int idx_peer = 1;
3609 return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE);
8a92a8a0
DS
3610}
3611
3612DEFUN (no_neighbor_capability_enhe,
3613 no_neighbor_capability_enhe_cmd,
9ccf14f7 3614 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
8a92a8a0
DS
3615 NO_STR
3616 NEIGHBOR_STR
3617 NEIGHBOR_ADDR_STR2
3618 "Advertise capability to the peer\n"
3619 "Advertise extended next-hop capability to the peer\n")
3620{
c500ae40
DW
3621 int idx_peer = 2;
3622 return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE);
8a92a8a0
DS
3623}
3624
94f2b392 3625static int
fd79ac91 3626peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi,
fee0f4c6 3627 safi_t safi, u_int32_t flag, int set)
718e3744 3628{
3629 int ret;
3630 struct peer *peer;
3631
3632 peer = peer_and_group_lookup_vty (vty, peer_str);
3633 if (! peer)
3634 return CMD_WARNING;
3635
3636 if (set)
3637 ret = peer_af_flag_set (peer, afi, safi, flag);
3638 else
3639 ret = peer_af_flag_unset (peer, afi, safi, flag);
3640
3641 return bgp_vty_return (vty, ret);
3642}
3643
94f2b392 3644static int
fd79ac91 3645peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi,
fee0f4c6 3646 safi_t safi, u_int32_t flag)
718e3744 3647{
3648 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1);
3649}
3650
94f2b392 3651static int
fd79ac91 3652peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi,
fee0f4c6 3653 safi_t safi, u_int32_t flag)
718e3744 3654{
3655 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0);
3656}
6b0655a2 3657
718e3744 3658/* neighbor capability orf prefix-list. */
3659DEFUN (neighbor_capability_orf_prefix,
3660 neighbor_capability_orf_prefix_cmd,
9ccf14f7 3661 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
718e3744 3662 NEIGHBOR_STR
3663 NEIGHBOR_ADDR_STR2
3664 "Advertise capability to the peer\n"
3665 "Advertise ORF capability to the peer\n"
3666 "Advertise prefixlist ORF capability to this neighbor\n"
3667 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3668 "Capability to RECEIVE the ORF from this neighbor\n"
3669 "Capability to SEND the ORF to this neighbor\n")
3670{
c500ae40
DW
3671 int idx_peer = 1;
3672 int idx_send_recv = 5;
718e3744 3673 u_int16_t flag = 0;
3674
c500ae40 3675 if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0)
718e3744 3676 flag = PEER_FLAG_ORF_PREFIX_SM;
c500ae40 3677 else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0)
718e3744 3678 flag = PEER_FLAG_ORF_PREFIX_RM;
c500ae40 3679 else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0)
718e3744 3680 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
3681 else
3682 return CMD_WARNING;
3683
c500ae40 3684 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 3685 bgp_node_safi (vty), flag);
3686}
3687
3688DEFUN (no_neighbor_capability_orf_prefix,
3689 no_neighbor_capability_orf_prefix_cmd,
9ccf14f7 3690 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
718e3744 3691 NO_STR
3692 NEIGHBOR_STR
3693 NEIGHBOR_ADDR_STR2
3694 "Advertise capability to the peer\n"
3695 "Advertise ORF capability to the peer\n"
3696 "Advertise prefixlist ORF capability to this neighbor\n"
3697 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3698 "Capability to RECEIVE the ORF from this neighbor\n"
3699 "Capability to SEND the ORF to this neighbor\n")
3700{
c500ae40
DW
3701 int idx_peer = 2;
3702 int idx_send_recv = 6;
718e3744 3703 u_int16_t flag = 0;
3704
c500ae40 3705 if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0)
718e3744 3706 flag = PEER_FLAG_ORF_PREFIX_SM;
c500ae40 3707 else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0)
718e3744 3708 flag = PEER_FLAG_ORF_PREFIX_RM;
c500ae40 3709 else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0)
718e3744 3710 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
3711 else
3712 return CMD_WARNING;
3713
c500ae40 3714 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 3715 bgp_node_safi (vty), flag);
3716}
6b0655a2 3717
718e3744 3718/* neighbor next-hop-self. */
3719DEFUN (neighbor_nexthop_self,
3720 neighbor_nexthop_self_cmd,
9ccf14f7 3721 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
718e3744 3722 NEIGHBOR_STR
3723 NEIGHBOR_ADDR_STR2
a538debe 3724 "Disable the next hop calculation for this neighbor\n")
718e3744 3725{
c500ae40
DW
3726 int idx_peer = 1;
3727 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
a538debe
DS
3728 bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF);
3729}
9e7a53c1 3730
a538debe
DS
3731/* neighbor next-hop-self. */
3732DEFUN (neighbor_nexthop_self_force,
3733 neighbor_nexthop_self_force_cmd,
9ccf14f7 3734 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
a538debe
DS
3735 NEIGHBOR_STR
3736 NEIGHBOR_ADDR_STR2
3737 "Disable the next hop calculation for this neighbor\n"
3738 "Set the next hop to self for reflected routes\n")
3739{
c500ae40
DW
3740 int idx_peer = 1;
3741 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
a538debe 3742 bgp_node_safi (vty),
88b8ed8d 3743 PEER_FLAG_FORCE_NEXTHOP_SELF);
718e3744 3744}
3745
3746DEFUN (no_neighbor_nexthop_self,
3747 no_neighbor_nexthop_self_cmd,
9ccf14f7 3748 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
718e3744 3749 NO_STR
3750 NEIGHBOR_STR
3751 NEIGHBOR_ADDR_STR2
a538debe 3752 "Disable the next hop calculation for this neighbor\n")
718e3744 3753{
c500ae40
DW
3754 int idx_peer = 2;
3755 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
9e7a53c1 3756 bgp_node_safi (vty),
88b8ed8d 3757 PEER_FLAG_NEXTHOP_SELF);
718e3744 3758}
6b0655a2 3759
88b8ed8d 3760DEFUN (no_neighbor_nexthop_self_force,
a538debe 3761 no_neighbor_nexthop_self_force_cmd,
9ccf14f7 3762 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
a538debe
DS
3763 NO_STR
3764 NEIGHBOR_STR
3765 NEIGHBOR_ADDR_STR2
3766 "Disable the next hop calculation for this neighbor\n"
3767 "Set the next hop to self for reflected routes\n")
88b8ed8d 3768{
c500ae40
DW
3769 int idx_peer = 2;
3770 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
88b8ed8d
DW
3771 bgp_node_safi (vty),
3772 PEER_FLAG_FORCE_NEXTHOP_SELF);
3773}
a538debe 3774
c7122e14
DS
3775/* neighbor as-override */
3776DEFUN (neighbor_as_override,
3777 neighbor_as_override_cmd,
9ccf14f7 3778 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
c7122e14
DS
3779 NEIGHBOR_STR
3780 NEIGHBOR_ADDR_STR2
3781 "Override ASNs in outbound updates if aspath equals remote-as\n")
3782{
c500ae40
DW
3783 int idx_peer = 1;
3784 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
c7122e14
DS
3785 bgp_node_safi (vty),
3786 PEER_FLAG_AS_OVERRIDE);
3787}
3788
3789DEFUN (no_neighbor_as_override,
3790 no_neighbor_as_override_cmd,
9ccf14f7 3791 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
c7122e14
DS
3792 NO_STR
3793 NEIGHBOR_STR
3794 NEIGHBOR_ADDR_STR2
3795 "Override ASNs in outbound updates if aspath equals remote-as\n")
3796{
c500ae40
DW
3797 int idx_peer = 2;
3798 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
c7122e14
DS
3799 bgp_node_safi (vty),
3800 PEER_FLAG_AS_OVERRIDE);
3801}
3802
718e3744 3803/* neighbor remove-private-AS. */
3804DEFUN (neighbor_remove_private_as,
3805 neighbor_remove_private_as_cmd,
9ccf14f7 3806 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
718e3744 3807 NEIGHBOR_STR
3808 NEIGHBOR_ADDR_STR2
5000f21c 3809 "Remove private ASNs in outbound updates\n")
718e3744 3810{
c500ae40
DW
3811 int idx_peer = 1;
3812 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 3813 bgp_node_safi (vty),
3814 PEER_FLAG_REMOVE_PRIVATE_AS);
3815}
3816
5000f21c
DS
3817DEFUN (neighbor_remove_private_as_all,
3818 neighbor_remove_private_as_all_cmd,
9ccf14f7 3819 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5000f21c
DS
3820 NEIGHBOR_STR
3821 NEIGHBOR_ADDR_STR2
3822 "Remove private ASNs in outbound updates\n"
3823 "Apply to all AS numbers")
3824{
c500ae40
DW
3825 int idx_peer = 1;
3826 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5000f21c 3827 bgp_node_safi (vty),
5000f21c
DS
3828 PEER_FLAG_REMOVE_PRIVATE_AS_ALL);
3829}
3830
3831DEFUN (neighbor_remove_private_as_replace_as,
3832 neighbor_remove_private_as_replace_as_cmd,
9ccf14f7 3833 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5000f21c
DS
3834 NEIGHBOR_STR
3835 NEIGHBOR_ADDR_STR2
3836 "Remove private ASNs in outbound updates\n"
3837 "Replace private ASNs with our ASN in outbound updates\n")
3838{
c500ae40
DW
3839 int idx_peer = 1;
3840 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5000f21c 3841 bgp_node_safi (vty),
5000f21c
DS
3842 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE);
3843}
3844
3845DEFUN (neighbor_remove_private_as_all_replace_as,
3846 neighbor_remove_private_as_all_replace_as_cmd,
9ccf14f7 3847 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5000f21c
DS
3848 NEIGHBOR_STR
3849 NEIGHBOR_ADDR_STR2
3850 "Remove private ASNs in outbound updates\n"
3851 "Apply to all AS numbers"
3852 "Replace private ASNs with our ASN in outbound updates\n")
3853{
c500ae40
DW
3854 int idx_peer = 1;
3855 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5000f21c 3856 bgp_node_safi (vty),
88b8ed8d 3857 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE);
5000f21c
DS
3858}
3859
718e3744 3860DEFUN (no_neighbor_remove_private_as,
3861 no_neighbor_remove_private_as_cmd,
9ccf14f7 3862 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
718e3744 3863 NO_STR
3864 NEIGHBOR_STR
3865 NEIGHBOR_ADDR_STR2
5000f21c 3866 "Remove private ASNs in outbound updates\n")
718e3744 3867{
c500ae40
DW
3868 int idx_peer = 2;
3869 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 3870 bgp_node_safi (vty),
88b8ed8d 3871 PEER_FLAG_REMOVE_PRIVATE_AS);
718e3744 3872}
6b0655a2 3873
88b8ed8d 3874DEFUN (no_neighbor_remove_private_as_all,
5000f21c 3875 no_neighbor_remove_private_as_all_cmd,
9ccf14f7 3876 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5000f21c
DS
3877 NO_STR
3878 NEIGHBOR_STR
3879 NEIGHBOR_ADDR_STR2
3880 "Remove private ASNs in outbound updates\n"
3881 "Apply to all AS numbers")
88b8ed8d 3882{
c500ae40
DW
3883 int idx_peer = 2;
3884 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
88b8ed8d
DW
3885 bgp_node_safi (vty),
3886 PEER_FLAG_REMOVE_PRIVATE_AS_ALL);
3887}
5000f21c 3888
88b8ed8d 3889DEFUN (no_neighbor_remove_private_as_replace_as,
5000f21c 3890 no_neighbor_remove_private_as_replace_as_cmd,
9ccf14f7 3891 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5000f21c
DS
3892 NO_STR
3893 NEIGHBOR_STR
3894 NEIGHBOR_ADDR_STR2
3895 "Remove private ASNs in outbound updates\n"
3896 "Replace private ASNs with our ASN in outbound updates\n")
88b8ed8d 3897{
c500ae40
DW
3898 int idx_peer = 2;
3899 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
88b8ed8d
DW
3900 bgp_node_safi (vty),
3901 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE);
3902}
5000f21c 3903
88b8ed8d 3904DEFUN (no_neighbor_remove_private_as_all_replace_as,
5000f21c 3905 no_neighbor_remove_private_as_all_replace_as_cmd,
9ccf14f7 3906 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5000f21c
DS
3907 NO_STR
3908 NEIGHBOR_STR
3909 NEIGHBOR_ADDR_STR2
3910 "Remove private ASNs in outbound updates\n"
3911 "Apply to all AS numbers"
3912 "Replace private ASNs with our ASN in outbound updates\n")
88b8ed8d 3913{
c500ae40
DW
3914 int idx_peer = 2;
3915 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
88b8ed8d
DW
3916 bgp_node_safi (vty),
3917 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE);
3918}
5000f21c
DS
3919
3920
718e3744 3921/* neighbor send-community. */
3922DEFUN (neighbor_send_community,
3923 neighbor_send_community_cmd,
9ccf14f7 3924 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
718e3744 3925 NEIGHBOR_STR
3926 NEIGHBOR_ADDR_STR2
3927 "Send Community attribute to this neighbor\n")
3928{
c500ae40
DW
3929 int idx_peer = 1;
3930 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 3931 bgp_node_safi (vty),
3932 PEER_FLAG_SEND_COMMUNITY);
3933}
3934
3935DEFUN (no_neighbor_send_community,
3936 no_neighbor_send_community_cmd,
9ccf14f7 3937 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
718e3744 3938 NO_STR
3939 NEIGHBOR_STR
3940 NEIGHBOR_ADDR_STR2
3941 "Send Community attribute to this neighbor\n")
3942{
c500ae40
DW
3943 int idx_peer = 2;
3944 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 3945 bgp_node_safi (vty),
3946 PEER_FLAG_SEND_COMMUNITY);
3947}
6b0655a2 3948
718e3744 3949/* neighbor send-community extended. */
3950DEFUN (neighbor_send_community_type,
3951 neighbor_send_community_type_cmd,
9ccf14f7 3952 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|extended|standard>",
718e3744 3953 NEIGHBOR_STR
3954 NEIGHBOR_ADDR_STR2
3955 "Send Community attribute to this neighbor\n"
3956 "Send Standard and Extended Community attributes\n"
3957 "Send Extended Community attributes\n"
3958 "Send Standard Community attributes\n")
3959{
c500ae40
DW
3960 int idx_peer = 1;
3961 int idx_type = 3;
3962 if (strncmp (argv[idx_type]->arg, "s", 1) == 0)
3963 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 3964 bgp_node_safi (vty),
3965 PEER_FLAG_SEND_COMMUNITY);
c500ae40
DW
3966 if (strncmp (argv[idx_type]->arg, "e", 1) == 0)
3967 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 3968 bgp_node_safi (vty),
3969 PEER_FLAG_SEND_EXT_COMMUNITY);
3970
c500ae40 3971 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 3972 bgp_node_safi (vty),
3973 (PEER_FLAG_SEND_COMMUNITY|
3974 PEER_FLAG_SEND_EXT_COMMUNITY));
3975}
3976
3977DEFUN (no_neighbor_send_community_type,
3978 no_neighbor_send_community_type_cmd,
9ccf14f7 3979 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|extended|standard>",
718e3744 3980 NO_STR
3981 NEIGHBOR_STR
3982 NEIGHBOR_ADDR_STR2
3983 "Send Community attribute to this neighbor\n"
3984 "Send Standard and Extended Community attributes\n"
3985 "Send Extended Community attributes\n"
3986 "Send Standard Community attributes\n")
3987{
c500ae40
DW
3988 int idx_peer = 2;
3989 int idx_type = 4;
3990 if (strncmp (argv[idx_type]->arg, "s", 1) == 0)
3991 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 3992 bgp_node_safi (vty),
3993 PEER_FLAG_SEND_COMMUNITY);
c500ae40
DW
3994 if (strncmp (argv[idx_type]->arg, "e", 1) == 0)
3995 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 3996 bgp_node_safi (vty),
3997 PEER_FLAG_SEND_EXT_COMMUNITY);
3998
c500ae40 3999 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4000 bgp_node_safi (vty),
4001 (PEER_FLAG_SEND_COMMUNITY |
4002 PEER_FLAG_SEND_EXT_COMMUNITY));
4003}
6b0655a2 4004
718e3744 4005/* neighbor soft-reconfig. */
4006DEFUN (neighbor_soft_reconfiguration,
4007 neighbor_soft_reconfiguration_cmd,
9ccf14f7 4008 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
718e3744 4009 NEIGHBOR_STR
4010 NEIGHBOR_ADDR_STR2
4011 "Per neighbor soft reconfiguration\n"
4012 "Allow inbound soft reconfiguration for this neighbor\n")
4013{
c500ae40
DW
4014 int idx_peer = 1;
4015 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg,
718e3744 4016 bgp_node_afi (vty), bgp_node_safi (vty),
4017 PEER_FLAG_SOFT_RECONFIG);
4018}
4019
4020DEFUN (no_neighbor_soft_reconfiguration,
4021 no_neighbor_soft_reconfiguration_cmd,
9ccf14f7 4022 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
718e3744 4023 NO_STR
4024 NEIGHBOR_STR
4025 NEIGHBOR_ADDR_STR2
4026 "Per neighbor soft reconfiguration\n"
4027 "Allow inbound soft reconfiguration for this neighbor\n")
4028{
c500ae40
DW
4029 int idx_peer = 2;
4030 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg,
718e3744 4031 bgp_node_afi (vty), bgp_node_safi (vty),
4032 PEER_FLAG_SOFT_RECONFIG);
4033}
6b0655a2 4034
718e3744 4035DEFUN (neighbor_route_reflector_client,
4036 neighbor_route_reflector_client_cmd,
9ccf14f7 4037 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
718e3744 4038 NEIGHBOR_STR
4039 NEIGHBOR_ADDR_STR2
4040 "Configure a neighbor as Route Reflector client\n")
4041{
c500ae40 4042 int idx_peer = 1;
718e3744 4043 struct peer *peer;
4044
4045
c500ae40 4046 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
718e3744 4047 if (! peer)
4048 return CMD_WARNING;
4049
c500ae40 4050 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4051 bgp_node_safi (vty),
4052 PEER_FLAG_REFLECTOR_CLIENT);
4053}
4054
4055DEFUN (no_neighbor_route_reflector_client,
4056 no_neighbor_route_reflector_client_cmd,
9ccf14f7 4057 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
718e3744 4058 NO_STR
4059 NEIGHBOR_STR
4060 NEIGHBOR_ADDR_STR2
4061 "Configure a neighbor as Route Reflector client\n")
4062{
c500ae40
DW
4063 int idx_peer = 2;
4064 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4065 bgp_node_safi (vty),
4066 PEER_FLAG_REFLECTOR_CLIENT);
4067}
6b0655a2 4068
718e3744 4069/* neighbor route-server-client. */
4070DEFUN (neighbor_route_server_client,
4071 neighbor_route_server_client_cmd,
9ccf14f7 4072 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
718e3744 4073 NEIGHBOR_STR
4074 NEIGHBOR_ADDR_STR2
4075 "Configure a neighbor as Route Server client\n")
4076{
c500ae40 4077 int idx_peer = 1;
2a3d5731
DW
4078 struct peer *peer;
4079
c500ae40 4080 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
2a3d5731
DW
4081 if (! peer)
4082 return CMD_WARNING;
c500ae40 4083 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
2a3d5731
DW
4084 bgp_node_safi (vty),
4085 PEER_FLAG_RSERVER_CLIENT);
718e3744 4086}
4087
4088DEFUN (no_neighbor_route_server_client,
4089 no_neighbor_route_server_client_cmd,
9ccf14f7 4090 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
718e3744 4091 NO_STR
4092 NEIGHBOR_STR
4093 NEIGHBOR_ADDR_STR2
4094 "Configure a neighbor as Route Server client\n")
fee0f4c6 4095{
c500ae40
DW
4096 int idx_peer = 2;
4097 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
2a3d5731
DW
4098 bgp_node_safi (vty),
4099 PEER_FLAG_RSERVER_CLIENT);
fee0f4c6 4100}
6b0655a2 4101
fee0f4c6 4102DEFUN (neighbor_nexthop_local_unchanged,
4103 neighbor_nexthop_local_unchanged_cmd,
9ccf14f7 4104 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
fee0f4c6 4105 NEIGHBOR_STR
4106 NEIGHBOR_ADDR_STR2
4107 "Configure treatment of outgoing link-local nexthop attribute\n"
4108 "Leave link-local nexthop unchanged for this peer\n")
4109{
c500ae40
DW
4110 int idx_peer = 1;
4111 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
fee0f4c6 4112 bgp_node_safi (vty),
4113 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
4114}
6b0655a2 4115
fee0f4c6 4116DEFUN (no_neighbor_nexthop_local_unchanged,
4117 no_neighbor_nexthop_local_unchanged_cmd,
9ccf14f7 4118 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
fee0f4c6 4119 NO_STR
4120 NEIGHBOR_STR
4121 NEIGHBOR_ADDR_STR2
4122 "Configure treatment of outgoing link-local-nexthop attribute\n"
4123 "Leave link-local nexthop unchanged for this peer\n")
718e3744 4124{
c500ae40
DW
4125 int idx_peer = 2;
4126 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4127 bgp_node_safi (vty),
fee0f4c6 4128 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
718e3744 4129}
6b0655a2 4130
f412b39a
DW
4131/*
4132 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
3ce54f78 4133 * "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged med next-hop as-path",
f412b39a
DW
4134 * NEIGHBOR_STR
4135 * NEIGHBOR_ADDR_STR2
4136 * "BGP attribute is propagated unchanged to this neighbor\n"
4137 * "Med attribute\n"
4138 * "Nexthop attribute\n"
4139 * "As-path attribute\n"
4140 *
3ce54f78 4141 * "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged med as-path next-hop",
f412b39a
DW
4142 * NEIGHBOR_STR
4143 * NEIGHBOR_ADDR_STR2
4144 * "BGP attribute is propagated unchanged to this neighbor\n"
4145 * "Med attribute\n"
4146 * "As-path attribute\n"
4147 * "Nexthop attribute\n"
4148 *
3ce54f78 4149 * "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged as-path next-hop med",
f412b39a
DW
4150 * NEIGHBOR_STR
4151 * NEIGHBOR_ADDR_STR2
4152 * "BGP attribute is propagated unchanged to this neighbor\n"
4153 * "As-path attribute\n"
4154 * "Nexthop attribute\n"
4155 * "Med attribute\n"
4156 *
3ce54f78 4157 * "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged next-hop as-path med",
f412b39a
DW
4158 * NEIGHBOR_STR
4159 * NEIGHBOR_ADDR_STR2
4160 * "BGP attribute is propagated unchanged to this neighbor\n"
4161 * "Nexthop attribute\n"
4162 * "As-path attribute\n"
4163 * "Med attribute\n"
4164 *
3ce54f78 4165 * "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged as-path med next-hop",
f412b39a
DW
4166 * NEIGHBOR_STR
4167 * NEIGHBOR_ADDR_STR2
4168 * "BGP attribute is propagated unchanged to this neighbor\n"
4169 * "As-path attribute\n"
4170 * "Med attribute\n"
4171 * "Nexthop attribute\n"
4172 *
3ce54f78 4173 * "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged next-hop med as-path",
f412b39a
DW
4174 * NEIGHBOR_STR
4175 * NEIGHBOR_ADDR_STR2
4176 * "BGP attribute is propagated unchanged to this neighbor\n"
4177 * "Nexthop attribute\n"
4178 * "Med attribute\n"
4179 * "As-path attribute\n"
4180 *
4181 */
718e3744 4182DEFUN (neighbor_attr_unchanged,
4183 neighbor_attr_unchanged_cmd,
9ccf14f7 4184 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged",
718e3744 4185 NEIGHBOR_STR
4186 NEIGHBOR_ADDR_STR2
4187 "BGP attribute is propagated unchanged to this neighbor\n")
4188{
c500ae40
DW
4189 int idx_peer = 1;
4190 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4191 bgp_node_safi (vty),
4192 (PEER_FLAG_AS_PATH_UNCHANGED |
4193 PEER_FLAG_NEXTHOP_UNCHANGED |
4194 PEER_FLAG_MED_UNCHANGED));
4195}
4196
4197DEFUN (neighbor_attr_unchanged1,
4198 neighbor_attr_unchanged1_cmd,
9ccf14f7 4199 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged <as-path|next-hop|med>",
718e3744 4200 NEIGHBOR_STR
4201 NEIGHBOR_ADDR_STR2
4202 "BGP attribute is propagated unchanged to this neighbor\n"
4203 "As-path attribute\n"
4204 "Nexthop attribute\n"
4205 "Med attribute\n")
4206{
c500ae40
DW
4207 int idx_peer = 1;
4208 int idx_attribute = 3;
718e3744 4209 u_int16_t flags = 0;
4210
c500ae40 4211 if (strncmp (argv[idx_attribute]->arg, "as-path", 1) == 0)
718e3744 4212 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
c500ae40 4213 else if (strncmp (argv[idx_attribute]->arg, "next-hop", 1) == 0)
718e3744 4214 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
c500ae40 4215 else if (strncmp (argv[idx_attribute]->arg, "med", 1) == 0)
718e3744 4216 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4217
c500ae40 4218 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4219 bgp_node_safi (vty), flags);
4220}
4221
4222DEFUN (neighbor_attr_unchanged2,
4223 neighbor_attr_unchanged2_cmd,
9ccf14f7 4224 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged as-path <next-hop|med>",
718e3744 4225 NEIGHBOR_STR
4226 NEIGHBOR_ADDR_STR2
4227 "BGP attribute is propagated unchanged to this neighbor\n"
4228 "As-path attribute\n"
4229 "Nexthop attribute\n"
4230 "Med attribute\n")
4231{
c500ae40
DW
4232 int idx_peer = 1;
4233 int idx_attribute = 4;
718e3744 4234 u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
4235
c500ae40 4236 if (strncmp (argv[idx_attribute]->arg, "next-hop", 1) == 0)
718e3744 4237 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
c500ae40 4238 else if (strncmp (argv[idx_attribute]->arg, "med", 1) == 0)
718e3744 4239 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4240
c500ae40 4241 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4242 bgp_node_safi (vty), flags);
4243
4244}
4245
4246DEFUN (neighbor_attr_unchanged3,
4247 neighbor_attr_unchanged3_cmd,
9ccf14f7 4248 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged next-hop <as-path|med>",
718e3744 4249 NEIGHBOR_STR
4250 NEIGHBOR_ADDR_STR2
4251 "BGP attribute is propagated unchanged to this neighbor\n"
4252 "Nexthop attribute\n"
4253 "As-path attribute\n"
4254 "Med attribute\n")
4255{
c500ae40
DW
4256 int idx_peer = 1;
4257 int idx_attribute = 4;
718e3744 4258 u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
4259
c500ae40 4260 if (strncmp (argv[idx_attribute]->arg, "as-path", 1) == 0)
718e3744 4261 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
c500ae40 4262 else if (strncmp (argv[idx_attribute]->arg, "med", 1) == 0)
718e3744 4263 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4264
c500ae40 4265 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4266 bgp_node_safi (vty), flags);
4267}
4268
4269DEFUN (neighbor_attr_unchanged4,
4270 neighbor_attr_unchanged4_cmd,
9ccf14f7 4271 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged med <as-path|next-hop>",
718e3744 4272 NEIGHBOR_STR
4273 NEIGHBOR_ADDR_STR2
4274 "BGP attribute is propagated unchanged to this neighbor\n"
4275 "Med attribute\n"
4276 "As-path attribute\n"
4277 "Nexthop attribute\n")
4278{
c500ae40
DW
4279 int idx_peer = 1;
4280 int idx_attribute = 4;
718e3744 4281 u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
4282
c500ae40 4283 if (strncmp (argv[idx_attribute]->arg, "as-path", 1) == 0)
718e3744 4284 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
c500ae40 4285 else if (strncmp (argv[idx_attribute]->arg, "next-hop", 1) == 0)
718e3744 4286 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
4287
c500ae40 4288 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4289 bgp_node_safi (vty), flags);
4290}
4291
718e3744 4292
718e3744 4293
718e3744 4294
718e3744 4295
718e3744 4296
718e3744 4297
f412b39a
DW
4298/*
4299 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
3ce54f78 4300 * "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged next-hop med as-path",
f412b39a
DW
4301 * NO_STR
4302 * NEIGHBOR_STR
4303 * NEIGHBOR_ADDR_STR2
4304 * "BGP attribute is propagated unchanged to this neighbor\n"
4305 * "Nexthop attribute\n"
4306 * "Med attribute\n"
4307 * "As-path attribute\n"
4308 *
3ce54f78 4309 * "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged as-path med next-hop",
f412b39a
DW
4310 * NO_STR
4311 * NEIGHBOR_STR
4312 * NEIGHBOR_ADDR_STR2
4313 * "BGP attribute is propagated unchanged to this neighbor\n"
4314 * "As-path attribute\n"
4315 * "Med attribute\n"
4316 * "Nexthop attribute\n"
4317 *
3ce54f78 4318 * "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged med as-path next-hop",
f412b39a
DW
4319 * NO_STR
4320 * NEIGHBOR_STR
4321 * NEIGHBOR_ADDR_STR2
4322 * "BGP attribute is propagated unchanged to this neighbor\n"
4323 * "Med attribute\n"
4324 * "As-path attribute\n"
4325 * "Nexthop attribute\n"
4326 *
3ce54f78 4327 * "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged next-hop as-path med",
f412b39a
DW
4328 * NO_STR
4329 * NEIGHBOR_STR
4330 * NEIGHBOR_ADDR_STR2
4331 * "BGP attribute is propagated unchanged to this neighbor\n"
4332 * "Nexthop attribute\n"
4333 * "As-path attribute\n"
4334 * "Med attribute\n"
4335 *
3ce54f78 4336 * "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged as-path next-hop med",
f412b39a
DW
4337 * NO_STR
4338 * NEIGHBOR_STR
4339 * NEIGHBOR_ADDR_STR2
4340 * "BGP attribute is propagated unchanged to this neighbor\n"
4341 * "As-path attribute\n"
4342 * "Nexthop attribute\n"
4343 * "Med attribute\n"
4344 *
3ce54f78 4345 * "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged med next-hop as-path",
f412b39a
DW
4346 * NO_STR
4347 * NEIGHBOR_STR
4348 * NEIGHBOR_ADDR_STR2
4349 * "BGP attribute is propagated unchanged to this neighbor\n"
4350 * "Med attribute\n"
4351 * "Nexthop attribute\n"
4352 * "As-path attribute\n"
4353 *
4354 */
718e3744 4355DEFUN (no_neighbor_attr_unchanged,
4356 no_neighbor_attr_unchanged_cmd,
9ccf14f7 4357 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged",
718e3744 4358 NO_STR
4359 NEIGHBOR_STR
4360 NEIGHBOR_ADDR_STR2
4361 "BGP attribute is propagated unchanged to this neighbor\n")
4362{
c500ae40
DW
4363 int idx_peer = 2;
4364 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4365 bgp_node_safi (vty),
4366 (PEER_FLAG_AS_PATH_UNCHANGED |
4367 PEER_FLAG_NEXTHOP_UNCHANGED |
4368 PEER_FLAG_MED_UNCHANGED));
4369}
4370
4371DEFUN (no_neighbor_attr_unchanged1,
4372 no_neighbor_attr_unchanged1_cmd,
9ccf14f7 4373 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged <as-path|next-hop|med>",
718e3744 4374 NO_STR
4375 NEIGHBOR_STR
4376 NEIGHBOR_ADDR_STR2
4377 "BGP attribute is propagated unchanged to this neighbor\n"
4378 "As-path attribute\n"
4379 "Nexthop attribute\n"
4380 "Med attribute\n")
4381{
c500ae40
DW
4382 int idx_peer = 2;
4383 int idx_attribute = 4;
718e3744 4384 u_int16_t flags = 0;
4385
c500ae40 4386 if (strncmp (argv[idx_attribute]->arg, "as-path", 1) == 0)
718e3744 4387 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
c500ae40 4388 else if (strncmp (argv[idx_attribute]->arg, "next-hop", 1) == 0)
718e3744 4389 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
c500ae40 4390 else if (strncmp (argv[idx_attribute]->arg, "med", 1) == 0)
718e3744 4391 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4392
c500ae40 4393 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4394 bgp_node_safi (vty), flags);
4395}
4396
4397DEFUN (no_neighbor_attr_unchanged2,
4398 no_neighbor_attr_unchanged2_cmd,
9ccf14f7 4399 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged as-path <next-hop|med>",
718e3744 4400 NO_STR
4401 NEIGHBOR_STR
4402 NEIGHBOR_ADDR_STR2
4403 "BGP attribute is propagated unchanged to this neighbor\n"
4404 "As-path attribute\n"
4405 "Nexthop attribute\n"
4406 "Med attribute\n")
4407{
c500ae40
DW
4408 int idx_peer = 2;
4409 int idx_attribute = 5;
718e3744 4410 u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
4411
c500ae40 4412 if (strncmp (argv[idx_attribute]->arg, "next-hop", 1) == 0)
718e3744 4413 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
c500ae40 4414 else if (strncmp (argv[idx_attribute]->arg, "med", 1) == 0)
718e3744 4415 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4416
c500ae40 4417 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4418 bgp_node_safi (vty), flags);
4419}
4420
4421DEFUN (no_neighbor_attr_unchanged3,
4422 no_neighbor_attr_unchanged3_cmd,
9ccf14f7 4423 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged next-hop <as-path|med>",
718e3744 4424 NO_STR
4425 NEIGHBOR_STR
4426 NEIGHBOR_ADDR_STR2
4427 "BGP attribute is propagated unchanged to this neighbor\n"
4428 "Nexthop attribute\n"
4429 "As-path attribute\n"
4430 "Med attribute\n")
4431{
c500ae40
DW
4432 int idx_peer = 2;
4433 int idx_attribute = 5;
718e3744 4434 u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
4435
c500ae40 4436 if (strncmp (argv[idx_attribute]->arg, "as-path", 1) == 0)
718e3744 4437 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
c500ae40 4438 else if (strncmp (argv[idx_attribute]->arg, "med", 1) == 0)
718e3744 4439 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4440
c500ae40 4441 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4442 bgp_node_safi (vty), flags);
4443}
4444
4445DEFUN (no_neighbor_attr_unchanged4,
4446 no_neighbor_attr_unchanged4_cmd,
9ccf14f7 4447 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged med <as-path|next-hop>",
718e3744 4448 NO_STR
4449 NEIGHBOR_STR
4450 NEIGHBOR_ADDR_STR2
4451 "BGP attribute is propagated unchanged to this neighbor\n"
4452 "Med attribute\n"
4453 "As-path attribute\n"
4454 "Nexthop attribute\n")
4455{
c500ae40
DW
4456 int idx_peer = 2;
4457 int idx_attribute = 5;
718e3744 4458 u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
4459
c500ae40 4460 if (strncmp (argv[idx_attribute]->arg, "as-path", 1) == 0)
718e3744 4461 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
c500ae40 4462 else if (strncmp (argv[idx_attribute]->arg, "next-hop", 1) == 0)
718e3744 4463 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
4464
c500ae40 4465 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4466 bgp_node_safi (vty), flags);
4467}
4468
718e3744 4469
718e3744 4470
718e3744 4471
718e3744 4472
718e3744 4473
718e3744 4474
718e3744 4475/* EBGP multihop configuration. */
94f2b392 4476static int
fd79ac91 4477peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str,
4478 const char *ttl_str)
718e3744 4479{
4480 struct peer *peer;
fd79ac91 4481 unsigned int ttl;
718e3744 4482
4483 peer = peer_and_group_lookup_vty (vty, ip_str);
4484 if (! peer)
4485 return CMD_WARNING;
4486
63fa10b5
QY
4487 if (peer->conf_if)
4488 return bgp_vty_return (vty, BGP_ERR_INVALID_FOR_DIRECT_PEER);
4489
718e3744 4490 if (! ttl_str)
9b1be336 4491 ttl = MAXTTL;
718e3744 4492 else
9b1be336 4493 VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, MAXTTL);
718e3744 4494
89b6d1f8 4495 return bgp_vty_return (vty, peer_ebgp_multihop_set (peer, ttl));
718e3744 4496}
4497
94f2b392 4498static int
fd79ac91 4499peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str)
718e3744 4500{
4501 struct peer *peer;
4502
4503 peer = peer_and_group_lookup_vty (vty, ip_str);
4504 if (! peer)
4505 return CMD_WARNING;
4506
89b6d1f8 4507 return bgp_vty_return (vty, peer_ebgp_multihop_unset (peer));
718e3744 4508}
4509
4510/* neighbor ebgp-multihop. */
4511DEFUN (neighbor_ebgp_multihop,
4512 neighbor_ebgp_multihop_cmd,
9ccf14f7 4513 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
718e3744 4514 NEIGHBOR_STR
4515 NEIGHBOR_ADDR_STR2
4516 "Allow EBGP neighbors not on directly connected networks\n")
4517{
c500ae40
DW
4518 int idx_peer = 1;
4519 return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, NULL);
718e3744 4520}
4521
4522DEFUN (neighbor_ebgp_multihop_ttl,
4523 neighbor_ebgp_multihop_ttl_cmd,
9ccf14f7 4524 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
718e3744 4525 NEIGHBOR_STR
4526 NEIGHBOR_ADDR_STR2
4527 "Allow EBGP neighbors not on directly connected networks\n"
4528 "maximum hop count\n")
4529{
c500ae40
DW
4530 int idx_peer = 1;
4531 int idx_number = 3;
4532 return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg);
718e3744 4533}
4534
f412b39a
DW
4535/*
4536 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
3ce54f78 4537 * "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
f412b39a
DW
4538 * NO_STR
4539 * NEIGHBOR_STR
4540 * NEIGHBOR_ADDR_STR2
4541 * "Allow EBGP neighbors not on directly connected networks\n"
4542 * "maximum hop count\n"
4543 *
4544 */
718e3744 4545DEFUN (no_neighbor_ebgp_multihop,
4546 no_neighbor_ebgp_multihop_cmd,
9ccf14f7 4547 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
718e3744 4548 NO_STR
4549 NEIGHBOR_STR
4550 NEIGHBOR_ADDR_STR2
4551 "Allow EBGP neighbors not on directly connected networks\n")
4552{
c500ae40
DW
4553 int idx_peer = 2;
4554 return peer_ebgp_multihop_unset_vty (vty, argv[idx_peer]->arg);
718e3744 4555}
4556
6b0655a2 4557
6ffd2079 4558/* disable-connected-check */
f412b39a
DW
4559/*
4560 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
3ce54f78 4561 * "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-multihop",
f412b39a
DW
4562 * NEIGHBOR_STR
4563 * NEIGHBOR_ADDR_STR2
4564 * "Enforce EBGP neighbors perform multihop\n"
4565 *
4566 */
6ffd2079 4567DEFUN (neighbor_disable_connected_check,
4568 neighbor_disable_connected_check_cmd,
9ccf14f7 4569 "neighbor <A.B.C.D|X:X::X:X|WORD> disable-connected-check",
6ffd2079 4570 NEIGHBOR_STR
4571 NEIGHBOR_ADDR_STR2
4572 "one-hop away EBGP peer using loopback address\n")
4573{
c500ae40
DW
4574 int idx_peer = 1;
4575 return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK);
6ffd2079 4576}
4577
f412b39a
DW
4578/*
4579 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
3ce54f78 4580 * "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-multihop",
f412b39a
DW
4581 * NO_STR
4582 * NEIGHBOR_STR
4583 * NEIGHBOR_ADDR_STR2
4584 * "Enforce EBGP neighbors perform multihop\n"
4585 *
4586 */
6ffd2079 4587DEFUN (no_neighbor_disable_connected_check,
4588 no_neighbor_disable_connected_check_cmd,
9ccf14f7 4589 "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-connected-check",
6ffd2079 4590 NO_STR
4591 NEIGHBOR_STR
4592 NEIGHBOR_ADDR_STR2
4593 "one-hop away EBGP peer using loopback address\n")
4594{
c500ae40
DW
4595 int idx_peer = 2;
4596 return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK);
6ffd2079 4597}
4598
718e3744 4599/* Enforce multihop. */
718e3744 4600
6ffd2079 4601/* Enforce multihop. */
6b0655a2 4602
718e3744 4603DEFUN (neighbor_description,
4604 neighbor_description_cmd,
9ccf14f7 4605 "neighbor <A.B.C.D|X:X::X:X|WORD> description .LINE",
718e3744 4606 NEIGHBOR_STR
4607 NEIGHBOR_ADDR_STR2
4608 "Neighbor specific description\n"
4609 "Up to 80 characters describing this neighbor\n")
4610{
c500ae40 4611 int idx_peer = 1;
718e3744 4612 struct peer *peer;
718e3744 4613 char *str;
718e3744 4614
c500ae40 4615 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
718e3744 4616 if (! peer)
4617 return CMD_WARNING;
4618
4619 if (argc == 1)
4620 return CMD_SUCCESS;
4621
3b8b1855 4622 str = argv_concat(argv, argc, 1);
718e3744 4623
4624 peer_description_set (peer, str);
4625
3b8b1855 4626 XFREE (MTYPE_TMP, str);
718e3744 4627
4628 return CMD_SUCCESS;
4629}
4630
f412b39a
DW
4631/*
4632 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
3ce54f78 4633 * "no neighbor <A.B.C.D|X:X::X:X|WORD> description .LINE",
f412b39a
DW
4634 * NO_STR
4635 * NEIGHBOR_STR
4636 * NEIGHBOR_ADDR_STR2
4637 * "Neighbor specific description\n"
4638 * "Up to 80 characters describing this neighbor\n"
4639 *
4640 */
718e3744 4641DEFUN (no_neighbor_description,
4642 no_neighbor_description_cmd,
9ccf14f7 4643 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
718e3744 4644 NO_STR
4645 NEIGHBOR_STR
4646 NEIGHBOR_ADDR_STR2
4647 "Neighbor specific description\n")
4648{
c500ae40 4649 int idx_peer = 2;
718e3744 4650 struct peer *peer;
4651
c500ae40 4652 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
718e3744 4653 if (! peer)
4654 return CMD_WARNING;
4655
4656 peer_description_unset (peer);
4657
4658 return CMD_SUCCESS;
4659}
4660
6b0655a2 4661
718e3744 4662/* Neighbor update-source. */
94f2b392 4663static int
fd79ac91 4664peer_update_source_vty (struct vty *vty, const char *peer_str,
4665 const char *source_str)
718e3744 4666{
4667 struct peer *peer;
718e3744 4668
4669 peer = peer_and_group_lookup_vty (vty, peer_str);
4670 if (! peer)
4671 return CMD_WARNING;
4672
a80beece
DS
4673 if (peer->conf_if)
4674 return CMD_WARNING;
4675
718e3744 4676 if (source_str)
4677 {
c63b83fe
JBD
4678 union sockunion su;
4679 int ret = str2sockunion (source_str, &su);
4680
4681 if (ret == 0)
4682 peer_update_source_addr_set (peer, &su);
718e3744 4683 else
4684 peer_update_source_if_set (peer, source_str);
4685 }
4686 else
4687 peer_update_source_unset (peer);
4688
4689 return CMD_SUCCESS;
4690}
4691
369688c0
PJ
4692#define BGP_UPDATE_SOURCE_HELP_STR \
4693 "IPv4 address\n" \
9a1a331d
PJ
4694 "IPv6 address\n" \
4695 "Interface name (requires zebra to be running)\n"
369688c0 4696
718e3744 4697DEFUN (neighbor_update_source,
4698 neighbor_update_source_cmd,
9ccf14f7 4699 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
718e3744 4700 NEIGHBOR_STR
4701 NEIGHBOR_ADDR_STR2
4702 "Source of routing updates\n"
369688c0 4703 BGP_UPDATE_SOURCE_HELP_STR)
718e3744 4704{
c500ae40
DW
4705 int idx_peer = 1;
4706 int idx_peer_2 = 3;
4707 return peer_update_source_vty (vty, argv[idx_peer]->arg, argv[idx_peer_2]->arg);
718e3744 4708}
4709
4710DEFUN (no_neighbor_update_source,
4711 no_neighbor_update_source_cmd,
9ccf14f7 4712 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [A.B.C.D|X:X::X:X|WORD]",
718e3744 4713 NO_STR
4714 NEIGHBOR_STR
4715 NEIGHBOR_ADDR_STR2
dcb52bd5
DS
4716 "Source of routing updates\n"
4717 BGP_UPDATE_SOURCE_HELP_STR)
718e3744 4718{
c500ae40
DW
4719 int idx_peer = 2;
4720 return peer_update_source_vty (vty, argv[idx_peer]->arg, NULL);
718e3744 4721}
6b0655a2 4722
94f2b392 4723static int
fd79ac91 4724peer_default_originate_set_vty (struct vty *vty, const char *peer_str,
4725 afi_t afi, safi_t safi,
4726 const char *rmap, int set)
718e3744 4727{
4728 int ret;
4729 struct peer *peer;
4730
4731 peer = peer_and_group_lookup_vty (vty, peer_str);
4732 if (! peer)
4733 return CMD_WARNING;
4734
4735 if (set)
4736 ret = peer_default_originate_set (peer, afi, safi, rmap);
4737 else
4738 ret = peer_default_originate_unset (peer, afi, safi);
4739
4740 return bgp_vty_return (vty, ret);
4741}
4742
4743/* neighbor default-originate. */
4744DEFUN (neighbor_default_originate,
4745 neighbor_default_originate_cmd,
9ccf14f7 4746 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
718e3744 4747 NEIGHBOR_STR
4748 NEIGHBOR_ADDR_STR2
4749 "Originate default route to this neighbor\n")
4750{
c500ae40
DW
4751 int idx_peer = 1;
4752 return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4753 bgp_node_safi (vty), NULL, 1);
4754}
4755
4756DEFUN (neighbor_default_originate_rmap,
4757 neighbor_default_originate_rmap_cmd,
9ccf14f7 4758 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
718e3744 4759 NEIGHBOR_STR
4760 NEIGHBOR_ADDR_STR2
4761 "Originate default route to this neighbor\n"
4762 "Route-map to specify criteria to originate default\n"
4763 "route-map name\n")
4764{
c500ae40
DW
4765 int idx_peer = 1;
4766 int idx_word = 4;
4767 return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
4768 bgp_node_safi (vty), argv[idx_word]->arg, 1);
718e3744 4769}
4770
f412b39a
DW
4771/*
4772 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
3ce54f78 4773 * "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
f412b39a
DW
4774 * NO_STR
4775 * NEIGHBOR_STR
4776 * NEIGHBOR_ADDR_STR2
4777 * "Originate default route to this neighbor\n"
4778 * "Route-map to specify criteria to originate default\n"
4779 * "route-map name\n"
4780 *
4781 */
718e3744 4782DEFUN (no_neighbor_default_originate,
4783 no_neighbor_default_originate_cmd,
9ccf14f7 4784 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
718e3744 4785 NO_STR
4786 NEIGHBOR_STR
4787 NEIGHBOR_ADDR_STR2
4788 "Originate default route to this neighbor\n")
4789{
c500ae40
DW
4790 int idx_peer = 2;
4791 return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4792 bgp_node_safi (vty), NULL, 0);
4793}
4794
6b0655a2 4795
718e3744 4796/* Set neighbor's BGP port. */
94f2b392 4797static int
fd79ac91 4798peer_port_vty (struct vty *vty, const char *ip_str, int afi,
4799 const char *port_str)
718e3744 4800{
4801 struct peer *peer;
4802 u_int16_t port;
4803 struct servent *sp;
4804
4805 peer = peer_lookup_vty (vty, ip_str);
4806 if (! peer)
4807 return CMD_WARNING;
4808
4809 if (! port_str)
4810 {
4811 sp = getservbyname ("bgp", "tcp");
4812 port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port);
4813 }
4814 else
4815 {
4816 VTY_GET_INTEGER("port", port, port_str);
4817 }
4818
4819 peer_port_set (peer, port);
4820
4821 return CMD_SUCCESS;
4822}
4823
f418446b 4824/* Set specified peer's BGP port. */
718e3744 4825DEFUN (neighbor_port,
4826 neighbor_port_cmd,
9ccf14f7 4827 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
718e3744 4828 NEIGHBOR_STR
4829 NEIGHBOR_ADDR_STR
4830 "Neighbor's BGP port\n"
4831 "TCP port number\n")
4832{
c500ae40
DW
4833 int idx_ip = 1;
4834 int idx_number = 3;
4835 return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, argv[idx_number]->arg);
718e3744 4836}
4837
4838DEFUN (no_neighbor_port,
4839 no_neighbor_port_cmd,
9ccf14f7 4840 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
718e3744 4841 NO_STR
4842 NEIGHBOR_STR
4843 NEIGHBOR_ADDR_STR
8334fd5a
DW
4844 "Neighbor's BGP port\n"
4845 "TCP port number\n")
718e3744 4846{
c500ae40
DW
4847 int idx_ip = 2;
4848 return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, NULL);
718e3744 4849}
4850
6b0655a2 4851
718e3744 4852/* neighbor weight. */
94f2b392 4853static int
fd79ac91 4854peer_weight_set_vty (struct vty *vty, const char *ip_str,
4855 const char *weight_str)
718e3744 4856{
1f9a9fff 4857 int ret;
718e3744 4858 struct peer *peer;
4859 unsigned long weight;
4860
4861 peer = peer_and_group_lookup_vty (vty, ip_str);
4862 if (! peer)
4863 return CMD_WARNING;
4864
4865 VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535);
4866
1f9a9fff
PJ
4867 ret = peer_weight_set (peer, weight);
4868 return bgp_vty_return (vty, ret);
718e3744 4869}
4870
94f2b392 4871static int
fd79ac91 4872peer_weight_unset_vty (struct vty *vty, const char *ip_str)
718e3744 4873{
1f9a9fff 4874 int ret;
718e3744 4875 struct peer *peer;
4876
4877 peer = peer_and_group_lookup_vty (vty, ip_str);
4878 if (! peer)
4879 return CMD_WARNING;
4880
1f9a9fff
PJ
4881 ret = peer_weight_unset (peer);
4882 return bgp_vty_return (vty, ret);
718e3744 4883}
4884
4885DEFUN (neighbor_weight,
4886 neighbor_weight_cmd,
9ccf14f7 4887 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
718e3744 4888 NEIGHBOR_STR
4889 NEIGHBOR_ADDR_STR2
4890 "Set default weight for routes from this neighbor\n"
4891 "default weight\n")
4892{
c500ae40
DW
4893 int idx_peer = 1;
4894 int idx_number = 3;
4895 return peer_weight_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg);
718e3744 4896}
4897
4898DEFUN (no_neighbor_weight,
4899 no_neighbor_weight_cmd,
9ccf14f7 4900 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
718e3744 4901 NO_STR
4902 NEIGHBOR_STR
4903 NEIGHBOR_ADDR_STR2
8334fd5a
DW
4904 "Set default weight for routes from this neighbor\n"
4905 "default weight\n")
718e3744 4906{
c500ae40
DW
4907 int idx_peer = 2;
4908 return peer_weight_unset_vty (vty, argv[idx_peer]->arg);
718e3744 4909}
4910
6b0655a2 4911
718e3744 4912/* Override capability negotiation. */
4913DEFUN (neighbor_override_capability,
4914 neighbor_override_capability_cmd,
9ccf14f7 4915 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
718e3744 4916 NEIGHBOR_STR
4917 NEIGHBOR_ADDR_STR2
4918 "Override capability negotiation result\n")
4919{
c500ae40
DW
4920 int idx_peer = 1;
4921 return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY);
718e3744 4922}
4923
4924DEFUN (no_neighbor_override_capability,
4925 no_neighbor_override_capability_cmd,
9ccf14f7 4926 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
718e3744 4927 NO_STR
4928 NEIGHBOR_STR
4929 NEIGHBOR_ADDR_STR2
4930 "Override capability negotiation result\n")
4931{
c500ae40
DW
4932 int idx_peer = 2;
4933 return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY);
718e3744 4934}
6b0655a2 4935
718e3744 4936DEFUN (neighbor_strict_capability,
4937 neighbor_strict_capability_cmd,
9ccf14f7 4938 "neighbor <A.B.C.D|X:X::X:X> strict-capability-match",
718e3744 4939 NEIGHBOR_STR
4940 NEIGHBOR_ADDR_STR
4941 "Strict capability negotiation match\n")
4942{
c500ae40
DW
4943 int idx_ip = 1;
4944 return peer_flag_set_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH);
718e3744 4945}
4946
4947DEFUN (no_neighbor_strict_capability,
4948 no_neighbor_strict_capability_cmd,
9ccf14f7 4949 "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match",
718e3744 4950 NO_STR
4951 NEIGHBOR_STR
4952 NEIGHBOR_ADDR_STR
4953 "Strict capability negotiation match\n")
4954{
c500ae40
DW
4955 int idx_ip = 2;
4956 return peer_flag_unset_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH);
718e3744 4957}
6b0655a2 4958
94f2b392 4959static int
fd79ac91 4960peer_timers_set_vty (struct vty *vty, const char *ip_str,
4961 const char *keep_str, const char *hold_str)
718e3744 4962{
4963 int ret;
4964 struct peer *peer;
4965 u_int32_t keepalive;
4966 u_int32_t holdtime;
4967
4968 peer = peer_and_group_lookup_vty (vty, ip_str);
4969 if (! peer)
4970 return CMD_WARNING;
4971
4972 VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535);
4973 VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535);
4974
4975 ret = peer_timers_set (peer, keepalive, holdtime);
4976
4977 return bgp_vty_return (vty, ret);
4978}
6b0655a2 4979
94f2b392 4980static int
fd79ac91 4981peer_timers_unset_vty (struct vty *vty, const char *ip_str)
718e3744 4982{
4983 int ret;
4984 struct peer *peer;
4985
0c412461 4986 peer = peer_and_group_lookup_vty (vty, ip_str);
718e3744 4987 if (! peer)
4988 return CMD_WARNING;
4989
4990 ret = peer_timers_unset (peer);
4991
4992 return bgp_vty_return (vty, ret);
4993}
4994
4995DEFUN (neighbor_timers,
4996 neighbor_timers_cmd,
9ccf14f7 4997 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
718e3744 4998 NEIGHBOR_STR
4999 NEIGHBOR_ADDR_STR2
5000 "BGP per neighbor timers\n"
5001 "Keepalive interval\n"
5002 "Holdtime\n")
5003{
c500ae40
DW
5004 int idx_peer = 1;
5005 int idx_number = 3;
5006 int idx_number_2 = 4;
5007 return peer_timers_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg);
718e3744 5008}
5009
5010DEFUN (no_neighbor_timers,
5011 no_neighbor_timers_cmd,
9ccf14f7 5012 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
718e3744 5013 NO_STR
5014 NEIGHBOR_STR
5015 NEIGHBOR_ADDR_STR2
8334fd5a
DW
5016 "BGP per neighbor timers\n"
5017 "Keepalive interval\n"
5018 "Holdtime\n")
718e3744 5019{
c500ae40
DW
5020 int idx_peer = 2;
5021 return peer_timers_unset_vty (vty, argv[idx_peer]->arg);
718e3744 5022}
6b0655a2 5023
813d4307 5024
94f2b392 5025static int
fd79ac91 5026peer_timers_connect_set_vty (struct vty *vty, const char *ip_str,
5027 const char *time_str)
718e3744 5028{
5029 int ret;
5030 struct peer *peer;
5031 u_int32_t connect;
5032
966f821c 5033 peer = peer_and_group_lookup_vty (vty, ip_str);
718e3744 5034 if (! peer)
5035 return CMD_WARNING;
5036
5037 VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535);
5038
5039 ret = peer_timers_connect_set (peer, connect);
5040
966f821c 5041 return bgp_vty_return (vty, ret);
718e3744 5042}
5043
94f2b392 5044static int
fd79ac91 5045peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str)
718e3744 5046{
5047 int ret;
5048 struct peer *peer;
5049
5050 peer = peer_and_group_lookup_vty (vty, ip_str);
5051 if (! peer)
5052 return CMD_WARNING;
5053
5054 ret = peer_timers_connect_unset (peer);
5055
966f821c 5056 return bgp_vty_return (vty, ret);
718e3744 5057}
5058
5059DEFUN (neighbor_timers_connect,
5060 neighbor_timers_connect_cmd,
9ccf14f7 5061 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
718e3744 5062 NEIGHBOR_STR
966f821c 5063 NEIGHBOR_ADDR_STR2
718e3744 5064 "BGP per neighbor timers\n"
5065 "BGP connect timer\n"
5066 "Connect timer\n")
5067{
c500ae40
DW
5068 int idx_peer = 1;
5069 int idx_number = 4;
5070 return peer_timers_connect_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg);
718e3744 5071}
5072
5073DEFUN (no_neighbor_timers_connect,
5074 no_neighbor_timers_connect_cmd,
9ccf14f7 5075 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
718e3744 5076 NO_STR
5077 NEIGHBOR_STR
966f821c 5078 NEIGHBOR_ADDR_STR2
718e3744 5079 "BGP per neighbor timers\n"
8334fd5a
DW
5080 "BGP connect timer\n"
5081 "Connect timer\n")
718e3744 5082{
c500ae40
DW
5083 int idx_peer = 2;
5084 return peer_timers_connect_unset_vty (vty, argv[idx_peer]->arg);
718e3744 5085}
5086
6b0655a2 5087
94f2b392 5088static int
fd79ac91 5089peer_advertise_interval_vty (struct vty *vty, const char *ip_str,
5090 const char *time_str, int set)
718e3744 5091{
5092 int ret;
5093 struct peer *peer;
5094 u_int32_t routeadv = 0;
5095
966f821c 5096 peer = peer_and_group_lookup_vty (vty, ip_str);
718e3744 5097 if (! peer)
5098 return CMD_WARNING;
5099
5100 if (time_str)
5101 VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600);
5102
5103 if (set)
5104 ret = peer_advertise_interval_set (peer, routeadv);
5105 else
5106 ret = peer_advertise_interval_unset (peer);
5107
966f821c 5108 return bgp_vty_return (vty, ret);
718e3744 5109}
5110
5111DEFUN (neighbor_advertise_interval,
5112 neighbor_advertise_interval_cmd,
9ccf14f7 5113 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
718e3744 5114 NEIGHBOR_STR
966f821c 5115 NEIGHBOR_ADDR_STR2
718e3744 5116 "Minimum interval between sending BGP routing updates\n"
5117 "time in seconds\n")
5118{
c500ae40
DW
5119 int idx_peer = 1;
5120 int idx_number = 3;
5121 return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, 1);
718e3744 5122}
5123
5124DEFUN (no_neighbor_advertise_interval,
5125 no_neighbor_advertise_interval_cmd,
9ccf14f7 5126 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
718e3744 5127 NO_STR
5128 NEIGHBOR_STR
966f821c 5129 NEIGHBOR_ADDR_STR2
8334fd5a
DW
5130 "Minimum interval between sending BGP routing updates\n"
5131 "time in seconds\n")
718e3744 5132{
c500ae40
DW
5133 int idx_peer = 2;
5134 return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, NULL, 0);
718e3744 5135}
5136
6b0655a2 5137
518f0eb1
DS
5138/* Time to wait before processing route-map updates */
5139DEFUN (bgp_set_route_map_delay_timer,
5140 bgp_set_route_map_delay_timer_cmd,
6147e2c6 5141 "bgp route-map delay-timer (0-600)",
518f0eb1
DS
5142 SET_STR
5143 "BGP route-map delay timer\n"
5144 "Time in secs to wait before processing route-map changes\n"
f414725f 5145 "0 disables the timer, no route updates happen when route-maps change\n")
518f0eb1 5146{
c500ae40 5147 int idx_number = 3;
518f0eb1 5148 u_int32_t rmap_delay_timer;
518f0eb1 5149
c500ae40 5150 if (argv[idx_number]->arg)
518f0eb1 5151 {
c500ae40 5152 VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[idx_number]->arg, 0, 600);
5fe9f963 5153 bm->rmap_update_timer = rmap_delay_timer;
518f0eb1
DS
5154
5155 /* if the dynamic update handling is being disabled, and a timer is
5156 * running, stop the timer and act as if the timer has already fired.
5157 */
5fe9f963 5158 if (!rmap_delay_timer && bm->t_rmap_update )
518f0eb1 5159 {
5fe9f963 5160 BGP_TIMER_OFF(bm->t_rmap_update);
5161 thread_execute (bm->master, bgp_route_map_update_timer, NULL, 0);
518f0eb1
DS
5162 }
5163 return CMD_SUCCESS;
5164 }
5165 else
ffd0c037 5166 return CMD_WARNING;
518f0eb1
DS
5167}
5168
5169DEFUN (no_bgp_set_route_map_delay_timer,
5170 no_bgp_set_route_map_delay_timer_cmd,
8334fd5a 5171 "no bgp route-map delay-timer [(0-600)]",
518f0eb1
DS
5172 NO_STR
5173 "Default BGP route-map delay timer\n"
8334fd5a
DW
5174 "Reset to default time to wait for processing route-map changes\n"
5175 "0 disables the timer, no route updates happen when route-maps change\n")
518f0eb1 5176{
518f0eb1 5177
5fe9f963 5178 bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER;
518f0eb1
DS
5179
5180 return CMD_SUCCESS;
5181}
5182
f414725f 5183
718e3744 5184/* neighbor interface */
94f2b392 5185static int
fd79ac91 5186peer_interface_vty (struct vty *vty, const char *ip_str, const char *str)
718e3744 5187{
718e3744 5188 struct peer *peer;
5189
5190 peer = peer_lookup_vty (vty, ip_str);
a80beece 5191 if (! peer || peer->conf_if)
718e3744 5192 return CMD_WARNING;
5193
5194 if (str)
ffd0c037 5195 peer_interface_set (peer, str);
718e3744 5196 else
ffd0c037 5197 peer_interface_unset (peer);
718e3744 5198
5199 return CMD_SUCCESS;
5200}
5201
5202DEFUN (neighbor_interface,
5203 neighbor_interface_cmd,
9ccf14f7 5204 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
718e3744 5205 NEIGHBOR_STR
5206 NEIGHBOR_ADDR_STR
5207 "Interface\n"
5208 "Interface name\n")
5209{
c500ae40
DW
5210 int idx_ip = 1;
5211 int idx_word = 3;
8ffedcea 5212 if (argc == 3)
c500ae40 5213 return peer_interface_vty (vty, argv[idx_ip]->arg, argv[idx_word]->arg);
8ffedcea 5214 else
c500ae40 5215 return peer_interface_vty (vty, argv[idx_ip]->arg, argv[idx_word]->arg);
718e3744 5216}
5217
5218DEFUN (no_neighbor_interface,
5219 no_neighbor_interface_cmd,
9ccf14f7 5220 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
718e3744 5221 NO_STR
5222 NEIGHBOR_STR
5223 NEIGHBOR_ADDR_STR
5224 "Interface\n"
5225 "Interface name\n")
5226{
c500ae40
DW
5227 int idx_peer = 2;
5228 return peer_interface_vty (vty, argv[idx_peer]->arg, NULL);
718e3744 5229}
6b0655a2 5230
718e3744 5231/* Set distribute list to the peer. */
94f2b392 5232static int
fd79ac91 5233peer_distribute_set_vty (struct vty *vty, const char *ip_str,
5234 afi_t afi, safi_t safi,
5235 const char *name_str, const char *direct_str)
718e3744 5236{
5237 int ret;
5238 struct peer *peer;
5239 int direct = FILTER_IN;
5240
5241 peer = peer_and_group_lookup_vty (vty, ip_str);
5242 if (! peer)
5243 return CMD_WARNING;
5244
5245 /* Check filter direction. */
5246 if (strncmp (direct_str, "i", 1) == 0)
5247 direct = FILTER_IN;
5248 else if (strncmp (direct_str, "o", 1) == 0)
5249 direct = FILTER_OUT;
5250
5251 ret = peer_distribute_set (peer, afi, safi, direct, name_str);
5252
5253 return bgp_vty_return (vty, ret);
5254}
5255
94f2b392 5256static int
fd79ac91 5257peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5258 safi_t safi, const char *direct_str)
718e3744 5259{
5260 int ret;
5261 struct peer *peer;
5262 int direct = FILTER_IN;
5263
5264 peer = peer_and_group_lookup_vty (vty, ip_str);
5265 if (! peer)
5266 return CMD_WARNING;
5267
5268 /* Check filter direction. */
5269 if (strncmp (direct_str, "i", 1) == 0)
5270 direct = FILTER_IN;
5271 else if (strncmp (direct_str, "o", 1) == 0)
5272 direct = FILTER_OUT;
5273
5274 ret = peer_distribute_unset (peer, afi, safi, direct);
5275
5276 return bgp_vty_return (vty, ret);
5277}
5278
5279DEFUN (neighbor_distribute_list,
5280 neighbor_distribute_list_cmd,
9ccf14f7 5281 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
718e3744 5282 NEIGHBOR_STR
5283 NEIGHBOR_ADDR_STR2
5284 "Filter updates to/from this neighbor\n"
5285 "IP access-list number\n"
5286 "IP access-list number (expanded range)\n"
5287 "IP Access-list name\n"
5288 "Filter incoming updates\n"
5289 "Filter outgoing updates\n")
5290{
c500ae40
DW
5291 int idx_peer = 1;
5292 int idx_acl = 3;
5293 int idx_in_out = 4;
5294 return peer_distribute_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5295 bgp_node_safi (vty), argv[idx_acl]->arg, argv[idx_in_out]->arg);
718e3744 5296}
5297
5298DEFUN (no_neighbor_distribute_list,
5299 no_neighbor_distribute_list_cmd,
9ccf14f7 5300 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
718e3744 5301 NO_STR
5302 NEIGHBOR_STR
5303 NEIGHBOR_ADDR_STR2
5304 "Filter updates to/from this neighbor\n"
5305 "IP access-list number\n"
5306 "IP access-list number (expanded range)\n"
5307 "IP Access-list name\n"
5308 "Filter incoming updates\n"
5309 "Filter outgoing updates\n")
5310{
c500ae40
DW
5311 int idx_peer = 2;
5312 int idx_in_out = 5;
5313 return peer_distribute_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5314 bgp_node_safi (vty), argv[idx_in_out]->arg);
718e3744 5315}
6b0655a2 5316
718e3744 5317/* Set prefix list to the peer. */
94f2b392 5318static int
fd79ac91 5319peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
5320 safi_t safi, const char *name_str,
5321 const char *direct_str)
718e3744 5322{
5323 int ret;
5324 struct peer *peer;
5325 int direct = FILTER_IN;
5326
5327 peer = peer_and_group_lookup_vty (vty, ip_str);
5328 if (! peer)
5329 return CMD_WARNING;
5330
5331 /* Check filter direction. */
5332 if (strncmp (direct_str, "i", 1) == 0)
5333 direct = FILTER_IN;
5334 else if (strncmp (direct_str, "o", 1) == 0)
5335 direct = FILTER_OUT;
5336
5337 ret = peer_prefix_list_set (peer, afi, safi, direct, name_str);
5338
5339 return bgp_vty_return (vty, ret);
5340}
5341
94f2b392 5342static int
fd79ac91 5343peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5344 safi_t safi, const char *direct_str)
718e3744 5345{
5346 int ret;
5347 struct peer *peer;
5348 int direct = FILTER_IN;
5349
5350 peer = peer_and_group_lookup_vty (vty, ip_str);
5351 if (! peer)
5352 return CMD_WARNING;
5353
5354 /* Check filter direction. */
5355 if (strncmp (direct_str, "i", 1) == 0)
5356 direct = FILTER_IN;
5357 else if (strncmp (direct_str, "o", 1) == 0)
5358 direct = FILTER_OUT;
5359
5360 ret = peer_prefix_list_unset (peer, afi, safi, direct);
5361
5362 return bgp_vty_return (vty, ret);
5363}
5364
5365DEFUN (neighbor_prefix_list,
5366 neighbor_prefix_list_cmd,
9ccf14f7 5367 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
718e3744 5368 NEIGHBOR_STR
5369 NEIGHBOR_ADDR_STR2
5370 "Filter updates to/from this neighbor\n"
5371 "Name of a prefix list\n"
5372 "Filter incoming updates\n"
5373 "Filter outgoing updates\n")
5374{
c500ae40
DW
5375 int idx_peer = 1;
5376 int idx_word = 3;
5377 int idx_in_out = 4;
5378 return peer_prefix_list_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5379 bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg);
718e3744 5380}
5381
5382DEFUN (no_neighbor_prefix_list,
5383 no_neighbor_prefix_list_cmd,
9ccf14f7 5384 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
718e3744 5385 NO_STR
5386 NEIGHBOR_STR
5387 NEIGHBOR_ADDR_STR2
5388 "Filter updates to/from this neighbor\n"
5389 "Name of a prefix list\n"
5390 "Filter incoming updates\n"
5391 "Filter outgoing updates\n")
5392{
c500ae40
DW
5393 int idx_peer = 2;
5394 int idx_in_out = 5;
5395 return peer_prefix_list_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5396 bgp_node_safi (vty), argv[idx_in_out]->arg);
718e3744 5397}
6b0655a2 5398
94f2b392 5399static int
fd79ac91 5400peer_aslist_set_vty (struct vty *vty, const char *ip_str,
5401 afi_t afi, safi_t safi,
5402 const char *name_str, const char *direct_str)
718e3744 5403{
5404 int ret;
5405 struct peer *peer;
5406 int direct = FILTER_IN;
5407
5408 peer = peer_and_group_lookup_vty (vty, ip_str);
5409 if (! peer)
5410 return CMD_WARNING;
5411
5412 /* Check filter direction. */
5413 if (strncmp (direct_str, "i", 1) == 0)
5414 direct = FILTER_IN;
5415 else if (strncmp (direct_str, "o", 1) == 0)
5416 direct = FILTER_OUT;
5417
5418 ret = peer_aslist_set (peer, afi, safi, direct, name_str);
5419
5420 return bgp_vty_return (vty, ret);
5421}
5422
94f2b392 5423static int
fd79ac91 5424peer_aslist_unset_vty (struct vty *vty, const char *ip_str,
5425 afi_t afi, safi_t safi,
5426 const char *direct_str)
718e3744 5427{
5428 int ret;
5429 struct peer *peer;
5430 int direct = FILTER_IN;
5431
5432 peer = peer_and_group_lookup_vty (vty, ip_str);
5433 if (! peer)
5434 return CMD_WARNING;
5435
5436 /* Check filter direction. */
5437 if (strncmp (direct_str, "i", 1) == 0)
5438 direct = FILTER_IN;
5439 else if (strncmp (direct_str, "o", 1) == 0)
5440 direct = FILTER_OUT;
5441
5442 ret = peer_aslist_unset (peer, afi, safi, direct);
5443
5444 return bgp_vty_return (vty, ret);
5445}
5446
5447DEFUN (neighbor_filter_list,
5448 neighbor_filter_list_cmd,
9ccf14f7 5449 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
718e3744 5450 NEIGHBOR_STR
5451 NEIGHBOR_ADDR_STR2
5452 "Establish BGP filters\n"
5453 "AS path access-list name\n"
5454 "Filter incoming routes\n"
5455 "Filter outgoing routes\n")
5456{
c500ae40
DW
5457 int idx_peer = 1;
5458 int idx_word = 3;
5459 int idx_in_out = 4;
5460 return peer_aslist_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5461 bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg);
718e3744 5462}
5463
5464DEFUN (no_neighbor_filter_list,
5465 no_neighbor_filter_list_cmd,
9ccf14f7 5466 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
718e3744 5467 NO_STR
5468 NEIGHBOR_STR
5469 NEIGHBOR_ADDR_STR2
5470 "Establish BGP filters\n"
5471 "AS path access-list name\n"
5472 "Filter incoming routes\n"
5473 "Filter outgoing routes\n")
5474{
c500ae40
DW
5475 int idx_peer = 2;
5476 int idx_in_out = 5;
5477 return peer_aslist_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5478 bgp_node_safi (vty), argv[idx_in_out]->arg);
718e3744 5479}
6b0655a2 5480
718e3744 5481/* Set route-map to the peer. */
94f2b392 5482static int
fd79ac91 5483peer_route_map_set_vty (struct vty *vty, const char *ip_str,
5484 afi_t afi, safi_t safi,
5485 const char *name_str, const char *direct_str)
718e3744 5486{
5487 int ret;
5488 struct peer *peer;
fee0f4c6 5489 int direct = RMAP_IN;
718e3744 5490
5491 peer = peer_and_group_lookup_vty (vty, ip_str);
5492 if (! peer)
5493 return CMD_WARNING;
5494
5495 /* Check filter direction. */
fee0f4c6 5496 if (strncmp (direct_str, "in", 2) == 0)
5497 direct = RMAP_IN;
718e3744 5498 else if (strncmp (direct_str, "o", 1) == 0)
fee0f4c6 5499 direct = RMAP_OUT;
718e3744 5500
5501 ret = peer_route_map_set (peer, afi, safi, direct, name_str);
5502
5503 return bgp_vty_return (vty, ret);
5504}
5505
94f2b392 5506static int
fd79ac91 5507peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5508 safi_t safi, const char *direct_str)
718e3744 5509{
5510 int ret;
5511 struct peer *peer;
fee0f4c6 5512 int direct = RMAP_IN;
718e3744 5513
5514 peer = peer_and_group_lookup_vty (vty, ip_str);
5515 if (! peer)
5516 return CMD_WARNING;
5517
5518 /* Check filter direction. */
fee0f4c6 5519 if (strncmp (direct_str, "in", 2) == 0)
5520 direct = RMAP_IN;
718e3744 5521 else if (strncmp (direct_str, "o", 1) == 0)
fee0f4c6 5522 direct = RMAP_OUT;
718e3744 5523
5524 ret = peer_route_map_unset (peer, afi, safi, direct);
5525
5526 return bgp_vty_return (vty, ret);
5527}
5528
5529DEFUN (neighbor_route_map,
5530 neighbor_route_map_cmd,
9ccf14f7 5531 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
718e3744 5532 NEIGHBOR_STR
5533 NEIGHBOR_ADDR_STR2
5534 "Apply route map to neighbor\n"
5535 "Name of route map\n"
5536 "Apply map to incoming routes\n"
2a3d5731 5537 "Apply map to outbound routes\n")
718e3744 5538{
c500ae40
DW
5539 int idx_peer = 1;
5540 int idx_word = 3;
5541 int idx_in_out = 4;
5542 return peer_route_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5543 bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg);
718e3744 5544}
5545
5546DEFUN (no_neighbor_route_map,
5547 no_neighbor_route_map_cmd,
9ccf14f7 5548 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
718e3744 5549 NO_STR
5550 NEIGHBOR_STR
5551 NEIGHBOR_ADDR_STR2
5552 "Apply route map to neighbor\n"
5553 "Name of route map\n"
5554 "Apply map to incoming routes\n"
2a3d5731 5555 "Apply map to outbound routes\n")
718e3744 5556{
c500ae40
DW
5557 int idx_peer = 2;
5558 int idx_in_out = 5;
5559 return peer_route_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5560 bgp_node_safi (vty), argv[idx_in_out]->arg);
718e3744 5561}
6b0655a2 5562
718e3744 5563/* Set unsuppress-map to the peer. */
94f2b392 5564static int
fd79ac91 5565peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
5566 safi_t safi, const char *name_str)
718e3744 5567{
5568 int ret;
5569 struct peer *peer;
5570
5571 peer = peer_and_group_lookup_vty (vty, ip_str);
5572 if (! peer)
5573 return CMD_WARNING;
5574
5575 ret = peer_unsuppress_map_set (peer, afi, safi, name_str);
5576
5577 return bgp_vty_return (vty, ret);
5578}
5579
5580/* Unset route-map from the peer. */
94f2b392 5581static int
fd79ac91 5582peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
718e3744 5583 safi_t safi)
5584{
5585 int ret;
5586 struct peer *peer;
5587
5588 peer = peer_and_group_lookup_vty (vty, ip_str);
5589 if (! peer)
5590 return CMD_WARNING;
5591
5592 ret = peer_unsuppress_map_unset (peer, afi, safi);
5593
5594 return bgp_vty_return (vty, ret);
5595}
5596
5597DEFUN (neighbor_unsuppress_map,
5598 neighbor_unsuppress_map_cmd,
9ccf14f7 5599 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
718e3744 5600 NEIGHBOR_STR
5601 NEIGHBOR_ADDR_STR2
5602 "Route-map to selectively unsuppress suppressed routes\n"
5603 "Name of route map\n")
5604{
c500ae40
DW
5605 int idx_peer = 1;
5606 int idx_word = 3;
5607 return peer_unsuppress_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5608 bgp_node_safi (vty), argv[idx_word]->arg);
718e3744 5609}
5610
5611DEFUN (no_neighbor_unsuppress_map,
5612 no_neighbor_unsuppress_map_cmd,
9ccf14f7 5613 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
718e3744 5614 NO_STR
5615 NEIGHBOR_STR
5616 NEIGHBOR_ADDR_STR2
5617 "Route-map to selectively unsuppress suppressed routes\n"
5618 "Name of route map\n")
5619{
c500ae40
DW
5620 int idx_peer = 2;
5621 return peer_unsuppress_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 5622 bgp_node_safi (vty));
5623}
6b0655a2 5624
94f2b392 5625static int
fd79ac91 5626peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
5627 safi_t safi, const char *num_str,
0a486e5f 5628 const char *threshold_str, int warning,
5629 const char *restart_str)
718e3744 5630{
5631 int ret;
5632 struct peer *peer;
5633 u_int32_t max;
e0701b79 5634 u_char threshold;
0a486e5f 5635 u_int16_t restart;
718e3744 5636
5637 peer = peer_and_group_lookup_vty (vty, ip_str);
5638 if (! peer)
5639 return CMD_WARNING;
5640
e6ec1c36 5641 VTY_GET_INTEGER ("maximum number", max, num_str);
e0701b79 5642 if (threshold_str)
5643 threshold = atoi (threshold_str);
5644 else
5645 threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT;
718e3744 5646
0a486e5f 5647 if (restart_str)
5648 restart = atoi (restart_str);
5649 else
5650 restart = 0;
5651
5652 ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart);
718e3744 5653
5654 return bgp_vty_return (vty, ret);
5655}
5656
94f2b392 5657static int
fd79ac91 5658peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
718e3744 5659 safi_t safi)
5660{
5661 int ret;
5662 struct peer *peer;
5663
5664 peer = peer_and_group_lookup_vty (vty, ip_str);
5665 if (! peer)
5666 return CMD_WARNING;
5667
5668 ret = peer_maximum_prefix_unset (peer, afi, safi);
5669
5670 return bgp_vty_return (vty, ret);
5671}
5672
5673/* Maximum number of prefix configuration. prefix count is different
5674 for each peer configuration. So this configuration can be set for
5675 each peer configuration. */
5676DEFUN (neighbor_maximum_prefix,
5677 neighbor_maximum_prefix_cmd,
9ccf14f7 5678 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
718e3744 5679 NEIGHBOR_STR
5680 NEIGHBOR_ADDR_STR2
5681 "Maximum number of prefix accept from this peer\n"
5682 "maximum no. of prefix limit\n")
5683{
c500ae40
DW
5684 int idx_peer = 1;
5685 int idx_number = 3;
5686 return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5687 bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0,
0a486e5f 5688 NULL);
718e3744 5689}
5690
e0701b79 5691DEFUN (neighbor_maximum_prefix_threshold,
5692 neighbor_maximum_prefix_threshold_cmd,
9ccf14f7 5693 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
e0701b79 5694 NEIGHBOR_STR
5695 NEIGHBOR_ADDR_STR2
5696 "Maximum number of prefix accept from this peer\n"
5697 "maximum no. of prefix limit\n"
5698 "Threshold value (%) at which to generate a warning msg\n")
5699{
c500ae40
DW
5700 int idx_peer = 1;
5701 int idx_number = 3;
5702 int idx_number_2 = 4;
5703 return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5704 bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0,
0a486e5f 5705 NULL);
5706}
e0701b79 5707
718e3744 5708DEFUN (neighbor_maximum_prefix_warning,
5709 neighbor_maximum_prefix_warning_cmd,
9ccf14f7 5710 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
718e3744 5711 NEIGHBOR_STR
5712 NEIGHBOR_ADDR_STR2
5713 "Maximum number of prefix accept from this peer\n"
5714 "maximum no. of prefix limit\n"
5715 "Only give warning message when limit is exceeded\n")
5716{
c500ae40
DW
5717 int idx_peer = 1;
5718 int idx_number = 3;
5719 return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5720 bgp_node_safi (vty), argv[idx_number]->arg, NULL, 1,
0a486e5f 5721 NULL);
718e3744 5722}
5723
e0701b79 5724DEFUN (neighbor_maximum_prefix_threshold_warning,
5725 neighbor_maximum_prefix_threshold_warning_cmd,
9ccf14f7 5726 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
e0701b79 5727 NEIGHBOR_STR
5728 NEIGHBOR_ADDR_STR2
5729 "Maximum number of prefix accept from this peer\n"
5730 "maximum no. of prefix limit\n"
5731 "Threshold value (%) at which to generate a warning msg\n"
5732 "Only give warning message when limit is exceeded\n")
5733{
c500ae40
DW
5734 int idx_peer = 1;
5735 int idx_number = 3;
5736 int idx_number_2 = 4;
5737 return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5738 bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL);
0a486e5f 5739}
5740
5741DEFUN (neighbor_maximum_prefix_restart,
5742 neighbor_maximum_prefix_restart_cmd,
9ccf14f7 5743 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
0a486e5f 5744 NEIGHBOR_STR
5745 NEIGHBOR_ADDR_STR2
5746 "Maximum number of prefix accept from this peer\n"
5747 "maximum no. of prefix limit\n"
5748 "Restart bgp connection after limit is exceeded\n"
5749 "Restart interval in minutes")
5750{
c500ae40
DW
5751 int idx_peer = 1;
5752 int idx_number = 3;
5753 int idx_number_2 = 5;
5754 return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5755 bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg);
0a486e5f 5756}
5757
5758DEFUN (neighbor_maximum_prefix_threshold_restart,
5759 neighbor_maximum_prefix_threshold_restart_cmd,
9ccf14f7 5760 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
0a486e5f 5761 NEIGHBOR_STR
5762 NEIGHBOR_ADDR_STR2
5763 "Maximum number of prefix accept from this peer\n"
5764 "maximum no. of prefix limit\n"
5765 "Threshold value (%) at which to generate a warning msg\n"
5766 "Restart bgp connection after limit is exceeded\n"
5767 "Restart interval in minutes")
5768{
c500ae40
DW
5769 int idx_peer = 1;
5770 int idx_number = 3;
5771 int idx_number_2 = 4;
5772 int idx_number_3 = 6;
5773 return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5774 bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, argv[idx_number_3]->arg);
0a486e5f 5775}
e0701b79 5776
f412b39a
DW
5777/*
5778 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
3ce54f78 5779 * "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix <1-4294967295>",
f412b39a
DW
5780 * NO_STR
5781 * NEIGHBOR_STR
5782 * NEIGHBOR_ADDR_STR2
5783 * "Maximum number of prefix accept from this peer\n"
5784 * "maximum no. of prefix limit\n"
5785 *
3ce54f78 5786 * "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
f412b39a
DW
5787 * NO_STR
5788 * NEIGHBOR_STR
5789 * NEIGHBOR_ADDR_STR2
5790 * "Maximum number of prefix accept from this peer\n"
5791 * "maximum no. of prefix limit\n"
5792 * "Threshold value (%) at which to generate a warning msg\n"
5793 * "Restart bgp connection after limit is exceeded\n"
5794 * "Restart interval in minutes"
5795 *
3ce54f78 5796 * "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix <1-4294967295> warning-only",
f412b39a
DW
5797 * NO_STR
5798 * NEIGHBOR_STR
5799 * NEIGHBOR_ADDR_STR2
5800 * "Maximum number of prefix accept from this peer\n"
5801 * "maximum no. of prefix limit\n"
5802 * "Only give warning message when limit is exceeded\n"
5803 *
3ce54f78 5804 * "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix <1-4294967295> restart <1-65535>",
f412b39a
DW
5805 * NO_STR
5806 * NEIGHBOR_STR
5807 * NEIGHBOR_ADDR_STR2
5808 * "Maximum number of prefix accept from this peer\n"
5809 * "maximum no. of prefix limit\n"
5810 * "Restart bgp connection after limit is exceeded\n"
5811 * "Restart interval in minutes"
5812 *
3ce54f78 5813 * "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix <1-4294967295> <1-100> warning-only",
f412b39a
DW
5814 * NO_STR
5815 * NEIGHBOR_STR
5816 * NEIGHBOR_ADDR_STR2
5817 * "Maximum number of prefix accept from this peer\n"
5818 * "maximum no. of prefix limit\n"
5819 * "Threshold value (%) at which to generate a warning msg\n"
5820 * "Only give warning message when limit is exceeded\n"
5821 *
3ce54f78 5822 * "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix <1-4294967295> <1-100>",
f412b39a
DW
5823 * NO_STR
5824 * NEIGHBOR_STR
5825 * NEIGHBOR_ADDR_STR2
5826 * "Maximum number of prefix accept from this peer\n"
5827 * "maximum no. of prefix limit\n"
5828 * "Threshold value (%) at which to generate a warning msg\n"
5829 *
5830 */
718e3744 5831DEFUN (no_neighbor_maximum_prefix,
5832 no_neighbor_maximum_prefix_cmd,
9ccf14f7 5833 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix",
718e3744 5834 NO_STR
5835 NEIGHBOR_STR
5836 NEIGHBOR_ADDR_STR2
5837 "Maximum number of prefix accept from this peer\n")
5838{
c500ae40
DW
5839 int idx_peer = 2;
5840 return peer_maximum_prefix_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 5841 bgp_node_safi (vty));
5842}
5843
718e3744 5844
0a486e5f 5845
0a486e5f 5846
e0701b79 5847
0a486e5f 5848
6b0655a2 5849
718e3744 5850/* "neighbor allowas-in" */
f412b39a
DW
5851/*
5852 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
3ce54f78 5853 * "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in <1-10>",
f412b39a
DW
5854 * NEIGHBOR_STR
5855 * NEIGHBOR_ADDR_STR2
5856 * "Accept as-path with my AS present in it\n"
5857 * "Number of occurances of AS number\n"
5858 *
5859 */
718e3744 5860DEFUN (neighbor_allowas_in,
5861 neighbor_allowas_in_cmd,
9ccf14f7 5862 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in",
718e3744 5863 NEIGHBOR_STR
5864 NEIGHBOR_ADDR_STR2
5865 "Accept as-path with my AS present in it\n")
5866{
c500ae40 5867 int idx_peer = 1;
718e3744 5868 int ret;
5869 struct peer *peer;
fd79ac91 5870 unsigned int allow_num;
718e3744 5871
c500ae40 5872 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
718e3744 5873 if (! peer)
5874 return CMD_WARNING;
5875
5876 if (argc == 1)
5877 allow_num = 3;
5878 else
afec25d9 5879 VTY_GET_INTEGER_RANGE ("AS number", allow_num, argv[3]->arg, 1, 10);
718e3744 5880
5881 ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty),
5882 allow_num);
5883
5884 return bgp_vty_return (vty, ret);
5885}
5886
718e3744 5887DEFUN (no_neighbor_allowas_in,
5888 no_neighbor_allowas_in_cmd,
9ccf14f7 5889 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [(1-10)]",
718e3744 5890 NO_STR
5891 NEIGHBOR_STR
5892 NEIGHBOR_ADDR_STR2
8334fd5a
DW
5893 "allow local ASN appears in aspath attribute\n"
5894 "Number of occurances of AS number\n")
718e3744 5895{
c500ae40 5896 int idx_peer = 2;
718e3744 5897 int ret;
5898 struct peer *peer;
5899
c500ae40 5900 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
718e3744 5901 if (! peer)
5902 return CMD_WARNING;
5903
5904 ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty));
5905
5906 return bgp_vty_return (vty, ret);
5907}
6b0655a2 5908
813d4307 5909
fa411a21
NH
5910DEFUN (neighbor_ttl_security,
5911 neighbor_ttl_security_cmd,
9ccf14f7 5912 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
fa411a21
NH
5913 NEIGHBOR_STR
5914 NEIGHBOR_ADDR_STR2
5915 "Specify the maximum number of hops to the BGP peer\n")
5916{
c500ae40
DW
5917 int idx_peer = 1;
5918 int idx_number = 4;
fa411a21 5919 struct peer *peer;
89b6d1f8 5920 int gtsm_hops;
fa411a21 5921
c500ae40 5922 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
fa411a21
NH
5923 if (! peer)
5924 return CMD_WARNING;
5925
c500ae40 5926 VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[idx_number]->arg, 1, 254);
fa411a21 5927
8cdabf90
SK
5928 /*
5929 * If 'neighbor swpX', then this is for directly connected peers,
5930 * we should not accept a ttl-security hops value greater than 1.
5931 */
5932 if (peer->conf_if && (gtsm_hops > 1)) {
5933 vty_out (vty, "%s is directly connected peer, hops cannot exceed 1%s",
c500ae40 5934 argv[idx_peer]->arg, VTY_NEWLINE);
8cdabf90
SK
5935 return CMD_WARNING;
5936 }
5937
89b6d1f8 5938 return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, gtsm_hops));
fa411a21
NH
5939}
5940
5941DEFUN (no_neighbor_ttl_security,
5942 no_neighbor_ttl_security_cmd,
9ccf14f7 5943 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
fa411a21
NH
5944 NO_STR
5945 NEIGHBOR_STR
5946 NEIGHBOR_ADDR_STR2
5947 "Specify the maximum number of hops to the BGP peer\n")
5948{
c500ae40 5949 int idx_peer = 2;
fa411a21 5950 struct peer *peer;
fa411a21 5951
c500ae40 5952 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
fa411a21
NH
5953 if (! peer)
5954 return CMD_WARNING;
5955
89b6d1f8 5956 return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer));
fa411a21 5957}
6b0655a2 5958
adbac85e
DW
5959DEFUN (neighbor_addpath_tx_all_paths,
5960 neighbor_addpath_tx_all_paths_cmd,
9ccf14f7 5961 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
adbac85e
DW
5962 NEIGHBOR_STR
5963 NEIGHBOR_ADDR_STR2
5964 "Use addpath to advertise all paths to a neighbor\n")
5965{
c500ae40 5966 int idx_peer = 1;
adbac85e
DW
5967 struct peer *peer;
5968
c500ae40 5969 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
adbac85e
DW
5970 if (! peer)
5971 return CMD_WARNING;
5972
c500ae40 5973 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
adbac85e
DW
5974 bgp_node_safi (vty),
5975 PEER_FLAG_ADDPATH_TX_ALL_PATHS);
5976}
5977
5978DEFUN (no_neighbor_addpath_tx_all_paths,
5979 no_neighbor_addpath_tx_all_paths_cmd,
9ccf14f7 5980 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
adbac85e
DW
5981 NO_STR
5982 NEIGHBOR_STR
5983 NEIGHBOR_ADDR_STR2
5984 "Use addpath to advertise all paths to a neighbor\n")
5985{
c500ae40
DW
5986 int idx_peer = 2;
5987 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
adbac85e
DW
5988 bgp_node_safi (vty),
5989 PEER_FLAG_ADDPATH_TX_ALL_PATHS);
5990}
5991
06370dac
DW
5992DEFUN (neighbor_addpath_tx_bestpath_per_as,
5993 neighbor_addpath_tx_bestpath_per_as_cmd,
9ccf14f7 5994 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
06370dac
DW
5995 NEIGHBOR_STR
5996 NEIGHBOR_ADDR_STR2
5997 "Use addpath to advertise the bestpath per each neighboring AS\n")
5998{
c500ae40 5999 int idx_peer = 1;
06370dac
DW
6000 struct peer *peer;
6001
c500ae40 6002 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
06370dac
DW
6003 if (! peer)
6004 return CMD_WARNING;
6005
c500ae40 6006 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
06370dac
DW
6007 bgp_node_safi (vty),
6008 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS);
6009}
6010
6011DEFUN (no_neighbor_addpath_tx_bestpath_per_as,
6012 no_neighbor_addpath_tx_bestpath_per_as_cmd,
9ccf14f7 6013 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
06370dac
DW
6014 NO_STR
6015 NEIGHBOR_STR
6016 NEIGHBOR_ADDR_STR2
6017 "Use addpath to advertise the bestpath per each neighboring AS\n")
6018{
c500ae40
DW
6019 int idx_peer = 2;
6020 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
06370dac
DW
6021 bgp_node_safi (vty),
6022 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS);
6023}
6024
6025
718e3744 6026/* Address family configuration. */
6027DEFUN (address_family_ipv4,
6028 address_family_ipv4_cmd,
6029 "address-family ipv4",
6030 "Enter Address Family command mode\n"
6031 "Address family\n")
6032{
6033 vty->node = BGP_IPV4_NODE;
6034 return CMD_SUCCESS;
6035}
6036
6037DEFUN (address_family_ipv4_safi,
6038 address_family_ipv4_safi_cmd,
6147e2c6 6039 "address-family ipv4 <unicast|multicast>",
718e3744 6040 "Enter Address Family command mode\n"
6041 "Address family\n"
6042 "Address Family modifier\n"
6043 "Address Family modifier\n")
6044{
c500ae40
DW
6045 int idx_safi = 2;
6046 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
718e3744 6047 vty->node = BGP_IPV4M_NODE;
6048 else
6049 vty->node = BGP_IPV4_NODE;
6050
6051 return CMD_SUCCESS;
6052}
6053
25ffbdc1 6054DEFUN (address_family_ipv6,
6055 address_family_ipv6_cmd,
6056 "address-family ipv6",
718e3744 6057 "Enter Address Family command mode\n"
25ffbdc1 6058 "Address family\n")
718e3744 6059{
6060 vty->node = BGP_IPV6_NODE;
6061 return CMD_SUCCESS;
6062}
6063
25ffbdc1 6064DEFUN (address_family_ipv6_safi,
6065 address_family_ipv6_safi_cmd,
6147e2c6 6066 "address-family ipv6 <unicast|multicast>",
718e3744 6067 "Enter Address Family command mode\n"
25ffbdc1 6068 "Address family\n"
6069 "Address Family modifier\n"
6070 "Address Family modifier\n")
6071{
c500ae40
DW
6072 int idx_safi = 2;
6073 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
25ffbdc1 6074 vty->node = BGP_IPV6M_NODE;
6075 else
6076 vty->node = BGP_IPV6_NODE;
6077
6078 return CMD_SUCCESS;
6079}
718e3744 6080
6081DEFUN (address_family_vpnv4,
6082 address_family_vpnv4_cmd,
8334fd5a 6083 "address-family vpnv4 [unicast]",
718e3744 6084 "Enter Address Family command mode\n"
8334fd5a
DW
6085 "Address family\n"
6086 "Address Family Modifier\n")
718e3744 6087{
6088 vty->node = BGP_VPNV4_NODE;
6089 return CMD_SUCCESS;
6090}
6091
8ecd3266 6092DEFUN (address_family_vpnv6,
6093 address_family_vpnv6_cmd,
8334fd5a 6094 "address-family vpnv6 [unicast]",
8ecd3266 6095 "Enter Address Family command mode\n"
8334fd5a
DW
6096 "Address family\n"
6097 "Address Family Modifier\n")
8ecd3266 6098{
6099 vty->node = BGP_VPNV6_NODE;
6100 return CMD_SUCCESS;
6101}
6102
8b1fb8be
LB
6103DEFUN (address_family_encap,
6104 address_family_encap_cmd,
8334fd5a 6105 "address-family <encap|encapv4>",
8b1fb8be 6106 "Enter Address Family command mode\n"
8334fd5a 6107 "Address family\n"
8b1fb8be
LB
6108 "Address family\n")
6109{
6110 vty->node = BGP_ENCAP_NODE;
6111 return CMD_SUCCESS;
6112}
6113
8b1fb8be
LB
6114
6115DEFUN (address_family_encapv6,
6116 address_family_encapv6_cmd,
6117 "address-family encapv6",
6118 "Enter Address Family command mode\n"
6119 "Address family\n")
6120{
6121 vty->node = BGP_ENCAPV6_NODE;
6122 return CMD_SUCCESS;
6123}
6124
718e3744 6125DEFUN (exit_address_family,
6126 exit_address_family_cmd,
6127 "exit-address-family",
6128 "Exit from Address Family configuration mode\n")
6129{
a8a80d53 6130 if (vty->node == BGP_IPV4_NODE
6131 || vty->node == BGP_IPV4M_NODE
718e3744 6132 || vty->node == BGP_VPNV4_NODE
25ffbdc1 6133 || vty->node == BGP_IPV6_NODE
8ecd3266 6134 || vty->node == BGP_IPV6M_NODE
8b1fb8be
LB
6135 || vty->node == BGP_VPNV6_NODE
6136 || vty->node == BGP_ENCAP_NODE
6137 || vty->node == BGP_ENCAPV6_NODE)
718e3744 6138 vty->node = BGP_NODE;
6139 return CMD_SUCCESS;
6140}
6b0655a2 6141
8ad7271d
DS
6142/* Recalculate bestpath and re-advertise a prefix */
6143static int
01080f7c 6144bgp_clear_prefix (struct vty *vty, const char *view_name, const char *ip_str,
8ad7271d
DS
6145 afi_t afi, safi_t safi, struct prefix_rd *prd)
6146{
6147 int ret;
6148 struct prefix match;
6149 struct bgp_node *rn;
6150 struct bgp_node *rm;
8ad7271d
DS
6151 struct bgp *bgp;
6152 struct bgp_table *table;
6153 struct bgp_table *rib;
6154
6155 /* BGP structure lookup. */
6156 if (view_name)
6157 {
6158 bgp = bgp_lookup_by_name (view_name);
6159 if (bgp == NULL)
6160 {
6aeb9e78 6161 vty_out (vty, "%% Can't find BGP instance %s%s", view_name, VTY_NEWLINE);
8ad7271d
DS
6162 return CMD_WARNING;
6163 }
6164 }
6165 else
6166 {
6167 bgp = bgp_get_default ();
6168 if (bgp == NULL)
6169 {
6170 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
6171 return CMD_WARNING;
6172 }
6173 }
6174
6175 /* Check IP address argument. */
6176 ret = str2prefix (ip_str, &match);
6177 if (! ret)
6178 {
6179 vty_out (vty, "%% address is malformed%s", VTY_NEWLINE);
6180 return CMD_WARNING;
6181 }
6182
6183 match.family = afi2family (afi);
6184 rib = bgp->rib[afi][safi];
6185
6186 if (safi == SAFI_MPLS_VPN)
6187 {
6188 for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn))
6189 {
6190 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
6191 continue;
6192
6193 if ((table = rn->info) != NULL)
6194 {
6195 if ((rm = bgp_node_match (table, &match)) != NULL)
6196 {
6197 if (rm->p.prefixlen == match.prefixlen)
6198 {
6199 SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR);
6200 bgp_process (bgp, rm, afi, safi);
6201 }
6202 bgp_unlock_node (rm);
6203 }
6204 }
6205 }
6206 }
6207 else
6208 {
6209 if ((rn = bgp_node_match (rib, &match)) != NULL)
6210 {
6211 if (rn->p.prefixlen == match.prefixlen)
6212 {
6213 SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR);
6214 bgp_process (bgp, rn, afi, safi);
6215 }
6216 bgp_unlock_node (rn);
6217 }
6218 }
6219
6220 return CMD_SUCCESS;
6221}
6222
f412b39a
DW
6223/*
6224 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
6225 * "clear bgp *",
6226 * CLEAR_STR
6227 * BGP_STR
6228 * "Clear all peers\n"
6229 *
9ccf14f7 6230 * "clear bgp <view|vrf> WORD ipv6 *",
f412b39a
DW
6231 * CLEAR_STR
6232 * BGP_STR
6233 * BGP_INSTANCE_HELP_STR
6234 * "Address family\n"
6235 * "Clear all peers\n"
6236 *
f412b39a
DW
6237 * "clear bgp ipv6 *",
6238 * CLEAR_STR
6239 * BGP_STR
6240 * "Address family\n"
6241 * "Clear all peers\n"
f412b39a 6242 */
718e3744 6243DEFUN (clear_ip_bgp_all,
6244 clear_ip_bgp_all_cmd,
8334fd5a 6245 "clear ip bgp [<view|vrf> WORD] *",
718e3744 6246 CLEAR_STR
6247 IP_STR
6248 BGP_STR
8334fd5a 6249 BGP_INSTANCE_HELP_STR
718e3744 6250 "Clear all peers\n")
6251{
8334fd5a
DW
6252 int idx_view_vrf = 3;
6253 int idx_vrf = 4;
6254 char *vrf = NULL;
6255
6256 if (strmatch(argv[idx_view_vrf]->text, "view") || strmatch(argv[idx_view_vrf]->text, "vrf"))
6257 vrf = argv[idx_vrf]->arg;
6258
6259 return bgp_clear_vty (vty, vrf, 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
718e3744 6260}
6261
f412b39a 6262/*
838758ac 6263 * CHECK ME need ipv6 equivalent
f412b39a 6264 */
718e3744 6265DEFUN (clear_ip_bgp_peer,
f412b39a 6266 clear_ip_bgp_peer_cmd,
838758ac 6267 "clear [ip] bgp [<view|vrf> WORD] <A.B.C.D|X:X::X:X|WORD|peer-group WORD>",
718e3744 6268 CLEAR_STR
6269 IP_STR
6270 BGP_STR
838758ac 6271 BGP_INSTANCE_HELP_STR
718e3744 6272 "BGP neighbor IP address to clear\n"
a80beece 6273 "BGP IPv6 neighbor to clear\n"
838758ac 6274 "BGP neighbor on interface to clear\n"
718e3744 6275 "Clear all members of peer-group\n"
6276 "BGP peer-group name\n")
6277{
838758ac
DW
6278 int idx_ip = 1;
6279 int idx_view_vrf = 3;
6280 int idx_vrf = 4;
6281 int idx_peer = 5;
8334fd5a 6282 char *vrf = NULL;
838758ac 6283 enum clear_sort clearer;
718e3744 6284
838758ac
DW
6285 if (!strmatch(argv[idx_ip]->text, "ip"))
6286 {
6287 idx_view_vrf--;
6288 idx_vrf--;
6289 idx_peer--;
6290 }
6291
6292 if (argv[idx_view_vrf]->type == WORD_TKN)
8334fd5a 6293 vrf = argv[idx_vrf]->arg;
838758ac
DW
6294 else
6295 idx_peer -= 2;
01080f7c 6296
838758ac
DW
6297 /* peer-group WORD */
6298 if (argv[idx_peer]->type == WORD_TKN)
6299 {
6300 clearer = clear_group;
6301 idx_peer += 1;
6302 }
6303 else
6304 {
6305 clearer = clear_peer;
6306 }
718e3744 6307
8334fd5a 6308 return bgp_clear_vty (vty, vrf, 0, 0, clearer, BGP_CLEAR_SOFT_NONE, argv[idx_peer]->arg);
838758ac 6309}
01080f7c 6310
f412b39a
DW
6311/*
6312 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9ccf14f7 6313 * "clear bgp <view|vrf> WORD ipv6 external",
f412b39a
DW
6314 * CLEAR_STR
6315 * BGP_STR
6316 * BGP_INSTANCE_HELP_STR
6317 * "Address family\n"
6318 * "Clear all external peers\n"
6319 *
f412b39a
DW
6320 * "clear bgp ipv6 external",
6321 * CLEAR_STR
6322 * BGP_STR
6323 * "Address family\n"
6324 * "Clear all external peers\n"
f412b39a 6325 */
718e3744 6326DEFUN (clear_ip_bgp_external,
6327 clear_ip_bgp_external_cmd,
838758ac 6328 "clear [ip] bgp [<view|vrf> WORD] external",
718e3744 6329 CLEAR_STR
6330 IP_STR
6331 BGP_STR
838758ac 6332 BGP_INSTANCE_HELP_STR
718e3744 6333 "Clear all external peers\n")
6334{
838758ac
DW
6335 int idx_ip = 1;
6336 int idx_view_vrf = 3;
6337 int idx_vrf = 4;
8334fd5a 6338 char *vrf = NULL;
718e3744 6339
838758ac
DW
6340 if (!strmatch(argv[idx_ip]->text, "ip"))
6341 {
6342 idx_view_vrf--;
6343 idx_vrf--;
6344 }
01080f7c 6345
838758ac 6346 if (argv[idx_view_vrf]->type == WORD_TKN)
8334fd5a 6347 vrf = argv[idx_vrf]->arg;
718e3744 6348
8334fd5a 6349 return bgp_clear_vty (vty, vrf, 0, 0, clear_external, BGP_CLEAR_SOFT_NONE, NULL);
838758ac 6350}
01080f7c 6351
8ad7271d
DS
6352DEFUN (clear_ip_bgp_prefix,
6353 clear_ip_bgp_prefix_cmd,
838758ac 6354 "clear [ip] bgp [<view|vrf> WORD] prefix A.B.C.D/M",
8ad7271d
DS
6355 CLEAR_STR
6356 IP_STR
6357 BGP_STR
838758ac 6358 BGP_INSTANCE_HELP_STR
8ad7271d
DS
6359 "Clear bestpath and re-advertise\n"
6360 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6361{
838758ac
DW
6362 int idx_ip = 1;
6363 int idx_view_vrf = 3;
6364 int idx_vrf = 4;
6365 int idx_ipv4_prefixlen = 6;
8334fd5a 6366 char *vrf = NULL;
8ad7271d 6367
838758ac
DW
6368 if (!strmatch(argv[idx_ip]->text, "ip"))
6369 {
6370 idx_view_vrf--;
6371 idx_vrf--;
6372 idx_ipv4_prefixlen--;
6373 }
01080f7c 6374
838758ac 6375 if (strmatch(argv[idx_view_vrf]->text, "view") || strmatch(argv[idx_view_vrf]->text, "vrf"))
8334fd5a 6376 vrf = argv[idx_vrf]->arg;
838758ac
DW
6377 else
6378 idx_ipv4_prefixlen -= 2;
8ad7271d 6379
8334fd5a 6380 return bgp_clear_prefix (vty, vrf, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL);
838758ac 6381}
8ad7271d 6382
f412b39a
DW
6383/*
6384 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
838758ac 6385 * need ipv6 options
f412b39a 6386 *
9ccf14f7 6387 * "clear bgp ipv6 (1-4294967295)",
f412b39a
DW
6388 * CLEAR_STR
6389 * BGP_STR
6390 * "Address family\n"
6391 * "Clear peers with the AS number\n"
6392 *
9ccf14f7 6393 * "clear bgp <view|vrf> WORD ipv6 (1-4294967295)",
f412b39a
DW
6394 * CLEAR_STR
6395 * BGP_STR
6396 * BGP_INSTANCE_HELP_STR
6397 * "Address family\n"
6398 * "Clear peers with the AS number\n"
f412b39a 6399 */
718e3744 6400DEFUN (clear_ip_bgp_as,
6401 clear_ip_bgp_as_cmd,
9ccf14f7 6402 "clear [ip] bgp [<view|vrf> WORD] (1-4294967295)",
718e3744 6403 CLEAR_STR
6404 IP_STR
6405 BGP_STR
838758ac 6406 BGP_INSTANCE_HELP_STR
718e3744 6407 "Clear peers with the AS number\n")
6408{
838758ac
DW
6409 int idx_ip = 1;
6410 int idx_view_vrf = 3;
6411 int idx_vrf = 4;
c500ae40 6412 int idx_number = 3;
8334fd5a 6413 char *vrf = NULL;
718e3744 6414
838758ac
DW
6415 if (!strmatch(argv[idx_ip]->text, "ip"))
6416 {
6417 idx_view_vrf--;
6418 idx_vrf--;
6419 idx_number--;
6420 }
01080f7c 6421
838758ac 6422 if (strmatch(argv[idx_view_vrf]->text, "view") || strmatch(argv[idx_view_vrf]->text, "vrf"))
8334fd5a 6423 vrf = argv[idx_vrf]->arg;
838758ac
DW
6424 else
6425 idx_number -= 2;
6b0655a2 6426
8334fd5a 6427 return bgp_clear_vty (vty, vrf, 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[idx_number]->arg);
838758ac 6428}
01080f7c 6429
718e3744 6430/* Outbound soft-reconfiguration */
6431DEFUN (clear_ip_bgp_all_soft_out,
6432 clear_ip_bgp_all_soft_out_cmd,
838758ac 6433 "clear ip bgp [<view|vrf> WORD] * [soft] out",
718e3744 6434 CLEAR_STR
6435 IP_STR
6436 BGP_STR
838758ac 6437 BGP_INSTANCE_HELP_STR
718e3744 6438 "Clear all peers\n"
e0bce756
DS
6439 BGP_SOFT_STR
6440 BGP_SOFT_OUT_STR)
718e3744 6441{
838758ac
DW
6442 int idx_view_vrf = 3;
6443 int idx_vrf = 4;
8334fd5a 6444 char *vrf = NULL;
01080f7c 6445
838758ac 6446 if (strmatch(argv[idx_view_vrf]->text, "view") || strmatch(argv[idx_view_vrf]->text, "vrf"))
8334fd5a 6447 vrf = argv[idx_vrf]->arg;
718e3744 6448
8334fd5a 6449 return bgp_clear_vty (vty, vrf, AFI_IP, SAFI_UNICAST, clear_all, BGP_CLEAR_SOFT_OUT, NULL);
838758ac 6450}
718e3744 6451
6452DEFUN (clear_ip_bgp_all_ipv4_soft_out,
6453 clear_ip_bgp_all_ipv4_soft_out_cmd,
838758ac 6454 "clear ip bgp * ipv4 <unicast|multicast> [soft] out",
718e3744 6455 CLEAR_STR
6456 IP_STR
6457 BGP_STR
6458 "Clear all peers\n"
6459 "Address family\n"
6460 "Address Family modifier\n"
6461 "Address Family modifier\n"
e0bce756
DS
6462 BGP_SOFT_STR
6463 BGP_SOFT_OUT_STR)
718e3744 6464{
c500ae40
DW
6465 int idx_safi = 5;
6466 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
718e3744 6467 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
6468 BGP_CLEAR_SOFT_OUT, NULL);
6469
6470 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6471 BGP_CLEAR_SOFT_OUT, NULL);
6472}
6473
01080f7c 6474DEFUN (clear_ip_bgp_instance_all_ipv4_soft_out,
6475 clear_ip_bgp_instance_all_ipv4_soft_out_cmd,
9ccf14f7 6476 "clear ip bgp <view|vrf> WORD * ipv4 <unicast|multicast> [soft] out",
01080f7c 6477 CLEAR_STR
6478 IP_STR
6479 BGP_STR
6480 BGP_INSTANCE_HELP_STR
6481 "Clear all peers\n"
6482 "Address family\n"
6483 "Address Family modifier\n"
6484 "Address Family modifier\n"
6485 BGP_SOFT_OUT_STR)
6486{
c500ae40
DW
6487 int idx_view_vrf = 3;
6488 int idx_word = 4;
6489 int idx_safi = 7;
6490 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
6491 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_all,
01080f7c 6492 BGP_CLEAR_SOFT_OUT, NULL);
6493
c500ae40 6494 return bgp_clear_vty (vty, argv[idx_view_vrf]->arg, AFI_IP, SAFI_UNICAST, clear_all,
01080f7c 6495 BGP_CLEAR_SOFT_OUT, NULL);
6496}
6497
718e3744 6498DEFUN (clear_ip_bgp_all_vpnv4_soft_out,
6499 clear_ip_bgp_all_vpnv4_soft_out_cmd,
838758ac 6500 "clear ip bgp * vpnv4 unicast [soft] out",
718e3744 6501 CLEAR_STR
6502 IP_STR
6503 BGP_STR
6504 "Clear all peers\n"
6505 "Address family\n"
6506 "Address Family Modifier\n"
e0bce756
DS
6507 BGP_SOFT_STR
6508 BGP_SOFT_OUT_STR)
718e3744 6509{
6510 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
6511 BGP_CLEAR_SOFT_OUT, NULL);
6512}
6513
587ff0fd
LB
6514DEFUN (clear_ip_bgp_all_encap_soft_out,
6515 clear_ip_bgp_all_encap_soft_out_cmd,
838758ac 6516 "clear ip bgp * encap unicast [soft] out",
587ff0fd
LB
6517 CLEAR_STR
6518 IP_STR
6519 BGP_STR
6520 "Clear all peers\n"
6521 "Address family\n"
6522 "Address Family Modifier\n"
6523 "Soft reconfig\n"
6524 "Soft reconfig outbound update\n")
6525{
6526 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_all,
6527 BGP_CLEAR_SOFT_OUT, NULL);
6528}
6529
8334fd5a 6530/* neither 'ipv6' or 'soft' do anything here */
718e3744 6531DEFUN (clear_bgp_all_soft_out,
6532 clear_bgp_all_soft_out_cmd,
8334fd5a 6533 "clear bgp [<view|vrf> WORD] [ipv6] * [soft] out",
718e3744 6534 CLEAR_STR
6535 BGP_STR
8334fd5a
DW
6536 BGP_INSTANCE_HELP_STR
6537 IPV6_STR
718e3744 6538 "Clear all peers\n"
e0bce756
DS
6539 BGP_SOFT_STR
6540 BGP_SOFT_OUT_STR)
718e3744 6541{
8334fd5a
DW
6542 int idx_view_vrf = 2;
6543 int idx_vrf = 3;
6544 char *vrf = NULL;
718e3744 6545
8334fd5a
DW
6546 if (strmatch(argv[idx_view_vrf]->text, "view") || strmatch(argv[idx_view_vrf]->text, "vrf"))
6547 vrf = argv[idx_vrf]->arg;
6548
6549 return bgp_clear_vty (vty, vrf, AFI_IP6, SAFI_UNICAST, clear_all,
718e3744 6550 BGP_CLEAR_SOFT_OUT, NULL);
6551}
6552
718e3744 6553
8ad7271d
DS
6554DEFUN (clear_bgp_ipv6_safi_prefix,
6555 clear_bgp_ipv6_safi_prefix_cmd,
6147e2c6 6556 "clear bgp ipv6 <unicast|multicast> prefix X:X::X:X/M",
8ad7271d
DS
6557 CLEAR_STR
6558 BGP_STR
6559 "Address family\n"
6560 "Address Family Modifier\n"
6561 "Clear bestpath and re-advertise\n"
6562 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6563{
c500ae40
DW
6564 int idx_safi = 3;
6565 int idx_ipv6_prefixlen = 5;
6566 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
6567 return bgp_clear_prefix (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_MULTICAST, NULL);
8ad7271d 6568 else
c500ae40 6569 return bgp_clear_prefix (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL);
8ad7271d
DS
6570}
6571
01080f7c 6572DEFUN (clear_bgp_instance_ipv6_safi_prefix,
6573 clear_bgp_instance_ipv6_safi_prefix_cmd,
9ccf14f7 6574 "clear bgp <view|vrf> WORD ipv6 <unicast|multicast> prefix X:X::X:X/M",
01080f7c 6575 CLEAR_STR
6576 BGP_STR
6577 BGP_INSTANCE_HELP_STR
6578 "Address family\n"
6579 "Address Family Modifier\n"
6580 "Clear bestpath and re-advertise\n"
6581 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6582{
c500ae40
DW
6583 int idx_word = 3;
6584 int idx_safi = 5;
6585 int idx_ipv6_prefixlen = 7;
6586 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
6587 return bgp_clear_prefix (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_MULTICAST, NULL);
01080f7c 6588 else
c500ae40 6589 return bgp_clear_prefix (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL);
01080f7c 6590}
6591
718e3744 6592DEFUN (clear_ip_bgp_peer_soft_out,
6593 clear_ip_bgp_peer_soft_out_cmd,
8334fd5a 6594 "clear ip bgp [<view|vrf> WORD] <A.B.C.D|WORD> [soft] out",
718e3744 6595 CLEAR_STR
6596 IP_STR
6597 BGP_STR
8334fd5a 6598 BGP_INSTANCE_HELP_STR
718e3744 6599 "BGP neighbor address to clear\n"
db64ea86 6600 "BGP neighbor on interface to clear\n"
e0bce756
DS
6601 BGP_SOFT_STR
6602 BGP_SOFT_OUT_STR)
718e3744 6603{
8334fd5a
DW
6604 int idx_view_vrf = 3;
6605 int idx_vrf = 4;
6606 int idx_ipv4_word = 5;
6607 char *vrf = NULL;
01080f7c 6608
8334fd5a
DW
6609 if (strmatch(argv[idx_view_vrf]->text, "view") || strmatch(argv[idx_view_vrf]->text, "vrf"))
6610 vrf = argv[idx_vrf]->arg;
6611 else
6612 idx_ipv4_word -= 2;
6613
6614 return bgp_clear_vty (vty, vrf, AFI_IP, SAFI_UNICAST, clear_peer,
c500ae40 6615 BGP_CLEAR_SOFT_OUT, argv[idx_ipv4_word]->arg);
718e3744 6616}
6617
718e3744 6618DEFUN (clear_ip_bgp_peer_ipv4_soft_out,
6619 clear_ip_bgp_peer_ipv4_soft_out_cmd,
8334fd5a 6620 "clear ip bgp <A.B.C.D|WORD> ipv4 <unicast|multicast> [soft] out",
718e3744 6621 CLEAR_STR
6622 IP_STR
6623 BGP_STR
6624 "BGP neighbor address to clear\n"
db64ea86 6625 "BGP neighbor on interface to clear\n"
718e3744 6626 "Address family\n"
6627 "Address Family modifier\n"
6628 "Address Family modifier\n"
e0bce756
DS
6629 BGP_SOFT_STR
6630 BGP_SOFT_OUT_STR)
718e3744 6631{
c500ae40
DW
6632 int idx_ipv4_word = 3;
6633 int idx_safi = 5;
6634 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
718e3744 6635 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
c500ae40 6636 BGP_CLEAR_SOFT_OUT, argv[idx_ipv4_word]->arg);
718e3744 6637
6638 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
c500ae40 6639 BGP_CLEAR_SOFT_OUT, argv[idx_ipv4_word]->arg);
718e3744 6640}
6641
01080f7c 6642DEFUN (clear_ip_bgp_instance_peer_ipv4_soft_out,
6643 clear_ip_bgp_instance_peer_ipv4_soft_out_cmd,
9ccf14f7 6644 "clear ip bgp <view|vrf> WORD <A.B.C.D|WORD> ipv4 <unicast|multicast> [soft] out",
01080f7c 6645 CLEAR_STR
6646 IP_STR
6647 BGP_STR
6648 BGP_INSTANCE_HELP_STR
6649 "BGP neighbor address to clear\n"
6650 "BGP neighbor on interface to clear\n"
6651 "Address family\n"
6652 "Address Family modifier\n"
6653 "Address Family modifier\n"
6654 BGP_SOFT_STR
6655 BGP_SOFT_OUT_STR)
6656{
c500ae40
DW
6657 int idx_word = 4;
6658 int idx_ipv4_word = 5;
6659 int idx_safi = 7;
6660 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
6661 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_peer,
6662 BGP_CLEAR_SOFT_OUT, argv[idx_ipv4_word]->arg);
01080f7c 6663
c500ae40
DW
6664 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, clear_peer,
6665 BGP_CLEAR_SOFT_OUT, argv[idx_ipv4_word]->arg);
01080f7c 6666}
6667
db64ea86 6668/* NOTE: WORD peers have not been tested for vpnv4 */
718e3744 6669DEFUN (clear_ip_bgp_peer_vpnv4_soft_out,
6670 clear_ip_bgp_peer_vpnv4_soft_out_cmd,
8334fd5a 6671 "clear ip bgp <A.B.C.D|WORD> vpnv4 unicast [soft] out",
718e3744 6672 CLEAR_STR
6673 IP_STR
6674 BGP_STR
6675 "BGP neighbor address to clear\n"
db64ea86 6676 "BGP neighbor on interface to clear\n"
718e3744 6677 "Address family\n"
6678 "Address Family Modifier\n"
e0bce756
DS
6679 BGP_SOFT_STR
6680 BGP_SOFT_OUT_STR)
718e3744 6681{
c500ae40 6682 int idx_ipv4_word = 3;
718e3744 6683 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
c500ae40 6684 BGP_CLEAR_SOFT_OUT, argv[idx_ipv4_word]->arg);
718e3744 6685}
6686
587ff0fd
LB
6687DEFUN (clear_ip_bgp_peer_encap_soft_out,
6688 clear_ip_bgp_peer_encap_soft_out_cmd,
8334fd5a 6689 "clear ip bgp A.B.C.D encap unicast [soft] out",
587ff0fd
LB
6690 CLEAR_STR
6691 IP_STR
6692 BGP_STR
6693 "BGP neighbor address to clear\n"
6694 "Address family\n"
6695 "Address Family Modifier\n"
6696 "Soft reconfig\n"
6697 "Soft reconfig outbound update\n")
6698{
c500ae40 6699 int idx_ipv4 = 3;
587ff0fd 6700 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_peer,
c500ae40 6701 BGP_CLEAR_SOFT_OUT, argv[idx_ipv4]->arg);
587ff0fd
LB
6702}
6703
8334fd5a
DW
6704DEFUN (clear_bgp_peer_soft_out,
6705 clear_bgp_peer_soft_out_cmd,
6706 "clear bgp [<view|vrf> WORD] [ipv6] <A.B.C.D|X:X::X:X|WORD> [soft] out",
6707 CLEAR_STR
6708 BGP_STR
6709 BGP_INSTANCE_HELP_STR
6710 IPV6_STR
6711 "BGP neighbor address to clear\n"
6712 "BGP IPv6 neighbor to clear\n"
6713 "BGP neighbor on interface to clear\n"
6714 BGP_SOFT_STR
6715 BGP_SOFT_OUT_STR)
6716{
6717 int idx_view_vrf = 2;
6718 int idx_vrf = 3;
6719 int idx_ipv6 = 4;
6720 int idx_peer = 5;
6721 char *vrf = NULL;
587ff0fd 6722
8334fd5a
DW
6723 if (strmatch(argv[idx_view_vrf]->text, "view") || strmatch(argv[idx_view_vrf]->text, "vrf"))
6724 vrf = argv[idx_vrf]->arg;
6725 else
6726 {
6727 idx_peer -= 2;
6728 idx_ipv6 -= 2;
6729 }
01080f7c 6730
8334fd5a
DW
6731 if (! strmatch(argv[idx_ipv6]->text, "ipv6"))
6732 idx_peer--;
6733
6734 return bgp_clear_vty (vty, vrf, AFI_IP6, SAFI_UNICAST, clear_peer,
c500ae40 6735 BGP_CLEAR_SOFT_OUT, argv[idx_peer]->arg);
718e3744 6736}
6737
f412b39a
DW
6738DEFUN (clear_ip_bgp_peer_group_soft_out,
6739 clear_ip_bgp_peer_group_soft_out_cmd,
8334fd5a 6740 "clear ip bgp [<view|vrf> WORD] peer-group WORD [soft] out",
718e3744 6741 CLEAR_STR
f412b39a 6742 IP_STR
718e3744 6743 BGP_STR
8334fd5a 6744 BGP_INSTANCE_HELP_STR
f412b39a
DW
6745 "Clear all members of peer-group\n"
6746 "BGP peer-group name\n"
e0bce756
DS
6747 BGP_SOFT_STR
6748 BGP_SOFT_OUT_STR)
f412b39a 6749{
8334fd5a
DW
6750 int idx_view_vrf = 2;
6751 int idx_vrf = 3;
c500ae40 6752 int idx_word = 4;
8334fd5a 6753 char *vrf = NULL;
01080f7c 6754
8334fd5a
DW
6755 if (strmatch(argv[idx_view_vrf]->text, "view") || strmatch(argv[idx_view_vrf]->text, "vrf"))
6756 vrf = argv[idx_vrf]->arg;
6757 else
6758 idx_word -= 2;
6759
6760 return bgp_clear_vty (vty, vrf, AFI_IP, SAFI_UNICAST, clear_group,
c500ae40 6761 BGP_CLEAR_SOFT_OUT, argv[idx_word]->arg);
718e3744 6762}
6763
718e3744 6764DEFUN (clear_ip_bgp_peer_group_ipv4_soft_out,
6765 clear_ip_bgp_peer_group_ipv4_soft_out_cmd,
8334fd5a 6766 "clear ip bgp peer-group WORD ipv4 <unicast|multicast> [soft] out",
718e3744 6767 CLEAR_STR
6768 IP_STR
6769 BGP_STR
6770 "Clear all members of peer-group\n"
6771 "BGP peer-group name\n"
6772 "Address family\n"
6773 "Address Family modifier\n"
6774 "Address Family modifier\n"
e0bce756
DS
6775 BGP_SOFT_STR
6776 BGP_SOFT_OUT_STR)
718e3744 6777{
c500ae40
DW
6778 int idx_word = 4;
6779 int idx_safi = 6;
6780 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
718e3744 6781 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
c500ae40 6782 BGP_CLEAR_SOFT_OUT, argv[idx_word]->arg);
718e3744 6783
6784 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
c500ae40 6785 BGP_CLEAR_SOFT_OUT, argv[idx_word]->arg);
718e3744 6786}
6787
01080f7c 6788DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft_out,
6789 clear_ip_bgp_instance_peer_group_ipv4_soft_out_cmd,
9ccf14f7 6790 "clear ip bgp <view|vrf> WORD peer-group WORD ipv4 <unicast|multicast> [soft] out",
01080f7c 6791 CLEAR_STR
6792 IP_STR
6793 BGP_STR
6794 BGP_INSTANCE_HELP_STR
6795 "Clear all members of peer-group\n"
6796 "BGP peer-group name\n"
6797 "Address family\n"
6798 "Address Family modifier\n"
6799 "Address Family modifier\n"
6800 BGP_SOFT_STR
6801 BGP_SOFT_OUT_STR)
6802{
c500ae40
DW
6803 int idx_word = 4;
6804 int idx_word_2 = 6;
6805 int idx_safi = 8;
6806 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
6807 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_group,
6808 BGP_CLEAR_SOFT_OUT, argv[idx_word_2]->arg);
01080f7c 6809
c500ae40
DW
6810 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, clear_group,
6811 BGP_CLEAR_SOFT_OUT, argv[idx_word_2]->arg);
01080f7c 6812}
6813
718e3744 6814DEFUN (clear_bgp_peer_group_soft_out,
6815 clear_bgp_peer_group_soft_out_cmd,
8334fd5a 6816 "clear bgp [<view|vrf> WORD] [ipv6] peer-group WORD [soft] out",
718e3744 6817 CLEAR_STR
6818 BGP_STR
8334fd5a 6819 BGP_INSTANCE_HELP_STR
718e3744 6820 "Clear all members of peer-group\n"
6821 "BGP peer-group name\n"
e0bce756
DS
6822 BGP_SOFT_STR
6823 BGP_SOFT_OUT_STR)
718e3744 6824{
8334fd5a
DW
6825 int idx_view_vrf = 2;
6826 int idx_vrf = 3;
6827 int idx_ipv6 = 4;
6828 int idx_word = 6;
6829 char *vrf = NULL;
718e3744 6830
8334fd5a
DW
6831 if (strmatch(argv[idx_view_vrf]->text, "view") || strmatch(argv[idx_view_vrf]->text, "vrf"))
6832 vrf = argv[idx_vrf]->arg;
6833 else
6834 {
6835 idx_ipv6 -= 2;
6836 idx_word -= 2;
6837 }
01080f7c 6838
8334fd5a
DW
6839 if (!strmatch(argv[idx_ipv6]->text, "ipv6"))
6840 idx_word--;
718e3744 6841
8334fd5a
DW
6842 return bgp_clear_vty (vty, vrf, AFI_IP6, SAFI_UNICAST, clear_group,
6843 BGP_CLEAR_SOFT_OUT, argv[idx_word]->arg);
6844}
01080f7c 6845
718e3744 6846DEFUN (clear_ip_bgp_external_soft_out,
f412b39a 6847 clear_ip_bgp_external_soft_out_cmd,
8334fd5a 6848 "clear ip bgp [<view|vrf> WORD] external [soft] out",
718e3744 6849 CLEAR_STR
6850 IP_STR
6851 BGP_STR
8334fd5a 6852 BGP_INSTANCE_HELP_STR
718e3744 6853 "Clear all external peers\n"
e0bce756
DS
6854 BGP_SOFT_STR
6855 BGP_SOFT_OUT_STR)
01080f7c 6856{
8334fd5a
DW
6857 int idx_view_vrf = 3;
6858 int idx_vrf = 4;
6859 char *vrf = NULL;
01080f7c 6860
8334fd5a
DW
6861 if (strmatch(argv[idx_view_vrf]->text, "view") || strmatch(argv[idx_view_vrf]->text, "vrf"))
6862 vrf = argv[idx_vrf]->arg;
6863
6864 return bgp_clear_vty (vty, vrf, AFI_IP, SAFI_UNICAST, clear_external,
01080f7c 6865 BGP_CLEAR_SOFT_OUT, NULL);
6866}
6867
718e3744 6868DEFUN (clear_ip_bgp_external_ipv4_soft_out,
6869 clear_ip_bgp_external_ipv4_soft_out_cmd,
8334fd5a 6870 "clear ip bgp external ipv4 <unicast|multicast> [soft] out",
718e3744 6871 CLEAR_STR
6872 IP_STR
6873 BGP_STR
6874 "Clear all external peers\n"
6875 "Address family\n"
6876 "Address Family modifier\n"
6877 "Address Family modifier\n"
e0bce756
DS
6878 BGP_SOFT_STR
6879 BGP_SOFT_OUT_STR)
718e3744 6880{
c500ae40
DW
6881 int idx_safi = 5;
6882 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
718e3744 6883 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
6884 BGP_CLEAR_SOFT_OUT, NULL);
6885
6886 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
6887 BGP_CLEAR_SOFT_OUT, NULL);
6888}
6889
01080f7c 6890DEFUN (clear_ip_bgp_instance_external_ipv4_soft_out,
6891 clear_ip_bgp_instance_external_ipv4_soft_out_cmd,
9ccf14f7 6892 "clear ip bgp <view|vrf> WORD external ipv4 <unicast|multicast> [soft] out",
01080f7c 6893 CLEAR_STR
6894 IP_STR
6895 BGP_STR
6896 BGP_INSTANCE_HELP_STR
6897 "Clear all external peers\n"
6898 "Address family\n"
6899 "Address Family modifier\n"
6900 "Address Family modifier\n"
6901 BGP_SOFT_STR
6902 BGP_SOFT_OUT_STR)
6903{
c500ae40
DW
6904 int idx_word = 4;
6905 int idx_safi = 7;
6906 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
6907 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_external,
01080f7c 6908 BGP_CLEAR_SOFT_OUT, NULL);
6909
c500ae40 6910 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, clear_external,
01080f7c 6911 BGP_CLEAR_SOFT_OUT, NULL);
6912}
6913
718e3744 6914DEFUN (clear_bgp_external_soft_out,
6915 clear_bgp_external_soft_out_cmd,
8334fd5a 6916 "clear bgp [<view|vrf> WORD] [ipv6] external [soft] out",
718e3744 6917 CLEAR_STR
6918 BGP_STR
8334fd5a 6919 BGP_INSTANCE_HELP_STR
718e3744 6920 "Clear all external peers\n"
e0bce756
DS
6921 BGP_SOFT_STR
6922 BGP_SOFT_OUT_STR)
718e3744 6923{
8334fd5a
DW
6924 int idx_view_vrf = 2;
6925 int idx_vrf = 3;
6926 char *vrf = NULL;
01080f7c 6927
8334fd5a
DW
6928 if (strmatch(argv[idx_view_vrf]->text, "view") || strmatch(argv[idx_view_vrf]->text, "vrf"))
6929 vrf = argv[idx_vrf]->arg;
6930
6931 return bgp_clear_vty (vty, vrf, AFI_IP6, SAFI_UNICAST, clear_external,
718e3744 6932 BGP_CLEAR_SOFT_OUT, NULL);
6933}
6934
718e3744 6935DEFUN (clear_ip_bgp_as_soft_out,
6936 clear_ip_bgp_as_soft_out_cmd,
9ccf14f7 6937 "clear ip bgp [<view|vrf> WORD] (1-4294967295) [soft] out",
718e3744 6938 CLEAR_STR
6939 IP_STR
6940 BGP_STR
8334fd5a 6941 BGP_INSTANCE_HELP_STR
718e3744 6942 "Clear peers with the AS number\n"
e0bce756
DS
6943 BGP_SOFT_STR
6944 BGP_SOFT_OUT_STR)
718e3744 6945{
8334fd5a
DW
6946 int idx_view_vrf = 3;
6947 int idx_vrf = 4;
6948 int idx_asn = 5;
6949 char *vrf = NULL;
01080f7c 6950
8334fd5a
DW
6951 if (strmatch(argv[idx_view_vrf]->text, "view") || strmatch(argv[idx_view_vrf]->text, "vrf"))
6952 vrf = argv[idx_vrf]->arg;
6953 else
6954 idx_asn -= 2;
718e3744 6955
8334fd5a
DW
6956 return bgp_clear_vty (vty, vrf, AFI_IP, SAFI_UNICAST, clear_as,
6957 BGP_CLEAR_SOFT_OUT, argv[idx_asn]->arg);
6958}
01080f7c 6959
718e3744 6960DEFUN (clear_ip_bgp_as_ipv4_soft_out,
6961 clear_ip_bgp_as_ipv4_soft_out_cmd,
9ccf14f7 6962 "clear ip bgp (1-4294967295) ipv4 <unicast|multicast> [soft] out",
718e3744 6963 CLEAR_STR
6964 IP_STR
6965 BGP_STR
6966 "Clear peers with the AS number\n"
6967 "Address family\n"
6968 "Address Family modifier\n"
6969 "Address Family modifier\n"
e0bce756
DS
6970 BGP_SOFT_STR
6971 BGP_SOFT_OUT_STR)
718e3744 6972{
c500ae40
DW
6973 int idx_number = 3;
6974 int idx_safi = 5;
6975 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
718e3744 6976 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
c500ae40 6977 BGP_CLEAR_SOFT_OUT, argv[idx_number]->arg);
718e3744 6978
6979 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
c500ae40 6980 BGP_CLEAR_SOFT_OUT, argv[idx_number]->arg);
718e3744 6981}
6982
01080f7c 6983DEFUN (clear_ip_bgp_instance_as_ipv4_soft_out,
6984 clear_ip_bgp_instance_as_ipv4_soft_out_cmd,
9ccf14f7 6985 "clear ip bgp <view|vrf> WORD (1-4294967295) ipv4 <unicast|multicast> [soft] out",
01080f7c 6986 CLEAR_STR
6987 IP_STR
6988 BGP_STR
6989 BGP_INSTANCE_HELP_STR
6990 "Clear peers with the AS number\n"
6991 "Address family\n"
6992 "Address Family modifier\n"
6993 "Address Family modifier\n"
6994 BGP_SOFT_STR
6995 BGP_SOFT_OUT_STR)
6996{
c500ae40
DW
6997 int idx_word = 4;
6998 int idx_number = 5;
6999 int idx_safi = 7;
7000 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
7001 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_as,
7002 BGP_CLEAR_SOFT_OUT, argv[idx_number]->arg);
01080f7c 7003
c500ae40
DW
7004 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, clear_as,
7005 BGP_CLEAR_SOFT_OUT, argv[idx_number]->arg);
01080f7c 7006}
7007
718e3744 7008DEFUN (clear_ip_bgp_as_vpnv4_soft_out,
7009 clear_ip_bgp_as_vpnv4_soft_out_cmd,
9ccf14f7 7010 "clear ip bgp (1-4294967295) vpnv4 unicast [soft] out",
718e3744 7011 CLEAR_STR
7012 IP_STR
7013 BGP_STR
7014 "Clear peers with the AS number\n"
7015 "Address family\n"
7016 "Address Family modifier\n"
e0bce756
DS
7017 BGP_SOFT_STR
7018 BGP_SOFT_OUT_STR)
718e3744 7019{
c500ae40 7020 int idx_number = 3;
718e3744 7021 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
c500ae40 7022 BGP_CLEAR_SOFT_OUT, argv[idx_number]->arg);
718e3744 7023}
7024
587ff0fd
LB
7025DEFUN (clear_ip_bgp_as_encap_soft_out,
7026 clear_ip_bgp_as_encap_soft_out_cmd,
9ccf14f7 7027 "clear ip bgp (1-4294967295) encap unicast [soft] out",
587ff0fd
LB
7028 CLEAR_STR
7029 IP_STR
7030 BGP_STR
7031 "Clear peers with the AS number\n"
7032 "Address family\n"
7033 "Address Family modifier\n"
7034 "Soft reconfig\n"
7035 "Soft reconfig outbound update\n")
7036{
c500ae40 7037 int idx_number = 3;
587ff0fd 7038 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_as,
c500ae40 7039 BGP_CLEAR_SOFT_OUT, argv[idx_number]->arg);
587ff0fd
LB
7040}
7041
718e3744 7042DEFUN (clear_bgp_as_soft_out,
7043 clear_bgp_as_soft_out_cmd,
9ccf14f7 7044 "clear bgp [<view|vrf> WORD] [ipv6] (1-4294967295) [soft] out",
718e3744 7045 CLEAR_STR
7046 BGP_STR
8334fd5a
DW
7047 BGP_INSTANCE_HELP_STR
7048 IPV6_STR
718e3744 7049 "Clear peers with the AS number\n"
e0bce756
DS
7050 BGP_SOFT_STR
7051 BGP_SOFT_OUT_STR)
718e3744 7052{
8334fd5a
DW
7053 int idx_view_vrf = 2;
7054 int idx_vrf = 3;
7055 int idx_asn = 4;
7056 char *vrf = NULL;
718e3744 7057
8334fd5a
DW
7058 if (strmatch(argv[idx_view_vrf]->text, "view") || strmatch(argv[idx_view_vrf]->text, "vrf"))
7059 vrf = argv[idx_vrf]->arg;
7060 else
7061 idx_asn -= 2;
01080f7c 7062
8334fd5a
DW
7063 return bgp_clear_vty (vty, vrf, AFI_IP6, SAFI_UNICAST, clear_as,
7064 BGP_CLEAR_SOFT_OUT, argv[idx_asn]->arg);
7065}
6b0655a2 7066
01080f7c 7067
718e3744 7068/* Inbound soft-reconfiguration */
7069DEFUN (clear_ip_bgp_all_soft_in,
7070 clear_ip_bgp_all_soft_in_cmd,
8334fd5a 7071 "clear ip bgp [<view|vrf> WORD] * [soft] in",
718e3744 7072 CLEAR_STR
7073 IP_STR
7074 BGP_STR
8334fd5a 7075 BGP_INSTANCE_HELP_STR
718e3744 7076 "Clear all peers\n"
e0bce756
DS
7077 BGP_SOFT_STR
7078 BGP_SOFT_IN_STR)
718e3744 7079{
8334fd5a
DW
7080 int idx_view_vrf = 3;
7081 int idx_vrf = 4;
7082 char *vrf = NULL;
718e3744 7083
8334fd5a
DW
7084 if (strmatch(argv[idx_view_vrf]->text, "view") || strmatch(argv[idx_view_vrf]->text, "vrf"))
7085 vrf = argv[idx_vrf]->arg;
7086
7087 return bgp_clear_vty (vty, vrf, AFI_IP, SAFI_UNICAST, clear_all,
718e3744 7088 BGP_CLEAR_SOFT_IN, NULL);
7089}
7090
718e3744 7091
718e3744 7092DEFUN (clear_ip_bgp_all_in_prefix_filter,
7093 clear_ip_bgp_all_in_prefix_filter_cmd,
8334fd5a 7094 "clear ip bgp [<view|vrf> WORD] * in prefix-filter",
718e3744 7095 CLEAR_STR
7096 IP_STR
7097 BGP_STR
8334fd5a 7098 BGP_INSTANCE_HELP_STR
718e3744 7099 "Clear all peers\n"
e0bce756 7100 BGP_SOFT_IN_STR
718e3744 7101 "Push out prefix-list ORF and do inbound soft reconfig\n")
7102{
8334fd5a
DW
7103 int idx_view_vrf = 3;
7104 int idx_vrf = 4;
7105 char *vrf = NULL;
718e3744 7106
8334fd5a
DW
7107 if (strmatch(argv[idx_view_vrf]->text, "view") || strmatch(argv[idx_view_vrf]->text, "vrf"))
7108 vrf = argv[idx_vrf]->arg;
7109
7110 return bgp_clear_vty (vty, vrf, AFI_IP, SAFI_UNICAST, clear_all,
718e3744 7111 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7112}
7113
718e3744 7114DEFUN (clear_ip_bgp_all_ipv4_soft_in,
7115 clear_ip_bgp_all_ipv4_soft_in_cmd,
8334fd5a 7116 "clear ip bgp * ipv4 <unicast|multicast> [soft] in",
718e3744 7117 CLEAR_STR
7118 IP_STR
7119 BGP_STR
7120 "Clear all peers\n"
7121 "Address family\n"
7122 "Address Family modifier\n"
7123 "Address Family modifier\n"
e0bce756
DS
7124 BGP_SOFT_STR
7125 BGP_SOFT_IN_STR)
718e3744 7126{
c500ae40
DW
7127 int idx_safi = 5;
7128 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
718e3744 7129 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
7130 BGP_CLEAR_SOFT_IN, NULL);
7131
7132 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
7133 BGP_CLEAR_SOFT_IN, NULL);
7134}
7135
718e3744 7136DEFUN (clear_ip_bgp_instance_all_ipv4_soft_in,
7137 clear_ip_bgp_instance_all_ipv4_soft_in_cmd,
9ccf14f7 7138 "clear ip bgp <view|vrf> WORD * ipv4 <unicast|multicast> [soft] in",
718e3744 7139 CLEAR_STR
7140 IP_STR
7141 BGP_STR
8386ac43 7142 BGP_INSTANCE_HELP_STR
718e3744 7143 "Clear all peers\n"
7144 "Address family\n"
7145 "Address Family modifier\n"
7146 "Address Family modifier\n"
e0bce756
DS
7147 BGP_SOFT_STR
7148 BGP_SOFT_IN_STR)
718e3744 7149{
c500ae40
DW
7150 int idx_word = 4;
7151 int idx_safi = 7;
7152 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
7153 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_all,
718e3744 7154 BGP_CLEAR_SOFT_IN, NULL);
7155
c500ae40 7156 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, clear_all,
718e3744 7157 BGP_CLEAR_SOFT_IN, NULL);
7158}
7159
718e3744 7160
718e3744 7161
01080f7c 7162DEFUN (clear_ip_bgp_all_ipv4_in_prefix_filter,
7163 clear_ip_bgp_all_ipv4_in_prefix_filter_cmd,
6147e2c6 7164 "clear ip bgp * ipv4 <unicast|multicast> in prefix-filter",
718e3744 7165 CLEAR_STR
7166 IP_STR
7167 BGP_STR
7168 "Clear all peers\n"
7169 "Address family\n"
7170 "Address Family modifier\n"
7171 "Address Family modifier\n"
e0bce756 7172 BGP_SOFT_IN_STR
718e3744 7173 "Push out prefix-list ORF and do inbound soft reconfig\n")
7174{
c500ae40
DW
7175 int idx_safi = 5;
7176 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
01080f7c 7177 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
7178 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
718e3744 7179
01080f7c 7180 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
7181 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
718e3744 7182}
7183
7184DEFUN (clear_ip_bgp_all_vpnv4_soft_in,
7185 clear_ip_bgp_all_vpnv4_soft_in_cmd,
8334fd5a 7186 "clear ip bgp * vpnv4 unicast [soft] in",
718e3744 7187 CLEAR_STR
7188 IP_STR
7189 BGP_STR
7190 "Clear all peers\n"
7191 "Address family\n"
7192 "Address Family Modifier\n"
e0bce756
DS
7193 BGP_SOFT_STR
7194 BGP_SOFT_IN_STR)
718e3744 7195{
7196 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
7197 BGP_CLEAR_SOFT_IN, NULL);
7198}
7199
587ff0fd
LB
7200DEFUN (clear_ip_bgp_all_encap_soft_in,
7201 clear_ip_bgp_all_encap_soft_in_cmd,
8334fd5a 7202 "clear ip bgp * encap unicast [soft] in",
587ff0fd
LB
7203 CLEAR_STR
7204 IP_STR
7205 BGP_STR
7206 "Clear all peers\n"
7207 "Address family\n"
7208 "Address Family Modifier\n"
7209 "Soft reconfig\n"
7210 "Soft reconfig inbound update\n")
7211{
7212 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_all,
7213 BGP_CLEAR_SOFT_IN, NULL);
7214}
7215
718e3744 7216DEFUN (clear_bgp_all_soft_in,
7217 clear_bgp_all_soft_in_cmd,
8334fd5a 7218 "clear bgp [<view|vrf> WORD] [ipv6] * [soft] in",
718e3744 7219 CLEAR_STR
7220 BGP_STR
8334fd5a 7221 BGP_INSTANCE_HELP_STR
718e3744 7222 "Clear all peers\n"
e0bce756
DS
7223 BGP_SOFT_STR
7224 BGP_SOFT_IN_STR)
718e3744 7225{
8334fd5a
DW
7226 // dwalton
7227 int idx_view_vrf = 2;
7228 int idx_vrf = 3;
7229 char *vrf = NULL;
718e3744 7230
8334fd5a
DW
7231 if (strmatch(argv[idx_view_vrf]->text, "view") || strmatch(argv[idx_view_vrf]->text, "vrf"))
7232 vrf = argv[idx_vrf]->arg;
7233
7234 return bgp_clear_vty (vty, vrf, AFI_IP6, SAFI_UNICAST, clear_all,
718e3744 7235 BGP_CLEAR_SOFT_IN, NULL);
7236}
7237
718e3744 7238DEFUN (clear_bgp_all_in_prefix_filter,
7239 clear_bgp_all_in_prefix_filter_cmd,
8334fd5a 7240 "clear bgp [ipv6] * in prefix-filter",
718e3744 7241 CLEAR_STR
7242 BGP_STR
8334fd5a 7243 IPV6_STR
718e3744 7244 "Clear all peers\n"
e0bce756 7245 BGP_SOFT_IN_STR
718e3744 7246 "Push out prefix-list ORF and do inbound soft reconfig\n")
7247{
7248 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
7249 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7250}
7251
718e3744 7252DEFUN (clear_ip_bgp_peer_soft_in,
7253 clear_ip_bgp_peer_soft_in_cmd,
8334fd5a 7254 "clear ip bgp [<view|vrf> WORD] <A.B.C.D|WORD> [soft] in",
718e3744 7255 CLEAR_STR
7256 IP_STR
7257 BGP_STR
8334fd5a 7258 BGP_INSTANCE_HELP_STR
718e3744 7259 "BGP neighbor address to clear\n"
db64ea86 7260 "BGP neighbor on interface to clear\n"
e0bce756
DS
7261 BGP_SOFT_STR
7262 BGP_SOFT_IN_STR)
718e3744 7263{
8334fd5a
DW
7264 int idx_view_vrf = 2;
7265 int idx_vrf = 3;
c500ae40 7266 int idx_ipv4_word = 3;
8334fd5a 7267 char *vrf = NULL;
01080f7c 7268
8334fd5a
DW
7269 if (strmatch(argv[idx_view_vrf]->text, "view") || strmatch(argv[idx_view_vrf]->text, "vrf"))
7270 vrf = argv[idx_vrf]->arg;
7271 else
7272 idx_ipv4_word -= 2;
7273
7274 return bgp_clear_vty (vty, vrf, AFI_IP, SAFI_UNICAST, clear_peer,
c500ae40 7275 BGP_CLEAR_SOFT_IN, argv[idx_ipv4_word]->arg);
718e3744 7276}
7277
01080f7c 7278
718e3744 7279DEFUN (clear_ip_bgp_peer_in_prefix_filter,
7280 clear_ip_bgp_peer_in_prefix_filter_cmd,
6147e2c6 7281 "clear ip bgp <A.B.C.D|WORD> in prefix-filter",
718e3744 7282 CLEAR_STR
7283 IP_STR
7284 BGP_STR
7285 "BGP neighbor address to clear\n"
db64ea86 7286 "BGP neighbor on interface to clear\n"
e0bce756 7287 BGP_SOFT_IN_STR
718e3744 7288 "Push out the existing ORF prefix-list\n")
7289{
c500ae40 7290 int idx_ipv4_word = 3;
718e3744 7291 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
c500ae40 7292 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[idx_ipv4_word]->arg);
718e3744 7293}
7294
7295DEFUN (clear_ip_bgp_peer_ipv4_soft_in,
7296 clear_ip_bgp_peer_ipv4_soft_in_cmd,
8334fd5a 7297 "clear ip bgp <A.B.C.D|WORD> ipv4 <unicast|multicast> [soft] in",
718e3744 7298 CLEAR_STR
7299 IP_STR
7300 BGP_STR
7301 "BGP neighbor address to clear\n"
db64ea86 7302 "BGP neighbor on interface to clear\n"
718e3744 7303 "Address family\n"
7304 "Address Family modifier\n"
7305 "Address Family modifier\n"
8334fd5a
DW
7306 BGP_SOFT_STR
7307 BGP_SOFT_IN_STR)
7308{
7309 int idx_ipv4_word = 3;
7310 int idx_safi = 5;
7311 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
7312 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
7313 BGP_CLEAR_SOFT_IN, argv[idx_ipv4_word]->arg);
7314
7315 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
7316 BGP_CLEAR_SOFT_IN, argv[idx_ipv4_word]->arg);
7317}
7318
01080f7c 7319DEFUN (clear_ip_bgp_instance_peer_ipv4_soft_in,
7320 clear_ip_bgp_instance_peer_ipv4_soft_in_cmd,
9ccf14f7 7321 "clear ip bgp <view|vrf> WORD <A.B.C.D|WORD> ipv4 <unicast|multicast> [soft] in",
01080f7c 7322 CLEAR_STR
7323 IP_STR
7324 BGP_STR
7325 BGP_INSTANCE_HELP_STR
7326 "BGP neighbor address to clear\n"
7327 "BGP neighbor on interface to clear\n"
7328 "Address family\n"
7329 "Address Family modifier\n"
7330 "Address Family modifier\n"
7331 BGP_SOFT_STR
7332 BGP_SOFT_IN_STR)
7333{
c500ae40
DW
7334 int idx_word = 4;
7335 int idx_ipv4_word = 5;
7336 int idx_safi = 7;
7337 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
7338 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_peer,
7339 BGP_CLEAR_SOFT_IN, argv[idx_ipv4_word]->arg);
01080f7c 7340
c500ae40
DW
7341 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, clear_peer,
7342 BGP_CLEAR_SOFT_IN, argv[idx_ipv4_word]->arg);
01080f7c 7343}
7344
718e3744 7345
01080f7c 7346
718e3744 7347DEFUN (clear_ip_bgp_peer_ipv4_in_prefix_filter,
7348 clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd,
6147e2c6 7349 "clear ip bgp <A.B.C.D|WORD> ipv4 <unicast|multicast> in prefix-filter",
718e3744 7350 CLEAR_STR
7351 IP_STR
7352 BGP_STR
7353 "BGP neighbor address to clear\n"
db64ea86 7354 "BGP neighbor on interface to clear\n"
718e3744 7355 "Address family\n"
7356 "Address Family modifier\n"
7357 "Address Family modifier\n"
e0bce756 7358 BGP_SOFT_IN_STR
718e3744 7359 "Push out the existing ORF prefix-list\n")
7360{
c500ae40
DW
7361 int idx_ipv4_word = 3;
7362 int idx_safi = 5;
7363 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
718e3744 7364 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
c500ae40 7365 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[idx_ipv4_word]->arg);
718e3744 7366
7367 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
c500ae40 7368 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[idx_ipv4_word]->arg);
718e3744 7369}
7370
7371DEFUN (clear_ip_bgp_peer_vpnv4_soft_in,
7372 clear_ip_bgp_peer_vpnv4_soft_in_cmd,
8334fd5a 7373 "clear ip bgp <A.B.C.D|WORD> vpnv4 unicast [soft] in",
718e3744 7374 CLEAR_STR
7375 IP_STR
7376 BGP_STR
7377 "BGP neighbor address to clear\n"
db64ea86 7378 "BGP neighbor on interface to clear\n"
718e3744 7379 "Address family\n"
7380 "Address Family Modifier\n"
f412b39a 7381 BGP_SOFT_STR
01080f7c 7382 BGP_SOFT_IN_STR)
f412b39a 7383{
c500ae40 7384 int idx_ipv4_word = 3;
f412b39a 7385 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
c500ae40 7386 BGP_CLEAR_SOFT_IN, argv[idx_ipv4_word]->arg);
f412b39a
DW
7387}
7388
f412b39a
DW
7389DEFUN (clear_ip_bgp_peer_encap_soft_in,
7390 clear_ip_bgp_peer_encap_soft_in_cmd,
8334fd5a 7391 "clear ip bgp A.B.C.D encap unicast [soft] in",
718e3744 7392 CLEAR_STR
f412b39a 7393 IP_STR
718e3744 7394 BGP_STR
718e3744 7395 "BGP neighbor address to clear\n"
f412b39a
DW
7396 "Address family\n"
7397 "Address Family Modifier\n"
7398 "Soft reconfig\n"
7399 "Soft reconfig inbound update\n")
7400{
c500ae40 7401 int idx_ipv4 = 3;
f412b39a 7402 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_peer,
c500ae40 7403 BGP_CLEAR_SOFT_IN, argv[idx_ipv4]->arg);
f412b39a 7404}
718e3744 7405
f412b39a
DW
7406DEFUN (clear_bgp_peer_soft_in,
7407 clear_bgp_peer_soft_in_cmd,
8334fd5a 7408 "clear bgp [<view|vrf> WORD] [ipv6] <A.B.C.D|X:X::X:X|WORD> [soft] in",
01080f7c 7409 CLEAR_STR
7410 BGP_STR
8334fd5a 7411 BGP_INSTANCE_HELP_STR
01080f7c 7412 "BGP neighbor address to clear\n"
7413 "BGP IPv6 neighbor to clear\n"
7414 "BGP neighbor on interface to clear\n"
f412b39a 7415 BGP_SOFT_STR
01080f7c 7416 BGP_SOFT_IN_STR)
f412b39a 7417{
8334fd5a
DW
7418 int idx_view_vrf = 2;
7419 int idx_vrf = 3;
7420 int idx_ipv6 = 4;
7421 int idx_peer = 5;
7422 char *vrf = NULL;
f412b39a 7423
8334fd5a
DW
7424 if (strmatch(argv[idx_view_vrf]->text, "view") || strmatch(argv[idx_view_vrf]->text, "vrf"))
7425 vrf = argv[idx_vrf]->arg;
7426 else
7427 {
7428 idx_ipv6 -= 2;
7429 idx_peer -= 2;
7430 }
f412b39a 7431
8334fd5a
DW
7432 if (!strmatch(argv[idx_ipv6]->text, "ipv6"))
7433 idx_peer--;
f412b39a 7434
8334fd5a
DW
7435 return bgp_clear_vty (vty, vrf, AFI_IP6, SAFI_UNICAST, clear_peer,
7436 BGP_CLEAR_SOFT_IN, argv[idx_peer]->arg);
7437}
f412b39a 7438
01080f7c 7439
f412b39a
DW
7440/*
7441 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
7442 * "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) in prefix-filter",
7443 * CLEAR_STR
7444 * BGP_STR
7445 * "Address family\n"
7446 * "BGP neighbor address to clear\n"
7447 * "BGP IPv6 neighbor to clear\n"
7448 * "BGP neighbor on interface to clear\n"
7449 * BGP_SOFT_IN_STR
7450 * "Push out the existing ORF prefix-list\n"
7451 *
7452 */
718e3744 7453DEFUN (clear_bgp_peer_in_prefix_filter,
7454 clear_bgp_peer_in_prefix_filter_cmd,
6147e2c6 7455 "clear bgp <A.B.C.D|X:X::X:X|WORD> in prefix-filter",
718e3744 7456 CLEAR_STR
7457 BGP_STR
7458 "BGP neighbor address to clear\n"
7459 "BGP IPv6 neighbor to clear\n"
a80beece 7460 "BGP neighbor on interface to clear\n"
e0bce756 7461 BGP_SOFT_IN_STR
718e3744 7462 "Push out the existing ORF prefix-list\n")
7463{
c500ae40 7464 int idx_peer = 2;
718e3744 7465 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
c500ae40 7466 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[idx_peer]->arg);
718e3744 7467}
7468
718e3744 7469
f412b39a
DW
7470/*
7471 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9ccf14f7 7472 * "clear ip bgp <view|vrf> WORD peer-group WORD soft in",
f412b39a
DW
7473 * CLEAR_STR
7474 * IP_STR
7475 * BGP_STR
7476 * BGP_INSTANCE_HELP_STR
7477 * "Clear all members of peer-group\n"
7478 * "BGP peer-group name\n"
7479 * BGP_SOFT_STR
7480 * BGP_SOFT_IN_STR
7481 *
7482 * "clear ip bgp peer-group WORD in",
7483 * CLEAR_STR
7484 * IP_STR
7485 * BGP_STR
7486 * "Clear all members of peer-group\n"
7487 * "BGP peer-group name\n"
7488 * BGP_SOFT_IN_STR
7489 *
9ccf14f7 7490 * "clear ip bgp <view|vrf> WORD peer-group WORD in",
f412b39a
DW
7491 * CLEAR_STR
7492 * IP_STR
7493 * BGP_STR
7494 * BGP_INSTANCE_HELP_STR
7495 * "Clear all members of peer-group\n"
7496 * "BGP peer-group name\n"
7497 * BGP_SOFT_IN_STR
7498 *
7499 */
718e3744 7500DEFUN (clear_ip_bgp_peer_group_soft_in,
7501 clear_ip_bgp_peer_group_soft_in_cmd,
7502 "clear ip bgp peer-group WORD soft in",
7503 CLEAR_STR
7504 IP_STR
7505 BGP_STR
7506 "Clear all members of peer-group\n"
7507 "BGP peer-group name\n"
e0bce756
DS
7508 BGP_SOFT_STR
7509 BGP_SOFT_IN_STR)
718e3744 7510{
c500ae40 7511 int idx_word = 4;
01080f7c 7512 if (argc == 3)
7513 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group,
7514 BGP_CLEAR_SOFT_IN, argv[2]);
7515
718e3744 7516 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
c500ae40 7517 BGP_CLEAR_SOFT_IN, argv[idx_word]->arg);
718e3744 7518}
7519
01080f7c 7520
718e3744 7521
01080f7c 7522
718e3744 7523DEFUN (clear_ip_bgp_peer_group_in_prefix_filter,
7524 clear_ip_bgp_peer_group_in_prefix_filter_cmd,
7525 "clear ip bgp peer-group WORD in prefix-filter",
7526 CLEAR_STR
7527 IP_STR
7528 BGP_STR
7529 "Clear all members of peer-group\n"
7530 "BGP peer-group name\n"
e0bce756 7531 BGP_SOFT_IN_STR
718e3744 7532 "Push out prefix-list ORF and do inbound soft reconfig\n")
7533{
c500ae40 7534 int idx_word = 4;
718e3744 7535 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
c500ae40 7536 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[idx_word]->arg);
718e3744 7537}
7538
7539DEFUN (clear_ip_bgp_peer_group_ipv4_soft_in,
7540 clear_ip_bgp_peer_group_ipv4_soft_in_cmd,
8334fd5a 7541 "clear ip bgp peer-group WORD ipv4 <unicast|multicast> [soft] in",
718e3744 7542 CLEAR_STR
7543 IP_STR
7544 BGP_STR
7545 "Clear all members of peer-group\n"
7546 "BGP peer-group name\n"
7547 "Address family\n"
7548 "Address Family modifier\n"
7549 "Address Family modifier\n"
e0bce756
DS
7550 BGP_SOFT_STR
7551 BGP_SOFT_IN_STR)
718e3744 7552{
c500ae40
DW
7553 int idx_word = 4;
7554 int idx_safi = 6;
7555 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
718e3744 7556 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
c500ae40 7557 BGP_CLEAR_SOFT_IN, argv[idx_word]->arg);
718e3744 7558
7559 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
c500ae40 7560 BGP_CLEAR_SOFT_IN, argv[idx_word]->arg);
718e3744 7561}
7562
01080f7c 7563DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft_in,
7564 clear_ip_bgp_instance_peer_group_ipv4_soft_in_cmd,
9ccf14f7 7565 "clear ip bgp <view|vrf> WORD peer-group WORD ipv4 <unicast|multicast> [soft] in",
01080f7c 7566 CLEAR_STR
7567 IP_STR
7568 BGP_STR
7569 BGP_INSTANCE_HELP_STR
7570 "Clear all members of peer-group\n"
7571 "BGP peer-group name\n"
7572 "Address family\n"
7573 "Address Family modifier\n"
7574 "Address Family modifier\n"
7575 BGP_SOFT_STR
7576 BGP_SOFT_IN_STR)
7577{
c500ae40
DW
7578 int idx_word = 4;
7579 int idx_word_2 = 6;
7580 int idx_safi = 8;
7581 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
7582 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_group,
7583 BGP_CLEAR_SOFT_IN, argv[idx_word_2]->arg);
01080f7c 7584
c500ae40
DW
7585 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, clear_group,
7586 BGP_CLEAR_SOFT_IN, argv[idx_word_2]->arg);
01080f7c 7587}
7588
718e3744 7589
01080f7c 7590
718e3744 7591DEFUN (clear_ip_bgp_peer_group_ipv4_in_prefix_filter,
7592 clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd,
6147e2c6 7593 "clear ip bgp peer-group WORD ipv4 <unicast|multicast> in prefix-filter",
718e3744 7594 CLEAR_STR
7595 IP_STR
7596 BGP_STR
7597 "Clear all members of peer-group\n"
7598 "BGP peer-group name\n"
7599 "Address family\n"
7600 "Address Family modifier\n"
7601 "Address Family modifier\n"
e0bce756 7602 BGP_SOFT_IN_STR
718e3744 7603 "Push out prefix-list ORF and do inbound soft reconfig\n")
7604{
c500ae40
DW
7605 int idx_word = 4;
7606 int idx_safi = 6;
7607 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
718e3744 7608 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
c500ae40 7609 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[idx_word]->arg);
718e3744 7610
7611 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
c500ae40 7612 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[idx_word]->arg);
718e3744 7613}
7614
f412b39a
DW
7615/*
7616 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
7617 * "clear bgp ipv6 peer-group WORD in",
7618 * CLEAR_STR
7619 * BGP_STR
7620 * "Address family\n"
7621 * "Clear all members of peer-group\n"
7622 * "BGP peer-group name\n"
7623 * BGP_SOFT_IN_STR
7624 *
9ccf14f7 7625 * "clear bgp <view|vrf> WORD ipv6 peer-group WORD soft in",
f412b39a
DW
7626 * CLEAR_STR
7627 * BGP_STR
7628 * BGP_INSTANCE_HELP_STR
7629 * "Address family\n"
7630 * "Clear all members of peer-group\n"
7631 * "BGP peer-group name\n"
7632 * BGP_SOFT_STR
7633 * BGP_SOFT_IN_STR
7634 *
9ccf14f7 7635 * "clear bgp <view|vrf> WORD peer-group WORD soft in",
f412b39a
DW
7636 * CLEAR_STR
7637 * BGP_STR
7638 * BGP_INSTANCE_HELP_STR
7639 * "Clear all members of peer-group\n"
7640 * "BGP peer-group name\n"
7641 * BGP_SOFT_STR
7642 * BGP_SOFT_IN_STR
7643 *
7644 * "clear bgp peer-group WORD in",
7645 * CLEAR_STR
7646 * BGP_STR
7647 * "Clear all members of peer-group\n"
7648 * "BGP peer-group name\n"
7649 * BGP_SOFT_IN_STR
7650 *
9ccf14f7 7651 * "clear bgp <view|vrf> WORD peer-group WORD in",
f412b39a
DW
7652 * CLEAR_STR
7653 * BGP_STR
7654 * BGP_INSTANCE_HELP_STR
7655 * "Clear all members of peer-group\n"
7656 * "BGP peer-group name\n"
7657 * BGP_SOFT_IN_STR
7658 *
7659 * "clear bgp ipv6 peer-group WORD soft in",
7660 * CLEAR_STR
7661 * BGP_STR
7662 * "Address family\n"
7663 * "Clear all members of peer-group\n"
7664 * "BGP peer-group name\n"
7665 * BGP_SOFT_STR
7666 * BGP_SOFT_IN_STR
7667 *
9ccf14f7 7668 * "clear bgp <view|vrf> WORD ipv6 peer-group WORD in",
f412b39a
DW
7669 * CLEAR_STR
7670 * BGP_STR
7671 * BGP_INSTANCE_HELP_STR
7672 * "Address family\n"
7673 * "Clear all members of peer-group\n"
7674 * "BGP peer-group name\n"
7675 * BGP_SOFT_IN_STR
7676 *
7677 */
718e3744 7678DEFUN (clear_bgp_peer_group_soft_in,
7679 clear_bgp_peer_group_soft_in_cmd,
7680 "clear bgp peer-group WORD soft in",
7681 CLEAR_STR
7682 BGP_STR
7683 "Clear all members of peer-group\n"
7684 "BGP peer-group name\n"
e0bce756
DS
7685 BGP_SOFT_STR
7686 BGP_SOFT_IN_STR)
718e3744 7687{
c500ae40 7688 int idx_word = 3;
01080f7c 7689 if (argc == 3)
7690 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_group,
7691 BGP_CLEAR_SOFT_IN, argv[2]);
7692
718e3744 7693 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
c500ae40 7694 BGP_CLEAR_SOFT_IN, argv[idx_word]->arg);
718e3744 7695}
7696
f412b39a
DW
7697/*
7698 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
7699 * "clear bgp ipv6 peer-group WORD in prefix-filter",
7700 * CLEAR_STR
7701 * BGP_STR
7702 * "Address family\n"
7703 * "Clear all members of peer-group\n"
7704 * "BGP peer-group name\n"
7705 * BGP_SOFT_IN_STR
7706 * "Push out prefix-list ORF and do inbound soft reconfig\n"
7707 *
7708 */
718e3744 7709DEFUN (clear_bgp_peer_group_in_prefix_filter,
7710 clear_bgp_peer_group_in_prefix_filter_cmd,
7711 "clear bgp peer-group WORD in prefix-filter",
7712 CLEAR_STR
7713 BGP_STR
7714 "Clear all members of peer-group\n"
7715 "BGP peer-group name\n"
e0bce756 7716 BGP_SOFT_IN_STR
718e3744 7717 "Push out prefix-list ORF and do inbound soft reconfig\n")
7718{
c500ae40 7719 int idx_word = 3;
718e3744 7720 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
c500ae40 7721 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[idx_word]->arg);
718e3744 7722}
7723
718e3744 7724
f412b39a
DW
7725/*
7726 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
7727 * "clear ip bgp external in",
7728 * CLEAR_STR
7729 * IP_STR
7730 * BGP_STR
7731 * "Clear all external peers\n"
7732 * BGP_SOFT_IN_STR
7733 *
9ccf14f7 7734 * "clear ip bgp <view|vrf> WORD external in",
f412b39a
DW
7735 * CLEAR_STR
7736 * IP_STR
7737 * BGP_STR
7738 * BGP_INSTANCE_HELP_STR
7739 * "Clear all external peers\n"
7740 * BGP_SOFT_IN_STR
7741 *
9ccf14f7 7742 * "clear ip bgp <view|vrf> WORD external soft in",
f412b39a
DW
7743 * CLEAR_STR
7744 * IP_STR
7745 * BGP_STR
7746 * BGP_INSTANCE_HELP_STR
7747 * "Clear all external peers\n"
7748 * BGP_SOFT_STR
7749 * BGP_SOFT_IN_STR
7750 *
7751 */
718e3744 7752DEFUN (clear_ip_bgp_external_soft_in,
7753 clear_ip_bgp_external_soft_in_cmd,
7754 "clear ip bgp external soft in",
7755 CLEAR_STR
7756 IP_STR
7757 BGP_STR
7758 "Clear all external peers\n"
e0bce756
DS
7759 BGP_SOFT_STR
7760 BGP_SOFT_IN_STR)
718e3744 7761{
01080f7c 7762 if (argc == 2)
7763 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external,
7764 BGP_CLEAR_SOFT_IN, NULL);
7765
718e3744 7766 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7767 BGP_CLEAR_SOFT_IN, NULL);
7768}
7769
01080f7c 7770
718e3744 7771
01080f7c 7772
718e3744 7773DEFUN (clear_ip_bgp_external_in_prefix_filter,
7774 clear_ip_bgp_external_in_prefix_filter_cmd,
7775 "clear ip bgp external in prefix-filter",
7776 CLEAR_STR
7777 IP_STR
7778 BGP_STR
7779 "Clear all external peers\n"
e0bce756 7780 BGP_SOFT_IN_STR
718e3744 7781 "Push out prefix-list ORF and do inbound soft reconfig\n")
7782{
7783 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7784 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7785}
7786
7787DEFUN (clear_ip_bgp_external_ipv4_soft_in,
7788 clear_ip_bgp_external_ipv4_soft_in_cmd,
8334fd5a 7789 "clear ip bgp external ipv4 <unicast|multicast> [soft] in",
718e3744 7790 CLEAR_STR
7791 IP_STR
7792 BGP_STR
7793 "Clear all external peers\n"
7794 "Address family\n"
7795 "Address Family modifier\n"
7796 "Address Family modifier\n"
e0bce756
DS
7797 BGP_SOFT_STR
7798 BGP_SOFT_IN_STR)
718e3744 7799{
c500ae40
DW
7800 int idx_safi = 5;
7801 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
718e3744 7802 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
7803 BGP_CLEAR_SOFT_IN, NULL);
7804
7805 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7806 BGP_CLEAR_SOFT_IN, NULL);
7807}
7808
01080f7c 7809DEFUN (clear_ip_bgp_instance_external_ipv4_soft_in,
7810 clear_ip_bgp_instance_external_ipv4_soft_in_cmd,
9ccf14f7 7811 "clear ip bgp <view|vrf> WORD external ipv4 <unicast|multicast> [soft] in",
01080f7c 7812 CLEAR_STR
7813 IP_STR
7814 BGP_STR
7815 BGP_INSTANCE_HELP_STR
7816 "Clear all external peers\n"
7817 "Address family\n"
7818 "Address Family modifier\n"
7819 "Address Family modifier\n"
7820 BGP_SOFT_STR
7821 BGP_SOFT_IN_STR)
7822{
c500ae40
DW
7823 int idx_word = 4;
7824 int idx_safi = 7;
7825 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
7826 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_external,
01080f7c 7827 BGP_CLEAR_SOFT_IN, NULL);
7828
c500ae40 7829 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, clear_external,
01080f7c 7830 BGP_CLEAR_SOFT_IN, NULL);
7831}
7832
718e3744 7833
01080f7c 7834
718e3744 7835DEFUN (clear_ip_bgp_external_ipv4_in_prefix_filter,
7836 clear_ip_bgp_external_ipv4_in_prefix_filter_cmd,
6147e2c6 7837 "clear ip bgp external ipv4 <unicast|multicast> in prefix-filter",
718e3744 7838 CLEAR_STR
7839 IP_STR
7840 BGP_STR
7841 "Clear all external peers\n"
7842 "Address family\n"
7843 "Address Family modifier\n"
7844 "Address Family modifier\n"
e0bce756 7845 BGP_SOFT_IN_STR
718e3744 7846 "Push out prefix-list ORF and do inbound soft reconfig\n")
7847{
c500ae40
DW
7848 int idx_safi = 5;
7849 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
718e3744 7850 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
7851 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7852
7853 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7854 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7855}
7856
f412b39a
DW
7857/*
7858 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9ccf14f7 7859 * "clear bgp <view|vrf> WORD external in",
f412b39a
DW
7860 * CLEAR_STR
7861 * BGP_STR
7862 * BGP_INSTANCE_HELP_STR
7863 * "Clear all external peers\n"
7864 * BGP_SOFT_IN_STR
7865 *
9ccf14f7 7866 * "clear bgp <view|vrf> WORD ipv6 external soft in",
f412b39a
DW
7867 * CLEAR_STR
7868 * BGP_STR
7869 * BGP_INSTANCE_HELP_STR
7870 * "Address family\n"
7871 * "Clear all external peers\n"
7872 * BGP_SOFT_STR
7873 * BGP_SOFT_IN_STR
7874 *
9ccf14f7 7875 * "clear bgp <view|vrf> WORD external soft in",
f412b39a
DW
7876 * CLEAR_STR
7877 * BGP_STR
7878 * BGP_INSTANCE_HELP_STR
7879 * "Clear all external peers\n"
7880 * BGP_SOFT_STR
7881 * BGP_SOFT_IN_STR
7882 *
9ccf14f7 7883 * "clear bgp <view|vrf> WORD ipv6 external WORD in",
f412b39a
DW
7884 * CLEAR_STR
7885 * BGP_STR
7886 * BGP_INSTANCE_HELP_STR
7887 * "Address family\n"
7888 * "Clear all external peers\n"
7889 * BGP_SOFT_IN_STR
7890 *
7891 * "clear bgp ipv6 external soft in",
7892 * CLEAR_STR
7893 * BGP_STR
7894 * "Address family\n"
7895 * "Clear all external peers\n"
7896 * BGP_SOFT_STR
7897 * BGP_SOFT_IN_STR
7898 *
7899 * "clear bgp ipv6 external WORD in",
7900 * CLEAR_STR
7901 * BGP_STR
7902 * "Address family\n"
7903 * "Clear all external peers\n"
7904 * BGP_SOFT_IN_STR
7905 *
7906 * "clear bgp external in",
7907 * CLEAR_STR
7908 * BGP_STR
7909 * "Clear all external peers\n"
7910 * BGP_SOFT_IN_STR
7911 *
7912 */
718e3744 7913DEFUN (clear_bgp_external_soft_in,
7914 clear_bgp_external_soft_in_cmd,
7915 "clear bgp external soft in",
7916 CLEAR_STR
7917 BGP_STR
7918 "Clear all external peers\n"
e0bce756
DS
7919 BGP_SOFT_STR
7920 BGP_SOFT_IN_STR)
718e3744 7921{
01080f7c 7922 if (argc == 2)
7923 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_external,
7924 BGP_CLEAR_SOFT_IN, NULL);
7925
718e3744 7926 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
7927 BGP_CLEAR_SOFT_IN, NULL);
7928}
7929
f412b39a
DW
7930/*
7931 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
7932 * "clear bgp ipv6 external in prefix-filter",
7933 * CLEAR_STR
7934 * BGP_STR
7935 * "Address family\n"
7936 * "Clear all external peers\n"
7937 * BGP_SOFT_IN_STR
7938 * "Push out prefix-list ORF and do inbound soft reconfig\n"
7939 *
7940 */
718e3744 7941DEFUN (clear_bgp_external_in_prefix_filter,
7942 clear_bgp_external_in_prefix_filter_cmd,
7943 "clear bgp external in prefix-filter",
7944 CLEAR_STR
7945 BGP_STR
7946 "Clear all external peers\n"
e0bce756 7947 BGP_SOFT_IN_STR
718e3744 7948 "Push out prefix-list ORF and do inbound soft reconfig\n")
f412b39a
DW
7949{
7950 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
7951 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7952}
718e3744 7953
f412b39a
DW
7954
7955/*
7956 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9ccf14f7 7957 * "clear ip bgp (1-4294967295) in",
f412b39a
DW
7958 * CLEAR_STR
7959 * IP_STR
7960 * BGP_STR
7961 * "Clear peers with the AS number\n"
7962 * BGP_SOFT_IN_STR
7963 *
9ccf14f7 7964 * "clear ip bgp <view|vrf> WORD (1-4294967295) in",
f412b39a
DW
7965 * CLEAR_STR
7966 * IP_STR
7967 * BGP_STR
7968 * BGP_INSTANCE_HELP_STR
7969 * "Clear peers with the AS number\n"
7970 * BGP_SOFT_IN_STR
7971 *
9ccf14f7 7972 * "clear ip bgp <view|vrf> WORD (1-4294967295) soft in",
f412b39a
DW
7973 * CLEAR_STR
7974 * IP_STR
7975 * BGP_STR
7976 * BGP_INSTANCE_HELP_STR
7977 * "Clear peers with the AS number\n"
7978 * BGP_SOFT_STR
7979 * BGP_SOFT_IN_STR
7980 *
7981 */
718e3744 7982DEFUN (clear_ip_bgp_as_soft_in,
7983 clear_ip_bgp_as_soft_in_cmd,
9ccf14f7 7984 "clear ip bgp (1-4294967295) soft in",
718e3744 7985 CLEAR_STR
7986 IP_STR
7987 BGP_STR
7988 "Clear peers with the AS number\n"
e0bce756
DS
7989 BGP_SOFT_STR
7990 BGP_SOFT_IN_STR)
718e3744 7991{
c500ae40 7992 int idx_number = 3;
01080f7c 7993 if (argc == 3)
7994 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as,
7995 BGP_CLEAR_SOFT_IN, argv[2]);
7996
718e3744 7997 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
c500ae40 7998 BGP_CLEAR_SOFT_IN, argv[idx_number]->arg);
718e3744 7999}
8000
718e3744 8001DEFUN (clear_ip_bgp_as_in_prefix_filter,
8002 clear_ip_bgp_as_in_prefix_filter_cmd,
9ccf14f7 8003 "clear ip bgp (1-4294967295) in prefix-filter",
718e3744 8004 CLEAR_STR
8005 IP_STR
8006 BGP_STR
8007 "Clear peers with the AS number\n"
e0bce756 8008 BGP_SOFT_IN_STR
718e3744 8009 "Push out prefix-list ORF and do inbound soft reconfig\n")
8010{
c500ae40 8011 int idx_number = 3;
718e3744 8012 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
c500ae40 8013 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[idx_number]->arg);
718e3744 8014}
8015
8016DEFUN (clear_ip_bgp_as_ipv4_soft_in,
8017 clear_ip_bgp_as_ipv4_soft_in_cmd,
9ccf14f7 8018 "clear ip bgp (1-4294967295) ipv4 <unicast|multicast> [soft] in",
718e3744 8019 CLEAR_STR
8020 IP_STR
8021 BGP_STR
8022 "Clear peers with the AS number\n"
8023 "Address family\n"
8024 "Address Family modifier\n"
8025 "Address Family modifier\n"
e0bce756
DS
8026 BGP_SOFT_STR
8027 BGP_SOFT_IN_STR)
718e3744 8028{
c500ae40
DW
8029 int idx_number = 3;
8030 int idx_safi = 5;
8031 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
718e3744 8032 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
c500ae40 8033 BGP_CLEAR_SOFT_IN, argv[idx_number]->arg);
718e3744 8034
8035 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
c500ae40 8036 BGP_CLEAR_SOFT_IN, argv[idx_number]->arg);
718e3744 8037}
8038
01080f7c 8039DEFUN (clear_ip_bgp_instance_as_ipv4_soft_in,
8040 clear_ip_bgp_instance_as_ipv4_soft_in_cmd,
9ccf14f7 8041 "clear ip bgp <view|vrf> WORD (1-4294967295) ipv4 <unicast|multicast> [soft] in",
01080f7c 8042 CLEAR_STR
8043 IP_STR
8044 BGP_STR
8045 BGP_INSTANCE_HELP_STR
8046 "Clear peers with the AS number\n"
8047 "Address family\n"
8048 "Address Family modifier\n"
8049 "Address Family modifier\n"
8050 BGP_SOFT_STR
8051 BGP_SOFT_IN_STR)
8052{
c500ae40
DW
8053 int idx_word = 4;
8054 int idx_number = 5;
8055 int idx_safi = 7;
8056 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
8057 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_as,
8058 BGP_CLEAR_SOFT_IN, argv[idx_number]->arg);
01080f7c 8059
c500ae40
DW
8060 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, clear_as,
8061 BGP_CLEAR_SOFT_IN, argv[idx_number]->arg);
01080f7c 8062}
8063
718e3744 8064DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter,
8065 clear_ip_bgp_as_ipv4_in_prefix_filter_cmd,
9ccf14f7 8066 "clear ip bgp (1-4294967295) ipv4 <unicast|multicast> in prefix-filter",
718e3744 8067 CLEAR_STR
8068 IP_STR
8069 BGP_STR
8070 "Clear peers with the AS number\n"
8071 "Address family\n"
8072 "Address Family modifier\n"
8073 "Address Family modifier\n"
e0bce756 8074 BGP_SOFT_IN_STR
718e3744 8075 "Push out prefix-list ORF and do inbound soft reconfig\n")
8076{
c500ae40
DW
8077 int idx_number = 3;
8078 int idx_safi = 5;
8079 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
718e3744 8080 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
c500ae40 8081 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[idx_number]->arg);
718e3744 8082
8083 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
c500ae40 8084 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[idx_number]->arg);
718e3744 8085}
8086
8087DEFUN (clear_ip_bgp_as_vpnv4_soft_in,
8088 clear_ip_bgp_as_vpnv4_soft_in_cmd,
9ccf14f7 8089 "clear ip bgp (1-4294967295) vpnv4 unicast [soft] in",
718e3744 8090 CLEAR_STR
8091 IP_STR
8092 BGP_STR
8093 "Clear peers with the AS number\n"
8094 "Address family\n"
8095 "Address Family modifier\n"
e0bce756
DS
8096 BGP_SOFT_STR
8097 BGP_SOFT_IN_STR)
718e3744 8098{
c500ae40 8099 int idx_number = 3;
718e3744 8100 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
c500ae40 8101 BGP_CLEAR_SOFT_IN, argv[idx_number]->arg);
718e3744 8102}
8103
587ff0fd
LB
8104DEFUN (clear_ip_bgp_as_encap_soft_in,
8105 clear_ip_bgp_as_encap_soft_in_cmd,
9ccf14f7 8106 "clear ip bgp (1-4294967295) encap unicast [soft] in",
587ff0fd
LB
8107 CLEAR_STR
8108 IP_STR
8109 BGP_STR
8110 "Clear peers with the AS number\n"
8111 "Address family\n"
8112 "Address Family modifier\n"
8113 "Soft reconfig\n"
8114 "Soft reconfig inbound update\n")
8115{
c500ae40 8116 int idx_number = 3;
587ff0fd 8117 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_as,
c500ae40 8118 BGP_CLEAR_SOFT_IN, argv[idx_number]->arg);
587ff0fd
LB
8119}
8120
f412b39a
DW
8121/*
8122 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9ccf14f7 8123 * "clear bgp ipv6 (1-4294967295) in",
f412b39a
DW
8124 * CLEAR_STR
8125 * BGP_STR
8126 * "Address family\n"
8127 * "Clear peers with the AS number\n"
8128 * BGP_SOFT_IN_STR
8129 *
9ccf14f7 8130 * "clear bgp <view|vrf> WORD (1-4294967295) in",
f412b39a
DW
8131 * CLEAR_STR
8132 * BGP_STR
8133 * BGP_INSTANCE_HELP_STR
8134 * "Clear peers with the AS number\n"
8135 * BGP_SOFT_IN_STR
8136 *
9ccf14f7 8137 * "clear bgp <view|vrf> WORD ipv6 (1-4294967295) in",
f412b39a
DW
8138 * CLEAR_STR
8139 * BGP_STR
8140 * BGP_INSTANCE_HELP_STR
8141 * "Address family\n"
8142 * "Clear peers with the AS number\n"
8143 * BGP_SOFT_IN_STR
8144 *
9ccf14f7 8145 * "clear bgp ipv6 (1-4294967295) soft in",
f412b39a
DW
8146 * CLEAR_STR
8147 * BGP_STR
8148 * "Address family\n"
8149 * "Clear peers with the AS number\n"
8150 * BGP_SOFT_STR
8151 * BGP_SOFT_IN_STR
8152 *
9ccf14f7 8153 * "clear bgp <view|vrf> WORD (1-4294967295) soft in",
f412b39a
DW
8154 * CLEAR_STR
8155 * BGP_STR
8156 * BGP_INSTANCE_HELP_STR
8157 * "Clear peers with the AS number\n"
8158 * BGP_SOFT_STR
8159 * BGP_SOFT_IN_STR
8160 *
9ccf14f7 8161 * "clear bgp (1-4294967295) in",
f412b39a
DW
8162 * CLEAR_STR
8163 * BGP_STR
8164 * "Clear peers with the AS number\n"
8165 * BGP_SOFT_IN_STR
8166 *
9ccf14f7 8167 * "clear bgp <view|vrf> WORD ipv6 (1-4294967295) soft in",
f412b39a
DW
8168 * CLEAR_STR
8169 * BGP_STR
8170 * BGP_INSTANCE_HELP_STR
8171 * "Address family\n"
8172 * "Clear peers with the AS number\n"
8173 * BGP_SOFT_STR
8174 * BGP_SOFT_IN_STR
8175 *
8176 */
718e3744 8177DEFUN (clear_bgp_as_soft_in,
8178 clear_bgp_as_soft_in_cmd,
9ccf14f7 8179 "clear bgp (1-4294967295) soft in",
718e3744 8180 CLEAR_STR
8181 BGP_STR
8182 "Clear peers with the AS number\n"
e0bce756
DS
8183 BGP_SOFT_STR
8184 BGP_SOFT_IN_STR)
718e3744 8185{
c500ae40 8186 int idx_number = 2;
01080f7c 8187 if (argc == 3)
8188 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_as,
8189 BGP_CLEAR_SOFT_IN, argv[2]);
8190
718e3744 8191 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
c500ae40 8192 BGP_CLEAR_SOFT_IN, argv[idx_number]->arg);
718e3744 8193}
8194
f412b39a
DW
8195/*
8196 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9ccf14f7 8197 * "clear bgp ipv6 (1-4294967295) in prefix-filter",
f412b39a
DW
8198 * CLEAR_STR
8199 * BGP_STR
8200 * "Address family\n"
8201 * "Clear peers with the AS number\n"
8202 * BGP_SOFT_IN_STR
8203 * "Push out prefix-list ORF and do inbound soft reconfig\n"
8204 *
8205 */
718e3744 8206DEFUN (clear_bgp_as_in_prefix_filter,
8207 clear_bgp_as_in_prefix_filter_cmd,
9ccf14f7 8208 "clear bgp (1-4294967295) in prefix-filter",
718e3744 8209 CLEAR_STR
8210 BGP_STR
8211 "Clear peers with the AS number\n"
e0bce756 8212 BGP_SOFT_IN_STR
718e3744 8213 "Push out prefix-list ORF and do inbound soft reconfig\n")
8214{
c500ae40 8215 int idx_number = 2;
718e3744 8216 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
c500ae40 8217 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[idx_number]->arg);
718e3744 8218}
8219
6b0655a2 8220
718e3744 8221/* Both soft-reconfiguration */
f412b39a
DW
8222/*
8223 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9ccf14f7 8224 * "clear ip bgp <view|vrf> WORD * soft",
f412b39a
DW
8225 * CLEAR_STR
8226 * IP_STR
8227 * BGP_STR
8228 * BGP_INSTANCE_HELP_STR
8229 * "Clear all peers\n"
8230 * BGP_SOFT_STR
8231 *
8232 */
718e3744 8233DEFUN (clear_ip_bgp_all_soft,
8234 clear_ip_bgp_all_soft_cmd,
8235 "clear ip bgp * soft",
8236 CLEAR_STR
8237 IP_STR
8238 BGP_STR
8239 "Clear all peers\n"
e0bce756 8240 BGP_SOFT_STR)
718e3744 8241{
6aeb9e78
DS
8242 if (argc == 2)
8243 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all,
718e3744 8244 BGP_CLEAR_SOFT_BOTH, NULL);
8245
8246 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
8247 BGP_CLEAR_SOFT_BOTH, NULL);
8248}
8249
718e3744 8250DEFUN (clear_ip_bgp_all_ipv4_soft,
8251 clear_ip_bgp_all_ipv4_soft_cmd,
6147e2c6 8252 "clear ip bgp * ipv4 <unicast|multicast> soft",
718e3744 8253 CLEAR_STR
8254 IP_STR
8255 BGP_STR
8256 "Clear all peers\n"
8257 "Address family\n"
8258 "Address Family Modifier\n"
8259 "Address Family Modifier\n"
e0bce756 8260 BGP_SOFT_STR)
718e3744 8261{
c500ae40
DW
8262 int idx_safi = 5;
8263 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
718e3744 8264 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
8265 BGP_CLEAR_SOFT_BOTH, NULL);
8266
8267 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
8268 BGP_CLEAR_SOFT_BOTH, NULL);
8269}
8270
8271DEFUN (clear_ip_bgp_instance_all_ipv4_soft,
8272 clear_ip_bgp_instance_all_ipv4_soft_cmd,
9ccf14f7 8273 "clear ip bgp <view|vrf> WORD * ipv4 <unicast|multicast> soft",
718e3744 8274 CLEAR_STR
8275 IP_STR
8276 BGP_STR
8386ac43 8277 BGP_INSTANCE_HELP_STR
718e3744 8278 "Clear all peers\n"
8279 "Address family\n"
8280 "Address Family Modifier\n"
8281 "Address Family Modifier\n"
e0bce756 8282 BGP_SOFT_STR)
718e3744 8283{
c500ae40
DW
8284 int idx_word = 4;
8285 int idx_safi = 7;
8286 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
8287 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_all,
718e3744 8288 BGP_CLEAR_SOFT_BOTH, NULL);
8289
8290 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
8291 BGP_CLEAR_SOFT_BOTH, NULL);
8292}
8293
8294DEFUN (clear_ip_bgp_all_vpnv4_soft,
8295 clear_ip_bgp_all_vpnv4_soft_cmd,
8296 "clear ip bgp * vpnv4 unicast soft",
8297 CLEAR_STR
8298 IP_STR
8299 BGP_STR
8300 "Clear all peers\n"
8301 "Address family\n"
8302 "Address Family Modifier\n"
e0bce756 8303 BGP_SOFT_STR)
718e3744 8304{
8305 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
8306 BGP_CLEAR_SOFT_BOTH, argv[0]);
8307}
8308
587ff0fd
LB
8309DEFUN (clear_ip_bgp_all_encap_soft,
8310 clear_ip_bgp_all_encap_soft_cmd,
8311 "clear ip bgp * encap unicast soft",
8312 CLEAR_STR
8313 IP_STR
8314 BGP_STR
8315 "Clear all peers\n"
8316 "Address family\n"
8317 "Address Family Modifier\n"
8318 "Soft reconfig\n")
8319{
8320 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_all,
8321 BGP_CLEAR_SOFT_BOTH, argv[0]);
8322}
8323
f412b39a
DW
8324/*
8325 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
8326 * "clear bgp ipv6 * soft",
8327 * CLEAR_STR
8328 * BGP_STR
8329 * "Address family\n"
8330 * "Clear all peers\n"
8331 * BGP_SOFT_STR
8332 *
9ccf14f7 8333 * "clear bgp <view|vrf> WORD * soft",
f412b39a
DW
8334 * CLEAR_STR
8335 * BGP_STR
8336 * BGP_INSTANCE_HELP_STR
8337 * "Clear all peers\n"
8338 * BGP_SOFT_STR
8339 *
9ccf14f7 8340 * "clear bgp <view|vrf> WORD ipv6 * soft",
f412b39a
DW
8341 * CLEAR_STR
8342 * BGP_STR
8343 * BGP_INSTANCE_HELP_STR
8344 * "Address family\n"
8345 * "Clear all peers\n"
8346 * BGP_SOFT_STR
8347 *
8348 */
718e3744 8349DEFUN (clear_bgp_all_soft,
8350 clear_bgp_all_soft_cmd,
8351 "clear bgp * soft",
8352 CLEAR_STR
8353 BGP_STR
8354 "Clear all peers\n"
e0bce756 8355 BGP_SOFT_STR)
718e3744 8356{
6aeb9e78
DS
8357 if (argc == 2)
8358 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_all,
01080f7c 8359 BGP_CLEAR_SOFT_BOTH, NULL);
718e3744 8360
8361 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
01080f7c 8362 BGP_CLEAR_SOFT_BOTH, NULL);
718e3744 8363}
8364
f412b39a
DW
8365/*
8366 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9ccf14f7 8367 * "clear ip bgp <view|vrf> WORD (A.B.C.D|WORD) soft",
f412b39a
DW
8368 * CLEAR_STR
8369 * IP_STR
8370 * BGP_STR
8371 * BGP_INSTANCE_HELP_STR
8372 * "BGP neighbor address to clear\n"
8373 * "BGP neighbor on interface to clear\n"
8374 * BGP_SOFT_STR
8375 *
8376 */
718e3744 8377DEFUN (clear_ip_bgp_peer_soft,
8378 clear_ip_bgp_peer_soft_cmd,
6147e2c6 8379 "clear ip bgp <A.B.C.D|WORD> soft",
718e3744 8380 CLEAR_STR
8381 IP_STR
8382 BGP_STR
8383 "BGP neighbor address to clear\n"
db64ea86 8384 "BGP neighbor on interface to clear\n"
e0bce756 8385 BGP_SOFT_STR)
718e3744 8386{
c500ae40 8387 int idx_ipv4_word = 3;
01080f7c 8388 if (argc == 3)
8389 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer,
8390 BGP_CLEAR_SOFT_BOTH, argv[2]);
8391
718e3744 8392 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
c500ae40 8393 BGP_CLEAR_SOFT_BOTH, argv[idx_ipv4_word]->arg);
718e3744 8394}
8395
01080f7c 8396
718e3744 8397DEFUN (clear_ip_bgp_peer_ipv4_soft,
8398 clear_ip_bgp_peer_ipv4_soft_cmd,
6147e2c6 8399 "clear ip bgp <A.B.C.D|WORD> ipv4 <unicast|multicast> soft",
718e3744 8400 CLEAR_STR
8401 IP_STR
8402 BGP_STR
8403 "BGP neighbor address to clear\n"
db64ea86 8404 "BGP neighbor on interface to clear\n"
718e3744 8405 "Address family\n"
8406 "Address Family Modifier\n"
8407 "Address Family Modifier\n"
e0bce756 8408 BGP_SOFT_STR)
718e3744 8409{
c500ae40
DW
8410 int idx_ipv4_word = 3;
8411 int idx_safi = 5;
8412 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
718e3744 8413 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
c500ae40 8414 BGP_CLEAR_SOFT_BOTH, argv[idx_ipv4_word]->arg);
718e3744 8415
8416 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
c500ae40 8417 BGP_CLEAR_SOFT_BOTH, argv[idx_ipv4_word]->arg);
718e3744 8418}
8419
01080f7c 8420DEFUN (clear_ip_bgp_instance_peer_ipv4_soft,
8421 clear_ip_bgp_instance_peer_ipv4_soft_cmd,
9ccf14f7 8422 "clear ip bgp <view|vrf> WORD <A.B.C.D|WORD> ipv4 <unicast|multicast> soft",
01080f7c 8423 CLEAR_STR
8424 IP_STR
8425 BGP_STR
8426 BGP_INSTANCE_HELP_STR
8427 "BGP neighbor address to clear\n"
8428 "BGP neighbor on interface to clear\n"
8429 "Address family\n"
8430 "Address Family Modifier\n"
8431 "Address Family Modifier\n"
8432 BGP_SOFT_STR)
8433{
c500ae40
DW
8434 int idx_word = 4;
8435 int idx_ipv4_word = 5;
8436 int idx_safi = 7;
8437 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
8438 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_peer,
8439 BGP_CLEAR_SOFT_BOTH, argv[idx_ipv4_word]->arg);
01080f7c 8440
c500ae40
DW
8441 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, clear_peer,
8442 BGP_CLEAR_SOFT_BOTH, argv[idx_ipv4_word]->arg);
01080f7c 8443}
8444
718e3744 8445DEFUN (clear_ip_bgp_peer_vpnv4_soft,
8446 clear_ip_bgp_peer_vpnv4_soft_cmd,
6147e2c6 8447 "clear ip bgp <A.B.C.D|WORD> vpnv4 unicast soft",
718e3744 8448 CLEAR_STR
8449 IP_STR
8450 BGP_STR
8451 "BGP neighbor address to clear\n"
db64ea86 8452 "BGP neighbor on interface to clear\n"
718e3744 8453 "Address family\n"
8454 "Address Family Modifier\n"
e0bce756 8455 BGP_SOFT_STR)
718e3744 8456{
c500ae40 8457 int idx_ipv4_word = 3;
718e3744 8458 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
c500ae40 8459 BGP_CLEAR_SOFT_BOTH, argv[idx_ipv4_word]->arg);
718e3744 8460}
8461
587ff0fd
LB
8462DEFUN (clear_ip_bgp_peer_encap_soft,
8463 clear_ip_bgp_peer_encap_soft_cmd,
8464 "clear ip bgp A.B.C.D encap unicast soft",
8465 CLEAR_STR
8466 IP_STR
8467 BGP_STR
8468 "BGP neighbor address to clear\n"
8469 "Address family\n"
8470 "Address Family Modifier\n"
8471 "Soft reconfig\n")
8472{
c500ae40 8473 int idx_ipv4 = 3;
587ff0fd 8474 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_peer,
c500ae40 8475 BGP_CLEAR_SOFT_BOTH, argv[idx_ipv4]->arg);
587ff0fd
LB
8476}
8477
f412b39a
DW
8478/*
8479 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
8480 * "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) soft",
8481 * CLEAR_STR
8482 * BGP_STR
8483 * "Address family\n"
8484 * "BGP neighbor address to clear\n"
8485 * "BGP IPv6 neighbor to clear\n"
8486 * "BGP neighbor on interface to clear\n"
8487 * BGP_SOFT_STR
8488 *
9ccf14f7 8489 * "clear bgp <view|vrf> WORD ipv6 (A.B.C.D|X:X::X:X|WORD) soft",
f412b39a
DW
8490 * CLEAR_STR
8491 * BGP_STR
8492 * BGP_INSTANCE_HELP_STR
8493 * "Address family\n"
8494 * "BGP neighbor address to clear\n"
8495 * "BGP IPv6 neighbor to clear\n"
8496 * "BGP neighbor on interface to clear\n"
8497 * BGP_SOFT_STR
8498 *
9ccf14f7 8499 * "clear bgp <view|vrf> WORD (A.B.C.D|X:X::X:X|WORD) soft",
f412b39a
DW
8500 * CLEAR_STR
8501 * BGP_STR
8502 * BGP_INSTANCE_HELP_STR
8503 * "BGP neighbor address to clear\n"
8504 * "BGP IPv6 neighbor to clear\n"
8505 * "BGP neighbor on interface to clear\n"
8506 * BGP_SOFT_STR
8507 *
8508 */
718e3744 8509DEFUN (clear_bgp_peer_soft,
8510 clear_bgp_peer_soft_cmd,
6147e2c6 8511 "clear bgp <A.B.C.D|X:X::X:X|WORD> soft",
718e3744 8512 CLEAR_STR
8513 BGP_STR
8514 "BGP neighbor address to clear\n"
8515 "BGP IPv6 neighbor to clear\n"
a80beece 8516 "BGP neighbor on interface to clear\n"
e0bce756 8517 BGP_SOFT_STR)
718e3744 8518{
c500ae40 8519 int idx_peer = 2;
01080f7c 8520 if (argc == 3)
8521 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_peer,
8522 BGP_CLEAR_SOFT_BOTH, argv[2]);
8523
718e3744 8524 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
c500ae40 8525 BGP_CLEAR_SOFT_BOTH, argv[idx_peer]->arg);
718e3744 8526}
8527
01080f7c 8528
718e3744 8529
01080f7c 8530
f412b39a
DW
8531/*
8532 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9ccf14f7 8533 * "clear ip bgp <view|vrf> WORD peer-group WORD soft",
f412b39a
DW
8534 * CLEAR_STR
8535 * IP_STR
8536 * BGP_STR
8537 * BGP_INSTANCE_HELP_STR
8538 * "Clear all members of peer-group\n"
8539 * "BGP peer-group name\n"
8540 * BGP_SOFT_STR
8541 *
8542 */
718e3744 8543DEFUN (clear_ip_bgp_peer_group_soft,
8544 clear_ip_bgp_peer_group_soft_cmd,
8545 "clear ip bgp peer-group WORD soft",
8546 CLEAR_STR
8547 IP_STR
8548 BGP_STR
8549 "Clear all members of peer-group\n"
8550 "BGP peer-group name\n"
e0bce756 8551 BGP_SOFT_STR)
718e3744 8552{
c500ae40 8553 int idx_word = 4;
01080f7c 8554 if (argc == 3)
8555 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group,
8556 BGP_CLEAR_SOFT_BOTH, argv[2]);
8557
718e3744 8558 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
c500ae40 8559 BGP_CLEAR_SOFT_BOTH, argv[idx_word]->arg);
718e3744 8560}
8561
01080f7c 8562
718e3744 8563DEFUN (clear_ip_bgp_peer_group_ipv4_soft,
8564 clear_ip_bgp_peer_group_ipv4_soft_cmd,
6147e2c6 8565 "clear ip bgp peer-group WORD ipv4 <unicast|multicast> soft",
718e3744 8566 CLEAR_STR
8567 IP_STR
8568 BGP_STR
8569 "Clear all members of peer-group\n"
8570 "BGP peer-group name\n"
8571 "Address family\n"
8572 "Address Family modifier\n"
8573 "Address Family modifier\n"
e0bce756 8574 BGP_SOFT_STR)
718e3744 8575{
c500ae40
DW
8576 int idx_word = 4;
8577 int idx_safi = 6;
8578 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
718e3744 8579 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
c500ae40 8580 BGP_CLEAR_SOFT_BOTH, argv[idx_word]->arg);
718e3744 8581
8582 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
c500ae40 8583 BGP_CLEAR_SOFT_BOTH, argv[idx_word]->arg);
718e3744 8584}
8585
01080f7c 8586DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft,
8587 clear_ip_bgp_instance_peer_group_ipv4_soft_cmd,
9ccf14f7 8588 "clear ip bgp <view|vrf> WORD peer-group WORD ipv4 <unicast|multicast> soft",
01080f7c 8589 CLEAR_STR
8590 IP_STR
8591 BGP_STR
8592 BGP_INSTANCE_HELP_STR
8593 "Clear all members of peer-group\n"
8594 "BGP peer-group name\n"
8595 "Address family\n"
8596 "Address Family modifier\n"
8597 "Address Family modifier\n"
8598 BGP_SOFT_STR)
8599{
c500ae40
DW
8600 int idx_word = 4;
8601 int idx_word_2 = 6;
8602 int idx_safi = 8;
8603 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
8604 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_group,
8605 BGP_CLEAR_SOFT_BOTH, argv[idx_word_2]->arg);
01080f7c 8606
c500ae40
DW
8607 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, clear_group,
8608 BGP_CLEAR_SOFT_BOTH, argv[idx_word_2]->arg);
01080f7c 8609}
8610
f412b39a
DW
8611/*
8612 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9ccf14f7 8613 * "clear bgp <view|vrf> WORD ipv6 peer-group WORD soft",
f412b39a
DW
8614 * CLEAR_STR
8615 * BGP_STR
8616 * BGP_INSTANCE_HELP_STR
8617 * "Address family\n"
8618 * "Clear all members of peer-group\n"
8619 * "BGP peer-group name\n"
8620 * BGP_SOFT_STR
8621 *
9ccf14f7 8622 * "clear bgp <view|vrf> WORD peer-group WORD soft",
f412b39a
DW
8623 * CLEAR_STR
8624 * BGP_STR
8625 * BGP_INSTANCE_HELP_STR
8626 * "Clear all members of peer-group\n"
8627 * "BGP peer-group name\n"
8628 * BGP_SOFT_STR
8629 *
8630 * "clear bgp ipv6 peer-group WORD soft",
8631 * CLEAR_STR
8632 * BGP_STR
8633 * "Address family\n"
8634 * "Clear all members of peer-group\n"
8635 * "BGP peer-group name\n"
8636 * BGP_SOFT_STR
8637 *
8638 */
718e3744 8639DEFUN (clear_bgp_peer_group_soft,
8640 clear_bgp_peer_group_soft_cmd,
8641 "clear bgp peer-group WORD soft",
8642 CLEAR_STR
8643 BGP_STR
8644 "Clear all members of peer-group\n"
8645 "BGP peer-group name\n"
e0bce756 8646 BGP_SOFT_STR)
718e3744 8647{
c500ae40 8648 int idx_word = 3;
01080f7c 8649 if (argc == 3)
8650 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_group,
8651 BGP_CLEAR_SOFT_BOTH, argv[2]);
8652
718e3744 8653 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
c500ae40 8654 BGP_CLEAR_SOFT_BOTH, argv[idx_word]->arg);
718e3744 8655}
8656
f412b39a
DW
8657/*
8658 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9ccf14f7 8659 * "clear ip bgp <view|vrf> WORD external soft",
f412b39a
DW
8660 * CLEAR_STR
8661 * IP_STR
8662 * BGP_STR
8663 * BGP_INSTANCE_HELP_STR
8664 * "Clear all external peers\n"
8665 * BGP_SOFT_STR
8666 *
8667 */
718e3744 8668DEFUN (clear_ip_bgp_external_soft,
8669 clear_ip_bgp_external_soft_cmd,
8670 "clear ip bgp external soft",
8671 CLEAR_STR
8672 IP_STR
8673 BGP_STR
8674 "Clear all external peers\n"
e0bce756 8675 BGP_SOFT_STR)
718e3744 8676{
01080f7c 8677 if (argc == 2)
8678 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external,
8679 BGP_CLEAR_SOFT_BOTH, NULL);
8680
718e3744 8681 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
8682 BGP_CLEAR_SOFT_BOTH, NULL);
8683}
8684
01080f7c 8685
718e3744 8686DEFUN (clear_ip_bgp_external_ipv4_soft,
8687 clear_ip_bgp_external_ipv4_soft_cmd,
6147e2c6 8688 "clear ip bgp external ipv4 <unicast|multicast> soft",
718e3744 8689 CLEAR_STR
8690 IP_STR
8691 BGP_STR
8692 "Clear all external peers\n"
8693 "Address family\n"
8694 "Address Family modifier\n"
8695 "Address Family modifier\n"
e0bce756 8696 BGP_SOFT_STR)
718e3744 8697{
c500ae40
DW
8698 int idx_safi = 5;
8699 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
718e3744 8700 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
8701 BGP_CLEAR_SOFT_BOTH, NULL);
8702
8703 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
8704 BGP_CLEAR_SOFT_BOTH, NULL);
8705}
8706
01080f7c 8707DEFUN (clear_ip_bgp_instance_external_ipv4_soft,
8708 clear_ip_bgp_instance_external_ipv4_soft_cmd,
9ccf14f7 8709 "clear ip bgp <view|vrf> WORD external ipv4 <unicast|multicast> soft",
01080f7c 8710 CLEAR_STR
8711 IP_STR
8712 BGP_STR
8713 BGP_INSTANCE_HELP_STR
8714 "Clear all external peers\n"
8715 "Address family\n"
8716 "Address Family modifier\n"
8717 "Address Family modifier\n"
8718 BGP_SOFT_STR)
8719{
c500ae40
DW
8720 int idx_word = 4;
8721 int idx_safi = 7;
8722 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
8723 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_external,
01080f7c 8724 BGP_CLEAR_SOFT_BOTH, NULL);
8725
c500ae40 8726 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, clear_external,
01080f7c 8727 BGP_CLEAR_SOFT_BOTH, NULL);
8728}
8729
f412b39a
DW
8730/*
8731 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9ccf14f7 8732 * "clear bgp <view|vrf> WORD external soft",
f412b39a
DW
8733 * CLEAR_STR
8734 * BGP_STR
8735 * BGP_INSTANCE_HELP_STR
8736 * "Clear all external peers\n"
8737 * BGP_SOFT_STR
8738 *
9ccf14f7 8739 * "clear bgp <view|vrf> WORD ipv6 external soft",
f412b39a
DW
8740 * CLEAR_STR
8741 * BGP_STR
8742 * BGP_INSTANCE_HELP_STR
8743 * "Address family\n"
8744 * "Clear all external peers\n"
8745 * BGP_SOFT_STR
8746 *
8747 * "clear bgp ipv6 external soft",
8748 * CLEAR_STR
8749 * BGP_STR
8750 * "Address family\n"
8751 * "Clear all external peers\n"
8752 * BGP_SOFT_STR
8753 *
8754 */
718e3744 8755DEFUN (clear_bgp_external_soft,
8756 clear_bgp_external_soft_cmd,
8757 "clear bgp external soft",
8758 CLEAR_STR
8759 BGP_STR
8760 "Clear all external peers\n"
e0bce756 8761 BGP_SOFT_STR)
718e3744 8762{
01080f7c 8763 if (argc == 2)
8764 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_external,
8765 BGP_CLEAR_SOFT_BOTH, NULL);
8766
718e3744 8767 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
8768 BGP_CLEAR_SOFT_BOTH, NULL);
8769}
8770
f412b39a
DW
8771/*
8772 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9ccf14f7 8773 * "clear ip bgp <view|vrf> WORD (1-4294967295) soft",
f412b39a
DW
8774 * CLEAR_STR
8775 * IP_STR
8776 * BGP_STR
8777 * BGP_INSTANCE_HELP_STR
8778 * "Clear peers with the AS number\n"
8779 * BGP_SOFT_STR
8780 *
8781 */
718e3744 8782DEFUN (clear_ip_bgp_as_soft,
8783 clear_ip_bgp_as_soft_cmd,
9ccf14f7 8784 "clear ip bgp (1-4294967295) soft",
718e3744 8785 CLEAR_STR
8786 IP_STR
8787 BGP_STR
8788 "Clear peers with the AS number\n"
e0bce756 8789 BGP_SOFT_STR)
718e3744 8790{
c500ae40 8791 int idx_number = 3;
01080f7c 8792 if (argc == 3)
8793 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as,
8794 BGP_CLEAR_SOFT_BOTH, argv[2]);
8795
718e3744 8796 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
c500ae40 8797 BGP_CLEAR_SOFT_BOTH, argv[idx_number]->arg);
718e3744 8798}
8799
01080f7c 8800
718e3744 8801DEFUN (clear_ip_bgp_as_ipv4_soft,
8802 clear_ip_bgp_as_ipv4_soft_cmd,
9ccf14f7 8803 "clear ip bgp (1-4294967295) ipv4 <unicast|multicast> soft",
718e3744 8804 CLEAR_STR
8805 IP_STR
8806 BGP_STR
8807 "Clear peers with the AS number\n"
8808 "Address family\n"
8809 "Address Family Modifier\n"
8810 "Address Family Modifier\n"
e0bce756 8811 BGP_SOFT_STR)
718e3744 8812{
c500ae40
DW
8813 int idx_number = 3;
8814 int idx_safi = 5;
8815 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
718e3744 8816 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
c500ae40 8817 BGP_CLEAR_SOFT_BOTH, argv[idx_number]->arg);
718e3744 8818
8819 return bgp_clear_vty (vty, NULL,AFI_IP, SAFI_UNICAST, clear_as,
c500ae40 8820 BGP_CLEAR_SOFT_BOTH, argv[idx_number]->arg);
718e3744 8821}
8822
01080f7c 8823DEFUN (clear_ip_bgp_instance_as_ipv4_soft,
8824 clear_ip_bgp_instance_as_ipv4_soft_cmd,
9ccf14f7 8825 "clear ip bgp <view|vrf> WORD (1-4294967295) ipv4 <unicast|multicast> soft",
01080f7c 8826 CLEAR_STR
8827 IP_STR
8828 BGP_STR
8829 BGP_INSTANCE_HELP_STR
8830 "Clear peers with the AS number\n"
8831 "Address family\n"
8832 "Address Family Modifier\n"
8833 "Address Family Modifier\n"
8834 BGP_SOFT_STR)
8835{
c500ae40
DW
8836 int idx_word = 4;
8837 int idx_number = 5;
8838 int idx_safi = 7;
8839 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
8840 return bgp_clear_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, clear_as,
8841 BGP_CLEAR_SOFT_BOTH, argv[idx_number]->arg);
01080f7c 8842
c500ae40
DW
8843 return bgp_clear_vty (vty, argv[idx_word]->arg,AFI_IP, SAFI_UNICAST, clear_as,
8844 BGP_CLEAR_SOFT_BOTH, argv[idx_number]->arg);
01080f7c 8845}
8846
718e3744 8847DEFUN (clear_ip_bgp_as_vpnv4_soft,
8848 clear_ip_bgp_as_vpnv4_soft_cmd,
9ccf14f7 8849 "clear ip bgp (1-4294967295) vpnv4 unicast soft",
718e3744 8850 CLEAR_STR
8851 IP_STR
8852 BGP_STR
8853 "Clear peers with the AS number\n"
8854 "Address family\n"
8855 "Address Family Modifier\n"
e0bce756 8856 BGP_SOFT_STR)
718e3744 8857{
c500ae40 8858 int idx_number = 3;
718e3744 8859 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
c500ae40 8860 BGP_CLEAR_SOFT_BOTH, argv[idx_number]->arg);
718e3744 8861}
8862
587ff0fd
LB
8863DEFUN (clear_ip_bgp_as_encap_soft,
8864 clear_ip_bgp_as_encap_soft_cmd,
9ccf14f7 8865 "clear ip bgp (1-4294967295) encap unicast soft",
587ff0fd
LB
8866 CLEAR_STR
8867 IP_STR
8868 BGP_STR
8869 "Clear peers with the AS number\n"
8870 "Address family\n"
8871 "Address Family Modifier\n"
8872 "Soft reconfig\n")
8873{
c500ae40 8874 int idx_number = 3;
587ff0fd 8875 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_as,
c500ae40 8876 BGP_CLEAR_SOFT_BOTH, argv[idx_number]->arg);
587ff0fd
LB
8877}
8878
f412b39a
DW
8879/*
8880 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9ccf14f7 8881 * "clear bgp ipv6 (1-4294967295) soft",
f412b39a
DW
8882 * CLEAR_STR
8883 * BGP_STR
8884 * "Address family\n"
8885 * "Clear peers with the AS number\n"
8886 * BGP_SOFT_STR
8887 *
9ccf14f7 8888 * "clear bgp <view|vrf> WORD ipv6 (1-4294967295) soft",
f412b39a
DW
8889 * CLEAR_STR
8890 * BGP_STR
8891 * BGP_INSTANCE_HELP_STR
8892 * "Address family\n"
8893 * "Clear peers with the AS number\n"
8894 * BGP_SOFT_STR
8895 *
9ccf14f7 8896 * "clear bgp <view|vrf> WORD (1-4294967295) soft",
f412b39a
DW
8897 * CLEAR_STR
8898 * BGP_STR
8899 * BGP_INSTANCE_HELP_STR
8900 * "Clear peers with the AS number\n"
8901 * BGP_SOFT_STR
8902 *
8903 */
718e3744 8904DEFUN (clear_bgp_as_soft,
8905 clear_bgp_as_soft_cmd,
9ccf14f7 8906 "clear bgp (1-4294967295) soft",
718e3744 8907 CLEAR_STR
8908 BGP_STR
8909 "Clear peers with the AS number\n"
e0bce756 8910 BGP_SOFT_STR)
718e3744 8911{
c500ae40 8912 int idx_number = 2;
01080f7c 8913 if (argc == 3)
8914 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_as,
8915 BGP_CLEAR_SOFT_BOTH, argv[2]);
8916
718e3744 8917 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
c500ae40 8918 BGP_CLEAR_SOFT_BOTH, argv[idx_number]->arg);
718e3744 8919}
8920
f412b39a
DW
8921
8922
01080f7c 8923
e0081f70
ML
8924DEFUN (show_bgp_views,
8925 show_bgp_views_cmd,
8926 "show bgp views",
8927 SHOW_STR
8928 BGP_STR
8929 "Show the defined BGP views\n")
8930{
8931 struct list *inst = bm->bgp;
8932 struct listnode *node;
8933 struct bgp *bgp;
8934
8935 if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
8936 {
8386ac43 8937 vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE);
e0081f70
ML
8938 return CMD_WARNING;
8939 }
8940
8941 vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE);
8942 for (ALL_LIST_ELEMENTS_RO(inst, node, bgp))
8386ac43 8943 {
8944 /* Skip VRFs. */
8945 if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF)
8946 continue;
8947 vty_out (vty, "\t%s (AS%u)%s",
8948 bgp->name ? bgp->name : "(null)",
8949 bgp->as, VTY_NEWLINE);
8950 }
e0081f70
ML
8951
8952 return CMD_SUCCESS;
8953}
8954
8386ac43 8955DEFUN (show_bgp_vrfs,
8956 show_bgp_vrfs_cmd,
b162fa78 8957 "show bgp vrfs [json]",
8386ac43 8958 SHOW_STR
8959 BGP_STR
8960 "Show BGP VRFs\n"
8961 "JavaScript Object Notation\n")
8962{
8963 struct list *inst = bm->bgp;
8964 struct listnode *node;
8965 struct bgp *bgp;
8966 u_char uj = use_json(argc, argv);
8967 json_object *json = NULL;
8968 json_object *json_vrfs = NULL;
8969 int count = 0;
8970 static char header[] = "Type Id RouterId #PeersCfg #PeersEstb Name";
8971
8972 if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
8973 {
8974 vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE);
8975 return CMD_WARNING;
8976 }
8977
8978 if (uj)
8979 {
8980 json = json_object_new_object();
8981 json_vrfs = json_object_new_object();
8982 }
8983
8984 for (ALL_LIST_ELEMENTS_RO(inst, node, bgp))
8985 {
8986 const char *name, *type;
8987 struct peer *peer;
8988 struct listnode *node, *nnode;
8989 int peers_cfg, peers_estb;
8990 json_object *json_vrf = NULL;
5c81a5f3 8991 int vrf_id_ui;
8386ac43 8992
8993 /* Skip Views. */
8994 if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW)
8995 continue;
8996
8997 count++;
8998 if (!uj && count == 1)
8999 vty_out (vty, "%s%s", header, VTY_NEWLINE);
9000
9001 peers_cfg = peers_estb = 0;
9002 if (uj)
9003 json_vrf = json_object_new_object();
9004
9005
9006 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
9007 {
9008 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
9009 continue;
9010 peers_cfg++;
9011 if (peer->status == Established)
9012 peers_estb++;
9013 }
9014
9015 if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
9016 {
9017 name = "Default";
9018 type = "DFLT";
9019 }
9020 else
9021 {
9022 name = bgp->name;
9023 type = "VRF";
9024 }
9025
5c81a5f3 9026 vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id;
8386ac43 9027 if (uj)
9028 {
9029 json_object_string_add(json_vrf, "type", type);
5c81a5f3 9030 json_object_int_add(json_vrf, "vrfId", vrf_id_ui);
8386ac43 9031 json_object_string_add(json_vrf, "routerId", inet_ntoa (bgp->router_id));
9032 json_object_int_add(json_vrf, "numConfiguredPeers", peers_cfg);
9033 json_object_int_add(json_vrf, "numEstablishedPeers", peers_estb);
9034
9035 json_object_object_add(json_vrfs, name, json_vrf);
9036 }
9037 else
5c81a5f3 9038 vty_out (vty, "%4s %-5d %-16s %9u %10u %s%s",
9039 type, vrf_id_ui, inet_ntoa (bgp->router_id),
8386ac43 9040 peers_cfg, peers_estb, name,
9041 VTY_NEWLINE);
9042 }
9043
9044 if (uj)
9045 {
9046 json_object_object_add(json, "vrfs", json_vrfs);
9047
9048 json_object_int_add(json, "totalVrfs", count);
9049
9050 vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
9051 json_object_free(json);
9052 }
9053 else
9054 {
9055 if (count)
9056 vty_out (vty, "%sTotal number of VRFs (including default): %d%s",
9057 VTY_NEWLINE, count, VTY_NEWLINE);
9058 }
9059
9060 return CMD_SUCCESS;
9061}
9062
f412b39a 9063DEFUN (show_bgp_memory,
4bf6a362
PJ
9064 show_bgp_memory_cmd,
9065 "show bgp memory",
9066 SHOW_STR
9067 BGP_STR
9068 "Global BGP memory statistics\n")
9069{
9070 char memstrbuf[MTYPE_MEMSTR_LEN];
9071 unsigned long count;
9072
9073 /* RIB related usage stats */
9074 count = mtype_stats_alloc (MTYPE_BGP_NODE);
9075 vty_out (vty, "%ld RIB nodes, using %s of memory%s", count,
9076 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9077 count * sizeof (struct bgp_node)),
9078 VTY_NEWLINE);
9079
9080 count = mtype_stats_alloc (MTYPE_BGP_ROUTE);
9081 vty_out (vty, "%ld BGP routes, using %s of memory%s", count,
9082 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9083 count * sizeof (struct bgp_info)),
9084 VTY_NEWLINE);
fb982c25
PJ
9085 if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA)))
9086 vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count,
9087 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9088 count * sizeof (struct bgp_info_extra)),
9089 VTY_NEWLINE);
4bf6a362
PJ
9090
9091 if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC)))
9092 vty_out (vty, "%ld Static routes, using %s of memory%s", count,
9093 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9094 count * sizeof (struct bgp_static)),
9095 VTY_NEWLINE);
3f9c7369
DS
9096
9097 if ((count = mtype_stats_alloc (MTYPE_BGP_PACKET)))
9098 vty_out (vty, "%ld Packets, using %s of memory%s", count,
9099 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9100 count * sizeof (struct bpacket)),
9101 VTY_NEWLINE);
4bf6a362
PJ
9102
9103 /* Adj-In/Out */
9104 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN)))
9105 vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count,
9106 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9107 count * sizeof (struct bgp_adj_in)),
9108 VTY_NEWLINE);
9109 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT)))
9110 vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count,
9111 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9112 count * sizeof (struct bgp_adj_out)),
9113 VTY_NEWLINE);
9114
9115 if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE)))
9116 vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count,
9117 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9118 count * sizeof (struct bgp_nexthop_cache)),
9119 VTY_NEWLINE);
9120
9121 if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO)))
9122 vty_out (vty, "%ld Dampening entries, using %s of memory%s", count,
9123 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9124 count * sizeof (struct bgp_damp_info)),
9125 VTY_NEWLINE);
9126
9127 /* Attributes */
9128 count = attr_count();
9129 vty_out (vty, "%ld BGP attributes, using %s of memory%s", count,
9130 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9131 count * sizeof(struct attr)),
9132 VTY_NEWLINE);
fb982c25
PJ
9133 if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA)))
9134 vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count,
9135 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9136 count * sizeof(struct attr_extra)),
9137 VTY_NEWLINE);
4bf6a362
PJ
9138
9139 if ((count = attr_unknown_count()))
9140 vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE);
9141
9142 /* AS_PATH attributes */
9143 count = aspath_count ();
9144 vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count,
9145 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9146 count * sizeof (struct aspath)),
9147 VTY_NEWLINE);
9148
9149 count = mtype_stats_alloc (MTYPE_AS_SEG);
9150 vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count,
9151 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9152 count * sizeof (struct assegment)),
9153 VTY_NEWLINE);
9154
9155 /* Other attributes */
9156 if ((count = community_count ()))
9157 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
9158 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9159 count * sizeof (struct community)),
9160 VTY_NEWLINE);
9161 if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY)))
9162 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
9163 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9164 count * sizeof (struct ecommunity)),
9165 VTY_NEWLINE);
9166
9167 if ((count = mtype_stats_alloc (MTYPE_CLUSTER)))
9168 vty_out (vty, "%ld Cluster lists, using %s of memory%s", count,
9169 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9170 count * sizeof (struct cluster_list)),
9171 VTY_NEWLINE);
9172
9173 /* Peer related usage */
9174 count = mtype_stats_alloc (MTYPE_BGP_PEER);
9175 vty_out (vty, "%ld peers, using %s of memory%s", count,
9176 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9177 count * sizeof (struct peer)),
9178 VTY_NEWLINE);
9179
4a1ab8e4 9180 if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP)))
4bf6a362
PJ
9181 vty_out (vty, "%ld peer groups, using %s of memory%s", count,
9182 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9183 count * sizeof (struct peer_group)),
9184 VTY_NEWLINE);
9185
9186 /* Other */
9187 if ((count = mtype_stats_alloc (MTYPE_HASH)))
9188 vty_out (vty, "%ld hash tables, using %s of memory%s", count,
9189 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9190 count * sizeof (struct hash)),
9191 VTY_NEWLINE);
9192 if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET)))
9193 vty_out (vty, "%ld hash buckets, using %s of memory%s", count,
9194 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9195 count * sizeof (struct hash_backet)),
9196 VTY_NEWLINE);
9197 if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP)))
9198 vty_out (vty, "%ld compiled regexes, using %s of memory%s", count,
9199 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9200 count * sizeof (regex_t)),
9201 VTY_NEWLINE);
9202 return CMD_SUCCESS;
9203}
fee0f4c6 9204
718e3744 9205/* Show BGP peer's summary information. */
94f2b392 9206static int
b05a1c8b 9207bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi,
9f689658 9208 u_char use_json, json_object *json)
718e3744 9209{
9210 struct peer *peer;
1eb8ef25 9211 struct listnode *node, *nnode;
f14e6fdb
DS
9212 unsigned int count = 0, dn_count = 0;
9213 char timebuf[BGP_UPTIME_LEN], dn_flag[2];
718e3744 9214 int len;
ffd0c037
DS
9215 json_object *json_peer = NULL;
9216 json_object *json_peers = NULL;
718e3744 9217
9218 /* Header string for each address family. */
4a7ac06c 9219 static char header[] = "Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd";
47fc97cc 9220
b05a1c8b
DS
9221 if (use_json)
9222 {
9f689658
DD
9223 if (json == NULL)
9224 json = json_object_new_object();
9225
f1aa5d8a 9226 json_peers = json_object_new_object();
b05a1c8b
DS
9227 }
9228
1eb8ef25 9229 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
718e3744 9230 {
1ff9a340
DS
9231 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
9232 continue;
9233
718e3744 9234 if (peer->afc[afi][safi])
9235 {
b05a1c8b 9236 if (!count)
4bf6a362
PJ
9237 {
9238 unsigned long ents;
9239 char memstrbuf[MTYPE_MEMSTR_LEN];
5c81a5f3 9240 int vrf_id_ui;
9241
9242 vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id;
b05a1c8b 9243
4bf6a362 9244 /* Usage summary and header */
b05a1c8b
DS
9245 if (use_json)
9246 {
62d6dca0 9247 json_object_string_add(json, "routerId", inet_ntoa (bgp->router_id));
f1aa5d8a 9248 json_object_int_add(json, "as", bgp->as);
9f689658
DD
9249 json_object_int_add(json, "vrfId", vrf_id_ui);
9250 json_object_string_add(json, "vrfName",
9251 (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
9252 ? "Default" : bgp->name);
b05a1c8b
DS
9253 }
9254 else
9255 {
9256 vty_out (vty,
5c81a5f3 9257 "BGP router identifier %s, local AS number %u vrf-id %d",
9258 inet_ntoa (bgp->router_id), bgp->as, vrf_id_ui);
6aeb9e78 9259 vty_out (vty, "%s", VTY_NEWLINE);
b05a1c8b
DS
9260 }
9261
f188f2c4
DS
9262 if (bgp_update_delay_configured(bgp))
9263 {
b05a1c8b 9264 if (use_json)
f188f2c4 9265 {
62d6dca0 9266 json_object_int_add(json, "updateDelayLimit", bgp->v_update_delay);
b05a1c8b
DS
9267
9268 if (bgp->v_update_delay != bgp->v_establish_wait)
62d6dca0 9269 json_object_int_add(json, "updateDelayEstablishWait", bgp->v_establish_wait);
b05a1c8b
DS
9270
9271 if (bgp_update_delay_active(bgp))
9272 {
62d6dca0
DS
9273 json_object_string_add(json, "updateDelayFirstNeighbor", bgp->update_delay_begin_time);
9274 json_object_boolean_true_add(json, "updateDelayInProgress");
b05a1c8b
DS
9275 }
9276 else
9277 {
9278 if (bgp->update_delay_over)
9279 {
62d6dca0 9280 json_object_string_add(json, "updateDelayFirstNeighbor",
f1aa5d8a 9281 bgp->update_delay_begin_time);
62d6dca0 9282 json_object_string_add(json, "updateDelayBestpathResumed",
f1aa5d8a 9283 bgp->update_delay_end_time);
62d6dca0 9284 json_object_string_add(json, "updateDelayZebraUpdateResume",
f1aa5d8a 9285 bgp->update_delay_zebra_resume_time);
62d6dca0 9286 json_object_string_add(json, "updateDelayPeerUpdateResume",
f1aa5d8a 9287 bgp->update_delay_peers_resume_time);
b05a1c8b
DS
9288 }
9289 }
f188f2c4
DS
9290 }
9291 else
9292 {
b05a1c8b
DS
9293 vty_out (vty, "Read-only mode update-delay limit: %d seconds%s",
9294 bgp->v_update_delay, VTY_NEWLINE);
9295 if (bgp->v_update_delay != bgp->v_establish_wait)
9296 vty_out (vty, " Establish wait: %d seconds%s",
9297 bgp->v_establish_wait, VTY_NEWLINE);
9298
9299 if (bgp_update_delay_active(bgp))
f188f2c4
DS
9300 {
9301 vty_out (vty, " First neighbor established: %s%s",
9302 bgp->update_delay_begin_time, VTY_NEWLINE);
b05a1c8b
DS
9303 vty_out (vty, " Delay in progress%s", VTY_NEWLINE);
9304 }
9305 else
9306 {
9307 if (bgp->update_delay_over)
9308 {
9309 vty_out (vty, " First neighbor established: %s%s",
9310 bgp->update_delay_begin_time, VTY_NEWLINE);
9311 vty_out (vty, " Best-paths resumed: %s%s",
9312 bgp->update_delay_end_time, VTY_NEWLINE);
9313 vty_out (vty, " zebra update resumed: %s%s",
9314 bgp->update_delay_zebra_resume_time, VTY_NEWLINE);
9315 vty_out (vty, " peers update resumed: %s%s",
9316 bgp->update_delay_peers_resume_time, VTY_NEWLINE);
9317 }
f188f2c4
DS
9318 }
9319 }
9320 }
4bf6a362 9321
b05a1c8b
DS
9322 if (use_json)
9323 {
9324 if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active)
62d6dca0 9325 json_object_boolean_true_add(json, "maxMedOnStartup");
b05a1c8b 9326 if (bgp->v_maxmed_admin)
62d6dca0 9327 json_object_boolean_true_add(json, "maxMedAdministrative");
b05a1c8b 9328
62d6dca0 9329 json_object_int_add(json, "tableVersion", bgp_table_version(bgp->rib[afi][safi]));
b05a1c8b
DS
9330
9331 ents = bgp_table_count (bgp->rib[afi][safi]);
62d6dca0
DS
9332 json_object_int_add(json, "ribCount", ents);
9333 json_object_int_add(json, "ribMemory", ents * sizeof (struct bgp_node));
b05a1c8b
DS
9334
9335 ents = listcount (bgp->peer);
62d6dca0
DS
9336 json_object_int_add(json, "peerCount", ents);
9337 json_object_int_add(json, "peerMemory", ents * sizeof (struct peer));
b05a1c8b 9338
b05a1c8b
DS
9339 if ((ents = listcount (bgp->group)))
9340 {
62d6dca0
DS
9341 json_object_int_add(json, "peerGroupCount", ents);
9342 json_object_int_add(json, "peerGroupMemory", ents * sizeof (struct peer_group));
b05a1c8b 9343 }
3f9c7369 9344
b05a1c8b 9345 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
62d6dca0 9346 json_object_boolean_true_add(json, "dampeningEnabled");
b05a1c8b
DS
9347 }
9348 else
9349 {
9350 if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active)
9351 vty_out (vty, "Max-med on-startup active%s", VTY_NEWLINE);
9352 if (bgp->v_maxmed_admin)
9353 vty_out (vty, "Max-med administrative active%s", VTY_NEWLINE);
9354
ffd0c037 9355 vty_out(vty, "BGP table version %" PRIu64 "%s",
b05a1c8b
DS
9356 bgp_table_version(bgp->rib[afi][safi]), VTY_NEWLINE);
9357
9358 ents = bgp_table_count (bgp->rib[afi][safi]);
9359 vty_out (vty, "RIB entries %ld, using %s of memory%s", ents,
9360 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9361 ents * sizeof (struct bgp_node)),
9362 VTY_NEWLINE);
9363
9364 /* Peer related usage */
9365 ents = listcount (bgp->peer);
9366 vty_out (vty, "Peers %ld, using %s of memory%s",
9367 ents,
9368 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9369 ents * sizeof (struct peer)),
9370 VTY_NEWLINE);
9371
b05a1c8b
DS
9372 if ((ents = listcount (bgp->group)))
9373 vty_out (vty, "Peer groups %ld, using %s of memory%s", ents,
9374 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9375 ents * sizeof (struct peer_group)),
9376 VTY_NEWLINE);
9377
9378 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
9379 vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE);
9380 vty_out (vty, "%s", VTY_NEWLINE);
9381 vty_out (vty, "%s%s", header, VTY_NEWLINE);
9382 }
4bf6a362
PJ
9383 }
9384
b05a1c8b 9385 count++;
718e3744 9386
b05a1c8b
DS
9387 if (use_json)
9388 {
9389 json_peer = json_object_new_object();
f14e6fdb 9390
b05a1c8b 9391 if (peer_dynamic_neighbor(peer))
62d6dca0 9392 json_object_boolean_true_add(json_peer, "dynamicPeer");
b05a1c8b 9393
04b6bdc0
DW
9394 if (peer->hostname)
9395 json_object_string_add(json_peer, "hostname", peer->hostname);
9396
9397 if (peer->domainname)
9398 json_object_string_add(json_peer, "domainname", peer->domainname);
9399
62d6dca0 9400 json_object_int_add(json_peer, "remoteAs", peer->as);
f1aa5d8a 9401 json_object_int_add(json_peer, "version", 4);
62d6dca0 9402 json_object_int_add(json_peer, "msgRcvd",
f1aa5d8a
DS
9403 peer->open_in + peer->update_in + peer->keepalive_in
9404 + peer->notify_in + peer->refresh_in
9405 + peer->dynamic_cap_in);
62d6dca0 9406 json_object_int_add(json_peer, "msgSent",
f1aa5d8a
DS
9407 peer->open_out + peer->update_out + peer->keepalive_out
9408 + peer->notify_out + peer->refresh_out
9409 + peer->dynamic_cap_out);
9410
62d6dca0 9411 json_object_int_add(json_peer, "tableVersion", peer->version[afi][safi]);
f1aa5d8a
DS
9412 json_object_int_add(json_peer, "outq", peer->obuf->count);
9413 json_object_int_add(json_peer, "inq", 0);
856ca177 9414 peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, use_json, json_peer);
62d6dca0 9415 json_object_int_add(json_peer, "prefixReceivedCount", peer->pcount[afi][safi]);
b05a1c8b
DS
9416
9417 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
f1aa5d8a 9418 json_object_string_add(json_peer, "state", "Idle (Admin)");
b05a1c8b 9419 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
f1aa5d8a 9420 json_object_string_add(json_peer, "state", "Idle (PfxCt)");
b05a1c8b 9421 else
f1aa5d8a 9422 json_object_string_add(json_peer, "state", LOOKUP(bgp_status_msg, peer->status));
b05a1c8b 9423
f1aa5d8a 9424 if (peer->conf_if)
62d6dca0 9425 json_object_string_add(json_peer, "idType", "interface");
f1aa5d8a 9426 else if (peer->su.sa.sa_family == AF_INET)
62d6dca0 9427 json_object_string_add(json_peer, "idType", "ipv4");
f1aa5d8a 9428 else if (peer->su.sa.sa_family == AF_INET6)
62d6dca0 9429 json_object_string_add(json_peer, "idType", "ipv6");
b05a1c8b 9430
f1aa5d8a 9431 json_object_object_add(json_peers, peer->host, json_peer);
b05a1c8b
DS
9432 }
9433 else
9434 {
9435 memset(dn_flag, '\0', sizeof(dn_flag));
9436 if (peer_dynamic_neighbor(peer))
9437 {
9438 dn_count++;
9439 dn_flag[0] = '*';
9440 }
9441
04b6bdc0
DW
9442 if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME))
9443 len = vty_out (vty, "%s%s(%s)", dn_flag, peer->hostname,
9444 peer->host);
9445 else
9446 len = vty_out (vty, "%s%s", dn_flag, peer->host);
b05a1c8b
DS
9447 len = 16 - len;
9448
9449 if (len < 1)
9450 vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
9451 else
9452 vty_out (vty, "%*s", len, " ");
9453
9454 vty_out (vty, "4 ");
9455
ee046671 9456 vty_out (vty, "%5u %7d %7d %8" PRIu64 " %4d %4zd ",
b05a1c8b
DS
9457 peer->as,
9458 peer->open_in + peer->update_in + peer->keepalive_in
9459 + peer->notify_in + peer->refresh_in
9460 + peer->dynamic_cap_in,
9461 peer->open_out + peer->update_out + peer->keepalive_out
9462 + peer->notify_out + peer->refresh_out
9463 + peer->dynamic_cap_out,
9464 peer->version[afi][safi],
9465 0,
ffd0c037 9466 peer->obuf->count);
b05a1c8b 9467
f1aa5d8a 9468 vty_out (vty, "%-8s",
856ca177 9469 peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL));
b05a1c8b
DS
9470
9471 if (peer->status == Established)
9472 vty_out (vty, " %8ld", peer->pcount[afi][safi]);
9473 else
9474 {
9475 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
9476 vty_out (vty, " Idle (Admin)");
9477 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
9478 vty_out (vty, " Idle (PfxCt)");
9479 else
9480 vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, peer->status));
9481 }
9482 vty_out (vty, "%s", VTY_NEWLINE);
9483 }
718e3744 9484 }
9485 }
9486
b05a1c8b
DS
9487 if (use_json)
9488 {
9489 json_object_object_add(json, "peers", json_peers);
14151a32 9490
62d6dca0
DS
9491 json_object_int_add(json, "totalPeers", count);
9492 json_object_int_add(json, "dynamicPeers", dn_count);
14151a32 9493
b05a1c8b 9494 vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
f1aa5d8a 9495 json_object_free(json);
b05a1c8b
DS
9496 }
9497 else
f14e6fdb 9498 {
b05a1c8b
DS
9499 if (count)
9500 vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE,
9501 count, VTY_NEWLINE);
9502 else
9f689658
DD
9503 {
9504 if (use_json)
9505 vty_out(vty, "{\"error\": {\"message\": \"No %s neighbor configured\"}}%s",
9506 afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
9507 else
9508 vty_out (vty, "No %s neighbor is configured%s",
9509 afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
9510 }
b05a1c8b 9511
9f689658 9512 if (dn_count && ! use_json)
b05a1c8b
DS
9513 {
9514 vty_out(vty, "* - dynamic neighbor%s", VTY_NEWLINE);
9515 vty_out(vty,
9516 "%d dynamic neighbor(s), limit %d%s",
9517 dn_count, bgp->dynamic_neighbors_limit, VTY_NEWLINE);
9518 }
f14e6fdb
DS
9519 }
9520
718e3744 9521 return CMD_SUCCESS;
9522}
9523
47fc97cc
DS
9524static int
9525bgp_show_summary_vty (struct vty *vty, const char *name,
b05a1c8b 9526 afi_t afi, safi_t safi, u_char use_json)
718e3744 9527{
9528 struct bgp *bgp;
9529
9530 if (name)
9531 {
9532 bgp = bgp_lookup_by_name (name);
47fc97cc 9533
718e3744 9534 if (! bgp)
9535 {
47fc97cc 9536 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
718e3744 9537 return CMD_WARNING;
9538 }
9539
9f689658 9540 bgp_show_summary (vty, bgp, afi, safi, use_json, NULL);
718e3744 9541 return CMD_SUCCESS;
9542 }
47fc97cc 9543
718e3744 9544 bgp = bgp_get_default ();
9545
9546 if (bgp)
9f689658 9547 bgp_show_summary (vty, bgp, afi, safi, use_json, NULL);
47fc97cc 9548
718e3744 9549 return CMD_SUCCESS;
9550}
9551
f186de26 9552static void
9553bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi,
9554 u_char use_json)
9555{
9556 struct listnode *node, *nnode;
9557 struct bgp *bgp;
9f689658
DD
9558 json_object *json = NULL;
9559 int is_first = 1;
9560
9561 if (use_json)
9562 vty_out (vty, "{%s", VTY_NEWLINE);
f186de26 9563
9564 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
9565 {
9f689658
DD
9566 if (use_json)
9567 {
9568 if (!(json = json_object_new_object()))
9569 {
9570 zlog_err("Unable to allocate memory for JSON object");
9571 vty_out (vty,
9572 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s",
9573 VTY_NEWLINE);
9574 return;
9575 }
9576
9577 if (! is_first)
9578 vty_out (vty, ",%s", VTY_NEWLINE);
9579 else
9580 is_first = 0;
9581
9582 vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
9583 ? "Default" : bgp->name);
9584 }
9585 else
9586 {
9587 vty_out (vty, "%sInstance %s:%s",
9588 VTY_NEWLINE,
9589 (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
9590 ? "Default" : bgp->name, VTY_NEWLINE);
9591 }
9592 bgp_show_summary (vty, bgp, afi, safi, use_json, json);
f186de26 9593 }
9f689658
DD
9594
9595 if (use_json)
9596 vty_out (vty, "}%s", VTY_NEWLINE);
9597
f186de26 9598}
9599
718e3744 9600/* `show ip bgp summary' commands. */
47fc97cc 9601DEFUN (show_ip_bgp_summary,
718e3744 9602 show_ip_bgp_summary_cmd,
b162fa78 9603 "show ip bgp summary [json]",
47fc97cc
DS
9604 SHOW_STR
9605 IP_STR
9606 BGP_STR
b05a1c8b
DS
9607 "Summary of BGP neighbor status\n"
9608 "JavaScript Object Notation\n")
47fc97cc 9609{
db7c8528
DS
9610 u_char uj = use_json(argc, argv);
9611 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST, uj);
718e3744 9612}
9613
9614DEFUN (show_ip_bgp_instance_summary,
9615 show_ip_bgp_instance_summary_cmd,
9ccf14f7 9616 "show ip bgp <view|vrf> WORD summary [json]",
718e3744 9617 SHOW_STR
9618 IP_STR
9619 BGP_STR
8386ac43 9620 BGP_INSTANCE_HELP_STR
b05a1c8b
DS
9621 "Summary of BGP neighbor status\n"
9622 "JavaScript Object Notation\n")
718e3744 9623{
c500ae40 9624 int idx_word = 4;
db7c8528 9625 u_char uj = use_json(argc, argv);
c500ae40 9626 return bgp_show_summary_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, uj);
718e3744 9627}
9628
f186de26 9629DEFUN (show_ip_bgp_instance_all_summary,
9630 show_ip_bgp_instance_all_summary_cmd,
9ccf14f7 9631 "show ip bgp <view|vrf> all summary [json]",
f186de26 9632 SHOW_STR
9633 IP_STR
9634 BGP_STR
9635 BGP_INSTANCE_ALL_HELP_STR
9636 "Summary of BGP neighbor status\n"
9637 "JavaScript Object Notation\n")
9638{
9639 u_char uj = use_json(argc, argv);
9640
9641 bgp_show_all_instances_summary_vty (vty, AFI_IP, SAFI_UNICAST, uj);
9642 return CMD_SUCCESS;
9643}
9644
f412b39a
DW
9645/*
9646 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
b162fa78 9647 * "show bgp ipv4 (unicast|multicast) summary [json]",
f412b39a
DW
9648 * SHOW_STR
9649 * BGP_STR
9650 * "Address family\n"
9651 * "Address Family modifier\n"
9652 * "Address Family modifier\n"
9653 * "Summary of BGP neighbor status\n"
9654 *
9655 */
9656DEFUN (show_ip_bgp_ipv4_summary,
718e3744 9657 show_ip_bgp_ipv4_summary_cmd,
6147e2c6 9658 "show ip bgp ipv4 <unicast|multicast> summary [json]",
718e3744 9659 SHOW_STR
9660 IP_STR
9661 BGP_STR
9662 "Address family\n"
9663 "Address Family modifier\n"
9664 "Address Family modifier\n"
b05a1c8b
DS
9665 "Summary of BGP neighbor status\n"
9666 "JavaScript Object Notation\n")
718e3744 9667{
c500ae40 9668 int idx_safi = 4;
db7c8528 9669 u_char uj = use_json(argc, argv);
c500ae40 9670 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
db7c8528 9671 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, uj);
718e3744 9672
db7c8528 9673 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST, uj);
718e3744 9674}
9675
95cbbd2a 9676
e3e29b32
LB
9677DEFUN (show_bgp_ipv4_vpn_summary,
9678 show_bgp_ipv4_vpn_summary_cmd,
b162fa78 9679 "show bgp ipv4 vpn summary [json]",
e3e29b32
LB
9680 SHOW_STR
9681 BGP_STR
9682 "IPv4\n"
9683 "Display VPN NLRI specific information\n"
9684 "Summary of BGP neighbor status\n"
9685 JSON_STR)
9686{
9687 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, use_json (argc, argv));
9688}
9689
9690/* `show ip bgp summary' commands. */
9691DEFUN (show_bgp_ipv6_vpn_summary,
9692 show_bgp_ipv6_vpn_summary_cmd,
b162fa78 9693 "show bgp ipv6 vpn summary [json]",
e3e29b32
LB
9694 SHOW_STR
9695 BGP_STR
9696 "IPv6\n"
9697 "Display VPN NLRI specific information\n"
9698 "Summary of BGP neighbor status\n"
9699 JSON_STR)
9700{
9701 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MPLS_VPN, use_json (argc, argv));
9702}
9703
f412b39a
DW
9704/*
9705 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
b162fa78 9706 * "show bgp view WORD ipv4 (unicast|multicast) summary [json]",
f412b39a
DW
9707 * SHOW_STR
9708 * BGP_STR
9709 * "BGP view\n"
9710 * "View name\n"
9711 * "Address family\n"
9712 * "Address Family modifier\n"
9713 * "Address Family modifier\n"
9714 * "Summary of BGP neighbor status\n"
9715 *
9716 */
718e3744 9717DEFUN (show_ip_bgp_instance_ipv4_summary,
9718 show_ip_bgp_instance_ipv4_summary_cmd,
6147e2c6 9719 "show ip bgp view WORD ipv4 <unicast|multicast> summary [json]",
718e3744 9720 SHOW_STR
9721 IP_STR
9722 BGP_STR
9723 "BGP view\n"
9724 "View name\n"
9725 "Address family\n"
9726 "Address Family modifier\n"
9727 "Address Family modifier\n"
b05a1c8b
DS
9728 "Summary of BGP neighbor status\n"
9729 "JavaScript Object Notation\n")
718e3744 9730{
c500ae40
DW
9731 int idx_word = 4;
9732 int idx_safi = 6;
db7c8528 9733 u_char uj = use_json(argc, argv);
c500ae40
DW
9734 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
9735 return bgp_show_summary_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, uj);
718e3744 9736 else
c500ae40 9737 return bgp_show_summary_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, uj);
718e3744 9738}
9739
95cbbd2a 9740
718e3744 9741DEFUN (show_ip_bgp_vpnv4_all_summary,
9742 show_ip_bgp_vpnv4_all_summary_cmd,
b162fa78 9743 "show ip bgp vpnv4 all summary [json]",
718e3744 9744 SHOW_STR
9745 IP_STR
9746 BGP_STR
9747 "Display VPNv4 NLRI specific information\n"
9748 "Display information about all VPNv4 NLRIs\n"
b05a1c8b
DS
9749 "Summary of BGP neighbor status\n"
9750 "JavaScript Object Notation\n")
718e3744 9751{
db7c8528
DS
9752 u_char uj = use_json(argc, argv);
9753 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, uj);
718e3744 9754}
9755
9756DEFUN (show_ip_bgp_vpnv4_rd_summary,
9757 show_ip_bgp_vpnv4_rd_summary_cmd,
b162fa78 9758 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn summary [json]",
718e3744 9759 SHOW_STR
9760 IP_STR
9761 BGP_STR
9762 "Display VPNv4 NLRI specific information\n"
9763 "Display information for a route distinguisher\n"
9764 "VPN Route Distinguisher\n"
b05a1c8b
DS
9765 "Summary of BGP neighbor status\n"
9766 "JavaScript Object Notation\n")
718e3744 9767{
c500ae40 9768 int idx_ext_community = 5;
718e3744 9769 int ret;
9770 struct prefix_rd prd;
db7c8528 9771 u_char uj = use_json(argc, argv);
718e3744 9772
c500ae40 9773 ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd);
718e3744 9774 if (! ret)
9775 {
9776 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
9777 return CMD_WARNING;
9778 }
9779
db7c8528 9780 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, uj);
718e3744 9781}
9782
9783#ifdef HAVE_IPV6
f412b39a
DW
9784/*
9785 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
b162fa78 9786 * "show bgp ipv6 summary [json]",
f412b39a
DW
9787 * SHOW_STR
9788 * BGP_STR
9789 * "Address family\n"
9790 * "Summary of BGP neighbor status\n"
9791 *
9792 */
47fc97cc 9793DEFUN (show_bgp_summary,
718e3744 9794 show_bgp_summary_cmd,
b162fa78 9795 "show bgp summary [json]",
718e3744 9796 SHOW_STR
9797 BGP_STR
b05a1c8b
DS
9798 "Summary of BGP neighbor status\n"
9799 "JavaScript Object Notation\n")
718e3744 9800{
db7c8528 9801 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, use_json(argc, argv));
718e3744 9802}
9803
f412b39a
DW
9804/*
9805 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9ccf14f7 9806 * "show bgp <view|vrf> WORD ipv6 summary [json]",
f412b39a
DW
9807 * SHOW_STR
9808 * BGP_STR
9809 * BGP_INSTANCE_HELP_STR
9810 * "Address family\n"
9811 * "Summary of BGP neighbor status\n"
9812 *
9813 */
718e3744 9814DEFUN (show_bgp_instance_summary,
9815 show_bgp_instance_summary_cmd,
9ccf14f7 9816 "show bgp <view|vrf> WORD summary [json]",
718e3744 9817 SHOW_STR
9818 BGP_STR
8386ac43 9819 BGP_INSTANCE_HELP_STR
b05a1c8b
DS
9820 "Summary of BGP neighbor status\n"
9821 "JavaScript Object Notation\n")
718e3744 9822{
c500ae40
DW
9823 int idx_word = 3;
9824 return bgp_show_summary_vty (vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, use_json(argc, argv));
718e3744 9825}
9826
f186de26 9827DEFUN (show_bgp_instance_all_summary,
9828 show_bgp_instance_all_summary_cmd,
9ccf14f7 9829 "show bgp <view|vrf> all summary [json]",
f186de26 9830 SHOW_STR
9831 BGP_STR
9832 BGP_INSTANCE_ALL_HELP_STR
9833 "Summary of BGP neighbor status\n"
9834 "JavaScript Object Notation\n")
9835{
9836 u_char uj = use_json(argc, argv);
9837
9838 bgp_show_all_instances_summary_vty (vty, AFI_IP6, SAFI_UNICAST, uj);
9839 return CMD_SUCCESS;
9840}
9841
718e3744 9842
718e3744 9843
95cbbd2a
ML
9844DEFUN (show_bgp_ipv6_safi_summary,
9845 show_bgp_ipv6_safi_summary_cmd,
6147e2c6 9846 "show bgp ipv6 <unicast|multicast> summary [json]",
95cbbd2a
ML
9847 SHOW_STR
9848 BGP_STR
9849 "Address family\n"
9850 "Address Family modifier\n"
9851 "Address Family modifier\n"
b05a1c8b
DS
9852 "Summary of BGP neighbor status\n"
9853 "JavaScript Object Notation\n")
95cbbd2a 9854{
c500ae40 9855 int idx_safi = 3;
db7c8528 9856 u_char uj = use_json(argc, argv);
c500ae40 9857 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
db7c8528 9858 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST, uj);
95cbbd2a 9859
db7c8528 9860 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, uj);
95cbbd2a
ML
9861}
9862
9863DEFUN (show_bgp_instance_ipv6_safi_summary,
9864 show_bgp_instance_ipv6_safi_summary_cmd,
9ccf14f7 9865 "show bgp <view|vrf> WORD ipv6 <unicast|multicast> summary [json]",
95cbbd2a
ML
9866 SHOW_STR
9867 BGP_STR
8386ac43 9868 BGP_INSTANCE_HELP_STR
95cbbd2a
ML
9869 "Address family\n"
9870 "Address Family modifier\n"
9871 "Address Family modifier\n"
b05a1c8b
DS
9872 "Summary of BGP neighbor status\n"
9873 "JavaScript Object Notation\n")
95cbbd2a 9874{
c500ae40
DW
9875 int idx_word = 3;
9876 int idx_safi = 5;
db7c8528 9877 u_char uj = use_json(argc, argv);
c500ae40
DW
9878 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
9879 return bgp_show_summary_vty (vty, argv[idx_word]->arg, AFI_IP6, SAFI_MULTICAST, uj);
95cbbd2a 9880
c500ae40 9881 return bgp_show_summary_vty (vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, uj);
95cbbd2a
ML
9882}
9883
718e3744 9884/* old command */
f412b39a 9885DEFUN (show_ipv6_bgp_summary,
718e3744 9886 show_ipv6_bgp_summary_cmd,
b162fa78 9887 "show ipv6 bgp summary [json]",
718e3744 9888 SHOW_STR
9889 IPV6_STR
9890 BGP_STR
b05a1c8b
DS
9891 "Summary of BGP neighbor status\n"
9892 "JavaScript Object Notation\n")
718e3744 9893{
db7c8528
DS
9894 u_char uj = use_json(argc, argv);
9895 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, uj);
718e3744 9896}
9897
9898/* old command */
f412b39a 9899DEFUN (show_ipv6_mbgp_summary,
718e3744 9900 show_ipv6_mbgp_summary_cmd,
b162fa78 9901 "show ipv6 mbgp summary [json]",
718e3744 9902 SHOW_STR
9903 IPV6_STR
9904 MBGP_STR
b05a1c8b
DS
9905 "Summary of BGP neighbor status\n"
9906 "JavaScript Object Notation\n")
718e3744 9907{
db7c8528
DS
9908 u_char uj = use_json(argc, argv);
9909 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST, uj);
718e3744 9910}
9911#endif /* HAVE_IPV6 */
6b0655a2 9912
fd79ac91 9913const char *
538621f2 9914afi_safi_print (afi_t afi, safi_t safi)
9915{
9916 if (afi == AFI_IP && safi == SAFI_UNICAST)
9917 return "IPv4 Unicast";
9918 else if (afi == AFI_IP && safi == SAFI_MULTICAST)
9919 return "IPv4 Multicast";
9920 else if (afi == AFI_IP && safi == SAFI_MPLS_VPN)
945c8fe9 9921 return "VPN-IPv4 Unicast";
8b1fb8be
LB
9922 else if (afi == AFI_IP && safi == SAFI_ENCAP)
9923 return "ENCAP-IPv4 Unicast";
538621f2 9924 else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
9925 return "IPv6 Unicast";
9926 else if (afi == AFI_IP6 && safi == SAFI_MULTICAST)
9927 return "IPv6 Multicast";
945c8fe9
LB
9928 else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN)
9929 return "VPN-IPv6 Unicast";
8b1fb8be
LB
9930 else if (afi == AFI_IP6 && safi == SAFI_ENCAP)
9931 return "ENCAP-IPv6 Unicast";
538621f2 9932 else
9933 return "Unknown";
9934}
9935
718e3744 9936/* Show BGP peer's information. */
9937enum show_type
9938{
9939 show_all,
9940 show_peer
9941};
9942
94f2b392 9943static void
856ca177
MS
9944bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p, afi_t afi, safi_t safi,
9945 u_int16_t adv_smcap, u_int16_t adv_rmcap, u_int16_t rcv_smcap,
9946 u_int16_t rcv_rmcap, u_char use_json, json_object *json_pref)
718e3744 9947{
9948 /* Send-Mode */
9949 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)
9950 || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
9951 {
856ca177
MS
9952 if (use_json)
9953 {
9954 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
9955 json_object_string_add(json_pref, "sendMode", "advertisedAndReceived");
9956 else if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
9957 json_object_string_add(json_pref, "sendMode", "advertised");
9958 else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
9959 json_object_string_add(json_pref, "sendMode", "received");
9960 }
9961 else
9962 {
9963 vty_out (vty, " Send-mode: ");
9964 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
9965 vty_out (vty, "advertised");
9966 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
9967 vty_out (vty, "%sreceived",
9968 CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ?
9969 ", " : "");
9970 vty_out (vty, "%s", VTY_NEWLINE);
9971 }
718e3744 9972 }
9973
9974 /* Receive-Mode */
9975 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)
9976 || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
9977 {
856ca177
MS
9978 if (use_json)
9979 {
9980 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
9981 json_object_string_add(json_pref, "recvMode", "advertisedAndReceived");
9982 else if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
9983 json_object_string_add(json_pref, "recvMode", "advertised");
9984 else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
9985 json_object_string_add(json_pref, "recvMode", "received");
9986 }
9987 else
9988 {
9989 vty_out (vty, " Receive-mode: ");
9990 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
9991 vty_out (vty, "advertised");
9992 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
9993 vty_out (vty, "%sreceived",
9994 CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ?
9995 ", " : "");
9996 vty_out (vty, "%s", VTY_NEWLINE);
9997 }
718e3744 9998 }
9999}
10000
94f2b392 10001static void
856ca177
MS
10002bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi,
10003 u_char use_json, json_object *json_neigh)
718e3744 10004{
10005 struct bgp_filter *filter;
3f9c7369 10006 struct peer_af *paf;
718e3744 10007 char orf_pfx_name[BUFSIZ];
10008 int orf_pfx_count;
856ca177
MS
10009 json_object *json_af = NULL;
10010 json_object *json_prefA = NULL;
10011 json_object *json_prefB = NULL;
10012 json_object *json_addr = NULL;
718e3744 10013
856ca177
MS
10014 if (use_json)
10015 {
10016 json_addr = json_object_new_object();
10017 json_af = json_object_new_object();
10018 json_prefA = json_object_new_object();
10019 json_prefB = json_object_new_object();
10020 filter = &p->filter[afi][safi];
718e3744 10021
c8560b44 10022 if (peer_group_active(p))
856ca177 10023 json_object_string_add(json_addr, "peerGroupMember", p->group->name);
538621f2 10024
856ca177
MS
10025 paf = peer_af_find(p, afi, safi);
10026 if (paf && PAF_SUBGRP(paf))
10027 {
10028 json_object_int_add(json_addr, "updateGroupId", PAF_UPDGRP(paf)->id);
10029 json_object_int_add(json_addr, "subGroupId", PAF_SUBGRP(paf)->id);
10030 json_object_int_add(json_addr, "packetQueueLength", bpacket_queue_virtual_length(paf));
10031 }
10032
10033 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
10034 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
10035 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
10036 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
10037 {
10038 json_object_int_add(json_af, "orfType", ORF_TYPE_PREFIX);
10039 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
10040 PEER_CAP_ORF_PREFIX_SM_ADV,
10041 PEER_CAP_ORF_PREFIX_RM_ADV,
10042 PEER_CAP_ORF_PREFIX_SM_RCV,
10043 PEER_CAP_ORF_PREFIX_RM_RCV, use_json, json_prefA);
10044 json_object_object_add(json_af, "orfPrefixList", json_prefA);
10045 }
10046
10047 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
10048 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
10049 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
10050 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
10051 {
10052 json_object_int_add(json_af, "orfOldType", ORF_TYPE_PREFIX_OLD);
10053 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
10054 PEER_CAP_ORF_PREFIX_SM_ADV,
10055 PEER_CAP_ORF_PREFIX_RM_ADV,
10056 PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
10057 PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, json_prefB);
10058 json_object_object_add(json_af, "orfOldPrefixList", json_prefB);
10059 }
10060
10061 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
10062 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
10063 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
10064 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
10065 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
10066 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
10067 json_object_object_add(json_addr, "afDependentCap", json_af);
10068
10069 sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
10070 orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json);
10071
10072 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
10073 || orf_pfx_count)
10074 {
10075 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
10076 json_object_boolean_true_add(json_neigh, "orfSent");
10077 if (orf_pfx_count)
10078 json_object_int_add(json_addr, "orfRecvCounter", orf_pfx_count);
10079 }
10080 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
10081 json_object_string_add(json_addr, "orfFirstUpdate", "deferredUntilORFOrRouteRefreshRecvd");
10082
10083 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
10084 json_object_boolean_true_add(json_addr, "routeReflectorClient");
10085 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
10086 json_object_boolean_true_add(json_addr, "routeServerClient");
10087 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
10088 json_object_boolean_true_add(json_addr, "inboundSoftConfigPermit");
10089
88b8ed8d
DW
10090 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE))
10091 json_object_boolean_true_add(json_addr, "privateAsNumsAllReplacedInUpdatesToNbr");
10092 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE))
856ca177 10093 json_object_boolean_true_add(json_addr, "privateAsNumsReplacedInUpdatesToNbr");
88b8ed8d
DW
10094 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL))
10095 json_object_boolean_true_add(json_addr, "privateAsNumsAllRemovedInUpdatesToNbr");
856ca177
MS
10096 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
10097 json_object_boolean_true_add(json_addr, "privateAsNumsRemovedInUpdatesToNbr");
10098
adbac85e
DW
10099 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS))
10100 json_object_boolean_true_add(json_addr, "addpathTxAllPaths");
10101
06370dac
DW
10102 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS))
10103 json_object_boolean_true_add(json_addr, "addpathTxBestpathPerAS");
10104
856ca177
MS
10105 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE))
10106 json_object_string_add(json_addr, "overrideASNsInOutboundUpdates", "ifAspathEqualRemoteAs");
10107
10108 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) ||
10109 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF))
10110 json_object_boolean_true_add(json_addr, "routerAlwaysNextHop");
10111 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
10112 json_object_boolean_true_add(json_addr, "unchangedAsPathPropogatedToNbr");
10113 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
10114 json_object_boolean_true_add(json_addr, "unchangedNextHopPropogatedToNbr");
10115 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
10116 json_object_boolean_true_add(json_addr, "unchangedMedPropogatedToNbr");
718e3744 10117 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
856ca177
MS
10118 || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
10119 {
10120 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
10121 && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
10122 json_object_string_add(json_addr, "commAttriSentToNbr", "extendedAndStandard");
10123 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
10124 json_object_string_add(json_addr, "commAttriSentToNbr", "extended");
10125 else
10126 json_object_string_add(json_addr, "commAttriSentToNbr", "standard");
10127 }
10128 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
10129 {
10130 if (p->default_rmap[afi][safi].name)
10131 json_object_string_add(json_addr, "defaultRouteMap", p->default_rmap[afi][safi].name);
10132
10133 if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE))
10134 json_object_boolean_true_add(json_addr, "defaultSent");
10135 else
10136 json_object_boolean_true_add(json_addr, "defaultNotSent");
10137 }
10138
10139 if (filter->plist[FILTER_IN].name
10140 || filter->dlist[FILTER_IN].name
10141 || filter->aslist[FILTER_IN].name
10142 || filter->map[RMAP_IN].name)
10143 json_object_boolean_true_add(json_addr, "inboundPathPolicyConfig");
10144 if (filter->plist[FILTER_OUT].name
10145 || filter->dlist[FILTER_OUT].name
10146 || filter->aslist[FILTER_OUT].name
10147 || filter->map[RMAP_OUT].name
10148 || filter->usmap.name)
10149 json_object_boolean_true_add(json_addr, "outboundPathPolicyConfig");
856ca177
MS
10150
10151 /* prefix-list */
10152 if (filter->plist[FILTER_IN].name)
10153 json_object_string_add(json_addr, "incomingUpdatePrefixFilterList", filter->plist[FILTER_IN].name);
10154 if (filter->plist[FILTER_OUT].name)
10155 json_object_string_add(json_addr, "outgoingUpdatePrefixFilterList", filter->plist[FILTER_OUT].name);
10156
10157 /* distribute-list */
10158 if (filter->dlist[FILTER_IN].name)
10159 json_object_string_add(json_addr, "incomingUpdateNetworkFilterList", filter->dlist[FILTER_IN].name);
10160 if (filter->dlist[FILTER_OUT].name)
10161 json_object_string_add(json_addr, "outgoingUpdateNetworkFilterList", filter->dlist[FILTER_OUT].name);
10162
10163 /* filter-list. */
10164 if (filter->aslist[FILTER_IN].name)
10165 json_object_string_add(json_addr, "incomingUpdateAsPathFilterList", filter->aslist[FILTER_IN].name);
10166 if (filter->aslist[FILTER_OUT].name)
10167 json_object_string_add(json_addr, "outgoingUpdateAsPathFilterList", filter->aslist[FILTER_OUT].name);
10168
10169 /* route-map. */
10170 if (filter->map[RMAP_IN].name)
10171 json_object_string_add(json_addr, "routeMapForIncomingAdvertisements", filter->map[RMAP_IN].name);
10172 if (filter->map[RMAP_OUT].name)
10173 json_object_string_add(json_addr, "routeMapForOutgoingAdvertisements", filter->map[RMAP_OUT].name);
856ca177
MS
10174
10175 /* unsuppress-map */
10176 if (filter->usmap.name)
10177 json_object_string_add(json_addr, "selectiveUnsuppressRouteMap", filter->usmap.name);
10178
10179 /* Receive prefix count */
10180 json_object_int_add(json_addr, "acceptedPrefixCounter", p->pcount[afi][safi]);
10181
10182 /* Maximum prefix */
10183 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
10184 {
10185 json_object_int_add(json_addr, "prefixAllowedMax", p->pmax[afi][safi]);
10186 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING))
10187 json_object_boolean_true_add(json_addr, "prefixAllowedMaxWarning");
10188 json_object_int_add(json_addr, "prefixAllowedWarningThresh", p->pmax_threshold[afi][safi]);
10189 if (p->pmax_restart[afi][safi])
10190 json_object_int_add(json_addr, "prefixAllowedRestartIntervalMsecs", p->pmax_restart[afi][safi] * 60000);
10191 }
10192 json_object_object_add(json_neigh, afi_safi_print (afi, safi), json_addr);
10193
10194 }
10195 else
10196 {
10197 filter = &p->filter[afi][safi];
10198
10199 vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi),
10200 VTY_NEWLINE);
10201
c8560b44 10202 if (peer_group_active(p))
856ca177
MS
10203 vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE);
10204
10205 paf = peer_af_find(p, afi, safi);
10206 if (paf && PAF_SUBGRP(paf))
10207 {
10208 vty_out (vty, " Update group %" PRIu64 ", subgroup %" PRIu64 "%s",
10209 PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id, VTY_NEWLINE);
10210 vty_out (vty, " Packet Queue length %d%s",
10211 bpacket_queue_virtual_length(paf), VTY_NEWLINE);
10212 }
718e3744 10213 else
856ca177
MS
10214 {
10215 vty_out(vty, " Not part of any update group%s", VTY_NEWLINE);
10216 }
10217 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
10218 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
10219 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
10220 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
10221 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
10222 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
10223 vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE);
10224
10225 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
10226 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
10227 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
10228 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
10229 {
10230 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
10231 ORF_TYPE_PREFIX, VTY_NEWLINE);
10232 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
10233 PEER_CAP_ORF_PREFIX_SM_ADV,
10234 PEER_CAP_ORF_PREFIX_RM_ADV,
10235 PEER_CAP_ORF_PREFIX_SM_RCV,
10236 PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL);
10237 }
10238 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
10239 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
10240 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
10241 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
10242 {
10243 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
10244 ORF_TYPE_PREFIX_OLD, VTY_NEWLINE);
10245 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
10246 PEER_CAP_ORF_PREFIX_SM_ADV,
10247 PEER_CAP_ORF_PREFIX_RM_ADV,
10248 PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
10249 PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL);
10250 }
718e3744 10251
856ca177
MS
10252 sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
10253 orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json);
718e3744 10254
856ca177
MS
10255 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
10256 || orf_pfx_count)
10257 {
10258 vty_out (vty, " Outbound Route Filter (ORF):");
10259 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
10260 vty_out (vty, " sent;");
10261 if (orf_pfx_count)
10262 vty_out (vty, " received (%d entries)", orf_pfx_count);
10263 vty_out (vty, "%s", VTY_NEWLINE);
10264 }
10265 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
10266 vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE);
10267
10268 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
10269 vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE);
10270 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
10271 vty_out (vty, " Route-Server Client%s", VTY_NEWLINE);
10272 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
10273 vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE);
10274
88b8ed8d
DW
10275 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE))
10276 vty_out (vty, " Private AS numbers (all) replaced in updates to this neighbor%s", VTY_NEWLINE);
10277 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE))
856ca177 10278 vty_out (vty, " Private AS numbers replaced in updates to this neighbor%s", VTY_NEWLINE);
88b8ed8d
DW
10279 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL))
10280 vty_out (vty, " Private AS numbers (all) removed in updates to this neighbor%s", VTY_NEWLINE);
856ca177
MS
10281 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
10282 vty_out (vty, " Private AS numbers removed in updates to this neighbor%s", VTY_NEWLINE);
10283
adbac85e
DW
10284 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS))
10285 vty_out (vty, " Advertise all paths via addpath%s", VTY_NEWLINE);
10286
06370dac
DW
10287 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS))
10288 vty_out (vty, " Advertise bestpath per AS via addpath%s", VTY_NEWLINE);
10289
856ca177
MS
10290 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE))
10291 vty_out (vty, " Override ASNs in outbound updates if aspath equals remote-as%s", VTY_NEWLINE);
10292
10293 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) ||
10294 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF))
10295 vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE);
10296 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
10297 vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE);
10298 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
10299 vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE);
10300 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
10301 vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE);
10302 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
10303 || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
10304 {
10305 vty_out (vty, " Community attribute sent to this neighbor");
10306 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
10307 && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
10308 vty_out (vty, "(both)%s", VTY_NEWLINE);
10309 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
10310 vty_out (vty, "(extended)%s", VTY_NEWLINE);
10311 else
10312 vty_out (vty, "(standard)%s", VTY_NEWLINE);
10313 }
10314 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
10315 {
10316 vty_out (vty, " Default information originate,");
10317
10318 if (p->default_rmap[afi][safi].name)
10319 vty_out (vty, " default route-map %s%s,",
10320 p->default_rmap[afi][safi].map ? "*" : "",
10321 p->default_rmap[afi][safi].name);
10322 if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE))
10323 vty_out (vty, " default sent%s", VTY_NEWLINE);
10324 else
10325 vty_out (vty, " default not sent%s", VTY_NEWLINE);
10326 }
718e3744 10327
856ca177
MS
10328 if (filter->plist[FILTER_IN].name
10329 || filter->dlist[FILTER_IN].name
10330 || filter->aslist[FILTER_IN].name
10331 || filter->map[RMAP_IN].name)
10332 vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE);
10333 if (filter->plist[FILTER_OUT].name
10334 || filter->dlist[FILTER_OUT].name
10335 || filter->aslist[FILTER_OUT].name
10336 || filter->map[RMAP_OUT].name
10337 || filter->usmap.name)
10338 vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE);
856ca177
MS
10339
10340 /* prefix-list */
10341 if (filter->plist[FILTER_IN].name)
10342 vty_out (vty, " Incoming update prefix filter list is %s%s%s",
10343 filter->plist[FILTER_IN].plist ? "*" : "",
10344 filter->plist[FILTER_IN].name,
10345 VTY_NEWLINE);
10346 if (filter->plist[FILTER_OUT].name)
10347 vty_out (vty, " Outgoing update prefix filter list is %s%s%s",
10348 filter->plist[FILTER_OUT].plist ? "*" : "",
10349 filter->plist[FILTER_OUT].name,
10350 VTY_NEWLINE);
10351
10352 /* distribute-list */
10353 if (filter->dlist[FILTER_IN].name)
10354 vty_out (vty, " Incoming update network filter list is %s%s%s",
10355 filter->dlist[FILTER_IN].alist ? "*" : "",
10356 filter->dlist[FILTER_IN].name,
10357 VTY_NEWLINE);
10358 if (filter->dlist[FILTER_OUT].name)
10359 vty_out (vty, " Outgoing update network filter list is %s%s%s",
10360 filter->dlist[FILTER_OUT].alist ? "*" : "",
10361 filter->dlist[FILTER_OUT].name,
10362 VTY_NEWLINE);
10363
10364 /* filter-list. */
10365 if (filter->aslist[FILTER_IN].name)
10366 vty_out (vty, " Incoming update AS path filter list is %s%s%s",
10367 filter->aslist[FILTER_IN].aslist ? "*" : "",
10368 filter->aslist[FILTER_IN].name,
10369 VTY_NEWLINE);
10370 if (filter->aslist[FILTER_OUT].name)
10371 vty_out (vty, " Outgoing update AS path filter list is %s%s%s",
10372 filter->aslist[FILTER_OUT].aslist ? "*" : "",
10373 filter->aslist[FILTER_OUT].name,
10374 VTY_NEWLINE);
10375
10376 /* route-map. */
10377 if (filter->map[RMAP_IN].name)
10378 vty_out (vty, " Route map for incoming advertisements is %s%s%s",
10379 filter->map[RMAP_IN].map ? "*" : "",
10380 filter->map[RMAP_IN].name,
10381 VTY_NEWLINE);
10382 if (filter->map[RMAP_OUT].name)
10383 vty_out (vty, " Route map for outgoing advertisements is %s%s%s",
10384 filter->map[RMAP_OUT].map ? "*" : "",
10385 filter->map[RMAP_OUT].name,
10386 VTY_NEWLINE);
856ca177
MS
10387
10388 /* unsuppress-map */
10389 if (filter->usmap.name)
10390 vty_out (vty, " Route map for selective unsuppress is %s%s%s",
10391 filter->usmap.map ? "*" : "",
10392 filter->usmap.name, VTY_NEWLINE);
10393
10394 /* Receive prefix count */
10395 vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE);
10396
10397 /* Maximum prefix */
10398 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
10399 {
10400 vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi],
10401 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)
10402 ? " (warning-only)" : "", VTY_NEWLINE);
10403 vty_out (vty, " Threshold for warning message %d%%",
10404 p->pmax_threshold[afi][safi]);
10405 if (p->pmax_restart[afi][safi])
10406 vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]);
10407 vty_out (vty, "%s", VTY_NEWLINE);
10408 }
718e3744 10409
0a486e5f 10410 vty_out (vty, "%s", VTY_NEWLINE);
718e3744 10411 }
718e3744 10412}
10413
94f2b392 10414static void
e8f7da3a 10415bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *json)
718e3744 10416{
10417 struct bgp *bgp;
4690c7d7 10418 char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN];
718e3744 10419 char timebuf[BGP_UPTIME_LEN];
f14e6fdb 10420 char dn_flag[2];
3a8c7ba1
DW
10421 const char *subcode_str;
10422 const char *code_str;
538621f2 10423 afi_t afi;
10424 safi_t safi;
d6661008
DS
10425 u_int16_t i;
10426 u_char *msg;
e8f7da3a 10427 json_object *json_neigh = NULL;
718e3744 10428
10429 bgp = p->bgp;
10430
e8f7da3a
DW
10431 if (use_json)
10432 json_neigh = json_object_new_object();
10433
856ca177 10434 if (!use_json)
f14e6fdb 10435 {
856ca177
MS
10436 if (p->conf_if) /* Configured interface name. */
10437 vty_out (vty, "BGP neighbor on %s: %s, ", p->conf_if,
10438 BGP_PEER_SU_UNSPEC(p) ? "None" :
10439 sockunion2str (&p->su, buf, SU_ADDRSTRLEN));
10440 else /* Configured IP address. */
10441 {
10442 memset(dn_flag, '\0', sizeof(dn_flag));
10443 if (peer_dynamic_neighbor(p))
10444 dn_flag[0] = '*';
f14e6fdb 10445
856ca177
MS
10446 vty_out (vty, "BGP neighbor is %s%s, ", dn_flag, p->host);
10447 }
f14e6fdb
DS
10448 }
10449
856ca177
MS
10450 if (use_json)
10451 {
10452 if (p->conf_if && BGP_PEER_SU_UNSPEC(p))
10453 json_object_string_add(json_neigh, "bgpNeighborAddr", "none");
10454 else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p))
10455 json_object_string_add(json_neigh, "bgpNeighborAddr", sockunion2str (&p->su, buf, SU_ADDRSTRLEN));
10456
10457 json_object_int_add(json_neigh, "remoteAs", p->as);
10458
10459 if (p->change_local_as)
10460 json_object_int_add(json_neigh, "localAs", p->change_local_as);
10461 else
10462 json_object_int_add(json_neigh, "localAs", p->local_as);
10463
10464 if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND))
10465 json_object_boolean_true_add(json_neigh, "localAsNoPrepend");
66b199b2 10466
856ca177
MS
10467 if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS))
10468 json_object_boolean_true_add(json_neigh, "localAsReplaceAs");
10469 }
10470 else
10471 {
f8cfafda
DS
10472 if ((p->as_type == AS_SPECIFIED) ||
10473 (p->as_type == AS_EXTERNAL) ||
10474 (p->as_type == AS_INTERNAL))
10475 vty_out (vty, "remote AS %u, ", p->as);
10476 else
10477 vty_out (vty, "remote AS Unspecified, ");
856ca177
MS
10478 vty_out (vty, "local AS %u%s%s, ",
10479 p->change_local_as ? p->change_local_as : p->local_as,
10480 CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ?
10481 " no-prepend" : "",
10482 CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) ?
10483 " replace-as" : "");
10484 }
66b199b2
DS
10485 /* peer type internal, external, confed-internal or confed-external */
10486 if (p->as == p->local_as)
10487 {
856ca177
MS
10488 if (use_json)
10489 {
10490 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
10491 json_object_boolean_true_add(json_neigh, "nbrConfedInternalLink");
10492 else
10493 json_object_boolean_true_add(json_neigh, "nbrInternalLink");
10494 }
66b199b2 10495 else
856ca177
MS
10496 {
10497 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
10498 vty_out (vty, "confed-internal link%s", VTY_NEWLINE);
10499 else
10500 vty_out (vty, "internal link%s", VTY_NEWLINE);
10501 }
66b199b2
DS
10502 }
10503 else
10504 {
856ca177
MS
10505 if (use_json)
10506 {
10507 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
10508 json_object_boolean_true_add(json_neigh, "nbrConfedExternalLink");
10509 else
10510 json_object_boolean_true_add(json_neigh, "nbrExternalLink");
10511 }
66b199b2 10512 else
856ca177
MS
10513 {
10514 if (bgp_confederation_peers_check(bgp, p->as))
10515 vty_out (vty, "confed-external link%s", VTY_NEWLINE);
10516 else
10517 vty_out (vty, "external link%s", VTY_NEWLINE);
10518 }
66b199b2 10519 }
718e3744 10520
10521 /* Description. */
10522 if (p->desc)
856ca177
MS
10523 {
10524 if (use_json)
10525 json_object_string_add(json_neigh, "nbrDesc", p->desc);
10526 else
10527 vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE);
10528 }
6410e93a 10529
04b6bdc0
DW
10530 if (p->hostname)
10531 {
d1570739
DW
10532 if (use_json)
10533 {
10534 if (p->hostname)
10535 json_object_string_add(json_neigh, "hostname", p->hostname);
10536
10537 if (p->domainname)
10538 json_object_string_add(json_neigh, "domainname", p->domainname);
10539 }
04b6bdc0 10540 else
d1570739
DW
10541 {
10542 if (p->domainname && (p->domainname[0] != '\0'))
10543 vty_out(vty, "Hostname: %s.%s%s", p->hostname, p->domainname,
10544 VTY_NEWLINE);
10545 else
10546 vty_out(vty, "Hostname: %s%s", p->hostname, VTY_NEWLINE);
10547 }
10548
04b6bdc0
DW
10549 }
10550
c744aa9f 10551 /* Peer-group */
718e3744 10552 if (p->group)
f14e6fdb 10553 {
856ca177
MS
10554 if (use_json)
10555 {
10556 json_object_string_add(json_neigh, "peerGroup", p->group->name);
10557
10558 if (dn_flag[0])
10559 {
40ee54a7 10560 struct prefix prefix, *range = NULL;
f14e6fdb 10561
40ee54a7
TT
10562 sockunion2hostprefix(&(p->su), &prefix);
10563 range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix);
856ca177
MS
10564
10565 if (range)
10566 {
10567 prefix2str(range, buf1, sizeof(buf1));
10568 json_object_string_add(json_neigh, "peerSubnetRangeGroup", buf1);
10569 }
10570 }
10571 }
10572 else
f14e6fdb 10573 {
856ca177
MS
10574 vty_out (vty, " Member of peer-group %s for session parameters%s",
10575 p->group->name, VTY_NEWLINE);
f14e6fdb 10576
856ca177 10577 if (dn_flag[0])
f14e6fdb 10578 {
40ee54a7 10579 struct prefix prefix, *range = NULL;
856ca177 10580
40ee54a7
TT
10581 sockunion2hostprefix(&(p->su), &prefix);
10582 range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix);
856ca177
MS
10583
10584 if (range)
10585 {
10586 prefix2str(range, buf1, sizeof(buf1));
10587 vty_out (vty, " Belongs to the subnet range group: %s%s", buf1, VTY_NEWLINE);
10588 }
f14e6fdb
DS
10589 }
10590 }
10591 }
718e3744 10592
856ca177
MS
10593 if (use_json)
10594 {
10595 /* Administrative shutdown. */
10596 if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
10597 json_object_boolean_true_add(json_neigh, "adminShutDown");
718e3744 10598
856ca177
MS
10599 /* BGP Version. */
10600 json_object_int_add(json_neigh, "bgpVersion", 4);
10601 json_object_string_add(json_neigh, "remoteRouterId", inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ));
718e3744 10602
856ca177
MS
10603 /* Confederation */
10604 if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) && bgp_confederation_peers_check (bgp, p->as))
10605 json_object_boolean_true_add(json_neigh, "nbrCommonAdmin");
10606
10607 /* Status. */
10608 json_object_string_add(json_neigh, "bgpState", LOOKUP (bgp_status_msg, p->status));
10609
10610 if (p->status == Established)
10611 {
10612 time_t uptime;
10613 struct tm *tm;
10614
10615 uptime = bgp_clock();
10616 uptime -= p->uptime;
10617 tm = gmtime(&uptime);
10618
10619 json_object_int_add(json_neigh, "bgpTimerUp", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
10620 }
10621
10622 else if (p->status == Active)
10623 {
10624 if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE))
10625 json_object_string_add(json_neigh, "bgpStateIs", "passive");
10626 else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT))
10627 json_object_string_add(json_neigh, "bgpStateIs", "passiveNSF");
10628 }
10629
10630 /* read timer */
10631 time_t uptime;
10632 struct tm *tm;
10633
10634 uptime = bgp_clock();
10635 uptime -= p->readtime;
10636 tm = gmtime(&uptime);
10637 json_object_int_add(json_neigh, "bgpTimerLastRead", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
10638
10639 uptime = bgp_clock();
10640 uptime -= p->last_write;
10641 tm = gmtime(&uptime);
39e871e6
ST
10642 json_object_int_add(json_neigh, "bgpTimerLastWrite", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
10643
10644 uptime = bgp_clock();
10645 uptime -= p->update_time;
10646 tm = gmtime(&uptime);
10647 json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs",
10648 (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
856ca177
MS
10649
10650 /* Configured timer values. */
10651 json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", p->v_holdtime * 1000);
10652 json_object_int_add(json_neigh, "bgpTimerKeepAliveIntervalMsecs", p->v_keepalive * 1000);
10653
10654 if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
10655 {
10656 json_object_int_add(json_neigh, "bgpTimerConfiguredHoldTimeMsecs", p->holdtime * 1000);
10657 json_object_int_add(json_neigh, "bgpTimerConfiguredKeepAliveIntervalMsecs", p->keepalive * 1000);
10658 }
93406d87 10659 }
856ca177
MS
10660 else
10661 {
10662 /* Administrative shutdown. */
10663 if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
10664 vty_out (vty, " Administratively shut down%s", VTY_NEWLINE);
10665
10666 /* BGP Version. */
10667 vty_out (vty, " BGP version 4");
10668 vty_out (vty, ", remote router ID %s%s", inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ),
10669 VTY_NEWLINE);
10670
10671 /* Confederation */
10672 if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION)
10673 && bgp_confederation_peers_check (bgp, p->as))
10674 vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE);
718e3744 10675
856ca177
MS
10676 /* Status. */
10677 vty_out (vty, " BGP state = %s", LOOKUP (bgp_status_msg, p->status));
718e3744 10678
856ca177
MS
10679 if (p->status == Established)
10680 vty_out (vty, ", up for %8s", peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL));
10681
10682 else if (p->status == Active)
10683 {
10684 if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE))
10685 vty_out (vty, " (passive)");
10686 else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT))
10687 vty_out (vty, " (NSF passive)");
10688 }
10689 vty_out (vty, "%s", VTY_NEWLINE);
93406d87 10690
856ca177
MS
10691 /* read timer */
10692 vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN, 0, NULL));
10693 vty_out (vty, ", Last write %s%s",
10694 peer_uptime (p->last_write, timebuf, BGP_UPTIME_LEN, 0, NULL), VTY_NEWLINE);
10695
10696 /* Configured timer values. */
10697 vty_out (vty, " Hold time is %d, keepalive interval is %d seconds%s",
10698 p->v_holdtime, p->v_keepalive, VTY_NEWLINE);
10699 if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
10700 {
10701 vty_out (vty, " Configured hold time is %d", p->holdtime);
10702 vty_out (vty, ", keepalive interval is %d seconds%s",
10703 p->keepalive, VTY_NEWLINE);
10704 }
10705 }
718e3744 10706 /* Capability. */
10707 if (p->status == Established)
10708 {
538621f2 10709 if (p->cap
718e3744 10710 || p->afc_adv[AFI_IP][SAFI_UNICAST]
10711 || p->afc_recv[AFI_IP][SAFI_UNICAST]
10712 || p->afc_adv[AFI_IP][SAFI_MULTICAST]
10713 || p->afc_recv[AFI_IP][SAFI_MULTICAST]
10714#ifdef HAVE_IPV6
10715 || p->afc_adv[AFI_IP6][SAFI_UNICAST]
10716 || p->afc_recv[AFI_IP6][SAFI_UNICAST]
10717 || p->afc_adv[AFI_IP6][SAFI_MULTICAST]
10718 || p->afc_recv[AFI_IP6][SAFI_MULTICAST]
945c8fe9
LB
10719 || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN]
10720 || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN]
8b1fb8be
LB
10721 || p->afc_adv[AFI_IP6][SAFI_ENCAP]
10722 || p->afc_recv[AFI_IP6][SAFI_ENCAP]
718e3744 10723#endif /* HAVE_IPV6 */
8b1fb8be
LB
10724 || p->afc_adv[AFI_IP][SAFI_ENCAP]
10725 || p->afc_recv[AFI_IP][SAFI_ENCAP]
718e3744 10726 || p->afc_adv[AFI_IP][SAFI_MPLS_VPN]
10727 || p->afc_recv[AFI_IP][SAFI_MPLS_VPN])
10728 {
856ca177
MS
10729 if (use_json)
10730 {
10731 json_object *json_cap = NULL;
10732
10733 json_cap = json_object_new_object();
10734
10735 /* AS4 */
10736 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)
10737 || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
10738 {
10739 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) && CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
10740 json_object_string_add(json_cap, "4byteAs", "advertisedAndReceived");
10741 else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
10742 json_object_string_add(json_cap, "4byteAs", "advertised");
10743 else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
10744 json_object_string_add(json_cap, "4byteAs", "received");
10745 }
10746
10747 /* AddPath */
10748 if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV)
10749 || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV))
10750 {
10751 json_object *json_add = NULL;
10752 const char *print_store;
718e3744 10753
856ca177 10754 json_add = json_object_new_object();
a82478b9 10755
856ca177
MS
10756 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
10757 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
10758 {
10759 json_object *json_sub = NULL;
10760 json_sub = json_object_new_object();
10761 print_store = afi_safi_print (afi, safi);
10762
10763 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ||
10764 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
10765 {
10766 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))
10767 json_object_boolean_true_add(json_sub, "txAdvertisedAndReceived");
10768 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV))
10769 json_object_boolean_true_add(json_sub, "txAdvertised");
10770 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
10771 json_object_boolean_true_add(json_sub, "txReceived");
10772 }
10773
10774 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
10775 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
10776 {
10777 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))
10778 json_object_boolean_true_add(json_sub, "rxAdvertisedAndReceived");
10779 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV))
10780 json_object_boolean_true_add(json_sub, "rxAdvertised");
10781 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
10782 json_object_boolean_true_add(json_sub, "rxReceived");
10783 }
10784
10785 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ||
10786 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV) ||
10787 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
10788 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
10789 json_object_object_add(json_add, print_store, json_sub);
10790 }
a82478b9 10791
856ca177
MS
10792 json_object_object_add(json_cap, "addPath", json_add);
10793 }
10794
10795 /* Dynamic */
10796 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
10797 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
10798 {
10799 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) && CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
10800 json_object_string_add(json_cap, "dynamic", "advertisedAndReceived");
10801 else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
10802 json_object_string_add(json_cap, "dynamic", "advertised");
10803 else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
10804 json_object_string_add(json_cap, "dynamic", "received");
10805 }
10806
10807 /* Extended nexthop */
10808 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)
10809 || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
10810 {
10811 json_object *json_nxt = NULL;
10812 const char *print_store;
10813
10814 json_nxt = json_object_new_object();
10815
10816 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) && CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
10817 json_object_string_add(json_cap, "extendedNexthop", "advertisedAndReceived");
10818 else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
10819 json_object_string_add(json_cap, "extendedNexthop", "advertised");
10820 else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
10821 json_object_string_add(json_cap, "extendedNexthop", "received");
10822
10823 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
10824 {
10825 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
10826 {
10827 if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV))
10828 {
10829 print_store = afi_safi_print (AFI_IP, safi);
10830 json_object_string_add(json_nxt, print_store, "recieved");
10831 }
10832 }
10833 json_object_object_add(json_cap, "extendedNexthopFamililesByPeer", json_nxt);
10834 }
10835 }
10836
10837 /* Route Refresh */
10838 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
10839 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
10840 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
10841 {
10842 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)))
10843 {
10844 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV))
10845 json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOldNew");
10846 else
10847 {
10848 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
10849 json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOld");
10850 else
10851 json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedNew");
10852 }
10853 }
10854 else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
10855 json_object_string_add(json_cap, "routeRefresh", "advertised");
10856 else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
10857 json_object_string_add(json_cap, "routeRefresh", "received");
10858 }
10859
10860 /* Multiprotocol Extensions */
10861 json_object *json_multi = NULL;
10862 json_multi = json_object_new_object();
10863
10864 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
10865 {
10866 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
10867 {
10868 if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
10869 {
10870 json_object *json_exten = NULL;
10871 json_exten = json_object_new_object();
10872
10873 if (p->afc_adv[afi][safi] && p->afc_recv[afi][safi])
10874 json_object_boolean_true_add(json_exten, "advertisedAndReceived");
10875 else if (p->afc_adv[afi][safi])
10876 json_object_boolean_true_add(json_exten, "advertised");
10877 else if (p->afc_recv[afi][safi])
10878 json_object_boolean_true_add(json_exten, "received");
10879
10880 json_object_object_add(json_multi, afi_safi_print (afi, safi), json_exten);
10881 }
10882 }
10883 }
10884 json_object_object_add(json_cap, "multiprotocolExtensions", json_multi);
10885
10886 /* Gracefull Restart */
10887 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
10888 || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
10889 {
10890 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) && CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
10891 json_object_string_add(json_cap, "gracefulRestart", "advertisedAndReceived");
10892 else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
10893 json_object_string_add(json_cap, "gracefulRestartCapability", "advertised");
10894 else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
10895 json_object_string_add(json_cap, "gracefulRestartCapability", "received");
10896
10897 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
10898 {
10899 int restart_af_count = 0;
10900 json_object *json_restart = NULL;
10901 json_restart = json_object_new_object();
10902
10903 json_object_int_add(json_cap, "gracefulRestartRemoteTimerMsecs", p->v_gr_restart * 1000);
10904
10905 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
10906 {
10907 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
10908 {
10909 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
10910 {
10911 json_object *json_sub = NULL;
10912 json_sub = json_object_new_object();
10913
10914 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV))
10915 json_object_boolean_true_add(json_sub, "preserved");
10916 restart_af_count++;
10917 json_object_object_add(json_restart, afi_safi_print (afi, safi), json_sub);
10918 }
10919 }
10920 }
10921 if (! restart_af_count)
10922 json_object_string_add(json_cap, "addressFamiliesByPeer", "none");
10923 else
10924 json_object_object_add(json_cap, "addressFamiliesByPeer", json_restart);
10925 }
10926 }
10927 json_object_object_add(json_neigh, "neighborCapabilities", json_cap);
10928 }
10929 else
10930 {
10931 vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE);
10932
10933 /* AS4 */
10934 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)
10935 || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
10936 {
10937 vty_out (vty, " 4 Byte AS:");
10938 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
10939 vty_out (vty, " advertised");
10940 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
10941 vty_out (vty, " %sreceived",
10942 CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : "");
10943 vty_out (vty, "%s", VTY_NEWLINE);
10944 }
10945
10946 /* AddPath */
10947 if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV)
10948 || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV))
10949 {
10950 vty_out (vty, " AddPath:%s", VTY_NEWLINE);
a82478b9 10951
856ca177
MS
10952 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
10953 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
a82478b9 10954 {
856ca177
MS
10955 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ||
10956 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
10957 {
10958 vty_out (vty, " %s: TX ", afi_safi_print (afi, safi));
a82478b9 10959
856ca177
MS
10960 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV))
10961 vty_out (vty, "advertised %s", afi_safi_print (afi, safi));
a82478b9 10962
856ca177
MS
10963 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
10964 vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ? " and " : "" );
a82478b9 10965
856ca177
MS
10966 vty_out (vty, "%s", VTY_NEWLINE);
10967 }
a82478b9 10968
856ca177 10969 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
a82478b9 10970 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
856ca177
MS
10971 {
10972 vty_out (vty, " %s: RX ", afi_safi_print (afi, safi));
a82478b9 10973
856ca177
MS
10974 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV))
10975 vty_out (vty, "advertised %s", afi_safi_print (afi, safi));
a82478b9 10976
856ca177
MS
10977 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
10978 vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ? " and " : "" );
a82478b9 10979
856ca177
MS
10980 vty_out (vty, "%s", VTY_NEWLINE);
10981 }
a82478b9 10982 }
856ca177 10983 }
a82478b9 10984
856ca177
MS
10985 /* Dynamic */
10986 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
10987 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
10988 {
10989 vty_out (vty, " Dynamic:");
10990 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
10991 vty_out (vty, " advertised");
10992 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
10993 vty_out (vty, " %sreceived",
10994 CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : "");
10995 vty_out (vty, "%s", VTY_NEWLINE);
10996 }
10997
10998 /* Extended nexthop */
10999 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)
11000 || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
11001 {
11002 vty_out (vty, " Extended nexthop:");
11003 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
11004 vty_out (vty, " advertised");
11005 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
11006 vty_out (vty, " %sreceived",
11007 CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) ? "and " : "");
11008 vty_out (vty, "%s", VTY_NEWLINE);
718e3744 11009
856ca177
MS
11010 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
11011 {
11012 vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE);
11013 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11014 if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV))
11015 vty_out (vty, " %s%s",
11016 afi_safi_print (AFI_IP, safi), VTY_NEWLINE);
11017 }
11018 }
8a92a8a0 11019
856ca177
MS
11020 /* Route Refresh */
11021 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
11022 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
11023 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
11024 {
11025 vty_out (vty, " Route refresh:");
11026 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
11027 vty_out (vty, " advertised");
11028 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
11029 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
11030 vty_out (vty, " %sreceived(%s)",
11031 CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "",
11032 (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)
11033 && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ?
11034 "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new");
8a92a8a0 11035
856ca177
MS
11036 vty_out (vty, "%s", VTY_NEWLINE);
11037 }
718e3744 11038
856ca177
MS
11039 /* Multiprotocol Extensions */
11040 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11041 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11042 if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
11043 {
11044 vty_out (vty, " Address family %s:", afi_safi_print (afi, safi));
11045 if (p->afc_adv[afi][safi])
11046 vty_out (vty, " advertised");
11047 if (p->afc_recv[afi][safi])
11048 vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : "");
11049 vty_out (vty, "%s", VTY_NEWLINE);
11050 }
538621f2 11051
04b6bdc0
DW
11052 /* Hostname capability */
11053 if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV) ||
11054 CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV))
11055 {
11056 vty_out (vty, " Hostname Capability:");
11057 if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV))
11058 vty_out (vty, " advertised");
11059 if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_RCV))
11060 vty_out (vty, " %sreceived",
11061 CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV) ? "and " : "");
11062 vty_out (vty, "%s", VTY_NEWLINE);
11063 }
11064
856ca177
MS
11065 /* Gracefull Restart */
11066 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
11067 || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
11068 {
11069 vty_out (vty, " Graceful Restart Capabilty:");
11070 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
538621f2 11071 vty_out (vty, " advertised");
856ca177
MS
11072 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
11073 vty_out (vty, " %sreceived",
11074 CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : "");
11075 vty_out (vty, "%s", VTY_NEWLINE);
538621f2 11076
856ca177
MS
11077 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
11078 {
11079 int restart_af_count = 0;
11080
11081 vty_out (vty, " Remote Restart timer is %d seconds%s",
11082 p->v_gr_restart, VTY_NEWLINE);
11083 vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE);
11084
11085 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11086 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11087 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
11088 {
11089 vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "",
11090 afi_safi_print (afi, safi),
11091 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ?
11092 "preserved" : "not preserved");
11093 restart_af_count++;
11094 }
11095 if (! restart_af_count)
11096 vty_out (vty, "none");
11097 vty_out (vty, "%s", VTY_NEWLINE);
11098 }
11099 }
11100 }
718e3744 11101 }
11102 }
11103
93406d87 11104 /* graceful restart information */
11105 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
11106 || p->t_gr_restart
11107 || p->t_gr_stale)
11108 {
856ca177
MS
11109 json_object *json_grace = NULL;
11110 json_object *json_grace_send = NULL;
11111 json_object *json_grace_recv = NULL;
93406d87 11112 int eor_send_af_count = 0;
11113 int eor_receive_af_count = 0;
11114
856ca177
MS
11115 if (use_json)
11116 {
11117 json_grace = json_object_new_object();
11118 json_grace_send = json_object_new_object();
11119 json_grace_recv = json_object_new_object();
11120
11121 if (p->status == Established)
11122 {
11123 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11124 {
11125 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11126 {
11127 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND))
11128 {
11129 json_object_boolean_true_add(json_grace_send, afi_safi_print (afi, safi));
11130 eor_send_af_count++;
11131 }
11132 }
11133 }
11134 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11135 {
11136 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11137 {
11138 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED))
11139 {
11140 json_object_boolean_true_add(json_grace_recv, afi_safi_print (afi, safi));
11141 eor_receive_af_count++;
11142 }
11143 }
11144 }
11145 }
11146
11147 json_object_object_add(json_grace, "endOfRibSend", json_grace_send);
11148 json_object_object_add(json_grace, "endOfRibRecv", json_grace_recv);
11149
11150 if (p->t_gr_restart)
11151 json_object_int_add(json_grace, "gracefulRestartTimerMsecs", thread_timer_remain_second (p->t_gr_restart) * 1000);
11152
11153 if (p->t_gr_stale)
11154 json_object_int_add(json_grace, "gracefulStalepathTimerMsecs", thread_timer_remain_second (p->t_gr_stale) * 1000);
11155
11156 json_object_object_add(json_neigh, "gracefulRestartInfo", json_grace);
11157 }
11158 else
11159 {
11160 vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE);
11161 if (p->status == Established)
11162 {
11163 vty_out (vty, " End-of-RIB send: ");
11164 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11165 {
11166 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11167 {
11168 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND))
11169 {
11170 vty_out (vty, "%s%s", eor_send_af_count ? ", " : "",
11171 afi_safi_print (afi, safi));
11172 eor_send_af_count++;
11173 }
11174 }
11175 }
11176 vty_out (vty, "%s", VTY_NEWLINE);
11177 vty_out (vty, " End-of-RIB received: ");
11178 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11179 {
11180 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11181 {
11182 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED))
11183 {
11184 vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "",
11185 afi_safi_print (afi, safi));
11186 eor_receive_af_count++;
11187 }
11188 }
11189 }
11190 vty_out (vty, "%s", VTY_NEWLINE);
11191 }
93406d87 11192
856ca177
MS
11193 if (p->t_gr_restart)
11194 vty_out (vty, " The remaining time of restart timer is %ld%s",
11195 thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE);
0b2aa3a0 11196
856ca177
MS
11197 if (p->t_gr_stale)
11198 vty_out (vty, " The remaining time of stalepath timer is %ld%s",
11199 thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE);
11200 }
11201 }
11202 if (use_json)
11203 {
11204 json_object *json_stat = NULL;
11205 json_stat = json_object_new_object();
11206 /* Packet counts. */
11207 json_object_int_add(json_stat, "depthInq", 0);
11208 json_object_int_add(json_stat, "depthOutq", (unsigned long) p->obuf->count);
11209 json_object_int_add(json_stat, "opensSent", p->open_out);
11210 json_object_int_add(json_stat, "opensRecv", p->open_in);
11211 json_object_int_add(json_stat, "notificationsSent", p->notify_out);
11212 json_object_int_add(json_stat, "notificationsRecv", p->notify_in);
11213 json_object_int_add(json_stat, "updatesSent", p->update_out);
11214 json_object_int_add(json_stat, "updatesRecv", p->update_in);
11215 json_object_int_add(json_stat, "keepalivesSent", p->keepalive_out);
11216 json_object_int_add(json_stat, "keepalivesRecv", p->keepalive_in);
11217 json_object_int_add(json_stat, "routeRefreshSent", p->refresh_out);
11218 json_object_int_add(json_stat, "routeRefreshRecv", p->refresh_in);
11219 json_object_int_add(json_stat, "capabilitySent", p->dynamic_cap_out);
11220 json_object_int_add(json_stat, "capabilityRecv", p->dynamic_cap_in);
11221 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);
11222 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);
11223 json_object_object_add(json_neigh, "messageStats", json_stat);
11224 }
11225 else
11226 {
11227 /* Packet counts. */
11228 vty_out (vty, " Message statistics:%s", VTY_NEWLINE);
11229 vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE);
11230 vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE);
11231 vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE);
11232 vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE);
11233 vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE);
11234 vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE);
11235 vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE);
11236 vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE);
11237 vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE);
11238 vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out +
11239 p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out,
11240 p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in +
11241 p->dynamic_cap_in, VTY_NEWLINE);
718e3744 11242 }
11243
856ca177
MS
11244 if (use_json)
11245 {
11246 /* advertisement-interval */
11247 json_object_int_add(json_neigh, "minBtwnAdvertisementRunsTimerMsecs", p->v_routeadv * 1000);
718e3744 11248
856ca177
MS
11249 /* Update-source. */
11250 if (p->update_if || p->update_source)
11251 {
11252 if (p->update_if)
11253 json_object_string_add(json_neigh, "updateSource", p->update_if);
11254 else if (p->update_source)
11255 json_object_string_add(json_neigh, "updateSource", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
11256 }
11257
11258 /* Default weight */
11259 if (CHECK_FLAG (p->config, PEER_CONFIG_WEIGHT))
11260 json_object_int_add(json_neigh, "defaultWeight", p->weight);
11261
11262 }
11263 else
11264 {
11265 /* advertisement-interval */
11266 vty_out (vty, " Minimum time between advertisement runs is %d seconds%s",
11267 p->v_routeadv, VTY_NEWLINE);
11268
11269 /* Update-source. */
11270 if (p->update_if || p->update_source)
11271 {
11272 vty_out (vty, " Update source is ");
11273 if (p->update_if)
11274 vty_out (vty, "%s", p->update_if);
11275 else if (p->update_source)
11276 vty_out (vty, "%s", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
11277 vty_out (vty, "%s", VTY_NEWLINE);
11278 }
11279
11280 /* Default weight */
11281 if (CHECK_FLAG (p->config, PEER_CONFIG_WEIGHT))
11282 vty_out (vty, " Default weight %d%s", p->weight, VTY_NEWLINE);
11283
11284 vty_out (vty, "%s", VTY_NEWLINE);
11285 }
718e3744 11286
11287 /* Address Family Information */
856ca177
MS
11288 json_object *json_hold = NULL;
11289
11290 if (use_json)
11291 json_hold = json_object_new_object();
11292
538621f2 11293 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11294 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11295 if (p->afc[afi][safi])
856ca177 11296 bgp_show_peer_afi (vty, p, afi, safi, use_json, json_hold);
718e3744 11297
856ca177
MS
11298 if (use_json)
11299 {
11300 json_object_int_add(json_hold, "connectionsEstablished", p->established);
11301 json_object_int_add(json_hold, "connectionsDropped", p->dropped);
11302 }
11303 else
11304 vty_out (vty, " Connections established %d; dropped %d%s", p->established, p->dropped,
11305 VTY_NEWLINE);
718e3744 11306
d6661008 11307 if (! p->last_reset)
856ca177
MS
11308 {
11309 if (use_json)
11310 json_object_string_add(json_hold, "lastReset", "never");
11311 else
11312 vty_out (vty, " Last reset never%s", VTY_NEWLINE);
11313 }
e0701b79 11314 else
d6661008 11315 {
856ca177
MS
11316 if (use_json)
11317 {
11318 time_t uptime;
11319 struct tm *tm;
11320
11321 uptime = bgp_clock();
11322 uptime -= p->resettime;
11323 tm = gmtime(&uptime);
11324 json_object_int_add(json_hold, "lastResetTimerMsecs", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
11325 json_object_string_add(json_hold, "lastResetDueTo", peer_down_str[(int) p->last_reset]);
11326 if (p->last_reset_cause_size)
11327 {
39e871e6
ST
11328 char errorcodesubcode_hexstr[5];
11329 sprintf(errorcodesubcode_hexstr, "%02X%02X", p->notify.code, p->notify.subcode);
11330 json_object_string_add(json_hold, "lastErrorCodeSubcode", errorcodesubcode_hexstr);
856ca177
MS
11331 }
11332 }
11333 else
d6661008 11334 {
3a8c7ba1
DW
11335 vty_out (vty, " Last reset %s, ",
11336 peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN, 0, NULL));
11337
11338 if (p->last_reset == PEER_DOWN_NOTIFY_SEND ||
11339 p->last_reset == PEER_DOWN_NOTIFY_RECEIVED)
11340 {
11341 code_str = bgp_notify_code_str(p->notify.code);
11342 subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode);
11343 vty_out (vty, "due to NOTIFICATION %s (%s%s)%s",
11344 p->last_reset == PEER_DOWN_NOTIFY_SEND ? "sent" : "received",
11345 code_str, subcode_str, VTY_NEWLINE);
11346 }
11347 else
11348 {
11349 vty_out (vty, "due to %s%s",
11350 peer_down_str[(int) p->last_reset], VTY_NEWLINE);
11351 }
856ca177
MS
11352
11353 if (p->last_reset_cause_size)
d6661008 11354 {
856ca177
MS
11355 msg = p->last_reset_cause;
11356 vty_out(vty, " Message received that caused BGP to send a NOTIFICATION:%s ", VTY_NEWLINE);
11357 for (i = 1; i <= p->last_reset_cause_size; i++)
11358 {
11359 vty_out(vty, "%02X", *msg++);
d6661008 11360
856ca177
MS
11361 if (i != p->last_reset_cause_size)
11362 {
11363 if (i % 16 == 0)
11364 {
11365 vty_out(vty, "%s ", VTY_NEWLINE);
11366 }
11367 else if (i % 4 == 0)
11368 {
11369 vty_out(vty, " ");
11370 }
11371 }
11372 }
11373 vty_out(vty, "%s", VTY_NEWLINE);
d6661008 11374 }
d6661008
DS
11375 }
11376 }
848973c7 11377
718e3744 11378 if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW))
11379 {
856ca177
MS
11380 if (use_json)
11381 json_object_boolean_true_add(json_hold, "prefixesConfigExceedMax");
11382 else
11383 vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE);
0a486e5f 11384
11385 if (p->t_pmax_restart)
856ca177
MS
11386 {
11387 if (use_json)
11388 {
e8f7da3a 11389 json_object_boolean_true_add(json_hold, "reducePrefixNumFrom");
856ca177
MS
11390 json_object_int_add(json_hold, "restartInTimerMsec", thread_timer_remain_second (p->t_pmax_restart) * 1000);
11391 }
11392 else
11393 vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s",
11394 p->host, thread_timer_remain_second (p->t_pmax_restart),
11395 VTY_NEWLINE);
11396 }
0a486e5f 11397 else
856ca177
MS
11398 {
11399 if (use_json)
e8f7da3a 11400 json_object_boolean_true_add(json_hold, "reducePrefixNumAndClearIpBgp");
856ca177
MS
11401 else
11402 vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s",
11403 p->host, VTY_NEWLINE);
11404 }
718e3744 11405 }
11406
856ca177
MS
11407 if (use_json)
11408 json_object_object_add(json_neigh, "addressFamilyInfo", json_hold);
11409
f5a4827d 11410 /* EBGP Multihop and GTSM */
6d85b15b 11411 if (p->sort != BGP_PEER_IBGP)
f5a4827d 11412 {
856ca177
MS
11413 if (use_json)
11414 {
11415 if (p->gtsm_hops > 0)
11416 json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->gtsm_hops);
11417 else if (p->ttl > 1)
11418 json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->ttl);
11419 }
11420 else
11421 {
11422 if (p->gtsm_hops > 0)
11423 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
11424 p->gtsm_hops, VTY_NEWLINE);
11425 else if (p->ttl > 1)
11426 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
11427 p->ttl, VTY_NEWLINE);
11428 }
f5a4827d 11429 }
5d804b43
PM
11430 else
11431 {
11432 if (p->gtsm_hops > 0)
856ca177
MS
11433 {
11434 if (use_json)
11435 json_object_int_add(json_neigh, "internalBgpNbrMaxHopsAway", p->gtsm_hops);
11436 else
11437 vty_out (vty, " Internal BGP neighbor may be up to %d hops away.%s",
11438 p->gtsm_hops, VTY_NEWLINE);
11439 }
5d804b43 11440 }
718e3744 11441
11442 /* Local address. */
11443 if (p->su_local)
11444 {
856ca177
MS
11445 if (use_json)
11446 {
11447 json_object_string_add(json_neigh, "hostLocal", sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN));
11448 json_object_int_add(json_neigh, "portLocal", ntohs (p->su_local->sin.sin_port));
11449 }
11450 else
11451 vty_out (vty, "Local host: %s, Local port: %d%s",
11452 sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN),
11453 ntohs (p->su_local->sin.sin_port),
11454 VTY_NEWLINE);
718e3744 11455 }
11456
11457 /* Remote address. */
11458 if (p->su_remote)
11459 {
856ca177
MS
11460 if (use_json)
11461 {
11462 json_object_string_add(json_neigh, "hostForeign", sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN));
11463 json_object_int_add(json_neigh, "portForeign", ntohs (p->su_remote->sin.sin_port));
11464 }
11465 else
11466 vty_out (vty, "Foreign host: %s, Foreign port: %d%s",
718e3744 11467 sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN),
11468 ntohs (p->su_remote->sin.sin_port),
11469 VTY_NEWLINE);
11470 }
11471
11472 /* Nexthop display. */
11473 if (p->su_local)
11474 {
856ca177
MS
11475 if (use_json)
11476 {
11477 json_object_string_add(json_neigh, "nexthop", inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ));
718e3744 11478#ifdef HAVE_IPV6
856ca177
MS
11479 json_object_string_add(json_neigh, "nexthopGlobal", inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ));
11480 json_object_string_add(json_neigh, "nexthopLocal", inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ));
11481 if (p->shared_network)
11482 json_object_string_add(json_neigh, "bgpConnection", "sharedNetwork");
11483 else
11484 json_object_string_add(json_neigh, "bgpConnection", "nonSharedNetwork");
11485#endif /* HAVE_IPV6 */
11486 }
11487 else
11488 {
11489 vty_out (vty, "Nexthop: %s%s",
11490 inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ),
11491 VTY_NEWLINE);
11492#ifdef HAVE_IPV6
11493 vty_out (vty, "Nexthop global: %s%s",
11494 inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ),
11495 VTY_NEWLINE);
11496 vty_out (vty, "Nexthop local: %s%s",
11497 inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ),
11498 VTY_NEWLINE);
11499 vty_out (vty, "BGP connection: %s%s",
11500 p->shared_network ? "shared network" : "non shared network",
11501 VTY_NEWLINE);
718e3744 11502#endif /* HAVE_IPV6 */
856ca177 11503 }
718e3744 11504 }
11505
11506 /* Timer information. */
856ca177
MS
11507 if (use_json)
11508 {
39e871e6 11509 json_object_int_add(json_neigh, "connectRetryTimer", p->v_connect);
dd9275d6
ST
11510 if (p->status == Established && p->rtt)
11511 json_object_int_add(json_neigh, "estimatedRttInMsecs", p->rtt);
856ca177
MS
11512 if (p->t_start)
11513 json_object_int_add(json_neigh, "nextStartTimerDueInMsecs", thread_timer_remain_second (p->t_start) * 1000);
11514 if (p->t_connect)
11515 json_object_int_add(json_neigh, "nextConnectTimerDueInMsecs", thread_timer_remain_second (p->t_connect) * 1000);
11516 if (p->t_routeadv)
11517 {
11518 json_object_int_add(json_neigh, "mraiInterval", p->v_routeadv);
11519 json_object_int_add(json_neigh, "mraiTimerExpireInMsecs", thread_timer_remain_second (p->t_routeadv) * 1000);
11520 }
cb1faec9 11521
856ca177
MS
11522 if (p->t_read)
11523 json_object_string_add(json_neigh, "readThread", "on");
11524 else
11525 json_object_string_add(json_neigh, "readThread", "off");
11526 if (p->t_write)
11527 json_object_string_add(json_neigh, "writeThread", "on");
11528 else
11529 json_object_string_add(json_neigh, "writeThread", "off");
11530 }
11531 else
11532 {
39e871e6
ST
11533 vty_out (vty, "BGP Connect Retry Timer in Seconds: %d%s",
11534 p->v_connect, VTY_NEWLINE);
dd9275d6
ST
11535 if (p->status == Established && p->rtt)
11536 vty_out (vty, "Estimated round trip time: %d ms%s",
11537 p->rtt, VTY_NEWLINE);
856ca177
MS
11538 if (p->t_start)
11539 vty_out (vty, "Next start timer due in %ld seconds%s",
11540 thread_timer_remain_second (p->t_start), VTY_NEWLINE);
11541 if (p->t_connect)
11542 vty_out (vty, "Next connect timer due in %ld seconds%s",
11543 thread_timer_remain_second (p->t_connect), VTY_NEWLINE);
11544 if (p->t_routeadv)
11545 vty_out (vty, "MRAI (interval %u) timer expires in %ld seconds%s",
11546 p->v_routeadv, thread_timer_remain_second (p->t_routeadv),
11547 VTY_NEWLINE);
11548
11549 vty_out (vty, "Read thread: %s Write thread: %s%s",
11550 p->t_read ? "on" : "off",
11551 p->t_write ? "on" : "off",
11552 VTY_NEWLINE);
11553 }
718e3744 11554
11555 if (p->notify.code == BGP_NOTIFY_OPEN_ERR
11556 && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL)
856ca177
MS
11557 bgp_capability_vty_out (vty, p, use_json, json_neigh);
11558
11559 if (!use_json)
11560 vty_out (vty, "%s", VTY_NEWLINE);
c43ed2e4
DS
11561
11562 /* BFD information. */
856ca177
MS
11563 bgp_bfd_show_info(vty, p, use_json, json_neigh);
11564
11565 if (use_json)
11566 {
11567 if (p->conf_if) /* Configured interface name. */
11568 json_object_object_add(json, p->conf_if, json_neigh);
11569 else /* Configured IP address. */
11570 json_object_object_add(json, p->host, json_neigh);
11571 }
718e3744 11572}
11573
94f2b392 11574static int
856ca177
MS
11575bgp_show_neighbor (struct vty *vty, struct bgp *bgp, enum show_type type,
11576 union sockunion *su, const char *conf_if, u_char use_json, json_object *json)
718e3744 11577{
1eb8ef25 11578 struct listnode *node, *nnode;
718e3744 11579 struct peer *peer;
11580 int find = 0;
11581
1eb8ef25 11582 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
718e3744 11583 {
1ff9a340
DS
11584 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
11585 continue;
11586
718e3744 11587 switch (type)
856ca177
MS
11588 {
11589 case show_all:
e8f7da3a 11590 bgp_show_peer (vty, peer, use_json, json);
856ca177
MS
11591 break;
11592 case show_peer:
11593 if (conf_if)
11594 {
4873b3b9
DW
11595 if ((peer->conf_if && !strcmp(peer->conf_if, conf_if)) ||
11596 (peer->hostname && !strcmp(peer->hostname, conf_if)))
856ca177
MS
11597 {
11598 find = 1;
e8f7da3a 11599 bgp_show_peer (vty, peer, use_json, json);
856ca177
MS
11600 }
11601 }
11602 else
11603 {
11604 if (sockunion_same (&peer->su, su))
11605 {
11606 find = 1;
e8f7da3a 11607 bgp_show_peer (vty, peer, use_json, json);
856ca177
MS
11608 }
11609 }
11610 break;
718e3744 11611 }
11612 }
11613
11614 if (type == show_peer && ! find)
856ca177
MS
11615 {
11616 if (use_json)
11617 json_object_boolean_true_add(json, "bgpNoSuchNeighbor");
11618 else
11619 vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE);
11620 }
11621
11622 if (use_json)
11623 {
11624 vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
11625 json_object_free(json);
11626 }
11627 else
11628 {
11629 vty_out (vty, "%s", VTY_NEWLINE);
11630 }
11631
718e3744 11632 return CMD_SUCCESS;
11633}
11634
94f2b392 11635static int
fd79ac91 11636bgp_show_neighbor_vty (struct vty *vty, const char *name,
9f689658
DD
11637 enum show_type type, const char *ip_str, u_char use_json,
11638 json_object *json)
718e3744 11639{
11640 int ret;
11641 struct bgp *bgp;
11642 union sockunion su;
856ca177 11643
9f689658 11644 if (use_json && (json == NULL))
856ca177 11645 json = json_object_new_object();
718e3744 11646
718e3744 11647 if (name)
11648 {
11649 bgp = bgp_lookup_by_name (name);
718e3744 11650 if (! bgp)
11651 {
856ca177
MS
11652 if (use_json)
11653 {
11654 json_object_boolean_true_add(json, "bgpNoSuchInstance");
11655 vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
11656 json_object_free(json);
11657 }
11658 else
11659 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
11660
718e3744 11661 return CMD_WARNING;
11662 }
718e3744 11663 }
a80beece
DS
11664 else
11665 {
11666 bgp = bgp_get_default ();
11667 }
718e3744 11668
11669 if (bgp)
a80beece
DS
11670 {
11671 if (ip_str)
11672 {
11673 ret = str2sockunion (ip_str, &su);
11674 if (ret < 0)
856ca177 11675 bgp_show_neighbor (vty, bgp, type, NULL, ip_str, use_json, json);
a80beece 11676 else
856ca177 11677 bgp_show_neighbor (vty, bgp, type, &su, NULL, use_json, json);
a80beece
DS
11678 }
11679 else
11680 {
856ca177 11681 bgp_show_neighbor (vty, bgp, type, NULL, NULL, use_json, json);
a80beece
DS
11682 }
11683 }
718e3744 11684
11685 return CMD_SUCCESS;
11686}
11687
f186de26 11688static void
11689bgp_show_all_instances_neighbors_vty (struct vty *vty, u_char use_json)
11690{
11691 struct listnode *node, *nnode;
11692 struct bgp *bgp;
11693 json_object *json = NULL;
9f689658
DD
11694 int is_first = 1;
11695
11696 if (use_json)
11697 vty_out (vty, "{%s", VTY_NEWLINE);
f186de26 11698
11699 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
11700 {
f186de26 11701 if (use_json)
9f689658
DD
11702 {
11703 if (!(json = json_object_new_object()))
11704 {
11705 zlog_err("Unable to allocate memory for JSON object");
11706 vty_out (vty,
11707 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s",
11708 VTY_NEWLINE);
11709 return;
11710 }
11711
11712 json_object_int_add(json, "vrfId",
11713 (bgp->vrf_id == VRF_UNKNOWN)
11714 ? -1 : bgp->vrf_id);
11715 json_object_string_add(json, "vrfName",
11716 (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
11717 ? "Default" : bgp->name);
11718
11719 if (! is_first)
11720 vty_out (vty, ",%s", VTY_NEWLINE);
11721 else
11722 is_first = 0;
11723
11724 vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
11725 ? "Default" : bgp->name);
11726 }
11727 else
11728 {
11729 vty_out (vty, "%sInstance %s:%s",
11730 VTY_NEWLINE,
11731 (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
11732 ? "Default" : bgp->name,
11733 VTY_NEWLINE);
11734 }
f186de26 11735 bgp_show_neighbor (vty, bgp, show_all, NULL, NULL, use_json, json);
11736 }
9f689658
DD
11737
11738 if (use_json)
11739 vty_out (vty, "}%s", VTY_NEWLINE);
f186de26 11740}
11741
718e3744 11742/* "show ip bgp neighbors" commands. */
f412b39a
DW
11743/*
11744 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
b162fa78 11745 * "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors [json]",
f412b39a
DW
11746 * SHOW_STR
11747 * IP_STR
11748 * BGP_STR
11749 * "Display VPNv4 NLRI specific information\n"
11750 * "Display information for a route distinguisher\n"
11751 * "VPN Route Distinguisher\n"
11752 * "Detailed information on TCP and BGP neighbor connections\n"
11753 * "JavaScript Object Notation\n"
11754 *
b162fa78 11755 * "show bgp neighbors [json]",
f412b39a
DW
11756 * SHOW_STR
11757 * BGP_STR
11758 * "Detailed information on TCP and BGP neighbor connections\n"
11759 * "JavaScript Object Notation\n"
11760 *
b162fa78 11761 * "show ip bgp vpnv4 all neighbors [json]",
f412b39a
DW
11762 * SHOW_STR
11763 * IP_STR
11764 * BGP_STR
11765 * "Display VPNv4 NLRI specific information\n"
11766 * "Display information about all VPNv4 NLRIs\n"
11767 * "Detailed information on TCP and BGP neighbor connections\n"
11768 * "JavaScript Object Notation\n"
11769 *
b162fa78 11770 * "show ip bgp ipv4 (unicast|multicast) neighbors [json]",
f412b39a
DW
11771 * SHOW_STR
11772 * IP_STR
11773 * BGP_STR
11774 * "Address family\n"
11775 * "Address Family modifier\n"
11776 * "Address Family modifier\n"
11777 * "Detailed information on TCP and BGP neighbor connections\n"
11778 * "JavaScript Object Notation\n"
11779 *
b162fa78 11780 * "show bgp ipv6 neighbors [json]",
f412b39a
DW
11781 * SHOW_STR
11782 * BGP_STR
11783 * "Address family\n"
11784 * "Detailed information on TCP and BGP neighbor connections\n"
11785 * "JavaScript Object Notation\n"
11786 *
11787 */
718e3744 11788DEFUN (show_ip_bgp_neighbors,
11789 show_ip_bgp_neighbors_cmd,
b162fa78 11790 "show ip bgp neighbors [json]",
718e3744 11791 SHOW_STR
11792 IP_STR
11793 BGP_STR
856ca177
MS
11794 "Detailed information on TCP and BGP neighbor connections\n"
11795 "JavaScript Object Notation\n")
718e3744 11796{
db7c8528 11797 u_char uj = use_json(argc, argv);
856ca177 11798
9f689658 11799 return bgp_show_neighbor_vty (vty, NULL, show_all, NULL, uj, NULL);
718e3744 11800}
11801
718e3744 11802
718e3744 11803
718e3744 11804
718e3744 11805
718e3744 11806
f412b39a
DW
11807/*
11808 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
b162fa78 11809 * "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) [json]",
f412b39a
DW
11810 * SHOW_STR
11811 * IP_STR
11812 * BGP_STR
11813 * "Address family\n"
11814 * "Address Family modifier\n"
11815 * "Address Family modifier\n"
11816 * "Detailed information on TCP and BGP neighbor connections\n"
11817 * "Neighbor to display information about\n"
11818 * "Neighbor to display information about\n"
11819 * "Neighbor on bgp configured interface\n"
11820 * "JavaScript Object Notation\n"
11821 *
b162fa78 11822 * "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D [json]",
f412b39a
DW
11823 * SHOW_STR
11824 * IP_STR
11825 * BGP_STR
11826 * "Display VPNv4 NLRI specific information\n"
11827 * "Display information about all VPNv4 NLRIs\n"
11828 * "Detailed information on TCP and BGP neighbor connections\n"
11829 * "Neighbor to display information about\n"
11830 * "JavaScript Object Notation\n"
11831 *
b162fa78 11832 * "show ip bgp vpnv4 all neighbors A.B.C.D [json]",
f412b39a
DW
11833 * SHOW_STR
11834 * IP_STR
11835 * BGP_STR
11836 * "Display VPNv4 NLRI specific information\n"
11837 * "Display information about all VPNv4 NLRIs\n"
11838 * "Detailed information on TCP and BGP neighbor connections\n"
11839 * "Neighbor to display information about\n"
11840 * "JavaScript Object Notation\n"
11841 *
b162fa78 11842 * "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) [json]",
f412b39a
DW
11843 * SHOW_STR
11844 * BGP_STR
11845 * "Address family\n"
11846 * "Detailed information on TCP and BGP neighbor connections\n"
11847 * "Neighbor to display information about\n"
11848 * "Neighbor to display information about\n"
11849 * "Neighbor on bgp configured interface\n"
11850 * "JavaScript Object Notation\n"
11851 *
b162fa78 11852 * "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) [json]",
f412b39a
DW
11853 * SHOW_STR
11854 * BGP_STR
11855 * "Detailed information on TCP and BGP neighbor connections\n"
11856 * "Neighbor to display information about\n"
11857 * "Neighbor to display information about\n"
11858 * "Neighbor on bgp configured interface\n"
11859 * "JavaScript Object Notation\n"
11860 *
11861 */
718e3744 11862DEFUN (show_ip_bgp_neighbors_peer,
11863 show_ip_bgp_neighbors_peer_cmd,
6147e2c6 11864 "show ip bgp neighbors <A.B.C.D|X:X::X:X|WORD> [json]",
718e3744 11865 SHOW_STR
11866 IP_STR
11867 BGP_STR
11868 "Detailed information on TCP and BGP neighbor connections\n"
11869 "Neighbor to display information about\n"
a80beece 11870 "Neighbor to display information about\n"
856ca177
MS
11871 "Neighbor on bgp configured interface\n"
11872 "JavaScript Object Notation\n")
718e3744 11873{
db7c8528 11874 u_char uj = use_json(argc, argv);
856ca177 11875
9f689658 11876 return bgp_show_neighbor_vty (vty, NULL, show_peer, argv[argc - 2], uj, NULL);
718e3744 11877}
11878
718e3744 11879
718e3744 11880
718e3744 11881
718e3744 11882
718e3744 11883
f412b39a
DW
11884/*
11885 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9ccf14f7 11886 * "show bgp <view|vrf> WORD neighbors [json]",
f412b39a
DW
11887 * SHOW_STR
11888 * BGP_STR
11889 * BGP_INSTANCE_HELP_STR
11890 * "Detailed information on TCP and BGP neighbor connections\n"
11891 * "JavaScript Object Notation\n"
11892 *
9ccf14f7 11893 * "show bgp <view|vrf> WORD ipv6 neighbors [json]",
f412b39a
DW
11894 * SHOW_STR
11895 * BGP_STR
11896 * BGP_INSTANCE_HELP_STR
11897 * "Address family\n"
11898 * "Detailed information on TCP and BGP neighbor connections\n"
11899 * "JavaScript Object Notation\n"
11900 *
11901 */
718e3744 11902DEFUN (show_ip_bgp_instance_neighbors,
11903 show_ip_bgp_instance_neighbors_cmd,
9ccf14f7 11904 "show ip bgp <view|vrf> WORD neighbors [json]",
718e3744 11905 SHOW_STR
11906 IP_STR
11907 BGP_STR
8386ac43 11908 BGP_INSTANCE_HELP_STR
856ca177
MS
11909 "Detailed information on TCP and BGP neighbor connections\n"
11910 "JavaScript Object Notation\n")
718e3744 11911{
c500ae40 11912 int idx_word = 4;
db7c8528 11913 u_char uj = use_json(argc, argv);
856ca177 11914
c500ae40 11915 return bgp_show_neighbor_vty (vty, argv[idx_word]->arg, show_all, NULL, uj, NULL);
718e3744 11916}
11917
f186de26 11918DEFUN (show_ip_bgp_instance_all_neighbors,
11919 show_ip_bgp_instance_all_neighbors_cmd,
9ccf14f7 11920 "show ip bgp <view|vrf> all neighbors [json]",
f186de26 11921 SHOW_STR
11922 IP_STR
11923 BGP_STR
11924 BGP_INSTANCE_ALL_HELP_STR
11925 "Detailed information on TCP and BGP neighbor connections\n"
11926 "JavaScript Object Notation\n")
11927{
11928 u_char uj = use_json(argc, argv);
11929
11930 bgp_show_all_instances_neighbors_vty (vty, uj);
11931 return CMD_SUCCESS;
11932}
11933
bb46e94f 11934
bb46e94f 11935
f412b39a
DW
11936/*
11937 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9ccf14f7 11938 * "show bgp <view|vrf> WORD ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) [json]",
f412b39a
DW
11939 * SHOW_STR
11940 * BGP_STR
11941 * BGP_INSTANCE_HELP_STR
11942 * "Address family\n"
11943 * "Detailed information on TCP and BGP neighbor connections\n"
11944 * "Neighbor to display information about\n"
11945 * "Neighbor to display information about\n"
11946 * "Neighbor on bgp configured interface\n"
11947 * "JavaScript Object Notation\n"
11948 *
9ccf14f7 11949 * "show bgp <view|vrf> WORD neighbors (A.B.C.D|X:X::X:X|WORD) [json]",
f412b39a
DW
11950 * SHOW_STR
11951 * BGP_STR
11952 * BGP_INSTANCE_HELP_STR
11953 * "Detailed information on TCP and BGP neighbor connections\n"
11954 * "Neighbor to display information about\n"
11955 * "Neighbor to display information about\n"
11956 * "Neighbor on bgp configured interface\n"
11957 * "JavaScript Object Notation\n"
11958 *
11959 */
718e3744 11960DEFUN (show_ip_bgp_instance_neighbors_peer,
11961 show_ip_bgp_instance_neighbors_peer_cmd,
9ccf14f7 11962 "show ip bgp <view|vrf> WORD neighbors <A.B.C.D|X:X::X:X|WORD> [json]",
718e3744 11963 SHOW_STR
11964 IP_STR
11965 BGP_STR
8386ac43 11966 BGP_INSTANCE_HELP_STR
718e3744 11967 "Detailed information on TCP and BGP neighbor connections\n"
11968 "Neighbor to display information about\n"
a80beece 11969 "Neighbor to display information about\n"
856ca177
MS
11970 "Neighbor on bgp configured interface\n"
11971 "JavaScript Object Notation\n")
718e3744 11972{
c500ae40
DW
11973 int idx_word = 4;
11974 int idx_peer = 6;
db7c8528 11975 u_char uj = use_json(argc, argv);
856ca177 11976
c500ae40 11977 return bgp_show_neighbor_vty (vty, argv[idx_word]->arg, show_peer, argv[idx_peer]->arg, uj, NULL);
718e3744 11978}
bb46e94f 11979
bb46e94f 11980
6b0655a2 11981
718e3744 11982/* Show BGP's AS paths internal data. There are both `show ip bgp
11983 paths' and `show ip mbgp paths'. Those functions results are the
11984 same.*/
f412b39a 11985DEFUN (show_ip_bgp_paths,
718e3744 11986 show_ip_bgp_paths_cmd,
11987 "show ip bgp paths",
11988 SHOW_STR
11989 IP_STR
11990 BGP_STR
11991 "Path information\n")
11992{
11993 vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE);
11994 aspath_print_all_vty (vty);
11995 return CMD_SUCCESS;
11996}
11997
f412b39a 11998DEFUN (show_ip_bgp_ipv4_paths,
718e3744 11999 show_ip_bgp_ipv4_paths_cmd,
6147e2c6 12000 "show ip bgp ipv4 <unicast|multicast> paths",
718e3744 12001 SHOW_STR
12002 IP_STR
12003 BGP_STR
12004 "Address family\n"
12005 "Address Family modifier\n"
12006 "Address Family modifier\n"
12007 "Path information\n")
12008{
12009 vty_out (vty, "Address Refcnt Path\r\n");
12010 aspath_print_all_vty (vty);
12011
12012 return CMD_SUCCESS;
12013}
6b0655a2 12014
718e3744 12015#include "hash.h"
12016
94f2b392 12017static void
718e3744 12018community_show_all_iterator (struct hash_backet *backet, struct vty *vty)
12019{
12020 struct community *com;
12021
12022 com = (struct community *) backet->data;
6c4f4e6e 12023 vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, com->refcnt,
718e3744 12024 community_str (com), VTY_NEWLINE);
12025}
12026
12027/* Show BGP's community internal data. */
f412b39a 12028DEFUN (show_ip_bgp_community_info,
718e3744 12029 show_ip_bgp_community_info_cmd,
12030 "show ip bgp community-info",
12031 SHOW_STR
12032 IP_STR
12033 BGP_STR
12034 "List all bgp community information\n")
12035{
12036 vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE);
12037
12038 hash_iterate (community_hash (),
12039 (void (*) (struct hash_backet *, void *))
12040 community_show_all_iterator,
12041 vty);
12042
12043 return CMD_SUCCESS;
12044}
12045
f412b39a 12046DEFUN (show_ip_bgp_attr_info,
718e3744 12047 show_ip_bgp_attr_info_cmd,
12048 "show ip bgp attribute-info",
12049 SHOW_STR
12050 IP_STR
12051 BGP_STR
12052 "List all bgp attribute information\n")
12053{
12054 attr_show_all (vty);
12055 return CMD_SUCCESS;
12056}
6b0655a2 12057
8386ac43 12058static int bgp_show_update_groups(struct vty *vty, const char *name,
12059 int afi, int safi,
f43e655e 12060 uint64_t subgrp_id)
3f9c7369
DS
12061{
12062 struct bgp *bgp;
12063
8386ac43 12064 if (name)
12065 bgp = bgp_lookup_by_name (name);
12066 else
12067 bgp = bgp_get_default ();
12068
3f9c7369 12069 if (bgp)
8fe8a7f6 12070 update_group_show(bgp, afi, safi, vty, subgrp_id);
3f9c7369
DS
12071 return CMD_SUCCESS;
12072}
12073
f186de26 12074static void
12075bgp_show_all_instances_updgrps_vty (struct vty *vty, afi_t afi, safi_t safi)
12076{
12077 struct listnode *node, *nnode;
12078 struct bgp *bgp;
12079
12080 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
12081 {
12082 vty_out (vty, "%sInstance %s:%s",
12083 VTY_NEWLINE,
12084 (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? "Default" : bgp->name,
12085 VTY_NEWLINE);
12086 update_group_show(bgp, afi, safi, vty, 0);
12087 }
12088}
12089
8fe8a7f6
DS
12090DEFUN (show_ip_bgp_updgrps,
12091 show_ip_bgp_updgrps_cmd,
12092 "show ip bgp update-groups",
12093 SHOW_STR
12094 IP_STR
12095 BGP_STR
12096 "Detailed info about dynamic update groups\n")
12097{
8386ac43 12098 return (bgp_show_update_groups(vty, NULL, AFI_IP, SAFI_UNICAST, 0));
12099}
12100
12101DEFUN (show_ip_bgp_instance_updgrps,
12102 show_ip_bgp_instance_updgrps_cmd,
9ccf14f7 12103 "show ip bgp <view|vrf> WORD update-groups",
8386ac43 12104 SHOW_STR
12105 IP_STR
12106 BGP_STR
12107 BGP_INSTANCE_HELP_STR
12108 "Detailed info about dynamic update groups\n")
12109{
c500ae40
DW
12110 int idx_word = 4;
12111 return (bgp_show_update_groups(vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0));
8fe8a7f6
DS
12112}
12113
f186de26 12114DEFUN (show_ip_bgp_instance_all_updgrps,
12115 show_ip_bgp_instance_all_updgrps_cmd,
9ccf14f7 12116 "show ip bgp <view|vrf> all update-groups",
f186de26 12117 SHOW_STR
12118 IP_STR
12119 BGP_STR
12120 BGP_INSTANCE_ALL_HELP_STR
12121 "Detailed info about dynamic update groups\n")
12122{
12123 bgp_show_all_instances_updgrps_vty (vty, AFI_IP, SAFI_UNICAST);
12124 return CMD_SUCCESS;
12125}
12126
3f9c7369
DS
12127DEFUN (show_bgp_ipv6_updgrps,
12128 show_bgp_ipv6_updgrps_cmd,
8fe8a7f6 12129 "show bgp update-groups",
3f9c7369
DS
12130 SHOW_STR
12131 BGP_STR
8fe8a7f6 12132 "Detailed info about v6 dynamic update groups\n")
3f9c7369 12133{
8386ac43 12134 return (bgp_show_update_groups(vty, NULL, AFI_IP6, SAFI_UNICAST, 0));
12135}
12136
12137DEFUN (show_bgp_instance_ipv6_updgrps,
12138 show_bgp_instance_ipv6_updgrps_cmd,
9ccf14f7 12139 "show bgp <view|vrf> WORD update-groups",
8386ac43 12140 SHOW_STR
12141 BGP_STR
12142 BGP_INSTANCE_HELP_STR
12143 "Detailed info about v6 dynamic update groups\n")
12144{
c500ae40
DW
12145 int idx_word = 3;
12146 return (bgp_show_update_groups(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, 0));
3f9c7369
DS
12147}
12148
f186de26 12149DEFUN (show_bgp_instance_all_ipv6_updgrps,
12150 show_bgp_instance_all_ipv6_updgrps_cmd,
9ccf14f7 12151 "show bgp <view|vrf> all update-groups",
f186de26 12152 SHOW_STR
12153 BGP_STR
12154 BGP_INSTANCE_ALL_HELP_STR
12155 "Detailed info about v6 dynamic update groups\n")
12156{
12157 bgp_show_all_instances_updgrps_vty (vty, AFI_IP6, SAFI_UNICAST);
12158 return CMD_SUCCESS;
12159}
12160
3f9c7369
DS
12161DEFUN (show_bgp_updgrps,
12162 show_bgp_updgrps_cmd,
6147e2c6 12163 "show bgp <ipv4|ipv6> <unicast|multicast> update-groups",
3f9c7369
DS
12164 SHOW_STR
12165 BGP_STR
12166 "Address family\n"
12167 "Address family\n"
12168 "Address Family modifier\n"
12169 "Address Family modifier\n"
8fe8a7f6 12170 "Detailed info about dynamic update groups\n")
3f9c7369 12171{
c500ae40
DW
12172 int idx_afi = 2;
12173 int idx_safi = 3;
3f9c7369
DS
12174 afi_t afi;
12175 safi_t safi;
12176
c500ae40
DW
12177 afi = (strcmp(argv[idx_afi]->arg, "ipv4") == 0) ? AFI_IP : AFI_IP6;
12178 safi = (strncmp (argv[idx_safi]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
8386ac43 12179 return (bgp_show_update_groups(vty, NULL, afi, safi, 0));
8fe8a7f6
DS
12180}
12181
12182DEFUN (show_ip_bgp_updgrps_s,
12183 show_ip_bgp_updgrps_s_cmd,
12184 "show ip bgp update-groups SUBGROUP-ID",
12185 SHOW_STR
12186 IP_STR
12187 BGP_STR
12188 "Detailed info about dynamic update groups\n"
12189 "Specific subgroup to display detailed info for\n")
12190{
f43e655e 12191 uint64_t subgrp_id;
8fe8a7f6
DS
12192
12193 VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]);
8386ac43 12194 return (bgp_show_update_groups(vty, NULL, AFI_IP, SAFI_UNICAST, subgrp_id));
12195}
12196
12197DEFUN (show_ip_bgp_instance_updgrps_s,
12198 show_ip_bgp_instance_updgrps_s_cmd,
9ccf14f7 12199 "show ip bgp <view|vrf> WORD update-groups SUBGROUP-ID",
8386ac43 12200 SHOW_STR
12201 IP_STR
12202 BGP_STR
12203 BGP_INSTANCE_HELP_STR
12204 "Detailed info about dynamic update groups\n"
12205 "Specific subgroup to display detailed info for\n")
12206{
c500ae40 12207 int idx_word = 4;
f43e655e 12208 uint64_t subgrp_id;
8386ac43 12209
12210 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
c500ae40 12211 return (bgp_show_update_groups(vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, subgrp_id));
8fe8a7f6
DS
12212}
12213
12214DEFUN (show_bgp_ipv6_updgrps_s,
12215 show_bgp_ipv6_updgrps_s_cmd,
12216 "show bgp update-groups SUBGROUP-ID",
12217 SHOW_STR
12218 BGP_STR
12219 "Detailed info about v6 dynamic update groups\n"
12220 "Specific subgroup to display detailed info for\n")
12221{
f43e655e 12222 uint64_t subgrp_id;
8fe8a7f6
DS
12223
12224 VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]);
8386ac43 12225 return(bgp_show_update_groups(vty, NULL, AFI_IP6, SAFI_UNICAST, subgrp_id));
12226}
12227
12228DEFUN (show_bgp_instance_ipv6_updgrps_s,
12229 show_bgp_instance_ipv6_updgrps_s_cmd,
9ccf14f7 12230 "show bgp <view|vrf> WORD update-groups SUBGROUP-ID",
8386ac43 12231 SHOW_STR
12232 BGP_STR
12233 "Detailed info about v6 dynamic update groups\n"
12234 "Specific subgroup to display detailed info for\n")
12235{
c500ae40 12236 int idx_word = 3;
f43e655e 12237 uint64_t subgrp_id;
8386ac43 12238
12239 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
c500ae40 12240 return(bgp_show_update_groups(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, subgrp_id));
8fe8a7f6
DS
12241}
12242
12243DEFUN (show_bgp_updgrps_s,
12244 show_bgp_updgrps_s_cmd,
6147e2c6 12245 "show bgp <ipv4|ipv6> <unicast|multicast> update-groups SUBGROUP-ID",
8fe8a7f6
DS
12246 SHOW_STR
12247 BGP_STR
12248 "Address family\n"
12249 "Address family\n"
12250 "Address Family modifier\n"
12251 "Address Family modifier\n"
12252 "Detailed info about v6 dynamic update groups\n"
12253 "Specific subgroup to display detailed info for")
12254{
c500ae40
DW
12255 int idx_afi = 2;
12256 int idx_safi = 3;
8fe8a7f6
DS
12257 afi_t afi;
12258 safi_t safi;
f43e655e 12259 uint64_t subgrp_id;
8fe8a7f6 12260
c500ae40
DW
12261 afi = (strcmp(argv[idx_afi]->arg, "ipv4") == 0) ? AFI_IP : AFI_IP6;
12262 safi = (strncmp (argv[idx_safi]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
8fe8a7f6
DS
12263
12264 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
8386ac43 12265 return(bgp_show_update_groups(vty, NULL, afi, safi, subgrp_id));
3f9c7369
DS
12266}
12267
12268DEFUN (show_bgp_updgrps_stats,
12269 show_bgp_updgrps_stats_cmd,
12270 "show bgp update-groups statistics",
12271 SHOW_STR
12272 BGP_STR
12273 "BGP update groups\n"
12274 "Statistics\n")
12275{
12276 struct bgp *bgp;
12277
12278 bgp = bgp_get_default();
12279 if (bgp)
12280 update_group_show_stats(bgp, vty);
12281
12282 return CMD_SUCCESS;
12283}
12284
8386ac43 12285DEFUN (show_bgp_instance_updgrps_stats,
12286 show_bgp_instance_updgrps_stats_cmd,
9ccf14f7 12287 "show bgp <view|vrf> WORD update-groups statistics",
8386ac43 12288 SHOW_STR
12289 BGP_STR
12290 BGP_INSTANCE_HELP_STR
12291 "BGP update groups\n"
12292 "Statistics\n")
12293{
c500ae40 12294 int idx_word = 3;
8386ac43 12295 struct bgp *bgp;
12296
c500ae40 12297 bgp = bgp_lookup_by_name (argv[idx_word]->arg);
8386ac43 12298 if (bgp)
12299 update_group_show_stats(bgp, vty);
12300
12301 return CMD_SUCCESS;
12302}
12303
3f9c7369 12304static void
8386ac43 12305show_bgp_updgrps_adj_info_aux (struct vty *vty, const char *name,
12306 afi_t afi, safi_t safi,
f43e655e 12307 const char *what, uint64_t subgrp_id)
3f9c7369
DS
12308{
12309 struct bgp *bgp;
8386ac43 12310
12311 if (name)
12312 bgp = bgp_lookup_by_name (name);
12313 else
12314 bgp = bgp_get_default ();
12315
3f9c7369
DS
12316 if (bgp)
12317 {
12318 if (!strcmp(what, "advertise-queue"))
12319 update_group_show_adj_queue(bgp, afi, safi, vty, subgrp_id);
12320 else if (!strcmp(what, "advertised-routes"))
12321 update_group_show_advertised(bgp, afi, safi, vty, subgrp_id);
12322 else if (!strcmp(what, "packet-queue"))
12323 update_group_show_packet_queue(bgp, afi, safi, vty, subgrp_id);
12324 }
12325}
12326
12327DEFUN (show_ip_bgp_updgrps_adj,
12328 show_ip_bgp_updgrps_adj_cmd,
6147e2c6 12329 "show ip bgp update-groups <advertise-queue|advertised-routes|packet-queue>",
3f9c7369
DS
12330 SHOW_STR
12331 IP_STR
12332 BGP_STR
12333 "BGP update groups\n"
12334 "Advertisement queue\n"
12335 "Announced routes\n"
12336 "Packet queue\n")
8fe8a7f6 12337
3f9c7369 12338{
c500ae40
DW
12339 int idx_type = 4;
12340 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0);
8386ac43 12341 return CMD_SUCCESS;
12342}
12343
12344DEFUN (show_ip_bgp_instance_updgrps_adj,
12345 show_ip_bgp_instance_updgrps_adj_cmd,
9ccf14f7 12346 "show ip bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>",
8386ac43 12347 SHOW_STR
12348 IP_STR
12349 BGP_STR
12350 BGP_INSTANCE_HELP_STR
12351 "BGP update groups\n"
12352 "Advertisement queue\n"
12353 "Announced routes\n"
12354 "Packet queue\n")
12355
12356{
c500ae40
DW
12357 int idx_word = 4;
12358 int idx_type = 6;
12359 show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0);
3f9c7369
DS
12360 return CMD_SUCCESS;
12361}
12362
12363DEFUN (show_bgp_updgrps_afi_adj,
12364 show_bgp_updgrps_afi_adj_cmd,
6147e2c6 12365 "show bgp <ipv4|ipv6> <unicast|multicast> update-groups <advertise-queue|advertised-routes|packet-queue>",
3f9c7369
DS
12366 SHOW_STR
12367 BGP_STR
12368 "Address family\n"
12369 "Address family\n"
12370 "Address Family modifier\n"
12371 "Address Family modifier\n"
12372 "BGP update groups\n"
12373 "Advertisement queue\n"
12374 "Announced routes\n"
8fe8a7f6
DS
12375 "Packet queue\n"
12376 "Specific subgroup info wanted for\n")
3f9c7369 12377{
c500ae40
DW
12378 int idx_afi = 2;
12379 int idx_safi = 3;
12380 int idx_type = 5;
3f9c7369
DS
12381 afi_t afi;
12382 safi_t safi;
12383
c500ae40
DW
12384 afi = (strcmp(argv[idx_afi]->arg, "ipv4") == 0) ? AFI_IP : AFI_IP6;
12385 safi = (strncmp (argv[idx_safi]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
12386 show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[idx_type]->arg, 0);
8fe8a7f6 12387 return CMD_SUCCESS;
3f9c7369
DS
12388}
12389
12390DEFUN (show_bgp_updgrps_adj,
12391 show_bgp_updgrps_adj_cmd,
6147e2c6 12392 "show bgp update-groups <advertise-queue|advertised-routes|packet-queue>",
3f9c7369
DS
12393 SHOW_STR
12394 BGP_STR
12395 "BGP update groups\n"
12396 "Advertisement queue\n"
12397 "Announced routes\n"
12398 "Packet queue\n")
12399{
c500ae40
DW
12400 int idx_type = 3;
12401 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0);
8386ac43 12402 return CMD_SUCCESS;
12403}
12404
12405DEFUN (show_bgp_instance_updgrps_adj,
12406 show_bgp_instance_updgrps_adj_cmd,
9ccf14f7 12407 "show bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>",
8386ac43 12408 SHOW_STR
12409 BGP_STR
12410 BGP_INSTANCE_HELP_STR
12411 "BGP update groups\n"
12412 "Advertisement queue\n"
12413 "Announced routes\n"
12414 "Packet queue\n")
12415{
c500ae40
DW
12416 int idx_word = 3;
12417 int idx_type = 5;
12418 show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0);
3f9c7369
DS
12419 return CMD_SUCCESS;
12420}
12421
12422DEFUN (show_ip_bgp_updgrps_adj_s,
8fe8a7f6 12423 show_ip_bgp_updgrps_adj_s_cmd,
6147e2c6 12424 "show ip bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
3f9c7369
DS
12425 SHOW_STR
12426 IP_STR
12427 BGP_STR
12428 "BGP update groups\n"
8fe8a7f6 12429 "Specific subgroup to display info for\n"
3f9c7369
DS
12430 "Advertisement queue\n"
12431 "Announced routes\n"
12432 "Packet queue\n")
3f9c7369 12433
3f9c7369 12434{
c500ae40 12435 int idx_type = 5;
f43e655e 12436 uint64_t subgrp_id;
8fe8a7f6 12437
c500ae40 12438 VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_type]->arg);
8fe8a7f6 12439
8386ac43 12440 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[1], subgrp_id);
12441 return CMD_SUCCESS;
12442}
12443
12444DEFUN (show_ip_bgp_instance_updgrps_adj_s,
12445 show_ip_bgp_instance_updgrps_adj_s_cmd,
9ccf14f7 12446 "show ip bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
8386ac43 12447 SHOW_STR
12448 IP_STR
12449 BGP_STR
12450 BGP_INSTANCE_HELP_STR
12451 "BGP update groups\n"
12452 "Specific subgroup to display info for\n"
12453 "Advertisement queue\n"
12454 "Announced routes\n"
12455 "Packet queue\n")
12456
12457{
c500ae40
DW
12458 int idx_word = 4;
12459 int idx_type = 7;
f43e655e 12460 uint64_t subgrp_id;
8386ac43 12461
c500ae40 12462 VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_type]->arg);
8386ac43 12463
c500ae40 12464 show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, argv[3], subgrp_id);
3f9c7369
DS
12465 return CMD_SUCCESS;
12466}
12467
8fe8a7f6
DS
12468DEFUN (show_bgp_updgrps_afi_adj_s,
12469 show_bgp_updgrps_afi_adj_s_cmd,
6147e2c6 12470 "show bgp <ipv4|ipv6> <unicast|multicast> update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
3f9c7369
DS
12471 SHOW_STR
12472 BGP_STR
12473 "Address family\n"
12474 "Address family\n"
12475 "Address Family modifier\n"
12476 "Address Family modifier\n"
12477 "BGP update groups\n"
8fe8a7f6 12478 "Specific subgroup to display info for\n"
3f9c7369
DS
12479 "Advertisement queue\n"
12480 "Announced routes\n"
8fe8a7f6
DS
12481 "Packet queue\n"
12482 "Specific subgroup info wanted for\n")
3f9c7369 12483{
c500ae40
DW
12484 int idx_afi = 2;
12485 int idx_safi = 3;
12486 int idx_type = 6;
3f9c7369
DS
12487 afi_t afi;
12488 safi_t safi;
f43e655e 12489 uint64_t subgrp_id;
3f9c7369 12490
c500ae40
DW
12491 afi = (strcmp(argv[idx_afi]->arg, "ipv4") == 0) ? AFI_IP : AFI_IP6;
12492 safi = (strncmp (argv[idx_safi]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
12493 VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_type]->arg);
8fe8a7f6 12494
8386ac43 12495 show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[3], subgrp_id);
8fe8a7f6 12496 return CMD_SUCCESS;
3f9c7369
DS
12497}
12498
8fe8a7f6
DS
12499DEFUN (show_bgp_updgrps_adj_s,
12500 show_bgp_updgrps_adj_s_cmd,
6147e2c6 12501 "show bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
8fe8a7f6
DS
12502 SHOW_STR
12503 BGP_STR
12504 "BGP update groups\n"
12505 "Specific subgroup to display info for\n"
12506 "Advertisement queue\n"
12507 "Announced routes\n"
12508 "Packet queue\n")
12509{
c500ae40 12510 int idx_type = 4;
f43e655e 12511 uint64_t subgrp_id;
8fe8a7f6 12512
c500ae40 12513 VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_type]->arg);
8fe8a7f6 12514
8386ac43 12515 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[1], subgrp_id);
8fe8a7f6
DS
12516 return CMD_SUCCESS;
12517}
12518
8386ac43 12519DEFUN (show_bgp_instance_updgrps_adj_s,
12520 show_bgp_instance_updgrps_adj_s_cmd,
9ccf14f7 12521 "show bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
8386ac43 12522 SHOW_STR
12523 BGP_STR
12524 BGP_INSTANCE_HELP_STR
12525 "BGP update groups\n"
12526 "Specific subgroup to display info for\n"
12527 "Advertisement queue\n"
12528 "Announced routes\n"
12529 "Packet queue\n")
12530{
c500ae40
DW
12531 int idx_word = 3;
12532 int idx_type = 6;
f43e655e 12533 uint64_t subgrp_id;
8386ac43 12534
c500ae40 12535 VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_type]->arg);
8386ac43 12536
c500ae40 12537 show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, argv[3], subgrp_id);
8386ac43 12538 return CMD_SUCCESS;
12539}
12540
12541
8fe8a7f6 12542
f14e6fdb
DS
12543static int
12544bgp_show_one_peer_group (struct vty *vty, struct peer_group *group)
12545{
12546 struct listnode *node, *nnode;
12547 struct prefix *range;
12548 struct peer *conf;
12549 struct peer *peer;
4690c7d7 12550 char buf[PREFIX2STR_BUFFER];
f14e6fdb
DS
12551 afi_t afi;
12552 safi_t safi;
ffd0c037
DS
12553 const char *peer_status;
12554 const char *af_str;
f14e6fdb
DS
12555 int lr_count;
12556 int dynamic;
12557 int af_cfgd;
12558
12559 conf = group->conf;
12560
0299c004
DS
12561 if (conf->as_type == AS_SPECIFIED ||
12562 conf->as_type == AS_EXTERNAL) {
66b199b2 12563 vty_out (vty, "%sBGP peer-group %s, remote AS %d%s",
f14e6fdb 12564 VTY_NEWLINE, group->name, conf->as, VTY_NEWLINE);
0299c004 12565 } else if (conf->as_type == AS_INTERNAL) {
66b199b2 12566 vty_out (vty, "%sBGP peer-group %s, remote AS %d%s",
0299c004 12567 VTY_NEWLINE, group->name, group->bgp->as, VTY_NEWLINE);
66b199b2
DS
12568 } else {
12569 vty_out (vty, "%sBGP peer-group %s%s",
12570 VTY_NEWLINE, group->name, VTY_NEWLINE);
0299c004 12571 }
f14e6fdb 12572
0299c004 12573 if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL))
f14e6fdb
DS
12574 vty_out (vty, " Peer-group type is internal%s", VTY_NEWLINE);
12575 else
12576 vty_out (vty, " Peer-group type is external%s", VTY_NEWLINE);
12577
12578 /* Display AFs configured. */
12579 vty_out (vty, " Configured address-families:");
12580 for (afi = AFI_IP; afi < AFI_MAX; afi++)
12581 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
12582 {
12583 if (conf->afc[afi][safi])
12584 {
12585 af_cfgd = 1;
12586 vty_out (vty, " %s;", afi_safi_print(afi, safi));
12587 }
12588 }
12589 if (!af_cfgd)
12590 vty_out (vty, " none%s", VTY_NEWLINE);
12591 else
12592 vty_out (vty, "%s", VTY_NEWLINE);
12593
12594 /* Display listen ranges (for dynamic neighbors), if any */
12595 for (afi = AFI_IP; afi < AFI_MAX; afi++)
12596 {
12597 if (afi == AFI_IP)
12598 af_str = "IPv4";
12599 else if (afi == AFI_IP6)
12600 af_str = "IPv6";
12601 lr_count = listcount(group->listen_range[afi]);
12602 if (lr_count)
12603 {
12604 vty_out(vty,
12605 " %d %s listen range(s)%s",
12606 lr_count, af_str, VTY_NEWLINE);
12607
12608
12609 for (ALL_LIST_ELEMENTS (group->listen_range[afi], node,
12610 nnode, range))
12611 {
12612 prefix2str(range, buf, sizeof(buf));
12613 vty_out(vty, " %s%s", buf, VTY_NEWLINE);
12614 }
12615 }
12616 }
12617
12618 /* Display group members and their status */
12619 if (listcount(group->peer))
12620 {
12621 vty_out (vty, " Peer-group members:%s", VTY_NEWLINE);
12622 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
12623 {
12624 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
12625 peer_status = "Idle (Admin)";
12626 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
12627 peer_status = "Idle (PfxCt)";
12628 else
12629 peer_status = LOOKUP(bgp_status_msg, peer->status);
12630
12631 dynamic = peer_dynamic_neighbor(peer);
12632 vty_out (vty, " %s %s %s %s",
12633 peer->host, dynamic ? "(dynamic)" : "",
12634 peer_status, VTY_NEWLINE);
12635 }
12636 }
12637
12638 return CMD_SUCCESS;
12639}
12640
12641/* Show BGP peer group's information. */
12642enum show_group_type
12643{
12644 show_all_groups,
12645 show_peer_group
12646};
12647
12648static int
12649bgp_show_peer_group (struct vty *vty, struct bgp *bgp,
12650 enum show_group_type type, const char *group_name)
12651{
12652 struct listnode *node, *nnode;
12653 struct peer_group *group;
12654 int find = 0;
12655
12656 for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
12657 {
12658 switch (type)
12659 {
12660 case show_all_groups:
12661 bgp_show_one_peer_group (vty, group);
12662 break;
12663 case show_peer_group:
12664 if (group_name && (strcmp(group->name, group_name) == 0))
12665 {
12666 find = 1;
12667 bgp_show_one_peer_group (vty, group);
12668 }
12669 break;
12670 }
12671 }
12672
12673 if (type == show_peer_group && ! find)
6d9e66dc 12674 vty_out (vty, "%% No such peer-group%s", VTY_NEWLINE);
f14e6fdb
DS
12675
12676 return CMD_SUCCESS;
12677}
12678
12679static int
12680bgp_show_peer_group_vty (struct vty *vty, const char *name,
12681 enum show_group_type type, const char *group_name)
12682{
12683 struct bgp *bgp;
12684 int ret = CMD_SUCCESS;
12685
12686 if (name)
8386ac43 12687 bgp = bgp_lookup_by_name (name);
12688 else
12689 bgp = bgp_get_default ();
f14e6fdb 12690
8386ac43 12691 if (! bgp)
12692 {
12693 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
12694 return CMD_WARNING;
f14e6fdb
DS
12695 }
12696
8386ac43 12697 ret = bgp_show_peer_group (vty, bgp, type, group_name);
f14e6fdb
DS
12698
12699 return ret;
12700}
12701
12702DEFUN (show_ip_bgp_peer_groups,
12703 show_ip_bgp_peer_groups_cmd,
12704 "show ip bgp peer-group",
12705 SHOW_STR
12706 IP_STR
12707 BGP_STR
12708 "Detailed information on all BGP peer groups\n")
12709{
12710 return bgp_show_peer_group_vty (vty, NULL, show_all_groups, NULL);
12711}
12712
12713DEFUN (show_ip_bgp_instance_peer_groups,
12714 show_ip_bgp_instance_peer_groups_cmd,
9ccf14f7 12715 "show ip bgp <view|vrf> WORD peer-group",
f14e6fdb
DS
12716 SHOW_STR
12717 IP_STR
12718 BGP_STR
8386ac43 12719 BGP_INSTANCE_HELP_STR
f14e6fdb
DS
12720 "Detailed information on all BGP peer groups\n")
12721{
c500ae40
DW
12722 int idx_word = 4;
12723 return bgp_show_peer_group_vty (vty, argv[idx_word]->arg, show_all_groups, NULL);
f14e6fdb
DS
12724}
12725
12726DEFUN (show_ip_bgp_peer_group,
12727 show_ip_bgp_peer_group_cmd,
12728 "show ip bgp peer-group WORD",
12729 SHOW_STR
12730 IP_STR
12731 BGP_STR
12732 "BGP peer-group name\n"
12733 "Detailed information on a BGP peer group\n")
12734{
c500ae40
DW
12735 int idx_word = 4;
12736 return bgp_show_peer_group_vty (vty, NULL, show_peer_group, argv[idx_word]->arg);
f14e6fdb
DS
12737}
12738
12739DEFUN (show_ip_bgp_instance_peer_group,
12740 show_ip_bgp_instance_peer_group_cmd,
9ccf14f7 12741 "show ip bgp <view|vrf> WORD peer-group WORD",
f14e6fdb
DS
12742 SHOW_STR
12743 IP_STR
12744 BGP_STR
8386ac43 12745 BGP_INSTANCE_HELP_STR
f14e6fdb
DS
12746 "BGP peer-group name\n"
12747 "Detailed information on a BGP peer group\n")
12748{
c500ae40
DW
12749 int idx_word = 4;
12750 int idx_word_2 = 6;
12751 return bgp_show_peer_group_vty (vty, argv[idx_word]->arg, show_peer_group, argv[idx_word_2]->arg);
f14e6fdb 12752}
3f9c7369 12753
718e3744 12754/* Redistribute VTY commands. */
12755
718e3744 12756DEFUN (bgp_redistribute_ipv4,
12757 bgp_redistribute_ipv4_cmd,
9ccf14f7 12758 "redistribute <kernel|connected|static|rip|ospf|isis|pim|table>",
718e3744 12759 "Redistribute information from another routing protocol\n"
e0ca5fde 12760 QUAGGA_IP_REDIST_HELP_STR_BGPD)
718e3744 12761{
c500ae40 12762 int idx_protocol = 1;
718e3744 12763 int type;
12764
c500ae40 12765 type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg);
e0ca5fde 12766 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 12767 {
12768 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
12769 return CMD_WARNING;
12770 }
7c8ff89e 12771 bgp_redist_add(vty->index, AFI_IP, type, 0);
6aeb9e78 12772 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
718e3744 12773}
12774
12775DEFUN (bgp_redistribute_ipv4_rmap,
12776 bgp_redistribute_ipv4_rmap_cmd,
9ccf14f7 12777 "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> route-map WORD",
718e3744 12778 "Redistribute information from another routing protocol\n"
e0ca5fde 12779 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 12780 "Route map reference\n"
12781 "Pointer to route-map entries\n")
12782{
c500ae40
DW
12783 int idx_protocol = 1;
12784 int idx_word = 3;
718e3744 12785 int type;
7c8ff89e 12786 struct bgp_redist *red;
718e3744 12787
c500ae40 12788 type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg);
e0ca5fde 12789 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 12790 {
12791 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
12792 return CMD_WARNING;
12793 }
12794
7c8ff89e 12795 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
c500ae40 12796 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
6aeb9e78 12797 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
718e3744 12798}
12799
12800DEFUN (bgp_redistribute_ipv4_metric,
12801 bgp_redistribute_ipv4_metric_cmd,
9ccf14f7 12802 "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> metric (0-4294967295)",
718e3744 12803 "Redistribute information from another routing protocol\n"
e0ca5fde 12804 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 12805 "Metric for redistributed routes\n"
12806 "Default metric\n")
12807{
c500ae40
DW
12808 int idx_protocol = 1;
12809 int idx_number = 3;
718e3744 12810 int type;
12811 u_int32_t metric;
7c8ff89e 12812 struct bgp_redist *red;
718e3744 12813
c500ae40 12814 type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg);
e0ca5fde 12815 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 12816 {
12817 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
12818 return CMD_WARNING;
12819 }
c500ae40 12820 VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg);
718e3744 12821
7c8ff89e 12822 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
caf958b4 12823 bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
6aeb9e78 12824 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
718e3744 12825}
12826
12827DEFUN (bgp_redistribute_ipv4_rmap_metric,
12828 bgp_redistribute_ipv4_rmap_metric_cmd,
9ccf14f7 12829 "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> route-map WORD metric (0-4294967295)",
718e3744 12830 "Redistribute information from another routing protocol\n"
e0ca5fde 12831 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 12832 "Route map reference\n"
12833 "Pointer to route-map entries\n"
12834 "Metric for redistributed routes\n"
12835 "Default metric\n")
12836{
c500ae40
DW
12837 int idx_protocol = 1;
12838 int idx_word = 3;
12839 int idx_number = 5;
718e3744 12840 int type;
12841 u_int32_t metric;
7c8ff89e 12842 struct bgp_redist *red;
718e3744 12843
c500ae40 12844 type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg);
e0ca5fde 12845 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 12846 {
12847 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
12848 return CMD_WARNING;
12849 }
c500ae40 12850 VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg);
718e3744 12851
7c8ff89e 12852 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
c500ae40 12853 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
caf958b4 12854 bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
6aeb9e78 12855 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
718e3744 12856}
12857
12858DEFUN (bgp_redistribute_ipv4_metric_rmap,
12859 bgp_redistribute_ipv4_metric_rmap_cmd,
9ccf14f7 12860 "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> metric (0-4294967295) route-map WORD",
718e3744 12861 "Redistribute information from another routing protocol\n"
e0ca5fde 12862 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 12863 "Metric for redistributed routes\n"
12864 "Default metric\n"
12865 "Route map reference\n"
12866 "Pointer to route-map entries\n")
12867{
c500ae40
DW
12868 int idx_protocol = 1;
12869 int idx_number = 3;
12870 int idx_word = 5;
718e3744 12871 int type;
12872 u_int32_t metric;
7c8ff89e 12873 struct bgp_redist *red;
718e3744 12874
c500ae40 12875 type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg);
e0ca5fde 12876 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 12877 {
12878 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
12879 return CMD_WARNING;
12880 }
c500ae40 12881 VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg);
718e3744 12882
7c8ff89e 12883 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
caf958b4 12884 bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
c500ae40 12885 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
6aeb9e78 12886 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
718e3744 12887}
12888
7c8ff89e
DS
12889DEFUN (bgp_redistribute_ipv4_ospf,
12890 bgp_redistribute_ipv4_ospf_cmd,
6147e2c6 12891 "redistribute <ospf|table> (1-65535)",
7c8ff89e
DS
12892 "Redistribute information from another routing protocol\n"
12893 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
12894 "Non-main Kernel Routing Table\n"
12895 "Instance ID/Table ID\n")
7c8ff89e 12896{
c500ae40
DW
12897 int idx_ospf_table = 1;
12898 int idx_number = 2;
7c8ff89e 12899 u_short instance;
7a4bb9c5 12900 u_short protocol;
7c8ff89e 12901
c500ae40 12902 VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg);
7a4bb9c5 12903
c500ae40 12904 if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
7a4bb9c5
DS
12905 protocol = ZEBRA_ROUTE_OSPF;
12906 else
12907 protocol = ZEBRA_ROUTE_TABLE;
12908
12909 bgp_redist_add(vty->index, AFI_IP, protocol, instance);
6aeb9e78 12910 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
7c8ff89e
DS
12911}
12912
12913DEFUN (bgp_redistribute_ipv4_ospf_rmap,
12914 bgp_redistribute_ipv4_ospf_rmap_cmd,
6147e2c6 12915 "redistribute <ospf|table> (1-65535) route-map WORD",
7c8ff89e
DS
12916 "Redistribute information from another routing protocol\n"
12917 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
12918 "Non-main Kernel Routing Table\n"
12919 "Instance ID/Table ID\n"
7c8ff89e
DS
12920 "Route map reference\n"
12921 "Pointer to route-map entries\n")
12922{
c500ae40
DW
12923 int idx_ospf_table = 1;
12924 int idx_number = 2;
12925 int idx_word = 4;
7c8ff89e
DS
12926 struct bgp_redist *red;
12927 u_short instance;
7a4bb9c5 12928 int protocol;
7c8ff89e 12929
c500ae40 12930 if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
7a4bb9c5
DS
12931 protocol = ZEBRA_ROUTE_OSPF;
12932 else
12933 protocol = ZEBRA_ROUTE_TABLE;
12934
c500ae40 12935 VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg);
7a4bb9c5 12936 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
c500ae40 12937 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
6aeb9e78 12938 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
7c8ff89e
DS
12939}
12940
12941DEFUN (bgp_redistribute_ipv4_ospf_metric,
12942 bgp_redistribute_ipv4_ospf_metric_cmd,
6147e2c6 12943 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
7c8ff89e
DS
12944 "Redistribute information from another routing protocol\n"
12945 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
12946 "Non-main Kernel Routing Table\n"
12947 "Instance ID/Table ID\n"
7c8ff89e
DS
12948 "Metric for redistributed routes\n"
12949 "Default metric\n")
12950{
c500ae40
DW
12951 int idx_ospf_table = 1;
12952 int idx_number = 2;
12953 int idx_number_2 = 4;
7c8ff89e
DS
12954 u_int32_t metric;
12955 struct bgp_redist *red;
12956 u_short instance;
7a4bb9c5 12957 int protocol;
7c8ff89e 12958
c500ae40 12959 if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
7a4bb9c5
DS
12960 protocol = ZEBRA_ROUTE_OSPF;
12961 else
12962 protocol = ZEBRA_ROUTE_TABLE;
7c8ff89e 12963
c500ae40
DW
12964 VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg);
12965 VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg);
7a4bb9c5
DS
12966
12967 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
caf958b4 12968 bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
6aeb9e78 12969 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
7c8ff89e
DS
12970}
12971
12972DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric,
12973 bgp_redistribute_ipv4_ospf_rmap_metric_cmd,
6147e2c6 12974 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
7c8ff89e
DS
12975 "Redistribute information from another routing protocol\n"
12976 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
12977 "Non-main Kernel Routing Table\n"
12978 "Instance ID/Table ID\n"
7c8ff89e
DS
12979 "Route map reference\n"
12980 "Pointer to route-map entries\n"
12981 "Metric for redistributed routes\n"
12982 "Default metric\n")
12983{
c500ae40
DW
12984 int idx_ospf_table = 1;
12985 int idx_number = 2;
12986 int idx_word = 4;
12987 int idx_number_2 = 6;
7c8ff89e
DS
12988 u_int32_t metric;
12989 struct bgp_redist *red;
12990 u_short instance;
7a4bb9c5 12991 int protocol;
7c8ff89e 12992
c500ae40 12993 if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
7a4bb9c5
DS
12994 protocol = ZEBRA_ROUTE_OSPF;
12995 else
12996 protocol = ZEBRA_ROUTE_TABLE;
7c8ff89e 12997
c500ae40
DW
12998 VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg);
12999 VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg);
7a4bb9c5
DS
13000
13001 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
c500ae40 13002 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
caf958b4 13003 bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
6aeb9e78 13004 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
7c8ff89e
DS
13005}
13006
13007DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap,
13008 bgp_redistribute_ipv4_ospf_metric_rmap_cmd,
6147e2c6 13009 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
7c8ff89e
DS
13010 "Redistribute information from another routing protocol\n"
13011 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
13012 "Non-main Kernel Routing Table\n"
13013 "Instance ID/Table ID\n"
7c8ff89e
DS
13014 "Metric for redistributed routes\n"
13015 "Default metric\n"
13016 "Route map reference\n"
13017 "Pointer to route-map entries\n")
13018{
c500ae40
DW
13019 int idx_ospf_table = 1;
13020 int idx_number = 2;
13021 int idx_number_2 = 4;
13022 int idx_word = 6;
7c8ff89e
DS
13023 u_int32_t metric;
13024 struct bgp_redist *red;
13025 u_short instance;
7a4bb9c5 13026 int protocol;
7c8ff89e 13027
c500ae40 13028 if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
7a4bb9c5
DS
13029 protocol = ZEBRA_ROUTE_OSPF;
13030 else
13031 protocol = ZEBRA_ROUTE_TABLE;
7c8ff89e 13032
c500ae40
DW
13033 VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg);
13034 VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg);
7a4bb9c5
DS
13035
13036 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
caf958b4 13037 bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
c500ae40 13038 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
6aeb9e78 13039 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
7c8ff89e
DS
13040}
13041
f412b39a
DW
13042/*
13043 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
13044 * "no redistribute (ospf|table) <1-65535> route-map WORD",
13045 * NO_STR
13046 * "Redistribute information from another routing protocol\n"
13047 * "Open Shortest Path First (OSPFv2)\n"
13048 * "Non-main Kernel Routing Table\n"
13049 * "Instance ID/Table ID\n"
13050 * "Route map reference\n"
13051 * "Pointer to route-map entries\n"
13052 *
13053 * "no redistribute (ospf|table) <1-65535> metric <0-4294967295>",
13054 * NO_STR
13055 * "Redistribute information from another routing protocol\n"
13056 * "Open Shortest Path First (OSPFv2)\n"
13057 * "Non-main Kernel Routing Table\n"
13058 * "Instance ID/Table ID\n"
13059 * "Metric for redistributed routes\n"
13060 * "Default metric\n"
13061 *
13062 * "no redistribute (ospf|table) <1-65535> route-map WORD metric <0-4294967295>",
13063 * NO_STR
13064 * "Redistribute information from another routing protocol\n"
13065 * "Open Shortest Path First (OSPFv2)\n"
13066 * "Non-main Kernel Routing Table\n"
13067 * "Instance ID/Table ID\n"
13068 * "Route map reference\n"
13069 * "Pointer to route-map entries\n"
13070 * "Metric for redistributed routes\n"
13071 * "Default metric\n"
13072 *
13073 * "no redistribute (ospf|table) <1-65535> metric <0-4294967295> route-map WORD",
13074 * NO_STR
13075 * "Redistribute information from another routing protocol\n"
13076 * "Open Shortest Path First (OSPFv2)\n"
13077 * "Non-main Kernel Routing Table\n"
13078 * "Instance ID/Table ID\n"
13079 * "Metric for redistributed routes\n"
13080 * "Default metric\n"
13081 * "Route map reference\n"
13082 * "Pointer to route-map entries\n"
13083 *
13084 */
7c8ff89e
DS
13085DEFUN (no_bgp_redistribute_ipv4_ospf,
13086 no_bgp_redistribute_ipv4_ospf_cmd,
6147e2c6 13087 "no redistribute <ospf|table> (1-65535)",
7c8ff89e
DS
13088 NO_STR
13089 "Redistribute information from another routing protocol\n"
13090 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
13091 "Non-main Kernel Routing Table\n"
13092 "Instance ID/Table ID\n")
7c8ff89e 13093{
c500ae40
DW
13094 int idx_ospf_table = 2;
13095 int idx_number = 3;
7c8ff89e 13096 u_short instance;
7a4bb9c5
DS
13097 int protocol;
13098
c500ae40 13099 if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
7a4bb9c5
DS
13100 protocol = ZEBRA_ROUTE_OSPF;
13101 else
13102 protocol = ZEBRA_ROUTE_TABLE;
7c8ff89e 13103
c500ae40 13104 VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg);
7a4bb9c5 13105 return bgp_redistribute_unset (vty->index, AFI_IP, protocol, instance);
7c8ff89e
DS
13106}
13107
7c8ff89e 13108
7c8ff89e 13109
7c8ff89e 13110
7c8ff89e 13111
f412b39a
DW
13112/*
13113 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9ccf14f7 13114 * "no redistribute <kernel|connected|static|rip|ospf|isis|pim|table> metric <0-4294967295> route-map WORD",
f412b39a
DW
13115 * NO_STR
13116 * "Redistribute information from another routing protocol\n"
13117 * QUAGGA_IP_REDIST_HELP_STR_BGPD
13118 * "Metric for redistributed routes\n"
13119 * "Default metric\n"
13120 * "Route map reference\n"
13121 * "Pointer to route-map entries\n"
13122 *
9ccf14f7 13123 * "no redistribute <kernel|connected|static|rip|ospf|isis|pim|table> route-map WORD",
f412b39a
DW
13124 * NO_STR
13125 * "Redistribute information from another routing protocol\n"
13126 * QUAGGA_IP_REDIST_HELP_STR_BGPD
13127 * "Route map reference\n"
13128 * "Pointer to route-map entries\n"
13129 *
9ccf14f7 13130 * "no redistribute <kernel|connected|static|rip|ospf|isis|pim|table> route-map WORD metric <0-4294967295>",
f412b39a
DW
13131 * NO_STR
13132 * "Redistribute information from another routing protocol\n"
13133 * QUAGGA_IP_REDIST_HELP_STR_BGPD
13134 * "Route map reference\n"
13135 * "Pointer to route-map entries\n"
13136 * "Metric for redistributed routes\n"
13137 * "Default metric\n"
13138 *
9ccf14f7 13139 * "no redistribute <kernel|connected|static|rip|ospf|isis|pim|table> metric <0-4294967295>",
f412b39a
DW
13140 * NO_STR
13141 * "Redistribute information from another routing protocol\n"
13142 * QUAGGA_IP_REDIST_HELP_STR_BGPD
13143 * "Metric for redistributed routes\n"
13144 * "Default metric\n"
13145 *
13146 */
718e3744 13147DEFUN (no_bgp_redistribute_ipv4,
13148 no_bgp_redistribute_ipv4_cmd,
9ccf14f7 13149 "no redistribute <kernel|connected|static|rip|ospf|isis|pim|table>",
718e3744 13150 NO_STR
13151 "Redistribute information from another routing protocol\n"
e0ca5fde 13152 QUAGGA_IP_REDIST_HELP_STR_BGPD)
718e3744 13153{
c500ae40 13154 int idx_protocol = 2;
718e3744 13155 int type;
13156
c500ae40 13157 type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg);
e0ca5fde 13158 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 13159 {
13160 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13161 return CMD_WARNING;
13162 }
7c8ff89e 13163 return bgp_redistribute_unset (vty->index, AFI_IP, type, 0);
718e3744 13164}
13165
718e3744 13166
718e3744 13167
718e3744 13168
6b0655a2 13169
718e3744 13170#ifdef HAVE_IPV6
13171DEFUN (bgp_redistribute_ipv6,
13172 bgp_redistribute_ipv6_cmd,
9ccf14f7 13173 "redistribute <kernel|connected|static|ripng|ospf6|isis|table>",
718e3744 13174 "Redistribute information from another routing protocol\n"
e0ca5fde 13175 QUAGGA_IP6_REDIST_HELP_STR_BGPD)
718e3744 13176{
c500ae40 13177 int idx_protocol = 1;
718e3744 13178 int type;
13179
c500ae40 13180 type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg);
e0ca5fde 13181 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 13182 {
13183 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13184 return CMD_WARNING;
13185 }
13186
7c8ff89e 13187 bgp_redist_add(vty->index, AFI_IP6, type, 0);
6aeb9e78 13188 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
718e3744 13189}
13190
13191DEFUN (bgp_redistribute_ipv6_rmap,
13192 bgp_redistribute_ipv6_rmap_cmd,
9ccf14f7 13193 "redistribute <kernel|connected|static|ripng|ospf6|isis|table> route-map WORD",
718e3744 13194 "Redistribute information from another routing protocol\n"
e0ca5fde 13195 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 13196 "Route map reference\n"
13197 "Pointer to route-map entries\n")
13198{
c500ae40
DW
13199 int idx_protocol = 1;
13200 int idx_word = 3;
718e3744 13201 int type;
7c8ff89e 13202 struct bgp_redist *red;
718e3744 13203
c500ae40 13204 type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg);
e0ca5fde 13205 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 13206 {
13207 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13208 return CMD_WARNING;
13209 }
13210
7c8ff89e 13211 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
c500ae40 13212 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
6aeb9e78 13213 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
718e3744 13214}
13215
13216DEFUN (bgp_redistribute_ipv6_metric,
13217 bgp_redistribute_ipv6_metric_cmd,
9ccf14f7 13218 "redistribute <kernel|connected|static|ripng|ospf6|isis|table> metric (0-4294967295)",
718e3744 13219 "Redistribute information from another routing protocol\n"
e0ca5fde 13220 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 13221 "Metric for redistributed routes\n"
13222 "Default metric\n")
13223{
c500ae40
DW
13224 int idx_protocol = 1;
13225 int idx_number = 3;
718e3744 13226 int type;
13227 u_int32_t metric;
7c8ff89e 13228 struct bgp_redist *red;
718e3744 13229
c500ae40 13230 type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg);
e0ca5fde 13231 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 13232 {
13233 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13234 return CMD_WARNING;
13235 }
c500ae40 13236 VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg);
718e3744 13237
7c8ff89e 13238 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
caf958b4 13239 bgp_redistribute_metric_set(vty->index, red, AFI_IP6, type, metric);
6aeb9e78 13240 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
718e3744 13241}
13242
13243DEFUN (bgp_redistribute_ipv6_rmap_metric,
13244 bgp_redistribute_ipv6_rmap_metric_cmd,
9ccf14f7 13245 "redistribute <kernel|connected|static|ripng|ospf6|isis|table> route-map WORD metric (0-4294967295)",
718e3744 13246 "Redistribute information from another routing protocol\n"
e0ca5fde 13247 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 13248 "Route map reference\n"
13249 "Pointer to route-map entries\n"
13250 "Metric for redistributed routes\n"
13251 "Default metric\n")
13252{
c500ae40
DW
13253 int idx_protocol = 1;
13254 int idx_word = 3;
13255 int idx_number = 5;
718e3744 13256 int type;
13257 u_int32_t metric;
7c8ff89e 13258 struct bgp_redist *red;
718e3744 13259
c500ae40 13260 type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg);
e0ca5fde 13261 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 13262 {
13263 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13264 return CMD_WARNING;
13265 }
c500ae40 13266 VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg);
718e3744 13267
7c8ff89e 13268 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
c500ae40 13269 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
caf958b4 13270 bgp_redistribute_metric_set(vty->index, red, AFI_IP6, type, metric);
6aeb9e78 13271 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
718e3744 13272}
13273
13274DEFUN (bgp_redistribute_ipv6_metric_rmap,
13275 bgp_redistribute_ipv6_metric_rmap_cmd,
9ccf14f7 13276 "redistribute <kernel|connected|static|ripng|ospf6|isis|table> metric (0-4294967295) route-map WORD",
718e3744 13277 "Redistribute information from another routing protocol\n"
e0ca5fde 13278 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 13279 "Metric for redistributed routes\n"
13280 "Default metric\n"
13281 "Route map reference\n"
13282 "Pointer to route-map entries\n")
13283{
c500ae40
DW
13284 int idx_protocol = 1;
13285 int idx_number = 3;
13286 int idx_word = 5;
718e3744 13287 int type;
13288 u_int32_t metric;
7c8ff89e 13289 struct bgp_redist *red;
718e3744 13290
c500ae40 13291 type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg);
e0ca5fde 13292 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 13293 {
13294 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13295 return CMD_WARNING;
13296 }
c500ae40 13297 VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg);
718e3744 13298
7c8ff89e 13299 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
caf958b4 13300 bgp_redistribute_metric_set(vty->index, red, AFI_IP6, SAFI_UNICAST, metric);
c500ae40 13301 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
6aeb9e78 13302 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
718e3744 13303}
13304
f412b39a
DW
13305/*
13306 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9ccf14f7 13307 * "no redistribute <kernel|connected|static|ripng|ospf6|isis|table> route-map WORD",
f412b39a
DW
13308 * NO_STR
13309 * "Redistribute information from another routing protocol\n"
13310 * QUAGGA_IP6_REDIST_HELP_STR_BGPD
13311 * "Route map reference\n"
13312 * "Pointer to route-map entries\n"
13313 *
9ccf14f7 13314 * "no redistribute <kernel|connected|static|ripng|ospf6|isis|table> route-map WORD metric <0-4294967295>",
f412b39a
DW
13315 * NO_STR
13316 * "Redistribute information from another routing protocol\n"
13317 * QUAGGA_IP6_REDIST_HELP_STR_BGPD
13318 * "Route map reference\n"
13319 * "Pointer to route-map entries\n"
13320 * "Metric for redistributed routes\n"
13321 * "Default metric\n"
13322 *
9ccf14f7 13323 * "no redistribute <kernel|connected|static|ripng|ospf6|isis|table> metric <0-4294967295> route-map WORD",
f412b39a
DW
13324 * NO_STR
13325 * "Redistribute information from another routing protocol\n"
13326 * QUAGGA_IP6_REDIST_HELP_STR_BGPD
13327 * "Metric for redistributed routes\n"
13328 * "Default metric\n"
13329 * "Route map reference\n"
13330 * "Pointer to route-map entries\n"
13331 *
9ccf14f7 13332 * "no redistribute <kernel|connected|static|ripng|ospf6|isis|table> metric <0-4294967295>",
f412b39a
DW
13333 * NO_STR
13334 * "Redistribute information from another routing protocol\n"
13335 * QUAGGA_IP6_REDIST_HELP_STR_BGPD
13336 * "Metric for redistributed routes\n"
13337 * "Default metric\n"
13338 *
13339 */
718e3744 13340DEFUN (no_bgp_redistribute_ipv6,
13341 no_bgp_redistribute_ipv6_cmd,
9ccf14f7 13342 "no redistribute <kernel|connected|static|ripng|ospf6|isis|table>",
718e3744 13343 NO_STR
13344 "Redistribute information from another routing protocol\n"
e0ca5fde 13345 QUAGGA_IP6_REDIST_HELP_STR_BGPD)
718e3744 13346{
c500ae40 13347 int idx_protocol = 2;
718e3744 13348 int type;
13349
c500ae40 13350 type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg);
e0ca5fde 13351 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 13352 {
13353 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13354 return CMD_WARNING;
13355 }
13356
7c8ff89e 13357 return bgp_redistribute_unset (vty->index, AFI_IP6, type, 0);
718e3744 13358}
13359
718e3744 13360
718e3744 13361
718e3744 13362
718e3744 13363#endif /* HAVE_IPV6 */
6b0655a2 13364
718e3744 13365int
13366bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi,
13367 safi_t safi, int *write)
13368{
13369 int i;
718e3744 13370
13371 /* Unicast redistribution only. */
13372 if (safi != SAFI_UNICAST)
13373 return 0;
13374
13375 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
13376 {
13377 /* Redistribute BGP does not make sense. */
7c8ff89e 13378 if (i != ZEBRA_ROUTE_BGP)
718e3744 13379 {
7c8ff89e
DS
13380 struct list *red_list;
13381 struct listnode *node;
13382 struct bgp_redist *red;
718e3744 13383
7c8ff89e
DS
13384 red_list = bgp->redist[afi][i];
13385 if (!red_list)
13386 continue;
718e3744 13387
7c8ff89e
DS
13388 for (ALL_LIST_ELEMENTS_RO(red_list, node, red))
13389 {
13390 /* Display "address-family" when it is not yet diplayed. */
13391 bgp_config_write_family_header (vty, afi, safi, write);
13392
13393 /* "redistribute" configuration. */
0b960b4d 13394 vty_out (vty, " redistribute %s", zebra_route_string(i));
7c8ff89e
DS
13395 if (red->instance)
13396 vty_out (vty, " %d", red->instance);
13397 if (red->redist_metric_flag)
13398 vty_out (vty, " metric %u", red->redist_metric);
13399 if (red->rmap.name)
13400 vty_out (vty, " route-map %s", red->rmap.name);
13401 vty_out (vty, "%s", VTY_NEWLINE);
13402 }
718e3744 13403 }
13404 }
13405 return *write;
13406}
6b0655a2 13407
718e3744 13408/* BGP node structure. */
7fc626de 13409static struct cmd_node bgp_node =
718e3744 13410{
13411 BGP_NODE,
13412 "%s(config-router)# ",
13413 1,
13414};
13415
7fc626de 13416static struct cmd_node bgp_ipv4_unicast_node =
718e3744 13417{
13418 BGP_IPV4_NODE,
13419 "%s(config-router-af)# ",
13420 1,
13421};
13422
7fc626de 13423static struct cmd_node bgp_ipv4_multicast_node =
718e3744 13424{
13425 BGP_IPV4M_NODE,
13426 "%s(config-router-af)# ",
13427 1,
13428};
13429
7fc626de 13430static struct cmd_node bgp_ipv6_unicast_node =
718e3744 13431{
13432 BGP_IPV6_NODE,
13433 "%s(config-router-af)# ",
13434 1,
13435};
13436
7fc626de 13437static struct cmd_node bgp_ipv6_multicast_node =
25ffbdc1 13438{
13439 BGP_IPV6M_NODE,
13440 "%s(config-router-af)# ",
13441 1,
13442};
13443
7fc626de 13444static struct cmd_node bgp_vpnv4_node =
718e3744 13445{
13446 BGP_VPNV4_NODE,
13447 "%s(config-router-af)# ",
13448 1
13449};
6b0655a2 13450
8ecd3266 13451static struct cmd_node bgp_vpnv6_node =
13452{
13453 BGP_VPNV6_NODE,
13454 "%s(config-router-af-vpnv6)# ",
13455 1
13456};
13457
8b1fb8be
LB
13458static struct cmd_node bgp_encap_node =
13459{
13460 BGP_ENCAP_NODE,
13461 "%s(config-router-af-encap)# ",
13462 1
13463};
13464
13465static struct cmd_node bgp_encapv6_node =
13466{
13467 BGP_ENCAPV6_NODE,
13468 "%s(config-router-af-encapv6)# ",
13469 1
13470};
13471
1f8ae70b 13472static void community_list_vty (void);
13473
718e3744 13474void
94f2b392 13475bgp_vty_init (void)
718e3744 13476{
718e3744 13477 /* Install bgp top node. */
13478 install_node (&bgp_node, bgp_config_write);
13479 install_node (&bgp_ipv4_unicast_node, NULL);
13480 install_node (&bgp_ipv4_multicast_node, NULL);
13481 install_node (&bgp_ipv6_unicast_node, NULL);
25ffbdc1 13482 install_node (&bgp_ipv6_multicast_node, NULL);
718e3744 13483 install_node (&bgp_vpnv4_node, NULL);
8ecd3266 13484 install_node (&bgp_vpnv6_node, NULL);
8b1fb8be
LB
13485 install_node (&bgp_encap_node, NULL);
13486 install_node (&bgp_encapv6_node, NULL);
718e3744 13487
13488 /* Install default VTY commands to new nodes. */
13489 install_default (BGP_NODE);
13490 install_default (BGP_IPV4_NODE);
13491 install_default (BGP_IPV4M_NODE);
13492 install_default (BGP_IPV6_NODE);
25ffbdc1 13493 install_default (BGP_IPV6M_NODE);
718e3744 13494 install_default (BGP_VPNV4_NODE);
8ecd3266 13495 install_default (BGP_VPNV6_NODE);
8b1fb8be
LB
13496 install_default (BGP_ENCAP_NODE);
13497 install_default (BGP_ENCAPV6_NODE);
718e3744 13498
13499 /* "bgp multiple-instance" commands. */
13500 install_element (CONFIG_NODE, &bgp_multiple_instance_cmd);
13501 install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd);
13502
13503 /* "bgp config-type" commands. */
13504 install_element (CONFIG_NODE, &bgp_config_type_cmd);
718e3744 13505
5fe9f963 13506 /* bgp route-map delay-timer commands. */
13507 install_element (CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd);
13508 install_element (CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd);
5fe9f963 13509
718e3744 13510 /* Dummy commands (Currently not supported) */
13511 install_element (BGP_NODE, &no_synchronization_cmd);
13512 install_element (BGP_NODE, &no_auto_summary_cmd);
13513
13514 /* "router bgp" commands. */
13515 install_element (CONFIG_NODE, &router_bgp_cmd);
718e3744 13516
13517 /* "no router bgp" commands. */
13518 install_element (CONFIG_NODE, &no_router_bgp_cmd);
718e3744 13519
13520 /* "bgp router-id" commands. */
13521 install_element (BGP_NODE, &bgp_router_id_cmd);
13522 install_element (BGP_NODE, &no_bgp_router_id_cmd);
718e3744 13523
13524 /* "bgp cluster-id" commands. */
13525 install_element (BGP_NODE, &bgp_cluster_id_cmd);
718e3744 13526 install_element (BGP_NODE, &no_bgp_cluster_id_cmd);
718e3744 13527
13528 /* "bgp confederation" commands. */
13529 install_element (BGP_NODE, &bgp_confederation_identifier_cmd);
13530 install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd);
718e3744 13531
13532 /* "bgp confederation peers" commands. */
13533 install_element (BGP_NODE, &bgp_confederation_peers_cmd);
13534 install_element (BGP_NODE, &no_bgp_confederation_peers_cmd);
13535
abc920f8
DS
13536 /* bgp max-med command */
13537 install_element (BGP_NODE, &bgp_maxmed_admin_cmd);
13538 install_element (BGP_NODE, &no_bgp_maxmed_admin_cmd);
13539 install_element (BGP_NODE, &bgp_maxmed_admin_medv_cmd);
abc920f8
DS
13540 install_element (BGP_NODE, &bgp_maxmed_onstartup_cmd);
13541 install_element (BGP_NODE, &no_bgp_maxmed_onstartup_cmd);
abc920f8 13542 install_element (BGP_NODE, &bgp_maxmed_onstartup_medv_cmd);
abc920f8 13543
907f92c8
DS
13544 /* bgp disable-ebgp-connected-nh-check */
13545 install_element (BGP_NODE, &bgp_disable_connected_route_check_cmd);
13546 install_element (BGP_NODE, &no_bgp_disable_connected_route_check_cmd);
13547
f188f2c4
DS
13548 /* bgp update-delay command */
13549 install_element (BGP_NODE, &bgp_update_delay_cmd);
13550 install_element (BGP_NODE, &no_bgp_update_delay_cmd);
13551 install_element (BGP_NODE, &bgp_update_delay_establish_wait_cmd);
f188f2c4 13552
cb1faec9
DS
13553 install_element (BGP_NODE, &bgp_wpkt_quanta_cmd);
13554 install_element (BGP_NODE, &no_bgp_wpkt_quanta_cmd);
13555
3f9c7369
DS
13556 install_element (BGP_NODE, &bgp_coalesce_time_cmd);
13557 install_element (BGP_NODE, &no_bgp_coalesce_time_cmd);
13558
165b5fff
JB
13559 /* "maximum-paths" commands. */
13560 install_element (BGP_NODE, &bgp_maxpaths_cmd);
13561 install_element (BGP_NODE, &no_bgp_maxpaths_cmd);
165b5fff
JB
13562 install_element (BGP_IPV4_NODE, &bgp_maxpaths_cmd);
13563 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_cmd);
431aa9f9
DS
13564 install_element (BGP_IPV6_NODE, &bgp_maxpaths_cmd);
13565 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_cmd);
165b5fff 13566 install_element (BGP_NODE, &bgp_maxpaths_ibgp_cmd);
5e242b0d 13567 install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
165b5fff 13568 install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cmd);
165b5fff 13569 install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd);
5e242b0d 13570 install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
165b5fff 13571 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd);
431aa9f9 13572 install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd);
5e242b0d 13573 install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
431aa9f9 13574 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd);
165b5fff 13575
718e3744 13576 /* "timers bgp" commands. */
13577 install_element (BGP_NODE, &bgp_timers_cmd);
13578 install_element (BGP_NODE, &no_bgp_timers_cmd);
718e3744 13579
5fe9f963 13580 /* route-map delay-timer commands - per instance for backwards compat. */
518f0eb1
DS
13581 install_element (BGP_NODE, &bgp_set_route_map_delay_timer_cmd);
13582 install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd);
13583
718e3744 13584 /* "bgp client-to-client reflection" commands */
13585 install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd);
13586 install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd);
13587
13588 /* "bgp always-compare-med" commands */
13589 install_element (BGP_NODE, &bgp_always_compare_med_cmd);
13590 install_element (BGP_NODE, &no_bgp_always_compare_med_cmd);
13591
13592 /* "bgp deterministic-med" commands */
13593 install_element (BGP_NODE, &bgp_deterministic_med_cmd);
13594 install_element (BGP_NODE, &no_bgp_deterministic_med_cmd);
538621f2 13595
538621f2 13596 /* "bgp graceful-restart" commands */
13597 install_element (BGP_NODE, &bgp_graceful_restart_cmd);
13598 install_element (BGP_NODE, &no_bgp_graceful_restart_cmd);
93406d87 13599 install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd);
13600 install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd);
eb6f1b41
PG
13601 install_element (BGP_NODE, &bgp_graceful_restart_restart_time_cmd);
13602 install_element (BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd);
718e3744 13603
13604 /* "bgp fast-external-failover" commands */
13605 install_element (BGP_NODE, &bgp_fast_external_failover_cmd);
13606 install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd);
13607
13608 /* "bgp enforce-first-as" commands */
13609 install_element (BGP_NODE, &bgp_enforce_first_as_cmd);
13610 install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd);
13611
13612 /* "bgp bestpath compare-routerid" commands */
13613 install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd);
13614 install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd);
13615
13616 /* "bgp bestpath as-path ignore" commands */
13617 install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd);
13618 install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd);
13619
6811845b 13620 /* "bgp bestpath as-path confed" commands */
13621 install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd);
13622 install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd);
13623
2fdd455c
PM
13624 /* "bgp bestpath as-path multipath-relax" commands */
13625 install_element (BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd);
13626 install_element (BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd);
13627
848973c7 13628 /* "bgp log-neighbor-changes" commands */
13629 install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd);
13630 install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd);
13631
718e3744 13632 /* "bgp bestpath med" commands */
13633 install_element (BGP_NODE, &bgp_bestpath_med_cmd);
13634 install_element (BGP_NODE, &bgp_bestpath_med2_cmd);
718e3744 13635 install_element (BGP_NODE, &no_bgp_bestpath_med_cmd);
13636 install_element (BGP_NODE, &no_bgp_bestpath_med2_cmd);
718e3744 13637
13638 /* "no bgp default ipv4-unicast" commands. */
13639 install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd);
13640 install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd);
13641
13642 /* "bgp network import-check" commands. */
13643 install_element (BGP_NODE, &bgp_network_import_check_cmd);
8233ef81 13644 install_element (BGP_NODE, &bgp_network_import_check_exact_cmd);
718e3744 13645 install_element (BGP_NODE, &no_bgp_network_import_check_cmd);
13646
13647 /* "bgp default local-preference" commands. */
13648 install_element (BGP_NODE, &bgp_default_local_preference_cmd);
13649 install_element (BGP_NODE, &no_bgp_default_local_preference_cmd);
718e3744 13650
04b6bdc0
DW
13651 /* bgp default show-hostname */
13652 install_element (BGP_NODE, &bgp_default_show_hostname_cmd);
13653 install_element (BGP_NODE, &no_bgp_default_show_hostname_cmd);
13654
3f9c7369
DS
13655 /* "bgp default subgroup-pkt-queue-max" commands. */
13656 install_element (BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd);
13657 install_element (BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd);
13658
8bd9d948
DS
13659 /* bgp ibgp-allow-policy-mods command */
13660 install_element (BGP_NODE, &bgp_rr_allow_outbound_policy_cmd);
13661 install_element (BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd);
13662
f14e6fdb
DS
13663 /* "bgp listen limit" commands. */
13664 install_element (BGP_NODE, &bgp_listen_limit_cmd);
13665 install_element (BGP_NODE, &no_bgp_listen_limit_cmd);
13666
13667 /* "bgp listen range" commands. */
13668 install_element (BGP_NODE, &bgp_listen_range_cmd);
13669 install_element (BGP_NODE, &no_bgp_listen_range_cmd);
13670
718e3744 13671 /* "neighbor remote-as" commands. */
13672 install_element (BGP_NODE, &neighbor_remote_as_cmd);
a80beece 13673 install_element (BGP_NODE, &neighbor_interface_config_cmd);
4c48cf63 13674 install_element (BGP_NODE, &neighbor_interface_config_v6only_cmd);
b3a39dc5
DD
13675 install_element (BGP_NODE, &neighbor_interface_config_remote_as_cmd);
13676 install_element (BGP_NODE, &neighbor_interface_v6only_config_remote_as_cmd);
718e3744 13677 install_element (BGP_NODE, &no_neighbor_cmd);
a80beece 13678 install_element (BGP_NODE, &no_neighbor_interface_config_cmd);
718e3744 13679
13680 /* "neighbor peer-group" commands. */
13681 install_element (BGP_NODE, &neighbor_peer_group_cmd);
13682 install_element (BGP_NODE, &no_neighbor_peer_group_cmd);
a80beece 13683 install_element (BGP_NODE, &no_neighbor_interface_peer_group_remote_as_cmd);
718e3744 13684
13685 /* "neighbor local-as" commands. */
13686 install_element (BGP_NODE, &neighbor_local_as_cmd);
13687 install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd);
9d3f9705 13688 install_element (BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd);
718e3744 13689 install_element (BGP_NODE, &no_neighbor_local_as_cmd);
718e3744 13690
3f9c7369
DS
13691 /* "neighbor solo" commands. */
13692 install_element (BGP_NODE, &neighbor_solo_cmd);
13693 install_element (BGP_NODE, &no_neighbor_solo_cmd);
13694
0df7c91f
PJ
13695 /* "neighbor password" commands. */
13696 install_element (BGP_NODE, &neighbor_password_cmd);
13697 install_element (BGP_NODE, &no_neighbor_password_cmd);
13698
718e3744 13699 /* "neighbor activate" commands. */
13700 install_element (BGP_NODE, &neighbor_activate_cmd);
13701 install_element (BGP_IPV4_NODE, &neighbor_activate_cmd);
13702 install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd);
13703 install_element (BGP_IPV6_NODE, &neighbor_activate_cmd);
25ffbdc1 13704 install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd);
718e3744 13705 install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd);
8ecd3266 13706 install_element (BGP_VPNV6_NODE, &neighbor_activate_cmd);
8b1fb8be
LB
13707 install_element (BGP_ENCAP_NODE, &neighbor_activate_cmd);
13708 install_element (BGP_ENCAPV6_NODE, &neighbor_activate_cmd);
718e3744 13709
13710 /* "no neighbor activate" commands. */
13711 install_element (BGP_NODE, &no_neighbor_activate_cmd);
13712 install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd);
13713 install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd);
13714 install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd);
25ffbdc1 13715 install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd);
718e3744 13716 install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd);
8ecd3266 13717 install_element (BGP_VPNV6_NODE, &no_neighbor_activate_cmd);
8b1fb8be
LB
13718 install_element (BGP_ENCAP_NODE, &no_neighbor_activate_cmd);
13719 install_element (BGP_ENCAPV6_NODE, &no_neighbor_activate_cmd);
718e3744 13720
c8560b44
DW
13721 /* "neighbor peer-group" set commands.
13722 * Long term we should only accept this command under BGP_NODE and not all of
13723 * the afi/safi sub-contexts. For now though we need to accept it for backwards
13724 * compatibility. This changed when we stopped requiring that peers be assigned
13725 * to their peer-group under each address-family sub-context.
13726 */
718e3744 13727 install_element (BGP_NODE, &neighbor_set_peer_group_cmd);
13728 install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_cmd);
13729 install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_cmd);
13730 install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd);
25ffbdc1 13731 install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_cmd);
a58545bb 13732 install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_cmd);
8ecd3266 13733 install_element (BGP_VPNV6_NODE, &neighbor_set_peer_group_cmd);
8b1fb8be
LB
13734 install_element (BGP_ENCAP_NODE, &neighbor_set_peer_group_cmd);
13735 install_element (BGP_ENCAPV6_NODE, &neighbor_set_peer_group_cmd);
c8560b44 13736
718e3744 13737 /* "no neighbor peer-group unset" commands. */
13738 install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd);
13739 install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd);
13740 install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_cmd);
13741 install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd);
25ffbdc1 13742 install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_cmd);
a58545bb 13743 install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_cmd);
8ecd3266 13744 install_element (BGP_VPNV6_NODE, &no_neighbor_set_peer_group_cmd);
8b1fb8be
LB
13745 install_element (BGP_ENCAP_NODE, &no_neighbor_set_peer_group_cmd);
13746 install_element (BGP_ENCAPV6_NODE, &no_neighbor_set_peer_group_cmd);
a58545bb 13747
718e3744 13748 /* "neighbor softreconfiguration inbound" commands.*/
13749 install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd);
13750 install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd);
13751 install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd);
13752 install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
13753 install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd);
13754 install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd);
13755 install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd);
13756 install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
25ffbdc1 13757 install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd);
13758 install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd);
a58545bb 13759 install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd);
13760 install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
8ecd3266 13761 install_element (BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd);
13762 install_element (BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
8b1fb8be
LB
13763 install_element (BGP_ENCAP_NODE, &neighbor_soft_reconfiguration_cmd);
13764 install_element (BGP_ENCAP_NODE, &no_neighbor_soft_reconfiguration_cmd);
13765 install_element (BGP_ENCAPV6_NODE, &neighbor_soft_reconfiguration_cmd);
13766 install_element (BGP_ENCAPV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
718e3744 13767
13768 /* "neighbor attribute-unchanged" commands. */
13769 install_element (BGP_NODE, &neighbor_attr_unchanged_cmd);
13770 install_element (BGP_NODE, &neighbor_attr_unchanged1_cmd);
13771 install_element (BGP_NODE, &neighbor_attr_unchanged2_cmd);
13772 install_element (BGP_NODE, &neighbor_attr_unchanged3_cmd);
13773 install_element (BGP_NODE, &neighbor_attr_unchanged4_cmd);
718e3744 13774 install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd);
13775 install_element (BGP_NODE, &no_neighbor_attr_unchanged1_cmd);
13776 install_element (BGP_NODE, &no_neighbor_attr_unchanged2_cmd);
13777 install_element (BGP_NODE, &no_neighbor_attr_unchanged3_cmd);
13778 install_element (BGP_NODE, &no_neighbor_attr_unchanged4_cmd);
718e3744 13779 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd);
13780 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged1_cmd);
13781 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged2_cmd);
13782 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged3_cmd);
13783 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged4_cmd);
718e3744 13784 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd);
13785 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged1_cmd);
13786 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged2_cmd);
13787 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged3_cmd);
13788 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged4_cmd);
718e3744 13789 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd);
13790 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged1_cmd);
13791 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged2_cmd);
13792 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged3_cmd);
13793 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged4_cmd);
718e3744 13794 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd);
13795 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged1_cmd);
13796 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged2_cmd);
13797 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged3_cmd);
13798 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged4_cmd);
718e3744 13799 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd);
13800 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged1_cmd);
13801 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged2_cmd);
13802 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged3_cmd);
13803 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged4_cmd);
718e3744 13804 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd);
13805 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged1_cmd);
13806 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged2_cmd);
13807 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged3_cmd);
13808 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged4_cmd);
25ffbdc1 13809 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd);
13810 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged1_cmd);
13811 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged2_cmd);
13812 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged3_cmd);
13813 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged4_cmd);
25ffbdc1 13814 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd);
13815 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged1_cmd);
13816 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged2_cmd);
13817 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged3_cmd);
13818 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged4_cmd);
718e3744 13819 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd);
13820 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged1_cmd);
13821 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged2_cmd);
13822 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged3_cmd);
13823 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged4_cmd);
718e3744 13824 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd);
13825 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged1_cmd);
13826 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged2_cmd);
13827 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged3_cmd);
13828 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged4_cmd);
8ecd3266 13829 install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd);
13830 install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged1_cmd);
13831 install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged2_cmd);
13832 install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged3_cmd);
13833 install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged4_cmd);
8ecd3266 13834 install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd);
13835 install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged1_cmd);
13836 install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged2_cmd);
13837 install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged3_cmd);
13838 install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged4_cmd);
8ecd3266 13839
8b1fb8be
LB
13840 install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged_cmd);
13841 install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged1_cmd);
13842 install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged2_cmd);
13843 install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged3_cmd);
13844 install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged4_cmd);
8b1fb8be
LB
13845 install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged_cmd);
13846 install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged1_cmd);
13847 install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged2_cmd);
13848 install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged3_cmd);
13849 install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged4_cmd);
8b1fb8be
LB
13850
13851 install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged_cmd);
13852 install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged1_cmd);
13853 install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged2_cmd);
13854 install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged3_cmd);
13855 install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged4_cmd);
8b1fb8be
LB
13856 install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged_cmd);
13857 install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged1_cmd);
13858 install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged2_cmd);
13859 install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged3_cmd);
13860 install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged4_cmd);
718e3744 13861
fee0f4c6 13862 /* "nexthop-local unchanged" commands */
13863 install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd);
13864 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd);
13865
718e3744 13866 /* "neighbor next-hop-self" commands. */
13867 install_element (BGP_NODE, &neighbor_nexthop_self_cmd);
13868 install_element (BGP_NODE, &no_neighbor_nexthop_self_cmd);
13869 install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd);
13870 install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd);
13871 install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd);
13872 install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd);
13873 install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd);
13874 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd);
25ffbdc1 13875 install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd);
13876 install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd);
718e3744 13877 install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd);
13878 install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd);
8ecd3266 13879 install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd);
13880 install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd);
8b1fb8be
LB
13881 install_element (BGP_ENCAP_NODE, &neighbor_nexthop_self_cmd);
13882 install_element (BGP_ENCAP_NODE, &no_neighbor_nexthop_self_cmd);
13883 install_element (BGP_ENCAPV6_NODE, &neighbor_nexthop_self_cmd);
13884 install_element (BGP_ENCAPV6_NODE, &no_neighbor_nexthop_self_cmd);
718e3744 13885
a538debe
DS
13886 /* "neighbor next-hop-self force" commands. */
13887 install_element (BGP_NODE, &neighbor_nexthop_self_force_cmd);
13888 install_element (BGP_NODE, &no_neighbor_nexthop_self_force_cmd);
13889 install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd);
13890 install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd);
13891 install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd);
13892 install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd);
13893 install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd);
13894 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd);
13895 install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd);
13896 install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd);
13897 install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd);
13898 install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd);
8ecd3266 13899 install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd);
13900 install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd);
a538debe 13901
c7122e14
DS
13902 /* "neighbor as-override" commands. */
13903 install_element (BGP_NODE, &neighbor_as_override_cmd);
13904 install_element (BGP_NODE, &no_neighbor_as_override_cmd);
13905 install_element (BGP_IPV4_NODE, &neighbor_as_override_cmd);
13906 install_element (BGP_IPV4_NODE, &no_neighbor_as_override_cmd);
13907 install_element (BGP_IPV4M_NODE, &neighbor_as_override_cmd);
13908 install_element (BGP_IPV4M_NODE, &no_neighbor_as_override_cmd);
13909 install_element (BGP_IPV6_NODE, &neighbor_as_override_cmd);
13910 install_element (BGP_IPV6_NODE, &no_neighbor_as_override_cmd);
13911 install_element (BGP_IPV6M_NODE, &neighbor_as_override_cmd);
13912 install_element (BGP_IPV6M_NODE, &no_neighbor_as_override_cmd);
13913 install_element (BGP_VPNV4_NODE, &neighbor_as_override_cmd);
13914 install_element (BGP_VPNV4_NODE, &no_neighbor_as_override_cmd);
8ecd3266 13915 install_element (BGP_VPNV6_NODE, &neighbor_as_override_cmd);
13916 install_element (BGP_VPNV6_NODE, &no_neighbor_as_override_cmd);
c7122e14 13917
718e3744 13918 /* "neighbor remove-private-AS" commands. */
13919 install_element (BGP_NODE, &neighbor_remove_private_as_cmd);
13920 install_element (BGP_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
13921 install_element (BGP_NODE, &neighbor_remove_private_as_all_cmd);
13922 install_element (BGP_NODE, &no_neighbor_remove_private_as_all_cmd);
13923 install_element (BGP_NODE, &neighbor_remove_private_as_replace_as_cmd);
13924 install_element (BGP_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
13925 install_element (BGP_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
13926 install_element (BGP_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 13927 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd);
13928 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
13929 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd);
13930 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd);
13931 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_replace_as_cmd);
13932 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
13933 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
13934 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 13935 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd);
13936 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
13937 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd);
13938 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd);
13939 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_replace_as_cmd);
13940 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
13941 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
13942 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 13943 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd);
13944 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
13945 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd);
13946 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd);
13947 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_replace_as_cmd);
13948 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
13949 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
13950 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
25ffbdc1 13951 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd);
13952 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
13953 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd);
13954 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd);
13955 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_replace_as_cmd);
13956 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
13957 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
13958 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 13959 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd);
13960 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
13961 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd);
13962 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd);
13963 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_replace_as_cmd);
13964 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
13965 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
13966 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
8ecd3266 13967 install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd);
13968 install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd);
13969 install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd);
13970 install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd);
13971 install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_replace_as_cmd);
13972 install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
13973 install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
13974 install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
8b1fb8be
LB
13975 install_element (BGP_ENCAP_NODE, &neighbor_remove_private_as_cmd);
13976 install_element (BGP_ENCAP_NODE, &no_neighbor_remove_private_as_cmd);
13977 install_element (BGP_ENCAPV6_NODE, &neighbor_remove_private_as_cmd);
13978 install_element (BGP_ENCAPV6_NODE, &no_neighbor_remove_private_as_cmd);
718e3744 13979
13980 /* "neighbor send-community" commands.*/
13981 install_element (BGP_NODE, &neighbor_send_community_cmd);
13982 install_element (BGP_NODE, &neighbor_send_community_type_cmd);
13983 install_element (BGP_NODE, &no_neighbor_send_community_cmd);
13984 install_element (BGP_NODE, &no_neighbor_send_community_type_cmd);
13985 install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd);
13986 install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd);
13987 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd);
13988 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd);
13989 install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd);
13990 install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd);
13991 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd);
13992 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd);
13993 install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd);
13994 install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd);
13995 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd);
13996 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd);
25ffbdc1 13997 install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd);
13998 install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd);
13999 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd);
14000 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd);
718e3744 14001 install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd);
14002 install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd);
14003 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd);
14004 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd);
8ecd3266 14005 install_element (BGP_VPNV6_NODE, &neighbor_send_community_cmd);
14006 install_element (BGP_VPNV6_NODE, &neighbor_send_community_type_cmd);
14007 install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_cmd);
14008 install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd);
8b1fb8be
LB
14009 install_element (BGP_ENCAP_NODE, &neighbor_send_community_cmd);
14010 install_element (BGP_ENCAP_NODE, &neighbor_send_community_type_cmd);
14011 install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_cmd);
14012 install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_type_cmd);
14013 install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_cmd);
14014 install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_type_cmd);
14015 install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_cmd);
14016 install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_type_cmd);
718e3744 14017
14018 /* "neighbor route-reflector" commands.*/
14019 install_element (BGP_NODE, &neighbor_route_reflector_client_cmd);
14020 install_element (BGP_NODE, &no_neighbor_route_reflector_client_cmd);
14021 install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd);
14022 install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd);
14023 install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd);
14024 install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd);
14025 install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd);
14026 install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd);
25ffbdc1 14027 install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd);
14028 install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd);
718e3744 14029 install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd);
14030 install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd);
8ecd3266 14031 install_element (BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd);
14032 install_element (BGP_VPNV6_NODE, &no_neighbor_route_reflector_client_cmd);
8b1fb8be
LB
14033 install_element (BGP_ENCAP_NODE, &neighbor_route_reflector_client_cmd);
14034 install_element (BGP_ENCAP_NODE, &no_neighbor_route_reflector_client_cmd);
14035 install_element (BGP_ENCAPV6_NODE, &neighbor_route_reflector_client_cmd);
14036 install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_reflector_client_cmd);
718e3744 14037
14038 /* "neighbor route-server" commands.*/
14039 install_element (BGP_NODE, &neighbor_route_server_client_cmd);
14040 install_element (BGP_NODE, &no_neighbor_route_server_client_cmd);
14041 install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd);
14042 install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd);
14043 install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd);
14044 install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd);
14045 install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd);
14046 install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd);
25ffbdc1 14047 install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd);
14048 install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd);
718e3744 14049 install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd);
14050 install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd);
8ecd3266 14051 install_element (BGP_VPNV6_NODE, &neighbor_route_server_client_cmd);
14052 install_element (BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd);
8b1fb8be
LB
14053 install_element (BGP_ENCAP_NODE, &neighbor_route_server_client_cmd);
14054 install_element (BGP_ENCAP_NODE, &no_neighbor_route_server_client_cmd);
14055 install_element (BGP_ENCAPV6_NODE, &neighbor_route_server_client_cmd);
14056 install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_server_client_cmd);
718e3744 14057
adbac85e
DW
14058 /* "neighbor addpath-tx-all-paths" commands.*/
14059 install_element (BGP_NODE, &neighbor_addpath_tx_all_paths_cmd);
14060 install_element (BGP_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
14061 install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd);
14062 install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
14063 install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd);
14064 install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
14065 install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd);
14066 install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
14067 install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd);
14068 install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
14069 install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd);
14070 install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
8ecd3266 14071 install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd);
14072 install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
adbac85e 14073
06370dac
DW
14074 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
14075 install_element (BGP_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14076 install_element (BGP_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
14077 install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14078 install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
14079 install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14080 install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
14081 install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14082 install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
14083 install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14084 install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
14085 install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14086 install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
8ecd3266 14087 install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14088 install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
06370dac 14089
718e3744 14090 /* "neighbor passive" commands. */
14091 install_element (BGP_NODE, &neighbor_passive_cmd);
14092 install_element (BGP_NODE, &no_neighbor_passive_cmd);
14093
d5a5c8f0 14094
718e3744 14095 /* "neighbor shutdown" commands. */
14096 install_element (BGP_NODE, &neighbor_shutdown_cmd);
14097 install_element (BGP_NODE, &no_neighbor_shutdown_cmd);
14098
8a92a8a0
DS
14099 /* "neighbor capability extended-nexthop" commands.*/
14100 install_element (BGP_NODE, &neighbor_capability_enhe_cmd);
14101 install_element (BGP_NODE, &no_neighbor_capability_enhe_cmd);
14102
718e3744 14103 /* "neighbor capability orf prefix-list" commands.*/
14104 install_element (BGP_NODE, &neighbor_capability_orf_prefix_cmd);
14105 install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_cmd);
14106 install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd);
14107 install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd);
14108 install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd);
14109 install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd);
14110 install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd);
14111 install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd);
25ffbdc1 14112 install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd);
14113 install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd);
718e3744 14114
14115 /* "neighbor capability dynamic" commands.*/
14116 install_element (BGP_NODE, &neighbor_capability_dynamic_cmd);
14117 install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd);
14118
14119 /* "neighbor dont-capability-negotiate" commands. */
14120 install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd);
14121 install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd);
14122
14123 /* "neighbor ebgp-multihop" commands. */
14124 install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd);
14125 install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd);
14126 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd);
718e3744 14127
6ffd2079 14128 /* "neighbor disable-connected-check" commands. */
14129 install_element (BGP_NODE, &neighbor_disable_connected_check_cmd);
14130 install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd);
718e3744 14131
14132 /* "neighbor description" commands. */
14133 install_element (BGP_NODE, &neighbor_description_cmd);
14134 install_element (BGP_NODE, &no_neighbor_description_cmd);
718e3744 14135
14136 /* "neighbor update-source" commands. "*/
14137 install_element (BGP_NODE, &neighbor_update_source_cmd);
14138 install_element (BGP_NODE, &no_neighbor_update_source_cmd);
14139
14140 /* "neighbor default-originate" commands. */
14141 install_element (BGP_NODE, &neighbor_default_originate_cmd);
14142 install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd);
14143 install_element (BGP_NODE, &no_neighbor_default_originate_cmd);
718e3744 14144 install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd);
14145 install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd);
14146 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd);
718e3744 14147 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd);
14148 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd);
14149 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd);
718e3744 14150 install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd);
14151 install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd);
14152 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd);
25ffbdc1 14153 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd);
14154 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd);
14155 install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd);
718e3744 14156
14157 /* "neighbor port" commands. */
14158 install_element (BGP_NODE, &neighbor_port_cmd);
14159 install_element (BGP_NODE, &no_neighbor_port_cmd);
718e3744 14160
14161 /* "neighbor weight" commands. */
14162 install_element (BGP_NODE, &neighbor_weight_cmd);
14163 install_element (BGP_NODE, &no_neighbor_weight_cmd);
718e3744 14164
14165 /* "neighbor override-capability" commands. */
14166 install_element (BGP_NODE, &neighbor_override_capability_cmd);
14167 install_element (BGP_NODE, &no_neighbor_override_capability_cmd);
14168
14169 /* "neighbor strict-capability-match" commands. */
14170 install_element (BGP_NODE, &neighbor_strict_capability_cmd);
14171 install_element (BGP_NODE, &no_neighbor_strict_capability_cmd);
14172
14173 /* "neighbor timers" commands. */
14174 install_element (BGP_NODE, &neighbor_timers_cmd);
14175 install_element (BGP_NODE, &no_neighbor_timers_cmd);
14176
14177 /* "neighbor timers connect" commands. */
14178 install_element (BGP_NODE, &neighbor_timers_connect_cmd);
14179 install_element (BGP_NODE, &no_neighbor_timers_connect_cmd);
718e3744 14180
14181 /* "neighbor advertisement-interval" commands. */
14182 install_element (BGP_NODE, &neighbor_advertise_interval_cmd);
14183 install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd);
718e3744 14184
718e3744 14185 /* "neighbor interface" commands. */
14186 install_element (BGP_NODE, &neighbor_interface_cmd);
14187 install_element (BGP_NODE, &no_neighbor_interface_cmd);
14188
14189 /* "neighbor distribute" commands. */
14190 install_element (BGP_NODE, &neighbor_distribute_list_cmd);
14191 install_element (BGP_NODE, &no_neighbor_distribute_list_cmd);
14192 install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd);
14193 install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd);
14194 install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd);
14195 install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd);
14196 install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd);
14197 install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd);
25ffbdc1 14198 install_element (BGP_IPV6M_NODE, &neighbor_distribute_list_cmd);
14199 install_element (BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd);
718e3744 14200 install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd);
14201 install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd);
8ecd3266 14202 install_element (BGP_VPNV6_NODE, &neighbor_distribute_list_cmd);
14203 install_element (BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd);
8b1fb8be
LB
14204 install_element (BGP_ENCAP_NODE, &neighbor_distribute_list_cmd);
14205 install_element (BGP_ENCAP_NODE, &no_neighbor_distribute_list_cmd);
14206 install_element (BGP_ENCAPV6_NODE, &neighbor_distribute_list_cmd);
14207 install_element (BGP_ENCAPV6_NODE, &no_neighbor_distribute_list_cmd);
718e3744 14208
14209 /* "neighbor prefix-list" commands. */
14210 install_element (BGP_NODE, &neighbor_prefix_list_cmd);
14211 install_element (BGP_NODE, &no_neighbor_prefix_list_cmd);
14212 install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd);
14213 install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd);
14214 install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd);
14215 install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd);
14216 install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd);
14217 install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd);
25ffbdc1 14218 install_element (BGP_IPV6M_NODE, &neighbor_prefix_list_cmd);
14219 install_element (BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd);
718e3744 14220 install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd);
14221 install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd);
8ecd3266 14222 install_element (BGP_VPNV6_NODE, &neighbor_prefix_list_cmd);
14223 install_element (BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd);
8b1fb8be
LB
14224 install_element (BGP_ENCAP_NODE, &neighbor_prefix_list_cmd);
14225 install_element (BGP_ENCAP_NODE, &no_neighbor_prefix_list_cmd);
14226 install_element (BGP_ENCAPV6_NODE, &neighbor_prefix_list_cmd);
14227 install_element (BGP_ENCAPV6_NODE, &no_neighbor_prefix_list_cmd);
718e3744 14228
14229 /* "neighbor filter-list" commands. */
14230 install_element (BGP_NODE, &neighbor_filter_list_cmd);
14231 install_element (BGP_NODE, &no_neighbor_filter_list_cmd);
14232 install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd);
14233 install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd);
14234 install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd);
14235 install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd);
14236 install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd);
14237 install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd);
25ffbdc1 14238 install_element (BGP_IPV6M_NODE, &neighbor_filter_list_cmd);
14239 install_element (BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd);
718e3744 14240 install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd);
14241 install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd);
8ecd3266 14242 install_element (BGP_VPNV6_NODE, &neighbor_filter_list_cmd);
14243 install_element (BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd);
8b1fb8be
LB
14244 install_element (BGP_ENCAP_NODE, &neighbor_filter_list_cmd);
14245 install_element (BGP_ENCAP_NODE, &no_neighbor_filter_list_cmd);
14246 install_element (BGP_ENCAPV6_NODE, &neighbor_filter_list_cmd);
14247 install_element (BGP_ENCAPV6_NODE, &no_neighbor_filter_list_cmd);
718e3744 14248
14249 /* "neighbor route-map" commands. */
14250 install_element (BGP_NODE, &neighbor_route_map_cmd);
14251 install_element (BGP_NODE, &no_neighbor_route_map_cmd);
14252 install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd);
14253 install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd);
14254 install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd);
14255 install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd);
14256 install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd);
14257 install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd);
25ffbdc1 14258 install_element (BGP_IPV6M_NODE, &neighbor_route_map_cmd);
14259 install_element (BGP_IPV6M_NODE, &no_neighbor_route_map_cmd);
718e3744 14260 install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd);
14261 install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd);
8ecd3266 14262 install_element (BGP_VPNV6_NODE, &neighbor_route_map_cmd);
14263 install_element (BGP_VPNV6_NODE, &no_neighbor_route_map_cmd);
8b1fb8be
LB
14264 install_element (BGP_ENCAP_NODE, &neighbor_route_map_cmd);
14265 install_element (BGP_ENCAP_NODE, &no_neighbor_route_map_cmd);
14266 install_element (BGP_ENCAPV6_NODE, &neighbor_route_map_cmd);
14267 install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_map_cmd);
718e3744 14268
14269 /* "neighbor unsuppress-map" commands. */
14270 install_element (BGP_NODE, &neighbor_unsuppress_map_cmd);
14271 install_element (BGP_NODE, &no_neighbor_unsuppress_map_cmd);
14272 install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd);
14273 install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd);
14274 install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd);
14275 install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd);
14276 install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd);
14277 install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd);
25ffbdc1 14278 install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd);
14279 install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd);
a58545bb 14280 install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd);
bb86c601 14281 install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd);
8ecd3266 14282 install_element (BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd);
bb86c601 14283 install_element (BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd);
8b1fb8be
LB
14284 install_element (BGP_ENCAP_NODE, &neighbor_unsuppress_map_cmd);
14285 install_element (BGP_ENCAP_NODE, &no_neighbor_unsuppress_map_cmd);
14286 install_element (BGP_ENCAPV6_NODE, &neighbor_unsuppress_map_cmd);
14287 install_element (BGP_ENCAPV6_NODE, &no_neighbor_unsuppress_map_cmd);
718e3744 14288
14289 /* "neighbor maximum-prefix" commands. */
14290 install_element (BGP_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 14291 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 14292 install_element (BGP_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 14293 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 14294 install_element (BGP_NODE, &neighbor_maximum_prefix_restart_cmd);
14295 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 14296 install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd);
718e3744 14297 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 14298 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 14299 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 14300 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 14301 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd);
14302 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 14303 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd);
718e3744 14304 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 14305 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 14306 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 14307 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 14308 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd);
14309 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 14310 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd);
718e3744 14311 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 14312 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 14313 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 14314 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 14315 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd);
14316 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 14317 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd);
25ffbdc1 14318 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd);
14319 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd);
14320 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd);
14321 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
14322 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd);
14323 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
14324 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd);
718e3744 14325 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 14326 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 14327 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 14328 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 14329 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd);
14330 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 14331 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd);
8ecd3266 14332 install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd);
14333 install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
14334 install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd);
14335 install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
14336 install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd);
14337 install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
14338 install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd);
718e3744 14339
8b1fb8be
LB
14340 install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_cmd);
14341 install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_cmd);
14342 install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_warning_cmd);
14343 install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
14344 install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_restart_cmd);
14345 install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
14346 install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_cmd);
8b1fb8be
LB
14347
14348 install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_cmd);
14349 install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
14350 install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_warning_cmd);
14351 install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
14352 install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_restart_cmd);
14353 install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
14354 install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_cmd);
8b1fb8be 14355
718e3744 14356 /* "neighbor allowas-in" */
14357 install_element (BGP_NODE, &neighbor_allowas_in_cmd);
718e3744 14358 install_element (BGP_NODE, &no_neighbor_allowas_in_cmd);
14359 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd);
718e3744 14360 install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd);
14361 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd);
718e3744 14362 install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd);
14363 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd);
718e3744 14364 install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd);
25ffbdc1 14365 install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd);
25ffbdc1 14366 install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd);
718e3744 14367 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd);
718e3744 14368 install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd);
8ecd3266 14369 install_element (BGP_VPNV6_NODE, &neighbor_allowas_in_cmd);
8ecd3266 14370 install_element (BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd);
8b1fb8be 14371 install_element (BGP_ENCAP_NODE, &neighbor_allowas_in_cmd);
8b1fb8be
LB
14372 install_element (BGP_ENCAP_NODE, &no_neighbor_allowas_in_cmd);
14373 install_element (BGP_ENCAPV6_NODE, &neighbor_allowas_in_cmd);
8b1fb8be 14374 install_element (BGP_ENCAPV6_NODE, &no_neighbor_allowas_in_cmd);
718e3744 14375
14376 /* address-family commands. */
14377 install_element (BGP_NODE, &address_family_ipv4_cmd);
14378 install_element (BGP_NODE, &address_family_ipv4_safi_cmd);
14379#ifdef HAVE_IPV6
14380 install_element (BGP_NODE, &address_family_ipv6_cmd);
25ffbdc1 14381 install_element (BGP_NODE, &address_family_ipv6_safi_cmd);
718e3744 14382#endif /* HAVE_IPV6 */
14383 install_element (BGP_NODE, &address_family_vpnv4_cmd);
718e3744 14384
8b1fb8be 14385 install_element (BGP_NODE, &address_family_vpnv6_cmd);
8b1fb8be
LB
14386
14387 install_element (BGP_NODE, &address_family_encap_cmd);
8b1fb8be
LB
14388#ifdef HAVE_IPV6
14389 install_element (BGP_NODE, &address_family_encapv6_cmd);
14390#endif
14391
718e3744 14392 /* "exit-address-family" command. */
14393 install_element (BGP_IPV4_NODE, &exit_address_family_cmd);
14394 install_element (BGP_IPV4M_NODE, &exit_address_family_cmd);
14395 install_element (BGP_IPV6_NODE, &exit_address_family_cmd);
25ffbdc1 14396 install_element (BGP_IPV6M_NODE, &exit_address_family_cmd);
718e3744 14397 install_element (BGP_VPNV4_NODE, &exit_address_family_cmd);
8ecd3266 14398 install_element (BGP_VPNV6_NODE, &exit_address_family_cmd);
8b1fb8be
LB
14399 install_element (BGP_ENCAP_NODE, &exit_address_family_cmd);
14400 install_element (BGP_ENCAPV6_NODE, &exit_address_family_cmd);
718e3744 14401
14402 /* "clear ip bgp commands" */
14403 install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd);
718e3744 14404 install_element (ENABLE_NODE, &clear_ip_bgp_as_cmd);
14405 install_element (ENABLE_NODE, &clear_ip_bgp_peer_cmd);
718e3744 14406 install_element (ENABLE_NODE, &clear_ip_bgp_external_cmd);
f412b39a 14407
718e3744 14408
14409 /* "clear ip bgp neighbor soft in" */
14410 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_in_cmd);
718e3744 14411 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_prefix_filter_cmd);
718e3744 14412 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_in_cmd);
718e3744 14413 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_prefix_filter_cmd);
14414 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_in_cmd);
718e3744 14415 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_prefix_filter_cmd);
14416 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_in_cmd);
718e3744 14417 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_prefix_filter_cmd);
14418 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_in_cmd);
718e3744 14419 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_prefix_filter_cmd);
14420 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_in_cmd);
14421 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_in_cmd);
718e3744 14422 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_prefix_filter_cmd);
718e3744 14423 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_in_cmd);
01080f7c 14424 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_ipv4_soft_in_cmd);
718e3744 14425 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd);
14426 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_in_cmd);
01080f7c 14427 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_ipv4_soft_in_cmd);
718e3744 14428 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd);
14429 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_in_cmd);
01080f7c 14430 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_soft_in_cmd);
718e3744 14431 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_prefix_filter_cmd);
14432 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_in_cmd);
01080f7c 14433 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_soft_in_cmd);
718e3744 14434 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_prefix_filter_cmd);
14435 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_in_cmd);
718e3744 14436 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_in_cmd);
718e3744 14437 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_in_cmd);
587ff0fd 14438 install_element (ENABLE_NODE, &clear_ip_bgp_all_encap_soft_in_cmd);
587ff0fd 14439 install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_soft_in_cmd);
587ff0fd 14440 install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_soft_in_cmd);
718e3744 14441 install_element (ENABLE_NODE, &clear_bgp_all_soft_in_cmd);
718e3744 14442 install_element (ENABLE_NODE, &clear_bgp_all_in_prefix_filter_cmd);
14443 install_element (ENABLE_NODE, &clear_bgp_peer_soft_in_cmd);
718e3744 14444 install_element (ENABLE_NODE, &clear_bgp_peer_in_prefix_filter_cmd);
14445 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_in_cmd);
718e3744 14446 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_prefix_filter_cmd);
14447 install_element (ENABLE_NODE, &clear_bgp_external_soft_in_cmd);
718e3744 14448 install_element (ENABLE_NODE, &clear_bgp_external_in_prefix_filter_cmd);
14449 install_element (ENABLE_NODE, &clear_bgp_as_soft_in_cmd);
718e3744 14450 install_element (ENABLE_NODE, &clear_bgp_as_in_prefix_filter_cmd);
718e3744 14451
8ad7271d
DS
14452 /* clear ip bgp prefix */
14453 install_element (ENABLE_NODE, &clear_ip_bgp_prefix_cmd);
14454 install_element (ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd);
01080f7c 14455 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd);
8ad7271d 14456
718e3744 14457 /* "clear ip bgp neighbor soft out" */
14458 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_out_cmd);
718e3744 14459 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_out_cmd);
718e3744 14460 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_out_cmd);
718e3744 14461 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_out_cmd);
718e3744 14462 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_out_cmd);
718e3744 14463 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_out_cmd);
14464 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_out_cmd);
718e3744 14465 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_out_cmd);
01080f7c 14466 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_ipv4_soft_out_cmd);
718e3744 14467 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_out_cmd);
01080f7c 14468 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_ipv4_soft_out_cmd);
718e3744 14469 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_out_cmd);
01080f7c 14470 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_soft_out_cmd);
718e3744 14471 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_out_cmd);
01080f7c 14472 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_soft_out_cmd);
718e3744 14473 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_out_cmd);
718e3744 14474 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_out_cmd);
718e3744 14475 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_out_cmd);
587ff0fd 14476 install_element (ENABLE_NODE, &clear_ip_bgp_all_encap_soft_out_cmd);
587ff0fd 14477 install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_soft_out_cmd);
587ff0fd 14478 install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_soft_out_cmd);
718e3744 14479 install_element (ENABLE_NODE, &clear_bgp_all_soft_out_cmd);
718e3744 14480 install_element (ENABLE_NODE, &clear_bgp_peer_soft_out_cmd);
718e3744 14481 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_out_cmd);
718e3744 14482 install_element (ENABLE_NODE, &clear_bgp_external_soft_out_cmd);
718e3744 14483 install_element (ENABLE_NODE, &clear_bgp_as_soft_out_cmd);
718e3744 14484
14485 /* "clear ip bgp neighbor soft" */
14486 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_cmd);
718e3744 14487 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_cmd);
14488 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_cmd);
14489 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_cmd);
14490 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_cmd);
14491 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_cmd);
14492 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_cmd);
14493 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_cmd);
01080f7c 14494 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_ipv4_soft_cmd);
718e3744 14495 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_cmd);
01080f7c 14496 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_ipv4_soft_cmd);
718e3744 14497 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_cmd);
01080f7c 14498 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_soft_cmd);
718e3744 14499 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_cmd);
01080f7c 14500 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_soft_cmd);
718e3744 14501 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_cmd);
14502 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_cmd);
14503 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_cmd);
587ff0fd
LB
14504 install_element (ENABLE_NODE, &clear_ip_bgp_all_encap_soft_cmd);
14505 install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_soft_cmd);
14506 install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_soft_cmd);
718e3744 14507 install_element (ENABLE_NODE, &clear_bgp_all_soft_cmd);
718e3744 14508 install_element (ENABLE_NODE, &clear_bgp_peer_soft_cmd);
14509 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_cmd);
14510 install_element (ENABLE_NODE, &clear_bgp_external_soft_cmd);
14511 install_element (ENABLE_NODE, &clear_bgp_as_soft_cmd);
718e3744 14512
14513 /* "show ip bgp summary" commands. */
14514 install_element (VIEW_NODE, &show_ip_bgp_summary_cmd);
3f9c7369 14515 install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd);
8386ac43 14516 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_cmd);
f186de26 14517 install_element (VIEW_NODE, &show_ip_bgp_instance_all_updgrps_cmd);
3f9c7369
DS
14518 install_element (VIEW_NODE, &show_bgp_updgrps_cmd);
14519 install_element (VIEW_NODE, &show_bgp_ipv6_updgrps_cmd);
8386ac43 14520 install_element (VIEW_NODE, &show_bgp_instance_ipv6_updgrps_cmd);
f186de26 14521 install_element (VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd);
8fe8a7f6 14522 install_element (VIEW_NODE, &show_ip_bgp_updgrps_s_cmd);
8386ac43 14523 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_s_cmd);
8fe8a7f6
DS
14524 install_element (VIEW_NODE, &show_bgp_updgrps_s_cmd);
14525 install_element (VIEW_NODE, &show_bgp_ipv6_updgrps_s_cmd);
8386ac43 14526 install_element (VIEW_NODE, &show_bgp_instance_ipv6_updgrps_s_cmd);
3f9c7369 14527 install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd);
8386ac43 14528 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd);
3f9c7369 14529 install_element (VIEW_NODE, &show_bgp_updgrps_adj_cmd);
8386ac43 14530 install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd);
3f9c7369 14531 install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd);
8fe8a7f6 14532 install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd);
8386ac43 14533 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd);
8fe8a7f6 14534 install_element (VIEW_NODE, &show_bgp_updgrps_adj_s_cmd);
8386ac43 14535 install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd);
8fe8a7f6 14536 install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd);
718e3744 14537 install_element (VIEW_NODE, &show_ip_bgp_instance_summary_cmd);
f186de26 14538 install_element (VIEW_NODE, &show_ip_bgp_instance_all_summary_cmd);
718e3744 14539 install_element (VIEW_NODE, &show_ip_bgp_ipv4_summary_cmd);
14540 install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
14541 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
14542 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
14543#ifdef HAVE_IPV6
14544 install_element (VIEW_NODE, &show_bgp_summary_cmd);
14545 install_element (VIEW_NODE, &show_bgp_instance_summary_cmd);
f186de26 14546 install_element (VIEW_NODE, &show_bgp_instance_all_summary_cmd);
95cbbd2a 14547 install_element (VIEW_NODE, &show_bgp_ipv6_safi_summary_cmd);
95cbbd2a 14548 install_element (VIEW_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
62687ff1
PJ
14549#endif /* HAVE_IPV6 */
14550 install_element (RESTRICTED_NODE, &show_ip_bgp_summary_cmd);
3f9c7369 14551 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_cmd);
8386ac43 14552 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_updgrps_cmd);
f186de26 14553 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_all_updgrps_cmd);
3f9c7369
DS
14554 install_element (RESTRICTED_NODE, &show_bgp_updgrps_cmd);
14555 install_element (RESTRICTED_NODE, &show_bgp_ipv6_updgrps_cmd);
8386ac43 14556 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_updgrps_cmd);
f186de26 14557 install_element (RESTRICTED_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd);
8fe8a7f6 14558 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_s_cmd);
8386ac43 14559 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_updgrps_s_cmd);
8fe8a7f6
DS
14560 install_element (RESTRICTED_NODE, &show_bgp_updgrps_s_cmd);
14561 install_element (RESTRICTED_NODE, &show_bgp_ipv6_updgrps_s_cmd);
8386ac43 14562 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_updgrps_s_cmd);
3f9c7369 14563 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_adj_cmd);
8386ac43 14564 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_updgrps_adj_cmd);
3f9c7369 14565 install_element (RESTRICTED_NODE, &show_bgp_updgrps_adj_cmd);
8386ac43 14566 install_element (RESTRICTED_NODE, &show_bgp_instance_updgrps_adj_cmd);
3f9c7369 14567 install_element (RESTRICTED_NODE, &show_bgp_updgrps_afi_adj_cmd);
8fe8a7f6 14568 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_adj_s_cmd);
8386ac43 14569 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd);
8fe8a7f6 14570 install_element (RESTRICTED_NODE, &show_bgp_updgrps_adj_s_cmd);
8386ac43 14571 install_element (RESTRICTED_NODE, &show_bgp_instance_updgrps_adj_s_cmd);
8fe8a7f6 14572 install_element (RESTRICTED_NODE, &show_bgp_updgrps_afi_adj_s_cmd);
62687ff1 14573 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_summary_cmd);
f186de26 14574 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_all_summary_cmd);
62687ff1
PJ
14575 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_summary_cmd);
14576 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
14577 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
14578 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
14579#ifdef HAVE_IPV6
14580 install_element (RESTRICTED_NODE, &show_bgp_summary_cmd);
14581 install_element (RESTRICTED_NODE, &show_bgp_instance_summary_cmd);
f186de26 14582 install_element (RESTRICTED_NODE, &show_bgp_instance_all_summary_cmd);
95cbbd2a 14583 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_summary_cmd);
95cbbd2a 14584 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
718e3744 14585#endif /* HAVE_IPV6 */
14586 install_element (ENABLE_NODE, &show_ip_bgp_summary_cmd);
3f9c7369 14587 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_cmd);
8386ac43 14588 install_element (ENABLE_NODE, &show_ip_bgp_instance_updgrps_cmd);
f186de26 14589 install_element (ENABLE_NODE, &show_ip_bgp_instance_all_updgrps_cmd);
3f9c7369
DS
14590 install_element (ENABLE_NODE, &show_bgp_updgrps_cmd);
14591 install_element (ENABLE_NODE, &show_bgp_ipv6_updgrps_cmd);
8386ac43 14592 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_updgrps_cmd);
f186de26 14593 install_element (ENABLE_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd);
8fe8a7f6 14594 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_s_cmd);
8386ac43 14595 install_element (ENABLE_NODE, &show_ip_bgp_instance_updgrps_s_cmd);
8fe8a7f6
DS
14596 install_element (ENABLE_NODE, &show_bgp_updgrps_s_cmd);
14597 install_element (ENABLE_NODE, &show_bgp_ipv6_updgrps_s_cmd);
8386ac43 14598 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_updgrps_s_cmd);
3f9c7369 14599 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_adj_cmd);
8386ac43 14600 install_element (ENABLE_NODE, &show_ip_bgp_instance_updgrps_adj_cmd);
3f9c7369 14601 install_element (ENABLE_NODE, &show_bgp_updgrps_adj_cmd);
8386ac43 14602 install_element (ENABLE_NODE, &show_bgp_instance_updgrps_adj_cmd);
3f9c7369 14603 install_element (ENABLE_NODE, &show_bgp_updgrps_afi_adj_cmd);
8fe8a7f6 14604 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_adj_s_cmd);
8386ac43 14605 install_element (ENABLE_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd);
8fe8a7f6 14606 install_element (ENABLE_NODE, &show_bgp_updgrps_adj_s_cmd);
8386ac43 14607 install_element (ENABLE_NODE, &show_bgp_instance_updgrps_adj_s_cmd);
8fe8a7f6 14608 install_element (ENABLE_NODE, &show_bgp_updgrps_afi_adj_s_cmd);
718e3744 14609 install_element (ENABLE_NODE, &show_ip_bgp_instance_summary_cmd);
f186de26 14610 install_element (ENABLE_NODE, &show_ip_bgp_instance_all_summary_cmd);
718e3744 14611 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_summary_cmd);
14612 install_element (ENABLE_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
14613 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
14614 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
14615#ifdef HAVE_IPV6
14616 install_element (ENABLE_NODE, &show_bgp_summary_cmd);
14617 install_element (ENABLE_NODE, &show_bgp_instance_summary_cmd);
f186de26 14618 install_element (ENABLE_NODE, &show_bgp_instance_all_summary_cmd);
95cbbd2a 14619 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_summary_cmd);
95cbbd2a 14620 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
718e3744 14621#endif /* HAVE_IPV6 */
14622
e3e29b32
LB
14623 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_summary_cmd);
14624 install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_summary_cmd);
14625
14626 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_summary_cmd);
14627 install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_summary_cmd);
14628
718e3744 14629 /* "show ip bgp neighbors" commands. */
14630 install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd);
718e3744 14631 install_element (VIEW_NODE, &show_ip_bgp_neighbors_peer_cmd);
718e3744 14632 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_cmd);
f186de26 14633 install_element (VIEW_NODE, &show_ip_bgp_instance_all_neighbors_cmd);
718e3744 14634 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
62687ff1 14635 install_element (RESTRICTED_NODE, &show_ip_bgp_neighbors_peer_cmd);
62687ff1 14636 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
718e3744 14637 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_cmd);
718e3744 14638 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_peer_cmd);
718e3744 14639 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_cmd);
f186de26 14640 install_element (ENABLE_NODE, &show_ip_bgp_instance_all_neighbors_cmd);
718e3744 14641 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
14642
14643#ifdef HAVE_IPV6
718e3744 14644
14645 /* Old commands. */
14646 install_element (VIEW_NODE, &show_ipv6_bgp_summary_cmd);
14647 install_element (VIEW_NODE, &show_ipv6_mbgp_summary_cmd);
14648 install_element (ENABLE_NODE, &show_ipv6_bgp_summary_cmd);
14649 install_element (ENABLE_NODE, &show_ipv6_mbgp_summary_cmd);
14650#endif /* HAVE_IPV6 */
fee0f4c6 14651
f14e6fdb
DS
14652 /* "show ip bgp peer-group" commands. */
14653 install_element (VIEW_NODE, &show_ip_bgp_peer_groups_cmd);
14654 install_element (VIEW_NODE, &show_ip_bgp_instance_peer_groups_cmd);
14655 install_element (VIEW_NODE, &show_ip_bgp_peer_group_cmd);
14656 install_element (VIEW_NODE, &show_ip_bgp_instance_peer_group_cmd);
14657 install_element (ENABLE_NODE, &show_ip_bgp_peer_groups_cmd);
14658 install_element (ENABLE_NODE, &show_ip_bgp_instance_peer_groups_cmd);
14659 install_element (ENABLE_NODE, &show_ip_bgp_peer_group_cmd);
14660 install_element (ENABLE_NODE, &show_ip_bgp_instance_peer_group_cmd);
14661
718e3744 14662 /* "show ip bgp paths" commands. */
14663 install_element (VIEW_NODE, &show_ip_bgp_paths_cmd);
14664 install_element (VIEW_NODE, &show_ip_bgp_ipv4_paths_cmd);
14665 install_element (ENABLE_NODE, &show_ip_bgp_paths_cmd);
14666 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_paths_cmd);
14667
14668 /* "show ip bgp community" commands. */
14669 install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd);
14670 install_element (ENABLE_NODE, &show_ip_bgp_community_info_cmd);
14671
14672 /* "show ip bgp attribute-info" commands. */
14673 install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd);
14674 install_element (ENABLE_NODE, &show_ip_bgp_attr_info_cmd);
14675
14676 /* "redistribute" commands. */
14677 install_element (BGP_NODE, &bgp_redistribute_ipv4_cmd);
14678 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_cmd);
14679 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_cmd);
718e3744 14680 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_cmd);
718e3744 14681 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd);
14682 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd);
7c8ff89e
DS
14683 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_cmd);
14684 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_cmd);
14685 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd);
7c8ff89e 14686 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd);
7c8ff89e 14687 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
7c8ff89e 14688 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
919e0666
DW
14689 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd);
14690 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd);
14691 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd);
919e0666 14692 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd);
919e0666
DW
14693 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd);
14694 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd);
919e0666
DW
14695 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd);
14696 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd);
14697 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd);
919e0666 14698 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd);
919e0666 14699 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
919e0666 14700 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
718e3744 14701#ifdef HAVE_IPV6
14702 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd);
14703 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd);
14704 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd);
718e3744 14705 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd);
718e3744 14706 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd);
14707 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd);
718e3744 14708#endif /* HAVE_IPV6 */
14709
fa411a21
NH
14710 /* ttl_security commands */
14711 install_element (BGP_NODE, &neighbor_ttl_security_cmd);
14712 install_element (BGP_NODE, &no_neighbor_ttl_security_cmd);
14713
4bf6a362
PJ
14714 /* "show bgp memory" commands. */
14715 install_element (VIEW_NODE, &show_bgp_memory_cmd);
62687ff1 14716 install_element (RESTRICTED_NODE, &show_bgp_memory_cmd);
4bf6a362
PJ
14717 install_element (ENABLE_NODE, &show_bgp_memory_cmd);
14718
e0081f70
ML
14719 /* "show bgp views" commands. */
14720 install_element (VIEW_NODE, &show_bgp_views_cmd);
14721 install_element (RESTRICTED_NODE, &show_bgp_views_cmd);
14722 install_element (ENABLE_NODE, &show_bgp_views_cmd);
14723
8386ac43 14724 /* "show bgp vrfs" commands. */
14725 install_element (VIEW_NODE, &show_bgp_vrfs_cmd);
14726 install_element (RESTRICTED_NODE, &show_bgp_vrfs_cmd);
14727 install_element (ENABLE_NODE, &show_bgp_vrfs_cmd);
14728
718e3744 14729 /* Community-list. */
14730 community_list_vty ();
14731}
6b0655a2 14732
718e3744 14733#include "memory.h"
14734#include "bgp_regex.h"
14735#include "bgp_clist.h"
14736#include "bgp_ecommunity.h"
14737
14738/* VTY functions. */
14739
14740/* Direction value to string conversion. */
94f2b392 14741static const char *
718e3744 14742community_direct_str (int direct)
14743{
14744 switch (direct)
14745 {
14746 case COMMUNITY_DENY:
14747 return "deny";
718e3744 14748 case COMMUNITY_PERMIT:
14749 return "permit";
718e3744 14750 default:
14751 return "unknown";
718e3744 14752 }
14753}
14754
14755/* Display error string. */
94f2b392 14756static void
718e3744 14757community_list_perror (struct vty *vty, int ret)
14758{
14759 switch (ret)
14760 {
14761 case COMMUNITY_LIST_ERR_CANT_FIND_LIST:
b729294c 14762 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
718e3744 14763 break;
14764 case COMMUNITY_LIST_ERR_MALFORMED_VAL:
14765 vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE);
14766 break;
14767 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT:
14768 vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE);
14769 break;
14770 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT:
14771 vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE);
14772 break;
14773 }
14774}
14775
14776/* VTY interface for community_set() function. */
94f2b392 14777static int
fd79ac91 14778community_list_set_vty (struct vty *vty, int argc, const char **argv,
14779 int style, int reject_all_digit_name)
718e3744 14780{
14781 int ret;
14782 int direct;
14783 char *str;
14784
14785 /* Check the list type. */
14786 if (strncmp (argv[1], "p", 1) == 0)
14787 direct = COMMUNITY_PERMIT;
14788 else if (strncmp (argv[1], "d", 1) == 0)
14789 direct = COMMUNITY_DENY;
14790 else
14791 {
14792 vty_out (vty, "%% Matching condition must be permit or deny%s",
14793 VTY_NEWLINE);
14794 return CMD_WARNING;
14795 }
14796
14797 /* All digit name check. */
14798 if (reject_all_digit_name && all_digit (argv[0]))
14799 {
14800 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
14801 return CMD_WARNING;
14802 }
14803
14804 /* Concat community string argument. */
14805 if (argc > 1)
14806 str = argv_concat (argv, argc, 2);
14807 else
14808 str = NULL;
14809
14810 /* When community_list_set() return nevetive value, it means
14811 malformed community string. */
14812 ret = community_list_set (bgp_clist, argv[0], str, direct, style);
14813
14814 /* Free temporary community list string allocated by
14815 argv_concat(). */
14816 if (str)
14817 XFREE (MTYPE_TMP, str);
14818
14819 if (ret < 0)
14820 {
14821 /* Display error string. */
14822 community_list_perror (vty, ret);
14823 return CMD_WARNING;
14824 }
14825
14826 return CMD_SUCCESS;
14827}
14828
718e3744 14829/* Communiyt-list entry delete. */
94f2b392 14830static int
fee6e4e4 14831community_list_unset_vty (struct vty *vty, int argc, const char **argv,
813d4307 14832 int style, int delete_all)
718e3744 14833{
14834 int ret;
fee6e4e4 14835 int direct = 0;
14836 char *str = NULL;
718e3744 14837
fee6e4e4 14838 if (argc > 1)
718e3744 14839 {
fee6e4e4 14840 /* Check the list direct. */
14841 if (strncmp (argv[1], "p", 1) == 0)
14842 direct = COMMUNITY_PERMIT;
14843 else if (strncmp (argv[1], "d", 1) == 0)
14844 direct = COMMUNITY_DENY;
14845 else
14846 {
14847 vty_out (vty, "%% Matching condition must be permit or deny%s",
14848 VTY_NEWLINE);
14849 return CMD_WARNING;
14850 }
718e3744 14851
fee6e4e4 14852 /* Concat community string argument. */
14853 str = argv_concat (argv, argc, 2);
14854 }
718e3744 14855
14856 /* Unset community list. */
813d4307 14857 ret = community_list_unset (bgp_clist, argv[0], str, direct, style, delete_all);
718e3744 14858
14859 /* Free temporary community list string allocated by
14860 argv_concat(). */
fee6e4e4 14861 if (str)
14862 XFREE (MTYPE_TMP, str);
718e3744 14863
14864 if (ret < 0)
14865 {
14866 community_list_perror (vty, ret);
14867 return CMD_WARNING;
14868 }
14869
14870 return CMD_SUCCESS;
14871}
14872
14873/* "community-list" keyword help string. */
14874#define COMMUNITY_LIST_STR "Add a community list entry\n"
718e3744 14875
f412b39a
DW
14876/*
14877 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
14878 * "ip community-list <1-99> (deny|permit)",
14879 * IP_STR
14880 * COMMUNITY_LIST_STR
14881 * "Community list number (standard)\n"
14882 * "Specify community to reject\n"
14883 * "Specify community to accept\n"
14884 *
14885 */
718e3744 14886DEFUN (ip_community_list_standard,
14887 ip_community_list_standard_cmd,
6147e2c6 14888 "ip community-list (1-99) <deny|permit> .AA:NN",
718e3744 14889 IP_STR
14890 COMMUNITY_LIST_STR
14891 "Community list number (standard)\n"
14892 "Specify community to reject\n"
14893 "Specify community to accept\n"
14894 COMMUNITY_VAL_STR)
14895{
14896 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
14897}
14898
718e3744 14899
14900DEFUN (ip_community_list_expanded,
14901 ip_community_list_expanded_cmd,
6147e2c6 14902 "ip community-list (100-500) <deny|permit> .LINE",
718e3744 14903 IP_STR
14904 COMMUNITY_LIST_STR
14905 "Community list number (expanded)\n"
14906 "Specify community to reject\n"
14907 "Specify community to accept\n"
14908 "An ordered list as a regular-expression\n")
14909{
14910 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
14911}
14912
f412b39a
DW
14913/*
14914 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
14915 * "ip community-list standard WORD (deny|permit)",
14916 * IP_STR
14917 * COMMUNITY_LIST_STR
14918 * "Add a standard community-list entry\n"
14919 * "Community list name\n"
14920 * "Specify community to reject\n"
14921 * "Specify community to accept\n"
14922 *
14923 */
718e3744 14924DEFUN (ip_community_list_name_standard,
14925 ip_community_list_name_standard_cmd,
6147e2c6 14926 "ip community-list standard WORD <deny|permit> .AA:NN",
718e3744 14927 IP_STR
14928 COMMUNITY_LIST_STR
14929 "Add a standard community-list entry\n"
14930 "Community list name\n"
14931 "Specify community to reject\n"
14932 "Specify community to accept\n"
14933 COMMUNITY_VAL_STR)
14934{
14935 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
14936}
14937
718e3744 14938
14939DEFUN (ip_community_list_name_expanded,
14940 ip_community_list_name_expanded_cmd,
6147e2c6 14941 "ip community-list expanded WORD <deny|permit> .LINE",
718e3744 14942 IP_STR
14943 COMMUNITY_LIST_STR
14944 "Add an expanded community-list entry\n"
14945 "Community list name\n"
14946 "Specify community to reject\n"
14947 "Specify community to accept\n"
14948 "An ordered list as a regular-expression\n")
14949{
14950 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
14951}
14952
fee6e4e4 14953DEFUN (no_ip_community_list_standard_all,
14954 no_ip_community_list_standard_all_cmd,
6147e2c6 14955 "no ip community-list (1-99)",
fee6e4e4 14956 NO_STR
14957 IP_STR
14958 COMMUNITY_LIST_STR
14959 "Community list number (standard)\n")
14960{
813d4307
DW
14961 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
14962}
14963
14964DEFUN (no_ip_community_list_standard_direction,
14965 no_ip_community_list_standard_direction_cmd,
6147e2c6 14966 "no ip community-list (1-99) <deny|permit>",
813d4307
DW
14967 NO_STR
14968 IP_STR
14969 COMMUNITY_LIST_STR
14970 "Community list number (standard)\n"
14971 "Specify community to reject\n"
14972 "Specify community to accept\n")
14973{
14974 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
fee6e4e4 14975}
14976
813d4307 14977
fee6e4e4 14978DEFUN (no_ip_community_list_expanded_all,
14979 no_ip_community_list_expanded_all_cmd,
6147e2c6 14980 "no ip community-list (100-500)",
718e3744 14981 NO_STR
14982 IP_STR
14983 COMMUNITY_LIST_STR
718e3744 14984 "Community list number (expanded)\n")
14985{
813d4307 14986 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
718e3744 14987}
14988
fee6e4e4 14989DEFUN (no_ip_community_list_name_standard_all,
14990 no_ip_community_list_name_standard_all_cmd,
14991 "no ip community-list standard WORD",
718e3744 14992 NO_STR
14993 IP_STR
14994 COMMUNITY_LIST_STR
14995 "Add a standard community-list entry\n"
718e3744 14996 "Community list name\n")
14997{
813d4307 14998 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
718e3744 14999}
15000
fee6e4e4 15001DEFUN (no_ip_community_list_name_expanded_all,
15002 no_ip_community_list_name_expanded_all_cmd,
15003 "no ip community-list expanded WORD",
718e3744 15004 NO_STR
15005 IP_STR
15006 COMMUNITY_LIST_STR
fee6e4e4 15007 "Add an expanded community-list entry\n"
15008 "Community list name\n")
718e3744 15009{
813d4307 15010 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
718e3744 15011}
15012
15013DEFUN (no_ip_community_list_standard,
15014 no_ip_community_list_standard_cmd,
6147e2c6 15015 "no ip community-list (1-99) <deny|permit> .AA:NN",
718e3744 15016 NO_STR
15017 IP_STR
15018 COMMUNITY_LIST_STR
15019 "Community list number (standard)\n"
15020 "Specify community to reject\n"
15021 "Specify community to accept\n"
15022 COMMUNITY_VAL_STR)
15023{
813d4307 15024 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
718e3744 15025}
15026
15027DEFUN (no_ip_community_list_expanded,
15028 no_ip_community_list_expanded_cmd,
6147e2c6 15029 "no ip community-list (100-500) <deny|permit> .LINE",
718e3744 15030 NO_STR
15031 IP_STR
15032 COMMUNITY_LIST_STR
15033 "Community list number (expanded)\n"
15034 "Specify community to reject\n"
15035 "Specify community to accept\n"
15036 "An ordered list as a regular-expression\n")
15037{
813d4307 15038 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
718e3744 15039}
15040
15041DEFUN (no_ip_community_list_name_standard,
15042 no_ip_community_list_name_standard_cmd,
6147e2c6 15043 "no ip community-list standard WORD <deny|permit> .AA:NN",
718e3744 15044 NO_STR
15045 IP_STR
15046 COMMUNITY_LIST_STR
15047 "Specify a standard community-list\n"
15048 "Community list name\n"
15049 "Specify community to reject\n"
15050 "Specify community to accept\n"
15051 COMMUNITY_VAL_STR)
15052{
813d4307
DW
15053 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
15054}
15055
15056DEFUN (no_ip_community_list_name_standard_brief,
15057 no_ip_community_list_name_standard_brief_cmd,
6147e2c6 15058 "no ip community-list standard WORD <deny|permit>",
813d4307
DW
15059 NO_STR
15060 IP_STR
15061 COMMUNITY_LIST_STR
15062 "Specify a standard community-list\n"
15063 "Community list name\n"
15064 "Specify community to reject\n"
15065 "Specify community to accept\n")
15066{
15067 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
718e3744 15068}
15069
15070DEFUN (no_ip_community_list_name_expanded,
15071 no_ip_community_list_name_expanded_cmd,
6147e2c6 15072 "no ip community-list expanded WORD <deny|permit> .LINE",
718e3744 15073 NO_STR
15074 IP_STR
15075 COMMUNITY_LIST_STR
15076 "Specify an expanded community-list\n"
15077 "Community list name\n"
15078 "Specify community to reject\n"
15079 "Specify community to accept\n"
15080 "An ordered list as a regular-expression\n")
15081{
813d4307 15082 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
718e3744 15083}
15084
94f2b392 15085static void
718e3744 15086community_list_show (struct vty *vty, struct community_list *list)
15087{
15088 struct community_entry *entry;
15089
15090 for (entry = list->head; entry; entry = entry->next)
15091 {
15092 if (entry == list->head)
15093 {
15094 if (all_digit (list->name))
15095 vty_out (vty, "Community %s list %s%s",
15096 entry->style == COMMUNITY_LIST_STANDARD ?
15097 "standard" : "(expanded) access",
15098 list->name, VTY_NEWLINE);
15099 else
15100 vty_out (vty, "Named Community %s list %s%s",
15101 entry->style == COMMUNITY_LIST_STANDARD ?
15102 "standard" : "expanded",
15103 list->name, VTY_NEWLINE);
15104 }
15105 if (entry->any)
15106 vty_out (vty, " %s%s",
15107 community_direct_str (entry->direct), VTY_NEWLINE);
15108 else
15109 vty_out (vty, " %s %s%s",
15110 community_direct_str (entry->direct),
15111 entry->style == COMMUNITY_LIST_STANDARD
15112 ? community_str (entry->u.com) : entry->config,
15113 VTY_NEWLINE);
15114 }
15115}
15116
15117DEFUN (show_ip_community_list,
15118 show_ip_community_list_cmd,
15119 "show ip community-list",
15120 SHOW_STR
15121 IP_STR
15122 "List community-list\n")
15123{
15124 struct community_list *list;
15125 struct community_list_master *cm;
15126
fee6e4e4 15127 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
718e3744 15128 if (! cm)
15129 return CMD_SUCCESS;
15130
15131 for (list = cm->num.head; list; list = list->next)
15132 community_list_show (vty, list);
15133
15134 for (list = cm->str.head; list; list = list->next)
15135 community_list_show (vty, list);
15136
15137 return CMD_SUCCESS;
15138}
15139
15140DEFUN (show_ip_community_list_arg,
15141 show_ip_community_list_arg_cmd,
6147e2c6 15142 "show ip community-list <(1-500)|WORD>",
718e3744 15143 SHOW_STR
15144 IP_STR
15145 "List community-list\n"
15146 "Community-list number\n"
15147 "Community-list name\n")
15148{
c500ae40 15149 int idx_comm_list = 3;
718e3744 15150 struct community_list *list;
15151
c500ae40 15152 list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, COMMUNITY_LIST_MASTER);
718e3744 15153 if (! list)
15154 {
b729294c 15155 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
718e3744 15156 return CMD_WARNING;
15157 }
15158
15159 community_list_show (vty, list);
15160
15161 return CMD_SUCCESS;
15162}
6b0655a2 15163
94f2b392 15164static int
afec25d9 15165extcommunity_list_set_vty (struct vty *vty, int argc, struct cmd_token **argv,
fd79ac91 15166 int style, int reject_all_digit_name)
718e3744 15167{
15168 int ret;
15169 int direct;
15170 char *str;
15171
15172 /* Check the list type. */
15173 if (strncmp (argv[1], "p", 1) == 0)
15174 direct = COMMUNITY_PERMIT;
15175 else if (strncmp (argv[1], "d", 1) == 0)
15176 direct = COMMUNITY_DENY;
15177 else
15178 {
15179 vty_out (vty, "%% Matching condition must be permit or deny%s",
15180 VTY_NEWLINE);
15181 return CMD_WARNING;
15182 }
15183
15184 /* All digit name check. */
15185 if (reject_all_digit_name && all_digit (argv[0]))
15186 {
15187 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
15188 return CMD_WARNING;
15189 }
15190
15191 /* Concat community string argument. */
15192 if (argc > 1)
15193 str = argv_concat (argv, argc, 2);
15194 else
15195 str = NULL;
15196
15197 ret = extcommunity_list_set (bgp_clist, argv[0], str, direct, style);
15198
15199 /* Free temporary community list string allocated by
15200 argv_concat(). */
15201 if (str)
15202 XFREE (MTYPE_TMP, str);
15203
15204 if (ret < 0)
15205 {
15206 community_list_perror (vty, ret);
15207 return CMD_WARNING;
15208 }
15209 return CMD_SUCCESS;
15210}
15211
94f2b392 15212static int
afec25d9 15213extcommunity_list_unset_vty (struct vty *vty, int argc, struct cmd_token **argv,
813d4307 15214 int style, int delete_all)
718e3744 15215{
15216 int ret;
fee6e4e4 15217 int direct = 0;
15218 char *str = NULL;
718e3744 15219
fee6e4e4 15220 if (argc > 1)
718e3744 15221 {
fee6e4e4 15222 /* Check the list direct. */
15223 if (strncmp (argv[1], "p", 1) == 0)
15224 direct = COMMUNITY_PERMIT;
15225 else if (strncmp (argv[1], "d", 1) == 0)
15226 direct = COMMUNITY_DENY;
15227 else
15228 {
15229 vty_out (vty, "%% Matching condition must be permit or deny%s",
15230 VTY_NEWLINE);
15231 return CMD_WARNING;
15232 }
718e3744 15233
fee6e4e4 15234 /* Concat community string argument. */
15235 str = argv_concat (argv, argc, 2);
718e3744 15236 }
15237
718e3744 15238 /* Unset community list. */
813d4307 15239 ret = extcommunity_list_unset (bgp_clist, argv[0], str, direct, style, delete_all);
718e3744 15240
15241 /* Free temporary community list string allocated by
15242 argv_concat(). */
fee6e4e4 15243 if (str)
15244 XFREE (MTYPE_TMP, str);
718e3744 15245
15246 if (ret < 0)
15247 {
15248 community_list_perror (vty, ret);
15249 return CMD_WARNING;
15250 }
15251
15252 return CMD_SUCCESS;
15253}
15254
15255/* "extcommunity-list" keyword help string. */
15256#define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
15257#define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
15258
f412b39a
DW
15259/*
15260 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
15261 * "ip extcommunity-list <1-99> (deny|permit)",
15262 * IP_STR
15263 * EXTCOMMUNITY_LIST_STR
15264 * "Extended Community list number (standard)\n"
15265 * "Specify community to reject\n"
15266 * "Specify community to accept\n"
15267 *
15268 */
718e3744 15269DEFUN (ip_extcommunity_list_standard,
15270 ip_extcommunity_list_standard_cmd,
6147e2c6 15271 "ip extcommunity-list (1-99) <deny|permit> .AA:NN",
718e3744 15272 IP_STR
15273 EXTCOMMUNITY_LIST_STR
15274 "Extended Community list number (standard)\n"
15275 "Specify community to reject\n"
15276 "Specify community to accept\n"
15277 EXTCOMMUNITY_VAL_STR)
15278{
15279 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
15280}
15281
718e3744 15282
15283DEFUN (ip_extcommunity_list_expanded,
15284 ip_extcommunity_list_expanded_cmd,
6147e2c6 15285 "ip extcommunity-list (100-500) <deny|permit> .LINE",
718e3744 15286 IP_STR
15287 EXTCOMMUNITY_LIST_STR
15288 "Extended Community list number (expanded)\n"
15289 "Specify community to reject\n"
15290 "Specify community to accept\n"
15291 "An ordered list as a regular-expression\n")
15292{
15293 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
15294}
15295
f412b39a
DW
15296/*
15297 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
15298 * "ip extcommunity-list standard WORD (deny|permit)",
15299 * IP_STR
15300 * EXTCOMMUNITY_LIST_STR
15301 * "Specify standard extcommunity-list\n"
15302 * "Extended Community list name\n"
15303 * "Specify community to reject\n"
15304 * "Specify community to accept\n"
15305 *
15306 */
718e3744 15307DEFUN (ip_extcommunity_list_name_standard,
15308 ip_extcommunity_list_name_standard_cmd,
6147e2c6 15309 "ip extcommunity-list standard WORD <deny|permit> .AA:NN",
718e3744 15310 IP_STR
15311 EXTCOMMUNITY_LIST_STR
15312 "Specify standard extcommunity-list\n"
15313 "Extended Community list name\n"
15314 "Specify community to reject\n"
15315 "Specify community to accept\n"
15316 EXTCOMMUNITY_VAL_STR)
15317{
15318 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
15319}
15320
718e3744 15321
15322DEFUN (ip_extcommunity_list_name_expanded,
15323 ip_extcommunity_list_name_expanded_cmd,
6147e2c6 15324 "ip extcommunity-list expanded WORD <deny|permit> .LINE",
718e3744 15325 IP_STR
15326 EXTCOMMUNITY_LIST_STR
15327 "Specify expanded extcommunity-list\n"
15328 "Extended Community list name\n"
15329 "Specify community to reject\n"
15330 "Specify community to accept\n"
15331 "An ordered list as a regular-expression\n")
15332{
15333 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
15334}
15335
fee6e4e4 15336DEFUN (no_ip_extcommunity_list_standard_all,
15337 no_ip_extcommunity_list_standard_all_cmd,
6147e2c6 15338 "no ip extcommunity-list (1-99)",
fee6e4e4 15339 NO_STR
15340 IP_STR
15341 EXTCOMMUNITY_LIST_STR
15342 "Extended Community list number (standard)\n")
15343{
813d4307
DW
15344 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
15345}
15346
15347DEFUN (no_ip_extcommunity_list_standard_direction,
15348 no_ip_extcommunity_list_standard_direction_cmd,
6147e2c6 15349 "no ip extcommunity-list (1-99) <deny|permit>",
813d4307
DW
15350 NO_STR
15351 IP_STR
15352 EXTCOMMUNITY_LIST_STR
15353 "Extended Community list number (standard)\n"
15354 "Specify community to reject\n"
15355 "Specify community to accept\n")
15356{
15357 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
fee6e4e4 15358}
15359
15360DEFUN (no_ip_extcommunity_list_expanded_all,
15361 no_ip_extcommunity_list_expanded_all_cmd,
6147e2c6 15362 "no ip extcommunity-list (100-500)",
718e3744 15363 NO_STR
15364 IP_STR
15365 EXTCOMMUNITY_LIST_STR
718e3744 15366 "Extended Community list number (expanded)\n")
15367{
813d4307 15368 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
718e3744 15369}
15370
fee6e4e4 15371DEFUN (no_ip_extcommunity_list_name_standard_all,
15372 no_ip_extcommunity_list_name_standard_all_cmd,
15373 "no ip extcommunity-list standard WORD",
718e3744 15374 NO_STR
15375 IP_STR
15376 EXTCOMMUNITY_LIST_STR
15377 "Specify standard extcommunity-list\n"
fee6e4e4 15378 "Extended Community list name\n")
15379{
813d4307 15380 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
fee6e4e4 15381}
15382
15383DEFUN (no_ip_extcommunity_list_name_expanded_all,
15384 no_ip_extcommunity_list_name_expanded_all_cmd,
15385 "no ip extcommunity-list expanded WORD",
15386 NO_STR
15387 IP_STR
15388 EXTCOMMUNITY_LIST_STR
718e3744 15389 "Specify expanded extcommunity-list\n"
15390 "Extended Community list name\n")
15391{
813d4307 15392 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
718e3744 15393}
15394
15395DEFUN (no_ip_extcommunity_list_standard,
15396 no_ip_extcommunity_list_standard_cmd,
6147e2c6 15397 "no ip extcommunity-list (1-99) <deny|permit> .AA:NN",
718e3744 15398 NO_STR
15399 IP_STR
15400 EXTCOMMUNITY_LIST_STR
15401 "Extended Community list number (standard)\n"
15402 "Specify community to reject\n"
15403 "Specify community to accept\n"
15404 EXTCOMMUNITY_VAL_STR)
15405{
813d4307 15406 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
718e3744 15407}
15408
15409DEFUN (no_ip_extcommunity_list_expanded,
15410 no_ip_extcommunity_list_expanded_cmd,
6147e2c6 15411 "no ip extcommunity-list (100-500) <deny|permit> .LINE",
718e3744 15412 NO_STR
15413 IP_STR
15414 EXTCOMMUNITY_LIST_STR
15415 "Extended Community list number (expanded)\n"
15416 "Specify community to reject\n"
15417 "Specify community to accept\n"
15418 "An ordered list as a regular-expression\n")
15419{
813d4307 15420 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
718e3744 15421}
15422
15423DEFUN (no_ip_extcommunity_list_name_standard,
15424 no_ip_extcommunity_list_name_standard_cmd,
6147e2c6 15425 "no ip extcommunity-list standard WORD <deny|permit> .AA:NN",
718e3744 15426 NO_STR
15427 IP_STR
15428 EXTCOMMUNITY_LIST_STR
15429 "Specify standard extcommunity-list\n"
15430 "Extended Community list name\n"
15431 "Specify community to reject\n"
15432 "Specify community to accept\n"
15433 EXTCOMMUNITY_VAL_STR)
15434{
813d4307
DW
15435 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
15436}
15437
15438DEFUN (no_ip_extcommunity_list_name_standard_brief,
15439 no_ip_extcommunity_list_name_standard_brief_cmd,
6147e2c6 15440 "no ip extcommunity-list standard WORD <deny|permit>",
813d4307
DW
15441 NO_STR
15442 IP_STR
15443 EXTCOMMUNITY_LIST_STR
15444 "Specify standard extcommunity-list\n"
15445 "Extended Community list name\n"
15446 "Specify community to reject\n"
15447 "Specify community to accept\n")
15448{
15449 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
718e3744 15450}
15451
15452DEFUN (no_ip_extcommunity_list_name_expanded,
15453 no_ip_extcommunity_list_name_expanded_cmd,
6147e2c6 15454 "no ip extcommunity-list expanded WORD <deny|permit> .LINE",
718e3744 15455 NO_STR
15456 IP_STR
15457 EXTCOMMUNITY_LIST_STR
15458 "Specify expanded extcommunity-list\n"
15459 "Community list name\n"
15460 "Specify community to reject\n"
15461 "Specify community to accept\n"
15462 "An ordered list as a regular-expression\n")
15463{
813d4307 15464 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
718e3744 15465}
15466
94f2b392 15467static void
718e3744 15468extcommunity_list_show (struct vty *vty, struct community_list *list)
15469{
15470 struct community_entry *entry;
15471
15472 for (entry = list->head; entry; entry = entry->next)
15473 {
15474 if (entry == list->head)
15475 {
15476 if (all_digit (list->name))
15477 vty_out (vty, "Extended community %s list %s%s",
15478 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
15479 "standard" : "(expanded) access",
15480 list->name, VTY_NEWLINE);
15481 else
15482 vty_out (vty, "Named extended community %s list %s%s",
15483 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
15484 "standard" : "expanded",
15485 list->name, VTY_NEWLINE);
15486 }
15487 if (entry->any)
15488 vty_out (vty, " %s%s",
15489 community_direct_str (entry->direct), VTY_NEWLINE);
15490 else
15491 vty_out (vty, " %s %s%s",
15492 community_direct_str (entry->direct),
15493 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
15494 entry->u.ecom->str : entry->config,
15495 VTY_NEWLINE);
15496 }
15497}
15498
15499DEFUN (show_ip_extcommunity_list,
15500 show_ip_extcommunity_list_cmd,
15501 "show ip extcommunity-list",
15502 SHOW_STR
15503 IP_STR
15504 "List extended-community list\n")
15505{
15506 struct community_list *list;
15507 struct community_list_master *cm;
15508
fee6e4e4 15509 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
718e3744 15510 if (! cm)
15511 return CMD_SUCCESS;
15512
15513 for (list = cm->num.head; list; list = list->next)
15514 extcommunity_list_show (vty, list);
15515
15516 for (list = cm->str.head; list; list = list->next)
15517 extcommunity_list_show (vty, list);
15518
15519 return CMD_SUCCESS;
15520}
15521
15522DEFUN (show_ip_extcommunity_list_arg,
15523 show_ip_extcommunity_list_arg_cmd,
6147e2c6 15524 "show ip extcommunity-list <(1-500)|WORD>",
718e3744 15525 SHOW_STR
15526 IP_STR
15527 "List extended-community list\n"
15528 "Extcommunity-list number\n"
15529 "Extcommunity-list name\n")
15530{
c500ae40 15531 int idx_comm_list = 3;
718e3744 15532 struct community_list *list;
15533
c500ae40 15534 list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, EXTCOMMUNITY_LIST_MASTER);
718e3744 15535 if (! list)
15536 {
b729294c 15537 vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE);
718e3744 15538 return CMD_WARNING;
15539 }
15540
15541 extcommunity_list_show (vty, list);
15542
15543 return CMD_SUCCESS;
15544}
6b0655a2 15545
718e3744 15546/* Return configuration string of community-list entry. */
fd79ac91 15547static const char *
718e3744 15548community_list_config_str (struct community_entry *entry)
15549{
fd79ac91 15550 const char *str;
718e3744 15551
15552 if (entry->any)
15553 str = "";
15554 else
15555 {
15556 if (entry->style == COMMUNITY_LIST_STANDARD)
15557 str = community_str (entry->u.com);
15558 else
15559 str = entry->config;
15560 }
15561 return str;
15562}
15563
15564/* Display community-list and extcommunity-list configuration. */
94f2b392 15565static int
718e3744 15566community_list_config_write (struct vty *vty)
15567{
15568 struct community_list *list;
15569 struct community_entry *entry;
15570 struct community_list_master *cm;
15571 int write = 0;
15572
15573 /* Community-list. */
fee6e4e4 15574 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
718e3744 15575
15576 for (list = cm->num.head; list; list = list->next)
15577 for (entry = list->head; entry; entry = entry->next)
15578 {
fee6e4e4 15579 vty_out (vty, "ip community-list %s %s %s%s",
15580 list->name, community_direct_str (entry->direct),
15581 community_list_config_str (entry),
15582 VTY_NEWLINE);
718e3744 15583 write++;
15584 }
15585 for (list = cm->str.head; list; list = list->next)
15586 for (entry = list->head; entry; entry = entry->next)
15587 {
15588 vty_out (vty, "ip community-list %s %s %s %s%s",
15589 entry->style == COMMUNITY_LIST_STANDARD
15590 ? "standard" : "expanded",
15591 list->name, community_direct_str (entry->direct),
15592 community_list_config_str (entry),
15593 VTY_NEWLINE);
15594 write++;
15595 }
15596
15597 /* Extcommunity-list. */
fee6e4e4 15598 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
718e3744 15599
15600 for (list = cm->num.head; list; list = list->next)
15601 for (entry = list->head; entry; entry = entry->next)
15602 {
fee6e4e4 15603 vty_out (vty, "ip extcommunity-list %s %s %s%s",
15604 list->name, community_direct_str (entry->direct),
15605 community_list_config_str (entry), VTY_NEWLINE);
718e3744 15606 write++;
15607 }
15608 for (list = cm->str.head; list; list = list->next)
15609 for (entry = list->head; entry; entry = entry->next)
15610 {
15611 vty_out (vty, "ip extcommunity-list %s %s %s %s%s",
15612 entry->style == EXTCOMMUNITY_LIST_STANDARD
15613 ? "standard" : "expanded",
15614 list->name, community_direct_str (entry->direct),
15615 community_list_config_str (entry), VTY_NEWLINE);
15616 write++;
15617 }
15618 return write;
15619}
15620
7fc626de 15621static struct cmd_node community_list_node =
718e3744 15622{
15623 COMMUNITY_LIST_NODE,
15624 "",
15625 1 /* Export to vtysh. */
15626};
15627
94f2b392 15628static void
15629community_list_vty (void)
718e3744 15630{
15631 install_node (&community_list_node, community_list_config_write);
15632
15633 /* Community-list. */
718e3744 15634 install_element (CONFIG_NODE, &ip_community_list_standard_cmd);
718e3744 15635 install_element (CONFIG_NODE, &ip_community_list_expanded_cmd);
15636 install_element (CONFIG_NODE, &ip_community_list_name_standard_cmd);
718e3744 15637 install_element (CONFIG_NODE, &ip_community_list_name_expanded_cmd);
fee6e4e4 15638 install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd);
813d4307 15639 install_element (CONFIG_NODE, &no_ip_community_list_standard_direction_cmd);
fee6e4e4 15640 install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd);
15641 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_all_cmd);
15642 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_all_cmd);
718e3744 15643 install_element (CONFIG_NODE, &no_ip_community_list_standard_cmd);
15644 install_element (CONFIG_NODE, &no_ip_community_list_expanded_cmd);
15645 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_cmd);
813d4307 15646 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_brief_cmd);
718e3744 15647 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_cmd);
15648 install_element (VIEW_NODE, &show_ip_community_list_cmd);
15649 install_element (VIEW_NODE, &show_ip_community_list_arg_cmd);
15650 install_element (ENABLE_NODE, &show_ip_community_list_cmd);
15651 install_element (ENABLE_NODE, &show_ip_community_list_arg_cmd);
15652
15653 /* Extcommunity-list. */
15654 install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd);
718e3744 15655 install_element (CONFIG_NODE, &ip_extcommunity_list_expanded_cmd);
15656 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard_cmd);
718e3744 15657 install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd);
fee6e4e4 15658 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd);
813d4307 15659 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_direction_cmd);
fee6e4e4 15660 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd);
15661 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_all_cmd);
15662 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_all_cmd);
718e3744 15663 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_cmd);
15664 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_cmd);
15665 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_cmd);
813d4307 15666 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_brief_cmd);
718e3744 15667 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_cmd);
15668 install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd);
15669 install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd);
15670 install_element (ENABLE_NODE, &show_ip_extcommunity_list_cmd);
15671 install_element (ENABLE_NODE, &show_ip_extcommunity_list_arg_cmd);
8334fd5a 15672T }