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