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