blob: 02f8e4cfbdca8e2ace5ba54df1887f208c39f8b0 [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
hassof4184462005-02-01 20:13:16 +00002773/* Set specified peer's BGP port. */
paul718e3742002-12-13 20:15:29 +00002774DEFUN (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,
hasso0a486e52005-02-01 20:57:17 +00003572 const char *threshold_str, int warning,
3573 const char *restart_str)
paul718e3742002-12-13 20:15:29 +00003574{
3575 int ret;
3576 struct peer *peer;
3577 u_int32_t max;
hassoe0701b72004-05-20 09:19:34 +00003578 u_char threshold;
hasso0a486e52005-02-01 20:57:17 +00003579 u_int16_t restart;
paul718e3742002-12-13 20:15:29 +00003580
3581 peer = peer_and_group_lookup_vty (vty, ip_str);
3582 if (! peer)
3583 return CMD_WARNING;
3584
3585 VTY_GET_INTEGER ("maxmum number", max, num_str);
hassoe0701b72004-05-20 09:19:34 +00003586 if (threshold_str)
3587 threshold = atoi (threshold_str);
3588 else
3589 threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003590
hasso0a486e52005-02-01 20:57:17 +00003591 if (restart_str)
3592 restart = atoi (restart_str);
3593 else
3594 restart = 0;
3595
3596 ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart);
paul718e3742002-12-13 20:15:29 +00003597
3598 return bgp_vty_return (vty, ret);
3599}
3600
3601int
paulfd79ac92004-10-13 05:06:08 +00003602peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00003603 safi_t safi)
3604{
3605 int ret;
3606 struct peer *peer;
3607
3608 peer = peer_and_group_lookup_vty (vty, ip_str);
3609 if (! peer)
3610 return CMD_WARNING;
3611
3612 ret = peer_maximum_prefix_unset (peer, afi, safi);
3613
3614 return bgp_vty_return (vty, ret);
3615}
3616
3617/* Maximum number of prefix configuration. prefix count is different
3618 for each peer configuration. So this configuration can be set for
3619 each peer configuration. */
3620DEFUN (neighbor_maximum_prefix,
3621 neighbor_maximum_prefix_cmd,
3622 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
3623 NEIGHBOR_STR
3624 NEIGHBOR_ADDR_STR2
3625 "Maximum number of prefix accept from this peer\n"
3626 "maximum no. of prefix limit\n")
3627{
3628 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
hasso0a486e52005-02-01 20:57:17 +00003629 bgp_node_safi (vty), argv[1], NULL, 0,
3630 NULL);
paul718e3742002-12-13 20:15:29 +00003631}
3632
hassoe0701b72004-05-20 09:19:34 +00003633DEFUN (neighbor_maximum_prefix_threshold,
3634 neighbor_maximum_prefix_threshold_cmd,
3635 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100>",
3636 NEIGHBOR_STR
3637 NEIGHBOR_ADDR_STR2
3638 "Maximum number of prefix accept from this peer\n"
3639 "maximum no. of prefix limit\n"
3640 "Threshold value (%) at which to generate a warning msg\n")
3641{
3642 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
hasso0a486e52005-02-01 20:57:17 +00003643 bgp_node_safi (vty), argv[1], argv[2], 0,
3644 NULL);
3645}
hassoe0701b72004-05-20 09:19:34 +00003646
paul718e3742002-12-13 20:15:29 +00003647DEFUN (neighbor_maximum_prefix_warning,
3648 neighbor_maximum_prefix_warning_cmd,
3649 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
3650 NEIGHBOR_STR
3651 NEIGHBOR_ADDR_STR2
3652 "Maximum number of prefix accept from this peer\n"
3653 "maximum no. of prefix limit\n"
3654 "Only give warning message when limit is exceeded\n")
3655{
3656 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
hasso0a486e52005-02-01 20:57:17 +00003657 bgp_node_safi (vty), argv[1], NULL, 1,
3658 NULL);
paul718e3742002-12-13 20:15:29 +00003659}
3660
hassoe0701b72004-05-20 09:19:34 +00003661DEFUN (neighbor_maximum_prefix_threshold_warning,
3662 neighbor_maximum_prefix_threshold_warning_cmd,
3663 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
3664 NEIGHBOR_STR
3665 NEIGHBOR_ADDR_STR2
3666 "Maximum number of prefix accept from this peer\n"
3667 "maximum no. of prefix limit\n"
3668 "Threshold value (%) at which to generate a warning msg\n"
3669 "Only give warning message when limit is exceeded\n")
3670{
3671 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
hasso0a486e52005-02-01 20:57:17 +00003672 bgp_node_safi (vty), argv[1], argv[2], 1, NULL);
3673}
3674
3675DEFUN (neighbor_maximum_prefix_restart,
3676 neighbor_maximum_prefix_restart_cmd,
3677 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
3678 NEIGHBOR_STR
3679 NEIGHBOR_ADDR_STR2
3680 "Maximum number of prefix accept from this peer\n"
3681 "maximum no. of prefix limit\n"
3682 "Restart bgp connection after limit is exceeded\n"
3683 "Restart interval in minutes")
3684{
3685 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
3686 bgp_node_safi (vty), argv[1], NULL, 0, argv[2]);
3687}
3688
3689DEFUN (neighbor_maximum_prefix_threshold_restart,
3690 neighbor_maximum_prefix_threshold_restart_cmd,
3691 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
3692 NEIGHBOR_STR
3693 NEIGHBOR_ADDR_STR2
3694 "Maximum number of prefix accept from this peer\n"
3695 "maximum no. of prefix limit\n"
3696 "Threshold value (%) at which to generate a warning msg\n"
3697 "Restart bgp connection after limit is exceeded\n"
3698 "Restart interval in minutes")
3699{
3700 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
3701 bgp_node_safi (vty), argv[1], argv[2], 0, argv[3]);
3702}
hassoe0701b72004-05-20 09:19:34 +00003703
paul718e3742002-12-13 20:15:29 +00003704DEFUN (no_neighbor_maximum_prefix,
3705 no_neighbor_maximum_prefix_cmd,
3706 NO_NEIGHBOR_CMD2 "maximum-prefix",
3707 NO_STR
3708 NEIGHBOR_STR
3709 NEIGHBOR_ADDR_STR2
3710 "Maximum number of prefix accept from this peer\n")
3711{
3712 return peer_maximum_prefix_unset_vty (vty, argv[0], bgp_node_afi (vty),
3713 bgp_node_safi (vty));
3714}
3715
3716ALIAS (no_neighbor_maximum_prefix,
3717 no_neighbor_maximum_prefix_val_cmd,
3718 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
3719 NO_STR
3720 NEIGHBOR_STR
3721 NEIGHBOR_ADDR_STR2
3722 "Maximum number of prefix accept from this peer\n"
3723 "maximum no. of prefix limit\n")
3724
3725ALIAS (no_neighbor_maximum_prefix,
hasso0a486e52005-02-01 20:57:17 +00003726 no_neighbor_maximum_prefix_threshold_cmd,
3727 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
3728 NO_STR
3729 NEIGHBOR_STR
3730 NEIGHBOR_ADDR_STR2
3731 "Maximum number of prefix accept from this peer\n"
3732 "maximum no. of prefix limit\n"
3733 "Threshold value (%) at which to generate a warning msg\n")
3734
3735ALIAS (no_neighbor_maximum_prefix,
3736 no_neighbor_maximum_prefix_warning_cmd,
3737 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
3738 NO_STR
3739 NEIGHBOR_STR
3740 NEIGHBOR_ADDR_STR2
3741 "Maximum number of prefix accept from this peer\n"
3742 "maximum no. of prefix limit\n"
3743 "Only give warning message when limit is exceeded\n");
3744
3745ALIAS (no_neighbor_maximum_prefix,
3746 no_neighbor_maximum_prefix_threshold_warning_cmd,
hassoe0701b72004-05-20 09:19:34 +00003747 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
3748 NO_STR
3749 NEIGHBOR_STR
3750 NEIGHBOR_ADDR_STR2
3751 "Maximum number of prefix accept from this peer\n"
3752 "maximum no. of prefix limit\n"
3753 "Threshold value (%) at which to generate a warning msg\n"
hasso0a486e52005-02-01 20:57:17 +00003754 "Only give warning message when limit is exceeded\n");
hassoe0701b72004-05-20 09:19:34 +00003755
3756ALIAS (no_neighbor_maximum_prefix,
hasso0a486e52005-02-01 20:57:17 +00003757 no_neighbor_maximum_prefix_restart_cmd,
3758 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
paul718e3742002-12-13 20:15:29 +00003759 NO_STR
3760 NEIGHBOR_STR
3761 NEIGHBOR_ADDR_STR2
3762 "Maximum number of prefix accept from this peer\n"
3763 "maximum no. of prefix limit\n"
hasso0a486e52005-02-01 20:57:17 +00003764 "Restart bgp connection after limit is exceeded\n"
3765 "Restart interval in minutes")
3766
3767ALIAS (no_neighbor_maximum_prefix,
3768 no_neighbor_maximum_prefix_threshold_restart_cmd,
3769 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
3770 NO_STR
3771 NEIGHBOR_STR
3772 NEIGHBOR_ADDR_STR2
3773 "Maximum number of prefix accept from this peer\n"
3774 "maximum no. of prefix limit\n"
3775 "Threshold value (%) at which to generate a warning msg\n"
3776 "Restart bgp connection after limit is exceeded\n"
3777 "Restart interval in minutes")
paul718e3742002-12-13 20:15:29 +00003778
3779/* "neighbor allowas-in" */
3780DEFUN (neighbor_allowas_in,
3781 neighbor_allowas_in_cmd,
3782 NEIGHBOR_CMD2 "allowas-in",
3783 NEIGHBOR_STR
3784 NEIGHBOR_ADDR_STR2
3785 "Accept as-path with my AS present in it\n")
3786{
3787 int ret;
3788 struct peer *peer;
paulfd79ac92004-10-13 05:06:08 +00003789 unsigned int allow_num;
paul718e3742002-12-13 20:15:29 +00003790
3791 peer = peer_and_group_lookup_vty (vty, argv[0]);
3792 if (! peer)
3793 return CMD_WARNING;
3794
3795 if (argc == 1)
3796 allow_num = 3;
3797 else
3798 VTY_GET_INTEGER_RANGE ("AS number", allow_num, argv[1], 1, 10);
3799
3800 ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty),
3801 allow_num);
3802
3803 return bgp_vty_return (vty, ret);
3804}
3805
3806ALIAS (neighbor_allowas_in,
3807 neighbor_allowas_in_arg_cmd,
3808 NEIGHBOR_CMD2 "allowas-in <1-10>",
3809 NEIGHBOR_STR
3810 NEIGHBOR_ADDR_STR2
3811 "Accept as-path with my AS present in it\n"
3812 "Number of occurances of AS number\n")
3813
3814DEFUN (no_neighbor_allowas_in,
3815 no_neighbor_allowas_in_cmd,
3816 NO_NEIGHBOR_CMD2 "allowas-in",
3817 NO_STR
3818 NEIGHBOR_STR
3819 NEIGHBOR_ADDR_STR2
3820 "allow local ASN appears in aspath attribute\n")
3821{
3822 int ret;
3823 struct peer *peer;
3824
3825 peer = peer_and_group_lookup_vty (vty, argv[0]);
3826 if (! peer)
3827 return CMD_WARNING;
3828
3829 ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty));
3830
3831 return bgp_vty_return (vty, ret);
3832}
3833
3834/* Address family configuration. */
3835DEFUN (address_family_ipv4,
3836 address_family_ipv4_cmd,
3837 "address-family ipv4",
3838 "Enter Address Family command mode\n"
3839 "Address family\n")
3840{
3841 vty->node = BGP_IPV4_NODE;
3842 return CMD_SUCCESS;
3843}
3844
3845DEFUN (address_family_ipv4_safi,
3846 address_family_ipv4_safi_cmd,
3847 "address-family ipv4 (unicast|multicast)",
3848 "Enter Address Family command mode\n"
3849 "Address family\n"
3850 "Address Family modifier\n"
3851 "Address Family modifier\n")
3852{
3853 if (strncmp (argv[0], "m", 1) == 0)
3854 vty->node = BGP_IPV4M_NODE;
3855 else
3856 vty->node = BGP_IPV4_NODE;
3857
3858 return CMD_SUCCESS;
3859}
3860
3861DEFUN (address_family_ipv6_unicast,
3862 address_family_ipv6_unicast_cmd,
3863 "address-family ipv6 unicast",
3864 "Enter Address Family command mode\n"
3865 "Address family\n"
3866 "unicast\n")
3867{
3868 vty->node = BGP_IPV6_NODE;
3869 return CMD_SUCCESS;
3870}
3871
3872ALIAS (address_family_ipv6_unicast,
3873 address_family_ipv6_cmd,
3874 "address-family ipv6",
3875 "Enter Address Family command mode\n"
3876 "Address family\n")
3877
3878DEFUN (address_family_vpnv4,
3879 address_family_vpnv4_cmd,
3880 "address-family vpnv4",
3881 "Enter Address Family command mode\n"
3882 "Address family\n")
3883{
3884 vty->node = BGP_VPNV4_NODE;
3885 return CMD_SUCCESS;
3886}
3887
3888ALIAS (address_family_vpnv4,
3889 address_family_vpnv4_unicast_cmd,
3890 "address-family vpnv4 unicast",
3891 "Enter Address Family command mode\n"
3892 "Address family\n"
3893 "Address Family Modifier\n")
3894
3895DEFUN (exit_address_family,
3896 exit_address_family_cmd,
3897 "exit-address-family",
3898 "Exit from Address Family configuration mode\n")
3899{
3900 if (vty->node == BGP_IPV4M_NODE
3901 || vty->node == BGP_VPNV4_NODE
3902 || vty->node == BGP_IPV6_NODE)
3903 vty->node = BGP_NODE;
3904 return CMD_SUCCESS;
3905}
3906
3907/* BGP clear sort. */
3908enum clear_sort
3909{
3910 clear_all,
3911 clear_peer,
3912 clear_group,
3913 clear_external,
3914 clear_as
3915};
3916
3917void
3918bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi,
3919 safi_t safi, int error)
3920{
3921 switch (error)
3922 {
3923 case BGP_ERR_AF_UNCONFIGURED:
3924 vty_out (vty,
3925 "%%BGP: Enable %s %s address family for the neighbor %s%s",
3926 afi == AFI_IP6 ? "IPv6" : safi == SAFI_MPLS_VPN ? "VPNv4" : "IPv4",
3927 safi == SAFI_MULTICAST ? "Multicast" : "Unicast",
3928 peer->host, VTY_NEWLINE);
3929 break;
3930 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED:
3931 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);
3932 break;
3933 default:
3934 break;
3935 }
3936}
3937
3938/* `clear ip bgp' functions. */
3939int
3940bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
paulfd79ac92004-10-13 05:06:08 +00003941 enum clear_sort sort,enum bgp_clear_type stype, const char *arg)
paul718e3742002-12-13 20:15:29 +00003942{
3943 int ret;
3944 struct peer *peer;
3945 struct listnode *nn;
3946
3947 /* Clear all neighbors. */
3948 if (sort == clear_all)
3949 {
3950 LIST_LOOP (bgp->peer, peer, nn)
3951 {
3952 if (stype == BGP_CLEAR_SOFT_NONE)
3953 ret = peer_clear (peer);
3954 else
3955 ret = peer_clear_soft (peer, afi, safi, stype);
3956
3957 if (ret < 0)
3958 bgp_clear_vty_error (vty, peer, afi, safi, ret);
3959 }
3960 return 0;
3961 }
3962
3963 /* Clear specified neighbors. */
3964 if (sort == clear_peer)
3965 {
3966 union sockunion su;
3967 int ret;
3968
3969 /* Make sockunion for lookup. */
3970 ret = str2sockunion (arg, &su);
3971 if (ret < 0)
3972 {
3973 vty_out (vty, "Malformed address: %s%s", arg, VTY_NEWLINE);
3974 return -1;
3975 }
3976 peer = peer_lookup (bgp, &su);
3977 if (! peer)
3978 {
3979 vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE);
3980 return -1;
3981 }
3982
3983 if (stype == BGP_CLEAR_SOFT_NONE)
3984 ret = peer_clear (peer);
3985 else
3986 ret = peer_clear_soft (peer, afi, safi, stype);
3987
3988 if (ret < 0)
3989 bgp_clear_vty_error (vty, peer, afi, safi, ret);
3990
3991 return 0;
3992 }
3993
3994 /* Clear all peer-group members. */
3995 if (sort == clear_group)
3996 {
3997 struct peer_group *group;
3998
3999 group = peer_group_lookup (bgp, arg);
4000 if (! group)
4001 {
4002 vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE);
4003 return -1;
4004 }
4005
4006 LIST_LOOP (group->peer, peer, nn)
4007 {
4008 if (stype == BGP_CLEAR_SOFT_NONE)
4009 {
4010 ret = peer_clear (peer);
4011 continue;
4012 }
4013
4014 if (! peer->af_group[afi][safi])
4015 continue;
4016
4017 ret = peer_clear_soft (peer, afi, safi, stype);
4018
4019 if (ret < 0)
4020 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4021 }
4022 return 0;
4023 }
4024
4025 if (sort == clear_external)
4026 {
4027 LIST_LOOP (bgp->peer, peer, nn)
4028 {
4029 if (peer_sort (peer) == BGP_PEER_IBGP)
4030 continue;
4031
4032 if (stype == BGP_CLEAR_SOFT_NONE)
4033 ret = peer_clear (peer);
4034 else
4035 ret = peer_clear_soft (peer, afi, safi, stype);
4036
4037 if (ret < 0)
4038 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4039 }
4040 return 0;
4041 }
4042
4043 if (sort == clear_as)
4044 {
4045 as_t as;
4046 unsigned long as_ul;
4047 char *endptr = NULL;
4048 int find = 0;
4049
4050 as_ul = strtoul(arg, &endptr, 10);
4051
4052 if ((as_ul == ULONG_MAX) || (*endptr != '\0') || (as_ul > USHRT_MAX))
4053 {
4054 vty_out (vty, "Invalid AS number%s", VTY_NEWLINE);
4055 return -1;
4056 }
4057 as = (as_t) as_ul;
4058
4059 LIST_LOOP (bgp->peer, peer, nn)
4060 {
4061 if (peer->as != as)
4062 continue;
4063
4064 find = 1;
4065 if (stype == BGP_CLEAR_SOFT_NONE)
4066 ret = peer_clear (peer);
4067 else
4068 ret = peer_clear_soft (peer, afi, safi, stype);
4069
4070 if (ret < 0)
4071 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4072 }
4073 if (! find)
4074 vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg,
4075 VTY_NEWLINE);
4076 return 0;
4077 }
4078
4079 return 0;
4080}
4081
4082int
paulfd79ac92004-10-13 05:06:08 +00004083bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi,
4084 enum clear_sort sort, enum bgp_clear_type stype,
4085 const char *arg)
paul718e3742002-12-13 20:15:29 +00004086{
4087 int ret;
4088 struct bgp *bgp;
4089
4090 /* BGP structure lookup. */
4091 if (name)
4092 {
4093 bgp = bgp_lookup_by_name (name);
4094 if (bgp == NULL)
4095 {
4096 vty_out (vty, "Can't find BGP view %s%s", name, VTY_NEWLINE);
4097 return CMD_WARNING;
4098 }
4099 }
4100 else
4101 {
4102 bgp = bgp_get_default ();
4103 if (bgp == NULL)
4104 {
4105 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
4106 return CMD_WARNING;
4107 }
4108 }
4109
4110 ret = bgp_clear (vty, bgp, afi, safi, sort, stype, arg);
4111 if (ret < 0)
4112 return CMD_WARNING;
4113
4114 return CMD_SUCCESS;
4115}
4116
4117DEFUN (clear_ip_bgp_all,
4118 clear_ip_bgp_all_cmd,
4119 "clear ip bgp *",
4120 CLEAR_STR
4121 IP_STR
4122 BGP_STR
4123 "Clear all peers\n")
4124{
4125 if (argc == 1)
4126 return bgp_clear_vty (vty, argv[0], 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
4127
4128 return bgp_clear_vty (vty, NULL, 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
4129}
4130
4131ALIAS (clear_ip_bgp_all,
4132 clear_bgp_all_cmd,
4133 "clear bgp *",
4134 CLEAR_STR
4135 BGP_STR
4136 "Clear all peers\n")
4137
4138ALIAS (clear_ip_bgp_all,
4139 clear_bgp_ipv6_all_cmd,
4140 "clear bgp ipv6 *",
4141 CLEAR_STR
4142 BGP_STR
4143 "Address family\n"
4144 "Clear all peers\n")
4145
4146ALIAS (clear_ip_bgp_all,
4147 clear_ip_bgp_instance_all_cmd,
4148 "clear ip bgp view WORD *",
4149 CLEAR_STR
4150 IP_STR
4151 BGP_STR
4152 "BGP view\n"
4153 "view name\n"
4154 "Clear all peers\n")
4155
4156ALIAS (clear_ip_bgp_all,
4157 clear_bgp_instance_all_cmd,
4158 "clear bgp view WORD *",
4159 CLEAR_STR
4160 BGP_STR
4161 "BGP view\n"
4162 "view name\n"
4163 "Clear all peers\n")
4164
4165DEFUN (clear_ip_bgp_peer,
4166 clear_ip_bgp_peer_cmd,
4167 "clear ip bgp (A.B.C.D|X:X::X:X)",
4168 CLEAR_STR
4169 IP_STR
4170 BGP_STR
4171 "BGP neighbor IP address to clear\n"
4172 "BGP IPv6 neighbor to clear\n")
4173{
4174 return bgp_clear_vty (vty, NULL, 0, 0, clear_peer, BGP_CLEAR_SOFT_NONE, argv[0]);
4175}
4176
4177ALIAS (clear_ip_bgp_peer,
4178 clear_bgp_peer_cmd,
4179 "clear bgp (A.B.C.D|X:X::X:X)",
4180 CLEAR_STR
4181 BGP_STR
4182 "BGP neighbor address to clear\n"
4183 "BGP IPv6 neighbor to clear\n")
4184
4185ALIAS (clear_ip_bgp_peer,
4186 clear_bgp_ipv6_peer_cmd,
4187 "clear bgp ipv6 (A.B.C.D|X:X::X:X)",
4188 CLEAR_STR
4189 BGP_STR
4190 "Address family\n"
4191 "BGP neighbor address to clear\n"
4192 "BGP IPv6 neighbor to clear\n")
4193
4194DEFUN (clear_ip_bgp_peer_group,
4195 clear_ip_bgp_peer_group_cmd,
4196 "clear ip bgp peer-group WORD",
4197 CLEAR_STR
4198 IP_STR
4199 BGP_STR
4200 "Clear all members of peer-group\n"
4201 "BGP peer-group name\n")
4202{
4203 return bgp_clear_vty (vty, NULL, 0, 0, clear_group, BGP_CLEAR_SOFT_NONE, argv[0]);
4204}
4205
4206ALIAS (clear_ip_bgp_peer_group,
4207 clear_bgp_peer_group_cmd,
4208 "clear bgp peer-group WORD",
4209 CLEAR_STR
4210 BGP_STR
4211 "Clear all members of peer-group\n"
4212 "BGP peer-group name\n")
4213
4214ALIAS (clear_ip_bgp_peer_group,
4215 clear_bgp_ipv6_peer_group_cmd,
4216 "clear bgp ipv6 peer-group WORD",
4217 CLEAR_STR
4218 BGP_STR
4219 "Address family\n"
4220 "Clear all members of peer-group\n"
4221 "BGP peer-group name\n")
4222
4223DEFUN (clear_ip_bgp_external,
4224 clear_ip_bgp_external_cmd,
4225 "clear ip bgp external",
4226 CLEAR_STR
4227 IP_STR
4228 BGP_STR
4229 "Clear all external peers\n")
4230{
4231 return bgp_clear_vty (vty, NULL, 0, 0, clear_external, BGP_CLEAR_SOFT_NONE, NULL);
4232}
4233
4234ALIAS (clear_ip_bgp_external,
4235 clear_bgp_external_cmd,
4236 "clear bgp external",
4237 CLEAR_STR
4238 BGP_STR
4239 "Clear all external peers\n")
4240
4241ALIAS (clear_ip_bgp_external,
4242 clear_bgp_ipv6_external_cmd,
4243 "clear bgp ipv6 external",
4244 CLEAR_STR
4245 BGP_STR
4246 "Address family\n"
4247 "Clear all external peers\n")
4248
4249DEFUN (clear_ip_bgp_as,
4250 clear_ip_bgp_as_cmd,
4251 "clear ip bgp <1-65535>",
4252 CLEAR_STR
4253 IP_STR
4254 BGP_STR
4255 "Clear peers with the AS number\n")
4256{
4257 return bgp_clear_vty (vty, NULL, 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[0]);
4258}
4259
4260ALIAS (clear_ip_bgp_as,
4261 clear_bgp_as_cmd,
4262 "clear bgp <1-65535>",
4263 CLEAR_STR
4264 BGP_STR
4265 "Clear peers with the AS number\n")
4266
4267ALIAS (clear_ip_bgp_as,
4268 clear_bgp_ipv6_as_cmd,
4269 "clear bgp ipv6 <1-65535>",
4270 CLEAR_STR
4271 BGP_STR
4272 "Address family\n"
4273 "Clear peers with the AS number\n")
4274
4275/* Outbound soft-reconfiguration */
4276DEFUN (clear_ip_bgp_all_soft_out,
4277 clear_ip_bgp_all_soft_out_cmd,
4278 "clear ip bgp * soft out",
4279 CLEAR_STR
4280 IP_STR
4281 BGP_STR
4282 "Clear all peers\n"
4283 "Soft reconfig\n"
4284 "Soft reconfig outbound update\n")
4285{
4286 if (argc == 1)
4287 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
4288 BGP_CLEAR_SOFT_OUT, NULL);
4289
4290 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
4291 BGP_CLEAR_SOFT_OUT, NULL);
4292}
4293
4294ALIAS (clear_ip_bgp_all_soft_out,
4295 clear_ip_bgp_all_out_cmd,
4296 "clear ip bgp * out",
4297 CLEAR_STR
4298 IP_STR
4299 BGP_STR
4300 "Clear all peers\n"
4301 "Soft reconfig outbound update\n")
4302
4303ALIAS (clear_ip_bgp_all_soft_out,
4304 clear_ip_bgp_instance_all_soft_out_cmd,
4305 "clear ip bgp view WORD * soft out",
4306 CLEAR_STR
4307 IP_STR
4308 BGP_STR
4309 "BGP view\n"
4310 "view name\n"
4311 "Clear all peers\n"
4312 "Soft reconfig\n"
4313 "Soft reconfig outbound update\n")
4314
4315DEFUN (clear_ip_bgp_all_ipv4_soft_out,
4316 clear_ip_bgp_all_ipv4_soft_out_cmd,
4317 "clear ip bgp * ipv4 (unicast|multicast) soft out",
4318 CLEAR_STR
4319 IP_STR
4320 BGP_STR
4321 "Clear all peers\n"
4322 "Address family\n"
4323 "Address Family modifier\n"
4324 "Address Family modifier\n"
4325 "Soft reconfig\n"
4326 "Soft reconfig outbound update\n")
4327{
4328 if (strncmp (argv[0], "m", 1) == 0)
4329 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
4330 BGP_CLEAR_SOFT_OUT, NULL);
4331
4332 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
4333 BGP_CLEAR_SOFT_OUT, NULL);
4334}
4335
4336ALIAS (clear_ip_bgp_all_ipv4_soft_out,
4337 clear_ip_bgp_all_ipv4_out_cmd,
4338 "clear ip bgp * ipv4 (unicast|multicast) out",
4339 CLEAR_STR
4340 IP_STR
4341 BGP_STR
4342 "Clear all peers\n"
4343 "Address family\n"
4344 "Address Family modifier\n"
4345 "Address Family modifier\n"
4346 "Soft reconfig outbound update\n")
4347
4348DEFUN (clear_ip_bgp_instance_all_ipv4_soft_out,
4349 clear_ip_bgp_instance_all_ipv4_soft_out_cmd,
4350 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft out",
4351 CLEAR_STR
4352 IP_STR
4353 BGP_STR
4354 "BGP view\n"
4355 "view name\n"
4356 "Clear all peers\n"
4357 "Address family\n"
4358 "Address Family modifier\n"
4359 "Address Family modifier\n"
4360 "Soft reconfig outbound update\n")
4361{
4362 if (strncmp (argv[1], "m", 1) == 0)
4363 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
4364 BGP_CLEAR_SOFT_OUT, NULL);
4365
4366 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
4367 BGP_CLEAR_SOFT_OUT, NULL);
4368}
4369
4370DEFUN (clear_ip_bgp_all_vpnv4_soft_out,
4371 clear_ip_bgp_all_vpnv4_soft_out_cmd,
4372 "clear ip bgp * vpnv4 unicast soft out",
4373 CLEAR_STR
4374 IP_STR
4375 BGP_STR
4376 "Clear all peers\n"
4377 "Address family\n"
4378 "Address Family Modifier\n"
4379 "Soft reconfig\n"
4380 "Soft reconfig outbound update\n")
4381{
4382 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
4383 BGP_CLEAR_SOFT_OUT, NULL);
4384}
4385
4386ALIAS (clear_ip_bgp_all_vpnv4_soft_out,
4387 clear_ip_bgp_all_vpnv4_out_cmd,
4388 "clear ip bgp * vpnv4 unicast out",
4389 CLEAR_STR
4390 IP_STR
4391 BGP_STR
4392 "Clear all peers\n"
4393 "Address family\n"
4394 "Address Family Modifier\n"
4395 "Soft reconfig outbound update\n")
4396
4397DEFUN (clear_bgp_all_soft_out,
4398 clear_bgp_all_soft_out_cmd,
4399 "clear bgp * soft out",
4400 CLEAR_STR
4401 BGP_STR
4402 "Clear all peers\n"
4403 "Soft reconfig\n"
4404 "Soft reconfig outbound update\n")
4405{
4406 if (argc == 1)
4407 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
4408 BGP_CLEAR_SOFT_OUT, NULL);
4409
4410 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
4411 BGP_CLEAR_SOFT_OUT, NULL);
4412}
4413
4414ALIAS (clear_bgp_all_soft_out,
4415 clear_bgp_instance_all_soft_out_cmd,
4416 "clear bgp view WORD * soft out",
4417 CLEAR_STR
4418 BGP_STR
4419 "BGP view\n"
4420 "view name\n"
4421 "Clear all peers\n"
4422 "Soft reconfig\n"
4423 "Soft reconfig outbound update\n")
4424
4425ALIAS (clear_bgp_all_soft_out,
4426 clear_bgp_all_out_cmd,
4427 "clear bgp * out",
4428 CLEAR_STR
4429 BGP_STR
4430 "Clear all peers\n"
4431 "Soft reconfig outbound update\n")
4432
4433ALIAS (clear_bgp_all_soft_out,
4434 clear_bgp_ipv6_all_soft_out_cmd,
4435 "clear bgp ipv6 * soft out",
4436 CLEAR_STR
4437 BGP_STR
4438 "Address family\n"
4439 "Clear all peers\n"
4440 "Soft reconfig\n"
4441 "Soft reconfig outbound update\n")
4442
4443ALIAS (clear_bgp_all_soft_out,
4444 clear_bgp_ipv6_all_out_cmd,
4445 "clear bgp ipv6 * out",
4446 CLEAR_STR
4447 BGP_STR
4448 "Address family\n"
4449 "Clear all peers\n"
4450 "Soft reconfig outbound update\n")
4451
4452DEFUN (clear_ip_bgp_peer_soft_out,
4453 clear_ip_bgp_peer_soft_out_cmd,
4454 "clear ip bgp A.B.C.D soft out",
4455 CLEAR_STR
4456 IP_STR
4457 BGP_STR
4458 "BGP neighbor address to clear\n"
4459 "Soft reconfig\n"
4460 "Soft reconfig outbound update\n")
4461{
4462 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
4463 BGP_CLEAR_SOFT_OUT, argv[0]);
4464}
4465
4466ALIAS (clear_ip_bgp_peer_soft_out,
4467 clear_ip_bgp_peer_out_cmd,
4468 "clear ip bgp A.B.C.D out",
4469 CLEAR_STR
4470 IP_STR
4471 BGP_STR
4472 "BGP neighbor address to clear\n"
4473 "Soft reconfig outbound update\n")
4474
4475DEFUN (clear_ip_bgp_peer_ipv4_soft_out,
4476 clear_ip_bgp_peer_ipv4_soft_out_cmd,
4477 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft out",
4478 CLEAR_STR
4479 IP_STR
4480 BGP_STR
4481 "BGP neighbor address to clear\n"
4482 "Address family\n"
4483 "Address Family modifier\n"
4484 "Address Family modifier\n"
4485 "Soft reconfig\n"
4486 "Soft reconfig outbound update\n")
4487{
4488 if (strncmp (argv[1], "m", 1) == 0)
4489 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
4490 BGP_CLEAR_SOFT_OUT, argv[0]);
4491
4492 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
4493 BGP_CLEAR_SOFT_OUT, argv[0]);
4494}
4495
4496ALIAS (clear_ip_bgp_peer_ipv4_soft_out,
4497 clear_ip_bgp_peer_ipv4_out_cmd,
4498 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) out",
4499 CLEAR_STR
4500 IP_STR
4501 BGP_STR
4502 "BGP neighbor address to clear\n"
4503 "Address family\n"
4504 "Address Family modifier\n"
4505 "Address Family modifier\n"
4506 "Soft reconfig outbound update\n")
4507
4508DEFUN (clear_ip_bgp_peer_vpnv4_soft_out,
4509 clear_ip_bgp_peer_vpnv4_soft_out_cmd,
4510 "clear ip bgp A.B.C.D vpnv4 unicast soft out",
4511 CLEAR_STR
4512 IP_STR
4513 BGP_STR
4514 "BGP neighbor address to clear\n"
4515 "Address family\n"
4516 "Address Family Modifier\n"
4517 "Soft reconfig\n"
4518 "Soft reconfig outbound update\n")
4519{
4520 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
4521 BGP_CLEAR_SOFT_OUT, argv[0]);
4522}
4523
4524ALIAS (clear_ip_bgp_peer_vpnv4_soft_out,
4525 clear_ip_bgp_peer_vpnv4_out_cmd,
4526 "clear ip bgp A.B.C.D vpnv4 unicast out",
4527 CLEAR_STR
4528 IP_STR
4529 BGP_STR
4530 "BGP neighbor address to clear\n"
4531 "Address family\n"
4532 "Address Family Modifier\n"
4533 "Soft reconfig outbound update\n")
4534
4535DEFUN (clear_bgp_peer_soft_out,
4536 clear_bgp_peer_soft_out_cmd,
4537 "clear bgp (A.B.C.D|X:X::X:X) soft out",
4538 CLEAR_STR
4539 BGP_STR
4540 "BGP neighbor address to clear\n"
4541 "BGP IPv6 neighbor to clear\n"
4542 "Soft reconfig\n"
4543 "Soft reconfig outbound update\n")
4544{
4545 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
4546 BGP_CLEAR_SOFT_OUT, argv[0]);
4547}
4548
4549ALIAS (clear_bgp_peer_soft_out,
4550 clear_bgp_ipv6_peer_soft_out_cmd,
4551 "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft out",
4552 CLEAR_STR
4553 BGP_STR
4554 "Address family\n"
4555 "BGP neighbor address to clear\n"
4556 "BGP IPv6 neighbor to clear\n"
4557 "Soft reconfig\n"
4558 "Soft reconfig outbound update\n")
4559
4560ALIAS (clear_bgp_peer_soft_out,
4561 clear_bgp_peer_out_cmd,
4562 "clear bgp (A.B.C.D|X:X::X:X) out",
4563 CLEAR_STR
4564 BGP_STR
4565 "BGP neighbor address to clear\n"
4566 "BGP IPv6 neighbor to clear\n"
4567 "Soft reconfig outbound update\n")
4568
4569ALIAS (clear_bgp_peer_soft_out,
4570 clear_bgp_ipv6_peer_out_cmd,
4571 "clear bgp ipv6 (A.B.C.D|X:X::X:X) out",
4572 CLEAR_STR
4573 BGP_STR
4574 "Address family\n"
4575 "BGP neighbor address to clear\n"
4576 "BGP IPv6 neighbor to clear\n"
4577 "Soft reconfig outbound update\n")
4578
4579DEFUN (clear_ip_bgp_peer_group_soft_out,
4580 clear_ip_bgp_peer_group_soft_out_cmd,
4581 "clear ip bgp peer-group WORD soft out",
4582 CLEAR_STR
4583 IP_STR
4584 BGP_STR
4585 "Clear all members of peer-group\n"
4586 "BGP peer-group name\n"
4587 "Soft reconfig\n"
4588 "Soft reconfig outbound update\n")
4589{
4590 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
4591 BGP_CLEAR_SOFT_OUT, argv[0]);
4592}
4593
4594ALIAS (clear_ip_bgp_peer_group_soft_out,
4595 clear_ip_bgp_peer_group_out_cmd,
4596 "clear ip bgp peer-group WORD out",
4597 CLEAR_STR
4598 IP_STR
4599 BGP_STR
4600 "Clear all members of peer-group\n"
4601 "BGP peer-group name\n"
4602 "Soft reconfig outbound update\n")
4603
4604DEFUN (clear_ip_bgp_peer_group_ipv4_soft_out,
4605 clear_ip_bgp_peer_group_ipv4_soft_out_cmd,
4606 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft out",
4607 CLEAR_STR
4608 IP_STR
4609 BGP_STR
4610 "Clear all members of peer-group\n"
4611 "BGP peer-group name\n"
4612 "Address family\n"
4613 "Address Family modifier\n"
4614 "Address Family modifier\n"
4615 "Soft reconfig\n"
4616 "Soft reconfig outbound update\n")
4617{
4618 if (strncmp (argv[1], "m", 1) == 0)
4619 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
4620 BGP_CLEAR_SOFT_OUT, argv[0]);
4621
4622 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
4623 BGP_CLEAR_SOFT_OUT, argv[0]);
4624}
4625
4626ALIAS (clear_ip_bgp_peer_group_ipv4_soft_out,
4627 clear_ip_bgp_peer_group_ipv4_out_cmd,
4628 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) out",
4629 CLEAR_STR
4630 IP_STR
4631 BGP_STR
4632 "Clear all members of peer-group\n"
4633 "BGP peer-group name\n"
4634 "Address family\n"
4635 "Address Family modifier\n"
4636 "Address Family modifier\n"
4637 "Soft reconfig outbound update\n")
4638
4639DEFUN (clear_bgp_peer_group_soft_out,
4640 clear_bgp_peer_group_soft_out_cmd,
4641 "clear bgp peer-group WORD soft out",
4642 CLEAR_STR
4643 BGP_STR
4644 "Clear all members of peer-group\n"
4645 "BGP peer-group name\n"
4646 "Soft reconfig\n"
4647 "Soft reconfig outbound update\n")
4648{
4649 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
4650 BGP_CLEAR_SOFT_OUT, argv[0]);
4651}
4652
4653ALIAS (clear_bgp_peer_group_soft_out,
4654 clear_bgp_ipv6_peer_group_soft_out_cmd,
4655 "clear bgp ipv6 peer-group WORD soft out",
4656 CLEAR_STR
4657 BGP_STR
4658 "Address family\n"
4659 "Clear all members of peer-group\n"
4660 "BGP peer-group name\n"
4661 "Soft reconfig\n"
4662 "Soft reconfig outbound update\n")
4663
4664ALIAS (clear_bgp_peer_group_soft_out,
4665 clear_bgp_peer_group_out_cmd,
4666 "clear bgp peer-group WORD out",
4667 CLEAR_STR
4668 BGP_STR
4669 "Clear all members of peer-group\n"
4670 "BGP peer-group name\n"
4671 "Soft reconfig outbound update\n")
4672
4673ALIAS (clear_bgp_peer_group_soft_out,
4674 clear_bgp_ipv6_peer_group_out_cmd,
4675 "clear bgp ipv6 peer-group WORD out",
4676 CLEAR_STR
4677 BGP_STR
4678 "Address family\n"
4679 "Clear all members of peer-group\n"
4680 "BGP peer-group name\n"
4681 "Soft reconfig outbound update\n")
4682
4683DEFUN (clear_ip_bgp_external_soft_out,
4684 clear_ip_bgp_external_soft_out_cmd,
4685 "clear ip bgp external soft out",
4686 CLEAR_STR
4687 IP_STR
4688 BGP_STR
4689 "Clear all external peers\n"
4690 "Soft reconfig\n"
4691 "Soft reconfig outbound update\n")
4692{
4693 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
4694 BGP_CLEAR_SOFT_OUT, NULL);
4695}
4696
4697ALIAS (clear_ip_bgp_external_soft_out,
4698 clear_ip_bgp_external_out_cmd,
4699 "clear ip bgp external out",
4700 CLEAR_STR
4701 IP_STR
4702 BGP_STR
4703 "Clear all external peers\n"
4704 "Soft reconfig outbound update\n")
4705
4706DEFUN (clear_ip_bgp_external_ipv4_soft_out,
4707 clear_ip_bgp_external_ipv4_soft_out_cmd,
4708 "clear ip bgp external ipv4 (unicast|multicast) soft out",
4709 CLEAR_STR
4710 IP_STR
4711 BGP_STR
4712 "Clear all external peers\n"
4713 "Address family\n"
4714 "Address Family modifier\n"
4715 "Address Family modifier\n"
4716 "Soft reconfig\n"
4717 "Soft reconfig outbound update\n")
4718{
4719 if (strncmp (argv[0], "m", 1) == 0)
4720 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
4721 BGP_CLEAR_SOFT_OUT, NULL);
4722
4723 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
4724 BGP_CLEAR_SOFT_OUT, NULL);
4725}
4726
4727ALIAS (clear_ip_bgp_external_ipv4_soft_out,
4728 clear_ip_bgp_external_ipv4_out_cmd,
4729 "clear ip bgp external ipv4 (unicast|multicast) out",
4730 CLEAR_STR
4731 IP_STR
4732 BGP_STR
4733 "Clear all external peers\n"
4734 "Address family\n"
4735 "Address Family modifier\n"
4736 "Address Family modifier\n"
4737 "Soft reconfig outbound update\n")
4738
4739DEFUN (clear_bgp_external_soft_out,
4740 clear_bgp_external_soft_out_cmd,
4741 "clear bgp external soft out",
4742 CLEAR_STR
4743 BGP_STR
4744 "Clear all external peers\n"
4745 "Soft reconfig\n"
4746 "Soft reconfig outbound update\n")
4747{
4748 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
4749 BGP_CLEAR_SOFT_OUT, NULL);
4750}
4751
4752ALIAS (clear_bgp_external_soft_out,
4753 clear_bgp_ipv6_external_soft_out_cmd,
4754 "clear bgp ipv6 external soft out",
4755 CLEAR_STR
4756 BGP_STR
4757 "Address family\n"
4758 "Clear all external peers\n"
4759 "Soft reconfig\n"
4760 "Soft reconfig outbound update\n")
4761
4762ALIAS (clear_bgp_external_soft_out,
4763 clear_bgp_external_out_cmd,
4764 "clear bgp external out",
4765 CLEAR_STR
4766 BGP_STR
4767 "Clear all external peers\n"
4768 "Soft reconfig outbound update\n")
4769
4770ALIAS (clear_bgp_external_soft_out,
4771 clear_bgp_ipv6_external_out_cmd,
4772 "clear bgp ipv6 external WORD out",
4773 CLEAR_STR
4774 BGP_STR
4775 "Address family\n"
4776 "Clear all external peers\n"
4777 "Soft reconfig outbound update\n")
4778
4779DEFUN (clear_ip_bgp_as_soft_out,
4780 clear_ip_bgp_as_soft_out_cmd,
4781 "clear ip bgp <1-65535> soft out",
4782 CLEAR_STR
4783 IP_STR
4784 BGP_STR
4785 "Clear peers with the AS number\n"
4786 "Soft reconfig\n"
4787 "Soft reconfig outbound update\n")
4788{
4789 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
4790 BGP_CLEAR_SOFT_OUT, argv[0]);
4791}
4792
4793ALIAS (clear_ip_bgp_as_soft_out,
4794 clear_ip_bgp_as_out_cmd,
4795 "clear ip bgp <1-65535> out",
4796 CLEAR_STR
4797 IP_STR
4798 BGP_STR
4799 "Clear peers with the AS number\n"
4800 "Soft reconfig outbound update\n")
4801
4802DEFUN (clear_ip_bgp_as_ipv4_soft_out,
4803 clear_ip_bgp_as_ipv4_soft_out_cmd,
4804 "clear ip bgp <1-65535> ipv4 (unicast|multicast) soft out",
4805 CLEAR_STR
4806 IP_STR
4807 BGP_STR
4808 "Clear peers with the AS number\n"
4809 "Address family\n"
4810 "Address Family modifier\n"
4811 "Address Family modifier\n"
4812 "Soft reconfig\n"
4813 "Soft reconfig outbound update\n")
4814{
4815 if (strncmp (argv[1], "m", 1) == 0)
4816 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
4817 BGP_CLEAR_SOFT_OUT, argv[0]);
4818
4819 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
4820 BGP_CLEAR_SOFT_OUT, argv[0]);
4821}
4822
4823ALIAS (clear_ip_bgp_as_ipv4_soft_out,
4824 clear_ip_bgp_as_ipv4_out_cmd,
4825 "clear ip bgp <1-65535> ipv4 (unicast|multicast) out",
4826 CLEAR_STR
4827 IP_STR
4828 BGP_STR
4829 "Clear peers with the AS number\n"
4830 "Address family\n"
4831 "Address Family modifier\n"
4832 "Address Family modifier\n"
4833 "Soft reconfig outbound update\n")
4834
4835DEFUN (clear_ip_bgp_as_vpnv4_soft_out,
4836 clear_ip_bgp_as_vpnv4_soft_out_cmd,
4837 "clear ip bgp <1-65535> vpnv4 unicast soft out",
4838 CLEAR_STR
4839 IP_STR
4840 BGP_STR
4841 "Clear peers with the AS number\n"
4842 "Address family\n"
4843 "Address Family modifier\n"
4844 "Soft reconfig\n"
4845 "Soft reconfig outbound update\n")
4846{
4847 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
4848 BGP_CLEAR_SOFT_OUT, argv[0]);
4849}
4850
4851ALIAS (clear_ip_bgp_as_vpnv4_soft_out,
4852 clear_ip_bgp_as_vpnv4_out_cmd,
4853 "clear ip bgp <1-65535> vpnv4 unicast out",
4854 CLEAR_STR
4855 IP_STR
4856 BGP_STR
4857 "Clear peers with the AS number\n"
4858 "Address family\n"
4859 "Address Family modifier\n"
4860 "Soft reconfig outbound update\n")
4861
4862DEFUN (clear_bgp_as_soft_out,
4863 clear_bgp_as_soft_out_cmd,
4864 "clear bgp <1-65535> soft out",
4865 CLEAR_STR
4866 BGP_STR
4867 "Clear peers with the AS number\n"
4868 "Soft reconfig\n"
4869 "Soft reconfig outbound update\n")
4870{
4871 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
4872 BGP_CLEAR_SOFT_OUT, argv[0]);
4873}
4874
4875ALIAS (clear_bgp_as_soft_out,
4876 clear_bgp_ipv6_as_soft_out_cmd,
4877 "clear bgp ipv6 <1-65535> soft out",
4878 CLEAR_STR
4879 BGP_STR
4880 "Address family\n"
4881 "Clear peers with the AS number\n"
4882 "Soft reconfig\n"
4883 "Soft reconfig outbound update\n")
4884
4885ALIAS (clear_bgp_as_soft_out,
4886 clear_bgp_as_out_cmd,
4887 "clear bgp <1-65535> out",
4888 CLEAR_STR
4889 BGP_STR
4890 "Clear peers with the AS number\n"
4891 "Soft reconfig outbound update\n")
4892
4893ALIAS (clear_bgp_as_soft_out,
4894 clear_bgp_ipv6_as_out_cmd,
4895 "clear bgp ipv6 <1-65535> out",
4896 CLEAR_STR
4897 BGP_STR
4898 "Address family\n"
4899 "Clear peers with the AS number\n"
4900 "Soft reconfig outbound update\n")
4901
4902/* Inbound soft-reconfiguration */
4903DEFUN (clear_ip_bgp_all_soft_in,
4904 clear_ip_bgp_all_soft_in_cmd,
4905 "clear ip bgp * soft in",
4906 CLEAR_STR
4907 IP_STR
4908 BGP_STR
4909 "Clear all peers\n"
4910 "Soft reconfig\n"
4911 "Soft reconfig inbound update\n")
4912{
4913 if (argc == 1)
4914 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
4915 BGP_CLEAR_SOFT_IN, NULL);
4916
4917 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
4918 BGP_CLEAR_SOFT_IN, NULL);
4919}
4920
4921ALIAS (clear_ip_bgp_all_soft_in,
4922 clear_ip_bgp_instance_all_soft_in_cmd,
4923 "clear ip bgp view WORD * soft in",
4924 CLEAR_STR
4925 IP_STR
4926 BGP_STR
4927 "BGP view\n"
4928 "view name\n"
4929 "Clear all peers\n"
4930 "Soft reconfig\n"
4931 "Soft reconfig inbound update\n")
4932
4933ALIAS (clear_ip_bgp_all_soft_in,
4934 clear_ip_bgp_all_in_cmd,
4935 "clear ip bgp * in",
4936 CLEAR_STR
4937 IP_STR
4938 BGP_STR
4939 "Clear all peers\n"
4940 "Soft reconfig inbound update\n")
4941
4942DEFUN (clear_ip_bgp_all_in_prefix_filter,
4943 clear_ip_bgp_all_in_prefix_filter_cmd,
4944 "clear ip bgp * in prefix-filter",
4945 CLEAR_STR
4946 IP_STR
4947 BGP_STR
4948 "Clear all peers\n"
4949 "Soft reconfig inbound update\n"
4950 "Push out prefix-list ORF and do inbound soft reconfig\n")
4951{
4952 if (argc== 1)
4953 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
4954 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
4955
4956 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
4957 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
4958}
4959
4960ALIAS (clear_ip_bgp_all_in_prefix_filter,
4961 clear_ip_bgp_instance_all_in_prefix_filter_cmd,
4962 "clear ip bgp view WORD * in prefix-filter",
4963 CLEAR_STR
4964 IP_STR
4965 BGP_STR
4966 "BGP view\n"
4967 "view name\n"
4968 "Clear all peers\n"
4969 "Soft reconfig inbound update\n"
4970 "Push out prefix-list ORF and do inbound soft reconfig\n")
4971
4972
4973DEFUN (clear_ip_bgp_all_ipv4_soft_in,
4974 clear_ip_bgp_all_ipv4_soft_in_cmd,
4975 "clear ip bgp * ipv4 (unicast|multicast) soft in",
4976 CLEAR_STR
4977 IP_STR
4978 BGP_STR
4979 "Clear all peers\n"
4980 "Address family\n"
4981 "Address Family modifier\n"
4982 "Address Family modifier\n"
4983 "Soft reconfig\n"
4984 "Soft reconfig inbound update\n")
4985{
4986 if (strncmp (argv[0], "m", 1) == 0)
4987 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
4988 BGP_CLEAR_SOFT_IN, NULL);
4989
4990 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
4991 BGP_CLEAR_SOFT_IN, NULL);
4992}
4993
4994ALIAS (clear_ip_bgp_all_ipv4_soft_in,
4995 clear_ip_bgp_all_ipv4_in_cmd,
4996 "clear ip bgp * ipv4 (unicast|multicast) in",
4997 CLEAR_STR
4998 IP_STR
4999 BGP_STR
5000 "Clear all peers\n"
5001 "Address family\n"
5002 "Address Family modifier\n"
5003 "Address Family modifier\n"
5004 "Soft reconfig inbound update\n")
5005
5006DEFUN (clear_ip_bgp_instance_all_ipv4_soft_in,
5007 clear_ip_bgp_instance_all_ipv4_soft_in_cmd,
5008 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft in",
5009 CLEAR_STR
5010 IP_STR
5011 BGP_STR
5012 "BGP view\n"
5013 "view name\n"
5014 "Clear all peers\n"
5015 "Address family\n"
5016 "Address Family modifier\n"
5017 "Address Family modifier\n"
5018 "Soft reconfig\n"
5019 "Soft reconfig inbound update\n")
5020{
5021 if (strncmp (argv[1], "m", 1) == 0)
5022 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
5023 BGP_CLEAR_SOFT_IN, NULL);
5024
5025 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5026 BGP_CLEAR_SOFT_IN, NULL);
5027}
5028
5029DEFUN (clear_ip_bgp_all_ipv4_in_prefix_filter,
5030 clear_ip_bgp_all_ipv4_in_prefix_filter_cmd,
5031 "clear ip bgp * ipv4 (unicast|multicast) in prefix-filter",
5032 CLEAR_STR
5033 IP_STR
5034 BGP_STR
5035 "Clear all peers\n"
5036 "Address family\n"
5037 "Address Family modifier\n"
5038 "Address Family modifier\n"
5039 "Soft reconfig inbound update\n"
5040 "Push out prefix-list ORF and do inbound soft reconfig\n")
5041{
5042 if (strncmp (argv[0], "m", 1) == 0)
5043 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
5044 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5045
5046 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5047 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5048}
5049
5050DEFUN (clear_ip_bgp_instance_all_ipv4_in_prefix_filter,
5051 clear_ip_bgp_instance_all_ipv4_in_prefix_filter_cmd,
5052 "clear ip bgp view WORD * ipv4 (unicast|multicast) in prefix-filter",
5053 CLEAR_STR
5054 IP_STR
5055 BGP_STR
5056 "Clear all peers\n"
5057 "Address family\n"
5058 "Address Family modifier\n"
5059 "Address Family modifier\n"
5060 "Soft reconfig inbound update\n"
5061 "Push out prefix-list ORF and do inbound soft reconfig\n")
5062{
5063 if (strncmp (argv[1], "m", 1) == 0)
5064 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
5065 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5066
5067 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5068 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5069}
5070
5071DEFUN (clear_ip_bgp_all_vpnv4_soft_in,
5072 clear_ip_bgp_all_vpnv4_soft_in_cmd,
5073 "clear ip bgp * vpnv4 unicast soft in",
5074 CLEAR_STR
5075 IP_STR
5076 BGP_STR
5077 "Clear all peers\n"
5078 "Address family\n"
5079 "Address Family Modifier\n"
5080 "Soft reconfig\n"
5081 "Soft reconfig inbound update\n")
5082{
5083 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
5084 BGP_CLEAR_SOFT_IN, NULL);
5085}
5086
5087ALIAS (clear_ip_bgp_all_vpnv4_soft_in,
5088 clear_ip_bgp_all_vpnv4_in_cmd,
5089 "clear ip bgp * vpnv4 unicast in",
5090 CLEAR_STR
5091 IP_STR
5092 BGP_STR
5093 "Clear all peers\n"
5094 "Address family\n"
5095 "Address Family Modifier\n"
5096 "Soft reconfig inbound update\n")
5097
5098DEFUN (clear_bgp_all_soft_in,
5099 clear_bgp_all_soft_in_cmd,
5100 "clear bgp * soft in",
5101 CLEAR_STR
5102 BGP_STR
5103 "Clear all peers\n"
5104 "Soft reconfig\n"
5105 "Soft reconfig inbound update\n")
5106{
5107 if (argc == 1)
5108 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
5109 BGP_CLEAR_SOFT_IN, NULL);
5110
5111 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
5112 BGP_CLEAR_SOFT_IN, NULL);
5113}
5114
5115ALIAS (clear_bgp_all_soft_in,
5116 clear_bgp_instance_all_soft_in_cmd,
5117 "clear bgp view WORD * soft in",
5118 CLEAR_STR
5119 BGP_STR
5120 "BGP view\n"
5121 "view name\n"
5122 "Clear all peers\n"
5123 "Soft reconfig\n"
5124 "Soft reconfig inbound update\n")
5125
5126ALIAS (clear_bgp_all_soft_in,
5127 clear_bgp_ipv6_all_soft_in_cmd,
5128 "clear bgp ipv6 * soft in",
5129 CLEAR_STR
5130 BGP_STR
5131 "Address family\n"
5132 "Clear all peers\n"
5133 "Soft reconfig\n"
5134 "Soft reconfig inbound update\n")
5135
5136ALIAS (clear_bgp_all_soft_in,
5137 clear_bgp_all_in_cmd,
5138 "clear bgp * in",
5139 CLEAR_STR
5140 BGP_STR
5141 "Clear all peers\n"
5142 "Soft reconfig inbound update\n")
5143
5144ALIAS (clear_bgp_all_soft_in,
5145 clear_bgp_ipv6_all_in_cmd,
5146 "clear bgp ipv6 * in",
5147 CLEAR_STR
5148 BGP_STR
5149 "Address family\n"
5150 "Clear all peers\n"
5151 "Soft reconfig inbound update\n")
5152
5153DEFUN (clear_bgp_all_in_prefix_filter,
5154 clear_bgp_all_in_prefix_filter_cmd,
5155 "clear bgp * in prefix-filter",
5156 CLEAR_STR
5157 BGP_STR
5158 "Clear all peers\n"
5159 "Soft reconfig inbound update\n"
5160 "Push out prefix-list ORF and do inbound soft reconfig\n")
5161{
5162 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
5163 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5164}
5165
5166ALIAS (clear_bgp_all_in_prefix_filter,
5167 clear_bgp_ipv6_all_in_prefix_filter_cmd,
5168 "clear bgp ipv6 * in prefix-filter",
5169 CLEAR_STR
5170 BGP_STR
5171 "Address family\n"
5172 "Clear all peers\n"
5173 "Soft reconfig inbound update\n"
5174 "Push out prefix-list ORF and do inbound soft reconfig\n")
5175
5176DEFUN (clear_ip_bgp_peer_soft_in,
5177 clear_ip_bgp_peer_soft_in_cmd,
5178 "clear ip bgp A.B.C.D soft in",
5179 CLEAR_STR
5180 IP_STR
5181 BGP_STR
5182 "BGP neighbor address to clear\n"
5183 "Soft reconfig\n"
5184 "Soft reconfig inbound update\n")
5185{
5186 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5187 BGP_CLEAR_SOFT_IN, argv[0]);
5188}
5189
5190ALIAS (clear_ip_bgp_peer_soft_in,
5191 clear_ip_bgp_peer_in_cmd,
5192 "clear ip bgp A.B.C.D in",
5193 CLEAR_STR
5194 IP_STR
5195 BGP_STR
5196 "BGP neighbor address to clear\n"
5197 "Soft reconfig inbound update\n")
5198
5199DEFUN (clear_ip_bgp_peer_in_prefix_filter,
5200 clear_ip_bgp_peer_in_prefix_filter_cmd,
5201 "clear ip bgp A.B.C.D in prefix-filter",
5202 CLEAR_STR
5203 IP_STR
5204 BGP_STR
5205 "BGP neighbor address to clear\n"
5206 "Soft reconfig inbound update\n"
5207 "Push out the existing ORF prefix-list\n")
5208{
5209 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5210 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5211}
5212
5213DEFUN (clear_ip_bgp_peer_ipv4_soft_in,
5214 clear_ip_bgp_peer_ipv4_soft_in_cmd,
5215 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft in",
5216 CLEAR_STR
5217 IP_STR
5218 BGP_STR
5219 "BGP neighbor address to clear\n"
5220 "Address family\n"
5221 "Address Family modifier\n"
5222 "Address Family modifier\n"
5223 "Soft reconfig\n"
5224 "Soft reconfig inbound update\n")
5225{
5226 if (strncmp (argv[1], "m", 1) == 0)
5227 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
5228 BGP_CLEAR_SOFT_IN, argv[0]);
5229
5230 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5231 BGP_CLEAR_SOFT_IN, argv[0]);
5232}
5233
5234ALIAS (clear_ip_bgp_peer_ipv4_soft_in,
5235 clear_ip_bgp_peer_ipv4_in_cmd,
5236 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) in",
5237 CLEAR_STR
5238 IP_STR
5239 BGP_STR
5240 "BGP neighbor address to clear\n"
5241 "Address family\n"
5242 "Address Family modifier\n"
5243 "Address Family modifier\n"
5244 "Soft reconfig inbound update\n")
5245
5246DEFUN (clear_ip_bgp_peer_ipv4_in_prefix_filter,
5247 clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd,
5248 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) in prefix-filter",
5249 CLEAR_STR
5250 IP_STR
5251 BGP_STR
5252 "BGP neighbor address to clear\n"
5253 "Address family\n"
5254 "Address Family modifier\n"
5255 "Address Family modifier\n"
5256 "Soft reconfig inbound update\n"
5257 "Push out the existing ORF prefix-list\n")
5258{
5259 if (strncmp (argv[1], "m", 1) == 0)
5260 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
5261 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5262
5263 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5264 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5265}
5266
5267DEFUN (clear_ip_bgp_peer_vpnv4_soft_in,
5268 clear_ip_bgp_peer_vpnv4_soft_in_cmd,
5269 "clear ip bgp A.B.C.D vpnv4 unicast soft in",
5270 CLEAR_STR
5271 IP_STR
5272 BGP_STR
5273 "BGP neighbor address to clear\n"
5274 "Address family\n"
5275 "Address Family Modifier\n"
5276 "Soft reconfig\n"
5277 "Soft reconfig inbound update\n")
5278{
5279 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
5280 BGP_CLEAR_SOFT_IN, argv[0]);
5281}
5282
5283ALIAS (clear_ip_bgp_peer_vpnv4_soft_in,
5284 clear_ip_bgp_peer_vpnv4_in_cmd,
5285 "clear ip bgp A.B.C.D vpnv4 unicast in",
5286 CLEAR_STR
5287 IP_STR
5288 BGP_STR
5289 "BGP neighbor address to clear\n"
5290 "Address family\n"
5291 "Address Family Modifier\n"
5292 "Soft reconfig inbound update\n")
5293
5294DEFUN (clear_bgp_peer_soft_in,
5295 clear_bgp_peer_soft_in_cmd,
5296 "clear bgp (A.B.C.D|X:X::X:X) soft in",
5297 CLEAR_STR
5298 BGP_STR
5299 "BGP neighbor address to clear\n"
5300 "BGP IPv6 neighbor to clear\n"
5301 "Soft reconfig\n"
5302 "Soft reconfig inbound update\n")
5303{
5304 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
5305 BGP_CLEAR_SOFT_IN, argv[0]);
5306}
5307
5308ALIAS (clear_bgp_peer_soft_in,
5309 clear_bgp_ipv6_peer_soft_in_cmd,
5310 "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft in",
5311 CLEAR_STR
5312 BGP_STR
5313 "Address family\n"
5314 "BGP neighbor address to clear\n"
5315 "BGP IPv6 neighbor to clear\n"
5316 "Soft reconfig\n"
5317 "Soft reconfig inbound update\n")
5318
5319ALIAS (clear_bgp_peer_soft_in,
5320 clear_bgp_peer_in_cmd,
5321 "clear bgp (A.B.C.D|X:X::X:X) in",
5322 CLEAR_STR
5323 BGP_STR
5324 "BGP neighbor address to clear\n"
5325 "BGP IPv6 neighbor to clear\n"
5326 "Soft reconfig inbound update\n")
5327
5328ALIAS (clear_bgp_peer_soft_in,
5329 clear_bgp_ipv6_peer_in_cmd,
5330 "clear bgp ipv6 (A.B.C.D|X:X::X:X) in",
5331 CLEAR_STR
5332 BGP_STR
5333 "Address family\n"
5334 "BGP neighbor address to clear\n"
5335 "BGP IPv6 neighbor to clear\n"
5336 "Soft reconfig inbound update\n")
5337
5338DEFUN (clear_bgp_peer_in_prefix_filter,
5339 clear_bgp_peer_in_prefix_filter_cmd,
5340 "clear bgp (A.B.C.D|X:X::X:X) in prefix-filter",
5341 CLEAR_STR
5342 BGP_STR
5343 "BGP neighbor address to clear\n"
5344 "BGP IPv6 neighbor to clear\n"
5345 "Soft reconfig inbound update\n"
5346 "Push out the existing ORF prefix-list\n")
5347{
5348 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
5349 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5350}
5351
5352ALIAS (clear_bgp_peer_in_prefix_filter,
5353 clear_bgp_ipv6_peer_in_prefix_filter_cmd,
5354 "clear bgp ipv6 (A.B.C.D|X:X::X:X) in prefix-filter",
5355 CLEAR_STR
5356 BGP_STR
5357 "Address family\n"
5358 "BGP neighbor address to clear\n"
5359 "BGP IPv6 neighbor to clear\n"
5360 "Soft reconfig inbound update\n"
5361 "Push out the existing ORF prefix-list\n")
5362
5363DEFUN (clear_ip_bgp_peer_group_soft_in,
5364 clear_ip_bgp_peer_group_soft_in_cmd,
5365 "clear ip bgp peer-group WORD soft in",
5366 CLEAR_STR
5367 IP_STR
5368 BGP_STR
5369 "Clear all members of peer-group\n"
5370 "BGP peer-group name\n"
5371 "Soft reconfig\n"
5372 "Soft reconfig inbound update\n")
5373{
5374 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5375 BGP_CLEAR_SOFT_IN, argv[0]);
5376}
5377
5378ALIAS (clear_ip_bgp_peer_group_soft_in,
5379 clear_ip_bgp_peer_group_in_cmd,
5380 "clear ip bgp peer-group WORD in",
5381 CLEAR_STR
5382 IP_STR
5383 BGP_STR
5384 "Clear all members of peer-group\n"
5385 "BGP peer-group name\n"
5386 "Soft reconfig inbound update\n")
5387
5388DEFUN (clear_ip_bgp_peer_group_in_prefix_filter,
5389 clear_ip_bgp_peer_group_in_prefix_filter_cmd,
5390 "clear ip bgp peer-group WORD in prefix-filter",
5391 CLEAR_STR
5392 IP_STR
5393 BGP_STR
5394 "Clear all members of peer-group\n"
5395 "BGP peer-group name\n"
5396 "Soft reconfig inbound update\n"
5397 "Push out prefix-list ORF and do inbound soft reconfig\n")
5398{
5399 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5400 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5401}
5402
5403DEFUN (clear_ip_bgp_peer_group_ipv4_soft_in,
5404 clear_ip_bgp_peer_group_ipv4_soft_in_cmd,
5405 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft in",
5406 CLEAR_STR
5407 IP_STR
5408 BGP_STR
5409 "Clear all members of peer-group\n"
5410 "BGP peer-group name\n"
5411 "Address family\n"
5412 "Address Family modifier\n"
5413 "Address Family modifier\n"
5414 "Soft reconfig\n"
5415 "Soft reconfig inbound update\n")
5416{
5417 if (strncmp (argv[1], "m", 1) == 0)
5418 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
5419 BGP_CLEAR_SOFT_IN, argv[0]);
5420
5421 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5422 BGP_CLEAR_SOFT_IN, argv[0]);
5423}
5424
5425ALIAS (clear_ip_bgp_peer_group_ipv4_soft_in,
5426 clear_ip_bgp_peer_group_ipv4_in_cmd,
5427 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in",
5428 CLEAR_STR
5429 IP_STR
5430 BGP_STR
5431 "Clear all members of peer-group\n"
5432 "BGP peer-group name\n"
5433 "Address family\n"
5434 "Address Family modifier\n"
5435 "Address Family modifier\n"
5436 "Soft reconfig inbound update\n")
5437
5438DEFUN (clear_ip_bgp_peer_group_ipv4_in_prefix_filter,
5439 clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd,
5440 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in prefix-filter",
5441 CLEAR_STR
5442 IP_STR
5443 BGP_STR
5444 "Clear all members of peer-group\n"
5445 "BGP peer-group name\n"
5446 "Address family\n"
5447 "Address Family modifier\n"
5448 "Address Family modifier\n"
5449 "Soft reconfig inbound update\n"
5450 "Push out prefix-list ORF and do inbound soft reconfig\n")
5451{
5452 if (strncmp (argv[1], "m", 1) == 0)
5453 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
5454 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5455
5456 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5457 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5458}
5459
5460DEFUN (clear_bgp_peer_group_soft_in,
5461 clear_bgp_peer_group_soft_in_cmd,
5462 "clear bgp peer-group WORD soft in",
5463 CLEAR_STR
5464 BGP_STR
5465 "Clear all members of peer-group\n"
5466 "BGP peer-group name\n"
5467 "Soft reconfig\n"
5468 "Soft reconfig inbound update\n")
5469{
5470 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
5471 BGP_CLEAR_SOFT_IN, argv[0]);
5472}
5473
5474ALIAS (clear_bgp_peer_group_soft_in,
5475 clear_bgp_ipv6_peer_group_soft_in_cmd,
5476 "clear bgp ipv6 peer-group WORD soft in",
5477 CLEAR_STR
5478 BGP_STR
5479 "Address family\n"
5480 "Clear all members of peer-group\n"
5481 "BGP peer-group name\n"
5482 "Soft reconfig\n"
5483 "Soft reconfig inbound update\n")
5484
5485ALIAS (clear_bgp_peer_group_soft_in,
5486 clear_bgp_peer_group_in_cmd,
5487 "clear bgp peer-group WORD in",
5488 CLEAR_STR
5489 BGP_STR
5490 "Clear all members of peer-group\n"
5491 "BGP peer-group name\n"
5492 "Soft reconfig inbound update\n")
5493
5494ALIAS (clear_bgp_peer_group_soft_in,
5495 clear_bgp_ipv6_peer_group_in_cmd,
5496 "clear bgp ipv6 peer-group WORD in",
5497 CLEAR_STR
5498 BGP_STR
5499 "Address family\n"
5500 "Clear all members of peer-group\n"
5501 "BGP peer-group name\n"
5502 "Soft reconfig inbound update\n")
5503
5504DEFUN (clear_bgp_peer_group_in_prefix_filter,
5505 clear_bgp_peer_group_in_prefix_filter_cmd,
5506 "clear bgp peer-group WORD in prefix-filter",
5507 CLEAR_STR
5508 BGP_STR
5509 "Clear all members of peer-group\n"
5510 "BGP peer-group name\n"
5511 "Soft reconfig inbound update\n"
5512 "Push out prefix-list ORF and do inbound soft reconfig\n")
5513{
5514 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
5515 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5516}
5517
5518ALIAS (clear_bgp_peer_group_in_prefix_filter,
5519 clear_bgp_ipv6_peer_group_in_prefix_filter_cmd,
5520 "clear bgp ipv6 peer-group WORD in prefix-filter",
5521 CLEAR_STR
5522 BGP_STR
5523 "Address family\n"
5524 "Clear all members of peer-group\n"
5525 "BGP peer-group name\n"
5526 "Soft reconfig inbound update\n"
5527 "Push out prefix-list ORF and do inbound soft reconfig\n")
5528
5529DEFUN (clear_ip_bgp_external_soft_in,
5530 clear_ip_bgp_external_soft_in_cmd,
5531 "clear ip bgp external soft in",
5532 CLEAR_STR
5533 IP_STR
5534 BGP_STR
5535 "Clear all external peers\n"
5536 "Soft reconfig\n"
5537 "Soft reconfig inbound update\n")
5538{
5539 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5540 BGP_CLEAR_SOFT_IN, NULL);
5541}
5542
5543ALIAS (clear_ip_bgp_external_soft_in,
5544 clear_ip_bgp_external_in_cmd,
5545 "clear ip bgp external in",
5546 CLEAR_STR
5547 IP_STR
5548 BGP_STR
5549 "Clear all external peers\n"
5550 "Soft reconfig inbound update\n")
5551
5552DEFUN (clear_ip_bgp_external_in_prefix_filter,
5553 clear_ip_bgp_external_in_prefix_filter_cmd,
5554 "clear ip bgp external in prefix-filter",
5555 CLEAR_STR
5556 IP_STR
5557 BGP_STR
5558 "Clear all external peers\n"
5559 "Soft reconfig inbound update\n"
5560 "Push out prefix-list ORF and do inbound soft reconfig\n")
5561{
5562 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5563 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5564}
5565
5566DEFUN (clear_ip_bgp_external_ipv4_soft_in,
5567 clear_ip_bgp_external_ipv4_soft_in_cmd,
5568 "clear ip bgp external ipv4 (unicast|multicast) soft in",
5569 CLEAR_STR
5570 IP_STR
5571 BGP_STR
5572 "Clear all external peers\n"
5573 "Address family\n"
5574 "Address Family modifier\n"
5575 "Address Family modifier\n"
5576 "Soft reconfig\n"
5577 "Soft reconfig inbound update\n")
5578{
5579 if (strncmp (argv[0], "m", 1) == 0)
5580 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
5581 BGP_CLEAR_SOFT_IN, NULL);
5582
5583 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5584 BGP_CLEAR_SOFT_IN, NULL);
5585}
5586
5587ALIAS (clear_ip_bgp_external_ipv4_soft_in,
5588 clear_ip_bgp_external_ipv4_in_cmd,
5589 "clear ip bgp external ipv4 (unicast|multicast) in",
5590 CLEAR_STR
5591 IP_STR
5592 BGP_STR
5593 "Clear all external peers\n"
5594 "Address family\n"
5595 "Address Family modifier\n"
5596 "Address Family modifier\n"
5597 "Soft reconfig inbound update\n")
5598
5599DEFUN (clear_ip_bgp_external_ipv4_in_prefix_filter,
5600 clear_ip_bgp_external_ipv4_in_prefix_filter_cmd,
5601 "clear ip bgp external ipv4 (unicast|multicast) in prefix-filter",
5602 CLEAR_STR
5603 IP_STR
5604 BGP_STR
5605 "Clear all external peers\n"
5606 "Address family\n"
5607 "Address Family modifier\n"
5608 "Address Family modifier\n"
5609 "Soft reconfig inbound update\n"
5610 "Push out prefix-list ORF and do inbound soft reconfig\n")
5611{
5612 if (strncmp (argv[0], "m", 1) == 0)
5613 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
5614 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5615
5616 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5617 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5618}
5619
5620DEFUN (clear_bgp_external_soft_in,
5621 clear_bgp_external_soft_in_cmd,
5622 "clear bgp external soft in",
5623 CLEAR_STR
5624 BGP_STR
5625 "Clear all external peers\n"
5626 "Soft reconfig\n"
5627 "Soft reconfig inbound update\n")
5628{
5629 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
5630 BGP_CLEAR_SOFT_IN, NULL);
5631}
5632
5633ALIAS (clear_bgp_external_soft_in,
5634 clear_bgp_ipv6_external_soft_in_cmd,
5635 "clear bgp ipv6 external soft in",
5636 CLEAR_STR
5637 BGP_STR
5638 "Address family\n"
5639 "Clear all external peers\n"
5640 "Soft reconfig\n"
5641 "Soft reconfig inbound update\n")
5642
5643ALIAS (clear_bgp_external_soft_in,
5644 clear_bgp_external_in_cmd,
5645 "clear bgp external in",
5646 CLEAR_STR
5647 BGP_STR
5648 "Clear all external peers\n"
5649 "Soft reconfig inbound update\n")
5650
5651ALIAS (clear_bgp_external_soft_in,
5652 clear_bgp_ipv6_external_in_cmd,
5653 "clear bgp ipv6 external WORD in",
5654 CLEAR_STR
5655 BGP_STR
5656 "Address family\n"
5657 "Clear all external peers\n"
5658 "Soft reconfig inbound update\n")
5659
5660DEFUN (clear_bgp_external_in_prefix_filter,
5661 clear_bgp_external_in_prefix_filter_cmd,
5662 "clear bgp external in prefix-filter",
5663 CLEAR_STR
5664 BGP_STR
5665 "Clear all external peers\n"
5666 "Soft reconfig inbound update\n"
5667 "Push out prefix-list ORF and do inbound soft reconfig\n")
5668{
5669 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
5670 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5671}
5672
5673ALIAS (clear_bgp_external_in_prefix_filter,
5674 clear_bgp_ipv6_external_in_prefix_filter_cmd,
5675 "clear bgp ipv6 external in prefix-filter",
5676 CLEAR_STR
5677 BGP_STR
5678 "Address family\n"
5679 "Clear all external peers\n"
5680 "Soft reconfig inbound update\n"
5681 "Push out prefix-list ORF and do inbound soft reconfig\n")
5682
5683DEFUN (clear_ip_bgp_as_soft_in,
5684 clear_ip_bgp_as_soft_in_cmd,
5685 "clear ip bgp <1-65535> soft in",
5686 CLEAR_STR
5687 IP_STR
5688 BGP_STR
5689 "Clear peers with the AS number\n"
5690 "Soft reconfig\n"
5691 "Soft reconfig inbound update\n")
5692{
5693 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5694 BGP_CLEAR_SOFT_IN, argv[0]);
5695}
5696
5697ALIAS (clear_ip_bgp_as_soft_in,
5698 clear_ip_bgp_as_in_cmd,
5699 "clear ip bgp <1-65535> in",
5700 CLEAR_STR
5701 IP_STR
5702 BGP_STR
5703 "Clear peers with the AS number\n"
5704 "Soft reconfig inbound update\n")
5705
5706DEFUN (clear_ip_bgp_as_in_prefix_filter,
5707 clear_ip_bgp_as_in_prefix_filter_cmd,
5708 "clear ip bgp <1-65535> in prefix-filter",
5709 CLEAR_STR
5710 IP_STR
5711 BGP_STR
5712 "Clear peers with the AS number\n"
5713 "Soft reconfig inbound update\n"
5714 "Push out prefix-list ORF and do inbound soft reconfig\n")
5715{
5716 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5717 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5718}
5719
5720DEFUN (clear_ip_bgp_as_ipv4_soft_in,
5721 clear_ip_bgp_as_ipv4_soft_in_cmd,
5722 "clear ip bgp <1-65535> ipv4 (unicast|multicast) soft in",
5723 CLEAR_STR
5724 IP_STR
5725 BGP_STR
5726 "Clear peers with the AS number\n"
5727 "Address family\n"
5728 "Address Family modifier\n"
5729 "Address Family modifier\n"
5730 "Soft reconfig\n"
5731 "Soft reconfig inbound update\n")
5732{
5733 if (strncmp (argv[1], "m", 1) == 0)
5734 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
5735 BGP_CLEAR_SOFT_IN, argv[0]);
5736
5737 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5738 BGP_CLEAR_SOFT_IN, argv[0]);
5739}
5740
5741ALIAS (clear_ip_bgp_as_ipv4_soft_in,
5742 clear_ip_bgp_as_ipv4_in_cmd,
5743 "clear ip bgp <1-65535> ipv4 (unicast|multicast) in",
5744 CLEAR_STR
5745 IP_STR
5746 BGP_STR
5747 "Clear peers with the AS number\n"
5748 "Address family\n"
5749 "Address Family modifier\n"
5750 "Address Family modifier\n"
5751 "Soft reconfig inbound update\n")
5752
5753DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter,
5754 clear_ip_bgp_as_ipv4_in_prefix_filter_cmd,
5755 "clear ip bgp <1-65535> ipv4 (unicast|multicast) in prefix-filter",
5756 CLEAR_STR
5757 IP_STR
5758 BGP_STR
5759 "Clear peers with the AS number\n"
5760 "Address family\n"
5761 "Address Family modifier\n"
5762 "Address Family modifier\n"
5763 "Soft reconfig inbound update\n"
5764 "Push out prefix-list ORF and do inbound soft reconfig\n")
5765{
5766 if (strncmp (argv[1], "m", 1) == 0)
5767 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
5768 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5769
5770 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5771 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5772}
5773
5774DEFUN (clear_ip_bgp_as_vpnv4_soft_in,
5775 clear_ip_bgp_as_vpnv4_soft_in_cmd,
5776 "clear ip bgp <1-65535> vpnv4 unicast soft in",
5777 CLEAR_STR
5778 IP_STR
5779 BGP_STR
5780 "Clear peers with the AS number\n"
5781 "Address family\n"
5782 "Address Family modifier\n"
5783 "Soft reconfig\n"
5784 "Soft reconfig inbound update\n")
5785{
5786 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
5787 BGP_CLEAR_SOFT_IN, argv[0]);
5788}
5789
5790ALIAS (clear_ip_bgp_as_vpnv4_soft_in,
5791 clear_ip_bgp_as_vpnv4_in_cmd,
5792 "clear ip bgp <1-65535> vpnv4 unicast in",
5793 CLEAR_STR
5794 IP_STR
5795 BGP_STR
5796 "Clear peers with the AS number\n"
5797 "Address family\n"
5798 "Address Family modifier\n"
5799 "Soft reconfig inbound update\n")
5800
5801DEFUN (clear_bgp_as_soft_in,
5802 clear_bgp_as_soft_in_cmd,
5803 "clear bgp <1-65535> soft in",
5804 CLEAR_STR
5805 BGP_STR
5806 "Clear peers with the AS number\n"
5807 "Soft reconfig\n"
5808 "Soft reconfig inbound update\n")
5809{
5810 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
5811 BGP_CLEAR_SOFT_IN, argv[0]);
5812}
5813
5814ALIAS (clear_bgp_as_soft_in,
5815 clear_bgp_ipv6_as_soft_in_cmd,
5816 "clear bgp ipv6 <1-65535> soft in",
5817 CLEAR_STR
5818 BGP_STR
5819 "Address family\n"
5820 "Clear peers with the AS number\n"
5821 "Soft reconfig\n"
5822 "Soft reconfig inbound update\n")
5823
5824ALIAS (clear_bgp_as_soft_in,
5825 clear_bgp_as_in_cmd,
5826 "clear bgp <1-65535> in",
5827 CLEAR_STR
5828 BGP_STR
5829 "Clear peers with the AS number\n"
5830 "Soft reconfig inbound update\n")
5831
5832ALIAS (clear_bgp_as_soft_in,
5833 clear_bgp_ipv6_as_in_cmd,
5834 "clear bgp ipv6 <1-65535> in",
5835 CLEAR_STR
5836 BGP_STR
5837 "Address family\n"
5838 "Clear peers with the AS number\n"
5839 "Soft reconfig inbound update\n")
5840
5841DEFUN (clear_bgp_as_in_prefix_filter,
5842 clear_bgp_as_in_prefix_filter_cmd,
5843 "clear bgp <1-65535> in prefix-filter",
5844 CLEAR_STR
5845 BGP_STR
5846 "Clear peers with the AS number\n"
5847 "Soft reconfig inbound update\n"
5848 "Push out prefix-list ORF and do inbound soft reconfig\n")
5849{
5850 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
5851 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5852}
5853
5854ALIAS (clear_bgp_as_in_prefix_filter,
5855 clear_bgp_ipv6_as_in_prefix_filter_cmd,
5856 "clear bgp ipv6 <1-65535> in prefix-filter",
5857 CLEAR_STR
5858 BGP_STR
5859 "Address family\n"
5860 "Clear peers with the AS number\n"
5861 "Soft reconfig inbound update\n"
5862 "Push out prefix-list ORF and do inbound soft reconfig\n")
5863
5864/* Both soft-reconfiguration */
5865DEFUN (clear_ip_bgp_all_soft,
5866 clear_ip_bgp_all_soft_cmd,
5867 "clear ip bgp * soft",
5868 CLEAR_STR
5869 IP_STR
5870 BGP_STR
5871 "Clear all peers\n"
5872 "Soft reconfig\n")
5873{
5874 if (argc == 1)
5875 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5876 BGP_CLEAR_SOFT_BOTH, NULL);
5877
5878 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5879 BGP_CLEAR_SOFT_BOTH, NULL);
5880}
5881
5882ALIAS (clear_ip_bgp_all_soft,
5883 clear_ip_bgp_instance_all_soft_cmd,
5884 "clear ip bgp view WORD * soft",
5885 CLEAR_STR
5886 IP_STR
5887 BGP_STR
5888 "BGP view\n"
5889 "view name\n"
5890 "Clear all peers\n"
5891 "Soft reconfig\n")
5892
5893
5894DEFUN (clear_ip_bgp_all_ipv4_soft,
5895 clear_ip_bgp_all_ipv4_soft_cmd,
5896 "clear ip bgp * ipv4 (unicast|multicast) soft",
5897 CLEAR_STR
5898 IP_STR
5899 BGP_STR
5900 "Clear all peers\n"
5901 "Address family\n"
5902 "Address Family Modifier\n"
5903 "Address Family Modifier\n"
5904 "Soft reconfig\n")
5905{
5906 if (strncmp (argv[0], "m", 1) == 0)
5907 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
5908 BGP_CLEAR_SOFT_BOTH, NULL);
5909
5910 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5911 BGP_CLEAR_SOFT_BOTH, NULL);
5912}
5913
5914DEFUN (clear_ip_bgp_instance_all_ipv4_soft,
5915 clear_ip_bgp_instance_all_ipv4_soft_cmd,
5916 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft",
5917 CLEAR_STR
5918 IP_STR
5919 BGP_STR
5920 "BGP view\n"
5921 "view name\n"
5922 "Clear all peers\n"
5923 "Address family\n"
5924 "Address Family Modifier\n"
5925 "Address Family Modifier\n"
5926 "Soft reconfig\n")
5927{
5928 if (strncmp (argv[1], "m", 1) == 0)
5929 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
5930 BGP_CLEAR_SOFT_BOTH, NULL);
5931
5932 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5933 BGP_CLEAR_SOFT_BOTH, NULL);
5934}
5935
5936DEFUN (clear_ip_bgp_all_vpnv4_soft,
5937 clear_ip_bgp_all_vpnv4_soft_cmd,
5938 "clear ip bgp * vpnv4 unicast soft",
5939 CLEAR_STR
5940 IP_STR
5941 BGP_STR
5942 "Clear all peers\n"
5943 "Address family\n"
5944 "Address Family Modifier\n"
5945 "Soft reconfig\n")
5946{
5947 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
5948 BGP_CLEAR_SOFT_BOTH, argv[0]);
5949}
5950
5951DEFUN (clear_bgp_all_soft,
5952 clear_bgp_all_soft_cmd,
5953 "clear bgp * soft",
5954 CLEAR_STR
5955 BGP_STR
5956 "Clear all peers\n"
5957 "Soft reconfig\n")
5958{
5959 if (argc == 1)
5960 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
5961 BGP_CLEAR_SOFT_BOTH, argv[0]);
5962
5963 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
5964 BGP_CLEAR_SOFT_BOTH, argv[0]);
5965}
5966
5967ALIAS (clear_bgp_all_soft,
5968 clear_bgp_instance_all_soft_cmd,
5969 "clear bgp view WORD * soft",
5970 CLEAR_STR
5971 BGP_STR
5972 "BGP view\n"
5973 "view name\n"
5974 "Clear all peers\n"
5975 "Soft reconfig\n")
5976
5977ALIAS (clear_bgp_all_soft,
5978 clear_bgp_ipv6_all_soft_cmd,
5979 "clear bgp ipv6 * soft",
5980 CLEAR_STR
5981 BGP_STR
5982 "Address family\n"
5983 "Clear all peers\n"
5984 "Soft reconfig\n")
5985
5986DEFUN (clear_ip_bgp_peer_soft,
5987 clear_ip_bgp_peer_soft_cmd,
5988 "clear ip bgp A.B.C.D soft",
5989 CLEAR_STR
5990 IP_STR
5991 BGP_STR
5992 "BGP neighbor address to clear\n"
5993 "Soft reconfig\n")
5994{
5995 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5996 BGP_CLEAR_SOFT_BOTH, argv[0]);
5997}
5998
5999DEFUN (clear_ip_bgp_peer_ipv4_soft,
6000 clear_ip_bgp_peer_ipv4_soft_cmd,
6001 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft",
6002 CLEAR_STR
6003 IP_STR
6004 BGP_STR
6005 "BGP neighbor address to clear\n"
6006 "Address family\n"
6007 "Address Family Modifier\n"
6008 "Address Family Modifier\n"
6009 "Soft reconfig\n")
6010{
6011 if (strncmp (argv[1], "m", 1) == 0)
6012 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
6013 BGP_CLEAR_SOFT_BOTH, argv[0]);
6014
6015 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6016 BGP_CLEAR_SOFT_BOTH, argv[0]);
6017}
6018
6019DEFUN (clear_ip_bgp_peer_vpnv4_soft,
6020 clear_ip_bgp_peer_vpnv4_soft_cmd,
6021 "clear ip bgp A.B.C.D vpnv4 unicast soft",
6022 CLEAR_STR
6023 IP_STR
6024 BGP_STR
6025 "BGP neighbor address to clear\n"
6026 "Address family\n"
6027 "Address Family Modifier\n"
6028 "Soft reconfig\n")
6029{
6030 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
6031 BGP_CLEAR_SOFT_BOTH, argv[0]);
6032}
6033
6034DEFUN (clear_bgp_peer_soft,
6035 clear_bgp_peer_soft_cmd,
6036 "clear bgp (A.B.C.D|X:X::X:X) soft",
6037 CLEAR_STR
6038 BGP_STR
6039 "BGP neighbor address to clear\n"
6040 "BGP IPv6 neighbor to clear\n"
6041 "Soft reconfig\n")
6042{
6043 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
6044 BGP_CLEAR_SOFT_BOTH, argv[0]);
6045}
6046
6047ALIAS (clear_bgp_peer_soft,
6048 clear_bgp_ipv6_peer_soft_cmd,
6049 "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft",
6050 CLEAR_STR
6051 BGP_STR
6052 "Address family\n"
6053 "BGP neighbor address to clear\n"
6054 "BGP IPv6 neighbor to clear\n"
6055 "Soft reconfig\n")
6056
6057DEFUN (clear_ip_bgp_peer_group_soft,
6058 clear_ip_bgp_peer_group_soft_cmd,
6059 "clear ip bgp peer-group WORD soft",
6060 CLEAR_STR
6061 IP_STR
6062 BGP_STR
6063 "Clear all members of peer-group\n"
6064 "BGP peer-group name\n"
6065 "Soft reconfig\n")
6066{
6067 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6068 BGP_CLEAR_SOFT_BOTH, argv[0]);
6069}
6070
6071DEFUN (clear_ip_bgp_peer_group_ipv4_soft,
6072 clear_ip_bgp_peer_group_ipv4_soft_cmd,
6073 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft",
6074 CLEAR_STR
6075 IP_STR
6076 BGP_STR
6077 "Clear all members of peer-group\n"
6078 "BGP peer-group name\n"
6079 "Address family\n"
6080 "Address Family modifier\n"
6081 "Address Family modifier\n"
6082 "Soft reconfig\n")
6083{
6084 if (strncmp (argv[1], "m", 1) == 0)
6085 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
6086 BGP_CLEAR_SOFT_BOTH, argv[0]);
6087
6088 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6089 BGP_CLEAR_SOFT_BOTH, argv[0]);
6090}
6091
6092DEFUN (clear_bgp_peer_group_soft,
6093 clear_bgp_peer_group_soft_cmd,
6094 "clear bgp peer-group WORD soft",
6095 CLEAR_STR
6096 BGP_STR
6097 "Clear all members of peer-group\n"
6098 "BGP peer-group name\n"
6099 "Soft reconfig\n")
6100{
6101 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
6102 BGP_CLEAR_SOFT_BOTH, argv[0]);
6103}
6104
6105ALIAS (clear_bgp_peer_group_soft,
6106 clear_bgp_ipv6_peer_group_soft_cmd,
6107 "clear bgp ipv6 peer-group WORD soft",
6108 CLEAR_STR
6109 BGP_STR
6110 "Address family\n"
6111 "Clear all members of peer-group\n"
6112 "BGP peer-group name\n"
6113 "Soft reconfig\n")
6114
6115DEFUN (clear_ip_bgp_external_soft,
6116 clear_ip_bgp_external_soft_cmd,
6117 "clear ip bgp external soft",
6118 CLEAR_STR
6119 IP_STR
6120 BGP_STR
6121 "Clear all external peers\n"
6122 "Soft reconfig\n")
6123{
6124 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
6125 BGP_CLEAR_SOFT_BOTH, NULL);
6126}
6127
6128DEFUN (clear_ip_bgp_external_ipv4_soft,
6129 clear_ip_bgp_external_ipv4_soft_cmd,
6130 "clear ip bgp external ipv4 (unicast|multicast) soft",
6131 CLEAR_STR
6132 IP_STR
6133 BGP_STR
6134 "Clear all external peers\n"
6135 "Address family\n"
6136 "Address Family modifier\n"
6137 "Address Family modifier\n"
6138 "Soft reconfig\n")
6139{
6140 if (strncmp (argv[0], "m", 1) == 0)
6141 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
6142 BGP_CLEAR_SOFT_BOTH, NULL);
6143
6144 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
6145 BGP_CLEAR_SOFT_BOTH, NULL);
6146}
6147
6148DEFUN (clear_bgp_external_soft,
6149 clear_bgp_external_soft_cmd,
6150 "clear bgp external soft",
6151 CLEAR_STR
6152 BGP_STR
6153 "Clear all external peers\n"
6154 "Soft reconfig\n")
6155{
6156 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
6157 BGP_CLEAR_SOFT_BOTH, NULL);
6158}
6159
6160ALIAS (clear_bgp_external_soft,
6161 clear_bgp_ipv6_external_soft_cmd,
6162 "clear bgp ipv6 external soft",
6163 CLEAR_STR
6164 BGP_STR
6165 "Address family\n"
6166 "Clear all external peers\n"
6167 "Soft reconfig\n")
6168
6169DEFUN (clear_ip_bgp_as_soft,
6170 clear_ip_bgp_as_soft_cmd,
6171 "clear ip bgp <1-65535> soft",
6172 CLEAR_STR
6173 IP_STR
6174 BGP_STR
6175 "Clear peers with the AS number\n"
6176 "Soft reconfig\n")
6177{
6178 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
6179 BGP_CLEAR_SOFT_BOTH, argv[0]);
6180}
6181
6182DEFUN (clear_ip_bgp_as_ipv4_soft,
6183 clear_ip_bgp_as_ipv4_soft_cmd,
6184 "clear ip bgp <1-65535> ipv4 (unicast|multicast) soft",
6185 CLEAR_STR
6186 IP_STR
6187 BGP_STR
6188 "Clear peers with the AS number\n"
6189 "Address family\n"
6190 "Address Family Modifier\n"
6191 "Address Family Modifier\n"
6192 "Soft reconfig\n")
6193{
6194 if (strncmp (argv[1], "m", 1) == 0)
6195 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
6196 BGP_CLEAR_SOFT_BOTH, argv[0]);
6197
6198 return bgp_clear_vty (vty, NULL,AFI_IP, SAFI_UNICAST, clear_as,
6199 BGP_CLEAR_SOFT_BOTH, argv[0]);
6200}
6201
6202DEFUN (clear_ip_bgp_as_vpnv4_soft,
6203 clear_ip_bgp_as_vpnv4_soft_cmd,
6204 "clear ip bgp <1-65535> vpnv4 unicast soft",
6205 CLEAR_STR
6206 IP_STR
6207 BGP_STR
6208 "Clear peers with the AS number\n"
6209 "Address family\n"
6210 "Address Family Modifier\n"
6211 "Soft reconfig\n")
6212{
6213 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
6214 BGP_CLEAR_SOFT_BOTH, argv[0]);
6215}
6216
6217DEFUN (clear_bgp_as_soft,
6218 clear_bgp_as_soft_cmd,
6219 "clear bgp <1-65535> soft",
6220 CLEAR_STR
6221 BGP_STR
6222 "Clear peers with the AS number\n"
6223 "Soft reconfig\n")
6224{
6225 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
6226 BGP_CLEAR_SOFT_BOTH, argv[0]);
6227}
6228
6229ALIAS (clear_bgp_as_soft,
6230 clear_bgp_ipv6_as_soft_cmd,
6231 "clear bgp ipv6 <1-65535> soft",
6232 CLEAR_STR
6233 BGP_STR
6234 "Address family\n"
6235 "Clear peers with the AS number\n"
6236 "Soft reconfig\n")
6237
paulfee0f4c2004-09-13 05:12:46 +00006238/* RS-client soft reconfiguration. */
6239#ifdef HAVE_IPV6
6240DEFUN (clear_bgp_all_rsclient,
6241 clear_bgp_all_rsclient_cmd,
6242 "clear bgp * rsclient",
6243 CLEAR_STR
6244 BGP_STR
6245 "Clear all peers\n"
6246 "Soft reconfig for rsclient RIB\n")
6247{
6248 if (argc == 1)
6249 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
6250 BGP_CLEAR_SOFT_RSCLIENT, NULL);
6251
6252 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
6253 BGP_CLEAR_SOFT_RSCLIENT, NULL);
6254}
6255
6256ALIAS (clear_bgp_all_rsclient,
6257 clear_bgp_ipv6_all_rsclient_cmd,
6258 "clear bgp ipv6 * rsclient",
6259 CLEAR_STR
6260 BGP_STR
6261 "Address family\n"
6262 "Clear all peers\n"
6263 "Soft reconfig for rsclient RIB\n")
6264
6265ALIAS (clear_bgp_all_rsclient,
6266 clear_bgp_instance_all_rsclient_cmd,
6267 "clear bgp view WORD * rsclient",
6268 CLEAR_STR
6269 BGP_STR
6270 "BGP view\n"
6271 "view name\n"
6272 "Clear all peers\n"
6273 "Soft reconfig for rsclient RIB\n")
6274
6275ALIAS (clear_bgp_all_rsclient,
6276 clear_bgp_ipv6_instance_all_rsclient_cmd,
6277 "clear bgp ipv6 view WORD * rsclient",
6278 CLEAR_STR
6279 BGP_STR
6280 "Address family\n"
6281 "BGP view\n"
6282 "view name\n"
6283 "Clear all peers\n"
6284 "Soft reconfig for rsclient RIB\n")
6285#endif /* HAVE_IPV6 */
6286
6287DEFUN (clear_ip_bgp_all_rsclient,
6288 clear_ip_bgp_all_rsclient_cmd,
6289 "clear ip bgp * rsclient",
6290 CLEAR_STR
6291 IP_STR
6292 BGP_STR
6293 "Clear all peers\n"
6294 "Soft reconfig for rsclient RIB\n")
6295{
6296 if (argc == 1)
6297 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
6298 BGP_CLEAR_SOFT_RSCLIENT, NULL);
6299
6300 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6301 BGP_CLEAR_SOFT_RSCLIENT, NULL);
6302}
6303
6304ALIAS (clear_ip_bgp_all_rsclient,
6305 clear_ip_bgp_instance_all_rsclient_cmd,
6306 "clear ip bgp view WORD * rsclient",
6307 CLEAR_STR
6308 IP_STR
6309 BGP_STR
6310 "BGP view\n"
6311 "view name\n"
6312 "Clear all peers\n"
6313 "Soft reconfig for rsclient RIB\n")
6314
6315#ifdef HAVE_IPV6
6316DEFUN (clear_bgp_peer_rsclient,
6317 clear_bgp_peer_rsclient_cmd,
6318 "clear bgp (A.B.C.D|X:X::X:X) rsclient",
6319 CLEAR_STR
6320 BGP_STR
6321 "BGP neighbor IP address to clear\n"
6322 "BGP IPv6 neighbor to clear\n"
6323 "Soft reconfig for rsclient RIB\n")
6324{
6325 if (argc == 2)
6326 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_peer,
6327 BGP_CLEAR_SOFT_RSCLIENT, argv[1]);
6328
6329 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
6330 BGP_CLEAR_SOFT_RSCLIENT, argv[0]);
6331}
6332
6333ALIAS (clear_bgp_peer_rsclient,
6334 clear_bgp_ipv6_peer_rsclient_cmd,
6335 "clear bgp ipv6 (A.B.C.D|X:X::X:X) rsclient",
6336 CLEAR_STR
6337 BGP_STR
6338 "Address family\n"
6339 "BGP neighbor IP address to clear\n"
6340 "BGP IPv6 neighbor to clear\n"
6341 "Soft reconfig for rsclient RIB\n")
6342
6343ALIAS (clear_bgp_peer_rsclient,
6344 clear_bgp_instance_peer_rsclient_cmd,
6345 "clear bgp view WORD (A.B.C.D|X:X::X:X) rsclient",
6346 CLEAR_STR
6347 BGP_STR
6348 "BGP view\n"
6349 "view name\n"
6350 "BGP neighbor IP address to clear\n"
6351 "BGP IPv6 neighbor to clear\n"
6352 "Soft reconfig for rsclient RIB\n")
6353
6354ALIAS (clear_bgp_peer_rsclient,
6355 clear_bgp_ipv6_instance_peer_rsclient_cmd,
6356 "clear bgp ipv6 view WORD (A.B.C.D|X:X::X:X) rsclient",
6357 CLEAR_STR
6358 BGP_STR
6359 "Address family\n"
6360 "BGP view\n"
6361 "view name\n"
6362 "BGP neighbor IP address to clear\n"
6363 "BGP IPv6 neighbor to clear\n"
6364 "Soft reconfig for rsclient RIB\n")
6365#endif /* HAVE_IPV6 */
6366
6367DEFUN (clear_ip_bgp_peer_rsclient,
6368 clear_ip_bgp_peer_rsclient_cmd,
6369 "clear ip bgp (A.B.C.D|X:X::X:X) rsclient",
6370 CLEAR_STR
6371 IP_STR
6372 BGP_STR
6373 "BGP neighbor IP address to clear\n"
6374 "BGP IPv6 neighbor to clear\n"
6375 "Soft reconfig for rsclient RIB\n")
6376{
6377 if (argc == 2)
6378 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_peer,
6379 BGP_CLEAR_SOFT_RSCLIENT, argv[1]);
6380
6381 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6382 BGP_CLEAR_SOFT_RSCLIENT, argv[0]);
6383}
6384
6385ALIAS (clear_ip_bgp_peer_rsclient,
6386 clear_ip_bgp_instance_peer_rsclient_cmd,
6387 "clear ip bgp view WORD (A.B.C.D|X:X::X:X) rsclient",
6388 CLEAR_STR
6389 IP_STR
6390 BGP_STR
6391 "BGP view\n"
6392 "view name\n"
6393 "BGP neighbor IP address to clear\n"
6394 "BGP IPv6 neighbor to clear\n"
6395 "Soft reconfig for rsclient RIB\n")
6396
6397
paul718e3742002-12-13 20:15:29 +00006398/* Show BGP peer's summary information. */
6399int
6400bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi)
6401{
6402 struct peer *peer;
6403 struct listnode *nn;
6404 int count = 0;
6405 char timebuf[BGP_UPTIME_LEN];
6406 int len;
6407
6408 /* Header string for each address family. */
6409 static char header[] = "Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd";
6410
6411 LIST_LOOP (bgp->peer, peer, nn)
6412 {
6413 if (peer->afc[afi][safi])
6414 {
6415 if (! count)
6416 {
6417 vty_out (vty,
6418 "BGP router identifier %s, local AS number %d%s",
6419 inet_ntoa (bgp->router_id), bgp->as, VTY_NEWLINE);
6420 vty_out (vty,
6421 "%ld BGP AS-PATH entries%s", aspath_count (),
6422 VTY_NEWLINE);
6423 vty_out (vty,
6424 "%ld BGP community entries%s", community_count (),
6425 VTY_NEWLINE);
6426
6427 if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
6428 vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE);
6429 vty_out (vty, "%s", VTY_NEWLINE);
6430 vty_out (vty, "%s%s", header, VTY_NEWLINE);
6431 }
6432 count++;
6433
6434 len = vty_out (vty, "%s", peer->host);
6435 len = 16 - len;
6436 if (len < 1)
6437 vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
6438 else
6439 vty_out (vty, "%*s", len, " ");
6440
6441 switch (peer->version)
6442 {
6443 case BGP_VERSION_4:
6444 vty_out (vty, "4 ");
6445 break;
6446 case BGP_VERSION_MP_4_DRAFT_00:
6447 vty_out (vty, "4-");
6448 break;
6449 }
6450
6451 vty_out (vty, "%5d %7d %7d %8d %4d %4ld ",
6452 peer->as,
6453 peer->open_in + peer->update_in + peer->keepalive_in
6454 + peer->notify_in + peer->refresh_in + peer->dynamic_cap_in,
6455 peer->open_out + peer->update_out + peer->keepalive_out
6456 + peer->notify_out + peer->refresh_out
6457 + peer->dynamic_cap_out,
6458 0, 0, peer->obuf->count);
6459
6460 vty_out (vty, "%8s",
6461 peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN));
6462
6463 if (peer->status == Established)
6464 {
6465 vty_out (vty, " %8ld", peer->pcount[afi][safi]);
6466 }
6467 else
6468 {
6469 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
6470 vty_out (vty, " Idle (Admin)");
6471 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
6472 vty_out (vty, " Idle (PfxCt)");
6473 else
6474 vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, peer->status));
6475 }
6476
6477 vty_out (vty, "%s", VTY_NEWLINE);
6478 }
6479 }
6480
6481 if (count)
6482 vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE,
6483 count, VTY_NEWLINE);
6484 else
6485 vty_out (vty, "No %s neighbor is configured%s",
6486 afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
6487 return CMD_SUCCESS;
6488}
6489
6490int
paulfd79ac92004-10-13 05:06:08 +00006491bgp_show_summary_vty (struct vty *vty, const char *name,
6492 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00006493{
6494 struct bgp *bgp;
6495
6496 if (name)
6497 {
6498 bgp = bgp_lookup_by_name (name);
6499
6500 if (! bgp)
6501 {
6502 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
6503 return CMD_WARNING;
6504 }
6505
6506 bgp_show_summary (vty, bgp, afi, safi);
6507 return CMD_SUCCESS;
6508 }
6509
6510 bgp = bgp_get_default ();
6511
6512 if (bgp)
6513 bgp_show_summary (vty, bgp, afi, safi);
6514
6515 return CMD_SUCCESS;
6516}
6517
6518/* `show ip bgp summary' commands. */
6519DEFUN (show_ip_bgp_summary,
6520 show_ip_bgp_summary_cmd,
6521 "show ip bgp summary",
6522 SHOW_STR
6523 IP_STR
6524 BGP_STR
6525 "Summary of BGP neighbor status\n")
6526{
6527 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
6528}
6529
6530DEFUN (show_ip_bgp_instance_summary,
6531 show_ip_bgp_instance_summary_cmd,
6532 "show ip bgp view WORD summary",
6533 SHOW_STR
6534 IP_STR
6535 BGP_STR
6536 "BGP view\n"
6537 "View name\n"
6538 "Summary of BGP neighbor status\n")
6539{
6540 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
6541}
6542
6543DEFUN (show_ip_bgp_ipv4_summary,
6544 show_ip_bgp_ipv4_summary_cmd,
6545 "show ip bgp ipv4 (unicast|multicast) summary",
6546 SHOW_STR
6547 IP_STR
6548 BGP_STR
6549 "Address family\n"
6550 "Address Family modifier\n"
6551 "Address Family modifier\n"
6552 "Summary of BGP neighbor status\n")
6553{
6554 if (strncmp (argv[0], "m", 1) == 0)
6555 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST);
6556
6557 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
6558}
6559
6560DEFUN (show_ip_bgp_instance_ipv4_summary,
6561 show_ip_bgp_instance_ipv4_summary_cmd,
6562 "show ip bgp view WORD ipv4 (unicast|multicast) summary",
6563 SHOW_STR
6564 IP_STR
6565 BGP_STR
6566 "BGP view\n"
6567 "View name\n"
6568 "Address family\n"
6569 "Address Family modifier\n"
6570 "Address Family modifier\n"
6571 "Summary of BGP neighbor status\n")
6572{
6573 if (strncmp (argv[1], "m", 1) == 0)
6574 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST);
6575 else
6576 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
6577}
6578
6579DEFUN (show_ip_bgp_vpnv4_all_summary,
6580 show_ip_bgp_vpnv4_all_summary_cmd,
6581 "show ip bgp vpnv4 all summary",
6582 SHOW_STR
6583 IP_STR
6584 BGP_STR
6585 "Display VPNv4 NLRI specific information\n"
6586 "Display information about all VPNv4 NLRIs\n"
6587 "Summary of BGP neighbor status\n")
6588{
6589 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN);
6590}
6591
6592DEFUN (show_ip_bgp_vpnv4_rd_summary,
6593 show_ip_bgp_vpnv4_rd_summary_cmd,
6594 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn summary",
6595 SHOW_STR
6596 IP_STR
6597 BGP_STR
6598 "Display VPNv4 NLRI specific information\n"
6599 "Display information for a route distinguisher\n"
6600 "VPN Route Distinguisher\n"
6601 "Summary of BGP neighbor status\n")
6602{
6603 int ret;
6604 struct prefix_rd prd;
6605
6606 ret = str2prefix_rd (argv[0], &prd);
6607 if (! ret)
6608 {
6609 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
6610 return CMD_WARNING;
6611 }
6612
6613 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN);
6614}
6615
6616#ifdef HAVE_IPV6
6617DEFUN (show_bgp_summary,
6618 show_bgp_summary_cmd,
6619 "show bgp summary",
6620 SHOW_STR
6621 BGP_STR
6622 "Summary of BGP neighbor status\n")
6623{
6624 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
6625}
6626
6627DEFUN (show_bgp_instance_summary,
6628 show_bgp_instance_summary_cmd,
6629 "show bgp view WORD summary",
6630 SHOW_STR
6631 BGP_STR
6632 "BGP view\n"
6633 "View name\n"
6634 "Summary of BGP neighbor status\n")
6635{
6636 return bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
6637}
6638
6639ALIAS (show_bgp_summary,
6640 show_bgp_ipv6_summary_cmd,
6641 "show bgp ipv6 summary",
6642 SHOW_STR
6643 BGP_STR
6644 "Address family\n"
6645 "Summary of BGP neighbor status\n")
6646
6647ALIAS (show_bgp_instance_summary,
6648 show_bgp_instance_ipv6_summary_cmd,
6649 "show bgp view WORD ipv6 summary",
6650 SHOW_STR
6651 BGP_STR
6652 "BGP view\n"
6653 "View name\n"
6654 "Address family\n"
6655 "Summary of BGP neighbor status\n")
6656
6657/* old command */
6658DEFUN (show_ipv6_bgp_summary,
6659 show_ipv6_bgp_summary_cmd,
6660 "show ipv6 bgp summary",
6661 SHOW_STR
6662 IPV6_STR
6663 BGP_STR
6664 "Summary of BGP neighbor status\n")
6665{
6666 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
6667}
6668
6669/* old command */
6670DEFUN (show_ipv6_mbgp_summary,
6671 show_ipv6_mbgp_summary_cmd,
6672 "show ipv6 mbgp summary",
6673 SHOW_STR
6674 IPV6_STR
6675 MBGP_STR
6676 "Summary of BGP neighbor status\n")
6677{
6678 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST);
6679}
6680#endif /* HAVE_IPV6 */
6681
paulfd79ac92004-10-13 05:06:08 +00006682const char *
hasso538621f2004-05-21 09:31:30 +00006683afi_safi_print (afi_t afi, safi_t safi)
6684{
6685 if (afi == AFI_IP && safi == SAFI_UNICAST)
6686 return "IPv4 Unicast";
6687 else if (afi == AFI_IP && safi == SAFI_MULTICAST)
6688 return "IPv4 Multicast";
6689 else if (afi == AFI_IP && safi == SAFI_MPLS_VPN)
6690 return "VPNv4 Unicast";
6691 else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
6692 return "IPv6 Unicast";
6693 else if (afi == AFI_IP6 && safi == SAFI_MULTICAST)
6694 return "IPv6 Multicast";
6695 else
6696 return "Unknown";
6697}
6698
paul718e3742002-12-13 20:15:29 +00006699/* Show BGP peer's information. */
6700enum show_type
6701{
6702 show_all,
6703 show_peer
6704};
6705
6706void
6707bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p,
6708 afi_t afi, safi_t safi,
6709 u_int16_t adv_smcap, u_int16_t adv_rmcap,
6710 u_int16_t rcv_smcap, u_int16_t rcv_rmcap)
6711{
6712 /* Send-Mode */
6713 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)
6714 || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
6715 {
6716 vty_out (vty, " Send-mode: ");
6717 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
6718 vty_out (vty, "advertised");
6719 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
6720 vty_out (vty, "%sreceived",
6721 CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ?
6722 ", " : "");
6723 vty_out (vty, "%s", VTY_NEWLINE);
6724 }
6725
6726 /* Receive-Mode */
6727 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)
6728 || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
6729 {
6730 vty_out (vty, " Receive-mode: ");
6731 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
6732 vty_out (vty, "advertised");
6733 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
6734 vty_out (vty, "%sreceived",
6735 CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ?
6736 ", " : "");
6737 vty_out (vty, "%s", VTY_NEWLINE);
6738 }
6739}
6740
6741void
6742bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi)
6743{
6744 struct bgp_filter *filter;
6745 char orf_pfx_name[BUFSIZ];
6746 int orf_pfx_count;
6747
6748 filter = &p->filter[afi][safi];
6749
hasso538621f2004-05-21 09:31:30 +00006750 vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi),
paul718e3742002-12-13 20:15:29 +00006751 VTY_NEWLINE);
hasso538621f2004-05-21 09:31:30 +00006752
paul718e3742002-12-13 20:15:29 +00006753 if (p->af_group[afi][safi])
6754 vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE);
6755
6756 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
6757 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
6758 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
6759 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
6760 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
6761 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
6762 vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE);
6763
6764 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
6765 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
6766 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
6767 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
6768 {
6769 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
6770 ORF_TYPE_PREFIX, VTY_NEWLINE);
6771 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
6772 PEER_CAP_ORF_PREFIX_SM_ADV,
6773 PEER_CAP_ORF_PREFIX_RM_ADV,
6774 PEER_CAP_ORF_PREFIX_SM_RCV,
6775 PEER_CAP_ORF_PREFIX_RM_RCV);
6776 }
6777 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
6778 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
6779 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
6780 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
6781 {
6782 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
6783 ORF_TYPE_PREFIX_OLD, VTY_NEWLINE);
6784 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
6785 PEER_CAP_ORF_PREFIX_SM_ADV,
6786 PEER_CAP_ORF_PREFIX_RM_ADV,
6787 PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
6788 PEER_CAP_ORF_PREFIX_RM_OLD_RCV);
6789 }
6790
6791 sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
6792 orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name);
6793
6794 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
6795 || orf_pfx_count)
6796 {
6797 vty_out (vty, " Outbound Route Filter (ORF):");
6798 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
6799 vty_out (vty, " sent;");
6800 if (orf_pfx_count)
6801 vty_out (vty, " received (%d entries)", orf_pfx_count);
6802 vty_out (vty, "%s", VTY_NEWLINE);
6803 }
6804 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
6805 vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE);
6806
6807 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
6808 vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE);
6809 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
6810 vty_out (vty, " Route-Server Client%s", VTY_NEWLINE);
6811 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
6812 vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE);
6813 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
6814 vty_out (vty, " Private AS number removed from updates to this neighbor%s", VTY_NEWLINE);
6815 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF))
6816 vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE);
6817 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
6818 vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE);
6819 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
6820 vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE);
6821 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
6822 vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE);
6823 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
6824 || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
6825 {
6826 vty_out (vty, " Community attribute sent to this neighbor");
6827 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
6828 && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
hasso538621f2004-05-21 09:31:30 +00006829 vty_out (vty, "(both)%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006830 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
hasso538621f2004-05-21 09:31:30 +00006831 vty_out (vty, "(extended)%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006832 else
hasso538621f2004-05-21 09:31:30 +00006833 vty_out (vty, "(standard)%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006834 }
6835 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
6836 {
6837 vty_out (vty, " Default information originate,");
6838
6839 if (p->default_rmap[afi][safi].name)
6840 vty_out (vty, " default route-map %s%s,",
6841 p->default_rmap[afi][safi].map ? "*" : "",
6842 p->default_rmap[afi][safi].name);
6843 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
6844 vty_out (vty, " default sent%s", VTY_NEWLINE);
6845 else
6846 vty_out (vty, " default not sent%s", VTY_NEWLINE);
6847 }
6848
6849 if (filter->plist[FILTER_IN].name
6850 || filter->dlist[FILTER_IN].name
6851 || filter->aslist[FILTER_IN].name
paulfee0f4c2004-09-13 05:12:46 +00006852 || filter->map[RMAP_IN].name)
paul718e3742002-12-13 20:15:29 +00006853 vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE);
6854 if (filter->plist[FILTER_OUT].name
6855 || filter->dlist[FILTER_OUT].name
6856 || filter->aslist[FILTER_OUT].name
paulfee0f4c2004-09-13 05:12:46 +00006857 || filter->map[RMAP_OUT].name
paul718e3742002-12-13 20:15:29 +00006858 || filter->usmap.name)
6859 vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE);
paulfee0f4c2004-09-13 05:12:46 +00006860 if (filter->map[RMAP_IMPORT].name)
6861 vty_out (vty, " Import policy for this RS-client configured%s", VTY_NEWLINE);
6862 if (filter->map[RMAP_EXPORT].name)
6863 vty_out (vty, " Export policy for this RS-client configured%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006864
6865 /* prefix-list */
6866 if (filter->plist[FILTER_IN].name)
6867 vty_out (vty, " Incoming update prefix filter list is %s%s%s",
6868 filter->plist[FILTER_IN].plist ? "*" : "",
6869 filter->plist[FILTER_IN].name,
6870 VTY_NEWLINE);
6871 if (filter->plist[FILTER_OUT].name)
6872 vty_out (vty, " Outgoing update prefix filter list is %s%s%s",
6873 filter->plist[FILTER_OUT].plist ? "*" : "",
6874 filter->plist[FILTER_OUT].name,
6875 VTY_NEWLINE);
6876
6877 /* distribute-list */
6878 if (filter->dlist[FILTER_IN].name)
6879 vty_out (vty, " Incoming update network filter list is %s%s%s",
6880 filter->dlist[FILTER_IN].alist ? "*" : "",
6881 filter->dlist[FILTER_IN].name,
6882 VTY_NEWLINE);
6883 if (filter->dlist[FILTER_OUT].name)
6884 vty_out (vty, " Outgoing update network filter list is %s%s%s",
6885 filter->dlist[FILTER_OUT].alist ? "*" : "",
6886 filter->dlist[FILTER_OUT].name,
6887 VTY_NEWLINE);
6888
6889 /* filter-list. */
6890 if (filter->aslist[FILTER_IN].name)
6891 vty_out (vty, " Incoming update AS path filter list is %s%s%s",
6892 filter->aslist[FILTER_IN].aslist ? "*" : "",
6893 filter->aslist[FILTER_IN].name,
6894 VTY_NEWLINE);
6895 if (filter->aslist[FILTER_OUT].name)
6896 vty_out (vty, " Outgoing update AS path filter list is %s%s%s",
6897 filter->aslist[FILTER_OUT].aslist ? "*" : "",
6898 filter->aslist[FILTER_OUT].name,
6899 VTY_NEWLINE);
6900
6901 /* route-map. */
paulfee0f4c2004-09-13 05:12:46 +00006902 if (filter->map[RMAP_IN].name)
paul718e3742002-12-13 20:15:29 +00006903 vty_out (vty, " Route map for incoming advertisements is %s%s%s",
paulfee0f4c2004-09-13 05:12:46 +00006904 filter->map[RMAP_IN].map ? "*" : "",
6905 filter->map[RMAP_IN].name,
paul718e3742002-12-13 20:15:29 +00006906 VTY_NEWLINE);
paulfee0f4c2004-09-13 05:12:46 +00006907 if (filter->map[RMAP_OUT].name)
paul718e3742002-12-13 20:15:29 +00006908 vty_out (vty, " Route map for outgoing advertisements is %s%s%s",
paulfee0f4c2004-09-13 05:12:46 +00006909 filter->map[RMAP_OUT].map ? "*" : "",
6910 filter->map[RMAP_OUT].name,
6911 VTY_NEWLINE);
6912 if (filter->map[RMAP_IMPORT].name)
6913 vty_out (vty, " Route map for advertisements going into this RS-client's table is %s%s%s",
6914 filter->map[RMAP_IMPORT].map ? "*" : "",
6915 filter->map[RMAP_IMPORT].name,
6916 VTY_NEWLINE);
6917 if (filter->map[RMAP_EXPORT].name)
6918 vty_out (vty, " Route map for advertisements coming from this RS-client is %s%s%s",
6919 filter->map[RMAP_EXPORT].map ? "*" : "",
6920 filter->map[RMAP_EXPORT].name,
paul718e3742002-12-13 20:15:29 +00006921 VTY_NEWLINE);
6922
6923 /* unsuppress-map */
6924 if (filter->usmap.name)
6925 vty_out (vty, " Route map for selective unsuppress is %s%s%s",
6926 filter->usmap.map ? "*" : "",
6927 filter->usmap.name, VTY_NEWLINE);
6928
6929 /* Receive prefix count */
hassoe0701b72004-05-20 09:19:34 +00006930 vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE);
6931
paul718e3742002-12-13 20:15:29 +00006932 /* Maximum prefix */
6933 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
6934 {
hasso0a486e52005-02-01 20:57:17 +00006935 vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi],
paul718e3742002-12-13 20:15:29 +00006936 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)
hasso0a486e52005-02-01 20:57:17 +00006937 ? " (warning-only)" : "", VTY_NEWLINE);
6938 vty_out (vty, " Threshold for warning message %d%%",
6939 p->pmax_threshold[afi][safi]);
6940 if (p->pmax_restart[afi][safi])
6941 vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]);
6942 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006943 }
paul718e3742002-12-13 20:15:29 +00006944
6945 vty_out (vty, "%s", VTY_NEWLINE);
6946}
6947
6948void
6949bgp_show_peer (struct vty *vty, struct peer *p)
6950{
6951 struct bgp *bgp;
6952 char buf1[BUFSIZ];
6953 char timebuf[BGP_UPTIME_LEN];
hasso538621f2004-05-21 09:31:30 +00006954 afi_t afi;
6955 safi_t safi;
paul718e3742002-12-13 20:15:29 +00006956
6957 bgp = p->bgp;
6958
6959 /* Configured IP address. */
6960 vty_out (vty, "BGP neighbor is %s, ", p->host);
6961 vty_out (vty, "remote AS %d, ", p->as);
6962 vty_out (vty, "local AS %d%s, ",
6963 p->change_local_as ? p->change_local_as : p->local_as,
6964 CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ?
6965 " no-prepend" : "");
6966 vty_out (vty, "%s link%s",
6967 p->as == p->local_as ? "internal" : "external",
6968 VTY_NEWLINE);
6969
6970 /* Description. */
6971 if (p->desc)
6972 vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE);
6973
6974 /* Peer-group */
6975 if (p->group)
6976 vty_out (vty, " Member of peer-group %s for session parameters%s",
6977 p->group->name, VTY_NEWLINE);
6978
6979 /* Administrative shutdown. */
6980 if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
6981 vty_out (vty, " Administratively shut down%s", VTY_NEWLINE);
6982
6983 /* BGP Version. */
6984 vty_out (vty, " BGP version 4");
6985 if (p->version == BGP_VERSION_MP_4_DRAFT_00)
6986 vty_out (vty, "(with draft-00 verion of multiporotocol extension)");
6987 vty_out (vty, ", remote router ID %s%s",
6988 inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ),
6989 VTY_NEWLINE);
6990
6991 /* Confederation */
hassoe0701b72004-05-20 09:19:34 +00006992 if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION)
6993 && bgp_confederation_peers_check (bgp, p->as))
paul718e3742002-12-13 20:15:29 +00006994 vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE);
6995
6996 /* Status. */
6997 vty_out (vty, " BGP state = %s",
6998 LOOKUP (bgp_status_msg, p->status));
6999 if (p->status == Established)
7000 vty_out (vty, ", up for %8s",
7001 peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN));
7002 vty_out (vty, "%s", VTY_NEWLINE);
7003
7004 /* read timer */
7005 vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN));
7006
7007 /* Configured timer values. */
7008 vty_out (vty, ", hold time is %d, keepalive interval is %d seconds%s",
7009 p->v_holdtime, p->v_keepalive, VTY_NEWLINE);
7010 if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
7011 {
7012 vty_out (vty, " Configured hold time is %d", p->holdtime);
7013 vty_out (vty, ", keepalive interval is %d seconds%s",
7014 p->keepalive, VTY_NEWLINE);
7015 }
7016
7017 /* Capability. */
7018 if (p->status == Established)
7019 {
hasso538621f2004-05-21 09:31:30 +00007020 if (p->cap
paul718e3742002-12-13 20:15:29 +00007021 || p->afc_adv[AFI_IP][SAFI_UNICAST]
7022 || p->afc_recv[AFI_IP][SAFI_UNICAST]
7023 || p->afc_adv[AFI_IP][SAFI_MULTICAST]
7024 || p->afc_recv[AFI_IP][SAFI_MULTICAST]
7025#ifdef HAVE_IPV6
7026 || p->afc_adv[AFI_IP6][SAFI_UNICAST]
7027 || p->afc_recv[AFI_IP6][SAFI_UNICAST]
7028 || p->afc_adv[AFI_IP6][SAFI_MULTICAST]
7029 || p->afc_recv[AFI_IP6][SAFI_MULTICAST]
7030#endif /* HAVE_IPV6 */
7031 || p->afc_adv[AFI_IP][SAFI_MPLS_VPN]
7032 || p->afc_recv[AFI_IP][SAFI_MPLS_VPN])
7033 {
7034 vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE);
7035
7036 /* Dynamic */
7037 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
7038 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
7039 {
7040 vty_out (vty, " Dynamic:");
7041 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
7042 vty_out (vty, " advertised");
7043 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
hasso538621f2004-05-21 09:31:30 +00007044 vty_out (vty, " %sreceived",
7045 CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : "");
paul718e3742002-12-13 20:15:29 +00007046 vty_out (vty, "%s", VTY_NEWLINE);
7047 }
7048
7049 /* Route Refresh */
7050 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
7051 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
7052 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
7053 {
7054 vty_out (vty, " Route refresh:");
7055 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
7056 vty_out (vty, " advertised");
7057 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
7058 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
hasso538621f2004-05-21 09:31:30 +00007059 vty_out (vty, " %sreceived(%s)",
7060 CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "",
7061 (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)
7062 && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ?
7063 "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new");
7064
paul718e3742002-12-13 20:15:29 +00007065 vty_out (vty, "%s", VTY_NEWLINE);
7066 }
7067
hasso538621f2004-05-21 09:31:30 +00007068 /* Multiprotocol Extensions */
7069 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7070 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7071 if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
paul718e3742002-12-13 20:15:29 +00007072 {
hasso538621f2004-05-21 09:31:30 +00007073 vty_out (vty, " Address family %s:", afi_safi_print (afi, safi));
7074 if (p->afc_adv[afi][safi])
7075 vty_out (vty, " advertised");
7076 if (p->afc_recv[afi][safi])
7077 vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : "");
7078 vty_out (vty, "%s", VTY_NEWLINE);
7079 }
7080
7081 /* Gracefull Restart */
7082 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
7083 || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
paul718e3742002-12-13 20:15:29 +00007084 {
hasso538621f2004-05-21 09:31:30 +00007085 vty_out (vty, " Graceful Restart Capabilty:");
7086 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
paul718e3742002-12-13 20:15:29 +00007087 vty_out (vty, " advertised");
hasso538621f2004-05-21 09:31:30 +00007088 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
7089 vty_out (vty, " %sreceived",
7090 CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : "");
paul718e3742002-12-13 20:15:29 +00007091 vty_out (vty, "%s", VTY_NEWLINE);
hasso538621f2004-05-21 09:31:30 +00007092
7093 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
paul718e3742002-12-13 20:15:29 +00007094 {
hasso538621f2004-05-21 09:31:30 +00007095 int restart_af_count = 0;
7096
7097 vty_out (vty, " Remote Restart timer is %d seconds%s",
7098 p->restart_time_rcv, VTY_NEWLINE);
7099 vty_out (vty, " Address families preserved by peer:%s ", VTY_NEWLINE);
7100
7101 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7102 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7103 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
7104 {
7105 vty_out (vty, "%s%s", restart_af_count ? ", " : "",
7106 afi_safi_print (afi, safi));
7107 restart_af_count++;
7108 }
7109 if (! restart_af_count)
7110 vty_out (vty, "none");
7111 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007112 }
paul718e3742002-12-13 20:15:29 +00007113 }
paul718e3742002-12-13 20:15:29 +00007114 }
7115 }
7116
7117 /* Packet counts. */
7118 vty_out(vty, " Received %d messages, %d notifications, %d in queue%s",
7119 p->open_in + p->update_in + p->keepalive_in + p->refresh_in
7120 + p->dynamic_cap_in, p->notify_in, 0, VTY_NEWLINE);
7121 vty_out(vty, " Sent %d messages, %d notifications, %ld in queue%s",
7122 p->open_out + p->update_out + p->keepalive_out + p->refresh_out
7123 + p->dynamic_cap_out, p->notify_out, p->obuf->count, VTY_NEWLINE);
7124 vty_out(vty, " Route refresh request: received %d, sent %d%s",
7125 p->refresh_in, p->refresh_out, VTY_NEWLINE);
7126
7127 /* advertisement-interval */
7128 vty_out (vty, " Minimum time between advertisement runs is %d seconds%s",
7129 p->v_routeadv, VTY_NEWLINE);
7130
7131 /* Update-source. */
7132 if (p->update_if || p->update_source)
7133 {
7134 vty_out (vty, " Update source is ");
7135 if (p->update_if)
7136 vty_out (vty, "%s", p->update_if);
7137 else if (p->update_source)
7138 vty_out (vty, "%s",
7139 sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
7140 vty_out (vty, "%s", VTY_NEWLINE);
7141 }
7142
7143 /* Default weight */
7144 if (CHECK_FLAG (p->config, PEER_CONFIG_WEIGHT))
7145 vty_out (vty, " Default weight %d%s", p->weight,
7146 VTY_NEWLINE);
7147
7148 vty_out (vty, "%s", VTY_NEWLINE);
7149
7150 /* Address Family Information */
hasso538621f2004-05-21 09:31:30 +00007151 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7152 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7153 if (p->afc[afi][safi])
7154 bgp_show_peer_afi (vty, p, afi, safi);
paul718e3742002-12-13 20:15:29 +00007155
7156 vty_out (vty, " Connections established %d; dropped %d%s",
7157 p->established, p->dropped,
7158 VTY_NEWLINE);
7159
hassoe0701b72004-05-20 09:19:34 +00007160 if (! p->dropped)
7161 vty_out (vty, " Last reset never%s", VTY_NEWLINE);
7162 else
7163 vty_out (vty, " Last reset %s, due to %s%s",
7164 peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN),
7165 peer_down_str[(int) p->last_reset], VTY_NEWLINE);
paul848973c2003-08-13 00:32:49 +00007166
paul718e3742002-12-13 20:15:29 +00007167 if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW))
7168 {
7169 vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE);
hasso0a486e52005-02-01 20:57:17 +00007170
7171 if (p->t_pmax_restart)
7172 vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s",
7173 p->host, thread_timer_remain_second (p->t_pmax_restart),
7174 VTY_NEWLINE);
7175 else
7176 vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s",
7177 p->host, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007178 }
7179
7180 /* EBGP Multihop */
7181 if (peer_sort (p) != BGP_PEER_IBGP && p->ttl > 1)
7182 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
7183 p->ttl, VTY_NEWLINE);
7184
7185 /* Local address. */
7186 if (p->su_local)
7187 {
7188 vty_out (vty, "Local host: %s, Local port: %d%s%s",
7189 sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN),
7190 ntohs (p->su_local->sin.sin_port),
7191 CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE) ?
7192 ", passive-mode" : "",
7193 VTY_NEWLINE);
7194 }
7195
7196 /* Remote address. */
7197 if (p->su_remote)
7198 {
7199 vty_out (vty, "Foreign host: %s, Foreign port: %d%s",
7200 sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN),
7201 ntohs (p->su_remote->sin.sin_port),
7202 VTY_NEWLINE);
7203 }
7204
7205 /* Nexthop display. */
7206 if (p->su_local)
7207 {
7208 vty_out (vty, "Nexthop: %s%s",
7209 inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ),
7210 VTY_NEWLINE);
7211#ifdef HAVE_IPV6
7212 vty_out (vty, "Nexthop global: %s%s",
7213 inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ),
7214 VTY_NEWLINE);
7215 vty_out (vty, "Nexthop local: %s%s",
7216 inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ),
7217 VTY_NEWLINE);
7218 vty_out (vty, "BGP connection: %s%s",
7219 p->shared_network ? "shared network" : "non shared network",
7220 VTY_NEWLINE);
7221#endif /* HAVE_IPV6 */
7222 }
7223
7224 /* Timer information. */
7225 if (p->t_start)
7226 vty_out (vty, "Next start timer due in %ld seconds%s",
7227 thread_timer_remain_second (p->t_start), VTY_NEWLINE);
7228 if (p->t_connect)
7229 vty_out (vty, "Next connect timer due in %ld seconds%s",
7230 thread_timer_remain_second (p->t_connect), VTY_NEWLINE);
7231
7232 vty_out (vty, "Read thread: %s Write thread: %s%s",
7233 p->t_read ? "on" : "off",
7234 p->t_write ? "on" : "off",
7235 VTY_NEWLINE);
7236
7237 if (p->notify.code == BGP_NOTIFY_OPEN_ERR
7238 && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL)
7239 bgp_capability_vty_out (vty, p);
7240
7241 vty_out (vty, "%s", VTY_NEWLINE);
7242}
7243
7244int
7245bgp_show_neighbor (struct vty *vty, struct bgp *bgp,
7246 enum show_type type, union sockunion *su)
7247{
7248 struct listnode *nn;
7249 struct peer *peer;
7250 int find = 0;
7251
7252 LIST_LOOP (bgp->peer, peer, nn)
7253 {
7254 switch (type)
7255 {
7256 case show_all:
7257 bgp_show_peer (vty, peer);
7258 break;
7259 case show_peer:
7260 if (sockunion_same (&peer->su, su))
7261 {
7262 find = 1;
7263 bgp_show_peer (vty, peer);
7264 }
7265 break;
7266 }
7267 }
7268
7269 if (type == show_peer && ! find)
7270 vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE);
7271
7272 return CMD_SUCCESS;
7273}
7274
7275int
paulfd79ac92004-10-13 05:06:08 +00007276bgp_show_neighbor_vty (struct vty *vty, const char *name,
7277 enum show_type type, const char *ip_str)
paul718e3742002-12-13 20:15:29 +00007278{
7279 int ret;
7280 struct bgp *bgp;
7281 union sockunion su;
7282
7283 if (ip_str)
7284 {
7285 ret = str2sockunion (ip_str, &su);
7286 if (ret < 0)
7287 {
7288 vty_out (vty, "%% Malformed address: %s%s", ip_str, VTY_NEWLINE);
7289 return CMD_WARNING;
7290 }
7291 }
7292
7293 if (name)
7294 {
7295 bgp = bgp_lookup_by_name (name);
7296
7297 if (! bgp)
7298 {
7299 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
7300 return CMD_WARNING;
7301 }
7302
7303 bgp_show_neighbor (vty, bgp, type, &su);
7304
7305 return CMD_SUCCESS;
7306 }
7307
7308 bgp = bgp_get_default ();
7309
7310 if (bgp)
7311 bgp_show_neighbor (vty, bgp, type, &su);
7312
7313 return CMD_SUCCESS;
7314}
7315
7316/* "show ip bgp neighbors" commands. */
7317DEFUN (show_ip_bgp_neighbors,
7318 show_ip_bgp_neighbors_cmd,
7319 "show ip bgp neighbors",
7320 SHOW_STR
7321 IP_STR
7322 BGP_STR
7323 "Detailed information on TCP and BGP neighbor connections\n")
7324{
7325 return bgp_show_neighbor_vty (vty, NULL, show_all, NULL);
7326}
7327
7328ALIAS (show_ip_bgp_neighbors,
7329 show_ip_bgp_ipv4_neighbors_cmd,
7330 "show ip bgp ipv4 (unicast|multicast) neighbors",
7331 SHOW_STR
7332 IP_STR
7333 BGP_STR
7334 "Address family\n"
7335 "Address Family modifier\n"
7336 "Address Family modifier\n"
7337 "Detailed information on TCP and BGP neighbor connections\n")
7338
7339ALIAS (show_ip_bgp_neighbors,
7340 show_ip_bgp_vpnv4_all_neighbors_cmd,
7341 "show ip bgp vpnv4 all neighbors",
7342 SHOW_STR
7343 IP_STR
7344 BGP_STR
7345 "Display VPNv4 NLRI specific information\n"
7346 "Display information about all VPNv4 NLRIs\n"
7347 "Detailed information on TCP and BGP neighbor connections\n")
7348
7349ALIAS (show_ip_bgp_neighbors,
7350 show_ip_bgp_vpnv4_rd_neighbors_cmd,
7351 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors",
7352 SHOW_STR
7353 IP_STR
7354 BGP_STR
7355 "Display VPNv4 NLRI specific information\n"
7356 "Display information for a route distinguisher\n"
7357 "VPN Route Distinguisher\n"
7358 "Detailed information on TCP and BGP neighbor connections\n")
7359
7360ALIAS (show_ip_bgp_neighbors,
7361 show_bgp_neighbors_cmd,
7362 "show bgp neighbors",
7363 SHOW_STR
7364 BGP_STR
7365 "Detailed information on TCP and BGP neighbor connections\n")
7366
7367ALIAS (show_ip_bgp_neighbors,
7368 show_bgp_ipv6_neighbors_cmd,
7369 "show bgp ipv6 neighbors",
7370 SHOW_STR
7371 BGP_STR
7372 "Address family\n"
7373 "Detailed information on TCP and BGP neighbor connections\n")
7374
7375DEFUN (show_ip_bgp_neighbors_peer,
7376 show_ip_bgp_neighbors_peer_cmd,
7377 "show ip bgp neighbors (A.B.C.D|X:X::X:X)",
7378 SHOW_STR
7379 IP_STR
7380 BGP_STR
7381 "Detailed information on TCP and BGP neighbor connections\n"
7382 "Neighbor to display information about\n"
7383 "Neighbor to display information about\n")
7384{
7385 return bgp_show_neighbor_vty (vty, NULL, show_peer, argv[argc - 1]);
7386}
7387
7388ALIAS (show_ip_bgp_neighbors_peer,
7389 show_ip_bgp_ipv4_neighbors_peer_cmd,
7390 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X)",
7391 SHOW_STR
7392 IP_STR
7393 BGP_STR
7394 "Address family\n"
7395 "Address Family modifier\n"
7396 "Address Family modifier\n"
7397 "Detailed information on TCP and BGP neighbor connections\n"
7398 "Neighbor to display information about\n"
7399 "Neighbor to display information about\n")
7400
7401ALIAS (show_ip_bgp_neighbors_peer,
7402 show_ip_bgp_vpnv4_all_neighbors_peer_cmd,
7403 "show ip bgp vpnv4 all neighbors A.B.C.D",
7404 SHOW_STR
7405 IP_STR
7406 BGP_STR
7407 "Display VPNv4 NLRI specific information\n"
7408 "Display information about all VPNv4 NLRIs\n"
7409 "Detailed information on TCP and BGP neighbor connections\n"
7410 "Neighbor to display information about\n")
7411
7412ALIAS (show_ip_bgp_neighbors_peer,
7413 show_ip_bgp_vpnv4_rd_neighbors_peer_cmd,
7414 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D",
7415 SHOW_STR
7416 IP_STR
7417 BGP_STR
7418 "Display VPNv4 NLRI specific information\n"
7419 "Display information about all VPNv4 NLRIs\n"
7420 "Detailed information on TCP and BGP neighbor connections\n"
7421 "Neighbor to display information about\n")
7422
7423ALIAS (show_ip_bgp_neighbors_peer,
7424 show_bgp_neighbors_peer_cmd,
7425 "show bgp neighbors (A.B.C.D|X:X::X:X)",
7426 SHOW_STR
7427 BGP_STR
7428 "Detailed information on TCP and BGP neighbor connections\n"
7429 "Neighbor to display information about\n"
7430 "Neighbor to display information about\n")
7431
7432ALIAS (show_ip_bgp_neighbors_peer,
7433 show_bgp_ipv6_neighbors_peer_cmd,
7434 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X)",
7435 SHOW_STR
7436 BGP_STR
7437 "Address family\n"
7438 "Detailed information on TCP and BGP neighbor connections\n"
7439 "Neighbor to display information about\n"
7440 "Neighbor to display information about\n")
7441
7442DEFUN (show_ip_bgp_instance_neighbors,
7443 show_ip_bgp_instance_neighbors_cmd,
7444 "show ip bgp view WORD neighbors",
7445 SHOW_STR
7446 IP_STR
7447 BGP_STR
7448 "BGP view\n"
7449 "View name\n"
7450 "Detailed information on TCP and BGP neighbor connections\n")
7451{
7452 return bgp_show_neighbor_vty (vty, argv[0], show_all, NULL);
7453}
7454
paulbb46e942003-10-24 19:02:03 +00007455ALIAS (show_ip_bgp_instance_neighbors,
7456 show_bgp_instance_neighbors_cmd,
7457 "show bgp view WORD neighbors",
7458 SHOW_STR
7459 BGP_STR
7460 "BGP view\n"
7461 "View name\n"
7462 "Detailed information on TCP and BGP neighbor connections\n")
7463
7464ALIAS (show_ip_bgp_instance_neighbors,
7465 show_bgp_instance_ipv6_neighbors_cmd,
7466 "show bgp view WORD ipv6 neighbors",
7467 SHOW_STR
7468 BGP_STR
7469 "BGP view\n"
7470 "View name\n"
7471 "Address family\n"
7472 "Detailed information on TCP and BGP neighbor connections\n")
7473
paul718e3742002-12-13 20:15:29 +00007474DEFUN (show_ip_bgp_instance_neighbors_peer,
7475 show_ip_bgp_instance_neighbors_peer_cmd,
7476 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X)",
7477 SHOW_STR
7478 IP_STR
7479 BGP_STR
7480 "BGP view\n"
7481 "View name\n"
7482 "Detailed information on TCP and BGP neighbor connections\n"
7483 "Neighbor to display information about\n"
7484 "Neighbor to display information about\n")
7485{
7486 return bgp_show_neighbor_vty (vty, argv[0], show_peer, argv[1]);
7487}
paulbb46e942003-10-24 19:02:03 +00007488
7489ALIAS (show_ip_bgp_instance_neighbors_peer,
7490 show_bgp_instance_neighbors_peer_cmd,
7491 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X)",
7492 SHOW_STR
7493 BGP_STR
7494 "BGP view\n"
7495 "View name\n"
7496 "Detailed information on TCP and BGP neighbor connections\n"
7497 "Neighbor to display information about\n"
7498 "Neighbor to display information about\n")
7499
7500ALIAS (show_ip_bgp_instance_neighbors_peer,
7501 show_bgp_instance_ipv6_neighbors_peer_cmd,
7502 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X)",
7503 SHOW_STR
7504 BGP_STR
7505 "BGP view\n"
7506 "View name\n"
7507 "Address family\n"
7508 "Detailed information on TCP and BGP neighbor connections\n"
7509 "Neighbor to display information about\n"
7510 "Neighbor to display information about\n")
7511
paul718e3742002-12-13 20:15:29 +00007512/* Show BGP's AS paths internal data. There are both `show ip bgp
7513 paths' and `show ip mbgp paths'. Those functions results are the
7514 same.*/
7515DEFUN (show_ip_bgp_paths,
7516 show_ip_bgp_paths_cmd,
7517 "show ip bgp paths",
7518 SHOW_STR
7519 IP_STR
7520 BGP_STR
7521 "Path information\n")
7522{
7523 vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE);
7524 aspath_print_all_vty (vty);
7525 return CMD_SUCCESS;
7526}
7527
7528DEFUN (show_ip_bgp_ipv4_paths,
7529 show_ip_bgp_ipv4_paths_cmd,
7530 "show ip bgp ipv4 (unicast|multicast) paths",
7531 SHOW_STR
7532 IP_STR
7533 BGP_STR
7534 "Address family\n"
7535 "Address Family modifier\n"
7536 "Address Family modifier\n"
7537 "Path information\n")
7538{
7539 vty_out (vty, "Address Refcnt Path\r\n");
7540 aspath_print_all_vty (vty);
7541
7542 return CMD_SUCCESS;
7543}
7544
7545#include "hash.h"
7546
7547void
7548community_show_all_iterator (struct hash_backet *backet, struct vty *vty)
7549{
7550 struct community *com;
7551
7552 com = (struct community *) backet->data;
7553 vty_out (vty, "[%p] (%ld) %s%s", backet, com->refcnt,
7554 community_str (com), VTY_NEWLINE);
7555}
7556
7557/* Show BGP's community internal data. */
7558DEFUN (show_ip_bgp_community_info,
7559 show_ip_bgp_community_info_cmd,
7560 "show ip bgp community-info",
7561 SHOW_STR
7562 IP_STR
7563 BGP_STR
7564 "List all bgp community information\n")
7565{
7566 vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE);
7567
7568 hash_iterate (community_hash (),
7569 (void (*) (struct hash_backet *, void *))
7570 community_show_all_iterator,
7571 vty);
7572
7573 return CMD_SUCCESS;
7574}
7575
7576DEFUN (show_ip_bgp_attr_info,
7577 show_ip_bgp_attr_info_cmd,
7578 "show ip bgp attribute-info",
7579 SHOW_STR
7580 IP_STR
7581 BGP_STR
7582 "List all bgp attribute information\n")
7583{
7584 attr_show_all (vty);
7585 return CMD_SUCCESS;
7586}
7587
paulfee0f4c2004-09-13 05:12:46 +00007588int
7589bgp_write_rsclient_summary (struct vty *vty, struct peer *rsclient,
7590 afi_t afi, safi_t safi)
7591{
7592 char timebuf[BGP_UPTIME_LEN];
7593 char rmbuf[14];
paulfd79ac92004-10-13 05:06:08 +00007594 const char *rmname;
paulfee0f4c2004-09-13 05:12:46 +00007595 struct peer *peer;
7596 struct listnode *nn;
7597 int len;
7598 int count = 0;
7599
7600 if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP))
7601 {
7602 LIST_LOOP (rsclient->group->peer, peer, nn)
7603 {
7604 count++;
7605 bgp_write_rsclient_summary (vty, peer, afi, safi);
7606 }
7607 return count;
7608 }
7609
7610 len = vty_out (vty, "%s", rsclient->host);
7611 len = 16 - len;
7612
7613 if (len < 1)
7614 vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
7615 else
7616 vty_out (vty, "%*s", len, " ");
7617
7618 switch (rsclient->version)
7619 {
7620 case BGP_VERSION_4:
7621 vty_out (vty, "4 ");
7622 break;
7623 case BGP_VERSION_MP_4_DRAFT_00:
7624 vty_out (vty, "4-");
7625 break;
7626 }
7627
7628 vty_out (vty, "%5d ", rsclient->as);
7629
7630 rmname = ROUTE_MAP_EXPORT_NAME(&rsclient->filter[afi][safi]);
7631 if ( rmname && strlen (rmname) > 13 )
7632 {
7633 sprintf (rmbuf, "%13s", "...");
7634 rmname = strncpy (rmbuf, rmname, 10);
7635 }
7636 else if (! rmname)
7637 rmname = "<none>";
7638 vty_out (vty, " %13s ", rmname);
7639
7640 rmname = ROUTE_MAP_IMPORT_NAME(&rsclient->filter[afi][safi]);
7641 if ( rmname && strlen (rmname) > 13 )
7642 {
7643 sprintf (rmbuf, "%13s", "...");
7644 rmname = strncpy (rmbuf, rmname, 10);
7645 }
7646 else if (! rmname)
7647 rmname = "<none>";
7648 vty_out (vty, " %13s ", rmname);
7649
7650 vty_out (vty, "%8s", peer_uptime (rsclient->uptime, timebuf, BGP_UPTIME_LEN));
7651
7652 if (CHECK_FLAG (rsclient->flags, PEER_FLAG_SHUTDOWN))
7653 vty_out (vty, " Idle (Admin)");
7654 else if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_PREFIX_OVERFLOW))
7655 vty_out (vty, " Idle (PfxCt)");
7656 else
7657 vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, rsclient->status));
7658
7659 vty_out (vty, "%s", VTY_NEWLINE);
7660
7661 return 1;
7662}
7663
7664int
paulfd79ac92004-10-13 05:06:08 +00007665bgp_show_rsclient_summary (struct vty *vty, struct bgp *bgp,
7666 afi_t afi, safi_t safi)
paulfee0f4c2004-09-13 05:12:46 +00007667{
7668 struct peer *peer;
7669 struct listnode *nn;
7670 int count = 0;
7671
7672 /* Header string for each address family. */
7673 static char header[] = "Neighbor V AS Export-Policy Import-Policy Up/Down State";
7674
7675 LIST_LOOP (bgp->rsclient, peer, nn)
7676 {
7677 if (peer->afc[afi][safi] &&
7678 CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
7679 {
7680 if (! count)
7681 {
7682 vty_out (vty,
7683 "Route Server's BGP router identifier %s%s",
7684 inet_ntoa (bgp->router_id), VTY_NEWLINE);
7685 vty_out (vty,
7686 "Route Server's local AS number %d%s", bgp->as,
7687 VTY_NEWLINE);
7688
7689 vty_out (vty, "%s", VTY_NEWLINE);
7690 vty_out (vty, "%s%s", header, VTY_NEWLINE);
7691 }
7692
7693 count += bgp_write_rsclient_summary (vty, peer, afi, safi);
7694 }
7695 }
7696
7697 if (count)
7698 vty_out (vty, "%sTotal number of Route Server Clients %d%s", VTY_NEWLINE,
7699 count, VTY_NEWLINE);
7700 else
7701 vty_out (vty, "No %s Route Server Client is configured%s",
7702 afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
7703
7704 return CMD_SUCCESS;
7705}
7706
7707int
paulfd79ac92004-10-13 05:06:08 +00007708bgp_show_rsclient_summary_vty (struct vty *vty, const char *name,
7709 afi_t afi, safi_t safi)
paulfee0f4c2004-09-13 05:12:46 +00007710{
7711 struct bgp *bgp;
7712
7713 if (name)
7714 {
7715 bgp = bgp_lookup_by_name (name);
7716
7717 if (! bgp)
7718 {
7719 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
7720 return CMD_WARNING;
7721 }
7722
7723 bgp_show_rsclient_summary (vty, bgp, afi, safi);
7724 return CMD_SUCCESS;
7725 }
7726
7727 bgp = bgp_get_default ();
7728
7729 if (bgp)
7730 bgp_show_rsclient_summary (vty, bgp, afi, safi);
7731
7732 return CMD_SUCCESS;
7733}
7734
7735/* 'show bgp rsclient' commands. */
7736DEFUN (show_ip_bgp_rsclient_summary,
7737 show_ip_bgp_rsclient_summary_cmd,
7738 "show ip bgp rsclient summary",
7739 SHOW_STR
7740 IP_STR
7741 BGP_STR
7742 "Information about Route Server Clients\n"
7743 "Summary of all Route Server Clients\n")
7744{
7745 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
7746}
7747
7748DEFUN (show_ip_bgp_instance_rsclient_summary,
7749 show_ip_bgp_instance_rsclient_summary_cmd,
7750 "show ip bgp view WORD rsclient summary",
7751 SHOW_STR
7752 IP_STR
7753 BGP_STR
7754 "BGP view\n"
7755 "View name\n"
7756 "Information about Route Server Clients\n"
7757 "Summary of all Route Server Clients\n")
7758{
7759 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
7760}
7761
7762DEFUN (show_ip_bgp_ipv4_rsclient_summary,
7763 show_ip_bgp_ipv4_rsclient_summary_cmd,
7764 "show ip bgp ipv4 (unicast|multicast) rsclient summary",
7765 SHOW_STR
7766 IP_STR
7767 BGP_STR
7768 "Address family\n"
7769 "Address Family modifier\n"
7770 "Address Family modifier\n"
7771 "Information about Route Server Clients\n"
7772 "Summary of all Route Server Clients\n")
7773{
7774 if (strncmp (argv[0], "m", 1) == 0)
7775 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST);
7776
7777 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
7778}
7779
7780DEFUN (show_ip_bgp_instance_ipv4_rsclient_summary,
7781 show_ip_bgp_instance_ipv4_rsclient_summary_cmd,
7782 "show ip bgp view WORD ipv4 (unicast|multicast) rsclient summary",
7783 SHOW_STR
7784 IP_STR
7785 BGP_STR
7786 "BGP view\n"
7787 "View name\n"
7788 "Address family\n"
7789 "Address Family modifier\n"
7790 "Address Family modifier\n"
7791 "Information about Route Server Clients\n"
7792 "Summary of all Route Server Clients\n")
7793{
7794 if (strncmp (argv[1], "m", 1) == 0)
7795 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST);
7796
7797 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
7798}
7799
7800#ifdef HAVE_IPV6
7801DEFUN (show_bgp_rsclient_summary,
7802 show_bgp_rsclient_summary_cmd,
7803 "show bgp rsclient summary",
7804 SHOW_STR
7805 BGP_STR
7806 "Information about Route Server Clients\n"
7807 "Summary of all Route Server Clients\n")
7808{
7809 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
7810}
7811
7812DEFUN (show_bgp_instance_rsclient_summary,
7813 show_bgp_instance_rsclient_summary_cmd,
7814 "show bgp view WORD rsclient summary",
7815 SHOW_STR
7816 BGP_STR
7817 "BGP view\n"
7818 "View name\n"
7819 "Information about Route Server Clients\n"
7820 "Summary of all Route Server Clients\n")
7821{
7822 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
7823}
7824
7825ALIAS (show_bgp_rsclient_summary,
7826 show_bgp_ipv6_rsclient_summary_cmd,
7827 "show bgp ipv6 rsclient summary",
7828 SHOW_STR
7829 BGP_STR
7830 "Address family\n"
7831 "Information about Route Server Clients\n"
7832 "Summary of all Route Server Clients\n")
7833
7834ALIAS (show_bgp_instance_rsclient_summary,
7835 show_bgp_instance_ipv6_rsclient_summary_cmd,
7836 "show bgp view WORD ipv6 rsclient summary",
7837 SHOW_STR
7838 BGP_STR
7839 "BGP view\n"
7840 "View name\n"
7841 "Address family\n"
7842 "Information about Route Server Clients\n"
7843 "Summary of all Route Server Clients\n")
7844#endif /* HAVE IPV6 */
7845
paul718e3742002-12-13 20:15:29 +00007846/* Redistribute VTY commands. */
7847
7848/* Utility function to convert user input route type string to route
7849 type. */
7850static int
paulfd79ac92004-10-13 05:06:08 +00007851bgp_str2route_type (int afi, const char *str)
paul718e3742002-12-13 20:15:29 +00007852{
7853 if (! str)
7854 return 0;
7855
7856 if (afi == AFI_IP)
7857 {
7858 if (strncmp (str, "k", 1) == 0)
7859 return ZEBRA_ROUTE_KERNEL;
7860 else if (strncmp (str, "c", 1) == 0)
7861 return ZEBRA_ROUTE_CONNECT;
7862 else if (strncmp (str, "s", 1) == 0)
7863 return ZEBRA_ROUTE_STATIC;
7864 else if (strncmp (str, "r", 1) == 0)
7865 return ZEBRA_ROUTE_RIP;
7866 else if (strncmp (str, "o", 1) == 0)
7867 return ZEBRA_ROUTE_OSPF;
7868 }
7869 if (afi == AFI_IP6)
7870 {
7871 if (strncmp (str, "k", 1) == 0)
7872 return ZEBRA_ROUTE_KERNEL;
7873 else if (strncmp (str, "c", 1) == 0)
7874 return ZEBRA_ROUTE_CONNECT;
7875 else if (strncmp (str, "s", 1) == 0)
7876 return ZEBRA_ROUTE_STATIC;
7877 else if (strncmp (str, "r", 1) == 0)
7878 return ZEBRA_ROUTE_RIPNG;
7879 else if (strncmp (str, "o", 1) == 0)
7880 return ZEBRA_ROUTE_OSPF6;
7881 }
7882 return 0;
7883}
7884
7885DEFUN (bgp_redistribute_ipv4,
7886 bgp_redistribute_ipv4_cmd,
7887 "redistribute (connected|kernel|ospf|rip|static)",
7888 "Redistribute information from another routing protocol\n"
7889 "Connected\n"
7890 "Kernel routes\n"
7891 "Open Shurtest Path First (OSPF)\n"
7892 "Routing Information Protocol (RIP)\n"
7893 "Static routes\n")
7894{
7895 int type;
7896
7897 type = bgp_str2route_type (AFI_IP, argv[0]);
7898 if (! type)
7899 {
7900 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
7901 return CMD_WARNING;
7902 }
7903 return bgp_redistribute_set (vty->index, AFI_IP, type);
7904}
7905
7906DEFUN (bgp_redistribute_ipv4_rmap,
7907 bgp_redistribute_ipv4_rmap_cmd,
7908 "redistribute (connected|kernel|ospf|rip|static) route-map WORD",
7909 "Redistribute information from another routing protocol\n"
7910 "Connected\n"
7911 "Kernel routes\n"
7912 "Open Shurtest Path First (OSPF)\n"
7913 "Routing Information Protocol (RIP)\n"
7914 "Static routes\n"
7915 "Route map reference\n"
7916 "Pointer to route-map entries\n")
7917{
7918 int type;
7919
7920 type = bgp_str2route_type (AFI_IP, argv[0]);
7921 if (! type)
7922 {
7923 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
7924 return CMD_WARNING;
7925 }
7926
7927 bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[1]);
7928 return bgp_redistribute_set (vty->index, AFI_IP, type);
7929}
7930
7931DEFUN (bgp_redistribute_ipv4_metric,
7932 bgp_redistribute_ipv4_metric_cmd,
7933 "redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295>",
7934 "Redistribute information from another routing protocol\n"
7935 "Connected\n"
7936 "Kernel routes\n"
7937 "Open Shurtest Path First (OSPF)\n"
7938 "Routing Information Protocol (RIP)\n"
7939 "Static routes\n"
7940 "Metric for redistributed routes\n"
7941 "Default metric\n")
7942{
7943 int type;
7944 u_int32_t metric;
7945
7946 type = bgp_str2route_type (AFI_IP, argv[0]);
7947 if (! type)
7948 {
7949 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
7950 return CMD_WARNING;
7951 }
7952 VTY_GET_INTEGER ("metric", metric, argv[1]);
7953
7954 bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
7955 return bgp_redistribute_set (vty->index, AFI_IP, type);
7956}
7957
7958DEFUN (bgp_redistribute_ipv4_rmap_metric,
7959 bgp_redistribute_ipv4_rmap_metric_cmd,
7960 "redistribute (connected|kernel|ospf|rip|static) route-map WORD metric <0-4294967295>",
7961 "Redistribute information from another routing protocol\n"
7962 "Connected\n"
7963 "Kernel routes\n"
7964 "Open Shurtest Path First (OSPF)\n"
7965 "Routing Information Protocol (RIP)\n"
7966 "Static routes\n"
7967 "Route map reference\n"
7968 "Pointer to route-map entries\n"
7969 "Metric for redistributed routes\n"
7970 "Default metric\n")
7971{
7972 int type;
7973 u_int32_t metric;
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 VTY_GET_INTEGER ("metric", metric, argv[2]);
7982
7983 bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[1]);
7984 bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
7985 return bgp_redistribute_set (vty->index, AFI_IP, type);
7986}
7987
7988DEFUN (bgp_redistribute_ipv4_metric_rmap,
7989 bgp_redistribute_ipv4_metric_rmap_cmd,
7990 "redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295> route-map WORD",
7991 "Redistribute information from another routing protocol\n"
7992 "Connected\n"
7993 "Kernel routes\n"
7994 "Open Shurtest Path First (OSPF)\n"
7995 "Routing Information Protocol (RIP)\n"
7996 "Static routes\n"
7997 "Metric for redistributed routes\n"
7998 "Default metric\n"
7999 "Route map reference\n"
8000 "Pointer to route-map entries\n")
8001{
8002 int type;
8003 u_int32_t metric;
8004
8005 type = bgp_str2route_type (AFI_IP, argv[0]);
8006 if (! type)
8007 {
8008 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8009 return CMD_WARNING;
8010 }
8011 VTY_GET_INTEGER ("metric", metric, argv[1]);
8012
8013 bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
8014 bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[2]);
8015 return bgp_redistribute_set (vty->index, AFI_IP, type);
8016}
8017
8018DEFUN (no_bgp_redistribute_ipv4,
8019 no_bgp_redistribute_ipv4_cmd,
8020 "no redistribute (connected|kernel|ospf|rip|static)",
8021 NO_STR
8022 "Redistribute information from another routing protocol\n"
8023 "Connected\n"
8024 "Kernel routes\n"
8025 "Open Shurtest Path First (OSPF)\n"
8026 "Routing Information Protocol (RIP)\n"
8027 "Static routes\n")
8028{
8029 int type;
8030
8031 type = bgp_str2route_type (AFI_IP, argv[0]);
8032 if (! type)
8033 {
8034 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8035 return CMD_WARNING;
8036 }
8037
8038 return bgp_redistribute_unset (vty->index, AFI_IP, type);
8039}
8040
8041DEFUN (no_bgp_redistribute_ipv4_rmap,
8042 no_bgp_redistribute_ipv4_rmap_cmd,
8043 "no redistribute (connected|kernel|ospf|rip|static) 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 "Route map reference\n"
8052 "Pointer to route-map entries\n")
8053{
8054 int type;
8055
8056 type = bgp_str2route_type (AFI_IP, argv[0]);
8057 if (! type)
8058 {
8059 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8060 return CMD_WARNING;
8061 }
8062
8063 bgp_redistribute_routemap_unset (vty->index, AFI_IP, type);
8064 return CMD_SUCCESS;
8065}
8066
8067DEFUN (no_bgp_redistribute_ipv4_metric,
8068 no_bgp_redistribute_ipv4_metric_cmd,
8069 "no redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295>",
8070 NO_STR
8071 "Redistribute information from another routing protocol\n"
8072 "Connected\n"
8073 "Kernel routes\n"
8074 "Open Shurtest Path First (OSPF)\n"
8075 "Routing Information Protocol (RIP)\n"
8076 "Static routes\n"
8077 "Metric for redistributed routes\n"
8078 "Default metric\n")
8079{
8080 int type;
8081
8082 type = bgp_str2route_type (AFI_IP, argv[0]);
8083 if (! type)
8084 {
8085 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8086 return CMD_WARNING;
8087 }
8088
8089 bgp_redistribute_metric_unset (vty->index, AFI_IP, type);
8090 return CMD_SUCCESS;
8091}
8092
8093DEFUN (no_bgp_redistribute_ipv4_rmap_metric,
8094 no_bgp_redistribute_ipv4_rmap_metric_cmd,
8095 "no redistribute (connected|kernel|ospf|rip|static) route-map WORD metric <0-4294967295>",
8096 NO_STR
8097 "Redistribute information from another routing protocol\n"
8098 "Connected\n"
8099 "Kernel routes\n"
8100 "Open Shurtest Path First (OSPF)\n"
8101 "Routing Information Protocol (RIP)\n"
8102 "Static routes\n"
8103 "Route map reference\n"
8104 "Pointer to route-map entries\n"
8105 "Metric for redistributed routes\n"
8106 "Default metric\n")
8107{
8108 int type;
8109
8110 type = bgp_str2route_type (AFI_IP, argv[0]);
8111 if (! type)
8112 {
8113 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8114 return CMD_WARNING;
8115 }
8116
8117 bgp_redistribute_metric_unset (vty->index, AFI_IP, type);
8118 bgp_redistribute_routemap_unset (vty->index, AFI_IP, type);
8119 return CMD_SUCCESS;
8120}
8121
8122ALIAS (no_bgp_redistribute_ipv4_rmap_metric,
8123 no_bgp_redistribute_ipv4_metric_rmap_cmd,
8124 "no redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295> route-map WORD",
8125 NO_STR
8126 "Redistribute information from another routing protocol\n"
8127 "Connected\n"
8128 "Kernel routes\n"
8129 "Open Shurtest Path First (OSPF)\n"
8130 "Routing Information Protocol (RIP)\n"
8131 "Static routes\n"
8132 "Metric for redistributed routes\n"
8133 "Default metric\n"
8134 "Route map reference\n"
8135 "Pointer to route-map entries\n")
8136
8137#ifdef HAVE_IPV6
8138DEFUN (bgp_redistribute_ipv6,
8139 bgp_redistribute_ipv6_cmd,
8140 "redistribute (connected|kernel|ospf6|ripng|static)",
8141 "Redistribute information from another routing protocol\n"
8142 "Connected\n"
8143 "Kernel routes\n"
8144 "Open Shurtest Path First (OSPFv3)\n"
8145 "Routing Information Protocol (RIPng)\n"
8146 "Static routes\n")
8147{
8148 int type;
8149
8150 type = bgp_str2route_type (AFI_IP6, argv[0]);
8151 if (! type)
8152 {
8153 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8154 return CMD_WARNING;
8155 }
8156
8157 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8158}
8159
8160DEFUN (bgp_redistribute_ipv6_rmap,
8161 bgp_redistribute_ipv6_rmap_cmd,
8162 "redistribute (connected|kernel|ospf6|ripng|static) route-map WORD",
8163 "Redistribute information from another routing protocol\n"
8164 "Connected\n"
8165 "Kernel routes\n"
8166 "Open Shurtest Path First (OSPFv3)\n"
8167 "Routing Information Protocol (RIPng)\n"
8168 "Static routes\n"
8169 "Route map reference\n"
8170 "Pointer to route-map entries\n")
8171{
8172 int type;
8173
8174 type = bgp_str2route_type (AFI_IP6, argv[0]);
8175 if (! type)
8176 {
8177 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8178 return CMD_WARNING;
8179 }
8180
8181 bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[1]);
8182 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8183}
8184
8185DEFUN (bgp_redistribute_ipv6_metric,
8186 bgp_redistribute_ipv6_metric_cmd,
8187 "redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295>",
8188 "Redistribute information from another routing protocol\n"
8189 "Connected\n"
8190 "Kernel routes\n"
8191 "Open Shurtest Path First (OSPFv3)\n"
8192 "Routing Information Protocol (RIPng)\n"
8193 "Static routes\n"
8194 "Metric for redistributed routes\n"
8195 "Default metric\n")
8196{
8197 int type;
8198 u_int32_t metric;
8199
8200 type = bgp_str2route_type (AFI_IP6, argv[0]);
8201 if (! type)
8202 {
8203 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8204 return CMD_WARNING;
8205 }
8206 VTY_GET_INTEGER ("metric", metric, argv[1]);
8207
8208 bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
8209 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8210}
8211
8212DEFUN (bgp_redistribute_ipv6_rmap_metric,
8213 bgp_redistribute_ipv6_rmap_metric_cmd,
8214 "redistribute (connected|kernel|ospf6|ripng|static) route-map WORD metric <0-4294967295>",
8215 "Redistribute information from another routing protocol\n"
8216 "Connected\n"
8217 "Kernel routes\n"
8218 "Open Shurtest Path First (OSPFv3)\n"
8219 "Routing Information Protocol (RIPng)\n"
8220 "Static routes\n"
8221 "Route map reference\n"
8222 "Pointer to route-map entries\n"
8223 "Metric for redistributed routes\n"
8224 "Default metric\n")
8225{
8226 int type;
8227 u_int32_t metric;
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 VTY_GET_INTEGER ("metric", metric, argv[2]);
8236
8237 bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[1]);
8238 bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
8239 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8240}
8241
8242DEFUN (bgp_redistribute_ipv6_metric_rmap,
8243 bgp_redistribute_ipv6_metric_rmap_cmd,
8244 "redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295> route-map WORD",
8245 "Redistribute information from another routing protocol\n"
8246 "Connected\n"
8247 "Kernel routes\n"
8248 "Open Shurtest Path First (OSPFv3)\n"
8249 "Routing Information Protocol (RIPng)\n"
8250 "Static routes\n"
8251 "Metric for redistributed routes\n"
8252 "Default metric\n"
8253 "Route map reference\n"
8254 "Pointer to route-map entries\n")
8255{
8256 int type;
8257 u_int32_t metric;
8258
8259 type = bgp_str2route_type (AFI_IP6, argv[0]);
8260 if (! type)
8261 {
8262 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8263 return CMD_WARNING;
8264 }
8265 VTY_GET_INTEGER ("metric", metric, argv[1]);
8266
8267 bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
8268 bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[2]);
8269 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8270}
8271
8272DEFUN (no_bgp_redistribute_ipv6,
8273 no_bgp_redistribute_ipv6_cmd,
8274 "no redistribute (connected|kernel|ospf6|ripng|static)",
8275 NO_STR
8276 "Redistribute information from another routing protocol\n"
8277 "Connected\n"
8278 "Kernel routes\n"
8279 "Open Shurtest Path First (OSPFv3)\n"
8280 "Routing Information Protocol (RIPng)\n"
8281 "Static routes\n")
8282{
8283 int type;
8284
8285 type = bgp_str2route_type (AFI_IP6, argv[0]);
8286 if (! type)
8287 {
8288 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8289 return CMD_WARNING;
8290 }
8291
8292 return bgp_redistribute_unset (vty->index, AFI_IP6, type);
8293}
8294
8295DEFUN (no_bgp_redistribute_ipv6_rmap,
8296 no_bgp_redistribute_ipv6_rmap_cmd,
8297 "no redistribute (connected|kernel|ospf6|ripng|static) 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 "Route map reference\n"
8306 "Pointer to route-map entries\n")
8307{
8308 int type;
8309
8310 type = bgp_str2route_type (AFI_IP6, argv[0]);
8311 if (! type)
8312 {
8313 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8314 return CMD_WARNING;
8315 }
8316
8317 bgp_redistribute_routemap_unset (vty->index, AFI_IP6, type);
8318 return CMD_SUCCESS;
8319}
8320
8321DEFUN (no_bgp_redistribute_ipv6_metric,
8322 no_bgp_redistribute_ipv6_metric_cmd,
8323 "no redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295>",
8324 NO_STR
8325 "Redistribute information from another routing protocol\n"
8326 "Connected\n"
8327 "Kernel routes\n"
8328 "Open Shurtest Path First (OSPFv3)\n"
8329 "Routing Information Protocol (RIPng)\n"
8330 "Static routes\n"
8331 "Metric for redistributed routes\n"
8332 "Default metric\n")
8333{
8334 int type;
8335
8336 type = bgp_str2route_type (AFI_IP6, argv[0]);
8337 if (! type)
8338 {
8339 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8340 return CMD_WARNING;
8341 }
8342
8343 bgp_redistribute_metric_unset (vty->index, AFI_IP6, type);
8344 return CMD_SUCCESS;
8345}
8346
8347DEFUN (no_bgp_redistribute_ipv6_rmap_metric,
8348 no_bgp_redistribute_ipv6_rmap_metric_cmd,
8349 "no redistribute (connected|kernel|ospf6|ripng|static) route-map WORD metric <0-4294967295>",
8350 NO_STR
8351 "Redistribute information from another routing protocol\n"
8352 "Connected\n"
8353 "Kernel routes\n"
8354 "Open Shurtest Path First (OSPFv3)\n"
8355 "Routing Information Protocol (RIPng)\n"
8356 "Static routes\n"
8357 "Route map reference\n"
8358 "Pointer to route-map entries\n"
8359 "Metric for redistributed routes\n"
8360 "Default metric\n")
8361{
8362 int type;
8363
8364 type = bgp_str2route_type (AFI_IP6, argv[0]);
8365 if (! type)
8366 {
8367 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8368 return CMD_WARNING;
8369 }
8370
8371 bgp_redistribute_metric_unset (vty->index, AFI_IP6, type);
8372 bgp_redistribute_routemap_unset (vty->index, AFI_IP6, type);
8373 return CMD_SUCCESS;
8374}
8375
8376ALIAS (no_bgp_redistribute_ipv6_rmap_metric,
8377 no_bgp_redistribute_ipv6_metric_rmap_cmd,
8378 "no redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295> route-map WORD",
8379 NO_STR
8380 "Redistribute information from another routing protocol\n"
8381 "Connected\n"
8382 "Kernel routes\n"
8383 "Open Shurtest Path First (OSPFv3)\n"
8384 "Routing Information Protocol (RIPng)\n"
8385 "Static routes\n"
8386 "Metric for redistributed routes\n"
8387 "Default metric\n"
8388 "Route map reference\n"
8389 "Pointer to route-map entries\n")
8390#endif /* HAVE_IPV6 */
8391
8392int
8393bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi,
8394 safi_t safi, int *write)
8395{
8396 int i;
paulfd79ac92004-10-13 05:06:08 +00008397 const char *str[] = { "system", "kernel", "connected", "static", "rip",
hasso66e31692004-03-20 19:33:06 +00008398 "ripng", "ospf", "ospf6", "isis", "bgp"};
paul718e3742002-12-13 20:15:29 +00008399
8400 /* Unicast redistribution only. */
8401 if (safi != SAFI_UNICAST)
8402 return 0;
8403
8404 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
8405 {
8406 /* Redistribute BGP does not make sense. */
8407 if (bgp->redist[afi][i] && i != ZEBRA_ROUTE_BGP)
8408 {
8409 /* Display "address-family" when it is not yet diplayed. */
8410 bgp_config_write_family_header (vty, afi, safi, write);
8411
8412 /* "redistribute" configuration. */
8413 vty_out (vty, " redistribute %s", str[i]);
8414
8415 if (bgp->redist_metric_flag[afi][i])
8416 vty_out (vty, " metric %d", bgp->redist_metric[afi][i]);
8417
8418 if (bgp->rmap[afi][i].name)
8419 vty_out (vty, " route-map %s", bgp->rmap[afi][i].name);
8420
8421 vty_out (vty, "%s", VTY_NEWLINE);
8422 }
8423 }
8424 return *write;
8425}
8426
8427/* BGP node structure. */
8428struct cmd_node bgp_node =
8429{
8430 BGP_NODE,
8431 "%s(config-router)# ",
8432 1,
8433};
8434
8435struct cmd_node bgp_ipv4_unicast_node =
8436{
8437 BGP_IPV4_NODE,
8438 "%s(config-router-af)# ",
8439 1,
8440};
8441
8442struct cmd_node bgp_ipv4_multicast_node =
8443{
8444 BGP_IPV4M_NODE,
8445 "%s(config-router-af)# ",
8446 1,
8447};
8448
8449struct cmd_node bgp_ipv6_unicast_node =
8450{
8451 BGP_IPV6_NODE,
8452 "%s(config-router-af)# ",
8453 1,
8454};
8455
8456struct cmd_node bgp_vpnv4_node =
8457{
8458 BGP_VPNV4_NODE,
8459 "%s(config-router-af)# ",
8460 1
8461};
8462
8463void
8464bgp_vty_init ()
8465{
8466 int bgp_config_write (struct vty *);
8467 void community_list_vty ();
8468
8469 /* Install bgp top node. */
8470 install_node (&bgp_node, bgp_config_write);
8471 install_node (&bgp_ipv4_unicast_node, NULL);
8472 install_node (&bgp_ipv4_multicast_node, NULL);
8473 install_node (&bgp_ipv6_unicast_node, NULL);
8474 install_node (&bgp_vpnv4_node, NULL);
8475
8476 /* Install default VTY commands to new nodes. */
8477 install_default (BGP_NODE);
8478 install_default (BGP_IPV4_NODE);
8479 install_default (BGP_IPV4M_NODE);
8480 install_default (BGP_IPV6_NODE);
8481 install_default (BGP_VPNV4_NODE);
8482
8483 /* "bgp multiple-instance" commands. */
8484 install_element (CONFIG_NODE, &bgp_multiple_instance_cmd);
8485 install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd);
8486
8487 /* "bgp config-type" commands. */
8488 install_element (CONFIG_NODE, &bgp_config_type_cmd);
8489 install_element (CONFIG_NODE, &no_bgp_config_type_cmd);
8490
8491 /* Dummy commands (Currently not supported) */
8492 install_element (BGP_NODE, &no_synchronization_cmd);
8493 install_element (BGP_NODE, &no_auto_summary_cmd);
8494
8495 /* "router bgp" commands. */
8496 install_element (CONFIG_NODE, &router_bgp_cmd);
8497 install_element (CONFIG_NODE, &router_bgp_view_cmd);
8498
8499 /* "no router bgp" commands. */
8500 install_element (CONFIG_NODE, &no_router_bgp_cmd);
8501 install_element (CONFIG_NODE, &no_router_bgp_view_cmd);
8502
8503 /* "bgp router-id" commands. */
8504 install_element (BGP_NODE, &bgp_router_id_cmd);
8505 install_element (BGP_NODE, &no_bgp_router_id_cmd);
8506 install_element (BGP_NODE, &no_bgp_router_id_val_cmd);
8507
8508 /* "bgp cluster-id" commands. */
8509 install_element (BGP_NODE, &bgp_cluster_id_cmd);
8510 install_element (BGP_NODE, &bgp_cluster_id32_cmd);
8511 install_element (BGP_NODE, &no_bgp_cluster_id_cmd);
8512 install_element (BGP_NODE, &no_bgp_cluster_id_arg_cmd);
8513
8514 /* "bgp confederation" commands. */
8515 install_element (BGP_NODE, &bgp_confederation_identifier_cmd);
8516 install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd);
8517 install_element (BGP_NODE, &no_bgp_confederation_identifier_arg_cmd);
8518
8519 /* "bgp confederation peers" commands. */
8520 install_element (BGP_NODE, &bgp_confederation_peers_cmd);
8521 install_element (BGP_NODE, &no_bgp_confederation_peers_cmd);
8522
8523 /* "timers bgp" commands. */
8524 install_element (BGP_NODE, &bgp_timers_cmd);
8525 install_element (BGP_NODE, &no_bgp_timers_cmd);
8526 install_element (BGP_NODE, &no_bgp_timers_arg_cmd);
8527
8528 /* "bgp client-to-client reflection" commands */
8529 install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd);
8530 install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd);
8531
8532 /* "bgp always-compare-med" commands */
8533 install_element (BGP_NODE, &bgp_always_compare_med_cmd);
8534 install_element (BGP_NODE, &no_bgp_always_compare_med_cmd);
8535
8536 /* "bgp deterministic-med" commands */
8537 install_element (BGP_NODE, &bgp_deterministic_med_cmd);
8538 install_element (BGP_NODE, &no_bgp_deterministic_med_cmd);
hasso538621f2004-05-21 09:31:30 +00008539
8540#if 0
8541 /* "bgp graceful-restart" commands */
8542 install_element (BGP_NODE, &bgp_graceful_restart_cmd);
8543 install_element (BGP_NODE, &no_bgp_graceful_restart_cmd);
8544#endif /* 0 */
paul718e3742002-12-13 20:15:29 +00008545
8546 /* "bgp fast-external-failover" commands */
8547 install_element (BGP_NODE, &bgp_fast_external_failover_cmd);
8548 install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd);
8549
8550 /* "bgp enforce-first-as" commands */
8551 install_element (BGP_NODE, &bgp_enforce_first_as_cmd);
8552 install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd);
8553
8554 /* "bgp bestpath compare-routerid" commands */
8555 install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd);
8556 install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd);
8557
8558 /* "bgp bestpath as-path ignore" commands */
8559 install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd);
8560 install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd);
8561
paul848973c2003-08-13 00:32:49 +00008562 /* "bgp log-neighbor-changes" commands */
8563 install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd);
8564 install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd);
8565
paul718e3742002-12-13 20:15:29 +00008566 /* "bgp bestpath med" commands */
8567 install_element (BGP_NODE, &bgp_bestpath_med_cmd);
8568 install_element (BGP_NODE, &bgp_bestpath_med2_cmd);
8569 install_element (BGP_NODE, &bgp_bestpath_med3_cmd);
8570 install_element (BGP_NODE, &no_bgp_bestpath_med_cmd);
8571 install_element (BGP_NODE, &no_bgp_bestpath_med2_cmd);
8572 install_element (BGP_NODE, &no_bgp_bestpath_med3_cmd);
8573
8574 /* "no bgp default ipv4-unicast" commands. */
8575 install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd);
8576 install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd);
8577
8578 /* "bgp network import-check" commands. */
8579 install_element (BGP_NODE, &bgp_network_import_check_cmd);
8580 install_element (BGP_NODE, &no_bgp_network_import_check_cmd);
8581
8582 /* "bgp default local-preference" commands. */
8583 install_element (BGP_NODE, &bgp_default_local_preference_cmd);
8584 install_element (BGP_NODE, &no_bgp_default_local_preference_cmd);
8585 install_element (BGP_NODE, &no_bgp_default_local_preference_val_cmd);
8586
8587 /* "neighbor remote-as" commands. */
8588 install_element (BGP_NODE, &neighbor_remote_as_cmd);
8589 install_element (BGP_NODE, &no_neighbor_cmd);
8590 install_element (BGP_NODE, &no_neighbor_remote_as_cmd);
8591
8592 /* "neighbor peer-group" commands. */
8593 install_element (BGP_NODE, &neighbor_peer_group_cmd);
8594 install_element (BGP_NODE, &no_neighbor_peer_group_cmd);
8595 install_element (BGP_NODE, &no_neighbor_peer_group_remote_as_cmd);
8596
8597 /* "neighbor local-as" commands. */
8598 install_element (BGP_NODE, &neighbor_local_as_cmd);
8599 install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd);
8600 install_element (BGP_NODE, &no_neighbor_local_as_cmd);
8601 install_element (BGP_NODE, &no_neighbor_local_as_val_cmd);
8602 install_element (BGP_NODE, &no_neighbor_local_as_val2_cmd);
8603
8604 /* "neighbor activate" commands. */
8605 install_element (BGP_NODE, &neighbor_activate_cmd);
8606 install_element (BGP_IPV4_NODE, &neighbor_activate_cmd);
8607 install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd);
8608 install_element (BGP_IPV6_NODE, &neighbor_activate_cmd);
8609 install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd);
8610
8611 /* "no neighbor activate" commands. */
8612 install_element (BGP_NODE, &no_neighbor_activate_cmd);
8613 install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd);
8614 install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd);
8615 install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd);
8616 install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd);
8617
8618 /* "neighbor peer-group set" commands. */
8619 install_element (BGP_NODE, &neighbor_set_peer_group_cmd);
8620 install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_cmd);
8621 install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_cmd);
8622 install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd);
paula58545b2003-07-12 21:43:01 +00008623 install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_cmd);
8624
paul718e3742002-12-13 20:15:29 +00008625 /* "no neighbor peer-group unset" commands. */
8626 install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd);
8627 install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd);
8628 install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_cmd);
8629 install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd);
paula58545b2003-07-12 21:43:01 +00008630 install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_cmd);
8631
paul718e3742002-12-13 20:15:29 +00008632 /* "neighbor softreconfiguration inbound" commands.*/
8633 install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd);
8634 install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd);
8635 install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd);
8636 install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
8637 install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd);
8638 install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd);
8639 install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd);
8640 install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
paula58545b2003-07-12 21:43:01 +00008641 install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd);
8642 install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
paul718e3742002-12-13 20:15:29 +00008643
8644 /* "neighbor attribute-unchanged" commands. */
8645 install_element (BGP_NODE, &neighbor_attr_unchanged_cmd);
8646 install_element (BGP_NODE, &neighbor_attr_unchanged1_cmd);
8647 install_element (BGP_NODE, &neighbor_attr_unchanged2_cmd);
8648 install_element (BGP_NODE, &neighbor_attr_unchanged3_cmd);
8649 install_element (BGP_NODE, &neighbor_attr_unchanged4_cmd);
8650 install_element (BGP_NODE, &neighbor_attr_unchanged5_cmd);
8651 install_element (BGP_NODE, &neighbor_attr_unchanged6_cmd);
8652 install_element (BGP_NODE, &neighbor_attr_unchanged7_cmd);
8653 install_element (BGP_NODE, &neighbor_attr_unchanged8_cmd);
8654 install_element (BGP_NODE, &neighbor_attr_unchanged9_cmd);
8655 install_element (BGP_NODE, &neighbor_attr_unchanged10_cmd);
8656 install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd);
8657 install_element (BGP_NODE, &no_neighbor_attr_unchanged1_cmd);
8658 install_element (BGP_NODE, &no_neighbor_attr_unchanged2_cmd);
8659 install_element (BGP_NODE, &no_neighbor_attr_unchanged3_cmd);
8660 install_element (BGP_NODE, &no_neighbor_attr_unchanged4_cmd);
8661 install_element (BGP_NODE, &no_neighbor_attr_unchanged5_cmd);
8662 install_element (BGP_NODE, &no_neighbor_attr_unchanged6_cmd);
8663 install_element (BGP_NODE, &no_neighbor_attr_unchanged7_cmd);
8664 install_element (BGP_NODE, &no_neighbor_attr_unchanged8_cmd);
8665 install_element (BGP_NODE, &no_neighbor_attr_unchanged9_cmd);
8666 install_element (BGP_NODE, &no_neighbor_attr_unchanged10_cmd);
8667 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd);
8668 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged1_cmd);
8669 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged2_cmd);
8670 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged3_cmd);
8671 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged4_cmd);
8672 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged5_cmd);
8673 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged6_cmd);
8674 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged7_cmd);
8675 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged8_cmd);
8676 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged9_cmd);
8677 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged10_cmd);
8678 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd);
8679 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged1_cmd);
8680 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged2_cmd);
8681 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged3_cmd);
8682 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged4_cmd);
8683 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged5_cmd);
8684 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged6_cmd);
8685 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged7_cmd);
8686 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged8_cmd);
8687 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged9_cmd);
8688 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged10_cmd);
8689 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd);
8690 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged1_cmd);
8691 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged2_cmd);
8692 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged3_cmd);
8693 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged4_cmd);
8694 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged5_cmd);
8695 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged6_cmd);
8696 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged7_cmd);
8697 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged8_cmd);
8698 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged9_cmd);
8699 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged10_cmd);
8700 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd);
8701 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged1_cmd);
8702 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged2_cmd);
8703 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged3_cmd);
8704 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged4_cmd);
8705 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged5_cmd);
8706 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged6_cmd);
8707 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged7_cmd);
8708 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged8_cmd);
8709 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged9_cmd);
8710 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged10_cmd);
8711 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd);
8712 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged1_cmd);
8713 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged2_cmd);
8714 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged3_cmd);
8715 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged4_cmd);
8716 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged5_cmd);
8717 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged6_cmd);
8718 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged7_cmd);
8719 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged8_cmd);
8720 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged9_cmd);
8721 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged10_cmd);
8722 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd);
8723 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged1_cmd);
8724 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged2_cmd);
8725 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged3_cmd);
8726 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged4_cmd);
8727 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged5_cmd);
8728 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged6_cmd);
8729 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged7_cmd);
8730 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged8_cmd);
8731 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged9_cmd);
8732 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged10_cmd);
8733 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd);
8734 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged1_cmd);
8735 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged2_cmd);
8736 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged3_cmd);
8737 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged4_cmd);
8738 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged5_cmd);
8739 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged6_cmd);
8740 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged7_cmd);
8741 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged8_cmd);
8742 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged9_cmd);
8743 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged10_cmd);
8744 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd);
8745 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged1_cmd);
8746 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged2_cmd);
8747 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged3_cmd);
8748 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged4_cmd);
8749 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged5_cmd);
8750 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged6_cmd);
8751 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged7_cmd);
8752 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged8_cmd);
8753 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged9_cmd);
8754 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged10_cmd);
8755
paulfee0f4c2004-09-13 05:12:46 +00008756 /* "nexthop-local unchanged" commands */
8757 install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd);
8758 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd);
8759
paul718e3742002-12-13 20:15:29 +00008760 /* "transparent-as" and "transparent-nexthop" for old version
8761 compatibility. */
8762 install_element (BGP_NODE, &neighbor_transparent_as_cmd);
8763 install_element (BGP_NODE, &neighbor_transparent_nexthop_cmd);
8764
8765 /* "neighbor next-hop-self" commands. */
8766 install_element (BGP_NODE, &neighbor_nexthop_self_cmd);
8767 install_element (BGP_NODE, &no_neighbor_nexthop_self_cmd);
8768 install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd);
8769 install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd);
8770 install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd);
8771 install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd);
8772 install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd);
8773 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd);
8774 install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd);
8775 install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd);
8776
8777 /* "neighbor remove-private-AS" commands. */
8778 install_element (BGP_NODE, &neighbor_remove_private_as_cmd);
8779 install_element (BGP_NODE, &no_neighbor_remove_private_as_cmd);
8780 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd);
8781 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd);
8782 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd);
8783 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd);
8784 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd);
8785 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd);
8786 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd);
8787 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd);
8788
8789 /* "neighbor send-community" commands.*/
8790 install_element (BGP_NODE, &neighbor_send_community_cmd);
8791 install_element (BGP_NODE, &neighbor_send_community_type_cmd);
8792 install_element (BGP_NODE, &no_neighbor_send_community_cmd);
8793 install_element (BGP_NODE, &no_neighbor_send_community_type_cmd);
8794 install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd);
8795 install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd);
8796 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd);
8797 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd);
8798 install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd);
8799 install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd);
8800 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd);
8801 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd);
8802 install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd);
8803 install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd);
8804 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd);
8805 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd);
8806 install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd);
8807 install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd);
8808 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd);
8809 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd);
8810
8811 /* "neighbor route-reflector" commands.*/
8812 install_element (BGP_NODE, &neighbor_route_reflector_client_cmd);
8813 install_element (BGP_NODE, &no_neighbor_route_reflector_client_cmd);
8814 install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd);
8815 install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd);
8816 install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd);
8817 install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd);
8818 install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd);
8819 install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd);
8820 install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd);
8821 install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd);
8822
8823 /* "neighbor route-server" commands.*/
8824 install_element (BGP_NODE, &neighbor_route_server_client_cmd);
8825 install_element (BGP_NODE, &no_neighbor_route_server_client_cmd);
8826 install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd);
8827 install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd);
8828 install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd);
8829 install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd);
8830 install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd);
8831 install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd);
8832 install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd);
8833 install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd);
8834
8835 /* "neighbor passive" commands. */
8836 install_element (BGP_NODE, &neighbor_passive_cmd);
8837 install_element (BGP_NODE, &no_neighbor_passive_cmd);
8838
8839 /* "neighbor shutdown" commands. */
8840 install_element (BGP_NODE, &neighbor_shutdown_cmd);
8841 install_element (BGP_NODE, &no_neighbor_shutdown_cmd);
8842
8843 /* "neighbor capability route-refresh" commands.*/
8844 install_element (BGP_NODE, &neighbor_capability_route_refresh_cmd);
8845 install_element (BGP_NODE, &no_neighbor_capability_route_refresh_cmd);
8846
8847 /* "neighbor capability orf prefix-list" commands.*/
8848 install_element (BGP_NODE, &neighbor_capability_orf_prefix_cmd);
8849 install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_cmd);
8850 install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd);
8851 install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd);
8852 install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd);
8853 install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd);
8854 install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd);
8855 install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd);
8856
8857 /* "neighbor capability dynamic" commands.*/
8858 install_element (BGP_NODE, &neighbor_capability_dynamic_cmd);
8859 install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd);
8860
8861 /* "neighbor dont-capability-negotiate" commands. */
8862 install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd);
8863 install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd);
8864
8865 /* "neighbor ebgp-multihop" commands. */
8866 install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd);
8867 install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd);
8868 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd);
8869 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_ttl_cmd);
8870
8871 /* "neighbor enforce-multihop" commands. */
8872 install_element (BGP_NODE, &neighbor_enforce_multihop_cmd);
8873 install_element (BGP_NODE, &no_neighbor_enforce_multihop_cmd);
8874
8875 /* "neighbor description" commands. */
8876 install_element (BGP_NODE, &neighbor_description_cmd);
8877 install_element (BGP_NODE, &no_neighbor_description_cmd);
8878 install_element (BGP_NODE, &no_neighbor_description_val_cmd);
8879
8880 /* "neighbor update-source" commands. "*/
8881 install_element (BGP_NODE, &neighbor_update_source_cmd);
8882 install_element (BGP_NODE, &no_neighbor_update_source_cmd);
8883
8884 /* "neighbor default-originate" commands. */
8885 install_element (BGP_NODE, &neighbor_default_originate_cmd);
8886 install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd);
8887 install_element (BGP_NODE, &no_neighbor_default_originate_cmd);
8888 install_element (BGP_NODE, &no_neighbor_default_originate_rmap_cmd);
8889 install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd);
8890 install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd);
8891 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd);
8892 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_rmap_cmd);
8893 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd);
8894 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd);
8895 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd);
8896 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_rmap_cmd);
8897 install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd);
8898 install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd);
8899 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd);
8900 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_rmap_cmd);
8901
8902 /* "neighbor port" commands. */
8903 install_element (BGP_NODE, &neighbor_port_cmd);
8904 install_element (BGP_NODE, &no_neighbor_port_cmd);
8905 install_element (BGP_NODE, &no_neighbor_port_val_cmd);
8906
8907 /* "neighbor weight" commands. */
8908 install_element (BGP_NODE, &neighbor_weight_cmd);
8909 install_element (BGP_NODE, &no_neighbor_weight_cmd);
8910 install_element (BGP_NODE, &no_neighbor_weight_val_cmd);
8911
8912 /* "neighbor override-capability" commands. */
8913 install_element (BGP_NODE, &neighbor_override_capability_cmd);
8914 install_element (BGP_NODE, &no_neighbor_override_capability_cmd);
8915
8916 /* "neighbor strict-capability-match" commands. */
8917 install_element (BGP_NODE, &neighbor_strict_capability_cmd);
8918 install_element (BGP_NODE, &no_neighbor_strict_capability_cmd);
8919
8920 /* "neighbor timers" commands. */
8921 install_element (BGP_NODE, &neighbor_timers_cmd);
8922 install_element (BGP_NODE, &no_neighbor_timers_cmd);
8923
8924 /* "neighbor timers connect" commands. */
8925 install_element (BGP_NODE, &neighbor_timers_connect_cmd);
8926 install_element (BGP_NODE, &no_neighbor_timers_connect_cmd);
8927 install_element (BGP_NODE, &no_neighbor_timers_connect_val_cmd);
8928
8929 /* "neighbor advertisement-interval" commands. */
8930 install_element (BGP_NODE, &neighbor_advertise_interval_cmd);
8931 install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd);
8932 install_element (BGP_NODE, &no_neighbor_advertise_interval_val_cmd);
8933
8934 /* "neighbor version" commands. */
8935 install_element (BGP_NODE, &neighbor_version_cmd);
8936 install_element (BGP_NODE, &no_neighbor_version_cmd);
8937
8938 /* "neighbor interface" commands. */
8939 install_element (BGP_NODE, &neighbor_interface_cmd);
8940 install_element (BGP_NODE, &no_neighbor_interface_cmd);
8941
8942 /* "neighbor distribute" commands. */
8943 install_element (BGP_NODE, &neighbor_distribute_list_cmd);
8944 install_element (BGP_NODE, &no_neighbor_distribute_list_cmd);
8945 install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd);
8946 install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd);
8947 install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd);
8948 install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd);
8949 install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd);
8950 install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd);
8951 install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd);
8952 install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd);
8953
8954 /* "neighbor prefix-list" commands. */
8955 install_element (BGP_NODE, &neighbor_prefix_list_cmd);
8956 install_element (BGP_NODE, &no_neighbor_prefix_list_cmd);
8957 install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd);
8958 install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd);
8959 install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd);
8960 install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd);
8961 install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd);
8962 install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd);
8963 install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd);
8964 install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd);
8965
8966 /* "neighbor filter-list" commands. */
8967 install_element (BGP_NODE, &neighbor_filter_list_cmd);
8968 install_element (BGP_NODE, &no_neighbor_filter_list_cmd);
8969 install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd);
8970 install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd);
8971 install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd);
8972 install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd);
8973 install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd);
8974 install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd);
8975 install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd);
8976 install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd);
8977
8978 /* "neighbor route-map" commands. */
8979 install_element (BGP_NODE, &neighbor_route_map_cmd);
8980 install_element (BGP_NODE, &no_neighbor_route_map_cmd);
8981 install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd);
8982 install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd);
8983 install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd);
8984 install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd);
8985 install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd);
8986 install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd);
8987 install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd);
8988 install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd);
8989
8990 /* "neighbor unsuppress-map" commands. */
8991 install_element (BGP_NODE, &neighbor_unsuppress_map_cmd);
8992 install_element (BGP_NODE, &no_neighbor_unsuppress_map_cmd);
8993 install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd);
8994 install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd);
8995 install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd);
8996 install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd);
8997 install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd);
8998 install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd);
paula58545b2003-07-12 21:43:01 +00008999 install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd);
9000 install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd);
paul718e3742002-12-13 20:15:29 +00009001
9002 /* "neighbor maximum-prefix" commands. */
9003 install_element (BGP_NODE, &neighbor_maximum_prefix_cmd);
hassoe0701b72004-05-20 09:19:34 +00009004 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_cmd);
paul718e3742002-12-13 20:15:29 +00009005 install_element (BGP_NODE, &neighbor_maximum_prefix_warning_cmd);
hassoe0701b72004-05-20 09:19:34 +00009006 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
hasso0a486e52005-02-01 20:57:17 +00009007 install_element (BGP_NODE, &neighbor_maximum_prefix_restart_cmd);
9008 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009009 install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd);
9010 install_element (BGP_NODE, &no_neighbor_maximum_prefix_val_cmd);
hasso0a486e52005-02-01 20:57:17 +00009011 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9012 install_element (BGP_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9013 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9014 install_element (BGP_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9015 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009016 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd);
hassoe0701b72004-05-20 09:19:34 +00009017 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
paul718e3742002-12-13 20:15:29 +00009018 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd);
hassoe0701b72004-05-20 09:19:34 +00009019 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
hasso0a486e52005-02-01 20:57:17 +00009020 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd);
9021 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009022 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd);
9023 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
hasso0a486e52005-02-01 20:57:17 +00009024 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9025 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9026 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9027 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9028 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009029 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd);
hassoe0701b72004-05-20 09:19:34 +00009030 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd);
paul718e3742002-12-13 20:15:29 +00009031 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd);
hassoe0701b72004-05-20 09:19:34 +00009032 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
hasso0a486e52005-02-01 20:57:17 +00009033 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd);
9034 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009035 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd);
9036 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_val_cmd);
hasso0a486e52005-02-01 20:57:17 +00009037 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9038 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9039 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9040 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9041 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009042 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd);
hassoe0701b72004-05-20 09:19:34 +00009043 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
paul718e3742002-12-13 20:15:29 +00009044 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd);
hassoe0701b72004-05-20 09:19:34 +00009045 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
hasso0a486e52005-02-01 20:57:17 +00009046 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd);
9047 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009048 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd);
9049 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_val_cmd);
hasso0a486e52005-02-01 20:57:17 +00009050 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9051 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9052 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9053 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9054 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009055 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd);
hassoe0701b72004-05-20 09:19:34 +00009056 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
paul718e3742002-12-13 20:15:29 +00009057 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd);
hassoe0701b72004-05-20 09:19:34 +00009058 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
hasso0a486e52005-02-01 20:57:17 +00009059 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd);
9060 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009061 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd);
9062 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
hasso0a486e52005-02-01 20:57:17 +00009063 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9064 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9065 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9066 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9067 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009068
9069 /* "neighbor allowas-in" */
9070 install_element (BGP_NODE, &neighbor_allowas_in_cmd);
9071 install_element (BGP_NODE, &neighbor_allowas_in_arg_cmd);
9072 install_element (BGP_NODE, &no_neighbor_allowas_in_cmd);
9073 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd);
9074 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_arg_cmd);
9075 install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd);
9076 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd);
9077 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_arg_cmd);
9078 install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd);
9079 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd);
9080 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_arg_cmd);
9081 install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd);
9082 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd);
9083 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_arg_cmd);
9084 install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd);
9085
9086 /* address-family commands. */
9087 install_element (BGP_NODE, &address_family_ipv4_cmd);
9088 install_element (BGP_NODE, &address_family_ipv4_safi_cmd);
9089#ifdef HAVE_IPV6
9090 install_element (BGP_NODE, &address_family_ipv6_cmd);
9091 install_element (BGP_NODE, &address_family_ipv6_unicast_cmd);
9092#endif /* HAVE_IPV6 */
9093 install_element (BGP_NODE, &address_family_vpnv4_cmd);
9094 install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd);
9095
9096 /* "exit-address-family" command. */
9097 install_element (BGP_IPV4_NODE, &exit_address_family_cmd);
9098 install_element (BGP_IPV4M_NODE, &exit_address_family_cmd);
9099 install_element (BGP_IPV6_NODE, &exit_address_family_cmd);
9100 install_element (BGP_VPNV4_NODE, &exit_address_family_cmd);
9101
9102 /* "clear ip bgp commands" */
9103 install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd);
9104 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_cmd);
9105 install_element (ENABLE_NODE, &clear_ip_bgp_as_cmd);
9106 install_element (ENABLE_NODE, &clear_ip_bgp_peer_cmd);
9107 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_cmd);
9108 install_element (ENABLE_NODE, &clear_ip_bgp_external_cmd);
9109#ifdef HAVE_IPV6
9110 install_element (ENABLE_NODE, &clear_bgp_all_cmd);
9111 install_element (ENABLE_NODE, &clear_bgp_instance_all_cmd);
9112 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_cmd);
9113 install_element (ENABLE_NODE, &clear_bgp_peer_cmd);
9114 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_cmd);
9115 install_element (ENABLE_NODE, &clear_bgp_peer_group_cmd);
9116 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_cmd);
9117 install_element (ENABLE_NODE, &clear_bgp_external_cmd);
9118 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_cmd);
9119 install_element (ENABLE_NODE, &clear_bgp_as_cmd);
9120 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_cmd);
9121#endif /* HAVE_IPV6 */
9122
9123 /* "clear ip bgp neighbor soft in" */
9124 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_in_cmd);
9125 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_in_cmd);
9126 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_cmd);
9127 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_prefix_filter_cmd);
9128 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_in_prefix_filter_cmd);
9129 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_in_cmd);
9130 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_cmd);
9131 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_prefix_filter_cmd);
9132 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_in_cmd);
9133 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_cmd);
9134 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_prefix_filter_cmd);
9135 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_in_cmd);
9136 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_cmd);
9137 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_prefix_filter_cmd);
9138 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_in_cmd);
9139 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_cmd);
9140 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_prefix_filter_cmd);
9141 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_in_cmd);
9142 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_in_cmd);
9143 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_cmd);
9144 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_prefix_filter_cmd);
9145 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_in_prefix_filter_cmd);
9146 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_in_cmd);
9147 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_cmd);
9148 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd);
9149 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_in_cmd);
9150 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_cmd);
9151 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd);
9152 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_in_cmd);
9153 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_cmd);
9154 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_prefix_filter_cmd);
9155 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_in_cmd);
9156 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_cmd);
9157 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_prefix_filter_cmd);
9158 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_in_cmd);
9159 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_in_cmd);
9160 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_in_cmd);
9161 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_in_cmd);
9162 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_in_cmd);
9163 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_in_cmd);
9164#ifdef HAVE_IPV6
9165 install_element (ENABLE_NODE, &clear_bgp_all_soft_in_cmd);
9166 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_in_cmd);
9167 install_element (ENABLE_NODE, &clear_bgp_all_in_cmd);
9168 install_element (ENABLE_NODE, &clear_bgp_all_in_prefix_filter_cmd);
9169 install_element (ENABLE_NODE, &clear_bgp_peer_soft_in_cmd);
9170 install_element (ENABLE_NODE, &clear_bgp_peer_in_cmd);
9171 install_element (ENABLE_NODE, &clear_bgp_peer_in_prefix_filter_cmd);
9172 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_in_cmd);
9173 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_cmd);
9174 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_prefix_filter_cmd);
9175 install_element (ENABLE_NODE, &clear_bgp_external_soft_in_cmd);
9176 install_element (ENABLE_NODE, &clear_bgp_external_in_cmd);
9177 install_element (ENABLE_NODE, &clear_bgp_external_in_prefix_filter_cmd);
9178 install_element (ENABLE_NODE, &clear_bgp_as_soft_in_cmd);
9179 install_element (ENABLE_NODE, &clear_bgp_as_in_cmd);
9180 install_element (ENABLE_NODE, &clear_bgp_as_in_prefix_filter_cmd);
9181 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_in_cmd);
9182 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_cmd);
9183 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_prefix_filter_cmd);
9184 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_in_cmd);
9185 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_cmd);
9186 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_prefix_filter_cmd);
9187 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_in_cmd);
9188 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_cmd);
9189 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_prefix_filter_cmd);
9190 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_in_cmd);
9191 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_cmd);
9192 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_prefix_filter_cmd);
9193 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_in_cmd);
9194 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_cmd);
9195 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_prefix_filter_cmd);
9196#endif /* HAVE_IPV6 */
9197
9198 /* "clear ip bgp neighbor soft out" */
9199 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_out_cmd);
9200 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_out_cmd);
9201 install_element (ENABLE_NODE, &clear_ip_bgp_all_out_cmd);
9202 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_out_cmd);
9203 install_element (ENABLE_NODE, &clear_ip_bgp_peer_out_cmd);
9204 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_out_cmd);
9205 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_out_cmd);
9206 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_out_cmd);
9207 install_element (ENABLE_NODE, &clear_ip_bgp_external_out_cmd);
9208 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_out_cmd);
9209 install_element (ENABLE_NODE, &clear_ip_bgp_as_out_cmd);
9210 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_out_cmd);
9211 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_out_cmd);
9212 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_out_cmd);
9213 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_out_cmd);
9214 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_out_cmd);
9215 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_out_cmd);
9216 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_out_cmd);
9217 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_out_cmd);
9218 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_out_cmd);
9219 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_out_cmd);
9220 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_out_cmd);
9221 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_out_cmd);
9222 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_out_cmd);
9223 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_out_cmd);
9224 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_out_cmd);
9225 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_out_cmd);
9226 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_out_cmd);
9227#ifdef HAVE_IPV6
9228 install_element (ENABLE_NODE, &clear_bgp_all_soft_out_cmd);
9229 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_out_cmd);
9230 install_element (ENABLE_NODE, &clear_bgp_all_out_cmd);
9231 install_element (ENABLE_NODE, &clear_bgp_peer_soft_out_cmd);
9232 install_element (ENABLE_NODE, &clear_bgp_peer_out_cmd);
9233 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_out_cmd);
9234 install_element (ENABLE_NODE, &clear_bgp_peer_group_out_cmd);
9235 install_element (ENABLE_NODE, &clear_bgp_external_soft_out_cmd);
9236 install_element (ENABLE_NODE, &clear_bgp_external_out_cmd);
9237 install_element (ENABLE_NODE, &clear_bgp_as_soft_out_cmd);
9238 install_element (ENABLE_NODE, &clear_bgp_as_out_cmd);
9239 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_out_cmd);
9240 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_out_cmd);
9241 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_out_cmd);
9242 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_out_cmd);
9243 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_out_cmd);
9244 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_out_cmd);
9245 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_out_cmd);
9246 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_out_cmd);
9247 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_out_cmd);
9248 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_out_cmd);
9249#endif /* HAVE_IPV6 */
9250
9251 /* "clear ip bgp neighbor soft" */
9252 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_cmd);
9253 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_cmd);
9254 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_cmd);
9255 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_cmd);
9256 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_cmd);
9257 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_cmd);
9258 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_cmd);
9259 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_cmd);
9260 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_cmd);
9261 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_cmd);
9262 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_cmd);
9263 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_cmd);
9264 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_cmd);
9265 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_cmd);
9266 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_cmd);
9267#ifdef HAVE_IPV6
9268 install_element (ENABLE_NODE, &clear_bgp_all_soft_cmd);
9269 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_cmd);
9270 install_element (ENABLE_NODE, &clear_bgp_peer_soft_cmd);
9271 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_cmd);
9272 install_element (ENABLE_NODE, &clear_bgp_external_soft_cmd);
9273 install_element (ENABLE_NODE, &clear_bgp_as_soft_cmd);
9274 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_cmd);
9275 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_cmd);
9276 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_cmd);
9277 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_cmd);
9278 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_cmd);
9279#endif /* HAVE_IPV6 */
9280
paulfee0f4c2004-09-13 05:12:46 +00009281 /* "clear ip bgp neighbor rsclient" */
9282 install_element (ENABLE_NODE, &clear_ip_bgp_all_rsclient_cmd);
9283 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_rsclient_cmd);
9284 install_element (ENABLE_NODE, &clear_ip_bgp_peer_rsclient_cmd);
9285 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_rsclient_cmd);
9286#ifdef HAVE_IPV6
9287 install_element (ENABLE_NODE, &clear_bgp_all_rsclient_cmd);
9288 install_element (ENABLE_NODE, &clear_bgp_instance_all_rsclient_cmd);
9289 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_rsclient_cmd);
9290 install_element (ENABLE_NODE, &clear_bgp_ipv6_instance_all_rsclient_cmd);
9291 install_element (ENABLE_NODE, &clear_bgp_peer_rsclient_cmd);
9292 install_element (ENABLE_NODE, &clear_bgp_instance_peer_rsclient_cmd);
9293 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_rsclient_cmd);
9294 install_element (ENABLE_NODE, &clear_bgp_ipv6_instance_peer_rsclient_cmd);
9295#endif /* HAVE_IPV6 */
9296
paul718e3742002-12-13 20:15:29 +00009297 /* "show ip bgp summary" commands. */
9298 install_element (VIEW_NODE, &show_ip_bgp_summary_cmd);
9299 install_element (VIEW_NODE, &show_ip_bgp_instance_summary_cmd);
9300 install_element (VIEW_NODE, &show_ip_bgp_ipv4_summary_cmd);
9301 install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
9302 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
9303 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
9304#ifdef HAVE_IPV6
9305 install_element (VIEW_NODE, &show_bgp_summary_cmd);
9306 install_element (VIEW_NODE, &show_bgp_instance_summary_cmd);
9307 install_element (VIEW_NODE, &show_bgp_ipv6_summary_cmd);
9308 install_element (VIEW_NODE, &show_bgp_instance_ipv6_summary_cmd);
9309#endif /* HAVE_IPV6 */
9310 install_element (ENABLE_NODE, &show_ip_bgp_summary_cmd);
9311 install_element (ENABLE_NODE, &show_ip_bgp_instance_summary_cmd);
9312 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_summary_cmd);
9313 install_element (ENABLE_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
9314 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
9315 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
9316#ifdef HAVE_IPV6
9317 install_element (ENABLE_NODE, &show_bgp_summary_cmd);
9318 install_element (ENABLE_NODE, &show_bgp_instance_summary_cmd);
9319 install_element (ENABLE_NODE, &show_bgp_ipv6_summary_cmd);
9320 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_summary_cmd);
9321#endif /* HAVE_IPV6 */
9322
9323 /* "show ip bgp neighbors" commands. */
9324 install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd);
9325 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
9326 install_element (VIEW_NODE, &show_ip_bgp_neighbors_peer_cmd);
9327 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
9328 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd);
9329 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd);
9330 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
9331 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
9332 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_cmd);
9333 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
9334 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_cmd);
9335 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
9336 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_peer_cmd);
9337 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
9338 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd);
9339 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd);
9340 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
9341 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
9342 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_cmd);
9343 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
9344
9345#ifdef HAVE_IPV6
9346 install_element (VIEW_NODE, &show_bgp_neighbors_cmd);
9347 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_cmd);
9348 install_element (VIEW_NODE, &show_bgp_neighbors_peer_cmd);
9349 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
paulbb46e942003-10-24 19:02:03 +00009350 install_element (VIEW_NODE, &show_bgp_instance_neighbors_cmd);
9351 install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
9352 install_element (VIEW_NODE, &show_bgp_instance_neighbors_peer_cmd);
9353 install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
paul718e3742002-12-13 20:15:29 +00009354 install_element (ENABLE_NODE, &show_bgp_neighbors_cmd);
9355 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_cmd);
9356 install_element (ENABLE_NODE, &show_bgp_neighbors_peer_cmd);
9357 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
paulbb46e942003-10-24 19:02:03 +00009358 install_element (ENABLE_NODE, &show_bgp_instance_neighbors_cmd);
9359 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
9360 install_element (ENABLE_NODE, &show_bgp_instance_neighbors_peer_cmd);
9361 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
paul718e3742002-12-13 20:15:29 +00009362
9363 /* Old commands. */
9364 install_element (VIEW_NODE, &show_ipv6_bgp_summary_cmd);
9365 install_element (VIEW_NODE, &show_ipv6_mbgp_summary_cmd);
9366 install_element (ENABLE_NODE, &show_ipv6_bgp_summary_cmd);
9367 install_element (ENABLE_NODE, &show_ipv6_mbgp_summary_cmd);
9368#endif /* HAVE_IPV6 */
9369
paulfee0f4c2004-09-13 05:12:46 +00009370 /* "show ip bgp rsclient" commands. */
9371 install_element (VIEW_NODE, &show_ip_bgp_rsclient_summary_cmd);
9372 install_element (VIEW_NODE, &show_ip_bgp_instance_rsclient_summary_cmd);
9373 install_element (VIEW_NODE, &show_ip_bgp_ipv4_rsclient_summary_cmd);
9374 install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_rsclient_summary_cmd);
9375 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_summary_cmd);
9376 install_element (ENABLE_NODE, &show_ip_bgp_instance_rsclient_summary_cmd);
9377 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_rsclient_summary_cmd);
9378 install_element (ENABLE_NODE, &show_ip_bgp_instance_ipv4_rsclient_summary_cmd);
9379
9380#ifdef HAVE_IPV6
9381 install_element (VIEW_NODE, &show_bgp_rsclient_summary_cmd);
9382 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_summary_cmd);
9383 install_element (VIEW_NODE, &show_bgp_instance_rsclient_summary_cmd);
9384 install_element (VIEW_NODE, &show_bgp_instance_ipv6_rsclient_summary_cmd);
9385 install_element (ENABLE_NODE, &show_bgp_rsclient_summary_cmd);
9386 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_summary_cmd);
9387 install_element (ENABLE_NODE, &show_bgp_instance_rsclient_summary_cmd);
9388 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_rsclient_summary_cmd);
9389#endif /* HAVE_IPV6 */
9390
paul718e3742002-12-13 20:15:29 +00009391 /* "show ip bgp paths" commands. */
9392 install_element (VIEW_NODE, &show_ip_bgp_paths_cmd);
9393 install_element (VIEW_NODE, &show_ip_bgp_ipv4_paths_cmd);
9394 install_element (ENABLE_NODE, &show_ip_bgp_paths_cmd);
9395 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_paths_cmd);
9396
9397 /* "show ip bgp community" commands. */
9398 install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd);
9399 install_element (ENABLE_NODE, &show_ip_bgp_community_info_cmd);
9400
9401 /* "show ip bgp attribute-info" commands. */
9402 install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd);
9403 install_element (ENABLE_NODE, &show_ip_bgp_attr_info_cmd);
9404
9405 /* "redistribute" commands. */
9406 install_element (BGP_NODE, &bgp_redistribute_ipv4_cmd);
9407 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_cmd);
9408 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_cmd);
9409 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_cmd);
9410 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_cmd);
9411 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_cmd);
9412 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd);
9413 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd);
9414 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_metric_cmd);
9415 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_rmap_cmd);
9416#ifdef HAVE_IPV6
9417 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd);
9418 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd);
9419 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd);
9420 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_cmd);
9421 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd);
9422 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_cmd);
9423 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd);
9424 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd);
9425 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_metric_cmd);
9426 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_rmap_cmd);
9427#endif /* HAVE_IPV6 */
9428
9429 /* Community-list. */
9430 community_list_vty ();
9431}
9432
9433#include "memory.h"
9434#include "bgp_regex.h"
9435#include "bgp_clist.h"
9436#include "bgp_ecommunity.h"
9437
9438/* VTY functions. */
9439
9440/* Direction value to string conversion. */
paulfd79ac92004-10-13 05:06:08 +00009441const char *
paul718e3742002-12-13 20:15:29 +00009442community_direct_str (int direct)
9443{
9444 switch (direct)
9445 {
9446 case COMMUNITY_DENY:
9447 return "deny";
9448 break;
9449 case COMMUNITY_PERMIT:
9450 return "permit";
9451 break;
9452 default:
9453 return "unknown";
9454 break;
9455 }
9456}
9457
9458/* Display error string. */
9459void
9460community_list_perror (struct vty *vty, int ret)
9461{
9462 switch (ret)
9463 {
9464 case COMMUNITY_LIST_ERR_CANT_FIND_LIST:
9465 vty_out (vty, "%% Can't find communit-list%s", VTY_NEWLINE);
9466 break;
9467 case COMMUNITY_LIST_ERR_MALFORMED_VAL:
9468 vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE);
9469 break;
9470 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT:
9471 vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE);
9472 break;
9473 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT:
9474 vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE);
9475 break;
9476 }
9477}
9478
9479/* VTY interface for community_set() function. */
9480int
paulfd79ac92004-10-13 05:06:08 +00009481community_list_set_vty (struct vty *vty, int argc, const char **argv,
9482 int style, int reject_all_digit_name)
paul718e3742002-12-13 20:15:29 +00009483{
9484 int ret;
9485 int direct;
9486 char *str;
9487
9488 /* Check the list type. */
9489 if (strncmp (argv[1], "p", 1) == 0)
9490 direct = COMMUNITY_PERMIT;
9491 else if (strncmp (argv[1], "d", 1) == 0)
9492 direct = COMMUNITY_DENY;
9493 else
9494 {
9495 vty_out (vty, "%% Matching condition must be permit or deny%s",
9496 VTY_NEWLINE);
9497 return CMD_WARNING;
9498 }
9499
9500 /* All digit name check. */
9501 if (reject_all_digit_name && all_digit (argv[0]))
9502 {
9503 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
9504 return CMD_WARNING;
9505 }
9506
9507 /* Concat community string argument. */
9508 if (argc > 1)
9509 str = argv_concat (argv, argc, 2);
9510 else
9511 str = NULL;
9512
9513 /* When community_list_set() return nevetive value, it means
9514 malformed community string. */
9515 ret = community_list_set (bgp_clist, argv[0], str, direct, style);
9516
9517 /* Free temporary community list string allocated by
9518 argv_concat(). */
9519 if (str)
9520 XFREE (MTYPE_TMP, str);
9521
9522 if (ret < 0)
9523 {
9524 /* Display error string. */
9525 community_list_perror (vty, ret);
9526 return CMD_WARNING;
9527 }
9528
9529 return CMD_SUCCESS;
9530}
9531
9532/* Community-list delete with name. */
9533int
paulfd79ac92004-10-13 05:06:08 +00009534community_list_unset_all_vty (struct vty *vty, const char *name)
paul718e3742002-12-13 20:15:29 +00009535{
9536 int ret;
9537
9538 ret = community_list_unset (bgp_clist, name, NULL, 0, COMMUNITY_LIST_AUTO);
9539
9540 if (ret < 0)
9541 {
9542 community_list_perror (vty, ret);
9543 return CMD_WARNING;
9544 }
9545 return CMD_SUCCESS;
9546}
9547
9548/* Communiyt-list entry delete. */
9549int
paulfd79ac92004-10-13 05:06:08 +00009550community_list_unset_vty (struct vty *vty, int argc, const char **argv,
9551 int style)
paul718e3742002-12-13 20:15:29 +00009552{
9553 int ret;
9554 int direct;
9555 char *str;
9556
9557 /* Check the list direct. */
9558 if (strncmp (argv[1], "p", 1) == 0)
9559 direct = COMMUNITY_PERMIT;
9560 else if (strncmp (argv[1], "d", 1) == 0)
9561 direct = COMMUNITY_DENY;
9562 else
9563 {
9564 vty_out (vty, "%% Matching condition must be permit or deny%s",
9565 VTY_NEWLINE);
9566 return CMD_WARNING;
9567 }
9568
9569 /* Concat community string argument. */
9570 str = argv_concat (argv, argc, 2);
9571
9572 /* Unset community list. */
9573 ret = community_list_unset (bgp_clist, argv[0], str, direct, style);
9574
9575 /* Free temporary community list string allocated by
9576 argv_concat(). */
9577 XFREE (MTYPE_TMP, str);
9578
9579 if (ret < 0)
9580 {
9581 community_list_perror (vty, ret);
9582 return CMD_WARNING;
9583 }
9584
9585 return CMD_SUCCESS;
9586}
9587
9588/* "community-list" keyword help string. */
9589#define COMMUNITY_LIST_STR "Add a community list entry\n"
9590#define COMMUNITY_VAL_STR "Community number in aa:nn format or internet|local-AS|no-advertise|no-export\n"
9591
9592DEFUN (ip_community_list,
9593 ip_community_list_cmd,
9594 "ip community-list WORD (deny|permit) .AA:NN",
9595 IP_STR
9596 COMMUNITY_LIST_STR
9597 "Community list name\n"
9598 "Specify community to reject\n"
9599 "Specify community to accept\n"
9600 COMMUNITY_VAL_STR)
9601{
9602 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_AUTO, 1);
9603}
9604
9605DEFUN (ip_community_list_standard,
9606 ip_community_list_standard_cmd,
9607 "ip community-list <1-99> (deny|permit) .AA:NN",
9608 IP_STR
9609 COMMUNITY_LIST_STR
9610 "Community list number (standard)\n"
9611 "Specify community to reject\n"
9612 "Specify community to accept\n"
9613 COMMUNITY_VAL_STR)
9614{
9615 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
9616}
9617
9618ALIAS (ip_community_list_standard,
9619 ip_community_list_standard2_cmd,
9620 "ip community-list <1-99> (deny|permit)",
9621 IP_STR
9622 COMMUNITY_LIST_STR
9623 "Community list number (standard)\n"
9624 "Specify community to reject\n"
9625 "Specify community to accept\n")
9626
9627DEFUN (ip_community_list_expanded,
9628 ip_community_list_expanded_cmd,
9629 "ip community-list <100-199> (deny|permit) .LINE",
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_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
9638}
9639
9640DEFUN (ip_community_list_name_standard,
9641 ip_community_list_name_standard_cmd,
9642 "ip community-list standard WORD (deny|permit) .AA:NN",
9643 IP_STR
9644 COMMUNITY_LIST_STR
9645 "Add a standard community-list entry\n"
9646 "Community list name\n"
9647 "Specify community to reject\n"
9648 "Specify community to accept\n"
9649 COMMUNITY_VAL_STR)
9650{
9651 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
9652}
9653
9654ALIAS (ip_community_list_name_standard,
9655 ip_community_list_name_standard2_cmd,
9656 "ip community-list standard WORD (deny|permit)",
9657 IP_STR
9658 COMMUNITY_LIST_STR
9659 "Add a standard community-list entry\n"
9660 "Community list name\n"
9661 "Specify community to reject\n"
9662 "Specify community to accept\n")
9663
9664DEFUN (ip_community_list_name_expanded,
9665 ip_community_list_name_expanded_cmd,
9666 "ip community-list expanded WORD (deny|permit) .LINE",
9667 IP_STR
9668 COMMUNITY_LIST_STR
9669 "Add an expanded community-list entry\n"
9670 "Community list name\n"
9671 "Specify community to reject\n"
9672 "Specify community to accept\n"
9673 "An ordered list as a regular-expression\n")
9674{
9675 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
9676}
9677
9678DEFUN (no_ip_community_list_all,
9679 no_ip_community_list_all_cmd,
9680 "no ip community-list (WORD|<1-99>|<100-199>)",
9681 NO_STR
9682 IP_STR
9683 COMMUNITY_LIST_STR
9684 "Community list name\n"
9685 "Community list number (standard)\n"
9686 "Community list number (expanded)\n")
9687{
9688 return community_list_unset_all_vty (vty, argv[0]);
9689}
9690
9691DEFUN (no_ip_community_list_name_all,
9692 no_ip_community_list_name_all_cmd,
9693 "no ip community-list (standard|expanded) WORD",
9694 NO_STR
9695 IP_STR
9696 COMMUNITY_LIST_STR
9697 "Add a standard community-list entry\n"
9698 "Add an expanded community-list entry\n"
9699 "Community list name\n")
9700{
9701 return community_list_unset_all_vty (vty, argv[1]);
9702}
9703
9704DEFUN (no_ip_community_list,
9705 no_ip_community_list_cmd,
9706 "no ip community-list WORD (deny|permit) .AA:NN",
9707 NO_STR
9708 IP_STR
9709 COMMUNITY_LIST_STR
9710 "Community list name\n"
9711 "Specify community to reject\n"
9712 "Specify community to accept\n"
9713 COMMUNITY_VAL_STR)
9714{
9715 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_AUTO);
9716}
9717
9718DEFUN (no_ip_community_list_standard,
9719 no_ip_community_list_standard_cmd,
9720 "no ip community-list <1-99> (deny|permit) .AA:NN",
9721 NO_STR
9722 IP_STR
9723 COMMUNITY_LIST_STR
9724 "Community list number (standard)\n"
9725 "Specify community to reject\n"
9726 "Specify community to accept\n"
9727 COMMUNITY_VAL_STR)
9728{
9729 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
9730}
9731
9732DEFUN (no_ip_community_list_expanded,
9733 no_ip_community_list_expanded_cmd,
9734 "no ip community-list <100-199> (deny|permit) .LINE",
9735 NO_STR
9736 IP_STR
9737 COMMUNITY_LIST_STR
9738 "Community list number (expanded)\n"
9739 "Specify community to reject\n"
9740 "Specify community to accept\n"
9741 "An ordered list as a regular-expression\n")
9742{
9743 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
9744}
9745
9746DEFUN (no_ip_community_list_name_standard,
9747 no_ip_community_list_name_standard_cmd,
9748 "no ip community-list standard WORD (deny|permit) .AA:NN",
9749 NO_STR
9750 IP_STR
9751 COMMUNITY_LIST_STR
9752 "Specify a standard community-list\n"
9753 "Community list name\n"
9754 "Specify community to reject\n"
9755 "Specify community to accept\n"
9756 COMMUNITY_VAL_STR)
9757{
9758 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
9759}
9760
9761DEFUN (no_ip_community_list_name_expanded,
9762 no_ip_community_list_name_expanded_cmd,
9763 "no ip community-list expanded WORD (deny|permit) .LINE",
9764 NO_STR
9765 IP_STR
9766 COMMUNITY_LIST_STR
9767 "Specify an expanded community-list\n"
9768 "Community list name\n"
9769 "Specify community to reject\n"
9770 "Specify community to accept\n"
9771 "An ordered list as a regular-expression\n")
9772{
9773 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
9774}
9775
9776void
9777community_list_show (struct vty *vty, struct community_list *list)
9778{
9779 struct community_entry *entry;
9780
9781 for (entry = list->head; entry; entry = entry->next)
9782 {
9783 if (entry == list->head)
9784 {
9785 if (all_digit (list->name))
9786 vty_out (vty, "Community %s list %s%s",
9787 entry->style == COMMUNITY_LIST_STANDARD ?
9788 "standard" : "(expanded) access",
9789 list->name, VTY_NEWLINE);
9790 else
9791 vty_out (vty, "Named Community %s list %s%s",
9792 entry->style == COMMUNITY_LIST_STANDARD ?
9793 "standard" : "expanded",
9794 list->name, VTY_NEWLINE);
9795 }
9796 if (entry->any)
9797 vty_out (vty, " %s%s",
9798 community_direct_str (entry->direct), VTY_NEWLINE);
9799 else
9800 vty_out (vty, " %s %s%s",
9801 community_direct_str (entry->direct),
9802 entry->style == COMMUNITY_LIST_STANDARD
9803 ? community_str (entry->u.com) : entry->config,
9804 VTY_NEWLINE);
9805 }
9806}
9807
9808DEFUN (show_ip_community_list,
9809 show_ip_community_list_cmd,
9810 "show ip community-list",
9811 SHOW_STR
9812 IP_STR
9813 "List community-list\n")
9814{
9815 struct community_list *list;
9816 struct community_list_master *cm;
9817
9818 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_AUTO);
9819 if (! cm)
9820 return CMD_SUCCESS;
9821
9822 for (list = cm->num.head; list; list = list->next)
9823 community_list_show (vty, list);
9824
9825 for (list = cm->str.head; list; list = list->next)
9826 community_list_show (vty, list);
9827
9828 return CMD_SUCCESS;
9829}
9830
9831DEFUN (show_ip_community_list_arg,
9832 show_ip_community_list_arg_cmd,
9833 "show ip community-list (<1-199>|WORD)",
9834 SHOW_STR
9835 IP_STR
9836 "List community-list\n"
9837 "Community-list number\n"
9838 "Community-list name\n")
9839{
9840 struct community_list *list;
9841
9842 list = community_list_lookup (bgp_clist, argv[0], COMMUNITY_LIST_AUTO);
9843 if (! list)
9844 {
9845 vty_out (vty, "%% Can't find communit-list%s", VTY_NEWLINE);
9846 return CMD_WARNING;
9847 }
9848
9849 community_list_show (vty, list);
9850
9851 return CMD_SUCCESS;
9852}
9853
9854int
paulfd79ac92004-10-13 05:06:08 +00009855extcommunity_list_set_vty (struct vty *vty, int argc, const char **argv,
9856 int style, int reject_all_digit_name)
paul718e3742002-12-13 20:15:29 +00009857{
9858 int ret;
9859 int direct;
9860 char *str;
9861
9862 /* Check the list type. */
9863 if (strncmp (argv[1], "p", 1) == 0)
9864 direct = COMMUNITY_PERMIT;
9865 else if (strncmp (argv[1], "d", 1) == 0)
9866 direct = COMMUNITY_DENY;
9867 else
9868 {
9869 vty_out (vty, "%% Matching condition must be permit or deny%s",
9870 VTY_NEWLINE);
9871 return CMD_WARNING;
9872 }
9873
9874 /* All digit name check. */
9875 if (reject_all_digit_name && all_digit (argv[0]))
9876 {
9877 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
9878 return CMD_WARNING;
9879 }
9880
9881 /* Concat community string argument. */
9882 if (argc > 1)
9883 str = argv_concat (argv, argc, 2);
9884 else
9885 str = NULL;
9886
9887 ret = extcommunity_list_set (bgp_clist, argv[0], str, direct, style);
9888
9889 /* Free temporary community list string allocated by
9890 argv_concat(). */
9891 if (str)
9892 XFREE (MTYPE_TMP, str);
9893
9894 if (ret < 0)
9895 {
9896 community_list_perror (vty, ret);
9897 return CMD_WARNING;
9898 }
9899 return CMD_SUCCESS;
9900}
9901
9902int
paulfd79ac92004-10-13 05:06:08 +00009903extcommunity_list_unset_all_vty (struct vty *vty, const char *name)
paul718e3742002-12-13 20:15:29 +00009904{
9905 int ret;
9906
9907 ret = extcommunity_list_unset (bgp_clist, name, NULL, 0, EXTCOMMUNITY_LIST_AUTO);
9908
9909 if (ret < 0)
9910 {
9911 community_list_perror (vty, ret);
9912 return CMD_WARNING;
9913 }
9914 return CMD_SUCCESS;
9915}
9916
9917int
paulfd79ac92004-10-13 05:06:08 +00009918extcommunity_list_unset_vty (struct vty *vty, int argc, const char **argv,
9919 int style)
paul718e3742002-12-13 20:15:29 +00009920{
9921 int ret;
9922 int direct;
9923 char *str;
9924
9925 /* Check the list direct. */
9926 if (strncmp (argv[1], "p", 1) == 0)
9927 direct = COMMUNITY_PERMIT;
9928 else if (strncmp (argv[1], "d", 1) == 0)
9929 direct = COMMUNITY_DENY;
9930 else
9931 {
9932 vty_out (vty, "%% Matching condition must be permit or deny%s",
9933 VTY_NEWLINE);
9934 return CMD_WARNING;
9935 }
9936
9937 /* Concat community string argument. */
9938 str = argv_concat (argv, argc, 2);
9939
9940 /* Unset community list. */
9941 ret = extcommunity_list_unset (bgp_clist, argv[0], str, direct, style);
9942
9943 /* Free temporary community list string allocated by
9944 argv_concat(). */
9945 XFREE (MTYPE_TMP, str);
9946
9947 if (ret < 0)
9948 {
9949 community_list_perror (vty, ret);
9950 return CMD_WARNING;
9951 }
9952
9953 return CMD_SUCCESS;
9954}
9955
9956/* "extcommunity-list" keyword help string. */
9957#define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
9958#define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
9959
9960DEFUN (ip_extcommunity_list_standard,
9961 ip_extcommunity_list_standard_cmd,
9962 "ip extcommunity-list <1-99> (deny|permit) .AA:NN",
9963 IP_STR
9964 EXTCOMMUNITY_LIST_STR
9965 "Extended Community list number (standard)\n"
9966 "Specify community to reject\n"
9967 "Specify community to accept\n"
9968 EXTCOMMUNITY_VAL_STR)
9969{
9970 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
9971}
9972
9973ALIAS (ip_extcommunity_list_standard,
9974 ip_extcommunity_list_standard2_cmd,
9975 "ip extcommunity-list <1-99> (deny|permit)",
9976 IP_STR
9977 EXTCOMMUNITY_LIST_STR
9978 "Extended Community list number (standard)\n"
9979 "Specify community to reject\n"
9980 "Specify community to accept\n")
9981
9982DEFUN (ip_extcommunity_list_expanded,
9983 ip_extcommunity_list_expanded_cmd,
9984 "ip extcommunity-list <100-199> (deny|permit) .LINE",
9985 IP_STR
9986 EXTCOMMUNITY_LIST_STR
9987 "Extended Community list number (expanded)\n"
9988 "Specify community to reject\n"
9989 "Specify community to accept\n"
9990 "An ordered list as a regular-expression\n")
9991{
9992 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
9993}
9994
9995DEFUN (ip_extcommunity_list_name_standard,
9996 ip_extcommunity_list_name_standard_cmd,
9997 "ip extcommunity-list standard WORD (deny|permit) .AA:NN",
9998 IP_STR
9999 EXTCOMMUNITY_LIST_STR
10000 "Specify standard extcommunity-list\n"
10001 "Extended Community list name\n"
10002 "Specify community to reject\n"
10003 "Specify community to accept\n"
10004 EXTCOMMUNITY_VAL_STR)
10005{
10006 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
10007}
10008
10009ALIAS (ip_extcommunity_list_name_standard,
10010 ip_extcommunity_list_name_standard2_cmd,
10011 "ip extcommunity-list standard WORD (deny|permit)",
10012 IP_STR
10013 EXTCOMMUNITY_LIST_STR
10014 "Specify standard extcommunity-list\n"
10015 "Extended Community list name\n"
10016 "Specify community to reject\n"
10017 "Specify community to accept\n")
10018
10019DEFUN (ip_extcommunity_list_name_expanded,
10020 ip_extcommunity_list_name_expanded_cmd,
10021 "ip extcommunity-list expanded WORD (deny|permit) .LINE",
10022 IP_STR
10023 EXTCOMMUNITY_LIST_STR
10024 "Specify expanded extcommunity-list\n"
10025 "Extended Community list name\n"
10026 "Specify community to reject\n"
10027 "Specify community to accept\n"
10028 "An ordered list as a regular-expression\n")
10029{
10030 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
10031}
10032
10033DEFUN (no_ip_extcommunity_list_all,
10034 no_ip_extcommunity_list_all_cmd,
10035 "no ip extcommunity-list (<1-99>|<100-199>)",
10036 NO_STR
10037 IP_STR
10038 EXTCOMMUNITY_LIST_STR
10039 "Extended Community list number (standard)\n"
10040 "Extended Community list number (expanded)\n")
10041{
10042 return extcommunity_list_unset_all_vty (vty, argv[0]);
10043}
10044
10045DEFUN (no_ip_extcommunity_list_name_all,
10046 no_ip_extcommunity_list_name_all_cmd,
10047 "no ip extcommunity-list (standard|expanded) WORD",
10048 NO_STR
10049 IP_STR
10050 EXTCOMMUNITY_LIST_STR
10051 "Specify standard extcommunity-list\n"
10052 "Specify expanded extcommunity-list\n"
10053 "Extended Community list name\n")
10054{
10055 return extcommunity_list_unset_all_vty (vty, argv[1]);
10056}
10057
10058DEFUN (no_ip_extcommunity_list_standard,
10059 no_ip_extcommunity_list_standard_cmd,
10060 "no ip extcommunity-list <1-99> (deny|permit) .AA:NN",
10061 NO_STR
10062 IP_STR
10063 EXTCOMMUNITY_LIST_STR
10064 "Extended Community list number (standard)\n"
10065 "Specify community to reject\n"
10066 "Specify community to accept\n"
10067 EXTCOMMUNITY_VAL_STR)
10068{
10069 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
10070}
10071
10072DEFUN (no_ip_extcommunity_list_expanded,
10073 no_ip_extcommunity_list_expanded_cmd,
10074 "no ip extcommunity-list <100-199> (deny|permit) .LINE",
10075 NO_STR
10076 IP_STR
10077 EXTCOMMUNITY_LIST_STR
10078 "Extended Community list number (expanded)\n"
10079 "Specify community to reject\n"
10080 "Specify community to accept\n"
10081 "An ordered list as a regular-expression\n")
10082{
10083 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
10084}
10085
10086DEFUN (no_ip_extcommunity_list_name_standard,
10087 no_ip_extcommunity_list_name_standard_cmd,
10088 "no ip extcommunity-list standard WORD (deny|permit) .AA:NN",
10089 NO_STR
10090 IP_STR
10091 EXTCOMMUNITY_LIST_STR
10092 "Specify standard extcommunity-list\n"
10093 "Extended Community list name\n"
10094 "Specify community to reject\n"
10095 "Specify community to accept\n"
10096 EXTCOMMUNITY_VAL_STR)
10097{
10098 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
10099}
10100
10101DEFUN (no_ip_extcommunity_list_name_expanded,
10102 no_ip_extcommunity_list_name_expanded_cmd,
10103 "no ip extcommunity-list expanded WORD (deny|permit) .LINE",
10104 NO_STR
10105 IP_STR
10106 EXTCOMMUNITY_LIST_STR
10107 "Specify expanded extcommunity-list\n"
10108 "Community list name\n"
10109 "Specify community to reject\n"
10110 "Specify community to accept\n"
10111 "An ordered list as a regular-expression\n")
10112{
10113 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
10114}
10115
10116void
10117extcommunity_list_show (struct vty *vty, struct community_list *list)
10118{
10119 struct community_entry *entry;
10120
10121 for (entry = list->head; entry; entry = entry->next)
10122 {
10123 if (entry == list->head)
10124 {
10125 if (all_digit (list->name))
10126 vty_out (vty, "Extended community %s list %s%s",
10127 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
10128 "standard" : "(expanded) access",
10129 list->name, VTY_NEWLINE);
10130 else
10131 vty_out (vty, "Named extended community %s list %s%s",
10132 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
10133 "standard" : "expanded",
10134 list->name, VTY_NEWLINE);
10135 }
10136 if (entry->any)
10137 vty_out (vty, " %s%s",
10138 community_direct_str (entry->direct), VTY_NEWLINE);
10139 else
10140 vty_out (vty, " %s %s%s",
10141 community_direct_str (entry->direct),
10142 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
10143 entry->u.ecom->str : entry->config,
10144 VTY_NEWLINE);
10145 }
10146}
10147
10148DEFUN (show_ip_extcommunity_list,
10149 show_ip_extcommunity_list_cmd,
10150 "show ip extcommunity-list",
10151 SHOW_STR
10152 IP_STR
10153 "List extended-community list\n")
10154{
10155 struct community_list *list;
10156 struct community_list_master *cm;
10157
10158 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_AUTO);
10159 if (! cm)
10160 return CMD_SUCCESS;
10161
10162 for (list = cm->num.head; list; list = list->next)
10163 extcommunity_list_show (vty, list);
10164
10165 for (list = cm->str.head; list; list = list->next)
10166 extcommunity_list_show (vty, list);
10167
10168 return CMD_SUCCESS;
10169}
10170
10171DEFUN (show_ip_extcommunity_list_arg,
10172 show_ip_extcommunity_list_arg_cmd,
10173 "show ip extcommunity-list (<1-199>|WORD)",
10174 SHOW_STR
10175 IP_STR
10176 "List extended-community list\n"
10177 "Extcommunity-list number\n"
10178 "Extcommunity-list name\n")
10179{
10180 struct community_list *list;
10181
10182 list = community_list_lookup (bgp_clist, argv[0], EXTCOMMUNITY_LIST_AUTO);
10183 if (! list)
10184 {
10185 vty_out (vty, "%% Can't find extcommunit-list%s", VTY_NEWLINE);
10186 return CMD_WARNING;
10187 }
10188
10189 extcommunity_list_show (vty, list);
10190
10191 return CMD_SUCCESS;
10192}
10193
10194/* Return configuration string of community-list entry. */
paulfd79ac92004-10-13 05:06:08 +000010195static const char *
paul718e3742002-12-13 20:15:29 +000010196community_list_config_str (struct community_entry *entry)
10197{
paulfd79ac92004-10-13 05:06:08 +000010198 const char *str;
paul718e3742002-12-13 20:15:29 +000010199
10200 if (entry->any)
10201 str = "";
10202 else
10203 {
10204 if (entry->style == COMMUNITY_LIST_STANDARD)
10205 str = community_str (entry->u.com);
10206 else
10207 str = entry->config;
10208 }
10209 return str;
10210}
10211
10212/* Display community-list and extcommunity-list configuration. */
10213int
10214community_list_config_write (struct vty *vty)
10215{
10216 struct community_list *list;
10217 struct community_entry *entry;
10218 struct community_list_master *cm;
10219 int write = 0;
10220
10221 /* Community-list. */
10222 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_AUTO);
10223
10224 for (list = cm->num.head; list; list = list->next)
10225 for (entry = list->head; entry; entry = entry->next)
10226 {
10227 if (atol (list->name) < 200)
10228 vty_out (vty, "ip community-list %s %s %s%s",
10229 list->name, community_direct_str (entry->direct),
10230 community_list_config_str (entry),
10231 VTY_NEWLINE);
10232 else
10233 vty_out (vty, "ip community-list %s %s %s %s%s",
10234 entry->style == COMMUNITY_LIST_STANDARD
10235 ? "standard" : "expanded",
10236 list->name, community_direct_str (entry->direct),
10237 community_list_config_str (entry),
10238 VTY_NEWLINE);
10239 write++;
10240 }
10241 for (list = cm->str.head; list; list = list->next)
10242 for (entry = list->head; entry; entry = entry->next)
10243 {
10244 vty_out (vty, "ip community-list %s %s %s %s%s",
10245 entry->style == COMMUNITY_LIST_STANDARD
10246 ? "standard" : "expanded",
10247 list->name, community_direct_str (entry->direct),
10248 community_list_config_str (entry),
10249 VTY_NEWLINE);
10250 write++;
10251 }
10252
10253 /* Extcommunity-list. */
10254 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_AUTO);
10255
10256 for (list = cm->num.head; list; list = list->next)
10257 for (entry = list->head; entry; entry = entry->next)
10258 {
10259 if (atol (list->name) < 200)
10260 vty_out (vty, "ip extcommunity-list %s %s %s%s",
10261 list->name, community_direct_str (entry->direct),
10262 community_list_config_str (entry), VTY_NEWLINE);
10263 else
10264 vty_out (vty, "ip extcommunity-list %s %s %s %s%s",
10265 entry->style == EXTCOMMUNITY_LIST_STANDARD
10266 ? "standard" : "expanded",
10267 list->name, community_direct_str (entry->direct),
10268 community_list_config_str (entry), VTY_NEWLINE);
10269 write++;
10270 }
10271 for (list = cm->str.head; list; list = list->next)
10272 for (entry = list->head; entry; entry = entry->next)
10273 {
10274 vty_out (vty, "ip extcommunity-list %s %s %s %s%s",
10275 entry->style == EXTCOMMUNITY_LIST_STANDARD
10276 ? "standard" : "expanded",
10277 list->name, community_direct_str (entry->direct),
10278 community_list_config_str (entry), VTY_NEWLINE);
10279 write++;
10280 }
10281 return write;
10282}
10283
10284struct cmd_node community_list_node =
10285{
10286 COMMUNITY_LIST_NODE,
10287 "",
10288 1 /* Export to vtysh. */
10289};
10290
10291void
10292community_list_vty ()
10293{
10294 install_node (&community_list_node, community_list_config_write);
10295
10296 /* Community-list. */
10297 install_element (CONFIG_NODE, &ip_community_list_cmd);
10298 install_element (CONFIG_NODE, &ip_community_list_standard_cmd);
10299 install_element (CONFIG_NODE, &ip_community_list_standard2_cmd);
10300 install_element (CONFIG_NODE, &ip_community_list_expanded_cmd);
10301 install_element (CONFIG_NODE, &ip_community_list_name_standard_cmd);
10302 install_element (CONFIG_NODE, &ip_community_list_name_standard2_cmd);
10303 install_element (CONFIG_NODE, &ip_community_list_name_expanded_cmd);
10304 install_element (CONFIG_NODE, &no_ip_community_list_all_cmd);
10305 install_element (CONFIG_NODE, &no_ip_community_list_name_all_cmd);
10306 install_element (CONFIG_NODE, &no_ip_community_list_cmd);
10307 install_element (CONFIG_NODE, &no_ip_community_list_standard_cmd);
10308 install_element (CONFIG_NODE, &no_ip_community_list_expanded_cmd);
10309 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_cmd);
10310 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_cmd);
10311 install_element (VIEW_NODE, &show_ip_community_list_cmd);
10312 install_element (VIEW_NODE, &show_ip_community_list_arg_cmd);
10313 install_element (ENABLE_NODE, &show_ip_community_list_cmd);
10314 install_element (ENABLE_NODE, &show_ip_community_list_arg_cmd);
10315
10316 /* Extcommunity-list. */
10317 install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd);
10318 install_element (CONFIG_NODE, &ip_extcommunity_list_standard2_cmd);
10319 install_element (CONFIG_NODE, &ip_extcommunity_list_expanded_cmd);
10320 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard_cmd);
10321 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard2_cmd);
10322 install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd);
10323 install_element (CONFIG_NODE, &no_ip_extcommunity_list_all_cmd);
10324 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_all_cmd);
10325 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_cmd);
10326 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_cmd);
10327 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_cmd);
10328 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_cmd);
10329 install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd);
10330 install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd);
10331 install_element (ENABLE_NODE, &show_ip_extcommunity_list_cmd);
10332 install_element (ENABLE_NODE, &show_ip_extcommunity_list_arg_cmd);
10333}