blob: 439aeebeb0f74a5871694481cdbbeb4e5fde5a82 [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;
Stephen Hemmingerf5a48272011-03-24 17:30:21 +0000219 case BGP_ERR_NO_IBGP_WITH_TTLHACK:
220 str = "ttl-security only allowed for EBGP peers";
221 break;
paul718e3742002-12-13 20:15:29 +0000222 }
223 if (str)
224 {
225 vty_out (vty, "%% %s%s", str, VTY_NEWLINE);
226 return CMD_WARNING;
227 }
228 return CMD_SUCCESS;
229}
230
231/* BGP global configuration. */
232
233DEFUN (bgp_multiple_instance_func,
234 bgp_multiple_instance_cmd,
235 "bgp multiple-instance",
236 BGP_STR
237 "Enable bgp multiple instance\n")
238{
239 bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE);
240 return CMD_SUCCESS;
241}
242
243DEFUN (no_bgp_multiple_instance,
244 no_bgp_multiple_instance_cmd,
245 "no bgp multiple-instance",
246 NO_STR
247 BGP_STR
248 "BGP multiple instance\n")
249{
250 int ret;
251
252 ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE);
253 if (ret < 0)
254 {
255 vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE);
256 return CMD_WARNING;
257 }
258 return CMD_SUCCESS;
259}
260
261DEFUN (bgp_config_type,
262 bgp_config_type_cmd,
263 "bgp config-type (cisco|zebra)",
264 BGP_STR
265 "Configuration type\n"
266 "cisco\n"
267 "zebra\n")
268{
269 if (strncmp (argv[0], "c", 1) == 0)
270 bgp_option_set (BGP_OPT_CONFIG_CISCO);
271 else
272 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
273
274 return CMD_SUCCESS;
275}
276
277DEFUN (no_bgp_config_type,
278 no_bgp_config_type_cmd,
279 "no bgp config-type",
280 NO_STR
281 BGP_STR
282 "Display configuration type\n")
283{
284 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
285 return CMD_SUCCESS;
286}
287
288DEFUN (no_synchronization,
289 no_synchronization_cmd,
290 "no synchronization",
291 NO_STR
292 "Perform IGP synchronization\n")
293{
294 return CMD_SUCCESS;
295}
296
297DEFUN (no_auto_summary,
298 no_auto_summary_cmd,
299 "no auto-summary",
300 NO_STR
301 "Enable automatic network number summarization\n")
302{
303 return CMD_SUCCESS;
304}
hasso3d515fd2005-02-01 21:30:04 +0000305
306DEFUN_DEPRECATED (neighbor_version,
307 neighbor_version_cmd,
308 NEIGHBOR_CMD "version (4|4-)",
309 NEIGHBOR_STR
310 NEIGHBOR_ADDR_STR
311 "Set the BGP version to match a neighbor\n"
312 "Neighbor's BGP version\n")
313{
314 return CMD_SUCCESS;
315}
paul718e3742002-12-13 20:15:29 +0000316
317/* "router bgp" commands. */
318DEFUN (router_bgp,
319 router_bgp_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000320 "router bgp " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +0000321 ROUTER_STR
322 BGP_STR
323 AS_STR)
324{
325 int ret;
326 as_t as;
327 struct bgp *bgp;
paulfd79ac92004-10-13 05:06:08 +0000328 const char *name = NULL;
paul718e3742002-12-13 20:15:29 +0000329
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000330 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
paul718e3742002-12-13 20:15:29 +0000331
332 if (argc == 2)
333 name = argv[1];
334
335 ret = bgp_get (&bgp, &as, name);
336 switch (ret)
337 {
338 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET:
339 vty_out (vty, "Please specify 'bgp multiple-instance' first%s",
340 VTY_NEWLINE);
341 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +0000342 case BGP_ERR_AS_MISMATCH:
Denis Ovsienkoaea339f2009-04-30 17:16:22 +0400343 vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +0000344 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +0000345 case BGP_ERR_INSTANCE_MISMATCH:
346 vty_out (vty, "BGP view name and AS number mismatch%s", VTY_NEWLINE);
Denis Ovsienkoaea339f2009-04-30 17:16:22 +0400347 vty_out (vty, "BGP instance is already running; AS is %u%s",
paul718e3742002-12-13 20:15:29 +0000348 as, VTY_NEWLINE);
349 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +0000350 }
351
352 vty->node = BGP_NODE;
353 vty->index = bgp;
354
355 return CMD_SUCCESS;
356}
357
358ALIAS (router_bgp,
359 router_bgp_view_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000360 "router bgp " CMD_AS_RANGE " view WORD",
paul718e3742002-12-13 20:15:29 +0000361 ROUTER_STR
362 BGP_STR
363 AS_STR
364 "BGP view\n"
365 "view name\n")
366
367/* "no router bgp" commands. */
368DEFUN (no_router_bgp,
369 no_router_bgp_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000370 "no router bgp " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +0000371 NO_STR
372 ROUTER_STR
373 BGP_STR
374 AS_STR)
375{
376 as_t as;
377 struct bgp *bgp;
paulfd79ac92004-10-13 05:06:08 +0000378 const char *name = NULL;
paul718e3742002-12-13 20:15:29 +0000379
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000380 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
paul718e3742002-12-13 20:15:29 +0000381
382 if (argc == 2)
383 name = argv[1];
384
385 /* Lookup bgp structure. */
386 bgp = bgp_lookup (as, name);
387 if (! bgp)
388 {
389 vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE);
390 return CMD_WARNING;
391 }
392
393 bgp_delete (bgp);
394
395 return CMD_SUCCESS;
396}
397
398ALIAS (no_router_bgp,
399 no_router_bgp_view_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000400 "no router bgp " CMD_AS_RANGE " view WORD",
paul718e3742002-12-13 20:15:29 +0000401 NO_STR
402 ROUTER_STR
403 BGP_STR
404 AS_STR
405 "BGP view\n"
406 "view name\n")
407
408/* BGP router-id. */
409
410DEFUN (bgp_router_id,
411 bgp_router_id_cmd,
412 "bgp router-id A.B.C.D",
413 BGP_STR
414 "Override configured router identifier\n"
415 "Manually configured router identifier\n")
416{
417 int ret;
418 struct in_addr id;
419 struct bgp *bgp;
420
421 bgp = vty->index;
422
423 ret = inet_aton (argv[0], &id);
424 if (! ret)
425 {
426 vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE);
427 return CMD_WARNING;
428 }
429
hasso18a6dce2004-10-03 18:18:34 +0000430 bgp->router_id_static = id;
paul718e3742002-12-13 20:15:29 +0000431 bgp_router_id_set (bgp, &id);
432
433 return CMD_SUCCESS;
434}
435
436DEFUN (no_bgp_router_id,
437 no_bgp_router_id_cmd,
438 "no bgp router-id",
439 NO_STR
440 BGP_STR
441 "Override configured router identifier\n")
442{
443 int ret;
444 struct in_addr id;
445 struct bgp *bgp;
446
447 bgp = vty->index;
448
449 if (argc == 1)
450 {
451 ret = inet_aton (argv[0], &id);
452 if (! ret)
453 {
454 vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE);
455 return CMD_WARNING;
456 }
457
hasso18a6dce2004-10-03 18:18:34 +0000458 if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id))
paul718e3742002-12-13 20:15:29 +0000459 {
460 vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE);
461 return CMD_WARNING;
462 }
463 }
464
hasso18a6dce2004-10-03 18:18:34 +0000465 bgp->router_id_static.s_addr = 0;
466 bgp_router_id_set (bgp, &router_id_zebra);
paul718e3742002-12-13 20:15:29 +0000467
468 return CMD_SUCCESS;
469}
470
471ALIAS (no_bgp_router_id,
472 no_bgp_router_id_val_cmd,
473 "no bgp router-id A.B.C.D",
474 NO_STR
475 BGP_STR
476 "Override configured router identifier\n"
477 "Manually configured router identifier\n")
478
479/* BGP Cluster ID. */
480
481DEFUN (bgp_cluster_id,
482 bgp_cluster_id_cmd,
483 "bgp cluster-id A.B.C.D",
484 BGP_STR
485 "Configure Route-Reflector Cluster-id\n"
486 "Route-Reflector Cluster-id in IP address format\n")
487{
488 int ret;
489 struct bgp *bgp;
490 struct in_addr cluster;
491
492 bgp = vty->index;
493
494 ret = inet_aton (argv[0], &cluster);
495 if (! ret)
496 {
497 vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
498 return CMD_WARNING;
499 }
500
501 bgp_cluster_id_set (bgp, &cluster);
502
503 return CMD_SUCCESS;
504}
505
506ALIAS (bgp_cluster_id,
507 bgp_cluster_id32_cmd,
508 "bgp cluster-id <1-4294967295>",
509 BGP_STR
510 "Configure Route-Reflector Cluster-id\n"
511 "Route-Reflector Cluster-id as 32 bit quantity\n")
512
513DEFUN (no_bgp_cluster_id,
514 no_bgp_cluster_id_cmd,
515 "no bgp cluster-id",
516 NO_STR
517 BGP_STR
518 "Configure Route-Reflector Cluster-id\n")
519{
520 int ret;
521 struct bgp *bgp;
522 struct in_addr cluster;
523
524 bgp = vty->index;
525
526 if (argc == 1)
527 {
528 ret = inet_aton (argv[0], &cluster);
529 if (! ret)
530 {
531 vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
532 return CMD_WARNING;
533 }
534 }
535
536 bgp_cluster_id_unset (bgp);
537
538 return CMD_SUCCESS;
539}
540
541ALIAS (no_bgp_cluster_id,
542 no_bgp_cluster_id_arg_cmd,
543 "no bgp cluster-id A.B.C.D",
544 NO_STR
545 BGP_STR
546 "Configure Route-Reflector Cluster-id\n"
547 "Route-Reflector Cluster-id in IP address format\n")
548
549DEFUN (bgp_confederation_identifier,
550 bgp_confederation_identifier_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000551 "bgp confederation identifier " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +0000552 "BGP specific commands\n"
553 "AS confederation parameters\n"
554 "AS number\n"
555 "Set routing domain confederation AS\n")
556{
557 struct bgp *bgp;
558 as_t as;
559
560 bgp = vty->index;
561
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000562 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
paul718e3742002-12-13 20:15:29 +0000563
564 bgp_confederation_id_set (bgp, as);
565
566 return CMD_SUCCESS;
567}
568
569DEFUN (no_bgp_confederation_identifier,
570 no_bgp_confederation_identifier_cmd,
571 "no bgp confederation identifier",
572 NO_STR
573 "BGP specific commands\n"
574 "AS confederation parameters\n"
575 "AS number\n")
576{
577 struct bgp *bgp;
578 as_t as;
579
580 bgp = vty->index;
581
582 if (argc == 1)
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000583 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
paul718e3742002-12-13 20:15:29 +0000584
585 bgp_confederation_id_unset (bgp);
586
587 return CMD_SUCCESS;
588}
589
590ALIAS (no_bgp_confederation_identifier,
591 no_bgp_confederation_identifier_arg_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000592 "no bgp confederation identifier " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +0000593 NO_STR
594 "BGP specific commands\n"
595 "AS confederation parameters\n"
596 "AS number\n"
597 "Set routing domain confederation AS\n")
598
599DEFUN (bgp_confederation_peers,
600 bgp_confederation_peers_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000601 "bgp confederation peers ." CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +0000602 "BGP specific commands\n"
603 "AS confederation parameters\n"
604 "Peer ASs in BGP confederation\n"
605 AS_STR)
606{
607 struct bgp *bgp;
608 as_t as;
609 int i;
610
611 bgp = vty->index;
612
613 for (i = 0; i < argc; i++)
614 {
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000615 VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX);
paul718e3742002-12-13 20:15:29 +0000616
617 if (bgp->as == as)
618 {
619 vty_out (vty, "%% Local member-AS not allowed in confed peer list%s",
620 VTY_NEWLINE);
621 continue;
622 }
623
624 bgp_confederation_peers_add (bgp, as);
625 }
626 return CMD_SUCCESS;
627}
628
629DEFUN (no_bgp_confederation_peers,
630 no_bgp_confederation_peers_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000631 "no bgp confederation peers ." CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +0000632 NO_STR
633 "BGP specific commands\n"
634 "AS confederation parameters\n"
635 "Peer ASs in BGP confederation\n"
636 AS_STR)
637{
638 struct bgp *bgp;
639 as_t as;
640 int i;
641
642 bgp = vty->index;
643
644 for (i = 0; i < argc; i++)
645 {
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000646 VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX);
647
paul718e3742002-12-13 20:15:29 +0000648 bgp_confederation_peers_remove (bgp, as);
649 }
650 return CMD_SUCCESS;
651}
652
653/* BGP timers. */
654
655DEFUN (bgp_timers,
656 bgp_timers_cmd,
657 "timers bgp <0-65535> <0-65535>",
658 "Adjust routing timers\n"
659 "BGP timers\n"
660 "Keepalive interval\n"
661 "Holdtime\n")
662{
663 struct bgp *bgp;
664 unsigned long keepalive = 0;
665 unsigned long holdtime = 0;
666
667 bgp = vty->index;
668
669 VTY_GET_INTEGER ("keepalive", keepalive, argv[0]);
670 VTY_GET_INTEGER ("holdtime", holdtime, argv[1]);
671
672 /* Holdtime value check. */
673 if (holdtime < 3 && holdtime != 0)
674 {
675 vty_out (vty, "%% hold time value must be either 0 or greater than 3%s",
676 VTY_NEWLINE);
677 return CMD_WARNING;
678 }
679
680 bgp_timers_set (bgp, keepalive, holdtime);
681
682 return CMD_SUCCESS;
683}
684
685DEFUN (no_bgp_timers,
686 no_bgp_timers_cmd,
687 "no timers bgp",
688 NO_STR
689 "Adjust routing timers\n"
690 "BGP timers\n")
691{
692 struct bgp *bgp;
693
694 bgp = vty->index;
695 bgp_timers_unset (bgp);
696
697 return CMD_SUCCESS;
698}
699
700ALIAS (no_bgp_timers,
701 no_bgp_timers_arg_cmd,
702 "no timers bgp <0-65535> <0-65535>",
703 NO_STR
704 "Adjust routing timers\n"
705 "BGP timers\n"
706 "Keepalive interval\n"
707 "Holdtime\n")
708
709DEFUN (bgp_client_to_client_reflection,
710 bgp_client_to_client_reflection_cmd,
711 "bgp client-to-client reflection",
712 "BGP specific commands\n"
713 "Configure client to client route reflection\n"
714 "reflection of routes allowed\n")
715{
716 struct bgp *bgp;
717
718 bgp = vty->index;
719 bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
720 return CMD_SUCCESS;
721}
722
723DEFUN (no_bgp_client_to_client_reflection,
724 no_bgp_client_to_client_reflection_cmd,
725 "no bgp client-to-client reflection",
726 NO_STR
727 "BGP specific commands\n"
728 "Configure client to client route reflection\n"
729 "reflection of routes allowed\n")
730{
731 struct bgp *bgp;
732
733 bgp = vty->index;
734 bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
735 return CMD_SUCCESS;
736}
737
738/* "bgp always-compare-med" configuration. */
739DEFUN (bgp_always_compare_med,
740 bgp_always_compare_med_cmd,
741 "bgp always-compare-med",
742 "BGP specific commands\n"
743 "Allow comparing MED from different neighbors\n")
744{
745 struct bgp *bgp;
746
747 bgp = vty->index;
748 bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
749 return CMD_SUCCESS;
750}
751
752DEFUN (no_bgp_always_compare_med,
753 no_bgp_always_compare_med_cmd,
754 "no bgp always-compare-med",
755 NO_STR
756 "BGP specific commands\n"
757 "Allow comparing MED from different neighbors\n")
758{
759 struct bgp *bgp;
760
761 bgp = vty->index;
762 bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
763 return CMD_SUCCESS;
764}
765
766/* "bgp deterministic-med" configuration. */
767DEFUN (bgp_deterministic_med,
768 bgp_deterministic_med_cmd,
769 "bgp deterministic-med",
770 "BGP specific commands\n"
771 "Pick the best-MED path among paths advertised from the neighboring AS\n")
772{
773 struct bgp *bgp;
774
775 bgp = vty->index;
776 bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED);
777 return CMD_SUCCESS;
778}
779
780DEFUN (no_bgp_deterministic_med,
781 no_bgp_deterministic_med_cmd,
782 "no bgp deterministic-med",
783 NO_STR
784 "BGP specific commands\n"
785 "Pick the best-MED path among paths advertised from the neighboring AS\n")
786{
787 struct bgp *bgp;
788
789 bgp = vty->index;
790 bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED);
791 return CMD_SUCCESS;
792}
hasso538621f2004-05-21 09:31:30 +0000793
794/* "bgp graceful-restart" configuration. */
795DEFUN (bgp_graceful_restart,
796 bgp_graceful_restart_cmd,
797 "bgp graceful-restart",
798 "BGP specific commands\n"
799 "Graceful restart capability parameters\n")
800{
801 struct bgp *bgp;
802
803 bgp = vty->index;
804 bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART);
805 return CMD_SUCCESS;
806}
807
808DEFUN (no_bgp_graceful_restart,
809 no_bgp_graceful_restart_cmd,
810 "no bgp graceful-restart",
811 NO_STR
812 "BGP specific commands\n"
813 "Graceful restart capability parameters\n")
814{
815 struct bgp *bgp;
816
817 bgp = vty->index;
818 bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART);
819 return CMD_SUCCESS;
820}
821
hasso93406d82005-02-02 14:40:33 +0000822DEFUN (bgp_graceful_restart_stalepath_time,
823 bgp_graceful_restart_stalepath_time_cmd,
824 "bgp graceful-restart stalepath-time <1-3600>",
825 "BGP specific commands\n"
826 "Graceful restart capability parameters\n"
827 "Set the max time to hold onto restarting peer's stale paths\n"
828 "Delay value (seconds)\n")
829{
830 struct bgp *bgp;
831 u_int32_t stalepath;
832
833 bgp = vty->index;
834 if (! bgp)
835 return CMD_WARNING;
836
837 VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[0], 1, 3600);
838 bgp->stalepath_time = stalepath;
839 return CMD_SUCCESS;
840}
841
842DEFUN (no_bgp_graceful_restart_stalepath_time,
843 no_bgp_graceful_restart_stalepath_time_cmd,
844 "no bgp graceful-restart stalepath-time",
845 NO_STR
846 "BGP specific commands\n"
847 "Graceful restart capability parameters\n"
848 "Set the max time to hold onto restarting peer's stale paths\n")
849{
850 struct bgp *bgp;
851
852 bgp = vty->index;
853 if (! bgp)
854 return CMD_WARNING;
855
856 bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME;
857 return CMD_SUCCESS;
858}
859
860ALIAS (no_bgp_graceful_restart_stalepath_time,
861 no_bgp_graceful_restart_stalepath_time_val_cmd,
862 "no bgp graceful-restart stalepath-time <1-3600>",
863 NO_STR
864 "BGP specific commands\n"
865 "Graceful restart capability parameters\n"
866 "Set the max time to hold onto restarting peer's stale paths\n"
867 "Delay value (seconds)\n")
868
paul718e3742002-12-13 20:15:29 +0000869/* "bgp fast-external-failover" configuration. */
870DEFUN (bgp_fast_external_failover,
871 bgp_fast_external_failover_cmd,
872 "bgp fast-external-failover",
873 BGP_STR
874 "Immediately reset session if a link to a directly connected external peer goes down\n")
875{
876 struct bgp *bgp;
877
878 bgp = vty->index;
879 bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
880 return CMD_SUCCESS;
881}
882
883DEFUN (no_bgp_fast_external_failover,
884 no_bgp_fast_external_failover_cmd,
885 "no bgp fast-external-failover",
886 NO_STR
887 BGP_STR
888 "Immediately reset session if a link to a directly connected external peer goes down\n")
889{
890 struct bgp *bgp;
891
892 bgp = vty->index;
893 bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
894 return CMD_SUCCESS;
895}
896
897/* "bgp enforce-first-as" configuration. */
898DEFUN (bgp_enforce_first_as,
899 bgp_enforce_first_as_cmd,
900 "bgp enforce-first-as",
901 BGP_STR
902 "Enforce the first AS for EBGP routes\n")
903{
904 struct bgp *bgp;
905
906 bgp = vty->index;
907 bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
908 return CMD_SUCCESS;
909}
910
911DEFUN (no_bgp_enforce_first_as,
912 no_bgp_enforce_first_as_cmd,
913 "no bgp enforce-first-as",
914 NO_STR
915 BGP_STR
916 "Enforce the first AS for EBGP routes\n")
917{
918 struct bgp *bgp;
919
920 bgp = vty->index;
921 bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
922 return CMD_SUCCESS;
923}
924
925/* "bgp bestpath compare-routerid" configuration. */
926DEFUN (bgp_bestpath_compare_router_id,
927 bgp_bestpath_compare_router_id_cmd,
928 "bgp bestpath compare-routerid",
929 "BGP specific commands\n"
930 "Change the default bestpath selection\n"
931 "Compare router-id for identical EBGP paths\n")
932{
933 struct bgp *bgp;
934
935 bgp = vty->index;
936 bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
937 return CMD_SUCCESS;
938}
939
940DEFUN (no_bgp_bestpath_compare_router_id,
941 no_bgp_bestpath_compare_router_id_cmd,
942 "no bgp bestpath compare-routerid",
943 NO_STR
944 "BGP specific commands\n"
945 "Change the default bestpath selection\n"
946 "Compare router-id for identical EBGP paths\n")
947{
948 struct bgp *bgp;
949
950 bgp = vty->index;
951 bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
952 return CMD_SUCCESS;
953}
954
955/* "bgp bestpath as-path ignore" configuration. */
956DEFUN (bgp_bestpath_aspath_ignore,
957 bgp_bestpath_aspath_ignore_cmd,
958 "bgp bestpath as-path ignore",
959 "BGP specific commands\n"
960 "Change the default bestpath selection\n"
961 "AS-path attribute\n"
962 "Ignore as-path length in selecting a route\n")
963{
964 struct bgp *bgp;
965
966 bgp = vty->index;
967 bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE);
968 return CMD_SUCCESS;
969}
970
971DEFUN (no_bgp_bestpath_aspath_ignore,
972 no_bgp_bestpath_aspath_ignore_cmd,
973 "no bgp bestpath as-path ignore",
974 NO_STR
975 "BGP specific commands\n"
976 "Change the default bestpath selection\n"
977 "AS-path attribute\n"
978 "Ignore as-path length in selecting a route\n")
979{
980 struct bgp *bgp;
981
982 bgp = vty->index;
983 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE);
984 return CMD_SUCCESS;
985}
986
hasso68118452005-04-08 15:40:36 +0000987/* "bgp bestpath as-path confed" configuration. */
988DEFUN (bgp_bestpath_aspath_confed,
989 bgp_bestpath_aspath_confed_cmd,
990 "bgp bestpath as-path confed",
991 "BGP specific commands\n"
992 "Change the default bestpath selection\n"
993 "AS-path attribute\n"
994 "Compare path lengths including confederation sets & sequences in selecting a route\n")
995{
996 struct bgp *bgp;
997
998 bgp = vty->index;
999 bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED);
1000 return CMD_SUCCESS;
1001}
1002
1003DEFUN (no_bgp_bestpath_aspath_confed,
1004 no_bgp_bestpath_aspath_confed_cmd,
1005 "no bgp bestpath as-path confed",
1006 NO_STR
1007 "BGP specific commands\n"
1008 "Change the default bestpath selection\n"
1009 "AS-path attribute\n"
1010 "Compare path lengths including confederation sets & sequences in selecting a route\n")
1011{
1012 struct bgp *bgp;
1013
1014 bgp = vty->index;
1015 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED);
1016 return CMD_SUCCESS;
1017}
1018
paul848973c2003-08-13 00:32:49 +00001019/* "bgp log-neighbor-changes" configuration. */
1020DEFUN (bgp_log_neighbor_changes,
1021 bgp_log_neighbor_changes_cmd,
1022 "bgp log-neighbor-changes",
1023 "BGP specific commands\n"
1024 "Log neighbor up/down and reset reason\n")
1025{
1026 struct bgp *bgp;
1027
1028 bgp = vty->index;
1029 bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
1030 return CMD_SUCCESS;
1031}
1032
1033DEFUN (no_bgp_log_neighbor_changes,
1034 no_bgp_log_neighbor_changes_cmd,
1035 "no bgp log-neighbor-changes",
1036 NO_STR
1037 "BGP specific commands\n"
1038 "Log neighbor up/down and reset reason\n")
1039{
1040 struct bgp *bgp;
1041
1042 bgp = vty->index;
1043 bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
1044 return CMD_SUCCESS;
1045}
1046
paul718e3742002-12-13 20:15:29 +00001047/* "bgp bestpath med" configuration. */
1048DEFUN (bgp_bestpath_med,
1049 bgp_bestpath_med_cmd,
1050 "bgp bestpath med (confed|missing-as-worst)",
1051 "BGP specific commands\n"
1052 "Change the default bestpath selection\n"
1053 "MED attribute\n"
1054 "Compare MED among confederation paths\n"
1055 "Treat missing MED as the least preferred one\n")
1056{
1057 struct bgp *bgp;
1058
1059 bgp = vty->index;
1060
1061 if (strncmp (argv[0], "confed", 1) == 0)
1062 bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
1063 else
1064 bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1065
1066 return CMD_SUCCESS;
1067}
1068
1069DEFUN (bgp_bestpath_med2,
1070 bgp_bestpath_med2_cmd,
1071 "bgp bestpath med confed missing-as-worst",
1072 "BGP specific commands\n"
1073 "Change the default bestpath selection\n"
1074 "MED attribute\n"
1075 "Compare MED among confederation paths\n"
1076 "Treat missing MED as the least preferred one\n")
1077{
1078 struct bgp *bgp;
1079
1080 bgp = vty->index;
1081 bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
1082 bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1083 return CMD_SUCCESS;
1084}
1085
1086ALIAS (bgp_bestpath_med2,
1087 bgp_bestpath_med3_cmd,
1088 "bgp bestpath med missing-as-worst confed",
1089 "BGP specific commands\n"
1090 "Change the default bestpath selection\n"
1091 "MED attribute\n"
1092 "Treat missing MED as the least preferred one\n"
1093 "Compare MED among confederation paths\n")
1094
1095DEFUN (no_bgp_bestpath_med,
1096 no_bgp_bestpath_med_cmd,
1097 "no bgp bestpath med (confed|missing-as-worst)",
1098 NO_STR
1099 "BGP specific commands\n"
1100 "Change the default bestpath selection\n"
1101 "MED attribute\n"
1102 "Compare MED among confederation paths\n"
1103 "Treat missing MED as the least preferred one\n")
1104{
1105 struct bgp *bgp;
1106
1107 bgp = vty->index;
1108
1109 if (strncmp (argv[0], "confed", 1) == 0)
1110 bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
1111 else
1112 bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1113
1114 return CMD_SUCCESS;
1115}
1116
1117DEFUN (no_bgp_bestpath_med2,
1118 no_bgp_bestpath_med2_cmd,
1119 "no bgp bestpath med confed missing-as-worst",
1120 NO_STR
1121 "BGP specific commands\n"
1122 "Change the default bestpath selection\n"
1123 "MED attribute\n"
1124 "Compare MED among confederation paths\n"
1125 "Treat missing MED as the least preferred one\n")
1126{
1127 struct bgp *bgp;
1128
1129 bgp = vty->index;
1130 bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
1131 bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1132 return CMD_SUCCESS;
1133}
1134
1135ALIAS (no_bgp_bestpath_med2,
1136 no_bgp_bestpath_med3_cmd,
1137 "no bgp bestpath med missing-as-worst confed",
1138 NO_STR
1139 "BGP specific commands\n"
1140 "Change the default bestpath selection\n"
1141 "MED attribute\n"
1142 "Treat missing MED as the least preferred one\n"
1143 "Compare MED among confederation paths\n")
1144
1145/* "no bgp default ipv4-unicast". */
1146DEFUN (no_bgp_default_ipv4_unicast,
1147 no_bgp_default_ipv4_unicast_cmd,
1148 "no bgp default ipv4-unicast",
1149 NO_STR
1150 "BGP specific commands\n"
1151 "Configure BGP defaults\n"
1152 "Activate ipv4-unicast for a peer by default\n")
1153{
1154 struct bgp *bgp;
1155
1156 bgp = vty->index;
1157 bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
1158 return CMD_SUCCESS;
1159}
1160
1161DEFUN (bgp_default_ipv4_unicast,
1162 bgp_default_ipv4_unicast_cmd,
1163 "bgp default ipv4-unicast",
1164 "BGP specific commands\n"
1165 "Configure BGP defaults\n"
1166 "Activate ipv4-unicast for a peer by default\n")
1167{
1168 struct bgp *bgp;
1169
1170 bgp = vty->index;
1171 bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
1172 return CMD_SUCCESS;
1173}
1174
1175/* "bgp import-check" configuration. */
1176DEFUN (bgp_network_import_check,
1177 bgp_network_import_check_cmd,
1178 "bgp network import-check",
1179 "BGP specific commands\n"
1180 "BGP network command\n"
1181 "Check BGP network route exists in IGP\n")
1182{
1183 struct bgp *bgp;
1184
1185 bgp = vty->index;
1186 bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK);
1187 return CMD_SUCCESS;
1188}
1189
1190DEFUN (no_bgp_network_import_check,
1191 no_bgp_network_import_check_cmd,
1192 "no bgp network import-check",
1193 NO_STR
1194 "BGP specific commands\n"
1195 "BGP network command\n"
1196 "Check BGP network route exists in IGP\n")
1197{
1198 struct bgp *bgp;
1199
1200 bgp = vty->index;
1201 bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK);
1202 return CMD_SUCCESS;
1203}
1204
1205DEFUN (bgp_default_local_preference,
1206 bgp_default_local_preference_cmd,
1207 "bgp default local-preference <0-4294967295>",
1208 "BGP specific commands\n"
1209 "Configure BGP defaults\n"
1210 "local preference (higher=more preferred)\n"
1211 "Configure default local preference value\n")
1212{
1213 struct bgp *bgp;
1214 u_int32_t local_pref;
1215
1216 bgp = vty->index;
1217
1218 VTY_GET_INTEGER ("local preference", local_pref, argv[0]);
1219
1220 bgp_default_local_preference_set (bgp, local_pref);
1221
1222 return CMD_SUCCESS;
1223}
1224
1225DEFUN (no_bgp_default_local_preference,
1226 no_bgp_default_local_preference_cmd,
1227 "no bgp default local-preference",
1228 NO_STR
1229 "BGP specific commands\n"
1230 "Configure BGP defaults\n"
1231 "local preference (higher=more preferred)\n")
1232{
1233 struct bgp *bgp;
1234
1235 bgp = vty->index;
1236 bgp_default_local_preference_unset (bgp);
1237 return CMD_SUCCESS;
1238}
1239
1240ALIAS (no_bgp_default_local_preference,
1241 no_bgp_default_local_preference_val_cmd,
1242 "no bgp default local-preference <0-4294967295>",
1243 NO_STR
1244 "BGP specific commands\n"
1245 "Configure BGP defaults\n"
1246 "local preference (higher=more preferred)\n"
1247 "Configure default local preference value\n")
1248
1249static int
paulfd79ac92004-10-13 05:06:08 +00001250peer_remote_as_vty (struct vty *vty, const char *peer_str,
1251 const char *as_str, afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00001252{
1253 int ret;
1254 struct bgp *bgp;
1255 as_t as;
1256 union sockunion su;
1257
1258 bgp = vty->index;
1259
1260 /* Get AS number. */
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00001261 VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX);
paul718e3742002-12-13 20:15:29 +00001262
1263 /* If peer is peer group, call proper function. */
1264 ret = str2sockunion (peer_str, &su);
1265 if (ret < 0)
1266 {
1267 ret = peer_group_remote_as (bgp, peer_str, &as);
1268 if (ret < 0)
1269 {
1270 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1271 return CMD_WARNING;
1272 }
1273 return CMD_SUCCESS;
1274 }
1275
1276 if (peer_address_self_check (&su))
1277 {
1278 vty_out (vty, "%% Can not configure the local system as neighbor%s",
1279 VTY_NEWLINE);
1280 return CMD_WARNING;
1281 }
1282
1283 ret = peer_remote_as (bgp, &su, &as, afi, safi);
1284
1285 /* This peer belongs to peer group. */
1286 switch (ret)
1287 {
1288 case BGP_ERR_PEER_GROUP_MEMBER:
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04001289 vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001290 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +00001291 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT:
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04001292 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 +00001293 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +00001294 }
1295 return bgp_vty_return (vty, ret);
1296}
1297
1298DEFUN (neighbor_remote_as,
1299 neighbor_remote_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001300 NEIGHBOR_CMD2 "remote-as " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00001301 NEIGHBOR_STR
1302 NEIGHBOR_ADDR_STR2
1303 "Specify a BGP neighbor\n"
1304 AS_STR)
1305{
1306 return peer_remote_as_vty (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST);
1307}
1308
1309DEFUN (neighbor_peer_group,
1310 neighbor_peer_group_cmd,
1311 "neighbor WORD peer-group",
1312 NEIGHBOR_STR
1313 "Neighbor tag\n"
1314 "Configure peer-group\n")
1315{
1316 struct bgp *bgp;
1317 struct peer_group *group;
1318
1319 bgp = vty->index;
1320
1321 group = peer_group_get (bgp, argv[0]);
1322 if (! group)
1323 return CMD_WARNING;
1324
1325 return CMD_SUCCESS;
1326}
1327
1328DEFUN (no_neighbor,
1329 no_neighbor_cmd,
1330 NO_NEIGHBOR_CMD2,
1331 NO_STR
1332 NEIGHBOR_STR
1333 NEIGHBOR_ADDR_STR2)
1334{
1335 int ret;
1336 union sockunion su;
1337 struct peer_group *group;
1338 struct peer *peer;
1339
1340 ret = str2sockunion (argv[0], &su);
1341 if (ret < 0)
1342 {
1343 group = peer_group_lookup (vty->index, argv[0]);
1344 if (group)
1345 peer_group_delete (group);
1346 else
1347 {
1348 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1349 return CMD_WARNING;
1350 }
1351 }
1352 else
1353 {
1354 peer = peer_lookup (vty->index, &su);
1355 if (peer)
paul200df112005-06-01 11:17:05 +00001356 peer_delete (peer);
paul718e3742002-12-13 20:15:29 +00001357 }
1358
1359 return CMD_SUCCESS;
1360}
1361
1362ALIAS (no_neighbor,
1363 no_neighbor_remote_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001364 NO_NEIGHBOR_CMD "remote-as " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00001365 NO_STR
1366 NEIGHBOR_STR
1367 NEIGHBOR_ADDR_STR
1368 "Specify a BGP neighbor\n"
1369 AS_STR)
1370
1371DEFUN (no_neighbor_peer_group,
1372 no_neighbor_peer_group_cmd,
1373 "no neighbor WORD peer-group",
1374 NO_STR
1375 NEIGHBOR_STR
1376 "Neighbor tag\n"
1377 "Configure peer-group\n")
1378{
1379 struct peer_group *group;
1380
1381 group = peer_group_lookup (vty->index, argv[0]);
1382 if (group)
1383 peer_group_delete (group);
1384 else
1385 {
1386 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1387 return CMD_WARNING;
1388 }
1389 return CMD_SUCCESS;
1390}
1391
1392DEFUN (no_neighbor_peer_group_remote_as,
1393 no_neighbor_peer_group_remote_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001394 "no neighbor WORD remote-as " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00001395 NO_STR
1396 NEIGHBOR_STR
1397 "Neighbor tag\n"
1398 "Specify a BGP neighbor\n"
1399 AS_STR)
1400{
1401 struct peer_group *group;
1402
1403 group = peer_group_lookup (vty->index, argv[0]);
1404 if (group)
1405 peer_group_remote_as_delete (group);
1406 else
1407 {
1408 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1409 return CMD_WARNING;
1410 }
1411 return CMD_SUCCESS;
1412}
1413
1414DEFUN (neighbor_local_as,
1415 neighbor_local_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001416 NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00001417 NEIGHBOR_STR
1418 NEIGHBOR_ADDR_STR2
1419 "Specify a local-as number\n"
1420 "AS number used as local AS\n")
1421{
1422 struct peer *peer;
1423 int ret;
1424
1425 peer = peer_and_group_lookup_vty (vty, argv[0]);
1426 if (! peer)
1427 return CMD_WARNING;
1428
1429 ret = peer_local_as_set (peer, atoi (argv[1]), 0);
1430 return bgp_vty_return (vty, ret);
1431}
1432
1433DEFUN (neighbor_local_as_no_prepend,
1434 neighbor_local_as_no_prepend_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001435 NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
paul718e3742002-12-13 20:15:29 +00001436 NEIGHBOR_STR
1437 NEIGHBOR_ADDR_STR2
1438 "Specify a local-as number\n"
1439 "AS number used as local AS\n"
1440 "Do not prepend local-as to updates from ebgp peers\n")
1441{
1442 struct peer *peer;
1443 int ret;
1444
1445 peer = peer_and_group_lookup_vty (vty, argv[0]);
1446 if (! peer)
1447 return CMD_WARNING;
1448
1449 ret = peer_local_as_set (peer, atoi (argv[1]), 1);
1450 return bgp_vty_return (vty, ret);
1451}
1452
1453DEFUN (no_neighbor_local_as,
1454 no_neighbor_local_as_cmd,
1455 NO_NEIGHBOR_CMD2 "local-as",
1456 NO_STR
1457 NEIGHBOR_STR
1458 NEIGHBOR_ADDR_STR2
1459 "Specify a local-as number\n")
1460{
1461 struct peer *peer;
1462 int ret;
1463
1464 peer = peer_and_group_lookup_vty (vty, argv[0]);
1465 if (! peer)
1466 return CMD_WARNING;
1467
1468 ret = peer_local_as_unset (peer);
1469 return bgp_vty_return (vty, ret);
1470}
1471
1472ALIAS (no_neighbor_local_as,
1473 no_neighbor_local_as_val_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001474 NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00001475 NO_STR
1476 NEIGHBOR_STR
1477 NEIGHBOR_ADDR_STR2
1478 "Specify a local-as number\n"
1479 "AS number used as local AS\n")
1480
1481ALIAS (no_neighbor_local_as,
1482 no_neighbor_local_as_val2_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001483 NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
paul718e3742002-12-13 20:15:29 +00001484 NO_STR
1485 NEIGHBOR_STR
1486 NEIGHBOR_ADDR_STR2
1487 "Specify a local-as number\n"
1488 "AS number used as local AS\n"
1489 "Do not prepend local-as to updates from ebgp peers\n")
1490
Paul Jakma0df7c912008-07-21 21:02:49 +00001491DEFUN (neighbor_password,
1492 neighbor_password_cmd,
1493 NEIGHBOR_CMD2 "password LINE",
1494 NEIGHBOR_STR
1495 NEIGHBOR_ADDR_STR2
1496 "Set a password\n"
1497 "The password\n")
1498{
1499 struct peer *peer;
1500 int ret;
1501
1502 peer = peer_and_group_lookup_vty (vty, argv[0]);
1503 if (! peer)
1504 return CMD_WARNING;
1505
1506 ret = peer_password_set (peer, argv[1]);
1507 return bgp_vty_return (vty, ret);
1508}
1509
1510DEFUN (no_neighbor_password,
1511 no_neighbor_password_cmd,
1512 NO_NEIGHBOR_CMD2 "password",
1513 NO_STR
1514 NEIGHBOR_STR
1515 NEIGHBOR_ADDR_STR2
1516 "Set a password\n")
1517{
1518 struct peer *peer;
1519 int ret;
1520
1521 peer = peer_and_group_lookup_vty (vty, argv[0]);
1522 if (! peer)
1523 return CMD_WARNING;
1524
1525 ret = peer_password_unset (peer);
1526 return bgp_vty_return (vty, ret);
1527}
1528
paul718e3742002-12-13 20:15:29 +00001529DEFUN (neighbor_activate,
1530 neighbor_activate_cmd,
1531 NEIGHBOR_CMD2 "activate",
1532 NEIGHBOR_STR
1533 NEIGHBOR_ADDR_STR2
1534 "Enable the Address Family for this Neighbor\n")
1535{
1536 struct peer *peer;
1537
1538 peer = peer_and_group_lookup_vty (vty, argv[0]);
1539 if (! peer)
1540 return CMD_WARNING;
1541
1542 peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
1543
1544 return CMD_SUCCESS;
1545}
1546
1547DEFUN (no_neighbor_activate,
1548 no_neighbor_activate_cmd,
1549 NO_NEIGHBOR_CMD2 "activate",
1550 NO_STR
1551 NEIGHBOR_STR
1552 NEIGHBOR_ADDR_STR2
1553 "Enable the Address Family for this Neighbor\n")
1554{
1555 int ret;
1556 struct peer *peer;
1557
1558 /* Lookup peer. */
1559 peer = peer_and_group_lookup_vty (vty, argv[0]);
1560 if (! peer)
1561 return CMD_WARNING;
1562
1563 ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
1564
1565 return bgp_vty_return (vty, ret);
1566}
1567
1568DEFUN (neighbor_set_peer_group,
1569 neighbor_set_peer_group_cmd,
1570 NEIGHBOR_CMD "peer-group WORD",
1571 NEIGHBOR_STR
1572 NEIGHBOR_ADDR_STR
1573 "Member of the peer-group\n"
1574 "peer-group name\n")
1575{
1576 int ret;
1577 as_t as;
1578 union sockunion su;
1579 struct bgp *bgp;
1580 struct peer_group *group;
1581
1582 bgp = vty->index;
1583
1584 ret = str2sockunion (argv[0], &su);
1585 if (ret < 0)
1586 {
1587 vty_out (vty, "%% Malformed address: %s%s", argv[0], VTY_NEWLINE);
1588 return CMD_WARNING;
1589 }
1590
1591 group = peer_group_lookup (bgp, argv[1]);
1592 if (! group)
1593 {
1594 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
1595 return CMD_WARNING;
1596 }
1597
1598 if (peer_address_self_check (&su))
1599 {
1600 vty_out (vty, "%% Can not configure the local system as neighbor%s",
1601 VTY_NEWLINE);
1602 return CMD_WARNING;
1603 }
1604
1605 ret = peer_group_bind (bgp, &su, group, bgp_node_afi (vty),
1606 bgp_node_safi (vty), &as);
1607
1608 if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT)
1609 {
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04001610 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 +00001611 return CMD_WARNING;
1612 }
1613
1614 return bgp_vty_return (vty, ret);
1615}
1616
1617DEFUN (no_neighbor_set_peer_group,
1618 no_neighbor_set_peer_group_cmd,
1619 NO_NEIGHBOR_CMD "peer-group WORD",
1620 NO_STR
1621 NEIGHBOR_STR
1622 NEIGHBOR_ADDR_STR
1623 "Member of the peer-group\n"
1624 "peer-group name\n")
1625{
1626 int ret;
1627 struct bgp *bgp;
1628 struct peer *peer;
1629 struct peer_group *group;
1630
1631 bgp = vty->index;
1632
1633 peer = peer_lookup_vty (vty, argv[0]);
1634 if (! peer)
1635 return CMD_WARNING;
1636
1637 group = peer_group_lookup (bgp, argv[1]);
1638 if (! group)
1639 {
1640 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
1641 return CMD_WARNING;
1642 }
1643
1644 ret = peer_group_unbind (bgp, peer, group, bgp_node_afi (vty),
1645 bgp_node_safi (vty));
1646
1647 return bgp_vty_return (vty, ret);
1648}
1649
paul94f2b392005-06-28 12:44:16 +00001650static int
paulfd79ac92004-10-13 05:06:08 +00001651peer_flag_modify_vty (struct vty *vty, const char *ip_str,
1652 u_int16_t flag, int set)
paul718e3742002-12-13 20:15:29 +00001653{
1654 int ret;
1655 struct peer *peer;
1656
1657 peer = peer_and_group_lookup_vty (vty, ip_str);
1658 if (! peer)
1659 return CMD_WARNING;
1660
1661 if (set)
1662 ret = peer_flag_set (peer, flag);
1663 else
1664 ret = peer_flag_unset (peer, flag);
1665
1666 return bgp_vty_return (vty, ret);
1667}
1668
paul94f2b392005-06-28 12:44:16 +00001669static int
paulfd79ac92004-10-13 05:06:08 +00001670peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
paul718e3742002-12-13 20:15:29 +00001671{
1672 return peer_flag_modify_vty (vty, ip_str, flag, 1);
1673}
1674
paul94f2b392005-06-28 12:44:16 +00001675static int
paulfd79ac92004-10-13 05:06:08 +00001676peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
paul718e3742002-12-13 20:15:29 +00001677{
1678 return peer_flag_modify_vty (vty, ip_str, flag, 0);
1679}
1680
1681/* neighbor passive. */
1682DEFUN (neighbor_passive,
1683 neighbor_passive_cmd,
1684 NEIGHBOR_CMD2 "passive",
1685 NEIGHBOR_STR
1686 NEIGHBOR_ADDR_STR2
1687 "Don't send open messages to this neighbor\n")
1688{
1689 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_PASSIVE);
1690}
1691
1692DEFUN (no_neighbor_passive,
1693 no_neighbor_passive_cmd,
1694 NO_NEIGHBOR_CMD2 "passive",
1695 NO_STR
1696 NEIGHBOR_STR
1697 NEIGHBOR_ADDR_STR2
1698 "Don't send open messages to this neighbor\n")
1699{
1700 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_PASSIVE);
1701}
1702
1703/* neighbor shutdown. */
1704DEFUN (neighbor_shutdown,
1705 neighbor_shutdown_cmd,
1706 NEIGHBOR_CMD2 "shutdown",
1707 NEIGHBOR_STR
1708 NEIGHBOR_ADDR_STR2
1709 "Administratively shut down this neighbor\n")
1710{
1711 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
1712}
1713
1714DEFUN (no_neighbor_shutdown,
1715 no_neighbor_shutdown_cmd,
1716 NO_NEIGHBOR_CMD2 "shutdown",
1717 NO_STR
1718 NEIGHBOR_STR
1719 NEIGHBOR_ADDR_STR2
1720 "Administratively shut down this neighbor\n")
1721{
1722 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
1723}
1724
hassoc9502432005-02-01 22:01:48 +00001725/* Deprecated neighbor capability route-refresh. */
1726DEFUN_DEPRECATED (neighbor_capability_route_refresh,
1727 neighbor_capability_route_refresh_cmd,
1728 NEIGHBOR_CMD2 "capability route-refresh",
1729 NEIGHBOR_STR
1730 NEIGHBOR_ADDR_STR2
1731 "Advertise capability to the peer\n"
1732 "Advertise route-refresh capability to this neighbor\n")
paul718e3742002-12-13 20:15:29 +00001733{
hassoc9502432005-02-01 22:01:48 +00001734 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00001735}
1736
hassoc9502432005-02-01 22:01:48 +00001737DEFUN_DEPRECATED (no_neighbor_capability_route_refresh,
1738 no_neighbor_capability_route_refresh_cmd,
1739 NO_NEIGHBOR_CMD2 "capability route-refresh",
1740 NO_STR
1741 NEIGHBOR_STR
1742 NEIGHBOR_ADDR_STR2
1743 "Advertise capability to the peer\n"
1744 "Advertise route-refresh capability to this neighbor\n")
paul718e3742002-12-13 20:15:29 +00001745{
hassoc9502432005-02-01 22:01:48 +00001746 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00001747}
1748
1749/* neighbor capability dynamic. */
1750DEFUN (neighbor_capability_dynamic,
1751 neighbor_capability_dynamic_cmd,
1752 NEIGHBOR_CMD2 "capability dynamic",
1753 NEIGHBOR_STR
1754 NEIGHBOR_ADDR_STR2
1755 "Advertise capability to the peer\n"
1756 "Advertise dynamic capability to this neighbor\n")
1757{
1758 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
1759}
1760
1761DEFUN (no_neighbor_capability_dynamic,
1762 no_neighbor_capability_dynamic_cmd,
1763 NO_NEIGHBOR_CMD2 "capability dynamic",
1764 NO_STR
1765 NEIGHBOR_STR
1766 NEIGHBOR_ADDR_STR2
1767 "Advertise capability to the peer\n"
1768 "Advertise dynamic capability to this neighbor\n")
1769{
1770 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
1771}
1772
1773/* neighbor dont-capability-negotiate */
1774DEFUN (neighbor_dont_capability_negotiate,
1775 neighbor_dont_capability_negotiate_cmd,
1776 NEIGHBOR_CMD2 "dont-capability-negotiate",
1777 NEIGHBOR_STR
1778 NEIGHBOR_ADDR_STR2
1779 "Do not perform capability negotiation\n")
1780{
1781 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
1782}
1783
1784DEFUN (no_neighbor_dont_capability_negotiate,
1785 no_neighbor_dont_capability_negotiate_cmd,
1786 NO_NEIGHBOR_CMD2 "dont-capability-negotiate",
1787 NO_STR
1788 NEIGHBOR_STR
1789 NEIGHBOR_ADDR_STR2
1790 "Do not perform capability negotiation\n")
1791{
1792 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
1793}
1794
paul94f2b392005-06-28 12:44:16 +00001795static int
paulfd79ac92004-10-13 05:06:08 +00001796peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi,
paulfee0f4c2004-09-13 05:12:46 +00001797 safi_t safi, u_int32_t flag, int set)
paul718e3742002-12-13 20:15:29 +00001798{
1799 int ret;
1800 struct peer *peer;
1801
1802 peer = peer_and_group_lookup_vty (vty, peer_str);
1803 if (! peer)
1804 return CMD_WARNING;
1805
1806 if (set)
1807 ret = peer_af_flag_set (peer, afi, safi, flag);
1808 else
1809 ret = peer_af_flag_unset (peer, afi, safi, flag);
1810
1811 return bgp_vty_return (vty, ret);
1812}
1813
paul94f2b392005-06-28 12:44:16 +00001814static int
paulfd79ac92004-10-13 05:06:08 +00001815peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi,
paulfee0f4c2004-09-13 05:12:46 +00001816 safi_t safi, u_int32_t flag)
paul718e3742002-12-13 20:15:29 +00001817{
1818 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1);
1819}
1820
paul94f2b392005-06-28 12:44:16 +00001821static int
paulfd79ac92004-10-13 05:06:08 +00001822peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi,
paulfee0f4c2004-09-13 05:12:46 +00001823 safi_t safi, u_int32_t flag)
paul718e3742002-12-13 20:15:29 +00001824{
1825 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0);
1826}
1827
1828/* neighbor capability orf prefix-list. */
1829DEFUN (neighbor_capability_orf_prefix,
1830 neighbor_capability_orf_prefix_cmd,
1831 NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
1832 NEIGHBOR_STR
1833 NEIGHBOR_ADDR_STR2
1834 "Advertise capability to the peer\n"
1835 "Advertise ORF capability to the peer\n"
1836 "Advertise prefixlist ORF capability to this neighbor\n"
1837 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
1838 "Capability to RECEIVE the ORF from this neighbor\n"
1839 "Capability to SEND the ORF to this neighbor\n")
1840{
1841 u_int16_t flag = 0;
1842
1843 if (strncmp (argv[1], "s", 1) == 0)
1844 flag = PEER_FLAG_ORF_PREFIX_SM;
1845 else if (strncmp (argv[1], "r", 1) == 0)
1846 flag = PEER_FLAG_ORF_PREFIX_RM;
1847 else if (strncmp (argv[1], "b", 1) == 0)
1848 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
1849 else
1850 return CMD_WARNING;
1851
1852 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1853 bgp_node_safi (vty), flag);
1854}
1855
1856DEFUN (no_neighbor_capability_orf_prefix,
1857 no_neighbor_capability_orf_prefix_cmd,
1858 NO_NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
1859 NO_STR
1860 NEIGHBOR_STR
1861 NEIGHBOR_ADDR_STR2
1862 "Advertise capability to the peer\n"
1863 "Advertise ORF capability to the peer\n"
1864 "Advertise prefixlist ORF capability to this neighbor\n"
1865 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
1866 "Capability to RECEIVE the ORF from this neighbor\n"
1867 "Capability to SEND the ORF to this neighbor\n")
1868{
1869 u_int16_t flag = 0;
1870
1871 if (strncmp (argv[1], "s", 1) == 0)
1872 flag = PEER_FLAG_ORF_PREFIX_SM;
1873 else if (strncmp (argv[1], "r", 1) == 0)
1874 flag = PEER_FLAG_ORF_PREFIX_RM;
1875 else if (strncmp (argv[1], "b", 1) == 0)
1876 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
1877 else
1878 return CMD_WARNING;
1879
1880 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1881 bgp_node_safi (vty), flag);
1882}
1883
1884/* neighbor next-hop-self. */
1885DEFUN (neighbor_nexthop_self,
1886 neighbor_nexthop_self_cmd,
1887 NEIGHBOR_CMD2 "next-hop-self",
1888 NEIGHBOR_STR
1889 NEIGHBOR_ADDR_STR2
1890 "Disable the next hop calculation for this neighbor\n")
1891{
1892 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1893 bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF);
1894}
1895
1896DEFUN (no_neighbor_nexthop_self,
1897 no_neighbor_nexthop_self_cmd,
1898 NO_NEIGHBOR_CMD2 "next-hop-self",
1899 NO_STR
1900 NEIGHBOR_STR
1901 NEIGHBOR_ADDR_STR2
1902 "Disable the next hop calculation for this neighbor\n")
1903{
1904 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1905 bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF);
1906}
1907
1908/* neighbor remove-private-AS. */
1909DEFUN (neighbor_remove_private_as,
1910 neighbor_remove_private_as_cmd,
1911 NEIGHBOR_CMD2 "remove-private-AS",
1912 NEIGHBOR_STR
1913 NEIGHBOR_ADDR_STR2
1914 "Remove private AS number from outbound updates\n")
1915{
1916 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1917 bgp_node_safi (vty),
1918 PEER_FLAG_REMOVE_PRIVATE_AS);
1919}
1920
1921DEFUN (no_neighbor_remove_private_as,
1922 no_neighbor_remove_private_as_cmd,
1923 NO_NEIGHBOR_CMD2 "remove-private-AS",
1924 NO_STR
1925 NEIGHBOR_STR
1926 NEIGHBOR_ADDR_STR2
1927 "Remove private AS number from outbound updates\n")
1928{
1929 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1930 bgp_node_safi (vty),
1931 PEER_FLAG_REMOVE_PRIVATE_AS);
1932}
1933
1934/* neighbor send-community. */
1935DEFUN (neighbor_send_community,
1936 neighbor_send_community_cmd,
1937 NEIGHBOR_CMD2 "send-community",
1938 NEIGHBOR_STR
1939 NEIGHBOR_ADDR_STR2
1940 "Send Community attribute to this neighbor\n")
1941{
1942 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1943 bgp_node_safi (vty),
1944 PEER_FLAG_SEND_COMMUNITY);
1945}
1946
1947DEFUN (no_neighbor_send_community,
1948 no_neighbor_send_community_cmd,
1949 NO_NEIGHBOR_CMD2 "send-community",
1950 NO_STR
1951 NEIGHBOR_STR
1952 NEIGHBOR_ADDR_STR2
1953 "Send Community attribute to this neighbor\n")
1954{
1955 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1956 bgp_node_safi (vty),
1957 PEER_FLAG_SEND_COMMUNITY);
1958}
1959
1960/* neighbor send-community extended. */
1961DEFUN (neighbor_send_community_type,
1962 neighbor_send_community_type_cmd,
1963 NEIGHBOR_CMD2 "send-community (both|extended|standard)",
1964 NEIGHBOR_STR
1965 NEIGHBOR_ADDR_STR2
1966 "Send Community attribute to this neighbor\n"
1967 "Send Standard and Extended Community attributes\n"
1968 "Send Extended Community attributes\n"
1969 "Send Standard Community attributes\n")
1970{
1971 if (strncmp (argv[1], "s", 1) == 0)
1972 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1973 bgp_node_safi (vty),
1974 PEER_FLAG_SEND_COMMUNITY);
1975 if (strncmp (argv[1], "e", 1) == 0)
1976 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1977 bgp_node_safi (vty),
1978 PEER_FLAG_SEND_EXT_COMMUNITY);
1979
1980 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1981 bgp_node_safi (vty),
1982 (PEER_FLAG_SEND_COMMUNITY|
1983 PEER_FLAG_SEND_EXT_COMMUNITY));
1984}
1985
1986DEFUN (no_neighbor_send_community_type,
1987 no_neighbor_send_community_type_cmd,
1988 NO_NEIGHBOR_CMD2 "send-community (both|extended|standard)",
1989 NO_STR
1990 NEIGHBOR_STR
1991 NEIGHBOR_ADDR_STR2
1992 "Send Community attribute to this neighbor\n"
1993 "Send Standard and Extended Community attributes\n"
1994 "Send Extended Community attributes\n"
1995 "Send Standard Community attributes\n")
1996{
1997 if (strncmp (argv[1], "s", 1) == 0)
1998 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1999 bgp_node_safi (vty),
2000 PEER_FLAG_SEND_COMMUNITY);
2001 if (strncmp (argv[1], "e", 1) == 0)
2002 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2003 bgp_node_safi (vty),
2004 PEER_FLAG_SEND_EXT_COMMUNITY);
2005
2006 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2007 bgp_node_safi (vty),
2008 (PEER_FLAG_SEND_COMMUNITY |
2009 PEER_FLAG_SEND_EXT_COMMUNITY));
2010}
2011
2012/* neighbor soft-reconfig. */
2013DEFUN (neighbor_soft_reconfiguration,
2014 neighbor_soft_reconfiguration_cmd,
2015 NEIGHBOR_CMD2 "soft-reconfiguration inbound",
2016 NEIGHBOR_STR
2017 NEIGHBOR_ADDR_STR2
2018 "Per neighbor soft reconfiguration\n"
2019 "Allow inbound soft reconfiguration for this neighbor\n")
2020{
2021 return peer_af_flag_set_vty (vty, argv[0],
2022 bgp_node_afi (vty), bgp_node_safi (vty),
2023 PEER_FLAG_SOFT_RECONFIG);
2024}
2025
2026DEFUN (no_neighbor_soft_reconfiguration,
2027 no_neighbor_soft_reconfiguration_cmd,
2028 NO_NEIGHBOR_CMD2 "soft-reconfiguration inbound",
2029 NO_STR
2030 NEIGHBOR_STR
2031 NEIGHBOR_ADDR_STR2
2032 "Per neighbor soft reconfiguration\n"
2033 "Allow inbound soft reconfiguration for this neighbor\n")
2034{
2035 return peer_af_flag_unset_vty (vty, argv[0],
2036 bgp_node_afi (vty), bgp_node_safi (vty),
2037 PEER_FLAG_SOFT_RECONFIG);
2038}
2039
2040DEFUN (neighbor_route_reflector_client,
2041 neighbor_route_reflector_client_cmd,
2042 NEIGHBOR_CMD2 "route-reflector-client",
2043 NEIGHBOR_STR
2044 NEIGHBOR_ADDR_STR2
2045 "Configure a neighbor as Route Reflector client\n")
2046{
2047 struct peer *peer;
2048
2049
2050 peer = peer_and_group_lookup_vty (vty, argv[0]);
2051 if (! peer)
2052 return CMD_WARNING;
2053
2054 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2055 bgp_node_safi (vty),
2056 PEER_FLAG_REFLECTOR_CLIENT);
2057}
2058
2059DEFUN (no_neighbor_route_reflector_client,
2060 no_neighbor_route_reflector_client_cmd,
2061 NO_NEIGHBOR_CMD2 "route-reflector-client",
2062 NO_STR
2063 NEIGHBOR_STR
2064 NEIGHBOR_ADDR_STR2
2065 "Configure a neighbor as Route Reflector client\n")
2066{
2067 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2068 bgp_node_safi (vty),
2069 PEER_FLAG_REFLECTOR_CLIENT);
2070}
2071
paul94f2b392005-06-28 12:44:16 +00002072static int
paulfd79ac92004-10-13 05:06:08 +00002073peer_rsclient_set_vty (struct vty *vty, const char *peer_str,
2074 int afi, int safi)
paulfee0f4c2004-09-13 05:12:46 +00002075{
2076 int ret;
2077 struct bgp *bgp;
2078 struct peer *peer;
2079 struct peer_group *group;
paul1eb8ef22005-04-07 07:30:20 +00002080 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00002081 struct bgp_filter *pfilter;
2082 struct bgp_filter *gfilter;
Chris Caputo228da422009-07-18 05:44:03 +00002083 int locked_and_added = 0;
paulfee0f4c2004-09-13 05:12:46 +00002084
2085 bgp = vty->index;
2086
2087 peer = peer_and_group_lookup_vty (vty, peer_str);
2088 if ( ! peer )
2089 return CMD_WARNING;
2090
2091 /* If it is already a RS-Client, don't do anything. */
2092 if ( CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) )
2093 return CMD_SUCCESS;
2094
2095 if ( ! peer_rsclient_active (peer) )
paul200df112005-06-01 11:17:05 +00002096 {
2097 peer = peer_lock (peer); /* rsclient peer list reference */
2098 listnode_add_sort (bgp->rsclient, peer);
Chris Caputo228da422009-07-18 05:44:03 +00002099 locked_and_added = 1;
paul200df112005-06-01 11:17:05 +00002100 }
paulfee0f4c2004-09-13 05:12:46 +00002101
2102 ret = peer_af_flag_set (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
2103 if (ret < 0)
Chris Caputo228da422009-07-18 05:44:03 +00002104 {
2105 if (locked_and_added)
2106 {
2107 listnode_delete (bgp->rsclient, peer);
2108 peer_unlock (peer); /* rsclient peer list reference */
2109 }
2110
2111 return bgp_vty_return (vty, ret);
2112 }
paulfee0f4c2004-09-13 05:12:46 +00002113
Paul Jakma64e580a2006-02-21 01:09:01 +00002114 peer->rib[afi][safi] = bgp_table_init (afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00002115 peer->rib[afi][safi]->type = BGP_TABLE_RSCLIENT;
Chris Caputo228da422009-07-18 05:44:03 +00002116 /* RIB peer reference. Released when table is free'd in bgp_table_free. */
2117 peer->rib[afi][safi]->owner = peer_lock (peer);
paulfee0f4c2004-09-13 05:12:46 +00002118
2119 /* Check for existing 'network' and 'redistribute' routes. */
2120 bgp_check_local_routes_rsclient (peer, afi, safi);
2121
2122 /* Check for routes for peers configured with 'soft-reconfiguration'. */
2123 bgp_soft_reconfig_rsclient (peer, afi, safi);
2124
2125 if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))
2126 {
2127 group = peer->group;
2128 gfilter = &peer->filter[afi][safi];
2129
paul1eb8ef22005-04-07 07:30:20 +00002130 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
paulfee0f4c2004-09-13 05:12:46 +00002131 {
2132 pfilter = &peer->filter[afi][safi];
2133
2134 /* Members of a non-RS-Client group should not be RS-Clients, as that
2135 is checked when the become part of the peer-group */
2136 ret = peer_af_flag_set (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
2137 if (ret < 0)
2138 return bgp_vty_return (vty, ret);
2139
2140 /* Make peer's RIB point to group's RIB. */
2141 peer->rib[afi][safi] = group->conf->rib[afi][safi];
2142
2143 /* Import policy. */
2144 if (pfilter->map[RMAP_IMPORT].name)
2145 free (pfilter->map[RMAP_IMPORT].name);
2146 if (gfilter->map[RMAP_IMPORT].name)
2147 {
2148 pfilter->map[RMAP_IMPORT].name = strdup (gfilter->map[RMAP_IMPORT].name);
2149 pfilter->map[RMAP_IMPORT].map = gfilter->map[RMAP_IMPORT].map;
2150 }
2151 else
2152 {
2153 pfilter->map[RMAP_IMPORT].name = NULL;
2154 pfilter->map[RMAP_IMPORT].map =NULL;
2155 }
2156
2157 /* Export policy. */
2158 if (gfilter->map[RMAP_EXPORT].name && ! pfilter->map[RMAP_EXPORT].name)
2159 {
2160 pfilter->map[RMAP_EXPORT].name = strdup (gfilter->map[RMAP_EXPORT].name);
2161 pfilter->map[RMAP_EXPORT].map = gfilter->map[RMAP_EXPORT].map;
2162 }
2163 }
2164 }
2165 return CMD_SUCCESS;
2166}
2167
paul94f2b392005-06-28 12:44:16 +00002168static int
paulfd79ac92004-10-13 05:06:08 +00002169peer_rsclient_unset_vty (struct vty *vty, const char *peer_str,
2170 int afi, int safi)
paulfee0f4c2004-09-13 05:12:46 +00002171{
2172 int ret;
2173 struct bgp *bgp;
2174 struct peer *peer;
2175 struct peer_group *group;
paul1eb8ef22005-04-07 07:30:20 +00002176 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00002177
2178 bgp = vty->index;
2179
2180 peer = peer_and_group_lookup_vty (vty, peer_str);
2181 if ( ! peer )
2182 return CMD_WARNING;
2183
2184 /* If it is not a RS-Client, don't do anything. */
2185 if ( ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) )
2186 return CMD_SUCCESS;
2187
2188 if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))
2189 {
2190 group = peer->group;
2191
paul1eb8ef22005-04-07 07:30:20 +00002192 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
paulfee0f4c2004-09-13 05:12:46 +00002193 {
2194 ret = peer_af_flag_unset (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
2195 if (ret < 0)
2196 return bgp_vty_return (vty, ret);
2197
2198 peer->rib[afi][safi] = NULL;
2199 }
2200
2201 peer = group->conf;
2202 }
2203
2204 ret = peer_af_flag_unset (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
2205 if (ret < 0)
2206 return bgp_vty_return (vty, ret);
2207
2208 if ( ! peer_rsclient_active (peer) )
paul200df112005-06-01 11:17:05 +00002209 {
Chris Caputo228da422009-07-18 05:44:03 +00002210 bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_MY_RSCLIENT);
paul200df112005-06-01 11:17:05 +00002211 listnode_delete (bgp->rsclient, peer);
Chris Caputo228da422009-07-18 05:44:03 +00002212 peer_unlock (peer); /* peer bgp rsclient reference */
paul200df112005-06-01 11:17:05 +00002213 }
paulfee0f4c2004-09-13 05:12:46 +00002214
Paul Jakmab608d5b2008-07-02 02:12:07 +00002215 bgp_table_finish (&peer->rib[bgp_node_afi(vty)][bgp_node_safi(vty)]);
paulfee0f4c2004-09-13 05:12:46 +00002216
2217 return CMD_SUCCESS;
2218}
2219
paul718e3742002-12-13 20:15:29 +00002220/* neighbor route-server-client. */
2221DEFUN (neighbor_route_server_client,
2222 neighbor_route_server_client_cmd,
2223 NEIGHBOR_CMD2 "route-server-client",
2224 NEIGHBOR_STR
2225 NEIGHBOR_ADDR_STR2
2226 "Configure a neighbor as Route Server client\n")
2227{
paulfee0f4c2004-09-13 05:12:46 +00002228 return peer_rsclient_set_vty (vty, argv[0], bgp_node_afi(vty),
2229 bgp_node_safi(vty));
paul718e3742002-12-13 20:15:29 +00002230}
2231
2232DEFUN (no_neighbor_route_server_client,
2233 no_neighbor_route_server_client_cmd,
2234 NO_NEIGHBOR_CMD2 "route-server-client",
2235 NO_STR
2236 NEIGHBOR_STR
2237 NEIGHBOR_ADDR_STR2
2238 "Configure a neighbor as Route Server client\n")
2239{
paulfee0f4c2004-09-13 05:12:46 +00002240 return peer_rsclient_unset_vty (vty, argv[0], bgp_node_afi(vty),
2241 bgp_node_safi(vty));
2242}
2243
2244DEFUN (neighbor_nexthop_local_unchanged,
2245 neighbor_nexthop_local_unchanged_cmd,
2246 NEIGHBOR_CMD2 "nexthop-local unchanged",
2247 NEIGHBOR_STR
2248 NEIGHBOR_ADDR_STR2
2249 "Configure treatment of outgoing link-local nexthop attribute\n"
2250 "Leave link-local nexthop unchanged for this peer\n")
2251{
2252 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2253 bgp_node_safi (vty),
2254 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
2255}
2256
2257DEFUN (no_neighbor_nexthop_local_unchanged,
2258 no_neighbor_nexthop_local_unchanged_cmd,
2259 NO_NEIGHBOR_CMD2 "nexthop-local unchanged",
2260 NO_STR
2261 NEIGHBOR_STR
2262 NEIGHBOR_ADDR_STR2
2263 "Configure treatment of outgoing link-local-nexthop attribute\n"
2264 "Leave link-local nexthop unchanged for this peer\n")
2265{
paul718e3742002-12-13 20:15:29 +00002266 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2267 bgp_node_safi (vty),
paulfee0f4c2004-09-13 05:12:46 +00002268 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
paul718e3742002-12-13 20:15:29 +00002269}
2270
2271DEFUN (neighbor_attr_unchanged,
2272 neighbor_attr_unchanged_cmd,
2273 NEIGHBOR_CMD2 "attribute-unchanged",
2274 NEIGHBOR_STR
2275 NEIGHBOR_ADDR_STR2
2276 "BGP attribute is propagated unchanged to this neighbor\n")
2277{
2278 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2279 bgp_node_safi (vty),
2280 (PEER_FLAG_AS_PATH_UNCHANGED |
2281 PEER_FLAG_NEXTHOP_UNCHANGED |
2282 PEER_FLAG_MED_UNCHANGED));
2283}
2284
2285DEFUN (neighbor_attr_unchanged1,
2286 neighbor_attr_unchanged1_cmd,
2287 NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
2288 NEIGHBOR_STR
2289 NEIGHBOR_ADDR_STR2
2290 "BGP attribute is propagated unchanged to this neighbor\n"
2291 "As-path attribute\n"
2292 "Nexthop attribute\n"
2293 "Med attribute\n")
2294{
2295 u_int16_t flags = 0;
2296
2297 if (strncmp (argv[1], "as-path", 1) == 0)
2298 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2299 else if (strncmp (argv[1], "next-hop", 1) == 0)
2300 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2301 else if (strncmp (argv[1], "med", 1) == 0)
2302 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2303
2304 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2305 bgp_node_safi (vty), flags);
2306}
2307
2308DEFUN (neighbor_attr_unchanged2,
2309 neighbor_attr_unchanged2_cmd,
2310 NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
2311 NEIGHBOR_STR
2312 NEIGHBOR_ADDR_STR2
2313 "BGP attribute is propagated unchanged to this neighbor\n"
2314 "As-path attribute\n"
2315 "Nexthop attribute\n"
2316 "Med attribute\n")
2317{
2318 u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
2319
2320 if (strncmp (argv[1], "next-hop", 1) == 0)
2321 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2322 else if (strncmp (argv[1], "med", 1) == 0)
2323 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2324
2325 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2326 bgp_node_safi (vty), flags);
2327
2328}
2329
2330DEFUN (neighbor_attr_unchanged3,
2331 neighbor_attr_unchanged3_cmd,
2332 NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
2333 NEIGHBOR_STR
2334 NEIGHBOR_ADDR_STR2
2335 "BGP attribute is propagated unchanged to this neighbor\n"
2336 "Nexthop attribute\n"
2337 "As-path attribute\n"
2338 "Med attribute\n")
2339{
2340 u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
2341
2342 if (strncmp (argv[1], "as-path", 1) == 0)
2343 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2344 else if (strncmp (argv[1], "med", 1) == 0)
2345 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2346
2347 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2348 bgp_node_safi (vty), flags);
2349}
2350
2351DEFUN (neighbor_attr_unchanged4,
2352 neighbor_attr_unchanged4_cmd,
2353 NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
2354 NEIGHBOR_STR
2355 NEIGHBOR_ADDR_STR2
2356 "BGP attribute is propagated unchanged to this neighbor\n"
2357 "Med attribute\n"
2358 "As-path attribute\n"
2359 "Nexthop attribute\n")
2360{
2361 u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
2362
2363 if (strncmp (argv[1], "as-path", 1) == 0)
2364 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2365 else if (strncmp (argv[1], "next-hop", 1) == 0)
2366 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2367
2368 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2369 bgp_node_safi (vty), flags);
2370}
2371
2372ALIAS (neighbor_attr_unchanged,
2373 neighbor_attr_unchanged5_cmd,
2374 NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
2375 NEIGHBOR_STR
2376 NEIGHBOR_ADDR_STR2
2377 "BGP attribute is propagated unchanged to this neighbor\n"
2378 "As-path attribute\n"
2379 "Nexthop attribute\n"
2380 "Med attribute\n")
2381
2382ALIAS (neighbor_attr_unchanged,
2383 neighbor_attr_unchanged6_cmd,
2384 NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
2385 NEIGHBOR_STR
2386 NEIGHBOR_ADDR_STR2
2387 "BGP attribute is propagated unchanged to this neighbor\n"
2388 "As-path attribute\n"
2389 "Med attribute\n"
2390 "Nexthop attribute\n")
2391
2392ALIAS (neighbor_attr_unchanged,
2393 neighbor_attr_unchanged7_cmd,
2394 NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
2395 NEIGHBOR_STR
2396 NEIGHBOR_ADDR_STR2
2397 "BGP attribute is propagated unchanged to this neighbor\n"
2398 "Nexthop attribute\n"
2399 "Med attribute\n"
2400 "As-path attribute\n")
2401
2402ALIAS (neighbor_attr_unchanged,
2403 neighbor_attr_unchanged8_cmd,
2404 NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
2405 NEIGHBOR_STR
2406 NEIGHBOR_ADDR_STR2
2407 "BGP attribute is propagated unchanged to this neighbor\n"
2408 "Nexthop attribute\n"
2409 "As-path attribute\n"
2410 "Med attribute\n")
2411
2412ALIAS (neighbor_attr_unchanged,
2413 neighbor_attr_unchanged9_cmd,
2414 NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
2415 NEIGHBOR_STR
2416 NEIGHBOR_ADDR_STR2
2417 "BGP attribute is propagated unchanged to this neighbor\n"
2418 "Med attribute\n"
2419 "Nexthop attribute\n"
2420 "As-path attribute\n")
2421
2422ALIAS (neighbor_attr_unchanged,
2423 neighbor_attr_unchanged10_cmd,
2424 NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
2425 NEIGHBOR_STR
2426 NEIGHBOR_ADDR_STR2
2427 "BGP attribute is propagated unchanged to this neighbor\n"
2428 "Med attribute\n"
2429 "As-path attribute\n"
2430 "Nexthop attribute\n")
2431
2432DEFUN (no_neighbor_attr_unchanged,
2433 no_neighbor_attr_unchanged_cmd,
2434 NO_NEIGHBOR_CMD2 "attribute-unchanged",
2435 NO_STR
2436 NEIGHBOR_STR
2437 NEIGHBOR_ADDR_STR2
2438 "BGP attribute is propagated unchanged to this neighbor\n")
2439{
2440 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2441 bgp_node_safi (vty),
2442 (PEER_FLAG_AS_PATH_UNCHANGED |
2443 PEER_FLAG_NEXTHOP_UNCHANGED |
2444 PEER_FLAG_MED_UNCHANGED));
2445}
2446
2447DEFUN (no_neighbor_attr_unchanged1,
2448 no_neighbor_attr_unchanged1_cmd,
2449 NO_NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
2450 NO_STR
2451 NEIGHBOR_STR
2452 NEIGHBOR_ADDR_STR2
2453 "BGP attribute is propagated unchanged to this neighbor\n"
2454 "As-path attribute\n"
2455 "Nexthop attribute\n"
2456 "Med attribute\n")
2457{
2458 u_int16_t flags = 0;
2459
2460 if (strncmp (argv[1], "as-path", 1) == 0)
2461 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2462 else if (strncmp (argv[1], "next-hop", 1) == 0)
2463 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2464 else if (strncmp (argv[1], "med", 1) == 0)
2465 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2466
2467 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2468 bgp_node_safi (vty), flags);
2469}
2470
2471DEFUN (no_neighbor_attr_unchanged2,
2472 no_neighbor_attr_unchanged2_cmd,
2473 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
2474 NO_STR
2475 NEIGHBOR_STR
2476 NEIGHBOR_ADDR_STR2
2477 "BGP attribute is propagated unchanged to this neighbor\n"
2478 "As-path attribute\n"
2479 "Nexthop attribute\n"
2480 "Med attribute\n")
2481{
2482 u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
2483
2484 if (strncmp (argv[1], "next-hop", 1) == 0)
2485 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2486 else if (strncmp (argv[1], "med", 1) == 0)
2487 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2488
2489 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2490 bgp_node_safi (vty), flags);
2491}
2492
2493DEFUN (no_neighbor_attr_unchanged3,
2494 no_neighbor_attr_unchanged3_cmd,
2495 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
2496 NO_STR
2497 NEIGHBOR_STR
2498 NEIGHBOR_ADDR_STR2
2499 "BGP attribute is propagated unchanged to this neighbor\n"
2500 "Nexthop attribute\n"
2501 "As-path attribute\n"
2502 "Med attribute\n")
2503{
2504 u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
2505
2506 if (strncmp (argv[1], "as-path", 1) == 0)
2507 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2508 else if (strncmp (argv[1], "med", 1) == 0)
2509 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2510
2511 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2512 bgp_node_safi (vty), flags);
2513}
2514
2515DEFUN (no_neighbor_attr_unchanged4,
2516 no_neighbor_attr_unchanged4_cmd,
2517 NO_NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
2518 NO_STR
2519 NEIGHBOR_STR
2520 NEIGHBOR_ADDR_STR2
2521 "BGP attribute is propagated unchanged to this neighbor\n"
2522 "Med attribute\n"
2523 "As-path attribute\n"
2524 "Nexthop attribute\n")
2525{
2526 u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
2527
2528 if (strncmp (argv[1], "as-path", 1) == 0)
2529 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2530 else if (strncmp (argv[1], "next-hop", 1) == 0)
2531 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2532
2533 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2534 bgp_node_safi (vty), flags);
2535}
2536
2537ALIAS (no_neighbor_attr_unchanged,
2538 no_neighbor_attr_unchanged5_cmd,
2539 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
2540 NO_STR
2541 NEIGHBOR_STR
2542 NEIGHBOR_ADDR_STR2
2543 "BGP attribute is propagated unchanged to this neighbor\n"
2544 "As-path attribute\n"
2545 "Nexthop attribute\n"
2546 "Med attribute\n")
2547
2548ALIAS (no_neighbor_attr_unchanged,
2549 no_neighbor_attr_unchanged6_cmd,
2550 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
2551 NO_STR
2552 NEIGHBOR_STR
2553 NEIGHBOR_ADDR_STR2
2554 "BGP attribute is propagated unchanged to this neighbor\n"
2555 "As-path attribute\n"
2556 "Med attribute\n"
2557 "Nexthop attribute\n")
2558
2559ALIAS (no_neighbor_attr_unchanged,
2560 no_neighbor_attr_unchanged7_cmd,
2561 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
2562 NO_STR
2563 NEIGHBOR_STR
2564 NEIGHBOR_ADDR_STR2
2565 "BGP attribute is propagated unchanged to this neighbor\n"
2566 "Nexthop attribute\n"
2567 "Med attribute\n"
2568 "As-path attribute\n")
2569
2570ALIAS (no_neighbor_attr_unchanged,
2571 no_neighbor_attr_unchanged8_cmd,
2572 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
2573 NO_STR
2574 NEIGHBOR_STR
2575 NEIGHBOR_ADDR_STR2
2576 "BGP attribute is propagated unchanged to this neighbor\n"
2577 "Nexthop attribute\n"
2578 "As-path attribute\n"
2579 "Med attribute\n")
2580
2581ALIAS (no_neighbor_attr_unchanged,
2582 no_neighbor_attr_unchanged9_cmd,
2583 NO_NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
2584 NO_STR
2585 NEIGHBOR_STR
2586 NEIGHBOR_ADDR_STR2
2587 "BGP attribute is propagated unchanged to this neighbor\n"
2588 "Med attribute\n"
2589 "Nexthop attribute\n"
2590 "As-path attribute\n")
2591
2592ALIAS (no_neighbor_attr_unchanged,
2593 no_neighbor_attr_unchanged10_cmd,
2594 NO_NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
2595 NO_STR
2596 NEIGHBOR_STR
2597 NEIGHBOR_ADDR_STR2
2598 "BGP attribute is propagated unchanged to this neighbor\n"
2599 "Med attribute\n"
2600 "As-path attribute\n"
2601 "Nexthop attribute\n")
2602
2603/* For old version Zebra compatibility. */
hassodd4c5932005-02-02 17:15:34 +00002604DEFUN_DEPRECATED (neighbor_transparent_as,
2605 neighbor_transparent_as_cmd,
2606 NEIGHBOR_CMD "transparent-as",
2607 NEIGHBOR_STR
2608 NEIGHBOR_ADDR_STR
2609 "Do not append my AS number even peer is EBGP peer\n")
paul718e3742002-12-13 20:15:29 +00002610{
2611 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2612 bgp_node_safi (vty),
2613 PEER_FLAG_AS_PATH_UNCHANGED);
2614}
2615
hassodd4c5932005-02-02 17:15:34 +00002616DEFUN_DEPRECATED (neighbor_transparent_nexthop,
2617 neighbor_transparent_nexthop_cmd,
2618 NEIGHBOR_CMD "transparent-nexthop",
2619 NEIGHBOR_STR
2620 NEIGHBOR_ADDR_STR
2621 "Do not change nexthop even peer is EBGP peer\n")
paul718e3742002-12-13 20:15:29 +00002622{
2623 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2624 bgp_node_safi (vty),
2625 PEER_FLAG_NEXTHOP_UNCHANGED);
2626}
2627
2628/* EBGP multihop configuration. */
paul94f2b392005-06-28 12:44:16 +00002629static int
paulfd79ac92004-10-13 05:06:08 +00002630peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str,
2631 const char *ttl_str)
paul718e3742002-12-13 20:15:29 +00002632{
2633 struct peer *peer;
paulfd79ac92004-10-13 05:06:08 +00002634 unsigned int ttl;
paul718e3742002-12-13 20:15:29 +00002635
2636 peer = peer_and_group_lookup_vty (vty, ip_str);
2637 if (! peer)
2638 return CMD_WARNING;
2639
2640 if (! ttl_str)
2641 ttl = TTL_MAX;
2642 else
2643 VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, 255);
2644
Stephen Hemminger89b6d1f2011-03-24 10:51:59 +00002645 return bgp_vty_return (vty, peer_ebgp_multihop_set (peer, ttl));
paul718e3742002-12-13 20:15:29 +00002646}
2647
paul94f2b392005-06-28 12:44:16 +00002648static int
paulfd79ac92004-10-13 05:06:08 +00002649peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str)
paul718e3742002-12-13 20:15:29 +00002650{
2651 struct peer *peer;
2652
2653 peer = peer_and_group_lookup_vty (vty, ip_str);
2654 if (! peer)
2655 return CMD_WARNING;
2656
Stephen Hemminger89b6d1f2011-03-24 10:51:59 +00002657 return bgp_vty_return (vty, peer_ebgp_multihop_unset (peer));
paul718e3742002-12-13 20:15:29 +00002658}
2659
2660/* neighbor ebgp-multihop. */
2661DEFUN (neighbor_ebgp_multihop,
2662 neighbor_ebgp_multihop_cmd,
2663 NEIGHBOR_CMD2 "ebgp-multihop",
2664 NEIGHBOR_STR
2665 NEIGHBOR_ADDR_STR2
2666 "Allow EBGP neighbors not on directly connected networks\n")
2667{
2668 return peer_ebgp_multihop_set_vty (vty, argv[0], NULL);
2669}
2670
2671DEFUN (neighbor_ebgp_multihop_ttl,
2672 neighbor_ebgp_multihop_ttl_cmd,
2673 NEIGHBOR_CMD2 "ebgp-multihop <1-255>",
2674 NEIGHBOR_STR
2675 NEIGHBOR_ADDR_STR2
2676 "Allow EBGP neighbors not on directly connected networks\n"
2677 "maximum hop count\n")
2678{
2679 return peer_ebgp_multihop_set_vty (vty, argv[0], argv[1]);
2680}
2681
2682DEFUN (no_neighbor_ebgp_multihop,
2683 no_neighbor_ebgp_multihop_cmd,
2684 NO_NEIGHBOR_CMD2 "ebgp-multihop",
2685 NO_STR
2686 NEIGHBOR_STR
2687 NEIGHBOR_ADDR_STR2
2688 "Allow EBGP neighbors not on directly connected networks\n")
2689{
2690 return peer_ebgp_multihop_unset_vty (vty, argv[0]);
2691}
2692
2693ALIAS (no_neighbor_ebgp_multihop,
2694 no_neighbor_ebgp_multihop_ttl_cmd,
2695 NO_NEIGHBOR_CMD2 "ebgp-multihop <1-255>",
2696 NO_STR
2697 NEIGHBOR_STR
2698 NEIGHBOR_ADDR_STR2
2699 "Allow EBGP neighbors not on directly connected networks\n"
2700 "maximum hop count\n")
2701
hasso6ffd2072005-02-02 14:50:11 +00002702/* disable-connected-check */
2703DEFUN (neighbor_disable_connected_check,
2704 neighbor_disable_connected_check_cmd,
2705 NEIGHBOR_CMD2 "disable-connected-check",
2706 NEIGHBOR_STR
2707 NEIGHBOR_ADDR_STR2
2708 "one-hop away EBGP peer using loopback address\n")
2709{
2710 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
2711}
2712
2713DEFUN (no_neighbor_disable_connected_check,
2714 no_neighbor_disable_connected_check_cmd,
2715 NO_NEIGHBOR_CMD2 "disable-connected-check",
2716 NO_STR
2717 NEIGHBOR_STR
2718 NEIGHBOR_ADDR_STR2
2719 "one-hop away EBGP peer using loopback address\n")
2720{
2721 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
2722}
2723
paul718e3742002-12-13 20:15:29 +00002724/* Enforce multihop. */
hasso6ffd2072005-02-02 14:50:11 +00002725ALIAS (neighbor_disable_connected_check,
paul718e3742002-12-13 20:15:29 +00002726 neighbor_enforce_multihop_cmd,
2727 NEIGHBOR_CMD2 "enforce-multihop",
2728 NEIGHBOR_STR
2729 NEIGHBOR_ADDR_STR2
paule8e19462006-01-19 20:16:55 +00002730 "Enforce EBGP neighbors perform multihop\n")
paul718e3742002-12-13 20:15:29 +00002731
hasso6ffd2072005-02-02 14:50:11 +00002732/* Enforce multihop. */
2733ALIAS (no_neighbor_disable_connected_check,
paul718e3742002-12-13 20:15:29 +00002734 no_neighbor_enforce_multihop_cmd,
2735 NO_NEIGHBOR_CMD2 "enforce-multihop",
2736 NO_STR
2737 NEIGHBOR_STR
2738 NEIGHBOR_ADDR_STR2
paule8e19462006-01-19 20:16:55 +00002739 "Enforce EBGP neighbors perform multihop\n")
paul718e3742002-12-13 20:15:29 +00002740
2741DEFUN (neighbor_description,
2742 neighbor_description_cmd,
2743 NEIGHBOR_CMD2 "description .LINE",
2744 NEIGHBOR_STR
2745 NEIGHBOR_ADDR_STR2
2746 "Neighbor specific description\n"
2747 "Up to 80 characters describing this neighbor\n")
2748{
2749 struct peer *peer;
paul718e3742002-12-13 20:15:29 +00002750 char *str;
paul718e3742002-12-13 20:15:29 +00002751
2752 peer = peer_and_group_lookup_vty (vty, argv[0]);
2753 if (! peer)
2754 return CMD_WARNING;
2755
2756 if (argc == 1)
2757 return CMD_SUCCESS;
2758
ajs3b8b1852005-01-29 18:19:13 +00002759 str = argv_concat(argv, argc, 1);
paul718e3742002-12-13 20:15:29 +00002760
2761 peer_description_set (peer, str);
2762
ajs3b8b1852005-01-29 18:19:13 +00002763 XFREE (MTYPE_TMP, str);
paul718e3742002-12-13 20:15:29 +00002764
2765 return CMD_SUCCESS;
2766}
2767
2768DEFUN (no_neighbor_description,
2769 no_neighbor_description_cmd,
2770 NO_NEIGHBOR_CMD2 "description",
2771 NO_STR
2772 NEIGHBOR_STR
2773 NEIGHBOR_ADDR_STR2
2774 "Neighbor specific description\n")
2775{
2776 struct peer *peer;
2777
2778 peer = peer_and_group_lookup_vty (vty, argv[0]);
2779 if (! peer)
2780 return CMD_WARNING;
2781
2782 peer_description_unset (peer);
2783
2784 return CMD_SUCCESS;
2785}
2786
2787ALIAS (no_neighbor_description,
2788 no_neighbor_description_val_cmd,
2789 NO_NEIGHBOR_CMD2 "description .LINE",
2790 NO_STR
2791 NEIGHBOR_STR
2792 NEIGHBOR_ADDR_STR2
2793 "Neighbor specific description\n"
2794 "Up to 80 characters describing this neighbor\n")
2795
2796/* Neighbor update-source. */
paul94f2b392005-06-28 12:44:16 +00002797static int
paulfd79ac92004-10-13 05:06:08 +00002798peer_update_source_vty (struct vty *vty, const char *peer_str,
2799 const char *source_str)
paul718e3742002-12-13 20:15:29 +00002800{
2801 struct peer *peer;
2802 union sockunion *su;
2803
2804 peer = peer_and_group_lookup_vty (vty, peer_str);
2805 if (! peer)
2806 return CMD_WARNING;
2807
2808 if (source_str)
2809 {
2810 su = sockunion_str2su (source_str);
2811 if (su)
2812 {
2813 peer_update_source_addr_set (peer, su);
2814 sockunion_free (su);
2815 }
2816 else
2817 peer_update_source_if_set (peer, source_str);
2818 }
2819 else
2820 peer_update_source_unset (peer);
2821
2822 return CMD_SUCCESS;
2823}
2824
Paul Jakma9a1a3312009-07-27 12:27:55 +01002825#define BGP_UPDATE_SOURCE_STR "(A.B.C.D|X:X::X:X|WORD)"
Paul Jakma369688c2006-05-23 22:27:55 +00002826#define BGP_UPDATE_SOURCE_HELP_STR \
2827 "IPv4 address\n" \
Paul Jakma9a1a3312009-07-27 12:27:55 +01002828 "IPv6 address\n" \
2829 "Interface name (requires zebra to be running)\n"
Paul Jakma369688c2006-05-23 22:27:55 +00002830
paul718e3742002-12-13 20:15:29 +00002831DEFUN (neighbor_update_source,
2832 neighbor_update_source_cmd,
Paul Jakma369688c2006-05-23 22:27:55 +00002833 NEIGHBOR_CMD2 "update-source " BGP_UPDATE_SOURCE_STR,
paul718e3742002-12-13 20:15:29 +00002834 NEIGHBOR_STR
2835 NEIGHBOR_ADDR_STR2
2836 "Source of routing updates\n"
Paul Jakma369688c2006-05-23 22:27:55 +00002837 BGP_UPDATE_SOURCE_HELP_STR)
paul718e3742002-12-13 20:15:29 +00002838{
2839 return peer_update_source_vty (vty, argv[0], argv[1]);
2840}
2841
2842DEFUN (no_neighbor_update_source,
2843 no_neighbor_update_source_cmd,
2844 NO_NEIGHBOR_CMD2 "update-source",
2845 NO_STR
2846 NEIGHBOR_STR
2847 NEIGHBOR_ADDR_STR2
Paul Jakma369688c2006-05-23 22:27:55 +00002848 "Source of routing updates\n")
paul718e3742002-12-13 20:15:29 +00002849{
2850 return peer_update_source_vty (vty, argv[0], NULL);
2851}
2852
paul94f2b392005-06-28 12:44:16 +00002853static int
paulfd79ac92004-10-13 05:06:08 +00002854peer_default_originate_set_vty (struct vty *vty, const char *peer_str,
2855 afi_t afi, safi_t safi,
2856 const char *rmap, int set)
paul718e3742002-12-13 20:15:29 +00002857{
2858 int ret;
2859 struct peer *peer;
2860
2861 peer = peer_and_group_lookup_vty (vty, peer_str);
2862 if (! peer)
2863 return CMD_WARNING;
2864
2865 if (set)
2866 ret = peer_default_originate_set (peer, afi, safi, rmap);
2867 else
2868 ret = peer_default_originate_unset (peer, afi, safi);
2869
2870 return bgp_vty_return (vty, ret);
2871}
2872
2873/* neighbor default-originate. */
2874DEFUN (neighbor_default_originate,
2875 neighbor_default_originate_cmd,
2876 NEIGHBOR_CMD2 "default-originate",
2877 NEIGHBOR_STR
2878 NEIGHBOR_ADDR_STR2
2879 "Originate default route to this neighbor\n")
2880{
2881 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
2882 bgp_node_safi (vty), NULL, 1);
2883}
2884
2885DEFUN (neighbor_default_originate_rmap,
2886 neighbor_default_originate_rmap_cmd,
2887 NEIGHBOR_CMD2 "default-originate route-map WORD",
2888 NEIGHBOR_STR
2889 NEIGHBOR_ADDR_STR2
2890 "Originate default route to this neighbor\n"
2891 "Route-map to specify criteria to originate default\n"
2892 "route-map name\n")
2893{
2894 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
2895 bgp_node_safi (vty), argv[1], 1);
2896}
2897
2898DEFUN (no_neighbor_default_originate,
2899 no_neighbor_default_originate_cmd,
2900 NO_NEIGHBOR_CMD2 "default-originate",
2901 NO_STR
2902 NEIGHBOR_STR
2903 NEIGHBOR_ADDR_STR2
2904 "Originate default route to this neighbor\n")
2905{
2906 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
2907 bgp_node_safi (vty), NULL, 0);
2908}
2909
2910ALIAS (no_neighbor_default_originate,
2911 no_neighbor_default_originate_rmap_cmd,
2912 NO_NEIGHBOR_CMD2 "default-originate route-map WORD",
2913 NO_STR
2914 NEIGHBOR_STR
2915 NEIGHBOR_ADDR_STR2
2916 "Originate default route to this neighbor\n"
2917 "Route-map to specify criteria to originate default\n"
2918 "route-map name\n")
2919
2920/* Set neighbor's BGP port. */
paul94f2b392005-06-28 12:44:16 +00002921static int
paulfd79ac92004-10-13 05:06:08 +00002922peer_port_vty (struct vty *vty, const char *ip_str, int afi,
2923 const char *port_str)
paul718e3742002-12-13 20:15:29 +00002924{
2925 struct peer *peer;
2926 u_int16_t port;
2927 struct servent *sp;
2928
2929 peer = peer_lookup_vty (vty, ip_str);
2930 if (! peer)
2931 return CMD_WARNING;
2932
2933 if (! port_str)
2934 {
2935 sp = getservbyname ("bgp", "tcp");
2936 port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port);
2937 }
2938 else
2939 {
2940 VTY_GET_INTEGER("port", port, port_str);
2941 }
2942
2943 peer_port_set (peer, port);
2944
2945 return CMD_SUCCESS;
2946}
2947
hassof4184462005-02-01 20:13:16 +00002948/* Set specified peer's BGP port. */
paul718e3742002-12-13 20:15:29 +00002949DEFUN (neighbor_port,
2950 neighbor_port_cmd,
2951 NEIGHBOR_CMD "port <0-65535>",
2952 NEIGHBOR_STR
2953 NEIGHBOR_ADDR_STR
2954 "Neighbor's BGP port\n"
2955 "TCP port number\n")
2956{
2957 return peer_port_vty (vty, argv[0], AFI_IP, argv[1]);
2958}
2959
2960DEFUN (no_neighbor_port,
2961 no_neighbor_port_cmd,
2962 NO_NEIGHBOR_CMD "port",
2963 NO_STR
2964 NEIGHBOR_STR
2965 NEIGHBOR_ADDR_STR
2966 "Neighbor's BGP port\n")
2967{
2968 return peer_port_vty (vty, argv[0], AFI_IP, NULL);
2969}
2970
2971ALIAS (no_neighbor_port,
2972 no_neighbor_port_val_cmd,
2973 NO_NEIGHBOR_CMD "port <0-65535>",
2974 NO_STR
2975 NEIGHBOR_STR
2976 NEIGHBOR_ADDR_STR
2977 "Neighbor's BGP port\n"
2978 "TCP port number\n")
2979
2980/* neighbor weight. */
paul94f2b392005-06-28 12:44:16 +00002981static int
paulfd79ac92004-10-13 05:06:08 +00002982peer_weight_set_vty (struct vty *vty, const char *ip_str,
2983 const char *weight_str)
paul718e3742002-12-13 20:15:29 +00002984{
2985 int ret;
2986 struct peer *peer;
2987 unsigned long weight;
2988
2989 peer = peer_and_group_lookup_vty (vty, ip_str);
2990 if (! peer)
2991 return CMD_WARNING;
2992
2993 VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535);
2994
2995 ret = peer_weight_set (peer, weight);
2996
2997 return CMD_SUCCESS;
2998}
2999
paul94f2b392005-06-28 12:44:16 +00003000static int
paulfd79ac92004-10-13 05:06:08 +00003001peer_weight_unset_vty (struct vty *vty, const char *ip_str)
paul718e3742002-12-13 20:15:29 +00003002{
3003 struct peer *peer;
3004
3005 peer = peer_and_group_lookup_vty (vty, ip_str);
3006 if (! peer)
3007 return CMD_WARNING;
3008
3009 peer_weight_unset (peer);
3010
3011 return CMD_SUCCESS;
3012}
3013
3014DEFUN (neighbor_weight,
3015 neighbor_weight_cmd,
3016 NEIGHBOR_CMD2 "weight <0-65535>",
3017 NEIGHBOR_STR
3018 NEIGHBOR_ADDR_STR2
3019 "Set default weight for routes from this neighbor\n"
3020 "default weight\n")
3021{
3022 return peer_weight_set_vty (vty, argv[0], argv[1]);
3023}
3024
3025DEFUN (no_neighbor_weight,
3026 no_neighbor_weight_cmd,
3027 NO_NEIGHBOR_CMD2 "weight",
3028 NO_STR
3029 NEIGHBOR_STR
3030 NEIGHBOR_ADDR_STR2
3031 "Set default weight for routes from this neighbor\n")
3032{
3033 return peer_weight_unset_vty (vty, argv[0]);
3034}
3035
3036ALIAS (no_neighbor_weight,
3037 no_neighbor_weight_val_cmd,
3038 NO_NEIGHBOR_CMD2 "weight <0-65535>",
3039 NO_STR
3040 NEIGHBOR_STR
3041 NEIGHBOR_ADDR_STR2
3042 "Set default weight for routes from this neighbor\n"
3043 "default weight\n")
3044
3045/* Override capability negotiation. */
3046DEFUN (neighbor_override_capability,
3047 neighbor_override_capability_cmd,
3048 NEIGHBOR_CMD2 "override-capability",
3049 NEIGHBOR_STR
3050 NEIGHBOR_ADDR_STR2
3051 "Override capability negotiation result\n")
3052{
3053 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
3054}
3055
3056DEFUN (no_neighbor_override_capability,
3057 no_neighbor_override_capability_cmd,
3058 NO_NEIGHBOR_CMD2 "override-capability",
3059 NO_STR
3060 NEIGHBOR_STR
3061 NEIGHBOR_ADDR_STR2
3062 "Override capability negotiation result\n")
3063{
3064 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
3065}
3066
3067DEFUN (neighbor_strict_capability,
3068 neighbor_strict_capability_cmd,
3069 NEIGHBOR_CMD "strict-capability-match",
3070 NEIGHBOR_STR
3071 NEIGHBOR_ADDR_STR
3072 "Strict capability negotiation match\n")
3073{
3074 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
3075}
3076
3077DEFUN (no_neighbor_strict_capability,
3078 no_neighbor_strict_capability_cmd,
3079 NO_NEIGHBOR_CMD "strict-capability-match",
3080 NO_STR
3081 NEIGHBOR_STR
3082 NEIGHBOR_ADDR_STR
3083 "Strict capability negotiation match\n")
3084{
3085 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
3086}
3087
paul94f2b392005-06-28 12:44:16 +00003088static int
paulfd79ac92004-10-13 05:06:08 +00003089peer_timers_set_vty (struct vty *vty, const char *ip_str,
3090 const char *keep_str, const char *hold_str)
paul718e3742002-12-13 20:15:29 +00003091{
3092 int ret;
3093 struct peer *peer;
3094 u_int32_t keepalive;
3095 u_int32_t holdtime;
3096
3097 peer = peer_and_group_lookup_vty (vty, ip_str);
3098 if (! peer)
3099 return CMD_WARNING;
3100
3101 VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535);
3102 VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535);
3103
3104 ret = peer_timers_set (peer, keepalive, holdtime);
3105
3106 return bgp_vty_return (vty, ret);
3107}
3108
paul94f2b392005-06-28 12:44:16 +00003109static int
paulfd79ac92004-10-13 05:06:08 +00003110peer_timers_unset_vty (struct vty *vty, const char *ip_str)
paul718e3742002-12-13 20:15:29 +00003111{
3112 int ret;
3113 struct peer *peer;
3114
3115 peer = peer_lookup_vty (vty, ip_str);
3116 if (! peer)
3117 return CMD_WARNING;
3118
3119 ret = peer_timers_unset (peer);
3120
3121 return bgp_vty_return (vty, ret);
3122}
3123
3124DEFUN (neighbor_timers,
3125 neighbor_timers_cmd,
3126 NEIGHBOR_CMD2 "timers <0-65535> <0-65535>",
3127 NEIGHBOR_STR
3128 NEIGHBOR_ADDR_STR2
3129 "BGP per neighbor timers\n"
3130 "Keepalive interval\n"
3131 "Holdtime\n")
3132{
3133 return peer_timers_set_vty (vty, argv[0], argv[1], argv[2]);
3134}
3135
3136DEFUN (no_neighbor_timers,
3137 no_neighbor_timers_cmd,
3138 NO_NEIGHBOR_CMD2 "timers",
3139 NO_STR
3140 NEIGHBOR_STR
3141 NEIGHBOR_ADDR_STR2
3142 "BGP per neighbor timers\n")
3143{
3144 return peer_timers_unset_vty (vty, argv[0]);
3145}
3146
paul94f2b392005-06-28 12:44:16 +00003147static int
paulfd79ac92004-10-13 05:06:08 +00003148peer_timers_connect_set_vty (struct vty *vty, const char *ip_str,
3149 const char *time_str)
paul718e3742002-12-13 20:15:29 +00003150{
3151 int ret;
3152 struct peer *peer;
3153 u_int32_t connect;
3154
3155 peer = peer_lookup_vty (vty, ip_str);
3156 if (! peer)
3157 return CMD_WARNING;
3158
3159 VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535);
3160
3161 ret = peer_timers_connect_set (peer, connect);
3162
3163 return CMD_SUCCESS;
3164}
3165
paul94f2b392005-06-28 12:44:16 +00003166static int
paulfd79ac92004-10-13 05:06:08 +00003167peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str)
paul718e3742002-12-13 20:15:29 +00003168{
3169 int ret;
3170 struct peer *peer;
3171
3172 peer = peer_and_group_lookup_vty (vty, ip_str);
3173 if (! peer)
3174 return CMD_WARNING;
3175
3176 ret = peer_timers_connect_unset (peer);
3177
3178 return CMD_SUCCESS;
3179}
3180
3181DEFUN (neighbor_timers_connect,
3182 neighbor_timers_connect_cmd,
3183 NEIGHBOR_CMD "timers connect <0-65535>",
3184 NEIGHBOR_STR
3185 NEIGHBOR_ADDR_STR
3186 "BGP per neighbor timers\n"
3187 "BGP connect timer\n"
3188 "Connect timer\n")
3189{
3190 return peer_timers_connect_set_vty (vty, argv[0], argv[1]);
3191}
3192
3193DEFUN (no_neighbor_timers_connect,
3194 no_neighbor_timers_connect_cmd,
3195 NO_NEIGHBOR_CMD "timers connect",
3196 NO_STR
3197 NEIGHBOR_STR
3198 NEIGHBOR_ADDR_STR
3199 "BGP per neighbor timers\n"
3200 "BGP connect timer\n")
3201{
3202 return peer_timers_connect_unset_vty (vty, argv[0]);
3203}
3204
3205ALIAS (no_neighbor_timers_connect,
3206 no_neighbor_timers_connect_val_cmd,
3207 NO_NEIGHBOR_CMD "timers connect <0-65535>",
3208 NO_STR
3209 NEIGHBOR_STR
3210 NEIGHBOR_ADDR_STR
3211 "BGP per neighbor timers\n"
3212 "BGP connect timer\n"
3213 "Connect timer\n")
3214
paul94f2b392005-06-28 12:44:16 +00003215static int
paulfd79ac92004-10-13 05:06:08 +00003216peer_advertise_interval_vty (struct vty *vty, const char *ip_str,
3217 const char *time_str, int set)
paul718e3742002-12-13 20:15:29 +00003218{
3219 int ret;
3220 struct peer *peer;
3221 u_int32_t routeadv = 0;
3222
3223 peer = peer_lookup_vty (vty, ip_str);
3224 if (! peer)
3225 return CMD_WARNING;
3226
3227 if (time_str)
3228 VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600);
3229
3230 if (set)
3231 ret = peer_advertise_interval_set (peer, routeadv);
3232 else
3233 ret = peer_advertise_interval_unset (peer);
3234
3235 return CMD_SUCCESS;
3236}
3237
3238DEFUN (neighbor_advertise_interval,
3239 neighbor_advertise_interval_cmd,
3240 NEIGHBOR_CMD "advertisement-interval <0-600>",
3241 NEIGHBOR_STR
3242 NEIGHBOR_ADDR_STR
3243 "Minimum interval between sending BGP routing updates\n"
3244 "time in seconds\n")
3245{
3246 return peer_advertise_interval_vty (vty, argv[0], argv[1], 1);
3247}
3248
3249DEFUN (no_neighbor_advertise_interval,
3250 no_neighbor_advertise_interval_cmd,
3251 NO_NEIGHBOR_CMD "advertisement-interval",
3252 NO_STR
3253 NEIGHBOR_STR
3254 NEIGHBOR_ADDR_STR
3255 "Minimum interval between sending BGP routing updates\n")
3256{
3257 return peer_advertise_interval_vty (vty, argv[0], NULL, 0);
3258}
3259
3260ALIAS (no_neighbor_advertise_interval,
3261 no_neighbor_advertise_interval_val_cmd,
3262 NO_NEIGHBOR_CMD "advertisement-interval <0-600>",
3263 NO_STR
3264 NEIGHBOR_STR
3265 NEIGHBOR_ADDR_STR
3266 "Minimum interval between sending BGP routing updates\n"
3267 "time in seconds\n")
3268
paul718e3742002-12-13 20:15:29 +00003269/* neighbor interface */
paul94f2b392005-06-28 12:44:16 +00003270static int
paulfd79ac92004-10-13 05:06:08 +00003271peer_interface_vty (struct vty *vty, const char *ip_str, const char *str)
paul718e3742002-12-13 20:15:29 +00003272{
3273 int ret;
3274 struct peer *peer;
3275
3276 peer = peer_lookup_vty (vty, ip_str);
3277 if (! peer)
3278 return CMD_WARNING;
3279
3280 if (str)
3281 ret = peer_interface_set (peer, str);
3282 else
3283 ret = peer_interface_unset (peer);
3284
3285 return CMD_SUCCESS;
3286}
3287
3288DEFUN (neighbor_interface,
3289 neighbor_interface_cmd,
3290 NEIGHBOR_CMD "interface WORD",
3291 NEIGHBOR_STR
3292 NEIGHBOR_ADDR_STR
3293 "Interface\n"
3294 "Interface name\n")
3295{
3296 return peer_interface_vty (vty, argv[0], argv[1]);
3297}
3298
3299DEFUN (no_neighbor_interface,
3300 no_neighbor_interface_cmd,
3301 NO_NEIGHBOR_CMD "interface WORD",
3302 NO_STR
3303 NEIGHBOR_STR
3304 NEIGHBOR_ADDR_STR
3305 "Interface\n"
3306 "Interface name\n")
3307{
3308 return peer_interface_vty (vty, argv[0], NULL);
3309}
3310
3311/* Set distribute list to the peer. */
paul94f2b392005-06-28 12:44:16 +00003312static int
paulfd79ac92004-10-13 05:06:08 +00003313peer_distribute_set_vty (struct vty *vty, const char *ip_str,
3314 afi_t afi, safi_t safi,
3315 const char *name_str, const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003316{
3317 int ret;
3318 struct peer *peer;
3319 int direct = FILTER_IN;
3320
3321 peer = peer_and_group_lookup_vty (vty, ip_str);
3322 if (! peer)
3323 return CMD_WARNING;
3324
3325 /* Check filter direction. */
3326 if (strncmp (direct_str, "i", 1) == 0)
3327 direct = FILTER_IN;
3328 else if (strncmp (direct_str, "o", 1) == 0)
3329 direct = FILTER_OUT;
3330
3331 ret = peer_distribute_set (peer, afi, safi, direct, name_str);
3332
3333 return bgp_vty_return (vty, ret);
3334}
3335
paul94f2b392005-06-28 12:44:16 +00003336static int
paulfd79ac92004-10-13 05:06:08 +00003337peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
3338 safi_t safi, const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003339{
3340 int ret;
3341 struct peer *peer;
3342 int direct = FILTER_IN;
3343
3344 peer = peer_and_group_lookup_vty (vty, ip_str);
3345 if (! peer)
3346 return CMD_WARNING;
3347
3348 /* Check filter direction. */
3349 if (strncmp (direct_str, "i", 1) == 0)
3350 direct = FILTER_IN;
3351 else if (strncmp (direct_str, "o", 1) == 0)
3352 direct = FILTER_OUT;
3353
3354 ret = peer_distribute_unset (peer, afi, safi, direct);
3355
3356 return bgp_vty_return (vty, ret);
3357}
3358
3359DEFUN (neighbor_distribute_list,
3360 neighbor_distribute_list_cmd,
3361 NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
3362 NEIGHBOR_STR
3363 NEIGHBOR_ADDR_STR2
3364 "Filter updates to/from this neighbor\n"
3365 "IP access-list number\n"
3366 "IP access-list number (expanded range)\n"
3367 "IP Access-list name\n"
3368 "Filter incoming updates\n"
3369 "Filter outgoing updates\n")
3370{
3371 return peer_distribute_set_vty (vty, argv[0], bgp_node_afi (vty),
3372 bgp_node_safi (vty), argv[1], argv[2]);
3373}
3374
3375DEFUN (no_neighbor_distribute_list,
3376 no_neighbor_distribute_list_cmd,
3377 NO_NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
3378 NO_STR
3379 NEIGHBOR_STR
3380 NEIGHBOR_ADDR_STR2
3381 "Filter updates to/from this neighbor\n"
3382 "IP access-list number\n"
3383 "IP access-list number (expanded range)\n"
3384 "IP Access-list name\n"
3385 "Filter incoming updates\n"
3386 "Filter outgoing updates\n")
3387{
3388 return peer_distribute_unset_vty (vty, argv[0], bgp_node_afi (vty),
3389 bgp_node_safi (vty), argv[2]);
3390}
3391
3392/* Set prefix list to the peer. */
paul94f2b392005-06-28 12:44:16 +00003393static int
paulfd79ac92004-10-13 05:06:08 +00003394peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
3395 safi_t safi, const char *name_str,
3396 const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003397{
3398 int ret;
3399 struct peer *peer;
3400 int direct = FILTER_IN;
3401
3402 peer = peer_and_group_lookup_vty (vty, ip_str);
3403 if (! peer)
3404 return CMD_WARNING;
3405
3406 /* Check filter direction. */
3407 if (strncmp (direct_str, "i", 1) == 0)
3408 direct = FILTER_IN;
3409 else if (strncmp (direct_str, "o", 1) == 0)
3410 direct = FILTER_OUT;
3411
3412 ret = peer_prefix_list_set (peer, afi, safi, direct, name_str);
3413
3414 return bgp_vty_return (vty, ret);
3415}
3416
paul94f2b392005-06-28 12:44:16 +00003417static int
paulfd79ac92004-10-13 05:06:08 +00003418peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
3419 safi_t safi, const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003420{
3421 int ret;
3422 struct peer *peer;
3423 int direct = FILTER_IN;
3424
3425 peer = peer_and_group_lookup_vty (vty, ip_str);
3426 if (! peer)
3427 return CMD_WARNING;
3428
3429 /* Check filter direction. */
3430 if (strncmp (direct_str, "i", 1) == 0)
3431 direct = FILTER_IN;
3432 else if (strncmp (direct_str, "o", 1) == 0)
3433 direct = FILTER_OUT;
3434
3435 ret = peer_prefix_list_unset (peer, afi, safi, direct);
3436
3437 return bgp_vty_return (vty, ret);
3438}
3439
3440DEFUN (neighbor_prefix_list,
3441 neighbor_prefix_list_cmd,
3442 NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
3443 NEIGHBOR_STR
3444 NEIGHBOR_ADDR_STR2
3445 "Filter updates to/from this neighbor\n"
3446 "Name of a prefix list\n"
3447 "Filter incoming updates\n"
3448 "Filter outgoing updates\n")
3449{
3450 return peer_prefix_list_set_vty (vty, argv[0], bgp_node_afi (vty),
3451 bgp_node_safi (vty), argv[1], argv[2]);
3452}
3453
3454DEFUN (no_neighbor_prefix_list,
3455 no_neighbor_prefix_list_cmd,
3456 NO_NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
3457 NO_STR
3458 NEIGHBOR_STR
3459 NEIGHBOR_ADDR_STR2
3460 "Filter updates to/from this neighbor\n"
3461 "Name of a prefix list\n"
3462 "Filter incoming updates\n"
3463 "Filter outgoing updates\n")
3464{
3465 return peer_prefix_list_unset_vty (vty, argv[0], bgp_node_afi (vty),
3466 bgp_node_safi (vty), argv[2]);
3467}
3468
paul94f2b392005-06-28 12:44:16 +00003469static int
paulfd79ac92004-10-13 05:06:08 +00003470peer_aslist_set_vty (struct vty *vty, const char *ip_str,
3471 afi_t afi, safi_t safi,
3472 const char *name_str, const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003473{
3474 int ret;
3475 struct peer *peer;
3476 int direct = FILTER_IN;
3477
3478 peer = peer_and_group_lookup_vty (vty, ip_str);
3479 if (! peer)
3480 return CMD_WARNING;
3481
3482 /* Check filter direction. */
3483 if (strncmp (direct_str, "i", 1) == 0)
3484 direct = FILTER_IN;
3485 else if (strncmp (direct_str, "o", 1) == 0)
3486 direct = FILTER_OUT;
3487
3488 ret = peer_aslist_set (peer, afi, safi, direct, name_str);
3489
3490 return bgp_vty_return (vty, ret);
3491}
3492
paul94f2b392005-06-28 12:44:16 +00003493static int
paulfd79ac92004-10-13 05:06:08 +00003494peer_aslist_unset_vty (struct vty *vty, const char *ip_str,
3495 afi_t afi, safi_t safi,
3496 const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003497{
3498 int ret;
3499 struct peer *peer;
3500 int direct = FILTER_IN;
3501
3502 peer = peer_and_group_lookup_vty (vty, ip_str);
3503 if (! peer)
3504 return CMD_WARNING;
3505
3506 /* Check filter direction. */
3507 if (strncmp (direct_str, "i", 1) == 0)
3508 direct = FILTER_IN;
3509 else if (strncmp (direct_str, "o", 1) == 0)
3510 direct = FILTER_OUT;
3511
3512 ret = peer_aslist_unset (peer, afi, safi, direct);
3513
3514 return bgp_vty_return (vty, ret);
3515}
3516
3517DEFUN (neighbor_filter_list,
3518 neighbor_filter_list_cmd,
3519 NEIGHBOR_CMD2 "filter-list WORD (in|out)",
3520 NEIGHBOR_STR
3521 NEIGHBOR_ADDR_STR2
3522 "Establish BGP filters\n"
3523 "AS path access-list name\n"
3524 "Filter incoming routes\n"
3525 "Filter outgoing routes\n")
3526{
3527 return peer_aslist_set_vty (vty, argv[0], bgp_node_afi (vty),
3528 bgp_node_safi (vty), argv[1], argv[2]);
3529}
3530
3531DEFUN (no_neighbor_filter_list,
3532 no_neighbor_filter_list_cmd,
3533 NO_NEIGHBOR_CMD2 "filter-list WORD (in|out)",
3534 NO_STR
3535 NEIGHBOR_STR
3536 NEIGHBOR_ADDR_STR2
3537 "Establish BGP filters\n"
3538 "AS path access-list name\n"
3539 "Filter incoming routes\n"
3540 "Filter outgoing routes\n")
3541{
3542 return peer_aslist_unset_vty (vty, argv[0], bgp_node_afi (vty),
3543 bgp_node_safi (vty), argv[2]);
3544}
3545
3546/* Set route-map to the peer. */
paul94f2b392005-06-28 12:44:16 +00003547static int
paulfd79ac92004-10-13 05:06:08 +00003548peer_route_map_set_vty (struct vty *vty, const char *ip_str,
3549 afi_t afi, safi_t safi,
3550 const char *name_str, const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003551{
3552 int ret;
3553 struct peer *peer;
paulfee0f4c2004-09-13 05:12:46 +00003554 int direct = RMAP_IN;
paul718e3742002-12-13 20:15:29 +00003555
3556 peer = peer_and_group_lookup_vty (vty, ip_str);
3557 if (! peer)
3558 return CMD_WARNING;
3559
3560 /* Check filter direction. */
paulfee0f4c2004-09-13 05:12:46 +00003561 if (strncmp (direct_str, "in", 2) == 0)
3562 direct = RMAP_IN;
paul718e3742002-12-13 20:15:29 +00003563 else if (strncmp (direct_str, "o", 1) == 0)
paulfee0f4c2004-09-13 05:12:46 +00003564 direct = RMAP_OUT;
3565 else if (strncmp (direct_str, "im", 2) == 0)
3566 direct = RMAP_IMPORT;
3567 else if (strncmp (direct_str, "e", 1) == 0)
3568 direct = RMAP_EXPORT;
paul718e3742002-12-13 20:15:29 +00003569
3570 ret = peer_route_map_set (peer, afi, safi, direct, name_str);
3571
3572 return bgp_vty_return (vty, ret);
3573}
3574
paul94f2b392005-06-28 12:44:16 +00003575static int
paulfd79ac92004-10-13 05:06:08 +00003576peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
3577 safi_t safi, const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003578{
3579 int ret;
3580 struct peer *peer;
paulfee0f4c2004-09-13 05:12:46 +00003581 int direct = RMAP_IN;
paul718e3742002-12-13 20:15:29 +00003582
3583 peer = peer_and_group_lookup_vty (vty, ip_str);
3584 if (! peer)
3585 return CMD_WARNING;
3586
3587 /* Check filter direction. */
paulfee0f4c2004-09-13 05:12:46 +00003588 if (strncmp (direct_str, "in", 2) == 0)
3589 direct = RMAP_IN;
paul718e3742002-12-13 20:15:29 +00003590 else if (strncmp (direct_str, "o", 1) == 0)
paulfee0f4c2004-09-13 05:12:46 +00003591 direct = RMAP_OUT;
3592 else if (strncmp (direct_str, "im", 2) == 0)
3593 direct = RMAP_IMPORT;
3594 else if (strncmp (direct_str, "e", 1) == 0)
3595 direct = RMAP_EXPORT;
paul718e3742002-12-13 20:15:29 +00003596
3597 ret = peer_route_map_unset (peer, afi, safi, direct);
3598
3599 return bgp_vty_return (vty, ret);
3600}
3601
3602DEFUN (neighbor_route_map,
3603 neighbor_route_map_cmd,
paulfee0f4c2004-09-13 05:12:46 +00003604 NEIGHBOR_CMD2 "route-map WORD (in|out|import|export)",
paul718e3742002-12-13 20:15:29 +00003605 NEIGHBOR_STR
3606 NEIGHBOR_ADDR_STR2
3607 "Apply route map to neighbor\n"
3608 "Name of route map\n"
3609 "Apply map to incoming routes\n"
paulfee0f4c2004-09-13 05:12:46 +00003610 "Apply map to outbound routes\n"
3611 "Apply map to routes going into a Route-Server client's table\n"
3612 "Apply map to routes coming from a Route-Server client")
paul718e3742002-12-13 20:15:29 +00003613{
3614 return peer_route_map_set_vty (vty, argv[0], bgp_node_afi (vty),
3615 bgp_node_safi (vty), argv[1], argv[2]);
3616}
3617
3618DEFUN (no_neighbor_route_map,
3619 no_neighbor_route_map_cmd,
paulfee0f4c2004-09-13 05:12:46 +00003620 NO_NEIGHBOR_CMD2 "route-map WORD (in|out|import|export)",
paul718e3742002-12-13 20:15:29 +00003621 NO_STR
3622 NEIGHBOR_STR
3623 NEIGHBOR_ADDR_STR2
3624 "Apply route map to neighbor\n"
3625 "Name of route map\n"
3626 "Apply map to incoming routes\n"
paulfee0f4c2004-09-13 05:12:46 +00003627 "Apply map to outbound routes\n"
3628 "Apply map to routes going into a Route-Server client's table\n"
3629 "Apply map to routes coming from a Route-Server client")
paul718e3742002-12-13 20:15:29 +00003630{
3631 return peer_route_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
3632 bgp_node_safi (vty), argv[2]);
3633}
3634
3635/* Set unsuppress-map to the peer. */
paul94f2b392005-06-28 12:44:16 +00003636static int
paulfd79ac92004-10-13 05:06:08 +00003637peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
3638 safi_t safi, const char *name_str)
paul718e3742002-12-13 20:15:29 +00003639{
3640 int ret;
3641 struct peer *peer;
3642
3643 peer = peer_and_group_lookup_vty (vty, ip_str);
3644 if (! peer)
3645 return CMD_WARNING;
3646
3647 ret = peer_unsuppress_map_set (peer, afi, safi, name_str);
3648
3649 return bgp_vty_return (vty, ret);
3650}
3651
3652/* Unset route-map from the peer. */
paul94f2b392005-06-28 12:44:16 +00003653static int
paulfd79ac92004-10-13 05:06:08 +00003654peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00003655 safi_t safi)
3656{
3657 int ret;
3658 struct peer *peer;
3659
3660 peer = peer_and_group_lookup_vty (vty, ip_str);
3661 if (! peer)
3662 return CMD_WARNING;
3663
3664 ret = peer_unsuppress_map_unset (peer, afi, safi);
3665
3666 return bgp_vty_return (vty, ret);
3667}
3668
3669DEFUN (neighbor_unsuppress_map,
3670 neighbor_unsuppress_map_cmd,
3671 NEIGHBOR_CMD2 "unsuppress-map WORD",
3672 NEIGHBOR_STR
3673 NEIGHBOR_ADDR_STR2
3674 "Route-map to selectively unsuppress suppressed routes\n"
3675 "Name of route map\n")
3676{
3677 return peer_unsuppress_map_set_vty (vty, argv[0], bgp_node_afi (vty),
3678 bgp_node_safi (vty), argv[1]);
3679}
3680
3681DEFUN (no_neighbor_unsuppress_map,
3682 no_neighbor_unsuppress_map_cmd,
3683 NO_NEIGHBOR_CMD2 "unsuppress-map WORD",
3684 NO_STR
3685 NEIGHBOR_STR
3686 NEIGHBOR_ADDR_STR2
3687 "Route-map to selectively unsuppress suppressed routes\n"
3688 "Name of route map\n")
3689{
3690 return peer_unsuppress_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
3691 bgp_node_safi (vty));
3692}
3693
paul94f2b392005-06-28 12:44:16 +00003694static int
paulfd79ac92004-10-13 05:06:08 +00003695peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
3696 safi_t safi, const char *num_str,
hasso0a486e52005-02-01 20:57:17 +00003697 const char *threshold_str, int warning,
3698 const char *restart_str)
paul718e3742002-12-13 20:15:29 +00003699{
3700 int ret;
3701 struct peer *peer;
3702 u_int32_t max;
hassoe0701b72004-05-20 09:19:34 +00003703 u_char threshold;
hasso0a486e52005-02-01 20:57:17 +00003704 u_int16_t restart;
paul718e3742002-12-13 20:15:29 +00003705
3706 peer = peer_and_group_lookup_vty (vty, ip_str);
3707 if (! peer)
3708 return CMD_WARNING;
3709
Denis Ovsienkoe6ec1c32011-09-10 21:50:53 +04003710 VTY_GET_INTEGER ("maximum number", max, num_str);
hassoe0701b72004-05-20 09:19:34 +00003711 if (threshold_str)
3712 threshold = atoi (threshold_str);
3713 else
3714 threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003715
hasso0a486e52005-02-01 20:57:17 +00003716 if (restart_str)
3717 restart = atoi (restart_str);
3718 else
3719 restart = 0;
3720
3721 ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart);
paul718e3742002-12-13 20:15:29 +00003722
3723 return bgp_vty_return (vty, ret);
3724}
3725
paul94f2b392005-06-28 12:44:16 +00003726static int
paulfd79ac92004-10-13 05:06:08 +00003727peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00003728 safi_t safi)
3729{
3730 int ret;
3731 struct peer *peer;
3732
3733 peer = peer_and_group_lookup_vty (vty, ip_str);
3734 if (! peer)
3735 return CMD_WARNING;
3736
3737 ret = peer_maximum_prefix_unset (peer, afi, safi);
3738
3739 return bgp_vty_return (vty, ret);
3740}
3741
3742/* Maximum number of prefix configuration. prefix count is different
3743 for each peer configuration. So this configuration can be set for
3744 each peer configuration. */
3745DEFUN (neighbor_maximum_prefix,
3746 neighbor_maximum_prefix_cmd,
3747 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
3748 NEIGHBOR_STR
3749 NEIGHBOR_ADDR_STR2
3750 "Maximum number of prefix accept from this peer\n"
3751 "maximum no. of prefix limit\n")
3752{
3753 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
hasso0a486e52005-02-01 20:57:17 +00003754 bgp_node_safi (vty), argv[1], NULL, 0,
3755 NULL);
paul718e3742002-12-13 20:15:29 +00003756}
3757
hassoe0701b72004-05-20 09:19:34 +00003758DEFUN (neighbor_maximum_prefix_threshold,
3759 neighbor_maximum_prefix_threshold_cmd,
3760 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100>",
3761 NEIGHBOR_STR
3762 NEIGHBOR_ADDR_STR2
3763 "Maximum number of prefix accept from this peer\n"
3764 "maximum no. of prefix limit\n"
3765 "Threshold value (%) at which to generate a warning msg\n")
3766{
3767 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
hasso0a486e52005-02-01 20:57:17 +00003768 bgp_node_safi (vty), argv[1], argv[2], 0,
3769 NULL);
3770}
hassoe0701b72004-05-20 09:19:34 +00003771
paul718e3742002-12-13 20:15:29 +00003772DEFUN (neighbor_maximum_prefix_warning,
3773 neighbor_maximum_prefix_warning_cmd,
3774 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
3775 NEIGHBOR_STR
3776 NEIGHBOR_ADDR_STR2
3777 "Maximum number of prefix accept from this peer\n"
3778 "maximum no. of prefix limit\n"
3779 "Only give warning message when limit is exceeded\n")
3780{
3781 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
hasso0a486e52005-02-01 20:57:17 +00003782 bgp_node_safi (vty), argv[1], NULL, 1,
3783 NULL);
paul718e3742002-12-13 20:15:29 +00003784}
3785
hassoe0701b72004-05-20 09:19:34 +00003786DEFUN (neighbor_maximum_prefix_threshold_warning,
3787 neighbor_maximum_prefix_threshold_warning_cmd,
3788 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
3789 NEIGHBOR_STR
3790 NEIGHBOR_ADDR_STR2
3791 "Maximum number of prefix accept from this peer\n"
3792 "maximum no. of prefix limit\n"
3793 "Threshold value (%) at which to generate a warning msg\n"
3794 "Only give warning message when limit is exceeded\n")
3795{
3796 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
hasso0a486e52005-02-01 20:57:17 +00003797 bgp_node_safi (vty), argv[1], argv[2], 1, NULL);
3798}
3799
3800DEFUN (neighbor_maximum_prefix_restart,
3801 neighbor_maximum_prefix_restart_cmd,
3802 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
3803 NEIGHBOR_STR
3804 NEIGHBOR_ADDR_STR2
3805 "Maximum number of prefix accept from this peer\n"
3806 "maximum no. of prefix limit\n"
3807 "Restart bgp connection after limit is exceeded\n"
3808 "Restart interval in minutes")
3809{
3810 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
3811 bgp_node_safi (vty), argv[1], NULL, 0, argv[2]);
3812}
3813
3814DEFUN (neighbor_maximum_prefix_threshold_restart,
3815 neighbor_maximum_prefix_threshold_restart_cmd,
3816 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
3817 NEIGHBOR_STR
3818 NEIGHBOR_ADDR_STR2
3819 "Maximum number of prefix accept from this peer\n"
3820 "maximum no. of prefix limit\n"
3821 "Threshold value (%) at which to generate a warning msg\n"
3822 "Restart bgp connection after limit is exceeded\n"
3823 "Restart interval in minutes")
3824{
3825 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
3826 bgp_node_safi (vty), argv[1], argv[2], 0, argv[3]);
3827}
hassoe0701b72004-05-20 09:19:34 +00003828
paul718e3742002-12-13 20:15:29 +00003829DEFUN (no_neighbor_maximum_prefix,
3830 no_neighbor_maximum_prefix_cmd,
3831 NO_NEIGHBOR_CMD2 "maximum-prefix",
3832 NO_STR
3833 NEIGHBOR_STR
3834 NEIGHBOR_ADDR_STR2
3835 "Maximum number of prefix accept from this peer\n")
3836{
3837 return peer_maximum_prefix_unset_vty (vty, argv[0], bgp_node_afi (vty),
3838 bgp_node_safi (vty));
3839}
3840
3841ALIAS (no_neighbor_maximum_prefix,
3842 no_neighbor_maximum_prefix_val_cmd,
3843 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
3844 NO_STR
3845 NEIGHBOR_STR
3846 NEIGHBOR_ADDR_STR2
3847 "Maximum number of prefix accept from this peer\n"
3848 "maximum no. of prefix limit\n")
3849
3850ALIAS (no_neighbor_maximum_prefix,
hasso0a486e52005-02-01 20:57:17 +00003851 no_neighbor_maximum_prefix_threshold_cmd,
3852 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
3853 NO_STR
3854 NEIGHBOR_STR
3855 NEIGHBOR_ADDR_STR2
3856 "Maximum number of prefix accept from this peer\n"
3857 "maximum no. of prefix limit\n"
3858 "Threshold value (%) at which to generate a warning msg\n")
3859
3860ALIAS (no_neighbor_maximum_prefix,
3861 no_neighbor_maximum_prefix_warning_cmd,
3862 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
3863 NO_STR
3864 NEIGHBOR_STR
3865 NEIGHBOR_ADDR_STR2
3866 "Maximum number of prefix accept from this peer\n"
3867 "maximum no. of prefix limit\n"
paule8e19462006-01-19 20:16:55 +00003868 "Only give warning message when limit is exceeded\n")
hasso0a486e52005-02-01 20:57:17 +00003869
3870ALIAS (no_neighbor_maximum_prefix,
3871 no_neighbor_maximum_prefix_threshold_warning_cmd,
hassoe0701b72004-05-20 09:19:34 +00003872 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
3873 NO_STR
3874 NEIGHBOR_STR
3875 NEIGHBOR_ADDR_STR2
3876 "Maximum number of prefix accept from this peer\n"
3877 "maximum no. of prefix limit\n"
3878 "Threshold value (%) at which to generate a warning msg\n"
paule8e19462006-01-19 20:16:55 +00003879 "Only give warning message when limit is exceeded\n")
hassoe0701b72004-05-20 09:19:34 +00003880
3881ALIAS (no_neighbor_maximum_prefix,
hasso0a486e52005-02-01 20:57:17 +00003882 no_neighbor_maximum_prefix_restart_cmd,
3883 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
paul718e3742002-12-13 20:15:29 +00003884 NO_STR
3885 NEIGHBOR_STR
3886 NEIGHBOR_ADDR_STR2
3887 "Maximum number of prefix accept from this peer\n"
3888 "maximum no. of prefix limit\n"
hasso0a486e52005-02-01 20:57:17 +00003889 "Restart bgp connection after limit is exceeded\n"
3890 "Restart interval in minutes")
3891
3892ALIAS (no_neighbor_maximum_prefix,
3893 no_neighbor_maximum_prefix_threshold_restart_cmd,
3894 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
3895 NO_STR
3896 NEIGHBOR_STR
3897 NEIGHBOR_ADDR_STR2
3898 "Maximum number of prefix accept from this peer\n"
3899 "maximum no. of prefix limit\n"
3900 "Threshold value (%) at which to generate a warning msg\n"
3901 "Restart bgp connection after limit is exceeded\n"
3902 "Restart interval in minutes")
paul718e3742002-12-13 20:15:29 +00003903
3904/* "neighbor allowas-in" */
3905DEFUN (neighbor_allowas_in,
3906 neighbor_allowas_in_cmd,
3907 NEIGHBOR_CMD2 "allowas-in",
3908 NEIGHBOR_STR
3909 NEIGHBOR_ADDR_STR2
3910 "Accept as-path with my AS present in it\n")
3911{
3912 int ret;
3913 struct peer *peer;
paulfd79ac92004-10-13 05:06:08 +00003914 unsigned int allow_num;
paul718e3742002-12-13 20:15:29 +00003915
3916 peer = peer_and_group_lookup_vty (vty, argv[0]);
3917 if (! peer)
3918 return CMD_WARNING;
3919
3920 if (argc == 1)
3921 allow_num = 3;
3922 else
3923 VTY_GET_INTEGER_RANGE ("AS number", allow_num, argv[1], 1, 10);
3924
3925 ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty),
3926 allow_num);
3927
3928 return bgp_vty_return (vty, ret);
3929}
3930
3931ALIAS (neighbor_allowas_in,
3932 neighbor_allowas_in_arg_cmd,
3933 NEIGHBOR_CMD2 "allowas-in <1-10>",
3934 NEIGHBOR_STR
3935 NEIGHBOR_ADDR_STR2
3936 "Accept as-path with my AS present in it\n"
3937 "Number of occurances of AS number\n")
3938
3939DEFUN (no_neighbor_allowas_in,
3940 no_neighbor_allowas_in_cmd,
3941 NO_NEIGHBOR_CMD2 "allowas-in",
3942 NO_STR
3943 NEIGHBOR_STR
3944 NEIGHBOR_ADDR_STR2
3945 "allow local ASN appears in aspath attribute\n")
3946{
3947 int ret;
3948 struct peer *peer;
3949
3950 peer = peer_and_group_lookup_vty (vty, argv[0]);
3951 if (! peer)
3952 return CMD_WARNING;
3953
3954 ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty));
3955
3956 return bgp_vty_return (vty, ret);
3957}
3958
Nick Hilliardfa411a22011-03-23 15:33:17 +00003959DEFUN (neighbor_ttl_security,
3960 neighbor_ttl_security_cmd,
3961 NEIGHBOR_CMD2 "ttl-security hops <1-254>",
3962 NEIGHBOR_STR
3963 NEIGHBOR_ADDR_STR2
3964 "Specify the maximum number of hops to the BGP peer\n")
3965{
3966 struct peer *peer;
Stephen Hemminger89b6d1f2011-03-24 10:51:59 +00003967 int gtsm_hops;
Nick Hilliardfa411a22011-03-23 15:33:17 +00003968
3969 peer = peer_and_group_lookup_vty (vty, argv[0]);
3970 if (! peer)
3971 return CMD_WARNING;
3972
3973 VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[1], 1, 254);
3974
Stephen Hemminger89b6d1f2011-03-24 10:51:59 +00003975 return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, gtsm_hops));
Nick Hilliardfa411a22011-03-23 15:33:17 +00003976}
3977
3978DEFUN (no_neighbor_ttl_security,
3979 no_neighbor_ttl_security_cmd,
3980 NO_NEIGHBOR_CMD2 "ttl-security hops <1-254>",
3981 NO_STR
3982 NEIGHBOR_STR
3983 NEIGHBOR_ADDR_STR2
3984 "Specify the maximum number of hops to the BGP peer\n")
3985{
3986 struct peer *peer;
Nick Hilliardfa411a22011-03-23 15:33:17 +00003987
3988 peer = peer_and_group_lookup_vty (vty, argv[0]);
3989 if (! peer)
3990 return CMD_WARNING;
3991
Stephen Hemminger89b6d1f2011-03-24 10:51:59 +00003992 return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer));
Nick Hilliardfa411a22011-03-23 15:33:17 +00003993}
3994
paul718e3742002-12-13 20:15:29 +00003995/* Address family configuration. */
3996DEFUN (address_family_ipv4,
3997 address_family_ipv4_cmd,
3998 "address-family ipv4",
3999 "Enter Address Family command mode\n"
4000 "Address family\n")
4001{
4002 vty->node = BGP_IPV4_NODE;
4003 return CMD_SUCCESS;
4004}
4005
4006DEFUN (address_family_ipv4_safi,
4007 address_family_ipv4_safi_cmd,
4008 "address-family ipv4 (unicast|multicast)",
4009 "Enter Address Family command mode\n"
4010 "Address family\n"
4011 "Address Family modifier\n"
4012 "Address Family modifier\n")
4013{
4014 if (strncmp (argv[0], "m", 1) == 0)
4015 vty->node = BGP_IPV4M_NODE;
4016 else
4017 vty->node = BGP_IPV4_NODE;
4018
4019 return CMD_SUCCESS;
4020}
4021
paul25ffbdc2005-08-22 22:42:08 +00004022DEFUN (address_family_ipv6,
4023 address_family_ipv6_cmd,
4024 "address-family ipv6",
paul718e3742002-12-13 20:15:29 +00004025 "Enter Address Family command mode\n"
paul25ffbdc2005-08-22 22:42:08 +00004026 "Address family\n")
paul718e3742002-12-13 20:15:29 +00004027{
4028 vty->node = BGP_IPV6_NODE;
4029 return CMD_SUCCESS;
4030}
4031
paul25ffbdc2005-08-22 22:42:08 +00004032DEFUN (address_family_ipv6_safi,
4033 address_family_ipv6_safi_cmd,
4034 "address-family ipv6 (unicast|multicast)",
paul718e3742002-12-13 20:15:29 +00004035 "Enter Address Family command mode\n"
paul25ffbdc2005-08-22 22:42:08 +00004036 "Address family\n"
4037 "Address Family modifier\n"
4038 "Address Family modifier\n")
4039{
4040 if (strncmp (argv[0], "m", 1) == 0)
4041 vty->node = BGP_IPV6M_NODE;
4042 else
4043 vty->node = BGP_IPV6_NODE;
4044
4045 return CMD_SUCCESS;
4046}
paul718e3742002-12-13 20:15:29 +00004047
4048DEFUN (address_family_vpnv4,
4049 address_family_vpnv4_cmd,
4050 "address-family vpnv4",
4051 "Enter Address Family command mode\n"
4052 "Address family\n")
4053{
4054 vty->node = BGP_VPNV4_NODE;
4055 return CMD_SUCCESS;
4056}
4057
4058ALIAS (address_family_vpnv4,
4059 address_family_vpnv4_unicast_cmd,
4060 "address-family vpnv4 unicast",
4061 "Enter Address Family command mode\n"
4062 "Address family\n"
4063 "Address Family Modifier\n")
4064
4065DEFUN (exit_address_family,
4066 exit_address_family_cmd,
4067 "exit-address-family",
4068 "Exit from Address Family configuration mode\n")
4069{
hassoa8a80d52005-04-09 13:07:47 +00004070 if (vty->node == BGP_IPV4_NODE
4071 || vty->node == BGP_IPV4M_NODE
paul718e3742002-12-13 20:15:29 +00004072 || vty->node == BGP_VPNV4_NODE
paul25ffbdc2005-08-22 22:42:08 +00004073 || vty->node == BGP_IPV6_NODE
4074 || vty->node == BGP_IPV6M_NODE)
paul718e3742002-12-13 20:15:29 +00004075 vty->node = BGP_NODE;
4076 return CMD_SUCCESS;
4077}
4078
4079/* BGP clear sort. */
4080enum clear_sort
4081{
4082 clear_all,
4083 clear_peer,
4084 clear_group,
4085 clear_external,
4086 clear_as
4087};
4088
paul94f2b392005-06-28 12:44:16 +00004089static void
paul718e3742002-12-13 20:15:29 +00004090bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi,
4091 safi_t safi, int error)
4092{
4093 switch (error)
4094 {
4095 case BGP_ERR_AF_UNCONFIGURED:
4096 vty_out (vty,
4097 "%%BGP: Enable %s %s address family for the neighbor %s%s",
4098 afi == AFI_IP6 ? "IPv6" : safi == SAFI_MPLS_VPN ? "VPNv4" : "IPv4",
4099 safi == SAFI_MULTICAST ? "Multicast" : "Unicast",
4100 peer->host, VTY_NEWLINE);
4101 break;
4102 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED:
4103 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);
4104 break;
4105 default:
4106 break;
4107 }
4108}
4109
4110/* `clear ip bgp' functions. */
paul94f2b392005-06-28 12:44:16 +00004111static int
paul718e3742002-12-13 20:15:29 +00004112bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
paulfd79ac92004-10-13 05:06:08 +00004113 enum clear_sort sort,enum bgp_clear_type stype, const char *arg)
paul718e3742002-12-13 20:15:29 +00004114{
4115 int ret;
4116 struct peer *peer;
paul1eb8ef22005-04-07 07:30:20 +00004117 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00004118
4119 /* Clear all neighbors. */
4120 if (sort == clear_all)
4121 {
paul1eb8ef22005-04-07 07:30:20 +00004122 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00004123 {
4124 if (stype == BGP_CLEAR_SOFT_NONE)
4125 ret = peer_clear (peer);
4126 else
4127 ret = peer_clear_soft (peer, afi, safi, stype);
4128
4129 if (ret < 0)
4130 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4131 }
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004132 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00004133 }
4134
4135 /* Clear specified neighbors. */
4136 if (sort == clear_peer)
4137 {
4138 union sockunion su;
4139 int ret;
4140
4141 /* Make sockunion for lookup. */
4142 ret = str2sockunion (arg, &su);
4143 if (ret < 0)
4144 {
4145 vty_out (vty, "Malformed address: %s%s", arg, VTY_NEWLINE);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004146 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +00004147 }
4148 peer = peer_lookup (bgp, &su);
4149 if (! peer)
4150 {
4151 vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004152 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +00004153 }
4154
4155 if (stype == BGP_CLEAR_SOFT_NONE)
4156 ret = peer_clear (peer);
4157 else
4158 ret = peer_clear_soft (peer, afi, safi, stype);
4159
4160 if (ret < 0)
4161 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4162
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004163 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00004164 }
4165
4166 /* Clear all peer-group members. */
4167 if (sort == clear_group)
4168 {
4169 struct peer_group *group;
4170
4171 group = peer_group_lookup (bgp, arg);
4172 if (! group)
4173 {
4174 vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004175 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +00004176 }
4177
paul1eb8ef22005-04-07 07:30:20 +00004178 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00004179 {
4180 if (stype == BGP_CLEAR_SOFT_NONE)
4181 {
4182 ret = peer_clear (peer);
4183 continue;
4184 }
4185
4186 if (! peer->af_group[afi][safi])
4187 continue;
4188
4189 ret = peer_clear_soft (peer, afi, safi, stype);
4190
4191 if (ret < 0)
4192 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4193 }
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004194 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00004195 }
4196
4197 if (sort == clear_external)
4198 {
paul1eb8ef22005-04-07 07:30:20 +00004199 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00004200 {
4201 if (peer_sort (peer) == BGP_PEER_IBGP)
4202 continue;
4203
4204 if (stype == BGP_CLEAR_SOFT_NONE)
4205 ret = peer_clear (peer);
4206 else
4207 ret = peer_clear_soft (peer, afi, safi, stype);
4208
4209 if (ret < 0)
4210 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4211 }
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004212 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00004213 }
4214
4215 if (sort == clear_as)
4216 {
4217 as_t as;
paul718e3742002-12-13 20:15:29 +00004218 int find = 0;
4219
Ulrich Weberbde12e32011-11-16 19:32:12 +04004220 VTY_GET_INTEGER_RANGE ("AS", as, arg, 1, BGP_AS4_MAX);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004221
paul1eb8ef22005-04-07 07:30:20 +00004222 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00004223 {
4224 if (peer->as != as)
4225 continue;
4226
4227 find = 1;
4228 if (stype == BGP_CLEAR_SOFT_NONE)
4229 ret = peer_clear (peer);
4230 else
4231 ret = peer_clear_soft (peer, afi, safi, stype);
4232
4233 if (ret < 0)
4234 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4235 }
4236 if (! find)
4237 vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg,
4238 VTY_NEWLINE);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004239 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00004240 }
4241
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004242 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00004243}
4244
paul94f2b392005-06-28 12:44:16 +00004245static int
paulfd79ac92004-10-13 05:06:08 +00004246bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi,
4247 enum clear_sort sort, enum bgp_clear_type stype,
4248 const char *arg)
paul718e3742002-12-13 20:15:29 +00004249{
paul718e3742002-12-13 20:15:29 +00004250 struct bgp *bgp;
4251
4252 /* BGP structure lookup. */
4253 if (name)
4254 {
4255 bgp = bgp_lookup_by_name (name);
4256 if (bgp == NULL)
4257 {
4258 vty_out (vty, "Can't find BGP view %s%s", name, VTY_NEWLINE);
4259 return CMD_WARNING;
4260 }
4261 }
4262 else
4263 {
4264 bgp = bgp_get_default ();
4265 if (bgp == NULL)
4266 {
4267 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
4268 return CMD_WARNING;
4269 }
4270 }
4271
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004272 return bgp_clear (vty, bgp, afi, safi, sort, stype, arg);
paul718e3742002-12-13 20:15:29 +00004273}
4274
4275DEFUN (clear_ip_bgp_all,
4276 clear_ip_bgp_all_cmd,
4277 "clear ip bgp *",
4278 CLEAR_STR
4279 IP_STR
4280 BGP_STR
4281 "Clear all peers\n")
4282{
4283 if (argc == 1)
4284 return bgp_clear_vty (vty, argv[0], 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
4285
4286 return bgp_clear_vty (vty, NULL, 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
4287}
4288
4289ALIAS (clear_ip_bgp_all,
4290 clear_bgp_all_cmd,
4291 "clear bgp *",
4292 CLEAR_STR
4293 BGP_STR
4294 "Clear all peers\n")
4295
4296ALIAS (clear_ip_bgp_all,
4297 clear_bgp_ipv6_all_cmd,
4298 "clear bgp ipv6 *",
4299 CLEAR_STR
4300 BGP_STR
4301 "Address family\n"
4302 "Clear all peers\n")
4303
4304ALIAS (clear_ip_bgp_all,
4305 clear_ip_bgp_instance_all_cmd,
4306 "clear ip bgp view WORD *",
4307 CLEAR_STR
4308 IP_STR
4309 BGP_STR
4310 "BGP view\n"
4311 "view name\n"
4312 "Clear all peers\n")
4313
4314ALIAS (clear_ip_bgp_all,
4315 clear_bgp_instance_all_cmd,
4316 "clear bgp view WORD *",
4317 CLEAR_STR
4318 BGP_STR
4319 "BGP view\n"
4320 "view name\n"
4321 "Clear all peers\n")
4322
4323DEFUN (clear_ip_bgp_peer,
4324 clear_ip_bgp_peer_cmd,
4325 "clear ip bgp (A.B.C.D|X:X::X:X)",
4326 CLEAR_STR
4327 IP_STR
4328 BGP_STR
4329 "BGP neighbor IP address to clear\n"
4330 "BGP IPv6 neighbor to clear\n")
4331{
4332 return bgp_clear_vty (vty, NULL, 0, 0, clear_peer, BGP_CLEAR_SOFT_NONE, argv[0]);
4333}
4334
4335ALIAS (clear_ip_bgp_peer,
4336 clear_bgp_peer_cmd,
4337 "clear bgp (A.B.C.D|X:X::X:X)",
4338 CLEAR_STR
4339 BGP_STR
4340 "BGP neighbor address to clear\n"
4341 "BGP IPv6 neighbor to clear\n")
4342
4343ALIAS (clear_ip_bgp_peer,
4344 clear_bgp_ipv6_peer_cmd,
4345 "clear bgp ipv6 (A.B.C.D|X:X::X:X)",
4346 CLEAR_STR
4347 BGP_STR
4348 "Address family\n"
4349 "BGP neighbor address to clear\n"
4350 "BGP IPv6 neighbor to clear\n")
4351
4352DEFUN (clear_ip_bgp_peer_group,
4353 clear_ip_bgp_peer_group_cmd,
4354 "clear ip bgp peer-group WORD",
4355 CLEAR_STR
4356 IP_STR
4357 BGP_STR
4358 "Clear all members of peer-group\n"
4359 "BGP peer-group name\n")
4360{
4361 return bgp_clear_vty (vty, NULL, 0, 0, clear_group, BGP_CLEAR_SOFT_NONE, argv[0]);
4362}
4363
4364ALIAS (clear_ip_bgp_peer_group,
4365 clear_bgp_peer_group_cmd,
4366 "clear bgp peer-group WORD",
4367 CLEAR_STR
4368 BGP_STR
4369 "Clear all members of peer-group\n"
4370 "BGP peer-group name\n")
4371
4372ALIAS (clear_ip_bgp_peer_group,
4373 clear_bgp_ipv6_peer_group_cmd,
4374 "clear bgp ipv6 peer-group WORD",
4375 CLEAR_STR
4376 BGP_STR
4377 "Address family\n"
4378 "Clear all members of peer-group\n"
4379 "BGP peer-group name\n")
4380
4381DEFUN (clear_ip_bgp_external,
4382 clear_ip_bgp_external_cmd,
4383 "clear ip bgp external",
4384 CLEAR_STR
4385 IP_STR
4386 BGP_STR
4387 "Clear all external peers\n")
4388{
4389 return bgp_clear_vty (vty, NULL, 0, 0, clear_external, BGP_CLEAR_SOFT_NONE, NULL);
4390}
4391
4392ALIAS (clear_ip_bgp_external,
4393 clear_bgp_external_cmd,
4394 "clear bgp external",
4395 CLEAR_STR
4396 BGP_STR
4397 "Clear all external peers\n")
4398
4399ALIAS (clear_ip_bgp_external,
4400 clear_bgp_ipv6_external_cmd,
4401 "clear bgp ipv6 external",
4402 CLEAR_STR
4403 BGP_STR
4404 "Address family\n"
4405 "Clear all external peers\n")
4406
4407DEFUN (clear_ip_bgp_as,
4408 clear_ip_bgp_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004409 "clear ip bgp " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00004410 CLEAR_STR
4411 IP_STR
4412 BGP_STR
4413 "Clear peers with the AS number\n")
4414{
4415 return bgp_clear_vty (vty, NULL, 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[0]);
4416}
4417
4418ALIAS (clear_ip_bgp_as,
4419 clear_bgp_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004420 "clear bgp " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00004421 CLEAR_STR
4422 BGP_STR
4423 "Clear peers with the AS number\n")
4424
4425ALIAS (clear_ip_bgp_as,
4426 clear_bgp_ipv6_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004427 "clear bgp ipv6 " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00004428 CLEAR_STR
4429 BGP_STR
4430 "Address family\n"
4431 "Clear peers with the AS number\n")
4432
4433/* Outbound soft-reconfiguration */
4434DEFUN (clear_ip_bgp_all_soft_out,
4435 clear_ip_bgp_all_soft_out_cmd,
4436 "clear ip bgp * soft out",
4437 CLEAR_STR
4438 IP_STR
4439 BGP_STR
4440 "Clear all peers\n"
4441 "Soft reconfig\n"
4442 "Soft reconfig outbound update\n")
4443{
4444 if (argc == 1)
4445 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
4446 BGP_CLEAR_SOFT_OUT, NULL);
4447
4448 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
4449 BGP_CLEAR_SOFT_OUT, NULL);
4450}
4451
4452ALIAS (clear_ip_bgp_all_soft_out,
4453 clear_ip_bgp_all_out_cmd,
4454 "clear ip bgp * out",
4455 CLEAR_STR
4456 IP_STR
4457 BGP_STR
4458 "Clear all peers\n"
4459 "Soft reconfig outbound update\n")
4460
4461ALIAS (clear_ip_bgp_all_soft_out,
4462 clear_ip_bgp_instance_all_soft_out_cmd,
4463 "clear ip bgp view WORD * soft out",
4464 CLEAR_STR
4465 IP_STR
4466 BGP_STR
4467 "BGP view\n"
4468 "view name\n"
4469 "Clear all peers\n"
4470 "Soft reconfig\n"
4471 "Soft reconfig outbound update\n")
4472
4473DEFUN (clear_ip_bgp_all_ipv4_soft_out,
4474 clear_ip_bgp_all_ipv4_soft_out_cmd,
4475 "clear ip bgp * ipv4 (unicast|multicast) soft out",
4476 CLEAR_STR
4477 IP_STR
4478 BGP_STR
4479 "Clear all peers\n"
4480 "Address family\n"
4481 "Address Family modifier\n"
4482 "Address Family modifier\n"
4483 "Soft reconfig\n"
4484 "Soft reconfig outbound update\n")
4485{
4486 if (strncmp (argv[0], "m", 1) == 0)
4487 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
4488 BGP_CLEAR_SOFT_OUT, NULL);
4489
4490 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
4491 BGP_CLEAR_SOFT_OUT, NULL);
4492}
4493
4494ALIAS (clear_ip_bgp_all_ipv4_soft_out,
4495 clear_ip_bgp_all_ipv4_out_cmd,
4496 "clear ip bgp * ipv4 (unicast|multicast) out",
4497 CLEAR_STR
4498 IP_STR
4499 BGP_STR
4500 "Clear all peers\n"
4501 "Address family\n"
4502 "Address Family modifier\n"
4503 "Address Family modifier\n"
4504 "Soft reconfig outbound update\n")
4505
4506DEFUN (clear_ip_bgp_instance_all_ipv4_soft_out,
4507 clear_ip_bgp_instance_all_ipv4_soft_out_cmd,
4508 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft out",
4509 CLEAR_STR
4510 IP_STR
4511 BGP_STR
4512 "BGP view\n"
4513 "view name\n"
4514 "Clear all peers\n"
4515 "Address family\n"
4516 "Address Family modifier\n"
4517 "Address Family modifier\n"
4518 "Soft reconfig outbound update\n")
4519{
4520 if (strncmp (argv[1], "m", 1) == 0)
4521 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
4522 BGP_CLEAR_SOFT_OUT, NULL);
4523
4524 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
4525 BGP_CLEAR_SOFT_OUT, NULL);
4526}
4527
4528DEFUN (clear_ip_bgp_all_vpnv4_soft_out,
4529 clear_ip_bgp_all_vpnv4_soft_out_cmd,
4530 "clear ip bgp * vpnv4 unicast soft out",
4531 CLEAR_STR
4532 IP_STR
4533 BGP_STR
4534 "Clear all peers\n"
4535 "Address family\n"
4536 "Address Family Modifier\n"
4537 "Soft reconfig\n"
4538 "Soft reconfig outbound update\n")
4539{
4540 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
4541 BGP_CLEAR_SOFT_OUT, NULL);
4542}
4543
4544ALIAS (clear_ip_bgp_all_vpnv4_soft_out,
4545 clear_ip_bgp_all_vpnv4_out_cmd,
4546 "clear ip bgp * vpnv4 unicast out",
4547 CLEAR_STR
4548 IP_STR
4549 BGP_STR
4550 "Clear all peers\n"
4551 "Address family\n"
4552 "Address Family Modifier\n"
4553 "Soft reconfig outbound update\n")
4554
4555DEFUN (clear_bgp_all_soft_out,
4556 clear_bgp_all_soft_out_cmd,
4557 "clear bgp * soft out",
4558 CLEAR_STR
4559 BGP_STR
4560 "Clear all peers\n"
4561 "Soft reconfig\n"
4562 "Soft reconfig outbound update\n")
4563{
4564 if (argc == 1)
4565 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
4566 BGP_CLEAR_SOFT_OUT, NULL);
4567
4568 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
4569 BGP_CLEAR_SOFT_OUT, NULL);
4570}
4571
4572ALIAS (clear_bgp_all_soft_out,
4573 clear_bgp_instance_all_soft_out_cmd,
4574 "clear bgp view WORD * soft out",
4575 CLEAR_STR
4576 BGP_STR
4577 "BGP view\n"
4578 "view name\n"
4579 "Clear all peers\n"
4580 "Soft reconfig\n"
4581 "Soft reconfig outbound update\n")
4582
4583ALIAS (clear_bgp_all_soft_out,
4584 clear_bgp_all_out_cmd,
4585 "clear bgp * out",
4586 CLEAR_STR
4587 BGP_STR
4588 "Clear all peers\n"
4589 "Soft reconfig outbound update\n")
4590
4591ALIAS (clear_bgp_all_soft_out,
4592 clear_bgp_ipv6_all_soft_out_cmd,
4593 "clear bgp ipv6 * soft out",
4594 CLEAR_STR
4595 BGP_STR
4596 "Address family\n"
4597 "Clear all peers\n"
4598 "Soft reconfig\n"
4599 "Soft reconfig outbound update\n")
4600
4601ALIAS (clear_bgp_all_soft_out,
4602 clear_bgp_ipv6_all_out_cmd,
4603 "clear bgp ipv6 * out",
4604 CLEAR_STR
4605 BGP_STR
4606 "Address family\n"
4607 "Clear all peers\n"
4608 "Soft reconfig outbound update\n")
4609
4610DEFUN (clear_ip_bgp_peer_soft_out,
4611 clear_ip_bgp_peer_soft_out_cmd,
4612 "clear ip bgp A.B.C.D soft out",
4613 CLEAR_STR
4614 IP_STR
4615 BGP_STR
4616 "BGP neighbor address to clear\n"
4617 "Soft reconfig\n"
4618 "Soft reconfig outbound update\n")
4619{
4620 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
4621 BGP_CLEAR_SOFT_OUT, argv[0]);
4622}
4623
4624ALIAS (clear_ip_bgp_peer_soft_out,
4625 clear_ip_bgp_peer_out_cmd,
4626 "clear ip bgp A.B.C.D out",
4627 CLEAR_STR
4628 IP_STR
4629 BGP_STR
4630 "BGP neighbor address to clear\n"
4631 "Soft reconfig outbound update\n")
4632
4633DEFUN (clear_ip_bgp_peer_ipv4_soft_out,
4634 clear_ip_bgp_peer_ipv4_soft_out_cmd,
4635 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft out",
4636 CLEAR_STR
4637 IP_STR
4638 BGP_STR
4639 "BGP neighbor address to clear\n"
4640 "Address family\n"
4641 "Address Family modifier\n"
4642 "Address Family modifier\n"
4643 "Soft reconfig\n"
4644 "Soft reconfig outbound update\n")
4645{
4646 if (strncmp (argv[1], "m", 1) == 0)
4647 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
4648 BGP_CLEAR_SOFT_OUT, argv[0]);
4649
4650 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
4651 BGP_CLEAR_SOFT_OUT, argv[0]);
4652}
4653
4654ALIAS (clear_ip_bgp_peer_ipv4_soft_out,
4655 clear_ip_bgp_peer_ipv4_out_cmd,
4656 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) out",
4657 CLEAR_STR
4658 IP_STR
4659 BGP_STR
4660 "BGP neighbor address to clear\n"
4661 "Address family\n"
4662 "Address Family modifier\n"
4663 "Address Family modifier\n"
4664 "Soft reconfig outbound update\n")
4665
4666DEFUN (clear_ip_bgp_peer_vpnv4_soft_out,
4667 clear_ip_bgp_peer_vpnv4_soft_out_cmd,
4668 "clear ip bgp A.B.C.D vpnv4 unicast soft out",
4669 CLEAR_STR
4670 IP_STR
4671 BGP_STR
4672 "BGP neighbor address to clear\n"
4673 "Address family\n"
4674 "Address Family Modifier\n"
4675 "Soft reconfig\n"
4676 "Soft reconfig outbound update\n")
4677{
4678 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
4679 BGP_CLEAR_SOFT_OUT, argv[0]);
4680}
4681
4682ALIAS (clear_ip_bgp_peer_vpnv4_soft_out,
4683 clear_ip_bgp_peer_vpnv4_out_cmd,
4684 "clear ip bgp A.B.C.D vpnv4 unicast out",
4685 CLEAR_STR
4686 IP_STR
4687 BGP_STR
4688 "BGP neighbor address to clear\n"
4689 "Address family\n"
4690 "Address Family Modifier\n"
4691 "Soft reconfig outbound update\n")
4692
4693DEFUN (clear_bgp_peer_soft_out,
4694 clear_bgp_peer_soft_out_cmd,
4695 "clear bgp (A.B.C.D|X:X::X:X) soft out",
4696 CLEAR_STR
4697 BGP_STR
4698 "BGP neighbor address to clear\n"
4699 "BGP IPv6 neighbor to clear\n"
4700 "Soft reconfig\n"
4701 "Soft reconfig outbound update\n")
4702{
4703 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
4704 BGP_CLEAR_SOFT_OUT, argv[0]);
4705}
4706
4707ALIAS (clear_bgp_peer_soft_out,
4708 clear_bgp_ipv6_peer_soft_out_cmd,
4709 "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft out",
4710 CLEAR_STR
4711 BGP_STR
4712 "Address family\n"
4713 "BGP neighbor address to clear\n"
4714 "BGP IPv6 neighbor to clear\n"
4715 "Soft reconfig\n"
4716 "Soft reconfig outbound update\n")
4717
4718ALIAS (clear_bgp_peer_soft_out,
4719 clear_bgp_peer_out_cmd,
4720 "clear bgp (A.B.C.D|X:X::X:X) out",
4721 CLEAR_STR
4722 BGP_STR
4723 "BGP neighbor address to clear\n"
4724 "BGP IPv6 neighbor to clear\n"
4725 "Soft reconfig outbound update\n")
4726
4727ALIAS (clear_bgp_peer_soft_out,
4728 clear_bgp_ipv6_peer_out_cmd,
4729 "clear bgp ipv6 (A.B.C.D|X:X::X:X) out",
4730 CLEAR_STR
4731 BGP_STR
4732 "Address family\n"
4733 "BGP neighbor address to clear\n"
4734 "BGP IPv6 neighbor to clear\n"
4735 "Soft reconfig outbound update\n")
4736
4737DEFUN (clear_ip_bgp_peer_group_soft_out,
4738 clear_ip_bgp_peer_group_soft_out_cmd,
4739 "clear ip bgp peer-group WORD soft out",
4740 CLEAR_STR
4741 IP_STR
4742 BGP_STR
4743 "Clear all members of peer-group\n"
4744 "BGP peer-group name\n"
4745 "Soft reconfig\n"
4746 "Soft reconfig outbound update\n")
4747{
4748 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
4749 BGP_CLEAR_SOFT_OUT, argv[0]);
4750}
4751
4752ALIAS (clear_ip_bgp_peer_group_soft_out,
4753 clear_ip_bgp_peer_group_out_cmd,
4754 "clear ip bgp peer-group WORD out",
4755 CLEAR_STR
4756 IP_STR
4757 BGP_STR
4758 "Clear all members of peer-group\n"
4759 "BGP peer-group name\n"
4760 "Soft reconfig outbound update\n")
4761
4762DEFUN (clear_ip_bgp_peer_group_ipv4_soft_out,
4763 clear_ip_bgp_peer_group_ipv4_soft_out_cmd,
4764 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft out",
4765 CLEAR_STR
4766 IP_STR
4767 BGP_STR
4768 "Clear all members of peer-group\n"
4769 "BGP peer-group name\n"
4770 "Address family\n"
4771 "Address Family modifier\n"
4772 "Address Family modifier\n"
4773 "Soft reconfig\n"
4774 "Soft reconfig outbound update\n")
4775{
4776 if (strncmp (argv[1], "m", 1) == 0)
4777 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
4778 BGP_CLEAR_SOFT_OUT, argv[0]);
4779
4780 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
4781 BGP_CLEAR_SOFT_OUT, argv[0]);
4782}
4783
4784ALIAS (clear_ip_bgp_peer_group_ipv4_soft_out,
4785 clear_ip_bgp_peer_group_ipv4_out_cmd,
4786 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) out",
4787 CLEAR_STR
4788 IP_STR
4789 BGP_STR
4790 "Clear all members of peer-group\n"
4791 "BGP peer-group name\n"
4792 "Address family\n"
4793 "Address Family modifier\n"
4794 "Address Family modifier\n"
4795 "Soft reconfig outbound update\n")
4796
4797DEFUN (clear_bgp_peer_group_soft_out,
4798 clear_bgp_peer_group_soft_out_cmd,
4799 "clear bgp peer-group WORD soft out",
4800 CLEAR_STR
4801 BGP_STR
4802 "Clear all members of peer-group\n"
4803 "BGP peer-group name\n"
4804 "Soft reconfig\n"
4805 "Soft reconfig outbound update\n")
4806{
4807 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
4808 BGP_CLEAR_SOFT_OUT, argv[0]);
4809}
4810
4811ALIAS (clear_bgp_peer_group_soft_out,
4812 clear_bgp_ipv6_peer_group_soft_out_cmd,
4813 "clear bgp ipv6 peer-group WORD soft out",
4814 CLEAR_STR
4815 BGP_STR
4816 "Address family\n"
4817 "Clear all members of peer-group\n"
4818 "BGP peer-group name\n"
4819 "Soft reconfig\n"
4820 "Soft reconfig outbound update\n")
4821
4822ALIAS (clear_bgp_peer_group_soft_out,
4823 clear_bgp_peer_group_out_cmd,
4824 "clear bgp peer-group WORD out",
4825 CLEAR_STR
4826 BGP_STR
4827 "Clear all members of peer-group\n"
4828 "BGP peer-group name\n"
4829 "Soft reconfig outbound update\n")
4830
4831ALIAS (clear_bgp_peer_group_soft_out,
4832 clear_bgp_ipv6_peer_group_out_cmd,
4833 "clear bgp ipv6 peer-group WORD out",
4834 CLEAR_STR
4835 BGP_STR
4836 "Address family\n"
4837 "Clear all members of peer-group\n"
4838 "BGP peer-group name\n"
4839 "Soft reconfig outbound update\n")
4840
4841DEFUN (clear_ip_bgp_external_soft_out,
4842 clear_ip_bgp_external_soft_out_cmd,
4843 "clear ip bgp external soft out",
4844 CLEAR_STR
4845 IP_STR
4846 BGP_STR
4847 "Clear all external peers\n"
4848 "Soft reconfig\n"
4849 "Soft reconfig outbound update\n")
4850{
4851 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
4852 BGP_CLEAR_SOFT_OUT, NULL);
4853}
4854
4855ALIAS (clear_ip_bgp_external_soft_out,
4856 clear_ip_bgp_external_out_cmd,
4857 "clear ip bgp external out",
4858 CLEAR_STR
4859 IP_STR
4860 BGP_STR
4861 "Clear all external peers\n"
4862 "Soft reconfig outbound update\n")
4863
4864DEFUN (clear_ip_bgp_external_ipv4_soft_out,
4865 clear_ip_bgp_external_ipv4_soft_out_cmd,
4866 "clear ip bgp external ipv4 (unicast|multicast) soft out",
4867 CLEAR_STR
4868 IP_STR
4869 BGP_STR
4870 "Clear all external peers\n"
4871 "Address family\n"
4872 "Address Family modifier\n"
4873 "Address Family modifier\n"
4874 "Soft reconfig\n"
4875 "Soft reconfig outbound update\n")
4876{
4877 if (strncmp (argv[0], "m", 1) == 0)
4878 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
4879 BGP_CLEAR_SOFT_OUT, NULL);
4880
4881 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
4882 BGP_CLEAR_SOFT_OUT, NULL);
4883}
4884
4885ALIAS (clear_ip_bgp_external_ipv4_soft_out,
4886 clear_ip_bgp_external_ipv4_out_cmd,
4887 "clear ip bgp external ipv4 (unicast|multicast) out",
4888 CLEAR_STR
4889 IP_STR
4890 BGP_STR
4891 "Clear all external peers\n"
4892 "Address family\n"
4893 "Address Family modifier\n"
4894 "Address Family modifier\n"
4895 "Soft reconfig outbound update\n")
4896
4897DEFUN (clear_bgp_external_soft_out,
4898 clear_bgp_external_soft_out_cmd,
4899 "clear bgp external soft out",
4900 CLEAR_STR
4901 BGP_STR
4902 "Clear all external peers\n"
4903 "Soft reconfig\n"
4904 "Soft reconfig outbound update\n")
4905{
4906 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
4907 BGP_CLEAR_SOFT_OUT, NULL);
4908}
4909
4910ALIAS (clear_bgp_external_soft_out,
4911 clear_bgp_ipv6_external_soft_out_cmd,
4912 "clear bgp ipv6 external soft out",
4913 CLEAR_STR
4914 BGP_STR
4915 "Address family\n"
4916 "Clear all external peers\n"
4917 "Soft reconfig\n"
4918 "Soft reconfig outbound update\n")
4919
4920ALIAS (clear_bgp_external_soft_out,
4921 clear_bgp_external_out_cmd,
4922 "clear bgp external out",
4923 CLEAR_STR
4924 BGP_STR
4925 "Clear all external peers\n"
4926 "Soft reconfig outbound update\n")
4927
4928ALIAS (clear_bgp_external_soft_out,
4929 clear_bgp_ipv6_external_out_cmd,
4930 "clear bgp ipv6 external WORD out",
4931 CLEAR_STR
4932 BGP_STR
4933 "Address family\n"
4934 "Clear all external peers\n"
4935 "Soft reconfig outbound update\n")
4936
4937DEFUN (clear_ip_bgp_as_soft_out,
4938 clear_ip_bgp_as_soft_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004939 "clear ip bgp " CMD_AS_RANGE " soft out",
paul718e3742002-12-13 20:15:29 +00004940 CLEAR_STR
4941 IP_STR
4942 BGP_STR
4943 "Clear peers with the AS number\n"
4944 "Soft reconfig\n"
4945 "Soft reconfig outbound update\n")
4946{
4947 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
4948 BGP_CLEAR_SOFT_OUT, argv[0]);
4949}
4950
4951ALIAS (clear_ip_bgp_as_soft_out,
4952 clear_ip_bgp_as_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004953 "clear ip bgp " CMD_AS_RANGE " out",
paul718e3742002-12-13 20:15:29 +00004954 CLEAR_STR
4955 IP_STR
4956 BGP_STR
4957 "Clear peers with the AS number\n"
4958 "Soft reconfig outbound update\n")
4959
4960DEFUN (clear_ip_bgp_as_ipv4_soft_out,
4961 clear_ip_bgp_as_ipv4_soft_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004962 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft out",
paul718e3742002-12-13 20:15:29 +00004963 CLEAR_STR
4964 IP_STR
4965 BGP_STR
4966 "Clear peers with the AS number\n"
4967 "Address family\n"
4968 "Address Family modifier\n"
4969 "Address Family modifier\n"
4970 "Soft reconfig\n"
4971 "Soft reconfig outbound update\n")
4972{
4973 if (strncmp (argv[1], "m", 1) == 0)
4974 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
4975 BGP_CLEAR_SOFT_OUT, argv[0]);
4976
4977 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
4978 BGP_CLEAR_SOFT_OUT, argv[0]);
4979}
4980
4981ALIAS (clear_ip_bgp_as_ipv4_soft_out,
4982 clear_ip_bgp_as_ipv4_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004983 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) out",
paul718e3742002-12-13 20:15:29 +00004984 CLEAR_STR
4985 IP_STR
4986 BGP_STR
4987 "Clear peers with the AS number\n"
4988 "Address family\n"
4989 "Address Family modifier\n"
4990 "Address Family modifier\n"
4991 "Soft reconfig outbound update\n")
4992
4993DEFUN (clear_ip_bgp_as_vpnv4_soft_out,
4994 clear_ip_bgp_as_vpnv4_soft_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004995 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft out",
paul718e3742002-12-13 20:15:29 +00004996 CLEAR_STR
4997 IP_STR
4998 BGP_STR
4999 "Clear peers with the AS number\n"
5000 "Address family\n"
5001 "Address Family modifier\n"
5002 "Soft reconfig\n"
5003 "Soft reconfig outbound update\n")
5004{
5005 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
5006 BGP_CLEAR_SOFT_OUT, argv[0]);
5007}
5008
5009ALIAS (clear_ip_bgp_as_vpnv4_soft_out,
5010 clear_ip_bgp_as_vpnv4_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005011 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast out",
paul718e3742002-12-13 20:15:29 +00005012 CLEAR_STR
5013 IP_STR
5014 BGP_STR
5015 "Clear peers with the AS number\n"
5016 "Address family\n"
5017 "Address Family modifier\n"
5018 "Soft reconfig outbound update\n")
5019
5020DEFUN (clear_bgp_as_soft_out,
5021 clear_bgp_as_soft_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005022 "clear bgp " CMD_AS_RANGE " soft out",
paul718e3742002-12-13 20:15:29 +00005023 CLEAR_STR
5024 BGP_STR
5025 "Clear peers with the AS number\n"
5026 "Soft reconfig\n"
5027 "Soft reconfig outbound update\n")
5028{
5029 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
5030 BGP_CLEAR_SOFT_OUT, argv[0]);
5031}
5032
5033ALIAS (clear_bgp_as_soft_out,
5034 clear_bgp_ipv6_as_soft_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005035 "clear bgp ipv6 " CMD_AS_RANGE " soft out",
paul718e3742002-12-13 20:15:29 +00005036 CLEAR_STR
5037 BGP_STR
5038 "Address family\n"
5039 "Clear peers with the AS number\n"
5040 "Soft reconfig\n"
5041 "Soft reconfig outbound update\n")
5042
5043ALIAS (clear_bgp_as_soft_out,
5044 clear_bgp_as_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005045 "clear bgp " CMD_AS_RANGE " out",
paul718e3742002-12-13 20:15:29 +00005046 CLEAR_STR
5047 BGP_STR
5048 "Clear peers with the AS number\n"
5049 "Soft reconfig outbound update\n")
5050
5051ALIAS (clear_bgp_as_soft_out,
5052 clear_bgp_ipv6_as_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005053 "clear bgp ipv6 " CMD_AS_RANGE " out",
paul718e3742002-12-13 20:15:29 +00005054 CLEAR_STR
5055 BGP_STR
5056 "Address family\n"
5057 "Clear peers with the AS number\n"
5058 "Soft reconfig outbound update\n")
5059
5060/* Inbound soft-reconfiguration */
5061DEFUN (clear_ip_bgp_all_soft_in,
5062 clear_ip_bgp_all_soft_in_cmd,
5063 "clear ip bgp * soft in",
5064 CLEAR_STR
5065 IP_STR
5066 BGP_STR
5067 "Clear all peers\n"
5068 "Soft reconfig\n"
5069 "Soft reconfig inbound update\n")
5070{
5071 if (argc == 1)
5072 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5073 BGP_CLEAR_SOFT_IN, NULL);
5074
5075 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5076 BGP_CLEAR_SOFT_IN, NULL);
5077}
5078
5079ALIAS (clear_ip_bgp_all_soft_in,
5080 clear_ip_bgp_instance_all_soft_in_cmd,
5081 "clear ip bgp view WORD * soft in",
5082 CLEAR_STR
5083 IP_STR
5084 BGP_STR
5085 "BGP view\n"
5086 "view name\n"
5087 "Clear all peers\n"
5088 "Soft reconfig\n"
5089 "Soft reconfig inbound update\n")
5090
5091ALIAS (clear_ip_bgp_all_soft_in,
5092 clear_ip_bgp_all_in_cmd,
5093 "clear ip bgp * in",
5094 CLEAR_STR
5095 IP_STR
5096 BGP_STR
5097 "Clear all peers\n"
5098 "Soft reconfig inbound update\n")
5099
5100DEFUN (clear_ip_bgp_all_in_prefix_filter,
5101 clear_ip_bgp_all_in_prefix_filter_cmd,
5102 "clear ip bgp * in prefix-filter",
5103 CLEAR_STR
5104 IP_STR
5105 BGP_STR
5106 "Clear all peers\n"
5107 "Soft reconfig inbound update\n"
5108 "Push out prefix-list ORF and do inbound soft reconfig\n")
5109{
5110 if (argc== 1)
5111 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5112 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5113
5114 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5115 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5116}
5117
5118ALIAS (clear_ip_bgp_all_in_prefix_filter,
5119 clear_ip_bgp_instance_all_in_prefix_filter_cmd,
5120 "clear ip bgp view WORD * in prefix-filter",
5121 CLEAR_STR
5122 IP_STR
5123 BGP_STR
5124 "BGP view\n"
5125 "view name\n"
5126 "Clear all peers\n"
5127 "Soft reconfig inbound update\n"
5128 "Push out prefix-list ORF and do inbound soft reconfig\n")
5129
5130
5131DEFUN (clear_ip_bgp_all_ipv4_soft_in,
5132 clear_ip_bgp_all_ipv4_soft_in_cmd,
5133 "clear ip bgp * ipv4 (unicast|multicast) soft in",
5134 CLEAR_STR
5135 IP_STR
5136 BGP_STR
5137 "Clear all peers\n"
5138 "Address family\n"
5139 "Address Family modifier\n"
5140 "Address Family modifier\n"
5141 "Soft reconfig\n"
5142 "Soft reconfig inbound update\n")
5143{
5144 if (strncmp (argv[0], "m", 1) == 0)
5145 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
5146 BGP_CLEAR_SOFT_IN, NULL);
5147
5148 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5149 BGP_CLEAR_SOFT_IN, NULL);
5150}
5151
5152ALIAS (clear_ip_bgp_all_ipv4_soft_in,
5153 clear_ip_bgp_all_ipv4_in_cmd,
5154 "clear ip bgp * ipv4 (unicast|multicast) in",
5155 CLEAR_STR
5156 IP_STR
5157 BGP_STR
5158 "Clear all peers\n"
5159 "Address family\n"
5160 "Address Family modifier\n"
5161 "Address Family modifier\n"
5162 "Soft reconfig inbound update\n")
5163
5164DEFUN (clear_ip_bgp_instance_all_ipv4_soft_in,
5165 clear_ip_bgp_instance_all_ipv4_soft_in_cmd,
5166 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft in",
5167 CLEAR_STR
5168 IP_STR
5169 BGP_STR
5170 "BGP view\n"
5171 "view name\n"
5172 "Clear all peers\n"
5173 "Address family\n"
5174 "Address Family modifier\n"
5175 "Address Family modifier\n"
5176 "Soft reconfig\n"
5177 "Soft reconfig inbound update\n")
5178{
5179 if (strncmp (argv[1], "m", 1) == 0)
5180 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
5181 BGP_CLEAR_SOFT_IN, NULL);
5182
5183 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5184 BGP_CLEAR_SOFT_IN, NULL);
5185}
5186
5187DEFUN (clear_ip_bgp_all_ipv4_in_prefix_filter,
5188 clear_ip_bgp_all_ipv4_in_prefix_filter_cmd,
5189 "clear ip bgp * ipv4 (unicast|multicast) in prefix-filter",
5190 CLEAR_STR
5191 IP_STR
5192 BGP_STR
5193 "Clear all peers\n"
5194 "Address family\n"
5195 "Address Family modifier\n"
5196 "Address Family modifier\n"
5197 "Soft reconfig inbound update\n"
5198 "Push out prefix-list ORF and do inbound soft reconfig\n")
5199{
5200 if (strncmp (argv[0], "m", 1) == 0)
5201 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
5202 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5203
5204 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5205 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5206}
5207
5208DEFUN (clear_ip_bgp_instance_all_ipv4_in_prefix_filter,
5209 clear_ip_bgp_instance_all_ipv4_in_prefix_filter_cmd,
5210 "clear ip bgp view WORD * ipv4 (unicast|multicast) in prefix-filter",
5211 CLEAR_STR
5212 IP_STR
5213 BGP_STR
5214 "Clear all peers\n"
5215 "Address family\n"
5216 "Address Family modifier\n"
5217 "Address Family modifier\n"
5218 "Soft reconfig inbound update\n"
5219 "Push out prefix-list ORF and do inbound soft reconfig\n")
5220{
5221 if (strncmp (argv[1], "m", 1) == 0)
5222 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
5223 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5224
5225 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5226 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5227}
5228
5229DEFUN (clear_ip_bgp_all_vpnv4_soft_in,
5230 clear_ip_bgp_all_vpnv4_soft_in_cmd,
5231 "clear ip bgp * vpnv4 unicast soft in",
5232 CLEAR_STR
5233 IP_STR
5234 BGP_STR
5235 "Clear all peers\n"
5236 "Address family\n"
5237 "Address Family Modifier\n"
5238 "Soft reconfig\n"
5239 "Soft reconfig inbound update\n")
5240{
5241 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
5242 BGP_CLEAR_SOFT_IN, NULL);
5243}
5244
5245ALIAS (clear_ip_bgp_all_vpnv4_soft_in,
5246 clear_ip_bgp_all_vpnv4_in_cmd,
5247 "clear ip bgp * vpnv4 unicast in",
5248 CLEAR_STR
5249 IP_STR
5250 BGP_STR
5251 "Clear all peers\n"
5252 "Address family\n"
5253 "Address Family Modifier\n"
5254 "Soft reconfig inbound update\n")
5255
5256DEFUN (clear_bgp_all_soft_in,
5257 clear_bgp_all_soft_in_cmd,
5258 "clear bgp * soft in",
5259 CLEAR_STR
5260 BGP_STR
5261 "Clear all peers\n"
5262 "Soft reconfig\n"
5263 "Soft reconfig inbound update\n")
5264{
5265 if (argc == 1)
5266 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
5267 BGP_CLEAR_SOFT_IN, NULL);
5268
5269 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
5270 BGP_CLEAR_SOFT_IN, NULL);
5271}
5272
5273ALIAS (clear_bgp_all_soft_in,
5274 clear_bgp_instance_all_soft_in_cmd,
5275 "clear bgp view WORD * soft in",
5276 CLEAR_STR
5277 BGP_STR
5278 "BGP view\n"
5279 "view name\n"
5280 "Clear all peers\n"
5281 "Soft reconfig\n"
5282 "Soft reconfig inbound update\n")
5283
5284ALIAS (clear_bgp_all_soft_in,
5285 clear_bgp_ipv6_all_soft_in_cmd,
5286 "clear bgp ipv6 * soft in",
5287 CLEAR_STR
5288 BGP_STR
5289 "Address family\n"
5290 "Clear all peers\n"
5291 "Soft reconfig\n"
5292 "Soft reconfig inbound update\n")
5293
5294ALIAS (clear_bgp_all_soft_in,
5295 clear_bgp_all_in_cmd,
5296 "clear bgp * in",
5297 CLEAR_STR
5298 BGP_STR
5299 "Clear all peers\n"
5300 "Soft reconfig inbound update\n")
5301
5302ALIAS (clear_bgp_all_soft_in,
5303 clear_bgp_ipv6_all_in_cmd,
5304 "clear bgp ipv6 * in",
5305 CLEAR_STR
5306 BGP_STR
5307 "Address family\n"
5308 "Clear all peers\n"
5309 "Soft reconfig inbound update\n")
5310
5311DEFUN (clear_bgp_all_in_prefix_filter,
5312 clear_bgp_all_in_prefix_filter_cmd,
5313 "clear bgp * in prefix-filter",
5314 CLEAR_STR
5315 BGP_STR
5316 "Clear all peers\n"
5317 "Soft reconfig inbound update\n"
5318 "Push out prefix-list ORF and do inbound soft reconfig\n")
5319{
5320 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
5321 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5322}
5323
5324ALIAS (clear_bgp_all_in_prefix_filter,
5325 clear_bgp_ipv6_all_in_prefix_filter_cmd,
5326 "clear bgp ipv6 * in prefix-filter",
5327 CLEAR_STR
5328 BGP_STR
5329 "Address family\n"
5330 "Clear all peers\n"
5331 "Soft reconfig inbound update\n"
5332 "Push out prefix-list ORF and do inbound soft reconfig\n")
5333
5334DEFUN (clear_ip_bgp_peer_soft_in,
5335 clear_ip_bgp_peer_soft_in_cmd,
5336 "clear ip bgp A.B.C.D soft in",
5337 CLEAR_STR
5338 IP_STR
5339 BGP_STR
5340 "BGP neighbor address to clear\n"
5341 "Soft reconfig\n"
5342 "Soft reconfig inbound update\n")
5343{
5344 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5345 BGP_CLEAR_SOFT_IN, argv[0]);
5346}
5347
5348ALIAS (clear_ip_bgp_peer_soft_in,
5349 clear_ip_bgp_peer_in_cmd,
5350 "clear ip bgp A.B.C.D in",
5351 CLEAR_STR
5352 IP_STR
5353 BGP_STR
5354 "BGP neighbor address to clear\n"
5355 "Soft reconfig inbound update\n")
5356
5357DEFUN (clear_ip_bgp_peer_in_prefix_filter,
5358 clear_ip_bgp_peer_in_prefix_filter_cmd,
5359 "clear ip bgp A.B.C.D in prefix-filter",
5360 CLEAR_STR
5361 IP_STR
5362 BGP_STR
5363 "BGP neighbor address to clear\n"
5364 "Soft reconfig inbound update\n"
5365 "Push out the existing ORF prefix-list\n")
5366{
5367 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5368 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5369}
5370
5371DEFUN (clear_ip_bgp_peer_ipv4_soft_in,
5372 clear_ip_bgp_peer_ipv4_soft_in_cmd,
5373 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft in",
5374 CLEAR_STR
5375 IP_STR
5376 BGP_STR
5377 "BGP neighbor address to clear\n"
5378 "Address family\n"
5379 "Address Family modifier\n"
5380 "Address Family modifier\n"
5381 "Soft reconfig\n"
5382 "Soft reconfig inbound update\n")
5383{
5384 if (strncmp (argv[1], "m", 1) == 0)
5385 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
5386 BGP_CLEAR_SOFT_IN, argv[0]);
5387
5388 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5389 BGP_CLEAR_SOFT_IN, argv[0]);
5390}
5391
5392ALIAS (clear_ip_bgp_peer_ipv4_soft_in,
5393 clear_ip_bgp_peer_ipv4_in_cmd,
5394 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) in",
5395 CLEAR_STR
5396 IP_STR
5397 BGP_STR
5398 "BGP neighbor address to clear\n"
5399 "Address family\n"
5400 "Address Family modifier\n"
5401 "Address Family modifier\n"
5402 "Soft reconfig inbound update\n")
5403
5404DEFUN (clear_ip_bgp_peer_ipv4_in_prefix_filter,
5405 clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd,
5406 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) in prefix-filter",
5407 CLEAR_STR
5408 IP_STR
5409 BGP_STR
5410 "BGP neighbor address to clear\n"
5411 "Address family\n"
5412 "Address Family modifier\n"
5413 "Address Family modifier\n"
5414 "Soft reconfig inbound update\n"
5415 "Push out the existing ORF prefix-list\n")
5416{
5417 if (strncmp (argv[1], "m", 1) == 0)
5418 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
5419 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5420
5421 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5422 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5423}
5424
5425DEFUN (clear_ip_bgp_peer_vpnv4_soft_in,
5426 clear_ip_bgp_peer_vpnv4_soft_in_cmd,
5427 "clear ip bgp A.B.C.D vpnv4 unicast soft in",
5428 CLEAR_STR
5429 IP_STR
5430 BGP_STR
5431 "BGP neighbor address to clear\n"
5432 "Address family\n"
5433 "Address Family Modifier\n"
5434 "Soft reconfig\n"
5435 "Soft reconfig inbound update\n")
5436{
5437 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
5438 BGP_CLEAR_SOFT_IN, argv[0]);
5439}
5440
5441ALIAS (clear_ip_bgp_peer_vpnv4_soft_in,
5442 clear_ip_bgp_peer_vpnv4_in_cmd,
5443 "clear ip bgp A.B.C.D vpnv4 unicast in",
5444 CLEAR_STR
5445 IP_STR
5446 BGP_STR
5447 "BGP neighbor address to clear\n"
5448 "Address family\n"
5449 "Address Family Modifier\n"
5450 "Soft reconfig inbound update\n")
5451
5452DEFUN (clear_bgp_peer_soft_in,
5453 clear_bgp_peer_soft_in_cmd,
5454 "clear bgp (A.B.C.D|X:X::X:X) soft in",
5455 CLEAR_STR
5456 BGP_STR
5457 "BGP neighbor address to clear\n"
5458 "BGP IPv6 neighbor to clear\n"
5459 "Soft reconfig\n"
5460 "Soft reconfig inbound update\n")
5461{
5462 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
5463 BGP_CLEAR_SOFT_IN, argv[0]);
5464}
5465
5466ALIAS (clear_bgp_peer_soft_in,
5467 clear_bgp_ipv6_peer_soft_in_cmd,
5468 "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft in",
5469 CLEAR_STR
5470 BGP_STR
5471 "Address family\n"
5472 "BGP neighbor address to clear\n"
5473 "BGP IPv6 neighbor to clear\n"
5474 "Soft reconfig\n"
5475 "Soft reconfig inbound update\n")
5476
5477ALIAS (clear_bgp_peer_soft_in,
5478 clear_bgp_peer_in_cmd,
5479 "clear bgp (A.B.C.D|X:X::X:X) in",
5480 CLEAR_STR
5481 BGP_STR
5482 "BGP neighbor address to clear\n"
5483 "BGP IPv6 neighbor to clear\n"
5484 "Soft reconfig inbound update\n")
5485
5486ALIAS (clear_bgp_peer_soft_in,
5487 clear_bgp_ipv6_peer_in_cmd,
5488 "clear bgp ipv6 (A.B.C.D|X:X::X:X) in",
5489 CLEAR_STR
5490 BGP_STR
5491 "Address family\n"
5492 "BGP neighbor address to clear\n"
5493 "BGP IPv6 neighbor to clear\n"
5494 "Soft reconfig inbound update\n")
5495
5496DEFUN (clear_bgp_peer_in_prefix_filter,
5497 clear_bgp_peer_in_prefix_filter_cmd,
5498 "clear bgp (A.B.C.D|X:X::X:X) in prefix-filter",
5499 CLEAR_STR
5500 BGP_STR
5501 "BGP neighbor address to clear\n"
5502 "BGP IPv6 neighbor to clear\n"
5503 "Soft reconfig inbound update\n"
5504 "Push out the existing ORF prefix-list\n")
5505{
5506 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
5507 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5508}
5509
5510ALIAS (clear_bgp_peer_in_prefix_filter,
5511 clear_bgp_ipv6_peer_in_prefix_filter_cmd,
5512 "clear bgp ipv6 (A.B.C.D|X:X::X:X) in prefix-filter",
5513 CLEAR_STR
5514 BGP_STR
5515 "Address family\n"
5516 "BGP neighbor address to clear\n"
5517 "BGP IPv6 neighbor to clear\n"
5518 "Soft reconfig inbound update\n"
5519 "Push out the existing ORF prefix-list\n")
5520
5521DEFUN (clear_ip_bgp_peer_group_soft_in,
5522 clear_ip_bgp_peer_group_soft_in_cmd,
5523 "clear ip bgp peer-group WORD soft in",
5524 CLEAR_STR
5525 IP_STR
5526 BGP_STR
5527 "Clear all members of peer-group\n"
5528 "BGP peer-group name\n"
5529 "Soft reconfig\n"
5530 "Soft reconfig inbound update\n")
5531{
5532 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5533 BGP_CLEAR_SOFT_IN, argv[0]);
5534}
5535
5536ALIAS (clear_ip_bgp_peer_group_soft_in,
5537 clear_ip_bgp_peer_group_in_cmd,
5538 "clear ip bgp peer-group WORD in",
5539 CLEAR_STR
5540 IP_STR
5541 BGP_STR
5542 "Clear all members of peer-group\n"
5543 "BGP peer-group name\n"
5544 "Soft reconfig inbound update\n")
5545
5546DEFUN (clear_ip_bgp_peer_group_in_prefix_filter,
5547 clear_ip_bgp_peer_group_in_prefix_filter_cmd,
5548 "clear ip bgp peer-group WORD in prefix-filter",
5549 CLEAR_STR
5550 IP_STR
5551 BGP_STR
5552 "Clear all members of peer-group\n"
5553 "BGP peer-group name\n"
5554 "Soft reconfig inbound update\n"
5555 "Push out prefix-list ORF and do inbound soft reconfig\n")
5556{
5557 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5558 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5559}
5560
5561DEFUN (clear_ip_bgp_peer_group_ipv4_soft_in,
5562 clear_ip_bgp_peer_group_ipv4_soft_in_cmd,
5563 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft in",
5564 CLEAR_STR
5565 IP_STR
5566 BGP_STR
5567 "Clear all members of peer-group\n"
5568 "BGP peer-group name\n"
5569 "Address family\n"
5570 "Address Family modifier\n"
5571 "Address Family modifier\n"
5572 "Soft reconfig\n"
5573 "Soft reconfig inbound update\n")
5574{
5575 if (strncmp (argv[1], "m", 1) == 0)
5576 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
5577 BGP_CLEAR_SOFT_IN, argv[0]);
5578
5579 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5580 BGP_CLEAR_SOFT_IN, argv[0]);
5581}
5582
5583ALIAS (clear_ip_bgp_peer_group_ipv4_soft_in,
5584 clear_ip_bgp_peer_group_ipv4_in_cmd,
5585 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in",
5586 CLEAR_STR
5587 IP_STR
5588 BGP_STR
5589 "Clear all members of peer-group\n"
5590 "BGP peer-group name\n"
5591 "Address family\n"
5592 "Address Family modifier\n"
5593 "Address Family modifier\n"
5594 "Soft reconfig inbound update\n")
5595
5596DEFUN (clear_ip_bgp_peer_group_ipv4_in_prefix_filter,
5597 clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd,
5598 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in prefix-filter",
5599 CLEAR_STR
5600 IP_STR
5601 BGP_STR
5602 "Clear all members of peer-group\n"
5603 "BGP peer-group name\n"
5604 "Address family\n"
5605 "Address Family modifier\n"
5606 "Address Family modifier\n"
5607 "Soft reconfig inbound update\n"
5608 "Push out prefix-list ORF and do inbound soft reconfig\n")
5609{
5610 if (strncmp (argv[1], "m", 1) == 0)
5611 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
5612 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5613
5614 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5615 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5616}
5617
5618DEFUN (clear_bgp_peer_group_soft_in,
5619 clear_bgp_peer_group_soft_in_cmd,
5620 "clear bgp peer-group WORD soft in",
5621 CLEAR_STR
5622 BGP_STR
5623 "Clear all members of peer-group\n"
5624 "BGP peer-group name\n"
5625 "Soft reconfig\n"
5626 "Soft reconfig inbound update\n")
5627{
5628 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
5629 BGP_CLEAR_SOFT_IN, argv[0]);
5630}
5631
5632ALIAS (clear_bgp_peer_group_soft_in,
5633 clear_bgp_ipv6_peer_group_soft_in_cmd,
5634 "clear bgp ipv6 peer-group WORD soft in",
5635 CLEAR_STR
5636 BGP_STR
5637 "Address family\n"
5638 "Clear all members of peer-group\n"
5639 "BGP peer-group name\n"
5640 "Soft reconfig\n"
5641 "Soft reconfig inbound update\n")
5642
5643ALIAS (clear_bgp_peer_group_soft_in,
5644 clear_bgp_peer_group_in_cmd,
5645 "clear bgp peer-group WORD in",
5646 CLEAR_STR
5647 BGP_STR
5648 "Clear all members of peer-group\n"
5649 "BGP peer-group name\n"
5650 "Soft reconfig inbound update\n")
5651
5652ALIAS (clear_bgp_peer_group_soft_in,
5653 clear_bgp_ipv6_peer_group_in_cmd,
5654 "clear bgp ipv6 peer-group WORD in",
5655 CLEAR_STR
5656 BGP_STR
5657 "Address family\n"
5658 "Clear all members of peer-group\n"
5659 "BGP peer-group name\n"
5660 "Soft reconfig inbound update\n")
5661
5662DEFUN (clear_bgp_peer_group_in_prefix_filter,
5663 clear_bgp_peer_group_in_prefix_filter_cmd,
5664 "clear bgp peer-group WORD in prefix-filter",
5665 CLEAR_STR
5666 BGP_STR
5667 "Clear all members of peer-group\n"
5668 "BGP peer-group name\n"
5669 "Soft reconfig inbound update\n"
5670 "Push out prefix-list ORF and do inbound soft reconfig\n")
5671{
5672 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
5673 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5674}
5675
5676ALIAS (clear_bgp_peer_group_in_prefix_filter,
5677 clear_bgp_ipv6_peer_group_in_prefix_filter_cmd,
5678 "clear bgp ipv6 peer-group WORD in prefix-filter",
5679 CLEAR_STR
5680 BGP_STR
5681 "Address family\n"
5682 "Clear all members of peer-group\n"
5683 "BGP peer-group name\n"
5684 "Soft reconfig inbound update\n"
5685 "Push out prefix-list ORF and do inbound soft reconfig\n")
5686
5687DEFUN (clear_ip_bgp_external_soft_in,
5688 clear_ip_bgp_external_soft_in_cmd,
5689 "clear ip bgp external soft in",
5690 CLEAR_STR
5691 IP_STR
5692 BGP_STR
5693 "Clear all external peers\n"
5694 "Soft reconfig\n"
5695 "Soft reconfig inbound update\n")
5696{
5697 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5698 BGP_CLEAR_SOFT_IN, NULL);
5699}
5700
5701ALIAS (clear_ip_bgp_external_soft_in,
5702 clear_ip_bgp_external_in_cmd,
5703 "clear ip bgp external in",
5704 CLEAR_STR
5705 IP_STR
5706 BGP_STR
5707 "Clear all external peers\n"
5708 "Soft reconfig inbound update\n")
5709
5710DEFUN (clear_ip_bgp_external_in_prefix_filter,
5711 clear_ip_bgp_external_in_prefix_filter_cmd,
5712 "clear ip bgp external in prefix-filter",
5713 CLEAR_STR
5714 IP_STR
5715 BGP_STR
5716 "Clear all external peers\n"
5717 "Soft reconfig inbound update\n"
5718 "Push out prefix-list ORF and do inbound soft reconfig\n")
5719{
5720 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5721 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5722}
5723
5724DEFUN (clear_ip_bgp_external_ipv4_soft_in,
5725 clear_ip_bgp_external_ipv4_soft_in_cmd,
5726 "clear ip bgp external ipv4 (unicast|multicast) soft in",
5727 CLEAR_STR
5728 IP_STR
5729 BGP_STR
5730 "Clear all external peers\n"
5731 "Address family\n"
5732 "Address Family modifier\n"
5733 "Address Family modifier\n"
5734 "Soft reconfig\n"
5735 "Soft reconfig inbound update\n")
5736{
5737 if (strncmp (argv[0], "m", 1) == 0)
5738 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
5739 BGP_CLEAR_SOFT_IN, NULL);
5740
5741 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5742 BGP_CLEAR_SOFT_IN, NULL);
5743}
5744
5745ALIAS (clear_ip_bgp_external_ipv4_soft_in,
5746 clear_ip_bgp_external_ipv4_in_cmd,
5747 "clear ip bgp external ipv4 (unicast|multicast) in",
5748 CLEAR_STR
5749 IP_STR
5750 BGP_STR
5751 "Clear all external peers\n"
5752 "Address family\n"
5753 "Address Family modifier\n"
5754 "Address Family modifier\n"
5755 "Soft reconfig inbound update\n")
5756
5757DEFUN (clear_ip_bgp_external_ipv4_in_prefix_filter,
5758 clear_ip_bgp_external_ipv4_in_prefix_filter_cmd,
5759 "clear ip bgp external ipv4 (unicast|multicast) in prefix-filter",
5760 CLEAR_STR
5761 IP_STR
5762 BGP_STR
5763 "Clear all external peers\n"
5764 "Address family\n"
5765 "Address Family modifier\n"
5766 "Address Family modifier\n"
5767 "Soft reconfig inbound update\n"
5768 "Push out prefix-list ORF and do inbound soft reconfig\n")
5769{
5770 if (strncmp (argv[0], "m", 1) == 0)
5771 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
5772 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5773
5774 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5775 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5776}
5777
5778DEFUN (clear_bgp_external_soft_in,
5779 clear_bgp_external_soft_in_cmd,
5780 "clear bgp external soft in",
5781 CLEAR_STR
5782 BGP_STR
5783 "Clear all external peers\n"
5784 "Soft reconfig\n"
5785 "Soft reconfig inbound update\n")
5786{
5787 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
5788 BGP_CLEAR_SOFT_IN, NULL);
5789}
5790
5791ALIAS (clear_bgp_external_soft_in,
5792 clear_bgp_ipv6_external_soft_in_cmd,
5793 "clear bgp ipv6 external soft in",
5794 CLEAR_STR
5795 BGP_STR
5796 "Address family\n"
5797 "Clear all external peers\n"
5798 "Soft reconfig\n"
5799 "Soft reconfig inbound update\n")
5800
5801ALIAS (clear_bgp_external_soft_in,
5802 clear_bgp_external_in_cmd,
5803 "clear bgp external in",
5804 CLEAR_STR
5805 BGP_STR
5806 "Clear all external peers\n"
5807 "Soft reconfig inbound update\n")
5808
5809ALIAS (clear_bgp_external_soft_in,
5810 clear_bgp_ipv6_external_in_cmd,
5811 "clear bgp ipv6 external WORD in",
5812 CLEAR_STR
5813 BGP_STR
5814 "Address family\n"
5815 "Clear all external peers\n"
5816 "Soft reconfig inbound update\n")
5817
5818DEFUN (clear_bgp_external_in_prefix_filter,
5819 clear_bgp_external_in_prefix_filter_cmd,
5820 "clear bgp external in prefix-filter",
5821 CLEAR_STR
5822 BGP_STR
5823 "Clear all external peers\n"
5824 "Soft reconfig inbound update\n"
5825 "Push out prefix-list ORF and do inbound soft reconfig\n")
5826{
5827 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
5828 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5829}
5830
5831ALIAS (clear_bgp_external_in_prefix_filter,
5832 clear_bgp_ipv6_external_in_prefix_filter_cmd,
5833 "clear bgp ipv6 external in prefix-filter",
5834 CLEAR_STR
5835 BGP_STR
5836 "Address family\n"
5837 "Clear all external peers\n"
5838 "Soft reconfig inbound update\n"
5839 "Push out prefix-list ORF and do inbound soft reconfig\n")
5840
5841DEFUN (clear_ip_bgp_as_soft_in,
5842 clear_ip_bgp_as_soft_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005843 "clear ip bgp " CMD_AS_RANGE " soft in",
paul718e3742002-12-13 20:15:29 +00005844 CLEAR_STR
5845 IP_STR
5846 BGP_STR
5847 "Clear peers with the AS number\n"
5848 "Soft reconfig\n"
5849 "Soft reconfig inbound update\n")
5850{
5851 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5852 BGP_CLEAR_SOFT_IN, argv[0]);
5853}
5854
5855ALIAS (clear_ip_bgp_as_soft_in,
5856 clear_ip_bgp_as_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005857 "clear ip bgp " CMD_AS_RANGE " in",
paul718e3742002-12-13 20:15:29 +00005858 CLEAR_STR
5859 IP_STR
5860 BGP_STR
5861 "Clear peers with the AS number\n"
5862 "Soft reconfig inbound update\n")
5863
5864DEFUN (clear_ip_bgp_as_in_prefix_filter,
5865 clear_ip_bgp_as_in_prefix_filter_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005866 "clear ip bgp " CMD_AS_RANGE " in prefix-filter",
paul718e3742002-12-13 20:15:29 +00005867 CLEAR_STR
5868 IP_STR
5869 BGP_STR
5870 "Clear peers with the AS number\n"
5871 "Soft reconfig inbound update\n"
5872 "Push out prefix-list ORF and do inbound soft reconfig\n")
5873{
5874 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5875 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5876}
5877
5878DEFUN (clear_ip_bgp_as_ipv4_soft_in,
5879 clear_ip_bgp_as_ipv4_soft_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005880 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft in",
paul718e3742002-12-13 20:15:29 +00005881 CLEAR_STR
5882 IP_STR
5883 BGP_STR
5884 "Clear peers with the AS number\n"
5885 "Address family\n"
5886 "Address Family modifier\n"
5887 "Address Family modifier\n"
5888 "Soft reconfig\n"
5889 "Soft reconfig inbound update\n")
5890{
5891 if (strncmp (argv[1], "m", 1) == 0)
5892 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
5893 BGP_CLEAR_SOFT_IN, argv[0]);
5894
5895 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5896 BGP_CLEAR_SOFT_IN, argv[0]);
5897}
5898
5899ALIAS (clear_ip_bgp_as_ipv4_soft_in,
5900 clear_ip_bgp_as_ipv4_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005901 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in",
paul718e3742002-12-13 20:15:29 +00005902 CLEAR_STR
5903 IP_STR
5904 BGP_STR
5905 "Clear peers with the AS number\n"
5906 "Address family\n"
5907 "Address Family modifier\n"
5908 "Address Family modifier\n"
5909 "Soft reconfig inbound update\n")
5910
5911DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter,
5912 clear_ip_bgp_as_ipv4_in_prefix_filter_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005913 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in prefix-filter",
paul718e3742002-12-13 20:15:29 +00005914 CLEAR_STR
5915 IP_STR
5916 BGP_STR
5917 "Clear peers with the AS number\n"
5918 "Address family\n"
5919 "Address Family modifier\n"
5920 "Address Family modifier\n"
5921 "Soft reconfig inbound update\n"
5922 "Push out prefix-list ORF and do inbound soft reconfig\n")
5923{
5924 if (strncmp (argv[1], "m", 1) == 0)
5925 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
5926 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5927
5928 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5929 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5930}
5931
5932DEFUN (clear_ip_bgp_as_vpnv4_soft_in,
5933 clear_ip_bgp_as_vpnv4_soft_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005934 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft in",
paul718e3742002-12-13 20:15:29 +00005935 CLEAR_STR
5936 IP_STR
5937 BGP_STR
5938 "Clear peers with the AS number\n"
5939 "Address family\n"
5940 "Address Family modifier\n"
5941 "Soft reconfig\n"
5942 "Soft reconfig inbound update\n")
5943{
5944 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
5945 BGP_CLEAR_SOFT_IN, argv[0]);
5946}
5947
5948ALIAS (clear_ip_bgp_as_vpnv4_soft_in,
5949 clear_ip_bgp_as_vpnv4_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005950 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast in",
paul718e3742002-12-13 20:15:29 +00005951 CLEAR_STR
5952 IP_STR
5953 BGP_STR
5954 "Clear peers with the AS number\n"
5955 "Address family\n"
5956 "Address Family modifier\n"
5957 "Soft reconfig inbound update\n")
5958
5959DEFUN (clear_bgp_as_soft_in,
5960 clear_bgp_as_soft_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005961 "clear bgp " CMD_AS_RANGE " soft in",
paul718e3742002-12-13 20:15:29 +00005962 CLEAR_STR
5963 BGP_STR
5964 "Clear peers with the AS number\n"
5965 "Soft reconfig\n"
5966 "Soft reconfig inbound update\n")
5967{
5968 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
5969 BGP_CLEAR_SOFT_IN, argv[0]);
5970}
5971
5972ALIAS (clear_bgp_as_soft_in,
5973 clear_bgp_ipv6_as_soft_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005974 "clear bgp ipv6 " CMD_AS_RANGE " soft in",
paul718e3742002-12-13 20:15:29 +00005975 CLEAR_STR
5976 BGP_STR
5977 "Address family\n"
5978 "Clear peers with the AS number\n"
5979 "Soft reconfig\n"
5980 "Soft reconfig inbound update\n")
5981
5982ALIAS (clear_bgp_as_soft_in,
5983 clear_bgp_as_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005984 "clear bgp " CMD_AS_RANGE " in",
paul718e3742002-12-13 20:15:29 +00005985 CLEAR_STR
5986 BGP_STR
5987 "Clear peers with the AS number\n"
5988 "Soft reconfig inbound update\n")
5989
5990ALIAS (clear_bgp_as_soft_in,
5991 clear_bgp_ipv6_as_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005992 "clear bgp ipv6 " CMD_AS_RANGE " in",
paul718e3742002-12-13 20:15:29 +00005993 CLEAR_STR
5994 BGP_STR
5995 "Address family\n"
5996 "Clear peers with the AS number\n"
5997 "Soft reconfig inbound update\n")
5998
5999DEFUN (clear_bgp_as_in_prefix_filter,
6000 clear_bgp_as_in_prefix_filter_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006001 "clear bgp " CMD_AS_RANGE " in prefix-filter",
paul718e3742002-12-13 20:15:29 +00006002 CLEAR_STR
6003 BGP_STR
6004 "Clear peers with the AS number\n"
6005 "Soft reconfig inbound update\n"
6006 "Push out prefix-list ORF and do inbound soft reconfig\n")
6007{
6008 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
6009 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6010}
6011
6012ALIAS (clear_bgp_as_in_prefix_filter,
6013 clear_bgp_ipv6_as_in_prefix_filter_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006014 "clear bgp ipv6 " CMD_AS_RANGE " in prefix-filter",
paul718e3742002-12-13 20:15:29 +00006015 CLEAR_STR
6016 BGP_STR
6017 "Address family\n"
6018 "Clear peers with the AS number\n"
6019 "Soft reconfig inbound update\n"
6020 "Push out prefix-list ORF and do inbound soft reconfig\n")
6021
6022/* Both soft-reconfiguration */
6023DEFUN (clear_ip_bgp_all_soft,
6024 clear_ip_bgp_all_soft_cmd,
6025 "clear ip bgp * soft",
6026 CLEAR_STR
6027 IP_STR
6028 BGP_STR
6029 "Clear all peers\n"
6030 "Soft reconfig\n")
6031{
6032 if (argc == 1)
6033 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
6034 BGP_CLEAR_SOFT_BOTH, NULL);
6035
6036 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6037 BGP_CLEAR_SOFT_BOTH, NULL);
6038}
6039
6040ALIAS (clear_ip_bgp_all_soft,
6041 clear_ip_bgp_instance_all_soft_cmd,
6042 "clear ip bgp view WORD * soft",
6043 CLEAR_STR
6044 IP_STR
6045 BGP_STR
6046 "BGP view\n"
6047 "view name\n"
6048 "Clear all peers\n"
6049 "Soft reconfig\n")
6050
6051
6052DEFUN (clear_ip_bgp_all_ipv4_soft,
6053 clear_ip_bgp_all_ipv4_soft_cmd,
6054 "clear ip bgp * ipv4 (unicast|multicast) soft",
6055 CLEAR_STR
6056 IP_STR
6057 BGP_STR
6058 "Clear all peers\n"
6059 "Address family\n"
6060 "Address Family Modifier\n"
6061 "Address Family Modifier\n"
6062 "Soft reconfig\n")
6063{
6064 if (strncmp (argv[0], "m", 1) == 0)
6065 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
6066 BGP_CLEAR_SOFT_BOTH, NULL);
6067
6068 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6069 BGP_CLEAR_SOFT_BOTH, NULL);
6070}
6071
6072DEFUN (clear_ip_bgp_instance_all_ipv4_soft,
6073 clear_ip_bgp_instance_all_ipv4_soft_cmd,
6074 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft",
6075 CLEAR_STR
6076 IP_STR
6077 BGP_STR
6078 "BGP view\n"
6079 "view name\n"
6080 "Clear all peers\n"
6081 "Address family\n"
6082 "Address Family Modifier\n"
6083 "Address Family Modifier\n"
6084 "Soft reconfig\n")
6085{
6086 if (strncmp (argv[1], "m", 1) == 0)
6087 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
6088 BGP_CLEAR_SOFT_BOTH, NULL);
6089
6090 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6091 BGP_CLEAR_SOFT_BOTH, NULL);
6092}
6093
6094DEFUN (clear_ip_bgp_all_vpnv4_soft,
6095 clear_ip_bgp_all_vpnv4_soft_cmd,
6096 "clear ip bgp * vpnv4 unicast soft",
6097 CLEAR_STR
6098 IP_STR
6099 BGP_STR
6100 "Clear all peers\n"
6101 "Address family\n"
6102 "Address Family Modifier\n"
6103 "Soft reconfig\n")
6104{
6105 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
6106 BGP_CLEAR_SOFT_BOTH, argv[0]);
6107}
6108
6109DEFUN (clear_bgp_all_soft,
6110 clear_bgp_all_soft_cmd,
6111 "clear bgp * soft",
6112 CLEAR_STR
6113 BGP_STR
6114 "Clear all peers\n"
6115 "Soft reconfig\n")
6116{
6117 if (argc == 1)
6118 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
6119 BGP_CLEAR_SOFT_BOTH, argv[0]);
6120
6121 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
6122 BGP_CLEAR_SOFT_BOTH, argv[0]);
6123}
6124
6125ALIAS (clear_bgp_all_soft,
6126 clear_bgp_instance_all_soft_cmd,
6127 "clear bgp view WORD * soft",
6128 CLEAR_STR
6129 BGP_STR
6130 "BGP view\n"
6131 "view name\n"
6132 "Clear all peers\n"
6133 "Soft reconfig\n")
6134
6135ALIAS (clear_bgp_all_soft,
6136 clear_bgp_ipv6_all_soft_cmd,
6137 "clear bgp ipv6 * soft",
6138 CLEAR_STR
6139 BGP_STR
6140 "Address family\n"
6141 "Clear all peers\n"
6142 "Soft reconfig\n")
6143
6144DEFUN (clear_ip_bgp_peer_soft,
6145 clear_ip_bgp_peer_soft_cmd,
6146 "clear ip bgp A.B.C.D soft",
6147 CLEAR_STR
6148 IP_STR
6149 BGP_STR
6150 "BGP neighbor address to clear\n"
6151 "Soft reconfig\n")
6152{
6153 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6154 BGP_CLEAR_SOFT_BOTH, argv[0]);
6155}
6156
6157DEFUN (clear_ip_bgp_peer_ipv4_soft,
6158 clear_ip_bgp_peer_ipv4_soft_cmd,
6159 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft",
6160 CLEAR_STR
6161 IP_STR
6162 BGP_STR
6163 "BGP neighbor address to clear\n"
6164 "Address family\n"
6165 "Address Family Modifier\n"
6166 "Address Family Modifier\n"
6167 "Soft reconfig\n")
6168{
6169 if (strncmp (argv[1], "m", 1) == 0)
6170 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
6171 BGP_CLEAR_SOFT_BOTH, argv[0]);
6172
6173 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6174 BGP_CLEAR_SOFT_BOTH, argv[0]);
6175}
6176
6177DEFUN (clear_ip_bgp_peer_vpnv4_soft,
6178 clear_ip_bgp_peer_vpnv4_soft_cmd,
6179 "clear ip bgp A.B.C.D vpnv4 unicast soft",
6180 CLEAR_STR
6181 IP_STR
6182 BGP_STR
6183 "BGP neighbor address to clear\n"
6184 "Address family\n"
6185 "Address Family Modifier\n"
6186 "Soft reconfig\n")
6187{
6188 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
6189 BGP_CLEAR_SOFT_BOTH, argv[0]);
6190}
6191
6192DEFUN (clear_bgp_peer_soft,
6193 clear_bgp_peer_soft_cmd,
6194 "clear bgp (A.B.C.D|X:X::X:X) soft",
6195 CLEAR_STR
6196 BGP_STR
6197 "BGP neighbor address to clear\n"
6198 "BGP IPv6 neighbor to clear\n"
6199 "Soft reconfig\n")
6200{
6201 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
6202 BGP_CLEAR_SOFT_BOTH, argv[0]);
6203}
6204
6205ALIAS (clear_bgp_peer_soft,
6206 clear_bgp_ipv6_peer_soft_cmd,
6207 "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft",
6208 CLEAR_STR
6209 BGP_STR
6210 "Address family\n"
6211 "BGP neighbor address to clear\n"
6212 "BGP IPv6 neighbor to clear\n"
6213 "Soft reconfig\n")
6214
6215DEFUN (clear_ip_bgp_peer_group_soft,
6216 clear_ip_bgp_peer_group_soft_cmd,
6217 "clear ip bgp peer-group WORD soft",
6218 CLEAR_STR
6219 IP_STR
6220 BGP_STR
6221 "Clear all members of peer-group\n"
6222 "BGP peer-group name\n"
6223 "Soft reconfig\n")
6224{
6225 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6226 BGP_CLEAR_SOFT_BOTH, argv[0]);
6227}
6228
6229DEFUN (clear_ip_bgp_peer_group_ipv4_soft,
6230 clear_ip_bgp_peer_group_ipv4_soft_cmd,
6231 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft",
6232 CLEAR_STR
6233 IP_STR
6234 BGP_STR
6235 "Clear all members of peer-group\n"
6236 "BGP peer-group name\n"
6237 "Address family\n"
6238 "Address Family modifier\n"
6239 "Address Family modifier\n"
6240 "Soft reconfig\n")
6241{
6242 if (strncmp (argv[1], "m", 1) == 0)
6243 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
6244 BGP_CLEAR_SOFT_BOTH, argv[0]);
6245
6246 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6247 BGP_CLEAR_SOFT_BOTH, argv[0]);
6248}
6249
6250DEFUN (clear_bgp_peer_group_soft,
6251 clear_bgp_peer_group_soft_cmd,
6252 "clear bgp peer-group WORD soft",
6253 CLEAR_STR
6254 BGP_STR
6255 "Clear all members of peer-group\n"
6256 "BGP peer-group name\n"
6257 "Soft reconfig\n")
6258{
6259 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
6260 BGP_CLEAR_SOFT_BOTH, argv[0]);
6261}
6262
6263ALIAS (clear_bgp_peer_group_soft,
6264 clear_bgp_ipv6_peer_group_soft_cmd,
6265 "clear bgp ipv6 peer-group WORD soft",
6266 CLEAR_STR
6267 BGP_STR
6268 "Address family\n"
6269 "Clear all members of peer-group\n"
6270 "BGP peer-group name\n"
6271 "Soft reconfig\n")
6272
6273DEFUN (clear_ip_bgp_external_soft,
6274 clear_ip_bgp_external_soft_cmd,
6275 "clear ip bgp external soft",
6276 CLEAR_STR
6277 IP_STR
6278 BGP_STR
6279 "Clear all external peers\n"
6280 "Soft reconfig\n")
6281{
6282 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
6283 BGP_CLEAR_SOFT_BOTH, NULL);
6284}
6285
6286DEFUN (clear_ip_bgp_external_ipv4_soft,
6287 clear_ip_bgp_external_ipv4_soft_cmd,
6288 "clear ip bgp external ipv4 (unicast|multicast) soft",
6289 CLEAR_STR
6290 IP_STR
6291 BGP_STR
6292 "Clear all external peers\n"
6293 "Address family\n"
6294 "Address Family modifier\n"
6295 "Address Family modifier\n"
6296 "Soft reconfig\n")
6297{
6298 if (strncmp (argv[0], "m", 1) == 0)
6299 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
6300 BGP_CLEAR_SOFT_BOTH, NULL);
6301
6302 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
6303 BGP_CLEAR_SOFT_BOTH, NULL);
6304}
6305
6306DEFUN (clear_bgp_external_soft,
6307 clear_bgp_external_soft_cmd,
6308 "clear bgp external soft",
6309 CLEAR_STR
6310 BGP_STR
6311 "Clear all external peers\n"
6312 "Soft reconfig\n")
6313{
6314 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
6315 BGP_CLEAR_SOFT_BOTH, NULL);
6316}
6317
6318ALIAS (clear_bgp_external_soft,
6319 clear_bgp_ipv6_external_soft_cmd,
6320 "clear bgp ipv6 external soft",
6321 CLEAR_STR
6322 BGP_STR
6323 "Address family\n"
6324 "Clear all external peers\n"
6325 "Soft reconfig\n")
6326
6327DEFUN (clear_ip_bgp_as_soft,
6328 clear_ip_bgp_as_soft_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006329 "clear ip bgp " CMD_AS_RANGE " soft",
paul718e3742002-12-13 20:15:29 +00006330 CLEAR_STR
6331 IP_STR
6332 BGP_STR
6333 "Clear peers with the AS number\n"
6334 "Soft reconfig\n")
6335{
6336 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
6337 BGP_CLEAR_SOFT_BOTH, argv[0]);
6338}
6339
6340DEFUN (clear_ip_bgp_as_ipv4_soft,
6341 clear_ip_bgp_as_ipv4_soft_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006342 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft",
paul718e3742002-12-13 20:15:29 +00006343 CLEAR_STR
6344 IP_STR
6345 BGP_STR
6346 "Clear peers with the AS number\n"
6347 "Address family\n"
6348 "Address Family Modifier\n"
6349 "Address Family Modifier\n"
6350 "Soft reconfig\n")
6351{
6352 if (strncmp (argv[1], "m", 1) == 0)
6353 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
6354 BGP_CLEAR_SOFT_BOTH, argv[0]);
6355
6356 return bgp_clear_vty (vty, NULL,AFI_IP, SAFI_UNICAST, clear_as,
6357 BGP_CLEAR_SOFT_BOTH, argv[0]);
6358}
6359
6360DEFUN (clear_ip_bgp_as_vpnv4_soft,
6361 clear_ip_bgp_as_vpnv4_soft_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006362 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft",
paul718e3742002-12-13 20:15:29 +00006363 CLEAR_STR
6364 IP_STR
6365 BGP_STR
6366 "Clear peers with the AS number\n"
6367 "Address family\n"
6368 "Address Family Modifier\n"
6369 "Soft reconfig\n")
6370{
6371 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
6372 BGP_CLEAR_SOFT_BOTH, argv[0]);
6373}
6374
6375DEFUN (clear_bgp_as_soft,
6376 clear_bgp_as_soft_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006377 "clear bgp " CMD_AS_RANGE " soft",
paul718e3742002-12-13 20:15:29 +00006378 CLEAR_STR
6379 BGP_STR
6380 "Clear peers with the AS number\n"
6381 "Soft reconfig\n")
6382{
6383 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
6384 BGP_CLEAR_SOFT_BOTH, argv[0]);
6385}
6386
6387ALIAS (clear_bgp_as_soft,
6388 clear_bgp_ipv6_as_soft_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006389 "clear bgp ipv6 " CMD_AS_RANGE " soft",
paul718e3742002-12-13 20:15:29 +00006390 CLEAR_STR
6391 BGP_STR
6392 "Address family\n"
6393 "Clear peers with the AS number\n"
6394 "Soft reconfig\n")
6395
paulfee0f4c2004-09-13 05:12:46 +00006396/* RS-client soft reconfiguration. */
6397#ifdef HAVE_IPV6
6398DEFUN (clear_bgp_all_rsclient,
6399 clear_bgp_all_rsclient_cmd,
6400 "clear bgp * rsclient",
6401 CLEAR_STR
6402 BGP_STR
6403 "Clear all peers\n"
6404 "Soft reconfig for rsclient RIB\n")
6405{
6406 if (argc == 1)
6407 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
6408 BGP_CLEAR_SOFT_RSCLIENT, NULL);
6409
6410 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
6411 BGP_CLEAR_SOFT_RSCLIENT, NULL);
6412}
6413
6414ALIAS (clear_bgp_all_rsclient,
6415 clear_bgp_ipv6_all_rsclient_cmd,
6416 "clear bgp ipv6 * rsclient",
6417 CLEAR_STR
6418 BGP_STR
6419 "Address family\n"
6420 "Clear all peers\n"
6421 "Soft reconfig for rsclient RIB\n")
6422
6423ALIAS (clear_bgp_all_rsclient,
6424 clear_bgp_instance_all_rsclient_cmd,
6425 "clear bgp view WORD * rsclient",
6426 CLEAR_STR
6427 BGP_STR
6428 "BGP view\n"
6429 "view name\n"
6430 "Clear all peers\n"
6431 "Soft reconfig for rsclient RIB\n")
6432
6433ALIAS (clear_bgp_all_rsclient,
6434 clear_bgp_ipv6_instance_all_rsclient_cmd,
6435 "clear bgp ipv6 view WORD * rsclient",
6436 CLEAR_STR
6437 BGP_STR
6438 "Address family\n"
6439 "BGP view\n"
6440 "view name\n"
6441 "Clear all peers\n"
6442 "Soft reconfig for rsclient RIB\n")
6443#endif /* HAVE_IPV6 */
6444
6445DEFUN (clear_ip_bgp_all_rsclient,
6446 clear_ip_bgp_all_rsclient_cmd,
6447 "clear ip bgp * rsclient",
6448 CLEAR_STR
6449 IP_STR
6450 BGP_STR
6451 "Clear all peers\n"
6452 "Soft reconfig for rsclient RIB\n")
6453{
6454 if (argc == 1)
6455 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
6456 BGP_CLEAR_SOFT_RSCLIENT, NULL);
6457
6458 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6459 BGP_CLEAR_SOFT_RSCLIENT, NULL);
6460}
6461
6462ALIAS (clear_ip_bgp_all_rsclient,
6463 clear_ip_bgp_instance_all_rsclient_cmd,
6464 "clear ip bgp view WORD * rsclient",
6465 CLEAR_STR
6466 IP_STR
6467 BGP_STR
6468 "BGP view\n"
6469 "view name\n"
6470 "Clear all peers\n"
6471 "Soft reconfig for rsclient RIB\n")
6472
6473#ifdef HAVE_IPV6
6474DEFUN (clear_bgp_peer_rsclient,
6475 clear_bgp_peer_rsclient_cmd,
6476 "clear bgp (A.B.C.D|X:X::X:X) rsclient",
6477 CLEAR_STR
6478 BGP_STR
6479 "BGP neighbor IP address to clear\n"
6480 "BGP IPv6 neighbor to clear\n"
6481 "Soft reconfig for rsclient RIB\n")
6482{
6483 if (argc == 2)
6484 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_peer,
6485 BGP_CLEAR_SOFT_RSCLIENT, argv[1]);
6486
6487 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
6488 BGP_CLEAR_SOFT_RSCLIENT, argv[0]);
6489}
6490
6491ALIAS (clear_bgp_peer_rsclient,
6492 clear_bgp_ipv6_peer_rsclient_cmd,
6493 "clear bgp ipv6 (A.B.C.D|X:X::X:X) rsclient",
6494 CLEAR_STR
6495 BGP_STR
6496 "Address family\n"
6497 "BGP neighbor IP address to clear\n"
6498 "BGP IPv6 neighbor to clear\n"
6499 "Soft reconfig for rsclient RIB\n")
6500
6501ALIAS (clear_bgp_peer_rsclient,
6502 clear_bgp_instance_peer_rsclient_cmd,
6503 "clear bgp view WORD (A.B.C.D|X:X::X:X) rsclient",
6504 CLEAR_STR
6505 BGP_STR
6506 "BGP view\n"
6507 "view name\n"
6508 "BGP neighbor IP address to clear\n"
6509 "BGP IPv6 neighbor to clear\n"
6510 "Soft reconfig for rsclient RIB\n")
6511
6512ALIAS (clear_bgp_peer_rsclient,
6513 clear_bgp_ipv6_instance_peer_rsclient_cmd,
6514 "clear bgp ipv6 view WORD (A.B.C.D|X:X::X:X) rsclient",
6515 CLEAR_STR
6516 BGP_STR
6517 "Address family\n"
6518 "BGP view\n"
6519 "view name\n"
6520 "BGP neighbor IP address to clear\n"
6521 "BGP IPv6 neighbor to clear\n"
6522 "Soft reconfig for rsclient RIB\n")
6523#endif /* HAVE_IPV6 */
6524
6525DEFUN (clear_ip_bgp_peer_rsclient,
6526 clear_ip_bgp_peer_rsclient_cmd,
6527 "clear ip bgp (A.B.C.D|X:X::X:X) rsclient",
6528 CLEAR_STR
6529 IP_STR
6530 BGP_STR
6531 "BGP neighbor IP address to clear\n"
6532 "BGP IPv6 neighbor to clear\n"
6533 "Soft reconfig for rsclient RIB\n")
6534{
6535 if (argc == 2)
6536 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_peer,
6537 BGP_CLEAR_SOFT_RSCLIENT, argv[1]);
6538
6539 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6540 BGP_CLEAR_SOFT_RSCLIENT, argv[0]);
6541}
6542
6543ALIAS (clear_ip_bgp_peer_rsclient,
6544 clear_ip_bgp_instance_peer_rsclient_cmd,
6545 "clear ip bgp view WORD (A.B.C.D|X:X::X:X) rsclient",
6546 CLEAR_STR
6547 IP_STR
6548 BGP_STR
6549 "BGP view\n"
6550 "view name\n"
6551 "BGP neighbor IP address to clear\n"
6552 "BGP IPv6 neighbor to clear\n"
6553 "Soft reconfig for rsclient RIB\n")
6554
Michael Lamberte0081f72008-11-16 20:12:04 +00006555DEFUN (show_bgp_views,
6556 show_bgp_views_cmd,
6557 "show bgp views",
6558 SHOW_STR
6559 BGP_STR
6560 "Show the defined BGP views\n")
6561{
6562 struct list *inst = bm->bgp;
6563 struct listnode *node;
6564 struct bgp *bgp;
6565
6566 if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
6567 {
6568 vty_out (vty, "Multiple BGP views are not defined%s", VTY_NEWLINE);
6569 return CMD_WARNING;
6570 }
6571
6572 vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE);
6573 for (ALL_LIST_ELEMENTS_RO(inst, node, bgp))
6574 vty_out (vty, "\t%s (AS%u)%s",
6575 bgp->name ? bgp->name : "(null)",
6576 bgp->as, VTY_NEWLINE);
6577
6578 return CMD_SUCCESS;
6579}
6580
Paul Jakma4bf6a362006-03-30 14:05:23 +00006581DEFUN (show_bgp_memory,
6582 show_bgp_memory_cmd,
6583 "show bgp memory",
6584 SHOW_STR
6585 BGP_STR
6586 "Global BGP memory statistics\n")
6587{
6588 char memstrbuf[MTYPE_MEMSTR_LEN];
6589 unsigned long count;
6590
6591 /* RIB related usage stats */
6592 count = mtype_stats_alloc (MTYPE_BGP_NODE);
6593 vty_out (vty, "%ld RIB nodes, using %s of memory%s", count,
6594 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6595 count * sizeof (struct bgp_node)),
6596 VTY_NEWLINE);
6597
6598 count = mtype_stats_alloc (MTYPE_BGP_ROUTE);
6599 vty_out (vty, "%ld BGP routes, using %s of memory%s", count,
6600 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6601 count * sizeof (struct bgp_info)),
6602 VTY_NEWLINE);
Paul Jakmafb982c22007-05-04 20:15:47 +00006603 if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA)))
6604 vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count,
6605 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6606 count * sizeof (struct bgp_info_extra)),
6607 VTY_NEWLINE);
Paul Jakma4bf6a362006-03-30 14:05:23 +00006608
6609 if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC)))
6610 vty_out (vty, "%ld Static routes, using %s of memory%s", count,
6611 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6612 count * sizeof (struct bgp_static)),
6613 VTY_NEWLINE);
6614
6615 /* Adj-In/Out */
6616 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN)))
6617 vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count,
6618 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6619 count * sizeof (struct bgp_adj_in)),
6620 VTY_NEWLINE);
6621 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT)))
6622 vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count,
6623 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6624 count * sizeof (struct bgp_adj_out)),
6625 VTY_NEWLINE);
6626
6627 if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE)))
6628 vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count,
6629 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6630 count * sizeof (struct bgp_nexthop_cache)),
6631 VTY_NEWLINE);
6632
6633 if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO)))
6634 vty_out (vty, "%ld Dampening entries, using %s of memory%s", count,
6635 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6636 count * sizeof (struct bgp_damp_info)),
6637 VTY_NEWLINE);
6638
6639 /* Attributes */
6640 count = attr_count();
6641 vty_out (vty, "%ld BGP attributes, using %s of memory%s", count,
6642 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6643 count * sizeof(struct attr)),
6644 VTY_NEWLINE);
Paul Jakmafb982c22007-05-04 20:15:47 +00006645 if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA)))
6646 vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count,
6647 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6648 count * sizeof(struct attr_extra)),
6649 VTY_NEWLINE);
Paul Jakma4bf6a362006-03-30 14:05:23 +00006650
6651 if ((count = attr_unknown_count()))
6652 vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE);
6653
6654 /* AS_PATH attributes */
6655 count = aspath_count ();
6656 vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count,
6657 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6658 count * sizeof (struct aspath)),
6659 VTY_NEWLINE);
6660
6661 count = mtype_stats_alloc (MTYPE_AS_SEG);
6662 vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count,
6663 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6664 count * sizeof (struct assegment)),
6665 VTY_NEWLINE);
6666
6667 /* Other attributes */
6668 if ((count = community_count ()))
6669 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
6670 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6671 count * sizeof (struct community)),
6672 VTY_NEWLINE);
6673 if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY)))
6674 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
6675 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6676 count * sizeof (struct ecommunity)),
6677 VTY_NEWLINE);
6678
6679 if ((count = mtype_stats_alloc (MTYPE_CLUSTER)))
6680 vty_out (vty, "%ld Cluster lists, using %s of memory%s", count,
6681 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6682 count * sizeof (struct cluster_list)),
6683 VTY_NEWLINE);
6684
6685 /* Peer related usage */
6686 count = mtype_stats_alloc (MTYPE_BGP_PEER);
6687 vty_out (vty, "%ld peers, using %s of memory%s", count,
6688 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6689 count * sizeof (struct peer)),
6690 VTY_NEWLINE);
6691
6692 if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP)))
6693 vty_out (vty, "%ld peer groups, using %s of memory%s", count,
6694 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6695 count * sizeof (struct peer_group)),
6696 VTY_NEWLINE);
6697
6698 /* Other */
6699 if ((count = mtype_stats_alloc (MTYPE_HASH)))
6700 vty_out (vty, "%ld hash tables, using %s of memory%s", count,
6701 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6702 count * sizeof (struct hash)),
6703 VTY_NEWLINE);
6704 if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET)))
6705 vty_out (vty, "%ld hash buckets, using %s of memory%s", count,
6706 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6707 count * sizeof (struct hash_backet)),
6708 VTY_NEWLINE);
6709 if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP)))
6710 vty_out (vty, "%ld compiled regexes, using %s of memory%s", count,
6711 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6712 count * sizeof (regex_t)),
6713 VTY_NEWLINE);
6714 return CMD_SUCCESS;
6715}
paulfee0f4c2004-09-13 05:12:46 +00006716
paul718e3742002-12-13 20:15:29 +00006717/* Show BGP peer's summary information. */
paul94f2b392005-06-28 12:44:16 +00006718static int
paul718e3742002-12-13 20:15:29 +00006719bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi)
6720{
6721 struct peer *peer;
paul1eb8ef22005-04-07 07:30:20 +00006722 struct listnode *node, *nnode;
Paul Jakma4bf6a362006-03-30 14:05:23 +00006723 unsigned int count = 0;
paul718e3742002-12-13 20:15:29 +00006724 char timebuf[BGP_UPTIME_LEN];
6725 int len;
6726
6727 /* Header string for each address family. */
6728 static char header[] = "Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd";
Paul Jakma4bf6a362006-03-30 14:05:23 +00006729
paul1eb8ef22005-04-07 07:30:20 +00006730 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00006731 {
6732 if (peer->afc[afi][safi])
6733 {
Paul Jakma4bf6a362006-03-30 14:05:23 +00006734 if (!count)
6735 {
6736 unsigned long ents;
6737 char memstrbuf[MTYPE_MEMSTR_LEN];
6738
6739 /* Usage summary and header */
6740 vty_out (vty,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04006741 "BGP router identifier %s, local AS number %u%s",
Paul Jakma4bf6a362006-03-30 14:05:23 +00006742 inet_ntoa (bgp->router_id), bgp->as, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006743
Paul Jakma4bf6a362006-03-30 14:05:23 +00006744 ents = bgp_table_count (bgp->rib[afi][safi]);
6745 vty_out (vty, "RIB entries %ld, using %s of memory%s", ents,
6746 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6747 ents * sizeof (struct bgp_node)),
6748 VTY_NEWLINE);
6749
6750 /* Peer related usage */
6751 ents = listcount (bgp->peer);
6752 vty_out (vty, "Peers %ld, using %s of memory%s",
6753 ents,
6754 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6755 ents * sizeof (struct peer)),
6756 VTY_NEWLINE);
6757
6758 if ((ents = listcount (bgp->rsclient)))
6759 vty_out (vty, "RS-Client peers %ld, using %s of memory%s",
6760 ents,
6761 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6762 ents * sizeof (struct peer)),
6763 VTY_NEWLINE);
6764
6765 if ((ents = listcount (bgp->group)))
6766 vty_out (vty, "Peer groups %ld, using %s of memory%s", ents,
6767 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6768 ents * sizeof (struct peer_group)),
6769 VTY_NEWLINE);
6770
6771 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
6772 vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE);
6773 vty_out (vty, "%s", VTY_NEWLINE);
6774 vty_out (vty, "%s%s", header, VTY_NEWLINE);
6775 }
6776
paul718e3742002-12-13 20:15:29 +00006777 count++;
6778
6779 len = vty_out (vty, "%s", peer->host);
6780 len = 16 - len;
6781 if (len < 1)
6782 vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
6783 else
6784 vty_out (vty, "%*s", len, " ");
6785
hasso3d515fd2005-02-01 21:30:04 +00006786 vty_out (vty, "4 ");
paul718e3742002-12-13 20:15:29 +00006787
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04006788 vty_out (vty, "%5u %7d %7d %8d %4d %4lu ",
paul718e3742002-12-13 20:15:29 +00006789 peer->as,
6790 peer->open_in + peer->update_in + peer->keepalive_in
6791 + peer->notify_in + peer->refresh_in + peer->dynamic_cap_in,
6792 peer->open_out + peer->update_out + peer->keepalive_out
6793 + peer->notify_out + peer->refresh_out
6794 + peer->dynamic_cap_out,
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00006795 0, 0, (unsigned long) peer->obuf->count);
paul718e3742002-12-13 20:15:29 +00006796
6797 vty_out (vty, "%8s",
6798 peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN));
6799
6800 if (peer->status == Established)
6801 {
6802 vty_out (vty, " %8ld", peer->pcount[afi][safi]);
6803 }
6804 else
6805 {
6806 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
6807 vty_out (vty, " Idle (Admin)");
6808 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
6809 vty_out (vty, " Idle (PfxCt)");
6810 else
6811 vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, peer->status));
6812 }
6813
6814 vty_out (vty, "%s", VTY_NEWLINE);
6815 }
6816 }
6817
6818 if (count)
6819 vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE,
6820 count, VTY_NEWLINE);
6821 else
6822 vty_out (vty, "No %s neighbor is configured%s",
6823 afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
6824 return CMD_SUCCESS;
6825}
6826
paul94f2b392005-06-28 12:44:16 +00006827static int
paulfd79ac92004-10-13 05:06:08 +00006828bgp_show_summary_vty (struct vty *vty, const char *name,
6829 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00006830{
6831 struct bgp *bgp;
6832
6833 if (name)
6834 {
6835 bgp = bgp_lookup_by_name (name);
6836
6837 if (! bgp)
6838 {
6839 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
6840 return CMD_WARNING;
6841 }
6842
6843 bgp_show_summary (vty, bgp, afi, safi);
6844 return CMD_SUCCESS;
6845 }
6846
6847 bgp = bgp_get_default ();
6848
6849 if (bgp)
6850 bgp_show_summary (vty, bgp, afi, safi);
6851
6852 return CMD_SUCCESS;
6853}
6854
6855/* `show ip bgp summary' commands. */
6856DEFUN (show_ip_bgp_summary,
6857 show_ip_bgp_summary_cmd,
6858 "show ip bgp summary",
6859 SHOW_STR
6860 IP_STR
6861 BGP_STR
6862 "Summary of BGP neighbor status\n")
6863{
6864 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
6865}
6866
6867DEFUN (show_ip_bgp_instance_summary,
6868 show_ip_bgp_instance_summary_cmd,
6869 "show ip bgp view WORD summary",
6870 SHOW_STR
6871 IP_STR
6872 BGP_STR
6873 "BGP view\n"
6874 "View name\n"
6875 "Summary of BGP neighbor status\n")
6876{
6877 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
6878}
6879
6880DEFUN (show_ip_bgp_ipv4_summary,
6881 show_ip_bgp_ipv4_summary_cmd,
6882 "show ip bgp ipv4 (unicast|multicast) summary",
6883 SHOW_STR
6884 IP_STR
6885 BGP_STR
6886 "Address family\n"
6887 "Address Family modifier\n"
6888 "Address Family modifier\n"
6889 "Summary of BGP neighbor status\n")
6890{
6891 if (strncmp (argv[0], "m", 1) == 0)
6892 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST);
6893
6894 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
6895}
6896
Michael Lambert95cbbd22010-07-23 14:43:04 -04006897ALIAS (show_ip_bgp_ipv4_summary,
6898 show_bgp_ipv4_safi_summary_cmd,
6899 "show bgp ipv4 (unicast|multicast) summary",
6900 SHOW_STR
6901 BGP_STR
6902 "Address family\n"
6903 "Address Family modifier\n"
6904 "Address Family modifier\n"
6905 "Summary of BGP neighbor status\n")
6906
paul718e3742002-12-13 20:15:29 +00006907DEFUN (show_ip_bgp_instance_ipv4_summary,
6908 show_ip_bgp_instance_ipv4_summary_cmd,
6909 "show ip bgp view WORD ipv4 (unicast|multicast) summary",
6910 SHOW_STR
6911 IP_STR
6912 BGP_STR
6913 "BGP view\n"
6914 "View name\n"
6915 "Address family\n"
6916 "Address Family modifier\n"
6917 "Address Family modifier\n"
6918 "Summary of BGP neighbor status\n")
6919{
6920 if (strncmp (argv[1], "m", 1) == 0)
6921 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST);
6922 else
6923 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
6924}
6925
Michael Lambert95cbbd22010-07-23 14:43:04 -04006926ALIAS (show_ip_bgp_instance_ipv4_summary,
6927 show_bgp_instance_ipv4_safi_summary_cmd,
6928 "show bgp view WORD ipv4 (unicast|multicast) summary",
6929 SHOW_STR
6930 BGP_STR
6931 "BGP view\n"
6932 "View name\n"
6933 "Address family\n"
6934 "Address Family modifier\n"
6935 "Address Family modifier\n"
6936 "Summary of BGP neighbor status\n")
6937
paul718e3742002-12-13 20:15:29 +00006938DEFUN (show_ip_bgp_vpnv4_all_summary,
6939 show_ip_bgp_vpnv4_all_summary_cmd,
6940 "show ip bgp vpnv4 all summary",
6941 SHOW_STR
6942 IP_STR
6943 BGP_STR
6944 "Display VPNv4 NLRI specific information\n"
6945 "Display information about all VPNv4 NLRIs\n"
6946 "Summary of BGP neighbor status\n")
6947{
6948 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN);
6949}
6950
6951DEFUN (show_ip_bgp_vpnv4_rd_summary,
6952 show_ip_bgp_vpnv4_rd_summary_cmd,
6953 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn summary",
6954 SHOW_STR
6955 IP_STR
6956 BGP_STR
6957 "Display VPNv4 NLRI specific information\n"
6958 "Display information for a route distinguisher\n"
6959 "VPN Route Distinguisher\n"
6960 "Summary of BGP neighbor status\n")
6961{
6962 int ret;
6963 struct prefix_rd prd;
6964
6965 ret = str2prefix_rd (argv[0], &prd);
6966 if (! ret)
6967 {
6968 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
6969 return CMD_WARNING;
6970 }
6971
6972 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN);
6973}
6974
6975#ifdef HAVE_IPV6
6976DEFUN (show_bgp_summary,
6977 show_bgp_summary_cmd,
6978 "show bgp summary",
6979 SHOW_STR
6980 BGP_STR
6981 "Summary of BGP neighbor status\n")
6982{
6983 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
6984}
6985
6986DEFUN (show_bgp_instance_summary,
6987 show_bgp_instance_summary_cmd,
6988 "show bgp view WORD summary",
6989 SHOW_STR
6990 BGP_STR
6991 "BGP view\n"
6992 "View name\n"
6993 "Summary of BGP neighbor status\n")
6994{
6995 return bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
6996}
6997
6998ALIAS (show_bgp_summary,
6999 show_bgp_ipv6_summary_cmd,
7000 "show bgp ipv6 summary",
7001 SHOW_STR
7002 BGP_STR
7003 "Address family\n"
7004 "Summary of BGP neighbor status\n")
7005
7006ALIAS (show_bgp_instance_summary,
7007 show_bgp_instance_ipv6_summary_cmd,
7008 "show bgp view WORD ipv6 summary",
7009 SHOW_STR
7010 BGP_STR
7011 "BGP view\n"
7012 "View name\n"
7013 "Address family\n"
7014 "Summary of BGP neighbor status\n")
7015
Michael Lambert95cbbd22010-07-23 14:43:04 -04007016DEFUN (show_bgp_ipv6_safi_summary,
7017 show_bgp_ipv6_safi_summary_cmd,
7018 "show bgp ipv6 (unicast|multicast) summary",
7019 SHOW_STR
7020 BGP_STR
7021 "Address family\n"
7022 "Address Family modifier\n"
7023 "Address Family modifier\n"
7024 "Summary of BGP neighbor status\n")
7025{
7026 if (strncmp (argv[0], "m", 1) == 0)
7027 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST);
7028
7029 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
7030}
7031
7032DEFUN (show_bgp_instance_ipv6_safi_summary,
7033 show_bgp_instance_ipv6_safi_summary_cmd,
7034 "show bgp view WORD ipv6 (unicast|multicast) summary",
7035 SHOW_STR
7036 BGP_STR
7037 "BGP view\n"
7038 "View name\n"
7039 "Address family\n"
7040 "Address Family modifier\n"
7041 "Address Family modifier\n"
7042 "Summary of BGP neighbor status\n")
7043{
7044 if (strncmp (argv[1], "m", 1) == 0)
7045 return bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_MULTICAST);
7046
7047 return bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
7048}
7049
paul718e3742002-12-13 20:15:29 +00007050/* old command */
7051DEFUN (show_ipv6_bgp_summary,
7052 show_ipv6_bgp_summary_cmd,
7053 "show ipv6 bgp summary",
7054 SHOW_STR
7055 IPV6_STR
7056 BGP_STR
7057 "Summary of BGP neighbor status\n")
7058{
7059 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
7060}
7061
7062/* old command */
7063DEFUN (show_ipv6_mbgp_summary,
7064 show_ipv6_mbgp_summary_cmd,
7065 "show ipv6 mbgp summary",
7066 SHOW_STR
7067 IPV6_STR
7068 MBGP_STR
7069 "Summary of BGP neighbor status\n")
7070{
7071 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST);
7072}
7073#endif /* HAVE_IPV6 */
7074
paulfd79ac92004-10-13 05:06:08 +00007075const char *
hasso538621f2004-05-21 09:31:30 +00007076afi_safi_print (afi_t afi, safi_t safi)
7077{
7078 if (afi == AFI_IP && safi == SAFI_UNICAST)
7079 return "IPv4 Unicast";
7080 else if (afi == AFI_IP && safi == SAFI_MULTICAST)
7081 return "IPv4 Multicast";
7082 else if (afi == AFI_IP && safi == SAFI_MPLS_VPN)
7083 return "VPNv4 Unicast";
7084 else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
7085 return "IPv6 Unicast";
7086 else if (afi == AFI_IP6 && safi == SAFI_MULTICAST)
7087 return "IPv6 Multicast";
7088 else
7089 return "Unknown";
7090}
7091
paul718e3742002-12-13 20:15:29 +00007092/* Show BGP peer's information. */
7093enum show_type
7094{
7095 show_all,
7096 show_peer
7097};
7098
paul94f2b392005-06-28 12:44:16 +00007099static void
paul718e3742002-12-13 20:15:29 +00007100bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p,
7101 afi_t afi, safi_t safi,
7102 u_int16_t adv_smcap, u_int16_t adv_rmcap,
7103 u_int16_t rcv_smcap, u_int16_t rcv_rmcap)
7104{
7105 /* Send-Mode */
7106 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)
7107 || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
7108 {
7109 vty_out (vty, " Send-mode: ");
7110 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
7111 vty_out (vty, "advertised");
7112 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
7113 vty_out (vty, "%sreceived",
7114 CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ?
7115 ", " : "");
7116 vty_out (vty, "%s", VTY_NEWLINE);
7117 }
7118
7119 /* Receive-Mode */
7120 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)
7121 || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
7122 {
7123 vty_out (vty, " Receive-mode: ");
7124 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
7125 vty_out (vty, "advertised");
7126 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
7127 vty_out (vty, "%sreceived",
7128 CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ?
7129 ", " : "");
7130 vty_out (vty, "%s", VTY_NEWLINE);
7131 }
7132}
7133
paul94f2b392005-06-28 12:44:16 +00007134static void
paul718e3742002-12-13 20:15:29 +00007135bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi)
7136{
7137 struct bgp_filter *filter;
7138 char orf_pfx_name[BUFSIZ];
7139 int orf_pfx_count;
7140
7141 filter = &p->filter[afi][safi];
7142
hasso538621f2004-05-21 09:31:30 +00007143 vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi),
paul718e3742002-12-13 20:15:29 +00007144 VTY_NEWLINE);
hasso538621f2004-05-21 09:31:30 +00007145
paul718e3742002-12-13 20:15:29 +00007146 if (p->af_group[afi][safi])
7147 vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE);
7148
7149 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7150 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
7151 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
7152 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7153 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
7154 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
7155 vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE);
7156
7157 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7158 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
7159 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7160 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
7161 {
7162 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
7163 ORF_TYPE_PREFIX, VTY_NEWLINE);
7164 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
7165 PEER_CAP_ORF_PREFIX_SM_ADV,
7166 PEER_CAP_ORF_PREFIX_RM_ADV,
7167 PEER_CAP_ORF_PREFIX_SM_RCV,
7168 PEER_CAP_ORF_PREFIX_RM_RCV);
7169 }
7170 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7171 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
7172 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7173 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
7174 {
7175 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
7176 ORF_TYPE_PREFIX_OLD, VTY_NEWLINE);
7177 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
7178 PEER_CAP_ORF_PREFIX_SM_ADV,
7179 PEER_CAP_ORF_PREFIX_RM_ADV,
7180 PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
7181 PEER_CAP_ORF_PREFIX_RM_OLD_RCV);
7182 }
7183
7184 sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
7185 orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name);
7186
7187 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
7188 || orf_pfx_count)
7189 {
7190 vty_out (vty, " Outbound Route Filter (ORF):");
7191 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
7192 vty_out (vty, " sent;");
7193 if (orf_pfx_count)
7194 vty_out (vty, " received (%d entries)", orf_pfx_count);
7195 vty_out (vty, "%s", VTY_NEWLINE);
7196 }
7197 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
7198 vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE);
7199
7200 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
7201 vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE);
7202 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
7203 vty_out (vty, " Route-Server Client%s", VTY_NEWLINE);
7204 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
7205 vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE);
7206 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
7207 vty_out (vty, " Private AS number removed from updates to this neighbor%s", VTY_NEWLINE);
7208 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF))
7209 vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE);
7210 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
7211 vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE);
7212 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
7213 vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE);
7214 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
7215 vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE);
7216 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
7217 || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
7218 {
7219 vty_out (vty, " Community attribute sent to this neighbor");
7220 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
7221 && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
hasso538621f2004-05-21 09:31:30 +00007222 vty_out (vty, "(both)%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007223 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
hasso538621f2004-05-21 09:31:30 +00007224 vty_out (vty, "(extended)%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007225 else
hasso538621f2004-05-21 09:31:30 +00007226 vty_out (vty, "(standard)%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007227 }
7228 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
7229 {
7230 vty_out (vty, " Default information originate,");
7231
7232 if (p->default_rmap[afi][safi].name)
7233 vty_out (vty, " default route-map %s%s,",
7234 p->default_rmap[afi][safi].map ? "*" : "",
7235 p->default_rmap[afi][safi].name);
7236 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
7237 vty_out (vty, " default sent%s", VTY_NEWLINE);
7238 else
7239 vty_out (vty, " default not sent%s", VTY_NEWLINE);
7240 }
7241
7242 if (filter->plist[FILTER_IN].name
7243 || filter->dlist[FILTER_IN].name
7244 || filter->aslist[FILTER_IN].name
paulfee0f4c2004-09-13 05:12:46 +00007245 || filter->map[RMAP_IN].name)
paul718e3742002-12-13 20:15:29 +00007246 vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE);
7247 if (filter->plist[FILTER_OUT].name
7248 || filter->dlist[FILTER_OUT].name
7249 || filter->aslist[FILTER_OUT].name
paulfee0f4c2004-09-13 05:12:46 +00007250 || filter->map[RMAP_OUT].name
paul718e3742002-12-13 20:15:29 +00007251 || filter->usmap.name)
7252 vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE);
paulfee0f4c2004-09-13 05:12:46 +00007253 if (filter->map[RMAP_IMPORT].name)
7254 vty_out (vty, " Import policy for this RS-client configured%s", VTY_NEWLINE);
7255 if (filter->map[RMAP_EXPORT].name)
7256 vty_out (vty, " Export policy for this RS-client configured%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007257
7258 /* prefix-list */
7259 if (filter->plist[FILTER_IN].name)
7260 vty_out (vty, " Incoming update prefix filter list is %s%s%s",
7261 filter->plist[FILTER_IN].plist ? "*" : "",
7262 filter->plist[FILTER_IN].name,
7263 VTY_NEWLINE);
7264 if (filter->plist[FILTER_OUT].name)
7265 vty_out (vty, " Outgoing update prefix filter list is %s%s%s",
7266 filter->plist[FILTER_OUT].plist ? "*" : "",
7267 filter->plist[FILTER_OUT].name,
7268 VTY_NEWLINE);
7269
7270 /* distribute-list */
7271 if (filter->dlist[FILTER_IN].name)
7272 vty_out (vty, " Incoming update network filter list is %s%s%s",
7273 filter->dlist[FILTER_IN].alist ? "*" : "",
7274 filter->dlist[FILTER_IN].name,
7275 VTY_NEWLINE);
7276 if (filter->dlist[FILTER_OUT].name)
7277 vty_out (vty, " Outgoing update network filter list is %s%s%s",
7278 filter->dlist[FILTER_OUT].alist ? "*" : "",
7279 filter->dlist[FILTER_OUT].name,
7280 VTY_NEWLINE);
7281
7282 /* filter-list. */
7283 if (filter->aslist[FILTER_IN].name)
7284 vty_out (vty, " Incoming update AS path filter list is %s%s%s",
7285 filter->aslist[FILTER_IN].aslist ? "*" : "",
7286 filter->aslist[FILTER_IN].name,
7287 VTY_NEWLINE);
7288 if (filter->aslist[FILTER_OUT].name)
7289 vty_out (vty, " Outgoing update AS path filter list is %s%s%s",
7290 filter->aslist[FILTER_OUT].aslist ? "*" : "",
7291 filter->aslist[FILTER_OUT].name,
7292 VTY_NEWLINE);
7293
7294 /* route-map. */
paulfee0f4c2004-09-13 05:12:46 +00007295 if (filter->map[RMAP_IN].name)
paul718e3742002-12-13 20:15:29 +00007296 vty_out (vty, " Route map for incoming advertisements is %s%s%s",
paulfee0f4c2004-09-13 05:12:46 +00007297 filter->map[RMAP_IN].map ? "*" : "",
7298 filter->map[RMAP_IN].name,
paul718e3742002-12-13 20:15:29 +00007299 VTY_NEWLINE);
paulfee0f4c2004-09-13 05:12:46 +00007300 if (filter->map[RMAP_OUT].name)
paul718e3742002-12-13 20:15:29 +00007301 vty_out (vty, " Route map for outgoing advertisements is %s%s%s",
paulfee0f4c2004-09-13 05:12:46 +00007302 filter->map[RMAP_OUT].map ? "*" : "",
7303 filter->map[RMAP_OUT].name,
7304 VTY_NEWLINE);
7305 if (filter->map[RMAP_IMPORT].name)
7306 vty_out (vty, " Route map for advertisements going into this RS-client's table is %s%s%s",
7307 filter->map[RMAP_IMPORT].map ? "*" : "",
7308 filter->map[RMAP_IMPORT].name,
7309 VTY_NEWLINE);
7310 if (filter->map[RMAP_EXPORT].name)
7311 vty_out (vty, " Route map for advertisements coming from this RS-client is %s%s%s",
7312 filter->map[RMAP_EXPORT].map ? "*" : "",
7313 filter->map[RMAP_EXPORT].name,
paul718e3742002-12-13 20:15:29 +00007314 VTY_NEWLINE);
7315
7316 /* unsuppress-map */
7317 if (filter->usmap.name)
7318 vty_out (vty, " Route map for selective unsuppress is %s%s%s",
7319 filter->usmap.map ? "*" : "",
7320 filter->usmap.name, VTY_NEWLINE);
7321
7322 /* Receive prefix count */
hassoe0701b72004-05-20 09:19:34 +00007323 vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE);
7324
paul718e3742002-12-13 20:15:29 +00007325 /* Maximum prefix */
7326 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
7327 {
hasso0a486e52005-02-01 20:57:17 +00007328 vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi],
paul718e3742002-12-13 20:15:29 +00007329 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)
hasso0a486e52005-02-01 20:57:17 +00007330 ? " (warning-only)" : "", VTY_NEWLINE);
7331 vty_out (vty, " Threshold for warning message %d%%",
7332 p->pmax_threshold[afi][safi]);
7333 if (p->pmax_restart[afi][safi])
7334 vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]);
7335 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007336 }
paul718e3742002-12-13 20:15:29 +00007337
7338 vty_out (vty, "%s", VTY_NEWLINE);
7339}
7340
paul94f2b392005-06-28 12:44:16 +00007341static void
paul718e3742002-12-13 20:15:29 +00007342bgp_show_peer (struct vty *vty, struct peer *p)
7343{
7344 struct bgp *bgp;
7345 char buf1[BUFSIZ];
7346 char timebuf[BGP_UPTIME_LEN];
hasso538621f2004-05-21 09:31:30 +00007347 afi_t afi;
7348 safi_t safi;
paul718e3742002-12-13 20:15:29 +00007349
7350 bgp = p->bgp;
7351
7352 /* Configured IP address. */
7353 vty_out (vty, "BGP neighbor is %s, ", p->host);
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04007354 vty_out (vty, "remote AS %u, ", p->as);
7355 vty_out (vty, "local AS %u%s, ",
paul718e3742002-12-13 20:15:29 +00007356 p->change_local_as ? p->change_local_as : p->local_as,
7357 CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ?
7358 " no-prepend" : "");
7359 vty_out (vty, "%s link%s",
7360 p->as == p->local_as ? "internal" : "external",
7361 VTY_NEWLINE);
7362
7363 /* Description. */
7364 if (p->desc)
7365 vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE);
7366
7367 /* Peer-group */
7368 if (p->group)
7369 vty_out (vty, " Member of peer-group %s for session parameters%s",
7370 p->group->name, VTY_NEWLINE);
7371
7372 /* Administrative shutdown. */
7373 if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
7374 vty_out (vty, " Administratively shut down%s", VTY_NEWLINE);
7375
7376 /* BGP Version. */
7377 vty_out (vty, " BGP version 4");
paul718e3742002-12-13 20:15:29 +00007378 vty_out (vty, ", remote router ID %s%s",
7379 inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ),
7380 VTY_NEWLINE);
7381
7382 /* Confederation */
hassoe0701b72004-05-20 09:19:34 +00007383 if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION)
7384 && bgp_confederation_peers_check (bgp, p->as))
paul718e3742002-12-13 20:15:29 +00007385 vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE);
7386
7387 /* Status. */
7388 vty_out (vty, " BGP state = %s",
7389 LOOKUP (bgp_status_msg, p->status));
7390 if (p->status == Established)
7391 vty_out (vty, ", up for %8s",
7392 peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN));
hasso93406d82005-02-02 14:40:33 +00007393 else if (p->status == Active)
7394 {
7395 if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE))
7396 vty_out (vty, " (passive)");
7397 else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT))
7398 vty_out (vty, " (NSF passive)");
7399 }
paul718e3742002-12-13 20:15:29 +00007400 vty_out (vty, "%s", VTY_NEWLINE);
7401
7402 /* read timer */
7403 vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN));
7404
7405 /* Configured timer values. */
7406 vty_out (vty, ", hold time is %d, keepalive interval is %d seconds%s",
7407 p->v_holdtime, p->v_keepalive, VTY_NEWLINE);
7408 if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
7409 {
7410 vty_out (vty, " Configured hold time is %d", p->holdtime);
7411 vty_out (vty, ", keepalive interval is %d seconds%s",
7412 p->keepalive, VTY_NEWLINE);
7413 }
hasso93406d82005-02-02 14:40:33 +00007414
paul718e3742002-12-13 20:15:29 +00007415 /* Capability. */
7416 if (p->status == Established)
7417 {
hasso538621f2004-05-21 09:31:30 +00007418 if (p->cap
paul718e3742002-12-13 20:15:29 +00007419 || p->afc_adv[AFI_IP][SAFI_UNICAST]
7420 || p->afc_recv[AFI_IP][SAFI_UNICAST]
7421 || p->afc_adv[AFI_IP][SAFI_MULTICAST]
7422 || p->afc_recv[AFI_IP][SAFI_MULTICAST]
7423#ifdef HAVE_IPV6
7424 || p->afc_adv[AFI_IP6][SAFI_UNICAST]
7425 || p->afc_recv[AFI_IP6][SAFI_UNICAST]
7426 || p->afc_adv[AFI_IP6][SAFI_MULTICAST]
7427 || p->afc_recv[AFI_IP6][SAFI_MULTICAST]
7428#endif /* HAVE_IPV6 */
7429 || p->afc_adv[AFI_IP][SAFI_MPLS_VPN]
7430 || p->afc_recv[AFI_IP][SAFI_MPLS_VPN])
7431 {
7432 vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE);
7433
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00007434 /* AS4 */
7435 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)
7436 || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
7437 {
7438 vty_out (vty, " 4 Byte AS:");
7439 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
7440 vty_out (vty, " advertised");
7441 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
7442 vty_out (vty, " %sreceived",
7443 CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : "");
7444 vty_out (vty, "%s", VTY_NEWLINE);
7445 }
paul718e3742002-12-13 20:15:29 +00007446 /* Dynamic */
7447 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
7448 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
7449 {
7450 vty_out (vty, " Dynamic:");
7451 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
7452 vty_out (vty, " advertised");
7453 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
hasso538621f2004-05-21 09:31:30 +00007454 vty_out (vty, " %sreceived",
7455 CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : "");
paul718e3742002-12-13 20:15:29 +00007456 vty_out (vty, "%s", VTY_NEWLINE);
7457 }
7458
7459 /* Route Refresh */
7460 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
7461 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
7462 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
7463 {
7464 vty_out (vty, " Route refresh:");
7465 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
7466 vty_out (vty, " advertised");
7467 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
7468 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
hasso538621f2004-05-21 09:31:30 +00007469 vty_out (vty, " %sreceived(%s)",
7470 CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "",
7471 (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)
7472 && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ?
7473 "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new");
7474
paul718e3742002-12-13 20:15:29 +00007475 vty_out (vty, "%s", VTY_NEWLINE);
7476 }
7477
hasso538621f2004-05-21 09:31:30 +00007478 /* Multiprotocol Extensions */
7479 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7480 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7481 if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
paul718e3742002-12-13 20:15:29 +00007482 {
hasso538621f2004-05-21 09:31:30 +00007483 vty_out (vty, " Address family %s:", afi_safi_print (afi, safi));
7484 if (p->afc_adv[afi][safi])
7485 vty_out (vty, " advertised");
7486 if (p->afc_recv[afi][safi])
7487 vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : "");
7488 vty_out (vty, "%s", VTY_NEWLINE);
7489 }
7490
7491 /* Gracefull Restart */
7492 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
7493 || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
paul718e3742002-12-13 20:15:29 +00007494 {
hasso538621f2004-05-21 09:31:30 +00007495 vty_out (vty, " Graceful Restart Capabilty:");
7496 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
paul718e3742002-12-13 20:15:29 +00007497 vty_out (vty, " advertised");
hasso538621f2004-05-21 09:31:30 +00007498 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
7499 vty_out (vty, " %sreceived",
7500 CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : "");
paul718e3742002-12-13 20:15:29 +00007501 vty_out (vty, "%s", VTY_NEWLINE);
hasso538621f2004-05-21 09:31:30 +00007502
7503 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
paul718e3742002-12-13 20:15:29 +00007504 {
hasso538621f2004-05-21 09:31:30 +00007505 int restart_af_count = 0;
7506
7507 vty_out (vty, " Remote Restart timer is %d seconds%s",
hasso93406d82005-02-02 14:40:33 +00007508 p->v_gr_restart, VTY_NEWLINE);
7509 vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE);
hasso538621f2004-05-21 09:31:30 +00007510
7511 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7512 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7513 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
7514 {
hasso93406d82005-02-02 14:40:33 +00007515 vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "",
7516 afi_safi_print (afi, safi),
7517 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ?
7518 "preserved" : "not preserved");
hasso538621f2004-05-21 09:31:30 +00007519 restart_af_count++;
hasso93406d82005-02-02 14:40:33 +00007520 }
hasso538621f2004-05-21 09:31:30 +00007521 if (! restart_af_count)
7522 vty_out (vty, "none");
7523 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007524 }
paul718e3742002-12-13 20:15:29 +00007525 }
paul718e3742002-12-13 20:15:29 +00007526 }
7527 }
7528
hasso93406d82005-02-02 14:40:33 +00007529 /* graceful restart information */
7530 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
7531 || p->t_gr_restart
7532 || p->t_gr_stale)
7533 {
7534 int eor_send_af_count = 0;
7535 int eor_receive_af_count = 0;
7536
7537 vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE);
7538 if (p->status == Established)
7539 {
7540 vty_out (vty, " End-of-RIB send: ");
7541 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7542 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7543 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND))
7544 {
7545 vty_out (vty, "%s%s", eor_send_af_count ? ", " : "",
7546 afi_safi_print (afi, safi));
7547 eor_send_af_count++;
7548 }
7549 vty_out (vty, "%s", VTY_NEWLINE);
7550
7551 vty_out (vty, " End-of-RIB received: ");
7552 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7553 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7554 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED))
7555 {
7556 vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "",
7557 afi_safi_print (afi, safi));
7558 eor_receive_af_count++;
7559 }
7560 vty_out (vty, "%s", VTY_NEWLINE);
7561 }
7562
7563 if (p->t_gr_restart)
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00007564 vty_out (vty, " The remaining time of restart timer is %ld%s",
7565 thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE);
7566
hasso93406d82005-02-02 14:40:33 +00007567 if (p->t_gr_stale)
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00007568 vty_out (vty, " The remaining time of stalepath timer is %ld%s",
7569 thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE);
hasso93406d82005-02-02 14:40:33 +00007570 }
7571
paul718e3742002-12-13 20:15:29 +00007572 /* Packet counts. */
hasso93406d82005-02-02 14:40:33 +00007573 vty_out (vty, " Message statistics:%s", VTY_NEWLINE);
7574 vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00007575 vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE);
hasso93406d82005-02-02 14:40:33 +00007576 vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE);
7577 vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE);
7578 vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE);
7579 vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE);
7580 vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE);
7581 vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE);
7582 vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE);
7583 vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out +
7584 p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out,
7585 p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in +
7586 p->dynamic_cap_in, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007587
7588 /* advertisement-interval */
7589 vty_out (vty, " Minimum time between advertisement runs is %d seconds%s",
7590 p->v_routeadv, VTY_NEWLINE);
7591
7592 /* Update-source. */
7593 if (p->update_if || p->update_source)
7594 {
7595 vty_out (vty, " Update source is ");
7596 if (p->update_if)
7597 vty_out (vty, "%s", p->update_if);
7598 else if (p->update_source)
7599 vty_out (vty, "%s",
7600 sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
7601 vty_out (vty, "%s", VTY_NEWLINE);
7602 }
7603
7604 /* Default weight */
7605 if (CHECK_FLAG (p->config, PEER_CONFIG_WEIGHT))
7606 vty_out (vty, " Default weight %d%s", p->weight,
7607 VTY_NEWLINE);
7608
7609 vty_out (vty, "%s", VTY_NEWLINE);
7610
7611 /* Address Family Information */
hasso538621f2004-05-21 09:31:30 +00007612 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7613 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7614 if (p->afc[afi][safi])
7615 bgp_show_peer_afi (vty, p, afi, safi);
paul718e3742002-12-13 20:15:29 +00007616
7617 vty_out (vty, " Connections established %d; dropped %d%s",
7618 p->established, p->dropped,
7619 VTY_NEWLINE);
7620
hassoe0701b72004-05-20 09:19:34 +00007621 if (! p->dropped)
7622 vty_out (vty, " Last reset never%s", VTY_NEWLINE);
7623 else
7624 vty_out (vty, " Last reset %s, due to %s%s",
7625 peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN),
7626 peer_down_str[(int) p->last_reset], VTY_NEWLINE);
paul848973c2003-08-13 00:32:49 +00007627
paul718e3742002-12-13 20:15:29 +00007628 if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW))
7629 {
7630 vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE);
hasso0a486e52005-02-01 20:57:17 +00007631
7632 if (p->t_pmax_restart)
7633 vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s",
7634 p->host, thread_timer_remain_second (p->t_pmax_restart),
7635 VTY_NEWLINE);
7636 else
7637 vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s",
7638 p->host, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007639 }
7640
Stephen Hemmingerf5a48272011-03-24 17:30:21 +00007641 /* EBGP Multihop and GTSM */
7642 if (peer_sort (p) != BGP_PEER_IBGP)
7643 {
7644 if (p->gtsm_hops > 0)
7645 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
7646 p->gtsm_hops, VTY_NEWLINE);
7647 else if (p->ttl > 1)
7648 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
7649 p->ttl, VTY_NEWLINE);
7650 }
paul718e3742002-12-13 20:15:29 +00007651
7652 /* Local address. */
7653 if (p->su_local)
7654 {
hasso93406d82005-02-02 14:40:33 +00007655 vty_out (vty, "Local host: %s, Local port: %d%s",
paul718e3742002-12-13 20:15:29 +00007656 sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN),
7657 ntohs (p->su_local->sin.sin_port),
paul718e3742002-12-13 20:15:29 +00007658 VTY_NEWLINE);
7659 }
7660
7661 /* Remote address. */
7662 if (p->su_remote)
7663 {
7664 vty_out (vty, "Foreign host: %s, Foreign port: %d%s",
7665 sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN),
7666 ntohs (p->su_remote->sin.sin_port),
7667 VTY_NEWLINE);
7668 }
7669
7670 /* Nexthop display. */
7671 if (p->su_local)
7672 {
7673 vty_out (vty, "Nexthop: %s%s",
7674 inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ),
7675 VTY_NEWLINE);
7676#ifdef HAVE_IPV6
7677 vty_out (vty, "Nexthop global: %s%s",
7678 inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ),
7679 VTY_NEWLINE);
7680 vty_out (vty, "Nexthop local: %s%s",
7681 inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ),
7682 VTY_NEWLINE);
7683 vty_out (vty, "BGP connection: %s%s",
7684 p->shared_network ? "shared network" : "non shared network",
7685 VTY_NEWLINE);
7686#endif /* HAVE_IPV6 */
7687 }
7688
7689 /* Timer information. */
7690 if (p->t_start)
7691 vty_out (vty, "Next start timer due in %ld seconds%s",
7692 thread_timer_remain_second (p->t_start), VTY_NEWLINE);
7693 if (p->t_connect)
7694 vty_out (vty, "Next connect timer due in %ld seconds%s",
7695 thread_timer_remain_second (p->t_connect), VTY_NEWLINE);
7696
7697 vty_out (vty, "Read thread: %s Write thread: %s%s",
7698 p->t_read ? "on" : "off",
7699 p->t_write ? "on" : "off",
7700 VTY_NEWLINE);
7701
7702 if (p->notify.code == BGP_NOTIFY_OPEN_ERR
7703 && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL)
7704 bgp_capability_vty_out (vty, p);
7705
7706 vty_out (vty, "%s", VTY_NEWLINE);
7707}
7708
paul94f2b392005-06-28 12:44:16 +00007709static int
paul718e3742002-12-13 20:15:29 +00007710bgp_show_neighbor (struct vty *vty, struct bgp *bgp,
7711 enum show_type type, union sockunion *su)
7712{
paul1eb8ef22005-04-07 07:30:20 +00007713 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00007714 struct peer *peer;
7715 int find = 0;
7716
paul1eb8ef22005-04-07 07:30:20 +00007717 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00007718 {
7719 switch (type)
7720 {
7721 case show_all:
7722 bgp_show_peer (vty, peer);
7723 break;
7724 case show_peer:
7725 if (sockunion_same (&peer->su, su))
7726 {
7727 find = 1;
7728 bgp_show_peer (vty, peer);
7729 }
7730 break;
7731 }
7732 }
7733
7734 if (type == show_peer && ! find)
7735 vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE);
7736
7737 return CMD_SUCCESS;
7738}
7739
paul94f2b392005-06-28 12:44:16 +00007740static int
paulfd79ac92004-10-13 05:06:08 +00007741bgp_show_neighbor_vty (struct vty *vty, const char *name,
7742 enum show_type type, const char *ip_str)
paul718e3742002-12-13 20:15:29 +00007743{
7744 int ret;
7745 struct bgp *bgp;
7746 union sockunion su;
7747
7748 if (ip_str)
7749 {
7750 ret = str2sockunion (ip_str, &su);
7751 if (ret < 0)
7752 {
7753 vty_out (vty, "%% Malformed address: %s%s", ip_str, VTY_NEWLINE);
7754 return CMD_WARNING;
7755 }
7756 }
7757
7758 if (name)
7759 {
7760 bgp = bgp_lookup_by_name (name);
7761
7762 if (! bgp)
7763 {
7764 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
7765 return CMD_WARNING;
7766 }
7767
7768 bgp_show_neighbor (vty, bgp, type, &su);
7769
7770 return CMD_SUCCESS;
7771 }
7772
7773 bgp = bgp_get_default ();
7774
7775 if (bgp)
7776 bgp_show_neighbor (vty, bgp, type, &su);
7777
7778 return CMD_SUCCESS;
7779}
7780
7781/* "show ip bgp neighbors" commands. */
7782DEFUN (show_ip_bgp_neighbors,
7783 show_ip_bgp_neighbors_cmd,
7784 "show ip bgp neighbors",
7785 SHOW_STR
7786 IP_STR
7787 BGP_STR
7788 "Detailed information on TCP and BGP neighbor connections\n")
7789{
7790 return bgp_show_neighbor_vty (vty, NULL, show_all, NULL);
7791}
7792
7793ALIAS (show_ip_bgp_neighbors,
7794 show_ip_bgp_ipv4_neighbors_cmd,
7795 "show ip bgp ipv4 (unicast|multicast) neighbors",
7796 SHOW_STR
7797 IP_STR
7798 BGP_STR
7799 "Address family\n"
7800 "Address Family modifier\n"
7801 "Address Family modifier\n"
7802 "Detailed information on TCP and BGP neighbor connections\n")
7803
7804ALIAS (show_ip_bgp_neighbors,
7805 show_ip_bgp_vpnv4_all_neighbors_cmd,
7806 "show ip bgp vpnv4 all neighbors",
7807 SHOW_STR
7808 IP_STR
7809 BGP_STR
7810 "Display VPNv4 NLRI specific information\n"
7811 "Display information about all VPNv4 NLRIs\n"
7812 "Detailed information on TCP and BGP neighbor connections\n")
7813
7814ALIAS (show_ip_bgp_neighbors,
7815 show_ip_bgp_vpnv4_rd_neighbors_cmd,
7816 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors",
7817 SHOW_STR
7818 IP_STR
7819 BGP_STR
7820 "Display VPNv4 NLRI specific information\n"
7821 "Display information for a route distinguisher\n"
7822 "VPN Route Distinguisher\n"
7823 "Detailed information on TCP and BGP neighbor connections\n")
7824
7825ALIAS (show_ip_bgp_neighbors,
7826 show_bgp_neighbors_cmd,
7827 "show bgp neighbors",
7828 SHOW_STR
7829 BGP_STR
7830 "Detailed information on TCP and BGP neighbor connections\n")
7831
7832ALIAS (show_ip_bgp_neighbors,
7833 show_bgp_ipv6_neighbors_cmd,
7834 "show bgp ipv6 neighbors",
7835 SHOW_STR
7836 BGP_STR
7837 "Address family\n"
7838 "Detailed information on TCP and BGP neighbor connections\n")
7839
7840DEFUN (show_ip_bgp_neighbors_peer,
7841 show_ip_bgp_neighbors_peer_cmd,
7842 "show ip bgp neighbors (A.B.C.D|X:X::X:X)",
7843 SHOW_STR
7844 IP_STR
7845 BGP_STR
7846 "Detailed information on TCP and BGP neighbor connections\n"
7847 "Neighbor to display information about\n"
7848 "Neighbor to display information about\n")
7849{
7850 return bgp_show_neighbor_vty (vty, NULL, show_peer, argv[argc - 1]);
7851}
7852
7853ALIAS (show_ip_bgp_neighbors_peer,
7854 show_ip_bgp_ipv4_neighbors_peer_cmd,
7855 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X)",
7856 SHOW_STR
7857 IP_STR
7858 BGP_STR
7859 "Address family\n"
7860 "Address Family modifier\n"
7861 "Address Family modifier\n"
7862 "Detailed information on TCP and BGP neighbor connections\n"
7863 "Neighbor to display information about\n"
7864 "Neighbor to display information about\n")
7865
7866ALIAS (show_ip_bgp_neighbors_peer,
7867 show_ip_bgp_vpnv4_all_neighbors_peer_cmd,
7868 "show ip bgp vpnv4 all neighbors A.B.C.D",
7869 SHOW_STR
7870 IP_STR
7871 BGP_STR
7872 "Display VPNv4 NLRI specific information\n"
7873 "Display information about all VPNv4 NLRIs\n"
7874 "Detailed information on TCP and BGP neighbor connections\n"
7875 "Neighbor to display information about\n")
7876
7877ALIAS (show_ip_bgp_neighbors_peer,
7878 show_ip_bgp_vpnv4_rd_neighbors_peer_cmd,
7879 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D",
7880 SHOW_STR
7881 IP_STR
7882 BGP_STR
7883 "Display VPNv4 NLRI specific information\n"
7884 "Display information about all VPNv4 NLRIs\n"
7885 "Detailed information on TCP and BGP neighbor connections\n"
7886 "Neighbor to display information about\n")
7887
7888ALIAS (show_ip_bgp_neighbors_peer,
7889 show_bgp_neighbors_peer_cmd,
7890 "show bgp neighbors (A.B.C.D|X:X::X:X)",
7891 SHOW_STR
7892 BGP_STR
7893 "Detailed information on TCP and BGP neighbor connections\n"
7894 "Neighbor to display information about\n"
7895 "Neighbor to display information about\n")
7896
7897ALIAS (show_ip_bgp_neighbors_peer,
7898 show_bgp_ipv6_neighbors_peer_cmd,
7899 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X)",
7900 SHOW_STR
7901 BGP_STR
7902 "Address family\n"
7903 "Detailed information on TCP and BGP neighbor connections\n"
7904 "Neighbor to display information about\n"
7905 "Neighbor to display information about\n")
7906
7907DEFUN (show_ip_bgp_instance_neighbors,
7908 show_ip_bgp_instance_neighbors_cmd,
7909 "show ip bgp view WORD neighbors",
7910 SHOW_STR
7911 IP_STR
7912 BGP_STR
7913 "BGP view\n"
7914 "View name\n"
7915 "Detailed information on TCP and BGP neighbor connections\n")
7916{
7917 return bgp_show_neighbor_vty (vty, argv[0], show_all, NULL);
7918}
7919
paulbb46e942003-10-24 19:02:03 +00007920ALIAS (show_ip_bgp_instance_neighbors,
7921 show_bgp_instance_neighbors_cmd,
7922 "show bgp view WORD neighbors",
7923 SHOW_STR
7924 BGP_STR
7925 "BGP view\n"
7926 "View name\n"
7927 "Detailed information on TCP and BGP neighbor connections\n")
7928
7929ALIAS (show_ip_bgp_instance_neighbors,
7930 show_bgp_instance_ipv6_neighbors_cmd,
7931 "show bgp view WORD ipv6 neighbors",
7932 SHOW_STR
7933 BGP_STR
7934 "BGP view\n"
7935 "View name\n"
7936 "Address family\n"
7937 "Detailed information on TCP and BGP neighbor connections\n")
7938
paul718e3742002-12-13 20:15:29 +00007939DEFUN (show_ip_bgp_instance_neighbors_peer,
7940 show_ip_bgp_instance_neighbors_peer_cmd,
7941 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X)",
7942 SHOW_STR
7943 IP_STR
7944 BGP_STR
7945 "BGP view\n"
7946 "View name\n"
7947 "Detailed information on TCP and BGP neighbor connections\n"
7948 "Neighbor to display information about\n"
7949 "Neighbor to display information about\n")
7950{
7951 return bgp_show_neighbor_vty (vty, argv[0], show_peer, argv[1]);
7952}
paulbb46e942003-10-24 19:02:03 +00007953
7954ALIAS (show_ip_bgp_instance_neighbors_peer,
7955 show_bgp_instance_neighbors_peer_cmd,
7956 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X)",
7957 SHOW_STR
7958 BGP_STR
7959 "BGP view\n"
7960 "View name\n"
7961 "Detailed information on TCP and BGP neighbor connections\n"
7962 "Neighbor to display information about\n"
7963 "Neighbor to display information about\n")
7964
7965ALIAS (show_ip_bgp_instance_neighbors_peer,
7966 show_bgp_instance_ipv6_neighbors_peer_cmd,
7967 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X)",
7968 SHOW_STR
7969 BGP_STR
7970 "BGP view\n"
7971 "View name\n"
7972 "Address family\n"
7973 "Detailed information on TCP and BGP neighbor connections\n"
7974 "Neighbor to display information about\n"
7975 "Neighbor to display information about\n")
7976
paul718e3742002-12-13 20:15:29 +00007977/* Show BGP's AS paths internal data. There are both `show ip bgp
7978 paths' and `show ip mbgp paths'. Those functions results are the
7979 same.*/
7980DEFUN (show_ip_bgp_paths,
7981 show_ip_bgp_paths_cmd,
7982 "show ip bgp paths",
7983 SHOW_STR
7984 IP_STR
7985 BGP_STR
7986 "Path information\n")
7987{
7988 vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE);
7989 aspath_print_all_vty (vty);
7990 return CMD_SUCCESS;
7991}
7992
7993DEFUN (show_ip_bgp_ipv4_paths,
7994 show_ip_bgp_ipv4_paths_cmd,
7995 "show ip bgp ipv4 (unicast|multicast) paths",
7996 SHOW_STR
7997 IP_STR
7998 BGP_STR
7999 "Address family\n"
8000 "Address Family modifier\n"
8001 "Address Family modifier\n"
8002 "Path information\n")
8003{
8004 vty_out (vty, "Address Refcnt Path\r\n");
8005 aspath_print_all_vty (vty);
8006
8007 return CMD_SUCCESS;
8008}
8009
8010#include "hash.h"
8011
paul94f2b392005-06-28 12:44:16 +00008012static void
paul718e3742002-12-13 20:15:29 +00008013community_show_all_iterator (struct hash_backet *backet, struct vty *vty)
8014{
8015 struct community *com;
8016
8017 com = (struct community *) backet->data;
8018 vty_out (vty, "[%p] (%ld) %s%s", backet, com->refcnt,
8019 community_str (com), VTY_NEWLINE);
8020}
8021
8022/* Show BGP's community internal data. */
8023DEFUN (show_ip_bgp_community_info,
8024 show_ip_bgp_community_info_cmd,
8025 "show ip bgp community-info",
8026 SHOW_STR
8027 IP_STR
8028 BGP_STR
8029 "List all bgp community information\n")
8030{
8031 vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE);
8032
8033 hash_iterate (community_hash (),
8034 (void (*) (struct hash_backet *, void *))
8035 community_show_all_iterator,
8036 vty);
8037
8038 return CMD_SUCCESS;
8039}
8040
8041DEFUN (show_ip_bgp_attr_info,
8042 show_ip_bgp_attr_info_cmd,
8043 "show ip bgp attribute-info",
8044 SHOW_STR
8045 IP_STR
8046 BGP_STR
8047 "List all bgp attribute information\n")
8048{
8049 attr_show_all (vty);
8050 return CMD_SUCCESS;
8051}
8052
paul94f2b392005-06-28 12:44:16 +00008053static int
paulfee0f4c2004-09-13 05:12:46 +00008054bgp_write_rsclient_summary (struct vty *vty, struct peer *rsclient,
8055 afi_t afi, safi_t safi)
8056{
8057 char timebuf[BGP_UPTIME_LEN];
8058 char rmbuf[14];
paulfd79ac92004-10-13 05:06:08 +00008059 const char *rmname;
paulfee0f4c2004-09-13 05:12:46 +00008060 struct peer *peer;
paul1eb8ef22005-04-07 07:30:20 +00008061 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00008062 int len;
8063 int count = 0;
8064
8065 if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP))
8066 {
paul1eb8ef22005-04-07 07:30:20 +00008067 for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, peer))
paulfee0f4c2004-09-13 05:12:46 +00008068 {
8069 count++;
8070 bgp_write_rsclient_summary (vty, peer, afi, safi);
8071 }
8072 return count;
8073 }
8074
8075 len = vty_out (vty, "%s", rsclient->host);
8076 len = 16 - len;
8077
8078 if (len < 1)
8079 vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
8080 else
8081 vty_out (vty, "%*s", len, " ");
8082
hasso3d515fd2005-02-01 21:30:04 +00008083 vty_out (vty, "4 ");
paulfee0f4c2004-09-13 05:12:46 +00008084
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00008085 vty_out (vty, "%11d ", rsclient->as);
paulfee0f4c2004-09-13 05:12:46 +00008086
8087 rmname = ROUTE_MAP_EXPORT_NAME(&rsclient->filter[afi][safi]);
8088 if ( rmname && strlen (rmname) > 13 )
8089 {
8090 sprintf (rmbuf, "%13s", "...");
8091 rmname = strncpy (rmbuf, rmname, 10);
8092 }
8093 else if (! rmname)
8094 rmname = "<none>";
8095 vty_out (vty, " %13s ", rmname);
8096
8097 rmname = ROUTE_MAP_IMPORT_NAME(&rsclient->filter[afi][safi]);
8098 if ( rmname && strlen (rmname) > 13 )
8099 {
8100 sprintf (rmbuf, "%13s", "...");
8101 rmname = strncpy (rmbuf, rmname, 10);
8102 }
8103 else if (! rmname)
8104 rmname = "<none>";
8105 vty_out (vty, " %13s ", rmname);
8106
8107 vty_out (vty, "%8s", peer_uptime (rsclient->uptime, timebuf, BGP_UPTIME_LEN));
8108
8109 if (CHECK_FLAG (rsclient->flags, PEER_FLAG_SHUTDOWN))
8110 vty_out (vty, " Idle (Admin)");
8111 else if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_PREFIX_OVERFLOW))
8112 vty_out (vty, " Idle (PfxCt)");
8113 else
8114 vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, rsclient->status));
8115
8116 vty_out (vty, "%s", VTY_NEWLINE);
8117
8118 return 1;
8119}
8120
paul94f2b392005-06-28 12:44:16 +00008121static int
paulfd79ac92004-10-13 05:06:08 +00008122bgp_show_rsclient_summary (struct vty *vty, struct bgp *bgp,
8123 afi_t afi, safi_t safi)
paulfee0f4c2004-09-13 05:12:46 +00008124{
8125 struct peer *peer;
paul1eb8ef22005-04-07 07:30:20 +00008126 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00008127 int count = 0;
8128
8129 /* Header string for each address family. */
8130 static char header[] = "Neighbor V AS Export-Policy Import-Policy Up/Down State";
8131
paul1eb8ef22005-04-07 07:30:20 +00008132 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, peer))
paulfee0f4c2004-09-13 05:12:46 +00008133 {
8134 if (peer->afc[afi][safi] &&
8135 CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
8136 {
8137 if (! count)
8138 {
8139 vty_out (vty,
8140 "Route Server's BGP router identifier %s%s",
8141 inet_ntoa (bgp->router_id), VTY_NEWLINE);
8142 vty_out (vty,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04008143 "Route Server's local AS number %u%s", bgp->as,
paulfee0f4c2004-09-13 05:12:46 +00008144 VTY_NEWLINE);
8145
8146 vty_out (vty, "%s", VTY_NEWLINE);
8147 vty_out (vty, "%s%s", header, VTY_NEWLINE);
8148 }
8149
8150 count += bgp_write_rsclient_summary (vty, peer, afi, safi);
8151 }
8152 }
8153
8154 if (count)
8155 vty_out (vty, "%sTotal number of Route Server Clients %d%s", VTY_NEWLINE,
8156 count, VTY_NEWLINE);
8157 else
8158 vty_out (vty, "No %s Route Server Client is configured%s",
8159 afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
8160
8161 return CMD_SUCCESS;
8162}
8163
paul94f2b392005-06-28 12:44:16 +00008164static int
paulfd79ac92004-10-13 05:06:08 +00008165bgp_show_rsclient_summary_vty (struct vty *vty, const char *name,
8166 afi_t afi, safi_t safi)
paulfee0f4c2004-09-13 05:12:46 +00008167{
8168 struct bgp *bgp;
8169
8170 if (name)
8171 {
8172 bgp = bgp_lookup_by_name (name);
8173
8174 if (! bgp)
8175 {
8176 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
8177 return CMD_WARNING;
8178 }
8179
8180 bgp_show_rsclient_summary (vty, bgp, afi, safi);
8181 return CMD_SUCCESS;
8182 }
8183
8184 bgp = bgp_get_default ();
8185
8186 if (bgp)
8187 bgp_show_rsclient_summary (vty, bgp, afi, safi);
8188
8189 return CMD_SUCCESS;
8190}
8191
8192/* 'show bgp rsclient' commands. */
8193DEFUN (show_ip_bgp_rsclient_summary,
8194 show_ip_bgp_rsclient_summary_cmd,
8195 "show ip bgp rsclient summary",
8196 SHOW_STR
8197 IP_STR
8198 BGP_STR
8199 "Information about Route Server Clients\n"
8200 "Summary of all Route Server Clients\n")
8201{
8202 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
8203}
8204
8205DEFUN (show_ip_bgp_instance_rsclient_summary,
8206 show_ip_bgp_instance_rsclient_summary_cmd,
8207 "show ip bgp view WORD rsclient summary",
8208 SHOW_STR
8209 IP_STR
8210 BGP_STR
8211 "BGP view\n"
8212 "View name\n"
8213 "Information about Route Server Clients\n"
8214 "Summary of all Route Server Clients\n")
8215{
8216 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
8217}
8218
8219DEFUN (show_ip_bgp_ipv4_rsclient_summary,
8220 show_ip_bgp_ipv4_rsclient_summary_cmd,
8221 "show ip bgp ipv4 (unicast|multicast) rsclient summary",
8222 SHOW_STR
8223 IP_STR
8224 BGP_STR
8225 "Address family\n"
8226 "Address Family modifier\n"
8227 "Address Family modifier\n"
8228 "Information about Route Server Clients\n"
8229 "Summary of all Route Server Clients\n")
8230{
8231 if (strncmp (argv[0], "m", 1) == 0)
8232 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST);
8233
8234 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
8235}
8236
8237DEFUN (show_ip_bgp_instance_ipv4_rsclient_summary,
8238 show_ip_bgp_instance_ipv4_rsclient_summary_cmd,
8239 "show ip bgp view WORD ipv4 (unicast|multicast) rsclient summary",
8240 SHOW_STR
8241 IP_STR
8242 BGP_STR
8243 "BGP view\n"
8244 "View name\n"
8245 "Address family\n"
8246 "Address Family modifier\n"
8247 "Address Family modifier\n"
8248 "Information about Route Server Clients\n"
8249 "Summary of all Route Server Clients\n")
8250{
8251 if (strncmp (argv[1], "m", 1) == 0)
8252 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST);
8253
8254 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
8255}
8256
Michael Lambert95cbbd22010-07-23 14:43:04 -04008257DEFUN (show_bgp_instance_ipv4_safi_rsclient_summary,
8258 show_bgp_instance_ipv4_safi_rsclient_summary_cmd,
8259 "show bgp view WORD ipv4 (unicast|multicast) rsclient summary",
8260 SHOW_STR
8261 BGP_STR
8262 "BGP view\n"
8263 "View name\n"
8264 "Address family\n"
8265 "Address Family modifier\n"
8266 "Address Family modifier\n"
8267 "Information about Route Server Clients\n"
8268 "Summary of all Route Server Clients\n")
8269{
8270 safi_t safi;
8271
8272 if (argc == 2) {
8273 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
8274 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, safi);
8275 } else {
8276 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
8277 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, safi);
8278 }
8279}
8280
8281ALIAS (show_bgp_instance_ipv4_safi_rsclient_summary,
8282 show_bgp_ipv4_safi_rsclient_summary_cmd,
8283 "show bgp ipv4 (unicast|multicast) rsclient summary",
8284 SHOW_STR
8285 BGP_STR
8286 "Address family\n"
8287 "Address Family modifier\n"
8288 "Address Family modifier\n"
8289 "Information about Route Server Clients\n"
8290 "Summary of all Route Server Clients\n")
8291
paulfee0f4c2004-09-13 05:12:46 +00008292#ifdef HAVE_IPV6
8293DEFUN (show_bgp_rsclient_summary,
8294 show_bgp_rsclient_summary_cmd,
8295 "show bgp rsclient summary",
8296 SHOW_STR
8297 BGP_STR
8298 "Information about Route Server Clients\n"
8299 "Summary of all Route Server Clients\n")
8300{
8301 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
8302}
8303
8304DEFUN (show_bgp_instance_rsclient_summary,
8305 show_bgp_instance_rsclient_summary_cmd,
8306 "show bgp view WORD rsclient summary",
8307 SHOW_STR
8308 BGP_STR
8309 "BGP view\n"
8310 "View name\n"
8311 "Information about Route Server Clients\n"
8312 "Summary of all Route Server Clients\n")
8313{
8314 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
8315}
8316
8317ALIAS (show_bgp_rsclient_summary,
8318 show_bgp_ipv6_rsclient_summary_cmd,
8319 "show bgp ipv6 rsclient summary",
8320 SHOW_STR
8321 BGP_STR
8322 "Address family\n"
8323 "Information about Route Server Clients\n"
8324 "Summary of all Route Server Clients\n")
8325
8326ALIAS (show_bgp_instance_rsclient_summary,
8327 show_bgp_instance_ipv6_rsclient_summary_cmd,
8328 "show bgp view WORD ipv6 rsclient summary",
8329 SHOW_STR
8330 BGP_STR
8331 "BGP view\n"
8332 "View name\n"
8333 "Address family\n"
8334 "Information about Route Server Clients\n"
8335 "Summary of all Route Server Clients\n")
Michael Lambert95cbbd22010-07-23 14:43:04 -04008336
8337DEFUN (show_bgp_instance_ipv6_safi_rsclient_summary,
8338 show_bgp_instance_ipv6_safi_rsclient_summary_cmd,
8339 "show bgp view WORD ipv6 (unicast|multicast) rsclient summary",
8340 SHOW_STR
8341 BGP_STR
8342 "BGP view\n"
8343 "View name\n"
8344 "Address family\n"
8345 "Address Family modifier\n"
8346 "Address Family modifier\n"
8347 "Information about Route Server Clients\n"
8348 "Summary of all Route Server Clients\n")
8349{
8350 safi_t safi;
8351
8352 if (argc == 2) {
8353 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
8354 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP6, safi);
8355 } else {
8356 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
8357 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP6, safi);
8358 }
8359}
8360
8361ALIAS (show_bgp_instance_ipv6_safi_rsclient_summary,
8362 show_bgp_ipv6_safi_rsclient_summary_cmd,
8363 "show bgp ipv6 (unicast|multicast) rsclient summary",
8364 SHOW_STR
8365 BGP_STR
8366 "Address family\n"
8367 "Address Family modifier\n"
8368 "Address Family modifier\n"
8369 "Information about Route Server Clients\n"
8370 "Summary of all Route Server Clients\n")
8371
paulfee0f4c2004-09-13 05:12:46 +00008372#endif /* HAVE IPV6 */
8373
paul718e3742002-12-13 20:15:29 +00008374/* Redistribute VTY commands. */
8375
8376/* Utility function to convert user input route type string to route
8377 type. */
8378static int
paulfd79ac92004-10-13 05:06:08 +00008379bgp_str2route_type (int afi, const char *str)
paul718e3742002-12-13 20:15:29 +00008380{
8381 if (! str)
8382 return 0;
8383
8384 if (afi == AFI_IP)
8385 {
8386 if (strncmp (str, "k", 1) == 0)
8387 return ZEBRA_ROUTE_KERNEL;
8388 else if (strncmp (str, "c", 1) == 0)
8389 return ZEBRA_ROUTE_CONNECT;
8390 else if (strncmp (str, "s", 1) == 0)
8391 return ZEBRA_ROUTE_STATIC;
8392 else if (strncmp (str, "r", 1) == 0)
8393 return ZEBRA_ROUTE_RIP;
8394 else if (strncmp (str, "o", 1) == 0)
8395 return ZEBRA_ROUTE_OSPF;
8396 }
8397 if (afi == AFI_IP6)
8398 {
8399 if (strncmp (str, "k", 1) == 0)
8400 return ZEBRA_ROUTE_KERNEL;
8401 else if (strncmp (str, "c", 1) == 0)
8402 return ZEBRA_ROUTE_CONNECT;
8403 else if (strncmp (str, "s", 1) == 0)
8404 return ZEBRA_ROUTE_STATIC;
8405 else if (strncmp (str, "r", 1) == 0)
8406 return ZEBRA_ROUTE_RIPNG;
8407 else if (strncmp (str, "o", 1) == 0)
8408 return ZEBRA_ROUTE_OSPF6;
8409 }
8410 return 0;
8411}
8412
8413DEFUN (bgp_redistribute_ipv4,
8414 bgp_redistribute_ipv4_cmd,
8415 "redistribute (connected|kernel|ospf|rip|static)",
8416 "Redistribute information from another routing protocol\n"
8417 "Connected\n"
8418 "Kernel routes\n"
8419 "Open Shurtest Path First (OSPF)\n"
8420 "Routing Information Protocol (RIP)\n"
8421 "Static routes\n")
8422{
8423 int type;
8424
8425 type = bgp_str2route_type (AFI_IP, argv[0]);
8426 if (! type)
8427 {
8428 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8429 return CMD_WARNING;
8430 }
8431 return bgp_redistribute_set (vty->index, AFI_IP, type);
8432}
8433
8434DEFUN (bgp_redistribute_ipv4_rmap,
8435 bgp_redistribute_ipv4_rmap_cmd,
8436 "redistribute (connected|kernel|ospf|rip|static) route-map WORD",
8437 "Redistribute information from another routing protocol\n"
8438 "Connected\n"
8439 "Kernel routes\n"
8440 "Open Shurtest Path First (OSPF)\n"
8441 "Routing Information Protocol (RIP)\n"
8442 "Static routes\n"
8443 "Route map reference\n"
8444 "Pointer to route-map entries\n")
8445{
8446 int type;
8447
8448 type = bgp_str2route_type (AFI_IP, argv[0]);
8449 if (! type)
8450 {
8451 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8452 return CMD_WARNING;
8453 }
8454
8455 bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[1]);
8456 return bgp_redistribute_set (vty->index, AFI_IP, type);
8457}
8458
8459DEFUN (bgp_redistribute_ipv4_metric,
8460 bgp_redistribute_ipv4_metric_cmd,
8461 "redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295>",
8462 "Redistribute information from another routing protocol\n"
8463 "Connected\n"
8464 "Kernel routes\n"
8465 "Open Shurtest Path First (OSPF)\n"
8466 "Routing Information Protocol (RIP)\n"
8467 "Static routes\n"
8468 "Metric for redistributed routes\n"
8469 "Default metric\n")
8470{
8471 int type;
8472 u_int32_t metric;
8473
8474 type = bgp_str2route_type (AFI_IP, argv[0]);
8475 if (! type)
8476 {
8477 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8478 return CMD_WARNING;
8479 }
8480 VTY_GET_INTEGER ("metric", metric, argv[1]);
8481
8482 bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
8483 return bgp_redistribute_set (vty->index, AFI_IP, type);
8484}
8485
8486DEFUN (bgp_redistribute_ipv4_rmap_metric,
8487 bgp_redistribute_ipv4_rmap_metric_cmd,
8488 "redistribute (connected|kernel|ospf|rip|static) route-map WORD metric <0-4294967295>",
8489 "Redistribute information from another routing protocol\n"
8490 "Connected\n"
8491 "Kernel routes\n"
8492 "Open Shurtest Path First (OSPF)\n"
8493 "Routing Information Protocol (RIP)\n"
8494 "Static routes\n"
8495 "Route map reference\n"
8496 "Pointer to route-map entries\n"
8497 "Metric for redistributed routes\n"
8498 "Default metric\n")
8499{
8500 int type;
8501 u_int32_t metric;
8502
8503 type = bgp_str2route_type (AFI_IP, argv[0]);
8504 if (! type)
8505 {
8506 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8507 return CMD_WARNING;
8508 }
8509 VTY_GET_INTEGER ("metric", metric, argv[2]);
8510
8511 bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[1]);
8512 bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
8513 return bgp_redistribute_set (vty->index, AFI_IP, type);
8514}
8515
8516DEFUN (bgp_redistribute_ipv4_metric_rmap,
8517 bgp_redistribute_ipv4_metric_rmap_cmd,
8518 "redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295> route-map WORD",
8519 "Redistribute information from another routing protocol\n"
8520 "Connected\n"
8521 "Kernel routes\n"
8522 "Open Shurtest Path First (OSPF)\n"
8523 "Routing Information Protocol (RIP)\n"
8524 "Static routes\n"
8525 "Metric for redistributed routes\n"
8526 "Default metric\n"
8527 "Route map reference\n"
8528 "Pointer to route-map entries\n")
8529{
8530 int type;
8531 u_int32_t metric;
8532
8533 type = bgp_str2route_type (AFI_IP, argv[0]);
8534 if (! type)
8535 {
8536 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8537 return CMD_WARNING;
8538 }
8539 VTY_GET_INTEGER ("metric", metric, argv[1]);
8540
8541 bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
8542 bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[2]);
8543 return bgp_redistribute_set (vty->index, AFI_IP, type);
8544}
8545
8546DEFUN (no_bgp_redistribute_ipv4,
8547 no_bgp_redistribute_ipv4_cmd,
8548 "no redistribute (connected|kernel|ospf|rip|static)",
8549 NO_STR
8550 "Redistribute information from another routing protocol\n"
8551 "Connected\n"
8552 "Kernel routes\n"
8553 "Open Shurtest Path First (OSPF)\n"
8554 "Routing Information Protocol (RIP)\n"
8555 "Static routes\n")
8556{
8557 int type;
8558
8559 type = bgp_str2route_type (AFI_IP, argv[0]);
8560 if (! type)
8561 {
8562 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8563 return CMD_WARNING;
8564 }
8565
8566 return bgp_redistribute_unset (vty->index, AFI_IP, type);
8567}
8568
8569DEFUN (no_bgp_redistribute_ipv4_rmap,
8570 no_bgp_redistribute_ipv4_rmap_cmd,
8571 "no redistribute (connected|kernel|ospf|rip|static) route-map WORD",
8572 NO_STR
8573 "Redistribute information from another routing protocol\n"
8574 "Connected\n"
8575 "Kernel routes\n"
8576 "Open Shurtest Path First (OSPF)\n"
8577 "Routing Information Protocol (RIP)\n"
8578 "Static routes\n"
8579 "Route map reference\n"
8580 "Pointer to route-map entries\n")
8581{
8582 int type;
8583
8584 type = bgp_str2route_type (AFI_IP, argv[0]);
8585 if (! type)
8586 {
8587 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8588 return CMD_WARNING;
8589 }
8590
8591 bgp_redistribute_routemap_unset (vty->index, AFI_IP, type);
8592 return CMD_SUCCESS;
8593}
8594
8595DEFUN (no_bgp_redistribute_ipv4_metric,
8596 no_bgp_redistribute_ipv4_metric_cmd,
8597 "no redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295>",
8598 NO_STR
8599 "Redistribute information from another routing protocol\n"
8600 "Connected\n"
8601 "Kernel routes\n"
8602 "Open Shurtest Path First (OSPF)\n"
8603 "Routing Information Protocol (RIP)\n"
8604 "Static routes\n"
8605 "Metric for redistributed routes\n"
8606 "Default metric\n")
8607{
8608 int type;
8609
8610 type = bgp_str2route_type (AFI_IP, argv[0]);
8611 if (! type)
8612 {
8613 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8614 return CMD_WARNING;
8615 }
8616
8617 bgp_redistribute_metric_unset (vty->index, AFI_IP, type);
8618 return CMD_SUCCESS;
8619}
8620
8621DEFUN (no_bgp_redistribute_ipv4_rmap_metric,
8622 no_bgp_redistribute_ipv4_rmap_metric_cmd,
8623 "no redistribute (connected|kernel|ospf|rip|static) route-map WORD metric <0-4294967295>",
8624 NO_STR
8625 "Redistribute information from another routing protocol\n"
8626 "Connected\n"
8627 "Kernel routes\n"
8628 "Open Shurtest Path First (OSPF)\n"
8629 "Routing Information Protocol (RIP)\n"
8630 "Static routes\n"
8631 "Route map reference\n"
8632 "Pointer to route-map entries\n"
8633 "Metric for redistributed routes\n"
8634 "Default metric\n")
8635{
8636 int type;
8637
8638 type = bgp_str2route_type (AFI_IP, argv[0]);
8639 if (! type)
8640 {
8641 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8642 return CMD_WARNING;
8643 }
8644
8645 bgp_redistribute_metric_unset (vty->index, AFI_IP, type);
8646 bgp_redistribute_routemap_unset (vty->index, AFI_IP, type);
8647 return CMD_SUCCESS;
8648}
8649
8650ALIAS (no_bgp_redistribute_ipv4_rmap_metric,
8651 no_bgp_redistribute_ipv4_metric_rmap_cmd,
8652 "no redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295> route-map WORD",
8653 NO_STR
8654 "Redistribute information from another routing protocol\n"
8655 "Connected\n"
8656 "Kernel routes\n"
8657 "Open Shurtest Path First (OSPF)\n"
8658 "Routing Information Protocol (RIP)\n"
8659 "Static routes\n"
8660 "Metric for redistributed routes\n"
8661 "Default metric\n"
8662 "Route map reference\n"
8663 "Pointer to route-map entries\n")
8664
8665#ifdef HAVE_IPV6
8666DEFUN (bgp_redistribute_ipv6,
8667 bgp_redistribute_ipv6_cmd,
8668 "redistribute (connected|kernel|ospf6|ripng|static)",
8669 "Redistribute information from another routing protocol\n"
8670 "Connected\n"
8671 "Kernel routes\n"
8672 "Open Shurtest Path First (OSPFv3)\n"
8673 "Routing Information Protocol (RIPng)\n"
8674 "Static routes\n")
8675{
8676 int type;
8677
8678 type = bgp_str2route_type (AFI_IP6, argv[0]);
8679 if (! type)
8680 {
8681 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8682 return CMD_WARNING;
8683 }
8684
8685 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8686}
8687
8688DEFUN (bgp_redistribute_ipv6_rmap,
8689 bgp_redistribute_ipv6_rmap_cmd,
8690 "redistribute (connected|kernel|ospf6|ripng|static) route-map WORD",
8691 "Redistribute information from another routing protocol\n"
8692 "Connected\n"
8693 "Kernel routes\n"
8694 "Open Shurtest Path First (OSPFv3)\n"
8695 "Routing Information Protocol (RIPng)\n"
8696 "Static routes\n"
8697 "Route map reference\n"
8698 "Pointer to route-map entries\n")
8699{
8700 int type;
8701
8702 type = bgp_str2route_type (AFI_IP6, argv[0]);
8703 if (! type)
8704 {
8705 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8706 return CMD_WARNING;
8707 }
8708
8709 bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[1]);
8710 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8711}
8712
8713DEFUN (bgp_redistribute_ipv6_metric,
8714 bgp_redistribute_ipv6_metric_cmd,
8715 "redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295>",
8716 "Redistribute information from another routing protocol\n"
8717 "Connected\n"
8718 "Kernel routes\n"
8719 "Open Shurtest Path First (OSPFv3)\n"
8720 "Routing Information Protocol (RIPng)\n"
8721 "Static routes\n"
8722 "Metric for redistributed routes\n"
8723 "Default metric\n")
8724{
8725 int type;
8726 u_int32_t metric;
8727
8728 type = bgp_str2route_type (AFI_IP6, argv[0]);
8729 if (! type)
8730 {
8731 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8732 return CMD_WARNING;
8733 }
8734 VTY_GET_INTEGER ("metric", metric, argv[1]);
8735
8736 bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
8737 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8738}
8739
8740DEFUN (bgp_redistribute_ipv6_rmap_metric,
8741 bgp_redistribute_ipv6_rmap_metric_cmd,
8742 "redistribute (connected|kernel|ospf6|ripng|static) route-map WORD metric <0-4294967295>",
8743 "Redistribute information from another routing protocol\n"
8744 "Connected\n"
8745 "Kernel routes\n"
8746 "Open Shurtest Path First (OSPFv3)\n"
8747 "Routing Information Protocol (RIPng)\n"
8748 "Static routes\n"
8749 "Route map reference\n"
8750 "Pointer to route-map entries\n"
8751 "Metric for redistributed routes\n"
8752 "Default metric\n")
8753{
8754 int type;
8755 u_int32_t metric;
8756
8757 type = bgp_str2route_type (AFI_IP6, argv[0]);
8758 if (! type)
8759 {
8760 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8761 return CMD_WARNING;
8762 }
8763 VTY_GET_INTEGER ("metric", metric, argv[2]);
8764
8765 bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[1]);
8766 bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
8767 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8768}
8769
8770DEFUN (bgp_redistribute_ipv6_metric_rmap,
8771 bgp_redistribute_ipv6_metric_rmap_cmd,
8772 "redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295> route-map WORD",
8773 "Redistribute information from another routing protocol\n"
8774 "Connected\n"
8775 "Kernel routes\n"
8776 "Open Shurtest Path First (OSPFv3)\n"
8777 "Routing Information Protocol (RIPng)\n"
8778 "Static routes\n"
8779 "Metric for redistributed routes\n"
8780 "Default metric\n"
8781 "Route map reference\n"
8782 "Pointer to route-map entries\n")
8783{
8784 int type;
8785 u_int32_t metric;
8786
8787 type = bgp_str2route_type (AFI_IP6, argv[0]);
8788 if (! type)
8789 {
8790 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8791 return CMD_WARNING;
8792 }
8793 VTY_GET_INTEGER ("metric", metric, argv[1]);
8794
8795 bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
8796 bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[2]);
8797 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8798}
8799
8800DEFUN (no_bgp_redistribute_ipv6,
8801 no_bgp_redistribute_ipv6_cmd,
8802 "no redistribute (connected|kernel|ospf6|ripng|static)",
8803 NO_STR
8804 "Redistribute information from another routing protocol\n"
8805 "Connected\n"
8806 "Kernel routes\n"
8807 "Open Shurtest Path First (OSPFv3)\n"
8808 "Routing Information Protocol (RIPng)\n"
8809 "Static routes\n")
8810{
8811 int type;
8812
8813 type = bgp_str2route_type (AFI_IP6, argv[0]);
8814 if (! type)
8815 {
8816 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8817 return CMD_WARNING;
8818 }
8819
8820 return bgp_redistribute_unset (vty->index, AFI_IP6, type);
8821}
8822
8823DEFUN (no_bgp_redistribute_ipv6_rmap,
8824 no_bgp_redistribute_ipv6_rmap_cmd,
8825 "no redistribute (connected|kernel|ospf6|ripng|static) route-map WORD",
8826 NO_STR
8827 "Redistribute information from another routing protocol\n"
8828 "Connected\n"
8829 "Kernel routes\n"
8830 "Open Shurtest Path First (OSPFv3)\n"
8831 "Routing Information Protocol (RIPng)\n"
8832 "Static routes\n"
8833 "Route map reference\n"
8834 "Pointer to route-map entries\n")
8835{
8836 int type;
8837
8838 type = bgp_str2route_type (AFI_IP6, argv[0]);
8839 if (! type)
8840 {
8841 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8842 return CMD_WARNING;
8843 }
8844
8845 bgp_redistribute_routemap_unset (vty->index, AFI_IP6, type);
8846 return CMD_SUCCESS;
8847}
8848
8849DEFUN (no_bgp_redistribute_ipv6_metric,
8850 no_bgp_redistribute_ipv6_metric_cmd,
8851 "no redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295>",
8852 NO_STR
8853 "Redistribute information from another routing protocol\n"
8854 "Connected\n"
8855 "Kernel routes\n"
8856 "Open Shurtest Path First (OSPFv3)\n"
8857 "Routing Information Protocol (RIPng)\n"
8858 "Static routes\n"
8859 "Metric for redistributed routes\n"
8860 "Default metric\n")
8861{
8862 int type;
8863
8864 type = bgp_str2route_type (AFI_IP6, argv[0]);
8865 if (! type)
8866 {
8867 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8868 return CMD_WARNING;
8869 }
8870
8871 bgp_redistribute_metric_unset (vty->index, AFI_IP6, type);
8872 return CMD_SUCCESS;
8873}
8874
8875DEFUN (no_bgp_redistribute_ipv6_rmap_metric,
8876 no_bgp_redistribute_ipv6_rmap_metric_cmd,
8877 "no redistribute (connected|kernel|ospf6|ripng|static) route-map WORD metric <0-4294967295>",
8878 NO_STR
8879 "Redistribute information from another routing protocol\n"
8880 "Connected\n"
8881 "Kernel routes\n"
8882 "Open Shurtest Path First (OSPFv3)\n"
8883 "Routing Information Protocol (RIPng)\n"
8884 "Static routes\n"
8885 "Route map reference\n"
8886 "Pointer to route-map entries\n"
8887 "Metric for redistributed routes\n"
8888 "Default metric\n")
8889{
8890 int type;
8891
8892 type = bgp_str2route_type (AFI_IP6, argv[0]);
8893 if (! type)
8894 {
8895 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8896 return CMD_WARNING;
8897 }
8898
8899 bgp_redistribute_metric_unset (vty->index, AFI_IP6, type);
8900 bgp_redistribute_routemap_unset (vty->index, AFI_IP6, type);
8901 return CMD_SUCCESS;
8902}
8903
8904ALIAS (no_bgp_redistribute_ipv6_rmap_metric,
8905 no_bgp_redistribute_ipv6_metric_rmap_cmd,
8906 "no redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295> route-map WORD",
8907 NO_STR
8908 "Redistribute information from another routing protocol\n"
8909 "Connected\n"
8910 "Kernel routes\n"
8911 "Open Shurtest Path First (OSPFv3)\n"
8912 "Routing Information Protocol (RIPng)\n"
8913 "Static routes\n"
8914 "Metric for redistributed routes\n"
8915 "Default metric\n"
8916 "Route map reference\n"
8917 "Pointer to route-map entries\n")
8918#endif /* HAVE_IPV6 */
8919
8920int
8921bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi,
8922 safi_t safi, int *write)
8923{
8924 int i;
paul718e3742002-12-13 20:15:29 +00008925
8926 /* Unicast redistribution only. */
8927 if (safi != SAFI_UNICAST)
8928 return 0;
8929
8930 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
8931 {
8932 /* Redistribute BGP does not make sense. */
8933 if (bgp->redist[afi][i] && i != ZEBRA_ROUTE_BGP)
8934 {
8935 /* Display "address-family" when it is not yet diplayed. */
8936 bgp_config_write_family_header (vty, afi, safi, write);
8937
8938 /* "redistribute" configuration. */
ajsf52d13c2005-10-01 17:38:06 +00008939 vty_out (vty, " redistribute %s", zebra_route_string(i));
paul718e3742002-12-13 20:15:29 +00008940
8941 if (bgp->redist_metric_flag[afi][i])
8942 vty_out (vty, " metric %d", bgp->redist_metric[afi][i]);
8943
8944 if (bgp->rmap[afi][i].name)
8945 vty_out (vty, " route-map %s", bgp->rmap[afi][i].name);
8946
8947 vty_out (vty, "%s", VTY_NEWLINE);
8948 }
8949 }
8950 return *write;
8951}
8952
8953/* BGP node structure. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008954static struct cmd_node bgp_node =
paul718e3742002-12-13 20:15:29 +00008955{
8956 BGP_NODE,
8957 "%s(config-router)# ",
8958 1,
8959};
8960
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008961static struct cmd_node bgp_ipv4_unicast_node =
paul718e3742002-12-13 20:15:29 +00008962{
8963 BGP_IPV4_NODE,
8964 "%s(config-router-af)# ",
8965 1,
8966};
8967
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008968static struct cmd_node bgp_ipv4_multicast_node =
paul718e3742002-12-13 20:15:29 +00008969{
8970 BGP_IPV4M_NODE,
8971 "%s(config-router-af)# ",
8972 1,
8973};
8974
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008975static struct cmd_node bgp_ipv6_unicast_node =
paul718e3742002-12-13 20:15:29 +00008976{
8977 BGP_IPV6_NODE,
8978 "%s(config-router-af)# ",
8979 1,
8980};
8981
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008982static struct cmd_node bgp_ipv6_multicast_node =
paul25ffbdc2005-08-22 22:42:08 +00008983{
8984 BGP_IPV6M_NODE,
8985 "%s(config-router-af)# ",
8986 1,
8987};
8988
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008989static struct cmd_node bgp_vpnv4_node =
paul718e3742002-12-13 20:15:29 +00008990{
8991 BGP_VPNV4_NODE,
8992 "%s(config-router-af)# ",
8993 1
8994};
8995
paul1f8ae702005-09-09 23:49:49 +00008996static void community_list_vty (void);
8997
paul718e3742002-12-13 20:15:29 +00008998void
paul94f2b392005-06-28 12:44:16 +00008999bgp_vty_init (void)
paul718e3742002-12-13 20:15:29 +00009000{
paul718e3742002-12-13 20:15:29 +00009001 /* Install bgp top node. */
9002 install_node (&bgp_node, bgp_config_write);
9003 install_node (&bgp_ipv4_unicast_node, NULL);
9004 install_node (&bgp_ipv4_multicast_node, NULL);
9005 install_node (&bgp_ipv6_unicast_node, NULL);
paul25ffbdc2005-08-22 22:42:08 +00009006 install_node (&bgp_ipv6_multicast_node, NULL);
paul718e3742002-12-13 20:15:29 +00009007 install_node (&bgp_vpnv4_node, NULL);
9008
9009 /* Install default VTY commands to new nodes. */
9010 install_default (BGP_NODE);
9011 install_default (BGP_IPV4_NODE);
9012 install_default (BGP_IPV4M_NODE);
9013 install_default (BGP_IPV6_NODE);
paul25ffbdc2005-08-22 22:42:08 +00009014 install_default (BGP_IPV6M_NODE);
paul718e3742002-12-13 20:15:29 +00009015 install_default (BGP_VPNV4_NODE);
9016
9017 /* "bgp multiple-instance" commands. */
9018 install_element (CONFIG_NODE, &bgp_multiple_instance_cmd);
9019 install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd);
9020
9021 /* "bgp config-type" commands. */
9022 install_element (CONFIG_NODE, &bgp_config_type_cmd);
9023 install_element (CONFIG_NODE, &no_bgp_config_type_cmd);
9024
9025 /* Dummy commands (Currently not supported) */
9026 install_element (BGP_NODE, &no_synchronization_cmd);
9027 install_element (BGP_NODE, &no_auto_summary_cmd);
9028
9029 /* "router bgp" commands. */
9030 install_element (CONFIG_NODE, &router_bgp_cmd);
9031 install_element (CONFIG_NODE, &router_bgp_view_cmd);
9032
9033 /* "no router bgp" commands. */
9034 install_element (CONFIG_NODE, &no_router_bgp_cmd);
9035 install_element (CONFIG_NODE, &no_router_bgp_view_cmd);
9036
9037 /* "bgp router-id" commands. */
9038 install_element (BGP_NODE, &bgp_router_id_cmd);
9039 install_element (BGP_NODE, &no_bgp_router_id_cmd);
9040 install_element (BGP_NODE, &no_bgp_router_id_val_cmd);
9041
9042 /* "bgp cluster-id" commands. */
9043 install_element (BGP_NODE, &bgp_cluster_id_cmd);
9044 install_element (BGP_NODE, &bgp_cluster_id32_cmd);
9045 install_element (BGP_NODE, &no_bgp_cluster_id_cmd);
9046 install_element (BGP_NODE, &no_bgp_cluster_id_arg_cmd);
9047
9048 /* "bgp confederation" commands. */
9049 install_element (BGP_NODE, &bgp_confederation_identifier_cmd);
9050 install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd);
9051 install_element (BGP_NODE, &no_bgp_confederation_identifier_arg_cmd);
9052
9053 /* "bgp confederation peers" commands. */
9054 install_element (BGP_NODE, &bgp_confederation_peers_cmd);
9055 install_element (BGP_NODE, &no_bgp_confederation_peers_cmd);
9056
9057 /* "timers bgp" commands. */
9058 install_element (BGP_NODE, &bgp_timers_cmd);
9059 install_element (BGP_NODE, &no_bgp_timers_cmd);
9060 install_element (BGP_NODE, &no_bgp_timers_arg_cmd);
9061
9062 /* "bgp client-to-client reflection" commands */
9063 install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd);
9064 install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd);
9065
9066 /* "bgp always-compare-med" commands */
9067 install_element (BGP_NODE, &bgp_always_compare_med_cmd);
9068 install_element (BGP_NODE, &no_bgp_always_compare_med_cmd);
9069
9070 /* "bgp deterministic-med" commands */
9071 install_element (BGP_NODE, &bgp_deterministic_med_cmd);
9072 install_element (BGP_NODE, &no_bgp_deterministic_med_cmd);
hasso538621f2004-05-21 09:31:30 +00009073
hasso538621f2004-05-21 09:31:30 +00009074 /* "bgp graceful-restart" commands */
9075 install_element (BGP_NODE, &bgp_graceful_restart_cmd);
9076 install_element (BGP_NODE, &no_bgp_graceful_restart_cmd);
hasso93406d82005-02-02 14:40:33 +00009077 install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd);
9078 install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd);
9079 install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_val_cmd);
paul718e3742002-12-13 20:15:29 +00009080
9081 /* "bgp fast-external-failover" commands */
9082 install_element (BGP_NODE, &bgp_fast_external_failover_cmd);
9083 install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd);
9084
9085 /* "bgp enforce-first-as" commands */
9086 install_element (BGP_NODE, &bgp_enforce_first_as_cmd);
9087 install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd);
9088
9089 /* "bgp bestpath compare-routerid" commands */
9090 install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd);
9091 install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd);
9092
9093 /* "bgp bestpath as-path ignore" commands */
9094 install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd);
9095 install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd);
9096
hasso68118452005-04-08 15:40:36 +00009097 /* "bgp bestpath as-path confed" commands */
9098 install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd);
9099 install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd);
9100
paul848973c2003-08-13 00:32:49 +00009101 /* "bgp log-neighbor-changes" commands */
9102 install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd);
9103 install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd);
9104
paul718e3742002-12-13 20:15:29 +00009105 /* "bgp bestpath med" commands */
9106 install_element (BGP_NODE, &bgp_bestpath_med_cmd);
9107 install_element (BGP_NODE, &bgp_bestpath_med2_cmd);
9108 install_element (BGP_NODE, &bgp_bestpath_med3_cmd);
9109 install_element (BGP_NODE, &no_bgp_bestpath_med_cmd);
9110 install_element (BGP_NODE, &no_bgp_bestpath_med2_cmd);
9111 install_element (BGP_NODE, &no_bgp_bestpath_med3_cmd);
9112
9113 /* "no bgp default ipv4-unicast" commands. */
9114 install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd);
9115 install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd);
9116
9117 /* "bgp network import-check" commands. */
9118 install_element (BGP_NODE, &bgp_network_import_check_cmd);
9119 install_element (BGP_NODE, &no_bgp_network_import_check_cmd);
9120
9121 /* "bgp default local-preference" commands. */
9122 install_element (BGP_NODE, &bgp_default_local_preference_cmd);
9123 install_element (BGP_NODE, &no_bgp_default_local_preference_cmd);
9124 install_element (BGP_NODE, &no_bgp_default_local_preference_val_cmd);
9125
9126 /* "neighbor remote-as" commands. */
9127 install_element (BGP_NODE, &neighbor_remote_as_cmd);
9128 install_element (BGP_NODE, &no_neighbor_cmd);
9129 install_element (BGP_NODE, &no_neighbor_remote_as_cmd);
9130
9131 /* "neighbor peer-group" commands. */
9132 install_element (BGP_NODE, &neighbor_peer_group_cmd);
9133 install_element (BGP_NODE, &no_neighbor_peer_group_cmd);
9134 install_element (BGP_NODE, &no_neighbor_peer_group_remote_as_cmd);
9135
9136 /* "neighbor local-as" commands. */
9137 install_element (BGP_NODE, &neighbor_local_as_cmd);
9138 install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd);
9139 install_element (BGP_NODE, &no_neighbor_local_as_cmd);
9140 install_element (BGP_NODE, &no_neighbor_local_as_val_cmd);
9141 install_element (BGP_NODE, &no_neighbor_local_as_val2_cmd);
9142
Paul Jakma0df7c912008-07-21 21:02:49 +00009143 /* "neighbor password" commands. */
9144 install_element (BGP_NODE, &neighbor_password_cmd);
9145 install_element (BGP_NODE, &no_neighbor_password_cmd);
9146
paul718e3742002-12-13 20:15:29 +00009147 /* "neighbor activate" commands. */
9148 install_element (BGP_NODE, &neighbor_activate_cmd);
9149 install_element (BGP_IPV4_NODE, &neighbor_activate_cmd);
9150 install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd);
9151 install_element (BGP_IPV6_NODE, &neighbor_activate_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009152 install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd);
paul718e3742002-12-13 20:15:29 +00009153 install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd);
9154
9155 /* "no neighbor activate" commands. */
9156 install_element (BGP_NODE, &no_neighbor_activate_cmd);
9157 install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd);
9158 install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd);
9159 install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009160 install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd);
paul718e3742002-12-13 20:15:29 +00009161 install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd);
9162
9163 /* "neighbor peer-group set" commands. */
9164 install_element (BGP_NODE, &neighbor_set_peer_group_cmd);
9165 install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_cmd);
9166 install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_cmd);
9167 install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009168 install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_cmd);
paula58545b2003-07-12 21:43:01 +00009169 install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_cmd);
9170
paul718e3742002-12-13 20:15:29 +00009171 /* "no neighbor peer-group unset" commands. */
9172 install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd);
9173 install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd);
9174 install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_cmd);
9175 install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009176 install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_cmd);
paula58545b2003-07-12 21:43:01 +00009177 install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_cmd);
9178
paul718e3742002-12-13 20:15:29 +00009179 /* "neighbor softreconfiguration inbound" commands.*/
9180 install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd);
9181 install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd);
9182 install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd);
9183 install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
9184 install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd);
9185 install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd);
9186 install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd);
9187 install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009188 install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd);
9189 install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd);
paula58545b2003-07-12 21:43:01 +00009190 install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd);
9191 install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
paul718e3742002-12-13 20:15:29 +00009192
9193 /* "neighbor attribute-unchanged" commands. */
9194 install_element (BGP_NODE, &neighbor_attr_unchanged_cmd);
9195 install_element (BGP_NODE, &neighbor_attr_unchanged1_cmd);
9196 install_element (BGP_NODE, &neighbor_attr_unchanged2_cmd);
9197 install_element (BGP_NODE, &neighbor_attr_unchanged3_cmd);
9198 install_element (BGP_NODE, &neighbor_attr_unchanged4_cmd);
9199 install_element (BGP_NODE, &neighbor_attr_unchanged5_cmd);
9200 install_element (BGP_NODE, &neighbor_attr_unchanged6_cmd);
9201 install_element (BGP_NODE, &neighbor_attr_unchanged7_cmd);
9202 install_element (BGP_NODE, &neighbor_attr_unchanged8_cmd);
9203 install_element (BGP_NODE, &neighbor_attr_unchanged9_cmd);
9204 install_element (BGP_NODE, &neighbor_attr_unchanged10_cmd);
9205 install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd);
9206 install_element (BGP_NODE, &no_neighbor_attr_unchanged1_cmd);
9207 install_element (BGP_NODE, &no_neighbor_attr_unchanged2_cmd);
9208 install_element (BGP_NODE, &no_neighbor_attr_unchanged3_cmd);
9209 install_element (BGP_NODE, &no_neighbor_attr_unchanged4_cmd);
9210 install_element (BGP_NODE, &no_neighbor_attr_unchanged5_cmd);
9211 install_element (BGP_NODE, &no_neighbor_attr_unchanged6_cmd);
9212 install_element (BGP_NODE, &no_neighbor_attr_unchanged7_cmd);
9213 install_element (BGP_NODE, &no_neighbor_attr_unchanged8_cmd);
9214 install_element (BGP_NODE, &no_neighbor_attr_unchanged9_cmd);
9215 install_element (BGP_NODE, &no_neighbor_attr_unchanged10_cmd);
9216 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd);
9217 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged1_cmd);
9218 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged2_cmd);
9219 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged3_cmd);
9220 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged4_cmd);
9221 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged5_cmd);
9222 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged6_cmd);
9223 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged7_cmd);
9224 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged8_cmd);
9225 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged9_cmd);
9226 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged10_cmd);
9227 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd);
9228 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged1_cmd);
9229 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged2_cmd);
9230 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged3_cmd);
9231 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged4_cmd);
9232 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged5_cmd);
9233 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged6_cmd);
9234 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged7_cmd);
9235 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged8_cmd);
9236 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged9_cmd);
9237 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged10_cmd);
9238 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd);
9239 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged1_cmd);
9240 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged2_cmd);
9241 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged3_cmd);
9242 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged4_cmd);
9243 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged5_cmd);
9244 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged6_cmd);
9245 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged7_cmd);
9246 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged8_cmd);
9247 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged9_cmd);
9248 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged10_cmd);
9249 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd);
9250 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged1_cmd);
9251 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged2_cmd);
9252 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged3_cmd);
9253 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged4_cmd);
9254 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged5_cmd);
9255 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged6_cmd);
9256 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged7_cmd);
9257 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged8_cmd);
9258 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged9_cmd);
9259 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged10_cmd);
9260 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd);
9261 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged1_cmd);
9262 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged2_cmd);
9263 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged3_cmd);
9264 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged4_cmd);
9265 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged5_cmd);
9266 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged6_cmd);
9267 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged7_cmd);
9268 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged8_cmd);
9269 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged9_cmd);
9270 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged10_cmd);
9271 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd);
9272 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged1_cmd);
9273 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged2_cmd);
9274 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged3_cmd);
9275 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged4_cmd);
9276 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged5_cmd);
9277 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged6_cmd);
9278 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged7_cmd);
9279 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged8_cmd);
9280 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged9_cmd);
9281 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged10_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009282 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd);
9283 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged1_cmd);
9284 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged2_cmd);
9285 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged3_cmd);
9286 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged4_cmd);
9287 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged5_cmd);
9288 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged6_cmd);
9289 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged7_cmd);
9290 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged8_cmd);
9291 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged9_cmd);
9292 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged10_cmd);
9293 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd);
9294 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged1_cmd);
9295 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged2_cmd);
9296 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged3_cmd);
9297 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged4_cmd);
9298 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged5_cmd);
9299 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged6_cmd);
9300 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged7_cmd);
9301 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged8_cmd);
9302 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged9_cmd);
9303 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged10_cmd);
paul718e3742002-12-13 20:15:29 +00009304 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd);
9305 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged1_cmd);
9306 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged2_cmd);
9307 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged3_cmd);
9308 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged4_cmd);
9309 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged5_cmd);
9310 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged6_cmd);
9311 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged7_cmd);
9312 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged8_cmd);
9313 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged9_cmd);
9314 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged10_cmd);
9315 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd);
9316 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged1_cmd);
9317 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged2_cmd);
9318 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged3_cmd);
9319 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged4_cmd);
9320 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged5_cmd);
9321 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged6_cmd);
9322 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged7_cmd);
9323 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged8_cmd);
9324 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged9_cmd);
9325 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged10_cmd);
9326
paulfee0f4c2004-09-13 05:12:46 +00009327 /* "nexthop-local unchanged" commands */
9328 install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd);
9329 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd);
9330
paul718e3742002-12-13 20:15:29 +00009331 /* "transparent-as" and "transparent-nexthop" for old version
9332 compatibility. */
9333 install_element (BGP_NODE, &neighbor_transparent_as_cmd);
9334 install_element (BGP_NODE, &neighbor_transparent_nexthop_cmd);
9335
9336 /* "neighbor next-hop-self" commands. */
9337 install_element (BGP_NODE, &neighbor_nexthop_self_cmd);
9338 install_element (BGP_NODE, &no_neighbor_nexthop_self_cmd);
9339 install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd);
9340 install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd);
9341 install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd);
9342 install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd);
9343 install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd);
9344 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009345 install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd);
9346 install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd);
paul718e3742002-12-13 20:15:29 +00009347 install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd);
9348 install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd);
9349
9350 /* "neighbor remove-private-AS" commands. */
9351 install_element (BGP_NODE, &neighbor_remove_private_as_cmd);
9352 install_element (BGP_NODE, &no_neighbor_remove_private_as_cmd);
9353 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd);
9354 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd);
9355 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd);
9356 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd);
9357 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd);
9358 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009359 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd);
9360 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd);
paul718e3742002-12-13 20:15:29 +00009361 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd);
9362 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd);
9363
9364 /* "neighbor send-community" commands.*/
9365 install_element (BGP_NODE, &neighbor_send_community_cmd);
9366 install_element (BGP_NODE, &neighbor_send_community_type_cmd);
9367 install_element (BGP_NODE, &no_neighbor_send_community_cmd);
9368 install_element (BGP_NODE, &no_neighbor_send_community_type_cmd);
9369 install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd);
9370 install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd);
9371 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd);
9372 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd);
9373 install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd);
9374 install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd);
9375 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd);
9376 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd);
9377 install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd);
9378 install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd);
9379 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd);
9380 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009381 install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd);
9382 install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd);
9383 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd);
9384 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd);
paul718e3742002-12-13 20:15:29 +00009385 install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd);
9386 install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd);
9387 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd);
9388 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd);
9389
9390 /* "neighbor route-reflector" commands.*/
9391 install_element (BGP_NODE, &neighbor_route_reflector_client_cmd);
9392 install_element (BGP_NODE, &no_neighbor_route_reflector_client_cmd);
9393 install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd);
9394 install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd);
9395 install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd);
9396 install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd);
9397 install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd);
9398 install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009399 install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd);
9400 install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd);
paul718e3742002-12-13 20:15:29 +00009401 install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd);
9402 install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd);
9403
9404 /* "neighbor route-server" commands.*/
9405 install_element (BGP_NODE, &neighbor_route_server_client_cmd);
9406 install_element (BGP_NODE, &no_neighbor_route_server_client_cmd);
9407 install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd);
9408 install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd);
9409 install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd);
9410 install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd);
9411 install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd);
9412 install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009413 install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd);
9414 install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd);
paul718e3742002-12-13 20:15:29 +00009415 install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd);
9416 install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd);
9417
9418 /* "neighbor passive" commands. */
9419 install_element (BGP_NODE, &neighbor_passive_cmd);
9420 install_element (BGP_NODE, &no_neighbor_passive_cmd);
9421
9422 /* "neighbor shutdown" commands. */
9423 install_element (BGP_NODE, &neighbor_shutdown_cmd);
9424 install_element (BGP_NODE, &no_neighbor_shutdown_cmd);
9425
hassoc9502432005-02-01 22:01:48 +00009426 /* Deprecated "neighbor capability route-refresh" commands.*/
paul718e3742002-12-13 20:15:29 +00009427 install_element (BGP_NODE, &neighbor_capability_route_refresh_cmd);
9428 install_element (BGP_NODE, &no_neighbor_capability_route_refresh_cmd);
9429
9430 /* "neighbor capability orf prefix-list" commands.*/
9431 install_element (BGP_NODE, &neighbor_capability_orf_prefix_cmd);
9432 install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_cmd);
9433 install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd);
9434 install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd);
9435 install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd);
9436 install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd);
9437 install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd);
9438 install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009439 install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd);
9440 install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00009441
9442 /* "neighbor capability dynamic" commands.*/
9443 install_element (BGP_NODE, &neighbor_capability_dynamic_cmd);
9444 install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd);
9445
9446 /* "neighbor dont-capability-negotiate" commands. */
9447 install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd);
9448 install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd);
9449
9450 /* "neighbor ebgp-multihop" commands. */
9451 install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd);
9452 install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd);
9453 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd);
9454 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_ttl_cmd);
9455
hasso6ffd2072005-02-02 14:50:11 +00009456 /* "neighbor disable-connected-check" commands. */
9457 install_element (BGP_NODE, &neighbor_disable_connected_check_cmd);
9458 install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd);
paul718e3742002-12-13 20:15:29 +00009459 install_element (BGP_NODE, &neighbor_enforce_multihop_cmd);
9460 install_element (BGP_NODE, &no_neighbor_enforce_multihop_cmd);
9461
9462 /* "neighbor description" commands. */
9463 install_element (BGP_NODE, &neighbor_description_cmd);
9464 install_element (BGP_NODE, &no_neighbor_description_cmd);
9465 install_element (BGP_NODE, &no_neighbor_description_val_cmd);
9466
9467 /* "neighbor update-source" commands. "*/
9468 install_element (BGP_NODE, &neighbor_update_source_cmd);
9469 install_element (BGP_NODE, &no_neighbor_update_source_cmd);
9470
9471 /* "neighbor default-originate" commands. */
9472 install_element (BGP_NODE, &neighbor_default_originate_cmd);
9473 install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd);
9474 install_element (BGP_NODE, &no_neighbor_default_originate_cmd);
9475 install_element (BGP_NODE, &no_neighbor_default_originate_rmap_cmd);
9476 install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd);
9477 install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd);
9478 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd);
9479 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_rmap_cmd);
9480 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd);
9481 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd);
9482 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd);
9483 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_rmap_cmd);
9484 install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd);
9485 install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd);
9486 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd);
9487 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_rmap_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009488 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd);
9489 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd);
9490 install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd);
9491 install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_rmap_cmd);
paul718e3742002-12-13 20:15:29 +00009492
9493 /* "neighbor port" commands. */
9494 install_element (BGP_NODE, &neighbor_port_cmd);
9495 install_element (BGP_NODE, &no_neighbor_port_cmd);
9496 install_element (BGP_NODE, &no_neighbor_port_val_cmd);
9497
9498 /* "neighbor weight" commands. */
9499 install_element (BGP_NODE, &neighbor_weight_cmd);
9500 install_element (BGP_NODE, &no_neighbor_weight_cmd);
9501 install_element (BGP_NODE, &no_neighbor_weight_val_cmd);
9502
9503 /* "neighbor override-capability" commands. */
9504 install_element (BGP_NODE, &neighbor_override_capability_cmd);
9505 install_element (BGP_NODE, &no_neighbor_override_capability_cmd);
9506
9507 /* "neighbor strict-capability-match" commands. */
9508 install_element (BGP_NODE, &neighbor_strict_capability_cmd);
9509 install_element (BGP_NODE, &no_neighbor_strict_capability_cmd);
9510
9511 /* "neighbor timers" commands. */
9512 install_element (BGP_NODE, &neighbor_timers_cmd);
9513 install_element (BGP_NODE, &no_neighbor_timers_cmd);
9514
9515 /* "neighbor timers connect" commands. */
9516 install_element (BGP_NODE, &neighbor_timers_connect_cmd);
9517 install_element (BGP_NODE, &no_neighbor_timers_connect_cmd);
9518 install_element (BGP_NODE, &no_neighbor_timers_connect_val_cmd);
9519
9520 /* "neighbor advertisement-interval" commands. */
9521 install_element (BGP_NODE, &neighbor_advertise_interval_cmd);
9522 install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd);
9523 install_element (BGP_NODE, &no_neighbor_advertise_interval_val_cmd);
9524
9525 /* "neighbor version" commands. */
9526 install_element (BGP_NODE, &neighbor_version_cmd);
paul718e3742002-12-13 20:15:29 +00009527
9528 /* "neighbor interface" commands. */
9529 install_element (BGP_NODE, &neighbor_interface_cmd);
9530 install_element (BGP_NODE, &no_neighbor_interface_cmd);
9531
9532 /* "neighbor distribute" commands. */
9533 install_element (BGP_NODE, &neighbor_distribute_list_cmd);
9534 install_element (BGP_NODE, &no_neighbor_distribute_list_cmd);
9535 install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd);
9536 install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd);
9537 install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd);
9538 install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd);
9539 install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd);
9540 install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009541 install_element (BGP_IPV6M_NODE, &neighbor_distribute_list_cmd);
9542 install_element (BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd);
paul718e3742002-12-13 20:15:29 +00009543 install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd);
9544 install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd);
9545
9546 /* "neighbor prefix-list" commands. */
9547 install_element (BGP_NODE, &neighbor_prefix_list_cmd);
9548 install_element (BGP_NODE, &no_neighbor_prefix_list_cmd);
9549 install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd);
9550 install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd);
9551 install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd);
9552 install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd);
9553 install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd);
9554 install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009555 install_element (BGP_IPV6M_NODE, &neighbor_prefix_list_cmd);
9556 install_element (BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd);
paul718e3742002-12-13 20:15:29 +00009557 install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd);
9558 install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd);
9559
9560 /* "neighbor filter-list" commands. */
9561 install_element (BGP_NODE, &neighbor_filter_list_cmd);
9562 install_element (BGP_NODE, &no_neighbor_filter_list_cmd);
9563 install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd);
9564 install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd);
9565 install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd);
9566 install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd);
9567 install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd);
9568 install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009569 install_element (BGP_IPV6M_NODE, &neighbor_filter_list_cmd);
9570 install_element (BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00009571 install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd);
9572 install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd);
9573
9574 /* "neighbor route-map" commands. */
9575 install_element (BGP_NODE, &neighbor_route_map_cmd);
9576 install_element (BGP_NODE, &no_neighbor_route_map_cmd);
9577 install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd);
9578 install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd);
9579 install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd);
9580 install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd);
9581 install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd);
9582 install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009583 install_element (BGP_IPV6M_NODE, &neighbor_route_map_cmd);
9584 install_element (BGP_IPV6M_NODE, &no_neighbor_route_map_cmd);
paul718e3742002-12-13 20:15:29 +00009585 install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd);
9586 install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd);
9587
9588 /* "neighbor unsuppress-map" commands. */
9589 install_element (BGP_NODE, &neighbor_unsuppress_map_cmd);
9590 install_element (BGP_NODE, &no_neighbor_unsuppress_map_cmd);
9591 install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd);
9592 install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd);
9593 install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd);
9594 install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd);
9595 install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd);
9596 install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009597 install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd);
9598 install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd);
paula58545b2003-07-12 21:43:01 +00009599 install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd);
9600 install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd);
paul718e3742002-12-13 20:15:29 +00009601
9602 /* "neighbor maximum-prefix" commands. */
9603 install_element (BGP_NODE, &neighbor_maximum_prefix_cmd);
hassoe0701b72004-05-20 09:19:34 +00009604 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_cmd);
paul718e3742002-12-13 20:15:29 +00009605 install_element (BGP_NODE, &neighbor_maximum_prefix_warning_cmd);
hassoe0701b72004-05-20 09:19:34 +00009606 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
hasso0a486e52005-02-01 20:57:17 +00009607 install_element (BGP_NODE, &neighbor_maximum_prefix_restart_cmd);
9608 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009609 install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd);
9610 install_element (BGP_NODE, &no_neighbor_maximum_prefix_val_cmd);
hasso0a486e52005-02-01 20:57:17 +00009611 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9612 install_element (BGP_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9613 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9614 install_element (BGP_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9615 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009616 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd);
hassoe0701b72004-05-20 09:19:34 +00009617 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
paul718e3742002-12-13 20:15:29 +00009618 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd);
hassoe0701b72004-05-20 09:19:34 +00009619 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
hasso0a486e52005-02-01 20:57:17 +00009620 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd);
9621 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009622 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd);
9623 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
hasso0a486e52005-02-01 20:57:17 +00009624 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9625 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9626 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9627 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9628 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009629 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd);
hassoe0701b72004-05-20 09:19:34 +00009630 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd);
paul718e3742002-12-13 20:15:29 +00009631 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd);
hassoe0701b72004-05-20 09:19:34 +00009632 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
hasso0a486e52005-02-01 20:57:17 +00009633 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd);
9634 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009635 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd);
9636 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_val_cmd);
hasso0a486e52005-02-01 20:57:17 +00009637 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9638 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9639 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9640 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9641 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009642 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd);
hassoe0701b72004-05-20 09:19:34 +00009643 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
paul718e3742002-12-13 20:15:29 +00009644 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd);
hassoe0701b72004-05-20 09:19:34 +00009645 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
hasso0a486e52005-02-01 20:57:17 +00009646 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd);
9647 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009648 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd);
9649 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_val_cmd);
hasso0a486e52005-02-01 20:57:17 +00009650 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9651 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9652 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9653 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9654 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009655 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd);
9656 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd);
9657 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd);
9658 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
9659 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd);
9660 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
9661 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd);
9662 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_val_cmd);
9663 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9664 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9665 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9666 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9667 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009668 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd);
hassoe0701b72004-05-20 09:19:34 +00009669 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
paul718e3742002-12-13 20:15:29 +00009670 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd);
hassoe0701b72004-05-20 09:19:34 +00009671 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
hasso0a486e52005-02-01 20:57:17 +00009672 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd);
9673 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009674 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd);
9675 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
hasso0a486e52005-02-01 20:57:17 +00009676 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9677 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9678 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9679 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9680 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009681
9682 /* "neighbor allowas-in" */
9683 install_element (BGP_NODE, &neighbor_allowas_in_cmd);
9684 install_element (BGP_NODE, &neighbor_allowas_in_arg_cmd);
9685 install_element (BGP_NODE, &no_neighbor_allowas_in_cmd);
9686 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd);
9687 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_arg_cmd);
9688 install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd);
9689 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd);
9690 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_arg_cmd);
9691 install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd);
9692 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd);
9693 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_arg_cmd);
9694 install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009695 install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd);
9696 install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_arg_cmd);
9697 install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd);
paul718e3742002-12-13 20:15:29 +00009698 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd);
9699 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_arg_cmd);
9700 install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd);
9701
9702 /* address-family commands. */
9703 install_element (BGP_NODE, &address_family_ipv4_cmd);
9704 install_element (BGP_NODE, &address_family_ipv4_safi_cmd);
9705#ifdef HAVE_IPV6
9706 install_element (BGP_NODE, &address_family_ipv6_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009707 install_element (BGP_NODE, &address_family_ipv6_safi_cmd);
paul718e3742002-12-13 20:15:29 +00009708#endif /* HAVE_IPV6 */
9709 install_element (BGP_NODE, &address_family_vpnv4_cmd);
9710 install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd);
9711
9712 /* "exit-address-family" command. */
9713 install_element (BGP_IPV4_NODE, &exit_address_family_cmd);
9714 install_element (BGP_IPV4M_NODE, &exit_address_family_cmd);
9715 install_element (BGP_IPV6_NODE, &exit_address_family_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009716 install_element (BGP_IPV6M_NODE, &exit_address_family_cmd);
paul718e3742002-12-13 20:15:29 +00009717 install_element (BGP_VPNV4_NODE, &exit_address_family_cmd);
9718
9719 /* "clear ip bgp commands" */
9720 install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd);
9721 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_cmd);
9722 install_element (ENABLE_NODE, &clear_ip_bgp_as_cmd);
9723 install_element (ENABLE_NODE, &clear_ip_bgp_peer_cmd);
9724 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_cmd);
9725 install_element (ENABLE_NODE, &clear_ip_bgp_external_cmd);
9726#ifdef HAVE_IPV6
9727 install_element (ENABLE_NODE, &clear_bgp_all_cmd);
9728 install_element (ENABLE_NODE, &clear_bgp_instance_all_cmd);
9729 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_cmd);
9730 install_element (ENABLE_NODE, &clear_bgp_peer_cmd);
9731 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_cmd);
9732 install_element (ENABLE_NODE, &clear_bgp_peer_group_cmd);
9733 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_cmd);
9734 install_element (ENABLE_NODE, &clear_bgp_external_cmd);
9735 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_cmd);
9736 install_element (ENABLE_NODE, &clear_bgp_as_cmd);
9737 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_cmd);
9738#endif /* HAVE_IPV6 */
9739
9740 /* "clear ip bgp neighbor soft in" */
9741 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_in_cmd);
9742 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_in_cmd);
9743 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_cmd);
9744 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_prefix_filter_cmd);
9745 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_in_prefix_filter_cmd);
9746 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_in_cmd);
9747 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_cmd);
9748 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_prefix_filter_cmd);
9749 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_in_cmd);
9750 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_cmd);
9751 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_prefix_filter_cmd);
9752 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_in_cmd);
9753 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_cmd);
9754 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_prefix_filter_cmd);
9755 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_in_cmd);
9756 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_cmd);
9757 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_prefix_filter_cmd);
9758 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_in_cmd);
9759 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_in_cmd);
9760 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_cmd);
9761 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_prefix_filter_cmd);
9762 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_in_prefix_filter_cmd);
9763 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_in_cmd);
9764 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_cmd);
9765 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd);
9766 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_in_cmd);
9767 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_cmd);
9768 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd);
9769 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_in_cmd);
9770 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_cmd);
9771 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_prefix_filter_cmd);
9772 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_in_cmd);
9773 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_cmd);
9774 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_prefix_filter_cmd);
9775 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_in_cmd);
9776 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_in_cmd);
9777 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_in_cmd);
9778 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_in_cmd);
9779 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_in_cmd);
9780 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_in_cmd);
9781#ifdef HAVE_IPV6
9782 install_element (ENABLE_NODE, &clear_bgp_all_soft_in_cmd);
9783 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_in_cmd);
9784 install_element (ENABLE_NODE, &clear_bgp_all_in_cmd);
9785 install_element (ENABLE_NODE, &clear_bgp_all_in_prefix_filter_cmd);
9786 install_element (ENABLE_NODE, &clear_bgp_peer_soft_in_cmd);
9787 install_element (ENABLE_NODE, &clear_bgp_peer_in_cmd);
9788 install_element (ENABLE_NODE, &clear_bgp_peer_in_prefix_filter_cmd);
9789 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_in_cmd);
9790 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_cmd);
9791 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_prefix_filter_cmd);
9792 install_element (ENABLE_NODE, &clear_bgp_external_soft_in_cmd);
9793 install_element (ENABLE_NODE, &clear_bgp_external_in_cmd);
9794 install_element (ENABLE_NODE, &clear_bgp_external_in_prefix_filter_cmd);
9795 install_element (ENABLE_NODE, &clear_bgp_as_soft_in_cmd);
9796 install_element (ENABLE_NODE, &clear_bgp_as_in_cmd);
9797 install_element (ENABLE_NODE, &clear_bgp_as_in_prefix_filter_cmd);
9798 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_in_cmd);
9799 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_cmd);
9800 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_prefix_filter_cmd);
9801 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_in_cmd);
9802 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_cmd);
9803 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_prefix_filter_cmd);
9804 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_in_cmd);
9805 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_cmd);
9806 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_prefix_filter_cmd);
9807 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_in_cmd);
9808 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_cmd);
9809 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_prefix_filter_cmd);
9810 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_in_cmd);
9811 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_cmd);
9812 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_prefix_filter_cmd);
9813#endif /* HAVE_IPV6 */
9814
9815 /* "clear ip bgp neighbor soft out" */
9816 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_out_cmd);
9817 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_out_cmd);
9818 install_element (ENABLE_NODE, &clear_ip_bgp_all_out_cmd);
9819 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_out_cmd);
9820 install_element (ENABLE_NODE, &clear_ip_bgp_peer_out_cmd);
9821 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_out_cmd);
9822 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_out_cmd);
9823 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_out_cmd);
9824 install_element (ENABLE_NODE, &clear_ip_bgp_external_out_cmd);
9825 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_out_cmd);
9826 install_element (ENABLE_NODE, &clear_ip_bgp_as_out_cmd);
9827 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_out_cmd);
9828 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_out_cmd);
9829 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_out_cmd);
9830 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_out_cmd);
9831 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_out_cmd);
9832 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_out_cmd);
9833 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_out_cmd);
9834 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_out_cmd);
9835 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_out_cmd);
9836 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_out_cmd);
9837 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_out_cmd);
9838 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_out_cmd);
9839 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_out_cmd);
9840 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_out_cmd);
9841 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_out_cmd);
9842 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_out_cmd);
9843 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_out_cmd);
9844#ifdef HAVE_IPV6
9845 install_element (ENABLE_NODE, &clear_bgp_all_soft_out_cmd);
9846 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_out_cmd);
9847 install_element (ENABLE_NODE, &clear_bgp_all_out_cmd);
9848 install_element (ENABLE_NODE, &clear_bgp_peer_soft_out_cmd);
9849 install_element (ENABLE_NODE, &clear_bgp_peer_out_cmd);
9850 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_out_cmd);
9851 install_element (ENABLE_NODE, &clear_bgp_peer_group_out_cmd);
9852 install_element (ENABLE_NODE, &clear_bgp_external_soft_out_cmd);
9853 install_element (ENABLE_NODE, &clear_bgp_external_out_cmd);
9854 install_element (ENABLE_NODE, &clear_bgp_as_soft_out_cmd);
9855 install_element (ENABLE_NODE, &clear_bgp_as_out_cmd);
9856 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_out_cmd);
9857 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_out_cmd);
9858 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_out_cmd);
9859 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_out_cmd);
9860 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_out_cmd);
9861 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_out_cmd);
9862 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_out_cmd);
9863 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_out_cmd);
9864 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_out_cmd);
9865 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_out_cmd);
9866#endif /* HAVE_IPV6 */
9867
9868 /* "clear ip bgp neighbor soft" */
9869 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_cmd);
9870 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_cmd);
9871 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_cmd);
9872 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_cmd);
9873 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_cmd);
9874 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_cmd);
9875 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_cmd);
9876 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_cmd);
9877 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_cmd);
9878 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_cmd);
9879 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_cmd);
9880 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_cmd);
9881 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_cmd);
9882 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_cmd);
9883 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_cmd);
9884#ifdef HAVE_IPV6
9885 install_element (ENABLE_NODE, &clear_bgp_all_soft_cmd);
9886 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_cmd);
9887 install_element (ENABLE_NODE, &clear_bgp_peer_soft_cmd);
9888 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_cmd);
9889 install_element (ENABLE_NODE, &clear_bgp_external_soft_cmd);
9890 install_element (ENABLE_NODE, &clear_bgp_as_soft_cmd);
9891 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_cmd);
9892 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_cmd);
9893 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_cmd);
9894 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_cmd);
9895 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_cmd);
9896#endif /* HAVE_IPV6 */
9897
paulfee0f4c2004-09-13 05:12:46 +00009898 /* "clear ip bgp neighbor rsclient" */
9899 install_element (ENABLE_NODE, &clear_ip_bgp_all_rsclient_cmd);
9900 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_rsclient_cmd);
9901 install_element (ENABLE_NODE, &clear_ip_bgp_peer_rsclient_cmd);
9902 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_rsclient_cmd);
9903#ifdef HAVE_IPV6
9904 install_element (ENABLE_NODE, &clear_bgp_all_rsclient_cmd);
9905 install_element (ENABLE_NODE, &clear_bgp_instance_all_rsclient_cmd);
9906 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_rsclient_cmd);
9907 install_element (ENABLE_NODE, &clear_bgp_ipv6_instance_all_rsclient_cmd);
9908 install_element (ENABLE_NODE, &clear_bgp_peer_rsclient_cmd);
9909 install_element (ENABLE_NODE, &clear_bgp_instance_peer_rsclient_cmd);
9910 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_rsclient_cmd);
9911 install_element (ENABLE_NODE, &clear_bgp_ipv6_instance_peer_rsclient_cmd);
9912#endif /* HAVE_IPV6 */
9913
paul718e3742002-12-13 20:15:29 +00009914 /* "show ip bgp summary" commands. */
9915 install_element (VIEW_NODE, &show_ip_bgp_summary_cmd);
9916 install_element (VIEW_NODE, &show_ip_bgp_instance_summary_cmd);
9917 install_element (VIEW_NODE, &show_ip_bgp_ipv4_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -04009918 install_element (VIEW_NODE, &show_bgp_ipv4_safi_summary_cmd);
paul718e3742002-12-13 20:15:29 +00009919 install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -04009920 install_element (VIEW_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
paul718e3742002-12-13 20:15:29 +00009921 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
9922 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
9923#ifdef HAVE_IPV6
9924 install_element (VIEW_NODE, &show_bgp_summary_cmd);
9925 install_element (VIEW_NODE, &show_bgp_instance_summary_cmd);
9926 install_element (VIEW_NODE, &show_bgp_ipv6_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -04009927 install_element (VIEW_NODE, &show_bgp_ipv6_safi_summary_cmd);
paul718e3742002-12-13 20:15:29 +00009928 install_element (VIEW_NODE, &show_bgp_instance_ipv6_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -04009929 install_element (VIEW_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
paul718e3742002-12-13 20:15:29 +00009930#endif /* HAVE_IPV6 */
Paul Jakma62687ff2008-08-23 14:27:06 +01009931 install_element (RESTRICTED_NODE, &show_ip_bgp_summary_cmd);
9932 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_summary_cmd);
9933 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -04009934 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_summary_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +01009935 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -04009936 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +01009937 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
9938 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
9939#ifdef HAVE_IPV6
9940 install_element (RESTRICTED_NODE, &show_bgp_summary_cmd);
9941 install_element (RESTRICTED_NODE, &show_bgp_instance_summary_cmd);
9942 install_element (RESTRICTED_NODE, &show_bgp_ipv6_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -04009943 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_summary_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +01009944 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -04009945 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +01009946#endif /* HAVE_IPV6 */
paul718e3742002-12-13 20:15:29 +00009947 install_element (ENABLE_NODE, &show_ip_bgp_summary_cmd);
9948 install_element (ENABLE_NODE, &show_ip_bgp_instance_summary_cmd);
9949 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -04009950 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_summary_cmd);
paul718e3742002-12-13 20:15:29 +00009951 install_element (ENABLE_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -04009952 install_element (ENABLE_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
paul718e3742002-12-13 20:15:29 +00009953 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
9954 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
9955#ifdef HAVE_IPV6
9956 install_element (ENABLE_NODE, &show_bgp_summary_cmd);
9957 install_element (ENABLE_NODE, &show_bgp_instance_summary_cmd);
9958 install_element (ENABLE_NODE, &show_bgp_ipv6_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -04009959 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_summary_cmd);
paul718e3742002-12-13 20:15:29 +00009960 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -04009961 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
paul718e3742002-12-13 20:15:29 +00009962#endif /* HAVE_IPV6 */
9963
9964 /* "show ip bgp neighbors" commands. */
9965 install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd);
9966 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
9967 install_element (VIEW_NODE, &show_ip_bgp_neighbors_peer_cmd);
9968 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
9969 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd);
9970 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd);
9971 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
9972 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
9973 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_cmd);
9974 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +01009975 install_element (RESTRICTED_NODE, &show_ip_bgp_neighbors_peer_cmd);
9976 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
9977 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
9978 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
9979 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
paul718e3742002-12-13 20:15:29 +00009980 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_cmd);
9981 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
9982 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_peer_cmd);
9983 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
9984 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd);
9985 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd);
9986 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
9987 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
9988 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_cmd);
9989 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
9990
9991#ifdef HAVE_IPV6
9992 install_element (VIEW_NODE, &show_bgp_neighbors_cmd);
9993 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_cmd);
9994 install_element (VIEW_NODE, &show_bgp_neighbors_peer_cmd);
9995 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
paulbb46e942003-10-24 19:02:03 +00009996 install_element (VIEW_NODE, &show_bgp_instance_neighbors_cmd);
9997 install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
9998 install_element (VIEW_NODE, &show_bgp_instance_neighbors_peer_cmd);
9999 install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010010000 install_element (RESTRICTED_NODE, &show_bgp_neighbors_peer_cmd);
10001 install_element (RESTRICTED_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
10002 install_element (RESTRICTED_NODE, &show_bgp_instance_neighbors_peer_cmd);
10003 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
paul718e3742002-12-13 20:15:29 +000010004 install_element (ENABLE_NODE, &show_bgp_neighbors_cmd);
10005 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_cmd);
10006 install_element (ENABLE_NODE, &show_bgp_neighbors_peer_cmd);
10007 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
paulbb46e942003-10-24 19:02:03 +000010008 install_element (ENABLE_NODE, &show_bgp_instance_neighbors_cmd);
10009 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
10010 install_element (ENABLE_NODE, &show_bgp_instance_neighbors_peer_cmd);
10011 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
paul718e3742002-12-13 20:15:29 +000010012
10013 /* Old commands. */
10014 install_element (VIEW_NODE, &show_ipv6_bgp_summary_cmd);
10015 install_element (VIEW_NODE, &show_ipv6_mbgp_summary_cmd);
10016 install_element (ENABLE_NODE, &show_ipv6_bgp_summary_cmd);
10017 install_element (ENABLE_NODE, &show_ipv6_mbgp_summary_cmd);
10018#endif /* HAVE_IPV6 */
10019
paulfee0f4c2004-09-13 05:12:46 +000010020 /* "show ip bgp rsclient" commands. */
10021 install_element (VIEW_NODE, &show_ip_bgp_rsclient_summary_cmd);
10022 install_element (VIEW_NODE, &show_ip_bgp_instance_rsclient_summary_cmd);
10023 install_element (VIEW_NODE, &show_ip_bgp_ipv4_rsclient_summary_cmd);
10024 install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_rsclient_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010025 install_element (VIEW_NODE, &show_bgp_instance_ipv4_safi_rsclient_summary_cmd);
10026 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_summary_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010010027 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_summary_cmd);
10028 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_rsclient_summary_cmd);
10029 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_rsclient_summary_cmd);
10030 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_ipv4_rsclient_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010031 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv4_safi_rsclient_summary_cmd);
10032 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_summary_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010033 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_summary_cmd);
10034 install_element (ENABLE_NODE, &show_ip_bgp_instance_rsclient_summary_cmd);
10035 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_rsclient_summary_cmd);
10036 install_element (ENABLE_NODE, &show_ip_bgp_instance_ipv4_rsclient_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010037 install_element (ENABLE_NODE, &show_bgp_instance_ipv4_safi_rsclient_summary_cmd);
10038 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_summary_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010039
10040#ifdef HAVE_IPV6
10041 install_element (VIEW_NODE, &show_bgp_rsclient_summary_cmd);
10042 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_summary_cmd);
10043 install_element (VIEW_NODE, &show_bgp_instance_rsclient_summary_cmd);
10044 install_element (VIEW_NODE, &show_bgp_instance_ipv6_rsclient_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010045 install_element (VIEW_NODE, &show_bgp_instance_ipv6_safi_rsclient_summary_cmd);
10046 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_summary_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010010047 install_element (RESTRICTED_NODE, &show_bgp_rsclient_summary_cmd);
10048 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_summary_cmd);
10049 install_element (RESTRICTED_NODE, &show_bgp_instance_rsclient_summary_cmd);
10050 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_rsclient_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010051 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_safi_rsclient_summary_cmd);
10052 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_summary_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010053 install_element (ENABLE_NODE, &show_bgp_rsclient_summary_cmd);
10054 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_summary_cmd);
10055 install_element (ENABLE_NODE, &show_bgp_instance_rsclient_summary_cmd);
10056 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_rsclient_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010057 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_safi_rsclient_summary_cmd);
10058 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_summary_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010059#endif /* HAVE_IPV6 */
10060
paul718e3742002-12-13 20:15:29 +000010061 /* "show ip bgp paths" commands. */
10062 install_element (VIEW_NODE, &show_ip_bgp_paths_cmd);
10063 install_element (VIEW_NODE, &show_ip_bgp_ipv4_paths_cmd);
10064 install_element (ENABLE_NODE, &show_ip_bgp_paths_cmd);
10065 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_paths_cmd);
10066
10067 /* "show ip bgp community" commands. */
10068 install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd);
10069 install_element (ENABLE_NODE, &show_ip_bgp_community_info_cmd);
10070
10071 /* "show ip bgp attribute-info" commands. */
10072 install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd);
10073 install_element (ENABLE_NODE, &show_ip_bgp_attr_info_cmd);
10074
10075 /* "redistribute" commands. */
10076 install_element (BGP_NODE, &bgp_redistribute_ipv4_cmd);
10077 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_cmd);
10078 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_cmd);
10079 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_cmd);
10080 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_cmd);
10081 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_cmd);
10082 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd);
10083 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd);
10084 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_metric_cmd);
10085 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_rmap_cmd);
10086#ifdef HAVE_IPV6
10087 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd);
10088 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd);
10089 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd);
10090 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_cmd);
10091 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd);
10092 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_cmd);
10093 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd);
10094 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd);
10095 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_metric_cmd);
10096 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_rmap_cmd);
10097#endif /* HAVE_IPV6 */
10098
Nick Hilliardfa411a22011-03-23 15:33:17 +000010099 /* ttl_security commands */
10100 install_element (BGP_NODE, &neighbor_ttl_security_cmd);
10101 install_element (BGP_NODE, &no_neighbor_ttl_security_cmd);
10102
Paul Jakma4bf6a362006-03-30 14:05:23 +000010103 /* "show bgp memory" commands. */
10104 install_element (VIEW_NODE, &show_bgp_memory_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010010105 install_element (RESTRICTED_NODE, &show_bgp_memory_cmd);
Paul Jakma4bf6a362006-03-30 14:05:23 +000010106 install_element (ENABLE_NODE, &show_bgp_memory_cmd);
10107
Michael Lamberte0081f72008-11-16 20:12:04 +000010108 /* "show bgp views" commands. */
10109 install_element (VIEW_NODE, &show_bgp_views_cmd);
10110 install_element (RESTRICTED_NODE, &show_bgp_views_cmd);
10111 install_element (ENABLE_NODE, &show_bgp_views_cmd);
10112
paul718e3742002-12-13 20:15:29 +000010113 /* Community-list. */
10114 community_list_vty ();
10115}
10116
10117#include "memory.h"
10118#include "bgp_regex.h"
10119#include "bgp_clist.h"
10120#include "bgp_ecommunity.h"
10121
10122/* VTY functions. */
10123
10124/* Direction value to string conversion. */
paul94f2b392005-06-28 12:44:16 +000010125static const char *
paul718e3742002-12-13 20:15:29 +000010126community_direct_str (int direct)
10127{
10128 switch (direct)
10129 {
10130 case COMMUNITY_DENY:
10131 return "deny";
paul718e3742002-12-13 20:15:29 +000010132 case COMMUNITY_PERMIT:
10133 return "permit";
paul718e3742002-12-13 20:15:29 +000010134 default:
10135 return "unknown";
paul718e3742002-12-13 20:15:29 +000010136 }
10137}
10138
10139/* Display error string. */
paul94f2b392005-06-28 12:44:16 +000010140static void
paul718e3742002-12-13 20:15:29 +000010141community_list_perror (struct vty *vty, int ret)
10142{
10143 switch (ret)
10144 {
10145 case COMMUNITY_LIST_ERR_CANT_FIND_LIST:
Denis Ovsienkob7292942010-12-08 18:51:37 +030010146 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000010147 break;
10148 case COMMUNITY_LIST_ERR_MALFORMED_VAL:
10149 vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE);
10150 break;
10151 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT:
10152 vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE);
10153 break;
10154 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT:
10155 vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE);
10156 break;
10157 }
10158}
10159
10160/* VTY interface for community_set() function. */
paul94f2b392005-06-28 12:44:16 +000010161static int
paulfd79ac92004-10-13 05:06:08 +000010162community_list_set_vty (struct vty *vty, int argc, const char **argv,
10163 int style, int reject_all_digit_name)
paul718e3742002-12-13 20:15:29 +000010164{
10165 int ret;
10166 int direct;
10167 char *str;
10168
10169 /* Check the list type. */
10170 if (strncmp (argv[1], "p", 1) == 0)
10171 direct = COMMUNITY_PERMIT;
10172 else if (strncmp (argv[1], "d", 1) == 0)
10173 direct = COMMUNITY_DENY;
10174 else
10175 {
10176 vty_out (vty, "%% Matching condition must be permit or deny%s",
10177 VTY_NEWLINE);
10178 return CMD_WARNING;
10179 }
10180
10181 /* All digit name check. */
10182 if (reject_all_digit_name && all_digit (argv[0]))
10183 {
10184 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
10185 return CMD_WARNING;
10186 }
10187
10188 /* Concat community string argument. */
10189 if (argc > 1)
10190 str = argv_concat (argv, argc, 2);
10191 else
10192 str = NULL;
10193
10194 /* When community_list_set() return nevetive value, it means
10195 malformed community string. */
10196 ret = community_list_set (bgp_clist, argv[0], str, direct, style);
10197
10198 /* Free temporary community list string allocated by
10199 argv_concat(). */
10200 if (str)
10201 XFREE (MTYPE_TMP, str);
10202
10203 if (ret < 0)
10204 {
10205 /* Display error string. */
10206 community_list_perror (vty, ret);
10207 return CMD_WARNING;
10208 }
10209
10210 return CMD_SUCCESS;
10211}
10212
paul718e3742002-12-13 20:15:29 +000010213/* Communiyt-list entry delete. */
paul94f2b392005-06-28 12:44:16 +000010214static int
hassofee6e4e2005-02-02 16:29:31 +000010215community_list_unset_vty (struct vty *vty, int argc, const char **argv,
10216 int style)
paul718e3742002-12-13 20:15:29 +000010217{
10218 int ret;
hassofee6e4e2005-02-02 16:29:31 +000010219 int direct = 0;
10220 char *str = NULL;
paul718e3742002-12-13 20:15:29 +000010221
hassofee6e4e2005-02-02 16:29:31 +000010222 if (argc > 1)
paul718e3742002-12-13 20:15:29 +000010223 {
hassofee6e4e2005-02-02 16:29:31 +000010224 /* Check the list direct. */
10225 if (strncmp (argv[1], "p", 1) == 0)
10226 direct = COMMUNITY_PERMIT;
10227 else if (strncmp (argv[1], "d", 1) == 0)
10228 direct = COMMUNITY_DENY;
10229 else
10230 {
10231 vty_out (vty, "%% Matching condition must be permit or deny%s",
10232 VTY_NEWLINE);
10233 return CMD_WARNING;
10234 }
paul718e3742002-12-13 20:15:29 +000010235
hassofee6e4e2005-02-02 16:29:31 +000010236 /* Concat community string argument. */
10237 str = argv_concat (argv, argc, 2);
10238 }
paul718e3742002-12-13 20:15:29 +000010239
10240 /* Unset community list. */
10241 ret = community_list_unset (bgp_clist, argv[0], str, direct, style);
10242
10243 /* Free temporary community list string allocated by
10244 argv_concat(). */
hassofee6e4e2005-02-02 16:29:31 +000010245 if (str)
10246 XFREE (MTYPE_TMP, str);
paul718e3742002-12-13 20:15:29 +000010247
10248 if (ret < 0)
10249 {
10250 community_list_perror (vty, ret);
10251 return CMD_WARNING;
10252 }
10253
10254 return CMD_SUCCESS;
10255}
10256
10257/* "community-list" keyword help string. */
10258#define COMMUNITY_LIST_STR "Add a community list entry\n"
10259#define COMMUNITY_VAL_STR "Community number in aa:nn format or internet|local-AS|no-advertise|no-export\n"
10260
paul718e3742002-12-13 20:15:29 +000010261DEFUN (ip_community_list_standard,
10262 ip_community_list_standard_cmd,
10263 "ip community-list <1-99> (deny|permit) .AA:NN",
10264 IP_STR
10265 COMMUNITY_LIST_STR
10266 "Community list number (standard)\n"
10267 "Specify community to reject\n"
10268 "Specify community to accept\n"
10269 COMMUNITY_VAL_STR)
10270{
10271 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
10272}
10273
10274ALIAS (ip_community_list_standard,
10275 ip_community_list_standard2_cmd,
10276 "ip community-list <1-99> (deny|permit)",
10277 IP_STR
10278 COMMUNITY_LIST_STR
10279 "Community list number (standard)\n"
10280 "Specify community to reject\n"
10281 "Specify community to accept\n")
10282
10283DEFUN (ip_community_list_expanded,
10284 ip_community_list_expanded_cmd,
hassofee6e4e2005-02-02 16:29:31 +000010285 "ip community-list <100-500> (deny|permit) .LINE",
paul718e3742002-12-13 20:15:29 +000010286 IP_STR
10287 COMMUNITY_LIST_STR
10288 "Community list number (expanded)\n"
10289 "Specify community to reject\n"
10290 "Specify community to accept\n"
10291 "An ordered list as a regular-expression\n")
10292{
10293 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
10294}
10295
10296DEFUN (ip_community_list_name_standard,
10297 ip_community_list_name_standard_cmd,
10298 "ip community-list standard WORD (deny|permit) .AA:NN",
10299 IP_STR
10300 COMMUNITY_LIST_STR
10301 "Add a standard community-list entry\n"
10302 "Community list name\n"
10303 "Specify community to reject\n"
10304 "Specify community to accept\n"
10305 COMMUNITY_VAL_STR)
10306{
10307 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
10308}
10309
10310ALIAS (ip_community_list_name_standard,
10311 ip_community_list_name_standard2_cmd,
10312 "ip community-list standard WORD (deny|permit)",
10313 IP_STR
10314 COMMUNITY_LIST_STR
10315 "Add a standard community-list entry\n"
10316 "Community list name\n"
10317 "Specify community to reject\n"
10318 "Specify community to accept\n")
10319
10320DEFUN (ip_community_list_name_expanded,
10321 ip_community_list_name_expanded_cmd,
10322 "ip community-list expanded WORD (deny|permit) .LINE",
10323 IP_STR
10324 COMMUNITY_LIST_STR
10325 "Add an expanded community-list entry\n"
10326 "Community list name\n"
10327 "Specify community to reject\n"
10328 "Specify community to accept\n"
10329 "An ordered list as a regular-expression\n")
10330{
10331 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
10332}
10333
hassofee6e4e2005-02-02 16:29:31 +000010334DEFUN (no_ip_community_list_standard_all,
10335 no_ip_community_list_standard_all_cmd,
10336 "no ip community-list <1-99>",
paul718e3742002-12-13 20:15:29 +000010337 NO_STR
10338 IP_STR
10339 COMMUNITY_LIST_STR
hassofee6e4e2005-02-02 16:29:31 +000010340 "Community list number (standard)\n")
paul718e3742002-12-13 20:15:29 +000010341{
hassofee6e4e2005-02-02 16:29:31 +000010342 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
paul718e3742002-12-13 20:15:29 +000010343}
10344
hassofee6e4e2005-02-02 16:29:31 +000010345DEFUN (no_ip_community_list_expanded_all,
10346 no_ip_community_list_expanded_all_cmd,
10347 "no ip community-list <100-500>",
10348 NO_STR
10349 IP_STR
10350 COMMUNITY_LIST_STR
10351 "Community list number (expanded)\n")
10352{
10353 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
10354}
10355
10356DEFUN (no_ip_community_list_name_standard_all,
10357 no_ip_community_list_name_standard_all_cmd,
10358 "no ip community-list standard WORD",
paul718e3742002-12-13 20:15:29 +000010359 NO_STR
10360 IP_STR
10361 COMMUNITY_LIST_STR
10362 "Add a standard community-list entry\n"
paul718e3742002-12-13 20:15:29 +000010363 "Community list name\n")
10364{
hassofee6e4e2005-02-02 16:29:31 +000010365 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
paul718e3742002-12-13 20:15:29 +000010366}
10367
hassofee6e4e2005-02-02 16:29:31 +000010368DEFUN (no_ip_community_list_name_expanded_all,
10369 no_ip_community_list_name_expanded_all_cmd,
10370 "no ip community-list expanded WORD",
paul718e3742002-12-13 20:15:29 +000010371 NO_STR
10372 IP_STR
10373 COMMUNITY_LIST_STR
hassofee6e4e2005-02-02 16:29:31 +000010374 "Add an expanded community-list entry\n"
10375 "Community list name\n")
paul718e3742002-12-13 20:15:29 +000010376{
hassofee6e4e2005-02-02 16:29:31 +000010377 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
paul718e3742002-12-13 20:15:29 +000010378}
10379
10380DEFUN (no_ip_community_list_standard,
10381 no_ip_community_list_standard_cmd,
10382 "no ip community-list <1-99> (deny|permit) .AA:NN",
10383 NO_STR
10384 IP_STR
10385 COMMUNITY_LIST_STR
10386 "Community list number (standard)\n"
10387 "Specify community to reject\n"
10388 "Specify community to accept\n"
10389 COMMUNITY_VAL_STR)
10390{
10391 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
10392}
10393
10394DEFUN (no_ip_community_list_expanded,
10395 no_ip_community_list_expanded_cmd,
hassofee6e4e2005-02-02 16:29:31 +000010396 "no ip community-list <100-500> (deny|permit) .LINE",
paul718e3742002-12-13 20:15:29 +000010397 NO_STR
10398 IP_STR
10399 COMMUNITY_LIST_STR
10400 "Community list number (expanded)\n"
10401 "Specify community to reject\n"
10402 "Specify community to accept\n"
10403 "An ordered list as a regular-expression\n")
10404{
10405 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
10406}
10407
10408DEFUN (no_ip_community_list_name_standard,
10409 no_ip_community_list_name_standard_cmd,
10410 "no ip community-list standard WORD (deny|permit) .AA:NN",
10411 NO_STR
10412 IP_STR
10413 COMMUNITY_LIST_STR
10414 "Specify a standard community-list\n"
10415 "Community list name\n"
10416 "Specify community to reject\n"
10417 "Specify community to accept\n"
10418 COMMUNITY_VAL_STR)
10419{
10420 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
10421}
10422
10423DEFUN (no_ip_community_list_name_expanded,
10424 no_ip_community_list_name_expanded_cmd,
10425 "no ip community-list expanded WORD (deny|permit) .LINE",
10426 NO_STR
10427 IP_STR
10428 COMMUNITY_LIST_STR
10429 "Specify an expanded community-list\n"
10430 "Community list name\n"
10431 "Specify community to reject\n"
10432 "Specify community to accept\n"
10433 "An ordered list as a regular-expression\n")
10434{
10435 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
10436}
10437
paul94f2b392005-06-28 12:44:16 +000010438static void
paul718e3742002-12-13 20:15:29 +000010439community_list_show (struct vty *vty, struct community_list *list)
10440{
10441 struct community_entry *entry;
10442
10443 for (entry = list->head; entry; entry = entry->next)
10444 {
10445 if (entry == list->head)
10446 {
10447 if (all_digit (list->name))
10448 vty_out (vty, "Community %s list %s%s",
10449 entry->style == COMMUNITY_LIST_STANDARD ?
10450 "standard" : "(expanded) access",
10451 list->name, VTY_NEWLINE);
10452 else
10453 vty_out (vty, "Named Community %s list %s%s",
10454 entry->style == COMMUNITY_LIST_STANDARD ?
10455 "standard" : "expanded",
10456 list->name, VTY_NEWLINE);
10457 }
10458 if (entry->any)
10459 vty_out (vty, " %s%s",
10460 community_direct_str (entry->direct), VTY_NEWLINE);
10461 else
10462 vty_out (vty, " %s %s%s",
10463 community_direct_str (entry->direct),
10464 entry->style == COMMUNITY_LIST_STANDARD
10465 ? community_str (entry->u.com) : entry->config,
10466 VTY_NEWLINE);
10467 }
10468}
10469
10470DEFUN (show_ip_community_list,
10471 show_ip_community_list_cmd,
10472 "show ip community-list",
10473 SHOW_STR
10474 IP_STR
10475 "List community-list\n")
10476{
10477 struct community_list *list;
10478 struct community_list_master *cm;
10479
hassofee6e4e2005-02-02 16:29:31 +000010480 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010481 if (! cm)
10482 return CMD_SUCCESS;
10483
10484 for (list = cm->num.head; list; list = list->next)
10485 community_list_show (vty, list);
10486
10487 for (list = cm->str.head; list; list = list->next)
10488 community_list_show (vty, list);
10489
10490 return CMD_SUCCESS;
10491}
10492
10493DEFUN (show_ip_community_list_arg,
10494 show_ip_community_list_arg_cmd,
hassofee6e4e2005-02-02 16:29:31 +000010495 "show ip community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000010496 SHOW_STR
10497 IP_STR
10498 "List community-list\n"
10499 "Community-list number\n"
10500 "Community-list name\n")
10501{
10502 struct community_list *list;
10503
hassofee6e4e2005-02-02 16:29:31 +000010504 list = community_list_lookup (bgp_clist, argv[0], COMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010505 if (! list)
10506 {
Denis Ovsienkob7292942010-12-08 18:51:37 +030010507 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000010508 return CMD_WARNING;
10509 }
10510
10511 community_list_show (vty, list);
10512
10513 return CMD_SUCCESS;
10514}
10515
paul94f2b392005-06-28 12:44:16 +000010516static int
paulfd79ac92004-10-13 05:06:08 +000010517extcommunity_list_set_vty (struct vty *vty, int argc, const char **argv,
10518 int style, int reject_all_digit_name)
paul718e3742002-12-13 20:15:29 +000010519{
10520 int ret;
10521 int direct;
10522 char *str;
10523
10524 /* Check the list type. */
10525 if (strncmp (argv[1], "p", 1) == 0)
10526 direct = COMMUNITY_PERMIT;
10527 else if (strncmp (argv[1], "d", 1) == 0)
10528 direct = COMMUNITY_DENY;
10529 else
10530 {
10531 vty_out (vty, "%% Matching condition must be permit or deny%s",
10532 VTY_NEWLINE);
10533 return CMD_WARNING;
10534 }
10535
10536 /* All digit name check. */
10537 if (reject_all_digit_name && all_digit (argv[0]))
10538 {
10539 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
10540 return CMD_WARNING;
10541 }
10542
10543 /* Concat community string argument. */
10544 if (argc > 1)
10545 str = argv_concat (argv, argc, 2);
10546 else
10547 str = NULL;
10548
10549 ret = extcommunity_list_set (bgp_clist, argv[0], str, direct, style);
10550
10551 /* Free temporary community list string allocated by
10552 argv_concat(). */
10553 if (str)
10554 XFREE (MTYPE_TMP, str);
10555
10556 if (ret < 0)
10557 {
10558 community_list_perror (vty, ret);
10559 return CMD_WARNING;
10560 }
10561 return CMD_SUCCESS;
10562}
10563
paul94f2b392005-06-28 12:44:16 +000010564static int
hassofee6e4e2005-02-02 16:29:31 +000010565extcommunity_list_unset_vty (struct vty *vty, int argc, const char **argv,
10566 int style)
paul718e3742002-12-13 20:15:29 +000010567{
10568 int ret;
hassofee6e4e2005-02-02 16:29:31 +000010569 int direct = 0;
10570 char *str = NULL;
paul718e3742002-12-13 20:15:29 +000010571
hassofee6e4e2005-02-02 16:29:31 +000010572 if (argc > 1)
paul718e3742002-12-13 20:15:29 +000010573 {
hassofee6e4e2005-02-02 16:29:31 +000010574 /* Check the list direct. */
10575 if (strncmp (argv[1], "p", 1) == 0)
10576 direct = COMMUNITY_PERMIT;
10577 else if (strncmp (argv[1], "d", 1) == 0)
10578 direct = COMMUNITY_DENY;
10579 else
10580 {
10581 vty_out (vty, "%% Matching condition must be permit or deny%s",
10582 VTY_NEWLINE);
10583 return CMD_WARNING;
10584 }
10585
10586 /* Concat community string argument. */
10587 str = argv_concat (argv, argc, 2);
paul718e3742002-12-13 20:15:29 +000010588 }
paul718e3742002-12-13 20:15:29 +000010589
10590 /* Unset community list. */
10591 ret = extcommunity_list_unset (bgp_clist, argv[0], str, direct, style);
10592
10593 /* Free temporary community list string allocated by
10594 argv_concat(). */
hassofee6e4e2005-02-02 16:29:31 +000010595 if (str)
10596 XFREE (MTYPE_TMP, str);
paul718e3742002-12-13 20:15:29 +000010597
10598 if (ret < 0)
10599 {
10600 community_list_perror (vty, ret);
10601 return CMD_WARNING;
10602 }
10603
10604 return CMD_SUCCESS;
10605}
10606
10607/* "extcommunity-list" keyword help string. */
10608#define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
10609#define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
10610
10611DEFUN (ip_extcommunity_list_standard,
10612 ip_extcommunity_list_standard_cmd,
10613 "ip extcommunity-list <1-99> (deny|permit) .AA:NN",
10614 IP_STR
10615 EXTCOMMUNITY_LIST_STR
10616 "Extended Community list number (standard)\n"
10617 "Specify community to reject\n"
10618 "Specify community to accept\n"
10619 EXTCOMMUNITY_VAL_STR)
10620{
10621 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
10622}
10623
10624ALIAS (ip_extcommunity_list_standard,
10625 ip_extcommunity_list_standard2_cmd,
10626 "ip extcommunity-list <1-99> (deny|permit)",
10627 IP_STR
10628 EXTCOMMUNITY_LIST_STR
10629 "Extended Community list number (standard)\n"
10630 "Specify community to reject\n"
10631 "Specify community to accept\n")
10632
10633DEFUN (ip_extcommunity_list_expanded,
10634 ip_extcommunity_list_expanded_cmd,
hassofee6e4e2005-02-02 16:29:31 +000010635 "ip extcommunity-list <100-500> (deny|permit) .LINE",
paul718e3742002-12-13 20:15:29 +000010636 IP_STR
10637 EXTCOMMUNITY_LIST_STR
10638 "Extended Community list number (expanded)\n"
10639 "Specify community to reject\n"
10640 "Specify community to accept\n"
10641 "An ordered list as a regular-expression\n")
10642{
10643 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
10644}
10645
10646DEFUN (ip_extcommunity_list_name_standard,
10647 ip_extcommunity_list_name_standard_cmd,
10648 "ip extcommunity-list standard WORD (deny|permit) .AA:NN",
10649 IP_STR
10650 EXTCOMMUNITY_LIST_STR
10651 "Specify standard extcommunity-list\n"
10652 "Extended Community list name\n"
10653 "Specify community to reject\n"
10654 "Specify community to accept\n"
10655 EXTCOMMUNITY_VAL_STR)
10656{
10657 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
10658}
10659
10660ALIAS (ip_extcommunity_list_name_standard,
10661 ip_extcommunity_list_name_standard2_cmd,
10662 "ip extcommunity-list standard WORD (deny|permit)",
10663 IP_STR
10664 EXTCOMMUNITY_LIST_STR
10665 "Specify standard extcommunity-list\n"
10666 "Extended Community list name\n"
10667 "Specify community to reject\n"
10668 "Specify community to accept\n")
10669
10670DEFUN (ip_extcommunity_list_name_expanded,
10671 ip_extcommunity_list_name_expanded_cmd,
10672 "ip extcommunity-list expanded WORD (deny|permit) .LINE",
10673 IP_STR
10674 EXTCOMMUNITY_LIST_STR
10675 "Specify expanded extcommunity-list\n"
10676 "Extended Community list name\n"
10677 "Specify community to reject\n"
10678 "Specify community to accept\n"
10679 "An ordered list as a regular-expression\n")
10680{
10681 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
10682}
10683
hassofee6e4e2005-02-02 16:29:31 +000010684DEFUN (no_ip_extcommunity_list_standard_all,
10685 no_ip_extcommunity_list_standard_all_cmd,
10686 "no ip extcommunity-list <1-99>",
paul718e3742002-12-13 20:15:29 +000010687 NO_STR
10688 IP_STR
10689 EXTCOMMUNITY_LIST_STR
hassofee6e4e2005-02-02 16:29:31 +000010690 "Extended Community list number (standard)\n")
paul718e3742002-12-13 20:15:29 +000010691{
hassofee6e4e2005-02-02 16:29:31 +000010692 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
paul718e3742002-12-13 20:15:29 +000010693}
10694
hassofee6e4e2005-02-02 16:29:31 +000010695DEFUN (no_ip_extcommunity_list_expanded_all,
10696 no_ip_extcommunity_list_expanded_all_cmd,
10697 "no ip extcommunity-list <100-500>",
10698 NO_STR
10699 IP_STR
10700 EXTCOMMUNITY_LIST_STR
10701 "Extended Community list number (expanded)\n")
10702{
10703 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
10704}
10705
10706DEFUN (no_ip_extcommunity_list_name_standard_all,
10707 no_ip_extcommunity_list_name_standard_all_cmd,
10708 "no ip extcommunity-list standard WORD",
paul718e3742002-12-13 20:15:29 +000010709 NO_STR
10710 IP_STR
10711 EXTCOMMUNITY_LIST_STR
10712 "Specify standard extcommunity-list\n"
hassofee6e4e2005-02-02 16:29:31 +000010713 "Extended Community list name\n")
10714{
10715 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
10716}
10717
10718DEFUN (no_ip_extcommunity_list_name_expanded_all,
10719 no_ip_extcommunity_list_name_expanded_all_cmd,
10720 "no ip extcommunity-list expanded WORD",
10721 NO_STR
10722 IP_STR
10723 EXTCOMMUNITY_LIST_STR
paul718e3742002-12-13 20:15:29 +000010724 "Specify expanded extcommunity-list\n"
10725 "Extended Community list name\n")
10726{
hassofee6e4e2005-02-02 16:29:31 +000010727 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
paul718e3742002-12-13 20:15:29 +000010728}
10729
10730DEFUN (no_ip_extcommunity_list_standard,
10731 no_ip_extcommunity_list_standard_cmd,
10732 "no ip extcommunity-list <1-99> (deny|permit) .AA:NN",
10733 NO_STR
10734 IP_STR
10735 EXTCOMMUNITY_LIST_STR
10736 "Extended Community list number (standard)\n"
10737 "Specify community to reject\n"
10738 "Specify community to accept\n"
10739 EXTCOMMUNITY_VAL_STR)
10740{
10741 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
10742}
10743
10744DEFUN (no_ip_extcommunity_list_expanded,
10745 no_ip_extcommunity_list_expanded_cmd,
hassofee6e4e2005-02-02 16:29:31 +000010746 "no ip extcommunity-list <100-500> (deny|permit) .LINE",
paul718e3742002-12-13 20:15:29 +000010747 NO_STR
10748 IP_STR
10749 EXTCOMMUNITY_LIST_STR
10750 "Extended Community list number (expanded)\n"
10751 "Specify community to reject\n"
10752 "Specify community to accept\n"
10753 "An ordered list as a regular-expression\n")
10754{
10755 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
10756}
10757
10758DEFUN (no_ip_extcommunity_list_name_standard,
10759 no_ip_extcommunity_list_name_standard_cmd,
10760 "no ip extcommunity-list standard WORD (deny|permit) .AA:NN",
10761 NO_STR
10762 IP_STR
10763 EXTCOMMUNITY_LIST_STR
10764 "Specify standard extcommunity-list\n"
10765 "Extended Community list name\n"
10766 "Specify community to reject\n"
10767 "Specify community to accept\n"
10768 EXTCOMMUNITY_VAL_STR)
10769{
10770 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
10771}
10772
10773DEFUN (no_ip_extcommunity_list_name_expanded,
10774 no_ip_extcommunity_list_name_expanded_cmd,
10775 "no ip extcommunity-list expanded WORD (deny|permit) .LINE",
10776 NO_STR
10777 IP_STR
10778 EXTCOMMUNITY_LIST_STR
10779 "Specify expanded extcommunity-list\n"
10780 "Community list name\n"
10781 "Specify community to reject\n"
10782 "Specify community to accept\n"
10783 "An ordered list as a regular-expression\n")
10784{
10785 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
10786}
10787
paul94f2b392005-06-28 12:44:16 +000010788static void
paul718e3742002-12-13 20:15:29 +000010789extcommunity_list_show (struct vty *vty, struct community_list *list)
10790{
10791 struct community_entry *entry;
10792
10793 for (entry = list->head; entry; entry = entry->next)
10794 {
10795 if (entry == list->head)
10796 {
10797 if (all_digit (list->name))
10798 vty_out (vty, "Extended community %s list %s%s",
10799 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
10800 "standard" : "(expanded) access",
10801 list->name, VTY_NEWLINE);
10802 else
10803 vty_out (vty, "Named extended community %s list %s%s",
10804 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
10805 "standard" : "expanded",
10806 list->name, VTY_NEWLINE);
10807 }
10808 if (entry->any)
10809 vty_out (vty, " %s%s",
10810 community_direct_str (entry->direct), VTY_NEWLINE);
10811 else
10812 vty_out (vty, " %s %s%s",
10813 community_direct_str (entry->direct),
10814 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
10815 entry->u.ecom->str : entry->config,
10816 VTY_NEWLINE);
10817 }
10818}
10819
10820DEFUN (show_ip_extcommunity_list,
10821 show_ip_extcommunity_list_cmd,
10822 "show ip extcommunity-list",
10823 SHOW_STR
10824 IP_STR
10825 "List extended-community list\n")
10826{
10827 struct community_list *list;
10828 struct community_list_master *cm;
10829
hassofee6e4e2005-02-02 16:29:31 +000010830 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010831 if (! cm)
10832 return CMD_SUCCESS;
10833
10834 for (list = cm->num.head; list; list = list->next)
10835 extcommunity_list_show (vty, list);
10836
10837 for (list = cm->str.head; list; list = list->next)
10838 extcommunity_list_show (vty, list);
10839
10840 return CMD_SUCCESS;
10841}
10842
10843DEFUN (show_ip_extcommunity_list_arg,
10844 show_ip_extcommunity_list_arg_cmd,
hassofee6e4e2005-02-02 16:29:31 +000010845 "show ip extcommunity-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000010846 SHOW_STR
10847 IP_STR
10848 "List extended-community list\n"
10849 "Extcommunity-list number\n"
10850 "Extcommunity-list name\n")
10851{
10852 struct community_list *list;
10853
hassofee6e4e2005-02-02 16:29:31 +000010854 list = community_list_lookup (bgp_clist, argv[0], EXTCOMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010855 if (! list)
10856 {
Denis Ovsienkob7292942010-12-08 18:51:37 +030010857 vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000010858 return CMD_WARNING;
10859 }
10860
10861 extcommunity_list_show (vty, list);
10862
10863 return CMD_SUCCESS;
10864}
10865
10866/* Return configuration string of community-list entry. */
paulfd79ac92004-10-13 05:06:08 +000010867static const char *
paul718e3742002-12-13 20:15:29 +000010868community_list_config_str (struct community_entry *entry)
10869{
paulfd79ac92004-10-13 05:06:08 +000010870 const char *str;
paul718e3742002-12-13 20:15:29 +000010871
10872 if (entry->any)
10873 str = "";
10874 else
10875 {
10876 if (entry->style == COMMUNITY_LIST_STANDARD)
10877 str = community_str (entry->u.com);
10878 else
10879 str = entry->config;
10880 }
10881 return str;
10882}
10883
10884/* Display community-list and extcommunity-list configuration. */
paul94f2b392005-06-28 12:44:16 +000010885static int
paul718e3742002-12-13 20:15:29 +000010886community_list_config_write (struct vty *vty)
10887{
10888 struct community_list *list;
10889 struct community_entry *entry;
10890 struct community_list_master *cm;
10891 int write = 0;
10892
10893 /* Community-list. */
hassofee6e4e2005-02-02 16:29:31 +000010894 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010895
10896 for (list = cm->num.head; list; list = list->next)
10897 for (entry = list->head; entry; entry = entry->next)
10898 {
hassofee6e4e2005-02-02 16:29:31 +000010899 vty_out (vty, "ip community-list %s %s %s%s",
10900 list->name, community_direct_str (entry->direct),
10901 community_list_config_str (entry),
10902 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000010903 write++;
10904 }
10905 for (list = cm->str.head; list; list = list->next)
10906 for (entry = list->head; entry; entry = entry->next)
10907 {
10908 vty_out (vty, "ip community-list %s %s %s %s%s",
10909 entry->style == COMMUNITY_LIST_STANDARD
10910 ? "standard" : "expanded",
10911 list->name, community_direct_str (entry->direct),
10912 community_list_config_str (entry),
10913 VTY_NEWLINE);
10914 write++;
10915 }
10916
10917 /* Extcommunity-list. */
hassofee6e4e2005-02-02 16:29:31 +000010918 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010919
10920 for (list = cm->num.head; list; list = list->next)
10921 for (entry = list->head; entry; entry = entry->next)
10922 {
hassofee6e4e2005-02-02 16:29:31 +000010923 vty_out (vty, "ip extcommunity-list %s %s %s%s",
10924 list->name, community_direct_str (entry->direct),
10925 community_list_config_str (entry), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000010926 write++;
10927 }
10928 for (list = cm->str.head; list; list = list->next)
10929 for (entry = list->head; entry; entry = entry->next)
10930 {
10931 vty_out (vty, "ip extcommunity-list %s %s %s %s%s",
10932 entry->style == EXTCOMMUNITY_LIST_STANDARD
10933 ? "standard" : "expanded",
10934 list->name, community_direct_str (entry->direct),
10935 community_list_config_str (entry), VTY_NEWLINE);
10936 write++;
10937 }
10938 return write;
10939}
10940
Stephen Hemminger7fc626d2008-12-01 11:10:34 -080010941static struct cmd_node community_list_node =
paul718e3742002-12-13 20:15:29 +000010942{
10943 COMMUNITY_LIST_NODE,
10944 "",
10945 1 /* Export to vtysh. */
10946};
10947
paul94f2b392005-06-28 12:44:16 +000010948static void
10949community_list_vty (void)
paul718e3742002-12-13 20:15:29 +000010950{
10951 install_node (&community_list_node, community_list_config_write);
10952
10953 /* Community-list. */
paul718e3742002-12-13 20:15:29 +000010954 install_element (CONFIG_NODE, &ip_community_list_standard_cmd);
10955 install_element (CONFIG_NODE, &ip_community_list_standard2_cmd);
10956 install_element (CONFIG_NODE, &ip_community_list_expanded_cmd);
10957 install_element (CONFIG_NODE, &ip_community_list_name_standard_cmd);
10958 install_element (CONFIG_NODE, &ip_community_list_name_standard2_cmd);
10959 install_element (CONFIG_NODE, &ip_community_list_name_expanded_cmd);
hassofee6e4e2005-02-02 16:29:31 +000010960 install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd);
10961 install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd);
10962 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_all_cmd);
10963 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_all_cmd);
paul718e3742002-12-13 20:15:29 +000010964 install_element (CONFIG_NODE, &no_ip_community_list_standard_cmd);
10965 install_element (CONFIG_NODE, &no_ip_community_list_expanded_cmd);
10966 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_cmd);
10967 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_cmd);
10968 install_element (VIEW_NODE, &show_ip_community_list_cmd);
10969 install_element (VIEW_NODE, &show_ip_community_list_arg_cmd);
10970 install_element (ENABLE_NODE, &show_ip_community_list_cmd);
10971 install_element (ENABLE_NODE, &show_ip_community_list_arg_cmd);
10972
10973 /* Extcommunity-list. */
10974 install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd);
10975 install_element (CONFIG_NODE, &ip_extcommunity_list_standard2_cmd);
10976 install_element (CONFIG_NODE, &ip_extcommunity_list_expanded_cmd);
10977 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard_cmd);
10978 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard2_cmd);
10979 install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd);
hassofee6e4e2005-02-02 16:29:31 +000010980 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd);
10981 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd);
10982 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_all_cmd);
10983 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_all_cmd);
paul718e3742002-12-13 20:15:29 +000010984 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_cmd);
10985 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_cmd);
10986 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_cmd);
10987 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_cmd);
10988 install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd);
10989 install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd);
10990 install_element (ENABLE_NODE, &show_ip_extcommunity_list_cmd);
10991 install_element (ENABLE_NODE, &show_ip_extcommunity_list_arg_cmd);
10992}