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