blob: d93c5d361fafa0f9a549c53250d29144ef93dd45 [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"
Paul Jakma4bf6a362006-03-30 14:05:23 +000032#include "hash.h"
paul718e3742002-12-13 20:15:29 +000033
34#include "bgpd/bgpd.h"
Paul Jakma4bf6a362006-03-30 14:05:23 +000035#include "bgpd/bgp_advertise.h"
paul718e3742002-12-13 20:15:29 +000036#include "bgpd/bgp_attr.h"
37#include "bgpd/bgp_aspath.h"
38#include "bgpd/bgp_community.h"
Paul Jakma4bf6a362006-03-30 14:05:23 +000039#include "bgpd/bgp_ecommunity.h"
40#include "bgpd/bgp_damp.h"
paul718e3742002-12-13 20:15:29 +000041#include "bgpd/bgp_debug.h"
hassoe0701b72004-05-20 09:19:34 +000042#include "bgpd/bgp_fsm.h"
paul718e3742002-12-13 20:15:29 +000043#include "bgpd/bgp_mplsvpn.h"
Paul Jakma4bf6a362006-03-30 14:05:23 +000044#include "bgpd/bgp_nexthop.h"
paul718e3742002-12-13 20:15:29 +000045#include "bgpd/bgp_open.h"
Paul Jakma4bf6a362006-03-30 14:05:23 +000046#include "bgpd/bgp_regex.h"
paul718e3742002-12-13 20:15:29 +000047#include "bgpd/bgp_route.h"
48#include "bgpd/bgp_zebra.h"
paulfee0f4c2004-09-13 05:12:46 +000049#include "bgpd/bgp_table.h"
paul94f2b392005-06-28 12:44:16 +000050#include "bgpd/bgp_vty.h"
paul718e3742002-12-13 20:15:29 +000051
hasso18a6dce2004-10-03 18:18:34 +000052extern struct in_addr router_id_zebra;
53
paul718e3742002-12-13 20:15:29 +000054/* Utility function to get address family from current node. */
55afi_t
56bgp_node_afi (struct vty *vty)
57{
paul25ffbdc2005-08-22 22:42:08 +000058 if (vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE)
paul718e3742002-12-13 20:15:29 +000059 return AFI_IP6;
60 return AFI_IP;
61}
62
63/* Utility function to get subsequent address family from current
64 node. */
65safi_t
66bgp_node_safi (struct vty *vty)
67{
68 if (vty->node == BGP_VPNV4_NODE)
69 return SAFI_MPLS_VPN;
paul25ffbdc2005-08-22 22:42:08 +000070 if (vty->node == BGP_IPV4M_NODE || vty->node == BGP_IPV6M_NODE)
paul718e3742002-12-13 20:15:29 +000071 return SAFI_MULTICAST;
72 return SAFI_UNICAST;
73}
74
paul94f2b392005-06-28 12:44:16 +000075static int
paul718e3742002-12-13 20:15:29 +000076peer_address_self_check (union sockunion *su)
77{
78 struct interface *ifp = NULL;
79
80 if (su->sa.sa_family == AF_INET)
81 ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr);
82#ifdef HAVE_IPV6
83 else if (su->sa.sa_family == AF_INET6)
84 ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr);
85#endif /* HAVE IPV6 */
86
87 if (ifp)
88 return 1;
89
90 return 0;
91}
92
93/* Utility function for looking up peer from VTY. */
paul94f2b392005-06-28 12:44:16 +000094static struct peer *
paulfd79ac92004-10-13 05:06:08 +000095peer_lookup_vty (struct vty *vty, const char *ip_str)
paul718e3742002-12-13 20:15:29 +000096{
97 int ret;
98 struct bgp *bgp;
99 union sockunion su;
100 struct peer *peer;
101
102 bgp = vty->index;
103
104 ret = str2sockunion (ip_str, &su);
105 if (ret < 0)
106 {
107 vty_out (vty, "%% Malformed address: %s%s", ip_str, VTY_NEWLINE);
108 return NULL;
109 }
110
111 peer = peer_lookup (bgp, &su);
112 if (! peer)
113 {
114 vty_out (vty, "%% Specify remote-as or peer-group commands first%s", VTY_NEWLINE);
115 return NULL;
116 }
117 return peer;
118}
119
120/* Utility function for looking up peer or peer group. */
paul94f2b392005-06-28 12:44:16 +0000121static struct peer *
paulfd79ac92004-10-13 05:06:08 +0000122peer_and_group_lookup_vty (struct vty *vty, const char *peer_str)
paul718e3742002-12-13 20:15:29 +0000123{
124 int ret;
125 struct bgp *bgp;
126 union sockunion su;
127 struct peer *peer;
128 struct peer_group *group;
129
130 bgp = vty->index;
131
132 ret = str2sockunion (peer_str, &su);
133 if (ret == 0)
134 {
135 peer = peer_lookup (bgp, &su);
136 if (peer)
137 return peer;
138 }
139 else
140 {
141 group = peer_group_lookup (bgp, peer_str);
142 if (group)
143 return group->conf;
144 }
145
146 vty_out (vty, "%% Specify remote-as or peer-group commands first%s",
147 VTY_NEWLINE);
148
149 return NULL;
150}
151
paul94f2b392005-06-28 12:44:16 +0000152static int
paul718e3742002-12-13 20:15:29 +0000153bgp_vty_return (struct vty *vty, int ret)
154{
paulfd79ac92004-10-13 05:06:08 +0000155 const char *str = NULL;
paul718e3742002-12-13 20:15:29 +0000156
157 switch (ret)
158 {
159 case BGP_ERR_INVALID_VALUE:
160 str = "Invalid value";
161 break;
162 case BGP_ERR_INVALID_FLAG:
163 str = "Invalid flag";
164 break;
165 case BGP_ERR_PEER_INACTIVE:
166 str = "Activate the neighbor for the address family first";
167 break;
168 case BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER:
169 str = "Invalid command for a peer-group member";
170 break;
171 case BGP_ERR_PEER_GROUP_SHUTDOWN:
172 str = "Peer-group has been shutdown. Activate the peer-group first";
173 break;
174 case BGP_ERR_PEER_GROUP_HAS_THE_FLAG:
175 str = "This peer is a peer-group member. Please change peer-group configuration";
176 break;
177 case BGP_ERR_PEER_FLAG_CONFLICT:
178 str = "Can't set override-capability and strict-capability-match at the same time";
179 break;
180 case BGP_ERR_PEER_GROUP_MEMBER_EXISTS:
181 str = "No activate for peergroup can be given only if peer-group has no members";
182 break;
183 case BGP_ERR_PEER_BELONGS_TO_GROUP:
184 str = "No activate for an individual peer-group member is invalid";
185 break;
186 case BGP_ERR_PEER_GROUP_AF_UNCONFIGURED:
187 str = "Activate the peer-group for the address family first";
188 break;
189 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS:
190 str = "Specify remote-as or peer-group remote AS first";
191 break;
192 case BGP_ERR_PEER_GROUP_CANT_CHANGE:
193 str = "Cannot change the peer-group. Deconfigure first";
194 break;
195 case BGP_ERR_PEER_GROUP_MISMATCH:
196 str = "Cannot have different peer-group for the neighbor";
197 break;
198 case BGP_ERR_PEER_FILTER_CONFLICT:
199 str = "Prefix/distribute list can not co-exist";
200 break;
201 case BGP_ERR_NOT_INTERNAL_PEER:
202 str = "Invalid command. Not an internal neighbor";
203 break;
204 case BGP_ERR_REMOVE_PRIVATE_AS:
205 str = "Private AS cannot be removed for IBGP peers";
206 break;
207 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP:
208 str = "Local-AS allowed only for EBGP peers";
209 break;
210 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS:
211 str = "Cannot have local-as same as BGP AS number";
212 break;
Paul Jakma0df7c912008-07-21 21:02:49 +0000213 case BGP_ERR_TCPSIG_FAILED:
214 str = "Error while applying TCP-Sig to session(s)";
215 break;
Nick Hilliardfa411a22011-03-23 15:33:17 +0000216 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK:
217 str = "ebgp-multihop and ttl-security cannot be configured together";
218 break;
paul718e3742002-12-13 20:15:29 +0000219 }
220 if (str)
221 {
222 vty_out (vty, "%% %s%s", str, VTY_NEWLINE);
223 return CMD_WARNING;
224 }
225 return CMD_SUCCESS;
226}
227
228/* BGP global configuration. */
229
230DEFUN (bgp_multiple_instance_func,
231 bgp_multiple_instance_cmd,
232 "bgp multiple-instance",
233 BGP_STR
234 "Enable bgp multiple instance\n")
235{
236 bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE);
237 return CMD_SUCCESS;
238}
239
240DEFUN (no_bgp_multiple_instance,
241 no_bgp_multiple_instance_cmd,
242 "no bgp multiple-instance",
243 NO_STR
244 BGP_STR
245 "BGP multiple instance\n")
246{
247 int ret;
248
249 ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE);
250 if (ret < 0)
251 {
252 vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE);
253 return CMD_WARNING;
254 }
255 return CMD_SUCCESS;
256}
257
258DEFUN (bgp_config_type,
259 bgp_config_type_cmd,
260 "bgp config-type (cisco|zebra)",
261 BGP_STR
262 "Configuration type\n"
263 "cisco\n"
264 "zebra\n")
265{
266 if (strncmp (argv[0], "c", 1) == 0)
267 bgp_option_set (BGP_OPT_CONFIG_CISCO);
268 else
269 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
270
271 return CMD_SUCCESS;
272}
273
274DEFUN (no_bgp_config_type,
275 no_bgp_config_type_cmd,
276 "no bgp config-type",
277 NO_STR
278 BGP_STR
279 "Display configuration type\n")
280{
281 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
282 return CMD_SUCCESS;
283}
284
285DEFUN (no_synchronization,
286 no_synchronization_cmd,
287 "no synchronization",
288 NO_STR
289 "Perform IGP synchronization\n")
290{
291 return CMD_SUCCESS;
292}
293
294DEFUN (no_auto_summary,
295 no_auto_summary_cmd,
296 "no auto-summary",
297 NO_STR
298 "Enable automatic network number summarization\n")
299{
300 return CMD_SUCCESS;
301}
hasso3d515fd2005-02-01 21:30:04 +0000302
303DEFUN_DEPRECATED (neighbor_version,
304 neighbor_version_cmd,
305 NEIGHBOR_CMD "version (4|4-)",
306 NEIGHBOR_STR
307 NEIGHBOR_ADDR_STR
308 "Set the BGP version to match a neighbor\n"
309 "Neighbor's BGP version\n")
310{
311 return CMD_SUCCESS;
312}
paul718e3742002-12-13 20:15:29 +0000313
314/* "router bgp" commands. */
315DEFUN (router_bgp,
316 router_bgp_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000317 "router bgp " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +0000318 ROUTER_STR
319 BGP_STR
320 AS_STR)
321{
322 int ret;
323 as_t as;
324 struct bgp *bgp;
paulfd79ac92004-10-13 05:06:08 +0000325 const char *name = NULL;
paul718e3742002-12-13 20:15:29 +0000326
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000327 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
paul718e3742002-12-13 20:15:29 +0000328
329 if (argc == 2)
330 name = argv[1];
331
332 ret = bgp_get (&bgp, &as, name);
333 switch (ret)
334 {
335 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET:
336 vty_out (vty, "Please specify 'bgp multiple-instance' first%s",
337 VTY_NEWLINE);
338 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +0000339 case BGP_ERR_AS_MISMATCH:
Denis Ovsienkoaea339f2009-04-30 17:16:22 +0400340 vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +0000341 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +0000342 case BGP_ERR_INSTANCE_MISMATCH:
343 vty_out (vty, "BGP view name and AS number mismatch%s", VTY_NEWLINE);
Denis Ovsienkoaea339f2009-04-30 17:16:22 +0400344 vty_out (vty, "BGP instance is already running; AS is %u%s",
paul718e3742002-12-13 20:15:29 +0000345 as, VTY_NEWLINE);
346 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +0000347 }
348
349 vty->node = BGP_NODE;
350 vty->index = bgp;
351
352 return CMD_SUCCESS;
353}
354
355ALIAS (router_bgp,
356 router_bgp_view_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000357 "router bgp " CMD_AS_RANGE " view WORD",
paul718e3742002-12-13 20:15:29 +0000358 ROUTER_STR
359 BGP_STR
360 AS_STR
361 "BGP view\n"
362 "view name\n")
363
364/* "no router bgp" commands. */
365DEFUN (no_router_bgp,
366 no_router_bgp_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000367 "no router bgp " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +0000368 NO_STR
369 ROUTER_STR
370 BGP_STR
371 AS_STR)
372{
373 as_t as;
374 struct bgp *bgp;
paulfd79ac92004-10-13 05:06:08 +0000375 const char *name = NULL;
paul718e3742002-12-13 20:15:29 +0000376
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000377 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
paul718e3742002-12-13 20:15:29 +0000378
379 if (argc == 2)
380 name = argv[1];
381
382 /* Lookup bgp structure. */
383 bgp = bgp_lookup (as, name);
384 if (! bgp)
385 {
386 vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE);
387 return CMD_WARNING;
388 }
389
390 bgp_delete (bgp);
391
392 return CMD_SUCCESS;
393}
394
395ALIAS (no_router_bgp,
396 no_router_bgp_view_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000397 "no router bgp " CMD_AS_RANGE " view WORD",
paul718e3742002-12-13 20:15:29 +0000398 NO_STR
399 ROUTER_STR
400 BGP_STR
401 AS_STR
402 "BGP view\n"
403 "view name\n")
404
405/* BGP router-id. */
406
407DEFUN (bgp_router_id,
408 bgp_router_id_cmd,
409 "bgp router-id A.B.C.D",
410 BGP_STR
411 "Override configured router identifier\n"
412 "Manually configured router identifier\n")
413{
414 int ret;
415 struct in_addr id;
416 struct bgp *bgp;
417
418 bgp = vty->index;
419
420 ret = inet_aton (argv[0], &id);
421 if (! ret)
422 {
423 vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE);
424 return CMD_WARNING;
425 }
426
hasso18a6dce2004-10-03 18:18:34 +0000427 bgp->router_id_static = id;
paul718e3742002-12-13 20:15:29 +0000428 bgp_router_id_set (bgp, &id);
429
430 return CMD_SUCCESS;
431}
432
433DEFUN (no_bgp_router_id,
434 no_bgp_router_id_cmd,
435 "no bgp router-id",
436 NO_STR
437 BGP_STR
438 "Override configured router identifier\n")
439{
440 int ret;
441 struct in_addr id;
442 struct bgp *bgp;
443
444 bgp = vty->index;
445
446 if (argc == 1)
447 {
448 ret = inet_aton (argv[0], &id);
449 if (! ret)
450 {
451 vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE);
452 return CMD_WARNING;
453 }
454
hasso18a6dce2004-10-03 18:18:34 +0000455 if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id))
paul718e3742002-12-13 20:15:29 +0000456 {
457 vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE);
458 return CMD_WARNING;
459 }
460 }
461
hasso18a6dce2004-10-03 18:18:34 +0000462 bgp->router_id_static.s_addr = 0;
463 bgp_router_id_set (bgp, &router_id_zebra);
paul718e3742002-12-13 20:15:29 +0000464
465 return CMD_SUCCESS;
466}
467
468ALIAS (no_bgp_router_id,
469 no_bgp_router_id_val_cmd,
470 "no bgp router-id A.B.C.D",
471 NO_STR
472 BGP_STR
473 "Override configured router identifier\n"
474 "Manually configured router identifier\n")
475
476/* BGP Cluster ID. */
477
478DEFUN (bgp_cluster_id,
479 bgp_cluster_id_cmd,
480 "bgp cluster-id A.B.C.D",
481 BGP_STR
482 "Configure Route-Reflector Cluster-id\n"
483 "Route-Reflector Cluster-id in IP address format\n")
484{
485 int ret;
486 struct bgp *bgp;
487 struct in_addr cluster;
488
489 bgp = vty->index;
490
491 ret = inet_aton (argv[0], &cluster);
492 if (! ret)
493 {
494 vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
495 return CMD_WARNING;
496 }
497
498 bgp_cluster_id_set (bgp, &cluster);
499
500 return CMD_SUCCESS;
501}
502
503ALIAS (bgp_cluster_id,
504 bgp_cluster_id32_cmd,
505 "bgp cluster-id <1-4294967295>",
506 BGP_STR
507 "Configure Route-Reflector Cluster-id\n"
508 "Route-Reflector Cluster-id as 32 bit quantity\n")
509
510DEFUN (no_bgp_cluster_id,
511 no_bgp_cluster_id_cmd,
512 "no bgp cluster-id",
513 NO_STR
514 BGP_STR
515 "Configure Route-Reflector Cluster-id\n")
516{
517 int ret;
518 struct bgp *bgp;
519 struct in_addr cluster;
520
521 bgp = vty->index;
522
523 if (argc == 1)
524 {
525 ret = inet_aton (argv[0], &cluster);
526 if (! ret)
527 {
528 vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
529 return CMD_WARNING;
530 }
531 }
532
533 bgp_cluster_id_unset (bgp);
534
535 return CMD_SUCCESS;
536}
537
538ALIAS (no_bgp_cluster_id,
539 no_bgp_cluster_id_arg_cmd,
540 "no bgp cluster-id A.B.C.D",
541 NO_STR
542 BGP_STR
543 "Configure Route-Reflector Cluster-id\n"
544 "Route-Reflector Cluster-id in IP address format\n")
545
546DEFUN (bgp_confederation_identifier,
547 bgp_confederation_identifier_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000548 "bgp confederation identifier " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +0000549 "BGP specific commands\n"
550 "AS confederation parameters\n"
551 "AS number\n"
552 "Set routing domain confederation AS\n")
553{
554 struct bgp *bgp;
555 as_t as;
556
557 bgp = vty->index;
558
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000559 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
paul718e3742002-12-13 20:15:29 +0000560
561 bgp_confederation_id_set (bgp, as);
562
563 return CMD_SUCCESS;
564}
565
566DEFUN (no_bgp_confederation_identifier,
567 no_bgp_confederation_identifier_cmd,
568 "no bgp confederation identifier",
569 NO_STR
570 "BGP specific commands\n"
571 "AS confederation parameters\n"
572 "AS number\n")
573{
574 struct bgp *bgp;
575 as_t as;
576
577 bgp = vty->index;
578
579 if (argc == 1)
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000580 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
paul718e3742002-12-13 20:15:29 +0000581
582 bgp_confederation_id_unset (bgp);
583
584 return CMD_SUCCESS;
585}
586
587ALIAS (no_bgp_confederation_identifier,
588 no_bgp_confederation_identifier_arg_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000589 "no bgp confederation identifier " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +0000590 NO_STR
591 "BGP specific commands\n"
592 "AS confederation parameters\n"
593 "AS number\n"
594 "Set routing domain confederation AS\n")
595
596DEFUN (bgp_confederation_peers,
597 bgp_confederation_peers_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000598 "bgp confederation peers ." CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +0000599 "BGP specific commands\n"
600 "AS confederation parameters\n"
601 "Peer ASs in BGP confederation\n"
602 AS_STR)
603{
604 struct bgp *bgp;
605 as_t as;
606 int i;
607
608 bgp = vty->index;
609
610 for (i = 0; i < argc; i++)
611 {
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000612 VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX);
paul718e3742002-12-13 20:15:29 +0000613
614 if (bgp->as == as)
615 {
616 vty_out (vty, "%% Local member-AS not allowed in confed peer list%s",
617 VTY_NEWLINE);
618 continue;
619 }
620
621 bgp_confederation_peers_add (bgp, as);
622 }
623 return CMD_SUCCESS;
624}
625
626DEFUN (no_bgp_confederation_peers,
627 no_bgp_confederation_peers_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000628 "no bgp confederation peers ." CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +0000629 NO_STR
630 "BGP specific commands\n"
631 "AS confederation parameters\n"
632 "Peer ASs in BGP confederation\n"
633 AS_STR)
634{
635 struct bgp *bgp;
636 as_t as;
637 int i;
638
639 bgp = vty->index;
640
641 for (i = 0; i < argc; i++)
642 {
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000643 VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX);
644
paul718e3742002-12-13 20:15:29 +0000645 bgp_confederation_peers_remove (bgp, as);
646 }
647 return CMD_SUCCESS;
648}
649
650/* BGP timers. */
651
652DEFUN (bgp_timers,
653 bgp_timers_cmd,
654 "timers bgp <0-65535> <0-65535>",
655 "Adjust routing timers\n"
656 "BGP timers\n"
657 "Keepalive interval\n"
658 "Holdtime\n")
659{
660 struct bgp *bgp;
661 unsigned long keepalive = 0;
662 unsigned long holdtime = 0;
663
664 bgp = vty->index;
665
666 VTY_GET_INTEGER ("keepalive", keepalive, argv[0]);
667 VTY_GET_INTEGER ("holdtime", holdtime, argv[1]);
668
669 /* Holdtime value check. */
670 if (holdtime < 3 && holdtime != 0)
671 {
672 vty_out (vty, "%% hold time value must be either 0 or greater than 3%s",
673 VTY_NEWLINE);
674 return CMD_WARNING;
675 }
676
677 bgp_timers_set (bgp, keepalive, holdtime);
678
679 return CMD_SUCCESS;
680}
681
682DEFUN (no_bgp_timers,
683 no_bgp_timers_cmd,
684 "no timers bgp",
685 NO_STR
686 "Adjust routing timers\n"
687 "BGP timers\n")
688{
689 struct bgp *bgp;
690
691 bgp = vty->index;
692 bgp_timers_unset (bgp);
693
694 return CMD_SUCCESS;
695}
696
697ALIAS (no_bgp_timers,
698 no_bgp_timers_arg_cmd,
699 "no timers bgp <0-65535> <0-65535>",
700 NO_STR
701 "Adjust routing timers\n"
702 "BGP timers\n"
703 "Keepalive interval\n"
704 "Holdtime\n")
705
706DEFUN (bgp_client_to_client_reflection,
707 bgp_client_to_client_reflection_cmd,
708 "bgp client-to-client reflection",
709 "BGP specific commands\n"
710 "Configure client to client route reflection\n"
711 "reflection of routes allowed\n")
712{
713 struct bgp *bgp;
714
715 bgp = vty->index;
716 bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
717 return CMD_SUCCESS;
718}
719
720DEFUN (no_bgp_client_to_client_reflection,
721 no_bgp_client_to_client_reflection_cmd,
722 "no bgp client-to-client reflection",
723 NO_STR
724 "BGP specific commands\n"
725 "Configure client to client route reflection\n"
726 "reflection of routes allowed\n")
727{
728 struct bgp *bgp;
729
730 bgp = vty->index;
731 bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
732 return CMD_SUCCESS;
733}
734
735/* "bgp always-compare-med" configuration. */
736DEFUN (bgp_always_compare_med,
737 bgp_always_compare_med_cmd,
738 "bgp always-compare-med",
739 "BGP specific commands\n"
740 "Allow comparing MED from different neighbors\n")
741{
742 struct bgp *bgp;
743
744 bgp = vty->index;
745 bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
746 return CMD_SUCCESS;
747}
748
749DEFUN (no_bgp_always_compare_med,
750 no_bgp_always_compare_med_cmd,
751 "no bgp always-compare-med",
752 NO_STR
753 "BGP specific commands\n"
754 "Allow comparing MED from different neighbors\n")
755{
756 struct bgp *bgp;
757
758 bgp = vty->index;
759 bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
760 return CMD_SUCCESS;
761}
762
763/* "bgp deterministic-med" configuration. */
764DEFUN (bgp_deterministic_med,
765 bgp_deterministic_med_cmd,
766 "bgp deterministic-med",
767 "BGP specific commands\n"
768 "Pick the best-MED path among paths advertised from the neighboring AS\n")
769{
770 struct bgp *bgp;
771
772 bgp = vty->index;
773 bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED);
774 return CMD_SUCCESS;
775}
776
777DEFUN (no_bgp_deterministic_med,
778 no_bgp_deterministic_med_cmd,
779 "no bgp deterministic-med",
780 NO_STR
781 "BGP specific commands\n"
782 "Pick the best-MED path among paths advertised from the neighboring AS\n")
783{
784 struct bgp *bgp;
785
786 bgp = vty->index;
787 bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED);
788 return CMD_SUCCESS;
789}
hasso538621f2004-05-21 09:31:30 +0000790
791/* "bgp graceful-restart" configuration. */
792DEFUN (bgp_graceful_restart,
793 bgp_graceful_restart_cmd,
794 "bgp graceful-restart",
795 "BGP specific commands\n"
796 "Graceful restart capability parameters\n")
797{
798 struct bgp *bgp;
799
800 bgp = vty->index;
801 bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART);
802 return CMD_SUCCESS;
803}
804
805DEFUN (no_bgp_graceful_restart,
806 no_bgp_graceful_restart_cmd,
807 "no bgp graceful-restart",
808 NO_STR
809 "BGP specific commands\n"
810 "Graceful restart capability parameters\n")
811{
812 struct bgp *bgp;
813
814 bgp = vty->index;
815 bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART);
816 return CMD_SUCCESS;
817}
818
hasso93406d82005-02-02 14:40:33 +0000819DEFUN (bgp_graceful_restart_stalepath_time,
820 bgp_graceful_restart_stalepath_time_cmd,
821 "bgp graceful-restart stalepath-time <1-3600>",
822 "BGP specific commands\n"
823 "Graceful restart capability parameters\n"
824 "Set the max time to hold onto restarting peer's stale paths\n"
825 "Delay value (seconds)\n")
826{
827 struct bgp *bgp;
828 u_int32_t stalepath;
829
830 bgp = vty->index;
831 if (! bgp)
832 return CMD_WARNING;
833
834 VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[0], 1, 3600);
835 bgp->stalepath_time = stalepath;
836 return CMD_SUCCESS;
837}
838
839DEFUN (no_bgp_graceful_restart_stalepath_time,
840 no_bgp_graceful_restart_stalepath_time_cmd,
841 "no bgp graceful-restart stalepath-time",
842 NO_STR
843 "BGP specific commands\n"
844 "Graceful restart capability parameters\n"
845 "Set the max time to hold onto restarting peer's stale paths\n")
846{
847 struct bgp *bgp;
848
849 bgp = vty->index;
850 if (! bgp)
851 return CMD_WARNING;
852
853 bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME;
854 return CMD_SUCCESS;
855}
856
857ALIAS (no_bgp_graceful_restart_stalepath_time,
858 no_bgp_graceful_restart_stalepath_time_val_cmd,
859 "no bgp graceful-restart stalepath-time <1-3600>",
860 NO_STR
861 "BGP specific commands\n"
862 "Graceful restart capability parameters\n"
863 "Set the max time to hold onto restarting peer's stale paths\n"
864 "Delay value (seconds)\n")
865
paul718e3742002-12-13 20:15:29 +0000866/* "bgp fast-external-failover" configuration. */
867DEFUN (bgp_fast_external_failover,
868 bgp_fast_external_failover_cmd,
869 "bgp fast-external-failover",
870 BGP_STR
871 "Immediately reset session if a link to a directly connected external peer goes down\n")
872{
873 struct bgp *bgp;
874
875 bgp = vty->index;
876 bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
877 return CMD_SUCCESS;
878}
879
880DEFUN (no_bgp_fast_external_failover,
881 no_bgp_fast_external_failover_cmd,
882 "no bgp fast-external-failover",
883 NO_STR
884 BGP_STR
885 "Immediately reset session if a link to a directly connected external peer goes down\n")
886{
887 struct bgp *bgp;
888
889 bgp = vty->index;
890 bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
891 return CMD_SUCCESS;
892}
893
894/* "bgp enforce-first-as" configuration. */
895DEFUN (bgp_enforce_first_as,
896 bgp_enforce_first_as_cmd,
897 "bgp enforce-first-as",
898 BGP_STR
899 "Enforce the first AS for EBGP routes\n")
900{
901 struct bgp *bgp;
902
903 bgp = vty->index;
904 bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
905 return CMD_SUCCESS;
906}
907
908DEFUN (no_bgp_enforce_first_as,
909 no_bgp_enforce_first_as_cmd,
910 "no bgp enforce-first-as",
911 NO_STR
912 BGP_STR
913 "Enforce the first AS for EBGP routes\n")
914{
915 struct bgp *bgp;
916
917 bgp = vty->index;
918 bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
919 return CMD_SUCCESS;
920}
921
922/* "bgp bestpath compare-routerid" configuration. */
923DEFUN (bgp_bestpath_compare_router_id,
924 bgp_bestpath_compare_router_id_cmd,
925 "bgp bestpath compare-routerid",
926 "BGP specific commands\n"
927 "Change the default bestpath selection\n"
928 "Compare router-id for identical EBGP paths\n")
929{
930 struct bgp *bgp;
931
932 bgp = vty->index;
933 bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
934 return CMD_SUCCESS;
935}
936
937DEFUN (no_bgp_bestpath_compare_router_id,
938 no_bgp_bestpath_compare_router_id_cmd,
939 "no bgp bestpath compare-routerid",
940 NO_STR
941 "BGP specific commands\n"
942 "Change the default bestpath selection\n"
943 "Compare router-id for identical EBGP paths\n")
944{
945 struct bgp *bgp;
946
947 bgp = vty->index;
948 bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
949 return CMD_SUCCESS;
950}
951
952/* "bgp bestpath as-path ignore" configuration. */
953DEFUN (bgp_bestpath_aspath_ignore,
954 bgp_bestpath_aspath_ignore_cmd,
955 "bgp bestpath as-path ignore",
956 "BGP specific commands\n"
957 "Change the default bestpath selection\n"
958 "AS-path attribute\n"
959 "Ignore as-path length in selecting a route\n")
960{
961 struct bgp *bgp;
962
963 bgp = vty->index;
964 bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE);
965 return CMD_SUCCESS;
966}
967
968DEFUN (no_bgp_bestpath_aspath_ignore,
969 no_bgp_bestpath_aspath_ignore_cmd,
970 "no bgp bestpath as-path ignore",
971 NO_STR
972 "BGP specific commands\n"
973 "Change the default bestpath selection\n"
974 "AS-path attribute\n"
975 "Ignore as-path length in selecting a route\n")
976{
977 struct bgp *bgp;
978
979 bgp = vty->index;
980 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE);
981 return CMD_SUCCESS;
982}
983
hasso68118452005-04-08 15:40:36 +0000984/* "bgp bestpath as-path confed" configuration. */
985DEFUN (bgp_bestpath_aspath_confed,
986 bgp_bestpath_aspath_confed_cmd,
987 "bgp bestpath as-path confed",
988 "BGP specific commands\n"
989 "Change the default bestpath selection\n"
990 "AS-path attribute\n"
991 "Compare path lengths including confederation sets & sequences in selecting a route\n")
992{
993 struct bgp *bgp;
994
995 bgp = vty->index;
996 bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED);
997 return CMD_SUCCESS;
998}
999
1000DEFUN (no_bgp_bestpath_aspath_confed,
1001 no_bgp_bestpath_aspath_confed_cmd,
1002 "no bgp bestpath as-path confed",
1003 NO_STR
1004 "BGP specific commands\n"
1005 "Change the default bestpath selection\n"
1006 "AS-path attribute\n"
1007 "Compare path lengths including confederation sets & sequences in selecting a route\n")
1008{
1009 struct bgp *bgp;
1010
1011 bgp = vty->index;
1012 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED);
1013 return CMD_SUCCESS;
1014}
1015
paul848973c2003-08-13 00:32:49 +00001016/* "bgp log-neighbor-changes" configuration. */
1017DEFUN (bgp_log_neighbor_changes,
1018 bgp_log_neighbor_changes_cmd,
1019 "bgp log-neighbor-changes",
1020 "BGP specific commands\n"
1021 "Log neighbor up/down and reset reason\n")
1022{
1023 struct bgp *bgp;
1024
1025 bgp = vty->index;
1026 bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
1027 return CMD_SUCCESS;
1028}
1029
1030DEFUN (no_bgp_log_neighbor_changes,
1031 no_bgp_log_neighbor_changes_cmd,
1032 "no bgp log-neighbor-changes",
1033 NO_STR
1034 "BGP specific commands\n"
1035 "Log neighbor up/down and reset reason\n")
1036{
1037 struct bgp *bgp;
1038
1039 bgp = vty->index;
1040 bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
1041 return CMD_SUCCESS;
1042}
1043
paul718e3742002-12-13 20:15:29 +00001044/* "bgp bestpath med" configuration. */
1045DEFUN (bgp_bestpath_med,
1046 bgp_bestpath_med_cmd,
1047 "bgp bestpath med (confed|missing-as-worst)",
1048 "BGP specific commands\n"
1049 "Change the default bestpath selection\n"
1050 "MED attribute\n"
1051 "Compare MED among confederation paths\n"
1052 "Treat missing MED as the least preferred one\n")
1053{
1054 struct bgp *bgp;
1055
1056 bgp = vty->index;
1057
1058 if (strncmp (argv[0], "confed", 1) == 0)
1059 bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
1060 else
1061 bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1062
1063 return CMD_SUCCESS;
1064}
1065
1066DEFUN (bgp_bestpath_med2,
1067 bgp_bestpath_med2_cmd,
1068 "bgp bestpath med confed missing-as-worst",
1069 "BGP specific commands\n"
1070 "Change the default bestpath selection\n"
1071 "MED attribute\n"
1072 "Compare MED among confederation paths\n"
1073 "Treat missing MED as the least preferred one\n")
1074{
1075 struct bgp *bgp;
1076
1077 bgp = vty->index;
1078 bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
1079 bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1080 return CMD_SUCCESS;
1081}
1082
1083ALIAS (bgp_bestpath_med2,
1084 bgp_bestpath_med3_cmd,
1085 "bgp bestpath med missing-as-worst confed",
1086 "BGP specific commands\n"
1087 "Change the default bestpath selection\n"
1088 "MED attribute\n"
1089 "Treat missing MED as the least preferred one\n"
1090 "Compare MED among confederation paths\n")
1091
1092DEFUN (no_bgp_bestpath_med,
1093 no_bgp_bestpath_med_cmd,
1094 "no bgp bestpath med (confed|missing-as-worst)",
1095 NO_STR
1096 "BGP specific commands\n"
1097 "Change the default bestpath selection\n"
1098 "MED attribute\n"
1099 "Compare MED among confederation paths\n"
1100 "Treat missing MED as the least preferred one\n")
1101{
1102 struct bgp *bgp;
1103
1104 bgp = vty->index;
1105
1106 if (strncmp (argv[0], "confed", 1) == 0)
1107 bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
1108 else
1109 bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1110
1111 return CMD_SUCCESS;
1112}
1113
1114DEFUN (no_bgp_bestpath_med2,
1115 no_bgp_bestpath_med2_cmd,
1116 "no bgp bestpath med confed missing-as-worst",
1117 NO_STR
1118 "BGP specific commands\n"
1119 "Change the default bestpath selection\n"
1120 "MED attribute\n"
1121 "Compare MED among confederation paths\n"
1122 "Treat missing MED as the least preferred one\n")
1123{
1124 struct bgp *bgp;
1125
1126 bgp = vty->index;
1127 bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
1128 bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1129 return CMD_SUCCESS;
1130}
1131
1132ALIAS (no_bgp_bestpath_med2,
1133 no_bgp_bestpath_med3_cmd,
1134 "no bgp bestpath med missing-as-worst confed",
1135 NO_STR
1136 "BGP specific commands\n"
1137 "Change the default bestpath selection\n"
1138 "MED attribute\n"
1139 "Treat missing MED as the least preferred one\n"
1140 "Compare MED among confederation paths\n")
1141
1142/* "no bgp default ipv4-unicast". */
1143DEFUN (no_bgp_default_ipv4_unicast,
1144 no_bgp_default_ipv4_unicast_cmd,
1145 "no bgp default ipv4-unicast",
1146 NO_STR
1147 "BGP specific commands\n"
1148 "Configure BGP defaults\n"
1149 "Activate ipv4-unicast for a peer by default\n")
1150{
1151 struct bgp *bgp;
1152
1153 bgp = vty->index;
1154 bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
1155 return CMD_SUCCESS;
1156}
1157
1158DEFUN (bgp_default_ipv4_unicast,
1159 bgp_default_ipv4_unicast_cmd,
1160 "bgp default ipv4-unicast",
1161 "BGP specific commands\n"
1162 "Configure BGP defaults\n"
1163 "Activate ipv4-unicast for a peer by default\n")
1164{
1165 struct bgp *bgp;
1166
1167 bgp = vty->index;
1168 bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
1169 return CMD_SUCCESS;
1170}
1171
1172/* "bgp import-check" configuration. */
1173DEFUN (bgp_network_import_check,
1174 bgp_network_import_check_cmd,
1175 "bgp network import-check",
1176 "BGP specific commands\n"
1177 "BGP network command\n"
1178 "Check BGP network route exists in IGP\n")
1179{
1180 struct bgp *bgp;
1181
1182 bgp = vty->index;
1183 bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK);
1184 return CMD_SUCCESS;
1185}
1186
1187DEFUN (no_bgp_network_import_check,
1188 no_bgp_network_import_check_cmd,
1189 "no bgp network import-check",
1190 NO_STR
1191 "BGP specific commands\n"
1192 "BGP network command\n"
1193 "Check BGP network route exists in IGP\n")
1194{
1195 struct bgp *bgp;
1196
1197 bgp = vty->index;
1198 bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK);
1199 return CMD_SUCCESS;
1200}
1201
1202DEFUN (bgp_default_local_preference,
1203 bgp_default_local_preference_cmd,
1204 "bgp default local-preference <0-4294967295>",
1205 "BGP specific commands\n"
1206 "Configure BGP defaults\n"
1207 "local preference (higher=more preferred)\n"
1208 "Configure default local preference value\n")
1209{
1210 struct bgp *bgp;
1211 u_int32_t local_pref;
1212
1213 bgp = vty->index;
1214
1215 VTY_GET_INTEGER ("local preference", local_pref, argv[0]);
1216
1217 bgp_default_local_preference_set (bgp, local_pref);
1218
1219 return CMD_SUCCESS;
1220}
1221
1222DEFUN (no_bgp_default_local_preference,
1223 no_bgp_default_local_preference_cmd,
1224 "no bgp default local-preference",
1225 NO_STR
1226 "BGP specific commands\n"
1227 "Configure BGP defaults\n"
1228 "local preference (higher=more preferred)\n")
1229{
1230 struct bgp *bgp;
1231
1232 bgp = vty->index;
1233 bgp_default_local_preference_unset (bgp);
1234 return CMD_SUCCESS;
1235}
1236
1237ALIAS (no_bgp_default_local_preference,
1238 no_bgp_default_local_preference_val_cmd,
1239 "no bgp default local-preference <0-4294967295>",
1240 NO_STR
1241 "BGP specific commands\n"
1242 "Configure BGP defaults\n"
1243 "local preference (higher=more preferred)\n"
1244 "Configure default local preference value\n")
1245
1246static int
paulfd79ac92004-10-13 05:06:08 +00001247peer_remote_as_vty (struct vty *vty, const char *peer_str,
1248 const char *as_str, afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00001249{
1250 int ret;
1251 struct bgp *bgp;
1252 as_t as;
1253 union sockunion su;
1254
1255 bgp = vty->index;
1256
1257 /* Get AS number. */
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00001258 VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX);
paul718e3742002-12-13 20:15:29 +00001259
1260 /* If peer is peer group, call proper function. */
1261 ret = str2sockunion (peer_str, &su);
1262 if (ret < 0)
1263 {
1264 ret = peer_group_remote_as (bgp, peer_str, &as);
1265 if (ret < 0)
1266 {
1267 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1268 return CMD_WARNING;
1269 }
1270 return CMD_SUCCESS;
1271 }
1272
1273 if (peer_address_self_check (&su))
1274 {
1275 vty_out (vty, "%% Can not configure the local system as neighbor%s",
1276 VTY_NEWLINE);
1277 return CMD_WARNING;
1278 }
1279
1280 ret = peer_remote_as (bgp, &su, &as, afi, safi);
1281
1282 /* This peer belongs to peer group. */
1283 switch (ret)
1284 {
1285 case BGP_ERR_PEER_GROUP_MEMBER:
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04001286 vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001287 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +00001288 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT:
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04001289 vty_out (vty, "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external%s", as, as_str, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001290 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +00001291 }
1292 return bgp_vty_return (vty, ret);
1293}
1294
1295DEFUN (neighbor_remote_as,
1296 neighbor_remote_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001297 NEIGHBOR_CMD2 "remote-as " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00001298 NEIGHBOR_STR
1299 NEIGHBOR_ADDR_STR2
1300 "Specify a BGP neighbor\n"
1301 AS_STR)
1302{
1303 return peer_remote_as_vty (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST);
1304}
1305
1306DEFUN (neighbor_peer_group,
1307 neighbor_peer_group_cmd,
1308 "neighbor WORD peer-group",
1309 NEIGHBOR_STR
1310 "Neighbor tag\n"
1311 "Configure peer-group\n")
1312{
1313 struct bgp *bgp;
1314 struct peer_group *group;
1315
1316 bgp = vty->index;
1317
1318 group = peer_group_get (bgp, argv[0]);
1319 if (! group)
1320 return CMD_WARNING;
1321
1322 return CMD_SUCCESS;
1323}
1324
1325DEFUN (no_neighbor,
1326 no_neighbor_cmd,
1327 NO_NEIGHBOR_CMD2,
1328 NO_STR
1329 NEIGHBOR_STR
1330 NEIGHBOR_ADDR_STR2)
1331{
1332 int ret;
1333 union sockunion su;
1334 struct peer_group *group;
1335 struct peer *peer;
1336
1337 ret = str2sockunion (argv[0], &su);
1338 if (ret < 0)
1339 {
1340 group = peer_group_lookup (vty->index, argv[0]);
1341 if (group)
1342 peer_group_delete (group);
1343 else
1344 {
1345 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1346 return CMD_WARNING;
1347 }
1348 }
1349 else
1350 {
1351 peer = peer_lookup (vty->index, &su);
1352 if (peer)
paul200df112005-06-01 11:17:05 +00001353 peer_delete (peer);
paul718e3742002-12-13 20:15:29 +00001354 }
1355
1356 return CMD_SUCCESS;
1357}
1358
1359ALIAS (no_neighbor,
1360 no_neighbor_remote_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001361 NO_NEIGHBOR_CMD "remote-as " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00001362 NO_STR
1363 NEIGHBOR_STR
1364 NEIGHBOR_ADDR_STR
1365 "Specify a BGP neighbor\n"
1366 AS_STR)
1367
1368DEFUN (no_neighbor_peer_group,
1369 no_neighbor_peer_group_cmd,
1370 "no neighbor WORD peer-group",
1371 NO_STR
1372 NEIGHBOR_STR
1373 "Neighbor tag\n"
1374 "Configure peer-group\n")
1375{
1376 struct peer_group *group;
1377
1378 group = peer_group_lookup (vty->index, argv[0]);
1379 if (group)
1380 peer_group_delete (group);
1381 else
1382 {
1383 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1384 return CMD_WARNING;
1385 }
1386 return CMD_SUCCESS;
1387}
1388
1389DEFUN (no_neighbor_peer_group_remote_as,
1390 no_neighbor_peer_group_remote_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001391 "no neighbor WORD remote-as " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00001392 NO_STR
1393 NEIGHBOR_STR
1394 "Neighbor tag\n"
1395 "Specify a BGP neighbor\n"
1396 AS_STR)
1397{
1398 struct peer_group *group;
1399
1400 group = peer_group_lookup (vty->index, argv[0]);
1401 if (group)
1402 peer_group_remote_as_delete (group);
1403 else
1404 {
1405 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1406 return CMD_WARNING;
1407 }
1408 return CMD_SUCCESS;
1409}
1410
1411DEFUN (neighbor_local_as,
1412 neighbor_local_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001413 NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00001414 NEIGHBOR_STR
1415 NEIGHBOR_ADDR_STR2
1416 "Specify a local-as number\n"
1417 "AS number used as local AS\n")
1418{
1419 struct peer *peer;
1420 int ret;
1421
1422 peer = peer_and_group_lookup_vty (vty, argv[0]);
1423 if (! peer)
1424 return CMD_WARNING;
1425
1426 ret = peer_local_as_set (peer, atoi (argv[1]), 0);
1427 return bgp_vty_return (vty, ret);
1428}
1429
1430DEFUN (neighbor_local_as_no_prepend,
1431 neighbor_local_as_no_prepend_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001432 NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
paul718e3742002-12-13 20:15:29 +00001433 NEIGHBOR_STR
1434 NEIGHBOR_ADDR_STR2
1435 "Specify a local-as number\n"
1436 "AS number used as local AS\n"
1437 "Do not prepend local-as to updates from ebgp peers\n")
1438{
1439 struct peer *peer;
1440 int ret;
1441
1442 peer = peer_and_group_lookup_vty (vty, argv[0]);
1443 if (! peer)
1444 return CMD_WARNING;
1445
1446 ret = peer_local_as_set (peer, atoi (argv[1]), 1);
1447 return bgp_vty_return (vty, ret);
1448}
1449
1450DEFUN (no_neighbor_local_as,
1451 no_neighbor_local_as_cmd,
1452 NO_NEIGHBOR_CMD2 "local-as",
1453 NO_STR
1454 NEIGHBOR_STR
1455 NEIGHBOR_ADDR_STR2
1456 "Specify a local-as number\n")
1457{
1458 struct peer *peer;
1459 int ret;
1460
1461 peer = peer_and_group_lookup_vty (vty, argv[0]);
1462 if (! peer)
1463 return CMD_WARNING;
1464
1465 ret = peer_local_as_unset (peer);
1466 return bgp_vty_return (vty, ret);
1467}
1468
1469ALIAS (no_neighbor_local_as,
1470 no_neighbor_local_as_val_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001471 NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00001472 NO_STR
1473 NEIGHBOR_STR
1474 NEIGHBOR_ADDR_STR2
1475 "Specify a local-as number\n"
1476 "AS number used as local AS\n")
1477
1478ALIAS (no_neighbor_local_as,
1479 no_neighbor_local_as_val2_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001480 NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
paul718e3742002-12-13 20:15:29 +00001481 NO_STR
1482 NEIGHBOR_STR
1483 NEIGHBOR_ADDR_STR2
1484 "Specify a local-as number\n"
1485 "AS number used as local AS\n"
1486 "Do not prepend local-as to updates from ebgp peers\n")
1487
Paul Jakma0df7c912008-07-21 21:02:49 +00001488DEFUN (neighbor_password,
1489 neighbor_password_cmd,
1490 NEIGHBOR_CMD2 "password LINE",
1491 NEIGHBOR_STR
1492 NEIGHBOR_ADDR_STR2
1493 "Set a password\n"
1494 "The password\n")
1495{
1496 struct peer *peer;
1497 int ret;
1498
1499 peer = peer_and_group_lookup_vty (vty, argv[0]);
1500 if (! peer)
1501 return CMD_WARNING;
1502
1503 ret = peer_password_set (peer, argv[1]);
1504 return bgp_vty_return (vty, ret);
1505}
1506
1507DEFUN (no_neighbor_password,
1508 no_neighbor_password_cmd,
1509 NO_NEIGHBOR_CMD2 "password",
1510 NO_STR
1511 NEIGHBOR_STR
1512 NEIGHBOR_ADDR_STR2
1513 "Set a password\n")
1514{
1515 struct peer *peer;
1516 int ret;
1517
1518 peer = peer_and_group_lookup_vty (vty, argv[0]);
1519 if (! peer)
1520 return CMD_WARNING;
1521
1522 ret = peer_password_unset (peer);
1523 return bgp_vty_return (vty, ret);
1524}
1525
paul718e3742002-12-13 20:15:29 +00001526DEFUN (neighbor_activate,
1527 neighbor_activate_cmd,
1528 NEIGHBOR_CMD2 "activate",
1529 NEIGHBOR_STR
1530 NEIGHBOR_ADDR_STR2
1531 "Enable the Address Family for this Neighbor\n")
1532{
1533 struct peer *peer;
1534
1535 peer = peer_and_group_lookup_vty (vty, argv[0]);
1536 if (! peer)
1537 return CMD_WARNING;
1538
1539 peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
1540
1541 return CMD_SUCCESS;
1542}
1543
1544DEFUN (no_neighbor_activate,
1545 no_neighbor_activate_cmd,
1546 NO_NEIGHBOR_CMD2 "activate",
1547 NO_STR
1548 NEIGHBOR_STR
1549 NEIGHBOR_ADDR_STR2
1550 "Enable the Address Family for this Neighbor\n")
1551{
1552 int ret;
1553 struct peer *peer;
1554
1555 /* Lookup peer. */
1556 peer = peer_and_group_lookup_vty (vty, argv[0]);
1557 if (! peer)
1558 return CMD_WARNING;
1559
1560 ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
1561
1562 return bgp_vty_return (vty, ret);
1563}
1564
1565DEFUN (neighbor_set_peer_group,
1566 neighbor_set_peer_group_cmd,
1567 NEIGHBOR_CMD "peer-group WORD",
1568 NEIGHBOR_STR
1569 NEIGHBOR_ADDR_STR
1570 "Member of the peer-group\n"
1571 "peer-group name\n")
1572{
1573 int ret;
1574 as_t as;
1575 union sockunion su;
1576 struct bgp *bgp;
1577 struct peer_group *group;
1578
1579 bgp = vty->index;
1580
1581 ret = str2sockunion (argv[0], &su);
1582 if (ret < 0)
1583 {
1584 vty_out (vty, "%% Malformed address: %s%s", argv[0], VTY_NEWLINE);
1585 return CMD_WARNING;
1586 }
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 if (peer_address_self_check (&su))
1596 {
1597 vty_out (vty, "%% Can not configure the local system as neighbor%s",
1598 VTY_NEWLINE);
1599 return CMD_WARNING;
1600 }
1601
1602 ret = peer_group_bind (bgp, &su, group, bgp_node_afi (vty),
1603 bgp_node_safi (vty), &as);
1604
1605 if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT)
1606 {
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04001607 vty_out (vty, "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external%s", as, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001608 return CMD_WARNING;
1609 }
1610
1611 return bgp_vty_return (vty, ret);
1612}
1613
1614DEFUN (no_neighbor_set_peer_group,
1615 no_neighbor_set_peer_group_cmd,
1616 NO_NEIGHBOR_CMD "peer-group WORD",
1617 NO_STR
1618 NEIGHBOR_STR
1619 NEIGHBOR_ADDR_STR
1620 "Member of the peer-group\n"
1621 "peer-group name\n")
1622{
1623 int ret;
1624 struct bgp *bgp;
1625 struct peer *peer;
1626 struct peer_group *group;
1627
1628 bgp = vty->index;
1629
1630 peer = peer_lookup_vty (vty, argv[0]);
1631 if (! peer)
1632 return CMD_WARNING;
1633
1634 group = peer_group_lookup (bgp, argv[1]);
1635 if (! group)
1636 {
1637 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
1638 return CMD_WARNING;
1639 }
1640
1641 ret = peer_group_unbind (bgp, peer, group, bgp_node_afi (vty),
1642 bgp_node_safi (vty));
1643
1644 return bgp_vty_return (vty, ret);
1645}
1646
paul94f2b392005-06-28 12:44:16 +00001647static int
paulfd79ac92004-10-13 05:06:08 +00001648peer_flag_modify_vty (struct vty *vty, const char *ip_str,
1649 u_int16_t flag, int set)
paul718e3742002-12-13 20:15:29 +00001650{
1651 int ret;
1652 struct peer *peer;
1653
1654 peer = peer_and_group_lookup_vty (vty, ip_str);
1655 if (! peer)
1656 return CMD_WARNING;
1657
1658 if (set)
1659 ret = peer_flag_set (peer, flag);
1660 else
1661 ret = peer_flag_unset (peer, flag);
1662
1663 return bgp_vty_return (vty, ret);
1664}
1665
paul94f2b392005-06-28 12:44:16 +00001666static int
paulfd79ac92004-10-13 05:06:08 +00001667peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
paul718e3742002-12-13 20:15:29 +00001668{
1669 return peer_flag_modify_vty (vty, ip_str, flag, 1);
1670}
1671
paul94f2b392005-06-28 12:44:16 +00001672static int
paulfd79ac92004-10-13 05:06:08 +00001673peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
paul718e3742002-12-13 20:15:29 +00001674{
1675 return peer_flag_modify_vty (vty, ip_str, flag, 0);
1676}
1677
1678/* neighbor passive. */
1679DEFUN (neighbor_passive,
1680 neighbor_passive_cmd,
1681 NEIGHBOR_CMD2 "passive",
1682 NEIGHBOR_STR
1683 NEIGHBOR_ADDR_STR2
1684 "Don't send open messages to this neighbor\n")
1685{
1686 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_PASSIVE);
1687}
1688
1689DEFUN (no_neighbor_passive,
1690 no_neighbor_passive_cmd,
1691 NO_NEIGHBOR_CMD2 "passive",
1692 NO_STR
1693 NEIGHBOR_STR
1694 NEIGHBOR_ADDR_STR2
1695 "Don't send open messages to this neighbor\n")
1696{
1697 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_PASSIVE);
1698}
1699
1700/* neighbor shutdown. */
1701DEFUN (neighbor_shutdown,
1702 neighbor_shutdown_cmd,
1703 NEIGHBOR_CMD2 "shutdown",
1704 NEIGHBOR_STR
1705 NEIGHBOR_ADDR_STR2
1706 "Administratively shut down this neighbor\n")
1707{
1708 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
1709}
1710
1711DEFUN (no_neighbor_shutdown,
1712 no_neighbor_shutdown_cmd,
1713 NO_NEIGHBOR_CMD2 "shutdown",
1714 NO_STR
1715 NEIGHBOR_STR
1716 NEIGHBOR_ADDR_STR2
1717 "Administratively shut down this neighbor\n")
1718{
1719 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
1720}
1721
hassoc9502432005-02-01 22:01:48 +00001722/* Deprecated neighbor capability route-refresh. */
1723DEFUN_DEPRECATED (neighbor_capability_route_refresh,
1724 neighbor_capability_route_refresh_cmd,
1725 NEIGHBOR_CMD2 "capability route-refresh",
1726 NEIGHBOR_STR
1727 NEIGHBOR_ADDR_STR2
1728 "Advertise capability to the peer\n"
1729 "Advertise route-refresh capability to this neighbor\n")
paul718e3742002-12-13 20:15:29 +00001730{
hassoc9502432005-02-01 22:01:48 +00001731 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00001732}
1733
hassoc9502432005-02-01 22:01:48 +00001734DEFUN_DEPRECATED (no_neighbor_capability_route_refresh,
1735 no_neighbor_capability_route_refresh_cmd,
1736 NO_NEIGHBOR_CMD2 "capability route-refresh",
1737 NO_STR
1738 NEIGHBOR_STR
1739 NEIGHBOR_ADDR_STR2
1740 "Advertise capability to the peer\n"
1741 "Advertise route-refresh capability to this neighbor\n")
paul718e3742002-12-13 20:15:29 +00001742{
hassoc9502432005-02-01 22:01:48 +00001743 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00001744}
1745
1746/* neighbor capability dynamic. */
1747DEFUN (neighbor_capability_dynamic,
1748 neighbor_capability_dynamic_cmd,
1749 NEIGHBOR_CMD2 "capability dynamic",
1750 NEIGHBOR_STR
1751 NEIGHBOR_ADDR_STR2
1752 "Advertise capability to the peer\n"
1753 "Advertise dynamic capability to this neighbor\n")
1754{
1755 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
1756}
1757
1758DEFUN (no_neighbor_capability_dynamic,
1759 no_neighbor_capability_dynamic_cmd,
1760 NO_NEIGHBOR_CMD2 "capability dynamic",
1761 NO_STR
1762 NEIGHBOR_STR
1763 NEIGHBOR_ADDR_STR2
1764 "Advertise capability to the peer\n"
1765 "Advertise dynamic capability to this neighbor\n")
1766{
1767 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
1768}
1769
1770/* neighbor dont-capability-negotiate */
1771DEFUN (neighbor_dont_capability_negotiate,
1772 neighbor_dont_capability_negotiate_cmd,
1773 NEIGHBOR_CMD2 "dont-capability-negotiate",
1774 NEIGHBOR_STR
1775 NEIGHBOR_ADDR_STR2
1776 "Do not perform capability negotiation\n")
1777{
1778 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
1779}
1780
1781DEFUN (no_neighbor_dont_capability_negotiate,
1782 no_neighbor_dont_capability_negotiate_cmd,
1783 NO_NEIGHBOR_CMD2 "dont-capability-negotiate",
1784 NO_STR
1785 NEIGHBOR_STR
1786 NEIGHBOR_ADDR_STR2
1787 "Do not perform capability negotiation\n")
1788{
1789 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
1790}
1791
paul94f2b392005-06-28 12:44:16 +00001792static int
paulfd79ac92004-10-13 05:06:08 +00001793peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi,
paulfee0f4c2004-09-13 05:12:46 +00001794 safi_t safi, u_int32_t flag, int set)
paul718e3742002-12-13 20:15:29 +00001795{
1796 int ret;
1797 struct peer *peer;
1798
1799 peer = peer_and_group_lookup_vty (vty, peer_str);
1800 if (! peer)
1801 return CMD_WARNING;
1802
1803 if (set)
1804 ret = peer_af_flag_set (peer, afi, safi, flag);
1805 else
1806 ret = peer_af_flag_unset (peer, afi, safi, flag);
1807
1808 return bgp_vty_return (vty, ret);
1809}
1810
paul94f2b392005-06-28 12:44:16 +00001811static int
paulfd79ac92004-10-13 05:06:08 +00001812peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi,
paulfee0f4c2004-09-13 05:12:46 +00001813 safi_t safi, u_int32_t flag)
paul718e3742002-12-13 20:15:29 +00001814{
1815 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1);
1816}
1817
paul94f2b392005-06-28 12:44:16 +00001818static int
paulfd79ac92004-10-13 05:06:08 +00001819peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi,
paulfee0f4c2004-09-13 05:12:46 +00001820 safi_t safi, u_int32_t flag)
paul718e3742002-12-13 20:15:29 +00001821{
1822 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0);
1823}
1824
1825/* neighbor capability orf prefix-list. */
1826DEFUN (neighbor_capability_orf_prefix,
1827 neighbor_capability_orf_prefix_cmd,
1828 NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
1829 NEIGHBOR_STR
1830 NEIGHBOR_ADDR_STR2
1831 "Advertise capability to the peer\n"
1832 "Advertise ORF capability to the peer\n"
1833 "Advertise prefixlist ORF capability to this neighbor\n"
1834 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
1835 "Capability to RECEIVE the ORF from this neighbor\n"
1836 "Capability to SEND the ORF to this neighbor\n")
1837{
1838 u_int16_t flag = 0;
1839
1840 if (strncmp (argv[1], "s", 1) == 0)
1841 flag = PEER_FLAG_ORF_PREFIX_SM;
1842 else if (strncmp (argv[1], "r", 1) == 0)
1843 flag = PEER_FLAG_ORF_PREFIX_RM;
1844 else if (strncmp (argv[1], "b", 1) == 0)
1845 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
1846 else
1847 return CMD_WARNING;
1848
1849 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1850 bgp_node_safi (vty), flag);
1851}
1852
1853DEFUN (no_neighbor_capability_orf_prefix,
1854 no_neighbor_capability_orf_prefix_cmd,
1855 NO_NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
1856 NO_STR
1857 NEIGHBOR_STR
1858 NEIGHBOR_ADDR_STR2
1859 "Advertise capability to the peer\n"
1860 "Advertise ORF capability to the peer\n"
1861 "Advertise prefixlist ORF capability to this neighbor\n"
1862 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
1863 "Capability to RECEIVE the ORF from this neighbor\n"
1864 "Capability to SEND the ORF to this neighbor\n")
1865{
1866 u_int16_t flag = 0;
1867
1868 if (strncmp (argv[1], "s", 1) == 0)
1869 flag = PEER_FLAG_ORF_PREFIX_SM;
1870 else if (strncmp (argv[1], "r", 1) == 0)
1871 flag = PEER_FLAG_ORF_PREFIX_RM;
1872 else if (strncmp (argv[1], "b", 1) == 0)
1873 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
1874 else
1875 return CMD_WARNING;
1876
1877 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1878 bgp_node_safi (vty), flag);
1879}
1880
1881/* neighbor next-hop-self. */
1882DEFUN (neighbor_nexthop_self,
1883 neighbor_nexthop_self_cmd,
1884 NEIGHBOR_CMD2 "next-hop-self",
1885 NEIGHBOR_STR
1886 NEIGHBOR_ADDR_STR2
1887 "Disable the next hop calculation for this neighbor\n")
1888{
1889 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1890 bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF);
1891}
1892
1893DEFUN (no_neighbor_nexthop_self,
1894 no_neighbor_nexthop_self_cmd,
1895 NO_NEIGHBOR_CMD2 "next-hop-self",
1896 NO_STR
1897 NEIGHBOR_STR
1898 NEIGHBOR_ADDR_STR2
1899 "Disable the next hop calculation for this neighbor\n")
1900{
1901 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1902 bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF);
1903}
1904
1905/* neighbor remove-private-AS. */
1906DEFUN (neighbor_remove_private_as,
1907 neighbor_remove_private_as_cmd,
1908 NEIGHBOR_CMD2 "remove-private-AS",
1909 NEIGHBOR_STR
1910 NEIGHBOR_ADDR_STR2
1911 "Remove private AS number from outbound updates\n")
1912{
1913 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1914 bgp_node_safi (vty),
1915 PEER_FLAG_REMOVE_PRIVATE_AS);
1916}
1917
1918DEFUN (no_neighbor_remove_private_as,
1919 no_neighbor_remove_private_as_cmd,
1920 NO_NEIGHBOR_CMD2 "remove-private-AS",
1921 NO_STR
1922 NEIGHBOR_STR
1923 NEIGHBOR_ADDR_STR2
1924 "Remove private AS number from outbound updates\n")
1925{
1926 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1927 bgp_node_safi (vty),
1928 PEER_FLAG_REMOVE_PRIVATE_AS);
1929}
1930
1931/* neighbor send-community. */
1932DEFUN (neighbor_send_community,
1933 neighbor_send_community_cmd,
1934 NEIGHBOR_CMD2 "send-community",
1935 NEIGHBOR_STR
1936 NEIGHBOR_ADDR_STR2
1937 "Send Community attribute to this neighbor\n")
1938{
1939 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1940 bgp_node_safi (vty),
1941 PEER_FLAG_SEND_COMMUNITY);
1942}
1943
1944DEFUN (no_neighbor_send_community,
1945 no_neighbor_send_community_cmd,
1946 NO_NEIGHBOR_CMD2 "send-community",
1947 NO_STR
1948 NEIGHBOR_STR
1949 NEIGHBOR_ADDR_STR2
1950 "Send Community attribute to this neighbor\n")
1951{
1952 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1953 bgp_node_safi (vty),
1954 PEER_FLAG_SEND_COMMUNITY);
1955}
1956
1957/* neighbor send-community extended. */
1958DEFUN (neighbor_send_community_type,
1959 neighbor_send_community_type_cmd,
1960 NEIGHBOR_CMD2 "send-community (both|extended|standard)",
1961 NEIGHBOR_STR
1962 NEIGHBOR_ADDR_STR2
1963 "Send Community attribute to this neighbor\n"
1964 "Send Standard and Extended Community attributes\n"
1965 "Send Extended Community attributes\n"
1966 "Send Standard Community attributes\n")
1967{
1968 if (strncmp (argv[1], "s", 1) == 0)
1969 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1970 bgp_node_safi (vty),
1971 PEER_FLAG_SEND_COMMUNITY);
1972 if (strncmp (argv[1], "e", 1) == 0)
1973 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1974 bgp_node_safi (vty),
1975 PEER_FLAG_SEND_EXT_COMMUNITY);
1976
1977 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1978 bgp_node_safi (vty),
1979 (PEER_FLAG_SEND_COMMUNITY|
1980 PEER_FLAG_SEND_EXT_COMMUNITY));
1981}
1982
1983DEFUN (no_neighbor_send_community_type,
1984 no_neighbor_send_community_type_cmd,
1985 NO_NEIGHBOR_CMD2 "send-community (both|extended|standard)",
1986 NO_STR
1987 NEIGHBOR_STR
1988 NEIGHBOR_ADDR_STR2
1989 "Send Community attribute to this neighbor\n"
1990 "Send Standard and Extended Community attributes\n"
1991 "Send Extended Community attributes\n"
1992 "Send Standard Community attributes\n")
1993{
1994 if (strncmp (argv[1], "s", 1) == 0)
1995 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1996 bgp_node_safi (vty),
1997 PEER_FLAG_SEND_COMMUNITY);
1998 if (strncmp (argv[1], "e", 1) == 0)
1999 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2000 bgp_node_safi (vty),
2001 PEER_FLAG_SEND_EXT_COMMUNITY);
2002
2003 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2004 bgp_node_safi (vty),
2005 (PEER_FLAG_SEND_COMMUNITY |
2006 PEER_FLAG_SEND_EXT_COMMUNITY));
2007}
2008
2009/* neighbor soft-reconfig. */
2010DEFUN (neighbor_soft_reconfiguration,
2011 neighbor_soft_reconfiguration_cmd,
2012 NEIGHBOR_CMD2 "soft-reconfiguration inbound",
2013 NEIGHBOR_STR
2014 NEIGHBOR_ADDR_STR2
2015 "Per neighbor soft reconfiguration\n"
2016 "Allow inbound soft reconfiguration for this neighbor\n")
2017{
2018 return peer_af_flag_set_vty (vty, argv[0],
2019 bgp_node_afi (vty), bgp_node_safi (vty),
2020 PEER_FLAG_SOFT_RECONFIG);
2021}
2022
2023DEFUN (no_neighbor_soft_reconfiguration,
2024 no_neighbor_soft_reconfiguration_cmd,
2025 NO_NEIGHBOR_CMD2 "soft-reconfiguration inbound",
2026 NO_STR
2027 NEIGHBOR_STR
2028 NEIGHBOR_ADDR_STR2
2029 "Per neighbor soft reconfiguration\n"
2030 "Allow inbound soft reconfiguration for this neighbor\n")
2031{
2032 return peer_af_flag_unset_vty (vty, argv[0],
2033 bgp_node_afi (vty), bgp_node_safi (vty),
2034 PEER_FLAG_SOFT_RECONFIG);
2035}
2036
2037DEFUN (neighbor_route_reflector_client,
2038 neighbor_route_reflector_client_cmd,
2039 NEIGHBOR_CMD2 "route-reflector-client",
2040 NEIGHBOR_STR
2041 NEIGHBOR_ADDR_STR2
2042 "Configure a neighbor as Route Reflector client\n")
2043{
2044 struct peer *peer;
2045
2046
2047 peer = peer_and_group_lookup_vty (vty, argv[0]);
2048 if (! peer)
2049 return CMD_WARNING;
2050
2051 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2052 bgp_node_safi (vty),
2053 PEER_FLAG_REFLECTOR_CLIENT);
2054}
2055
2056DEFUN (no_neighbor_route_reflector_client,
2057 no_neighbor_route_reflector_client_cmd,
2058 NO_NEIGHBOR_CMD2 "route-reflector-client",
2059 NO_STR
2060 NEIGHBOR_STR
2061 NEIGHBOR_ADDR_STR2
2062 "Configure a neighbor as Route Reflector client\n")
2063{
2064 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2065 bgp_node_safi (vty),
2066 PEER_FLAG_REFLECTOR_CLIENT);
2067}
2068
paul94f2b392005-06-28 12:44:16 +00002069static int
paulfd79ac92004-10-13 05:06:08 +00002070peer_rsclient_set_vty (struct vty *vty, const char *peer_str,
2071 int afi, int safi)
paulfee0f4c2004-09-13 05:12:46 +00002072{
2073 int ret;
2074 struct bgp *bgp;
2075 struct peer *peer;
2076 struct peer_group *group;
paul1eb8ef22005-04-07 07:30:20 +00002077 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00002078 struct bgp_filter *pfilter;
2079 struct bgp_filter *gfilter;
Chris Caputo228da422009-07-18 05:44:03 +00002080 int locked_and_added = 0;
paulfee0f4c2004-09-13 05:12:46 +00002081
2082 bgp = vty->index;
2083
2084 peer = peer_and_group_lookup_vty (vty, peer_str);
2085 if ( ! peer )
2086 return CMD_WARNING;
2087
2088 /* If it is already a RS-Client, don't do anything. */
2089 if ( CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) )
2090 return CMD_SUCCESS;
2091
2092 if ( ! peer_rsclient_active (peer) )
paul200df112005-06-01 11:17:05 +00002093 {
2094 peer = peer_lock (peer); /* rsclient peer list reference */
2095 listnode_add_sort (bgp->rsclient, peer);
Chris Caputo228da422009-07-18 05:44:03 +00002096 locked_and_added = 1;
paul200df112005-06-01 11:17:05 +00002097 }
paulfee0f4c2004-09-13 05:12:46 +00002098
2099 ret = peer_af_flag_set (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
2100 if (ret < 0)
Chris Caputo228da422009-07-18 05:44:03 +00002101 {
2102 if (locked_and_added)
2103 {
2104 listnode_delete (bgp->rsclient, peer);
2105 peer_unlock (peer); /* rsclient peer list reference */
2106 }
2107
2108 return bgp_vty_return (vty, ret);
2109 }
paulfee0f4c2004-09-13 05:12:46 +00002110
Paul Jakma64e580a2006-02-21 01:09:01 +00002111 peer->rib[afi][safi] = bgp_table_init (afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00002112 peer->rib[afi][safi]->type = BGP_TABLE_RSCLIENT;
Chris Caputo228da422009-07-18 05:44:03 +00002113 /* RIB peer reference. Released when table is free'd in bgp_table_free. */
2114 peer->rib[afi][safi]->owner = peer_lock (peer);
paulfee0f4c2004-09-13 05:12:46 +00002115
2116 /* Check for existing 'network' and 'redistribute' routes. */
2117 bgp_check_local_routes_rsclient (peer, afi, safi);
2118
2119 /* Check for routes for peers configured with 'soft-reconfiguration'. */
2120 bgp_soft_reconfig_rsclient (peer, afi, safi);
2121
2122 if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))
2123 {
2124 group = peer->group;
2125 gfilter = &peer->filter[afi][safi];
2126
paul1eb8ef22005-04-07 07:30:20 +00002127 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
paulfee0f4c2004-09-13 05:12:46 +00002128 {
2129 pfilter = &peer->filter[afi][safi];
2130
2131 /* Members of a non-RS-Client group should not be RS-Clients, as that
2132 is checked when the become part of the peer-group */
2133 ret = peer_af_flag_set (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
2134 if (ret < 0)
2135 return bgp_vty_return (vty, ret);
2136
2137 /* Make peer's RIB point to group's RIB. */
2138 peer->rib[afi][safi] = group->conf->rib[afi][safi];
2139
2140 /* Import policy. */
2141 if (pfilter->map[RMAP_IMPORT].name)
2142 free (pfilter->map[RMAP_IMPORT].name);
2143 if (gfilter->map[RMAP_IMPORT].name)
2144 {
2145 pfilter->map[RMAP_IMPORT].name = strdup (gfilter->map[RMAP_IMPORT].name);
2146 pfilter->map[RMAP_IMPORT].map = gfilter->map[RMAP_IMPORT].map;
2147 }
2148 else
2149 {
2150 pfilter->map[RMAP_IMPORT].name = NULL;
2151 pfilter->map[RMAP_IMPORT].map =NULL;
2152 }
2153
2154 /* Export policy. */
2155 if (gfilter->map[RMAP_EXPORT].name && ! pfilter->map[RMAP_EXPORT].name)
2156 {
2157 pfilter->map[RMAP_EXPORT].name = strdup (gfilter->map[RMAP_EXPORT].name);
2158 pfilter->map[RMAP_EXPORT].map = gfilter->map[RMAP_EXPORT].map;
2159 }
2160 }
2161 }
2162 return CMD_SUCCESS;
2163}
2164
paul94f2b392005-06-28 12:44:16 +00002165static int
paulfd79ac92004-10-13 05:06:08 +00002166peer_rsclient_unset_vty (struct vty *vty, const char *peer_str,
2167 int afi, int safi)
paulfee0f4c2004-09-13 05:12:46 +00002168{
2169 int ret;
2170 struct bgp *bgp;
2171 struct peer *peer;
2172 struct peer_group *group;
paul1eb8ef22005-04-07 07:30:20 +00002173 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00002174
2175 bgp = vty->index;
2176
2177 peer = peer_and_group_lookup_vty (vty, peer_str);
2178 if ( ! peer )
2179 return CMD_WARNING;
2180
2181 /* If it is not a RS-Client, don't do anything. */
2182 if ( ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) )
2183 return CMD_SUCCESS;
2184
2185 if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))
2186 {
2187 group = peer->group;
2188
paul1eb8ef22005-04-07 07:30:20 +00002189 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
paulfee0f4c2004-09-13 05:12:46 +00002190 {
2191 ret = peer_af_flag_unset (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
2192 if (ret < 0)
2193 return bgp_vty_return (vty, ret);
2194
2195 peer->rib[afi][safi] = NULL;
2196 }
2197
2198 peer = group->conf;
2199 }
2200
2201 ret = peer_af_flag_unset (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
2202 if (ret < 0)
2203 return bgp_vty_return (vty, ret);
2204
2205 if ( ! peer_rsclient_active (peer) )
paul200df112005-06-01 11:17:05 +00002206 {
Chris Caputo228da422009-07-18 05:44:03 +00002207 bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_MY_RSCLIENT);
paul200df112005-06-01 11:17:05 +00002208 listnode_delete (bgp->rsclient, peer);
Chris Caputo228da422009-07-18 05:44:03 +00002209 peer_unlock (peer); /* peer bgp rsclient reference */
paul200df112005-06-01 11:17:05 +00002210 }
paulfee0f4c2004-09-13 05:12:46 +00002211
Paul Jakmab608d5b2008-07-02 02:12:07 +00002212 bgp_table_finish (&peer->rib[bgp_node_afi(vty)][bgp_node_safi(vty)]);
paulfee0f4c2004-09-13 05:12:46 +00002213
2214 return CMD_SUCCESS;
2215}
2216
paul718e3742002-12-13 20:15:29 +00002217/* neighbor route-server-client. */
2218DEFUN (neighbor_route_server_client,
2219 neighbor_route_server_client_cmd,
2220 NEIGHBOR_CMD2 "route-server-client",
2221 NEIGHBOR_STR
2222 NEIGHBOR_ADDR_STR2
2223 "Configure a neighbor as Route Server client\n")
2224{
paulfee0f4c2004-09-13 05:12:46 +00002225 return peer_rsclient_set_vty (vty, argv[0], bgp_node_afi(vty),
2226 bgp_node_safi(vty));
paul718e3742002-12-13 20:15:29 +00002227}
2228
2229DEFUN (no_neighbor_route_server_client,
2230 no_neighbor_route_server_client_cmd,
2231 NO_NEIGHBOR_CMD2 "route-server-client",
2232 NO_STR
2233 NEIGHBOR_STR
2234 NEIGHBOR_ADDR_STR2
2235 "Configure a neighbor as Route Server client\n")
2236{
paulfee0f4c2004-09-13 05:12:46 +00002237 return peer_rsclient_unset_vty (vty, argv[0], bgp_node_afi(vty),
2238 bgp_node_safi(vty));
2239}
2240
2241DEFUN (neighbor_nexthop_local_unchanged,
2242 neighbor_nexthop_local_unchanged_cmd,
2243 NEIGHBOR_CMD2 "nexthop-local unchanged",
2244 NEIGHBOR_STR
2245 NEIGHBOR_ADDR_STR2
2246 "Configure treatment of outgoing link-local nexthop attribute\n"
2247 "Leave link-local nexthop unchanged for this peer\n")
2248{
2249 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2250 bgp_node_safi (vty),
2251 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
2252}
2253
2254DEFUN (no_neighbor_nexthop_local_unchanged,
2255 no_neighbor_nexthop_local_unchanged_cmd,
2256 NO_NEIGHBOR_CMD2 "nexthop-local unchanged",
2257 NO_STR
2258 NEIGHBOR_STR
2259 NEIGHBOR_ADDR_STR2
2260 "Configure treatment of outgoing link-local-nexthop attribute\n"
2261 "Leave link-local nexthop unchanged for this peer\n")
2262{
paul718e3742002-12-13 20:15:29 +00002263 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2264 bgp_node_safi (vty),
paulfee0f4c2004-09-13 05:12:46 +00002265 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
paul718e3742002-12-13 20:15:29 +00002266}
2267
2268DEFUN (neighbor_attr_unchanged,
2269 neighbor_attr_unchanged_cmd,
2270 NEIGHBOR_CMD2 "attribute-unchanged",
2271 NEIGHBOR_STR
2272 NEIGHBOR_ADDR_STR2
2273 "BGP attribute is propagated unchanged to this neighbor\n")
2274{
2275 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2276 bgp_node_safi (vty),
2277 (PEER_FLAG_AS_PATH_UNCHANGED |
2278 PEER_FLAG_NEXTHOP_UNCHANGED |
2279 PEER_FLAG_MED_UNCHANGED));
2280}
2281
2282DEFUN (neighbor_attr_unchanged1,
2283 neighbor_attr_unchanged1_cmd,
2284 NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
2285 NEIGHBOR_STR
2286 NEIGHBOR_ADDR_STR2
2287 "BGP attribute is propagated unchanged to this neighbor\n"
2288 "As-path attribute\n"
2289 "Nexthop attribute\n"
2290 "Med attribute\n")
2291{
2292 u_int16_t flags = 0;
2293
2294 if (strncmp (argv[1], "as-path", 1) == 0)
2295 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2296 else if (strncmp (argv[1], "next-hop", 1) == 0)
2297 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2298 else if (strncmp (argv[1], "med", 1) == 0)
2299 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2300
2301 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2302 bgp_node_safi (vty), flags);
2303}
2304
2305DEFUN (neighbor_attr_unchanged2,
2306 neighbor_attr_unchanged2_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{
2315 u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
2316
2317 if (strncmp (argv[1], "next-hop", 1) == 0)
2318 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2319 else if (strncmp (argv[1], "med", 1) == 0)
2320 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2321
2322 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2323 bgp_node_safi (vty), flags);
2324
2325}
2326
2327DEFUN (neighbor_attr_unchanged3,
2328 neighbor_attr_unchanged3_cmd,
2329 NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
2330 NEIGHBOR_STR
2331 NEIGHBOR_ADDR_STR2
2332 "BGP attribute is propagated unchanged to this neighbor\n"
2333 "Nexthop attribute\n"
2334 "As-path attribute\n"
2335 "Med attribute\n")
2336{
2337 u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
2338
2339 if (strncmp (argv[1], "as-path", 1) == 0)
2340 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2341 else if (strncmp (argv[1], "med", 1) == 0)
2342 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2343
2344 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2345 bgp_node_safi (vty), flags);
2346}
2347
2348DEFUN (neighbor_attr_unchanged4,
2349 neighbor_attr_unchanged4_cmd,
2350 NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
2351 NEIGHBOR_STR
2352 NEIGHBOR_ADDR_STR2
2353 "BGP attribute is propagated unchanged to this neighbor\n"
2354 "Med attribute\n"
2355 "As-path attribute\n"
2356 "Nexthop attribute\n")
2357{
2358 u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
2359
2360 if (strncmp (argv[1], "as-path", 1) == 0)
2361 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2362 else if (strncmp (argv[1], "next-hop", 1) == 0)
2363 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2364
2365 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2366 bgp_node_safi (vty), flags);
2367}
2368
2369ALIAS (neighbor_attr_unchanged,
2370 neighbor_attr_unchanged5_cmd,
2371 NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
2372 NEIGHBOR_STR
2373 NEIGHBOR_ADDR_STR2
2374 "BGP attribute is propagated unchanged to this neighbor\n"
2375 "As-path attribute\n"
2376 "Nexthop attribute\n"
2377 "Med attribute\n")
2378
2379ALIAS (neighbor_attr_unchanged,
2380 neighbor_attr_unchanged6_cmd,
2381 NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
2382 NEIGHBOR_STR
2383 NEIGHBOR_ADDR_STR2
2384 "BGP attribute is propagated unchanged to this neighbor\n"
2385 "As-path attribute\n"
2386 "Med attribute\n"
2387 "Nexthop attribute\n")
2388
2389ALIAS (neighbor_attr_unchanged,
2390 neighbor_attr_unchanged7_cmd,
2391 NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
2392 NEIGHBOR_STR
2393 NEIGHBOR_ADDR_STR2
2394 "BGP attribute is propagated unchanged to this neighbor\n"
2395 "Nexthop attribute\n"
2396 "Med attribute\n"
2397 "As-path attribute\n")
2398
2399ALIAS (neighbor_attr_unchanged,
2400 neighbor_attr_unchanged8_cmd,
2401 NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
2402 NEIGHBOR_STR
2403 NEIGHBOR_ADDR_STR2
2404 "BGP attribute is propagated unchanged to this neighbor\n"
2405 "Nexthop attribute\n"
2406 "As-path attribute\n"
2407 "Med attribute\n")
2408
2409ALIAS (neighbor_attr_unchanged,
2410 neighbor_attr_unchanged9_cmd,
2411 NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
2412 NEIGHBOR_STR
2413 NEIGHBOR_ADDR_STR2
2414 "BGP attribute is propagated unchanged to this neighbor\n"
2415 "Med attribute\n"
2416 "Nexthop attribute\n"
2417 "As-path attribute\n")
2418
2419ALIAS (neighbor_attr_unchanged,
2420 neighbor_attr_unchanged10_cmd,
2421 NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
2422 NEIGHBOR_STR
2423 NEIGHBOR_ADDR_STR2
2424 "BGP attribute is propagated unchanged to this neighbor\n"
2425 "Med attribute\n"
2426 "As-path attribute\n"
2427 "Nexthop attribute\n")
2428
2429DEFUN (no_neighbor_attr_unchanged,
2430 no_neighbor_attr_unchanged_cmd,
2431 NO_NEIGHBOR_CMD2 "attribute-unchanged",
2432 NO_STR
2433 NEIGHBOR_STR
2434 NEIGHBOR_ADDR_STR2
2435 "BGP attribute is propagated unchanged to this neighbor\n")
2436{
2437 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2438 bgp_node_safi (vty),
2439 (PEER_FLAG_AS_PATH_UNCHANGED |
2440 PEER_FLAG_NEXTHOP_UNCHANGED |
2441 PEER_FLAG_MED_UNCHANGED));
2442}
2443
2444DEFUN (no_neighbor_attr_unchanged1,
2445 no_neighbor_attr_unchanged1_cmd,
2446 NO_NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
2447 NO_STR
2448 NEIGHBOR_STR
2449 NEIGHBOR_ADDR_STR2
2450 "BGP attribute is propagated unchanged to this neighbor\n"
2451 "As-path attribute\n"
2452 "Nexthop attribute\n"
2453 "Med attribute\n")
2454{
2455 u_int16_t flags = 0;
2456
2457 if (strncmp (argv[1], "as-path", 1) == 0)
2458 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2459 else if (strncmp (argv[1], "next-hop", 1) == 0)
2460 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2461 else if (strncmp (argv[1], "med", 1) == 0)
2462 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2463
2464 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2465 bgp_node_safi (vty), flags);
2466}
2467
2468DEFUN (no_neighbor_attr_unchanged2,
2469 no_neighbor_attr_unchanged2_cmd,
2470 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
2471 NO_STR
2472 NEIGHBOR_STR
2473 NEIGHBOR_ADDR_STR2
2474 "BGP attribute is propagated unchanged to this neighbor\n"
2475 "As-path attribute\n"
2476 "Nexthop attribute\n"
2477 "Med attribute\n")
2478{
2479 u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
2480
2481 if (strncmp (argv[1], "next-hop", 1) == 0)
2482 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2483 else if (strncmp (argv[1], "med", 1) == 0)
2484 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2485
2486 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2487 bgp_node_safi (vty), flags);
2488}
2489
2490DEFUN (no_neighbor_attr_unchanged3,
2491 no_neighbor_attr_unchanged3_cmd,
2492 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
2493 NO_STR
2494 NEIGHBOR_STR
2495 NEIGHBOR_ADDR_STR2
2496 "BGP attribute is propagated unchanged to this neighbor\n"
2497 "Nexthop attribute\n"
2498 "As-path attribute\n"
2499 "Med attribute\n")
2500{
2501 u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
2502
2503 if (strncmp (argv[1], "as-path", 1) == 0)
2504 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2505 else if (strncmp (argv[1], "med", 1) == 0)
2506 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2507
2508 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2509 bgp_node_safi (vty), flags);
2510}
2511
2512DEFUN (no_neighbor_attr_unchanged4,
2513 no_neighbor_attr_unchanged4_cmd,
2514 NO_NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
2515 NO_STR
2516 NEIGHBOR_STR
2517 NEIGHBOR_ADDR_STR2
2518 "BGP attribute is propagated unchanged to this neighbor\n"
2519 "Med attribute\n"
2520 "As-path attribute\n"
2521 "Nexthop attribute\n")
2522{
2523 u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
2524
2525 if (strncmp (argv[1], "as-path", 1) == 0)
2526 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2527 else if (strncmp (argv[1], "next-hop", 1) == 0)
2528 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2529
2530 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2531 bgp_node_safi (vty), flags);
2532}
2533
2534ALIAS (no_neighbor_attr_unchanged,
2535 no_neighbor_attr_unchanged5_cmd,
2536 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
2537 NO_STR
2538 NEIGHBOR_STR
2539 NEIGHBOR_ADDR_STR2
2540 "BGP attribute is propagated unchanged to this neighbor\n"
2541 "As-path attribute\n"
2542 "Nexthop attribute\n"
2543 "Med attribute\n")
2544
2545ALIAS (no_neighbor_attr_unchanged,
2546 no_neighbor_attr_unchanged6_cmd,
2547 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
2548 NO_STR
2549 NEIGHBOR_STR
2550 NEIGHBOR_ADDR_STR2
2551 "BGP attribute is propagated unchanged to this neighbor\n"
2552 "As-path attribute\n"
2553 "Med attribute\n"
2554 "Nexthop attribute\n")
2555
2556ALIAS (no_neighbor_attr_unchanged,
2557 no_neighbor_attr_unchanged7_cmd,
2558 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
2559 NO_STR
2560 NEIGHBOR_STR
2561 NEIGHBOR_ADDR_STR2
2562 "BGP attribute is propagated unchanged to this neighbor\n"
2563 "Nexthop attribute\n"
2564 "Med attribute\n"
2565 "As-path attribute\n")
2566
2567ALIAS (no_neighbor_attr_unchanged,
2568 no_neighbor_attr_unchanged8_cmd,
2569 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
2570 NO_STR
2571 NEIGHBOR_STR
2572 NEIGHBOR_ADDR_STR2
2573 "BGP attribute is propagated unchanged to this neighbor\n"
2574 "Nexthop attribute\n"
2575 "As-path attribute\n"
2576 "Med attribute\n")
2577
2578ALIAS (no_neighbor_attr_unchanged,
2579 no_neighbor_attr_unchanged9_cmd,
2580 NO_NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
2581 NO_STR
2582 NEIGHBOR_STR
2583 NEIGHBOR_ADDR_STR2
2584 "BGP attribute is propagated unchanged to this neighbor\n"
2585 "Med attribute\n"
2586 "Nexthop attribute\n"
2587 "As-path attribute\n")
2588
2589ALIAS (no_neighbor_attr_unchanged,
2590 no_neighbor_attr_unchanged10_cmd,
2591 NO_NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
2592 NO_STR
2593 NEIGHBOR_STR
2594 NEIGHBOR_ADDR_STR2
2595 "BGP attribute is propagated unchanged to this neighbor\n"
2596 "Med attribute\n"
2597 "As-path attribute\n"
2598 "Nexthop attribute\n")
2599
2600/* For old version Zebra compatibility. */
hassodd4c5932005-02-02 17:15:34 +00002601DEFUN_DEPRECATED (neighbor_transparent_as,
2602 neighbor_transparent_as_cmd,
2603 NEIGHBOR_CMD "transparent-as",
2604 NEIGHBOR_STR
2605 NEIGHBOR_ADDR_STR
2606 "Do not append my AS number even peer is EBGP peer\n")
paul718e3742002-12-13 20:15:29 +00002607{
2608 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2609 bgp_node_safi (vty),
2610 PEER_FLAG_AS_PATH_UNCHANGED);
2611}
2612
hassodd4c5932005-02-02 17:15:34 +00002613DEFUN_DEPRECATED (neighbor_transparent_nexthop,
2614 neighbor_transparent_nexthop_cmd,
2615 NEIGHBOR_CMD "transparent-nexthop",
2616 NEIGHBOR_STR
2617 NEIGHBOR_ADDR_STR
2618 "Do not change nexthop even peer is EBGP peer\n")
paul718e3742002-12-13 20:15:29 +00002619{
2620 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2621 bgp_node_safi (vty),
2622 PEER_FLAG_NEXTHOP_UNCHANGED);
2623}
2624
2625/* EBGP multihop configuration. */
paul94f2b392005-06-28 12:44:16 +00002626static int
paulfd79ac92004-10-13 05:06:08 +00002627peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str,
2628 const char *ttl_str)
paul718e3742002-12-13 20:15:29 +00002629{
2630 struct peer *peer;
paulfd79ac92004-10-13 05:06:08 +00002631 unsigned int ttl;
paul718e3742002-12-13 20:15:29 +00002632
2633 peer = peer_and_group_lookup_vty (vty, ip_str);
2634 if (! peer)
2635 return CMD_WARNING;
2636
2637 if (! ttl_str)
2638 ttl = TTL_MAX;
2639 else
2640 VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, 255);
2641
Stephen Hemminger89b6d1f2011-03-24 10:51:59 +00002642 return bgp_vty_return (vty, peer_ebgp_multihop_set (peer, ttl));
paul718e3742002-12-13 20:15:29 +00002643}
2644
paul94f2b392005-06-28 12:44:16 +00002645static int
paulfd79ac92004-10-13 05:06:08 +00002646peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str)
paul718e3742002-12-13 20:15:29 +00002647{
2648 struct peer *peer;
2649
2650 peer = peer_and_group_lookup_vty (vty, ip_str);
2651 if (! peer)
2652 return CMD_WARNING;
2653
Stephen Hemminger89b6d1f2011-03-24 10:51:59 +00002654 return bgp_vty_return (vty, peer_ebgp_multihop_unset (peer));
paul718e3742002-12-13 20:15:29 +00002655}
2656
2657/* neighbor ebgp-multihop. */
2658DEFUN (neighbor_ebgp_multihop,
2659 neighbor_ebgp_multihop_cmd,
2660 NEIGHBOR_CMD2 "ebgp-multihop",
2661 NEIGHBOR_STR
2662 NEIGHBOR_ADDR_STR2
2663 "Allow EBGP neighbors not on directly connected networks\n")
2664{
2665 return peer_ebgp_multihop_set_vty (vty, argv[0], NULL);
2666}
2667
2668DEFUN (neighbor_ebgp_multihop_ttl,
2669 neighbor_ebgp_multihop_ttl_cmd,
2670 NEIGHBOR_CMD2 "ebgp-multihop <1-255>",
2671 NEIGHBOR_STR
2672 NEIGHBOR_ADDR_STR2
2673 "Allow EBGP neighbors not on directly connected networks\n"
2674 "maximum hop count\n")
2675{
2676 return peer_ebgp_multihop_set_vty (vty, argv[0], argv[1]);
2677}
2678
2679DEFUN (no_neighbor_ebgp_multihop,
2680 no_neighbor_ebgp_multihop_cmd,
2681 NO_NEIGHBOR_CMD2 "ebgp-multihop",
2682 NO_STR
2683 NEIGHBOR_STR
2684 NEIGHBOR_ADDR_STR2
2685 "Allow EBGP neighbors not on directly connected networks\n")
2686{
2687 return peer_ebgp_multihop_unset_vty (vty, argv[0]);
2688}
2689
2690ALIAS (no_neighbor_ebgp_multihop,
2691 no_neighbor_ebgp_multihop_ttl_cmd,
2692 NO_NEIGHBOR_CMD2 "ebgp-multihop <1-255>",
2693 NO_STR
2694 NEIGHBOR_STR
2695 NEIGHBOR_ADDR_STR2
2696 "Allow EBGP neighbors not on directly connected networks\n"
2697 "maximum hop count\n")
2698
hasso6ffd2072005-02-02 14:50:11 +00002699/* disable-connected-check */
2700DEFUN (neighbor_disable_connected_check,
2701 neighbor_disable_connected_check_cmd,
2702 NEIGHBOR_CMD2 "disable-connected-check",
2703 NEIGHBOR_STR
2704 NEIGHBOR_ADDR_STR2
2705 "one-hop away EBGP peer using loopback address\n")
2706{
2707 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
2708}
2709
2710DEFUN (no_neighbor_disable_connected_check,
2711 no_neighbor_disable_connected_check_cmd,
2712 NO_NEIGHBOR_CMD2 "disable-connected-check",
2713 NO_STR
2714 NEIGHBOR_STR
2715 NEIGHBOR_ADDR_STR2
2716 "one-hop away EBGP peer using loopback address\n")
2717{
2718 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
2719}
2720
paul718e3742002-12-13 20:15:29 +00002721/* Enforce multihop. */
hasso6ffd2072005-02-02 14:50:11 +00002722ALIAS (neighbor_disable_connected_check,
paul718e3742002-12-13 20:15:29 +00002723 neighbor_enforce_multihop_cmd,
2724 NEIGHBOR_CMD2 "enforce-multihop",
2725 NEIGHBOR_STR
2726 NEIGHBOR_ADDR_STR2
paule8e19462006-01-19 20:16:55 +00002727 "Enforce EBGP neighbors perform multihop\n")
paul718e3742002-12-13 20:15:29 +00002728
hasso6ffd2072005-02-02 14:50:11 +00002729/* Enforce multihop. */
2730ALIAS (no_neighbor_disable_connected_check,
paul718e3742002-12-13 20:15:29 +00002731 no_neighbor_enforce_multihop_cmd,
2732 NO_NEIGHBOR_CMD2 "enforce-multihop",
2733 NO_STR
2734 NEIGHBOR_STR
2735 NEIGHBOR_ADDR_STR2
paule8e19462006-01-19 20:16:55 +00002736 "Enforce EBGP neighbors perform multihop\n")
paul718e3742002-12-13 20:15:29 +00002737
2738DEFUN (neighbor_description,
2739 neighbor_description_cmd,
2740 NEIGHBOR_CMD2 "description .LINE",
2741 NEIGHBOR_STR
2742 NEIGHBOR_ADDR_STR2
2743 "Neighbor specific description\n"
2744 "Up to 80 characters describing this neighbor\n")
2745{
2746 struct peer *peer;
paul718e3742002-12-13 20:15:29 +00002747 char *str;
paul718e3742002-12-13 20:15:29 +00002748
2749 peer = peer_and_group_lookup_vty (vty, argv[0]);
2750 if (! peer)
2751 return CMD_WARNING;
2752
2753 if (argc == 1)
2754 return CMD_SUCCESS;
2755
ajs3b8b1852005-01-29 18:19:13 +00002756 str = argv_concat(argv, argc, 1);
paul718e3742002-12-13 20:15:29 +00002757
2758 peer_description_set (peer, str);
2759
ajs3b8b1852005-01-29 18:19:13 +00002760 XFREE (MTYPE_TMP, str);
paul718e3742002-12-13 20:15:29 +00002761
2762 return CMD_SUCCESS;
2763}
2764
2765DEFUN (no_neighbor_description,
2766 no_neighbor_description_cmd,
2767 NO_NEIGHBOR_CMD2 "description",
2768 NO_STR
2769 NEIGHBOR_STR
2770 NEIGHBOR_ADDR_STR2
2771 "Neighbor specific description\n")
2772{
2773 struct peer *peer;
2774
2775 peer = peer_and_group_lookup_vty (vty, argv[0]);
2776 if (! peer)
2777 return CMD_WARNING;
2778
2779 peer_description_unset (peer);
2780
2781 return CMD_SUCCESS;
2782}
2783
2784ALIAS (no_neighbor_description,
2785 no_neighbor_description_val_cmd,
2786 NO_NEIGHBOR_CMD2 "description .LINE",
2787 NO_STR
2788 NEIGHBOR_STR
2789 NEIGHBOR_ADDR_STR2
2790 "Neighbor specific description\n"
2791 "Up to 80 characters describing this neighbor\n")
2792
2793/* Neighbor update-source. */
paul94f2b392005-06-28 12:44:16 +00002794static int
paulfd79ac92004-10-13 05:06:08 +00002795peer_update_source_vty (struct vty *vty, const char *peer_str,
2796 const char *source_str)
paul718e3742002-12-13 20:15:29 +00002797{
2798 struct peer *peer;
2799 union sockunion *su;
2800
2801 peer = peer_and_group_lookup_vty (vty, peer_str);
2802 if (! peer)
2803 return CMD_WARNING;
2804
2805 if (source_str)
2806 {
2807 su = sockunion_str2su (source_str);
2808 if (su)
2809 {
2810 peer_update_source_addr_set (peer, su);
2811 sockunion_free (su);
2812 }
2813 else
2814 peer_update_source_if_set (peer, source_str);
2815 }
2816 else
2817 peer_update_source_unset (peer);
2818
2819 return CMD_SUCCESS;
2820}
2821
Paul Jakma9a1a3312009-07-27 12:27:55 +01002822#define BGP_UPDATE_SOURCE_STR "(A.B.C.D|X:X::X:X|WORD)"
Paul Jakma369688c2006-05-23 22:27:55 +00002823#define BGP_UPDATE_SOURCE_HELP_STR \
2824 "IPv4 address\n" \
Paul Jakma9a1a3312009-07-27 12:27:55 +01002825 "IPv6 address\n" \
2826 "Interface name (requires zebra to be running)\n"
Paul Jakma369688c2006-05-23 22:27:55 +00002827
paul718e3742002-12-13 20:15:29 +00002828DEFUN (neighbor_update_source,
2829 neighbor_update_source_cmd,
Paul Jakma369688c2006-05-23 22:27:55 +00002830 NEIGHBOR_CMD2 "update-source " BGP_UPDATE_SOURCE_STR,
paul718e3742002-12-13 20:15:29 +00002831 NEIGHBOR_STR
2832 NEIGHBOR_ADDR_STR2
2833 "Source of routing updates\n"
Paul Jakma369688c2006-05-23 22:27:55 +00002834 BGP_UPDATE_SOURCE_HELP_STR)
paul718e3742002-12-13 20:15:29 +00002835{
2836 return peer_update_source_vty (vty, argv[0], argv[1]);
2837}
2838
2839DEFUN (no_neighbor_update_source,
2840 no_neighbor_update_source_cmd,
2841 NO_NEIGHBOR_CMD2 "update-source",
2842 NO_STR
2843 NEIGHBOR_STR
2844 NEIGHBOR_ADDR_STR2
Paul Jakma369688c2006-05-23 22:27:55 +00002845 "Source of routing updates\n")
paul718e3742002-12-13 20:15:29 +00002846{
2847 return peer_update_source_vty (vty, argv[0], NULL);
2848}
2849
paul94f2b392005-06-28 12:44:16 +00002850static int
paulfd79ac92004-10-13 05:06:08 +00002851peer_default_originate_set_vty (struct vty *vty, const char *peer_str,
2852 afi_t afi, safi_t safi,
2853 const char *rmap, int set)
paul718e3742002-12-13 20:15:29 +00002854{
2855 int ret;
2856 struct peer *peer;
2857
2858 peer = peer_and_group_lookup_vty (vty, peer_str);
2859 if (! peer)
2860 return CMD_WARNING;
2861
2862 if (set)
2863 ret = peer_default_originate_set (peer, afi, safi, rmap);
2864 else
2865 ret = peer_default_originate_unset (peer, afi, safi);
2866
2867 return bgp_vty_return (vty, ret);
2868}
2869
2870/* neighbor default-originate. */
2871DEFUN (neighbor_default_originate,
2872 neighbor_default_originate_cmd,
2873 NEIGHBOR_CMD2 "default-originate",
2874 NEIGHBOR_STR
2875 NEIGHBOR_ADDR_STR2
2876 "Originate default route to this neighbor\n")
2877{
2878 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
2879 bgp_node_safi (vty), NULL, 1);
2880}
2881
2882DEFUN (neighbor_default_originate_rmap,
2883 neighbor_default_originate_rmap_cmd,
2884 NEIGHBOR_CMD2 "default-originate route-map WORD",
2885 NEIGHBOR_STR
2886 NEIGHBOR_ADDR_STR2
2887 "Originate default route to this neighbor\n"
2888 "Route-map to specify criteria to originate default\n"
2889 "route-map name\n")
2890{
2891 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
2892 bgp_node_safi (vty), argv[1], 1);
2893}
2894
2895DEFUN (no_neighbor_default_originate,
2896 no_neighbor_default_originate_cmd,
2897 NO_NEIGHBOR_CMD2 "default-originate",
2898 NO_STR
2899 NEIGHBOR_STR
2900 NEIGHBOR_ADDR_STR2
2901 "Originate default route to this neighbor\n")
2902{
2903 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
2904 bgp_node_safi (vty), NULL, 0);
2905}
2906
2907ALIAS (no_neighbor_default_originate,
2908 no_neighbor_default_originate_rmap_cmd,
2909 NO_NEIGHBOR_CMD2 "default-originate route-map WORD",
2910 NO_STR
2911 NEIGHBOR_STR
2912 NEIGHBOR_ADDR_STR2
2913 "Originate default route to this neighbor\n"
2914 "Route-map to specify criteria to originate default\n"
2915 "route-map name\n")
2916
2917/* Set neighbor's BGP port. */
paul94f2b392005-06-28 12:44:16 +00002918static int
paulfd79ac92004-10-13 05:06:08 +00002919peer_port_vty (struct vty *vty, const char *ip_str, int afi,
2920 const char *port_str)
paul718e3742002-12-13 20:15:29 +00002921{
2922 struct peer *peer;
2923 u_int16_t port;
2924 struct servent *sp;
2925
2926 peer = peer_lookup_vty (vty, ip_str);
2927 if (! peer)
2928 return CMD_WARNING;
2929
2930 if (! port_str)
2931 {
2932 sp = getservbyname ("bgp", "tcp");
2933 port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port);
2934 }
2935 else
2936 {
2937 VTY_GET_INTEGER("port", port, port_str);
2938 }
2939
2940 peer_port_set (peer, port);
2941
2942 return CMD_SUCCESS;
2943}
2944
hassof4184462005-02-01 20:13:16 +00002945/* Set specified peer's BGP port. */
paul718e3742002-12-13 20:15:29 +00002946DEFUN (neighbor_port,
2947 neighbor_port_cmd,
2948 NEIGHBOR_CMD "port <0-65535>",
2949 NEIGHBOR_STR
2950 NEIGHBOR_ADDR_STR
2951 "Neighbor's BGP port\n"
2952 "TCP port number\n")
2953{
2954 return peer_port_vty (vty, argv[0], AFI_IP, argv[1]);
2955}
2956
2957DEFUN (no_neighbor_port,
2958 no_neighbor_port_cmd,
2959 NO_NEIGHBOR_CMD "port",
2960 NO_STR
2961 NEIGHBOR_STR
2962 NEIGHBOR_ADDR_STR
2963 "Neighbor's BGP port\n")
2964{
2965 return peer_port_vty (vty, argv[0], AFI_IP, NULL);
2966}
2967
2968ALIAS (no_neighbor_port,
2969 no_neighbor_port_val_cmd,
2970 NO_NEIGHBOR_CMD "port <0-65535>",
2971 NO_STR
2972 NEIGHBOR_STR
2973 NEIGHBOR_ADDR_STR
2974 "Neighbor's BGP port\n"
2975 "TCP port number\n")
2976
2977/* neighbor weight. */
paul94f2b392005-06-28 12:44:16 +00002978static int
paulfd79ac92004-10-13 05:06:08 +00002979peer_weight_set_vty (struct vty *vty, const char *ip_str,
2980 const char *weight_str)
paul718e3742002-12-13 20:15:29 +00002981{
2982 int ret;
2983 struct peer *peer;
2984 unsigned long weight;
2985
2986 peer = peer_and_group_lookup_vty (vty, ip_str);
2987 if (! peer)
2988 return CMD_WARNING;
2989
2990 VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535);
2991
2992 ret = peer_weight_set (peer, weight);
2993
2994 return CMD_SUCCESS;
2995}
2996
paul94f2b392005-06-28 12:44:16 +00002997static int
paulfd79ac92004-10-13 05:06:08 +00002998peer_weight_unset_vty (struct vty *vty, const char *ip_str)
paul718e3742002-12-13 20:15:29 +00002999{
3000 struct peer *peer;
3001
3002 peer = peer_and_group_lookup_vty (vty, ip_str);
3003 if (! peer)
3004 return CMD_WARNING;
3005
3006 peer_weight_unset (peer);
3007
3008 return CMD_SUCCESS;
3009}
3010
3011DEFUN (neighbor_weight,
3012 neighbor_weight_cmd,
3013 NEIGHBOR_CMD2 "weight <0-65535>",
3014 NEIGHBOR_STR
3015 NEIGHBOR_ADDR_STR2
3016 "Set default weight for routes from this neighbor\n"
3017 "default weight\n")
3018{
3019 return peer_weight_set_vty (vty, argv[0], argv[1]);
3020}
3021
3022DEFUN (no_neighbor_weight,
3023 no_neighbor_weight_cmd,
3024 NO_NEIGHBOR_CMD2 "weight",
3025 NO_STR
3026 NEIGHBOR_STR
3027 NEIGHBOR_ADDR_STR2
3028 "Set default weight for routes from this neighbor\n")
3029{
3030 return peer_weight_unset_vty (vty, argv[0]);
3031}
3032
3033ALIAS (no_neighbor_weight,
3034 no_neighbor_weight_val_cmd,
3035 NO_NEIGHBOR_CMD2 "weight <0-65535>",
3036 NO_STR
3037 NEIGHBOR_STR
3038 NEIGHBOR_ADDR_STR2
3039 "Set default weight for routes from this neighbor\n"
3040 "default weight\n")
3041
3042/* Override capability negotiation. */
3043DEFUN (neighbor_override_capability,
3044 neighbor_override_capability_cmd,
3045 NEIGHBOR_CMD2 "override-capability",
3046 NEIGHBOR_STR
3047 NEIGHBOR_ADDR_STR2
3048 "Override capability negotiation result\n")
3049{
3050 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
3051}
3052
3053DEFUN (no_neighbor_override_capability,
3054 no_neighbor_override_capability_cmd,
3055 NO_NEIGHBOR_CMD2 "override-capability",
3056 NO_STR
3057 NEIGHBOR_STR
3058 NEIGHBOR_ADDR_STR2
3059 "Override capability negotiation result\n")
3060{
3061 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
3062}
3063
3064DEFUN (neighbor_strict_capability,
3065 neighbor_strict_capability_cmd,
3066 NEIGHBOR_CMD "strict-capability-match",
3067 NEIGHBOR_STR
3068 NEIGHBOR_ADDR_STR
3069 "Strict capability negotiation match\n")
3070{
3071 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
3072}
3073
3074DEFUN (no_neighbor_strict_capability,
3075 no_neighbor_strict_capability_cmd,
3076 NO_NEIGHBOR_CMD "strict-capability-match",
3077 NO_STR
3078 NEIGHBOR_STR
3079 NEIGHBOR_ADDR_STR
3080 "Strict capability negotiation match\n")
3081{
3082 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
3083}
3084
paul94f2b392005-06-28 12:44:16 +00003085static int
paulfd79ac92004-10-13 05:06:08 +00003086peer_timers_set_vty (struct vty *vty, const char *ip_str,
3087 const char *keep_str, const char *hold_str)
paul718e3742002-12-13 20:15:29 +00003088{
3089 int ret;
3090 struct peer *peer;
3091 u_int32_t keepalive;
3092 u_int32_t holdtime;
3093
3094 peer = peer_and_group_lookup_vty (vty, ip_str);
3095 if (! peer)
3096 return CMD_WARNING;
3097
3098 VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535);
3099 VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535);
3100
3101 ret = peer_timers_set (peer, keepalive, holdtime);
3102
3103 return bgp_vty_return (vty, ret);
3104}
3105
paul94f2b392005-06-28 12:44:16 +00003106static int
paulfd79ac92004-10-13 05:06:08 +00003107peer_timers_unset_vty (struct vty *vty, const char *ip_str)
paul718e3742002-12-13 20:15:29 +00003108{
3109 int ret;
3110 struct peer *peer;
3111
3112 peer = peer_lookup_vty (vty, ip_str);
3113 if (! peer)
3114 return CMD_WARNING;
3115
3116 ret = peer_timers_unset (peer);
3117
3118 return bgp_vty_return (vty, ret);
3119}
3120
3121DEFUN (neighbor_timers,
3122 neighbor_timers_cmd,
3123 NEIGHBOR_CMD2 "timers <0-65535> <0-65535>",
3124 NEIGHBOR_STR
3125 NEIGHBOR_ADDR_STR2
3126 "BGP per neighbor timers\n"
3127 "Keepalive interval\n"
3128 "Holdtime\n")
3129{
3130 return peer_timers_set_vty (vty, argv[0], argv[1], argv[2]);
3131}
3132
3133DEFUN (no_neighbor_timers,
3134 no_neighbor_timers_cmd,
3135 NO_NEIGHBOR_CMD2 "timers",
3136 NO_STR
3137 NEIGHBOR_STR
3138 NEIGHBOR_ADDR_STR2
3139 "BGP per neighbor timers\n")
3140{
3141 return peer_timers_unset_vty (vty, argv[0]);
3142}
3143
paul94f2b392005-06-28 12:44:16 +00003144static int
paulfd79ac92004-10-13 05:06:08 +00003145peer_timers_connect_set_vty (struct vty *vty, const char *ip_str,
3146 const char *time_str)
paul718e3742002-12-13 20:15:29 +00003147{
3148 int ret;
3149 struct peer *peer;
3150 u_int32_t connect;
3151
3152 peer = peer_lookup_vty (vty, ip_str);
3153 if (! peer)
3154 return CMD_WARNING;
3155
3156 VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535);
3157
3158 ret = peer_timers_connect_set (peer, connect);
3159
3160 return CMD_SUCCESS;
3161}
3162
paul94f2b392005-06-28 12:44:16 +00003163static int
paulfd79ac92004-10-13 05:06:08 +00003164peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str)
paul718e3742002-12-13 20:15:29 +00003165{
3166 int ret;
3167 struct peer *peer;
3168
3169 peer = peer_and_group_lookup_vty (vty, ip_str);
3170 if (! peer)
3171 return CMD_WARNING;
3172
3173 ret = peer_timers_connect_unset (peer);
3174
3175 return CMD_SUCCESS;
3176}
3177
3178DEFUN (neighbor_timers_connect,
3179 neighbor_timers_connect_cmd,
3180 NEIGHBOR_CMD "timers connect <0-65535>",
3181 NEIGHBOR_STR
3182 NEIGHBOR_ADDR_STR
3183 "BGP per neighbor timers\n"
3184 "BGP connect timer\n"
3185 "Connect timer\n")
3186{
3187 return peer_timers_connect_set_vty (vty, argv[0], argv[1]);
3188}
3189
3190DEFUN (no_neighbor_timers_connect,
3191 no_neighbor_timers_connect_cmd,
3192 NO_NEIGHBOR_CMD "timers connect",
3193 NO_STR
3194 NEIGHBOR_STR
3195 NEIGHBOR_ADDR_STR
3196 "BGP per neighbor timers\n"
3197 "BGP connect timer\n")
3198{
3199 return peer_timers_connect_unset_vty (vty, argv[0]);
3200}
3201
3202ALIAS (no_neighbor_timers_connect,
3203 no_neighbor_timers_connect_val_cmd,
3204 NO_NEIGHBOR_CMD "timers connect <0-65535>",
3205 NO_STR
3206 NEIGHBOR_STR
3207 NEIGHBOR_ADDR_STR
3208 "BGP per neighbor timers\n"
3209 "BGP connect timer\n"
3210 "Connect timer\n")
3211
paul94f2b392005-06-28 12:44:16 +00003212static int
paulfd79ac92004-10-13 05:06:08 +00003213peer_advertise_interval_vty (struct vty *vty, const char *ip_str,
3214 const char *time_str, int set)
paul718e3742002-12-13 20:15:29 +00003215{
3216 int ret;
3217 struct peer *peer;
3218 u_int32_t routeadv = 0;
3219
3220 peer = peer_lookup_vty (vty, ip_str);
3221 if (! peer)
3222 return CMD_WARNING;
3223
3224 if (time_str)
3225 VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600);
3226
3227 if (set)
3228 ret = peer_advertise_interval_set (peer, routeadv);
3229 else
3230 ret = peer_advertise_interval_unset (peer);
3231
3232 return CMD_SUCCESS;
3233}
3234
3235DEFUN (neighbor_advertise_interval,
3236 neighbor_advertise_interval_cmd,
3237 NEIGHBOR_CMD "advertisement-interval <0-600>",
3238 NEIGHBOR_STR
3239 NEIGHBOR_ADDR_STR
3240 "Minimum interval between sending BGP routing updates\n"
3241 "time in seconds\n")
3242{
3243 return peer_advertise_interval_vty (vty, argv[0], argv[1], 1);
3244}
3245
3246DEFUN (no_neighbor_advertise_interval,
3247 no_neighbor_advertise_interval_cmd,
3248 NO_NEIGHBOR_CMD "advertisement-interval",
3249 NO_STR
3250 NEIGHBOR_STR
3251 NEIGHBOR_ADDR_STR
3252 "Minimum interval between sending BGP routing updates\n")
3253{
3254 return peer_advertise_interval_vty (vty, argv[0], NULL, 0);
3255}
3256
3257ALIAS (no_neighbor_advertise_interval,
3258 no_neighbor_advertise_interval_val_cmd,
3259 NO_NEIGHBOR_CMD "advertisement-interval <0-600>",
3260 NO_STR
3261 NEIGHBOR_STR
3262 NEIGHBOR_ADDR_STR
3263 "Minimum interval between sending BGP routing updates\n"
3264 "time in seconds\n")
3265
paul718e3742002-12-13 20:15:29 +00003266/* neighbor interface */
paul94f2b392005-06-28 12:44:16 +00003267static int
paulfd79ac92004-10-13 05:06:08 +00003268peer_interface_vty (struct vty *vty, const char *ip_str, const char *str)
paul718e3742002-12-13 20:15:29 +00003269{
3270 int ret;
3271 struct peer *peer;
3272
3273 peer = peer_lookup_vty (vty, ip_str);
3274 if (! peer)
3275 return CMD_WARNING;
3276
3277 if (str)
3278 ret = peer_interface_set (peer, str);
3279 else
3280 ret = peer_interface_unset (peer);
3281
3282 return CMD_SUCCESS;
3283}
3284
3285DEFUN (neighbor_interface,
3286 neighbor_interface_cmd,
3287 NEIGHBOR_CMD "interface WORD",
3288 NEIGHBOR_STR
3289 NEIGHBOR_ADDR_STR
3290 "Interface\n"
3291 "Interface name\n")
3292{
3293 return peer_interface_vty (vty, argv[0], argv[1]);
3294}
3295
3296DEFUN (no_neighbor_interface,
3297 no_neighbor_interface_cmd,
3298 NO_NEIGHBOR_CMD "interface WORD",
3299 NO_STR
3300 NEIGHBOR_STR
3301 NEIGHBOR_ADDR_STR
3302 "Interface\n"
3303 "Interface name\n")
3304{
3305 return peer_interface_vty (vty, argv[0], NULL);
3306}
3307
3308/* Set distribute list to the peer. */
paul94f2b392005-06-28 12:44:16 +00003309static int
paulfd79ac92004-10-13 05:06:08 +00003310peer_distribute_set_vty (struct vty *vty, const char *ip_str,
3311 afi_t afi, safi_t safi,
3312 const char *name_str, const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003313{
3314 int ret;
3315 struct peer *peer;
3316 int direct = FILTER_IN;
3317
3318 peer = peer_and_group_lookup_vty (vty, ip_str);
3319 if (! peer)
3320 return CMD_WARNING;
3321
3322 /* Check filter direction. */
3323 if (strncmp (direct_str, "i", 1) == 0)
3324 direct = FILTER_IN;
3325 else if (strncmp (direct_str, "o", 1) == 0)
3326 direct = FILTER_OUT;
3327
3328 ret = peer_distribute_set (peer, afi, safi, direct, name_str);
3329
3330 return bgp_vty_return (vty, ret);
3331}
3332
paul94f2b392005-06-28 12:44:16 +00003333static int
paulfd79ac92004-10-13 05:06:08 +00003334peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
3335 safi_t safi, const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003336{
3337 int ret;
3338 struct peer *peer;
3339 int direct = FILTER_IN;
3340
3341 peer = peer_and_group_lookup_vty (vty, ip_str);
3342 if (! peer)
3343 return CMD_WARNING;
3344
3345 /* Check filter direction. */
3346 if (strncmp (direct_str, "i", 1) == 0)
3347 direct = FILTER_IN;
3348 else if (strncmp (direct_str, "o", 1) == 0)
3349 direct = FILTER_OUT;
3350
3351 ret = peer_distribute_unset (peer, afi, safi, direct);
3352
3353 return bgp_vty_return (vty, ret);
3354}
3355
3356DEFUN (neighbor_distribute_list,
3357 neighbor_distribute_list_cmd,
3358 NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
3359 NEIGHBOR_STR
3360 NEIGHBOR_ADDR_STR2
3361 "Filter updates to/from this neighbor\n"
3362 "IP access-list number\n"
3363 "IP access-list number (expanded range)\n"
3364 "IP Access-list name\n"
3365 "Filter incoming updates\n"
3366 "Filter outgoing updates\n")
3367{
3368 return peer_distribute_set_vty (vty, argv[0], bgp_node_afi (vty),
3369 bgp_node_safi (vty), argv[1], argv[2]);
3370}
3371
3372DEFUN (no_neighbor_distribute_list,
3373 no_neighbor_distribute_list_cmd,
3374 NO_NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
3375 NO_STR
3376 NEIGHBOR_STR
3377 NEIGHBOR_ADDR_STR2
3378 "Filter updates to/from this neighbor\n"
3379 "IP access-list number\n"
3380 "IP access-list number (expanded range)\n"
3381 "IP Access-list name\n"
3382 "Filter incoming updates\n"
3383 "Filter outgoing updates\n")
3384{
3385 return peer_distribute_unset_vty (vty, argv[0], bgp_node_afi (vty),
3386 bgp_node_safi (vty), argv[2]);
3387}
3388
3389/* Set prefix list to the peer. */
paul94f2b392005-06-28 12:44:16 +00003390static int
paulfd79ac92004-10-13 05:06:08 +00003391peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
3392 safi_t safi, const char *name_str,
3393 const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003394{
3395 int ret;
3396 struct peer *peer;
3397 int direct = FILTER_IN;
3398
3399 peer = peer_and_group_lookup_vty (vty, ip_str);
3400 if (! peer)
3401 return CMD_WARNING;
3402
3403 /* Check filter direction. */
3404 if (strncmp (direct_str, "i", 1) == 0)
3405 direct = FILTER_IN;
3406 else if (strncmp (direct_str, "o", 1) == 0)
3407 direct = FILTER_OUT;
3408
3409 ret = peer_prefix_list_set (peer, afi, safi, direct, name_str);
3410
3411 return bgp_vty_return (vty, ret);
3412}
3413
paul94f2b392005-06-28 12:44:16 +00003414static int
paulfd79ac92004-10-13 05:06:08 +00003415peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
3416 safi_t safi, const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003417{
3418 int ret;
3419 struct peer *peer;
3420 int direct = FILTER_IN;
3421
3422 peer = peer_and_group_lookup_vty (vty, ip_str);
3423 if (! peer)
3424 return CMD_WARNING;
3425
3426 /* Check filter direction. */
3427 if (strncmp (direct_str, "i", 1) == 0)
3428 direct = FILTER_IN;
3429 else if (strncmp (direct_str, "o", 1) == 0)
3430 direct = FILTER_OUT;
3431
3432 ret = peer_prefix_list_unset (peer, afi, safi, direct);
3433
3434 return bgp_vty_return (vty, ret);
3435}
3436
3437DEFUN (neighbor_prefix_list,
3438 neighbor_prefix_list_cmd,
3439 NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
3440 NEIGHBOR_STR
3441 NEIGHBOR_ADDR_STR2
3442 "Filter updates to/from this neighbor\n"
3443 "Name of a prefix list\n"
3444 "Filter incoming updates\n"
3445 "Filter outgoing updates\n")
3446{
3447 return peer_prefix_list_set_vty (vty, argv[0], bgp_node_afi (vty),
3448 bgp_node_safi (vty), argv[1], argv[2]);
3449}
3450
3451DEFUN (no_neighbor_prefix_list,
3452 no_neighbor_prefix_list_cmd,
3453 NO_NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
3454 NO_STR
3455 NEIGHBOR_STR
3456 NEIGHBOR_ADDR_STR2
3457 "Filter updates to/from this neighbor\n"
3458 "Name of a prefix list\n"
3459 "Filter incoming updates\n"
3460 "Filter outgoing updates\n")
3461{
3462 return peer_prefix_list_unset_vty (vty, argv[0], bgp_node_afi (vty),
3463 bgp_node_safi (vty), argv[2]);
3464}
3465
paul94f2b392005-06-28 12:44:16 +00003466static int
paulfd79ac92004-10-13 05:06:08 +00003467peer_aslist_set_vty (struct vty *vty, const char *ip_str,
3468 afi_t afi, safi_t safi,
3469 const char *name_str, const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003470{
3471 int ret;
3472 struct peer *peer;
3473 int direct = FILTER_IN;
3474
3475 peer = peer_and_group_lookup_vty (vty, ip_str);
3476 if (! peer)
3477 return CMD_WARNING;
3478
3479 /* Check filter direction. */
3480 if (strncmp (direct_str, "i", 1) == 0)
3481 direct = FILTER_IN;
3482 else if (strncmp (direct_str, "o", 1) == 0)
3483 direct = FILTER_OUT;
3484
3485 ret = peer_aslist_set (peer, afi, safi, direct, name_str);
3486
3487 return bgp_vty_return (vty, ret);
3488}
3489
paul94f2b392005-06-28 12:44:16 +00003490static int
paulfd79ac92004-10-13 05:06:08 +00003491peer_aslist_unset_vty (struct vty *vty, const char *ip_str,
3492 afi_t afi, safi_t safi,
3493 const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003494{
3495 int ret;
3496 struct peer *peer;
3497 int direct = FILTER_IN;
3498
3499 peer = peer_and_group_lookup_vty (vty, ip_str);
3500 if (! peer)
3501 return CMD_WARNING;
3502
3503 /* Check filter direction. */
3504 if (strncmp (direct_str, "i", 1) == 0)
3505 direct = FILTER_IN;
3506 else if (strncmp (direct_str, "o", 1) == 0)
3507 direct = FILTER_OUT;
3508
3509 ret = peer_aslist_unset (peer, afi, safi, direct);
3510
3511 return bgp_vty_return (vty, ret);
3512}
3513
3514DEFUN (neighbor_filter_list,
3515 neighbor_filter_list_cmd,
3516 NEIGHBOR_CMD2 "filter-list WORD (in|out)",
3517 NEIGHBOR_STR
3518 NEIGHBOR_ADDR_STR2
3519 "Establish BGP filters\n"
3520 "AS path access-list name\n"
3521 "Filter incoming routes\n"
3522 "Filter outgoing routes\n")
3523{
3524 return peer_aslist_set_vty (vty, argv[0], bgp_node_afi (vty),
3525 bgp_node_safi (vty), argv[1], argv[2]);
3526}
3527
3528DEFUN (no_neighbor_filter_list,
3529 no_neighbor_filter_list_cmd,
3530 NO_NEIGHBOR_CMD2 "filter-list WORD (in|out)",
3531 NO_STR
3532 NEIGHBOR_STR
3533 NEIGHBOR_ADDR_STR2
3534 "Establish BGP filters\n"
3535 "AS path access-list name\n"
3536 "Filter incoming routes\n"
3537 "Filter outgoing routes\n")
3538{
3539 return peer_aslist_unset_vty (vty, argv[0], bgp_node_afi (vty),
3540 bgp_node_safi (vty), argv[2]);
3541}
3542
3543/* Set route-map to the peer. */
paul94f2b392005-06-28 12:44:16 +00003544static int
paulfd79ac92004-10-13 05:06:08 +00003545peer_route_map_set_vty (struct vty *vty, const char *ip_str,
3546 afi_t afi, safi_t safi,
3547 const char *name_str, const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003548{
3549 int ret;
3550 struct peer *peer;
paulfee0f4c2004-09-13 05:12:46 +00003551 int direct = RMAP_IN;
paul718e3742002-12-13 20:15:29 +00003552
3553 peer = peer_and_group_lookup_vty (vty, ip_str);
3554 if (! peer)
3555 return CMD_WARNING;
3556
3557 /* Check filter direction. */
paulfee0f4c2004-09-13 05:12:46 +00003558 if (strncmp (direct_str, "in", 2) == 0)
3559 direct = RMAP_IN;
paul718e3742002-12-13 20:15:29 +00003560 else if (strncmp (direct_str, "o", 1) == 0)
paulfee0f4c2004-09-13 05:12:46 +00003561 direct = RMAP_OUT;
3562 else if (strncmp (direct_str, "im", 2) == 0)
3563 direct = RMAP_IMPORT;
3564 else if (strncmp (direct_str, "e", 1) == 0)
3565 direct = RMAP_EXPORT;
paul718e3742002-12-13 20:15:29 +00003566
3567 ret = peer_route_map_set (peer, afi, safi, direct, name_str);
3568
3569 return bgp_vty_return (vty, ret);
3570}
3571
paul94f2b392005-06-28 12:44:16 +00003572static int
paulfd79ac92004-10-13 05:06:08 +00003573peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
3574 safi_t safi, const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003575{
3576 int ret;
3577 struct peer *peer;
paulfee0f4c2004-09-13 05:12:46 +00003578 int direct = RMAP_IN;
paul718e3742002-12-13 20:15:29 +00003579
3580 peer = peer_and_group_lookup_vty (vty, ip_str);
3581 if (! peer)
3582 return CMD_WARNING;
3583
3584 /* Check filter direction. */
paulfee0f4c2004-09-13 05:12:46 +00003585 if (strncmp (direct_str, "in", 2) == 0)
3586 direct = RMAP_IN;
paul718e3742002-12-13 20:15:29 +00003587 else if (strncmp (direct_str, "o", 1) == 0)
paulfee0f4c2004-09-13 05:12:46 +00003588 direct = RMAP_OUT;
3589 else if (strncmp (direct_str, "im", 2) == 0)
3590 direct = RMAP_IMPORT;
3591 else if (strncmp (direct_str, "e", 1) == 0)
3592 direct = RMAP_EXPORT;
paul718e3742002-12-13 20:15:29 +00003593
3594 ret = peer_route_map_unset (peer, afi, safi, direct);
3595
3596 return bgp_vty_return (vty, ret);
3597}
3598
3599DEFUN (neighbor_route_map,
3600 neighbor_route_map_cmd,
paulfee0f4c2004-09-13 05:12:46 +00003601 NEIGHBOR_CMD2 "route-map WORD (in|out|import|export)",
paul718e3742002-12-13 20:15:29 +00003602 NEIGHBOR_STR
3603 NEIGHBOR_ADDR_STR2
3604 "Apply route map to neighbor\n"
3605 "Name of route map\n"
3606 "Apply map to incoming routes\n"
paulfee0f4c2004-09-13 05:12:46 +00003607 "Apply map to outbound routes\n"
3608 "Apply map to routes going into a Route-Server client's table\n"
3609 "Apply map to routes coming from a Route-Server client")
paul718e3742002-12-13 20:15:29 +00003610{
3611 return peer_route_map_set_vty (vty, argv[0], bgp_node_afi (vty),
3612 bgp_node_safi (vty), argv[1], argv[2]);
3613}
3614
3615DEFUN (no_neighbor_route_map,
3616 no_neighbor_route_map_cmd,
paulfee0f4c2004-09-13 05:12:46 +00003617 NO_NEIGHBOR_CMD2 "route-map WORD (in|out|import|export)",
paul718e3742002-12-13 20:15:29 +00003618 NO_STR
3619 NEIGHBOR_STR
3620 NEIGHBOR_ADDR_STR2
3621 "Apply route map to neighbor\n"
3622 "Name of route map\n"
3623 "Apply map to incoming routes\n"
paulfee0f4c2004-09-13 05:12:46 +00003624 "Apply map to outbound routes\n"
3625 "Apply map to routes going into a Route-Server client's table\n"
3626 "Apply map to routes coming from a Route-Server client")
paul718e3742002-12-13 20:15:29 +00003627{
3628 return peer_route_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
3629 bgp_node_safi (vty), argv[2]);
3630}
3631
3632/* Set unsuppress-map to the peer. */
paul94f2b392005-06-28 12:44:16 +00003633static int
paulfd79ac92004-10-13 05:06:08 +00003634peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
3635 safi_t safi, const char *name_str)
paul718e3742002-12-13 20:15:29 +00003636{
3637 int ret;
3638 struct peer *peer;
3639
3640 peer = peer_and_group_lookup_vty (vty, ip_str);
3641 if (! peer)
3642 return CMD_WARNING;
3643
3644 ret = peer_unsuppress_map_set (peer, afi, safi, name_str);
3645
3646 return bgp_vty_return (vty, ret);
3647}
3648
3649/* Unset route-map from the peer. */
paul94f2b392005-06-28 12:44:16 +00003650static int
paulfd79ac92004-10-13 05:06:08 +00003651peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00003652 safi_t safi)
3653{
3654 int ret;
3655 struct peer *peer;
3656
3657 peer = peer_and_group_lookup_vty (vty, ip_str);
3658 if (! peer)
3659 return CMD_WARNING;
3660
3661 ret = peer_unsuppress_map_unset (peer, afi, safi);
3662
3663 return bgp_vty_return (vty, ret);
3664}
3665
3666DEFUN (neighbor_unsuppress_map,
3667 neighbor_unsuppress_map_cmd,
3668 NEIGHBOR_CMD2 "unsuppress-map WORD",
3669 NEIGHBOR_STR
3670 NEIGHBOR_ADDR_STR2
3671 "Route-map to selectively unsuppress suppressed routes\n"
3672 "Name of route map\n")
3673{
3674 return peer_unsuppress_map_set_vty (vty, argv[0], bgp_node_afi (vty),
3675 bgp_node_safi (vty), argv[1]);
3676}
3677
3678DEFUN (no_neighbor_unsuppress_map,
3679 no_neighbor_unsuppress_map_cmd,
3680 NO_NEIGHBOR_CMD2 "unsuppress-map WORD",
3681 NO_STR
3682 NEIGHBOR_STR
3683 NEIGHBOR_ADDR_STR2
3684 "Route-map to selectively unsuppress suppressed routes\n"
3685 "Name of route map\n")
3686{
3687 return peer_unsuppress_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
3688 bgp_node_safi (vty));
3689}
3690
paul94f2b392005-06-28 12:44:16 +00003691static int
paulfd79ac92004-10-13 05:06:08 +00003692peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
3693 safi_t safi, const char *num_str,
hasso0a486e52005-02-01 20:57:17 +00003694 const char *threshold_str, int warning,
3695 const char *restart_str)
paul718e3742002-12-13 20:15:29 +00003696{
3697 int ret;
3698 struct peer *peer;
3699 u_int32_t max;
hassoe0701b72004-05-20 09:19:34 +00003700 u_char threshold;
hasso0a486e52005-02-01 20:57:17 +00003701 u_int16_t restart;
paul718e3742002-12-13 20:15:29 +00003702
3703 peer = peer_and_group_lookup_vty (vty, ip_str);
3704 if (! peer)
3705 return CMD_WARNING;
3706
3707 VTY_GET_INTEGER ("maxmum number", max, num_str);
hassoe0701b72004-05-20 09:19:34 +00003708 if (threshold_str)
3709 threshold = atoi (threshold_str);
3710 else
3711 threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003712
hasso0a486e52005-02-01 20:57:17 +00003713 if (restart_str)
3714 restart = atoi (restart_str);
3715 else
3716 restart = 0;
3717
3718 ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart);
paul718e3742002-12-13 20:15:29 +00003719
3720 return bgp_vty_return (vty, ret);
3721}
3722
paul94f2b392005-06-28 12:44:16 +00003723static int
paulfd79ac92004-10-13 05:06:08 +00003724peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00003725 safi_t safi)
3726{
3727 int ret;
3728 struct peer *peer;
3729
3730 peer = peer_and_group_lookup_vty (vty, ip_str);
3731 if (! peer)
3732 return CMD_WARNING;
3733
3734 ret = peer_maximum_prefix_unset (peer, afi, safi);
3735
3736 return bgp_vty_return (vty, ret);
3737}
3738
3739/* Maximum number of prefix configuration. prefix count is different
3740 for each peer configuration. So this configuration can be set for
3741 each peer configuration. */
3742DEFUN (neighbor_maximum_prefix,
3743 neighbor_maximum_prefix_cmd,
3744 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
3745 NEIGHBOR_STR
3746 NEIGHBOR_ADDR_STR2
3747 "Maximum number of prefix accept from this peer\n"
3748 "maximum no. of prefix limit\n")
3749{
3750 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
hasso0a486e52005-02-01 20:57:17 +00003751 bgp_node_safi (vty), argv[1], NULL, 0,
3752 NULL);
paul718e3742002-12-13 20:15:29 +00003753}
3754
hassoe0701b72004-05-20 09:19:34 +00003755DEFUN (neighbor_maximum_prefix_threshold,
3756 neighbor_maximum_prefix_threshold_cmd,
3757 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100>",
3758 NEIGHBOR_STR
3759 NEIGHBOR_ADDR_STR2
3760 "Maximum number of prefix accept from this peer\n"
3761 "maximum no. of prefix limit\n"
3762 "Threshold value (%) at which to generate a warning msg\n")
3763{
3764 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
hasso0a486e52005-02-01 20:57:17 +00003765 bgp_node_safi (vty), argv[1], argv[2], 0,
3766 NULL);
3767}
hassoe0701b72004-05-20 09:19:34 +00003768
paul718e3742002-12-13 20:15:29 +00003769DEFUN (neighbor_maximum_prefix_warning,
3770 neighbor_maximum_prefix_warning_cmd,
3771 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
3772 NEIGHBOR_STR
3773 NEIGHBOR_ADDR_STR2
3774 "Maximum number of prefix accept from this peer\n"
3775 "maximum no. of prefix limit\n"
3776 "Only give warning message when limit is exceeded\n")
3777{
3778 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
hasso0a486e52005-02-01 20:57:17 +00003779 bgp_node_safi (vty), argv[1], NULL, 1,
3780 NULL);
paul718e3742002-12-13 20:15:29 +00003781}
3782
hassoe0701b72004-05-20 09:19:34 +00003783DEFUN (neighbor_maximum_prefix_threshold_warning,
3784 neighbor_maximum_prefix_threshold_warning_cmd,
3785 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
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 "Only give warning message when limit is exceeded\n")
3792{
3793 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
hasso0a486e52005-02-01 20:57:17 +00003794 bgp_node_safi (vty), argv[1], argv[2], 1, NULL);
3795}
3796
3797DEFUN (neighbor_maximum_prefix_restart,
3798 neighbor_maximum_prefix_restart_cmd,
3799 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
3800 NEIGHBOR_STR
3801 NEIGHBOR_ADDR_STR2
3802 "Maximum number of prefix accept from this peer\n"
3803 "maximum no. of prefix limit\n"
3804 "Restart bgp connection after limit is exceeded\n"
3805 "Restart interval in minutes")
3806{
3807 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
3808 bgp_node_safi (vty), argv[1], NULL, 0, argv[2]);
3809}
3810
3811DEFUN (neighbor_maximum_prefix_threshold_restart,
3812 neighbor_maximum_prefix_threshold_restart_cmd,
3813 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
3814 NEIGHBOR_STR
3815 NEIGHBOR_ADDR_STR2
3816 "Maximum number of prefix accept from this peer\n"
3817 "maximum no. of prefix limit\n"
3818 "Threshold value (%) at which to generate a warning msg\n"
3819 "Restart bgp connection after limit is exceeded\n"
3820 "Restart interval in minutes")
3821{
3822 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
3823 bgp_node_safi (vty), argv[1], argv[2], 0, argv[3]);
3824}
hassoe0701b72004-05-20 09:19:34 +00003825
paul718e3742002-12-13 20:15:29 +00003826DEFUN (no_neighbor_maximum_prefix,
3827 no_neighbor_maximum_prefix_cmd,
3828 NO_NEIGHBOR_CMD2 "maximum-prefix",
3829 NO_STR
3830 NEIGHBOR_STR
3831 NEIGHBOR_ADDR_STR2
3832 "Maximum number of prefix accept from this peer\n")
3833{
3834 return peer_maximum_prefix_unset_vty (vty, argv[0], bgp_node_afi (vty),
3835 bgp_node_safi (vty));
3836}
3837
3838ALIAS (no_neighbor_maximum_prefix,
3839 no_neighbor_maximum_prefix_val_cmd,
3840 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
3841 NO_STR
3842 NEIGHBOR_STR
3843 NEIGHBOR_ADDR_STR2
3844 "Maximum number of prefix accept from this peer\n"
3845 "maximum no. of prefix limit\n")
3846
3847ALIAS (no_neighbor_maximum_prefix,
hasso0a486e52005-02-01 20:57:17 +00003848 no_neighbor_maximum_prefix_threshold_cmd,
3849 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
3850 NO_STR
3851 NEIGHBOR_STR
3852 NEIGHBOR_ADDR_STR2
3853 "Maximum number of prefix accept from this peer\n"
3854 "maximum no. of prefix limit\n"
3855 "Threshold value (%) at which to generate a warning msg\n")
3856
3857ALIAS (no_neighbor_maximum_prefix,
3858 no_neighbor_maximum_prefix_warning_cmd,
3859 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
3860 NO_STR
3861 NEIGHBOR_STR
3862 NEIGHBOR_ADDR_STR2
3863 "Maximum number of prefix accept from this peer\n"
3864 "maximum no. of prefix limit\n"
paule8e19462006-01-19 20:16:55 +00003865 "Only give warning message when limit is exceeded\n")
hasso0a486e52005-02-01 20:57:17 +00003866
3867ALIAS (no_neighbor_maximum_prefix,
3868 no_neighbor_maximum_prefix_threshold_warning_cmd,
hassoe0701b72004-05-20 09:19:34 +00003869 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
3870 NO_STR
3871 NEIGHBOR_STR
3872 NEIGHBOR_ADDR_STR2
3873 "Maximum number of prefix accept from this peer\n"
3874 "maximum no. of prefix limit\n"
3875 "Threshold value (%) at which to generate a warning msg\n"
paule8e19462006-01-19 20:16:55 +00003876 "Only give warning message when limit is exceeded\n")
hassoe0701b72004-05-20 09:19:34 +00003877
3878ALIAS (no_neighbor_maximum_prefix,
hasso0a486e52005-02-01 20:57:17 +00003879 no_neighbor_maximum_prefix_restart_cmd,
3880 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
paul718e3742002-12-13 20:15:29 +00003881 NO_STR
3882 NEIGHBOR_STR
3883 NEIGHBOR_ADDR_STR2
3884 "Maximum number of prefix accept from this peer\n"
3885 "maximum no. of prefix limit\n"
hasso0a486e52005-02-01 20:57:17 +00003886 "Restart bgp connection after limit is exceeded\n"
3887 "Restart interval in minutes")
3888
3889ALIAS (no_neighbor_maximum_prefix,
3890 no_neighbor_maximum_prefix_threshold_restart_cmd,
3891 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
3892 NO_STR
3893 NEIGHBOR_STR
3894 NEIGHBOR_ADDR_STR2
3895 "Maximum number of prefix accept from this peer\n"
3896 "maximum no. of prefix limit\n"
3897 "Threshold value (%) at which to generate a warning msg\n"
3898 "Restart bgp connection after limit is exceeded\n"
3899 "Restart interval in minutes")
paul718e3742002-12-13 20:15:29 +00003900
3901/* "neighbor allowas-in" */
3902DEFUN (neighbor_allowas_in,
3903 neighbor_allowas_in_cmd,
3904 NEIGHBOR_CMD2 "allowas-in",
3905 NEIGHBOR_STR
3906 NEIGHBOR_ADDR_STR2
3907 "Accept as-path with my AS present in it\n")
3908{
3909 int ret;
3910 struct peer *peer;
paulfd79ac92004-10-13 05:06:08 +00003911 unsigned int allow_num;
paul718e3742002-12-13 20:15:29 +00003912
3913 peer = peer_and_group_lookup_vty (vty, argv[0]);
3914 if (! peer)
3915 return CMD_WARNING;
3916
3917 if (argc == 1)
3918 allow_num = 3;
3919 else
3920 VTY_GET_INTEGER_RANGE ("AS number", allow_num, argv[1], 1, 10);
3921
3922 ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty),
3923 allow_num);
3924
3925 return bgp_vty_return (vty, ret);
3926}
3927
3928ALIAS (neighbor_allowas_in,
3929 neighbor_allowas_in_arg_cmd,
3930 NEIGHBOR_CMD2 "allowas-in <1-10>",
3931 NEIGHBOR_STR
3932 NEIGHBOR_ADDR_STR2
3933 "Accept as-path with my AS present in it\n"
3934 "Number of occurances of AS number\n")
3935
3936DEFUN (no_neighbor_allowas_in,
3937 no_neighbor_allowas_in_cmd,
3938 NO_NEIGHBOR_CMD2 "allowas-in",
3939 NO_STR
3940 NEIGHBOR_STR
3941 NEIGHBOR_ADDR_STR2
3942 "allow local ASN appears in aspath attribute\n")
3943{
3944 int ret;
3945 struct peer *peer;
3946
3947 peer = peer_and_group_lookup_vty (vty, argv[0]);
3948 if (! peer)
3949 return CMD_WARNING;
3950
3951 ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty));
3952
3953 return bgp_vty_return (vty, ret);
3954}
3955
Nick Hilliardfa411a22011-03-23 15:33:17 +00003956DEFUN (neighbor_ttl_security,
3957 neighbor_ttl_security_cmd,
3958 NEIGHBOR_CMD2 "ttl-security hops <1-254>",
3959 NEIGHBOR_STR
3960 NEIGHBOR_ADDR_STR2
3961 "Specify the maximum number of hops to the BGP peer\n")
3962{
3963 struct peer *peer;
Stephen Hemminger89b6d1f2011-03-24 10:51:59 +00003964 int gtsm_hops;
Nick Hilliardfa411a22011-03-23 15:33:17 +00003965
3966 peer = peer_and_group_lookup_vty (vty, argv[0]);
3967 if (! peer)
3968 return CMD_WARNING;
3969
3970 VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[1], 1, 254);
3971
Stephen Hemminger89b6d1f2011-03-24 10:51:59 +00003972 return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, gtsm_hops));
Nick Hilliardfa411a22011-03-23 15:33:17 +00003973}
3974
3975DEFUN (no_neighbor_ttl_security,
3976 no_neighbor_ttl_security_cmd,
3977 NO_NEIGHBOR_CMD2 "ttl-security hops <1-254>",
3978 NO_STR
3979 NEIGHBOR_STR
3980 NEIGHBOR_ADDR_STR2
3981 "Specify the maximum number of hops to the BGP peer\n")
3982{
3983 struct peer *peer;
Nick Hilliardfa411a22011-03-23 15:33:17 +00003984
3985 peer = peer_and_group_lookup_vty (vty, argv[0]);
3986 if (! peer)
3987 return CMD_WARNING;
3988
Stephen Hemminger89b6d1f2011-03-24 10:51:59 +00003989 return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer));
Nick Hilliardfa411a22011-03-23 15:33:17 +00003990}
3991
paul718e3742002-12-13 20:15:29 +00003992/* Address family configuration. */
3993DEFUN (address_family_ipv4,
3994 address_family_ipv4_cmd,
3995 "address-family ipv4",
3996 "Enter Address Family command mode\n"
3997 "Address family\n")
3998{
3999 vty->node = BGP_IPV4_NODE;
4000 return CMD_SUCCESS;
4001}
4002
4003DEFUN (address_family_ipv4_safi,
4004 address_family_ipv4_safi_cmd,
4005 "address-family ipv4 (unicast|multicast)",
4006 "Enter Address Family command mode\n"
4007 "Address family\n"
4008 "Address Family modifier\n"
4009 "Address Family modifier\n")
4010{
4011 if (strncmp (argv[0], "m", 1) == 0)
4012 vty->node = BGP_IPV4M_NODE;
4013 else
4014 vty->node = BGP_IPV4_NODE;
4015
4016 return CMD_SUCCESS;
4017}
4018
paul25ffbdc2005-08-22 22:42:08 +00004019DEFUN (address_family_ipv6,
4020 address_family_ipv6_cmd,
4021 "address-family ipv6",
paul718e3742002-12-13 20:15:29 +00004022 "Enter Address Family command mode\n"
paul25ffbdc2005-08-22 22:42:08 +00004023 "Address family\n")
paul718e3742002-12-13 20:15:29 +00004024{
4025 vty->node = BGP_IPV6_NODE;
4026 return CMD_SUCCESS;
4027}
4028
paul25ffbdc2005-08-22 22:42:08 +00004029DEFUN (address_family_ipv6_safi,
4030 address_family_ipv6_safi_cmd,
4031 "address-family ipv6 (unicast|multicast)",
paul718e3742002-12-13 20:15:29 +00004032 "Enter Address Family command mode\n"
paul25ffbdc2005-08-22 22:42:08 +00004033 "Address family\n"
4034 "Address Family modifier\n"
4035 "Address Family modifier\n")
4036{
4037 if (strncmp (argv[0], "m", 1) == 0)
4038 vty->node = BGP_IPV6M_NODE;
4039 else
4040 vty->node = BGP_IPV6_NODE;
4041
4042 return CMD_SUCCESS;
4043}
paul718e3742002-12-13 20:15:29 +00004044
4045DEFUN (address_family_vpnv4,
4046 address_family_vpnv4_cmd,
4047 "address-family vpnv4",
4048 "Enter Address Family command mode\n"
4049 "Address family\n")
4050{
4051 vty->node = BGP_VPNV4_NODE;
4052 return CMD_SUCCESS;
4053}
4054
4055ALIAS (address_family_vpnv4,
4056 address_family_vpnv4_unicast_cmd,
4057 "address-family vpnv4 unicast",
4058 "Enter Address Family command mode\n"
4059 "Address family\n"
4060 "Address Family Modifier\n")
4061
4062DEFUN (exit_address_family,
4063 exit_address_family_cmd,
4064 "exit-address-family",
4065 "Exit from Address Family configuration mode\n")
4066{
hassoa8a80d52005-04-09 13:07:47 +00004067 if (vty->node == BGP_IPV4_NODE
4068 || vty->node == BGP_IPV4M_NODE
paul718e3742002-12-13 20:15:29 +00004069 || vty->node == BGP_VPNV4_NODE
paul25ffbdc2005-08-22 22:42:08 +00004070 || vty->node == BGP_IPV6_NODE
4071 || vty->node == BGP_IPV6M_NODE)
paul718e3742002-12-13 20:15:29 +00004072 vty->node = BGP_NODE;
4073 return CMD_SUCCESS;
4074}
4075
4076/* BGP clear sort. */
4077enum clear_sort
4078{
4079 clear_all,
4080 clear_peer,
4081 clear_group,
4082 clear_external,
4083 clear_as
4084};
4085
paul94f2b392005-06-28 12:44:16 +00004086static void
paul718e3742002-12-13 20:15:29 +00004087bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi,
4088 safi_t safi, int error)
4089{
4090 switch (error)
4091 {
4092 case BGP_ERR_AF_UNCONFIGURED:
4093 vty_out (vty,
4094 "%%BGP: Enable %s %s address family for the neighbor %s%s",
4095 afi == AFI_IP6 ? "IPv6" : safi == SAFI_MPLS_VPN ? "VPNv4" : "IPv4",
4096 safi == SAFI_MULTICAST ? "Multicast" : "Unicast",
4097 peer->host, VTY_NEWLINE);
4098 break;
4099 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED:
4100 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);
4101 break;
4102 default:
4103 break;
4104 }
4105}
4106
4107/* `clear ip bgp' functions. */
paul94f2b392005-06-28 12:44:16 +00004108static int
paul718e3742002-12-13 20:15:29 +00004109bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
paulfd79ac92004-10-13 05:06:08 +00004110 enum clear_sort sort,enum bgp_clear_type stype, const char *arg)
paul718e3742002-12-13 20:15:29 +00004111{
4112 int ret;
4113 struct peer *peer;
paul1eb8ef22005-04-07 07:30:20 +00004114 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00004115
4116 /* Clear all neighbors. */
4117 if (sort == clear_all)
4118 {
paul1eb8ef22005-04-07 07:30:20 +00004119 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00004120 {
4121 if (stype == BGP_CLEAR_SOFT_NONE)
4122 ret = peer_clear (peer);
4123 else
4124 ret = peer_clear_soft (peer, afi, safi, stype);
4125
4126 if (ret < 0)
4127 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4128 }
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004129 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00004130 }
4131
4132 /* Clear specified neighbors. */
4133 if (sort == clear_peer)
4134 {
4135 union sockunion su;
4136 int ret;
4137
4138 /* Make sockunion for lookup. */
4139 ret = str2sockunion (arg, &su);
4140 if (ret < 0)
4141 {
4142 vty_out (vty, "Malformed address: %s%s", arg, VTY_NEWLINE);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004143 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +00004144 }
4145 peer = peer_lookup (bgp, &su);
4146 if (! peer)
4147 {
4148 vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004149 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +00004150 }
4151
4152 if (stype == BGP_CLEAR_SOFT_NONE)
4153 ret = peer_clear (peer);
4154 else
4155 ret = peer_clear_soft (peer, afi, safi, stype);
4156
4157 if (ret < 0)
4158 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4159
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004160 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00004161 }
4162
4163 /* Clear all peer-group members. */
4164 if (sort == clear_group)
4165 {
4166 struct peer_group *group;
4167
4168 group = peer_group_lookup (bgp, arg);
4169 if (! group)
4170 {
4171 vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004172 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +00004173 }
4174
paul1eb8ef22005-04-07 07:30:20 +00004175 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00004176 {
4177 if (stype == BGP_CLEAR_SOFT_NONE)
4178 {
4179 ret = peer_clear (peer);
4180 continue;
4181 }
4182
4183 if (! peer->af_group[afi][safi])
4184 continue;
4185
4186 ret = peer_clear_soft (peer, afi, safi, stype);
4187
4188 if (ret < 0)
4189 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4190 }
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004191 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00004192 }
4193
4194 if (sort == clear_external)
4195 {
paul1eb8ef22005-04-07 07:30:20 +00004196 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00004197 {
4198 if (peer_sort (peer) == BGP_PEER_IBGP)
4199 continue;
4200
4201 if (stype == BGP_CLEAR_SOFT_NONE)
4202 ret = peer_clear (peer);
4203 else
4204 ret = peer_clear_soft (peer, afi, safi, stype);
4205
4206 if (ret < 0)
4207 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4208 }
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004209 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00004210 }
4211
4212 if (sort == clear_as)
4213 {
4214 as_t as;
4215 unsigned long as_ul;
paul718e3742002-12-13 20:15:29 +00004216 int find = 0;
4217
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004218 VTY_GET_LONG ("AS", as_ul, arg);
4219
4220 if (!as_ul)
paul718e3742002-12-13 20:15:29 +00004221 {
4222 vty_out (vty, "Invalid AS number%s", VTY_NEWLINE);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004223 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +00004224 }
4225 as = (as_t) as_ul;
4226
paul1eb8ef22005-04-07 07:30:20 +00004227 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00004228 {
4229 if (peer->as != as)
4230 continue;
4231
4232 find = 1;
4233 if (stype == BGP_CLEAR_SOFT_NONE)
4234 ret = peer_clear (peer);
4235 else
4236 ret = peer_clear_soft (peer, afi, safi, stype);
4237
4238 if (ret < 0)
4239 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4240 }
4241 if (! find)
4242 vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg,
4243 VTY_NEWLINE);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004244 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00004245 }
4246
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004247 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00004248}
4249
paul94f2b392005-06-28 12:44:16 +00004250static int
paulfd79ac92004-10-13 05:06:08 +00004251bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi,
4252 enum clear_sort sort, enum bgp_clear_type stype,
4253 const char *arg)
paul718e3742002-12-13 20:15:29 +00004254{
paul718e3742002-12-13 20:15:29 +00004255 struct bgp *bgp;
4256
4257 /* BGP structure lookup. */
4258 if (name)
4259 {
4260 bgp = bgp_lookup_by_name (name);
4261 if (bgp == NULL)
4262 {
4263 vty_out (vty, "Can't find BGP view %s%s", name, VTY_NEWLINE);
4264 return CMD_WARNING;
4265 }
4266 }
4267 else
4268 {
4269 bgp = bgp_get_default ();
4270 if (bgp == NULL)
4271 {
4272 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
4273 return CMD_WARNING;
4274 }
4275 }
4276
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004277 return bgp_clear (vty, bgp, afi, safi, sort, stype, arg);
paul718e3742002-12-13 20:15:29 +00004278}
4279
4280DEFUN (clear_ip_bgp_all,
4281 clear_ip_bgp_all_cmd,
4282 "clear ip bgp *",
4283 CLEAR_STR
4284 IP_STR
4285 BGP_STR
4286 "Clear all peers\n")
4287{
4288 if (argc == 1)
4289 return bgp_clear_vty (vty, argv[0], 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
4290
4291 return bgp_clear_vty (vty, NULL, 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
4292}
4293
4294ALIAS (clear_ip_bgp_all,
4295 clear_bgp_all_cmd,
4296 "clear bgp *",
4297 CLEAR_STR
4298 BGP_STR
4299 "Clear all peers\n")
4300
4301ALIAS (clear_ip_bgp_all,
4302 clear_bgp_ipv6_all_cmd,
4303 "clear bgp ipv6 *",
4304 CLEAR_STR
4305 BGP_STR
4306 "Address family\n"
4307 "Clear all peers\n")
4308
4309ALIAS (clear_ip_bgp_all,
4310 clear_ip_bgp_instance_all_cmd,
4311 "clear ip bgp view WORD *",
4312 CLEAR_STR
4313 IP_STR
4314 BGP_STR
4315 "BGP view\n"
4316 "view name\n"
4317 "Clear all peers\n")
4318
4319ALIAS (clear_ip_bgp_all,
4320 clear_bgp_instance_all_cmd,
4321 "clear bgp view WORD *",
4322 CLEAR_STR
4323 BGP_STR
4324 "BGP view\n"
4325 "view name\n"
4326 "Clear all peers\n")
4327
4328DEFUN (clear_ip_bgp_peer,
4329 clear_ip_bgp_peer_cmd,
4330 "clear ip bgp (A.B.C.D|X:X::X:X)",
4331 CLEAR_STR
4332 IP_STR
4333 BGP_STR
4334 "BGP neighbor IP address to clear\n"
4335 "BGP IPv6 neighbor to clear\n")
4336{
4337 return bgp_clear_vty (vty, NULL, 0, 0, clear_peer, BGP_CLEAR_SOFT_NONE, argv[0]);
4338}
4339
4340ALIAS (clear_ip_bgp_peer,
4341 clear_bgp_peer_cmd,
4342 "clear bgp (A.B.C.D|X:X::X:X)",
4343 CLEAR_STR
4344 BGP_STR
4345 "BGP neighbor address to clear\n"
4346 "BGP IPv6 neighbor to clear\n")
4347
4348ALIAS (clear_ip_bgp_peer,
4349 clear_bgp_ipv6_peer_cmd,
4350 "clear bgp ipv6 (A.B.C.D|X:X::X:X)",
4351 CLEAR_STR
4352 BGP_STR
4353 "Address family\n"
4354 "BGP neighbor address to clear\n"
4355 "BGP IPv6 neighbor to clear\n")
4356
4357DEFUN (clear_ip_bgp_peer_group,
4358 clear_ip_bgp_peer_group_cmd,
4359 "clear ip bgp peer-group WORD",
4360 CLEAR_STR
4361 IP_STR
4362 BGP_STR
4363 "Clear all members of peer-group\n"
4364 "BGP peer-group name\n")
4365{
4366 return bgp_clear_vty (vty, NULL, 0, 0, clear_group, BGP_CLEAR_SOFT_NONE, argv[0]);
4367}
4368
4369ALIAS (clear_ip_bgp_peer_group,
4370 clear_bgp_peer_group_cmd,
4371 "clear bgp peer-group WORD",
4372 CLEAR_STR
4373 BGP_STR
4374 "Clear all members of peer-group\n"
4375 "BGP peer-group name\n")
4376
4377ALIAS (clear_ip_bgp_peer_group,
4378 clear_bgp_ipv6_peer_group_cmd,
4379 "clear bgp ipv6 peer-group WORD",
4380 CLEAR_STR
4381 BGP_STR
4382 "Address family\n"
4383 "Clear all members of peer-group\n"
4384 "BGP peer-group name\n")
4385
4386DEFUN (clear_ip_bgp_external,
4387 clear_ip_bgp_external_cmd,
4388 "clear ip bgp external",
4389 CLEAR_STR
4390 IP_STR
4391 BGP_STR
4392 "Clear all external peers\n")
4393{
4394 return bgp_clear_vty (vty, NULL, 0, 0, clear_external, BGP_CLEAR_SOFT_NONE, NULL);
4395}
4396
4397ALIAS (clear_ip_bgp_external,
4398 clear_bgp_external_cmd,
4399 "clear bgp external",
4400 CLEAR_STR
4401 BGP_STR
4402 "Clear all external peers\n")
4403
4404ALIAS (clear_ip_bgp_external,
4405 clear_bgp_ipv6_external_cmd,
4406 "clear bgp ipv6 external",
4407 CLEAR_STR
4408 BGP_STR
4409 "Address family\n"
4410 "Clear all external peers\n")
4411
4412DEFUN (clear_ip_bgp_as,
4413 clear_ip_bgp_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004414 "clear ip bgp " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00004415 CLEAR_STR
4416 IP_STR
4417 BGP_STR
4418 "Clear peers with the AS number\n")
4419{
4420 return bgp_clear_vty (vty, NULL, 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[0]);
4421}
4422
4423ALIAS (clear_ip_bgp_as,
4424 clear_bgp_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004425 "clear bgp " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00004426 CLEAR_STR
4427 BGP_STR
4428 "Clear peers with the AS number\n")
4429
4430ALIAS (clear_ip_bgp_as,
4431 clear_bgp_ipv6_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004432 "clear bgp ipv6 " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00004433 CLEAR_STR
4434 BGP_STR
4435 "Address family\n"
4436 "Clear peers with the AS number\n")
4437
4438/* Outbound soft-reconfiguration */
4439DEFUN (clear_ip_bgp_all_soft_out,
4440 clear_ip_bgp_all_soft_out_cmd,
4441 "clear ip bgp * soft out",
4442 CLEAR_STR
4443 IP_STR
4444 BGP_STR
4445 "Clear all peers\n"
4446 "Soft reconfig\n"
4447 "Soft reconfig outbound update\n")
4448{
4449 if (argc == 1)
4450 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
4451 BGP_CLEAR_SOFT_OUT, NULL);
4452
4453 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
4454 BGP_CLEAR_SOFT_OUT, NULL);
4455}
4456
4457ALIAS (clear_ip_bgp_all_soft_out,
4458 clear_ip_bgp_all_out_cmd,
4459 "clear ip bgp * out",
4460 CLEAR_STR
4461 IP_STR
4462 BGP_STR
4463 "Clear all peers\n"
4464 "Soft reconfig outbound update\n")
4465
4466ALIAS (clear_ip_bgp_all_soft_out,
4467 clear_ip_bgp_instance_all_soft_out_cmd,
4468 "clear ip bgp view WORD * soft out",
4469 CLEAR_STR
4470 IP_STR
4471 BGP_STR
4472 "BGP view\n"
4473 "view name\n"
4474 "Clear all peers\n"
4475 "Soft reconfig\n"
4476 "Soft reconfig outbound update\n")
4477
4478DEFUN (clear_ip_bgp_all_ipv4_soft_out,
4479 clear_ip_bgp_all_ipv4_soft_out_cmd,
4480 "clear ip bgp * ipv4 (unicast|multicast) soft out",
4481 CLEAR_STR
4482 IP_STR
4483 BGP_STR
4484 "Clear all peers\n"
4485 "Address family\n"
4486 "Address Family modifier\n"
4487 "Address Family modifier\n"
4488 "Soft reconfig\n"
4489 "Soft reconfig outbound update\n")
4490{
4491 if (strncmp (argv[0], "m", 1) == 0)
4492 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
4493 BGP_CLEAR_SOFT_OUT, NULL);
4494
4495 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
4496 BGP_CLEAR_SOFT_OUT, NULL);
4497}
4498
4499ALIAS (clear_ip_bgp_all_ipv4_soft_out,
4500 clear_ip_bgp_all_ipv4_out_cmd,
4501 "clear ip bgp * ipv4 (unicast|multicast) out",
4502 CLEAR_STR
4503 IP_STR
4504 BGP_STR
4505 "Clear all peers\n"
4506 "Address family\n"
4507 "Address Family modifier\n"
4508 "Address Family modifier\n"
4509 "Soft reconfig outbound update\n")
4510
4511DEFUN (clear_ip_bgp_instance_all_ipv4_soft_out,
4512 clear_ip_bgp_instance_all_ipv4_soft_out_cmd,
4513 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft out",
4514 CLEAR_STR
4515 IP_STR
4516 BGP_STR
4517 "BGP view\n"
4518 "view name\n"
4519 "Clear all peers\n"
4520 "Address family\n"
4521 "Address Family modifier\n"
4522 "Address Family modifier\n"
4523 "Soft reconfig outbound update\n")
4524{
4525 if (strncmp (argv[1], "m", 1) == 0)
4526 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
4527 BGP_CLEAR_SOFT_OUT, NULL);
4528
4529 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
4530 BGP_CLEAR_SOFT_OUT, NULL);
4531}
4532
4533DEFUN (clear_ip_bgp_all_vpnv4_soft_out,
4534 clear_ip_bgp_all_vpnv4_soft_out_cmd,
4535 "clear ip bgp * vpnv4 unicast soft out",
4536 CLEAR_STR
4537 IP_STR
4538 BGP_STR
4539 "Clear all peers\n"
4540 "Address family\n"
4541 "Address Family Modifier\n"
4542 "Soft reconfig\n"
4543 "Soft reconfig outbound update\n")
4544{
4545 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
4546 BGP_CLEAR_SOFT_OUT, NULL);
4547}
4548
4549ALIAS (clear_ip_bgp_all_vpnv4_soft_out,
4550 clear_ip_bgp_all_vpnv4_out_cmd,
4551 "clear ip bgp * vpnv4 unicast out",
4552 CLEAR_STR
4553 IP_STR
4554 BGP_STR
4555 "Clear all peers\n"
4556 "Address family\n"
4557 "Address Family Modifier\n"
4558 "Soft reconfig outbound update\n")
4559
4560DEFUN (clear_bgp_all_soft_out,
4561 clear_bgp_all_soft_out_cmd,
4562 "clear bgp * soft out",
4563 CLEAR_STR
4564 BGP_STR
4565 "Clear all peers\n"
4566 "Soft reconfig\n"
4567 "Soft reconfig outbound update\n")
4568{
4569 if (argc == 1)
4570 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
4571 BGP_CLEAR_SOFT_OUT, NULL);
4572
4573 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
4574 BGP_CLEAR_SOFT_OUT, NULL);
4575}
4576
4577ALIAS (clear_bgp_all_soft_out,
4578 clear_bgp_instance_all_soft_out_cmd,
4579 "clear bgp view WORD * soft out",
4580 CLEAR_STR
4581 BGP_STR
4582 "BGP view\n"
4583 "view name\n"
4584 "Clear all peers\n"
4585 "Soft reconfig\n"
4586 "Soft reconfig outbound update\n")
4587
4588ALIAS (clear_bgp_all_soft_out,
4589 clear_bgp_all_out_cmd,
4590 "clear bgp * out",
4591 CLEAR_STR
4592 BGP_STR
4593 "Clear all peers\n"
4594 "Soft reconfig outbound update\n")
4595
4596ALIAS (clear_bgp_all_soft_out,
4597 clear_bgp_ipv6_all_soft_out_cmd,
4598 "clear bgp ipv6 * soft out",
4599 CLEAR_STR
4600 BGP_STR
4601 "Address family\n"
4602 "Clear all peers\n"
4603 "Soft reconfig\n"
4604 "Soft reconfig outbound update\n")
4605
4606ALIAS (clear_bgp_all_soft_out,
4607 clear_bgp_ipv6_all_out_cmd,
4608 "clear bgp ipv6 * out",
4609 CLEAR_STR
4610 BGP_STR
4611 "Address family\n"
4612 "Clear all peers\n"
4613 "Soft reconfig outbound update\n")
4614
4615DEFUN (clear_ip_bgp_peer_soft_out,
4616 clear_ip_bgp_peer_soft_out_cmd,
4617 "clear ip bgp A.B.C.D soft out",
4618 CLEAR_STR
4619 IP_STR
4620 BGP_STR
4621 "BGP neighbor address to clear\n"
4622 "Soft reconfig\n"
4623 "Soft reconfig outbound update\n")
4624{
4625 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
4626 BGP_CLEAR_SOFT_OUT, argv[0]);
4627}
4628
4629ALIAS (clear_ip_bgp_peer_soft_out,
4630 clear_ip_bgp_peer_out_cmd,
4631 "clear ip bgp A.B.C.D out",
4632 CLEAR_STR
4633 IP_STR
4634 BGP_STR
4635 "BGP neighbor address to clear\n"
4636 "Soft reconfig outbound update\n")
4637
4638DEFUN (clear_ip_bgp_peer_ipv4_soft_out,
4639 clear_ip_bgp_peer_ipv4_soft_out_cmd,
4640 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft out",
4641 CLEAR_STR
4642 IP_STR
4643 BGP_STR
4644 "BGP neighbor address to clear\n"
4645 "Address family\n"
4646 "Address Family modifier\n"
4647 "Address Family modifier\n"
4648 "Soft reconfig\n"
4649 "Soft reconfig outbound update\n")
4650{
4651 if (strncmp (argv[1], "m", 1) == 0)
4652 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
4653 BGP_CLEAR_SOFT_OUT, argv[0]);
4654
4655 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
4656 BGP_CLEAR_SOFT_OUT, argv[0]);
4657}
4658
4659ALIAS (clear_ip_bgp_peer_ipv4_soft_out,
4660 clear_ip_bgp_peer_ipv4_out_cmd,
4661 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) out",
4662 CLEAR_STR
4663 IP_STR
4664 BGP_STR
4665 "BGP neighbor address to clear\n"
4666 "Address family\n"
4667 "Address Family modifier\n"
4668 "Address Family modifier\n"
4669 "Soft reconfig outbound update\n")
4670
4671DEFUN (clear_ip_bgp_peer_vpnv4_soft_out,
4672 clear_ip_bgp_peer_vpnv4_soft_out_cmd,
4673 "clear ip bgp A.B.C.D vpnv4 unicast soft out",
4674 CLEAR_STR
4675 IP_STR
4676 BGP_STR
4677 "BGP neighbor address to clear\n"
4678 "Address family\n"
4679 "Address Family Modifier\n"
4680 "Soft reconfig\n"
4681 "Soft reconfig outbound update\n")
4682{
4683 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
4684 BGP_CLEAR_SOFT_OUT, argv[0]);
4685}
4686
4687ALIAS (clear_ip_bgp_peer_vpnv4_soft_out,
4688 clear_ip_bgp_peer_vpnv4_out_cmd,
4689 "clear ip bgp A.B.C.D vpnv4 unicast out",
4690 CLEAR_STR
4691 IP_STR
4692 BGP_STR
4693 "BGP neighbor address to clear\n"
4694 "Address family\n"
4695 "Address Family Modifier\n"
4696 "Soft reconfig outbound update\n")
4697
4698DEFUN (clear_bgp_peer_soft_out,
4699 clear_bgp_peer_soft_out_cmd,
4700 "clear bgp (A.B.C.D|X:X::X:X) soft out",
4701 CLEAR_STR
4702 BGP_STR
4703 "BGP neighbor address to clear\n"
4704 "BGP IPv6 neighbor to clear\n"
4705 "Soft reconfig\n"
4706 "Soft reconfig outbound update\n")
4707{
4708 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
4709 BGP_CLEAR_SOFT_OUT, argv[0]);
4710}
4711
4712ALIAS (clear_bgp_peer_soft_out,
4713 clear_bgp_ipv6_peer_soft_out_cmd,
4714 "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft out",
4715 CLEAR_STR
4716 BGP_STR
4717 "Address family\n"
4718 "BGP neighbor address to clear\n"
4719 "BGP IPv6 neighbor to clear\n"
4720 "Soft reconfig\n"
4721 "Soft reconfig outbound update\n")
4722
4723ALIAS (clear_bgp_peer_soft_out,
4724 clear_bgp_peer_out_cmd,
4725 "clear bgp (A.B.C.D|X:X::X:X) out",
4726 CLEAR_STR
4727 BGP_STR
4728 "BGP neighbor address to clear\n"
4729 "BGP IPv6 neighbor to clear\n"
4730 "Soft reconfig outbound update\n")
4731
4732ALIAS (clear_bgp_peer_soft_out,
4733 clear_bgp_ipv6_peer_out_cmd,
4734 "clear bgp ipv6 (A.B.C.D|X:X::X:X) out",
4735 CLEAR_STR
4736 BGP_STR
4737 "Address family\n"
4738 "BGP neighbor address to clear\n"
4739 "BGP IPv6 neighbor to clear\n"
4740 "Soft reconfig outbound update\n")
4741
4742DEFUN (clear_ip_bgp_peer_group_soft_out,
4743 clear_ip_bgp_peer_group_soft_out_cmd,
4744 "clear ip bgp peer-group WORD soft out",
4745 CLEAR_STR
4746 IP_STR
4747 BGP_STR
4748 "Clear all members of peer-group\n"
4749 "BGP peer-group name\n"
4750 "Soft reconfig\n"
4751 "Soft reconfig outbound update\n")
4752{
4753 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
4754 BGP_CLEAR_SOFT_OUT, argv[0]);
4755}
4756
4757ALIAS (clear_ip_bgp_peer_group_soft_out,
4758 clear_ip_bgp_peer_group_out_cmd,
4759 "clear ip bgp peer-group WORD out",
4760 CLEAR_STR
4761 IP_STR
4762 BGP_STR
4763 "Clear all members of peer-group\n"
4764 "BGP peer-group name\n"
4765 "Soft reconfig outbound update\n")
4766
4767DEFUN (clear_ip_bgp_peer_group_ipv4_soft_out,
4768 clear_ip_bgp_peer_group_ipv4_soft_out_cmd,
4769 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft out",
4770 CLEAR_STR
4771 IP_STR
4772 BGP_STR
4773 "Clear all members of peer-group\n"
4774 "BGP peer-group name\n"
4775 "Address family\n"
4776 "Address Family modifier\n"
4777 "Address Family modifier\n"
4778 "Soft reconfig\n"
4779 "Soft reconfig outbound update\n")
4780{
4781 if (strncmp (argv[1], "m", 1) == 0)
4782 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
4783 BGP_CLEAR_SOFT_OUT, argv[0]);
4784
4785 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
4786 BGP_CLEAR_SOFT_OUT, argv[0]);
4787}
4788
4789ALIAS (clear_ip_bgp_peer_group_ipv4_soft_out,
4790 clear_ip_bgp_peer_group_ipv4_out_cmd,
4791 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) out",
4792 CLEAR_STR
4793 IP_STR
4794 BGP_STR
4795 "Clear all members of peer-group\n"
4796 "BGP peer-group name\n"
4797 "Address family\n"
4798 "Address Family modifier\n"
4799 "Address Family modifier\n"
4800 "Soft reconfig outbound update\n")
4801
4802DEFUN (clear_bgp_peer_group_soft_out,
4803 clear_bgp_peer_group_soft_out_cmd,
4804 "clear bgp peer-group WORD soft out",
4805 CLEAR_STR
4806 BGP_STR
4807 "Clear all members of peer-group\n"
4808 "BGP peer-group name\n"
4809 "Soft reconfig\n"
4810 "Soft reconfig outbound update\n")
4811{
4812 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
4813 BGP_CLEAR_SOFT_OUT, argv[0]);
4814}
4815
4816ALIAS (clear_bgp_peer_group_soft_out,
4817 clear_bgp_ipv6_peer_group_soft_out_cmd,
4818 "clear bgp ipv6 peer-group WORD soft out",
4819 CLEAR_STR
4820 BGP_STR
4821 "Address family\n"
4822 "Clear all members of peer-group\n"
4823 "BGP peer-group name\n"
4824 "Soft reconfig\n"
4825 "Soft reconfig outbound update\n")
4826
4827ALIAS (clear_bgp_peer_group_soft_out,
4828 clear_bgp_peer_group_out_cmd,
4829 "clear bgp peer-group WORD out",
4830 CLEAR_STR
4831 BGP_STR
4832 "Clear all members of peer-group\n"
4833 "BGP peer-group name\n"
4834 "Soft reconfig outbound update\n")
4835
4836ALIAS (clear_bgp_peer_group_soft_out,
4837 clear_bgp_ipv6_peer_group_out_cmd,
4838 "clear bgp ipv6 peer-group WORD out",
4839 CLEAR_STR
4840 BGP_STR
4841 "Address family\n"
4842 "Clear all members of peer-group\n"
4843 "BGP peer-group name\n"
4844 "Soft reconfig outbound update\n")
4845
4846DEFUN (clear_ip_bgp_external_soft_out,
4847 clear_ip_bgp_external_soft_out_cmd,
4848 "clear ip bgp external soft out",
4849 CLEAR_STR
4850 IP_STR
4851 BGP_STR
4852 "Clear all external peers\n"
4853 "Soft reconfig\n"
4854 "Soft reconfig outbound update\n")
4855{
4856 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
4857 BGP_CLEAR_SOFT_OUT, NULL);
4858}
4859
4860ALIAS (clear_ip_bgp_external_soft_out,
4861 clear_ip_bgp_external_out_cmd,
4862 "clear ip bgp external out",
4863 CLEAR_STR
4864 IP_STR
4865 BGP_STR
4866 "Clear all external peers\n"
4867 "Soft reconfig outbound update\n")
4868
4869DEFUN (clear_ip_bgp_external_ipv4_soft_out,
4870 clear_ip_bgp_external_ipv4_soft_out_cmd,
4871 "clear ip bgp external ipv4 (unicast|multicast) soft out",
4872 CLEAR_STR
4873 IP_STR
4874 BGP_STR
4875 "Clear all external peers\n"
4876 "Address family\n"
4877 "Address Family modifier\n"
4878 "Address Family modifier\n"
4879 "Soft reconfig\n"
4880 "Soft reconfig outbound update\n")
4881{
4882 if (strncmp (argv[0], "m", 1) == 0)
4883 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
4884 BGP_CLEAR_SOFT_OUT, NULL);
4885
4886 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
4887 BGP_CLEAR_SOFT_OUT, NULL);
4888}
4889
4890ALIAS (clear_ip_bgp_external_ipv4_soft_out,
4891 clear_ip_bgp_external_ipv4_out_cmd,
4892 "clear ip bgp external ipv4 (unicast|multicast) out",
4893 CLEAR_STR
4894 IP_STR
4895 BGP_STR
4896 "Clear all external peers\n"
4897 "Address family\n"
4898 "Address Family modifier\n"
4899 "Address Family modifier\n"
4900 "Soft reconfig outbound update\n")
4901
4902DEFUN (clear_bgp_external_soft_out,
4903 clear_bgp_external_soft_out_cmd,
4904 "clear bgp external soft out",
4905 CLEAR_STR
4906 BGP_STR
4907 "Clear all external peers\n"
4908 "Soft reconfig\n"
4909 "Soft reconfig outbound update\n")
4910{
4911 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
4912 BGP_CLEAR_SOFT_OUT, NULL);
4913}
4914
4915ALIAS (clear_bgp_external_soft_out,
4916 clear_bgp_ipv6_external_soft_out_cmd,
4917 "clear bgp ipv6 external soft out",
4918 CLEAR_STR
4919 BGP_STR
4920 "Address family\n"
4921 "Clear all external peers\n"
4922 "Soft reconfig\n"
4923 "Soft reconfig outbound update\n")
4924
4925ALIAS (clear_bgp_external_soft_out,
4926 clear_bgp_external_out_cmd,
4927 "clear bgp external out",
4928 CLEAR_STR
4929 BGP_STR
4930 "Clear all external peers\n"
4931 "Soft reconfig outbound update\n")
4932
4933ALIAS (clear_bgp_external_soft_out,
4934 clear_bgp_ipv6_external_out_cmd,
4935 "clear bgp ipv6 external WORD out",
4936 CLEAR_STR
4937 BGP_STR
4938 "Address family\n"
4939 "Clear all external peers\n"
4940 "Soft reconfig outbound update\n")
4941
4942DEFUN (clear_ip_bgp_as_soft_out,
4943 clear_ip_bgp_as_soft_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004944 "clear ip bgp " CMD_AS_RANGE " soft out",
paul718e3742002-12-13 20:15:29 +00004945 CLEAR_STR
4946 IP_STR
4947 BGP_STR
4948 "Clear peers with the AS number\n"
4949 "Soft reconfig\n"
4950 "Soft reconfig outbound update\n")
4951{
4952 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
4953 BGP_CLEAR_SOFT_OUT, argv[0]);
4954}
4955
4956ALIAS (clear_ip_bgp_as_soft_out,
4957 clear_ip_bgp_as_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004958 "clear ip bgp " CMD_AS_RANGE " out",
paul718e3742002-12-13 20:15:29 +00004959 CLEAR_STR
4960 IP_STR
4961 BGP_STR
4962 "Clear peers with the AS number\n"
4963 "Soft reconfig outbound update\n")
4964
4965DEFUN (clear_ip_bgp_as_ipv4_soft_out,
4966 clear_ip_bgp_as_ipv4_soft_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004967 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft out",
paul718e3742002-12-13 20:15:29 +00004968 CLEAR_STR
4969 IP_STR
4970 BGP_STR
4971 "Clear peers with the AS number\n"
4972 "Address family\n"
4973 "Address Family modifier\n"
4974 "Address Family modifier\n"
4975 "Soft reconfig\n"
4976 "Soft reconfig outbound update\n")
4977{
4978 if (strncmp (argv[1], "m", 1) == 0)
4979 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
4980 BGP_CLEAR_SOFT_OUT, argv[0]);
4981
4982 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
4983 BGP_CLEAR_SOFT_OUT, argv[0]);
4984}
4985
4986ALIAS (clear_ip_bgp_as_ipv4_soft_out,
4987 clear_ip_bgp_as_ipv4_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004988 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) out",
paul718e3742002-12-13 20:15:29 +00004989 CLEAR_STR
4990 IP_STR
4991 BGP_STR
4992 "Clear peers with the AS number\n"
4993 "Address family\n"
4994 "Address Family modifier\n"
4995 "Address Family modifier\n"
4996 "Soft reconfig outbound update\n")
4997
4998DEFUN (clear_ip_bgp_as_vpnv4_soft_out,
4999 clear_ip_bgp_as_vpnv4_soft_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005000 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft out",
paul718e3742002-12-13 20:15:29 +00005001 CLEAR_STR
5002 IP_STR
5003 BGP_STR
5004 "Clear peers with the AS number\n"
5005 "Address family\n"
5006 "Address Family modifier\n"
5007 "Soft reconfig\n"
5008 "Soft reconfig outbound update\n")
5009{
5010 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
5011 BGP_CLEAR_SOFT_OUT, argv[0]);
5012}
5013
5014ALIAS (clear_ip_bgp_as_vpnv4_soft_out,
5015 clear_ip_bgp_as_vpnv4_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005016 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast out",
paul718e3742002-12-13 20:15:29 +00005017 CLEAR_STR
5018 IP_STR
5019 BGP_STR
5020 "Clear peers with the AS number\n"
5021 "Address family\n"
5022 "Address Family modifier\n"
5023 "Soft reconfig outbound update\n")
5024
5025DEFUN (clear_bgp_as_soft_out,
5026 clear_bgp_as_soft_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005027 "clear bgp " CMD_AS_RANGE " soft out",
paul718e3742002-12-13 20:15:29 +00005028 CLEAR_STR
5029 BGP_STR
5030 "Clear peers with the AS number\n"
5031 "Soft reconfig\n"
5032 "Soft reconfig outbound update\n")
5033{
5034 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
5035 BGP_CLEAR_SOFT_OUT, argv[0]);
5036}
5037
5038ALIAS (clear_bgp_as_soft_out,
5039 clear_bgp_ipv6_as_soft_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005040 "clear bgp ipv6 " CMD_AS_RANGE " soft out",
paul718e3742002-12-13 20:15:29 +00005041 CLEAR_STR
5042 BGP_STR
5043 "Address family\n"
5044 "Clear peers with the AS number\n"
5045 "Soft reconfig\n"
5046 "Soft reconfig outbound update\n")
5047
5048ALIAS (clear_bgp_as_soft_out,
5049 clear_bgp_as_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005050 "clear bgp " CMD_AS_RANGE " out",
paul718e3742002-12-13 20:15:29 +00005051 CLEAR_STR
5052 BGP_STR
5053 "Clear peers with the AS number\n"
5054 "Soft reconfig outbound update\n")
5055
5056ALIAS (clear_bgp_as_soft_out,
5057 clear_bgp_ipv6_as_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005058 "clear bgp ipv6 " CMD_AS_RANGE " out",
paul718e3742002-12-13 20:15:29 +00005059 CLEAR_STR
5060 BGP_STR
5061 "Address family\n"
5062 "Clear peers with the AS number\n"
5063 "Soft reconfig outbound update\n")
5064
5065/* Inbound soft-reconfiguration */
5066DEFUN (clear_ip_bgp_all_soft_in,
5067 clear_ip_bgp_all_soft_in_cmd,
5068 "clear ip bgp * soft in",
5069 CLEAR_STR
5070 IP_STR
5071 BGP_STR
5072 "Clear all peers\n"
5073 "Soft reconfig\n"
5074 "Soft reconfig inbound update\n")
5075{
5076 if (argc == 1)
5077 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5078 BGP_CLEAR_SOFT_IN, NULL);
5079
5080 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5081 BGP_CLEAR_SOFT_IN, NULL);
5082}
5083
5084ALIAS (clear_ip_bgp_all_soft_in,
5085 clear_ip_bgp_instance_all_soft_in_cmd,
5086 "clear ip bgp view WORD * soft in",
5087 CLEAR_STR
5088 IP_STR
5089 BGP_STR
5090 "BGP view\n"
5091 "view name\n"
5092 "Clear all peers\n"
5093 "Soft reconfig\n"
5094 "Soft reconfig inbound update\n")
5095
5096ALIAS (clear_ip_bgp_all_soft_in,
5097 clear_ip_bgp_all_in_cmd,
5098 "clear ip bgp * in",
5099 CLEAR_STR
5100 IP_STR
5101 BGP_STR
5102 "Clear all peers\n"
5103 "Soft reconfig inbound update\n")
5104
5105DEFUN (clear_ip_bgp_all_in_prefix_filter,
5106 clear_ip_bgp_all_in_prefix_filter_cmd,
5107 "clear ip bgp * in prefix-filter",
5108 CLEAR_STR
5109 IP_STR
5110 BGP_STR
5111 "Clear all peers\n"
5112 "Soft reconfig inbound update\n"
5113 "Push out prefix-list ORF and do inbound soft reconfig\n")
5114{
5115 if (argc== 1)
5116 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5117 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5118
5119 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5120 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5121}
5122
5123ALIAS (clear_ip_bgp_all_in_prefix_filter,
5124 clear_ip_bgp_instance_all_in_prefix_filter_cmd,
5125 "clear ip bgp view WORD * in prefix-filter",
5126 CLEAR_STR
5127 IP_STR
5128 BGP_STR
5129 "BGP view\n"
5130 "view name\n"
5131 "Clear all peers\n"
5132 "Soft reconfig inbound update\n"
5133 "Push out prefix-list ORF and do inbound soft reconfig\n")
5134
5135
5136DEFUN (clear_ip_bgp_all_ipv4_soft_in,
5137 clear_ip_bgp_all_ipv4_soft_in_cmd,
5138 "clear ip bgp * ipv4 (unicast|multicast) soft in",
5139 CLEAR_STR
5140 IP_STR
5141 BGP_STR
5142 "Clear all peers\n"
5143 "Address family\n"
5144 "Address Family modifier\n"
5145 "Address Family modifier\n"
5146 "Soft reconfig\n"
5147 "Soft reconfig inbound update\n")
5148{
5149 if (strncmp (argv[0], "m", 1) == 0)
5150 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
5151 BGP_CLEAR_SOFT_IN, NULL);
5152
5153 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5154 BGP_CLEAR_SOFT_IN, NULL);
5155}
5156
5157ALIAS (clear_ip_bgp_all_ipv4_soft_in,
5158 clear_ip_bgp_all_ipv4_in_cmd,
5159 "clear ip bgp * ipv4 (unicast|multicast) in",
5160 CLEAR_STR
5161 IP_STR
5162 BGP_STR
5163 "Clear all peers\n"
5164 "Address family\n"
5165 "Address Family modifier\n"
5166 "Address Family modifier\n"
5167 "Soft reconfig inbound update\n")
5168
5169DEFUN (clear_ip_bgp_instance_all_ipv4_soft_in,
5170 clear_ip_bgp_instance_all_ipv4_soft_in_cmd,
5171 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft in",
5172 CLEAR_STR
5173 IP_STR
5174 BGP_STR
5175 "BGP view\n"
5176 "view name\n"
5177 "Clear all peers\n"
5178 "Address family\n"
5179 "Address Family modifier\n"
5180 "Address Family modifier\n"
5181 "Soft reconfig\n"
5182 "Soft reconfig inbound update\n")
5183{
5184 if (strncmp (argv[1], "m", 1) == 0)
5185 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
5186 BGP_CLEAR_SOFT_IN, NULL);
5187
5188 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5189 BGP_CLEAR_SOFT_IN, NULL);
5190}
5191
5192DEFUN (clear_ip_bgp_all_ipv4_in_prefix_filter,
5193 clear_ip_bgp_all_ipv4_in_prefix_filter_cmd,
5194 "clear ip bgp * ipv4 (unicast|multicast) in prefix-filter",
5195 CLEAR_STR
5196 IP_STR
5197 BGP_STR
5198 "Clear all peers\n"
5199 "Address family\n"
5200 "Address Family modifier\n"
5201 "Address Family modifier\n"
5202 "Soft reconfig inbound update\n"
5203 "Push out prefix-list ORF and do inbound soft reconfig\n")
5204{
5205 if (strncmp (argv[0], "m", 1) == 0)
5206 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
5207 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5208
5209 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5210 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5211}
5212
5213DEFUN (clear_ip_bgp_instance_all_ipv4_in_prefix_filter,
5214 clear_ip_bgp_instance_all_ipv4_in_prefix_filter_cmd,
5215 "clear ip bgp view WORD * ipv4 (unicast|multicast) in prefix-filter",
5216 CLEAR_STR
5217 IP_STR
5218 BGP_STR
5219 "Clear all peers\n"
5220 "Address family\n"
5221 "Address Family modifier\n"
5222 "Address Family modifier\n"
5223 "Soft reconfig inbound update\n"
5224 "Push out prefix-list ORF and do inbound soft reconfig\n")
5225{
5226 if (strncmp (argv[1], "m", 1) == 0)
5227 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
5228 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5229
5230 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5231 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5232}
5233
5234DEFUN (clear_ip_bgp_all_vpnv4_soft_in,
5235 clear_ip_bgp_all_vpnv4_soft_in_cmd,
5236 "clear ip bgp * vpnv4 unicast soft in",
5237 CLEAR_STR
5238 IP_STR
5239 BGP_STR
5240 "Clear all peers\n"
5241 "Address family\n"
5242 "Address Family Modifier\n"
5243 "Soft reconfig\n"
5244 "Soft reconfig inbound update\n")
5245{
5246 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
5247 BGP_CLEAR_SOFT_IN, NULL);
5248}
5249
5250ALIAS (clear_ip_bgp_all_vpnv4_soft_in,
5251 clear_ip_bgp_all_vpnv4_in_cmd,
5252 "clear ip bgp * vpnv4 unicast in",
5253 CLEAR_STR
5254 IP_STR
5255 BGP_STR
5256 "Clear all peers\n"
5257 "Address family\n"
5258 "Address Family Modifier\n"
5259 "Soft reconfig inbound update\n")
5260
5261DEFUN (clear_bgp_all_soft_in,
5262 clear_bgp_all_soft_in_cmd,
5263 "clear bgp * soft in",
5264 CLEAR_STR
5265 BGP_STR
5266 "Clear all peers\n"
5267 "Soft reconfig\n"
5268 "Soft reconfig inbound update\n")
5269{
5270 if (argc == 1)
5271 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
5272 BGP_CLEAR_SOFT_IN, NULL);
5273
5274 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
5275 BGP_CLEAR_SOFT_IN, NULL);
5276}
5277
5278ALIAS (clear_bgp_all_soft_in,
5279 clear_bgp_instance_all_soft_in_cmd,
5280 "clear bgp view WORD * soft in",
5281 CLEAR_STR
5282 BGP_STR
5283 "BGP view\n"
5284 "view name\n"
5285 "Clear all peers\n"
5286 "Soft reconfig\n"
5287 "Soft reconfig inbound update\n")
5288
5289ALIAS (clear_bgp_all_soft_in,
5290 clear_bgp_ipv6_all_soft_in_cmd,
5291 "clear bgp ipv6 * soft in",
5292 CLEAR_STR
5293 BGP_STR
5294 "Address family\n"
5295 "Clear all peers\n"
5296 "Soft reconfig\n"
5297 "Soft reconfig inbound update\n")
5298
5299ALIAS (clear_bgp_all_soft_in,
5300 clear_bgp_all_in_cmd,
5301 "clear bgp * in",
5302 CLEAR_STR
5303 BGP_STR
5304 "Clear all peers\n"
5305 "Soft reconfig inbound update\n")
5306
5307ALIAS (clear_bgp_all_soft_in,
5308 clear_bgp_ipv6_all_in_cmd,
5309 "clear bgp ipv6 * in",
5310 CLEAR_STR
5311 BGP_STR
5312 "Address family\n"
5313 "Clear all peers\n"
5314 "Soft reconfig inbound update\n")
5315
5316DEFUN (clear_bgp_all_in_prefix_filter,
5317 clear_bgp_all_in_prefix_filter_cmd,
5318 "clear bgp * in prefix-filter",
5319 CLEAR_STR
5320 BGP_STR
5321 "Clear all peers\n"
5322 "Soft reconfig inbound update\n"
5323 "Push out prefix-list ORF and do inbound soft reconfig\n")
5324{
5325 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
5326 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5327}
5328
5329ALIAS (clear_bgp_all_in_prefix_filter,
5330 clear_bgp_ipv6_all_in_prefix_filter_cmd,
5331 "clear bgp ipv6 * in prefix-filter",
5332 CLEAR_STR
5333 BGP_STR
5334 "Address family\n"
5335 "Clear all peers\n"
5336 "Soft reconfig inbound update\n"
5337 "Push out prefix-list ORF and do inbound soft reconfig\n")
5338
5339DEFUN (clear_ip_bgp_peer_soft_in,
5340 clear_ip_bgp_peer_soft_in_cmd,
5341 "clear ip bgp A.B.C.D soft in",
5342 CLEAR_STR
5343 IP_STR
5344 BGP_STR
5345 "BGP neighbor address to clear\n"
5346 "Soft reconfig\n"
5347 "Soft reconfig inbound update\n")
5348{
5349 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5350 BGP_CLEAR_SOFT_IN, argv[0]);
5351}
5352
5353ALIAS (clear_ip_bgp_peer_soft_in,
5354 clear_ip_bgp_peer_in_cmd,
5355 "clear ip bgp A.B.C.D in",
5356 CLEAR_STR
5357 IP_STR
5358 BGP_STR
5359 "BGP neighbor address to clear\n"
5360 "Soft reconfig inbound update\n")
5361
5362DEFUN (clear_ip_bgp_peer_in_prefix_filter,
5363 clear_ip_bgp_peer_in_prefix_filter_cmd,
5364 "clear ip bgp A.B.C.D in prefix-filter",
5365 CLEAR_STR
5366 IP_STR
5367 BGP_STR
5368 "BGP neighbor address to clear\n"
5369 "Soft reconfig inbound update\n"
5370 "Push out the existing ORF prefix-list\n")
5371{
5372 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5373 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5374}
5375
5376DEFUN (clear_ip_bgp_peer_ipv4_soft_in,
5377 clear_ip_bgp_peer_ipv4_soft_in_cmd,
5378 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft in",
5379 CLEAR_STR
5380 IP_STR
5381 BGP_STR
5382 "BGP neighbor address to clear\n"
5383 "Address family\n"
5384 "Address Family modifier\n"
5385 "Address Family modifier\n"
5386 "Soft reconfig\n"
5387 "Soft reconfig inbound update\n")
5388{
5389 if (strncmp (argv[1], "m", 1) == 0)
5390 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
5391 BGP_CLEAR_SOFT_IN, argv[0]);
5392
5393 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5394 BGP_CLEAR_SOFT_IN, argv[0]);
5395}
5396
5397ALIAS (clear_ip_bgp_peer_ipv4_soft_in,
5398 clear_ip_bgp_peer_ipv4_in_cmd,
5399 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) in",
5400 CLEAR_STR
5401 IP_STR
5402 BGP_STR
5403 "BGP neighbor address to clear\n"
5404 "Address family\n"
5405 "Address Family modifier\n"
5406 "Address Family modifier\n"
5407 "Soft reconfig inbound update\n")
5408
5409DEFUN (clear_ip_bgp_peer_ipv4_in_prefix_filter,
5410 clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd,
5411 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) in prefix-filter",
5412 CLEAR_STR
5413 IP_STR
5414 BGP_STR
5415 "BGP neighbor address to clear\n"
5416 "Address family\n"
5417 "Address Family modifier\n"
5418 "Address Family modifier\n"
5419 "Soft reconfig inbound update\n"
5420 "Push out the existing ORF prefix-list\n")
5421{
5422 if (strncmp (argv[1], "m", 1) == 0)
5423 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
5424 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5425
5426 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5427 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5428}
5429
5430DEFUN (clear_ip_bgp_peer_vpnv4_soft_in,
5431 clear_ip_bgp_peer_vpnv4_soft_in_cmd,
5432 "clear ip bgp A.B.C.D vpnv4 unicast soft in",
5433 CLEAR_STR
5434 IP_STR
5435 BGP_STR
5436 "BGP neighbor address to clear\n"
5437 "Address family\n"
5438 "Address Family Modifier\n"
5439 "Soft reconfig\n"
5440 "Soft reconfig inbound update\n")
5441{
5442 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
5443 BGP_CLEAR_SOFT_IN, argv[0]);
5444}
5445
5446ALIAS (clear_ip_bgp_peer_vpnv4_soft_in,
5447 clear_ip_bgp_peer_vpnv4_in_cmd,
5448 "clear ip bgp A.B.C.D vpnv4 unicast in",
5449 CLEAR_STR
5450 IP_STR
5451 BGP_STR
5452 "BGP neighbor address to clear\n"
5453 "Address family\n"
5454 "Address Family Modifier\n"
5455 "Soft reconfig inbound update\n")
5456
5457DEFUN (clear_bgp_peer_soft_in,
5458 clear_bgp_peer_soft_in_cmd,
5459 "clear bgp (A.B.C.D|X:X::X:X) soft in",
5460 CLEAR_STR
5461 BGP_STR
5462 "BGP neighbor address to clear\n"
5463 "BGP IPv6 neighbor to clear\n"
5464 "Soft reconfig\n"
5465 "Soft reconfig inbound update\n")
5466{
5467 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
5468 BGP_CLEAR_SOFT_IN, argv[0]);
5469}
5470
5471ALIAS (clear_bgp_peer_soft_in,
5472 clear_bgp_ipv6_peer_soft_in_cmd,
5473 "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft in",
5474 CLEAR_STR
5475 BGP_STR
5476 "Address family\n"
5477 "BGP neighbor address to clear\n"
5478 "BGP IPv6 neighbor to clear\n"
5479 "Soft reconfig\n"
5480 "Soft reconfig inbound update\n")
5481
5482ALIAS (clear_bgp_peer_soft_in,
5483 clear_bgp_peer_in_cmd,
5484 "clear bgp (A.B.C.D|X:X::X:X) in",
5485 CLEAR_STR
5486 BGP_STR
5487 "BGP neighbor address to clear\n"
5488 "BGP IPv6 neighbor to clear\n"
5489 "Soft reconfig inbound update\n")
5490
5491ALIAS (clear_bgp_peer_soft_in,
5492 clear_bgp_ipv6_peer_in_cmd,
5493 "clear bgp ipv6 (A.B.C.D|X:X::X:X) in",
5494 CLEAR_STR
5495 BGP_STR
5496 "Address family\n"
5497 "BGP neighbor address to clear\n"
5498 "BGP IPv6 neighbor to clear\n"
5499 "Soft reconfig inbound update\n")
5500
5501DEFUN (clear_bgp_peer_in_prefix_filter,
5502 clear_bgp_peer_in_prefix_filter_cmd,
5503 "clear bgp (A.B.C.D|X:X::X:X) in prefix-filter",
5504 CLEAR_STR
5505 BGP_STR
5506 "BGP neighbor address to clear\n"
5507 "BGP IPv6 neighbor to clear\n"
5508 "Soft reconfig inbound update\n"
5509 "Push out the existing ORF prefix-list\n")
5510{
5511 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
5512 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5513}
5514
5515ALIAS (clear_bgp_peer_in_prefix_filter,
5516 clear_bgp_ipv6_peer_in_prefix_filter_cmd,
5517 "clear bgp ipv6 (A.B.C.D|X:X::X:X) in prefix-filter",
5518 CLEAR_STR
5519 BGP_STR
5520 "Address family\n"
5521 "BGP neighbor address to clear\n"
5522 "BGP IPv6 neighbor to clear\n"
5523 "Soft reconfig inbound update\n"
5524 "Push out the existing ORF prefix-list\n")
5525
5526DEFUN (clear_ip_bgp_peer_group_soft_in,
5527 clear_ip_bgp_peer_group_soft_in_cmd,
5528 "clear ip bgp peer-group WORD soft in",
5529 CLEAR_STR
5530 IP_STR
5531 BGP_STR
5532 "Clear all members of peer-group\n"
5533 "BGP peer-group name\n"
5534 "Soft reconfig\n"
5535 "Soft reconfig inbound update\n")
5536{
5537 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5538 BGP_CLEAR_SOFT_IN, argv[0]);
5539}
5540
5541ALIAS (clear_ip_bgp_peer_group_soft_in,
5542 clear_ip_bgp_peer_group_in_cmd,
5543 "clear ip bgp peer-group WORD in",
5544 CLEAR_STR
5545 IP_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
5551DEFUN (clear_ip_bgp_peer_group_in_prefix_filter,
5552 clear_ip_bgp_peer_group_in_prefix_filter_cmd,
5553 "clear ip bgp peer-group WORD in prefix-filter",
5554 CLEAR_STR
5555 IP_STR
5556 BGP_STR
5557 "Clear all members of peer-group\n"
5558 "BGP peer-group name\n"
5559 "Soft reconfig inbound update\n"
5560 "Push out prefix-list ORF and do inbound soft reconfig\n")
5561{
5562 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5563 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5564}
5565
5566DEFUN (clear_ip_bgp_peer_group_ipv4_soft_in,
5567 clear_ip_bgp_peer_group_ipv4_soft_in_cmd,
5568 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft in",
5569 CLEAR_STR
5570 IP_STR
5571 BGP_STR
5572 "Clear all members of peer-group\n"
5573 "BGP peer-group name\n"
5574 "Address family\n"
5575 "Address Family modifier\n"
5576 "Address Family modifier\n"
5577 "Soft reconfig\n"
5578 "Soft reconfig inbound update\n")
5579{
5580 if (strncmp (argv[1], "m", 1) == 0)
5581 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
5582 BGP_CLEAR_SOFT_IN, argv[0]);
5583
5584 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5585 BGP_CLEAR_SOFT_IN, argv[0]);
5586}
5587
5588ALIAS (clear_ip_bgp_peer_group_ipv4_soft_in,
5589 clear_ip_bgp_peer_group_ipv4_in_cmd,
5590 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in",
5591 CLEAR_STR
5592 IP_STR
5593 BGP_STR
5594 "Clear all members of peer-group\n"
5595 "BGP peer-group name\n"
5596 "Address family\n"
5597 "Address Family modifier\n"
5598 "Address Family modifier\n"
5599 "Soft reconfig inbound update\n")
5600
5601DEFUN (clear_ip_bgp_peer_group_ipv4_in_prefix_filter,
5602 clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd,
5603 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in prefix-filter",
5604 CLEAR_STR
5605 IP_STR
5606 BGP_STR
5607 "Clear all members of peer-group\n"
5608 "BGP peer-group name\n"
5609 "Address family\n"
5610 "Address Family modifier\n"
5611 "Address Family modifier\n"
5612 "Soft reconfig inbound update\n"
5613 "Push out prefix-list ORF and do inbound soft reconfig\n")
5614{
5615 if (strncmp (argv[1], "m", 1) == 0)
5616 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
5617 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5618
5619 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5620 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5621}
5622
5623DEFUN (clear_bgp_peer_group_soft_in,
5624 clear_bgp_peer_group_soft_in_cmd,
5625 "clear bgp peer-group WORD soft in",
5626 CLEAR_STR
5627 BGP_STR
5628 "Clear all members of peer-group\n"
5629 "BGP peer-group name\n"
5630 "Soft reconfig\n"
5631 "Soft reconfig inbound update\n")
5632{
5633 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
5634 BGP_CLEAR_SOFT_IN, argv[0]);
5635}
5636
5637ALIAS (clear_bgp_peer_group_soft_in,
5638 clear_bgp_ipv6_peer_group_soft_in_cmd,
5639 "clear bgp ipv6 peer-group WORD soft in",
5640 CLEAR_STR
5641 BGP_STR
5642 "Address family\n"
5643 "Clear all members of peer-group\n"
5644 "BGP peer-group name\n"
5645 "Soft reconfig\n"
5646 "Soft reconfig inbound update\n")
5647
5648ALIAS (clear_bgp_peer_group_soft_in,
5649 clear_bgp_peer_group_in_cmd,
5650 "clear bgp peer-group WORD in",
5651 CLEAR_STR
5652 BGP_STR
5653 "Clear all members of peer-group\n"
5654 "BGP peer-group name\n"
5655 "Soft reconfig inbound update\n")
5656
5657ALIAS (clear_bgp_peer_group_soft_in,
5658 clear_bgp_ipv6_peer_group_in_cmd,
5659 "clear bgp ipv6 peer-group WORD in",
5660 CLEAR_STR
5661 BGP_STR
5662 "Address family\n"
5663 "Clear all members of peer-group\n"
5664 "BGP peer-group name\n"
5665 "Soft reconfig inbound update\n")
5666
5667DEFUN (clear_bgp_peer_group_in_prefix_filter,
5668 clear_bgp_peer_group_in_prefix_filter_cmd,
5669 "clear bgp peer-group WORD in prefix-filter",
5670 CLEAR_STR
5671 BGP_STR
5672 "Clear all members of peer-group\n"
5673 "BGP peer-group name\n"
5674 "Soft reconfig inbound update\n"
5675 "Push out prefix-list ORF and do inbound soft reconfig\n")
5676{
5677 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
5678 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5679}
5680
5681ALIAS (clear_bgp_peer_group_in_prefix_filter,
5682 clear_bgp_ipv6_peer_group_in_prefix_filter_cmd,
5683 "clear bgp ipv6 peer-group WORD in prefix-filter",
5684 CLEAR_STR
5685 BGP_STR
5686 "Address family\n"
5687 "Clear all members of peer-group\n"
5688 "BGP peer-group name\n"
5689 "Soft reconfig inbound update\n"
5690 "Push out prefix-list ORF and do inbound soft reconfig\n")
5691
5692DEFUN (clear_ip_bgp_external_soft_in,
5693 clear_ip_bgp_external_soft_in_cmd,
5694 "clear ip bgp external soft in",
5695 CLEAR_STR
5696 IP_STR
5697 BGP_STR
5698 "Clear all external peers\n"
5699 "Soft reconfig\n"
5700 "Soft reconfig inbound update\n")
5701{
5702 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5703 BGP_CLEAR_SOFT_IN, NULL);
5704}
5705
5706ALIAS (clear_ip_bgp_external_soft_in,
5707 clear_ip_bgp_external_in_cmd,
5708 "clear ip bgp external in",
5709 CLEAR_STR
5710 IP_STR
5711 BGP_STR
5712 "Clear all external peers\n"
5713 "Soft reconfig inbound update\n")
5714
5715DEFUN (clear_ip_bgp_external_in_prefix_filter,
5716 clear_ip_bgp_external_in_prefix_filter_cmd,
5717 "clear ip bgp external in prefix-filter",
5718 CLEAR_STR
5719 IP_STR
5720 BGP_STR
5721 "Clear all external peers\n"
5722 "Soft reconfig inbound update\n"
5723 "Push out prefix-list ORF and do inbound soft reconfig\n")
5724{
5725 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5726 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5727}
5728
5729DEFUN (clear_ip_bgp_external_ipv4_soft_in,
5730 clear_ip_bgp_external_ipv4_soft_in_cmd,
5731 "clear ip bgp external ipv4 (unicast|multicast) soft in",
5732 CLEAR_STR
5733 IP_STR
5734 BGP_STR
5735 "Clear all external peers\n"
5736 "Address family\n"
5737 "Address Family modifier\n"
5738 "Address Family modifier\n"
5739 "Soft reconfig\n"
5740 "Soft reconfig inbound update\n")
5741{
5742 if (strncmp (argv[0], "m", 1) == 0)
5743 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
5744 BGP_CLEAR_SOFT_IN, NULL);
5745
5746 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5747 BGP_CLEAR_SOFT_IN, NULL);
5748}
5749
5750ALIAS (clear_ip_bgp_external_ipv4_soft_in,
5751 clear_ip_bgp_external_ipv4_in_cmd,
5752 "clear ip bgp external ipv4 (unicast|multicast) in",
5753 CLEAR_STR
5754 IP_STR
5755 BGP_STR
5756 "Clear all external peers\n"
5757 "Address family\n"
5758 "Address Family modifier\n"
5759 "Address Family modifier\n"
5760 "Soft reconfig inbound update\n")
5761
5762DEFUN (clear_ip_bgp_external_ipv4_in_prefix_filter,
5763 clear_ip_bgp_external_ipv4_in_prefix_filter_cmd,
5764 "clear ip bgp external ipv4 (unicast|multicast) in prefix-filter",
5765 CLEAR_STR
5766 IP_STR
5767 BGP_STR
5768 "Clear all external peers\n"
5769 "Address family\n"
5770 "Address Family modifier\n"
5771 "Address Family modifier\n"
5772 "Soft reconfig inbound update\n"
5773 "Push out prefix-list ORF and do inbound soft reconfig\n")
5774{
5775 if (strncmp (argv[0], "m", 1) == 0)
5776 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
5777 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5778
5779 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5780 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5781}
5782
5783DEFUN (clear_bgp_external_soft_in,
5784 clear_bgp_external_soft_in_cmd,
5785 "clear bgp external soft in",
5786 CLEAR_STR
5787 BGP_STR
5788 "Clear all external peers\n"
5789 "Soft reconfig\n"
5790 "Soft reconfig inbound update\n")
5791{
5792 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
5793 BGP_CLEAR_SOFT_IN, NULL);
5794}
5795
5796ALIAS (clear_bgp_external_soft_in,
5797 clear_bgp_ipv6_external_soft_in_cmd,
5798 "clear bgp ipv6 external soft in",
5799 CLEAR_STR
5800 BGP_STR
5801 "Address family\n"
5802 "Clear all external peers\n"
5803 "Soft reconfig\n"
5804 "Soft reconfig inbound update\n")
5805
5806ALIAS (clear_bgp_external_soft_in,
5807 clear_bgp_external_in_cmd,
5808 "clear bgp external in",
5809 CLEAR_STR
5810 BGP_STR
5811 "Clear all external peers\n"
5812 "Soft reconfig inbound update\n")
5813
5814ALIAS (clear_bgp_external_soft_in,
5815 clear_bgp_ipv6_external_in_cmd,
5816 "clear bgp ipv6 external WORD in",
5817 CLEAR_STR
5818 BGP_STR
5819 "Address family\n"
5820 "Clear all external peers\n"
5821 "Soft reconfig inbound update\n")
5822
5823DEFUN (clear_bgp_external_in_prefix_filter,
5824 clear_bgp_external_in_prefix_filter_cmd,
5825 "clear bgp external in prefix-filter",
5826 CLEAR_STR
5827 BGP_STR
5828 "Clear all external peers\n"
5829 "Soft reconfig inbound update\n"
5830 "Push out prefix-list ORF and do inbound soft reconfig\n")
5831{
5832 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
5833 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5834}
5835
5836ALIAS (clear_bgp_external_in_prefix_filter,
5837 clear_bgp_ipv6_external_in_prefix_filter_cmd,
5838 "clear bgp ipv6 external in prefix-filter",
5839 CLEAR_STR
5840 BGP_STR
5841 "Address family\n"
5842 "Clear all external peers\n"
5843 "Soft reconfig inbound update\n"
5844 "Push out prefix-list ORF and do inbound soft reconfig\n")
5845
5846DEFUN (clear_ip_bgp_as_soft_in,
5847 clear_ip_bgp_as_soft_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005848 "clear ip bgp " CMD_AS_RANGE " soft in",
paul718e3742002-12-13 20:15:29 +00005849 CLEAR_STR
5850 IP_STR
5851 BGP_STR
5852 "Clear peers with the AS number\n"
5853 "Soft reconfig\n"
5854 "Soft reconfig inbound update\n")
5855{
5856 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5857 BGP_CLEAR_SOFT_IN, argv[0]);
5858}
5859
5860ALIAS (clear_ip_bgp_as_soft_in,
5861 clear_ip_bgp_as_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005862 "clear ip bgp " CMD_AS_RANGE " in",
paul718e3742002-12-13 20:15:29 +00005863 CLEAR_STR
5864 IP_STR
5865 BGP_STR
5866 "Clear peers with the AS number\n"
5867 "Soft reconfig inbound update\n")
5868
5869DEFUN (clear_ip_bgp_as_in_prefix_filter,
5870 clear_ip_bgp_as_in_prefix_filter_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005871 "clear ip bgp " CMD_AS_RANGE " in prefix-filter",
paul718e3742002-12-13 20:15:29 +00005872 CLEAR_STR
5873 IP_STR
5874 BGP_STR
5875 "Clear peers with the AS number\n"
5876 "Soft reconfig inbound update\n"
5877 "Push out prefix-list ORF and do inbound soft reconfig\n")
5878{
5879 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5880 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5881}
5882
5883DEFUN (clear_ip_bgp_as_ipv4_soft_in,
5884 clear_ip_bgp_as_ipv4_soft_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005885 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft in",
paul718e3742002-12-13 20:15:29 +00005886 CLEAR_STR
5887 IP_STR
5888 BGP_STR
5889 "Clear peers with the AS number\n"
5890 "Address family\n"
5891 "Address Family modifier\n"
5892 "Address Family modifier\n"
5893 "Soft reconfig\n"
5894 "Soft reconfig inbound update\n")
5895{
5896 if (strncmp (argv[1], "m", 1) == 0)
5897 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
5898 BGP_CLEAR_SOFT_IN, argv[0]);
5899
5900 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5901 BGP_CLEAR_SOFT_IN, argv[0]);
5902}
5903
5904ALIAS (clear_ip_bgp_as_ipv4_soft_in,
5905 clear_ip_bgp_as_ipv4_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005906 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in",
paul718e3742002-12-13 20:15:29 +00005907 CLEAR_STR
5908 IP_STR
5909 BGP_STR
5910 "Clear peers with the AS number\n"
5911 "Address family\n"
5912 "Address Family modifier\n"
5913 "Address Family modifier\n"
5914 "Soft reconfig inbound update\n")
5915
5916DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter,
5917 clear_ip_bgp_as_ipv4_in_prefix_filter_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005918 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in prefix-filter",
paul718e3742002-12-13 20:15:29 +00005919 CLEAR_STR
5920 IP_STR
5921 BGP_STR
5922 "Clear peers with the AS number\n"
5923 "Address family\n"
5924 "Address Family modifier\n"
5925 "Address Family modifier\n"
5926 "Soft reconfig inbound update\n"
5927 "Push out prefix-list ORF and do inbound soft reconfig\n")
5928{
5929 if (strncmp (argv[1], "m", 1) == 0)
5930 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
5931 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5932
5933 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5934 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5935}
5936
5937DEFUN (clear_ip_bgp_as_vpnv4_soft_in,
5938 clear_ip_bgp_as_vpnv4_soft_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005939 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft in",
paul718e3742002-12-13 20:15:29 +00005940 CLEAR_STR
5941 IP_STR
5942 BGP_STR
5943 "Clear peers with the AS number\n"
5944 "Address family\n"
5945 "Address Family modifier\n"
5946 "Soft reconfig\n"
5947 "Soft reconfig inbound update\n")
5948{
5949 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
5950 BGP_CLEAR_SOFT_IN, argv[0]);
5951}
5952
5953ALIAS (clear_ip_bgp_as_vpnv4_soft_in,
5954 clear_ip_bgp_as_vpnv4_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005955 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast in",
paul718e3742002-12-13 20:15:29 +00005956 CLEAR_STR
5957 IP_STR
5958 BGP_STR
5959 "Clear peers with the AS number\n"
5960 "Address family\n"
5961 "Address Family modifier\n"
5962 "Soft reconfig inbound update\n")
5963
5964DEFUN (clear_bgp_as_soft_in,
5965 clear_bgp_as_soft_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005966 "clear bgp " CMD_AS_RANGE " soft in",
paul718e3742002-12-13 20:15:29 +00005967 CLEAR_STR
5968 BGP_STR
5969 "Clear peers with the AS number\n"
5970 "Soft reconfig\n"
5971 "Soft reconfig inbound update\n")
5972{
5973 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
5974 BGP_CLEAR_SOFT_IN, argv[0]);
5975}
5976
5977ALIAS (clear_bgp_as_soft_in,
5978 clear_bgp_ipv6_as_soft_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005979 "clear bgp ipv6 " CMD_AS_RANGE " soft in",
paul718e3742002-12-13 20:15:29 +00005980 CLEAR_STR
5981 BGP_STR
5982 "Address family\n"
5983 "Clear peers with the AS number\n"
5984 "Soft reconfig\n"
5985 "Soft reconfig inbound update\n")
5986
5987ALIAS (clear_bgp_as_soft_in,
5988 clear_bgp_as_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005989 "clear bgp " CMD_AS_RANGE " in",
paul718e3742002-12-13 20:15:29 +00005990 CLEAR_STR
5991 BGP_STR
5992 "Clear peers with the AS number\n"
5993 "Soft reconfig inbound update\n")
5994
5995ALIAS (clear_bgp_as_soft_in,
5996 clear_bgp_ipv6_as_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005997 "clear bgp ipv6 " CMD_AS_RANGE " in",
paul718e3742002-12-13 20:15:29 +00005998 CLEAR_STR
5999 BGP_STR
6000 "Address family\n"
6001 "Clear peers with the AS number\n"
6002 "Soft reconfig inbound update\n")
6003
6004DEFUN (clear_bgp_as_in_prefix_filter,
6005 clear_bgp_as_in_prefix_filter_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006006 "clear bgp " CMD_AS_RANGE " in prefix-filter",
paul718e3742002-12-13 20:15:29 +00006007 CLEAR_STR
6008 BGP_STR
6009 "Clear peers with the AS number\n"
6010 "Soft reconfig inbound update\n"
6011 "Push out prefix-list ORF and do inbound soft reconfig\n")
6012{
6013 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
6014 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6015}
6016
6017ALIAS (clear_bgp_as_in_prefix_filter,
6018 clear_bgp_ipv6_as_in_prefix_filter_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006019 "clear bgp ipv6 " CMD_AS_RANGE " in prefix-filter",
paul718e3742002-12-13 20:15:29 +00006020 CLEAR_STR
6021 BGP_STR
6022 "Address family\n"
6023 "Clear peers with the AS number\n"
6024 "Soft reconfig inbound update\n"
6025 "Push out prefix-list ORF and do inbound soft reconfig\n")
6026
6027/* Both soft-reconfiguration */
6028DEFUN (clear_ip_bgp_all_soft,
6029 clear_ip_bgp_all_soft_cmd,
6030 "clear ip bgp * soft",
6031 CLEAR_STR
6032 IP_STR
6033 BGP_STR
6034 "Clear all peers\n"
6035 "Soft reconfig\n")
6036{
6037 if (argc == 1)
6038 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
6039 BGP_CLEAR_SOFT_BOTH, NULL);
6040
6041 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6042 BGP_CLEAR_SOFT_BOTH, NULL);
6043}
6044
6045ALIAS (clear_ip_bgp_all_soft,
6046 clear_ip_bgp_instance_all_soft_cmd,
6047 "clear ip bgp view WORD * soft",
6048 CLEAR_STR
6049 IP_STR
6050 BGP_STR
6051 "BGP view\n"
6052 "view name\n"
6053 "Clear all peers\n"
6054 "Soft reconfig\n")
6055
6056
6057DEFUN (clear_ip_bgp_all_ipv4_soft,
6058 clear_ip_bgp_all_ipv4_soft_cmd,
6059 "clear ip bgp * ipv4 (unicast|multicast) soft",
6060 CLEAR_STR
6061 IP_STR
6062 BGP_STR
6063 "Clear all peers\n"
6064 "Address family\n"
6065 "Address Family Modifier\n"
6066 "Address Family Modifier\n"
6067 "Soft reconfig\n")
6068{
6069 if (strncmp (argv[0], "m", 1) == 0)
6070 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
6071 BGP_CLEAR_SOFT_BOTH, NULL);
6072
6073 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6074 BGP_CLEAR_SOFT_BOTH, NULL);
6075}
6076
6077DEFUN (clear_ip_bgp_instance_all_ipv4_soft,
6078 clear_ip_bgp_instance_all_ipv4_soft_cmd,
6079 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft",
6080 CLEAR_STR
6081 IP_STR
6082 BGP_STR
6083 "BGP view\n"
6084 "view name\n"
6085 "Clear all peers\n"
6086 "Address family\n"
6087 "Address Family Modifier\n"
6088 "Address Family Modifier\n"
6089 "Soft reconfig\n")
6090{
6091 if (strncmp (argv[1], "m", 1) == 0)
6092 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
6093 BGP_CLEAR_SOFT_BOTH, NULL);
6094
6095 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6096 BGP_CLEAR_SOFT_BOTH, NULL);
6097}
6098
6099DEFUN (clear_ip_bgp_all_vpnv4_soft,
6100 clear_ip_bgp_all_vpnv4_soft_cmd,
6101 "clear ip bgp * vpnv4 unicast soft",
6102 CLEAR_STR
6103 IP_STR
6104 BGP_STR
6105 "Clear all peers\n"
6106 "Address family\n"
6107 "Address Family Modifier\n"
6108 "Soft reconfig\n")
6109{
6110 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
6111 BGP_CLEAR_SOFT_BOTH, argv[0]);
6112}
6113
6114DEFUN (clear_bgp_all_soft,
6115 clear_bgp_all_soft_cmd,
6116 "clear bgp * soft",
6117 CLEAR_STR
6118 BGP_STR
6119 "Clear all peers\n"
6120 "Soft reconfig\n")
6121{
6122 if (argc == 1)
6123 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
6124 BGP_CLEAR_SOFT_BOTH, argv[0]);
6125
6126 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
6127 BGP_CLEAR_SOFT_BOTH, argv[0]);
6128}
6129
6130ALIAS (clear_bgp_all_soft,
6131 clear_bgp_instance_all_soft_cmd,
6132 "clear bgp view WORD * soft",
6133 CLEAR_STR
6134 BGP_STR
6135 "BGP view\n"
6136 "view name\n"
6137 "Clear all peers\n"
6138 "Soft reconfig\n")
6139
6140ALIAS (clear_bgp_all_soft,
6141 clear_bgp_ipv6_all_soft_cmd,
6142 "clear bgp ipv6 * soft",
6143 CLEAR_STR
6144 BGP_STR
6145 "Address family\n"
6146 "Clear all peers\n"
6147 "Soft reconfig\n")
6148
6149DEFUN (clear_ip_bgp_peer_soft,
6150 clear_ip_bgp_peer_soft_cmd,
6151 "clear ip bgp A.B.C.D soft",
6152 CLEAR_STR
6153 IP_STR
6154 BGP_STR
6155 "BGP neighbor address to clear\n"
6156 "Soft reconfig\n")
6157{
6158 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6159 BGP_CLEAR_SOFT_BOTH, argv[0]);
6160}
6161
6162DEFUN (clear_ip_bgp_peer_ipv4_soft,
6163 clear_ip_bgp_peer_ipv4_soft_cmd,
6164 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft",
6165 CLEAR_STR
6166 IP_STR
6167 BGP_STR
6168 "BGP neighbor address to clear\n"
6169 "Address family\n"
6170 "Address Family Modifier\n"
6171 "Address Family Modifier\n"
6172 "Soft reconfig\n")
6173{
6174 if (strncmp (argv[1], "m", 1) == 0)
6175 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
6176 BGP_CLEAR_SOFT_BOTH, argv[0]);
6177
6178 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6179 BGP_CLEAR_SOFT_BOTH, argv[0]);
6180}
6181
6182DEFUN (clear_ip_bgp_peer_vpnv4_soft,
6183 clear_ip_bgp_peer_vpnv4_soft_cmd,
6184 "clear ip bgp A.B.C.D vpnv4 unicast soft",
6185 CLEAR_STR
6186 IP_STR
6187 BGP_STR
6188 "BGP neighbor address to clear\n"
6189 "Address family\n"
6190 "Address Family Modifier\n"
6191 "Soft reconfig\n")
6192{
6193 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
6194 BGP_CLEAR_SOFT_BOTH, argv[0]);
6195}
6196
6197DEFUN (clear_bgp_peer_soft,
6198 clear_bgp_peer_soft_cmd,
6199 "clear bgp (A.B.C.D|X:X::X:X) soft",
6200 CLEAR_STR
6201 BGP_STR
6202 "BGP neighbor address to clear\n"
6203 "BGP IPv6 neighbor to clear\n"
6204 "Soft reconfig\n")
6205{
6206 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
6207 BGP_CLEAR_SOFT_BOTH, argv[0]);
6208}
6209
6210ALIAS (clear_bgp_peer_soft,
6211 clear_bgp_ipv6_peer_soft_cmd,
6212 "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft",
6213 CLEAR_STR
6214 BGP_STR
6215 "Address family\n"
6216 "BGP neighbor address to clear\n"
6217 "BGP IPv6 neighbor to clear\n"
6218 "Soft reconfig\n")
6219
6220DEFUN (clear_ip_bgp_peer_group_soft,
6221 clear_ip_bgp_peer_group_soft_cmd,
6222 "clear ip bgp peer-group WORD soft",
6223 CLEAR_STR
6224 IP_STR
6225 BGP_STR
6226 "Clear all members of peer-group\n"
6227 "BGP peer-group name\n"
6228 "Soft reconfig\n")
6229{
6230 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6231 BGP_CLEAR_SOFT_BOTH, argv[0]);
6232}
6233
6234DEFUN (clear_ip_bgp_peer_group_ipv4_soft,
6235 clear_ip_bgp_peer_group_ipv4_soft_cmd,
6236 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft",
6237 CLEAR_STR
6238 IP_STR
6239 BGP_STR
6240 "Clear all members of peer-group\n"
6241 "BGP peer-group name\n"
6242 "Address family\n"
6243 "Address Family modifier\n"
6244 "Address Family modifier\n"
6245 "Soft reconfig\n")
6246{
6247 if (strncmp (argv[1], "m", 1) == 0)
6248 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
6249 BGP_CLEAR_SOFT_BOTH, argv[0]);
6250
6251 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6252 BGP_CLEAR_SOFT_BOTH, argv[0]);
6253}
6254
6255DEFUN (clear_bgp_peer_group_soft,
6256 clear_bgp_peer_group_soft_cmd,
6257 "clear bgp peer-group WORD soft",
6258 CLEAR_STR
6259 BGP_STR
6260 "Clear all members of peer-group\n"
6261 "BGP peer-group name\n"
6262 "Soft reconfig\n")
6263{
6264 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
6265 BGP_CLEAR_SOFT_BOTH, argv[0]);
6266}
6267
6268ALIAS (clear_bgp_peer_group_soft,
6269 clear_bgp_ipv6_peer_group_soft_cmd,
6270 "clear bgp ipv6 peer-group WORD soft",
6271 CLEAR_STR
6272 BGP_STR
6273 "Address family\n"
6274 "Clear all members of peer-group\n"
6275 "BGP peer-group name\n"
6276 "Soft reconfig\n")
6277
6278DEFUN (clear_ip_bgp_external_soft,
6279 clear_ip_bgp_external_soft_cmd,
6280 "clear ip bgp external soft",
6281 CLEAR_STR
6282 IP_STR
6283 BGP_STR
6284 "Clear all external peers\n"
6285 "Soft reconfig\n")
6286{
6287 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
6288 BGP_CLEAR_SOFT_BOTH, NULL);
6289}
6290
6291DEFUN (clear_ip_bgp_external_ipv4_soft,
6292 clear_ip_bgp_external_ipv4_soft_cmd,
6293 "clear ip bgp external ipv4 (unicast|multicast) soft",
6294 CLEAR_STR
6295 IP_STR
6296 BGP_STR
6297 "Clear all external peers\n"
6298 "Address family\n"
6299 "Address Family modifier\n"
6300 "Address Family modifier\n"
6301 "Soft reconfig\n")
6302{
6303 if (strncmp (argv[0], "m", 1) == 0)
6304 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
6305 BGP_CLEAR_SOFT_BOTH, NULL);
6306
6307 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
6308 BGP_CLEAR_SOFT_BOTH, NULL);
6309}
6310
6311DEFUN (clear_bgp_external_soft,
6312 clear_bgp_external_soft_cmd,
6313 "clear bgp external soft",
6314 CLEAR_STR
6315 BGP_STR
6316 "Clear all external peers\n"
6317 "Soft reconfig\n")
6318{
6319 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
6320 BGP_CLEAR_SOFT_BOTH, NULL);
6321}
6322
6323ALIAS (clear_bgp_external_soft,
6324 clear_bgp_ipv6_external_soft_cmd,
6325 "clear bgp ipv6 external soft",
6326 CLEAR_STR
6327 BGP_STR
6328 "Address family\n"
6329 "Clear all external peers\n"
6330 "Soft reconfig\n")
6331
6332DEFUN (clear_ip_bgp_as_soft,
6333 clear_ip_bgp_as_soft_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006334 "clear ip bgp " CMD_AS_RANGE " soft",
paul718e3742002-12-13 20:15:29 +00006335 CLEAR_STR
6336 IP_STR
6337 BGP_STR
6338 "Clear peers with the AS number\n"
6339 "Soft reconfig\n")
6340{
6341 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
6342 BGP_CLEAR_SOFT_BOTH, argv[0]);
6343}
6344
6345DEFUN (clear_ip_bgp_as_ipv4_soft,
6346 clear_ip_bgp_as_ipv4_soft_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006347 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft",
paul718e3742002-12-13 20:15:29 +00006348 CLEAR_STR
6349 IP_STR
6350 BGP_STR
6351 "Clear peers with the AS number\n"
6352 "Address family\n"
6353 "Address Family Modifier\n"
6354 "Address Family Modifier\n"
6355 "Soft reconfig\n")
6356{
6357 if (strncmp (argv[1], "m", 1) == 0)
6358 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
6359 BGP_CLEAR_SOFT_BOTH, argv[0]);
6360
6361 return bgp_clear_vty (vty, NULL,AFI_IP, SAFI_UNICAST, clear_as,
6362 BGP_CLEAR_SOFT_BOTH, argv[0]);
6363}
6364
6365DEFUN (clear_ip_bgp_as_vpnv4_soft,
6366 clear_ip_bgp_as_vpnv4_soft_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006367 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft",
paul718e3742002-12-13 20:15:29 +00006368 CLEAR_STR
6369 IP_STR
6370 BGP_STR
6371 "Clear peers with the AS number\n"
6372 "Address family\n"
6373 "Address Family Modifier\n"
6374 "Soft reconfig\n")
6375{
6376 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
6377 BGP_CLEAR_SOFT_BOTH, argv[0]);
6378}
6379
6380DEFUN (clear_bgp_as_soft,
6381 clear_bgp_as_soft_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006382 "clear bgp " CMD_AS_RANGE " soft",
paul718e3742002-12-13 20:15:29 +00006383 CLEAR_STR
6384 BGP_STR
6385 "Clear peers with the AS number\n"
6386 "Soft reconfig\n")
6387{
6388 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
6389 BGP_CLEAR_SOFT_BOTH, argv[0]);
6390}
6391
6392ALIAS (clear_bgp_as_soft,
6393 clear_bgp_ipv6_as_soft_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006394 "clear bgp ipv6 " CMD_AS_RANGE " soft",
paul718e3742002-12-13 20:15:29 +00006395 CLEAR_STR
6396 BGP_STR
6397 "Address family\n"
6398 "Clear peers with the AS number\n"
6399 "Soft reconfig\n")
6400
paulfee0f4c2004-09-13 05:12:46 +00006401/* RS-client soft reconfiguration. */
6402#ifdef HAVE_IPV6
6403DEFUN (clear_bgp_all_rsclient,
6404 clear_bgp_all_rsclient_cmd,
6405 "clear bgp * rsclient",
6406 CLEAR_STR
6407 BGP_STR
6408 "Clear all peers\n"
6409 "Soft reconfig for rsclient RIB\n")
6410{
6411 if (argc == 1)
6412 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
6413 BGP_CLEAR_SOFT_RSCLIENT, NULL);
6414
6415 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
6416 BGP_CLEAR_SOFT_RSCLIENT, NULL);
6417}
6418
6419ALIAS (clear_bgp_all_rsclient,
6420 clear_bgp_ipv6_all_rsclient_cmd,
6421 "clear bgp ipv6 * rsclient",
6422 CLEAR_STR
6423 BGP_STR
6424 "Address family\n"
6425 "Clear all peers\n"
6426 "Soft reconfig for rsclient RIB\n")
6427
6428ALIAS (clear_bgp_all_rsclient,
6429 clear_bgp_instance_all_rsclient_cmd,
6430 "clear bgp view WORD * rsclient",
6431 CLEAR_STR
6432 BGP_STR
6433 "BGP view\n"
6434 "view name\n"
6435 "Clear all peers\n"
6436 "Soft reconfig for rsclient RIB\n")
6437
6438ALIAS (clear_bgp_all_rsclient,
6439 clear_bgp_ipv6_instance_all_rsclient_cmd,
6440 "clear bgp ipv6 view WORD * rsclient",
6441 CLEAR_STR
6442 BGP_STR
6443 "Address family\n"
6444 "BGP view\n"
6445 "view name\n"
6446 "Clear all peers\n"
6447 "Soft reconfig for rsclient RIB\n")
6448#endif /* HAVE_IPV6 */
6449
6450DEFUN (clear_ip_bgp_all_rsclient,
6451 clear_ip_bgp_all_rsclient_cmd,
6452 "clear ip bgp * rsclient",
6453 CLEAR_STR
6454 IP_STR
6455 BGP_STR
6456 "Clear all peers\n"
6457 "Soft reconfig for rsclient RIB\n")
6458{
6459 if (argc == 1)
6460 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
6461 BGP_CLEAR_SOFT_RSCLIENT, NULL);
6462
6463 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6464 BGP_CLEAR_SOFT_RSCLIENT, NULL);
6465}
6466
6467ALIAS (clear_ip_bgp_all_rsclient,
6468 clear_ip_bgp_instance_all_rsclient_cmd,
6469 "clear ip bgp view WORD * rsclient",
6470 CLEAR_STR
6471 IP_STR
6472 BGP_STR
6473 "BGP view\n"
6474 "view name\n"
6475 "Clear all peers\n"
6476 "Soft reconfig for rsclient RIB\n")
6477
6478#ifdef HAVE_IPV6
6479DEFUN (clear_bgp_peer_rsclient,
6480 clear_bgp_peer_rsclient_cmd,
6481 "clear bgp (A.B.C.D|X:X::X:X) rsclient",
6482 CLEAR_STR
6483 BGP_STR
6484 "BGP neighbor IP address to clear\n"
6485 "BGP IPv6 neighbor to clear\n"
6486 "Soft reconfig for rsclient RIB\n")
6487{
6488 if (argc == 2)
6489 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_peer,
6490 BGP_CLEAR_SOFT_RSCLIENT, argv[1]);
6491
6492 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
6493 BGP_CLEAR_SOFT_RSCLIENT, argv[0]);
6494}
6495
6496ALIAS (clear_bgp_peer_rsclient,
6497 clear_bgp_ipv6_peer_rsclient_cmd,
6498 "clear bgp ipv6 (A.B.C.D|X:X::X:X) rsclient",
6499 CLEAR_STR
6500 BGP_STR
6501 "Address family\n"
6502 "BGP neighbor IP address to clear\n"
6503 "BGP IPv6 neighbor to clear\n"
6504 "Soft reconfig for rsclient RIB\n")
6505
6506ALIAS (clear_bgp_peer_rsclient,
6507 clear_bgp_instance_peer_rsclient_cmd,
6508 "clear bgp view WORD (A.B.C.D|X:X::X:X) rsclient",
6509 CLEAR_STR
6510 BGP_STR
6511 "BGP view\n"
6512 "view name\n"
6513 "BGP neighbor IP address to clear\n"
6514 "BGP IPv6 neighbor to clear\n"
6515 "Soft reconfig for rsclient RIB\n")
6516
6517ALIAS (clear_bgp_peer_rsclient,
6518 clear_bgp_ipv6_instance_peer_rsclient_cmd,
6519 "clear bgp ipv6 view WORD (A.B.C.D|X:X::X:X) rsclient",
6520 CLEAR_STR
6521 BGP_STR
6522 "Address family\n"
6523 "BGP view\n"
6524 "view name\n"
6525 "BGP neighbor IP address to clear\n"
6526 "BGP IPv6 neighbor to clear\n"
6527 "Soft reconfig for rsclient RIB\n")
6528#endif /* HAVE_IPV6 */
6529
6530DEFUN (clear_ip_bgp_peer_rsclient,
6531 clear_ip_bgp_peer_rsclient_cmd,
6532 "clear ip bgp (A.B.C.D|X:X::X:X) rsclient",
6533 CLEAR_STR
6534 IP_STR
6535 BGP_STR
6536 "BGP neighbor IP address to clear\n"
6537 "BGP IPv6 neighbor to clear\n"
6538 "Soft reconfig for rsclient RIB\n")
6539{
6540 if (argc == 2)
6541 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_peer,
6542 BGP_CLEAR_SOFT_RSCLIENT, argv[1]);
6543
6544 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6545 BGP_CLEAR_SOFT_RSCLIENT, argv[0]);
6546}
6547
6548ALIAS (clear_ip_bgp_peer_rsclient,
6549 clear_ip_bgp_instance_peer_rsclient_cmd,
6550 "clear ip bgp view WORD (A.B.C.D|X:X::X:X) rsclient",
6551 CLEAR_STR
6552 IP_STR
6553 BGP_STR
6554 "BGP view\n"
6555 "view name\n"
6556 "BGP neighbor IP address to clear\n"
6557 "BGP IPv6 neighbor to clear\n"
6558 "Soft reconfig for rsclient RIB\n")
6559
Michael Lamberte0081f72008-11-16 20:12:04 +00006560DEFUN (show_bgp_views,
6561 show_bgp_views_cmd,
6562 "show bgp views",
6563 SHOW_STR
6564 BGP_STR
6565 "Show the defined BGP views\n")
6566{
6567 struct list *inst = bm->bgp;
6568 struct listnode *node;
6569 struct bgp *bgp;
6570
6571 if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
6572 {
6573 vty_out (vty, "Multiple BGP views are not defined%s", VTY_NEWLINE);
6574 return CMD_WARNING;
6575 }
6576
6577 vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE);
6578 for (ALL_LIST_ELEMENTS_RO(inst, node, bgp))
6579 vty_out (vty, "\t%s (AS%u)%s",
6580 bgp->name ? bgp->name : "(null)",
6581 bgp->as, VTY_NEWLINE);
6582
6583 return CMD_SUCCESS;
6584}
6585
Paul Jakma4bf6a362006-03-30 14:05:23 +00006586DEFUN (show_bgp_memory,
6587 show_bgp_memory_cmd,
6588 "show bgp memory",
6589 SHOW_STR
6590 BGP_STR
6591 "Global BGP memory statistics\n")
6592{
6593 char memstrbuf[MTYPE_MEMSTR_LEN];
6594 unsigned long count;
6595
6596 /* RIB related usage stats */
6597 count = mtype_stats_alloc (MTYPE_BGP_NODE);
6598 vty_out (vty, "%ld RIB nodes, using %s of memory%s", count,
6599 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6600 count * sizeof (struct bgp_node)),
6601 VTY_NEWLINE);
6602
6603 count = mtype_stats_alloc (MTYPE_BGP_ROUTE);
6604 vty_out (vty, "%ld BGP routes, using %s of memory%s", count,
6605 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6606 count * sizeof (struct bgp_info)),
6607 VTY_NEWLINE);
Paul Jakmafb982c22007-05-04 20:15:47 +00006608 if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA)))
6609 vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count,
6610 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6611 count * sizeof (struct bgp_info_extra)),
6612 VTY_NEWLINE);
Paul Jakma4bf6a362006-03-30 14:05:23 +00006613
6614 if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC)))
6615 vty_out (vty, "%ld Static routes, using %s of memory%s", count,
6616 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6617 count * sizeof (struct bgp_static)),
6618 VTY_NEWLINE);
6619
6620 /* Adj-In/Out */
6621 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN)))
6622 vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count,
6623 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6624 count * sizeof (struct bgp_adj_in)),
6625 VTY_NEWLINE);
6626 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT)))
6627 vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count,
6628 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6629 count * sizeof (struct bgp_adj_out)),
6630 VTY_NEWLINE);
6631
6632 if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE)))
6633 vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count,
6634 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6635 count * sizeof (struct bgp_nexthop_cache)),
6636 VTY_NEWLINE);
6637
6638 if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO)))
6639 vty_out (vty, "%ld Dampening entries, using %s of memory%s", count,
6640 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6641 count * sizeof (struct bgp_damp_info)),
6642 VTY_NEWLINE);
6643
6644 /* Attributes */
6645 count = attr_count();
6646 vty_out (vty, "%ld BGP attributes, using %s of memory%s", count,
6647 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6648 count * sizeof(struct attr)),
6649 VTY_NEWLINE);
Paul Jakmafb982c22007-05-04 20:15:47 +00006650 if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA)))
6651 vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count,
6652 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6653 count * sizeof(struct attr_extra)),
6654 VTY_NEWLINE);
Paul Jakma4bf6a362006-03-30 14:05:23 +00006655
6656 if ((count = attr_unknown_count()))
6657 vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE);
6658
6659 /* AS_PATH attributes */
6660 count = aspath_count ();
6661 vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count,
6662 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6663 count * sizeof (struct aspath)),
6664 VTY_NEWLINE);
6665
6666 count = mtype_stats_alloc (MTYPE_AS_SEG);
6667 vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count,
6668 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6669 count * sizeof (struct assegment)),
6670 VTY_NEWLINE);
6671
6672 /* Other attributes */
6673 if ((count = community_count ()))
6674 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
6675 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6676 count * sizeof (struct community)),
6677 VTY_NEWLINE);
6678 if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY)))
6679 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
6680 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6681 count * sizeof (struct ecommunity)),
6682 VTY_NEWLINE);
6683
6684 if ((count = mtype_stats_alloc (MTYPE_CLUSTER)))
6685 vty_out (vty, "%ld Cluster lists, using %s of memory%s", count,
6686 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6687 count * sizeof (struct cluster_list)),
6688 VTY_NEWLINE);
6689
6690 /* Peer related usage */
6691 count = mtype_stats_alloc (MTYPE_BGP_PEER);
6692 vty_out (vty, "%ld peers, using %s of memory%s", count,
6693 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6694 count * sizeof (struct peer)),
6695 VTY_NEWLINE);
6696
6697 if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP)))
6698 vty_out (vty, "%ld peer groups, using %s of memory%s", count,
6699 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6700 count * sizeof (struct peer_group)),
6701 VTY_NEWLINE);
6702
6703 /* Other */
6704 if ((count = mtype_stats_alloc (MTYPE_HASH)))
6705 vty_out (vty, "%ld hash tables, using %s of memory%s", count,
6706 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6707 count * sizeof (struct hash)),
6708 VTY_NEWLINE);
6709 if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET)))
6710 vty_out (vty, "%ld hash buckets, using %s of memory%s", count,
6711 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6712 count * sizeof (struct hash_backet)),
6713 VTY_NEWLINE);
6714 if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP)))
6715 vty_out (vty, "%ld compiled regexes, using %s of memory%s", count,
6716 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6717 count * sizeof (regex_t)),
6718 VTY_NEWLINE);
6719 return CMD_SUCCESS;
6720}
paulfee0f4c2004-09-13 05:12:46 +00006721
paul718e3742002-12-13 20:15:29 +00006722/* Show BGP peer's summary information. */
paul94f2b392005-06-28 12:44:16 +00006723static int
paul718e3742002-12-13 20:15:29 +00006724bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi)
6725{
6726 struct peer *peer;
paul1eb8ef22005-04-07 07:30:20 +00006727 struct listnode *node, *nnode;
Paul Jakma4bf6a362006-03-30 14:05:23 +00006728 unsigned int count = 0;
paul718e3742002-12-13 20:15:29 +00006729 char timebuf[BGP_UPTIME_LEN];
6730 int len;
6731
6732 /* Header string for each address family. */
6733 static char header[] = "Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd";
Paul Jakma4bf6a362006-03-30 14:05:23 +00006734
paul1eb8ef22005-04-07 07:30:20 +00006735 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00006736 {
6737 if (peer->afc[afi][safi])
6738 {
Paul Jakma4bf6a362006-03-30 14:05:23 +00006739 if (!count)
6740 {
6741 unsigned long ents;
6742 char memstrbuf[MTYPE_MEMSTR_LEN];
6743
6744 /* Usage summary and header */
6745 vty_out (vty,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04006746 "BGP router identifier %s, local AS number %u%s",
Paul Jakma4bf6a362006-03-30 14:05:23 +00006747 inet_ntoa (bgp->router_id), bgp->as, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006748
Paul Jakma4bf6a362006-03-30 14:05:23 +00006749 ents = bgp_table_count (bgp->rib[afi][safi]);
6750 vty_out (vty, "RIB entries %ld, using %s of memory%s", ents,
6751 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6752 ents * sizeof (struct bgp_node)),
6753 VTY_NEWLINE);
6754
6755 /* Peer related usage */
6756 ents = listcount (bgp->peer);
6757 vty_out (vty, "Peers %ld, using %s of memory%s",
6758 ents,
6759 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6760 ents * sizeof (struct peer)),
6761 VTY_NEWLINE);
6762
6763 if ((ents = listcount (bgp->rsclient)))
6764 vty_out (vty, "RS-Client peers %ld, using %s of memory%s",
6765 ents,
6766 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6767 ents * sizeof (struct peer)),
6768 VTY_NEWLINE);
6769
6770 if ((ents = listcount (bgp->group)))
6771 vty_out (vty, "Peer groups %ld, using %s of memory%s", ents,
6772 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6773 ents * sizeof (struct peer_group)),
6774 VTY_NEWLINE);
6775
6776 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
6777 vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE);
6778 vty_out (vty, "%s", VTY_NEWLINE);
6779 vty_out (vty, "%s%s", header, VTY_NEWLINE);
6780 }
6781
paul718e3742002-12-13 20:15:29 +00006782 count++;
6783
6784 len = vty_out (vty, "%s", peer->host);
6785 len = 16 - len;
6786 if (len < 1)
6787 vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
6788 else
6789 vty_out (vty, "%*s", len, " ");
6790
hasso3d515fd2005-02-01 21:30:04 +00006791 vty_out (vty, "4 ");
paul718e3742002-12-13 20:15:29 +00006792
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04006793 vty_out (vty, "%5u %7d %7d %8d %4d %4lu ",
paul718e3742002-12-13 20:15:29 +00006794 peer->as,
6795 peer->open_in + peer->update_in + peer->keepalive_in
6796 + peer->notify_in + peer->refresh_in + peer->dynamic_cap_in,
6797 peer->open_out + peer->update_out + peer->keepalive_out
6798 + peer->notify_out + peer->refresh_out
6799 + peer->dynamic_cap_out,
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00006800 0, 0, (unsigned long) peer->obuf->count);
paul718e3742002-12-13 20:15:29 +00006801
6802 vty_out (vty, "%8s",
6803 peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN));
6804
6805 if (peer->status == Established)
6806 {
6807 vty_out (vty, " %8ld", peer->pcount[afi][safi]);
6808 }
6809 else
6810 {
6811 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
6812 vty_out (vty, " Idle (Admin)");
6813 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
6814 vty_out (vty, " Idle (PfxCt)");
6815 else
6816 vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, peer->status));
6817 }
6818
6819 vty_out (vty, "%s", VTY_NEWLINE);
6820 }
6821 }
6822
6823 if (count)
6824 vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE,
6825 count, VTY_NEWLINE);
6826 else
6827 vty_out (vty, "No %s neighbor is configured%s",
6828 afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
6829 return CMD_SUCCESS;
6830}
6831
paul94f2b392005-06-28 12:44:16 +00006832static int
paulfd79ac92004-10-13 05:06:08 +00006833bgp_show_summary_vty (struct vty *vty, const char *name,
6834 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00006835{
6836 struct bgp *bgp;
6837
6838 if (name)
6839 {
6840 bgp = bgp_lookup_by_name (name);
6841
6842 if (! bgp)
6843 {
6844 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
6845 return CMD_WARNING;
6846 }
6847
6848 bgp_show_summary (vty, bgp, afi, safi);
6849 return CMD_SUCCESS;
6850 }
6851
6852 bgp = bgp_get_default ();
6853
6854 if (bgp)
6855 bgp_show_summary (vty, bgp, afi, safi);
6856
6857 return CMD_SUCCESS;
6858}
6859
6860/* `show ip bgp summary' commands. */
6861DEFUN (show_ip_bgp_summary,
6862 show_ip_bgp_summary_cmd,
6863 "show ip bgp summary",
6864 SHOW_STR
6865 IP_STR
6866 BGP_STR
6867 "Summary of BGP neighbor status\n")
6868{
6869 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
6870}
6871
6872DEFUN (show_ip_bgp_instance_summary,
6873 show_ip_bgp_instance_summary_cmd,
6874 "show ip bgp view WORD summary",
6875 SHOW_STR
6876 IP_STR
6877 BGP_STR
6878 "BGP view\n"
6879 "View name\n"
6880 "Summary of BGP neighbor status\n")
6881{
6882 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
6883}
6884
6885DEFUN (show_ip_bgp_ipv4_summary,
6886 show_ip_bgp_ipv4_summary_cmd,
6887 "show ip bgp ipv4 (unicast|multicast) summary",
6888 SHOW_STR
6889 IP_STR
6890 BGP_STR
6891 "Address family\n"
6892 "Address Family modifier\n"
6893 "Address Family modifier\n"
6894 "Summary of BGP neighbor status\n")
6895{
6896 if (strncmp (argv[0], "m", 1) == 0)
6897 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST);
6898
6899 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
6900}
6901
Michael Lambert95cbbd22010-07-23 14:43:04 -04006902ALIAS (show_ip_bgp_ipv4_summary,
6903 show_bgp_ipv4_safi_summary_cmd,
6904 "show bgp ipv4 (unicast|multicast) summary",
6905 SHOW_STR
6906 BGP_STR
6907 "Address family\n"
6908 "Address Family modifier\n"
6909 "Address Family modifier\n"
6910 "Summary of BGP neighbor status\n")
6911
paul718e3742002-12-13 20:15:29 +00006912DEFUN (show_ip_bgp_instance_ipv4_summary,
6913 show_ip_bgp_instance_ipv4_summary_cmd,
6914 "show ip bgp view WORD ipv4 (unicast|multicast) summary",
6915 SHOW_STR
6916 IP_STR
6917 BGP_STR
6918 "BGP view\n"
6919 "View name\n"
6920 "Address family\n"
6921 "Address Family modifier\n"
6922 "Address Family modifier\n"
6923 "Summary of BGP neighbor status\n")
6924{
6925 if (strncmp (argv[1], "m", 1) == 0)
6926 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST);
6927 else
6928 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
6929}
6930
Michael Lambert95cbbd22010-07-23 14:43:04 -04006931ALIAS (show_ip_bgp_instance_ipv4_summary,
6932 show_bgp_instance_ipv4_safi_summary_cmd,
6933 "show bgp view WORD ipv4 (unicast|multicast) summary",
6934 SHOW_STR
6935 BGP_STR
6936 "BGP view\n"
6937 "View name\n"
6938 "Address family\n"
6939 "Address Family modifier\n"
6940 "Address Family modifier\n"
6941 "Summary of BGP neighbor status\n")
6942
paul718e3742002-12-13 20:15:29 +00006943DEFUN (show_ip_bgp_vpnv4_all_summary,
6944 show_ip_bgp_vpnv4_all_summary_cmd,
6945 "show ip bgp vpnv4 all summary",
6946 SHOW_STR
6947 IP_STR
6948 BGP_STR
6949 "Display VPNv4 NLRI specific information\n"
6950 "Display information about all VPNv4 NLRIs\n"
6951 "Summary of BGP neighbor status\n")
6952{
6953 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN);
6954}
6955
6956DEFUN (show_ip_bgp_vpnv4_rd_summary,
6957 show_ip_bgp_vpnv4_rd_summary_cmd,
6958 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn summary",
6959 SHOW_STR
6960 IP_STR
6961 BGP_STR
6962 "Display VPNv4 NLRI specific information\n"
6963 "Display information for a route distinguisher\n"
6964 "VPN Route Distinguisher\n"
6965 "Summary of BGP neighbor status\n")
6966{
6967 int ret;
6968 struct prefix_rd prd;
6969
6970 ret = str2prefix_rd (argv[0], &prd);
6971 if (! ret)
6972 {
6973 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
6974 return CMD_WARNING;
6975 }
6976
6977 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN);
6978}
6979
6980#ifdef HAVE_IPV6
6981DEFUN (show_bgp_summary,
6982 show_bgp_summary_cmd,
6983 "show bgp summary",
6984 SHOW_STR
6985 BGP_STR
6986 "Summary of BGP neighbor status\n")
6987{
6988 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
6989}
6990
6991DEFUN (show_bgp_instance_summary,
6992 show_bgp_instance_summary_cmd,
6993 "show bgp view WORD summary",
6994 SHOW_STR
6995 BGP_STR
6996 "BGP view\n"
6997 "View name\n"
6998 "Summary of BGP neighbor status\n")
6999{
7000 return bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
7001}
7002
7003ALIAS (show_bgp_summary,
7004 show_bgp_ipv6_summary_cmd,
7005 "show bgp ipv6 summary",
7006 SHOW_STR
7007 BGP_STR
7008 "Address family\n"
7009 "Summary of BGP neighbor status\n")
7010
7011ALIAS (show_bgp_instance_summary,
7012 show_bgp_instance_ipv6_summary_cmd,
7013 "show bgp view WORD ipv6 summary",
7014 SHOW_STR
7015 BGP_STR
7016 "BGP view\n"
7017 "View name\n"
7018 "Address family\n"
7019 "Summary of BGP neighbor status\n")
7020
Michael Lambert95cbbd22010-07-23 14:43:04 -04007021DEFUN (show_bgp_ipv6_safi_summary,
7022 show_bgp_ipv6_safi_summary_cmd,
7023 "show bgp ipv6 (unicast|multicast) summary",
7024 SHOW_STR
7025 BGP_STR
7026 "Address family\n"
7027 "Address Family modifier\n"
7028 "Address Family modifier\n"
7029 "Summary of BGP neighbor status\n")
7030{
7031 if (strncmp (argv[0], "m", 1) == 0)
7032 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST);
7033
7034 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
7035}
7036
7037DEFUN (show_bgp_instance_ipv6_safi_summary,
7038 show_bgp_instance_ipv6_safi_summary_cmd,
7039 "show bgp view WORD ipv6 (unicast|multicast) summary",
7040 SHOW_STR
7041 BGP_STR
7042 "BGP view\n"
7043 "View name\n"
7044 "Address family\n"
7045 "Address Family modifier\n"
7046 "Address Family modifier\n"
7047 "Summary of BGP neighbor status\n")
7048{
7049 if (strncmp (argv[1], "m", 1) == 0)
7050 return bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_MULTICAST);
7051
7052 return bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
7053}
7054
paul718e3742002-12-13 20:15:29 +00007055/* old command */
7056DEFUN (show_ipv6_bgp_summary,
7057 show_ipv6_bgp_summary_cmd,
7058 "show ipv6 bgp summary",
7059 SHOW_STR
7060 IPV6_STR
7061 BGP_STR
7062 "Summary of BGP neighbor status\n")
7063{
7064 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
7065}
7066
7067/* old command */
7068DEFUN (show_ipv6_mbgp_summary,
7069 show_ipv6_mbgp_summary_cmd,
7070 "show ipv6 mbgp summary",
7071 SHOW_STR
7072 IPV6_STR
7073 MBGP_STR
7074 "Summary of BGP neighbor status\n")
7075{
7076 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST);
7077}
7078#endif /* HAVE_IPV6 */
7079
paulfd79ac92004-10-13 05:06:08 +00007080const char *
hasso538621f2004-05-21 09:31:30 +00007081afi_safi_print (afi_t afi, safi_t safi)
7082{
7083 if (afi == AFI_IP && safi == SAFI_UNICAST)
7084 return "IPv4 Unicast";
7085 else if (afi == AFI_IP && safi == SAFI_MULTICAST)
7086 return "IPv4 Multicast";
7087 else if (afi == AFI_IP && safi == SAFI_MPLS_VPN)
7088 return "VPNv4 Unicast";
7089 else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
7090 return "IPv6 Unicast";
7091 else if (afi == AFI_IP6 && safi == SAFI_MULTICAST)
7092 return "IPv6 Multicast";
7093 else
7094 return "Unknown";
7095}
7096
paul718e3742002-12-13 20:15:29 +00007097/* Show BGP peer's information. */
7098enum show_type
7099{
7100 show_all,
7101 show_peer
7102};
7103
paul94f2b392005-06-28 12:44:16 +00007104static void
paul718e3742002-12-13 20:15:29 +00007105bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p,
7106 afi_t afi, safi_t safi,
7107 u_int16_t adv_smcap, u_int16_t adv_rmcap,
7108 u_int16_t rcv_smcap, u_int16_t rcv_rmcap)
7109{
7110 /* Send-Mode */
7111 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)
7112 || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
7113 {
7114 vty_out (vty, " Send-mode: ");
7115 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
7116 vty_out (vty, "advertised");
7117 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
7118 vty_out (vty, "%sreceived",
7119 CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ?
7120 ", " : "");
7121 vty_out (vty, "%s", VTY_NEWLINE);
7122 }
7123
7124 /* Receive-Mode */
7125 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)
7126 || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
7127 {
7128 vty_out (vty, " Receive-mode: ");
7129 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
7130 vty_out (vty, "advertised");
7131 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
7132 vty_out (vty, "%sreceived",
7133 CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ?
7134 ", " : "");
7135 vty_out (vty, "%s", VTY_NEWLINE);
7136 }
7137}
7138
paul94f2b392005-06-28 12:44:16 +00007139static void
paul718e3742002-12-13 20:15:29 +00007140bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi)
7141{
7142 struct bgp_filter *filter;
7143 char orf_pfx_name[BUFSIZ];
7144 int orf_pfx_count;
7145
7146 filter = &p->filter[afi][safi];
7147
hasso538621f2004-05-21 09:31:30 +00007148 vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi),
paul718e3742002-12-13 20:15:29 +00007149 VTY_NEWLINE);
hasso538621f2004-05-21 09:31:30 +00007150
paul718e3742002-12-13 20:15:29 +00007151 if (p->af_group[afi][safi])
7152 vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE);
7153
7154 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7155 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
7156 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
7157 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7158 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
7159 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
7160 vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE);
7161
7162 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7163 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
7164 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7165 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
7166 {
7167 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
7168 ORF_TYPE_PREFIX, VTY_NEWLINE);
7169 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
7170 PEER_CAP_ORF_PREFIX_SM_ADV,
7171 PEER_CAP_ORF_PREFIX_RM_ADV,
7172 PEER_CAP_ORF_PREFIX_SM_RCV,
7173 PEER_CAP_ORF_PREFIX_RM_RCV);
7174 }
7175 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7176 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
7177 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7178 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
7179 {
7180 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
7181 ORF_TYPE_PREFIX_OLD, VTY_NEWLINE);
7182 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
7183 PEER_CAP_ORF_PREFIX_SM_ADV,
7184 PEER_CAP_ORF_PREFIX_RM_ADV,
7185 PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
7186 PEER_CAP_ORF_PREFIX_RM_OLD_RCV);
7187 }
7188
7189 sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
7190 orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name);
7191
7192 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
7193 || orf_pfx_count)
7194 {
7195 vty_out (vty, " Outbound Route Filter (ORF):");
7196 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
7197 vty_out (vty, " sent;");
7198 if (orf_pfx_count)
7199 vty_out (vty, " received (%d entries)", orf_pfx_count);
7200 vty_out (vty, "%s", VTY_NEWLINE);
7201 }
7202 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
7203 vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE);
7204
7205 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
7206 vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE);
7207 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
7208 vty_out (vty, " Route-Server Client%s", VTY_NEWLINE);
7209 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
7210 vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE);
7211 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
7212 vty_out (vty, " Private AS number removed from updates to this neighbor%s", VTY_NEWLINE);
7213 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF))
7214 vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE);
7215 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
7216 vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE);
7217 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
7218 vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE);
7219 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
7220 vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE);
7221 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
7222 || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
7223 {
7224 vty_out (vty, " Community attribute sent to this neighbor");
7225 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
7226 && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
hasso538621f2004-05-21 09:31:30 +00007227 vty_out (vty, "(both)%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007228 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
hasso538621f2004-05-21 09:31:30 +00007229 vty_out (vty, "(extended)%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007230 else
hasso538621f2004-05-21 09:31:30 +00007231 vty_out (vty, "(standard)%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007232 }
7233 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
7234 {
7235 vty_out (vty, " Default information originate,");
7236
7237 if (p->default_rmap[afi][safi].name)
7238 vty_out (vty, " default route-map %s%s,",
7239 p->default_rmap[afi][safi].map ? "*" : "",
7240 p->default_rmap[afi][safi].name);
7241 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
7242 vty_out (vty, " default sent%s", VTY_NEWLINE);
7243 else
7244 vty_out (vty, " default not sent%s", VTY_NEWLINE);
7245 }
7246
7247 if (filter->plist[FILTER_IN].name
7248 || filter->dlist[FILTER_IN].name
7249 || filter->aslist[FILTER_IN].name
paulfee0f4c2004-09-13 05:12:46 +00007250 || filter->map[RMAP_IN].name)
paul718e3742002-12-13 20:15:29 +00007251 vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE);
7252 if (filter->plist[FILTER_OUT].name
7253 || filter->dlist[FILTER_OUT].name
7254 || filter->aslist[FILTER_OUT].name
paulfee0f4c2004-09-13 05:12:46 +00007255 || filter->map[RMAP_OUT].name
paul718e3742002-12-13 20:15:29 +00007256 || filter->usmap.name)
7257 vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE);
paulfee0f4c2004-09-13 05:12:46 +00007258 if (filter->map[RMAP_IMPORT].name)
7259 vty_out (vty, " Import policy for this RS-client configured%s", VTY_NEWLINE);
7260 if (filter->map[RMAP_EXPORT].name)
7261 vty_out (vty, " Export policy for this RS-client configured%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007262
7263 /* prefix-list */
7264 if (filter->plist[FILTER_IN].name)
7265 vty_out (vty, " Incoming update prefix filter list is %s%s%s",
7266 filter->plist[FILTER_IN].plist ? "*" : "",
7267 filter->plist[FILTER_IN].name,
7268 VTY_NEWLINE);
7269 if (filter->plist[FILTER_OUT].name)
7270 vty_out (vty, " Outgoing update prefix filter list is %s%s%s",
7271 filter->plist[FILTER_OUT].plist ? "*" : "",
7272 filter->plist[FILTER_OUT].name,
7273 VTY_NEWLINE);
7274
7275 /* distribute-list */
7276 if (filter->dlist[FILTER_IN].name)
7277 vty_out (vty, " Incoming update network filter list is %s%s%s",
7278 filter->dlist[FILTER_IN].alist ? "*" : "",
7279 filter->dlist[FILTER_IN].name,
7280 VTY_NEWLINE);
7281 if (filter->dlist[FILTER_OUT].name)
7282 vty_out (vty, " Outgoing update network filter list is %s%s%s",
7283 filter->dlist[FILTER_OUT].alist ? "*" : "",
7284 filter->dlist[FILTER_OUT].name,
7285 VTY_NEWLINE);
7286
7287 /* filter-list. */
7288 if (filter->aslist[FILTER_IN].name)
7289 vty_out (vty, " Incoming update AS path filter list is %s%s%s",
7290 filter->aslist[FILTER_IN].aslist ? "*" : "",
7291 filter->aslist[FILTER_IN].name,
7292 VTY_NEWLINE);
7293 if (filter->aslist[FILTER_OUT].name)
7294 vty_out (vty, " Outgoing update AS path filter list is %s%s%s",
7295 filter->aslist[FILTER_OUT].aslist ? "*" : "",
7296 filter->aslist[FILTER_OUT].name,
7297 VTY_NEWLINE);
7298
7299 /* route-map. */
paulfee0f4c2004-09-13 05:12:46 +00007300 if (filter->map[RMAP_IN].name)
paul718e3742002-12-13 20:15:29 +00007301 vty_out (vty, " Route map for incoming advertisements is %s%s%s",
paulfee0f4c2004-09-13 05:12:46 +00007302 filter->map[RMAP_IN].map ? "*" : "",
7303 filter->map[RMAP_IN].name,
paul718e3742002-12-13 20:15:29 +00007304 VTY_NEWLINE);
paulfee0f4c2004-09-13 05:12:46 +00007305 if (filter->map[RMAP_OUT].name)
paul718e3742002-12-13 20:15:29 +00007306 vty_out (vty, " Route map for outgoing advertisements is %s%s%s",
paulfee0f4c2004-09-13 05:12:46 +00007307 filter->map[RMAP_OUT].map ? "*" : "",
7308 filter->map[RMAP_OUT].name,
7309 VTY_NEWLINE);
7310 if (filter->map[RMAP_IMPORT].name)
7311 vty_out (vty, " Route map for advertisements going into this RS-client's table is %s%s%s",
7312 filter->map[RMAP_IMPORT].map ? "*" : "",
7313 filter->map[RMAP_IMPORT].name,
7314 VTY_NEWLINE);
7315 if (filter->map[RMAP_EXPORT].name)
7316 vty_out (vty, " Route map for advertisements coming from this RS-client is %s%s%s",
7317 filter->map[RMAP_EXPORT].map ? "*" : "",
7318 filter->map[RMAP_EXPORT].name,
paul718e3742002-12-13 20:15:29 +00007319 VTY_NEWLINE);
7320
7321 /* unsuppress-map */
7322 if (filter->usmap.name)
7323 vty_out (vty, " Route map for selective unsuppress is %s%s%s",
7324 filter->usmap.map ? "*" : "",
7325 filter->usmap.name, VTY_NEWLINE);
7326
7327 /* Receive prefix count */
hassoe0701b72004-05-20 09:19:34 +00007328 vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE);
7329
paul718e3742002-12-13 20:15:29 +00007330 /* Maximum prefix */
7331 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
7332 {
hasso0a486e52005-02-01 20:57:17 +00007333 vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi],
paul718e3742002-12-13 20:15:29 +00007334 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)
hasso0a486e52005-02-01 20:57:17 +00007335 ? " (warning-only)" : "", VTY_NEWLINE);
7336 vty_out (vty, " Threshold for warning message %d%%",
7337 p->pmax_threshold[afi][safi]);
7338 if (p->pmax_restart[afi][safi])
7339 vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]);
7340 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007341 }
paul718e3742002-12-13 20:15:29 +00007342
7343 vty_out (vty, "%s", VTY_NEWLINE);
7344}
7345
paul94f2b392005-06-28 12:44:16 +00007346static void
paul718e3742002-12-13 20:15:29 +00007347bgp_show_peer (struct vty *vty, struct peer *p)
7348{
7349 struct bgp *bgp;
7350 char buf1[BUFSIZ];
7351 char timebuf[BGP_UPTIME_LEN];
hasso538621f2004-05-21 09:31:30 +00007352 afi_t afi;
7353 safi_t safi;
paul718e3742002-12-13 20:15:29 +00007354
7355 bgp = p->bgp;
7356
7357 /* Configured IP address. */
7358 vty_out (vty, "BGP neighbor is %s, ", p->host);
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04007359 vty_out (vty, "remote AS %u, ", p->as);
7360 vty_out (vty, "local AS %u%s, ",
paul718e3742002-12-13 20:15:29 +00007361 p->change_local_as ? p->change_local_as : p->local_as,
7362 CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ?
7363 " no-prepend" : "");
7364 vty_out (vty, "%s link%s",
7365 p->as == p->local_as ? "internal" : "external",
7366 VTY_NEWLINE);
7367
7368 /* Description. */
7369 if (p->desc)
7370 vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE);
7371
7372 /* Peer-group */
7373 if (p->group)
7374 vty_out (vty, " Member of peer-group %s for session parameters%s",
7375 p->group->name, VTY_NEWLINE);
7376
7377 /* Administrative shutdown. */
7378 if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
7379 vty_out (vty, " Administratively shut down%s", VTY_NEWLINE);
7380
7381 /* BGP Version. */
7382 vty_out (vty, " BGP version 4");
paul718e3742002-12-13 20:15:29 +00007383 vty_out (vty, ", remote router ID %s%s",
7384 inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ),
7385 VTY_NEWLINE);
7386
7387 /* Confederation */
hassoe0701b72004-05-20 09:19:34 +00007388 if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION)
7389 && bgp_confederation_peers_check (bgp, p->as))
paul718e3742002-12-13 20:15:29 +00007390 vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE);
7391
7392 /* Status. */
7393 vty_out (vty, " BGP state = %s",
7394 LOOKUP (bgp_status_msg, p->status));
7395 if (p->status == Established)
7396 vty_out (vty, ", up for %8s",
7397 peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN));
hasso93406d82005-02-02 14:40:33 +00007398 else if (p->status == Active)
7399 {
7400 if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE))
7401 vty_out (vty, " (passive)");
7402 else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT))
7403 vty_out (vty, " (NSF passive)");
7404 }
paul718e3742002-12-13 20:15:29 +00007405 vty_out (vty, "%s", VTY_NEWLINE);
7406
7407 /* read timer */
7408 vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN));
7409
7410 /* Configured timer values. */
7411 vty_out (vty, ", hold time is %d, keepalive interval is %d seconds%s",
7412 p->v_holdtime, p->v_keepalive, VTY_NEWLINE);
7413 if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
7414 {
7415 vty_out (vty, " Configured hold time is %d", p->holdtime);
7416 vty_out (vty, ", keepalive interval is %d seconds%s",
7417 p->keepalive, VTY_NEWLINE);
7418 }
hasso93406d82005-02-02 14:40:33 +00007419
paul718e3742002-12-13 20:15:29 +00007420 /* Capability. */
7421 if (p->status == Established)
7422 {
hasso538621f2004-05-21 09:31:30 +00007423 if (p->cap
paul718e3742002-12-13 20:15:29 +00007424 || p->afc_adv[AFI_IP][SAFI_UNICAST]
7425 || p->afc_recv[AFI_IP][SAFI_UNICAST]
7426 || p->afc_adv[AFI_IP][SAFI_MULTICAST]
7427 || p->afc_recv[AFI_IP][SAFI_MULTICAST]
7428#ifdef HAVE_IPV6
7429 || p->afc_adv[AFI_IP6][SAFI_UNICAST]
7430 || p->afc_recv[AFI_IP6][SAFI_UNICAST]
7431 || p->afc_adv[AFI_IP6][SAFI_MULTICAST]
7432 || p->afc_recv[AFI_IP6][SAFI_MULTICAST]
7433#endif /* HAVE_IPV6 */
7434 || p->afc_adv[AFI_IP][SAFI_MPLS_VPN]
7435 || p->afc_recv[AFI_IP][SAFI_MPLS_VPN])
7436 {
7437 vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE);
7438
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00007439 /* AS4 */
7440 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)
7441 || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
7442 {
7443 vty_out (vty, " 4 Byte AS:");
7444 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
7445 vty_out (vty, " advertised");
7446 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
7447 vty_out (vty, " %sreceived",
7448 CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : "");
7449 vty_out (vty, "%s", VTY_NEWLINE);
7450 }
paul718e3742002-12-13 20:15:29 +00007451 /* Dynamic */
7452 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
7453 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
7454 {
7455 vty_out (vty, " Dynamic:");
7456 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
7457 vty_out (vty, " advertised");
7458 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
hasso538621f2004-05-21 09:31:30 +00007459 vty_out (vty, " %sreceived",
7460 CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : "");
paul718e3742002-12-13 20:15:29 +00007461 vty_out (vty, "%s", VTY_NEWLINE);
7462 }
7463
7464 /* Route Refresh */
7465 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
7466 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
7467 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
7468 {
7469 vty_out (vty, " Route refresh:");
7470 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
7471 vty_out (vty, " advertised");
7472 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
7473 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
hasso538621f2004-05-21 09:31:30 +00007474 vty_out (vty, " %sreceived(%s)",
7475 CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "",
7476 (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)
7477 && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ?
7478 "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new");
7479
paul718e3742002-12-13 20:15:29 +00007480 vty_out (vty, "%s", VTY_NEWLINE);
7481 }
7482
hasso538621f2004-05-21 09:31:30 +00007483 /* Multiprotocol Extensions */
7484 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7485 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7486 if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
paul718e3742002-12-13 20:15:29 +00007487 {
hasso538621f2004-05-21 09:31:30 +00007488 vty_out (vty, " Address family %s:", afi_safi_print (afi, safi));
7489 if (p->afc_adv[afi][safi])
7490 vty_out (vty, " advertised");
7491 if (p->afc_recv[afi][safi])
7492 vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : "");
7493 vty_out (vty, "%s", VTY_NEWLINE);
7494 }
7495
7496 /* Gracefull Restart */
7497 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
7498 || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
paul718e3742002-12-13 20:15:29 +00007499 {
hasso538621f2004-05-21 09:31:30 +00007500 vty_out (vty, " Graceful Restart Capabilty:");
7501 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
paul718e3742002-12-13 20:15:29 +00007502 vty_out (vty, " advertised");
hasso538621f2004-05-21 09:31:30 +00007503 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
7504 vty_out (vty, " %sreceived",
7505 CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : "");
paul718e3742002-12-13 20:15:29 +00007506 vty_out (vty, "%s", VTY_NEWLINE);
hasso538621f2004-05-21 09:31:30 +00007507
7508 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
paul718e3742002-12-13 20:15:29 +00007509 {
hasso538621f2004-05-21 09:31:30 +00007510 int restart_af_count = 0;
7511
7512 vty_out (vty, " Remote Restart timer is %d seconds%s",
hasso93406d82005-02-02 14:40:33 +00007513 p->v_gr_restart, VTY_NEWLINE);
7514 vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE);
hasso538621f2004-05-21 09:31:30 +00007515
7516 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7517 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7518 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
7519 {
hasso93406d82005-02-02 14:40:33 +00007520 vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "",
7521 afi_safi_print (afi, safi),
7522 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ?
7523 "preserved" : "not preserved");
hasso538621f2004-05-21 09:31:30 +00007524 restart_af_count++;
hasso93406d82005-02-02 14:40:33 +00007525 }
hasso538621f2004-05-21 09:31:30 +00007526 if (! restart_af_count)
7527 vty_out (vty, "none");
7528 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007529 }
paul718e3742002-12-13 20:15:29 +00007530 }
paul718e3742002-12-13 20:15:29 +00007531 }
7532 }
7533
hasso93406d82005-02-02 14:40:33 +00007534 /* graceful restart information */
7535 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
7536 || p->t_gr_restart
7537 || p->t_gr_stale)
7538 {
7539 int eor_send_af_count = 0;
7540 int eor_receive_af_count = 0;
7541
7542 vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE);
7543 if (p->status == Established)
7544 {
7545 vty_out (vty, " End-of-RIB send: ");
7546 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7547 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7548 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND))
7549 {
7550 vty_out (vty, "%s%s", eor_send_af_count ? ", " : "",
7551 afi_safi_print (afi, safi));
7552 eor_send_af_count++;
7553 }
7554 vty_out (vty, "%s", VTY_NEWLINE);
7555
7556 vty_out (vty, " End-of-RIB received: ");
7557 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7558 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7559 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED))
7560 {
7561 vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "",
7562 afi_safi_print (afi, safi));
7563 eor_receive_af_count++;
7564 }
7565 vty_out (vty, "%s", VTY_NEWLINE);
7566 }
7567
7568 if (p->t_gr_restart)
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00007569 vty_out (vty, " The remaining time of restart timer is %ld%s",
7570 thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE);
7571
hasso93406d82005-02-02 14:40:33 +00007572 if (p->t_gr_stale)
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00007573 vty_out (vty, " The remaining time of stalepath timer is %ld%s",
7574 thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE);
hasso93406d82005-02-02 14:40:33 +00007575 }
7576
paul718e3742002-12-13 20:15:29 +00007577 /* Packet counts. */
hasso93406d82005-02-02 14:40:33 +00007578 vty_out (vty, " Message statistics:%s", VTY_NEWLINE);
7579 vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00007580 vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE);
hasso93406d82005-02-02 14:40:33 +00007581 vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE);
7582 vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE);
7583 vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE);
7584 vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE);
7585 vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE);
7586 vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE);
7587 vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE);
7588 vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out +
7589 p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out,
7590 p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in +
7591 p->dynamic_cap_in, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007592
7593 /* advertisement-interval */
7594 vty_out (vty, " Minimum time between advertisement runs is %d seconds%s",
7595 p->v_routeadv, VTY_NEWLINE);
7596
7597 /* Update-source. */
7598 if (p->update_if || p->update_source)
7599 {
7600 vty_out (vty, " Update source is ");
7601 if (p->update_if)
7602 vty_out (vty, "%s", p->update_if);
7603 else if (p->update_source)
7604 vty_out (vty, "%s",
7605 sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
7606 vty_out (vty, "%s", VTY_NEWLINE);
7607 }
7608
7609 /* Default weight */
7610 if (CHECK_FLAG (p->config, PEER_CONFIG_WEIGHT))
7611 vty_out (vty, " Default weight %d%s", p->weight,
7612 VTY_NEWLINE);
7613
7614 vty_out (vty, "%s", VTY_NEWLINE);
7615
7616 /* Address Family Information */
hasso538621f2004-05-21 09:31:30 +00007617 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7618 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7619 if (p->afc[afi][safi])
7620 bgp_show_peer_afi (vty, p, afi, safi);
paul718e3742002-12-13 20:15:29 +00007621
7622 vty_out (vty, " Connections established %d; dropped %d%s",
7623 p->established, p->dropped,
7624 VTY_NEWLINE);
7625
hassoe0701b72004-05-20 09:19:34 +00007626 if (! p->dropped)
7627 vty_out (vty, " Last reset never%s", VTY_NEWLINE);
7628 else
7629 vty_out (vty, " Last reset %s, due to %s%s",
7630 peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN),
7631 peer_down_str[(int) p->last_reset], VTY_NEWLINE);
paul848973c2003-08-13 00:32:49 +00007632
paul718e3742002-12-13 20:15:29 +00007633 if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW))
7634 {
7635 vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE);
hasso0a486e52005-02-01 20:57:17 +00007636
7637 if (p->t_pmax_restart)
7638 vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s",
7639 p->host, thread_timer_remain_second (p->t_pmax_restart),
7640 VTY_NEWLINE);
7641 else
7642 vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s",
7643 p->host, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007644 }
7645
7646 /* EBGP Multihop */
7647 if (peer_sort (p) != BGP_PEER_IBGP && p->ttl > 1)
7648 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
7649 p->ttl, VTY_NEWLINE);
7650
7651 /* Local address. */
7652 if (p->su_local)
7653 {
hasso93406d82005-02-02 14:40:33 +00007654 vty_out (vty, "Local host: %s, Local port: %d%s",
paul718e3742002-12-13 20:15:29 +00007655 sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN),
7656 ntohs (p->su_local->sin.sin_port),
paul718e3742002-12-13 20:15:29 +00007657 VTY_NEWLINE);
7658 }
7659
7660 /* Remote address. */
7661 if (p->su_remote)
7662 {
7663 vty_out (vty, "Foreign host: %s, Foreign port: %d%s",
7664 sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN),
7665 ntohs (p->su_remote->sin.sin_port),
7666 VTY_NEWLINE);
7667 }
7668
7669 /* Nexthop display. */
7670 if (p->su_local)
7671 {
7672 vty_out (vty, "Nexthop: %s%s",
7673 inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ),
7674 VTY_NEWLINE);
7675#ifdef HAVE_IPV6
7676 vty_out (vty, "Nexthop global: %s%s",
7677 inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ),
7678 VTY_NEWLINE);
7679 vty_out (vty, "Nexthop local: %s%s",
7680 inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ),
7681 VTY_NEWLINE);
7682 vty_out (vty, "BGP connection: %s%s",
7683 p->shared_network ? "shared network" : "non shared network",
7684 VTY_NEWLINE);
7685#endif /* HAVE_IPV6 */
7686 }
7687
7688 /* Timer information. */
7689 if (p->t_start)
7690 vty_out (vty, "Next start timer due in %ld seconds%s",
7691 thread_timer_remain_second (p->t_start), VTY_NEWLINE);
7692 if (p->t_connect)
7693 vty_out (vty, "Next connect timer due in %ld seconds%s",
7694 thread_timer_remain_second (p->t_connect), VTY_NEWLINE);
7695
7696 vty_out (vty, "Read thread: %s Write thread: %s%s",
7697 p->t_read ? "on" : "off",
7698 p->t_write ? "on" : "off",
7699 VTY_NEWLINE);
7700
7701 if (p->notify.code == BGP_NOTIFY_OPEN_ERR
7702 && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL)
7703 bgp_capability_vty_out (vty, p);
7704
7705 vty_out (vty, "%s", VTY_NEWLINE);
7706}
7707
paul94f2b392005-06-28 12:44:16 +00007708static int
paul718e3742002-12-13 20:15:29 +00007709bgp_show_neighbor (struct vty *vty, struct bgp *bgp,
7710 enum show_type type, union sockunion *su)
7711{
paul1eb8ef22005-04-07 07:30:20 +00007712 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00007713 struct peer *peer;
7714 int find = 0;
7715
paul1eb8ef22005-04-07 07:30:20 +00007716 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00007717 {
7718 switch (type)
7719 {
7720 case show_all:
7721 bgp_show_peer (vty, peer);
7722 break;
7723 case show_peer:
7724 if (sockunion_same (&peer->su, su))
7725 {
7726 find = 1;
7727 bgp_show_peer (vty, peer);
7728 }
7729 break;
7730 }
7731 }
7732
7733 if (type == show_peer && ! find)
7734 vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE);
7735
7736 return CMD_SUCCESS;
7737}
7738
paul94f2b392005-06-28 12:44:16 +00007739static int
paulfd79ac92004-10-13 05:06:08 +00007740bgp_show_neighbor_vty (struct vty *vty, const char *name,
7741 enum show_type type, const char *ip_str)
paul718e3742002-12-13 20:15:29 +00007742{
7743 int ret;
7744 struct bgp *bgp;
7745 union sockunion su;
7746
7747 if (ip_str)
7748 {
7749 ret = str2sockunion (ip_str, &su);
7750 if (ret < 0)
7751 {
7752 vty_out (vty, "%% Malformed address: %s%s", ip_str, VTY_NEWLINE);
7753 return CMD_WARNING;
7754 }
7755 }
7756
7757 if (name)
7758 {
7759 bgp = bgp_lookup_by_name (name);
7760
7761 if (! bgp)
7762 {
7763 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
7764 return CMD_WARNING;
7765 }
7766
7767 bgp_show_neighbor (vty, bgp, type, &su);
7768
7769 return CMD_SUCCESS;
7770 }
7771
7772 bgp = bgp_get_default ();
7773
7774 if (bgp)
7775 bgp_show_neighbor (vty, bgp, type, &su);
7776
7777 return CMD_SUCCESS;
7778}
7779
7780/* "show ip bgp neighbors" commands. */
7781DEFUN (show_ip_bgp_neighbors,
7782 show_ip_bgp_neighbors_cmd,
7783 "show ip bgp neighbors",
7784 SHOW_STR
7785 IP_STR
7786 BGP_STR
7787 "Detailed information on TCP and BGP neighbor connections\n")
7788{
7789 return bgp_show_neighbor_vty (vty, NULL, show_all, NULL);
7790}
7791
7792ALIAS (show_ip_bgp_neighbors,
7793 show_ip_bgp_ipv4_neighbors_cmd,
7794 "show ip bgp ipv4 (unicast|multicast) neighbors",
7795 SHOW_STR
7796 IP_STR
7797 BGP_STR
7798 "Address family\n"
7799 "Address Family modifier\n"
7800 "Address Family modifier\n"
7801 "Detailed information on TCP and BGP neighbor connections\n")
7802
7803ALIAS (show_ip_bgp_neighbors,
7804 show_ip_bgp_vpnv4_all_neighbors_cmd,
7805 "show ip bgp vpnv4 all neighbors",
7806 SHOW_STR
7807 IP_STR
7808 BGP_STR
7809 "Display VPNv4 NLRI specific information\n"
7810 "Display information about all VPNv4 NLRIs\n"
7811 "Detailed information on TCP and BGP neighbor connections\n")
7812
7813ALIAS (show_ip_bgp_neighbors,
7814 show_ip_bgp_vpnv4_rd_neighbors_cmd,
7815 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors",
7816 SHOW_STR
7817 IP_STR
7818 BGP_STR
7819 "Display VPNv4 NLRI specific information\n"
7820 "Display information for a route distinguisher\n"
7821 "VPN Route Distinguisher\n"
7822 "Detailed information on TCP and BGP neighbor connections\n")
7823
7824ALIAS (show_ip_bgp_neighbors,
7825 show_bgp_neighbors_cmd,
7826 "show bgp neighbors",
7827 SHOW_STR
7828 BGP_STR
7829 "Detailed information on TCP and BGP neighbor connections\n")
7830
7831ALIAS (show_ip_bgp_neighbors,
7832 show_bgp_ipv6_neighbors_cmd,
7833 "show bgp ipv6 neighbors",
7834 SHOW_STR
7835 BGP_STR
7836 "Address family\n"
7837 "Detailed information on TCP and BGP neighbor connections\n")
7838
7839DEFUN (show_ip_bgp_neighbors_peer,
7840 show_ip_bgp_neighbors_peer_cmd,
7841 "show ip bgp neighbors (A.B.C.D|X:X::X:X)",
7842 SHOW_STR
7843 IP_STR
7844 BGP_STR
7845 "Detailed information on TCP and BGP neighbor connections\n"
7846 "Neighbor to display information about\n"
7847 "Neighbor to display information about\n")
7848{
7849 return bgp_show_neighbor_vty (vty, NULL, show_peer, argv[argc - 1]);
7850}
7851
7852ALIAS (show_ip_bgp_neighbors_peer,
7853 show_ip_bgp_ipv4_neighbors_peer_cmd,
7854 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X)",
7855 SHOW_STR
7856 IP_STR
7857 BGP_STR
7858 "Address family\n"
7859 "Address Family modifier\n"
7860 "Address Family modifier\n"
7861 "Detailed information on TCP and BGP neighbor connections\n"
7862 "Neighbor to display information about\n"
7863 "Neighbor to display information about\n")
7864
7865ALIAS (show_ip_bgp_neighbors_peer,
7866 show_ip_bgp_vpnv4_all_neighbors_peer_cmd,
7867 "show ip bgp vpnv4 all neighbors A.B.C.D",
7868 SHOW_STR
7869 IP_STR
7870 BGP_STR
7871 "Display VPNv4 NLRI specific information\n"
7872 "Display information about all VPNv4 NLRIs\n"
7873 "Detailed information on TCP and BGP neighbor connections\n"
7874 "Neighbor to display information about\n")
7875
7876ALIAS (show_ip_bgp_neighbors_peer,
7877 show_ip_bgp_vpnv4_rd_neighbors_peer_cmd,
7878 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D",
7879 SHOW_STR
7880 IP_STR
7881 BGP_STR
7882 "Display VPNv4 NLRI specific information\n"
7883 "Display information about all VPNv4 NLRIs\n"
7884 "Detailed information on TCP and BGP neighbor connections\n"
7885 "Neighbor to display information about\n")
7886
7887ALIAS (show_ip_bgp_neighbors_peer,
7888 show_bgp_neighbors_peer_cmd,
7889 "show bgp neighbors (A.B.C.D|X:X::X:X)",
7890 SHOW_STR
7891 BGP_STR
7892 "Detailed information on TCP and BGP neighbor connections\n"
7893 "Neighbor to display information about\n"
7894 "Neighbor to display information about\n")
7895
7896ALIAS (show_ip_bgp_neighbors_peer,
7897 show_bgp_ipv6_neighbors_peer_cmd,
7898 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X)",
7899 SHOW_STR
7900 BGP_STR
7901 "Address family\n"
7902 "Detailed information on TCP and BGP neighbor connections\n"
7903 "Neighbor to display information about\n"
7904 "Neighbor to display information about\n")
7905
7906DEFUN (show_ip_bgp_instance_neighbors,
7907 show_ip_bgp_instance_neighbors_cmd,
7908 "show ip bgp view WORD neighbors",
7909 SHOW_STR
7910 IP_STR
7911 BGP_STR
7912 "BGP view\n"
7913 "View name\n"
7914 "Detailed information on TCP and BGP neighbor connections\n")
7915{
7916 return bgp_show_neighbor_vty (vty, argv[0], show_all, NULL);
7917}
7918
paulbb46e942003-10-24 19:02:03 +00007919ALIAS (show_ip_bgp_instance_neighbors,
7920 show_bgp_instance_neighbors_cmd,
7921 "show bgp view WORD neighbors",
7922 SHOW_STR
7923 BGP_STR
7924 "BGP view\n"
7925 "View name\n"
7926 "Detailed information on TCP and BGP neighbor connections\n")
7927
7928ALIAS (show_ip_bgp_instance_neighbors,
7929 show_bgp_instance_ipv6_neighbors_cmd,
7930 "show bgp view WORD ipv6 neighbors",
7931 SHOW_STR
7932 BGP_STR
7933 "BGP view\n"
7934 "View name\n"
7935 "Address family\n"
7936 "Detailed information on TCP and BGP neighbor connections\n")
7937
paul718e3742002-12-13 20:15:29 +00007938DEFUN (show_ip_bgp_instance_neighbors_peer,
7939 show_ip_bgp_instance_neighbors_peer_cmd,
7940 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X)",
7941 SHOW_STR
7942 IP_STR
7943 BGP_STR
7944 "BGP view\n"
7945 "View name\n"
7946 "Detailed information on TCP and BGP neighbor connections\n"
7947 "Neighbor to display information about\n"
7948 "Neighbor to display information about\n")
7949{
7950 return bgp_show_neighbor_vty (vty, argv[0], show_peer, argv[1]);
7951}
paulbb46e942003-10-24 19:02:03 +00007952
7953ALIAS (show_ip_bgp_instance_neighbors_peer,
7954 show_bgp_instance_neighbors_peer_cmd,
7955 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X)",
7956 SHOW_STR
7957 BGP_STR
7958 "BGP view\n"
7959 "View name\n"
7960 "Detailed information on TCP and BGP neighbor connections\n"
7961 "Neighbor to display information about\n"
7962 "Neighbor to display information about\n")
7963
7964ALIAS (show_ip_bgp_instance_neighbors_peer,
7965 show_bgp_instance_ipv6_neighbors_peer_cmd,
7966 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X)",
7967 SHOW_STR
7968 BGP_STR
7969 "BGP view\n"
7970 "View name\n"
7971 "Address family\n"
7972 "Detailed information on TCP and BGP neighbor connections\n"
7973 "Neighbor to display information about\n"
7974 "Neighbor to display information about\n")
7975
paul718e3742002-12-13 20:15:29 +00007976/* Show BGP's AS paths internal data. There are both `show ip bgp
7977 paths' and `show ip mbgp paths'. Those functions results are the
7978 same.*/
7979DEFUN (show_ip_bgp_paths,
7980 show_ip_bgp_paths_cmd,
7981 "show ip bgp paths",
7982 SHOW_STR
7983 IP_STR
7984 BGP_STR
7985 "Path information\n")
7986{
7987 vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE);
7988 aspath_print_all_vty (vty);
7989 return CMD_SUCCESS;
7990}
7991
7992DEFUN (show_ip_bgp_ipv4_paths,
7993 show_ip_bgp_ipv4_paths_cmd,
7994 "show ip bgp ipv4 (unicast|multicast) paths",
7995 SHOW_STR
7996 IP_STR
7997 BGP_STR
7998 "Address family\n"
7999 "Address Family modifier\n"
8000 "Address Family modifier\n"
8001 "Path information\n")
8002{
8003 vty_out (vty, "Address Refcnt Path\r\n");
8004 aspath_print_all_vty (vty);
8005
8006 return CMD_SUCCESS;
8007}
8008
8009#include "hash.h"
8010
paul94f2b392005-06-28 12:44:16 +00008011static void
paul718e3742002-12-13 20:15:29 +00008012community_show_all_iterator (struct hash_backet *backet, struct vty *vty)
8013{
8014 struct community *com;
8015
8016 com = (struct community *) backet->data;
8017 vty_out (vty, "[%p] (%ld) %s%s", backet, com->refcnt,
8018 community_str (com), VTY_NEWLINE);
8019}
8020
8021/* Show BGP's community internal data. */
8022DEFUN (show_ip_bgp_community_info,
8023 show_ip_bgp_community_info_cmd,
8024 "show ip bgp community-info",
8025 SHOW_STR
8026 IP_STR
8027 BGP_STR
8028 "List all bgp community information\n")
8029{
8030 vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE);
8031
8032 hash_iterate (community_hash (),
8033 (void (*) (struct hash_backet *, void *))
8034 community_show_all_iterator,
8035 vty);
8036
8037 return CMD_SUCCESS;
8038}
8039
8040DEFUN (show_ip_bgp_attr_info,
8041 show_ip_bgp_attr_info_cmd,
8042 "show ip bgp attribute-info",
8043 SHOW_STR
8044 IP_STR
8045 BGP_STR
8046 "List all bgp attribute information\n")
8047{
8048 attr_show_all (vty);
8049 return CMD_SUCCESS;
8050}
8051
paul94f2b392005-06-28 12:44:16 +00008052static int
paulfee0f4c2004-09-13 05:12:46 +00008053bgp_write_rsclient_summary (struct vty *vty, struct peer *rsclient,
8054 afi_t afi, safi_t safi)
8055{
8056 char timebuf[BGP_UPTIME_LEN];
8057 char rmbuf[14];
paulfd79ac92004-10-13 05:06:08 +00008058 const char *rmname;
paulfee0f4c2004-09-13 05:12:46 +00008059 struct peer *peer;
paul1eb8ef22005-04-07 07:30:20 +00008060 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00008061 int len;
8062 int count = 0;
8063
8064 if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP))
8065 {
paul1eb8ef22005-04-07 07:30:20 +00008066 for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, peer))
paulfee0f4c2004-09-13 05:12:46 +00008067 {
8068 count++;
8069 bgp_write_rsclient_summary (vty, peer, afi, safi);
8070 }
8071 return count;
8072 }
8073
8074 len = vty_out (vty, "%s", rsclient->host);
8075 len = 16 - len;
8076
8077 if (len < 1)
8078 vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
8079 else
8080 vty_out (vty, "%*s", len, " ");
8081
hasso3d515fd2005-02-01 21:30:04 +00008082 vty_out (vty, "4 ");
paulfee0f4c2004-09-13 05:12:46 +00008083
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00008084 vty_out (vty, "%11d ", rsclient->as);
paulfee0f4c2004-09-13 05:12:46 +00008085
8086 rmname = ROUTE_MAP_EXPORT_NAME(&rsclient->filter[afi][safi]);
8087 if ( rmname && strlen (rmname) > 13 )
8088 {
8089 sprintf (rmbuf, "%13s", "...");
8090 rmname = strncpy (rmbuf, rmname, 10);
8091 }
8092 else if (! rmname)
8093 rmname = "<none>";
8094 vty_out (vty, " %13s ", rmname);
8095
8096 rmname = ROUTE_MAP_IMPORT_NAME(&rsclient->filter[afi][safi]);
8097 if ( rmname && strlen (rmname) > 13 )
8098 {
8099 sprintf (rmbuf, "%13s", "...");
8100 rmname = strncpy (rmbuf, rmname, 10);
8101 }
8102 else if (! rmname)
8103 rmname = "<none>";
8104 vty_out (vty, " %13s ", rmname);
8105
8106 vty_out (vty, "%8s", peer_uptime (rsclient->uptime, timebuf, BGP_UPTIME_LEN));
8107
8108 if (CHECK_FLAG (rsclient->flags, PEER_FLAG_SHUTDOWN))
8109 vty_out (vty, " Idle (Admin)");
8110 else if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_PREFIX_OVERFLOW))
8111 vty_out (vty, " Idle (PfxCt)");
8112 else
8113 vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, rsclient->status));
8114
8115 vty_out (vty, "%s", VTY_NEWLINE);
8116
8117 return 1;
8118}
8119
paul94f2b392005-06-28 12:44:16 +00008120static int
paulfd79ac92004-10-13 05:06:08 +00008121bgp_show_rsclient_summary (struct vty *vty, struct bgp *bgp,
8122 afi_t afi, safi_t safi)
paulfee0f4c2004-09-13 05:12:46 +00008123{
8124 struct peer *peer;
paul1eb8ef22005-04-07 07:30:20 +00008125 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00008126 int count = 0;
8127
8128 /* Header string for each address family. */
8129 static char header[] = "Neighbor V AS Export-Policy Import-Policy Up/Down State";
8130
paul1eb8ef22005-04-07 07:30:20 +00008131 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, peer))
paulfee0f4c2004-09-13 05:12:46 +00008132 {
8133 if (peer->afc[afi][safi] &&
8134 CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
8135 {
8136 if (! count)
8137 {
8138 vty_out (vty,
8139 "Route Server's BGP router identifier %s%s",
8140 inet_ntoa (bgp->router_id), VTY_NEWLINE);
8141 vty_out (vty,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04008142 "Route Server's local AS number %u%s", bgp->as,
paulfee0f4c2004-09-13 05:12:46 +00008143 VTY_NEWLINE);
8144
8145 vty_out (vty, "%s", VTY_NEWLINE);
8146 vty_out (vty, "%s%s", header, VTY_NEWLINE);
8147 }
8148
8149 count += bgp_write_rsclient_summary (vty, peer, afi, safi);
8150 }
8151 }
8152
8153 if (count)
8154 vty_out (vty, "%sTotal number of Route Server Clients %d%s", VTY_NEWLINE,
8155 count, VTY_NEWLINE);
8156 else
8157 vty_out (vty, "No %s Route Server Client is configured%s",
8158 afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
8159
8160 return CMD_SUCCESS;
8161}
8162
paul94f2b392005-06-28 12:44:16 +00008163static int
paulfd79ac92004-10-13 05:06:08 +00008164bgp_show_rsclient_summary_vty (struct vty *vty, const char *name,
8165 afi_t afi, safi_t safi)
paulfee0f4c2004-09-13 05:12:46 +00008166{
8167 struct bgp *bgp;
8168
8169 if (name)
8170 {
8171 bgp = bgp_lookup_by_name (name);
8172
8173 if (! bgp)
8174 {
8175 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
8176 return CMD_WARNING;
8177 }
8178
8179 bgp_show_rsclient_summary (vty, bgp, afi, safi);
8180 return CMD_SUCCESS;
8181 }
8182
8183 bgp = bgp_get_default ();
8184
8185 if (bgp)
8186 bgp_show_rsclient_summary (vty, bgp, afi, safi);
8187
8188 return CMD_SUCCESS;
8189}
8190
8191/* 'show bgp rsclient' commands. */
8192DEFUN (show_ip_bgp_rsclient_summary,
8193 show_ip_bgp_rsclient_summary_cmd,
8194 "show ip bgp rsclient summary",
8195 SHOW_STR
8196 IP_STR
8197 BGP_STR
8198 "Information about Route Server Clients\n"
8199 "Summary of all Route Server Clients\n")
8200{
8201 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
8202}
8203
8204DEFUN (show_ip_bgp_instance_rsclient_summary,
8205 show_ip_bgp_instance_rsclient_summary_cmd,
8206 "show ip bgp view WORD rsclient summary",
8207 SHOW_STR
8208 IP_STR
8209 BGP_STR
8210 "BGP view\n"
8211 "View name\n"
8212 "Information about Route Server Clients\n"
8213 "Summary of all Route Server Clients\n")
8214{
8215 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
8216}
8217
8218DEFUN (show_ip_bgp_ipv4_rsclient_summary,
8219 show_ip_bgp_ipv4_rsclient_summary_cmd,
8220 "show ip bgp ipv4 (unicast|multicast) rsclient summary",
8221 SHOW_STR
8222 IP_STR
8223 BGP_STR
8224 "Address family\n"
8225 "Address Family modifier\n"
8226 "Address Family modifier\n"
8227 "Information about Route Server Clients\n"
8228 "Summary of all Route Server Clients\n")
8229{
8230 if (strncmp (argv[0], "m", 1) == 0)
8231 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST);
8232
8233 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
8234}
8235
8236DEFUN (show_ip_bgp_instance_ipv4_rsclient_summary,
8237 show_ip_bgp_instance_ipv4_rsclient_summary_cmd,
8238 "show ip bgp view WORD ipv4 (unicast|multicast) rsclient summary",
8239 SHOW_STR
8240 IP_STR
8241 BGP_STR
8242 "BGP view\n"
8243 "View name\n"
8244 "Address family\n"
8245 "Address Family modifier\n"
8246 "Address Family modifier\n"
8247 "Information about Route Server Clients\n"
8248 "Summary of all Route Server Clients\n")
8249{
8250 if (strncmp (argv[1], "m", 1) == 0)
8251 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST);
8252
8253 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
8254}
8255
Michael Lambert95cbbd22010-07-23 14:43:04 -04008256DEFUN (show_bgp_instance_ipv4_safi_rsclient_summary,
8257 show_bgp_instance_ipv4_safi_rsclient_summary_cmd,
8258 "show bgp view WORD ipv4 (unicast|multicast) rsclient summary",
8259 SHOW_STR
8260 BGP_STR
8261 "BGP view\n"
8262 "View name\n"
8263 "Address family\n"
8264 "Address Family modifier\n"
8265 "Address Family modifier\n"
8266 "Information about Route Server Clients\n"
8267 "Summary of all Route Server Clients\n")
8268{
8269 safi_t safi;
8270
8271 if (argc == 2) {
8272 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
8273 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, safi);
8274 } else {
8275 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
8276 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, safi);
8277 }
8278}
8279
8280ALIAS (show_bgp_instance_ipv4_safi_rsclient_summary,
8281 show_bgp_ipv4_safi_rsclient_summary_cmd,
8282 "show bgp ipv4 (unicast|multicast) rsclient summary",
8283 SHOW_STR
8284 BGP_STR
8285 "Address family\n"
8286 "Address Family modifier\n"
8287 "Address Family modifier\n"
8288 "Information about Route Server Clients\n"
8289 "Summary of all Route Server Clients\n")
8290
paulfee0f4c2004-09-13 05:12:46 +00008291#ifdef HAVE_IPV6
8292DEFUN (show_bgp_rsclient_summary,
8293 show_bgp_rsclient_summary_cmd,
8294 "show bgp rsclient summary",
8295 SHOW_STR
8296 BGP_STR
8297 "Information about Route Server Clients\n"
8298 "Summary of all Route Server Clients\n")
8299{
8300 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
8301}
8302
8303DEFUN (show_bgp_instance_rsclient_summary,
8304 show_bgp_instance_rsclient_summary_cmd,
8305 "show bgp view WORD rsclient summary",
8306 SHOW_STR
8307 BGP_STR
8308 "BGP view\n"
8309 "View name\n"
8310 "Information about Route Server Clients\n"
8311 "Summary of all Route Server Clients\n")
8312{
8313 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
8314}
8315
8316ALIAS (show_bgp_rsclient_summary,
8317 show_bgp_ipv6_rsclient_summary_cmd,
8318 "show bgp ipv6 rsclient summary",
8319 SHOW_STR
8320 BGP_STR
8321 "Address family\n"
8322 "Information about Route Server Clients\n"
8323 "Summary of all Route Server Clients\n")
8324
8325ALIAS (show_bgp_instance_rsclient_summary,
8326 show_bgp_instance_ipv6_rsclient_summary_cmd,
8327 "show bgp view WORD ipv6 rsclient summary",
8328 SHOW_STR
8329 BGP_STR
8330 "BGP view\n"
8331 "View name\n"
8332 "Address family\n"
8333 "Information about Route Server Clients\n"
8334 "Summary of all Route Server Clients\n")
Michael Lambert95cbbd22010-07-23 14:43:04 -04008335
8336DEFUN (show_bgp_instance_ipv6_safi_rsclient_summary,
8337 show_bgp_instance_ipv6_safi_rsclient_summary_cmd,
8338 "show bgp view WORD ipv6 (unicast|multicast) rsclient summary",
8339 SHOW_STR
8340 BGP_STR
8341 "BGP view\n"
8342 "View name\n"
8343 "Address family\n"
8344 "Address Family modifier\n"
8345 "Address Family modifier\n"
8346 "Information about Route Server Clients\n"
8347 "Summary of all Route Server Clients\n")
8348{
8349 safi_t safi;
8350
8351 if (argc == 2) {
8352 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
8353 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP6, safi);
8354 } else {
8355 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
8356 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP6, safi);
8357 }
8358}
8359
8360ALIAS (show_bgp_instance_ipv6_safi_rsclient_summary,
8361 show_bgp_ipv6_safi_rsclient_summary_cmd,
8362 "show bgp ipv6 (unicast|multicast) rsclient summary",
8363 SHOW_STR
8364 BGP_STR
8365 "Address family\n"
8366 "Address Family modifier\n"
8367 "Address Family modifier\n"
8368 "Information about Route Server Clients\n"
8369 "Summary of all Route Server Clients\n")
8370
paulfee0f4c2004-09-13 05:12:46 +00008371#endif /* HAVE IPV6 */
8372
paul718e3742002-12-13 20:15:29 +00008373/* Redistribute VTY commands. */
8374
8375/* Utility function to convert user input route type string to route
8376 type. */
8377static int
paulfd79ac92004-10-13 05:06:08 +00008378bgp_str2route_type (int afi, const char *str)
paul718e3742002-12-13 20:15:29 +00008379{
8380 if (! str)
8381 return 0;
8382
8383 if (afi == AFI_IP)
8384 {
8385 if (strncmp (str, "k", 1) == 0)
8386 return ZEBRA_ROUTE_KERNEL;
8387 else if (strncmp (str, "c", 1) == 0)
8388 return ZEBRA_ROUTE_CONNECT;
8389 else if (strncmp (str, "s", 1) == 0)
8390 return ZEBRA_ROUTE_STATIC;
8391 else if (strncmp (str, "r", 1) == 0)
8392 return ZEBRA_ROUTE_RIP;
8393 else if (strncmp (str, "o", 1) == 0)
8394 return ZEBRA_ROUTE_OSPF;
8395 }
8396 if (afi == AFI_IP6)
8397 {
8398 if (strncmp (str, "k", 1) == 0)
8399 return ZEBRA_ROUTE_KERNEL;
8400 else if (strncmp (str, "c", 1) == 0)
8401 return ZEBRA_ROUTE_CONNECT;
8402 else if (strncmp (str, "s", 1) == 0)
8403 return ZEBRA_ROUTE_STATIC;
8404 else if (strncmp (str, "r", 1) == 0)
8405 return ZEBRA_ROUTE_RIPNG;
8406 else if (strncmp (str, "o", 1) == 0)
8407 return ZEBRA_ROUTE_OSPF6;
8408 }
8409 return 0;
8410}
8411
8412DEFUN (bgp_redistribute_ipv4,
8413 bgp_redistribute_ipv4_cmd,
8414 "redistribute (connected|kernel|ospf|rip|static)",
8415 "Redistribute information from another routing protocol\n"
8416 "Connected\n"
8417 "Kernel routes\n"
8418 "Open Shurtest Path First (OSPF)\n"
8419 "Routing Information Protocol (RIP)\n"
8420 "Static routes\n")
8421{
8422 int type;
8423
8424 type = bgp_str2route_type (AFI_IP, argv[0]);
8425 if (! type)
8426 {
8427 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8428 return CMD_WARNING;
8429 }
8430 return bgp_redistribute_set (vty->index, AFI_IP, type);
8431}
8432
8433DEFUN (bgp_redistribute_ipv4_rmap,
8434 bgp_redistribute_ipv4_rmap_cmd,
8435 "redistribute (connected|kernel|ospf|rip|static) route-map WORD",
8436 "Redistribute information from another routing protocol\n"
8437 "Connected\n"
8438 "Kernel routes\n"
8439 "Open Shurtest Path First (OSPF)\n"
8440 "Routing Information Protocol (RIP)\n"
8441 "Static routes\n"
8442 "Route map reference\n"
8443 "Pointer to route-map entries\n")
8444{
8445 int type;
8446
8447 type = bgp_str2route_type (AFI_IP, argv[0]);
8448 if (! type)
8449 {
8450 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8451 return CMD_WARNING;
8452 }
8453
8454 bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[1]);
8455 return bgp_redistribute_set (vty->index, AFI_IP, type);
8456}
8457
8458DEFUN (bgp_redistribute_ipv4_metric,
8459 bgp_redistribute_ipv4_metric_cmd,
8460 "redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295>",
8461 "Redistribute information from another routing protocol\n"
8462 "Connected\n"
8463 "Kernel routes\n"
8464 "Open Shurtest Path First (OSPF)\n"
8465 "Routing Information Protocol (RIP)\n"
8466 "Static routes\n"
8467 "Metric for redistributed routes\n"
8468 "Default metric\n")
8469{
8470 int type;
8471 u_int32_t metric;
8472
8473 type = bgp_str2route_type (AFI_IP, argv[0]);
8474 if (! type)
8475 {
8476 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8477 return CMD_WARNING;
8478 }
8479 VTY_GET_INTEGER ("metric", metric, argv[1]);
8480
8481 bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
8482 return bgp_redistribute_set (vty->index, AFI_IP, type);
8483}
8484
8485DEFUN (bgp_redistribute_ipv4_rmap_metric,
8486 bgp_redistribute_ipv4_rmap_metric_cmd,
8487 "redistribute (connected|kernel|ospf|rip|static) route-map WORD metric <0-4294967295>",
8488 "Redistribute information from another routing protocol\n"
8489 "Connected\n"
8490 "Kernel routes\n"
8491 "Open Shurtest Path First (OSPF)\n"
8492 "Routing Information Protocol (RIP)\n"
8493 "Static routes\n"
8494 "Route map reference\n"
8495 "Pointer to route-map entries\n"
8496 "Metric for redistributed routes\n"
8497 "Default metric\n")
8498{
8499 int type;
8500 u_int32_t metric;
8501
8502 type = bgp_str2route_type (AFI_IP, argv[0]);
8503 if (! type)
8504 {
8505 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8506 return CMD_WARNING;
8507 }
8508 VTY_GET_INTEGER ("metric", metric, argv[2]);
8509
8510 bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[1]);
8511 bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
8512 return bgp_redistribute_set (vty->index, AFI_IP, type);
8513}
8514
8515DEFUN (bgp_redistribute_ipv4_metric_rmap,
8516 bgp_redistribute_ipv4_metric_rmap_cmd,
8517 "redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295> route-map WORD",
8518 "Redistribute information from another routing protocol\n"
8519 "Connected\n"
8520 "Kernel routes\n"
8521 "Open Shurtest Path First (OSPF)\n"
8522 "Routing Information Protocol (RIP)\n"
8523 "Static routes\n"
8524 "Metric for redistributed routes\n"
8525 "Default metric\n"
8526 "Route map reference\n"
8527 "Pointer to route-map entries\n")
8528{
8529 int type;
8530 u_int32_t metric;
8531
8532 type = bgp_str2route_type (AFI_IP, argv[0]);
8533 if (! type)
8534 {
8535 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8536 return CMD_WARNING;
8537 }
8538 VTY_GET_INTEGER ("metric", metric, argv[1]);
8539
8540 bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
8541 bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[2]);
8542 return bgp_redistribute_set (vty->index, AFI_IP, type);
8543}
8544
8545DEFUN (no_bgp_redistribute_ipv4,
8546 no_bgp_redistribute_ipv4_cmd,
8547 "no redistribute (connected|kernel|ospf|rip|static)",
8548 NO_STR
8549 "Redistribute information from another routing protocol\n"
8550 "Connected\n"
8551 "Kernel routes\n"
8552 "Open Shurtest Path First (OSPF)\n"
8553 "Routing Information Protocol (RIP)\n"
8554 "Static routes\n")
8555{
8556 int type;
8557
8558 type = bgp_str2route_type (AFI_IP, argv[0]);
8559 if (! type)
8560 {
8561 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8562 return CMD_WARNING;
8563 }
8564
8565 return bgp_redistribute_unset (vty->index, AFI_IP, type);
8566}
8567
8568DEFUN (no_bgp_redistribute_ipv4_rmap,
8569 no_bgp_redistribute_ipv4_rmap_cmd,
8570 "no redistribute (connected|kernel|ospf|rip|static) route-map WORD",
8571 NO_STR
8572 "Redistribute information from another routing protocol\n"
8573 "Connected\n"
8574 "Kernel routes\n"
8575 "Open Shurtest Path First (OSPF)\n"
8576 "Routing Information Protocol (RIP)\n"
8577 "Static routes\n"
8578 "Route map reference\n"
8579 "Pointer to route-map entries\n")
8580{
8581 int type;
8582
8583 type = bgp_str2route_type (AFI_IP, argv[0]);
8584 if (! type)
8585 {
8586 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8587 return CMD_WARNING;
8588 }
8589
8590 bgp_redistribute_routemap_unset (vty->index, AFI_IP, type);
8591 return CMD_SUCCESS;
8592}
8593
8594DEFUN (no_bgp_redistribute_ipv4_metric,
8595 no_bgp_redistribute_ipv4_metric_cmd,
8596 "no redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295>",
8597 NO_STR
8598 "Redistribute information from another routing protocol\n"
8599 "Connected\n"
8600 "Kernel routes\n"
8601 "Open Shurtest Path First (OSPF)\n"
8602 "Routing Information Protocol (RIP)\n"
8603 "Static routes\n"
8604 "Metric for redistributed routes\n"
8605 "Default metric\n")
8606{
8607 int type;
8608
8609 type = bgp_str2route_type (AFI_IP, argv[0]);
8610 if (! type)
8611 {
8612 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8613 return CMD_WARNING;
8614 }
8615
8616 bgp_redistribute_metric_unset (vty->index, AFI_IP, type);
8617 return CMD_SUCCESS;
8618}
8619
8620DEFUN (no_bgp_redistribute_ipv4_rmap_metric,
8621 no_bgp_redistribute_ipv4_rmap_metric_cmd,
8622 "no redistribute (connected|kernel|ospf|rip|static) route-map WORD metric <0-4294967295>",
8623 NO_STR
8624 "Redistribute information from another routing protocol\n"
8625 "Connected\n"
8626 "Kernel routes\n"
8627 "Open Shurtest Path First (OSPF)\n"
8628 "Routing Information Protocol (RIP)\n"
8629 "Static routes\n"
8630 "Route map reference\n"
8631 "Pointer to route-map entries\n"
8632 "Metric for redistributed routes\n"
8633 "Default metric\n")
8634{
8635 int type;
8636
8637 type = bgp_str2route_type (AFI_IP, argv[0]);
8638 if (! type)
8639 {
8640 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8641 return CMD_WARNING;
8642 }
8643
8644 bgp_redistribute_metric_unset (vty->index, AFI_IP, type);
8645 bgp_redistribute_routemap_unset (vty->index, AFI_IP, type);
8646 return CMD_SUCCESS;
8647}
8648
8649ALIAS (no_bgp_redistribute_ipv4_rmap_metric,
8650 no_bgp_redistribute_ipv4_metric_rmap_cmd,
8651 "no redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295> route-map WORD",
8652 NO_STR
8653 "Redistribute information from another routing protocol\n"
8654 "Connected\n"
8655 "Kernel routes\n"
8656 "Open Shurtest Path First (OSPF)\n"
8657 "Routing Information Protocol (RIP)\n"
8658 "Static routes\n"
8659 "Metric for redistributed routes\n"
8660 "Default metric\n"
8661 "Route map reference\n"
8662 "Pointer to route-map entries\n")
8663
8664#ifdef HAVE_IPV6
8665DEFUN (bgp_redistribute_ipv6,
8666 bgp_redistribute_ipv6_cmd,
8667 "redistribute (connected|kernel|ospf6|ripng|static)",
8668 "Redistribute information from another routing protocol\n"
8669 "Connected\n"
8670 "Kernel routes\n"
8671 "Open Shurtest Path First (OSPFv3)\n"
8672 "Routing Information Protocol (RIPng)\n"
8673 "Static routes\n")
8674{
8675 int type;
8676
8677 type = bgp_str2route_type (AFI_IP6, argv[0]);
8678 if (! type)
8679 {
8680 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8681 return CMD_WARNING;
8682 }
8683
8684 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8685}
8686
8687DEFUN (bgp_redistribute_ipv6_rmap,
8688 bgp_redistribute_ipv6_rmap_cmd,
8689 "redistribute (connected|kernel|ospf6|ripng|static) route-map WORD",
8690 "Redistribute information from another routing protocol\n"
8691 "Connected\n"
8692 "Kernel routes\n"
8693 "Open Shurtest Path First (OSPFv3)\n"
8694 "Routing Information Protocol (RIPng)\n"
8695 "Static routes\n"
8696 "Route map reference\n"
8697 "Pointer to route-map entries\n")
8698{
8699 int type;
8700
8701 type = bgp_str2route_type (AFI_IP6, argv[0]);
8702 if (! type)
8703 {
8704 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8705 return CMD_WARNING;
8706 }
8707
8708 bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[1]);
8709 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8710}
8711
8712DEFUN (bgp_redistribute_ipv6_metric,
8713 bgp_redistribute_ipv6_metric_cmd,
8714 "redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295>",
8715 "Redistribute information from another routing protocol\n"
8716 "Connected\n"
8717 "Kernel routes\n"
8718 "Open Shurtest Path First (OSPFv3)\n"
8719 "Routing Information Protocol (RIPng)\n"
8720 "Static routes\n"
8721 "Metric for redistributed routes\n"
8722 "Default metric\n")
8723{
8724 int type;
8725 u_int32_t metric;
8726
8727 type = bgp_str2route_type (AFI_IP6, argv[0]);
8728 if (! type)
8729 {
8730 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8731 return CMD_WARNING;
8732 }
8733 VTY_GET_INTEGER ("metric", metric, argv[1]);
8734
8735 bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
8736 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8737}
8738
8739DEFUN (bgp_redistribute_ipv6_rmap_metric,
8740 bgp_redistribute_ipv6_rmap_metric_cmd,
8741 "redistribute (connected|kernel|ospf6|ripng|static) route-map WORD metric <0-4294967295>",
8742 "Redistribute information from another routing protocol\n"
8743 "Connected\n"
8744 "Kernel routes\n"
8745 "Open Shurtest Path First (OSPFv3)\n"
8746 "Routing Information Protocol (RIPng)\n"
8747 "Static routes\n"
8748 "Route map reference\n"
8749 "Pointer to route-map entries\n"
8750 "Metric for redistributed routes\n"
8751 "Default metric\n")
8752{
8753 int type;
8754 u_int32_t metric;
8755
8756 type = bgp_str2route_type (AFI_IP6, argv[0]);
8757 if (! type)
8758 {
8759 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8760 return CMD_WARNING;
8761 }
8762 VTY_GET_INTEGER ("metric", metric, argv[2]);
8763
8764 bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[1]);
8765 bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
8766 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8767}
8768
8769DEFUN (bgp_redistribute_ipv6_metric_rmap,
8770 bgp_redistribute_ipv6_metric_rmap_cmd,
8771 "redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295> route-map WORD",
8772 "Redistribute information from another routing protocol\n"
8773 "Connected\n"
8774 "Kernel routes\n"
8775 "Open Shurtest Path First (OSPFv3)\n"
8776 "Routing Information Protocol (RIPng)\n"
8777 "Static routes\n"
8778 "Metric for redistributed routes\n"
8779 "Default metric\n"
8780 "Route map reference\n"
8781 "Pointer to route-map entries\n")
8782{
8783 int type;
8784 u_int32_t metric;
8785
8786 type = bgp_str2route_type (AFI_IP6, argv[0]);
8787 if (! type)
8788 {
8789 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8790 return CMD_WARNING;
8791 }
8792 VTY_GET_INTEGER ("metric", metric, argv[1]);
8793
8794 bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
8795 bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[2]);
8796 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8797}
8798
8799DEFUN (no_bgp_redistribute_ipv6,
8800 no_bgp_redistribute_ipv6_cmd,
8801 "no redistribute (connected|kernel|ospf6|ripng|static)",
8802 NO_STR
8803 "Redistribute information from another routing protocol\n"
8804 "Connected\n"
8805 "Kernel routes\n"
8806 "Open Shurtest Path First (OSPFv3)\n"
8807 "Routing Information Protocol (RIPng)\n"
8808 "Static routes\n")
8809{
8810 int type;
8811
8812 type = bgp_str2route_type (AFI_IP6, argv[0]);
8813 if (! type)
8814 {
8815 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8816 return CMD_WARNING;
8817 }
8818
8819 return bgp_redistribute_unset (vty->index, AFI_IP6, type);
8820}
8821
8822DEFUN (no_bgp_redistribute_ipv6_rmap,
8823 no_bgp_redistribute_ipv6_rmap_cmd,
8824 "no redistribute (connected|kernel|ospf6|ripng|static) route-map WORD",
8825 NO_STR
8826 "Redistribute information from another routing protocol\n"
8827 "Connected\n"
8828 "Kernel routes\n"
8829 "Open Shurtest Path First (OSPFv3)\n"
8830 "Routing Information Protocol (RIPng)\n"
8831 "Static routes\n"
8832 "Route map reference\n"
8833 "Pointer to route-map entries\n")
8834{
8835 int type;
8836
8837 type = bgp_str2route_type (AFI_IP6, argv[0]);
8838 if (! type)
8839 {
8840 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8841 return CMD_WARNING;
8842 }
8843
8844 bgp_redistribute_routemap_unset (vty->index, AFI_IP6, type);
8845 return CMD_SUCCESS;
8846}
8847
8848DEFUN (no_bgp_redistribute_ipv6_metric,
8849 no_bgp_redistribute_ipv6_metric_cmd,
8850 "no redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295>",
8851 NO_STR
8852 "Redistribute information from another routing protocol\n"
8853 "Connected\n"
8854 "Kernel routes\n"
8855 "Open Shurtest Path First (OSPFv3)\n"
8856 "Routing Information Protocol (RIPng)\n"
8857 "Static routes\n"
8858 "Metric for redistributed routes\n"
8859 "Default metric\n")
8860{
8861 int type;
8862
8863 type = bgp_str2route_type (AFI_IP6, argv[0]);
8864 if (! type)
8865 {
8866 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8867 return CMD_WARNING;
8868 }
8869
8870 bgp_redistribute_metric_unset (vty->index, AFI_IP6, type);
8871 return CMD_SUCCESS;
8872}
8873
8874DEFUN (no_bgp_redistribute_ipv6_rmap_metric,
8875 no_bgp_redistribute_ipv6_rmap_metric_cmd,
8876 "no redistribute (connected|kernel|ospf6|ripng|static) route-map WORD metric <0-4294967295>",
8877 NO_STR
8878 "Redistribute information from another routing protocol\n"
8879 "Connected\n"
8880 "Kernel routes\n"
8881 "Open Shurtest Path First (OSPFv3)\n"
8882 "Routing Information Protocol (RIPng)\n"
8883 "Static routes\n"
8884 "Route map reference\n"
8885 "Pointer to route-map entries\n"
8886 "Metric for redistributed routes\n"
8887 "Default metric\n")
8888{
8889 int type;
8890
8891 type = bgp_str2route_type (AFI_IP6, argv[0]);
8892 if (! type)
8893 {
8894 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8895 return CMD_WARNING;
8896 }
8897
8898 bgp_redistribute_metric_unset (vty->index, AFI_IP6, type);
8899 bgp_redistribute_routemap_unset (vty->index, AFI_IP6, type);
8900 return CMD_SUCCESS;
8901}
8902
8903ALIAS (no_bgp_redistribute_ipv6_rmap_metric,
8904 no_bgp_redistribute_ipv6_metric_rmap_cmd,
8905 "no redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295> route-map WORD",
8906 NO_STR
8907 "Redistribute information from another routing protocol\n"
8908 "Connected\n"
8909 "Kernel routes\n"
8910 "Open Shurtest Path First (OSPFv3)\n"
8911 "Routing Information Protocol (RIPng)\n"
8912 "Static routes\n"
8913 "Metric for redistributed routes\n"
8914 "Default metric\n"
8915 "Route map reference\n"
8916 "Pointer to route-map entries\n")
8917#endif /* HAVE_IPV6 */
8918
8919int
8920bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi,
8921 safi_t safi, int *write)
8922{
8923 int i;
paul718e3742002-12-13 20:15:29 +00008924
8925 /* Unicast redistribution only. */
8926 if (safi != SAFI_UNICAST)
8927 return 0;
8928
8929 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
8930 {
8931 /* Redistribute BGP does not make sense. */
8932 if (bgp->redist[afi][i] && i != ZEBRA_ROUTE_BGP)
8933 {
8934 /* Display "address-family" when it is not yet diplayed. */
8935 bgp_config_write_family_header (vty, afi, safi, write);
8936
8937 /* "redistribute" configuration. */
ajsf52d13c2005-10-01 17:38:06 +00008938 vty_out (vty, " redistribute %s", zebra_route_string(i));
paul718e3742002-12-13 20:15:29 +00008939
8940 if (bgp->redist_metric_flag[afi][i])
8941 vty_out (vty, " metric %d", bgp->redist_metric[afi][i]);
8942
8943 if (bgp->rmap[afi][i].name)
8944 vty_out (vty, " route-map %s", bgp->rmap[afi][i].name);
8945
8946 vty_out (vty, "%s", VTY_NEWLINE);
8947 }
8948 }
8949 return *write;
8950}
8951
8952/* BGP node structure. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008953static struct cmd_node bgp_node =
paul718e3742002-12-13 20:15:29 +00008954{
8955 BGP_NODE,
8956 "%s(config-router)# ",
8957 1,
8958};
8959
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008960static struct cmd_node bgp_ipv4_unicast_node =
paul718e3742002-12-13 20:15:29 +00008961{
8962 BGP_IPV4_NODE,
8963 "%s(config-router-af)# ",
8964 1,
8965};
8966
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008967static struct cmd_node bgp_ipv4_multicast_node =
paul718e3742002-12-13 20:15:29 +00008968{
8969 BGP_IPV4M_NODE,
8970 "%s(config-router-af)# ",
8971 1,
8972};
8973
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008974static struct cmd_node bgp_ipv6_unicast_node =
paul718e3742002-12-13 20:15:29 +00008975{
8976 BGP_IPV6_NODE,
8977 "%s(config-router-af)# ",
8978 1,
8979};
8980
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008981static struct cmd_node bgp_ipv6_multicast_node =
paul25ffbdc2005-08-22 22:42:08 +00008982{
8983 BGP_IPV6M_NODE,
8984 "%s(config-router-af)# ",
8985 1,
8986};
8987
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008988static struct cmd_node bgp_vpnv4_node =
paul718e3742002-12-13 20:15:29 +00008989{
8990 BGP_VPNV4_NODE,
8991 "%s(config-router-af)# ",
8992 1
8993};
8994
paul1f8ae702005-09-09 23:49:49 +00008995static void community_list_vty (void);
8996
paul718e3742002-12-13 20:15:29 +00008997void
paul94f2b392005-06-28 12:44:16 +00008998bgp_vty_init (void)
paul718e3742002-12-13 20:15:29 +00008999{
paul718e3742002-12-13 20:15:29 +00009000 /* Install bgp top node. */
9001 install_node (&bgp_node, bgp_config_write);
9002 install_node (&bgp_ipv4_unicast_node, NULL);
9003 install_node (&bgp_ipv4_multicast_node, NULL);
9004 install_node (&bgp_ipv6_unicast_node, NULL);
paul25ffbdc2005-08-22 22:42:08 +00009005 install_node (&bgp_ipv6_multicast_node, NULL);
paul718e3742002-12-13 20:15:29 +00009006 install_node (&bgp_vpnv4_node, NULL);
9007
9008 /* Install default VTY commands to new nodes. */
9009 install_default (BGP_NODE);
9010 install_default (BGP_IPV4_NODE);
9011 install_default (BGP_IPV4M_NODE);
9012 install_default (BGP_IPV6_NODE);
paul25ffbdc2005-08-22 22:42:08 +00009013 install_default (BGP_IPV6M_NODE);
paul718e3742002-12-13 20:15:29 +00009014 install_default (BGP_VPNV4_NODE);
9015
9016 /* "bgp multiple-instance" commands. */
9017 install_element (CONFIG_NODE, &bgp_multiple_instance_cmd);
9018 install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd);
9019
9020 /* "bgp config-type" commands. */
9021 install_element (CONFIG_NODE, &bgp_config_type_cmd);
9022 install_element (CONFIG_NODE, &no_bgp_config_type_cmd);
9023
9024 /* Dummy commands (Currently not supported) */
9025 install_element (BGP_NODE, &no_synchronization_cmd);
9026 install_element (BGP_NODE, &no_auto_summary_cmd);
9027
9028 /* "router bgp" commands. */
9029 install_element (CONFIG_NODE, &router_bgp_cmd);
9030 install_element (CONFIG_NODE, &router_bgp_view_cmd);
9031
9032 /* "no router bgp" commands. */
9033 install_element (CONFIG_NODE, &no_router_bgp_cmd);
9034 install_element (CONFIG_NODE, &no_router_bgp_view_cmd);
9035
9036 /* "bgp router-id" commands. */
9037 install_element (BGP_NODE, &bgp_router_id_cmd);
9038 install_element (BGP_NODE, &no_bgp_router_id_cmd);
9039 install_element (BGP_NODE, &no_bgp_router_id_val_cmd);
9040
9041 /* "bgp cluster-id" commands. */
9042 install_element (BGP_NODE, &bgp_cluster_id_cmd);
9043 install_element (BGP_NODE, &bgp_cluster_id32_cmd);
9044 install_element (BGP_NODE, &no_bgp_cluster_id_cmd);
9045 install_element (BGP_NODE, &no_bgp_cluster_id_arg_cmd);
9046
9047 /* "bgp confederation" commands. */
9048 install_element (BGP_NODE, &bgp_confederation_identifier_cmd);
9049 install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd);
9050 install_element (BGP_NODE, &no_bgp_confederation_identifier_arg_cmd);
9051
9052 /* "bgp confederation peers" commands. */
9053 install_element (BGP_NODE, &bgp_confederation_peers_cmd);
9054 install_element (BGP_NODE, &no_bgp_confederation_peers_cmd);
9055
9056 /* "timers bgp" commands. */
9057 install_element (BGP_NODE, &bgp_timers_cmd);
9058 install_element (BGP_NODE, &no_bgp_timers_cmd);
9059 install_element (BGP_NODE, &no_bgp_timers_arg_cmd);
9060
9061 /* "bgp client-to-client reflection" commands */
9062 install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd);
9063 install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd);
9064
9065 /* "bgp always-compare-med" commands */
9066 install_element (BGP_NODE, &bgp_always_compare_med_cmd);
9067 install_element (BGP_NODE, &no_bgp_always_compare_med_cmd);
9068
9069 /* "bgp deterministic-med" commands */
9070 install_element (BGP_NODE, &bgp_deterministic_med_cmd);
9071 install_element (BGP_NODE, &no_bgp_deterministic_med_cmd);
hasso538621f2004-05-21 09:31:30 +00009072
hasso538621f2004-05-21 09:31:30 +00009073 /* "bgp graceful-restart" commands */
9074 install_element (BGP_NODE, &bgp_graceful_restart_cmd);
9075 install_element (BGP_NODE, &no_bgp_graceful_restart_cmd);
hasso93406d82005-02-02 14:40:33 +00009076 install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd);
9077 install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd);
9078 install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_val_cmd);
paul718e3742002-12-13 20:15:29 +00009079
9080 /* "bgp fast-external-failover" commands */
9081 install_element (BGP_NODE, &bgp_fast_external_failover_cmd);
9082 install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd);
9083
9084 /* "bgp enforce-first-as" commands */
9085 install_element (BGP_NODE, &bgp_enforce_first_as_cmd);
9086 install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd);
9087
9088 /* "bgp bestpath compare-routerid" commands */
9089 install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd);
9090 install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd);
9091
9092 /* "bgp bestpath as-path ignore" commands */
9093 install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd);
9094 install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd);
9095
hasso68118452005-04-08 15:40:36 +00009096 /* "bgp bestpath as-path confed" commands */
9097 install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd);
9098 install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd);
9099
paul848973c2003-08-13 00:32:49 +00009100 /* "bgp log-neighbor-changes" commands */
9101 install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd);
9102 install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd);
9103
paul718e3742002-12-13 20:15:29 +00009104 /* "bgp bestpath med" commands */
9105 install_element (BGP_NODE, &bgp_bestpath_med_cmd);
9106 install_element (BGP_NODE, &bgp_bestpath_med2_cmd);
9107 install_element (BGP_NODE, &bgp_bestpath_med3_cmd);
9108 install_element (BGP_NODE, &no_bgp_bestpath_med_cmd);
9109 install_element (BGP_NODE, &no_bgp_bestpath_med2_cmd);
9110 install_element (BGP_NODE, &no_bgp_bestpath_med3_cmd);
9111
9112 /* "no bgp default ipv4-unicast" commands. */
9113 install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd);
9114 install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd);
9115
9116 /* "bgp network import-check" commands. */
9117 install_element (BGP_NODE, &bgp_network_import_check_cmd);
9118 install_element (BGP_NODE, &no_bgp_network_import_check_cmd);
9119
9120 /* "bgp default local-preference" commands. */
9121 install_element (BGP_NODE, &bgp_default_local_preference_cmd);
9122 install_element (BGP_NODE, &no_bgp_default_local_preference_cmd);
9123 install_element (BGP_NODE, &no_bgp_default_local_preference_val_cmd);
9124
9125 /* "neighbor remote-as" commands. */
9126 install_element (BGP_NODE, &neighbor_remote_as_cmd);
9127 install_element (BGP_NODE, &no_neighbor_cmd);
9128 install_element (BGP_NODE, &no_neighbor_remote_as_cmd);
9129
9130 /* "neighbor peer-group" commands. */
9131 install_element (BGP_NODE, &neighbor_peer_group_cmd);
9132 install_element (BGP_NODE, &no_neighbor_peer_group_cmd);
9133 install_element (BGP_NODE, &no_neighbor_peer_group_remote_as_cmd);
9134
9135 /* "neighbor local-as" commands. */
9136 install_element (BGP_NODE, &neighbor_local_as_cmd);
9137 install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd);
9138 install_element (BGP_NODE, &no_neighbor_local_as_cmd);
9139 install_element (BGP_NODE, &no_neighbor_local_as_val_cmd);
9140 install_element (BGP_NODE, &no_neighbor_local_as_val2_cmd);
9141
Paul Jakma0df7c912008-07-21 21:02:49 +00009142 /* "neighbor password" commands. */
9143 install_element (BGP_NODE, &neighbor_password_cmd);
9144 install_element (BGP_NODE, &no_neighbor_password_cmd);
9145
paul718e3742002-12-13 20:15:29 +00009146 /* "neighbor activate" commands. */
9147 install_element (BGP_NODE, &neighbor_activate_cmd);
9148 install_element (BGP_IPV4_NODE, &neighbor_activate_cmd);
9149 install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd);
9150 install_element (BGP_IPV6_NODE, &neighbor_activate_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009151 install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd);
paul718e3742002-12-13 20:15:29 +00009152 install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd);
9153
9154 /* "no neighbor activate" commands. */
9155 install_element (BGP_NODE, &no_neighbor_activate_cmd);
9156 install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd);
9157 install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd);
9158 install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009159 install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd);
paul718e3742002-12-13 20:15:29 +00009160 install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd);
9161
9162 /* "neighbor peer-group set" commands. */
9163 install_element (BGP_NODE, &neighbor_set_peer_group_cmd);
9164 install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_cmd);
9165 install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_cmd);
9166 install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009167 install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_cmd);
paula58545b2003-07-12 21:43:01 +00009168 install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_cmd);
9169
paul718e3742002-12-13 20:15:29 +00009170 /* "no neighbor peer-group unset" commands. */
9171 install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd);
9172 install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd);
9173 install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_cmd);
9174 install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009175 install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_cmd);
paula58545b2003-07-12 21:43:01 +00009176 install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_cmd);
9177
paul718e3742002-12-13 20:15:29 +00009178 /* "neighbor softreconfiguration inbound" commands.*/
9179 install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd);
9180 install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd);
9181 install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd);
9182 install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
9183 install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd);
9184 install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd);
9185 install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd);
9186 install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009187 install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd);
9188 install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd);
paula58545b2003-07-12 21:43:01 +00009189 install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd);
9190 install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
paul718e3742002-12-13 20:15:29 +00009191
9192 /* "neighbor attribute-unchanged" commands. */
9193 install_element (BGP_NODE, &neighbor_attr_unchanged_cmd);
9194 install_element (BGP_NODE, &neighbor_attr_unchanged1_cmd);
9195 install_element (BGP_NODE, &neighbor_attr_unchanged2_cmd);
9196 install_element (BGP_NODE, &neighbor_attr_unchanged3_cmd);
9197 install_element (BGP_NODE, &neighbor_attr_unchanged4_cmd);
9198 install_element (BGP_NODE, &neighbor_attr_unchanged5_cmd);
9199 install_element (BGP_NODE, &neighbor_attr_unchanged6_cmd);
9200 install_element (BGP_NODE, &neighbor_attr_unchanged7_cmd);
9201 install_element (BGP_NODE, &neighbor_attr_unchanged8_cmd);
9202 install_element (BGP_NODE, &neighbor_attr_unchanged9_cmd);
9203 install_element (BGP_NODE, &neighbor_attr_unchanged10_cmd);
9204 install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd);
9205 install_element (BGP_NODE, &no_neighbor_attr_unchanged1_cmd);
9206 install_element (BGP_NODE, &no_neighbor_attr_unchanged2_cmd);
9207 install_element (BGP_NODE, &no_neighbor_attr_unchanged3_cmd);
9208 install_element (BGP_NODE, &no_neighbor_attr_unchanged4_cmd);
9209 install_element (BGP_NODE, &no_neighbor_attr_unchanged5_cmd);
9210 install_element (BGP_NODE, &no_neighbor_attr_unchanged6_cmd);
9211 install_element (BGP_NODE, &no_neighbor_attr_unchanged7_cmd);
9212 install_element (BGP_NODE, &no_neighbor_attr_unchanged8_cmd);
9213 install_element (BGP_NODE, &no_neighbor_attr_unchanged9_cmd);
9214 install_element (BGP_NODE, &no_neighbor_attr_unchanged10_cmd);
9215 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd);
9216 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged1_cmd);
9217 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged2_cmd);
9218 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged3_cmd);
9219 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged4_cmd);
9220 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged5_cmd);
9221 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged6_cmd);
9222 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged7_cmd);
9223 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged8_cmd);
9224 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged9_cmd);
9225 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged10_cmd);
9226 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd);
9227 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged1_cmd);
9228 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged2_cmd);
9229 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged3_cmd);
9230 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged4_cmd);
9231 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged5_cmd);
9232 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged6_cmd);
9233 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged7_cmd);
9234 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged8_cmd);
9235 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged9_cmd);
9236 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged10_cmd);
9237 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd);
9238 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged1_cmd);
9239 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged2_cmd);
9240 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged3_cmd);
9241 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged4_cmd);
9242 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged5_cmd);
9243 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged6_cmd);
9244 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged7_cmd);
9245 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged8_cmd);
9246 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged9_cmd);
9247 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged10_cmd);
9248 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd);
9249 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged1_cmd);
9250 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged2_cmd);
9251 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged3_cmd);
9252 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged4_cmd);
9253 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged5_cmd);
9254 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged6_cmd);
9255 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged7_cmd);
9256 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged8_cmd);
9257 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged9_cmd);
9258 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged10_cmd);
9259 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd);
9260 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged1_cmd);
9261 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged2_cmd);
9262 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged3_cmd);
9263 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged4_cmd);
9264 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged5_cmd);
9265 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged6_cmd);
9266 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged7_cmd);
9267 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged8_cmd);
9268 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged9_cmd);
9269 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged10_cmd);
9270 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd);
9271 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged1_cmd);
9272 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged2_cmd);
9273 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged3_cmd);
9274 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged4_cmd);
9275 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged5_cmd);
9276 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged6_cmd);
9277 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged7_cmd);
9278 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged8_cmd);
9279 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged9_cmd);
9280 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged10_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009281 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd);
9282 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged1_cmd);
9283 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged2_cmd);
9284 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged3_cmd);
9285 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged4_cmd);
9286 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged5_cmd);
9287 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged6_cmd);
9288 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged7_cmd);
9289 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged8_cmd);
9290 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged9_cmd);
9291 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged10_cmd);
9292 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd);
9293 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged1_cmd);
9294 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged2_cmd);
9295 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged3_cmd);
9296 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged4_cmd);
9297 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged5_cmd);
9298 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged6_cmd);
9299 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged7_cmd);
9300 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged8_cmd);
9301 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged9_cmd);
9302 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged10_cmd);
paul718e3742002-12-13 20:15:29 +00009303 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd);
9304 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged1_cmd);
9305 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged2_cmd);
9306 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged3_cmd);
9307 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged4_cmd);
9308 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged5_cmd);
9309 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged6_cmd);
9310 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged7_cmd);
9311 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged8_cmd);
9312 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged9_cmd);
9313 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged10_cmd);
9314 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd);
9315 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged1_cmd);
9316 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged2_cmd);
9317 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged3_cmd);
9318 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged4_cmd);
9319 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged5_cmd);
9320 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged6_cmd);
9321 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged7_cmd);
9322 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged8_cmd);
9323 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged9_cmd);
9324 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged10_cmd);
9325
paulfee0f4c2004-09-13 05:12:46 +00009326 /* "nexthop-local unchanged" commands */
9327 install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd);
9328 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd);
9329
paul718e3742002-12-13 20:15:29 +00009330 /* "transparent-as" and "transparent-nexthop" for old version
9331 compatibility. */
9332 install_element (BGP_NODE, &neighbor_transparent_as_cmd);
9333 install_element (BGP_NODE, &neighbor_transparent_nexthop_cmd);
9334
9335 /* "neighbor next-hop-self" commands. */
9336 install_element (BGP_NODE, &neighbor_nexthop_self_cmd);
9337 install_element (BGP_NODE, &no_neighbor_nexthop_self_cmd);
9338 install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd);
9339 install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd);
9340 install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd);
9341 install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd);
9342 install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd);
9343 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009344 install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd);
9345 install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd);
paul718e3742002-12-13 20:15:29 +00009346 install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd);
9347 install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd);
9348
9349 /* "neighbor remove-private-AS" commands. */
9350 install_element (BGP_NODE, &neighbor_remove_private_as_cmd);
9351 install_element (BGP_NODE, &no_neighbor_remove_private_as_cmd);
9352 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd);
9353 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd);
9354 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd);
9355 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd);
9356 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd);
9357 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009358 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd);
9359 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd);
paul718e3742002-12-13 20:15:29 +00009360 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd);
9361 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd);
9362
9363 /* "neighbor send-community" commands.*/
9364 install_element (BGP_NODE, &neighbor_send_community_cmd);
9365 install_element (BGP_NODE, &neighbor_send_community_type_cmd);
9366 install_element (BGP_NODE, &no_neighbor_send_community_cmd);
9367 install_element (BGP_NODE, &no_neighbor_send_community_type_cmd);
9368 install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd);
9369 install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd);
9370 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd);
9371 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd);
9372 install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd);
9373 install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd);
9374 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd);
9375 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd);
9376 install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd);
9377 install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd);
9378 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd);
9379 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009380 install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd);
9381 install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd);
9382 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd);
9383 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd);
paul718e3742002-12-13 20:15:29 +00009384 install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd);
9385 install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd);
9386 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd);
9387 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd);
9388
9389 /* "neighbor route-reflector" commands.*/
9390 install_element (BGP_NODE, &neighbor_route_reflector_client_cmd);
9391 install_element (BGP_NODE, &no_neighbor_route_reflector_client_cmd);
9392 install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd);
9393 install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd);
9394 install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd);
9395 install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd);
9396 install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd);
9397 install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009398 install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd);
9399 install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd);
paul718e3742002-12-13 20:15:29 +00009400 install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd);
9401 install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd);
9402
9403 /* "neighbor route-server" commands.*/
9404 install_element (BGP_NODE, &neighbor_route_server_client_cmd);
9405 install_element (BGP_NODE, &no_neighbor_route_server_client_cmd);
9406 install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd);
9407 install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd);
9408 install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd);
9409 install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd);
9410 install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd);
9411 install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009412 install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd);
9413 install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd);
paul718e3742002-12-13 20:15:29 +00009414 install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd);
9415 install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd);
9416
9417 /* "neighbor passive" commands. */
9418 install_element (BGP_NODE, &neighbor_passive_cmd);
9419 install_element (BGP_NODE, &no_neighbor_passive_cmd);
9420
9421 /* "neighbor shutdown" commands. */
9422 install_element (BGP_NODE, &neighbor_shutdown_cmd);
9423 install_element (BGP_NODE, &no_neighbor_shutdown_cmd);
9424
hassoc9502432005-02-01 22:01:48 +00009425 /* Deprecated "neighbor capability route-refresh" commands.*/
paul718e3742002-12-13 20:15:29 +00009426 install_element (BGP_NODE, &neighbor_capability_route_refresh_cmd);
9427 install_element (BGP_NODE, &no_neighbor_capability_route_refresh_cmd);
9428
9429 /* "neighbor capability orf prefix-list" commands.*/
9430 install_element (BGP_NODE, &neighbor_capability_orf_prefix_cmd);
9431 install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_cmd);
9432 install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd);
9433 install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd);
9434 install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd);
9435 install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd);
9436 install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd);
9437 install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009438 install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd);
9439 install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00009440
9441 /* "neighbor capability dynamic" commands.*/
9442 install_element (BGP_NODE, &neighbor_capability_dynamic_cmd);
9443 install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd);
9444
9445 /* "neighbor dont-capability-negotiate" commands. */
9446 install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd);
9447 install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd);
9448
9449 /* "neighbor ebgp-multihop" commands. */
9450 install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd);
9451 install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd);
9452 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd);
9453 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_ttl_cmd);
9454
hasso6ffd2072005-02-02 14:50:11 +00009455 /* "neighbor disable-connected-check" commands. */
9456 install_element (BGP_NODE, &neighbor_disable_connected_check_cmd);
9457 install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd);
paul718e3742002-12-13 20:15:29 +00009458 install_element (BGP_NODE, &neighbor_enforce_multihop_cmd);
9459 install_element (BGP_NODE, &no_neighbor_enforce_multihop_cmd);
9460
9461 /* "neighbor description" commands. */
9462 install_element (BGP_NODE, &neighbor_description_cmd);
9463 install_element (BGP_NODE, &no_neighbor_description_cmd);
9464 install_element (BGP_NODE, &no_neighbor_description_val_cmd);
9465
9466 /* "neighbor update-source" commands. "*/
9467 install_element (BGP_NODE, &neighbor_update_source_cmd);
9468 install_element (BGP_NODE, &no_neighbor_update_source_cmd);
9469
9470 /* "neighbor default-originate" commands. */
9471 install_element (BGP_NODE, &neighbor_default_originate_cmd);
9472 install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd);
9473 install_element (BGP_NODE, &no_neighbor_default_originate_cmd);
9474 install_element (BGP_NODE, &no_neighbor_default_originate_rmap_cmd);
9475 install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd);
9476 install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd);
9477 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd);
9478 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_rmap_cmd);
9479 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd);
9480 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd);
9481 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd);
9482 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_rmap_cmd);
9483 install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd);
9484 install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd);
9485 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd);
9486 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_rmap_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009487 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd);
9488 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd);
9489 install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd);
9490 install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_rmap_cmd);
paul718e3742002-12-13 20:15:29 +00009491
9492 /* "neighbor port" commands. */
9493 install_element (BGP_NODE, &neighbor_port_cmd);
9494 install_element (BGP_NODE, &no_neighbor_port_cmd);
9495 install_element (BGP_NODE, &no_neighbor_port_val_cmd);
9496
9497 /* "neighbor weight" commands. */
9498 install_element (BGP_NODE, &neighbor_weight_cmd);
9499 install_element (BGP_NODE, &no_neighbor_weight_cmd);
9500 install_element (BGP_NODE, &no_neighbor_weight_val_cmd);
9501
9502 /* "neighbor override-capability" commands. */
9503 install_element (BGP_NODE, &neighbor_override_capability_cmd);
9504 install_element (BGP_NODE, &no_neighbor_override_capability_cmd);
9505
9506 /* "neighbor strict-capability-match" commands. */
9507 install_element (BGP_NODE, &neighbor_strict_capability_cmd);
9508 install_element (BGP_NODE, &no_neighbor_strict_capability_cmd);
9509
9510 /* "neighbor timers" commands. */
9511 install_element (BGP_NODE, &neighbor_timers_cmd);
9512 install_element (BGP_NODE, &no_neighbor_timers_cmd);
9513
9514 /* "neighbor timers connect" commands. */
9515 install_element (BGP_NODE, &neighbor_timers_connect_cmd);
9516 install_element (BGP_NODE, &no_neighbor_timers_connect_cmd);
9517 install_element (BGP_NODE, &no_neighbor_timers_connect_val_cmd);
9518
9519 /* "neighbor advertisement-interval" commands. */
9520 install_element (BGP_NODE, &neighbor_advertise_interval_cmd);
9521 install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd);
9522 install_element (BGP_NODE, &no_neighbor_advertise_interval_val_cmd);
9523
9524 /* "neighbor version" commands. */
9525 install_element (BGP_NODE, &neighbor_version_cmd);
paul718e3742002-12-13 20:15:29 +00009526
9527 /* "neighbor interface" commands. */
9528 install_element (BGP_NODE, &neighbor_interface_cmd);
9529 install_element (BGP_NODE, &no_neighbor_interface_cmd);
9530
9531 /* "neighbor distribute" commands. */
9532 install_element (BGP_NODE, &neighbor_distribute_list_cmd);
9533 install_element (BGP_NODE, &no_neighbor_distribute_list_cmd);
9534 install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd);
9535 install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd);
9536 install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd);
9537 install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd);
9538 install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd);
9539 install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009540 install_element (BGP_IPV6M_NODE, &neighbor_distribute_list_cmd);
9541 install_element (BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd);
paul718e3742002-12-13 20:15:29 +00009542 install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd);
9543 install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd);
9544
9545 /* "neighbor prefix-list" commands. */
9546 install_element (BGP_NODE, &neighbor_prefix_list_cmd);
9547 install_element (BGP_NODE, &no_neighbor_prefix_list_cmd);
9548 install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd);
9549 install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd);
9550 install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd);
9551 install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd);
9552 install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd);
9553 install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009554 install_element (BGP_IPV6M_NODE, &neighbor_prefix_list_cmd);
9555 install_element (BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd);
paul718e3742002-12-13 20:15:29 +00009556 install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd);
9557 install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd);
9558
9559 /* "neighbor filter-list" commands. */
9560 install_element (BGP_NODE, &neighbor_filter_list_cmd);
9561 install_element (BGP_NODE, &no_neighbor_filter_list_cmd);
9562 install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd);
9563 install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd);
9564 install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd);
9565 install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd);
9566 install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd);
9567 install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009568 install_element (BGP_IPV6M_NODE, &neighbor_filter_list_cmd);
9569 install_element (BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00009570 install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd);
9571 install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd);
9572
9573 /* "neighbor route-map" commands. */
9574 install_element (BGP_NODE, &neighbor_route_map_cmd);
9575 install_element (BGP_NODE, &no_neighbor_route_map_cmd);
9576 install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd);
9577 install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd);
9578 install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd);
9579 install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd);
9580 install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd);
9581 install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009582 install_element (BGP_IPV6M_NODE, &neighbor_route_map_cmd);
9583 install_element (BGP_IPV6M_NODE, &no_neighbor_route_map_cmd);
paul718e3742002-12-13 20:15:29 +00009584 install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd);
9585 install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd);
9586
9587 /* "neighbor unsuppress-map" commands. */
9588 install_element (BGP_NODE, &neighbor_unsuppress_map_cmd);
9589 install_element (BGP_NODE, &no_neighbor_unsuppress_map_cmd);
9590 install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd);
9591 install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd);
9592 install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd);
9593 install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd);
9594 install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd);
9595 install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009596 install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd);
9597 install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd);
paula58545b2003-07-12 21:43:01 +00009598 install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd);
9599 install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd);
paul718e3742002-12-13 20:15:29 +00009600
9601 /* "neighbor maximum-prefix" commands. */
9602 install_element (BGP_NODE, &neighbor_maximum_prefix_cmd);
hassoe0701b72004-05-20 09:19:34 +00009603 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_cmd);
paul718e3742002-12-13 20:15:29 +00009604 install_element (BGP_NODE, &neighbor_maximum_prefix_warning_cmd);
hassoe0701b72004-05-20 09:19:34 +00009605 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
hasso0a486e52005-02-01 20:57:17 +00009606 install_element (BGP_NODE, &neighbor_maximum_prefix_restart_cmd);
9607 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009608 install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd);
9609 install_element (BGP_NODE, &no_neighbor_maximum_prefix_val_cmd);
hasso0a486e52005-02-01 20:57:17 +00009610 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9611 install_element (BGP_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9612 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9613 install_element (BGP_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9614 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009615 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd);
hassoe0701b72004-05-20 09:19:34 +00009616 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
paul718e3742002-12-13 20:15:29 +00009617 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd);
hassoe0701b72004-05-20 09:19:34 +00009618 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
hasso0a486e52005-02-01 20:57:17 +00009619 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd);
9620 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009621 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd);
9622 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
hasso0a486e52005-02-01 20:57:17 +00009623 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9624 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9625 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9626 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9627 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009628 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd);
hassoe0701b72004-05-20 09:19:34 +00009629 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd);
paul718e3742002-12-13 20:15:29 +00009630 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd);
hassoe0701b72004-05-20 09:19:34 +00009631 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
hasso0a486e52005-02-01 20:57:17 +00009632 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd);
9633 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009634 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd);
9635 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_val_cmd);
hasso0a486e52005-02-01 20:57:17 +00009636 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9637 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9638 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9639 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9640 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009641 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd);
hassoe0701b72004-05-20 09:19:34 +00009642 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
paul718e3742002-12-13 20:15:29 +00009643 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd);
hassoe0701b72004-05-20 09:19:34 +00009644 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
hasso0a486e52005-02-01 20:57:17 +00009645 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd);
9646 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009647 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd);
9648 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_val_cmd);
hasso0a486e52005-02-01 20:57:17 +00009649 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9650 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9651 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9652 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9653 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009654 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd);
9655 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd);
9656 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd);
9657 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
9658 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd);
9659 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
9660 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd);
9661 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_val_cmd);
9662 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9663 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9664 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9665 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9666 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009667 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd);
hassoe0701b72004-05-20 09:19:34 +00009668 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
paul718e3742002-12-13 20:15:29 +00009669 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd);
hassoe0701b72004-05-20 09:19:34 +00009670 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
hasso0a486e52005-02-01 20:57:17 +00009671 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd);
9672 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009673 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd);
9674 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
hasso0a486e52005-02-01 20:57:17 +00009675 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9676 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9677 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9678 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9679 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009680
9681 /* "neighbor allowas-in" */
9682 install_element (BGP_NODE, &neighbor_allowas_in_cmd);
9683 install_element (BGP_NODE, &neighbor_allowas_in_arg_cmd);
9684 install_element (BGP_NODE, &no_neighbor_allowas_in_cmd);
9685 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd);
9686 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_arg_cmd);
9687 install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd);
9688 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd);
9689 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_arg_cmd);
9690 install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd);
9691 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd);
9692 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_arg_cmd);
9693 install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009694 install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd);
9695 install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_arg_cmd);
9696 install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd);
paul718e3742002-12-13 20:15:29 +00009697 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd);
9698 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_arg_cmd);
9699 install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd);
9700
9701 /* address-family commands. */
9702 install_element (BGP_NODE, &address_family_ipv4_cmd);
9703 install_element (BGP_NODE, &address_family_ipv4_safi_cmd);
9704#ifdef HAVE_IPV6
9705 install_element (BGP_NODE, &address_family_ipv6_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009706 install_element (BGP_NODE, &address_family_ipv6_safi_cmd);
paul718e3742002-12-13 20:15:29 +00009707#endif /* HAVE_IPV6 */
9708 install_element (BGP_NODE, &address_family_vpnv4_cmd);
9709 install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd);
9710
9711 /* "exit-address-family" command. */
9712 install_element (BGP_IPV4_NODE, &exit_address_family_cmd);
9713 install_element (BGP_IPV4M_NODE, &exit_address_family_cmd);
9714 install_element (BGP_IPV6_NODE, &exit_address_family_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009715 install_element (BGP_IPV6M_NODE, &exit_address_family_cmd);
paul718e3742002-12-13 20:15:29 +00009716 install_element (BGP_VPNV4_NODE, &exit_address_family_cmd);
9717
9718 /* "clear ip bgp commands" */
9719 install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd);
9720 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_cmd);
9721 install_element (ENABLE_NODE, &clear_ip_bgp_as_cmd);
9722 install_element (ENABLE_NODE, &clear_ip_bgp_peer_cmd);
9723 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_cmd);
9724 install_element (ENABLE_NODE, &clear_ip_bgp_external_cmd);
9725#ifdef HAVE_IPV6
9726 install_element (ENABLE_NODE, &clear_bgp_all_cmd);
9727 install_element (ENABLE_NODE, &clear_bgp_instance_all_cmd);
9728 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_cmd);
9729 install_element (ENABLE_NODE, &clear_bgp_peer_cmd);
9730 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_cmd);
9731 install_element (ENABLE_NODE, &clear_bgp_peer_group_cmd);
9732 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_cmd);
9733 install_element (ENABLE_NODE, &clear_bgp_external_cmd);
9734 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_cmd);
9735 install_element (ENABLE_NODE, &clear_bgp_as_cmd);
9736 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_cmd);
9737#endif /* HAVE_IPV6 */
9738
9739 /* "clear ip bgp neighbor soft in" */
9740 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_in_cmd);
9741 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_in_cmd);
9742 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_cmd);
9743 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_prefix_filter_cmd);
9744 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_in_prefix_filter_cmd);
9745 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_in_cmd);
9746 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_cmd);
9747 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_prefix_filter_cmd);
9748 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_in_cmd);
9749 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_cmd);
9750 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_prefix_filter_cmd);
9751 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_in_cmd);
9752 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_cmd);
9753 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_prefix_filter_cmd);
9754 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_in_cmd);
9755 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_cmd);
9756 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_prefix_filter_cmd);
9757 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_in_cmd);
9758 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_in_cmd);
9759 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_cmd);
9760 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_prefix_filter_cmd);
9761 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_in_prefix_filter_cmd);
9762 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_in_cmd);
9763 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_cmd);
9764 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd);
9765 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_in_cmd);
9766 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_cmd);
9767 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd);
9768 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_in_cmd);
9769 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_cmd);
9770 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_prefix_filter_cmd);
9771 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_in_cmd);
9772 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_cmd);
9773 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_prefix_filter_cmd);
9774 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_in_cmd);
9775 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_in_cmd);
9776 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_in_cmd);
9777 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_in_cmd);
9778 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_in_cmd);
9779 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_in_cmd);
9780#ifdef HAVE_IPV6
9781 install_element (ENABLE_NODE, &clear_bgp_all_soft_in_cmd);
9782 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_in_cmd);
9783 install_element (ENABLE_NODE, &clear_bgp_all_in_cmd);
9784 install_element (ENABLE_NODE, &clear_bgp_all_in_prefix_filter_cmd);
9785 install_element (ENABLE_NODE, &clear_bgp_peer_soft_in_cmd);
9786 install_element (ENABLE_NODE, &clear_bgp_peer_in_cmd);
9787 install_element (ENABLE_NODE, &clear_bgp_peer_in_prefix_filter_cmd);
9788 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_in_cmd);
9789 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_cmd);
9790 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_prefix_filter_cmd);
9791 install_element (ENABLE_NODE, &clear_bgp_external_soft_in_cmd);
9792 install_element (ENABLE_NODE, &clear_bgp_external_in_cmd);
9793 install_element (ENABLE_NODE, &clear_bgp_external_in_prefix_filter_cmd);
9794 install_element (ENABLE_NODE, &clear_bgp_as_soft_in_cmd);
9795 install_element (ENABLE_NODE, &clear_bgp_as_in_cmd);
9796 install_element (ENABLE_NODE, &clear_bgp_as_in_prefix_filter_cmd);
9797 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_in_cmd);
9798 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_cmd);
9799 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_prefix_filter_cmd);
9800 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_in_cmd);
9801 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_cmd);
9802 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_prefix_filter_cmd);
9803 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_in_cmd);
9804 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_cmd);
9805 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_prefix_filter_cmd);
9806 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_in_cmd);
9807 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_cmd);
9808 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_prefix_filter_cmd);
9809 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_in_cmd);
9810 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_cmd);
9811 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_prefix_filter_cmd);
9812#endif /* HAVE_IPV6 */
9813
9814 /* "clear ip bgp neighbor soft out" */
9815 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_out_cmd);
9816 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_out_cmd);
9817 install_element (ENABLE_NODE, &clear_ip_bgp_all_out_cmd);
9818 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_out_cmd);
9819 install_element (ENABLE_NODE, &clear_ip_bgp_peer_out_cmd);
9820 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_out_cmd);
9821 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_out_cmd);
9822 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_out_cmd);
9823 install_element (ENABLE_NODE, &clear_ip_bgp_external_out_cmd);
9824 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_out_cmd);
9825 install_element (ENABLE_NODE, &clear_ip_bgp_as_out_cmd);
9826 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_out_cmd);
9827 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_out_cmd);
9828 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_out_cmd);
9829 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_out_cmd);
9830 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_out_cmd);
9831 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_out_cmd);
9832 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_out_cmd);
9833 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_out_cmd);
9834 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_out_cmd);
9835 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_out_cmd);
9836 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_out_cmd);
9837 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_out_cmd);
9838 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_out_cmd);
9839 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_out_cmd);
9840 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_out_cmd);
9841 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_out_cmd);
9842 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_out_cmd);
9843#ifdef HAVE_IPV6
9844 install_element (ENABLE_NODE, &clear_bgp_all_soft_out_cmd);
9845 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_out_cmd);
9846 install_element (ENABLE_NODE, &clear_bgp_all_out_cmd);
9847 install_element (ENABLE_NODE, &clear_bgp_peer_soft_out_cmd);
9848 install_element (ENABLE_NODE, &clear_bgp_peer_out_cmd);
9849 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_out_cmd);
9850 install_element (ENABLE_NODE, &clear_bgp_peer_group_out_cmd);
9851 install_element (ENABLE_NODE, &clear_bgp_external_soft_out_cmd);
9852 install_element (ENABLE_NODE, &clear_bgp_external_out_cmd);
9853 install_element (ENABLE_NODE, &clear_bgp_as_soft_out_cmd);
9854 install_element (ENABLE_NODE, &clear_bgp_as_out_cmd);
9855 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_out_cmd);
9856 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_out_cmd);
9857 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_out_cmd);
9858 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_out_cmd);
9859 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_out_cmd);
9860 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_out_cmd);
9861 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_out_cmd);
9862 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_out_cmd);
9863 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_out_cmd);
9864 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_out_cmd);
9865#endif /* HAVE_IPV6 */
9866
9867 /* "clear ip bgp neighbor soft" */
9868 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_cmd);
9869 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_cmd);
9870 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_cmd);
9871 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_cmd);
9872 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_cmd);
9873 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_cmd);
9874 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_cmd);
9875 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_cmd);
9876 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_cmd);
9877 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_cmd);
9878 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_cmd);
9879 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_cmd);
9880 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_cmd);
9881 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_cmd);
9882 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_cmd);
9883#ifdef HAVE_IPV6
9884 install_element (ENABLE_NODE, &clear_bgp_all_soft_cmd);
9885 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_cmd);
9886 install_element (ENABLE_NODE, &clear_bgp_peer_soft_cmd);
9887 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_cmd);
9888 install_element (ENABLE_NODE, &clear_bgp_external_soft_cmd);
9889 install_element (ENABLE_NODE, &clear_bgp_as_soft_cmd);
9890 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_cmd);
9891 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_cmd);
9892 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_cmd);
9893 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_cmd);
9894 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_cmd);
9895#endif /* HAVE_IPV6 */
9896
paulfee0f4c2004-09-13 05:12:46 +00009897 /* "clear ip bgp neighbor rsclient" */
9898 install_element (ENABLE_NODE, &clear_ip_bgp_all_rsclient_cmd);
9899 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_rsclient_cmd);
9900 install_element (ENABLE_NODE, &clear_ip_bgp_peer_rsclient_cmd);
9901 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_rsclient_cmd);
9902#ifdef HAVE_IPV6
9903 install_element (ENABLE_NODE, &clear_bgp_all_rsclient_cmd);
9904 install_element (ENABLE_NODE, &clear_bgp_instance_all_rsclient_cmd);
9905 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_rsclient_cmd);
9906 install_element (ENABLE_NODE, &clear_bgp_ipv6_instance_all_rsclient_cmd);
9907 install_element (ENABLE_NODE, &clear_bgp_peer_rsclient_cmd);
9908 install_element (ENABLE_NODE, &clear_bgp_instance_peer_rsclient_cmd);
9909 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_rsclient_cmd);
9910 install_element (ENABLE_NODE, &clear_bgp_ipv6_instance_peer_rsclient_cmd);
9911#endif /* HAVE_IPV6 */
9912
paul718e3742002-12-13 20:15:29 +00009913 /* "show ip bgp summary" commands. */
9914 install_element (VIEW_NODE, &show_ip_bgp_summary_cmd);
9915 install_element (VIEW_NODE, &show_ip_bgp_instance_summary_cmd);
9916 install_element (VIEW_NODE, &show_ip_bgp_ipv4_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -04009917 install_element (VIEW_NODE, &show_bgp_ipv4_safi_summary_cmd);
paul718e3742002-12-13 20:15:29 +00009918 install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -04009919 install_element (VIEW_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
paul718e3742002-12-13 20:15:29 +00009920 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
9921 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
9922#ifdef HAVE_IPV6
9923 install_element (VIEW_NODE, &show_bgp_summary_cmd);
9924 install_element (VIEW_NODE, &show_bgp_instance_summary_cmd);
9925 install_element (VIEW_NODE, &show_bgp_ipv6_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -04009926 install_element (VIEW_NODE, &show_bgp_ipv6_safi_summary_cmd);
paul718e3742002-12-13 20:15:29 +00009927 install_element (VIEW_NODE, &show_bgp_instance_ipv6_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -04009928 install_element (VIEW_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
paul718e3742002-12-13 20:15:29 +00009929#endif /* HAVE_IPV6 */
Paul Jakma62687ff2008-08-23 14:27:06 +01009930 install_element (RESTRICTED_NODE, &show_ip_bgp_summary_cmd);
9931 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_summary_cmd);
9932 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -04009933 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_summary_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +01009934 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -04009935 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +01009936 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
9937 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
9938#ifdef HAVE_IPV6
9939 install_element (RESTRICTED_NODE, &show_bgp_summary_cmd);
9940 install_element (RESTRICTED_NODE, &show_bgp_instance_summary_cmd);
9941 install_element (RESTRICTED_NODE, &show_bgp_ipv6_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -04009942 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_summary_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +01009943 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -04009944 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +01009945#endif /* HAVE_IPV6 */
paul718e3742002-12-13 20:15:29 +00009946 install_element (ENABLE_NODE, &show_ip_bgp_summary_cmd);
9947 install_element (ENABLE_NODE, &show_ip_bgp_instance_summary_cmd);
9948 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -04009949 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_summary_cmd);
paul718e3742002-12-13 20:15:29 +00009950 install_element (ENABLE_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -04009951 install_element (ENABLE_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
paul718e3742002-12-13 20:15:29 +00009952 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
9953 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
9954#ifdef HAVE_IPV6
9955 install_element (ENABLE_NODE, &show_bgp_summary_cmd);
9956 install_element (ENABLE_NODE, &show_bgp_instance_summary_cmd);
9957 install_element (ENABLE_NODE, &show_bgp_ipv6_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -04009958 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_summary_cmd);
paul718e3742002-12-13 20:15:29 +00009959 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -04009960 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
paul718e3742002-12-13 20:15:29 +00009961#endif /* HAVE_IPV6 */
9962
9963 /* "show ip bgp neighbors" commands. */
9964 install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd);
9965 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
9966 install_element (VIEW_NODE, &show_ip_bgp_neighbors_peer_cmd);
9967 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
9968 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd);
9969 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd);
9970 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
9971 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
9972 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_cmd);
9973 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +01009974 install_element (RESTRICTED_NODE, &show_ip_bgp_neighbors_peer_cmd);
9975 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
9976 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
9977 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
9978 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
paul718e3742002-12-13 20:15:29 +00009979 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_cmd);
9980 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
9981 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_peer_cmd);
9982 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
9983 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd);
9984 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd);
9985 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
9986 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
9987 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_cmd);
9988 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
9989
9990#ifdef HAVE_IPV6
9991 install_element (VIEW_NODE, &show_bgp_neighbors_cmd);
9992 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_cmd);
9993 install_element (VIEW_NODE, &show_bgp_neighbors_peer_cmd);
9994 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
paulbb46e942003-10-24 19:02:03 +00009995 install_element (VIEW_NODE, &show_bgp_instance_neighbors_cmd);
9996 install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
9997 install_element (VIEW_NODE, &show_bgp_instance_neighbors_peer_cmd);
9998 install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +01009999 install_element (RESTRICTED_NODE, &show_bgp_neighbors_peer_cmd);
10000 install_element (RESTRICTED_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
10001 install_element (RESTRICTED_NODE, &show_bgp_instance_neighbors_peer_cmd);
10002 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
paul718e3742002-12-13 20:15:29 +000010003 install_element (ENABLE_NODE, &show_bgp_neighbors_cmd);
10004 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_cmd);
10005 install_element (ENABLE_NODE, &show_bgp_neighbors_peer_cmd);
10006 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
paulbb46e942003-10-24 19:02:03 +000010007 install_element (ENABLE_NODE, &show_bgp_instance_neighbors_cmd);
10008 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
10009 install_element (ENABLE_NODE, &show_bgp_instance_neighbors_peer_cmd);
10010 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
paul718e3742002-12-13 20:15:29 +000010011
10012 /* Old commands. */
10013 install_element (VIEW_NODE, &show_ipv6_bgp_summary_cmd);
10014 install_element (VIEW_NODE, &show_ipv6_mbgp_summary_cmd);
10015 install_element (ENABLE_NODE, &show_ipv6_bgp_summary_cmd);
10016 install_element (ENABLE_NODE, &show_ipv6_mbgp_summary_cmd);
10017#endif /* HAVE_IPV6 */
10018
paulfee0f4c2004-09-13 05:12:46 +000010019 /* "show ip bgp rsclient" commands. */
10020 install_element (VIEW_NODE, &show_ip_bgp_rsclient_summary_cmd);
10021 install_element (VIEW_NODE, &show_ip_bgp_instance_rsclient_summary_cmd);
10022 install_element (VIEW_NODE, &show_ip_bgp_ipv4_rsclient_summary_cmd);
10023 install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_rsclient_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010024 install_element (VIEW_NODE, &show_bgp_instance_ipv4_safi_rsclient_summary_cmd);
10025 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_summary_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010010026 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_summary_cmd);
10027 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_rsclient_summary_cmd);
10028 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_rsclient_summary_cmd);
10029 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_ipv4_rsclient_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010030 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv4_safi_rsclient_summary_cmd);
10031 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_summary_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010032 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_summary_cmd);
10033 install_element (ENABLE_NODE, &show_ip_bgp_instance_rsclient_summary_cmd);
10034 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_rsclient_summary_cmd);
10035 install_element (ENABLE_NODE, &show_ip_bgp_instance_ipv4_rsclient_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010036 install_element (ENABLE_NODE, &show_bgp_instance_ipv4_safi_rsclient_summary_cmd);
10037 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_summary_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010038
10039#ifdef HAVE_IPV6
10040 install_element (VIEW_NODE, &show_bgp_rsclient_summary_cmd);
10041 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_summary_cmd);
10042 install_element (VIEW_NODE, &show_bgp_instance_rsclient_summary_cmd);
10043 install_element (VIEW_NODE, &show_bgp_instance_ipv6_rsclient_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010044 install_element (VIEW_NODE, &show_bgp_instance_ipv6_safi_rsclient_summary_cmd);
10045 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_summary_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010010046 install_element (RESTRICTED_NODE, &show_bgp_rsclient_summary_cmd);
10047 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_summary_cmd);
10048 install_element (RESTRICTED_NODE, &show_bgp_instance_rsclient_summary_cmd);
10049 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_rsclient_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010050 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_safi_rsclient_summary_cmd);
10051 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_summary_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010052 install_element (ENABLE_NODE, &show_bgp_rsclient_summary_cmd);
10053 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_summary_cmd);
10054 install_element (ENABLE_NODE, &show_bgp_instance_rsclient_summary_cmd);
10055 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_rsclient_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010056 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_safi_rsclient_summary_cmd);
10057 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_summary_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010058#endif /* HAVE_IPV6 */
10059
paul718e3742002-12-13 20:15:29 +000010060 /* "show ip bgp paths" commands. */
10061 install_element (VIEW_NODE, &show_ip_bgp_paths_cmd);
10062 install_element (VIEW_NODE, &show_ip_bgp_ipv4_paths_cmd);
10063 install_element (ENABLE_NODE, &show_ip_bgp_paths_cmd);
10064 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_paths_cmd);
10065
10066 /* "show ip bgp community" commands. */
10067 install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd);
10068 install_element (ENABLE_NODE, &show_ip_bgp_community_info_cmd);
10069
10070 /* "show ip bgp attribute-info" commands. */
10071 install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd);
10072 install_element (ENABLE_NODE, &show_ip_bgp_attr_info_cmd);
10073
10074 /* "redistribute" commands. */
10075 install_element (BGP_NODE, &bgp_redistribute_ipv4_cmd);
10076 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_cmd);
10077 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_cmd);
10078 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_cmd);
10079 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_cmd);
10080 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_cmd);
10081 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd);
10082 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd);
10083 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_metric_cmd);
10084 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_rmap_cmd);
10085#ifdef HAVE_IPV6
10086 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd);
10087 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd);
10088 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd);
10089 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_cmd);
10090 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd);
10091 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_cmd);
10092 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd);
10093 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd);
10094 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_metric_cmd);
10095 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_rmap_cmd);
10096#endif /* HAVE_IPV6 */
10097
Nick Hilliardfa411a22011-03-23 15:33:17 +000010098 /* ttl_security commands */
10099 install_element (BGP_NODE, &neighbor_ttl_security_cmd);
10100 install_element (BGP_NODE, &no_neighbor_ttl_security_cmd);
10101
Paul Jakma4bf6a362006-03-30 14:05:23 +000010102 /* "show bgp memory" commands. */
10103 install_element (VIEW_NODE, &show_bgp_memory_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010010104 install_element (RESTRICTED_NODE, &show_bgp_memory_cmd);
Paul Jakma4bf6a362006-03-30 14:05:23 +000010105 install_element (ENABLE_NODE, &show_bgp_memory_cmd);
10106
Michael Lamberte0081f72008-11-16 20:12:04 +000010107 /* "show bgp views" commands. */
10108 install_element (VIEW_NODE, &show_bgp_views_cmd);
10109 install_element (RESTRICTED_NODE, &show_bgp_views_cmd);
10110 install_element (ENABLE_NODE, &show_bgp_views_cmd);
10111
paul718e3742002-12-13 20:15:29 +000010112 /* Community-list. */
10113 community_list_vty ();
10114}
10115
10116#include "memory.h"
10117#include "bgp_regex.h"
10118#include "bgp_clist.h"
10119#include "bgp_ecommunity.h"
10120
10121/* VTY functions. */
10122
10123/* Direction value to string conversion. */
paul94f2b392005-06-28 12:44:16 +000010124static const char *
paul718e3742002-12-13 20:15:29 +000010125community_direct_str (int direct)
10126{
10127 switch (direct)
10128 {
10129 case COMMUNITY_DENY:
10130 return "deny";
paul718e3742002-12-13 20:15:29 +000010131 case COMMUNITY_PERMIT:
10132 return "permit";
paul718e3742002-12-13 20:15:29 +000010133 default:
10134 return "unknown";
paul718e3742002-12-13 20:15:29 +000010135 }
10136}
10137
10138/* Display error string. */
paul94f2b392005-06-28 12:44:16 +000010139static void
paul718e3742002-12-13 20:15:29 +000010140community_list_perror (struct vty *vty, int ret)
10141{
10142 switch (ret)
10143 {
10144 case COMMUNITY_LIST_ERR_CANT_FIND_LIST:
Denis Ovsienkob7292942010-12-08 18:51:37 +030010145 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000010146 break;
10147 case COMMUNITY_LIST_ERR_MALFORMED_VAL:
10148 vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE);
10149 break;
10150 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT:
10151 vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE);
10152 break;
10153 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT:
10154 vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE);
10155 break;
10156 }
10157}
10158
10159/* VTY interface for community_set() function. */
paul94f2b392005-06-28 12:44:16 +000010160static int
paulfd79ac92004-10-13 05:06:08 +000010161community_list_set_vty (struct vty *vty, int argc, const char **argv,
10162 int style, int reject_all_digit_name)
paul718e3742002-12-13 20:15:29 +000010163{
10164 int ret;
10165 int direct;
10166 char *str;
10167
10168 /* Check the list type. */
10169 if (strncmp (argv[1], "p", 1) == 0)
10170 direct = COMMUNITY_PERMIT;
10171 else if (strncmp (argv[1], "d", 1) == 0)
10172 direct = COMMUNITY_DENY;
10173 else
10174 {
10175 vty_out (vty, "%% Matching condition must be permit or deny%s",
10176 VTY_NEWLINE);
10177 return CMD_WARNING;
10178 }
10179
10180 /* All digit name check. */
10181 if (reject_all_digit_name && all_digit (argv[0]))
10182 {
10183 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
10184 return CMD_WARNING;
10185 }
10186
10187 /* Concat community string argument. */
10188 if (argc > 1)
10189 str = argv_concat (argv, argc, 2);
10190 else
10191 str = NULL;
10192
10193 /* When community_list_set() return nevetive value, it means
10194 malformed community string. */
10195 ret = community_list_set (bgp_clist, argv[0], str, direct, style);
10196
10197 /* Free temporary community list string allocated by
10198 argv_concat(). */
10199 if (str)
10200 XFREE (MTYPE_TMP, str);
10201
10202 if (ret < 0)
10203 {
10204 /* Display error string. */
10205 community_list_perror (vty, ret);
10206 return CMD_WARNING;
10207 }
10208
10209 return CMD_SUCCESS;
10210}
10211
paul718e3742002-12-13 20:15:29 +000010212/* Communiyt-list entry delete. */
paul94f2b392005-06-28 12:44:16 +000010213static int
hassofee6e4e2005-02-02 16:29:31 +000010214community_list_unset_vty (struct vty *vty, int argc, const char **argv,
10215 int style)
paul718e3742002-12-13 20:15:29 +000010216{
10217 int ret;
hassofee6e4e2005-02-02 16:29:31 +000010218 int direct = 0;
10219 char *str = NULL;
paul718e3742002-12-13 20:15:29 +000010220
hassofee6e4e2005-02-02 16:29:31 +000010221 if (argc > 1)
paul718e3742002-12-13 20:15:29 +000010222 {
hassofee6e4e2005-02-02 16:29:31 +000010223 /* Check the list direct. */
10224 if (strncmp (argv[1], "p", 1) == 0)
10225 direct = COMMUNITY_PERMIT;
10226 else if (strncmp (argv[1], "d", 1) == 0)
10227 direct = COMMUNITY_DENY;
10228 else
10229 {
10230 vty_out (vty, "%% Matching condition must be permit or deny%s",
10231 VTY_NEWLINE);
10232 return CMD_WARNING;
10233 }
paul718e3742002-12-13 20:15:29 +000010234
hassofee6e4e2005-02-02 16:29:31 +000010235 /* Concat community string argument. */
10236 str = argv_concat (argv, argc, 2);
10237 }
paul718e3742002-12-13 20:15:29 +000010238
10239 /* Unset community list. */
10240 ret = community_list_unset (bgp_clist, argv[0], str, direct, style);
10241
10242 /* Free temporary community list string allocated by
10243 argv_concat(). */
hassofee6e4e2005-02-02 16:29:31 +000010244 if (str)
10245 XFREE (MTYPE_TMP, str);
paul718e3742002-12-13 20:15:29 +000010246
10247 if (ret < 0)
10248 {
10249 community_list_perror (vty, ret);
10250 return CMD_WARNING;
10251 }
10252
10253 return CMD_SUCCESS;
10254}
10255
10256/* "community-list" keyword help string. */
10257#define COMMUNITY_LIST_STR "Add a community list entry\n"
10258#define COMMUNITY_VAL_STR "Community number in aa:nn format or internet|local-AS|no-advertise|no-export\n"
10259
paul718e3742002-12-13 20:15:29 +000010260DEFUN (ip_community_list_standard,
10261 ip_community_list_standard_cmd,
10262 "ip community-list <1-99> (deny|permit) .AA:NN",
10263 IP_STR
10264 COMMUNITY_LIST_STR
10265 "Community list number (standard)\n"
10266 "Specify community to reject\n"
10267 "Specify community to accept\n"
10268 COMMUNITY_VAL_STR)
10269{
10270 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
10271}
10272
10273ALIAS (ip_community_list_standard,
10274 ip_community_list_standard2_cmd,
10275 "ip community-list <1-99> (deny|permit)",
10276 IP_STR
10277 COMMUNITY_LIST_STR
10278 "Community list number (standard)\n"
10279 "Specify community to reject\n"
10280 "Specify community to accept\n")
10281
10282DEFUN (ip_community_list_expanded,
10283 ip_community_list_expanded_cmd,
hassofee6e4e2005-02-02 16:29:31 +000010284 "ip community-list <100-500> (deny|permit) .LINE",
paul718e3742002-12-13 20:15:29 +000010285 IP_STR
10286 COMMUNITY_LIST_STR
10287 "Community list number (expanded)\n"
10288 "Specify community to reject\n"
10289 "Specify community to accept\n"
10290 "An ordered list as a regular-expression\n")
10291{
10292 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
10293}
10294
10295DEFUN (ip_community_list_name_standard,
10296 ip_community_list_name_standard_cmd,
10297 "ip community-list standard WORD (deny|permit) .AA:NN",
10298 IP_STR
10299 COMMUNITY_LIST_STR
10300 "Add a standard community-list entry\n"
10301 "Community list name\n"
10302 "Specify community to reject\n"
10303 "Specify community to accept\n"
10304 COMMUNITY_VAL_STR)
10305{
10306 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
10307}
10308
10309ALIAS (ip_community_list_name_standard,
10310 ip_community_list_name_standard2_cmd,
10311 "ip community-list standard WORD (deny|permit)",
10312 IP_STR
10313 COMMUNITY_LIST_STR
10314 "Add a standard community-list entry\n"
10315 "Community list name\n"
10316 "Specify community to reject\n"
10317 "Specify community to accept\n")
10318
10319DEFUN (ip_community_list_name_expanded,
10320 ip_community_list_name_expanded_cmd,
10321 "ip community-list expanded WORD (deny|permit) .LINE",
10322 IP_STR
10323 COMMUNITY_LIST_STR
10324 "Add an expanded community-list entry\n"
10325 "Community list name\n"
10326 "Specify community to reject\n"
10327 "Specify community to accept\n"
10328 "An ordered list as a regular-expression\n")
10329{
10330 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
10331}
10332
hassofee6e4e2005-02-02 16:29:31 +000010333DEFUN (no_ip_community_list_standard_all,
10334 no_ip_community_list_standard_all_cmd,
10335 "no ip community-list <1-99>",
paul718e3742002-12-13 20:15:29 +000010336 NO_STR
10337 IP_STR
10338 COMMUNITY_LIST_STR
hassofee6e4e2005-02-02 16:29:31 +000010339 "Community list number (standard)\n")
paul718e3742002-12-13 20:15:29 +000010340{
hassofee6e4e2005-02-02 16:29:31 +000010341 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
paul718e3742002-12-13 20:15:29 +000010342}
10343
hassofee6e4e2005-02-02 16:29:31 +000010344DEFUN (no_ip_community_list_expanded_all,
10345 no_ip_community_list_expanded_all_cmd,
10346 "no ip community-list <100-500>",
10347 NO_STR
10348 IP_STR
10349 COMMUNITY_LIST_STR
10350 "Community list number (expanded)\n")
10351{
10352 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
10353}
10354
10355DEFUN (no_ip_community_list_name_standard_all,
10356 no_ip_community_list_name_standard_all_cmd,
10357 "no ip community-list standard WORD",
paul718e3742002-12-13 20:15:29 +000010358 NO_STR
10359 IP_STR
10360 COMMUNITY_LIST_STR
10361 "Add a standard community-list entry\n"
paul718e3742002-12-13 20:15:29 +000010362 "Community list name\n")
10363{
hassofee6e4e2005-02-02 16:29:31 +000010364 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
paul718e3742002-12-13 20:15:29 +000010365}
10366
hassofee6e4e2005-02-02 16:29:31 +000010367DEFUN (no_ip_community_list_name_expanded_all,
10368 no_ip_community_list_name_expanded_all_cmd,
10369 "no ip community-list expanded WORD",
paul718e3742002-12-13 20:15:29 +000010370 NO_STR
10371 IP_STR
10372 COMMUNITY_LIST_STR
hassofee6e4e2005-02-02 16:29:31 +000010373 "Add an expanded community-list entry\n"
10374 "Community list name\n")
paul718e3742002-12-13 20:15:29 +000010375{
hassofee6e4e2005-02-02 16:29:31 +000010376 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
paul718e3742002-12-13 20:15:29 +000010377}
10378
10379DEFUN (no_ip_community_list_standard,
10380 no_ip_community_list_standard_cmd,
10381 "no ip community-list <1-99> (deny|permit) .AA:NN",
10382 NO_STR
10383 IP_STR
10384 COMMUNITY_LIST_STR
10385 "Community list number (standard)\n"
10386 "Specify community to reject\n"
10387 "Specify community to accept\n"
10388 COMMUNITY_VAL_STR)
10389{
10390 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
10391}
10392
10393DEFUN (no_ip_community_list_expanded,
10394 no_ip_community_list_expanded_cmd,
hassofee6e4e2005-02-02 16:29:31 +000010395 "no ip community-list <100-500> (deny|permit) .LINE",
paul718e3742002-12-13 20:15:29 +000010396 NO_STR
10397 IP_STR
10398 COMMUNITY_LIST_STR
10399 "Community list number (expanded)\n"
10400 "Specify community to reject\n"
10401 "Specify community to accept\n"
10402 "An ordered list as a regular-expression\n")
10403{
10404 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
10405}
10406
10407DEFUN (no_ip_community_list_name_standard,
10408 no_ip_community_list_name_standard_cmd,
10409 "no ip community-list standard WORD (deny|permit) .AA:NN",
10410 NO_STR
10411 IP_STR
10412 COMMUNITY_LIST_STR
10413 "Specify a standard community-list\n"
10414 "Community list name\n"
10415 "Specify community to reject\n"
10416 "Specify community to accept\n"
10417 COMMUNITY_VAL_STR)
10418{
10419 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
10420}
10421
10422DEFUN (no_ip_community_list_name_expanded,
10423 no_ip_community_list_name_expanded_cmd,
10424 "no ip community-list expanded WORD (deny|permit) .LINE",
10425 NO_STR
10426 IP_STR
10427 COMMUNITY_LIST_STR
10428 "Specify an expanded community-list\n"
10429 "Community list name\n"
10430 "Specify community to reject\n"
10431 "Specify community to accept\n"
10432 "An ordered list as a regular-expression\n")
10433{
10434 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
10435}
10436
paul94f2b392005-06-28 12:44:16 +000010437static void
paul718e3742002-12-13 20:15:29 +000010438community_list_show (struct vty *vty, struct community_list *list)
10439{
10440 struct community_entry *entry;
10441
10442 for (entry = list->head; entry; entry = entry->next)
10443 {
10444 if (entry == list->head)
10445 {
10446 if (all_digit (list->name))
10447 vty_out (vty, "Community %s list %s%s",
10448 entry->style == COMMUNITY_LIST_STANDARD ?
10449 "standard" : "(expanded) access",
10450 list->name, VTY_NEWLINE);
10451 else
10452 vty_out (vty, "Named Community %s list %s%s",
10453 entry->style == COMMUNITY_LIST_STANDARD ?
10454 "standard" : "expanded",
10455 list->name, VTY_NEWLINE);
10456 }
10457 if (entry->any)
10458 vty_out (vty, " %s%s",
10459 community_direct_str (entry->direct), VTY_NEWLINE);
10460 else
10461 vty_out (vty, " %s %s%s",
10462 community_direct_str (entry->direct),
10463 entry->style == COMMUNITY_LIST_STANDARD
10464 ? community_str (entry->u.com) : entry->config,
10465 VTY_NEWLINE);
10466 }
10467}
10468
10469DEFUN (show_ip_community_list,
10470 show_ip_community_list_cmd,
10471 "show ip community-list",
10472 SHOW_STR
10473 IP_STR
10474 "List community-list\n")
10475{
10476 struct community_list *list;
10477 struct community_list_master *cm;
10478
hassofee6e4e2005-02-02 16:29:31 +000010479 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010480 if (! cm)
10481 return CMD_SUCCESS;
10482
10483 for (list = cm->num.head; list; list = list->next)
10484 community_list_show (vty, list);
10485
10486 for (list = cm->str.head; list; list = list->next)
10487 community_list_show (vty, list);
10488
10489 return CMD_SUCCESS;
10490}
10491
10492DEFUN (show_ip_community_list_arg,
10493 show_ip_community_list_arg_cmd,
hassofee6e4e2005-02-02 16:29:31 +000010494 "show ip community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000010495 SHOW_STR
10496 IP_STR
10497 "List community-list\n"
10498 "Community-list number\n"
10499 "Community-list name\n")
10500{
10501 struct community_list *list;
10502
hassofee6e4e2005-02-02 16:29:31 +000010503 list = community_list_lookup (bgp_clist, argv[0], COMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010504 if (! list)
10505 {
Denis Ovsienkob7292942010-12-08 18:51:37 +030010506 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000010507 return CMD_WARNING;
10508 }
10509
10510 community_list_show (vty, list);
10511
10512 return CMD_SUCCESS;
10513}
10514
paul94f2b392005-06-28 12:44:16 +000010515static int
paulfd79ac92004-10-13 05:06:08 +000010516extcommunity_list_set_vty (struct vty *vty, int argc, const char **argv,
10517 int style, int reject_all_digit_name)
paul718e3742002-12-13 20:15:29 +000010518{
10519 int ret;
10520 int direct;
10521 char *str;
10522
10523 /* Check the list type. */
10524 if (strncmp (argv[1], "p", 1) == 0)
10525 direct = COMMUNITY_PERMIT;
10526 else if (strncmp (argv[1], "d", 1) == 0)
10527 direct = COMMUNITY_DENY;
10528 else
10529 {
10530 vty_out (vty, "%% Matching condition must be permit or deny%s",
10531 VTY_NEWLINE);
10532 return CMD_WARNING;
10533 }
10534
10535 /* All digit name check. */
10536 if (reject_all_digit_name && all_digit (argv[0]))
10537 {
10538 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
10539 return CMD_WARNING;
10540 }
10541
10542 /* Concat community string argument. */
10543 if (argc > 1)
10544 str = argv_concat (argv, argc, 2);
10545 else
10546 str = NULL;
10547
10548 ret = extcommunity_list_set (bgp_clist, argv[0], str, direct, style);
10549
10550 /* Free temporary community list string allocated by
10551 argv_concat(). */
10552 if (str)
10553 XFREE (MTYPE_TMP, str);
10554
10555 if (ret < 0)
10556 {
10557 community_list_perror (vty, ret);
10558 return CMD_WARNING;
10559 }
10560 return CMD_SUCCESS;
10561}
10562
paul94f2b392005-06-28 12:44:16 +000010563static int
hassofee6e4e2005-02-02 16:29:31 +000010564extcommunity_list_unset_vty (struct vty *vty, int argc, const char **argv,
10565 int style)
paul718e3742002-12-13 20:15:29 +000010566{
10567 int ret;
hassofee6e4e2005-02-02 16:29:31 +000010568 int direct = 0;
10569 char *str = NULL;
paul718e3742002-12-13 20:15:29 +000010570
hassofee6e4e2005-02-02 16:29:31 +000010571 if (argc > 1)
paul718e3742002-12-13 20:15:29 +000010572 {
hassofee6e4e2005-02-02 16:29:31 +000010573 /* Check the list direct. */
10574 if (strncmp (argv[1], "p", 1) == 0)
10575 direct = COMMUNITY_PERMIT;
10576 else if (strncmp (argv[1], "d", 1) == 0)
10577 direct = COMMUNITY_DENY;
10578 else
10579 {
10580 vty_out (vty, "%% Matching condition must be permit or deny%s",
10581 VTY_NEWLINE);
10582 return CMD_WARNING;
10583 }
10584
10585 /* Concat community string argument. */
10586 str = argv_concat (argv, argc, 2);
paul718e3742002-12-13 20:15:29 +000010587 }
paul718e3742002-12-13 20:15:29 +000010588
10589 /* Unset community list. */
10590 ret = extcommunity_list_unset (bgp_clist, argv[0], str, direct, style);
10591
10592 /* Free temporary community list string allocated by
10593 argv_concat(). */
hassofee6e4e2005-02-02 16:29:31 +000010594 if (str)
10595 XFREE (MTYPE_TMP, str);
paul718e3742002-12-13 20:15:29 +000010596
10597 if (ret < 0)
10598 {
10599 community_list_perror (vty, ret);
10600 return CMD_WARNING;
10601 }
10602
10603 return CMD_SUCCESS;
10604}
10605
10606/* "extcommunity-list" keyword help string. */
10607#define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
10608#define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
10609
10610DEFUN (ip_extcommunity_list_standard,
10611 ip_extcommunity_list_standard_cmd,
10612 "ip extcommunity-list <1-99> (deny|permit) .AA:NN",
10613 IP_STR
10614 EXTCOMMUNITY_LIST_STR
10615 "Extended Community list number (standard)\n"
10616 "Specify community to reject\n"
10617 "Specify community to accept\n"
10618 EXTCOMMUNITY_VAL_STR)
10619{
10620 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
10621}
10622
10623ALIAS (ip_extcommunity_list_standard,
10624 ip_extcommunity_list_standard2_cmd,
10625 "ip extcommunity-list <1-99> (deny|permit)",
10626 IP_STR
10627 EXTCOMMUNITY_LIST_STR
10628 "Extended Community list number (standard)\n"
10629 "Specify community to reject\n"
10630 "Specify community to accept\n")
10631
10632DEFUN (ip_extcommunity_list_expanded,
10633 ip_extcommunity_list_expanded_cmd,
hassofee6e4e2005-02-02 16:29:31 +000010634 "ip extcommunity-list <100-500> (deny|permit) .LINE",
paul718e3742002-12-13 20:15:29 +000010635 IP_STR
10636 EXTCOMMUNITY_LIST_STR
10637 "Extended Community list number (expanded)\n"
10638 "Specify community to reject\n"
10639 "Specify community to accept\n"
10640 "An ordered list as a regular-expression\n")
10641{
10642 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
10643}
10644
10645DEFUN (ip_extcommunity_list_name_standard,
10646 ip_extcommunity_list_name_standard_cmd,
10647 "ip extcommunity-list standard WORD (deny|permit) .AA:NN",
10648 IP_STR
10649 EXTCOMMUNITY_LIST_STR
10650 "Specify standard extcommunity-list\n"
10651 "Extended Community list name\n"
10652 "Specify community to reject\n"
10653 "Specify community to accept\n"
10654 EXTCOMMUNITY_VAL_STR)
10655{
10656 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
10657}
10658
10659ALIAS (ip_extcommunity_list_name_standard,
10660 ip_extcommunity_list_name_standard2_cmd,
10661 "ip extcommunity-list standard WORD (deny|permit)",
10662 IP_STR
10663 EXTCOMMUNITY_LIST_STR
10664 "Specify standard extcommunity-list\n"
10665 "Extended Community list name\n"
10666 "Specify community to reject\n"
10667 "Specify community to accept\n")
10668
10669DEFUN (ip_extcommunity_list_name_expanded,
10670 ip_extcommunity_list_name_expanded_cmd,
10671 "ip extcommunity-list expanded WORD (deny|permit) .LINE",
10672 IP_STR
10673 EXTCOMMUNITY_LIST_STR
10674 "Specify expanded extcommunity-list\n"
10675 "Extended Community list name\n"
10676 "Specify community to reject\n"
10677 "Specify community to accept\n"
10678 "An ordered list as a regular-expression\n")
10679{
10680 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
10681}
10682
hassofee6e4e2005-02-02 16:29:31 +000010683DEFUN (no_ip_extcommunity_list_standard_all,
10684 no_ip_extcommunity_list_standard_all_cmd,
10685 "no ip extcommunity-list <1-99>",
paul718e3742002-12-13 20:15:29 +000010686 NO_STR
10687 IP_STR
10688 EXTCOMMUNITY_LIST_STR
hassofee6e4e2005-02-02 16:29:31 +000010689 "Extended Community list number (standard)\n")
paul718e3742002-12-13 20:15:29 +000010690{
hassofee6e4e2005-02-02 16:29:31 +000010691 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
paul718e3742002-12-13 20:15:29 +000010692}
10693
hassofee6e4e2005-02-02 16:29:31 +000010694DEFUN (no_ip_extcommunity_list_expanded_all,
10695 no_ip_extcommunity_list_expanded_all_cmd,
10696 "no ip extcommunity-list <100-500>",
10697 NO_STR
10698 IP_STR
10699 EXTCOMMUNITY_LIST_STR
10700 "Extended Community list number (expanded)\n")
10701{
10702 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
10703}
10704
10705DEFUN (no_ip_extcommunity_list_name_standard_all,
10706 no_ip_extcommunity_list_name_standard_all_cmd,
10707 "no ip extcommunity-list standard WORD",
paul718e3742002-12-13 20:15:29 +000010708 NO_STR
10709 IP_STR
10710 EXTCOMMUNITY_LIST_STR
10711 "Specify standard extcommunity-list\n"
hassofee6e4e2005-02-02 16:29:31 +000010712 "Extended Community list name\n")
10713{
10714 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
10715}
10716
10717DEFUN (no_ip_extcommunity_list_name_expanded_all,
10718 no_ip_extcommunity_list_name_expanded_all_cmd,
10719 "no ip extcommunity-list expanded WORD",
10720 NO_STR
10721 IP_STR
10722 EXTCOMMUNITY_LIST_STR
paul718e3742002-12-13 20:15:29 +000010723 "Specify expanded extcommunity-list\n"
10724 "Extended Community list name\n")
10725{
hassofee6e4e2005-02-02 16:29:31 +000010726 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
paul718e3742002-12-13 20:15:29 +000010727}
10728
10729DEFUN (no_ip_extcommunity_list_standard,
10730 no_ip_extcommunity_list_standard_cmd,
10731 "no ip extcommunity-list <1-99> (deny|permit) .AA:NN",
10732 NO_STR
10733 IP_STR
10734 EXTCOMMUNITY_LIST_STR
10735 "Extended Community list number (standard)\n"
10736 "Specify community to reject\n"
10737 "Specify community to accept\n"
10738 EXTCOMMUNITY_VAL_STR)
10739{
10740 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
10741}
10742
10743DEFUN (no_ip_extcommunity_list_expanded,
10744 no_ip_extcommunity_list_expanded_cmd,
hassofee6e4e2005-02-02 16:29:31 +000010745 "no ip extcommunity-list <100-500> (deny|permit) .LINE",
paul718e3742002-12-13 20:15:29 +000010746 NO_STR
10747 IP_STR
10748 EXTCOMMUNITY_LIST_STR
10749 "Extended Community list number (expanded)\n"
10750 "Specify community to reject\n"
10751 "Specify community to accept\n"
10752 "An ordered list as a regular-expression\n")
10753{
10754 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
10755}
10756
10757DEFUN (no_ip_extcommunity_list_name_standard,
10758 no_ip_extcommunity_list_name_standard_cmd,
10759 "no ip extcommunity-list standard WORD (deny|permit) .AA:NN",
10760 NO_STR
10761 IP_STR
10762 EXTCOMMUNITY_LIST_STR
10763 "Specify standard extcommunity-list\n"
10764 "Extended Community list name\n"
10765 "Specify community to reject\n"
10766 "Specify community to accept\n"
10767 EXTCOMMUNITY_VAL_STR)
10768{
10769 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
10770}
10771
10772DEFUN (no_ip_extcommunity_list_name_expanded,
10773 no_ip_extcommunity_list_name_expanded_cmd,
10774 "no ip extcommunity-list expanded WORD (deny|permit) .LINE",
10775 NO_STR
10776 IP_STR
10777 EXTCOMMUNITY_LIST_STR
10778 "Specify expanded extcommunity-list\n"
10779 "Community list name\n"
10780 "Specify community to reject\n"
10781 "Specify community to accept\n"
10782 "An ordered list as a regular-expression\n")
10783{
10784 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
10785}
10786
paul94f2b392005-06-28 12:44:16 +000010787static void
paul718e3742002-12-13 20:15:29 +000010788extcommunity_list_show (struct vty *vty, struct community_list *list)
10789{
10790 struct community_entry *entry;
10791
10792 for (entry = list->head; entry; entry = entry->next)
10793 {
10794 if (entry == list->head)
10795 {
10796 if (all_digit (list->name))
10797 vty_out (vty, "Extended community %s list %s%s",
10798 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
10799 "standard" : "(expanded) access",
10800 list->name, VTY_NEWLINE);
10801 else
10802 vty_out (vty, "Named extended community %s list %s%s",
10803 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
10804 "standard" : "expanded",
10805 list->name, VTY_NEWLINE);
10806 }
10807 if (entry->any)
10808 vty_out (vty, " %s%s",
10809 community_direct_str (entry->direct), VTY_NEWLINE);
10810 else
10811 vty_out (vty, " %s %s%s",
10812 community_direct_str (entry->direct),
10813 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
10814 entry->u.ecom->str : entry->config,
10815 VTY_NEWLINE);
10816 }
10817}
10818
10819DEFUN (show_ip_extcommunity_list,
10820 show_ip_extcommunity_list_cmd,
10821 "show ip extcommunity-list",
10822 SHOW_STR
10823 IP_STR
10824 "List extended-community list\n")
10825{
10826 struct community_list *list;
10827 struct community_list_master *cm;
10828
hassofee6e4e2005-02-02 16:29:31 +000010829 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010830 if (! cm)
10831 return CMD_SUCCESS;
10832
10833 for (list = cm->num.head; list; list = list->next)
10834 extcommunity_list_show (vty, list);
10835
10836 for (list = cm->str.head; list; list = list->next)
10837 extcommunity_list_show (vty, list);
10838
10839 return CMD_SUCCESS;
10840}
10841
10842DEFUN (show_ip_extcommunity_list_arg,
10843 show_ip_extcommunity_list_arg_cmd,
hassofee6e4e2005-02-02 16:29:31 +000010844 "show ip extcommunity-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000010845 SHOW_STR
10846 IP_STR
10847 "List extended-community list\n"
10848 "Extcommunity-list number\n"
10849 "Extcommunity-list name\n")
10850{
10851 struct community_list *list;
10852
hassofee6e4e2005-02-02 16:29:31 +000010853 list = community_list_lookup (bgp_clist, argv[0], EXTCOMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010854 if (! list)
10855 {
Denis Ovsienkob7292942010-12-08 18:51:37 +030010856 vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000010857 return CMD_WARNING;
10858 }
10859
10860 extcommunity_list_show (vty, list);
10861
10862 return CMD_SUCCESS;
10863}
10864
10865/* Return configuration string of community-list entry. */
paulfd79ac92004-10-13 05:06:08 +000010866static const char *
paul718e3742002-12-13 20:15:29 +000010867community_list_config_str (struct community_entry *entry)
10868{
paulfd79ac92004-10-13 05:06:08 +000010869 const char *str;
paul718e3742002-12-13 20:15:29 +000010870
10871 if (entry->any)
10872 str = "";
10873 else
10874 {
10875 if (entry->style == COMMUNITY_LIST_STANDARD)
10876 str = community_str (entry->u.com);
10877 else
10878 str = entry->config;
10879 }
10880 return str;
10881}
10882
10883/* Display community-list and extcommunity-list configuration. */
paul94f2b392005-06-28 12:44:16 +000010884static int
paul718e3742002-12-13 20:15:29 +000010885community_list_config_write (struct vty *vty)
10886{
10887 struct community_list *list;
10888 struct community_entry *entry;
10889 struct community_list_master *cm;
10890 int write = 0;
10891
10892 /* Community-list. */
hassofee6e4e2005-02-02 16:29:31 +000010893 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010894
10895 for (list = cm->num.head; list; list = list->next)
10896 for (entry = list->head; entry; entry = entry->next)
10897 {
hassofee6e4e2005-02-02 16:29:31 +000010898 vty_out (vty, "ip community-list %s %s %s%s",
10899 list->name, community_direct_str (entry->direct),
10900 community_list_config_str (entry),
10901 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000010902 write++;
10903 }
10904 for (list = cm->str.head; list; list = list->next)
10905 for (entry = list->head; entry; entry = entry->next)
10906 {
10907 vty_out (vty, "ip community-list %s %s %s %s%s",
10908 entry->style == COMMUNITY_LIST_STANDARD
10909 ? "standard" : "expanded",
10910 list->name, community_direct_str (entry->direct),
10911 community_list_config_str (entry),
10912 VTY_NEWLINE);
10913 write++;
10914 }
10915
10916 /* Extcommunity-list. */
hassofee6e4e2005-02-02 16:29:31 +000010917 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010918
10919 for (list = cm->num.head; list; list = list->next)
10920 for (entry = list->head; entry; entry = entry->next)
10921 {
hassofee6e4e2005-02-02 16:29:31 +000010922 vty_out (vty, "ip extcommunity-list %s %s %s%s",
10923 list->name, community_direct_str (entry->direct),
10924 community_list_config_str (entry), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000010925 write++;
10926 }
10927 for (list = cm->str.head; list; list = list->next)
10928 for (entry = list->head; entry; entry = entry->next)
10929 {
10930 vty_out (vty, "ip extcommunity-list %s %s %s %s%s",
10931 entry->style == EXTCOMMUNITY_LIST_STANDARD
10932 ? "standard" : "expanded",
10933 list->name, community_direct_str (entry->direct),
10934 community_list_config_str (entry), VTY_NEWLINE);
10935 write++;
10936 }
10937 return write;
10938}
10939
Stephen Hemminger7fc626d2008-12-01 11:10:34 -080010940static struct cmd_node community_list_node =
paul718e3742002-12-13 20:15:29 +000010941{
10942 COMMUNITY_LIST_NODE,
10943 "",
10944 1 /* Export to vtysh. */
10945};
10946
paul94f2b392005-06-28 12:44:16 +000010947static void
10948community_list_vty (void)
paul718e3742002-12-13 20:15:29 +000010949{
10950 install_node (&community_list_node, community_list_config_write);
10951
10952 /* Community-list. */
paul718e3742002-12-13 20:15:29 +000010953 install_element (CONFIG_NODE, &ip_community_list_standard_cmd);
10954 install_element (CONFIG_NODE, &ip_community_list_standard2_cmd);
10955 install_element (CONFIG_NODE, &ip_community_list_expanded_cmd);
10956 install_element (CONFIG_NODE, &ip_community_list_name_standard_cmd);
10957 install_element (CONFIG_NODE, &ip_community_list_name_standard2_cmd);
10958 install_element (CONFIG_NODE, &ip_community_list_name_expanded_cmd);
hassofee6e4e2005-02-02 16:29:31 +000010959 install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd);
10960 install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd);
10961 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_all_cmd);
10962 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_all_cmd);
paul718e3742002-12-13 20:15:29 +000010963 install_element (CONFIG_NODE, &no_ip_community_list_standard_cmd);
10964 install_element (CONFIG_NODE, &no_ip_community_list_expanded_cmd);
10965 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_cmd);
10966 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_cmd);
10967 install_element (VIEW_NODE, &show_ip_community_list_cmd);
10968 install_element (VIEW_NODE, &show_ip_community_list_arg_cmd);
10969 install_element (ENABLE_NODE, &show_ip_community_list_cmd);
10970 install_element (ENABLE_NODE, &show_ip_community_list_arg_cmd);
10971
10972 /* Extcommunity-list. */
10973 install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd);
10974 install_element (CONFIG_NODE, &ip_extcommunity_list_standard2_cmd);
10975 install_element (CONFIG_NODE, &ip_extcommunity_list_expanded_cmd);
10976 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard_cmd);
10977 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard2_cmd);
10978 install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd);
hassofee6e4e2005-02-02 16:29:31 +000010979 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd);
10980 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd);
10981 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_all_cmd);
10982 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_all_cmd);
paul718e3742002-12-13 20:15:29 +000010983 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_cmd);
10984 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_cmd);
10985 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_cmd);
10986 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_cmd);
10987 install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd);
10988 install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd);
10989 install_element (ENABLE_NODE, &show_ip_extcommunity_list_cmd);
10990 install_element (ENABLE_NODE, &show_ip_extcommunity_list_arg_cmd);
10991}