blob: 9cb30182af17564cf86e1ff46f05b17abc3c9699 [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;
paul718e3742002-12-13 20:15:29 +0000216 }
217 if (str)
218 {
219 vty_out (vty, "%% %s%s", str, VTY_NEWLINE);
220 return CMD_WARNING;
221 }
222 return CMD_SUCCESS;
223}
224
225/* BGP global configuration. */
226
227DEFUN (bgp_multiple_instance_func,
228 bgp_multiple_instance_cmd,
229 "bgp multiple-instance",
230 BGP_STR
231 "Enable bgp multiple instance\n")
232{
233 bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE);
234 return CMD_SUCCESS;
235}
236
237DEFUN (no_bgp_multiple_instance,
238 no_bgp_multiple_instance_cmd,
239 "no bgp multiple-instance",
240 NO_STR
241 BGP_STR
242 "BGP multiple instance\n")
243{
244 int ret;
245
246 ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE);
247 if (ret < 0)
248 {
249 vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE);
250 return CMD_WARNING;
251 }
252 return CMD_SUCCESS;
253}
254
255DEFUN (bgp_config_type,
256 bgp_config_type_cmd,
257 "bgp config-type (cisco|zebra)",
258 BGP_STR
259 "Configuration type\n"
260 "cisco\n"
261 "zebra\n")
262{
263 if (strncmp (argv[0], "c", 1) == 0)
264 bgp_option_set (BGP_OPT_CONFIG_CISCO);
265 else
266 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
267
268 return CMD_SUCCESS;
269}
270
271DEFUN (no_bgp_config_type,
272 no_bgp_config_type_cmd,
273 "no bgp config-type",
274 NO_STR
275 BGP_STR
276 "Display configuration type\n")
277{
278 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
279 return CMD_SUCCESS;
280}
281
282DEFUN (no_synchronization,
283 no_synchronization_cmd,
284 "no synchronization",
285 NO_STR
286 "Perform IGP synchronization\n")
287{
288 return CMD_SUCCESS;
289}
290
291DEFUN (no_auto_summary,
292 no_auto_summary_cmd,
293 "no auto-summary",
294 NO_STR
295 "Enable automatic network number summarization\n")
296{
297 return CMD_SUCCESS;
298}
hasso3d515fd2005-02-01 21:30:04 +0000299
300DEFUN_DEPRECATED (neighbor_version,
301 neighbor_version_cmd,
302 NEIGHBOR_CMD "version (4|4-)",
303 NEIGHBOR_STR
304 NEIGHBOR_ADDR_STR
305 "Set the BGP version to match a neighbor\n"
306 "Neighbor's BGP version\n")
307{
308 return CMD_SUCCESS;
309}
paul718e3742002-12-13 20:15:29 +0000310
311/* "router bgp" commands. */
312DEFUN (router_bgp,
313 router_bgp_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000314 "router bgp " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +0000315 ROUTER_STR
316 BGP_STR
317 AS_STR)
318{
319 int ret;
320 as_t as;
321 struct bgp *bgp;
paulfd79ac92004-10-13 05:06:08 +0000322 const char *name = NULL;
paul718e3742002-12-13 20:15:29 +0000323
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000324 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
paul718e3742002-12-13 20:15:29 +0000325
326 if (argc == 2)
327 name = argv[1];
328
329 ret = bgp_get (&bgp, &as, name);
330 switch (ret)
331 {
332 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET:
333 vty_out (vty, "Please specify 'bgp multiple-instance' first%s",
334 VTY_NEWLINE);
335 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +0000336 case BGP_ERR_AS_MISMATCH:
Denis Ovsienkoaea339f2009-04-30 17:16:22 +0400337 vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +0000338 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +0000339 case BGP_ERR_INSTANCE_MISMATCH:
340 vty_out (vty, "BGP view name and AS number mismatch%s", VTY_NEWLINE);
Denis Ovsienkoaea339f2009-04-30 17:16:22 +0400341 vty_out (vty, "BGP instance is already running; AS is %u%s",
paul718e3742002-12-13 20:15:29 +0000342 as, VTY_NEWLINE);
343 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +0000344 }
345
346 vty->node = BGP_NODE;
347 vty->index = bgp;
348
349 return CMD_SUCCESS;
350}
351
352ALIAS (router_bgp,
353 router_bgp_view_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000354 "router bgp " CMD_AS_RANGE " view WORD",
paul718e3742002-12-13 20:15:29 +0000355 ROUTER_STR
356 BGP_STR
357 AS_STR
358 "BGP view\n"
359 "view name\n")
360
361/* "no router bgp" commands. */
362DEFUN (no_router_bgp,
363 no_router_bgp_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000364 "no router bgp " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +0000365 NO_STR
366 ROUTER_STR
367 BGP_STR
368 AS_STR)
369{
370 as_t as;
371 struct bgp *bgp;
paulfd79ac92004-10-13 05:06:08 +0000372 const char *name = NULL;
paul718e3742002-12-13 20:15:29 +0000373
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000374 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
paul718e3742002-12-13 20:15:29 +0000375
376 if (argc == 2)
377 name = argv[1];
378
379 /* Lookup bgp structure. */
380 bgp = bgp_lookup (as, name);
381 if (! bgp)
382 {
383 vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE);
384 return CMD_WARNING;
385 }
386
387 bgp_delete (bgp);
388
389 return CMD_SUCCESS;
390}
391
392ALIAS (no_router_bgp,
393 no_router_bgp_view_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000394 "no router bgp " CMD_AS_RANGE " view WORD",
paul718e3742002-12-13 20:15:29 +0000395 NO_STR
396 ROUTER_STR
397 BGP_STR
398 AS_STR
399 "BGP view\n"
400 "view name\n")
401
402/* BGP router-id. */
403
404DEFUN (bgp_router_id,
405 bgp_router_id_cmd,
406 "bgp router-id A.B.C.D",
407 BGP_STR
408 "Override configured router identifier\n"
409 "Manually configured router identifier\n")
410{
411 int ret;
412 struct in_addr id;
413 struct bgp *bgp;
414
415 bgp = vty->index;
416
417 ret = inet_aton (argv[0], &id);
418 if (! ret)
419 {
420 vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE);
421 return CMD_WARNING;
422 }
423
hasso18a6dce2004-10-03 18:18:34 +0000424 bgp->router_id_static = id;
paul718e3742002-12-13 20:15:29 +0000425 bgp_router_id_set (bgp, &id);
426
427 return CMD_SUCCESS;
428}
429
430DEFUN (no_bgp_router_id,
431 no_bgp_router_id_cmd,
432 "no bgp router-id",
433 NO_STR
434 BGP_STR
435 "Override configured router identifier\n")
436{
437 int ret;
438 struct in_addr id;
439 struct bgp *bgp;
440
441 bgp = vty->index;
442
443 if (argc == 1)
444 {
445 ret = inet_aton (argv[0], &id);
446 if (! ret)
447 {
448 vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE);
449 return CMD_WARNING;
450 }
451
hasso18a6dce2004-10-03 18:18:34 +0000452 if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id))
paul718e3742002-12-13 20:15:29 +0000453 {
454 vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE);
455 return CMD_WARNING;
456 }
457 }
458
hasso18a6dce2004-10-03 18:18:34 +0000459 bgp->router_id_static.s_addr = 0;
460 bgp_router_id_set (bgp, &router_id_zebra);
paul718e3742002-12-13 20:15:29 +0000461
462 return CMD_SUCCESS;
463}
464
465ALIAS (no_bgp_router_id,
466 no_bgp_router_id_val_cmd,
467 "no bgp router-id A.B.C.D",
468 NO_STR
469 BGP_STR
470 "Override configured router identifier\n"
471 "Manually configured router identifier\n")
472
473/* BGP Cluster ID. */
474
475DEFUN (bgp_cluster_id,
476 bgp_cluster_id_cmd,
477 "bgp cluster-id A.B.C.D",
478 BGP_STR
479 "Configure Route-Reflector Cluster-id\n"
480 "Route-Reflector Cluster-id in IP address format\n")
481{
482 int ret;
483 struct bgp *bgp;
484 struct in_addr cluster;
485
486 bgp = vty->index;
487
488 ret = inet_aton (argv[0], &cluster);
489 if (! ret)
490 {
491 vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
492 return CMD_WARNING;
493 }
494
495 bgp_cluster_id_set (bgp, &cluster);
496
497 return CMD_SUCCESS;
498}
499
500ALIAS (bgp_cluster_id,
501 bgp_cluster_id32_cmd,
502 "bgp cluster-id <1-4294967295>",
503 BGP_STR
504 "Configure Route-Reflector Cluster-id\n"
505 "Route-Reflector Cluster-id as 32 bit quantity\n")
506
507DEFUN (no_bgp_cluster_id,
508 no_bgp_cluster_id_cmd,
509 "no bgp cluster-id",
510 NO_STR
511 BGP_STR
512 "Configure Route-Reflector Cluster-id\n")
513{
514 int ret;
515 struct bgp *bgp;
516 struct in_addr cluster;
517
518 bgp = vty->index;
519
520 if (argc == 1)
521 {
522 ret = inet_aton (argv[0], &cluster);
523 if (! ret)
524 {
525 vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
526 return CMD_WARNING;
527 }
528 }
529
530 bgp_cluster_id_unset (bgp);
531
532 return CMD_SUCCESS;
533}
534
535ALIAS (no_bgp_cluster_id,
536 no_bgp_cluster_id_arg_cmd,
537 "no bgp cluster-id A.B.C.D",
538 NO_STR
539 BGP_STR
540 "Configure Route-Reflector Cluster-id\n"
541 "Route-Reflector Cluster-id in IP address format\n")
542
543DEFUN (bgp_confederation_identifier,
544 bgp_confederation_identifier_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000545 "bgp confederation identifier " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +0000546 "BGP specific commands\n"
547 "AS confederation parameters\n"
548 "AS number\n"
549 "Set routing domain confederation AS\n")
550{
551 struct bgp *bgp;
552 as_t as;
553
554 bgp = vty->index;
555
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000556 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
paul718e3742002-12-13 20:15:29 +0000557
558 bgp_confederation_id_set (bgp, as);
559
560 return CMD_SUCCESS;
561}
562
563DEFUN (no_bgp_confederation_identifier,
564 no_bgp_confederation_identifier_cmd,
565 "no bgp confederation identifier",
566 NO_STR
567 "BGP specific commands\n"
568 "AS confederation parameters\n"
569 "AS number\n")
570{
571 struct bgp *bgp;
572 as_t as;
573
574 bgp = vty->index;
575
576 if (argc == 1)
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000577 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
paul718e3742002-12-13 20:15:29 +0000578
579 bgp_confederation_id_unset (bgp);
580
581 return CMD_SUCCESS;
582}
583
584ALIAS (no_bgp_confederation_identifier,
585 no_bgp_confederation_identifier_arg_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000586 "no bgp confederation identifier " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +0000587 NO_STR
588 "BGP specific commands\n"
589 "AS confederation parameters\n"
590 "AS number\n"
591 "Set routing domain confederation AS\n")
592
593DEFUN (bgp_confederation_peers,
594 bgp_confederation_peers_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000595 "bgp confederation peers ." CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +0000596 "BGP specific commands\n"
597 "AS confederation parameters\n"
598 "Peer ASs in BGP confederation\n"
599 AS_STR)
600{
601 struct bgp *bgp;
602 as_t as;
603 int i;
604
605 bgp = vty->index;
606
607 for (i = 0; i < argc; i++)
608 {
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000609 VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX);
paul718e3742002-12-13 20:15:29 +0000610
611 if (bgp->as == as)
612 {
613 vty_out (vty, "%% Local member-AS not allowed in confed peer list%s",
614 VTY_NEWLINE);
615 continue;
616 }
617
618 bgp_confederation_peers_add (bgp, as);
619 }
620 return CMD_SUCCESS;
621}
622
623DEFUN (no_bgp_confederation_peers,
624 no_bgp_confederation_peers_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000625 "no bgp confederation peers ." CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +0000626 NO_STR
627 "BGP specific commands\n"
628 "AS confederation parameters\n"
629 "Peer ASs in BGP confederation\n"
630 AS_STR)
631{
632 struct bgp *bgp;
633 as_t as;
634 int i;
635
636 bgp = vty->index;
637
638 for (i = 0; i < argc; i++)
639 {
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000640 VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX);
641
paul718e3742002-12-13 20:15:29 +0000642 bgp_confederation_peers_remove (bgp, as);
643 }
644 return CMD_SUCCESS;
645}
646
647/* BGP timers. */
648
649DEFUN (bgp_timers,
650 bgp_timers_cmd,
651 "timers bgp <0-65535> <0-65535>",
652 "Adjust routing timers\n"
653 "BGP timers\n"
654 "Keepalive interval\n"
655 "Holdtime\n")
656{
657 struct bgp *bgp;
658 unsigned long keepalive = 0;
659 unsigned long holdtime = 0;
660
661 bgp = vty->index;
662
663 VTY_GET_INTEGER ("keepalive", keepalive, argv[0]);
664 VTY_GET_INTEGER ("holdtime", holdtime, argv[1]);
665
666 /* Holdtime value check. */
667 if (holdtime < 3 && holdtime != 0)
668 {
669 vty_out (vty, "%% hold time value must be either 0 or greater than 3%s",
670 VTY_NEWLINE);
671 return CMD_WARNING;
672 }
673
674 bgp_timers_set (bgp, keepalive, holdtime);
675
676 return CMD_SUCCESS;
677}
678
679DEFUN (no_bgp_timers,
680 no_bgp_timers_cmd,
681 "no timers bgp",
682 NO_STR
683 "Adjust routing timers\n"
684 "BGP timers\n")
685{
686 struct bgp *bgp;
687
688 bgp = vty->index;
689 bgp_timers_unset (bgp);
690
691 return CMD_SUCCESS;
692}
693
694ALIAS (no_bgp_timers,
695 no_bgp_timers_arg_cmd,
696 "no timers bgp <0-65535> <0-65535>",
697 NO_STR
698 "Adjust routing timers\n"
699 "BGP timers\n"
700 "Keepalive interval\n"
701 "Holdtime\n")
702
703DEFUN (bgp_client_to_client_reflection,
704 bgp_client_to_client_reflection_cmd,
705 "bgp client-to-client reflection",
706 "BGP specific commands\n"
707 "Configure client to client route reflection\n"
708 "reflection of routes allowed\n")
709{
710 struct bgp *bgp;
711
712 bgp = vty->index;
713 bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
714 return CMD_SUCCESS;
715}
716
717DEFUN (no_bgp_client_to_client_reflection,
718 no_bgp_client_to_client_reflection_cmd,
719 "no bgp client-to-client reflection",
720 NO_STR
721 "BGP specific commands\n"
722 "Configure client to client route reflection\n"
723 "reflection of routes allowed\n")
724{
725 struct bgp *bgp;
726
727 bgp = vty->index;
728 bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
729 return CMD_SUCCESS;
730}
731
732/* "bgp always-compare-med" configuration. */
733DEFUN (bgp_always_compare_med,
734 bgp_always_compare_med_cmd,
735 "bgp always-compare-med",
736 "BGP specific commands\n"
737 "Allow comparing MED from different neighbors\n")
738{
739 struct bgp *bgp;
740
741 bgp = vty->index;
742 bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
743 return CMD_SUCCESS;
744}
745
746DEFUN (no_bgp_always_compare_med,
747 no_bgp_always_compare_med_cmd,
748 "no bgp always-compare-med",
749 NO_STR
750 "BGP specific commands\n"
751 "Allow comparing MED from different neighbors\n")
752{
753 struct bgp *bgp;
754
755 bgp = vty->index;
756 bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
757 return CMD_SUCCESS;
758}
759
760/* "bgp deterministic-med" configuration. */
761DEFUN (bgp_deterministic_med,
762 bgp_deterministic_med_cmd,
763 "bgp deterministic-med",
764 "BGP specific commands\n"
765 "Pick the best-MED path among paths advertised from the neighboring AS\n")
766{
767 struct bgp *bgp;
768
769 bgp = vty->index;
770 bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED);
771 return CMD_SUCCESS;
772}
773
774DEFUN (no_bgp_deterministic_med,
775 no_bgp_deterministic_med_cmd,
776 "no bgp deterministic-med",
777 NO_STR
778 "BGP specific commands\n"
779 "Pick the best-MED path among paths advertised from the neighboring AS\n")
780{
781 struct bgp *bgp;
782
783 bgp = vty->index;
784 bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED);
785 return CMD_SUCCESS;
786}
hasso538621f2004-05-21 09:31:30 +0000787
788/* "bgp graceful-restart" configuration. */
789DEFUN (bgp_graceful_restart,
790 bgp_graceful_restart_cmd,
791 "bgp graceful-restart",
792 "BGP specific commands\n"
793 "Graceful restart capability parameters\n")
794{
795 struct bgp *bgp;
796
797 bgp = vty->index;
798 bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART);
799 return CMD_SUCCESS;
800}
801
802DEFUN (no_bgp_graceful_restart,
803 no_bgp_graceful_restart_cmd,
804 "no bgp graceful-restart",
805 NO_STR
806 "BGP specific commands\n"
807 "Graceful restart capability parameters\n")
808{
809 struct bgp *bgp;
810
811 bgp = vty->index;
812 bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART);
813 return CMD_SUCCESS;
814}
815
hasso93406d82005-02-02 14:40:33 +0000816DEFUN (bgp_graceful_restart_stalepath_time,
817 bgp_graceful_restart_stalepath_time_cmd,
818 "bgp graceful-restart stalepath-time <1-3600>",
819 "BGP specific commands\n"
820 "Graceful restart capability parameters\n"
821 "Set the max time to hold onto restarting peer's stale paths\n"
822 "Delay value (seconds)\n")
823{
824 struct bgp *bgp;
825 u_int32_t stalepath;
826
827 bgp = vty->index;
828 if (! bgp)
829 return CMD_WARNING;
830
831 VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[0], 1, 3600);
832 bgp->stalepath_time = stalepath;
833 return CMD_SUCCESS;
834}
835
836DEFUN (no_bgp_graceful_restart_stalepath_time,
837 no_bgp_graceful_restart_stalepath_time_cmd,
838 "no bgp graceful-restart stalepath-time",
839 NO_STR
840 "BGP specific commands\n"
841 "Graceful restart capability parameters\n"
842 "Set the max time to hold onto restarting peer's stale paths\n")
843{
844 struct bgp *bgp;
845
846 bgp = vty->index;
847 if (! bgp)
848 return CMD_WARNING;
849
850 bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME;
851 return CMD_SUCCESS;
852}
853
854ALIAS (no_bgp_graceful_restart_stalepath_time,
855 no_bgp_graceful_restart_stalepath_time_val_cmd,
856 "no bgp graceful-restart stalepath-time <1-3600>",
857 NO_STR
858 "BGP specific commands\n"
859 "Graceful restart capability parameters\n"
860 "Set the max time to hold onto restarting peer's stale paths\n"
861 "Delay value (seconds)\n")
862
paul718e3742002-12-13 20:15:29 +0000863/* "bgp fast-external-failover" configuration. */
864DEFUN (bgp_fast_external_failover,
865 bgp_fast_external_failover_cmd,
866 "bgp fast-external-failover",
867 BGP_STR
868 "Immediately reset session if a link to a directly connected external peer goes down\n")
869{
870 struct bgp *bgp;
871
872 bgp = vty->index;
873 bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
874 return CMD_SUCCESS;
875}
876
877DEFUN (no_bgp_fast_external_failover,
878 no_bgp_fast_external_failover_cmd,
879 "no bgp fast-external-failover",
880 NO_STR
881 BGP_STR
882 "Immediately reset session if a link to a directly connected external peer goes down\n")
883{
884 struct bgp *bgp;
885
886 bgp = vty->index;
887 bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
888 return CMD_SUCCESS;
889}
890
891/* "bgp enforce-first-as" configuration. */
892DEFUN (bgp_enforce_first_as,
893 bgp_enforce_first_as_cmd,
894 "bgp enforce-first-as",
895 BGP_STR
896 "Enforce the first AS for EBGP routes\n")
897{
898 struct bgp *bgp;
899
900 bgp = vty->index;
901 bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
902 return CMD_SUCCESS;
903}
904
905DEFUN (no_bgp_enforce_first_as,
906 no_bgp_enforce_first_as_cmd,
907 "no bgp enforce-first-as",
908 NO_STR
909 BGP_STR
910 "Enforce the first AS for EBGP routes\n")
911{
912 struct bgp *bgp;
913
914 bgp = vty->index;
915 bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
916 return CMD_SUCCESS;
917}
918
919/* "bgp bestpath compare-routerid" configuration. */
920DEFUN (bgp_bestpath_compare_router_id,
921 bgp_bestpath_compare_router_id_cmd,
922 "bgp bestpath compare-routerid",
923 "BGP specific commands\n"
924 "Change the default bestpath selection\n"
925 "Compare router-id for identical EBGP paths\n")
926{
927 struct bgp *bgp;
928
929 bgp = vty->index;
930 bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
931 return CMD_SUCCESS;
932}
933
934DEFUN (no_bgp_bestpath_compare_router_id,
935 no_bgp_bestpath_compare_router_id_cmd,
936 "no bgp bestpath compare-routerid",
937 NO_STR
938 "BGP specific commands\n"
939 "Change the default bestpath selection\n"
940 "Compare router-id for identical EBGP paths\n")
941{
942 struct bgp *bgp;
943
944 bgp = vty->index;
945 bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
946 return CMD_SUCCESS;
947}
948
949/* "bgp bestpath as-path ignore" configuration. */
950DEFUN (bgp_bestpath_aspath_ignore,
951 bgp_bestpath_aspath_ignore_cmd,
952 "bgp bestpath as-path ignore",
953 "BGP specific commands\n"
954 "Change the default bestpath selection\n"
955 "AS-path attribute\n"
956 "Ignore as-path length in selecting a route\n")
957{
958 struct bgp *bgp;
959
960 bgp = vty->index;
961 bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE);
962 return CMD_SUCCESS;
963}
964
965DEFUN (no_bgp_bestpath_aspath_ignore,
966 no_bgp_bestpath_aspath_ignore_cmd,
967 "no bgp bestpath as-path ignore",
968 NO_STR
969 "BGP specific commands\n"
970 "Change the default bestpath selection\n"
971 "AS-path attribute\n"
972 "Ignore as-path length in selecting a route\n")
973{
974 struct bgp *bgp;
975
976 bgp = vty->index;
977 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE);
978 return CMD_SUCCESS;
979}
980
hasso68118452005-04-08 15:40:36 +0000981/* "bgp bestpath as-path confed" configuration. */
982DEFUN (bgp_bestpath_aspath_confed,
983 bgp_bestpath_aspath_confed_cmd,
984 "bgp bestpath as-path confed",
985 "BGP specific commands\n"
986 "Change the default bestpath selection\n"
987 "AS-path attribute\n"
988 "Compare path lengths including confederation sets & sequences in selecting a route\n")
989{
990 struct bgp *bgp;
991
992 bgp = vty->index;
993 bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED);
994 return CMD_SUCCESS;
995}
996
997DEFUN (no_bgp_bestpath_aspath_confed,
998 no_bgp_bestpath_aspath_confed_cmd,
999 "no bgp bestpath as-path confed",
1000 NO_STR
1001 "BGP specific commands\n"
1002 "Change the default bestpath selection\n"
1003 "AS-path attribute\n"
1004 "Compare path lengths including confederation sets & sequences in selecting a route\n")
1005{
1006 struct bgp *bgp;
1007
1008 bgp = vty->index;
1009 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED);
1010 return CMD_SUCCESS;
1011}
1012
paul848973c2003-08-13 00:32:49 +00001013/* "bgp log-neighbor-changes" configuration. */
1014DEFUN (bgp_log_neighbor_changes,
1015 bgp_log_neighbor_changes_cmd,
1016 "bgp log-neighbor-changes",
1017 "BGP specific commands\n"
1018 "Log neighbor up/down and reset reason\n")
1019{
1020 struct bgp *bgp;
1021
1022 bgp = vty->index;
1023 bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
1024 return CMD_SUCCESS;
1025}
1026
1027DEFUN (no_bgp_log_neighbor_changes,
1028 no_bgp_log_neighbor_changes_cmd,
1029 "no bgp log-neighbor-changes",
1030 NO_STR
1031 "BGP specific commands\n"
1032 "Log neighbor up/down and reset reason\n")
1033{
1034 struct bgp *bgp;
1035
1036 bgp = vty->index;
1037 bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
1038 return CMD_SUCCESS;
1039}
1040
paul718e3742002-12-13 20:15:29 +00001041/* "bgp bestpath med" configuration. */
1042DEFUN (bgp_bestpath_med,
1043 bgp_bestpath_med_cmd,
1044 "bgp bestpath med (confed|missing-as-worst)",
1045 "BGP specific commands\n"
1046 "Change the default bestpath selection\n"
1047 "MED attribute\n"
1048 "Compare MED among confederation paths\n"
1049 "Treat missing MED as the least preferred one\n")
1050{
1051 struct bgp *bgp;
1052
1053 bgp = vty->index;
1054
1055 if (strncmp (argv[0], "confed", 1) == 0)
1056 bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
1057 else
1058 bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1059
1060 return CMD_SUCCESS;
1061}
1062
1063DEFUN (bgp_bestpath_med2,
1064 bgp_bestpath_med2_cmd,
1065 "bgp bestpath med confed missing-as-worst",
1066 "BGP specific commands\n"
1067 "Change the default bestpath selection\n"
1068 "MED attribute\n"
1069 "Compare MED among confederation paths\n"
1070 "Treat missing MED as the least preferred one\n")
1071{
1072 struct bgp *bgp;
1073
1074 bgp = vty->index;
1075 bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
1076 bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1077 return CMD_SUCCESS;
1078}
1079
1080ALIAS (bgp_bestpath_med2,
1081 bgp_bestpath_med3_cmd,
1082 "bgp bestpath med missing-as-worst confed",
1083 "BGP specific commands\n"
1084 "Change the default bestpath selection\n"
1085 "MED attribute\n"
1086 "Treat missing MED as the least preferred one\n"
1087 "Compare MED among confederation paths\n")
1088
1089DEFUN (no_bgp_bestpath_med,
1090 no_bgp_bestpath_med_cmd,
1091 "no bgp bestpath med (confed|missing-as-worst)",
1092 NO_STR
1093 "BGP specific commands\n"
1094 "Change the default bestpath selection\n"
1095 "MED attribute\n"
1096 "Compare MED among confederation paths\n"
1097 "Treat missing MED as the least preferred one\n")
1098{
1099 struct bgp *bgp;
1100
1101 bgp = vty->index;
1102
1103 if (strncmp (argv[0], "confed", 1) == 0)
1104 bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
1105 else
1106 bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1107
1108 return CMD_SUCCESS;
1109}
1110
1111DEFUN (no_bgp_bestpath_med2,
1112 no_bgp_bestpath_med2_cmd,
1113 "no bgp bestpath med confed missing-as-worst",
1114 NO_STR
1115 "BGP specific commands\n"
1116 "Change the default bestpath selection\n"
1117 "MED attribute\n"
1118 "Compare MED among confederation paths\n"
1119 "Treat missing MED as the least preferred one\n")
1120{
1121 struct bgp *bgp;
1122
1123 bgp = vty->index;
1124 bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
1125 bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1126 return CMD_SUCCESS;
1127}
1128
1129ALIAS (no_bgp_bestpath_med2,
1130 no_bgp_bestpath_med3_cmd,
1131 "no bgp bestpath med missing-as-worst confed",
1132 NO_STR
1133 "BGP specific commands\n"
1134 "Change the default bestpath selection\n"
1135 "MED attribute\n"
1136 "Treat missing MED as the least preferred one\n"
1137 "Compare MED among confederation paths\n")
1138
1139/* "no bgp default ipv4-unicast". */
1140DEFUN (no_bgp_default_ipv4_unicast,
1141 no_bgp_default_ipv4_unicast_cmd,
1142 "no bgp default ipv4-unicast",
1143 NO_STR
1144 "BGP specific commands\n"
1145 "Configure BGP defaults\n"
1146 "Activate ipv4-unicast for a peer by default\n")
1147{
1148 struct bgp *bgp;
1149
1150 bgp = vty->index;
1151 bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
1152 return CMD_SUCCESS;
1153}
1154
1155DEFUN (bgp_default_ipv4_unicast,
1156 bgp_default_ipv4_unicast_cmd,
1157 "bgp default ipv4-unicast",
1158 "BGP specific commands\n"
1159 "Configure BGP defaults\n"
1160 "Activate ipv4-unicast for a peer by default\n")
1161{
1162 struct bgp *bgp;
1163
1164 bgp = vty->index;
1165 bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
1166 return CMD_SUCCESS;
1167}
1168
1169/* "bgp import-check" configuration. */
1170DEFUN (bgp_network_import_check,
1171 bgp_network_import_check_cmd,
1172 "bgp network import-check",
1173 "BGP specific commands\n"
1174 "BGP network command\n"
1175 "Check BGP network route exists in IGP\n")
1176{
1177 struct bgp *bgp;
1178
1179 bgp = vty->index;
1180 bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK);
1181 return CMD_SUCCESS;
1182}
1183
1184DEFUN (no_bgp_network_import_check,
1185 no_bgp_network_import_check_cmd,
1186 "no bgp network import-check",
1187 NO_STR
1188 "BGP specific commands\n"
1189 "BGP network command\n"
1190 "Check BGP network route exists in IGP\n")
1191{
1192 struct bgp *bgp;
1193
1194 bgp = vty->index;
1195 bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK);
1196 return CMD_SUCCESS;
1197}
1198
1199DEFUN (bgp_default_local_preference,
1200 bgp_default_local_preference_cmd,
1201 "bgp default local-preference <0-4294967295>",
1202 "BGP specific commands\n"
1203 "Configure BGP defaults\n"
1204 "local preference (higher=more preferred)\n"
1205 "Configure default local preference value\n")
1206{
1207 struct bgp *bgp;
1208 u_int32_t local_pref;
1209
1210 bgp = vty->index;
1211
1212 VTY_GET_INTEGER ("local preference", local_pref, argv[0]);
1213
1214 bgp_default_local_preference_set (bgp, local_pref);
1215
1216 return CMD_SUCCESS;
1217}
1218
1219DEFUN (no_bgp_default_local_preference,
1220 no_bgp_default_local_preference_cmd,
1221 "no bgp default local-preference",
1222 NO_STR
1223 "BGP specific commands\n"
1224 "Configure BGP defaults\n"
1225 "local preference (higher=more preferred)\n")
1226{
1227 struct bgp *bgp;
1228
1229 bgp = vty->index;
1230 bgp_default_local_preference_unset (bgp);
1231 return CMD_SUCCESS;
1232}
1233
1234ALIAS (no_bgp_default_local_preference,
1235 no_bgp_default_local_preference_val_cmd,
1236 "no bgp default local-preference <0-4294967295>",
1237 NO_STR
1238 "BGP specific commands\n"
1239 "Configure BGP defaults\n"
1240 "local preference (higher=more preferred)\n"
1241 "Configure default local preference value\n")
1242
1243static int
paulfd79ac92004-10-13 05:06:08 +00001244peer_remote_as_vty (struct vty *vty, const char *peer_str,
1245 const char *as_str, afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00001246{
1247 int ret;
1248 struct bgp *bgp;
1249 as_t as;
1250 union sockunion su;
1251
1252 bgp = vty->index;
1253
1254 /* Get AS number. */
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00001255 VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX);
paul718e3742002-12-13 20:15:29 +00001256
1257 /* If peer is peer group, call proper function. */
1258 ret = str2sockunion (peer_str, &su);
1259 if (ret < 0)
1260 {
1261 ret = peer_group_remote_as (bgp, peer_str, &as);
1262 if (ret < 0)
1263 {
1264 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1265 return CMD_WARNING;
1266 }
1267 return CMD_SUCCESS;
1268 }
1269
1270 if (peer_address_self_check (&su))
1271 {
1272 vty_out (vty, "%% Can not configure the local system as neighbor%s",
1273 VTY_NEWLINE);
1274 return CMD_WARNING;
1275 }
1276
1277 ret = peer_remote_as (bgp, &su, &as, afi, safi);
1278
1279 /* This peer belongs to peer group. */
1280 switch (ret)
1281 {
1282 case BGP_ERR_PEER_GROUP_MEMBER:
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04001283 vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001284 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +00001285 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT:
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04001286 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 +00001287 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +00001288 }
1289 return bgp_vty_return (vty, ret);
1290}
1291
1292DEFUN (neighbor_remote_as,
1293 neighbor_remote_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001294 NEIGHBOR_CMD2 "remote-as " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00001295 NEIGHBOR_STR
1296 NEIGHBOR_ADDR_STR2
1297 "Specify a BGP neighbor\n"
1298 AS_STR)
1299{
1300 return peer_remote_as_vty (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST);
1301}
1302
1303DEFUN (neighbor_peer_group,
1304 neighbor_peer_group_cmd,
1305 "neighbor WORD peer-group",
1306 NEIGHBOR_STR
1307 "Neighbor tag\n"
1308 "Configure peer-group\n")
1309{
1310 struct bgp *bgp;
1311 struct peer_group *group;
1312
1313 bgp = vty->index;
1314
1315 group = peer_group_get (bgp, argv[0]);
1316 if (! group)
1317 return CMD_WARNING;
1318
1319 return CMD_SUCCESS;
1320}
1321
1322DEFUN (no_neighbor,
1323 no_neighbor_cmd,
1324 NO_NEIGHBOR_CMD2,
1325 NO_STR
1326 NEIGHBOR_STR
1327 NEIGHBOR_ADDR_STR2)
1328{
1329 int ret;
1330 union sockunion su;
1331 struct peer_group *group;
1332 struct peer *peer;
1333
1334 ret = str2sockunion (argv[0], &su);
1335 if (ret < 0)
1336 {
1337 group = peer_group_lookup (vty->index, argv[0]);
1338 if (group)
1339 peer_group_delete (group);
1340 else
1341 {
1342 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1343 return CMD_WARNING;
1344 }
1345 }
1346 else
1347 {
1348 peer = peer_lookup (vty->index, &su);
1349 if (peer)
paul200df112005-06-01 11:17:05 +00001350 peer_delete (peer);
paul718e3742002-12-13 20:15:29 +00001351 }
1352
1353 return CMD_SUCCESS;
1354}
1355
1356ALIAS (no_neighbor,
1357 no_neighbor_remote_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001358 NO_NEIGHBOR_CMD "remote-as " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00001359 NO_STR
1360 NEIGHBOR_STR
1361 NEIGHBOR_ADDR_STR
1362 "Specify a BGP neighbor\n"
1363 AS_STR)
1364
1365DEFUN (no_neighbor_peer_group,
1366 no_neighbor_peer_group_cmd,
1367 "no neighbor WORD peer-group",
1368 NO_STR
1369 NEIGHBOR_STR
1370 "Neighbor tag\n"
1371 "Configure peer-group\n")
1372{
1373 struct peer_group *group;
1374
1375 group = peer_group_lookup (vty->index, argv[0]);
1376 if (group)
1377 peer_group_delete (group);
1378 else
1379 {
1380 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1381 return CMD_WARNING;
1382 }
1383 return CMD_SUCCESS;
1384}
1385
1386DEFUN (no_neighbor_peer_group_remote_as,
1387 no_neighbor_peer_group_remote_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001388 "no neighbor WORD remote-as " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00001389 NO_STR
1390 NEIGHBOR_STR
1391 "Neighbor tag\n"
1392 "Specify a BGP neighbor\n"
1393 AS_STR)
1394{
1395 struct peer_group *group;
1396
1397 group = peer_group_lookup (vty->index, argv[0]);
1398 if (group)
1399 peer_group_remote_as_delete (group);
1400 else
1401 {
1402 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1403 return CMD_WARNING;
1404 }
1405 return CMD_SUCCESS;
1406}
1407
1408DEFUN (neighbor_local_as,
1409 neighbor_local_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001410 NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00001411 NEIGHBOR_STR
1412 NEIGHBOR_ADDR_STR2
1413 "Specify a local-as number\n"
1414 "AS number used as local AS\n")
1415{
1416 struct peer *peer;
1417 int ret;
1418
1419 peer = peer_and_group_lookup_vty (vty, argv[0]);
1420 if (! peer)
1421 return CMD_WARNING;
1422
1423 ret = peer_local_as_set (peer, atoi (argv[1]), 0);
1424 return bgp_vty_return (vty, ret);
1425}
1426
1427DEFUN (neighbor_local_as_no_prepend,
1428 neighbor_local_as_no_prepend_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001429 NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
paul718e3742002-12-13 20:15:29 +00001430 NEIGHBOR_STR
1431 NEIGHBOR_ADDR_STR2
1432 "Specify a local-as number\n"
1433 "AS number used as local AS\n"
1434 "Do not prepend local-as to updates from ebgp peers\n")
1435{
1436 struct peer *peer;
1437 int ret;
1438
1439 peer = peer_and_group_lookup_vty (vty, argv[0]);
1440 if (! peer)
1441 return CMD_WARNING;
1442
1443 ret = peer_local_as_set (peer, atoi (argv[1]), 1);
1444 return bgp_vty_return (vty, ret);
1445}
1446
1447DEFUN (no_neighbor_local_as,
1448 no_neighbor_local_as_cmd,
1449 NO_NEIGHBOR_CMD2 "local-as",
1450 NO_STR
1451 NEIGHBOR_STR
1452 NEIGHBOR_ADDR_STR2
1453 "Specify a local-as number\n")
1454{
1455 struct peer *peer;
1456 int ret;
1457
1458 peer = peer_and_group_lookup_vty (vty, argv[0]);
1459 if (! peer)
1460 return CMD_WARNING;
1461
1462 ret = peer_local_as_unset (peer);
1463 return bgp_vty_return (vty, ret);
1464}
1465
1466ALIAS (no_neighbor_local_as,
1467 no_neighbor_local_as_val_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001468 NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00001469 NO_STR
1470 NEIGHBOR_STR
1471 NEIGHBOR_ADDR_STR2
1472 "Specify a local-as number\n"
1473 "AS number used as local AS\n")
1474
1475ALIAS (no_neighbor_local_as,
1476 no_neighbor_local_as_val2_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001477 NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
paul718e3742002-12-13 20:15:29 +00001478 NO_STR
1479 NEIGHBOR_STR
1480 NEIGHBOR_ADDR_STR2
1481 "Specify a local-as number\n"
1482 "AS number used as local AS\n"
1483 "Do not prepend local-as to updates from ebgp peers\n")
1484
Paul Jakma0df7c912008-07-21 21:02:49 +00001485DEFUN (neighbor_password,
1486 neighbor_password_cmd,
1487 NEIGHBOR_CMD2 "password LINE",
1488 NEIGHBOR_STR
1489 NEIGHBOR_ADDR_STR2
1490 "Set a password\n"
1491 "The password\n")
1492{
1493 struct peer *peer;
1494 int ret;
1495
1496 peer = peer_and_group_lookup_vty (vty, argv[0]);
1497 if (! peer)
1498 return CMD_WARNING;
1499
1500 ret = peer_password_set (peer, argv[1]);
1501 return bgp_vty_return (vty, ret);
1502}
1503
1504DEFUN (no_neighbor_password,
1505 no_neighbor_password_cmd,
1506 NO_NEIGHBOR_CMD2 "password",
1507 NO_STR
1508 NEIGHBOR_STR
1509 NEIGHBOR_ADDR_STR2
1510 "Set a password\n")
1511{
1512 struct peer *peer;
1513 int ret;
1514
1515 peer = peer_and_group_lookup_vty (vty, argv[0]);
1516 if (! peer)
1517 return CMD_WARNING;
1518
1519 ret = peer_password_unset (peer);
1520 return bgp_vty_return (vty, ret);
1521}
1522
paul718e3742002-12-13 20:15:29 +00001523DEFUN (neighbor_activate,
1524 neighbor_activate_cmd,
1525 NEIGHBOR_CMD2 "activate",
1526 NEIGHBOR_STR
1527 NEIGHBOR_ADDR_STR2
1528 "Enable the Address Family for this Neighbor\n")
1529{
1530 struct peer *peer;
1531
1532 peer = peer_and_group_lookup_vty (vty, argv[0]);
1533 if (! peer)
1534 return CMD_WARNING;
1535
1536 peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
1537
1538 return CMD_SUCCESS;
1539}
1540
1541DEFUN (no_neighbor_activate,
1542 no_neighbor_activate_cmd,
1543 NO_NEIGHBOR_CMD2 "activate",
1544 NO_STR
1545 NEIGHBOR_STR
1546 NEIGHBOR_ADDR_STR2
1547 "Enable the Address Family for this Neighbor\n")
1548{
1549 int ret;
1550 struct peer *peer;
1551
1552 /* Lookup peer. */
1553 peer = peer_and_group_lookup_vty (vty, argv[0]);
1554 if (! peer)
1555 return CMD_WARNING;
1556
1557 ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
1558
1559 return bgp_vty_return (vty, ret);
1560}
1561
1562DEFUN (neighbor_set_peer_group,
1563 neighbor_set_peer_group_cmd,
1564 NEIGHBOR_CMD "peer-group WORD",
1565 NEIGHBOR_STR
1566 NEIGHBOR_ADDR_STR
1567 "Member of the peer-group\n"
1568 "peer-group name\n")
1569{
1570 int ret;
1571 as_t as;
1572 union sockunion su;
1573 struct bgp *bgp;
1574 struct peer_group *group;
1575
1576 bgp = vty->index;
1577
1578 ret = str2sockunion (argv[0], &su);
1579 if (ret < 0)
1580 {
1581 vty_out (vty, "%% Malformed address: %s%s", argv[0], VTY_NEWLINE);
1582 return CMD_WARNING;
1583 }
1584
1585 group = peer_group_lookup (bgp, argv[1]);
1586 if (! group)
1587 {
1588 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
1589 return CMD_WARNING;
1590 }
1591
1592 if (peer_address_self_check (&su))
1593 {
1594 vty_out (vty, "%% Can not configure the local system as neighbor%s",
1595 VTY_NEWLINE);
1596 return CMD_WARNING;
1597 }
1598
1599 ret = peer_group_bind (bgp, &su, group, bgp_node_afi (vty),
1600 bgp_node_safi (vty), &as);
1601
1602 if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT)
1603 {
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04001604 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 +00001605 return CMD_WARNING;
1606 }
1607
1608 return bgp_vty_return (vty, ret);
1609}
1610
1611DEFUN (no_neighbor_set_peer_group,
1612 no_neighbor_set_peer_group_cmd,
1613 NO_NEIGHBOR_CMD "peer-group WORD",
1614 NO_STR
1615 NEIGHBOR_STR
1616 NEIGHBOR_ADDR_STR
1617 "Member of the peer-group\n"
1618 "peer-group name\n")
1619{
1620 int ret;
1621 struct bgp *bgp;
1622 struct peer *peer;
1623 struct peer_group *group;
1624
1625 bgp = vty->index;
1626
1627 peer = peer_lookup_vty (vty, argv[0]);
1628 if (! peer)
1629 return CMD_WARNING;
1630
1631 group = peer_group_lookup (bgp, argv[1]);
1632 if (! group)
1633 {
1634 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
1635 return CMD_WARNING;
1636 }
1637
1638 ret = peer_group_unbind (bgp, peer, group, bgp_node_afi (vty),
1639 bgp_node_safi (vty));
1640
1641 return bgp_vty_return (vty, ret);
1642}
1643
paul94f2b392005-06-28 12:44:16 +00001644static int
paulfd79ac92004-10-13 05:06:08 +00001645peer_flag_modify_vty (struct vty *vty, const char *ip_str,
1646 u_int16_t flag, int set)
paul718e3742002-12-13 20:15:29 +00001647{
1648 int ret;
1649 struct peer *peer;
1650
1651 peer = peer_and_group_lookup_vty (vty, ip_str);
1652 if (! peer)
1653 return CMD_WARNING;
1654
1655 if (set)
1656 ret = peer_flag_set (peer, flag);
1657 else
1658 ret = peer_flag_unset (peer, flag);
1659
1660 return bgp_vty_return (vty, ret);
1661}
1662
paul94f2b392005-06-28 12:44:16 +00001663static int
paulfd79ac92004-10-13 05:06:08 +00001664peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
paul718e3742002-12-13 20:15:29 +00001665{
1666 return peer_flag_modify_vty (vty, ip_str, flag, 1);
1667}
1668
paul94f2b392005-06-28 12:44:16 +00001669static int
paulfd79ac92004-10-13 05:06:08 +00001670peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
paul718e3742002-12-13 20:15:29 +00001671{
1672 return peer_flag_modify_vty (vty, ip_str, flag, 0);
1673}
1674
1675/* neighbor passive. */
1676DEFUN (neighbor_passive,
1677 neighbor_passive_cmd,
1678 NEIGHBOR_CMD2 "passive",
1679 NEIGHBOR_STR
1680 NEIGHBOR_ADDR_STR2
1681 "Don't send open messages to this neighbor\n")
1682{
1683 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_PASSIVE);
1684}
1685
1686DEFUN (no_neighbor_passive,
1687 no_neighbor_passive_cmd,
1688 NO_NEIGHBOR_CMD2 "passive",
1689 NO_STR
1690 NEIGHBOR_STR
1691 NEIGHBOR_ADDR_STR2
1692 "Don't send open messages to this neighbor\n")
1693{
1694 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_PASSIVE);
1695}
1696
1697/* neighbor shutdown. */
1698DEFUN (neighbor_shutdown,
1699 neighbor_shutdown_cmd,
1700 NEIGHBOR_CMD2 "shutdown",
1701 NEIGHBOR_STR
1702 NEIGHBOR_ADDR_STR2
1703 "Administratively shut down this neighbor\n")
1704{
1705 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
1706}
1707
1708DEFUN (no_neighbor_shutdown,
1709 no_neighbor_shutdown_cmd,
1710 NO_NEIGHBOR_CMD2 "shutdown",
1711 NO_STR
1712 NEIGHBOR_STR
1713 NEIGHBOR_ADDR_STR2
1714 "Administratively shut down this neighbor\n")
1715{
1716 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
1717}
1718
hassoc9502432005-02-01 22:01:48 +00001719/* Deprecated neighbor capability route-refresh. */
1720DEFUN_DEPRECATED (neighbor_capability_route_refresh,
1721 neighbor_capability_route_refresh_cmd,
1722 NEIGHBOR_CMD2 "capability route-refresh",
1723 NEIGHBOR_STR
1724 NEIGHBOR_ADDR_STR2
1725 "Advertise capability to the peer\n"
1726 "Advertise route-refresh capability to this neighbor\n")
paul718e3742002-12-13 20:15:29 +00001727{
hassoc9502432005-02-01 22:01:48 +00001728 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00001729}
1730
hassoc9502432005-02-01 22:01:48 +00001731DEFUN_DEPRECATED (no_neighbor_capability_route_refresh,
1732 no_neighbor_capability_route_refresh_cmd,
1733 NO_NEIGHBOR_CMD2 "capability route-refresh",
1734 NO_STR
1735 NEIGHBOR_STR
1736 NEIGHBOR_ADDR_STR2
1737 "Advertise capability to the peer\n"
1738 "Advertise route-refresh capability to this neighbor\n")
paul718e3742002-12-13 20:15:29 +00001739{
hassoc9502432005-02-01 22:01:48 +00001740 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00001741}
1742
1743/* neighbor capability dynamic. */
1744DEFUN (neighbor_capability_dynamic,
1745 neighbor_capability_dynamic_cmd,
1746 NEIGHBOR_CMD2 "capability dynamic",
1747 NEIGHBOR_STR
1748 NEIGHBOR_ADDR_STR2
1749 "Advertise capability to the peer\n"
1750 "Advertise dynamic capability to this neighbor\n")
1751{
1752 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
1753}
1754
1755DEFUN (no_neighbor_capability_dynamic,
1756 no_neighbor_capability_dynamic_cmd,
1757 NO_NEIGHBOR_CMD2 "capability dynamic",
1758 NO_STR
1759 NEIGHBOR_STR
1760 NEIGHBOR_ADDR_STR2
1761 "Advertise capability to the peer\n"
1762 "Advertise dynamic capability to this neighbor\n")
1763{
1764 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
1765}
1766
1767/* neighbor dont-capability-negotiate */
1768DEFUN (neighbor_dont_capability_negotiate,
1769 neighbor_dont_capability_negotiate_cmd,
1770 NEIGHBOR_CMD2 "dont-capability-negotiate",
1771 NEIGHBOR_STR
1772 NEIGHBOR_ADDR_STR2
1773 "Do not perform capability negotiation\n")
1774{
1775 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
1776}
1777
1778DEFUN (no_neighbor_dont_capability_negotiate,
1779 no_neighbor_dont_capability_negotiate_cmd,
1780 NO_NEIGHBOR_CMD2 "dont-capability-negotiate",
1781 NO_STR
1782 NEIGHBOR_STR
1783 NEIGHBOR_ADDR_STR2
1784 "Do not perform capability negotiation\n")
1785{
1786 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
1787}
1788
paul94f2b392005-06-28 12:44:16 +00001789static int
paulfd79ac92004-10-13 05:06:08 +00001790peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi,
paulfee0f4c2004-09-13 05:12:46 +00001791 safi_t safi, u_int32_t flag, int set)
paul718e3742002-12-13 20:15:29 +00001792{
1793 int ret;
1794 struct peer *peer;
1795
1796 peer = peer_and_group_lookup_vty (vty, peer_str);
1797 if (! peer)
1798 return CMD_WARNING;
1799
1800 if (set)
1801 ret = peer_af_flag_set (peer, afi, safi, flag);
1802 else
1803 ret = peer_af_flag_unset (peer, afi, safi, flag);
1804
1805 return bgp_vty_return (vty, ret);
1806}
1807
paul94f2b392005-06-28 12:44:16 +00001808static int
paulfd79ac92004-10-13 05:06:08 +00001809peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi,
paulfee0f4c2004-09-13 05:12:46 +00001810 safi_t safi, u_int32_t flag)
paul718e3742002-12-13 20:15:29 +00001811{
1812 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1);
1813}
1814
paul94f2b392005-06-28 12:44:16 +00001815static int
paulfd79ac92004-10-13 05:06:08 +00001816peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi,
paulfee0f4c2004-09-13 05:12:46 +00001817 safi_t safi, u_int32_t flag)
paul718e3742002-12-13 20:15:29 +00001818{
1819 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0);
1820}
1821
1822/* neighbor capability orf prefix-list. */
1823DEFUN (neighbor_capability_orf_prefix,
1824 neighbor_capability_orf_prefix_cmd,
1825 NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
1826 NEIGHBOR_STR
1827 NEIGHBOR_ADDR_STR2
1828 "Advertise capability to the peer\n"
1829 "Advertise ORF capability to the peer\n"
1830 "Advertise prefixlist ORF capability to this neighbor\n"
1831 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
1832 "Capability to RECEIVE the ORF from this neighbor\n"
1833 "Capability to SEND the ORF to this neighbor\n")
1834{
1835 u_int16_t flag = 0;
1836
1837 if (strncmp (argv[1], "s", 1) == 0)
1838 flag = PEER_FLAG_ORF_PREFIX_SM;
1839 else if (strncmp (argv[1], "r", 1) == 0)
1840 flag = PEER_FLAG_ORF_PREFIX_RM;
1841 else if (strncmp (argv[1], "b", 1) == 0)
1842 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
1843 else
1844 return CMD_WARNING;
1845
1846 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1847 bgp_node_safi (vty), flag);
1848}
1849
1850DEFUN (no_neighbor_capability_orf_prefix,
1851 no_neighbor_capability_orf_prefix_cmd,
1852 NO_NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
1853 NO_STR
1854 NEIGHBOR_STR
1855 NEIGHBOR_ADDR_STR2
1856 "Advertise capability to the peer\n"
1857 "Advertise ORF capability to the peer\n"
1858 "Advertise prefixlist ORF capability to this neighbor\n"
1859 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
1860 "Capability to RECEIVE the ORF from this neighbor\n"
1861 "Capability to SEND the ORF to this neighbor\n")
1862{
1863 u_int16_t flag = 0;
1864
1865 if (strncmp (argv[1], "s", 1) == 0)
1866 flag = PEER_FLAG_ORF_PREFIX_SM;
1867 else if (strncmp (argv[1], "r", 1) == 0)
1868 flag = PEER_FLAG_ORF_PREFIX_RM;
1869 else if (strncmp (argv[1], "b", 1) == 0)
1870 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
1871 else
1872 return CMD_WARNING;
1873
1874 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1875 bgp_node_safi (vty), flag);
1876}
1877
1878/* neighbor next-hop-self. */
1879DEFUN (neighbor_nexthop_self,
1880 neighbor_nexthop_self_cmd,
1881 NEIGHBOR_CMD2 "next-hop-self",
1882 NEIGHBOR_STR
1883 NEIGHBOR_ADDR_STR2
1884 "Disable the next hop calculation for this neighbor\n")
1885{
1886 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1887 bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF);
1888}
1889
1890DEFUN (no_neighbor_nexthop_self,
1891 no_neighbor_nexthop_self_cmd,
1892 NO_NEIGHBOR_CMD2 "next-hop-self",
1893 NO_STR
1894 NEIGHBOR_STR
1895 NEIGHBOR_ADDR_STR2
1896 "Disable the next hop calculation for this neighbor\n")
1897{
1898 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1899 bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF);
1900}
1901
1902/* neighbor remove-private-AS. */
1903DEFUN (neighbor_remove_private_as,
1904 neighbor_remove_private_as_cmd,
1905 NEIGHBOR_CMD2 "remove-private-AS",
1906 NEIGHBOR_STR
1907 NEIGHBOR_ADDR_STR2
1908 "Remove private AS number from outbound updates\n")
1909{
1910 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1911 bgp_node_safi (vty),
1912 PEER_FLAG_REMOVE_PRIVATE_AS);
1913}
1914
1915DEFUN (no_neighbor_remove_private_as,
1916 no_neighbor_remove_private_as_cmd,
1917 NO_NEIGHBOR_CMD2 "remove-private-AS",
1918 NO_STR
1919 NEIGHBOR_STR
1920 NEIGHBOR_ADDR_STR2
1921 "Remove private AS number from outbound updates\n")
1922{
1923 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1924 bgp_node_safi (vty),
1925 PEER_FLAG_REMOVE_PRIVATE_AS);
1926}
1927
1928/* neighbor send-community. */
1929DEFUN (neighbor_send_community,
1930 neighbor_send_community_cmd,
1931 NEIGHBOR_CMD2 "send-community",
1932 NEIGHBOR_STR
1933 NEIGHBOR_ADDR_STR2
1934 "Send Community attribute to this neighbor\n")
1935{
1936 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1937 bgp_node_safi (vty),
1938 PEER_FLAG_SEND_COMMUNITY);
1939}
1940
1941DEFUN (no_neighbor_send_community,
1942 no_neighbor_send_community_cmd,
1943 NO_NEIGHBOR_CMD2 "send-community",
1944 NO_STR
1945 NEIGHBOR_STR
1946 NEIGHBOR_ADDR_STR2
1947 "Send Community attribute to this neighbor\n")
1948{
1949 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1950 bgp_node_safi (vty),
1951 PEER_FLAG_SEND_COMMUNITY);
1952}
1953
1954/* neighbor send-community extended. */
1955DEFUN (neighbor_send_community_type,
1956 neighbor_send_community_type_cmd,
1957 NEIGHBOR_CMD2 "send-community (both|extended|standard)",
1958 NEIGHBOR_STR
1959 NEIGHBOR_ADDR_STR2
1960 "Send Community attribute to this neighbor\n"
1961 "Send Standard and Extended Community attributes\n"
1962 "Send Extended Community attributes\n"
1963 "Send Standard Community attributes\n")
1964{
1965 if (strncmp (argv[1], "s", 1) == 0)
1966 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1967 bgp_node_safi (vty),
1968 PEER_FLAG_SEND_COMMUNITY);
1969 if (strncmp (argv[1], "e", 1) == 0)
1970 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1971 bgp_node_safi (vty),
1972 PEER_FLAG_SEND_EXT_COMMUNITY);
1973
1974 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1975 bgp_node_safi (vty),
1976 (PEER_FLAG_SEND_COMMUNITY|
1977 PEER_FLAG_SEND_EXT_COMMUNITY));
1978}
1979
1980DEFUN (no_neighbor_send_community_type,
1981 no_neighbor_send_community_type_cmd,
1982 NO_NEIGHBOR_CMD2 "send-community (both|extended|standard)",
1983 NO_STR
1984 NEIGHBOR_STR
1985 NEIGHBOR_ADDR_STR2
1986 "Send Community attribute to this neighbor\n"
1987 "Send Standard and Extended Community attributes\n"
1988 "Send Extended Community attributes\n"
1989 "Send Standard Community attributes\n")
1990{
1991 if (strncmp (argv[1], "s", 1) == 0)
1992 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1993 bgp_node_safi (vty),
1994 PEER_FLAG_SEND_COMMUNITY);
1995 if (strncmp (argv[1], "e", 1) == 0)
1996 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1997 bgp_node_safi (vty),
1998 PEER_FLAG_SEND_EXT_COMMUNITY);
1999
2000 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2001 bgp_node_safi (vty),
2002 (PEER_FLAG_SEND_COMMUNITY |
2003 PEER_FLAG_SEND_EXT_COMMUNITY));
2004}
2005
2006/* neighbor soft-reconfig. */
2007DEFUN (neighbor_soft_reconfiguration,
2008 neighbor_soft_reconfiguration_cmd,
2009 NEIGHBOR_CMD2 "soft-reconfiguration inbound",
2010 NEIGHBOR_STR
2011 NEIGHBOR_ADDR_STR2
2012 "Per neighbor soft reconfiguration\n"
2013 "Allow inbound soft reconfiguration for this neighbor\n")
2014{
2015 return peer_af_flag_set_vty (vty, argv[0],
2016 bgp_node_afi (vty), bgp_node_safi (vty),
2017 PEER_FLAG_SOFT_RECONFIG);
2018}
2019
2020DEFUN (no_neighbor_soft_reconfiguration,
2021 no_neighbor_soft_reconfiguration_cmd,
2022 NO_NEIGHBOR_CMD2 "soft-reconfiguration inbound",
2023 NO_STR
2024 NEIGHBOR_STR
2025 NEIGHBOR_ADDR_STR2
2026 "Per neighbor soft reconfiguration\n"
2027 "Allow inbound soft reconfiguration for this neighbor\n")
2028{
2029 return peer_af_flag_unset_vty (vty, argv[0],
2030 bgp_node_afi (vty), bgp_node_safi (vty),
2031 PEER_FLAG_SOFT_RECONFIG);
2032}
2033
2034DEFUN (neighbor_route_reflector_client,
2035 neighbor_route_reflector_client_cmd,
2036 NEIGHBOR_CMD2 "route-reflector-client",
2037 NEIGHBOR_STR
2038 NEIGHBOR_ADDR_STR2
2039 "Configure a neighbor as Route Reflector client\n")
2040{
2041 struct peer *peer;
2042
2043
2044 peer = peer_and_group_lookup_vty (vty, argv[0]);
2045 if (! peer)
2046 return CMD_WARNING;
2047
2048 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2049 bgp_node_safi (vty),
2050 PEER_FLAG_REFLECTOR_CLIENT);
2051}
2052
2053DEFUN (no_neighbor_route_reflector_client,
2054 no_neighbor_route_reflector_client_cmd,
2055 NO_NEIGHBOR_CMD2 "route-reflector-client",
2056 NO_STR
2057 NEIGHBOR_STR
2058 NEIGHBOR_ADDR_STR2
2059 "Configure a neighbor as Route Reflector client\n")
2060{
2061 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2062 bgp_node_safi (vty),
2063 PEER_FLAG_REFLECTOR_CLIENT);
2064}
2065
paul94f2b392005-06-28 12:44:16 +00002066static int
paulfd79ac92004-10-13 05:06:08 +00002067peer_rsclient_set_vty (struct vty *vty, const char *peer_str,
2068 int afi, int safi)
paulfee0f4c2004-09-13 05:12:46 +00002069{
2070 int ret;
2071 struct bgp *bgp;
2072 struct peer *peer;
2073 struct peer_group *group;
paul1eb8ef22005-04-07 07:30:20 +00002074 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00002075 struct bgp_filter *pfilter;
2076 struct bgp_filter *gfilter;
Chris Caputo228da422009-07-18 05:44:03 +00002077 int locked_and_added = 0;
paulfee0f4c2004-09-13 05:12:46 +00002078
2079 bgp = vty->index;
2080
2081 peer = peer_and_group_lookup_vty (vty, peer_str);
2082 if ( ! peer )
2083 return CMD_WARNING;
2084
2085 /* If it is already a RS-Client, don't do anything. */
2086 if ( CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) )
2087 return CMD_SUCCESS;
2088
2089 if ( ! peer_rsclient_active (peer) )
paul200df112005-06-01 11:17:05 +00002090 {
2091 peer = peer_lock (peer); /* rsclient peer list reference */
2092 listnode_add_sort (bgp->rsclient, peer);
Chris Caputo228da422009-07-18 05:44:03 +00002093 locked_and_added = 1;
paul200df112005-06-01 11:17:05 +00002094 }
paulfee0f4c2004-09-13 05:12:46 +00002095
2096 ret = peer_af_flag_set (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
2097 if (ret < 0)
Chris Caputo228da422009-07-18 05:44:03 +00002098 {
2099 if (locked_and_added)
2100 {
2101 listnode_delete (bgp->rsclient, peer);
2102 peer_unlock (peer); /* rsclient peer list reference */
2103 }
2104
2105 return bgp_vty_return (vty, ret);
2106 }
paulfee0f4c2004-09-13 05:12:46 +00002107
Paul Jakma64e580a2006-02-21 01:09:01 +00002108 peer->rib[afi][safi] = bgp_table_init (afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00002109 peer->rib[afi][safi]->type = BGP_TABLE_RSCLIENT;
Chris Caputo228da422009-07-18 05:44:03 +00002110 /* RIB peer reference. Released when table is free'd in bgp_table_free. */
2111 peer->rib[afi][safi]->owner = peer_lock (peer);
paulfee0f4c2004-09-13 05:12:46 +00002112
2113 /* Check for existing 'network' and 'redistribute' routes. */
2114 bgp_check_local_routes_rsclient (peer, afi, safi);
2115
2116 /* Check for routes for peers configured with 'soft-reconfiguration'. */
2117 bgp_soft_reconfig_rsclient (peer, afi, safi);
2118
2119 if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))
2120 {
2121 group = peer->group;
2122 gfilter = &peer->filter[afi][safi];
2123
paul1eb8ef22005-04-07 07:30:20 +00002124 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
paulfee0f4c2004-09-13 05:12:46 +00002125 {
2126 pfilter = &peer->filter[afi][safi];
2127
2128 /* Members of a non-RS-Client group should not be RS-Clients, as that
2129 is checked when the become part of the peer-group */
2130 ret = peer_af_flag_set (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
2131 if (ret < 0)
2132 return bgp_vty_return (vty, ret);
2133
2134 /* Make peer's RIB point to group's RIB. */
2135 peer->rib[afi][safi] = group->conf->rib[afi][safi];
2136
2137 /* Import policy. */
2138 if (pfilter->map[RMAP_IMPORT].name)
2139 free (pfilter->map[RMAP_IMPORT].name);
2140 if (gfilter->map[RMAP_IMPORT].name)
2141 {
2142 pfilter->map[RMAP_IMPORT].name = strdup (gfilter->map[RMAP_IMPORT].name);
2143 pfilter->map[RMAP_IMPORT].map = gfilter->map[RMAP_IMPORT].map;
2144 }
2145 else
2146 {
2147 pfilter->map[RMAP_IMPORT].name = NULL;
2148 pfilter->map[RMAP_IMPORT].map =NULL;
2149 }
2150
2151 /* Export policy. */
2152 if (gfilter->map[RMAP_EXPORT].name && ! pfilter->map[RMAP_EXPORT].name)
2153 {
2154 pfilter->map[RMAP_EXPORT].name = strdup (gfilter->map[RMAP_EXPORT].name);
2155 pfilter->map[RMAP_EXPORT].map = gfilter->map[RMAP_EXPORT].map;
2156 }
2157 }
2158 }
2159 return CMD_SUCCESS;
2160}
2161
paul94f2b392005-06-28 12:44:16 +00002162static int
paulfd79ac92004-10-13 05:06:08 +00002163peer_rsclient_unset_vty (struct vty *vty, const char *peer_str,
2164 int afi, int safi)
paulfee0f4c2004-09-13 05:12:46 +00002165{
2166 int ret;
2167 struct bgp *bgp;
2168 struct peer *peer;
2169 struct peer_group *group;
paul1eb8ef22005-04-07 07:30:20 +00002170 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00002171
2172 bgp = vty->index;
2173
2174 peer = peer_and_group_lookup_vty (vty, peer_str);
2175 if ( ! peer )
2176 return CMD_WARNING;
2177
2178 /* If it is not a RS-Client, don't do anything. */
2179 if ( ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) )
2180 return CMD_SUCCESS;
2181
2182 if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))
2183 {
2184 group = peer->group;
2185
paul1eb8ef22005-04-07 07:30:20 +00002186 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
paulfee0f4c2004-09-13 05:12:46 +00002187 {
2188 ret = peer_af_flag_unset (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
2189 if (ret < 0)
2190 return bgp_vty_return (vty, ret);
2191
2192 peer->rib[afi][safi] = NULL;
2193 }
2194
2195 peer = group->conf;
2196 }
2197
2198 ret = peer_af_flag_unset (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
2199 if (ret < 0)
2200 return bgp_vty_return (vty, ret);
2201
2202 if ( ! peer_rsclient_active (peer) )
paul200df112005-06-01 11:17:05 +00002203 {
Chris Caputo228da422009-07-18 05:44:03 +00002204 bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_MY_RSCLIENT);
paul200df112005-06-01 11:17:05 +00002205 listnode_delete (bgp->rsclient, peer);
Chris Caputo228da422009-07-18 05:44:03 +00002206 peer_unlock (peer); /* peer bgp rsclient reference */
paul200df112005-06-01 11:17:05 +00002207 }
paulfee0f4c2004-09-13 05:12:46 +00002208
Paul Jakmab608d5b2008-07-02 02:12:07 +00002209 bgp_table_finish (&peer->rib[bgp_node_afi(vty)][bgp_node_safi(vty)]);
paulfee0f4c2004-09-13 05:12:46 +00002210
2211 return CMD_SUCCESS;
2212}
2213
paul718e3742002-12-13 20:15:29 +00002214/* neighbor route-server-client. */
2215DEFUN (neighbor_route_server_client,
2216 neighbor_route_server_client_cmd,
2217 NEIGHBOR_CMD2 "route-server-client",
2218 NEIGHBOR_STR
2219 NEIGHBOR_ADDR_STR2
2220 "Configure a neighbor as Route Server client\n")
2221{
paulfee0f4c2004-09-13 05:12:46 +00002222 return peer_rsclient_set_vty (vty, argv[0], bgp_node_afi(vty),
2223 bgp_node_safi(vty));
paul718e3742002-12-13 20:15:29 +00002224}
2225
2226DEFUN (no_neighbor_route_server_client,
2227 no_neighbor_route_server_client_cmd,
2228 NO_NEIGHBOR_CMD2 "route-server-client",
2229 NO_STR
2230 NEIGHBOR_STR
2231 NEIGHBOR_ADDR_STR2
2232 "Configure a neighbor as Route Server client\n")
2233{
paulfee0f4c2004-09-13 05:12:46 +00002234 return peer_rsclient_unset_vty (vty, argv[0], bgp_node_afi(vty),
2235 bgp_node_safi(vty));
2236}
2237
2238DEFUN (neighbor_nexthop_local_unchanged,
2239 neighbor_nexthop_local_unchanged_cmd,
2240 NEIGHBOR_CMD2 "nexthop-local unchanged",
2241 NEIGHBOR_STR
2242 NEIGHBOR_ADDR_STR2
2243 "Configure treatment of outgoing link-local nexthop attribute\n"
2244 "Leave link-local nexthop unchanged for this peer\n")
2245{
2246 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2247 bgp_node_safi (vty),
2248 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
2249}
2250
2251DEFUN (no_neighbor_nexthop_local_unchanged,
2252 no_neighbor_nexthop_local_unchanged_cmd,
2253 NO_NEIGHBOR_CMD2 "nexthop-local unchanged",
2254 NO_STR
2255 NEIGHBOR_STR
2256 NEIGHBOR_ADDR_STR2
2257 "Configure treatment of outgoing link-local-nexthop attribute\n"
2258 "Leave link-local nexthop unchanged for this peer\n")
2259{
paul718e3742002-12-13 20:15:29 +00002260 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2261 bgp_node_safi (vty),
paulfee0f4c2004-09-13 05:12:46 +00002262 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
paul718e3742002-12-13 20:15:29 +00002263}
2264
2265DEFUN (neighbor_attr_unchanged,
2266 neighbor_attr_unchanged_cmd,
2267 NEIGHBOR_CMD2 "attribute-unchanged",
2268 NEIGHBOR_STR
2269 NEIGHBOR_ADDR_STR2
2270 "BGP attribute is propagated unchanged to this neighbor\n")
2271{
2272 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2273 bgp_node_safi (vty),
2274 (PEER_FLAG_AS_PATH_UNCHANGED |
2275 PEER_FLAG_NEXTHOP_UNCHANGED |
2276 PEER_FLAG_MED_UNCHANGED));
2277}
2278
2279DEFUN (neighbor_attr_unchanged1,
2280 neighbor_attr_unchanged1_cmd,
2281 NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
2282 NEIGHBOR_STR
2283 NEIGHBOR_ADDR_STR2
2284 "BGP attribute is propagated unchanged to this neighbor\n"
2285 "As-path attribute\n"
2286 "Nexthop attribute\n"
2287 "Med attribute\n")
2288{
2289 u_int16_t flags = 0;
2290
2291 if (strncmp (argv[1], "as-path", 1) == 0)
2292 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2293 else if (strncmp (argv[1], "next-hop", 1) == 0)
2294 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2295 else if (strncmp (argv[1], "med", 1) == 0)
2296 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2297
2298 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2299 bgp_node_safi (vty), flags);
2300}
2301
2302DEFUN (neighbor_attr_unchanged2,
2303 neighbor_attr_unchanged2_cmd,
2304 NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
2305 NEIGHBOR_STR
2306 NEIGHBOR_ADDR_STR2
2307 "BGP attribute is propagated unchanged to this neighbor\n"
2308 "As-path attribute\n"
2309 "Nexthop attribute\n"
2310 "Med attribute\n")
2311{
2312 u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
2313
2314 if (strncmp (argv[1], "next-hop", 1) == 0)
2315 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2316 else if (strncmp (argv[1], "med", 1) == 0)
2317 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2318
2319 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2320 bgp_node_safi (vty), flags);
2321
2322}
2323
2324DEFUN (neighbor_attr_unchanged3,
2325 neighbor_attr_unchanged3_cmd,
2326 NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
2327 NEIGHBOR_STR
2328 NEIGHBOR_ADDR_STR2
2329 "BGP attribute is propagated unchanged to this neighbor\n"
2330 "Nexthop attribute\n"
2331 "As-path attribute\n"
2332 "Med attribute\n")
2333{
2334 u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
2335
2336 if (strncmp (argv[1], "as-path", 1) == 0)
2337 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2338 else if (strncmp (argv[1], "med", 1) == 0)
2339 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2340
2341 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2342 bgp_node_safi (vty), flags);
2343}
2344
2345DEFUN (neighbor_attr_unchanged4,
2346 neighbor_attr_unchanged4_cmd,
2347 NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
2348 NEIGHBOR_STR
2349 NEIGHBOR_ADDR_STR2
2350 "BGP attribute is propagated unchanged to this neighbor\n"
2351 "Med attribute\n"
2352 "As-path attribute\n"
2353 "Nexthop attribute\n")
2354{
2355 u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
2356
2357 if (strncmp (argv[1], "as-path", 1) == 0)
2358 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2359 else if (strncmp (argv[1], "next-hop", 1) == 0)
2360 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2361
2362 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2363 bgp_node_safi (vty), flags);
2364}
2365
2366ALIAS (neighbor_attr_unchanged,
2367 neighbor_attr_unchanged5_cmd,
2368 NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
2369 NEIGHBOR_STR
2370 NEIGHBOR_ADDR_STR2
2371 "BGP attribute is propagated unchanged to this neighbor\n"
2372 "As-path attribute\n"
2373 "Nexthop attribute\n"
2374 "Med attribute\n")
2375
2376ALIAS (neighbor_attr_unchanged,
2377 neighbor_attr_unchanged6_cmd,
2378 NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
2379 NEIGHBOR_STR
2380 NEIGHBOR_ADDR_STR2
2381 "BGP attribute is propagated unchanged to this neighbor\n"
2382 "As-path attribute\n"
2383 "Med attribute\n"
2384 "Nexthop attribute\n")
2385
2386ALIAS (neighbor_attr_unchanged,
2387 neighbor_attr_unchanged7_cmd,
2388 NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
2389 NEIGHBOR_STR
2390 NEIGHBOR_ADDR_STR2
2391 "BGP attribute is propagated unchanged to this neighbor\n"
2392 "Nexthop attribute\n"
2393 "Med attribute\n"
2394 "As-path attribute\n")
2395
2396ALIAS (neighbor_attr_unchanged,
2397 neighbor_attr_unchanged8_cmd,
2398 NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
2399 NEIGHBOR_STR
2400 NEIGHBOR_ADDR_STR2
2401 "BGP attribute is propagated unchanged to this neighbor\n"
2402 "Nexthop attribute\n"
2403 "As-path attribute\n"
2404 "Med attribute\n")
2405
2406ALIAS (neighbor_attr_unchanged,
2407 neighbor_attr_unchanged9_cmd,
2408 NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
2409 NEIGHBOR_STR
2410 NEIGHBOR_ADDR_STR2
2411 "BGP attribute is propagated unchanged to this neighbor\n"
2412 "Med attribute\n"
2413 "Nexthop attribute\n"
2414 "As-path attribute\n")
2415
2416ALIAS (neighbor_attr_unchanged,
2417 neighbor_attr_unchanged10_cmd,
2418 NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
2419 NEIGHBOR_STR
2420 NEIGHBOR_ADDR_STR2
2421 "BGP attribute is propagated unchanged to this neighbor\n"
2422 "Med attribute\n"
2423 "As-path attribute\n"
2424 "Nexthop attribute\n")
2425
2426DEFUN (no_neighbor_attr_unchanged,
2427 no_neighbor_attr_unchanged_cmd,
2428 NO_NEIGHBOR_CMD2 "attribute-unchanged",
2429 NO_STR
2430 NEIGHBOR_STR
2431 NEIGHBOR_ADDR_STR2
2432 "BGP attribute is propagated unchanged to this neighbor\n")
2433{
2434 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2435 bgp_node_safi (vty),
2436 (PEER_FLAG_AS_PATH_UNCHANGED |
2437 PEER_FLAG_NEXTHOP_UNCHANGED |
2438 PEER_FLAG_MED_UNCHANGED));
2439}
2440
2441DEFUN (no_neighbor_attr_unchanged1,
2442 no_neighbor_attr_unchanged1_cmd,
2443 NO_NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
2444 NO_STR
2445 NEIGHBOR_STR
2446 NEIGHBOR_ADDR_STR2
2447 "BGP attribute is propagated unchanged to this neighbor\n"
2448 "As-path attribute\n"
2449 "Nexthop attribute\n"
2450 "Med attribute\n")
2451{
2452 u_int16_t flags = 0;
2453
2454 if (strncmp (argv[1], "as-path", 1) == 0)
2455 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2456 else if (strncmp (argv[1], "next-hop", 1) == 0)
2457 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2458 else if (strncmp (argv[1], "med", 1) == 0)
2459 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2460
2461 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2462 bgp_node_safi (vty), flags);
2463}
2464
2465DEFUN (no_neighbor_attr_unchanged2,
2466 no_neighbor_attr_unchanged2_cmd,
2467 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
2468 NO_STR
2469 NEIGHBOR_STR
2470 NEIGHBOR_ADDR_STR2
2471 "BGP attribute is propagated unchanged to this neighbor\n"
2472 "As-path attribute\n"
2473 "Nexthop attribute\n"
2474 "Med attribute\n")
2475{
2476 u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
2477
2478 if (strncmp (argv[1], "next-hop", 1) == 0)
2479 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2480 else if (strncmp (argv[1], "med", 1) == 0)
2481 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2482
2483 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2484 bgp_node_safi (vty), flags);
2485}
2486
2487DEFUN (no_neighbor_attr_unchanged3,
2488 no_neighbor_attr_unchanged3_cmd,
2489 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
2490 NO_STR
2491 NEIGHBOR_STR
2492 NEIGHBOR_ADDR_STR2
2493 "BGP attribute is propagated unchanged to this neighbor\n"
2494 "Nexthop attribute\n"
2495 "As-path attribute\n"
2496 "Med attribute\n")
2497{
2498 u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
2499
2500 if (strncmp (argv[1], "as-path", 1) == 0)
2501 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2502 else if (strncmp (argv[1], "med", 1) == 0)
2503 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2504
2505 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2506 bgp_node_safi (vty), flags);
2507}
2508
2509DEFUN (no_neighbor_attr_unchanged4,
2510 no_neighbor_attr_unchanged4_cmd,
2511 NO_NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
2512 NO_STR
2513 NEIGHBOR_STR
2514 NEIGHBOR_ADDR_STR2
2515 "BGP attribute is propagated unchanged to this neighbor\n"
2516 "Med attribute\n"
2517 "As-path attribute\n"
2518 "Nexthop attribute\n")
2519{
2520 u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
2521
2522 if (strncmp (argv[1], "as-path", 1) == 0)
2523 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2524 else if (strncmp (argv[1], "next-hop", 1) == 0)
2525 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2526
2527 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2528 bgp_node_safi (vty), flags);
2529}
2530
2531ALIAS (no_neighbor_attr_unchanged,
2532 no_neighbor_attr_unchanged5_cmd,
2533 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
2534 NO_STR
2535 NEIGHBOR_STR
2536 NEIGHBOR_ADDR_STR2
2537 "BGP attribute is propagated unchanged to this neighbor\n"
2538 "As-path attribute\n"
2539 "Nexthop attribute\n"
2540 "Med attribute\n")
2541
2542ALIAS (no_neighbor_attr_unchanged,
2543 no_neighbor_attr_unchanged6_cmd,
2544 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
2545 NO_STR
2546 NEIGHBOR_STR
2547 NEIGHBOR_ADDR_STR2
2548 "BGP attribute is propagated unchanged to this neighbor\n"
2549 "As-path attribute\n"
2550 "Med attribute\n"
2551 "Nexthop attribute\n")
2552
2553ALIAS (no_neighbor_attr_unchanged,
2554 no_neighbor_attr_unchanged7_cmd,
2555 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
2556 NO_STR
2557 NEIGHBOR_STR
2558 NEIGHBOR_ADDR_STR2
2559 "BGP attribute is propagated unchanged to this neighbor\n"
2560 "Nexthop attribute\n"
2561 "Med attribute\n"
2562 "As-path attribute\n")
2563
2564ALIAS (no_neighbor_attr_unchanged,
2565 no_neighbor_attr_unchanged8_cmd,
2566 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
2567 NO_STR
2568 NEIGHBOR_STR
2569 NEIGHBOR_ADDR_STR2
2570 "BGP attribute is propagated unchanged to this neighbor\n"
2571 "Nexthop attribute\n"
2572 "As-path attribute\n"
2573 "Med attribute\n")
2574
2575ALIAS (no_neighbor_attr_unchanged,
2576 no_neighbor_attr_unchanged9_cmd,
2577 NO_NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
2578 NO_STR
2579 NEIGHBOR_STR
2580 NEIGHBOR_ADDR_STR2
2581 "BGP attribute is propagated unchanged to this neighbor\n"
2582 "Med attribute\n"
2583 "Nexthop attribute\n"
2584 "As-path attribute\n")
2585
2586ALIAS (no_neighbor_attr_unchanged,
2587 no_neighbor_attr_unchanged10_cmd,
2588 NO_NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
2589 NO_STR
2590 NEIGHBOR_STR
2591 NEIGHBOR_ADDR_STR2
2592 "BGP attribute is propagated unchanged to this neighbor\n"
2593 "Med attribute\n"
2594 "As-path attribute\n"
2595 "Nexthop attribute\n")
2596
2597/* For old version Zebra compatibility. */
hassodd4c5932005-02-02 17:15:34 +00002598DEFUN_DEPRECATED (neighbor_transparent_as,
2599 neighbor_transparent_as_cmd,
2600 NEIGHBOR_CMD "transparent-as",
2601 NEIGHBOR_STR
2602 NEIGHBOR_ADDR_STR
2603 "Do not append my AS number even peer is EBGP peer\n")
paul718e3742002-12-13 20:15:29 +00002604{
2605 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2606 bgp_node_safi (vty),
2607 PEER_FLAG_AS_PATH_UNCHANGED);
2608}
2609
hassodd4c5932005-02-02 17:15:34 +00002610DEFUN_DEPRECATED (neighbor_transparent_nexthop,
2611 neighbor_transparent_nexthop_cmd,
2612 NEIGHBOR_CMD "transparent-nexthop",
2613 NEIGHBOR_STR
2614 NEIGHBOR_ADDR_STR
2615 "Do not change nexthop even peer is EBGP peer\n")
paul718e3742002-12-13 20:15:29 +00002616{
2617 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2618 bgp_node_safi (vty),
2619 PEER_FLAG_NEXTHOP_UNCHANGED);
2620}
2621
2622/* EBGP multihop configuration. */
paul94f2b392005-06-28 12:44:16 +00002623static int
paulfd79ac92004-10-13 05:06:08 +00002624peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str,
2625 const char *ttl_str)
paul718e3742002-12-13 20:15:29 +00002626{
2627 struct peer *peer;
paulfd79ac92004-10-13 05:06:08 +00002628 unsigned int ttl;
paul718e3742002-12-13 20:15:29 +00002629
2630 peer = peer_and_group_lookup_vty (vty, ip_str);
2631 if (! peer)
2632 return CMD_WARNING;
2633
2634 if (! ttl_str)
2635 ttl = TTL_MAX;
2636 else
2637 VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, 255);
2638
2639 peer_ebgp_multihop_set (peer, ttl);
2640
2641 return CMD_SUCCESS;
2642}
2643
paul94f2b392005-06-28 12:44:16 +00002644static int
paulfd79ac92004-10-13 05:06:08 +00002645peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str)
paul718e3742002-12-13 20:15:29 +00002646{
2647 struct peer *peer;
2648
2649 peer = peer_and_group_lookup_vty (vty, ip_str);
2650 if (! peer)
2651 return CMD_WARNING;
2652
2653 peer_ebgp_multihop_unset (peer);
2654
2655 return CMD_SUCCESS;
2656}
2657
2658/* neighbor ebgp-multihop. */
2659DEFUN (neighbor_ebgp_multihop,
2660 neighbor_ebgp_multihop_cmd,
2661 NEIGHBOR_CMD2 "ebgp-multihop",
2662 NEIGHBOR_STR
2663 NEIGHBOR_ADDR_STR2
2664 "Allow EBGP neighbors not on directly connected networks\n")
2665{
2666 return peer_ebgp_multihop_set_vty (vty, argv[0], NULL);
2667}
2668
2669DEFUN (neighbor_ebgp_multihop_ttl,
2670 neighbor_ebgp_multihop_ttl_cmd,
2671 NEIGHBOR_CMD2 "ebgp-multihop <1-255>",
2672 NEIGHBOR_STR
2673 NEIGHBOR_ADDR_STR2
2674 "Allow EBGP neighbors not on directly connected networks\n"
2675 "maximum hop count\n")
2676{
2677 return peer_ebgp_multihop_set_vty (vty, argv[0], argv[1]);
2678}
2679
2680DEFUN (no_neighbor_ebgp_multihop,
2681 no_neighbor_ebgp_multihop_cmd,
2682 NO_NEIGHBOR_CMD2 "ebgp-multihop",
2683 NO_STR
2684 NEIGHBOR_STR
2685 NEIGHBOR_ADDR_STR2
2686 "Allow EBGP neighbors not on directly connected networks\n")
2687{
2688 return peer_ebgp_multihop_unset_vty (vty, argv[0]);
2689}
2690
2691ALIAS (no_neighbor_ebgp_multihop,
2692 no_neighbor_ebgp_multihop_ttl_cmd,
2693 NO_NEIGHBOR_CMD2 "ebgp-multihop <1-255>",
2694 NO_STR
2695 NEIGHBOR_STR
2696 NEIGHBOR_ADDR_STR2
2697 "Allow EBGP neighbors not on directly connected networks\n"
2698 "maximum hop count\n")
2699
hasso6ffd2072005-02-02 14:50:11 +00002700/* disable-connected-check */
2701DEFUN (neighbor_disable_connected_check,
2702 neighbor_disable_connected_check_cmd,
2703 NEIGHBOR_CMD2 "disable-connected-check",
2704 NEIGHBOR_STR
2705 NEIGHBOR_ADDR_STR2
2706 "one-hop away EBGP peer using loopback address\n")
2707{
2708 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
2709}
2710
2711DEFUN (no_neighbor_disable_connected_check,
2712 no_neighbor_disable_connected_check_cmd,
2713 NO_NEIGHBOR_CMD2 "disable-connected-check",
2714 NO_STR
2715 NEIGHBOR_STR
2716 NEIGHBOR_ADDR_STR2
2717 "one-hop away EBGP peer using loopback address\n")
2718{
2719 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
2720}
2721
paul718e3742002-12-13 20:15:29 +00002722/* Enforce multihop. */
hasso6ffd2072005-02-02 14:50:11 +00002723ALIAS (neighbor_disable_connected_check,
paul718e3742002-12-13 20:15:29 +00002724 neighbor_enforce_multihop_cmd,
2725 NEIGHBOR_CMD2 "enforce-multihop",
2726 NEIGHBOR_STR
2727 NEIGHBOR_ADDR_STR2
paule8e19462006-01-19 20:16:55 +00002728 "Enforce EBGP neighbors perform multihop\n")
paul718e3742002-12-13 20:15:29 +00002729
hasso6ffd2072005-02-02 14:50:11 +00002730/* Enforce multihop. */
2731ALIAS (no_neighbor_disable_connected_check,
paul718e3742002-12-13 20:15:29 +00002732 no_neighbor_enforce_multihop_cmd,
2733 NO_NEIGHBOR_CMD2 "enforce-multihop",
2734 NO_STR
2735 NEIGHBOR_STR
2736 NEIGHBOR_ADDR_STR2
paule8e19462006-01-19 20:16:55 +00002737 "Enforce EBGP neighbors perform multihop\n")
paul718e3742002-12-13 20:15:29 +00002738
2739DEFUN (neighbor_description,
2740 neighbor_description_cmd,
2741 NEIGHBOR_CMD2 "description .LINE",
2742 NEIGHBOR_STR
2743 NEIGHBOR_ADDR_STR2
2744 "Neighbor specific description\n"
2745 "Up to 80 characters describing this neighbor\n")
2746{
2747 struct peer *peer;
paul718e3742002-12-13 20:15:29 +00002748 char *str;
paul718e3742002-12-13 20:15:29 +00002749
2750 peer = peer_and_group_lookup_vty (vty, argv[0]);
2751 if (! peer)
2752 return CMD_WARNING;
2753
2754 if (argc == 1)
2755 return CMD_SUCCESS;
2756
ajs3b8b1852005-01-29 18:19:13 +00002757 str = argv_concat(argv, argc, 1);
paul718e3742002-12-13 20:15:29 +00002758
2759 peer_description_set (peer, str);
2760
ajs3b8b1852005-01-29 18:19:13 +00002761 XFREE (MTYPE_TMP, str);
paul718e3742002-12-13 20:15:29 +00002762
2763 return CMD_SUCCESS;
2764}
2765
2766DEFUN (no_neighbor_description,
2767 no_neighbor_description_cmd,
2768 NO_NEIGHBOR_CMD2 "description",
2769 NO_STR
2770 NEIGHBOR_STR
2771 NEIGHBOR_ADDR_STR2
2772 "Neighbor specific description\n")
2773{
2774 struct peer *peer;
2775
2776 peer = peer_and_group_lookup_vty (vty, argv[0]);
2777 if (! peer)
2778 return CMD_WARNING;
2779
2780 peer_description_unset (peer);
2781
2782 return CMD_SUCCESS;
2783}
2784
2785ALIAS (no_neighbor_description,
2786 no_neighbor_description_val_cmd,
2787 NO_NEIGHBOR_CMD2 "description .LINE",
2788 NO_STR
2789 NEIGHBOR_STR
2790 NEIGHBOR_ADDR_STR2
2791 "Neighbor specific description\n"
2792 "Up to 80 characters describing this neighbor\n")
2793
2794/* Neighbor update-source. */
paul94f2b392005-06-28 12:44:16 +00002795static int
paulfd79ac92004-10-13 05:06:08 +00002796peer_update_source_vty (struct vty *vty, const char *peer_str,
2797 const char *source_str)
paul718e3742002-12-13 20:15:29 +00002798{
2799 struct peer *peer;
2800 union sockunion *su;
2801
2802 peer = peer_and_group_lookup_vty (vty, peer_str);
2803 if (! peer)
2804 return CMD_WARNING;
2805
2806 if (source_str)
2807 {
2808 su = sockunion_str2su (source_str);
2809 if (su)
2810 {
2811 peer_update_source_addr_set (peer, su);
2812 sockunion_free (su);
2813 }
2814 else
2815 peer_update_source_if_set (peer, source_str);
2816 }
2817 else
2818 peer_update_source_unset (peer);
2819
2820 return CMD_SUCCESS;
2821}
2822
Paul Jakma9a1a3312009-07-27 12:27:55 +01002823#define BGP_UPDATE_SOURCE_STR "(A.B.C.D|X:X::X:X|WORD)"
Paul Jakma369688c2006-05-23 22:27:55 +00002824#define BGP_UPDATE_SOURCE_HELP_STR \
2825 "IPv4 address\n" \
Paul Jakma9a1a3312009-07-27 12:27:55 +01002826 "IPv6 address\n" \
2827 "Interface name (requires zebra to be running)\n"
Paul Jakma369688c2006-05-23 22:27:55 +00002828
paul718e3742002-12-13 20:15:29 +00002829DEFUN (neighbor_update_source,
2830 neighbor_update_source_cmd,
Paul Jakma369688c2006-05-23 22:27:55 +00002831 NEIGHBOR_CMD2 "update-source " BGP_UPDATE_SOURCE_STR,
paul718e3742002-12-13 20:15:29 +00002832 NEIGHBOR_STR
2833 NEIGHBOR_ADDR_STR2
2834 "Source of routing updates\n"
Paul Jakma369688c2006-05-23 22:27:55 +00002835 BGP_UPDATE_SOURCE_HELP_STR)
paul718e3742002-12-13 20:15:29 +00002836{
2837 return peer_update_source_vty (vty, argv[0], argv[1]);
2838}
2839
2840DEFUN (no_neighbor_update_source,
2841 no_neighbor_update_source_cmd,
2842 NO_NEIGHBOR_CMD2 "update-source",
2843 NO_STR
2844 NEIGHBOR_STR
2845 NEIGHBOR_ADDR_STR2
Paul Jakma369688c2006-05-23 22:27:55 +00002846 "Source of routing updates\n")
paul718e3742002-12-13 20:15:29 +00002847{
2848 return peer_update_source_vty (vty, argv[0], NULL);
2849}
2850
paul94f2b392005-06-28 12:44:16 +00002851static int
paulfd79ac92004-10-13 05:06:08 +00002852peer_default_originate_set_vty (struct vty *vty, const char *peer_str,
2853 afi_t afi, safi_t safi,
2854 const char *rmap, int set)
paul718e3742002-12-13 20:15:29 +00002855{
2856 int ret;
2857 struct peer *peer;
2858
2859 peer = peer_and_group_lookup_vty (vty, peer_str);
2860 if (! peer)
2861 return CMD_WARNING;
2862
2863 if (set)
2864 ret = peer_default_originate_set (peer, afi, safi, rmap);
2865 else
2866 ret = peer_default_originate_unset (peer, afi, safi);
2867
2868 return bgp_vty_return (vty, ret);
2869}
2870
2871/* neighbor default-originate. */
2872DEFUN (neighbor_default_originate,
2873 neighbor_default_originate_cmd,
2874 NEIGHBOR_CMD2 "default-originate",
2875 NEIGHBOR_STR
2876 NEIGHBOR_ADDR_STR2
2877 "Originate default route to this neighbor\n")
2878{
2879 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
2880 bgp_node_safi (vty), NULL, 1);
2881}
2882
2883DEFUN (neighbor_default_originate_rmap,
2884 neighbor_default_originate_rmap_cmd,
2885 NEIGHBOR_CMD2 "default-originate route-map WORD",
2886 NEIGHBOR_STR
2887 NEIGHBOR_ADDR_STR2
2888 "Originate default route to this neighbor\n"
2889 "Route-map to specify criteria to originate default\n"
2890 "route-map name\n")
2891{
2892 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
2893 bgp_node_safi (vty), argv[1], 1);
2894}
2895
2896DEFUN (no_neighbor_default_originate,
2897 no_neighbor_default_originate_cmd,
2898 NO_NEIGHBOR_CMD2 "default-originate",
2899 NO_STR
2900 NEIGHBOR_STR
2901 NEIGHBOR_ADDR_STR2
2902 "Originate default route to this neighbor\n")
2903{
2904 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
2905 bgp_node_safi (vty), NULL, 0);
2906}
2907
2908ALIAS (no_neighbor_default_originate,
2909 no_neighbor_default_originate_rmap_cmd,
2910 NO_NEIGHBOR_CMD2 "default-originate route-map WORD",
2911 NO_STR
2912 NEIGHBOR_STR
2913 NEIGHBOR_ADDR_STR2
2914 "Originate default route to this neighbor\n"
2915 "Route-map to specify criteria to originate default\n"
2916 "route-map name\n")
2917
2918/* Set neighbor's BGP port. */
paul94f2b392005-06-28 12:44:16 +00002919static int
paulfd79ac92004-10-13 05:06:08 +00002920peer_port_vty (struct vty *vty, const char *ip_str, int afi,
2921 const char *port_str)
paul718e3742002-12-13 20:15:29 +00002922{
2923 struct peer *peer;
2924 u_int16_t port;
2925 struct servent *sp;
2926
2927 peer = peer_lookup_vty (vty, ip_str);
2928 if (! peer)
2929 return CMD_WARNING;
2930
2931 if (! port_str)
2932 {
2933 sp = getservbyname ("bgp", "tcp");
2934 port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port);
2935 }
2936 else
2937 {
2938 VTY_GET_INTEGER("port", port, port_str);
2939 }
2940
2941 peer_port_set (peer, port);
2942
2943 return CMD_SUCCESS;
2944}
2945
hassof4184462005-02-01 20:13:16 +00002946/* Set specified peer's BGP port. */
paul718e3742002-12-13 20:15:29 +00002947DEFUN (neighbor_port,
2948 neighbor_port_cmd,
2949 NEIGHBOR_CMD "port <0-65535>",
2950 NEIGHBOR_STR
2951 NEIGHBOR_ADDR_STR
2952 "Neighbor's BGP port\n"
2953 "TCP port number\n")
2954{
2955 return peer_port_vty (vty, argv[0], AFI_IP, argv[1]);
2956}
2957
2958DEFUN (no_neighbor_port,
2959 no_neighbor_port_cmd,
2960 NO_NEIGHBOR_CMD "port",
2961 NO_STR
2962 NEIGHBOR_STR
2963 NEIGHBOR_ADDR_STR
2964 "Neighbor's BGP port\n")
2965{
2966 return peer_port_vty (vty, argv[0], AFI_IP, NULL);
2967}
2968
2969ALIAS (no_neighbor_port,
2970 no_neighbor_port_val_cmd,
2971 NO_NEIGHBOR_CMD "port <0-65535>",
2972 NO_STR
2973 NEIGHBOR_STR
2974 NEIGHBOR_ADDR_STR
2975 "Neighbor's BGP port\n"
2976 "TCP port number\n")
2977
2978/* neighbor weight. */
paul94f2b392005-06-28 12:44:16 +00002979static int
paulfd79ac92004-10-13 05:06:08 +00002980peer_weight_set_vty (struct vty *vty, const char *ip_str,
2981 const char *weight_str)
paul718e3742002-12-13 20:15:29 +00002982{
2983 int ret;
2984 struct peer *peer;
2985 unsigned long weight;
2986
2987 peer = peer_and_group_lookup_vty (vty, ip_str);
2988 if (! peer)
2989 return CMD_WARNING;
2990
2991 VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535);
2992
2993 ret = peer_weight_set (peer, weight);
2994
2995 return CMD_SUCCESS;
2996}
2997
paul94f2b392005-06-28 12:44:16 +00002998static int
paulfd79ac92004-10-13 05:06:08 +00002999peer_weight_unset_vty (struct vty *vty, const char *ip_str)
paul718e3742002-12-13 20:15:29 +00003000{
3001 struct peer *peer;
3002
3003 peer = peer_and_group_lookup_vty (vty, ip_str);
3004 if (! peer)
3005 return CMD_WARNING;
3006
3007 peer_weight_unset (peer);
3008
3009 return CMD_SUCCESS;
3010}
3011
3012DEFUN (neighbor_weight,
3013 neighbor_weight_cmd,
3014 NEIGHBOR_CMD2 "weight <0-65535>",
3015 NEIGHBOR_STR
3016 NEIGHBOR_ADDR_STR2
3017 "Set default weight for routes from this neighbor\n"
3018 "default weight\n")
3019{
3020 return peer_weight_set_vty (vty, argv[0], argv[1]);
3021}
3022
3023DEFUN (no_neighbor_weight,
3024 no_neighbor_weight_cmd,
3025 NO_NEIGHBOR_CMD2 "weight",
3026 NO_STR
3027 NEIGHBOR_STR
3028 NEIGHBOR_ADDR_STR2
3029 "Set default weight for routes from this neighbor\n")
3030{
3031 return peer_weight_unset_vty (vty, argv[0]);
3032}
3033
3034ALIAS (no_neighbor_weight,
3035 no_neighbor_weight_val_cmd,
3036 NO_NEIGHBOR_CMD2 "weight <0-65535>",
3037 NO_STR
3038 NEIGHBOR_STR
3039 NEIGHBOR_ADDR_STR2
3040 "Set default weight for routes from this neighbor\n"
3041 "default weight\n")
3042
3043/* Override capability negotiation. */
3044DEFUN (neighbor_override_capability,
3045 neighbor_override_capability_cmd,
3046 NEIGHBOR_CMD2 "override-capability",
3047 NEIGHBOR_STR
3048 NEIGHBOR_ADDR_STR2
3049 "Override capability negotiation result\n")
3050{
3051 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
3052}
3053
3054DEFUN (no_neighbor_override_capability,
3055 no_neighbor_override_capability_cmd,
3056 NO_NEIGHBOR_CMD2 "override-capability",
3057 NO_STR
3058 NEIGHBOR_STR
3059 NEIGHBOR_ADDR_STR2
3060 "Override capability negotiation result\n")
3061{
3062 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
3063}
3064
3065DEFUN (neighbor_strict_capability,
3066 neighbor_strict_capability_cmd,
3067 NEIGHBOR_CMD "strict-capability-match",
3068 NEIGHBOR_STR
3069 NEIGHBOR_ADDR_STR
3070 "Strict capability negotiation match\n")
3071{
3072 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
3073}
3074
3075DEFUN (no_neighbor_strict_capability,
3076 no_neighbor_strict_capability_cmd,
3077 NO_NEIGHBOR_CMD "strict-capability-match",
3078 NO_STR
3079 NEIGHBOR_STR
3080 NEIGHBOR_ADDR_STR
3081 "Strict capability negotiation match\n")
3082{
3083 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
3084}
3085
paul94f2b392005-06-28 12:44:16 +00003086static int
paulfd79ac92004-10-13 05:06:08 +00003087peer_timers_set_vty (struct vty *vty, const char *ip_str,
3088 const char *keep_str, const char *hold_str)
paul718e3742002-12-13 20:15:29 +00003089{
3090 int ret;
3091 struct peer *peer;
3092 u_int32_t keepalive;
3093 u_int32_t holdtime;
3094
3095 peer = peer_and_group_lookup_vty (vty, ip_str);
3096 if (! peer)
3097 return CMD_WARNING;
3098
3099 VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535);
3100 VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535);
3101
3102 ret = peer_timers_set (peer, keepalive, holdtime);
3103
3104 return bgp_vty_return (vty, ret);
3105}
3106
paul94f2b392005-06-28 12:44:16 +00003107static int
paulfd79ac92004-10-13 05:06:08 +00003108peer_timers_unset_vty (struct vty *vty, const char *ip_str)
paul718e3742002-12-13 20:15:29 +00003109{
3110 int ret;
3111 struct peer *peer;
3112
3113 peer = peer_lookup_vty (vty, ip_str);
3114 if (! peer)
3115 return CMD_WARNING;
3116
3117 ret = peer_timers_unset (peer);
3118
3119 return bgp_vty_return (vty, ret);
3120}
3121
3122DEFUN (neighbor_timers,
3123 neighbor_timers_cmd,
3124 NEIGHBOR_CMD2 "timers <0-65535> <0-65535>",
3125 NEIGHBOR_STR
3126 NEIGHBOR_ADDR_STR2
3127 "BGP per neighbor timers\n"
3128 "Keepalive interval\n"
3129 "Holdtime\n")
3130{
3131 return peer_timers_set_vty (vty, argv[0], argv[1], argv[2]);
3132}
3133
3134DEFUN (no_neighbor_timers,
3135 no_neighbor_timers_cmd,
3136 NO_NEIGHBOR_CMD2 "timers",
3137 NO_STR
3138 NEIGHBOR_STR
3139 NEIGHBOR_ADDR_STR2
3140 "BGP per neighbor timers\n")
3141{
3142 return peer_timers_unset_vty (vty, argv[0]);
3143}
3144
paul94f2b392005-06-28 12:44:16 +00003145static int
paulfd79ac92004-10-13 05:06:08 +00003146peer_timers_connect_set_vty (struct vty *vty, const char *ip_str,
3147 const char *time_str)
paul718e3742002-12-13 20:15:29 +00003148{
3149 int ret;
3150 struct peer *peer;
3151 u_int32_t connect;
3152
3153 peer = peer_lookup_vty (vty, ip_str);
3154 if (! peer)
3155 return CMD_WARNING;
3156
3157 VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535);
3158
3159 ret = peer_timers_connect_set (peer, connect);
3160
3161 return CMD_SUCCESS;
3162}
3163
paul94f2b392005-06-28 12:44:16 +00003164static int
paulfd79ac92004-10-13 05:06:08 +00003165peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str)
paul718e3742002-12-13 20:15:29 +00003166{
3167 int ret;
3168 struct peer *peer;
3169
3170 peer = peer_and_group_lookup_vty (vty, ip_str);
3171 if (! peer)
3172 return CMD_WARNING;
3173
3174 ret = peer_timers_connect_unset (peer);
3175
3176 return CMD_SUCCESS;
3177}
3178
3179DEFUN (neighbor_timers_connect,
3180 neighbor_timers_connect_cmd,
3181 NEIGHBOR_CMD "timers connect <0-65535>",
3182 NEIGHBOR_STR
3183 NEIGHBOR_ADDR_STR
3184 "BGP per neighbor timers\n"
3185 "BGP connect timer\n"
3186 "Connect timer\n")
3187{
3188 return peer_timers_connect_set_vty (vty, argv[0], argv[1]);
3189}
3190
3191DEFUN (no_neighbor_timers_connect,
3192 no_neighbor_timers_connect_cmd,
3193 NO_NEIGHBOR_CMD "timers connect",
3194 NO_STR
3195 NEIGHBOR_STR
3196 NEIGHBOR_ADDR_STR
3197 "BGP per neighbor timers\n"
3198 "BGP connect timer\n")
3199{
3200 return peer_timers_connect_unset_vty (vty, argv[0]);
3201}
3202
3203ALIAS (no_neighbor_timers_connect,
3204 no_neighbor_timers_connect_val_cmd,
3205 NO_NEIGHBOR_CMD "timers connect <0-65535>",
3206 NO_STR
3207 NEIGHBOR_STR
3208 NEIGHBOR_ADDR_STR
3209 "BGP per neighbor timers\n"
3210 "BGP connect timer\n"
3211 "Connect timer\n")
3212
paul94f2b392005-06-28 12:44:16 +00003213static int
paulfd79ac92004-10-13 05:06:08 +00003214peer_advertise_interval_vty (struct vty *vty, const char *ip_str,
3215 const char *time_str, int set)
paul718e3742002-12-13 20:15:29 +00003216{
3217 int ret;
3218 struct peer *peer;
3219 u_int32_t routeadv = 0;
3220
3221 peer = peer_lookup_vty (vty, ip_str);
3222 if (! peer)
3223 return CMD_WARNING;
3224
3225 if (time_str)
3226 VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600);
3227
3228 if (set)
3229 ret = peer_advertise_interval_set (peer, routeadv);
3230 else
3231 ret = peer_advertise_interval_unset (peer);
3232
3233 return CMD_SUCCESS;
3234}
3235
3236DEFUN (neighbor_advertise_interval,
3237 neighbor_advertise_interval_cmd,
3238 NEIGHBOR_CMD "advertisement-interval <0-600>",
3239 NEIGHBOR_STR
3240 NEIGHBOR_ADDR_STR
3241 "Minimum interval between sending BGP routing updates\n"
3242 "time in seconds\n")
3243{
3244 return peer_advertise_interval_vty (vty, argv[0], argv[1], 1);
3245}
3246
3247DEFUN (no_neighbor_advertise_interval,
3248 no_neighbor_advertise_interval_cmd,
3249 NO_NEIGHBOR_CMD "advertisement-interval",
3250 NO_STR
3251 NEIGHBOR_STR
3252 NEIGHBOR_ADDR_STR
3253 "Minimum interval between sending BGP routing updates\n")
3254{
3255 return peer_advertise_interval_vty (vty, argv[0], NULL, 0);
3256}
3257
3258ALIAS (no_neighbor_advertise_interval,
3259 no_neighbor_advertise_interval_val_cmd,
3260 NO_NEIGHBOR_CMD "advertisement-interval <0-600>",
3261 NO_STR
3262 NEIGHBOR_STR
3263 NEIGHBOR_ADDR_STR
3264 "Minimum interval between sending BGP routing updates\n"
3265 "time in seconds\n")
3266
paul718e3742002-12-13 20:15:29 +00003267/* neighbor interface */
paul94f2b392005-06-28 12:44:16 +00003268static int
paulfd79ac92004-10-13 05:06:08 +00003269peer_interface_vty (struct vty *vty, const char *ip_str, const char *str)
paul718e3742002-12-13 20:15:29 +00003270{
3271 int ret;
3272 struct peer *peer;
3273
3274 peer = peer_lookup_vty (vty, ip_str);
3275 if (! peer)
3276 return CMD_WARNING;
3277
3278 if (str)
3279 ret = peer_interface_set (peer, str);
3280 else
3281 ret = peer_interface_unset (peer);
3282
3283 return CMD_SUCCESS;
3284}
3285
3286DEFUN (neighbor_interface,
3287 neighbor_interface_cmd,
3288 NEIGHBOR_CMD "interface WORD",
3289 NEIGHBOR_STR
3290 NEIGHBOR_ADDR_STR
3291 "Interface\n"
3292 "Interface name\n")
3293{
3294 return peer_interface_vty (vty, argv[0], argv[1]);
3295}
3296
3297DEFUN (no_neighbor_interface,
3298 no_neighbor_interface_cmd,
3299 NO_NEIGHBOR_CMD "interface WORD",
3300 NO_STR
3301 NEIGHBOR_STR
3302 NEIGHBOR_ADDR_STR
3303 "Interface\n"
3304 "Interface name\n")
3305{
3306 return peer_interface_vty (vty, argv[0], NULL);
3307}
3308
3309/* Set distribute list to the peer. */
paul94f2b392005-06-28 12:44:16 +00003310static int
paulfd79ac92004-10-13 05:06:08 +00003311peer_distribute_set_vty (struct vty *vty, const char *ip_str,
3312 afi_t afi, safi_t safi,
3313 const char *name_str, const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003314{
3315 int ret;
3316 struct peer *peer;
3317 int direct = FILTER_IN;
3318
3319 peer = peer_and_group_lookup_vty (vty, ip_str);
3320 if (! peer)
3321 return CMD_WARNING;
3322
3323 /* Check filter direction. */
3324 if (strncmp (direct_str, "i", 1) == 0)
3325 direct = FILTER_IN;
3326 else if (strncmp (direct_str, "o", 1) == 0)
3327 direct = FILTER_OUT;
3328
3329 ret = peer_distribute_set (peer, afi, safi, direct, name_str);
3330
3331 return bgp_vty_return (vty, ret);
3332}
3333
paul94f2b392005-06-28 12:44:16 +00003334static int
paulfd79ac92004-10-13 05:06:08 +00003335peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
3336 safi_t safi, const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003337{
3338 int ret;
3339 struct peer *peer;
3340 int direct = FILTER_IN;
3341
3342 peer = peer_and_group_lookup_vty (vty, ip_str);
3343 if (! peer)
3344 return CMD_WARNING;
3345
3346 /* Check filter direction. */
3347 if (strncmp (direct_str, "i", 1) == 0)
3348 direct = FILTER_IN;
3349 else if (strncmp (direct_str, "o", 1) == 0)
3350 direct = FILTER_OUT;
3351
3352 ret = peer_distribute_unset (peer, afi, safi, direct);
3353
3354 return bgp_vty_return (vty, ret);
3355}
3356
3357DEFUN (neighbor_distribute_list,
3358 neighbor_distribute_list_cmd,
3359 NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
3360 NEIGHBOR_STR
3361 NEIGHBOR_ADDR_STR2
3362 "Filter updates to/from this neighbor\n"
3363 "IP access-list number\n"
3364 "IP access-list number (expanded range)\n"
3365 "IP Access-list name\n"
3366 "Filter incoming updates\n"
3367 "Filter outgoing updates\n")
3368{
3369 return peer_distribute_set_vty (vty, argv[0], bgp_node_afi (vty),
3370 bgp_node_safi (vty), argv[1], argv[2]);
3371}
3372
3373DEFUN (no_neighbor_distribute_list,
3374 no_neighbor_distribute_list_cmd,
3375 NO_NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
3376 NO_STR
3377 NEIGHBOR_STR
3378 NEIGHBOR_ADDR_STR2
3379 "Filter updates to/from this neighbor\n"
3380 "IP access-list number\n"
3381 "IP access-list number (expanded range)\n"
3382 "IP Access-list name\n"
3383 "Filter incoming updates\n"
3384 "Filter outgoing updates\n")
3385{
3386 return peer_distribute_unset_vty (vty, argv[0], bgp_node_afi (vty),
3387 bgp_node_safi (vty), argv[2]);
3388}
3389
3390/* Set prefix list to the peer. */
paul94f2b392005-06-28 12:44:16 +00003391static int
paulfd79ac92004-10-13 05:06:08 +00003392peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
3393 safi_t safi, const char *name_str,
3394 const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003395{
3396 int ret;
3397 struct peer *peer;
3398 int direct = FILTER_IN;
3399
3400 peer = peer_and_group_lookup_vty (vty, ip_str);
3401 if (! peer)
3402 return CMD_WARNING;
3403
3404 /* Check filter direction. */
3405 if (strncmp (direct_str, "i", 1) == 0)
3406 direct = FILTER_IN;
3407 else if (strncmp (direct_str, "o", 1) == 0)
3408 direct = FILTER_OUT;
3409
3410 ret = peer_prefix_list_set (peer, afi, safi, direct, name_str);
3411
3412 return bgp_vty_return (vty, ret);
3413}
3414
paul94f2b392005-06-28 12:44:16 +00003415static int
paulfd79ac92004-10-13 05:06:08 +00003416peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
3417 safi_t safi, const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003418{
3419 int ret;
3420 struct peer *peer;
3421 int direct = FILTER_IN;
3422
3423 peer = peer_and_group_lookup_vty (vty, ip_str);
3424 if (! peer)
3425 return CMD_WARNING;
3426
3427 /* Check filter direction. */
3428 if (strncmp (direct_str, "i", 1) == 0)
3429 direct = FILTER_IN;
3430 else if (strncmp (direct_str, "o", 1) == 0)
3431 direct = FILTER_OUT;
3432
3433 ret = peer_prefix_list_unset (peer, afi, safi, direct);
3434
3435 return bgp_vty_return (vty, ret);
3436}
3437
3438DEFUN (neighbor_prefix_list,
3439 neighbor_prefix_list_cmd,
3440 NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
3441 NEIGHBOR_STR
3442 NEIGHBOR_ADDR_STR2
3443 "Filter updates to/from this neighbor\n"
3444 "Name of a prefix list\n"
3445 "Filter incoming updates\n"
3446 "Filter outgoing updates\n")
3447{
3448 return peer_prefix_list_set_vty (vty, argv[0], bgp_node_afi (vty),
3449 bgp_node_safi (vty), argv[1], argv[2]);
3450}
3451
3452DEFUN (no_neighbor_prefix_list,
3453 no_neighbor_prefix_list_cmd,
3454 NO_NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
3455 NO_STR
3456 NEIGHBOR_STR
3457 NEIGHBOR_ADDR_STR2
3458 "Filter updates to/from this neighbor\n"
3459 "Name of a prefix list\n"
3460 "Filter incoming updates\n"
3461 "Filter outgoing updates\n")
3462{
3463 return peer_prefix_list_unset_vty (vty, argv[0], bgp_node_afi (vty),
3464 bgp_node_safi (vty), argv[2]);
3465}
3466
paul94f2b392005-06-28 12:44:16 +00003467static int
paulfd79ac92004-10-13 05:06:08 +00003468peer_aslist_set_vty (struct vty *vty, const char *ip_str,
3469 afi_t afi, safi_t safi,
3470 const char *name_str, const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003471{
3472 int ret;
3473 struct peer *peer;
3474 int direct = FILTER_IN;
3475
3476 peer = peer_and_group_lookup_vty (vty, ip_str);
3477 if (! peer)
3478 return CMD_WARNING;
3479
3480 /* Check filter direction. */
3481 if (strncmp (direct_str, "i", 1) == 0)
3482 direct = FILTER_IN;
3483 else if (strncmp (direct_str, "o", 1) == 0)
3484 direct = FILTER_OUT;
3485
3486 ret = peer_aslist_set (peer, afi, safi, direct, name_str);
3487
3488 return bgp_vty_return (vty, ret);
3489}
3490
paul94f2b392005-06-28 12:44:16 +00003491static int
paulfd79ac92004-10-13 05:06:08 +00003492peer_aslist_unset_vty (struct vty *vty, const char *ip_str,
3493 afi_t afi, safi_t safi,
3494 const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003495{
3496 int ret;
3497 struct peer *peer;
3498 int direct = FILTER_IN;
3499
3500 peer = peer_and_group_lookup_vty (vty, ip_str);
3501 if (! peer)
3502 return CMD_WARNING;
3503
3504 /* Check filter direction. */
3505 if (strncmp (direct_str, "i", 1) == 0)
3506 direct = FILTER_IN;
3507 else if (strncmp (direct_str, "o", 1) == 0)
3508 direct = FILTER_OUT;
3509
3510 ret = peer_aslist_unset (peer, afi, safi, direct);
3511
3512 return bgp_vty_return (vty, ret);
3513}
3514
3515DEFUN (neighbor_filter_list,
3516 neighbor_filter_list_cmd,
3517 NEIGHBOR_CMD2 "filter-list WORD (in|out)",
3518 NEIGHBOR_STR
3519 NEIGHBOR_ADDR_STR2
3520 "Establish BGP filters\n"
3521 "AS path access-list name\n"
3522 "Filter incoming routes\n"
3523 "Filter outgoing routes\n")
3524{
3525 return peer_aslist_set_vty (vty, argv[0], bgp_node_afi (vty),
3526 bgp_node_safi (vty), argv[1], argv[2]);
3527}
3528
3529DEFUN (no_neighbor_filter_list,
3530 no_neighbor_filter_list_cmd,
3531 NO_NEIGHBOR_CMD2 "filter-list WORD (in|out)",
3532 NO_STR
3533 NEIGHBOR_STR
3534 NEIGHBOR_ADDR_STR2
3535 "Establish BGP filters\n"
3536 "AS path access-list name\n"
3537 "Filter incoming routes\n"
3538 "Filter outgoing routes\n")
3539{
3540 return peer_aslist_unset_vty (vty, argv[0], bgp_node_afi (vty),
3541 bgp_node_safi (vty), argv[2]);
3542}
3543
3544/* Set route-map to the peer. */
paul94f2b392005-06-28 12:44:16 +00003545static int
paulfd79ac92004-10-13 05:06:08 +00003546peer_route_map_set_vty (struct vty *vty, const char *ip_str,
3547 afi_t afi, safi_t safi,
3548 const char *name_str, const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003549{
3550 int ret;
3551 struct peer *peer;
paulfee0f4c2004-09-13 05:12:46 +00003552 int direct = RMAP_IN;
paul718e3742002-12-13 20:15:29 +00003553
3554 peer = peer_and_group_lookup_vty (vty, ip_str);
3555 if (! peer)
3556 return CMD_WARNING;
3557
3558 /* Check filter direction. */
paulfee0f4c2004-09-13 05:12:46 +00003559 if (strncmp (direct_str, "in", 2) == 0)
3560 direct = RMAP_IN;
paul718e3742002-12-13 20:15:29 +00003561 else if (strncmp (direct_str, "o", 1) == 0)
paulfee0f4c2004-09-13 05:12:46 +00003562 direct = RMAP_OUT;
3563 else if (strncmp (direct_str, "im", 2) == 0)
3564 direct = RMAP_IMPORT;
3565 else if (strncmp (direct_str, "e", 1) == 0)
3566 direct = RMAP_EXPORT;
paul718e3742002-12-13 20:15:29 +00003567
3568 ret = peer_route_map_set (peer, afi, safi, direct, name_str);
3569
3570 return bgp_vty_return (vty, ret);
3571}
3572
paul94f2b392005-06-28 12:44:16 +00003573static int
paulfd79ac92004-10-13 05:06:08 +00003574peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
3575 safi_t safi, const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003576{
3577 int ret;
3578 struct peer *peer;
paulfee0f4c2004-09-13 05:12:46 +00003579 int direct = RMAP_IN;
paul718e3742002-12-13 20:15:29 +00003580
3581 peer = peer_and_group_lookup_vty (vty, ip_str);
3582 if (! peer)
3583 return CMD_WARNING;
3584
3585 /* Check filter direction. */
paulfee0f4c2004-09-13 05:12:46 +00003586 if (strncmp (direct_str, "in", 2) == 0)
3587 direct = RMAP_IN;
paul718e3742002-12-13 20:15:29 +00003588 else if (strncmp (direct_str, "o", 1) == 0)
paulfee0f4c2004-09-13 05:12:46 +00003589 direct = RMAP_OUT;
3590 else if (strncmp (direct_str, "im", 2) == 0)
3591 direct = RMAP_IMPORT;
3592 else if (strncmp (direct_str, "e", 1) == 0)
3593 direct = RMAP_EXPORT;
paul718e3742002-12-13 20:15:29 +00003594
3595 ret = peer_route_map_unset (peer, afi, safi, direct);
3596
3597 return bgp_vty_return (vty, ret);
3598}
3599
3600DEFUN (neighbor_route_map,
3601 neighbor_route_map_cmd,
paulfee0f4c2004-09-13 05:12:46 +00003602 NEIGHBOR_CMD2 "route-map WORD (in|out|import|export)",
paul718e3742002-12-13 20:15:29 +00003603 NEIGHBOR_STR
3604 NEIGHBOR_ADDR_STR2
3605 "Apply route map to neighbor\n"
3606 "Name of route map\n"
3607 "Apply map to incoming routes\n"
paulfee0f4c2004-09-13 05:12:46 +00003608 "Apply map to outbound routes\n"
3609 "Apply map to routes going into a Route-Server client's table\n"
3610 "Apply map to routes coming from a Route-Server client")
paul718e3742002-12-13 20:15:29 +00003611{
3612 return peer_route_map_set_vty (vty, argv[0], bgp_node_afi (vty),
3613 bgp_node_safi (vty), argv[1], argv[2]);
3614}
3615
3616DEFUN (no_neighbor_route_map,
3617 no_neighbor_route_map_cmd,
paulfee0f4c2004-09-13 05:12:46 +00003618 NO_NEIGHBOR_CMD2 "route-map WORD (in|out|import|export)",
paul718e3742002-12-13 20:15:29 +00003619 NO_STR
3620 NEIGHBOR_STR
3621 NEIGHBOR_ADDR_STR2
3622 "Apply route map to neighbor\n"
3623 "Name of route map\n"
3624 "Apply map to incoming routes\n"
paulfee0f4c2004-09-13 05:12:46 +00003625 "Apply map to outbound routes\n"
3626 "Apply map to routes going into a Route-Server client's table\n"
3627 "Apply map to routes coming from a Route-Server client")
paul718e3742002-12-13 20:15:29 +00003628{
3629 return peer_route_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
3630 bgp_node_safi (vty), argv[2]);
3631}
3632
3633/* Set unsuppress-map to the peer. */
paul94f2b392005-06-28 12:44:16 +00003634static int
paulfd79ac92004-10-13 05:06:08 +00003635peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
3636 safi_t safi, const char *name_str)
paul718e3742002-12-13 20:15:29 +00003637{
3638 int ret;
3639 struct peer *peer;
3640
3641 peer = peer_and_group_lookup_vty (vty, ip_str);
3642 if (! peer)
3643 return CMD_WARNING;
3644
3645 ret = peer_unsuppress_map_set (peer, afi, safi, name_str);
3646
3647 return bgp_vty_return (vty, ret);
3648}
3649
3650/* Unset route-map from the peer. */
paul94f2b392005-06-28 12:44:16 +00003651static int
paulfd79ac92004-10-13 05:06:08 +00003652peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00003653 safi_t safi)
3654{
3655 int ret;
3656 struct peer *peer;
3657
3658 peer = peer_and_group_lookup_vty (vty, ip_str);
3659 if (! peer)
3660 return CMD_WARNING;
3661
3662 ret = peer_unsuppress_map_unset (peer, afi, safi);
3663
3664 return bgp_vty_return (vty, ret);
3665}
3666
3667DEFUN (neighbor_unsuppress_map,
3668 neighbor_unsuppress_map_cmd,
3669 NEIGHBOR_CMD2 "unsuppress-map WORD",
3670 NEIGHBOR_STR
3671 NEIGHBOR_ADDR_STR2
3672 "Route-map to selectively unsuppress suppressed routes\n"
3673 "Name of route map\n")
3674{
3675 return peer_unsuppress_map_set_vty (vty, argv[0], bgp_node_afi (vty),
3676 bgp_node_safi (vty), argv[1]);
3677}
3678
3679DEFUN (no_neighbor_unsuppress_map,
3680 no_neighbor_unsuppress_map_cmd,
3681 NO_NEIGHBOR_CMD2 "unsuppress-map WORD",
3682 NO_STR
3683 NEIGHBOR_STR
3684 NEIGHBOR_ADDR_STR2
3685 "Route-map to selectively unsuppress suppressed routes\n"
3686 "Name of route map\n")
3687{
3688 return peer_unsuppress_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
3689 bgp_node_safi (vty));
3690}
3691
paul94f2b392005-06-28 12:44:16 +00003692static int
paulfd79ac92004-10-13 05:06:08 +00003693peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
3694 safi_t safi, const char *num_str,
hasso0a486e52005-02-01 20:57:17 +00003695 const char *threshold_str, int warning,
3696 const char *restart_str)
paul718e3742002-12-13 20:15:29 +00003697{
3698 int ret;
3699 struct peer *peer;
3700 u_int32_t max;
hassoe0701b72004-05-20 09:19:34 +00003701 u_char threshold;
hasso0a486e52005-02-01 20:57:17 +00003702 u_int16_t restart;
paul718e3742002-12-13 20:15:29 +00003703
3704 peer = peer_and_group_lookup_vty (vty, ip_str);
3705 if (! peer)
3706 return CMD_WARNING;
3707
Denis Ovsienko67879782011-09-10 21:50:53 +04003708 VTY_GET_INTEGER ("maximum number", max, num_str);
hassoe0701b72004-05-20 09:19:34 +00003709 if (threshold_str)
3710 threshold = atoi (threshold_str);
3711 else
3712 threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003713
hasso0a486e52005-02-01 20:57:17 +00003714 if (restart_str)
3715 restart = atoi (restart_str);
3716 else
3717 restart = 0;
3718
3719 ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart);
paul718e3742002-12-13 20:15:29 +00003720
3721 return bgp_vty_return (vty, ret);
3722}
3723
paul94f2b392005-06-28 12:44:16 +00003724static int
paulfd79ac92004-10-13 05:06:08 +00003725peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00003726 safi_t safi)
3727{
3728 int ret;
3729 struct peer *peer;
3730
3731 peer = peer_and_group_lookup_vty (vty, ip_str);
3732 if (! peer)
3733 return CMD_WARNING;
3734
3735 ret = peer_maximum_prefix_unset (peer, afi, safi);
3736
3737 return bgp_vty_return (vty, ret);
3738}
3739
3740/* Maximum number of prefix configuration. prefix count is different
3741 for each peer configuration. So this configuration can be set for
3742 each peer configuration. */
3743DEFUN (neighbor_maximum_prefix,
3744 neighbor_maximum_prefix_cmd,
3745 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
3746 NEIGHBOR_STR
3747 NEIGHBOR_ADDR_STR2
3748 "Maximum number of prefix accept from this peer\n"
3749 "maximum no. of prefix limit\n")
3750{
3751 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
hasso0a486e52005-02-01 20:57:17 +00003752 bgp_node_safi (vty), argv[1], NULL, 0,
3753 NULL);
paul718e3742002-12-13 20:15:29 +00003754}
3755
hassoe0701b72004-05-20 09:19:34 +00003756DEFUN (neighbor_maximum_prefix_threshold,
3757 neighbor_maximum_prefix_threshold_cmd,
3758 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100>",
3759 NEIGHBOR_STR
3760 NEIGHBOR_ADDR_STR2
3761 "Maximum number of prefix accept from this peer\n"
3762 "maximum no. of prefix limit\n"
3763 "Threshold value (%) at which to generate a warning msg\n")
3764{
3765 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
hasso0a486e52005-02-01 20:57:17 +00003766 bgp_node_safi (vty), argv[1], argv[2], 0,
3767 NULL);
3768}
hassoe0701b72004-05-20 09:19:34 +00003769
paul718e3742002-12-13 20:15:29 +00003770DEFUN (neighbor_maximum_prefix_warning,
3771 neighbor_maximum_prefix_warning_cmd,
3772 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
3773 NEIGHBOR_STR
3774 NEIGHBOR_ADDR_STR2
3775 "Maximum number of prefix accept from this peer\n"
3776 "maximum no. of prefix limit\n"
3777 "Only give warning message when limit is exceeded\n")
3778{
3779 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
hasso0a486e52005-02-01 20:57:17 +00003780 bgp_node_safi (vty), argv[1], NULL, 1,
3781 NULL);
paul718e3742002-12-13 20:15:29 +00003782}
3783
hassoe0701b72004-05-20 09:19:34 +00003784DEFUN (neighbor_maximum_prefix_threshold_warning,
3785 neighbor_maximum_prefix_threshold_warning_cmd,
3786 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
3787 NEIGHBOR_STR
3788 NEIGHBOR_ADDR_STR2
3789 "Maximum number of prefix accept from this peer\n"
3790 "maximum no. of prefix limit\n"
3791 "Threshold value (%) at which to generate a warning msg\n"
3792 "Only give warning message when limit is exceeded\n")
3793{
3794 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
hasso0a486e52005-02-01 20:57:17 +00003795 bgp_node_safi (vty), argv[1], argv[2], 1, NULL);
3796}
3797
3798DEFUN (neighbor_maximum_prefix_restart,
3799 neighbor_maximum_prefix_restart_cmd,
3800 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
3801 NEIGHBOR_STR
3802 NEIGHBOR_ADDR_STR2
3803 "Maximum number of prefix accept from this peer\n"
3804 "maximum no. of prefix limit\n"
3805 "Restart bgp connection after limit is exceeded\n"
3806 "Restart interval in minutes")
3807{
3808 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
3809 bgp_node_safi (vty), argv[1], NULL, 0, argv[2]);
3810}
3811
3812DEFUN (neighbor_maximum_prefix_threshold_restart,
3813 neighbor_maximum_prefix_threshold_restart_cmd,
3814 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
3815 NEIGHBOR_STR
3816 NEIGHBOR_ADDR_STR2
3817 "Maximum number of prefix accept from this peer\n"
3818 "maximum no. of prefix limit\n"
3819 "Threshold value (%) at which to generate a warning msg\n"
3820 "Restart bgp connection after limit is exceeded\n"
3821 "Restart interval in minutes")
3822{
3823 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
3824 bgp_node_safi (vty), argv[1], argv[2], 0, argv[3]);
3825}
hassoe0701b72004-05-20 09:19:34 +00003826
paul718e3742002-12-13 20:15:29 +00003827DEFUN (no_neighbor_maximum_prefix,
3828 no_neighbor_maximum_prefix_cmd,
3829 NO_NEIGHBOR_CMD2 "maximum-prefix",
3830 NO_STR
3831 NEIGHBOR_STR
3832 NEIGHBOR_ADDR_STR2
3833 "Maximum number of prefix accept from this peer\n")
3834{
3835 return peer_maximum_prefix_unset_vty (vty, argv[0], bgp_node_afi (vty),
3836 bgp_node_safi (vty));
3837}
3838
3839ALIAS (no_neighbor_maximum_prefix,
3840 no_neighbor_maximum_prefix_val_cmd,
3841 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
3842 NO_STR
3843 NEIGHBOR_STR
3844 NEIGHBOR_ADDR_STR2
3845 "Maximum number of prefix accept from this peer\n"
3846 "maximum no. of prefix limit\n")
3847
3848ALIAS (no_neighbor_maximum_prefix,
hasso0a486e52005-02-01 20:57:17 +00003849 no_neighbor_maximum_prefix_threshold_cmd,
3850 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
3851 NO_STR
3852 NEIGHBOR_STR
3853 NEIGHBOR_ADDR_STR2
3854 "Maximum number of prefix accept from this peer\n"
3855 "maximum no. of prefix limit\n"
3856 "Threshold value (%) at which to generate a warning msg\n")
3857
3858ALIAS (no_neighbor_maximum_prefix,
3859 no_neighbor_maximum_prefix_warning_cmd,
3860 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
3861 NO_STR
3862 NEIGHBOR_STR
3863 NEIGHBOR_ADDR_STR2
3864 "Maximum number of prefix accept from this peer\n"
3865 "maximum no. of prefix limit\n"
paule8e19462006-01-19 20:16:55 +00003866 "Only give warning message when limit is exceeded\n")
hasso0a486e52005-02-01 20:57:17 +00003867
3868ALIAS (no_neighbor_maximum_prefix,
3869 no_neighbor_maximum_prefix_threshold_warning_cmd,
hassoe0701b72004-05-20 09:19:34 +00003870 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
3871 NO_STR
3872 NEIGHBOR_STR
3873 NEIGHBOR_ADDR_STR2
3874 "Maximum number of prefix accept from this peer\n"
3875 "maximum no. of prefix limit\n"
3876 "Threshold value (%) at which to generate a warning msg\n"
paule8e19462006-01-19 20:16:55 +00003877 "Only give warning message when limit is exceeded\n")
hassoe0701b72004-05-20 09:19:34 +00003878
3879ALIAS (no_neighbor_maximum_prefix,
hasso0a486e52005-02-01 20:57:17 +00003880 no_neighbor_maximum_prefix_restart_cmd,
3881 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
paul718e3742002-12-13 20:15:29 +00003882 NO_STR
3883 NEIGHBOR_STR
3884 NEIGHBOR_ADDR_STR2
3885 "Maximum number of prefix accept from this peer\n"
3886 "maximum no. of prefix limit\n"
hasso0a486e52005-02-01 20:57:17 +00003887 "Restart bgp connection after limit is exceeded\n"
3888 "Restart interval in minutes")
3889
3890ALIAS (no_neighbor_maximum_prefix,
3891 no_neighbor_maximum_prefix_threshold_restart_cmd,
3892 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
3893 NO_STR
3894 NEIGHBOR_STR
3895 NEIGHBOR_ADDR_STR2
3896 "Maximum number of prefix accept from this peer\n"
3897 "maximum no. of prefix limit\n"
3898 "Threshold value (%) at which to generate a warning msg\n"
3899 "Restart bgp connection after limit is exceeded\n"
3900 "Restart interval in minutes")
paul718e3742002-12-13 20:15:29 +00003901
3902/* "neighbor allowas-in" */
3903DEFUN (neighbor_allowas_in,
3904 neighbor_allowas_in_cmd,
3905 NEIGHBOR_CMD2 "allowas-in",
3906 NEIGHBOR_STR
3907 NEIGHBOR_ADDR_STR2
3908 "Accept as-path with my AS present in it\n")
3909{
3910 int ret;
3911 struct peer *peer;
paulfd79ac92004-10-13 05:06:08 +00003912 unsigned int allow_num;
paul718e3742002-12-13 20:15:29 +00003913
3914 peer = peer_and_group_lookup_vty (vty, argv[0]);
3915 if (! peer)
3916 return CMD_WARNING;
3917
3918 if (argc == 1)
3919 allow_num = 3;
3920 else
3921 VTY_GET_INTEGER_RANGE ("AS number", allow_num, argv[1], 1, 10);
3922
3923 ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty),
3924 allow_num);
3925
3926 return bgp_vty_return (vty, ret);
3927}
3928
3929ALIAS (neighbor_allowas_in,
3930 neighbor_allowas_in_arg_cmd,
3931 NEIGHBOR_CMD2 "allowas-in <1-10>",
3932 NEIGHBOR_STR
3933 NEIGHBOR_ADDR_STR2
3934 "Accept as-path with my AS present in it\n"
3935 "Number of occurances of AS number\n")
3936
3937DEFUN (no_neighbor_allowas_in,
3938 no_neighbor_allowas_in_cmd,
3939 NO_NEIGHBOR_CMD2 "allowas-in",
3940 NO_STR
3941 NEIGHBOR_STR
3942 NEIGHBOR_ADDR_STR2
3943 "allow local ASN appears in aspath attribute\n")
3944{
3945 int ret;
3946 struct peer *peer;
3947
3948 peer = peer_and_group_lookup_vty (vty, argv[0]);
3949 if (! peer)
3950 return CMD_WARNING;
3951
3952 ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty));
3953
3954 return bgp_vty_return (vty, ret);
3955}
3956
3957/* Address family configuration. */
3958DEFUN (address_family_ipv4,
3959 address_family_ipv4_cmd,
3960 "address-family ipv4",
3961 "Enter Address Family command mode\n"
3962 "Address family\n")
3963{
3964 vty->node = BGP_IPV4_NODE;
3965 return CMD_SUCCESS;
3966}
3967
3968DEFUN (address_family_ipv4_safi,
3969 address_family_ipv4_safi_cmd,
3970 "address-family ipv4 (unicast|multicast)",
3971 "Enter Address Family command mode\n"
3972 "Address family\n"
3973 "Address Family modifier\n"
3974 "Address Family modifier\n")
3975{
3976 if (strncmp (argv[0], "m", 1) == 0)
3977 vty->node = BGP_IPV4M_NODE;
3978 else
3979 vty->node = BGP_IPV4_NODE;
3980
3981 return CMD_SUCCESS;
3982}
3983
paul25ffbdc2005-08-22 22:42:08 +00003984DEFUN (address_family_ipv6,
3985 address_family_ipv6_cmd,
3986 "address-family ipv6",
paul718e3742002-12-13 20:15:29 +00003987 "Enter Address Family command mode\n"
paul25ffbdc2005-08-22 22:42:08 +00003988 "Address family\n")
paul718e3742002-12-13 20:15:29 +00003989{
3990 vty->node = BGP_IPV6_NODE;
3991 return CMD_SUCCESS;
3992}
3993
paul25ffbdc2005-08-22 22:42:08 +00003994DEFUN (address_family_ipv6_safi,
3995 address_family_ipv6_safi_cmd,
3996 "address-family ipv6 (unicast|multicast)",
paul718e3742002-12-13 20:15:29 +00003997 "Enter Address Family command mode\n"
paul25ffbdc2005-08-22 22:42:08 +00003998 "Address family\n"
3999 "Address Family modifier\n"
4000 "Address Family modifier\n")
4001{
4002 if (strncmp (argv[0], "m", 1) == 0)
4003 vty->node = BGP_IPV6M_NODE;
4004 else
4005 vty->node = BGP_IPV6_NODE;
4006
4007 return CMD_SUCCESS;
4008}
paul718e3742002-12-13 20:15:29 +00004009
4010DEFUN (address_family_vpnv4,
4011 address_family_vpnv4_cmd,
4012 "address-family vpnv4",
4013 "Enter Address Family command mode\n"
4014 "Address family\n")
4015{
4016 vty->node = BGP_VPNV4_NODE;
4017 return CMD_SUCCESS;
4018}
4019
4020ALIAS (address_family_vpnv4,
4021 address_family_vpnv4_unicast_cmd,
4022 "address-family vpnv4 unicast",
4023 "Enter Address Family command mode\n"
4024 "Address family\n"
4025 "Address Family Modifier\n")
4026
4027DEFUN (exit_address_family,
4028 exit_address_family_cmd,
4029 "exit-address-family",
4030 "Exit from Address Family configuration mode\n")
4031{
hassoa8a80d52005-04-09 13:07:47 +00004032 if (vty->node == BGP_IPV4_NODE
4033 || vty->node == BGP_IPV4M_NODE
paul718e3742002-12-13 20:15:29 +00004034 || vty->node == BGP_VPNV4_NODE
paul25ffbdc2005-08-22 22:42:08 +00004035 || vty->node == BGP_IPV6_NODE
4036 || vty->node == BGP_IPV6M_NODE)
paul718e3742002-12-13 20:15:29 +00004037 vty->node = BGP_NODE;
4038 return CMD_SUCCESS;
4039}
4040
4041/* BGP clear sort. */
4042enum clear_sort
4043{
4044 clear_all,
4045 clear_peer,
4046 clear_group,
4047 clear_external,
4048 clear_as
4049};
4050
paul94f2b392005-06-28 12:44:16 +00004051static void
paul718e3742002-12-13 20:15:29 +00004052bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi,
4053 safi_t safi, int error)
4054{
4055 switch (error)
4056 {
4057 case BGP_ERR_AF_UNCONFIGURED:
4058 vty_out (vty,
4059 "%%BGP: Enable %s %s address family for the neighbor %s%s",
4060 afi == AFI_IP6 ? "IPv6" : safi == SAFI_MPLS_VPN ? "VPNv4" : "IPv4",
4061 safi == SAFI_MULTICAST ? "Multicast" : "Unicast",
4062 peer->host, VTY_NEWLINE);
4063 break;
4064 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED:
4065 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);
4066 break;
4067 default:
4068 break;
4069 }
4070}
4071
4072/* `clear ip bgp' functions. */
paul94f2b392005-06-28 12:44:16 +00004073static int
paul718e3742002-12-13 20:15:29 +00004074bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
paulfd79ac92004-10-13 05:06:08 +00004075 enum clear_sort sort,enum bgp_clear_type stype, const char *arg)
paul718e3742002-12-13 20:15:29 +00004076{
4077 int ret;
4078 struct peer *peer;
paul1eb8ef22005-04-07 07:30:20 +00004079 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00004080
4081 /* Clear all neighbors. */
4082 if (sort == clear_all)
4083 {
paul1eb8ef22005-04-07 07:30:20 +00004084 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00004085 {
4086 if (stype == BGP_CLEAR_SOFT_NONE)
4087 ret = peer_clear (peer);
4088 else
4089 ret = peer_clear_soft (peer, afi, safi, stype);
4090
4091 if (ret < 0)
4092 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4093 }
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004094 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00004095 }
4096
4097 /* Clear specified neighbors. */
4098 if (sort == clear_peer)
4099 {
4100 union sockunion su;
4101 int ret;
4102
4103 /* Make sockunion for lookup. */
4104 ret = str2sockunion (arg, &su);
4105 if (ret < 0)
4106 {
4107 vty_out (vty, "Malformed address: %s%s", arg, VTY_NEWLINE);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004108 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +00004109 }
4110 peer = peer_lookup (bgp, &su);
4111 if (! peer)
4112 {
4113 vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004114 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +00004115 }
4116
4117 if (stype == BGP_CLEAR_SOFT_NONE)
4118 ret = peer_clear (peer);
4119 else
4120 ret = peer_clear_soft (peer, afi, safi, stype);
4121
4122 if (ret < 0)
4123 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4124
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004125 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00004126 }
4127
4128 /* Clear all peer-group members. */
4129 if (sort == clear_group)
4130 {
4131 struct peer_group *group;
4132
4133 group = peer_group_lookup (bgp, arg);
4134 if (! group)
4135 {
4136 vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004137 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +00004138 }
4139
paul1eb8ef22005-04-07 07:30:20 +00004140 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00004141 {
4142 if (stype == BGP_CLEAR_SOFT_NONE)
4143 {
4144 ret = peer_clear (peer);
4145 continue;
4146 }
4147
4148 if (! peer->af_group[afi][safi])
4149 continue;
4150
4151 ret = peer_clear_soft (peer, afi, safi, stype);
4152
4153 if (ret < 0)
4154 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4155 }
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004156 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00004157 }
4158
4159 if (sort == clear_external)
4160 {
paul1eb8ef22005-04-07 07:30:20 +00004161 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00004162 {
4163 if (peer_sort (peer) == BGP_PEER_IBGP)
4164 continue;
4165
4166 if (stype == BGP_CLEAR_SOFT_NONE)
4167 ret = peer_clear (peer);
4168 else
4169 ret = peer_clear_soft (peer, afi, safi, stype);
4170
4171 if (ret < 0)
4172 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4173 }
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004174 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00004175 }
4176
4177 if (sort == clear_as)
4178 {
4179 as_t as;
paul718e3742002-12-13 20:15:29 +00004180 int find = 0;
4181
Ulrich Weber50091602011-11-16 19:32:12 +04004182 VTY_GET_INTEGER_RANGE ("AS", as, arg, 1, BGP_AS4_MAX);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004183
paul1eb8ef22005-04-07 07:30:20 +00004184 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00004185 {
4186 if (peer->as != as)
4187 continue;
4188
4189 find = 1;
4190 if (stype == BGP_CLEAR_SOFT_NONE)
4191 ret = peer_clear (peer);
4192 else
4193 ret = peer_clear_soft (peer, afi, safi, stype);
4194
4195 if (ret < 0)
4196 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4197 }
4198 if (! find)
4199 vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg,
4200 VTY_NEWLINE);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004201 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00004202 }
4203
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004204 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00004205}
4206
paul94f2b392005-06-28 12:44:16 +00004207static int
paulfd79ac92004-10-13 05:06:08 +00004208bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi,
4209 enum clear_sort sort, enum bgp_clear_type stype,
4210 const char *arg)
paul718e3742002-12-13 20:15:29 +00004211{
paul718e3742002-12-13 20:15:29 +00004212 struct bgp *bgp;
4213
4214 /* BGP structure lookup. */
4215 if (name)
4216 {
4217 bgp = bgp_lookup_by_name (name);
4218 if (bgp == NULL)
4219 {
4220 vty_out (vty, "Can't find BGP view %s%s", name, VTY_NEWLINE);
4221 return CMD_WARNING;
4222 }
4223 }
4224 else
4225 {
4226 bgp = bgp_get_default ();
4227 if (bgp == NULL)
4228 {
4229 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
4230 return CMD_WARNING;
4231 }
4232 }
4233
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004234 return bgp_clear (vty, bgp, afi, safi, sort, stype, arg);
paul718e3742002-12-13 20:15:29 +00004235}
4236
4237DEFUN (clear_ip_bgp_all,
4238 clear_ip_bgp_all_cmd,
4239 "clear ip bgp *",
4240 CLEAR_STR
4241 IP_STR
4242 BGP_STR
4243 "Clear all peers\n")
4244{
4245 if (argc == 1)
4246 return bgp_clear_vty (vty, argv[0], 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
4247
4248 return bgp_clear_vty (vty, NULL, 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
4249}
4250
4251ALIAS (clear_ip_bgp_all,
4252 clear_bgp_all_cmd,
4253 "clear bgp *",
4254 CLEAR_STR
4255 BGP_STR
4256 "Clear all peers\n")
4257
4258ALIAS (clear_ip_bgp_all,
4259 clear_bgp_ipv6_all_cmd,
4260 "clear bgp ipv6 *",
4261 CLEAR_STR
4262 BGP_STR
4263 "Address family\n"
4264 "Clear all peers\n")
4265
4266ALIAS (clear_ip_bgp_all,
4267 clear_ip_bgp_instance_all_cmd,
4268 "clear ip bgp view WORD *",
4269 CLEAR_STR
4270 IP_STR
4271 BGP_STR
4272 "BGP view\n"
4273 "view name\n"
4274 "Clear all peers\n")
4275
4276ALIAS (clear_ip_bgp_all,
4277 clear_bgp_instance_all_cmd,
4278 "clear bgp view WORD *",
4279 CLEAR_STR
4280 BGP_STR
4281 "BGP view\n"
4282 "view name\n"
4283 "Clear all peers\n")
4284
4285DEFUN (clear_ip_bgp_peer,
4286 clear_ip_bgp_peer_cmd,
4287 "clear ip bgp (A.B.C.D|X:X::X:X)",
4288 CLEAR_STR
4289 IP_STR
4290 BGP_STR
4291 "BGP neighbor IP address to clear\n"
4292 "BGP IPv6 neighbor to clear\n")
4293{
4294 return bgp_clear_vty (vty, NULL, 0, 0, clear_peer, BGP_CLEAR_SOFT_NONE, argv[0]);
4295}
4296
4297ALIAS (clear_ip_bgp_peer,
4298 clear_bgp_peer_cmd,
4299 "clear bgp (A.B.C.D|X:X::X:X)",
4300 CLEAR_STR
4301 BGP_STR
4302 "BGP neighbor address to clear\n"
4303 "BGP IPv6 neighbor to clear\n")
4304
4305ALIAS (clear_ip_bgp_peer,
4306 clear_bgp_ipv6_peer_cmd,
4307 "clear bgp ipv6 (A.B.C.D|X:X::X:X)",
4308 CLEAR_STR
4309 BGP_STR
4310 "Address family\n"
4311 "BGP neighbor address to clear\n"
4312 "BGP IPv6 neighbor to clear\n")
4313
4314DEFUN (clear_ip_bgp_peer_group,
4315 clear_ip_bgp_peer_group_cmd,
4316 "clear ip bgp peer-group WORD",
4317 CLEAR_STR
4318 IP_STR
4319 BGP_STR
4320 "Clear all members of peer-group\n"
4321 "BGP peer-group name\n")
4322{
4323 return bgp_clear_vty (vty, NULL, 0, 0, clear_group, BGP_CLEAR_SOFT_NONE, argv[0]);
4324}
4325
4326ALIAS (clear_ip_bgp_peer_group,
4327 clear_bgp_peer_group_cmd,
4328 "clear bgp peer-group WORD",
4329 CLEAR_STR
4330 BGP_STR
4331 "Clear all members of peer-group\n"
4332 "BGP peer-group name\n")
4333
4334ALIAS (clear_ip_bgp_peer_group,
4335 clear_bgp_ipv6_peer_group_cmd,
4336 "clear bgp ipv6 peer-group WORD",
4337 CLEAR_STR
4338 BGP_STR
4339 "Address family\n"
4340 "Clear all members of peer-group\n"
4341 "BGP peer-group name\n")
4342
4343DEFUN (clear_ip_bgp_external,
4344 clear_ip_bgp_external_cmd,
4345 "clear ip bgp external",
4346 CLEAR_STR
4347 IP_STR
4348 BGP_STR
4349 "Clear all external peers\n")
4350{
4351 return bgp_clear_vty (vty, NULL, 0, 0, clear_external, BGP_CLEAR_SOFT_NONE, NULL);
4352}
4353
4354ALIAS (clear_ip_bgp_external,
4355 clear_bgp_external_cmd,
4356 "clear bgp external",
4357 CLEAR_STR
4358 BGP_STR
4359 "Clear all external peers\n")
4360
4361ALIAS (clear_ip_bgp_external,
4362 clear_bgp_ipv6_external_cmd,
4363 "clear bgp ipv6 external",
4364 CLEAR_STR
4365 BGP_STR
4366 "Address family\n"
4367 "Clear all external peers\n")
4368
4369DEFUN (clear_ip_bgp_as,
4370 clear_ip_bgp_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004371 "clear ip bgp " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00004372 CLEAR_STR
4373 IP_STR
4374 BGP_STR
4375 "Clear peers with the AS number\n")
4376{
4377 return bgp_clear_vty (vty, NULL, 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[0]);
4378}
4379
4380ALIAS (clear_ip_bgp_as,
4381 clear_bgp_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004382 "clear bgp " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00004383 CLEAR_STR
4384 BGP_STR
4385 "Clear peers with the AS number\n")
4386
4387ALIAS (clear_ip_bgp_as,
4388 clear_bgp_ipv6_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004389 "clear bgp ipv6 " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00004390 CLEAR_STR
4391 BGP_STR
4392 "Address family\n"
4393 "Clear peers with the AS number\n")
4394
4395/* Outbound soft-reconfiguration */
4396DEFUN (clear_ip_bgp_all_soft_out,
4397 clear_ip_bgp_all_soft_out_cmd,
4398 "clear ip bgp * soft out",
4399 CLEAR_STR
4400 IP_STR
4401 BGP_STR
4402 "Clear all peers\n"
4403 "Soft reconfig\n"
4404 "Soft reconfig outbound update\n")
4405{
4406 if (argc == 1)
4407 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
4408 BGP_CLEAR_SOFT_OUT, NULL);
4409
4410 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
4411 BGP_CLEAR_SOFT_OUT, NULL);
4412}
4413
4414ALIAS (clear_ip_bgp_all_soft_out,
4415 clear_ip_bgp_all_out_cmd,
4416 "clear ip bgp * out",
4417 CLEAR_STR
4418 IP_STR
4419 BGP_STR
4420 "Clear all peers\n"
4421 "Soft reconfig outbound update\n")
4422
4423ALIAS (clear_ip_bgp_all_soft_out,
4424 clear_ip_bgp_instance_all_soft_out_cmd,
4425 "clear ip bgp view WORD * soft out",
4426 CLEAR_STR
4427 IP_STR
4428 BGP_STR
4429 "BGP view\n"
4430 "view name\n"
4431 "Clear all peers\n"
4432 "Soft reconfig\n"
4433 "Soft reconfig outbound update\n")
4434
4435DEFUN (clear_ip_bgp_all_ipv4_soft_out,
4436 clear_ip_bgp_all_ipv4_soft_out_cmd,
4437 "clear ip bgp * ipv4 (unicast|multicast) soft out",
4438 CLEAR_STR
4439 IP_STR
4440 BGP_STR
4441 "Clear all peers\n"
4442 "Address family\n"
4443 "Address Family modifier\n"
4444 "Address Family modifier\n"
4445 "Soft reconfig\n"
4446 "Soft reconfig outbound update\n")
4447{
4448 if (strncmp (argv[0], "m", 1) == 0)
4449 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
4450 BGP_CLEAR_SOFT_OUT, NULL);
4451
4452 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
4453 BGP_CLEAR_SOFT_OUT, NULL);
4454}
4455
4456ALIAS (clear_ip_bgp_all_ipv4_soft_out,
4457 clear_ip_bgp_all_ipv4_out_cmd,
4458 "clear ip bgp * ipv4 (unicast|multicast) out",
4459 CLEAR_STR
4460 IP_STR
4461 BGP_STR
4462 "Clear all peers\n"
4463 "Address family\n"
4464 "Address Family modifier\n"
4465 "Address Family modifier\n"
4466 "Soft reconfig outbound update\n")
4467
4468DEFUN (clear_ip_bgp_instance_all_ipv4_soft_out,
4469 clear_ip_bgp_instance_all_ipv4_soft_out_cmd,
4470 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft out",
4471 CLEAR_STR
4472 IP_STR
4473 BGP_STR
4474 "BGP view\n"
4475 "view name\n"
4476 "Clear all peers\n"
4477 "Address family\n"
4478 "Address Family modifier\n"
4479 "Address Family modifier\n"
4480 "Soft reconfig outbound update\n")
4481{
4482 if (strncmp (argv[1], "m", 1) == 0)
4483 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
4484 BGP_CLEAR_SOFT_OUT, NULL);
4485
4486 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
4487 BGP_CLEAR_SOFT_OUT, NULL);
4488}
4489
4490DEFUN (clear_ip_bgp_all_vpnv4_soft_out,
4491 clear_ip_bgp_all_vpnv4_soft_out_cmd,
4492 "clear ip bgp * vpnv4 unicast soft out",
4493 CLEAR_STR
4494 IP_STR
4495 BGP_STR
4496 "Clear all peers\n"
4497 "Address family\n"
4498 "Address Family Modifier\n"
4499 "Soft reconfig\n"
4500 "Soft reconfig outbound update\n")
4501{
4502 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
4503 BGP_CLEAR_SOFT_OUT, NULL);
4504}
4505
4506ALIAS (clear_ip_bgp_all_vpnv4_soft_out,
4507 clear_ip_bgp_all_vpnv4_out_cmd,
4508 "clear ip bgp * vpnv4 unicast out",
4509 CLEAR_STR
4510 IP_STR
4511 BGP_STR
4512 "Clear all peers\n"
4513 "Address family\n"
4514 "Address Family Modifier\n"
4515 "Soft reconfig outbound update\n")
4516
4517DEFUN (clear_bgp_all_soft_out,
4518 clear_bgp_all_soft_out_cmd,
4519 "clear bgp * soft out",
4520 CLEAR_STR
4521 BGP_STR
4522 "Clear all peers\n"
4523 "Soft reconfig\n"
4524 "Soft reconfig outbound update\n")
4525{
4526 if (argc == 1)
4527 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
4528 BGP_CLEAR_SOFT_OUT, NULL);
4529
4530 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
4531 BGP_CLEAR_SOFT_OUT, NULL);
4532}
4533
4534ALIAS (clear_bgp_all_soft_out,
4535 clear_bgp_instance_all_soft_out_cmd,
4536 "clear bgp view WORD * soft out",
4537 CLEAR_STR
4538 BGP_STR
4539 "BGP view\n"
4540 "view name\n"
4541 "Clear all peers\n"
4542 "Soft reconfig\n"
4543 "Soft reconfig outbound update\n")
4544
4545ALIAS (clear_bgp_all_soft_out,
4546 clear_bgp_all_out_cmd,
4547 "clear bgp * out",
4548 CLEAR_STR
4549 BGP_STR
4550 "Clear all peers\n"
4551 "Soft reconfig outbound update\n")
4552
4553ALIAS (clear_bgp_all_soft_out,
4554 clear_bgp_ipv6_all_soft_out_cmd,
4555 "clear bgp ipv6 * soft out",
4556 CLEAR_STR
4557 BGP_STR
4558 "Address family\n"
4559 "Clear all peers\n"
4560 "Soft reconfig\n"
4561 "Soft reconfig outbound update\n")
4562
4563ALIAS (clear_bgp_all_soft_out,
4564 clear_bgp_ipv6_all_out_cmd,
4565 "clear bgp ipv6 * out",
4566 CLEAR_STR
4567 BGP_STR
4568 "Address family\n"
4569 "Clear all peers\n"
4570 "Soft reconfig outbound update\n")
4571
4572DEFUN (clear_ip_bgp_peer_soft_out,
4573 clear_ip_bgp_peer_soft_out_cmd,
4574 "clear ip bgp A.B.C.D soft out",
4575 CLEAR_STR
4576 IP_STR
4577 BGP_STR
4578 "BGP neighbor address to clear\n"
4579 "Soft reconfig\n"
4580 "Soft reconfig outbound update\n")
4581{
4582 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
4583 BGP_CLEAR_SOFT_OUT, argv[0]);
4584}
4585
4586ALIAS (clear_ip_bgp_peer_soft_out,
4587 clear_ip_bgp_peer_out_cmd,
4588 "clear ip bgp A.B.C.D out",
4589 CLEAR_STR
4590 IP_STR
4591 BGP_STR
4592 "BGP neighbor address to clear\n"
4593 "Soft reconfig outbound update\n")
4594
4595DEFUN (clear_ip_bgp_peer_ipv4_soft_out,
4596 clear_ip_bgp_peer_ipv4_soft_out_cmd,
4597 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft out",
4598 CLEAR_STR
4599 IP_STR
4600 BGP_STR
4601 "BGP neighbor address to clear\n"
4602 "Address family\n"
4603 "Address Family modifier\n"
4604 "Address Family modifier\n"
4605 "Soft reconfig\n"
4606 "Soft reconfig outbound update\n")
4607{
4608 if (strncmp (argv[1], "m", 1) == 0)
4609 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
4610 BGP_CLEAR_SOFT_OUT, argv[0]);
4611
4612 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
4613 BGP_CLEAR_SOFT_OUT, argv[0]);
4614}
4615
4616ALIAS (clear_ip_bgp_peer_ipv4_soft_out,
4617 clear_ip_bgp_peer_ipv4_out_cmd,
4618 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) out",
4619 CLEAR_STR
4620 IP_STR
4621 BGP_STR
4622 "BGP neighbor address to clear\n"
4623 "Address family\n"
4624 "Address Family modifier\n"
4625 "Address Family modifier\n"
4626 "Soft reconfig outbound update\n")
4627
4628DEFUN (clear_ip_bgp_peer_vpnv4_soft_out,
4629 clear_ip_bgp_peer_vpnv4_soft_out_cmd,
4630 "clear ip bgp A.B.C.D vpnv4 unicast soft out",
4631 CLEAR_STR
4632 IP_STR
4633 BGP_STR
4634 "BGP neighbor address to clear\n"
4635 "Address family\n"
4636 "Address Family Modifier\n"
4637 "Soft reconfig\n"
4638 "Soft reconfig outbound update\n")
4639{
4640 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
4641 BGP_CLEAR_SOFT_OUT, argv[0]);
4642}
4643
4644ALIAS (clear_ip_bgp_peer_vpnv4_soft_out,
4645 clear_ip_bgp_peer_vpnv4_out_cmd,
4646 "clear ip bgp A.B.C.D vpnv4 unicast out",
4647 CLEAR_STR
4648 IP_STR
4649 BGP_STR
4650 "BGP neighbor address to clear\n"
4651 "Address family\n"
4652 "Address Family Modifier\n"
4653 "Soft reconfig outbound update\n")
4654
4655DEFUN (clear_bgp_peer_soft_out,
4656 clear_bgp_peer_soft_out_cmd,
4657 "clear bgp (A.B.C.D|X:X::X:X) soft out",
4658 CLEAR_STR
4659 BGP_STR
4660 "BGP neighbor address to clear\n"
4661 "BGP IPv6 neighbor to clear\n"
4662 "Soft reconfig\n"
4663 "Soft reconfig outbound update\n")
4664{
4665 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
4666 BGP_CLEAR_SOFT_OUT, argv[0]);
4667}
4668
4669ALIAS (clear_bgp_peer_soft_out,
4670 clear_bgp_ipv6_peer_soft_out_cmd,
4671 "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft out",
4672 CLEAR_STR
4673 BGP_STR
4674 "Address family\n"
4675 "BGP neighbor address to clear\n"
4676 "BGP IPv6 neighbor to clear\n"
4677 "Soft reconfig\n"
4678 "Soft reconfig outbound update\n")
4679
4680ALIAS (clear_bgp_peer_soft_out,
4681 clear_bgp_peer_out_cmd,
4682 "clear bgp (A.B.C.D|X:X::X:X) out",
4683 CLEAR_STR
4684 BGP_STR
4685 "BGP neighbor address to clear\n"
4686 "BGP IPv6 neighbor to clear\n"
4687 "Soft reconfig outbound update\n")
4688
4689ALIAS (clear_bgp_peer_soft_out,
4690 clear_bgp_ipv6_peer_out_cmd,
4691 "clear bgp ipv6 (A.B.C.D|X:X::X:X) out",
4692 CLEAR_STR
4693 BGP_STR
4694 "Address family\n"
4695 "BGP neighbor address to clear\n"
4696 "BGP IPv6 neighbor to clear\n"
4697 "Soft reconfig outbound update\n")
4698
4699DEFUN (clear_ip_bgp_peer_group_soft_out,
4700 clear_ip_bgp_peer_group_soft_out_cmd,
4701 "clear ip bgp peer-group WORD soft out",
4702 CLEAR_STR
4703 IP_STR
4704 BGP_STR
4705 "Clear all members of peer-group\n"
4706 "BGP peer-group name\n"
4707 "Soft reconfig\n"
4708 "Soft reconfig outbound update\n")
4709{
4710 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
4711 BGP_CLEAR_SOFT_OUT, argv[0]);
4712}
4713
4714ALIAS (clear_ip_bgp_peer_group_soft_out,
4715 clear_ip_bgp_peer_group_out_cmd,
4716 "clear ip bgp peer-group WORD out",
4717 CLEAR_STR
4718 IP_STR
4719 BGP_STR
4720 "Clear all members of peer-group\n"
4721 "BGP peer-group name\n"
4722 "Soft reconfig outbound update\n")
4723
4724DEFUN (clear_ip_bgp_peer_group_ipv4_soft_out,
4725 clear_ip_bgp_peer_group_ipv4_soft_out_cmd,
4726 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft out",
4727 CLEAR_STR
4728 IP_STR
4729 BGP_STR
4730 "Clear all members of peer-group\n"
4731 "BGP peer-group name\n"
4732 "Address family\n"
4733 "Address Family modifier\n"
4734 "Address Family modifier\n"
4735 "Soft reconfig\n"
4736 "Soft reconfig outbound update\n")
4737{
4738 if (strncmp (argv[1], "m", 1) == 0)
4739 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
4740 BGP_CLEAR_SOFT_OUT, argv[0]);
4741
4742 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
4743 BGP_CLEAR_SOFT_OUT, argv[0]);
4744}
4745
4746ALIAS (clear_ip_bgp_peer_group_ipv4_soft_out,
4747 clear_ip_bgp_peer_group_ipv4_out_cmd,
4748 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) out",
4749 CLEAR_STR
4750 IP_STR
4751 BGP_STR
4752 "Clear all members of peer-group\n"
4753 "BGP peer-group name\n"
4754 "Address family\n"
4755 "Address Family modifier\n"
4756 "Address Family modifier\n"
4757 "Soft reconfig outbound update\n")
4758
4759DEFUN (clear_bgp_peer_group_soft_out,
4760 clear_bgp_peer_group_soft_out_cmd,
4761 "clear bgp peer-group WORD soft out",
4762 CLEAR_STR
4763 BGP_STR
4764 "Clear all members of peer-group\n"
4765 "BGP peer-group name\n"
4766 "Soft reconfig\n"
4767 "Soft reconfig outbound update\n")
4768{
4769 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
4770 BGP_CLEAR_SOFT_OUT, argv[0]);
4771}
4772
4773ALIAS (clear_bgp_peer_group_soft_out,
4774 clear_bgp_ipv6_peer_group_soft_out_cmd,
4775 "clear bgp ipv6 peer-group WORD soft out",
4776 CLEAR_STR
4777 BGP_STR
4778 "Address family\n"
4779 "Clear all members of peer-group\n"
4780 "BGP peer-group name\n"
4781 "Soft reconfig\n"
4782 "Soft reconfig outbound update\n")
4783
4784ALIAS (clear_bgp_peer_group_soft_out,
4785 clear_bgp_peer_group_out_cmd,
4786 "clear bgp peer-group WORD out",
4787 CLEAR_STR
4788 BGP_STR
4789 "Clear all members of peer-group\n"
4790 "BGP peer-group name\n"
4791 "Soft reconfig outbound update\n")
4792
4793ALIAS (clear_bgp_peer_group_soft_out,
4794 clear_bgp_ipv6_peer_group_out_cmd,
4795 "clear bgp ipv6 peer-group WORD out",
4796 CLEAR_STR
4797 BGP_STR
4798 "Address family\n"
4799 "Clear all members of peer-group\n"
4800 "BGP peer-group name\n"
4801 "Soft reconfig outbound update\n")
4802
4803DEFUN (clear_ip_bgp_external_soft_out,
4804 clear_ip_bgp_external_soft_out_cmd,
4805 "clear ip bgp external soft out",
4806 CLEAR_STR
4807 IP_STR
4808 BGP_STR
4809 "Clear all external peers\n"
4810 "Soft reconfig\n"
4811 "Soft reconfig outbound update\n")
4812{
4813 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
4814 BGP_CLEAR_SOFT_OUT, NULL);
4815}
4816
4817ALIAS (clear_ip_bgp_external_soft_out,
4818 clear_ip_bgp_external_out_cmd,
4819 "clear ip bgp external out",
4820 CLEAR_STR
4821 IP_STR
4822 BGP_STR
4823 "Clear all external peers\n"
4824 "Soft reconfig outbound update\n")
4825
4826DEFUN (clear_ip_bgp_external_ipv4_soft_out,
4827 clear_ip_bgp_external_ipv4_soft_out_cmd,
4828 "clear ip bgp external ipv4 (unicast|multicast) soft out",
4829 CLEAR_STR
4830 IP_STR
4831 BGP_STR
4832 "Clear all external peers\n"
4833 "Address family\n"
4834 "Address Family modifier\n"
4835 "Address Family modifier\n"
4836 "Soft reconfig\n"
4837 "Soft reconfig outbound update\n")
4838{
4839 if (strncmp (argv[0], "m", 1) == 0)
4840 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
4841 BGP_CLEAR_SOFT_OUT, NULL);
4842
4843 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
4844 BGP_CLEAR_SOFT_OUT, NULL);
4845}
4846
4847ALIAS (clear_ip_bgp_external_ipv4_soft_out,
4848 clear_ip_bgp_external_ipv4_out_cmd,
4849 "clear ip bgp external ipv4 (unicast|multicast) out",
4850 CLEAR_STR
4851 IP_STR
4852 BGP_STR
4853 "Clear all external peers\n"
4854 "Address family\n"
4855 "Address Family modifier\n"
4856 "Address Family modifier\n"
4857 "Soft reconfig outbound update\n")
4858
4859DEFUN (clear_bgp_external_soft_out,
4860 clear_bgp_external_soft_out_cmd,
4861 "clear bgp external soft out",
4862 CLEAR_STR
4863 BGP_STR
4864 "Clear all external peers\n"
4865 "Soft reconfig\n"
4866 "Soft reconfig outbound update\n")
4867{
4868 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
4869 BGP_CLEAR_SOFT_OUT, NULL);
4870}
4871
4872ALIAS (clear_bgp_external_soft_out,
4873 clear_bgp_ipv6_external_soft_out_cmd,
4874 "clear bgp ipv6 external soft out",
4875 CLEAR_STR
4876 BGP_STR
4877 "Address family\n"
4878 "Clear all external peers\n"
4879 "Soft reconfig\n"
4880 "Soft reconfig outbound update\n")
4881
4882ALIAS (clear_bgp_external_soft_out,
4883 clear_bgp_external_out_cmd,
4884 "clear bgp external out",
4885 CLEAR_STR
4886 BGP_STR
4887 "Clear all external peers\n"
4888 "Soft reconfig outbound update\n")
4889
4890ALIAS (clear_bgp_external_soft_out,
4891 clear_bgp_ipv6_external_out_cmd,
4892 "clear bgp ipv6 external WORD out",
4893 CLEAR_STR
4894 BGP_STR
4895 "Address family\n"
4896 "Clear all external peers\n"
4897 "Soft reconfig outbound update\n")
4898
4899DEFUN (clear_ip_bgp_as_soft_out,
4900 clear_ip_bgp_as_soft_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004901 "clear ip bgp " CMD_AS_RANGE " soft out",
paul718e3742002-12-13 20:15:29 +00004902 CLEAR_STR
4903 IP_STR
4904 BGP_STR
4905 "Clear peers with the AS number\n"
4906 "Soft reconfig\n"
4907 "Soft reconfig outbound update\n")
4908{
4909 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
4910 BGP_CLEAR_SOFT_OUT, argv[0]);
4911}
4912
4913ALIAS (clear_ip_bgp_as_soft_out,
4914 clear_ip_bgp_as_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004915 "clear ip bgp " CMD_AS_RANGE " out",
paul718e3742002-12-13 20:15:29 +00004916 CLEAR_STR
4917 IP_STR
4918 BGP_STR
4919 "Clear peers with the AS number\n"
4920 "Soft reconfig outbound update\n")
4921
4922DEFUN (clear_ip_bgp_as_ipv4_soft_out,
4923 clear_ip_bgp_as_ipv4_soft_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004924 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft out",
paul718e3742002-12-13 20:15:29 +00004925 CLEAR_STR
4926 IP_STR
4927 BGP_STR
4928 "Clear peers with the AS number\n"
4929 "Address family\n"
4930 "Address Family modifier\n"
4931 "Address Family modifier\n"
4932 "Soft reconfig\n"
4933 "Soft reconfig outbound update\n")
4934{
4935 if (strncmp (argv[1], "m", 1) == 0)
4936 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
4937 BGP_CLEAR_SOFT_OUT, argv[0]);
4938
4939 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
4940 BGP_CLEAR_SOFT_OUT, argv[0]);
4941}
4942
4943ALIAS (clear_ip_bgp_as_ipv4_soft_out,
4944 clear_ip_bgp_as_ipv4_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004945 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) out",
paul718e3742002-12-13 20:15:29 +00004946 CLEAR_STR
4947 IP_STR
4948 BGP_STR
4949 "Clear peers with the AS number\n"
4950 "Address family\n"
4951 "Address Family modifier\n"
4952 "Address Family modifier\n"
4953 "Soft reconfig outbound update\n")
4954
4955DEFUN (clear_ip_bgp_as_vpnv4_soft_out,
4956 clear_ip_bgp_as_vpnv4_soft_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004957 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft out",
paul718e3742002-12-13 20:15:29 +00004958 CLEAR_STR
4959 IP_STR
4960 BGP_STR
4961 "Clear peers with the AS number\n"
4962 "Address family\n"
4963 "Address Family modifier\n"
4964 "Soft reconfig\n"
4965 "Soft reconfig outbound update\n")
4966{
4967 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
4968 BGP_CLEAR_SOFT_OUT, argv[0]);
4969}
4970
4971ALIAS (clear_ip_bgp_as_vpnv4_soft_out,
4972 clear_ip_bgp_as_vpnv4_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004973 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast out",
paul718e3742002-12-13 20:15:29 +00004974 CLEAR_STR
4975 IP_STR
4976 BGP_STR
4977 "Clear peers with the AS number\n"
4978 "Address family\n"
4979 "Address Family modifier\n"
4980 "Soft reconfig outbound update\n")
4981
4982DEFUN (clear_bgp_as_soft_out,
4983 clear_bgp_as_soft_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004984 "clear bgp " CMD_AS_RANGE " soft out",
paul718e3742002-12-13 20:15:29 +00004985 CLEAR_STR
4986 BGP_STR
4987 "Clear peers with the AS number\n"
4988 "Soft reconfig\n"
4989 "Soft reconfig outbound update\n")
4990{
4991 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
4992 BGP_CLEAR_SOFT_OUT, argv[0]);
4993}
4994
4995ALIAS (clear_bgp_as_soft_out,
4996 clear_bgp_ipv6_as_soft_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004997 "clear bgp ipv6 " CMD_AS_RANGE " soft out",
paul718e3742002-12-13 20:15:29 +00004998 CLEAR_STR
4999 BGP_STR
5000 "Address family\n"
5001 "Clear peers with the AS number\n"
5002 "Soft reconfig\n"
5003 "Soft reconfig outbound update\n")
5004
5005ALIAS (clear_bgp_as_soft_out,
5006 clear_bgp_as_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005007 "clear bgp " CMD_AS_RANGE " out",
paul718e3742002-12-13 20:15:29 +00005008 CLEAR_STR
5009 BGP_STR
5010 "Clear peers with the AS number\n"
5011 "Soft reconfig outbound update\n")
5012
5013ALIAS (clear_bgp_as_soft_out,
5014 clear_bgp_ipv6_as_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005015 "clear bgp ipv6 " CMD_AS_RANGE " out",
paul718e3742002-12-13 20:15:29 +00005016 CLEAR_STR
5017 BGP_STR
5018 "Address family\n"
5019 "Clear peers with the AS number\n"
5020 "Soft reconfig outbound update\n")
5021
5022/* Inbound soft-reconfiguration */
5023DEFUN (clear_ip_bgp_all_soft_in,
5024 clear_ip_bgp_all_soft_in_cmd,
5025 "clear ip bgp * soft in",
5026 CLEAR_STR
5027 IP_STR
5028 BGP_STR
5029 "Clear all peers\n"
5030 "Soft reconfig\n"
5031 "Soft reconfig inbound update\n")
5032{
5033 if (argc == 1)
5034 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5035 BGP_CLEAR_SOFT_IN, NULL);
5036
5037 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5038 BGP_CLEAR_SOFT_IN, NULL);
5039}
5040
5041ALIAS (clear_ip_bgp_all_soft_in,
5042 clear_ip_bgp_instance_all_soft_in_cmd,
5043 "clear ip bgp view WORD * soft in",
5044 CLEAR_STR
5045 IP_STR
5046 BGP_STR
5047 "BGP view\n"
5048 "view name\n"
5049 "Clear all peers\n"
5050 "Soft reconfig\n"
5051 "Soft reconfig inbound update\n")
5052
5053ALIAS (clear_ip_bgp_all_soft_in,
5054 clear_ip_bgp_all_in_cmd,
5055 "clear ip bgp * in",
5056 CLEAR_STR
5057 IP_STR
5058 BGP_STR
5059 "Clear all peers\n"
5060 "Soft reconfig inbound update\n")
5061
5062DEFUN (clear_ip_bgp_all_in_prefix_filter,
5063 clear_ip_bgp_all_in_prefix_filter_cmd,
5064 "clear ip bgp * in prefix-filter",
5065 CLEAR_STR
5066 IP_STR
5067 BGP_STR
5068 "Clear all peers\n"
5069 "Soft reconfig inbound update\n"
5070 "Push out prefix-list ORF and do inbound soft reconfig\n")
5071{
5072 if (argc== 1)
5073 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5074 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5075
5076 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5077 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5078}
5079
5080ALIAS (clear_ip_bgp_all_in_prefix_filter,
5081 clear_ip_bgp_instance_all_in_prefix_filter_cmd,
5082 "clear ip bgp view WORD * in prefix-filter",
5083 CLEAR_STR
5084 IP_STR
5085 BGP_STR
5086 "BGP view\n"
5087 "view name\n"
5088 "Clear all peers\n"
5089 "Soft reconfig inbound update\n"
5090 "Push out prefix-list ORF and do inbound soft reconfig\n")
5091
5092
5093DEFUN (clear_ip_bgp_all_ipv4_soft_in,
5094 clear_ip_bgp_all_ipv4_soft_in_cmd,
5095 "clear ip bgp * ipv4 (unicast|multicast) soft in",
5096 CLEAR_STR
5097 IP_STR
5098 BGP_STR
5099 "Clear all peers\n"
5100 "Address family\n"
5101 "Address Family modifier\n"
5102 "Address Family modifier\n"
5103 "Soft reconfig\n"
5104 "Soft reconfig inbound update\n")
5105{
5106 if (strncmp (argv[0], "m", 1) == 0)
5107 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
5108 BGP_CLEAR_SOFT_IN, NULL);
5109
5110 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5111 BGP_CLEAR_SOFT_IN, NULL);
5112}
5113
5114ALIAS (clear_ip_bgp_all_ipv4_soft_in,
5115 clear_ip_bgp_all_ipv4_in_cmd,
5116 "clear ip bgp * ipv4 (unicast|multicast) in",
5117 CLEAR_STR
5118 IP_STR
5119 BGP_STR
5120 "Clear all peers\n"
5121 "Address family\n"
5122 "Address Family modifier\n"
5123 "Address Family modifier\n"
5124 "Soft reconfig inbound update\n")
5125
5126DEFUN (clear_ip_bgp_instance_all_ipv4_soft_in,
5127 clear_ip_bgp_instance_all_ipv4_soft_in_cmd,
5128 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft in",
5129 CLEAR_STR
5130 IP_STR
5131 BGP_STR
5132 "BGP view\n"
5133 "view name\n"
5134 "Clear all peers\n"
5135 "Address family\n"
5136 "Address Family modifier\n"
5137 "Address Family modifier\n"
5138 "Soft reconfig\n"
5139 "Soft reconfig inbound update\n")
5140{
5141 if (strncmp (argv[1], "m", 1) == 0)
5142 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
5143 BGP_CLEAR_SOFT_IN, NULL);
5144
5145 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5146 BGP_CLEAR_SOFT_IN, NULL);
5147}
5148
5149DEFUN (clear_ip_bgp_all_ipv4_in_prefix_filter,
5150 clear_ip_bgp_all_ipv4_in_prefix_filter_cmd,
5151 "clear ip bgp * ipv4 (unicast|multicast) in prefix-filter",
5152 CLEAR_STR
5153 IP_STR
5154 BGP_STR
5155 "Clear all peers\n"
5156 "Address family\n"
5157 "Address Family modifier\n"
5158 "Address Family modifier\n"
5159 "Soft reconfig inbound update\n"
5160 "Push out prefix-list ORF and do inbound soft reconfig\n")
5161{
5162 if (strncmp (argv[0], "m", 1) == 0)
5163 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
5164 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5165
5166 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5167 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5168}
5169
5170DEFUN (clear_ip_bgp_instance_all_ipv4_in_prefix_filter,
5171 clear_ip_bgp_instance_all_ipv4_in_prefix_filter_cmd,
5172 "clear ip bgp view WORD * ipv4 (unicast|multicast) in prefix-filter",
5173 CLEAR_STR
5174 IP_STR
5175 BGP_STR
5176 "Clear all peers\n"
5177 "Address family\n"
5178 "Address Family modifier\n"
5179 "Address Family modifier\n"
5180 "Soft reconfig inbound update\n"
5181 "Push out prefix-list ORF and do inbound soft reconfig\n")
5182{
5183 if (strncmp (argv[1], "m", 1) == 0)
5184 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
5185 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5186
5187 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5188 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5189}
5190
5191DEFUN (clear_ip_bgp_all_vpnv4_soft_in,
5192 clear_ip_bgp_all_vpnv4_soft_in_cmd,
5193 "clear ip bgp * vpnv4 unicast soft in",
5194 CLEAR_STR
5195 IP_STR
5196 BGP_STR
5197 "Clear all peers\n"
5198 "Address family\n"
5199 "Address Family Modifier\n"
5200 "Soft reconfig\n"
5201 "Soft reconfig inbound update\n")
5202{
5203 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
5204 BGP_CLEAR_SOFT_IN, NULL);
5205}
5206
5207ALIAS (clear_ip_bgp_all_vpnv4_soft_in,
5208 clear_ip_bgp_all_vpnv4_in_cmd,
5209 "clear ip bgp * vpnv4 unicast in",
5210 CLEAR_STR
5211 IP_STR
5212 BGP_STR
5213 "Clear all peers\n"
5214 "Address family\n"
5215 "Address Family Modifier\n"
5216 "Soft reconfig inbound update\n")
5217
5218DEFUN (clear_bgp_all_soft_in,
5219 clear_bgp_all_soft_in_cmd,
5220 "clear bgp * soft in",
5221 CLEAR_STR
5222 BGP_STR
5223 "Clear all peers\n"
5224 "Soft reconfig\n"
5225 "Soft reconfig inbound update\n")
5226{
5227 if (argc == 1)
5228 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
5229 BGP_CLEAR_SOFT_IN, NULL);
5230
5231 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
5232 BGP_CLEAR_SOFT_IN, NULL);
5233}
5234
5235ALIAS (clear_bgp_all_soft_in,
5236 clear_bgp_instance_all_soft_in_cmd,
5237 "clear bgp view WORD * soft in",
5238 CLEAR_STR
5239 BGP_STR
5240 "BGP view\n"
5241 "view name\n"
5242 "Clear all peers\n"
5243 "Soft reconfig\n"
5244 "Soft reconfig inbound update\n")
5245
5246ALIAS (clear_bgp_all_soft_in,
5247 clear_bgp_ipv6_all_soft_in_cmd,
5248 "clear bgp ipv6 * soft in",
5249 CLEAR_STR
5250 BGP_STR
5251 "Address family\n"
5252 "Clear all peers\n"
5253 "Soft reconfig\n"
5254 "Soft reconfig inbound update\n")
5255
5256ALIAS (clear_bgp_all_soft_in,
5257 clear_bgp_all_in_cmd,
5258 "clear bgp * in",
5259 CLEAR_STR
5260 BGP_STR
5261 "Clear all peers\n"
5262 "Soft reconfig inbound update\n")
5263
5264ALIAS (clear_bgp_all_soft_in,
5265 clear_bgp_ipv6_all_in_cmd,
5266 "clear bgp ipv6 * in",
5267 CLEAR_STR
5268 BGP_STR
5269 "Address family\n"
5270 "Clear all peers\n"
5271 "Soft reconfig inbound update\n")
5272
5273DEFUN (clear_bgp_all_in_prefix_filter,
5274 clear_bgp_all_in_prefix_filter_cmd,
5275 "clear bgp * in prefix-filter",
5276 CLEAR_STR
5277 BGP_STR
5278 "Clear all peers\n"
5279 "Soft reconfig inbound update\n"
5280 "Push out prefix-list ORF and do inbound soft reconfig\n")
5281{
5282 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
5283 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5284}
5285
5286ALIAS (clear_bgp_all_in_prefix_filter,
5287 clear_bgp_ipv6_all_in_prefix_filter_cmd,
5288 "clear bgp ipv6 * in prefix-filter",
5289 CLEAR_STR
5290 BGP_STR
5291 "Address family\n"
5292 "Clear all peers\n"
5293 "Soft reconfig inbound update\n"
5294 "Push out prefix-list ORF and do inbound soft reconfig\n")
5295
5296DEFUN (clear_ip_bgp_peer_soft_in,
5297 clear_ip_bgp_peer_soft_in_cmd,
5298 "clear ip bgp A.B.C.D soft in",
5299 CLEAR_STR
5300 IP_STR
5301 BGP_STR
5302 "BGP neighbor address to clear\n"
5303 "Soft reconfig\n"
5304 "Soft reconfig inbound update\n")
5305{
5306 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5307 BGP_CLEAR_SOFT_IN, argv[0]);
5308}
5309
5310ALIAS (clear_ip_bgp_peer_soft_in,
5311 clear_ip_bgp_peer_in_cmd,
5312 "clear ip bgp A.B.C.D in",
5313 CLEAR_STR
5314 IP_STR
5315 BGP_STR
5316 "BGP neighbor address to clear\n"
5317 "Soft reconfig inbound update\n")
5318
5319DEFUN (clear_ip_bgp_peer_in_prefix_filter,
5320 clear_ip_bgp_peer_in_prefix_filter_cmd,
5321 "clear ip bgp A.B.C.D in prefix-filter",
5322 CLEAR_STR
5323 IP_STR
5324 BGP_STR
5325 "BGP neighbor address to clear\n"
5326 "Soft reconfig inbound update\n"
5327 "Push out the existing ORF prefix-list\n")
5328{
5329 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5330 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5331}
5332
5333DEFUN (clear_ip_bgp_peer_ipv4_soft_in,
5334 clear_ip_bgp_peer_ipv4_soft_in_cmd,
5335 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft in",
5336 CLEAR_STR
5337 IP_STR
5338 BGP_STR
5339 "BGP neighbor address to clear\n"
5340 "Address family\n"
5341 "Address Family modifier\n"
5342 "Address Family modifier\n"
5343 "Soft reconfig\n"
5344 "Soft reconfig inbound update\n")
5345{
5346 if (strncmp (argv[1], "m", 1) == 0)
5347 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
5348 BGP_CLEAR_SOFT_IN, argv[0]);
5349
5350 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5351 BGP_CLEAR_SOFT_IN, argv[0]);
5352}
5353
5354ALIAS (clear_ip_bgp_peer_ipv4_soft_in,
5355 clear_ip_bgp_peer_ipv4_in_cmd,
5356 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) in",
5357 CLEAR_STR
5358 IP_STR
5359 BGP_STR
5360 "BGP neighbor address to clear\n"
5361 "Address family\n"
5362 "Address Family modifier\n"
5363 "Address Family modifier\n"
5364 "Soft reconfig inbound update\n")
5365
5366DEFUN (clear_ip_bgp_peer_ipv4_in_prefix_filter,
5367 clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd,
5368 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) in prefix-filter",
5369 CLEAR_STR
5370 IP_STR
5371 BGP_STR
5372 "BGP neighbor address to clear\n"
5373 "Address family\n"
5374 "Address Family modifier\n"
5375 "Address Family modifier\n"
5376 "Soft reconfig inbound update\n"
5377 "Push out the existing ORF prefix-list\n")
5378{
5379 if (strncmp (argv[1], "m", 1) == 0)
5380 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
5381 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
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_vpnv4_soft_in,
5388 clear_ip_bgp_peer_vpnv4_soft_in_cmd,
5389 "clear ip bgp A.B.C.D vpnv4 unicast 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 "Soft reconfig\n"
5397 "Soft reconfig inbound update\n")
5398{
5399 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
5400 BGP_CLEAR_SOFT_IN, argv[0]);
5401}
5402
5403ALIAS (clear_ip_bgp_peer_vpnv4_soft_in,
5404 clear_ip_bgp_peer_vpnv4_in_cmd,
5405 "clear ip bgp A.B.C.D vpnv4 unicast in",
5406 CLEAR_STR
5407 IP_STR
5408 BGP_STR
5409 "BGP neighbor address to clear\n"
5410 "Address family\n"
5411 "Address Family Modifier\n"
5412 "Soft reconfig inbound update\n")
5413
5414DEFUN (clear_bgp_peer_soft_in,
5415 clear_bgp_peer_soft_in_cmd,
5416 "clear bgp (A.B.C.D|X:X::X:X) soft in",
5417 CLEAR_STR
5418 BGP_STR
5419 "BGP neighbor address to clear\n"
5420 "BGP IPv6 neighbor to clear\n"
5421 "Soft reconfig\n"
5422 "Soft reconfig inbound update\n")
5423{
5424 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
5425 BGP_CLEAR_SOFT_IN, argv[0]);
5426}
5427
5428ALIAS (clear_bgp_peer_soft_in,
5429 clear_bgp_ipv6_peer_soft_in_cmd,
5430 "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft in",
5431 CLEAR_STR
5432 BGP_STR
5433 "Address family\n"
5434 "BGP neighbor address to clear\n"
5435 "BGP IPv6 neighbor to clear\n"
5436 "Soft reconfig\n"
5437 "Soft reconfig inbound update\n")
5438
5439ALIAS (clear_bgp_peer_soft_in,
5440 clear_bgp_peer_in_cmd,
5441 "clear bgp (A.B.C.D|X:X::X:X) in",
5442 CLEAR_STR
5443 BGP_STR
5444 "BGP neighbor address to clear\n"
5445 "BGP IPv6 neighbor to clear\n"
5446 "Soft reconfig inbound update\n")
5447
5448ALIAS (clear_bgp_peer_soft_in,
5449 clear_bgp_ipv6_peer_in_cmd,
5450 "clear bgp ipv6 (A.B.C.D|X:X::X:X) in",
5451 CLEAR_STR
5452 BGP_STR
5453 "Address family\n"
5454 "BGP neighbor address to clear\n"
5455 "BGP IPv6 neighbor to clear\n"
5456 "Soft reconfig inbound update\n")
5457
5458DEFUN (clear_bgp_peer_in_prefix_filter,
5459 clear_bgp_peer_in_prefix_filter_cmd,
5460 "clear bgp (A.B.C.D|X:X::X:X) in prefix-filter",
5461 CLEAR_STR
5462 BGP_STR
5463 "BGP neighbor address to clear\n"
5464 "BGP IPv6 neighbor to clear\n"
5465 "Soft reconfig inbound update\n"
5466 "Push out the existing ORF prefix-list\n")
5467{
5468 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
5469 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5470}
5471
5472ALIAS (clear_bgp_peer_in_prefix_filter,
5473 clear_bgp_ipv6_peer_in_prefix_filter_cmd,
5474 "clear bgp ipv6 (A.B.C.D|X:X::X:X) in prefix-filter",
5475 CLEAR_STR
5476 BGP_STR
5477 "Address family\n"
5478 "BGP neighbor address to clear\n"
5479 "BGP IPv6 neighbor to clear\n"
5480 "Soft reconfig inbound update\n"
5481 "Push out the existing ORF prefix-list\n")
5482
5483DEFUN (clear_ip_bgp_peer_group_soft_in,
5484 clear_ip_bgp_peer_group_soft_in_cmd,
5485 "clear ip bgp peer-group WORD soft in",
5486 CLEAR_STR
5487 IP_STR
5488 BGP_STR
5489 "Clear all members of peer-group\n"
5490 "BGP peer-group name\n"
5491 "Soft reconfig\n"
5492 "Soft reconfig inbound update\n")
5493{
5494 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5495 BGP_CLEAR_SOFT_IN, argv[0]);
5496}
5497
5498ALIAS (clear_ip_bgp_peer_group_soft_in,
5499 clear_ip_bgp_peer_group_in_cmd,
5500 "clear ip bgp peer-group WORD in",
5501 CLEAR_STR
5502 IP_STR
5503 BGP_STR
5504 "Clear all members of peer-group\n"
5505 "BGP peer-group name\n"
5506 "Soft reconfig inbound update\n")
5507
5508DEFUN (clear_ip_bgp_peer_group_in_prefix_filter,
5509 clear_ip_bgp_peer_group_in_prefix_filter_cmd,
5510 "clear ip bgp peer-group WORD in prefix-filter",
5511 CLEAR_STR
5512 IP_STR
5513 BGP_STR
5514 "Clear all members of peer-group\n"
5515 "BGP peer-group name\n"
5516 "Soft reconfig inbound update\n"
5517 "Push out prefix-list ORF and do inbound soft reconfig\n")
5518{
5519 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5520 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5521}
5522
5523DEFUN (clear_ip_bgp_peer_group_ipv4_soft_in,
5524 clear_ip_bgp_peer_group_ipv4_soft_in_cmd,
5525 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft in",
5526 CLEAR_STR
5527 IP_STR
5528 BGP_STR
5529 "Clear all members of peer-group\n"
5530 "BGP peer-group name\n"
5531 "Address family\n"
5532 "Address Family modifier\n"
5533 "Address Family modifier\n"
5534 "Soft reconfig\n"
5535 "Soft reconfig inbound update\n")
5536{
5537 if (strncmp (argv[1], "m", 1) == 0)
5538 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
5539 BGP_CLEAR_SOFT_IN, argv[0]);
5540
5541 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5542 BGP_CLEAR_SOFT_IN, argv[0]);
5543}
5544
5545ALIAS (clear_ip_bgp_peer_group_ipv4_soft_in,
5546 clear_ip_bgp_peer_group_ipv4_in_cmd,
5547 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in",
5548 CLEAR_STR
5549 IP_STR
5550 BGP_STR
5551 "Clear all members of peer-group\n"
5552 "BGP peer-group name\n"
5553 "Address family\n"
5554 "Address Family modifier\n"
5555 "Address Family modifier\n"
5556 "Soft reconfig inbound update\n")
5557
5558DEFUN (clear_ip_bgp_peer_group_ipv4_in_prefix_filter,
5559 clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd,
5560 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in prefix-filter",
5561 CLEAR_STR
5562 IP_STR
5563 BGP_STR
5564 "Clear all members of peer-group\n"
5565 "BGP peer-group name\n"
5566 "Address family\n"
5567 "Address Family modifier\n"
5568 "Address Family modifier\n"
5569 "Soft reconfig inbound update\n"
5570 "Push out prefix-list ORF and do inbound soft reconfig\n")
5571{
5572 if (strncmp (argv[1], "m", 1) == 0)
5573 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
5574 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5575
5576 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5577 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5578}
5579
5580DEFUN (clear_bgp_peer_group_soft_in,
5581 clear_bgp_peer_group_soft_in_cmd,
5582 "clear bgp peer-group WORD soft in",
5583 CLEAR_STR
5584 BGP_STR
5585 "Clear all members of peer-group\n"
5586 "BGP peer-group name\n"
5587 "Soft reconfig\n"
5588 "Soft reconfig inbound update\n")
5589{
5590 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
5591 BGP_CLEAR_SOFT_IN, argv[0]);
5592}
5593
5594ALIAS (clear_bgp_peer_group_soft_in,
5595 clear_bgp_ipv6_peer_group_soft_in_cmd,
5596 "clear bgp ipv6 peer-group WORD soft in",
5597 CLEAR_STR
5598 BGP_STR
5599 "Address family\n"
5600 "Clear all members of peer-group\n"
5601 "BGP peer-group name\n"
5602 "Soft reconfig\n"
5603 "Soft reconfig inbound update\n")
5604
5605ALIAS (clear_bgp_peer_group_soft_in,
5606 clear_bgp_peer_group_in_cmd,
5607 "clear bgp peer-group WORD in",
5608 CLEAR_STR
5609 BGP_STR
5610 "Clear all members of peer-group\n"
5611 "BGP peer-group name\n"
5612 "Soft reconfig inbound update\n")
5613
5614ALIAS (clear_bgp_peer_group_soft_in,
5615 clear_bgp_ipv6_peer_group_in_cmd,
5616 "clear bgp ipv6 peer-group WORD in",
5617 CLEAR_STR
5618 BGP_STR
5619 "Address family\n"
5620 "Clear all members of peer-group\n"
5621 "BGP peer-group name\n"
5622 "Soft reconfig inbound update\n")
5623
5624DEFUN (clear_bgp_peer_group_in_prefix_filter,
5625 clear_bgp_peer_group_in_prefix_filter_cmd,
5626 "clear bgp peer-group WORD in prefix-filter",
5627 CLEAR_STR
5628 BGP_STR
5629 "Clear all members of peer-group\n"
5630 "BGP peer-group name\n"
5631 "Soft reconfig inbound update\n"
5632 "Push out prefix-list ORF and do inbound soft reconfig\n")
5633{
5634 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
5635 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5636}
5637
5638ALIAS (clear_bgp_peer_group_in_prefix_filter,
5639 clear_bgp_ipv6_peer_group_in_prefix_filter_cmd,
5640 "clear bgp ipv6 peer-group WORD in prefix-filter",
5641 CLEAR_STR
5642 BGP_STR
5643 "Address family\n"
5644 "Clear all members of peer-group\n"
5645 "BGP peer-group name\n"
5646 "Soft reconfig inbound update\n"
5647 "Push out prefix-list ORF and do inbound soft reconfig\n")
5648
5649DEFUN (clear_ip_bgp_external_soft_in,
5650 clear_ip_bgp_external_soft_in_cmd,
5651 "clear ip bgp external soft in",
5652 CLEAR_STR
5653 IP_STR
5654 BGP_STR
5655 "Clear all external peers\n"
5656 "Soft reconfig\n"
5657 "Soft reconfig inbound update\n")
5658{
5659 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5660 BGP_CLEAR_SOFT_IN, NULL);
5661}
5662
5663ALIAS (clear_ip_bgp_external_soft_in,
5664 clear_ip_bgp_external_in_cmd,
5665 "clear ip bgp external in",
5666 CLEAR_STR
5667 IP_STR
5668 BGP_STR
5669 "Clear all external peers\n"
5670 "Soft reconfig inbound update\n")
5671
5672DEFUN (clear_ip_bgp_external_in_prefix_filter,
5673 clear_ip_bgp_external_in_prefix_filter_cmd,
5674 "clear ip bgp external in prefix-filter",
5675 CLEAR_STR
5676 IP_STR
5677 BGP_STR
5678 "Clear all external peers\n"
5679 "Soft reconfig inbound update\n"
5680 "Push out prefix-list ORF and do inbound soft reconfig\n")
5681{
5682 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5683 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5684}
5685
5686DEFUN (clear_ip_bgp_external_ipv4_soft_in,
5687 clear_ip_bgp_external_ipv4_soft_in_cmd,
5688 "clear ip bgp external ipv4 (unicast|multicast) soft in",
5689 CLEAR_STR
5690 IP_STR
5691 BGP_STR
5692 "Clear all external peers\n"
5693 "Address family\n"
5694 "Address Family modifier\n"
5695 "Address Family modifier\n"
5696 "Soft reconfig\n"
5697 "Soft reconfig inbound update\n")
5698{
5699 if (strncmp (argv[0], "m", 1) == 0)
5700 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
5701 BGP_CLEAR_SOFT_IN, NULL);
5702
5703 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5704 BGP_CLEAR_SOFT_IN, NULL);
5705}
5706
5707ALIAS (clear_ip_bgp_external_ipv4_soft_in,
5708 clear_ip_bgp_external_ipv4_in_cmd,
5709 "clear ip bgp external ipv4 (unicast|multicast) in",
5710 CLEAR_STR
5711 IP_STR
5712 BGP_STR
5713 "Clear all external peers\n"
5714 "Address family\n"
5715 "Address Family modifier\n"
5716 "Address Family modifier\n"
5717 "Soft reconfig inbound update\n")
5718
5719DEFUN (clear_ip_bgp_external_ipv4_in_prefix_filter,
5720 clear_ip_bgp_external_ipv4_in_prefix_filter_cmd,
5721 "clear ip bgp external ipv4 (unicast|multicast) in prefix-filter",
5722 CLEAR_STR
5723 IP_STR
5724 BGP_STR
5725 "Clear all external peers\n"
5726 "Address family\n"
5727 "Address Family modifier\n"
5728 "Address Family modifier\n"
5729 "Soft reconfig inbound update\n"
5730 "Push out prefix-list ORF and do inbound soft reconfig\n")
5731{
5732 if (strncmp (argv[0], "m", 1) == 0)
5733 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
5734 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
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_bgp_external_soft_in,
5741 clear_bgp_external_soft_in_cmd,
5742 "clear bgp external soft in",
5743 CLEAR_STR
5744 BGP_STR
5745 "Clear all external peers\n"
5746 "Soft reconfig\n"
5747 "Soft reconfig inbound update\n")
5748{
5749 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
5750 BGP_CLEAR_SOFT_IN, NULL);
5751}
5752
5753ALIAS (clear_bgp_external_soft_in,
5754 clear_bgp_ipv6_external_soft_in_cmd,
5755 "clear bgp ipv6 external soft in",
5756 CLEAR_STR
5757 BGP_STR
5758 "Address family\n"
5759 "Clear all external peers\n"
5760 "Soft reconfig\n"
5761 "Soft reconfig inbound update\n")
5762
5763ALIAS (clear_bgp_external_soft_in,
5764 clear_bgp_external_in_cmd,
5765 "clear bgp external in",
5766 CLEAR_STR
5767 BGP_STR
5768 "Clear all external peers\n"
5769 "Soft reconfig inbound update\n")
5770
5771ALIAS (clear_bgp_external_soft_in,
5772 clear_bgp_ipv6_external_in_cmd,
5773 "clear bgp ipv6 external WORD in",
5774 CLEAR_STR
5775 BGP_STR
5776 "Address family\n"
5777 "Clear all external peers\n"
5778 "Soft reconfig inbound update\n")
5779
5780DEFUN (clear_bgp_external_in_prefix_filter,
5781 clear_bgp_external_in_prefix_filter_cmd,
5782 "clear bgp external in prefix-filter",
5783 CLEAR_STR
5784 BGP_STR
5785 "Clear all external peers\n"
5786 "Soft reconfig inbound update\n"
5787 "Push out prefix-list ORF and do inbound soft reconfig\n")
5788{
5789 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
5790 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5791}
5792
5793ALIAS (clear_bgp_external_in_prefix_filter,
5794 clear_bgp_ipv6_external_in_prefix_filter_cmd,
5795 "clear bgp ipv6 external in prefix-filter",
5796 CLEAR_STR
5797 BGP_STR
5798 "Address family\n"
5799 "Clear all external peers\n"
5800 "Soft reconfig inbound update\n"
5801 "Push out prefix-list ORF and do inbound soft reconfig\n")
5802
5803DEFUN (clear_ip_bgp_as_soft_in,
5804 clear_ip_bgp_as_soft_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005805 "clear ip bgp " CMD_AS_RANGE " soft in",
paul718e3742002-12-13 20:15:29 +00005806 CLEAR_STR
5807 IP_STR
5808 BGP_STR
5809 "Clear peers with the AS number\n"
5810 "Soft reconfig\n"
5811 "Soft reconfig inbound update\n")
5812{
5813 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5814 BGP_CLEAR_SOFT_IN, argv[0]);
5815}
5816
5817ALIAS (clear_ip_bgp_as_soft_in,
5818 clear_ip_bgp_as_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005819 "clear ip bgp " CMD_AS_RANGE " in",
paul718e3742002-12-13 20:15:29 +00005820 CLEAR_STR
5821 IP_STR
5822 BGP_STR
5823 "Clear peers with the AS number\n"
5824 "Soft reconfig inbound update\n")
5825
5826DEFUN (clear_ip_bgp_as_in_prefix_filter,
5827 clear_ip_bgp_as_in_prefix_filter_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005828 "clear ip bgp " CMD_AS_RANGE " in prefix-filter",
paul718e3742002-12-13 20:15:29 +00005829 CLEAR_STR
5830 IP_STR
5831 BGP_STR
5832 "Clear peers with the AS number\n"
5833 "Soft reconfig inbound update\n"
5834 "Push out prefix-list ORF and do inbound soft reconfig\n")
5835{
5836 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5837 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5838}
5839
5840DEFUN (clear_ip_bgp_as_ipv4_soft_in,
5841 clear_ip_bgp_as_ipv4_soft_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005842 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft in",
paul718e3742002-12-13 20:15:29 +00005843 CLEAR_STR
5844 IP_STR
5845 BGP_STR
5846 "Clear peers with the AS number\n"
5847 "Address family\n"
5848 "Address Family modifier\n"
5849 "Address Family modifier\n"
5850 "Soft reconfig\n"
5851 "Soft reconfig inbound update\n")
5852{
5853 if (strncmp (argv[1], "m", 1) == 0)
5854 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
5855 BGP_CLEAR_SOFT_IN, argv[0]);
5856
5857 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5858 BGP_CLEAR_SOFT_IN, argv[0]);
5859}
5860
5861ALIAS (clear_ip_bgp_as_ipv4_soft_in,
5862 clear_ip_bgp_as_ipv4_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005863 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in",
paul718e3742002-12-13 20:15:29 +00005864 CLEAR_STR
5865 IP_STR
5866 BGP_STR
5867 "Clear peers with the AS number\n"
5868 "Address family\n"
5869 "Address Family modifier\n"
5870 "Address Family modifier\n"
5871 "Soft reconfig inbound update\n")
5872
5873DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter,
5874 clear_ip_bgp_as_ipv4_in_prefix_filter_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005875 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in prefix-filter",
paul718e3742002-12-13 20:15:29 +00005876 CLEAR_STR
5877 IP_STR
5878 BGP_STR
5879 "Clear peers with the AS number\n"
5880 "Address family\n"
5881 "Address Family modifier\n"
5882 "Address Family modifier\n"
5883 "Soft reconfig inbound update\n"
5884 "Push out prefix-list ORF and do inbound soft reconfig\n")
5885{
5886 if (strncmp (argv[1], "m", 1) == 0)
5887 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
5888 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
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_vpnv4_soft_in,
5895 clear_ip_bgp_as_vpnv4_soft_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005896 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast 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 "Soft reconfig\n"
5904 "Soft reconfig inbound update\n")
5905{
5906 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
5907 BGP_CLEAR_SOFT_IN, argv[0]);
5908}
5909
5910ALIAS (clear_ip_bgp_as_vpnv4_soft_in,
5911 clear_ip_bgp_as_vpnv4_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005912 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast in",
paul718e3742002-12-13 20:15:29 +00005913 CLEAR_STR
5914 IP_STR
5915 BGP_STR
5916 "Clear peers with the AS number\n"
5917 "Address family\n"
5918 "Address Family modifier\n"
5919 "Soft reconfig inbound update\n")
5920
5921DEFUN (clear_bgp_as_soft_in,
5922 clear_bgp_as_soft_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005923 "clear bgp " CMD_AS_RANGE " soft in",
paul718e3742002-12-13 20:15:29 +00005924 CLEAR_STR
5925 BGP_STR
5926 "Clear peers with the AS number\n"
5927 "Soft reconfig\n"
5928 "Soft reconfig inbound update\n")
5929{
5930 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
5931 BGP_CLEAR_SOFT_IN, argv[0]);
5932}
5933
5934ALIAS (clear_bgp_as_soft_in,
5935 clear_bgp_ipv6_as_soft_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005936 "clear bgp ipv6 " CMD_AS_RANGE " soft in",
paul718e3742002-12-13 20:15:29 +00005937 CLEAR_STR
5938 BGP_STR
5939 "Address family\n"
5940 "Clear peers with the AS number\n"
5941 "Soft reconfig\n"
5942 "Soft reconfig inbound update\n")
5943
5944ALIAS (clear_bgp_as_soft_in,
5945 clear_bgp_as_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005946 "clear bgp " CMD_AS_RANGE " in",
paul718e3742002-12-13 20:15:29 +00005947 CLEAR_STR
5948 BGP_STR
5949 "Clear peers with the AS number\n"
5950 "Soft reconfig inbound update\n")
5951
5952ALIAS (clear_bgp_as_soft_in,
5953 clear_bgp_ipv6_as_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005954 "clear bgp ipv6 " CMD_AS_RANGE " in",
paul718e3742002-12-13 20:15:29 +00005955 CLEAR_STR
5956 BGP_STR
5957 "Address family\n"
5958 "Clear peers with the AS number\n"
5959 "Soft reconfig inbound update\n")
5960
5961DEFUN (clear_bgp_as_in_prefix_filter,
5962 clear_bgp_as_in_prefix_filter_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005963 "clear bgp " CMD_AS_RANGE " in prefix-filter",
paul718e3742002-12-13 20:15:29 +00005964 CLEAR_STR
5965 BGP_STR
5966 "Clear peers with the AS number\n"
5967 "Soft reconfig inbound update\n"
5968 "Push out prefix-list ORF and do inbound soft reconfig\n")
5969{
5970 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
5971 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5972}
5973
5974ALIAS (clear_bgp_as_in_prefix_filter,
5975 clear_bgp_ipv6_as_in_prefix_filter_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005976 "clear bgp ipv6 " CMD_AS_RANGE " in prefix-filter",
paul718e3742002-12-13 20:15:29 +00005977 CLEAR_STR
5978 BGP_STR
5979 "Address family\n"
5980 "Clear peers with the AS number\n"
5981 "Soft reconfig inbound update\n"
5982 "Push out prefix-list ORF and do inbound soft reconfig\n")
5983
5984/* Both soft-reconfiguration */
5985DEFUN (clear_ip_bgp_all_soft,
5986 clear_ip_bgp_all_soft_cmd,
5987 "clear ip bgp * soft",
5988 CLEAR_STR
5989 IP_STR
5990 BGP_STR
5991 "Clear all peers\n"
5992 "Soft reconfig\n")
5993{
5994 if (argc == 1)
5995 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5996 BGP_CLEAR_SOFT_BOTH, NULL);
5997
5998 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5999 BGP_CLEAR_SOFT_BOTH, NULL);
6000}
6001
6002ALIAS (clear_ip_bgp_all_soft,
6003 clear_ip_bgp_instance_all_soft_cmd,
6004 "clear ip bgp view WORD * soft",
6005 CLEAR_STR
6006 IP_STR
6007 BGP_STR
6008 "BGP view\n"
6009 "view name\n"
6010 "Clear all peers\n"
6011 "Soft reconfig\n")
6012
6013
6014DEFUN (clear_ip_bgp_all_ipv4_soft,
6015 clear_ip_bgp_all_ipv4_soft_cmd,
6016 "clear ip bgp * ipv4 (unicast|multicast) soft",
6017 CLEAR_STR
6018 IP_STR
6019 BGP_STR
6020 "Clear all peers\n"
6021 "Address family\n"
6022 "Address Family Modifier\n"
6023 "Address Family Modifier\n"
6024 "Soft reconfig\n")
6025{
6026 if (strncmp (argv[0], "m", 1) == 0)
6027 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
6028 BGP_CLEAR_SOFT_BOTH, NULL);
6029
6030 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6031 BGP_CLEAR_SOFT_BOTH, NULL);
6032}
6033
6034DEFUN (clear_ip_bgp_instance_all_ipv4_soft,
6035 clear_ip_bgp_instance_all_ipv4_soft_cmd,
6036 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft",
6037 CLEAR_STR
6038 IP_STR
6039 BGP_STR
6040 "BGP view\n"
6041 "view name\n"
6042 "Clear all peers\n"
6043 "Address family\n"
6044 "Address Family Modifier\n"
6045 "Address Family Modifier\n"
6046 "Soft reconfig\n")
6047{
6048 if (strncmp (argv[1], "m", 1) == 0)
6049 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, 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
6056DEFUN (clear_ip_bgp_all_vpnv4_soft,
6057 clear_ip_bgp_all_vpnv4_soft_cmd,
6058 "clear ip bgp * vpnv4 unicast soft",
6059 CLEAR_STR
6060 IP_STR
6061 BGP_STR
6062 "Clear all peers\n"
6063 "Address family\n"
6064 "Address Family Modifier\n"
6065 "Soft reconfig\n")
6066{
6067 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
6068 BGP_CLEAR_SOFT_BOTH, argv[0]);
6069}
6070
6071DEFUN (clear_bgp_all_soft,
6072 clear_bgp_all_soft_cmd,
6073 "clear bgp * soft",
6074 CLEAR_STR
6075 BGP_STR
6076 "Clear all peers\n"
6077 "Soft reconfig\n")
6078{
6079 if (argc == 1)
6080 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
6081 BGP_CLEAR_SOFT_BOTH, argv[0]);
6082
6083 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
6084 BGP_CLEAR_SOFT_BOTH, argv[0]);
6085}
6086
6087ALIAS (clear_bgp_all_soft,
6088 clear_bgp_instance_all_soft_cmd,
6089 "clear bgp view WORD * soft",
6090 CLEAR_STR
6091 BGP_STR
6092 "BGP view\n"
6093 "view name\n"
6094 "Clear all peers\n"
6095 "Soft reconfig\n")
6096
6097ALIAS (clear_bgp_all_soft,
6098 clear_bgp_ipv6_all_soft_cmd,
6099 "clear bgp ipv6 * soft",
6100 CLEAR_STR
6101 BGP_STR
6102 "Address family\n"
6103 "Clear all peers\n"
6104 "Soft reconfig\n")
6105
6106DEFUN (clear_ip_bgp_peer_soft,
6107 clear_ip_bgp_peer_soft_cmd,
6108 "clear ip bgp A.B.C.D soft",
6109 CLEAR_STR
6110 IP_STR
6111 BGP_STR
6112 "BGP neighbor address to clear\n"
6113 "Soft reconfig\n")
6114{
6115 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6116 BGP_CLEAR_SOFT_BOTH, argv[0]);
6117}
6118
6119DEFUN (clear_ip_bgp_peer_ipv4_soft,
6120 clear_ip_bgp_peer_ipv4_soft_cmd,
6121 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft",
6122 CLEAR_STR
6123 IP_STR
6124 BGP_STR
6125 "BGP neighbor address to clear\n"
6126 "Address family\n"
6127 "Address Family Modifier\n"
6128 "Address Family Modifier\n"
6129 "Soft reconfig\n")
6130{
6131 if (strncmp (argv[1], "m", 1) == 0)
6132 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
6133 BGP_CLEAR_SOFT_BOTH, argv[0]);
6134
6135 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6136 BGP_CLEAR_SOFT_BOTH, argv[0]);
6137}
6138
6139DEFUN (clear_ip_bgp_peer_vpnv4_soft,
6140 clear_ip_bgp_peer_vpnv4_soft_cmd,
6141 "clear ip bgp A.B.C.D vpnv4 unicast soft",
6142 CLEAR_STR
6143 IP_STR
6144 BGP_STR
6145 "BGP neighbor address to clear\n"
6146 "Address family\n"
6147 "Address Family Modifier\n"
6148 "Soft reconfig\n")
6149{
6150 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
6151 BGP_CLEAR_SOFT_BOTH, argv[0]);
6152}
6153
6154DEFUN (clear_bgp_peer_soft,
6155 clear_bgp_peer_soft_cmd,
6156 "clear bgp (A.B.C.D|X:X::X:X) soft",
6157 CLEAR_STR
6158 BGP_STR
6159 "BGP neighbor address to clear\n"
6160 "BGP IPv6 neighbor to clear\n"
6161 "Soft reconfig\n")
6162{
6163 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
6164 BGP_CLEAR_SOFT_BOTH, argv[0]);
6165}
6166
6167ALIAS (clear_bgp_peer_soft,
6168 clear_bgp_ipv6_peer_soft_cmd,
6169 "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft",
6170 CLEAR_STR
6171 BGP_STR
6172 "Address family\n"
6173 "BGP neighbor address to clear\n"
6174 "BGP IPv6 neighbor to clear\n"
6175 "Soft reconfig\n")
6176
6177DEFUN (clear_ip_bgp_peer_group_soft,
6178 clear_ip_bgp_peer_group_soft_cmd,
6179 "clear ip bgp peer-group WORD soft",
6180 CLEAR_STR
6181 IP_STR
6182 BGP_STR
6183 "Clear all members of peer-group\n"
6184 "BGP peer-group name\n"
6185 "Soft reconfig\n")
6186{
6187 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6188 BGP_CLEAR_SOFT_BOTH, argv[0]);
6189}
6190
6191DEFUN (clear_ip_bgp_peer_group_ipv4_soft,
6192 clear_ip_bgp_peer_group_ipv4_soft_cmd,
6193 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft",
6194 CLEAR_STR
6195 IP_STR
6196 BGP_STR
6197 "Clear all members of peer-group\n"
6198 "BGP peer-group name\n"
6199 "Address family\n"
6200 "Address Family modifier\n"
6201 "Address Family modifier\n"
6202 "Soft reconfig\n")
6203{
6204 if (strncmp (argv[1], "m", 1) == 0)
6205 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
6206 BGP_CLEAR_SOFT_BOTH, argv[0]);
6207
6208 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6209 BGP_CLEAR_SOFT_BOTH, argv[0]);
6210}
6211
6212DEFUN (clear_bgp_peer_group_soft,
6213 clear_bgp_peer_group_soft_cmd,
6214 "clear bgp peer-group WORD soft",
6215 CLEAR_STR
6216 BGP_STR
6217 "Clear all members of peer-group\n"
6218 "BGP peer-group name\n"
6219 "Soft reconfig\n")
6220{
6221 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
6222 BGP_CLEAR_SOFT_BOTH, argv[0]);
6223}
6224
6225ALIAS (clear_bgp_peer_group_soft,
6226 clear_bgp_ipv6_peer_group_soft_cmd,
6227 "clear bgp ipv6 peer-group WORD soft",
6228 CLEAR_STR
6229 BGP_STR
6230 "Address family\n"
6231 "Clear all members of peer-group\n"
6232 "BGP peer-group name\n"
6233 "Soft reconfig\n")
6234
6235DEFUN (clear_ip_bgp_external_soft,
6236 clear_ip_bgp_external_soft_cmd,
6237 "clear ip bgp external soft",
6238 CLEAR_STR
6239 IP_STR
6240 BGP_STR
6241 "Clear all external peers\n"
6242 "Soft reconfig\n")
6243{
6244 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
6245 BGP_CLEAR_SOFT_BOTH, NULL);
6246}
6247
6248DEFUN (clear_ip_bgp_external_ipv4_soft,
6249 clear_ip_bgp_external_ipv4_soft_cmd,
6250 "clear ip bgp external ipv4 (unicast|multicast) soft",
6251 CLEAR_STR
6252 IP_STR
6253 BGP_STR
6254 "Clear all external peers\n"
6255 "Address family\n"
6256 "Address Family modifier\n"
6257 "Address Family modifier\n"
6258 "Soft reconfig\n")
6259{
6260 if (strncmp (argv[0], "m", 1) == 0)
6261 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
6262 BGP_CLEAR_SOFT_BOTH, NULL);
6263
6264 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
6265 BGP_CLEAR_SOFT_BOTH, NULL);
6266}
6267
6268DEFUN (clear_bgp_external_soft,
6269 clear_bgp_external_soft_cmd,
6270 "clear bgp external soft",
6271 CLEAR_STR
6272 BGP_STR
6273 "Clear all external peers\n"
6274 "Soft reconfig\n")
6275{
6276 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
6277 BGP_CLEAR_SOFT_BOTH, NULL);
6278}
6279
6280ALIAS (clear_bgp_external_soft,
6281 clear_bgp_ipv6_external_soft_cmd,
6282 "clear bgp ipv6 external soft",
6283 CLEAR_STR
6284 BGP_STR
6285 "Address family\n"
6286 "Clear all external peers\n"
6287 "Soft reconfig\n")
6288
6289DEFUN (clear_ip_bgp_as_soft,
6290 clear_ip_bgp_as_soft_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006291 "clear ip bgp " CMD_AS_RANGE " soft",
paul718e3742002-12-13 20:15:29 +00006292 CLEAR_STR
6293 IP_STR
6294 BGP_STR
6295 "Clear peers with the AS number\n"
6296 "Soft reconfig\n")
6297{
6298 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
6299 BGP_CLEAR_SOFT_BOTH, argv[0]);
6300}
6301
6302DEFUN (clear_ip_bgp_as_ipv4_soft,
6303 clear_ip_bgp_as_ipv4_soft_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006304 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft",
paul718e3742002-12-13 20:15:29 +00006305 CLEAR_STR
6306 IP_STR
6307 BGP_STR
6308 "Clear peers with the AS number\n"
6309 "Address family\n"
6310 "Address Family Modifier\n"
6311 "Address Family Modifier\n"
6312 "Soft reconfig\n")
6313{
6314 if (strncmp (argv[1], "m", 1) == 0)
6315 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
6316 BGP_CLEAR_SOFT_BOTH, argv[0]);
6317
6318 return bgp_clear_vty (vty, NULL,AFI_IP, SAFI_UNICAST, clear_as,
6319 BGP_CLEAR_SOFT_BOTH, argv[0]);
6320}
6321
6322DEFUN (clear_ip_bgp_as_vpnv4_soft,
6323 clear_ip_bgp_as_vpnv4_soft_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006324 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft",
paul718e3742002-12-13 20:15:29 +00006325 CLEAR_STR
6326 IP_STR
6327 BGP_STR
6328 "Clear peers with the AS number\n"
6329 "Address family\n"
6330 "Address Family Modifier\n"
6331 "Soft reconfig\n")
6332{
6333 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
6334 BGP_CLEAR_SOFT_BOTH, argv[0]);
6335}
6336
6337DEFUN (clear_bgp_as_soft,
6338 clear_bgp_as_soft_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006339 "clear bgp " CMD_AS_RANGE " soft",
paul718e3742002-12-13 20:15:29 +00006340 CLEAR_STR
6341 BGP_STR
6342 "Clear peers with the AS number\n"
6343 "Soft reconfig\n")
6344{
6345 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
6346 BGP_CLEAR_SOFT_BOTH, argv[0]);
6347}
6348
6349ALIAS (clear_bgp_as_soft,
6350 clear_bgp_ipv6_as_soft_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006351 "clear bgp ipv6 " CMD_AS_RANGE " soft",
paul718e3742002-12-13 20:15:29 +00006352 CLEAR_STR
6353 BGP_STR
6354 "Address family\n"
6355 "Clear peers with the AS number\n"
6356 "Soft reconfig\n")
6357
paulfee0f4c2004-09-13 05:12:46 +00006358/* RS-client soft reconfiguration. */
6359#ifdef HAVE_IPV6
6360DEFUN (clear_bgp_all_rsclient,
6361 clear_bgp_all_rsclient_cmd,
6362 "clear bgp * rsclient",
6363 CLEAR_STR
6364 BGP_STR
6365 "Clear all peers\n"
6366 "Soft reconfig for rsclient RIB\n")
6367{
6368 if (argc == 1)
6369 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
6370 BGP_CLEAR_SOFT_RSCLIENT, NULL);
6371
6372 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
6373 BGP_CLEAR_SOFT_RSCLIENT, NULL);
6374}
6375
6376ALIAS (clear_bgp_all_rsclient,
6377 clear_bgp_ipv6_all_rsclient_cmd,
6378 "clear bgp ipv6 * rsclient",
6379 CLEAR_STR
6380 BGP_STR
6381 "Address family\n"
6382 "Clear all peers\n"
6383 "Soft reconfig for rsclient RIB\n")
6384
6385ALIAS (clear_bgp_all_rsclient,
6386 clear_bgp_instance_all_rsclient_cmd,
6387 "clear bgp view WORD * rsclient",
6388 CLEAR_STR
6389 BGP_STR
6390 "BGP view\n"
6391 "view name\n"
6392 "Clear all peers\n"
6393 "Soft reconfig for rsclient RIB\n")
6394
6395ALIAS (clear_bgp_all_rsclient,
6396 clear_bgp_ipv6_instance_all_rsclient_cmd,
6397 "clear bgp ipv6 view WORD * rsclient",
6398 CLEAR_STR
6399 BGP_STR
6400 "Address family\n"
6401 "BGP view\n"
6402 "view name\n"
6403 "Clear all peers\n"
6404 "Soft reconfig for rsclient RIB\n")
6405#endif /* HAVE_IPV6 */
6406
6407DEFUN (clear_ip_bgp_all_rsclient,
6408 clear_ip_bgp_all_rsclient_cmd,
6409 "clear ip bgp * rsclient",
6410 CLEAR_STR
6411 IP_STR
6412 BGP_STR
6413 "Clear all peers\n"
6414 "Soft reconfig for rsclient RIB\n")
6415{
6416 if (argc == 1)
6417 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
6418 BGP_CLEAR_SOFT_RSCLIENT, NULL);
6419
6420 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6421 BGP_CLEAR_SOFT_RSCLIENT, NULL);
6422}
6423
6424ALIAS (clear_ip_bgp_all_rsclient,
6425 clear_ip_bgp_instance_all_rsclient_cmd,
6426 "clear ip bgp view WORD * rsclient",
6427 CLEAR_STR
6428 IP_STR
6429 BGP_STR
6430 "BGP view\n"
6431 "view name\n"
6432 "Clear all peers\n"
6433 "Soft reconfig for rsclient RIB\n")
6434
6435#ifdef HAVE_IPV6
6436DEFUN (clear_bgp_peer_rsclient,
6437 clear_bgp_peer_rsclient_cmd,
6438 "clear bgp (A.B.C.D|X:X::X:X) rsclient",
6439 CLEAR_STR
6440 BGP_STR
6441 "BGP neighbor IP address to clear\n"
6442 "BGP IPv6 neighbor to clear\n"
6443 "Soft reconfig for rsclient RIB\n")
6444{
6445 if (argc == 2)
6446 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_peer,
6447 BGP_CLEAR_SOFT_RSCLIENT, argv[1]);
6448
6449 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
6450 BGP_CLEAR_SOFT_RSCLIENT, argv[0]);
6451}
6452
6453ALIAS (clear_bgp_peer_rsclient,
6454 clear_bgp_ipv6_peer_rsclient_cmd,
6455 "clear bgp ipv6 (A.B.C.D|X:X::X:X) rsclient",
6456 CLEAR_STR
6457 BGP_STR
6458 "Address family\n"
6459 "BGP neighbor IP address to clear\n"
6460 "BGP IPv6 neighbor to clear\n"
6461 "Soft reconfig for rsclient RIB\n")
6462
6463ALIAS (clear_bgp_peer_rsclient,
6464 clear_bgp_instance_peer_rsclient_cmd,
6465 "clear bgp view WORD (A.B.C.D|X:X::X:X) rsclient",
6466 CLEAR_STR
6467 BGP_STR
6468 "BGP view\n"
6469 "view name\n"
6470 "BGP neighbor IP address to clear\n"
6471 "BGP IPv6 neighbor to clear\n"
6472 "Soft reconfig for rsclient RIB\n")
6473
6474ALIAS (clear_bgp_peer_rsclient,
6475 clear_bgp_ipv6_instance_peer_rsclient_cmd,
6476 "clear bgp ipv6 view WORD (A.B.C.D|X:X::X:X) rsclient",
6477 CLEAR_STR
6478 BGP_STR
6479 "Address family\n"
6480 "BGP view\n"
6481 "view name\n"
6482 "BGP neighbor IP address to clear\n"
6483 "BGP IPv6 neighbor to clear\n"
6484 "Soft reconfig for rsclient RIB\n")
6485#endif /* HAVE_IPV6 */
6486
6487DEFUN (clear_ip_bgp_peer_rsclient,
6488 clear_ip_bgp_peer_rsclient_cmd,
6489 "clear ip bgp (A.B.C.D|X:X::X:X) rsclient",
6490 CLEAR_STR
6491 IP_STR
6492 BGP_STR
6493 "BGP neighbor IP address to clear\n"
6494 "BGP IPv6 neighbor to clear\n"
6495 "Soft reconfig for rsclient RIB\n")
6496{
6497 if (argc == 2)
6498 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_peer,
6499 BGP_CLEAR_SOFT_RSCLIENT, argv[1]);
6500
6501 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6502 BGP_CLEAR_SOFT_RSCLIENT, argv[0]);
6503}
6504
6505ALIAS (clear_ip_bgp_peer_rsclient,
6506 clear_ip_bgp_instance_peer_rsclient_cmd,
6507 "clear ip bgp view WORD (A.B.C.D|X:X::X:X) rsclient",
6508 CLEAR_STR
6509 IP_STR
6510 BGP_STR
6511 "BGP view\n"
6512 "view name\n"
6513 "BGP neighbor IP address to clear\n"
6514 "BGP IPv6 neighbor to clear\n"
6515 "Soft reconfig for rsclient RIB\n")
6516
Michael Lamberte0081f72008-11-16 20:12:04 +00006517DEFUN (show_bgp_views,
6518 show_bgp_views_cmd,
6519 "show bgp views",
6520 SHOW_STR
6521 BGP_STR
6522 "Show the defined BGP views\n")
6523{
6524 struct list *inst = bm->bgp;
6525 struct listnode *node;
6526 struct bgp *bgp;
6527
6528 if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
6529 {
6530 vty_out (vty, "Multiple BGP views are not defined%s", VTY_NEWLINE);
6531 return CMD_WARNING;
6532 }
6533
6534 vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE);
6535 for (ALL_LIST_ELEMENTS_RO(inst, node, bgp))
6536 vty_out (vty, "\t%s (AS%u)%s",
6537 bgp->name ? bgp->name : "(null)",
6538 bgp->as, VTY_NEWLINE);
6539
6540 return CMD_SUCCESS;
6541}
6542
Paul Jakma4bf6a362006-03-30 14:05:23 +00006543DEFUN (show_bgp_memory,
6544 show_bgp_memory_cmd,
6545 "show bgp memory",
6546 SHOW_STR
6547 BGP_STR
6548 "Global BGP memory statistics\n")
6549{
6550 char memstrbuf[MTYPE_MEMSTR_LEN];
6551 unsigned long count;
6552
6553 /* RIB related usage stats */
6554 count = mtype_stats_alloc (MTYPE_BGP_NODE);
6555 vty_out (vty, "%ld RIB nodes, using %s of memory%s", count,
6556 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6557 count * sizeof (struct bgp_node)),
6558 VTY_NEWLINE);
6559
6560 count = mtype_stats_alloc (MTYPE_BGP_ROUTE);
6561 vty_out (vty, "%ld BGP routes, using %s of memory%s", count,
6562 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6563 count * sizeof (struct bgp_info)),
6564 VTY_NEWLINE);
Paul Jakmafb982c22007-05-04 20:15:47 +00006565 if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA)))
6566 vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count,
6567 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6568 count * sizeof (struct bgp_info_extra)),
6569 VTY_NEWLINE);
Paul Jakma4bf6a362006-03-30 14:05:23 +00006570
6571 if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC)))
6572 vty_out (vty, "%ld Static routes, using %s of memory%s", count,
6573 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6574 count * sizeof (struct bgp_static)),
6575 VTY_NEWLINE);
6576
6577 /* Adj-In/Out */
6578 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN)))
6579 vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count,
6580 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6581 count * sizeof (struct bgp_adj_in)),
6582 VTY_NEWLINE);
6583 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT)))
6584 vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count,
6585 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6586 count * sizeof (struct bgp_adj_out)),
6587 VTY_NEWLINE);
6588
6589 if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE)))
6590 vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count,
6591 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6592 count * sizeof (struct bgp_nexthop_cache)),
6593 VTY_NEWLINE);
6594
6595 if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO)))
6596 vty_out (vty, "%ld Dampening entries, using %s of memory%s", count,
6597 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6598 count * sizeof (struct bgp_damp_info)),
6599 VTY_NEWLINE);
6600
6601 /* Attributes */
6602 count = attr_count();
6603 vty_out (vty, "%ld BGP attributes, using %s of memory%s", count,
6604 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6605 count * sizeof(struct attr)),
6606 VTY_NEWLINE);
Paul Jakmafb982c22007-05-04 20:15:47 +00006607 if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA)))
6608 vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count,
6609 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6610 count * sizeof(struct attr_extra)),
6611 VTY_NEWLINE);
Paul Jakma4bf6a362006-03-30 14:05:23 +00006612
6613 if ((count = attr_unknown_count()))
6614 vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE);
6615
6616 /* AS_PATH attributes */
6617 count = aspath_count ();
6618 vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count,
6619 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6620 count * sizeof (struct aspath)),
6621 VTY_NEWLINE);
6622
6623 count = mtype_stats_alloc (MTYPE_AS_SEG);
6624 vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count,
6625 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6626 count * sizeof (struct assegment)),
6627 VTY_NEWLINE);
6628
6629 /* Other attributes */
6630 if ((count = community_count ()))
6631 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
6632 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6633 count * sizeof (struct community)),
6634 VTY_NEWLINE);
6635 if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY)))
6636 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
6637 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6638 count * sizeof (struct ecommunity)),
6639 VTY_NEWLINE);
6640
6641 if ((count = mtype_stats_alloc (MTYPE_CLUSTER)))
6642 vty_out (vty, "%ld Cluster lists, using %s of memory%s", count,
6643 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6644 count * sizeof (struct cluster_list)),
6645 VTY_NEWLINE);
6646
6647 /* Peer related usage */
6648 count = mtype_stats_alloc (MTYPE_BGP_PEER);
6649 vty_out (vty, "%ld peers, using %s of memory%s", count,
6650 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6651 count * sizeof (struct peer)),
6652 VTY_NEWLINE);
6653
6654 if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP)))
6655 vty_out (vty, "%ld peer groups, using %s of memory%s", count,
6656 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6657 count * sizeof (struct peer_group)),
6658 VTY_NEWLINE);
6659
6660 /* Other */
6661 if ((count = mtype_stats_alloc (MTYPE_HASH)))
6662 vty_out (vty, "%ld hash tables, using %s of memory%s", count,
6663 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6664 count * sizeof (struct hash)),
6665 VTY_NEWLINE);
6666 if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET)))
6667 vty_out (vty, "%ld hash buckets, using %s of memory%s", count,
6668 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6669 count * sizeof (struct hash_backet)),
6670 VTY_NEWLINE);
6671 if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP)))
6672 vty_out (vty, "%ld compiled regexes, using %s of memory%s", count,
6673 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6674 count * sizeof (regex_t)),
6675 VTY_NEWLINE);
6676 return CMD_SUCCESS;
6677}
paulfee0f4c2004-09-13 05:12:46 +00006678
paul718e3742002-12-13 20:15:29 +00006679/* Show BGP peer's summary information. */
paul94f2b392005-06-28 12:44:16 +00006680static int
paul718e3742002-12-13 20:15:29 +00006681bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi)
6682{
6683 struct peer *peer;
paul1eb8ef22005-04-07 07:30:20 +00006684 struct listnode *node, *nnode;
Paul Jakma4bf6a362006-03-30 14:05:23 +00006685 unsigned int count = 0;
paul718e3742002-12-13 20:15:29 +00006686 char timebuf[BGP_UPTIME_LEN];
6687 int len;
6688
6689 /* Header string for each address family. */
6690 static char header[] = "Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd";
Paul Jakma4bf6a362006-03-30 14:05:23 +00006691
paul1eb8ef22005-04-07 07:30:20 +00006692 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00006693 {
6694 if (peer->afc[afi][safi])
6695 {
Paul Jakma4bf6a362006-03-30 14:05:23 +00006696 if (!count)
6697 {
6698 unsigned long ents;
6699 char memstrbuf[MTYPE_MEMSTR_LEN];
6700
6701 /* Usage summary and header */
6702 vty_out (vty,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04006703 "BGP router identifier %s, local AS number %u%s",
Paul Jakma4bf6a362006-03-30 14:05:23 +00006704 inet_ntoa (bgp->router_id), bgp->as, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006705
Paul Jakma4bf6a362006-03-30 14:05:23 +00006706 ents = bgp_table_count (bgp->rib[afi][safi]);
6707 vty_out (vty, "RIB entries %ld, using %s of memory%s", ents,
6708 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6709 ents * sizeof (struct bgp_node)),
6710 VTY_NEWLINE);
6711
6712 /* Peer related usage */
6713 ents = listcount (bgp->peer);
6714 vty_out (vty, "Peers %ld, using %s of memory%s",
6715 ents,
6716 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6717 ents * sizeof (struct peer)),
6718 VTY_NEWLINE);
6719
6720 if ((ents = listcount (bgp->rsclient)))
6721 vty_out (vty, "RS-Client peers %ld, using %s of memory%s",
6722 ents,
6723 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6724 ents * sizeof (struct peer)),
6725 VTY_NEWLINE);
6726
6727 if ((ents = listcount (bgp->group)))
6728 vty_out (vty, "Peer groups %ld, using %s of memory%s", ents,
6729 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6730 ents * sizeof (struct peer_group)),
6731 VTY_NEWLINE);
6732
6733 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
6734 vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE);
6735 vty_out (vty, "%s", VTY_NEWLINE);
6736 vty_out (vty, "%s%s", header, VTY_NEWLINE);
6737 }
6738
paul718e3742002-12-13 20:15:29 +00006739 count++;
6740
6741 len = vty_out (vty, "%s", peer->host);
6742 len = 16 - len;
6743 if (len < 1)
6744 vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
6745 else
6746 vty_out (vty, "%*s", len, " ");
6747
hasso3d515fd2005-02-01 21:30:04 +00006748 vty_out (vty, "4 ");
paul718e3742002-12-13 20:15:29 +00006749
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04006750 vty_out (vty, "%5u %7d %7d %8d %4d %4lu ",
paul718e3742002-12-13 20:15:29 +00006751 peer->as,
6752 peer->open_in + peer->update_in + peer->keepalive_in
6753 + peer->notify_in + peer->refresh_in + peer->dynamic_cap_in,
6754 peer->open_out + peer->update_out + peer->keepalive_out
6755 + peer->notify_out + peer->refresh_out
6756 + peer->dynamic_cap_out,
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00006757 0, 0, (unsigned long) peer->obuf->count);
paul718e3742002-12-13 20:15:29 +00006758
6759 vty_out (vty, "%8s",
6760 peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN));
6761
6762 if (peer->status == Established)
6763 {
6764 vty_out (vty, " %8ld", peer->pcount[afi][safi]);
6765 }
6766 else
6767 {
6768 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
6769 vty_out (vty, " Idle (Admin)");
6770 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
6771 vty_out (vty, " Idle (PfxCt)");
6772 else
6773 vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, peer->status));
6774 }
6775
6776 vty_out (vty, "%s", VTY_NEWLINE);
6777 }
6778 }
6779
6780 if (count)
6781 vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE,
6782 count, VTY_NEWLINE);
6783 else
6784 vty_out (vty, "No %s neighbor is configured%s",
6785 afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
6786 return CMD_SUCCESS;
6787}
6788
paul94f2b392005-06-28 12:44:16 +00006789static int
paulfd79ac92004-10-13 05:06:08 +00006790bgp_show_summary_vty (struct vty *vty, const char *name,
6791 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00006792{
6793 struct bgp *bgp;
6794
6795 if (name)
6796 {
6797 bgp = bgp_lookup_by_name (name);
6798
6799 if (! bgp)
6800 {
6801 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
6802 return CMD_WARNING;
6803 }
6804
6805 bgp_show_summary (vty, bgp, afi, safi);
6806 return CMD_SUCCESS;
6807 }
6808
6809 bgp = bgp_get_default ();
6810
6811 if (bgp)
6812 bgp_show_summary (vty, bgp, afi, safi);
6813
6814 return CMD_SUCCESS;
6815}
6816
6817/* `show ip bgp summary' commands. */
6818DEFUN (show_ip_bgp_summary,
6819 show_ip_bgp_summary_cmd,
6820 "show ip bgp summary",
6821 SHOW_STR
6822 IP_STR
6823 BGP_STR
6824 "Summary of BGP neighbor status\n")
6825{
6826 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
6827}
6828
6829DEFUN (show_ip_bgp_instance_summary,
6830 show_ip_bgp_instance_summary_cmd,
6831 "show ip bgp view WORD summary",
6832 SHOW_STR
6833 IP_STR
6834 BGP_STR
6835 "BGP view\n"
6836 "View name\n"
6837 "Summary of BGP neighbor status\n")
6838{
6839 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
6840}
6841
6842DEFUN (show_ip_bgp_ipv4_summary,
6843 show_ip_bgp_ipv4_summary_cmd,
6844 "show ip bgp ipv4 (unicast|multicast) summary",
6845 SHOW_STR
6846 IP_STR
6847 BGP_STR
6848 "Address family\n"
6849 "Address Family modifier\n"
6850 "Address Family modifier\n"
6851 "Summary of BGP neighbor status\n")
6852{
6853 if (strncmp (argv[0], "m", 1) == 0)
6854 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST);
6855
6856 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
6857}
6858
6859DEFUN (show_ip_bgp_instance_ipv4_summary,
6860 show_ip_bgp_instance_ipv4_summary_cmd,
6861 "show ip bgp view WORD ipv4 (unicast|multicast) summary",
6862 SHOW_STR
6863 IP_STR
6864 BGP_STR
6865 "BGP view\n"
6866 "View name\n"
6867 "Address family\n"
6868 "Address Family modifier\n"
6869 "Address Family modifier\n"
6870 "Summary of BGP neighbor status\n")
6871{
6872 if (strncmp (argv[1], "m", 1) == 0)
6873 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST);
6874 else
6875 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
6876}
6877
6878DEFUN (show_ip_bgp_vpnv4_all_summary,
6879 show_ip_bgp_vpnv4_all_summary_cmd,
6880 "show ip bgp vpnv4 all summary",
6881 SHOW_STR
6882 IP_STR
6883 BGP_STR
6884 "Display VPNv4 NLRI specific information\n"
6885 "Display information about all VPNv4 NLRIs\n"
6886 "Summary of BGP neighbor status\n")
6887{
6888 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN);
6889}
6890
6891DEFUN (show_ip_bgp_vpnv4_rd_summary,
6892 show_ip_bgp_vpnv4_rd_summary_cmd,
6893 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn summary",
6894 SHOW_STR
6895 IP_STR
6896 BGP_STR
6897 "Display VPNv4 NLRI specific information\n"
6898 "Display information for a route distinguisher\n"
6899 "VPN Route Distinguisher\n"
6900 "Summary of BGP neighbor status\n")
6901{
6902 int ret;
6903 struct prefix_rd prd;
6904
6905 ret = str2prefix_rd (argv[0], &prd);
6906 if (! ret)
6907 {
6908 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
6909 return CMD_WARNING;
6910 }
6911
6912 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN);
6913}
6914
6915#ifdef HAVE_IPV6
6916DEFUN (show_bgp_summary,
6917 show_bgp_summary_cmd,
6918 "show bgp summary",
6919 SHOW_STR
6920 BGP_STR
6921 "Summary of BGP neighbor status\n")
6922{
6923 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
6924}
6925
6926DEFUN (show_bgp_instance_summary,
6927 show_bgp_instance_summary_cmd,
6928 "show bgp view WORD summary",
6929 SHOW_STR
6930 BGP_STR
6931 "BGP view\n"
6932 "View name\n"
6933 "Summary of BGP neighbor status\n")
6934{
6935 return bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
6936}
6937
6938ALIAS (show_bgp_summary,
6939 show_bgp_ipv6_summary_cmd,
6940 "show bgp ipv6 summary",
6941 SHOW_STR
6942 BGP_STR
6943 "Address family\n"
6944 "Summary of BGP neighbor status\n")
6945
6946ALIAS (show_bgp_instance_summary,
6947 show_bgp_instance_ipv6_summary_cmd,
6948 "show bgp view WORD ipv6 summary",
6949 SHOW_STR
6950 BGP_STR
6951 "BGP view\n"
6952 "View name\n"
6953 "Address family\n"
6954 "Summary of BGP neighbor status\n")
6955
6956/* old command */
6957DEFUN (show_ipv6_bgp_summary,
6958 show_ipv6_bgp_summary_cmd,
6959 "show ipv6 bgp summary",
6960 SHOW_STR
6961 IPV6_STR
6962 BGP_STR
6963 "Summary of BGP neighbor status\n")
6964{
6965 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
6966}
6967
6968/* old command */
6969DEFUN (show_ipv6_mbgp_summary,
6970 show_ipv6_mbgp_summary_cmd,
6971 "show ipv6 mbgp summary",
6972 SHOW_STR
6973 IPV6_STR
6974 MBGP_STR
6975 "Summary of BGP neighbor status\n")
6976{
6977 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST);
6978}
6979#endif /* HAVE_IPV6 */
6980
paulfd79ac92004-10-13 05:06:08 +00006981const char *
hasso538621f2004-05-21 09:31:30 +00006982afi_safi_print (afi_t afi, safi_t safi)
6983{
6984 if (afi == AFI_IP && safi == SAFI_UNICAST)
6985 return "IPv4 Unicast";
6986 else if (afi == AFI_IP && safi == SAFI_MULTICAST)
6987 return "IPv4 Multicast";
6988 else if (afi == AFI_IP && safi == SAFI_MPLS_VPN)
6989 return "VPNv4 Unicast";
6990 else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
6991 return "IPv6 Unicast";
6992 else if (afi == AFI_IP6 && safi == SAFI_MULTICAST)
6993 return "IPv6 Multicast";
6994 else
6995 return "Unknown";
6996}
6997
paul718e3742002-12-13 20:15:29 +00006998/* Show BGP peer's information. */
6999enum show_type
7000{
7001 show_all,
7002 show_peer
7003};
7004
paul94f2b392005-06-28 12:44:16 +00007005static void
paul718e3742002-12-13 20:15:29 +00007006bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p,
7007 afi_t afi, safi_t safi,
7008 u_int16_t adv_smcap, u_int16_t adv_rmcap,
7009 u_int16_t rcv_smcap, u_int16_t rcv_rmcap)
7010{
7011 /* Send-Mode */
7012 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)
7013 || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
7014 {
7015 vty_out (vty, " Send-mode: ");
7016 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
7017 vty_out (vty, "advertised");
7018 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
7019 vty_out (vty, "%sreceived",
7020 CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ?
7021 ", " : "");
7022 vty_out (vty, "%s", VTY_NEWLINE);
7023 }
7024
7025 /* Receive-Mode */
7026 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)
7027 || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
7028 {
7029 vty_out (vty, " Receive-mode: ");
7030 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
7031 vty_out (vty, "advertised");
7032 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
7033 vty_out (vty, "%sreceived",
7034 CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ?
7035 ", " : "");
7036 vty_out (vty, "%s", VTY_NEWLINE);
7037 }
7038}
7039
paul94f2b392005-06-28 12:44:16 +00007040static void
paul718e3742002-12-13 20:15:29 +00007041bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi)
7042{
7043 struct bgp_filter *filter;
7044 char orf_pfx_name[BUFSIZ];
7045 int orf_pfx_count;
7046
7047 filter = &p->filter[afi][safi];
7048
hasso538621f2004-05-21 09:31:30 +00007049 vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi),
paul718e3742002-12-13 20:15:29 +00007050 VTY_NEWLINE);
hasso538621f2004-05-21 09:31:30 +00007051
paul718e3742002-12-13 20:15:29 +00007052 if (p->af_group[afi][safi])
7053 vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE);
7054
7055 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7056 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
7057 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
7058 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7059 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
7060 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
7061 vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE);
7062
7063 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7064 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
7065 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7066 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
7067 {
7068 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
7069 ORF_TYPE_PREFIX, VTY_NEWLINE);
7070 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
7071 PEER_CAP_ORF_PREFIX_SM_ADV,
7072 PEER_CAP_ORF_PREFIX_RM_ADV,
7073 PEER_CAP_ORF_PREFIX_SM_RCV,
7074 PEER_CAP_ORF_PREFIX_RM_RCV);
7075 }
7076 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7077 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
7078 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7079 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
7080 {
7081 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
7082 ORF_TYPE_PREFIX_OLD, VTY_NEWLINE);
7083 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
7084 PEER_CAP_ORF_PREFIX_SM_ADV,
7085 PEER_CAP_ORF_PREFIX_RM_ADV,
7086 PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
7087 PEER_CAP_ORF_PREFIX_RM_OLD_RCV);
7088 }
7089
7090 sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
7091 orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name);
7092
7093 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
7094 || orf_pfx_count)
7095 {
7096 vty_out (vty, " Outbound Route Filter (ORF):");
7097 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
7098 vty_out (vty, " sent;");
7099 if (orf_pfx_count)
7100 vty_out (vty, " received (%d entries)", orf_pfx_count);
7101 vty_out (vty, "%s", VTY_NEWLINE);
7102 }
7103 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
7104 vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE);
7105
7106 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
7107 vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE);
7108 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
7109 vty_out (vty, " Route-Server Client%s", VTY_NEWLINE);
7110 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
7111 vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE);
7112 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
7113 vty_out (vty, " Private AS number removed from updates to this neighbor%s", VTY_NEWLINE);
7114 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF))
7115 vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE);
7116 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
7117 vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE);
7118 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
7119 vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE);
7120 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
7121 vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE);
7122 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
7123 || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
7124 {
7125 vty_out (vty, " Community attribute sent to this neighbor");
7126 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
7127 && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
hasso538621f2004-05-21 09:31:30 +00007128 vty_out (vty, "(both)%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007129 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
hasso538621f2004-05-21 09:31:30 +00007130 vty_out (vty, "(extended)%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007131 else
hasso538621f2004-05-21 09:31:30 +00007132 vty_out (vty, "(standard)%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007133 }
7134 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
7135 {
7136 vty_out (vty, " Default information originate,");
7137
7138 if (p->default_rmap[afi][safi].name)
7139 vty_out (vty, " default route-map %s%s,",
7140 p->default_rmap[afi][safi].map ? "*" : "",
7141 p->default_rmap[afi][safi].name);
7142 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
7143 vty_out (vty, " default sent%s", VTY_NEWLINE);
7144 else
7145 vty_out (vty, " default not sent%s", VTY_NEWLINE);
7146 }
7147
7148 if (filter->plist[FILTER_IN].name
7149 || filter->dlist[FILTER_IN].name
7150 || filter->aslist[FILTER_IN].name
paulfee0f4c2004-09-13 05:12:46 +00007151 || filter->map[RMAP_IN].name)
paul718e3742002-12-13 20:15:29 +00007152 vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE);
7153 if (filter->plist[FILTER_OUT].name
7154 || filter->dlist[FILTER_OUT].name
7155 || filter->aslist[FILTER_OUT].name
paulfee0f4c2004-09-13 05:12:46 +00007156 || filter->map[RMAP_OUT].name
paul718e3742002-12-13 20:15:29 +00007157 || filter->usmap.name)
7158 vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE);
paulfee0f4c2004-09-13 05:12:46 +00007159 if (filter->map[RMAP_IMPORT].name)
7160 vty_out (vty, " Import policy for this RS-client configured%s", VTY_NEWLINE);
7161 if (filter->map[RMAP_EXPORT].name)
7162 vty_out (vty, " Export policy for this RS-client configured%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007163
7164 /* prefix-list */
7165 if (filter->plist[FILTER_IN].name)
7166 vty_out (vty, " Incoming update prefix filter list is %s%s%s",
7167 filter->plist[FILTER_IN].plist ? "*" : "",
7168 filter->plist[FILTER_IN].name,
7169 VTY_NEWLINE);
7170 if (filter->plist[FILTER_OUT].name)
7171 vty_out (vty, " Outgoing update prefix filter list is %s%s%s",
7172 filter->plist[FILTER_OUT].plist ? "*" : "",
7173 filter->plist[FILTER_OUT].name,
7174 VTY_NEWLINE);
7175
7176 /* distribute-list */
7177 if (filter->dlist[FILTER_IN].name)
7178 vty_out (vty, " Incoming update network filter list is %s%s%s",
7179 filter->dlist[FILTER_IN].alist ? "*" : "",
7180 filter->dlist[FILTER_IN].name,
7181 VTY_NEWLINE);
7182 if (filter->dlist[FILTER_OUT].name)
7183 vty_out (vty, " Outgoing update network filter list is %s%s%s",
7184 filter->dlist[FILTER_OUT].alist ? "*" : "",
7185 filter->dlist[FILTER_OUT].name,
7186 VTY_NEWLINE);
7187
7188 /* filter-list. */
7189 if (filter->aslist[FILTER_IN].name)
7190 vty_out (vty, " Incoming update AS path filter list is %s%s%s",
7191 filter->aslist[FILTER_IN].aslist ? "*" : "",
7192 filter->aslist[FILTER_IN].name,
7193 VTY_NEWLINE);
7194 if (filter->aslist[FILTER_OUT].name)
7195 vty_out (vty, " Outgoing update AS path filter list is %s%s%s",
7196 filter->aslist[FILTER_OUT].aslist ? "*" : "",
7197 filter->aslist[FILTER_OUT].name,
7198 VTY_NEWLINE);
7199
7200 /* route-map. */
paulfee0f4c2004-09-13 05:12:46 +00007201 if (filter->map[RMAP_IN].name)
paul718e3742002-12-13 20:15:29 +00007202 vty_out (vty, " Route map for incoming advertisements is %s%s%s",
paulfee0f4c2004-09-13 05:12:46 +00007203 filter->map[RMAP_IN].map ? "*" : "",
7204 filter->map[RMAP_IN].name,
paul718e3742002-12-13 20:15:29 +00007205 VTY_NEWLINE);
paulfee0f4c2004-09-13 05:12:46 +00007206 if (filter->map[RMAP_OUT].name)
paul718e3742002-12-13 20:15:29 +00007207 vty_out (vty, " Route map for outgoing advertisements is %s%s%s",
paulfee0f4c2004-09-13 05:12:46 +00007208 filter->map[RMAP_OUT].map ? "*" : "",
7209 filter->map[RMAP_OUT].name,
7210 VTY_NEWLINE);
7211 if (filter->map[RMAP_IMPORT].name)
7212 vty_out (vty, " Route map for advertisements going into this RS-client's table is %s%s%s",
7213 filter->map[RMAP_IMPORT].map ? "*" : "",
7214 filter->map[RMAP_IMPORT].name,
7215 VTY_NEWLINE);
7216 if (filter->map[RMAP_EXPORT].name)
7217 vty_out (vty, " Route map for advertisements coming from this RS-client is %s%s%s",
7218 filter->map[RMAP_EXPORT].map ? "*" : "",
7219 filter->map[RMAP_EXPORT].name,
paul718e3742002-12-13 20:15:29 +00007220 VTY_NEWLINE);
7221
7222 /* unsuppress-map */
7223 if (filter->usmap.name)
7224 vty_out (vty, " Route map for selective unsuppress is %s%s%s",
7225 filter->usmap.map ? "*" : "",
7226 filter->usmap.name, VTY_NEWLINE);
7227
7228 /* Receive prefix count */
hassoe0701b72004-05-20 09:19:34 +00007229 vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE);
7230
paul718e3742002-12-13 20:15:29 +00007231 /* Maximum prefix */
7232 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
7233 {
hasso0a486e52005-02-01 20:57:17 +00007234 vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi],
paul718e3742002-12-13 20:15:29 +00007235 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)
hasso0a486e52005-02-01 20:57:17 +00007236 ? " (warning-only)" : "", VTY_NEWLINE);
7237 vty_out (vty, " Threshold for warning message %d%%",
7238 p->pmax_threshold[afi][safi]);
7239 if (p->pmax_restart[afi][safi])
7240 vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]);
7241 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007242 }
paul718e3742002-12-13 20:15:29 +00007243
7244 vty_out (vty, "%s", VTY_NEWLINE);
7245}
7246
paul94f2b392005-06-28 12:44:16 +00007247static void
paul718e3742002-12-13 20:15:29 +00007248bgp_show_peer (struct vty *vty, struct peer *p)
7249{
7250 struct bgp *bgp;
7251 char buf1[BUFSIZ];
7252 char timebuf[BGP_UPTIME_LEN];
hasso538621f2004-05-21 09:31:30 +00007253 afi_t afi;
7254 safi_t safi;
paul718e3742002-12-13 20:15:29 +00007255
7256 bgp = p->bgp;
7257
7258 /* Configured IP address. */
7259 vty_out (vty, "BGP neighbor is %s, ", p->host);
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04007260 vty_out (vty, "remote AS %u, ", p->as);
7261 vty_out (vty, "local AS %u%s, ",
paul718e3742002-12-13 20:15:29 +00007262 p->change_local_as ? p->change_local_as : p->local_as,
7263 CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ?
7264 " no-prepend" : "");
7265 vty_out (vty, "%s link%s",
7266 p->as == p->local_as ? "internal" : "external",
7267 VTY_NEWLINE);
7268
7269 /* Description. */
7270 if (p->desc)
7271 vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE);
7272
7273 /* Peer-group */
7274 if (p->group)
7275 vty_out (vty, " Member of peer-group %s for session parameters%s",
7276 p->group->name, VTY_NEWLINE);
7277
7278 /* Administrative shutdown. */
7279 if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
7280 vty_out (vty, " Administratively shut down%s", VTY_NEWLINE);
7281
7282 /* BGP Version. */
7283 vty_out (vty, " BGP version 4");
paul718e3742002-12-13 20:15:29 +00007284 vty_out (vty, ", remote router ID %s%s",
7285 inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ),
7286 VTY_NEWLINE);
7287
7288 /* Confederation */
hassoe0701b72004-05-20 09:19:34 +00007289 if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION)
7290 && bgp_confederation_peers_check (bgp, p->as))
paul718e3742002-12-13 20:15:29 +00007291 vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE);
7292
7293 /* Status. */
7294 vty_out (vty, " BGP state = %s",
7295 LOOKUP (bgp_status_msg, p->status));
7296 if (p->status == Established)
7297 vty_out (vty, ", up for %8s",
7298 peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN));
hasso93406d82005-02-02 14:40:33 +00007299 else if (p->status == Active)
7300 {
7301 if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE))
7302 vty_out (vty, " (passive)");
7303 else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT))
7304 vty_out (vty, " (NSF passive)");
7305 }
paul718e3742002-12-13 20:15:29 +00007306 vty_out (vty, "%s", VTY_NEWLINE);
7307
7308 /* read timer */
7309 vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN));
7310
7311 /* Configured timer values. */
7312 vty_out (vty, ", hold time is %d, keepalive interval is %d seconds%s",
7313 p->v_holdtime, p->v_keepalive, VTY_NEWLINE);
7314 if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
7315 {
7316 vty_out (vty, " Configured hold time is %d", p->holdtime);
7317 vty_out (vty, ", keepalive interval is %d seconds%s",
7318 p->keepalive, VTY_NEWLINE);
7319 }
hasso93406d82005-02-02 14:40:33 +00007320
paul718e3742002-12-13 20:15:29 +00007321 /* Capability. */
7322 if (p->status == Established)
7323 {
hasso538621f2004-05-21 09:31:30 +00007324 if (p->cap
paul718e3742002-12-13 20:15:29 +00007325 || p->afc_adv[AFI_IP][SAFI_UNICAST]
7326 || p->afc_recv[AFI_IP][SAFI_UNICAST]
7327 || p->afc_adv[AFI_IP][SAFI_MULTICAST]
7328 || p->afc_recv[AFI_IP][SAFI_MULTICAST]
7329#ifdef HAVE_IPV6
7330 || p->afc_adv[AFI_IP6][SAFI_UNICAST]
7331 || p->afc_recv[AFI_IP6][SAFI_UNICAST]
7332 || p->afc_adv[AFI_IP6][SAFI_MULTICAST]
7333 || p->afc_recv[AFI_IP6][SAFI_MULTICAST]
7334#endif /* HAVE_IPV6 */
7335 || p->afc_adv[AFI_IP][SAFI_MPLS_VPN]
7336 || p->afc_recv[AFI_IP][SAFI_MPLS_VPN])
7337 {
7338 vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE);
7339
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00007340 /* AS4 */
7341 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)
7342 || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
7343 {
7344 vty_out (vty, " 4 Byte AS:");
7345 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
7346 vty_out (vty, " advertised");
7347 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
7348 vty_out (vty, " %sreceived",
7349 CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : "");
7350 vty_out (vty, "%s", VTY_NEWLINE);
7351 }
paul718e3742002-12-13 20:15:29 +00007352 /* Dynamic */
7353 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
7354 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
7355 {
7356 vty_out (vty, " Dynamic:");
7357 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
7358 vty_out (vty, " advertised");
7359 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
hasso538621f2004-05-21 09:31:30 +00007360 vty_out (vty, " %sreceived",
7361 CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : "");
paul718e3742002-12-13 20:15:29 +00007362 vty_out (vty, "%s", VTY_NEWLINE);
7363 }
7364
7365 /* Route Refresh */
7366 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
7367 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
7368 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
7369 {
7370 vty_out (vty, " Route refresh:");
7371 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
7372 vty_out (vty, " advertised");
7373 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
7374 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
hasso538621f2004-05-21 09:31:30 +00007375 vty_out (vty, " %sreceived(%s)",
7376 CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "",
7377 (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)
7378 && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ?
7379 "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new");
7380
paul718e3742002-12-13 20:15:29 +00007381 vty_out (vty, "%s", VTY_NEWLINE);
7382 }
7383
hasso538621f2004-05-21 09:31:30 +00007384 /* Multiprotocol Extensions */
7385 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7386 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7387 if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
paul718e3742002-12-13 20:15:29 +00007388 {
hasso538621f2004-05-21 09:31:30 +00007389 vty_out (vty, " Address family %s:", afi_safi_print (afi, safi));
7390 if (p->afc_adv[afi][safi])
7391 vty_out (vty, " advertised");
7392 if (p->afc_recv[afi][safi])
7393 vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : "");
7394 vty_out (vty, "%s", VTY_NEWLINE);
7395 }
7396
7397 /* Gracefull Restart */
7398 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
7399 || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
paul718e3742002-12-13 20:15:29 +00007400 {
hasso538621f2004-05-21 09:31:30 +00007401 vty_out (vty, " Graceful Restart Capabilty:");
7402 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
paul718e3742002-12-13 20:15:29 +00007403 vty_out (vty, " advertised");
hasso538621f2004-05-21 09:31:30 +00007404 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
7405 vty_out (vty, " %sreceived",
7406 CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : "");
paul718e3742002-12-13 20:15:29 +00007407 vty_out (vty, "%s", VTY_NEWLINE);
hasso538621f2004-05-21 09:31:30 +00007408
7409 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
paul718e3742002-12-13 20:15:29 +00007410 {
hasso538621f2004-05-21 09:31:30 +00007411 int restart_af_count = 0;
7412
7413 vty_out (vty, " Remote Restart timer is %d seconds%s",
hasso93406d82005-02-02 14:40:33 +00007414 p->v_gr_restart, VTY_NEWLINE);
7415 vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE);
hasso538621f2004-05-21 09:31:30 +00007416
7417 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7418 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7419 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
7420 {
hasso93406d82005-02-02 14:40:33 +00007421 vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "",
7422 afi_safi_print (afi, safi),
7423 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ?
7424 "preserved" : "not preserved");
hasso538621f2004-05-21 09:31:30 +00007425 restart_af_count++;
hasso93406d82005-02-02 14:40:33 +00007426 }
hasso538621f2004-05-21 09:31:30 +00007427 if (! restart_af_count)
7428 vty_out (vty, "none");
7429 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007430 }
paul718e3742002-12-13 20:15:29 +00007431 }
paul718e3742002-12-13 20:15:29 +00007432 }
7433 }
7434
hasso93406d82005-02-02 14:40:33 +00007435 /* graceful restart information */
7436 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
7437 || p->t_gr_restart
7438 || p->t_gr_stale)
7439 {
7440 int eor_send_af_count = 0;
7441 int eor_receive_af_count = 0;
7442
7443 vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE);
7444 if (p->status == Established)
7445 {
7446 vty_out (vty, " End-of-RIB send: ");
7447 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7448 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7449 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND))
7450 {
7451 vty_out (vty, "%s%s", eor_send_af_count ? ", " : "",
7452 afi_safi_print (afi, safi));
7453 eor_send_af_count++;
7454 }
7455 vty_out (vty, "%s", VTY_NEWLINE);
7456
7457 vty_out (vty, " End-of-RIB received: ");
7458 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7459 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7460 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED))
7461 {
7462 vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "",
7463 afi_safi_print (afi, safi));
7464 eor_receive_af_count++;
7465 }
7466 vty_out (vty, "%s", VTY_NEWLINE);
7467 }
7468
7469 if (p->t_gr_restart)
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00007470 vty_out (vty, " The remaining time of restart timer is %ld%s",
7471 thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE);
7472
hasso93406d82005-02-02 14:40:33 +00007473 if (p->t_gr_stale)
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00007474 vty_out (vty, " The remaining time of stalepath timer is %ld%s",
7475 thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE);
hasso93406d82005-02-02 14:40:33 +00007476 }
7477
paul718e3742002-12-13 20:15:29 +00007478 /* Packet counts. */
hasso93406d82005-02-02 14:40:33 +00007479 vty_out (vty, " Message statistics:%s", VTY_NEWLINE);
7480 vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00007481 vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE);
hasso93406d82005-02-02 14:40:33 +00007482 vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE);
7483 vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE);
7484 vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE);
7485 vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE);
7486 vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE);
7487 vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE);
7488 vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE);
7489 vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out +
7490 p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out,
7491 p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in +
7492 p->dynamic_cap_in, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007493
7494 /* advertisement-interval */
7495 vty_out (vty, " Minimum time between advertisement runs is %d seconds%s",
7496 p->v_routeadv, VTY_NEWLINE);
7497
7498 /* Update-source. */
7499 if (p->update_if || p->update_source)
7500 {
7501 vty_out (vty, " Update source is ");
7502 if (p->update_if)
7503 vty_out (vty, "%s", p->update_if);
7504 else if (p->update_source)
7505 vty_out (vty, "%s",
7506 sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
7507 vty_out (vty, "%s", VTY_NEWLINE);
7508 }
7509
7510 /* Default weight */
7511 if (CHECK_FLAG (p->config, PEER_CONFIG_WEIGHT))
7512 vty_out (vty, " Default weight %d%s", p->weight,
7513 VTY_NEWLINE);
7514
7515 vty_out (vty, "%s", VTY_NEWLINE);
7516
7517 /* Address Family Information */
hasso538621f2004-05-21 09:31:30 +00007518 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7519 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7520 if (p->afc[afi][safi])
7521 bgp_show_peer_afi (vty, p, afi, safi);
paul718e3742002-12-13 20:15:29 +00007522
7523 vty_out (vty, " Connections established %d; dropped %d%s",
7524 p->established, p->dropped,
7525 VTY_NEWLINE);
7526
hassoe0701b72004-05-20 09:19:34 +00007527 if (! p->dropped)
7528 vty_out (vty, " Last reset never%s", VTY_NEWLINE);
7529 else
7530 vty_out (vty, " Last reset %s, due to %s%s",
7531 peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN),
7532 peer_down_str[(int) p->last_reset], VTY_NEWLINE);
paul848973c2003-08-13 00:32:49 +00007533
paul718e3742002-12-13 20:15:29 +00007534 if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW))
7535 {
7536 vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE);
hasso0a486e52005-02-01 20:57:17 +00007537
7538 if (p->t_pmax_restart)
7539 vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s",
7540 p->host, thread_timer_remain_second (p->t_pmax_restart),
7541 VTY_NEWLINE);
7542 else
7543 vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s",
7544 p->host, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007545 }
7546
7547 /* EBGP Multihop */
7548 if (peer_sort (p) != BGP_PEER_IBGP && p->ttl > 1)
7549 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
7550 p->ttl, VTY_NEWLINE);
7551
7552 /* Local address. */
7553 if (p->su_local)
7554 {
hasso93406d82005-02-02 14:40:33 +00007555 vty_out (vty, "Local host: %s, Local port: %d%s",
paul718e3742002-12-13 20:15:29 +00007556 sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN),
7557 ntohs (p->su_local->sin.sin_port),
paul718e3742002-12-13 20:15:29 +00007558 VTY_NEWLINE);
7559 }
7560
7561 /* Remote address. */
7562 if (p->su_remote)
7563 {
7564 vty_out (vty, "Foreign host: %s, Foreign port: %d%s",
7565 sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN),
7566 ntohs (p->su_remote->sin.sin_port),
7567 VTY_NEWLINE);
7568 }
7569
7570 /* Nexthop display. */
7571 if (p->su_local)
7572 {
7573 vty_out (vty, "Nexthop: %s%s",
7574 inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ),
7575 VTY_NEWLINE);
7576#ifdef HAVE_IPV6
7577 vty_out (vty, "Nexthop global: %s%s",
7578 inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ),
7579 VTY_NEWLINE);
7580 vty_out (vty, "Nexthop local: %s%s",
7581 inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ),
7582 VTY_NEWLINE);
7583 vty_out (vty, "BGP connection: %s%s",
7584 p->shared_network ? "shared network" : "non shared network",
7585 VTY_NEWLINE);
7586#endif /* HAVE_IPV6 */
7587 }
7588
7589 /* Timer information. */
7590 if (p->t_start)
7591 vty_out (vty, "Next start timer due in %ld seconds%s",
7592 thread_timer_remain_second (p->t_start), VTY_NEWLINE);
7593 if (p->t_connect)
7594 vty_out (vty, "Next connect timer due in %ld seconds%s",
7595 thread_timer_remain_second (p->t_connect), VTY_NEWLINE);
7596
7597 vty_out (vty, "Read thread: %s Write thread: %s%s",
7598 p->t_read ? "on" : "off",
7599 p->t_write ? "on" : "off",
7600 VTY_NEWLINE);
7601
7602 if (p->notify.code == BGP_NOTIFY_OPEN_ERR
7603 && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL)
7604 bgp_capability_vty_out (vty, p);
7605
7606 vty_out (vty, "%s", VTY_NEWLINE);
7607}
7608
paul94f2b392005-06-28 12:44:16 +00007609static int
paul718e3742002-12-13 20:15:29 +00007610bgp_show_neighbor (struct vty *vty, struct bgp *bgp,
7611 enum show_type type, union sockunion *su)
7612{
paul1eb8ef22005-04-07 07:30:20 +00007613 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00007614 struct peer *peer;
7615 int find = 0;
7616
paul1eb8ef22005-04-07 07:30:20 +00007617 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00007618 {
7619 switch (type)
7620 {
7621 case show_all:
7622 bgp_show_peer (vty, peer);
7623 break;
7624 case show_peer:
7625 if (sockunion_same (&peer->su, su))
7626 {
7627 find = 1;
7628 bgp_show_peer (vty, peer);
7629 }
7630 break;
7631 }
7632 }
7633
7634 if (type == show_peer && ! find)
7635 vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE);
7636
7637 return CMD_SUCCESS;
7638}
7639
paul94f2b392005-06-28 12:44:16 +00007640static int
paulfd79ac92004-10-13 05:06:08 +00007641bgp_show_neighbor_vty (struct vty *vty, const char *name,
7642 enum show_type type, const char *ip_str)
paul718e3742002-12-13 20:15:29 +00007643{
7644 int ret;
7645 struct bgp *bgp;
7646 union sockunion su;
7647
7648 if (ip_str)
7649 {
7650 ret = str2sockunion (ip_str, &su);
7651 if (ret < 0)
7652 {
7653 vty_out (vty, "%% Malformed address: %s%s", ip_str, VTY_NEWLINE);
7654 return CMD_WARNING;
7655 }
7656 }
7657
7658 if (name)
7659 {
7660 bgp = bgp_lookup_by_name (name);
7661
7662 if (! bgp)
7663 {
7664 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
7665 return CMD_WARNING;
7666 }
7667
7668 bgp_show_neighbor (vty, bgp, type, &su);
7669
7670 return CMD_SUCCESS;
7671 }
7672
7673 bgp = bgp_get_default ();
7674
7675 if (bgp)
7676 bgp_show_neighbor (vty, bgp, type, &su);
7677
7678 return CMD_SUCCESS;
7679}
7680
7681/* "show ip bgp neighbors" commands. */
7682DEFUN (show_ip_bgp_neighbors,
7683 show_ip_bgp_neighbors_cmd,
7684 "show ip bgp neighbors",
7685 SHOW_STR
7686 IP_STR
7687 BGP_STR
7688 "Detailed information on TCP and BGP neighbor connections\n")
7689{
7690 return bgp_show_neighbor_vty (vty, NULL, show_all, NULL);
7691}
7692
7693ALIAS (show_ip_bgp_neighbors,
7694 show_ip_bgp_ipv4_neighbors_cmd,
7695 "show ip bgp ipv4 (unicast|multicast) neighbors",
7696 SHOW_STR
7697 IP_STR
7698 BGP_STR
7699 "Address family\n"
7700 "Address Family modifier\n"
7701 "Address Family modifier\n"
7702 "Detailed information on TCP and BGP neighbor connections\n")
7703
7704ALIAS (show_ip_bgp_neighbors,
7705 show_ip_bgp_vpnv4_all_neighbors_cmd,
7706 "show ip bgp vpnv4 all neighbors",
7707 SHOW_STR
7708 IP_STR
7709 BGP_STR
7710 "Display VPNv4 NLRI specific information\n"
7711 "Display information about all VPNv4 NLRIs\n"
7712 "Detailed information on TCP and BGP neighbor connections\n")
7713
7714ALIAS (show_ip_bgp_neighbors,
7715 show_ip_bgp_vpnv4_rd_neighbors_cmd,
7716 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors",
7717 SHOW_STR
7718 IP_STR
7719 BGP_STR
7720 "Display VPNv4 NLRI specific information\n"
7721 "Display information for a route distinguisher\n"
7722 "VPN Route Distinguisher\n"
7723 "Detailed information on TCP and BGP neighbor connections\n")
7724
7725ALIAS (show_ip_bgp_neighbors,
7726 show_bgp_neighbors_cmd,
7727 "show bgp neighbors",
7728 SHOW_STR
7729 BGP_STR
7730 "Detailed information on TCP and BGP neighbor connections\n")
7731
7732ALIAS (show_ip_bgp_neighbors,
7733 show_bgp_ipv6_neighbors_cmd,
7734 "show bgp ipv6 neighbors",
7735 SHOW_STR
7736 BGP_STR
7737 "Address family\n"
7738 "Detailed information on TCP and BGP neighbor connections\n")
7739
7740DEFUN (show_ip_bgp_neighbors_peer,
7741 show_ip_bgp_neighbors_peer_cmd,
7742 "show ip bgp neighbors (A.B.C.D|X:X::X:X)",
7743 SHOW_STR
7744 IP_STR
7745 BGP_STR
7746 "Detailed information on TCP and BGP neighbor connections\n"
7747 "Neighbor to display information about\n"
7748 "Neighbor to display information about\n")
7749{
7750 return bgp_show_neighbor_vty (vty, NULL, show_peer, argv[argc - 1]);
7751}
7752
7753ALIAS (show_ip_bgp_neighbors_peer,
7754 show_ip_bgp_ipv4_neighbors_peer_cmd,
7755 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X)",
7756 SHOW_STR
7757 IP_STR
7758 BGP_STR
7759 "Address family\n"
7760 "Address Family modifier\n"
7761 "Address Family modifier\n"
7762 "Detailed information on TCP and BGP neighbor connections\n"
7763 "Neighbor to display information about\n"
7764 "Neighbor to display information about\n")
7765
7766ALIAS (show_ip_bgp_neighbors_peer,
7767 show_ip_bgp_vpnv4_all_neighbors_peer_cmd,
7768 "show ip bgp vpnv4 all neighbors A.B.C.D",
7769 SHOW_STR
7770 IP_STR
7771 BGP_STR
7772 "Display VPNv4 NLRI specific information\n"
7773 "Display information about all VPNv4 NLRIs\n"
7774 "Detailed information on TCP and BGP neighbor connections\n"
7775 "Neighbor to display information about\n")
7776
7777ALIAS (show_ip_bgp_neighbors_peer,
7778 show_ip_bgp_vpnv4_rd_neighbors_peer_cmd,
7779 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D",
7780 SHOW_STR
7781 IP_STR
7782 BGP_STR
7783 "Display VPNv4 NLRI specific information\n"
7784 "Display information about all VPNv4 NLRIs\n"
7785 "Detailed information on TCP and BGP neighbor connections\n"
7786 "Neighbor to display information about\n")
7787
7788ALIAS (show_ip_bgp_neighbors_peer,
7789 show_bgp_neighbors_peer_cmd,
7790 "show bgp neighbors (A.B.C.D|X:X::X:X)",
7791 SHOW_STR
7792 BGP_STR
7793 "Detailed information on TCP and BGP neighbor connections\n"
7794 "Neighbor to display information about\n"
7795 "Neighbor to display information about\n")
7796
7797ALIAS (show_ip_bgp_neighbors_peer,
7798 show_bgp_ipv6_neighbors_peer_cmd,
7799 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X)",
7800 SHOW_STR
7801 BGP_STR
7802 "Address family\n"
7803 "Detailed information on TCP and BGP neighbor connections\n"
7804 "Neighbor to display information about\n"
7805 "Neighbor to display information about\n")
7806
7807DEFUN (show_ip_bgp_instance_neighbors,
7808 show_ip_bgp_instance_neighbors_cmd,
7809 "show ip bgp view WORD neighbors",
7810 SHOW_STR
7811 IP_STR
7812 BGP_STR
7813 "BGP view\n"
7814 "View name\n"
7815 "Detailed information on TCP and BGP neighbor connections\n")
7816{
7817 return bgp_show_neighbor_vty (vty, argv[0], show_all, NULL);
7818}
7819
paulbb46e942003-10-24 19:02:03 +00007820ALIAS (show_ip_bgp_instance_neighbors,
7821 show_bgp_instance_neighbors_cmd,
7822 "show bgp view WORD neighbors",
7823 SHOW_STR
7824 BGP_STR
7825 "BGP view\n"
7826 "View name\n"
7827 "Detailed information on TCP and BGP neighbor connections\n")
7828
7829ALIAS (show_ip_bgp_instance_neighbors,
7830 show_bgp_instance_ipv6_neighbors_cmd,
7831 "show bgp view WORD ipv6 neighbors",
7832 SHOW_STR
7833 BGP_STR
7834 "BGP view\n"
7835 "View name\n"
7836 "Address family\n"
7837 "Detailed information on TCP and BGP neighbor connections\n")
7838
paul718e3742002-12-13 20:15:29 +00007839DEFUN (show_ip_bgp_instance_neighbors_peer,
7840 show_ip_bgp_instance_neighbors_peer_cmd,
7841 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X)",
7842 SHOW_STR
7843 IP_STR
7844 BGP_STR
7845 "BGP view\n"
7846 "View name\n"
7847 "Detailed information on TCP and BGP neighbor connections\n"
7848 "Neighbor to display information about\n"
7849 "Neighbor to display information about\n")
7850{
7851 return bgp_show_neighbor_vty (vty, argv[0], show_peer, argv[1]);
7852}
paulbb46e942003-10-24 19:02:03 +00007853
7854ALIAS (show_ip_bgp_instance_neighbors_peer,
7855 show_bgp_instance_neighbors_peer_cmd,
7856 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X)",
7857 SHOW_STR
7858 BGP_STR
7859 "BGP view\n"
7860 "View name\n"
7861 "Detailed information on TCP and BGP neighbor connections\n"
7862 "Neighbor to display information about\n"
7863 "Neighbor to display information about\n")
7864
7865ALIAS (show_ip_bgp_instance_neighbors_peer,
7866 show_bgp_instance_ipv6_neighbors_peer_cmd,
7867 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X)",
7868 SHOW_STR
7869 BGP_STR
7870 "BGP view\n"
7871 "View name\n"
7872 "Address family\n"
7873 "Detailed information on TCP and BGP neighbor connections\n"
7874 "Neighbor to display information about\n"
7875 "Neighbor to display information about\n")
7876
paul718e3742002-12-13 20:15:29 +00007877/* Show BGP's AS paths internal data. There are both `show ip bgp
7878 paths' and `show ip mbgp paths'. Those functions results are the
7879 same.*/
7880DEFUN (show_ip_bgp_paths,
7881 show_ip_bgp_paths_cmd,
7882 "show ip bgp paths",
7883 SHOW_STR
7884 IP_STR
7885 BGP_STR
7886 "Path information\n")
7887{
7888 vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE);
7889 aspath_print_all_vty (vty);
7890 return CMD_SUCCESS;
7891}
7892
7893DEFUN (show_ip_bgp_ipv4_paths,
7894 show_ip_bgp_ipv4_paths_cmd,
7895 "show ip bgp ipv4 (unicast|multicast) paths",
7896 SHOW_STR
7897 IP_STR
7898 BGP_STR
7899 "Address family\n"
7900 "Address Family modifier\n"
7901 "Address Family modifier\n"
7902 "Path information\n")
7903{
7904 vty_out (vty, "Address Refcnt Path\r\n");
7905 aspath_print_all_vty (vty);
7906
7907 return CMD_SUCCESS;
7908}
7909
7910#include "hash.h"
7911
paul94f2b392005-06-28 12:44:16 +00007912static void
paul718e3742002-12-13 20:15:29 +00007913community_show_all_iterator (struct hash_backet *backet, struct vty *vty)
7914{
7915 struct community *com;
7916
7917 com = (struct community *) backet->data;
7918 vty_out (vty, "[%p] (%ld) %s%s", backet, com->refcnt,
7919 community_str (com), VTY_NEWLINE);
7920}
7921
7922/* Show BGP's community internal data. */
7923DEFUN (show_ip_bgp_community_info,
7924 show_ip_bgp_community_info_cmd,
7925 "show ip bgp community-info",
7926 SHOW_STR
7927 IP_STR
7928 BGP_STR
7929 "List all bgp community information\n")
7930{
7931 vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE);
7932
7933 hash_iterate (community_hash (),
7934 (void (*) (struct hash_backet *, void *))
7935 community_show_all_iterator,
7936 vty);
7937
7938 return CMD_SUCCESS;
7939}
7940
7941DEFUN (show_ip_bgp_attr_info,
7942 show_ip_bgp_attr_info_cmd,
7943 "show ip bgp attribute-info",
7944 SHOW_STR
7945 IP_STR
7946 BGP_STR
7947 "List all bgp attribute information\n")
7948{
7949 attr_show_all (vty);
7950 return CMD_SUCCESS;
7951}
7952
paul94f2b392005-06-28 12:44:16 +00007953static int
paulfee0f4c2004-09-13 05:12:46 +00007954bgp_write_rsclient_summary (struct vty *vty, struct peer *rsclient,
7955 afi_t afi, safi_t safi)
7956{
7957 char timebuf[BGP_UPTIME_LEN];
7958 char rmbuf[14];
paulfd79ac92004-10-13 05:06:08 +00007959 const char *rmname;
paulfee0f4c2004-09-13 05:12:46 +00007960 struct peer *peer;
paul1eb8ef22005-04-07 07:30:20 +00007961 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00007962 int len;
7963 int count = 0;
7964
7965 if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP))
7966 {
paul1eb8ef22005-04-07 07:30:20 +00007967 for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, peer))
paulfee0f4c2004-09-13 05:12:46 +00007968 {
7969 count++;
7970 bgp_write_rsclient_summary (vty, peer, afi, safi);
7971 }
7972 return count;
7973 }
7974
7975 len = vty_out (vty, "%s", rsclient->host);
7976 len = 16 - len;
7977
7978 if (len < 1)
7979 vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
7980 else
7981 vty_out (vty, "%*s", len, " ");
7982
hasso3d515fd2005-02-01 21:30:04 +00007983 vty_out (vty, "4 ");
paulfee0f4c2004-09-13 05:12:46 +00007984
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00007985 vty_out (vty, "%11d ", rsclient->as);
paulfee0f4c2004-09-13 05:12:46 +00007986
7987 rmname = ROUTE_MAP_EXPORT_NAME(&rsclient->filter[afi][safi]);
7988 if ( rmname && strlen (rmname) > 13 )
7989 {
7990 sprintf (rmbuf, "%13s", "...");
7991 rmname = strncpy (rmbuf, rmname, 10);
7992 }
7993 else if (! rmname)
7994 rmname = "<none>";
7995 vty_out (vty, " %13s ", rmname);
7996
7997 rmname = ROUTE_MAP_IMPORT_NAME(&rsclient->filter[afi][safi]);
7998 if ( rmname && strlen (rmname) > 13 )
7999 {
8000 sprintf (rmbuf, "%13s", "...");
8001 rmname = strncpy (rmbuf, rmname, 10);
8002 }
8003 else if (! rmname)
8004 rmname = "<none>";
8005 vty_out (vty, " %13s ", rmname);
8006
8007 vty_out (vty, "%8s", peer_uptime (rsclient->uptime, timebuf, BGP_UPTIME_LEN));
8008
8009 if (CHECK_FLAG (rsclient->flags, PEER_FLAG_SHUTDOWN))
8010 vty_out (vty, " Idle (Admin)");
8011 else if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_PREFIX_OVERFLOW))
8012 vty_out (vty, " Idle (PfxCt)");
8013 else
8014 vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, rsclient->status));
8015
8016 vty_out (vty, "%s", VTY_NEWLINE);
8017
8018 return 1;
8019}
8020
paul94f2b392005-06-28 12:44:16 +00008021static int
paulfd79ac92004-10-13 05:06:08 +00008022bgp_show_rsclient_summary (struct vty *vty, struct bgp *bgp,
8023 afi_t afi, safi_t safi)
paulfee0f4c2004-09-13 05:12:46 +00008024{
8025 struct peer *peer;
paul1eb8ef22005-04-07 07:30:20 +00008026 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00008027 int count = 0;
8028
8029 /* Header string for each address family. */
8030 static char header[] = "Neighbor V AS Export-Policy Import-Policy Up/Down State";
8031
paul1eb8ef22005-04-07 07:30:20 +00008032 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, peer))
paulfee0f4c2004-09-13 05:12:46 +00008033 {
8034 if (peer->afc[afi][safi] &&
8035 CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
8036 {
8037 if (! count)
8038 {
8039 vty_out (vty,
8040 "Route Server's BGP router identifier %s%s",
8041 inet_ntoa (bgp->router_id), VTY_NEWLINE);
8042 vty_out (vty,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04008043 "Route Server's local AS number %u%s", bgp->as,
paulfee0f4c2004-09-13 05:12:46 +00008044 VTY_NEWLINE);
8045
8046 vty_out (vty, "%s", VTY_NEWLINE);
8047 vty_out (vty, "%s%s", header, VTY_NEWLINE);
8048 }
8049
8050 count += bgp_write_rsclient_summary (vty, peer, afi, safi);
8051 }
8052 }
8053
8054 if (count)
8055 vty_out (vty, "%sTotal number of Route Server Clients %d%s", VTY_NEWLINE,
8056 count, VTY_NEWLINE);
8057 else
8058 vty_out (vty, "No %s Route Server Client is configured%s",
8059 afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
8060
8061 return CMD_SUCCESS;
8062}
8063
paul94f2b392005-06-28 12:44:16 +00008064static int
paulfd79ac92004-10-13 05:06:08 +00008065bgp_show_rsclient_summary_vty (struct vty *vty, const char *name,
8066 afi_t afi, safi_t safi)
paulfee0f4c2004-09-13 05:12:46 +00008067{
8068 struct bgp *bgp;
8069
8070 if (name)
8071 {
8072 bgp = bgp_lookup_by_name (name);
8073
8074 if (! bgp)
8075 {
8076 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
8077 return CMD_WARNING;
8078 }
8079
8080 bgp_show_rsclient_summary (vty, bgp, afi, safi);
8081 return CMD_SUCCESS;
8082 }
8083
8084 bgp = bgp_get_default ();
8085
8086 if (bgp)
8087 bgp_show_rsclient_summary (vty, bgp, afi, safi);
8088
8089 return CMD_SUCCESS;
8090}
8091
8092/* 'show bgp rsclient' commands. */
8093DEFUN (show_ip_bgp_rsclient_summary,
8094 show_ip_bgp_rsclient_summary_cmd,
8095 "show ip bgp rsclient summary",
8096 SHOW_STR
8097 IP_STR
8098 BGP_STR
8099 "Information about Route Server Clients\n"
8100 "Summary of all Route Server Clients\n")
8101{
8102 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
8103}
8104
8105DEFUN (show_ip_bgp_instance_rsclient_summary,
8106 show_ip_bgp_instance_rsclient_summary_cmd,
8107 "show ip bgp view WORD rsclient summary",
8108 SHOW_STR
8109 IP_STR
8110 BGP_STR
8111 "BGP view\n"
8112 "View name\n"
8113 "Information about Route Server Clients\n"
8114 "Summary of all Route Server Clients\n")
8115{
8116 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
8117}
8118
8119DEFUN (show_ip_bgp_ipv4_rsclient_summary,
8120 show_ip_bgp_ipv4_rsclient_summary_cmd,
8121 "show ip bgp ipv4 (unicast|multicast) rsclient summary",
8122 SHOW_STR
8123 IP_STR
8124 BGP_STR
8125 "Address family\n"
8126 "Address Family modifier\n"
8127 "Address Family modifier\n"
8128 "Information about Route Server Clients\n"
8129 "Summary of all Route Server Clients\n")
8130{
8131 if (strncmp (argv[0], "m", 1) == 0)
8132 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST);
8133
8134 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
8135}
8136
8137DEFUN (show_ip_bgp_instance_ipv4_rsclient_summary,
8138 show_ip_bgp_instance_ipv4_rsclient_summary_cmd,
8139 "show ip bgp view WORD ipv4 (unicast|multicast) rsclient summary",
8140 SHOW_STR
8141 IP_STR
8142 BGP_STR
8143 "BGP view\n"
8144 "View name\n"
8145 "Address family\n"
8146 "Address Family modifier\n"
8147 "Address Family modifier\n"
8148 "Information about Route Server Clients\n"
8149 "Summary of all Route Server Clients\n")
8150{
8151 if (strncmp (argv[1], "m", 1) == 0)
8152 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST);
8153
8154 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
8155}
8156
8157#ifdef HAVE_IPV6
8158DEFUN (show_bgp_rsclient_summary,
8159 show_bgp_rsclient_summary_cmd,
8160 "show bgp rsclient summary",
8161 SHOW_STR
8162 BGP_STR
8163 "Information about Route Server Clients\n"
8164 "Summary of all Route Server Clients\n")
8165{
8166 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
8167}
8168
8169DEFUN (show_bgp_instance_rsclient_summary,
8170 show_bgp_instance_rsclient_summary_cmd,
8171 "show bgp view WORD rsclient summary",
8172 SHOW_STR
8173 BGP_STR
8174 "BGP view\n"
8175 "View name\n"
8176 "Information about Route Server Clients\n"
8177 "Summary of all Route Server Clients\n")
8178{
8179 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
8180}
8181
8182ALIAS (show_bgp_rsclient_summary,
8183 show_bgp_ipv6_rsclient_summary_cmd,
8184 "show bgp ipv6 rsclient summary",
8185 SHOW_STR
8186 BGP_STR
8187 "Address family\n"
8188 "Information about Route Server Clients\n"
8189 "Summary of all Route Server Clients\n")
8190
8191ALIAS (show_bgp_instance_rsclient_summary,
8192 show_bgp_instance_ipv6_rsclient_summary_cmd,
8193 "show bgp view WORD ipv6 rsclient summary",
8194 SHOW_STR
8195 BGP_STR
8196 "BGP view\n"
8197 "View name\n"
8198 "Address family\n"
8199 "Information about Route Server Clients\n"
8200 "Summary of all Route Server Clients\n")
8201#endif /* HAVE IPV6 */
8202
paul718e3742002-12-13 20:15:29 +00008203/* Redistribute VTY commands. */
8204
paul718e3742002-12-13 20:15:29 +00008205DEFUN (bgp_redistribute_ipv4,
8206 bgp_redistribute_ipv4_cmd,
David Lamparterdaca2cf2009-09-16 01:52:42 +02008207 "redistribute " QUAGGA_IP_REDIST_STR_BGPD,
paul718e3742002-12-13 20:15:29 +00008208 "Redistribute information from another routing protocol\n"
David Lamparterdaca2cf2009-09-16 01:52:42 +02008209 QUAGGA_IP_REDIST_HELP_STR_BGPD)
paul718e3742002-12-13 20:15:29 +00008210{
8211 int type;
8212
David Lamparterdaca2cf2009-09-16 01:52:42 +02008213 type = proto_redistnum (AFI_IP, argv[0]);
8214 if (type < 0 || type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00008215 {
8216 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8217 return CMD_WARNING;
8218 }
8219 return bgp_redistribute_set (vty->index, AFI_IP, type);
8220}
8221
8222DEFUN (bgp_redistribute_ipv4_rmap,
8223 bgp_redistribute_ipv4_rmap_cmd,
David Lamparterdaca2cf2009-09-16 01:52:42 +02008224 "redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD",
paul718e3742002-12-13 20:15:29 +00008225 "Redistribute information from another routing protocol\n"
David Lamparterdaca2cf2009-09-16 01:52:42 +02008226 QUAGGA_IP_REDIST_HELP_STR_BGPD
paul718e3742002-12-13 20:15:29 +00008227 "Route map reference\n"
8228 "Pointer to route-map entries\n")
8229{
8230 int type;
8231
David Lamparterdaca2cf2009-09-16 01:52:42 +02008232 type = proto_redistnum (AFI_IP, argv[0]);
8233 if (type < 0 || type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00008234 {
8235 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8236 return CMD_WARNING;
8237 }
8238
8239 bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[1]);
8240 return bgp_redistribute_set (vty->index, AFI_IP, type);
8241}
8242
8243DEFUN (bgp_redistribute_ipv4_metric,
8244 bgp_redistribute_ipv4_metric_cmd,
David Lamparterdaca2cf2009-09-16 01:52:42 +02008245 "redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295>",
paul718e3742002-12-13 20:15:29 +00008246 "Redistribute information from another routing protocol\n"
David Lamparterdaca2cf2009-09-16 01:52:42 +02008247 QUAGGA_IP_REDIST_HELP_STR_BGPD
paul718e3742002-12-13 20:15:29 +00008248 "Metric for redistributed routes\n"
8249 "Default metric\n")
8250{
8251 int type;
8252 u_int32_t metric;
8253
David Lamparterdaca2cf2009-09-16 01:52:42 +02008254 type = proto_redistnum (AFI_IP, argv[0]);
8255 if (type < 0 || type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00008256 {
8257 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8258 return CMD_WARNING;
8259 }
8260 VTY_GET_INTEGER ("metric", metric, argv[1]);
8261
8262 bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
8263 return bgp_redistribute_set (vty->index, AFI_IP, type);
8264}
8265
8266DEFUN (bgp_redistribute_ipv4_rmap_metric,
8267 bgp_redistribute_ipv4_rmap_metric_cmd,
David Lamparterdaca2cf2009-09-16 01:52:42 +02008268 "redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
paul718e3742002-12-13 20:15:29 +00008269 "Redistribute information from another routing protocol\n"
David Lamparterdaca2cf2009-09-16 01:52:42 +02008270 QUAGGA_IP_REDIST_HELP_STR_BGPD
paul718e3742002-12-13 20:15:29 +00008271 "Route map reference\n"
8272 "Pointer to route-map entries\n"
8273 "Metric for redistributed routes\n"
8274 "Default metric\n")
8275{
8276 int type;
8277 u_int32_t metric;
8278
David Lamparterdaca2cf2009-09-16 01:52:42 +02008279 type = proto_redistnum (AFI_IP, argv[0]);
8280 if (type < 0 || type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00008281 {
8282 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8283 return CMD_WARNING;
8284 }
8285 VTY_GET_INTEGER ("metric", metric, argv[2]);
8286
8287 bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[1]);
8288 bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
8289 return bgp_redistribute_set (vty->index, AFI_IP, type);
8290}
8291
8292DEFUN (bgp_redistribute_ipv4_metric_rmap,
8293 bgp_redistribute_ipv4_metric_rmap_cmd,
David Lamparterdaca2cf2009-09-16 01:52:42 +02008294 "redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
paul718e3742002-12-13 20:15:29 +00008295 "Redistribute information from another routing protocol\n"
David Lamparterdaca2cf2009-09-16 01:52:42 +02008296 QUAGGA_IP_REDIST_HELP_STR_BGPD
paul718e3742002-12-13 20:15:29 +00008297 "Metric for redistributed routes\n"
8298 "Default metric\n"
8299 "Route map reference\n"
8300 "Pointer to route-map entries\n")
8301{
8302 int type;
8303 u_int32_t metric;
8304
David Lamparterdaca2cf2009-09-16 01:52:42 +02008305 type = proto_redistnum (AFI_IP, argv[0]);
8306 if (type < 0 || type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00008307 {
8308 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8309 return CMD_WARNING;
8310 }
8311 VTY_GET_INTEGER ("metric", metric, argv[1]);
8312
8313 bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
8314 bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[2]);
8315 return bgp_redistribute_set (vty->index, AFI_IP, type);
8316}
8317
8318DEFUN (no_bgp_redistribute_ipv4,
8319 no_bgp_redistribute_ipv4_cmd,
David Lamparterdaca2cf2009-09-16 01:52:42 +02008320 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD,
paul718e3742002-12-13 20:15:29 +00008321 NO_STR
8322 "Redistribute information from another routing protocol\n"
David Lamparterdaca2cf2009-09-16 01:52:42 +02008323 QUAGGA_IP_REDIST_HELP_STR_BGPD)
paul718e3742002-12-13 20:15:29 +00008324{
8325 int type;
8326
David Lamparterdaca2cf2009-09-16 01:52:42 +02008327 type = proto_redistnum (AFI_IP, argv[0]);
8328 if (type < 0 || type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00008329 {
8330 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8331 return CMD_WARNING;
8332 }
8333
8334 return bgp_redistribute_unset (vty->index, AFI_IP, type);
8335}
8336
8337DEFUN (no_bgp_redistribute_ipv4_rmap,
8338 no_bgp_redistribute_ipv4_rmap_cmd,
David Lamparterdaca2cf2009-09-16 01:52:42 +02008339 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD",
paul718e3742002-12-13 20:15:29 +00008340 NO_STR
8341 "Redistribute information from another routing protocol\n"
David Lamparterdaca2cf2009-09-16 01:52:42 +02008342 QUAGGA_IP_REDIST_HELP_STR_BGPD
paul718e3742002-12-13 20:15:29 +00008343 "Route map reference\n"
8344 "Pointer to route-map entries\n")
8345{
8346 int type;
8347
David Lamparterdaca2cf2009-09-16 01:52:42 +02008348 type = proto_redistnum (AFI_IP, argv[0]);
8349 if (type < 0 || type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00008350 {
8351 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8352 return CMD_WARNING;
8353 }
8354
8355 bgp_redistribute_routemap_unset (vty->index, AFI_IP, type);
8356 return CMD_SUCCESS;
8357}
8358
8359DEFUN (no_bgp_redistribute_ipv4_metric,
8360 no_bgp_redistribute_ipv4_metric_cmd,
David Lamparterdaca2cf2009-09-16 01:52:42 +02008361 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295>",
paul718e3742002-12-13 20:15:29 +00008362 NO_STR
8363 "Redistribute information from another routing protocol\n"
David Lamparterdaca2cf2009-09-16 01:52:42 +02008364 QUAGGA_IP_REDIST_HELP_STR_BGPD
paul718e3742002-12-13 20:15:29 +00008365 "Metric for redistributed routes\n"
8366 "Default metric\n")
8367{
8368 int type;
8369
David Lamparterdaca2cf2009-09-16 01:52:42 +02008370 type = proto_redistnum (AFI_IP, argv[0]);
8371 if (type < 0 || type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00008372 {
8373 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8374 return CMD_WARNING;
8375 }
8376
8377 bgp_redistribute_metric_unset (vty->index, AFI_IP, type);
8378 return CMD_SUCCESS;
8379}
8380
8381DEFUN (no_bgp_redistribute_ipv4_rmap_metric,
8382 no_bgp_redistribute_ipv4_rmap_metric_cmd,
David Lamparterdaca2cf2009-09-16 01:52:42 +02008383 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
paul718e3742002-12-13 20:15:29 +00008384 NO_STR
8385 "Redistribute information from another routing protocol\n"
David Lamparterdaca2cf2009-09-16 01:52:42 +02008386 QUAGGA_IP_REDIST_HELP_STR_BGPD
paul718e3742002-12-13 20:15:29 +00008387 "Route map reference\n"
8388 "Pointer to route-map entries\n"
8389 "Metric for redistributed routes\n"
8390 "Default metric\n")
8391{
8392 int type;
8393
David Lamparterdaca2cf2009-09-16 01:52:42 +02008394 type = proto_redistnum (AFI_IP, argv[0]);
8395 if (type < 0 || type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00008396 {
8397 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8398 return CMD_WARNING;
8399 }
8400
8401 bgp_redistribute_metric_unset (vty->index, AFI_IP, type);
8402 bgp_redistribute_routemap_unset (vty->index, AFI_IP, type);
8403 return CMD_SUCCESS;
8404}
8405
8406ALIAS (no_bgp_redistribute_ipv4_rmap_metric,
8407 no_bgp_redistribute_ipv4_metric_rmap_cmd,
David Lamparterdaca2cf2009-09-16 01:52:42 +02008408 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
paul718e3742002-12-13 20:15:29 +00008409 NO_STR
8410 "Redistribute information from another routing protocol\n"
David Lamparterdaca2cf2009-09-16 01:52:42 +02008411 QUAGGA_IP_REDIST_HELP_STR_BGPD
paul718e3742002-12-13 20:15:29 +00008412 "Metric for redistributed routes\n"
8413 "Default metric\n"
8414 "Route map reference\n"
8415 "Pointer to route-map entries\n")
8416
8417#ifdef HAVE_IPV6
8418DEFUN (bgp_redistribute_ipv6,
8419 bgp_redistribute_ipv6_cmd,
David Lamparterdaca2cf2009-09-16 01:52:42 +02008420 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD,
paul718e3742002-12-13 20:15:29 +00008421 "Redistribute information from another routing protocol\n"
David Lamparterdaca2cf2009-09-16 01:52:42 +02008422 QUAGGA_IP6_REDIST_HELP_STR_BGPD)
paul718e3742002-12-13 20:15:29 +00008423{
8424 int type;
8425
David Lamparterdaca2cf2009-09-16 01:52:42 +02008426 type = proto_redistnum (AFI_IP6, argv[0]);
8427 if (type < 0 || type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00008428 {
8429 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8430 return CMD_WARNING;
8431 }
8432
8433 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8434}
8435
8436DEFUN (bgp_redistribute_ipv6_rmap,
8437 bgp_redistribute_ipv6_rmap_cmd,
David Lamparterdaca2cf2009-09-16 01:52:42 +02008438 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD",
paul718e3742002-12-13 20:15:29 +00008439 "Redistribute information from another routing protocol\n"
David Lamparterdaca2cf2009-09-16 01:52:42 +02008440 QUAGGA_IP6_REDIST_HELP_STR_BGPD
paul718e3742002-12-13 20:15:29 +00008441 "Route map reference\n"
8442 "Pointer to route-map entries\n")
8443{
8444 int type;
8445
David Lamparterdaca2cf2009-09-16 01:52:42 +02008446 type = proto_redistnum (AFI_IP6, argv[0]);
8447 if (type < 0 || type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00008448 {
8449 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8450 return CMD_WARNING;
8451 }
8452
8453 bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[1]);
8454 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8455}
8456
8457DEFUN (bgp_redistribute_ipv6_metric,
8458 bgp_redistribute_ipv6_metric_cmd,
David Lamparterdaca2cf2009-09-16 01:52:42 +02008459 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295>",
paul718e3742002-12-13 20:15:29 +00008460 "Redistribute information from another routing protocol\n"
David Lamparterdaca2cf2009-09-16 01:52:42 +02008461 QUAGGA_IP6_REDIST_HELP_STR_BGPD
paul718e3742002-12-13 20:15:29 +00008462 "Metric for redistributed routes\n"
8463 "Default metric\n")
8464{
8465 int type;
8466 u_int32_t metric;
8467
David Lamparterdaca2cf2009-09-16 01:52:42 +02008468 type = proto_redistnum (AFI_IP6, argv[0]);
8469 if (type < 0 || type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00008470 {
8471 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8472 return CMD_WARNING;
8473 }
8474 VTY_GET_INTEGER ("metric", metric, argv[1]);
8475
8476 bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
8477 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8478}
8479
8480DEFUN (bgp_redistribute_ipv6_rmap_metric,
8481 bgp_redistribute_ipv6_rmap_metric_cmd,
David Lamparterdaca2cf2009-09-16 01:52:42 +02008482 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
paul718e3742002-12-13 20:15:29 +00008483 "Redistribute information from another routing protocol\n"
David Lamparterdaca2cf2009-09-16 01:52:42 +02008484 QUAGGA_IP6_REDIST_HELP_STR_BGPD
paul718e3742002-12-13 20:15:29 +00008485 "Route map reference\n"
8486 "Pointer to route-map entries\n"
8487 "Metric for redistributed routes\n"
8488 "Default metric\n")
8489{
8490 int type;
8491 u_int32_t metric;
8492
David Lamparterdaca2cf2009-09-16 01:52:42 +02008493 type = proto_redistnum (AFI_IP6, argv[0]);
8494 if (type < 0 || type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00008495 {
8496 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8497 return CMD_WARNING;
8498 }
8499 VTY_GET_INTEGER ("metric", metric, argv[2]);
8500
8501 bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[1]);
8502 bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
8503 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8504}
8505
8506DEFUN (bgp_redistribute_ipv6_metric_rmap,
8507 bgp_redistribute_ipv6_metric_rmap_cmd,
David Lamparterdaca2cf2009-09-16 01:52:42 +02008508 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
paul718e3742002-12-13 20:15:29 +00008509 "Redistribute information from another routing protocol\n"
David Lamparterdaca2cf2009-09-16 01:52:42 +02008510 QUAGGA_IP6_REDIST_HELP_STR_BGPD
paul718e3742002-12-13 20:15:29 +00008511 "Metric for redistributed routes\n"
8512 "Default metric\n"
8513 "Route map reference\n"
8514 "Pointer to route-map entries\n")
8515{
8516 int type;
8517 u_int32_t metric;
8518
David Lamparterdaca2cf2009-09-16 01:52:42 +02008519 type = proto_redistnum (AFI_IP6, argv[0]);
8520 if (type < 0 || type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00008521 {
8522 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8523 return CMD_WARNING;
8524 }
8525 VTY_GET_INTEGER ("metric", metric, argv[1]);
8526
8527 bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
8528 bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[2]);
8529 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8530}
8531
8532DEFUN (no_bgp_redistribute_ipv6,
8533 no_bgp_redistribute_ipv6_cmd,
David Lamparterdaca2cf2009-09-16 01:52:42 +02008534 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD,
paul718e3742002-12-13 20:15:29 +00008535 NO_STR
8536 "Redistribute information from another routing protocol\n"
David Lamparterdaca2cf2009-09-16 01:52:42 +02008537 QUAGGA_IP6_REDIST_HELP_STR_BGPD)
paul718e3742002-12-13 20:15:29 +00008538{
8539 int type;
8540
David Lamparterdaca2cf2009-09-16 01:52:42 +02008541 type = proto_redistnum (AFI_IP6, argv[0]);
8542 if (type < 0 || type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00008543 {
8544 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8545 return CMD_WARNING;
8546 }
8547
8548 return bgp_redistribute_unset (vty->index, AFI_IP6, type);
8549}
8550
8551DEFUN (no_bgp_redistribute_ipv6_rmap,
8552 no_bgp_redistribute_ipv6_rmap_cmd,
David Lamparterdaca2cf2009-09-16 01:52:42 +02008553 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD",
paul718e3742002-12-13 20:15:29 +00008554 NO_STR
8555 "Redistribute information from another routing protocol\n"
David Lamparterdaca2cf2009-09-16 01:52:42 +02008556 QUAGGA_IP6_REDIST_HELP_STR_BGPD
paul718e3742002-12-13 20:15:29 +00008557 "Route map reference\n"
8558 "Pointer to route-map entries\n")
8559{
8560 int type;
8561
David Lamparterdaca2cf2009-09-16 01:52:42 +02008562 type = proto_redistnum (AFI_IP6, argv[0]);
8563 if (type < 0 || type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00008564 {
8565 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8566 return CMD_WARNING;
8567 }
8568
8569 bgp_redistribute_routemap_unset (vty->index, AFI_IP6, type);
8570 return CMD_SUCCESS;
8571}
8572
8573DEFUN (no_bgp_redistribute_ipv6_metric,
8574 no_bgp_redistribute_ipv6_metric_cmd,
David Lamparterdaca2cf2009-09-16 01:52:42 +02008575 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295>",
paul718e3742002-12-13 20:15:29 +00008576 NO_STR
8577 "Redistribute information from another routing protocol\n"
David Lamparterdaca2cf2009-09-16 01:52:42 +02008578 QUAGGA_IP6_REDIST_HELP_STR_BGPD
paul718e3742002-12-13 20:15:29 +00008579 "Metric for redistributed routes\n"
8580 "Default metric\n")
8581{
8582 int type;
8583
David Lamparterdaca2cf2009-09-16 01:52:42 +02008584 type = proto_redistnum (AFI_IP6, argv[0]);
8585 if (type < 0 || type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00008586 {
8587 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8588 return CMD_WARNING;
8589 }
8590
8591 bgp_redistribute_metric_unset (vty->index, AFI_IP6, type);
8592 return CMD_SUCCESS;
8593}
8594
8595DEFUN (no_bgp_redistribute_ipv6_rmap_metric,
8596 no_bgp_redistribute_ipv6_rmap_metric_cmd,
David Lamparterdaca2cf2009-09-16 01:52:42 +02008597 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
paul718e3742002-12-13 20:15:29 +00008598 NO_STR
8599 "Redistribute information from another routing protocol\n"
David Lamparterdaca2cf2009-09-16 01:52:42 +02008600 QUAGGA_IP6_REDIST_HELP_STR_BGPD
paul718e3742002-12-13 20:15:29 +00008601 "Route map reference\n"
8602 "Pointer to route-map entries\n"
8603 "Metric for redistributed routes\n"
8604 "Default metric\n")
8605{
8606 int type;
8607
David Lamparterdaca2cf2009-09-16 01:52:42 +02008608 type = proto_redistnum (AFI_IP6, argv[0]);
8609 if (type < 0 || type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00008610 {
8611 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8612 return CMD_WARNING;
8613 }
8614
8615 bgp_redistribute_metric_unset (vty->index, AFI_IP6, type);
8616 bgp_redistribute_routemap_unset (vty->index, AFI_IP6, type);
8617 return CMD_SUCCESS;
8618}
8619
8620ALIAS (no_bgp_redistribute_ipv6_rmap_metric,
8621 no_bgp_redistribute_ipv6_metric_rmap_cmd,
David Lamparterdaca2cf2009-09-16 01:52:42 +02008622 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
paul718e3742002-12-13 20:15:29 +00008623 NO_STR
8624 "Redistribute information from another routing protocol\n"
David Lamparterdaca2cf2009-09-16 01:52:42 +02008625 QUAGGA_IP6_REDIST_HELP_STR_BGPD
paul718e3742002-12-13 20:15:29 +00008626 "Metric for redistributed routes\n"
8627 "Default metric\n"
8628 "Route map reference\n"
8629 "Pointer to route-map entries\n")
8630#endif /* HAVE_IPV6 */
8631
8632int
8633bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi,
8634 safi_t safi, int *write)
8635{
8636 int i;
paul718e3742002-12-13 20:15:29 +00008637
8638 /* Unicast redistribution only. */
8639 if (safi != SAFI_UNICAST)
8640 return 0;
8641
8642 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
8643 {
8644 /* Redistribute BGP does not make sense. */
8645 if (bgp->redist[afi][i] && i != ZEBRA_ROUTE_BGP)
8646 {
8647 /* Display "address-family" when it is not yet diplayed. */
8648 bgp_config_write_family_header (vty, afi, safi, write);
8649
8650 /* "redistribute" configuration. */
ajsf52d13c2005-10-01 17:38:06 +00008651 vty_out (vty, " redistribute %s", zebra_route_string(i));
paul718e3742002-12-13 20:15:29 +00008652
8653 if (bgp->redist_metric_flag[afi][i])
8654 vty_out (vty, " metric %d", bgp->redist_metric[afi][i]);
8655
8656 if (bgp->rmap[afi][i].name)
8657 vty_out (vty, " route-map %s", bgp->rmap[afi][i].name);
8658
8659 vty_out (vty, "%s", VTY_NEWLINE);
8660 }
8661 }
8662 return *write;
8663}
8664
8665/* BGP node structure. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008666static struct cmd_node bgp_node =
paul718e3742002-12-13 20:15:29 +00008667{
8668 BGP_NODE,
8669 "%s(config-router)# ",
8670 1,
8671};
8672
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008673static struct cmd_node bgp_ipv4_unicast_node =
paul718e3742002-12-13 20:15:29 +00008674{
8675 BGP_IPV4_NODE,
8676 "%s(config-router-af)# ",
8677 1,
8678};
8679
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008680static struct cmd_node bgp_ipv4_multicast_node =
paul718e3742002-12-13 20:15:29 +00008681{
8682 BGP_IPV4M_NODE,
8683 "%s(config-router-af)# ",
8684 1,
8685};
8686
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008687static struct cmd_node bgp_ipv6_unicast_node =
paul718e3742002-12-13 20:15:29 +00008688{
8689 BGP_IPV6_NODE,
8690 "%s(config-router-af)# ",
8691 1,
8692};
8693
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008694static struct cmd_node bgp_ipv6_multicast_node =
paul25ffbdc2005-08-22 22:42:08 +00008695{
8696 BGP_IPV6M_NODE,
8697 "%s(config-router-af)# ",
8698 1,
8699};
8700
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008701static struct cmd_node bgp_vpnv4_node =
paul718e3742002-12-13 20:15:29 +00008702{
8703 BGP_VPNV4_NODE,
8704 "%s(config-router-af)# ",
8705 1
8706};
8707
paul1f8ae702005-09-09 23:49:49 +00008708static void community_list_vty (void);
8709
paul718e3742002-12-13 20:15:29 +00008710void
paul94f2b392005-06-28 12:44:16 +00008711bgp_vty_init (void)
paul718e3742002-12-13 20:15:29 +00008712{
paul718e3742002-12-13 20:15:29 +00008713 /* Install bgp top node. */
8714 install_node (&bgp_node, bgp_config_write);
8715 install_node (&bgp_ipv4_unicast_node, NULL);
8716 install_node (&bgp_ipv4_multicast_node, NULL);
8717 install_node (&bgp_ipv6_unicast_node, NULL);
paul25ffbdc2005-08-22 22:42:08 +00008718 install_node (&bgp_ipv6_multicast_node, NULL);
paul718e3742002-12-13 20:15:29 +00008719 install_node (&bgp_vpnv4_node, NULL);
8720
8721 /* Install default VTY commands to new nodes. */
8722 install_default (BGP_NODE);
8723 install_default (BGP_IPV4_NODE);
8724 install_default (BGP_IPV4M_NODE);
8725 install_default (BGP_IPV6_NODE);
paul25ffbdc2005-08-22 22:42:08 +00008726 install_default (BGP_IPV6M_NODE);
paul718e3742002-12-13 20:15:29 +00008727 install_default (BGP_VPNV4_NODE);
8728
8729 /* "bgp multiple-instance" commands. */
8730 install_element (CONFIG_NODE, &bgp_multiple_instance_cmd);
8731 install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd);
8732
8733 /* "bgp config-type" commands. */
8734 install_element (CONFIG_NODE, &bgp_config_type_cmd);
8735 install_element (CONFIG_NODE, &no_bgp_config_type_cmd);
8736
8737 /* Dummy commands (Currently not supported) */
8738 install_element (BGP_NODE, &no_synchronization_cmd);
8739 install_element (BGP_NODE, &no_auto_summary_cmd);
8740
8741 /* "router bgp" commands. */
8742 install_element (CONFIG_NODE, &router_bgp_cmd);
8743 install_element (CONFIG_NODE, &router_bgp_view_cmd);
8744
8745 /* "no router bgp" commands. */
8746 install_element (CONFIG_NODE, &no_router_bgp_cmd);
8747 install_element (CONFIG_NODE, &no_router_bgp_view_cmd);
8748
8749 /* "bgp router-id" commands. */
8750 install_element (BGP_NODE, &bgp_router_id_cmd);
8751 install_element (BGP_NODE, &no_bgp_router_id_cmd);
8752 install_element (BGP_NODE, &no_bgp_router_id_val_cmd);
8753
8754 /* "bgp cluster-id" commands. */
8755 install_element (BGP_NODE, &bgp_cluster_id_cmd);
8756 install_element (BGP_NODE, &bgp_cluster_id32_cmd);
8757 install_element (BGP_NODE, &no_bgp_cluster_id_cmd);
8758 install_element (BGP_NODE, &no_bgp_cluster_id_arg_cmd);
8759
8760 /* "bgp confederation" commands. */
8761 install_element (BGP_NODE, &bgp_confederation_identifier_cmd);
8762 install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd);
8763 install_element (BGP_NODE, &no_bgp_confederation_identifier_arg_cmd);
8764
8765 /* "bgp confederation peers" commands. */
8766 install_element (BGP_NODE, &bgp_confederation_peers_cmd);
8767 install_element (BGP_NODE, &no_bgp_confederation_peers_cmd);
8768
8769 /* "timers bgp" commands. */
8770 install_element (BGP_NODE, &bgp_timers_cmd);
8771 install_element (BGP_NODE, &no_bgp_timers_cmd);
8772 install_element (BGP_NODE, &no_bgp_timers_arg_cmd);
8773
8774 /* "bgp client-to-client reflection" commands */
8775 install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd);
8776 install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd);
8777
8778 /* "bgp always-compare-med" commands */
8779 install_element (BGP_NODE, &bgp_always_compare_med_cmd);
8780 install_element (BGP_NODE, &no_bgp_always_compare_med_cmd);
8781
8782 /* "bgp deterministic-med" commands */
8783 install_element (BGP_NODE, &bgp_deterministic_med_cmd);
8784 install_element (BGP_NODE, &no_bgp_deterministic_med_cmd);
hasso538621f2004-05-21 09:31:30 +00008785
hasso538621f2004-05-21 09:31:30 +00008786 /* "bgp graceful-restart" commands */
8787 install_element (BGP_NODE, &bgp_graceful_restart_cmd);
8788 install_element (BGP_NODE, &no_bgp_graceful_restart_cmd);
hasso93406d82005-02-02 14:40:33 +00008789 install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd);
8790 install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd);
8791 install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_val_cmd);
paul718e3742002-12-13 20:15:29 +00008792
8793 /* "bgp fast-external-failover" commands */
8794 install_element (BGP_NODE, &bgp_fast_external_failover_cmd);
8795 install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd);
8796
8797 /* "bgp enforce-first-as" commands */
8798 install_element (BGP_NODE, &bgp_enforce_first_as_cmd);
8799 install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd);
8800
8801 /* "bgp bestpath compare-routerid" commands */
8802 install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd);
8803 install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd);
8804
8805 /* "bgp bestpath as-path ignore" commands */
8806 install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd);
8807 install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd);
8808
hasso68118452005-04-08 15:40:36 +00008809 /* "bgp bestpath as-path confed" commands */
8810 install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd);
8811 install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd);
8812
paul848973c2003-08-13 00:32:49 +00008813 /* "bgp log-neighbor-changes" commands */
8814 install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd);
8815 install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd);
8816
paul718e3742002-12-13 20:15:29 +00008817 /* "bgp bestpath med" commands */
8818 install_element (BGP_NODE, &bgp_bestpath_med_cmd);
8819 install_element (BGP_NODE, &bgp_bestpath_med2_cmd);
8820 install_element (BGP_NODE, &bgp_bestpath_med3_cmd);
8821 install_element (BGP_NODE, &no_bgp_bestpath_med_cmd);
8822 install_element (BGP_NODE, &no_bgp_bestpath_med2_cmd);
8823 install_element (BGP_NODE, &no_bgp_bestpath_med3_cmd);
8824
8825 /* "no bgp default ipv4-unicast" commands. */
8826 install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd);
8827 install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd);
8828
8829 /* "bgp network import-check" commands. */
8830 install_element (BGP_NODE, &bgp_network_import_check_cmd);
8831 install_element (BGP_NODE, &no_bgp_network_import_check_cmd);
8832
8833 /* "bgp default local-preference" commands. */
8834 install_element (BGP_NODE, &bgp_default_local_preference_cmd);
8835 install_element (BGP_NODE, &no_bgp_default_local_preference_cmd);
8836 install_element (BGP_NODE, &no_bgp_default_local_preference_val_cmd);
8837
8838 /* "neighbor remote-as" commands. */
8839 install_element (BGP_NODE, &neighbor_remote_as_cmd);
8840 install_element (BGP_NODE, &no_neighbor_cmd);
8841 install_element (BGP_NODE, &no_neighbor_remote_as_cmd);
8842
8843 /* "neighbor peer-group" commands. */
8844 install_element (BGP_NODE, &neighbor_peer_group_cmd);
8845 install_element (BGP_NODE, &no_neighbor_peer_group_cmd);
8846 install_element (BGP_NODE, &no_neighbor_peer_group_remote_as_cmd);
8847
8848 /* "neighbor local-as" commands. */
8849 install_element (BGP_NODE, &neighbor_local_as_cmd);
8850 install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd);
8851 install_element (BGP_NODE, &no_neighbor_local_as_cmd);
8852 install_element (BGP_NODE, &no_neighbor_local_as_val_cmd);
8853 install_element (BGP_NODE, &no_neighbor_local_as_val2_cmd);
8854
Paul Jakma0df7c912008-07-21 21:02:49 +00008855 /* "neighbor password" commands. */
8856 install_element (BGP_NODE, &neighbor_password_cmd);
8857 install_element (BGP_NODE, &no_neighbor_password_cmd);
8858
paul718e3742002-12-13 20:15:29 +00008859 /* "neighbor activate" commands. */
8860 install_element (BGP_NODE, &neighbor_activate_cmd);
8861 install_element (BGP_IPV4_NODE, &neighbor_activate_cmd);
8862 install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd);
8863 install_element (BGP_IPV6_NODE, &neighbor_activate_cmd);
paul25ffbdc2005-08-22 22:42:08 +00008864 install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd);
paul718e3742002-12-13 20:15:29 +00008865 install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd);
8866
8867 /* "no neighbor activate" commands. */
8868 install_element (BGP_NODE, &no_neighbor_activate_cmd);
8869 install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd);
8870 install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd);
8871 install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd);
paul25ffbdc2005-08-22 22:42:08 +00008872 install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd);
paul718e3742002-12-13 20:15:29 +00008873 install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd);
8874
8875 /* "neighbor peer-group set" commands. */
8876 install_element (BGP_NODE, &neighbor_set_peer_group_cmd);
8877 install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_cmd);
8878 install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_cmd);
8879 install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd);
paul25ffbdc2005-08-22 22:42:08 +00008880 install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_cmd);
paula58545b2003-07-12 21:43:01 +00008881 install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_cmd);
8882
paul718e3742002-12-13 20:15:29 +00008883 /* "no neighbor peer-group unset" commands. */
8884 install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd);
8885 install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd);
8886 install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_cmd);
8887 install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd);
paul25ffbdc2005-08-22 22:42:08 +00008888 install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_cmd);
paula58545b2003-07-12 21:43:01 +00008889 install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_cmd);
8890
paul718e3742002-12-13 20:15:29 +00008891 /* "neighbor softreconfiguration inbound" commands.*/
8892 install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd);
8893 install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd);
8894 install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd);
8895 install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
8896 install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd);
8897 install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd);
8898 install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd);
8899 install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
paul25ffbdc2005-08-22 22:42:08 +00008900 install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd);
8901 install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd);
paula58545b2003-07-12 21:43:01 +00008902 install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd);
8903 install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
paul718e3742002-12-13 20:15:29 +00008904
8905 /* "neighbor attribute-unchanged" commands. */
8906 install_element (BGP_NODE, &neighbor_attr_unchanged_cmd);
8907 install_element (BGP_NODE, &neighbor_attr_unchanged1_cmd);
8908 install_element (BGP_NODE, &neighbor_attr_unchanged2_cmd);
8909 install_element (BGP_NODE, &neighbor_attr_unchanged3_cmd);
8910 install_element (BGP_NODE, &neighbor_attr_unchanged4_cmd);
8911 install_element (BGP_NODE, &neighbor_attr_unchanged5_cmd);
8912 install_element (BGP_NODE, &neighbor_attr_unchanged6_cmd);
8913 install_element (BGP_NODE, &neighbor_attr_unchanged7_cmd);
8914 install_element (BGP_NODE, &neighbor_attr_unchanged8_cmd);
8915 install_element (BGP_NODE, &neighbor_attr_unchanged9_cmd);
8916 install_element (BGP_NODE, &neighbor_attr_unchanged10_cmd);
8917 install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd);
8918 install_element (BGP_NODE, &no_neighbor_attr_unchanged1_cmd);
8919 install_element (BGP_NODE, &no_neighbor_attr_unchanged2_cmd);
8920 install_element (BGP_NODE, &no_neighbor_attr_unchanged3_cmd);
8921 install_element (BGP_NODE, &no_neighbor_attr_unchanged4_cmd);
8922 install_element (BGP_NODE, &no_neighbor_attr_unchanged5_cmd);
8923 install_element (BGP_NODE, &no_neighbor_attr_unchanged6_cmd);
8924 install_element (BGP_NODE, &no_neighbor_attr_unchanged7_cmd);
8925 install_element (BGP_NODE, &no_neighbor_attr_unchanged8_cmd);
8926 install_element (BGP_NODE, &no_neighbor_attr_unchanged9_cmd);
8927 install_element (BGP_NODE, &no_neighbor_attr_unchanged10_cmd);
8928 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd);
8929 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged1_cmd);
8930 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged2_cmd);
8931 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged3_cmd);
8932 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged4_cmd);
8933 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged5_cmd);
8934 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged6_cmd);
8935 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged7_cmd);
8936 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged8_cmd);
8937 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged9_cmd);
8938 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged10_cmd);
8939 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd);
8940 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged1_cmd);
8941 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged2_cmd);
8942 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged3_cmd);
8943 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged4_cmd);
8944 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged5_cmd);
8945 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged6_cmd);
8946 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged7_cmd);
8947 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged8_cmd);
8948 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged9_cmd);
8949 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged10_cmd);
8950 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd);
8951 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged1_cmd);
8952 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged2_cmd);
8953 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged3_cmd);
8954 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged4_cmd);
8955 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged5_cmd);
8956 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged6_cmd);
8957 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged7_cmd);
8958 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged8_cmd);
8959 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged9_cmd);
8960 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged10_cmd);
8961 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd);
8962 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged1_cmd);
8963 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged2_cmd);
8964 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged3_cmd);
8965 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged4_cmd);
8966 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged5_cmd);
8967 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged6_cmd);
8968 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged7_cmd);
8969 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged8_cmd);
8970 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged9_cmd);
8971 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged10_cmd);
8972 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd);
8973 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged1_cmd);
8974 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged2_cmd);
8975 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged3_cmd);
8976 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged4_cmd);
8977 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged5_cmd);
8978 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged6_cmd);
8979 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged7_cmd);
8980 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged8_cmd);
8981 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged9_cmd);
8982 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged10_cmd);
8983 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd);
8984 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged1_cmd);
8985 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged2_cmd);
8986 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged3_cmd);
8987 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged4_cmd);
8988 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged5_cmd);
8989 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged6_cmd);
8990 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged7_cmd);
8991 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged8_cmd);
8992 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged9_cmd);
8993 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged10_cmd);
paul25ffbdc2005-08-22 22:42:08 +00008994 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd);
8995 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged1_cmd);
8996 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged2_cmd);
8997 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged3_cmd);
8998 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged4_cmd);
8999 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged5_cmd);
9000 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged6_cmd);
9001 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged7_cmd);
9002 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged8_cmd);
9003 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged9_cmd);
9004 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged10_cmd);
9005 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd);
9006 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged1_cmd);
9007 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged2_cmd);
9008 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged3_cmd);
9009 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged4_cmd);
9010 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged5_cmd);
9011 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged6_cmd);
9012 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged7_cmd);
9013 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged8_cmd);
9014 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged9_cmd);
9015 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged10_cmd);
paul718e3742002-12-13 20:15:29 +00009016 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd);
9017 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged1_cmd);
9018 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged2_cmd);
9019 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged3_cmd);
9020 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged4_cmd);
9021 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged5_cmd);
9022 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged6_cmd);
9023 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged7_cmd);
9024 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged8_cmd);
9025 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged9_cmd);
9026 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged10_cmd);
9027 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd);
9028 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged1_cmd);
9029 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged2_cmd);
9030 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged3_cmd);
9031 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged4_cmd);
9032 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged5_cmd);
9033 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged6_cmd);
9034 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged7_cmd);
9035 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged8_cmd);
9036 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged9_cmd);
9037 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged10_cmd);
9038
paulfee0f4c2004-09-13 05:12:46 +00009039 /* "nexthop-local unchanged" commands */
9040 install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd);
9041 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd);
9042
paul718e3742002-12-13 20:15:29 +00009043 /* "transparent-as" and "transparent-nexthop" for old version
9044 compatibility. */
9045 install_element (BGP_NODE, &neighbor_transparent_as_cmd);
9046 install_element (BGP_NODE, &neighbor_transparent_nexthop_cmd);
9047
9048 /* "neighbor next-hop-self" commands. */
9049 install_element (BGP_NODE, &neighbor_nexthop_self_cmd);
9050 install_element (BGP_NODE, &no_neighbor_nexthop_self_cmd);
9051 install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd);
9052 install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd);
9053 install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd);
9054 install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd);
9055 install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd);
9056 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009057 install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd);
9058 install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd);
paul718e3742002-12-13 20:15:29 +00009059 install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd);
9060 install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd);
9061
9062 /* "neighbor remove-private-AS" commands. */
9063 install_element (BGP_NODE, &neighbor_remove_private_as_cmd);
9064 install_element (BGP_NODE, &no_neighbor_remove_private_as_cmd);
9065 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd);
9066 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd);
9067 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd);
9068 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd);
9069 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd);
9070 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009071 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd);
9072 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd);
paul718e3742002-12-13 20:15:29 +00009073 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd);
9074 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd);
9075
9076 /* "neighbor send-community" commands.*/
9077 install_element (BGP_NODE, &neighbor_send_community_cmd);
9078 install_element (BGP_NODE, &neighbor_send_community_type_cmd);
9079 install_element (BGP_NODE, &no_neighbor_send_community_cmd);
9080 install_element (BGP_NODE, &no_neighbor_send_community_type_cmd);
9081 install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd);
9082 install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd);
9083 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd);
9084 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd);
9085 install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd);
9086 install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd);
9087 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd);
9088 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd);
9089 install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd);
9090 install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd);
9091 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd);
9092 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009093 install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd);
9094 install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd);
9095 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd);
9096 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd);
paul718e3742002-12-13 20:15:29 +00009097 install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd);
9098 install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd);
9099 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd);
9100 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd);
9101
9102 /* "neighbor route-reflector" commands.*/
9103 install_element (BGP_NODE, &neighbor_route_reflector_client_cmd);
9104 install_element (BGP_NODE, &no_neighbor_route_reflector_client_cmd);
9105 install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd);
9106 install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd);
9107 install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd);
9108 install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd);
9109 install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd);
9110 install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009111 install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd);
9112 install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd);
paul718e3742002-12-13 20:15:29 +00009113 install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd);
9114 install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd);
9115
9116 /* "neighbor route-server" commands.*/
9117 install_element (BGP_NODE, &neighbor_route_server_client_cmd);
9118 install_element (BGP_NODE, &no_neighbor_route_server_client_cmd);
9119 install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd);
9120 install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd);
9121 install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd);
9122 install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd);
9123 install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd);
9124 install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009125 install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd);
9126 install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd);
paul718e3742002-12-13 20:15:29 +00009127 install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd);
9128 install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd);
9129
9130 /* "neighbor passive" commands. */
9131 install_element (BGP_NODE, &neighbor_passive_cmd);
9132 install_element (BGP_NODE, &no_neighbor_passive_cmd);
9133
9134 /* "neighbor shutdown" commands. */
9135 install_element (BGP_NODE, &neighbor_shutdown_cmd);
9136 install_element (BGP_NODE, &no_neighbor_shutdown_cmd);
9137
hassoc9502432005-02-01 22:01:48 +00009138 /* Deprecated "neighbor capability route-refresh" commands.*/
paul718e3742002-12-13 20:15:29 +00009139 install_element (BGP_NODE, &neighbor_capability_route_refresh_cmd);
9140 install_element (BGP_NODE, &no_neighbor_capability_route_refresh_cmd);
9141
9142 /* "neighbor capability orf prefix-list" commands.*/
9143 install_element (BGP_NODE, &neighbor_capability_orf_prefix_cmd);
9144 install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_cmd);
9145 install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd);
9146 install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd);
9147 install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd);
9148 install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd);
9149 install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd);
9150 install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009151 install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd);
9152 install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00009153
9154 /* "neighbor capability dynamic" commands.*/
9155 install_element (BGP_NODE, &neighbor_capability_dynamic_cmd);
9156 install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd);
9157
9158 /* "neighbor dont-capability-negotiate" commands. */
9159 install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd);
9160 install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd);
9161
9162 /* "neighbor ebgp-multihop" commands. */
9163 install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd);
9164 install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd);
9165 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd);
9166 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_ttl_cmd);
9167
hasso6ffd2072005-02-02 14:50:11 +00009168 /* "neighbor disable-connected-check" commands. */
9169 install_element (BGP_NODE, &neighbor_disable_connected_check_cmd);
9170 install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd);
paul718e3742002-12-13 20:15:29 +00009171 install_element (BGP_NODE, &neighbor_enforce_multihop_cmd);
9172 install_element (BGP_NODE, &no_neighbor_enforce_multihop_cmd);
9173
9174 /* "neighbor description" commands. */
9175 install_element (BGP_NODE, &neighbor_description_cmd);
9176 install_element (BGP_NODE, &no_neighbor_description_cmd);
9177 install_element (BGP_NODE, &no_neighbor_description_val_cmd);
9178
9179 /* "neighbor update-source" commands. "*/
9180 install_element (BGP_NODE, &neighbor_update_source_cmd);
9181 install_element (BGP_NODE, &no_neighbor_update_source_cmd);
9182
9183 /* "neighbor default-originate" commands. */
9184 install_element (BGP_NODE, &neighbor_default_originate_cmd);
9185 install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd);
9186 install_element (BGP_NODE, &no_neighbor_default_originate_cmd);
9187 install_element (BGP_NODE, &no_neighbor_default_originate_rmap_cmd);
9188 install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd);
9189 install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd);
9190 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd);
9191 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_rmap_cmd);
9192 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd);
9193 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd);
9194 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd);
9195 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_rmap_cmd);
9196 install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd);
9197 install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd);
9198 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd);
9199 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_rmap_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009200 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd);
9201 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd);
9202 install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd);
9203 install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_rmap_cmd);
paul718e3742002-12-13 20:15:29 +00009204
9205 /* "neighbor port" commands. */
9206 install_element (BGP_NODE, &neighbor_port_cmd);
9207 install_element (BGP_NODE, &no_neighbor_port_cmd);
9208 install_element (BGP_NODE, &no_neighbor_port_val_cmd);
9209
9210 /* "neighbor weight" commands. */
9211 install_element (BGP_NODE, &neighbor_weight_cmd);
9212 install_element (BGP_NODE, &no_neighbor_weight_cmd);
9213 install_element (BGP_NODE, &no_neighbor_weight_val_cmd);
9214
9215 /* "neighbor override-capability" commands. */
9216 install_element (BGP_NODE, &neighbor_override_capability_cmd);
9217 install_element (BGP_NODE, &no_neighbor_override_capability_cmd);
9218
9219 /* "neighbor strict-capability-match" commands. */
9220 install_element (BGP_NODE, &neighbor_strict_capability_cmd);
9221 install_element (BGP_NODE, &no_neighbor_strict_capability_cmd);
9222
9223 /* "neighbor timers" commands. */
9224 install_element (BGP_NODE, &neighbor_timers_cmd);
9225 install_element (BGP_NODE, &no_neighbor_timers_cmd);
9226
9227 /* "neighbor timers connect" commands. */
9228 install_element (BGP_NODE, &neighbor_timers_connect_cmd);
9229 install_element (BGP_NODE, &no_neighbor_timers_connect_cmd);
9230 install_element (BGP_NODE, &no_neighbor_timers_connect_val_cmd);
9231
9232 /* "neighbor advertisement-interval" commands. */
9233 install_element (BGP_NODE, &neighbor_advertise_interval_cmd);
9234 install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd);
9235 install_element (BGP_NODE, &no_neighbor_advertise_interval_val_cmd);
9236
9237 /* "neighbor version" commands. */
9238 install_element (BGP_NODE, &neighbor_version_cmd);
paul718e3742002-12-13 20:15:29 +00009239
9240 /* "neighbor interface" commands. */
9241 install_element (BGP_NODE, &neighbor_interface_cmd);
9242 install_element (BGP_NODE, &no_neighbor_interface_cmd);
9243
9244 /* "neighbor distribute" commands. */
9245 install_element (BGP_NODE, &neighbor_distribute_list_cmd);
9246 install_element (BGP_NODE, &no_neighbor_distribute_list_cmd);
9247 install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd);
9248 install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd);
9249 install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd);
9250 install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd);
9251 install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd);
9252 install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009253 install_element (BGP_IPV6M_NODE, &neighbor_distribute_list_cmd);
9254 install_element (BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd);
paul718e3742002-12-13 20:15:29 +00009255 install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd);
9256 install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd);
9257
9258 /* "neighbor prefix-list" commands. */
9259 install_element (BGP_NODE, &neighbor_prefix_list_cmd);
9260 install_element (BGP_NODE, &no_neighbor_prefix_list_cmd);
9261 install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd);
9262 install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd);
9263 install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd);
9264 install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd);
9265 install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd);
9266 install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009267 install_element (BGP_IPV6M_NODE, &neighbor_prefix_list_cmd);
9268 install_element (BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd);
paul718e3742002-12-13 20:15:29 +00009269 install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd);
9270 install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd);
9271
9272 /* "neighbor filter-list" commands. */
9273 install_element (BGP_NODE, &neighbor_filter_list_cmd);
9274 install_element (BGP_NODE, &no_neighbor_filter_list_cmd);
9275 install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd);
9276 install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd);
9277 install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd);
9278 install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd);
9279 install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd);
9280 install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009281 install_element (BGP_IPV6M_NODE, &neighbor_filter_list_cmd);
9282 install_element (BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00009283 install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd);
9284 install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd);
9285
9286 /* "neighbor route-map" commands. */
9287 install_element (BGP_NODE, &neighbor_route_map_cmd);
9288 install_element (BGP_NODE, &no_neighbor_route_map_cmd);
9289 install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd);
9290 install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd);
9291 install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd);
9292 install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd);
9293 install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd);
9294 install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009295 install_element (BGP_IPV6M_NODE, &neighbor_route_map_cmd);
9296 install_element (BGP_IPV6M_NODE, &no_neighbor_route_map_cmd);
paul718e3742002-12-13 20:15:29 +00009297 install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd);
9298 install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd);
9299
9300 /* "neighbor unsuppress-map" commands. */
9301 install_element (BGP_NODE, &neighbor_unsuppress_map_cmd);
9302 install_element (BGP_NODE, &no_neighbor_unsuppress_map_cmd);
9303 install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd);
9304 install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd);
9305 install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd);
9306 install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd);
9307 install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd);
9308 install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009309 install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd);
9310 install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd);
paula58545b2003-07-12 21:43:01 +00009311 install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd);
9312 install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd);
paul718e3742002-12-13 20:15:29 +00009313
9314 /* "neighbor maximum-prefix" commands. */
9315 install_element (BGP_NODE, &neighbor_maximum_prefix_cmd);
hassoe0701b72004-05-20 09:19:34 +00009316 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_cmd);
paul718e3742002-12-13 20:15:29 +00009317 install_element (BGP_NODE, &neighbor_maximum_prefix_warning_cmd);
hassoe0701b72004-05-20 09:19:34 +00009318 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
hasso0a486e52005-02-01 20:57:17 +00009319 install_element (BGP_NODE, &neighbor_maximum_prefix_restart_cmd);
9320 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009321 install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd);
9322 install_element (BGP_NODE, &no_neighbor_maximum_prefix_val_cmd);
hasso0a486e52005-02-01 20:57:17 +00009323 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9324 install_element (BGP_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9325 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9326 install_element (BGP_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9327 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009328 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd);
hassoe0701b72004-05-20 09:19:34 +00009329 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
paul718e3742002-12-13 20:15:29 +00009330 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd);
hassoe0701b72004-05-20 09:19:34 +00009331 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
hasso0a486e52005-02-01 20:57:17 +00009332 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd);
9333 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009334 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd);
9335 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
hasso0a486e52005-02-01 20:57:17 +00009336 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9337 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9338 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9339 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9340 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009341 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd);
hassoe0701b72004-05-20 09:19:34 +00009342 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd);
paul718e3742002-12-13 20:15:29 +00009343 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd);
hassoe0701b72004-05-20 09:19:34 +00009344 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
hasso0a486e52005-02-01 20:57:17 +00009345 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd);
9346 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009347 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd);
9348 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_val_cmd);
hasso0a486e52005-02-01 20:57:17 +00009349 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9350 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9351 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9352 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9353 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009354 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd);
hassoe0701b72004-05-20 09:19:34 +00009355 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
paul718e3742002-12-13 20:15:29 +00009356 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd);
hassoe0701b72004-05-20 09:19:34 +00009357 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
hasso0a486e52005-02-01 20:57:17 +00009358 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd);
9359 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009360 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd);
9361 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_val_cmd);
hasso0a486e52005-02-01 20:57:17 +00009362 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9363 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9364 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9365 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9366 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009367 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd);
9368 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd);
9369 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd);
9370 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
9371 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd);
9372 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
9373 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd);
9374 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_val_cmd);
9375 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9376 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9377 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9378 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9379 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009380 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd);
hassoe0701b72004-05-20 09:19:34 +00009381 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
paul718e3742002-12-13 20:15:29 +00009382 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd);
hassoe0701b72004-05-20 09:19:34 +00009383 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
hasso0a486e52005-02-01 20:57:17 +00009384 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd);
9385 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009386 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd);
9387 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
hasso0a486e52005-02-01 20:57:17 +00009388 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9389 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9390 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9391 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9392 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009393
9394 /* "neighbor allowas-in" */
9395 install_element (BGP_NODE, &neighbor_allowas_in_cmd);
9396 install_element (BGP_NODE, &neighbor_allowas_in_arg_cmd);
9397 install_element (BGP_NODE, &no_neighbor_allowas_in_cmd);
9398 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd);
9399 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_arg_cmd);
9400 install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd);
9401 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd);
9402 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_arg_cmd);
9403 install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd);
9404 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd);
9405 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_arg_cmd);
9406 install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009407 install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd);
9408 install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_arg_cmd);
9409 install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd);
paul718e3742002-12-13 20:15:29 +00009410 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd);
9411 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_arg_cmd);
9412 install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd);
9413
9414 /* address-family commands. */
9415 install_element (BGP_NODE, &address_family_ipv4_cmd);
9416 install_element (BGP_NODE, &address_family_ipv4_safi_cmd);
9417#ifdef HAVE_IPV6
9418 install_element (BGP_NODE, &address_family_ipv6_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009419 install_element (BGP_NODE, &address_family_ipv6_safi_cmd);
paul718e3742002-12-13 20:15:29 +00009420#endif /* HAVE_IPV6 */
9421 install_element (BGP_NODE, &address_family_vpnv4_cmd);
9422 install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd);
9423
9424 /* "exit-address-family" command. */
9425 install_element (BGP_IPV4_NODE, &exit_address_family_cmd);
9426 install_element (BGP_IPV4M_NODE, &exit_address_family_cmd);
9427 install_element (BGP_IPV6_NODE, &exit_address_family_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009428 install_element (BGP_IPV6M_NODE, &exit_address_family_cmd);
paul718e3742002-12-13 20:15:29 +00009429 install_element (BGP_VPNV4_NODE, &exit_address_family_cmd);
9430
9431 /* "clear ip bgp commands" */
9432 install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd);
9433 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_cmd);
9434 install_element (ENABLE_NODE, &clear_ip_bgp_as_cmd);
9435 install_element (ENABLE_NODE, &clear_ip_bgp_peer_cmd);
9436 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_cmd);
9437 install_element (ENABLE_NODE, &clear_ip_bgp_external_cmd);
9438#ifdef HAVE_IPV6
9439 install_element (ENABLE_NODE, &clear_bgp_all_cmd);
9440 install_element (ENABLE_NODE, &clear_bgp_instance_all_cmd);
9441 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_cmd);
9442 install_element (ENABLE_NODE, &clear_bgp_peer_cmd);
9443 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_cmd);
9444 install_element (ENABLE_NODE, &clear_bgp_peer_group_cmd);
9445 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_cmd);
9446 install_element (ENABLE_NODE, &clear_bgp_external_cmd);
9447 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_cmd);
9448 install_element (ENABLE_NODE, &clear_bgp_as_cmd);
9449 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_cmd);
9450#endif /* HAVE_IPV6 */
9451
9452 /* "clear ip bgp neighbor soft in" */
9453 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_in_cmd);
9454 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_in_cmd);
9455 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_cmd);
9456 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_prefix_filter_cmd);
9457 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_in_prefix_filter_cmd);
9458 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_in_cmd);
9459 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_cmd);
9460 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_prefix_filter_cmd);
9461 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_in_cmd);
9462 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_cmd);
9463 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_prefix_filter_cmd);
9464 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_in_cmd);
9465 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_cmd);
9466 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_prefix_filter_cmd);
9467 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_in_cmd);
9468 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_cmd);
9469 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_prefix_filter_cmd);
9470 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_in_cmd);
9471 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_in_cmd);
9472 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_cmd);
9473 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_prefix_filter_cmd);
9474 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_in_prefix_filter_cmd);
9475 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_in_cmd);
9476 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_cmd);
9477 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd);
9478 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_in_cmd);
9479 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_cmd);
9480 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd);
9481 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_in_cmd);
9482 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_cmd);
9483 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_prefix_filter_cmd);
9484 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_in_cmd);
9485 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_cmd);
9486 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_prefix_filter_cmd);
9487 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_in_cmd);
9488 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_in_cmd);
9489 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_in_cmd);
9490 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_in_cmd);
9491 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_in_cmd);
9492 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_in_cmd);
9493#ifdef HAVE_IPV6
9494 install_element (ENABLE_NODE, &clear_bgp_all_soft_in_cmd);
9495 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_in_cmd);
9496 install_element (ENABLE_NODE, &clear_bgp_all_in_cmd);
9497 install_element (ENABLE_NODE, &clear_bgp_all_in_prefix_filter_cmd);
9498 install_element (ENABLE_NODE, &clear_bgp_peer_soft_in_cmd);
9499 install_element (ENABLE_NODE, &clear_bgp_peer_in_cmd);
9500 install_element (ENABLE_NODE, &clear_bgp_peer_in_prefix_filter_cmd);
9501 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_in_cmd);
9502 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_cmd);
9503 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_prefix_filter_cmd);
9504 install_element (ENABLE_NODE, &clear_bgp_external_soft_in_cmd);
9505 install_element (ENABLE_NODE, &clear_bgp_external_in_cmd);
9506 install_element (ENABLE_NODE, &clear_bgp_external_in_prefix_filter_cmd);
9507 install_element (ENABLE_NODE, &clear_bgp_as_soft_in_cmd);
9508 install_element (ENABLE_NODE, &clear_bgp_as_in_cmd);
9509 install_element (ENABLE_NODE, &clear_bgp_as_in_prefix_filter_cmd);
9510 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_in_cmd);
9511 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_cmd);
9512 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_prefix_filter_cmd);
9513 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_in_cmd);
9514 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_cmd);
9515 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_prefix_filter_cmd);
9516 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_in_cmd);
9517 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_cmd);
9518 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_prefix_filter_cmd);
9519 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_in_cmd);
9520 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_cmd);
9521 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_prefix_filter_cmd);
9522 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_in_cmd);
9523 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_cmd);
9524 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_prefix_filter_cmd);
9525#endif /* HAVE_IPV6 */
9526
9527 /* "clear ip bgp neighbor soft out" */
9528 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_out_cmd);
9529 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_out_cmd);
9530 install_element (ENABLE_NODE, &clear_ip_bgp_all_out_cmd);
9531 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_out_cmd);
9532 install_element (ENABLE_NODE, &clear_ip_bgp_peer_out_cmd);
9533 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_out_cmd);
9534 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_out_cmd);
9535 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_out_cmd);
9536 install_element (ENABLE_NODE, &clear_ip_bgp_external_out_cmd);
9537 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_out_cmd);
9538 install_element (ENABLE_NODE, &clear_ip_bgp_as_out_cmd);
9539 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_out_cmd);
9540 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_out_cmd);
9541 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_out_cmd);
9542 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_out_cmd);
9543 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_out_cmd);
9544 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_out_cmd);
9545 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_out_cmd);
9546 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_out_cmd);
9547 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_out_cmd);
9548 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_out_cmd);
9549 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_out_cmd);
9550 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_out_cmd);
9551 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_out_cmd);
9552 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_out_cmd);
9553 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_out_cmd);
9554 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_out_cmd);
9555 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_out_cmd);
9556#ifdef HAVE_IPV6
9557 install_element (ENABLE_NODE, &clear_bgp_all_soft_out_cmd);
9558 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_out_cmd);
9559 install_element (ENABLE_NODE, &clear_bgp_all_out_cmd);
9560 install_element (ENABLE_NODE, &clear_bgp_peer_soft_out_cmd);
9561 install_element (ENABLE_NODE, &clear_bgp_peer_out_cmd);
9562 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_out_cmd);
9563 install_element (ENABLE_NODE, &clear_bgp_peer_group_out_cmd);
9564 install_element (ENABLE_NODE, &clear_bgp_external_soft_out_cmd);
9565 install_element (ENABLE_NODE, &clear_bgp_external_out_cmd);
9566 install_element (ENABLE_NODE, &clear_bgp_as_soft_out_cmd);
9567 install_element (ENABLE_NODE, &clear_bgp_as_out_cmd);
9568 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_out_cmd);
9569 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_out_cmd);
9570 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_out_cmd);
9571 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_out_cmd);
9572 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_out_cmd);
9573 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_out_cmd);
9574 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_out_cmd);
9575 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_out_cmd);
9576 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_out_cmd);
9577 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_out_cmd);
9578#endif /* HAVE_IPV6 */
9579
9580 /* "clear ip bgp neighbor soft" */
9581 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_cmd);
9582 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_cmd);
9583 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_cmd);
9584 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_cmd);
9585 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_cmd);
9586 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_cmd);
9587 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_cmd);
9588 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_cmd);
9589 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_cmd);
9590 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_cmd);
9591 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_cmd);
9592 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_cmd);
9593 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_cmd);
9594 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_cmd);
9595 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_cmd);
9596#ifdef HAVE_IPV6
9597 install_element (ENABLE_NODE, &clear_bgp_all_soft_cmd);
9598 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_cmd);
9599 install_element (ENABLE_NODE, &clear_bgp_peer_soft_cmd);
9600 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_cmd);
9601 install_element (ENABLE_NODE, &clear_bgp_external_soft_cmd);
9602 install_element (ENABLE_NODE, &clear_bgp_as_soft_cmd);
9603 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_cmd);
9604 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_cmd);
9605 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_cmd);
9606 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_cmd);
9607 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_cmd);
9608#endif /* HAVE_IPV6 */
9609
paulfee0f4c2004-09-13 05:12:46 +00009610 /* "clear ip bgp neighbor rsclient" */
9611 install_element (ENABLE_NODE, &clear_ip_bgp_all_rsclient_cmd);
9612 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_rsclient_cmd);
9613 install_element (ENABLE_NODE, &clear_ip_bgp_peer_rsclient_cmd);
9614 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_rsclient_cmd);
9615#ifdef HAVE_IPV6
9616 install_element (ENABLE_NODE, &clear_bgp_all_rsclient_cmd);
9617 install_element (ENABLE_NODE, &clear_bgp_instance_all_rsclient_cmd);
9618 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_rsclient_cmd);
9619 install_element (ENABLE_NODE, &clear_bgp_ipv6_instance_all_rsclient_cmd);
9620 install_element (ENABLE_NODE, &clear_bgp_peer_rsclient_cmd);
9621 install_element (ENABLE_NODE, &clear_bgp_instance_peer_rsclient_cmd);
9622 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_rsclient_cmd);
9623 install_element (ENABLE_NODE, &clear_bgp_ipv6_instance_peer_rsclient_cmd);
9624#endif /* HAVE_IPV6 */
9625
paul718e3742002-12-13 20:15:29 +00009626 /* "show ip bgp summary" commands. */
9627 install_element (VIEW_NODE, &show_ip_bgp_summary_cmd);
9628 install_element (VIEW_NODE, &show_ip_bgp_instance_summary_cmd);
9629 install_element (VIEW_NODE, &show_ip_bgp_ipv4_summary_cmd);
9630 install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
9631 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
9632 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
9633#ifdef HAVE_IPV6
9634 install_element (VIEW_NODE, &show_bgp_summary_cmd);
9635 install_element (VIEW_NODE, &show_bgp_instance_summary_cmd);
9636 install_element (VIEW_NODE, &show_bgp_ipv6_summary_cmd);
9637 install_element (VIEW_NODE, &show_bgp_instance_ipv6_summary_cmd);
9638#endif /* HAVE_IPV6 */
Paul Jakma62687ff2008-08-23 14:27:06 +01009639 install_element (RESTRICTED_NODE, &show_ip_bgp_summary_cmd);
9640 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_summary_cmd);
9641 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_summary_cmd);
9642 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
9643 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
9644 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
9645#ifdef HAVE_IPV6
9646 install_element (RESTRICTED_NODE, &show_bgp_summary_cmd);
9647 install_element (RESTRICTED_NODE, &show_bgp_instance_summary_cmd);
9648 install_element (RESTRICTED_NODE, &show_bgp_ipv6_summary_cmd);
9649 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_summary_cmd);
9650#endif /* HAVE_IPV6 */
paul718e3742002-12-13 20:15:29 +00009651 install_element (ENABLE_NODE, &show_ip_bgp_summary_cmd);
9652 install_element (ENABLE_NODE, &show_ip_bgp_instance_summary_cmd);
9653 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_summary_cmd);
9654 install_element (ENABLE_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
9655 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
9656 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
9657#ifdef HAVE_IPV6
9658 install_element (ENABLE_NODE, &show_bgp_summary_cmd);
9659 install_element (ENABLE_NODE, &show_bgp_instance_summary_cmd);
9660 install_element (ENABLE_NODE, &show_bgp_ipv6_summary_cmd);
9661 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_summary_cmd);
9662#endif /* HAVE_IPV6 */
9663
9664 /* "show ip bgp neighbors" commands. */
9665 install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd);
9666 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
9667 install_element (VIEW_NODE, &show_ip_bgp_neighbors_peer_cmd);
9668 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
9669 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd);
9670 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd);
9671 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
9672 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
9673 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_cmd);
9674 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +01009675 install_element (RESTRICTED_NODE, &show_ip_bgp_neighbors_peer_cmd);
9676 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
9677 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
9678 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
9679 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
paul718e3742002-12-13 20:15:29 +00009680 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_cmd);
9681 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
9682 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_peer_cmd);
9683 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
9684 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd);
9685 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd);
9686 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
9687 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
9688 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_cmd);
9689 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
9690
9691#ifdef HAVE_IPV6
9692 install_element (VIEW_NODE, &show_bgp_neighbors_cmd);
9693 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_cmd);
9694 install_element (VIEW_NODE, &show_bgp_neighbors_peer_cmd);
9695 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
paulbb46e942003-10-24 19:02:03 +00009696 install_element (VIEW_NODE, &show_bgp_instance_neighbors_cmd);
9697 install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
9698 install_element (VIEW_NODE, &show_bgp_instance_neighbors_peer_cmd);
9699 install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +01009700 install_element (RESTRICTED_NODE, &show_bgp_neighbors_peer_cmd);
9701 install_element (RESTRICTED_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
9702 install_element (RESTRICTED_NODE, &show_bgp_instance_neighbors_peer_cmd);
9703 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
paul718e3742002-12-13 20:15:29 +00009704 install_element (ENABLE_NODE, &show_bgp_neighbors_cmd);
9705 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_cmd);
9706 install_element (ENABLE_NODE, &show_bgp_neighbors_peer_cmd);
9707 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
paulbb46e942003-10-24 19:02:03 +00009708 install_element (ENABLE_NODE, &show_bgp_instance_neighbors_cmd);
9709 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
9710 install_element (ENABLE_NODE, &show_bgp_instance_neighbors_peer_cmd);
9711 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
paul718e3742002-12-13 20:15:29 +00009712
9713 /* Old commands. */
9714 install_element (VIEW_NODE, &show_ipv6_bgp_summary_cmd);
9715 install_element (VIEW_NODE, &show_ipv6_mbgp_summary_cmd);
9716 install_element (ENABLE_NODE, &show_ipv6_bgp_summary_cmd);
9717 install_element (ENABLE_NODE, &show_ipv6_mbgp_summary_cmd);
9718#endif /* HAVE_IPV6 */
9719
paulfee0f4c2004-09-13 05:12:46 +00009720 /* "show ip bgp rsclient" commands. */
9721 install_element (VIEW_NODE, &show_ip_bgp_rsclient_summary_cmd);
9722 install_element (VIEW_NODE, &show_ip_bgp_instance_rsclient_summary_cmd);
9723 install_element (VIEW_NODE, &show_ip_bgp_ipv4_rsclient_summary_cmd);
9724 install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_rsclient_summary_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +01009725 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_summary_cmd);
9726 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_rsclient_summary_cmd);
9727 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_rsclient_summary_cmd);
9728 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_ipv4_rsclient_summary_cmd);
paulfee0f4c2004-09-13 05:12:46 +00009729 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_summary_cmd);
9730 install_element (ENABLE_NODE, &show_ip_bgp_instance_rsclient_summary_cmd);
9731 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_rsclient_summary_cmd);
9732 install_element (ENABLE_NODE, &show_ip_bgp_instance_ipv4_rsclient_summary_cmd);
9733
9734#ifdef HAVE_IPV6
9735 install_element (VIEW_NODE, &show_bgp_rsclient_summary_cmd);
9736 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_summary_cmd);
9737 install_element (VIEW_NODE, &show_bgp_instance_rsclient_summary_cmd);
9738 install_element (VIEW_NODE, &show_bgp_instance_ipv6_rsclient_summary_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +01009739 install_element (RESTRICTED_NODE, &show_bgp_rsclient_summary_cmd);
9740 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_summary_cmd);
9741 install_element (RESTRICTED_NODE, &show_bgp_instance_rsclient_summary_cmd);
9742 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_rsclient_summary_cmd);
paulfee0f4c2004-09-13 05:12:46 +00009743 install_element (ENABLE_NODE, &show_bgp_rsclient_summary_cmd);
9744 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_summary_cmd);
9745 install_element (ENABLE_NODE, &show_bgp_instance_rsclient_summary_cmd);
9746 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_rsclient_summary_cmd);
9747#endif /* HAVE_IPV6 */
9748
paul718e3742002-12-13 20:15:29 +00009749 /* "show ip bgp paths" commands. */
9750 install_element (VIEW_NODE, &show_ip_bgp_paths_cmd);
9751 install_element (VIEW_NODE, &show_ip_bgp_ipv4_paths_cmd);
9752 install_element (ENABLE_NODE, &show_ip_bgp_paths_cmd);
9753 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_paths_cmd);
9754
9755 /* "show ip bgp community" commands. */
9756 install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd);
9757 install_element (ENABLE_NODE, &show_ip_bgp_community_info_cmd);
9758
9759 /* "show ip bgp attribute-info" commands. */
9760 install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd);
9761 install_element (ENABLE_NODE, &show_ip_bgp_attr_info_cmd);
9762
9763 /* "redistribute" commands. */
9764 install_element (BGP_NODE, &bgp_redistribute_ipv4_cmd);
9765 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_cmd);
9766 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_cmd);
9767 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_cmd);
9768 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_cmd);
9769 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_cmd);
9770 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd);
9771 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd);
9772 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_metric_cmd);
9773 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_rmap_cmd);
9774#ifdef HAVE_IPV6
9775 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd);
9776 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd);
9777 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd);
9778 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_cmd);
9779 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd);
9780 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_cmd);
9781 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd);
9782 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd);
9783 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_metric_cmd);
9784 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_rmap_cmd);
9785#endif /* HAVE_IPV6 */
9786
Paul Jakma4bf6a362006-03-30 14:05:23 +00009787 /* "show bgp memory" commands. */
9788 install_element (VIEW_NODE, &show_bgp_memory_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +01009789 install_element (RESTRICTED_NODE, &show_bgp_memory_cmd);
Paul Jakma4bf6a362006-03-30 14:05:23 +00009790 install_element (ENABLE_NODE, &show_bgp_memory_cmd);
9791
Michael Lamberte0081f72008-11-16 20:12:04 +00009792 /* "show bgp views" commands. */
9793 install_element (VIEW_NODE, &show_bgp_views_cmd);
9794 install_element (RESTRICTED_NODE, &show_bgp_views_cmd);
9795 install_element (ENABLE_NODE, &show_bgp_views_cmd);
9796
paul718e3742002-12-13 20:15:29 +00009797 /* Community-list. */
9798 community_list_vty ();
9799}
9800
9801#include "memory.h"
9802#include "bgp_regex.h"
9803#include "bgp_clist.h"
9804#include "bgp_ecommunity.h"
9805
9806/* VTY functions. */
9807
9808/* Direction value to string conversion. */
paul94f2b392005-06-28 12:44:16 +00009809static const char *
paul718e3742002-12-13 20:15:29 +00009810community_direct_str (int direct)
9811{
9812 switch (direct)
9813 {
9814 case COMMUNITY_DENY:
9815 return "deny";
paul718e3742002-12-13 20:15:29 +00009816 case COMMUNITY_PERMIT:
9817 return "permit";
paul718e3742002-12-13 20:15:29 +00009818 default:
9819 return "unknown";
paul718e3742002-12-13 20:15:29 +00009820 }
9821}
9822
9823/* Display error string. */
paul94f2b392005-06-28 12:44:16 +00009824static void
paul718e3742002-12-13 20:15:29 +00009825community_list_perror (struct vty *vty, int ret)
9826{
9827 switch (ret)
9828 {
9829 case COMMUNITY_LIST_ERR_CANT_FIND_LIST:
Denis Ovsienkodfc1d5c2010-12-08 18:51:37 +03009830 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00009831 break;
9832 case COMMUNITY_LIST_ERR_MALFORMED_VAL:
9833 vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE);
9834 break;
9835 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT:
9836 vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE);
9837 break;
9838 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT:
9839 vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE);
9840 break;
9841 }
9842}
9843
9844/* VTY interface for community_set() function. */
paul94f2b392005-06-28 12:44:16 +00009845static int
paulfd79ac92004-10-13 05:06:08 +00009846community_list_set_vty (struct vty *vty, int argc, const char **argv,
9847 int style, int reject_all_digit_name)
paul718e3742002-12-13 20:15:29 +00009848{
9849 int ret;
9850 int direct;
9851 char *str;
9852
9853 /* Check the list type. */
9854 if (strncmp (argv[1], "p", 1) == 0)
9855 direct = COMMUNITY_PERMIT;
9856 else if (strncmp (argv[1], "d", 1) == 0)
9857 direct = COMMUNITY_DENY;
9858 else
9859 {
9860 vty_out (vty, "%% Matching condition must be permit or deny%s",
9861 VTY_NEWLINE);
9862 return CMD_WARNING;
9863 }
9864
9865 /* All digit name check. */
9866 if (reject_all_digit_name && all_digit (argv[0]))
9867 {
9868 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
9869 return CMD_WARNING;
9870 }
9871
9872 /* Concat community string argument. */
9873 if (argc > 1)
9874 str = argv_concat (argv, argc, 2);
9875 else
9876 str = NULL;
9877
9878 /* When community_list_set() return nevetive value, it means
9879 malformed community string. */
9880 ret = community_list_set (bgp_clist, argv[0], str, direct, style);
9881
9882 /* Free temporary community list string allocated by
9883 argv_concat(). */
9884 if (str)
9885 XFREE (MTYPE_TMP, str);
9886
9887 if (ret < 0)
9888 {
9889 /* Display error string. */
9890 community_list_perror (vty, ret);
9891 return CMD_WARNING;
9892 }
9893
9894 return CMD_SUCCESS;
9895}
9896
paul718e3742002-12-13 20:15:29 +00009897/* Communiyt-list entry delete. */
paul94f2b392005-06-28 12:44:16 +00009898static int
hassofee6e4e2005-02-02 16:29:31 +00009899community_list_unset_vty (struct vty *vty, int argc, const char **argv,
9900 int style)
paul718e3742002-12-13 20:15:29 +00009901{
9902 int ret;
hassofee6e4e2005-02-02 16:29:31 +00009903 int direct = 0;
9904 char *str = NULL;
paul718e3742002-12-13 20:15:29 +00009905
hassofee6e4e2005-02-02 16:29:31 +00009906 if (argc > 1)
paul718e3742002-12-13 20:15:29 +00009907 {
hassofee6e4e2005-02-02 16:29:31 +00009908 /* Check the list direct. */
9909 if (strncmp (argv[1], "p", 1) == 0)
9910 direct = COMMUNITY_PERMIT;
9911 else if (strncmp (argv[1], "d", 1) == 0)
9912 direct = COMMUNITY_DENY;
9913 else
9914 {
9915 vty_out (vty, "%% Matching condition must be permit or deny%s",
9916 VTY_NEWLINE);
9917 return CMD_WARNING;
9918 }
paul718e3742002-12-13 20:15:29 +00009919
hassofee6e4e2005-02-02 16:29:31 +00009920 /* Concat community string argument. */
9921 str = argv_concat (argv, argc, 2);
9922 }
paul718e3742002-12-13 20:15:29 +00009923
9924 /* Unset community list. */
9925 ret = community_list_unset (bgp_clist, argv[0], str, direct, style);
9926
9927 /* Free temporary community list string allocated by
9928 argv_concat(). */
hassofee6e4e2005-02-02 16:29:31 +00009929 if (str)
9930 XFREE (MTYPE_TMP, str);
paul718e3742002-12-13 20:15:29 +00009931
9932 if (ret < 0)
9933 {
9934 community_list_perror (vty, ret);
9935 return CMD_WARNING;
9936 }
9937
9938 return CMD_SUCCESS;
9939}
9940
9941/* "community-list" keyword help string. */
9942#define COMMUNITY_LIST_STR "Add a community list entry\n"
9943#define COMMUNITY_VAL_STR "Community number in aa:nn format or internet|local-AS|no-advertise|no-export\n"
9944
paul718e3742002-12-13 20:15:29 +00009945DEFUN (ip_community_list_standard,
9946 ip_community_list_standard_cmd,
9947 "ip community-list <1-99> (deny|permit) .AA:NN",
9948 IP_STR
9949 COMMUNITY_LIST_STR
9950 "Community list number (standard)\n"
9951 "Specify community to reject\n"
9952 "Specify community to accept\n"
9953 COMMUNITY_VAL_STR)
9954{
9955 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
9956}
9957
9958ALIAS (ip_community_list_standard,
9959 ip_community_list_standard2_cmd,
9960 "ip community-list <1-99> (deny|permit)",
9961 IP_STR
9962 COMMUNITY_LIST_STR
9963 "Community list number (standard)\n"
9964 "Specify community to reject\n"
9965 "Specify community to accept\n")
9966
9967DEFUN (ip_community_list_expanded,
9968 ip_community_list_expanded_cmd,
hassofee6e4e2005-02-02 16:29:31 +00009969 "ip community-list <100-500> (deny|permit) .LINE",
paul718e3742002-12-13 20:15:29 +00009970 IP_STR
9971 COMMUNITY_LIST_STR
9972 "Community list number (expanded)\n"
9973 "Specify community to reject\n"
9974 "Specify community to accept\n"
9975 "An ordered list as a regular-expression\n")
9976{
9977 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
9978}
9979
9980DEFUN (ip_community_list_name_standard,
9981 ip_community_list_name_standard_cmd,
9982 "ip community-list standard WORD (deny|permit) .AA:NN",
9983 IP_STR
9984 COMMUNITY_LIST_STR
9985 "Add a standard community-list entry\n"
9986 "Community list name\n"
9987 "Specify community to reject\n"
9988 "Specify community to accept\n"
9989 COMMUNITY_VAL_STR)
9990{
9991 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
9992}
9993
9994ALIAS (ip_community_list_name_standard,
9995 ip_community_list_name_standard2_cmd,
9996 "ip community-list standard WORD (deny|permit)",
9997 IP_STR
9998 COMMUNITY_LIST_STR
9999 "Add a standard community-list entry\n"
10000 "Community list name\n"
10001 "Specify community to reject\n"
10002 "Specify community to accept\n")
10003
10004DEFUN (ip_community_list_name_expanded,
10005 ip_community_list_name_expanded_cmd,
10006 "ip community-list expanded WORD (deny|permit) .LINE",
10007 IP_STR
10008 COMMUNITY_LIST_STR
10009 "Add an expanded community-list entry\n"
10010 "Community list name\n"
10011 "Specify community to reject\n"
10012 "Specify community to accept\n"
10013 "An ordered list as a regular-expression\n")
10014{
10015 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
10016}
10017
hassofee6e4e2005-02-02 16:29:31 +000010018DEFUN (no_ip_community_list_standard_all,
10019 no_ip_community_list_standard_all_cmd,
10020 "no ip community-list <1-99>",
paul718e3742002-12-13 20:15:29 +000010021 NO_STR
10022 IP_STR
10023 COMMUNITY_LIST_STR
hassofee6e4e2005-02-02 16:29:31 +000010024 "Community list number (standard)\n")
paul718e3742002-12-13 20:15:29 +000010025{
hassofee6e4e2005-02-02 16:29:31 +000010026 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
paul718e3742002-12-13 20:15:29 +000010027}
10028
hassofee6e4e2005-02-02 16:29:31 +000010029DEFUN (no_ip_community_list_expanded_all,
10030 no_ip_community_list_expanded_all_cmd,
10031 "no ip community-list <100-500>",
10032 NO_STR
10033 IP_STR
10034 COMMUNITY_LIST_STR
10035 "Community list number (expanded)\n")
10036{
10037 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
10038}
10039
10040DEFUN (no_ip_community_list_name_standard_all,
10041 no_ip_community_list_name_standard_all_cmd,
10042 "no ip community-list standard WORD",
paul718e3742002-12-13 20:15:29 +000010043 NO_STR
10044 IP_STR
10045 COMMUNITY_LIST_STR
10046 "Add a standard community-list entry\n"
paul718e3742002-12-13 20:15:29 +000010047 "Community list name\n")
10048{
hassofee6e4e2005-02-02 16:29:31 +000010049 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
paul718e3742002-12-13 20:15:29 +000010050}
10051
hassofee6e4e2005-02-02 16:29:31 +000010052DEFUN (no_ip_community_list_name_expanded_all,
10053 no_ip_community_list_name_expanded_all_cmd,
10054 "no ip community-list expanded WORD",
paul718e3742002-12-13 20:15:29 +000010055 NO_STR
10056 IP_STR
10057 COMMUNITY_LIST_STR
hassofee6e4e2005-02-02 16:29:31 +000010058 "Add an expanded community-list entry\n"
10059 "Community list name\n")
paul718e3742002-12-13 20:15:29 +000010060{
hassofee6e4e2005-02-02 16:29:31 +000010061 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
paul718e3742002-12-13 20:15:29 +000010062}
10063
10064DEFUN (no_ip_community_list_standard,
10065 no_ip_community_list_standard_cmd,
10066 "no ip community-list <1-99> (deny|permit) .AA:NN",
10067 NO_STR
10068 IP_STR
10069 COMMUNITY_LIST_STR
10070 "Community list number (standard)\n"
10071 "Specify community to reject\n"
10072 "Specify community to accept\n"
10073 COMMUNITY_VAL_STR)
10074{
10075 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
10076}
10077
10078DEFUN (no_ip_community_list_expanded,
10079 no_ip_community_list_expanded_cmd,
hassofee6e4e2005-02-02 16:29:31 +000010080 "no ip community-list <100-500> (deny|permit) .LINE",
paul718e3742002-12-13 20:15:29 +000010081 NO_STR
10082 IP_STR
10083 COMMUNITY_LIST_STR
10084 "Community list number (expanded)\n"
10085 "Specify community to reject\n"
10086 "Specify community to accept\n"
10087 "An ordered list as a regular-expression\n")
10088{
10089 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
10090}
10091
10092DEFUN (no_ip_community_list_name_standard,
10093 no_ip_community_list_name_standard_cmd,
10094 "no ip community-list standard WORD (deny|permit) .AA:NN",
10095 NO_STR
10096 IP_STR
10097 COMMUNITY_LIST_STR
10098 "Specify a standard community-list\n"
10099 "Community list name\n"
10100 "Specify community to reject\n"
10101 "Specify community to accept\n"
10102 COMMUNITY_VAL_STR)
10103{
10104 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
10105}
10106
10107DEFUN (no_ip_community_list_name_expanded,
10108 no_ip_community_list_name_expanded_cmd,
10109 "no ip community-list expanded WORD (deny|permit) .LINE",
10110 NO_STR
10111 IP_STR
10112 COMMUNITY_LIST_STR
10113 "Specify an expanded community-list\n"
10114 "Community list name\n"
10115 "Specify community to reject\n"
10116 "Specify community to accept\n"
10117 "An ordered list as a regular-expression\n")
10118{
10119 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
10120}
10121
paul94f2b392005-06-28 12:44:16 +000010122static void
paul718e3742002-12-13 20:15:29 +000010123community_list_show (struct vty *vty, struct community_list *list)
10124{
10125 struct community_entry *entry;
10126
10127 for (entry = list->head; entry; entry = entry->next)
10128 {
10129 if (entry == list->head)
10130 {
10131 if (all_digit (list->name))
10132 vty_out (vty, "Community %s list %s%s",
10133 entry->style == COMMUNITY_LIST_STANDARD ?
10134 "standard" : "(expanded) access",
10135 list->name, VTY_NEWLINE);
10136 else
10137 vty_out (vty, "Named Community %s list %s%s",
10138 entry->style == COMMUNITY_LIST_STANDARD ?
10139 "standard" : "expanded",
10140 list->name, VTY_NEWLINE);
10141 }
10142 if (entry->any)
10143 vty_out (vty, " %s%s",
10144 community_direct_str (entry->direct), VTY_NEWLINE);
10145 else
10146 vty_out (vty, " %s %s%s",
10147 community_direct_str (entry->direct),
10148 entry->style == COMMUNITY_LIST_STANDARD
10149 ? community_str (entry->u.com) : entry->config,
10150 VTY_NEWLINE);
10151 }
10152}
10153
10154DEFUN (show_ip_community_list,
10155 show_ip_community_list_cmd,
10156 "show ip community-list",
10157 SHOW_STR
10158 IP_STR
10159 "List community-list\n")
10160{
10161 struct community_list *list;
10162 struct community_list_master *cm;
10163
hassofee6e4e2005-02-02 16:29:31 +000010164 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010165 if (! cm)
10166 return CMD_SUCCESS;
10167
10168 for (list = cm->num.head; list; list = list->next)
10169 community_list_show (vty, list);
10170
10171 for (list = cm->str.head; list; list = list->next)
10172 community_list_show (vty, list);
10173
10174 return CMD_SUCCESS;
10175}
10176
10177DEFUN (show_ip_community_list_arg,
10178 show_ip_community_list_arg_cmd,
hassofee6e4e2005-02-02 16:29:31 +000010179 "show ip community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000010180 SHOW_STR
10181 IP_STR
10182 "List community-list\n"
10183 "Community-list number\n"
10184 "Community-list name\n")
10185{
10186 struct community_list *list;
10187
hassofee6e4e2005-02-02 16:29:31 +000010188 list = community_list_lookup (bgp_clist, argv[0], COMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010189 if (! list)
10190 {
Denis Ovsienkodfc1d5c2010-12-08 18:51:37 +030010191 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000010192 return CMD_WARNING;
10193 }
10194
10195 community_list_show (vty, list);
10196
10197 return CMD_SUCCESS;
10198}
10199
paul94f2b392005-06-28 12:44:16 +000010200static int
paulfd79ac92004-10-13 05:06:08 +000010201extcommunity_list_set_vty (struct vty *vty, int argc, const char **argv,
10202 int style, int reject_all_digit_name)
paul718e3742002-12-13 20:15:29 +000010203{
10204 int ret;
10205 int direct;
10206 char *str;
10207
10208 /* Check the list type. */
10209 if (strncmp (argv[1], "p", 1) == 0)
10210 direct = COMMUNITY_PERMIT;
10211 else if (strncmp (argv[1], "d", 1) == 0)
10212 direct = COMMUNITY_DENY;
10213 else
10214 {
10215 vty_out (vty, "%% Matching condition must be permit or deny%s",
10216 VTY_NEWLINE);
10217 return CMD_WARNING;
10218 }
10219
10220 /* All digit name check. */
10221 if (reject_all_digit_name && all_digit (argv[0]))
10222 {
10223 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
10224 return CMD_WARNING;
10225 }
10226
10227 /* Concat community string argument. */
10228 if (argc > 1)
10229 str = argv_concat (argv, argc, 2);
10230 else
10231 str = NULL;
10232
10233 ret = extcommunity_list_set (bgp_clist, argv[0], str, direct, style);
10234
10235 /* Free temporary community list string allocated by
10236 argv_concat(). */
10237 if (str)
10238 XFREE (MTYPE_TMP, str);
10239
10240 if (ret < 0)
10241 {
10242 community_list_perror (vty, ret);
10243 return CMD_WARNING;
10244 }
10245 return CMD_SUCCESS;
10246}
10247
paul94f2b392005-06-28 12:44:16 +000010248static int
hassofee6e4e2005-02-02 16:29:31 +000010249extcommunity_list_unset_vty (struct vty *vty, int argc, const char **argv,
10250 int style)
paul718e3742002-12-13 20:15:29 +000010251{
10252 int ret;
hassofee6e4e2005-02-02 16:29:31 +000010253 int direct = 0;
10254 char *str = NULL;
paul718e3742002-12-13 20:15:29 +000010255
hassofee6e4e2005-02-02 16:29:31 +000010256 if (argc > 1)
paul718e3742002-12-13 20:15:29 +000010257 {
hassofee6e4e2005-02-02 16:29:31 +000010258 /* Check the list direct. */
10259 if (strncmp (argv[1], "p", 1) == 0)
10260 direct = COMMUNITY_PERMIT;
10261 else if (strncmp (argv[1], "d", 1) == 0)
10262 direct = COMMUNITY_DENY;
10263 else
10264 {
10265 vty_out (vty, "%% Matching condition must be permit or deny%s",
10266 VTY_NEWLINE);
10267 return CMD_WARNING;
10268 }
10269
10270 /* Concat community string argument. */
10271 str = argv_concat (argv, argc, 2);
paul718e3742002-12-13 20:15:29 +000010272 }
paul718e3742002-12-13 20:15:29 +000010273
10274 /* Unset community list. */
10275 ret = extcommunity_list_unset (bgp_clist, argv[0], str, direct, style);
10276
10277 /* Free temporary community list string allocated by
10278 argv_concat(). */
hassofee6e4e2005-02-02 16:29:31 +000010279 if (str)
10280 XFREE (MTYPE_TMP, str);
paul718e3742002-12-13 20:15:29 +000010281
10282 if (ret < 0)
10283 {
10284 community_list_perror (vty, ret);
10285 return CMD_WARNING;
10286 }
10287
10288 return CMD_SUCCESS;
10289}
10290
10291/* "extcommunity-list" keyword help string. */
10292#define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
10293#define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
10294
10295DEFUN (ip_extcommunity_list_standard,
10296 ip_extcommunity_list_standard_cmd,
10297 "ip extcommunity-list <1-99> (deny|permit) .AA:NN",
10298 IP_STR
10299 EXTCOMMUNITY_LIST_STR
10300 "Extended Community list number (standard)\n"
10301 "Specify community to reject\n"
10302 "Specify community to accept\n"
10303 EXTCOMMUNITY_VAL_STR)
10304{
10305 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
10306}
10307
10308ALIAS (ip_extcommunity_list_standard,
10309 ip_extcommunity_list_standard2_cmd,
10310 "ip extcommunity-list <1-99> (deny|permit)",
10311 IP_STR
10312 EXTCOMMUNITY_LIST_STR
10313 "Extended Community list number (standard)\n"
10314 "Specify community to reject\n"
10315 "Specify community to accept\n")
10316
10317DEFUN (ip_extcommunity_list_expanded,
10318 ip_extcommunity_list_expanded_cmd,
hassofee6e4e2005-02-02 16:29:31 +000010319 "ip extcommunity-list <100-500> (deny|permit) .LINE",
paul718e3742002-12-13 20:15:29 +000010320 IP_STR
10321 EXTCOMMUNITY_LIST_STR
10322 "Extended Community list number (expanded)\n"
10323 "Specify community to reject\n"
10324 "Specify community to accept\n"
10325 "An ordered list as a regular-expression\n")
10326{
10327 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
10328}
10329
10330DEFUN (ip_extcommunity_list_name_standard,
10331 ip_extcommunity_list_name_standard_cmd,
10332 "ip extcommunity-list standard WORD (deny|permit) .AA:NN",
10333 IP_STR
10334 EXTCOMMUNITY_LIST_STR
10335 "Specify standard extcommunity-list\n"
10336 "Extended Community list name\n"
10337 "Specify community to reject\n"
10338 "Specify community to accept\n"
10339 EXTCOMMUNITY_VAL_STR)
10340{
10341 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
10342}
10343
10344ALIAS (ip_extcommunity_list_name_standard,
10345 ip_extcommunity_list_name_standard2_cmd,
10346 "ip extcommunity-list standard WORD (deny|permit)",
10347 IP_STR
10348 EXTCOMMUNITY_LIST_STR
10349 "Specify standard extcommunity-list\n"
10350 "Extended Community list name\n"
10351 "Specify community to reject\n"
10352 "Specify community to accept\n")
10353
10354DEFUN (ip_extcommunity_list_name_expanded,
10355 ip_extcommunity_list_name_expanded_cmd,
10356 "ip extcommunity-list expanded WORD (deny|permit) .LINE",
10357 IP_STR
10358 EXTCOMMUNITY_LIST_STR
10359 "Specify expanded extcommunity-list\n"
10360 "Extended Community list name\n"
10361 "Specify community to reject\n"
10362 "Specify community to accept\n"
10363 "An ordered list as a regular-expression\n")
10364{
10365 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
10366}
10367
hassofee6e4e2005-02-02 16:29:31 +000010368DEFUN (no_ip_extcommunity_list_standard_all,
10369 no_ip_extcommunity_list_standard_all_cmd,
10370 "no ip extcommunity-list <1-99>",
paul718e3742002-12-13 20:15:29 +000010371 NO_STR
10372 IP_STR
10373 EXTCOMMUNITY_LIST_STR
hassofee6e4e2005-02-02 16:29:31 +000010374 "Extended Community list number (standard)\n")
paul718e3742002-12-13 20:15:29 +000010375{
hassofee6e4e2005-02-02 16:29:31 +000010376 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
paul718e3742002-12-13 20:15:29 +000010377}
10378
hassofee6e4e2005-02-02 16:29:31 +000010379DEFUN (no_ip_extcommunity_list_expanded_all,
10380 no_ip_extcommunity_list_expanded_all_cmd,
10381 "no ip extcommunity-list <100-500>",
10382 NO_STR
10383 IP_STR
10384 EXTCOMMUNITY_LIST_STR
10385 "Extended Community list number (expanded)\n")
10386{
10387 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
10388}
10389
10390DEFUN (no_ip_extcommunity_list_name_standard_all,
10391 no_ip_extcommunity_list_name_standard_all_cmd,
10392 "no ip extcommunity-list standard WORD",
paul718e3742002-12-13 20:15:29 +000010393 NO_STR
10394 IP_STR
10395 EXTCOMMUNITY_LIST_STR
10396 "Specify standard extcommunity-list\n"
hassofee6e4e2005-02-02 16:29:31 +000010397 "Extended Community list name\n")
10398{
10399 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
10400}
10401
10402DEFUN (no_ip_extcommunity_list_name_expanded_all,
10403 no_ip_extcommunity_list_name_expanded_all_cmd,
10404 "no ip extcommunity-list expanded WORD",
10405 NO_STR
10406 IP_STR
10407 EXTCOMMUNITY_LIST_STR
paul718e3742002-12-13 20:15:29 +000010408 "Specify expanded extcommunity-list\n"
10409 "Extended Community list name\n")
10410{
hassofee6e4e2005-02-02 16:29:31 +000010411 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
paul718e3742002-12-13 20:15:29 +000010412}
10413
10414DEFUN (no_ip_extcommunity_list_standard,
10415 no_ip_extcommunity_list_standard_cmd,
10416 "no ip extcommunity-list <1-99> (deny|permit) .AA:NN",
10417 NO_STR
10418 IP_STR
10419 EXTCOMMUNITY_LIST_STR
10420 "Extended Community list number (standard)\n"
10421 "Specify community to reject\n"
10422 "Specify community to accept\n"
10423 EXTCOMMUNITY_VAL_STR)
10424{
10425 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
10426}
10427
10428DEFUN (no_ip_extcommunity_list_expanded,
10429 no_ip_extcommunity_list_expanded_cmd,
hassofee6e4e2005-02-02 16:29:31 +000010430 "no ip extcommunity-list <100-500> (deny|permit) .LINE",
paul718e3742002-12-13 20:15:29 +000010431 NO_STR
10432 IP_STR
10433 EXTCOMMUNITY_LIST_STR
10434 "Extended Community list number (expanded)\n"
10435 "Specify community to reject\n"
10436 "Specify community to accept\n"
10437 "An ordered list as a regular-expression\n")
10438{
10439 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
10440}
10441
10442DEFUN (no_ip_extcommunity_list_name_standard,
10443 no_ip_extcommunity_list_name_standard_cmd,
10444 "no ip extcommunity-list standard WORD (deny|permit) .AA:NN",
10445 NO_STR
10446 IP_STR
10447 EXTCOMMUNITY_LIST_STR
10448 "Specify standard extcommunity-list\n"
10449 "Extended Community list name\n"
10450 "Specify community to reject\n"
10451 "Specify community to accept\n"
10452 EXTCOMMUNITY_VAL_STR)
10453{
10454 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
10455}
10456
10457DEFUN (no_ip_extcommunity_list_name_expanded,
10458 no_ip_extcommunity_list_name_expanded_cmd,
10459 "no ip extcommunity-list expanded WORD (deny|permit) .LINE",
10460 NO_STR
10461 IP_STR
10462 EXTCOMMUNITY_LIST_STR
10463 "Specify expanded extcommunity-list\n"
10464 "Community list name\n"
10465 "Specify community to reject\n"
10466 "Specify community to accept\n"
10467 "An ordered list as a regular-expression\n")
10468{
10469 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
10470}
10471
paul94f2b392005-06-28 12:44:16 +000010472static void
paul718e3742002-12-13 20:15:29 +000010473extcommunity_list_show (struct vty *vty, struct community_list *list)
10474{
10475 struct community_entry *entry;
10476
10477 for (entry = list->head; entry; entry = entry->next)
10478 {
10479 if (entry == list->head)
10480 {
10481 if (all_digit (list->name))
10482 vty_out (vty, "Extended community %s list %s%s",
10483 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
10484 "standard" : "(expanded) access",
10485 list->name, VTY_NEWLINE);
10486 else
10487 vty_out (vty, "Named extended community %s list %s%s",
10488 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
10489 "standard" : "expanded",
10490 list->name, VTY_NEWLINE);
10491 }
10492 if (entry->any)
10493 vty_out (vty, " %s%s",
10494 community_direct_str (entry->direct), VTY_NEWLINE);
10495 else
10496 vty_out (vty, " %s %s%s",
10497 community_direct_str (entry->direct),
10498 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
10499 entry->u.ecom->str : entry->config,
10500 VTY_NEWLINE);
10501 }
10502}
10503
10504DEFUN (show_ip_extcommunity_list,
10505 show_ip_extcommunity_list_cmd,
10506 "show ip extcommunity-list",
10507 SHOW_STR
10508 IP_STR
10509 "List extended-community list\n")
10510{
10511 struct community_list *list;
10512 struct community_list_master *cm;
10513
hassofee6e4e2005-02-02 16:29:31 +000010514 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010515 if (! cm)
10516 return CMD_SUCCESS;
10517
10518 for (list = cm->num.head; list; list = list->next)
10519 extcommunity_list_show (vty, list);
10520
10521 for (list = cm->str.head; list; list = list->next)
10522 extcommunity_list_show (vty, list);
10523
10524 return CMD_SUCCESS;
10525}
10526
10527DEFUN (show_ip_extcommunity_list_arg,
10528 show_ip_extcommunity_list_arg_cmd,
hassofee6e4e2005-02-02 16:29:31 +000010529 "show ip extcommunity-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000010530 SHOW_STR
10531 IP_STR
10532 "List extended-community list\n"
10533 "Extcommunity-list number\n"
10534 "Extcommunity-list name\n")
10535{
10536 struct community_list *list;
10537
hassofee6e4e2005-02-02 16:29:31 +000010538 list = community_list_lookup (bgp_clist, argv[0], EXTCOMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010539 if (! list)
10540 {
Denis Ovsienkodfc1d5c2010-12-08 18:51:37 +030010541 vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000010542 return CMD_WARNING;
10543 }
10544
10545 extcommunity_list_show (vty, list);
10546
10547 return CMD_SUCCESS;
10548}
10549
10550/* Return configuration string of community-list entry. */
paulfd79ac92004-10-13 05:06:08 +000010551static const char *
paul718e3742002-12-13 20:15:29 +000010552community_list_config_str (struct community_entry *entry)
10553{
paulfd79ac92004-10-13 05:06:08 +000010554 const char *str;
paul718e3742002-12-13 20:15:29 +000010555
10556 if (entry->any)
10557 str = "";
10558 else
10559 {
10560 if (entry->style == COMMUNITY_LIST_STANDARD)
10561 str = community_str (entry->u.com);
10562 else
10563 str = entry->config;
10564 }
10565 return str;
10566}
10567
10568/* Display community-list and extcommunity-list configuration. */
paul94f2b392005-06-28 12:44:16 +000010569static int
paul718e3742002-12-13 20:15:29 +000010570community_list_config_write (struct vty *vty)
10571{
10572 struct community_list *list;
10573 struct community_entry *entry;
10574 struct community_list_master *cm;
10575 int write = 0;
10576
10577 /* Community-list. */
hassofee6e4e2005-02-02 16:29:31 +000010578 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010579
10580 for (list = cm->num.head; list; list = list->next)
10581 for (entry = list->head; entry; entry = entry->next)
10582 {
hassofee6e4e2005-02-02 16:29:31 +000010583 vty_out (vty, "ip community-list %s %s %s%s",
10584 list->name, community_direct_str (entry->direct),
10585 community_list_config_str (entry),
10586 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000010587 write++;
10588 }
10589 for (list = cm->str.head; list; list = list->next)
10590 for (entry = list->head; entry; entry = entry->next)
10591 {
10592 vty_out (vty, "ip community-list %s %s %s %s%s",
10593 entry->style == COMMUNITY_LIST_STANDARD
10594 ? "standard" : "expanded",
10595 list->name, community_direct_str (entry->direct),
10596 community_list_config_str (entry),
10597 VTY_NEWLINE);
10598 write++;
10599 }
10600
10601 /* Extcommunity-list. */
hassofee6e4e2005-02-02 16:29:31 +000010602 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010603
10604 for (list = cm->num.head; list; list = list->next)
10605 for (entry = list->head; entry; entry = entry->next)
10606 {
hassofee6e4e2005-02-02 16:29:31 +000010607 vty_out (vty, "ip extcommunity-list %s %s %s%s",
10608 list->name, community_direct_str (entry->direct),
10609 community_list_config_str (entry), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000010610 write++;
10611 }
10612 for (list = cm->str.head; list; list = list->next)
10613 for (entry = list->head; entry; entry = entry->next)
10614 {
10615 vty_out (vty, "ip extcommunity-list %s %s %s %s%s",
10616 entry->style == EXTCOMMUNITY_LIST_STANDARD
10617 ? "standard" : "expanded",
10618 list->name, community_direct_str (entry->direct),
10619 community_list_config_str (entry), VTY_NEWLINE);
10620 write++;
10621 }
10622 return write;
10623}
10624
Stephen Hemminger7fc626d2008-12-01 11:10:34 -080010625static struct cmd_node community_list_node =
paul718e3742002-12-13 20:15:29 +000010626{
10627 COMMUNITY_LIST_NODE,
10628 "",
10629 1 /* Export to vtysh. */
10630};
10631
paul94f2b392005-06-28 12:44:16 +000010632static void
10633community_list_vty (void)
paul718e3742002-12-13 20:15:29 +000010634{
10635 install_node (&community_list_node, community_list_config_write);
10636
10637 /* Community-list. */
paul718e3742002-12-13 20:15:29 +000010638 install_element (CONFIG_NODE, &ip_community_list_standard_cmd);
10639 install_element (CONFIG_NODE, &ip_community_list_standard2_cmd);
10640 install_element (CONFIG_NODE, &ip_community_list_expanded_cmd);
10641 install_element (CONFIG_NODE, &ip_community_list_name_standard_cmd);
10642 install_element (CONFIG_NODE, &ip_community_list_name_standard2_cmd);
10643 install_element (CONFIG_NODE, &ip_community_list_name_expanded_cmd);
hassofee6e4e2005-02-02 16:29:31 +000010644 install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd);
10645 install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd);
10646 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_all_cmd);
10647 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_all_cmd);
paul718e3742002-12-13 20:15:29 +000010648 install_element (CONFIG_NODE, &no_ip_community_list_standard_cmd);
10649 install_element (CONFIG_NODE, &no_ip_community_list_expanded_cmd);
10650 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_cmd);
10651 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_cmd);
10652 install_element (VIEW_NODE, &show_ip_community_list_cmd);
10653 install_element (VIEW_NODE, &show_ip_community_list_arg_cmd);
10654 install_element (ENABLE_NODE, &show_ip_community_list_cmd);
10655 install_element (ENABLE_NODE, &show_ip_community_list_arg_cmd);
10656
10657 /* Extcommunity-list. */
10658 install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd);
10659 install_element (CONFIG_NODE, &ip_extcommunity_list_standard2_cmd);
10660 install_element (CONFIG_NODE, &ip_extcommunity_list_expanded_cmd);
10661 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard_cmd);
10662 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard2_cmd);
10663 install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd);
hassofee6e4e2005-02-02 16:29:31 +000010664 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd);
10665 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd);
10666 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_all_cmd);
10667 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_all_cmd);
paul718e3742002-12-13 20:15:29 +000010668 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_cmd);
10669 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_cmd);
10670 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_cmd);
10671 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_cmd);
10672 install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd);
10673 install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd);
10674 install_element (ENABLE_NODE, &show_ip_extcommunity_list_cmd);
10675 install_element (ENABLE_NODE, &show_ip_extcommunity_list_arg_cmd);
10676}