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