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