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