]> git.proxmox.com Git - mirror_frr.git/blame - bgpd/bgp_vty.c
bgpd: combine "clear bgp, clear ip bgp" commands into one DEFUN
[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{
b09b5ae0 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
b09b5ae0
DW
6223// dwalton
6224/* one clear bgp command to rule them all */
718e3744 6225DEFUN (clear_ip_bgp_all,
6226 clear_ip_bgp_all_cmd,
b09b5ae0 6227 "clear [ip] bgp [<view|vrf> WORD] <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> [<ipv4 unicast|ipv4 multicast|ipv6 unicast|vpnv4 unicast|encap unicast>] [<soft|soft in|soft out|in prefix-filter|in|out>]",
718e3744 6228 CLEAR_STR
6229 IP_STR
6230 BGP_STR
838758ac 6231 BGP_INSTANCE_HELP_STR
b09b5ae0
DW
6232 "Clear all peers\n"
6233 "BGP neighbor address to clear\n"
a80beece 6234 "BGP IPv6 neighbor to clear\n"
838758ac 6235 "BGP neighbor on interface to clear\n"
b09b5ae0
DW
6236 "Clear peers with the AS number\n"
6237 "Clear all external peers\n"
718e3744 6238 "Clear all members of peer-group\n"
b09b5ae0
DW
6239 "BGP peer-group name\n"
6240 "Address family\n"
6241 "Address Family modifier\n"
6242 "Address family\n"
6243 "Address Family modifier\n"
6244 "Address family\n"
6245 "Address Family modifier\n"
6246 "Address family\n"
6247 "Address Family modifier\n"
6248 "Address family\n"
6249 "Address Family modifier\n"
6250 BGP_SOFT_STR
6251 BGP_SOFT_STR
6252 BGP_SOFT_IN_STR
6253 BGP_SOFT_STR
6254 BGP_SOFT_OUT_STR
6255 BGP_SOFT_IN_STR
6256 "Push out prefix-list ORF and do inbound soft reconfig\n"
6257 BGP_SOFT_IN_STR
6258 BGP_SOFT_OUT_STR)
718e3744 6259{
838758ac
DW
6260 int idx_ip = 1;
6261 int idx_view_vrf = 3;
6262 int idx_vrf = 4;
b09b5ae0
DW
6263 int idx_clr_sort = 5;
6264 int idx_soft_in_out = argc - 1;
6265 int idx_afi;
6266 int idx_safi;
8334fd5a 6267 char *vrf = NULL;
b09b5ae0
DW
6268 afi_t afi;
6269 safi_t safi;
6270 enum clear_sort clr_sort;
6271 enum bgp_clear_type clr_type;
6272 char *clr_arg = NULL;
718e3744 6273
b09b5ae0
DW
6274 /*
6275 * If the user does "clear ip bgp" then we default the afi safi to ipv4 unicast.
6276 * If the user does "clear bgp" then we default the afi safi to ipv6 unicast.
6277 * This may be over-written later in the command if they explicitly
6278 * specify an afi safi.
6279 */
6280 if (strmatch(argv[idx_ip]->text, "ip"))
6281 {
6282 afi = AFI_IP;
6283 safi = SAFI_UNICAST;
6284 }
6285 else
838758ac 6286 {
b09b5ae0
DW
6287 afi = AFI_IP6;
6288 safi = SAFI_UNICAST;
838758ac
DW
6289 idx_view_vrf--;
6290 idx_vrf--;
b09b5ae0 6291 idx_clr_sort--;
838758ac 6292 }
b09b5ae0
DW
6293
6294 if (strmatch(argv[idx_view_vrf]->text, "view") || strmatch(argv[idx_view_vrf]->text, "vrf"))
8334fd5a 6295 vrf = argv[idx_vrf]->arg;
838758ac 6296 else
b09b5ae0 6297 idx_clr_sort -= 2;
01080f7c 6298
b09b5ae0
DW
6299 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external> */
6300 if (strmatch(argv[idx_clr_sort]->text, "*"))
838758ac 6301 {
b09b5ae0 6302 clr_sort = clear_all;
838758ac 6303 }
b09b5ae0
DW
6304 else if (argv[idx_clr_sort]->type == IPV4_TKN)
6305 {
6306 clr_sort = clear_peer;
6307 clr_arg = argv[idx_clr_sort]->arg;
6308 }
6309 else if (argv[idx_clr_sort]->type == IPV6_TKN)
6310 {
6311 clr_sort = clear_peer;
6312 clr_arg = argv[idx_clr_sort]->arg;
6313 }
6314 else if (argv[idx_clr_sort]->type == RANGE_TKN)
6315 {
6316 clr_sort = clear_as;
6317 clr_arg = argv[idx_clr_sort]->arg;
6318 }
6319 else if (strmatch(argv[idx_clr_sort]->text, "external"))
838758ac 6320 {
b09b5ae0 6321 clr_sort = clear_external;
838758ac 6322 }
b09b5ae0
DW
6323 else if (strmatch(argv[idx_clr_sort]->text, "peer-group"))
6324 {
6325 clr_sort = clear_group;
6326 clr_arg = argv[idx_clr_sort + 1]->arg;
718e3744 6327
b09b5ae0
DW
6328 if (! peer_group_lookup (vty->index, clr_arg))
6329 {
6330 vty_out (vty, "%% No such peer-group%s", VTY_NEWLINE);
6331 return CMD_WARNING;
6332 }
6333 }
6334 else if (argv[idx_clr_sort]->type == WORD_TKN)
6335 {
6336 if (peer_lookup_by_conf_if (vty->index, argv[idx_clr_sort]->arg))
6337 {
6338 clr_sort = clear_peer;
6339 clr_arg = argv[idx_clr_sort]->arg;
6340 }
6341 else
6342 {
6343 vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE);
6344 return CMD_WARNING;
6345 }
6346 }
01080f7c 6347
b09b5ae0
DW
6348 /* soft, soft in, or soft out */
6349 if (strmatch(argv[idx_soft_in_out]->text, "in"))
6350 {
6351 clr_type = BGP_CLEAR_SOFT_IN;
718e3744 6352
b09b5ae0
DW
6353 if (strmatch(argv[idx_soft_in_out-1]->text, "soft"))
6354 {
6355 idx_afi = idx_soft_in_out - 3;
6356 idx_safi = idx_soft_in_out - 2;
6357 }
6358 else
6359 {
6360 idx_afi = idx_soft_in_out - 2;
6361 idx_safi = idx_soft_in_out - 1;
6362 }
6363 }
6364 else if (strmatch(argv[idx_soft_in_out]->text, "out"))
838758ac 6365 {
b09b5ae0
DW
6366 clr_type = BGP_CLEAR_SOFT_OUT;
6367
6368 if (strmatch(argv[idx_soft_in_out-1]->text, "soft"))
6369 {
6370 idx_afi = idx_soft_in_out - 3;
6371 idx_safi = idx_soft_in_out - 2;
6372 }
6373 else
6374 {
6375 idx_afi = idx_soft_in_out - 2;
6376 idx_safi = idx_soft_in_out - 1;
6377 }
6378 }
6379 else if (strmatch(argv[idx_soft_in_out]->text, "soft"))
6380 {
6381 clr_type = BGP_CLEAR_SOFT_BOTH;
6382 idx_afi = idx_soft_in_out - 2;
6383 idx_safi = idx_soft_in_out - 1;
6384 }
6385 else if (strmatch(argv[idx_soft_in_out]->text, "prefix-filter"))
6386 {
6387 clr_type = BGP_CLEAR_SOFT_IN_ORF_PREFIX;
6388 idx_afi = idx_soft_in_out - 3;
6389 idx_safi = idx_soft_in_out - 2;
6390 }
6391 else
6392 {
6393 clr_type = BGP_CLEAR_SOFT_NONE;
6394 idx_afi = idx_soft_in_out - 1;
6395 idx_safi = idx_soft_in_out;
838758ac 6396 }
01080f7c 6397
b09b5ae0
DW
6398 /* afi safi */
6399 if (strmatch(argv[idx_afi]->text, "ipv4"))
6400 {
6401 afi = AFI_IP;
6402
6403 if (strmatch(argv[idx_safi]->text, "unicast"))
6404 safi = SAFI_UNICAST;
6405 else if (strmatch(argv[idx_safi]->text, "multicast"))
6406 safi = SAFI_MULTICAST;
6407 }
6408 else if (strmatch(argv[idx_afi]->text, "ipv6"))
6409 {
6410 afi = AFI_IP6;
6411
6412 if (strmatch(argv[idx_safi]->text, "unicast"))
6413 safi = SAFI_UNICAST;
6414 else if (strmatch(argv[idx_safi]->text, "multicast"))
6415 safi = SAFI_MULTICAST;
6416 }
6417 else if (strmatch(argv[idx_afi]->text, "encap"))
6418 {
6419 afi = AFI_IP;
6420 safi = SAFI_ENCAP;
6421 }
6422 else if (strmatch(argv[idx_afi]->text, "vpnv4"))
6423 {
6424 afi = AFI_IP;
6425 safi = SAFI_MPLS_VPN;
6426 }
718e3744 6427
b09b5ae0 6428 return bgp_clear_vty (vty, vrf, afi, safi, clr_sort, clr_type, clr_arg);
838758ac 6429}
01080f7c 6430
8ad7271d
DS
6431DEFUN (clear_ip_bgp_prefix,
6432 clear_ip_bgp_prefix_cmd,
838758ac 6433 "clear [ip] bgp [<view|vrf> WORD] prefix A.B.C.D/M",
8ad7271d
DS
6434 CLEAR_STR
6435 IP_STR
6436 BGP_STR
838758ac 6437 BGP_INSTANCE_HELP_STR
8ad7271d
DS
6438 "Clear bestpath and re-advertise\n"
6439 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6440{
838758ac
DW
6441 int idx_ip = 1;
6442 int idx_view_vrf = 3;
6443 int idx_vrf = 4;
6444 int idx_ipv4_prefixlen = 6;
8334fd5a 6445 char *vrf = NULL;
8ad7271d 6446
838758ac
DW
6447 if (!strmatch(argv[idx_ip]->text, "ip"))
6448 {
6449 idx_view_vrf--;
6450 idx_vrf--;
6451 idx_ipv4_prefixlen--;
6452 }
01080f7c 6453
838758ac 6454 if (strmatch(argv[idx_view_vrf]->text, "view") || strmatch(argv[idx_view_vrf]->text, "vrf"))
8334fd5a 6455 vrf = argv[idx_vrf]->arg;
838758ac
DW
6456 else
6457 idx_ipv4_prefixlen -= 2;
8ad7271d 6458
8334fd5a 6459 return bgp_clear_prefix (vty, vrf, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL);
838758ac 6460}
8ad7271d 6461
b09b5ae0
DW
6462DEFUN (clear_bgp_ipv6_safi_prefix,
6463 clear_bgp_ipv6_safi_prefix_cmd,
6464 "clear bgp ipv6 <unicast|multicast> prefix X:X::X:X/M",
718e3744 6465 CLEAR_STR
718e3744 6466 BGP_STR
b09b5ae0
DW
6467 "Address family\n"
6468 "Address Family Modifier\n"
6469 "Clear bestpath and re-advertise\n"
6470 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
718e3744 6471{
b09b5ae0
DW
6472 int idx_safi = 3;
6473 int idx_ipv6_prefixlen = 5;
6474 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
6475 return bgp_clear_prefix (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_MULTICAST, NULL);
838758ac 6476 else
b09b5ae0 6477 return bgp_clear_prefix (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL);
838758ac 6478}
01080f7c 6479
b09b5ae0
DW
6480DEFUN (clear_bgp_instance_ipv6_safi_prefix,
6481 clear_bgp_instance_ipv6_safi_prefix_cmd,
6482 "clear bgp <view|vrf> WORD ipv6 <unicast|multicast> prefix X:X::X:X/M",
718e3744 6483 CLEAR_STR
718e3744 6484 BGP_STR
838758ac 6485 BGP_INSTANCE_HELP_STR
718e3744 6486 "Address family\n"
b09b5ae0
DW
6487 "Address Family Modifier\n"
6488 "Clear bestpath and re-advertise\n"
6489 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
718e3744 6490{
b09b5ae0 6491 int idx_word = 3;
c500ae40 6492 int idx_safi = 5;
b09b5ae0 6493 int idx_ipv6_prefixlen = 7;
c500ae40 6494 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
b09b5ae0
DW
6495 return bgp_clear_prefix (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_MULTICAST, NULL);
6496 else
6497 return bgp_clear_prefix (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL);
718e3744 6498}
6499
b09b5ae0
DW
6500DEFUN (show_bgp_views,
6501 show_bgp_views_cmd,
6502 "show bgp views",
6503 SHOW_STR
01080f7c 6504 BGP_STR
b09b5ae0 6505 "Show the defined BGP views\n")
01080f7c 6506{
b09b5ae0
DW
6507 struct list *inst = bm->bgp;
6508 struct listnode *node;
6509 struct bgp *bgp;
01080f7c 6510
b09b5ae0
DW
6511 if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
6512 {
6513 vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE);
6514 return CMD_WARNING;
6515 }
6516
6517 vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE);
6518 for (ALL_LIST_ELEMENTS_RO(inst, node, bgp))
6519 {
6520 /* Skip VRFs. */
6521 if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF)
6522 continue;
6523 vty_out (vty, "\t%s (AS%u)%s",
6524 bgp->name ? bgp->name : "(null)",
6525 bgp->as, VTY_NEWLINE);
6526 }
6527
6528 return CMD_SUCCESS;
e0081f70
ML
6529}
6530
8386ac43 6531DEFUN (show_bgp_vrfs,
6532 show_bgp_vrfs_cmd,
b162fa78 6533 "show bgp vrfs [json]",
8386ac43 6534 SHOW_STR
6535 BGP_STR
6536 "Show BGP VRFs\n"
6537 "JavaScript Object Notation\n")
6538{
6539 struct list *inst = bm->bgp;
6540 struct listnode *node;
6541 struct bgp *bgp;
6542 u_char uj = use_json(argc, argv);
6543 json_object *json = NULL;
6544 json_object *json_vrfs = NULL;
6545 int count = 0;
6546 static char header[] = "Type Id RouterId #PeersCfg #PeersEstb Name";
6547
6548 if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
6549 {
6550 vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE);
6551 return CMD_WARNING;
6552 }
6553
6554 if (uj)
6555 {
6556 json = json_object_new_object();
6557 json_vrfs = json_object_new_object();
6558 }
6559
6560 for (ALL_LIST_ELEMENTS_RO(inst, node, bgp))
6561 {
6562 const char *name, *type;
6563 struct peer *peer;
6564 struct listnode *node, *nnode;
6565 int peers_cfg, peers_estb;
6566 json_object *json_vrf = NULL;
5c81a5f3 6567 int vrf_id_ui;
8386ac43 6568
6569 /* Skip Views. */
6570 if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW)
6571 continue;
6572
6573 count++;
6574 if (!uj && count == 1)
6575 vty_out (vty, "%s%s", header, VTY_NEWLINE);
6576
6577 peers_cfg = peers_estb = 0;
6578 if (uj)
6579 json_vrf = json_object_new_object();
6580
6581
6582 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
6583 {
6584 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
6585 continue;
6586 peers_cfg++;
6587 if (peer->status == Established)
6588 peers_estb++;
6589 }
6590
6591 if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
6592 {
6593 name = "Default";
6594 type = "DFLT";
6595 }
6596 else
6597 {
6598 name = bgp->name;
6599 type = "VRF";
6600 }
6601
5c81a5f3 6602 vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id;
8386ac43 6603 if (uj)
6604 {
6605 json_object_string_add(json_vrf, "type", type);
5c81a5f3 6606 json_object_int_add(json_vrf, "vrfId", vrf_id_ui);
8386ac43 6607 json_object_string_add(json_vrf, "routerId", inet_ntoa (bgp->router_id));
6608 json_object_int_add(json_vrf, "numConfiguredPeers", peers_cfg);
6609 json_object_int_add(json_vrf, "numEstablishedPeers", peers_estb);
6610
6611 json_object_object_add(json_vrfs, name, json_vrf);
6612 }
6613 else
5c81a5f3 6614 vty_out (vty, "%4s %-5d %-16s %9u %10u %s%s",
6615 type, vrf_id_ui, inet_ntoa (bgp->router_id),
8386ac43 6616 peers_cfg, peers_estb, name,
6617 VTY_NEWLINE);
6618 }
6619
6620 if (uj)
6621 {
6622 json_object_object_add(json, "vrfs", json_vrfs);
6623
6624 json_object_int_add(json, "totalVrfs", count);
6625
6626 vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
6627 json_object_free(json);
6628 }
6629 else
6630 {
6631 if (count)
6632 vty_out (vty, "%sTotal number of VRFs (including default): %d%s",
6633 VTY_NEWLINE, count, VTY_NEWLINE);
6634 }
6635
6636 return CMD_SUCCESS;
6637}
6638
f412b39a 6639DEFUN (show_bgp_memory,
4bf6a362
PJ
6640 show_bgp_memory_cmd,
6641 "show bgp memory",
6642 SHOW_STR
6643 BGP_STR
6644 "Global BGP memory statistics\n")
6645{
6646 char memstrbuf[MTYPE_MEMSTR_LEN];
6647 unsigned long count;
6648
6649 /* RIB related usage stats */
6650 count = mtype_stats_alloc (MTYPE_BGP_NODE);
6651 vty_out (vty, "%ld RIB nodes, using %s of memory%s", count,
6652 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6653 count * sizeof (struct bgp_node)),
6654 VTY_NEWLINE);
6655
6656 count = mtype_stats_alloc (MTYPE_BGP_ROUTE);
6657 vty_out (vty, "%ld BGP routes, using %s of memory%s", count,
6658 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6659 count * sizeof (struct bgp_info)),
6660 VTY_NEWLINE);
fb982c25
PJ
6661 if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA)))
6662 vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count,
6663 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6664 count * sizeof (struct bgp_info_extra)),
6665 VTY_NEWLINE);
4bf6a362
PJ
6666
6667 if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC)))
6668 vty_out (vty, "%ld Static routes, using %s of memory%s", count,
6669 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6670 count * sizeof (struct bgp_static)),
6671 VTY_NEWLINE);
3f9c7369
DS
6672
6673 if ((count = mtype_stats_alloc (MTYPE_BGP_PACKET)))
6674 vty_out (vty, "%ld Packets, using %s of memory%s", count,
6675 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6676 count * sizeof (struct bpacket)),
6677 VTY_NEWLINE);
4bf6a362
PJ
6678
6679 /* Adj-In/Out */
6680 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN)))
6681 vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count,
6682 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6683 count * sizeof (struct bgp_adj_in)),
6684 VTY_NEWLINE);
6685 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT)))
6686 vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count,
6687 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6688 count * sizeof (struct bgp_adj_out)),
6689 VTY_NEWLINE);
6690
6691 if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE)))
6692 vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count,
6693 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6694 count * sizeof (struct bgp_nexthop_cache)),
6695 VTY_NEWLINE);
6696
6697 if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO)))
6698 vty_out (vty, "%ld Dampening entries, using %s of memory%s", count,
6699 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6700 count * sizeof (struct bgp_damp_info)),
6701 VTY_NEWLINE);
6702
6703 /* Attributes */
6704 count = attr_count();
6705 vty_out (vty, "%ld BGP attributes, using %s of memory%s", count,
6706 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6707 count * sizeof(struct attr)),
6708 VTY_NEWLINE);
fb982c25
PJ
6709 if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA)))
6710 vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count,
6711 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6712 count * sizeof(struct attr_extra)),
6713 VTY_NEWLINE);
4bf6a362
PJ
6714
6715 if ((count = attr_unknown_count()))
6716 vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE);
6717
6718 /* AS_PATH attributes */
6719 count = aspath_count ();
6720 vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count,
6721 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6722 count * sizeof (struct aspath)),
6723 VTY_NEWLINE);
6724
6725 count = mtype_stats_alloc (MTYPE_AS_SEG);
6726 vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count,
6727 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6728 count * sizeof (struct assegment)),
6729 VTY_NEWLINE);
6730
6731 /* Other attributes */
6732 if ((count = community_count ()))
6733 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
6734 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6735 count * sizeof (struct community)),
6736 VTY_NEWLINE);
6737 if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY)))
6738 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
6739 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6740 count * sizeof (struct ecommunity)),
6741 VTY_NEWLINE);
6742
6743 if ((count = mtype_stats_alloc (MTYPE_CLUSTER)))
6744 vty_out (vty, "%ld Cluster lists, using %s of memory%s", count,
6745 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6746 count * sizeof (struct cluster_list)),
6747 VTY_NEWLINE);
6748
6749 /* Peer related usage */
6750 count = mtype_stats_alloc (MTYPE_BGP_PEER);
6751 vty_out (vty, "%ld peers, using %s of memory%s", count,
6752 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6753 count * sizeof (struct peer)),
6754 VTY_NEWLINE);
6755
4a1ab8e4 6756 if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP)))
4bf6a362
PJ
6757 vty_out (vty, "%ld peer groups, using %s of memory%s", count,
6758 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6759 count * sizeof (struct peer_group)),
6760 VTY_NEWLINE);
6761
6762 /* Other */
6763 if ((count = mtype_stats_alloc (MTYPE_HASH)))
6764 vty_out (vty, "%ld hash tables, using %s of memory%s", count,
6765 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6766 count * sizeof (struct hash)),
6767 VTY_NEWLINE);
6768 if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET)))
6769 vty_out (vty, "%ld hash buckets, using %s of memory%s", count,
6770 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6771 count * sizeof (struct hash_backet)),
6772 VTY_NEWLINE);
6773 if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP)))
6774 vty_out (vty, "%ld compiled regexes, using %s of memory%s", count,
6775 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6776 count * sizeof (regex_t)),
6777 VTY_NEWLINE);
6778 return CMD_SUCCESS;
6779}
fee0f4c6 6780
718e3744 6781/* Show BGP peer's summary information. */
94f2b392 6782static int
b05a1c8b 6783bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi,
9f689658 6784 u_char use_json, json_object *json)
718e3744 6785{
6786 struct peer *peer;
1eb8ef25 6787 struct listnode *node, *nnode;
f14e6fdb
DS
6788 unsigned int count = 0, dn_count = 0;
6789 char timebuf[BGP_UPTIME_LEN], dn_flag[2];
718e3744 6790 int len;
ffd0c037
DS
6791 json_object *json_peer = NULL;
6792 json_object *json_peers = NULL;
718e3744 6793
6794 /* Header string for each address family. */
4a7ac06c 6795 static char header[] = "Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd";
47fc97cc 6796
b05a1c8b
DS
6797 if (use_json)
6798 {
9f689658
DD
6799 if (json == NULL)
6800 json = json_object_new_object();
6801
f1aa5d8a 6802 json_peers = json_object_new_object();
b05a1c8b
DS
6803 }
6804
1eb8ef25 6805 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
718e3744 6806 {
1ff9a340
DS
6807 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
6808 continue;
6809
718e3744 6810 if (peer->afc[afi][safi])
6811 {
b05a1c8b 6812 if (!count)
4bf6a362
PJ
6813 {
6814 unsigned long ents;
6815 char memstrbuf[MTYPE_MEMSTR_LEN];
5c81a5f3 6816 int vrf_id_ui;
6817
6818 vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id;
b05a1c8b 6819
4bf6a362 6820 /* Usage summary and header */
b05a1c8b
DS
6821 if (use_json)
6822 {
62d6dca0 6823 json_object_string_add(json, "routerId", inet_ntoa (bgp->router_id));
f1aa5d8a 6824 json_object_int_add(json, "as", bgp->as);
9f689658
DD
6825 json_object_int_add(json, "vrfId", vrf_id_ui);
6826 json_object_string_add(json, "vrfName",
6827 (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
6828 ? "Default" : bgp->name);
b05a1c8b
DS
6829 }
6830 else
6831 {
6832 vty_out (vty,
5c81a5f3 6833 "BGP router identifier %s, local AS number %u vrf-id %d",
6834 inet_ntoa (bgp->router_id), bgp->as, vrf_id_ui);
6aeb9e78 6835 vty_out (vty, "%s", VTY_NEWLINE);
b05a1c8b
DS
6836 }
6837
f188f2c4
DS
6838 if (bgp_update_delay_configured(bgp))
6839 {
b05a1c8b 6840 if (use_json)
f188f2c4 6841 {
62d6dca0 6842 json_object_int_add(json, "updateDelayLimit", bgp->v_update_delay);
b05a1c8b
DS
6843
6844 if (bgp->v_update_delay != bgp->v_establish_wait)
62d6dca0 6845 json_object_int_add(json, "updateDelayEstablishWait", bgp->v_establish_wait);
b05a1c8b
DS
6846
6847 if (bgp_update_delay_active(bgp))
6848 {
62d6dca0
DS
6849 json_object_string_add(json, "updateDelayFirstNeighbor", bgp->update_delay_begin_time);
6850 json_object_boolean_true_add(json, "updateDelayInProgress");
b05a1c8b
DS
6851 }
6852 else
6853 {
6854 if (bgp->update_delay_over)
6855 {
62d6dca0 6856 json_object_string_add(json, "updateDelayFirstNeighbor",
f1aa5d8a 6857 bgp->update_delay_begin_time);
62d6dca0 6858 json_object_string_add(json, "updateDelayBestpathResumed",
f1aa5d8a 6859 bgp->update_delay_end_time);
62d6dca0 6860 json_object_string_add(json, "updateDelayZebraUpdateResume",
f1aa5d8a 6861 bgp->update_delay_zebra_resume_time);
62d6dca0 6862 json_object_string_add(json, "updateDelayPeerUpdateResume",
f1aa5d8a 6863 bgp->update_delay_peers_resume_time);
b05a1c8b
DS
6864 }
6865 }
f188f2c4
DS
6866 }
6867 else
6868 {
b05a1c8b
DS
6869 vty_out (vty, "Read-only mode update-delay limit: %d seconds%s",
6870 bgp->v_update_delay, VTY_NEWLINE);
6871 if (bgp->v_update_delay != bgp->v_establish_wait)
6872 vty_out (vty, " Establish wait: %d seconds%s",
6873 bgp->v_establish_wait, VTY_NEWLINE);
6874
6875 if (bgp_update_delay_active(bgp))
f188f2c4
DS
6876 {
6877 vty_out (vty, " First neighbor established: %s%s",
6878 bgp->update_delay_begin_time, VTY_NEWLINE);
b05a1c8b
DS
6879 vty_out (vty, " Delay in progress%s", VTY_NEWLINE);
6880 }
6881 else
6882 {
6883 if (bgp->update_delay_over)
6884 {
6885 vty_out (vty, " First neighbor established: %s%s",
6886 bgp->update_delay_begin_time, VTY_NEWLINE);
6887 vty_out (vty, " Best-paths resumed: %s%s",
6888 bgp->update_delay_end_time, VTY_NEWLINE);
6889 vty_out (vty, " zebra update resumed: %s%s",
6890 bgp->update_delay_zebra_resume_time, VTY_NEWLINE);
6891 vty_out (vty, " peers update resumed: %s%s",
6892 bgp->update_delay_peers_resume_time, VTY_NEWLINE);
6893 }
f188f2c4
DS
6894 }
6895 }
6896 }
4bf6a362 6897
b05a1c8b
DS
6898 if (use_json)
6899 {
6900 if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active)
62d6dca0 6901 json_object_boolean_true_add(json, "maxMedOnStartup");
b05a1c8b 6902 if (bgp->v_maxmed_admin)
62d6dca0 6903 json_object_boolean_true_add(json, "maxMedAdministrative");
b05a1c8b 6904
62d6dca0 6905 json_object_int_add(json, "tableVersion", bgp_table_version(bgp->rib[afi][safi]));
b05a1c8b
DS
6906
6907 ents = bgp_table_count (bgp->rib[afi][safi]);
62d6dca0
DS
6908 json_object_int_add(json, "ribCount", ents);
6909 json_object_int_add(json, "ribMemory", ents * sizeof (struct bgp_node));
b05a1c8b
DS
6910
6911 ents = listcount (bgp->peer);
62d6dca0
DS
6912 json_object_int_add(json, "peerCount", ents);
6913 json_object_int_add(json, "peerMemory", ents * sizeof (struct peer));
b05a1c8b 6914
b05a1c8b
DS
6915 if ((ents = listcount (bgp->group)))
6916 {
62d6dca0
DS
6917 json_object_int_add(json, "peerGroupCount", ents);
6918 json_object_int_add(json, "peerGroupMemory", ents * sizeof (struct peer_group));
b05a1c8b 6919 }
3f9c7369 6920
b05a1c8b 6921 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
62d6dca0 6922 json_object_boolean_true_add(json, "dampeningEnabled");
b05a1c8b
DS
6923 }
6924 else
6925 {
6926 if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active)
6927 vty_out (vty, "Max-med on-startup active%s", VTY_NEWLINE);
6928 if (bgp->v_maxmed_admin)
6929 vty_out (vty, "Max-med administrative active%s", VTY_NEWLINE);
6930
ffd0c037 6931 vty_out(vty, "BGP table version %" PRIu64 "%s",
b05a1c8b
DS
6932 bgp_table_version(bgp->rib[afi][safi]), VTY_NEWLINE);
6933
6934 ents = bgp_table_count (bgp->rib[afi][safi]);
6935 vty_out (vty, "RIB entries %ld, using %s of memory%s", ents,
6936 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6937 ents * sizeof (struct bgp_node)),
6938 VTY_NEWLINE);
6939
6940 /* Peer related usage */
6941 ents = listcount (bgp->peer);
6942 vty_out (vty, "Peers %ld, using %s of memory%s",
6943 ents,
6944 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6945 ents * sizeof (struct peer)),
6946 VTY_NEWLINE);
6947
b05a1c8b
DS
6948 if ((ents = listcount (bgp->group)))
6949 vty_out (vty, "Peer groups %ld, using %s of memory%s", ents,
6950 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6951 ents * sizeof (struct peer_group)),
6952 VTY_NEWLINE);
6953
6954 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
6955 vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE);
6956 vty_out (vty, "%s", VTY_NEWLINE);
6957 vty_out (vty, "%s%s", header, VTY_NEWLINE);
6958 }
4bf6a362
PJ
6959 }
6960
b05a1c8b 6961 count++;
718e3744 6962
b05a1c8b
DS
6963 if (use_json)
6964 {
6965 json_peer = json_object_new_object();
f14e6fdb 6966
b05a1c8b 6967 if (peer_dynamic_neighbor(peer))
62d6dca0 6968 json_object_boolean_true_add(json_peer, "dynamicPeer");
b05a1c8b 6969
04b6bdc0
DW
6970 if (peer->hostname)
6971 json_object_string_add(json_peer, "hostname", peer->hostname);
6972
6973 if (peer->domainname)
6974 json_object_string_add(json_peer, "domainname", peer->domainname);
6975
62d6dca0 6976 json_object_int_add(json_peer, "remoteAs", peer->as);
f1aa5d8a 6977 json_object_int_add(json_peer, "version", 4);
62d6dca0 6978 json_object_int_add(json_peer, "msgRcvd",
f1aa5d8a
DS
6979 peer->open_in + peer->update_in + peer->keepalive_in
6980 + peer->notify_in + peer->refresh_in
6981 + peer->dynamic_cap_in);
62d6dca0 6982 json_object_int_add(json_peer, "msgSent",
f1aa5d8a
DS
6983 peer->open_out + peer->update_out + peer->keepalive_out
6984 + peer->notify_out + peer->refresh_out
6985 + peer->dynamic_cap_out);
6986
62d6dca0 6987 json_object_int_add(json_peer, "tableVersion", peer->version[afi][safi]);
f1aa5d8a
DS
6988 json_object_int_add(json_peer, "outq", peer->obuf->count);
6989 json_object_int_add(json_peer, "inq", 0);
856ca177 6990 peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, use_json, json_peer);
62d6dca0 6991 json_object_int_add(json_peer, "prefixReceivedCount", peer->pcount[afi][safi]);
b05a1c8b
DS
6992
6993 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
f1aa5d8a 6994 json_object_string_add(json_peer, "state", "Idle (Admin)");
b05a1c8b 6995 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
f1aa5d8a 6996 json_object_string_add(json_peer, "state", "Idle (PfxCt)");
b05a1c8b 6997 else
f1aa5d8a 6998 json_object_string_add(json_peer, "state", LOOKUP(bgp_status_msg, peer->status));
b05a1c8b 6999
f1aa5d8a 7000 if (peer->conf_if)
62d6dca0 7001 json_object_string_add(json_peer, "idType", "interface");
f1aa5d8a 7002 else if (peer->su.sa.sa_family == AF_INET)
62d6dca0 7003 json_object_string_add(json_peer, "idType", "ipv4");
f1aa5d8a 7004 else if (peer->su.sa.sa_family == AF_INET6)
62d6dca0 7005 json_object_string_add(json_peer, "idType", "ipv6");
b05a1c8b 7006
f1aa5d8a 7007 json_object_object_add(json_peers, peer->host, json_peer);
b05a1c8b
DS
7008 }
7009 else
7010 {
7011 memset(dn_flag, '\0', sizeof(dn_flag));
7012 if (peer_dynamic_neighbor(peer))
7013 {
7014 dn_count++;
7015 dn_flag[0] = '*';
7016 }
7017
04b6bdc0
DW
7018 if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME))
7019 len = vty_out (vty, "%s%s(%s)", dn_flag, peer->hostname,
7020 peer->host);
7021 else
7022 len = vty_out (vty, "%s%s", dn_flag, peer->host);
b05a1c8b
DS
7023 len = 16 - len;
7024
7025 if (len < 1)
7026 vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
7027 else
7028 vty_out (vty, "%*s", len, " ");
7029
7030 vty_out (vty, "4 ");
7031
ee046671 7032 vty_out (vty, "%5u %7d %7d %8" PRIu64 " %4d %4zd ",
b05a1c8b
DS
7033 peer->as,
7034 peer->open_in + peer->update_in + peer->keepalive_in
7035 + peer->notify_in + peer->refresh_in
7036 + peer->dynamic_cap_in,
7037 peer->open_out + peer->update_out + peer->keepalive_out
7038 + peer->notify_out + peer->refresh_out
7039 + peer->dynamic_cap_out,
7040 peer->version[afi][safi],
7041 0,
ffd0c037 7042 peer->obuf->count);
b05a1c8b 7043
f1aa5d8a 7044 vty_out (vty, "%-8s",
856ca177 7045 peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL));
b05a1c8b
DS
7046
7047 if (peer->status == Established)
7048 vty_out (vty, " %8ld", peer->pcount[afi][safi]);
7049 else
7050 {
7051 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
7052 vty_out (vty, " Idle (Admin)");
7053 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
7054 vty_out (vty, " Idle (PfxCt)");
7055 else
7056 vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, peer->status));
7057 }
7058 vty_out (vty, "%s", VTY_NEWLINE);
7059 }
718e3744 7060 }
7061 }
7062
b05a1c8b
DS
7063 if (use_json)
7064 {
7065 json_object_object_add(json, "peers", json_peers);
14151a32 7066
62d6dca0
DS
7067 json_object_int_add(json, "totalPeers", count);
7068 json_object_int_add(json, "dynamicPeers", dn_count);
14151a32 7069
b05a1c8b 7070 vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
f1aa5d8a 7071 json_object_free(json);
b05a1c8b
DS
7072 }
7073 else
f14e6fdb 7074 {
b05a1c8b
DS
7075 if (count)
7076 vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE,
7077 count, VTY_NEWLINE);
7078 else
9f689658
DD
7079 {
7080 if (use_json)
7081 vty_out(vty, "{\"error\": {\"message\": \"No %s neighbor configured\"}}%s",
7082 afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
7083 else
7084 vty_out (vty, "No %s neighbor is configured%s",
7085 afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
7086 }
b05a1c8b 7087
9f689658 7088 if (dn_count && ! use_json)
b05a1c8b
DS
7089 {
7090 vty_out(vty, "* - dynamic neighbor%s", VTY_NEWLINE);
7091 vty_out(vty,
7092 "%d dynamic neighbor(s), limit %d%s",
7093 dn_count, bgp->dynamic_neighbors_limit, VTY_NEWLINE);
7094 }
f14e6fdb
DS
7095 }
7096
718e3744 7097 return CMD_SUCCESS;
7098}
7099
47fc97cc
DS
7100static int
7101bgp_show_summary_vty (struct vty *vty, const char *name,
b05a1c8b 7102 afi_t afi, safi_t safi, u_char use_json)
718e3744 7103{
7104 struct bgp *bgp;
7105
7106 if (name)
7107 {
7108 bgp = bgp_lookup_by_name (name);
47fc97cc 7109
718e3744 7110 if (! bgp)
7111 {
47fc97cc 7112 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
718e3744 7113 return CMD_WARNING;
7114 }
7115
9f689658 7116 bgp_show_summary (vty, bgp, afi, safi, use_json, NULL);
718e3744 7117 return CMD_SUCCESS;
7118 }
47fc97cc 7119
718e3744 7120 bgp = bgp_get_default ();
7121
7122 if (bgp)
9f689658 7123 bgp_show_summary (vty, bgp, afi, safi, use_json, NULL);
47fc97cc 7124
718e3744 7125 return CMD_SUCCESS;
7126}
7127
f186de26 7128static void
7129bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi,
7130 u_char use_json)
7131{
7132 struct listnode *node, *nnode;
7133 struct bgp *bgp;
9f689658
DD
7134 json_object *json = NULL;
7135 int is_first = 1;
7136
7137 if (use_json)
7138 vty_out (vty, "{%s", VTY_NEWLINE);
f186de26 7139
7140 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
7141 {
9f689658
DD
7142 if (use_json)
7143 {
7144 if (!(json = json_object_new_object()))
7145 {
7146 zlog_err("Unable to allocate memory for JSON object");
7147 vty_out (vty,
7148 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s",
7149 VTY_NEWLINE);
7150 return;
7151 }
7152
7153 if (! is_first)
7154 vty_out (vty, ",%s", VTY_NEWLINE);
7155 else
7156 is_first = 0;
7157
7158 vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
7159 ? "Default" : bgp->name);
7160 }
7161 else
7162 {
7163 vty_out (vty, "%sInstance %s:%s",
7164 VTY_NEWLINE,
7165 (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
7166 ? "Default" : bgp->name, VTY_NEWLINE);
7167 }
7168 bgp_show_summary (vty, bgp, afi, safi, use_json, json);
f186de26 7169 }
9f689658
DD
7170
7171 if (use_json)
7172 vty_out (vty, "}%s", VTY_NEWLINE);
7173
f186de26 7174}
7175
718e3744 7176/* `show ip bgp summary' commands. */
47fc97cc 7177DEFUN (show_ip_bgp_summary,
718e3744 7178 show_ip_bgp_summary_cmd,
b162fa78 7179 "show ip bgp summary [json]",
47fc97cc
DS
7180 SHOW_STR
7181 IP_STR
7182 BGP_STR
b05a1c8b
DS
7183 "Summary of BGP neighbor status\n"
7184 "JavaScript Object Notation\n")
47fc97cc 7185{
db7c8528
DS
7186 u_char uj = use_json(argc, argv);
7187 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST, uj);
718e3744 7188}
7189
7190DEFUN (show_ip_bgp_instance_summary,
7191 show_ip_bgp_instance_summary_cmd,
9ccf14f7 7192 "show ip bgp <view|vrf> WORD summary [json]",
718e3744 7193 SHOW_STR
7194 IP_STR
7195 BGP_STR
8386ac43 7196 BGP_INSTANCE_HELP_STR
b05a1c8b
DS
7197 "Summary of BGP neighbor status\n"
7198 "JavaScript Object Notation\n")
718e3744 7199{
c500ae40 7200 int idx_word = 4;
db7c8528 7201 u_char uj = use_json(argc, argv);
c500ae40 7202 return bgp_show_summary_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, uj);
718e3744 7203}
7204
f186de26 7205DEFUN (show_ip_bgp_instance_all_summary,
7206 show_ip_bgp_instance_all_summary_cmd,
9ccf14f7 7207 "show ip bgp <view|vrf> all summary [json]",
f186de26 7208 SHOW_STR
7209 IP_STR
7210 BGP_STR
7211 BGP_INSTANCE_ALL_HELP_STR
7212 "Summary of BGP neighbor status\n"
7213 "JavaScript Object Notation\n")
7214{
7215 u_char uj = use_json(argc, argv);
7216
7217 bgp_show_all_instances_summary_vty (vty, AFI_IP, SAFI_UNICAST, uj);
7218 return CMD_SUCCESS;
7219}
7220
f412b39a
DW
7221/*
7222 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
b162fa78 7223 * "show bgp ipv4 (unicast|multicast) summary [json]",
f412b39a
DW
7224 * SHOW_STR
7225 * BGP_STR
7226 * "Address family\n"
7227 * "Address Family modifier\n"
7228 * "Address Family modifier\n"
7229 * "Summary of BGP neighbor status\n"
7230 *
7231 */
7232DEFUN (show_ip_bgp_ipv4_summary,
718e3744 7233 show_ip_bgp_ipv4_summary_cmd,
6147e2c6 7234 "show ip bgp ipv4 <unicast|multicast> summary [json]",
718e3744 7235 SHOW_STR
7236 IP_STR
7237 BGP_STR
7238 "Address family\n"
7239 "Address Family modifier\n"
7240 "Address Family modifier\n"
b05a1c8b
DS
7241 "Summary of BGP neighbor status\n"
7242 "JavaScript Object Notation\n")
718e3744 7243{
c500ae40 7244 int idx_safi = 4;
db7c8528 7245 u_char uj = use_json(argc, argv);
c500ae40 7246 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
db7c8528 7247 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, uj);
718e3744 7248
db7c8528 7249 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST, uj);
718e3744 7250}
7251
95cbbd2a 7252
e3e29b32
LB
7253DEFUN (show_bgp_ipv4_vpn_summary,
7254 show_bgp_ipv4_vpn_summary_cmd,
b162fa78 7255 "show bgp ipv4 vpn summary [json]",
e3e29b32
LB
7256 SHOW_STR
7257 BGP_STR
7258 "IPv4\n"
7259 "Display VPN NLRI specific information\n"
7260 "Summary of BGP neighbor status\n"
7261 JSON_STR)
7262{
7263 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, use_json (argc, argv));
7264}
7265
7266/* `show ip bgp summary' commands. */
7267DEFUN (show_bgp_ipv6_vpn_summary,
7268 show_bgp_ipv6_vpn_summary_cmd,
b162fa78 7269 "show bgp ipv6 vpn summary [json]",
e3e29b32
LB
7270 SHOW_STR
7271 BGP_STR
7272 "IPv6\n"
7273 "Display VPN NLRI specific information\n"
7274 "Summary of BGP neighbor status\n"
7275 JSON_STR)
7276{
7277 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MPLS_VPN, use_json (argc, argv));
7278}
7279
f412b39a
DW
7280/*
7281 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
b162fa78 7282 * "show bgp view WORD ipv4 (unicast|multicast) summary [json]",
f412b39a
DW
7283 * SHOW_STR
7284 * BGP_STR
7285 * "BGP view\n"
7286 * "View name\n"
7287 * "Address family\n"
7288 * "Address Family modifier\n"
7289 * "Address Family modifier\n"
7290 * "Summary of BGP neighbor status\n"
7291 *
7292 */
718e3744 7293DEFUN (show_ip_bgp_instance_ipv4_summary,
7294 show_ip_bgp_instance_ipv4_summary_cmd,
6147e2c6 7295 "show ip bgp view WORD ipv4 <unicast|multicast> summary [json]",
718e3744 7296 SHOW_STR
7297 IP_STR
7298 BGP_STR
7299 "BGP view\n"
7300 "View name\n"
7301 "Address family\n"
7302 "Address Family modifier\n"
7303 "Address Family modifier\n"
b05a1c8b
DS
7304 "Summary of BGP neighbor status\n"
7305 "JavaScript Object Notation\n")
718e3744 7306{
c500ae40
DW
7307 int idx_word = 4;
7308 int idx_safi = 6;
db7c8528 7309 u_char uj = use_json(argc, argv);
c500ae40
DW
7310 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
7311 return bgp_show_summary_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, uj);
718e3744 7312 else
c500ae40 7313 return bgp_show_summary_vty (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, uj);
718e3744 7314}
7315
95cbbd2a 7316
718e3744 7317DEFUN (show_ip_bgp_vpnv4_all_summary,
7318 show_ip_bgp_vpnv4_all_summary_cmd,
b162fa78 7319 "show ip bgp vpnv4 all summary [json]",
718e3744 7320 SHOW_STR
7321 IP_STR
7322 BGP_STR
7323 "Display VPNv4 NLRI specific information\n"
7324 "Display information about all VPNv4 NLRIs\n"
b05a1c8b
DS
7325 "Summary of BGP neighbor status\n"
7326 "JavaScript Object Notation\n")
718e3744 7327{
db7c8528
DS
7328 u_char uj = use_json(argc, argv);
7329 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, uj);
718e3744 7330}
7331
7332DEFUN (show_ip_bgp_vpnv4_rd_summary,
7333 show_ip_bgp_vpnv4_rd_summary_cmd,
b162fa78 7334 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn summary [json]",
718e3744 7335 SHOW_STR
7336 IP_STR
7337 BGP_STR
7338 "Display VPNv4 NLRI specific information\n"
7339 "Display information for a route distinguisher\n"
7340 "VPN Route Distinguisher\n"
b05a1c8b
DS
7341 "Summary of BGP neighbor status\n"
7342 "JavaScript Object Notation\n")
718e3744 7343{
c500ae40 7344 int idx_ext_community = 5;
718e3744 7345 int ret;
7346 struct prefix_rd prd;
db7c8528 7347 u_char uj = use_json(argc, argv);
718e3744 7348
c500ae40 7349 ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd);
718e3744 7350 if (! ret)
7351 {
7352 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7353 return CMD_WARNING;
7354 }
7355
db7c8528 7356 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, uj);
718e3744 7357}
7358
7359#ifdef HAVE_IPV6
f412b39a
DW
7360/*
7361 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
b162fa78 7362 * "show bgp ipv6 summary [json]",
f412b39a
DW
7363 * SHOW_STR
7364 * BGP_STR
7365 * "Address family\n"
7366 * "Summary of BGP neighbor status\n"
7367 *
7368 */
47fc97cc 7369DEFUN (show_bgp_summary,
718e3744 7370 show_bgp_summary_cmd,
b162fa78 7371 "show bgp summary [json]",
718e3744 7372 SHOW_STR
7373 BGP_STR
b05a1c8b
DS
7374 "Summary of BGP neighbor status\n"
7375 "JavaScript Object Notation\n")
718e3744 7376{
db7c8528 7377 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, use_json(argc, argv));
718e3744 7378}
7379
f412b39a
DW
7380/*
7381 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9ccf14f7 7382 * "show bgp <view|vrf> WORD ipv6 summary [json]",
f412b39a
DW
7383 * SHOW_STR
7384 * BGP_STR
7385 * BGP_INSTANCE_HELP_STR
7386 * "Address family\n"
7387 * "Summary of BGP neighbor status\n"
7388 *
7389 */
718e3744 7390DEFUN (show_bgp_instance_summary,
7391 show_bgp_instance_summary_cmd,
9ccf14f7 7392 "show bgp <view|vrf> WORD summary [json]",
718e3744 7393 SHOW_STR
7394 BGP_STR
8386ac43 7395 BGP_INSTANCE_HELP_STR
b05a1c8b
DS
7396 "Summary of BGP neighbor status\n"
7397 "JavaScript Object Notation\n")
718e3744 7398{
c500ae40
DW
7399 int idx_word = 3;
7400 return bgp_show_summary_vty (vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, use_json(argc, argv));
718e3744 7401}
7402
f186de26 7403DEFUN (show_bgp_instance_all_summary,
7404 show_bgp_instance_all_summary_cmd,
9ccf14f7 7405 "show bgp <view|vrf> all summary [json]",
f186de26 7406 SHOW_STR
7407 BGP_STR
7408 BGP_INSTANCE_ALL_HELP_STR
7409 "Summary of BGP neighbor status\n"
7410 "JavaScript Object Notation\n")
7411{
7412 u_char uj = use_json(argc, argv);
7413
7414 bgp_show_all_instances_summary_vty (vty, AFI_IP6, SAFI_UNICAST, uj);
7415 return CMD_SUCCESS;
7416}
7417
718e3744 7418
718e3744 7419
95cbbd2a
ML
7420DEFUN (show_bgp_ipv6_safi_summary,
7421 show_bgp_ipv6_safi_summary_cmd,
6147e2c6 7422 "show bgp ipv6 <unicast|multicast> summary [json]",
95cbbd2a
ML
7423 SHOW_STR
7424 BGP_STR
7425 "Address family\n"
7426 "Address Family modifier\n"
7427 "Address Family modifier\n"
b05a1c8b
DS
7428 "Summary of BGP neighbor status\n"
7429 "JavaScript Object Notation\n")
95cbbd2a 7430{
c500ae40 7431 int idx_safi = 3;
db7c8528 7432 u_char uj = use_json(argc, argv);
c500ae40 7433 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
db7c8528 7434 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST, uj);
95cbbd2a 7435
db7c8528 7436 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, uj);
95cbbd2a
ML
7437}
7438
7439DEFUN (show_bgp_instance_ipv6_safi_summary,
7440 show_bgp_instance_ipv6_safi_summary_cmd,
9ccf14f7 7441 "show bgp <view|vrf> WORD ipv6 <unicast|multicast> summary [json]",
95cbbd2a
ML
7442 SHOW_STR
7443 BGP_STR
8386ac43 7444 BGP_INSTANCE_HELP_STR
95cbbd2a
ML
7445 "Address family\n"
7446 "Address Family modifier\n"
7447 "Address Family modifier\n"
b05a1c8b
DS
7448 "Summary of BGP neighbor status\n"
7449 "JavaScript Object Notation\n")
95cbbd2a 7450{
c500ae40
DW
7451 int idx_word = 3;
7452 int idx_safi = 5;
db7c8528 7453 u_char uj = use_json(argc, argv);
c500ae40
DW
7454 if (strncmp (argv[idx_safi]->arg, "m", 1) == 0)
7455 return bgp_show_summary_vty (vty, argv[idx_word]->arg, AFI_IP6, SAFI_MULTICAST, uj);
95cbbd2a 7456
c500ae40 7457 return bgp_show_summary_vty (vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, uj);
95cbbd2a
ML
7458}
7459
718e3744 7460/* old command */
f412b39a 7461DEFUN (show_ipv6_bgp_summary,
718e3744 7462 show_ipv6_bgp_summary_cmd,
b162fa78 7463 "show ipv6 bgp summary [json]",
718e3744 7464 SHOW_STR
7465 IPV6_STR
7466 BGP_STR
b05a1c8b
DS
7467 "Summary of BGP neighbor status\n"
7468 "JavaScript Object Notation\n")
718e3744 7469{
db7c8528
DS
7470 u_char uj = use_json(argc, argv);
7471 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, uj);
718e3744 7472}
7473
7474/* old command */
f412b39a 7475DEFUN (show_ipv6_mbgp_summary,
718e3744 7476 show_ipv6_mbgp_summary_cmd,
b162fa78 7477 "show ipv6 mbgp summary [json]",
718e3744 7478 SHOW_STR
7479 IPV6_STR
7480 MBGP_STR
b05a1c8b
DS
7481 "Summary of BGP neighbor status\n"
7482 "JavaScript Object Notation\n")
718e3744 7483{
db7c8528
DS
7484 u_char uj = use_json(argc, argv);
7485 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST, uj);
718e3744 7486}
7487#endif /* HAVE_IPV6 */
6b0655a2 7488
fd79ac91 7489const char *
538621f2 7490afi_safi_print (afi_t afi, safi_t safi)
7491{
7492 if (afi == AFI_IP && safi == SAFI_UNICAST)
7493 return "IPv4 Unicast";
7494 else if (afi == AFI_IP && safi == SAFI_MULTICAST)
7495 return "IPv4 Multicast";
7496 else if (afi == AFI_IP && safi == SAFI_MPLS_VPN)
945c8fe9 7497 return "VPN-IPv4 Unicast";
8b1fb8be
LB
7498 else if (afi == AFI_IP && safi == SAFI_ENCAP)
7499 return "ENCAP-IPv4 Unicast";
538621f2 7500 else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
7501 return "IPv6 Unicast";
7502 else if (afi == AFI_IP6 && safi == SAFI_MULTICAST)
7503 return "IPv6 Multicast";
945c8fe9
LB
7504 else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN)
7505 return "VPN-IPv6 Unicast";
8b1fb8be
LB
7506 else if (afi == AFI_IP6 && safi == SAFI_ENCAP)
7507 return "ENCAP-IPv6 Unicast";
538621f2 7508 else
7509 return "Unknown";
7510}
7511
718e3744 7512/* Show BGP peer's information. */
7513enum show_type
7514{
7515 show_all,
7516 show_peer
7517};
7518
94f2b392 7519static void
856ca177
MS
7520bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p, afi_t afi, safi_t safi,
7521 u_int16_t adv_smcap, u_int16_t adv_rmcap, u_int16_t rcv_smcap,
7522 u_int16_t rcv_rmcap, u_char use_json, json_object *json_pref)
718e3744 7523{
7524 /* Send-Mode */
7525 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)
7526 || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
7527 {
856ca177
MS
7528 if (use_json)
7529 {
7530 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
7531 json_object_string_add(json_pref, "sendMode", "advertisedAndReceived");
7532 else if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
7533 json_object_string_add(json_pref, "sendMode", "advertised");
7534 else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
7535 json_object_string_add(json_pref, "sendMode", "received");
7536 }
7537 else
7538 {
7539 vty_out (vty, " Send-mode: ");
7540 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
7541 vty_out (vty, "advertised");
7542 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
7543 vty_out (vty, "%sreceived",
7544 CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ?
7545 ", " : "");
7546 vty_out (vty, "%s", VTY_NEWLINE);
7547 }
718e3744 7548 }
7549
7550 /* Receive-Mode */
7551 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)
7552 || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
7553 {
856ca177
MS
7554 if (use_json)
7555 {
7556 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
7557 json_object_string_add(json_pref, "recvMode", "advertisedAndReceived");
7558 else if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
7559 json_object_string_add(json_pref, "recvMode", "advertised");
7560 else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
7561 json_object_string_add(json_pref, "recvMode", "received");
7562 }
7563 else
7564 {
7565 vty_out (vty, " Receive-mode: ");
7566 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
7567 vty_out (vty, "advertised");
7568 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
7569 vty_out (vty, "%sreceived",
7570 CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ?
7571 ", " : "");
7572 vty_out (vty, "%s", VTY_NEWLINE);
7573 }
718e3744 7574 }
7575}
7576
94f2b392 7577static void
856ca177
MS
7578bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi,
7579 u_char use_json, json_object *json_neigh)
718e3744 7580{
7581 struct bgp_filter *filter;
3f9c7369 7582 struct peer_af *paf;
718e3744 7583 char orf_pfx_name[BUFSIZ];
7584 int orf_pfx_count;
856ca177
MS
7585 json_object *json_af = NULL;
7586 json_object *json_prefA = NULL;
7587 json_object *json_prefB = NULL;
7588 json_object *json_addr = NULL;
718e3744 7589
856ca177
MS
7590 if (use_json)
7591 {
7592 json_addr = json_object_new_object();
7593 json_af = json_object_new_object();
7594 json_prefA = json_object_new_object();
7595 json_prefB = json_object_new_object();
7596 filter = &p->filter[afi][safi];
718e3744 7597
c8560b44 7598 if (peer_group_active(p))
856ca177 7599 json_object_string_add(json_addr, "peerGroupMember", p->group->name);
538621f2 7600
856ca177
MS
7601 paf = peer_af_find(p, afi, safi);
7602 if (paf && PAF_SUBGRP(paf))
7603 {
7604 json_object_int_add(json_addr, "updateGroupId", PAF_UPDGRP(paf)->id);
7605 json_object_int_add(json_addr, "subGroupId", PAF_SUBGRP(paf)->id);
7606 json_object_int_add(json_addr, "packetQueueLength", bpacket_queue_virtual_length(paf));
7607 }
7608
7609 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7610 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
7611 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7612 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
7613 {
7614 json_object_int_add(json_af, "orfType", ORF_TYPE_PREFIX);
7615 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
7616 PEER_CAP_ORF_PREFIX_SM_ADV,
7617 PEER_CAP_ORF_PREFIX_RM_ADV,
7618 PEER_CAP_ORF_PREFIX_SM_RCV,
7619 PEER_CAP_ORF_PREFIX_RM_RCV, use_json, json_prefA);
7620 json_object_object_add(json_af, "orfPrefixList", json_prefA);
7621 }
7622
7623 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7624 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
7625 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7626 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
7627 {
7628 json_object_int_add(json_af, "orfOldType", ORF_TYPE_PREFIX_OLD);
7629 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
7630 PEER_CAP_ORF_PREFIX_SM_ADV,
7631 PEER_CAP_ORF_PREFIX_RM_ADV,
7632 PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
7633 PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, json_prefB);
7634 json_object_object_add(json_af, "orfOldPrefixList", json_prefB);
7635 }
7636
7637 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7638 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
7639 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
7640 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7641 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
7642 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
7643 json_object_object_add(json_addr, "afDependentCap", json_af);
7644
7645 sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
7646 orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json);
7647
7648 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
7649 || orf_pfx_count)
7650 {
7651 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
7652 json_object_boolean_true_add(json_neigh, "orfSent");
7653 if (orf_pfx_count)
7654 json_object_int_add(json_addr, "orfRecvCounter", orf_pfx_count);
7655 }
7656 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
7657 json_object_string_add(json_addr, "orfFirstUpdate", "deferredUntilORFOrRouteRefreshRecvd");
7658
7659 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
7660 json_object_boolean_true_add(json_addr, "routeReflectorClient");
7661 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
7662 json_object_boolean_true_add(json_addr, "routeServerClient");
7663 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
7664 json_object_boolean_true_add(json_addr, "inboundSoftConfigPermit");
7665
88b8ed8d
DW
7666 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE))
7667 json_object_boolean_true_add(json_addr, "privateAsNumsAllReplacedInUpdatesToNbr");
7668 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE))
856ca177 7669 json_object_boolean_true_add(json_addr, "privateAsNumsReplacedInUpdatesToNbr");
88b8ed8d
DW
7670 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL))
7671 json_object_boolean_true_add(json_addr, "privateAsNumsAllRemovedInUpdatesToNbr");
856ca177
MS
7672 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
7673 json_object_boolean_true_add(json_addr, "privateAsNumsRemovedInUpdatesToNbr");
7674
adbac85e
DW
7675 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS))
7676 json_object_boolean_true_add(json_addr, "addpathTxAllPaths");
7677
06370dac
DW
7678 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS))
7679 json_object_boolean_true_add(json_addr, "addpathTxBestpathPerAS");
7680
856ca177
MS
7681 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE))
7682 json_object_string_add(json_addr, "overrideASNsInOutboundUpdates", "ifAspathEqualRemoteAs");
7683
7684 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) ||
7685 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF))
7686 json_object_boolean_true_add(json_addr, "routerAlwaysNextHop");
7687 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
7688 json_object_boolean_true_add(json_addr, "unchangedAsPathPropogatedToNbr");
7689 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
7690 json_object_boolean_true_add(json_addr, "unchangedNextHopPropogatedToNbr");
7691 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
7692 json_object_boolean_true_add(json_addr, "unchangedMedPropogatedToNbr");
718e3744 7693 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
856ca177
MS
7694 || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
7695 {
7696 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
7697 && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
7698 json_object_string_add(json_addr, "commAttriSentToNbr", "extendedAndStandard");
7699 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
7700 json_object_string_add(json_addr, "commAttriSentToNbr", "extended");
7701 else
7702 json_object_string_add(json_addr, "commAttriSentToNbr", "standard");
7703 }
7704 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
7705 {
7706 if (p->default_rmap[afi][safi].name)
7707 json_object_string_add(json_addr, "defaultRouteMap", p->default_rmap[afi][safi].name);
7708
7709 if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE))
7710 json_object_boolean_true_add(json_addr, "defaultSent");
7711 else
7712 json_object_boolean_true_add(json_addr, "defaultNotSent");
7713 }
7714
7715 if (filter->plist[FILTER_IN].name
7716 || filter->dlist[FILTER_IN].name
7717 || filter->aslist[FILTER_IN].name
7718 || filter->map[RMAP_IN].name)
7719 json_object_boolean_true_add(json_addr, "inboundPathPolicyConfig");
7720 if (filter->plist[FILTER_OUT].name
7721 || filter->dlist[FILTER_OUT].name
7722 || filter->aslist[FILTER_OUT].name
7723 || filter->map[RMAP_OUT].name
7724 || filter->usmap.name)
7725 json_object_boolean_true_add(json_addr, "outboundPathPolicyConfig");
856ca177
MS
7726
7727 /* prefix-list */
7728 if (filter->plist[FILTER_IN].name)
7729 json_object_string_add(json_addr, "incomingUpdatePrefixFilterList", filter->plist[FILTER_IN].name);
7730 if (filter->plist[FILTER_OUT].name)
7731 json_object_string_add(json_addr, "outgoingUpdatePrefixFilterList", filter->plist[FILTER_OUT].name);
7732
7733 /* distribute-list */
7734 if (filter->dlist[FILTER_IN].name)
7735 json_object_string_add(json_addr, "incomingUpdateNetworkFilterList", filter->dlist[FILTER_IN].name);
7736 if (filter->dlist[FILTER_OUT].name)
7737 json_object_string_add(json_addr, "outgoingUpdateNetworkFilterList", filter->dlist[FILTER_OUT].name);
7738
7739 /* filter-list. */
7740 if (filter->aslist[FILTER_IN].name)
7741 json_object_string_add(json_addr, "incomingUpdateAsPathFilterList", filter->aslist[FILTER_IN].name);
7742 if (filter->aslist[FILTER_OUT].name)
7743 json_object_string_add(json_addr, "outgoingUpdateAsPathFilterList", filter->aslist[FILTER_OUT].name);
7744
7745 /* route-map. */
7746 if (filter->map[RMAP_IN].name)
7747 json_object_string_add(json_addr, "routeMapForIncomingAdvertisements", filter->map[RMAP_IN].name);
7748 if (filter->map[RMAP_OUT].name)
7749 json_object_string_add(json_addr, "routeMapForOutgoingAdvertisements", filter->map[RMAP_OUT].name);
856ca177
MS
7750
7751 /* unsuppress-map */
7752 if (filter->usmap.name)
7753 json_object_string_add(json_addr, "selectiveUnsuppressRouteMap", filter->usmap.name);
7754
7755 /* Receive prefix count */
7756 json_object_int_add(json_addr, "acceptedPrefixCounter", p->pcount[afi][safi]);
7757
7758 /* Maximum prefix */
7759 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
7760 {
7761 json_object_int_add(json_addr, "prefixAllowedMax", p->pmax[afi][safi]);
7762 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING))
7763 json_object_boolean_true_add(json_addr, "prefixAllowedMaxWarning");
7764 json_object_int_add(json_addr, "prefixAllowedWarningThresh", p->pmax_threshold[afi][safi]);
7765 if (p->pmax_restart[afi][safi])
7766 json_object_int_add(json_addr, "prefixAllowedRestartIntervalMsecs", p->pmax_restart[afi][safi] * 60000);
7767 }
7768 json_object_object_add(json_neigh, afi_safi_print (afi, safi), json_addr);
7769
7770 }
7771 else
7772 {
7773 filter = &p->filter[afi][safi];
7774
7775 vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi),
7776 VTY_NEWLINE);
7777
c8560b44 7778 if (peer_group_active(p))
856ca177
MS
7779 vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE);
7780
7781 paf = peer_af_find(p, afi, safi);
7782 if (paf && PAF_SUBGRP(paf))
7783 {
7784 vty_out (vty, " Update group %" PRIu64 ", subgroup %" PRIu64 "%s",
7785 PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id, VTY_NEWLINE);
7786 vty_out (vty, " Packet Queue length %d%s",
7787 bpacket_queue_virtual_length(paf), VTY_NEWLINE);
7788 }
718e3744 7789 else
856ca177
MS
7790 {
7791 vty_out(vty, " Not part of any update group%s", VTY_NEWLINE);
7792 }
7793 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7794 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
7795 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
7796 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7797 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
7798 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
7799 vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE);
7800
7801 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7802 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
7803 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7804 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
7805 {
7806 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
7807 ORF_TYPE_PREFIX, VTY_NEWLINE);
7808 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
7809 PEER_CAP_ORF_PREFIX_SM_ADV,
7810 PEER_CAP_ORF_PREFIX_RM_ADV,
7811 PEER_CAP_ORF_PREFIX_SM_RCV,
7812 PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL);
7813 }
7814 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7815 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
7816 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7817 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
7818 {
7819 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
7820 ORF_TYPE_PREFIX_OLD, VTY_NEWLINE);
7821 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
7822 PEER_CAP_ORF_PREFIX_SM_ADV,
7823 PEER_CAP_ORF_PREFIX_RM_ADV,
7824 PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
7825 PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL);
7826 }
718e3744 7827
856ca177
MS
7828 sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
7829 orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json);
718e3744 7830
856ca177
MS
7831 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
7832 || orf_pfx_count)
7833 {
7834 vty_out (vty, " Outbound Route Filter (ORF):");
7835 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
7836 vty_out (vty, " sent;");
7837 if (orf_pfx_count)
7838 vty_out (vty, " received (%d entries)", orf_pfx_count);
7839 vty_out (vty, "%s", VTY_NEWLINE);
7840 }
7841 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
7842 vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE);
7843
7844 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
7845 vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE);
7846 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
7847 vty_out (vty, " Route-Server Client%s", VTY_NEWLINE);
7848 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
7849 vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE);
7850
88b8ed8d
DW
7851 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE))
7852 vty_out (vty, " Private AS numbers (all) replaced in updates to this neighbor%s", VTY_NEWLINE);
7853 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE))
856ca177 7854 vty_out (vty, " Private AS numbers replaced in updates to this neighbor%s", VTY_NEWLINE);
88b8ed8d
DW
7855 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL))
7856 vty_out (vty, " Private AS numbers (all) removed in updates to this neighbor%s", VTY_NEWLINE);
856ca177
MS
7857 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
7858 vty_out (vty, " Private AS numbers removed in updates to this neighbor%s", VTY_NEWLINE);
7859
adbac85e
DW
7860 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS))
7861 vty_out (vty, " Advertise all paths via addpath%s", VTY_NEWLINE);
7862
06370dac
DW
7863 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS))
7864 vty_out (vty, " Advertise bestpath per AS via addpath%s", VTY_NEWLINE);
7865
856ca177
MS
7866 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE))
7867 vty_out (vty, " Override ASNs in outbound updates if aspath equals remote-as%s", VTY_NEWLINE);
7868
7869 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) ||
7870 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF))
7871 vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE);
7872 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
7873 vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE);
7874 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
7875 vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE);
7876 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
7877 vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE);
7878 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
7879 || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
7880 {
7881 vty_out (vty, " Community attribute sent to this neighbor");
7882 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
7883 && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
7884 vty_out (vty, "(both)%s", VTY_NEWLINE);
7885 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
7886 vty_out (vty, "(extended)%s", VTY_NEWLINE);
7887 else
7888 vty_out (vty, "(standard)%s", VTY_NEWLINE);
7889 }
7890 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
7891 {
7892 vty_out (vty, " Default information originate,");
7893
7894 if (p->default_rmap[afi][safi].name)
7895 vty_out (vty, " default route-map %s%s,",
7896 p->default_rmap[afi][safi].map ? "*" : "",
7897 p->default_rmap[afi][safi].name);
7898 if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE))
7899 vty_out (vty, " default sent%s", VTY_NEWLINE);
7900 else
7901 vty_out (vty, " default not sent%s", VTY_NEWLINE);
7902 }
718e3744 7903
856ca177
MS
7904 if (filter->plist[FILTER_IN].name
7905 || filter->dlist[FILTER_IN].name
7906 || filter->aslist[FILTER_IN].name
7907 || filter->map[RMAP_IN].name)
7908 vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE);
7909 if (filter->plist[FILTER_OUT].name
7910 || filter->dlist[FILTER_OUT].name
7911 || filter->aslist[FILTER_OUT].name
7912 || filter->map[RMAP_OUT].name
7913 || filter->usmap.name)
7914 vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE);
856ca177
MS
7915
7916 /* prefix-list */
7917 if (filter->plist[FILTER_IN].name)
7918 vty_out (vty, " Incoming update prefix filter list is %s%s%s",
7919 filter->plist[FILTER_IN].plist ? "*" : "",
7920 filter->plist[FILTER_IN].name,
7921 VTY_NEWLINE);
7922 if (filter->plist[FILTER_OUT].name)
7923 vty_out (vty, " Outgoing update prefix filter list is %s%s%s",
7924 filter->plist[FILTER_OUT].plist ? "*" : "",
7925 filter->plist[FILTER_OUT].name,
7926 VTY_NEWLINE);
7927
7928 /* distribute-list */
7929 if (filter->dlist[FILTER_IN].name)
7930 vty_out (vty, " Incoming update network filter list is %s%s%s",
7931 filter->dlist[FILTER_IN].alist ? "*" : "",
7932 filter->dlist[FILTER_IN].name,
7933 VTY_NEWLINE);
7934 if (filter->dlist[FILTER_OUT].name)
7935 vty_out (vty, " Outgoing update network filter list is %s%s%s",
7936 filter->dlist[FILTER_OUT].alist ? "*" : "",
7937 filter->dlist[FILTER_OUT].name,
7938 VTY_NEWLINE);
7939
7940 /* filter-list. */
7941 if (filter->aslist[FILTER_IN].name)
7942 vty_out (vty, " Incoming update AS path filter list is %s%s%s",
7943 filter->aslist[FILTER_IN].aslist ? "*" : "",
7944 filter->aslist[FILTER_IN].name,
7945 VTY_NEWLINE);
7946 if (filter->aslist[FILTER_OUT].name)
7947 vty_out (vty, " Outgoing update AS path filter list is %s%s%s",
7948 filter->aslist[FILTER_OUT].aslist ? "*" : "",
7949 filter->aslist[FILTER_OUT].name,
7950 VTY_NEWLINE);
7951
7952 /* route-map. */
7953 if (filter->map[RMAP_IN].name)
7954 vty_out (vty, " Route map for incoming advertisements is %s%s%s",
7955 filter->map[RMAP_IN].map ? "*" : "",
7956 filter->map[RMAP_IN].name,
7957 VTY_NEWLINE);
7958 if (filter->map[RMAP_OUT].name)
7959 vty_out (vty, " Route map for outgoing advertisements is %s%s%s",
7960 filter->map[RMAP_OUT].map ? "*" : "",
7961 filter->map[RMAP_OUT].name,
7962 VTY_NEWLINE);
856ca177
MS
7963
7964 /* unsuppress-map */
7965 if (filter->usmap.name)
7966 vty_out (vty, " Route map for selective unsuppress is %s%s%s",
7967 filter->usmap.map ? "*" : "",
7968 filter->usmap.name, VTY_NEWLINE);
7969
7970 /* Receive prefix count */
7971 vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE);
7972
7973 /* Maximum prefix */
7974 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
7975 {
7976 vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi],
7977 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)
7978 ? " (warning-only)" : "", VTY_NEWLINE);
7979 vty_out (vty, " Threshold for warning message %d%%",
7980 p->pmax_threshold[afi][safi]);
7981 if (p->pmax_restart[afi][safi])
7982 vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]);
7983 vty_out (vty, "%s", VTY_NEWLINE);
7984 }
718e3744 7985
0a486e5f 7986 vty_out (vty, "%s", VTY_NEWLINE);
718e3744 7987 }
718e3744 7988}
7989
94f2b392 7990static void
e8f7da3a 7991bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *json)
718e3744 7992{
7993 struct bgp *bgp;
4690c7d7 7994 char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN];
718e3744 7995 char timebuf[BGP_UPTIME_LEN];
f14e6fdb 7996 char dn_flag[2];
3a8c7ba1
DW
7997 const char *subcode_str;
7998 const char *code_str;
538621f2 7999 afi_t afi;
8000 safi_t safi;
d6661008
DS
8001 u_int16_t i;
8002 u_char *msg;
e8f7da3a 8003 json_object *json_neigh = NULL;
718e3744 8004
8005 bgp = p->bgp;
8006
e8f7da3a
DW
8007 if (use_json)
8008 json_neigh = json_object_new_object();
8009
856ca177 8010 if (!use_json)
f14e6fdb 8011 {
856ca177
MS
8012 if (p->conf_if) /* Configured interface name. */
8013 vty_out (vty, "BGP neighbor on %s: %s, ", p->conf_if,
8014 BGP_PEER_SU_UNSPEC(p) ? "None" :
8015 sockunion2str (&p->su, buf, SU_ADDRSTRLEN));
8016 else /* Configured IP address. */
8017 {
8018 memset(dn_flag, '\0', sizeof(dn_flag));
8019 if (peer_dynamic_neighbor(p))
8020 dn_flag[0] = '*';
f14e6fdb 8021
856ca177
MS
8022 vty_out (vty, "BGP neighbor is %s%s, ", dn_flag, p->host);
8023 }
f14e6fdb
DS
8024 }
8025
856ca177
MS
8026 if (use_json)
8027 {
8028 if (p->conf_if && BGP_PEER_SU_UNSPEC(p))
8029 json_object_string_add(json_neigh, "bgpNeighborAddr", "none");
8030 else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p))
8031 json_object_string_add(json_neigh, "bgpNeighborAddr", sockunion2str (&p->su, buf, SU_ADDRSTRLEN));
8032
8033 json_object_int_add(json_neigh, "remoteAs", p->as);
8034
8035 if (p->change_local_as)
8036 json_object_int_add(json_neigh, "localAs", p->change_local_as);
8037 else
8038 json_object_int_add(json_neigh, "localAs", p->local_as);
8039
8040 if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND))
8041 json_object_boolean_true_add(json_neigh, "localAsNoPrepend");
66b199b2 8042
856ca177
MS
8043 if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS))
8044 json_object_boolean_true_add(json_neigh, "localAsReplaceAs");
8045 }
8046 else
8047 {
f8cfafda
DS
8048 if ((p->as_type == AS_SPECIFIED) ||
8049 (p->as_type == AS_EXTERNAL) ||
8050 (p->as_type == AS_INTERNAL))
8051 vty_out (vty, "remote AS %u, ", p->as);
8052 else
8053 vty_out (vty, "remote AS Unspecified, ");
856ca177
MS
8054 vty_out (vty, "local AS %u%s%s, ",
8055 p->change_local_as ? p->change_local_as : p->local_as,
8056 CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ?
8057 " no-prepend" : "",
8058 CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) ?
8059 " replace-as" : "");
8060 }
66b199b2
DS
8061 /* peer type internal, external, confed-internal or confed-external */
8062 if (p->as == p->local_as)
8063 {
856ca177
MS
8064 if (use_json)
8065 {
8066 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
8067 json_object_boolean_true_add(json_neigh, "nbrConfedInternalLink");
8068 else
8069 json_object_boolean_true_add(json_neigh, "nbrInternalLink");
8070 }
66b199b2 8071 else
856ca177
MS
8072 {
8073 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
8074 vty_out (vty, "confed-internal link%s", VTY_NEWLINE);
8075 else
8076 vty_out (vty, "internal link%s", VTY_NEWLINE);
8077 }
66b199b2
DS
8078 }
8079 else
8080 {
856ca177
MS
8081 if (use_json)
8082 {
8083 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
8084 json_object_boolean_true_add(json_neigh, "nbrConfedExternalLink");
8085 else
8086 json_object_boolean_true_add(json_neigh, "nbrExternalLink");
8087 }
66b199b2 8088 else
856ca177
MS
8089 {
8090 if (bgp_confederation_peers_check(bgp, p->as))
8091 vty_out (vty, "confed-external link%s", VTY_NEWLINE);
8092 else
8093 vty_out (vty, "external link%s", VTY_NEWLINE);
8094 }
66b199b2 8095 }
718e3744 8096
8097 /* Description. */
8098 if (p->desc)
856ca177
MS
8099 {
8100 if (use_json)
8101 json_object_string_add(json_neigh, "nbrDesc", p->desc);
8102 else
8103 vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE);
8104 }
6410e93a 8105
04b6bdc0
DW
8106 if (p->hostname)
8107 {
d1570739
DW
8108 if (use_json)
8109 {
8110 if (p->hostname)
8111 json_object_string_add(json_neigh, "hostname", p->hostname);
8112
8113 if (p->domainname)
8114 json_object_string_add(json_neigh, "domainname", p->domainname);
8115 }
04b6bdc0 8116 else
d1570739
DW
8117 {
8118 if (p->domainname && (p->domainname[0] != '\0'))
8119 vty_out(vty, "Hostname: %s.%s%s", p->hostname, p->domainname,
8120 VTY_NEWLINE);
8121 else
8122 vty_out(vty, "Hostname: %s%s", p->hostname, VTY_NEWLINE);
8123 }
8124
04b6bdc0
DW
8125 }
8126
c744aa9f 8127 /* Peer-group */
718e3744 8128 if (p->group)
f14e6fdb 8129 {
856ca177
MS
8130 if (use_json)
8131 {
8132 json_object_string_add(json_neigh, "peerGroup", p->group->name);
8133
8134 if (dn_flag[0])
8135 {
40ee54a7 8136 struct prefix prefix, *range = NULL;
f14e6fdb 8137
40ee54a7
TT
8138 sockunion2hostprefix(&(p->su), &prefix);
8139 range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix);
856ca177
MS
8140
8141 if (range)
8142 {
8143 prefix2str(range, buf1, sizeof(buf1));
8144 json_object_string_add(json_neigh, "peerSubnetRangeGroup", buf1);
8145 }
8146 }
8147 }
8148 else
f14e6fdb 8149 {
856ca177
MS
8150 vty_out (vty, " Member of peer-group %s for session parameters%s",
8151 p->group->name, VTY_NEWLINE);
f14e6fdb 8152
856ca177 8153 if (dn_flag[0])
f14e6fdb 8154 {
40ee54a7 8155 struct prefix prefix, *range = NULL;
856ca177 8156
40ee54a7
TT
8157 sockunion2hostprefix(&(p->su), &prefix);
8158 range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix);
856ca177
MS
8159
8160 if (range)
8161 {
8162 prefix2str(range, buf1, sizeof(buf1));
8163 vty_out (vty, " Belongs to the subnet range group: %s%s", buf1, VTY_NEWLINE);
8164 }
f14e6fdb
DS
8165 }
8166 }
8167 }
718e3744 8168
856ca177
MS
8169 if (use_json)
8170 {
8171 /* Administrative shutdown. */
8172 if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
8173 json_object_boolean_true_add(json_neigh, "adminShutDown");
718e3744 8174
856ca177
MS
8175 /* BGP Version. */
8176 json_object_int_add(json_neigh, "bgpVersion", 4);
8177 json_object_string_add(json_neigh, "remoteRouterId", inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ));
718e3744 8178
856ca177
MS
8179 /* Confederation */
8180 if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) && bgp_confederation_peers_check (bgp, p->as))
8181 json_object_boolean_true_add(json_neigh, "nbrCommonAdmin");
8182
8183 /* Status. */
8184 json_object_string_add(json_neigh, "bgpState", LOOKUP (bgp_status_msg, p->status));
8185
8186 if (p->status == Established)
8187 {
8188 time_t uptime;
8189 struct tm *tm;
8190
8191 uptime = bgp_clock();
8192 uptime -= p->uptime;
8193 tm = gmtime(&uptime);
8194
8195 json_object_int_add(json_neigh, "bgpTimerUp", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
8196 }
8197
8198 else if (p->status == Active)
8199 {
8200 if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE))
8201 json_object_string_add(json_neigh, "bgpStateIs", "passive");
8202 else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT))
8203 json_object_string_add(json_neigh, "bgpStateIs", "passiveNSF");
8204 }
8205
8206 /* read timer */
8207 time_t uptime;
8208 struct tm *tm;
8209
8210 uptime = bgp_clock();
8211 uptime -= p->readtime;
8212 tm = gmtime(&uptime);
8213 json_object_int_add(json_neigh, "bgpTimerLastRead", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
8214
8215 uptime = bgp_clock();
8216 uptime -= p->last_write;
8217 tm = gmtime(&uptime);
39e871e6
ST
8218 json_object_int_add(json_neigh, "bgpTimerLastWrite", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
8219
8220 uptime = bgp_clock();
8221 uptime -= p->update_time;
8222 tm = gmtime(&uptime);
8223 json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs",
8224 (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
856ca177
MS
8225
8226 /* Configured timer values. */
8227 json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", p->v_holdtime * 1000);
8228 json_object_int_add(json_neigh, "bgpTimerKeepAliveIntervalMsecs", p->v_keepalive * 1000);
8229
8230 if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
8231 {
8232 json_object_int_add(json_neigh, "bgpTimerConfiguredHoldTimeMsecs", p->holdtime * 1000);
8233 json_object_int_add(json_neigh, "bgpTimerConfiguredKeepAliveIntervalMsecs", p->keepalive * 1000);
8234 }
93406d87 8235 }
856ca177
MS
8236 else
8237 {
8238 /* Administrative shutdown. */
8239 if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
8240 vty_out (vty, " Administratively shut down%s", VTY_NEWLINE);
8241
8242 /* BGP Version. */
8243 vty_out (vty, " BGP version 4");
8244 vty_out (vty, ", remote router ID %s%s", inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ),
8245 VTY_NEWLINE);
8246
8247 /* Confederation */
8248 if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION)
8249 && bgp_confederation_peers_check (bgp, p->as))
8250 vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE);
718e3744 8251
856ca177
MS
8252 /* Status. */
8253 vty_out (vty, " BGP state = %s", LOOKUP (bgp_status_msg, p->status));
718e3744 8254
856ca177
MS
8255 if (p->status == Established)
8256 vty_out (vty, ", up for %8s", peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL));
8257
8258 else if (p->status == Active)
8259 {
8260 if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE))
8261 vty_out (vty, " (passive)");
8262 else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT))
8263 vty_out (vty, " (NSF passive)");
8264 }
8265 vty_out (vty, "%s", VTY_NEWLINE);
93406d87 8266
856ca177
MS
8267 /* read timer */
8268 vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN, 0, NULL));
8269 vty_out (vty, ", Last write %s%s",
8270 peer_uptime (p->last_write, timebuf, BGP_UPTIME_LEN, 0, NULL), VTY_NEWLINE);
8271
8272 /* Configured timer values. */
8273 vty_out (vty, " Hold time is %d, keepalive interval is %d seconds%s",
8274 p->v_holdtime, p->v_keepalive, VTY_NEWLINE);
8275 if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
8276 {
8277 vty_out (vty, " Configured hold time is %d", p->holdtime);
8278 vty_out (vty, ", keepalive interval is %d seconds%s",
8279 p->keepalive, VTY_NEWLINE);
8280 }
8281 }
718e3744 8282 /* Capability. */
8283 if (p->status == Established)
8284 {
538621f2 8285 if (p->cap
718e3744 8286 || p->afc_adv[AFI_IP][SAFI_UNICAST]
8287 || p->afc_recv[AFI_IP][SAFI_UNICAST]
8288 || p->afc_adv[AFI_IP][SAFI_MULTICAST]
8289 || p->afc_recv[AFI_IP][SAFI_MULTICAST]
8290#ifdef HAVE_IPV6
8291 || p->afc_adv[AFI_IP6][SAFI_UNICAST]
8292 || p->afc_recv[AFI_IP6][SAFI_UNICAST]
8293 || p->afc_adv[AFI_IP6][SAFI_MULTICAST]
8294 || p->afc_recv[AFI_IP6][SAFI_MULTICAST]
945c8fe9
LB
8295 || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN]
8296 || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN]
8b1fb8be
LB
8297 || p->afc_adv[AFI_IP6][SAFI_ENCAP]
8298 || p->afc_recv[AFI_IP6][SAFI_ENCAP]
718e3744 8299#endif /* HAVE_IPV6 */
8b1fb8be
LB
8300 || p->afc_adv[AFI_IP][SAFI_ENCAP]
8301 || p->afc_recv[AFI_IP][SAFI_ENCAP]
718e3744 8302 || p->afc_adv[AFI_IP][SAFI_MPLS_VPN]
8303 || p->afc_recv[AFI_IP][SAFI_MPLS_VPN])
8304 {
856ca177
MS
8305 if (use_json)
8306 {
8307 json_object *json_cap = NULL;
8308
8309 json_cap = json_object_new_object();
8310
8311 /* AS4 */
8312 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)
8313 || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
8314 {
8315 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) && CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
8316 json_object_string_add(json_cap, "4byteAs", "advertisedAndReceived");
8317 else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
8318 json_object_string_add(json_cap, "4byteAs", "advertised");
8319 else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
8320 json_object_string_add(json_cap, "4byteAs", "received");
8321 }
8322
8323 /* AddPath */
8324 if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV)
8325 || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV))
8326 {
8327 json_object *json_add = NULL;
8328 const char *print_store;
718e3744 8329
856ca177 8330 json_add = json_object_new_object();
a82478b9 8331
856ca177
MS
8332 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8333 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8334 {
8335 json_object *json_sub = NULL;
8336 json_sub = json_object_new_object();
8337 print_store = afi_safi_print (afi, safi);
8338
8339 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ||
8340 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
8341 {
8342 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))
8343 json_object_boolean_true_add(json_sub, "txAdvertisedAndReceived");
8344 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV))
8345 json_object_boolean_true_add(json_sub, "txAdvertised");
8346 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
8347 json_object_boolean_true_add(json_sub, "txReceived");
8348 }
8349
8350 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
8351 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
8352 {
8353 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))
8354 json_object_boolean_true_add(json_sub, "rxAdvertisedAndReceived");
8355 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV))
8356 json_object_boolean_true_add(json_sub, "rxAdvertised");
8357 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
8358 json_object_boolean_true_add(json_sub, "rxReceived");
8359 }
8360
8361 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ||
8362 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV) ||
8363 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
8364 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
8365 json_object_object_add(json_add, print_store, json_sub);
8366 }
a82478b9 8367
856ca177
MS
8368 json_object_object_add(json_cap, "addPath", json_add);
8369 }
8370
8371 /* Dynamic */
8372 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
8373 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
8374 {
8375 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) && CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
8376 json_object_string_add(json_cap, "dynamic", "advertisedAndReceived");
8377 else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
8378 json_object_string_add(json_cap, "dynamic", "advertised");
8379 else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
8380 json_object_string_add(json_cap, "dynamic", "received");
8381 }
8382
8383 /* Extended nexthop */
8384 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)
8385 || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
8386 {
8387 json_object *json_nxt = NULL;
8388 const char *print_store;
8389
8390 json_nxt = json_object_new_object();
8391
8392 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) && CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
8393 json_object_string_add(json_cap, "extendedNexthop", "advertisedAndReceived");
8394 else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
8395 json_object_string_add(json_cap, "extendedNexthop", "advertised");
8396 else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
8397 json_object_string_add(json_cap, "extendedNexthop", "received");
8398
8399 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
8400 {
8401 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8402 {
8403 if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV))
8404 {
8405 print_store = afi_safi_print (AFI_IP, safi);
8406 json_object_string_add(json_nxt, print_store, "recieved");
8407 }
8408 }
8409 json_object_object_add(json_cap, "extendedNexthopFamililesByPeer", json_nxt);
8410 }
8411 }
8412
8413 /* Route Refresh */
8414 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
8415 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
8416 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
8417 {
8418 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)))
8419 {
8420 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV))
8421 json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOldNew");
8422 else
8423 {
8424 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
8425 json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOld");
8426 else
8427 json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedNew");
8428 }
8429 }
8430 else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
8431 json_object_string_add(json_cap, "routeRefresh", "advertised");
8432 else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
8433 json_object_string_add(json_cap, "routeRefresh", "received");
8434 }
8435
8436 /* Multiprotocol Extensions */
8437 json_object *json_multi = NULL;
8438 json_multi = json_object_new_object();
8439
8440 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8441 {
8442 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8443 {
8444 if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
8445 {
8446 json_object *json_exten = NULL;
8447 json_exten = json_object_new_object();
8448
8449 if (p->afc_adv[afi][safi] && p->afc_recv[afi][safi])
8450 json_object_boolean_true_add(json_exten, "advertisedAndReceived");
8451 else if (p->afc_adv[afi][safi])
8452 json_object_boolean_true_add(json_exten, "advertised");
8453 else if (p->afc_recv[afi][safi])
8454 json_object_boolean_true_add(json_exten, "received");
8455
8456 json_object_object_add(json_multi, afi_safi_print (afi, safi), json_exten);
8457 }
8458 }
8459 }
8460 json_object_object_add(json_cap, "multiprotocolExtensions", json_multi);
8461
8462 /* Gracefull Restart */
8463 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
8464 || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
8465 {
8466 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) && CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
8467 json_object_string_add(json_cap, "gracefulRestart", "advertisedAndReceived");
8468 else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
8469 json_object_string_add(json_cap, "gracefulRestartCapability", "advertised");
8470 else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
8471 json_object_string_add(json_cap, "gracefulRestartCapability", "received");
8472
8473 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
8474 {
8475 int restart_af_count = 0;
8476 json_object *json_restart = NULL;
8477 json_restart = json_object_new_object();
8478
8479 json_object_int_add(json_cap, "gracefulRestartRemoteTimerMsecs", p->v_gr_restart * 1000);
8480
8481 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8482 {
8483 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8484 {
8485 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
8486 {
8487 json_object *json_sub = NULL;
8488 json_sub = json_object_new_object();
8489
8490 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV))
8491 json_object_boolean_true_add(json_sub, "preserved");
8492 restart_af_count++;
8493 json_object_object_add(json_restart, afi_safi_print (afi, safi), json_sub);
8494 }
8495 }
8496 }
8497 if (! restart_af_count)
8498 json_object_string_add(json_cap, "addressFamiliesByPeer", "none");
8499 else
8500 json_object_object_add(json_cap, "addressFamiliesByPeer", json_restart);
8501 }
8502 }
8503 json_object_object_add(json_neigh, "neighborCapabilities", json_cap);
8504 }
8505 else
8506 {
8507 vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE);
8508
8509 /* AS4 */
8510 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)
8511 || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
8512 {
8513 vty_out (vty, " 4 Byte AS:");
8514 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
8515 vty_out (vty, " advertised");
8516 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
8517 vty_out (vty, " %sreceived",
8518 CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : "");
8519 vty_out (vty, "%s", VTY_NEWLINE);
8520 }
8521
8522 /* AddPath */
8523 if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV)
8524 || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV))
8525 {
8526 vty_out (vty, " AddPath:%s", VTY_NEWLINE);
a82478b9 8527
856ca177
MS
8528 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8529 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
a82478b9 8530 {
856ca177
MS
8531 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ||
8532 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
8533 {
8534 vty_out (vty, " %s: TX ", afi_safi_print (afi, safi));
a82478b9 8535
856ca177
MS
8536 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV))
8537 vty_out (vty, "advertised %s", afi_safi_print (afi, safi));
a82478b9 8538
856ca177
MS
8539 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
8540 vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ? " and " : "" );
a82478b9 8541
856ca177
MS
8542 vty_out (vty, "%s", VTY_NEWLINE);
8543 }
a82478b9 8544
856ca177 8545 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
a82478b9 8546 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
856ca177
MS
8547 {
8548 vty_out (vty, " %s: RX ", afi_safi_print (afi, safi));
a82478b9 8549
856ca177
MS
8550 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV))
8551 vty_out (vty, "advertised %s", afi_safi_print (afi, safi));
a82478b9 8552
856ca177
MS
8553 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
8554 vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ? " and " : "" );
a82478b9 8555
856ca177
MS
8556 vty_out (vty, "%s", VTY_NEWLINE);
8557 }
a82478b9 8558 }
856ca177 8559 }
a82478b9 8560
856ca177
MS
8561 /* Dynamic */
8562 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
8563 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
8564 {
8565 vty_out (vty, " Dynamic:");
8566 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
8567 vty_out (vty, " advertised");
8568 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
8569 vty_out (vty, " %sreceived",
8570 CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : "");
8571 vty_out (vty, "%s", VTY_NEWLINE);
8572 }
8573
8574 /* Extended nexthop */
8575 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)
8576 || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
8577 {
8578 vty_out (vty, " Extended nexthop:");
8579 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
8580 vty_out (vty, " advertised");
8581 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
8582 vty_out (vty, " %sreceived",
8583 CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) ? "and " : "");
8584 vty_out (vty, "%s", VTY_NEWLINE);
718e3744 8585
856ca177
MS
8586 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
8587 {
8588 vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE);
8589 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8590 if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV))
8591 vty_out (vty, " %s%s",
8592 afi_safi_print (AFI_IP, safi), VTY_NEWLINE);
8593 }
8594 }
8a92a8a0 8595
856ca177
MS
8596 /* Route Refresh */
8597 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
8598 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
8599 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
8600 {
8601 vty_out (vty, " Route refresh:");
8602 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
8603 vty_out (vty, " advertised");
8604 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
8605 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
8606 vty_out (vty, " %sreceived(%s)",
8607 CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "",
8608 (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)
8609 && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ?
8610 "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new");
8a92a8a0 8611
856ca177
MS
8612 vty_out (vty, "%s", VTY_NEWLINE);
8613 }
718e3744 8614
856ca177
MS
8615 /* Multiprotocol Extensions */
8616 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8617 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8618 if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
8619 {
8620 vty_out (vty, " Address family %s:", afi_safi_print (afi, safi));
8621 if (p->afc_adv[afi][safi])
8622 vty_out (vty, " advertised");
8623 if (p->afc_recv[afi][safi])
8624 vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : "");
8625 vty_out (vty, "%s", VTY_NEWLINE);
8626 }
538621f2 8627
04b6bdc0
DW
8628 /* Hostname capability */
8629 if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV) ||
8630 CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV))
8631 {
8632 vty_out (vty, " Hostname Capability:");
8633 if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV))
8634 vty_out (vty, " advertised");
8635 if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_RCV))
8636 vty_out (vty, " %sreceived",
8637 CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV) ? "and " : "");
8638 vty_out (vty, "%s", VTY_NEWLINE);
8639 }
8640
856ca177
MS
8641 /* Gracefull Restart */
8642 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
8643 || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
8644 {
8645 vty_out (vty, " Graceful Restart Capabilty:");
8646 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
538621f2 8647 vty_out (vty, " advertised");
856ca177
MS
8648 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
8649 vty_out (vty, " %sreceived",
8650 CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : "");
8651 vty_out (vty, "%s", VTY_NEWLINE);
538621f2 8652
856ca177
MS
8653 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
8654 {
8655 int restart_af_count = 0;
8656
8657 vty_out (vty, " Remote Restart timer is %d seconds%s",
8658 p->v_gr_restart, VTY_NEWLINE);
8659 vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE);
8660
8661 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8662 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8663 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
8664 {
8665 vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "",
8666 afi_safi_print (afi, safi),
8667 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ?
8668 "preserved" : "not preserved");
8669 restart_af_count++;
8670 }
8671 if (! restart_af_count)
8672 vty_out (vty, "none");
8673 vty_out (vty, "%s", VTY_NEWLINE);
8674 }
8675 }
8676 }
718e3744 8677 }
8678 }
8679
93406d87 8680 /* graceful restart information */
8681 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
8682 || p->t_gr_restart
8683 || p->t_gr_stale)
8684 {
856ca177
MS
8685 json_object *json_grace = NULL;
8686 json_object *json_grace_send = NULL;
8687 json_object *json_grace_recv = NULL;
93406d87 8688 int eor_send_af_count = 0;
8689 int eor_receive_af_count = 0;
8690
856ca177
MS
8691 if (use_json)
8692 {
8693 json_grace = json_object_new_object();
8694 json_grace_send = json_object_new_object();
8695 json_grace_recv = json_object_new_object();
8696
8697 if (p->status == Established)
8698 {
8699 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8700 {
8701 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8702 {
8703 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND))
8704 {
8705 json_object_boolean_true_add(json_grace_send, afi_safi_print (afi, safi));
8706 eor_send_af_count++;
8707 }
8708 }
8709 }
8710 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8711 {
8712 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8713 {
8714 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED))
8715 {
8716 json_object_boolean_true_add(json_grace_recv, afi_safi_print (afi, safi));
8717 eor_receive_af_count++;
8718 }
8719 }
8720 }
8721 }
8722
8723 json_object_object_add(json_grace, "endOfRibSend", json_grace_send);
8724 json_object_object_add(json_grace, "endOfRibRecv", json_grace_recv);
8725
8726 if (p->t_gr_restart)
8727 json_object_int_add(json_grace, "gracefulRestartTimerMsecs", thread_timer_remain_second (p->t_gr_restart) * 1000);
8728
8729 if (p->t_gr_stale)
8730 json_object_int_add(json_grace, "gracefulStalepathTimerMsecs", thread_timer_remain_second (p->t_gr_stale) * 1000);
8731
8732 json_object_object_add(json_neigh, "gracefulRestartInfo", json_grace);
8733 }
8734 else
8735 {
8736 vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE);
8737 if (p->status == Established)
8738 {
8739 vty_out (vty, " End-of-RIB send: ");
8740 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8741 {
8742 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8743 {
8744 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND))
8745 {
8746 vty_out (vty, "%s%s", eor_send_af_count ? ", " : "",
8747 afi_safi_print (afi, safi));
8748 eor_send_af_count++;
8749 }
8750 }
8751 }
8752 vty_out (vty, "%s", VTY_NEWLINE);
8753 vty_out (vty, " End-of-RIB received: ");
8754 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8755 {
8756 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8757 {
8758 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED))
8759 {
8760 vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "",
8761 afi_safi_print (afi, safi));
8762 eor_receive_af_count++;
8763 }
8764 }
8765 }
8766 vty_out (vty, "%s", VTY_NEWLINE);
8767 }
93406d87 8768
856ca177
MS
8769 if (p->t_gr_restart)
8770 vty_out (vty, " The remaining time of restart timer is %ld%s",
8771 thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE);
0b2aa3a0 8772
856ca177
MS
8773 if (p->t_gr_stale)
8774 vty_out (vty, " The remaining time of stalepath timer is %ld%s",
8775 thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE);
8776 }
8777 }
8778 if (use_json)
8779 {
8780 json_object *json_stat = NULL;
8781 json_stat = json_object_new_object();
8782 /* Packet counts. */
8783 json_object_int_add(json_stat, "depthInq", 0);
8784 json_object_int_add(json_stat, "depthOutq", (unsigned long) p->obuf->count);
8785 json_object_int_add(json_stat, "opensSent", p->open_out);
8786 json_object_int_add(json_stat, "opensRecv", p->open_in);
8787 json_object_int_add(json_stat, "notificationsSent", p->notify_out);
8788 json_object_int_add(json_stat, "notificationsRecv", p->notify_in);
8789 json_object_int_add(json_stat, "updatesSent", p->update_out);
8790 json_object_int_add(json_stat, "updatesRecv", p->update_in);
8791 json_object_int_add(json_stat, "keepalivesSent", p->keepalive_out);
8792 json_object_int_add(json_stat, "keepalivesRecv", p->keepalive_in);
8793 json_object_int_add(json_stat, "routeRefreshSent", p->refresh_out);
8794 json_object_int_add(json_stat, "routeRefreshRecv", p->refresh_in);
8795 json_object_int_add(json_stat, "capabilitySent", p->dynamic_cap_out);
8796 json_object_int_add(json_stat, "capabilityRecv", p->dynamic_cap_in);
8797 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);
8798 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);
8799 json_object_object_add(json_neigh, "messageStats", json_stat);
8800 }
8801 else
8802 {
8803 /* Packet counts. */
8804 vty_out (vty, " Message statistics:%s", VTY_NEWLINE);
8805 vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE);
8806 vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE);
8807 vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE);
8808 vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE);
8809 vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE);
8810 vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE);
8811 vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE);
8812 vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE);
8813 vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE);
8814 vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out +
8815 p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out,
8816 p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in +
8817 p->dynamic_cap_in, VTY_NEWLINE);
718e3744 8818 }
8819
856ca177
MS
8820 if (use_json)
8821 {
8822 /* advertisement-interval */
8823 json_object_int_add(json_neigh, "minBtwnAdvertisementRunsTimerMsecs", p->v_routeadv * 1000);
718e3744 8824
856ca177
MS
8825 /* Update-source. */
8826 if (p->update_if || p->update_source)
8827 {
8828 if (p->update_if)
8829 json_object_string_add(json_neigh, "updateSource", p->update_if);
8830 else if (p->update_source)
8831 json_object_string_add(json_neigh, "updateSource", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
8832 }
8833
8834 /* Default weight */
8835 if (CHECK_FLAG (p->config, PEER_CONFIG_WEIGHT))
8836 json_object_int_add(json_neigh, "defaultWeight", p->weight);
8837
8838 }
8839 else
8840 {
8841 /* advertisement-interval */
8842 vty_out (vty, " Minimum time between advertisement runs is %d seconds%s",
8843 p->v_routeadv, VTY_NEWLINE);
8844
8845 /* Update-source. */
8846 if (p->update_if || p->update_source)
8847 {
8848 vty_out (vty, " Update source is ");
8849 if (p->update_if)
8850 vty_out (vty, "%s", p->update_if);
8851 else if (p->update_source)
8852 vty_out (vty, "%s", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
8853 vty_out (vty, "%s", VTY_NEWLINE);
8854 }
8855
8856 /* Default weight */
8857 if (CHECK_FLAG (p->config, PEER_CONFIG_WEIGHT))
8858 vty_out (vty, " Default weight %d%s", p->weight, VTY_NEWLINE);
8859
8860 vty_out (vty, "%s", VTY_NEWLINE);
8861 }
718e3744 8862
8863 /* Address Family Information */
856ca177
MS
8864 json_object *json_hold = NULL;
8865
8866 if (use_json)
8867 json_hold = json_object_new_object();
8868
538621f2 8869 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8870 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8871 if (p->afc[afi][safi])
856ca177 8872 bgp_show_peer_afi (vty, p, afi, safi, use_json, json_hold);
718e3744 8873
856ca177
MS
8874 if (use_json)
8875 {
8876 json_object_int_add(json_hold, "connectionsEstablished", p->established);
8877 json_object_int_add(json_hold, "connectionsDropped", p->dropped);
8878 }
8879 else
8880 vty_out (vty, " Connections established %d; dropped %d%s", p->established, p->dropped,
8881 VTY_NEWLINE);
718e3744 8882
d6661008 8883 if (! p->last_reset)
856ca177
MS
8884 {
8885 if (use_json)
8886 json_object_string_add(json_hold, "lastReset", "never");
8887 else
8888 vty_out (vty, " Last reset never%s", VTY_NEWLINE);
8889 }
e0701b79 8890 else
d6661008 8891 {
856ca177
MS
8892 if (use_json)
8893 {
8894 time_t uptime;
8895 struct tm *tm;
8896
8897 uptime = bgp_clock();
8898 uptime -= p->resettime;
8899 tm = gmtime(&uptime);
8900 json_object_int_add(json_hold, "lastResetTimerMsecs", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
8901 json_object_string_add(json_hold, "lastResetDueTo", peer_down_str[(int) p->last_reset]);
8902 if (p->last_reset_cause_size)
8903 {
39e871e6
ST
8904 char errorcodesubcode_hexstr[5];
8905 sprintf(errorcodesubcode_hexstr, "%02X%02X", p->notify.code, p->notify.subcode);
8906 json_object_string_add(json_hold, "lastErrorCodeSubcode", errorcodesubcode_hexstr);
856ca177
MS
8907 }
8908 }
8909 else
d6661008 8910 {
3a8c7ba1
DW
8911 vty_out (vty, " Last reset %s, ",
8912 peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN, 0, NULL));
8913
8914 if (p->last_reset == PEER_DOWN_NOTIFY_SEND ||
8915 p->last_reset == PEER_DOWN_NOTIFY_RECEIVED)
8916 {
8917 code_str = bgp_notify_code_str(p->notify.code);
8918 subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode);
8919 vty_out (vty, "due to NOTIFICATION %s (%s%s)%s",
8920 p->last_reset == PEER_DOWN_NOTIFY_SEND ? "sent" : "received",
8921 code_str, subcode_str, VTY_NEWLINE);
8922 }
8923 else
8924 {
8925 vty_out (vty, "due to %s%s",
8926 peer_down_str[(int) p->last_reset], VTY_NEWLINE);
8927 }
856ca177
MS
8928
8929 if (p->last_reset_cause_size)
d6661008 8930 {
856ca177
MS
8931 msg = p->last_reset_cause;
8932 vty_out(vty, " Message received that caused BGP to send a NOTIFICATION:%s ", VTY_NEWLINE);
8933 for (i = 1; i <= p->last_reset_cause_size; i++)
8934 {
8935 vty_out(vty, "%02X", *msg++);
d6661008 8936
856ca177
MS
8937 if (i != p->last_reset_cause_size)
8938 {
8939 if (i % 16 == 0)
8940 {
8941 vty_out(vty, "%s ", VTY_NEWLINE);
8942 }
8943 else if (i % 4 == 0)
8944 {
8945 vty_out(vty, " ");
8946 }
8947 }
8948 }
8949 vty_out(vty, "%s", VTY_NEWLINE);
d6661008 8950 }
d6661008
DS
8951 }
8952 }
848973c7 8953
718e3744 8954 if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW))
8955 {
856ca177
MS
8956 if (use_json)
8957 json_object_boolean_true_add(json_hold, "prefixesConfigExceedMax");
8958 else
8959 vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE);
0a486e5f 8960
8961 if (p->t_pmax_restart)
856ca177
MS
8962 {
8963 if (use_json)
8964 {
e8f7da3a 8965 json_object_boolean_true_add(json_hold, "reducePrefixNumFrom");
856ca177
MS
8966 json_object_int_add(json_hold, "restartInTimerMsec", thread_timer_remain_second (p->t_pmax_restart) * 1000);
8967 }
8968 else
8969 vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s",
8970 p->host, thread_timer_remain_second (p->t_pmax_restart),
8971 VTY_NEWLINE);
8972 }
0a486e5f 8973 else
856ca177
MS
8974 {
8975 if (use_json)
e8f7da3a 8976 json_object_boolean_true_add(json_hold, "reducePrefixNumAndClearIpBgp");
856ca177
MS
8977 else
8978 vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s",
8979 p->host, VTY_NEWLINE);
8980 }
718e3744 8981 }
8982
856ca177
MS
8983 if (use_json)
8984 json_object_object_add(json_neigh, "addressFamilyInfo", json_hold);
8985
f5a4827d 8986 /* EBGP Multihop and GTSM */
6d85b15b 8987 if (p->sort != BGP_PEER_IBGP)
f5a4827d 8988 {
856ca177
MS
8989 if (use_json)
8990 {
8991 if (p->gtsm_hops > 0)
8992 json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->gtsm_hops);
8993 else if (p->ttl > 1)
8994 json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->ttl);
8995 }
8996 else
8997 {
8998 if (p->gtsm_hops > 0)
8999 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
9000 p->gtsm_hops, VTY_NEWLINE);
9001 else if (p->ttl > 1)
9002 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
9003 p->ttl, VTY_NEWLINE);
9004 }
f5a4827d 9005 }
5d804b43
PM
9006 else
9007 {
9008 if (p->gtsm_hops > 0)
856ca177
MS
9009 {
9010 if (use_json)
9011 json_object_int_add(json_neigh, "internalBgpNbrMaxHopsAway", p->gtsm_hops);
9012 else
9013 vty_out (vty, " Internal BGP neighbor may be up to %d hops away.%s",
9014 p->gtsm_hops, VTY_NEWLINE);
9015 }
5d804b43 9016 }
718e3744 9017
9018 /* Local address. */
9019 if (p->su_local)
9020 {
856ca177
MS
9021 if (use_json)
9022 {
9023 json_object_string_add(json_neigh, "hostLocal", sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN));
9024 json_object_int_add(json_neigh, "portLocal", ntohs (p->su_local->sin.sin_port));
9025 }
9026 else
9027 vty_out (vty, "Local host: %s, Local port: %d%s",
9028 sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN),
9029 ntohs (p->su_local->sin.sin_port),
9030 VTY_NEWLINE);
718e3744 9031 }
9032
9033 /* Remote address. */
9034 if (p->su_remote)
9035 {
856ca177
MS
9036 if (use_json)
9037 {
9038 json_object_string_add(json_neigh, "hostForeign", sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN));
9039 json_object_int_add(json_neigh, "portForeign", ntohs (p->su_remote->sin.sin_port));
9040 }
9041 else
9042 vty_out (vty, "Foreign host: %s, Foreign port: %d%s",
718e3744 9043 sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN),
9044 ntohs (p->su_remote->sin.sin_port),
9045 VTY_NEWLINE);
9046 }
9047
9048 /* Nexthop display. */
9049 if (p->su_local)
9050 {
856ca177
MS
9051 if (use_json)
9052 {
9053 json_object_string_add(json_neigh, "nexthop", inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ));
718e3744 9054#ifdef HAVE_IPV6
856ca177
MS
9055 json_object_string_add(json_neigh, "nexthopGlobal", inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ));
9056 json_object_string_add(json_neigh, "nexthopLocal", inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ));
9057 if (p->shared_network)
9058 json_object_string_add(json_neigh, "bgpConnection", "sharedNetwork");
9059 else
9060 json_object_string_add(json_neigh, "bgpConnection", "nonSharedNetwork");
9061#endif /* HAVE_IPV6 */
9062 }
9063 else
9064 {
9065 vty_out (vty, "Nexthop: %s%s",
9066 inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ),
9067 VTY_NEWLINE);
9068#ifdef HAVE_IPV6
9069 vty_out (vty, "Nexthop global: %s%s",
9070 inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ),
9071 VTY_NEWLINE);
9072 vty_out (vty, "Nexthop local: %s%s",
9073 inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ),
9074 VTY_NEWLINE);
9075 vty_out (vty, "BGP connection: %s%s",
9076 p->shared_network ? "shared network" : "non shared network",
9077 VTY_NEWLINE);
718e3744 9078#endif /* HAVE_IPV6 */
856ca177 9079 }
718e3744 9080 }
9081
9082 /* Timer information. */
856ca177
MS
9083 if (use_json)
9084 {
39e871e6 9085 json_object_int_add(json_neigh, "connectRetryTimer", p->v_connect);
dd9275d6
ST
9086 if (p->status == Established && p->rtt)
9087 json_object_int_add(json_neigh, "estimatedRttInMsecs", p->rtt);
856ca177
MS
9088 if (p->t_start)
9089 json_object_int_add(json_neigh, "nextStartTimerDueInMsecs", thread_timer_remain_second (p->t_start) * 1000);
9090 if (p->t_connect)
9091 json_object_int_add(json_neigh, "nextConnectTimerDueInMsecs", thread_timer_remain_second (p->t_connect) * 1000);
9092 if (p->t_routeadv)
9093 {
9094 json_object_int_add(json_neigh, "mraiInterval", p->v_routeadv);
9095 json_object_int_add(json_neigh, "mraiTimerExpireInMsecs", thread_timer_remain_second (p->t_routeadv) * 1000);
9096 }
cb1faec9 9097
856ca177
MS
9098 if (p->t_read)
9099 json_object_string_add(json_neigh, "readThread", "on");
9100 else
9101 json_object_string_add(json_neigh, "readThread", "off");
9102 if (p->t_write)
9103 json_object_string_add(json_neigh, "writeThread", "on");
9104 else
9105 json_object_string_add(json_neigh, "writeThread", "off");
9106 }
9107 else
9108 {
39e871e6
ST
9109 vty_out (vty, "BGP Connect Retry Timer in Seconds: %d%s",
9110 p->v_connect, VTY_NEWLINE);
dd9275d6
ST
9111 if (p->status == Established && p->rtt)
9112 vty_out (vty, "Estimated round trip time: %d ms%s",
9113 p->rtt, VTY_NEWLINE);
856ca177
MS
9114 if (p->t_start)
9115 vty_out (vty, "Next start timer due in %ld seconds%s",
9116 thread_timer_remain_second (p->t_start), VTY_NEWLINE);
9117 if (p->t_connect)
9118 vty_out (vty, "Next connect timer due in %ld seconds%s",
9119 thread_timer_remain_second (p->t_connect), VTY_NEWLINE);
9120 if (p->t_routeadv)
9121 vty_out (vty, "MRAI (interval %u) timer expires in %ld seconds%s",
9122 p->v_routeadv, thread_timer_remain_second (p->t_routeadv),
9123 VTY_NEWLINE);
9124
9125 vty_out (vty, "Read thread: %s Write thread: %s%s",
9126 p->t_read ? "on" : "off",
9127 p->t_write ? "on" : "off",
9128 VTY_NEWLINE);
9129 }
718e3744 9130
9131 if (p->notify.code == BGP_NOTIFY_OPEN_ERR
9132 && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL)
856ca177
MS
9133 bgp_capability_vty_out (vty, p, use_json, json_neigh);
9134
9135 if (!use_json)
9136 vty_out (vty, "%s", VTY_NEWLINE);
c43ed2e4
DS
9137
9138 /* BFD information. */
856ca177
MS
9139 bgp_bfd_show_info(vty, p, use_json, json_neigh);
9140
9141 if (use_json)
9142 {
9143 if (p->conf_if) /* Configured interface name. */
9144 json_object_object_add(json, p->conf_if, json_neigh);
9145 else /* Configured IP address. */
9146 json_object_object_add(json, p->host, json_neigh);
9147 }
718e3744 9148}
9149
94f2b392 9150static int
856ca177
MS
9151bgp_show_neighbor (struct vty *vty, struct bgp *bgp, enum show_type type,
9152 union sockunion *su, const char *conf_if, u_char use_json, json_object *json)
718e3744 9153{
1eb8ef25 9154 struct listnode *node, *nnode;
718e3744 9155 struct peer *peer;
9156 int find = 0;
9157
1eb8ef25 9158 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
718e3744 9159 {
1ff9a340
DS
9160 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
9161 continue;
9162
718e3744 9163 switch (type)
856ca177
MS
9164 {
9165 case show_all:
e8f7da3a 9166 bgp_show_peer (vty, peer, use_json, json);
856ca177
MS
9167 break;
9168 case show_peer:
9169 if (conf_if)
9170 {
4873b3b9
DW
9171 if ((peer->conf_if && !strcmp(peer->conf_if, conf_if)) ||
9172 (peer->hostname && !strcmp(peer->hostname, conf_if)))
856ca177
MS
9173 {
9174 find = 1;
e8f7da3a 9175 bgp_show_peer (vty, peer, use_json, json);
856ca177
MS
9176 }
9177 }
9178 else
9179 {
9180 if (sockunion_same (&peer->su, su))
9181 {
9182 find = 1;
e8f7da3a 9183 bgp_show_peer (vty, peer, use_json, json);
856ca177
MS
9184 }
9185 }
9186 break;
718e3744 9187 }
9188 }
9189
9190 if (type == show_peer && ! find)
856ca177
MS
9191 {
9192 if (use_json)
9193 json_object_boolean_true_add(json, "bgpNoSuchNeighbor");
9194 else
9195 vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE);
9196 }
9197
9198 if (use_json)
9199 {
9200 vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
9201 json_object_free(json);
9202 }
9203 else
9204 {
9205 vty_out (vty, "%s", VTY_NEWLINE);
9206 }
9207
718e3744 9208 return CMD_SUCCESS;
9209}
9210
94f2b392 9211static int
fd79ac91 9212bgp_show_neighbor_vty (struct vty *vty, const char *name,
9f689658
DD
9213 enum show_type type, const char *ip_str, u_char use_json,
9214 json_object *json)
718e3744 9215{
9216 int ret;
9217 struct bgp *bgp;
9218 union sockunion su;
856ca177 9219
9f689658 9220 if (use_json && (json == NULL))
856ca177 9221 json = json_object_new_object();
718e3744 9222
718e3744 9223 if (name)
9224 {
9225 bgp = bgp_lookup_by_name (name);
718e3744 9226 if (! bgp)
9227 {
856ca177
MS
9228 if (use_json)
9229 {
9230 json_object_boolean_true_add(json, "bgpNoSuchInstance");
9231 vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
9232 json_object_free(json);
9233 }
9234 else
9235 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
9236
718e3744 9237 return CMD_WARNING;
9238 }
718e3744 9239 }
a80beece
DS
9240 else
9241 {
9242 bgp = bgp_get_default ();
9243 }
718e3744 9244
9245 if (bgp)
a80beece
DS
9246 {
9247 if (ip_str)
9248 {
9249 ret = str2sockunion (ip_str, &su);
9250 if (ret < 0)
856ca177 9251 bgp_show_neighbor (vty, bgp, type, NULL, ip_str, use_json, json);
a80beece 9252 else
856ca177 9253 bgp_show_neighbor (vty, bgp, type, &su, NULL, use_json, json);
a80beece
DS
9254 }
9255 else
9256 {
856ca177 9257 bgp_show_neighbor (vty, bgp, type, NULL, NULL, use_json, json);
a80beece
DS
9258 }
9259 }
718e3744 9260
9261 return CMD_SUCCESS;
9262}
9263
f186de26 9264static void
9265bgp_show_all_instances_neighbors_vty (struct vty *vty, u_char use_json)
9266{
9267 struct listnode *node, *nnode;
9268 struct bgp *bgp;
9269 json_object *json = NULL;
9f689658
DD
9270 int is_first = 1;
9271
9272 if (use_json)
9273 vty_out (vty, "{%s", VTY_NEWLINE);
f186de26 9274
9275 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
9276 {
f186de26 9277 if (use_json)
9f689658
DD
9278 {
9279 if (!(json = json_object_new_object()))
9280 {
9281 zlog_err("Unable to allocate memory for JSON object");
9282 vty_out (vty,
9283 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s",
9284 VTY_NEWLINE);
9285 return;
9286 }
9287
9288 json_object_int_add(json, "vrfId",
9289 (bgp->vrf_id == VRF_UNKNOWN)
9290 ? -1 : bgp->vrf_id);
9291 json_object_string_add(json, "vrfName",
9292 (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
9293 ? "Default" : bgp->name);
9294
9295 if (! is_first)
9296 vty_out (vty, ",%s", VTY_NEWLINE);
9297 else
9298 is_first = 0;
9299
9300 vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
9301 ? "Default" : bgp->name);
9302 }
9303 else
9304 {
9305 vty_out (vty, "%sInstance %s:%s",
9306 VTY_NEWLINE,
9307 (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
9308 ? "Default" : bgp->name,
9309 VTY_NEWLINE);
9310 }
f186de26 9311 bgp_show_neighbor (vty, bgp, show_all, NULL, NULL, use_json, json);
9312 }
9f689658
DD
9313
9314 if (use_json)
9315 vty_out (vty, "}%s", VTY_NEWLINE);
f186de26 9316}
9317
718e3744 9318/* "show ip bgp neighbors" commands. */
f412b39a
DW
9319/*
9320 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
b162fa78 9321 * "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors [json]",
f412b39a
DW
9322 * SHOW_STR
9323 * IP_STR
9324 * BGP_STR
9325 * "Display VPNv4 NLRI specific information\n"
9326 * "Display information for a route distinguisher\n"
9327 * "VPN Route Distinguisher\n"
9328 * "Detailed information on TCP and BGP neighbor connections\n"
9329 * "JavaScript Object Notation\n"
9330 *
b162fa78 9331 * "show bgp neighbors [json]",
f412b39a
DW
9332 * SHOW_STR
9333 * BGP_STR
9334 * "Detailed information on TCP and BGP neighbor connections\n"
9335 * "JavaScript Object Notation\n"
9336 *
b162fa78 9337 * "show ip bgp vpnv4 all neighbors [json]",
f412b39a
DW
9338 * SHOW_STR
9339 * IP_STR
9340 * BGP_STR
9341 * "Display VPNv4 NLRI specific information\n"
9342 * "Display information about all VPNv4 NLRIs\n"
9343 * "Detailed information on TCP and BGP neighbor connections\n"
9344 * "JavaScript Object Notation\n"
9345 *
b162fa78 9346 * "show ip bgp ipv4 (unicast|multicast) neighbors [json]",
f412b39a
DW
9347 * SHOW_STR
9348 * IP_STR
9349 * BGP_STR
9350 * "Address family\n"
9351 * "Address Family modifier\n"
9352 * "Address Family modifier\n"
9353 * "Detailed information on TCP and BGP neighbor connections\n"
9354 * "JavaScript Object Notation\n"
9355 *
b162fa78 9356 * "show bgp ipv6 neighbors [json]",
f412b39a
DW
9357 * SHOW_STR
9358 * BGP_STR
9359 * "Address family\n"
9360 * "Detailed information on TCP and BGP neighbor connections\n"
9361 * "JavaScript Object Notation\n"
9362 *
9363 */
718e3744 9364DEFUN (show_ip_bgp_neighbors,
9365 show_ip_bgp_neighbors_cmd,
b162fa78 9366 "show ip bgp neighbors [json]",
718e3744 9367 SHOW_STR
9368 IP_STR
9369 BGP_STR
856ca177
MS
9370 "Detailed information on TCP and BGP neighbor connections\n"
9371 "JavaScript Object Notation\n")
718e3744 9372{
db7c8528 9373 u_char uj = use_json(argc, argv);
856ca177 9374
9f689658 9375 return bgp_show_neighbor_vty (vty, NULL, show_all, NULL, uj, NULL);
718e3744 9376}
9377
718e3744 9378
718e3744 9379
718e3744 9380
718e3744 9381
718e3744 9382
f412b39a
DW
9383/*
9384 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
b162fa78 9385 * "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) [json]",
f412b39a
DW
9386 * SHOW_STR
9387 * IP_STR
9388 * BGP_STR
9389 * "Address family\n"
9390 * "Address Family modifier\n"
9391 * "Address Family modifier\n"
9392 * "Detailed information on TCP and BGP neighbor connections\n"
9393 * "Neighbor to display information about\n"
9394 * "Neighbor to display information about\n"
9395 * "Neighbor on bgp configured interface\n"
9396 * "JavaScript Object Notation\n"
9397 *
b162fa78 9398 * "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D [json]",
f412b39a
DW
9399 * SHOW_STR
9400 * IP_STR
9401 * BGP_STR
9402 * "Display VPNv4 NLRI specific information\n"
9403 * "Display information about all VPNv4 NLRIs\n"
9404 * "Detailed information on TCP and BGP neighbor connections\n"
9405 * "Neighbor to display information about\n"
9406 * "JavaScript Object Notation\n"
9407 *
b162fa78 9408 * "show ip bgp vpnv4 all neighbors A.B.C.D [json]",
f412b39a
DW
9409 * SHOW_STR
9410 * IP_STR
9411 * BGP_STR
9412 * "Display VPNv4 NLRI specific information\n"
9413 * "Display information about all VPNv4 NLRIs\n"
9414 * "Detailed information on TCP and BGP neighbor connections\n"
9415 * "Neighbor to display information about\n"
9416 * "JavaScript Object Notation\n"
9417 *
b162fa78 9418 * "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) [json]",
f412b39a
DW
9419 * SHOW_STR
9420 * BGP_STR
9421 * "Address family\n"
9422 * "Detailed information on TCP and BGP neighbor connections\n"
9423 * "Neighbor to display information about\n"
9424 * "Neighbor to display information about\n"
9425 * "Neighbor on bgp configured interface\n"
9426 * "JavaScript Object Notation\n"
9427 *
b162fa78 9428 * "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) [json]",
f412b39a
DW
9429 * SHOW_STR
9430 * BGP_STR
9431 * "Detailed information on TCP and BGP neighbor connections\n"
9432 * "Neighbor to display information about\n"
9433 * "Neighbor to display information about\n"
9434 * "Neighbor on bgp configured interface\n"
9435 * "JavaScript Object Notation\n"
9436 *
9437 */
718e3744 9438DEFUN (show_ip_bgp_neighbors_peer,
9439 show_ip_bgp_neighbors_peer_cmd,
6147e2c6 9440 "show ip bgp neighbors <A.B.C.D|X:X::X:X|WORD> [json]",
718e3744 9441 SHOW_STR
9442 IP_STR
9443 BGP_STR
9444 "Detailed information on TCP and BGP neighbor connections\n"
9445 "Neighbor to display information about\n"
a80beece 9446 "Neighbor to display information about\n"
856ca177
MS
9447 "Neighbor on bgp configured interface\n"
9448 "JavaScript Object Notation\n")
718e3744 9449{
db7c8528 9450 u_char uj = use_json(argc, argv);
856ca177 9451
9f689658 9452 return bgp_show_neighbor_vty (vty, NULL, show_peer, argv[argc - 2], uj, NULL);
718e3744 9453}
9454
718e3744 9455
718e3744 9456
718e3744 9457
718e3744 9458
718e3744 9459
f412b39a
DW
9460/*
9461 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9ccf14f7 9462 * "show bgp <view|vrf> WORD neighbors [json]",
f412b39a
DW
9463 * SHOW_STR
9464 * BGP_STR
9465 * BGP_INSTANCE_HELP_STR
9466 * "Detailed information on TCP and BGP neighbor connections\n"
9467 * "JavaScript Object Notation\n"
9468 *
9ccf14f7 9469 * "show bgp <view|vrf> WORD ipv6 neighbors [json]",
f412b39a
DW
9470 * SHOW_STR
9471 * BGP_STR
9472 * BGP_INSTANCE_HELP_STR
9473 * "Address family\n"
9474 * "Detailed information on TCP and BGP neighbor connections\n"
9475 * "JavaScript Object Notation\n"
9476 *
9477 */
718e3744 9478DEFUN (show_ip_bgp_instance_neighbors,
9479 show_ip_bgp_instance_neighbors_cmd,
9ccf14f7 9480 "show ip bgp <view|vrf> WORD neighbors [json]",
718e3744 9481 SHOW_STR
9482 IP_STR
9483 BGP_STR
8386ac43 9484 BGP_INSTANCE_HELP_STR
856ca177
MS
9485 "Detailed information on TCP and BGP neighbor connections\n"
9486 "JavaScript Object Notation\n")
718e3744 9487{
c500ae40 9488 int idx_word = 4;
db7c8528 9489 u_char uj = use_json(argc, argv);
856ca177 9490
c500ae40 9491 return bgp_show_neighbor_vty (vty, argv[idx_word]->arg, show_all, NULL, uj, NULL);
718e3744 9492}
9493
f186de26 9494DEFUN (show_ip_bgp_instance_all_neighbors,
9495 show_ip_bgp_instance_all_neighbors_cmd,
9ccf14f7 9496 "show ip bgp <view|vrf> all neighbors [json]",
f186de26 9497 SHOW_STR
9498 IP_STR
9499 BGP_STR
9500 BGP_INSTANCE_ALL_HELP_STR
9501 "Detailed information on TCP and BGP neighbor connections\n"
9502 "JavaScript Object Notation\n")
9503{
9504 u_char uj = use_json(argc, argv);
9505
9506 bgp_show_all_instances_neighbors_vty (vty, uj);
9507 return CMD_SUCCESS;
9508}
9509
bb46e94f 9510
bb46e94f 9511
f412b39a
DW
9512/*
9513 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9ccf14f7 9514 * "show bgp <view|vrf> WORD ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) [json]",
f412b39a
DW
9515 * SHOW_STR
9516 * BGP_STR
9517 * BGP_INSTANCE_HELP_STR
9518 * "Address family\n"
9519 * "Detailed information on TCP and BGP neighbor connections\n"
9520 * "Neighbor to display information about\n"
9521 * "Neighbor to display information about\n"
9522 * "Neighbor on bgp configured interface\n"
9523 * "JavaScript Object Notation\n"
9524 *
9ccf14f7 9525 * "show bgp <view|vrf> WORD neighbors (A.B.C.D|X:X::X:X|WORD) [json]",
f412b39a
DW
9526 * SHOW_STR
9527 * BGP_STR
9528 * BGP_INSTANCE_HELP_STR
9529 * "Detailed information on TCP and BGP neighbor connections\n"
9530 * "Neighbor to display information about\n"
9531 * "Neighbor to display information about\n"
9532 * "Neighbor on bgp configured interface\n"
9533 * "JavaScript Object Notation\n"
9534 *
9535 */
718e3744 9536DEFUN (show_ip_bgp_instance_neighbors_peer,
9537 show_ip_bgp_instance_neighbors_peer_cmd,
9ccf14f7 9538 "show ip bgp <view|vrf> WORD neighbors <A.B.C.D|X:X::X:X|WORD> [json]",
718e3744 9539 SHOW_STR
9540 IP_STR
9541 BGP_STR
8386ac43 9542 BGP_INSTANCE_HELP_STR
718e3744 9543 "Detailed information on TCP and BGP neighbor connections\n"
9544 "Neighbor to display information about\n"
a80beece 9545 "Neighbor to display information about\n"
856ca177
MS
9546 "Neighbor on bgp configured interface\n"
9547 "JavaScript Object Notation\n")
718e3744 9548{
c500ae40
DW
9549 int idx_word = 4;
9550 int idx_peer = 6;
db7c8528 9551 u_char uj = use_json(argc, argv);
856ca177 9552
c500ae40 9553 return bgp_show_neighbor_vty (vty, argv[idx_word]->arg, show_peer, argv[idx_peer]->arg, uj, NULL);
718e3744 9554}
bb46e94f 9555
bb46e94f 9556
6b0655a2 9557
718e3744 9558/* Show BGP's AS paths internal data. There are both `show ip bgp
9559 paths' and `show ip mbgp paths'. Those functions results are the
9560 same.*/
f412b39a 9561DEFUN (show_ip_bgp_paths,
718e3744 9562 show_ip_bgp_paths_cmd,
9563 "show ip bgp paths",
9564 SHOW_STR
9565 IP_STR
9566 BGP_STR
9567 "Path information\n")
9568{
9569 vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE);
9570 aspath_print_all_vty (vty);
9571 return CMD_SUCCESS;
9572}
9573
f412b39a 9574DEFUN (show_ip_bgp_ipv4_paths,
718e3744 9575 show_ip_bgp_ipv4_paths_cmd,
6147e2c6 9576 "show ip bgp ipv4 <unicast|multicast> paths",
718e3744 9577 SHOW_STR
9578 IP_STR
9579 BGP_STR
9580 "Address family\n"
9581 "Address Family modifier\n"
9582 "Address Family modifier\n"
9583 "Path information\n")
9584{
9585 vty_out (vty, "Address Refcnt Path\r\n");
9586 aspath_print_all_vty (vty);
9587
9588 return CMD_SUCCESS;
9589}
6b0655a2 9590
718e3744 9591#include "hash.h"
9592
94f2b392 9593static void
718e3744 9594community_show_all_iterator (struct hash_backet *backet, struct vty *vty)
9595{
9596 struct community *com;
9597
9598 com = (struct community *) backet->data;
6c4f4e6e 9599 vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, com->refcnt,
718e3744 9600 community_str (com), VTY_NEWLINE);
9601}
9602
9603/* Show BGP's community internal data. */
f412b39a 9604DEFUN (show_ip_bgp_community_info,
718e3744 9605 show_ip_bgp_community_info_cmd,
9606 "show ip bgp community-info",
9607 SHOW_STR
9608 IP_STR
9609 BGP_STR
9610 "List all bgp community information\n")
9611{
9612 vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE);
9613
9614 hash_iterate (community_hash (),
9615 (void (*) (struct hash_backet *, void *))
9616 community_show_all_iterator,
9617 vty);
9618
9619 return CMD_SUCCESS;
9620}
9621
f412b39a 9622DEFUN (show_ip_bgp_attr_info,
718e3744 9623 show_ip_bgp_attr_info_cmd,
9624 "show ip bgp attribute-info",
9625 SHOW_STR
9626 IP_STR
9627 BGP_STR
9628 "List all bgp attribute information\n")
9629{
9630 attr_show_all (vty);
9631 return CMD_SUCCESS;
9632}
6b0655a2 9633
8386ac43 9634static int bgp_show_update_groups(struct vty *vty, const char *name,
9635 int afi, int safi,
f43e655e 9636 uint64_t subgrp_id)
3f9c7369
DS
9637{
9638 struct bgp *bgp;
9639
8386ac43 9640 if (name)
9641 bgp = bgp_lookup_by_name (name);
9642 else
9643 bgp = bgp_get_default ();
9644
3f9c7369 9645 if (bgp)
8fe8a7f6 9646 update_group_show(bgp, afi, safi, vty, subgrp_id);
3f9c7369
DS
9647 return CMD_SUCCESS;
9648}
9649
f186de26 9650static void
9651bgp_show_all_instances_updgrps_vty (struct vty *vty, afi_t afi, safi_t safi)
9652{
9653 struct listnode *node, *nnode;
9654 struct bgp *bgp;
9655
9656 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
9657 {
9658 vty_out (vty, "%sInstance %s:%s",
9659 VTY_NEWLINE,
9660 (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? "Default" : bgp->name,
9661 VTY_NEWLINE);
9662 update_group_show(bgp, afi, safi, vty, 0);
9663 }
9664}
9665
8fe8a7f6
DS
9666DEFUN (show_ip_bgp_updgrps,
9667 show_ip_bgp_updgrps_cmd,
9668 "show ip bgp update-groups",
9669 SHOW_STR
9670 IP_STR
9671 BGP_STR
9672 "Detailed info about dynamic update groups\n")
9673{
8386ac43 9674 return (bgp_show_update_groups(vty, NULL, AFI_IP, SAFI_UNICAST, 0));
9675}
9676
9677DEFUN (show_ip_bgp_instance_updgrps,
9678 show_ip_bgp_instance_updgrps_cmd,
9ccf14f7 9679 "show ip bgp <view|vrf> WORD update-groups",
8386ac43 9680 SHOW_STR
9681 IP_STR
9682 BGP_STR
9683 BGP_INSTANCE_HELP_STR
9684 "Detailed info about dynamic update groups\n")
9685{
c500ae40
DW
9686 int idx_word = 4;
9687 return (bgp_show_update_groups(vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0));
8fe8a7f6
DS
9688}
9689
f186de26 9690DEFUN (show_ip_bgp_instance_all_updgrps,
9691 show_ip_bgp_instance_all_updgrps_cmd,
9ccf14f7 9692 "show ip bgp <view|vrf> all update-groups",
f186de26 9693 SHOW_STR
9694 IP_STR
9695 BGP_STR
9696 BGP_INSTANCE_ALL_HELP_STR
9697 "Detailed info about dynamic update groups\n")
9698{
9699 bgp_show_all_instances_updgrps_vty (vty, AFI_IP, SAFI_UNICAST);
9700 return CMD_SUCCESS;
9701}
9702
3f9c7369
DS
9703DEFUN (show_bgp_ipv6_updgrps,
9704 show_bgp_ipv6_updgrps_cmd,
8fe8a7f6 9705 "show bgp update-groups",
3f9c7369
DS
9706 SHOW_STR
9707 BGP_STR
8fe8a7f6 9708 "Detailed info about v6 dynamic update groups\n")
3f9c7369 9709{
8386ac43 9710 return (bgp_show_update_groups(vty, NULL, AFI_IP6, SAFI_UNICAST, 0));
9711}
9712
9713DEFUN (show_bgp_instance_ipv6_updgrps,
9714 show_bgp_instance_ipv6_updgrps_cmd,
9ccf14f7 9715 "show bgp <view|vrf> WORD update-groups",
8386ac43 9716 SHOW_STR
9717 BGP_STR
9718 BGP_INSTANCE_HELP_STR
9719 "Detailed info about v6 dynamic update groups\n")
9720{
c500ae40
DW
9721 int idx_word = 3;
9722 return (bgp_show_update_groups(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, 0));
3f9c7369
DS
9723}
9724
f186de26 9725DEFUN (show_bgp_instance_all_ipv6_updgrps,
9726 show_bgp_instance_all_ipv6_updgrps_cmd,
9ccf14f7 9727 "show bgp <view|vrf> all update-groups",
f186de26 9728 SHOW_STR
9729 BGP_STR
9730 BGP_INSTANCE_ALL_HELP_STR
9731 "Detailed info about v6 dynamic update groups\n")
9732{
9733 bgp_show_all_instances_updgrps_vty (vty, AFI_IP6, SAFI_UNICAST);
9734 return CMD_SUCCESS;
9735}
9736
3f9c7369
DS
9737DEFUN (show_bgp_updgrps,
9738 show_bgp_updgrps_cmd,
6147e2c6 9739 "show bgp <ipv4|ipv6> <unicast|multicast> update-groups",
3f9c7369
DS
9740 SHOW_STR
9741 BGP_STR
9742 "Address family\n"
9743 "Address family\n"
9744 "Address Family modifier\n"
9745 "Address Family modifier\n"
8fe8a7f6 9746 "Detailed info about dynamic update groups\n")
3f9c7369 9747{
c500ae40
DW
9748 int idx_afi = 2;
9749 int idx_safi = 3;
3f9c7369
DS
9750 afi_t afi;
9751 safi_t safi;
9752
c500ae40
DW
9753 afi = (strcmp(argv[idx_afi]->arg, "ipv4") == 0) ? AFI_IP : AFI_IP6;
9754 safi = (strncmp (argv[idx_safi]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
8386ac43 9755 return (bgp_show_update_groups(vty, NULL, afi, safi, 0));
8fe8a7f6
DS
9756}
9757
9758DEFUN (show_ip_bgp_updgrps_s,
9759 show_ip_bgp_updgrps_s_cmd,
9760 "show ip bgp update-groups SUBGROUP-ID",
9761 SHOW_STR
9762 IP_STR
9763 BGP_STR
9764 "Detailed info about dynamic update groups\n"
9765 "Specific subgroup to display detailed info for\n")
9766{
f43e655e 9767 uint64_t subgrp_id;
8fe8a7f6
DS
9768
9769 VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]);
8386ac43 9770 return (bgp_show_update_groups(vty, NULL, AFI_IP, SAFI_UNICAST, subgrp_id));
9771}
9772
9773DEFUN (show_ip_bgp_instance_updgrps_s,
9774 show_ip_bgp_instance_updgrps_s_cmd,
9ccf14f7 9775 "show ip bgp <view|vrf> WORD update-groups SUBGROUP-ID",
8386ac43 9776 SHOW_STR
9777 IP_STR
9778 BGP_STR
9779 BGP_INSTANCE_HELP_STR
9780 "Detailed info about dynamic update groups\n"
9781 "Specific subgroup to display detailed info for\n")
9782{
c500ae40 9783 int idx_word = 4;
f43e655e 9784 uint64_t subgrp_id;
8386ac43 9785
9786 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
c500ae40 9787 return (bgp_show_update_groups(vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, subgrp_id));
8fe8a7f6
DS
9788}
9789
9790DEFUN (show_bgp_ipv6_updgrps_s,
9791 show_bgp_ipv6_updgrps_s_cmd,
9792 "show bgp update-groups SUBGROUP-ID",
9793 SHOW_STR
9794 BGP_STR
9795 "Detailed info about v6 dynamic update groups\n"
9796 "Specific subgroup to display detailed info for\n")
9797{
f43e655e 9798 uint64_t subgrp_id;
8fe8a7f6
DS
9799
9800 VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]);
8386ac43 9801 return(bgp_show_update_groups(vty, NULL, AFI_IP6, SAFI_UNICAST, subgrp_id));
9802}
9803
9804DEFUN (show_bgp_instance_ipv6_updgrps_s,
9805 show_bgp_instance_ipv6_updgrps_s_cmd,
9ccf14f7 9806 "show bgp <view|vrf> WORD update-groups SUBGROUP-ID",
8386ac43 9807 SHOW_STR
9808 BGP_STR
9809 "Detailed info about v6 dynamic update groups\n"
9810 "Specific subgroup to display detailed info for\n")
9811{
c500ae40 9812 int idx_word = 3;
f43e655e 9813 uint64_t subgrp_id;
8386ac43 9814
9815 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
c500ae40 9816 return(bgp_show_update_groups(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, subgrp_id));
8fe8a7f6
DS
9817}
9818
9819DEFUN (show_bgp_updgrps_s,
9820 show_bgp_updgrps_s_cmd,
6147e2c6 9821 "show bgp <ipv4|ipv6> <unicast|multicast> update-groups SUBGROUP-ID",
8fe8a7f6
DS
9822 SHOW_STR
9823 BGP_STR
9824 "Address family\n"
9825 "Address family\n"
9826 "Address Family modifier\n"
9827 "Address Family modifier\n"
9828 "Detailed info about v6 dynamic update groups\n"
9829 "Specific subgroup to display detailed info for")
9830{
c500ae40
DW
9831 int idx_afi = 2;
9832 int idx_safi = 3;
8fe8a7f6
DS
9833 afi_t afi;
9834 safi_t safi;
f43e655e 9835 uint64_t subgrp_id;
8fe8a7f6 9836
c500ae40
DW
9837 afi = (strcmp(argv[idx_afi]->arg, "ipv4") == 0) ? AFI_IP : AFI_IP6;
9838 safi = (strncmp (argv[idx_safi]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
8fe8a7f6
DS
9839
9840 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
8386ac43 9841 return(bgp_show_update_groups(vty, NULL, afi, safi, subgrp_id));
3f9c7369
DS
9842}
9843
9844DEFUN (show_bgp_updgrps_stats,
9845 show_bgp_updgrps_stats_cmd,
9846 "show bgp update-groups statistics",
9847 SHOW_STR
9848 BGP_STR
9849 "BGP update groups\n"
9850 "Statistics\n")
9851{
9852 struct bgp *bgp;
9853
9854 bgp = bgp_get_default();
9855 if (bgp)
9856 update_group_show_stats(bgp, vty);
9857
9858 return CMD_SUCCESS;
9859}
9860
8386ac43 9861DEFUN (show_bgp_instance_updgrps_stats,
9862 show_bgp_instance_updgrps_stats_cmd,
9ccf14f7 9863 "show bgp <view|vrf> WORD update-groups statistics",
8386ac43 9864 SHOW_STR
9865 BGP_STR
9866 BGP_INSTANCE_HELP_STR
9867 "BGP update groups\n"
9868 "Statistics\n")
9869{
c500ae40 9870 int idx_word = 3;
8386ac43 9871 struct bgp *bgp;
9872
c500ae40 9873 bgp = bgp_lookup_by_name (argv[idx_word]->arg);
8386ac43 9874 if (bgp)
9875 update_group_show_stats(bgp, vty);
9876
9877 return CMD_SUCCESS;
9878}
9879
3f9c7369 9880static void
8386ac43 9881show_bgp_updgrps_adj_info_aux (struct vty *vty, const char *name,
9882 afi_t afi, safi_t safi,
f43e655e 9883 const char *what, uint64_t subgrp_id)
3f9c7369
DS
9884{
9885 struct bgp *bgp;
8386ac43 9886
9887 if (name)
9888 bgp = bgp_lookup_by_name (name);
9889 else
9890 bgp = bgp_get_default ();
9891
3f9c7369
DS
9892 if (bgp)
9893 {
9894 if (!strcmp(what, "advertise-queue"))
9895 update_group_show_adj_queue(bgp, afi, safi, vty, subgrp_id);
9896 else if (!strcmp(what, "advertised-routes"))
9897 update_group_show_advertised(bgp, afi, safi, vty, subgrp_id);
9898 else if (!strcmp(what, "packet-queue"))
9899 update_group_show_packet_queue(bgp, afi, safi, vty, subgrp_id);
9900 }
9901}
9902
9903DEFUN (show_ip_bgp_updgrps_adj,
9904 show_ip_bgp_updgrps_adj_cmd,
6147e2c6 9905 "show ip bgp update-groups <advertise-queue|advertised-routes|packet-queue>",
3f9c7369
DS
9906 SHOW_STR
9907 IP_STR
9908 BGP_STR
9909 "BGP update groups\n"
9910 "Advertisement queue\n"
9911 "Announced routes\n"
9912 "Packet queue\n")
8fe8a7f6 9913
3f9c7369 9914{
c500ae40
DW
9915 int idx_type = 4;
9916 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0);
8386ac43 9917 return CMD_SUCCESS;
9918}
9919
9920DEFUN (show_ip_bgp_instance_updgrps_adj,
9921 show_ip_bgp_instance_updgrps_adj_cmd,
9ccf14f7 9922 "show ip bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>",
8386ac43 9923 SHOW_STR
9924 IP_STR
9925 BGP_STR
9926 BGP_INSTANCE_HELP_STR
9927 "BGP update groups\n"
9928 "Advertisement queue\n"
9929 "Announced routes\n"
9930 "Packet queue\n")
9931
9932{
c500ae40
DW
9933 int idx_word = 4;
9934 int idx_type = 6;
9935 show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0);
3f9c7369
DS
9936 return CMD_SUCCESS;
9937}
9938
9939DEFUN (show_bgp_updgrps_afi_adj,
9940 show_bgp_updgrps_afi_adj_cmd,
6147e2c6 9941 "show bgp <ipv4|ipv6> <unicast|multicast> update-groups <advertise-queue|advertised-routes|packet-queue>",
3f9c7369
DS
9942 SHOW_STR
9943 BGP_STR
9944 "Address family\n"
9945 "Address family\n"
9946 "Address Family modifier\n"
9947 "Address Family modifier\n"
9948 "BGP update groups\n"
9949 "Advertisement queue\n"
9950 "Announced routes\n"
8fe8a7f6
DS
9951 "Packet queue\n"
9952 "Specific subgroup info wanted for\n")
3f9c7369 9953{
c500ae40
DW
9954 int idx_afi = 2;
9955 int idx_safi = 3;
9956 int idx_type = 5;
3f9c7369
DS
9957 afi_t afi;
9958 safi_t safi;
9959
c500ae40
DW
9960 afi = (strcmp(argv[idx_afi]->arg, "ipv4") == 0) ? AFI_IP : AFI_IP6;
9961 safi = (strncmp (argv[idx_safi]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
9962 show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[idx_type]->arg, 0);
8fe8a7f6 9963 return CMD_SUCCESS;
3f9c7369
DS
9964}
9965
9966DEFUN (show_bgp_updgrps_adj,
9967 show_bgp_updgrps_adj_cmd,
6147e2c6 9968 "show bgp update-groups <advertise-queue|advertised-routes|packet-queue>",
3f9c7369
DS
9969 SHOW_STR
9970 BGP_STR
9971 "BGP update groups\n"
9972 "Advertisement queue\n"
9973 "Announced routes\n"
9974 "Packet queue\n")
9975{
c500ae40
DW
9976 int idx_type = 3;
9977 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0);
8386ac43 9978 return CMD_SUCCESS;
9979}
9980
9981DEFUN (show_bgp_instance_updgrps_adj,
9982 show_bgp_instance_updgrps_adj_cmd,
9ccf14f7 9983 "show bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>",
8386ac43 9984 SHOW_STR
9985 BGP_STR
9986 BGP_INSTANCE_HELP_STR
9987 "BGP update groups\n"
9988 "Advertisement queue\n"
9989 "Announced routes\n"
9990 "Packet queue\n")
9991{
c500ae40
DW
9992 int idx_word = 3;
9993 int idx_type = 5;
9994 show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0);
3f9c7369
DS
9995 return CMD_SUCCESS;
9996}
9997
9998DEFUN (show_ip_bgp_updgrps_adj_s,
8fe8a7f6 9999 show_ip_bgp_updgrps_adj_s_cmd,
6147e2c6 10000 "show ip bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
3f9c7369
DS
10001 SHOW_STR
10002 IP_STR
10003 BGP_STR
10004 "BGP update groups\n"
8fe8a7f6 10005 "Specific subgroup to display info for\n"
3f9c7369
DS
10006 "Advertisement queue\n"
10007 "Announced routes\n"
10008 "Packet queue\n")
3f9c7369 10009
3f9c7369 10010{
c500ae40 10011 int idx_type = 5;
f43e655e 10012 uint64_t subgrp_id;
8fe8a7f6 10013
c500ae40 10014 VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_type]->arg);
8fe8a7f6 10015
8386ac43 10016 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[1], subgrp_id);
10017 return CMD_SUCCESS;
10018}
10019
10020DEFUN (show_ip_bgp_instance_updgrps_adj_s,
10021 show_ip_bgp_instance_updgrps_adj_s_cmd,
9ccf14f7 10022 "show ip bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
8386ac43 10023 SHOW_STR
10024 IP_STR
10025 BGP_STR
10026 BGP_INSTANCE_HELP_STR
10027 "BGP update groups\n"
10028 "Specific subgroup to display info for\n"
10029 "Advertisement queue\n"
10030 "Announced routes\n"
10031 "Packet queue\n")
10032
10033{
c500ae40
DW
10034 int idx_word = 4;
10035 int idx_type = 7;
f43e655e 10036 uint64_t subgrp_id;
8386ac43 10037
c500ae40 10038 VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_type]->arg);
8386ac43 10039
c500ae40 10040 show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, argv[3], subgrp_id);
3f9c7369
DS
10041 return CMD_SUCCESS;
10042}
10043
8fe8a7f6
DS
10044DEFUN (show_bgp_updgrps_afi_adj_s,
10045 show_bgp_updgrps_afi_adj_s_cmd,
6147e2c6 10046 "show bgp <ipv4|ipv6> <unicast|multicast> update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
3f9c7369
DS
10047 SHOW_STR
10048 BGP_STR
10049 "Address family\n"
10050 "Address family\n"
10051 "Address Family modifier\n"
10052 "Address Family modifier\n"
10053 "BGP update groups\n"
8fe8a7f6 10054 "Specific subgroup to display info for\n"
3f9c7369
DS
10055 "Advertisement queue\n"
10056 "Announced routes\n"
8fe8a7f6
DS
10057 "Packet queue\n"
10058 "Specific subgroup info wanted for\n")
3f9c7369 10059{
c500ae40
DW
10060 int idx_afi = 2;
10061 int idx_safi = 3;
10062 int idx_type = 6;
3f9c7369
DS
10063 afi_t afi;
10064 safi_t safi;
f43e655e 10065 uint64_t subgrp_id;
3f9c7369 10066
c500ae40
DW
10067 afi = (strcmp(argv[idx_afi]->arg, "ipv4") == 0) ? AFI_IP : AFI_IP6;
10068 safi = (strncmp (argv[idx_safi]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
10069 VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_type]->arg);
8fe8a7f6 10070
8386ac43 10071 show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[3], subgrp_id);
8fe8a7f6 10072 return CMD_SUCCESS;
3f9c7369
DS
10073}
10074
8fe8a7f6
DS
10075DEFUN (show_bgp_updgrps_adj_s,
10076 show_bgp_updgrps_adj_s_cmd,
6147e2c6 10077 "show bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
8fe8a7f6
DS
10078 SHOW_STR
10079 BGP_STR
10080 "BGP update groups\n"
10081 "Specific subgroup to display info for\n"
10082 "Advertisement queue\n"
10083 "Announced routes\n"
10084 "Packet queue\n")
10085{
c500ae40 10086 int idx_type = 4;
f43e655e 10087 uint64_t subgrp_id;
8fe8a7f6 10088
c500ae40 10089 VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_type]->arg);
8fe8a7f6 10090
8386ac43 10091 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[1], subgrp_id);
8fe8a7f6
DS
10092 return CMD_SUCCESS;
10093}
10094
8386ac43 10095DEFUN (show_bgp_instance_updgrps_adj_s,
10096 show_bgp_instance_updgrps_adj_s_cmd,
9ccf14f7 10097 "show bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
8386ac43 10098 SHOW_STR
10099 BGP_STR
10100 BGP_INSTANCE_HELP_STR
10101 "BGP update groups\n"
10102 "Specific subgroup to display info for\n"
10103 "Advertisement queue\n"
10104 "Announced routes\n"
10105 "Packet queue\n")
10106{
c500ae40
DW
10107 int idx_word = 3;
10108 int idx_type = 6;
f43e655e 10109 uint64_t subgrp_id;
8386ac43 10110
c500ae40 10111 VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_type]->arg);
8386ac43 10112
c500ae40 10113 show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, argv[3], subgrp_id);
8386ac43 10114 return CMD_SUCCESS;
10115}
10116
10117
8fe8a7f6 10118
f14e6fdb
DS
10119static int
10120bgp_show_one_peer_group (struct vty *vty, struct peer_group *group)
10121{
10122 struct listnode *node, *nnode;
10123 struct prefix *range;
10124 struct peer *conf;
10125 struct peer *peer;
4690c7d7 10126 char buf[PREFIX2STR_BUFFER];
f14e6fdb
DS
10127 afi_t afi;
10128 safi_t safi;
ffd0c037
DS
10129 const char *peer_status;
10130 const char *af_str;
f14e6fdb
DS
10131 int lr_count;
10132 int dynamic;
10133 int af_cfgd;
10134
10135 conf = group->conf;
10136
0299c004
DS
10137 if (conf->as_type == AS_SPECIFIED ||
10138 conf->as_type == AS_EXTERNAL) {
66b199b2 10139 vty_out (vty, "%sBGP peer-group %s, remote AS %d%s",
f14e6fdb 10140 VTY_NEWLINE, group->name, conf->as, VTY_NEWLINE);
0299c004 10141 } else if (conf->as_type == AS_INTERNAL) {
66b199b2 10142 vty_out (vty, "%sBGP peer-group %s, remote AS %d%s",
0299c004 10143 VTY_NEWLINE, group->name, group->bgp->as, VTY_NEWLINE);
66b199b2
DS
10144 } else {
10145 vty_out (vty, "%sBGP peer-group %s%s",
10146 VTY_NEWLINE, group->name, VTY_NEWLINE);
0299c004 10147 }
f14e6fdb 10148
0299c004 10149 if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL))
f14e6fdb
DS
10150 vty_out (vty, " Peer-group type is internal%s", VTY_NEWLINE);
10151 else
10152 vty_out (vty, " Peer-group type is external%s", VTY_NEWLINE);
10153
10154 /* Display AFs configured. */
10155 vty_out (vty, " Configured address-families:");
10156 for (afi = AFI_IP; afi < AFI_MAX; afi++)
10157 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
10158 {
10159 if (conf->afc[afi][safi])
10160 {
10161 af_cfgd = 1;
10162 vty_out (vty, " %s;", afi_safi_print(afi, safi));
10163 }
10164 }
10165 if (!af_cfgd)
10166 vty_out (vty, " none%s", VTY_NEWLINE);
10167 else
10168 vty_out (vty, "%s", VTY_NEWLINE);
10169
10170 /* Display listen ranges (for dynamic neighbors), if any */
10171 for (afi = AFI_IP; afi < AFI_MAX; afi++)
10172 {
10173 if (afi == AFI_IP)
10174 af_str = "IPv4";
10175 else if (afi == AFI_IP6)
10176 af_str = "IPv6";
10177 lr_count = listcount(group->listen_range[afi]);
10178 if (lr_count)
10179 {
10180 vty_out(vty,
10181 " %d %s listen range(s)%s",
10182 lr_count, af_str, VTY_NEWLINE);
10183
10184
10185 for (ALL_LIST_ELEMENTS (group->listen_range[afi], node,
10186 nnode, range))
10187 {
10188 prefix2str(range, buf, sizeof(buf));
10189 vty_out(vty, " %s%s", buf, VTY_NEWLINE);
10190 }
10191 }
10192 }
10193
10194 /* Display group members and their status */
10195 if (listcount(group->peer))
10196 {
10197 vty_out (vty, " Peer-group members:%s", VTY_NEWLINE);
10198 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
10199 {
10200 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
10201 peer_status = "Idle (Admin)";
10202 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
10203 peer_status = "Idle (PfxCt)";
10204 else
10205 peer_status = LOOKUP(bgp_status_msg, peer->status);
10206
10207 dynamic = peer_dynamic_neighbor(peer);
10208 vty_out (vty, " %s %s %s %s",
10209 peer->host, dynamic ? "(dynamic)" : "",
10210 peer_status, VTY_NEWLINE);
10211 }
10212 }
10213
10214 return CMD_SUCCESS;
10215}
10216
10217/* Show BGP peer group's information. */
10218enum show_group_type
10219{
10220 show_all_groups,
10221 show_peer_group
10222};
10223
10224static int
10225bgp_show_peer_group (struct vty *vty, struct bgp *bgp,
10226 enum show_group_type type, const char *group_name)
10227{
10228 struct listnode *node, *nnode;
10229 struct peer_group *group;
10230 int find = 0;
10231
10232 for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
10233 {
10234 switch (type)
10235 {
10236 case show_all_groups:
10237 bgp_show_one_peer_group (vty, group);
10238 break;
10239 case show_peer_group:
10240 if (group_name && (strcmp(group->name, group_name) == 0))
10241 {
10242 find = 1;
10243 bgp_show_one_peer_group (vty, group);
10244 }
10245 break;
10246 }
10247 }
10248
10249 if (type == show_peer_group && ! find)
6d9e66dc 10250 vty_out (vty, "%% No such peer-group%s", VTY_NEWLINE);
f14e6fdb
DS
10251
10252 return CMD_SUCCESS;
10253}
10254
10255static int
10256bgp_show_peer_group_vty (struct vty *vty, const char *name,
10257 enum show_group_type type, const char *group_name)
10258{
10259 struct bgp *bgp;
10260 int ret = CMD_SUCCESS;
10261
10262 if (name)
8386ac43 10263 bgp = bgp_lookup_by_name (name);
10264 else
10265 bgp = bgp_get_default ();
f14e6fdb 10266
8386ac43 10267 if (! bgp)
10268 {
10269 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
10270 return CMD_WARNING;
f14e6fdb
DS
10271 }
10272
8386ac43 10273 ret = bgp_show_peer_group (vty, bgp, type, group_name);
f14e6fdb
DS
10274
10275 return ret;
10276}
10277
10278DEFUN (show_ip_bgp_peer_groups,
10279 show_ip_bgp_peer_groups_cmd,
10280 "show ip bgp peer-group",
10281 SHOW_STR
10282 IP_STR
10283 BGP_STR
10284 "Detailed information on all BGP peer groups\n")
10285{
10286 return bgp_show_peer_group_vty (vty, NULL, show_all_groups, NULL);
10287}
10288
10289DEFUN (show_ip_bgp_instance_peer_groups,
10290 show_ip_bgp_instance_peer_groups_cmd,
9ccf14f7 10291 "show ip bgp <view|vrf> WORD peer-group",
f14e6fdb
DS
10292 SHOW_STR
10293 IP_STR
10294 BGP_STR
8386ac43 10295 BGP_INSTANCE_HELP_STR
f14e6fdb
DS
10296 "Detailed information on all BGP peer groups\n")
10297{
c500ae40
DW
10298 int idx_word = 4;
10299 return bgp_show_peer_group_vty (vty, argv[idx_word]->arg, show_all_groups, NULL);
f14e6fdb
DS
10300}
10301
10302DEFUN (show_ip_bgp_peer_group,
10303 show_ip_bgp_peer_group_cmd,
10304 "show ip bgp peer-group WORD",
10305 SHOW_STR
10306 IP_STR
10307 BGP_STR
10308 "BGP peer-group name\n"
10309 "Detailed information on a BGP peer group\n")
10310{
c500ae40
DW
10311 int idx_word = 4;
10312 return bgp_show_peer_group_vty (vty, NULL, show_peer_group, argv[idx_word]->arg);
f14e6fdb
DS
10313}
10314
10315DEFUN (show_ip_bgp_instance_peer_group,
10316 show_ip_bgp_instance_peer_group_cmd,
9ccf14f7 10317 "show ip bgp <view|vrf> WORD peer-group WORD",
f14e6fdb
DS
10318 SHOW_STR
10319 IP_STR
10320 BGP_STR
8386ac43 10321 BGP_INSTANCE_HELP_STR
f14e6fdb
DS
10322 "BGP peer-group name\n"
10323 "Detailed information on a BGP peer group\n")
10324{
c500ae40
DW
10325 int idx_word = 4;
10326 int idx_word_2 = 6;
10327 return bgp_show_peer_group_vty (vty, argv[idx_word]->arg, show_peer_group, argv[idx_word_2]->arg);
f14e6fdb 10328}
3f9c7369 10329
718e3744 10330/* Redistribute VTY commands. */
10331
718e3744 10332DEFUN (bgp_redistribute_ipv4,
10333 bgp_redistribute_ipv4_cmd,
9ccf14f7 10334 "redistribute <kernel|connected|static|rip|ospf|isis|pim|table>",
718e3744 10335 "Redistribute information from another routing protocol\n"
e0ca5fde 10336 QUAGGA_IP_REDIST_HELP_STR_BGPD)
718e3744 10337{
c500ae40 10338 int idx_protocol = 1;
718e3744 10339 int type;
10340
c500ae40 10341 type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg);
e0ca5fde 10342 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 10343 {
10344 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10345 return CMD_WARNING;
10346 }
7c8ff89e 10347 bgp_redist_add(vty->index, AFI_IP, type, 0);
6aeb9e78 10348 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
718e3744 10349}
10350
10351DEFUN (bgp_redistribute_ipv4_rmap,
10352 bgp_redistribute_ipv4_rmap_cmd,
9ccf14f7 10353 "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> route-map WORD",
718e3744 10354 "Redistribute information from another routing protocol\n"
e0ca5fde 10355 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 10356 "Route map reference\n"
10357 "Pointer to route-map entries\n")
10358{
c500ae40
DW
10359 int idx_protocol = 1;
10360 int idx_word = 3;
718e3744 10361 int type;
7c8ff89e 10362 struct bgp_redist *red;
718e3744 10363
c500ae40 10364 type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg);
e0ca5fde 10365 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 10366 {
10367 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10368 return CMD_WARNING;
10369 }
10370
7c8ff89e 10371 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
c500ae40 10372 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
6aeb9e78 10373 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
718e3744 10374}
10375
10376DEFUN (bgp_redistribute_ipv4_metric,
10377 bgp_redistribute_ipv4_metric_cmd,
9ccf14f7 10378 "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> metric (0-4294967295)",
718e3744 10379 "Redistribute information from another routing protocol\n"
e0ca5fde 10380 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 10381 "Metric for redistributed routes\n"
10382 "Default metric\n")
10383{
c500ae40
DW
10384 int idx_protocol = 1;
10385 int idx_number = 3;
718e3744 10386 int type;
10387 u_int32_t metric;
7c8ff89e 10388 struct bgp_redist *red;
718e3744 10389
c500ae40 10390 type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg);
e0ca5fde 10391 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 10392 {
10393 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10394 return CMD_WARNING;
10395 }
c500ae40 10396 VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg);
718e3744 10397
7c8ff89e 10398 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
caf958b4 10399 bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
6aeb9e78 10400 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
718e3744 10401}
10402
10403DEFUN (bgp_redistribute_ipv4_rmap_metric,
10404 bgp_redistribute_ipv4_rmap_metric_cmd,
9ccf14f7 10405 "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> route-map WORD metric (0-4294967295)",
718e3744 10406 "Redistribute information from another routing protocol\n"
e0ca5fde 10407 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 10408 "Route map reference\n"
10409 "Pointer to route-map entries\n"
10410 "Metric for redistributed routes\n"
10411 "Default metric\n")
10412{
c500ae40
DW
10413 int idx_protocol = 1;
10414 int idx_word = 3;
10415 int idx_number = 5;
718e3744 10416 int type;
10417 u_int32_t metric;
7c8ff89e 10418 struct bgp_redist *red;
718e3744 10419
c500ae40 10420 type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg);
e0ca5fde 10421 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 10422 {
10423 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10424 return CMD_WARNING;
10425 }
c500ae40 10426 VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg);
718e3744 10427
7c8ff89e 10428 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
c500ae40 10429 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
caf958b4 10430 bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
6aeb9e78 10431 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
718e3744 10432}
10433
10434DEFUN (bgp_redistribute_ipv4_metric_rmap,
10435 bgp_redistribute_ipv4_metric_rmap_cmd,
9ccf14f7 10436 "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> metric (0-4294967295) route-map WORD",
718e3744 10437 "Redistribute information from another routing protocol\n"
e0ca5fde 10438 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 10439 "Metric for redistributed routes\n"
10440 "Default metric\n"
10441 "Route map reference\n"
10442 "Pointer to route-map entries\n")
10443{
c500ae40
DW
10444 int idx_protocol = 1;
10445 int idx_number = 3;
10446 int idx_word = 5;
718e3744 10447 int type;
10448 u_int32_t metric;
7c8ff89e 10449 struct bgp_redist *red;
718e3744 10450
c500ae40 10451 type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg);
e0ca5fde 10452 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 10453 {
10454 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10455 return CMD_WARNING;
10456 }
c500ae40 10457 VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg);
718e3744 10458
7c8ff89e 10459 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
caf958b4 10460 bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
c500ae40 10461 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
6aeb9e78 10462 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
718e3744 10463}
10464
7c8ff89e
DS
10465DEFUN (bgp_redistribute_ipv4_ospf,
10466 bgp_redistribute_ipv4_ospf_cmd,
6147e2c6 10467 "redistribute <ospf|table> (1-65535)",
7c8ff89e
DS
10468 "Redistribute information from another routing protocol\n"
10469 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
10470 "Non-main Kernel Routing Table\n"
10471 "Instance ID/Table ID\n")
7c8ff89e 10472{
c500ae40
DW
10473 int idx_ospf_table = 1;
10474 int idx_number = 2;
7c8ff89e 10475 u_short instance;
7a4bb9c5 10476 u_short protocol;
7c8ff89e 10477
c500ae40 10478 VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg);
7a4bb9c5 10479
c500ae40 10480 if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
7a4bb9c5
DS
10481 protocol = ZEBRA_ROUTE_OSPF;
10482 else
10483 protocol = ZEBRA_ROUTE_TABLE;
10484
10485 bgp_redist_add(vty->index, AFI_IP, protocol, instance);
6aeb9e78 10486 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
7c8ff89e
DS
10487}
10488
10489DEFUN (bgp_redistribute_ipv4_ospf_rmap,
10490 bgp_redistribute_ipv4_ospf_rmap_cmd,
6147e2c6 10491 "redistribute <ospf|table> (1-65535) route-map WORD",
7c8ff89e
DS
10492 "Redistribute information from another routing protocol\n"
10493 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
10494 "Non-main Kernel Routing Table\n"
10495 "Instance ID/Table ID\n"
7c8ff89e
DS
10496 "Route map reference\n"
10497 "Pointer to route-map entries\n")
10498{
c500ae40
DW
10499 int idx_ospf_table = 1;
10500 int idx_number = 2;
10501 int idx_word = 4;
7c8ff89e
DS
10502 struct bgp_redist *red;
10503 u_short instance;
7a4bb9c5 10504 int protocol;
7c8ff89e 10505
c500ae40 10506 if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
7a4bb9c5
DS
10507 protocol = ZEBRA_ROUTE_OSPF;
10508 else
10509 protocol = ZEBRA_ROUTE_TABLE;
10510
c500ae40 10511 VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg);
7a4bb9c5 10512 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
c500ae40 10513 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
6aeb9e78 10514 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
7c8ff89e
DS
10515}
10516
10517DEFUN (bgp_redistribute_ipv4_ospf_metric,
10518 bgp_redistribute_ipv4_ospf_metric_cmd,
6147e2c6 10519 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
7c8ff89e
DS
10520 "Redistribute information from another routing protocol\n"
10521 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
10522 "Non-main Kernel Routing Table\n"
10523 "Instance ID/Table ID\n"
7c8ff89e
DS
10524 "Metric for redistributed routes\n"
10525 "Default metric\n")
10526{
c500ae40
DW
10527 int idx_ospf_table = 1;
10528 int idx_number = 2;
10529 int idx_number_2 = 4;
7c8ff89e
DS
10530 u_int32_t metric;
10531 struct bgp_redist *red;
10532 u_short instance;
7a4bb9c5 10533 int protocol;
7c8ff89e 10534
c500ae40 10535 if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
7a4bb9c5
DS
10536 protocol = ZEBRA_ROUTE_OSPF;
10537 else
10538 protocol = ZEBRA_ROUTE_TABLE;
7c8ff89e 10539
c500ae40
DW
10540 VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg);
10541 VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg);
7a4bb9c5
DS
10542
10543 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
caf958b4 10544 bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
6aeb9e78 10545 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
7c8ff89e
DS
10546}
10547
10548DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric,
10549 bgp_redistribute_ipv4_ospf_rmap_metric_cmd,
6147e2c6 10550 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
7c8ff89e
DS
10551 "Redistribute information from another routing protocol\n"
10552 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
10553 "Non-main Kernel Routing Table\n"
10554 "Instance ID/Table ID\n"
7c8ff89e
DS
10555 "Route map reference\n"
10556 "Pointer to route-map entries\n"
10557 "Metric for redistributed routes\n"
10558 "Default metric\n")
10559{
c500ae40
DW
10560 int idx_ospf_table = 1;
10561 int idx_number = 2;
10562 int idx_word = 4;
10563 int idx_number_2 = 6;
7c8ff89e
DS
10564 u_int32_t metric;
10565 struct bgp_redist *red;
10566 u_short instance;
7a4bb9c5 10567 int protocol;
7c8ff89e 10568
c500ae40 10569 if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
7a4bb9c5
DS
10570 protocol = ZEBRA_ROUTE_OSPF;
10571 else
10572 protocol = ZEBRA_ROUTE_TABLE;
7c8ff89e 10573
c500ae40
DW
10574 VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg);
10575 VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg);
7a4bb9c5
DS
10576
10577 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
c500ae40 10578 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
caf958b4 10579 bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
6aeb9e78 10580 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
7c8ff89e
DS
10581}
10582
10583DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap,
10584 bgp_redistribute_ipv4_ospf_metric_rmap_cmd,
6147e2c6 10585 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
7c8ff89e
DS
10586 "Redistribute information from another routing protocol\n"
10587 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
10588 "Non-main Kernel Routing Table\n"
10589 "Instance ID/Table ID\n"
7c8ff89e
DS
10590 "Metric for redistributed routes\n"
10591 "Default metric\n"
10592 "Route map reference\n"
10593 "Pointer to route-map entries\n")
10594{
c500ae40
DW
10595 int idx_ospf_table = 1;
10596 int idx_number = 2;
10597 int idx_number_2 = 4;
10598 int idx_word = 6;
7c8ff89e
DS
10599 u_int32_t metric;
10600 struct bgp_redist *red;
10601 u_short instance;
7a4bb9c5 10602 int protocol;
7c8ff89e 10603
c500ae40 10604 if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
7a4bb9c5
DS
10605 protocol = ZEBRA_ROUTE_OSPF;
10606 else
10607 protocol = ZEBRA_ROUTE_TABLE;
7c8ff89e 10608
c500ae40
DW
10609 VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg);
10610 VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg);
7a4bb9c5
DS
10611
10612 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
caf958b4 10613 bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
c500ae40 10614 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
6aeb9e78 10615 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
7c8ff89e
DS
10616}
10617
f412b39a
DW
10618/*
10619 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
10620 * "no redistribute (ospf|table) <1-65535> route-map WORD",
10621 * NO_STR
10622 * "Redistribute information from another routing protocol\n"
10623 * "Open Shortest Path First (OSPFv2)\n"
10624 * "Non-main Kernel Routing Table\n"
10625 * "Instance ID/Table ID\n"
10626 * "Route map reference\n"
10627 * "Pointer to route-map entries\n"
10628 *
10629 * "no redistribute (ospf|table) <1-65535> metric <0-4294967295>",
10630 * NO_STR
10631 * "Redistribute information from another routing protocol\n"
10632 * "Open Shortest Path First (OSPFv2)\n"
10633 * "Non-main Kernel Routing Table\n"
10634 * "Instance ID/Table ID\n"
10635 * "Metric for redistributed routes\n"
10636 * "Default metric\n"
10637 *
10638 * "no redistribute (ospf|table) <1-65535> route-map WORD metric <0-4294967295>",
10639 * NO_STR
10640 * "Redistribute information from another routing protocol\n"
10641 * "Open Shortest Path First (OSPFv2)\n"
10642 * "Non-main Kernel Routing Table\n"
10643 * "Instance ID/Table ID\n"
10644 * "Route map reference\n"
10645 * "Pointer to route-map entries\n"
10646 * "Metric for redistributed routes\n"
10647 * "Default metric\n"
10648 *
10649 * "no redistribute (ospf|table) <1-65535> metric <0-4294967295> route-map WORD",
10650 * NO_STR
10651 * "Redistribute information from another routing protocol\n"
10652 * "Open Shortest Path First (OSPFv2)\n"
10653 * "Non-main Kernel Routing Table\n"
10654 * "Instance ID/Table ID\n"
10655 * "Metric for redistributed routes\n"
10656 * "Default metric\n"
10657 * "Route map reference\n"
10658 * "Pointer to route-map entries\n"
10659 *
10660 */
7c8ff89e
DS
10661DEFUN (no_bgp_redistribute_ipv4_ospf,
10662 no_bgp_redistribute_ipv4_ospf_cmd,
6147e2c6 10663 "no redistribute <ospf|table> (1-65535)",
7c8ff89e
DS
10664 NO_STR
10665 "Redistribute information from another routing protocol\n"
10666 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
10667 "Non-main Kernel Routing Table\n"
10668 "Instance ID/Table ID\n")
7c8ff89e 10669{
c500ae40
DW
10670 int idx_ospf_table = 2;
10671 int idx_number = 3;
7c8ff89e 10672 u_short instance;
7a4bb9c5
DS
10673 int protocol;
10674
c500ae40 10675 if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
7a4bb9c5
DS
10676 protocol = ZEBRA_ROUTE_OSPF;
10677 else
10678 protocol = ZEBRA_ROUTE_TABLE;
7c8ff89e 10679
c500ae40 10680 VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg);
7a4bb9c5 10681 return bgp_redistribute_unset (vty->index, AFI_IP, protocol, instance);
7c8ff89e
DS
10682}
10683
7c8ff89e 10684
7c8ff89e 10685
7c8ff89e 10686
7c8ff89e 10687
f412b39a
DW
10688/*
10689 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9ccf14f7 10690 * "no redistribute <kernel|connected|static|rip|ospf|isis|pim|table> metric <0-4294967295> route-map WORD",
f412b39a
DW
10691 * NO_STR
10692 * "Redistribute information from another routing protocol\n"
10693 * QUAGGA_IP_REDIST_HELP_STR_BGPD
10694 * "Metric for redistributed routes\n"
10695 * "Default metric\n"
10696 * "Route map reference\n"
10697 * "Pointer to route-map entries\n"
10698 *
9ccf14f7 10699 * "no redistribute <kernel|connected|static|rip|ospf|isis|pim|table> route-map WORD",
f412b39a
DW
10700 * NO_STR
10701 * "Redistribute information from another routing protocol\n"
10702 * QUAGGA_IP_REDIST_HELP_STR_BGPD
10703 * "Route map reference\n"
10704 * "Pointer to route-map entries\n"
10705 *
9ccf14f7 10706 * "no redistribute <kernel|connected|static|rip|ospf|isis|pim|table> route-map WORD metric <0-4294967295>",
f412b39a
DW
10707 * NO_STR
10708 * "Redistribute information from another routing protocol\n"
10709 * QUAGGA_IP_REDIST_HELP_STR_BGPD
10710 * "Route map reference\n"
10711 * "Pointer to route-map entries\n"
10712 * "Metric for redistributed routes\n"
10713 * "Default metric\n"
10714 *
9ccf14f7 10715 * "no redistribute <kernel|connected|static|rip|ospf|isis|pim|table> metric <0-4294967295>",
f412b39a
DW
10716 * NO_STR
10717 * "Redistribute information from another routing protocol\n"
10718 * QUAGGA_IP_REDIST_HELP_STR_BGPD
10719 * "Metric for redistributed routes\n"
10720 * "Default metric\n"
10721 *
10722 */
718e3744 10723DEFUN (no_bgp_redistribute_ipv4,
10724 no_bgp_redistribute_ipv4_cmd,
9ccf14f7 10725 "no redistribute <kernel|connected|static|rip|ospf|isis|pim|table>",
718e3744 10726 NO_STR
10727 "Redistribute information from another routing protocol\n"
e0ca5fde 10728 QUAGGA_IP_REDIST_HELP_STR_BGPD)
718e3744 10729{
c500ae40 10730 int idx_protocol = 2;
718e3744 10731 int type;
10732
c500ae40 10733 type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg);
e0ca5fde 10734 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 10735 {
10736 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10737 return CMD_WARNING;
10738 }
7c8ff89e 10739 return bgp_redistribute_unset (vty->index, AFI_IP, type, 0);
718e3744 10740}
10741
718e3744 10742
718e3744 10743
718e3744 10744
6b0655a2 10745
718e3744 10746#ifdef HAVE_IPV6
10747DEFUN (bgp_redistribute_ipv6,
10748 bgp_redistribute_ipv6_cmd,
9ccf14f7 10749 "redistribute <kernel|connected|static|ripng|ospf6|isis|table>",
718e3744 10750 "Redistribute information from another routing protocol\n"
e0ca5fde 10751 QUAGGA_IP6_REDIST_HELP_STR_BGPD)
718e3744 10752{
c500ae40 10753 int idx_protocol = 1;
718e3744 10754 int type;
10755
c500ae40 10756 type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg);
e0ca5fde 10757 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 10758 {
10759 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10760 return CMD_WARNING;
10761 }
10762
7c8ff89e 10763 bgp_redist_add(vty->index, AFI_IP6, type, 0);
6aeb9e78 10764 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
718e3744 10765}
10766
10767DEFUN (bgp_redistribute_ipv6_rmap,
10768 bgp_redistribute_ipv6_rmap_cmd,
9ccf14f7 10769 "redistribute <kernel|connected|static|ripng|ospf6|isis|table> route-map WORD",
718e3744 10770 "Redistribute information from another routing protocol\n"
e0ca5fde 10771 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 10772 "Route map reference\n"
10773 "Pointer to route-map entries\n")
10774{
c500ae40
DW
10775 int idx_protocol = 1;
10776 int idx_word = 3;
718e3744 10777 int type;
7c8ff89e 10778 struct bgp_redist *red;
718e3744 10779
c500ae40 10780 type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg);
e0ca5fde 10781 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 10782 {
10783 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10784 return CMD_WARNING;
10785 }
10786
7c8ff89e 10787 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
c500ae40 10788 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
6aeb9e78 10789 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
718e3744 10790}
10791
10792DEFUN (bgp_redistribute_ipv6_metric,
10793 bgp_redistribute_ipv6_metric_cmd,
9ccf14f7 10794 "redistribute <kernel|connected|static|ripng|ospf6|isis|table> metric (0-4294967295)",
718e3744 10795 "Redistribute information from another routing protocol\n"
e0ca5fde 10796 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 10797 "Metric for redistributed routes\n"
10798 "Default metric\n")
10799{
c500ae40
DW
10800 int idx_protocol = 1;
10801 int idx_number = 3;
718e3744 10802 int type;
10803 u_int32_t metric;
7c8ff89e 10804 struct bgp_redist *red;
718e3744 10805
c500ae40 10806 type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg);
e0ca5fde 10807 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 10808 {
10809 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10810 return CMD_WARNING;
10811 }
c500ae40 10812 VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg);
718e3744 10813
7c8ff89e 10814 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
caf958b4 10815 bgp_redistribute_metric_set(vty->index, red, AFI_IP6, type, metric);
6aeb9e78 10816 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
718e3744 10817}
10818
10819DEFUN (bgp_redistribute_ipv6_rmap_metric,
10820 bgp_redistribute_ipv6_rmap_metric_cmd,
9ccf14f7 10821 "redistribute <kernel|connected|static|ripng|ospf6|isis|table> route-map WORD metric (0-4294967295)",
718e3744 10822 "Redistribute information from another routing protocol\n"
e0ca5fde 10823 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 10824 "Route map reference\n"
10825 "Pointer to route-map entries\n"
10826 "Metric for redistributed routes\n"
10827 "Default metric\n")
10828{
c500ae40
DW
10829 int idx_protocol = 1;
10830 int idx_word = 3;
10831 int idx_number = 5;
718e3744 10832 int type;
10833 u_int32_t metric;
7c8ff89e 10834 struct bgp_redist *red;
718e3744 10835
c500ae40 10836 type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg);
e0ca5fde 10837 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 10838 {
10839 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10840 return CMD_WARNING;
10841 }
c500ae40 10842 VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg);
718e3744 10843
7c8ff89e 10844 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
c500ae40 10845 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
caf958b4 10846 bgp_redistribute_metric_set(vty->index, red, AFI_IP6, type, metric);
6aeb9e78 10847 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
718e3744 10848}
10849
10850DEFUN (bgp_redistribute_ipv6_metric_rmap,
10851 bgp_redistribute_ipv6_metric_rmap_cmd,
9ccf14f7 10852 "redistribute <kernel|connected|static|ripng|ospf6|isis|table> metric (0-4294967295) route-map WORD",
718e3744 10853 "Redistribute information from another routing protocol\n"
e0ca5fde 10854 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 10855 "Metric for redistributed routes\n"
10856 "Default metric\n"
10857 "Route map reference\n"
10858 "Pointer to route-map entries\n")
10859{
c500ae40
DW
10860 int idx_protocol = 1;
10861 int idx_number = 3;
10862 int idx_word = 5;
718e3744 10863 int type;
10864 u_int32_t metric;
7c8ff89e 10865 struct bgp_redist *red;
718e3744 10866
c500ae40 10867 type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg);
e0ca5fde 10868 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 10869 {
10870 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10871 return CMD_WARNING;
10872 }
c500ae40 10873 VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg);
718e3744 10874
7c8ff89e 10875 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
caf958b4 10876 bgp_redistribute_metric_set(vty->index, red, AFI_IP6, SAFI_UNICAST, metric);
c500ae40 10877 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
6aeb9e78 10878 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
718e3744 10879}
10880
f412b39a
DW
10881/*
10882 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9ccf14f7 10883 * "no redistribute <kernel|connected|static|ripng|ospf6|isis|table> route-map WORD",
f412b39a
DW
10884 * NO_STR
10885 * "Redistribute information from another routing protocol\n"
10886 * QUAGGA_IP6_REDIST_HELP_STR_BGPD
10887 * "Route map reference\n"
10888 * "Pointer to route-map entries\n"
10889 *
9ccf14f7 10890 * "no redistribute <kernel|connected|static|ripng|ospf6|isis|table> route-map WORD metric <0-4294967295>",
f412b39a
DW
10891 * NO_STR
10892 * "Redistribute information from another routing protocol\n"
10893 * QUAGGA_IP6_REDIST_HELP_STR_BGPD
10894 * "Route map reference\n"
10895 * "Pointer to route-map entries\n"
10896 * "Metric for redistributed routes\n"
10897 * "Default metric\n"
10898 *
9ccf14f7 10899 * "no redistribute <kernel|connected|static|ripng|ospf6|isis|table> metric <0-4294967295> route-map WORD",
f412b39a
DW
10900 * NO_STR
10901 * "Redistribute information from another routing protocol\n"
10902 * QUAGGA_IP6_REDIST_HELP_STR_BGPD
10903 * "Metric for redistributed routes\n"
10904 * "Default metric\n"
10905 * "Route map reference\n"
10906 * "Pointer to route-map entries\n"
10907 *
9ccf14f7 10908 * "no redistribute <kernel|connected|static|ripng|ospf6|isis|table> metric <0-4294967295>",
f412b39a
DW
10909 * NO_STR
10910 * "Redistribute information from another routing protocol\n"
10911 * QUAGGA_IP6_REDIST_HELP_STR_BGPD
10912 * "Metric for redistributed routes\n"
10913 * "Default metric\n"
10914 *
10915 */
718e3744 10916DEFUN (no_bgp_redistribute_ipv6,
10917 no_bgp_redistribute_ipv6_cmd,
9ccf14f7 10918 "no redistribute <kernel|connected|static|ripng|ospf6|isis|table>",
718e3744 10919 NO_STR
10920 "Redistribute information from another routing protocol\n"
e0ca5fde 10921 QUAGGA_IP6_REDIST_HELP_STR_BGPD)
718e3744 10922{
c500ae40 10923 int idx_protocol = 2;
718e3744 10924 int type;
10925
c500ae40 10926 type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg);
e0ca5fde 10927 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 10928 {
10929 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10930 return CMD_WARNING;
10931 }
10932
7c8ff89e 10933 return bgp_redistribute_unset (vty->index, AFI_IP6, type, 0);
718e3744 10934}
10935
718e3744 10936
718e3744 10937
718e3744 10938
718e3744 10939#endif /* HAVE_IPV6 */
6b0655a2 10940
718e3744 10941int
10942bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi,
10943 safi_t safi, int *write)
10944{
10945 int i;
718e3744 10946
10947 /* Unicast redistribution only. */
10948 if (safi != SAFI_UNICAST)
10949 return 0;
10950
10951 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
10952 {
10953 /* Redistribute BGP does not make sense. */
7c8ff89e 10954 if (i != ZEBRA_ROUTE_BGP)
718e3744 10955 {
7c8ff89e
DS
10956 struct list *red_list;
10957 struct listnode *node;
10958 struct bgp_redist *red;
718e3744 10959
7c8ff89e
DS
10960 red_list = bgp->redist[afi][i];
10961 if (!red_list)
10962 continue;
718e3744 10963
7c8ff89e
DS
10964 for (ALL_LIST_ELEMENTS_RO(red_list, node, red))
10965 {
10966 /* Display "address-family" when it is not yet diplayed. */
10967 bgp_config_write_family_header (vty, afi, safi, write);
10968
10969 /* "redistribute" configuration. */
0b960b4d 10970 vty_out (vty, " redistribute %s", zebra_route_string(i));
7c8ff89e
DS
10971 if (red->instance)
10972 vty_out (vty, " %d", red->instance);
10973 if (red->redist_metric_flag)
10974 vty_out (vty, " metric %u", red->redist_metric);
10975 if (red->rmap.name)
10976 vty_out (vty, " route-map %s", red->rmap.name);
10977 vty_out (vty, "%s", VTY_NEWLINE);
10978 }
718e3744 10979 }
10980 }
10981 return *write;
10982}
6b0655a2 10983
718e3744 10984/* BGP node structure. */
7fc626de 10985static struct cmd_node bgp_node =
718e3744 10986{
10987 BGP_NODE,
10988 "%s(config-router)# ",
10989 1,
10990};
10991
7fc626de 10992static struct cmd_node bgp_ipv4_unicast_node =
718e3744 10993{
10994 BGP_IPV4_NODE,
10995 "%s(config-router-af)# ",
10996 1,
10997};
10998
7fc626de 10999static struct cmd_node bgp_ipv4_multicast_node =
718e3744 11000{
11001 BGP_IPV4M_NODE,
11002 "%s(config-router-af)# ",
11003 1,
11004};
11005
7fc626de 11006static struct cmd_node bgp_ipv6_unicast_node =
718e3744 11007{
11008 BGP_IPV6_NODE,
11009 "%s(config-router-af)# ",
11010 1,
11011};
11012
7fc626de 11013static struct cmd_node bgp_ipv6_multicast_node =
25ffbdc1 11014{
11015 BGP_IPV6M_NODE,
11016 "%s(config-router-af)# ",
11017 1,
11018};
11019
7fc626de 11020static struct cmd_node bgp_vpnv4_node =
718e3744 11021{
11022 BGP_VPNV4_NODE,
11023 "%s(config-router-af)# ",
11024 1
11025};
6b0655a2 11026
8ecd3266 11027static struct cmd_node bgp_vpnv6_node =
11028{
11029 BGP_VPNV6_NODE,
11030 "%s(config-router-af-vpnv6)# ",
11031 1
11032};
11033
8b1fb8be
LB
11034static struct cmd_node bgp_encap_node =
11035{
11036 BGP_ENCAP_NODE,
11037 "%s(config-router-af-encap)# ",
11038 1
11039};
11040
11041static struct cmd_node bgp_encapv6_node =
11042{
11043 BGP_ENCAPV6_NODE,
11044 "%s(config-router-af-encapv6)# ",
11045 1
11046};
11047
1f8ae70b 11048static void community_list_vty (void);
11049
718e3744 11050void
94f2b392 11051bgp_vty_init (void)
718e3744 11052{
718e3744 11053 /* Install bgp top node. */
11054 install_node (&bgp_node, bgp_config_write);
11055 install_node (&bgp_ipv4_unicast_node, NULL);
11056 install_node (&bgp_ipv4_multicast_node, NULL);
11057 install_node (&bgp_ipv6_unicast_node, NULL);
25ffbdc1 11058 install_node (&bgp_ipv6_multicast_node, NULL);
718e3744 11059 install_node (&bgp_vpnv4_node, NULL);
8ecd3266 11060 install_node (&bgp_vpnv6_node, NULL);
8b1fb8be
LB
11061 install_node (&bgp_encap_node, NULL);
11062 install_node (&bgp_encapv6_node, NULL);
718e3744 11063
11064 /* Install default VTY commands to new nodes. */
11065 install_default (BGP_NODE);
11066 install_default (BGP_IPV4_NODE);
11067 install_default (BGP_IPV4M_NODE);
11068 install_default (BGP_IPV6_NODE);
25ffbdc1 11069 install_default (BGP_IPV6M_NODE);
718e3744 11070 install_default (BGP_VPNV4_NODE);
8ecd3266 11071 install_default (BGP_VPNV6_NODE);
8b1fb8be
LB
11072 install_default (BGP_ENCAP_NODE);
11073 install_default (BGP_ENCAPV6_NODE);
718e3744 11074
11075 /* "bgp multiple-instance" commands. */
11076 install_element (CONFIG_NODE, &bgp_multiple_instance_cmd);
11077 install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd);
11078
11079 /* "bgp config-type" commands. */
11080 install_element (CONFIG_NODE, &bgp_config_type_cmd);
718e3744 11081
5fe9f963 11082 /* bgp route-map delay-timer commands. */
11083 install_element (CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd);
11084 install_element (CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd);
5fe9f963 11085
718e3744 11086 /* Dummy commands (Currently not supported) */
11087 install_element (BGP_NODE, &no_synchronization_cmd);
11088 install_element (BGP_NODE, &no_auto_summary_cmd);
11089
11090 /* "router bgp" commands. */
11091 install_element (CONFIG_NODE, &router_bgp_cmd);
718e3744 11092
11093 /* "no router bgp" commands. */
11094 install_element (CONFIG_NODE, &no_router_bgp_cmd);
718e3744 11095
11096 /* "bgp router-id" commands. */
11097 install_element (BGP_NODE, &bgp_router_id_cmd);
11098 install_element (BGP_NODE, &no_bgp_router_id_cmd);
718e3744 11099
11100 /* "bgp cluster-id" commands. */
11101 install_element (BGP_NODE, &bgp_cluster_id_cmd);
718e3744 11102 install_element (BGP_NODE, &no_bgp_cluster_id_cmd);
718e3744 11103
11104 /* "bgp confederation" commands. */
11105 install_element (BGP_NODE, &bgp_confederation_identifier_cmd);
11106 install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd);
718e3744 11107
11108 /* "bgp confederation peers" commands. */
11109 install_element (BGP_NODE, &bgp_confederation_peers_cmd);
11110 install_element (BGP_NODE, &no_bgp_confederation_peers_cmd);
11111
abc920f8
DS
11112 /* bgp max-med command */
11113 install_element (BGP_NODE, &bgp_maxmed_admin_cmd);
11114 install_element (BGP_NODE, &no_bgp_maxmed_admin_cmd);
11115 install_element (BGP_NODE, &bgp_maxmed_admin_medv_cmd);
abc920f8
DS
11116 install_element (BGP_NODE, &bgp_maxmed_onstartup_cmd);
11117 install_element (BGP_NODE, &no_bgp_maxmed_onstartup_cmd);
abc920f8 11118 install_element (BGP_NODE, &bgp_maxmed_onstartup_medv_cmd);
abc920f8 11119
907f92c8
DS
11120 /* bgp disable-ebgp-connected-nh-check */
11121 install_element (BGP_NODE, &bgp_disable_connected_route_check_cmd);
11122 install_element (BGP_NODE, &no_bgp_disable_connected_route_check_cmd);
11123
f188f2c4
DS
11124 /* bgp update-delay command */
11125 install_element (BGP_NODE, &bgp_update_delay_cmd);
11126 install_element (BGP_NODE, &no_bgp_update_delay_cmd);
11127 install_element (BGP_NODE, &bgp_update_delay_establish_wait_cmd);
f188f2c4 11128
cb1faec9
DS
11129 install_element (BGP_NODE, &bgp_wpkt_quanta_cmd);
11130 install_element (BGP_NODE, &no_bgp_wpkt_quanta_cmd);
11131
3f9c7369
DS
11132 install_element (BGP_NODE, &bgp_coalesce_time_cmd);
11133 install_element (BGP_NODE, &no_bgp_coalesce_time_cmd);
11134
165b5fff
JB
11135 /* "maximum-paths" commands. */
11136 install_element (BGP_NODE, &bgp_maxpaths_cmd);
11137 install_element (BGP_NODE, &no_bgp_maxpaths_cmd);
165b5fff
JB
11138 install_element (BGP_IPV4_NODE, &bgp_maxpaths_cmd);
11139 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_cmd);
431aa9f9
DS
11140 install_element (BGP_IPV6_NODE, &bgp_maxpaths_cmd);
11141 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_cmd);
165b5fff 11142 install_element (BGP_NODE, &bgp_maxpaths_ibgp_cmd);
5e242b0d 11143 install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
165b5fff 11144 install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cmd);
165b5fff 11145 install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd);
5e242b0d 11146 install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
165b5fff 11147 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd);
431aa9f9 11148 install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd);
5e242b0d 11149 install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
431aa9f9 11150 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd);
165b5fff 11151
718e3744 11152 /* "timers bgp" commands. */
11153 install_element (BGP_NODE, &bgp_timers_cmd);
11154 install_element (BGP_NODE, &no_bgp_timers_cmd);
718e3744 11155
5fe9f963 11156 /* route-map delay-timer commands - per instance for backwards compat. */
518f0eb1
DS
11157 install_element (BGP_NODE, &bgp_set_route_map_delay_timer_cmd);
11158 install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd);
11159
718e3744 11160 /* "bgp client-to-client reflection" commands */
11161 install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd);
11162 install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd);
11163
11164 /* "bgp always-compare-med" commands */
11165 install_element (BGP_NODE, &bgp_always_compare_med_cmd);
11166 install_element (BGP_NODE, &no_bgp_always_compare_med_cmd);
11167
11168 /* "bgp deterministic-med" commands */
11169 install_element (BGP_NODE, &bgp_deterministic_med_cmd);
11170 install_element (BGP_NODE, &no_bgp_deterministic_med_cmd);
538621f2 11171
538621f2 11172 /* "bgp graceful-restart" commands */
11173 install_element (BGP_NODE, &bgp_graceful_restart_cmd);
11174 install_element (BGP_NODE, &no_bgp_graceful_restart_cmd);
93406d87 11175 install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd);
11176 install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd);
eb6f1b41
PG
11177 install_element (BGP_NODE, &bgp_graceful_restart_restart_time_cmd);
11178 install_element (BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd);
718e3744 11179
11180 /* "bgp fast-external-failover" commands */
11181 install_element (BGP_NODE, &bgp_fast_external_failover_cmd);
11182 install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd);
11183
11184 /* "bgp enforce-first-as" commands */
11185 install_element (BGP_NODE, &bgp_enforce_first_as_cmd);
11186 install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd);
11187
11188 /* "bgp bestpath compare-routerid" commands */
11189 install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd);
11190 install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd);
11191
11192 /* "bgp bestpath as-path ignore" commands */
11193 install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd);
11194 install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd);
11195
6811845b 11196 /* "bgp bestpath as-path confed" commands */
11197 install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd);
11198 install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd);
11199
2fdd455c
PM
11200 /* "bgp bestpath as-path multipath-relax" commands */
11201 install_element (BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd);
11202 install_element (BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd);
11203
848973c7 11204 /* "bgp log-neighbor-changes" commands */
11205 install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd);
11206 install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd);
11207
718e3744 11208 /* "bgp bestpath med" commands */
11209 install_element (BGP_NODE, &bgp_bestpath_med_cmd);
11210 install_element (BGP_NODE, &bgp_bestpath_med2_cmd);
718e3744 11211 install_element (BGP_NODE, &no_bgp_bestpath_med_cmd);
11212 install_element (BGP_NODE, &no_bgp_bestpath_med2_cmd);
718e3744 11213
11214 /* "no bgp default ipv4-unicast" commands. */
11215 install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd);
11216 install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd);
11217
11218 /* "bgp network import-check" commands. */
11219 install_element (BGP_NODE, &bgp_network_import_check_cmd);
8233ef81 11220 install_element (BGP_NODE, &bgp_network_import_check_exact_cmd);
718e3744 11221 install_element (BGP_NODE, &no_bgp_network_import_check_cmd);
11222
11223 /* "bgp default local-preference" commands. */
11224 install_element (BGP_NODE, &bgp_default_local_preference_cmd);
11225 install_element (BGP_NODE, &no_bgp_default_local_preference_cmd);
718e3744 11226
04b6bdc0
DW
11227 /* bgp default show-hostname */
11228 install_element (BGP_NODE, &bgp_default_show_hostname_cmd);
11229 install_element (BGP_NODE, &no_bgp_default_show_hostname_cmd);
11230
3f9c7369
DS
11231 /* "bgp default subgroup-pkt-queue-max" commands. */
11232 install_element (BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd);
11233 install_element (BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd);
11234
8bd9d948
DS
11235 /* bgp ibgp-allow-policy-mods command */
11236 install_element (BGP_NODE, &bgp_rr_allow_outbound_policy_cmd);
11237 install_element (BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd);
11238
f14e6fdb
DS
11239 /* "bgp listen limit" commands. */
11240 install_element (BGP_NODE, &bgp_listen_limit_cmd);
11241 install_element (BGP_NODE, &no_bgp_listen_limit_cmd);
11242
11243 /* "bgp listen range" commands. */
11244 install_element (BGP_NODE, &bgp_listen_range_cmd);
11245 install_element (BGP_NODE, &no_bgp_listen_range_cmd);
11246
718e3744 11247 /* "neighbor remote-as" commands. */
11248 install_element (BGP_NODE, &neighbor_remote_as_cmd);
a80beece 11249 install_element (BGP_NODE, &neighbor_interface_config_cmd);
4c48cf63 11250 install_element (BGP_NODE, &neighbor_interface_config_v6only_cmd);
b3a39dc5
DD
11251 install_element (BGP_NODE, &neighbor_interface_config_remote_as_cmd);
11252 install_element (BGP_NODE, &neighbor_interface_v6only_config_remote_as_cmd);
718e3744 11253 install_element (BGP_NODE, &no_neighbor_cmd);
a80beece 11254 install_element (BGP_NODE, &no_neighbor_interface_config_cmd);
718e3744 11255
11256 /* "neighbor peer-group" commands. */
11257 install_element (BGP_NODE, &neighbor_peer_group_cmd);
11258 install_element (BGP_NODE, &no_neighbor_peer_group_cmd);
a80beece 11259 install_element (BGP_NODE, &no_neighbor_interface_peer_group_remote_as_cmd);
718e3744 11260
11261 /* "neighbor local-as" commands. */
11262 install_element (BGP_NODE, &neighbor_local_as_cmd);
11263 install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd);
9d3f9705 11264 install_element (BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd);
718e3744 11265 install_element (BGP_NODE, &no_neighbor_local_as_cmd);
718e3744 11266
3f9c7369
DS
11267 /* "neighbor solo" commands. */
11268 install_element (BGP_NODE, &neighbor_solo_cmd);
11269 install_element (BGP_NODE, &no_neighbor_solo_cmd);
11270
0df7c91f
PJ
11271 /* "neighbor password" commands. */
11272 install_element (BGP_NODE, &neighbor_password_cmd);
11273 install_element (BGP_NODE, &no_neighbor_password_cmd);
11274
718e3744 11275 /* "neighbor activate" commands. */
11276 install_element (BGP_NODE, &neighbor_activate_cmd);
11277 install_element (BGP_IPV4_NODE, &neighbor_activate_cmd);
11278 install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd);
11279 install_element (BGP_IPV6_NODE, &neighbor_activate_cmd);
25ffbdc1 11280 install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd);
718e3744 11281 install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd);
8ecd3266 11282 install_element (BGP_VPNV6_NODE, &neighbor_activate_cmd);
8b1fb8be
LB
11283 install_element (BGP_ENCAP_NODE, &neighbor_activate_cmd);
11284 install_element (BGP_ENCAPV6_NODE, &neighbor_activate_cmd);
718e3744 11285
11286 /* "no neighbor activate" commands. */
11287 install_element (BGP_NODE, &no_neighbor_activate_cmd);
11288 install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd);
11289 install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd);
11290 install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd);
25ffbdc1 11291 install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd);
718e3744 11292 install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd);
8ecd3266 11293 install_element (BGP_VPNV6_NODE, &no_neighbor_activate_cmd);
8b1fb8be
LB
11294 install_element (BGP_ENCAP_NODE, &no_neighbor_activate_cmd);
11295 install_element (BGP_ENCAPV6_NODE, &no_neighbor_activate_cmd);
718e3744 11296
c8560b44
DW
11297 /* "neighbor peer-group" set commands.
11298 * Long term we should only accept this command under BGP_NODE and not all of
11299 * the afi/safi sub-contexts. For now though we need to accept it for backwards
11300 * compatibility. This changed when we stopped requiring that peers be assigned
11301 * to their peer-group under each address-family sub-context.
11302 */
718e3744 11303 install_element (BGP_NODE, &neighbor_set_peer_group_cmd);
11304 install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_cmd);
11305 install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_cmd);
11306 install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd);
25ffbdc1 11307 install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_cmd);
a58545bb 11308 install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_cmd);
8ecd3266 11309 install_element (BGP_VPNV6_NODE, &neighbor_set_peer_group_cmd);
8b1fb8be
LB
11310 install_element (BGP_ENCAP_NODE, &neighbor_set_peer_group_cmd);
11311 install_element (BGP_ENCAPV6_NODE, &neighbor_set_peer_group_cmd);
c8560b44 11312
718e3744 11313 /* "no neighbor peer-group unset" commands. */
11314 install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd);
11315 install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd);
11316 install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_cmd);
11317 install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd);
25ffbdc1 11318 install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_cmd);
a58545bb 11319 install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_cmd);
8ecd3266 11320 install_element (BGP_VPNV6_NODE, &no_neighbor_set_peer_group_cmd);
8b1fb8be
LB
11321 install_element (BGP_ENCAP_NODE, &no_neighbor_set_peer_group_cmd);
11322 install_element (BGP_ENCAPV6_NODE, &no_neighbor_set_peer_group_cmd);
a58545bb 11323
718e3744 11324 /* "neighbor softreconfiguration inbound" commands.*/
11325 install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd);
11326 install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd);
11327 install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd);
11328 install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
11329 install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd);
11330 install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd);
11331 install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd);
11332 install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
25ffbdc1 11333 install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd);
11334 install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd);
a58545bb 11335 install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd);
11336 install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
8ecd3266 11337 install_element (BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd);
11338 install_element (BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
8b1fb8be
LB
11339 install_element (BGP_ENCAP_NODE, &neighbor_soft_reconfiguration_cmd);
11340 install_element (BGP_ENCAP_NODE, &no_neighbor_soft_reconfiguration_cmd);
11341 install_element (BGP_ENCAPV6_NODE, &neighbor_soft_reconfiguration_cmd);
11342 install_element (BGP_ENCAPV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
718e3744 11343
11344 /* "neighbor attribute-unchanged" commands. */
11345 install_element (BGP_NODE, &neighbor_attr_unchanged_cmd);
11346 install_element (BGP_NODE, &neighbor_attr_unchanged1_cmd);
11347 install_element (BGP_NODE, &neighbor_attr_unchanged2_cmd);
11348 install_element (BGP_NODE, &neighbor_attr_unchanged3_cmd);
11349 install_element (BGP_NODE, &neighbor_attr_unchanged4_cmd);
718e3744 11350 install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd);
11351 install_element (BGP_NODE, &no_neighbor_attr_unchanged1_cmd);
11352 install_element (BGP_NODE, &no_neighbor_attr_unchanged2_cmd);
11353 install_element (BGP_NODE, &no_neighbor_attr_unchanged3_cmd);
11354 install_element (BGP_NODE, &no_neighbor_attr_unchanged4_cmd);
718e3744 11355 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd);
11356 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged1_cmd);
11357 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged2_cmd);
11358 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged3_cmd);
11359 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged4_cmd);
718e3744 11360 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd);
11361 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged1_cmd);
11362 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged2_cmd);
11363 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged3_cmd);
11364 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged4_cmd);
718e3744 11365 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd);
11366 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged1_cmd);
11367 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged2_cmd);
11368 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged3_cmd);
11369 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged4_cmd);
718e3744 11370 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd);
11371 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged1_cmd);
11372 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged2_cmd);
11373 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged3_cmd);
11374 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged4_cmd);
718e3744 11375 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd);
11376 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged1_cmd);
11377 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged2_cmd);
11378 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged3_cmd);
11379 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged4_cmd);
718e3744 11380 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd);
11381 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged1_cmd);
11382 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged2_cmd);
11383 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged3_cmd);
11384 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged4_cmd);
25ffbdc1 11385 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd);
11386 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged1_cmd);
11387 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged2_cmd);
11388 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged3_cmd);
11389 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged4_cmd);
25ffbdc1 11390 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd);
11391 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged1_cmd);
11392 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged2_cmd);
11393 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged3_cmd);
11394 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged4_cmd);
718e3744 11395 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd);
11396 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged1_cmd);
11397 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged2_cmd);
11398 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged3_cmd);
11399 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged4_cmd);
718e3744 11400 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd);
11401 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged1_cmd);
11402 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged2_cmd);
11403 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged3_cmd);
11404 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged4_cmd);
8ecd3266 11405 install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd);
11406 install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged1_cmd);
11407 install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged2_cmd);
11408 install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged3_cmd);
11409 install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged4_cmd);
8ecd3266 11410 install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd);
11411 install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged1_cmd);
11412 install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged2_cmd);
11413 install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged3_cmd);
11414 install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged4_cmd);
8ecd3266 11415
8b1fb8be
LB
11416 install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged_cmd);
11417 install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged1_cmd);
11418 install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged2_cmd);
11419 install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged3_cmd);
11420 install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged4_cmd);
8b1fb8be
LB
11421 install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged_cmd);
11422 install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged1_cmd);
11423 install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged2_cmd);
11424 install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged3_cmd);
11425 install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged4_cmd);
8b1fb8be
LB
11426
11427 install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged_cmd);
11428 install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged1_cmd);
11429 install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged2_cmd);
11430 install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged3_cmd);
11431 install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged4_cmd);
8b1fb8be
LB
11432 install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged_cmd);
11433 install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged1_cmd);
11434 install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged2_cmd);
11435 install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged3_cmd);
11436 install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged4_cmd);
718e3744 11437
fee0f4c6 11438 /* "nexthop-local unchanged" commands */
11439 install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd);
11440 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd);
11441
718e3744 11442 /* "neighbor next-hop-self" commands. */
11443 install_element (BGP_NODE, &neighbor_nexthop_self_cmd);
11444 install_element (BGP_NODE, &no_neighbor_nexthop_self_cmd);
11445 install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd);
11446 install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd);
11447 install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd);
11448 install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd);
11449 install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd);
11450 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd);
25ffbdc1 11451 install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd);
11452 install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd);
718e3744 11453 install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd);
11454 install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd);
8ecd3266 11455 install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd);
11456 install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd);
8b1fb8be
LB
11457 install_element (BGP_ENCAP_NODE, &neighbor_nexthop_self_cmd);
11458 install_element (BGP_ENCAP_NODE, &no_neighbor_nexthop_self_cmd);
11459 install_element (BGP_ENCAPV6_NODE, &neighbor_nexthop_self_cmd);
11460 install_element (BGP_ENCAPV6_NODE, &no_neighbor_nexthop_self_cmd);
718e3744 11461
a538debe
DS
11462 /* "neighbor next-hop-self force" commands. */
11463 install_element (BGP_NODE, &neighbor_nexthop_self_force_cmd);
11464 install_element (BGP_NODE, &no_neighbor_nexthop_self_force_cmd);
11465 install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd);
11466 install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd);
11467 install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd);
11468 install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd);
11469 install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd);
11470 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd);
11471 install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd);
11472 install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd);
11473 install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd);
11474 install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd);
8ecd3266 11475 install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd);
11476 install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd);
a538debe 11477
c7122e14
DS
11478 /* "neighbor as-override" commands. */
11479 install_element (BGP_NODE, &neighbor_as_override_cmd);
11480 install_element (BGP_NODE, &no_neighbor_as_override_cmd);
11481 install_element (BGP_IPV4_NODE, &neighbor_as_override_cmd);
11482 install_element (BGP_IPV4_NODE, &no_neighbor_as_override_cmd);
11483 install_element (BGP_IPV4M_NODE, &neighbor_as_override_cmd);
11484 install_element (BGP_IPV4M_NODE, &no_neighbor_as_override_cmd);
11485 install_element (BGP_IPV6_NODE, &neighbor_as_override_cmd);
11486 install_element (BGP_IPV6_NODE, &no_neighbor_as_override_cmd);
11487 install_element (BGP_IPV6M_NODE, &neighbor_as_override_cmd);
11488 install_element (BGP_IPV6M_NODE, &no_neighbor_as_override_cmd);
11489 install_element (BGP_VPNV4_NODE, &neighbor_as_override_cmd);
11490 install_element (BGP_VPNV4_NODE, &no_neighbor_as_override_cmd);
8ecd3266 11491 install_element (BGP_VPNV6_NODE, &neighbor_as_override_cmd);
11492 install_element (BGP_VPNV6_NODE, &no_neighbor_as_override_cmd);
c7122e14 11493
718e3744 11494 /* "neighbor remove-private-AS" commands. */
11495 install_element (BGP_NODE, &neighbor_remove_private_as_cmd);
11496 install_element (BGP_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
11497 install_element (BGP_NODE, &neighbor_remove_private_as_all_cmd);
11498 install_element (BGP_NODE, &no_neighbor_remove_private_as_all_cmd);
11499 install_element (BGP_NODE, &neighbor_remove_private_as_replace_as_cmd);
11500 install_element (BGP_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
11501 install_element (BGP_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
11502 install_element (BGP_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 11503 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd);
11504 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
11505 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd);
11506 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd);
11507 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_replace_as_cmd);
11508 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
11509 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
11510 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 11511 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd);
11512 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
11513 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd);
11514 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd);
11515 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_replace_as_cmd);
11516 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
11517 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
11518 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 11519 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd);
11520 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
11521 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd);
11522 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd);
11523 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_replace_as_cmd);
11524 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
11525 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
11526 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
25ffbdc1 11527 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd);
11528 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
11529 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd);
11530 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd);
11531 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_replace_as_cmd);
11532 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
11533 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
11534 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 11535 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd);
11536 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
11537 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd);
11538 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd);
11539 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_replace_as_cmd);
11540 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
11541 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
11542 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
8ecd3266 11543 install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd);
11544 install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd);
11545 install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd);
11546 install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd);
11547 install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_replace_as_cmd);
11548 install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
11549 install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
11550 install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
8b1fb8be
LB
11551 install_element (BGP_ENCAP_NODE, &neighbor_remove_private_as_cmd);
11552 install_element (BGP_ENCAP_NODE, &no_neighbor_remove_private_as_cmd);
11553 install_element (BGP_ENCAPV6_NODE, &neighbor_remove_private_as_cmd);
11554 install_element (BGP_ENCAPV6_NODE, &no_neighbor_remove_private_as_cmd);
718e3744 11555
11556 /* "neighbor send-community" commands.*/
11557 install_element (BGP_NODE, &neighbor_send_community_cmd);
11558 install_element (BGP_NODE, &neighbor_send_community_type_cmd);
11559 install_element (BGP_NODE, &no_neighbor_send_community_cmd);
11560 install_element (BGP_NODE, &no_neighbor_send_community_type_cmd);
11561 install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd);
11562 install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd);
11563 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd);
11564 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd);
11565 install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd);
11566 install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd);
11567 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd);
11568 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd);
11569 install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd);
11570 install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd);
11571 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd);
11572 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd);
25ffbdc1 11573 install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd);
11574 install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd);
11575 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd);
11576 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd);
718e3744 11577 install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd);
11578 install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd);
11579 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd);
11580 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd);
8ecd3266 11581 install_element (BGP_VPNV6_NODE, &neighbor_send_community_cmd);
11582 install_element (BGP_VPNV6_NODE, &neighbor_send_community_type_cmd);
11583 install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_cmd);
11584 install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd);
8b1fb8be
LB
11585 install_element (BGP_ENCAP_NODE, &neighbor_send_community_cmd);
11586 install_element (BGP_ENCAP_NODE, &neighbor_send_community_type_cmd);
11587 install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_cmd);
11588 install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_type_cmd);
11589 install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_cmd);
11590 install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_type_cmd);
11591 install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_cmd);
11592 install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_type_cmd);
718e3744 11593
11594 /* "neighbor route-reflector" commands.*/
11595 install_element (BGP_NODE, &neighbor_route_reflector_client_cmd);
11596 install_element (BGP_NODE, &no_neighbor_route_reflector_client_cmd);
11597 install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd);
11598 install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd);
11599 install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd);
11600 install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd);
11601 install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd);
11602 install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd);
25ffbdc1 11603 install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd);
11604 install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd);
718e3744 11605 install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd);
11606 install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd);
8ecd3266 11607 install_element (BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd);
11608 install_element (BGP_VPNV6_NODE, &no_neighbor_route_reflector_client_cmd);
8b1fb8be
LB
11609 install_element (BGP_ENCAP_NODE, &neighbor_route_reflector_client_cmd);
11610 install_element (BGP_ENCAP_NODE, &no_neighbor_route_reflector_client_cmd);
11611 install_element (BGP_ENCAPV6_NODE, &neighbor_route_reflector_client_cmd);
11612 install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_reflector_client_cmd);
718e3744 11613
11614 /* "neighbor route-server" commands.*/
11615 install_element (BGP_NODE, &neighbor_route_server_client_cmd);
11616 install_element (BGP_NODE, &no_neighbor_route_server_client_cmd);
11617 install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd);
11618 install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd);
11619 install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd);
11620 install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd);
11621 install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd);
11622 install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd);
25ffbdc1 11623 install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd);
11624 install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd);
718e3744 11625 install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd);
11626 install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd);
8ecd3266 11627 install_element (BGP_VPNV6_NODE, &neighbor_route_server_client_cmd);
11628 install_element (BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd);
8b1fb8be
LB
11629 install_element (BGP_ENCAP_NODE, &neighbor_route_server_client_cmd);
11630 install_element (BGP_ENCAP_NODE, &no_neighbor_route_server_client_cmd);
11631 install_element (BGP_ENCAPV6_NODE, &neighbor_route_server_client_cmd);
11632 install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_server_client_cmd);
718e3744 11633
adbac85e
DW
11634 /* "neighbor addpath-tx-all-paths" commands.*/
11635 install_element (BGP_NODE, &neighbor_addpath_tx_all_paths_cmd);
11636 install_element (BGP_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
11637 install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd);
11638 install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
11639 install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd);
11640 install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
11641 install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd);
11642 install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
11643 install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd);
11644 install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
11645 install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd);
11646 install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
8ecd3266 11647 install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd);
11648 install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
adbac85e 11649
06370dac
DW
11650 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
11651 install_element (BGP_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
11652 install_element (BGP_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
11653 install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
11654 install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
11655 install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
11656 install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
11657 install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
11658 install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
11659 install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
11660 install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
11661 install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
11662 install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
8ecd3266 11663 install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
11664 install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
06370dac 11665
718e3744 11666 /* "neighbor passive" commands. */
11667 install_element (BGP_NODE, &neighbor_passive_cmd);
11668 install_element (BGP_NODE, &no_neighbor_passive_cmd);
11669
d5a5c8f0 11670
718e3744 11671 /* "neighbor shutdown" commands. */
11672 install_element (BGP_NODE, &neighbor_shutdown_cmd);
11673 install_element (BGP_NODE, &no_neighbor_shutdown_cmd);
11674
8a92a8a0
DS
11675 /* "neighbor capability extended-nexthop" commands.*/
11676 install_element (BGP_NODE, &neighbor_capability_enhe_cmd);
11677 install_element (BGP_NODE, &no_neighbor_capability_enhe_cmd);
11678
718e3744 11679 /* "neighbor capability orf prefix-list" commands.*/
11680 install_element (BGP_NODE, &neighbor_capability_orf_prefix_cmd);
11681 install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_cmd);
11682 install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd);
11683 install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd);
11684 install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd);
11685 install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd);
11686 install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd);
11687 install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd);
25ffbdc1 11688 install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd);
11689 install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd);
718e3744 11690
11691 /* "neighbor capability dynamic" commands.*/
11692 install_element (BGP_NODE, &neighbor_capability_dynamic_cmd);
11693 install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd);
11694
11695 /* "neighbor dont-capability-negotiate" commands. */
11696 install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd);
11697 install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd);
11698
11699 /* "neighbor ebgp-multihop" commands. */
11700 install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd);
11701 install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd);
11702 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd);
718e3744 11703
6ffd2079 11704 /* "neighbor disable-connected-check" commands. */
11705 install_element (BGP_NODE, &neighbor_disable_connected_check_cmd);
11706 install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd);
718e3744 11707
11708 /* "neighbor description" commands. */
11709 install_element (BGP_NODE, &neighbor_description_cmd);
11710 install_element (BGP_NODE, &no_neighbor_description_cmd);
718e3744 11711
11712 /* "neighbor update-source" commands. "*/
11713 install_element (BGP_NODE, &neighbor_update_source_cmd);
11714 install_element (BGP_NODE, &no_neighbor_update_source_cmd);
11715
11716 /* "neighbor default-originate" commands. */
11717 install_element (BGP_NODE, &neighbor_default_originate_cmd);
11718 install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd);
11719 install_element (BGP_NODE, &no_neighbor_default_originate_cmd);
718e3744 11720 install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd);
11721 install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd);
11722 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd);
718e3744 11723 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd);
11724 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd);
11725 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd);
718e3744 11726 install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd);
11727 install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd);
11728 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd);
25ffbdc1 11729 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd);
11730 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd);
11731 install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd);
718e3744 11732
11733 /* "neighbor port" commands. */
11734 install_element (BGP_NODE, &neighbor_port_cmd);
11735 install_element (BGP_NODE, &no_neighbor_port_cmd);
718e3744 11736
11737 /* "neighbor weight" commands. */
11738 install_element (BGP_NODE, &neighbor_weight_cmd);
11739 install_element (BGP_NODE, &no_neighbor_weight_cmd);
718e3744 11740
11741 /* "neighbor override-capability" commands. */
11742 install_element (BGP_NODE, &neighbor_override_capability_cmd);
11743 install_element (BGP_NODE, &no_neighbor_override_capability_cmd);
11744
11745 /* "neighbor strict-capability-match" commands. */
11746 install_element (BGP_NODE, &neighbor_strict_capability_cmd);
11747 install_element (BGP_NODE, &no_neighbor_strict_capability_cmd);
11748
11749 /* "neighbor timers" commands. */
11750 install_element (BGP_NODE, &neighbor_timers_cmd);
11751 install_element (BGP_NODE, &no_neighbor_timers_cmd);
11752
11753 /* "neighbor timers connect" commands. */
11754 install_element (BGP_NODE, &neighbor_timers_connect_cmd);
11755 install_element (BGP_NODE, &no_neighbor_timers_connect_cmd);
718e3744 11756
11757 /* "neighbor advertisement-interval" commands. */
11758 install_element (BGP_NODE, &neighbor_advertise_interval_cmd);
11759 install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd);
718e3744 11760
718e3744 11761 /* "neighbor interface" commands. */
11762 install_element (BGP_NODE, &neighbor_interface_cmd);
11763 install_element (BGP_NODE, &no_neighbor_interface_cmd);
11764
11765 /* "neighbor distribute" commands. */
11766 install_element (BGP_NODE, &neighbor_distribute_list_cmd);
11767 install_element (BGP_NODE, &no_neighbor_distribute_list_cmd);
11768 install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd);
11769 install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd);
11770 install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd);
11771 install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd);
11772 install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd);
11773 install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd);
25ffbdc1 11774 install_element (BGP_IPV6M_NODE, &neighbor_distribute_list_cmd);
11775 install_element (BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd);
718e3744 11776 install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd);
11777 install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd);
8ecd3266 11778 install_element (BGP_VPNV6_NODE, &neighbor_distribute_list_cmd);
11779 install_element (BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd);
8b1fb8be
LB
11780 install_element (BGP_ENCAP_NODE, &neighbor_distribute_list_cmd);
11781 install_element (BGP_ENCAP_NODE, &no_neighbor_distribute_list_cmd);
11782 install_element (BGP_ENCAPV6_NODE, &neighbor_distribute_list_cmd);
11783 install_element (BGP_ENCAPV6_NODE, &no_neighbor_distribute_list_cmd);
718e3744 11784
11785 /* "neighbor prefix-list" commands. */
11786 install_element (BGP_NODE, &neighbor_prefix_list_cmd);
11787 install_element (BGP_NODE, &no_neighbor_prefix_list_cmd);
11788 install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd);
11789 install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd);
11790 install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd);
11791 install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd);
11792 install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd);
11793 install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd);
25ffbdc1 11794 install_element (BGP_IPV6M_NODE, &neighbor_prefix_list_cmd);
11795 install_element (BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd);
718e3744 11796 install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd);
11797 install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd);
8ecd3266 11798 install_element (BGP_VPNV6_NODE, &neighbor_prefix_list_cmd);
11799 install_element (BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd);
8b1fb8be
LB
11800 install_element (BGP_ENCAP_NODE, &neighbor_prefix_list_cmd);
11801 install_element (BGP_ENCAP_NODE, &no_neighbor_prefix_list_cmd);
11802 install_element (BGP_ENCAPV6_NODE, &neighbor_prefix_list_cmd);
11803 install_element (BGP_ENCAPV6_NODE, &no_neighbor_prefix_list_cmd);
718e3744 11804
11805 /* "neighbor filter-list" commands. */
11806 install_element (BGP_NODE, &neighbor_filter_list_cmd);
11807 install_element (BGP_NODE, &no_neighbor_filter_list_cmd);
11808 install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd);
11809 install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd);
11810 install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd);
11811 install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd);
11812 install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd);
11813 install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd);
25ffbdc1 11814 install_element (BGP_IPV6M_NODE, &neighbor_filter_list_cmd);
11815 install_element (BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd);
718e3744 11816 install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd);
11817 install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd);
8ecd3266 11818 install_element (BGP_VPNV6_NODE, &neighbor_filter_list_cmd);
11819 install_element (BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd);
8b1fb8be
LB
11820 install_element (BGP_ENCAP_NODE, &neighbor_filter_list_cmd);
11821 install_element (BGP_ENCAP_NODE, &no_neighbor_filter_list_cmd);
11822 install_element (BGP_ENCAPV6_NODE, &neighbor_filter_list_cmd);
11823 install_element (BGP_ENCAPV6_NODE, &no_neighbor_filter_list_cmd);
718e3744 11824
11825 /* "neighbor route-map" commands. */
11826 install_element (BGP_NODE, &neighbor_route_map_cmd);
11827 install_element (BGP_NODE, &no_neighbor_route_map_cmd);
11828 install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd);
11829 install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd);
11830 install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd);
11831 install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd);
11832 install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd);
11833 install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd);
25ffbdc1 11834 install_element (BGP_IPV6M_NODE, &neighbor_route_map_cmd);
11835 install_element (BGP_IPV6M_NODE, &no_neighbor_route_map_cmd);
718e3744 11836 install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd);
11837 install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd);
8ecd3266 11838 install_element (BGP_VPNV6_NODE, &neighbor_route_map_cmd);
11839 install_element (BGP_VPNV6_NODE, &no_neighbor_route_map_cmd);
8b1fb8be
LB
11840 install_element (BGP_ENCAP_NODE, &neighbor_route_map_cmd);
11841 install_element (BGP_ENCAP_NODE, &no_neighbor_route_map_cmd);
11842 install_element (BGP_ENCAPV6_NODE, &neighbor_route_map_cmd);
11843 install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_map_cmd);
718e3744 11844
11845 /* "neighbor unsuppress-map" commands. */
11846 install_element (BGP_NODE, &neighbor_unsuppress_map_cmd);
11847 install_element (BGP_NODE, &no_neighbor_unsuppress_map_cmd);
11848 install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd);
11849 install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd);
11850 install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd);
11851 install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd);
11852 install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd);
11853 install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd);
25ffbdc1 11854 install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd);
11855 install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd);
a58545bb 11856 install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd);
bb86c601 11857 install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd);
8ecd3266 11858 install_element (BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd);
bb86c601 11859 install_element (BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd);
8b1fb8be
LB
11860 install_element (BGP_ENCAP_NODE, &neighbor_unsuppress_map_cmd);
11861 install_element (BGP_ENCAP_NODE, &no_neighbor_unsuppress_map_cmd);
11862 install_element (BGP_ENCAPV6_NODE, &neighbor_unsuppress_map_cmd);
11863 install_element (BGP_ENCAPV6_NODE, &no_neighbor_unsuppress_map_cmd);
718e3744 11864
11865 /* "neighbor maximum-prefix" commands. */
11866 install_element (BGP_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 11867 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 11868 install_element (BGP_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 11869 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 11870 install_element (BGP_NODE, &neighbor_maximum_prefix_restart_cmd);
11871 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 11872 install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd);
718e3744 11873 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 11874 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 11875 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 11876 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 11877 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd);
11878 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 11879 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd);
718e3744 11880 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 11881 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 11882 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 11883 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 11884 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd);
11885 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 11886 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd);
718e3744 11887 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 11888 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 11889 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 11890 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 11891 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd);
11892 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 11893 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd);
25ffbdc1 11894 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd);
11895 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd);
11896 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd);
11897 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
11898 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd);
11899 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
11900 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd);
718e3744 11901 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 11902 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 11903 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 11904 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 11905 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd);
11906 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 11907 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd);
8ecd3266 11908 install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd);
11909 install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
11910 install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd);
11911 install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
11912 install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd);
11913 install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
11914 install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd);
718e3744 11915
8b1fb8be
LB
11916 install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_cmd);
11917 install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_cmd);
11918 install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_warning_cmd);
11919 install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
11920 install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_restart_cmd);
11921 install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
11922 install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_cmd);
8b1fb8be
LB
11923
11924 install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_cmd);
11925 install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
11926 install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_warning_cmd);
11927 install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
11928 install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_restart_cmd);
11929 install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
11930 install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_cmd);
8b1fb8be 11931
718e3744 11932 /* "neighbor allowas-in" */
11933 install_element (BGP_NODE, &neighbor_allowas_in_cmd);
718e3744 11934 install_element (BGP_NODE, &no_neighbor_allowas_in_cmd);
11935 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd);
718e3744 11936 install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd);
11937 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd);
718e3744 11938 install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd);
11939 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd);
718e3744 11940 install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd);
25ffbdc1 11941 install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd);
25ffbdc1 11942 install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd);
718e3744 11943 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd);
718e3744 11944 install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd);
8ecd3266 11945 install_element (BGP_VPNV6_NODE, &neighbor_allowas_in_cmd);
8ecd3266 11946 install_element (BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd);
8b1fb8be 11947 install_element (BGP_ENCAP_NODE, &neighbor_allowas_in_cmd);
8b1fb8be
LB
11948 install_element (BGP_ENCAP_NODE, &no_neighbor_allowas_in_cmd);
11949 install_element (BGP_ENCAPV6_NODE, &neighbor_allowas_in_cmd);
8b1fb8be 11950 install_element (BGP_ENCAPV6_NODE, &no_neighbor_allowas_in_cmd);
718e3744 11951
11952 /* address-family commands. */
11953 install_element (BGP_NODE, &address_family_ipv4_cmd);
11954 install_element (BGP_NODE, &address_family_ipv4_safi_cmd);
11955#ifdef HAVE_IPV6
11956 install_element (BGP_NODE, &address_family_ipv6_cmd);
25ffbdc1 11957 install_element (BGP_NODE, &address_family_ipv6_safi_cmd);
718e3744 11958#endif /* HAVE_IPV6 */
11959 install_element (BGP_NODE, &address_family_vpnv4_cmd);
718e3744 11960
8b1fb8be 11961 install_element (BGP_NODE, &address_family_vpnv6_cmd);
8b1fb8be
LB
11962
11963 install_element (BGP_NODE, &address_family_encap_cmd);
8b1fb8be
LB
11964#ifdef HAVE_IPV6
11965 install_element (BGP_NODE, &address_family_encapv6_cmd);
11966#endif
11967
718e3744 11968 /* "exit-address-family" command. */
11969 install_element (BGP_IPV4_NODE, &exit_address_family_cmd);
11970 install_element (BGP_IPV4M_NODE, &exit_address_family_cmd);
11971 install_element (BGP_IPV6_NODE, &exit_address_family_cmd);
25ffbdc1 11972 install_element (BGP_IPV6M_NODE, &exit_address_family_cmd);
718e3744 11973 install_element (BGP_VPNV4_NODE, &exit_address_family_cmd);
8ecd3266 11974 install_element (BGP_VPNV6_NODE, &exit_address_family_cmd);
8b1fb8be
LB
11975 install_element (BGP_ENCAP_NODE, &exit_address_family_cmd);
11976 install_element (BGP_ENCAPV6_NODE, &exit_address_family_cmd);
718e3744 11977
11978 /* "clear ip bgp commands" */
11979 install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd);
718e3744 11980
8ad7271d
DS
11981 /* clear ip bgp prefix */
11982 install_element (ENABLE_NODE, &clear_ip_bgp_prefix_cmd);
11983 install_element (ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd);
01080f7c 11984 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd);
8ad7271d 11985
718e3744 11986 /* "show ip bgp summary" commands. */
11987 install_element (VIEW_NODE, &show_ip_bgp_summary_cmd);
3f9c7369 11988 install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd);
8386ac43 11989 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_cmd);
f186de26 11990 install_element (VIEW_NODE, &show_ip_bgp_instance_all_updgrps_cmd);
3f9c7369
DS
11991 install_element (VIEW_NODE, &show_bgp_updgrps_cmd);
11992 install_element (VIEW_NODE, &show_bgp_ipv6_updgrps_cmd);
8386ac43 11993 install_element (VIEW_NODE, &show_bgp_instance_ipv6_updgrps_cmd);
f186de26 11994 install_element (VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd);
8fe8a7f6 11995 install_element (VIEW_NODE, &show_ip_bgp_updgrps_s_cmd);
8386ac43 11996 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_s_cmd);
8fe8a7f6
DS
11997 install_element (VIEW_NODE, &show_bgp_updgrps_s_cmd);
11998 install_element (VIEW_NODE, &show_bgp_ipv6_updgrps_s_cmd);
8386ac43 11999 install_element (VIEW_NODE, &show_bgp_instance_ipv6_updgrps_s_cmd);
3f9c7369 12000 install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd);
8386ac43 12001 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd);
3f9c7369 12002 install_element (VIEW_NODE, &show_bgp_updgrps_adj_cmd);
8386ac43 12003 install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd);
3f9c7369 12004 install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd);
8fe8a7f6 12005 install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd);
8386ac43 12006 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd);
8fe8a7f6 12007 install_element (VIEW_NODE, &show_bgp_updgrps_adj_s_cmd);
8386ac43 12008 install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd);
8fe8a7f6 12009 install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd);
718e3744 12010 install_element (VIEW_NODE, &show_ip_bgp_instance_summary_cmd);
f186de26 12011 install_element (VIEW_NODE, &show_ip_bgp_instance_all_summary_cmd);
718e3744 12012 install_element (VIEW_NODE, &show_ip_bgp_ipv4_summary_cmd);
12013 install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
12014 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
12015 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
12016#ifdef HAVE_IPV6
12017 install_element (VIEW_NODE, &show_bgp_summary_cmd);
12018 install_element (VIEW_NODE, &show_bgp_instance_summary_cmd);
f186de26 12019 install_element (VIEW_NODE, &show_bgp_instance_all_summary_cmd);
95cbbd2a 12020 install_element (VIEW_NODE, &show_bgp_ipv6_safi_summary_cmd);
95cbbd2a 12021 install_element (VIEW_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
62687ff1
PJ
12022#endif /* HAVE_IPV6 */
12023 install_element (RESTRICTED_NODE, &show_ip_bgp_summary_cmd);
3f9c7369 12024 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_cmd);
8386ac43 12025 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_updgrps_cmd);
f186de26 12026 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_all_updgrps_cmd);
3f9c7369
DS
12027 install_element (RESTRICTED_NODE, &show_bgp_updgrps_cmd);
12028 install_element (RESTRICTED_NODE, &show_bgp_ipv6_updgrps_cmd);
8386ac43 12029 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_updgrps_cmd);
f186de26 12030 install_element (RESTRICTED_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd);
8fe8a7f6 12031 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_s_cmd);
8386ac43 12032 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_updgrps_s_cmd);
8fe8a7f6
DS
12033 install_element (RESTRICTED_NODE, &show_bgp_updgrps_s_cmd);
12034 install_element (RESTRICTED_NODE, &show_bgp_ipv6_updgrps_s_cmd);
8386ac43 12035 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_updgrps_s_cmd);
3f9c7369 12036 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_adj_cmd);
8386ac43 12037 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_updgrps_adj_cmd);
3f9c7369 12038 install_element (RESTRICTED_NODE, &show_bgp_updgrps_adj_cmd);
8386ac43 12039 install_element (RESTRICTED_NODE, &show_bgp_instance_updgrps_adj_cmd);
3f9c7369 12040 install_element (RESTRICTED_NODE, &show_bgp_updgrps_afi_adj_cmd);
8fe8a7f6 12041 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_adj_s_cmd);
8386ac43 12042 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd);
8fe8a7f6 12043 install_element (RESTRICTED_NODE, &show_bgp_updgrps_adj_s_cmd);
8386ac43 12044 install_element (RESTRICTED_NODE, &show_bgp_instance_updgrps_adj_s_cmd);
8fe8a7f6 12045 install_element (RESTRICTED_NODE, &show_bgp_updgrps_afi_adj_s_cmd);
62687ff1 12046 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_summary_cmd);
f186de26 12047 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_all_summary_cmd);
62687ff1
PJ
12048 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_summary_cmd);
12049 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
12050 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
12051 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
12052#ifdef HAVE_IPV6
12053 install_element (RESTRICTED_NODE, &show_bgp_summary_cmd);
12054 install_element (RESTRICTED_NODE, &show_bgp_instance_summary_cmd);
f186de26 12055 install_element (RESTRICTED_NODE, &show_bgp_instance_all_summary_cmd);
95cbbd2a 12056 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_summary_cmd);
95cbbd2a 12057 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
718e3744 12058#endif /* HAVE_IPV6 */
12059 install_element (ENABLE_NODE, &show_ip_bgp_summary_cmd);
3f9c7369 12060 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_cmd);
8386ac43 12061 install_element (ENABLE_NODE, &show_ip_bgp_instance_updgrps_cmd);
f186de26 12062 install_element (ENABLE_NODE, &show_ip_bgp_instance_all_updgrps_cmd);
3f9c7369
DS
12063 install_element (ENABLE_NODE, &show_bgp_updgrps_cmd);
12064 install_element (ENABLE_NODE, &show_bgp_ipv6_updgrps_cmd);
8386ac43 12065 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_updgrps_cmd);
f186de26 12066 install_element (ENABLE_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd);
8fe8a7f6 12067 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_s_cmd);
8386ac43 12068 install_element (ENABLE_NODE, &show_ip_bgp_instance_updgrps_s_cmd);
8fe8a7f6
DS
12069 install_element (ENABLE_NODE, &show_bgp_updgrps_s_cmd);
12070 install_element (ENABLE_NODE, &show_bgp_ipv6_updgrps_s_cmd);
8386ac43 12071 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_updgrps_s_cmd);
3f9c7369 12072 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_adj_cmd);
8386ac43 12073 install_element (ENABLE_NODE, &show_ip_bgp_instance_updgrps_adj_cmd);
3f9c7369 12074 install_element (ENABLE_NODE, &show_bgp_updgrps_adj_cmd);
8386ac43 12075 install_element (ENABLE_NODE, &show_bgp_instance_updgrps_adj_cmd);
3f9c7369 12076 install_element (ENABLE_NODE, &show_bgp_updgrps_afi_adj_cmd);
8fe8a7f6 12077 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_adj_s_cmd);
8386ac43 12078 install_element (ENABLE_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd);
8fe8a7f6 12079 install_element (ENABLE_NODE, &show_bgp_updgrps_adj_s_cmd);
8386ac43 12080 install_element (ENABLE_NODE, &show_bgp_instance_updgrps_adj_s_cmd);
8fe8a7f6 12081 install_element (ENABLE_NODE, &show_bgp_updgrps_afi_adj_s_cmd);
718e3744 12082 install_element (ENABLE_NODE, &show_ip_bgp_instance_summary_cmd);
f186de26 12083 install_element (ENABLE_NODE, &show_ip_bgp_instance_all_summary_cmd);
718e3744 12084 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_summary_cmd);
12085 install_element (ENABLE_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
12086 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
12087 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
12088#ifdef HAVE_IPV6
12089 install_element (ENABLE_NODE, &show_bgp_summary_cmd);
12090 install_element (ENABLE_NODE, &show_bgp_instance_summary_cmd);
f186de26 12091 install_element (ENABLE_NODE, &show_bgp_instance_all_summary_cmd);
95cbbd2a 12092 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_summary_cmd);
95cbbd2a 12093 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
718e3744 12094#endif /* HAVE_IPV6 */
12095
e3e29b32
LB
12096 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_summary_cmd);
12097 install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_summary_cmd);
12098
12099 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_summary_cmd);
12100 install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_summary_cmd);
12101
718e3744 12102 /* "show ip bgp neighbors" commands. */
12103 install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd);
718e3744 12104 install_element (VIEW_NODE, &show_ip_bgp_neighbors_peer_cmd);
718e3744 12105 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_cmd);
f186de26 12106 install_element (VIEW_NODE, &show_ip_bgp_instance_all_neighbors_cmd);
718e3744 12107 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
62687ff1 12108 install_element (RESTRICTED_NODE, &show_ip_bgp_neighbors_peer_cmd);
62687ff1 12109 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
718e3744 12110 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_cmd);
718e3744 12111 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_peer_cmd);
718e3744 12112 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_cmd);
f186de26 12113 install_element (ENABLE_NODE, &show_ip_bgp_instance_all_neighbors_cmd);
718e3744 12114 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
12115
12116#ifdef HAVE_IPV6
718e3744 12117
12118 /* Old commands. */
12119 install_element (VIEW_NODE, &show_ipv6_bgp_summary_cmd);
12120 install_element (VIEW_NODE, &show_ipv6_mbgp_summary_cmd);
12121 install_element (ENABLE_NODE, &show_ipv6_bgp_summary_cmd);
12122 install_element (ENABLE_NODE, &show_ipv6_mbgp_summary_cmd);
12123#endif /* HAVE_IPV6 */
fee0f4c6 12124
f14e6fdb
DS
12125 /* "show ip bgp peer-group" commands. */
12126 install_element (VIEW_NODE, &show_ip_bgp_peer_groups_cmd);
12127 install_element (VIEW_NODE, &show_ip_bgp_instance_peer_groups_cmd);
12128 install_element (VIEW_NODE, &show_ip_bgp_peer_group_cmd);
12129 install_element (VIEW_NODE, &show_ip_bgp_instance_peer_group_cmd);
12130 install_element (ENABLE_NODE, &show_ip_bgp_peer_groups_cmd);
12131 install_element (ENABLE_NODE, &show_ip_bgp_instance_peer_groups_cmd);
12132 install_element (ENABLE_NODE, &show_ip_bgp_peer_group_cmd);
12133 install_element (ENABLE_NODE, &show_ip_bgp_instance_peer_group_cmd);
12134
718e3744 12135 /* "show ip bgp paths" commands. */
12136 install_element (VIEW_NODE, &show_ip_bgp_paths_cmd);
12137 install_element (VIEW_NODE, &show_ip_bgp_ipv4_paths_cmd);
12138 install_element (ENABLE_NODE, &show_ip_bgp_paths_cmd);
12139 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_paths_cmd);
12140
12141 /* "show ip bgp community" commands. */
12142 install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd);
12143 install_element (ENABLE_NODE, &show_ip_bgp_community_info_cmd);
12144
12145 /* "show ip bgp attribute-info" commands. */
12146 install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd);
12147 install_element (ENABLE_NODE, &show_ip_bgp_attr_info_cmd);
12148
12149 /* "redistribute" commands. */
12150 install_element (BGP_NODE, &bgp_redistribute_ipv4_cmd);
12151 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_cmd);
12152 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_cmd);
718e3744 12153 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_cmd);
718e3744 12154 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd);
12155 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd);
7c8ff89e
DS
12156 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_cmd);
12157 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_cmd);
12158 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd);
7c8ff89e 12159 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd);
7c8ff89e 12160 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
7c8ff89e 12161 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
919e0666
DW
12162 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd);
12163 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd);
12164 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd);
919e0666 12165 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd);
919e0666
DW
12166 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd);
12167 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd);
919e0666
DW
12168 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd);
12169 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd);
12170 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd);
919e0666 12171 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd);
919e0666 12172 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
919e0666 12173 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
718e3744 12174#ifdef HAVE_IPV6
12175 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd);
12176 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd);
12177 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd);
718e3744 12178 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd);
718e3744 12179 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd);
12180 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd);
718e3744 12181#endif /* HAVE_IPV6 */
12182
fa411a21
NH
12183 /* ttl_security commands */
12184 install_element (BGP_NODE, &neighbor_ttl_security_cmd);
12185 install_element (BGP_NODE, &no_neighbor_ttl_security_cmd);
12186
4bf6a362
PJ
12187 /* "show bgp memory" commands. */
12188 install_element (VIEW_NODE, &show_bgp_memory_cmd);
62687ff1 12189 install_element (RESTRICTED_NODE, &show_bgp_memory_cmd);
4bf6a362
PJ
12190 install_element (ENABLE_NODE, &show_bgp_memory_cmd);
12191
e0081f70
ML
12192 /* "show bgp views" commands. */
12193 install_element (VIEW_NODE, &show_bgp_views_cmd);
12194 install_element (RESTRICTED_NODE, &show_bgp_views_cmd);
12195 install_element (ENABLE_NODE, &show_bgp_views_cmd);
12196
8386ac43 12197 /* "show bgp vrfs" commands. */
12198 install_element (VIEW_NODE, &show_bgp_vrfs_cmd);
12199 install_element (RESTRICTED_NODE, &show_bgp_vrfs_cmd);
12200 install_element (ENABLE_NODE, &show_bgp_vrfs_cmd);
12201
718e3744 12202 /* Community-list. */
12203 community_list_vty ();
12204}
6b0655a2 12205
718e3744 12206#include "memory.h"
12207#include "bgp_regex.h"
12208#include "bgp_clist.h"
12209#include "bgp_ecommunity.h"
12210
12211/* VTY functions. */
12212
12213/* Direction value to string conversion. */
94f2b392 12214static const char *
718e3744 12215community_direct_str (int direct)
12216{
12217 switch (direct)
12218 {
12219 case COMMUNITY_DENY:
12220 return "deny";
718e3744 12221 case COMMUNITY_PERMIT:
12222 return "permit";
718e3744 12223 default:
12224 return "unknown";
718e3744 12225 }
12226}
12227
12228/* Display error string. */
94f2b392 12229static void
718e3744 12230community_list_perror (struct vty *vty, int ret)
12231{
12232 switch (ret)
12233 {
12234 case COMMUNITY_LIST_ERR_CANT_FIND_LIST:
b729294c 12235 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
718e3744 12236 break;
12237 case COMMUNITY_LIST_ERR_MALFORMED_VAL:
12238 vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE);
12239 break;
12240 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT:
12241 vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE);
12242 break;
12243 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT:
12244 vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE);
12245 break;
12246 }
12247}
12248
12249/* VTY interface for community_set() function. */
94f2b392 12250static int
fd79ac91 12251community_list_set_vty (struct vty *vty, int argc, const char **argv,
12252 int style, int reject_all_digit_name)
718e3744 12253{
12254 int ret;
12255 int direct;
12256 char *str;
12257
12258 /* Check the list type. */
12259 if (strncmp (argv[1], "p", 1) == 0)
12260 direct = COMMUNITY_PERMIT;
12261 else if (strncmp (argv[1], "d", 1) == 0)
12262 direct = COMMUNITY_DENY;
12263 else
12264 {
12265 vty_out (vty, "%% Matching condition must be permit or deny%s",
12266 VTY_NEWLINE);
12267 return CMD_WARNING;
12268 }
12269
12270 /* All digit name check. */
12271 if (reject_all_digit_name && all_digit (argv[0]))
12272 {
12273 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
12274 return CMD_WARNING;
12275 }
12276
12277 /* Concat community string argument. */
12278 if (argc > 1)
12279 str = argv_concat (argv, argc, 2);
12280 else
12281 str = NULL;
12282
12283 /* When community_list_set() return nevetive value, it means
12284 malformed community string. */
12285 ret = community_list_set (bgp_clist, argv[0], str, direct, style);
12286
12287 /* Free temporary community list string allocated by
12288 argv_concat(). */
12289 if (str)
12290 XFREE (MTYPE_TMP, str);
12291
12292 if (ret < 0)
12293 {
12294 /* Display error string. */
12295 community_list_perror (vty, ret);
12296 return CMD_WARNING;
12297 }
12298
12299 return CMD_SUCCESS;
12300}
12301
718e3744 12302/* Communiyt-list entry delete. */
94f2b392 12303static int
fee6e4e4 12304community_list_unset_vty (struct vty *vty, int argc, const char **argv,
813d4307 12305 int style, int delete_all)
718e3744 12306{
12307 int ret;
fee6e4e4 12308 int direct = 0;
12309 char *str = NULL;
718e3744 12310
fee6e4e4 12311 if (argc > 1)
718e3744 12312 {
fee6e4e4 12313 /* Check the list direct. */
12314 if (strncmp (argv[1], "p", 1) == 0)
12315 direct = COMMUNITY_PERMIT;
12316 else if (strncmp (argv[1], "d", 1) == 0)
12317 direct = COMMUNITY_DENY;
12318 else
12319 {
12320 vty_out (vty, "%% Matching condition must be permit or deny%s",
12321 VTY_NEWLINE);
12322 return CMD_WARNING;
12323 }
718e3744 12324
fee6e4e4 12325 /* Concat community string argument. */
12326 str = argv_concat (argv, argc, 2);
12327 }
718e3744 12328
12329 /* Unset community list. */
813d4307 12330 ret = community_list_unset (bgp_clist, argv[0], str, direct, style, delete_all);
718e3744 12331
12332 /* Free temporary community list string allocated by
12333 argv_concat(). */
fee6e4e4 12334 if (str)
12335 XFREE (MTYPE_TMP, str);
718e3744 12336
12337 if (ret < 0)
12338 {
12339 community_list_perror (vty, ret);
12340 return CMD_WARNING;
12341 }
12342
12343 return CMD_SUCCESS;
12344}
12345
12346/* "community-list" keyword help string. */
12347#define COMMUNITY_LIST_STR "Add a community list entry\n"
718e3744 12348
f412b39a
DW
12349/*
12350 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
12351 * "ip community-list <1-99> (deny|permit)",
12352 * IP_STR
12353 * COMMUNITY_LIST_STR
12354 * "Community list number (standard)\n"
12355 * "Specify community to reject\n"
12356 * "Specify community to accept\n"
12357 *
12358 */
718e3744 12359DEFUN (ip_community_list_standard,
12360 ip_community_list_standard_cmd,
6147e2c6 12361 "ip community-list (1-99) <deny|permit> .AA:NN",
718e3744 12362 IP_STR
12363 COMMUNITY_LIST_STR
12364 "Community list number (standard)\n"
12365 "Specify community to reject\n"
12366 "Specify community to accept\n"
12367 COMMUNITY_VAL_STR)
12368{
12369 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
12370}
12371
718e3744 12372
12373DEFUN (ip_community_list_expanded,
12374 ip_community_list_expanded_cmd,
6147e2c6 12375 "ip community-list (100-500) <deny|permit> .LINE",
718e3744 12376 IP_STR
12377 COMMUNITY_LIST_STR
12378 "Community list number (expanded)\n"
12379 "Specify community to reject\n"
12380 "Specify community to accept\n"
12381 "An ordered list as a regular-expression\n")
12382{
12383 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
12384}
12385
f412b39a
DW
12386/*
12387 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
12388 * "ip community-list standard WORD (deny|permit)",
12389 * IP_STR
12390 * COMMUNITY_LIST_STR
12391 * "Add a standard community-list entry\n"
12392 * "Community list name\n"
12393 * "Specify community to reject\n"
12394 * "Specify community to accept\n"
12395 *
12396 */
718e3744 12397DEFUN (ip_community_list_name_standard,
12398 ip_community_list_name_standard_cmd,
6147e2c6 12399 "ip community-list standard WORD <deny|permit> .AA:NN",
718e3744 12400 IP_STR
12401 COMMUNITY_LIST_STR
12402 "Add a standard community-list entry\n"
12403 "Community list name\n"
12404 "Specify community to reject\n"
12405 "Specify community to accept\n"
12406 COMMUNITY_VAL_STR)
12407{
12408 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
12409}
12410
718e3744 12411
12412DEFUN (ip_community_list_name_expanded,
12413 ip_community_list_name_expanded_cmd,
6147e2c6 12414 "ip community-list expanded WORD <deny|permit> .LINE",
718e3744 12415 IP_STR
12416 COMMUNITY_LIST_STR
12417 "Add an expanded community-list entry\n"
12418 "Community list name\n"
12419 "Specify community to reject\n"
12420 "Specify community to accept\n"
12421 "An ordered list as a regular-expression\n")
12422{
12423 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
12424}
12425
fee6e4e4 12426DEFUN (no_ip_community_list_standard_all,
12427 no_ip_community_list_standard_all_cmd,
6147e2c6 12428 "no ip community-list (1-99)",
fee6e4e4 12429 NO_STR
12430 IP_STR
12431 COMMUNITY_LIST_STR
12432 "Community list number (standard)\n")
12433{
813d4307
DW
12434 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
12435}
12436
12437DEFUN (no_ip_community_list_standard_direction,
12438 no_ip_community_list_standard_direction_cmd,
6147e2c6 12439 "no ip community-list (1-99) <deny|permit>",
813d4307
DW
12440 NO_STR
12441 IP_STR
12442 COMMUNITY_LIST_STR
12443 "Community list number (standard)\n"
12444 "Specify community to reject\n"
12445 "Specify community to accept\n")
12446{
12447 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
fee6e4e4 12448}
12449
813d4307 12450
fee6e4e4 12451DEFUN (no_ip_community_list_expanded_all,
12452 no_ip_community_list_expanded_all_cmd,
6147e2c6 12453 "no ip community-list (100-500)",
718e3744 12454 NO_STR
12455 IP_STR
12456 COMMUNITY_LIST_STR
718e3744 12457 "Community list number (expanded)\n")
12458{
813d4307 12459 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
718e3744 12460}
12461
fee6e4e4 12462DEFUN (no_ip_community_list_name_standard_all,
12463 no_ip_community_list_name_standard_all_cmd,
12464 "no ip community-list standard WORD",
718e3744 12465 NO_STR
12466 IP_STR
12467 COMMUNITY_LIST_STR
12468 "Add a standard community-list entry\n"
718e3744 12469 "Community list name\n")
12470{
813d4307 12471 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
718e3744 12472}
12473
fee6e4e4 12474DEFUN (no_ip_community_list_name_expanded_all,
12475 no_ip_community_list_name_expanded_all_cmd,
12476 "no ip community-list expanded WORD",
718e3744 12477 NO_STR
12478 IP_STR
12479 COMMUNITY_LIST_STR
fee6e4e4 12480 "Add an expanded community-list entry\n"
12481 "Community list name\n")
718e3744 12482{
813d4307 12483 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
718e3744 12484}
12485
12486DEFUN (no_ip_community_list_standard,
12487 no_ip_community_list_standard_cmd,
6147e2c6 12488 "no ip community-list (1-99) <deny|permit> .AA:NN",
718e3744 12489 NO_STR
12490 IP_STR
12491 COMMUNITY_LIST_STR
12492 "Community list number (standard)\n"
12493 "Specify community to reject\n"
12494 "Specify community to accept\n"
12495 COMMUNITY_VAL_STR)
12496{
813d4307 12497 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
718e3744 12498}
12499
12500DEFUN (no_ip_community_list_expanded,
12501 no_ip_community_list_expanded_cmd,
6147e2c6 12502 "no ip community-list (100-500) <deny|permit> .LINE",
718e3744 12503 NO_STR
12504 IP_STR
12505 COMMUNITY_LIST_STR
12506 "Community list number (expanded)\n"
12507 "Specify community to reject\n"
12508 "Specify community to accept\n"
12509 "An ordered list as a regular-expression\n")
12510{
813d4307 12511 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
718e3744 12512}
12513
12514DEFUN (no_ip_community_list_name_standard,
12515 no_ip_community_list_name_standard_cmd,
6147e2c6 12516 "no ip community-list standard WORD <deny|permit> .AA:NN",
718e3744 12517 NO_STR
12518 IP_STR
12519 COMMUNITY_LIST_STR
12520 "Specify a standard community-list\n"
12521 "Community list name\n"
12522 "Specify community to reject\n"
12523 "Specify community to accept\n"
12524 COMMUNITY_VAL_STR)
12525{
813d4307
DW
12526 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
12527}
12528
12529DEFUN (no_ip_community_list_name_standard_brief,
12530 no_ip_community_list_name_standard_brief_cmd,
6147e2c6 12531 "no ip community-list standard WORD <deny|permit>",
813d4307
DW
12532 NO_STR
12533 IP_STR
12534 COMMUNITY_LIST_STR
12535 "Specify a standard community-list\n"
12536 "Community list name\n"
12537 "Specify community to reject\n"
12538 "Specify community to accept\n")
12539{
12540 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
718e3744 12541}
12542
12543DEFUN (no_ip_community_list_name_expanded,
12544 no_ip_community_list_name_expanded_cmd,
6147e2c6 12545 "no ip community-list expanded WORD <deny|permit> .LINE",
718e3744 12546 NO_STR
12547 IP_STR
12548 COMMUNITY_LIST_STR
12549 "Specify an expanded community-list\n"
12550 "Community list name\n"
12551 "Specify community to reject\n"
12552 "Specify community to accept\n"
12553 "An ordered list as a regular-expression\n")
12554{
813d4307 12555 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
718e3744 12556}
12557
94f2b392 12558static void
718e3744 12559community_list_show (struct vty *vty, struct community_list *list)
12560{
12561 struct community_entry *entry;
12562
12563 for (entry = list->head; entry; entry = entry->next)
12564 {
12565 if (entry == list->head)
12566 {
12567 if (all_digit (list->name))
12568 vty_out (vty, "Community %s list %s%s",
12569 entry->style == COMMUNITY_LIST_STANDARD ?
12570 "standard" : "(expanded) access",
12571 list->name, VTY_NEWLINE);
12572 else
12573 vty_out (vty, "Named Community %s list %s%s",
12574 entry->style == COMMUNITY_LIST_STANDARD ?
12575 "standard" : "expanded",
12576 list->name, VTY_NEWLINE);
12577 }
12578 if (entry->any)
12579 vty_out (vty, " %s%s",
12580 community_direct_str (entry->direct), VTY_NEWLINE);
12581 else
12582 vty_out (vty, " %s %s%s",
12583 community_direct_str (entry->direct),
12584 entry->style == COMMUNITY_LIST_STANDARD
12585 ? community_str (entry->u.com) : entry->config,
12586 VTY_NEWLINE);
12587 }
12588}
12589
12590DEFUN (show_ip_community_list,
12591 show_ip_community_list_cmd,
12592 "show ip community-list",
12593 SHOW_STR
12594 IP_STR
12595 "List community-list\n")
12596{
12597 struct community_list *list;
12598 struct community_list_master *cm;
12599
fee6e4e4 12600 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
718e3744 12601 if (! cm)
12602 return CMD_SUCCESS;
12603
12604 for (list = cm->num.head; list; list = list->next)
12605 community_list_show (vty, list);
12606
12607 for (list = cm->str.head; list; list = list->next)
12608 community_list_show (vty, list);
12609
12610 return CMD_SUCCESS;
12611}
12612
12613DEFUN (show_ip_community_list_arg,
12614 show_ip_community_list_arg_cmd,
6147e2c6 12615 "show ip community-list <(1-500)|WORD>",
718e3744 12616 SHOW_STR
12617 IP_STR
12618 "List community-list\n"
12619 "Community-list number\n"
12620 "Community-list name\n")
12621{
c500ae40 12622 int idx_comm_list = 3;
718e3744 12623 struct community_list *list;
12624
c500ae40 12625 list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, COMMUNITY_LIST_MASTER);
718e3744 12626 if (! list)
12627 {
b729294c 12628 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
718e3744 12629 return CMD_WARNING;
12630 }
12631
12632 community_list_show (vty, list);
12633
12634 return CMD_SUCCESS;
12635}
6b0655a2 12636
94f2b392 12637static int
afec25d9 12638extcommunity_list_set_vty (struct vty *vty, int argc, struct cmd_token **argv,
fd79ac91 12639 int style, int reject_all_digit_name)
718e3744 12640{
12641 int ret;
12642 int direct;
12643 char *str;
12644
12645 /* Check the list type. */
12646 if (strncmp (argv[1], "p", 1) == 0)
12647 direct = COMMUNITY_PERMIT;
12648 else if (strncmp (argv[1], "d", 1) == 0)
12649 direct = COMMUNITY_DENY;
12650 else
12651 {
12652 vty_out (vty, "%% Matching condition must be permit or deny%s",
12653 VTY_NEWLINE);
12654 return CMD_WARNING;
12655 }
12656
12657 /* All digit name check. */
12658 if (reject_all_digit_name && all_digit (argv[0]))
12659 {
12660 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
12661 return CMD_WARNING;
12662 }
12663
12664 /* Concat community string argument. */
12665 if (argc > 1)
12666 str = argv_concat (argv, argc, 2);
12667 else
12668 str = NULL;
12669
12670 ret = extcommunity_list_set (bgp_clist, argv[0], str, direct, style);
12671
12672 /* Free temporary community list string allocated by
12673 argv_concat(). */
12674 if (str)
12675 XFREE (MTYPE_TMP, str);
12676
12677 if (ret < 0)
12678 {
12679 community_list_perror (vty, ret);
12680 return CMD_WARNING;
12681 }
12682 return CMD_SUCCESS;
12683}
12684
94f2b392 12685static int
afec25d9 12686extcommunity_list_unset_vty (struct vty *vty, int argc, struct cmd_token **argv,
813d4307 12687 int style, int delete_all)
718e3744 12688{
12689 int ret;
fee6e4e4 12690 int direct = 0;
12691 char *str = NULL;
718e3744 12692
fee6e4e4 12693 if (argc > 1)
718e3744 12694 {
fee6e4e4 12695 /* Check the list direct. */
12696 if (strncmp (argv[1], "p", 1) == 0)
12697 direct = COMMUNITY_PERMIT;
12698 else if (strncmp (argv[1], "d", 1) == 0)
12699 direct = COMMUNITY_DENY;
12700 else
12701 {
12702 vty_out (vty, "%% Matching condition must be permit or deny%s",
12703 VTY_NEWLINE);
12704 return CMD_WARNING;
12705 }
718e3744 12706
fee6e4e4 12707 /* Concat community string argument. */
12708 str = argv_concat (argv, argc, 2);
718e3744 12709 }
12710
718e3744 12711 /* Unset community list. */
813d4307 12712 ret = extcommunity_list_unset (bgp_clist, argv[0], str, direct, style, delete_all);
718e3744 12713
12714 /* Free temporary community list string allocated by
12715 argv_concat(). */
fee6e4e4 12716 if (str)
12717 XFREE (MTYPE_TMP, str);
718e3744 12718
12719 if (ret < 0)
12720 {
12721 community_list_perror (vty, ret);
12722 return CMD_WARNING;
12723 }
12724
12725 return CMD_SUCCESS;
12726}
12727
12728/* "extcommunity-list" keyword help string. */
12729#define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
12730#define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
12731
f412b39a
DW
12732/*
12733 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
12734 * "ip extcommunity-list <1-99> (deny|permit)",
12735 * IP_STR
12736 * EXTCOMMUNITY_LIST_STR
12737 * "Extended Community list number (standard)\n"
12738 * "Specify community to reject\n"
12739 * "Specify community to accept\n"
12740 *
12741 */
718e3744 12742DEFUN (ip_extcommunity_list_standard,
12743 ip_extcommunity_list_standard_cmd,
6147e2c6 12744 "ip extcommunity-list (1-99) <deny|permit> .AA:NN",
718e3744 12745 IP_STR
12746 EXTCOMMUNITY_LIST_STR
12747 "Extended Community list number (standard)\n"
12748 "Specify community to reject\n"
12749 "Specify community to accept\n"
12750 EXTCOMMUNITY_VAL_STR)
12751{
12752 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
12753}
12754
718e3744 12755
12756DEFUN (ip_extcommunity_list_expanded,
12757 ip_extcommunity_list_expanded_cmd,
6147e2c6 12758 "ip extcommunity-list (100-500) <deny|permit> .LINE",
718e3744 12759 IP_STR
12760 EXTCOMMUNITY_LIST_STR
12761 "Extended Community list number (expanded)\n"
12762 "Specify community to reject\n"
12763 "Specify community to accept\n"
12764 "An ordered list as a regular-expression\n")
12765{
12766 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
12767}
12768
f412b39a
DW
12769/*
12770 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
12771 * "ip extcommunity-list standard WORD (deny|permit)",
12772 * IP_STR
12773 * EXTCOMMUNITY_LIST_STR
12774 * "Specify standard extcommunity-list\n"
12775 * "Extended Community list name\n"
12776 * "Specify community to reject\n"
12777 * "Specify community to accept\n"
12778 *
12779 */
718e3744 12780DEFUN (ip_extcommunity_list_name_standard,
12781 ip_extcommunity_list_name_standard_cmd,
6147e2c6 12782 "ip extcommunity-list standard WORD <deny|permit> .AA:NN",
718e3744 12783 IP_STR
12784 EXTCOMMUNITY_LIST_STR
12785 "Specify standard extcommunity-list\n"
12786 "Extended Community list name\n"
12787 "Specify community to reject\n"
12788 "Specify community to accept\n"
12789 EXTCOMMUNITY_VAL_STR)
12790{
12791 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
12792}
12793
718e3744 12794
12795DEFUN (ip_extcommunity_list_name_expanded,
12796 ip_extcommunity_list_name_expanded_cmd,
6147e2c6 12797 "ip extcommunity-list expanded WORD <deny|permit> .LINE",
718e3744 12798 IP_STR
12799 EXTCOMMUNITY_LIST_STR
12800 "Specify expanded extcommunity-list\n"
12801 "Extended Community list name\n"
12802 "Specify community to reject\n"
12803 "Specify community to accept\n"
12804 "An ordered list as a regular-expression\n")
12805{
12806 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
12807}
12808
fee6e4e4 12809DEFUN (no_ip_extcommunity_list_standard_all,
12810 no_ip_extcommunity_list_standard_all_cmd,
6147e2c6 12811 "no ip extcommunity-list (1-99)",
fee6e4e4 12812 NO_STR
12813 IP_STR
12814 EXTCOMMUNITY_LIST_STR
12815 "Extended Community list number (standard)\n")
12816{
813d4307
DW
12817 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
12818}
12819
12820DEFUN (no_ip_extcommunity_list_standard_direction,
12821 no_ip_extcommunity_list_standard_direction_cmd,
6147e2c6 12822 "no ip extcommunity-list (1-99) <deny|permit>",
813d4307
DW
12823 NO_STR
12824 IP_STR
12825 EXTCOMMUNITY_LIST_STR
12826 "Extended Community list number (standard)\n"
12827 "Specify community to reject\n"
12828 "Specify community to accept\n")
12829{
12830 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
fee6e4e4 12831}
12832
12833DEFUN (no_ip_extcommunity_list_expanded_all,
12834 no_ip_extcommunity_list_expanded_all_cmd,
6147e2c6 12835 "no ip extcommunity-list (100-500)",
718e3744 12836 NO_STR
12837 IP_STR
12838 EXTCOMMUNITY_LIST_STR
718e3744 12839 "Extended Community list number (expanded)\n")
12840{
813d4307 12841 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
718e3744 12842}
12843
fee6e4e4 12844DEFUN (no_ip_extcommunity_list_name_standard_all,
12845 no_ip_extcommunity_list_name_standard_all_cmd,
12846 "no ip extcommunity-list standard WORD",
718e3744 12847 NO_STR
12848 IP_STR
12849 EXTCOMMUNITY_LIST_STR
12850 "Specify standard extcommunity-list\n"
fee6e4e4 12851 "Extended Community list name\n")
12852{
813d4307 12853 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
fee6e4e4 12854}
12855
12856DEFUN (no_ip_extcommunity_list_name_expanded_all,
12857 no_ip_extcommunity_list_name_expanded_all_cmd,
12858 "no ip extcommunity-list expanded WORD",
12859 NO_STR
12860 IP_STR
12861 EXTCOMMUNITY_LIST_STR
718e3744 12862 "Specify expanded extcommunity-list\n"
12863 "Extended Community list name\n")
12864{
813d4307 12865 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
718e3744 12866}
12867
12868DEFUN (no_ip_extcommunity_list_standard,
12869 no_ip_extcommunity_list_standard_cmd,
6147e2c6 12870 "no ip extcommunity-list (1-99) <deny|permit> .AA:NN",
718e3744 12871 NO_STR
12872 IP_STR
12873 EXTCOMMUNITY_LIST_STR
12874 "Extended Community list number (standard)\n"
12875 "Specify community to reject\n"
12876 "Specify community to accept\n"
12877 EXTCOMMUNITY_VAL_STR)
12878{
813d4307 12879 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
718e3744 12880}
12881
12882DEFUN (no_ip_extcommunity_list_expanded,
12883 no_ip_extcommunity_list_expanded_cmd,
6147e2c6 12884 "no ip extcommunity-list (100-500) <deny|permit> .LINE",
718e3744 12885 NO_STR
12886 IP_STR
12887 EXTCOMMUNITY_LIST_STR
12888 "Extended Community list number (expanded)\n"
12889 "Specify community to reject\n"
12890 "Specify community to accept\n"
12891 "An ordered list as a regular-expression\n")
12892{
813d4307 12893 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
718e3744 12894}
12895
12896DEFUN (no_ip_extcommunity_list_name_standard,
12897 no_ip_extcommunity_list_name_standard_cmd,
6147e2c6 12898 "no ip extcommunity-list standard WORD <deny|permit> .AA:NN",
718e3744 12899 NO_STR
12900 IP_STR
12901 EXTCOMMUNITY_LIST_STR
12902 "Specify standard extcommunity-list\n"
12903 "Extended Community list name\n"
12904 "Specify community to reject\n"
12905 "Specify community to accept\n"
12906 EXTCOMMUNITY_VAL_STR)
12907{
813d4307
DW
12908 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
12909}
12910
12911DEFUN (no_ip_extcommunity_list_name_standard_brief,
12912 no_ip_extcommunity_list_name_standard_brief_cmd,
6147e2c6 12913 "no ip extcommunity-list standard WORD <deny|permit>",
813d4307
DW
12914 NO_STR
12915 IP_STR
12916 EXTCOMMUNITY_LIST_STR
12917 "Specify standard extcommunity-list\n"
12918 "Extended Community list name\n"
12919 "Specify community to reject\n"
12920 "Specify community to accept\n")
12921{
12922 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
718e3744 12923}
12924
12925DEFUN (no_ip_extcommunity_list_name_expanded,
12926 no_ip_extcommunity_list_name_expanded_cmd,
6147e2c6 12927 "no ip extcommunity-list expanded WORD <deny|permit> .LINE",
718e3744 12928 NO_STR
12929 IP_STR
12930 EXTCOMMUNITY_LIST_STR
12931 "Specify expanded extcommunity-list\n"
12932 "Community list name\n"
12933 "Specify community to reject\n"
12934 "Specify community to accept\n"
12935 "An ordered list as a regular-expression\n")
12936{
813d4307 12937 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
718e3744 12938}
12939
94f2b392 12940static void
718e3744 12941extcommunity_list_show (struct vty *vty, struct community_list *list)
12942{
12943 struct community_entry *entry;
12944
12945 for (entry = list->head; entry; entry = entry->next)
12946 {
12947 if (entry == list->head)
12948 {
12949 if (all_digit (list->name))
12950 vty_out (vty, "Extended community %s list %s%s",
12951 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
12952 "standard" : "(expanded) access",
12953 list->name, VTY_NEWLINE);
12954 else
12955 vty_out (vty, "Named extended community %s list %s%s",
12956 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
12957 "standard" : "expanded",
12958 list->name, VTY_NEWLINE);
12959 }
12960 if (entry->any)
12961 vty_out (vty, " %s%s",
12962 community_direct_str (entry->direct), VTY_NEWLINE);
12963 else
12964 vty_out (vty, " %s %s%s",
12965 community_direct_str (entry->direct),
12966 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
12967 entry->u.ecom->str : entry->config,
12968 VTY_NEWLINE);
12969 }
12970}
12971
12972DEFUN (show_ip_extcommunity_list,
12973 show_ip_extcommunity_list_cmd,
12974 "show ip extcommunity-list",
12975 SHOW_STR
12976 IP_STR
12977 "List extended-community list\n")
12978{
12979 struct community_list *list;
12980 struct community_list_master *cm;
12981
fee6e4e4 12982 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
718e3744 12983 if (! cm)
12984 return CMD_SUCCESS;
12985
12986 for (list = cm->num.head; list; list = list->next)
12987 extcommunity_list_show (vty, list);
12988
12989 for (list = cm->str.head; list; list = list->next)
12990 extcommunity_list_show (vty, list);
12991
12992 return CMD_SUCCESS;
12993}
12994
12995DEFUN (show_ip_extcommunity_list_arg,
12996 show_ip_extcommunity_list_arg_cmd,
6147e2c6 12997 "show ip extcommunity-list <(1-500)|WORD>",
718e3744 12998 SHOW_STR
12999 IP_STR
13000 "List extended-community list\n"
13001 "Extcommunity-list number\n"
13002 "Extcommunity-list name\n")
13003{
c500ae40 13004 int idx_comm_list = 3;
718e3744 13005 struct community_list *list;
13006
c500ae40 13007 list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, EXTCOMMUNITY_LIST_MASTER);
718e3744 13008 if (! list)
13009 {
b729294c 13010 vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE);
718e3744 13011 return CMD_WARNING;
13012 }
13013
13014 extcommunity_list_show (vty, list);
13015
13016 return CMD_SUCCESS;
13017}
6b0655a2 13018
718e3744 13019/* Return configuration string of community-list entry. */
fd79ac91 13020static const char *
718e3744 13021community_list_config_str (struct community_entry *entry)
13022{
fd79ac91 13023 const char *str;
718e3744 13024
13025 if (entry->any)
13026 str = "";
13027 else
13028 {
13029 if (entry->style == COMMUNITY_LIST_STANDARD)
13030 str = community_str (entry->u.com);
13031 else
13032 str = entry->config;
13033 }
13034 return str;
13035}
13036
13037/* Display community-list and extcommunity-list configuration. */
94f2b392 13038static int
718e3744 13039community_list_config_write (struct vty *vty)
13040{
13041 struct community_list *list;
13042 struct community_entry *entry;
13043 struct community_list_master *cm;
13044 int write = 0;
13045
13046 /* Community-list. */
fee6e4e4 13047 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
718e3744 13048
13049 for (list = cm->num.head; list; list = list->next)
13050 for (entry = list->head; entry; entry = entry->next)
13051 {
fee6e4e4 13052 vty_out (vty, "ip community-list %s %s %s%s",
13053 list->name, community_direct_str (entry->direct),
13054 community_list_config_str (entry),
13055 VTY_NEWLINE);
718e3744 13056 write++;
13057 }
13058 for (list = cm->str.head; list; list = list->next)
13059 for (entry = list->head; entry; entry = entry->next)
13060 {
13061 vty_out (vty, "ip community-list %s %s %s %s%s",
13062 entry->style == COMMUNITY_LIST_STANDARD
13063 ? "standard" : "expanded",
13064 list->name, community_direct_str (entry->direct),
13065 community_list_config_str (entry),
13066 VTY_NEWLINE);
13067 write++;
13068 }
13069
13070 /* Extcommunity-list. */
fee6e4e4 13071 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
718e3744 13072
13073 for (list = cm->num.head; list; list = list->next)
13074 for (entry = list->head; entry; entry = entry->next)
13075 {
fee6e4e4 13076 vty_out (vty, "ip extcommunity-list %s %s %s%s",
13077 list->name, community_direct_str (entry->direct),
13078 community_list_config_str (entry), VTY_NEWLINE);
718e3744 13079 write++;
13080 }
13081 for (list = cm->str.head; list; list = list->next)
13082 for (entry = list->head; entry; entry = entry->next)
13083 {
13084 vty_out (vty, "ip extcommunity-list %s %s %s %s%s",
13085 entry->style == EXTCOMMUNITY_LIST_STANDARD
13086 ? "standard" : "expanded",
13087 list->name, community_direct_str (entry->direct),
13088 community_list_config_str (entry), VTY_NEWLINE);
13089 write++;
13090 }
13091 return write;
13092}
13093
7fc626de 13094static struct cmd_node community_list_node =
718e3744 13095{
13096 COMMUNITY_LIST_NODE,
13097 "",
13098 1 /* Export to vtysh. */
13099};
13100
94f2b392 13101static void
13102community_list_vty (void)
718e3744 13103{
13104 install_node (&community_list_node, community_list_config_write);
13105
13106 /* Community-list. */
718e3744 13107 install_element (CONFIG_NODE, &ip_community_list_standard_cmd);
718e3744 13108 install_element (CONFIG_NODE, &ip_community_list_expanded_cmd);
13109 install_element (CONFIG_NODE, &ip_community_list_name_standard_cmd);
718e3744 13110 install_element (CONFIG_NODE, &ip_community_list_name_expanded_cmd);
fee6e4e4 13111 install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd);
813d4307 13112 install_element (CONFIG_NODE, &no_ip_community_list_standard_direction_cmd);
fee6e4e4 13113 install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd);
13114 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_all_cmd);
13115 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_all_cmd);
718e3744 13116 install_element (CONFIG_NODE, &no_ip_community_list_standard_cmd);
13117 install_element (CONFIG_NODE, &no_ip_community_list_expanded_cmd);
13118 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_cmd);
813d4307 13119 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_brief_cmd);
718e3744 13120 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_cmd);
13121 install_element (VIEW_NODE, &show_ip_community_list_cmd);
13122 install_element (VIEW_NODE, &show_ip_community_list_arg_cmd);
13123 install_element (ENABLE_NODE, &show_ip_community_list_cmd);
13124 install_element (ENABLE_NODE, &show_ip_community_list_arg_cmd);
13125
13126 /* Extcommunity-list. */
13127 install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd);
718e3744 13128 install_element (CONFIG_NODE, &ip_extcommunity_list_expanded_cmd);
13129 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard_cmd);
718e3744 13130 install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd);
fee6e4e4 13131 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd);
813d4307 13132 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_direction_cmd);
fee6e4e4 13133 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd);
13134 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_all_cmd);
13135 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_all_cmd);
718e3744 13136 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_cmd);
13137 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_cmd);
13138 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_cmd);
813d4307 13139 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_brief_cmd);
718e3744 13140 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_cmd);
13141 install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd);
13142 install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd);
13143 install_element (ENABLE_NODE, &show_ip_extcommunity_list_cmd);
13144 install_element (ENABLE_NODE, &show_ip_extcommunity_list_arg_cmd);
8334fd5a 13145T }