]> git.proxmox.com Git - mirror_frr.git/blame - bgpd/bgp_vty.c
This patch adds support for allowing BGP to create and bring up neighbor
[mirror_frr.git] / bgpd / bgp_vty.c
CommitLineData
718e3744 1/* BGP VTY interface.
2 Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
3
4This file is part of GNU Zebra.
5
6GNU Zebra is free software; you can redistribute it and/or modify it
7under the terms of the GNU General Public License as published by the
8Free Software Foundation; either version 2, or (at your option) any
9later version.
10
11GNU Zebra is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Zebra; see the file COPYING. If not, write to the Free
18Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1902111-1307, USA. */
20
21#include <zebra.h>
22
23#include "command.h"
24#include "prefix.h"
25#include "plist.h"
26#include "buffer.h"
27#include "linklist.h"
28#include "stream.h"
29#include "thread.h"
30#include "log.h"
3b8b1855 31#include "memory.h"
4bf6a362 32#include "hash.h"
3f9c7369 33#include "queue.h"
718e3744 34
35#include "bgpd/bgpd.h"
4bf6a362 36#include "bgpd/bgp_advertise.h"
718e3744 37#include "bgpd/bgp_attr.h"
38#include "bgpd/bgp_aspath.h"
39#include "bgpd/bgp_community.h"
4bf6a362
PJ
40#include "bgpd/bgp_ecommunity.h"
41#include "bgpd/bgp_damp.h"
718e3744 42#include "bgpd/bgp_debug.h"
e0701b79 43#include "bgpd/bgp_fsm.h"
718e3744 44#include "bgpd/bgp_mplsvpn.h"
4bf6a362 45#include "bgpd/bgp_nexthop.h"
718e3744 46#include "bgpd/bgp_open.h"
4bf6a362 47#include "bgpd/bgp_regex.h"
718e3744 48#include "bgpd/bgp_route.h"
49#include "bgpd/bgp_zebra.h"
fee0f4c6 50#include "bgpd/bgp_table.h"
94f2b392 51#include "bgpd/bgp_vty.h"
165b5fff 52#include "bgpd/bgp_mpath.h"
cb1faec9 53#include "bgpd/bgp_packet.h"
3f9c7369 54#include "bgpd/bgp_updgrp.h"
718e3744 55
18a6dce6 56extern struct in_addr router_id_zebra;
57
718e3744 58/* Utility function to get address family from current node. */
59afi_t
60bgp_node_afi (struct vty *vty)
61{
25ffbdc1 62 if (vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE)
718e3744 63 return AFI_IP6;
64 return AFI_IP;
65}
66
67/* Utility function to get subsequent address family from current
68 node. */
69safi_t
70bgp_node_safi (struct vty *vty)
71{
72 if (vty->node == BGP_VPNV4_NODE)
73 return SAFI_MPLS_VPN;
25ffbdc1 74 if (vty->node == BGP_IPV4M_NODE || vty->node == BGP_IPV6M_NODE)
718e3744 75 return SAFI_MULTICAST;
76 return SAFI_UNICAST;
77}
78
94f2b392 79static int
718e3744 80peer_address_self_check (union sockunion *su)
81{
82 struct interface *ifp = NULL;
83
84 if (su->sa.sa_family == AF_INET)
85 ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr);
86#ifdef HAVE_IPV6
87 else if (su->sa.sa_family == AF_INET6)
88 ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr);
89#endif /* HAVE IPV6 */
90
91 if (ifp)
92 return 1;
93
94 return 0;
95}
96
97/* Utility function for looking up peer from VTY. */
f14e6fdb
DS
98/* This is used only for configuration, so disallow if attempted on
99 * a dynamic neighbor.
100 */
94f2b392 101static struct peer *
fd79ac91 102peer_lookup_vty (struct vty *vty, const char *ip_str)
718e3744 103{
104 int ret;
105 struct bgp *bgp;
106 union sockunion su;
107 struct peer *peer;
108
109 bgp = vty->index;
110
111 ret = str2sockunion (ip_str, &su);
112 if (ret < 0)
113 {
a80beece
DS
114 peer = peer_lookup_by_conf_if (bgp, ip_str);
115 if (!peer)
116 {
117 vty_out (vty, "%% Malformed address or name: %s%s", ip_str, VTY_NEWLINE);
118 return NULL;
119 }
718e3744 120 }
a80beece 121 else
718e3744 122 {
a80beece
DS
123 peer = peer_lookup (bgp, &su);
124 if (! peer)
125 {
126 vty_out (vty, "%% Specify remote-as or peer-group commands first%s",
127 VTY_NEWLINE);
128 return NULL;
129 }
f14e6fdb
DS
130 if (peer_dynamic_neighbor (peer))
131 {
132 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
133 VTY_NEWLINE);
134 return NULL;
135 }
136
718e3744 137 }
138 return peer;
139}
140
141/* Utility function for looking up peer or peer group. */
f14e6fdb
DS
142/* This is used only for configuration, so disallow if attempted on
143 * a dynamic neighbor.
144 */
94f2b392 145static struct peer *
fd79ac91 146peer_and_group_lookup_vty (struct vty *vty, const char *peer_str)
718e3744 147{
148 int ret;
149 struct bgp *bgp;
150 union sockunion su;
f14e6fdb
DS
151 struct peer *peer = NULL;
152 struct peer_group *group = NULL;
718e3744 153
154 bgp = vty->index;
155
156 ret = str2sockunion (peer_str, &su);
157 if (ret == 0)
158 {
f14e6fdb 159 /* IP address, locate peer. */
718e3744 160 peer = peer_lookup (bgp, &su);
718e3744 161 }
162 else
163 {
f14e6fdb 164 /* Not IP, could match either peer configured on interface or a group. */
a80beece 165 peer = peer_lookup_by_conf_if (bgp, peer_str);
f14e6fdb
DS
166 if (!peer)
167 group = peer_group_lookup (bgp, peer_str);
168 }
a80beece 169
f14e6fdb
DS
170 if (peer)
171 {
172 if (peer_dynamic_neighbor (peer))
173 {
174 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
175 VTY_NEWLINE);
176 return NULL;
177 }
178
179 return peer;
718e3744 180 }
181
f14e6fdb
DS
182 if (group)
183 return group->conf;
184
718e3744 185 vty_out (vty, "%% Specify remote-as or peer-group commands first%s",
186 VTY_NEWLINE);
187
188 return NULL;
189}
190
94f2b392 191static int
718e3744 192bgp_vty_return (struct vty *vty, int ret)
193{
fd79ac91 194 const char *str = NULL;
718e3744 195
196 switch (ret)
197 {
198 case BGP_ERR_INVALID_VALUE:
199 str = "Invalid value";
200 break;
201 case BGP_ERR_INVALID_FLAG:
202 str = "Invalid flag";
203 break;
204 case BGP_ERR_PEER_INACTIVE:
205 str = "Activate the neighbor for the address family first";
206 break;
207 case BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER:
208 str = "Invalid command for a peer-group member";
209 break;
210 case BGP_ERR_PEER_GROUP_SHUTDOWN:
211 str = "Peer-group has been shutdown. Activate the peer-group first";
212 break;
213 case BGP_ERR_PEER_GROUP_HAS_THE_FLAG:
214 str = "This peer is a peer-group member. Please change peer-group configuration";
215 break;
216 case BGP_ERR_PEER_FLAG_CONFLICT:
217 str = "Can't set override-capability and strict-capability-match at the same time";
218 break;
219 case BGP_ERR_PEER_GROUP_MEMBER_EXISTS:
220 str = "No activate for peergroup can be given only if peer-group has no members";
221 break;
222 case BGP_ERR_PEER_BELONGS_TO_GROUP:
223 str = "No activate for an individual peer-group member is invalid";
224 break;
225 case BGP_ERR_PEER_GROUP_AF_UNCONFIGURED:
226 str = "Activate the peer-group for the address family first";
227 break;
228 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS:
229 str = "Specify remote-as or peer-group remote AS first";
230 break;
231 case BGP_ERR_PEER_GROUP_CANT_CHANGE:
232 str = "Cannot change the peer-group. Deconfigure first";
233 break;
234 case BGP_ERR_PEER_GROUP_MISMATCH:
235 str = "Cannot have different peer-group for the neighbor";
236 break;
237 case BGP_ERR_PEER_FILTER_CONFLICT:
238 str = "Prefix/distribute list can not co-exist";
239 break;
240 case BGP_ERR_NOT_INTERNAL_PEER:
241 str = "Invalid command. Not an internal neighbor";
242 break;
243 case BGP_ERR_REMOVE_PRIVATE_AS:
5000f21c 244 str = "remove-private-AS cannot be configured for IBGP peers";
718e3744 245 break;
246 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP:
247 str = "Local-AS allowed only for EBGP peers";
248 break;
249 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS:
250 str = "Cannot have local-as same as BGP AS number";
251 break;
0df7c91f
PJ
252 case BGP_ERR_TCPSIG_FAILED:
253 str = "Error while applying TCP-Sig to session(s)";
254 break;
fa411a21
NH
255 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK:
256 str = "ebgp-multihop and ttl-security cannot be configured together";
257 break;
f5a4827d
SH
258 case BGP_ERR_NO_IBGP_WITH_TTLHACK:
259 str = "ttl-security only allowed for EBGP peers";
260 break;
c7122e14
DS
261 case BGP_ERR_AS_OVERRIDE:
262 str = "as-override cannot be configured for IBGP peers";
263 break;
f14e6fdb
DS
264 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT:
265 str = "Invalid limit for number of dynamic neighbors";
266 break;
267 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS:
268 str = "Dynamic neighbor listen range already exists";
269 break;
270 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER:
271 str = "Operation not allowed on a dynamic neighbor";
272 break;
718e3744 273 }
274 if (str)
275 {
276 vty_out (vty, "%% %s%s", str, VTY_NEWLINE);
277 return CMD_WARNING;
278 }
279 return CMD_SUCCESS;
280}
281
282/* BGP global configuration. */
283
284DEFUN (bgp_multiple_instance_func,
285 bgp_multiple_instance_cmd,
286 "bgp multiple-instance",
287 BGP_STR
288 "Enable bgp multiple instance\n")
289{
290 bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE);
291 return CMD_SUCCESS;
292}
293
294DEFUN (no_bgp_multiple_instance,
295 no_bgp_multiple_instance_cmd,
296 "no bgp multiple-instance",
297 NO_STR
298 BGP_STR
299 "BGP multiple instance\n")
300{
301 int ret;
302
303 ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE);
304 if (ret < 0)
305 {
306 vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE);
307 return CMD_WARNING;
308 }
309 return CMD_SUCCESS;
310}
311
312DEFUN (bgp_config_type,
313 bgp_config_type_cmd,
314 "bgp config-type (cisco|zebra)",
315 BGP_STR
316 "Configuration type\n"
317 "cisco\n"
318 "zebra\n")
319{
320 if (strncmp (argv[0], "c", 1) == 0)
321 bgp_option_set (BGP_OPT_CONFIG_CISCO);
322 else
323 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
324
325 return CMD_SUCCESS;
326}
327
328DEFUN (no_bgp_config_type,
329 no_bgp_config_type_cmd,
330 "no bgp config-type",
331 NO_STR
332 BGP_STR
333 "Display configuration type\n")
334{
335 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
336 return CMD_SUCCESS;
337}
338
339DEFUN (no_synchronization,
340 no_synchronization_cmd,
341 "no synchronization",
342 NO_STR
343 "Perform IGP synchronization\n")
344{
345 return CMD_SUCCESS;
346}
347
348DEFUN (no_auto_summary,
349 no_auto_summary_cmd,
350 "no auto-summary",
351 NO_STR
352 "Enable automatic network number summarization\n")
353{
354 return CMD_SUCCESS;
355}
3d515fd9 356
357DEFUN_DEPRECATED (neighbor_version,
358 neighbor_version_cmd,
359 NEIGHBOR_CMD "version (4|4-)",
360 NEIGHBOR_STR
361 NEIGHBOR_ADDR_STR
362 "Set the BGP version to match a neighbor\n"
363 "Neighbor's BGP version\n")
364{
365 return CMD_SUCCESS;
366}
6b0655a2 367
718e3744 368/* "router bgp" commands. */
369DEFUN (router_bgp,
370 router_bgp_cmd,
320da874 371 "router bgp " CMD_AS_RANGE,
718e3744 372 ROUTER_STR
373 BGP_STR
374 AS_STR)
375{
376 int ret;
377 as_t as;
378 struct bgp *bgp;
fd79ac91 379 const char *name = NULL;
718e3744 380
0b2aa3a0 381 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
718e3744 382
383 if (argc == 2)
384 name = argv[1];
385
386 ret = bgp_get (&bgp, &as, name);
387 switch (ret)
388 {
389 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET:
390 vty_out (vty, "Please specify 'bgp multiple-instance' first%s",
391 VTY_NEWLINE);
392 return CMD_WARNING;
718e3744 393 case BGP_ERR_AS_MISMATCH:
aea339f7 394 vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE);
718e3744 395 return CMD_WARNING;
718e3744 396 case BGP_ERR_INSTANCE_MISMATCH:
397 vty_out (vty, "BGP view name and AS number mismatch%s", VTY_NEWLINE);
aea339f7 398 vty_out (vty, "BGP instance is already running; AS is %u%s",
718e3744 399 as, VTY_NEWLINE);
400 return CMD_WARNING;
718e3744 401 }
402
403 vty->node = BGP_NODE;
404 vty->index = bgp;
405
406 return CMD_SUCCESS;
407}
408
409ALIAS (router_bgp,
410 router_bgp_view_cmd,
320da874 411 "router bgp " CMD_AS_RANGE " view WORD",
718e3744 412 ROUTER_STR
413 BGP_STR
414 AS_STR
415 "BGP view\n"
416 "view name\n")
6b0655a2 417
718e3744 418/* "no router bgp" commands. */
419DEFUN (no_router_bgp,
420 no_router_bgp_cmd,
320da874 421 "no router bgp " CMD_AS_RANGE,
718e3744 422 NO_STR
423 ROUTER_STR
424 BGP_STR
425 AS_STR)
426{
427 as_t as;
428 struct bgp *bgp;
fd79ac91 429 const char *name = NULL;
718e3744 430
0b2aa3a0 431 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
718e3744 432
433 if (argc == 2)
434 name = argv[1];
435
436 /* Lookup bgp structure. */
437 bgp = bgp_lookup (as, name);
438 if (! bgp)
439 {
440 vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE);
441 return CMD_WARNING;
442 }
443
444 bgp_delete (bgp);
445
446 return CMD_SUCCESS;
447}
448
449ALIAS (no_router_bgp,
450 no_router_bgp_view_cmd,
320da874 451 "no router bgp " CMD_AS_RANGE " view WORD",
718e3744 452 NO_STR
453 ROUTER_STR
454 BGP_STR
455 AS_STR
456 "BGP view\n"
457 "view name\n")
6b0655a2 458
718e3744 459/* BGP router-id. */
460
461DEFUN (bgp_router_id,
462 bgp_router_id_cmd,
463 "bgp router-id A.B.C.D",
464 BGP_STR
465 "Override configured router identifier\n"
466 "Manually configured router identifier\n")
467{
468 int ret;
469 struct in_addr id;
470 struct bgp *bgp;
471
472 bgp = vty->index;
473
474 ret = inet_aton (argv[0], &id);
475 if (! ret)
476 {
477 vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE);
478 return CMD_WARNING;
479 }
480
18a6dce6 481 bgp->router_id_static = id;
718e3744 482 bgp_router_id_set (bgp, &id);
483
484 return CMD_SUCCESS;
485}
486
487DEFUN (no_bgp_router_id,
488 no_bgp_router_id_cmd,
489 "no bgp router-id",
490 NO_STR
491 BGP_STR
492 "Override configured router identifier\n")
493{
494 int ret;
495 struct in_addr id;
496 struct bgp *bgp;
497
498 bgp = vty->index;
499
500 if (argc == 1)
501 {
502 ret = inet_aton (argv[0], &id);
503 if (! ret)
504 {
505 vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE);
506 return CMD_WARNING;
507 }
508
18a6dce6 509 if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id))
718e3744 510 {
511 vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE);
512 return CMD_WARNING;
513 }
514 }
515
18a6dce6 516 bgp->router_id_static.s_addr = 0;
517 bgp_router_id_set (bgp, &router_id_zebra);
718e3744 518
519 return CMD_SUCCESS;
520}
521
522ALIAS (no_bgp_router_id,
523 no_bgp_router_id_val_cmd,
524 "no bgp router-id A.B.C.D",
525 NO_STR
526 BGP_STR
527 "Override configured router identifier\n"
528 "Manually configured router identifier\n")
6b0655a2 529
718e3744 530/* BGP Cluster ID. */
531
532DEFUN (bgp_cluster_id,
533 bgp_cluster_id_cmd,
534 "bgp cluster-id A.B.C.D",
535 BGP_STR
536 "Configure Route-Reflector Cluster-id\n"
537 "Route-Reflector Cluster-id in IP address format\n")
538{
539 int ret;
540 struct bgp *bgp;
541 struct in_addr cluster;
542
543 bgp = vty->index;
544
545 ret = inet_aton (argv[0], &cluster);
546 if (! ret)
547 {
548 vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
549 return CMD_WARNING;
550 }
551
552 bgp_cluster_id_set (bgp, &cluster);
553
554 return CMD_SUCCESS;
555}
556
557ALIAS (bgp_cluster_id,
558 bgp_cluster_id32_cmd,
559 "bgp cluster-id <1-4294967295>",
560 BGP_STR
561 "Configure Route-Reflector Cluster-id\n"
562 "Route-Reflector Cluster-id as 32 bit quantity\n")
563
564DEFUN (no_bgp_cluster_id,
565 no_bgp_cluster_id_cmd,
566 "no bgp cluster-id",
567 NO_STR
568 BGP_STR
569 "Configure Route-Reflector Cluster-id\n")
570{
571 int ret;
572 struct bgp *bgp;
573 struct in_addr cluster;
574
575 bgp = vty->index;
576
577 if (argc == 1)
578 {
579 ret = inet_aton (argv[0], &cluster);
580 if (! ret)
581 {
582 vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
583 return CMD_WARNING;
584 }
585 }
586
587 bgp_cluster_id_unset (bgp);
588
589 return CMD_SUCCESS;
590}
591
592ALIAS (no_bgp_cluster_id,
593 no_bgp_cluster_id_arg_cmd,
594 "no bgp cluster-id A.B.C.D",
595 NO_STR
596 BGP_STR
597 "Configure Route-Reflector Cluster-id\n"
598 "Route-Reflector Cluster-id in IP address format\n")
6b0655a2 599
718e3744 600DEFUN (bgp_confederation_identifier,
601 bgp_confederation_identifier_cmd,
320da874 602 "bgp confederation identifier " CMD_AS_RANGE,
718e3744 603 "BGP specific commands\n"
604 "AS confederation parameters\n"
605 "AS number\n"
606 "Set routing domain confederation AS\n")
607{
608 struct bgp *bgp;
609 as_t as;
610
611 bgp = vty->index;
612
0b2aa3a0 613 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
718e3744 614
615 bgp_confederation_id_set (bgp, as);
616
617 return CMD_SUCCESS;
618}
619
620DEFUN (no_bgp_confederation_identifier,
621 no_bgp_confederation_identifier_cmd,
622 "no bgp confederation identifier",
623 NO_STR
624 "BGP specific commands\n"
625 "AS confederation parameters\n"
626 "AS number\n")
627{
628 struct bgp *bgp;
629 as_t as;
630
631 bgp = vty->index;
632
633 if (argc == 1)
0b2aa3a0 634 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
718e3744 635
636 bgp_confederation_id_unset (bgp);
637
638 return CMD_SUCCESS;
639}
640
641ALIAS (no_bgp_confederation_identifier,
642 no_bgp_confederation_identifier_arg_cmd,
320da874 643 "no bgp confederation identifier " CMD_AS_RANGE,
718e3744 644 NO_STR
645 "BGP specific commands\n"
646 "AS confederation parameters\n"
647 "AS number\n"
648 "Set routing domain confederation AS\n")
6b0655a2 649
718e3744 650DEFUN (bgp_confederation_peers,
651 bgp_confederation_peers_cmd,
320da874 652 "bgp confederation peers ." CMD_AS_RANGE,
718e3744 653 "BGP specific commands\n"
654 "AS confederation parameters\n"
655 "Peer ASs in BGP confederation\n"
656 AS_STR)
657{
658 struct bgp *bgp;
659 as_t as;
660 int i;
661
662 bgp = vty->index;
663
664 for (i = 0; i < argc; i++)
665 {
0b2aa3a0 666 VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX);
718e3744 667
668 if (bgp->as == as)
669 {
670 vty_out (vty, "%% Local member-AS not allowed in confed peer list%s",
671 VTY_NEWLINE);
672 continue;
673 }
674
675 bgp_confederation_peers_add (bgp, as);
676 }
677 return CMD_SUCCESS;
678}
679
680DEFUN (no_bgp_confederation_peers,
681 no_bgp_confederation_peers_cmd,
320da874 682 "no bgp confederation peers ." CMD_AS_RANGE,
718e3744 683 NO_STR
684 "BGP specific commands\n"
685 "AS confederation parameters\n"
686 "Peer ASs in BGP confederation\n"
687 AS_STR)
688{
689 struct bgp *bgp;
690 as_t as;
691 int i;
692
693 bgp = vty->index;
694
695 for (i = 0; i < argc; i++)
696 {
0b2aa3a0
PJ
697 VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX);
698
718e3744 699 bgp_confederation_peers_remove (bgp, as);
700 }
701 return CMD_SUCCESS;
702}
6b0655a2 703
5e242b0d
DS
704/**
705 * Central routine for maximum-paths configuration.
706 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
707 * @set: 1 for setting values, 0 for removing the max-paths config.
708 */
709int
710bgp_maxpaths_config_vty (struct vty *vty, int peer_type, char *mpaths,
711 u_int16_t options, int set)
165b5fff
JB
712{
713 struct bgp *bgp;
714 u_int16_t maxpaths;
715 int ret;
5e242b0d
DS
716 afi_t afi;
717 safi_t safi;
165b5fff
JB
718
719 bgp = vty->index;
5e242b0d
DS
720 afi = bgp_node_afi (vty);
721 safi = bgp_node_safi (vty);
165b5fff 722
5e242b0d
DS
723 if (set)
724 {
73ac8160
DS
725 VTY_GET_INTEGER_RANGE ("maximum-paths", maxpaths, mpaths, 1,
726 BGP_MAXIMUM_MAXPATHS);
5e242b0d
DS
727 ret = bgp_maximum_paths_set (bgp, afi, safi, peer_type, maxpaths,
728 options);
729 }
730 else
731 ret = bgp_maximum_paths_unset (bgp, afi, safi, peer_type);
165b5fff 732
165b5fff
JB
733 if (ret < 0)
734 {
735 vty_out (vty,
5e242b0d
DS
736 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u%s",
737 (set == 1) ? "" : "un",
738 (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp",
739 maxpaths, afi, safi, VTY_NEWLINE);
165b5fff
JB
740 return CMD_WARNING;
741 }
742
743 return CMD_SUCCESS;
744}
745
abc920f8
DS
746DEFUN (bgp_maxmed_admin,
747 bgp_maxmed_admin_cmd,
748 "bgp max-med administrative ",
749 BGP_STR
750 "Advertise routes with max-med\n"
751 "Administratively applied, for an indefinite period\n")
752{
753 struct bgp *bgp;
754
755 bgp = vty->index;
756
757 bgp->v_maxmed_admin = 1;
758 bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT;
759
760 bgp_maxmed_update(bgp);
761
762 return CMD_SUCCESS;
763}
764
765DEFUN (bgp_maxmed_admin_medv,
766 bgp_maxmed_admin_medv_cmd,
767 "bgp max-med administrative <0-4294967294>",
768 BGP_STR
769 "Advertise routes with max-med\n"
770 "Administratively applied, for an indefinite period\n"
771 "Max MED value to be used\n")
772{
773 struct bgp *bgp;
774
775 bgp = vty->index;
776
777 bgp->v_maxmed_admin = 1;
778 VTY_GET_INTEGER ("max-med admin med-value", bgp->maxmed_admin_value, argv[0]);
779
780 bgp_maxmed_update(bgp);
781
782 return CMD_SUCCESS;
783}
784
785DEFUN (no_bgp_maxmed_admin,
786 no_bgp_maxmed_admin_cmd,
787 "no bgp max-med administrative",
788 NO_STR
789 BGP_STR
790 "Advertise routes with max-med\n"
791 "Administratively applied, for an indefinite period\n")
792{
793 struct bgp *bgp;
794
795 bgp = vty->index;
796
797 bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED;
798 bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT;
799
800 bgp_maxmed_update(bgp);
801
802 return CMD_SUCCESS;
803}
804
805ALIAS (no_bgp_maxmed_admin,
806 no_bgp_maxmed_admin_medv_cmd,
807 "no bgp max-med administrative <0-4294967294>",
808 NO_STR
809 BGP_STR
810 "Advertise routes with max-med\n"
811 "Administratively applied, for an indefinite period\n"
812 "Max MED value to be used\n")
813
814
815DEFUN (bgp_maxmed_onstartup,
816 bgp_maxmed_onstartup_cmd,
817 "bgp max-med on-startup <5-86400>",
818 BGP_STR
819 "Advertise routes with max-med\n"
820 "Effective on a startup\n"
821 "Time (seconds) period for max-med\n")
822{
823 struct bgp *bgp;
824
825 bgp = vty->index;
826
827 if (argc != 1)
828 {
829 vty_out (vty, "%% Must supply max-med on-startup period");
830 return CMD_WARNING;
831 }
832
833 VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[0]);
834 bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT;
835
836 bgp_maxmed_update(bgp);
837
838 return CMD_SUCCESS;
839}
840
841DEFUN (bgp_maxmed_onstartup_medv,
842 bgp_maxmed_onstartup_medv_cmd,
843 "bgp max-med on-startup <5-86400> <0-4294967294>",
844 BGP_STR
845 "Advertise routes with max-med\n"
846 "Effective on a startup\n"
847 "Time (seconds) period for max-med\n"
848 "Max MED value to be used\n")
849{
850 struct bgp *bgp;
851
852 bgp = vty->index;
853
854 if (argc != 2)
855 {
856 vty_out (vty, "%% Must supply max-med on-startup period and med value");
857 return CMD_WARNING;
858 }
859
860 VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[0]);
861 VTY_GET_INTEGER ("max-med on-startup med-value", bgp->maxmed_onstartup_value, argv[1]);
862
863 bgp_maxmed_update(bgp);
864
865 return CMD_SUCCESS;
866}
867
868DEFUN (no_bgp_maxmed_onstartup,
869 no_bgp_maxmed_onstartup_cmd,
870 "no bgp max-med on-startup",
871 NO_STR
872 BGP_STR
873 "Advertise routes with max-med\n"
874 "Effective on a startup\n")
875{
876 struct bgp *bgp;
877
878 bgp = vty->index;
879
880 /* Cancel max-med onstartup if its on */
881 if (bgp->t_maxmed_onstartup)
882 {
883 THREAD_TIMER_OFF (bgp->t_maxmed_onstartup);
884 bgp->maxmed_onstartup_over = 1;
885 }
886
887 bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED;
888 bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT;
889
890 bgp_maxmed_update(bgp);
891
892 return CMD_SUCCESS;
893}
894
895ALIAS (no_bgp_maxmed_onstartup,
896 no_bgp_maxmed_onstartup_period_cmd,
897 "no bgp max-med on-startup <5-86400>",
898 NO_STR
899 BGP_STR
900 "Advertise routes with max-med\n"
901 "Effective on a startup\n"
902 "Time (seconds) period for max-med\n")
903
904ALIAS (no_bgp_maxmed_onstartup,
905 no_bgp_maxmed_onstartup_period_medv_cmd,
906 "no bgp max-med on-startup <5-86400> <0-4294967294>",
907 NO_STR
908 BGP_STR
909 "Advertise routes with max-med\n"
910 "Effective on a startup\n"
911 "Time (seconds) period for max-med\n"
912 "Max MED value to be used\n")
913
f188f2c4
DS
914static int
915bgp_update_delay_config_vty (struct vty *vty, const char *delay,
916 const char *wait)
917{
918 struct bgp *bgp;
919 u_int16_t update_delay;
920 u_int16_t establish_wait;
921
922
923 bgp = vty->index;
924
925 VTY_GET_INTEGER_RANGE ("update-delay", update_delay, delay,
926 BGP_UPDATE_DELAY_MIN, BGP_UPDATE_DELAY_MAX);
927
928 if (!wait) /* update-delay <delay> */
929 {
930 bgp->v_update_delay = update_delay;
931 bgp->v_establish_wait = bgp->v_update_delay;
932 return CMD_SUCCESS;
933 }
934
935 /* update-delay <delay> <establish-wait> */
936 establish_wait = atoi (wait);
937 if (update_delay < establish_wait)
938 {
939 vty_out (vty, "%%Failed: update-delay less than the establish-wait!%s",
940 VTY_NEWLINE);
941 return CMD_WARNING;
942 }
943
944 bgp->v_update_delay = update_delay;
945 bgp->v_establish_wait = establish_wait;
946
947 return CMD_SUCCESS;
948}
949
950static int
951bgp_update_delay_deconfig_vty (struct vty *vty)
952{
953 struct bgp *bgp;
954
955 bgp = vty->index;
956
957 bgp->v_update_delay = BGP_UPDATE_DELAY_DEF;
958 bgp->v_establish_wait = bgp->v_update_delay;
959
960 return CMD_SUCCESS;
961}
962
963int
964bgp_config_write_update_delay (struct vty *vty, struct bgp *bgp)
965{
966 if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF)
967 {
968 vty_out (vty, " update-delay %d", bgp->v_update_delay);
969 if (bgp->v_update_delay != bgp->v_establish_wait)
970 vty_out (vty, " %d", bgp->v_establish_wait);
971 vty_out (vty, "%s", VTY_NEWLINE);
972 }
973
974 return 0;
975}
976
977
978/* Update-delay configuration */
979DEFUN (bgp_update_delay,
980 bgp_update_delay_cmd,
981 "update-delay <0-3600>",
982 "Force initial delay for best-path and updates\n"
983 "Seconds\n")
984{
985 return bgp_update_delay_config_vty(vty, argv[0], NULL);
986}
987
988DEFUN (bgp_update_delay_establish_wait,
989 bgp_update_delay_establish_wait_cmd,
990 "update-delay <0-3600> <1-3600>",
991 "Force initial delay for best-path and updates\n"
992 "Seconds\n"
993 "Wait for peers to be established\n"
994 "Seconds\n")
995{
996 return bgp_update_delay_config_vty(vty, argv[0], argv[1]);
997}
998
999/* Update-delay deconfiguration */
1000DEFUN (no_bgp_update_delay,
1001 no_bgp_update_delay_cmd,
1002 "no update-delay <0-3600>",
1003 "Force initial delay for best-path and updates\n"
1004 "Seconds\n")
1005{
1006 return bgp_update_delay_deconfig_vty(vty);
1007}
1008
1009ALIAS (no_bgp_update_delay,
1010 no_bgp_update_delay_establish_wait_cmd,
1011 "no update-delay <0-3600> <1-3600>",
1012 "Force initial delay for best-path and updates\n"
1013 "Seconds\n"
1014 "Wait for peers to be established\n"
1015 "Seconds\n")
5e242b0d 1016
cb1faec9
DS
1017int
1018bgp_wpkt_quanta_config_vty (struct vty *vty, char *num, char set)
1019{
1020 struct bgp *bgp;
1021 u_int16_t update_delay;
1022
1023 bgp = vty->index;
1024
1025 if (set)
1026 VTY_GET_INTEGER_RANGE ("write-quanta", bgp->wpkt_quanta, num,
1027 1, 4294967295);
1028 else
1029 bgp->wpkt_quanta = BGP_WRITE_PACKET_MAX;
1030
1031 return CMD_SUCCESS;
1032}
1033
1034int
1035bgp_config_write_wpkt_quanta (struct vty *vty, struct bgp *bgp)
1036{
1037 if (bgp->wpkt_quanta != BGP_WRITE_PACKET_MAX)
1038 vty_out (vty, " write-quanta %d%s",
1039 bgp->wpkt_quanta, VTY_NEWLINE);
1040
1041 return 0;
1042}
1043
1044
1045/* Update-delay configuration */
1046DEFUN (bgp_wpkt_quanta,
1047 bgp_wpkt_quanta_cmd,
1048 "write-quanta <1-4294967295>",
1049 "How many packets to write to peer socket per run\n"
1050 "Number of packets\n")
1051{
1052 return bgp_wpkt_quanta_config_vty(vty, argv[0], 1);
1053}
1054
1055/* Update-delay deconfiguration */
1056DEFUN (no_bgp_wpkt_quanta,
1057 no_bgp_wpkt_quanta_cmd,
1058 "no write-quanta <1-4294967295>",
1059 "How many packets to write to peer socket per run\n"
1060 "Number of packets\n")
1061{
1062 return bgp_wpkt_quanta_config_vty(vty, argv[0], 0);
1063}
1064
3f9c7369
DS
1065int
1066bgp_coalesce_config_vty (struct vty *vty, const char *num, char set)
1067{
1068 struct bgp *bgp;
1069
1070 bgp = vty->index;
1071
1072 if (set)
1073 VTY_GET_INTEGER_RANGE ("coalesce-time", bgp->coalesce_time, num,
1074 0, 4294967295);
1075 else
1076 bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME;
1077
1078 return CMD_SUCCESS;
1079}
1080
1081int
1082bgp_config_write_coalesce_time (struct vty *vty, struct bgp *bgp)
1083{
1084 if (bgp->coalesce_time != BGP_DEFAULT_SUBGROUP_COALESCE_TIME)
1085 vty_out (vty, " coalesce-time %d%s",
1086 bgp->coalesce_time, VTY_NEWLINE);
1087
1088 return 0;
1089}
1090
1091
1092DEFUN (bgp_coalesce_time,
1093 bgp_coalesce_time_cmd,
1094 "coalesce-time <0-4294967295>",
1095 "Subgroup coalesce timer\n"
1096 "Subgroup coalesce timer value (in ms)\n")
1097{
1098 return bgp_coalesce_config_vty(vty, argv[0], 1);
1099}
1100
1101DEFUN (no_bgp_coalesce_time,
1102 no_bgp_coalesce_time_cmd,
1103 "no coalesce-time <0-4294967295>",
1104 "Subgroup coalesce timer\n"
1105 "Subgroup coalesce timer value (in ms)\n")
1106{
1107 return bgp_coalesce_config_vty(vty, argv[0], 0);
1108}
1109
5e242b0d
DS
1110/* Maximum-paths configuration */
1111DEFUN (bgp_maxpaths,
1112 bgp_maxpaths_cmd,
1113 "maximum-paths <1-255>",
1114 "Forward packets over multiple paths\n"
1115 "Number of paths\n")
1116{
1117 return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, argv[0], 0, 1);
1118}
1119
165b5fff
JB
1120DEFUN (bgp_maxpaths_ibgp,
1121 bgp_maxpaths_ibgp_cmd,
1122 "maximum-paths ibgp <1-255>",
1123 "Forward packets over multiple paths\n"
1124 "iBGP-multipath\n"
1125 "Number of paths\n")
1126{
5e242b0d
DS
1127 return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[0], 0, 1);
1128}
165b5fff 1129
5e242b0d
DS
1130DEFUN (bgp_maxpaths_ibgp_cluster,
1131 bgp_maxpaths_ibgp_cluster_cmd,
1132 "maximum-paths ibgp <1-255> equal-cluster-length",
1133 "Forward packets over multiple paths\n"
1134 "iBGP-multipath\n"
1135 "Number of paths\n"
1136 "Match the cluster length\n")
1137{
1138 return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[0],
1139 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1);
165b5fff
JB
1140}
1141
1142DEFUN (no_bgp_maxpaths,
1143 no_bgp_maxpaths_cmd,
1144 "no maximum-paths",
1145 NO_STR
1146 "Forward packets over multiple paths\n"
1147 "Number of paths\n")
1148{
5e242b0d 1149 return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0);
165b5fff
JB
1150}
1151
1152ALIAS (no_bgp_maxpaths,
1153 no_bgp_maxpaths_arg_cmd,
1154 "no maximum-paths <1-255>",
1155 NO_STR
1156 "Forward packets over multiple paths\n"
1157 "Number of paths\n")
1158
1159DEFUN (no_bgp_maxpaths_ibgp,
1160 no_bgp_maxpaths_ibgp_cmd,
1161 "no maximum-paths ibgp",
1162 NO_STR
1163 "Forward packets over multiple paths\n"
1164 "iBGP-multipath\n"
1165 "Number of paths\n")
1166{
5e242b0d 1167 return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0);
165b5fff
JB
1168}
1169
1170ALIAS (no_bgp_maxpaths_ibgp,
1171 no_bgp_maxpaths_ibgp_arg_cmd,
1172 "no maximum-paths ibgp <1-255>",
1173 NO_STR
1174 "Forward packets over multiple paths\n"
1175 "iBGP-multipath\n"
1176 "Number of paths\n")
1177
5e242b0d
DS
1178ALIAS (no_bgp_maxpaths_ibgp,
1179 no_bgp_maxpaths_ibgp_cluster_cmd,
1180 "no maximum-paths ibgp <1-255> equal-cluster-length",
1181 NO_STR
1182 "Forward packets over multiple paths\n"
1183 "iBGP-multipath\n"
1184 "Number of paths\n"
1185 "Match the cluster length\n")
1186
165b5fff
JB
1187int
1188bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi,
1189 safi_t safi, int *write)
1190{
1191 if (bgp->maxpaths[afi][safi].maxpaths_ebgp != BGP_DEFAULT_MAXPATHS)
1192 {
1193 bgp_config_write_family_header (vty, afi, safi, write);
1194 vty_out (vty, " maximum-paths %d%s",
1195 bgp->maxpaths[afi][safi].maxpaths_ebgp, VTY_NEWLINE);
1196 }
1197
1198 if (bgp->maxpaths[afi][safi].maxpaths_ibgp != BGP_DEFAULT_MAXPATHS)
1199 {
1200 bgp_config_write_family_header (vty, afi, safi, write);
5e242b0d
DS
1201 vty_out (vty, " maximum-paths ibgp %d",
1202 bgp->maxpaths[afi][safi].maxpaths_ibgp);
1203 if (CHECK_FLAG (bgp->maxpaths[afi][safi].ibgp_flags,
1204 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN))
1205 vty_out (vty, " equal-cluster-length");
1206 vty_out (vty, "%s", VTY_NEWLINE);
165b5fff
JB
1207 }
1208
1209 return 0;
1210}
6b0655a2 1211
718e3744 1212/* BGP timers. */
1213
1214DEFUN (bgp_timers,
1215 bgp_timers_cmd,
1216 "timers bgp <0-65535> <0-65535>",
1217 "Adjust routing timers\n"
1218 "BGP timers\n"
1219 "Keepalive interval\n"
1220 "Holdtime\n")
1221{
1222 struct bgp *bgp;
1223 unsigned long keepalive = 0;
1224 unsigned long holdtime = 0;
1225
1226 bgp = vty->index;
1227
1228 VTY_GET_INTEGER ("keepalive", keepalive, argv[0]);
1229 VTY_GET_INTEGER ("holdtime", holdtime, argv[1]);
1230
1231 /* Holdtime value check. */
1232 if (holdtime < 3 && holdtime != 0)
1233 {
1234 vty_out (vty, "%% hold time value must be either 0 or greater than 3%s",
1235 VTY_NEWLINE);
1236 return CMD_WARNING;
1237 }
1238
1239 bgp_timers_set (bgp, keepalive, holdtime);
1240
1241 return CMD_SUCCESS;
1242}
1243
1244DEFUN (no_bgp_timers,
1245 no_bgp_timers_cmd,
1246 "no timers bgp",
1247 NO_STR
1248 "Adjust routing timers\n"
1249 "BGP timers\n")
1250{
1251 struct bgp *bgp;
1252
1253 bgp = vty->index;
1254 bgp_timers_unset (bgp);
1255
1256 return CMD_SUCCESS;
1257}
1258
1259ALIAS (no_bgp_timers,
1260 no_bgp_timers_arg_cmd,
1261 "no timers bgp <0-65535> <0-65535>",
1262 NO_STR
1263 "Adjust routing timers\n"
1264 "BGP timers\n"
1265 "Keepalive interval\n"
1266 "Holdtime\n")
6b0655a2 1267
718e3744 1268DEFUN (bgp_client_to_client_reflection,
1269 bgp_client_to_client_reflection_cmd,
1270 "bgp client-to-client reflection",
1271 "BGP specific commands\n"
1272 "Configure client to client route reflection\n"
1273 "reflection of routes allowed\n")
1274{
1275 struct bgp *bgp;
1276
1277 bgp = vty->index;
1278 bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
1279 return CMD_SUCCESS;
1280}
1281
1282DEFUN (no_bgp_client_to_client_reflection,
1283 no_bgp_client_to_client_reflection_cmd,
1284 "no bgp client-to-client reflection",
1285 NO_STR
1286 "BGP specific commands\n"
1287 "Configure client to client route reflection\n"
1288 "reflection of routes allowed\n")
1289{
1290 struct bgp *bgp;
1291
1292 bgp = vty->index;
1293 bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
1294 return CMD_SUCCESS;
1295}
1296
1297/* "bgp always-compare-med" configuration. */
1298DEFUN (bgp_always_compare_med,
1299 bgp_always_compare_med_cmd,
1300 "bgp always-compare-med",
1301 "BGP specific commands\n"
1302 "Allow comparing MED from different neighbors\n")
1303{
1304 struct bgp *bgp;
1305
1306 bgp = vty->index;
1307 bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
1308 return CMD_SUCCESS;
1309}
1310
1311DEFUN (no_bgp_always_compare_med,
1312 no_bgp_always_compare_med_cmd,
1313 "no bgp always-compare-med",
1314 NO_STR
1315 "BGP specific commands\n"
1316 "Allow comparing MED from different neighbors\n")
1317{
1318 struct bgp *bgp;
1319
1320 bgp = vty->index;
1321 bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
1322 return CMD_SUCCESS;
1323}
6b0655a2 1324
718e3744 1325/* "bgp deterministic-med" configuration. */
1326DEFUN (bgp_deterministic_med,
1327 bgp_deterministic_med_cmd,
1328 "bgp deterministic-med",
1329 "BGP specific commands\n"
1330 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1331{
1332 struct bgp *bgp;
1333
1334 bgp = vty->index;
1335 bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED);
1336 return CMD_SUCCESS;
1337}
1338
1339DEFUN (no_bgp_deterministic_med,
1340 no_bgp_deterministic_med_cmd,
1341 "no bgp deterministic-med",
1342 NO_STR
1343 "BGP specific commands\n"
1344 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1345{
1346 struct bgp *bgp;
1347
1348 bgp = vty->index;
1349 bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED);
1350 return CMD_SUCCESS;
1351}
538621f2 1352
1353/* "bgp graceful-restart" configuration. */
1354DEFUN (bgp_graceful_restart,
1355 bgp_graceful_restart_cmd,
1356 "bgp graceful-restart",
1357 "BGP specific commands\n"
1358 "Graceful restart capability parameters\n")
1359{
1360 struct bgp *bgp;
1361
1362 bgp = vty->index;
1363 bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART);
1364 return CMD_SUCCESS;
1365}
1366
1367DEFUN (no_bgp_graceful_restart,
1368 no_bgp_graceful_restart_cmd,
1369 "no bgp graceful-restart",
1370 NO_STR
1371 "BGP specific commands\n"
1372 "Graceful restart capability parameters\n")
1373{
1374 struct bgp *bgp;
1375
1376 bgp = vty->index;
1377 bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART);
1378 return CMD_SUCCESS;
1379}
1380
93406d87 1381DEFUN (bgp_graceful_restart_stalepath_time,
1382 bgp_graceful_restart_stalepath_time_cmd,
1383 "bgp graceful-restart stalepath-time <1-3600>",
1384 "BGP specific commands\n"
1385 "Graceful restart capability parameters\n"
1386 "Set the max time to hold onto restarting peer's stale paths\n"
1387 "Delay value (seconds)\n")
1388{
1389 struct bgp *bgp;
1390 u_int32_t stalepath;
1391
1392 bgp = vty->index;
1393 if (! bgp)
1394 return CMD_WARNING;
1395
1396 VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[0], 1, 3600);
1397 bgp->stalepath_time = stalepath;
1398 return CMD_SUCCESS;
1399}
1400
1401DEFUN (no_bgp_graceful_restart_stalepath_time,
1402 no_bgp_graceful_restart_stalepath_time_cmd,
1403 "no bgp graceful-restart stalepath-time",
1404 NO_STR
1405 "BGP specific commands\n"
1406 "Graceful restart capability parameters\n"
1407 "Set the max time to hold onto restarting peer's stale paths\n")
1408{
1409 struct bgp *bgp;
1410
1411 bgp = vty->index;
1412 if (! bgp)
1413 return CMD_WARNING;
1414
1415 bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME;
1416 return CMD_SUCCESS;
1417}
1418
1419ALIAS (no_bgp_graceful_restart_stalepath_time,
1420 no_bgp_graceful_restart_stalepath_time_val_cmd,
1421 "no bgp graceful-restart stalepath-time <1-3600>",
1422 NO_STR
1423 "BGP specific commands\n"
1424 "Graceful restart capability parameters\n"
1425 "Set the max time to hold onto restarting peer's stale paths\n"
1426 "Delay value (seconds)\n")
1427
718e3744 1428/* "bgp fast-external-failover" configuration. */
1429DEFUN (bgp_fast_external_failover,
1430 bgp_fast_external_failover_cmd,
1431 "bgp fast-external-failover",
1432 BGP_STR
1433 "Immediately reset session if a link to a directly connected external peer goes down\n")
1434{
1435 struct bgp *bgp;
1436
1437 bgp = vty->index;
1438 bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
1439 return CMD_SUCCESS;
1440}
1441
1442DEFUN (no_bgp_fast_external_failover,
1443 no_bgp_fast_external_failover_cmd,
1444 "no bgp fast-external-failover",
1445 NO_STR
1446 BGP_STR
1447 "Immediately reset session if a link to a directly connected external peer goes down\n")
1448{
1449 struct bgp *bgp;
1450
1451 bgp = vty->index;
1452 bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
1453 return CMD_SUCCESS;
1454}
6b0655a2 1455
718e3744 1456/* "bgp enforce-first-as" configuration. */
1457DEFUN (bgp_enforce_first_as,
1458 bgp_enforce_first_as_cmd,
1459 "bgp enforce-first-as",
1460 BGP_STR
1461 "Enforce the first AS for EBGP routes\n")
1462{
1463 struct bgp *bgp;
1464
1465 bgp = vty->index;
1466 bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
1467 return CMD_SUCCESS;
1468}
1469
1470DEFUN (no_bgp_enforce_first_as,
1471 no_bgp_enforce_first_as_cmd,
1472 "no bgp enforce-first-as",
1473 NO_STR
1474 BGP_STR
1475 "Enforce the first AS for EBGP routes\n")
1476{
1477 struct bgp *bgp;
1478
1479 bgp = vty->index;
1480 bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
1481 return CMD_SUCCESS;
1482}
6b0655a2 1483
718e3744 1484/* "bgp bestpath compare-routerid" configuration. */
1485DEFUN (bgp_bestpath_compare_router_id,
1486 bgp_bestpath_compare_router_id_cmd,
1487 "bgp bestpath compare-routerid",
1488 "BGP specific commands\n"
1489 "Change the default bestpath selection\n"
1490 "Compare router-id for identical EBGP paths\n")
1491{
1492 struct bgp *bgp;
1493
1494 bgp = vty->index;
1495 bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
1496 return CMD_SUCCESS;
1497}
1498
1499DEFUN (no_bgp_bestpath_compare_router_id,
1500 no_bgp_bestpath_compare_router_id_cmd,
1501 "no bgp bestpath compare-routerid",
1502 NO_STR
1503 "BGP specific commands\n"
1504 "Change the default bestpath selection\n"
1505 "Compare router-id for identical EBGP paths\n")
1506{
1507 struct bgp *bgp;
1508
1509 bgp = vty->index;
1510 bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
1511 return CMD_SUCCESS;
1512}
6b0655a2 1513
718e3744 1514/* "bgp bestpath as-path ignore" configuration. */
1515DEFUN (bgp_bestpath_aspath_ignore,
1516 bgp_bestpath_aspath_ignore_cmd,
1517 "bgp bestpath as-path ignore",
1518 "BGP specific commands\n"
1519 "Change the default bestpath selection\n"
1520 "AS-path attribute\n"
1521 "Ignore as-path length in selecting a route\n")
1522{
1523 struct bgp *bgp;
1524
1525 bgp = vty->index;
1526 bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE);
1527 return CMD_SUCCESS;
1528}
1529
1530DEFUN (no_bgp_bestpath_aspath_ignore,
1531 no_bgp_bestpath_aspath_ignore_cmd,
1532 "no bgp bestpath as-path ignore",
1533 NO_STR
1534 "BGP specific commands\n"
1535 "Change the default bestpath selection\n"
1536 "AS-path attribute\n"
1537 "Ignore as-path length in selecting a route\n")
1538{
1539 struct bgp *bgp;
1540
1541 bgp = vty->index;
1542 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE);
1543 return CMD_SUCCESS;
1544}
6b0655a2 1545
6811845b 1546/* "bgp bestpath as-path confed" configuration. */
1547DEFUN (bgp_bestpath_aspath_confed,
1548 bgp_bestpath_aspath_confed_cmd,
1549 "bgp bestpath as-path confed",
1550 "BGP specific commands\n"
1551 "Change the default bestpath selection\n"
1552 "AS-path attribute\n"
1553 "Compare path lengths including confederation sets & sequences in selecting a route\n")
1554{
1555 struct bgp *bgp;
1556
1557 bgp = vty->index;
1558 bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED);
1559 return CMD_SUCCESS;
1560}
1561
1562DEFUN (no_bgp_bestpath_aspath_confed,
1563 no_bgp_bestpath_aspath_confed_cmd,
1564 "no bgp bestpath as-path confed",
1565 NO_STR
1566 "BGP specific commands\n"
1567 "Change the default bestpath selection\n"
1568 "AS-path attribute\n"
1569 "Compare path lengths including confederation sets & sequences in selecting a route\n")
1570{
1571 struct bgp *bgp;
1572
1573 bgp = vty->index;
1574 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED);
1575 return CMD_SUCCESS;
1576}
6b0655a2 1577
2fdd455c
PM
1578/* "bgp bestpath as-path multipath-relax" configuration. */
1579DEFUN (bgp_bestpath_aspath_multipath_relax,
1580 bgp_bestpath_aspath_multipath_relax_cmd,
1581 "bgp bestpath as-path multipath-relax",
1582 "BGP specific commands\n"
1583 "Change the default bestpath selection\n"
1584 "AS-path attribute\n"
1585 "Allow load sharing across routes that have different AS paths (but same length)\n")
1586{
1587 struct bgp *bgp;
1588
1589 bgp = vty->index;
1590 bgp_flag_set (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
1591 return CMD_SUCCESS;
1592}
1593
1594DEFUN (no_bgp_bestpath_aspath_multipath_relax,
1595 no_bgp_bestpath_aspath_multipath_relax_cmd,
1596 "no bgp bestpath as-path multipath-relax",
1597 NO_STR
1598 "BGP specific commands\n"
1599 "Change the default bestpath selection\n"
1600 "AS-path attribute\n"
1601 "Allow load sharing across routes that have different AS paths (but same length)\n")
1602{
1603 struct bgp *bgp;
1604
1605 bgp = vty->index;
1606 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
1607 return CMD_SUCCESS;
1608}
6b0655a2 1609
848973c7 1610/* "bgp log-neighbor-changes" configuration. */
1611DEFUN (bgp_log_neighbor_changes,
1612 bgp_log_neighbor_changes_cmd,
1613 "bgp log-neighbor-changes",
1614 "BGP specific commands\n"
1615 "Log neighbor up/down and reset reason\n")
1616{
1617 struct bgp *bgp;
1618
1619 bgp = vty->index;
1620 bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
1621 return CMD_SUCCESS;
1622}
1623
1624DEFUN (no_bgp_log_neighbor_changes,
1625 no_bgp_log_neighbor_changes_cmd,
1626 "no bgp log-neighbor-changes",
1627 NO_STR
1628 "BGP specific commands\n"
1629 "Log neighbor up/down and reset reason\n")
1630{
1631 struct bgp *bgp;
1632
1633 bgp = vty->index;
1634 bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
1635 return CMD_SUCCESS;
1636}
6b0655a2 1637
718e3744 1638/* "bgp bestpath med" configuration. */
1639DEFUN (bgp_bestpath_med,
1640 bgp_bestpath_med_cmd,
1641 "bgp bestpath med (confed|missing-as-worst)",
1642 "BGP specific commands\n"
1643 "Change the default bestpath selection\n"
1644 "MED attribute\n"
1645 "Compare MED among confederation paths\n"
1646 "Treat missing MED as the least preferred one\n")
1647{
1648 struct bgp *bgp;
1649
1650 bgp = vty->index;
1651
1652 if (strncmp (argv[0], "confed", 1) == 0)
1653 bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
1654 else
1655 bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1656
1657 return CMD_SUCCESS;
1658}
1659
1660DEFUN (bgp_bestpath_med2,
1661 bgp_bestpath_med2_cmd,
1662 "bgp bestpath med confed missing-as-worst",
1663 "BGP specific commands\n"
1664 "Change the default bestpath selection\n"
1665 "MED attribute\n"
1666 "Compare MED among confederation paths\n"
1667 "Treat missing MED as the least preferred one\n")
1668{
1669 struct bgp *bgp;
1670
1671 bgp = vty->index;
1672 bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
1673 bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1674 return CMD_SUCCESS;
1675}
1676
1677ALIAS (bgp_bestpath_med2,
1678 bgp_bestpath_med3_cmd,
1679 "bgp bestpath med missing-as-worst confed",
1680 "BGP specific commands\n"
1681 "Change the default bestpath selection\n"
1682 "MED attribute\n"
1683 "Treat missing MED as the least preferred one\n"
1684 "Compare MED among confederation paths\n")
1685
1686DEFUN (no_bgp_bestpath_med,
1687 no_bgp_bestpath_med_cmd,
1688 "no bgp bestpath med (confed|missing-as-worst)",
1689 NO_STR
1690 "BGP specific commands\n"
1691 "Change the default bestpath selection\n"
1692 "MED attribute\n"
1693 "Compare MED among confederation paths\n"
1694 "Treat missing MED as the least preferred one\n")
1695{
1696 struct bgp *bgp;
1697
1698 bgp = vty->index;
1699
1700 if (strncmp (argv[0], "confed", 1) == 0)
1701 bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
1702 else
1703 bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1704
1705 return CMD_SUCCESS;
1706}
1707
1708DEFUN (no_bgp_bestpath_med2,
1709 no_bgp_bestpath_med2_cmd,
1710 "no bgp bestpath med confed missing-as-worst",
1711 NO_STR
1712 "BGP specific commands\n"
1713 "Change the default bestpath selection\n"
1714 "MED attribute\n"
1715 "Compare MED among confederation paths\n"
1716 "Treat missing MED as the least preferred one\n")
1717{
1718 struct bgp *bgp;
1719
1720 bgp = vty->index;
1721 bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
1722 bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1723 return CMD_SUCCESS;
1724}
1725
1726ALIAS (no_bgp_bestpath_med2,
1727 no_bgp_bestpath_med3_cmd,
1728 "no bgp bestpath med missing-as-worst confed",
1729 NO_STR
1730 "BGP specific commands\n"
1731 "Change the default bestpath selection\n"
1732 "MED attribute\n"
1733 "Treat missing MED as the least preferred one\n"
1734 "Compare MED among confederation paths\n")
6b0655a2 1735
718e3744 1736/* "no bgp default ipv4-unicast". */
1737DEFUN (no_bgp_default_ipv4_unicast,
1738 no_bgp_default_ipv4_unicast_cmd,
1739 "no bgp default ipv4-unicast",
1740 NO_STR
1741 "BGP specific commands\n"
1742 "Configure BGP defaults\n"
1743 "Activate ipv4-unicast for a peer by default\n")
1744{
1745 struct bgp *bgp;
1746
1747 bgp = vty->index;
1748 bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
1749 return CMD_SUCCESS;
1750}
1751
1752DEFUN (bgp_default_ipv4_unicast,
1753 bgp_default_ipv4_unicast_cmd,
1754 "bgp default ipv4-unicast",
1755 "BGP specific commands\n"
1756 "Configure BGP defaults\n"
1757 "Activate ipv4-unicast for a peer by default\n")
1758{
1759 struct bgp *bgp;
1760
1761 bgp = vty->index;
1762 bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
1763 return CMD_SUCCESS;
1764}
6b0655a2 1765
718e3744 1766/* "bgp import-check" configuration. */
1767DEFUN (bgp_network_import_check,
1768 bgp_network_import_check_cmd,
1769 "bgp network import-check",
1770 "BGP specific commands\n"
1771 "BGP network command\n"
1772 "Check BGP network route exists in IGP\n")
1773{
1774 struct bgp *bgp;
1775
1776 bgp = vty->index;
1777 bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK);
1778 return CMD_SUCCESS;
1779}
1780
1781DEFUN (no_bgp_network_import_check,
1782 no_bgp_network_import_check_cmd,
1783 "no bgp network import-check",
1784 NO_STR
1785 "BGP specific commands\n"
1786 "BGP network command\n"
1787 "Check BGP network route exists in IGP\n")
1788{
1789 struct bgp *bgp;
1790
1791 bgp = vty->index;
1792 bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK);
1793 return CMD_SUCCESS;
1794}
6b0655a2 1795
718e3744 1796DEFUN (bgp_default_local_preference,
1797 bgp_default_local_preference_cmd,
1798 "bgp default local-preference <0-4294967295>",
1799 "BGP specific commands\n"
1800 "Configure BGP defaults\n"
1801 "local preference (higher=more preferred)\n"
1802 "Configure default local preference value\n")
1803{
1804 struct bgp *bgp;
1805 u_int32_t local_pref;
1806
1807 bgp = vty->index;
1808
1809 VTY_GET_INTEGER ("local preference", local_pref, argv[0]);
1810
1811 bgp_default_local_preference_set (bgp, local_pref);
1812
1813 return CMD_SUCCESS;
1814}
1815
1816DEFUN (no_bgp_default_local_preference,
1817 no_bgp_default_local_preference_cmd,
1818 "no bgp default local-preference",
1819 NO_STR
1820 "BGP specific commands\n"
1821 "Configure BGP defaults\n"
1822 "local preference (higher=more preferred)\n")
1823{
1824 struct bgp *bgp;
1825
1826 bgp = vty->index;
1827 bgp_default_local_preference_unset (bgp);
1828 return CMD_SUCCESS;
1829}
1830
1831ALIAS (no_bgp_default_local_preference,
1832 no_bgp_default_local_preference_val_cmd,
1833 "no bgp default local-preference <0-4294967295>",
1834 NO_STR
1835 "BGP specific commands\n"
1836 "Configure BGP defaults\n"
1837 "local preference (higher=more preferred)\n"
1838 "Configure default local preference value\n")
6b0655a2 1839
3f9c7369
DS
1840DEFUN (bgp_default_subgroup_pkt_queue_max,
1841 bgp_default_subgroup_pkt_queue_max_cmd,
1842 "bgp default subgroup-pkt-queue-max <20-100>",
1843 "BGP specific commands\n"
1844 "Configure BGP defaults\n"
1845 "subgroup-pkt-queue-max\n"
1846 "Configure subgroup packet queue max\n")
8bd9d948 1847{
3f9c7369
DS
1848 struct bgp *bgp;
1849 u_int32_t max_size;
8bd9d948 1850
3f9c7369
DS
1851 bgp = vty->index;
1852
1853 VTY_GET_INTEGER ("subgroup packet queue max", max_size, argv[0]);
1854
1855 bgp_default_subgroup_pkt_queue_max_set (bgp, max_size);
1856
1857 return CMD_SUCCESS;
1858}
1859
1860DEFUN (no_bgp_default_subgroup_pkt_queue_max,
1861 no_bgp_default_subgroup_pkt_queue_max_cmd,
1862 "no bgp default subgroup-pkt-queue-max",
1863 NO_STR
1864 "BGP specific commands\n"
1865 "Configure BGP defaults\n"
1866 "subgroup-pkt-queue-max\n")
1867{
1868 struct bgp *bgp;
1869
1870 bgp = vty->index;
1871 bgp_default_subgroup_pkt_queue_max_unset (bgp);
1872 return CMD_SUCCESS;
8bd9d948
DS
1873}
1874
1875DEFUN (bgp_rr_allow_outbound_policy,
1876 bgp_rr_allow_outbound_policy_cmd,
1877 "bgp route-reflector allow-outbound-policy",
1878 "BGP specific commands\n"
1879 "Allow modifications made by out route-map\n"
1880 "on ibgp neighbors\n")
1881{
1882 struct bgp *bgp;
1883 u_int32_t local_pref;
1884 int ret;
1885
1886 bgp = vty->index;
1887
1888 if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY))
1889 {
1890 bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
3f9c7369 1891 update_group_announce_rrclients(bgp);
8bd9d948
DS
1892 }
1893
1894 return CMD_SUCCESS;
1895}
1896
1897DEFUN (no_bgp_rr_allow_outbound_policy,
1898 no_bgp_rr_allow_outbound_policy_cmd,
1899 "no bgp route-reflector allow-outbound-policy",
1900 NO_STR
1901 "BGP specific commands\n"
1902 "Allow modifications made by out route-map\n"
1903 "on ibgp neighbors\n")
1904{
1905 struct bgp *bgp;
1906 u_int32_t local_pref;
1907
1908 bgp = vty->index;
1909
1910 if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY))
1911 {
1912 bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
3f9c7369 1913 update_group_announce_rrclients(bgp);
8bd9d948
DS
1914 }
1915
1916 return CMD_SUCCESS;
1917}
1918
f14e6fdb
DS
1919DEFUN (bgp_listen_limit,
1920 bgp_listen_limit_cmd,
1921 "bgp listen limit " DYNAMIC_NEIGHBOR_LIMIT_RANGE,
1922 "BGP specific commands\n"
1923 "Configure BGP defaults\n"
1924 "maximum number of BGP Dynamic Neighbors that can be created\n"
1925 "Configure Dynamic Neighbors listen limit value\n")
1926{
1927 struct bgp *bgp;
1928 int listen_limit;
1929
1930 bgp = vty->index;
1931
1932 VTY_GET_INTEGER_RANGE ("listen limit", listen_limit, argv[0],
1933 BGP_DYNAMIC_NEIGHBORS_LIMIT_MIN,
1934 BGP_DYNAMIC_NEIGHBORS_LIMIT_MAX);
1935
1936 bgp_listen_limit_set (bgp, listen_limit);
1937
1938 return CMD_SUCCESS;
1939}
1940
1941DEFUN (no_bgp_listen_limit,
1942 no_bgp_listen_limit_cmd,
1943 "no bgp listen limit",
1944 "BGP specific commands\n"
1945 "Configure BGP defaults\n"
1946 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
1947 "Configure Dynamic Neighbors listen limit value to default\n")
1948{
1949 struct bgp *bgp;
1950
1951 bgp = vty->index;
1952 bgp_listen_limit_unset (bgp);
1953 return CMD_SUCCESS;
1954}
1955
1956
1957DEFUN (bgp_listen_range,
1958 bgp_listen_range_cmd,
1959 LISTEN_RANGE_CMD "peer-group WORD" ,
1960 "BGP specific commands\n"
1961 "Configure BGP Dynamic Neighbors\n"
1962 "add a listening range for Dynamic Neighbors\n"
1963 LISTEN_RANGE_ADDR_STR)
1964{
1965 struct bgp *bgp;
1966 struct prefix range;
1967 struct peer_group *group;
1968 afi_t afi;
1969 int ret;
1970
1971 bgp = vty->index;
1972
1973 //VTY_GET_IPV4_PREFIX ("listen range", range, argv[0]);
1974
1975 /* Convert IP prefix string to struct prefix. */
1976 ret = str2prefix (argv[0], &range);
1977 if (! ret)
1978 {
1979 vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE);
1980 return CMD_WARNING;
1981 }
1982
1983 afi = family2afi(range.family);
1984
1985#ifdef HAVE_IPV6
1986 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6))
1987 {
1988 vty_out (vty, "%% Malformed listen range (link-local address)%s",
1989 VTY_NEWLINE);
1990 return CMD_WARNING;
1991 }
1992#endif /* HAVE_IPV6 */
1993
1994 apply_mask (&range);
1995
1996
1997 group = peer_group_lookup (bgp, argv[1]);
1998 if (! group)
1999 {
2000 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
2001 return CMD_WARNING;
2002 }
2003
2004 ret = peer_group_listen_range_add(group, &range);
2005 return bgp_vty_return (vty, ret);
2006}
2007
2008DEFUN (no_bgp_listen_range,
2009 no_bgp_listen_range_cmd,
2010 "no bgp listen range A.B.C.D/M peer-group WORD" ,
2011 "BGP specific commands\n"
2012 "Configure BGP defaults\n"
2013 "delete a listening range for Dynamic Neighbors\n"
2014 "Remove Dynamic Neighbors listening range\n")
2015{
2016 struct bgp *bgp;
2017 struct prefix range;
2018 struct peer_group *group;
2019 afi_t afi;
2020 int ret;
2021
2022 bgp = vty->index;
2023
2024 // VTY_GET_IPV4_PREFIX ("listen range", range, argv[0]);
2025
2026 /* Convert IP prefix string to struct prefix. */
2027 ret = str2prefix (argv[0], &range);
2028 if (! ret)
2029 {
2030 vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE);
2031 return CMD_WARNING;
2032 }
2033
2034 afi = family2afi(range.family);
2035
2036#ifdef HAVE_IPV6
2037 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6))
2038 {
2039 vty_out (vty, "%% Malformed listen range (link-local address)%s",
2040 VTY_NEWLINE);
2041 return CMD_WARNING;
2042 }
2043#endif /* HAVE_IPV6 */
2044
2045 apply_mask (&range);
2046
2047
2048 group = peer_group_lookup (bgp, argv[1]);
2049 if (! group)
2050 {
2051 vty_out (vty, "%% Peer-group does not exist%s", VTY_NEWLINE);
2052 return CMD_WARNING;
2053 }
2054
2055 ret = peer_group_listen_range_del(group, &range);
2056 return bgp_vty_return (vty, ret);
2057}
2058
2059int
2060bgp_config_write_listen (struct vty *vty, struct bgp *bgp)
2061{
2062 struct peer_group *group;
2063 struct listnode *node, *nnode, *rnode, *nrnode;
2064 struct prefix *range;
2065 afi_t afi;
2066 char buf[128];
2067
2068 if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT)
2069 vty_out (vty, " bgp listen limit %d%s",
2070 bgp->dynamic_neighbors_limit, VTY_NEWLINE);
2071
2072 for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
2073 {
2074 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2075 {
2076 for (ALL_LIST_ELEMENTS (group->listen_range[afi], rnode, nrnode, range))
2077 {
2078 prefix2str(range, buf, sizeof(buf));
2079 vty_out(vty, " bgp listen range %s peer-group %s%s",
2080 buf, group->name, VTY_NEWLINE);
2081 }
2082 }
2083 }
2084
2085 return 0;
2086}
2087
2088
718e3744 2089static int
fd79ac91 2090peer_remote_as_vty (struct vty *vty, const char *peer_str,
2091 const char *as_str, afi_t afi, safi_t safi)
718e3744 2092{
2093 int ret;
2094 struct bgp *bgp;
2095 as_t as;
2096 union sockunion su;
2097
2098 bgp = vty->index;
2099
2100 /* Get AS number. */
0b2aa3a0 2101 VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX);
718e3744 2102
2103 /* If peer is peer group, call proper function. */
2104 ret = str2sockunion (peer_str, &su);
2105 if (ret < 0)
2106 {
a80beece
DS
2107 /* Check for peer by interface */
2108 ret = peer_remote_as (bgp, NULL, peer_str, &as, afi, safi);
718e3744 2109 if (ret < 0)
a80beece
DS
2110 {
2111 ret = peer_group_remote_as (bgp, peer_str, &as);
2112 if (ret < 0)
2113 {
2114 vty_out (vty, "%% Create the peer-group or interface first%s",
2115 VTY_NEWLINE);
2116 return CMD_WARNING;
2117 }
2118 return CMD_SUCCESS;
2119 }
718e3744 2120 }
a80beece 2121 else
718e3744 2122 {
a80beece
DS
2123 if (peer_address_self_check (&su))
2124 {
2125 vty_out (vty, "%% Can not configure the local system as neighbor%s",
2126 VTY_NEWLINE);
2127 return CMD_WARNING;
2128 }
2129 ret = peer_remote_as (bgp, &su, NULL, &as, afi, safi);
718e3744 2130 }
2131
718e3744 2132 /* This peer belongs to peer group. */
2133 switch (ret)
2134 {
2135 case BGP_ERR_PEER_GROUP_MEMBER:
aea339f7 2136 vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTY_NEWLINE);
718e3744 2137 return CMD_WARNING;
718e3744 2138 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT:
aea339f7 2139 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 2140 return CMD_WARNING;
718e3744 2141 }
2142 return bgp_vty_return (vty, ret);
2143}
2144
2145DEFUN (neighbor_remote_as,
2146 neighbor_remote_as_cmd,
320da874 2147 NEIGHBOR_CMD2 "remote-as " CMD_AS_RANGE,
718e3744 2148 NEIGHBOR_STR
2149 NEIGHBOR_ADDR_STR2
2150 "Specify a BGP neighbor\n"
2151 AS_STR)
2152{
2153 return peer_remote_as_vty (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST);
2154}
6b0655a2 2155
a80beece
DS
2156DEFUN (neighbor_interface_config,
2157 neighbor_interface_config_cmd,
2158 "neighbor WORD interface",
2159 NEIGHBOR_STR
2160 "Interface name or neighbor tag\n"
2161 "Enable BGP on interface\n")
2162{
2163 struct bgp *bgp;
2164 struct peer *peer;
2165 struct peer_group *group;
2166
2167 bgp = vty->index;
2168 group = peer_group_lookup (bgp, argv[0]);
2169 if (group)
2170 {
2171 vty_out (vty, "%% Name conflict with peer-group %s", VTY_NEWLINE);
2172 return CMD_WARNING;
2173 }
2174
2175 peer = peer_conf_interface_get (bgp, argv[0], AFI_IP, SAFI_UNICAST);
2176 if (!peer)
2177 return CMD_WARNING;
2178
2179 return CMD_SUCCESS;
2180}
2181
2182
718e3744 2183DEFUN (neighbor_peer_group,
2184 neighbor_peer_group_cmd,
2185 "neighbor WORD peer-group",
2186 NEIGHBOR_STR
a80beece 2187 "Interface name or neighbor tag\n"
718e3744 2188 "Configure peer-group\n")
2189{
2190 struct bgp *bgp;
a80beece 2191 struct peer *peer;
718e3744 2192 struct peer_group *group;
2193
2194 bgp = vty->index;
a80beece
DS
2195 peer = peer_lookup_by_conf_if (bgp, argv[0]);
2196 if (peer)
2197 {
2198 vty_out (vty, "%% Name conflict with interface: %s", VTY_NEWLINE);
2199 return CMD_WARNING;
2200 }
718e3744 2201
2202 group = peer_group_get (bgp, argv[0]);
2203 if (! group)
2204 return CMD_WARNING;
2205
2206 return CMD_SUCCESS;
2207}
2208
2209DEFUN (no_neighbor,
2210 no_neighbor_cmd,
2211 NO_NEIGHBOR_CMD2,
2212 NO_STR
2213 NEIGHBOR_STR
2214 NEIGHBOR_ADDR_STR2)
2215{
2216 int ret;
2217 union sockunion su;
2218 struct peer_group *group;
2219 struct peer *peer;
1ff9a340 2220 struct peer *other;
718e3744 2221
2222 ret = str2sockunion (argv[0], &su);
2223 if (ret < 0)
2224 {
a80beece
DS
2225 /* look up for neighbor by interface name config. */
2226 peer = peer_lookup_by_conf_if (vty->index, argv[0]);
2227 if (peer)
2228 {
2229 peer_delete (peer);
2230 return CMD_SUCCESS;
2231 }
2232
718e3744 2233 group = peer_group_lookup (vty->index, argv[0]);
2234 if (group)
2235 peer_group_delete (group);
2236 else
2237 {
2238 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
2239 return CMD_WARNING;
2240 }
2241 }
2242 else
2243 {
2244 peer = peer_lookup (vty->index, &su);
2245 if (peer)
1ff9a340 2246 {
f14e6fdb
DS
2247 if (peer_dynamic_neighbor (peer))
2248 {
2249 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
2250 VTY_NEWLINE);
2251 return CMD_WARNING;
2252 }
2253
1ff9a340
DS
2254 other = peer->doppelganger;
2255 peer_delete (peer);
2256 if (other && other->status != Deleted)
2257 peer_delete(other);
2258 }
718e3744 2259 }
2260
2261 return CMD_SUCCESS;
2262}
2263
2264ALIAS (no_neighbor,
2265 no_neighbor_remote_as_cmd,
320da874 2266 NO_NEIGHBOR_CMD "remote-as " CMD_AS_RANGE,
718e3744 2267 NO_STR
2268 NEIGHBOR_STR
2269 NEIGHBOR_ADDR_STR
2270 "Specify a BGP neighbor\n"
2271 AS_STR)
2272
a80beece
DS
2273DEFUN (no_neighbor_interface_config,
2274 no_neighbor_interface_config_cmd,
2275 "no neighbor WORD interface",
2276 NO_STR
2277 NEIGHBOR_STR
2278 "Interface name\n"
2279 "Configure BGP on interface\n")
2280{
2281 struct peer *peer;
2282
2283 /* look up for neighbor by interface name config. */
2284 peer = peer_lookup_by_conf_if (vty->index, argv[0]);
2285 if (peer)
2286 {
2287 peer_delete (peer);
2288 }
2289 else
2290 {
2291 vty_out (vty, "%% Create the bgp interface first%s", VTY_NEWLINE);
2292 return CMD_WARNING;
2293 }
2294 return CMD_SUCCESS;
2295}
2296
718e3744 2297DEFUN (no_neighbor_peer_group,
2298 no_neighbor_peer_group_cmd,
2299 "no neighbor WORD peer-group",
2300 NO_STR
2301 NEIGHBOR_STR
2302 "Neighbor tag\n"
2303 "Configure peer-group\n")
2304{
2305 struct peer_group *group;
2306
2307 group = peer_group_lookup (vty->index, argv[0]);
2308 if (group)
2309 peer_group_delete (group);
2310 else
2311 {
2312 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
2313 return CMD_WARNING;
2314 }
2315 return CMD_SUCCESS;
2316}
2317
a80beece
DS
2318DEFUN (no_neighbor_interface_peer_group_remote_as,
2319 no_neighbor_interface_peer_group_remote_as_cmd,
320da874 2320 "no neighbor WORD remote-as " CMD_AS_RANGE,
718e3744 2321 NO_STR
2322 NEIGHBOR_STR
a80beece 2323 "Interface name or neighbor tag\n"
718e3744 2324 "Specify a BGP neighbor\n"
2325 AS_STR)
2326{
2327 struct peer_group *group;
a80beece
DS
2328 struct peer *peer;
2329
2330 /* look up for neighbor by interface name config. */
2331 peer = peer_lookup_by_conf_if (vty->index, argv[0]);
2332 if (peer)
2333 {
2334 peer_as_change (peer, 0);
2335 return CMD_SUCCESS;
2336 }
718e3744 2337
2338 group = peer_group_lookup (vty->index, argv[0]);
2339 if (group)
2340 peer_group_remote_as_delete (group);
2341 else
2342 {
a80beece 2343 vty_out (vty, "%% Create the peer-group or interface first%s", VTY_NEWLINE);
718e3744 2344 return CMD_WARNING;
2345 }
2346 return CMD_SUCCESS;
2347}
6b0655a2 2348
718e3744 2349DEFUN (neighbor_local_as,
2350 neighbor_local_as_cmd,
320da874 2351 NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
718e3744 2352 NEIGHBOR_STR
2353 NEIGHBOR_ADDR_STR2
2354 "Specify a local-as number\n"
2355 "AS number used as local AS\n")
2356{
2357 struct peer *peer;
2358 int ret;
2359
2360 peer = peer_and_group_lookup_vty (vty, argv[0]);
2361 if (! peer)
2362 return CMD_WARNING;
2363
9d3f9705 2364 ret = peer_local_as_set (peer, atoi (argv[1]), 0, 0);
718e3744 2365 return bgp_vty_return (vty, ret);
2366}
2367
2368DEFUN (neighbor_local_as_no_prepend,
2369 neighbor_local_as_no_prepend_cmd,
320da874 2370 NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
718e3744 2371 NEIGHBOR_STR
2372 NEIGHBOR_ADDR_STR2
2373 "Specify a local-as number\n"
2374 "AS number used as local AS\n"
2375 "Do not prepend local-as to updates from ebgp peers\n")
2376{
2377 struct peer *peer;
2378 int ret;
2379
2380 peer = peer_and_group_lookup_vty (vty, argv[0]);
2381 if (! peer)
2382 return CMD_WARNING;
2383
9d3f9705 2384 ret = peer_local_as_set (peer, atoi (argv[1]), 1, 0);
718e3744 2385 return bgp_vty_return (vty, ret);
2386}
2387
9d3f9705
AC
2388DEFUN (neighbor_local_as_no_prepend_replace_as,
2389 neighbor_local_as_no_prepend_replace_as_cmd,
2390 NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend replace-as",
2391 NEIGHBOR_STR
2392 NEIGHBOR_ADDR_STR2
2393 "Specify a local-as number\n"
2394 "AS number used as local AS\n"
2395 "Do not prepend local-as to updates from ebgp peers\n"
2396 "Do not prepend local-as to updates from ibgp peers\n")
2397{
2398 struct peer *peer;
2399 int ret;
2400
2401 peer = peer_and_group_lookup_vty (vty, argv[0]);
2402 if (! peer)
2403 return CMD_WARNING;
2404
2405 ret = peer_local_as_set (peer, atoi (argv[1]), 1, 1);
2406 return bgp_vty_return (vty, ret);
2407}
2408
2409
718e3744 2410DEFUN (no_neighbor_local_as,
2411 no_neighbor_local_as_cmd,
2412 NO_NEIGHBOR_CMD2 "local-as",
2413 NO_STR
2414 NEIGHBOR_STR
2415 NEIGHBOR_ADDR_STR2
2416 "Specify a local-as number\n")
2417{
2418 struct peer *peer;
2419 int ret;
2420
2421 peer = peer_and_group_lookup_vty (vty, argv[0]);
2422 if (! peer)
2423 return CMD_WARNING;
2424
2425 ret = peer_local_as_unset (peer);
2426 return bgp_vty_return (vty, ret);
2427}
2428
2429ALIAS (no_neighbor_local_as,
2430 no_neighbor_local_as_val_cmd,
320da874 2431 NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
718e3744 2432 NO_STR
2433 NEIGHBOR_STR
2434 NEIGHBOR_ADDR_STR2
2435 "Specify a local-as number\n"
2436 "AS number used as local AS\n")
2437
2438ALIAS (no_neighbor_local_as,
2439 no_neighbor_local_as_val2_cmd,
320da874 2440 NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
718e3744 2441 NO_STR
2442 NEIGHBOR_STR
2443 NEIGHBOR_ADDR_STR2
2444 "Specify a local-as number\n"
2445 "AS number used as local AS\n"
2446 "Do not prepend local-as to updates from ebgp peers\n")
9d3f9705
AC
2447
2448ALIAS (no_neighbor_local_as,
2449 no_neighbor_local_as_val3_cmd,
2450 NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend replace-as",
2451 NO_STR
2452 NEIGHBOR_STR
2453 NEIGHBOR_ADDR_STR2
2454 "Specify a local-as number\n"
2455 "AS number used as local AS\n"
2456 "Do not prepend local-as to updates from ebgp peers\n"
2457 "Do not prepend local-as to updates from ibgp peers\n")
6b0655a2 2458
3f9c7369
DS
2459DEFUN (neighbor_solo,
2460 neighbor_solo_cmd,
2461 NEIGHBOR_CMD2 "solo",
2462 NEIGHBOR_STR
2463 NEIGHBOR_ADDR_STR2
2464 "Solo peer - part of its own update group\n")
2465{
2466 struct peer *peer;
2467 int ret;
2468
2469 peer = peer_and_group_lookup_vty (vty, argv[0]);
2470 if (! peer)
2471 return CMD_WARNING;
2472
2473 ret = update_group_adjust_soloness(peer, 1);
2474 return bgp_vty_return (vty, ret);
2475}
2476
2477DEFUN (no_neighbor_solo,
2478 no_neighbor_solo_cmd,
2479 NO_NEIGHBOR_CMD2 "solo",
2480 NO_STR
2481 NEIGHBOR_STR
2482 NEIGHBOR_ADDR_STR2
2483 "Solo peer - part of its own update group\n")
2484{
2485 struct peer *peer;
2486 int ret;
2487
2488 peer = peer_and_group_lookup_vty (vty, argv[0]);
2489 if (! peer)
2490 return CMD_WARNING;
2491
2492 ret = update_group_adjust_soloness(peer, 0);
2493 return bgp_vty_return (vty, ret);
2494}
2495
0df7c91f
PJ
2496DEFUN (neighbor_password,
2497 neighbor_password_cmd,
2498 NEIGHBOR_CMD2 "password LINE",
2499 NEIGHBOR_STR
2500 NEIGHBOR_ADDR_STR2
2501 "Set a password\n"
2502 "The password\n")
2503{
2504 struct peer *peer;
2505 int ret;
2506
2507 peer = peer_and_group_lookup_vty (vty, argv[0]);
2508 if (! peer)
2509 return CMD_WARNING;
2510
2511 ret = peer_password_set (peer, argv[1]);
2512 return bgp_vty_return (vty, ret);
2513}
2514
2515DEFUN (no_neighbor_password,
2516 no_neighbor_password_cmd,
2517 NO_NEIGHBOR_CMD2 "password",
2518 NO_STR
2519 NEIGHBOR_STR
2520 NEIGHBOR_ADDR_STR2
2521 "Set a password\n")
2522{
2523 struct peer *peer;
2524 int ret;
2525
2526 peer = peer_and_group_lookup_vty (vty, argv[0]);
2527 if (! peer)
2528 return CMD_WARNING;
2529
2530 ret = peer_password_unset (peer);
2531 return bgp_vty_return (vty, ret);
2532}
6b0655a2 2533
718e3744 2534DEFUN (neighbor_activate,
2535 neighbor_activate_cmd,
2536 NEIGHBOR_CMD2 "activate",
2537 NEIGHBOR_STR
2538 NEIGHBOR_ADDR_STR2
2539 "Enable the Address Family for this Neighbor\n")
2540{
2541 struct peer *peer;
2542
2543 peer = peer_and_group_lookup_vty (vty, argv[0]);
2544 if (! peer)
2545 return CMD_WARNING;
2546
2547 peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
2548
2549 return CMD_SUCCESS;
2550}
2551
2552DEFUN (no_neighbor_activate,
2553 no_neighbor_activate_cmd,
2554 NO_NEIGHBOR_CMD2 "activate",
2555 NO_STR
2556 NEIGHBOR_STR
2557 NEIGHBOR_ADDR_STR2
2558 "Enable the Address Family for this Neighbor\n")
2559{
2560 int ret;
2561 struct peer *peer;
2562
2563 /* Lookup peer. */
2564 peer = peer_and_group_lookup_vty (vty, argv[0]);
2565 if (! peer)
2566 return CMD_WARNING;
2567
2568 ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
2569
2570 return bgp_vty_return (vty, ret);
2571}
6b0655a2 2572
718e3744 2573DEFUN (neighbor_set_peer_group,
2574 neighbor_set_peer_group_cmd,
a80beece 2575 NEIGHBOR_CMD2 "peer-group WORD",
718e3744 2576 NEIGHBOR_STR
a80beece 2577 NEIGHBOR_ADDR_STR2
718e3744 2578 "Member of the peer-group\n"
2579 "peer-group name\n")
2580{
2581 int ret;
2582 as_t as;
2583 union sockunion su;
2584 struct bgp *bgp;
a80beece 2585 struct peer *peer;
718e3744 2586 struct peer_group *group;
2587
2588 bgp = vty->index;
a80beece 2589 peer = NULL;
718e3744 2590
2591 ret = str2sockunion (argv[0], &su);
2592 if (ret < 0)
2593 {
a80beece
DS
2594 peer = peer_lookup_by_conf_if (bgp, argv[0]);
2595 if (!peer)
2596 {
2597 vty_out (vty, "%% Malformed address or name: %s%s", argv[0], VTY_NEWLINE);
2598 return CMD_WARNING;
2599 }
2600 }
2601 else
2602 {
2603 if (peer_address_self_check (&su))
2604 {
2605 vty_out (vty, "%% Can not configure the local system as neighbor%s",
2606 VTY_NEWLINE);
2607 return CMD_WARNING;
2608 }
f14e6fdb
DS
2609
2610 /* Disallow for dynamic neighbor. */
2611 peer = peer_lookup (bgp, &su);
2612 if (peer && peer_dynamic_neighbor (peer))
2613 {
2614 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
2615 VTY_NEWLINE);
2616 return CMD_WARNING;
2617 }
718e3744 2618 }
2619
2620 group = peer_group_lookup (bgp, argv[1]);
2621 if (! group)
2622 {
2623 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
2624 return CMD_WARNING;
2625 }
2626
a80beece 2627 ret = peer_group_bind (bgp, &su, peer, group, bgp_node_afi (vty),
718e3744 2628 bgp_node_safi (vty), &as);
2629
2630 if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT)
2631 {
aea339f7 2632 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 2633 return CMD_WARNING;
2634 }
2635
2636 return bgp_vty_return (vty, ret);
2637}
2638
2639DEFUN (no_neighbor_set_peer_group,
2640 no_neighbor_set_peer_group_cmd,
a80beece 2641 NO_NEIGHBOR_CMD2 "peer-group WORD",
718e3744 2642 NO_STR
2643 NEIGHBOR_STR
a80beece 2644 NEIGHBOR_ADDR_STR2
718e3744 2645 "Member of the peer-group\n"
2646 "peer-group name\n")
2647{
2648 int ret;
2649 struct bgp *bgp;
2650 struct peer *peer;
2651 struct peer_group *group;
2652
2653 bgp = vty->index;
2654
2655 peer = peer_lookup_vty (vty, argv[0]);
2656 if (! peer)
2657 return CMD_WARNING;
2658
2659 group = peer_group_lookup (bgp, argv[1]);
2660 if (! group)
2661 {
2662 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
2663 return CMD_WARNING;
2664 }
2665
2666 ret = peer_group_unbind (bgp, peer, group, bgp_node_afi (vty),
2667 bgp_node_safi (vty));
2668
2669 return bgp_vty_return (vty, ret);
2670}
6b0655a2 2671
94f2b392 2672static int
fd79ac91 2673peer_flag_modify_vty (struct vty *vty, const char *ip_str,
2674 u_int16_t flag, int set)
718e3744 2675{
2676 int ret;
2677 struct peer *peer;
2678
2679 peer = peer_and_group_lookup_vty (vty, ip_str);
2680 if (! peer)
2681 return CMD_WARNING;
2682
2683 if (set)
2684 ret = peer_flag_set (peer, flag);
2685 else
2686 ret = peer_flag_unset (peer, flag);
2687
2688 return bgp_vty_return (vty, ret);
2689}
2690
94f2b392 2691static int
fd79ac91 2692peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
718e3744 2693{
2694 return peer_flag_modify_vty (vty, ip_str, flag, 1);
2695}
2696
94f2b392 2697static int
fd79ac91 2698peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
718e3744 2699{
2700 return peer_flag_modify_vty (vty, ip_str, flag, 0);
2701}
2702
2703/* neighbor passive. */
2704DEFUN (neighbor_passive,
2705 neighbor_passive_cmd,
2706 NEIGHBOR_CMD2 "passive",
2707 NEIGHBOR_STR
2708 NEIGHBOR_ADDR_STR2
2709 "Don't send open messages to this neighbor\n")
2710{
2711 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_PASSIVE);
2712}
2713
2714DEFUN (no_neighbor_passive,
2715 no_neighbor_passive_cmd,
2716 NO_NEIGHBOR_CMD2 "passive",
2717 NO_STR
2718 NEIGHBOR_STR
2719 NEIGHBOR_ADDR_STR2
2720 "Don't send open messages to this neighbor\n")
2721{
2722 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_PASSIVE);
2723}
6b0655a2 2724
718e3744 2725/* neighbor shutdown. */
2726DEFUN (neighbor_shutdown,
2727 neighbor_shutdown_cmd,
2728 NEIGHBOR_CMD2 "shutdown",
2729 NEIGHBOR_STR
2730 NEIGHBOR_ADDR_STR2
2731 "Administratively shut down this neighbor\n")
2732{
2733 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
2734}
2735
2736DEFUN (no_neighbor_shutdown,
2737 no_neighbor_shutdown_cmd,
2738 NO_NEIGHBOR_CMD2 "shutdown",
2739 NO_STR
2740 NEIGHBOR_STR
2741 NEIGHBOR_ADDR_STR2
2742 "Administratively shut down this neighbor\n")
2743{
2744 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
2745}
6b0655a2 2746
d5a5c8f0
DS
2747/* neighbor bfd. */
2748DEFUN (neighbor_bfd,
2749 neighbor_bfd_cmd,
2750 NEIGHBOR_CMD2 "bfd",
2751 NEIGHBOR_STR
2752 NEIGHBOR_ADDR_STR2
2753 "Respond to BFD session event\n")
2754{
2755 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_BFD);
2756}
2757
2758DEFUN (no_neighbor_bfd,
2759 no_neighbor_bfd_cmd,
2760 NO_NEIGHBOR_CMD2 "bfd",
2761 NO_STR
2762 NEIGHBOR_STR
2763 NEIGHBOR_ADDR_STR2
2764 "Respond to BFD session event\n")
2765{
2766 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_BFD);
2767}
2768
c9502438 2769/* Deprecated neighbor capability route-refresh. */
2770DEFUN_DEPRECATED (neighbor_capability_route_refresh,
2771 neighbor_capability_route_refresh_cmd,
2772 NEIGHBOR_CMD2 "capability route-refresh",
2773 NEIGHBOR_STR
2774 NEIGHBOR_ADDR_STR2
2775 "Advertise capability to the peer\n"
2776 "Advertise route-refresh capability to this neighbor\n")
718e3744 2777{
c9502438 2778 return CMD_SUCCESS;
718e3744 2779}
2780
c9502438 2781DEFUN_DEPRECATED (no_neighbor_capability_route_refresh,
2782 no_neighbor_capability_route_refresh_cmd,
2783 NO_NEIGHBOR_CMD2 "capability route-refresh",
2784 NO_STR
2785 NEIGHBOR_STR
2786 NEIGHBOR_ADDR_STR2
2787 "Advertise capability to the peer\n"
2788 "Advertise route-refresh capability to this neighbor\n")
718e3744 2789{
c9502438 2790 return CMD_SUCCESS;
718e3744 2791}
6b0655a2 2792
718e3744 2793/* neighbor capability dynamic. */
2794DEFUN (neighbor_capability_dynamic,
2795 neighbor_capability_dynamic_cmd,
2796 NEIGHBOR_CMD2 "capability dynamic",
2797 NEIGHBOR_STR
2798 NEIGHBOR_ADDR_STR2
2799 "Advertise capability to the peer\n"
2800 "Advertise dynamic capability to this neighbor\n")
2801{
2802 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
2803}
2804
2805DEFUN (no_neighbor_capability_dynamic,
2806 no_neighbor_capability_dynamic_cmd,
2807 NO_NEIGHBOR_CMD2 "capability dynamic",
2808 NO_STR
2809 NEIGHBOR_STR
2810 NEIGHBOR_ADDR_STR2
2811 "Advertise capability to the peer\n"
2812 "Advertise dynamic capability to this neighbor\n")
2813{
2814 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
2815}
6b0655a2 2816
718e3744 2817/* neighbor dont-capability-negotiate */
2818DEFUN (neighbor_dont_capability_negotiate,
2819 neighbor_dont_capability_negotiate_cmd,
2820 NEIGHBOR_CMD2 "dont-capability-negotiate",
2821 NEIGHBOR_STR
2822 NEIGHBOR_ADDR_STR2
2823 "Do not perform capability negotiation\n")
2824{
2825 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
2826}
2827
2828DEFUN (no_neighbor_dont_capability_negotiate,
2829 no_neighbor_dont_capability_negotiate_cmd,
2830 NO_NEIGHBOR_CMD2 "dont-capability-negotiate",
2831 NO_STR
2832 NEIGHBOR_STR
2833 NEIGHBOR_ADDR_STR2
2834 "Do not perform capability negotiation\n")
2835{
2836 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
2837}
6b0655a2 2838
94f2b392 2839static int
fd79ac91 2840peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi,
fee0f4c6 2841 safi_t safi, u_int32_t flag, int set)
718e3744 2842{
2843 int ret;
2844 struct peer *peer;
2845
2846 peer = peer_and_group_lookup_vty (vty, peer_str);
2847 if (! peer)
2848 return CMD_WARNING;
2849
2850 if (set)
2851 ret = peer_af_flag_set (peer, afi, safi, flag);
2852 else
2853 ret = peer_af_flag_unset (peer, afi, safi, flag);
2854
2855 return bgp_vty_return (vty, ret);
2856}
2857
94f2b392 2858static int
fd79ac91 2859peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi,
fee0f4c6 2860 safi_t safi, u_int32_t flag)
718e3744 2861{
2862 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1);
2863}
2864
94f2b392 2865static int
fd79ac91 2866peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi,
fee0f4c6 2867 safi_t safi, u_int32_t flag)
718e3744 2868{
2869 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0);
2870}
6b0655a2 2871
718e3744 2872/* neighbor capability orf prefix-list. */
2873DEFUN (neighbor_capability_orf_prefix,
2874 neighbor_capability_orf_prefix_cmd,
2875 NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
2876 NEIGHBOR_STR
2877 NEIGHBOR_ADDR_STR2
2878 "Advertise capability to the peer\n"
2879 "Advertise ORF capability to the peer\n"
2880 "Advertise prefixlist ORF capability to this neighbor\n"
2881 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
2882 "Capability to RECEIVE the ORF from this neighbor\n"
2883 "Capability to SEND the ORF to this neighbor\n")
2884{
2885 u_int16_t flag = 0;
2886
2887 if (strncmp (argv[1], "s", 1) == 0)
2888 flag = PEER_FLAG_ORF_PREFIX_SM;
2889 else if (strncmp (argv[1], "r", 1) == 0)
2890 flag = PEER_FLAG_ORF_PREFIX_RM;
2891 else if (strncmp (argv[1], "b", 1) == 0)
2892 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
2893 else
2894 return CMD_WARNING;
2895
2896 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2897 bgp_node_safi (vty), flag);
2898}
2899
2900DEFUN (no_neighbor_capability_orf_prefix,
2901 no_neighbor_capability_orf_prefix_cmd,
2902 NO_NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
2903 NO_STR
2904 NEIGHBOR_STR
2905 NEIGHBOR_ADDR_STR2
2906 "Advertise capability to the peer\n"
2907 "Advertise ORF capability to the peer\n"
2908 "Advertise prefixlist ORF capability to this neighbor\n"
2909 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
2910 "Capability to RECEIVE the ORF from this neighbor\n"
2911 "Capability to SEND the ORF to this neighbor\n")
2912{
2913 u_int16_t flag = 0;
2914
2915 if (strncmp (argv[1], "s", 1) == 0)
2916 flag = PEER_FLAG_ORF_PREFIX_SM;
2917 else if (strncmp (argv[1], "r", 1) == 0)
2918 flag = PEER_FLAG_ORF_PREFIX_RM;
2919 else if (strncmp (argv[1], "b", 1) == 0)
2920 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
2921 else
2922 return CMD_WARNING;
2923
2924 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2925 bgp_node_safi (vty), flag);
2926}
6b0655a2 2927
718e3744 2928/* neighbor next-hop-self. */
2929DEFUN (neighbor_nexthop_self,
2930 neighbor_nexthop_self_cmd,
9e7a53c1 2931 NEIGHBOR_CMD2 "next-hop-self {all}",
718e3744 2932 NEIGHBOR_STR
2933 NEIGHBOR_ADDR_STR2
9e7a53c1
TT
2934 "Disable the next hop calculation for this neighbor\n"
2935 "Apply also to ibgp-learned routes when acting as a route reflector\n")
718e3744 2936{
9e7a53c1
TT
2937 u_int32_t flags = PEER_FLAG_NEXTHOP_SELF, unset = 0;
2938 int rc;
2939
2940 /* Check if "all" is specified */
2941 if (argv[1] != NULL)
2942 flags |= PEER_FLAG_NEXTHOP_SELF_ALL;
2943 else
2944 unset |= PEER_FLAG_NEXTHOP_SELF_ALL;
2945
2946 rc = peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2947 bgp_node_safi (vty), flags);
2948 if ( rc == CMD_SUCCESS && unset )
2949 rc = peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2950 bgp_node_safi (vty), unset);
2951 return rc;
718e3744 2952}
2953
2954DEFUN (no_neighbor_nexthop_self,
2955 no_neighbor_nexthop_self_cmd,
9e7a53c1 2956 NO_NEIGHBOR_CMD2 "next-hop-self {all}",
718e3744 2957 NO_STR
2958 NEIGHBOR_STR
2959 NEIGHBOR_ADDR_STR2
9e7a53c1
TT
2960 "Disable the next hop calculation for this neighbor\n"
2961 "Apply also to ibgp-learned routes when acting as a route reflector\n")
718e3744 2962{
2963 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
9e7a53c1
TT
2964 bgp_node_safi (vty),
2965 PEER_FLAG_NEXTHOP_SELF|PEER_FLAG_NEXTHOP_SELF_ALL);
718e3744 2966}
6b0655a2 2967
c7122e14
DS
2968/* neighbor as-override */
2969DEFUN (neighbor_as_override,
2970 neighbor_as_override_cmd,
2971 NEIGHBOR_CMD2 "as-override",
2972 NEIGHBOR_STR
2973 NEIGHBOR_ADDR_STR2
2974 "Override ASNs in outbound updates if aspath equals remote-as\n")
2975{
2976 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2977 bgp_node_safi (vty),
2978 PEER_FLAG_AS_OVERRIDE);
2979}
2980
2981DEFUN (no_neighbor_as_override,
2982 no_neighbor_as_override_cmd,
2983 NO_NEIGHBOR_CMD2 "as-override",
2984 NO_STR
2985 NEIGHBOR_STR
2986 NEIGHBOR_ADDR_STR2
2987 "Override ASNs in outbound updates if aspath equals remote-as\n")
2988{
2989 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2990 bgp_node_safi (vty),
2991 PEER_FLAG_AS_OVERRIDE);
2992}
2993
718e3744 2994/* neighbor remove-private-AS. */
2995DEFUN (neighbor_remove_private_as,
2996 neighbor_remove_private_as_cmd,
2997 NEIGHBOR_CMD2 "remove-private-AS",
2998 NEIGHBOR_STR
2999 NEIGHBOR_ADDR_STR2
5000f21c 3000 "Remove private ASNs in outbound updates\n")
718e3744 3001{
5000f21c
DS
3002 peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3003 bgp_node_safi (vty),
3004 PEER_FLAG_REMOVE_PRIVATE_AS_ALL|
3005 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE);
718e3744 3006 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3007 bgp_node_safi (vty),
3008 PEER_FLAG_REMOVE_PRIVATE_AS);
3009}
3010
5000f21c
DS
3011DEFUN (neighbor_remove_private_as_all,
3012 neighbor_remove_private_as_all_cmd,
3013 NEIGHBOR_CMD2 "remove-private-AS all",
3014 NEIGHBOR_STR
3015 NEIGHBOR_ADDR_STR2
3016 "Remove private ASNs in outbound updates\n"
3017 "Apply to all AS numbers")
3018{
3019 peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3020 bgp_node_safi (vty),
3021 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE);
3022 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3023 bgp_node_safi (vty),
3024 PEER_FLAG_REMOVE_PRIVATE_AS|
3025 PEER_FLAG_REMOVE_PRIVATE_AS_ALL);
3026}
3027
3028DEFUN (neighbor_remove_private_as_replace_as,
3029 neighbor_remove_private_as_replace_as_cmd,
3030 NEIGHBOR_CMD2 "remove-private-AS replace-AS",
3031 NEIGHBOR_STR
3032 NEIGHBOR_ADDR_STR2
3033 "Remove private ASNs in outbound updates\n"
3034 "Replace private ASNs with our ASN in outbound updates\n")
3035{
3036 peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3037 bgp_node_safi (vty),
3038 PEER_FLAG_REMOVE_PRIVATE_AS_ALL);
3039 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3040 bgp_node_safi (vty),
3041 PEER_FLAG_REMOVE_PRIVATE_AS|
3042 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE);
3043}
3044
3045DEFUN (neighbor_remove_private_as_all_replace_as,
3046 neighbor_remove_private_as_all_replace_as_cmd,
3047 NEIGHBOR_CMD2 "remove-private-AS all replace-AS",
3048 NEIGHBOR_STR
3049 NEIGHBOR_ADDR_STR2
3050 "Remove private ASNs in outbound updates\n"
3051 "Apply to all AS numbers"
3052 "Replace private ASNs with our ASN in outbound updates\n")
3053{
3054 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3055 bgp_node_safi (vty),
3056 PEER_FLAG_REMOVE_PRIVATE_AS|
3057 PEER_FLAG_REMOVE_PRIVATE_AS_ALL|
3058 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE);
3059}
3060
718e3744 3061DEFUN (no_neighbor_remove_private_as,
3062 no_neighbor_remove_private_as_cmd,
3063 NO_NEIGHBOR_CMD2 "remove-private-AS",
3064 NO_STR
3065 NEIGHBOR_STR
3066 NEIGHBOR_ADDR_STR2
5000f21c 3067 "Remove private ASNs in outbound updates\n")
718e3744 3068{
3069 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3070 bgp_node_safi (vty),
5000f21c
DS
3071 PEER_FLAG_REMOVE_PRIVATE_AS|
3072 PEER_FLAG_REMOVE_PRIVATE_AS_ALL|
3073 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE);
718e3744 3074}
6b0655a2 3075
5000f21c
DS
3076ALIAS (no_neighbor_remove_private_as,
3077 no_neighbor_remove_private_as_all_cmd,
3078 NO_NEIGHBOR_CMD2 "remove-private-AS all",
3079 NO_STR
3080 NEIGHBOR_STR
3081 NEIGHBOR_ADDR_STR2
3082 "Remove private ASNs in outbound updates\n"
3083 "Apply to all AS numbers")
3084
3085ALIAS (no_neighbor_remove_private_as,
3086 no_neighbor_remove_private_as_replace_as_cmd,
3087 NO_NEIGHBOR_CMD2 "remove-private-AS replace-AS",
3088 NO_STR
3089 NEIGHBOR_STR
3090 NEIGHBOR_ADDR_STR2
3091 "Remove private ASNs in outbound updates\n"
3092 "Replace private ASNs with our ASN in outbound updates\n")
3093
3094ALIAS (no_neighbor_remove_private_as,
3095 no_neighbor_remove_private_as_all_replace_as_cmd,
3096 NO_NEIGHBOR_CMD2 "remove-private-AS all replace-AS",
3097 NO_STR
3098 NEIGHBOR_STR
3099 NEIGHBOR_ADDR_STR2
3100 "Remove private ASNs in outbound updates\n"
3101 "Apply to all AS numbers"
3102 "Replace private ASNs with our ASN in outbound updates\n")
3103
3104
718e3744 3105/* neighbor send-community. */
3106DEFUN (neighbor_send_community,
3107 neighbor_send_community_cmd,
3108 NEIGHBOR_CMD2 "send-community",
3109 NEIGHBOR_STR
3110 NEIGHBOR_ADDR_STR2
3111 "Send Community attribute to this neighbor\n")
3112{
3113 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3114 bgp_node_safi (vty),
3115 PEER_FLAG_SEND_COMMUNITY);
3116}
3117
3118DEFUN (no_neighbor_send_community,
3119 no_neighbor_send_community_cmd,
3120 NO_NEIGHBOR_CMD2 "send-community",
3121 NO_STR
3122 NEIGHBOR_STR
3123 NEIGHBOR_ADDR_STR2
3124 "Send Community attribute to this neighbor\n")
3125{
3126 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3127 bgp_node_safi (vty),
3128 PEER_FLAG_SEND_COMMUNITY);
3129}
6b0655a2 3130
718e3744 3131/* neighbor send-community extended. */
3132DEFUN (neighbor_send_community_type,
3133 neighbor_send_community_type_cmd,
3134 NEIGHBOR_CMD2 "send-community (both|extended|standard)",
3135 NEIGHBOR_STR
3136 NEIGHBOR_ADDR_STR2
3137 "Send Community attribute to this neighbor\n"
3138 "Send Standard and Extended Community attributes\n"
3139 "Send Extended Community attributes\n"
3140 "Send Standard Community attributes\n")
3141{
3142 if (strncmp (argv[1], "s", 1) == 0)
3143 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3144 bgp_node_safi (vty),
3145 PEER_FLAG_SEND_COMMUNITY);
3146 if (strncmp (argv[1], "e", 1) == 0)
3147 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3148 bgp_node_safi (vty),
3149 PEER_FLAG_SEND_EXT_COMMUNITY);
3150
3151 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3152 bgp_node_safi (vty),
3153 (PEER_FLAG_SEND_COMMUNITY|
3154 PEER_FLAG_SEND_EXT_COMMUNITY));
3155}
3156
3157DEFUN (no_neighbor_send_community_type,
3158 no_neighbor_send_community_type_cmd,
3159 NO_NEIGHBOR_CMD2 "send-community (both|extended|standard)",
3160 NO_STR
3161 NEIGHBOR_STR
3162 NEIGHBOR_ADDR_STR2
3163 "Send Community attribute to this neighbor\n"
3164 "Send Standard and Extended Community attributes\n"
3165 "Send Extended Community attributes\n"
3166 "Send Standard Community attributes\n")
3167{
3168 if (strncmp (argv[1], "s", 1) == 0)
3169 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3170 bgp_node_safi (vty),
3171 PEER_FLAG_SEND_COMMUNITY);
3172 if (strncmp (argv[1], "e", 1) == 0)
3173 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3174 bgp_node_safi (vty),
3175 PEER_FLAG_SEND_EXT_COMMUNITY);
3176
3177 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3178 bgp_node_safi (vty),
3179 (PEER_FLAG_SEND_COMMUNITY |
3180 PEER_FLAG_SEND_EXT_COMMUNITY));
3181}
6b0655a2 3182
718e3744 3183/* neighbor soft-reconfig. */
3184DEFUN (neighbor_soft_reconfiguration,
3185 neighbor_soft_reconfiguration_cmd,
3186 NEIGHBOR_CMD2 "soft-reconfiguration inbound",
3187 NEIGHBOR_STR
3188 NEIGHBOR_ADDR_STR2
3189 "Per neighbor soft reconfiguration\n"
3190 "Allow inbound soft reconfiguration for this neighbor\n")
3191{
3192 return peer_af_flag_set_vty (vty, argv[0],
3193 bgp_node_afi (vty), bgp_node_safi (vty),
3194 PEER_FLAG_SOFT_RECONFIG);
3195}
3196
3197DEFUN (no_neighbor_soft_reconfiguration,
3198 no_neighbor_soft_reconfiguration_cmd,
3199 NO_NEIGHBOR_CMD2 "soft-reconfiguration inbound",
3200 NO_STR
3201 NEIGHBOR_STR
3202 NEIGHBOR_ADDR_STR2
3203 "Per neighbor soft reconfiguration\n"
3204 "Allow inbound soft reconfiguration for this neighbor\n")
3205{
3206 return peer_af_flag_unset_vty (vty, argv[0],
3207 bgp_node_afi (vty), bgp_node_safi (vty),
3208 PEER_FLAG_SOFT_RECONFIG);
3209}
6b0655a2 3210
718e3744 3211DEFUN (neighbor_route_reflector_client,
3212 neighbor_route_reflector_client_cmd,
3213 NEIGHBOR_CMD2 "route-reflector-client",
3214 NEIGHBOR_STR
3215 NEIGHBOR_ADDR_STR2
3216 "Configure a neighbor as Route Reflector client\n")
3217{
3218 struct peer *peer;
3219
3220
3221 peer = peer_and_group_lookup_vty (vty, argv[0]);
3222 if (! peer)
3223 return CMD_WARNING;
3224
3225 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3226 bgp_node_safi (vty),
3227 PEER_FLAG_REFLECTOR_CLIENT);
3228}
3229
3230DEFUN (no_neighbor_route_reflector_client,
3231 no_neighbor_route_reflector_client_cmd,
3232 NO_NEIGHBOR_CMD2 "route-reflector-client",
3233 NO_STR
3234 NEIGHBOR_STR
3235 NEIGHBOR_ADDR_STR2
3236 "Configure a neighbor as Route Reflector client\n")
3237{
3238 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3239 bgp_node_safi (vty),
3240 PEER_FLAG_REFLECTOR_CLIENT);
3241}
6b0655a2 3242
94f2b392 3243static int
fd79ac91 3244peer_rsclient_set_vty (struct vty *vty, const char *peer_str,
3245 int afi, int safi)
fee0f4c6 3246{
3247 int ret;
3248 struct bgp *bgp;
3249 struct peer *peer;
3250 struct peer_group *group;
1eb8ef25 3251 struct listnode *node, *nnode;
fee0f4c6 3252 struct bgp_filter *pfilter;
3253 struct bgp_filter *gfilter;
228da428 3254 int locked_and_added = 0;
fee0f4c6 3255
3256 bgp = vty->index;
3257
3258 peer = peer_and_group_lookup_vty (vty, peer_str);
3259 if ( ! peer )
3260 return CMD_WARNING;
3261
3262 /* If it is already a RS-Client, don't do anything. */
3263 if ( CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) )
3264 return CMD_SUCCESS;
3265
3266 if ( ! peer_rsclient_active (peer) )
200df115 3267 {
3268 peer = peer_lock (peer); /* rsclient peer list reference */
3269 listnode_add_sort (bgp->rsclient, peer);
228da428 3270 locked_and_added = 1;
200df115 3271 }
fee0f4c6 3272
3273 ret = peer_af_flag_set (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
3274 if (ret < 0)
228da428
CC
3275 {
3276 if (locked_and_added)
3277 {
3278 listnode_delete (bgp->rsclient, peer);
3279 peer_unlock (peer); /* rsclient peer list reference */
3280 }
3281
3282 return bgp_vty_return (vty, ret);
3283 }
fee0f4c6 3284
64e580a7 3285 peer->rib[afi][safi] = bgp_table_init (afi, safi);
fee0f4c6 3286 peer->rib[afi][safi]->type = BGP_TABLE_RSCLIENT;
228da428
CC
3287 /* RIB peer reference. Released when table is free'd in bgp_table_free. */
3288 peer->rib[afi][safi]->owner = peer_lock (peer);
fee0f4c6 3289
3290 /* Check for existing 'network' and 'redistribute' routes. */
3291 bgp_check_local_routes_rsclient (peer, afi, safi);
3292
3293 /* Check for routes for peers configured with 'soft-reconfiguration'. */
3294 bgp_soft_reconfig_rsclient (peer, afi, safi);
3295
3296 if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))
3297 {
3298 group = peer->group;
3299 gfilter = &peer->filter[afi][safi];
3300
1eb8ef25 3301 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
fee0f4c6 3302 {
3303 pfilter = &peer->filter[afi][safi];
3304
3305 /* Members of a non-RS-Client group should not be RS-Clients, as that
3306 is checked when the become part of the peer-group */
3307 ret = peer_af_flag_set (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
3308 if (ret < 0)
3309 return bgp_vty_return (vty, ret);
3310
3311 /* Make peer's RIB point to group's RIB. */
3312 peer->rib[afi][safi] = group->conf->rib[afi][safi];
3313
3314 /* Import policy. */
3315 if (pfilter->map[RMAP_IMPORT].name)
3316 free (pfilter->map[RMAP_IMPORT].name);
3317 if (gfilter->map[RMAP_IMPORT].name)
3318 {
3319 pfilter->map[RMAP_IMPORT].name = strdup (gfilter->map[RMAP_IMPORT].name);
3320 pfilter->map[RMAP_IMPORT].map = gfilter->map[RMAP_IMPORT].map;
3321 }
3322 else
3323 {
3324 pfilter->map[RMAP_IMPORT].name = NULL;
3325 pfilter->map[RMAP_IMPORT].map =NULL;
3326 }
3327
3328 /* Export policy. */
3329 if (gfilter->map[RMAP_EXPORT].name && ! pfilter->map[RMAP_EXPORT].name)
3330 {
3331 pfilter->map[RMAP_EXPORT].name = strdup (gfilter->map[RMAP_EXPORT].name);
3332 pfilter->map[RMAP_EXPORT].map = gfilter->map[RMAP_EXPORT].map;
3333 }
3334 }
3335 }
3336 return CMD_SUCCESS;
3337}
3338
94f2b392 3339static int
fd79ac91 3340peer_rsclient_unset_vty (struct vty *vty, const char *peer_str,
3341 int afi, int safi)
fee0f4c6 3342{
3343 int ret;
3344 struct bgp *bgp;
3345 struct peer *peer;
3346 struct peer_group *group;
1eb8ef25 3347 struct listnode *node, *nnode;
fee0f4c6 3348
3349 bgp = vty->index;
3350
3351 peer = peer_and_group_lookup_vty (vty, peer_str);
3352 if ( ! peer )
3353 return CMD_WARNING;
3354
3355 /* If it is not a RS-Client, don't do anything. */
3356 if ( ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) )
3357 return CMD_SUCCESS;
3358
3359 if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))
3360 {
3361 group = peer->group;
3362
1eb8ef25 3363 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
fee0f4c6 3364 {
3365 ret = peer_af_flag_unset (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
3366 if (ret < 0)
3367 return bgp_vty_return (vty, ret);
3368
3369 peer->rib[afi][safi] = NULL;
3370 }
3371
3372 peer = group->conf;
3373 }
3374
3375 ret = peer_af_flag_unset (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
3376 if (ret < 0)
3377 return bgp_vty_return (vty, ret);
3378
3379 if ( ! peer_rsclient_active (peer) )
200df115 3380 {
228da428 3381 bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_MY_RSCLIENT);
200df115 3382 listnode_delete (bgp->rsclient, peer);
228da428 3383 peer_unlock (peer); /* peer bgp rsclient reference */
200df115 3384 }
fee0f4c6 3385
b608d5b5 3386 bgp_table_finish (&peer->rib[bgp_node_afi(vty)][bgp_node_safi(vty)]);
fee0f4c6 3387
3388 return CMD_SUCCESS;
3389}
6b0655a2 3390
718e3744 3391/* neighbor route-server-client. */
3392DEFUN (neighbor_route_server_client,
3393 neighbor_route_server_client_cmd,
3394 NEIGHBOR_CMD2 "route-server-client",
3395 NEIGHBOR_STR
3396 NEIGHBOR_ADDR_STR2
3397 "Configure a neighbor as Route Server client\n")
3398{
fee0f4c6 3399 return peer_rsclient_set_vty (vty, argv[0], bgp_node_afi(vty),
3400 bgp_node_safi(vty));
718e3744 3401}
3402
3403DEFUN (no_neighbor_route_server_client,
3404 no_neighbor_route_server_client_cmd,
3405 NO_NEIGHBOR_CMD2 "route-server-client",
3406 NO_STR
3407 NEIGHBOR_STR
3408 NEIGHBOR_ADDR_STR2
3409 "Configure a neighbor as Route Server client\n")
fee0f4c6 3410{
3411 return peer_rsclient_unset_vty (vty, argv[0], bgp_node_afi(vty),
3412 bgp_node_safi(vty));
3413}
6b0655a2 3414
fee0f4c6 3415DEFUN (neighbor_nexthop_local_unchanged,
3416 neighbor_nexthop_local_unchanged_cmd,
3417 NEIGHBOR_CMD2 "nexthop-local unchanged",
3418 NEIGHBOR_STR
3419 NEIGHBOR_ADDR_STR2
3420 "Configure treatment of outgoing link-local nexthop attribute\n"
3421 "Leave link-local nexthop unchanged for this peer\n")
3422{
3423 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3424 bgp_node_safi (vty),
3425 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
3426}
6b0655a2 3427
fee0f4c6 3428DEFUN (no_neighbor_nexthop_local_unchanged,
3429 no_neighbor_nexthop_local_unchanged_cmd,
3430 NO_NEIGHBOR_CMD2 "nexthop-local unchanged",
3431 NO_STR
3432 NEIGHBOR_STR
3433 NEIGHBOR_ADDR_STR2
3434 "Configure treatment of outgoing link-local-nexthop attribute\n"
3435 "Leave link-local nexthop unchanged for this peer\n")
718e3744 3436{
3437 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3438 bgp_node_safi (vty),
fee0f4c6 3439 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
718e3744 3440}
6b0655a2 3441
718e3744 3442DEFUN (neighbor_attr_unchanged,
3443 neighbor_attr_unchanged_cmd,
3444 NEIGHBOR_CMD2 "attribute-unchanged",
3445 NEIGHBOR_STR
3446 NEIGHBOR_ADDR_STR2
3447 "BGP attribute is propagated unchanged to this neighbor\n")
3448{
3449 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3450 bgp_node_safi (vty),
3451 (PEER_FLAG_AS_PATH_UNCHANGED |
3452 PEER_FLAG_NEXTHOP_UNCHANGED |
3453 PEER_FLAG_MED_UNCHANGED));
3454}
3455
3456DEFUN (neighbor_attr_unchanged1,
3457 neighbor_attr_unchanged1_cmd,
3458 NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
3459 NEIGHBOR_STR
3460 NEIGHBOR_ADDR_STR2
3461 "BGP attribute is propagated unchanged to this neighbor\n"
3462 "As-path attribute\n"
3463 "Nexthop attribute\n"
3464 "Med attribute\n")
3465{
3466 u_int16_t flags = 0;
3467
3468 if (strncmp (argv[1], "as-path", 1) == 0)
3469 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
3470 else if (strncmp (argv[1], "next-hop", 1) == 0)
3471 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
3472 else if (strncmp (argv[1], "med", 1) == 0)
3473 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
3474
3475 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3476 bgp_node_safi (vty), flags);
3477}
3478
3479DEFUN (neighbor_attr_unchanged2,
3480 neighbor_attr_unchanged2_cmd,
3481 NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
3482 NEIGHBOR_STR
3483 NEIGHBOR_ADDR_STR2
3484 "BGP attribute is propagated unchanged to this neighbor\n"
3485 "As-path attribute\n"
3486 "Nexthop attribute\n"
3487 "Med attribute\n")
3488{
3489 u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
3490
3491 if (strncmp (argv[1], "next-hop", 1) == 0)
3492 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
3493 else if (strncmp (argv[1], "med", 1) == 0)
3494 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
3495
3496 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3497 bgp_node_safi (vty), flags);
3498
3499}
3500
3501DEFUN (neighbor_attr_unchanged3,
3502 neighbor_attr_unchanged3_cmd,
3503 NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
3504 NEIGHBOR_STR
3505 NEIGHBOR_ADDR_STR2
3506 "BGP attribute is propagated unchanged to this neighbor\n"
3507 "Nexthop attribute\n"
3508 "As-path attribute\n"
3509 "Med attribute\n")
3510{
3511 u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
3512
3513 if (strncmp (argv[1], "as-path", 1) == 0)
3514 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
3515 else if (strncmp (argv[1], "med", 1) == 0)
3516 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
3517
3518 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3519 bgp_node_safi (vty), flags);
3520}
3521
3522DEFUN (neighbor_attr_unchanged4,
3523 neighbor_attr_unchanged4_cmd,
3524 NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
3525 NEIGHBOR_STR
3526 NEIGHBOR_ADDR_STR2
3527 "BGP attribute is propagated unchanged to this neighbor\n"
3528 "Med attribute\n"
3529 "As-path attribute\n"
3530 "Nexthop attribute\n")
3531{
3532 u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
3533
3534 if (strncmp (argv[1], "as-path", 1) == 0)
3535 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
3536 else if (strncmp (argv[1], "next-hop", 1) == 0)
3537 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
3538
3539 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3540 bgp_node_safi (vty), flags);
3541}
3542
3543ALIAS (neighbor_attr_unchanged,
3544 neighbor_attr_unchanged5_cmd,
3545 NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
3546 NEIGHBOR_STR
3547 NEIGHBOR_ADDR_STR2
3548 "BGP attribute is propagated unchanged to this neighbor\n"
3549 "As-path attribute\n"
3550 "Nexthop attribute\n"
3551 "Med attribute\n")
3552
3553ALIAS (neighbor_attr_unchanged,
3554 neighbor_attr_unchanged6_cmd,
3555 NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
3556 NEIGHBOR_STR
3557 NEIGHBOR_ADDR_STR2
3558 "BGP attribute is propagated unchanged to this neighbor\n"
3559 "As-path attribute\n"
3560 "Med attribute\n"
3561 "Nexthop attribute\n")
3562
3563ALIAS (neighbor_attr_unchanged,
3564 neighbor_attr_unchanged7_cmd,
3565 NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
3566 NEIGHBOR_STR
3567 NEIGHBOR_ADDR_STR2
3568 "BGP attribute is propagated unchanged to this neighbor\n"
3569 "Nexthop attribute\n"
3570 "Med attribute\n"
3571 "As-path attribute\n")
3572
3573ALIAS (neighbor_attr_unchanged,
3574 neighbor_attr_unchanged8_cmd,
3575 NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
3576 NEIGHBOR_STR
3577 NEIGHBOR_ADDR_STR2
3578 "BGP attribute is propagated unchanged to this neighbor\n"
3579 "Nexthop attribute\n"
3580 "As-path attribute\n"
3581 "Med attribute\n")
3582
3583ALIAS (neighbor_attr_unchanged,
3584 neighbor_attr_unchanged9_cmd,
3585 NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
3586 NEIGHBOR_STR
3587 NEIGHBOR_ADDR_STR2
3588 "BGP attribute is propagated unchanged to this neighbor\n"
3589 "Med attribute\n"
3590 "Nexthop attribute\n"
3591 "As-path attribute\n")
3592
3593ALIAS (neighbor_attr_unchanged,
3594 neighbor_attr_unchanged10_cmd,
3595 NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
3596 NEIGHBOR_STR
3597 NEIGHBOR_ADDR_STR2
3598 "BGP attribute is propagated unchanged to this neighbor\n"
3599 "Med attribute\n"
3600 "As-path attribute\n"
3601 "Nexthop attribute\n")
3602
3603DEFUN (no_neighbor_attr_unchanged,
3604 no_neighbor_attr_unchanged_cmd,
3605 NO_NEIGHBOR_CMD2 "attribute-unchanged",
3606 NO_STR
3607 NEIGHBOR_STR
3608 NEIGHBOR_ADDR_STR2
3609 "BGP attribute is propagated unchanged to this neighbor\n")
3610{
3611 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3612 bgp_node_safi (vty),
3613 (PEER_FLAG_AS_PATH_UNCHANGED |
3614 PEER_FLAG_NEXTHOP_UNCHANGED |
3615 PEER_FLAG_MED_UNCHANGED));
3616}
3617
3618DEFUN (no_neighbor_attr_unchanged1,
3619 no_neighbor_attr_unchanged1_cmd,
3620 NO_NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
3621 NO_STR
3622 NEIGHBOR_STR
3623 NEIGHBOR_ADDR_STR2
3624 "BGP attribute is propagated unchanged to this neighbor\n"
3625 "As-path attribute\n"
3626 "Nexthop attribute\n"
3627 "Med attribute\n")
3628{
3629 u_int16_t flags = 0;
3630
3631 if (strncmp (argv[1], "as-path", 1) == 0)
3632 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
3633 else if (strncmp (argv[1], "next-hop", 1) == 0)
3634 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
3635 else if (strncmp (argv[1], "med", 1) == 0)
3636 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
3637
3638 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3639 bgp_node_safi (vty), flags);
3640}
3641
3642DEFUN (no_neighbor_attr_unchanged2,
3643 no_neighbor_attr_unchanged2_cmd,
3644 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
3645 NO_STR
3646 NEIGHBOR_STR
3647 NEIGHBOR_ADDR_STR2
3648 "BGP attribute is propagated unchanged to this neighbor\n"
3649 "As-path attribute\n"
3650 "Nexthop attribute\n"
3651 "Med attribute\n")
3652{
3653 u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
3654
3655 if (strncmp (argv[1], "next-hop", 1) == 0)
3656 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
3657 else if (strncmp (argv[1], "med", 1) == 0)
3658 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
3659
3660 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3661 bgp_node_safi (vty), flags);
3662}
3663
3664DEFUN (no_neighbor_attr_unchanged3,
3665 no_neighbor_attr_unchanged3_cmd,
3666 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
3667 NO_STR
3668 NEIGHBOR_STR
3669 NEIGHBOR_ADDR_STR2
3670 "BGP attribute is propagated unchanged to this neighbor\n"
3671 "Nexthop attribute\n"
3672 "As-path attribute\n"
3673 "Med attribute\n")
3674{
3675 u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
3676
3677 if (strncmp (argv[1], "as-path", 1) == 0)
3678 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
3679 else if (strncmp (argv[1], "med", 1) == 0)
3680 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
3681
3682 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3683 bgp_node_safi (vty), flags);
3684}
3685
3686DEFUN (no_neighbor_attr_unchanged4,
3687 no_neighbor_attr_unchanged4_cmd,
3688 NO_NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
3689 NO_STR
3690 NEIGHBOR_STR
3691 NEIGHBOR_ADDR_STR2
3692 "BGP attribute is propagated unchanged to this neighbor\n"
3693 "Med attribute\n"
3694 "As-path attribute\n"
3695 "Nexthop attribute\n")
3696{
3697 u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
3698
3699 if (strncmp (argv[1], "as-path", 1) == 0)
3700 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
3701 else if (strncmp (argv[1], "next-hop", 1) == 0)
3702 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
3703
3704 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3705 bgp_node_safi (vty), flags);
3706}
3707
3708ALIAS (no_neighbor_attr_unchanged,
3709 no_neighbor_attr_unchanged5_cmd,
3710 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
3711 NO_STR
3712 NEIGHBOR_STR
3713 NEIGHBOR_ADDR_STR2
3714 "BGP attribute is propagated unchanged to this neighbor\n"
3715 "As-path attribute\n"
3716 "Nexthop attribute\n"
3717 "Med attribute\n")
3718
3719ALIAS (no_neighbor_attr_unchanged,
3720 no_neighbor_attr_unchanged6_cmd,
3721 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
3722 NO_STR
3723 NEIGHBOR_STR
3724 NEIGHBOR_ADDR_STR2
3725 "BGP attribute is propagated unchanged to this neighbor\n"
3726 "As-path attribute\n"
3727 "Med attribute\n"
3728 "Nexthop attribute\n")
3729
3730ALIAS (no_neighbor_attr_unchanged,
3731 no_neighbor_attr_unchanged7_cmd,
3732 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
3733 NO_STR
3734 NEIGHBOR_STR
3735 NEIGHBOR_ADDR_STR2
3736 "BGP attribute is propagated unchanged to this neighbor\n"
3737 "Nexthop attribute\n"
3738 "Med attribute\n"
3739 "As-path attribute\n")
3740
3741ALIAS (no_neighbor_attr_unchanged,
3742 no_neighbor_attr_unchanged8_cmd,
3743 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
3744 NO_STR
3745 NEIGHBOR_STR
3746 NEIGHBOR_ADDR_STR2
3747 "BGP attribute is propagated unchanged to this neighbor\n"
3748 "Nexthop attribute\n"
3749 "As-path attribute\n"
3750 "Med attribute\n")
3751
3752ALIAS (no_neighbor_attr_unchanged,
3753 no_neighbor_attr_unchanged9_cmd,
3754 NO_NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
3755 NO_STR
3756 NEIGHBOR_STR
3757 NEIGHBOR_ADDR_STR2
3758 "BGP attribute is propagated unchanged to this neighbor\n"
3759 "Med attribute\n"
3760 "Nexthop attribute\n"
3761 "As-path attribute\n")
3762
3763ALIAS (no_neighbor_attr_unchanged,
3764 no_neighbor_attr_unchanged10_cmd,
3765 NO_NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
3766 NO_STR
3767 NEIGHBOR_STR
3768 NEIGHBOR_ADDR_STR2
3769 "BGP attribute is propagated unchanged to this neighbor\n"
3770 "Med attribute\n"
3771 "As-path attribute\n"
3772 "Nexthop attribute\n")
3773
3774/* For old version Zebra compatibility. */
dd4c593f 3775DEFUN_DEPRECATED (neighbor_transparent_as,
3776 neighbor_transparent_as_cmd,
3777 NEIGHBOR_CMD "transparent-as",
3778 NEIGHBOR_STR
3779 NEIGHBOR_ADDR_STR
3780 "Do not append my AS number even peer is EBGP peer\n")
718e3744 3781{
3782 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3783 bgp_node_safi (vty),
3784 PEER_FLAG_AS_PATH_UNCHANGED);
3785}
3786
dd4c593f 3787DEFUN_DEPRECATED (neighbor_transparent_nexthop,
3788 neighbor_transparent_nexthop_cmd,
3789 NEIGHBOR_CMD "transparent-nexthop",
3790 NEIGHBOR_STR
3791 NEIGHBOR_ADDR_STR
3792 "Do not change nexthop even peer is EBGP peer\n")
718e3744 3793{
3794 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3795 bgp_node_safi (vty),
3796 PEER_FLAG_NEXTHOP_UNCHANGED);
3797}
6b0655a2 3798
718e3744 3799/* EBGP multihop configuration. */
94f2b392 3800static int
fd79ac91 3801peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str,
3802 const char *ttl_str)
718e3744 3803{
3804 struct peer *peer;
fd79ac91 3805 unsigned int ttl;
718e3744 3806
3807 peer = peer_and_group_lookup_vty (vty, ip_str);
3808 if (! peer)
3809 return CMD_WARNING;
3810
3811 if (! ttl_str)
3812 ttl = TTL_MAX;
3813 else
3814 VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, 255);
3815
89b6d1f8 3816 return bgp_vty_return (vty, peer_ebgp_multihop_set (peer, ttl));
718e3744 3817}
3818
94f2b392 3819static int
fd79ac91 3820peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str)
718e3744 3821{
3822 struct peer *peer;
3823
3824 peer = peer_and_group_lookup_vty (vty, ip_str);
3825 if (! peer)
3826 return CMD_WARNING;
3827
89b6d1f8 3828 return bgp_vty_return (vty, peer_ebgp_multihop_unset (peer));
718e3744 3829}
3830
3831/* neighbor ebgp-multihop. */
3832DEFUN (neighbor_ebgp_multihop,
3833 neighbor_ebgp_multihop_cmd,
3834 NEIGHBOR_CMD2 "ebgp-multihop",
3835 NEIGHBOR_STR
3836 NEIGHBOR_ADDR_STR2
3837 "Allow EBGP neighbors not on directly connected networks\n")
3838{
3839 return peer_ebgp_multihop_set_vty (vty, argv[0], NULL);
3840}
3841
3842DEFUN (neighbor_ebgp_multihop_ttl,
3843 neighbor_ebgp_multihop_ttl_cmd,
3844 NEIGHBOR_CMD2 "ebgp-multihop <1-255>",
3845 NEIGHBOR_STR
3846 NEIGHBOR_ADDR_STR2
3847 "Allow EBGP neighbors not on directly connected networks\n"
3848 "maximum hop count\n")
3849{
3850 return peer_ebgp_multihop_set_vty (vty, argv[0], argv[1]);
3851}
3852
3853DEFUN (no_neighbor_ebgp_multihop,
3854 no_neighbor_ebgp_multihop_cmd,
3855 NO_NEIGHBOR_CMD2 "ebgp-multihop",
3856 NO_STR
3857 NEIGHBOR_STR
3858 NEIGHBOR_ADDR_STR2
3859 "Allow EBGP neighbors not on directly connected networks\n")
3860{
3861 return peer_ebgp_multihop_unset_vty (vty, argv[0]);
3862}
3863
3864ALIAS (no_neighbor_ebgp_multihop,
3865 no_neighbor_ebgp_multihop_ttl_cmd,
3866 NO_NEIGHBOR_CMD2 "ebgp-multihop <1-255>",
3867 NO_STR
3868 NEIGHBOR_STR
3869 NEIGHBOR_ADDR_STR2
3870 "Allow EBGP neighbors not on directly connected networks\n"
3871 "maximum hop count\n")
6b0655a2 3872
6ffd2079 3873/* disable-connected-check */
3874DEFUN (neighbor_disable_connected_check,
3875 neighbor_disable_connected_check_cmd,
3876 NEIGHBOR_CMD2 "disable-connected-check",
3877 NEIGHBOR_STR
3878 NEIGHBOR_ADDR_STR2
3879 "one-hop away EBGP peer using loopback address\n")
3880{
3881 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
3882}
3883
3884DEFUN (no_neighbor_disable_connected_check,
3885 no_neighbor_disable_connected_check_cmd,
3886 NO_NEIGHBOR_CMD2 "disable-connected-check",
3887 NO_STR
3888 NEIGHBOR_STR
3889 NEIGHBOR_ADDR_STR2
3890 "one-hop away EBGP peer using loopback address\n")
3891{
3892 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
3893}
3894
718e3744 3895/* Enforce multihop. */
6ffd2079 3896ALIAS (neighbor_disable_connected_check,
718e3744 3897 neighbor_enforce_multihop_cmd,
3898 NEIGHBOR_CMD2 "enforce-multihop",
3899 NEIGHBOR_STR
3900 NEIGHBOR_ADDR_STR2
e8e1946e 3901 "Enforce EBGP neighbors perform multihop\n")
718e3744 3902
6ffd2079 3903/* Enforce multihop. */
3904ALIAS (no_neighbor_disable_connected_check,
718e3744 3905 no_neighbor_enforce_multihop_cmd,
3906 NO_NEIGHBOR_CMD2 "enforce-multihop",
3907 NO_STR
3908 NEIGHBOR_STR
3909 NEIGHBOR_ADDR_STR2
e8e1946e 3910 "Enforce EBGP neighbors perform multihop\n")
6b0655a2 3911
718e3744 3912DEFUN (neighbor_description,
3913 neighbor_description_cmd,
3914 NEIGHBOR_CMD2 "description .LINE",
3915 NEIGHBOR_STR
3916 NEIGHBOR_ADDR_STR2
3917 "Neighbor specific description\n"
3918 "Up to 80 characters describing this neighbor\n")
3919{
3920 struct peer *peer;
718e3744 3921 char *str;
718e3744 3922
3923 peer = peer_and_group_lookup_vty (vty, argv[0]);
3924 if (! peer)
3925 return CMD_WARNING;
3926
3927 if (argc == 1)
3928 return CMD_SUCCESS;
3929
3b8b1855 3930 str = argv_concat(argv, argc, 1);
718e3744 3931
3932 peer_description_set (peer, str);
3933
3b8b1855 3934 XFREE (MTYPE_TMP, str);
718e3744 3935
3936 return CMD_SUCCESS;
3937}
3938
3939DEFUN (no_neighbor_description,
3940 no_neighbor_description_cmd,
3941 NO_NEIGHBOR_CMD2 "description",
3942 NO_STR
3943 NEIGHBOR_STR
3944 NEIGHBOR_ADDR_STR2
3945 "Neighbor specific description\n")
3946{
3947 struct peer *peer;
3948
3949 peer = peer_and_group_lookup_vty (vty, argv[0]);
3950 if (! peer)
3951 return CMD_WARNING;
3952
3953 peer_description_unset (peer);
3954
3955 return CMD_SUCCESS;
3956}
3957
3958ALIAS (no_neighbor_description,
3959 no_neighbor_description_val_cmd,
3960 NO_NEIGHBOR_CMD2 "description .LINE",
3961 NO_STR
3962 NEIGHBOR_STR
3963 NEIGHBOR_ADDR_STR2
3964 "Neighbor specific description\n"
3965 "Up to 80 characters describing this neighbor\n")
6b0655a2 3966
718e3744 3967/* Neighbor update-source. */
94f2b392 3968static int
fd79ac91 3969peer_update_source_vty (struct vty *vty, const char *peer_str,
3970 const char *source_str)
718e3744 3971{
3972 struct peer *peer;
718e3744 3973
3974 peer = peer_and_group_lookup_vty (vty, peer_str);
3975 if (! peer)
3976 return CMD_WARNING;
3977
a80beece
DS
3978 if (peer->conf_if)
3979 return CMD_WARNING;
3980
718e3744 3981 if (source_str)
3982 {
c63b83fe
JBD
3983 union sockunion su;
3984 int ret = str2sockunion (source_str, &su);
3985
3986 if (ret == 0)
3987 peer_update_source_addr_set (peer, &su);
718e3744 3988 else
3989 peer_update_source_if_set (peer, source_str);
3990 }
3991 else
3992 peer_update_source_unset (peer);
3993
3994 return CMD_SUCCESS;
3995}
3996
9a1a331d 3997#define BGP_UPDATE_SOURCE_STR "(A.B.C.D|X:X::X:X|WORD)"
369688c0
PJ
3998#define BGP_UPDATE_SOURCE_HELP_STR \
3999 "IPv4 address\n" \
9a1a331d
PJ
4000 "IPv6 address\n" \
4001 "Interface name (requires zebra to be running)\n"
369688c0 4002
718e3744 4003DEFUN (neighbor_update_source,
4004 neighbor_update_source_cmd,
369688c0 4005 NEIGHBOR_CMD2 "update-source " BGP_UPDATE_SOURCE_STR,
718e3744 4006 NEIGHBOR_STR
4007 NEIGHBOR_ADDR_STR2
4008 "Source of routing updates\n"
369688c0 4009 BGP_UPDATE_SOURCE_HELP_STR)
718e3744 4010{
4011 return peer_update_source_vty (vty, argv[0], argv[1]);
4012}
4013
4014DEFUN (no_neighbor_update_source,
4015 no_neighbor_update_source_cmd,
4016 NO_NEIGHBOR_CMD2 "update-source",
4017 NO_STR
4018 NEIGHBOR_STR
4019 NEIGHBOR_ADDR_STR2
369688c0 4020 "Source of routing updates\n")
718e3744 4021{
4022 return peer_update_source_vty (vty, argv[0], NULL);
4023}
6b0655a2 4024
94f2b392 4025static int
fd79ac91 4026peer_default_originate_set_vty (struct vty *vty, const char *peer_str,
4027 afi_t afi, safi_t safi,
4028 const char *rmap, int set)
718e3744 4029{
4030 int ret;
4031 struct peer *peer;
4032
4033 peer = peer_and_group_lookup_vty (vty, peer_str);
4034 if (! peer)
4035 return CMD_WARNING;
4036
4037 if (set)
4038 ret = peer_default_originate_set (peer, afi, safi, rmap);
4039 else
4040 ret = peer_default_originate_unset (peer, afi, safi);
4041
4042 return bgp_vty_return (vty, ret);
4043}
4044
4045/* neighbor default-originate. */
4046DEFUN (neighbor_default_originate,
4047 neighbor_default_originate_cmd,
4048 NEIGHBOR_CMD2 "default-originate",
4049 NEIGHBOR_STR
4050 NEIGHBOR_ADDR_STR2
4051 "Originate default route to this neighbor\n")
4052{
4053 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
4054 bgp_node_safi (vty), NULL, 1);
4055}
4056
4057DEFUN (neighbor_default_originate_rmap,
4058 neighbor_default_originate_rmap_cmd,
4059 NEIGHBOR_CMD2 "default-originate route-map WORD",
4060 NEIGHBOR_STR
4061 NEIGHBOR_ADDR_STR2
4062 "Originate default route to this neighbor\n"
4063 "Route-map to specify criteria to originate default\n"
4064 "route-map name\n")
4065{
4066 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
4067 bgp_node_safi (vty), argv[1], 1);
4068}
4069
4070DEFUN (no_neighbor_default_originate,
4071 no_neighbor_default_originate_cmd,
4072 NO_NEIGHBOR_CMD2 "default-originate",
4073 NO_STR
4074 NEIGHBOR_STR
4075 NEIGHBOR_ADDR_STR2
4076 "Originate default route to this neighbor\n")
4077{
4078 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
4079 bgp_node_safi (vty), NULL, 0);
4080}
4081
4082ALIAS (no_neighbor_default_originate,
4083 no_neighbor_default_originate_rmap_cmd,
4084 NO_NEIGHBOR_CMD2 "default-originate route-map WORD",
4085 NO_STR
4086 NEIGHBOR_STR
4087 NEIGHBOR_ADDR_STR2
4088 "Originate default route to this neighbor\n"
4089 "Route-map to specify criteria to originate default\n"
4090 "route-map name\n")
6b0655a2 4091
718e3744 4092/* Set neighbor's BGP port. */
94f2b392 4093static int
fd79ac91 4094peer_port_vty (struct vty *vty, const char *ip_str, int afi,
4095 const char *port_str)
718e3744 4096{
4097 struct peer *peer;
4098 u_int16_t port;
4099 struct servent *sp;
4100
4101 peer = peer_lookup_vty (vty, ip_str);
4102 if (! peer)
4103 return CMD_WARNING;
4104
4105 if (! port_str)
4106 {
4107 sp = getservbyname ("bgp", "tcp");
4108 port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port);
4109 }
4110 else
4111 {
4112 VTY_GET_INTEGER("port", port, port_str);
4113 }
4114
4115 peer_port_set (peer, port);
4116
4117 return CMD_SUCCESS;
4118}
4119
f418446b 4120/* Set specified peer's BGP port. */
718e3744 4121DEFUN (neighbor_port,
4122 neighbor_port_cmd,
4123 NEIGHBOR_CMD "port <0-65535>",
4124 NEIGHBOR_STR
4125 NEIGHBOR_ADDR_STR
4126 "Neighbor's BGP port\n"
4127 "TCP port number\n")
4128{
4129 return peer_port_vty (vty, argv[0], AFI_IP, argv[1]);
4130}
4131
4132DEFUN (no_neighbor_port,
4133 no_neighbor_port_cmd,
4134 NO_NEIGHBOR_CMD "port",
4135 NO_STR
4136 NEIGHBOR_STR
4137 NEIGHBOR_ADDR_STR
4138 "Neighbor's BGP port\n")
4139{
4140 return peer_port_vty (vty, argv[0], AFI_IP, NULL);
4141}
4142
4143ALIAS (no_neighbor_port,
4144 no_neighbor_port_val_cmd,
4145 NO_NEIGHBOR_CMD "port <0-65535>",
4146 NO_STR
4147 NEIGHBOR_STR
4148 NEIGHBOR_ADDR_STR
4149 "Neighbor's BGP port\n"
4150 "TCP port number\n")
6b0655a2 4151
718e3744 4152/* neighbor weight. */
94f2b392 4153static int
fd79ac91 4154peer_weight_set_vty (struct vty *vty, const char *ip_str,
4155 const char *weight_str)
718e3744 4156{
4157 int ret;
4158 struct peer *peer;
4159 unsigned long weight;
4160
4161 peer = peer_and_group_lookup_vty (vty, ip_str);
4162 if (! peer)
4163 return CMD_WARNING;
4164
4165 VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535);
4166
4167 ret = peer_weight_set (peer, weight);
4168
4169 return CMD_SUCCESS;
4170}
4171
94f2b392 4172static int
fd79ac91 4173peer_weight_unset_vty (struct vty *vty, const char *ip_str)
718e3744 4174{
4175 struct peer *peer;
4176
4177 peer = peer_and_group_lookup_vty (vty, ip_str);
4178 if (! peer)
4179 return CMD_WARNING;
4180
4181 peer_weight_unset (peer);
4182
4183 return CMD_SUCCESS;
4184}
4185
4186DEFUN (neighbor_weight,
4187 neighbor_weight_cmd,
4188 NEIGHBOR_CMD2 "weight <0-65535>",
4189 NEIGHBOR_STR
4190 NEIGHBOR_ADDR_STR2
4191 "Set default weight for routes from this neighbor\n"
4192 "default weight\n")
4193{
4194 return peer_weight_set_vty (vty, argv[0], argv[1]);
4195}
4196
4197DEFUN (no_neighbor_weight,
4198 no_neighbor_weight_cmd,
4199 NO_NEIGHBOR_CMD2 "weight",
4200 NO_STR
4201 NEIGHBOR_STR
4202 NEIGHBOR_ADDR_STR2
4203 "Set default weight for routes from this neighbor\n")
4204{
4205 return peer_weight_unset_vty (vty, argv[0]);
4206}
4207
4208ALIAS (no_neighbor_weight,
4209 no_neighbor_weight_val_cmd,
4210 NO_NEIGHBOR_CMD2 "weight <0-65535>",
4211 NO_STR
4212 NEIGHBOR_STR
4213 NEIGHBOR_ADDR_STR2
4214 "Set default weight for routes from this neighbor\n"
4215 "default weight\n")
6b0655a2 4216
718e3744 4217/* Override capability negotiation. */
4218DEFUN (neighbor_override_capability,
4219 neighbor_override_capability_cmd,
4220 NEIGHBOR_CMD2 "override-capability",
4221 NEIGHBOR_STR
4222 NEIGHBOR_ADDR_STR2
4223 "Override capability negotiation result\n")
4224{
4225 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
4226}
4227
4228DEFUN (no_neighbor_override_capability,
4229 no_neighbor_override_capability_cmd,
4230 NO_NEIGHBOR_CMD2 "override-capability",
4231 NO_STR
4232 NEIGHBOR_STR
4233 NEIGHBOR_ADDR_STR2
4234 "Override capability negotiation result\n")
4235{
4236 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
4237}
6b0655a2 4238
718e3744 4239DEFUN (neighbor_strict_capability,
4240 neighbor_strict_capability_cmd,
4241 NEIGHBOR_CMD "strict-capability-match",
4242 NEIGHBOR_STR
4243 NEIGHBOR_ADDR_STR
4244 "Strict capability negotiation match\n")
4245{
4246 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
4247}
4248
4249DEFUN (no_neighbor_strict_capability,
4250 no_neighbor_strict_capability_cmd,
4251 NO_NEIGHBOR_CMD "strict-capability-match",
4252 NO_STR
4253 NEIGHBOR_STR
4254 NEIGHBOR_ADDR_STR
4255 "Strict capability negotiation match\n")
4256{
4257 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
4258}
6b0655a2 4259
94f2b392 4260static int
fd79ac91 4261peer_timers_set_vty (struct vty *vty, const char *ip_str,
4262 const char *keep_str, const char *hold_str)
718e3744 4263{
4264 int ret;
4265 struct peer *peer;
4266 u_int32_t keepalive;
4267 u_int32_t holdtime;
4268
4269 peer = peer_and_group_lookup_vty (vty, ip_str);
4270 if (! peer)
4271 return CMD_WARNING;
4272
4273 VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535);
4274 VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535);
4275
4276 ret = peer_timers_set (peer, keepalive, holdtime);
4277
4278 return bgp_vty_return (vty, ret);
4279}
6b0655a2 4280
94f2b392 4281static int
fd79ac91 4282peer_timers_unset_vty (struct vty *vty, const char *ip_str)
718e3744 4283{
4284 int ret;
4285 struct peer *peer;
4286
4287 peer = peer_lookup_vty (vty, ip_str);
4288 if (! peer)
4289 return CMD_WARNING;
4290
4291 ret = peer_timers_unset (peer);
4292
4293 return bgp_vty_return (vty, ret);
4294}
4295
4296DEFUN (neighbor_timers,
4297 neighbor_timers_cmd,
4298 NEIGHBOR_CMD2 "timers <0-65535> <0-65535>",
4299 NEIGHBOR_STR
4300 NEIGHBOR_ADDR_STR2
4301 "BGP per neighbor timers\n"
4302 "Keepalive interval\n"
4303 "Holdtime\n")
4304{
4305 return peer_timers_set_vty (vty, argv[0], argv[1], argv[2]);
4306}
4307
4308DEFUN (no_neighbor_timers,
4309 no_neighbor_timers_cmd,
4310 NO_NEIGHBOR_CMD2 "timers",
4311 NO_STR
4312 NEIGHBOR_STR
4313 NEIGHBOR_ADDR_STR2
4314 "BGP per neighbor timers\n")
4315{
4316 return peer_timers_unset_vty (vty, argv[0]);
4317}
6b0655a2 4318
94f2b392 4319static int
fd79ac91 4320peer_timers_connect_set_vty (struct vty *vty, const char *ip_str,
4321 const char *time_str)
718e3744 4322{
4323 int ret;
4324 struct peer *peer;
4325 u_int32_t connect;
4326
966f821c 4327 peer = peer_and_group_lookup_vty (vty, ip_str);
718e3744 4328 if (! peer)
4329 return CMD_WARNING;
4330
4331 VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535);
4332
4333 ret = peer_timers_connect_set (peer, connect);
4334
966f821c 4335 return bgp_vty_return (vty, ret);
718e3744 4336}
4337
94f2b392 4338static int
fd79ac91 4339peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str)
718e3744 4340{
4341 int ret;
4342 struct peer *peer;
4343
4344 peer = peer_and_group_lookup_vty (vty, ip_str);
4345 if (! peer)
4346 return CMD_WARNING;
4347
4348 ret = peer_timers_connect_unset (peer);
4349
966f821c 4350 return bgp_vty_return (vty, ret);
718e3744 4351}
4352
4353DEFUN (neighbor_timers_connect,
4354 neighbor_timers_connect_cmd,
966f821c 4355 NEIGHBOR_CMD2 "timers connect <0-65535>",
718e3744 4356 NEIGHBOR_STR
966f821c 4357 NEIGHBOR_ADDR_STR2
718e3744 4358 "BGP per neighbor timers\n"
4359 "BGP connect timer\n"
4360 "Connect timer\n")
4361{
4362 return peer_timers_connect_set_vty (vty, argv[0], argv[1]);
4363}
4364
4365DEFUN (no_neighbor_timers_connect,
4366 no_neighbor_timers_connect_cmd,
966f821c 4367 NO_NEIGHBOR_CMD2 "timers connect",
718e3744 4368 NO_STR
4369 NEIGHBOR_STR
966f821c 4370 NEIGHBOR_ADDR_STR2
718e3744 4371 "BGP per neighbor timers\n"
4372 "BGP connect timer\n")
4373{
4374 return peer_timers_connect_unset_vty (vty, argv[0]);
4375}
4376
4377ALIAS (no_neighbor_timers_connect,
4378 no_neighbor_timers_connect_val_cmd,
966f821c 4379 NO_NEIGHBOR_CMD2 "timers connect <0-65535>",
718e3744 4380 NO_STR
4381 NEIGHBOR_STR
966f821c 4382 NEIGHBOR_ADDR_STR2
718e3744 4383 "BGP per neighbor timers\n"
4384 "BGP connect timer\n"
4385 "Connect timer\n")
6b0655a2 4386
94f2b392 4387static int
fd79ac91 4388peer_advertise_interval_vty (struct vty *vty, const char *ip_str,
4389 const char *time_str, int set)
718e3744 4390{
4391 int ret;
4392 struct peer *peer;
4393 u_int32_t routeadv = 0;
4394
966f821c 4395 peer = peer_and_group_lookup_vty (vty, ip_str);
718e3744 4396 if (! peer)
4397 return CMD_WARNING;
4398
4399 if (time_str)
4400 VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600);
4401
4402 if (set)
4403 ret = peer_advertise_interval_set (peer, routeadv);
4404 else
4405 ret = peer_advertise_interval_unset (peer);
4406
966f821c 4407 return bgp_vty_return (vty, ret);
718e3744 4408}
4409
4410DEFUN (neighbor_advertise_interval,
4411 neighbor_advertise_interval_cmd,
966f821c 4412 NEIGHBOR_CMD2 "advertisement-interval <0-600>",
718e3744 4413 NEIGHBOR_STR
966f821c 4414 NEIGHBOR_ADDR_STR2
718e3744 4415 "Minimum interval between sending BGP routing updates\n"
4416 "time in seconds\n")
4417{
4418 return peer_advertise_interval_vty (vty, argv[0], argv[1], 1);
4419}
4420
4421DEFUN (no_neighbor_advertise_interval,
4422 no_neighbor_advertise_interval_cmd,
966f821c 4423 NO_NEIGHBOR_CMD2 "advertisement-interval",
718e3744 4424 NO_STR
4425 NEIGHBOR_STR
966f821c 4426 NEIGHBOR_ADDR_STR2
718e3744 4427 "Minimum interval between sending BGP routing updates\n")
4428{
4429 return peer_advertise_interval_vty (vty, argv[0], NULL, 0);
4430}
4431
4432ALIAS (no_neighbor_advertise_interval,
4433 no_neighbor_advertise_interval_val_cmd,
966f821c 4434 NO_NEIGHBOR_CMD2 "advertisement-interval <0-600>",
718e3744 4435 NO_STR
4436 NEIGHBOR_STR
966f821c 4437 NEIGHBOR_ADDR_STR2
718e3744 4438 "Minimum interval between sending BGP routing updates\n"
4439 "time in seconds\n")
6b0655a2 4440
518f0eb1
DS
4441/* Time to wait before processing route-map updates */
4442DEFUN (bgp_set_route_map_delay_timer,
4443 bgp_set_route_map_delay_timer_cmd,
4444 "bgp route-map delay-timer <0-600>",
4445 SET_STR
4446 "BGP route-map delay timer\n"
4447 "Time in secs to wait before processing route-map changes\n"
4448 "0 disables the timer and no route updates happen when\n"
4449 "route-maps change")
4450{
4451 u_int32_t rmap_delay_timer;
4452 struct bgp *bgp;
4453
4454 bgp = vty->index;
4455 if (argv[0])
4456 {
4457 VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[0], 0, 600);
4458 bgp->rmap_update_timer = rmap_delay_timer;
4459
4460 /* if the dynamic update handling is being disabled, and a timer is
4461 * running, stop the timer and act as if the timer has already fired.
4462 */
4463 if (!rmap_delay_timer && bgp->t_rmap_update )
4464 {
4465 BGP_TIMER_OFF(bgp->t_rmap_update);
4466 thread_execute (bm->master, bgp_route_map_update_timer, &bgp, 0);
4467 }
4468 return CMD_SUCCESS;
4469 }
4470 else
4471 CMD_WARNING;
4472}
4473
4474DEFUN (no_bgp_set_route_map_delay_timer,
4475 no_bgp_set_route_map_delay_timer_cmd,
4476 "no bgp route-map delay-timer",
4477 NO_STR
4478 "Default BGP route-map delay timer\n"
4479 "Reset to default time to wait for processing route-map changes")
4480{
4481 u_int32_t rmap_delay_timer;
4482 struct bgp *bgp;
4483
4484 bgp = vty->index;
4485 bgp->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER;
4486
4487 return CMD_SUCCESS;
4488}
4489
718e3744 4490/* neighbor interface */
94f2b392 4491static int
fd79ac91 4492peer_interface_vty (struct vty *vty, const char *ip_str, const char *str)
718e3744 4493{
4494 int ret;
4495 struct peer *peer;
4496
4497 peer = peer_lookup_vty (vty, ip_str);
a80beece 4498 if (! peer || peer->conf_if)
718e3744 4499 return CMD_WARNING;
4500
4501 if (str)
4502 ret = peer_interface_set (peer, str);
4503 else
4504 ret = peer_interface_unset (peer);
4505
4506 return CMD_SUCCESS;
4507}
4508
4509DEFUN (neighbor_interface,
4510 neighbor_interface_cmd,
4511 NEIGHBOR_CMD "interface WORD",
4512 NEIGHBOR_STR
4513 NEIGHBOR_ADDR_STR
4514 "Interface\n"
4515 "Interface name\n")
4516{
4517 return peer_interface_vty (vty, argv[0], argv[1]);
4518}
4519
4520DEFUN (no_neighbor_interface,
4521 no_neighbor_interface_cmd,
4522 NO_NEIGHBOR_CMD "interface WORD",
4523 NO_STR
4524 NEIGHBOR_STR
4525 NEIGHBOR_ADDR_STR
4526 "Interface\n"
4527 "Interface name\n")
4528{
4529 return peer_interface_vty (vty, argv[0], NULL);
4530}
6b0655a2 4531
718e3744 4532/* Set distribute list to the peer. */
94f2b392 4533static int
fd79ac91 4534peer_distribute_set_vty (struct vty *vty, const char *ip_str,
4535 afi_t afi, safi_t safi,
4536 const char *name_str, const char *direct_str)
718e3744 4537{
4538 int ret;
4539 struct peer *peer;
4540 int direct = FILTER_IN;
4541
4542 peer = peer_and_group_lookup_vty (vty, ip_str);
4543 if (! peer)
4544 return CMD_WARNING;
4545
4546 /* Check filter direction. */
4547 if (strncmp (direct_str, "i", 1) == 0)
4548 direct = FILTER_IN;
4549 else if (strncmp (direct_str, "o", 1) == 0)
4550 direct = FILTER_OUT;
4551
4552 ret = peer_distribute_set (peer, afi, safi, direct, name_str);
4553
4554 return bgp_vty_return (vty, ret);
4555}
4556
94f2b392 4557static int
fd79ac91 4558peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
4559 safi_t safi, const char *direct_str)
718e3744 4560{
4561 int ret;
4562 struct peer *peer;
4563 int direct = FILTER_IN;
4564
4565 peer = peer_and_group_lookup_vty (vty, ip_str);
4566 if (! peer)
4567 return CMD_WARNING;
4568
4569 /* Check filter direction. */
4570 if (strncmp (direct_str, "i", 1) == 0)
4571 direct = FILTER_IN;
4572 else if (strncmp (direct_str, "o", 1) == 0)
4573 direct = FILTER_OUT;
4574
4575 ret = peer_distribute_unset (peer, afi, safi, direct);
4576
4577 return bgp_vty_return (vty, ret);
4578}
4579
4580DEFUN (neighbor_distribute_list,
4581 neighbor_distribute_list_cmd,
4582 NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
4583 NEIGHBOR_STR
4584 NEIGHBOR_ADDR_STR2
4585 "Filter updates to/from this neighbor\n"
4586 "IP access-list number\n"
4587 "IP access-list number (expanded range)\n"
4588 "IP Access-list name\n"
4589 "Filter incoming updates\n"
4590 "Filter outgoing updates\n")
4591{
4592 return peer_distribute_set_vty (vty, argv[0], bgp_node_afi (vty),
4593 bgp_node_safi (vty), argv[1], argv[2]);
4594}
4595
4596DEFUN (no_neighbor_distribute_list,
4597 no_neighbor_distribute_list_cmd,
4598 NO_NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
4599 NO_STR
4600 NEIGHBOR_STR
4601 NEIGHBOR_ADDR_STR2
4602 "Filter updates to/from this neighbor\n"
4603 "IP access-list number\n"
4604 "IP access-list number (expanded range)\n"
4605 "IP Access-list name\n"
4606 "Filter incoming updates\n"
4607 "Filter outgoing updates\n")
4608{
4609 return peer_distribute_unset_vty (vty, argv[0], bgp_node_afi (vty),
4610 bgp_node_safi (vty), argv[2]);
4611}
6b0655a2 4612
718e3744 4613/* Set prefix list to the peer. */
94f2b392 4614static int
fd79ac91 4615peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
4616 safi_t safi, const char *name_str,
4617 const char *direct_str)
718e3744 4618{
4619 int ret;
4620 struct peer *peer;
4621 int direct = FILTER_IN;
4622
4623 peer = peer_and_group_lookup_vty (vty, ip_str);
4624 if (! peer)
4625 return CMD_WARNING;
4626
4627 /* Check filter direction. */
4628 if (strncmp (direct_str, "i", 1) == 0)
4629 direct = FILTER_IN;
4630 else if (strncmp (direct_str, "o", 1) == 0)
4631 direct = FILTER_OUT;
4632
4633 ret = peer_prefix_list_set (peer, afi, safi, direct, name_str);
4634
4635 return bgp_vty_return (vty, ret);
4636}
4637
94f2b392 4638static int
fd79ac91 4639peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
4640 safi_t safi, const char *direct_str)
718e3744 4641{
4642 int ret;
4643 struct peer *peer;
4644 int direct = FILTER_IN;
4645
4646 peer = peer_and_group_lookup_vty (vty, ip_str);
4647 if (! peer)
4648 return CMD_WARNING;
4649
4650 /* Check filter direction. */
4651 if (strncmp (direct_str, "i", 1) == 0)
4652 direct = FILTER_IN;
4653 else if (strncmp (direct_str, "o", 1) == 0)
4654 direct = FILTER_OUT;
4655
4656 ret = peer_prefix_list_unset (peer, afi, safi, direct);
4657
4658 return bgp_vty_return (vty, ret);
4659}
4660
4661DEFUN (neighbor_prefix_list,
4662 neighbor_prefix_list_cmd,
4663 NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
4664 NEIGHBOR_STR
4665 NEIGHBOR_ADDR_STR2
4666 "Filter updates to/from this neighbor\n"
4667 "Name of a prefix list\n"
4668 "Filter incoming updates\n"
4669 "Filter outgoing updates\n")
4670{
4671 return peer_prefix_list_set_vty (vty, argv[0], bgp_node_afi (vty),
4672 bgp_node_safi (vty), argv[1], argv[2]);
4673}
4674
4675DEFUN (no_neighbor_prefix_list,
4676 no_neighbor_prefix_list_cmd,
4677 NO_NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
4678 NO_STR
4679 NEIGHBOR_STR
4680 NEIGHBOR_ADDR_STR2
4681 "Filter updates to/from this neighbor\n"
4682 "Name of a prefix list\n"
4683 "Filter incoming updates\n"
4684 "Filter outgoing updates\n")
4685{
4686 return peer_prefix_list_unset_vty (vty, argv[0], bgp_node_afi (vty),
4687 bgp_node_safi (vty), argv[2]);
4688}
6b0655a2 4689
94f2b392 4690static int
fd79ac91 4691peer_aslist_set_vty (struct vty *vty, const char *ip_str,
4692 afi_t afi, safi_t safi,
4693 const char *name_str, const char *direct_str)
718e3744 4694{
4695 int ret;
4696 struct peer *peer;
4697 int direct = FILTER_IN;
4698
4699 peer = peer_and_group_lookup_vty (vty, ip_str);
4700 if (! peer)
4701 return CMD_WARNING;
4702
4703 /* Check filter direction. */
4704 if (strncmp (direct_str, "i", 1) == 0)
4705 direct = FILTER_IN;
4706 else if (strncmp (direct_str, "o", 1) == 0)
4707 direct = FILTER_OUT;
4708
4709 ret = peer_aslist_set (peer, afi, safi, direct, name_str);
4710
4711 return bgp_vty_return (vty, ret);
4712}
4713
94f2b392 4714static int
fd79ac91 4715peer_aslist_unset_vty (struct vty *vty, const char *ip_str,
4716 afi_t afi, safi_t safi,
4717 const char *direct_str)
718e3744 4718{
4719 int ret;
4720 struct peer *peer;
4721 int direct = FILTER_IN;
4722
4723 peer = peer_and_group_lookup_vty (vty, ip_str);
4724 if (! peer)
4725 return CMD_WARNING;
4726
4727 /* Check filter direction. */
4728 if (strncmp (direct_str, "i", 1) == 0)
4729 direct = FILTER_IN;
4730 else if (strncmp (direct_str, "o", 1) == 0)
4731 direct = FILTER_OUT;
4732
4733 ret = peer_aslist_unset (peer, afi, safi, direct);
4734
4735 return bgp_vty_return (vty, ret);
4736}
4737
4738DEFUN (neighbor_filter_list,
4739 neighbor_filter_list_cmd,
4740 NEIGHBOR_CMD2 "filter-list WORD (in|out)",
4741 NEIGHBOR_STR
4742 NEIGHBOR_ADDR_STR2
4743 "Establish BGP filters\n"
4744 "AS path access-list name\n"
4745 "Filter incoming routes\n"
4746 "Filter outgoing routes\n")
4747{
4748 return peer_aslist_set_vty (vty, argv[0], bgp_node_afi (vty),
4749 bgp_node_safi (vty), argv[1], argv[2]);
4750}
4751
4752DEFUN (no_neighbor_filter_list,
4753 no_neighbor_filter_list_cmd,
4754 NO_NEIGHBOR_CMD2 "filter-list WORD (in|out)",
4755 NO_STR
4756 NEIGHBOR_STR
4757 NEIGHBOR_ADDR_STR2
4758 "Establish BGP filters\n"
4759 "AS path access-list name\n"
4760 "Filter incoming routes\n"
4761 "Filter outgoing routes\n")
4762{
4763 return peer_aslist_unset_vty (vty, argv[0], bgp_node_afi (vty),
4764 bgp_node_safi (vty), argv[2]);
4765}
6b0655a2 4766
718e3744 4767/* Set route-map to the peer. */
94f2b392 4768static int
fd79ac91 4769peer_route_map_set_vty (struct vty *vty, const char *ip_str,
4770 afi_t afi, safi_t safi,
4771 const char *name_str, const char *direct_str)
718e3744 4772{
4773 int ret;
4774 struct peer *peer;
fee0f4c6 4775 int direct = RMAP_IN;
718e3744 4776
4777 peer = peer_and_group_lookup_vty (vty, ip_str);
4778 if (! peer)
4779 return CMD_WARNING;
4780
4781 /* Check filter direction. */
fee0f4c6 4782 if (strncmp (direct_str, "in", 2) == 0)
4783 direct = RMAP_IN;
718e3744 4784 else if (strncmp (direct_str, "o", 1) == 0)
fee0f4c6 4785 direct = RMAP_OUT;
4786 else if (strncmp (direct_str, "im", 2) == 0)
4787 direct = RMAP_IMPORT;
4788 else if (strncmp (direct_str, "e", 1) == 0)
4789 direct = RMAP_EXPORT;
718e3744 4790
4791 ret = peer_route_map_set (peer, afi, safi, direct, name_str);
4792
4793 return bgp_vty_return (vty, ret);
4794}
4795
94f2b392 4796static int
fd79ac91 4797peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
4798 safi_t safi, const char *direct_str)
718e3744 4799{
4800 int ret;
4801 struct peer *peer;
fee0f4c6 4802 int direct = RMAP_IN;
718e3744 4803
4804 peer = peer_and_group_lookup_vty (vty, ip_str);
4805 if (! peer)
4806 return CMD_WARNING;
4807
4808 /* Check filter direction. */
fee0f4c6 4809 if (strncmp (direct_str, "in", 2) == 0)
4810 direct = RMAP_IN;
718e3744 4811 else if (strncmp (direct_str, "o", 1) == 0)
fee0f4c6 4812 direct = RMAP_OUT;
4813 else if (strncmp (direct_str, "im", 2) == 0)
4814 direct = RMAP_IMPORT;
4815 else if (strncmp (direct_str, "e", 1) == 0)
4816 direct = RMAP_EXPORT;
718e3744 4817
4818 ret = peer_route_map_unset (peer, afi, safi, direct);
4819
4820 return bgp_vty_return (vty, ret);
4821}
4822
4823DEFUN (neighbor_route_map,
4824 neighbor_route_map_cmd,
fee0f4c6 4825 NEIGHBOR_CMD2 "route-map WORD (in|out|import|export)",
718e3744 4826 NEIGHBOR_STR
4827 NEIGHBOR_ADDR_STR2
4828 "Apply route map to neighbor\n"
4829 "Name of route map\n"
4830 "Apply map to incoming routes\n"
fee0f4c6 4831 "Apply map to outbound routes\n"
4832 "Apply map to routes going into a Route-Server client's table\n"
4833 "Apply map to routes coming from a Route-Server client")
718e3744 4834{
4835 return peer_route_map_set_vty (vty, argv[0], bgp_node_afi (vty),
4836 bgp_node_safi (vty), argv[1], argv[2]);
4837}
4838
4839DEFUN (no_neighbor_route_map,
4840 no_neighbor_route_map_cmd,
fee0f4c6 4841 NO_NEIGHBOR_CMD2 "route-map WORD (in|out|import|export)",
718e3744 4842 NO_STR
4843 NEIGHBOR_STR
4844 NEIGHBOR_ADDR_STR2
4845 "Apply route map to neighbor\n"
4846 "Name of route map\n"
4847 "Apply map to incoming routes\n"
fee0f4c6 4848 "Apply map to outbound routes\n"
4849 "Apply map to routes going into a Route-Server client's table\n"
4850 "Apply map to routes coming from a Route-Server client")
718e3744 4851{
4852 return peer_route_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
4853 bgp_node_safi (vty), argv[2]);
4854}
6b0655a2 4855
718e3744 4856/* Set unsuppress-map to the peer. */
94f2b392 4857static int
fd79ac91 4858peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
4859 safi_t safi, const char *name_str)
718e3744 4860{
4861 int ret;
4862 struct peer *peer;
4863
4864 peer = peer_and_group_lookup_vty (vty, ip_str);
4865 if (! peer)
4866 return CMD_WARNING;
4867
4868 ret = peer_unsuppress_map_set (peer, afi, safi, name_str);
4869
4870 return bgp_vty_return (vty, ret);
4871}
4872
4873/* Unset route-map from the peer. */
94f2b392 4874static int
fd79ac91 4875peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
718e3744 4876 safi_t safi)
4877{
4878 int ret;
4879 struct peer *peer;
4880
4881 peer = peer_and_group_lookup_vty (vty, ip_str);
4882 if (! peer)
4883 return CMD_WARNING;
4884
4885 ret = peer_unsuppress_map_unset (peer, afi, safi);
4886
4887 return bgp_vty_return (vty, ret);
4888}
4889
4890DEFUN (neighbor_unsuppress_map,
4891 neighbor_unsuppress_map_cmd,
4892 NEIGHBOR_CMD2 "unsuppress-map WORD",
4893 NEIGHBOR_STR
4894 NEIGHBOR_ADDR_STR2
4895 "Route-map to selectively unsuppress suppressed routes\n"
4896 "Name of route map\n")
4897{
4898 return peer_unsuppress_map_set_vty (vty, argv[0], bgp_node_afi (vty),
4899 bgp_node_safi (vty), argv[1]);
4900}
4901
4902DEFUN (no_neighbor_unsuppress_map,
4903 no_neighbor_unsuppress_map_cmd,
4904 NO_NEIGHBOR_CMD2 "unsuppress-map WORD",
4905 NO_STR
4906 NEIGHBOR_STR
4907 NEIGHBOR_ADDR_STR2
4908 "Route-map to selectively unsuppress suppressed routes\n"
4909 "Name of route map\n")
4910{
4911 return peer_unsuppress_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
4912 bgp_node_safi (vty));
4913}
6b0655a2 4914
94f2b392 4915static int
fd79ac91 4916peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
4917 safi_t safi, const char *num_str,
0a486e5f 4918 const char *threshold_str, int warning,
4919 const char *restart_str)
718e3744 4920{
4921 int ret;
4922 struct peer *peer;
4923 u_int32_t max;
e0701b79 4924 u_char threshold;
0a486e5f 4925 u_int16_t restart;
718e3744 4926
4927 peer = peer_and_group_lookup_vty (vty, ip_str);
4928 if (! peer)
4929 return CMD_WARNING;
4930
e6ec1c36 4931 VTY_GET_INTEGER ("maximum number", max, num_str);
e0701b79 4932 if (threshold_str)
4933 threshold = atoi (threshold_str);
4934 else
4935 threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT;
718e3744 4936
0a486e5f 4937 if (restart_str)
4938 restart = atoi (restart_str);
4939 else
4940 restart = 0;
4941
4942 ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart);
718e3744 4943
4944 return bgp_vty_return (vty, ret);
4945}
4946
94f2b392 4947static int
fd79ac91 4948peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
718e3744 4949 safi_t safi)
4950{
4951 int ret;
4952 struct peer *peer;
4953
4954 peer = peer_and_group_lookup_vty (vty, ip_str);
4955 if (! peer)
4956 return CMD_WARNING;
4957
4958 ret = peer_maximum_prefix_unset (peer, afi, safi);
4959
4960 return bgp_vty_return (vty, ret);
4961}
4962
4963/* Maximum number of prefix configuration. prefix count is different
4964 for each peer configuration. So this configuration can be set for
4965 each peer configuration. */
4966DEFUN (neighbor_maximum_prefix,
4967 neighbor_maximum_prefix_cmd,
4968 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
4969 NEIGHBOR_STR
4970 NEIGHBOR_ADDR_STR2
4971 "Maximum number of prefix accept from this peer\n"
4972 "maximum no. of prefix limit\n")
4973{
4974 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
0a486e5f 4975 bgp_node_safi (vty), argv[1], NULL, 0,
4976 NULL);
718e3744 4977}
4978
e0701b79 4979DEFUN (neighbor_maximum_prefix_threshold,
4980 neighbor_maximum_prefix_threshold_cmd,
4981 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100>",
4982 NEIGHBOR_STR
4983 NEIGHBOR_ADDR_STR2
4984 "Maximum number of prefix accept from this peer\n"
4985 "maximum no. of prefix limit\n"
4986 "Threshold value (%) at which to generate a warning msg\n")
4987{
4988 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
0a486e5f 4989 bgp_node_safi (vty), argv[1], argv[2], 0,
4990 NULL);
4991}
e0701b79 4992
718e3744 4993DEFUN (neighbor_maximum_prefix_warning,
4994 neighbor_maximum_prefix_warning_cmd,
4995 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
4996 NEIGHBOR_STR
4997 NEIGHBOR_ADDR_STR2
4998 "Maximum number of prefix accept from this peer\n"
4999 "maximum no. of prefix limit\n"
5000 "Only give warning message when limit is exceeded\n")
5001{
5002 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
0a486e5f 5003 bgp_node_safi (vty), argv[1], NULL, 1,
5004 NULL);
718e3744 5005}
5006
e0701b79 5007DEFUN (neighbor_maximum_prefix_threshold_warning,
5008 neighbor_maximum_prefix_threshold_warning_cmd,
5009 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
5010 NEIGHBOR_STR
5011 NEIGHBOR_ADDR_STR2
5012 "Maximum number of prefix accept from this peer\n"
5013 "maximum no. of prefix limit\n"
5014 "Threshold value (%) at which to generate a warning msg\n"
5015 "Only give warning message when limit is exceeded\n")
5016{
5017 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
0a486e5f 5018 bgp_node_safi (vty), argv[1], argv[2], 1, NULL);
5019}
5020
5021DEFUN (neighbor_maximum_prefix_restart,
5022 neighbor_maximum_prefix_restart_cmd,
5023 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
5024 NEIGHBOR_STR
5025 NEIGHBOR_ADDR_STR2
5026 "Maximum number of prefix accept from this peer\n"
5027 "maximum no. of prefix limit\n"
5028 "Restart bgp connection after limit is exceeded\n"
5029 "Restart interval in minutes")
5030{
5031 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
5032 bgp_node_safi (vty), argv[1], NULL, 0, argv[2]);
5033}
5034
5035DEFUN (neighbor_maximum_prefix_threshold_restart,
5036 neighbor_maximum_prefix_threshold_restart_cmd,
5037 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
5038 NEIGHBOR_STR
5039 NEIGHBOR_ADDR_STR2
5040 "Maximum number of prefix accept from this peer\n"
5041 "maximum no. of prefix limit\n"
5042 "Threshold value (%) at which to generate a warning msg\n"
5043 "Restart bgp connection after limit is exceeded\n"
5044 "Restart interval in minutes")
5045{
5046 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
5047 bgp_node_safi (vty), argv[1], argv[2], 0, argv[3]);
5048}
e0701b79 5049
718e3744 5050DEFUN (no_neighbor_maximum_prefix,
5051 no_neighbor_maximum_prefix_cmd,
5052 NO_NEIGHBOR_CMD2 "maximum-prefix",
5053 NO_STR
5054 NEIGHBOR_STR
5055 NEIGHBOR_ADDR_STR2
5056 "Maximum number of prefix accept from this peer\n")
5057{
5058 return peer_maximum_prefix_unset_vty (vty, argv[0], bgp_node_afi (vty),
5059 bgp_node_safi (vty));
5060}
5061
5062ALIAS (no_neighbor_maximum_prefix,
5063 no_neighbor_maximum_prefix_val_cmd,
5064 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
5065 NO_STR
5066 NEIGHBOR_STR
5067 NEIGHBOR_ADDR_STR2
5068 "Maximum number of prefix accept from this peer\n"
5069 "maximum no. of prefix limit\n")
5070
5071ALIAS (no_neighbor_maximum_prefix,
0a486e5f 5072 no_neighbor_maximum_prefix_threshold_cmd,
5073 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
5074 NO_STR
5075 NEIGHBOR_STR
5076 NEIGHBOR_ADDR_STR2
5077 "Maximum number of prefix accept from this peer\n"
5078 "maximum no. of prefix limit\n"
5079 "Threshold value (%) at which to generate a warning msg\n")
5080
5081ALIAS (no_neighbor_maximum_prefix,
5082 no_neighbor_maximum_prefix_warning_cmd,
5083 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
5084 NO_STR
5085 NEIGHBOR_STR
5086 NEIGHBOR_ADDR_STR2
5087 "Maximum number of prefix accept from this peer\n"
5088 "maximum no. of prefix limit\n"
e8e1946e 5089 "Only give warning message when limit is exceeded\n")
0a486e5f 5090
5091ALIAS (no_neighbor_maximum_prefix,
5092 no_neighbor_maximum_prefix_threshold_warning_cmd,
e0701b79 5093 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
5094 NO_STR
5095 NEIGHBOR_STR
5096 NEIGHBOR_ADDR_STR2
5097 "Maximum number of prefix accept from this peer\n"
5098 "maximum no. of prefix limit\n"
5099 "Threshold value (%) at which to generate a warning msg\n"
e8e1946e 5100 "Only give warning message when limit is exceeded\n")
e0701b79 5101
5102ALIAS (no_neighbor_maximum_prefix,
0a486e5f 5103 no_neighbor_maximum_prefix_restart_cmd,
5104 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
718e3744 5105 NO_STR
5106 NEIGHBOR_STR
5107 NEIGHBOR_ADDR_STR2
5108 "Maximum number of prefix accept from this peer\n"
5109 "maximum no. of prefix limit\n"
0a486e5f 5110 "Restart bgp connection after limit is exceeded\n"
5111 "Restart interval in minutes")
5112
5113ALIAS (no_neighbor_maximum_prefix,
5114 no_neighbor_maximum_prefix_threshold_restart_cmd,
5115 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
5116 NO_STR
5117 NEIGHBOR_STR
5118 NEIGHBOR_ADDR_STR2
5119 "Maximum number of prefix accept from this peer\n"
5120 "maximum no. of prefix limit\n"
5121 "Threshold value (%) at which to generate a warning msg\n"
5122 "Restart bgp connection after limit is exceeded\n"
5123 "Restart interval in minutes")
6b0655a2 5124
718e3744 5125/* "neighbor allowas-in" */
5126DEFUN (neighbor_allowas_in,
5127 neighbor_allowas_in_cmd,
5128 NEIGHBOR_CMD2 "allowas-in",
5129 NEIGHBOR_STR
5130 NEIGHBOR_ADDR_STR2
5131 "Accept as-path with my AS present in it\n")
5132{
5133 int ret;
5134 struct peer *peer;
fd79ac91 5135 unsigned int allow_num;
718e3744 5136
5137 peer = peer_and_group_lookup_vty (vty, argv[0]);
5138 if (! peer)
5139 return CMD_WARNING;
5140
5141 if (argc == 1)
5142 allow_num = 3;
5143 else
5144 VTY_GET_INTEGER_RANGE ("AS number", allow_num, argv[1], 1, 10);
5145
5146 ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty),
5147 allow_num);
5148
5149 return bgp_vty_return (vty, ret);
5150}
5151
5152ALIAS (neighbor_allowas_in,
5153 neighbor_allowas_in_arg_cmd,
5154 NEIGHBOR_CMD2 "allowas-in <1-10>",
5155 NEIGHBOR_STR
5156 NEIGHBOR_ADDR_STR2
5157 "Accept as-path with my AS present in it\n"
5158 "Number of occurances of AS number\n")
5159
5160DEFUN (no_neighbor_allowas_in,
5161 no_neighbor_allowas_in_cmd,
5162 NO_NEIGHBOR_CMD2 "allowas-in",
5163 NO_STR
5164 NEIGHBOR_STR
5165 NEIGHBOR_ADDR_STR2
5166 "allow local ASN appears in aspath attribute\n")
5167{
5168 int ret;
5169 struct peer *peer;
5170
5171 peer = peer_and_group_lookup_vty (vty, argv[0]);
5172 if (! peer)
5173 return CMD_WARNING;
5174
5175 ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty));
5176
5177 return bgp_vty_return (vty, ret);
5178}
6b0655a2 5179
fa411a21
NH
5180DEFUN (neighbor_ttl_security,
5181 neighbor_ttl_security_cmd,
5182 NEIGHBOR_CMD2 "ttl-security hops <1-254>",
5183 NEIGHBOR_STR
5184 NEIGHBOR_ADDR_STR2
5185 "Specify the maximum number of hops to the BGP peer\n")
5186{
5187 struct peer *peer;
89b6d1f8 5188 int gtsm_hops;
fa411a21
NH
5189
5190 peer = peer_and_group_lookup_vty (vty, argv[0]);
5191 if (! peer)
5192 return CMD_WARNING;
5193
5194 VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[1], 1, 254);
5195
89b6d1f8 5196 return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, gtsm_hops));
fa411a21
NH
5197}
5198
5199DEFUN (no_neighbor_ttl_security,
5200 no_neighbor_ttl_security_cmd,
5201 NO_NEIGHBOR_CMD2 "ttl-security hops <1-254>",
5202 NO_STR
5203 NEIGHBOR_STR
5204 NEIGHBOR_ADDR_STR2
5205 "Specify the maximum number of hops to the BGP peer\n")
5206{
5207 struct peer *peer;
fa411a21
NH
5208
5209 peer = peer_and_group_lookup_vty (vty, argv[0]);
5210 if (! peer)
5211 return CMD_WARNING;
5212
89b6d1f8 5213 return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer));
fa411a21 5214}
6b0655a2 5215
718e3744 5216/* Address family configuration. */
5217DEFUN (address_family_ipv4,
5218 address_family_ipv4_cmd,
5219 "address-family ipv4",
5220 "Enter Address Family command mode\n"
5221 "Address family\n")
5222{
5223 vty->node = BGP_IPV4_NODE;
5224 return CMD_SUCCESS;
5225}
5226
5227DEFUN (address_family_ipv4_safi,
5228 address_family_ipv4_safi_cmd,
5229 "address-family ipv4 (unicast|multicast)",
5230 "Enter Address Family command mode\n"
5231 "Address family\n"
5232 "Address Family modifier\n"
5233 "Address Family modifier\n")
5234{
5235 if (strncmp (argv[0], "m", 1) == 0)
5236 vty->node = BGP_IPV4M_NODE;
5237 else
5238 vty->node = BGP_IPV4_NODE;
5239
5240 return CMD_SUCCESS;
5241}
5242
25ffbdc1 5243DEFUN (address_family_ipv6,
5244 address_family_ipv6_cmd,
5245 "address-family ipv6",
718e3744 5246 "Enter Address Family command mode\n"
25ffbdc1 5247 "Address family\n")
718e3744 5248{
5249 vty->node = BGP_IPV6_NODE;
5250 return CMD_SUCCESS;
5251}
5252
25ffbdc1 5253DEFUN (address_family_ipv6_safi,
5254 address_family_ipv6_safi_cmd,
5255 "address-family ipv6 (unicast|multicast)",
718e3744 5256 "Enter Address Family command mode\n"
25ffbdc1 5257 "Address family\n"
5258 "Address Family modifier\n"
5259 "Address Family modifier\n")
5260{
5261 if (strncmp (argv[0], "m", 1) == 0)
5262 vty->node = BGP_IPV6M_NODE;
5263 else
5264 vty->node = BGP_IPV6_NODE;
5265
5266 return CMD_SUCCESS;
5267}
718e3744 5268
5269DEFUN (address_family_vpnv4,
5270 address_family_vpnv4_cmd,
5271 "address-family vpnv4",
5272 "Enter Address Family command mode\n"
5273 "Address family\n")
5274{
5275 vty->node = BGP_VPNV4_NODE;
5276 return CMD_SUCCESS;
5277}
5278
5279ALIAS (address_family_vpnv4,
5280 address_family_vpnv4_unicast_cmd,
5281 "address-family vpnv4 unicast",
5282 "Enter Address Family command mode\n"
5283 "Address family\n"
5284 "Address Family Modifier\n")
5285
5286DEFUN (exit_address_family,
5287 exit_address_family_cmd,
5288 "exit-address-family",
5289 "Exit from Address Family configuration mode\n")
5290{
a8a80d53 5291 if (vty->node == BGP_IPV4_NODE
5292 || vty->node == BGP_IPV4M_NODE
718e3744 5293 || vty->node == BGP_VPNV4_NODE
25ffbdc1 5294 || vty->node == BGP_IPV6_NODE
5295 || vty->node == BGP_IPV6M_NODE)
718e3744 5296 vty->node = BGP_NODE;
5297 return CMD_SUCCESS;
5298}
6b0655a2 5299
718e3744 5300/* BGP clear sort. */
5301enum clear_sort
5302{
5303 clear_all,
5304 clear_peer,
5305 clear_group,
5306 clear_external,
5307 clear_as
5308};
5309
94f2b392 5310static void
718e3744 5311bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi,
5312 safi_t safi, int error)
5313{
5314 switch (error)
5315 {
5316 case BGP_ERR_AF_UNCONFIGURED:
5317 vty_out (vty,
5318 "%%BGP: Enable %s %s address family for the neighbor %s%s",
5319 afi == AFI_IP6 ? "IPv6" : safi == SAFI_MPLS_VPN ? "VPNv4" : "IPv4",
5320 safi == SAFI_MULTICAST ? "Multicast" : "Unicast",
5321 peer->host, VTY_NEWLINE);
5322 break;
5323 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED:
5324 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);
5325 break;
5326 default:
5327 break;
5328 }
5329}
5330
5331/* `clear ip bgp' functions. */
94f2b392 5332static int
718e3744 5333bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
fd79ac91 5334 enum clear_sort sort,enum bgp_clear_type stype, const char *arg)
718e3744 5335{
5336 int ret;
5337 struct peer *peer;
1eb8ef25 5338 struct listnode *node, *nnode;
718e3744 5339
5340 /* Clear all neighbors. */
1ff9a340
DS
5341 /*
5342 * Pass along pointer to next node to peer_clear() when walking all nodes
5343 * on the BGP instance as that may get freed if it is a doppelganger
5344 */
718e3744 5345 if (sort == clear_all)
5346 {
1eb8ef25 5347 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
718e3744 5348 {
5349 if (stype == BGP_CLEAR_SOFT_NONE)
1ff9a340 5350 ret = peer_clear (peer, &nnode);
718e3744 5351 else
5352 ret = peer_clear_soft (peer, afi, safi, stype);
5353
5354 if (ret < 0)
5355 bgp_clear_vty_error (vty, peer, afi, safi, ret);
5356 }
f188f2c4
DS
5357
5358 /* This is to apply read-only mode on this clear. */
5359 if (stype == BGP_CLEAR_SOFT_NONE)
5360 bgp->update_delay_over = 0;
5361
0b2aa3a0 5362 return CMD_SUCCESS;
718e3744 5363 }
5364
5365 /* Clear specified neighbors. */
5366 if (sort == clear_peer)
5367 {
5368 union sockunion su;
5369 int ret;
5370
5371 /* Make sockunion for lookup. */
5372 ret = str2sockunion (arg, &su);
5373 if (ret < 0)
a80beece
DS
5374 {
5375 peer = peer_lookup_by_conf_if (bgp, arg);
5376 if (!peer)
5377 {
5378 vty_out (vty, "Malformed address or name: %s%s", arg, VTY_NEWLINE);
5379 return CMD_WARNING;
5380 }
5381 }
5382 else
5383 {
5384 peer = peer_lookup (bgp, &su);
5385 if (! peer)
5386 {
5387 vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE);
5388 return CMD_WARNING;
5389 }
5390 }
718e3744 5391
5392 if (stype == BGP_CLEAR_SOFT_NONE)
1ff9a340 5393 ret = peer_clear (peer, NULL);
718e3744 5394 else
5395 ret = peer_clear_soft (peer, afi, safi, stype);
5396
5397 if (ret < 0)
5398 bgp_clear_vty_error (vty, peer, afi, safi, ret);
5399
0b2aa3a0 5400 return CMD_SUCCESS;
718e3744 5401 }
5402
5403 /* Clear all peer-group members. */
5404 if (sort == clear_group)
5405 {
5406 struct peer_group *group;
5407
5408 group = peer_group_lookup (bgp, arg);
5409 if (! group)
5410 {
5411 vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE);
0b2aa3a0 5412 return CMD_WARNING;
718e3744 5413 }
5414
1eb8ef25 5415 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
718e3744 5416 {
5417 if (stype == BGP_CLEAR_SOFT_NONE)
5418 {
1ff9a340 5419 ret = peer_clear (peer, NULL);
718e3744 5420 continue;
5421 }
5422
5423 if (! peer->af_group[afi][safi])
5424 continue;
5425
5426 ret = peer_clear_soft (peer, afi, safi, stype);
5427
5428 if (ret < 0)
5429 bgp_clear_vty_error (vty, peer, afi, safi, ret);
5430 }
0b2aa3a0 5431 return CMD_SUCCESS;
718e3744 5432 }
5433
5434 if (sort == clear_external)
5435 {
1eb8ef25 5436 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
718e3744 5437 {
6d85b15b 5438 if (peer->sort == BGP_PEER_IBGP)
718e3744 5439 continue;
5440
5441 if (stype == BGP_CLEAR_SOFT_NONE)
1ff9a340 5442 ret = peer_clear (peer, &nnode);
718e3744 5443 else
5444 ret = peer_clear_soft (peer, afi, safi, stype);
5445
5446 if (ret < 0)
5447 bgp_clear_vty_error (vty, peer, afi, safi, ret);
5448 }
0b2aa3a0 5449 return CMD_SUCCESS;
718e3744 5450 }
5451
5452 if (sort == clear_as)
5453 {
5454 as_t as;
718e3744 5455 int find = 0;
5456
bde12e3f 5457 VTY_GET_INTEGER_RANGE ("AS", as, arg, 1, BGP_AS4_MAX);
0b2aa3a0 5458
1eb8ef25 5459 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
718e3744 5460 {
5461 if (peer->as != as)
5462 continue;
5463
5464 find = 1;
5465 if (stype == BGP_CLEAR_SOFT_NONE)
1ff9a340 5466 ret = peer_clear (peer, &nnode);
718e3744 5467 else
5468 ret = peer_clear_soft (peer, afi, safi, stype);
5469
5470 if (ret < 0)
5471 bgp_clear_vty_error (vty, peer, afi, safi, ret);
5472 }
5473 if (! find)
5474 vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg,
5475 VTY_NEWLINE);
0b2aa3a0 5476 return CMD_SUCCESS;
718e3744 5477 }
5478
0b2aa3a0 5479 return CMD_SUCCESS;
718e3744 5480}
5481
8ad7271d
DS
5482/* Recalculate bestpath and re-advertise a prefix */
5483static int
5484bgp_clear_prefix (struct vty *vty, char *view_name, const char *ip_str,
5485 afi_t afi, safi_t safi, struct prefix_rd *prd)
5486{
5487 int ret;
5488 struct prefix match;
5489 struct bgp_node *rn;
5490 struct bgp_node *rm;
5491 struct bgp_info *ri;
5492 struct bgp_info *ri_temp;
5493 struct bgp *bgp;
5494 struct bgp_table *table;
5495 struct bgp_table *rib;
5496
5497 /* BGP structure lookup. */
5498 if (view_name)
5499 {
5500 bgp = bgp_lookup_by_name (view_name);
5501 if (bgp == NULL)
5502 {
5503 vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE);
5504 return CMD_WARNING;
5505 }
5506 }
5507 else
5508 {
5509 bgp = bgp_get_default ();
5510 if (bgp == NULL)
5511 {
5512 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
5513 return CMD_WARNING;
5514 }
5515 }
5516
5517 /* Check IP address argument. */
5518 ret = str2prefix (ip_str, &match);
5519 if (! ret)
5520 {
5521 vty_out (vty, "%% address is malformed%s", VTY_NEWLINE);
5522 return CMD_WARNING;
5523 }
5524
5525 match.family = afi2family (afi);
5526 rib = bgp->rib[afi][safi];
5527
5528 if (safi == SAFI_MPLS_VPN)
5529 {
5530 for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn))
5531 {
5532 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
5533 continue;
5534
5535 if ((table = rn->info) != NULL)
5536 {
5537 if ((rm = bgp_node_match (table, &match)) != NULL)
5538 {
5539 if (rm->p.prefixlen == match.prefixlen)
5540 {
5541 SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR);
5542 bgp_process (bgp, rm, afi, safi);
5543 }
5544 bgp_unlock_node (rm);
5545 }
5546 }
5547 }
5548 }
5549 else
5550 {
5551 if ((rn = bgp_node_match (rib, &match)) != NULL)
5552 {
5553 if (rn->p.prefixlen == match.prefixlen)
5554 {
5555 SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR);
5556 bgp_process (bgp, rn, afi, safi);
5557 }
5558 bgp_unlock_node (rn);
5559 }
5560 }
5561
5562 return CMD_SUCCESS;
5563}
5564
94f2b392 5565static int
fd79ac91 5566bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi,
5567 enum clear_sort sort, enum bgp_clear_type stype,
5568 const char *arg)
718e3744 5569{
718e3744 5570 struct bgp *bgp;
5571
5572 /* BGP structure lookup. */
5573 if (name)
5574 {
5575 bgp = bgp_lookup_by_name (name);
5576 if (bgp == NULL)
5577 {
5578 vty_out (vty, "Can't find BGP view %s%s", name, VTY_NEWLINE);
5579 return CMD_WARNING;
5580 }
5581 }
5582 else
5583 {
5584 bgp = bgp_get_default ();
5585 if (bgp == NULL)
5586 {
5587 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
5588 return CMD_WARNING;
5589 }
5590 }
5591
0b2aa3a0 5592 return bgp_clear (vty, bgp, afi, safi, sort, stype, arg);
718e3744 5593}
5594
5595DEFUN (clear_ip_bgp_all,
5596 clear_ip_bgp_all_cmd,
5597 "clear ip bgp *",
5598 CLEAR_STR
5599 IP_STR
5600 BGP_STR
5601 "Clear all peers\n")
5602{
5603 if (argc == 1)
5604 return bgp_clear_vty (vty, argv[0], 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
5605
5606 return bgp_clear_vty (vty, NULL, 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
5607}
5608
5609ALIAS (clear_ip_bgp_all,
5610 clear_bgp_all_cmd,
5611 "clear bgp *",
5612 CLEAR_STR
5613 BGP_STR
5614 "Clear all peers\n")
5615
5616ALIAS (clear_ip_bgp_all,
5617 clear_bgp_ipv6_all_cmd,
5618 "clear bgp ipv6 *",
5619 CLEAR_STR
5620 BGP_STR
5621 "Address family\n"
5622 "Clear all peers\n")
5623
5624ALIAS (clear_ip_bgp_all,
5625 clear_ip_bgp_instance_all_cmd,
5626 "clear ip bgp view WORD *",
5627 CLEAR_STR
5628 IP_STR
5629 BGP_STR
5630 "BGP view\n"
5631 "view name\n"
5632 "Clear all peers\n")
5633
5634ALIAS (clear_ip_bgp_all,
5635 clear_bgp_instance_all_cmd,
5636 "clear bgp view WORD *",
5637 CLEAR_STR
5638 BGP_STR
5639 "BGP view\n"
5640 "view name\n"
5641 "Clear all peers\n")
5642
5643DEFUN (clear_ip_bgp_peer,
5644 clear_ip_bgp_peer_cmd,
a80beece 5645 "clear ip bgp (A.B.C.D|X:X::X:X|WORD)",
718e3744 5646 CLEAR_STR
5647 IP_STR
5648 BGP_STR
5649 "BGP neighbor IP address to clear\n"
a80beece
DS
5650 "BGP IPv6 neighbor to clear\n"
5651 "BGP neighbor on interface to clear\n")
718e3744 5652{
5653 return bgp_clear_vty (vty, NULL, 0, 0, clear_peer, BGP_CLEAR_SOFT_NONE, argv[0]);
5654}
5655
5656ALIAS (clear_ip_bgp_peer,
5657 clear_bgp_peer_cmd,
a80beece 5658 "clear bgp (A.B.C.D|X:X::X:X|WORD)",
718e3744 5659 CLEAR_STR
5660 BGP_STR
5661 "BGP neighbor address to clear\n"
a80beece
DS
5662 "BGP IPv6 neighbor to clear\n"
5663 "BGP neighbor on interface to clear\n")
718e3744 5664
5665ALIAS (clear_ip_bgp_peer,
5666 clear_bgp_ipv6_peer_cmd,
a80beece 5667 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD)",
718e3744 5668 CLEAR_STR
5669 BGP_STR
5670 "Address family\n"
5671 "BGP neighbor address to clear\n"
a80beece
DS
5672 "BGP IPv6 neighbor to clear\n"
5673 "BGP neighbor on interface to clear\n")
718e3744 5674
5675DEFUN (clear_ip_bgp_peer_group,
5676 clear_ip_bgp_peer_group_cmd,
5677 "clear ip bgp peer-group WORD",
5678 CLEAR_STR
5679 IP_STR
5680 BGP_STR
5681 "Clear all members of peer-group\n"
5682 "BGP peer-group name\n")
5683{
5684 return bgp_clear_vty (vty, NULL, 0, 0, clear_group, BGP_CLEAR_SOFT_NONE, argv[0]);
5685}
5686
5687ALIAS (clear_ip_bgp_peer_group,
5688 clear_bgp_peer_group_cmd,
5689 "clear bgp peer-group WORD",
5690 CLEAR_STR
5691 BGP_STR
5692 "Clear all members of peer-group\n"
5693 "BGP peer-group name\n")
5694
5695ALIAS (clear_ip_bgp_peer_group,
5696 clear_bgp_ipv6_peer_group_cmd,
5697 "clear bgp ipv6 peer-group WORD",
5698 CLEAR_STR
5699 BGP_STR
5700 "Address family\n"
5701 "Clear all members of peer-group\n"
5702 "BGP peer-group name\n")
5703
5704DEFUN (clear_ip_bgp_external,
5705 clear_ip_bgp_external_cmd,
5706 "clear ip bgp external",
5707 CLEAR_STR
5708 IP_STR
5709 BGP_STR
5710 "Clear all external peers\n")
5711{
5712 return bgp_clear_vty (vty, NULL, 0, 0, clear_external, BGP_CLEAR_SOFT_NONE, NULL);
5713}
5714
5715ALIAS (clear_ip_bgp_external,
5716 clear_bgp_external_cmd,
5717 "clear bgp external",
5718 CLEAR_STR
5719 BGP_STR
5720 "Clear all external peers\n")
5721
5722ALIAS (clear_ip_bgp_external,
5723 clear_bgp_ipv6_external_cmd,
5724 "clear bgp ipv6 external",
5725 CLEAR_STR
5726 BGP_STR
5727 "Address family\n"
5728 "Clear all external peers\n")
5729
8ad7271d
DS
5730DEFUN (clear_ip_bgp_prefix,
5731 clear_ip_bgp_prefix_cmd,
5732 "clear ip bgp prefix A.B.C.D/M",
5733 CLEAR_STR
5734 IP_STR
5735 BGP_STR
5736 "Clear bestpath and re-advertise\n"
5737 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
5738{
5739 return bgp_clear_prefix (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL);
5740}
5741
5742ALIAS (clear_ip_bgp_prefix,
5743 clear_bgp_prefix_cmd,
5744 "clear bgp prefix A.B.C.D/M",
5745 CLEAR_STR
5746 BGP_STR
5747 "Clear bestpath and re-advertise\n"
5748 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
5749
5750
718e3744 5751DEFUN (clear_ip_bgp_as,
5752 clear_ip_bgp_as_cmd,
320da874 5753 "clear ip bgp " CMD_AS_RANGE,
718e3744 5754 CLEAR_STR
5755 IP_STR
5756 BGP_STR
5757 "Clear peers with the AS number\n")
5758{
5759 return bgp_clear_vty (vty, NULL, 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[0]);
5760}
5761
5762ALIAS (clear_ip_bgp_as,
5763 clear_bgp_as_cmd,
320da874 5764 "clear bgp " CMD_AS_RANGE,
718e3744 5765 CLEAR_STR
5766 BGP_STR
5767 "Clear peers with the AS number\n")
5768
5769ALIAS (clear_ip_bgp_as,
5770 clear_bgp_ipv6_as_cmd,
320da874 5771 "clear bgp ipv6 " CMD_AS_RANGE,
718e3744 5772 CLEAR_STR
5773 BGP_STR
5774 "Address family\n"
5775 "Clear peers with the AS number\n")
6b0655a2 5776
718e3744 5777/* Outbound soft-reconfiguration */
5778DEFUN (clear_ip_bgp_all_soft_out,
5779 clear_ip_bgp_all_soft_out_cmd,
5780 "clear ip bgp * soft out",
5781 CLEAR_STR
5782 IP_STR
5783 BGP_STR
5784 "Clear all peers\n"
e0bce756
DS
5785 BGP_SOFT_STR
5786 BGP_SOFT_OUT_STR)
718e3744 5787{
5788 if (argc == 1)
5789 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5790 BGP_CLEAR_SOFT_OUT, NULL);
5791
5792 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5793 BGP_CLEAR_SOFT_OUT, NULL);
5794}
5795
5796ALIAS (clear_ip_bgp_all_soft_out,
5797 clear_ip_bgp_all_out_cmd,
5798 "clear ip bgp * out",
5799 CLEAR_STR
5800 IP_STR
5801 BGP_STR
5802 "Clear all peers\n"
e0bce756 5803 BGP_SOFT_OUT_STR)
718e3744 5804
5805ALIAS (clear_ip_bgp_all_soft_out,
5806 clear_ip_bgp_instance_all_soft_out_cmd,
5807 "clear ip bgp view WORD * soft out",
5808 CLEAR_STR
5809 IP_STR
5810 BGP_STR
5811 "BGP view\n"
5812 "view name\n"
5813 "Clear all peers\n"
e0bce756
DS
5814 BGP_SOFT_STR
5815 BGP_SOFT_OUT_STR)
718e3744 5816
5817DEFUN (clear_ip_bgp_all_ipv4_soft_out,
5818 clear_ip_bgp_all_ipv4_soft_out_cmd,
5819 "clear ip bgp * ipv4 (unicast|multicast) soft out",
5820 CLEAR_STR
5821 IP_STR
5822 BGP_STR
5823 "Clear all peers\n"
5824 "Address family\n"
5825 "Address Family modifier\n"
5826 "Address Family modifier\n"
e0bce756
DS
5827 BGP_SOFT_STR
5828 BGP_SOFT_OUT_STR)
718e3744 5829{
5830 if (strncmp (argv[0], "m", 1) == 0)
5831 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
5832 BGP_CLEAR_SOFT_OUT, NULL);
5833
5834 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5835 BGP_CLEAR_SOFT_OUT, NULL);
5836}
5837
5838ALIAS (clear_ip_bgp_all_ipv4_soft_out,
5839 clear_ip_bgp_all_ipv4_out_cmd,
5840 "clear ip bgp * ipv4 (unicast|multicast) out",
5841 CLEAR_STR
5842 IP_STR
5843 BGP_STR
5844 "Clear all peers\n"
5845 "Address family\n"
5846 "Address Family modifier\n"
5847 "Address Family modifier\n"
e0bce756 5848 BGP_SOFT_OUT_STR)
718e3744 5849
5850DEFUN (clear_ip_bgp_instance_all_ipv4_soft_out,
5851 clear_ip_bgp_instance_all_ipv4_soft_out_cmd,
5852 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft out",
5853 CLEAR_STR
5854 IP_STR
5855 BGP_STR
5856 "BGP view\n"
5857 "view name\n"
5858 "Clear all peers\n"
5859 "Address family\n"
5860 "Address Family modifier\n"
5861 "Address Family modifier\n"
e0bce756 5862 BGP_SOFT_OUT_STR)
718e3744 5863{
5864 if (strncmp (argv[1], "m", 1) == 0)
5865 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
5866 BGP_CLEAR_SOFT_OUT, NULL);
5867
5868 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5869 BGP_CLEAR_SOFT_OUT, NULL);
5870}
5871
5872DEFUN (clear_ip_bgp_all_vpnv4_soft_out,
5873 clear_ip_bgp_all_vpnv4_soft_out_cmd,
5874 "clear ip bgp * vpnv4 unicast soft out",
5875 CLEAR_STR
5876 IP_STR
5877 BGP_STR
5878 "Clear all peers\n"
5879 "Address family\n"
5880 "Address Family Modifier\n"
e0bce756
DS
5881 BGP_SOFT_STR
5882 BGP_SOFT_OUT_STR)
718e3744 5883{
5884 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
5885 BGP_CLEAR_SOFT_OUT, NULL);
5886}
5887
5888ALIAS (clear_ip_bgp_all_vpnv4_soft_out,
5889 clear_ip_bgp_all_vpnv4_out_cmd,
5890 "clear ip bgp * vpnv4 unicast out",
5891 CLEAR_STR
5892 IP_STR
5893 BGP_STR
5894 "Clear all peers\n"
5895 "Address family\n"
5896 "Address Family Modifier\n"
e0bce756 5897 BGP_SOFT_OUT_STR)
718e3744 5898
5899DEFUN (clear_bgp_all_soft_out,
5900 clear_bgp_all_soft_out_cmd,
5901 "clear bgp * soft out",
5902 CLEAR_STR
5903 BGP_STR
5904 "Clear all peers\n"
e0bce756
DS
5905 BGP_SOFT_STR
5906 BGP_SOFT_OUT_STR)
718e3744 5907{
5908 if (argc == 1)
5909 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
5910 BGP_CLEAR_SOFT_OUT, NULL);
5911
5912 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
5913 BGP_CLEAR_SOFT_OUT, NULL);
5914}
5915
5916ALIAS (clear_bgp_all_soft_out,
5917 clear_bgp_instance_all_soft_out_cmd,
5918 "clear bgp view WORD * soft out",
5919 CLEAR_STR
5920 BGP_STR
5921 "BGP view\n"
5922 "view name\n"
5923 "Clear all peers\n"
e0bce756
DS
5924 BGP_SOFT_STR
5925 BGP_SOFT_OUT_STR)
718e3744 5926
5927ALIAS (clear_bgp_all_soft_out,
5928 clear_bgp_all_out_cmd,
5929 "clear bgp * out",
5930 CLEAR_STR
5931 BGP_STR
5932 "Clear all peers\n"
e0bce756 5933 BGP_SOFT_OUT_STR)
718e3744 5934
5935ALIAS (clear_bgp_all_soft_out,
5936 clear_bgp_ipv6_all_soft_out_cmd,
5937 "clear bgp ipv6 * soft out",
5938 CLEAR_STR
5939 BGP_STR
5940 "Address family\n"
5941 "Clear all peers\n"
e0bce756
DS
5942 BGP_SOFT_STR
5943 BGP_SOFT_OUT_STR)
718e3744 5944
5945ALIAS (clear_bgp_all_soft_out,
5946 clear_bgp_ipv6_all_out_cmd,
5947 "clear bgp ipv6 * out",
5948 CLEAR_STR
5949 BGP_STR
5950 "Address family\n"
5951 "Clear all peers\n"
e0bce756 5952 BGP_SOFT_OUT_STR)
718e3744 5953
8ad7271d
DS
5954DEFUN (clear_bgp_ipv6_safi_prefix,
5955 clear_bgp_ipv6_safi_prefix_cmd,
5956 "clear bgp ipv6 (unicast|multicast) prefix X:X::X:X/M",
5957 CLEAR_STR
5958 BGP_STR
5959 "Address family\n"
5960 "Address Family Modifier\n"
5961 "Clear bestpath and re-advertise\n"
5962 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
5963{
5964 if (strncmp (argv[0], "m", 1) == 0)
5965 return bgp_clear_prefix (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL);
5966 else
5967 return bgp_clear_prefix (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL);
5968}
5969
718e3744 5970DEFUN (clear_ip_bgp_peer_soft_out,
5971 clear_ip_bgp_peer_soft_out_cmd,
5972 "clear ip bgp A.B.C.D soft out",
5973 CLEAR_STR
5974 IP_STR
5975 BGP_STR
5976 "BGP neighbor address to clear\n"
e0bce756
DS
5977 BGP_SOFT_STR
5978 BGP_SOFT_OUT_STR)
718e3744 5979{
5980 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5981 BGP_CLEAR_SOFT_OUT, argv[0]);
5982}
5983
5984ALIAS (clear_ip_bgp_peer_soft_out,
5985 clear_ip_bgp_peer_out_cmd,
5986 "clear ip bgp A.B.C.D out",
5987 CLEAR_STR
5988 IP_STR
5989 BGP_STR
5990 "BGP neighbor address to clear\n"
e0bce756 5991 BGP_SOFT_OUT_STR)
718e3744 5992
5993DEFUN (clear_ip_bgp_peer_ipv4_soft_out,
5994 clear_ip_bgp_peer_ipv4_soft_out_cmd,
5995 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft out",
5996 CLEAR_STR
5997 IP_STR
5998 BGP_STR
5999 "BGP neighbor address to clear\n"
6000 "Address family\n"
6001 "Address Family modifier\n"
6002 "Address Family modifier\n"
e0bce756
DS
6003 BGP_SOFT_STR
6004 BGP_SOFT_OUT_STR)
718e3744 6005{
6006 if (strncmp (argv[1], "m", 1) == 0)
6007 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
6008 BGP_CLEAR_SOFT_OUT, argv[0]);
6009
6010 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6011 BGP_CLEAR_SOFT_OUT, argv[0]);
6012}
6013
6014ALIAS (clear_ip_bgp_peer_ipv4_soft_out,
6015 clear_ip_bgp_peer_ipv4_out_cmd,
6016 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) out",
6017 CLEAR_STR
6018 IP_STR
6019 BGP_STR
6020 "BGP neighbor address to clear\n"
6021 "Address family\n"
6022 "Address Family modifier\n"
6023 "Address Family modifier\n"
e0bce756 6024 BGP_SOFT_OUT_STR)
718e3744 6025
6026DEFUN (clear_ip_bgp_peer_vpnv4_soft_out,
6027 clear_ip_bgp_peer_vpnv4_soft_out_cmd,
6028 "clear ip bgp A.B.C.D vpnv4 unicast soft out",
6029 CLEAR_STR
6030 IP_STR
6031 BGP_STR
6032 "BGP neighbor address to clear\n"
6033 "Address family\n"
6034 "Address Family Modifier\n"
e0bce756
DS
6035 BGP_SOFT_STR
6036 BGP_SOFT_OUT_STR)
718e3744 6037{
6038 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
6039 BGP_CLEAR_SOFT_OUT, argv[0]);
6040}
6041
6042ALIAS (clear_ip_bgp_peer_vpnv4_soft_out,
6043 clear_ip_bgp_peer_vpnv4_out_cmd,
6044 "clear ip bgp A.B.C.D vpnv4 unicast out",
6045 CLEAR_STR
6046 IP_STR
6047 BGP_STR
6048 "BGP neighbor address to clear\n"
6049 "Address family\n"
6050 "Address Family Modifier\n"
e0bce756 6051 BGP_SOFT_OUT_STR)
718e3744 6052
6053DEFUN (clear_bgp_peer_soft_out,
6054 clear_bgp_peer_soft_out_cmd,
a80beece 6055 "clear bgp (A.B.C.D|X:X::X:X|WORD) soft out",
718e3744 6056 CLEAR_STR
6057 BGP_STR
6058 "BGP neighbor address to clear\n"
6059 "BGP IPv6 neighbor to clear\n"
a80beece 6060 "BGP neighbor on interface to clear\n"
e0bce756
DS
6061 BGP_SOFT_STR
6062 BGP_SOFT_OUT_STR)
718e3744 6063{
6064 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
6065 BGP_CLEAR_SOFT_OUT, argv[0]);
6066}
6067
6068ALIAS (clear_bgp_peer_soft_out,
6069 clear_bgp_ipv6_peer_soft_out_cmd,
a80beece 6070 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) soft out",
718e3744 6071 CLEAR_STR
6072 BGP_STR
6073 "Address family\n"
6074 "BGP neighbor address to clear\n"
6075 "BGP IPv6 neighbor to clear\n"
a80beece 6076 "BGP neighbor on interface to clear\n"
e0bce756
DS
6077 BGP_SOFT_STR
6078 BGP_SOFT_OUT_STR)
718e3744 6079
6080ALIAS (clear_bgp_peer_soft_out,
6081 clear_bgp_peer_out_cmd,
a80beece 6082 "clear bgp (A.B.C.D|X:X::X:X|WORD) out",
718e3744 6083 CLEAR_STR
6084 BGP_STR
6085 "BGP neighbor address to clear\n"
6086 "BGP IPv6 neighbor to clear\n"
a80beece 6087 "BGP neighbor on interface to clear\n"
e0bce756 6088 BGP_SOFT_OUT_STR)
718e3744 6089
6090ALIAS (clear_bgp_peer_soft_out,
6091 clear_bgp_ipv6_peer_out_cmd,
a80beece 6092 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) out",
718e3744 6093 CLEAR_STR
6094 BGP_STR
6095 "Address family\n"
6096 "BGP neighbor address to clear\n"
6097 "BGP IPv6 neighbor to clear\n"
a80beece 6098 "BGP neighbor on interface to clear\n"
e0bce756 6099 BGP_SOFT_OUT_STR)
718e3744 6100
6101DEFUN (clear_ip_bgp_peer_group_soft_out,
6102 clear_ip_bgp_peer_group_soft_out_cmd,
6103 "clear ip bgp peer-group WORD soft out",
6104 CLEAR_STR
6105 IP_STR
6106 BGP_STR
6107 "Clear all members of peer-group\n"
6108 "BGP peer-group name\n"
e0bce756
DS
6109 BGP_SOFT_STR
6110 BGP_SOFT_OUT_STR)
718e3744 6111{
6112 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6113 BGP_CLEAR_SOFT_OUT, argv[0]);
6114}
6115
6116ALIAS (clear_ip_bgp_peer_group_soft_out,
6117 clear_ip_bgp_peer_group_out_cmd,
6118 "clear ip bgp peer-group WORD out",
6119 CLEAR_STR
6120 IP_STR
6121 BGP_STR
6122 "Clear all members of peer-group\n"
6123 "BGP peer-group name\n"
e0bce756 6124 BGP_SOFT_OUT_STR)
718e3744 6125
6126DEFUN (clear_ip_bgp_peer_group_ipv4_soft_out,
6127 clear_ip_bgp_peer_group_ipv4_soft_out_cmd,
6128 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft out",
6129 CLEAR_STR
6130 IP_STR
6131 BGP_STR
6132 "Clear all members of peer-group\n"
6133 "BGP peer-group name\n"
6134 "Address family\n"
6135 "Address Family modifier\n"
6136 "Address Family modifier\n"
e0bce756
DS
6137 BGP_SOFT_STR
6138 BGP_SOFT_OUT_STR)
718e3744 6139{
6140 if (strncmp (argv[1], "m", 1) == 0)
6141 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
6142 BGP_CLEAR_SOFT_OUT, argv[0]);
6143
6144 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6145 BGP_CLEAR_SOFT_OUT, argv[0]);
6146}
6147
6148ALIAS (clear_ip_bgp_peer_group_ipv4_soft_out,
6149 clear_ip_bgp_peer_group_ipv4_out_cmd,
6150 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) out",
6151 CLEAR_STR
6152 IP_STR
6153 BGP_STR
6154 "Clear all members of peer-group\n"
6155 "BGP peer-group name\n"
6156 "Address family\n"
6157 "Address Family modifier\n"
6158 "Address Family modifier\n"
e0bce756 6159 BGP_SOFT_OUT_STR)
718e3744 6160
6161DEFUN (clear_bgp_peer_group_soft_out,
6162 clear_bgp_peer_group_soft_out_cmd,
6163 "clear bgp peer-group WORD soft out",
6164 CLEAR_STR
6165 BGP_STR
6166 "Clear all members of peer-group\n"
6167 "BGP peer-group name\n"
e0bce756
DS
6168 BGP_SOFT_STR
6169 BGP_SOFT_OUT_STR)
718e3744 6170{
6171 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
6172 BGP_CLEAR_SOFT_OUT, argv[0]);
6173}
6174
6175ALIAS (clear_bgp_peer_group_soft_out,
6176 clear_bgp_ipv6_peer_group_soft_out_cmd,
6177 "clear bgp ipv6 peer-group WORD soft out",
6178 CLEAR_STR
6179 BGP_STR
6180 "Address family\n"
6181 "Clear all members of peer-group\n"
6182 "BGP peer-group name\n"
e0bce756
DS
6183 BGP_SOFT_STR
6184 BGP_SOFT_OUT_STR)
718e3744 6185
6186ALIAS (clear_bgp_peer_group_soft_out,
6187 clear_bgp_peer_group_out_cmd,
6188 "clear bgp peer-group WORD out",
6189 CLEAR_STR
6190 BGP_STR
6191 "Clear all members of peer-group\n"
6192 "BGP peer-group name\n"
e0bce756 6193 BGP_SOFT_OUT_STR)
718e3744 6194
6195ALIAS (clear_bgp_peer_group_soft_out,
6196 clear_bgp_ipv6_peer_group_out_cmd,
6197 "clear bgp ipv6 peer-group WORD out",
6198 CLEAR_STR
6199 BGP_STR
6200 "Address family\n"
6201 "Clear all members of peer-group\n"
6202 "BGP peer-group name\n"
e0bce756 6203 BGP_SOFT_OUT_STR)
718e3744 6204
6205DEFUN (clear_ip_bgp_external_soft_out,
6206 clear_ip_bgp_external_soft_out_cmd,
6207 "clear ip bgp external soft out",
6208 CLEAR_STR
6209 IP_STR
6210 BGP_STR
6211 "Clear all external peers\n"
e0bce756
DS
6212 BGP_SOFT_STR
6213 BGP_SOFT_OUT_STR)
718e3744 6214{
6215 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
6216 BGP_CLEAR_SOFT_OUT, NULL);
6217}
6218
6219ALIAS (clear_ip_bgp_external_soft_out,
6220 clear_ip_bgp_external_out_cmd,
6221 "clear ip bgp external out",
6222 CLEAR_STR
6223 IP_STR
6224 BGP_STR
6225 "Clear all external peers\n"
e0bce756 6226 BGP_SOFT_OUT_STR)
718e3744 6227
6228DEFUN (clear_ip_bgp_external_ipv4_soft_out,
6229 clear_ip_bgp_external_ipv4_soft_out_cmd,
6230 "clear ip bgp external ipv4 (unicast|multicast) soft out",
6231 CLEAR_STR
6232 IP_STR
6233 BGP_STR
6234 "Clear all external peers\n"
6235 "Address family\n"
6236 "Address Family modifier\n"
6237 "Address Family modifier\n"
e0bce756
DS
6238 BGP_SOFT_STR
6239 BGP_SOFT_OUT_STR)
718e3744 6240{
6241 if (strncmp (argv[0], "m", 1) == 0)
6242 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
6243 BGP_CLEAR_SOFT_OUT, NULL);
6244
6245 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
6246 BGP_CLEAR_SOFT_OUT, NULL);
6247}
6248
6249ALIAS (clear_ip_bgp_external_ipv4_soft_out,
6250 clear_ip_bgp_external_ipv4_out_cmd,
6251 "clear ip bgp external ipv4 (unicast|multicast) out",
6252 CLEAR_STR
6253 IP_STR
6254 BGP_STR
6255 "Clear all external peers\n"
6256 "Address family\n"
6257 "Address Family modifier\n"
6258 "Address Family modifier\n"
e0bce756 6259 BGP_SOFT_OUT_STR)
718e3744 6260
6261DEFUN (clear_bgp_external_soft_out,
6262 clear_bgp_external_soft_out_cmd,
6263 "clear bgp external soft out",
6264 CLEAR_STR
6265 BGP_STR
6266 "Clear all external peers\n"
e0bce756
DS
6267 BGP_SOFT_STR
6268 BGP_SOFT_OUT_STR)
718e3744 6269{
6270 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
6271 BGP_CLEAR_SOFT_OUT, NULL);
6272}
6273
6274ALIAS (clear_bgp_external_soft_out,
6275 clear_bgp_ipv6_external_soft_out_cmd,
6276 "clear bgp ipv6 external soft out",
6277 CLEAR_STR
6278 BGP_STR
6279 "Address family\n"
6280 "Clear all external peers\n"
e0bce756
DS
6281 BGP_SOFT_STR
6282 BGP_SOFT_OUT_STR)
718e3744 6283
6284ALIAS (clear_bgp_external_soft_out,
6285 clear_bgp_external_out_cmd,
6286 "clear bgp external out",
6287 CLEAR_STR
6288 BGP_STR
6289 "Clear all external peers\n"
e0bce756 6290 BGP_SOFT_OUT_STR)
718e3744 6291
6292ALIAS (clear_bgp_external_soft_out,
6293 clear_bgp_ipv6_external_out_cmd,
6294 "clear bgp ipv6 external WORD out",
6295 CLEAR_STR
6296 BGP_STR
6297 "Address family\n"
6298 "Clear all external peers\n"
e0bce756 6299 BGP_SOFT_OUT_STR)
718e3744 6300
6301DEFUN (clear_ip_bgp_as_soft_out,
6302 clear_ip_bgp_as_soft_out_cmd,
320da874 6303 "clear ip bgp " CMD_AS_RANGE " soft out",
718e3744 6304 CLEAR_STR
6305 IP_STR
6306 BGP_STR
6307 "Clear peers with the AS number\n"
e0bce756
DS
6308 BGP_SOFT_STR
6309 BGP_SOFT_OUT_STR)
718e3744 6310{
6311 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
6312 BGP_CLEAR_SOFT_OUT, argv[0]);
6313}
6314
6315ALIAS (clear_ip_bgp_as_soft_out,
6316 clear_ip_bgp_as_out_cmd,
320da874 6317 "clear ip bgp " CMD_AS_RANGE " out",
718e3744 6318 CLEAR_STR
6319 IP_STR
6320 BGP_STR
6321 "Clear peers with the AS number\n"
e0bce756 6322 BGP_SOFT_OUT_STR)
718e3744 6323
6324DEFUN (clear_ip_bgp_as_ipv4_soft_out,
6325 clear_ip_bgp_as_ipv4_soft_out_cmd,
320da874 6326 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft out",
718e3744 6327 CLEAR_STR
6328 IP_STR
6329 BGP_STR
6330 "Clear peers with the AS number\n"
6331 "Address family\n"
6332 "Address Family modifier\n"
6333 "Address Family modifier\n"
e0bce756
DS
6334 BGP_SOFT_STR
6335 BGP_SOFT_OUT_STR)
718e3744 6336{
6337 if (strncmp (argv[1], "m", 1) == 0)
6338 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
6339 BGP_CLEAR_SOFT_OUT, argv[0]);
6340
6341 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
6342 BGP_CLEAR_SOFT_OUT, argv[0]);
6343}
6344
6345ALIAS (clear_ip_bgp_as_ipv4_soft_out,
6346 clear_ip_bgp_as_ipv4_out_cmd,
320da874 6347 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) out",
718e3744 6348 CLEAR_STR
6349 IP_STR
6350 BGP_STR
6351 "Clear peers with the AS number\n"
6352 "Address family\n"
6353 "Address Family modifier\n"
6354 "Address Family modifier\n"
e0bce756 6355 BGP_SOFT_OUT_STR)
718e3744 6356
6357DEFUN (clear_ip_bgp_as_vpnv4_soft_out,
6358 clear_ip_bgp_as_vpnv4_soft_out_cmd,
320da874 6359 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft out",
718e3744 6360 CLEAR_STR
6361 IP_STR
6362 BGP_STR
6363 "Clear peers with the AS number\n"
6364 "Address family\n"
6365 "Address Family modifier\n"
e0bce756
DS
6366 BGP_SOFT_STR
6367 BGP_SOFT_OUT_STR)
718e3744 6368{
6369 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
6370 BGP_CLEAR_SOFT_OUT, argv[0]);
6371}
6372
6373ALIAS (clear_ip_bgp_as_vpnv4_soft_out,
6374 clear_ip_bgp_as_vpnv4_out_cmd,
320da874 6375 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast out",
718e3744 6376 CLEAR_STR
6377 IP_STR
6378 BGP_STR
6379 "Clear peers with the AS number\n"
6380 "Address family\n"
6381 "Address Family modifier\n"
e0bce756 6382 BGP_SOFT_OUT_STR)
718e3744 6383
6384DEFUN (clear_bgp_as_soft_out,
6385 clear_bgp_as_soft_out_cmd,
320da874 6386 "clear bgp " CMD_AS_RANGE " soft out",
718e3744 6387 CLEAR_STR
6388 BGP_STR
6389 "Clear peers with the AS number\n"
e0bce756
DS
6390 BGP_SOFT_STR
6391 BGP_SOFT_OUT_STR)
718e3744 6392{
6393 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
6394 BGP_CLEAR_SOFT_OUT, argv[0]);
6395}
6396
6397ALIAS (clear_bgp_as_soft_out,
6398 clear_bgp_ipv6_as_soft_out_cmd,
320da874 6399 "clear bgp ipv6 " CMD_AS_RANGE " soft out",
718e3744 6400 CLEAR_STR
6401 BGP_STR
6402 "Address family\n"
6403 "Clear peers with the AS number\n"
e0bce756
DS
6404 BGP_SOFT_STR
6405 BGP_SOFT_OUT_STR)
718e3744 6406
6407ALIAS (clear_bgp_as_soft_out,
6408 clear_bgp_as_out_cmd,
320da874 6409 "clear bgp " CMD_AS_RANGE " out",
718e3744 6410 CLEAR_STR
6411 BGP_STR
6412 "Clear peers with the AS number\n"
e0bce756 6413 BGP_SOFT_OUT_STR)
718e3744 6414
6415ALIAS (clear_bgp_as_soft_out,
6416 clear_bgp_ipv6_as_out_cmd,
320da874 6417 "clear bgp ipv6 " CMD_AS_RANGE " out",
718e3744 6418 CLEAR_STR
6419 BGP_STR
6420 "Address family\n"
6421 "Clear peers with the AS number\n"
e0bce756 6422 BGP_SOFT_OUT_STR)
6b0655a2 6423
718e3744 6424/* Inbound soft-reconfiguration */
6425DEFUN (clear_ip_bgp_all_soft_in,
6426 clear_ip_bgp_all_soft_in_cmd,
6427 "clear ip bgp * soft in",
6428 CLEAR_STR
6429 IP_STR
6430 BGP_STR
6431 "Clear all peers\n"
e0bce756
DS
6432 BGP_SOFT_STR
6433 BGP_SOFT_IN_STR)
718e3744 6434{
6435 if (argc == 1)
6436 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
6437 BGP_CLEAR_SOFT_IN, NULL);
6438
6439 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6440 BGP_CLEAR_SOFT_IN, NULL);
6441}
6442
6443ALIAS (clear_ip_bgp_all_soft_in,
6444 clear_ip_bgp_instance_all_soft_in_cmd,
6445 "clear ip bgp view WORD * soft in",
6446 CLEAR_STR
6447 IP_STR
6448 BGP_STR
6449 "BGP view\n"
6450 "view name\n"
6451 "Clear all peers\n"
e0bce756
DS
6452 BGP_SOFT_STR
6453 BGP_SOFT_IN_STR)
718e3744 6454
6455ALIAS (clear_ip_bgp_all_soft_in,
6456 clear_ip_bgp_all_in_cmd,
6457 "clear ip bgp * in",
6458 CLEAR_STR
6459 IP_STR
6460 BGP_STR
6461 "Clear all peers\n"
e0bce756 6462 BGP_SOFT_IN_STR)
718e3744 6463
6464DEFUN (clear_ip_bgp_all_in_prefix_filter,
6465 clear_ip_bgp_all_in_prefix_filter_cmd,
6466 "clear ip bgp * in prefix-filter",
6467 CLEAR_STR
6468 IP_STR
6469 BGP_STR
6470 "Clear all peers\n"
e0bce756 6471 BGP_SOFT_IN_STR
718e3744 6472 "Push out prefix-list ORF and do inbound soft reconfig\n")
6473{
6474 if (argc== 1)
6475 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
6476 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
6477
6478 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6479 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
6480}
6481
6482ALIAS (clear_ip_bgp_all_in_prefix_filter,
6483 clear_ip_bgp_instance_all_in_prefix_filter_cmd,
6484 "clear ip bgp view WORD * in prefix-filter",
6485 CLEAR_STR
6486 IP_STR
6487 BGP_STR
6488 "BGP view\n"
6489 "view name\n"
6490 "Clear all peers\n"
e0bce756 6491 BGP_SOFT_IN_STR
718e3744 6492 "Push out prefix-list ORF and do inbound soft reconfig\n")
6493
6494
6495DEFUN (clear_ip_bgp_all_ipv4_soft_in,
6496 clear_ip_bgp_all_ipv4_soft_in_cmd,
6497 "clear ip bgp * ipv4 (unicast|multicast) soft in",
6498 CLEAR_STR
6499 IP_STR
6500 BGP_STR
6501 "Clear all peers\n"
6502 "Address family\n"
6503 "Address Family modifier\n"
6504 "Address Family modifier\n"
e0bce756
DS
6505 BGP_SOFT_STR
6506 BGP_SOFT_IN_STR)
718e3744 6507{
6508 if (strncmp (argv[0], "m", 1) == 0)
6509 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
6510 BGP_CLEAR_SOFT_IN, NULL);
6511
6512 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6513 BGP_CLEAR_SOFT_IN, NULL);
6514}
6515
6516ALIAS (clear_ip_bgp_all_ipv4_soft_in,
6517 clear_ip_bgp_all_ipv4_in_cmd,
6518 "clear ip bgp * ipv4 (unicast|multicast) in",
6519 CLEAR_STR
6520 IP_STR
6521 BGP_STR
6522 "Clear all peers\n"
6523 "Address family\n"
6524 "Address Family modifier\n"
6525 "Address Family modifier\n"
e0bce756 6526 BGP_SOFT_IN_STR)
718e3744 6527
6528DEFUN (clear_ip_bgp_instance_all_ipv4_soft_in,
6529 clear_ip_bgp_instance_all_ipv4_soft_in_cmd,
6530 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft in",
6531 CLEAR_STR
6532 IP_STR
6533 BGP_STR
6534 "BGP view\n"
6535 "view name\n"
6536 "Clear all peers\n"
6537 "Address family\n"
6538 "Address Family modifier\n"
6539 "Address Family modifier\n"
e0bce756
DS
6540 BGP_SOFT_STR
6541 BGP_SOFT_IN_STR)
718e3744 6542{
6543 if (strncmp (argv[1], "m", 1) == 0)
6544 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
6545 BGP_CLEAR_SOFT_IN, NULL);
6546
6547 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
6548 BGP_CLEAR_SOFT_IN, NULL);
6549}
6550
6551DEFUN (clear_ip_bgp_all_ipv4_in_prefix_filter,
6552 clear_ip_bgp_all_ipv4_in_prefix_filter_cmd,
6553 "clear ip bgp * ipv4 (unicast|multicast) in prefix-filter",
6554 CLEAR_STR
6555 IP_STR
6556 BGP_STR
6557 "Clear all peers\n"
6558 "Address family\n"
6559 "Address Family modifier\n"
6560 "Address Family modifier\n"
e0bce756 6561 BGP_SOFT_IN_STR
718e3744 6562 "Push out prefix-list ORF and do inbound soft reconfig\n")
6563{
6564 if (strncmp (argv[0], "m", 1) == 0)
6565 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
6566 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
6567
6568 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6569 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
6570}
6571
6572DEFUN (clear_ip_bgp_instance_all_ipv4_in_prefix_filter,
6573 clear_ip_bgp_instance_all_ipv4_in_prefix_filter_cmd,
6574 "clear ip bgp view WORD * ipv4 (unicast|multicast) in prefix-filter",
6575 CLEAR_STR
6576 IP_STR
6577 BGP_STR
6578 "Clear all peers\n"
6579 "Address family\n"
6580 "Address Family modifier\n"
6581 "Address Family modifier\n"
e0bce756 6582 BGP_SOFT_IN_STR
718e3744 6583 "Push out prefix-list ORF and do inbound soft reconfig\n")
6584{
6585 if (strncmp (argv[1], "m", 1) == 0)
6586 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
6587 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
6588
6589 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
6590 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
6591}
6592
6593DEFUN (clear_ip_bgp_all_vpnv4_soft_in,
6594 clear_ip_bgp_all_vpnv4_soft_in_cmd,
6595 "clear ip bgp * vpnv4 unicast soft in",
6596 CLEAR_STR
6597 IP_STR
6598 BGP_STR
6599 "Clear all peers\n"
6600 "Address family\n"
6601 "Address Family Modifier\n"
e0bce756
DS
6602 BGP_SOFT_STR
6603 BGP_SOFT_IN_STR)
718e3744 6604{
6605 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
6606 BGP_CLEAR_SOFT_IN, NULL);
6607}
6608
6609ALIAS (clear_ip_bgp_all_vpnv4_soft_in,
6610 clear_ip_bgp_all_vpnv4_in_cmd,
6611 "clear ip bgp * vpnv4 unicast in",
6612 CLEAR_STR
6613 IP_STR
6614 BGP_STR
6615 "Clear all peers\n"
6616 "Address family\n"
6617 "Address Family Modifier\n"
e0bce756 6618 BGP_SOFT_IN_STR)
718e3744 6619
6620DEFUN (clear_bgp_all_soft_in,
6621 clear_bgp_all_soft_in_cmd,
6622 "clear bgp * soft in",
6623 CLEAR_STR
6624 BGP_STR
6625 "Clear all peers\n"
e0bce756
DS
6626 BGP_SOFT_STR
6627 BGP_SOFT_IN_STR)
718e3744 6628{
6629 if (argc == 1)
6630 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
6631 BGP_CLEAR_SOFT_IN, NULL);
6632
6633 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
6634 BGP_CLEAR_SOFT_IN, NULL);
6635}
6636
6637ALIAS (clear_bgp_all_soft_in,
6638 clear_bgp_instance_all_soft_in_cmd,
6639 "clear bgp view WORD * soft in",
6640 CLEAR_STR
6641 BGP_STR
6642 "BGP view\n"
6643 "view name\n"
6644 "Clear all peers\n"
e0bce756
DS
6645 BGP_SOFT_STR
6646 BGP_SOFT_IN_STR)
718e3744 6647
6648ALIAS (clear_bgp_all_soft_in,
6649 clear_bgp_ipv6_all_soft_in_cmd,
6650 "clear bgp ipv6 * soft in",
6651 CLEAR_STR
6652 BGP_STR
6653 "Address family\n"
6654 "Clear all peers\n"
e0bce756
DS
6655 BGP_SOFT_STR
6656 BGP_SOFT_IN_STR)
718e3744 6657
6658ALIAS (clear_bgp_all_soft_in,
6659 clear_bgp_all_in_cmd,
6660 "clear bgp * in",
6661 CLEAR_STR
6662 BGP_STR
6663 "Clear all peers\n"
e0bce756 6664 BGP_SOFT_IN_STR)
718e3744 6665
6666ALIAS (clear_bgp_all_soft_in,
6667 clear_bgp_ipv6_all_in_cmd,
6668 "clear bgp ipv6 * in",
6669 CLEAR_STR
6670 BGP_STR
6671 "Address family\n"
6672 "Clear all peers\n"
e0bce756 6673 BGP_SOFT_IN_STR)
718e3744 6674
6675DEFUN (clear_bgp_all_in_prefix_filter,
6676 clear_bgp_all_in_prefix_filter_cmd,
6677 "clear bgp * in prefix-filter",
6678 CLEAR_STR
6679 BGP_STR
6680 "Clear all peers\n"
e0bce756 6681 BGP_SOFT_IN_STR
718e3744 6682 "Push out prefix-list ORF and do inbound soft reconfig\n")
6683{
6684 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
6685 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
6686}
6687
6688ALIAS (clear_bgp_all_in_prefix_filter,
6689 clear_bgp_ipv6_all_in_prefix_filter_cmd,
6690 "clear bgp ipv6 * in prefix-filter",
6691 CLEAR_STR
6692 BGP_STR
6693 "Address family\n"
6694 "Clear all peers\n"
e0bce756 6695 BGP_SOFT_IN_STR
718e3744 6696 "Push out prefix-list ORF and do inbound soft reconfig\n")
6697
6698DEFUN (clear_ip_bgp_peer_soft_in,
6699 clear_ip_bgp_peer_soft_in_cmd,
6700 "clear ip bgp A.B.C.D soft in",
6701 CLEAR_STR
6702 IP_STR
6703 BGP_STR
6704 "BGP neighbor address to clear\n"
e0bce756
DS
6705 BGP_SOFT_STR
6706 BGP_SOFT_IN_STR)
718e3744 6707{
6708 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6709 BGP_CLEAR_SOFT_IN, argv[0]);
6710}
6711
6712ALIAS (clear_ip_bgp_peer_soft_in,
6713 clear_ip_bgp_peer_in_cmd,
6714 "clear ip bgp A.B.C.D in",
6715 CLEAR_STR
6716 IP_STR
6717 BGP_STR
6718 "BGP neighbor address to clear\n"
e0bce756 6719 BGP_SOFT_IN_STR)
718e3744 6720
6721DEFUN (clear_ip_bgp_peer_in_prefix_filter,
6722 clear_ip_bgp_peer_in_prefix_filter_cmd,
6723 "clear ip bgp A.B.C.D in prefix-filter",
6724 CLEAR_STR
6725 IP_STR
6726 BGP_STR
6727 "BGP neighbor address to clear\n"
e0bce756 6728 BGP_SOFT_IN_STR
718e3744 6729 "Push out the existing ORF prefix-list\n")
6730{
6731 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6732 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6733}
6734
6735DEFUN (clear_ip_bgp_peer_ipv4_soft_in,
6736 clear_ip_bgp_peer_ipv4_soft_in_cmd,
6737 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft in",
6738 CLEAR_STR
6739 IP_STR
6740 BGP_STR
6741 "BGP neighbor address to clear\n"
6742 "Address family\n"
6743 "Address Family modifier\n"
6744 "Address Family modifier\n"
e0bce756
DS
6745 BGP_SOFT_STR
6746 BGP_SOFT_IN_STR)
718e3744 6747{
6748 if (strncmp (argv[1], "m", 1) == 0)
6749 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
6750 BGP_CLEAR_SOFT_IN, argv[0]);
6751
6752 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6753 BGP_CLEAR_SOFT_IN, argv[0]);
6754}
6755
6756ALIAS (clear_ip_bgp_peer_ipv4_soft_in,
6757 clear_ip_bgp_peer_ipv4_in_cmd,
6758 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) in",
6759 CLEAR_STR
6760 IP_STR
6761 BGP_STR
6762 "BGP neighbor address to clear\n"
6763 "Address family\n"
6764 "Address Family modifier\n"
6765 "Address Family modifier\n"
e0bce756 6766 BGP_SOFT_IN_STR)
718e3744 6767
6768DEFUN (clear_ip_bgp_peer_ipv4_in_prefix_filter,
6769 clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd,
6770 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) in prefix-filter",
6771 CLEAR_STR
6772 IP_STR
6773 BGP_STR
6774 "BGP neighbor address to clear\n"
6775 "Address family\n"
6776 "Address Family modifier\n"
6777 "Address Family modifier\n"
e0bce756 6778 BGP_SOFT_IN_STR
718e3744 6779 "Push out the existing ORF prefix-list\n")
6780{
6781 if (strncmp (argv[1], "m", 1) == 0)
6782 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
6783 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6784
6785 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6786 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6787}
6788
6789DEFUN (clear_ip_bgp_peer_vpnv4_soft_in,
6790 clear_ip_bgp_peer_vpnv4_soft_in_cmd,
6791 "clear ip bgp A.B.C.D vpnv4 unicast soft in",
6792 CLEAR_STR
6793 IP_STR
6794 BGP_STR
6795 "BGP neighbor address to clear\n"
6796 "Address family\n"
6797 "Address Family Modifier\n"
e0bce756
DS
6798 BGP_SOFT_STR
6799 BGP_SOFT_IN_STR)
718e3744 6800{
6801 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
6802 BGP_CLEAR_SOFT_IN, argv[0]);
6803}
6804
6805ALIAS (clear_ip_bgp_peer_vpnv4_soft_in,
6806 clear_ip_bgp_peer_vpnv4_in_cmd,
6807 "clear ip bgp A.B.C.D vpnv4 unicast in",
6808 CLEAR_STR
6809 IP_STR
6810 BGP_STR
6811 "BGP neighbor address to clear\n"
6812 "Address family\n"
6813 "Address Family Modifier\n"
e0bce756 6814 BGP_SOFT_IN_STR)
718e3744 6815
6816DEFUN (clear_bgp_peer_soft_in,
6817 clear_bgp_peer_soft_in_cmd,
a80beece 6818 "clear bgp (A.B.C.D|X:X::X:X|WORD) soft in",
718e3744 6819 CLEAR_STR
6820 BGP_STR
6821 "BGP neighbor address to clear\n"
6822 "BGP IPv6 neighbor to clear\n"
a80beece 6823 "BGP neighbor on interface to clear\n"
e0bce756
DS
6824 BGP_SOFT_STR
6825 BGP_SOFT_IN_STR)
718e3744 6826{
6827 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
6828 BGP_CLEAR_SOFT_IN, argv[0]);
6829}
6830
6831ALIAS (clear_bgp_peer_soft_in,
6832 clear_bgp_ipv6_peer_soft_in_cmd,
a80beece 6833 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) soft in",
718e3744 6834 CLEAR_STR
6835 BGP_STR
6836 "Address family\n"
6837 "BGP neighbor address to clear\n"
6838 "BGP IPv6 neighbor to clear\n"
a80beece 6839 "BGP neighbor on interface to clear\n"
e0bce756
DS
6840 BGP_SOFT_STR
6841 BGP_SOFT_IN_STR)
718e3744 6842
6843ALIAS (clear_bgp_peer_soft_in,
6844 clear_bgp_peer_in_cmd,
a80beece 6845 "clear bgp (A.B.C.D|X:X::X:X|WORD) in",
718e3744 6846 CLEAR_STR
6847 BGP_STR
6848 "BGP neighbor address to clear\n"
6849 "BGP IPv6 neighbor to clear\n"
a80beece 6850 "BGP neighbor on interface to clear\n"
e0bce756 6851 BGP_SOFT_IN_STR)
718e3744 6852
6853ALIAS (clear_bgp_peer_soft_in,
6854 clear_bgp_ipv6_peer_in_cmd,
a80beece 6855 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) in",
718e3744 6856 CLEAR_STR
6857 BGP_STR
6858 "Address family\n"
6859 "BGP neighbor address to clear\n"
6860 "BGP IPv6 neighbor to clear\n"
a80beece 6861 "BGP neighbor on interface to clear\n"
e0bce756 6862 BGP_SOFT_IN_STR)
718e3744 6863
6864DEFUN (clear_bgp_peer_in_prefix_filter,
6865 clear_bgp_peer_in_prefix_filter_cmd,
a80beece 6866 "clear bgp (A.B.C.D|X:X::X:X|WORD) in prefix-filter",
718e3744 6867 CLEAR_STR
6868 BGP_STR
6869 "BGP neighbor address to clear\n"
6870 "BGP IPv6 neighbor to clear\n"
a80beece 6871 "BGP neighbor on interface to clear\n"
e0bce756 6872 BGP_SOFT_IN_STR
718e3744 6873 "Push out the existing ORF prefix-list\n")
6874{
6875 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
6876 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6877}
6878
6879ALIAS (clear_bgp_peer_in_prefix_filter,
6880 clear_bgp_ipv6_peer_in_prefix_filter_cmd,
a80beece 6881 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) in prefix-filter",
718e3744 6882 CLEAR_STR
6883 BGP_STR
6884 "Address family\n"
6885 "BGP neighbor address to clear\n"
6886 "BGP IPv6 neighbor to clear\n"
a80beece 6887 "BGP neighbor on interface to clear\n"
e0bce756 6888 BGP_SOFT_IN_STR
718e3744 6889 "Push out the existing ORF prefix-list\n")
6890
6891DEFUN (clear_ip_bgp_peer_group_soft_in,
6892 clear_ip_bgp_peer_group_soft_in_cmd,
6893 "clear ip bgp peer-group WORD soft in",
6894 CLEAR_STR
6895 IP_STR
6896 BGP_STR
6897 "Clear all members of peer-group\n"
6898 "BGP peer-group name\n"
e0bce756
DS
6899 BGP_SOFT_STR
6900 BGP_SOFT_IN_STR)
718e3744 6901{
6902 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6903 BGP_CLEAR_SOFT_IN, argv[0]);
6904}
6905
6906ALIAS (clear_ip_bgp_peer_group_soft_in,
6907 clear_ip_bgp_peer_group_in_cmd,
6908 "clear ip bgp peer-group WORD in",
6909 CLEAR_STR
6910 IP_STR
6911 BGP_STR
6912 "Clear all members of peer-group\n"
6913 "BGP peer-group name\n"
e0bce756 6914 BGP_SOFT_IN_STR)
718e3744 6915
6916DEFUN (clear_ip_bgp_peer_group_in_prefix_filter,
6917 clear_ip_bgp_peer_group_in_prefix_filter_cmd,
6918 "clear ip bgp peer-group WORD in prefix-filter",
6919 CLEAR_STR
6920 IP_STR
6921 BGP_STR
6922 "Clear all members of peer-group\n"
6923 "BGP peer-group name\n"
e0bce756 6924 BGP_SOFT_IN_STR
718e3744 6925 "Push out prefix-list ORF and do inbound soft reconfig\n")
6926{
6927 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6928 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6929}
6930
6931DEFUN (clear_ip_bgp_peer_group_ipv4_soft_in,
6932 clear_ip_bgp_peer_group_ipv4_soft_in_cmd,
6933 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft in",
6934 CLEAR_STR
6935 IP_STR
6936 BGP_STR
6937 "Clear all members of peer-group\n"
6938 "BGP peer-group name\n"
6939 "Address family\n"
6940 "Address Family modifier\n"
6941 "Address Family modifier\n"
e0bce756
DS
6942 BGP_SOFT_STR
6943 BGP_SOFT_IN_STR)
718e3744 6944{
6945 if (strncmp (argv[1], "m", 1) == 0)
6946 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
6947 BGP_CLEAR_SOFT_IN, argv[0]);
6948
6949 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6950 BGP_CLEAR_SOFT_IN, argv[0]);
6951}
6952
6953ALIAS (clear_ip_bgp_peer_group_ipv4_soft_in,
6954 clear_ip_bgp_peer_group_ipv4_in_cmd,
6955 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in",
6956 CLEAR_STR
6957 IP_STR
6958 BGP_STR
6959 "Clear all members of peer-group\n"
6960 "BGP peer-group name\n"
6961 "Address family\n"
6962 "Address Family modifier\n"
6963 "Address Family modifier\n"
e0bce756 6964 BGP_SOFT_IN_STR)
718e3744 6965
6966DEFUN (clear_ip_bgp_peer_group_ipv4_in_prefix_filter,
6967 clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd,
6968 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in prefix-filter",
6969 CLEAR_STR
6970 IP_STR
6971 BGP_STR
6972 "Clear all members of peer-group\n"
6973 "BGP peer-group name\n"
6974 "Address family\n"
6975 "Address Family modifier\n"
6976 "Address Family modifier\n"
e0bce756 6977 BGP_SOFT_IN_STR
718e3744 6978 "Push out prefix-list ORF and do inbound soft reconfig\n")
6979{
6980 if (strncmp (argv[1], "m", 1) == 0)
6981 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
6982 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6983
6984 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6985 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6986}
6987
6988DEFUN (clear_bgp_peer_group_soft_in,
6989 clear_bgp_peer_group_soft_in_cmd,
6990 "clear bgp peer-group WORD soft in",
6991 CLEAR_STR
6992 BGP_STR
6993 "Clear all members of peer-group\n"
6994 "BGP peer-group name\n"
e0bce756
DS
6995 BGP_SOFT_STR
6996 BGP_SOFT_IN_STR)
718e3744 6997{
6998 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
6999 BGP_CLEAR_SOFT_IN, argv[0]);
7000}
7001
7002ALIAS (clear_bgp_peer_group_soft_in,
7003 clear_bgp_ipv6_peer_group_soft_in_cmd,
7004 "clear bgp ipv6 peer-group WORD soft in",
7005 CLEAR_STR
7006 BGP_STR
7007 "Address family\n"
7008 "Clear all members of peer-group\n"
7009 "BGP peer-group name\n"
e0bce756
DS
7010 BGP_SOFT_STR
7011 BGP_SOFT_IN_STR)
718e3744 7012
7013ALIAS (clear_bgp_peer_group_soft_in,
7014 clear_bgp_peer_group_in_cmd,
7015 "clear bgp peer-group WORD in",
7016 CLEAR_STR
7017 BGP_STR
7018 "Clear all members of peer-group\n"
7019 "BGP peer-group name\n"
e0bce756 7020 BGP_SOFT_IN_STR)
718e3744 7021
7022ALIAS (clear_bgp_peer_group_soft_in,
7023 clear_bgp_ipv6_peer_group_in_cmd,
7024 "clear bgp ipv6 peer-group WORD in",
7025 CLEAR_STR
7026 BGP_STR
7027 "Address family\n"
7028 "Clear all members of peer-group\n"
7029 "BGP peer-group name\n"
e0bce756 7030 BGP_SOFT_IN_STR)
718e3744 7031
7032DEFUN (clear_bgp_peer_group_in_prefix_filter,
7033 clear_bgp_peer_group_in_prefix_filter_cmd,
7034 "clear bgp peer-group WORD in prefix-filter",
7035 CLEAR_STR
7036 BGP_STR
7037 "Clear all members of peer-group\n"
7038 "BGP peer-group name\n"
e0bce756 7039 BGP_SOFT_IN_STR
718e3744 7040 "Push out prefix-list ORF and do inbound soft reconfig\n")
7041{
7042 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
7043 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7044}
7045
7046ALIAS (clear_bgp_peer_group_in_prefix_filter,
7047 clear_bgp_ipv6_peer_group_in_prefix_filter_cmd,
7048 "clear bgp ipv6 peer-group WORD in prefix-filter",
7049 CLEAR_STR
7050 BGP_STR
7051 "Address family\n"
7052 "Clear all members of peer-group\n"
7053 "BGP peer-group name\n"
e0bce756 7054 BGP_SOFT_IN_STR
718e3744 7055 "Push out prefix-list ORF and do inbound soft reconfig\n")
7056
7057DEFUN (clear_ip_bgp_external_soft_in,
7058 clear_ip_bgp_external_soft_in_cmd,
7059 "clear ip bgp external soft in",
7060 CLEAR_STR
7061 IP_STR
7062 BGP_STR
7063 "Clear all external peers\n"
e0bce756
DS
7064 BGP_SOFT_STR
7065 BGP_SOFT_IN_STR)
718e3744 7066{
7067 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7068 BGP_CLEAR_SOFT_IN, NULL);
7069}
7070
7071ALIAS (clear_ip_bgp_external_soft_in,
7072 clear_ip_bgp_external_in_cmd,
7073 "clear ip bgp external in",
7074 CLEAR_STR
7075 IP_STR
7076 BGP_STR
7077 "Clear all external peers\n"
e0bce756 7078 BGP_SOFT_IN_STR)
718e3744 7079
7080DEFUN (clear_ip_bgp_external_in_prefix_filter,
7081 clear_ip_bgp_external_in_prefix_filter_cmd,
7082 "clear ip bgp external in prefix-filter",
7083 CLEAR_STR
7084 IP_STR
7085 BGP_STR
7086 "Clear all external peers\n"
e0bce756 7087 BGP_SOFT_IN_STR
718e3744 7088 "Push out prefix-list ORF and do inbound soft reconfig\n")
7089{
7090 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7091 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7092}
7093
7094DEFUN (clear_ip_bgp_external_ipv4_soft_in,
7095 clear_ip_bgp_external_ipv4_soft_in_cmd,
7096 "clear ip bgp external ipv4 (unicast|multicast) soft in",
7097 CLEAR_STR
7098 IP_STR
7099 BGP_STR
7100 "Clear all external peers\n"
7101 "Address family\n"
7102 "Address Family modifier\n"
7103 "Address Family modifier\n"
e0bce756
DS
7104 BGP_SOFT_STR
7105 BGP_SOFT_IN_STR)
718e3744 7106{
7107 if (strncmp (argv[0], "m", 1) == 0)
7108 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
7109 BGP_CLEAR_SOFT_IN, NULL);
7110
7111 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7112 BGP_CLEAR_SOFT_IN, NULL);
7113}
7114
7115ALIAS (clear_ip_bgp_external_ipv4_soft_in,
7116 clear_ip_bgp_external_ipv4_in_cmd,
7117 "clear ip bgp external ipv4 (unicast|multicast) in",
7118 CLEAR_STR
7119 IP_STR
7120 BGP_STR
7121 "Clear all external peers\n"
7122 "Address family\n"
7123 "Address Family modifier\n"
7124 "Address Family modifier\n"
e0bce756 7125 BGP_SOFT_IN_STR)
718e3744 7126
7127DEFUN (clear_ip_bgp_external_ipv4_in_prefix_filter,
7128 clear_ip_bgp_external_ipv4_in_prefix_filter_cmd,
7129 "clear ip bgp external ipv4 (unicast|multicast) in prefix-filter",
7130 CLEAR_STR
7131 IP_STR
7132 BGP_STR
7133 "Clear all external peers\n"
7134 "Address family\n"
7135 "Address Family modifier\n"
7136 "Address Family modifier\n"
e0bce756 7137 BGP_SOFT_IN_STR
718e3744 7138 "Push out prefix-list ORF and do inbound soft reconfig\n")
7139{
7140 if (strncmp (argv[0], "m", 1) == 0)
7141 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
7142 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7143
7144 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7145 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7146}
7147
7148DEFUN (clear_bgp_external_soft_in,
7149 clear_bgp_external_soft_in_cmd,
7150 "clear bgp external soft in",
7151 CLEAR_STR
7152 BGP_STR
7153 "Clear all external peers\n"
e0bce756
DS
7154 BGP_SOFT_STR
7155 BGP_SOFT_IN_STR)
718e3744 7156{
7157 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
7158 BGP_CLEAR_SOFT_IN, NULL);
7159}
7160
7161ALIAS (clear_bgp_external_soft_in,
7162 clear_bgp_ipv6_external_soft_in_cmd,
7163 "clear bgp ipv6 external soft in",
7164 CLEAR_STR
7165 BGP_STR
7166 "Address family\n"
7167 "Clear all external peers\n"
e0bce756
DS
7168 BGP_SOFT_STR
7169 BGP_SOFT_IN_STR)
718e3744 7170
7171ALIAS (clear_bgp_external_soft_in,
7172 clear_bgp_external_in_cmd,
7173 "clear bgp external in",
7174 CLEAR_STR
7175 BGP_STR
7176 "Clear all external peers\n"
e0bce756 7177 BGP_SOFT_IN_STR)
718e3744 7178
7179ALIAS (clear_bgp_external_soft_in,
7180 clear_bgp_ipv6_external_in_cmd,
7181 "clear bgp ipv6 external WORD in",
7182 CLEAR_STR
7183 BGP_STR
7184 "Address family\n"
7185 "Clear all external peers\n"
e0bce756 7186 BGP_SOFT_IN_STR)
718e3744 7187
7188DEFUN (clear_bgp_external_in_prefix_filter,
7189 clear_bgp_external_in_prefix_filter_cmd,
7190 "clear bgp external in prefix-filter",
7191 CLEAR_STR
7192 BGP_STR
7193 "Clear all external peers\n"
e0bce756 7194 BGP_SOFT_IN_STR
718e3744 7195 "Push out prefix-list ORF and do inbound soft reconfig\n")
7196{
7197 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
7198 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7199}
7200
7201ALIAS (clear_bgp_external_in_prefix_filter,
7202 clear_bgp_ipv6_external_in_prefix_filter_cmd,
7203 "clear bgp ipv6 external in prefix-filter",
7204 CLEAR_STR
7205 BGP_STR
7206 "Address family\n"
7207 "Clear all external peers\n"
e0bce756 7208 BGP_SOFT_IN_STR
718e3744 7209 "Push out prefix-list ORF and do inbound soft reconfig\n")
7210
7211DEFUN (clear_ip_bgp_as_soft_in,
7212 clear_ip_bgp_as_soft_in_cmd,
320da874 7213 "clear ip bgp " CMD_AS_RANGE " soft in",
718e3744 7214 CLEAR_STR
7215 IP_STR
7216 BGP_STR
7217 "Clear peers with the AS number\n"
e0bce756
DS
7218 BGP_SOFT_STR
7219 BGP_SOFT_IN_STR)
718e3744 7220{
7221 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
7222 BGP_CLEAR_SOFT_IN, argv[0]);
7223}
7224
7225ALIAS (clear_ip_bgp_as_soft_in,
7226 clear_ip_bgp_as_in_cmd,
320da874 7227 "clear ip bgp " CMD_AS_RANGE " in",
718e3744 7228 CLEAR_STR
7229 IP_STR
7230 BGP_STR
7231 "Clear peers with the AS number\n"
e0bce756 7232 BGP_SOFT_IN_STR)
718e3744 7233
7234DEFUN (clear_ip_bgp_as_in_prefix_filter,
7235 clear_ip_bgp_as_in_prefix_filter_cmd,
320da874 7236 "clear ip bgp " CMD_AS_RANGE " in prefix-filter",
718e3744 7237 CLEAR_STR
7238 IP_STR
7239 BGP_STR
7240 "Clear peers with the AS number\n"
e0bce756 7241 BGP_SOFT_IN_STR
718e3744 7242 "Push out prefix-list ORF and do inbound soft reconfig\n")
7243{
7244 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
7245 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7246}
7247
7248DEFUN (clear_ip_bgp_as_ipv4_soft_in,
7249 clear_ip_bgp_as_ipv4_soft_in_cmd,
320da874 7250 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft in",
718e3744 7251 CLEAR_STR
7252 IP_STR
7253 BGP_STR
7254 "Clear peers with the AS number\n"
7255 "Address family\n"
7256 "Address Family modifier\n"
7257 "Address Family modifier\n"
e0bce756
DS
7258 BGP_SOFT_STR
7259 BGP_SOFT_IN_STR)
718e3744 7260{
7261 if (strncmp (argv[1], "m", 1) == 0)
7262 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
7263 BGP_CLEAR_SOFT_IN, argv[0]);
7264
7265 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
7266 BGP_CLEAR_SOFT_IN, argv[0]);
7267}
7268
7269ALIAS (clear_ip_bgp_as_ipv4_soft_in,
7270 clear_ip_bgp_as_ipv4_in_cmd,
320da874 7271 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in",
718e3744 7272 CLEAR_STR
7273 IP_STR
7274 BGP_STR
7275 "Clear peers with the AS number\n"
7276 "Address family\n"
7277 "Address Family modifier\n"
7278 "Address Family modifier\n"
e0bce756 7279 BGP_SOFT_IN_STR)
718e3744 7280
7281DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter,
7282 clear_ip_bgp_as_ipv4_in_prefix_filter_cmd,
320da874 7283 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in prefix-filter",
718e3744 7284 CLEAR_STR
7285 IP_STR
7286 BGP_STR
7287 "Clear peers with the AS number\n"
7288 "Address family\n"
7289 "Address Family modifier\n"
7290 "Address Family modifier\n"
e0bce756 7291 BGP_SOFT_IN_STR
718e3744 7292 "Push out prefix-list ORF and do inbound soft reconfig\n")
7293{
7294 if (strncmp (argv[1], "m", 1) == 0)
7295 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
7296 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7297
7298 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
7299 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7300}
7301
7302DEFUN (clear_ip_bgp_as_vpnv4_soft_in,
7303 clear_ip_bgp_as_vpnv4_soft_in_cmd,
320da874 7304 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft in",
718e3744 7305 CLEAR_STR
7306 IP_STR
7307 BGP_STR
7308 "Clear peers with the AS number\n"
7309 "Address family\n"
7310 "Address Family modifier\n"
e0bce756
DS
7311 BGP_SOFT_STR
7312 BGP_SOFT_IN_STR)
718e3744 7313{
7314 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
7315 BGP_CLEAR_SOFT_IN, argv[0]);
7316}
7317
7318ALIAS (clear_ip_bgp_as_vpnv4_soft_in,
7319 clear_ip_bgp_as_vpnv4_in_cmd,
320da874 7320 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast in",
718e3744 7321 CLEAR_STR
7322 IP_STR
7323 BGP_STR
7324 "Clear peers with the AS number\n"
7325 "Address family\n"
7326 "Address Family modifier\n"
e0bce756 7327 BGP_SOFT_IN_STR)
718e3744 7328
7329DEFUN (clear_bgp_as_soft_in,
7330 clear_bgp_as_soft_in_cmd,
320da874 7331 "clear bgp " CMD_AS_RANGE " soft in",
718e3744 7332 CLEAR_STR
7333 BGP_STR
7334 "Clear peers with the AS number\n"
e0bce756
DS
7335 BGP_SOFT_STR
7336 BGP_SOFT_IN_STR)
718e3744 7337{
7338 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
7339 BGP_CLEAR_SOFT_IN, argv[0]);
7340}
7341
7342ALIAS (clear_bgp_as_soft_in,
7343 clear_bgp_ipv6_as_soft_in_cmd,
320da874 7344 "clear bgp ipv6 " CMD_AS_RANGE " soft in",
718e3744 7345 CLEAR_STR
7346 BGP_STR
7347 "Address family\n"
7348 "Clear peers with the AS number\n"
e0bce756
DS
7349 BGP_SOFT_STR
7350 BGP_SOFT_IN_STR)
718e3744 7351
7352ALIAS (clear_bgp_as_soft_in,
7353 clear_bgp_as_in_cmd,
320da874 7354 "clear bgp " CMD_AS_RANGE " in",
718e3744 7355 CLEAR_STR
7356 BGP_STR
7357 "Clear peers with the AS number\n"
e0bce756 7358 BGP_SOFT_IN_STR)
718e3744 7359
7360ALIAS (clear_bgp_as_soft_in,
7361 clear_bgp_ipv6_as_in_cmd,
320da874 7362 "clear bgp ipv6 " CMD_AS_RANGE " in",
718e3744 7363 CLEAR_STR
7364 BGP_STR
7365 "Address family\n"
7366 "Clear peers with the AS number\n"
e0bce756 7367 BGP_SOFT_IN_STR)
718e3744 7368
7369DEFUN (clear_bgp_as_in_prefix_filter,
7370 clear_bgp_as_in_prefix_filter_cmd,
320da874 7371 "clear bgp " CMD_AS_RANGE " in prefix-filter",
718e3744 7372 CLEAR_STR
7373 BGP_STR
7374 "Clear peers with the AS number\n"
e0bce756 7375 BGP_SOFT_IN_STR
718e3744 7376 "Push out prefix-list ORF and do inbound soft reconfig\n")
7377{
7378 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
7379 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7380}
7381
7382ALIAS (clear_bgp_as_in_prefix_filter,
7383 clear_bgp_ipv6_as_in_prefix_filter_cmd,
320da874 7384 "clear bgp ipv6 " CMD_AS_RANGE " in prefix-filter",
718e3744 7385 CLEAR_STR
7386 BGP_STR
7387 "Address family\n"
7388 "Clear peers with the AS number\n"
e0bce756 7389 BGP_SOFT_IN_STR
718e3744 7390 "Push out prefix-list ORF and do inbound soft reconfig\n")
6b0655a2 7391
718e3744 7392/* Both soft-reconfiguration */
7393DEFUN (clear_ip_bgp_all_soft,
7394 clear_ip_bgp_all_soft_cmd,
7395 "clear ip bgp * soft",
7396 CLEAR_STR
7397 IP_STR
7398 BGP_STR
7399 "Clear all peers\n"
e0bce756 7400 BGP_SOFT_STR)
718e3744 7401{
7402 if (argc == 1)
7403 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
7404 BGP_CLEAR_SOFT_BOTH, NULL);
7405
7406 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
7407 BGP_CLEAR_SOFT_BOTH, NULL);
7408}
7409
7410ALIAS (clear_ip_bgp_all_soft,
7411 clear_ip_bgp_instance_all_soft_cmd,
7412 "clear ip bgp view WORD * soft",
7413 CLEAR_STR
7414 IP_STR
7415 BGP_STR
7416 "BGP view\n"
7417 "view name\n"
7418 "Clear all peers\n"
e0bce756 7419 BGP_SOFT_STR)
718e3744 7420
7421
7422DEFUN (clear_ip_bgp_all_ipv4_soft,
7423 clear_ip_bgp_all_ipv4_soft_cmd,
7424 "clear ip bgp * ipv4 (unicast|multicast) soft",
7425 CLEAR_STR
7426 IP_STR
7427 BGP_STR
7428 "Clear all peers\n"
7429 "Address family\n"
7430 "Address Family Modifier\n"
7431 "Address Family Modifier\n"
e0bce756 7432 BGP_SOFT_STR)
718e3744 7433{
7434 if (strncmp (argv[0], "m", 1) == 0)
7435 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
7436 BGP_CLEAR_SOFT_BOTH, NULL);
7437
7438 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
7439 BGP_CLEAR_SOFT_BOTH, NULL);
7440}
7441
7442DEFUN (clear_ip_bgp_instance_all_ipv4_soft,
7443 clear_ip_bgp_instance_all_ipv4_soft_cmd,
7444 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft",
7445 CLEAR_STR
7446 IP_STR
7447 BGP_STR
7448 "BGP view\n"
7449 "view name\n"
7450 "Clear all peers\n"
7451 "Address family\n"
7452 "Address Family Modifier\n"
7453 "Address Family Modifier\n"
e0bce756 7454 BGP_SOFT_STR)
718e3744 7455{
7456 if (strncmp (argv[1], "m", 1) == 0)
7457 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
7458 BGP_CLEAR_SOFT_BOTH, NULL);
7459
7460 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
7461 BGP_CLEAR_SOFT_BOTH, NULL);
7462}
7463
7464DEFUN (clear_ip_bgp_all_vpnv4_soft,
7465 clear_ip_bgp_all_vpnv4_soft_cmd,
7466 "clear ip bgp * vpnv4 unicast soft",
7467 CLEAR_STR
7468 IP_STR
7469 BGP_STR
7470 "Clear all peers\n"
7471 "Address family\n"
7472 "Address Family Modifier\n"
e0bce756 7473 BGP_SOFT_STR)
718e3744 7474{
7475 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
7476 BGP_CLEAR_SOFT_BOTH, argv[0]);
7477}
7478
7479DEFUN (clear_bgp_all_soft,
7480 clear_bgp_all_soft_cmd,
7481 "clear bgp * soft",
7482 CLEAR_STR
7483 BGP_STR
7484 "Clear all peers\n"
e0bce756 7485 BGP_SOFT_STR)
718e3744 7486{
7487 if (argc == 1)
7488 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
7489 BGP_CLEAR_SOFT_BOTH, argv[0]);
7490
7491 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
7492 BGP_CLEAR_SOFT_BOTH, argv[0]);
7493}
7494
7495ALIAS (clear_bgp_all_soft,
7496 clear_bgp_instance_all_soft_cmd,
7497 "clear bgp view WORD * soft",
7498 CLEAR_STR
7499 BGP_STR
7500 "BGP view\n"
7501 "view name\n"
7502 "Clear all peers\n"
e0bce756 7503 BGP_SOFT_STR)
718e3744 7504
7505ALIAS (clear_bgp_all_soft,
7506 clear_bgp_ipv6_all_soft_cmd,
7507 "clear bgp ipv6 * soft",
7508 CLEAR_STR
7509 BGP_STR
7510 "Address family\n"
7511 "Clear all peers\n"
e0bce756 7512 BGP_SOFT_STR)
718e3744 7513
7514DEFUN (clear_ip_bgp_peer_soft,
7515 clear_ip_bgp_peer_soft_cmd,
7516 "clear ip bgp A.B.C.D soft",
7517 CLEAR_STR
7518 IP_STR
7519 BGP_STR
7520 "BGP neighbor address to clear\n"
e0bce756 7521 BGP_SOFT_STR)
718e3744 7522{
7523 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
7524 BGP_CLEAR_SOFT_BOTH, argv[0]);
7525}
7526
7527DEFUN (clear_ip_bgp_peer_ipv4_soft,
7528 clear_ip_bgp_peer_ipv4_soft_cmd,
7529 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft",
7530 CLEAR_STR
7531 IP_STR
7532 BGP_STR
7533 "BGP neighbor address to clear\n"
7534 "Address family\n"
7535 "Address Family Modifier\n"
7536 "Address Family Modifier\n"
e0bce756 7537 BGP_SOFT_STR)
718e3744 7538{
7539 if (strncmp (argv[1], "m", 1) == 0)
7540 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
7541 BGP_CLEAR_SOFT_BOTH, argv[0]);
7542
7543 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
7544 BGP_CLEAR_SOFT_BOTH, argv[0]);
7545}
7546
7547DEFUN (clear_ip_bgp_peer_vpnv4_soft,
7548 clear_ip_bgp_peer_vpnv4_soft_cmd,
7549 "clear ip bgp A.B.C.D vpnv4 unicast soft",
7550 CLEAR_STR
7551 IP_STR
7552 BGP_STR
7553 "BGP neighbor address to clear\n"
7554 "Address family\n"
7555 "Address Family Modifier\n"
e0bce756 7556 BGP_SOFT_STR)
718e3744 7557{
7558 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
7559 BGP_CLEAR_SOFT_BOTH, argv[0]);
7560}
7561
7562DEFUN (clear_bgp_peer_soft,
7563 clear_bgp_peer_soft_cmd,
a80beece 7564 "clear bgp (A.B.C.D|X:X::X:X|WORD) soft",
718e3744 7565 CLEAR_STR
7566 BGP_STR
7567 "BGP neighbor address to clear\n"
7568 "BGP IPv6 neighbor to clear\n"
a80beece 7569 "BGP neighbor on interface to clear\n"
e0bce756 7570 BGP_SOFT_STR)
718e3744 7571{
7572 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
7573 BGP_CLEAR_SOFT_BOTH, argv[0]);
7574}
7575
7576ALIAS (clear_bgp_peer_soft,
7577 clear_bgp_ipv6_peer_soft_cmd,
a80beece 7578 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) soft",
718e3744 7579 CLEAR_STR
7580 BGP_STR
7581 "Address family\n"
7582 "BGP neighbor address to clear\n"
7583 "BGP IPv6 neighbor to clear\n"
a80beece 7584 "BGP neighbor on interface to clear\n"
e0bce756 7585 BGP_SOFT_STR)
718e3744 7586
7587DEFUN (clear_ip_bgp_peer_group_soft,
7588 clear_ip_bgp_peer_group_soft_cmd,
7589 "clear ip bgp peer-group WORD soft",
7590 CLEAR_STR
7591 IP_STR
7592 BGP_STR
7593 "Clear all members of peer-group\n"
7594 "BGP peer-group name\n"
e0bce756 7595 BGP_SOFT_STR)
718e3744 7596{
7597 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
7598 BGP_CLEAR_SOFT_BOTH, argv[0]);
7599}
7600
7601DEFUN (clear_ip_bgp_peer_group_ipv4_soft,
7602 clear_ip_bgp_peer_group_ipv4_soft_cmd,
7603 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft",
7604 CLEAR_STR
7605 IP_STR
7606 BGP_STR
7607 "Clear all members of peer-group\n"
7608 "BGP peer-group name\n"
7609 "Address family\n"
7610 "Address Family modifier\n"
7611 "Address Family modifier\n"
e0bce756 7612 BGP_SOFT_STR)
718e3744 7613{
7614 if (strncmp (argv[1], "m", 1) == 0)
7615 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
7616 BGP_CLEAR_SOFT_BOTH, argv[0]);
7617
7618 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
7619 BGP_CLEAR_SOFT_BOTH, argv[0]);
7620}
7621
7622DEFUN (clear_bgp_peer_group_soft,
7623 clear_bgp_peer_group_soft_cmd,
7624 "clear bgp peer-group WORD soft",
7625 CLEAR_STR
7626 BGP_STR
7627 "Clear all members of peer-group\n"
7628 "BGP peer-group name\n"
e0bce756 7629 BGP_SOFT_STR)
718e3744 7630{
7631 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
7632 BGP_CLEAR_SOFT_BOTH, argv[0]);
7633}
7634
7635ALIAS (clear_bgp_peer_group_soft,
7636 clear_bgp_ipv6_peer_group_soft_cmd,
7637 "clear bgp ipv6 peer-group WORD soft",
7638 CLEAR_STR
7639 BGP_STR
7640 "Address family\n"
7641 "Clear all members of peer-group\n"
7642 "BGP peer-group name\n"
e0bce756 7643 BGP_SOFT_STR)
718e3744 7644
7645DEFUN (clear_ip_bgp_external_soft,
7646 clear_ip_bgp_external_soft_cmd,
7647 "clear ip bgp external soft",
7648 CLEAR_STR
7649 IP_STR
7650 BGP_STR
7651 "Clear all external peers\n"
e0bce756 7652 BGP_SOFT_STR)
718e3744 7653{
7654 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7655 BGP_CLEAR_SOFT_BOTH, NULL);
7656}
7657
7658DEFUN (clear_ip_bgp_external_ipv4_soft,
7659 clear_ip_bgp_external_ipv4_soft_cmd,
7660 "clear ip bgp external ipv4 (unicast|multicast) soft",
7661 CLEAR_STR
7662 IP_STR
7663 BGP_STR
7664 "Clear all external peers\n"
7665 "Address family\n"
7666 "Address Family modifier\n"
7667 "Address Family modifier\n"
e0bce756 7668 BGP_SOFT_STR)
718e3744 7669{
7670 if (strncmp (argv[0], "m", 1) == 0)
7671 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
7672 BGP_CLEAR_SOFT_BOTH, NULL);
7673
7674 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7675 BGP_CLEAR_SOFT_BOTH, NULL);
7676}
7677
7678DEFUN (clear_bgp_external_soft,
7679 clear_bgp_external_soft_cmd,
7680 "clear bgp external soft",
7681 CLEAR_STR
7682 BGP_STR
7683 "Clear all external peers\n"
e0bce756 7684 BGP_SOFT_STR)
718e3744 7685{
7686 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
7687 BGP_CLEAR_SOFT_BOTH, NULL);
7688}
7689
7690ALIAS (clear_bgp_external_soft,
7691 clear_bgp_ipv6_external_soft_cmd,
7692 "clear bgp ipv6 external soft",
7693 CLEAR_STR
7694 BGP_STR
7695 "Address family\n"
7696 "Clear all external peers\n"
e0bce756 7697 BGP_SOFT_STR)
718e3744 7698
7699DEFUN (clear_ip_bgp_as_soft,
7700 clear_ip_bgp_as_soft_cmd,
320da874 7701 "clear ip bgp " CMD_AS_RANGE " soft",
718e3744 7702 CLEAR_STR
7703 IP_STR
7704 BGP_STR
7705 "Clear peers with the AS number\n"
e0bce756 7706 BGP_SOFT_STR)
718e3744 7707{
7708 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
7709 BGP_CLEAR_SOFT_BOTH, argv[0]);
7710}
7711
7712DEFUN (clear_ip_bgp_as_ipv4_soft,
7713 clear_ip_bgp_as_ipv4_soft_cmd,
320da874 7714 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft",
718e3744 7715 CLEAR_STR
7716 IP_STR
7717 BGP_STR
7718 "Clear peers with the AS number\n"
7719 "Address family\n"
7720 "Address Family Modifier\n"
7721 "Address Family Modifier\n"
e0bce756 7722 BGP_SOFT_STR)
718e3744 7723{
7724 if (strncmp (argv[1], "m", 1) == 0)
7725 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
7726 BGP_CLEAR_SOFT_BOTH, argv[0]);
7727
7728 return bgp_clear_vty (vty, NULL,AFI_IP, SAFI_UNICAST, clear_as,
7729 BGP_CLEAR_SOFT_BOTH, argv[0]);
7730}
7731
7732DEFUN (clear_ip_bgp_as_vpnv4_soft,
7733 clear_ip_bgp_as_vpnv4_soft_cmd,
320da874 7734 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft",
718e3744 7735 CLEAR_STR
7736 IP_STR
7737 BGP_STR
7738 "Clear peers with the AS number\n"
7739 "Address family\n"
7740 "Address Family Modifier\n"
e0bce756 7741 BGP_SOFT_STR)
718e3744 7742{
7743 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
7744 BGP_CLEAR_SOFT_BOTH, argv[0]);
7745}
7746
7747DEFUN (clear_bgp_as_soft,
7748 clear_bgp_as_soft_cmd,
320da874 7749 "clear bgp " CMD_AS_RANGE " soft",
718e3744 7750 CLEAR_STR
7751 BGP_STR
7752 "Clear peers with the AS number\n"
e0bce756 7753 BGP_SOFT_STR)
718e3744 7754{
7755 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
7756 BGP_CLEAR_SOFT_BOTH, argv[0]);
7757}
7758
7759ALIAS (clear_bgp_as_soft,
7760 clear_bgp_ipv6_as_soft_cmd,
320da874 7761 "clear bgp ipv6 " CMD_AS_RANGE " soft",
718e3744 7762 CLEAR_STR
7763 BGP_STR
7764 "Address family\n"
7765 "Clear peers with the AS number\n"
e0bce756 7766 BGP_SOFT_STR)
6b0655a2 7767
fee0f4c6 7768/* RS-client soft reconfiguration. */
7769#ifdef HAVE_IPV6
7770DEFUN (clear_bgp_all_rsclient,
7771 clear_bgp_all_rsclient_cmd,
7772 "clear bgp * rsclient",
7773 CLEAR_STR
7774 BGP_STR
7775 "Clear all peers\n"
e0bce756 7776 BGP_SOFT_RSCLIENT_RIB_STR)
fee0f4c6 7777{
7778 if (argc == 1)
7779 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
7780 BGP_CLEAR_SOFT_RSCLIENT, NULL);
7781
7782 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
7783 BGP_CLEAR_SOFT_RSCLIENT, NULL);
7784}
7785
7786ALIAS (clear_bgp_all_rsclient,
7787 clear_bgp_ipv6_all_rsclient_cmd,
7788 "clear bgp ipv6 * rsclient",
7789 CLEAR_STR
7790 BGP_STR
7791 "Address family\n"
7792 "Clear all peers\n"
e0bce756 7793 BGP_SOFT_RSCLIENT_RIB_STR)
fee0f4c6 7794
7795ALIAS (clear_bgp_all_rsclient,
7796 clear_bgp_instance_all_rsclient_cmd,
7797 "clear bgp view WORD * rsclient",
7798 CLEAR_STR
7799 BGP_STR
7800 "BGP view\n"
7801 "view name\n"
7802 "Clear all peers\n"
e0bce756 7803 BGP_SOFT_RSCLIENT_RIB_STR)
fee0f4c6 7804
7805ALIAS (clear_bgp_all_rsclient,
7806 clear_bgp_ipv6_instance_all_rsclient_cmd,
7807 "clear bgp ipv6 view WORD * rsclient",
7808 CLEAR_STR
7809 BGP_STR
7810 "Address family\n"
7811 "BGP view\n"
7812 "view name\n"
7813 "Clear all peers\n"
e0bce756 7814 BGP_SOFT_RSCLIENT_RIB_STR)
fee0f4c6 7815#endif /* HAVE_IPV6 */
7816
7817DEFUN (clear_ip_bgp_all_rsclient,
7818 clear_ip_bgp_all_rsclient_cmd,
7819 "clear ip bgp * rsclient",
7820 CLEAR_STR
7821 IP_STR
7822 BGP_STR
7823 "Clear all peers\n"
e0bce756 7824 BGP_SOFT_RSCLIENT_RIB_STR)
fee0f4c6 7825{
7826 if (argc == 1)
7827 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
7828 BGP_CLEAR_SOFT_RSCLIENT, NULL);
7829
7830 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
7831 BGP_CLEAR_SOFT_RSCLIENT, NULL);
7832}
7833
7834ALIAS (clear_ip_bgp_all_rsclient,
7835 clear_ip_bgp_instance_all_rsclient_cmd,
7836 "clear ip bgp view WORD * rsclient",
7837 CLEAR_STR
7838 IP_STR
7839 BGP_STR
7840 "BGP view\n"
7841 "view name\n"
7842 "Clear all peers\n"
e0bce756 7843 BGP_SOFT_RSCLIENT_RIB_STR)
fee0f4c6 7844
7845#ifdef HAVE_IPV6
7846DEFUN (clear_bgp_peer_rsclient,
7847 clear_bgp_peer_rsclient_cmd,
a80beece 7848 "clear bgp (A.B.C.D|X:X::X:X|WORD) rsclient",
fee0f4c6 7849 CLEAR_STR
7850 BGP_STR
7851 "BGP neighbor IP address to clear\n"
7852 "BGP IPv6 neighbor to clear\n"
a80beece 7853 "BGP neighbor on interface to clear\n"
e0bce756 7854 BGP_SOFT_RSCLIENT_RIB_STR)
fee0f4c6 7855{
7856 if (argc == 2)
7857 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_peer,
7858 BGP_CLEAR_SOFT_RSCLIENT, argv[1]);
7859
7860 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
7861 BGP_CLEAR_SOFT_RSCLIENT, argv[0]);
7862}
7863
7864ALIAS (clear_bgp_peer_rsclient,
7865 clear_bgp_ipv6_peer_rsclient_cmd,
a80beece 7866 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) rsclient",
fee0f4c6 7867 CLEAR_STR
7868 BGP_STR
7869 "Address family\n"
7870 "BGP neighbor IP address to clear\n"
7871 "BGP IPv6 neighbor to clear\n"
a80beece 7872 "BGP neighbor on interface to clear\n"
e0bce756 7873 BGP_SOFT_RSCLIENT_RIB_STR)
fee0f4c6 7874
7875ALIAS (clear_bgp_peer_rsclient,
7876 clear_bgp_instance_peer_rsclient_cmd,
a80beece 7877 "clear bgp view WORD (A.B.C.D|X:X::X:X|WORD) rsclient",
fee0f4c6 7878 CLEAR_STR
7879 BGP_STR
7880 "BGP view\n"
7881 "view name\n"
7882 "BGP neighbor IP address to clear\n"
7883 "BGP IPv6 neighbor to clear\n"
a80beece 7884 "BGP neighbor on interface to clear\n"
e0bce756 7885 BGP_SOFT_RSCLIENT_RIB_STR)
fee0f4c6 7886
7887ALIAS (clear_bgp_peer_rsclient,
7888 clear_bgp_ipv6_instance_peer_rsclient_cmd,
a80beece 7889 "clear bgp ipv6 view WORD (A.B.C.D|X:X::X:X|WORD) rsclient",
fee0f4c6 7890 CLEAR_STR
7891 BGP_STR
7892 "Address family\n"
7893 "BGP view\n"
7894 "view name\n"
7895 "BGP neighbor IP address to clear\n"
7896 "BGP IPv6 neighbor to clear\n"
a80beece 7897 "BGP neighbor on interface to clear\n"
e0bce756 7898 BGP_SOFT_RSCLIENT_RIB_STR)
fee0f4c6 7899#endif /* HAVE_IPV6 */
7900
7901DEFUN (clear_ip_bgp_peer_rsclient,
7902 clear_ip_bgp_peer_rsclient_cmd,
a80beece 7903 "clear ip bgp (A.B.C.D|X:X::X:X|WORD) rsclient",
fee0f4c6 7904 CLEAR_STR
7905 IP_STR
7906 BGP_STR
7907 "BGP neighbor IP address to clear\n"
7908 "BGP IPv6 neighbor to clear\n"
a80beece 7909 "BGP neighbor on interface to clear\n"
e0bce756 7910 BGP_SOFT_RSCLIENT_RIB_STR)
fee0f4c6 7911{
7912 if (argc == 2)
7913 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_peer,
7914 BGP_CLEAR_SOFT_RSCLIENT, argv[1]);
7915
7916 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
7917 BGP_CLEAR_SOFT_RSCLIENT, argv[0]);
7918}
7919
7920ALIAS (clear_ip_bgp_peer_rsclient,
7921 clear_ip_bgp_instance_peer_rsclient_cmd,
a80beece 7922 "clear ip bgp view WORD (A.B.C.D|X:X::X:X|WORD) rsclient",
fee0f4c6 7923 CLEAR_STR
7924 IP_STR
7925 BGP_STR
7926 "BGP view\n"
7927 "view name\n"
7928 "BGP neighbor IP address to clear\n"
7929 "BGP IPv6 neighbor to clear\n"
a80beece 7930 "BGP neighbor on interface to clear\n"
e0bce756 7931 BGP_SOFT_RSCLIENT_RIB_STR)
fee0f4c6 7932
e0081f70
ML
7933DEFUN (show_bgp_views,
7934 show_bgp_views_cmd,
7935 "show bgp views",
7936 SHOW_STR
7937 BGP_STR
7938 "Show the defined BGP views\n")
7939{
7940 struct list *inst = bm->bgp;
7941 struct listnode *node;
7942 struct bgp *bgp;
7943
7944 if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
7945 {
7946 vty_out (vty, "Multiple BGP views are not defined%s", VTY_NEWLINE);
7947 return CMD_WARNING;
7948 }
7949
7950 vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE);
7951 for (ALL_LIST_ELEMENTS_RO(inst, node, bgp))
7952 vty_out (vty, "\t%s (AS%u)%s",
7953 bgp->name ? bgp->name : "(null)",
7954 bgp->as, VTY_NEWLINE);
7955
7956 return CMD_SUCCESS;
7957}
7958
4bf6a362
PJ
7959DEFUN (show_bgp_memory,
7960 show_bgp_memory_cmd,
7961 "show bgp memory",
7962 SHOW_STR
7963 BGP_STR
7964 "Global BGP memory statistics\n")
7965{
7966 char memstrbuf[MTYPE_MEMSTR_LEN];
7967 unsigned long count;
7968
7969 /* RIB related usage stats */
7970 count = mtype_stats_alloc (MTYPE_BGP_NODE);
7971 vty_out (vty, "%ld RIB nodes, using %s of memory%s", count,
7972 mtype_memstr (memstrbuf, sizeof (memstrbuf),
7973 count * sizeof (struct bgp_node)),
7974 VTY_NEWLINE);
7975
7976 count = mtype_stats_alloc (MTYPE_BGP_ROUTE);
7977 vty_out (vty, "%ld BGP routes, using %s of memory%s", count,
7978 mtype_memstr (memstrbuf, sizeof (memstrbuf),
7979 count * sizeof (struct bgp_info)),
7980 VTY_NEWLINE);
fb982c25
PJ
7981 if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA)))
7982 vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count,
7983 mtype_memstr (memstrbuf, sizeof (memstrbuf),
7984 count * sizeof (struct bgp_info_extra)),
7985 VTY_NEWLINE);
4bf6a362
PJ
7986
7987 if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC)))
7988 vty_out (vty, "%ld Static routes, using %s of memory%s", count,
7989 mtype_memstr (memstrbuf, sizeof (memstrbuf),
7990 count * sizeof (struct bgp_static)),
7991 VTY_NEWLINE);
3f9c7369
DS
7992
7993 if ((count = mtype_stats_alloc (MTYPE_BGP_PACKET)))
7994 vty_out (vty, "%ld Packets, using %s of memory%s", count,
7995 mtype_memstr (memstrbuf, sizeof (memstrbuf),
7996 count * sizeof (struct bpacket)),
7997 VTY_NEWLINE);
4bf6a362
PJ
7998
7999 /* Adj-In/Out */
8000 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN)))
8001 vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count,
8002 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8003 count * sizeof (struct bgp_adj_in)),
8004 VTY_NEWLINE);
8005 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT)))
8006 vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count,
8007 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8008 count * sizeof (struct bgp_adj_out)),
8009 VTY_NEWLINE);
8010
8011 if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE)))
8012 vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count,
8013 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8014 count * sizeof (struct bgp_nexthop_cache)),
8015 VTY_NEWLINE);
8016
8017 if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO)))
8018 vty_out (vty, "%ld Dampening entries, using %s of memory%s", count,
8019 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8020 count * sizeof (struct bgp_damp_info)),
8021 VTY_NEWLINE);
8022
8023 /* Attributes */
8024 count = attr_count();
8025 vty_out (vty, "%ld BGP attributes, using %s of memory%s", count,
8026 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8027 count * sizeof(struct attr)),
8028 VTY_NEWLINE);
fb982c25
PJ
8029 if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA)))
8030 vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count,
8031 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8032 count * sizeof(struct attr_extra)),
8033 VTY_NEWLINE);
4bf6a362
PJ
8034
8035 if ((count = attr_unknown_count()))
8036 vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE);
8037
8038 /* AS_PATH attributes */
8039 count = aspath_count ();
8040 vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count,
8041 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8042 count * sizeof (struct aspath)),
8043 VTY_NEWLINE);
8044
8045 count = mtype_stats_alloc (MTYPE_AS_SEG);
8046 vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count,
8047 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8048 count * sizeof (struct assegment)),
8049 VTY_NEWLINE);
8050
8051 /* Other attributes */
8052 if ((count = community_count ()))
8053 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
8054 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8055 count * sizeof (struct community)),
8056 VTY_NEWLINE);
8057 if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY)))
8058 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
8059 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8060 count * sizeof (struct ecommunity)),
8061 VTY_NEWLINE);
8062
8063 if ((count = mtype_stats_alloc (MTYPE_CLUSTER)))
8064 vty_out (vty, "%ld Cluster lists, using %s of memory%s", count,
8065 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8066 count * sizeof (struct cluster_list)),
8067 VTY_NEWLINE);
8068
8069 /* Peer related usage */
8070 count = mtype_stats_alloc (MTYPE_BGP_PEER);
8071 vty_out (vty, "%ld peers, using %s of memory%s", count,
8072 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8073 count * sizeof (struct peer)),
8074 VTY_NEWLINE);
8075
8076 if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP)))
8077 vty_out (vty, "%ld peer groups, using %s of memory%s", count,
8078 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8079 count * sizeof (struct peer_group)),
8080 VTY_NEWLINE);
8081
8082 /* Other */
8083 if ((count = mtype_stats_alloc (MTYPE_HASH)))
8084 vty_out (vty, "%ld hash tables, using %s of memory%s", count,
8085 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8086 count * sizeof (struct hash)),
8087 VTY_NEWLINE);
8088 if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET)))
8089 vty_out (vty, "%ld hash buckets, using %s of memory%s", count,
8090 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8091 count * sizeof (struct hash_backet)),
8092 VTY_NEWLINE);
8093 if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP)))
8094 vty_out (vty, "%ld compiled regexes, using %s of memory%s", count,
8095 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8096 count * sizeof (regex_t)),
8097 VTY_NEWLINE);
8098 return CMD_SUCCESS;
8099}
fee0f4c6 8100
47fc97cc
DS
8101static int
8102bgp_adj_out_count (struct peer *peer, int afi, int safi)
8103{
8104 struct bgp_table *table;
8105 struct bgp_node *rn;
8106 struct bgp_adj_out *adj;
8107 int count = 0;
8108
8109 if (!peer) return(0);
8110
8111 table = peer->bgp->rib[afi][safi];
8112 if (!table) return(0);
8113 for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn))
8114 if (bgp_adj_out_lookup(peer, NULL, afi, safi, rn))
8115 count++;
8116 return (count);
8117}
8118
718e3744 8119/* Show BGP peer's summary information. */
94f2b392 8120static int
47fc97cc 8121bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, char *delimit)
718e3744 8122{
8123 struct peer *peer;
1eb8ef25 8124 struct listnode *node, *nnode;
f14e6fdb
DS
8125 unsigned int count = 0, dn_count = 0;
8126 char timebuf[BGP_UPTIME_LEN], dn_flag[2];
718e3744 8127 int len;
f14e6fdb 8128 struct peer_group *group;
718e3744 8129
8130 /* Header string for each address family. */
8131 static char header[] = "Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd";
47fc97cc
DS
8132 static char header_csv[] = "Neighbor, V, AS, MsgRcvd, MsgSent, TblVer, InQ, OutQ, Up/Down, State/PfxRcd, PfxAdv";
8133
1eb8ef25 8134 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
718e3744 8135 {
1ff9a340
DS
8136 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
8137 continue;
8138
718e3744 8139 if (peer->afc[afi][safi])
8140 {
47fc97cc
DS
8141 if (delimit)
8142 {
8143 if (!count)
8144 {
8145 vty_out (vty, "%s%s", header_csv, VTY_NEWLINE);
8146 }
8147 }
8148 else if (!count)
4bf6a362
PJ
8149 {
8150 unsigned long ents;
8151 char memstrbuf[MTYPE_MEMSTR_LEN];
8152
8153 /* Usage summary and header */
8154 vty_out (vty,
aea339f7 8155 "BGP router identifier %s, local AS number %u%s",
4bf6a362 8156 inet_ntoa (bgp->router_id), bgp->as, VTY_NEWLINE);
f188f2c4
DS
8157 if (bgp_update_delay_configured(bgp))
8158 {
8159 vty_out (vty, "Read-only mode update-delay limit: %d seconds%s",
8160 bgp->v_update_delay, VTY_NEWLINE);
8161 if (bgp->v_update_delay != bgp->v_establish_wait)
8162 vty_out (vty, " Establish wait: %d seconds%s",
8163 bgp->v_establish_wait, VTY_NEWLINE);
8164 if (bgp_update_delay_active(bgp))
8165 {
8166 vty_out (vty, " First neighbor established: %s%s",
8167 bgp->update_delay_begin_time, VTY_NEWLINE);
8168 vty_out (vty, " Delay in progress%s", VTY_NEWLINE);
8169 }
8170 else
8171 {
8172 if (bgp->update_delay_over)
8173 {
8174 vty_out (vty, " First neighbor established: %s%s",
8175 bgp->update_delay_begin_time, VTY_NEWLINE);
4a16ae86 8176 vty_out (vty, " Best-paths resumed: %s%s",
f188f2c4 8177 bgp->update_delay_end_time, VTY_NEWLINE);
4a16ae86
DS
8178 vty_out (vty, " zebra update resumed: %s%s",
8179 bgp->update_delay_zebra_resume_time, VTY_NEWLINE);
8180 vty_out (vty, " peers update resumed: %s%s",
8181 bgp->update_delay_peers_resume_time, VTY_NEWLINE);
f188f2c4
DS
8182 }
8183 }
8184 }
4bf6a362 8185
abc920f8
DS
8186 if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active)
8187 vty_out (vty, "Max-med on-startup active%s", VTY_NEWLINE);
8188 if (bgp->v_maxmed_admin)
8189 vty_out (vty, "Max-med administrative active%s", VTY_NEWLINE);
8190
3f9c7369
DS
8191 vty_out(vty, "BGP table version %llu%s",
8192 bgp_table_version(bgp->rib[afi][safi]), VTY_NEWLINE);
8193
4bf6a362
PJ
8194 ents = bgp_table_count (bgp->rib[afi][safi]);
8195 vty_out (vty, "RIB entries %ld, using %s of memory%s", ents,
8196 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8197 ents * sizeof (struct bgp_node)),
8198 VTY_NEWLINE);
8199
8200 /* Peer related usage */
8201 ents = listcount (bgp->peer);
8202 vty_out (vty, "Peers %ld, using %s of memory%s",
8203 ents,
8204 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8205 ents * sizeof (struct peer)),
8206 VTY_NEWLINE);
8207
8208 if ((ents = listcount (bgp->rsclient)))
8209 vty_out (vty, "RS-Client peers %ld, using %s of memory%s",
8210 ents,
8211 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8212 ents * sizeof (struct peer)),
8213 VTY_NEWLINE);
8214
8215 if ((ents = listcount (bgp->group)))
8216 vty_out (vty, "Peer groups %ld, using %s of memory%s", ents,
8217 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8218 ents * sizeof (struct peer_group)),
8219 VTY_NEWLINE);
8220
8221 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
8222 vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE);
8223 vty_out (vty, "%s", VTY_NEWLINE);
8224 vty_out (vty, "%s%s", header, VTY_NEWLINE);
8225 }
8226
718e3744 8227 count++;
8228
f14e6fdb
DS
8229 memset(dn_flag, '\0', sizeof(dn_flag));
8230 if (peer_dynamic_neighbor(peer))
8231 {
8232 dn_count++;
8233 dn_flag[0] = '*';
8234 }
8235
8236 len = vty_out (vty, "%s%s", dn_flag, peer->host);
718e3744 8237 len = 16 - len;
8238 if (len < 1)
8239 vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
8240 else
8241 vty_out (vty, "%*s", len, " ");
8242
47fc97cc
DS
8243 if (delimit)
8244 vty_out(vty, "%c", *delimit);
718e3744 8245
47fc97cc 8246 vty_out (vty, "4 ");
718e3744 8247
47fc97cc
DS
8248 if (delimit)
8249 vty_out(vty, "%c", *delimit);
8250
8251 if (!delimit)
3f9c7369 8252 vty_out (vty, "%5u %7d %7d %8lu %4d %4u ",
47fc97cc
DS
8253 peer->as,
8254 peer->open_in + peer->update_in + peer->keepalive_in
8255 + peer->notify_in + peer->refresh_in
8256 + peer->dynamic_cap_in,
8257 peer->open_out + peer->update_out + peer->keepalive_out
8258 + peer->notify_out + peer->refresh_out
8259 + peer->dynamic_cap_out,
3f9c7369 8260 peer->version[afi][safi],
47fc97cc 8261 0,
3f9c7369 8262 (unsigned long) peer->obuf->count);
47fc97cc 8263 else
3f9c7369 8264 vty_out (vty, "%5u %c %7d %c %7d %c %8lu %c %4d %c %4u %c",
47fc97cc
DS
8265 peer->as, *delimit,
8266 peer->open_in + peer->update_in + peer->keepalive_in
8267 + peer->notify_in + peer->refresh_in
8268 + peer->dynamic_cap_in, *delimit,
8269 peer->open_out + peer->update_out + peer->keepalive_out
8270 + peer->notify_out + peer->refresh_out
8271 + peer->dynamic_cap_out, *delimit,
3f9c7369 8272 peer->version[afi][safi], *delimit,
47fc97cc 8273 0, *delimit,
3f9c7369 8274 (unsigned long) peer->obuf->count, *delimit);
47fc97cc
DS
8275
8276 vty_out (vty, "%8s",
718e3744 8277 peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN));
47fc97cc
DS
8278 if (delimit)
8279 vty_out(vty, "%c", *delimit);
718e3744 8280
8281 if (peer->status == Established)
718e3744 8282 vty_out (vty, " %8ld", peer->pcount[afi][safi]);
718e3744 8283 else
8284 {
8285 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
8286 vty_out (vty, " Idle (Admin)");
8287 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
8288 vty_out (vty, " Idle (PfxCt)");
8289 else
8290 vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, peer->status));
8291 }
47fc97cc
DS
8292 if (delimit)
8293 vty_out(vty, ", %d", bgp_adj_out_count(peer, afi, safi));
718e3744 8294
8295 vty_out (vty, "%s", VTY_NEWLINE);
8296 }
8297 }
8298
8299 if (count)
8300 vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE,
8301 count, VTY_NEWLINE);
8302 else
8303 vty_out (vty, "No %s neighbor is configured%s",
8304 afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
f188f2c4 8305
f14e6fdb
DS
8306
8307 if (dn_count)
8308 {
8309 vty_out(vty, "* - dynamic neighbor%s", VTY_NEWLINE);
8310 vty_out(vty,
8311 "%d %s dynamic neighbor(s), limit %d%s",
8312 dn_count, afi == AFI_IP ? "IPv4" : "IPv6",
8313 bgp->dynamic_neighbors_limit, VTY_NEWLINE);
8314 }
8315
718e3744 8316 return CMD_SUCCESS;
8317}
8318
47fc97cc
DS
8319static int
8320bgp_show_summary_vty (struct vty *vty, const char *name,
8321 afi_t afi, safi_t safi, char *delimit)
718e3744 8322{
8323 struct bgp *bgp;
8324
8325 if (name)
8326 {
8327 bgp = bgp_lookup_by_name (name);
47fc97cc 8328
718e3744 8329 if (! bgp)
8330 {
47fc97cc 8331 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
718e3744 8332 return CMD_WARNING;
8333 }
8334
47fc97cc 8335 bgp_show_summary (vty, bgp, afi, safi, delimit);
718e3744 8336 return CMD_SUCCESS;
8337 }
47fc97cc 8338
718e3744 8339 bgp = bgp_get_default ();
8340
8341 if (bgp)
47fc97cc
DS
8342 bgp_show_summary (vty, bgp, afi, safi, delimit);
8343
718e3744 8344 return CMD_SUCCESS;
8345}
8346
8347/* `show ip bgp summary' commands. */
47fc97cc 8348DEFUN (show_ip_bgp_summary,
718e3744 8349 show_ip_bgp_summary_cmd,
8350 "show ip bgp summary",
8351 SHOW_STR
8352 IP_STR
8353 BGP_STR
8354 "Summary of BGP neighbor status\n")
8355{
47fc97cc
DS
8356 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST, NULL);
8357}
8358
8359DEFUN (show_ip_bgp_summary_csv,
8360 show_ip_bgp_summary_csv_cmd,
8361 "show ip bgp summary csv",
8362 SHOW_STR
8363 IP_STR
8364 BGP_STR
8365 "Summary of BGP neighbor status\n")
8366{
8367 char csv = ',';
8368 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST, &csv);
718e3744 8369}
8370
8371DEFUN (show_ip_bgp_instance_summary,
8372 show_ip_bgp_instance_summary_cmd,
8373 "show ip bgp view WORD summary",
8374 SHOW_STR
8375 IP_STR
8376 BGP_STR
8377 "BGP view\n"
8378 "View name\n"
8379 "Summary of BGP neighbor status\n")
8380{
47fc97cc 8381 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, NULL);
718e3744 8382}
8383
8384DEFUN (show_ip_bgp_ipv4_summary,
8385 show_ip_bgp_ipv4_summary_cmd,
8386 "show ip bgp ipv4 (unicast|multicast) summary",
8387 SHOW_STR
8388 IP_STR
8389 BGP_STR
8390 "Address family\n"
8391 "Address Family modifier\n"
8392 "Address Family modifier\n"
8393 "Summary of BGP neighbor status\n")
8394{
8395 if (strncmp (argv[0], "m", 1) == 0)
47fc97cc 8396 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, NULL);
718e3744 8397
47fc97cc 8398 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST, NULL);
718e3744 8399}
8400
95cbbd2a
ML
8401ALIAS (show_ip_bgp_ipv4_summary,
8402 show_bgp_ipv4_safi_summary_cmd,
8403 "show bgp ipv4 (unicast|multicast) summary",
8404 SHOW_STR
8405 BGP_STR
8406 "Address family\n"
8407 "Address Family modifier\n"
8408 "Address Family modifier\n"
8409 "Summary of BGP neighbor status\n")
8410
718e3744 8411DEFUN (show_ip_bgp_instance_ipv4_summary,
8412 show_ip_bgp_instance_ipv4_summary_cmd,
8413 "show ip bgp view WORD ipv4 (unicast|multicast) summary",
8414 SHOW_STR
8415 IP_STR
8416 BGP_STR
8417 "BGP view\n"
8418 "View name\n"
8419 "Address family\n"
8420 "Address Family modifier\n"
8421 "Address Family modifier\n"
8422 "Summary of BGP neighbor status\n")
8423{
8424 if (strncmp (argv[1], "m", 1) == 0)
47fc97cc 8425 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, NULL);
718e3744 8426 else
47fc97cc 8427 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, NULL);
718e3744 8428}
8429
95cbbd2a
ML
8430ALIAS (show_ip_bgp_instance_ipv4_summary,
8431 show_bgp_instance_ipv4_safi_summary_cmd,
8432 "show bgp view WORD ipv4 (unicast|multicast) summary",
8433 SHOW_STR
8434 BGP_STR
8435 "BGP view\n"
8436 "View name\n"
8437 "Address family\n"
8438 "Address Family modifier\n"
8439 "Address Family modifier\n"
8440 "Summary of BGP neighbor status\n")
8441
718e3744 8442DEFUN (show_ip_bgp_vpnv4_all_summary,
8443 show_ip_bgp_vpnv4_all_summary_cmd,
8444 "show ip bgp vpnv4 all summary",
8445 SHOW_STR
8446 IP_STR
8447 BGP_STR
8448 "Display VPNv4 NLRI specific information\n"
8449 "Display information about all VPNv4 NLRIs\n"
8450 "Summary of BGP neighbor status\n")
8451{
47fc97cc 8452 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, NULL);
718e3744 8453}
8454
8455DEFUN (show_ip_bgp_vpnv4_rd_summary,
8456 show_ip_bgp_vpnv4_rd_summary_cmd,
8457 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn summary",
8458 SHOW_STR
8459 IP_STR
8460 BGP_STR
8461 "Display VPNv4 NLRI specific information\n"
8462 "Display information for a route distinguisher\n"
8463 "VPN Route Distinguisher\n"
8464 "Summary of BGP neighbor status\n")
8465{
8466 int ret;
8467 struct prefix_rd prd;
8468
8469 ret = str2prefix_rd (argv[0], &prd);
8470 if (! ret)
8471 {
8472 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
8473 return CMD_WARNING;
8474 }
8475
47fc97cc 8476 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, NULL);
718e3744 8477}
8478
8479#ifdef HAVE_IPV6
47fc97cc 8480DEFUN (show_bgp_summary,
718e3744 8481 show_bgp_summary_cmd,
8482 "show bgp summary",
8483 SHOW_STR
8484 BGP_STR
8485 "Summary of BGP neighbor status\n")
8486{
47fc97cc
DS
8487 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, NULL);
8488}
8489
8490DEFUN (show_bgp_summary_csv,
8491 show_bgp_summary_csv_cmd,
8492 "show bgp summary csv",
8493 SHOW_STR
8494 BGP_STR
8495 "Summary of BGP neighbor status\n")
8496{
8497 char csv = ',';
8498 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, &csv);
718e3744 8499}
8500
8501DEFUN (show_bgp_instance_summary,
8502 show_bgp_instance_summary_cmd,
8503 "show bgp view WORD summary",
8504 SHOW_STR
8505 BGP_STR
8506 "BGP view\n"
8507 "View name\n"
8508 "Summary of BGP neighbor status\n")
8509{
47fc97cc 8510 return bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, NULL);
718e3744 8511}
8512
8513ALIAS (show_bgp_summary,
8514 show_bgp_ipv6_summary_cmd,
8515 "show bgp ipv6 summary",
8516 SHOW_STR
8517 BGP_STR
8518 "Address family\n"
8519 "Summary of BGP neighbor status\n")
8520
8521ALIAS (show_bgp_instance_summary,
8522 show_bgp_instance_ipv6_summary_cmd,
8523 "show bgp view WORD ipv6 summary",
8524 SHOW_STR
8525 BGP_STR
8526 "BGP view\n"
8527 "View name\n"
8528 "Address family\n"
8529 "Summary of BGP neighbor status\n")
8530
95cbbd2a
ML
8531DEFUN (show_bgp_ipv6_safi_summary,
8532 show_bgp_ipv6_safi_summary_cmd,
8533 "show bgp ipv6 (unicast|multicast) summary",
8534 SHOW_STR
8535 BGP_STR
8536 "Address family\n"
8537 "Address Family modifier\n"
8538 "Address Family modifier\n"
8539 "Summary of BGP neighbor status\n")
8540{
8541 if (strncmp (argv[0], "m", 1) == 0)
47fc97cc 8542 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST, NULL);
95cbbd2a 8543
47fc97cc 8544 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, NULL);
95cbbd2a
ML
8545}
8546
8547DEFUN (show_bgp_instance_ipv6_safi_summary,
8548 show_bgp_instance_ipv6_safi_summary_cmd,
8549 "show bgp view WORD ipv6 (unicast|multicast) summary",
8550 SHOW_STR
8551 BGP_STR
8552 "BGP view\n"
8553 "View name\n"
8554 "Address family\n"
8555 "Address Family modifier\n"
8556 "Address Family modifier\n"
8557 "Summary of BGP neighbor status\n")
8558{
8559 if (strncmp (argv[1], "m", 1) == 0)
47fc97cc 8560 return bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_MULTICAST, NULL);
95cbbd2a 8561
47fc97cc 8562 return bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, NULL);
95cbbd2a
ML
8563}
8564
718e3744 8565/* old command */
8566DEFUN (show_ipv6_bgp_summary,
8567 show_ipv6_bgp_summary_cmd,
8568 "show ipv6 bgp summary",
8569 SHOW_STR
8570 IPV6_STR
8571 BGP_STR
8572 "Summary of BGP neighbor status\n")
8573{
47fc97cc 8574 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, NULL);
718e3744 8575}
8576
8577/* old command */
8578DEFUN (show_ipv6_mbgp_summary,
8579 show_ipv6_mbgp_summary_cmd,
8580 "show ipv6 mbgp summary",
8581 SHOW_STR
8582 IPV6_STR
8583 MBGP_STR
8584 "Summary of BGP neighbor status\n")
8585{
47fc97cc 8586 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST, NULL);
718e3744 8587}
8588#endif /* HAVE_IPV6 */
6b0655a2 8589
fd79ac91 8590const char *
538621f2 8591afi_safi_print (afi_t afi, safi_t safi)
8592{
8593 if (afi == AFI_IP && safi == SAFI_UNICAST)
8594 return "IPv4 Unicast";
8595 else if (afi == AFI_IP && safi == SAFI_MULTICAST)
8596 return "IPv4 Multicast";
8597 else if (afi == AFI_IP && safi == SAFI_MPLS_VPN)
8598 return "VPNv4 Unicast";
8599 else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
8600 return "IPv6 Unicast";
8601 else if (afi == AFI_IP6 && safi == SAFI_MULTICAST)
8602 return "IPv6 Multicast";
8603 else
8604 return "Unknown";
8605}
8606
718e3744 8607/* Show BGP peer's information. */
8608enum show_type
8609{
8610 show_all,
8611 show_peer
8612};
8613
94f2b392 8614static void
718e3744 8615bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p,
8616 afi_t afi, safi_t safi,
8617 u_int16_t adv_smcap, u_int16_t adv_rmcap,
8618 u_int16_t rcv_smcap, u_int16_t rcv_rmcap)
8619{
8620 /* Send-Mode */
8621 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)
8622 || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
8623 {
8624 vty_out (vty, " Send-mode: ");
8625 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
8626 vty_out (vty, "advertised");
8627 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
8628 vty_out (vty, "%sreceived",
8629 CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ?
8630 ", " : "");
8631 vty_out (vty, "%s", VTY_NEWLINE);
8632 }
8633
8634 /* Receive-Mode */
8635 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)
8636 || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
8637 {
8638 vty_out (vty, " Receive-mode: ");
8639 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
8640 vty_out (vty, "advertised");
8641 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
8642 vty_out (vty, "%sreceived",
8643 CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ?
8644 ", " : "");
8645 vty_out (vty, "%s", VTY_NEWLINE);
8646 }
8647}
8648
94f2b392 8649static void
718e3744 8650bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi)
8651{
8652 struct bgp_filter *filter;
3f9c7369 8653 struct peer_af *paf;
718e3744 8654 char orf_pfx_name[BUFSIZ];
8655 int orf_pfx_count;
8656
8657 filter = &p->filter[afi][safi];
8658
538621f2 8659 vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi),
718e3744 8660 VTY_NEWLINE);
538621f2 8661
718e3744 8662 if (p->af_group[afi][safi])
8663 vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE);
8664
3f9c7369
DS
8665 paf = peer_af_find(p, afi, safi);
8666 if (paf && PAF_SUBGRP(paf))
8667 {
8668 vty_out (vty, " Update group %llu, subgroup %llu%s",
8669 PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id, VTY_NEWLINE);
8670 vty_out (vty, " Packet Queue length %d%s",
8671 bpacket_queue_virtual_length(paf), VTY_NEWLINE);
8672 } else
8673 {
8674 vty_out(vty, " Not part of any update group%s", VTY_NEWLINE);
8675 }
718e3744 8676 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
8677 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
8678 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
8679 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
8680 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
8681 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
8682 vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE);
8683
8684 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
8685 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
8686 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
8687 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
8688 {
8689 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
8690 ORF_TYPE_PREFIX, VTY_NEWLINE);
8691 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
8692 PEER_CAP_ORF_PREFIX_SM_ADV,
8693 PEER_CAP_ORF_PREFIX_RM_ADV,
8694 PEER_CAP_ORF_PREFIX_SM_RCV,
8695 PEER_CAP_ORF_PREFIX_RM_RCV);
8696 }
8697 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
8698 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
8699 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
8700 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
8701 {
8702 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
8703 ORF_TYPE_PREFIX_OLD, VTY_NEWLINE);
8704 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
8705 PEER_CAP_ORF_PREFIX_SM_ADV,
8706 PEER_CAP_ORF_PREFIX_RM_ADV,
8707 PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
8708 PEER_CAP_ORF_PREFIX_RM_OLD_RCV);
8709 }
8710
8711 sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
8712 orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name);
8713
8714 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
8715 || orf_pfx_count)
8716 {
8717 vty_out (vty, " Outbound Route Filter (ORF):");
8718 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
8719 vty_out (vty, " sent;");
8720 if (orf_pfx_count)
8721 vty_out (vty, " received (%d entries)", orf_pfx_count);
8722 vty_out (vty, "%s", VTY_NEWLINE);
8723 }
8724 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
8725 vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE);
8726
8727 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
8728 vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE);
8729 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
8730 vty_out (vty, " Route-Server Client%s", VTY_NEWLINE);
8731 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
8732 vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE);
5000f21c
DS
8733 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE))
8734 vty_out (vty, " Private AS numbers replaced in updates to this neighbor%s", VTY_NEWLINE);
8735 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
8736 vty_out (vty, " Private AS numbers removed in updates to this neighbor%s", VTY_NEWLINE);
8737
c7122e14
DS
8738 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE))
8739 vty_out (vty, " Override ASNs in outbound updates if aspath equals remote-as%s", VTY_NEWLINE);
8740
5000f21c
DS
8741 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) ||
8742 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF_ALL))
718e3744 8743 vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE);
8744 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
8745 vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE);
8746 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
8747 vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE);
8748 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
8749 vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE);
8750 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
8751 || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
8752 {
8753 vty_out (vty, " Community attribute sent to this neighbor");
8754 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
8755 && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
538621f2 8756 vty_out (vty, "(both)%s", VTY_NEWLINE);
718e3744 8757 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
538621f2 8758 vty_out (vty, "(extended)%s", VTY_NEWLINE);
718e3744 8759 else
538621f2 8760 vty_out (vty, "(standard)%s", VTY_NEWLINE);
718e3744 8761 }
8762 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
8763 {
8764 vty_out (vty, " Default information originate,");
8765
8766 if (p->default_rmap[afi][safi].name)
8767 vty_out (vty, " default route-map %s%s,",
8768 p->default_rmap[afi][safi].map ? "*" : "",
8769 p->default_rmap[afi][safi].name);
3f9c7369
DS
8770 if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags,
8771 SUBGRP_STATUS_DEFAULT_ORIGINATE))
718e3744 8772 vty_out (vty, " default sent%s", VTY_NEWLINE);
8773 else
8774 vty_out (vty, " default not sent%s", VTY_NEWLINE);
8775 }
8776
8777 if (filter->plist[FILTER_IN].name
8778 || filter->dlist[FILTER_IN].name
8779 || filter->aslist[FILTER_IN].name
fee0f4c6 8780 || filter->map[RMAP_IN].name)
718e3744 8781 vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE);
8782 if (filter->plist[FILTER_OUT].name
8783 || filter->dlist[FILTER_OUT].name
8784 || filter->aslist[FILTER_OUT].name
fee0f4c6 8785 || filter->map[RMAP_OUT].name
718e3744 8786 || filter->usmap.name)
8787 vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE);
fee0f4c6 8788 if (filter->map[RMAP_IMPORT].name)
8789 vty_out (vty, " Import policy for this RS-client configured%s", VTY_NEWLINE);
8790 if (filter->map[RMAP_EXPORT].name)
8791 vty_out (vty, " Export policy for this RS-client configured%s", VTY_NEWLINE);
718e3744 8792
8793 /* prefix-list */
8794 if (filter->plist[FILTER_IN].name)
8795 vty_out (vty, " Incoming update prefix filter list is %s%s%s",
8796 filter->plist[FILTER_IN].plist ? "*" : "",
8797 filter->plist[FILTER_IN].name,
8798 VTY_NEWLINE);
8799 if (filter->plist[FILTER_OUT].name)
8800 vty_out (vty, " Outgoing update prefix filter list is %s%s%s",
8801 filter->plist[FILTER_OUT].plist ? "*" : "",
8802 filter->plist[FILTER_OUT].name,
8803 VTY_NEWLINE);
8804
8805 /* distribute-list */
8806 if (filter->dlist[FILTER_IN].name)
8807 vty_out (vty, " Incoming update network filter list is %s%s%s",
8808 filter->dlist[FILTER_IN].alist ? "*" : "",
8809 filter->dlist[FILTER_IN].name,
8810 VTY_NEWLINE);
8811 if (filter->dlist[FILTER_OUT].name)
8812 vty_out (vty, " Outgoing update network filter list is %s%s%s",
8813 filter->dlist[FILTER_OUT].alist ? "*" : "",
8814 filter->dlist[FILTER_OUT].name,
8815 VTY_NEWLINE);
8816
8817 /* filter-list. */
8818 if (filter->aslist[FILTER_IN].name)
8819 vty_out (vty, " Incoming update AS path filter list is %s%s%s",
8820 filter->aslist[FILTER_IN].aslist ? "*" : "",
8821 filter->aslist[FILTER_IN].name,
8822 VTY_NEWLINE);
8823 if (filter->aslist[FILTER_OUT].name)
8824 vty_out (vty, " Outgoing update AS path filter list is %s%s%s",
8825 filter->aslist[FILTER_OUT].aslist ? "*" : "",
8826 filter->aslist[FILTER_OUT].name,
8827 VTY_NEWLINE);
8828
8829 /* route-map. */
fee0f4c6 8830 if (filter->map[RMAP_IN].name)
718e3744 8831 vty_out (vty, " Route map for incoming advertisements is %s%s%s",
fee0f4c6 8832 filter->map[RMAP_IN].map ? "*" : "",
8833 filter->map[RMAP_IN].name,
718e3744 8834 VTY_NEWLINE);
fee0f4c6 8835 if (filter->map[RMAP_OUT].name)
718e3744 8836 vty_out (vty, " Route map for outgoing advertisements is %s%s%s",
fee0f4c6 8837 filter->map[RMAP_OUT].map ? "*" : "",
8838 filter->map[RMAP_OUT].name,
8839 VTY_NEWLINE);
8840 if (filter->map[RMAP_IMPORT].name)
8841 vty_out (vty, " Route map for advertisements going into this RS-client's table is %s%s%s",
8842 filter->map[RMAP_IMPORT].map ? "*" : "",
8843 filter->map[RMAP_IMPORT].name,
8844 VTY_NEWLINE);
8845 if (filter->map[RMAP_EXPORT].name)
8846 vty_out (vty, " Route map for advertisements coming from this RS-client is %s%s%s",
8847 filter->map[RMAP_EXPORT].map ? "*" : "",
8848 filter->map[RMAP_EXPORT].name,
718e3744 8849 VTY_NEWLINE);
8850
8851 /* unsuppress-map */
8852 if (filter->usmap.name)
8853 vty_out (vty, " Route map for selective unsuppress is %s%s%s",
8854 filter->usmap.map ? "*" : "",
8855 filter->usmap.name, VTY_NEWLINE);
8856
8857 /* Receive prefix count */
e0701b79 8858 vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE);
8859
718e3744 8860 /* Maximum prefix */
8861 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
8862 {
0a486e5f 8863 vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi],
718e3744 8864 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)
0a486e5f 8865 ? " (warning-only)" : "", VTY_NEWLINE);
8866 vty_out (vty, " Threshold for warning message %d%%",
8867 p->pmax_threshold[afi][safi]);
8868 if (p->pmax_restart[afi][safi])
8869 vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]);
8870 vty_out (vty, "%s", VTY_NEWLINE);
718e3744 8871 }
718e3744 8872
8873 vty_out (vty, "%s", VTY_NEWLINE);
8874}
8875
94f2b392 8876static void
718e3744 8877bgp_show_peer (struct vty *vty, struct peer *p)
8878{
8879 struct bgp *bgp;
a80beece 8880 char buf1[BUFSIZ], buf[SU_ADDRSTRLEN];
718e3744 8881 char timebuf[BGP_UPTIME_LEN];
f14e6fdb 8882 char dn_flag[2];
538621f2 8883 afi_t afi;
8884 safi_t safi;
d6661008
DS
8885 u_int16_t i;
8886 u_char *msg;
718e3744 8887
8888 bgp = p->bgp;
8889
a80beece
DS
8890 if (p->conf_if) /* Configured interface name. */
8891 vty_out (vty, "BGP neighbor on %s: %s, ", p->conf_if,
8892 BGP_PEER_SU_UNSPEC(p) ? "None" :
8893 sockunion2str (&p->su, buf, SU_ADDRSTRLEN));
8894 else /* Configured IP address. */
f14e6fdb
DS
8895 {
8896 memset(dn_flag, '\0', sizeof(dn_flag));
8897 if (peer_dynamic_neighbor(p))
8898 dn_flag[0] = '*';
8899
8900 vty_out (vty, "BGP neighbor is %s%s, ", dn_flag, p->host);
8901 }
8902
aea339f7 8903 vty_out (vty, "remote AS %u, ", p->as);
9d3f9705 8904 vty_out (vty, "local AS %u%s%s, ",
718e3744 8905 p->change_local_as ? p->change_local_as : p->local_as,
8906 CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ?
9d3f9705
AC
8907 " no-prepend" : "",
8908 CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) ?
8909 " replace-as" : "");
718e3744 8910 vty_out (vty, "%s link%s",
8911 p->as == p->local_as ? "internal" : "external",
8912 VTY_NEWLINE);
8913
8914 /* Description. */
8915 if (p->desc)
8916 vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE);
8917
8918 /* Peer-group */
8919 if (p->group)
f14e6fdb
DS
8920 {
8921 vty_out (vty, " Member of peer-group %s for session parameters%s",
8922 p->group->name, VTY_NEWLINE);
8923
8924 if (dn_flag[0])
8925 {
8926 struct prefix *prefix = NULL, *range = NULL;
8927
8928 prefix = sockunion2hostprefix(&(p->su));
8929 if (prefix)
8930 range = peer_group_lookup_dynamic_neighbor_range (p->group,
8931 prefix);
8932 if (range)
8933 {
8934 prefix2str(range, buf1, sizeof(buf1));
8935 vty_out (vty, " Belongs to the subnet range group: %s%s",
8936 buf1, VTY_NEWLINE);
8937 }
8938 }
8939 }
718e3744 8940
8941 /* Administrative shutdown. */
8942 if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
8943 vty_out (vty, " Administratively shut down%s", VTY_NEWLINE);
8944
8945 /* BGP Version. */
8946 vty_out (vty, " BGP version 4");
718e3744 8947 vty_out (vty, ", remote router ID %s%s",
8948 inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ),
8949 VTY_NEWLINE);
8950
8951 /* Confederation */
e0701b79 8952 if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION)
8953 && bgp_confederation_peers_check (bgp, p->as))
718e3744 8954 vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE);
8955
8956 /* Status. */
8957 vty_out (vty, " BGP state = %s",
8958 LOOKUP (bgp_status_msg, p->status));
8959 if (p->status == Established)
8960 vty_out (vty, ", up for %8s",
8961 peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN));
93406d87 8962 else if (p->status == Active)
8963 {
8964 if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE))
8965 vty_out (vty, " (passive)");
8966 else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT))
8967 vty_out (vty, " (NSF passive)");
8968 }
718e3744 8969 vty_out (vty, "%s", VTY_NEWLINE);
8970
8971 /* read timer */
8972 vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN));
cb1faec9
DS
8973 vty_out (vty, ", Last write %s%s",
8974 peer_uptime (p->last_write, timebuf, BGP_UPTIME_LEN), VTY_NEWLINE);
718e3744 8975
8976 /* Configured timer values. */
cb1faec9 8977 vty_out (vty, " Hold time is %d, keepalive interval is %d seconds%s",
718e3744 8978 p->v_holdtime, p->v_keepalive, VTY_NEWLINE);
8979 if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
8980 {
8981 vty_out (vty, " Configured hold time is %d", p->holdtime);
8982 vty_out (vty, ", keepalive interval is %d seconds%s",
8983 p->keepalive, VTY_NEWLINE);
8984 }
93406d87 8985
718e3744 8986 /* Capability. */
8987 if (p->status == Established)
8988 {
538621f2 8989 if (p->cap
718e3744 8990 || p->afc_adv[AFI_IP][SAFI_UNICAST]
8991 || p->afc_recv[AFI_IP][SAFI_UNICAST]
8992 || p->afc_adv[AFI_IP][SAFI_MULTICAST]
8993 || p->afc_recv[AFI_IP][SAFI_MULTICAST]
8994#ifdef HAVE_IPV6
8995 || p->afc_adv[AFI_IP6][SAFI_UNICAST]
8996 || p->afc_recv[AFI_IP6][SAFI_UNICAST]
8997 || p->afc_adv[AFI_IP6][SAFI_MULTICAST]
8998 || p->afc_recv[AFI_IP6][SAFI_MULTICAST]
8999#endif /* HAVE_IPV6 */
9000 || p->afc_adv[AFI_IP][SAFI_MPLS_VPN]
9001 || p->afc_recv[AFI_IP][SAFI_MPLS_VPN])
9002 {
9003 vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE);
9004
0b2aa3a0
PJ
9005 /* AS4 */
9006 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)
9007 || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
9008 {
9009 vty_out (vty, " 4 Byte AS:");
9010 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
9011 vty_out (vty, " advertised");
9012 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
9013 vty_out (vty, " %sreceived",
9014 CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : "");
9015 vty_out (vty, "%s", VTY_NEWLINE);
9016 }
a82478b9
DS
9017
9018 /* AddPath */
9019 if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV)
9020 || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV))
9021 {
9022 vty_out (vty, " AddPath:%s", VTY_NEWLINE);
9023
9024 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
9025 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
9026 {
9027
9028 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ||
9029 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
9030 {
9031 vty_out (vty, " %s: TX ", afi_safi_print (afi, safi));
9032
9033 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV))
9034 vty_out (vty, "advertised", afi_safi_print (afi, safi));
9035
9036 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
9037 vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ? " and " : "" );
9038
9039 vty_out (vty, "%s", VTY_NEWLINE);
9040 }
9041
9042 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
9043 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
9044 {
9045 vty_out (vty, " %s: RX ", afi_safi_print (afi, safi));
9046
9047 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV))
9048 vty_out (vty, "advertised", afi_safi_print (afi, safi));
9049
9050 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
9051 vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ? " and " : "" );
9052
9053 vty_out (vty, "%s", VTY_NEWLINE);
9054 }
9055 }
9056 }
9057
718e3744 9058 /* Dynamic */
9059 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
9060 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
9061 {
9062 vty_out (vty, " Dynamic:");
9063 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
9064 vty_out (vty, " advertised");
9065 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
538621f2 9066 vty_out (vty, " %sreceived",
9067 CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : "");
718e3744 9068 vty_out (vty, "%s", VTY_NEWLINE);
9069 }
9070
9071 /* Route Refresh */
9072 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
9073 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
9074 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
9075 {
9076 vty_out (vty, " Route refresh:");
9077 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
9078 vty_out (vty, " advertised");
9079 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
9080 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
538621f2 9081 vty_out (vty, " %sreceived(%s)",
9082 CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "",
9083 (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)
9084 && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ?
9085 "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new");
718e3744 9086
718e3744 9087 vty_out (vty, "%s", VTY_NEWLINE);
9088 }
538621f2 9089
9090 /* Multiprotocol Extensions */
9091 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
9092 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
9093 if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
718e3744 9094 {
538621f2 9095 vty_out (vty, " Address family %s:", afi_safi_print (afi, safi));
9096 if (p->afc_adv[afi][safi])
9097 vty_out (vty, " advertised");
9098 if (p->afc_recv[afi][safi])
9099 vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : "");
9100 vty_out (vty, "%s", VTY_NEWLINE);
9101 }
9102
9103 /* Gracefull Restart */
9104 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
9105 || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
718e3744 9106 {
538621f2 9107 vty_out (vty, " Graceful Restart Capabilty:");
9108 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
718e3744 9109 vty_out (vty, " advertised");
538621f2 9110 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
9111 vty_out (vty, " %sreceived",
9112 CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : "");
718e3744 9113 vty_out (vty, "%s", VTY_NEWLINE);
538621f2 9114
9115 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
718e3744 9116 {
538621f2 9117 int restart_af_count = 0;
9118
9119 vty_out (vty, " Remote Restart timer is %d seconds%s",
93406d87 9120 p->v_gr_restart, VTY_NEWLINE);
9121 vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE);
538621f2 9122
9123 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
9124 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
9125 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
9126 {
93406d87 9127 vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "",
9128 afi_safi_print (afi, safi),
9129 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ?
9130 "preserved" : "not preserved");
538621f2 9131 restart_af_count++;
93406d87 9132 }
538621f2 9133 if (! restart_af_count)
9134 vty_out (vty, "none");
9135 vty_out (vty, "%s", VTY_NEWLINE);
718e3744 9136 }
718e3744 9137 }
718e3744 9138 }
9139 }
9140
93406d87 9141 /* graceful restart information */
9142 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
9143 || p->t_gr_restart
9144 || p->t_gr_stale)
9145 {
9146 int eor_send_af_count = 0;
9147 int eor_receive_af_count = 0;
9148
9149 vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE);
9150 if (p->status == Established)
9151 {
9152 vty_out (vty, " End-of-RIB send: ");
9153 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
9154 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
9155 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND))
9156 {
9157 vty_out (vty, "%s%s", eor_send_af_count ? ", " : "",
9158 afi_safi_print (afi, safi));
9159 eor_send_af_count++;
9160 }
9161 vty_out (vty, "%s", VTY_NEWLINE);
9162
9163 vty_out (vty, " End-of-RIB received: ");
9164 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
9165 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
9166 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED))
9167 {
9168 vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "",
9169 afi_safi_print (afi, safi));
9170 eor_receive_af_count++;
9171 }
9172 vty_out (vty, "%s", VTY_NEWLINE);
9173 }
9174
9175 if (p->t_gr_restart)
0b2aa3a0
PJ
9176 vty_out (vty, " The remaining time of restart timer is %ld%s",
9177 thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE);
9178
93406d87 9179 if (p->t_gr_stale)
0b2aa3a0
PJ
9180 vty_out (vty, " The remaining time of stalepath timer is %ld%s",
9181 thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE);
93406d87 9182 }
9183
718e3744 9184 /* Packet counts. */
93406d87 9185 vty_out (vty, " Message statistics:%s", VTY_NEWLINE);
9186 vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE);
0b2aa3a0 9187 vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE);
93406d87 9188 vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE);
9189 vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE);
9190 vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE);
9191 vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE);
9192 vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE);
9193 vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE);
9194 vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE);
9195 vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out +
9196 p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out,
9197 p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in +
9198 p->dynamic_cap_in, VTY_NEWLINE);
718e3744 9199
9200 /* advertisement-interval */
9201 vty_out (vty, " Minimum time between advertisement runs is %d seconds%s",
9202 p->v_routeadv, VTY_NEWLINE);
9203
9204 /* Update-source. */
9205 if (p->update_if || p->update_source)
9206 {
9207 vty_out (vty, " Update source is ");
9208 if (p->update_if)
9209 vty_out (vty, "%s", p->update_if);
9210 else if (p->update_source)
9211 vty_out (vty, "%s",
9212 sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
9213 vty_out (vty, "%s", VTY_NEWLINE);
9214 }
9215
9216 /* Default weight */
9217 if (CHECK_FLAG (p->config, PEER_CONFIG_WEIGHT))
9218 vty_out (vty, " Default weight %d%s", p->weight,
9219 VTY_NEWLINE);
9220
9221 vty_out (vty, "%s", VTY_NEWLINE);
9222
9223 /* Address Family Information */
538621f2 9224 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
9225 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
9226 if (p->afc[afi][safi])
9227 bgp_show_peer_afi (vty, p, afi, safi);
718e3744 9228
9229 vty_out (vty, " Connections established %d; dropped %d%s",
9230 p->established, p->dropped,
9231 VTY_NEWLINE);
9232
d6661008 9233 if (! p->last_reset)
e0701b79 9234 vty_out (vty, " Last reset never%s", VTY_NEWLINE);
9235 else
d6661008
DS
9236 {
9237 vty_out (vty, " Last reset %s, due to %s%s",
9238 peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN),
9239 peer_down_str[(int) p->last_reset], VTY_NEWLINE);
9240
9241 if (p->last_reset_cause_size)
9242 {
9243 msg = p->last_reset_cause;
9244 vty_out(vty, " Message received that caused BGP to send a NOTIFICATION:%s ", VTY_NEWLINE);
9245 for (i = 1; i <= p->last_reset_cause_size; i++)
9246 {
9247 vty_out(vty, "%02X", *msg++);
9248
9249 if (i != p->last_reset_cause_size)
9250 if (i % 16 == 0)
9251 vty_out(vty, "%s ", VTY_NEWLINE);
9252 else if (i % 4 == 0)
9253 vty_out(vty, " ");
9254 }
9255 vty_out(vty, "%s", VTY_NEWLINE);
9256 }
9257 }
848973c7 9258
718e3744 9259 if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW))
9260 {
9261 vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE);
0a486e5f 9262
9263 if (p->t_pmax_restart)
9264 vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s",
9265 p->host, thread_timer_remain_second (p->t_pmax_restart),
9266 VTY_NEWLINE);
9267 else
9268 vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s",
9269 p->host, VTY_NEWLINE);
718e3744 9270 }
9271
f5a4827d 9272 /* EBGP Multihop and GTSM */
6d85b15b 9273 if (p->sort != BGP_PEER_IBGP)
f5a4827d
SH
9274 {
9275 if (p->gtsm_hops > 0)
9276 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
9277 p->gtsm_hops, VTY_NEWLINE);
9278 else if (p->ttl > 1)
9279 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
9280 p->ttl, VTY_NEWLINE);
9281 }
5d804b43
PM
9282 else
9283 {
9284 if (p->gtsm_hops > 0)
9285 vty_out (vty, " Internal BGP neighbor may be up to %d hops away.%s",
9286 p->gtsm_hops, VTY_NEWLINE);
9287 }
718e3744 9288
9289 /* Local address. */
9290 if (p->su_local)
9291 {
93406d87 9292 vty_out (vty, "Local host: %s, Local port: %d%s",
718e3744 9293 sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN),
9294 ntohs (p->su_local->sin.sin_port),
718e3744 9295 VTY_NEWLINE);
9296 }
9297
9298 /* Remote address. */
9299 if (p->su_remote)
9300 {
9301 vty_out (vty, "Foreign host: %s, Foreign port: %d%s",
9302 sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN),
9303 ntohs (p->su_remote->sin.sin_port),
9304 VTY_NEWLINE);
9305 }
9306
9307 /* Nexthop display. */
9308 if (p->su_local)
9309 {
9310 vty_out (vty, "Nexthop: %s%s",
9311 inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ),
9312 VTY_NEWLINE);
9313#ifdef HAVE_IPV6
9314 vty_out (vty, "Nexthop global: %s%s",
9315 inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ),
9316 VTY_NEWLINE);
9317 vty_out (vty, "Nexthop local: %s%s",
9318 inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ),
9319 VTY_NEWLINE);
9320 vty_out (vty, "BGP connection: %s%s",
9321 p->shared_network ? "shared network" : "non shared network",
9322 VTY_NEWLINE);
9323#endif /* HAVE_IPV6 */
9324 }
9325
9326 /* Timer information. */
9327 if (p->t_start)
9328 vty_out (vty, "Next start timer due in %ld seconds%s",
9329 thread_timer_remain_second (p->t_start), VTY_NEWLINE);
9330 if (p->t_connect)
9331 vty_out (vty, "Next connect timer due in %ld seconds%s",
9332 thread_timer_remain_second (p->t_connect), VTY_NEWLINE);
cb1faec9 9333 if (p->t_routeadv)
3f9c7369 9334 vty_out (vty, "MRAI (interval %u) timer expires in %ld seconds%s",
cb1faec9
DS
9335 p->v_routeadv, thread_timer_remain_second (p->t_routeadv),
9336 VTY_NEWLINE);
9337
9338 vty_out (vty, "Read thread: %s Write thread: %s%s",
718e3744 9339 p->t_read ? "on" : "off",
9340 p->t_write ? "on" : "off",
9341 VTY_NEWLINE);
9342
9343 if (p->notify.code == BGP_NOTIFY_OPEN_ERR
9344 && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL)
9345 bgp_capability_vty_out (vty, p);
9346
9347 vty_out (vty, "%s", VTY_NEWLINE);
9348}
9349
94f2b392 9350static int
718e3744 9351bgp_show_neighbor (struct vty *vty, struct bgp *bgp,
a80beece 9352 enum show_type type, union sockunion *su, const char *conf_if)
718e3744 9353{
1eb8ef25 9354 struct listnode *node, *nnode;
718e3744 9355 struct peer *peer;
9356 int find = 0;
9357
1eb8ef25 9358 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
718e3744 9359 {
1ff9a340
DS
9360 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
9361 continue;
9362
718e3744 9363 switch (type)
9364 {
9365 case show_all:
9366 bgp_show_peer (vty, peer);
9367 break;
9368 case show_peer:
a80beece
DS
9369 if (conf_if)
9370 {
9371 if (peer->conf_if && !strcmp(peer->conf_if, conf_if))
9372 {
9373 find = 1;
9374 bgp_show_peer (vty, peer);
9375 }
9376 }
9377 else
9378 {
9379 if (sockunion_same (&peer->su, su))
9380 {
9381 find = 1;
9382 bgp_show_peer (vty, peer);
9383 }
9384 }
718e3744 9385 break;
9386 }
9387 }
9388
9389 if (type == show_peer && ! find)
9390 vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE);
9391
9392 return CMD_SUCCESS;
9393}
9394
94f2b392 9395static int
fd79ac91 9396bgp_show_neighbor_vty (struct vty *vty, const char *name,
9397 enum show_type type, const char *ip_str)
718e3744 9398{
9399 int ret;
9400 struct bgp *bgp;
9401 union sockunion su;
9402
718e3744 9403 if (name)
9404 {
9405 bgp = bgp_lookup_by_name (name);
718e3744 9406 if (! bgp)
9407 {
9408 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
9409 return CMD_WARNING;
9410 }
718e3744 9411 }
a80beece
DS
9412 else
9413 {
9414 bgp = bgp_get_default ();
9415 }
718e3744 9416
9417 if (bgp)
a80beece
DS
9418 {
9419 if (ip_str)
9420 {
9421 ret = str2sockunion (ip_str, &su);
9422 if (ret < 0)
9423 bgp_show_neighbor (vty, bgp, type, NULL, ip_str);
9424 else
9425 bgp_show_neighbor (vty, bgp, type, &su, NULL);
9426 }
9427 else
9428 {
9429 bgp_show_neighbor (vty, bgp, type, NULL, NULL);
9430 }
9431 }
718e3744 9432
9433 return CMD_SUCCESS;
9434}
9435
9436/* "show ip bgp neighbors" commands. */
9437DEFUN (show_ip_bgp_neighbors,
9438 show_ip_bgp_neighbors_cmd,
9439 "show ip bgp neighbors",
9440 SHOW_STR
9441 IP_STR
9442 BGP_STR
9443 "Detailed information on TCP and BGP neighbor connections\n")
9444{
9445 return bgp_show_neighbor_vty (vty, NULL, show_all, NULL);
9446}
9447
9448ALIAS (show_ip_bgp_neighbors,
9449 show_ip_bgp_ipv4_neighbors_cmd,
9450 "show ip bgp ipv4 (unicast|multicast) neighbors",
9451 SHOW_STR
9452 IP_STR
9453 BGP_STR
9454 "Address family\n"
9455 "Address Family modifier\n"
9456 "Address Family modifier\n"
9457 "Detailed information on TCP and BGP neighbor connections\n")
9458
9459ALIAS (show_ip_bgp_neighbors,
9460 show_ip_bgp_vpnv4_all_neighbors_cmd,
9461 "show ip bgp vpnv4 all neighbors",
9462 SHOW_STR
9463 IP_STR
9464 BGP_STR
9465 "Display VPNv4 NLRI specific information\n"
9466 "Display information about all VPNv4 NLRIs\n"
9467 "Detailed information on TCP and BGP neighbor connections\n")
9468
9469ALIAS (show_ip_bgp_neighbors,
9470 show_ip_bgp_vpnv4_rd_neighbors_cmd,
9471 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors",
9472 SHOW_STR
9473 IP_STR
9474 BGP_STR
9475 "Display VPNv4 NLRI specific information\n"
9476 "Display information for a route distinguisher\n"
9477 "VPN Route Distinguisher\n"
9478 "Detailed information on TCP and BGP neighbor connections\n")
9479
9480ALIAS (show_ip_bgp_neighbors,
9481 show_bgp_neighbors_cmd,
9482 "show bgp neighbors",
9483 SHOW_STR
9484 BGP_STR
9485 "Detailed information on TCP and BGP neighbor connections\n")
9486
9487ALIAS (show_ip_bgp_neighbors,
9488 show_bgp_ipv6_neighbors_cmd,
9489 "show bgp ipv6 neighbors",
9490 SHOW_STR
9491 BGP_STR
9492 "Address family\n"
9493 "Detailed information on TCP and BGP neighbor connections\n")
9494
9495DEFUN (show_ip_bgp_neighbors_peer,
9496 show_ip_bgp_neighbors_peer_cmd,
a80beece 9497 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD)",
718e3744 9498 SHOW_STR
9499 IP_STR
9500 BGP_STR
9501 "Detailed information on TCP and BGP neighbor connections\n"
9502 "Neighbor to display information about\n"
a80beece
DS
9503 "Neighbor to display information about\n"
9504 "Neighbor on bgp configured interface\n")
718e3744 9505{
9506 return bgp_show_neighbor_vty (vty, NULL, show_peer, argv[argc - 1]);
9507}
9508
9509ALIAS (show_ip_bgp_neighbors_peer,
9510 show_ip_bgp_ipv4_neighbors_peer_cmd,
a80beece 9511 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD)",
718e3744 9512 SHOW_STR
9513 IP_STR
9514 BGP_STR
9515 "Address family\n"
9516 "Address Family modifier\n"
9517 "Address Family modifier\n"
9518 "Detailed information on TCP and BGP neighbor connections\n"
9519 "Neighbor to display information about\n"
a80beece
DS
9520 "Neighbor to display information about\n"
9521 "Neighbor on bgp configured interface\n")
718e3744 9522
9523ALIAS (show_ip_bgp_neighbors_peer,
9524 show_ip_bgp_vpnv4_all_neighbors_peer_cmd,
9525 "show ip bgp vpnv4 all neighbors A.B.C.D",
9526 SHOW_STR
9527 IP_STR
9528 BGP_STR
9529 "Display VPNv4 NLRI specific information\n"
9530 "Display information about all VPNv4 NLRIs\n"
9531 "Detailed information on TCP and BGP neighbor connections\n"
9532 "Neighbor to display information about\n")
9533
9534ALIAS (show_ip_bgp_neighbors_peer,
9535 show_ip_bgp_vpnv4_rd_neighbors_peer_cmd,
9536 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D",
9537 SHOW_STR
9538 IP_STR
9539 BGP_STR
9540 "Display VPNv4 NLRI specific information\n"
9541 "Display information about all VPNv4 NLRIs\n"
9542 "Detailed information on TCP and BGP neighbor connections\n"
9543 "Neighbor to display information about\n")
9544
9545ALIAS (show_ip_bgp_neighbors_peer,
9546 show_bgp_neighbors_peer_cmd,
a80beece 9547 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD)",
718e3744 9548 SHOW_STR
9549 BGP_STR
9550 "Detailed information on TCP and BGP neighbor connections\n"
9551 "Neighbor to display information about\n"
a80beece
DS
9552 "Neighbor to display information about\n"
9553 "Neighbor on bgp configured interface\n")
718e3744 9554
9555ALIAS (show_ip_bgp_neighbors_peer,
9556 show_bgp_ipv6_neighbors_peer_cmd,
a80beece 9557 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD)",
718e3744 9558 SHOW_STR
9559 BGP_STR
9560 "Address family\n"
9561 "Detailed information on TCP and BGP neighbor connections\n"
9562 "Neighbor to display information about\n"
a80beece
DS
9563 "Neighbor to display information about\n"
9564 "Neighbor on bgp configured interface\n")
718e3744 9565
9566DEFUN (show_ip_bgp_instance_neighbors,
9567 show_ip_bgp_instance_neighbors_cmd,
9568 "show ip bgp view WORD neighbors",
9569 SHOW_STR
9570 IP_STR
9571 BGP_STR
9572 "BGP view\n"
9573 "View name\n"
9574 "Detailed information on TCP and BGP neighbor connections\n")
9575{
9576 return bgp_show_neighbor_vty (vty, argv[0], show_all, NULL);
9577}
9578
bb46e94f 9579ALIAS (show_ip_bgp_instance_neighbors,
9580 show_bgp_instance_neighbors_cmd,
9581 "show bgp view WORD neighbors",
9582 SHOW_STR
9583 BGP_STR
9584 "BGP view\n"
9585 "View name\n"
9586 "Detailed information on TCP and BGP neighbor connections\n")
9587
9588ALIAS (show_ip_bgp_instance_neighbors,
9589 show_bgp_instance_ipv6_neighbors_cmd,
9590 "show bgp view WORD ipv6 neighbors",
9591 SHOW_STR
9592 BGP_STR
9593 "BGP view\n"
9594 "View name\n"
9595 "Address family\n"
9596 "Detailed information on TCP and BGP neighbor connections\n")
9597
718e3744 9598DEFUN (show_ip_bgp_instance_neighbors_peer,
9599 show_ip_bgp_instance_neighbors_peer_cmd,
a80beece 9600 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X|WORD)",
718e3744 9601 SHOW_STR
9602 IP_STR
9603 BGP_STR
9604 "BGP view\n"
9605 "View name\n"
9606 "Detailed information on TCP and BGP neighbor connections\n"
9607 "Neighbor to display information about\n"
a80beece
DS
9608 "Neighbor to display information about\n"
9609 "Neighbor on bgp configured interface\n")
718e3744 9610{
9611 return bgp_show_neighbor_vty (vty, argv[0], show_peer, argv[1]);
9612}
bb46e94f 9613
9614ALIAS (show_ip_bgp_instance_neighbors_peer,
9615 show_bgp_instance_neighbors_peer_cmd,
a80beece 9616 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X|WORD)",
bb46e94f 9617 SHOW_STR
9618 BGP_STR
9619 "BGP view\n"
9620 "View name\n"
9621 "Detailed information on TCP and BGP neighbor connections\n"
9622 "Neighbor to display information about\n"
a80beece
DS
9623 "Neighbor to display information about\n"
9624 "Neighbor on bgp configured interface\n")
bb46e94f 9625
9626ALIAS (show_ip_bgp_instance_neighbors_peer,
9627 show_bgp_instance_ipv6_neighbors_peer_cmd,
a80beece 9628 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X|WORD)",
bb46e94f 9629 SHOW_STR
9630 BGP_STR
9631 "BGP view\n"
9632 "View name\n"
9633 "Address family\n"
9634 "Detailed information on TCP and BGP neighbor connections\n"
9635 "Neighbor to display information about\n"
a80beece
DS
9636 "Neighbor to display information about\n"
9637 "Neighbor on bgp configured interface\n")
6b0655a2 9638
718e3744 9639/* Show BGP's AS paths internal data. There are both `show ip bgp
9640 paths' and `show ip mbgp paths'. Those functions results are the
9641 same.*/
9642DEFUN (show_ip_bgp_paths,
9643 show_ip_bgp_paths_cmd,
9644 "show ip bgp paths",
9645 SHOW_STR
9646 IP_STR
9647 BGP_STR
9648 "Path information\n")
9649{
9650 vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE);
9651 aspath_print_all_vty (vty);
9652 return CMD_SUCCESS;
9653}
9654
9655DEFUN (show_ip_bgp_ipv4_paths,
9656 show_ip_bgp_ipv4_paths_cmd,
9657 "show ip bgp ipv4 (unicast|multicast) paths",
9658 SHOW_STR
9659 IP_STR
9660 BGP_STR
9661 "Address family\n"
9662 "Address Family modifier\n"
9663 "Address Family modifier\n"
9664 "Path information\n")
9665{
9666 vty_out (vty, "Address Refcnt Path\r\n");
9667 aspath_print_all_vty (vty);
9668
9669 return CMD_SUCCESS;
9670}
6b0655a2 9671
718e3744 9672#include "hash.h"
9673
94f2b392 9674static void
718e3744 9675community_show_all_iterator (struct hash_backet *backet, struct vty *vty)
9676{
9677 struct community *com;
9678
9679 com = (struct community *) backet->data;
9680 vty_out (vty, "[%p] (%ld) %s%s", backet, com->refcnt,
9681 community_str (com), VTY_NEWLINE);
9682}
9683
9684/* Show BGP's community internal data. */
9685DEFUN (show_ip_bgp_community_info,
9686 show_ip_bgp_community_info_cmd,
9687 "show ip bgp community-info",
9688 SHOW_STR
9689 IP_STR
9690 BGP_STR
9691 "List all bgp community information\n")
9692{
9693 vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE);
9694
9695 hash_iterate (community_hash (),
9696 (void (*) (struct hash_backet *, void *))
9697 community_show_all_iterator,
9698 vty);
9699
9700 return CMD_SUCCESS;
9701}
9702
9703DEFUN (show_ip_bgp_attr_info,
9704 show_ip_bgp_attr_info_cmd,
9705 "show ip bgp attribute-info",
9706 SHOW_STR
9707 IP_STR
9708 BGP_STR
9709 "List all bgp attribute information\n")
9710{
9711 attr_show_all (vty);
9712 return CMD_SUCCESS;
9713}
6b0655a2 9714
94f2b392 9715static int
fee0f4c6 9716bgp_write_rsclient_summary (struct vty *vty, struct peer *rsclient,
9717 afi_t afi, safi_t safi)
9718{
9719 char timebuf[BGP_UPTIME_LEN];
9720 char rmbuf[14];
fd79ac91 9721 const char *rmname;
fee0f4c6 9722 struct peer *peer;
1eb8ef25 9723 struct listnode *node, *nnode;
fee0f4c6 9724 int len;
9725 int count = 0;
9726
9727 if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP))
9728 {
1eb8ef25 9729 for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, peer))
fee0f4c6 9730 {
9731 count++;
9732 bgp_write_rsclient_summary (vty, peer, afi, safi);
9733 }
9734 return count;
9735 }
9736
9737 len = vty_out (vty, "%s", rsclient->host);
9738 len = 16 - len;
9739
9740 if (len < 1)
9741 vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
9742 else
9743 vty_out (vty, "%*s", len, " ");
9744
3d515fd9 9745 vty_out (vty, "4 ");
fee0f4c6 9746
0b2aa3a0 9747 vty_out (vty, "%11d ", rsclient->as);
fee0f4c6 9748
9749 rmname = ROUTE_MAP_EXPORT_NAME(&rsclient->filter[afi][safi]);
9750 if ( rmname && strlen (rmname) > 13 )
9751 {
9752 sprintf (rmbuf, "%13s", "...");
9753 rmname = strncpy (rmbuf, rmname, 10);
9754 }
9755 else if (! rmname)
9756 rmname = "<none>";
9757 vty_out (vty, " %13s ", rmname);
9758
9759 rmname = ROUTE_MAP_IMPORT_NAME(&rsclient->filter[afi][safi]);
9760 if ( rmname && strlen (rmname) > 13 )
9761 {
9762 sprintf (rmbuf, "%13s", "...");
9763 rmname = strncpy (rmbuf, rmname, 10);
9764 }
9765 else if (! rmname)
9766 rmname = "<none>";
9767 vty_out (vty, " %13s ", rmname);
9768
9769 vty_out (vty, "%8s", peer_uptime (rsclient->uptime, timebuf, BGP_UPTIME_LEN));
9770
9771 if (CHECK_FLAG (rsclient->flags, PEER_FLAG_SHUTDOWN))
9772 vty_out (vty, " Idle (Admin)");
9773 else if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_PREFIX_OVERFLOW))
9774 vty_out (vty, " Idle (PfxCt)");
9775 else
9776 vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, rsclient->status));
9777
9778 vty_out (vty, "%s", VTY_NEWLINE);
9779
9780 return 1;
9781}
9782
94f2b392 9783static int
fd79ac91 9784bgp_show_rsclient_summary (struct vty *vty, struct bgp *bgp,
9785 afi_t afi, safi_t safi)
fee0f4c6 9786{
9787 struct peer *peer;
1eb8ef25 9788 struct listnode *node, *nnode;
fee0f4c6 9789 int count = 0;
9790
9791 /* Header string for each address family. */
9792 static char header[] = "Neighbor V AS Export-Policy Import-Policy Up/Down State";
9793
1eb8ef25 9794 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, peer))
fee0f4c6 9795 {
9796 if (peer->afc[afi][safi] &&
9797 CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
9798 {
9799 if (! count)
9800 {
9801 vty_out (vty,
9802 "Route Server's BGP router identifier %s%s",
9803 inet_ntoa (bgp->router_id), VTY_NEWLINE);
9804 vty_out (vty,
aea339f7 9805 "Route Server's local AS number %u%s", bgp->as,
fee0f4c6 9806 VTY_NEWLINE);
9807
9808 vty_out (vty, "%s", VTY_NEWLINE);
9809 vty_out (vty, "%s%s", header, VTY_NEWLINE);
9810 }
9811
9812 count += bgp_write_rsclient_summary (vty, peer, afi, safi);
9813 }
9814 }
9815
9816 if (count)
9817 vty_out (vty, "%sTotal number of Route Server Clients %d%s", VTY_NEWLINE,
9818 count, VTY_NEWLINE);
9819 else
9820 vty_out (vty, "No %s Route Server Client is configured%s",
9821 afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
9822
9823 return CMD_SUCCESS;
9824}
9825
94f2b392 9826static int
fd79ac91 9827bgp_show_rsclient_summary_vty (struct vty *vty, const char *name,
9828 afi_t afi, safi_t safi)
fee0f4c6 9829{
9830 struct bgp *bgp;
9831
9832 if (name)
9833 {
9834 bgp = bgp_lookup_by_name (name);
9835
9836 if (! bgp)
9837 {
9838 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
9839 return CMD_WARNING;
9840 }
9841
9842 bgp_show_rsclient_summary (vty, bgp, afi, safi);
9843 return CMD_SUCCESS;
9844 }
9845
9846 bgp = bgp_get_default ();
9847
9848 if (bgp)
9849 bgp_show_rsclient_summary (vty, bgp, afi, safi);
9850
9851 return CMD_SUCCESS;
9852}
9853
9854/* 'show bgp rsclient' commands. */
9855DEFUN (show_ip_bgp_rsclient_summary,
9856 show_ip_bgp_rsclient_summary_cmd,
9857 "show ip bgp rsclient summary",
9858 SHOW_STR
9859 IP_STR
9860 BGP_STR
9861 "Information about Route Server Clients\n"
9862 "Summary of all Route Server Clients\n")
9863{
9864 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
9865}
9866
9867DEFUN (show_ip_bgp_instance_rsclient_summary,
9868 show_ip_bgp_instance_rsclient_summary_cmd,
9869 "show ip bgp view WORD rsclient summary",
9870 SHOW_STR
9871 IP_STR
9872 BGP_STR
9873 "BGP view\n"
9874 "View name\n"
9875 "Information about Route Server Clients\n"
9876 "Summary of all Route Server Clients\n")
9877{
9878 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
9879}
9880
9881DEFUN (show_ip_bgp_ipv4_rsclient_summary,
9882 show_ip_bgp_ipv4_rsclient_summary_cmd,
9883 "show ip bgp ipv4 (unicast|multicast) rsclient summary",
9884 SHOW_STR
9885 IP_STR
9886 BGP_STR
9887 "Address family\n"
9888 "Address Family modifier\n"
9889 "Address Family modifier\n"
9890 "Information about Route Server Clients\n"
9891 "Summary of all Route Server Clients\n")
9892{
9893 if (strncmp (argv[0], "m", 1) == 0)
9894 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST);
9895
9896 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
9897}
9898
9899DEFUN (show_ip_bgp_instance_ipv4_rsclient_summary,
9900 show_ip_bgp_instance_ipv4_rsclient_summary_cmd,
9901 "show ip bgp view WORD ipv4 (unicast|multicast) rsclient summary",
9902 SHOW_STR
9903 IP_STR
9904 BGP_STR
9905 "BGP view\n"
9906 "View name\n"
9907 "Address family\n"
9908 "Address Family modifier\n"
9909 "Address Family modifier\n"
9910 "Information about Route Server Clients\n"
9911 "Summary of all Route Server Clients\n")
9912{
9913 if (strncmp (argv[1], "m", 1) == 0)
9914 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST);
9915
9916 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
9917}
9918
95cbbd2a
ML
9919DEFUN (show_bgp_instance_ipv4_safi_rsclient_summary,
9920 show_bgp_instance_ipv4_safi_rsclient_summary_cmd,
9921 "show bgp view WORD ipv4 (unicast|multicast) rsclient summary",
9922 SHOW_STR
9923 BGP_STR
9924 "BGP view\n"
9925 "View name\n"
9926 "Address family\n"
9927 "Address Family modifier\n"
9928 "Address Family modifier\n"
9929 "Information about Route Server Clients\n"
9930 "Summary of all Route Server Clients\n")
9931{
9932 safi_t safi;
9933
9934 if (argc == 2) {
9935 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
9936 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, safi);
9937 } else {
9938 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
9939 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, safi);
9940 }
9941}
9942
9943ALIAS (show_bgp_instance_ipv4_safi_rsclient_summary,
9944 show_bgp_ipv4_safi_rsclient_summary_cmd,
9945 "show bgp ipv4 (unicast|multicast) rsclient summary",
9946 SHOW_STR
9947 BGP_STR
9948 "Address family\n"
9949 "Address Family modifier\n"
9950 "Address Family modifier\n"
9951 "Information about Route Server Clients\n"
9952 "Summary of all Route Server Clients\n")
9953
fee0f4c6 9954#ifdef HAVE_IPV6
9955DEFUN (show_bgp_rsclient_summary,
9956 show_bgp_rsclient_summary_cmd,
9957 "show bgp rsclient summary",
9958 SHOW_STR
9959 BGP_STR
9960 "Information about Route Server Clients\n"
9961 "Summary of all Route Server Clients\n")
9962{
9963 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
9964}
9965
9966DEFUN (show_bgp_instance_rsclient_summary,
9967 show_bgp_instance_rsclient_summary_cmd,
9968 "show bgp view WORD rsclient summary",
9969 SHOW_STR
9970 BGP_STR
9971 "BGP view\n"
9972 "View name\n"
9973 "Information about Route Server Clients\n"
9974 "Summary of all Route Server Clients\n")
9975{
9976 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
9977}
9978
9979ALIAS (show_bgp_rsclient_summary,
9980 show_bgp_ipv6_rsclient_summary_cmd,
9981 "show bgp ipv6 rsclient summary",
9982 SHOW_STR
9983 BGP_STR
9984 "Address family\n"
9985 "Information about Route Server Clients\n"
9986 "Summary of all Route Server Clients\n")
9987
9988ALIAS (show_bgp_instance_rsclient_summary,
9989 show_bgp_instance_ipv6_rsclient_summary_cmd,
9990 "show bgp view WORD ipv6 rsclient summary",
9991 SHOW_STR
9992 BGP_STR
9993 "BGP view\n"
9994 "View name\n"
9995 "Address family\n"
9996 "Information about Route Server Clients\n"
9997 "Summary of all Route Server Clients\n")
95cbbd2a
ML
9998
9999DEFUN (show_bgp_instance_ipv6_safi_rsclient_summary,
10000 show_bgp_instance_ipv6_safi_rsclient_summary_cmd,
10001 "show bgp view WORD ipv6 (unicast|multicast) rsclient summary",
10002 SHOW_STR
10003 BGP_STR
10004 "BGP view\n"
10005 "View name\n"
10006 "Address family\n"
10007 "Address Family modifier\n"
10008 "Address Family modifier\n"
10009 "Information about Route Server Clients\n"
10010 "Summary of all Route Server Clients\n")
10011{
10012 safi_t safi;
10013
10014 if (argc == 2) {
10015 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
10016 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP6, safi);
10017 } else {
10018 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
10019 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP6, safi);
10020 }
10021}
10022
10023ALIAS (show_bgp_instance_ipv6_safi_rsclient_summary,
10024 show_bgp_ipv6_safi_rsclient_summary_cmd,
10025 "show bgp ipv6 (unicast|multicast) rsclient summary",
10026 SHOW_STR
10027 BGP_STR
10028 "Address family\n"
10029 "Address Family modifier\n"
10030 "Address Family modifier\n"
10031 "Information about Route Server Clients\n"
10032 "Summary of all Route Server Clients\n")
10033
fee0f4c6 10034#endif /* HAVE IPV6 */
6b0655a2 10035
3f9c7369
DS
10036DEFUN (show_ip_bgp_updgrps,
10037 show_ip_bgp_updgrps_cmd,
10038 "show ip bgp update-groups summary",
10039 SHOW_STR
10040 IP_STR
10041 BGP_STR
10042 "BGP update groups\n"
10043 "Summary information\n")
10044{
10045 struct bgp *bgp;
10046
10047 bgp = bgp_get_default();
10048 if (bgp)
10049 update_group_show(bgp, AFI_IP, SAFI_UNICAST, vty);
10050 return CMD_SUCCESS;
10051}
10052
10053DEFUN (show_bgp_ipv6_updgrps,
10054 show_bgp_ipv6_updgrps_cmd,
10055 "show bgp update-groups summary",
10056 SHOW_STR
10057 BGP_STR
10058 "BGP update groups\n"
10059 "Summary information\n")
10060{
10061 struct bgp *bgp;
10062
10063 bgp = bgp_get_default();
10064 if (bgp)
10065 update_group_show(bgp, AFI_IP6, SAFI_UNICAST, vty);
10066 return CMD_SUCCESS;
10067}
10068
10069DEFUN (show_bgp_updgrps,
10070 show_bgp_updgrps_cmd,
10071 "show bgp (ipv4|ipv6) (unicast|multicast) update-groups summary",
10072 SHOW_STR
10073 BGP_STR
10074 "Address family\n"
10075 "Address family\n"
10076 "Address Family modifier\n"
10077 "Address Family modifier\n"
10078 "BGP update groups\n"
10079 "Summary information\n")
10080{
10081 struct bgp *bgp;
10082 afi_t afi;
10083 safi_t safi;
10084
10085 afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6;
10086 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
10087 bgp = bgp_get_default();
10088 if (bgp)
10089 update_group_show(bgp, afi, safi, vty);
10090 return CMD_SUCCESS;
10091}
10092
10093DEFUN (show_bgp_updgrps_stats,
10094 show_bgp_updgrps_stats_cmd,
10095 "show bgp update-groups statistics",
10096 SHOW_STR
10097 BGP_STR
10098 "BGP update groups\n"
10099 "Statistics\n")
10100{
10101 struct bgp *bgp;
10102
10103 bgp = bgp_get_default();
10104 if (bgp)
10105 update_group_show_stats(bgp, vty);
10106
10107 return CMD_SUCCESS;
10108}
10109
10110static void
10111show_bgp_updgrps_adj_info_aux (struct vty *vty, afi_t afi, safi_t safi,
10112 const char *what, u_int64_t subgrp_id)
10113{
10114 struct bgp *bgp;
10115 bgp = bgp_get_default();
10116 if (bgp)
10117 {
10118 if (!strcmp(what, "advertise-queue"))
10119 update_group_show_adj_queue(bgp, afi, safi, vty, subgrp_id);
10120 else if (!strcmp(what, "advertised-routes"))
10121 update_group_show_advertised(bgp, afi, safi, vty, subgrp_id);
10122 else if (!strcmp(what, "packet-queue"))
10123 update_group_show_packet_queue(bgp, afi, safi, vty, subgrp_id);
10124 }
10125}
10126
10127DEFUN (show_ip_bgp_updgrps_adj,
10128 show_ip_bgp_updgrps_adj_cmd,
10129 "show ip bgp update-groups (advertise-queue|advertised-routes|packet-queue)",
10130 SHOW_STR
10131 IP_STR
10132 BGP_STR
10133 "BGP update groups\n"
10134 "Advertisement queue\n"
10135 "Announced routes\n"
10136 "Packet queue\n")
10137{
10138 show_bgp_updgrps_adj_info_aux(vty, AFI_IP, SAFI_UNICAST, argv[0], 0);
10139 return CMD_SUCCESS;
10140}
10141
10142DEFUN (show_bgp_updgrps_afi_adj,
10143 show_bgp_updgrps_afi_adj_cmd,
10144 "show bgp (ipv4|ipv6) (unicast|multicast) update-groups (advertise-queue|advertised-routes|packet-queue)",
10145 SHOW_STR
10146 BGP_STR
10147 "Address family\n"
10148 "Address family\n"
10149 "Address Family modifier\n"
10150 "Address Family modifier\n"
10151 "BGP update groups\n"
10152 "Advertisement queue\n"
10153 "Announced routes\n"
10154 "Packet queue\n")
10155{
10156 afi_t afi;
10157 safi_t safi;
10158
10159 afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6;
10160 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
10161 show_bgp_updgrps_adj_info_aux(vty, afi, safi, argv[2], 0);
10162}
10163
10164DEFUN (show_bgp_updgrps_adj,
10165 show_bgp_updgrps_adj_cmd,
10166 "show bgp update-groups (advertise-queue|advertised-routes|packet-queue)",
10167 SHOW_STR
10168 BGP_STR
10169 "BGP update groups\n"
10170 "Advertisement queue\n"
10171 "Announced routes\n"
10172 "Packet queue\n")
10173{
10174 show_bgp_updgrps_adj_info_aux(vty, AFI_IP6, SAFI_UNICAST, argv[0], 0);
10175 return CMD_SUCCESS;
10176}
10177
10178DEFUN (show_ip_bgp_updgrps_adj_s,
10179 show_ip_bgp_updgrps_adj_subgroup_cmd,
10180 "show ip bgp update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
10181 SHOW_STR
10182 IP_STR
10183 BGP_STR
10184 "BGP update groups\n"
10185 "64-bit subgroup id\n"
10186 "Advertisement queue\n"
10187 "Announced routes\n"
10188 "Packet queue\n")
10189{
10190 show_bgp_updgrps_adj_info_aux(vty, AFI_IP, SAFI_UNICAST, argv[1],
10191 atoll(argv[0]));
10192 return CMD_SUCCESS;
10193}
10194
10195DEFUN (show_bgp_updgrps_adj_s,
10196 show_bgp_updgrps_adj_subgroup_cmd,
10197 "show bgp update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
10198 SHOW_STR
10199 BGP_STR
10200 "BGP update groups\n"
10201 "64-bit subgroup id\n"
10202 "Advertisement queue\n"
10203 "Announced routes\n"
10204 "Packet queue\n")
10205{
10206 show_bgp_updgrps_adj_info_aux(vty, AFI_IP6, SAFI_UNICAST, argv[1],
10207 atoll(argv[0]));
10208 return CMD_SUCCESS;
10209}
10210
10211DEFUN (show_bgp_updgrps_afi_adj_subgroup,
10212 show_bgp_updgrps_afi_adj_subgroup_cmd,
10213 "show bgp (ipv4|ipv6) (unicast|multicast) update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
10214 SHOW_STR
10215 BGP_STR
10216 "Address family\n"
10217 "Address family\n"
10218 "Address Family modifier\n"
10219 "Address Family modifier\n"
10220 "BGP update groups\n"
10221 "64-bit subgroup id\n"
10222 "Advertisement queue\n"
10223 "Announced routes\n"
10224 "Packet queue\n")
10225{
10226 afi_t afi;
10227 safi_t safi;
10228
10229 afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6;
10230 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
10231 show_bgp_updgrps_adj_info_aux(vty, afi, safi, argv[3], atoll(argv[2]));
10232}
10233
f14e6fdb
DS
10234static int
10235bgp_show_one_peer_group (struct vty *vty, struct peer_group *group)
10236{
10237 struct listnode *node, *nnode;
10238 struct prefix *range;
10239 struct peer *conf;
10240 struct peer *peer;
10241 char buf[128];
10242 afi_t afi;
10243 safi_t safi;
10244 char *peer_status, *af_str;
10245 int lr_count;
10246 int dynamic;
10247 int af_cfgd;
10248
10249 conf = group->conf;
10250
10251 vty_out (vty, "%sBGP peer-group %s, remote AS %d%s",
10252 VTY_NEWLINE, group->name, conf->as, VTY_NEWLINE);
10253
10254 if (group->bgp->as == conf->as)
10255 vty_out (vty, " Peer-group type is internal%s", VTY_NEWLINE);
10256 else
10257 vty_out (vty, " Peer-group type is external%s", VTY_NEWLINE);
10258
10259 /* Display AFs configured. */
10260 vty_out (vty, " Configured address-families:");
10261 for (afi = AFI_IP; afi < AFI_MAX; afi++)
10262 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
10263 {
10264 if (conf->afc[afi][safi])
10265 {
10266 af_cfgd = 1;
10267 vty_out (vty, " %s;", afi_safi_print(afi, safi));
10268 }
10269 }
10270 if (!af_cfgd)
10271 vty_out (vty, " none%s", VTY_NEWLINE);
10272 else
10273 vty_out (vty, "%s", VTY_NEWLINE);
10274
10275 /* Display listen ranges (for dynamic neighbors), if any */
10276 for (afi = AFI_IP; afi < AFI_MAX; afi++)
10277 {
10278 if (afi == AFI_IP)
10279 af_str = "IPv4";
10280 else if (afi == AFI_IP6)
10281 af_str = "IPv6";
10282 lr_count = listcount(group->listen_range[afi]);
10283 if (lr_count)
10284 {
10285 vty_out(vty,
10286 " %d %s listen range(s)%s",
10287 lr_count, af_str, VTY_NEWLINE);
10288
10289
10290 for (ALL_LIST_ELEMENTS (group->listen_range[afi], node,
10291 nnode, range))
10292 {
10293 prefix2str(range, buf, sizeof(buf));
10294 vty_out(vty, " %s%s", buf, VTY_NEWLINE);
10295 }
10296 }
10297 }
10298
10299 /* Display group members and their status */
10300 if (listcount(group->peer))
10301 {
10302 vty_out (vty, " Peer-group members:%s", VTY_NEWLINE);
10303 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
10304 {
10305 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
10306 peer_status = "Idle (Admin)";
10307 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
10308 peer_status = "Idle (PfxCt)";
10309 else
10310 peer_status = LOOKUP(bgp_status_msg, peer->status);
10311
10312 dynamic = peer_dynamic_neighbor(peer);
10313 vty_out (vty, " %s %s %s %s",
10314 peer->host, dynamic ? "(dynamic)" : "",
10315 peer_status, VTY_NEWLINE);
10316 }
10317 }
10318
10319 return CMD_SUCCESS;
10320}
10321
10322/* Show BGP peer group's information. */
10323enum show_group_type
10324{
10325 show_all_groups,
10326 show_peer_group
10327};
10328
10329static int
10330bgp_show_peer_group (struct vty *vty, struct bgp *bgp,
10331 enum show_group_type type, const char *group_name)
10332{
10333 struct listnode *node, *nnode;
10334 struct peer_group *group;
10335 int find = 0;
10336
10337 for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
10338 {
10339 switch (type)
10340 {
10341 case show_all_groups:
10342 bgp_show_one_peer_group (vty, group);
10343 break;
10344 case show_peer_group:
10345 if (group_name && (strcmp(group->name, group_name) == 0))
10346 {
10347 find = 1;
10348 bgp_show_one_peer_group (vty, group);
10349 }
10350 break;
10351 }
10352 }
10353
10354 if (type == show_peer_group && ! find)
10355 vty_out (vty, "%% No such peer-groupr%s", VTY_NEWLINE);
10356
10357 return CMD_SUCCESS;
10358}
10359
10360static int
10361bgp_show_peer_group_vty (struct vty *vty, const char *name,
10362 enum show_group_type type, const char *group_name)
10363{
10364 struct bgp *bgp;
10365 int ret = CMD_SUCCESS;
10366
10367 if (name)
10368 {
10369 bgp = bgp_lookup_by_name (name);
10370
10371 if (! bgp)
10372 {
10373 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
10374 return CMD_WARNING;
10375 }
10376 }
10377
10378 bgp = bgp_get_default ();
10379
10380 if (bgp)
10381 ret = bgp_show_peer_group (vty, bgp, type, group_name);
10382
10383 return ret;
10384}
10385
10386DEFUN (show_ip_bgp_peer_groups,
10387 show_ip_bgp_peer_groups_cmd,
10388 "show ip bgp peer-group",
10389 SHOW_STR
10390 IP_STR
10391 BGP_STR
10392 "Detailed information on all BGP peer groups\n")
10393{
10394 return bgp_show_peer_group_vty (vty, NULL, show_all_groups, NULL);
10395}
10396
10397DEFUN (show_ip_bgp_instance_peer_groups,
10398 show_ip_bgp_instance_peer_groups_cmd,
10399 "show ip bgp view WORD peer-group",
10400 SHOW_STR
10401 IP_STR
10402 BGP_STR
10403 "BGP View\n"
10404 "Detailed information on all BGP peer groups\n")
10405{
10406 return bgp_show_peer_group_vty (vty, argv[0], show_all_groups, NULL);
10407}
10408
10409DEFUN (show_ip_bgp_peer_group,
10410 show_ip_bgp_peer_group_cmd,
10411 "show ip bgp peer-group WORD",
10412 SHOW_STR
10413 IP_STR
10414 BGP_STR
10415 "BGP peer-group name\n"
10416 "Detailed information on a BGP peer group\n")
10417{
10418 return bgp_show_peer_group_vty (vty, NULL, show_peer_group, argv[0]);
10419}
10420
10421DEFUN (show_ip_bgp_instance_peer_group,
10422 show_ip_bgp_instance_peer_group_cmd,
10423 "show ip bgp view WORD peer-group WORD",
10424 SHOW_STR
10425 IP_STR
10426 BGP_STR
10427 "BGP View\n"
10428 "BGP peer-group name\n"
10429 "Detailed information on a BGP peer group\n")
10430{
10431 return bgp_show_peer_group_vty (vty, argv[0], show_peer_group, argv[1]);
10432}
3f9c7369 10433
718e3744 10434/* Redistribute VTY commands. */
10435
718e3744 10436DEFUN (bgp_redistribute_ipv4,
10437 bgp_redistribute_ipv4_cmd,
e0ca5fde 10438 "redistribute " QUAGGA_IP_REDIST_STR_BGPD,
718e3744 10439 "Redistribute information from another routing protocol\n"
e0ca5fde 10440 QUAGGA_IP_REDIST_HELP_STR_BGPD)
718e3744 10441{
10442 int type;
10443
e0ca5fde
DL
10444 type = proto_redistnum (AFI_IP, argv[0]);
10445 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 10446 {
10447 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10448 return CMD_WARNING;
10449 }
7c8ff89e 10450 bgp_redist_add(vty->index, AFI_IP, type, 0);
8bb0831e 10451 return bgp_redistribute_set (AFI_IP, type, 0);
718e3744 10452}
10453
10454DEFUN (bgp_redistribute_ipv4_rmap,
10455 bgp_redistribute_ipv4_rmap_cmd,
e0ca5fde 10456 "redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD",
718e3744 10457 "Redistribute information from another routing protocol\n"
e0ca5fde 10458 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 10459 "Route map reference\n"
10460 "Pointer to route-map entries\n")
10461{
10462 int type;
7c8ff89e 10463 struct bgp_redist *red;
718e3744 10464
e0ca5fde
DL
10465 type = proto_redistnum (AFI_IP, argv[0]);
10466 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 10467 {
10468 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10469 return CMD_WARNING;
10470 }
10471
7c8ff89e
DS
10472 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
10473 bgp_redistribute_rmap_set (red, argv[1]);
8bb0831e 10474 return bgp_redistribute_set (AFI_IP, type, 0);
718e3744 10475}
10476
10477DEFUN (bgp_redistribute_ipv4_metric,
10478 bgp_redistribute_ipv4_metric_cmd,
e0ca5fde 10479 "redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295>",
718e3744 10480 "Redistribute information from another routing protocol\n"
e0ca5fde 10481 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 10482 "Metric for redistributed routes\n"
10483 "Default metric\n")
10484{
10485 int type;
10486 u_int32_t metric;
7c8ff89e 10487 struct bgp_redist *red;
718e3744 10488
e0ca5fde
DL
10489 type = proto_redistnum (AFI_IP, argv[0]);
10490 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 10491 {
10492 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10493 return CMD_WARNING;
10494 }
10495 VTY_GET_INTEGER ("metric", metric, argv[1]);
10496
7c8ff89e
DS
10497 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
10498 bgp_redistribute_metric_set (red, metric);
8bb0831e 10499 return bgp_redistribute_set (AFI_IP, type, 0);
718e3744 10500}
10501
10502DEFUN (bgp_redistribute_ipv4_rmap_metric,
10503 bgp_redistribute_ipv4_rmap_metric_cmd,
e0ca5fde 10504 "redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
718e3744 10505 "Redistribute information from another routing protocol\n"
e0ca5fde 10506 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 10507 "Route map reference\n"
10508 "Pointer to route-map entries\n"
10509 "Metric for redistributed routes\n"
10510 "Default metric\n")
10511{
10512 int type;
10513 u_int32_t metric;
7c8ff89e 10514 struct bgp_redist *red;
718e3744 10515
e0ca5fde
DL
10516 type = proto_redistnum (AFI_IP, argv[0]);
10517 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 10518 {
10519 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10520 return CMD_WARNING;
10521 }
10522 VTY_GET_INTEGER ("metric", metric, argv[2]);
10523
7c8ff89e
DS
10524 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
10525 bgp_redistribute_rmap_set (red, argv[1]);
10526 bgp_redistribute_metric_set (red, metric);
8bb0831e 10527 return bgp_redistribute_set (AFI_IP, type, 0);
718e3744 10528}
10529
10530DEFUN (bgp_redistribute_ipv4_metric_rmap,
10531 bgp_redistribute_ipv4_metric_rmap_cmd,
e0ca5fde 10532 "redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
718e3744 10533 "Redistribute information from another routing protocol\n"
e0ca5fde 10534 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 10535 "Metric for redistributed routes\n"
10536 "Default metric\n"
10537 "Route map reference\n"
10538 "Pointer to route-map entries\n")
10539{
10540 int type;
10541 u_int32_t metric;
7c8ff89e 10542 struct bgp_redist *red;
718e3744 10543
e0ca5fde
DL
10544 type = proto_redistnum (AFI_IP, argv[0]);
10545 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 10546 {
10547 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10548 return CMD_WARNING;
10549 }
10550 VTY_GET_INTEGER ("metric", metric, argv[1]);
10551
7c8ff89e
DS
10552 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
10553 bgp_redistribute_metric_set (red, metric);
10554 bgp_redistribute_rmap_set (red, argv[2]);
8bb0831e 10555 return bgp_redistribute_set (AFI_IP, type, 0);
718e3744 10556}
10557
7c8ff89e
DS
10558DEFUN (bgp_redistribute_ipv4_ospf,
10559 bgp_redistribute_ipv4_ospf_cmd,
7a4bb9c5 10560 "redistribute (ospf|table) <1-65535>",
7c8ff89e
DS
10561 "Redistribute information from another routing protocol\n"
10562 "Open Shortest Path First (OSPFv2)\n"
10563 "Instance ID\n")
10564{
10565 u_short instance;
7a4bb9c5 10566 u_short protocol;
7c8ff89e 10567
7a4bb9c5
DS
10568 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
10569
10570 if (strncmp(argv[0], "o", 1) == 0)
10571 protocol = ZEBRA_ROUTE_OSPF;
10572 else
10573 protocol = ZEBRA_ROUTE_TABLE;
10574
10575 bgp_redist_add(vty->index, AFI_IP, protocol, instance);
8bb0831e 10576 return bgp_redistribute_set (AFI_IP, protocol, instance);
7c8ff89e
DS
10577}
10578
10579DEFUN (bgp_redistribute_ipv4_ospf_rmap,
10580 bgp_redistribute_ipv4_ospf_rmap_cmd,
7a4bb9c5 10581 "redistribute (ospf|table) <1-65535> route-map WORD",
7c8ff89e
DS
10582 "Redistribute information from another routing protocol\n"
10583 "Open Shortest Path First (OSPFv2)\n"
10584 "Instance ID\n"
10585 "Route map reference\n"
10586 "Pointer to route-map entries\n")
10587{
10588 struct bgp_redist *red;
10589 u_short instance;
7a4bb9c5 10590 int protocol;
7c8ff89e 10591
7a4bb9c5
DS
10592 if (strncmp(argv[0], "o", 1) == 0)
10593 protocol = ZEBRA_ROUTE_OSPF;
10594 else
10595 protocol = ZEBRA_ROUTE_TABLE;
10596
10597 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
10598 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
10599 bgp_redistribute_rmap_set (red, argv[2]);
8bb0831e 10600 return bgp_redistribute_set (AFI_IP, protocol, instance);
7c8ff89e
DS
10601}
10602
10603DEFUN (bgp_redistribute_ipv4_ospf_metric,
10604 bgp_redistribute_ipv4_ospf_metric_cmd,
7a4bb9c5 10605 "redistribute (ospf|table) <1-65535> metric <0-4294967295>",
7c8ff89e
DS
10606 "Redistribute information from another routing protocol\n"
10607 "Open Shortest Path First (OSPFv2)\n"
10608 "Instance ID\n"
10609 "Metric for redistributed routes\n"
10610 "Default metric\n")
10611{
10612 u_int32_t metric;
10613 struct bgp_redist *red;
10614 u_short instance;
7a4bb9c5 10615 int protocol;
7c8ff89e 10616
7a4bb9c5
DS
10617 if (strncmp(argv[0], "o", 1) == 0)
10618 protocol = ZEBRA_ROUTE_OSPF;
10619 else
10620 protocol = ZEBRA_ROUTE_TABLE;
7c8ff89e 10621
7a4bb9c5
DS
10622 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
10623 VTY_GET_INTEGER ("metric", metric, argv[2]);
10624
10625 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
7c8ff89e 10626 bgp_redistribute_metric_set (red, metric);
8bb0831e 10627 return bgp_redistribute_set (AFI_IP, protocol, instance);
7c8ff89e
DS
10628}
10629
10630DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric,
10631 bgp_redistribute_ipv4_ospf_rmap_metric_cmd,
7a4bb9c5 10632 "redistribute (ospf|table) <1-65535> route-map WORD metric <0-4294967295>",
7c8ff89e
DS
10633 "Redistribute information from another routing protocol\n"
10634 "Open Shortest Path First (OSPFv2)\n"
10635 "Instance ID\n"
10636 "Route map reference\n"
10637 "Pointer to route-map entries\n"
10638 "Metric for redistributed routes\n"
10639 "Default metric\n")
10640{
10641 u_int32_t metric;
10642 struct bgp_redist *red;
10643 u_short instance;
7a4bb9c5 10644 int protocol;
7c8ff89e 10645
7a4bb9c5
DS
10646 if (strncmp(argv[0], "o", 1) == 0)
10647 protocol = ZEBRA_ROUTE_OSPF;
10648 else
10649 protocol = ZEBRA_ROUTE_TABLE;
7c8ff89e 10650
7a4bb9c5
DS
10651 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
10652 VTY_GET_INTEGER ("metric", metric, argv[3]);
10653
10654 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
10655 bgp_redistribute_rmap_set (red, argv[2]);
7c8ff89e 10656 bgp_redistribute_metric_set (red, metric);
8bb0831e 10657 return bgp_redistribute_set (AFI_IP, protocol, instance);
7c8ff89e
DS
10658}
10659
10660DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap,
10661 bgp_redistribute_ipv4_ospf_metric_rmap_cmd,
7a4bb9c5 10662 "redistribute (ospf|table) <1-65535> metric <0-4294967295> route-map WORD",
7c8ff89e
DS
10663 "Redistribute information from another routing protocol\n"
10664 "Open Shortest Path First (OSPFv2)\n"
10665 "Instance ID\n"
10666 "Metric for redistributed routes\n"
10667 "Default metric\n"
10668 "Route map reference\n"
10669 "Pointer to route-map entries\n")
10670{
10671 u_int32_t metric;
10672 struct bgp_redist *red;
10673 u_short instance;
7a4bb9c5 10674 int protocol;
7c8ff89e 10675
7a4bb9c5
DS
10676 if (strncmp(argv[0], "o", 1) == 0)
10677 protocol = ZEBRA_ROUTE_OSPF;
10678 else
10679 protocol = ZEBRA_ROUTE_TABLE;
7c8ff89e 10680
7a4bb9c5
DS
10681 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
10682 VTY_GET_INTEGER ("metric", metric, argv[2]);
10683
10684 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
7c8ff89e 10685 bgp_redistribute_metric_set (red, metric);
7a4bb9c5 10686 bgp_redistribute_rmap_set (red, argv[3]);
8bb0831e 10687 return bgp_redistribute_set (AFI_IP, protocol, instance);
7c8ff89e
DS
10688}
10689
10690DEFUN (no_bgp_redistribute_ipv4_ospf,
10691 no_bgp_redistribute_ipv4_ospf_cmd,
7a4bb9c5 10692 "no redistribute (ospf|table) <1-65535>",
7c8ff89e
DS
10693 NO_STR
10694 "Redistribute information from another routing protocol\n"
10695 "Open Shortest Path First (OSPFv2)\n"
10696 "Instance ID\n")
10697{
10698 u_short instance;
7a4bb9c5
DS
10699 int protocol;
10700
10701 if (strncmp(argv[0], "o", 1) == 0)
10702 protocol = ZEBRA_ROUTE_OSPF;
10703 else
10704 protocol = ZEBRA_ROUTE_TABLE;
7c8ff89e 10705
7a4bb9c5
DS
10706 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
10707 return bgp_redistribute_unset (vty->index, AFI_IP, protocol, instance);
7c8ff89e
DS
10708}
10709
10710ALIAS (no_bgp_redistribute_ipv4_ospf,
10711 no_bgp_redistribute_ipv4_ospf_rmap_cmd,
7a4bb9c5 10712 "no redistribute (ospf|table) <1-65535> route-map WORD",
7c8ff89e
DS
10713 NO_STR
10714 "Redistribute information from another routing protocol\n"
10715 "Open Shortest Path First (OSPFv2)\n"
10716 "Instance ID\n"
10717 "Route map reference\n"
10718 "Pointer to route-map entries\n")
10719
10720ALIAS (no_bgp_redistribute_ipv4_ospf,
10721 no_bgp_redistribute_ipv4_ospf_metric_cmd,
7a4bb9c5 10722 "no redistribute (ospf|table) <1-65535> metric <0-4294967295>",
7c8ff89e
DS
10723 NO_STR
10724 "Redistribute information from another routing protocol\n"
10725 "Open Shortest Path First (OSPFv2)\n"
10726 "Instance ID\n"
10727 "Metric for redistributed routes\n"
10728 "Default metric\n")
10729
10730ALIAS (no_bgp_redistribute_ipv4_ospf,
10731 no_bgp_redistribute_ipv4_ospf_rmap_metric_cmd,
7a4bb9c5 10732 "no redistribute (ospf|table) <1-65535> route-map WORD metric <0-4294967295>",
7c8ff89e
DS
10733 NO_STR
10734 "Redistribute information from another routing protocol\n"
10735 "Open Shortest Path First (OSPFv2)\n"
10736 "Instance ID\n"
10737 "Route map reference\n"
10738 "Pointer to route-map entries\n"
10739 "Metric for redistributed routes\n"
10740 "Default metric\n")
10741
10742ALIAS (no_bgp_redistribute_ipv4_ospf,
10743 no_bgp_redistribute_ipv4_ospf_metric_rmap_cmd,
7a4bb9c5 10744 "no redistribute (ospf|table) <1-65535> metric <0-4294967295> route-map WORD",
7c8ff89e
DS
10745 NO_STR
10746 "Redistribute information from another routing protocol\n"
10747 "Open Shortest Path First (OSPFv2)\n"
10748 "Instance ID\n"
10749 "Metric for redistributed routes\n"
10750 "Default metric\n"
10751 "Route map reference\n"
10752 "Pointer to route-map entries\n")
10753
718e3744 10754DEFUN (no_bgp_redistribute_ipv4,
10755 no_bgp_redistribute_ipv4_cmd,
e0ca5fde 10756 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD,
718e3744 10757 NO_STR
10758 "Redistribute information from another routing protocol\n"
e0ca5fde 10759 QUAGGA_IP_REDIST_HELP_STR_BGPD)
718e3744 10760{
10761 int type;
10762
e0ca5fde
DL
10763 type = proto_redistnum (AFI_IP, argv[0]);
10764 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 10765 {
10766 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10767 return CMD_WARNING;
10768 }
7c8ff89e 10769 return bgp_redistribute_unset (vty->index, AFI_IP, type, 0);
718e3744 10770}
10771
503006bc 10772ALIAS (no_bgp_redistribute_ipv4,
718e3744 10773 no_bgp_redistribute_ipv4_rmap_cmd,
e0ca5fde 10774 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD",
718e3744 10775 NO_STR
10776 "Redistribute information from another routing protocol\n"
e0ca5fde 10777 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 10778 "Route map reference\n"
10779 "Pointer to route-map entries\n")
718e3744 10780
503006bc 10781ALIAS (no_bgp_redistribute_ipv4,
718e3744 10782 no_bgp_redistribute_ipv4_metric_cmd,
e0ca5fde 10783 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295>",
718e3744 10784 NO_STR
10785 "Redistribute information from another routing protocol\n"
e0ca5fde 10786 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 10787 "Metric for redistributed routes\n"
10788 "Default metric\n")
718e3744 10789
503006bc 10790ALIAS (no_bgp_redistribute_ipv4,
718e3744 10791 no_bgp_redistribute_ipv4_rmap_metric_cmd,
e0ca5fde 10792 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
718e3744 10793 NO_STR
10794 "Redistribute information from another routing protocol\n"
e0ca5fde 10795 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 10796 "Route map reference\n"
10797 "Pointer to route-map entries\n"
10798 "Metric for redistributed routes\n"
10799 "Default metric\n")
718e3744 10800
503006bc 10801ALIAS (no_bgp_redistribute_ipv4,
718e3744 10802 no_bgp_redistribute_ipv4_metric_rmap_cmd,
e0ca5fde 10803 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
718e3744 10804 NO_STR
10805 "Redistribute information from another routing protocol\n"
e0ca5fde 10806 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 10807 "Metric for redistributed routes\n"
10808 "Default metric\n"
10809 "Route map reference\n"
10810 "Pointer to route-map entries\n")
6b0655a2 10811
718e3744 10812#ifdef HAVE_IPV6
10813DEFUN (bgp_redistribute_ipv6,
10814 bgp_redistribute_ipv6_cmd,
e0ca5fde 10815 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD,
718e3744 10816 "Redistribute information from another routing protocol\n"
e0ca5fde 10817 QUAGGA_IP6_REDIST_HELP_STR_BGPD)
718e3744 10818{
10819 int type;
10820
e0ca5fde
DL
10821 type = proto_redistnum (AFI_IP6, argv[0]);
10822 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 10823 {
10824 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10825 return CMD_WARNING;
10826 }
10827
7c8ff89e 10828 bgp_redist_add(vty->index, AFI_IP6, type, 0);
8bb0831e 10829 return bgp_redistribute_set (AFI_IP6, type, 0);
718e3744 10830}
10831
10832DEFUN (bgp_redistribute_ipv6_rmap,
10833 bgp_redistribute_ipv6_rmap_cmd,
e0ca5fde 10834 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD",
718e3744 10835 "Redistribute information from another routing protocol\n"
e0ca5fde 10836 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 10837 "Route map reference\n"
10838 "Pointer to route-map entries\n")
10839{
10840 int type;
7c8ff89e 10841 struct bgp_redist *red;
718e3744 10842
e0ca5fde
DL
10843 type = proto_redistnum (AFI_IP6, argv[0]);
10844 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 10845 {
10846 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10847 return CMD_WARNING;
10848 }
10849
7c8ff89e
DS
10850 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
10851 bgp_redistribute_rmap_set (red, argv[1]);
8bb0831e 10852 return bgp_redistribute_set (AFI_IP6, type, 0);
718e3744 10853}
10854
10855DEFUN (bgp_redistribute_ipv6_metric,
10856 bgp_redistribute_ipv6_metric_cmd,
e0ca5fde 10857 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295>",
718e3744 10858 "Redistribute information from another routing protocol\n"
e0ca5fde 10859 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 10860 "Metric for redistributed routes\n"
10861 "Default metric\n")
10862{
10863 int type;
10864 u_int32_t metric;
7c8ff89e 10865 struct bgp_redist *red;
718e3744 10866
e0ca5fde
DL
10867 type = proto_redistnum (AFI_IP6, argv[0]);
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 }
10873 VTY_GET_INTEGER ("metric", metric, argv[1]);
10874
7c8ff89e
DS
10875 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
10876 bgp_redistribute_metric_set (red, metric);
8bb0831e 10877 return bgp_redistribute_set (AFI_IP6, type, 0);
718e3744 10878}
10879
10880DEFUN (bgp_redistribute_ipv6_rmap_metric,
10881 bgp_redistribute_ipv6_rmap_metric_cmd,
e0ca5fde 10882 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
718e3744 10883 "Redistribute information from another routing protocol\n"
e0ca5fde 10884 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 10885 "Route map reference\n"
10886 "Pointer to route-map entries\n"
10887 "Metric for redistributed routes\n"
10888 "Default metric\n")
10889{
10890 int type;
10891 u_int32_t metric;
7c8ff89e 10892 struct bgp_redist *red;
718e3744 10893
e0ca5fde
DL
10894 type = proto_redistnum (AFI_IP6, argv[0]);
10895 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 10896 {
10897 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10898 return CMD_WARNING;
10899 }
10900 VTY_GET_INTEGER ("metric", metric, argv[2]);
10901
7c8ff89e
DS
10902 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
10903 bgp_redistribute_rmap_set (red, argv[1]);
10904 bgp_redistribute_metric_set (red, metric);
8bb0831e 10905 return bgp_redistribute_set (AFI_IP6, type, 0);
718e3744 10906}
10907
10908DEFUN (bgp_redistribute_ipv6_metric_rmap,
10909 bgp_redistribute_ipv6_metric_rmap_cmd,
e0ca5fde 10910 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
718e3744 10911 "Redistribute information from another routing protocol\n"
e0ca5fde 10912 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 10913 "Metric for redistributed routes\n"
10914 "Default metric\n"
10915 "Route map reference\n"
10916 "Pointer to route-map entries\n")
10917{
10918 int type;
10919 u_int32_t metric;
7c8ff89e 10920 struct bgp_redist *red;
718e3744 10921
e0ca5fde
DL
10922 type = proto_redistnum (AFI_IP6, argv[0]);
10923 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 10924 {
10925 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10926 return CMD_WARNING;
10927 }
10928 VTY_GET_INTEGER ("metric", metric, argv[1]);
10929
7c8ff89e
DS
10930 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
10931 bgp_redistribute_metric_set (red, metric);
10932 bgp_redistribute_rmap_set (red, argv[2]);
8bb0831e 10933 return bgp_redistribute_set (AFI_IP6, type, 0);
718e3744 10934}
10935
10936DEFUN (no_bgp_redistribute_ipv6,
10937 no_bgp_redistribute_ipv6_cmd,
e0ca5fde 10938 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD,
718e3744 10939 NO_STR
10940 "Redistribute information from another routing protocol\n"
e0ca5fde 10941 QUAGGA_IP6_REDIST_HELP_STR_BGPD)
718e3744 10942{
10943 int type;
10944
e0ca5fde
DL
10945 type = proto_redistnum (AFI_IP6, argv[0]);
10946 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 10947 {
10948 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10949 return CMD_WARNING;
10950 }
10951
7c8ff89e 10952 return bgp_redistribute_unset (vty->index, AFI_IP6, type, 0);
718e3744 10953}
10954
503006bc 10955ALIAS (no_bgp_redistribute_ipv6,
718e3744 10956 no_bgp_redistribute_ipv6_rmap_cmd,
e0ca5fde 10957 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD",
718e3744 10958 NO_STR
10959 "Redistribute information from another routing protocol\n"
e0ca5fde 10960 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 10961 "Route map reference\n"
10962 "Pointer to route-map entries\n")
718e3744 10963
503006bc 10964ALIAS (no_bgp_redistribute_ipv6,
718e3744 10965 no_bgp_redistribute_ipv6_metric_cmd,
e0ca5fde 10966 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295>",
718e3744 10967 NO_STR
10968 "Redistribute information from another routing protocol\n"
e0ca5fde 10969 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 10970 "Metric for redistributed routes\n"
10971 "Default metric\n")
718e3744 10972
503006bc 10973ALIAS (no_bgp_redistribute_ipv6,
718e3744 10974 no_bgp_redistribute_ipv6_rmap_metric_cmd,
e0ca5fde 10975 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
718e3744 10976 NO_STR
10977 "Redistribute information from another routing protocol\n"
e0ca5fde 10978 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 10979 "Route map reference\n"
10980 "Pointer to route-map entries\n"
10981 "Metric for redistributed routes\n"
10982 "Default metric\n")
718e3744 10983
503006bc 10984ALIAS (no_bgp_redistribute_ipv6,
718e3744 10985 no_bgp_redistribute_ipv6_metric_rmap_cmd,
e0ca5fde 10986 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
718e3744 10987 NO_STR
10988 "Redistribute information from another routing protocol\n"
e0ca5fde 10989 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 10990 "Metric for redistributed routes\n"
10991 "Default metric\n"
10992 "Route map reference\n"
10993 "Pointer to route-map entries\n")
10994#endif /* HAVE_IPV6 */
6b0655a2 10995
718e3744 10996int
10997bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi,
10998 safi_t safi, int *write)
10999{
11000 int i;
718e3744 11001
11002 /* Unicast redistribution only. */
11003 if (safi != SAFI_UNICAST)
11004 return 0;
11005
11006 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
11007 {
11008 /* Redistribute BGP does not make sense. */
7c8ff89e 11009 if (i != ZEBRA_ROUTE_BGP)
718e3744 11010 {
7c8ff89e
DS
11011 struct list *red_list;
11012 struct listnode *node;
11013 struct bgp_redist *red;
718e3744 11014
7c8ff89e
DS
11015 red_list = bgp->redist[afi][i];
11016 if (!red_list)
11017 continue;
718e3744 11018
7c8ff89e
DS
11019 for (ALL_LIST_ELEMENTS_RO(red_list, node, red))
11020 {
11021 /* Display "address-family" when it is not yet diplayed. */
11022 bgp_config_write_family_header (vty, afi, safi, write);
11023
11024 /* "redistribute" configuration. */
11025 vty_out (vty, " redistribute %s", zebra_route_string(i));
11026 if (red->instance)
11027 vty_out (vty, " %d", red->instance);
11028 if (red->redist_metric_flag)
11029 vty_out (vty, " metric %u", red->redist_metric);
11030 if (red->rmap.name)
11031 vty_out (vty, " route-map %s", red->rmap.name);
11032 vty_out (vty, "%s", VTY_NEWLINE);
11033 }
718e3744 11034 }
11035 }
11036 return *write;
11037}
6b0655a2 11038
718e3744 11039/* BGP node structure. */
7fc626de 11040static struct cmd_node bgp_node =
718e3744 11041{
11042 BGP_NODE,
11043 "%s(config-router)# ",
11044 1,
11045};
11046
7fc626de 11047static struct cmd_node bgp_ipv4_unicast_node =
718e3744 11048{
11049 BGP_IPV4_NODE,
11050 "%s(config-router-af)# ",
11051 1,
11052};
11053
7fc626de 11054static struct cmd_node bgp_ipv4_multicast_node =
718e3744 11055{
11056 BGP_IPV4M_NODE,
11057 "%s(config-router-af)# ",
11058 1,
11059};
11060
7fc626de 11061static struct cmd_node bgp_ipv6_unicast_node =
718e3744 11062{
11063 BGP_IPV6_NODE,
11064 "%s(config-router-af)# ",
11065 1,
11066};
11067
7fc626de 11068static struct cmd_node bgp_ipv6_multicast_node =
25ffbdc1 11069{
11070 BGP_IPV6M_NODE,
11071 "%s(config-router-af)# ",
11072 1,
11073};
11074
7fc626de 11075static struct cmd_node bgp_vpnv4_node =
718e3744 11076{
11077 BGP_VPNV4_NODE,
11078 "%s(config-router-af)# ",
11079 1
11080};
6b0655a2 11081
1f8ae70b 11082static void community_list_vty (void);
11083
718e3744 11084void
94f2b392 11085bgp_vty_init (void)
718e3744 11086{
718e3744 11087 /* Install bgp top node. */
11088 install_node (&bgp_node, bgp_config_write);
11089 install_node (&bgp_ipv4_unicast_node, NULL);
11090 install_node (&bgp_ipv4_multicast_node, NULL);
11091 install_node (&bgp_ipv6_unicast_node, NULL);
25ffbdc1 11092 install_node (&bgp_ipv6_multicast_node, NULL);
718e3744 11093 install_node (&bgp_vpnv4_node, NULL);
11094
11095 /* Install default VTY commands to new nodes. */
11096 install_default (BGP_NODE);
11097 install_default (BGP_IPV4_NODE);
11098 install_default (BGP_IPV4M_NODE);
11099 install_default (BGP_IPV6_NODE);
25ffbdc1 11100 install_default (BGP_IPV6M_NODE);
718e3744 11101 install_default (BGP_VPNV4_NODE);
11102
11103 /* "bgp multiple-instance" commands. */
11104 install_element (CONFIG_NODE, &bgp_multiple_instance_cmd);
11105 install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd);
11106
11107 /* "bgp config-type" commands. */
11108 install_element (CONFIG_NODE, &bgp_config_type_cmd);
11109 install_element (CONFIG_NODE, &no_bgp_config_type_cmd);
11110
11111 /* Dummy commands (Currently not supported) */
11112 install_element (BGP_NODE, &no_synchronization_cmd);
11113 install_element (BGP_NODE, &no_auto_summary_cmd);
11114
11115 /* "router bgp" commands. */
11116 install_element (CONFIG_NODE, &router_bgp_cmd);
11117 install_element (CONFIG_NODE, &router_bgp_view_cmd);
11118
11119 /* "no router bgp" commands. */
11120 install_element (CONFIG_NODE, &no_router_bgp_cmd);
11121 install_element (CONFIG_NODE, &no_router_bgp_view_cmd);
11122
11123 /* "bgp router-id" commands. */
11124 install_element (BGP_NODE, &bgp_router_id_cmd);
11125 install_element (BGP_NODE, &no_bgp_router_id_cmd);
11126 install_element (BGP_NODE, &no_bgp_router_id_val_cmd);
11127
11128 /* "bgp cluster-id" commands. */
11129 install_element (BGP_NODE, &bgp_cluster_id_cmd);
11130 install_element (BGP_NODE, &bgp_cluster_id32_cmd);
11131 install_element (BGP_NODE, &no_bgp_cluster_id_cmd);
11132 install_element (BGP_NODE, &no_bgp_cluster_id_arg_cmd);
11133
11134 /* "bgp confederation" commands. */
11135 install_element (BGP_NODE, &bgp_confederation_identifier_cmd);
11136 install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd);
11137 install_element (BGP_NODE, &no_bgp_confederation_identifier_arg_cmd);
11138
11139 /* "bgp confederation peers" commands. */
11140 install_element (BGP_NODE, &bgp_confederation_peers_cmd);
11141 install_element (BGP_NODE, &no_bgp_confederation_peers_cmd);
11142
abc920f8
DS
11143 /* bgp max-med command */
11144 install_element (BGP_NODE, &bgp_maxmed_admin_cmd);
11145 install_element (BGP_NODE, &no_bgp_maxmed_admin_cmd);
11146 install_element (BGP_NODE, &bgp_maxmed_admin_medv_cmd);
11147 install_element (BGP_NODE, &no_bgp_maxmed_admin_medv_cmd);
11148 install_element (BGP_NODE, &bgp_maxmed_onstartup_cmd);
11149 install_element (BGP_NODE, &no_bgp_maxmed_onstartup_cmd);
11150 install_element (BGP_NODE, &no_bgp_maxmed_onstartup_period_cmd);
11151 install_element (BGP_NODE, &bgp_maxmed_onstartup_medv_cmd);
11152 install_element (BGP_NODE, &no_bgp_maxmed_onstartup_period_medv_cmd);
11153
f188f2c4
DS
11154 /* bgp update-delay command */
11155 install_element (BGP_NODE, &bgp_update_delay_cmd);
11156 install_element (BGP_NODE, &no_bgp_update_delay_cmd);
11157 install_element (BGP_NODE, &bgp_update_delay_establish_wait_cmd);
11158 install_element (BGP_NODE, &no_bgp_update_delay_establish_wait_cmd);
11159
cb1faec9
DS
11160 install_element (BGP_NODE, &bgp_wpkt_quanta_cmd);
11161 install_element (BGP_NODE, &no_bgp_wpkt_quanta_cmd);
11162
3f9c7369
DS
11163 install_element (BGP_NODE, &bgp_coalesce_time_cmd);
11164 install_element (BGP_NODE, &no_bgp_coalesce_time_cmd);
11165
165b5fff
JB
11166 /* "maximum-paths" commands. */
11167 install_element (BGP_NODE, &bgp_maxpaths_cmd);
11168 install_element (BGP_NODE, &no_bgp_maxpaths_cmd);
11169 install_element (BGP_NODE, &no_bgp_maxpaths_arg_cmd);
11170 install_element (BGP_IPV4_NODE, &bgp_maxpaths_cmd);
11171 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_cmd);
11172 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_arg_cmd);
431aa9f9
DS
11173 install_element (BGP_IPV6_NODE, &bgp_maxpaths_cmd);
11174 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_cmd);
11175 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_arg_cmd);
165b5fff 11176 install_element (BGP_NODE, &bgp_maxpaths_ibgp_cmd);
5e242b0d 11177 install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
165b5fff
JB
11178 install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cmd);
11179 install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_arg_cmd);
5e242b0d 11180 install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cluster_cmd);
165b5fff 11181 install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd);
5e242b0d 11182 install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
165b5fff 11183 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd);
5e242b0d 11184 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cluster_cmd);
165b5fff 11185 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_arg_cmd);
431aa9f9 11186 install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd);
5e242b0d 11187 install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
431aa9f9
DS
11188 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd);
11189 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_arg_cmd);
5e242b0d 11190 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cluster_cmd);
165b5fff 11191
718e3744 11192 /* "timers bgp" commands. */
11193 install_element (BGP_NODE, &bgp_timers_cmd);
11194 install_element (BGP_NODE, &no_bgp_timers_cmd);
11195 install_element (BGP_NODE, &no_bgp_timers_arg_cmd);
11196
518f0eb1
DS
11197 /* route-map delay-timer commands */
11198 install_element (BGP_NODE, &bgp_set_route_map_delay_timer_cmd);
11199 install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd);
11200
718e3744 11201 /* "bgp client-to-client reflection" commands */
11202 install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd);
11203 install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd);
11204
11205 /* "bgp always-compare-med" commands */
11206 install_element (BGP_NODE, &bgp_always_compare_med_cmd);
11207 install_element (BGP_NODE, &no_bgp_always_compare_med_cmd);
11208
11209 /* "bgp deterministic-med" commands */
11210 install_element (BGP_NODE, &bgp_deterministic_med_cmd);
11211 install_element (BGP_NODE, &no_bgp_deterministic_med_cmd);
538621f2 11212
538621f2 11213 /* "bgp graceful-restart" commands */
11214 install_element (BGP_NODE, &bgp_graceful_restart_cmd);
11215 install_element (BGP_NODE, &no_bgp_graceful_restart_cmd);
93406d87 11216 install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd);
11217 install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd);
11218 install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_val_cmd);
718e3744 11219
11220 /* "bgp fast-external-failover" commands */
11221 install_element (BGP_NODE, &bgp_fast_external_failover_cmd);
11222 install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd);
11223
11224 /* "bgp enforce-first-as" commands */
11225 install_element (BGP_NODE, &bgp_enforce_first_as_cmd);
11226 install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd);
11227
11228 /* "bgp bestpath compare-routerid" commands */
11229 install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd);
11230 install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd);
11231
11232 /* "bgp bestpath as-path ignore" commands */
11233 install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd);
11234 install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd);
11235
6811845b 11236 /* "bgp bestpath as-path confed" commands */
11237 install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd);
11238 install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd);
11239
2fdd455c
PM
11240 /* "bgp bestpath as-path multipath-relax" commands */
11241 install_element (BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd);
11242 install_element (BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd);
11243
848973c7 11244 /* "bgp log-neighbor-changes" commands */
11245 install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd);
11246 install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd);
11247
718e3744 11248 /* "bgp bestpath med" commands */
11249 install_element (BGP_NODE, &bgp_bestpath_med_cmd);
11250 install_element (BGP_NODE, &bgp_bestpath_med2_cmd);
11251 install_element (BGP_NODE, &bgp_bestpath_med3_cmd);
11252 install_element (BGP_NODE, &no_bgp_bestpath_med_cmd);
11253 install_element (BGP_NODE, &no_bgp_bestpath_med2_cmd);
11254 install_element (BGP_NODE, &no_bgp_bestpath_med3_cmd);
11255
11256 /* "no bgp default ipv4-unicast" commands. */
11257 install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd);
11258 install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd);
11259
11260 /* "bgp network import-check" commands. */
11261 install_element (BGP_NODE, &bgp_network_import_check_cmd);
11262 install_element (BGP_NODE, &no_bgp_network_import_check_cmd);
11263
11264 /* "bgp default local-preference" commands. */
11265 install_element (BGP_NODE, &bgp_default_local_preference_cmd);
11266 install_element (BGP_NODE, &no_bgp_default_local_preference_cmd);
11267 install_element (BGP_NODE, &no_bgp_default_local_preference_val_cmd);
11268
3f9c7369
DS
11269 /* "bgp default subgroup-pkt-queue-max" commands. */
11270 install_element (BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd);
11271 install_element (BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd);
11272
8bd9d948
DS
11273 /* bgp ibgp-allow-policy-mods command */
11274 install_element (BGP_NODE, &bgp_rr_allow_outbound_policy_cmd);
11275 install_element (BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd);
11276
f14e6fdb
DS
11277 /* "bgp listen limit" commands. */
11278 install_element (BGP_NODE, &bgp_listen_limit_cmd);
11279 install_element (BGP_NODE, &no_bgp_listen_limit_cmd);
11280
11281 /* "bgp listen range" commands. */
11282 install_element (BGP_NODE, &bgp_listen_range_cmd);
11283 install_element (BGP_NODE, &no_bgp_listen_range_cmd);
11284
718e3744 11285 /* "neighbor remote-as" commands. */
11286 install_element (BGP_NODE, &neighbor_remote_as_cmd);
a80beece 11287 install_element (BGP_NODE, &neighbor_interface_config_cmd);
718e3744 11288 install_element (BGP_NODE, &no_neighbor_cmd);
11289 install_element (BGP_NODE, &no_neighbor_remote_as_cmd);
a80beece 11290 install_element (BGP_NODE, &no_neighbor_interface_config_cmd);
718e3744 11291
11292 /* "neighbor peer-group" commands. */
11293 install_element (BGP_NODE, &neighbor_peer_group_cmd);
11294 install_element (BGP_NODE, &no_neighbor_peer_group_cmd);
a80beece 11295 install_element (BGP_NODE, &no_neighbor_interface_peer_group_remote_as_cmd);
718e3744 11296
11297 /* "neighbor local-as" commands. */
11298 install_element (BGP_NODE, &neighbor_local_as_cmd);
11299 install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd);
9d3f9705 11300 install_element (BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd);
718e3744 11301 install_element (BGP_NODE, &no_neighbor_local_as_cmd);
11302 install_element (BGP_NODE, &no_neighbor_local_as_val_cmd);
11303 install_element (BGP_NODE, &no_neighbor_local_as_val2_cmd);
9d3f9705 11304 install_element (BGP_NODE, &no_neighbor_local_as_val3_cmd);
718e3744 11305
3f9c7369
DS
11306 /* "neighbor solo" commands. */
11307 install_element (BGP_NODE, &neighbor_solo_cmd);
11308 install_element (BGP_NODE, &no_neighbor_solo_cmd);
11309
0df7c91f
PJ
11310 /* "neighbor password" commands. */
11311 install_element (BGP_NODE, &neighbor_password_cmd);
11312 install_element (BGP_NODE, &no_neighbor_password_cmd);
11313
718e3744 11314 /* "neighbor activate" commands. */
11315 install_element (BGP_NODE, &neighbor_activate_cmd);
11316 install_element (BGP_IPV4_NODE, &neighbor_activate_cmd);
11317 install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd);
11318 install_element (BGP_IPV6_NODE, &neighbor_activate_cmd);
25ffbdc1 11319 install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd);
718e3744 11320 install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd);
11321
11322 /* "no neighbor activate" commands. */
11323 install_element (BGP_NODE, &no_neighbor_activate_cmd);
11324 install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd);
11325 install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd);
11326 install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd);
25ffbdc1 11327 install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd);
718e3744 11328 install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd);
11329
11330 /* "neighbor peer-group set" commands. */
11331 install_element (BGP_NODE, &neighbor_set_peer_group_cmd);
11332 install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_cmd);
11333 install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_cmd);
11334 install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd);
25ffbdc1 11335 install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_cmd);
a58545bb 11336 install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_cmd);
11337
718e3744 11338 /* "no neighbor peer-group unset" commands. */
11339 install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd);
11340 install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd);
11341 install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_cmd);
11342 install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd);
25ffbdc1 11343 install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_cmd);
a58545bb 11344 install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_cmd);
11345
718e3744 11346 /* "neighbor softreconfiguration inbound" commands.*/
11347 install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd);
11348 install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd);
11349 install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd);
11350 install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
11351 install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd);
11352 install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd);
11353 install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd);
11354 install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
25ffbdc1 11355 install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd);
11356 install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd);
a58545bb 11357 install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd);
11358 install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
718e3744 11359
11360 /* "neighbor attribute-unchanged" commands. */
11361 install_element (BGP_NODE, &neighbor_attr_unchanged_cmd);
11362 install_element (BGP_NODE, &neighbor_attr_unchanged1_cmd);
11363 install_element (BGP_NODE, &neighbor_attr_unchanged2_cmd);
11364 install_element (BGP_NODE, &neighbor_attr_unchanged3_cmd);
11365 install_element (BGP_NODE, &neighbor_attr_unchanged4_cmd);
11366 install_element (BGP_NODE, &neighbor_attr_unchanged5_cmd);
11367 install_element (BGP_NODE, &neighbor_attr_unchanged6_cmd);
11368 install_element (BGP_NODE, &neighbor_attr_unchanged7_cmd);
11369 install_element (BGP_NODE, &neighbor_attr_unchanged8_cmd);
11370 install_element (BGP_NODE, &neighbor_attr_unchanged9_cmd);
11371 install_element (BGP_NODE, &neighbor_attr_unchanged10_cmd);
11372 install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd);
11373 install_element (BGP_NODE, &no_neighbor_attr_unchanged1_cmd);
11374 install_element (BGP_NODE, &no_neighbor_attr_unchanged2_cmd);
11375 install_element (BGP_NODE, &no_neighbor_attr_unchanged3_cmd);
11376 install_element (BGP_NODE, &no_neighbor_attr_unchanged4_cmd);
11377 install_element (BGP_NODE, &no_neighbor_attr_unchanged5_cmd);
11378 install_element (BGP_NODE, &no_neighbor_attr_unchanged6_cmd);
11379 install_element (BGP_NODE, &no_neighbor_attr_unchanged7_cmd);
11380 install_element (BGP_NODE, &no_neighbor_attr_unchanged8_cmd);
11381 install_element (BGP_NODE, &no_neighbor_attr_unchanged9_cmd);
11382 install_element (BGP_NODE, &no_neighbor_attr_unchanged10_cmd);
11383 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd);
11384 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged1_cmd);
11385 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged2_cmd);
11386 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged3_cmd);
11387 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged4_cmd);
11388 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged5_cmd);
11389 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged6_cmd);
11390 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged7_cmd);
11391 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged8_cmd);
11392 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged9_cmd);
11393 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged10_cmd);
11394 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd);
11395 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged1_cmd);
11396 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged2_cmd);
11397 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged3_cmd);
11398 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged4_cmd);
11399 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged5_cmd);
11400 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged6_cmd);
11401 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged7_cmd);
11402 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged8_cmd);
11403 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged9_cmd);
11404 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged10_cmd);
11405 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd);
11406 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged1_cmd);
11407 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged2_cmd);
11408 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged3_cmd);
11409 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged4_cmd);
11410 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged5_cmd);
11411 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged6_cmd);
11412 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged7_cmd);
11413 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged8_cmd);
11414 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged9_cmd);
11415 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged10_cmd);
11416 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd);
11417 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged1_cmd);
11418 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged2_cmd);
11419 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged3_cmd);
11420 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged4_cmd);
11421 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged5_cmd);
11422 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged6_cmd);
11423 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged7_cmd);
11424 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged8_cmd);
11425 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged9_cmd);
11426 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged10_cmd);
11427 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd);
11428 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged1_cmd);
11429 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged2_cmd);
11430 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged3_cmd);
11431 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged4_cmd);
11432 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged5_cmd);
11433 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged6_cmd);
11434 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged7_cmd);
11435 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged8_cmd);
11436 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged9_cmd);
11437 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged10_cmd);
11438 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd);
11439 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged1_cmd);
11440 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged2_cmd);
11441 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged3_cmd);
11442 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged4_cmd);
11443 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged5_cmd);
11444 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged6_cmd);
11445 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged7_cmd);
11446 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged8_cmd);
11447 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged9_cmd);
11448 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged10_cmd);
25ffbdc1 11449 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd);
11450 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged1_cmd);
11451 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged2_cmd);
11452 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged3_cmd);
11453 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged4_cmd);
11454 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged5_cmd);
11455 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged6_cmd);
11456 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged7_cmd);
11457 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged8_cmd);
11458 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged9_cmd);
11459 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged10_cmd);
11460 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd);
11461 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged1_cmd);
11462 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged2_cmd);
11463 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged3_cmd);
11464 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged4_cmd);
11465 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged5_cmd);
11466 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged6_cmd);
11467 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged7_cmd);
11468 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged8_cmd);
11469 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged9_cmd);
11470 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged10_cmd);
718e3744 11471 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd);
11472 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged1_cmd);
11473 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged2_cmd);
11474 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged3_cmd);
11475 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged4_cmd);
11476 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged5_cmd);
11477 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged6_cmd);
11478 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged7_cmd);
11479 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged8_cmd);
11480 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged9_cmd);
11481 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged10_cmd);
11482 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd);
11483 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged1_cmd);
11484 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged2_cmd);
11485 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged3_cmd);
11486 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged4_cmd);
11487 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged5_cmd);
11488 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged6_cmd);
11489 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged7_cmd);
11490 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged8_cmd);
11491 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged9_cmd);
11492 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged10_cmd);
11493
fee0f4c6 11494 /* "nexthop-local unchanged" commands */
11495 install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd);
11496 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd);
11497
718e3744 11498 /* "transparent-as" and "transparent-nexthop" for old version
11499 compatibility. */
11500 install_element (BGP_NODE, &neighbor_transparent_as_cmd);
11501 install_element (BGP_NODE, &neighbor_transparent_nexthop_cmd);
11502
11503 /* "neighbor next-hop-self" commands. */
11504 install_element (BGP_NODE, &neighbor_nexthop_self_cmd);
11505 install_element (BGP_NODE, &no_neighbor_nexthop_self_cmd);
11506 install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd);
11507 install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd);
11508 install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd);
11509 install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd);
11510 install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd);
11511 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd);
25ffbdc1 11512 install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd);
11513 install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd);
718e3744 11514 install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd);
11515 install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd);
11516
c7122e14
DS
11517 /* "neighbor as-override" commands. */
11518 install_element (BGP_NODE, &neighbor_as_override_cmd);
11519 install_element (BGP_NODE, &no_neighbor_as_override_cmd);
11520 install_element (BGP_IPV4_NODE, &neighbor_as_override_cmd);
11521 install_element (BGP_IPV4_NODE, &no_neighbor_as_override_cmd);
11522 install_element (BGP_IPV4M_NODE, &neighbor_as_override_cmd);
11523 install_element (BGP_IPV4M_NODE, &no_neighbor_as_override_cmd);
11524 install_element (BGP_IPV6_NODE, &neighbor_as_override_cmd);
11525 install_element (BGP_IPV6_NODE, &no_neighbor_as_override_cmd);
11526 install_element (BGP_IPV6M_NODE, &neighbor_as_override_cmd);
11527 install_element (BGP_IPV6M_NODE, &no_neighbor_as_override_cmd);
11528 install_element (BGP_VPNV4_NODE, &neighbor_as_override_cmd);
11529 install_element (BGP_VPNV4_NODE, &no_neighbor_as_override_cmd);
11530
718e3744 11531 /* "neighbor remove-private-AS" commands. */
11532 install_element (BGP_NODE, &neighbor_remove_private_as_cmd);
11533 install_element (BGP_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
11534 install_element (BGP_NODE, &neighbor_remove_private_as_all_cmd);
11535 install_element (BGP_NODE, &no_neighbor_remove_private_as_all_cmd);
11536 install_element (BGP_NODE, &neighbor_remove_private_as_replace_as_cmd);
11537 install_element (BGP_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
11538 install_element (BGP_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
11539 install_element (BGP_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 11540 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd);
11541 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
11542 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd);
11543 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd);
11544 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_replace_as_cmd);
11545 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
11546 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
11547 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 11548 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd);
11549 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
11550 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd);
11551 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd);
11552 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_replace_as_cmd);
11553 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
11554 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
11555 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 11556 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd);
11557 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
11558 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd);
11559 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd);
11560 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_replace_as_cmd);
11561 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
11562 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
11563 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
25ffbdc1 11564 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd);
11565 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
11566 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd);
11567 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd);
11568 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_replace_as_cmd);
11569 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
11570 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
11571 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 11572 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd);
11573 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
11574 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd);
11575 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd);
11576 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_replace_as_cmd);
11577 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
11578 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
11579 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 11580
11581 /* "neighbor send-community" commands.*/
11582 install_element (BGP_NODE, &neighbor_send_community_cmd);
11583 install_element (BGP_NODE, &neighbor_send_community_type_cmd);
11584 install_element (BGP_NODE, &no_neighbor_send_community_cmd);
11585 install_element (BGP_NODE, &no_neighbor_send_community_type_cmd);
11586 install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd);
11587 install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd);
11588 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd);
11589 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd);
11590 install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd);
11591 install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd);
11592 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd);
11593 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd);
11594 install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd);
11595 install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd);
11596 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd);
11597 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd);
25ffbdc1 11598 install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd);
11599 install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd);
11600 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd);
11601 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd);
718e3744 11602 install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd);
11603 install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd);
11604 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd);
11605 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd);
11606
11607 /* "neighbor route-reflector" commands.*/
11608 install_element (BGP_NODE, &neighbor_route_reflector_client_cmd);
11609 install_element (BGP_NODE, &no_neighbor_route_reflector_client_cmd);
11610 install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd);
11611 install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd);
11612 install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd);
11613 install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd);
11614 install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd);
11615 install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd);
25ffbdc1 11616 install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd);
11617 install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd);
718e3744 11618 install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd);
11619 install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd);
11620
11621 /* "neighbor route-server" commands.*/
11622 install_element (BGP_NODE, &neighbor_route_server_client_cmd);
11623 install_element (BGP_NODE, &no_neighbor_route_server_client_cmd);
11624 install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd);
11625 install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd);
11626 install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd);
11627 install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd);
11628 install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd);
11629 install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd);
25ffbdc1 11630 install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd);
11631 install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd);
718e3744 11632 install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd);
11633 install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd);
11634
11635 /* "neighbor passive" commands. */
11636 install_element (BGP_NODE, &neighbor_passive_cmd);
11637 install_element (BGP_NODE, &no_neighbor_passive_cmd);
11638
d5a5c8f0
DS
11639 /* "neighbor bfd" commands. */
11640 install_element (BGP_NODE, &neighbor_bfd_cmd);
11641 install_element (BGP_NODE, &no_neighbor_bfd_cmd);
11642
718e3744 11643 /* "neighbor shutdown" commands. */
11644 install_element (BGP_NODE, &neighbor_shutdown_cmd);
11645 install_element (BGP_NODE, &no_neighbor_shutdown_cmd);
11646
c9502438 11647 /* Deprecated "neighbor capability route-refresh" commands.*/
718e3744 11648 install_element (BGP_NODE, &neighbor_capability_route_refresh_cmd);
11649 install_element (BGP_NODE, &no_neighbor_capability_route_refresh_cmd);
11650
11651 /* "neighbor capability orf prefix-list" commands.*/
11652 install_element (BGP_NODE, &neighbor_capability_orf_prefix_cmd);
11653 install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_cmd);
11654 install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd);
11655 install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd);
11656 install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd);
11657 install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd);
11658 install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd);
11659 install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd);
25ffbdc1 11660 install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd);
11661 install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd);
718e3744 11662
11663 /* "neighbor capability dynamic" commands.*/
11664 install_element (BGP_NODE, &neighbor_capability_dynamic_cmd);
11665 install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd);
11666
11667 /* "neighbor dont-capability-negotiate" commands. */
11668 install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd);
11669 install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd);
11670
11671 /* "neighbor ebgp-multihop" commands. */
11672 install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd);
11673 install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd);
11674 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd);
11675 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_ttl_cmd);
11676
6ffd2079 11677 /* "neighbor disable-connected-check" commands. */
11678 install_element (BGP_NODE, &neighbor_disable_connected_check_cmd);
11679 install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd);
718e3744 11680 install_element (BGP_NODE, &neighbor_enforce_multihop_cmd);
11681 install_element (BGP_NODE, &no_neighbor_enforce_multihop_cmd);
11682
11683 /* "neighbor description" commands. */
11684 install_element (BGP_NODE, &neighbor_description_cmd);
11685 install_element (BGP_NODE, &no_neighbor_description_cmd);
11686 install_element (BGP_NODE, &no_neighbor_description_val_cmd);
11687
11688 /* "neighbor update-source" commands. "*/
11689 install_element (BGP_NODE, &neighbor_update_source_cmd);
11690 install_element (BGP_NODE, &no_neighbor_update_source_cmd);
11691
11692 /* "neighbor default-originate" commands. */
11693 install_element (BGP_NODE, &neighbor_default_originate_cmd);
11694 install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd);
11695 install_element (BGP_NODE, &no_neighbor_default_originate_cmd);
11696 install_element (BGP_NODE, &no_neighbor_default_originate_rmap_cmd);
11697 install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd);
11698 install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd);
11699 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd);
11700 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_rmap_cmd);
11701 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd);
11702 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd);
11703 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd);
11704 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_rmap_cmd);
11705 install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd);
11706 install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd);
11707 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd);
11708 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_rmap_cmd);
25ffbdc1 11709 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd);
11710 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd);
11711 install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd);
11712 install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_rmap_cmd);
718e3744 11713
11714 /* "neighbor port" commands. */
11715 install_element (BGP_NODE, &neighbor_port_cmd);
11716 install_element (BGP_NODE, &no_neighbor_port_cmd);
11717 install_element (BGP_NODE, &no_neighbor_port_val_cmd);
11718
11719 /* "neighbor weight" commands. */
11720 install_element (BGP_NODE, &neighbor_weight_cmd);
11721 install_element (BGP_NODE, &no_neighbor_weight_cmd);
11722 install_element (BGP_NODE, &no_neighbor_weight_val_cmd);
11723
11724 /* "neighbor override-capability" commands. */
11725 install_element (BGP_NODE, &neighbor_override_capability_cmd);
11726 install_element (BGP_NODE, &no_neighbor_override_capability_cmd);
11727
11728 /* "neighbor strict-capability-match" commands. */
11729 install_element (BGP_NODE, &neighbor_strict_capability_cmd);
11730 install_element (BGP_NODE, &no_neighbor_strict_capability_cmd);
11731
11732 /* "neighbor timers" commands. */
11733 install_element (BGP_NODE, &neighbor_timers_cmd);
11734 install_element (BGP_NODE, &no_neighbor_timers_cmd);
11735
11736 /* "neighbor timers connect" commands. */
11737 install_element (BGP_NODE, &neighbor_timers_connect_cmd);
11738 install_element (BGP_NODE, &no_neighbor_timers_connect_cmd);
11739 install_element (BGP_NODE, &no_neighbor_timers_connect_val_cmd);
11740
11741 /* "neighbor advertisement-interval" commands. */
11742 install_element (BGP_NODE, &neighbor_advertise_interval_cmd);
11743 install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd);
11744 install_element (BGP_NODE, &no_neighbor_advertise_interval_val_cmd);
11745
11746 /* "neighbor version" commands. */
11747 install_element (BGP_NODE, &neighbor_version_cmd);
718e3744 11748
11749 /* "neighbor interface" commands. */
11750 install_element (BGP_NODE, &neighbor_interface_cmd);
11751 install_element (BGP_NODE, &no_neighbor_interface_cmd);
11752
11753 /* "neighbor distribute" commands. */
11754 install_element (BGP_NODE, &neighbor_distribute_list_cmd);
11755 install_element (BGP_NODE, &no_neighbor_distribute_list_cmd);
11756 install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd);
11757 install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd);
11758 install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd);
11759 install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd);
11760 install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd);
11761 install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd);
25ffbdc1 11762 install_element (BGP_IPV6M_NODE, &neighbor_distribute_list_cmd);
11763 install_element (BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd);
718e3744 11764 install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd);
11765 install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd);
11766
11767 /* "neighbor prefix-list" commands. */
11768 install_element (BGP_NODE, &neighbor_prefix_list_cmd);
11769 install_element (BGP_NODE, &no_neighbor_prefix_list_cmd);
11770 install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd);
11771 install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd);
11772 install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd);
11773 install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd);
11774 install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd);
11775 install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd);
25ffbdc1 11776 install_element (BGP_IPV6M_NODE, &neighbor_prefix_list_cmd);
11777 install_element (BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd);
718e3744 11778 install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd);
11779 install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd);
11780
11781 /* "neighbor filter-list" commands. */
11782 install_element (BGP_NODE, &neighbor_filter_list_cmd);
11783 install_element (BGP_NODE, &no_neighbor_filter_list_cmd);
11784 install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd);
11785 install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd);
11786 install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd);
11787 install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd);
11788 install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd);
11789 install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd);
25ffbdc1 11790 install_element (BGP_IPV6M_NODE, &neighbor_filter_list_cmd);
11791 install_element (BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd);
718e3744 11792 install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd);
11793 install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd);
11794
11795 /* "neighbor route-map" commands. */
11796 install_element (BGP_NODE, &neighbor_route_map_cmd);
11797 install_element (BGP_NODE, &no_neighbor_route_map_cmd);
11798 install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd);
11799 install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd);
11800 install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd);
11801 install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd);
11802 install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd);
11803 install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd);
25ffbdc1 11804 install_element (BGP_IPV6M_NODE, &neighbor_route_map_cmd);
11805 install_element (BGP_IPV6M_NODE, &no_neighbor_route_map_cmd);
718e3744 11806 install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd);
11807 install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd);
11808
11809 /* "neighbor unsuppress-map" commands. */
11810 install_element (BGP_NODE, &neighbor_unsuppress_map_cmd);
11811 install_element (BGP_NODE, &no_neighbor_unsuppress_map_cmd);
11812 install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd);
11813 install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd);
11814 install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd);
11815 install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd);
11816 install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd);
11817 install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd);
25ffbdc1 11818 install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd);
11819 install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd);
a58545bb 11820 install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd);
11821 install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd);
718e3744 11822
11823 /* "neighbor maximum-prefix" commands. */
11824 install_element (BGP_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 11825 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 11826 install_element (BGP_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 11827 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 11828 install_element (BGP_NODE, &neighbor_maximum_prefix_restart_cmd);
11829 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 11830 install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd);
11831 install_element (BGP_NODE, &no_neighbor_maximum_prefix_val_cmd);
0a486e5f 11832 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
11833 install_element (BGP_NODE, &no_neighbor_maximum_prefix_warning_cmd);
11834 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
11835 install_element (BGP_NODE, &no_neighbor_maximum_prefix_restart_cmd);
11836 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 11837 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 11838 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 11839 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 11840 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 11841 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd);
11842 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 11843 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd);
11844 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
0a486e5f 11845 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
11846 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
11847 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
11848 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
11849 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 11850 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 11851 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 11852 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 11853 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 11854 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd);
11855 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 11856 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd);
11857 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_val_cmd);
0a486e5f 11858 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
11859 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_warning_cmd);
11860 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
11861 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_restart_cmd);
11862 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 11863 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 11864 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 11865 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 11866 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 11867 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd);
11868 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 11869 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd);
11870 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_val_cmd);
0a486e5f 11871 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
11872 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_warning_cmd);
11873 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
11874 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_restart_cmd);
11875 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
25ffbdc1 11876 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd);
11877 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd);
11878 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd);
11879 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
11880 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd);
11881 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
11882 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd);
11883 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_val_cmd);
11884 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
11885 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_warning_cmd);
11886 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
11887 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_restart_cmd);
11888 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 11889 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 11890 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 11891 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 11892 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 11893 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd);
11894 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 11895 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd);
11896 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
0a486e5f 11897 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
11898 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
11899 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
11900 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
11901 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 11902
11903 /* "neighbor allowas-in" */
11904 install_element (BGP_NODE, &neighbor_allowas_in_cmd);
11905 install_element (BGP_NODE, &neighbor_allowas_in_arg_cmd);
11906 install_element (BGP_NODE, &no_neighbor_allowas_in_cmd);
11907 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd);
11908 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_arg_cmd);
11909 install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd);
11910 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd);
11911 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_arg_cmd);
11912 install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd);
11913 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd);
11914 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_arg_cmd);
11915 install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd);
25ffbdc1 11916 install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd);
11917 install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_arg_cmd);
11918 install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd);
718e3744 11919 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd);
11920 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_arg_cmd);
11921 install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd);
11922
11923 /* address-family commands. */
11924 install_element (BGP_NODE, &address_family_ipv4_cmd);
11925 install_element (BGP_NODE, &address_family_ipv4_safi_cmd);
11926#ifdef HAVE_IPV6
11927 install_element (BGP_NODE, &address_family_ipv6_cmd);
25ffbdc1 11928 install_element (BGP_NODE, &address_family_ipv6_safi_cmd);
718e3744 11929#endif /* HAVE_IPV6 */
11930 install_element (BGP_NODE, &address_family_vpnv4_cmd);
11931 install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd);
11932
11933 /* "exit-address-family" command. */
11934 install_element (BGP_IPV4_NODE, &exit_address_family_cmd);
11935 install_element (BGP_IPV4M_NODE, &exit_address_family_cmd);
11936 install_element (BGP_IPV6_NODE, &exit_address_family_cmd);
25ffbdc1 11937 install_element (BGP_IPV6M_NODE, &exit_address_family_cmd);
718e3744 11938 install_element (BGP_VPNV4_NODE, &exit_address_family_cmd);
11939
11940 /* "clear ip bgp commands" */
11941 install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd);
11942 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_cmd);
11943 install_element (ENABLE_NODE, &clear_ip_bgp_as_cmd);
11944 install_element (ENABLE_NODE, &clear_ip_bgp_peer_cmd);
11945 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_cmd);
11946 install_element (ENABLE_NODE, &clear_ip_bgp_external_cmd);
11947#ifdef HAVE_IPV6
11948 install_element (ENABLE_NODE, &clear_bgp_all_cmd);
11949 install_element (ENABLE_NODE, &clear_bgp_instance_all_cmd);
11950 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_cmd);
11951 install_element (ENABLE_NODE, &clear_bgp_peer_cmd);
11952 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_cmd);
11953 install_element (ENABLE_NODE, &clear_bgp_peer_group_cmd);
11954 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_cmd);
11955 install_element (ENABLE_NODE, &clear_bgp_external_cmd);
11956 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_cmd);
11957 install_element (ENABLE_NODE, &clear_bgp_as_cmd);
11958 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_cmd);
11959#endif /* HAVE_IPV6 */
11960
11961 /* "clear ip bgp neighbor soft in" */
11962 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_in_cmd);
11963 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_in_cmd);
11964 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_cmd);
11965 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_prefix_filter_cmd);
11966 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_in_prefix_filter_cmd);
11967 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_in_cmd);
11968 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_cmd);
11969 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_prefix_filter_cmd);
11970 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_in_cmd);
11971 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_cmd);
11972 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_prefix_filter_cmd);
11973 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_in_cmd);
11974 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_cmd);
11975 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_prefix_filter_cmd);
11976 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_in_cmd);
11977 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_cmd);
11978 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_prefix_filter_cmd);
11979 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_in_cmd);
11980 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_in_cmd);
11981 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_cmd);
11982 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_prefix_filter_cmd);
11983 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_in_prefix_filter_cmd);
11984 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_in_cmd);
11985 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_cmd);
11986 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd);
11987 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_in_cmd);
11988 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_cmd);
11989 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd);
11990 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_in_cmd);
11991 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_cmd);
11992 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_prefix_filter_cmd);
11993 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_in_cmd);
11994 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_cmd);
11995 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_prefix_filter_cmd);
11996 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_in_cmd);
11997 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_in_cmd);
11998 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_in_cmd);
11999 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_in_cmd);
12000 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_in_cmd);
12001 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_in_cmd);
12002#ifdef HAVE_IPV6
12003 install_element (ENABLE_NODE, &clear_bgp_all_soft_in_cmd);
12004 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_in_cmd);
12005 install_element (ENABLE_NODE, &clear_bgp_all_in_cmd);
12006 install_element (ENABLE_NODE, &clear_bgp_all_in_prefix_filter_cmd);
12007 install_element (ENABLE_NODE, &clear_bgp_peer_soft_in_cmd);
12008 install_element (ENABLE_NODE, &clear_bgp_peer_in_cmd);
12009 install_element (ENABLE_NODE, &clear_bgp_peer_in_prefix_filter_cmd);
12010 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_in_cmd);
12011 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_cmd);
12012 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_prefix_filter_cmd);
12013 install_element (ENABLE_NODE, &clear_bgp_external_soft_in_cmd);
12014 install_element (ENABLE_NODE, &clear_bgp_external_in_cmd);
12015 install_element (ENABLE_NODE, &clear_bgp_external_in_prefix_filter_cmd);
12016 install_element (ENABLE_NODE, &clear_bgp_as_soft_in_cmd);
12017 install_element (ENABLE_NODE, &clear_bgp_as_in_cmd);
12018 install_element (ENABLE_NODE, &clear_bgp_as_in_prefix_filter_cmd);
12019 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_in_cmd);
12020 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_cmd);
12021 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_prefix_filter_cmd);
12022 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_in_cmd);
12023 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_cmd);
12024 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_prefix_filter_cmd);
12025 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_in_cmd);
12026 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_cmd);
12027 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_prefix_filter_cmd);
12028 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_in_cmd);
12029 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_cmd);
12030 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_prefix_filter_cmd);
12031 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_in_cmd);
12032 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_cmd);
12033 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_prefix_filter_cmd);
12034#endif /* HAVE_IPV6 */
12035
8ad7271d
DS
12036 /* clear ip bgp prefix */
12037 install_element (ENABLE_NODE, &clear_ip_bgp_prefix_cmd);
12038 install_element (ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd);
12039
718e3744 12040 /* "clear ip bgp neighbor soft out" */
12041 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_out_cmd);
12042 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_out_cmd);
12043 install_element (ENABLE_NODE, &clear_ip_bgp_all_out_cmd);
12044 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_out_cmd);
12045 install_element (ENABLE_NODE, &clear_ip_bgp_peer_out_cmd);
12046 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_out_cmd);
12047 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_out_cmd);
12048 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_out_cmd);
12049 install_element (ENABLE_NODE, &clear_ip_bgp_external_out_cmd);
12050 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_out_cmd);
12051 install_element (ENABLE_NODE, &clear_ip_bgp_as_out_cmd);
12052 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_out_cmd);
12053 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_out_cmd);
12054 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_out_cmd);
12055 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_out_cmd);
12056 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_out_cmd);
12057 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_out_cmd);
12058 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_out_cmd);
12059 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_out_cmd);
12060 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_out_cmd);
12061 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_out_cmd);
12062 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_out_cmd);
12063 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_out_cmd);
12064 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_out_cmd);
12065 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_out_cmd);
12066 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_out_cmd);
12067 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_out_cmd);
12068 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_out_cmd);
12069#ifdef HAVE_IPV6
12070 install_element (ENABLE_NODE, &clear_bgp_all_soft_out_cmd);
12071 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_out_cmd);
12072 install_element (ENABLE_NODE, &clear_bgp_all_out_cmd);
12073 install_element (ENABLE_NODE, &clear_bgp_peer_soft_out_cmd);
12074 install_element (ENABLE_NODE, &clear_bgp_peer_out_cmd);
12075 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_out_cmd);
12076 install_element (ENABLE_NODE, &clear_bgp_peer_group_out_cmd);
12077 install_element (ENABLE_NODE, &clear_bgp_external_soft_out_cmd);
12078 install_element (ENABLE_NODE, &clear_bgp_external_out_cmd);
12079 install_element (ENABLE_NODE, &clear_bgp_as_soft_out_cmd);
12080 install_element (ENABLE_NODE, &clear_bgp_as_out_cmd);
12081 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_out_cmd);
12082 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_out_cmd);
12083 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_out_cmd);
12084 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_out_cmd);
12085 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_out_cmd);
12086 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_out_cmd);
12087 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_out_cmd);
12088 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_out_cmd);
12089 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_out_cmd);
12090 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_out_cmd);
12091#endif /* HAVE_IPV6 */
12092
12093 /* "clear ip bgp neighbor soft" */
12094 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_cmd);
12095 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_cmd);
12096 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_cmd);
12097 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_cmd);
12098 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_cmd);
12099 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_cmd);
12100 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_cmd);
12101 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_cmd);
12102 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_cmd);
12103 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_cmd);
12104 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_cmd);
12105 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_cmd);
12106 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_cmd);
12107 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_cmd);
12108 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_cmd);
12109#ifdef HAVE_IPV6
12110 install_element (ENABLE_NODE, &clear_bgp_all_soft_cmd);
12111 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_cmd);
12112 install_element (ENABLE_NODE, &clear_bgp_peer_soft_cmd);
12113 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_cmd);
12114 install_element (ENABLE_NODE, &clear_bgp_external_soft_cmd);
12115 install_element (ENABLE_NODE, &clear_bgp_as_soft_cmd);
12116 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_cmd);
12117 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_cmd);
12118 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_cmd);
12119 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_cmd);
12120 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_cmd);
12121#endif /* HAVE_IPV6 */
12122
fee0f4c6 12123 /* "clear ip bgp neighbor rsclient" */
12124 install_element (ENABLE_NODE, &clear_ip_bgp_all_rsclient_cmd);
12125 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_rsclient_cmd);
12126 install_element (ENABLE_NODE, &clear_ip_bgp_peer_rsclient_cmd);
12127 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_rsclient_cmd);
12128#ifdef HAVE_IPV6
12129 install_element (ENABLE_NODE, &clear_bgp_all_rsclient_cmd);
12130 install_element (ENABLE_NODE, &clear_bgp_instance_all_rsclient_cmd);
12131 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_rsclient_cmd);
12132 install_element (ENABLE_NODE, &clear_bgp_ipv6_instance_all_rsclient_cmd);
12133 install_element (ENABLE_NODE, &clear_bgp_peer_rsclient_cmd);
12134 install_element (ENABLE_NODE, &clear_bgp_instance_peer_rsclient_cmd);
12135 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_rsclient_cmd);
12136 install_element (ENABLE_NODE, &clear_bgp_ipv6_instance_peer_rsclient_cmd);
12137#endif /* HAVE_IPV6 */
12138
718e3744 12139 /* "show ip bgp summary" commands. */
12140 install_element (VIEW_NODE, &show_ip_bgp_summary_cmd);
47fc97cc 12141 install_element (VIEW_NODE, &show_ip_bgp_summary_csv_cmd);
3f9c7369
DS
12142 install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd);
12143 install_element (VIEW_NODE, &show_bgp_updgrps_cmd);
12144 install_element (VIEW_NODE, &show_bgp_ipv6_updgrps_cmd);
12145 install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd);
12146 install_element (VIEW_NODE, &show_bgp_updgrps_adj_cmd);
12147 install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd);
12148 install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_subgroup_cmd);
12149 install_element (VIEW_NODE, &show_bgp_updgrps_adj_subgroup_cmd);
12150 install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_subgroup_cmd);
718e3744 12151 install_element (VIEW_NODE, &show_ip_bgp_instance_summary_cmd);
12152 install_element (VIEW_NODE, &show_ip_bgp_ipv4_summary_cmd);
95cbbd2a 12153 install_element (VIEW_NODE, &show_bgp_ipv4_safi_summary_cmd);
718e3744 12154 install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
95cbbd2a 12155 install_element (VIEW_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
718e3744 12156 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
12157 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
12158#ifdef HAVE_IPV6
12159 install_element (VIEW_NODE, &show_bgp_summary_cmd);
47fc97cc 12160 install_element (VIEW_NODE, &show_bgp_summary_csv_cmd);
718e3744 12161 install_element (VIEW_NODE, &show_bgp_instance_summary_cmd);
12162 install_element (VIEW_NODE, &show_bgp_ipv6_summary_cmd);
95cbbd2a 12163 install_element (VIEW_NODE, &show_bgp_ipv6_safi_summary_cmd);
718e3744 12164 install_element (VIEW_NODE, &show_bgp_instance_ipv6_summary_cmd);
95cbbd2a 12165 install_element (VIEW_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
62687ff1
PJ
12166#endif /* HAVE_IPV6 */
12167 install_element (RESTRICTED_NODE, &show_ip_bgp_summary_cmd);
47fc97cc 12168 install_element (RESTRICTED_NODE, &show_ip_bgp_summary_csv_cmd);
3f9c7369
DS
12169 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_cmd);
12170 install_element (RESTRICTED_NODE, &show_bgp_updgrps_cmd);
12171 install_element (RESTRICTED_NODE, &show_bgp_ipv6_updgrps_cmd);
12172 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_adj_cmd);
12173 install_element (RESTRICTED_NODE, &show_bgp_updgrps_adj_cmd);
12174 install_element (RESTRICTED_NODE, &show_bgp_updgrps_afi_adj_cmd);
12175 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_adj_subgroup_cmd);
12176 install_element (RESTRICTED_NODE, &show_bgp_updgrps_adj_subgroup_cmd);
12177 install_element (RESTRICTED_NODE, &show_bgp_updgrps_afi_adj_subgroup_cmd);
62687ff1
PJ
12178 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_summary_cmd);
12179 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_summary_cmd);
95cbbd2a 12180 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_summary_cmd);
62687ff1 12181 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
95cbbd2a 12182 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
62687ff1
PJ
12183 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
12184 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
12185#ifdef HAVE_IPV6
12186 install_element (RESTRICTED_NODE, &show_bgp_summary_cmd);
47fc97cc 12187 install_element (RESTRICTED_NODE, &show_bgp_summary_csv_cmd);
62687ff1
PJ
12188 install_element (RESTRICTED_NODE, &show_bgp_instance_summary_cmd);
12189 install_element (RESTRICTED_NODE, &show_bgp_ipv6_summary_cmd);
95cbbd2a 12190 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_summary_cmd);
62687ff1 12191 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_summary_cmd);
95cbbd2a 12192 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
718e3744 12193#endif /* HAVE_IPV6 */
12194 install_element (ENABLE_NODE, &show_ip_bgp_summary_cmd);
47fc97cc 12195 install_element (ENABLE_NODE, &show_ip_bgp_summary_csv_cmd);
3f9c7369
DS
12196 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_cmd);
12197 install_element (ENABLE_NODE, &show_bgp_updgrps_cmd);
12198 install_element (ENABLE_NODE, &show_bgp_ipv6_updgrps_cmd);
12199 install_element (ENABLE_NODE, &show_bgp_updgrps_stats_cmd);
12200 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_adj_cmd);
12201 install_element (ENABLE_NODE, &show_bgp_updgrps_adj_cmd);
12202 install_element (ENABLE_NODE, &show_bgp_updgrps_afi_adj_cmd);
12203 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_adj_subgroup_cmd);
12204 install_element (ENABLE_NODE, &show_bgp_updgrps_adj_subgroup_cmd);
12205 install_element (ENABLE_NODE, &show_bgp_updgrps_afi_adj_subgroup_cmd);
718e3744 12206 install_element (ENABLE_NODE, &show_ip_bgp_instance_summary_cmd);
12207 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_summary_cmd);
95cbbd2a 12208 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_summary_cmd);
718e3744 12209 install_element (ENABLE_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
95cbbd2a 12210 install_element (ENABLE_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
718e3744 12211 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
12212 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
12213#ifdef HAVE_IPV6
12214 install_element (ENABLE_NODE, &show_bgp_summary_cmd);
47fc97cc 12215 install_element (ENABLE_NODE, &show_bgp_summary_csv_cmd);
718e3744 12216 install_element (ENABLE_NODE, &show_bgp_instance_summary_cmd);
12217 install_element (ENABLE_NODE, &show_bgp_ipv6_summary_cmd);
95cbbd2a 12218 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_summary_cmd);
718e3744 12219 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_summary_cmd);
95cbbd2a 12220 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
718e3744 12221#endif /* HAVE_IPV6 */
12222
12223 /* "show ip bgp neighbors" commands. */
12224 install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd);
12225 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
12226 install_element (VIEW_NODE, &show_ip_bgp_neighbors_peer_cmd);
12227 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
12228 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd);
12229 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd);
12230 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
12231 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
12232 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_cmd);
12233 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
62687ff1
PJ
12234 install_element (RESTRICTED_NODE, &show_ip_bgp_neighbors_peer_cmd);
12235 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
12236 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
12237 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
12238 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
718e3744 12239 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_cmd);
12240 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
12241 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_peer_cmd);
12242 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
12243 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd);
12244 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd);
12245 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
12246 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
12247 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_cmd);
12248 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
12249
12250#ifdef HAVE_IPV6
12251 install_element (VIEW_NODE, &show_bgp_neighbors_cmd);
12252 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_cmd);
12253 install_element (VIEW_NODE, &show_bgp_neighbors_peer_cmd);
12254 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
bb46e94f 12255 install_element (VIEW_NODE, &show_bgp_instance_neighbors_cmd);
12256 install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
12257 install_element (VIEW_NODE, &show_bgp_instance_neighbors_peer_cmd);
12258 install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
62687ff1
PJ
12259 install_element (RESTRICTED_NODE, &show_bgp_neighbors_peer_cmd);
12260 install_element (RESTRICTED_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
12261 install_element (RESTRICTED_NODE, &show_bgp_instance_neighbors_peer_cmd);
12262 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
718e3744 12263 install_element (ENABLE_NODE, &show_bgp_neighbors_cmd);
12264 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_cmd);
12265 install_element (ENABLE_NODE, &show_bgp_neighbors_peer_cmd);
12266 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
bb46e94f 12267 install_element (ENABLE_NODE, &show_bgp_instance_neighbors_cmd);
12268 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
12269 install_element (ENABLE_NODE, &show_bgp_instance_neighbors_peer_cmd);
12270 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
718e3744 12271
12272 /* Old commands. */
12273 install_element (VIEW_NODE, &show_ipv6_bgp_summary_cmd);
12274 install_element (VIEW_NODE, &show_ipv6_mbgp_summary_cmd);
12275 install_element (ENABLE_NODE, &show_ipv6_bgp_summary_cmd);
12276 install_element (ENABLE_NODE, &show_ipv6_mbgp_summary_cmd);
12277#endif /* HAVE_IPV6 */
fee0f4c6 12278
f14e6fdb
DS
12279 /* "show ip bgp peer-group" commands. */
12280 install_element (VIEW_NODE, &show_ip_bgp_peer_groups_cmd);
12281 install_element (VIEW_NODE, &show_ip_bgp_instance_peer_groups_cmd);
12282 install_element (VIEW_NODE, &show_ip_bgp_peer_group_cmd);
12283 install_element (VIEW_NODE, &show_ip_bgp_instance_peer_group_cmd);
12284 install_element (ENABLE_NODE, &show_ip_bgp_peer_groups_cmd);
12285 install_element (ENABLE_NODE, &show_ip_bgp_instance_peer_groups_cmd);
12286 install_element (ENABLE_NODE, &show_ip_bgp_peer_group_cmd);
12287 install_element (ENABLE_NODE, &show_ip_bgp_instance_peer_group_cmd);
12288
fee0f4c6 12289 /* "show ip bgp rsclient" commands. */
12290 install_element (VIEW_NODE, &show_ip_bgp_rsclient_summary_cmd);
12291 install_element (VIEW_NODE, &show_ip_bgp_instance_rsclient_summary_cmd);
12292 install_element (VIEW_NODE, &show_ip_bgp_ipv4_rsclient_summary_cmd);
12293 install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_rsclient_summary_cmd);
95cbbd2a
ML
12294 install_element (VIEW_NODE, &show_bgp_instance_ipv4_safi_rsclient_summary_cmd);
12295 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_summary_cmd);
62687ff1
PJ
12296 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_summary_cmd);
12297 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_rsclient_summary_cmd);
12298 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_rsclient_summary_cmd);
12299 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_ipv4_rsclient_summary_cmd);
95cbbd2a
ML
12300 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv4_safi_rsclient_summary_cmd);
12301 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_summary_cmd);
fee0f4c6 12302 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_summary_cmd);
12303 install_element (ENABLE_NODE, &show_ip_bgp_instance_rsclient_summary_cmd);
12304 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_rsclient_summary_cmd);
12305 install_element (ENABLE_NODE, &show_ip_bgp_instance_ipv4_rsclient_summary_cmd);
95cbbd2a
ML
12306 install_element (ENABLE_NODE, &show_bgp_instance_ipv4_safi_rsclient_summary_cmd);
12307 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_summary_cmd);
fee0f4c6 12308
12309#ifdef HAVE_IPV6
12310 install_element (VIEW_NODE, &show_bgp_rsclient_summary_cmd);
12311 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_summary_cmd);
12312 install_element (VIEW_NODE, &show_bgp_instance_rsclient_summary_cmd);
12313 install_element (VIEW_NODE, &show_bgp_instance_ipv6_rsclient_summary_cmd);
95cbbd2a
ML
12314 install_element (VIEW_NODE, &show_bgp_instance_ipv6_safi_rsclient_summary_cmd);
12315 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_summary_cmd);
62687ff1
PJ
12316 install_element (RESTRICTED_NODE, &show_bgp_rsclient_summary_cmd);
12317 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_summary_cmd);
12318 install_element (RESTRICTED_NODE, &show_bgp_instance_rsclient_summary_cmd);
12319 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_rsclient_summary_cmd);
95cbbd2a
ML
12320 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_safi_rsclient_summary_cmd);
12321 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_summary_cmd);
fee0f4c6 12322 install_element (ENABLE_NODE, &show_bgp_rsclient_summary_cmd);
12323 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_summary_cmd);
12324 install_element (ENABLE_NODE, &show_bgp_instance_rsclient_summary_cmd);
12325 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_rsclient_summary_cmd);
95cbbd2a
ML
12326 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_safi_rsclient_summary_cmd);
12327 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_summary_cmd);
fee0f4c6 12328#endif /* HAVE_IPV6 */
718e3744 12329
12330 /* "show ip bgp paths" commands. */
12331 install_element (VIEW_NODE, &show_ip_bgp_paths_cmd);
12332 install_element (VIEW_NODE, &show_ip_bgp_ipv4_paths_cmd);
12333 install_element (ENABLE_NODE, &show_ip_bgp_paths_cmd);
12334 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_paths_cmd);
12335
12336 /* "show ip bgp community" commands. */
12337 install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd);
12338 install_element (ENABLE_NODE, &show_ip_bgp_community_info_cmd);
12339
12340 /* "show ip bgp attribute-info" commands. */
12341 install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd);
12342 install_element (ENABLE_NODE, &show_ip_bgp_attr_info_cmd);
12343
12344 /* "redistribute" commands. */
12345 install_element (BGP_NODE, &bgp_redistribute_ipv4_cmd);
12346 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_cmd);
12347 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_cmd);
12348 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_cmd);
12349 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_cmd);
12350 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_cmd);
12351 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd);
12352 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd);
12353 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_metric_cmd);
12354 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_rmap_cmd);
7c8ff89e
DS
12355 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_cmd);
12356 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_cmd);
12357 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd);
12358 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_cmd);
12359 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd);
12360 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_metric_cmd);
12361 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
12362 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
12363 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
12364 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
718e3744 12365#ifdef HAVE_IPV6
12366 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd);
12367 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd);
12368 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd);
12369 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_cmd);
12370 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd);
12371 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_cmd);
12372 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd);
12373 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd);
12374 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_metric_cmd);
12375 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_rmap_cmd);
12376#endif /* HAVE_IPV6 */
12377
fa411a21
NH
12378 /* ttl_security commands */
12379 install_element (BGP_NODE, &neighbor_ttl_security_cmd);
12380 install_element (BGP_NODE, &no_neighbor_ttl_security_cmd);
12381
4bf6a362
PJ
12382 /* "show bgp memory" commands. */
12383 install_element (VIEW_NODE, &show_bgp_memory_cmd);
62687ff1 12384 install_element (RESTRICTED_NODE, &show_bgp_memory_cmd);
4bf6a362
PJ
12385 install_element (ENABLE_NODE, &show_bgp_memory_cmd);
12386
e0081f70
ML
12387 /* "show bgp views" commands. */
12388 install_element (VIEW_NODE, &show_bgp_views_cmd);
12389 install_element (RESTRICTED_NODE, &show_bgp_views_cmd);
12390 install_element (ENABLE_NODE, &show_bgp_views_cmd);
12391
718e3744 12392 /* Community-list. */
12393 community_list_vty ();
12394}
6b0655a2 12395
718e3744 12396#include "memory.h"
12397#include "bgp_regex.h"
12398#include "bgp_clist.h"
12399#include "bgp_ecommunity.h"
12400
12401/* VTY functions. */
12402
12403/* Direction value to string conversion. */
94f2b392 12404static const char *
718e3744 12405community_direct_str (int direct)
12406{
12407 switch (direct)
12408 {
12409 case COMMUNITY_DENY:
12410 return "deny";
718e3744 12411 case COMMUNITY_PERMIT:
12412 return "permit";
718e3744 12413 default:
12414 return "unknown";
718e3744 12415 }
12416}
12417
12418/* Display error string. */
94f2b392 12419static void
718e3744 12420community_list_perror (struct vty *vty, int ret)
12421{
12422 switch (ret)
12423 {
12424 case COMMUNITY_LIST_ERR_CANT_FIND_LIST:
b729294c 12425 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
718e3744 12426 break;
12427 case COMMUNITY_LIST_ERR_MALFORMED_VAL:
12428 vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE);
12429 break;
12430 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT:
12431 vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE);
12432 break;
12433 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT:
12434 vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE);
12435 break;
12436 }
12437}
12438
12439/* VTY interface for community_set() function. */
94f2b392 12440static int
fd79ac91 12441community_list_set_vty (struct vty *vty, int argc, const char **argv,
12442 int style, int reject_all_digit_name)
718e3744 12443{
12444 int ret;
12445 int direct;
12446 char *str;
12447
12448 /* Check the list type. */
12449 if (strncmp (argv[1], "p", 1) == 0)
12450 direct = COMMUNITY_PERMIT;
12451 else if (strncmp (argv[1], "d", 1) == 0)
12452 direct = COMMUNITY_DENY;
12453 else
12454 {
12455 vty_out (vty, "%% Matching condition must be permit or deny%s",
12456 VTY_NEWLINE);
12457 return CMD_WARNING;
12458 }
12459
12460 /* All digit name check. */
12461 if (reject_all_digit_name && all_digit (argv[0]))
12462 {
12463 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
12464 return CMD_WARNING;
12465 }
12466
12467 /* Concat community string argument. */
12468 if (argc > 1)
12469 str = argv_concat (argv, argc, 2);
12470 else
12471 str = NULL;
12472
12473 /* When community_list_set() return nevetive value, it means
12474 malformed community string. */
12475 ret = community_list_set (bgp_clist, argv[0], str, direct, style);
12476
12477 /* Free temporary community list string allocated by
12478 argv_concat(). */
12479 if (str)
12480 XFREE (MTYPE_TMP, str);
12481
12482 if (ret < 0)
12483 {
12484 /* Display error string. */
12485 community_list_perror (vty, ret);
12486 return CMD_WARNING;
12487 }
12488
12489 return CMD_SUCCESS;
12490}
12491
718e3744 12492/* Communiyt-list entry delete. */
94f2b392 12493static int
fee6e4e4 12494community_list_unset_vty (struct vty *vty, int argc, const char **argv,
12495 int style)
718e3744 12496{
12497 int ret;
fee6e4e4 12498 int direct = 0;
12499 char *str = NULL;
718e3744 12500
fee6e4e4 12501 if (argc > 1)
718e3744 12502 {
fee6e4e4 12503 /* Check the list direct. */
12504 if (strncmp (argv[1], "p", 1) == 0)
12505 direct = COMMUNITY_PERMIT;
12506 else if (strncmp (argv[1], "d", 1) == 0)
12507 direct = COMMUNITY_DENY;
12508 else
12509 {
12510 vty_out (vty, "%% Matching condition must be permit or deny%s",
12511 VTY_NEWLINE);
12512 return CMD_WARNING;
12513 }
718e3744 12514
fee6e4e4 12515 /* Concat community string argument. */
12516 str = argv_concat (argv, argc, 2);
12517 }
718e3744 12518
12519 /* Unset community list. */
12520 ret = community_list_unset (bgp_clist, argv[0], str, direct, style);
12521
12522 /* Free temporary community list string allocated by
12523 argv_concat(). */
fee6e4e4 12524 if (str)
12525 XFREE (MTYPE_TMP, str);
718e3744 12526
12527 if (ret < 0)
12528 {
12529 community_list_perror (vty, ret);
12530 return CMD_WARNING;
12531 }
12532
12533 return CMD_SUCCESS;
12534}
12535
12536/* "community-list" keyword help string. */
12537#define COMMUNITY_LIST_STR "Add a community list entry\n"
12538#define COMMUNITY_VAL_STR "Community number in aa:nn format or internet|local-AS|no-advertise|no-export\n"
12539
718e3744 12540DEFUN (ip_community_list_standard,
12541 ip_community_list_standard_cmd,
12542 "ip community-list <1-99> (deny|permit) .AA:NN",
12543 IP_STR
12544 COMMUNITY_LIST_STR
12545 "Community list number (standard)\n"
12546 "Specify community to reject\n"
12547 "Specify community to accept\n"
12548 COMMUNITY_VAL_STR)
12549{
12550 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
12551}
12552
12553ALIAS (ip_community_list_standard,
12554 ip_community_list_standard2_cmd,
12555 "ip community-list <1-99> (deny|permit)",
12556 IP_STR
12557 COMMUNITY_LIST_STR
12558 "Community list number (standard)\n"
12559 "Specify community to reject\n"
12560 "Specify community to accept\n")
12561
12562DEFUN (ip_community_list_expanded,
12563 ip_community_list_expanded_cmd,
fee6e4e4 12564 "ip community-list <100-500> (deny|permit) .LINE",
718e3744 12565 IP_STR
12566 COMMUNITY_LIST_STR
12567 "Community list number (expanded)\n"
12568 "Specify community to reject\n"
12569 "Specify community to accept\n"
12570 "An ordered list as a regular-expression\n")
12571{
12572 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
12573}
12574
12575DEFUN (ip_community_list_name_standard,
12576 ip_community_list_name_standard_cmd,
12577 "ip community-list standard WORD (deny|permit) .AA:NN",
12578 IP_STR
12579 COMMUNITY_LIST_STR
12580 "Add a standard community-list entry\n"
12581 "Community list name\n"
12582 "Specify community to reject\n"
12583 "Specify community to accept\n"
12584 COMMUNITY_VAL_STR)
12585{
12586 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
12587}
12588
12589ALIAS (ip_community_list_name_standard,
12590 ip_community_list_name_standard2_cmd,
12591 "ip community-list standard WORD (deny|permit)",
12592 IP_STR
12593 COMMUNITY_LIST_STR
12594 "Add a standard community-list entry\n"
12595 "Community list name\n"
12596 "Specify community to reject\n"
12597 "Specify community to accept\n")
12598
12599DEFUN (ip_community_list_name_expanded,
12600 ip_community_list_name_expanded_cmd,
12601 "ip community-list expanded WORD (deny|permit) .LINE",
12602 IP_STR
12603 COMMUNITY_LIST_STR
12604 "Add an expanded community-list entry\n"
12605 "Community list name\n"
12606 "Specify community to reject\n"
12607 "Specify community to accept\n"
12608 "An ordered list as a regular-expression\n")
12609{
12610 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
12611}
12612
fee6e4e4 12613DEFUN (no_ip_community_list_standard_all,
12614 no_ip_community_list_standard_all_cmd,
12615 "no ip community-list <1-99>",
12616 NO_STR
12617 IP_STR
12618 COMMUNITY_LIST_STR
12619 "Community list number (standard)\n")
12620{
12621 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
12622}
12623
12624DEFUN (no_ip_community_list_expanded_all,
12625 no_ip_community_list_expanded_all_cmd,
12626 "no ip community-list <100-500>",
718e3744 12627 NO_STR
12628 IP_STR
12629 COMMUNITY_LIST_STR
718e3744 12630 "Community list number (expanded)\n")
12631{
fee6e4e4 12632 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
718e3744 12633}
12634
fee6e4e4 12635DEFUN (no_ip_community_list_name_standard_all,
12636 no_ip_community_list_name_standard_all_cmd,
12637 "no ip community-list standard WORD",
718e3744 12638 NO_STR
12639 IP_STR
12640 COMMUNITY_LIST_STR
12641 "Add a standard community-list entry\n"
718e3744 12642 "Community list name\n")
12643{
fee6e4e4 12644 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
718e3744 12645}
12646
fee6e4e4 12647DEFUN (no_ip_community_list_name_expanded_all,
12648 no_ip_community_list_name_expanded_all_cmd,
12649 "no ip community-list expanded WORD",
718e3744 12650 NO_STR
12651 IP_STR
12652 COMMUNITY_LIST_STR
fee6e4e4 12653 "Add an expanded community-list entry\n"
12654 "Community list name\n")
718e3744 12655{
fee6e4e4 12656 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
718e3744 12657}
12658
12659DEFUN (no_ip_community_list_standard,
12660 no_ip_community_list_standard_cmd,
12661 "no ip community-list <1-99> (deny|permit) .AA:NN",
12662 NO_STR
12663 IP_STR
12664 COMMUNITY_LIST_STR
12665 "Community list number (standard)\n"
12666 "Specify community to reject\n"
12667 "Specify community to accept\n"
12668 COMMUNITY_VAL_STR)
12669{
12670 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
12671}
12672
12673DEFUN (no_ip_community_list_expanded,
12674 no_ip_community_list_expanded_cmd,
fee6e4e4 12675 "no ip community-list <100-500> (deny|permit) .LINE",
718e3744 12676 NO_STR
12677 IP_STR
12678 COMMUNITY_LIST_STR
12679 "Community list number (expanded)\n"
12680 "Specify community to reject\n"
12681 "Specify community to accept\n"
12682 "An ordered list as a regular-expression\n")
12683{
12684 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
12685}
12686
12687DEFUN (no_ip_community_list_name_standard,
12688 no_ip_community_list_name_standard_cmd,
12689 "no ip community-list standard WORD (deny|permit) .AA:NN",
12690 NO_STR
12691 IP_STR
12692 COMMUNITY_LIST_STR
12693 "Specify a standard community-list\n"
12694 "Community list name\n"
12695 "Specify community to reject\n"
12696 "Specify community to accept\n"
12697 COMMUNITY_VAL_STR)
12698{
12699 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
12700}
12701
12702DEFUN (no_ip_community_list_name_expanded,
12703 no_ip_community_list_name_expanded_cmd,
12704 "no ip community-list expanded WORD (deny|permit) .LINE",
12705 NO_STR
12706 IP_STR
12707 COMMUNITY_LIST_STR
12708 "Specify an expanded community-list\n"
12709 "Community list name\n"
12710 "Specify community to reject\n"
12711 "Specify community to accept\n"
12712 "An ordered list as a regular-expression\n")
12713{
12714 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
12715}
12716
94f2b392 12717static void
718e3744 12718community_list_show (struct vty *vty, struct community_list *list)
12719{
12720 struct community_entry *entry;
12721
12722 for (entry = list->head; entry; entry = entry->next)
12723 {
12724 if (entry == list->head)
12725 {
12726 if (all_digit (list->name))
12727 vty_out (vty, "Community %s list %s%s",
12728 entry->style == COMMUNITY_LIST_STANDARD ?
12729 "standard" : "(expanded) access",
12730 list->name, VTY_NEWLINE);
12731 else
12732 vty_out (vty, "Named Community %s list %s%s",
12733 entry->style == COMMUNITY_LIST_STANDARD ?
12734 "standard" : "expanded",
12735 list->name, VTY_NEWLINE);
12736 }
12737 if (entry->any)
12738 vty_out (vty, " %s%s",
12739 community_direct_str (entry->direct), VTY_NEWLINE);
12740 else
12741 vty_out (vty, " %s %s%s",
12742 community_direct_str (entry->direct),
12743 entry->style == COMMUNITY_LIST_STANDARD
12744 ? community_str (entry->u.com) : entry->config,
12745 VTY_NEWLINE);
12746 }
12747}
12748
12749DEFUN (show_ip_community_list,
12750 show_ip_community_list_cmd,
12751 "show ip community-list",
12752 SHOW_STR
12753 IP_STR
12754 "List community-list\n")
12755{
12756 struct community_list *list;
12757 struct community_list_master *cm;
12758
fee6e4e4 12759 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
718e3744 12760 if (! cm)
12761 return CMD_SUCCESS;
12762
12763 for (list = cm->num.head; list; list = list->next)
12764 community_list_show (vty, list);
12765
12766 for (list = cm->str.head; list; list = list->next)
12767 community_list_show (vty, list);
12768
12769 return CMD_SUCCESS;
12770}
12771
12772DEFUN (show_ip_community_list_arg,
12773 show_ip_community_list_arg_cmd,
fee6e4e4 12774 "show ip community-list (<1-500>|WORD)",
718e3744 12775 SHOW_STR
12776 IP_STR
12777 "List community-list\n"
12778 "Community-list number\n"
12779 "Community-list name\n")
12780{
12781 struct community_list *list;
12782
fee6e4e4 12783 list = community_list_lookup (bgp_clist, argv[0], COMMUNITY_LIST_MASTER);
718e3744 12784 if (! list)
12785 {
b729294c 12786 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
718e3744 12787 return CMD_WARNING;
12788 }
12789
12790 community_list_show (vty, list);
12791
12792 return CMD_SUCCESS;
12793}
6b0655a2 12794
94f2b392 12795static int
fd79ac91 12796extcommunity_list_set_vty (struct vty *vty, int argc, const char **argv,
12797 int style, int reject_all_digit_name)
718e3744 12798{
12799 int ret;
12800 int direct;
12801 char *str;
12802
12803 /* Check the list type. */
12804 if (strncmp (argv[1], "p", 1) == 0)
12805 direct = COMMUNITY_PERMIT;
12806 else if (strncmp (argv[1], "d", 1) == 0)
12807 direct = COMMUNITY_DENY;
12808 else
12809 {
12810 vty_out (vty, "%% Matching condition must be permit or deny%s",
12811 VTY_NEWLINE);
12812 return CMD_WARNING;
12813 }
12814
12815 /* All digit name check. */
12816 if (reject_all_digit_name && all_digit (argv[0]))
12817 {
12818 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
12819 return CMD_WARNING;
12820 }
12821
12822 /* Concat community string argument. */
12823 if (argc > 1)
12824 str = argv_concat (argv, argc, 2);
12825 else
12826 str = NULL;
12827
12828 ret = extcommunity_list_set (bgp_clist, argv[0], str, direct, style);
12829
12830 /* Free temporary community list string allocated by
12831 argv_concat(). */
12832 if (str)
12833 XFREE (MTYPE_TMP, str);
12834
12835 if (ret < 0)
12836 {
12837 community_list_perror (vty, ret);
12838 return CMD_WARNING;
12839 }
12840 return CMD_SUCCESS;
12841}
12842
94f2b392 12843static int
fee6e4e4 12844extcommunity_list_unset_vty (struct vty *vty, int argc, const char **argv,
12845 int style)
718e3744 12846{
12847 int ret;
fee6e4e4 12848 int direct = 0;
12849 char *str = NULL;
718e3744 12850
fee6e4e4 12851 if (argc > 1)
718e3744 12852 {
fee6e4e4 12853 /* Check the list direct. */
12854 if (strncmp (argv[1], "p", 1) == 0)
12855 direct = COMMUNITY_PERMIT;
12856 else if (strncmp (argv[1], "d", 1) == 0)
12857 direct = COMMUNITY_DENY;
12858 else
12859 {
12860 vty_out (vty, "%% Matching condition must be permit or deny%s",
12861 VTY_NEWLINE);
12862 return CMD_WARNING;
12863 }
718e3744 12864
fee6e4e4 12865 /* Concat community string argument. */
12866 str = argv_concat (argv, argc, 2);
718e3744 12867 }
12868
718e3744 12869 /* Unset community list. */
12870 ret = extcommunity_list_unset (bgp_clist, argv[0], str, direct, style);
12871
12872 /* Free temporary community list string allocated by
12873 argv_concat(). */
fee6e4e4 12874 if (str)
12875 XFREE (MTYPE_TMP, str);
718e3744 12876
12877 if (ret < 0)
12878 {
12879 community_list_perror (vty, ret);
12880 return CMD_WARNING;
12881 }
12882
12883 return CMD_SUCCESS;
12884}
12885
12886/* "extcommunity-list" keyword help string. */
12887#define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
12888#define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
12889
12890DEFUN (ip_extcommunity_list_standard,
12891 ip_extcommunity_list_standard_cmd,
12892 "ip extcommunity-list <1-99> (deny|permit) .AA:NN",
12893 IP_STR
12894 EXTCOMMUNITY_LIST_STR
12895 "Extended Community list number (standard)\n"
12896 "Specify community to reject\n"
12897 "Specify community to accept\n"
12898 EXTCOMMUNITY_VAL_STR)
12899{
12900 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
12901}
12902
12903ALIAS (ip_extcommunity_list_standard,
12904 ip_extcommunity_list_standard2_cmd,
12905 "ip extcommunity-list <1-99> (deny|permit)",
12906 IP_STR
12907 EXTCOMMUNITY_LIST_STR
12908 "Extended Community list number (standard)\n"
12909 "Specify community to reject\n"
12910 "Specify community to accept\n")
12911
12912DEFUN (ip_extcommunity_list_expanded,
12913 ip_extcommunity_list_expanded_cmd,
fee6e4e4 12914 "ip extcommunity-list <100-500> (deny|permit) .LINE",
718e3744 12915 IP_STR
12916 EXTCOMMUNITY_LIST_STR
12917 "Extended Community list number (expanded)\n"
12918 "Specify community to reject\n"
12919 "Specify community to accept\n"
12920 "An ordered list as a regular-expression\n")
12921{
12922 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
12923}
12924
12925DEFUN (ip_extcommunity_list_name_standard,
12926 ip_extcommunity_list_name_standard_cmd,
12927 "ip extcommunity-list standard WORD (deny|permit) .AA:NN",
12928 IP_STR
12929 EXTCOMMUNITY_LIST_STR
12930 "Specify standard extcommunity-list\n"
12931 "Extended Community list name\n"
12932 "Specify community to reject\n"
12933 "Specify community to accept\n"
12934 EXTCOMMUNITY_VAL_STR)
12935{
12936 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
12937}
12938
12939ALIAS (ip_extcommunity_list_name_standard,
12940 ip_extcommunity_list_name_standard2_cmd,
12941 "ip extcommunity-list standard WORD (deny|permit)",
12942 IP_STR
12943 EXTCOMMUNITY_LIST_STR
12944 "Specify standard extcommunity-list\n"
12945 "Extended Community list name\n"
12946 "Specify community to reject\n"
12947 "Specify community to accept\n")
12948
12949DEFUN (ip_extcommunity_list_name_expanded,
12950 ip_extcommunity_list_name_expanded_cmd,
12951 "ip extcommunity-list expanded WORD (deny|permit) .LINE",
12952 IP_STR
12953 EXTCOMMUNITY_LIST_STR
12954 "Specify expanded extcommunity-list\n"
12955 "Extended Community list name\n"
12956 "Specify community to reject\n"
12957 "Specify community to accept\n"
12958 "An ordered list as a regular-expression\n")
12959{
12960 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
12961}
12962
fee6e4e4 12963DEFUN (no_ip_extcommunity_list_standard_all,
12964 no_ip_extcommunity_list_standard_all_cmd,
12965 "no ip extcommunity-list <1-99>",
12966 NO_STR
12967 IP_STR
12968 EXTCOMMUNITY_LIST_STR
12969 "Extended Community list number (standard)\n")
12970{
12971 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
12972}
12973
12974DEFUN (no_ip_extcommunity_list_expanded_all,
12975 no_ip_extcommunity_list_expanded_all_cmd,
12976 "no ip extcommunity-list <100-500>",
718e3744 12977 NO_STR
12978 IP_STR
12979 EXTCOMMUNITY_LIST_STR
718e3744 12980 "Extended Community list number (expanded)\n")
12981{
fee6e4e4 12982 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
718e3744 12983}
12984
fee6e4e4 12985DEFUN (no_ip_extcommunity_list_name_standard_all,
12986 no_ip_extcommunity_list_name_standard_all_cmd,
12987 "no ip extcommunity-list standard WORD",
718e3744 12988 NO_STR
12989 IP_STR
12990 EXTCOMMUNITY_LIST_STR
12991 "Specify standard extcommunity-list\n"
fee6e4e4 12992 "Extended Community list name\n")
12993{
12994 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
12995}
12996
12997DEFUN (no_ip_extcommunity_list_name_expanded_all,
12998 no_ip_extcommunity_list_name_expanded_all_cmd,
12999 "no ip extcommunity-list expanded WORD",
13000 NO_STR
13001 IP_STR
13002 EXTCOMMUNITY_LIST_STR
718e3744 13003 "Specify expanded extcommunity-list\n"
13004 "Extended Community list name\n")
13005{
fee6e4e4 13006 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
718e3744 13007}
13008
13009DEFUN (no_ip_extcommunity_list_standard,
13010 no_ip_extcommunity_list_standard_cmd,
13011 "no ip extcommunity-list <1-99> (deny|permit) .AA:NN",
13012 NO_STR
13013 IP_STR
13014 EXTCOMMUNITY_LIST_STR
13015 "Extended Community list number (standard)\n"
13016 "Specify community to reject\n"
13017 "Specify community to accept\n"
13018 EXTCOMMUNITY_VAL_STR)
13019{
13020 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
13021}
13022
13023DEFUN (no_ip_extcommunity_list_expanded,
13024 no_ip_extcommunity_list_expanded_cmd,
fee6e4e4 13025 "no ip extcommunity-list <100-500> (deny|permit) .LINE",
718e3744 13026 NO_STR
13027 IP_STR
13028 EXTCOMMUNITY_LIST_STR
13029 "Extended Community list number (expanded)\n"
13030 "Specify community to reject\n"
13031 "Specify community to accept\n"
13032 "An ordered list as a regular-expression\n")
13033{
13034 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
13035}
13036
13037DEFUN (no_ip_extcommunity_list_name_standard,
13038 no_ip_extcommunity_list_name_standard_cmd,
13039 "no ip extcommunity-list standard WORD (deny|permit) .AA:NN",
13040 NO_STR
13041 IP_STR
13042 EXTCOMMUNITY_LIST_STR
13043 "Specify standard extcommunity-list\n"
13044 "Extended Community list name\n"
13045 "Specify community to reject\n"
13046 "Specify community to accept\n"
13047 EXTCOMMUNITY_VAL_STR)
13048{
13049 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
13050}
13051
13052DEFUN (no_ip_extcommunity_list_name_expanded,
13053 no_ip_extcommunity_list_name_expanded_cmd,
13054 "no ip extcommunity-list expanded WORD (deny|permit) .LINE",
13055 NO_STR
13056 IP_STR
13057 EXTCOMMUNITY_LIST_STR
13058 "Specify expanded extcommunity-list\n"
13059 "Community list name\n"
13060 "Specify community to reject\n"
13061 "Specify community to accept\n"
13062 "An ordered list as a regular-expression\n")
13063{
13064 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
13065}
13066
94f2b392 13067static void
718e3744 13068extcommunity_list_show (struct vty *vty, struct community_list *list)
13069{
13070 struct community_entry *entry;
13071
13072 for (entry = list->head; entry; entry = entry->next)
13073 {
13074 if (entry == list->head)
13075 {
13076 if (all_digit (list->name))
13077 vty_out (vty, "Extended community %s list %s%s",
13078 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
13079 "standard" : "(expanded) access",
13080 list->name, VTY_NEWLINE);
13081 else
13082 vty_out (vty, "Named extended community %s list %s%s",
13083 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
13084 "standard" : "expanded",
13085 list->name, VTY_NEWLINE);
13086 }
13087 if (entry->any)
13088 vty_out (vty, " %s%s",
13089 community_direct_str (entry->direct), VTY_NEWLINE);
13090 else
13091 vty_out (vty, " %s %s%s",
13092 community_direct_str (entry->direct),
13093 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
13094 entry->u.ecom->str : entry->config,
13095 VTY_NEWLINE);
13096 }
13097}
13098
13099DEFUN (show_ip_extcommunity_list,
13100 show_ip_extcommunity_list_cmd,
13101 "show ip extcommunity-list",
13102 SHOW_STR
13103 IP_STR
13104 "List extended-community list\n")
13105{
13106 struct community_list *list;
13107 struct community_list_master *cm;
13108
fee6e4e4 13109 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
718e3744 13110 if (! cm)
13111 return CMD_SUCCESS;
13112
13113 for (list = cm->num.head; list; list = list->next)
13114 extcommunity_list_show (vty, list);
13115
13116 for (list = cm->str.head; list; list = list->next)
13117 extcommunity_list_show (vty, list);
13118
13119 return CMD_SUCCESS;
13120}
13121
13122DEFUN (show_ip_extcommunity_list_arg,
13123 show_ip_extcommunity_list_arg_cmd,
fee6e4e4 13124 "show ip extcommunity-list (<1-500>|WORD)",
718e3744 13125 SHOW_STR
13126 IP_STR
13127 "List extended-community list\n"
13128 "Extcommunity-list number\n"
13129 "Extcommunity-list name\n")
13130{
13131 struct community_list *list;
13132
fee6e4e4 13133 list = community_list_lookup (bgp_clist, argv[0], EXTCOMMUNITY_LIST_MASTER);
718e3744 13134 if (! list)
13135 {
b729294c 13136 vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE);
718e3744 13137 return CMD_WARNING;
13138 }
13139
13140 extcommunity_list_show (vty, list);
13141
13142 return CMD_SUCCESS;
13143}
6b0655a2 13144
718e3744 13145/* Return configuration string of community-list entry. */
fd79ac91 13146static const char *
718e3744 13147community_list_config_str (struct community_entry *entry)
13148{
fd79ac91 13149 const char *str;
718e3744 13150
13151 if (entry->any)
13152 str = "";
13153 else
13154 {
13155 if (entry->style == COMMUNITY_LIST_STANDARD)
13156 str = community_str (entry->u.com);
13157 else
13158 str = entry->config;
13159 }
13160 return str;
13161}
13162
13163/* Display community-list and extcommunity-list configuration. */
94f2b392 13164static int
718e3744 13165community_list_config_write (struct vty *vty)
13166{
13167 struct community_list *list;
13168 struct community_entry *entry;
13169 struct community_list_master *cm;
13170 int write = 0;
13171
13172 /* Community-list. */
fee6e4e4 13173 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
718e3744 13174
13175 for (list = cm->num.head; list; list = list->next)
13176 for (entry = list->head; entry; entry = entry->next)
13177 {
fee6e4e4 13178 vty_out (vty, "ip community-list %s %s %s%s",
13179 list->name, community_direct_str (entry->direct),
13180 community_list_config_str (entry),
13181 VTY_NEWLINE);
718e3744 13182 write++;
13183 }
13184 for (list = cm->str.head; list; list = list->next)
13185 for (entry = list->head; entry; entry = entry->next)
13186 {
13187 vty_out (vty, "ip community-list %s %s %s %s%s",
13188 entry->style == COMMUNITY_LIST_STANDARD
13189 ? "standard" : "expanded",
13190 list->name, community_direct_str (entry->direct),
13191 community_list_config_str (entry),
13192 VTY_NEWLINE);
13193 write++;
13194 }
13195
13196 /* Extcommunity-list. */
fee6e4e4 13197 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
718e3744 13198
13199 for (list = cm->num.head; list; list = list->next)
13200 for (entry = list->head; entry; entry = entry->next)
13201 {
fee6e4e4 13202 vty_out (vty, "ip extcommunity-list %s %s %s%s",
13203 list->name, community_direct_str (entry->direct),
13204 community_list_config_str (entry), VTY_NEWLINE);
718e3744 13205 write++;
13206 }
13207 for (list = cm->str.head; list; list = list->next)
13208 for (entry = list->head; entry; entry = entry->next)
13209 {
13210 vty_out (vty, "ip extcommunity-list %s %s %s %s%s",
13211 entry->style == EXTCOMMUNITY_LIST_STANDARD
13212 ? "standard" : "expanded",
13213 list->name, community_direct_str (entry->direct),
13214 community_list_config_str (entry), VTY_NEWLINE);
13215 write++;
13216 }
13217 return write;
13218}
13219
7fc626de 13220static struct cmd_node community_list_node =
718e3744 13221{
13222 COMMUNITY_LIST_NODE,
13223 "",
13224 1 /* Export to vtysh. */
13225};
13226
94f2b392 13227static void
13228community_list_vty (void)
718e3744 13229{
13230 install_node (&community_list_node, community_list_config_write);
13231
13232 /* Community-list. */
718e3744 13233 install_element (CONFIG_NODE, &ip_community_list_standard_cmd);
13234 install_element (CONFIG_NODE, &ip_community_list_standard2_cmd);
13235 install_element (CONFIG_NODE, &ip_community_list_expanded_cmd);
13236 install_element (CONFIG_NODE, &ip_community_list_name_standard_cmd);
13237 install_element (CONFIG_NODE, &ip_community_list_name_standard2_cmd);
13238 install_element (CONFIG_NODE, &ip_community_list_name_expanded_cmd);
fee6e4e4 13239 install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd);
13240 install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd);
13241 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_all_cmd);
13242 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_all_cmd);
718e3744 13243 install_element (CONFIG_NODE, &no_ip_community_list_standard_cmd);
13244 install_element (CONFIG_NODE, &no_ip_community_list_expanded_cmd);
13245 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_cmd);
13246 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_cmd);
13247 install_element (VIEW_NODE, &show_ip_community_list_cmd);
13248 install_element (VIEW_NODE, &show_ip_community_list_arg_cmd);
13249 install_element (ENABLE_NODE, &show_ip_community_list_cmd);
13250 install_element (ENABLE_NODE, &show_ip_community_list_arg_cmd);
13251
13252 /* Extcommunity-list. */
13253 install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd);
13254 install_element (CONFIG_NODE, &ip_extcommunity_list_standard2_cmd);
13255 install_element (CONFIG_NODE, &ip_extcommunity_list_expanded_cmd);
13256 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard_cmd);
13257 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard2_cmd);
13258 install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd);
fee6e4e4 13259 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd);
13260 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd);
13261 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_all_cmd);
13262 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_all_cmd);
718e3744 13263 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_cmd);
13264 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_cmd);
13265 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_cmd);
13266 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_cmd);
13267 install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd);
13268 install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd);
13269 install_element (ENABLE_NODE, &show_ip_extcommunity_list_cmd);
13270 install_element (ENABLE_NODE, &show_ip_extcommunity_list_arg_cmd);
13271}