blob: c1bae93ef9f600ee317823f2a2b4a8ddca7fba19 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* 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"
31
32#include "bgpd/bgpd.h"
33#include "bgpd/bgp_attr.h"
34#include "bgpd/bgp_aspath.h"
35#include "bgpd/bgp_community.h"
36#include "bgpd/bgp_debug.h"
37#include "bgpd/bgp_mplsvpn.h"
38#include "bgpd/bgp_open.h"
39#include "bgpd/bgp_route.h"
40#include "bgpd/bgp_zebra.h"
41
42/* Utility function to get address family from current node. */
43afi_t
44bgp_node_afi (struct vty *vty)
45{
46 if (vty->node == BGP_IPV6_NODE)
47 return AFI_IP6;
48 return AFI_IP;
49}
50
51/* Utility function to get subsequent address family from current
52 node. */
53safi_t
54bgp_node_safi (struct vty *vty)
55{
56 if (vty->node == BGP_VPNV4_NODE)
57 return SAFI_MPLS_VPN;
58 if (vty->node == BGP_IPV4M_NODE)
59 return SAFI_MULTICAST;
60 return SAFI_UNICAST;
61}
62
63int
64peer_address_self_check (union sockunion *su)
65{
66 struct interface *ifp = NULL;
67
68 if (su->sa.sa_family == AF_INET)
69 ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr);
70#ifdef HAVE_IPV6
71 else if (su->sa.sa_family == AF_INET6)
72 ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr);
73#endif /* HAVE IPV6 */
74
75 if (ifp)
76 return 1;
77
78 return 0;
79}
80
81/* Utility function for looking up peer from VTY. */
82struct peer *
83peer_lookup_vty (struct vty *vty, char *ip_str)
84{
85 int ret;
86 struct bgp *bgp;
87 union sockunion su;
88 struct peer *peer;
89
90 bgp = vty->index;
91
92 ret = str2sockunion (ip_str, &su);
93 if (ret < 0)
94 {
95 vty_out (vty, "%% Malformed address: %s%s", ip_str, VTY_NEWLINE);
96 return NULL;
97 }
98
99 peer = peer_lookup (bgp, &su);
100 if (! peer)
101 {
102 vty_out (vty, "%% Specify remote-as or peer-group commands first%s", VTY_NEWLINE);
103 return NULL;
104 }
105 return peer;
106}
107
108/* Utility function for looking up peer or peer group. */
109struct peer *
110peer_and_group_lookup_vty (struct vty *vty, char *peer_str)
111{
112 int ret;
113 struct bgp *bgp;
114 union sockunion su;
115 struct peer *peer;
116 struct peer_group *group;
117
118 bgp = vty->index;
119
120 ret = str2sockunion (peer_str, &su);
121 if (ret == 0)
122 {
123 peer = peer_lookup (bgp, &su);
124 if (peer)
125 return peer;
126 }
127 else
128 {
129 group = peer_group_lookup (bgp, peer_str);
130 if (group)
131 return group->conf;
132 }
133
134 vty_out (vty, "%% Specify remote-as or peer-group commands first%s",
135 VTY_NEWLINE);
136
137 return NULL;
138}
139
140int
141bgp_vty_return (struct vty *vty, int ret)
142{
143 char *str = NULL;
144
145 switch (ret)
146 {
147 case BGP_ERR_INVALID_VALUE:
148 str = "Invalid value";
149 break;
150 case BGP_ERR_INVALID_FLAG:
151 str = "Invalid flag";
152 break;
153 case BGP_ERR_PEER_INACTIVE:
154 str = "Activate the neighbor for the address family first";
155 break;
156 case BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER:
157 str = "Invalid command for a peer-group member";
158 break;
159 case BGP_ERR_PEER_GROUP_SHUTDOWN:
160 str = "Peer-group has been shutdown. Activate the peer-group first";
161 break;
162 case BGP_ERR_PEER_GROUP_HAS_THE_FLAG:
163 str = "This peer is a peer-group member. Please change peer-group configuration";
164 break;
165 case BGP_ERR_PEER_FLAG_CONFLICT:
166 str = "Can't set override-capability and strict-capability-match at the same time";
167 break;
168 case BGP_ERR_PEER_GROUP_MEMBER_EXISTS:
169 str = "No activate for peergroup can be given only if peer-group has no members";
170 break;
171 case BGP_ERR_PEER_BELONGS_TO_GROUP:
172 str = "No activate for an individual peer-group member is invalid";
173 break;
174 case BGP_ERR_PEER_GROUP_AF_UNCONFIGURED:
175 str = "Activate the peer-group for the address family first";
176 break;
177 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS:
178 str = "Specify remote-as or peer-group remote AS first";
179 break;
180 case BGP_ERR_PEER_GROUP_CANT_CHANGE:
181 str = "Cannot change the peer-group. Deconfigure first";
182 break;
183 case BGP_ERR_PEER_GROUP_MISMATCH:
184 str = "Cannot have different peer-group for the neighbor";
185 break;
186 case BGP_ERR_PEER_FILTER_CONFLICT:
187 str = "Prefix/distribute list can not co-exist";
188 break;
189 case BGP_ERR_NOT_INTERNAL_PEER:
190 str = "Invalid command. Not an internal neighbor";
191 break;
192 case BGP_ERR_REMOVE_PRIVATE_AS:
193 str = "Private AS cannot be removed for IBGP peers";
194 break;
195 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP:
196 str = "Local-AS allowed only for EBGP peers";
197 break;
198 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS:
199 str = "Cannot have local-as same as BGP AS number";
200 break;
201 }
202 if (str)
203 {
204 vty_out (vty, "%% %s%s", str, VTY_NEWLINE);
205 return CMD_WARNING;
206 }
207 return CMD_SUCCESS;
208}
209
210/* BGP global configuration. */
211
212DEFUN (bgp_multiple_instance_func,
213 bgp_multiple_instance_cmd,
214 "bgp multiple-instance",
215 BGP_STR
216 "Enable bgp multiple instance\n")
217{
218 bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE);
219 return CMD_SUCCESS;
220}
221
222DEFUN (no_bgp_multiple_instance,
223 no_bgp_multiple_instance_cmd,
224 "no bgp multiple-instance",
225 NO_STR
226 BGP_STR
227 "BGP multiple instance\n")
228{
229 int ret;
230
231 ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE);
232 if (ret < 0)
233 {
234 vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE);
235 return CMD_WARNING;
236 }
237 return CMD_SUCCESS;
238}
239
240DEFUN (bgp_config_type,
241 bgp_config_type_cmd,
242 "bgp config-type (cisco|zebra)",
243 BGP_STR
244 "Configuration type\n"
245 "cisco\n"
246 "zebra\n")
247{
248 if (strncmp (argv[0], "c", 1) == 0)
249 bgp_option_set (BGP_OPT_CONFIG_CISCO);
250 else
251 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
252
253 return CMD_SUCCESS;
254}
255
256DEFUN (no_bgp_config_type,
257 no_bgp_config_type_cmd,
258 "no bgp config-type",
259 NO_STR
260 BGP_STR
261 "Display configuration type\n")
262{
263 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
264 return CMD_SUCCESS;
265}
266
267DEFUN (no_synchronization,
268 no_synchronization_cmd,
269 "no synchronization",
270 NO_STR
271 "Perform IGP synchronization\n")
272{
273 return CMD_SUCCESS;
274}
275
276DEFUN (no_auto_summary,
277 no_auto_summary_cmd,
278 "no auto-summary",
279 NO_STR
280 "Enable automatic network number summarization\n")
281{
282 return CMD_SUCCESS;
283}
284
285/* "router bgp" commands. */
286DEFUN (router_bgp,
287 router_bgp_cmd,
288 "router bgp <1-65535>",
289 ROUTER_STR
290 BGP_STR
291 AS_STR)
292{
293 int ret;
294 as_t as;
295 struct bgp *bgp;
296 char *name = NULL;
297
298 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, 65535);
299
300 if (argc == 2)
301 name = argv[1];
302
303 ret = bgp_get (&bgp, &as, name);
304 switch (ret)
305 {
306 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET:
307 vty_out (vty, "Please specify 'bgp multiple-instance' first%s",
308 VTY_NEWLINE);
309 return CMD_WARNING;
310 break;
311 case BGP_ERR_AS_MISMATCH:
312 vty_out (vty, "BGP is already running; AS is %d%s", as, VTY_NEWLINE);
313 return CMD_WARNING;
314 break;
315 case BGP_ERR_INSTANCE_MISMATCH:
316 vty_out (vty, "BGP view name and AS number mismatch%s", VTY_NEWLINE);
317 vty_out (vty, "BGP instance is already running; AS is %d%s",
318 as, VTY_NEWLINE);
319 return CMD_WARNING;
320 break;
321 }
322
323 vty->node = BGP_NODE;
324 vty->index = bgp;
325
326 return CMD_SUCCESS;
327}
328
329ALIAS (router_bgp,
330 router_bgp_view_cmd,
331 "router bgp <1-65535> view WORD",
332 ROUTER_STR
333 BGP_STR
334 AS_STR
335 "BGP view\n"
336 "view name\n")
337
338/* "no router bgp" commands. */
339DEFUN (no_router_bgp,
340 no_router_bgp_cmd,
341 "no router bgp <1-65535>",
342 NO_STR
343 ROUTER_STR
344 BGP_STR
345 AS_STR)
346{
347 as_t as;
348 struct bgp *bgp;
349 char *name = NULL;
350
351 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, 65535);
352
353 if (argc == 2)
354 name = argv[1];
355
356 /* Lookup bgp structure. */
357 bgp = bgp_lookup (as, name);
358 if (! bgp)
359 {
360 vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE);
361 return CMD_WARNING;
362 }
363
364 bgp_delete (bgp);
365
366 return CMD_SUCCESS;
367}
368
369ALIAS (no_router_bgp,
370 no_router_bgp_view_cmd,
371 "no router bgp <1-65535> view WORD",
372 NO_STR
373 ROUTER_STR
374 BGP_STR
375 AS_STR
376 "BGP view\n"
377 "view name\n")
378
379/* BGP router-id. */
380
381DEFUN (bgp_router_id,
382 bgp_router_id_cmd,
383 "bgp router-id A.B.C.D",
384 BGP_STR
385 "Override configured router identifier\n"
386 "Manually configured router identifier\n")
387{
388 int ret;
389 struct in_addr id;
390 struct bgp *bgp;
391
392 bgp = vty->index;
393
394 ret = inet_aton (argv[0], &id);
395 if (! ret)
396 {
397 vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE);
398 return CMD_WARNING;
399 }
400
401 bgp_router_id_set (bgp, &id);
402
403 return CMD_SUCCESS;
404}
405
406DEFUN (no_bgp_router_id,
407 no_bgp_router_id_cmd,
408 "no bgp router-id",
409 NO_STR
410 BGP_STR
411 "Override configured router identifier\n")
412{
413 int ret;
414 struct in_addr id;
415 struct bgp *bgp;
416
417 bgp = vty->index;
418
419 if (argc == 1)
420 {
421 ret = inet_aton (argv[0], &id);
422 if (! ret)
423 {
424 vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE);
425 return CMD_WARNING;
426 }
427
428 if (! IPV4_ADDR_SAME (&bgp->router_id, &id))
429 {
430 vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE);
431 return CMD_WARNING;
432 }
433 }
434
435 bgp_router_id_unset (bgp);
436
437 return CMD_SUCCESS;
438}
439
440ALIAS (no_bgp_router_id,
441 no_bgp_router_id_val_cmd,
442 "no bgp router-id A.B.C.D",
443 NO_STR
444 BGP_STR
445 "Override configured router identifier\n"
446 "Manually configured router identifier\n")
447
448/* BGP Cluster ID. */
449
450DEFUN (bgp_cluster_id,
451 bgp_cluster_id_cmd,
452 "bgp cluster-id A.B.C.D",
453 BGP_STR
454 "Configure Route-Reflector Cluster-id\n"
455 "Route-Reflector Cluster-id in IP address format\n")
456{
457 int ret;
458 struct bgp *bgp;
459 struct in_addr cluster;
460
461 bgp = vty->index;
462
463 ret = inet_aton (argv[0], &cluster);
464 if (! ret)
465 {
466 vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
467 return CMD_WARNING;
468 }
469
470 bgp_cluster_id_set (bgp, &cluster);
471
472 return CMD_SUCCESS;
473}
474
475ALIAS (bgp_cluster_id,
476 bgp_cluster_id32_cmd,
477 "bgp cluster-id <1-4294967295>",
478 BGP_STR
479 "Configure Route-Reflector Cluster-id\n"
480 "Route-Reflector Cluster-id as 32 bit quantity\n")
481
482DEFUN (no_bgp_cluster_id,
483 no_bgp_cluster_id_cmd,
484 "no bgp cluster-id",
485 NO_STR
486 BGP_STR
487 "Configure Route-Reflector Cluster-id\n")
488{
489 int ret;
490 struct bgp *bgp;
491 struct in_addr cluster;
492
493 bgp = vty->index;
494
495 if (argc == 1)
496 {
497 ret = inet_aton (argv[0], &cluster);
498 if (! ret)
499 {
500 vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
501 return CMD_WARNING;
502 }
503 }
504
505 bgp_cluster_id_unset (bgp);
506
507 return CMD_SUCCESS;
508}
509
510ALIAS (no_bgp_cluster_id,
511 no_bgp_cluster_id_arg_cmd,
512 "no bgp cluster-id A.B.C.D",
513 NO_STR
514 BGP_STR
515 "Configure Route-Reflector Cluster-id\n"
516 "Route-Reflector Cluster-id in IP address format\n")
517
518DEFUN (bgp_confederation_identifier,
519 bgp_confederation_identifier_cmd,
520 "bgp confederation identifier <1-65535>",
521 "BGP specific commands\n"
522 "AS confederation parameters\n"
523 "AS number\n"
524 "Set routing domain confederation AS\n")
525{
526 struct bgp *bgp;
527 as_t as;
528
529 bgp = vty->index;
530
531 VTY_GET_INTEGER ("AS", as, argv[0]);
532
533 bgp_confederation_id_set (bgp, as);
534
535 return CMD_SUCCESS;
536}
537
538DEFUN (no_bgp_confederation_identifier,
539 no_bgp_confederation_identifier_cmd,
540 "no bgp confederation identifier",
541 NO_STR
542 "BGP specific commands\n"
543 "AS confederation parameters\n"
544 "AS number\n")
545{
546 struct bgp *bgp;
547 as_t as;
548
549 bgp = vty->index;
550
551 if (argc == 1)
552 VTY_GET_INTEGER ("AS", as, argv[0]);
553
554 bgp_confederation_id_unset (bgp);
555
556 return CMD_SUCCESS;
557}
558
559ALIAS (no_bgp_confederation_identifier,
560 no_bgp_confederation_identifier_arg_cmd,
561 "no bgp confederation identifier <1-65535>",
562 NO_STR
563 "BGP specific commands\n"
564 "AS confederation parameters\n"
565 "AS number\n"
566 "Set routing domain confederation AS\n")
567
568DEFUN (bgp_confederation_peers,
569 bgp_confederation_peers_cmd,
570 "bgp confederation peers .<1-65535>",
571 "BGP specific commands\n"
572 "AS confederation parameters\n"
573 "Peer ASs in BGP confederation\n"
574 AS_STR)
575{
576 struct bgp *bgp;
577 as_t as;
578 int i;
579
580 bgp = vty->index;
581
582 for (i = 0; i < argc; i++)
583 {
584 VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, 65535);
585
586 if (bgp->as == as)
587 {
588 vty_out (vty, "%% Local member-AS not allowed in confed peer list%s",
589 VTY_NEWLINE);
590 continue;
591 }
592
593 bgp_confederation_peers_add (bgp, as);
594 }
595 return CMD_SUCCESS;
596}
597
598DEFUN (no_bgp_confederation_peers,
599 no_bgp_confederation_peers_cmd,
600 "no bgp confederation peers .<1-65535>",
601 NO_STR
602 "BGP specific commands\n"
603 "AS confederation parameters\n"
604 "Peer ASs in BGP confederation\n"
605 AS_STR)
606{
607 struct bgp *bgp;
608 as_t as;
609 int i;
610
611 bgp = vty->index;
612
613 for (i = 0; i < argc; i++)
614 {
615 VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, 65535);
616
617 bgp_confederation_peers_remove (bgp, as);
618 }
619 return CMD_SUCCESS;
620}
621
622/* BGP timers. */
623
624DEFUN (bgp_timers,
625 bgp_timers_cmd,
626 "timers bgp <0-65535> <0-65535>",
627 "Adjust routing timers\n"
628 "BGP timers\n"
629 "Keepalive interval\n"
630 "Holdtime\n")
631{
632 struct bgp *bgp;
633 unsigned long keepalive = 0;
634 unsigned long holdtime = 0;
635
636 bgp = vty->index;
637
638 VTY_GET_INTEGER ("keepalive", keepalive, argv[0]);
639 VTY_GET_INTEGER ("holdtime", holdtime, argv[1]);
640
641 /* Holdtime value check. */
642 if (holdtime < 3 && holdtime != 0)
643 {
644 vty_out (vty, "%% hold time value must be either 0 or greater than 3%s",
645 VTY_NEWLINE);
646 return CMD_WARNING;
647 }
648
649 bgp_timers_set (bgp, keepalive, holdtime);
650
651 return CMD_SUCCESS;
652}
653
654DEFUN (no_bgp_timers,
655 no_bgp_timers_cmd,
656 "no timers bgp",
657 NO_STR
658 "Adjust routing timers\n"
659 "BGP timers\n")
660{
661 struct bgp *bgp;
662
663 bgp = vty->index;
664 bgp_timers_unset (bgp);
665
666 return CMD_SUCCESS;
667}
668
669ALIAS (no_bgp_timers,
670 no_bgp_timers_arg_cmd,
671 "no timers bgp <0-65535> <0-65535>",
672 NO_STR
673 "Adjust routing timers\n"
674 "BGP timers\n"
675 "Keepalive interval\n"
676 "Holdtime\n")
677
678DEFUN (bgp_client_to_client_reflection,
679 bgp_client_to_client_reflection_cmd,
680 "bgp client-to-client reflection",
681 "BGP specific commands\n"
682 "Configure client to client route reflection\n"
683 "reflection of routes allowed\n")
684{
685 struct bgp *bgp;
686
687 bgp = vty->index;
688 bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
689 return CMD_SUCCESS;
690}
691
692DEFUN (no_bgp_client_to_client_reflection,
693 no_bgp_client_to_client_reflection_cmd,
694 "no bgp client-to-client reflection",
695 NO_STR
696 "BGP specific commands\n"
697 "Configure client to client route reflection\n"
698 "reflection of routes allowed\n")
699{
700 struct bgp *bgp;
701
702 bgp = vty->index;
703 bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
704 return CMD_SUCCESS;
705}
706
707/* "bgp always-compare-med" configuration. */
708DEFUN (bgp_always_compare_med,
709 bgp_always_compare_med_cmd,
710 "bgp always-compare-med",
711 "BGP specific commands\n"
712 "Allow comparing MED from different neighbors\n")
713{
714 struct bgp *bgp;
715
716 bgp = vty->index;
717 bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
718 return CMD_SUCCESS;
719}
720
721DEFUN (no_bgp_always_compare_med,
722 no_bgp_always_compare_med_cmd,
723 "no bgp always-compare-med",
724 NO_STR
725 "BGP specific commands\n"
726 "Allow comparing MED from different neighbors\n")
727{
728 struct bgp *bgp;
729
730 bgp = vty->index;
731 bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
732 return CMD_SUCCESS;
733}
734
735/* "bgp deterministic-med" configuration. */
736DEFUN (bgp_deterministic_med,
737 bgp_deterministic_med_cmd,
738 "bgp deterministic-med",
739 "BGP specific commands\n"
740 "Pick the best-MED path among paths advertised from the neighboring AS\n")
741{
742 struct bgp *bgp;
743
744 bgp = vty->index;
745 bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED);
746 return CMD_SUCCESS;
747}
748
749DEFUN (no_bgp_deterministic_med,
750 no_bgp_deterministic_med_cmd,
751 "no bgp deterministic-med",
752 NO_STR
753 "BGP specific commands\n"
754 "Pick the best-MED path among paths advertised from the neighboring AS\n")
755{
756 struct bgp *bgp;
757
758 bgp = vty->index;
759 bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED);
760 return CMD_SUCCESS;
761}
762
763/* "bgp fast-external-failover" configuration. */
764DEFUN (bgp_fast_external_failover,
765 bgp_fast_external_failover_cmd,
766 "bgp fast-external-failover",
767 BGP_STR
768 "Immediately reset session if a link to a directly connected external peer goes down\n")
769{
770 struct bgp *bgp;
771
772 bgp = vty->index;
773 bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
774 return CMD_SUCCESS;
775}
776
777DEFUN (no_bgp_fast_external_failover,
778 no_bgp_fast_external_failover_cmd,
779 "no bgp fast-external-failover",
780 NO_STR
781 BGP_STR
782 "Immediately reset session if a link to a directly connected external peer goes down\n")
783{
784 struct bgp *bgp;
785
786 bgp = vty->index;
787 bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
788 return CMD_SUCCESS;
789}
790
791/* "bgp enforce-first-as" configuration. */
792DEFUN (bgp_enforce_first_as,
793 bgp_enforce_first_as_cmd,
794 "bgp enforce-first-as",
795 BGP_STR
796 "Enforce the first AS for EBGP routes\n")
797{
798 struct bgp *bgp;
799
800 bgp = vty->index;
801 bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
802 return CMD_SUCCESS;
803}
804
805DEFUN (no_bgp_enforce_first_as,
806 no_bgp_enforce_first_as_cmd,
807 "no bgp enforce-first-as",
808 NO_STR
809 BGP_STR
810 "Enforce the first AS for EBGP routes\n")
811{
812 struct bgp *bgp;
813
814 bgp = vty->index;
815 bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
816 return CMD_SUCCESS;
817}
818
819/* "bgp bestpath compare-routerid" configuration. */
820DEFUN (bgp_bestpath_compare_router_id,
821 bgp_bestpath_compare_router_id_cmd,
822 "bgp bestpath compare-routerid",
823 "BGP specific commands\n"
824 "Change the default bestpath selection\n"
825 "Compare router-id for identical EBGP paths\n")
826{
827 struct bgp *bgp;
828
829 bgp = vty->index;
830 bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
831 return CMD_SUCCESS;
832}
833
834DEFUN (no_bgp_bestpath_compare_router_id,
835 no_bgp_bestpath_compare_router_id_cmd,
836 "no bgp bestpath compare-routerid",
837 NO_STR
838 "BGP specific commands\n"
839 "Change the default bestpath selection\n"
840 "Compare router-id for identical EBGP paths\n")
841{
842 struct bgp *bgp;
843
844 bgp = vty->index;
845 bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
846 return CMD_SUCCESS;
847}
848
849/* "bgp bestpath as-path ignore" configuration. */
850DEFUN (bgp_bestpath_aspath_ignore,
851 bgp_bestpath_aspath_ignore_cmd,
852 "bgp bestpath as-path ignore",
853 "BGP specific commands\n"
854 "Change the default bestpath selection\n"
855 "AS-path attribute\n"
856 "Ignore as-path length in selecting a route\n")
857{
858 struct bgp *bgp;
859
860 bgp = vty->index;
861 bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE);
862 return CMD_SUCCESS;
863}
864
865DEFUN (no_bgp_bestpath_aspath_ignore,
866 no_bgp_bestpath_aspath_ignore_cmd,
867 "no bgp bestpath as-path ignore",
868 NO_STR
869 "BGP specific commands\n"
870 "Change the default bestpath selection\n"
871 "AS-path attribute\n"
872 "Ignore as-path length in selecting a route\n")
873{
874 struct bgp *bgp;
875
876 bgp = vty->index;
877 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE);
878 return CMD_SUCCESS;
879}
880
881/* "bgp bestpath med" configuration. */
882DEFUN (bgp_bestpath_med,
883 bgp_bestpath_med_cmd,
884 "bgp bestpath med (confed|missing-as-worst)",
885 "BGP specific commands\n"
886 "Change the default bestpath selection\n"
887 "MED attribute\n"
888 "Compare MED among confederation paths\n"
889 "Treat missing MED as the least preferred one\n")
890{
891 struct bgp *bgp;
892
893 bgp = vty->index;
894
895 if (strncmp (argv[0], "confed", 1) == 0)
896 bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
897 else
898 bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
899
900 return CMD_SUCCESS;
901}
902
903DEFUN (bgp_bestpath_med2,
904 bgp_bestpath_med2_cmd,
905 "bgp bestpath med confed missing-as-worst",
906 "BGP specific commands\n"
907 "Change the default bestpath selection\n"
908 "MED attribute\n"
909 "Compare MED among confederation paths\n"
910 "Treat missing MED as the least preferred one\n")
911{
912 struct bgp *bgp;
913
914 bgp = vty->index;
915 bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
916 bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
917 return CMD_SUCCESS;
918}
919
920ALIAS (bgp_bestpath_med2,
921 bgp_bestpath_med3_cmd,
922 "bgp bestpath med missing-as-worst confed",
923 "BGP specific commands\n"
924 "Change the default bestpath selection\n"
925 "MED attribute\n"
926 "Treat missing MED as the least preferred one\n"
927 "Compare MED among confederation paths\n")
928
929DEFUN (no_bgp_bestpath_med,
930 no_bgp_bestpath_med_cmd,
931 "no bgp bestpath med (confed|missing-as-worst)",
932 NO_STR
933 "BGP specific commands\n"
934 "Change the default bestpath selection\n"
935 "MED attribute\n"
936 "Compare MED among confederation paths\n"
937 "Treat missing MED as the least preferred one\n")
938{
939 struct bgp *bgp;
940
941 bgp = vty->index;
942
943 if (strncmp (argv[0], "confed", 1) == 0)
944 bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
945 else
946 bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
947
948 return CMD_SUCCESS;
949}
950
951DEFUN (no_bgp_bestpath_med2,
952 no_bgp_bestpath_med2_cmd,
953 "no bgp bestpath med confed missing-as-worst",
954 NO_STR
955 "BGP specific commands\n"
956 "Change the default bestpath selection\n"
957 "MED attribute\n"
958 "Compare MED among confederation paths\n"
959 "Treat missing MED as the least preferred one\n")
960{
961 struct bgp *bgp;
962
963 bgp = vty->index;
964 bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
965 bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
966 return CMD_SUCCESS;
967}
968
969ALIAS (no_bgp_bestpath_med2,
970 no_bgp_bestpath_med3_cmd,
971 "no bgp bestpath med missing-as-worst confed",
972 NO_STR
973 "BGP specific commands\n"
974 "Change the default bestpath selection\n"
975 "MED attribute\n"
976 "Treat missing MED as the least preferred one\n"
977 "Compare MED among confederation paths\n")
978
979/* "no bgp default ipv4-unicast". */
980DEFUN (no_bgp_default_ipv4_unicast,
981 no_bgp_default_ipv4_unicast_cmd,
982 "no bgp default ipv4-unicast",
983 NO_STR
984 "BGP specific commands\n"
985 "Configure BGP defaults\n"
986 "Activate ipv4-unicast for a peer by default\n")
987{
988 struct bgp *bgp;
989
990 bgp = vty->index;
991 bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
992 return CMD_SUCCESS;
993}
994
995DEFUN (bgp_default_ipv4_unicast,
996 bgp_default_ipv4_unicast_cmd,
997 "bgp default ipv4-unicast",
998 "BGP specific commands\n"
999 "Configure BGP defaults\n"
1000 "Activate ipv4-unicast for a peer by default\n")
1001{
1002 struct bgp *bgp;
1003
1004 bgp = vty->index;
1005 bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
1006 return CMD_SUCCESS;
1007}
1008
1009/* "bgp import-check" configuration. */
1010DEFUN (bgp_network_import_check,
1011 bgp_network_import_check_cmd,
1012 "bgp network import-check",
1013 "BGP specific commands\n"
1014 "BGP network command\n"
1015 "Check BGP network route exists in IGP\n")
1016{
1017 struct bgp *bgp;
1018
1019 bgp = vty->index;
1020 bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK);
1021 return CMD_SUCCESS;
1022}
1023
1024DEFUN (no_bgp_network_import_check,
1025 no_bgp_network_import_check_cmd,
1026 "no bgp network import-check",
1027 NO_STR
1028 "BGP specific commands\n"
1029 "BGP network command\n"
1030 "Check BGP network route exists in IGP\n")
1031{
1032 struct bgp *bgp;
1033
1034 bgp = vty->index;
1035 bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK);
1036 return CMD_SUCCESS;
1037}
1038
1039DEFUN (bgp_default_local_preference,
1040 bgp_default_local_preference_cmd,
1041 "bgp default local-preference <0-4294967295>",
1042 "BGP specific commands\n"
1043 "Configure BGP defaults\n"
1044 "local preference (higher=more preferred)\n"
1045 "Configure default local preference value\n")
1046{
1047 struct bgp *bgp;
1048 u_int32_t local_pref;
1049
1050 bgp = vty->index;
1051
1052 VTY_GET_INTEGER ("local preference", local_pref, argv[0]);
1053
1054 bgp_default_local_preference_set (bgp, local_pref);
1055
1056 return CMD_SUCCESS;
1057}
1058
1059DEFUN (no_bgp_default_local_preference,
1060 no_bgp_default_local_preference_cmd,
1061 "no bgp default local-preference",
1062 NO_STR
1063 "BGP specific commands\n"
1064 "Configure BGP defaults\n"
1065 "local preference (higher=more preferred)\n")
1066{
1067 struct bgp *bgp;
1068
1069 bgp = vty->index;
1070 bgp_default_local_preference_unset (bgp);
1071 return CMD_SUCCESS;
1072}
1073
1074ALIAS (no_bgp_default_local_preference,
1075 no_bgp_default_local_preference_val_cmd,
1076 "no bgp default local-preference <0-4294967295>",
1077 NO_STR
1078 "BGP specific commands\n"
1079 "Configure BGP defaults\n"
1080 "local preference (higher=more preferred)\n"
1081 "Configure default local preference value\n")
1082
1083static int
1084peer_remote_as_vty (struct vty *vty, char *peer_str, char *as_str, afi_t afi,
1085 safi_t safi)
1086{
1087 int ret;
1088 struct bgp *bgp;
1089 as_t as;
1090 union sockunion su;
1091
1092 bgp = vty->index;
1093
1094 /* Get AS number. */
1095 VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, 65535);
1096
1097 /* If peer is peer group, call proper function. */
1098 ret = str2sockunion (peer_str, &su);
1099 if (ret < 0)
1100 {
1101 ret = peer_group_remote_as (bgp, peer_str, &as);
1102 if (ret < 0)
1103 {
1104 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1105 return CMD_WARNING;
1106 }
1107 return CMD_SUCCESS;
1108 }
1109
1110 if (peer_address_self_check (&su))
1111 {
1112 vty_out (vty, "%% Can not configure the local system as neighbor%s",
1113 VTY_NEWLINE);
1114 return CMD_WARNING;
1115 }
1116
1117 ret = peer_remote_as (bgp, &su, &as, afi, safi);
1118
1119 /* This peer belongs to peer group. */
1120 switch (ret)
1121 {
1122 case BGP_ERR_PEER_GROUP_MEMBER:
1123 vty_out (vty, "%% Peer-group AS %d. Cannot configure remote-as for member%s", as, VTY_NEWLINE);
1124 return CMD_WARNING;
1125 break;
1126 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT:
1127 vty_out (vty, "%% The AS# can not be changed from %d to %s, peer-group members must be all internal or all external%s", as, as_str, VTY_NEWLINE);
1128 return CMD_WARNING;
1129 break;
1130 }
1131 return bgp_vty_return (vty, ret);
1132}
1133
1134DEFUN (neighbor_remote_as,
1135 neighbor_remote_as_cmd,
1136 NEIGHBOR_CMD2 "remote-as <1-65535>",
1137 NEIGHBOR_STR
1138 NEIGHBOR_ADDR_STR2
1139 "Specify a BGP neighbor\n"
1140 AS_STR)
1141{
1142 return peer_remote_as_vty (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST);
1143}
1144
1145DEFUN (neighbor_peer_group,
1146 neighbor_peer_group_cmd,
1147 "neighbor WORD peer-group",
1148 NEIGHBOR_STR
1149 "Neighbor tag\n"
1150 "Configure peer-group\n")
1151{
1152 struct bgp *bgp;
1153 struct peer_group *group;
1154
1155 bgp = vty->index;
1156
1157 group = peer_group_get (bgp, argv[0]);
1158 if (! group)
1159 return CMD_WARNING;
1160
1161 return CMD_SUCCESS;
1162}
1163
1164DEFUN (no_neighbor,
1165 no_neighbor_cmd,
1166 NO_NEIGHBOR_CMD2,
1167 NO_STR
1168 NEIGHBOR_STR
1169 NEIGHBOR_ADDR_STR2)
1170{
1171 int ret;
1172 union sockunion su;
1173 struct peer_group *group;
1174 struct peer *peer;
1175
1176 ret = str2sockunion (argv[0], &su);
1177 if (ret < 0)
1178 {
1179 group = peer_group_lookup (vty->index, argv[0]);
1180 if (group)
1181 peer_group_delete (group);
1182 else
1183 {
1184 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1185 return CMD_WARNING;
1186 }
1187 }
1188 else
1189 {
1190 peer = peer_lookup (vty->index, &su);
1191 if (peer)
1192 peer_delete (peer);
1193 }
1194
1195 return CMD_SUCCESS;
1196}
1197
1198ALIAS (no_neighbor,
1199 no_neighbor_remote_as_cmd,
1200 NO_NEIGHBOR_CMD "remote-as <1-65535>",
1201 NO_STR
1202 NEIGHBOR_STR
1203 NEIGHBOR_ADDR_STR
1204 "Specify a BGP neighbor\n"
1205 AS_STR)
1206
1207DEFUN (no_neighbor_peer_group,
1208 no_neighbor_peer_group_cmd,
1209 "no neighbor WORD peer-group",
1210 NO_STR
1211 NEIGHBOR_STR
1212 "Neighbor tag\n"
1213 "Configure peer-group\n")
1214{
1215 struct peer_group *group;
1216
1217 group = peer_group_lookup (vty->index, argv[0]);
1218 if (group)
1219 peer_group_delete (group);
1220 else
1221 {
1222 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1223 return CMD_WARNING;
1224 }
1225 return CMD_SUCCESS;
1226}
1227
1228DEFUN (no_neighbor_peer_group_remote_as,
1229 no_neighbor_peer_group_remote_as_cmd,
1230 "no neighbor WORD remote-as <1-65535>",
1231 NO_STR
1232 NEIGHBOR_STR
1233 "Neighbor tag\n"
1234 "Specify a BGP neighbor\n"
1235 AS_STR)
1236{
1237 struct peer_group *group;
1238
1239 group = peer_group_lookup (vty->index, argv[0]);
1240 if (group)
1241 peer_group_remote_as_delete (group);
1242 else
1243 {
1244 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1245 return CMD_WARNING;
1246 }
1247 return CMD_SUCCESS;
1248}
1249
1250DEFUN (neighbor_local_as,
1251 neighbor_local_as_cmd,
1252 NEIGHBOR_CMD2 "local-as <1-65535>",
1253 NEIGHBOR_STR
1254 NEIGHBOR_ADDR_STR2
1255 "Specify a local-as number\n"
1256 "AS number used as local AS\n")
1257{
1258 struct peer *peer;
1259 int ret;
1260
1261 peer = peer_and_group_lookup_vty (vty, argv[0]);
1262 if (! peer)
1263 return CMD_WARNING;
1264
1265 ret = peer_local_as_set (peer, atoi (argv[1]), 0);
1266 return bgp_vty_return (vty, ret);
1267}
1268
1269DEFUN (neighbor_local_as_no_prepend,
1270 neighbor_local_as_no_prepend_cmd,
1271 NEIGHBOR_CMD2 "local-as <1-65535> no-prepend",
1272 NEIGHBOR_STR
1273 NEIGHBOR_ADDR_STR2
1274 "Specify a local-as number\n"
1275 "AS number used as local AS\n"
1276 "Do not prepend local-as to updates from ebgp peers\n")
1277{
1278 struct peer *peer;
1279 int ret;
1280
1281 peer = peer_and_group_lookup_vty (vty, argv[0]);
1282 if (! peer)
1283 return CMD_WARNING;
1284
1285 ret = peer_local_as_set (peer, atoi (argv[1]), 1);
1286 return bgp_vty_return (vty, ret);
1287}
1288
1289DEFUN (no_neighbor_local_as,
1290 no_neighbor_local_as_cmd,
1291 NO_NEIGHBOR_CMD2 "local-as",
1292 NO_STR
1293 NEIGHBOR_STR
1294 NEIGHBOR_ADDR_STR2
1295 "Specify a local-as number\n")
1296{
1297 struct peer *peer;
1298 int ret;
1299
1300 peer = peer_and_group_lookup_vty (vty, argv[0]);
1301 if (! peer)
1302 return CMD_WARNING;
1303
1304 ret = peer_local_as_unset (peer);
1305 return bgp_vty_return (vty, ret);
1306}
1307
1308ALIAS (no_neighbor_local_as,
1309 no_neighbor_local_as_val_cmd,
1310 NO_NEIGHBOR_CMD2 "local-as <1-65535>",
1311 NO_STR
1312 NEIGHBOR_STR
1313 NEIGHBOR_ADDR_STR2
1314 "Specify a local-as number\n"
1315 "AS number used as local AS\n")
1316
1317ALIAS (no_neighbor_local_as,
1318 no_neighbor_local_as_val2_cmd,
1319 NO_NEIGHBOR_CMD2 "local-as <1-65535> no-prepend",
1320 NO_STR
1321 NEIGHBOR_STR
1322 NEIGHBOR_ADDR_STR2
1323 "Specify a local-as number\n"
1324 "AS number used as local AS\n"
1325 "Do not prepend local-as to updates from ebgp peers\n")
1326
1327DEFUN (neighbor_activate,
1328 neighbor_activate_cmd,
1329 NEIGHBOR_CMD2 "activate",
1330 NEIGHBOR_STR
1331 NEIGHBOR_ADDR_STR2
1332 "Enable the Address Family for this Neighbor\n")
1333{
1334 struct peer *peer;
1335
1336 peer = peer_and_group_lookup_vty (vty, argv[0]);
1337 if (! peer)
1338 return CMD_WARNING;
1339
1340 peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
1341
1342 return CMD_SUCCESS;
1343}
1344
1345DEFUN (no_neighbor_activate,
1346 no_neighbor_activate_cmd,
1347 NO_NEIGHBOR_CMD2 "activate",
1348 NO_STR
1349 NEIGHBOR_STR
1350 NEIGHBOR_ADDR_STR2
1351 "Enable the Address Family for this Neighbor\n")
1352{
1353 int ret;
1354 struct peer *peer;
1355
1356 /* Lookup peer. */
1357 peer = peer_and_group_lookup_vty (vty, argv[0]);
1358 if (! peer)
1359 return CMD_WARNING;
1360
1361 ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
1362
1363 return bgp_vty_return (vty, ret);
1364}
1365
1366DEFUN (neighbor_set_peer_group,
1367 neighbor_set_peer_group_cmd,
1368 NEIGHBOR_CMD "peer-group WORD",
1369 NEIGHBOR_STR
1370 NEIGHBOR_ADDR_STR
1371 "Member of the peer-group\n"
1372 "peer-group name\n")
1373{
1374 int ret;
1375 as_t as;
1376 union sockunion su;
1377 struct bgp *bgp;
1378 struct peer_group *group;
1379
1380 bgp = vty->index;
1381
1382 ret = str2sockunion (argv[0], &su);
1383 if (ret < 0)
1384 {
1385 vty_out (vty, "%% Malformed address: %s%s", argv[0], VTY_NEWLINE);
1386 return CMD_WARNING;
1387 }
1388
1389 group = peer_group_lookup (bgp, argv[1]);
1390 if (! group)
1391 {
1392 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
1393 return CMD_WARNING;
1394 }
1395
1396 if (peer_address_self_check (&su))
1397 {
1398 vty_out (vty, "%% Can not configure the local system as neighbor%s",
1399 VTY_NEWLINE);
1400 return CMD_WARNING;
1401 }
1402
1403 ret = peer_group_bind (bgp, &su, group, bgp_node_afi (vty),
1404 bgp_node_safi (vty), &as);
1405
1406 if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT)
1407 {
1408 vty_out (vty, "%% Peer with AS %d cannot be in this peer-group, members must be all internal or all external%s", as, VTY_NEWLINE);
1409 return CMD_WARNING;
1410 }
1411
1412 return bgp_vty_return (vty, ret);
1413}
1414
1415DEFUN (no_neighbor_set_peer_group,
1416 no_neighbor_set_peer_group_cmd,
1417 NO_NEIGHBOR_CMD "peer-group WORD",
1418 NO_STR
1419 NEIGHBOR_STR
1420 NEIGHBOR_ADDR_STR
1421 "Member of the peer-group\n"
1422 "peer-group name\n")
1423{
1424 int ret;
1425 struct bgp *bgp;
1426 struct peer *peer;
1427 struct peer_group *group;
1428
1429 bgp = vty->index;
1430
1431 peer = peer_lookup_vty (vty, argv[0]);
1432 if (! peer)
1433 return CMD_WARNING;
1434
1435 group = peer_group_lookup (bgp, argv[1]);
1436 if (! group)
1437 {
1438 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
1439 return CMD_WARNING;
1440 }
1441
1442 ret = peer_group_unbind (bgp, peer, group, bgp_node_afi (vty),
1443 bgp_node_safi (vty));
1444
1445 return bgp_vty_return (vty, ret);
1446}
1447
1448int
1449peer_flag_modify_vty (struct vty *vty, char *ip_str, u_int16_t flag, int set)
1450{
1451 int ret;
1452 struct peer *peer;
1453
1454 peer = peer_and_group_lookup_vty (vty, ip_str);
1455 if (! peer)
1456 return CMD_WARNING;
1457
1458 if (set)
1459 ret = peer_flag_set (peer, flag);
1460 else
1461 ret = peer_flag_unset (peer, flag);
1462
1463 return bgp_vty_return (vty, ret);
1464}
1465
1466int
1467peer_flag_set_vty (struct vty *vty, char *ip_str, u_int16_t flag)
1468{
1469 return peer_flag_modify_vty (vty, ip_str, flag, 1);
1470}
1471
1472int
1473peer_flag_unset_vty (struct vty *vty, char *ip_str, u_int16_t flag)
1474{
1475 return peer_flag_modify_vty (vty, ip_str, flag, 0);
1476}
1477
1478/* neighbor passive. */
1479DEFUN (neighbor_passive,
1480 neighbor_passive_cmd,
1481 NEIGHBOR_CMD2 "passive",
1482 NEIGHBOR_STR
1483 NEIGHBOR_ADDR_STR2
1484 "Don't send open messages to this neighbor\n")
1485{
1486 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_PASSIVE);
1487}
1488
1489DEFUN (no_neighbor_passive,
1490 no_neighbor_passive_cmd,
1491 NO_NEIGHBOR_CMD2 "passive",
1492 NO_STR
1493 NEIGHBOR_STR
1494 NEIGHBOR_ADDR_STR2
1495 "Don't send open messages to this neighbor\n")
1496{
1497 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_PASSIVE);
1498}
1499
1500/* neighbor shutdown. */
1501DEFUN (neighbor_shutdown,
1502 neighbor_shutdown_cmd,
1503 NEIGHBOR_CMD2 "shutdown",
1504 NEIGHBOR_STR
1505 NEIGHBOR_ADDR_STR2
1506 "Administratively shut down this neighbor\n")
1507{
1508 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
1509}
1510
1511DEFUN (no_neighbor_shutdown,
1512 no_neighbor_shutdown_cmd,
1513 NO_NEIGHBOR_CMD2 "shutdown",
1514 NO_STR
1515 NEIGHBOR_STR
1516 NEIGHBOR_ADDR_STR2
1517 "Administratively shut down this neighbor\n")
1518{
1519 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
1520}
1521
1522/* neighbor capability route-refresh. */
1523DEFUN (neighbor_capability_route_refresh,
1524 neighbor_capability_route_refresh_cmd,
1525 NEIGHBOR_CMD2 "capability route-refresh",
1526 NEIGHBOR_STR
1527 NEIGHBOR_ADDR_STR2
1528 "Advertise capability to the peer\n"
1529 "Advertise route-refresh capability to this neighbor\n")
1530{
1531 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_NO_ROUTE_REFRESH_CAP);
1532}
1533
1534DEFUN (no_neighbor_capability_route_refresh,
1535 no_neighbor_capability_route_refresh_cmd,
1536 NO_NEIGHBOR_CMD2 "capability route-refresh",
1537 NO_STR
1538 NEIGHBOR_STR
1539 NEIGHBOR_ADDR_STR2
1540 "Advertise capability to the peer\n"
1541 "Advertise route-refresh capability to this neighbor\n")
1542{
1543 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_NO_ROUTE_REFRESH_CAP);
1544}
1545
1546/* neighbor capability dynamic. */
1547DEFUN (neighbor_capability_dynamic,
1548 neighbor_capability_dynamic_cmd,
1549 NEIGHBOR_CMD2 "capability dynamic",
1550 NEIGHBOR_STR
1551 NEIGHBOR_ADDR_STR2
1552 "Advertise capability to the peer\n"
1553 "Advertise dynamic capability to this neighbor\n")
1554{
1555 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
1556}
1557
1558DEFUN (no_neighbor_capability_dynamic,
1559 no_neighbor_capability_dynamic_cmd,
1560 NO_NEIGHBOR_CMD2 "capability dynamic",
1561 NO_STR
1562 NEIGHBOR_STR
1563 NEIGHBOR_ADDR_STR2
1564 "Advertise capability to the peer\n"
1565 "Advertise dynamic capability to this neighbor\n")
1566{
1567 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
1568}
1569
1570/* neighbor dont-capability-negotiate */
1571DEFUN (neighbor_dont_capability_negotiate,
1572 neighbor_dont_capability_negotiate_cmd,
1573 NEIGHBOR_CMD2 "dont-capability-negotiate",
1574 NEIGHBOR_STR
1575 NEIGHBOR_ADDR_STR2
1576 "Do not perform capability negotiation\n")
1577{
1578 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
1579}
1580
1581DEFUN (no_neighbor_dont_capability_negotiate,
1582 no_neighbor_dont_capability_negotiate_cmd,
1583 NO_NEIGHBOR_CMD2 "dont-capability-negotiate",
1584 NO_STR
1585 NEIGHBOR_STR
1586 NEIGHBOR_ADDR_STR2
1587 "Do not perform capability negotiation\n")
1588{
1589 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
1590}
1591
1592int
1593peer_af_flag_modify_vty (struct vty *vty, char *peer_str, afi_t afi,
1594 safi_t safi, u_int16_t flag, int set)
1595{
1596 int ret;
1597 struct peer *peer;
1598
1599 peer = peer_and_group_lookup_vty (vty, peer_str);
1600 if (! peer)
1601 return CMD_WARNING;
1602
1603 if (set)
1604 ret = peer_af_flag_set (peer, afi, safi, flag);
1605 else
1606 ret = peer_af_flag_unset (peer, afi, safi, flag);
1607
1608 return bgp_vty_return (vty, ret);
1609}
1610
1611int
1612peer_af_flag_set_vty (struct vty *vty, char *peer_str, afi_t afi,
1613 safi_t safi, u_int16_t flag)
1614{
1615 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1);
1616}
1617
1618int
1619peer_af_flag_unset_vty (struct vty *vty, char *peer_str, afi_t afi,
1620 safi_t safi, u_int16_t flag)
1621{
1622 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0);
1623}
1624
1625/* neighbor capability orf prefix-list. */
1626DEFUN (neighbor_capability_orf_prefix,
1627 neighbor_capability_orf_prefix_cmd,
1628 NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
1629 NEIGHBOR_STR
1630 NEIGHBOR_ADDR_STR2
1631 "Advertise capability to the peer\n"
1632 "Advertise ORF capability to the peer\n"
1633 "Advertise prefixlist ORF capability to this neighbor\n"
1634 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
1635 "Capability to RECEIVE the ORF from this neighbor\n"
1636 "Capability to SEND the ORF to this neighbor\n")
1637{
1638 u_int16_t flag = 0;
1639
1640 if (strncmp (argv[1], "s", 1) == 0)
1641 flag = PEER_FLAG_ORF_PREFIX_SM;
1642 else if (strncmp (argv[1], "r", 1) == 0)
1643 flag = PEER_FLAG_ORF_PREFIX_RM;
1644 else if (strncmp (argv[1], "b", 1) == 0)
1645 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
1646 else
1647 return CMD_WARNING;
1648
1649 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1650 bgp_node_safi (vty), flag);
1651}
1652
1653DEFUN (no_neighbor_capability_orf_prefix,
1654 no_neighbor_capability_orf_prefix_cmd,
1655 NO_NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
1656 NO_STR
1657 NEIGHBOR_STR
1658 NEIGHBOR_ADDR_STR2
1659 "Advertise capability to the peer\n"
1660 "Advertise ORF capability to the peer\n"
1661 "Advertise prefixlist ORF capability to this neighbor\n"
1662 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
1663 "Capability to RECEIVE the ORF from this neighbor\n"
1664 "Capability to SEND the ORF to this neighbor\n")
1665{
1666 u_int16_t flag = 0;
1667
1668 if (strncmp (argv[1], "s", 1) == 0)
1669 flag = PEER_FLAG_ORF_PREFIX_SM;
1670 else if (strncmp (argv[1], "r", 1) == 0)
1671 flag = PEER_FLAG_ORF_PREFIX_RM;
1672 else if (strncmp (argv[1], "b", 1) == 0)
1673 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
1674 else
1675 return CMD_WARNING;
1676
1677 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1678 bgp_node_safi (vty), flag);
1679}
1680
1681/* neighbor next-hop-self. */
1682DEFUN (neighbor_nexthop_self,
1683 neighbor_nexthop_self_cmd,
1684 NEIGHBOR_CMD2 "next-hop-self",
1685 NEIGHBOR_STR
1686 NEIGHBOR_ADDR_STR2
1687 "Disable the next hop calculation for this neighbor\n")
1688{
1689 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1690 bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF);
1691}
1692
1693DEFUN (no_neighbor_nexthop_self,
1694 no_neighbor_nexthop_self_cmd,
1695 NO_NEIGHBOR_CMD2 "next-hop-self",
1696 NO_STR
1697 NEIGHBOR_STR
1698 NEIGHBOR_ADDR_STR2
1699 "Disable the next hop calculation for this neighbor\n")
1700{
1701 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1702 bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF);
1703}
1704
1705/* neighbor remove-private-AS. */
1706DEFUN (neighbor_remove_private_as,
1707 neighbor_remove_private_as_cmd,
1708 NEIGHBOR_CMD2 "remove-private-AS",
1709 NEIGHBOR_STR
1710 NEIGHBOR_ADDR_STR2
1711 "Remove private AS number from outbound updates\n")
1712{
1713 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1714 bgp_node_safi (vty),
1715 PEER_FLAG_REMOVE_PRIVATE_AS);
1716}
1717
1718DEFUN (no_neighbor_remove_private_as,
1719 no_neighbor_remove_private_as_cmd,
1720 NO_NEIGHBOR_CMD2 "remove-private-AS",
1721 NO_STR
1722 NEIGHBOR_STR
1723 NEIGHBOR_ADDR_STR2
1724 "Remove private AS number from outbound updates\n")
1725{
1726 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1727 bgp_node_safi (vty),
1728 PEER_FLAG_REMOVE_PRIVATE_AS);
1729}
1730
1731/* neighbor send-community. */
1732DEFUN (neighbor_send_community,
1733 neighbor_send_community_cmd,
1734 NEIGHBOR_CMD2 "send-community",
1735 NEIGHBOR_STR
1736 NEIGHBOR_ADDR_STR2
1737 "Send Community attribute to this neighbor\n")
1738{
1739 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1740 bgp_node_safi (vty),
1741 PEER_FLAG_SEND_COMMUNITY);
1742}
1743
1744DEFUN (no_neighbor_send_community,
1745 no_neighbor_send_community_cmd,
1746 NO_NEIGHBOR_CMD2 "send-community",
1747 NO_STR
1748 NEIGHBOR_STR
1749 NEIGHBOR_ADDR_STR2
1750 "Send Community attribute to this neighbor\n")
1751{
1752 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1753 bgp_node_safi (vty),
1754 PEER_FLAG_SEND_COMMUNITY);
1755}
1756
1757/* neighbor send-community extended. */
1758DEFUN (neighbor_send_community_type,
1759 neighbor_send_community_type_cmd,
1760 NEIGHBOR_CMD2 "send-community (both|extended|standard)",
1761 NEIGHBOR_STR
1762 NEIGHBOR_ADDR_STR2
1763 "Send Community attribute to this neighbor\n"
1764 "Send Standard and Extended Community attributes\n"
1765 "Send Extended Community attributes\n"
1766 "Send Standard Community attributes\n")
1767{
1768 if (strncmp (argv[1], "s", 1) == 0)
1769 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1770 bgp_node_safi (vty),
1771 PEER_FLAG_SEND_COMMUNITY);
1772 if (strncmp (argv[1], "e", 1) == 0)
1773 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1774 bgp_node_safi (vty),
1775 PEER_FLAG_SEND_EXT_COMMUNITY);
1776
1777 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1778 bgp_node_safi (vty),
1779 (PEER_FLAG_SEND_COMMUNITY|
1780 PEER_FLAG_SEND_EXT_COMMUNITY));
1781}
1782
1783DEFUN (no_neighbor_send_community_type,
1784 no_neighbor_send_community_type_cmd,
1785 NO_NEIGHBOR_CMD2 "send-community (both|extended|standard)",
1786 NO_STR
1787 NEIGHBOR_STR
1788 NEIGHBOR_ADDR_STR2
1789 "Send Community attribute to this neighbor\n"
1790 "Send Standard and Extended Community attributes\n"
1791 "Send Extended Community attributes\n"
1792 "Send Standard Community attributes\n")
1793{
1794 if (strncmp (argv[1], "s", 1) == 0)
1795 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1796 bgp_node_safi (vty),
1797 PEER_FLAG_SEND_COMMUNITY);
1798 if (strncmp (argv[1], "e", 1) == 0)
1799 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1800 bgp_node_safi (vty),
1801 PEER_FLAG_SEND_EXT_COMMUNITY);
1802
1803 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1804 bgp_node_safi (vty),
1805 (PEER_FLAG_SEND_COMMUNITY |
1806 PEER_FLAG_SEND_EXT_COMMUNITY));
1807}
1808
1809/* neighbor soft-reconfig. */
1810DEFUN (neighbor_soft_reconfiguration,
1811 neighbor_soft_reconfiguration_cmd,
1812 NEIGHBOR_CMD2 "soft-reconfiguration inbound",
1813 NEIGHBOR_STR
1814 NEIGHBOR_ADDR_STR2
1815 "Per neighbor soft reconfiguration\n"
1816 "Allow inbound soft reconfiguration for this neighbor\n")
1817{
1818 return peer_af_flag_set_vty (vty, argv[0],
1819 bgp_node_afi (vty), bgp_node_safi (vty),
1820 PEER_FLAG_SOFT_RECONFIG);
1821}
1822
1823DEFUN (no_neighbor_soft_reconfiguration,
1824 no_neighbor_soft_reconfiguration_cmd,
1825 NO_NEIGHBOR_CMD2 "soft-reconfiguration inbound",
1826 NO_STR
1827 NEIGHBOR_STR
1828 NEIGHBOR_ADDR_STR2
1829 "Per neighbor soft reconfiguration\n"
1830 "Allow inbound soft reconfiguration for this neighbor\n")
1831{
1832 return peer_af_flag_unset_vty (vty, argv[0],
1833 bgp_node_afi (vty), bgp_node_safi (vty),
1834 PEER_FLAG_SOFT_RECONFIG);
1835}
1836
1837DEFUN (neighbor_route_reflector_client,
1838 neighbor_route_reflector_client_cmd,
1839 NEIGHBOR_CMD2 "route-reflector-client",
1840 NEIGHBOR_STR
1841 NEIGHBOR_ADDR_STR2
1842 "Configure a neighbor as Route Reflector client\n")
1843{
1844 struct peer *peer;
1845
1846
1847 peer = peer_and_group_lookup_vty (vty, argv[0]);
1848 if (! peer)
1849 return CMD_WARNING;
1850
1851 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1852 bgp_node_safi (vty),
1853 PEER_FLAG_REFLECTOR_CLIENT);
1854}
1855
1856DEFUN (no_neighbor_route_reflector_client,
1857 no_neighbor_route_reflector_client_cmd,
1858 NO_NEIGHBOR_CMD2 "route-reflector-client",
1859 NO_STR
1860 NEIGHBOR_STR
1861 NEIGHBOR_ADDR_STR2
1862 "Configure a neighbor as Route Reflector client\n")
1863{
1864 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1865 bgp_node_safi (vty),
1866 PEER_FLAG_REFLECTOR_CLIENT);
1867}
1868
1869/* neighbor route-server-client. */
1870DEFUN (neighbor_route_server_client,
1871 neighbor_route_server_client_cmd,
1872 NEIGHBOR_CMD2 "route-server-client",
1873 NEIGHBOR_STR
1874 NEIGHBOR_ADDR_STR2
1875 "Configure a neighbor as Route Server client\n")
1876{
1877 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1878 bgp_node_safi (vty),
1879 PEER_FLAG_RSERVER_CLIENT);
1880}
1881
1882DEFUN (no_neighbor_route_server_client,
1883 no_neighbor_route_server_client_cmd,
1884 NO_NEIGHBOR_CMD2 "route-server-client",
1885 NO_STR
1886 NEIGHBOR_STR
1887 NEIGHBOR_ADDR_STR2
1888 "Configure a neighbor as Route Server client\n")
1889{
1890 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1891 bgp_node_safi (vty),
1892 PEER_FLAG_RSERVER_CLIENT);
1893}
1894
1895DEFUN (neighbor_attr_unchanged,
1896 neighbor_attr_unchanged_cmd,
1897 NEIGHBOR_CMD2 "attribute-unchanged",
1898 NEIGHBOR_STR
1899 NEIGHBOR_ADDR_STR2
1900 "BGP attribute is propagated unchanged to this neighbor\n")
1901{
1902 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1903 bgp_node_safi (vty),
1904 (PEER_FLAG_AS_PATH_UNCHANGED |
1905 PEER_FLAG_NEXTHOP_UNCHANGED |
1906 PEER_FLAG_MED_UNCHANGED));
1907}
1908
1909DEFUN (neighbor_attr_unchanged1,
1910 neighbor_attr_unchanged1_cmd,
1911 NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
1912 NEIGHBOR_STR
1913 NEIGHBOR_ADDR_STR2
1914 "BGP attribute is propagated unchanged to this neighbor\n"
1915 "As-path attribute\n"
1916 "Nexthop attribute\n"
1917 "Med attribute\n")
1918{
1919 u_int16_t flags = 0;
1920
1921 if (strncmp (argv[1], "as-path", 1) == 0)
1922 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
1923 else if (strncmp (argv[1], "next-hop", 1) == 0)
1924 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
1925 else if (strncmp (argv[1], "med", 1) == 0)
1926 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
1927
1928 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1929 bgp_node_safi (vty), flags);
1930}
1931
1932DEFUN (neighbor_attr_unchanged2,
1933 neighbor_attr_unchanged2_cmd,
1934 NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
1935 NEIGHBOR_STR
1936 NEIGHBOR_ADDR_STR2
1937 "BGP attribute is propagated unchanged to this neighbor\n"
1938 "As-path attribute\n"
1939 "Nexthop attribute\n"
1940 "Med attribute\n")
1941{
1942 u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
1943
1944 if (strncmp (argv[1], "next-hop", 1) == 0)
1945 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
1946 else if (strncmp (argv[1], "med", 1) == 0)
1947 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
1948
1949 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1950 bgp_node_safi (vty), flags);
1951
1952}
1953
1954DEFUN (neighbor_attr_unchanged3,
1955 neighbor_attr_unchanged3_cmd,
1956 NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
1957 NEIGHBOR_STR
1958 NEIGHBOR_ADDR_STR2
1959 "BGP attribute is propagated unchanged to this neighbor\n"
1960 "Nexthop attribute\n"
1961 "As-path attribute\n"
1962 "Med attribute\n")
1963{
1964 u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
1965
1966 if (strncmp (argv[1], "as-path", 1) == 0)
1967 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
1968 else if (strncmp (argv[1], "med", 1) == 0)
1969 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
1970
1971 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1972 bgp_node_safi (vty), flags);
1973}
1974
1975DEFUN (neighbor_attr_unchanged4,
1976 neighbor_attr_unchanged4_cmd,
1977 NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
1978 NEIGHBOR_STR
1979 NEIGHBOR_ADDR_STR2
1980 "BGP attribute is propagated unchanged to this neighbor\n"
1981 "Med attribute\n"
1982 "As-path attribute\n"
1983 "Nexthop attribute\n")
1984{
1985 u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
1986
1987 if (strncmp (argv[1], "as-path", 1) == 0)
1988 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
1989 else if (strncmp (argv[1], "next-hop", 1) == 0)
1990 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
1991
1992 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1993 bgp_node_safi (vty), flags);
1994}
1995
1996ALIAS (neighbor_attr_unchanged,
1997 neighbor_attr_unchanged5_cmd,
1998 NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
1999 NEIGHBOR_STR
2000 NEIGHBOR_ADDR_STR2
2001 "BGP attribute is propagated unchanged to this neighbor\n"
2002 "As-path attribute\n"
2003 "Nexthop attribute\n"
2004 "Med attribute\n")
2005
2006ALIAS (neighbor_attr_unchanged,
2007 neighbor_attr_unchanged6_cmd,
2008 NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
2009 NEIGHBOR_STR
2010 NEIGHBOR_ADDR_STR2
2011 "BGP attribute is propagated unchanged to this neighbor\n"
2012 "As-path attribute\n"
2013 "Med attribute\n"
2014 "Nexthop attribute\n")
2015
2016ALIAS (neighbor_attr_unchanged,
2017 neighbor_attr_unchanged7_cmd,
2018 NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
2019 NEIGHBOR_STR
2020 NEIGHBOR_ADDR_STR2
2021 "BGP attribute is propagated unchanged to this neighbor\n"
2022 "Nexthop attribute\n"
2023 "Med attribute\n"
2024 "As-path attribute\n")
2025
2026ALIAS (neighbor_attr_unchanged,
2027 neighbor_attr_unchanged8_cmd,
2028 NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
2029 NEIGHBOR_STR
2030 NEIGHBOR_ADDR_STR2
2031 "BGP attribute is propagated unchanged to this neighbor\n"
2032 "Nexthop attribute\n"
2033 "As-path attribute\n"
2034 "Med attribute\n")
2035
2036ALIAS (neighbor_attr_unchanged,
2037 neighbor_attr_unchanged9_cmd,
2038 NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
2039 NEIGHBOR_STR
2040 NEIGHBOR_ADDR_STR2
2041 "BGP attribute is propagated unchanged to this neighbor\n"
2042 "Med attribute\n"
2043 "Nexthop attribute\n"
2044 "As-path attribute\n")
2045
2046ALIAS (neighbor_attr_unchanged,
2047 neighbor_attr_unchanged10_cmd,
2048 NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
2049 NEIGHBOR_STR
2050 NEIGHBOR_ADDR_STR2
2051 "BGP attribute is propagated unchanged to this neighbor\n"
2052 "Med attribute\n"
2053 "As-path attribute\n"
2054 "Nexthop attribute\n")
2055
2056DEFUN (no_neighbor_attr_unchanged,
2057 no_neighbor_attr_unchanged_cmd,
2058 NO_NEIGHBOR_CMD2 "attribute-unchanged",
2059 NO_STR
2060 NEIGHBOR_STR
2061 NEIGHBOR_ADDR_STR2
2062 "BGP attribute is propagated unchanged to this neighbor\n")
2063{
2064 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2065 bgp_node_safi (vty),
2066 (PEER_FLAG_AS_PATH_UNCHANGED |
2067 PEER_FLAG_NEXTHOP_UNCHANGED |
2068 PEER_FLAG_MED_UNCHANGED));
2069}
2070
2071DEFUN (no_neighbor_attr_unchanged1,
2072 no_neighbor_attr_unchanged1_cmd,
2073 NO_NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
2074 NO_STR
2075 NEIGHBOR_STR
2076 NEIGHBOR_ADDR_STR2
2077 "BGP attribute is propagated unchanged to this neighbor\n"
2078 "As-path attribute\n"
2079 "Nexthop attribute\n"
2080 "Med attribute\n")
2081{
2082 u_int16_t flags = 0;
2083
2084 if (strncmp (argv[1], "as-path", 1) == 0)
2085 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2086 else if (strncmp (argv[1], "next-hop", 1) == 0)
2087 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2088 else if (strncmp (argv[1], "med", 1) == 0)
2089 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2090
2091 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2092 bgp_node_safi (vty), flags);
2093}
2094
2095DEFUN (no_neighbor_attr_unchanged2,
2096 no_neighbor_attr_unchanged2_cmd,
2097 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
2098 NO_STR
2099 NEIGHBOR_STR
2100 NEIGHBOR_ADDR_STR2
2101 "BGP attribute is propagated unchanged to this neighbor\n"
2102 "As-path attribute\n"
2103 "Nexthop attribute\n"
2104 "Med attribute\n")
2105{
2106 u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
2107
2108 if (strncmp (argv[1], "next-hop", 1) == 0)
2109 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2110 else if (strncmp (argv[1], "med", 1) == 0)
2111 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2112
2113 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2114 bgp_node_safi (vty), flags);
2115}
2116
2117DEFUN (no_neighbor_attr_unchanged3,
2118 no_neighbor_attr_unchanged3_cmd,
2119 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
2120 NO_STR
2121 NEIGHBOR_STR
2122 NEIGHBOR_ADDR_STR2
2123 "BGP attribute is propagated unchanged to this neighbor\n"
2124 "Nexthop attribute\n"
2125 "As-path attribute\n"
2126 "Med attribute\n")
2127{
2128 u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
2129
2130 if (strncmp (argv[1], "as-path", 1) == 0)
2131 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2132 else if (strncmp (argv[1], "med", 1) == 0)
2133 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2134
2135 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2136 bgp_node_safi (vty), flags);
2137}
2138
2139DEFUN (no_neighbor_attr_unchanged4,
2140 no_neighbor_attr_unchanged4_cmd,
2141 NO_NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
2142 NO_STR
2143 NEIGHBOR_STR
2144 NEIGHBOR_ADDR_STR2
2145 "BGP attribute is propagated unchanged to this neighbor\n"
2146 "Med attribute\n"
2147 "As-path attribute\n"
2148 "Nexthop attribute\n")
2149{
2150 u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
2151
2152 if (strncmp (argv[1], "as-path", 1) == 0)
2153 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2154 else if (strncmp (argv[1], "next-hop", 1) == 0)
2155 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2156
2157 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2158 bgp_node_safi (vty), flags);
2159}
2160
2161ALIAS (no_neighbor_attr_unchanged,
2162 no_neighbor_attr_unchanged5_cmd,
2163 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
2164 NO_STR
2165 NEIGHBOR_STR
2166 NEIGHBOR_ADDR_STR2
2167 "BGP attribute is propagated unchanged to this neighbor\n"
2168 "As-path attribute\n"
2169 "Nexthop attribute\n"
2170 "Med attribute\n")
2171
2172ALIAS (no_neighbor_attr_unchanged,
2173 no_neighbor_attr_unchanged6_cmd,
2174 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
2175 NO_STR
2176 NEIGHBOR_STR
2177 NEIGHBOR_ADDR_STR2
2178 "BGP attribute is propagated unchanged to this neighbor\n"
2179 "As-path attribute\n"
2180 "Med attribute\n"
2181 "Nexthop attribute\n")
2182
2183ALIAS (no_neighbor_attr_unchanged,
2184 no_neighbor_attr_unchanged7_cmd,
2185 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
2186 NO_STR
2187 NEIGHBOR_STR
2188 NEIGHBOR_ADDR_STR2
2189 "BGP attribute is propagated unchanged to this neighbor\n"
2190 "Nexthop attribute\n"
2191 "Med attribute\n"
2192 "As-path attribute\n")
2193
2194ALIAS (no_neighbor_attr_unchanged,
2195 no_neighbor_attr_unchanged8_cmd,
2196 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
2197 NO_STR
2198 NEIGHBOR_STR
2199 NEIGHBOR_ADDR_STR2
2200 "BGP attribute is propagated unchanged to this neighbor\n"
2201 "Nexthop attribute\n"
2202 "As-path attribute\n"
2203 "Med attribute\n")
2204
2205ALIAS (no_neighbor_attr_unchanged,
2206 no_neighbor_attr_unchanged9_cmd,
2207 NO_NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
2208 NO_STR
2209 NEIGHBOR_STR
2210 NEIGHBOR_ADDR_STR2
2211 "BGP attribute is propagated unchanged to this neighbor\n"
2212 "Med attribute\n"
2213 "Nexthop attribute\n"
2214 "As-path attribute\n")
2215
2216ALIAS (no_neighbor_attr_unchanged,
2217 no_neighbor_attr_unchanged10_cmd,
2218 NO_NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
2219 NO_STR
2220 NEIGHBOR_STR
2221 NEIGHBOR_ADDR_STR2
2222 "BGP attribute is propagated unchanged to this neighbor\n"
2223 "Med attribute\n"
2224 "As-path attribute\n"
2225 "Nexthop attribute\n")
2226
2227/* For old version Zebra compatibility. */
2228DEFUN (neighbor_transparent_as,
2229 neighbor_transparent_as_cmd,
2230 NEIGHBOR_CMD "transparent-as",
2231 NEIGHBOR_STR
2232 NEIGHBOR_ADDR_STR
2233 "Do not append my AS number even peer is EBGP peer\n")
2234{
2235 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2236 bgp_node_safi (vty),
2237 PEER_FLAG_AS_PATH_UNCHANGED);
2238}
2239
2240DEFUN (neighbor_transparent_nexthop,
2241 neighbor_transparent_nexthop_cmd,
2242 NEIGHBOR_CMD "transparent-nexthop",
2243 NEIGHBOR_STR
2244 NEIGHBOR_ADDR_STR
2245 "Do not change nexthop even peer is EBGP peer\n")
2246{
2247 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2248 bgp_node_safi (vty),
2249 PEER_FLAG_NEXTHOP_UNCHANGED);
2250}
2251
2252/* EBGP multihop configuration. */
2253int
2254peer_ebgp_multihop_set_vty (struct vty *vty, char *ip_str, char *ttl_str)
2255{
2256 struct peer *peer;
2257 int ttl;
2258
2259 peer = peer_and_group_lookup_vty (vty, ip_str);
2260 if (! peer)
2261 return CMD_WARNING;
2262
2263 if (! ttl_str)
2264 ttl = TTL_MAX;
2265 else
2266 VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, 255);
2267
2268 peer_ebgp_multihop_set (peer, ttl);
2269
2270 return CMD_SUCCESS;
2271}
2272
2273int
2274peer_ebgp_multihop_unset_vty (struct vty *vty, char *ip_str)
2275{
2276 struct peer *peer;
2277
2278 peer = peer_and_group_lookup_vty (vty, ip_str);
2279 if (! peer)
2280 return CMD_WARNING;
2281
2282 peer_ebgp_multihop_unset (peer);
2283
2284 return CMD_SUCCESS;
2285}
2286
2287/* neighbor ebgp-multihop. */
2288DEFUN (neighbor_ebgp_multihop,
2289 neighbor_ebgp_multihop_cmd,
2290 NEIGHBOR_CMD2 "ebgp-multihop",
2291 NEIGHBOR_STR
2292 NEIGHBOR_ADDR_STR2
2293 "Allow EBGP neighbors not on directly connected networks\n")
2294{
2295 return peer_ebgp_multihop_set_vty (vty, argv[0], NULL);
2296}
2297
2298DEFUN (neighbor_ebgp_multihop_ttl,
2299 neighbor_ebgp_multihop_ttl_cmd,
2300 NEIGHBOR_CMD2 "ebgp-multihop <1-255>",
2301 NEIGHBOR_STR
2302 NEIGHBOR_ADDR_STR2
2303 "Allow EBGP neighbors not on directly connected networks\n"
2304 "maximum hop count\n")
2305{
2306 return peer_ebgp_multihop_set_vty (vty, argv[0], argv[1]);
2307}
2308
2309DEFUN (no_neighbor_ebgp_multihop,
2310 no_neighbor_ebgp_multihop_cmd,
2311 NO_NEIGHBOR_CMD2 "ebgp-multihop",
2312 NO_STR
2313 NEIGHBOR_STR
2314 NEIGHBOR_ADDR_STR2
2315 "Allow EBGP neighbors not on directly connected networks\n")
2316{
2317 return peer_ebgp_multihop_unset_vty (vty, argv[0]);
2318}
2319
2320ALIAS (no_neighbor_ebgp_multihop,
2321 no_neighbor_ebgp_multihop_ttl_cmd,
2322 NO_NEIGHBOR_CMD2 "ebgp-multihop <1-255>",
2323 NO_STR
2324 NEIGHBOR_STR
2325 NEIGHBOR_ADDR_STR2
2326 "Allow EBGP neighbors not on directly connected networks\n"
2327 "maximum hop count\n")
2328
2329/* Enforce multihop. */
2330DEFUN (neighbor_enforce_multihop,
2331 neighbor_enforce_multihop_cmd,
2332 NEIGHBOR_CMD2 "enforce-multihop",
2333 NEIGHBOR_STR
2334 NEIGHBOR_ADDR_STR2
2335 "Enforce EBGP neighbors perform multihop\n")
2336{
2337 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_ENFORCE_MULTIHOP);
2338}
2339
2340DEFUN (no_neighbor_enforce_multihop,
2341 no_neighbor_enforce_multihop_cmd,
2342 NO_NEIGHBOR_CMD2 "enforce-multihop",
2343 NO_STR
2344 NEIGHBOR_STR
2345 NEIGHBOR_ADDR_STR2
2346 "Enforce EBGP neighbors perform multihop\n")
2347{
2348 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_ENFORCE_MULTIHOP);
2349}
2350
2351DEFUN (neighbor_description,
2352 neighbor_description_cmd,
2353 NEIGHBOR_CMD2 "description .LINE",
2354 NEIGHBOR_STR
2355 NEIGHBOR_ADDR_STR2
2356 "Neighbor specific description\n"
2357 "Up to 80 characters describing this neighbor\n")
2358{
2359 struct peer *peer;
2360 struct buffer *b;
2361 char *str;
2362 int i;
2363
2364 peer = peer_and_group_lookup_vty (vty, argv[0]);
2365 if (! peer)
2366 return CMD_WARNING;
2367
2368 if (argc == 1)
2369 return CMD_SUCCESS;
2370
2371 /* Make string from buffer. This function should be provided by
2372 buffer.c. */
2373 b = buffer_new (1024);
2374 for (i = 1; i < argc; i++)
2375 {
2376 buffer_putstr (b, (u_char *)argv[i]);
2377 buffer_putc (b, ' ');
2378 }
2379 buffer_putc (b, '\0');
2380 str = buffer_getstr (b);
2381 buffer_free (b);
2382
2383 peer_description_set (peer, str);
2384
2385 free (str);
2386
2387 return CMD_SUCCESS;
2388}
2389
2390DEFUN (no_neighbor_description,
2391 no_neighbor_description_cmd,
2392 NO_NEIGHBOR_CMD2 "description",
2393 NO_STR
2394 NEIGHBOR_STR
2395 NEIGHBOR_ADDR_STR2
2396 "Neighbor specific description\n")
2397{
2398 struct peer *peer;
2399
2400 peer = peer_and_group_lookup_vty (vty, argv[0]);
2401 if (! peer)
2402 return CMD_WARNING;
2403
2404 peer_description_unset (peer);
2405
2406 return CMD_SUCCESS;
2407}
2408
2409ALIAS (no_neighbor_description,
2410 no_neighbor_description_val_cmd,
2411 NO_NEIGHBOR_CMD2 "description .LINE",
2412 NO_STR
2413 NEIGHBOR_STR
2414 NEIGHBOR_ADDR_STR2
2415 "Neighbor specific description\n"
2416 "Up to 80 characters describing this neighbor\n")
2417
2418/* Neighbor update-source. */
2419int
2420peer_update_source_vty (struct vty *vty, char *peer_str, char *source_str)
2421{
2422 struct peer *peer;
2423 union sockunion *su;
2424
2425 peer = peer_and_group_lookup_vty (vty, peer_str);
2426 if (! peer)
2427 return CMD_WARNING;
2428
2429 if (source_str)
2430 {
2431 su = sockunion_str2su (source_str);
2432 if (su)
2433 {
2434 peer_update_source_addr_set (peer, su);
2435 sockunion_free (su);
2436 }
2437 else
2438 peer_update_source_if_set (peer, source_str);
2439 }
2440 else
2441 peer_update_source_unset (peer);
2442
2443 return CMD_SUCCESS;
2444}
2445
2446DEFUN (neighbor_update_source,
2447 neighbor_update_source_cmd,
2448 NEIGHBOR_CMD2 "update-source WORD",
2449 NEIGHBOR_STR
2450 NEIGHBOR_ADDR_STR2
2451 "Source of routing updates\n"
2452 "Interface name\n")
2453{
2454 return peer_update_source_vty (vty, argv[0], argv[1]);
2455}
2456
2457DEFUN (no_neighbor_update_source,
2458 no_neighbor_update_source_cmd,
2459 NO_NEIGHBOR_CMD2 "update-source",
2460 NO_STR
2461 NEIGHBOR_STR
2462 NEIGHBOR_ADDR_STR2
2463 "Source of routing updates\n"
2464 "Interface name\n")
2465{
2466 return peer_update_source_vty (vty, argv[0], NULL);
2467}
2468
2469int
2470peer_default_originate_set_vty (struct vty *vty, char *peer_str, afi_t afi,
2471 safi_t safi, char *rmap, int set)
2472{
2473 int ret;
2474 struct peer *peer;
2475
2476 peer = peer_and_group_lookup_vty (vty, peer_str);
2477 if (! peer)
2478 return CMD_WARNING;
2479
2480 if (set)
2481 ret = peer_default_originate_set (peer, afi, safi, rmap);
2482 else
2483 ret = peer_default_originate_unset (peer, afi, safi);
2484
2485 return bgp_vty_return (vty, ret);
2486}
2487
2488/* neighbor default-originate. */
2489DEFUN (neighbor_default_originate,
2490 neighbor_default_originate_cmd,
2491 NEIGHBOR_CMD2 "default-originate",
2492 NEIGHBOR_STR
2493 NEIGHBOR_ADDR_STR2
2494 "Originate default route to this neighbor\n")
2495{
2496 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
2497 bgp_node_safi (vty), NULL, 1);
2498}
2499
2500DEFUN (neighbor_default_originate_rmap,
2501 neighbor_default_originate_rmap_cmd,
2502 NEIGHBOR_CMD2 "default-originate route-map WORD",
2503 NEIGHBOR_STR
2504 NEIGHBOR_ADDR_STR2
2505 "Originate default route to this neighbor\n"
2506 "Route-map to specify criteria to originate default\n"
2507 "route-map name\n")
2508{
2509 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
2510 bgp_node_safi (vty), argv[1], 1);
2511}
2512
2513DEFUN (no_neighbor_default_originate,
2514 no_neighbor_default_originate_cmd,
2515 NO_NEIGHBOR_CMD2 "default-originate",
2516 NO_STR
2517 NEIGHBOR_STR
2518 NEIGHBOR_ADDR_STR2
2519 "Originate default route to this neighbor\n")
2520{
2521 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
2522 bgp_node_safi (vty), NULL, 0);
2523}
2524
2525ALIAS (no_neighbor_default_originate,
2526 no_neighbor_default_originate_rmap_cmd,
2527 NO_NEIGHBOR_CMD2 "default-originate route-map WORD",
2528 NO_STR
2529 NEIGHBOR_STR
2530 NEIGHBOR_ADDR_STR2
2531 "Originate default route to this neighbor\n"
2532 "Route-map to specify criteria to originate default\n"
2533 "route-map name\n")
2534
2535/* Set neighbor's BGP port. */
2536int
2537peer_port_vty (struct vty *vty, char *ip_str, int afi, char *port_str)
2538{
2539 struct peer *peer;
2540 u_int16_t port;
2541 struct servent *sp;
2542
2543 peer = peer_lookup_vty (vty, ip_str);
2544 if (! peer)
2545 return CMD_WARNING;
2546
2547 if (! port_str)
2548 {
2549 sp = getservbyname ("bgp", "tcp");
2550 port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port);
2551 }
2552 else
2553 {
2554 VTY_GET_INTEGER("port", port, port_str);
2555 }
2556
2557 peer_port_set (peer, port);
2558
2559 return CMD_SUCCESS;
2560}
2561
2562/* Set specified peer's BGP version. */
2563DEFUN (neighbor_port,
2564 neighbor_port_cmd,
2565 NEIGHBOR_CMD "port <0-65535>",
2566 NEIGHBOR_STR
2567 NEIGHBOR_ADDR_STR
2568 "Neighbor's BGP port\n"
2569 "TCP port number\n")
2570{
2571 return peer_port_vty (vty, argv[0], AFI_IP, argv[1]);
2572}
2573
2574DEFUN (no_neighbor_port,
2575 no_neighbor_port_cmd,
2576 NO_NEIGHBOR_CMD "port",
2577 NO_STR
2578 NEIGHBOR_STR
2579 NEIGHBOR_ADDR_STR
2580 "Neighbor's BGP port\n")
2581{
2582 return peer_port_vty (vty, argv[0], AFI_IP, NULL);
2583}
2584
2585ALIAS (no_neighbor_port,
2586 no_neighbor_port_val_cmd,
2587 NO_NEIGHBOR_CMD "port <0-65535>",
2588 NO_STR
2589 NEIGHBOR_STR
2590 NEIGHBOR_ADDR_STR
2591 "Neighbor's BGP port\n"
2592 "TCP port number\n")
2593
2594/* neighbor weight. */
2595int
2596peer_weight_set_vty (struct vty *vty, char *ip_str, char *weight_str)
2597{
2598 int ret;
2599 struct peer *peer;
2600 unsigned long weight;
2601
2602 peer = peer_and_group_lookup_vty (vty, ip_str);
2603 if (! peer)
2604 return CMD_WARNING;
2605
2606 VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535);
2607
2608 ret = peer_weight_set (peer, weight);
2609
2610 return CMD_SUCCESS;
2611}
2612
2613int
2614peer_weight_unset_vty (struct vty *vty, char *ip_str)
2615{
2616 struct peer *peer;
2617
2618 peer = peer_and_group_lookup_vty (vty, ip_str);
2619 if (! peer)
2620 return CMD_WARNING;
2621
2622 peer_weight_unset (peer);
2623
2624 return CMD_SUCCESS;
2625}
2626
2627DEFUN (neighbor_weight,
2628 neighbor_weight_cmd,
2629 NEIGHBOR_CMD2 "weight <0-65535>",
2630 NEIGHBOR_STR
2631 NEIGHBOR_ADDR_STR2
2632 "Set default weight for routes from this neighbor\n"
2633 "default weight\n")
2634{
2635 return peer_weight_set_vty (vty, argv[0], argv[1]);
2636}
2637
2638DEFUN (no_neighbor_weight,
2639 no_neighbor_weight_cmd,
2640 NO_NEIGHBOR_CMD2 "weight",
2641 NO_STR
2642 NEIGHBOR_STR
2643 NEIGHBOR_ADDR_STR2
2644 "Set default weight for routes from this neighbor\n")
2645{
2646 return peer_weight_unset_vty (vty, argv[0]);
2647}
2648
2649ALIAS (no_neighbor_weight,
2650 no_neighbor_weight_val_cmd,
2651 NO_NEIGHBOR_CMD2 "weight <0-65535>",
2652 NO_STR
2653 NEIGHBOR_STR
2654 NEIGHBOR_ADDR_STR2
2655 "Set default weight for routes from this neighbor\n"
2656 "default weight\n")
2657
2658/* Override capability negotiation. */
2659DEFUN (neighbor_override_capability,
2660 neighbor_override_capability_cmd,
2661 NEIGHBOR_CMD2 "override-capability",
2662 NEIGHBOR_STR
2663 NEIGHBOR_ADDR_STR2
2664 "Override capability negotiation result\n")
2665{
2666 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
2667}
2668
2669DEFUN (no_neighbor_override_capability,
2670 no_neighbor_override_capability_cmd,
2671 NO_NEIGHBOR_CMD2 "override-capability",
2672 NO_STR
2673 NEIGHBOR_STR
2674 NEIGHBOR_ADDR_STR2
2675 "Override capability negotiation result\n")
2676{
2677 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
2678}
2679
2680DEFUN (neighbor_strict_capability,
2681 neighbor_strict_capability_cmd,
2682 NEIGHBOR_CMD "strict-capability-match",
2683 NEIGHBOR_STR
2684 NEIGHBOR_ADDR_STR
2685 "Strict capability negotiation match\n")
2686{
2687 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
2688}
2689
2690DEFUN (no_neighbor_strict_capability,
2691 no_neighbor_strict_capability_cmd,
2692 NO_NEIGHBOR_CMD "strict-capability-match",
2693 NO_STR
2694 NEIGHBOR_STR
2695 NEIGHBOR_ADDR_STR
2696 "Strict capability negotiation match\n")
2697{
2698 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
2699}
2700
2701int
2702peer_timers_set_vty (struct vty *vty, char *ip_str, char *keep_str,
2703 char *hold_str)
2704{
2705 int ret;
2706 struct peer *peer;
2707 u_int32_t keepalive;
2708 u_int32_t holdtime;
2709
2710 peer = peer_and_group_lookup_vty (vty, ip_str);
2711 if (! peer)
2712 return CMD_WARNING;
2713
2714 VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535);
2715 VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535);
2716
2717 ret = peer_timers_set (peer, keepalive, holdtime);
2718
2719 return bgp_vty_return (vty, ret);
2720}
2721
2722int
2723peer_timers_unset_vty (struct vty *vty, char *ip_str)
2724{
2725 int ret;
2726 struct peer *peer;
2727
2728 peer = peer_lookup_vty (vty, ip_str);
2729 if (! peer)
2730 return CMD_WARNING;
2731
2732 ret = peer_timers_unset (peer);
2733
2734 return bgp_vty_return (vty, ret);
2735}
2736
2737DEFUN (neighbor_timers,
2738 neighbor_timers_cmd,
2739 NEIGHBOR_CMD2 "timers <0-65535> <0-65535>",
2740 NEIGHBOR_STR
2741 NEIGHBOR_ADDR_STR2
2742 "BGP per neighbor timers\n"
2743 "Keepalive interval\n"
2744 "Holdtime\n")
2745{
2746 return peer_timers_set_vty (vty, argv[0], argv[1], argv[2]);
2747}
2748
2749DEFUN (no_neighbor_timers,
2750 no_neighbor_timers_cmd,
2751 NO_NEIGHBOR_CMD2 "timers",
2752 NO_STR
2753 NEIGHBOR_STR
2754 NEIGHBOR_ADDR_STR2
2755 "BGP per neighbor timers\n")
2756{
2757 return peer_timers_unset_vty (vty, argv[0]);
2758}
2759
2760int
2761peer_timers_connect_set_vty (struct vty *vty, char *ip_str, char *time_str)
2762{
2763 int ret;
2764 struct peer *peer;
2765 u_int32_t connect;
2766
2767 peer = peer_lookup_vty (vty, ip_str);
2768 if (! peer)
2769 return CMD_WARNING;
2770
2771 VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535);
2772
2773 ret = peer_timers_connect_set (peer, connect);
2774
2775 return CMD_SUCCESS;
2776}
2777
2778int
2779peer_timers_connect_unset_vty (struct vty *vty, char *ip_str)
2780{
2781 int ret;
2782 struct peer *peer;
2783
2784 peer = peer_and_group_lookup_vty (vty, ip_str);
2785 if (! peer)
2786 return CMD_WARNING;
2787
2788 ret = peer_timers_connect_unset (peer);
2789
2790 return CMD_SUCCESS;
2791}
2792
2793DEFUN (neighbor_timers_connect,
2794 neighbor_timers_connect_cmd,
2795 NEIGHBOR_CMD "timers connect <0-65535>",
2796 NEIGHBOR_STR
2797 NEIGHBOR_ADDR_STR
2798 "BGP per neighbor timers\n"
2799 "BGP connect timer\n"
2800 "Connect timer\n")
2801{
2802 return peer_timers_connect_set_vty (vty, argv[0], argv[1]);
2803}
2804
2805DEFUN (no_neighbor_timers_connect,
2806 no_neighbor_timers_connect_cmd,
2807 NO_NEIGHBOR_CMD "timers connect",
2808 NO_STR
2809 NEIGHBOR_STR
2810 NEIGHBOR_ADDR_STR
2811 "BGP per neighbor timers\n"
2812 "BGP connect timer\n")
2813{
2814 return peer_timers_connect_unset_vty (vty, argv[0]);
2815}
2816
2817ALIAS (no_neighbor_timers_connect,
2818 no_neighbor_timers_connect_val_cmd,
2819 NO_NEIGHBOR_CMD "timers connect <0-65535>",
2820 NO_STR
2821 NEIGHBOR_STR
2822 NEIGHBOR_ADDR_STR
2823 "BGP per neighbor timers\n"
2824 "BGP connect timer\n"
2825 "Connect timer\n")
2826
2827int
2828peer_advertise_interval_vty (struct vty *vty, char *ip_str, char *time_str,
2829 int set)
2830{
2831 int ret;
2832 struct peer *peer;
2833 u_int32_t routeadv = 0;
2834
2835 peer = peer_lookup_vty (vty, ip_str);
2836 if (! peer)
2837 return CMD_WARNING;
2838
2839 if (time_str)
2840 VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600);
2841
2842 if (set)
2843 ret = peer_advertise_interval_set (peer, routeadv);
2844 else
2845 ret = peer_advertise_interval_unset (peer);
2846
2847 return CMD_SUCCESS;
2848}
2849
2850DEFUN (neighbor_advertise_interval,
2851 neighbor_advertise_interval_cmd,
2852 NEIGHBOR_CMD "advertisement-interval <0-600>",
2853 NEIGHBOR_STR
2854 NEIGHBOR_ADDR_STR
2855 "Minimum interval between sending BGP routing updates\n"
2856 "time in seconds\n")
2857{
2858 return peer_advertise_interval_vty (vty, argv[0], argv[1], 1);
2859}
2860
2861DEFUN (no_neighbor_advertise_interval,
2862 no_neighbor_advertise_interval_cmd,
2863 NO_NEIGHBOR_CMD "advertisement-interval",
2864 NO_STR
2865 NEIGHBOR_STR
2866 NEIGHBOR_ADDR_STR
2867 "Minimum interval between sending BGP routing updates\n")
2868{
2869 return peer_advertise_interval_vty (vty, argv[0], NULL, 0);
2870}
2871
2872ALIAS (no_neighbor_advertise_interval,
2873 no_neighbor_advertise_interval_val_cmd,
2874 NO_NEIGHBOR_CMD "advertisement-interval <0-600>",
2875 NO_STR
2876 NEIGHBOR_STR
2877 NEIGHBOR_ADDR_STR
2878 "Minimum interval between sending BGP routing updates\n"
2879 "time in seconds\n")
2880
2881int
2882peer_version_vty (struct vty *vty, char *ip_str, char *str)
2883{
2884 int ret;
2885 struct peer *peer;
2886 int version = BGP_VERSION_4;
2887
2888 peer = peer_lookup_vty (vty, ip_str);
2889 if (! peer)
2890 return CMD_WARNING;
2891
2892 /* BGP version string check. */
2893 if (str)
2894 {
2895 if (strcmp (str, "4") == 0)
2896 version = BGP_VERSION_4;
2897 else if (strcmp (str, "4-") == 0)
2898 version = BGP_VERSION_MP_4_DRAFT_00;
2899
2900 ret = peer_version_set (peer, version);
2901 }
2902 else
2903 ret = peer_version_unset (peer);
2904
2905 return CMD_SUCCESS;
2906}
2907
2908DEFUN (neighbor_version,
2909 neighbor_version_cmd,
2910 NEIGHBOR_CMD "version (4|4-)",
2911 NEIGHBOR_STR
2912 NEIGHBOR_ADDR_STR
2913 "Neighbor's BGP version\n"
2914 "Border Gateway Protocol 4\n"
2915 "Multiprotocol Extensions for BGP-4(Old Draft)\n")
2916{
2917 return peer_version_vty (vty, argv[0], argv[1]);
2918}
2919
2920DEFUN (no_neighbor_version,
2921 no_neighbor_version_cmd,
2922 NO_NEIGHBOR_CMD "version",
2923 NO_STR
2924 NEIGHBOR_STR
2925 NEIGHBOR_ADDR_STR
2926 "Neighbor's BGP version\n")
2927{
2928 return peer_version_vty (vty, argv[0], NULL);
2929}
2930
2931/* neighbor interface */
2932int
2933peer_interface_vty (struct vty *vty, char *ip_str, char *str)
2934{
2935 int ret;
2936 struct peer *peer;
2937
2938 peer = peer_lookup_vty (vty, ip_str);
2939 if (! peer)
2940 return CMD_WARNING;
2941
2942 if (str)
2943 ret = peer_interface_set (peer, str);
2944 else
2945 ret = peer_interface_unset (peer);
2946
2947 return CMD_SUCCESS;
2948}
2949
2950DEFUN (neighbor_interface,
2951 neighbor_interface_cmd,
2952 NEIGHBOR_CMD "interface WORD",
2953 NEIGHBOR_STR
2954 NEIGHBOR_ADDR_STR
2955 "Interface\n"
2956 "Interface name\n")
2957{
2958 return peer_interface_vty (vty, argv[0], argv[1]);
2959}
2960
2961DEFUN (no_neighbor_interface,
2962 no_neighbor_interface_cmd,
2963 NO_NEIGHBOR_CMD "interface WORD",
2964 NO_STR
2965 NEIGHBOR_STR
2966 NEIGHBOR_ADDR_STR
2967 "Interface\n"
2968 "Interface name\n")
2969{
2970 return peer_interface_vty (vty, argv[0], NULL);
2971}
2972
2973/* Set distribute list to the peer. */
2974int
2975peer_distribute_set_vty (struct vty *vty, char *ip_str, afi_t afi, safi_t safi,
2976 char *name_str, char *direct_str)
2977{
2978 int ret;
2979 struct peer *peer;
2980 int direct = FILTER_IN;
2981
2982 peer = peer_and_group_lookup_vty (vty, ip_str);
2983 if (! peer)
2984 return CMD_WARNING;
2985
2986 /* Check filter direction. */
2987 if (strncmp (direct_str, "i", 1) == 0)
2988 direct = FILTER_IN;
2989 else if (strncmp (direct_str, "o", 1) == 0)
2990 direct = FILTER_OUT;
2991
2992 ret = peer_distribute_set (peer, afi, safi, direct, name_str);
2993
2994 return bgp_vty_return (vty, ret);
2995}
2996
2997int
2998peer_distribute_unset_vty (struct vty *vty, char *ip_str, afi_t afi,
2999 safi_t safi, char *direct_str)
3000{
3001 int ret;
3002 struct peer *peer;
3003 int direct = FILTER_IN;
3004
3005 peer = peer_and_group_lookup_vty (vty, ip_str);
3006 if (! peer)
3007 return CMD_WARNING;
3008
3009 /* Check filter direction. */
3010 if (strncmp (direct_str, "i", 1) == 0)
3011 direct = FILTER_IN;
3012 else if (strncmp (direct_str, "o", 1) == 0)
3013 direct = FILTER_OUT;
3014
3015 ret = peer_distribute_unset (peer, afi, safi, direct);
3016
3017 return bgp_vty_return (vty, ret);
3018}
3019
3020DEFUN (neighbor_distribute_list,
3021 neighbor_distribute_list_cmd,
3022 NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
3023 NEIGHBOR_STR
3024 NEIGHBOR_ADDR_STR2
3025 "Filter updates to/from this neighbor\n"
3026 "IP access-list number\n"
3027 "IP access-list number (expanded range)\n"
3028 "IP Access-list name\n"
3029 "Filter incoming updates\n"
3030 "Filter outgoing updates\n")
3031{
3032 return peer_distribute_set_vty (vty, argv[0], bgp_node_afi (vty),
3033 bgp_node_safi (vty), argv[1], argv[2]);
3034}
3035
3036DEFUN (no_neighbor_distribute_list,
3037 no_neighbor_distribute_list_cmd,
3038 NO_NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
3039 NO_STR
3040 NEIGHBOR_STR
3041 NEIGHBOR_ADDR_STR2
3042 "Filter updates to/from this neighbor\n"
3043 "IP access-list number\n"
3044 "IP access-list number (expanded range)\n"
3045 "IP Access-list name\n"
3046 "Filter incoming updates\n"
3047 "Filter outgoing updates\n")
3048{
3049 return peer_distribute_unset_vty (vty, argv[0], bgp_node_afi (vty),
3050 bgp_node_safi (vty), argv[2]);
3051}
3052
3053/* Set prefix list to the peer. */
3054int
3055peer_prefix_list_set_vty (struct vty *vty, char *ip_str, afi_t afi,
3056 safi_t safi, char *name_str, char *direct_str)
3057{
3058 int ret;
3059 struct peer *peer;
3060 int direct = FILTER_IN;
3061
3062 peer = peer_and_group_lookup_vty (vty, ip_str);
3063 if (! peer)
3064 return CMD_WARNING;
3065
3066 /* Check filter direction. */
3067 if (strncmp (direct_str, "i", 1) == 0)
3068 direct = FILTER_IN;
3069 else if (strncmp (direct_str, "o", 1) == 0)
3070 direct = FILTER_OUT;
3071
3072 ret = peer_prefix_list_set (peer, afi, safi, direct, name_str);
3073
3074 return bgp_vty_return (vty, ret);
3075}
3076
3077int
3078peer_prefix_list_unset_vty (struct vty *vty, char *ip_str, afi_t afi,
3079 safi_t safi, char *direct_str)
3080{
3081 int ret;
3082 struct peer *peer;
3083 int direct = FILTER_IN;
3084
3085 peer = peer_and_group_lookup_vty (vty, ip_str);
3086 if (! peer)
3087 return CMD_WARNING;
3088
3089 /* Check filter direction. */
3090 if (strncmp (direct_str, "i", 1) == 0)
3091 direct = FILTER_IN;
3092 else if (strncmp (direct_str, "o", 1) == 0)
3093 direct = FILTER_OUT;
3094
3095 ret = peer_prefix_list_unset (peer, afi, safi, direct);
3096
3097 return bgp_vty_return (vty, ret);
3098}
3099
3100DEFUN (neighbor_prefix_list,
3101 neighbor_prefix_list_cmd,
3102 NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
3103 NEIGHBOR_STR
3104 NEIGHBOR_ADDR_STR2
3105 "Filter updates to/from this neighbor\n"
3106 "Name of a prefix list\n"
3107 "Filter incoming updates\n"
3108 "Filter outgoing updates\n")
3109{
3110 return peer_prefix_list_set_vty (vty, argv[0], bgp_node_afi (vty),
3111 bgp_node_safi (vty), argv[1], argv[2]);
3112}
3113
3114DEFUN (no_neighbor_prefix_list,
3115 no_neighbor_prefix_list_cmd,
3116 NO_NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
3117 NO_STR
3118 NEIGHBOR_STR
3119 NEIGHBOR_ADDR_STR2
3120 "Filter updates to/from this neighbor\n"
3121 "Name of a prefix list\n"
3122 "Filter incoming updates\n"
3123 "Filter outgoing updates\n")
3124{
3125 return peer_prefix_list_unset_vty (vty, argv[0], bgp_node_afi (vty),
3126 bgp_node_safi (vty), argv[2]);
3127}
3128
3129int
3130peer_aslist_set_vty (struct vty *vty, char *ip_str, afi_t afi, safi_t safi,
3131 char *name_str, char *direct_str)
3132{
3133 int ret;
3134 struct peer *peer;
3135 int direct = FILTER_IN;
3136
3137 peer = peer_and_group_lookup_vty (vty, ip_str);
3138 if (! peer)
3139 return CMD_WARNING;
3140
3141 /* Check filter direction. */
3142 if (strncmp (direct_str, "i", 1) == 0)
3143 direct = FILTER_IN;
3144 else if (strncmp (direct_str, "o", 1) == 0)
3145 direct = FILTER_OUT;
3146
3147 ret = peer_aslist_set (peer, afi, safi, direct, name_str);
3148
3149 return bgp_vty_return (vty, ret);
3150}
3151
3152int
3153peer_aslist_unset_vty (struct vty *vty, char *ip_str, afi_t afi, safi_t safi,
3154 char *direct_str)
3155{
3156 int ret;
3157 struct peer *peer;
3158 int direct = FILTER_IN;
3159
3160 peer = peer_and_group_lookup_vty (vty, ip_str);
3161 if (! peer)
3162 return CMD_WARNING;
3163
3164 /* Check filter direction. */
3165 if (strncmp (direct_str, "i", 1) == 0)
3166 direct = FILTER_IN;
3167 else if (strncmp (direct_str, "o", 1) == 0)
3168 direct = FILTER_OUT;
3169
3170 ret = peer_aslist_unset (peer, afi, safi, direct);
3171
3172 return bgp_vty_return (vty, ret);
3173}
3174
3175DEFUN (neighbor_filter_list,
3176 neighbor_filter_list_cmd,
3177 NEIGHBOR_CMD2 "filter-list WORD (in|out)",
3178 NEIGHBOR_STR
3179 NEIGHBOR_ADDR_STR2
3180 "Establish BGP filters\n"
3181 "AS path access-list name\n"
3182 "Filter incoming routes\n"
3183 "Filter outgoing routes\n")
3184{
3185 return peer_aslist_set_vty (vty, argv[0], bgp_node_afi (vty),
3186 bgp_node_safi (vty), argv[1], argv[2]);
3187}
3188
3189DEFUN (no_neighbor_filter_list,
3190 no_neighbor_filter_list_cmd,
3191 NO_NEIGHBOR_CMD2 "filter-list WORD (in|out)",
3192 NO_STR
3193 NEIGHBOR_STR
3194 NEIGHBOR_ADDR_STR2
3195 "Establish BGP filters\n"
3196 "AS path access-list name\n"
3197 "Filter incoming routes\n"
3198 "Filter outgoing routes\n")
3199{
3200 return peer_aslist_unset_vty (vty, argv[0], bgp_node_afi (vty),
3201 bgp_node_safi (vty), argv[2]);
3202}
3203
3204/* Set route-map to the peer. */
3205int
3206peer_route_map_set_vty (struct vty *vty, char *ip_str, afi_t afi, safi_t safi,
3207 char *name_str, char *direct_str)
3208{
3209 int ret;
3210 struct peer *peer;
3211 int direct = FILTER_IN;
3212
3213 peer = peer_and_group_lookup_vty (vty, ip_str);
3214 if (! peer)
3215 return CMD_WARNING;
3216
3217 /* Check filter direction. */
3218 if (strncmp (direct_str, "i", 1) == 0)
3219 direct = FILTER_IN;
3220 else if (strncmp (direct_str, "o", 1) == 0)
3221 direct = FILTER_OUT;
3222
3223 ret = peer_route_map_set (peer, afi, safi, direct, name_str);
3224
3225 return bgp_vty_return (vty, ret);
3226}
3227
3228int
3229peer_route_map_unset_vty (struct vty *vty, char *ip_str, afi_t afi,
3230 safi_t safi, char *direct_str)
3231{
3232 int ret;
3233 struct peer *peer;
3234 int direct = FILTER_IN;
3235
3236 peer = peer_and_group_lookup_vty (vty, ip_str);
3237 if (! peer)
3238 return CMD_WARNING;
3239
3240 /* Check filter direction. */
3241 if (strncmp (direct_str, "i", 1) == 0)
3242 direct = FILTER_IN;
3243 else if (strncmp (direct_str, "o", 1) == 0)
3244
3245 direct = FILTER_OUT;
3246
3247 ret = peer_route_map_unset (peer, afi, safi, direct);
3248
3249 return bgp_vty_return (vty, ret);
3250}
3251
3252DEFUN (neighbor_route_map,
3253 neighbor_route_map_cmd,
3254 NEIGHBOR_CMD2 "route-map WORD (in|out)",
3255 NEIGHBOR_STR
3256 NEIGHBOR_ADDR_STR2
3257 "Apply route map to neighbor\n"
3258 "Name of route map\n"
3259 "Apply map to incoming routes\n"
3260 "Apply map to outbound routes\n")
3261{
3262 return peer_route_map_set_vty (vty, argv[0], bgp_node_afi (vty),
3263 bgp_node_safi (vty), argv[1], argv[2]);
3264}
3265
3266DEFUN (no_neighbor_route_map,
3267 no_neighbor_route_map_cmd,
3268 NO_NEIGHBOR_CMD2 "route-map WORD (in|out)",
3269 NO_STR
3270 NEIGHBOR_STR
3271 NEIGHBOR_ADDR_STR2
3272 "Apply route map to neighbor\n"
3273 "Name of route map\n"
3274 "Apply map to incoming routes\n"
3275 "Apply map to outbound routes\n")
3276{
3277 return peer_route_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
3278 bgp_node_safi (vty), argv[2]);
3279}
3280
3281/* Set unsuppress-map to the peer. */
3282int
3283peer_unsuppress_map_set_vty (struct vty *vty, char *ip_str, afi_t afi,
3284 safi_t safi, char *name_str)
3285{
3286 int ret;
3287 struct peer *peer;
3288
3289 peer = peer_and_group_lookup_vty (vty, ip_str);
3290 if (! peer)
3291 return CMD_WARNING;
3292
3293 ret = peer_unsuppress_map_set (peer, afi, safi, name_str);
3294
3295 return bgp_vty_return (vty, ret);
3296}
3297
3298/* Unset route-map from the peer. */
3299int
3300peer_unsuppress_map_unset_vty (struct vty *vty, char *ip_str, afi_t afi,
3301 safi_t safi)
3302{
3303 int ret;
3304 struct peer *peer;
3305
3306 peer = peer_and_group_lookup_vty (vty, ip_str);
3307 if (! peer)
3308 return CMD_WARNING;
3309
3310 ret = peer_unsuppress_map_unset (peer, afi, safi);
3311
3312 return bgp_vty_return (vty, ret);
3313}
3314
3315DEFUN (neighbor_unsuppress_map,
3316 neighbor_unsuppress_map_cmd,
3317 NEIGHBOR_CMD2 "unsuppress-map WORD",
3318 NEIGHBOR_STR
3319 NEIGHBOR_ADDR_STR2
3320 "Route-map to selectively unsuppress suppressed routes\n"
3321 "Name of route map\n")
3322{
3323 return peer_unsuppress_map_set_vty (vty, argv[0], bgp_node_afi (vty),
3324 bgp_node_safi (vty), argv[1]);
3325}
3326
3327DEFUN (no_neighbor_unsuppress_map,
3328 no_neighbor_unsuppress_map_cmd,
3329 NO_NEIGHBOR_CMD2 "unsuppress-map WORD",
3330 NO_STR
3331 NEIGHBOR_STR
3332 NEIGHBOR_ADDR_STR2
3333 "Route-map to selectively unsuppress suppressed routes\n"
3334 "Name of route map\n")
3335{
3336 return peer_unsuppress_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
3337 bgp_node_safi (vty));
3338}
3339
3340int
3341peer_maximum_prefix_set_vty (struct vty *vty, char *ip_str, afi_t afi,
3342 safi_t safi, char *num_str, int warning)
3343{
3344 int ret;
3345 struct peer *peer;
3346 u_int32_t max;
3347
3348 peer = peer_and_group_lookup_vty (vty, ip_str);
3349 if (! peer)
3350 return CMD_WARNING;
3351
3352 VTY_GET_INTEGER ("maxmum number", max, num_str);
3353
3354 ret = peer_maximum_prefix_set (peer, afi, safi, max, warning);
3355
3356 return bgp_vty_return (vty, ret);
3357}
3358
3359int
3360peer_maximum_prefix_unset_vty (struct vty *vty, char *ip_str, afi_t afi,
3361 safi_t safi)
3362{
3363 int ret;
3364 struct peer *peer;
3365
3366 peer = peer_and_group_lookup_vty (vty, ip_str);
3367 if (! peer)
3368 return CMD_WARNING;
3369
3370 ret = peer_maximum_prefix_unset (peer, afi, safi);
3371
3372 return bgp_vty_return (vty, ret);
3373}
3374
3375/* Maximum number of prefix configuration. prefix count is different
3376 for each peer configuration. So this configuration can be set for
3377 each peer configuration. */
3378DEFUN (neighbor_maximum_prefix,
3379 neighbor_maximum_prefix_cmd,
3380 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
3381 NEIGHBOR_STR
3382 NEIGHBOR_ADDR_STR2
3383 "Maximum number of prefix accept from this peer\n"
3384 "maximum no. of prefix limit\n")
3385{
3386 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
3387 bgp_node_safi (vty), argv[1], 0);
3388}
3389
3390DEFUN (neighbor_maximum_prefix_warning,
3391 neighbor_maximum_prefix_warning_cmd,
3392 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
3393 NEIGHBOR_STR
3394 NEIGHBOR_ADDR_STR2
3395 "Maximum number of prefix accept from this peer\n"
3396 "maximum no. of prefix limit\n"
3397 "Only give warning message when limit is exceeded\n")
3398{
3399 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
3400 bgp_node_safi (vty), argv[1], 1);
3401}
3402
3403DEFUN (no_neighbor_maximum_prefix,
3404 no_neighbor_maximum_prefix_cmd,
3405 NO_NEIGHBOR_CMD2 "maximum-prefix",
3406 NO_STR
3407 NEIGHBOR_STR
3408 NEIGHBOR_ADDR_STR2
3409 "Maximum number of prefix accept from this peer\n")
3410{
3411 return peer_maximum_prefix_unset_vty (vty, argv[0], bgp_node_afi (vty),
3412 bgp_node_safi (vty));
3413}
3414
3415ALIAS (no_neighbor_maximum_prefix,
3416 no_neighbor_maximum_prefix_val_cmd,
3417 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
3418 NO_STR
3419 NEIGHBOR_STR
3420 NEIGHBOR_ADDR_STR2
3421 "Maximum number of prefix accept from this peer\n"
3422 "maximum no. of prefix limit\n")
3423
3424ALIAS (no_neighbor_maximum_prefix,
3425 no_neighbor_maximum_prefix_val2_cmd,
3426 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
3427 NO_STR
3428 NEIGHBOR_STR
3429 NEIGHBOR_ADDR_STR2
3430 "Maximum number of prefix accept from this peer\n"
3431 "maximum no. of prefix limit\n"
3432 "Only give warning message when limit is exceeded\n")
3433
3434/* "neighbor allowas-in" */
3435DEFUN (neighbor_allowas_in,
3436 neighbor_allowas_in_cmd,
3437 NEIGHBOR_CMD2 "allowas-in",
3438 NEIGHBOR_STR
3439 NEIGHBOR_ADDR_STR2
3440 "Accept as-path with my AS present in it\n")
3441{
3442 int ret;
3443 struct peer *peer;
3444 int allow_num;
3445
3446 peer = peer_and_group_lookup_vty (vty, argv[0]);
3447 if (! peer)
3448 return CMD_WARNING;
3449
3450 if (argc == 1)
3451 allow_num = 3;
3452 else
3453 VTY_GET_INTEGER_RANGE ("AS number", allow_num, argv[1], 1, 10);
3454
3455 ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty),
3456 allow_num);
3457
3458 return bgp_vty_return (vty, ret);
3459}
3460
3461ALIAS (neighbor_allowas_in,
3462 neighbor_allowas_in_arg_cmd,
3463 NEIGHBOR_CMD2 "allowas-in <1-10>",
3464 NEIGHBOR_STR
3465 NEIGHBOR_ADDR_STR2
3466 "Accept as-path with my AS present in it\n"
3467 "Number of occurances of AS number\n")
3468
3469DEFUN (no_neighbor_allowas_in,
3470 no_neighbor_allowas_in_cmd,
3471 NO_NEIGHBOR_CMD2 "allowas-in",
3472 NO_STR
3473 NEIGHBOR_STR
3474 NEIGHBOR_ADDR_STR2
3475 "allow local ASN appears in aspath attribute\n")
3476{
3477 int ret;
3478 struct peer *peer;
3479
3480 peer = peer_and_group_lookup_vty (vty, argv[0]);
3481 if (! peer)
3482 return CMD_WARNING;
3483
3484 ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty));
3485
3486 return bgp_vty_return (vty, ret);
3487}
3488
3489/* Address family configuration. */
3490DEFUN (address_family_ipv4,
3491 address_family_ipv4_cmd,
3492 "address-family ipv4",
3493 "Enter Address Family command mode\n"
3494 "Address family\n")
3495{
3496 vty->node = BGP_IPV4_NODE;
3497 return CMD_SUCCESS;
3498}
3499
3500DEFUN (address_family_ipv4_safi,
3501 address_family_ipv4_safi_cmd,
3502 "address-family ipv4 (unicast|multicast)",
3503 "Enter Address Family command mode\n"
3504 "Address family\n"
3505 "Address Family modifier\n"
3506 "Address Family modifier\n")
3507{
3508 if (strncmp (argv[0], "m", 1) == 0)
3509 vty->node = BGP_IPV4M_NODE;
3510 else
3511 vty->node = BGP_IPV4_NODE;
3512
3513 return CMD_SUCCESS;
3514}
3515
3516DEFUN (address_family_ipv6_unicast,
3517 address_family_ipv6_unicast_cmd,
3518 "address-family ipv6 unicast",
3519 "Enter Address Family command mode\n"
3520 "Address family\n"
3521 "unicast\n")
3522{
3523 vty->node = BGP_IPV6_NODE;
3524 return CMD_SUCCESS;
3525}
3526
3527ALIAS (address_family_ipv6_unicast,
3528 address_family_ipv6_cmd,
3529 "address-family ipv6",
3530 "Enter Address Family command mode\n"
3531 "Address family\n")
3532
3533DEFUN (address_family_vpnv4,
3534 address_family_vpnv4_cmd,
3535 "address-family vpnv4",
3536 "Enter Address Family command mode\n"
3537 "Address family\n")
3538{
3539 vty->node = BGP_VPNV4_NODE;
3540 return CMD_SUCCESS;
3541}
3542
3543ALIAS (address_family_vpnv4,
3544 address_family_vpnv4_unicast_cmd,
3545 "address-family vpnv4 unicast",
3546 "Enter Address Family command mode\n"
3547 "Address family\n"
3548 "Address Family Modifier\n")
3549
3550DEFUN (exit_address_family,
3551 exit_address_family_cmd,
3552 "exit-address-family",
3553 "Exit from Address Family configuration mode\n")
3554{
3555 if (vty->node == BGP_IPV4M_NODE
3556 || vty->node == BGP_VPNV4_NODE
3557 || vty->node == BGP_IPV6_NODE)
3558 vty->node = BGP_NODE;
3559 return CMD_SUCCESS;
3560}
3561
3562/* BGP clear sort. */
3563enum clear_sort
3564{
3565 clear_all,
3566 clear_peer,
3567 clear_group,
3568 clear_external,
3569 clear_as
3570};
3571
3572void
3573bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi,
3574 safi_t safi, int error)
3575{
3576 switch (error)
3577 {
3578 case BGP_ERR_AF_UNCONFIGURED:
3579 vty_out (vty,
3580 "%%BGP: Enable %s %s address family for the neighbor %s%s",
3581 afi == AFI_IP6 ? "IPv6" : safi == SAFI_MPLS_VPN ? "VPNv4" : "IPv4",
3582 safi == SAFI_MULTICAST ? "Multicast" : "Unicast",
3583 peer->host, VTY_NEWLINE);
3584 break;
3585 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED:
3586 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);
3587 break;
3588 default:
3589 break;
3590 }
3591}
3592
3593/* `clear ip bgp' functions. */
3594int
3595bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
3596 enum clear_sort sort,enum bgp_clear_type stype, char *arg)
3597{
3598 int ret;
3599 struct peer *peer;
3600 struct listnode *nn;
3601
3602 /* Clear all neighbors. */
3603 if (sort == clear_all)
3604 {
3605 LIST_LOOP (bgp->peer, peer, nn)
3606 {
3607 if (stype == BGP_CLEAR_SOFT_NONE)
3608 ret = peer_clear (peer);
3609 else
3610 ret = peer_clear_soft (peer, afi, safi, stype);
3611
3612 if (ret < 0)
3613 bgp_clear_vty_error (vty, peer, afi, safi, ret);
3614 }
3615 return 0;
3616 }
3617
3618 /* Clear specified neighbors. */
3619 if (sort == clear_peer)
3620 {
3621 union sockunion su;
3622 int ret;
3623
3624 /* Make sockunion for lookup. */
3625 ret = str2sockunion (arg, &su);
3626 if (ret < 0)
3627 {
3628 vty_out (vty, "Malformed address: %s%s", arg, VTY_NEWLINE);
3629 return -1;
3630 }
3631 peer = peer_lookup (bgp, &su);
3632 if (! peer)
3633 {
3634 vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE);
3635 return -1;
3636 }
3637
3638 if (stype == BGP_CLEAR_SOFT_NONE)
3639 ret = peer_clear (peer);
3640 else
3641 ret = peer_clear_soft (peer, afi, safi, stype);
3642
3643 if (ret < 0)
3644 bgp_clear_vty_error (vty, peer, afi, safi, ret);
3645
3646 return 0;
3647 }
3648
3649 /* Clear all peer-group members. */
3650 if (sort == clear_group)
3651 {
3652 struct peer_group *group;
3653
3654 group = peer_group_lookup (bgp, arg);
3655 if (! group)
3656 {
3657 vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE);
3658 return -1;
3659 }
3660
3661 LIST_LOOP (group->peer, peer, nn)
3662 {
3663 if (stype == BGP_CLEAR_SOFT_NONE)
3664 {
3665 ret = peer_clear (peer);
3666 continue;
3667 }
3668
3669 if (! peer->af_group[afi][safi])
3670 continue;
3671
3672 ret = peer_clear_soft (peer, afi, safi, stype);
3673
3674 if (ret < 0)
3675 bgp_clear_vty_error (vty, peer, afi, safi, ret);
3676 }
3677 return 0;
3678 }
3679
3680 if (sort == clear_external)
3681 {
3682 LIST_LOOP (bgp->peer, peer, nn)
3683 {
3684 if (peer_sort (peer) == BGP_PEER_IBGP)
3685 continue;
3686
3687 if (stype == BGP_CLEAR_SOFT_NONE)
3688 ret = peer_clear (peer);
3689 else
3690 ret = peer_clear_soft (peer, afi, safi, stype);
3691
3692 if (ret < 0)
3693 bgp_clear_vty_error (vty, peer, afi, safi, ret);
3694 }
3695 return 0;
3696 }
3697
3698 if (sort == clear_as)
3699 {
3700 as_t as;
3701 unsigned long as_ul;
3702 char *endptr = NULL;
3703 int find = 0;
3704
3705 as_ul = strtoul(arg, &endptr, 10);
3706
3707 if ((as_ul == ULONG_MAX) || (*endptr != '\0') || (as_ul > USHRT_MAX))
3708 {
3709 vty_out (vty, "Invalid AS number%s", VTY_NEWLINE);
3710 return -1;
3711 }
3712 as = (as_t) as_ul;
3713
3714 LIST_LOOP (bgp->peer, peer, nn)
3715 {
3716 if (peer->as != as)
3717 continue;
3718
3719 find = 1;
3720 if (stype == BGP_CLEAR_SOFT_NONE)
3721 ret = peer_clear (peer);
3722 else
3723 ret = peer_clear_soft (peer, afi, safi, stype);
3724
3725 if (ret < 0)
3726 bgp_clear_vty_error (vty, peer, afi, safi, ret);
3727 }
3728 if (! find)
3729 vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg,
3730 VTY_NEWLINE);
3731 return 0;
3732 }
3733
3734 return 0;
3735}
3736
3737int
3738bgp_clear_vty (struct vty *vty, char *name, afi_t afi, safi_t safi,
3739 enum clear_sort sort, enum bgp_clear_type stype, char *arg)
3740{
3741 int ret;
3742 struct bgp *bgp;
3743
3744 /* BGP structure lookup. */
3745 if (name)
3746 {
3747 bgp = bgp_lookup_by_name (name);
3748 if (bgp == NULL)
3749 {
3750 vty_out (vty, "Can't find BGP view %s%s", name, VTY_NEWLINE);
3751 return CMD_WARNING;
3752 }
3753 }
3754 else
3755 {
3756 bgp = bgp_get_default ();
3757 if (bgp == NULL)
3758 {
3759 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
3760 return CMD_WARNING;
3761 }
3762 }
3763
3764 ret = bgp_clear (vty, bgp, afi, safi, sort, stype, arg);
3765 if (ret < 0)
3766 return CMD_WARNING;
3767
3768 return CMD_SUCCESS;
3769}
3770
3771DEFUN (clear_ip_bgp_all,
3772 clear_ip_bgp_all_cmd,
3773 "clear ip bgp *",
3774 CLEAR_STR
3775 IP_STR
3776 BGP_STR
3777 "Clear all peers\n")
3778{
3779 if (argc == 1)
3780 return bgp_clear_vty (vty, argv[0], 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
3781
3782 return bgp_clear_vty (vty, NULL, 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
3783}
3784
3785ALIAS (clear_ip_bgp_all,
3786 clear_bgp_all_cmd,
3787 "clear bgp *",
3788 CLEAR_STR
3789 BGP_STR
3790 "Clear all peers\n")
3791
3792ALIAS (clear_ip_bgp_all,
3793 clear_bgp_ipv6_all_cmd,
3794 "clear bgp ipv6 *",
3795 CLEAR_STR
3796 BGP_STR
3797 "Address family\n"
3798 "Clear all peers\n")
3799
3800ALIAS (clear_ip_bgp_all,
3801 clear_ip_bgp_instance_all_cmd,
3802 "clear ip bgp view WORD *",
3803 CLEAR_STR
3804 IP_STR
3805 BGP_STR
3806 "BGP view\n"
3807 "view name\n"
3808 "Clear all peers\n")
3809
3810ALIAS (clear_ip_bgp_all,
3811 clear_bgp_instance_all_cmd,
3812 "clear bgp view WORD *",
3813 CLEAR_STR
3814 BGP_STR
3815 "BGP view\n"
3816 "view name\n"
3817 "Clear all peers\n")
3818
3819DEFUN (clear_ip_bgp_peer,
3820 clear_ip_bgp_peer_cmd,
3821 "clear ip bgp (A.B.C.D|X:X::X:X)",
3822 CLEAR_STR
3823 IP_STR
3824 BGP_STR
3825 "BGP neighbor IP address to clear\n"
3826 "BGP IPv6 neighbor to clear\n")
3827{
3828 return bgp_clear_vty (vty, NULL, 0, 0, clear_peer, BGP_CLEAR_SOFT_NONE, argv[0]);
3829}
3830
3831ALIAS (clear_ip_bgp_peer,
3832 clear_bgp_peer_cmd,
3833 "clear bgp (A.B.C.D|X:X::X:X)",
3834 CLEAR_STR
3835 BGP_STR
3836 "BGP neighbor address to clear\n"
3837 "BGP IPv6 neighbor to clear\n")
3838
3839ALIAS (clear_ip_bgp_peer,
3840 clear_bgp_ipv6_peer_cmd,
3841 "clear bgp ipv6 (A.B.C.D|X:X::X:X)",
3842 CLEAR_STR
3843 BGP_STR
3844 "Address family\n"
3845 "BGP neighbor address to clear\n"
3846 "BGP IPv6 neighbor to clear\n")
3847
3848DEFUN (clear_ip_bgp_peer_group,
3849 clear_ip_bgp_peer_group_cmd,
3850 "clear ip bgp peer-group WORD",
3851 CLEAR_STR
3852 IP_STR
3853 BGP_STR
3854 "Clear all members of peer-group\n"
3855 "BGP peer-group name\n")
3856{
3857 return bgp_clear_vty (vty, NULL, 0, 0, clear_group, BGP_CLEAR_SOFT_NONE, argv[0]);
3858}
3859
3860ALIAS (clear_ip_bgp_peer_group,
3861 clear_bgp_peer_group_cmd,
3862 "clear bgp peer-group WORD",
3863 CLEAR_STR
3864 BGP_STR
3865 "Clear all members of peer-group\n"
3866 "BGP peer-group name\n")
3867
3868ALIAS (clear_ip_bgp_peer_group,
3869 clear_bgp_ipv6_peer_group_cmd,
3870 "clear bgp ipv6 peer-group WORD",
3871 CLEAR_STR
3872 BGP_STR
3873 "Address family\n"
3874 "Clear all members of peer-group\n"
3875 "BGP peer-group name\n")
3876
3877DEFUN (clear_ip_bgp_external,
3878 clear_ip_bgp_external_cmd,
3879 "clear ip bgp external",
3880 CLEAR_STR
3881 IP_STR
3882 BGP_STR
3883 "Clear all external peers\n")
3884{
3885 return bgp_clear_vty (vty, NULL, 0, 0, clear_external, BGP_CLEAR_SOFT_NONE, NULL);
3886}
3887
3888ALIAS (clear_ip_bgp_external,
3889 clear_bgp_external_cmd,
3890 "clear bgp external",
3891 CLEAR_STR
3892 BGP_STR
3893 "Clear all external peers\n")
3894
3895ALIAS (clear_ip_bgp_external,
3896 clear_bgp_ipv6_external_cmd,
3897 "clear bgp ipv6 external",
3898 CLEAR_STR
3899 BGP_STR
3900 "Address family\n"
3901 "Clear all external peers\n")
3902
3903DEFUN (clear_ip_bgp_as,
3904 clear_ip_bgp_as_cmd,
3905 "clear ip bgp <1-65535>",
3906 CLEAR_STR
3907 IP_STR
3908 BGP_STR
3909 "Clear peers with the AS number\n")
3910{
3911 return bgp_clear_vty (vty, NULL, 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[0]);
3912}
3913
3914ALIAS (clear_ip_bgp_as,
3915 clear_bgp_as_cmd,
3916 "clear bgp <1-65535>",
3917 CLEAR_STR
3918 BGP_STR
3919 "Clear peers with the AS number\n")
3920
3921ALIAS (clear_ip_bgp_as,
3922 clear_bgp_ipv6_as_cmd,
3923 "clear bgp ipv6 <1-65535>",
3924 CLEAR_STR
3925 BGP_STR
3926 "Address family\n"
3927 "Clear peers with the AS number\n")
3928
3929/* Outbound soft-reconfiguration */
3930DEFUN (clear_ip_bgp_all_soft_out,
3931 clear_ip_bgp_all_soft_out_cmd,
3932 "clear ip bgp * soft out",
3933 CLEAR_STR
3934 IP_STR
3935 BGP_STR
3936 "Clear all peers\n"
3937 "Soft reconfig\n"
3938 "Soft reconfig outbound update\n")
3939{
3940 if (argc == 1)
3941 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
3942 BGP_CLEAR_SOFT_OUT, NULL);
3943
3944 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
3945 BGP_CLEAR_SOFT_OUT, NULL);
3946}
3947
3948ALIAS (clear_ip_bgp_all_soft_out,
3949 clear_ip_bgp_all_out_cmd,
3950 "clear ip bgp * out",
3951 CLEAR_STR
3952 IP_STR
3953 BGP_STR
3954 "Clear all peers\n"
3955 "Soft reconfig outbound update\n")
3956
3957ALIAS (clear_ip_bgp_all_soft_out,
3958 clear_ip_bgp_instance_all_soft_out_cmd,
3959 "clear ip bgp view WORD * soft out",
3960 CLEAR_STR
3961 IP_STR
3962 BGP_STR
3963 "BGP view\n"
3964 "view name\n"
3965 "Clear all peers\n"
3966 "Soft reconfig\n"
3967 "Soft reconfig outbound update\n")
3968
3969DEFUN (clear_ip_bgp_all_ipv4_soft_out,
3970 clear_ip_bgp_all_ipv4_soft_out_cmd,
3971 "clear ip bgp * ipv4 (unicast|multicast) soft out",
3972 CLEAR_STR
3973 IP_STR
3974 BGP_STR
3975 "Clear all peers\n"
3976 "Address family\n"
3977 "Address Family modifier\n"
3978 "Address Family modifier\n"
3979 "Soft reconfig\n"
3980 "Soft reconfig outbound update\n")
3981{
3982 if (strncmp (argv[0], "m", 1) == 0)
3983 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
3984 BGP_CLEAR_SOFT_OUT, NULL);
3985
3986 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
3987 BGP_CLEAR_SOFT_OUT, NULL);
3988}
3989
3990ALIAS (clear_ip_bgp_all_ipv4_soft_out,
3991 clear_ip_bgp_all_ipv4_out_cmd,
3992 "clear ip bgp * ipv4 (unicast|multicast) out",
3993 CLEAR_STR
3994 IP_STR
3995 BGP_STR
3996 "Clear all peers\n"
3997 "Address family\n"
3998 "Address Family modifier\n"
3999 "Address Family modifier\n"
4000 "Soft reconfig outbound update\n")
4001
4002DEFUN (clear_ip_bgp_instance_all_ipv4_soft_out,
4003 clear_ip_bgp_instance_all_ipv4_soft_out_cmd,
4004 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft out",
4005 CLEAR_STR
4006 IP_STR
4007 BGP_STR
4008 "BGP view\n"
4009 "view name\n"
4010 "Clear all peers\n"
4011 "Address family\n"
4012 "Address Family modifier\n"
4013 "Address Family modifier\n"
4014 "Soft reconfig outbound update\n")
4015{
4016 if (strncmp (argv[1], "m", 1) == 0)
4017 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
4018 BGP_CLEAR_SOFT_OUT, NULL);
4019
4020 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
4021 BGP_CLEAR_SOFT_OUT, NULL);
4022}
4023
4024DEFUN (clear_ip_bgp_all_vpnv4_soft_out,
4025 clear_ip_bgp_all_vpnv4_soft_out_cmd,
4026 "clear ip bgp * vpnv4 unicast soft out",
4027 CLEAR_STR
4028 IP_STR
4029 BGP_STR
4030 "Clear all peers\n"
4031 "Address family\n"
4032 "Address Family Modifier\n"
4033 "Soft reconfig\n"
4034 "Soft reconfig outbound update\n")
4035{
4036 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
4037 BGP_CLEAR_SOFT_OUT, NULL);
4038}
4039
4040ALIAS (clear_ip_bgp_all_vpnv4_soft_out,
4041 clear_ip_bgp_all_vpnv4_out_cmd,
4042 "clear ip bgp * vpnv4 unicast out",
4043 CLEAR_STR
4044 IP_STR
4045 BGP_STR
4046 "Clear all peers\n"
4047 "Address family\n"
4048 "Address Family Modifier\n"
4049 "Soft reconfig outbound update\n")
4050
4051DEFUN (clear_bgp_all_soft_out,
4052 clear_bgp_all_soft_out_cmd,
4053 "clear bgp * soft out",
4054 CLEAR_STR
4055 BGP_STR
4056 "Clear all peers\n"
4057 "Soft reconfig\n"
4058 "Soft reconfig outbound update\n")
4059{
4060 if (argc == 1)
4061 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
4062 BGP_CLEAR_SOFT_OUT, NULL);
4063
4064 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
4065 BGP_CLEAR_SOFT_OUT, NULL);
4066}
4067
4068ALIAS (clear_bgp_all_soft_out,
4069 clear_bgp_instance_all_soft_out_cmd,
4070 "clear bgp view WORD * soft out",
4071 CLEAR_STR
4072 BGP_STR
4073 "BGP view\n"
4074 "view name\n"
4075 "Clear all peers\n"
4076 "Soft reconfig\n"
4077 "Soft reconfig outbound update\n")
4078
4079ALIAS (clear_bgp_all_soft_out,
4080 clear_bgp_all_out_cmd,
4081 "clear bgp * out",
4082 CLEAR_STR
4083 BGP_STR
4084 "Clear all peers\n"
4085 "Soft reconfig outbound update\n")
4086
4087ALIAS (clear_bgp_all_soft_out,
4088 clear_bgp_ipv6_all_soft_out_cmd,
4089 "clear bgp ipv6 * soft out",
4090 CLEAR_STR
4091 BGP_STR
4092 "Address family\n"
4093 "Clear all peers\n"
4094 "Soft reconfig\n"
4095 "Soft reconfig outbound update\n")
4096
4097ALIAS (clear_bgp_all_soft_out,
4098 clear_bgp_ipv6_all_out_cmd,
4099 "clear bgp ipv6 * out",
4100 CLEAR_STR
4101 BGP_STR
4102 "Address family\n"
4103 "Clear all peers\n"
4104 "Soft reconfig outbound update\n")
4105
4106DEFUN (clear_ip_bgp_peer_soft_out,
4107 clear_ip_bgp_peer_soft_out_cmd,
4108 "clear ip bgp A.B.C.D soft out",
4109 CLEAR_STR
4110 IP_STR
4111 BGP_STR
4112 "BGP neighbor address to clear\n"
4113 "Soft reconfig\n"
4114 "Soft reconfig outbound update\n")
4115{
4116 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
4117 BGP_CLEAR_SOFT_OUT, argv[0]);
4118}
4119
4120ALIAS (clear_ip_bgp_peer_soft_out,
4121 clear_ip_bgp_peer_out_cmd,
4122 "clear ip bgp A.B.C.D out",
4123 CLEAR_STR
4124 IP_STR
4125 BGP_STR
4126 "BGP neighbor address to clear\n"
4127 "Soft reconfig outbound update\n")
4128
4129DEFUN (clear_ip_bgp_peer_ipv4_soft_out,
4130 clear_ip_bgp_peer_ipv4_soft_out_cmd,
4131 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft out",
4132 CLEAR_STR
4133 IP_STR
4134 BGP_STR
4135 "BGP neighbor address to clear\n"
4136 "Address family\n"
4137 "Address Family modifier\n"
4138 "Address Family modifier\n"
4139 "Soft reconfig\n"
4140 "Soft reconfig outbound update\n")
4141{
4142 if (strncmp (argv[1], "m", 1) == 0)
4143 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
4144 BGP_CLEAR_SOFT_OUT, argv[0]);
4145
4146 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
4147 BGP_CLEAR_SOFT_OUT, argv[0]);
4148}
4149
4150ALIAS (clear_ip_bgp_peer_ipv4_soft_out,
4151 clear_ip_bgp_peer_ipv4_out_cmd,
4152 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) out",
4153 CLEAR_STR
4154 IP_STR
4155 BGP_STR
4156 "BGP neighbor address to clear\n"
4157 "Address family\n"
4158 "Address Family modifier\n"
4159 "Address Family modifier\n"
4160 "Soft reconfig outbound update\n")
4161
4162DEFUN (clear_ip_bgp_peer_vpnv4_soft_out,
4163 clear_ip_bgp_peer_vpnv4_soft_out_cmd,
4164 "clear ip bgp A.B.C.D vpnv4 unicast soft out",
4165 CLEAR_STR
4166 IP_STR
4167 BGP_STR
4168 "BGP neighbor address to clear\n"
4169 "Address family\n"
4170 "Address Family Modifier\n"
4171 "Soft reconfig\n"
4172 "Soft reconfig outbound update\n")
4173{
4174 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
4175 BGP_CLEAR_SOFT_OUT, argv[0]);
4176}
4177
4178ALIAS (clear_ip_bgp_peer_vpnv4_soft_out,
4179 clear_ip_bgp_peer_vpnv4_out_cmd,
4180 "clear ip bgp A.B.C.D vpnv4 unicast out",
4181 CLEAR_STR
4182 IP_STR
4183 BGP_STR
4184 "BGP neighbor address to clear\n"
4185 "Address family\n"
4186 "Address Family Modifier\n"
4187 "Soft reconfig outbound update\n")
4188
4189DEFUN (clear_bgp_peer_soft_out,
4190 clear_bgp_peer_soft_out_cmd,
4191 "clear bgp (A.B.C.D|X:X::X:X) soft out",
4192 CLEAR_STR
4193 BGP_STR
4194 "BGP neighbor address to clear\n"
4195 "BGP IPv6 neighbor to clear\n"
4196 "Soft reconfig\n"
4197 "Soft reconfig outbound update\n")
4198{
4199 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
4200 BGP_CLEAR_SOFT_OUT, argv[0]);
4201}
4202
4203ALIAS (clear_bgp_peer_soft_out,
4204 clear_bgp_ipv6_peer_soft_out_cmd,
4205 "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft out",
4206 CLEAR_STR
4207 BGP_STR
4208 "Address family\n"
4209 "BGP neighbor address to clear\n"
4210 "BGP IPv6 neighbor to clear\n"
4211 "Soft reconfig\n"
4212 "Soft reconfig outbound update\n")
4213
4214ALIAS (clear_bgp_peer_soft_out,
4215 clear_bgp_peer_out_cmd,
4216 "clear bgp (A.B.C.D|X:X::X:X) out",
4217 CLEAR_STR
4218 BGP_STR
4219 "BGP neighbor address to clear\n"
4220 "BGP IPv6 neighbor to clear\n"
4221 "Soft reconfig outbound update\n")
4222
4223ALIAS (clear_bgp_peer_soft_out,
4224 clear_bgp_ipv6_peer_out_cmd,
4225 "clear bgp ipv6 (A.B.C.D|X:X::X:X) out",
4226 CLEAR_STR
4227 BGP_STR
4228 "Address family\n"
4229 "BGP neighbor address to clear\n"
4230 "BGP IPv6 neighbor to clear\n"
4231 "Soft reconfig outbound update\n")
4232
4233DEFUN (clear_ip_bgp_peer_group_soft_out,
4234 clear_ip_bgp_peer_group_soft_out_cmd,
4235 "clear ip bgp peer-group WORD soft out",
4236 CLEAR_STR
4237 IP_STR
4238 BGP_STR
4239 "Clear all members of peer-group\n"
4240 "BGP peer-group name\n"
4241 "Soft reconfig\n"
4242 "Soft reconfig outbound update\n")
4243{
4244 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
4245 BGP_CLEAR_SOFT_OUT, argv[0]);
4246}
4247
4248ALIAS (clear_ip_bgp_peer_group_soft_out,
4249 clear_ip_bgp_peer_group_out_cmd,
4250 "clear ip bgp peer-group WORD out",
4251 CLEAR_STR
4252 IP_STR
4253 BGP_STR
4254 "Clear all members of peer-group\n"
4255 "BGP peer-group name\n"
4256 "Soft reconfig outbound update\n")
4257
4258DEFUN (clear_ip_bgp_peer_group_ipv4_soft_out,
4259 clear_ip_bgp_peer_group_ipv4_soft_out_cmd,
4260 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft out",
4261 CLEAR_STR
4262 IP_STR
4263 BGP_STR
4264 "Clear all members of peer-group\n"
4265 "BGP peer-group name\n"
4266 "Address family\n"
4267 "Address Family modifier\n"
4268 "Address Family modifier\n"
4269 "Soft reconfig\n"
4270 "Soft reconfig outbound update\n")
4271{
4272 if (strncmp (argv[1], "m", 1) == 0)
4273 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
4274 BGP_CLEAR_SOFT_OUT, argv[0]);
4275
4276 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
4277 BGP_CLEAR_SOFT_OUT, argv[0]);
4278}
4279
4280ALIAS (clear_ip_bgp_peer_group_ipv4_soft_out,
4281 clear_ip_bgp_peer_group_ipv4_out_cmd,
4282 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) out",
4283 CLEAR_STR
4284 IP_STR
4285 BGP_STR
4286 "Clear all members of peer-group\n"
4287 "BGP peer-group name\n"
4288 "Address family\n"
4289 "Address Family modifier\n"
4290 "Address Family modifier\n"
4291 "Soft reconfig outbound update\n")
4292
4293DEFUN (clear_bgp_peer_group_soft_out,
4294 clear_bgp_peer_group_soft_out_cmd,
4295 "clear bgp peer-group WORD soft out",
4296 CLEAR_STR
4297 BGP_STR
4298 "Clear all members of peer-group\n"
4299 "BGP peer-group name\n"
4300 "Soft reconfig\n"
4301 "Soft reconfig outbound update\n")
4302{
4303 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
4304 BGP_CLEAR_SOFT_OUT, argv[0]);
4305}
4306
4307ALIAS (clear_bgp_peer_group_soft_out,
4308 clear_bgp_ipv6_peer_group_soft_out_cmd,
4309 "clear bgp ipv6 peer-group WORD soft out",
4310 CLEAR_STR
4311 BGP_STR
4312 "Address family\n"
4313 "Clear all members of peer-group\n"
4314 "BGP peer-group name\n"
4315 "Soft reconfig\n"
4316 "Soft reconfig outbound update\n")
4317
4318ALIAS (clear_bgp_peer_group_soft_out,
4319 clear_bgp_peer_group_out_cmd,
4320 "clear bgp peer-group WORD out",
4321 CLEAR_STR
4322 BGP_STR
4323 "Clear all members of peer-group\n"
4324 "BGP peer-group name\n"
4325 "Soft reconfig outbound update\n")
4326
4327ALIAS (clear_bgp_peer_group_soft_out,
4328 clear_bgp_ipv6_peer_group_out_cmd,
4329 "clear bgp ipv6 peer-group WORD out",
4330 CLEAR_STR
4331 BGP_STR
4332 "Address family\n"
4333 "Clear all members of peer-group\n"
4334 "BGP peer-group name\n"
4335 "Soft reconfig outbound update\n")
4336
4337DEFUN (clear_ip_bgp_external_soft_out,
4338 clear_ip_bgp_external_soft_out_cmd,
4339 "clear ip bgp external soft out",
4340 CLEAR_STR
4341 IP_STR
4342 BGP_STR
4343 "Clear all external peers\n"
4344 "Soft reconfig\n"
4345 "Soft reconfig outbound update\n")
4346{
4347 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
4348 BGP_CLEAR_SOFT_OUT, NULL);
4349}
4350
4351ALIAS (clear_ip_bgp_external_soft_out,
4352 clear_ip_bgp_external_out_cmd,
4353 "clear ip bgp external out",
4354 CLEAR_STR
4355 IP_STR
4356 BGP_STR
4357 "Clear all external peers\n"
4358 "Soft reconfig outbound update\n")
4359
4360DEFUN (clear_ip_bgp_external_ipv4_soft_out,
4361 clear_ip_bgp_external_ipv4_soft_out_cmd,
4362 "clear ip bgp external ipv4 (unicast|multicast) soft out",
4363 CLEAR_STR
4364 IP_STR
4365 BGP_STR
4366 "Clear all external peers\n"
4367 "Address family\n"
4368 "Address Family modifier\n"
4369 "Address Family modifier\n"
4370 "Soft reconfig\n"
4371 "Soft reconfig outbound update\n")
4372{
4373 if (strncmp (argv[0], "m", 1) == 0)
4374 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
4375 BGP_CLEAR_SOFT_OUT, NULL);
4376
4377 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
4378 BGP_CLEAR_SOFT_OUT, NULL);
4379}
4380
4381ALIAS (clear_ip_bgp_external_ipv4_soft_out,
4382 clear_ip_bgp_external_ipv4_out_cmd,
4383 "clear ip bgp external ipv4 (unicast|multicast) out",
4384 CLEAR_STR
4385 IP_STR
4386 BGP_STR
4387 "Clear all external peers\n"
4388 "Address family\n"
4389 "Address Family modifier\n"
4390 "Address Family modifier\n"
4391 "Soft reconfig outbound update\n")
4392
4393DEFUN (clear_bgp_external_soft_out,
4394 clear_bgp_external_soft_out_cmd,
4395 "clear bgp external soft out",
4396 CLEAR_STR
4397 BGP_STR
4398 "Clear all external peers\n"
4399 "Soft reconfig\n"
4400 "Soft reconfig outbound update\n")
4401{
4402 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
4403 BGP_CLEAR_SOFT_OUT, NULL);
4404}
4405
4406ALIAS (clear_bgp_external_soft_out,
4407 clear_bgp_ipv6_external_soft_out_cmd,
4408 "clear bgp ipv6 external soft out",
4409 CLEAR_STR
4410 BGP_STR
4411 "Address family\n"
4412 "Clear all external peers\n"
4413 "Soft reconfig\n"
4414 "Soft reconfig outbound update\n")
4415
4416ALIAS (clear_bgp_external_soft_out,
4417 clear_bgp_external_out_cmd,
4418 "clear bgp external out",
4419 CLEAR_STR
4420 BGP_STR
4421 "Clear all external peers\n"
4422 "Soft reconfig outbound update\n")
4423
4424ALIAS (clear_bgp_external_soft_out,
4425 clear_bgp_ipv6_external_out_cmd,
4426 "clear bgp ipv6 external WORD out",
4427 CLEAR_STR
4428 BGP_STR
4429 "Address family\n"
4430 "Clear all external peers\n"
4431 "Soft reconfig outbound update\n")
4432
4433DEFUN (clear_ip_bgp_as_soft_out,
4434 clear_ip_bgp_as_soft_out_cmd,
4435 "clear ip bgp <1-65535> soft out",
4436 CLEAR_STR
4437 IP_STR
4438 BGP_STR
4439 "Clear peers with the AS number\n"
4440 "Soft reconfig\n"
4441 "Soft reconfig outbound update\n")
4442{
4443 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
4444 BGP_CLEAR_SOFT_OUT, argv[0]);
4445}
4446
4447ALIAS (clear_ip_bgp_as_soft_out,
4448 clear_ip_bgp_as_out_cmd,
4449 "clear ip bgp <1-65535> out",
4450 CLEAR_STR
4451 IP_STR
4452 BGP_STR
4453 "Clear peers with the AS number\n"
4454 "Soft reconfig outbound update\n")
4455
4456DEFUN (clear_ip_bgp_as_ipv4_soft_out,
4457 clear_ip_bgp_as_ipv4_soft_out_cmd,
4458 "clear ip bgp <1-65535> ipv4 (unicast|multicast) soft out",
4459 CLEAR_STR
4460 IP_STR
4461 BGP_STR
4462 "Clear peers with the AS number\n"
4463 "Address family\n"
4464 "Address Family modifier\n"
4465 "Address Family modifier\n"
4466 "Soft reconfig\n"
4467 "Soft reconfig outbound update\n")
4468{
4469 if (strncmp (argv[1], "m", 1) == 0)
4470 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
4471 BGP_CLEAR_SOFT_OUT, argv[0]);
4472
4473 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
4474 BGP_CLEAR_SOFT_OUT, argv[0]);
4475}
4476
4477ALIAS (clear_ip_bgp_as_ipv4_soft_out,
4478 clear_ip_bgp_as_ipv4_out_cmd,
4479 "clear ip bgp <1-65535> ipv4 (unicast|multicast) out",
4480 CLEAR_STR
4481 IP_STR
4482 BGP_STR
4483 "Clear peers with the AS number\n"
4484 "Address family\n"
4485 "Address Family modifier\n"
4486 "Address Family modifier\n"
4487 "Soft reconfig outbound update\n")
4488
4489DEFUN (clear_ip_bgp_as_vpnv4_soft_out,
4490 clear_ip_bgp_as_vpnv4_soft_out_cmd,
4491 "clear ip bgp <1-65535> vpnv4 unicast soft out",
4492 CLEAR_STR
4493 IP_STR
4494 BGP_STR
4495 "Clear peers with the AS number\n"
4496 "Address family\n"
4497 "Address Family modifier\n"
4498 "Soft reconfig\n"
4499 "Soft reconfig outbound update\n")
4500{
4501 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
4502 BGP_CLEAR_SOFT_OUT, argv[0]);
4503}
4504
4505ALIAS (clear_ip_bgp_as_vpnv4_soft_out,
4506 clear_ip_bgp_as_vpnv4_out_cmd,
4507 "clear ip bgp <1-65535> vpnv4 unicast out",
4508 CLEAR_STR
4509 IP_STR
4510 BGP_STR
4511 "Clear peers with the AS number\n"
4512 "Address family\n"
4513 "Address Family modifier\n"
4514 "Soft reconfig outbound update\n")
4515
4516DEFUN (clear_bgp_as_soft_out,
4517 clear_bgp_as_soft_out_cmd,
4518 "clear bgp <1-65535> soft out",
4519 CLEAR_STR
4520 BGP_STR
4521 "Clear peers with the AS number\n"
4522 "Soft reconfig\n"
4523 "Soft reconfig outbound update\n")
4524{
4525 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
4526 BGP_CLEAR_SOFT_OUT, argv[0]);
4527}
4528
4529ALIAS (clear_bgp_as_soft_out,
4530 clear_bgp_ipv6_as_soft_out_cmd,
4531 "clear bgp ipv6 <1-65535> soft out",
4532 CLEAR_STR
4533 BGP_STR
4534 "Address family\n"
4535 "Clear peers with the AS number\n"
4536 "Soft reconfig\n"
4537 "Soft reconfig outbound update\n")
4538
4539ALIAS (clear_bgp_as_soft_out,
4540 clear_bgp_as_out_cmd,
4541 "clear bgp <1-65535> out",
4542 CLEAR_STR
4543 BGP_STR
4544 "Clear peers with the AS number\n"
4545 "Soft reconfig outbound update\n")
4546
4547ALIAS (clear_bgp_as_soft_out,
4548 clear_bgp_ipv6_as_out_cmd,
4549 "clear bgp ipv6 <1-65535> out",
4550 CLEAR_STR
4551 BGP_STR
4552 "Address family\n"
4553 "Clear peers with the AS number\n"
4554 "Soft reconfig outbound update\n")
4555
4556/* Inbound soft-reconfiguration */
4557DEFUN (clear_ip_bgp_all_soft_in,
4558 clear_ip_bgp_all_soft_in_cmd,
4559 "clear ip bgp * soft in",
4560 CLEAR_STR
4561 IP_STR
4562 BGP_STR
4563 "Clear all peers\n"
4564 "Soft reconfig\n"
4565 "Soft reconfig inbound update\n")
4566{
4567 if (argc == 1)
4568 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
4569 BGP_CLEAR_SOFT_IN, NULL);
4570
4571 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
4572 BGP_CLEAR_SOFT_IN, NULL);
4573}
4574
4575ALIAS (clear_ip_bgp_all_soft_in,
4576 clear_ip_bgp_instance_all_soft_in_cmd,
4577 "clear ip bgp view WORD * soft in",
4578 CLEAR_STR
4579 IP_STR
4580 BGP_STR
4581 "BGP view\n"
4582 "view name\n"
4583 "Clear all peers\n"
4584 "Soft reconfig\n"
4585 "Soft reconfig inbound update\n")
4586
4587ALIAS (clear_ip_bgp_all_soft_in,
4588 clear_ip_bgp_all_in_cmd,
4589 "clear ip bgp * in",
4590 CLEAR_STR
4591 IP_STR
4592 BGP_STR
4593 "Clear all peers\n"
4594 "Soft reconfig inbound update\n")
4595
4596DEFUN (clear_ip_bgp_all_in_prefix_filter,
4597 clear_ip_bgp_all_in_prefix_filter_cmd,
4598 "clear ip bgp * in prefix-filter",
4599 CLEAR_STR
4600 IP_STR
4601 BGP_STR
4602 "Clear all peers\n"
4603 "Soft reconfig inbound update\n"
4604 "Push out prefix-list ORF and do inbound soft reconfig\n")
4605{
4606 if (argc== 1)
4607 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
4608 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
4609
4610 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
4611 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
4612}
4613
4614ALIAS (clear_ip_bgp_all_in_prefix_filter,
4615 clear_ip_bgp_instance_all_in_prefix_filter_cmd,
4616 "clear ip bgp view WORD * in prefix-filter",
4617 CLEAR_STR
4618 IP_STR
4619 BGP_STR
4620 "BGP view\n"
4621 "view name\n"
4622 "Clear all peers\n"
4623 "Soft reconfig inbound update\n"
4624 "Push out prefix-list ORF and do inbound soft reconfig\n")
4625
4626
4627DEFUN (clear_ip_bgp_all_ipv4_soft_in,
4628 clear_ip_bgp_all_ipv4_soft_in_cmd,
4629 "clear ip bgp * ipv4 (unicast|multicast) soft in",
4630 CLEAR_STR
4631 IP_STR
4632 BGP_STR
4633 "Clear all peers\n"
4634 "Address family\n"
4635 "Address Family modifier\n"
4636 "Address Family modifier\n"
4637 "Soft reconfig\n"
4638 "Soft reconfig inbound update\n")
4639{
4640 if (strncmp (argv[0], "m", 1) == 0)
4641 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
4642 BGP_CLEAR_SOFT_IN, NULL);
4643
4644 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
4645 BGP_CLEAR_SOFT_IN, NULL);
4646}
4647
4648ALIAS (clear_ip_bgp_all_ipv4_soft_in,
4649 clear_ip_bgp_all_ipv4_in_cmd,
4650 "clear ip bgp * ipv4 (unicast|multicast) in",
4651 CLEAR_STR
4652 IP_STR
4653 BGP_STR
4654 "Clear all peers\n"
4655 "Address family\n"
4656 "Address Family modifier\n"
4657 "Address Family modifier\n"
4658 "Soft reconfig inbound update\n")
4659
4660DEFUN (clear_ip_bgp_instance_all_ipv4_soft_in,
4661 clear_ip_bgp_instance_all_ipv4_soft_in_cmd,
4662 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft in",
4663 CLEAR_STR
4664 IP_STR
4665 BGP_STR
4666 "BGP view\n"
4667 "view name\n"
4668 "Clear all peers\n"
4669 "Address family\n"
4670 "Address Family modifier\n"
4671 "Address Family modifier\n"
4672 "Soft reconfig\n"
4673 "Soft reconfig inbound update\n")
4674{
4675 if (strncmp (argv[1], "m", 1) == 0)
4676 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
4677 BGP_CLEAR_SOFT_IN, NULL);
4678
4679 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
4680 BGP_CLEAR_SOFT_IN, NULL);
4681}
4682
4683DEFUN (clear_ip_bgp_all_ipv4_in_prefix_filter,
4684 clear_ip_bgp_all_ipv4_in_prefix_filter_cmd,
4685 "clear ip bgp * ipv4 (unicast|multicast) in prefix-filter",
4686 CLEAR_STR
4687 IP_STR
4688 BGP_STR
4689 "Clear all peers\n"
4690 "Address family\n"
4691 "Address Family modifier\n"
4692 "Address Family modifier\n"
4693 "Soft reconfig inbound update\n"
4694 "Push out prefix-list ORF and do inbound soft reconfig\n")
4695{
4696 if (strncmp (argv[0], "m", 1) == 0)
4697 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
4698 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
4699
4700 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
4701 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
4702}
4703
4704DEFUN (clear_ip_bgp_instance_all_ipv4_in_prefix_filter,
4705 clear_ip_bgp_instance_all_ipv4_in_prefix_filter_cmd,
4706 "clear ip bgp view WORD * ipv4 (unicast|multicast) in prefix-filter",
4707 CLEAR_STR
4708 IP_STR
4709 BGP_STR
4710 "Clear all peers\n"
4711 "Address family\n"
4712 "Address Family modifier\n"
4713 "Address Family modifier\n"
4714 "Soft reconfig inbound update\n"
4715 "Push out prefix-list ORF and do inbound soft reconfig\n")
4716{
4717 if (strncmp (argv[1], "m", 1) == 0)
4718 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
4719 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
4720
4721 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
4722 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
4723}
4724
4725DEFUN (clear_ip_bgp_all_vpnv4_soft_in,
4726 clear_ip_bgp_all_vpnv4_soft_in_cmd,
4727 "clear ip bgp * vpnv4 unicast soft in",
4728 CLEAR_STR
4729 IP_STR
4730 BGP_STR
4731 "Clear all peers\n"
4732 "Address family\n"
4733 "Address Family Modifier\n"
4734 "Soft reconfig\n"
4735 "Soft reconfig inbound update\n")
4736{
4737 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
4738 BGP_CLEAR_SOFT_IN, NULL);
4739}
4740
4741ALIAS (clear_ip_bgp_all_vpnv4_soft_in,
4742 clear_ip_bgp_all_vpnv4_in_cmd,
4743 "clear ip bgp * vpnv4 unicast in",
4744 CLEAR_STR
4745 IP_STR
4746 BGP_STR
4747 "Clear all peers\n"
4748 "Address family\n"
4749 "Address Family Modifier\n"
4750 "Soft reconfig inbound update\n")
4751
4752DEFUN (clear_bgp_all_soft_in,
4753 clear_bgp_all_soft_in_cmd,
4754 "clear bgp * soft in",
4755 CLEAR_STR
4756 BGP_STR
4757 "Clear all peers\n"
4758 "Soft reconfig\n"
4759 "Soft reconfig inbound update\n")
4760{
4761 if (argc == 1)
4762 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
4763 BGP_CLEAR_SOFT_IN, NULL);
4764
4765 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
4766 BGP_CLEAR_SOFT_IN, NULL);
4767}
4768
4769ALIAS (clear_bgp_all_soft_in,
4770 clear_bgp_instance_all_soft_in_cmd,
4771 "clear bgp view WORD * soft in",
4772 CLEAR_STR
4773 BGP_STR
4774 "BGP view\n"
4775 "view name\n"
4776 "Clear all peers\n"
4777 "Soft reconfig\n"
4778 "Soft reconfig inbound update\n")
4779
4780ALIAS (clear_bgp_all_soft_in,
4781 clear_bgp_ipv6_all_soft_in_cmd,
4782 "clear bgp ipv6 * soft in",
4783 CLEAR_STR
4784 BGP_STR
4785 "Address family\n"
4786 "Clear all peers\n"
4787 "Soft reconfig\n"
4788 "Soft reconfig inbound update\n")
4789
4790ALIAS (clear_bgp_all_soft_in,
4791 clear_bgp_all_in_cmd,
4792 "clear bgp * in",
4793 CLEAR_STR
4794 BGP_STR
4795 "Clear all peers\n"
4796 "Soft reconfig inbound update\n")
4797
4798ALIAS (clear_bgp_all_soft_in,
4799 clear_bgp_ipv6_all_in_cmd,
4800 "clear bgp ipv6 * in",
4801 CLEAR_STR
4802 BGP_STR
4803 "Address family\n"
4804 "Clear all peers\n"
4805 "Soft reconfig inbound update\n")
4806
4807DEFUN (clear_bgp_all_in_prefix_filter,
4808 clear_bgp_all_in_prefix_filter_cmd,
4809 "clear bgp * in prefix-filter",
4810 CLEAR_STR
4811 BGP_STR
4812 "Clear all peers\n"
4813 "Soft reconfig inbound update\n"
4814 "Push out prefix-list ORF and do inbound soft reconfig\n")
4815{
4816 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
4817 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
4818}
4819
4820ALIAS (clear_bgp_all_in_prefix_filter,
4821 clear_bgp_ipv6_all_in_prefix_filter_cmd,
4822 "clear bgp ipv6 * in prefix-filter",
4823 CLEAR_STR
4824 BGP_STR
4825 "Address family\n"
4826 "Clear all peers\n"
4827 "Soft reconfig inbound update\n"
4828 "Push out prefix-list ORF and do inbound soft reconfig\n")
4829
4830DEFUN (clear_ip_bgp_peer_soft_in,
4831 clear_ip_bgp_peer_soft_in_cmd,
4832 "clear ip bgp A.B.C.D soft in",
4833 CLEAR_STR
4834 IP_STR
4835 BGP_STR
4836 "BGP neighbor address to clear\n"
4837 "Soft reconfig\n"
4838 "Soft reconfig inbound update\n")
4839{
4840 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
4841 BGP_CLEAR_SOFT_IN, argv[0]);
4842}
4843
4844ALIAS (clear_ip_bgp_peer_soft_in,
4845 clear_ip_bgp_peer_in_cmd,
4846 "clear ip bgp A.B.C.D in",
4847 CLEAR_STR
4848 IP_STR
4849 BGP_STR
4850 "BGP neighbor address to clear\n"
4851 "Soft reconfig inbound update\n")
4852
4853DEFUN (clear_ip_bgp_peer_in_prefix_filter,
4854 clear_ip_bgp_peer_in_prefix_filter_cmd,
4855 "clear ip bgp A.B.C.D in prefix-filter",
4856 CLEAR_STR
4857 IP_STR
4858 BGP_STR
4859 "BGP neighbor address to clear\n"
4860 "Soft reconfig inbound update\n"
4861 "Push out the existing ORF prefix-list\n")
4862{
4863 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
4864 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
4865}
4866
4867DEFUN (clear_ip_bgp_peer_ipv4_soft_in,
4868 clear_ip_bgp_peer_ipv4_soft_in_cmd,
4869 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft in",
4870 CLEAR_STR
4871 IP_STR
4872 BGP_STR
4873 "BGP neighbor address to clear\n"
4874 "Address family\n"
4875 "Address Family modifier\n"
4876 "Address Family modifier\n"
4877 "Soft reconfig\n"
4878 "Soft reconfig inbound update\n")
4879{
4880 if (strncmp (argv[1], "m", 1) == 0)
4881 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
4882 BGP_CLEAR_SOFT_IN, argv[0]);
4883
4884 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
4885 BGP_CLEAR_SOFT_IN, argv[0]);
4886}
4887
4888ALIAS (clear_ip_bgp_peer_ipv4_soft_in,
4889 clear_ip_bgp_peer_ipv4_in_cmd,
4890 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) in",
4891 CLEAR_STR
4892 IP_STR
4893 BGP_STR
4894 "BGP neighbor address to clear\n"
4895 "Address family\n"
4896 "Address Family modifier\n"
4897 "Address Family modifier\n"
4898 "Soft reconfig inbound update\n")
4899
4900DEFUN (clear_ip_bgp_peer_ipv4_in_prefix_filter,
4901 clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd,
4902 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) in prefix-filter",
4903 CLEAR_STR
4904 IP_STR
4905 BGP_STR
4906 "BGP neighbor address to clear\n"
4907 "Address family\n"
4908 "Address Family modifier\n"
4909 "Address Family modifier\n"
4910 "Soft reconfig inbound update\n"
4911 "Push out the existing ORF prefix-list\n")
4912{
4913 if (strncmp (argv[1], "m", 1) == 0)
4914 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
4915 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
4916
4917 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
4918 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
4919}
4920
4921DEFUN (clear_ip_bgp_peer_vpnv4_soft_in,
4922 clear_ip_bgp_peer_vpnv4_soft_in_cmd,
4923 "clear ip bgp A.B.C.D vpnv4 unicast soft in",
4924 CLEAR_STR
4925 IP_STR
4926 BGP_STR
4927 "BGP neighbor address to clear\n"
4928 "Address family\n"
4929 "Address Family Modifier\n"
4930 "Soft reconfig\n"
4931 "Soft reconfig inbound update\n")
4932{
4933 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
4934 BGP_CLEAR_SOFT_IN, argv[0]);
4935}
4936
4937ALIAS (clear_ip_bgp_peer_vpnv4_soft_in,
4938 clear_ip_bgp_peer_vpnv4_in_cmd,
4939 "clear ip bgp A.B.C.D vpnv4 unicast in",
4940 CLEAR_STR
4941 IP_STR
4942 BGP_STR
4943 "BGP neighbor address to clear\n"
4944 "Address family\n"
4945 "Address Family Modifier\n"
4946 "Soft reconfig inbound update\n")
4947
4948DEFUN (clear_bgp_peer_soft_in,
4949 clear_bgp_peer_soft_in_cmd,
4950 "clear bgp (A.B.C.D|X:X::X:X) soft in",
4951 CLEAR_STR
4952 BGP_STR
4953 "BGP neighbor address to clear\n"
4954 "BGP IPv6 neighbor to clear\n"
4955 "Soft reconfig\n"
4956 "Soft reconfig inbound update\n")
4957{
4958 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
4959 BGP_CLEAR_SOFT_IN, argv[0]);
4960}
4961
4962ALIAS (clear_bgp_peer_soft_in,
4963 clear_bgp_ipv6_peer_soft_in_cmd,
4964 "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft in",
4965 CLEAR_STR
4966 BGP_STR
4967 "Address family\n"
4968 "BGP neighbor address to clear\n"
4969 "BGP IPv6 neighbor to clear\n"
4970 "Soft reconfig\n"
4971 "Soft reconfig inbound update\n")
4972
4973ALIAS (clear_bgp_peer_soft_in,
4974 clear_bgp_peer_in_cmd,
4975 "clear bgp (A.B.C.D|X:X::X:X) in",
4976 CLEAR_STR
4977 BGP_STR
4978 "BGP neighbor address to clear\n"
4979 "BGP IPv6 neighbor to clear\n"
4980 "Soft reconfig inbound update\n")
4981
4982ALIAS (clear_bgp_peer_soft_in,
4983 clear_bgp_ipv6_peer_in_cmd,
4984 "clear bgp ipv6 (A.B.C.D|X:X::X:X) in",
4985 CLEAR_STR
4986 BGP_STR
4987 "Address family\n"
4988 "BGP neighbor address to clear\n"
4989 "BGP IPv6 neighbor to clear\n"
4990 "Soft reconfig inbound update\n")
4991
4992DEFUN (clear_bgp_peer_in_prefix_filter,
4993 clear_bgp_peer_in_prefix_filter_cmd,
4994 "clear bgp (A.B.C.D|X:X::X:X) in prefix-filter",
4995 CLEAR_STR
4996 BGP_STR
4997 "BGP neighbor address to clear\n"
4998 "BGP IPv6 neighbor to clear\n"
4999 "Soft reconfig inbound update\n"
5000 "Push out the existing ORF prefix-list\n")
5001{
5002 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
5003 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5004}
5005
5006ALIAS (clear_bgp_peer_in_prefix_filter,
5007 clear_bgp_ipv6_peer_in_prefix_filter_cmd,
5008 "clear bgp ipv6 (A.B.C.D|X:X::X:X) in prefix-filter",
5009 CLEAR_STR
5010 BGP_STR
5011 "Address family\n"
5012 "BGP neighbor address to clear\n"
5013 "BGP IPv6 neighbor to clear\n"
5014 "Soft reconfig inbound update\n"
5015 "Push out the existing ORF prefix-list\n")
5016
5017DEFUN (clear_ip_bgp_peer_group_soft_in,
5018 clear_ip_bgp_peer_group_soft_in_cmd,
5019 "clear ip bgp peer-group WORD soft in",
5020 CLEAR_STR
5021 IP_STR
5022 BGP_STR
5023 "Clear all members of peer-group\n"
5024 "BGP peer-group name\n"
5025 "Soft reconfig\n"
5026 "Soft reconfig inbound update\n")
5027{
5028 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5029 BGP_CLEAR_SOFT_IN, argv[0]);
5030}
5031
5032ALIAS (clear_ip_bgp_peer_group_soft_in,
5033 clear_ip_bgp_peer_group_in_cmd,
5034 "clear ip bgp peer-group WORD in",
5035 CLEAR_STR
5036 IP_STR
5037 BGP_STR
5038 "Clear all members of peer-group\n"
5039 "BGP peer-group name\n"
5040 "Soft reconfig inbound update\n")
5041
5042DEFUN (clear_ip_bgp_peer_group_in_prefix_filter,
5043 clear_ip_bgp_peer_group_in_prefix_filter_cmd,
5044 "clear ip bgp peer-group WORD in prefix-filter",
5045 CLEAR_STR
5046 IP_STR
5047 BGP_STR
5048 "Clear all members of peer-group\n"
5049 "BGP peer-group name\n"
5050 "Soft reconfig inbound update\n"
5051 "Push out prefix-list ORF and do inbound soft reconfig\n")
5052{
5053 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5054 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5055}
5056
5057DEFUN (clear_ip_bgp_peer_group_ipv4_soft_in,
5058 clear_ip_bgp_peer_group_ipv4_soft_in_cmd,
5059 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft in",
5060 CLEAR_STR
5061 IP_STR
5062 BGP_STR
5063 "Clear all members of peer-group\n"
5064 "BGP peer-group name\n"
5065 "Address family\n"
5066 "Address Family modifier\n"
5067 "Address Family modifier\n"
5068 "Soft reconfig\n"
5069 "Soft reconfig inbound update\n")
5070{
5071 if (strncmp (argv[1], "m", 1) == 0)
5072 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
5073 BGP_CLEAR_SOFT_IN, argv[0]);
5074
5075 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5076 BGP_CLEAR_SOFT_IN, argv[0]);
5077}
5078
5079ALIAS (clear_ip_bgp_peer_group_ipv4_soft_in,
5080 clear_ip_bgp_peer_group_ipv4_in_cmd,
5081 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in",
5082 CLEAR_STR
5083 IP_STR
5084 BGP_STR
5085 "Clear all members of peer-group\n"
5086 "BGP peer-group name\n"
5087 "Address family\n"
5088 "Address Family modifier\n"
5089 "Address Family modifier\n"
5090 "Soft reconfig inbound update\n")
5091
5092DEFUN (clear_ip_bgp_peer_group_ipv4_in_prefix_filter,
5093 clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd,
5094 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in prefix-filter",
5095 CLEAR_STR
5096 IP_STR
5097 BGP_STR
5098 "Clear all members of peer-group\n"
5099 "BGP peer-group name\n"
5100 "Address family\n"
5101 "Address Family modifier\n"
5102 "Address Family modifier\n"
5103 "Soft reconfig inbound update\n"
5104 "Push out prefix-list ORF and do inbound soft reconfig\n")
5105{
5106 if (strncmp (argv[1], "m", 1) == 0)
5107 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
5108 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5109
5110 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5111 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5112}
5113
5114DEFUN (clear_bgp_peer_group_soft_in,
5115 clear_bgp_peer_group_soft_in_cmd,
5116 "clear bgp peer-group WORD soft in",
5117 CLEAR_STR
5118 BGP_STR
5119 "Clear all members of peer-group\n"
5120 "BGP peer-group name\n"
5121 "Soft reconfig\n"
5122 "Soft reconfig inbound update\n")
5123{
5124 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
5125 BGP_CLEAR_SOFT_IN, argv[0]);
5126}
5127
5128ALIAS (clear_bgp_peer_group_soft_in,
5129 clear_bgp_ipv6_peer_group_soft_in_cmd,
5130 "clear bgp ipv6 peer-group WORD soft in",
5131 CLEAR_STR
5132 BGP_STR
5133 "Address family\n"
5134 "Clear all members of peer-group\n"
5135 "BGP peer-group name\n"
5136 "Soft reconfig\n"
5137 "Soft reconfig inbound update\n")
5138
5139ALIAS (clear_bgp_peer_group_soft_in,
5140 clear_bgp_peer_group_in_cmd,
5141 "clear bgp peer-group WORD in",
5142 CLEAR_STR
5143 BGP_STR
5144 "Clear all members of peer-group\n"
5145 "BGP peer-group name\n"
5146 "Soft reconfig inbound update\n")
5147
5148ALIAS (clear_bgp_peer_group_soft_in,
5149 clear_bgp_ipv6_peer_group_in_cmd,
5150 "clear bgp ipv6 peer-group WORD in",
5151 CLEAR_STR
5152 BGP_STR
5153 "Address family\n"
5154 "Clear all members of peer-group\n"
5155 "BGP peer-group name\n"
5156 "Soft reconfig inbound update\n")
5157
5158DEFUN (clear_bgp_peer_group_in_prefix_filter,
5159 clear_bgp_peer_group_in_prefix_filter_cmd,
5160 "clear bgp peer-group WORD in prefix-filter",
5161 CLEAR_STR
5162 BGP_STR
5163 "Clear all members of peer-group\n"
5164 "BGP peer-group name\n"
5165 "Soft reconfig inbound update\n"
5166 "Push out prefix-list ORF and do inbound soft reconfig\n")
5167{
5168 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
5169 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5170}
5171
5172ALIAS (clear_bgp_peer_group_in_prefix_filter,
5173 clear_bgp_ipv6_peer_group_in_prefix_filter_cmd,
5174 "clear bgp ipv6 peer-group WORD in prefix-filter",
5175 CLEAR_STR
5176 BGP_STR
5177 "Address family\n"
5178 "Clear all members of peer-group\n"
5179 "BGP peer-group name\n"
5180 "Soft reconfig inbound update\n"
5181 "Push out prefix-list ORF and do inbound soft reconfig\n")
5182
5183DEFUN (clear_ip_bgp_external_soft_in,
5184 clear_ip_bgp_external_soft_in_cmd,
5185 "clear ip bgp external soft in",
5186 CLEAR_STR
5187 IP_STR
5188 BGP_STR
5189 "Clear all external peers\n"
5190 "Soft reconfig\n"
5191 "Soft reconfig inbound update\n")
5192{
5193 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5194 BGP_CLEAR_SOFT_IN, NULL);
5195}
5196
5197ALIAS (clear_ip_bgp_external_soft_in,
5198 clear_ip_bgp_external_in_cmd,
5199 "clear ip bgp external in",
5200 CLEAR_STR
5201 IP_STR
5202 BGP_STR
5203 "Clear all external peers\n"
5204 "Soft reconfig inbound update\n")
5205
5206DEFUN (clear_ip_bgp_external_in_prefix_filter,
5207 clear_ip_bgp_external_in_prefix_filter_cmd,
5208 "clear ip bgp external in prefix-filter",
5209 CLEAR_STR
5210 IP_STR
5211 BGP_STR
5212 "Clear all external peers\n"
5213 "Soft reconfig inbound update\n"
5214 "Push out prefix-list ORF and do inbound soft reconfig\n")
5215{
5216 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5217 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5218}
5219
5220DEFUN (clear_ip_bgp_external_ipv4_soft_in,
5221 clear_ip_bgp_external_ipv4_soft_in_cmd,
5222 "clear ip bgp external ipv4 (unicast|multicast) soft in",
5223 CLEAR_STR
5224 IP_STR
5225 BGP_STR
5226 "Clear all external peers\n"
5227 "Address family\n"
5228 "Address Family modifier\n"
5229 "Address Family modifier\n"
5230 "Soft reconfig\n"
5231 "Soft reconfig inbound update\n")
5232{
5233 if (strncmp (argv[0], "m", 1) == 0)
5234 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
5235 BGP_CLEAR_SOFT_IN, NULL);
5236
5237 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5238 BGP_CLEAR_SOFT_IN, NULL);
5239}
5240
5241ALIAS (clear_ip_bgp_external_ipv4_soft_in,
5242 clear_ip_bgp_external_ipv4_in_cmd,
5243 "clear ip bgp external ipv4 (unicast|multicast) in",
5244 CLEAR_STR
5245 IP_STR
5246 BGP_STR
5247 "Clear all external peers\n"
5248 "Address family\n"
5249 "Address Family modifier\n"
5250 "Address Family modifier\n"
5251 "Soft reconfig inbound update\n")
5252
5253DEFUN (clear_ip_bgp_external_ipv4_in_prefix_filter,
5254 clear_ip_bgp_external_ipv4_in_prefix_filter_cmd,
5255 "clear ip bgp external ipv4 (unicast|multicast) in prefix-filter",
5256 CLEAR_STR
5257 IP_STR
5258 BGP_STR
5259 "Clear all external peers\n"
5260 "Address family\n"
5261 "Address Family modifier\n"
5262 "Address Family modifier\n"
5263 "Soft reconfig inbound update\n"
5264 "Push out prefix-list ORF and do inbound soft reconfig\n")
5265{
5266 if (strncmp (argv[0], "m", 1) == 0)
5267 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
5268 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5269
5270 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5271 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5272}
5273
5274DEFUN (clear_bgp_external_soft_in,
5275 clear_bgp_external_soft_in_cmd,
5276 "clear bgp external soft in",
5277 CLEAR_STR
5278 BGP_STR
5279 "Clear all external peers\n"
5280 "Soft reconfig\n"
5281 "Soft reconfig inbound update\n")
5282{
5283 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
5284 BGP_CLEAR_SOFT_IN, NULL);
5285}
5286
5287ALIAS (clear_bgp_external_soft_in,
5288 clear_bgp_ipv6_external_soft_in_cmd,
5289 "clear bgp ipv6 external soft in",
5290 CLEAR_STR
5291 BGP_STR
5292 "Address family\n"
5293 "Clear all external peers\n"
5294 "Soft reconfig\n"
5295 "Soft reconfig inbound update\n")
5296
5297ALIAS (clear_bgp_external_soft_in,
5298 clear_bgp_external_in_cmd,
5299 "clear bgp external in",
5300 CLEAR_STR
5301 BGP_STR
5302 "Clear all external peers\n"
5303 "Soft reconfig inbound update\n")
5304
5305ALIAS (clear_bgp_external_soft_in,
5306 clear_bgp_ipv6_external_in_cmd,
5307 "clear bgp ipv6 external WORD in",
5308 CLEAR_STR
5309 BGP_STR
5310 "Address family\n"
5311 "Clear all external peers\n"
5312 "Soft reconfig inbound update\n")
5313
5314DEFUN (clear_bgp_external_in_prefix_filter,
5315 clear_bgp_external_in_prefix_filter_cmd,
5316 "clear bgp external in prefix-filter",
5317 CLEAR_STR
5318 BGP_STR
5319 "Clear all external peers\n"
5320 "Soft reconfig inbound update\n"
5321 "Push out prefix-list ORF and do inbound soft reconfig\n")
5322{
5323 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
5324 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5325}
5326
5327ALIAS (clear_bgp_external_in_prefix_filter,
5328 clear_bgp_ipv6_external_in_prefix_filter_cmd,
5329 "clear bgp ipv6 external in prefix-filter",
5330 CLEAR_STR
5331 BGP_STR
5332 "Address family\n"
5333 "Clear all external peers\n"
5334 "Soft reconfig inbound update\n"
5335 "Push out prefix-list ORF and do inbound soft reconfig\n")
5336
5337DEFUN (clear_ip_bgp_as_soft_in,
5338 clear_ip_bgp_as_soft_in_cmd,
5339 "clear ip bgp <1-65535> soft in",
5340 CLEAR_STR
5341 IP_STR
5342 BGP_STR
5343 "Clear peers with the AS number\n"
5344 "Soft reconfig\n"
5345 "Soft reconfig inbound update\n")
5346{
5347 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5348 BGP_CLEAR_SOFT_IN, argv[0]);
5349}
5350
5351ALIAS (clear_ip_bgp_as_soft_in,
5352 clear_ip_bgp_as_in_cmd,
5353 "clear ip bgp <1-65535> in",
5354 CLEAR_STR
5355 IP_STR
5356 BGP_STR
5357 "Clear peers with the AS number\n"
5358 "Soft reconfig inbound update\n")
5359
5360DEFUN (clear_ip_bgp_as_in_prefix_filter,
5361 clear_ip_bgp_as_in_prefix_filter_cmd,
5362 "clear ip bgp <1-65535> in prefix-filter",
5363 CLEAR_STR
5364 IP_STR
5365 BGP_STR
5366 "Clear peers with the AS number\n"
5367 "Soft reconfig inbound update\n"
5368 "Push out prefix-list ORF and do inbound soft reconfig\n")
5369{
5370 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5371 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5372}
5373
5374DEFUN (clear_ip_bgp_as_ipv4_soft_in,
5375 clear_ip_bgp_as_ipv4_soft_in_cmd,
5376 "clear ip bgp <1-65535> ipv4 (unicast|multicast) soft in",
5377 CLEAR_STR
5378 IP_STR
5379 BGP_STR
5380 "Clear peers with the AS number\n"
5381 "Address family\n"
5382 "Address Family modifier\n"
5383 "Address Family modifier\n"
5384 "Soft reconfig\n"
5385 "Soft reconfig inbound update\n")
5386{
5387 if (strncmp (argv[1], "m", 1) == 0)
5388 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
5389 BGP_CLEAR_SOFT_IN, argv[0]);
5390
5391 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5392 BGP_CLEAR_SOFT_IN, argv[0]);
5393}
5394
5395ALIAS (clear_ip_bgp_as_ipv4_soft_in,
5396 clear_ip_bgp_as_ipv4_in_cmd,
5397 "clear ip bgp <1-65535> ipv4 (unicast|multicast) in",
5398 CLEAR_STR
5399 IP_STR
5400 BGP_STR
5401 "Clear peers with the AS number\n"
5402 "Address family\n"
5403 "Address Family modifier\n"
5404 "Address Family modifier\n"
5405 "Soft reconfig inbound update\n")
5406
5407DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter,
5408 clear_ip_bgp_as_ipv4_in_prefix_filter_cmd,
5409 "clear ip bgp <1-65535> ipv4 (unicast|multicast) in prefix-filter",
5410 CLEAR_STR
5411 IP_STR
5412 BGP_STR
5413 "Clear peers with the AS number\n"
5414 "Address family\n"
5415 "Address Family modifier\n"
5416 "Address Family modifier\n"
5417 "Soft reconfig inbound update\n"
5418 "Push out prefix-list ORF and do inbound soft reconfig\n")
5419{
5420 if (strncmp (argv[1], "m", 1) == 0)
5421 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
5422 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5423
5424 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5425 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5426}
5427
5428DEFUN (clear_ip_bgp_as_vpnv4_soft_in,
5429 clear_ip_bgp_as_vpnv4_soft_in_cmd,
5430 "clear ip bgp <1-65535> vpnv4 unicast soft in",
5431 CLEAR_STR
5432 IP_STR
5433 BGP_STR
5434 "Clear peers with the AS number\n"
5435 "Address family\n"
5436 "Address Family modifier\n"
5437 "Soft reconfig\n"
5438 "Soft reconfig inbound update\n")
5439{
5440 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
5441 BGP_CLEAR_SOFT_IN, argv[0]);
5442}
5443
5444ALIAS (clear_ip_bgp_as_vpnv4_soft_in,
5445 clear_ip_bgp_as_vpnv4_in_cmd,
5446 "clear ip bgp <1-65535> vpnv4 unicast in",
5447 CLEAR_STR
5448 IP_STR
5449 BGP_STR
5450 "Clear peers with the AS number\n"
5451 "Address family\n"
5452 "Address Family modifier\n"
5453 "Soft reconfig inbound update\n")
5454
5455DEFUN (clear_bgp_as_soft_in,
5456 clear_bgp_as_soft_in_cmd,
5457 "clear bgp <1-65535> soft in",
5458 CLEAR_STR
5459 BGP_STR
5460 "Clear peers with the AS number\n"
5461 "Soft reconfig\n"
5462 "Soft reconfig inbound update\n")
5463{
5464 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
5465 BGP_CLEAR_SOFT_IN, argv[0]);
5466}
5467
5468ALIAS (clear_bgp_as_soft_in,
5469 clear_bgp_ipv6_as_soft_in_cmd,
5470 "clear bgp ipv6 <1-65535> soft in",
5471 CLEAR_STR
5472 BGP_STR
5473 "Address family\n"
5474 "Clear peers with the AS number\n"
5475 "Soft reconfig\n"
5476 "Soft reconfig inbound update\n")
5477
5478ALIAS (clear_bgp_as_soft_in,
5479 clear_bgp_as_in_cmd,
5480 "clear bgp <1-65535> in",
5481 CLEAR_STR
5482 BGP_STR
5483 "Clear peers with the AS number\n"
5484 "Soft reconfig inbound update\n")
5485
5486ALIAS (clear_bgp_as_soft_in,
5487 clear_bgp_ipv6_as_in_cmd,
5488 "clear bgp ipv6 <1-65535> in",
5489 CLEAR_STR
5490 BGP_STR
5491 "Address family\n"
5492 "Clear peers with the AS number\n"
5493 "Soft reconfig inbound update\n")
5494
5495DEFUN (clear_bgp_as_in_prefix_filter,
5496 clear_bgp_as_in_prefix_filter_cmd,
5497 "clear bgp <1-65535> in prefix-filter",
5498 CLEAR_STR
5499 BGP_STR
5500 "Clear peers with the AS number\n"
5501 "Soft reconfig inbound update\n"
5502 "Push out prefix-list ORF and do inbound soft reconfig\n")
5503{
5504 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
5505 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5506}
5507
5508ALIAS (clear_bgp_as_in_prefix_filter,
5509 clear_bgp_ipv6_as_in_prefix_filter_cmd,
5510 "clear bgp ipv6 <1-65535> in prefix-filter",
5511 CLEAR_STR
5512 BGP_STR
5513 "Address family\n"
5514 "Clear peers with the AS number\n"
5515 "Soft reconfig inbound update\n"
5516 "Push out prefix-list ORF and do inbound soft reconfig\n")
5517
5518/* Both soft-reconfiguration */
5519DEFUN (clear_ip_bgp_all_soft,
5520 clear_ip_bgp_all_soft_cmd,
5521 "clear ip bgp * soft",
5522 CLEAR_STR
5523 IP_STR
5524 BGP_STR
5525 "Clear all peers\n"
5526 "Soft reconfig\n")
5527{
5528 if (argc == 1)
5529 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5530 BGP_CLEAR_SOFT_BOTH, NULL);
5531
5532 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5533 BGP_CLEAR_SOFT_BOTH, NULL);
5534}
5535
5536ALIAS (clear_ip_bgp_all_soft,
5537 clear_ip_bgp_instance_all_soft_cmd,
5538 "clear ip bgp view WORD * soft",
5539 CLEAR_STR
5540 IP_STR
5541 BGP_STR
5542 "BGP view\n"
5543 "view name\n"
5544 "Clear all peers\n"
5545 "Soft reconfig\n")
5546
5547
5548DEFUN (clear_ip_bgp_all_ipv4_soft,
5549 clear_ip_bgp_all_ipv4_soft_cmd,
5550 "clear ip bgp * ipv4 (unicast|multicast) soft",
5551 CLEAR_STR
5552 IP_STR
5553 BGP_STR
5554 "Clear all peers\n"
5555 "Address family\n"
5556 "Address Family Modifier\n"
5557 "Address Family Modifier\n"
5558 "Soft reconfig\n")
5559{
5560 if (strncmp (argv[0], "m", 1) == 0)
5561 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
5562 BGP_CLEAR_SOFT_BOTH, NULL);
5563
5564 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5565 BGP_CLEAR_SOFT_BOTH, NULL);
5566}
5567
5568DEFUN (clear_ip_bgp_instance_all_ipv4_soft,
5569 clear_ip_bgp_instance_all_ipv4_soft_cmd,
5570 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft",
5571 CLEAR_STR
5572 IP_STR
5573 BGP_STR
5574 "BGP view\n"
5575 "view name\n"
5576 "Clear all peers\n"
5577 "Address family\n"
5578 "Address Family Modifier\n"
5579 "Address Family Modifier\n"
5580 "Soft reconfig\n")
5581{
5582 if (strncmp (argv[1], "m", 1) == 0)
5583 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
5584 BGP_CLEAR_SOFT_BOTH, NULL);
5585
5586 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5587 BGP_CLEAR_SOFT_BOTH, NULL);
5588}
5589
5590DEFUN (clear_ip_bgp_all_vpnv4_soft,
5591 clear_ip_bgp_all_vpnv4_soft_cmd,
5592 "clear ip bgp * vpnv4 unicast soft",
5593 CLEAR_STR
5594 IP_STR
5595 BGP_STR
5596 "Clear all peers\n"
5597 "Address family\n"
5598 "Address Family Modifier\n"
5599 "Soft reconfig\n")
5600{
5601 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
5602 BGP_CLEAR_SOFT_BOTH, argv[0]);
5603}
5604
5605DEFUN (clear_bgp_all_soft,
5606 clear_bgp_all_soft_cmd,
5607 "clear bgp * soft",
5608 CLEAR_STR
5609 BGP_STR
5610 "Clear all peers\n"
5611 "Soft reconfig\n")
5612{
5613 if (argc == 1)
5614 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
5615 BGP_CLEAR_SOFT_BOTH, argv[0]);
5616
5617 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
5618 BGP_CLEAR_SOFT_BOTH, argv[0]);
5619}
5620
5621ALIAS (clear_bgp_all_soft,
5622 clear_bgp_instance_all_soft_cmd,
5623 "clear bgp view WORD * soft",
5624 CLEAR_STR
5625 BGP_STR
5626 "BGP view\n"
5627 "view name\n"
5628 "Clear all peers\n"
5629 "Soft reconfig\n")
5630
5631ALIAS (clear_bgp_all_soft,
5632 clear_bgp_ipv6_all_soft_cmd,
5633 "clear bgp ipv6 * soft",
5634 CLEAR_STR
5635 BGP_STR
5636 "Address family\n"
5637 "Clear all peers\n"
5638 "Soft reconfig\n")
5639
5640DEFUN (clear_ip_bgp_peer_soft,
5641 clear_ip_bgp_peer_soft_cmd,
5642 "clear ip bgp A.B.C.D soft",
5643 CLEAR_STR
5644 IP_STR
5645 BGP_STR
5646 "BGP neighbor address to clear\n"
5647 "Soft reconfig\n")
5648{
5649 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5650 BGP_CLEAR_SOFT_BOTH, argv[0]);
5651}
5652
5653DEFUN (clear_ip_bgp_peer_ipv4_soft,
5654 clear_ip_bgp_peer_ipv4_soft_cmd,
5655 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft",
5656 CLEAR_STR
5657 IP_STR
5658 BGP_STR
5659 "BGP neighbor address to clear\n"
5660 "Address family\n"
5661 "Address Family Modifier\n"
5662 "Address Family Modifier\n"
5663 "Soft reconfig\n")
5664{
5665 if (strncmp (argv[1], "m", 1) == 0)
5666 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
5667 BGP_CLEAR_SOFT_BOTH, argv[0]);
5668
5669 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5670 BGP_CLEAR_SOFT_BOTH, argv[0]);
5671}
5672
5673DEFUN (clear_ip_bgp_peer_vpnv4_soft,
5674 clear_ip_bgp_peer_vpnv4_soft_cmd,
5675 "clear ip bgp A.B.C.D vpnv4 unicast soft",
5676 CLEAR_STR
5677 IP_STR
5678 BGP_STR
5679 "BGP neighbor address to clear\n"
5680 "Address family\n"
5681 "Address Family Modifier\n"
5682 "Soft reconfig\n")
5683{
5684 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
5685 BGP_CLEAR_SOFT_BOTH, argv[0]);
5686}
5687
5688DEFUN (clear_bgp_peer_soft,
5689 clear_bgp_peer_soft_cmd,
5690 "clear bgp (A.B.C.D|X:X::X:X) soft",
5691 CLEAR_STR
5692 BGP_STR
5693 "BGP neighbor address to clear\n"
5694 "BGP IPv6 neighbor to clear\n"
5695 "Soft reconfig\n")
5696{
5697 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
5698 BGP_CLEAR_SOFT_BOTH, argv[0]);
5699}
5700
5701ALIAS (clear_bgp_peer_soft,
5702 clear_bgp_ipv6_peer_soft_cmd,
5703 "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft",
5704 CLEAR_STR
5705 BGP_STR
5706 "Address family\n"
5707 "BGP neighbor address to clear\n"
5708 "BGP IPv6 neighbor to clear\n"
5709 "Soft reconfig\n")
5710
5711DEFUN (clear_ip_bgp_peer_group_soft,
5712 clear_ip_bgp_peer_group_soft_cmd,
5713 "clear ip bgp peer-group WORD soft",
5714 CLEAR_STR
5715 IP_STR
5716 BGP_STR
5717 "Clear all members of peer-group\n"
5718 "BGP peer-group name\n"
5719 "Soft reconfig\n")
5720{
5721 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5722 BGP_CLEAR_SOFT_BOTH, argv[0]);
5723}
5724
5725DEFUN (clear_ip_bgp_peer_group_ipv4_soft,
5726 clear_ip_bgp_peer_group_ipv4_soft_cmd,
5727 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft",
5728 CLEAR_STR
5729 IP_STR
5730 BGP_STR
5731 "Clear all members of peer-group\n"
5732 "BGP peer-group name\n"
5733 "Address family\n"
5734 "Address Family modifier\n"
5735 "Address Family modifier\n"
5736 "Soft reconfig\n")
5737{
5738 if (strncmp (argv[1], "m", 1) == 0)
5739 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
5740 BGP_CLEAR_SOFT_BOTH, argv[0]);
5741
5742 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5743 BGP_CLEAR_SOFT_BOTH, argv[0]);
5744}
5745
5746DEFUN (clear_bgp_peer_group_soft,
5747 clear_bgp_peer_group_soft_cmd,
5748 "clear bgp peer-group WORD soft",
5749 CLEAR_STR
5750 BGP_STR
5751 "Clear all members of peer-group\n"
5752 "BGP peer-group name\n"
5753 "Soft reconfig\n")
5754{
5755 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
5756 BGP_CLEAR_SOFT_BOTH, argv[0]);
5757}
5758
5759ALIAS (clear_bgp_peer_group_soft,
5760 clear_bgp_ipv6_peer_group_soft_cmd,
5761 "clear bgp ipv6 peer-group WORD soft",
5762 CLEAR_STR
5763 BGP_STR
5764 "Address family\n"
5765 "Clear all members of peer-group\n"
5766 "BGP peer-group name\n"
5767 "Soft reconfig\n")
5768
5769DEFUN (clear_ip_bgp_external_soft,
5770 clear_ip_bgp_external_soft_cmd,
5771 "clear ip bgp external soft",
5772 CLEAR_STR
5773 IP_STR
5774 BGP_STR
5775 "Clear all external peers\n"
5776 "Soft reconfig\n")
5777{
5778 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5779 BGP_CLEAR_SOFT_BOTH, NULL);
5780}
5781
5782DEFUN (clear_ip_bgp_external_ipv4_soft,
5783 clear_ip_bgp_external_ipv4_soft_cmd,
5784 "clear ip bgp external ipv4 (unicast|multicast) soft",
5785 CLEAR_STR
5786 IP_STR
5787 BGP_STR
5788 "Clear all external peers\n"
5789 "Address family\n"
5790 "Address Family modifier\n"
5791 "Address Family modifier\n"
5792 "Soft reconfig\n")
5793{
5794 if (strncmp (argv[0], "m", 1) == 0)
5795 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
5796 BGP_CLEAR_SOFT_BOTH, NULL);
5797
5798 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5799 BGP_CLEAR_SOFT_BOTH, NULL);
5800}
5801
5802DEFUN (clear_bgp_external_soft,
5803 clear_bgp_external_soft_cmd,
5804 "clear bgp external soft",
5805 CLEAR_STR
5806 BGP_STR
5807 "Clear all external peers\n"
5808 "Soft reconfig\n")
5809{
5810 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
5811 BGP_CLEAR_SOFT_BOTH, NULL);
5812}
5813
5814ALIAS (clear_bgp_external_soft,
5815 clear_bgp_ipv6_external_soft_cmd,
5816 "clear bgp ipv6 external soft",
5817 CLEAR_STR
5818 BGP_STR
5819 "Address family\n"
5820 "Clear all external peers\n"
5821 "Soft reconfig\n")
5822
5823DEFUN (clear_ip_bgp_as_soft,
5824 clear_ip_bgp_as_soft_cmd,
5825 "clear ip bgp <1-65535> soft",
5826 CLEAR_STR
5827 IP_STR
5828 BGP_STR
5829 "Clear peers with the AS number\n"
5830 "Soft reconfig\n")
5831{
5832 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5833 BGP_CLEAR_SOFT_BOTH, argv[0]);
5834}
5835
5836DEFUN (clear_ip_bgp_as_ipv4_soft,
5837 clear_ip_bgp_as_ipv4_soft_cmd,
5838 "clear ip bgp <1-65535> ipv4 (unicast|multicast) soft",
5839 CLEAR_STR
5840 IP_STR
5841 BGP_STR
5842 "Clear peers with the AS number\n"
5843 "Address family\n"
5844 "Address Family Modifier\n"
5845 "Address Family Modifier\n"
5846 "Soft reconfig\n")
5847{
5848 if (strncmp (argv[1], "m", 1) == 0)
5849 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
5850 BGP_CLEAR_SOFT_BOTH, argv[0]);
5851
5852 return bgp_clear_vty (vty, NULL,AFI_IP, SAFI_UNICAST, clear_as,
5853 BGP_CLEAR_SOFT_BOTH, argv[0]);
5854}
5855
5856DEFUN (clear_ip_bgp_as_vpnv4_soft,
5857 clear_ip_bgp_as_vpnv4_soft_cmd,
5858 "clear ip bgp <1-65535> vpnv4 unicast soft",
5859 CLEAR_STR
5860 IP_STR
5861 BGP_STR
5862 "Clear peers with the AS number\n"
5863 "Address family\n"
5864 "Address Family Modifier\n"
5865 "Soft reconfig\n")
5866{
5867 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
5868 BGP_CLEAR_SOFT_BOTH, argv[0]);
5869}
5870
5871DEFUN (clear_bgp_as_soft,
5872 clear_bgp_as_soft_cmd,
5873 "clear bgp <1-65535> soft",
5874 CLEAR_STR
5875 BGP_STR
5876 "Clear peers with the AS number\n"
5877 "Soft reconfig\n")
5878{
5879 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
5880 BGP_CLEAR_SOFT_BOTH, argv[0]);
5881}
5882
5883ALIAS (clear_bgp_as_soft,
5884 clear_bgp_ipv6_as_soft_cmd,
5885 "clear bgp ipv6 <1-65535> soft",
5886 CLEAR_STR
5887 BGP_STR
5888 "Address family\n"
5889 "Clear peers with the AS number\n"
5890 "Soft reconfig\n")
5891
5892/* Show BGP peer's summary information. */
5893int
5894bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi)
5895{
5896 struct peer *peer;
5897 struct listnode *nn;
5898 int count = 0;
5899 char timebuf[BGP_UPTIME_LEN];
5900 int len;
5901
5902 /* Header string for each address family. */
5903 static char header[] = "Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd";
5904
5905 LIST_LOOP (bgp->peer, peer, nn)
5906 {
5907 if (peer->afc[afi][safi])
5908 {
5909 if (! count)
5910 {
5911 vty_out (vty,
5912 "BGP router identifier %s, local AS number %d%s",
5913 inet_ntoa (bgp->router_id), bgp->as, VTY_NEWLINE);
5914 vty_out (vty,
5915 "%ld BGP AS-PATH entries%s", aspath_count (),
5916 VTY_NEWLINE);
5917 vty_out (vty,
5918 "%ld BGP community entries%s", community_count (),
5919 VTY_NEWLINE);
5920
5921 if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
5922 vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE);
5923 vty_out (vty, "%s", VTY_NEWLINE);
5924 vty_out (vty, "%s%s", header, VTY_NEWLINE);
5925 }
5926 count++;
5927
5928 len = vty_out (vty, "%s", peer->host);
5929 len = 16 - len;
5930 if (len < 1)
5931 vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
5932 else
5933 vty_out (vty, "%*s", len, " ");
5934
5935 switch (peer->version)
5936 {
5937 case BGP_VERSION_4:
5938 vty_out (vty, "4 ");
5939 break;
5940 case BGP_VERSION_MP_4_DRAFT_00:
5941 vty_out (vty, "4-");
5942 break;
5943 }
5944
5945 vty_out (vty, "%5d %7d %7d %8d %4d %4ld ",
5946 peer->as,
5947 peer->open_in + peer->update_in + peer->keepalive_in
5948 + peer->notify_in + peer->refresh_in + peer->dynamic_cap_in,
5949 peer->open_out + peer->update_out + peer->keepalive_out
5950 + peer->notify_out + peer->refresh_out
5951 + peer->dynamic_cap_out,
5952 0, 0, peer->obuf->count);
5953
5954 vty_out (vty, "%8s",
5955 peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN));
5956
5957 if (peer->status == Established)
5958 {
5959 vty_out (vty, " %8ld", peer->pcount[afi][safi]);
5960 }
5961 else
5962 {
5963 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
5964 vty_out (vty, " Idle (Admin)");
5965 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
5966 vty_out (vty, " Idle (PfxCt)");
5967 else
5968 vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, peer->status));
5969 }
5970
5971 vty_out (vty, "%s", VTY_NEWLINE);
5972 }
5973 }
5974
5975 if (count)
5976 vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE,
5977 count, VTY_NEWLINE);
5978 else
5979 vty_out (vty, "No %s neighbor is configured%s",
5980 afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
5981 return CMD_SUCCESS;
5982}
5983
5984int
5985bgp_show_summary_vty (struct vty *vty, char *name, afi_t afi, safi_t safi)
5986{
5987 struct bgp *bgp;
5988
5989 if (name)
5990 {
5991 bgp = bgp_lookup_by_name (name);
5992
5993 if (! bgp)
5994 {
5995 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
5996 return CMD_WARNING;
5997 }
5998
5999 bgp_show_summary (vty, bgp, afi, safi);
6000 return CMD_SUCCESS;
6001 }
6002
6003 bgp = bgp_get_default ();
6004
6005 if (bgp)
6006 bgp_show_summary (vty, bgp, afi, safi);
6007
6008 return CMD_SUCCESS;
6009}
6010
6011/* `show ip bgp summary' commands. */
6012DEFUN (show_ip_bgp_summary,
6013 show_ip_bgp_summary_cmd,
6014 "show ip bgp summary",
6015 SHOW_STR
6016 IP_STR
6017 BGP_STR
6018 "Summary of BGP neighbor status\n")
6019{
6020 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
6021}
6022
6023DEFUN (show_ip_bgp_instance_summary,
6024 show_ip_bgp_instance_summary_cmd,
6025 "show ip bgp view WORD summary",
6026 SHOW_STR
6027 IP_STR
6028 BGP_STR
6029 "BGP view\n"
6030 "View name\n"
6031 "Summary of BGP neighbor status\n")
6032{
6033 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
6034}
6035
6036DEFUN (show_ip_bgp_ipv4_summary,
6037 show_ip_bgp_ipv4_summary_cmd,
6038 "show ip bgp ipv4 (unicast|multicast) summary",
6039 SHOW_STR
6040 IP_STR
6041 BGP_STR
6042 "Address family\n"
6043 "Address Family modifier\n"
6044 "Address Family modifier\n"
6045 "Summary of BGP neighbor status\n")
6046{
6047 if (strncmp (argv[0], "m", 1) == 0)
6048 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST);
6049
6050 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
6051}
6052
6053DEFUN (show_ip_bgp_instance_ipv4_summary,
6054 show_ip_bgp_instance_ipv4_summary_cmd,
6055 "show ip bgp view WORD ipv4 (unicast|multicast) summary",
6056 SHOW_STR
6057 IP_STR
6058 BGP_STR
6059 "BGP view\n"
6060 "View name\n"
6061 "Address family\n"
6062 "Address Family modifier\n"
6063 "Address Family modifier\n"
6064 "Summary of BGP neighbor status\n")
6065{
6066 if (strncmp (argv[1], "m", 1) == 0)
6067 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST);
6068 else
6069 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
6070}
6071
6072DEFUN (show_ip_bgp_vpnv4_all_summary,
6073 show_ip_bgp_vpnv4_all_summary_cmd,
6074 "show ip bgp vpnv4 all summary",
6075 SHOW_STR
6076 IP_STR
6077 BGP_STR
6078 "Display VPNv4 NLRI specific information\n"
6079 "Display information about all VPNv4 NLRIs\n"
6080 "Summary of BGP neighbor status\n")
6081{
6082 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN);
6083}
6084
6085DEFUN (show_ip_bgp_vpnv4_rd_summary,
6086 show_ip_bgp_vpnv4_rd_summary_cmd,
6087 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn summary",
6088 SHOW_STR
6089 IP_STR
6090 BGP_STR
6091 "Display VPNv4 NLRI specific information\n"
6092 "Display information for a route distinguisher\n"
6093 "VPN Route Distinguisher\n"
6094 "Summary of BGP neighbor status\n")
6095{
6096 int ret;
6097 struct prefix_rd prd;
6098
6099 ret = str2prefix_rd (argv[0], &prd);
6100 if (! ret)
6101 {
6102 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
6103 return CMD_WARNING;
6104 }
6105
6106 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN);
6107}
6108
6109#ifdef HAVE_IPV6
6110DEFUN (show_bgp_summary,
6111 show_bgp_summary_cmd,
6112 "show bgp summary",
6113 SHOW_STR
6114 BGP_STR
6115 "Summary of BGP neighbor status\n")
6116{
6117 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
6118}
6119
6120DEFUN (show_bgp_instance_summary,
6121 show_bgp_instance_summary_cmd,
6122 "show bgp view WORD summary",
6123 SHOW_STR
6124 BGP_STR
6125 "BGP view\n"
6126 "View name\n"
6127 "Summary of BGP neighbor status\n")
6128{
6129 return bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
6130}
6131
6132ALIAS (show_bgp_summary,
6133 show_bgp_ipv6_summary_cmd,
6134 "show bgp ipv6 summary",
6135 SHOW_STR
6136 BGP_STR
6137 "Address family\n"
6138 "Summary of BGP neighbor status\n")
6139
6140ALIAS (show_bgp_instance_summary,
6141 show_bgp_instance_ipv6_summary_cmd,
6142 "show bgp view WORD ipv6 summary",
6143 SHOW_STR
6144 BGP_STR
6145 "BGP view\n"
6146 "View name\n"
6147 "Address family\n"
6148 "Summary of BGP neighbor status\n")
6149
6150/* old command */
6151DEFUN (show_ipv6_bgp_summary,
6152 show_ipv6_bgp_summary_cmd,
6153 "show ipv6 bgp summary",
6154 SHOW_STR
6155 IPV6_STR
6156 BGP_STR
6157 "Summary of BGP neighbor status\n")
6158{
6159 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
6160}
6161
6162/* old command */
6163DEFUN (show_ipv6_mbgp_summary,
6164 show_ipv6_mbgp_summary_cmd,
6165 "show ipv6 mbgp summary",
6166 SHOW_STR
6167 IPV6_STR
6168 MBGP_STR
6169 "Summary of BGP neighbor status\n")
6170{
6171 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST);
6172}
6173#endif /* HAVE_IPV6 */
6174
6175/* Show BGP peer's information. */
6176enum show_type
6177{
6178 show_all,
6179 show_peer
6180};
6181
6182void
6183bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p,
6184 afi_t afi, safi_t safi,
6185 u_int16_t adv_smcap, u_int16_t adv_rmcap,
6186 u_int16_t rcv_smcap, u_int16_t rcv_rmcap)
6187{
6188 /* Send-Mode */
6189 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)
6190 || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
6191 {
6192 vty_out (vty, " Send-mode: ");
6193 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
6194 vty_out (vty, "advertised");
6195 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
6196 vty_out (vty, "%sreceived",
6197 CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ?
6198 ", " : "");
6199 vty_out (vty, "%s", VTY_NEWLINE);
6200 }
6201
6202 /* Receive-Mode */
6203 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)
6204 || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
6205 {
6206 vty_out (vty, " Receive-mode: ");
6207 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
6208 vty_out (vty, "advertised");
6209 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
6210 vty_out (vty, "%sreceived",
6211 CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ?
6212 ", " : "");
6213 vty_out (vty, "%s", VTY_NEWLINE);
6214 }
6215}
6216
6217void
6218bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi)
6219{
6220 struct bgp_filter *filter;
6221 char orf_pfx_name[BUFSIZ];
6222 int orf_pfx_count;
6223
6224 filter = &p->filter[afi][safi];
6225
6226 vty_out (vty, " For address family: %s %s%s",
6227 afi == AFI_IP6 ? "IPv6" :
6228 safi == SAFI_MPLS_VPN ? "VPNv4" : "IPv4",
6229 safi == SAFI_MULTICAST ? "Multicast" : "Unicast",
6230 VTY_NEWLINE);
6231 if (p->af_group[afi][safi])
6232 vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE);
6233
6234 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
6235 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
6236 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
6237 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
6238 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
6239 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
6240 vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE);
6241
6242 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
6243 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
6244 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
6245 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
6246 {
6247 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
6248 ORF_TYPE_PREFIX, VTY_NEWLINE);
6249 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
6250 PEER_CAP_ORF_PREFIX_SM_ADV,
6251 PEER_CAP_ORF_PREFIX_RM_ADV,
6252 PEER_CAP_ORF_PREFIX_SM_RCV,
6253 PEER_CAP_ORF_PREFIX_RM_RCV);
6254 }
6255 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
6256 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
6257 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
6258 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
6259 {
6260 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
6261 ORF_TYPE_PREFIX_OLD, VTY_NEWLINE);
6262 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
6263 PEER_CAP_ORF_PREFIX_SM_ADV,
6264 PEER_CAP_ORF_PREFIX_RM_ADV,
6265 PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
6266 PEER_CAP_ORF_PREFIX_RM_OLD_RCV);
6267 }
6268
6269 sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
6270 orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name);
6271
6272 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
6273 || orf_pfx_count)
6274 {
6275 vty_out (vty, " Outbound Route Filter (ORF):");
6276 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
6277 vty_out (vty, " sent;");
6278 if (orf_pfx_count)
6279 vty_out (vty, " received (%d entries)", orf_pfx_count);
6280 vty_out (vty, "%s", VTY_NEWLINE);
6281 }
6282 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
6283 vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE);
6284
6285 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
6286 vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE);
6287 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
6288 vty_out (vty, " Route-Server Client%s", VTY_NEWLINE);
6289 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
6290 vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE);
6291 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
6292 vty_out (vty, " Private AS number removed from updates to this neighbor%s", VTY_NEWLINE);
6293 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF))
6294 vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE);
6295 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
6296 vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE);
6297 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
6298 vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE);
6299 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
6300 vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE);
6301 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
6302 || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
6303 {
6304 vty_out (vty, " Community attribute sent to this neighbor");
6305 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
6306 && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
6307 vty_out (vty, " (both)%s", VTY_NEWLINE);
6308 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
6309 vty_out (vty, " (extended)%s", VTY_NEWLINE);
6310 else
6311 vty_out (vty, " (standard)%s", VTY_NEWLINE);
6312 }
6313 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
6314 {
6315 vty_out (vty, " Default information originate,");
6316
6317 if (p->default_rmap[afi][safi].name)
6318 vty_out (vty, " default route-map %s%s,",
6319 p->default_rmap[afi][safi].map ? "*" : "",
6320 p->default_rmap[afi][safi].name);
6321 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
6322 vty_out (vty, " default sent%s", VTY_NEWLINE);
6323 else
6324 vty_out (vty, " default not sent%s", VTY_NEWLINE);
6325 }
6326
6327 if (filter->plist[FILTER_IN].name
6328 || filter->dlist[FILTER_IN].name
6329 || filter->aslist[FILTER_IN].name
6330 || filter->map[FILTER_IN].name)
6331 vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE);
6332 if (filter->plist[FILTER_OUT].name
6333 || filter->dlist[FILTER_OUT].name
6334 || filter->aslist[FILTER_OUT].name
6335 || filter->map[FILTER_OUT].name
6336 || filter->usmap.name)
6337 vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE);
6338
6339 /* prefix-list */
6340 if (filter->plist[FILTER_IN].name)
6341 vty_out (vty, " Incoming update prefix filter list is %s%s%s",
6342 filter->plist[FILTER_IN].plist ? "*" : "",
6343 filter->plist[FILTER_IN].name,
6344 VTY_NEWLINE);
6345 if (filter->plist[FILTER_OUT].name)
6346 vty_out (vty, " Outgoing update prefix filter list is %s%s%s",
6347 filter->plist[FILTER_OUT].plist ? "*" : "",
6348 filter->plist[FILTER_OUT].name,
6349 VTY_NEWLINE);
6350
6351 /* distribute-list */
6352 if (filter->dlist[FILTER_IN].name)
6353 vty_out (vty, " Incoming update network filter list is %s%s%s",
6354 filter->dlist[FILTER_IN].alist ? "*" : "",
6355 filter->dlist[FILTER_IN].name,
6356 VTY_NEWLINE);
6357 if (filter->dlist[FILTER_OUT].name)
6358 vty_out (vty, " Outgoing update network filter list is %s%s%s",
6359 filter->dlist[FILTER_OUT].alist ? "*" : "",
6360 filter->dlist[FILTER_OUT].name,
6361 VTY_NEWLINE);
6362
6363 /* filter-list. */
6364 if (filter->aslist[FILTER_IN].name)
6365 vty_out (vty, " Incoming update AS path filter list is %s%s%s",
6366 filter->aslist[FILTER_IN].aslist ? "*" : "",
6367 filter->aslist[FILTER_IN].name,
6368 VTY_NEWLINE);
6369 if (filter->aslist[FILTER_OUT].name)
6370 vty_out (vty, " Outgoing update AS path filter list is %s%s%s",
6371 filter->aslist[FILTER_OUT].aslist ? "*" : "",
6372 filter->aslist[FILTER_OUT].name,
6373 VTY_NEWLINE);
6374
6375 /* route-map. */
6376 if (filter->map[FILTER_IN].name)
6377 vty_out (vty, " Route map for incoming advertisements is %s%s%s",
6378 filter->map[FILTER_IN].map ? "*" : "",
6379 filter->map[FILTER_IN].name,
6380 VTY_NEWLINE);
6381 if (filter->map[FILTER_OUT].name)
6382 vty_out (vty, " Route map for outgoing advertisements is %s%s%s",
6383 filter->map[FILTER_OUT].map ? "*" : "",
6384 filter->map[FILTER_OUT].name,
6385 VTY_NEWLINE);
6386
6387 /* unsuppress-map */
6388 if (filter->usmap.name)
6389 vty_out (vty, " Route map for selective unsuppress is %s%s%s",
6390 filter->usmap.map ? "*" : "",
6391 filter->usmap.name, VTY_NEWLINE);
6392
6393 /* Receive prefix count */
6394 vty_out (vty, " %ld accepted prefixes",
6395 p->pcount[afi][safi]);
6396 /* Maximum prefix */
6397 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
6398 {
6399 vty_out (vty, ", maximum limit %ld%s",
6400 p->pmax[afi][safi],
6401 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)
6402 ? " (warning-only)" : "");
6403 }
6404 vty_out (vty, "%s", VTY_NEWLINE);
6405
6406 vty_out (vty, "%s", VTY_NEWLINE);
6407}
6408
6409void
6410bgp_show_peer (struct vty *vty, struct peer *p)
6411{
6412 struct bgp *bgp;
6413 char buf1[BUFSIZ];
6414 char timebuf[BGP_UPTIME_LEN];
6415
6416 bgp = p->bgp;
6417
6418 /* Configured IP address. */
6419 vty_out (vty, "BGP neighbor is %s, ", p->host);
6420 vty_out (vty, "remote AS %d, ", p->as);
6421 vty_out (vty, "local AS %d%s, ",
6422 p->change_local_as ? p->change_local_as : p->local_as,
6423 CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ?
6424 " no-prepend" : "");
6425 vty_out (vty, "%s link%s",
6426 p->as == p->local_as ? "internal" : "external",
6427 VTY_NEWLINE);
6428
6429 /* Description. */
6430 if (p->desc)
6431 vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE);
6432
6433 /* Peer-group */
6434 if (p->group)
6435 vty_out (vty, " Member of peer-group %s for session parameters%s",
6436 p->group->name, VTY_NEWLINE);
6437
6438 /* Administrative shutdown. */
6439 if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
6440 vty_out (vty, " Administratively shut down%s", VTY_NEWLINE);
6441
6442 /* BGP Version. */
6443 vty_out (vty, " BGP version 4");
6444 if (p->version == BGP_VERSION_MP_4_DRAFT_00)
6445 vty_out (vty, "(with draft-00 verion of multiporotocol extension)");
6446 vty_out (vty, ", remote router ID %s%s",
6447 inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ),
6448 VTY_NEWLINE);
6449
6450 /* Confederation */
6451 if (bgp_confederation_peers_check (bgp, p->as))
6452 vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE);
6453
6454 /* Status. */
6455 vty_out (vty, " BGP state = %s",
6456 LOOKUP (bgp_status_msg, p->status));
6457 if (p->status == Established)
6458 vty_out (vty, ", up for %8s",
6459 peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN));
6460 vty_out (vty, "%s", VTY_NEWLINE);
6461
6462 /* read timer */
6463 vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN));
6464
6465 /* Configured timer values. */
6466 vty_out (vty, ", hold time is %d, keepalive interval is %d seconds%s",
6467 p->v_holdtime, p->v_keepalive, VTY_NEWLINE);
6468 if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
6469 {
6470 vty_out (vty, " Configured hold time is %d", p->holdtime);
6471 vty_out (vty, ", keepalive interval is %d seconds%s",
6472 p->keepalive, VTY_NEWLINE);
6473 }
6474
6475 /* Capability. */
6476 if (p->status == Established)
6477 {
6478 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
6479 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
6480 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)
6481 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)
6482 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
6483 || p->afc_adv[AFI_IP][SAFI_UNICAST]
6484 || p->afc_recv[AFI_IP][SAFI_UNICAST]
6485 || p->afc_adv[AFI_IP][SAFI_MULTICAST]
6486 || p->afc_recv[AFI_IP][SAFI_MULTICAST]
6487#ifdef HAVE_IPV6
6488 || p->afc_adv[AFI_IP6][SAFI_UNICAST]
6489 || p->afc_recv[AFI_IP6][SAFI_UNICAST]
6490 || p->afc_adv[AFI_IP6][SAFI_MULTICAST]
6491 || p->afc_recv[AFI_IP6][SAFI_MULTICAST]
6492#endif /* HAVE_IPV6 */
6493 || p->afc_adv[AFI_IP][SAFI_MPLS_VPN]
6494 || p->afc_recv[AFI_IP][SAFI_MPLS_VPN])
6495 {
6496 vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE);
6497
6498 /* Dynamic */
6499 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
6500 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
6501 {
6502 vty_out (vty, " Dynamic:");
6503 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
6504 vty_out (vty, " advertised");
6505 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
6506 {
6507 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
6508 vty_out (vty, " and");
6509 vty_out (vty, " received");
6510 }
6511 vty_out (vty, "%s", VTY_NEWLINE);
6512 }
6513
6514 /* Route Refresh */
6515 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
6516 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
6517 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
6518 {
6519 vty_out (vty, " Route refresh:");
6520 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
6521 vty_out (vty, " advertised");
6522 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
6523 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
6524 {
6525 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
6526 vty_out (vty, " and");
6527 vty_out (vty, " received");
6528 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
6529 && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
6530 vty_out (vty, " (old and new)");
6531 else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
6532 vty_out (vty, " (old)");
6533 else
6534 vty_out (vty, " (new)");
6535 }
6536 vty_out (vty, "%s", VTY_NEWLINE);
6537 }
6538
6539 /* IPv4 */
6540 if (p->afc_adv[AFI_IP][SAFI_UNICAST]
6541 || p->afc_recv[AFI_IP][SAFI_UNICAST])
6542 {
6543 vty_out (vty, " Address family IPv4 Unicast:");
6544 if (p->afc_adv[AFI_IP][SAFI_UNICAST])
6545 vty_out (vty, " advertised");
6546 if (p->afc_recv[AFI_IP][SAFI_UNICAST])
6547 {
6548 if (p->afc_adv[AFI_IP][SAFI_UNICAST])
6549 vty_out (vty, " and");
6550 vty_out (vty, " received");
6551 }
6552 vty_out (vty, "%s", VTY_NEWLINE);
6553 }
6554 if (p->afc_adv[AFI_IP][SAFI_MULTICAST] || p->afc_recv[AFI_IP][SAFI_MULTICAST])
6555 {
6556 vty_out (vty, " Address family IPv4 Multicast:");
6557 if (p->afc_adv[AFI_IP][SAFI_MULTICAST])
6558 vty_out (vty, " advertised");
6559 if (p->afc_recv[AFI_IP][SAFI_MULTICAST])
6560 {
6561 if (p->afc_adv[AFI_IP][SAFI_MULTICAST])
6562 vty_out (vty, " and");
6563 vty_out (vty, " received");
6564 }
6565 vty_out (vty, "%s", VTY_NEWLINE);
6566 }
6567 if (p->afc_adv[AFI_IP][SAFI_MPLS_VPN] || p->afc_recv[AFI_IP][SAFI_MPLS_VPN])
6568 {
6569 vty_out (vty, " Address family VPNv4 Unicast:");
6570 if (p->afc_adv[AFI_IP][SAFI_MPLS_VPN])
6571 vty_out (vty, " advertised");
6572 if (p->afc_recv[AFI_IP][SAFI_MPLS_VPN])
6573 {
6574 if (p->afc_adv[AFI_IP][SAFI_MPLS_VPN])
6575 vty_out (vty, " and");
6576 vty_out (vty, " received");
6577 }
6578 vty_out (vty, "%s", VTY_NEWLINE);
6579 }
6580 /* IPv6 */
6581#ifdef HAVE_IPV6
6582 if (p->afc_adv[AFI_IP6][SAFI_UNICAST] || p->afc_recv[AFI_IP6][SAFI_UNICAST])
6583 {
6584 vty_out (vty, " Address family IPv6 Unicast:");
6585 if (p->afc_adv[AFI_IP6][SAFI_UNICAST])
6586 vty_out (vty, " advertised");
6587 if (p->afc_recv[AFI_IP6][SAFI_UNICAST])
6588 {
6589 if (p->afc_adv[AFI_IP6][SAFI_UNICAST])
6590 vty_out (vty, " and");
6591 vty_out (vty, " received");
6592 }
6593 vty_out (vty, "%s", VTY_NEWLINE);
6594 }
6595 if (p->afc_adv[AFI_IP6][SAFI_MULTICAST] || p->afc_recv[AFI_IP6][SAFI_MULTICAST])
6596 {
6597 vty_out (vty, " Address family IPv6 Multicast:");
6598 if (p->afc_adv[AFI_IP6][SAFI_MULTICAST])
6599 vty_out (vty, " advertised");
6600 if (p->afc_recv[AFI_IP6][SAFI_MULTICAST])
6601 {
6602 if (p->afc_adv[AFI_IP6][SAFI_MULTICAST])
6603 vty_out (vty, " and");
6604 vty_out (vty, " received");
6605 }
6606 vty_out (vty, "%s", VTY_NEWLINE);
6607 }
6608#endif /* HAVE_IPV6 */
6609 }
6610 }
6611
6612 /* Packet counts. */
6613 vty_out(vty, " Received %d messages, %d notifications, %d in queue%s",
6614 p->open_in + p->update_in + p->keepalive_in + p->refresh_in
6615 + p->dynamic_cap_in, p->notify_in, 0, VTY_NEWLINE);
6616 vty_out(vty, " Sent %d messages, %d notifications, %ld in queue%s",
6617 p->open_out + p->update_out + p->keepalive_out + p->refresh_out
6618 + p->dynamic_cap_out, p->notify_out, p->obuf->count, VTY_NEWLINE);
6619 vty_out(vty, " Route refresh request: received %d, sent %d%s",
6620 p->refresh_in, p->refresh_out, VTY_NEWLINE);
6621
6622 /* advertisement-interval */
6623 vty_out (vty, " Minimum time between advertisement runs is %d seconds%s",
6624 p->v_routeadv, VTY_NEWLINE);
6625
6626 /* Update-source. */
6627 if (p->update_if || p->update_source)
6628 {
6629 vty_out (vty, " Update source is ");
6630 if (p->update_if)
6631 vty_out (vty, "%s", p->update_if);
6632 else if (p->update_source)
6633 vty_out (vty, "%s",
6634 sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
6635 vty_out (vty, "%s", VTY_NEWLINE);
6636 }
6637
6638 /* Default weight */
6639 if (CHECK_FLAG (p->config, PEER_CONFIG_WEIGHT))
6640 vty_out (vty, " Default weight %d%s", p->weight,
6641 VTY_NEWLINE);
6642
6643 vty_out (vty, "%s", VTY_NEWLINE);
6644
6645 /* Address Family Information */
6646 if (p->afc[AFI_IP][SAFI_UNICAST])
6647 bgp_show_peer_afi (vty, p, AFI_IP, SAFI_UNICAST);
6648 if (p->afc[AFI_IP][SAFI_MULTICAST])
6649 bgp_show_peer_afi (vty, p, AFI_IP, SAFI_MULTICAST);
6650 if (p->afc[AFI_IP][SAFI_MPLS_VPN])
6651 bgp_show_peer_afi (vty, p, AFI_IP, SAFI_MPLS_VPN);
6652#ifdef HAVE_IPV6
6653 if (p->afc[AFI_IP6][SAFI_UNICAST])
6654 bgp_show_peer_afi (vty, p, AFI_IP6, SAFI_UNICAST);
6655 if (p->afc[AFI_IP6][SAFI_MULTICAST])
6656 bgp_show_peer_afi (vty, p, AFI_IP6, SAFI_MULTICAST);
6657#endif /* HAVE_IPV6 */
6658
6659 vty_out (vty, " Connections established %d; dropped %d%s",
6660 p->established, p->dropped,
6661 VTY_NEWLINE);
6662
6663 if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW))
6664 {
6665 vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE);
6666 vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s",
6667 p->host, VTY_NEWLINE);
6668 }
6669
6670 /* EBGP Multihop */
6671 if (peer_sort (p) != BGP_PEER_IBGP && p->ttl > 1)
6672 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
6673 p->ttl, VTY_NEWLINE);
6674
6675 /* Local address. */
6676 if (p->su_local)
6677 {
6678 vty_out (vty, "Local host: %s, Local port: %d%s%s",
6679 sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN),
6680 ntohs (p->su_local->sin.sin_port),
6681 CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE) ?
6682 ", passive-mode" : "",
6683 VTY_NEWLINE);
6684 }
6685
6686 /* Remote address. */
6687 if (p->su_remote)
6688 {
6689 vty_out (vty, "Foreign host: %s, Foreign port: %d%s",
6690 sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN),
6691 ntohs (p->su_remote->sin.sin_port),
6692 VTY_NEWLINE);
6693 }
6694
6695 /* Nexthop display. */
6696 if (p->su_local)
6697 {
6698 vty_out (vty, "Nexthop: %s%s",
6699 inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ),
6700 VTY_NEWLINE);
6701#ifdef HAVE_IPV6
6702 vty_out (vty, "Nexthop global: %s%s",
6703 inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ),
6704 VTY_NEWLINE);
6705 vty_out (vty, "Nexthop local: %s%s",
6706 inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ),
6707 VTY_NEWLINE);
6708 vty_out (vty, "BGP connection: %s%s",
6709 p->shared_network ? "shared network" : "non shared network",
6710 VTY_NEWLINE);
6711#endif /* HAVE_IPV6 */
6712 }
6713
6714 /* Timer information. */
6715 if (p->t_start)
6716 vty_out (vty, "Next start timer due in %ld seconds%s",
6717 thread_timer_remain_second (p->t_start), VTY_NEWLINE);
6718 if (p->t_connect)
6719 vty_out (vty, "Next connect timer due in %ld seconds%s",
6720 thread_timer_remain_second (p->t_connect), VTY_NEWLINE);
6721
6722 vty_out (vty, "Read thread: %s Write thread: %s%s",
6723 p->t_read ? "on" : "off",
6724 p->t_write ? "on" : "off",
6725 VTY_NEWLINE);
6726
6727 if (p->notify.code == BGP_NOTIFY_OPEN_ERR
6728 && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL)
6729 bgp_capability_vty_out (vty, p);
6730
6731 vty_out (vty, "%s", VTY_NEWLINE);
6732}
6733
6734int
6735bgp_show_neighbor (struct vty *vty, struct bgp *bgp,
6736 enum show_type type, union sockunion *su)
6737{
6738 struct listnode *nn;
6739 struct peer *peer;
6740 int find = 0;
6741
6742 LIST_LOOP (bgp->peer, peer, nn)
6743 {
6744 switch (type)
6745 {
6746 case show_all:
6747 bgp_show_peer (vty, peer);
6748 break;
6749 case show_peer:
6750 if (sockunion_same (&peer->su, su))
6751 {
6752 find = 1;
6753 bgp_show_peer (vty, peer);
6754 }
6755 break;
6756 }
6757 }
6758
6759 if (type == show_peer && ! find)
6760 vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE);
6761
6762 return CMD_SUCCESS;
6763}
6764
6765int
6766bgp_show_neighbor_vty (struct vty *vty, char *name, enum show_type type,
6767 char *ip_str)
6768{
6769 int ret;
6770 struct bgp *bgp;
6771 union sockunion su;
6772
6773 if (ip_str)
6774 {
6775 ret = str2sockunion (ip_str, &su);
6776 if (ret < 0)
6777 {
6778 vty_out (vty, "%% Malformed address: %s%s", ip_str, VTY_NEWLINE);
6779 return CMD_WARNING;
6780 }
6781 }
6782
6783 if (name)
6784 {
6785 bgp = bgp_lookup_by_name (name);
6786
6787 if (! bgp)
6788 {
6789 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
6790 return CMD_WARNING;
6791 }
6792
6793 bgp_show_neighbor (vty, bgp, type, &su);
6794
6795 return CMD_SUCCESS;
6796 }
6797
6798 bgp = bgp_get_default ();
6799
6800 if (bgp)
6801 bgp_show_neighbor (vty, bgp, type, &su);
6802
6803 return CMD_SUCCESS;
6804}
6805
6806/* "show ip bgp neighbors" commands. */
6807DEFUN (show_ip_bgp_neighbors,
6808 show_ip_bgp_neighbors_cmd,
6809 "show ip bgp neighbors",
6810 SHOW_STR
6811 IP_STR
6812 BGP_STR
6813 "Detailed information on TCP and BGP neighbor connections\n")
6814{
6815 return bgp_show_neighbor_vty (vty, NULL, show_all, NULL);
6816}
6817
6818ALIAS (show_ip_bgp_neighbors,
6819 show_ip_bgp_ipv4_neighbors_cmd,
6820 "show ip bgp ipv4 (unicast|multicast) neighbors",
6821 SHOW_STR
6822 IP_STR
6823 BGP_STR
6824 "Address family\n"
6825 "Address Family modifier\n"
6826 "Address Family modifier\n"
6827 "Detailed information on TCP and BGP neighbor connections\n")
6828
6829ALIAS (show_ip_bgp_neighbors,
6830 show_ip_bgp_vpnv4_all_neighbors_cmd,
6831 "show ip bgp vpnv4 all neighbors",
6832 SHOW_STR
6833 IP_STR
6834 BGP_STR
6835 "Display VPNv4 NLRI specific information\n"
6836 "Display information about all VPNv4 NLRIs\n"
6837 "Detailed information on TCP and BGP neighbor connections\n")
6838
6839ALIAS (show_ip_bgp_neighbors,
6840 show_ip_bgp_vpnv4_rd_neighbors_cmd,
6841 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors",
6842 SHOW_STR
6843 IP_STR
6844 BGP_STR
6845 "Display VPNv4 NLRI specific information\n"
6846 "Display information for a route distinguisher\n"
6847 "VPN Route Distinguisher\n"
6848 "Detailed information on TCP and BGP neighbor connections\n")
6849
6850ALIAS (show_ip_bgp_neighbors,
6851 show_bgp_neighbors_cmd,
6852 "show bgp neighbors",
6853 SHOW_STR
6854 BGP_STR
6855 "Detailed information on TCP and BGP neighbor connections\n")
6856
6857ALIAS (show_ip_bgp_neighbors,
6858 show_bgp_ipv6_neighbors_cmd,
6859 "show bgp ipv6 neighbors",
6860 SHOW_STR
6861 BGP_STR
6862 "Address family\n"
6863 "Detailed information on TCP and BGP neighbor connections\n")
6864
6865DEFUN (show_ip_bgp_neighbors_peer,
6866 show_ip_bgp_neighbors_peer_cmd,
6867 "show ip bgp neighbors (A.B.C.D|X:X::X:X)",
6868 SHOW_STR
6869 IP_STR
6870 BGP_STR
6871 "Detailed information on TCP and BGP neighbor connections\n"
6872 "Neighbor to display information about\n"
6873 "Neighbor to display information about\n")
6874{
6875 return bgp_show_neighbor_vty (vty, NULL, show_peer, argv[argc - 1]);
6876}
6877
6878ALIAS (show_ip_bgp_neighbors_peer,
6879 show_ip_bgp_ipv4_neighbors_peer_cmd,
6880 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X)",
6881 SHOW_STR
6882 IP_STR
6883 BGP_STR
6884 "Address family\n"
6885 "Address Family modifier\n"
6886 "Address Family modifier\n"
6887 "Detailed information on TCP and BGP neighbor connections\n"
6888 "Neighbor to display information about\n"
6889 "Neighbor to display information about\n")
6890
6891ALIAS (show_ip_bgp_neighbors_peer,
6892 show_ip_bgp_vpnv4_all_neighbors_peer_cmd,
6893 "show ip bgp vpnv4 all neighbors A.B.C.D",
6894 SHOW_STR
6895 IP_STR
6896 BGP_STR
6897 "Display VPNv4 NLRI specific information\n"
6898 "Display information about all VPNv4 NLRIs\n"
6899 "Detailed information on TCP and BGP neighbor connections\n"
6900 "Neighbor to display information about\n")
6901
6902ALIAS (show_ip_bgp_neighbors_peer,
6903 show_ip_bgp_vpnv4_rd_neighbors_peer_cmd,
6904 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D",
6905 SHOW_STR
6906 IP_STR
6907 BGP_STR
6908 "Display VPNv4 NLRI specific information\n"
6909 "Display information about all VPNv4 NLRIs\n"
6910 "Detailed information on TCP and BGP neighbor connections\n"
6911 "Neighbor to display information about\n")
6912
6913ALIAS (show_ip_bgp_neighbors_peer,
6914 show_bgp_neighbors_peer_cmd,
6915 "show bgp neighbors (A.B.C.D|X:X::X:X)",
6916 SHOW_STR
6917 BGP_STR
6918 "Detailed information on TCP and BGP neighbor connections\n"
6919 "Neighbor to display information about\n"
6920 "Neighbor to display information about\n")
6921
6922ALIAS (show_ip_bgp_neighbors_peer,
6923 show_bgp_ipv6_neighbors_peer_cmd,
6924 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X)",
6925 SHOW_STR
6926 BGP_STR
6927 "Address family\n"
6928 "Detailed information on TCP and BGP neighbor connections\n"
6929 "Neighbor to display information about\n"
6930 "Neighbor to display information about\n")
6931
6932DEFUN (show_ip_bgp_instance_neighbors,
6933 show_ip_bgp_instance_neighbors_cmd,
6934 "show ip bgp view WORD neighbors",
6935 SHOW_STR
6936 IP_STR
6937 BGP_STR
6938 "BGP view\n"
6939 "View name\n"
6940 "Detailed information on TCP and BGP neighbor connections\n")
6941{
6942 return bgp_show_neighbor_vty (vty, argv[0], show_all, NULL);
6943}
6944
6945DEFUN (show_ip_bgp_instance_neighbors_peer,
6946 show_ip_bgp_instance_neighbors_peer_cmd,
6947 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X)",
6948 SHOW_STR
6949 IP_STR
6950 BGP_STR
6951 "BGP view\n"
6952 "View name\n"
6953 "Detailed information on TCP and BGP neighbor connections\n"
6954 "Neighbor to display information about\n"
6955 "Neighbor to display information about\n")
6956{
6957 return bgp_show_neighbor_vty (vty, argv[0], show_peer, argv[1]);
6958}
6959
6960/* Show BGP's AS paths internal data. There are both `show ip bgp
6961 paths' and `show ip mbgp paths'. Those functions results are the
6962 same.*/
6963DEFUN (show_ip_bgp_paths,
6964 show_ip_bgp_paths_cmd,
6965 "show ip bgp paths",
6966 SHOW_STR
6967 IP_STR
6968 BGP_STR
6969 "Path information\n")
6970{
6971 vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE);
6972 aspath_print_all_vty (vty);
6973 return CMD_SUCCESS;
6974}
6975
6976DEFUN (show_ip_bgp_ipv4_paths,
6977 show_ip_bgp_ipv4_paths_cmd,
6978 "show ip bgp ipv4 (unicast|multicast) paths",
6979 SHOW_STR
6980 IP_STR
6981 BGP_STR
6982 "Address family\n"
6983 "Address Family modifier\n"
6984 "Address Family modifier\n"
6985 "Path information\n")
6986{
6987 vty_out (vty, "Address Refcnt Path\r\n");
6988 aspath_print_all_vty (vty);
6989
6990 return CMD_SUCCESS;
6991}
6992
6993#include "hash.h"
6994
6995void
6996community_show_all_iterator (struct hash_backet *backet, struct vty *vty)
6997{
6998 struct community *com;
6999
7000 com = (struct community *) backet->data;
7001 vty_out (vty, "[%p] (%ld) %s%s", backet, com->refcnt,
7002 community_str (com), VTY_NEWLINE);
7003}
7004
7005/* Show BGP's community internal data. */
7006DEFUN (show_ip_bgp_community_info,
7007 show_ip_bgp_community_info_cmd,
7008 "show ip bgp community-info",
7009 SHOW_STR
7010 IP_STR
7011 BGP_STR
7012 "List all bgp community information\n")
7013{
7014 vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE);
7015
7016 hash_iterate (community_hash (),
7017 (void (*) (struct hash_backet *, void *))
7018 community_show_all_iterator,
7019 vty);
7020
7021 return CMD_SUCCESS;
7022}
7023
7024DEFUN (show_ip_bgp_attr_info,
7025 show_ip_bgp_attr_info_cmd,
7026 "show ip bgp attribute-info",
7027 SHOW_STR
7028 IP_STR
7029 BGP_STR
7030 "List all bgp attribute information\n")
7031{
7032 attr_show_all (vty);
7033 return CMD_SUCCESS;
7034}
7035
7036/* Redistribute VTY commands. */
7037
7038/* Utility function to convert user input route type string to route
7039 type. */
7040static int
7041bgp_str2route_type (int afi, char *str)
7042{
7043 if (! str)
7044 return 0;
7045
7046 if (afi == AFI_IP)
7047 {
7048 if (strncmp (str, "k", 1) == 0)
7049 return ZEBRA_ROUTE_KERNEL;
7050 else if (strncmp (str, "c", 1) == 0)
7051 return ZEBRA_ROUTE_CONNECT;
7052 else if (strncmp (str, "s", 1) == 0)
7053 return ZEBRA_ROUTE_STATIC;
7054 else if (strncmp (str, "r", 1) == 0)
7055 return ZEBRA_ROUTE_RIP;
7056 else if (strncmp (str, "o", 1) == 0)
7057 return ZEBRA_ROUTE_OSPF;
7058 }
7059 if (afi == AFI_IP6)
7060 {
7061 if (strncmp (str, "k", 1) == 0)
7062 return ZEBRA_ROUTE_KERNEL;
7063 else if (strncmp (str, "c", 1) == 0)
7064 return ZEBRA_ROUTE_CONNECT;
7065 else if (strncmp (str, "s", 1) == 0)
7066 return ZEBRA_ROUTE_STATIC;
7067 else if (strncmp (str, "r", 1) == 0)
7068 return ZEBRA_ROUTE_RIPNG;
7069 else if (strncmp (str, "o", 1) == 0)
7070 return ZEBRA_ROUTE_OSPF6;
7071 }
7072 return 0;
7073}
7074
7075DEFUN (bgp_redistribute_ipv4,
7076 bgp_redistribute_ipv4_cmd,
7077 "redistribute (connected|kernel|ospf|rip|static)",
7078 "Redistribute information from another routing protocol\n"
7079 "Connected\n"
7080 "Kernel routes\n"
7081 "Open Shurtest Path First (OSPF)\n"
7082 "Routing Information Protocol (RIP)\n"
7083 "Static routes\n")
7084{
7085 int type;
7086
7087 type = bgp_str2route_type (AFI_IP, argv[0]);
7088 if (! type)
7089 {
7090 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
7091 return CMD_WARNING;
7092 }
7093 return bgp_redistribute_set (vty->index, AFI_IP, type);
7094}
7095
7096DEFUN (bgp_redistribute_ipv4_rmap,
7097 bgp_redistribute_ipv4_rmap_cmd,
7098 "redistribute (connected|kernel|ospf|rip|static) route-map WORD",
7099 "Redistribute information from another routing protocol\n"
7100 "Connected\n"
7101 "Kernel routes\n"
7102 "Open Shurtest Path First (OSPF)\n"
7103 "Routing Information Protocol (RIP)\n"
7104 "Static routes\n"
7105 "Route map reference\n"
7106 "Pointer to route-map entries\n")
7107{
7108 int type;
7109
7110 type = bgp_str2route_type (AFI_IP, argv[0]);
7111 if (! type)
7112 {
7113 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
7114 return CMD_WARNING;
7115 }
7116
7117 bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[1]);
7118 return bgp_redistribute_set (vty->index, AFI_IP, type);
7119}
7120
7121DEFUN (bgp_redistribute_ipv4_metric,
7122 bgp_redistribute_ipv4_metric_cmd,
7123 "redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295>",
7124 "Redistribute information from another routing protocol\n"
7125 "Connected\n"
7126 "Kernel routes\n"
7127 "Open Shurtest Path First (OSPF)\n"
7128 "Routing Information Protocol (RIP)\n"
7129 "Static routes\n"
7130 "Metric for redistributed routes\n"
7131 "Default metric\n")
7132{
7133 int type;
7134 u_int32_t metric;
7135
7136 type = bgp_str2route_type (AFI_IP, argv[0]);
7137 if (! type)
7138 {
7139 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
7140 return CMD_WARNING;
7141 }
7142 VTY_GET_INTEGER ("metric", metric, argv[1]);
7143
7144 bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
7145 return bgp_redistribute_set (vty->index, AFI_IP, type);
7146}
7147
7148DEFUN (bgp_redistribute_ipv4_rmap_metric,
7149 bgp_redistribute_ipv4_rmap_metric_cmd,
7150 "redistribute (connected|kernel|ospf|rip|static) route-map WORD metric <0-4294967295>",
7151 "Redistribute information from another routing protocol\n"
7152 "Connected\n"
7153 "Kernel routes\n"
7154 "Open Shurtest Path First (OSPF)\n"
7155 "Routing Information Protocol (RIP)\n"
7156 "Static routes\n"
7157 "Route map reference\n"
7158 "Pointer to route-map entries\n"
7159 "Metric for redistributed routes\n"
7160 "Default metric\n")
7161{
7162 int type;
7163 u_int32_t metric;
7164
7165 type = bgp_str2route_type (AFI_IP, argv[0]);
7166 if (! type)
7167 {
7168 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
7169 return CMD_WARNING;
7170 }
7171 VTY_GET_INTEGER ("metric", metric, argv[2]);
7172
7173 bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[1]);
7174 bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
7175 return bgp_redistribute_set (vty->index, AFI_IP, type);
7176}
7177
7178DEFUN (bgp_redistribute_ipv4_metric_rmap,
7179 bgp_redistribute_ipv4_metric_rmap_cmd,
7180 "redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295> route-map WORD",
7181 "Redistribute information from another routing protocol\n"
7182 "Connected\n"
7183 "Kernel routes\n"
7184 "Open Shurtest Path First (OSPF)\n"
7185 "Routing Information Protocol (RIP)\n"
7186 "Static routes\n"
7187 "Metric for redistributed routes\n"
7188 "Default metric\n"
7189 "Route map reference\n"
7190 "Pointer to route-map entries\n")
7191{
7192 int type;
7193 u_int32_t metric;
7194
7195 type = bgp_str2route_type (AFI_IP, argv[0]);
7196 if (! type)
7197 {
7198 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
7199 return CMD_WARNING;
7200 }
7201 VTY_GET_INTEGER ("metric", metric, argv[1]);
7202
7203 bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
7204 bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[2]);
7205 return bgp_redistribute_set (vty->index, AFI_IP, type);
7206}
7207
7208DEFUN (no_bgp_redistribute_ipv4,
7209 no_bgp_redistribute_ipv4_cmd,
7210 "no redistribute (connected|kernel|ospf|rip|static)",
7211 NO_STR
7212 "Redistribute information from another routing protocol\n"
7213 "Connected\n"
7214 "Kernel routes\n"
7215 "Open Shurtest Path First (OSPF)\n"
7216 "Routing Information Protocol (RIP)\n"
7217 "Static routes\n")
7218{
7219 int type;
7220
7221 type = bgp_str2route_type (AFI_IP, argv[0]);
7222 if (! type)
7223 {
7224 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
7225 return CMD_WARNING;
7226 }
7227
7228 return bgp_redistribute_unset (vty->index, AFI_IP, type);
7229}
7230
7231DEFUN (no_bgp_redistribute_ipv4_rmap,
7232 no_bgp_redistribute_ipv4_rmap_cmd,
7233 "no redistribute (connected|kernel|ospf|rip|static) route-map WORD",
7234 NO_STR
7235 "Redistribute information from another routing protocol\n"
7236 "Connected\n"
7237 "Kernel routes\n"
7238 "Open Shurtest Path First (OSPF)\n"
7239 "Routing Information Protocol (RIP)\n"
7240 "Static routes\n"
7241 "Route map reference\n"
7242 "Pointer to route-map entries\n")
7243{
7244 int type;
7245
7246 type = bgp_str2route_type (AFI_IP, argv[0]);
7247 if (! type)
7248 {
7249 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
7250 return CMD_WARNING;
7251 }
7252
7253 bgp_redistribute_routemap_unset (vty->index, AFI_IP, type);
7254 return CMD_SUCCESS;
7255}
7256
7257DEFUN (no_bgp_redistribute_ipv4_metric,
7258 no_bgp_redistribute_ipv4_metric_cmd,
7259 "no redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295>",
7260 NO_STR
7261 "Redistribute information from another routing protocol\n"
7262 "Connected\n"
7263 "Kernel routes\n"
7264 "Open Shurtest Path First (OSPF)\n"
7265 "Routing Information Protocol (RIP)\n"
7266 "Static routes\n"
7267 "Metric for redistributed routes\n"
7268 "Default metric\n")
7269{
7270 int type;
7271
7272 type = bgp_str2route_type (AFI_IP, argv[0]);
7273 if (! type)
7274 {
7275 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
7276 return CMD_WARNING;
7277 }
7278
7279 bgp_redistribute_metric_unset (vty->index, AFI_IP, type);
7280 return CMD_SUCCESS;
7281}
7282
7283DEFUN (no_bgp_redistribute_ipv4_rmap_metric,
7284 no_bgp_redistribute_ipv4_rmap_metric_cmd,
7285 "no redistribute (connected|kernel|ospf|rip|static) route-map WORD metric <0-4294967295>",
7286 NO_STR
7287 "Redistribute information from another routing protocol\n"
7288 "Connected\n"
7289 "Kernel routes\n"
7290 "Open Shurtest Path First (OSPF)\n"
7291 "Routing Information Protocol (RIP)\n"
7292 "Static routes\n"
7293 "Route map reference\n"
7294 "Pointer to route-map entries\n"
7295 "Metric for redistributed routes\n"
7296 "Default metric\n")
7297{
7298 int type;
7299
7300 type = bgp_str2route_type (AFI_IP, argv[0]);
7301 if (! type)
7302 {
7303 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
7304 return CMD_WARNING;
7305 }
7306
7307 bgp_redistribute_metric_unset (vty->index, AFI_IP, type);
7308 bgp_redistribute_routemap_unset (vty->index, AFI_IP, type);
7309 return CMD_SUCCESS;
7310}
7311
7312ALIAS (no_bgp_redistribute_ipv4_rmap_metric,
7313 no_bgp_redistribute_ipv4_metric_rmap_cmd,
7314 "no redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295> route-map WORD",
7315 NO_STR
7316 "Redistribute information from another routing protocol\n"
7317 "Connected\n"
7318 "Kernel routes\n"
7319 "Open Shurtest Path First (OSPF)\n"
7320 "Routing Information Protocol (RIP)\n"
7321 "Static routes\n"
7322 "Metric for redistributed routes\n"
7323 "Default metric\n"
7324 "Route map reference\n"
7325 "Pointer to route-map entries\n")
7326
7327#ifdef HAVE_IPV6
7328DEFUN (bgp_redistribute_ipv6,
7329 bgp_redistribute_ipv6_cmd,
7330 "redistribute (connected|kernel|ospf6|ripng|static)",
7331 "Redistribute information from another routing protocol\n"
7332 "Connected\n"
7333 "Kernel routes\n"
7334 "Open Shurtest Path First (OSPFv3)\n"
7335 "Routing Information Protocol (RIPng)\n"
7336 "Static routes\n")
7337{
7338 int type;
7339
7340 type = bgp_str2route_type (AFI_IP6, argv[0]);
7341 if (! type)
7342 {
7343 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
7344 return CMD_WARNING;
7345 }
7346
7347 return bgp_redistribute_set (vty->index, AFI_IP6, type);
7348}
7349
7350DEFUN (bgp_redistribute_ipv6_rmap,
7351 bgp_redistribute_ipv6_rmap_cmd,
7352 "redistribute (connected|kernel|ospf6|ripng|static) route-map WORD",
7353 "Redistribute information from another routing protocol\n"
7354 "Connected\n"
7355 "Kernel routes\n"
7356 "Open Shurtest Path First (OSPFv3)\n"
7357 "Routing Information Protocol (RIPng)\n"
7358 "Static routes\n"
7359 "Route map reference\n"
7360 "Pointer to route-map entries\n")
7361{
7362 int type;
7363
7364 type = bgp_str2route_type (AFI_IP6, argv[0]);
7365 if (! type)
7366 {
7367 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
7368 return CMD_WARNING;
7369 }
7370
7371 bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[1]);
7372 return bgp_redistribute_set (vty->index, AFI_IP6, type);
7373}
7374
7375DEFUN (bgp_redistribute_ipv6_metric,
7376 bgp_redistribute_ipv6_metric_cmd,
7377 "redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295>",
7378 "Redistribute information from another routing protocol\n"
7379 "Connected\n"
7380 "Kernel routes\n"
7381 "Open Shurtest Path First (OSPFv3)\n"
7382 "Routing Information Protocol (RIPng)\n"
7383 "Static routes\n"
7384 "Metric for redistributed routes\n"
7385 "Default metric\n")
7386{
7387 int type;
7388 u_int32_t metric;
7389
7390 type = bgp_str2route_type (AFI_IP6, argv[0]);
7391 if (! type)
7392 {
7393 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
7394 return CMD_WARNING;
7395 }
7396 VTY_GET_INTEGER ("metric", metric, argv[1]);
7397
7398 bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
7399 return bgp_redistribute_set (vty->index, AFI_IP6, type);
7400}
7401
7402DEFUN (bgp_redistribute_ipv6_rmap_metric,
7403 bgp_redistribute_ipv6_rmap_metric_cmd,
7404 "redistribute (connected|kernel|ospf6|ripng|static) route-map WORD metric <0-4294967295>",
7405 "Redistribute information from another routing protocol\n"
7406 "Connected\n"
7407 "Kernel routes\n"
7408 "Open Shurtest Path First (OSPFv3)\n"
7409 "Routing Information Protocol (RIPng)\n"
7410 "Static routes\n"
7411 "Route map reference\n"
7412 "Pointer to route-map entries\n"
7413 "Metric for redistributed routes\n"
7414 "Default metric\n")
7415{
7416 int type;
7417 u_int32_t metric;
7418
7419 type = bgp_str2route_type (AFI_IP6, argv[0]);
7420 if (! type)
7421 {
7422 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
7423 return CMD_WARNING;
7424 }
7425 VTY_GET_INTEGER ("metric", metric, argv[2]);
7426
7427 bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[1]);
7428 bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
7429 return bgp_redistribute_set (vty->index, AFI_IP6, type);
7430}
7431
7432DEFUN (bgp_redistribute_ipv6_metric_rmap,
7433 bgp_redistribute_ipv6_metric_rmap_cmd,
7434 "redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295> route-map WORD",
7435 "Redistribute information from another routing protocol\n"
7436 "Connected\n"
7437 "Kernel routes\n"
7438 "Open Shurtest Path First (OSPFv3)\n"
7439 "Routing Information Protocol (RIPng)\n"
7440 "Static routes\n"
7441 "Metric for redistributed routes\n"
7442 "Default metric\n"
7443 "Route map reference\n"
7444 "Pointer to route-map entries\n")
7445{
7446 int type;
7447 u_int32_t metric;
7448
7449 type = bgp_str2route_type (AFI_IP6, argv[0]);
7450 if (! type)
7451 {
7452 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
7453 return CMD_WARNING;
7454 }
7455 VTY_GET_INTEGER ("metric", metric, argv[1]);
7456
7457 bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
7458 bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[2]);
7459 return bgp_redistribute_set (vty->index, AFI_IP6, type);
7460}
7461
7462DEFUN (no_bgp_redistribute_ipv6,
7463 no_bgp_redistribute_ipv6_cmd,
7464 "no redistribute (connected|kernel|ospf6|ripng|static)",
7465 NO_STR
7466 "Redistribute information from another routing protocol\n"
7467 "Connected\n"
7468 "Kernel routes\n"
7469 "Open Shurtest Path First (OSPFv3)\n"
7470 "Routing Information Protocol (RIPng)\n"
7471 "Static routes\n")
7472{
7473 int type;
7474
7475 type = bgp_str2route_type (AFI_IP6, argv[0]);
7476 if (! type)
7477 {
7478 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
7479 return CMD_WARNING;
7480 }
7481
7482 return bgp_redistribute_unset (vty->index, AFI_IP6, type);
7483}
7484
7485DEFUN (no_bgp_redistribute_ipv6_rmap,
7486 no_bgp_redistribute_ipv6_rmap_cmd,
7487 "no redistribute (connected|kernel|ospf6|ripng|static) route-map WORD",
7488 NO_STR
7489 "Redistribute information from another routing protocol\n"
7490 "Connected\n"
7491 "Kernel routes\n"
7492 "Open Shurtest Path First (OSPFv3)\n"
7493 "Routing Information Protocol (RIPng)\n"
7494 "Static routes\n"
7495 "Route map reference\n"
7496 "Pointer to route-map entries\n")
7497{
7498 int type;
7499
7500 type = bgp_str2route_type (AFI_IP6, argv[0]);
7501 if (! type)
7502 {
7503 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
7504 return CMD_WARNING;
7505 }
7506
7507 bgp_redistribute_routemap_unset (vty->index, AFI_IP6, type);
7508 return CMD_SUCCESS;
7509}
7510
7511DEFUN (no_bgp_redistribute_ipv6_metric,
7512 no_bgp_redistribute_ipv6_metric_cmd,
7513 "no redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295>",
7514 NO_STR
7515 "Redistribute information from another routing protocol\n"
7516 "Connected\n"
7517 "Kernel routes\n"
7518 "Open Shurtest Path First (OSPFv3)\n"
7519 "Routing Information Protocol (RIPng)\n"
7520 "Static routes\n"
7521 "Metric for redistributed routes\n"
7522 "Default metric\n")
7523{
7524 int type;
7525
7526 type = bgp_str2route_type (AFI_IP6, argv[0]);
7527 if (! type)
7528 {
7529 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
7530 return CMD_WARNING;
7531 }
7532
7533 bgp_redistribute_metric_unset (vty->index, AFI_IP6, type);
7534 return CMD_SUCCESS;
7535}
7536
7537DEFUN (no_bgp_redistribute_ipv6_rmap_metric,
7538 no_bgp_redistribute_ipv6_rmap_metric_cmd,
7539 "no redistribute (connected|kernel|ospf6|ripng|static) route-map WORD metric <0-4294967295>",
7540 NO_STR
7541 "Redistribute information from another routing protocol\n"
7542 "Connected\n"
7543 "Kernel routes\n"
7544 "Open Shurtest Path First (OSPFv3)\n"
7545 "Routing Information Protocol (RIPng)\n"
7546 "Static routes\n"
7547 "Route map reference\n"
7548 "Pointer to route-map entries\n"
7549 "Metric for redistributed routes\n"
7550 "Default metric\n")
7551{
7552 int type;
7553
7554 type = bgp_str2route_type (AFI_IP6, argv[0]);
7555 if (! type)
7556 {
7557 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
7558 return CMD_WARNING;
7559 }
7560
7561 bgp_redistribute_metric_unset (vty->index, AFI_IP6, type);
7562 bgp_redistribute_routemap_unset (vty->index, AFI_IP6, type);
7563 return CMD_SUCCESS;
7564}
7565
7566ALIAS (no_bgp_redistribute_ipv6_rmap_metric,
7567 no_bgp_redistribute_ipv6_metric_rmap_cmd,
7568 "no redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295> route-map WORD",
7569 NO_STR
7570 "Redistribute information from another routing protocol\n"
7571 "Connected\n"
7572 "Kernel routes\n"
7573 "Open Shurtest Path First (OSPFv3)\n"
7574 "Routing Information Protocol (RIPng)\n"
7575 "Static routes\n"
7576 "Metric for redistributed routes\n"
7577 "Default metric\n"
7578 "Route map reference\n"
7579 "Pointer to route-map entries\n")
7580#endif /* HAVE_IPV6 */
7581
7582int
7583bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi,
7584 safi_t safi, int *write)
7585{
7586 int i;
7587 char *str[] = { "system", "kernel", "connected", "static", "rip",
7588 "ripng", "ospf", "ospf6", "bgp"};
7589
7590 /* Unicast redistribution only. */
7591 if (safi != SAFI_UNICAST)
7592 return 0;
7593
7594 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
7595 {
7596 /* Redistribute BGP does not make sense. */
7597 if (bgp->redist[afi][i] && i != ZEBRA_ROUTE_BGP)
7598 {
7599 /* Display "address-family" when it is not yet diplayed. */
7600 bgp_config_write_family_header (vty, afi, safi, write);
7601
7602 /* "redistribute" configuration. */
7603 vty_out (vty, " redistribute %s", str[i]);
7604
7605 if (bgp->redist_metric_flag[afi][i])
7606 vty_out (vty, " metric %d", bgp->redist_metric[afi][i]);
7607
7608 if (bgp->rmap[afi][i].name)
7609 vty_out (vty, " route-map %s", bgp->rmap[afi][i].name);
7610
7611 vty_out (vty, "%s", VTY_NEWLINE);
7612 }
7613 }
7614 return *write;
7615}
7616
7617/* BGP node structure. */
7618struct cmd_node bgp_node =
7619{
7620 BGP_NODE,
7621 "%s(config-router)# ",
7622 1,
7623};
7624
7625struct cmd_node bgp_ipv4_unicast_node =
7626{
7627 BGP_IPV4_NODE,
7628 "%s(config-router-af)# ",
7629 1,
7630};
7631
7632struct cmd_node bgp_ipv4_multicast_node =
7633{
7634 BGP_IPV4M_NODE,
7635 "%s(config-router-af)# ",
7636 1,
7637};
7638
7639struct cmd_node bgp_ipv6_unicast_node =
7640{
7641 BGP_IPV6_NODE,
7642 "%s(config-router-af)# ",
7643 1,
7644};
7645
7646struct cmd_node bgp_vpnv4_node =
7647{
7648 BGP_VPNV4_NODE,
7649 "%s(config-router-af)# ",
7650 1
7651};
7652
7653void
7654bgp_vty_init ()
7655{
7656 int bgp_config_write (struct vty *);
7657 void community_list_vty ();
7658
7659 /* Install bgp top node. */
7660 install_node (&bgp_node, bgp_config_write);
7661 install_node (&bgp_ipv4_unicast_node, NULL);
7662 install_node (&bgp_ipv4_multicast_node, NULL);
7663 install_node (&bgp_ipv6_unicast_node, NULL);
7664 install_node (&bgp_vpnv4_node, NULL);
7665
7666 /* Install default VTY commands to new nodes. */
7667 install_default (BGP_NODE);
7668 install_default (BGP_IPV4_NODE);
7669 install_default (BGP_IPV4M_NODE);
7670 install_default (BGP_IPV6_NODE);
7671 install_default (BGP_VPNV4_NODE);
7672
7673 /* "bgp multiple-instance" commands. */
7674 install_element (CONFIG_NODE, &bgp_multiple_instance_cmd);
7675 install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd);
7676
7677 /* "bgp config-type" commands. */
7678 install_element (CONFIG_NODE, &bgp_config_type_cmd);
7679 install_element (CONFIG_NODE, &no_bgp_config_type_cmd);
7680
7681 /* Dummy commands (Currently not supported) */
7682 install_element (BGP_NODE, &no_synchronization_cmd);
7683 install_element (BGP_NODE, &no_auto_summary_cmd);
7684
7685 /* "router bgp" commands. */
7686 install_element (CONFIG_NODE, &router_bgp_cmd);
7687 install_element (CONFIG_NODE, &router_bgp_view_cmd);
7688
7689 /* "no router bgp" commands. */
7690 install_element (CONFIG_NODE, &no_router_bgp_cmd);
7691 install_element (CONFIG_NODE, &no_router_bgp_view_cmd);
7692
7693 /* "bgp router-id" commands. */
7694 install_element (BGP_NODE, &bgp_router_id_cmd);
7695 install_element (BGP_NODE, &no_bgp_router_id_cmd);
7696 install_element (BGP_NODE, &no_bgp_router_id_val_cmd);
7697
7698 /* "bgp cluster-id" commands. */
7699 install_element (BGP_NODE, &bgp_cluster_id_cmd);
7700 install_element (BGP_NODE, &bgp_cluster_id32_cmd);
7701 install_element (BGP_NODE, &no_bgp_cluster_id_cmd);
7702 install_element (BGP_NODE, &no_bgp_cluster_id_arg_cmd);
7703
7704 /* "bgp confederation" commands. */
7705 install_element (BGP_NODE, &bgp_confederation_identifier_cmd);
7706 install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd);
7707 install_element (BGP_NODE, &no_bgp_confederation_identifier_arg_cmd);
7708
7709 /* "bgp confederation peers" commands. */
7710 install_element (BGP_NODE, &bgp_confederation_peers_cmd);
7711 install_element (BGP_NODE, &no_bgp_confederation_peers_cmd);
7712
7713 /* "timers bgp" commands. */
7714 install_element (BGP_NODE, &bgp_timers_cmd);
7715 install_element (BGP_NODE, &no_bgp_timers_cmd);
7716 install_element (BGP_NODE, &no_bgp_timers_arg_cmd);
7717
7718 /* "bgp client-to-client reflection" commands */
7719 install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd);
7720 install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd);
7721
7722 /* "bgp always-compare-med" commands */
7723 install_element (BGP_NODE, &bgp_always_compare_med_cmd);
7724 install_element (BGP_NODE, &no_bgp_always_compare_med_cmd);
7725
7726 /* "bgp deterministic-med" commands */
7727 install_element (BGP_NODE, &bgp_deterministic_med_cmd);
7728 install_element (BGP_NODE, &no_bgp_deterministic_med_cmd);
7729
7730 /* "bgp fast-external-failover" commands */
7731 install_element (BGP_NODE, &bgp_fast_external_failover_cmd);
7732 install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd);
7733
7734 /* "bgp enforce-first-as" commands */
7735 install_element (BGP_NODE, &bgp_enforce_first_as_cmd);
7736 install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd);
7737
7738 /* "bgp bestpath compare-routerid" commands */
7739 install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd);
7740 install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd);
7741
7742 /* "bgp bestpath as-path ignore" commands */
7743 install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd);
7744 install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd);
7745
7746 /* "bgp bestpath med" commands */
7747 install_element (BGP_NODE, &bgp_bestpath_med_cmd);
7748 install_element (BGP_NODE, &bgp_bestpath_med2_cmd);
7749 install_element (BGP_NODE, &bgp_bestpath_med3_cmd);
7750 install_element (BGP_NODE, &no_bgp_bestpath_med_cmd);
7751 install_element (BGP_NODE, &no_bgp_bestpath_med2_cmd);
7752 install_element (BGP_NODE, &no_bgp_bestpath_med3_cmd);
7753
7754 /* "no bgp default ipv4-unicast" commands. */
7755 install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd);
7756 install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd);
7757
7758 /* "bgp network import-check" commands. */
7759 install_element (BGP_NODE, &bgp_network_import_check_cmd);
7760 install_element (BGP_NODE, &no_bgp_network_import_check_cmd);
7761
7762 /* "bgp default local-preference" commands. */
7763 install_element (BGP_NODE, &bgp_default_local_preference_cmd);
7764 install_element (BGP_NODE, &no_bgp_default_local_preference_cmd);
7765 install_element (BGP_NODE, &no_bgp_default_local_preference_val_cmd);
7766
7767 /* "neighbor remote-as" commands. */
7768 install_element (BGP_NODE, &neighbor_remote_as_cmd);
7769 install_element (BGP_NODE, &no_neighbor_cmd);
7770 install_element (BGP_NODE, &no_neighbor_remote_as_cmd);
7771
7772 /* "neighbor peer-group" commands. */
7773 install_element (BGP_NODE, &neighbor_peer_group_cmd);
7774 install_element (BGP_NODE, &no_neighbor_peer_group_cmd);
7775 install_element (BGP_NODE, &no_neighbor_peer_group_remote_as_cmd);
7776
7777 /* "neighbor local-as" commands. */
7778 install_element (BGP_NODE, &neighbor_local_as_cmd);
7779 install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd);
7780 install_element (BGP_NODE, &no_neighbor_local_as_cmd);
7781 install_element (BGP_NODE, &no_neighbor_local_as_val_cmd);
7782 install_element (BGP_NODE, &no_neighbor_local_as_val2_cmd);
7783
7784 /* "neighbor activate" commands. */
7785 install_element (BGP_NODE, &neighbor_activate_cmd);
7786 install_element (BGP_IPV4_NODE, &neighbor_activate_cmd);
7787 install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd);
7788 install_element (BGP_IPV6_NODE, &neighbor_activate_cmd);
7789 install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd);
7790
7791 /* "no neighbor activate" commands. */
7792 install_element (BGP_NODE, &no_neighbor_activate_cmd);
7793 install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd);
7794 install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd);
7795 install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd);
7796 install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd);
7797
7798 /* "neighbor peer-group set" commands. */
7799 install_element (BGP_NODE, &neighbor_set_peer_group_cmd);
7800 install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_cmd);
7801 install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_cmd);
7802 install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd);
7803
7804 /* "no neighbor peer-group unset" commands. */
7805 install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd);
7806 install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd);
7807 install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_cmd);
7808 install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd);
7809
7810 /* "neighbor softreconfiguration inbound" commands.*/
7811 install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd);
7812 install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd);
7813 install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd);
7814 install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
7815 install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd);
7816 install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd);
7817 install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd);
7818 install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
7819
7820 /* "neighbor attribute-unchanged" commands. */
7821 install_element (BGP_NODE, &neighbor_attr_unchanged_cmd);
7822 install_element (BGP_NODE, &neighbor_attr_unchanged1_cmd);
7823 install_element (BGP_NODE, &neighbor_attr_unchanged2_cmd);
7824 install_element (BGP_NODE, &neighbor_attr_unchanged3_cmd);
7825 install_element (BGP_NODE, &neighbor_attr_unchanged4_cmd);
7826 install_element (BGP_NODE, &neighbor_attr_unchanged5_cmd);
7827 install_element (BGP_NODE, &neighbor_attr_unchanged6_cmd);
7828 install_element (BGP_NODE, &neighbor_attr_unchanged7_cmd);
7829 install_element (BGP_NODE, &neighbor_attr_unchanged8_cmd);
7830 install_element (BGP_NODE, &neighbor_attr_unchanged9_cmd);
7831 install_element (BGP_NODE, &neighbor_attr_unchanged10_cmd);
7832 install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd);
7833 install_element (BGP_NODE, &no_neighbor_attr_unchanged1_cmd);
7834 install_element (BGP_NODE, &no_neighbor_attr_unchanged2_cmd);
7835 install_element (BGP_NODE, &no_neighbor_attr_unchanged3_cmd);
7836 install_element (BGP_NODE, &no_neighbor_attr_unchanged4_cmd);
7837 install_element (BGP_NODE, &no_neighbor_attr_unchanged5_cmd);
7838 install_element (BGP_NODE, &no_neighbor_attr_unchanged6_cmd);
7839 install_element (BGP_NODE, &no_neighbor_attr_unchanged7_cmd);
7840 install_element (BGP_NODE, &no_neighbor_attr_unchanged8_cmd);
7841 install_element (BGP_NODE, &no_neighbor_attr_unchanged9_cmd);
7842 install_element (BGP_NODE, &no_neighbor_attr_unchanged10_cmd);
7843 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd);
7844 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged1_cmd);
7845 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged2_cmd);
7846 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged3_cmd);
7847 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged4_cmd);
7848 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged5_cmd);
7849 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged6_cmd);
7850 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged7_cmd);
7851 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged8_cmd);
7852 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged9_cmd);
7853 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged10_cmd);
7854 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd);
7855 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged1_cmd);
7856 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged2_cmd);
7857 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged3_cmd);
7858 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged4_cmd);
7859 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged5_cmd);
7860 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged6_cmd);
7861 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged7_cmd);
7862 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged8_cmd);
7863 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged9_cmd);
7864 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged10_cmd);
7865 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd);
7866 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged1_cmd);
7867 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged2_cmd);
7868 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged3_cmd);
7869 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged4_cmd);
7870 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged5_cmd);
7871 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged6_cmd);
7872 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged7_cmd);
7873 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged8_cmd);
7874 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged9_cmd);
7875 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged10_cmd);
7876 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd);
7877 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged1_cmd);
7878 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged2_cmd);
7879 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged3_cmd);
7880 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged4_cmd);
7881 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged5_cmd);
7882 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged6_cmd);
7883 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged7_cmd);
7884 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged8_cmd);
7885 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged9_cmd);
7886 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged10_cmd);
7887 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd);
7888 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged1_cmd);
7889 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged2_cmd);
7890 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged3_cmd);
7891 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged4_cmd);
7892 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged5_cmd);
7893 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged6_cmd);
7894 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged7_cmd);
7895 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged8_cmd);
7896 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged9_cmd);
7897 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged10_cmd);
7898 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd);
7899 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged1_cmd);
7900 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged2_cmd);
7901 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged3_cmd);
7902 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged4_cmd);
7903 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged5_cmd);
7904 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged6_cmd);
7905 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged7_cmd);
7906 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged8_cmd);
7907 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged9_cmd);
7908 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged10_cmd);
7909 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd);
7910 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged1_cmd);
7911 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged2_cmd);
7912 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged3_cmd);
7913 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged4_cmd);
7914 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged5_cmd);
7915 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged6_cmd);
7916 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged7_cmd);
7917 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged8_cmd);
7918 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged9_cmd);
7919 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged10_cmd);
7920 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd);
7921 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged1_cmd);
7922 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged2_cmd);
7923 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged3_cmd);
7924 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged4_cmd);
7925 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged5_cmd);
7926 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged6_cmd);
7927 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged7_cmd);
7928 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged8_cmd);
7929 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged9_cmd);
7930 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged10_cmd);
7931
7932 /* "transparent-as" and "transparent-nexthop" for old version
7933 compatibility. */
7934 install_element (BGP_NODE, &neighbor_transparent_as_cmd);
7935 install_element (BGP_NODE, &neighbor_transparent_nexthop_cmd);
7936
7937 /* "neighbor next-hop-self" commands. */
7938 install_element (BGP_NODE, &neighbor_nexthop_self_cmd);
7939 install_element (BGP_NODE, &no_neighbor_nexthop_self_cmd);
7940 install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd);
7941 install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd);
7942 install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd);
7943 install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd);
7944 install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd);
7945 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd);
7946 install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd);
7947 install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd);
7948
7949 /* "neighbor remove-private-AS" commands. */
7950 install_element (BGP_NODE, &neighbor_remove_private_as_cmd);
7951 install_element (BGP_NODE, &no_neighbor_remove_private_as_cmd);
7952 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd);
7953 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd);
7954 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd);
7955 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd);
7956 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd);
7957 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd);
7958 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd);
7959 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd);
7960
7961 /* "neighbor send-community" commands.*/
7962 install_element (BGP_NODE, &neighbor_send_community_cmd);
7963 install_element (BGP_NODE, &neighbor_send_community_type_cmd);
7964 install_element (BGP_NODE, &no_neighbor_send_community_cmd);
7965 install_element (BGP_NODE, &no_neighbor_send_community_type_cmd);
7966 install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd);
7967 install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd);
7968 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd);
7969 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd);
7970 install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd);
7971 install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd);
7972 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd);
7973 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd);
7974 install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd);
7975 install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd);
7976 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd);
7977 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd);
7978 install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd);
7979 install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd);
7980 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd);
7981 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd);
7982
7983 /* "neighbor route-reflector" commands.*/
7984 install_element (BGP_NODE, &neighbor_route_reflector_client_cmd);
7985 install_element (BGP_NODE, &no_neighbor_route_reflector_client_cmd);
7986 install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd);
7987 install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd);
7988 install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd);
7989 install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd);
7990 install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd);
7991 install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd);
7992 install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd);
7993 install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd);
7994
7995 /* "neighbor route-server" commands.*/
7996 install_element (BGP_NODE, &neighbor_route_server_client_cmd);
7997 install_element (BGP_NODE, &no_neighbor_route_server_client_cmd);
7998 install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd);
7999 install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd);
8000 install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd);
8001 install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd);
8002 install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd);
8003 install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd);
8004 install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd);
8005 install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd);
8006
8007 /* "neighbor passive" commands. */
8008 install_element (BGP_NODE, &neighbor_passive_cmd);
8009 install_element (BGP_NODE, &no_neighbor_passive_cmd);
8010
8011 /* "neighbor shutdown" commands. */
8012 install_element (BGP_NODE, &neighbor_shutdown_cmd);
8013 install_element (BGP_NODE, &no_neighbor_shutdown_cmd);
8014
8015 /* "neighbor capability route-refresh" commands.*/
8016 install_element (BGP_NODE, &neighbor_capability_route_refresh_cmd);
8017 install_element (BGP_NODE, &no_neighbor_capability_route_refresh_cmd);
8018
8019 /* "neighbor capability orf prefix-list" commands.*/
8020 install_element (BGP_NODE, &neighbor_capability_orf_prefix_cmd);
8021 install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_cmd);
8022 install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd);
8023 install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd);
8024 install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd);
8025 install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd);
8026 install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd);
8027 install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd);
8028
8029 /* "neighbor capability dynamic" commands.*/
8030 install_element (BGP_NODE, &neighbor_capability_dynamic_cmd);
8031 install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd);
8032
8033 /* "neighbor dont-capability-negotiate" commands. */
8034 install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd);
8035 install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd);
8036
8037 /* "neighbor ebgp-multihop" commands. */
8038 install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd);
8039 install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd);
8040 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd);
8041 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_ttl_cmd);
8042
8043 /* "neighbor enforce-multihop" commands. */
8044 install_element (BGP_NODE, &neighbor_enforce_multihop_cmd);
8045 install_element (BGP_NODE, &no_neighbor_enforce_multihop_cmd);
8046
8047 /* "neighbor description" commands. */
8048 install_element (BGP_NODE, &neighbor_description_cmd);
8049 install_element (BGP_NODE, &no_neighbor_description_cmd);
8050 install_element (BGP_NODE, &no_neighbor_description_val_cmd);
8051
8052 /* "neighbor update-source" commands. "*/
8053 install_element (BGP_NODE, &neighbor_update_source_cmd);
8054 install_element (BGP_NODE, &no_neighbor_update_source_cmd);
8055
8056 /* "neighbor default-originate" commands. */
8057 install_element (BGP_NODE, &neighbor_default_originate_cmd);
8058 install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd);
8059 install_element (BGP_NODE, &no_neighbor_default_originate_cmd);
8060 install_element (BGP_NODE, &no_neighbor_default_originate_rmap_cmd);
8061 install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd);
8062 install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd);
8063 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd);
8064 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_rmap_cmd);
8065 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd);
8066 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd);
8067 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd);
8068 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_rmap_cmd);
8069 install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd);
8070 install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd);
8071 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd);
8072 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_rmap_cmd);
8073
8074 /* "neighbor port" commands. */
8075 install_element (BGP_NODE, &neighbor_port_cmd);
8076 install_element (BGP_NODE, &no_neighbor_port_cmd);
8077 install_element (BGP_NODE, &no_neighbor_port_val_cmd);
8078
8079 /* "neighbor weight" commands. */
8080 install_element (BGP_NODE, &neighbor_weight_cmd);
8081 install_element (BGP_NODE, &no_neighbor_weight_cmd);
8082 install_element (BGP_NODE, &no_neighbor_weight_val_cmd);
8083
8084 /* "neighbor override-capability" commands. */
8085 install_element (BGP_NODE, &neighbor_override_capability_cmd);
8086 install_element (BGP_NODE, &no_neighbor_override_capability_cmd);
8087
8088 /* "neighbor strict-capability-match" commands. */
8089 install_element (BGP_NODE, &neighbor_strict_capability_cmd);
8090 install_element (BGP_NODE, &no_neighbor_strict_capability_cmd);
8091
8092 /* "neighbor timers" commands. */
8093 install_element (BGP_NODE, &neighbor_timers_cmd);
8094 install_element (BGP_NODE, &no_neighbor_timers_cmd);
8095
8096 /* "neighbor timers connect" commands. */
8097 install_element (BGP_NODE, &neighbor_timers_connect_cmd);
8098 install_element (BGP_NODE, &no_neighbor_timers_connect_cmd);
8099 install_element (BGP_NODE, &no_neighbor_timers_connect_val_cmd);
8100
8101 /* "neighbor advertisement-interval" commands. */
8102 install_element (BGP_NODE, &neighbor_advertise_interval_cmd);
8103 install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd);
8104 install_element (BGP_NODE, &no_neighbor_advertise_interval_val_cmd);
8105
8106 /* "neighbor version" commands. */
8107 install_element (BGP_NODE, &neighbor_version_cmd);
8108 install_element (BGP_NODE, &no_neighbor_version_cmd);
8109
8110 /* "neighbor interface" commands. */
8111 install_element (BGP_NODE, &neighbor_interface_cmd);
8112 install_element (BGP_NODE, &no_neighbor_interface_cmd);
8113
8114 /* "neighbor distribute" commands. */
8115 install_element (BGP_NODE, &neighbor_distribute_list_cmd);
8116 install_element (BGP_NODE, &no_neighbor_distribute_list_cmd);
8117 install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd);
8118 install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd);
8119 install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd);
8120 install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd);
8121 install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd);
8122 install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd);
8123 install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd);
8124 install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd);
8125
8126 /* "neighbor prefix-list" commands. */
8127 install_element (BGP_NODE, &neighbor_prefix_list_cmd);
8128 install_element (BGP_NODE, &no_neighbor_prefix_list_cmd);
8129 install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd);
8130 install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd);
8131 install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd);
8132 install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd);
8133 install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd);
8134 install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd);
8135 install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd);
8136 install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd);
8137
8138 /* "neighbor filter-list" commands. */
8139 install_element (BGP_NODE, &neighbor_filter_list_cmd);
8140 install_element (BGP_NODE, &no_neighbor_filter_list_cmd);
8141 install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd);
8142 install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd);
8143 install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd);
8144 install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd);
8145 install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd);
8146 install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd);
8147 install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd);
8148 install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd);
8149
8150 /* "neighbor route-map" commands. */
8151 install_element (BGP_NODE, &neighbor_route_map_cmd);
8152 install_element (BGP_NODE, &no_neighbor_route_map_cmd);
8153 install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd);
8154 install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd);
8155 install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd);
8156 install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd);
8157 install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd);
8158 install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd);
8159 install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd);
8160 install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd);
8161
8162 /* "neighbor unsuppress-map" commands. */
8163 install_element (BGP_NODE, &neighbor_unsuppress_map_cmd);
8164 install_element (BGP_NODE, &no_neighbor_unsuppress_map_cmd);
8165 install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd);
8166 install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd);
8167 install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd);
8168 install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd);
8169 install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd);
8170 install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd);
8171
8172 /* "neighbor maximum-prefix" commands. */
8173 install_element (BGP_NODE, &neighbor_maximum_prefix_cmd);
8174 install_element (BGP_NODE, &neighbor_maximum_prefix_warning_cmd);
8175 install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd);
8176 install_element (BGP_NODE, &no_neighbor_maximum_prefix_val_cmd);
8177 install_element (BGP_NODE, &no_neighbor_maximum_prefix_val2_cmd);
8178 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd);
8179 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd);
8180 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd);
8181 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
8182 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_val2_cmd);
8183 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd);
8184 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd);
8185 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd);
8186 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_val_cmd);
8187 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_val2_cmd);
8188 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd);
8189 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd);
8190 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd);
8191 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_val_cmd);
8192 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_val2_cmd);
8193 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd);
8194 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd);
8195 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd);
8196 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
8197 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_val2_cmd);
8198
8199 /* "neighbor allowas-in" */
8200 install_element (BGP_NODE, &neighbor_allowas_in_cmd);
8201 install_element (BGP_NODE, &neighbor_allowas_in_arg_cmd);
8202 install_element (BGP_NODE, &no_neighbor_allowas_in_cmd);
8203 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd);
8204 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_arg_cmd);
8205 install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd);
8206 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd);
8207 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_arg_cmd);
8208 install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd);
8209 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd);
8210 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_arg_cmd);
8211 install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd);
8212 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd);
8213 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_arg_cmd);
8214 install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd);
8215
8216 /* address-family commands. */
8217 install_element (BGP_NODE, &address_family_ipv4_cmd);
8218 install_element (BGP_NODE, &address_family_ipv4_safi_cmd);
8219#ifdef HAVE_IPV6
8220 install_element (BGP_NODE, &address_family_ipv6_cmd);
8221 install_element (BGP_NODE, &address_family_ipv6_unicast_cmd);
8222#endif /* HAVE_IPV6 */
8223 install_element (BGP_NODE, &address_family_vpnv4_cmd);
8224 install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd);
8225
8226 /* "exit-address-family" command. */
8227 install_element (BGP_IPV4_NODE, &exit_address_family_cmd);
8228 install_element (BGP_IPV4M_NODE, &exit_address_family_cmd);
8229 install_element (BGP_IPV6_NODE, &exit_address_family_cmd);
8230 install_element (BGP_VPNV4_NODE, &exit_address_family_cmd);
8231
8232 /* "clear ip bgp commands" */
8233 install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd);
8234 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_cmd);
8235 install_element (ENABLE_NODE, &clear_ip_bgp_as_cmd);
8236 install_element (ENABLE_NODE, &clear_ip_bgp_peer_cmd);
8237 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_cmd);
8238 install_element (ENABLE_NODE, &clear_ip_bgp_external_cmd);
8239#ifdef HAVE_IPV6
8240 install_element (ENABLE_NODE, &clear_bgp_all_cmd);
8241 install_element (ENABLE_NODE, &clear_bgp_instance_all_cmd);
8242 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_cmd);
8243 install_element (ENABLE_NODE, &clear_bgp_peer_cmd);
8244 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_cmd);
8245 install_element (ENABLE_NODE, &clear_bgp_peer_group_cmd);
8246 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_cmd);
8247 install_element (ENABLE_NODE, &clear_bgp_external_cmd);
8248 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_cmd);
8249 install_element (ENABLE_NODE, &clear_bgp_as_cmd);
8250 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_cmd);
8251#endif /* HAVE_IPV6 */
8252
8253 /* "clear ip bgp neighbor soft in" */
8254 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_in_cmd);
8255 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_in_cmd);
8256 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_cmd);
8257 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_prefix_filter_cmd);
8258 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_in_prefix_filter_cmd);
8259 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_in_cmd);
8260 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_cmd);
8261 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_prefix_filter_cmd);
8262 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_in_cmd);
8263 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_cmd);
8264 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_prefix_filter_cmd);
8265 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_in_cmd);
8266 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_cmd);
8267 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_prefix_filter_cmd);
8268 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_in_cmd);
8269 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_cmd);
8270 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_prefix_filter_cmd);
8271 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_in_cmd);
8272 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_in_cmd);
8273 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_cmd);
8274 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_prefix_filter_cmd);
8275 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_in_prefix_filter_cmd);
8276 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_in_cmd);
8277 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_cmd);
8278 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd);
8279 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_in_cmd);
8280 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_cmd);
8281 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd);
8282 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_in_cmd);
8283 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_cmd);
8284 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_prefix_filter_cmd);
8285 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_in_cmd);
8286 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_cmd);
8287 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_prefix_filter_cmd);
8288 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_in_cmd);
8289 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_in_cmd);
8290 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_in_cmd);
8291 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_in_cmd);
8292 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_in_cmd);
8293 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_in_cmd);
8294#ifdef HAVE_IPV6
8295 install_element (ENABLE_NODE, &clear_bgp_all_soft_in_cmd);
8296 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_in_cmd);
8297 install_element (ENABLE_NODE, &clear_bgp_all_in_cmd);
8298 install_element (ENABLE_NODE, &clear_bgp_all_in_prefix_filter_cmd);
8299 install_element (ENABLE_NODE, &clear_bgp_peer_soft_in_cmd);
8300 install_element (ENABLE_NODE, &clear_bgp_peer_in_cmd);
8301 install_element (ENABLE_NODE, &clear_bgp_peer_in_prefix_filter_cmd);
8302 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_in_cmd);
8303 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_cmd);
8304 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_prefix_filter_cmd);
8305 install_element (ENABLE_NODE, &clear_bgp_external_soft_in_cmd);
8306 install_element (ENABLE_NODE, &clear_bgp_external_in_cmd);
8307 install_element (ENABLE_NODE, &clear_bgp_external_in_prefix_filter_cmd);
8308 install_element (ENABLE_NODE, &clear_bgp_as_soft_in_cmd);
8309 install_element (ENABLE_NODE, &clear_bgp_as_in_cmd);
8310 install_element (ENABLE_NODE, &clear_bgp_as_in_prefix_filter_cmd);
8311 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_in_cmd);
8312 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_cmd);
8313 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_prefix_filter_cmd);
8314 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_in_cmd);
8315 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_cmd);
8316 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_prefix_filter_cmd);
8317 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_in_cmd);
8318 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_cmd);
8319 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_prefix_filter_cmd);
8320 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_in_cmd);
8321 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_cmd);
8322 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_prefix_filter_cmd);
8323 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_in_cmd);
8324 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_cmd);
8325 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_prefix_filter_cmd);
8326#endif /* HAVE_IPV6 */
8327
8328 /* "clear ip bgp neighbor soft out" */
8329 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_out_cmd);
8330 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_out_cmd);
8331 install_element (ENABLE_NODE, &clear_ip_bgp_all_out_cmd);
8332 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_out_cmd);
8333 install_element (ENABLE_NODE, &clear_ip_bgp_peer_out_cmd);
8334 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_out_cmd);
8335 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_out_cmd);
8336 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_out_cmd);
8337 install_element (ENABLE_NODE, &clear_ip_bgp_external_out_cmd);
8338 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_out_cmd);
8339 install_element (ENABLE_NODE, &clear_ip_bgp_as_out_cmd);
8340 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_out_cmd);
8341 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_out_cmd);
8342 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_out_cmd);
8343 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_out_cmd);
8344 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_out_cmd);
8345 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_out_cmd);
8346 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_out_cmd);
8347 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_out_cmd);
8348 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_out_cmd);
8349 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_out_cmd);
8350 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_out_cmd);
8351 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_out_cmd);
8352 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_out_cmd);
8353 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_out_cmd);
8354 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_out_cmd);
8355 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_out_cmd);
8356 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_out_cmd);
8357#ifdef HAVE_IPV6
8358 install_element (ENABLE_NODE, &clear_bgp_all_soft_out_cmd);
8359 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_out_cmd);
8360 install_element (ENABLE_NODE, &clear_bgp_all_out_cmd);
8361 install_element (ENABLE_NODE, &clear_bgp_peer_soft_out_cmd);
8362 install_element (ENABLE_NODE, &clear_bgp_peer_out_cmd);
8363 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_out_cmd);
8364 install_element (ENABLE_NODE, &clear_bgp_peer_group_out_cmd);
8365 install_element (ENABLE_NODE, &clear_bgp_external_soft_out_cmd);
8366 install_element (ENABLE_NODE, &clear_bgp_external_out_cmd);
8367 install_element (ENABLE_NODE, &clear_bgp_as_soft_out_cmd);
8368 install_element (ENABLE_NODE, &clear_bgp_as_out_cmd);
8369 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_out_cmd);
8370 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_out_cmd);
8371 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_out_cmd);
8372 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_out_cmd);
8373 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_out_cmd);
8374 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_out_cmd);
8375 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_out_cmd);
8376 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_out_cmd);
8377 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_out_cmd);
8378 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_out_cmd);
8379#endif /* HAVE_IPV6 */
8380
8381 /* "clear ip bgp neighbor soft" */
8382 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_cmd);
8383 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_cmd);
8384 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_cmd);
8385 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_cmd);
8386 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_cmd);
8387 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_cmd);
8388 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_cmd);
8389 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_cmd);
8390 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_cmd);
8391 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_cmd);
8392 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_cmd);
8393 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_cmd);
8394 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_cmd);
8395 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_cmd);
8396 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_cmd);
8397#ifdef HAVE_IPV6
8398 install_element (ENABLE_NODE, &clear_bgp_all_soft_cmd);
8399 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_cmd);
8400 install_element (ENABLE_NODE, &clear_bgp_peer_soft_cmd);
8401 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_cmd);
8402 install_element (ENABLE_NODE, &clear_bgp_external_soft_cmd);
8403 install_element (ENABLE_NODE, &clear_bgp_as_soft_cmd);
8404 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_cmd);
8405 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_cmd);
8406 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_cmd);
8407 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_cmd);
8408 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_cmd);
8409#endif /* HAVE_IPV6 */
8410
8411 /* "show ip bgp summary" commands. */
8412 install_element (VIEW_NODE, &show_ip_bgp_summary_cmd);
8413 install_element (VIEW_NODE, &show_ip_bgp_instance_summary_cmd);
8414 install_element (VIEW_NODE, &show_ip_bgp_ipv4_summary_cmd);
8415 install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
8416 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
8417 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
8418#ifdef HAVE_IPV6
8419 install_element (VIEW_NODE, &show_bgp_summary_cmd);
8420 install_element (VIEW_NODE, &show_bgp_instance_summary_cmd);
8421 install_element (VIEW_NODE, &show_bgp_ipv6_summary_cmd);
8422 install_element (VIEW_NODE, &show_bgp_instance_ipv6_summary_cmd);
8423#endif /* HAVE_IPV6 */
8424 install_element (ENABLE_NODE, &show_ip_bgp_summary_cmd);
8425 install_element (ENABLE_NODE, &show_ip_bgp_instance_summary_cmd);
8426 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_summary_cmd);
8427 install_element (ENABLE_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
8428 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
8429 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
8430#ifdef HAVE_IPV6
8431 install_element (ENABLE_NODE, &show_bgp_summary_cmd);
8432 install_element (ENABLE_NODE, &show_bgp_instance_summary_cmd);
8433 install_element (ENABLE_NODE, &show_bgp_ipv6_summary_cmd);
8434 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_summary_cmd);
8435#endif /* HAVE_IPV6 */
8436
8437 /* "show ip bgp neighbors" commands. */
8438 install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd);
8439 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
8440 install_element (VIEW_NODE, &show_ip_bgp_neighbors_peer_cmd);
8441 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
8442 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd);
8443 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd);
8444 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
8445 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
8446 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_cmd);
8447 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
8448 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_cmd);
8449 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
8450 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_peer_cmd);
8451 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
8452 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd);
8453 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd);
8454 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
8455 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
8456 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_cmd);
8457 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
8458
8459#ifdef HAVE_IPV6
8460 install_element (VIEW_NODE, &show_bgp_neighbors_cmd);
8461 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_cmd);
8462 install_element (VIEW_NODE, &show_bgp_neighbors_peer_cmd);
8463 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
8464 install_element (ENABLE_NODE, &show_bgp_neighbors_cmd);
8465 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_cmd);
8466 install_element (ENABLE_NODE, &show_bgp_neighbors_peer_cmd);
8467 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
8468
8469 /* Old commands. */
8470 install_element (VIEW_NODE, &show_ipv6_bgp_summary_cmd);
8471 install_element (VIEW_NODE, &show_ipv6_mbgp_summary_cmd);
8472 install_element (ENABLE_NODE, &show_ipv6_bgp_summary_cmd);
8473 install_element (ENABLE_NODE, &show_ipv6_mbgp_summary_cmd);
8474#endif /* HAVE_IPV6 */
8475
8476 /* "show ip bgp paths" commands. */
8477 install_element (VIEW_NODE, &show_ip_bgp_paths_cmd);
8478 install_element (VIEW_NODE, &show_ip_bgp_ipv4_paths_cmd);
8479 install_element (ENABLE_NODE, &show_ip_bgp_paths_cmd);
8480 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_paths_cmd);
8481
8482 /* "show ip bgp community" commands. */
8483 install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd);
8484 install_element (ENABLE_NODE, &show_ip_bgp_community_info_cmd);
8485
8486 /* "show ip bgp attribute-info" commands. */
8487 install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd);
8488 install_element (ENABLE_NODE, &show_ip_bgp_attr_info_cmd);
8489
8490 /* "redistribute" commands. */
8491 install_element (BGP_NODE, &bgp_redistribute_ipv4_cmd);
8492 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_cmd);
8493 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_cmd);
8494 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_cmd);
8495 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_cmd);
8496 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_cmd);
8497 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd);
8498 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd);
8499 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_metric_cmd);
8500 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_rmap_cmd);
8501#ifdef HAVE_IPV6
8502 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd);
8503 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd);
8504 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd);
8505 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_cmd);
8506 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd);
8507 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_cmd);
8508 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd);
8509 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd);
8510 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_metric_cmd);
8511 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_rmap_cmd);
8512#endif /* HAVE_IPV6 */
8513
8514 /* Community-list. */
8515 community_list_vty ();
8516}
8517
8518#include "memory.h"
8519#include "bgp_regex.h"
8520#include "bgp_clist.h"
8521#include "bgp_ecommunity.h"
8522
8523/* VTY functions. */
8524
8525/* Direction value to string conversion. */
8526char *
8527community_direct_str (int direct)
8528{
8529 switch (direct)
8530 {
8531 case COMMUNITY_DENY:
8532 return "deny";
8533 break;
8534 case COMMUNITY_PERMIT:
8535 return "permit";
8536 break;
8537 default:
8538 return "unknown";
8539 break;
8540 }
8541}
8542
8543/* Display error string. */
8544void
8545community_list_perror (struct vty *vty, int ret)
8546{
8547 switch (ret)
8548 {
8549 case COMMUNITY_LIST_ERR_CANT_FIND_LIST:
8550 vty_out (vty, "%% Can't find communit-list%s", VTY_NEWLINE);
8551 break;
8552 case COMMUNITY_LIST_ERR_MALFORMED_VAL:
8553 vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE);
8554 break;
8555 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT:
8556 vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE);
8557 break;
8558 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT:
8559 vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE);
8560 break;
8561 }
8562}
8563
8564/* VTY interface for community_set() function. */
8565int
8566community_list_set_vty (struct vty *vty, int argc, char **argv, int style,
8567 int reject_all_digit_name)
8568{
8569 int ret;
8570 int direct;
8571 char *str;
8572
8573 /* Check the list type. */
8574 if (strncmp (argv[1], "p", 1) == 0)
8575 direct = COMMUNITY_PERMIT;
8576 else if (strncmp (argv[1], "d", 1) == 0)
8577 direct = COMMUNITY_DENY;
8578 else
8579 {
8580 vty_out (vty, "%% Matching condition must be permit or deny%s",
8581 VTY_NEWLINE);
8582 return CMD_WARNING;
8583 }
8584
8585 /* All digit name check. */
8586 if (reject_all_digit_name && all_digit (argv[0]))
8587 {
8588 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
8589 return CMD_WARNING;
8590 }
8591
8592 /* Concat community string argument. */
8593 if (argc > 1)
8594 str = argv_concat (argv, argc, 2);
8595 else
8596 str = NULL;
8597
8598 /* When community_list_set() return nevetive value, it means
8599 malformed community string. */
8600 ret = community_list_set (bgp_clist, argv[0], str, direct, style);
8601
8602 /* Free temporary community list string allocated by
8603 argv_concat(). */
8604 if (str)
8605 XFREE (MTYPE_TMP, str);
8606
8607 if (ret < 0)
8608 {
8609 /* Display error string. */
8610 community_list_perror (vty, ret);
8611 return CMD_WARNING;
8612 }
8613
8614 return CMD_SUCCESS;
8615}
8616
8617/* Community-list delete with name. */
8618int
8619community_list_unset_all_vty (struct vty *vty, char *name)
8620{
8621 int ret;
8622
8623 ret = community_list_unset (bgp_clist, name, NULL, 0, COMMUNITY_LIST_AUTO);
8624
8625 if (ret < 0)
8626 {
8627 community_list_perror (vty, ret);
8628 return CMD_WARNING;
8629 }
8630 return CMD_SUCCESS;
8631}
8632
8633/* Communiyt-list entry delete. */
8634int
8635community_list_unset_vty (struct vty *vty, int argc, char **argv, int style)
8636{
8637 int ret;
8638 int direct;
8639 char *str;
8640
8641 /* Check the list direct. */
8642 if (strncmp (argv[1], "p", 1) == 0)
8643 direct = COMMUNITY_PERMIT;
8644 else if (strncmp (argv[1], "d", 1) == 0)
8645 direct = COMMUNITY_DENY;
8646 else
8647 {
8648 vty_out (vty, "%% Matching condition must be permit or deny%s",
8649 VTY_NEWLINE);
8650 return CMD_WARNING;
8651 }
8652
8653 /* Concat community string argument. */
8654 str = argv_concat (argv, argc, 2);
8655
8656 /* Unset community list. */
8657 ret = community_list_unset (bgp_clist, argv[0], str, direct, style);
8658
8659 /* Free temporary community list string allocated by
8660 argv_concat(). */
8661 XFREE (MTYPE_TMP, str);
8662
8663 if (ret < 0)
8664 {
8665 community_list_perror (vty, ret);
8666 return CMD_WARNING;
8667 }
8668
8669 return CMD_SUCCESS;
8670}
8671
8672/* "community-list" keyword help string. */
8673#define COMMUNITY_LIST_STR "Add a community list entry\n"
8674#define COMMUNITY_VAL_STR "Community number in aa:nn format or internet|local-AS|no-advertise|no-export\n"
8675
8676DEFUN (ip_community_list,
8677 ip_community_list_cmd,
8678 "ip community-list WORD (deny|permit) .AA:NN",
8679 IP_STR
8680 COMMUNITY_LIST_STR
8681 "Community list name\n"
8682 "Specify community to reject\n"
8683 "Specify community to accept\n"
8684 COMMUNITY_VAL_STR)
8685{
8686 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_AUTO, 1);
8687}
8688
8689DEFUN (ip_community_list_standard,
8690 ip_community_list_standard_cmd,
8691 "ip community-list <1-99> (deny|permit) .AA:NN",
8692 IP_STR
8693 COMMUNITY_LIST_STR
8694 "Community list number (standard)\n"
8695 "Specify community to reject\n"
8696 "Specify community to accept\n"
8697 COMMUNITY_VAL_STR)
8698{
8699 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
8700}
8701
8702ALIAS (ip_community_list_standard,
8703 ip_community_list_standard2_cmd,
8704 "ip community-list <1-99> (deny|permit)",
8705 IP_STR
8706 COMMUNITY_LIST_STR
8707 "Community list number (standard)\n"
8708 "Specify community to reject\n"
8709 "Specify community to accept\n")
8710
8711DEFUN (ip_community_list_expanded,
8712 ip_community_list_expanded_cmd,
8713 "ip community-list <100-199> (deny|permit) .LINE",
8714 IP_STR
8715 COMMUNITY_LIST_STR
8716 "Community list number (expanded)\n"
8717 "Specify community to reject\n"
8718 "Specify community to accept\n"
8719 "An ordered list as a regular-expression\n")
8720{
8721 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
8722}
8723
8724DEFUN (ip_community_list_name_standard,
8725 ip_community_list_name_standard_cmd,
8726 "ip community-list standard WORD (deny|permit) .AA:NN",
8727 IP_STR
8728 COMMUNITY_LIST_STR
8729 "Add a standard community-list entry\n"
8730 "Community list name\n"
8731 "Specify community to reject\n"
8732 "Specify community to accept\n"
8733 COMMUNITY_VAL_STR)
8734{
8735 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
8736}
8737
8738ALIAS (ip_community_list_name_standard,
8739 ip_community_list_name_standard2_cmd,
8740 "ip community-list standard WORD (deny|permit)",
8741 IP_STR
8742 COMMUNITY_LIST_STR
8743 "Add a standard community-list entry\n"
8744 "Community list name\n"
8745 "Specify community to reject\n"
8746 "Specify community to accept\n")
8747
8748DEFUN (ip_community_list_name_expanded,
8749 ip_community_list_name_expanded_cmd,
8750 "ip community-list expanded WORD (deny|permit) .LINE",
8751 IP_STR
8752 COMMUNITY_LIST_STR
8753 "Add an expanded community-list entry\n"
8754 "Community list name\n"
8755 "Specify community to reject\n"
8756 "Specify community to accept\n"
8757 "An ordered list as a regular-expression\n")
8758{
8759 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
8760}
8761
8762DEFUN (no_ip_community_list_all,
8763 no_ip_community_list_all_cmd,
8764 "no ip community-list (WORD|<1-99>|<100-199>)",
8765 NO_STR
8766 IP_STR
8767 COMMUNITY_LIST_STR
8768 "Community list name\n"
8769 "Community list number (standard)\n"
8770 "Community list number (expanded)\n")
8771{
8772 return community_list_unset_all_vty (vty, argv[0]);
8773}
8774
8775DEFUN (no_ip_community_list_name_all,
8776 no_ip_community_list_name_all_cmd,
8777 "no ip community-list (standard|expanded) WORD",
8778 NO_STR
8779 IP_STR
8780 COMMUNITY_LIST_STR
8781 "Add a standard community-list entry\n"
8782 "Add an expanded community-list entry\n"
8783 "Community list name\n")
8784{
8785 return community_list_unset_all_vty (vty, argv[1]);
8786}
8787
8788DEFUN (no_ip_community_list,
8789 no_ip_community_list_cmd,
8790 "no ip community-list WORD (deny|permit) .AA:NN",
8791 NO_STR
8792 IP_STR
8793 COMMUNITY_LIST_STR
8794 "Community list name\n"
8795 "Specify community to reject\n"
8796 "Specify community to accept\n"
8797 COMMUNITY_VAL_STR)
8798{
8799 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_AUTO);
8800}
8801
8802DEFUN (no_ip_community_list_standard,
8803 no_ip_community_list_standard_cmd,
8804 "no ip community-list <1-99> (deny|permit) .AA:NN",
8805 NO_STR
8806 IP_STR
8807 COMMUNITY_LIST_STR
8808 "Community list number (standard)\n"
8809 "Specify community to reject\n"
8810 "Specify community to accept\n"
8811 COMMUNITY_VAL_STR)
8812{
8813 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
8814}
8815
8816DEFUN (no_ip_community_list_expanded,
8817 no_ip_community_list_expanded_cmd,
8818 "no ip community-list <100-199> (deny|permit) .LINE",
8819 NO_STR
8820 IP_STR
8821 COMMUNITY_LIST_STR
8822 "Community list number (expanded)\n"
8823 "Specify community to reject\n"
8824 "Specify community to accept\n"
8825 "An ordered list as a regular-expression\n")
8826{
8827 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
8828}
8829
8830DEFUN (no_ip_community_list_name_standard,
8831 no_ip_community_list_name_standard_cmd,
8832 "no ip community-list standard WORD (deny|permit) .AA:NN",
8833 NO_STR
8834 IP_STR
8835 COMMUNITY_LIST_STR
8836 "Specify a standard community-list\n"
8837 "Community list name\n"
8838 "Specify community to reject\n"
8839 "Specify community to accept\n"
8840 COMMUNITY_VAL_STR)
8841{
8842 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
8843}
8844
8845DEFUN (no_ip_community_list_name_expanded,
8846 no_ip_community_list_name_expanded_cmd,
8847 "no ip community-list expanded WORD (deny|permit) .LINE",
8848 NO_STR
8849 IP_STR
8850 COMMUNITY_LIST_STR
8851 "Specify an expanded community-list\n"
8852 "Community list name\n"
8853 "Specify community to reject\n"
8854 "Specify community to accept\n"
8855 "An ordered list as a regular-expression\n")
8856{
8857 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
8858}
8859
8860void
8861community_list_show (struct vty *vty, struct community_list *list)
8862{
8863 struct community_entry *entry;
8864
8865 for (entry = list->head; entry; entry = entry->next)
8866 {
8867 if (entry == list->head)
8868 {
8869 if (all_digit (list->name))
8870 vty_out (vty, "Community %s list %s%s",
8871 entry->style == COMMUNITY_LIST_STANDARD ?
8872 "standard" : "(expanded) access",
8873 list->name, VTY_NEWLINE);
8874 else
8875 vty_out (vty, "Named Community %s list %s%s",
8876 entry->style == COMMUNITY_LIST_STANDARD ?
8877 "standard" : "expanded",
8878 list->name, VTY_NEWLINE);
8879 }
8880 if (entry->any)
8881 vty_out (vty, " %s%s",
8882 community_direct_str (entry->direct), VTY_NEWLINE);
8883 else
8884 vty_out (vty, " %s %s%s",
8885 community_direct_str (entry->direct),
8886 entry->style == COMMUNITY_LIST_STANDARD
8887 ? community_str (entry->u.com) : entry->config,
8888 VTY_NEWLINE);
8889 }
8890}
8891
8892DEFUN (show_ip_community_list,
8893 show_ip_community_list_cmd,
8894 "show ip community-list",
8895 SHOW_STR
8896 IP_STR
8897 "List community-list\n")
8898{
8899 struct community_list *list;
8900 struct community_list_master *cm;
8901
8902 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_AUTO);
8903 if (! cm)
8904 return CMD_SUCCESS;
8905
8906 for (list = cm->num.head; list; list = list->next)
8907 community_list_show (vty, list);
8908
8909 for (list = cm->str.head; list; list = list->next)
8910 community_list_show (vty, list);
8911
8912 return CMD_SUCCESS;
8913}
8914
8915DEFUN (show_ip_community_list_arg,
8916 show_ip_community_list_arg_cmd,
8917 "show ip community-list (<1-199>|WORD)",
8918 SHOW_STR
8919 IP_STR
8920 "List community-list\n"
8921 "Community-list number\n"
8922 "Community-list name\n")
8923{
8924 struct community_list *list;
8925
8926 list = community_list_lookup (bgp_clist, argv[0], COMMUNITY_LIST_AUTO);
8927 if (! list)
8928 {
8929 vty_out (vty, "%% Can't find communit-list%s", VTY_NEWLINE);
8930 return CMD_WARNING;
8931 }
8932
8933 community_list_show (vty, list);
8934
8935 return CMD_SUCCESS;
8936}
8937
8938int
8939extcommunity_list_set_vty (struct vty *vty, int argc, char **argv, int style,
8940 int reject_all_digit_name)
8941{
8942 int ret;
8943 int direct;
8944 char *str;
8945
8946 /* Check the list type. */
8947 if (strncmp (argv[1], "p", 1) == 0)
8948 direct = COMMUNITY_PERMIT;
8949 else if (strncmp (argv[1], "d", 1) == 0)
8950 direct = COMMUNITY_DENY;
8951 else
8952 {
8953 vty_out (vty, "%% Matching condition must be permit or deny%s",
8954 VTY_NEWLINE);
8955 return CMD_WARNING;
8956 }
8957
8958 /* All digit name check. */
8959 if (reject_all_digit_name && all_digit (argv[0]))
8960 {
8961 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
8962 return CMD_WARNING;
8963 }
8964
8965 /* Concat community string argument. */
8966 if (argc > 1)
8967 str = argv_concat (argv, argc, 2);
8968 else
8969 str = NULL;
8970
8971 ret = extcommunity_list_set (bgp_clist, argv[0], str, direct, style);
8972
8973 /* Free temporary community list string allocated by
8974 argv_concat(). */
8975 if (str)
8976 XFREE (MTYPE_TMP, str);
8977
8978 if (ret < 0)
8979 {
8980 community_list_perror (vty, ret);
8981 return CMD_WARNING;
8982 }
8983 return CMD_SUCCESS;
8984}
8985
8986int
8987extcommunity_list_unset_all_vty (struct vty *vty, char *name)
8988{
8989 int ret;
8990
8991 ret = extcommunity_list_unset (bgp_clist, name, NULL, 0, EXTCOMMUNITY_LIST_AUTO);
8992
8993 if (ret < 0)
8994 {
8995 community_list_perror (vty, ret);
8996 return CMD_WARNING;
8997 }
8998 return CMD_SUCCESS;
8999}
9000
9001int
9002extcommunity_list_unset_vty (struct vty *vty, int argc, char **argv, int style)
9003{
9004 int ret;
9005 int direct;
9006 char *str;
9007
9008 /* Check the list direct. */
9009 if (strncmp (argv[1], "p", 1) == 0)
9010 direct = COMMUNITY_PERMIT;
9011 else if (strncmp (argv[1], "d", 1) == 0)
9012 direct = COMMUNITY_DENY;
9013 else
9014 {
9015 vty_out (vty, "%% Matching condition must be permit or deny%s",
9016 VTY_NEWLINE);
9017 return CMD_WARNING;
9018 }
9019
9020 /* Concat community string argument. */
9021 str = argv_concat (argv, argc, 2);
9022
9023 /* Unset community list. */
9024 ret = extcommunity_list_unset (bgp_clist, argv[0], str, direct, style);
9025
9026 /* Free temporary community list string allocated by
9027 argv_concat(). */
9028 XFREE (MTYPE_TMP, str);
9029
9030 if (ret < 0)
9031 {
9032 community_list_perror (vty, ret);
9033 return CMD_WARNING;
9034 }
9035
9036 return CMD_SUCCESS;
9037}
9038
9039/* "extcommunity-list" keyword help string. */
9040#define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
9041#define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
9042
9043DEFUN (ip_extcommunity_list_standard,
9044 ip_extcommunity_list_standard_cmd,
9045 "ip extcommunity-list <1-99> (deny|permit) .AA:NN",
9046 IP_STR
9047 EXTCOMMUNITY_LIST_STR
9048 "Extended Community list number (standard)\n"
9049 "Specify community to reject\n"
9050 "Specify community to accept\n"
9051 EXTCOMMUNITY_VAL_STR)
9052{
9053 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
9054}
9055
9056ALIAS (ip_extcommunity_list_standard,
9057 ip_extcommunity_list_standard2_cmd,
9058 "ip extcommunity-list <1-99> (deny|permit)",
9059 IP_STR
9060 EXTCOMMUNITY_LIST_STR
9061 "Extended Community list number (standard)\n"
9062 "Specify community to reject\n"
9063 "Specify community to accept\n")
9064
9065DEFUN (ip_extcommunity_list_expanded,
9066 ip_extcommunity_list_expanded_cmd,
9067 "ip extcommunity-list <100-199> (deny|permit) .LINE",
9068 IP_STR
9069 EXTCOMMUNITY_LIST_STR
9070 "Extended Community list number (expanded)\n"
9071 "Specify community to reject\n"
9072 "Specify community to accept\n"
9073 "An ordered list as a regular-expression\n")
9074{
9075 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
9076}
9077
9078DEFUN (ip_extcommunity_list_name_standard,
9079 ip_extcommunity_list_name_standard_cmd,
9080 "ip extcommunity-list standard WORD (deny|permit) .AA:NN",
9081 IP_STR
9082 EXTCOMMUNITY_LIST_STR
9083 "Specify standard extcommunity-list\n"
9084 "Extended Community list name\n"
9085 "Specify community to reject\n"
9086 "Specify community to accept\n"
9087 EXTCOMMUNITY_VAL_STR)
9088{
9089 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
9090}
9091
9092ALIAS (ip_extcommunity_list_name_standard,
9093 ip_extcommunity_list_name_standard2_cmd,
9094 "ip extcommunity-list standard WORD (deny|permit)",
9095 IP_STR
9096 EXTCOMMUNITY_LIST_STR
9097 "Specify standard extcommunity-list\n"
9098 "Extended Community list name\n"
9099 "Specify community to reject\n"
9100 "Specify community to accept\n")
9101
9102DEFUN (ip_extcommunity_list_name_expanded,
9103 ip_extcommunity_list_name_expanded_cmd,
9104 "ip extcommunity-list expanded WORD (deny|permit) .LINE",
9105 IP_STR
9106 EXTCOMMUNITY_LIST_STR
9107 "Specify expanded extcommunity-list\n"
9108 "Extended Community list name\n"
9109 "Specify community to reject\n"
9110 "Specify community to accept\n"
9111 "An ordered list as a regular-expression\n")
9112{
9113 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
9114}
9115
9116DEFUN (no_ip_extcommunity_list_all,
9117 no_ip_extcommunity_list_all_cmd,
9118 "no ip extcommunity-list (<1-99>|<100-199>)",
9119 NO_STR
9120 IP_STR
9121 EXTCOMMUNITY_LIST_STR
9122 "Extended Community list number (standard)\n"
9123 "Extended Community list number (expanded)\n")
9124{
9125 return extcommunity_list_unset_all_vty (vty, argv[0]);
9126}
9127
9128DEFUN (no_ip_extcommunity_list_name_all,
9129 no_ip_extcommunity_list_name_all_cmd,
9130 "no ip extcommunity-list (standard|expanded) WORD",
9131 NO_STR
9132 IP_STR
9133 EXTCOMMUNITY_LIST_STR
9134 "Specify standard extcommunity-list\n"
9135 "Specify expanded extcommunity-list\n"
9136 "Extended Community list name\n")
9137{
9138 return extcommunity_list_unset_all_vty (vty, argv[1]);
9139}
9140
9141DEFUN (no_ip_extcommunity_list_standard,
9142 no_ip_extcommunity_list_standard_cmd,
9143 "no ip extcommunity-list <1-99> (deny|permit) .AA:NN",
9144 NO_STR
9145 IP_STR
9146 EXTCOMMUNITY_LIST_STR
9147 "Extended Community list number (standard)\n"
9148 "Specify community to reject\n"
9149 "Specify community to accept\n"
9150 EXTCOMMUNITY_VAL_STR)
9151{
9152 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
9153}
9154
9155DEFUN (no_ip_extcommunity_list_expanded,
9156 no_ip_extcommunity_list_expanded_cmd,
9157 "no ip extcommunity-list <100-199> (deny|permit) .LINE",
9158 NO_STR
9159 IP_STR
9160 EXTCOMMUNITY_LIST_STR
9161 "Extended Community list number (expanded)\n"
9162 "Specify community to reject\n"
9163 "Specify community to accept\n"
9164 "An ordered list as a regular-expression\n")
9165{
9166 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
9167}
9168
9169DEFUN (no_ip_extcommunity_list_name_standard,
9170 no_ip_extcommunity_list_name_standard_cmd,
9171 "no ip extcommunity-list standard WORD (deny|permit) .AA:NN",
9172 NO_STR
9173 IP_STR
9174 EXTCOMMUNITY_LIST_STR
9175 "Specify standard extcommunity-list\n"
9176 "Extended Community list name\n"
9177 "Specify community to reject\n"
9178 "Specify community to accept\n"
9179 EXTCOMMUNITY_VAL_STR)
9180{
9181 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
9182}
9183
9184DEFUN (no_ip_extcommunity_list_name_expanded,
9185 no_ip_extcommunity_list_name_expanded_cmd,
9186 "no ip extcommunity-list expanded WORD (deny|permit) .LINE",
9187 NO_STR
9188 IP_STR
9189 EXTCOMMUNITY_LIST_STR
9190 "Specify expanded extcommunity-list\n"
9191 "Community list name\n"
9192 "Specify community to reject\n"
9193 "Specify community to accept\n"
9194 "An ordered list as a regular-expression\n")
9195{
9196 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
9197}
9198
9199void
9200extcommunity_list_show (struct vty *vty, struct community_list *list)
9201{
9202 struct community_entry *entry;
9203
9204 for (entry = list->head; entry; entry = entry->next)
9205 {
9206 if (entry == list->head)
9207 {
9208 if (all_digit (list->name))
9209 vty_out (vty, "Extended community %s list %s%s",
9210 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
9211 "standard" : "(expanded) access",
9212 list->name, VTY_NEWLINE);
9213 else
9214 vty_out (vty, "Named extended community %s list %s%s",
9215 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
9216 "standard" : "expanded",
9217 list->name, VTY_NEWLINE);
9218 }
9219 if (entry->any)
9220 vty_out (vty, " %s%s",
9221 community_direct_str (entry->direct), VTY_NEWLINE);
9222 else
9223 vty_out (vty, " %s %s%s",
9224 community_direct_str (entry->direct),
9225 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
9226 entry->u.ecom->str : entry->config,
9227 VTY_NEWLINE);
9228 }
9229}
9230
9231DEFUN (show_ip_extcommunity_list,
9232 show_ip_extcommunity_list_cmd,
9233 "show ip extcommunity-list",
9234 SHOW_STR
9235 IP_STR
9236 "List extended-community list\n")
9237{
9238 struct community_list *list;
9239 struct community_list_master *cm;
9240
9241 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_AUTO);
9242 if (! cm)
9243 return CMD_SUCCESS;
9244
9245 for (list = cm->num.head; list; list = list->next)
9246 extcommunity_list_show (vty, list);
9247
9248 for (list = cm->str.head; list; list = list->next)
9249 extcommunity_list_show (vty, list);
9250
9251 return CMD_SUCCESS;
9252}
9253
9254DEFUN (show_ip_extcommunity_list_arg,
9255 show_ip_extcommunity_list_arg_cmd,
9256 "show ip extcommunity-list (<1-199>|WORD)",
9257 SHOW_STR
9258 IP_STR
9259 "List extended-community list\n"
9260 "Extcommunity-list number\n"
9261 "Extcommunity-list name\n")
9262{
9263 struct community_list *list;
9264
9265 list = community_list_lookup (bgp_clist, argv[0], EXTCOMMUNITY_LIST_AUTO);
9266 if (! list)
9267 {
9268 vty_out (vty, "%% Can't find extcommunit-list%s", VTY_NEWLINE);
9269 return CMD_WARNING;
9270 }
9271
9272 extcommunity_list_show (vty, list);
9273
9274 return CMD_SUCCESS;
9275}
9276
9277/* Return configuration string of community-list entry. */
9278static char *
9279community_list_config_str (struct community_entry *entry)
9280{
9281 char *str;
9282
9283 if (entry->any)
9284 str = "";
9285 else
9286 {
9287 if (entry->style == COMMUNITY_LIST_STANDARD)
9288 str = community_str (entry->u.com);
9289 else
9290 str = entry->config;
9291 }
9292 return str;
9293}
9294
9295/* Display community-list and extcommunity-list configuration. */
9296int
9297community_list_config_write (struct vty *vty)
9298{
9299 struct community_list *list;
9300 struct community_entry *entry;
9301 struct community_list_master *cm;
9302 int write = 0;
9303
9304 /* Community-list. */
9305 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_AUTO);
9306
9307 for (list = cm->num.head; list; list = list->next)
9308 for (entry = list->head; entry; entry = entry->next)
9309 {
9310 if (atol (list->name) < 200)
9311 vty_out (vty, "ip community-list %s %s %s%s",
9312 list->name, community_direct_str (entry->direct),
9313 community_list_config_str (entry),
9314 VTY_NEWLINE);
9315 else
9316 vty_out (vty, "ip community-list %s %s %s %s%s",
9317 entry->style == COMMUNITY_LIST_STANDARD
9318 ? "standard" : "expanded",
9319 list->name, community_direct_str (entry->direct),
9320 community_list_config_str (entry),
9321 VTY_NEWLINE);
9322 write++;
9323 }
9324 for (list = cm->str.head; list; list = list->next)
9325 for (entry = list->head; entry; entry = entry->next)
9326 {
9327 vty_out (vty, "ip community-list %s %s %s %s%s",
9328 entry->style == COMMUNITY_LIST_STANDARD
9329 ? "standard" : "expanded",
9330 list->name, community_direct_str (entry->direct),
9331 community_list_config_str (entry),
9332 VTY_NEWLINE);
9333 write++;
9334 }
9335
9336 /* Extcommunity-list. */
9337 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_AUTO);
9338
9339 for (list = cm->num.head; list; list = list->next)
9340 for (entry = list->head; entry; entry = entry->next)
9341 {
9342 if (atol (list->name) < 200)
9343 vty_out (vty, "ip extcommunity-list %s %s %s%s",
9344 list->name, community_direct_str (entry->direct),
9345 community_list_config_str (entry), VTY_NEWLINE);
9346 else
9347 vty_out (vty, "ip extcommunity-list %s %s %s %s%s",
9348 entry->style == EXTCOMMUNITY_LIST_STANDARD
9349 ? "standard" : "expanded",
9350 list->name, community_direct_str (entry->direct),
9351 community_list_config_str (entry), VTY_NEWLINE);
9352 write++;
9353 }
9354 for (list = cm->str.head; list; list = list->next)
9355 for (entry = list->head; entry; entry = entry->next)
9356 {
9357 vty_out (vty, "ip extcommunity-list %s %s %s %s%s",
9358 entry->style == EXTCOMMUNITY_LIST_STANDARD
9359 ? "standard" : "expanded",
9360 list->name, community_direct_str (entry->direct),
9361 community_list_config_str (entry), VTY_NEWLINE);
9362 write++;
9363 }
9364 return write;
9365}
9366
9367struct cmd_node community_list_node =
9368{
9369 COMMUNITY_LIST_NODE,
9370 "",
9371 1 /* Export to vtysh. */
9372};
9373
9374void
9375community_list_vty ()
9376{
9377 install_node (&community_list_node, community_list_config_write);
9378
9379 /* Community-list. */
9380 install_element (CONFIG_NODE, &ip_community_list_cmd);
9381 install_element (CONFIG_NODE, &ip_community_list_standard_cmd);
9382 install_element (CONFIG_NODE, &ip_community_list_standard2_cmd);
9383 install_element (CONFIG_NODE, &ip_community_list_expanded_cmd);
9384 install_element (CONFIG_NODE, &ip_community_list_name_standard_cmd);
9385 install_element (CONFIG_NODE, &ip_community_list_name_standard2_cmd);
9386 install_element (CONFIG_NODE, &ip_community_list_name_expanded_cmd);
9387 install_element (CONFIG_NODE, &no_ip_community_list_all_cmd);
9388 install_element (CONFIG_NODE, &no_ip_community_list_name_all_cmd);
9389 install_element (CONFIG_NODE, &no_ip_community_list_cmd);
9390 install_element (CONFIG_NODE, &no_ip_community_list_standard_cmd);
9391 install_element (CONFIG_NODE, &no_ip_community_list_expanded_cmd);
9392 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_cmd);
9393 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_cmd);
9394 install_element (VIEW_NODE, &show_ip_community_list_cmd);
9395 install_element (VIEW_NODE, &show_ip_community_list_arg_cmd);
9396 install_element (ENABLE_NODE, &show_ip_community_list_cmd);
9397 install_element (ENABLE_NODE, &show_ip_community_list_arg_cmd);
9398
9399 /* Extcommunity-list. */
9400 install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd);
9401 install_element (CONFIG_NODE, &ip_extcommunity_list_standard2_cmd);
9402 install_element (CONFIG_NODE, &ip_extcommunity_list_expanded_cmd);
9403 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard_cmd);
9404 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard2_cmd);
9405 install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd);
9406 install_element (CONFIG_NODE, &no_ip_extcommunity_list_all_cmd);
9407 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_all_cmd);
9408 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_cmd);
9409 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_cmd);
9410 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_cmd);
9411 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_cmd);
9412 install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd);
9413 install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd);
9414 install_element (ENABLE_NODE, &show_ip_extcommunity_list_cmd);
9415 install_element (ENABLE_NODE, &show_ip_extcommunity_list_arg_cmd);
9416}