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