blob: 2c44efc2285e15775e813fe111c4215a0754744b [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"
Josh Bailey165b5ff2011-07-20 20:43:22 -070051#include "bgpd/bgp_mpath.h"
paul718e3742002-12-13 20:15:29 +000052
hasso18a6dce2004-10-03 18:18:34 +000053extern struct in_addr router_id_zebra;
54
paul718e3742002-12-13 20:15:29 +000055/* Utility function to get address family from current node. */
56afi_t
57bgp_node_afi (struct vty *vty)
58{
paul25ffbdc2005-08-22 22:42:08 +000059 if (vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE)
paul718e3742002-12-13 20:15:29 +000060 return AFI_IP6;
61 return AFI_IP;
62}
63
64/* Utility function to get subsequent address family from current
65 node. */
66safi_t
67bgp_node_safi (struct vty *vty)
68{
69 if (vty->node == BGP_VPNV4_NODE)
70 return SAFI_MPLS_VPN;
paul25ffbdc2005-08-22 22:42:08 +000071 if (vty->node == BGP_IPV4M_NODE || vty->node == BGP_IPV6M_NODE)
paul718e3742002-12-13 20:15:29 +000072 return SAFI_MULTICAST;
73 return SAFI_UNICAST;
74}
75
paul94f2b392005-06-28 12:44:16 +000076static int
paul718e3742002-12-13 20:15:29 +000077peer_address_self_check (union sockunion *su)
78{
79 struct interface *ifp = NULL;
80
81 if (su->sa.sa_family == AF_INET)
82 ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr);
83#ifdef HAVE_IPV6
84 else if (su->sa.sa_family == AF_INET6)
85 ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr);
86#endif /* HAVE IPV6 */
87
88 if (ifp)
89 return 1;
90
91 return 0;
92}
93
94/* Utility function for looking up peer from VTY. */
paul94f2b392005-06-28 12:44:16 +000095static struct peer *
paulfd79ac92004-10-13 05:06:08 +000096peer_lookup_vty (struct vty *vty, const char *ip_str)
paul718e3742002-12-13 20:15:29 +000097{
98 int ret;
99 struct bgp *bgp;
100 union sockunion su;
101 struct peer *peer;
102
103 bgp = vty->index;
104
105 ret = str2sockunion (ip_str, &su);
106 if (ret < 0)
107 {
108 vty_out (vty, "%% Malformed address: %s%s", ip_str, VTY_NEWLINE);
109 return NULL;
110 }
111
112 peer = peer_lookup (bgp, &su);
113 if (! peer)
114 {
115 vty_out (vty, "%% Specify remote-as or peer-group commands first%s", VTY_NEWLINE);
116 return NULL;
117 }
118 return peer;
119}
120
121/* Utility function for looking up peer or peer group. */
paul94f2b392005-06-28 12:44:16 +0000122static struct peer *
paulfd79ac92004-10-13 05:06:08 +0000123peer_and_group_lookup_vty (struct vty *vty, const char *peer_str)
paul718e3742002-12-13 20:15:29 +0000124{
125 int ret;
126 struct bgp *bgp;
127 union sockunion su;
128 struct peer *peer;
129 struct peer_group *group;
130
131 bgp = vty->index;
132
133 ret = str2sockunion (peer_str, &su);
134 if (ret == 0)
135 {
136 peer = peer_lookup (bgp, &su);
137 if (peer)
138 return peer;
139 }
140 else
141 {
142 group = peer_group_lookup (bgp, peer_str);
143 if (group)
144 return group->conf;
145 }
146
147 vty_out (vty, "%% Specify remote-as or peer-group commands first%s",
148 VTY_NEWLINE);
149
150 return NULL;
151}
152
paul94f2b392005-06-28 12:44:16 +0000153static int
paul718e3742002-12-13 20:15:29 +0000154bgp_vty_return (struct vty *vty, int ret)
155{
paulfd79ac92004-10-13 05:06:08 +0000156 const char *str = NULL;
paul718e3742002-12-13 20:15:29 +0000157
158 switch (ret)
159 {
160 case BGP_ERR_INVALID_VALUE:
161 str = "Invalid value";
162 break;
163 case BGP_ERR_INVALID_FLAG:
164 str = "Invalid flag";
165 break;
166 case BGP_ERR_PEER_INACTIVE:
167 str = "Activate the neighbor for the address family first";
168 break;
169 case BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER:
170 str = "Invalid command for a peer-group member";
171 break;
172 case BGP_ERR_PEER_GROUP_SHUTDOWN:
173 str = "Peer-group has been shutdown. Activate the peer-group first";
174 break;
175 case BGP_ERR_PEER_GROUP_HAS_THE_FLAG:
176 str = "This peer is a peer-group member. Please change peer-group configuration";
177 break;
178 case BGP_ERR_PEER_FLAG_CONFLICT:
179 str = "Can't set override-capability and strict-capability-match at the same time";
180 break;
181 case BGP_ERR_PEER_GROUP_MEMBER_EXISTS:
182 str = "No activate for peergroup can be given only if peer-group has no members";
183 break;
184 case BGP_ERR_PEER_BELONGS_TO_GROUP:
185 str = "No activate for an individual peer-group member is invalid";
186 break;
187 case BGP_ERR_PEER_GROUP_AF_UNCONFIGURED:
188 str = "Activate the peer-group for the address family first";
189 break;
190 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS:
191 str = "Specify remote-as or peer-group remote AS first";
192 break;
193 case BGP_ERR_PEER_GROUP_CANT_CHANGE:
194 str = "Cannot change the peer-group. Deconfigure first";
195 break;
196 case BGP_ERR_PEER_GROUP_MISMATCH:
197 str = "Cannot have different peer-group for the neighbor";
198 break;
199 case BGP_ERR_PEER_FILTER_CONFLICT:
200 str = "Prefix/distribute list can not co-exist";
201 break;
202 case BGP_ERR_NOT_INTERNAL_PEER:
203 str = "Invalid command. Not an internal neighbor";
204 break;
205 case BGP_ERR_REMOVE_PRIVATE_AS:
206 str = "Private AS cannot be removed for IBGP peers";
207 break;
208 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP:
209 str = "Local-AS allowed only for EBGP peers";
210 break;
211 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS:
212 str = "Cannot have local-as same as BGP AS number";
213 break;
Paul Jakma0df7c912008-07-21 21:02:49 +0000214 case BGP_ERR_TCPSIG_FAILED:
215 str = "Error while applying TCP-Sig to session(s)";
216 break;
Nick Hilliardfa411a22011-03-23 15:33:17 +0000217 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK:
218 str = "ebgp-multihop and ttl-security cannot be configured together";
219 break;
Stephen Hemmingerf5a48272011-03-24 17:30:21 +0000220 case BGP_ERR_NO_IBGP_WITH_TTLHACK:
221 str = "ttl-security only allowed for EBGP peers";
222 break;
paul718e3742002-12-13 20:15:29 +0000223 }
224 if (str)
225 {
226 vty_out (vty, "%% %s%s", str, VTY_NEWLINE);
227 return CMD_WARNING;
228 }
229 return CMD_SUCCESS;
230}
231
232/* BGP global configuration. */
233
234DEFUN (bgp_multiple_instance_func,
235 bgp_multiple_instance_cmd,
236 "bgp multiple-instance",
237 BGP_STR
238 "Enable bgp multiple instance\n")
239{
240 bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE);
241 return CMD_SUCCESS;
242}
243
244DEFUN (no_bgp_multiple_instance,
245 no_bgp_multiple_instance_cmd,
246 "no bgp multiple-instance",
247 NO_STR
248 BGP_STR
249 "BGP multiple instance\n")
250{
251 int ret;
252
253 ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE);
254 if (ret < 0)
255 {
256 vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE);
257 return CMD_WARNING;
258 }
259 return CMD_SUCCESS;
260}
261
262DEFUN (bgp_config_type,
263 bgp_config_type_cmd,
264 "bgp config-type (cisco|zebra)",
265 BGP_STR
266 "Configuration type\n"
267 "cisco\n"
268 "zebra\n")
269{
270 if (strncmp (argv[0], "c", 1) == 0)
271 bgp_option_set (BGP_OPT_CONFIG_CISCO);
272 else
273 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
274
275 return CMD_SUCCESS;
276}
277
278DEFUN (no_bgp_config_type,
279 no_bgp_config_type_cmd,
280 "no bgp config-type",
281 NO_STR
282 BGP_STR
283 "Display configuration type\n")
284{
285 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
286 return CMD_SUCCESS;
287}
288
289DEFUN (no_synchronization,
290 no_synchronization_cmd,
291 "no synchronization",
292 NO_STR
293 "Perform IGP synchronization\n")
294{
295 return CMD_SUCCESS;
296}
297
298DEFUN (no_auto_summary,
299 no_auto_summary_cmd,
300 "no auto-summary",
301 NO_STR
302 "Enable automatic network number summarization\n")
303{
304 return CMD_SUCCESS;
305}
hasso3d515fd2005-02-01 21:30:04 +0000306
307DEFUN_DEPRECATED (neighbor_version,
308 neighbor_version_cmd,
309 NEIGHBOR_CMD "version (4|4-)",
310 NEIGHBOR_STR
311 NEIGHBOR_ADDR_STR
312 "Set the BGP version to match a neighbor\n"
313 "Neighbor's BGP version\n")
314{
315 return CMD_SUCCESS;
316}
paul718e3742002-12-13 20:15:29 +0000317
318/* "router bgp" commands. */
319DEFUN (router_bgp,
320 router_bgp_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000321 "router bgp " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +0000322 ROUTER_STR
323 BGP_STR
324 AS_STR)
325{
326 int ret;
327 as_t as;
328 struct bgp *bgp;
paulfd79ac92004-10-13 05:06:08 +0000329 const char *name = NULL;
paul718e3742002-12-13 20:15:29 +0000330
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000331 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
paul718e3742002-12-13 20:15:29 +0000332
333 if (argc == 2)
334 name = argv[1];
335
336 ret = bgp_get (&bgp, &as, name);
337 switch (ret)
338 {
339 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET:
340 vty_out (vty, "Please specify 'bgp multiple-instance' first%s",
341 VTY_NEWLINE);
342 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +0000343 case BGP_ERR_AS_MISMATCH:
Denis Ovsienkoaea339f2009-04-30 17:16:22 +0400344 vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +0000345 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +0000346 case BGP_ERR_INSTANCE_MISMATCH:
347 vty_out (vty, "BGP view name and AS number mismatch%s", VTY_NEWLINE);
Denis Ovsienkoaea339f2009-04-30 17:16:22 +0400348 vty_out (vty, "BGP instance is already running; AS is %u%s",
paul718e3742002-12-13 20:15:29 +0000349 as, VTY_NEWLINE);
350 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +0000351 }
352
353 vty->node = BGP_NODE;
354 vty->index = bgp;
355
356 return CMD_SUCCESS;
357}
358
359ALIAS (router_bgp,
360 router_bgp_view_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000361 "router bgp " CMD_AS_RANGE " view WORD",
paul718e3742002-12-13 20:15:29 +0000362 ROUTER_STR
363 BGP_STR
364 AS_STR
365 "BGP view\n"
366 "view name\n")
367
368/* "no router bgp" commands. */
369DEFUN (no_router_bgp,
370 no_router_bgp_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000371 "no router bgp " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +0000372 NO_STR
373 ROUTER_STR
374 BGP_STR
375 AS_STR)
376{
377 as_t as;
378 struct bgp *bgp;
paulfd79ac92004-10-13 05:06:08 +0000379 const char *name = NULL;
paul718e3742002-12-13 20:15:29 +0000380
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000381 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
paul718e3742002-12-13 20:15:29 +0000382
383 if (argc == 2)
384 name = argv[1];
385
386 /* Lookup bgp structure. */
387 bgp = bgp_lookup (as, name);
388 if (! bgp)
389 {
390 vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE);
391 return CMD_WARNING;
392 }
393
394 bgp_delete (bgp);
395
396 return CMD_SUCCESS;
397}
398
399ALIAS (no_router_bgp,
400 no_router_bgp_view_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000401 "no router bgp " CMD_AS_RANGE " view WORD",
paul718e3742002-12-13 20:15:29 +0000402 NO_STR
403 ROUTER_STR
404 BGP_STR
405 AS_STR
406 "BGP view\n"
407 "view name\n")
408
409/* BGP router-id. */
410
411DEFUN (bgp_router_id,
412 bgp_router_id_cmd,
413 "bgp router-id A.B.C.D",
414 BGP_STR
415 "Override configured router identifier\n"
416 "Manually configured router identifier\n")
417{
418 int ret;
419 struct in_addr id;
420 struct bgp *bgp;
421
422 bgp = vty->index;
423
424 ret = inet_aton (argv[0], &id);
425 if (! ret)
426 {
427 vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE);
428 return CMD_WARNING;
429 }
430
hasso18a6dce2004-10-03 18:18:34 +0000431 bgp->router_id_static = id;
paul718e3742002-12-13 20:15:29 +0000432 bgp_router_id_set (bgp, &id);
433
434 return CMD_SUCCESS;
435}
436
437DEFUN (no_bgp_router_id,
438 no_bgp_router_id_cmd,
439 "no bgp router-id",
440 NO_STR
441 BGP_STR
442 "Override configured router identifier\n")
443{
444 int ret;
445 struct in_addr id;
446 struct bgp *bgp;
447
448 bgp = vty->index;
449
450 if (argc == 1)
451 {
452 ret = inet_aton (argv[0], &id);
453 if (! ret)
454 {
455 vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE);
456 return CMD_WARNING;
457 }
458
hasso18a6dce2004-10-03 18:18:34 +0000459 if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id))
paul718e3742002-12-13 20:15:29 +0000460 {
461 vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE);
462 return CMD_WARNING;
463 }
464 }
465
hasso18a6dce2004-10-03 18:18:34 +0000466 bgp->router_id_static.s_addr = 0;
467 bgp_router_id_set (bgp, &router_id_zebra);
paul718e3742002-12-13 20:15:29 +0000468
469 return CMD_SUCCESS;
470}
471
472ALIAS (no_bgp_router_id,
473 no_bgp_router_id_val_cmd,
474 "no bgp router-id A.B.C.D",
475 NO_STR
476 BGP_STR
477 "Override configured router identifier\n"
478 "Manually configured router identifier\n")
479
480/* BGP Cluster ID. */
481
482DEFUN (bgp_cluster_id,
483 bgp_cluster_id_cmd,
484 "bgp cluster-id A.B.C.D",
485 BGP_STR
486 "Configure Route-Reflector Cluster-id\n"
487 "Route-Reflector Cluster-id in IP address format\n")
488{
489 int ret;
490 struct bgp *bgp;
491 struct in_addr cluster;
492
493 bgp = vty->index;
494
495 ret = inet_aton (argv[0], &cluster);
496 if (! ret)
497 {
498 vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
499 return CMD_WARNING;
500 }
501
502 bgp_cluster_id_set (bgp, &cluster);
503
504 return CMD_SUCCESS;
505}
506
507ALIAS (bgp_cluster_id,
508 bgp_cluster_id32_cmd,
509 "bgp cluster-id <1-4294967295>",
510 BGP_STR
511 "Configure Route-Reflector Cluster-id\n"
512 "Route-Reflector Cluster-id as 32 bit quantity\n")
513
514DEFUN (no_bgp_cluster_id,
515 no_bgp_cluster_id_cmd,
516 "no bgp cluster-id",
517 NO_STR
518 BGP_STR
519 "Configure Route-Reflector Cluster-id\n")
520{
521 int ret;
522 struct bgp *bgp;
523 struct in_addr cluster;
524
525 bgp = vty->index;
526
527 if (argc == 1)
528 {
529 ret = inet_aton (argv[0], &cluster);
530 if (! ret)
531 {
532 vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
533 return CMD_WARNING;
534 }
535 }
536
537 bgp_cluster_id_unset (bgp);
538
539 return CMD_SUCCESS;
540}
541
542ALIAS (no_bgp_cluster_id,
543 no_bgp_cluster_id_arg_cmd,
544 "no bgp cluster-id A.B.C.D",
545 NO_STR
546 BGP_STR
547 "Configure Route-Reflector Cluster-id\n"
548 "Route-Reflector Cluster-id in IP address format\n")
549
550DEFUN (bgp_confederation_identifier,
551 bgp_confederation_identifier_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000552 "bgp confederation identifier " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +0000553 "BGP specific commands\n"
554 "AS confederation parameters\n"
555 "AS number\n"
556 "Set routing domain confederation AS\n")
557{
558 struct bgp *bgp;
559 as_t as;
560
561 bgp = vty->index;
562
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000563 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
paul718e3742002-12-13 20:15:29 +0000564
565 bgp_confederation_id_set (bgp, as);
566
567 return CMD_SUCCESS;
568}
569
570DEFUN (no_bgp_confederation_identifier,
571 no_bgp_confederation_identifier_cmd,
572 "no bgp confederation identifier",
573 NO_STR
574 "BGP specific commands\n"
575 "AS confederation parameters\n"
576 "AS number\n")
577{
578 struct bgp *bgp;
579 as_t as;
580
581 bgp = vty->index;
582
583 if (argc == 1)
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000584 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
paul718e3742002-12-13 20:15:29 +0000585
586 bgp_confederation_id_unset (bgp);
587
588 return CMD_SUCCESS;
589}
590
591ALIAS (no_bgp_confederation_identifier,
592 no_bgp_confederation_identifier_arg_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000593 "no bgp confederation identifier " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +0000594 NO_STR
595 "BGP specific commands\n"
596 "AS confederation parameters\n"
597 "AS number\n"
598 "Set routing domain confederation AS\n")
599
600DEFUN (bgp_confederation_peers,
601 bgp_confederation_peers_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000602 "bgp confederation peers ." CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +0000603 "BGP specific commands\n"
604 "AS confederation parameters\n"
605 "Peer ASs in BGP confederation\n"
606 AS_STR)
607{
608 struct bgp *bgp;
609 as_t as;
610 int i;
611
612 bgp = vty->index;
613
614 for (i = 0; i < argc; i++)
615 {
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000616 VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX);
paul718e3742002-12-13 20:15:29 +0000617
618 if (bgp->as == as)
619 {
620 vty_out (vty, "%% Local member-AS not allowed in confed peer list%s",
621 VTY_NEWLINE);
622 continue;
623 }
624
625 bgp_confederation_peers_add (bgp, as);
626 }
627 return CMD_SUCCESS;
628}
629
630DEFUN (no_bgp_confederation_peers,
631 no_bgp_confederation_peers_cmd,
Paul Jakma320da872008-07-02 13:40:33 +0000632 "no bgp confederation peers ." CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +0000633 NO_STR
634 "BGP specific commands\n"
635 "AS confederation parameters\n"
636 "Peer ASs in BGP confederation\n"
637 AS_STR)
638{
639 struct bgp *bgp;
640 as_t as;
641 int i;
642
643 bgp = vty->index;
644
645 for (i = 0; i < argc; i++)
646 {
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000647 VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX);
648
paul718e3742002-12-13 20:15:29 +0000649 bgp_confederation_peers_remove (bgp, as);
650 }
651 return CMD_SUCCESS;
652}
653
Josh Bailey165b5ff2011-07-20 20:43:22 -0700654/* Maximum-paths configuration */
655DEFUN (bgp_maxpaths,
656 bgp_maxpaths_cmd,
657 "maximum-paths <1-255>",
658 "Forward packets over multiple paths\n"
659 "Number of paths\n")
660{
661 struct bgp *bgp;
662 u_int16_t maxpaths;
663 int ret;
664
665 bgp = vty->index;
666
667 VTY_GET_INTEGER_RANGE ("maximum-paths", maxpaths, argv[0], 1, 255);
668
669 ret = bgp_maximum_paths_set (bgp, bgp_node_afi (vty), bgp_node_safi(vty),
670 BGP_PEER_EBGP, maxpaths);
671 if (ret < 0)
672 {
673 vty_out (vty,
674 "%% Failed to set maximum-paths %u for afi %u, safi %u%s",
675 maxpaths, bgp_node_afi (vty), bgp_node_safi(vty), VTY_NEWLINE);
676 return CMD_WARNING;
677 }
678
679 return CMD_SUCCESS;
680}
681
682DEFUN (bgp_maxpaths_ibgp,
683 bgp_maxpaths_ibgp_cmd,
684 "maximum-paths ibgp <1-255>",
685 "Forward packets over multiple paths\n"
686 "iBGP-multipath\n"
687 "Number of paths\n")
688{
689 struct bgp *bgp;
690 u_int16_t maxpaths;
691 int ret;
692
693 bgp = vty->index;
694
695 VTY_GET_INTEGER_RANGE ("maximum-paths", maxpaths, argv[0], 1, 255);
696
697 ret = bgp_maximum_paths_set (bgp, bgp_node_afi (vty), bgp_node_safi(vty),
698 BGP_PEER_IBGP, maxpaths);
699 if (ret < 0)
700 {
701 vty_out (vty,
702 "%% Failed to set maximum-paths ibgp %u for afi %u, safi %u%s",
703 maxpaths, bgp_node_afi (vty), bgp_node_safi(vty), VTY_NEWLINE);
704 return CMD_WARNING;
705 }
706
707 return CMD_SUCCESS;
708}
709
710DEFUN (no_bgp_maxpaths,
711 no_bgp_maxpaths_cmd,
712 "no maximum-paths",
713 NO_STR
714 "Forward packets over multiple paths\n"
715 "Number of paths\n")
716{
717 struct bgp *bgp;
718 int ret;
719
720 bgp = vty->index;
721
722 ret = bgp_maximum_paths_unset (bgp, bgp_node_afi (vty), bgp_node_safi(vty),
723 BGP_PEER_EBGP);
724 if (ret < 0)
725 {
726 vty_out (vty,
727 "%% Failed to unset maximum-paths for afi %u, safi %u%s",
728 bgp_node_afi (vty), bgp_node_safi(vty), VTY_NEWLINE);
729 return CMD_WARNING;
730 }
731
732 return CMD_SUCCESS;
733}
734
735ALIAS (no_bgp_maxpaths,
736 no_bgp_maxpaths_arg_cmd,
737 "no maximum-paths <1-255>",
738 NO_STR
739 "Forward packets over multiple paths\n"
740 "Number of paths\n")
741
742DEFUN (no_bgp_maxpaths_ibgp,
743 no_bgp_maxpaths_ibgp_cmd,
744 "no maximum-paths ibgp",
745 NO_STR
746 "Forward packets over multiple paths\n"
747 "iBGP-multipath\n"
748 "Number of paths\n")
749{
750 struct bgp *bgp;
751 int ret;
752
753 bgp = vty->index;
754
755 ret = bgp_maximum_paths_unset (bgp, bgp_node_afi (vty), bgp_node_safi(vty),
756 BGP_PEER_IBGP);
757 if (ret < 0)
758 {
759 vty_out (vty,
760 "%% Failed to unset maximum-paths ibgp for afi %u, safi %u%s",
761 bgp_node_afi (vty), bgp_node_safi(vty), VTY_NEWLINE);
762 return CMD_WARNING;
763 }
764
765 return CMD_SUCCESS;
766}
767
768ALIAS (no_bgp_maxpaths_ibgp,
769 no_bgp_maxpaths_ibgp_arg_cmd,
770 "no maximum-paths ibgp <1-255>",
771 NO_STR
772 "Forward packets over multiple paths\n"
773 "iBGP-multipath\n"
774 "Number of paths\n")
775
776int
777bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi,
778 safi_t safi, int *write)
779{
780 if (bgp->maxpaths[afi][safi].maxpaths_ebgp != BGP_DEFAULT_MAXPATHS)
781 {
782 bgp_config_write_family_header (vty, afi, safi, write);
783 vty_out (vty, " maximum-paths %d%s",
784 bgp->maxpaths[afi][safi].maxpaths_ebgp, VTY_NEWLINE);
785 }
786
787 if (bgp->maxpaths[afi][safi].maxpaths_ibgp != BGP_DEFAULT_MAXPATHS)
788 {
789 bgp_config_write_family_header (vty, afi, safi, write);
790 vty_out (vty, " maximum-paths ibgp %d%s",
791 bgp->maxpaths[afi][safi].maxpaths_ibgp, VTY_NEWLINE);
792 }
793
794 return 0;
795}
796
paul718e3742002-12-13 20:15:29 +0000797/* BGP timers. */
798
799DEFUN (bgp_timers,
800 bgp_timers_cmd,
801 "timers bgp <0-65535> <0-65535>",
802 "Adjust routing timers\n"
803 "BGP timers\n"
804 "Keepalive interval\n"
805 "Holdtime\n")
806{
807 struct bgp *bgp;
808 unsigned long keepalive = 0;
809 unsigned long holdtime = 0;
810
811 bgp = vty->index;
812
813 VTY_GET_INTEGER ("keepalive", keepalive, argv[0]);
814 VTY_GET_INTEGER ("holdtime", holdtime, argv[1]);
815
816 /* Holdtime value check. */
817 if (holdtime < 3 && holdtime != 0)
818 {
819 vty_out (vty, "%% hold time value must be either 0 or greater than 3%s",
820 VTY_NEWLINE);
821 return CMD_WARNING;
822 }
823
824 bgp_timers_set (bgp, keepalive, holdtime);
825
826 return CMD_SUCCESS;
827}
828
829DEFUN (no_bgp_timers,
830 no_bgp_timers_cmd,
831 "no timers bgp",
832 NO_STR
833 "Adjust routing timers\n"
834 "BGP timers\n")
835{
836 struct bgp *bgp;
837
838 bgp = vty->index;
839 bgp_timers_unset (bgp);
840
841 return CMD_SUCCESS;
842}
843
844ALIAS (no_bgp_timers,
845 no_bgp_timers_arg_cmd,
846 "no timers bgp <0-65535> <0-65535>",
847 NO_STR
848 "Adjust routing timers\n"
849 "BGP timers\n"
850 "Keepalive interval\n"
851 "Holdtime\n")
852
853DEFUN (bgp_client_to_client_reflection,
854 bgp_client_to_client_reflection_cmd,
855 "bgp client-to-client reflection",
856 "BGP specific commands\n"
857 "Configure client to client route reflection\n"
858 "reflection of routes allowed\n")
859{
860 struct bgp *bgp;
861
862 bgp = vty->index;
863 bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
864 return CMD_SUCCESS;
865}
866
867DEFUN (no_bgp_client_to_client_reflection,
868 no_bgp_client_to_client_reflection_cmd,
869 "no bgp client-to-client reflection",
870 NO_STR
871 "BGP specific commands\n"
872 "Configure client to client route reflection\n"
873 "reflection of routes allowed\n")
874{
875 struct bgp *bgp;
876
877 bgp = vty->index;
878 bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
879 return CMD_SUCCESS;
880}
881
882/* "bgp always-compare-med" configuration. */
883DEFUN (bgp_always_compare_med,
884 bgp_always_compare_med_cmd,
885 "bgp always-compare-med",
886 "BGP specific commands\n"
887 "Allow comparing MED from different neighbors\n")
888{
889 struct bgp *bgp;
890
891 bgp = vty->index;
892 bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
893 return CMD_SUCCESS;
894}
895
896DEFUN (no_bgp_always_compare_med,
897 no_bgp_always_compare_med_cmd,
898 "no bgp always-compare-med",
899 NO_STR
900 "BGP specific commands\n"
901 "Allow comparing MED from different neighbors\n")
902{
903 struct bgp *bgp;
904
905 bgp = vty->index;
906 bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
907 return CMD_SUCCESS;
908}
909
910/* "bgp deterministic-med" configuration. */
911DEFUN (bgp_deterministic_med,
912 bgp_deterministic_med_cmd,
913 "bgp deterministic-med",
914 "BGP specific commands\n"
915 "Pick the best-MED path among paths advertised from the neighboring AS\n")
916{
917 struct bgp *bgp;
918
919 bgp = vty->index;
920 bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED);
921 return CMD_SUCCESS;
922}
923
924DEFUN (no_bgp_deterministic_med,
925 no_bgp_deterministic_med_cmd,
926 "no bgp deterministic-med",
927 NO_STR
928 "BGP specific commands\n"
929 "Pick the best-MED path among paths advertised from the neighboring AS\n")
930{
931 struct bgp *bgp;
932
933 bgp = vty->index;
934 bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED);
935 return CMD_SUCCESS;
936}
hasso538621f2004-05-21 09:31:30 +0000937
938/* "bgp graceful-restart" configuration. */
939DEFUN (bgp_graceful_restart,
940 bgp_graceful_restart_cmd,
941 "bgp graceful-restart",
942 "BGP specific commands\n"
943 "Graceful restart capability parameters\n")
944{
945 struct bgp *bgp;
946
947 bgp = vty->index;
948 bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART);
949 return CMD_SUCCESS;
950}
951
952DEFUN (no_bgp_graceful_restart,
953 no_bgp_graceful_restart_cmd,
954 "no bgp graceful-restart",
955 NO_STR
956 "BGP specific commands\n"
957 "Graceful restart capability parameters\n")
958{
959 struct bgp *bgp;
960
961 bgp = vty->index;
962 bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART);
963 return CMD_SUCCESS;
964}
965
hasso93406d82005-02-02 14:40:33 +0000966DEFUN (bgp_graceful_restart_stalepath_time,
967 bgp_graceful_restart_stalepath_time_cmd,
968 "bgp graceful-restart stalepath-time <1-3600>",
969 "BGP specific commands\n"
970 "Graceful restart capability parameters\n"
971 "Set the max time to hold onto restarting peer's stale paths\n"
972 "Delay value (seconds)\n")
973{
974 struct bgp *bgp;
975 u_int32_t stalepath;
976
977 bgp = vty->index;
978 if (! bgp)
979 return CMD_WARNING;
980
981 VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[0], 1, 3600);
982 bgp->stalepath_time = stalepath;
983 return CMD_SUCCESS;
984}
985
986DEFUN (no_bgp_graceful_restart_stalepath_time,
987 no_bgp_graceful_restart_stalepath_time_cmd,
988 "no bgp graceful-restart stalepath-time",
989 NO_STR
990 "BGP specific commands\n"
991 "Graceful restart capability parameters\n"
992 "Set the max time to hold onto restarting peer's stale paths\n")
993{
994 struct bgp *bgp;
995
996 bgp = vty->index;
997 if (! bgp)
998 return CMD_WARNING;
999
1000 bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME;
1001 return CMD_SUCCESS;
1002}
1003
1004ALIAS (no_bgp_graceful_restart_stalepath_time,
1005 no_bgp_graceful_restart_stalepath_time_val_cmd,
1006 "no bgp graceful-restart stalepath-time <1-3600>",
1007 NO_STR
1008 "BGP specific commands\n"
1009 "Graceful restart capability parameters\n"
1010 "Set the max time to hold onto restarting peer's stale paths\n"
1011 "Delay value (seconds)\n")
1012
paul718e3742002-12-13 20:15:29 +00001013/* "bgp fast-external-failover" configuration. */
1014DEFUN (bgp_fast_external_failover,
1015 bgp_fast_external_failover_cmd,
1016 "bgp fast-external-failover",
1017 BGP_STR
1018 "Immediately reset session if a link to a directly connected external peer goes down\n")
1019{
1020 struct bgp *bgp;
1021
1022 bgp = vty->index;
1023 bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
1024 return CMD_SUCCESS;
1025}
1026
1027DEFUN (no_bgp_fast_external_failover,
1028 no_bgp_fast_external_failover_cmd,
1029 "no bgp fast-external-failover",
1030 NO_STR
1031 BGP_STR
1032 "Immediately reset session if a link to a directly connected external peer goes down\n")
1033{
1034 struct bgp *bgp;
1035
1036 bgp = vty->index;
1037 bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
1038 return CMD_SUCCESS;
1039}
1040
1041/* "bgp enforce-first-as" configuration. */
1042DEFUN (bgp_enforce_first_as,
1043 bgp_enforce_first_as_cmd,
1044 "bgp enforce-first-as",
1045 BGP_STR
1046 "Enforce the first AS for EBGP routes\n")
1047{
1048 struct bgp *bgp;
1049
1050 bgp = vty->index;
1051 bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
1052 return CMD_SUCCESS;
1053}
1054
1055DEFUN (no_bgp_enforce_first_as,
1056 no_bgp_enforce_first_as_cmd,
1057 "no bgp enforce-first-as",
1058 NO_STR
1059 BGP_STR
1060 "Enforce the first AS for EBGP routes\n")
1061{
1062 struct bgp *bgp;
1063
1064 bgp = vty->index;
1065 bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
1066 return CMD_SUCCESS;
1067}
1068
1069/* "bgp bestpath compare-routerid" configuration. */
1070DEFUN (bgp_bestpath_compare_router_id,
1071 bgp_bestpath_compare_router_id_cmd,
1072 "bgp bestpath compare-routerid",
1073 "BGP specific commands\n"
1074 "Change the default bestpath selection\n"
1075 "Compare router-id for identical EBGP paths\n")
1076{
1077 struct bgp *bgp;
1078
1079 bgp = vty->index;
1080 bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
1081 return CMD_SUCCESS;
1082}
1083
1084DEFUN (no_bgp_bestpath_compare_router_id,
1085 no_bgp_bestpath_compare_router_id_cmd,
1086 "no bgp bestpath compare-routerid",
1087 NO_STR
1088 "BGP specific commands\n"
1089 "Change the default bestpath selection\n"
1090 "Compare router-id for identical EBGP paths\n")
1091{
1092 struct bgp *bgp;
1093
1094 bgp = vty->index;
1095 bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
1096 return CMD_SUCCESS;
1097}
1098
1099/* "bgp bestpath as-path ignore" configuration. */
1100DEFUN (bgp_bestpath_aspath_ignore,
1101 bgp_bestpath_aspath_ignore_cmd,
1102 "bgp bestpath as-path ignore",
1103 "BGP specific commands\n"
1104 "Change the default bestpath selection\n"
1105 "AS-path attribute\n"
1106 "Ignore as-path length in selecting a route\n")
1107{
1108 struct bgp *bgp;
1109
1110 bgp = vty->index;
1111 bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE);
1112 return CMD_SUCCESS;
1113}
1114
1115DEFUN (no_bgp_bestpath_aspath_ignore,
1116 no_bgp_bestpath_aspath_ignore_cmd,
1117 "no bgp bestpath as-path ignore",
1118 NO_STR
1119 "BGP specific commands\n"
1120 "Change the default bestpath selection\n"
1121 "AS-path attribute\n"
1122 "Ignore as-path length in selecting a route\n")
1123{
1124 struct bgp *bgp;
1125
1126 bgp = vty->index;
1127 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE);
1128 return CMD_SUCCESS;
1129}
1130
hasso68118452005-04-08 15:40:36 +00001131/* "bgp bestpath as-path confed" configuration. */
1132DEFUN (bgp_bestpath_aspath_confed,
1133 bgp_bestpath_aspath_confed_cmd,
1134 "bgp bestpath as-path confed",
1135 "BGP specific commands\n"
1136 "Change the default bestpath selection\n"
1137 "AS-path attribute\n"
1138 "Compare path lengths including confederation sets & sequences in selecting a route\n")
1139{
1140 struct bgp *bgp;
1141
1142 bgp = vty->index;
1143 bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED);
1144 return CMD_SUCCESS;
1145}
1146
1147DEFUN (no_bgp_bestpath_aspath_confed,
1148 no_bgp_bestpath_aspath_confed_cmd,
1149 "no bgp bestpath as-path confed",
1150 NO_STR
1151 "BGP specific commands\n"
1152 "Change the default bestpath selection\n"
1153 "AS-path attribute\n"
1154 "Compare path lengths including confederation sets & sequences in selecting a route\n")
1155{
1156 struct bgp *bgp;
1157
1158 bgp = vty->index;
1159 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED);
1160 return CMD_SUCCESS;
1161}
1162
paul848973c2003-08-13 00:32:49 +00001163/* "bgp log-neighbor-changes" configuration. */
1164DEFUN (bgp_log_neighbor_changes,
1165 bgp_log_neighbor_changes_cmd,
1166 "bgp log-neighbor-changes",
1167 "BGP specific commands\n"
1168 "Log neighbor up/down and reset reason\n")
1169{
1170 struct bgp *bgp;
1171
1172 bgp = vty->index;
1173 bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
1174 return CMD_SUCCESS;
1175}
1176
1177DEFUN (no_bgp_log_neighbor_changes,
1178 no_bgp_log_neighbor_changes_cmd,
1179 "no bgp log-neighbor-changes",
1180 NO_STR
1181 "BGP specific commands\n"
1182 "Log neighbor up/down and reset reason\n")
1183{
1184 struct bgp *bgp;
1185
1186 bgp = vty->index;
1187 bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
1188 return CMD_SUCCESS;
1189}
1190
paul718e3742002-12-13 20:15:29 +00001191/* "bgp bestpath med" configuration. */
1192DEFUN (bgp_bestpath_med,
1193 bgp_bestpath_med_cmd,
1194 "bgp bestpath med (confed|missing-as-worst)",
1195 "BGP specific commands\n"
1196 "Change the default bestpath selection\n"
1197 "MED attribute\n"
1198 "Compare MED among confederation paths\n"
1199 "Treat missing MED as the least preferred one\n")
1200{
1201 struct bgp *bgp;
1202
1203 bgp = vty->index;
1204
1205 if (strncmp (argv[0], "confed", 1) == 0)
1206 bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
1207 else
1208 bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1209
1210 return CMD_SUCCESS;
1211}
1212
1213DEFUN (bgp_bestpath_med2,
1214 bgp_bestpath_med2_cmd,
1215 "bgp bestpath med confed missing-as-worst",
1216 "BGP specific commands\n"
1217 "Change the default bestpath selection\n"
1218 "MED attribute\n"
1219 "Compare MED among confederation paths\n"
1220 "Treat missing MED as the least preferred one\n")
1221{
1222 struct bgp *bgp;
1223
1224 bgp = vty->index;
1225 bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
1226 bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1227 return CMD_SUCCESS;
1228}
1229
1230ALIAS (bgp_bestpath_med2,
1231 bgp_bestpath_med3_cmd,
1232 "bgp bestpath med missing-as-worst confed",
1233 "BGP specific commands\n"
1234 "Change the default bestpath selection\n"
1235 "MED attribute\n"
1236 "Treat missing MED as the least preferred one\n"
1237 "Compare MED among confederation paths\n")
1238
1239DEFUN (no_bgp_bestpath_med,
1240 no_bgp_bestpath_med_cmd,
1241 "no bgp bestpath med (confed|missing-as-worst)",
1242 NO_STR
1243 "BGP specific commands\n"
1244 "Change the default bestpath selection\n"
1245 "MED attribute\n"
1246 "Compare MED among confederation paths\n"
1247 "Treat missing MED as the least preferred one\n")
1248{
1249 struct bgp *bgp;
1250
1251 bgp = vty->index;
1252
1253 if (strncmp (argv[0], "confed", 1) == 0)
1254 bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
1255 else
1256 bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1257
1258 return CMD_SUCCESS;
1259}
1260
1261DEFUN (no_bgp_bestpath_med2,
1262 no_bgp_bestpath_med2_cmd,
1263 "no bgp bestpath med confed missing-as-worst",
1264 NO_STR
1265 "BGP specific commands\n"
1266 "Change the default bestpath selection\n"
1267 "MED attribute\n"
1268 "Compare MED among confederation paths\n"
1269 "Treat missing MED as the least preferred one\n")
1270{
1271 struct bgp *bgp;
1272
1273 bgp = vty->index;
1274 bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
1275 bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1276 return CMD_SUCCESS;
1277}
1278
1279ALIAS (no_bgp_bestpath_med2,
1280 no_bgp_bestpath_med3_cmd,
1281 "no bgp bestpath med missing-as-worst confed",
1282 NO_STR
1283 "BGP specific commands\n"
1284 "Change the default bestpath selection\n"
1285 "MED attribute\n"
1286 "Treat missing MED as the least preferred one\n"
1287 "Compare MED among confederation paths\n")
1288
1289/* "no bgp default ipv4-unicast". */
1290DEFUN (no_bgp_default_ipv4_unicast,
1291 no_bgp_default_ipv4_unicast_cmd,
1292 "no bgp default ipv4-unicast",
1293 NO_STR
1294 "BGP specific commands\n"
1295 "Configure BGP defaults\n"
1296 "Activate ipv4-unicast for a peer by default\n")
1297{
1298 struct bgp *bgp;
1299
1300 bgp = vty->index;
1301 bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
1302 return CMD_SUCCESS;
1303}
1304
1305DEFUN (bgp_default_ipv4_unicast,
1306 bgp_default_ipv4_unicast_cmd,
1307 "bgp default ipv4-unicast",
1308 "BGP specific commands\n"
1309 "Configure BGP defaults\n"
1310 "Activate ipv4-unicast for a peer by default\n")
1311{
1312 struct bgp *bgp;
1313
1314 bgp = vty->index;
1315 bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
1316 return CMD_SUCCESS;
1317}
1318
1319/* "bgp import-check" configuration. */
1320DEFUN (bgp_network_import_check,
1321 bgp_network_import_check_cmd,
1322 "bgp network import-check",
1323 "BGP specific commands\n"
1324 "BGP network command\n"
1325 "Check BGP network route exists in IGP\n")
1326{
1327 struct bgp *bgp;
1328
1329 bgp = vty->index;
1330 bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK);
1331 return CMD_SUCCESS;
1332}
1333
1334DEFUN (no_bgp_network_import_check,
1335 no_bgp_network_import_check_cmd,
1336 "no bgp network import-check",
1337 NO_STR
1338 "BGP specific commands\n"
1339 "BGP network command\n"
1340 "Check BGP network route exists in IGP\n")
1341{
1342 struct bgp *bgp;
1343
1344 bgp = vty->index;
1345 bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK);
1346 return CMD_SUCCESS;
1347}
1348
1349DEFUN (bgp_default_local_preference,
1350 bgp_default_local_preference_cmd,
1351 "bgp default local-preference <0-4294967295>",
1352 "BGP specific commands\n"
1353 "Configure BGP defaults\n"
1354 "local preference (higher=more preferred)\n"
1355 "Configure default local preference value\n")
1356{
1357 struct bgp *bgp;
1358 u_int32_t local_pref;
1359
1360 bgp = vty->index;
1361
1362 VTY_GET_INTEGER ("local preference", local_pref, argv[0]);
1363
1364 bgp_default_local_preference_set (bgp, local_pref);
1365
1366 return CMD_SUCCESS;
1367}
1368
1369DEFUN (no_bgp_default_local_preference,
1370 no_bgp_default_local_preference_cmd,
1371 "no bgp default local-preference",
1372 NO_STR
1373 "BGP specific commands\n"
1374 "Configure BGP defaults\n"
1375 "local preference (higher=more preferred)\n")
1376{
1377 struct bgp *bgp;
1378
1379 bgp = vty->index;
1380 bgp_default_local_preference_unset (bgp);
1381 return CMD_SUCCESS;
1382}
1383
1384ALIAS (no_bgp_default_local_preference,
1385 no_bgp_default_local_preference_val_cmd,
1386 "no bgp default local-preference <0-4294967295>",
1387 NO_STR
1388 "BGP specific commands\n"
1389 "Configure BGP defaults\n"
1390 "local preference (higher=more preferred)\n"
1391 "Configure default local preference value\n")
1392
1393static int
paulfd79ac92004-10-13 05:06:08 +00001394peer_remote_as_vty (struct vty *vty, const char *peer_str,
1395 const char *as_str, afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00001396{
1397 int ret;
1398 struct bgp *bgp;
1399 as_t as;
1400 union sockunion su;
1401
1402 bgp = vty->index;
1403
1404 /* Get AS number. */
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00001405 VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX);
paul718e3742002-12-13 20:15:29 +00001406
1407 /* If peer is peer group, call proper function. */
1408 ret = str2sockunion (peer_str, &su);
1409 if (ret < 0)
1410 {
1411 ret = peer_group_remote_as (bgp, peer_str, &as);
1412 if (ret < 0)
1413 {
1414 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1415 return CMD_WARNING;
1416 }
1417 return CMD_SUCCESS;
1418 }
1419
1420 if (peer_address_self_check (&su))
1421 {
1422 vty_out (vty, "%% Can not configure the local system as neighbor%s",
1423 VTY_NEWLINE);
1424 return CMD_WARNING;
1425 }
1426
1427 ret = peer_remote_as (bgp, &su, &as, afi, safi);
1428
1429 /* This peer belongs to peer group. */
1430 switch (ret)
1431 {
1432 case BGP_ERR_PEER_GROUP_MEMBER:
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04001433 vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001434 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +00001435 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT:
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04001436 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 +00001437 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +00001438 }
1439 return bgp_vty_return (vty, ret);
1440}
1441
1442DEFUN (neighbor_remote_as,
1443 neighbor_remote_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001444 NEIGHBOR_CMD2 "remote-as " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00001445 NEIGHBOR_STR
1446 NEIGHBOR_ADDR_STR2
1447 "Specify a BGP neighbor\n"
1448 AS_STR)
1449{
1450 return peer_remote_as_vty (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST);
1451}
1452
1453DEFUN (neighbor_peer_group,
1454 neighbor_peer_group_cmd,
1455 "neighbor WORD peer-group",
1456 NEIGHBOR_STR
1457 "Neighbor tag\n"
1458 "Configure peer-group\n")
1459{
1460 struct bgp *bgp;
1461 struct peer_group *group;
1462
1463 bgp = vty->index;
1464
1465 group = peer_group_get (bgp, argv[0]);
1466 if (! group)
1467 return CMD_WARNING;
1468
1469 return CMD_SUCCESS;
1470}
1471
1472DEFUN (no_neighbor,
1473 no_neighbor_cmd,
1474 NO_NEIGHBOR_CMD2,
1475 NO_STR
1476 NEIGHBOR_STR
1477 NEIGHBOR_ADDR_STR2)
1478{
1479 int ret;
1480 union sockunion su;
1481 struct peer_group *group;
1482 struct peer *peer;
1483
1484 ret = str2sockunion (argv[0], &su);
1485 if (ret < 0)
1486 {
1487 group = peer_group_lookup (vty->index, argv[0]);
1488 if (group)
1489 peer_group_delete (group);
1490 else
1491 {
1492 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1493 return CMD_WARNING;
1494 }
1495 }
1496 else
1497 {
1498 peer = peer_lookup (vty->index, &su);
1499 if (peer)
paul200df112005-06-01 11:17:05 +00001500 peer_delete (peer);
paul718e3742002-12-13 20:15:29 +00001501 }
1502
1503 return CMD_SUCCESS;
1504}
1505
1506ALIAS (no_neighbor,
1507 no_neighbor_remote_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001508 NO_NEIGHBOR_CMD "remote-as " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00001509 NO_STR
1510 NEIGHBOR_STR
1511 NEIGHBOR_ADDR_STR
1512 "Specify a BGP neighbor\n"
1513 AS_STR)
1514
1515DEFUN (no_neighbor_peer_group,
1516 no_neighbor_peer_group_cmd,
1517 "no neighbor WORD peer-group",
1518 NO_STR
1519 NEIGHBOR_STR
1520 "Neighbor tag\n"
1521 "Configure peer-group\n")
1522{
1523 struct peer_group *group;
1524
1525 group = peer_group_lookup (vty->index, argv[0]);
1526 if (group)
1527 peer_group_delete (group);
1528 else
1529 {
1530 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1531 return CMD_WARNING;
1532 }
1533 return CMD_SUCCESS;
1534}
1535
1536DEFUN (no_neighbor_peer_group_remote_as,
1537 no_neighbor_peer_group_remote_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001538 "no neighbor WORD remote-as " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00001539 NO_STR
1540 NEIGHBOR_STR
1541 "Neighbor tag\n"
1542 "Specify a BGP neighbor\n"
1543 AS_STR)
1544{
1545 struct peer_group *group;
1546
1547 group = peer_group_lookup (vty->index, argv[0]);
1548 if (group)
1549 peer_group_remote_as_delete (group);
1550 else
1551 {
1552 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1553 return CMD_WARNING;
1554 }
1555 return CMD_SUCCESS;
1556}
1557
1558DEFUN (neighbor_local_as,
1559 neighbor_local_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001560 NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00001561 NEIGHBOR_STR
1562 NEIGHBOR_ADDR_STR2
1563 "Specify a local-as number\n"
1564 "AS number used as local AS\n")
1565{
1566 struct peer *peer;
1567 int ret;
1568
1569 peer = peer_and_group_lookup_vty (vty, argv[0]);
1570 if (! peer)
1571 return CMD_WARNING;
1572
1573 ret = peer_local_as_set (peer, atoi (argv[1]), 0);
1574 return bgp_vty_return (vty, ret);
1575}
1576
1577DEFUN (neighbor_local_as_no_prepend,
1578 neighbor_local_as_no_prepend_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001579 NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
paul718e3742002-12-13 20:15:29 +00001580 NEIGHBOR_STR
1581 NEIGHBOR_ADDR_STR2
1582 "Specify a local-as number\n"
1583 "AS number used as local AS\n"
1584 "Do not prepend local-as to updates from ebgp peers\n")
1585{
1586 struct peer *peer;
1587 int ret;
1588
1589 peer = peer_and_group_lookup_vty (vty, argv[0]);
1590 if (! peer)
1591 return CMD_WARNING;
1592
1593 ret = peer_local_as_set (peer, atoi (argv[1]), 1);
1594 return bgp_vty_return (vty, ret);
1595}
1596
1597DEFUN (no_neighbor_local_as,
1598 no_neighbor_local_as_cmd,
1599 NO_NEIGHBOR_CMD2 "local-as",
1600 NO_STR
1601 NEIGHBOR_STR
1602 NEIGHBOR_ADDR_STR2
1603 "Specify a local-as number\n")
1604{
1605 struct peer *peer;
1606 int ret;
1607
1608 peer = peer_and_group_lookup_vty (vty, argv[0]);
1609 if (! peer)
1610 return CMD_WARNING;
1611
1612 ret = peer_local_as_unset (peer);
1613 return bgp_vty_return (vty, ret);
1614}
1615
1616ALIAS (no_neighbor_local_as,
1617 no_neighbor_local_as_val_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001618 NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00001619 NO_STR
1620 NEIGHBOR_STR
1621 NEIGHBOR_ADDR_STR2
1622 "Specify a local-as number\n"
1623 "AS number used as local AS\n")
1624
1625ALIAS (no_neighbor_local_as,
1626 no_neighbor_local_as_val2_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00001627 NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
paul718e3742002-12-13 20:15:29 +00001628 NO_STR
1629 NEIGHBOR_STR
1630 NEIGHBOR_ADDR_STR2
1631 "Specify a local-as number\n"
1632 "AS number used as local AS\n"
1633 "Do not prepend local-as to updates from ebgp peers\n")
1634
Paul Jakma0df7c912008-07-21 21:02:49 +00001635DEFUN (neighbor_password,
1636 neighbor_password_cmd,
1637 NEIGHBOR_CMD2 "password LINE",
1638 NEIGHBOR_STR
1639 NEIGHBOR_ADDR_STR2
1640 "Set a password\n"
1641 "The password\n")
1642{
1643 struct peer *peer;
1644 int ret;
1645
1646 peer = peer_and_group_lookup_vty (vty, argv[0]);
1647 if (! peer)
1648 return CMD_WARNING;
1649
1650 ret = peer_password_set (peer, argv[1]);
1651 return bgp_vty_return (vty, ret);
1652}
1653
1654DEFUN (no_neighbor_password,
1655 no_neighbor_password_cmd,
1656 NO_NEIGHBOR_CMD2 "password",
1657 NO_STR
1658 NEIGHBOR_STR
1659 NEIGHBOR_ADDR_STR2
1660 "Set a password\n")
1661{
1662 struct peer *peer;
1663 int ret;
1664
1665 peer = peer_and_group_lookup_vty (vty, argv[0]);
1666 if (! peer)
1667 return CMD_WARNING;
1668
1669 ret = peer_password_unset (peer);
1670 return bgp_vty_return (vty, ret);
1671}
1672
paul718e3742002-12-13 20:15:29 +00001673DEFUN (neighbor_activate,
1674 neighbor_activate_cmd,
1675 NEIGHBOR_CMD2 "activate",
1676 NEIGHBOR_STR
1677 NEIGHBOR_ADDR_STR2
1678 "Enable the Address Family for this Neighbor\n")
1679{
1680 struct peer *peer;
1681
1682 peer = peer_and_group_lookup_vty (vty, argv[0]);
1683 if (! peer)
1684 return CMD_WARNING;
1685
1686 peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
1687
1688 return CMD_SUCCESS;
1689}
1690
1691DEFUN (no_neighbor_activate,
1692 no_neighbor_activate_cmd,
1693 NO_NEIGHBOR_CMD2 "activate",
1694 NO_STR
1695 NEIGHBOR_STR
1696 NEIGHBOR_ADDR_STR2
1697 "Enable the Address Family for this Neighbor\n")
1698{
1699 int ret;
1700 struct peer *peer;
1701
1702 /* Lookup peer. */
1703 peer = peer_and_group_lookup_vty (vty, argv[0]);
1704 if (! peer)
1705 return CMD_WARNING;
1706
1707 ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
1708
1709 return bgp_vty_return (vty, ret);
1710}
1711
1712DEFUN (neighbor_set_peer_group,
1713 neighbor_set_peer_group_cmd,
1714 NEIGHBOR_CMD "peer-group WORD",
1715 NEIGHBOR_STR
1716 NEIGHBOR_ADDR_STR
1717 "Member of the peer-group\n"
1718 "peer-group name\n")
1719{
1720 int ret;
1721 as_t as;
1722 union sockunion su;
1723 struct bgp *bgp;
1724 struct peer_group *group;
1725
1726 bgp = vty->index;
1727
1728 ret = str2sockunion (argv[0], &su);
1729 if (ret < 0)
1730 {
1731 vty_out (vty, "%% Malformed address: %s%s", argv[0], VTY_NEWLINE);
1732 return CMD_WARNING;
1733 }
1734
1735 group = peer_group_lookup (bgp, argv[1]);
1736 if (! group)
1737 {
1738 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
1739 return CMD_WARNING;
1740 }
1741
1742 if (peer_address_self_check (&su))
1743 {
1744 vty_out (vty, "%% Can not configure the local system as neighbor%s",
1745 VTY_NEWLINE);
1746 return CMD_WARNING;
1747 }
1748
1749 ret = peer_group_bind (bgp, &su, group, bgp_node_afi (vty),
1750 bgp_node_safi (vty), &as);
1751
1752 if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT)
1753 {
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04001754 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 +00001755 return CMD_WARNING;
1756 }
1757
1758 return bgp_vty_return (vty, ret);
1759}
1760
1761DEFUN (no_neighbor_set_peer_group,
1762 no_neighbor_set_peer_group_cmd,
1763 NO_NEIGHBOR_CMD "peer-group WORD",
1764 NO_STR
1765 NEIGHBOR_STR
1766 NEIGHBOR_ADDR_STR
1767 "Member of the peer-group\n"
1768 "peer-group name\n")
1769{
1770 int ret;
1771 struct bgp *bgp;
1772 struct peer *peer;
1773 struct peer_group *group;
1774
1775 bgp = vty->index;
1776
1777 peer = peer_lookup_vty (vty, argv[0]);
1778 if (! peer)
1779 return CMD_WARNING;
1780
1781 group = peer_group_lookup (bgp, argv[1]);
1782 if (! group)
1783 {
1784 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
1785 return CMD_WARNING;
1786 }
1787
1788 ret = peer_group_unbind (bgp, peer, group, bgp_node_afi (vty),
1789 bgp_node_safi (vty));
1790
1791 return bgp_vty_return (vty, ret);
1792}
1793
paul94f2b392005-06-28 12:44:16 +00001794static int
paulfd79ac92004-10-13 05:06:08 +00001795peer_flag_modify_vty (struct vty *vty, const char *ip_str,
1796 u_int16_t flag, int set)
paul718e3742002-12-13 20:15:29 +00001797{
1798 int ret;
1799 struct peer *peer;
1800
1801 peer = peer_and_group_lookup_vty (vty, ip_str);
1802 if (! peer)
1803 return CMD_WARNING;
1804
1805 if (set)
1806 ret = peer_flag_set (peer, flag);
1807 else
1808 ret = peer_flag_unset (peer, flag);
1809
1810 return bgp_vty_return (vty, ret);
1811}
1812
paul94f2b392005-06-28 12:44:16 +00001813static int
paulfd79ac92004-10-13 05:06:08 +00001814peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
paul718e3742002-12-13 20:15:29 +00001815{
1816 return peer_flag_modify_vty (vty, ip_str, flag, 1);
1817}
1818
paul94f2b392005-06-28 12:44:16 +00001819static int
paulfd79ac92004-10-13 05:06:08 +00001820peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
paul718e3742002-12-13 20:15:29 +00001821{
1822 return peer_flag_modify_vty (vty, ip_str, flag, 0);
1823}
1824
1825/* neighbor passive. */
1826DEFUN (neighbor_passive,
1827 neighbor_passive_cmd,
1828 NEIGHBOR_CMD2 "passive",
1829 NEIGHBOR_STR
1830 NEIGHBOR_ADDR_STR2
1831 "Don't send open messages to this neighbor\n")
1832{
1833 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_PASSIVE);
1834}
1835
1836DEFUN (no_neighbor_passive,
1837 no_neighbor_passive_cmd,
1838 NO_NEIGHBOR_CMD2 "passive",
1839 NO_STR
1840 NEIGHBOR_STR
1841 NEIGHBOR_ADDR_STR2
1842 "Don't send open messages to this neighbor\n")
1843{
1844 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_PASSIVE);
1845}
1846
1847/* neighbor shutdown. */
1848DEFUN (neighbor_shutdown,
1849 neighbor_shutdown_cmd,
1850 NEIGHBOR_CMD2 "shutdown",
1851 NEIGHBOR_STR
1852 NEIGHBOR_ADDR_STR2
1853 "Administratively shut down this neighbor\n")
1854{
1855 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
1856}
1857
1858DEFUN (no_neighbor_shutdown,
1859 no_neighbor_shutdown_cmd,
1860 NO_NEIGHBOR_CMD2 "shutdown",
1861 NO_STR
1862 NEIGHBOR_STR
1863 NEIGHBOR_ADDR_STR2
1864 "Administratively shut down this neighbor\n")
1865{
1866 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
1867}
1868
hassoc9502432005-02-01 22:01:48 +00001869/* Deprecated neighbor capability route-refresh. */
1870DEFUN_DEPRECATED (neighbor_capability_route_refresh,
1871 neighbor_capability_route_refresh_cmd,
1872 NEIGHBOR_CMD2 "capability route-refresh",
1873 NEIGHBOR_STR
1874 NEIGHBOR_ADDR_STR2
1875 "Advertise capability to the peer\n"
1876 "Advertise route-refresh capability to this neighbor\n")
paul718e3742002-12-13 20:15:29 +00001877{
hassoc9502432005-02-01 22:01:48 +00001878 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00001879}
1880
hassoc9502432005-02-01 22:01:48 +00001881DEFUN_DEPRECATED (no_neighbor_capability_route_refresh,
1882 no_neighbor_capability_route_refresh_cmd,
1883 NO_NEIGHBOR_CMD2 "capability route-refresh",
1884 NO_STR
1885 NEIGHBOR_STR
1886 NEIGHBOR_ADDR_STR2
1887 "Advertise capability to the peer\n"
1888 "Advertise route-refresh capability to this neighbor\n")
paul718e3742002-12-13 20:15:29 +00001889{
hassoc9502432005-02-01 22:01:48 +00001890 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00001891}
1892
1893/* neighbor capability dynamic. */
1894DEFUN (neighbor_capability_dynamic,
1895 neighbor_capability_dynamic_cmd,
1896 NEIGHBOR_CMD2 "capability dynamic",
1897 NEIGHBOR_STR
1898 NEIGHBOR_ADDR_STR2
1899 "Advertise capability to the peer\n"
1900 "Advertise dynamic capability to this neighbor\n")
1901{
1902 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
1903}
1904
1905DEFUN (no_neighbor_capability_dynamic,
1906 no_neighbor_capability_dynamic_cmd,
1907 NO_NEIGHBOR_CMD2 "capability dynamic",
1908 NO_STR
1909 NEIGHBOR_STR
1910 NEIGHBOR_ADDR_STR2
1911 "Advertise capability to the peer\n"
1912 "Advertise dynamic capability to this neighbor\n")
1913{
1914 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
1915}
1916
1917/* neighbor dont-capability-negotiate */
1918DEFUN (neighbor_dont_capability_negotiate,
1919 neighbor_dont_capability_negotiate_cmd,
1920 NEIGHBOR_CMD2 "dont-capability-negotiate",
1921 NEIGHBOR_STR
1922 NEIGHBOR_ADDR_STR2
1923 "Do not perform capability negotiation\n")
1924{
1925 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
1926}
1927
1928DEFUN (no_neighbor_dont_capability_negotiate,
1929 no_neighbor_dont_capability_negotiate_cmd,
1930 NO_NEIGHBOR_CMD2 "dont-capability-negotiate",
1931 NO_STR
1932 NEIGHBOR_STR
1933 NEIGHBOR_ADDR_STR2
1934 "Do not perform capability negotiation\n")
1935{
1936 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
1937}
1938
paul94f2b392005-06-28 12:44:16 +00001939static int
paulfd79ac92004-10-13 05:06:08 +00001940peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi,
paulfee0f4c2004-09-13 05:12:46 +00001941 safi_t safi, u_int32_t flag, int set)
paul718e3742002-12-13 20:15:29 +00001942{
1943 int ret;
1944 struct peer *peer;
1945
1946 peer = peer_and_group_lookup_vty (vty, peer_str);
1947 if (! peer)
1948 return CMD_WARNING;
1949
1950 if (set)
1951 ret = peer_af_flag_set (peer, afi, safi, flag);
1952 else
1953 ret = peer_af_flag_unset (peer, afi, safi, flag);
1954
1955 return bgp_vty_return (vty, ret);
1956}
1957
paul94f2b392005-06-28 12:44:16 +00001958static int
paulfd79ac92004-10-13 05:06:08 +00001959peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi,
paulfee0f4c2004-09-13 05:12:46 +00001960 safi_t safi, u_int32_t flag)
paul718e3742002-12-13 20:15:29 +00001961{
1962 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1);
1963}
1964
paul94f2b392005-06-28 12:44:16 +00001965static int
paulfd79ac92004-10-13 05:06:08 +00001966peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi,
paulfee0f4c2004-09-13 05:12:46 +00001967 safi_t safi, u_int32_t flag)
paul718e3742002-12-13 20:15:29 +00001968{
1969 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0);
1970}
1971
1972/* neighbor capability orf prefix-list. */
1973DEFUN (neighbor_capability_orf_prefix,
1974 neighbor_capability_orf_prefix_cmd,
1975 NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
1976 NEIGHBOR_STR
1977 NEIGHBOR_ADDR_STR2
1978 "Advertise capability to the peer\n"
1979 "Advertise ORF capability to the peer\n"
1980 "Advertise prefixlist ORF capability to this neighbor\n"
1981 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
1982 "Capability to RECEIVE the ORF from this neighbor\n"
1983 "Capability to SEND the ORF to this neighbor\n")
1984{
1985 u_int16_t flag = 0;
1986
1987 if (strncmp (argv[1], "s", 1) == 0)
1988 flag = PEER_FLAG_ORF_PREFIX_SM;
1989 else if (strncmp (argv[1], "r", 1) == 0)
1990 flag = PEER_FLAG_ORF_PREFIX_RM;
1991 else if (strncmp (argv[1], "b", 1) == 0)
1992 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
1993 else
1994 return CMD_WARNING;
1995
1996 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1997 bgp_node_safi (vty), flag);
1998}
1999
2000DEFUN (no_neighbor_capability_orf_prefix,
2001 no_neighbor_capability_orf_prefix_cmd,
2002 NO_NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
2003 NO_STR
2004 NEIGHBOR_STR
2005 NEIGHBOR_ADDR_STR2
2006 "Advertise capability to the peer\n"
2007 "Advertise ORF capability to the peer\n"
2008 "Advertise prefixlist ORF capability to this neighbor\n"
2009 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
2010 "Capability to RECEIVE the ORF from this neighbor\n"
2011 "Capability to SEND the ORF to this neighbor\n")
2012{
2013 u_int16_t flag = 0;
2014
2015 if (strncmp (argv[1], "s", 1) == 0)
2016 flag = PEER_FLAG_ORF_PREFIX_SM;
2017 else if (strncmp (argv[1], "r", 1) == 0)
2018 flag = PEER_FLAG_ORF_PREFIX_RM;
2019 else if (strncmp (argv[1], "b", 1) == 0)
2020 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
2021 else
2022 return CMD_WARNING;
2023
2024 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2025 bgp_node_safi (vty), flag);
2026}
2027
2028/* neighbor next-hop-self. */
2029DEFUN (neighbor_nexthop_self,
2030 neighbor_nexthop_self_cmd,
2031 NEIGHBOR_CMD2 "next-hop-self",
2032 NEIGHBOR_STR
2033 NEIGHBOR_ADDR_STR2
2034 "Disable the next hop calculation for this neighbor\n")
2035{
2036 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2037 bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF);
2038}
2039
2040DEFUN (no_neighbor_nexthop_self,
2041 no_neighbor_nexthop_self_cmd,
2042 NO_NEIGHBOR_CMD2 "next-hop-self",
2043 NO_STR
2044 NEIGHBOR_STR
2045 NEIGHBOR_ADDR_STR2
2046 "Disable the next hop calculation for this neighbor\n")
2047{
2048 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2049 bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF);
2050}
2051
2052/* neighbor remove-private-AS. */
2053DEFUN (neighbor_remove_private_as,
2054 neighbor_remove_private_as_cmd,
2055 NEIGHBOR_CMD2 "remove-private-AS",
2056 NEIGHBOR_STR
2057 NEIGHBOR_ADDR_STR2
2058 "Remove private AS number from outbound updates\n")
2059{
2060 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2061 bgp_node_safi (vty),
2062 PEER_FLAG_REMOVE_PRIVATE_AS);
2063}
2064
2065DEFUN (no_neighbor_remove_private_as,
2066 no_neighbor_remove_private_as_cmd,
2067 NO_NEIGHBOR_CMD2 "remove-private-AS",
2068 NO_STR
2069 NEIGHBOR_STR
2070 NEIGHBOR_ADDR_STR2
2071 "Remove private AS number from outbound updates\n")
2072{
2073 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2074 bgp_node_safi (vty),
2075 PEER_FLAG_REMOVE_PRIVATE_AS);
2076}
2077
2078/* neighbor send-community. */
2079DEFUN (neighbor_send_community,
2080 neighbor_send_community_cmd,
2081 NEIGHBOR_CMD2 "send-community",
2082 NEIGHBOR_STR
2083 NEIGHBOR_ADDR_STR2
2084 "Send Community attribute to this neighbor\n")
2085{
2086 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2087 bgp_node_safi (vty),
2088 PEER_FLAG_SEND_COMMUNITY);
2089}
2090
2091DEFUN (no_neighbor_send_community,
2092 no_neighbor_send_community_cmd,
2093 NO_NEIGHBOR_CMD2 "send-community",
2094 NO_STR
2095 NEIGHBOR_STR
2096 NEIGHBOR_ADDR_STR2
2097 "Send Community attribute to this neighbor\n")
2098{
2099 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2100 bgp_node_safi (vty),
2101 PEER_FLAG_SEND_COMMUNITY);
2102}
2103
2104/* neighbor send-community extended. */
2105DEFUN (neighbor_send_community_type,
2106 neighbor_send_community_type_cmd,
2107 NEIGHBOR_CMD2 "send-community (both|extended|standard)",
2108 NEIGHBOR_STR
2109 NEIGHBOR_ADDR_STR2
2110 "Send Community attribute to this neighbor\n"
2111 "Send Standard and Extended Community attributes\n"
2112 "Send Extended Community attributes\n"
2113 "Send Standard Community attributes\n")
2114{
2115 if (strncmp (argv[1], "s", 1) == 0)
2116 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2117 bgp_node_safi (vty),
2118 PEER_FLAG_SEND_COMMUNITY);
2119 if (strncmp (argv[1], "e", 1) == 0)
2120 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2121 bgp_node_safi (vty),
2122 PEER_FLAG_SEND_EXT_COMMUNITY);
2123
2124 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2125 bgp_node_safi (vty),
2126 (PEER_FLAG_SEND_COMMUNITY|
2127 PEER_FLAG_SEND_EXT_COMMUNITY));
2128}
2129
2130DEFUN (no_neighbor_send_community_type,
2131 no_neighbor_send_community_type_cmd,
2132 NO_NEIGHBOR_CMD2 "send-community (both|extended|standard)",
2133 NO_STR
2134 NEIGHBOR_STR
2135 NEIGHBOR_ADDR_STR2
2136 "Send Community attribute to this neighbor\n"
2137 "Send Standard and Extended Community attributes\n"
2138 "Send Extended Community attributes\n"
2139 "Send Standard Community attributes\n")
2140{
2141 if (strncmp (argv[1], "s", 1) == 0)
2142 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2143 bgp_node_safi (vty),
2144 PEER_FLAG_SEND_COMMUNITY);
2145 if (strncmp (argv[1], "e", 1) == 0)
2146 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2147 bgp_node_safi (vty),
2148 PEER_FLAG_SEND_EXT_COMMUNITY);
2149
2150 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2151 bgp_node_safi (vty),
2152 (PEER_FLAG_SEND_COMMUNITY |
2153 PEER_FLAG_SEND_EXT_COMMUNITY));
2154}
2155
2156/* neighbor soft-reconfig. */
2157DEFUN (neighbor_soft_reconfiguration,
2158 neighbor_soft_reconfiguration_cmd,
2159 NEIGHBOR_CMD2 "soft-reconfiguration inbound",
2160 NEIGHBOR_STR
2161 NEIGHBOR_ADDR_STR2
2162 "Per neighbor soft reconfiguration\n"
2163 "Allow inbound soft reconfiguration for this neighbor\n")
2164{
2165 return peer_af_flag_set_vty (vty, argv[0],
2166 bgp_node_afi (vty), bgp_node_safi (vty),
2167 PEER_FLAG_SOFT_RECONFIG);
2168}
2169
2170DEFUN (no_neighbor_soft_reconfiguration,
2171 no_neighbor_soft_reconfiguration_cmd,
2172 NO_NEIGHBOR_CMD2 "soft-reconfiguration inbound",
2173 NO_STR
2174 NEIGHBOR_STR
2175 NEIGHBOR_ADDR_STR2
2176 "Per neighbor soft reconfiguration\n"
2177 "Allow inbound soft reconfiguration for this neighbor\n")
2178{
2179 return peer_af_flag_unset_vty (vty, argv[0],
2180 bgp_node_afi (vty), bgp_node_safi (vty),
2181 PEER_FLAG_SOFT_RECONFIG);
2182}
2183
2184DEFUN (neighbor_route_reflector_client,
2185 neighbor_route_reflector_client_cmd,
2186 NEIGHBOR_CMD2 "route-reflector-client",
2187 NEIGHBOR_STR
2188 NEIGHBOR_ADDR_STR2
2189 "Configure a neighbor as Route Reflector client\n")
2190{
2191 struct peer *peer;
2192
2193
2194 peer = peer_and_group_lookup_vty (vty, argv[0]);
2195 if (! peer)
2196 return CMD_WARNING;
2197
2198 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2199 bgp_node_safi (vty),
2200 PEER_FLAG_REFLECTOR_CLIENT);
2201}
2202
2203DEFUN (no_neighbor_route_reflector_client,
2204 no_neighbor_route_reflector_client_cmd,
2205 NO_NEIGHBOR_CMD2 "route-reflector-client",
2206 NO_STR
2207 NEIGHBOR_STR
2208 NEIGHBOR_ADDR_STR2
2209 "Configure a neighbor as Route Reflector client\n")
2210{
2211 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2212 bgp_node_safi (vty),
2213 PEER_FLAG_REFLECTOR_CLIENT);
2214}
2215
paul94f2b392005-06-28 12:44:16 +00002216static int
paulfd79ac92004-10-13 05:06:08 +00002217peer_rsclient_set_vty (struct vty *vty, const char *peer_str,
2218 int afi, int safi)
paulfee0f4c2004-09-13 05:12:46 +00002219{
2220 int ret;
2221 struct bgp *bgp;
2222 struct peer *peer;
2223 struct peer_group *group;
paul1eb8ef22005-04-07 07:30:20 +00002224 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00002225 struct bgp_filter *pfilter;
2226 struct bgp_filter *gfilter;
Chris Caputo228da422009-07-18 05:44:03 +00002227 int locked_and_added = 0;
paulfee0f4c2004-09-13 05:12:46 +00002228
2229 bgp = vty->index;
2230
2231 peer = peer_and_group_lookup_vty (vty, peer_str);
2232 if ( ! peer )
2233 return CMD_WARNING;
2234
2235 /* If it is already a RS-Client, don't do anything. */
2236 if ( CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) )
2237 return CMD_SUCCESS;
2238
2239 if ( ! peer_rsclient_active (peer) )
paul200df112005-06-01 11:17:05 +00002240 {
2241 peer = peer_lock (peer); /* rsclient peer list reference */
2242 listnode_add_sort (bgp->rsclient, peer);
Chris Caputo228da422009-07-18 05:44:03 +00002243 locked_and_added = 1;
paul200df112005-06-01 11:17:05 +00002244 }
paulfee0f4c2004-09-13 05:12:46 +00002245
2246 ret = peer_af_flag_set (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
2247 if (ret < 0)
Chris Caputo228da422009-07-18 05:44:03 +00002248 {
2249 if (locked_and_added)
2250 {
2251 listnode_delete (bgp->rsclient, peer);
2252 peer_unlock (peer); /* rsclient peer list reference */
2253 }
2254
2255 return bgp_vty_return (vty, ret);
2256 }
paulfee0f4c2004-09-13 05:12:46 +00002257
Paul Jakma64e580a2006-02-21 01:09:01 +00002258 peer->rib[afi][safi] = bgp_table_init (afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00002259 peer->rib[afi][safi]->type = BGP_TABLE_RSCLIENT;
Chris Caputo228da422009-07-18 05:44:03 +00002260 /* RIB peer reference. Released when table is free'd in bgp_table_free. */
2261 peer->rib[afi][safi]->owner = peer_lock (peer);
paulfee0f4c2004-09-13 05:12:46 +00002262
2263 /* Check for existing 'network' and 'redistribute' routes. */
2264 bgp_check_local_routes_rsclient (peer, afi, safi);
2265
2266 /* Check for routes for peers configured with 'soft-reconfiguration'. */
2267 bgp_soft_reconfig_rsclient (peer, afi, safi);
2268
2269 if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))
2270 {
2271 group = peer->group;
2272 gfilter = &peer->filter[afi][safi];
2273
paul1eb8ef22005-04-07 07:30:20 +00002274 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
paulfee0f4c2004-09-13 05:12:46 +00002275 {
2276 pfilter = &peer->filter[afi][safi];
2277
2278 /* Members of a non-RS-Client group should not be RS-Clients, as that
2279 is checked when the become part of the peer-group */
2280 ret = peer_af_flag_set (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
2281 if (ret < 0)
2282 return bgp_vty_return (vty, ret);
2283
2284 /* Make peer's RIB point to group's RIB. */
2285 peer->rib[afi][safi] = group->conf->rib[afi][safi];
2286
2287 /* Import policy. */
2288 if (pfilter->map[RMAP_IMPORT].name)
2289 free (pfilter->map[RMAP_IMPORT].name);
2290 if (gfilter->map[RMAP_IMPORT].name)
2291 {
2292 pfilter->map[RMAP_IMPORT].name = strdup (gfilter->map[RMAP_IMPORT].name);
2293 pfilter->map[RMAP_IMPORT].map = gfilter->map[RMAP_IMPORT].map;
2294 }
2295 else
2296 {
2297 pfilter->map[RMAP_IMPORT].name = NULL;
2298 pfilter->map[RMAP_IMPORT].map =NULL;
2299 }
2300
2301 /* Export policy. */
2302 if (gfilter->map[RMAP_EXPORT].name && ! pfilter->map[RMAP_EXPORT].name)
2303 {
2304 pfilter->map[RMAP_EXPORT].name = strdup (gfilter->map[RMAP_EXPORT].name);
2305 pfilter->map[RMAP_EXPORT].map = gfilter->map[RMAP_EXPORT].map;
2306 }
2307 }
2308 }
2309 return CMD_SUCCESS;
2310}
2311
paul94f2b392005-06-28 12:44:16 +00002312static int
paulfd79ac92004-10-13 05:06:08 +00002313peer_rsclient_unset_vty (struct vty *vty, const char *peer_str,
2314 int afi, int safi)
paulfee0f4c2004-09-13 05:12:46 +00002315{
2316 int ret;
2317 struct bgp *bgp;
2318 struct peer *peer;
2319 struct peer_group *group;
paul1eb8ef22005-04-07 07:30:20 +00002320 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00002321
2322 bgp = vty->index;
2323
2324 peer = peer_and_group_lookup_vty (vty, peer_str);
2325 if ( ! peer )
2326 return CMD_WARNING;
2327
2328 /* If it is not a RS-Client, don't do anything. */
2329 if ( ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) )
2330 return CMD_SUCCESS;
2331
2332 if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))
2333 {
2334 group = peer->group;
2335
paul1eb8ef22005-04-07 07:30:20 +00002336 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
paulfee0f4c2004-09-13 05:12:46 +00002337 {
2338 ret = peer_af_flag_unset (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
2339 if (ret < 0)
2340 return bgp_vty_return (vty, ret);
2341
2342 peer->rib[afi][safi] = NULL;
2343 }
2344
2345 peer = group->conf;
2346 }
2347
2348 ret = peer_af_flag_unset (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
2349 if (ret < 0)
2350 return bgp_vty_return (vty, ret);
2351
2352 if ( ! peer_rsclient_active (peer) )
paul200df112005-06-01 11:17:05 +00002353 {
Chris Caputo228da422009-07-18 05:44:03 +00002354 bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_MY_RSCLIENT);
paul200df112005-06-01 11:17:05 +00002355 listnode_delete (bgp->rsclient, peer);
Chris Caputo228da422009-07-18 05:44:03 +00002356 peer_unlock (peer); /* peer bgp rsclient reference */
paul200df112005-06-01 11:17:05 +00002357 }
paulfee0f4c2004-09-13 05:12:46 +00002358
Paul Jakmab608d5b2008-07-02 02:12:07 +00002359 bgp_table_finish (&peer->rib[bgp_node_afi(vty)][bgp_node_safi(vty)]);
paulfee0f4c2004-09-13 05:12:46 +00002360
2361 return CMD_SUCCESS;
2362}
2363
paul718e3742002-12-13 20:15:29 +00002364/* neighbor route-server-client. */
2365DEFUN (neighbor_route_server_client,
2366 neighbor_route_server_client_cmd,
2367 NEIGHBOR_CMD2 "route-server-client",
2368 NEIGHBOR_STR
2369 NEIGHBOR_ADDR_STR2
2370 "Configure a neighbor as Route Server client\n")
2371{
paulfee0f4c2004-09-13 05:12:46 +00002372 return peer_rsclient_set_vty (vty, argv[0], bgp_node_afi(vty),
2373 bgp_node_safi(vty));
paul718e3742002-12-13 20:15:29 +00002374}
2375
2376DEFUN (no_neighbor_route_server_client,
2377 no_neighbor_route_server_client_cmd,
2378 NO_NEIGHBOR_CMD2 "route-server-client",
2379 NO_STR
2380 NEIGHBOR_STR
2381 NEIGHBOR_ADDR_STR2
2382 "Configure a neighbor as Route Server client\n")
2383{
paulfee0f4c2004-09-13 05:12:46 +00002384 return peer_rsclient_unset_vty (vty, argv[0], bgp_node_afi(vty),
2385 bgp_node_safi(vty));
2386}
2387
2388DEFUN (neighbor_nexthop_local_unchanged,
2389 neighbor_nexthop_local_unchanged_cmd,
2390 NEIGHBOR_CMD2 "nexthop-local unchanged",
2391 NEIGHBOR_STR
2392 NEIGHBOR_ADDR_STR2
2393 "Configure treatment of outgoing link-local nexthop attribute\n"
2394 "Leave link-local nexthop unchanged for this peer\n")
2395{
2396 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2397 bgp_node_safi (vty),
2398 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
2399}
2400
2401DEFUN (no_neighbor_nexthop_local_unchanged,
2402 no_neighbor_nexthop_local_unchanged_cmd,
2403 NO_NEIGHBOR_CMD2 "nexthop-local unchanged",
2404 NO_STR
2405 NEIGHBOR_STR
2406 NEIGHBOR_ADDR_STR2
2407 "Configure treatment of outgoing link-local-nexthop attribute\n"
2408 "Leave link-local nexthop unchanged for this peer\n")
2409{
paul718e3742002-12-13 20:15:29 +00002410 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2411 bgp_node_safi (vty),
paulfee0f4c2004-09-13 05:12:46 +00002412 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
paul718e3742002-12-13 20:15:29 +00002413}
2414
2415DEFUN (neighbor_attr_unchanged,
2416 neighbor_attr_unchanged_cmd,
2417 NEIGHBOR_CMD2 "attribute-unchanged",
2418 NEIGHBOR_STR
2419 NEIGHBOR_ADDR_STR2
2420 "BGP attribute is propagated unchanged to this neighbor\n")
2421{
2422 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2423 bgp_node_safi (vty),
2424 (PEER_FLAG_AS_PATH_UNCHANGED |
2425 PEER_FLAG_NEXTHOP_UNCHANGED |
2426 PEER_FLAG_MED_UNCHANGED));
2427}
2428
2429DEFUN (neighbor_attr_unchanged1,
2430 neighbor_attr_unchanged1_cmd,
2431 NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
2432 NEIGHBOR_STR
2433 NEIGHBOR_ADDR_STR2
2434 "BGP attribute is propagated unchanged to this neighbor\n"
2435 "As-path attribute\n"
2436 "Nexthop attribute\n"
2437 "Med attribute\n")
2438{
2439 u_int16_t flags = 0;
2440
2441 if (strncmp (argv[1], "as-path", 1) == 0)
2442 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2443 else if (strncmp (argv[1], "next-hop", 1) == 0)
2444 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2445 else if (strncmp (argv[1], "med", 1) == 0)
2446 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2447
2448 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2449 bgp_node_safi (vty), flags);
2450}
2451
2452DEFUN (neighbor_attr_unchanged2,
2453 neighbor_attr_unchanged2_cmd,
2454 NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
2455 NEIGHBOR_STR
2456 NEIGHBOR_ADDR_STR2
2457 "BGP attribute is propagated unchanged to this neighbor\n"
2458 "As-path attribute\n"
2459 "Nexthop attribute\n"
2460 "Med attribute\n")
2461{
2462 u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
2463
2464 if (strncmp (argv[1], "next-hop", 1) == 0)
2465 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2466 else if (strncmp (argv[1], "med", 1) == 0)
2467 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2468
2469 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2470 bgp_node_safi (vty), flags);
2471
2472}
2473
2474DEFUN (neighbor_attr_unchanged3,
2475 neighbor_attr_unchanged3_cmd,
2476 NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
2477 NEIGHBOR_STR
2478 NEIGHBOR_ADDR_STR2
2479 "BGP attribute is propagated unchanged to this neighbor\n"
2480 "Nexthop attribute\n"
2481 "As-path attribute\n"
2482 "Med attribute\n")
2483{
2484 u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
2485
2486 if (strncmp (argv[1], "as-path", 1) == 0)
2487 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2488 else if (strncmp (argv[1], "med", 1) == 0)
2489 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2490
2491 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2492 bgp_node_safi (vty), flags);
2493}
2494
2495DEFUN (neighbor_attr_unchanged4,
2496 neighbor_attr_unchanged4_cmd,
2497 NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
2498 NEIGHBOR_STR
2499 NEIGHBOR_ADDR_STR2
2500 "BGP attribute is propagated unchanged to this neighbor\n"
2501 "Med attribute\n"
2502 "As-path attribute\n"
2503 "Nexthop attribute\n")
2504{
2505 u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
2506
2507 if (strncmp (argv[1], "as-path", 1) == 0)
2508 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2509 else if (strncmp (argv[1], "next-hop", 1) == 0)
2510 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2511
2512 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2513 bgp_node_safi (vty), flags);
2514}
2515
2516ALIAS (neighbor_attr_unchanged,
2517 neighbor_attr_unchanged5_cmd,
2518 NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
2519 NEIGHBOR_STR
2520 NEIGHBOR_ADDR_STR2
2521 "BGP attribute is propagated unchanged to this neighbor\n"
2522 "As-path attribute\n"
2523 "Nexthop attribute\n"
2524 "Med attribute\n")
2525
2526ALIAS (neighbor_attr_unchanged,
2527 neighbor_attr_unchanged6_cmd,
2528 NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
2529 NEIGHBOR_STR
2530 NEIGHBOR_ADDR_STR2
2531 "BGP attribute is propagated unchanged to this neighbor\n"
2532 "As-path attribute\n"
2533 "Med attribute\n"
2534 "Nexthop attribute\n")
2535
2536ALIAS (neighbor_attr_unchanged,
2537 neighbor_attr_unchanged7_cmd,
2538 NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
2539 NEIGHBOR_STR
2540 NEIGHBOR_ADDR_STR2
2541 "BGP attribute is propagated unchanged to this neighbor\n"
2542 "Nexthop attribute\n"
2543 "Med attribute\n"
2544 "As-path attribute\n")
2545
2546ALIAS (neighbor_attr_unchanged,
2547 neighbor_attr_unchanged8_cmd,
2548 NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
2549 NEIGHBOR_STR
2550 NEIGHBOR_ADDR_STR2
2551 "BGP attribute is propagated unchanged to this neighbor\n"
2552 "Nexthop attribute\n"
2553 "As-path attribute\n"
2554 "Med attribute\n")
2555
2556ALIAS (neighbor_attr_unchanged,
2557 neighbor_attr_unchanged9_cmd,
2558 NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
2559 NEIGHBOR_STR
2560 NEIGHBOR_ADDR_STR2
2561 "BGP attribute is propagated unchanged to this neighbor\n"
2562 "Med attribute\n"
2563 "Nexthop attribute\n"
2564 "As-path attribute\n")
2565
2566ALIAS (neighbor_attr_unchanged,
2567 neighbor_attr_unchanged10_cmd,
2568 NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
2569 NEIGHBOR_STR
2570 NEIGHBOR_ADDR_STR2
2571 "BGP attribute is propagated unchanged to this neighbor\n"
2572 "Med attribute\n"
2573 "As-path attribute\n"
2574 "Nexthop attribute\n")
2575
2576DEFUN (no_neighbor_attr_unchanged,
2577 no_neighbor_attr_unchanged_cmd,
2578 NO_NEIGHBOR_CMD2 "attribute-unchanged",
2579 NO_STR
2580 NEIGHBOR_STR
2581 NEIGHBOR_ADDR_STR2
2582 "BGP attribute is propagated unchanged to this neighbor\n")
2583{
2584 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2585 bgp_node_safi (vty),
2586 (PEER_FLAG_AS_PATH_UNCHANGED |
2587 PEER_FLAG_NEXTHOP_UNCHANGED |
2588 PEER_FLAG_MED_UNCHANGED));
2589}
2590
2591DEFUN (no_neighbor_attr_unchanged1,
2592 no_neighbor_attr_unchanged1_cmd,
2593 NO_NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
2594 NO_STR
2595 NEIGHBOR_STR
2596 NEIGHBOR_ADDR_STR2
2597 "BGP attribute is propagated unchanged to this neighbor\n"
2598 "As-path attribute\n"
2599 "Nexthop attribute\n"
2600 "Med attribute\n")
2601{
2602 u_int16_t flags = 0;
2603
2604 if (strncmp (argv[1], "as-path", 1) == 0)
2605 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2606 else if (strncmp (argv[1], "next-hop", 1) == 0)
2607 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2608 else if (strncmp (argv[1], "med", 1) == 0)
2609 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2610
2611 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2612 bgp_node_safi (vty), flags);
2613}
2614
2615DEFUN (no_neighbor_attr_unchanged2,
2616 no_neighbor_attr_unchanged2_cmd,
2617 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
2618 NO_STR
2619 NEIGHBOR_STR
2620 NEIGHBOR_ADDR_STR2
2621 "BGP attribute is propagated unchanged to this neighbor\n"
2622 "As-path attribute\n"
2623 "Nexthop attribute\n"
2624 "Med attribute\n")
2625{
2626 u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
2627
2628 if (strncmp (argv[1], "next-hop", 1) == 0)
2629 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2630 else if (strncmp (argv[1], "med", 1) == 0)
2631 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2632
2633 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2634 bgp_node_safi (vty), flags);
2635}
2636
2637DEFUN (no_neighbor_attr_unchanged3,
2638 no_neighbor_attr_unchanged3_cmd,
2639 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
2640 NO_STR
2641 NEIGHBOR_STR
2642 NEIGHBOR_ADDR_STR2
2643 "BGP attribute is propagated unchanged to this neighbor\n"
2644 "Nexthop attribute\n"
2645 "As-path attribute\n"
2646 "Med attribute\n")
2647{
2648 u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
2649
2650 if (strncmp (argv[1], "as-path", 1) == 0)
2651 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2652 else if (strncmp (argv[1], "med", 1) == 0)
2653 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2654
2655 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2656 bgp_node_safi (vty), flags);
2657}
2658
2659DEFUN (no_neighbor_attr_unchanged4,
2660 no_neighbor_attr_unchanged4_cmd,
2661 NO_NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
2662 NO_STR
2663 NEIGHBOR_STR
2664 NEIGHBOR_ADDR_STR2
2665 "BGP attribute is propagated unchanged to this neighbor\n"
2666 "Med attribute\n"
2667 "As-path attribute\n"
2668 "Nexthop attribute\n")
2669{
2670 u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
2671
2672 if (strncmp (argv[1], "as-path", 1) == 0)
2673 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2674 else if (strncmp (argv[1], "next-hop", 1) == 0)
2675 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2676
2677 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2678 bgp_node_safi (vty), flags);
2679}
2680
2681ALIAS (no_neighbor_attr_unchanged,
2682 no_neighbor_attr_unchanged5_cmd,
2683 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
2684 NO_STR
2685 NEIGHBOR_STR
2686 NEIGHBOR_ADDR_STR2
2687 "BGP attribute is propagated unchanged to this neighbor\n"
2688 "As-path attribute\n"
2689 "Nexthop attribute\n"
2690 "Med attribute\n")
2691
2692ALIAS (no_neighbor_attr_unchanged,
2693 no_neighbor_attr_unchanged6_cmd,
2694 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
2695 NO_STR
2696 NEIGHBOR_STR
2697 NEIGHBOR_ADDR_STR2
2698 "BGP attribute is propagated unchanged to this neighbor\n"
2699 "As-path attribute\n"
2700 "Med attribute\n"
2701 "Nexthop attribute\n")
2702
2703ALIAS (no_neighbor_attr_unchanged,
2704 no_neighbor_attr_unchanged7_cmd,
2705 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
2706 NO_STR
2707 NEIGHBOR_STR
2708 NEIGHBOR_ADDR_STR2
2709 "BGP attribute is propagated unchanged to this neighbor\n"
2710 "Nexthop attribute\n"
2711 "Med attribute\n"
2712 "As-path attribute\n")
2713
2714ALIAS (no_neighbor_attr_unchanged,
2715 no_neighbor_attr_unchanged8_cmd,
2716 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
2717 NO_STR
2718 NEIGHBOR_STR
2719 NEIGHBOR_ADDR_STR2
2720 "BGP attribute is propagated unchanged to this neighbor\n"
2721 "Nexthop attribute\n"
2722 "As-path attribute\n"
2723 "Med attribute\n")
2724
2725ALIAS (no_neighbor_attr_unchanged,
2726 no_neighbor_attr_unchanged9_cmd,
2727 NO_NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
2728 NO_STR
2729 NEIGHBOR_STR
2730 NEIGHBOR_ADDR_STR2
2731 "BGP attribute is propagated unchanged to this neighbor\n"
2732 "Med attribute\n"
2733 "Nexthop attribute\n"
2734 "As-path attribute\n")
2735
2736ALIAS (no_neighbor_attr_unchanged,
2737 no_neighbor_attr_unchanged10_cmd,
2738 NO_NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
2739 NO_STR
2740 NEIGHBOR_STR
2741 NEIGHBOR_ADDR_STR2
2742 "BGP attribute is propagated unchanged to this neighbor\n"
2743 "Med attribute\n"
2744 "As-path attribute\n"
2745 "Nexthop attribute\n")
2746
2747/* For old version Zebra compatibility. */
hassodd4c5932005-02-02 17:15:34 +00002748DEFUN_DEPRECATED (neighbor_transparent_as,
2749 neighbor_transparent_as_cmd,
2750 NEIGHBOR_CMD "transparent-as",
2751 NEIGHBOR_STR
2752 NEIGHBOR_ADDR_STR
2753 "Do not append my AS number even peer is EBGP peer\n")
paul718e3742002-12-13 20:15:29 +00002754{
2755 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2756 bgp_node_safi (vty),
2757 PEER_FLAG_AS_PATH_UNCHANGED);
2758}
2759
hassodd4c5932005-02-02 17:15:34 +00002760DEFUN_DEPRECATED (neighbor_transparent_nexthop,
2761 neighbor_transparent_nexthop_cmd,
2762 NEIGHBOR_CMD "transparent-nexthop",
2763 NEIGHBOR_STR
2764 NEIGHBOR_ADDR_STR
2765 "Do not change nexthop even peer is EBGP peer\n")
paul718e3742002-12-13 20:15:29 +00002766{
2767 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2768 bgp_node_safi (vty),
2769 PEER_FLAG_NEXTHOP_UNCHANGED);
2770}
2771
2772/* EBGP multihop configuration. */
paul94f2b392005-06-28 12:44:16 +00002773static int
paulfd79ac92004-10-13 05:06:08 +00002774peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str,
2775 const char *ttl_str)
paul718e3742002-12-13 20:15:29 +00002776{
2777 struct peer *peer;
paulfd79ac92004-10-13 05:06:08 +00002778 unsigned int ttl;
paul718e3742002-12-13 20:15:29 +00002779
2780 peer = peer_and_group_lookup_vty (vty, ip_str);
2781 if (! peer)
2782 return CMD_WARNING;
2783
2784 if (! ttl_str)
2785 ttl = TTL_MAX;
2786 else
2787 VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, 255);
2788
Stephen Hemminger89b6d1f2011-03-24 10:51:59 +00002789 return bgp_vty_return (vty, peer_ebgp_multihop_set (peer, ttl));
paul718e3742002-12-13 20:15:29 +00002790}
2791
paul94f2b392005-06-28 12:44:16 +00002792static int
paulfd79ac92004-10-13 05:06:08 +00002793peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str)
paul718e3742002-12-13 20:15:29 +00002794{
2795 struct peer *peer;
2796
2797 peer = peer_and_group_lookup_vty (vty, ip_str);
2798 if (! peer)
2799 return CMD_WARNING;
2800
Stephen Hemminger89b6d1f2011-03-24 10:51:59 +00002801 return bgp_vty_return (vty, peer_ebgp_multihop_unset (peer));
paul718e3742002-12-13 20:15:29 +00002802}
2803
2804/* neighbor ebgp-multihop. */
2805DEFUN (neighbor_ebgp_multihop,
2806 neighbor_ebgp_multihop_cmd,
2807 NEIGHBOR_CMD2 "ebgp-multihop",
2808 NEIGHBOR_STR
2809 NEIGHBOR_ADDR_STR2
2810 "Allow EBGP neighbors not on directly connected networks\n")
2811{
2812 return peer_ebgp_multihop_set_vty (vty, argv[0], NULL);
2813}
2814
2815DEFUN (neighbor_ebgp_multihop_ttl,
2816 neighbor_ebgp_multihop_ttl_cmd,
2817 NEIGHBOR_CMD2 "ebgp-multihop <1-255>",
2818 NEIGHBOR_STR
2819 NEIGHBOR_ADDR_STR2
2820 "Allow EBGP neighbors not on directly connected networks\n"
2821 "maximum hop count\n")
2822{
2823 return peer_ebgp_multihop_set_vty (vty, argv[0], argv[1]);
2824}
2825
2826DEFUN (no_neighbor_ebgp_multihop,
2827 no_neighbor_ebgp_multihop_cmd,
2828 NO_NEIGHBOR_CMD2 "ebgp-multihop",
2829 NO_STR
2830 NEIGHBOR_STR
2831 NEIGHBOR_ADDR_STR2
2832 "Allow EBGP neighbors not on directly connected networks\n")
2833{
2834 return peer_ebgp_multihop_unset_vty (vty, argv[0]);
2835}
2836
2837ALIAS (no_neighbor_ebgp_multihop,
2838 no_neighbor_ebgp_multihop_ttl_cmd,
2839 NO_NEIGHBOR_CMD2 "ebgp-multihop <1-255>",
2840 NO_STR
2841 NEIGHBOR_STR
2842 NEIGHBOR_ADDR_STR2
2843 "Allow EBGP neighbors not on directly connected networks\n"
2844 "maximum hop count\n")
2845
hasso6ffd2072005-02-02 14:50:11 +00002846/* disable-connected-check */
2847DEFUN (neighbor_disable_connected_check,
2848 neighbor_disable_connected_check_cmd,
2849 NEIGHBOR_CMD2 "disable-connected-check",
2850 NEIGHBOR_STR
2851 NEIGHBOR_ADDR_STR2
2852 "one-hop away EBGP peer using loopback address\n")
2853{
2854 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
2855}
2856
2857DEFUN (no_neighbor_disable_connected_check,
2858 no_neighbor_disable_connected_check_cmd,
2859 NO_NEIGHBOR_CMD2 "disable-connected-check",
2860 NO_STR
2861 NEIGHBOR_STR
2862 NEIGHBOR_ADDR_STR2
2863 "one-hop away EBGP peer using loopback address\n")
2864{
2865 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
2866}
2867
paul718e3742002-12-13 20:15:29 +00002868/* Enforce multihop. */
hasso6ffd2072005-02-02 14:50:11 +00002869ALIAS (neighbor_disable_connected_check,
paul718e3742002-12-13 20:15:29 +00002870 neighbor_enforce_multihop_cmd,
2871 NEIGHBOR_CMD2 "enforce-multihop",
2872 NEIGHBOR_STR
2873 NEIGHBOR_ADDR_STR2
paule8e19462006-01-19 20:16:55 +00002874 "Enforce EBGP neighbors perform multihop\n")
paul718e3742002-12-13 20:15:29 +00002875
hasso6ffd2072005-02-02 14:50:11 +00002876/* Enforce multihop. */
2877ALIAS (no_neighbor_disable_connected_check,
paul718e3742002-12-13 20:15:29 +00002878 no_neighbor_enforce_multihop_cmd,
2879 NO_NEIGHBOR_CMD2 "enforce-multihop",
2880 NO_STR
2881 NEIGHBOR_STR
2882 NEIGHBOR_ADDR_STR2
paule8e19462006-01-19 20:16:55 +00002883 "Enforce EBGP neighbors perform multihop\n")
paul718e3742002-12-13 20:15:29 +00002884
2885DEFUN (neighbor_description,
2886 neighbor_description_cmd,
2887 NEIGHBOR_CMD2 "description .LINE",
2888 NEIGHBOR_STR
2889 NEIGHBOR_ADDR_STR2
2890 "Neighbor specific description\n"
2891 "Up to 80 characters describing this neighbor\n")
2892{
2893 struct peer *peer;
paul718e3742002-12-13 20:15:29 +00002894 char *str;
paul718e3742002-12-13 20:15:29 +00002895
2896 peer = peer_and_group_lookup_vty (vty, argv[0]);
2897 if (! peer)
2898 return CMD_WARNING;
2899
2900 if (argc == 1)
2901 return CMD_SUCCESS;
2902
ajs3b8b1852005-01-29 18:19:13 +00002903 str = argv_concat(argv, argc, 1);
paul718e3742002-12-13 20:15:29 +00002904
2905 peer_description_set (peer, str);
2906
ajs3b8b1852005-01-29 18:19:13 +00002907 XFREE (MTYPE_TMP, str);
paul718e3742002-12-13 20:15:29 +00002908
2909 return CMD_SUCCESS;
2910}
2911
2912DEFUN (no_neighbor_description,
2913 no_neighbor_description_cmd,
2914 NO_NEIGHBOR_CMD2 "description",
2915 NO_STR
2916 NEIGHBOR_STR
2917 NEIGHBOR_ADDR_STR2
2918 "Neighbor specific description\n")
2919{
2920 struct peer *peer;
2921
2922 peer = peer_and_group_lookup_vty (vty, argv[0]);
2923 if (! peer)
2924 return CMD_WARNING;
2925
2926 peer_description_unset (peer);
2927
2928 return CMD_SUCCESS;
2929}
2930
2931ALIAS (no_neighbor_description,
2932 no_neighbor_description_val_cmd,
2933 NO_NEIGHBOR_CMD2 "description .LINE",
2934 NO_STR
2935 NEIGHBOR_STR
2936 NEIGHBOR_ADDR_STR2
2937 "Neighbor specific description\n"
2938 "Up to 80 characters describing this neighbor\n")
2939
2940/* Neighbor update-source. */
paul94f2b392005-06-28 12:44:16 +00002941static int
paulfd79ac92004-10-13 05:06:08 +00002942peer_update_source_vty (struct vty *vty, const char *peer_str,
2943 const char *source_str)
paul718e3742002-12-13 20:15:29 +00002944{
2945 struct peer *peer;
2946 union sockunion *su;
2947
2948 peer = peer_and_group_lookup_vty (vty, peer_str);
2949 if (! peer)
2950 return CMD_WARNING;
2951
2952 if (source_str)
2953 {
2954 su = sockunion_str2su (source_str);
2955 if (su)
2956 {
2957 peer_update_source_addr_set (peer, su);
2958 sockunion_free (su);
2959 }
2960 else
2961 peer_update_source_if_set (peer, source_str);
2962 }
2963 else
2964 peer_update_source_unset (peer);
2965
2966 return CMD_SUCCESS;
2967}
2968
Paul Jakma9a1a3312009-07-27 12:27:55 +01002969#define BGP_UPDATE_SOURCE_STR "(A.B.C.D|X:X::X:X|WORD)"
Paul Jakma369688c2006-05-23 22:27:55 +00002970#define BGP_UPDATE_SOURCE_HELP_STR \
2971 "IPv4 address\n" \
Paul Jakma9a1a3312009-07-27 12:27:55 +01002972 "IPv6 address\n" \
2973 "Interface name (requires zebra to be running)\n"
Paul Jakma369688c2006-05-23 22:27:55 +00002974
paul718e3742002-12-13 20:15:29 +00002975DEFUN (neighbor_update_source,
2976 neighbor_update_source_cmd,
Paul Jakma369688c2006-05-23 22:27:55 +00002977 NEIGHBOR_CMD2 "update-source " BGP_UPDATE_SOURCE_STR,
paul718e3742002-12-13 20:15:29 +00002978 NEIGHBOR_STR
2979 NEIGHBOR_ADDR_STR2
2980 "Source of routing updates\n"
Paul Jakma369688c2006-05-23 22:27:55 +00002981 BGP_UPDATE_SOURCE_HELP_STR)
paul718e3742002-12-13 20:15:29 +00002982{
2983 return peer_update_source_vty (vty, argv[0], argv[1]);
2984}
2985
2986DEFUN (no_neighbor_update_source,
2987 no_neighbor_update_source_cmd,
2988 NO_NEIGHBOR_CMD2 "update-source",
2989 NO_STR
2990 NEIGHBOR_STR
2991 NEIGHBOR_ADDR_STR2
Paul Jakma369688c2006-05-23 22:27:55 +00002992 "Source of routing updates\n")
paul718e3742002-12-13 20:15:29 +00002993{
2994 return peer_update_source_vty (vty, argv[0], NULL);
2995}
2996
paul94f2b392005-06-28 12:44:16 +00002997static int
paulfd79ac92004-10-13 05:06:08 +00002998peer_default_originate_set_vty (struct vty *vty, const char *peer_str,
2999 afi_t afi, safi_t safi,
3000 const char *rmap, int set)
paul718e3742002-12-13 20:15:29 +00003001{
3002 int ret;
3003 struct peer *peer;
3004
3005 peer = peer_and_group_lookup_vty (vty, peer_str);
3006 if (! peer)
3007 return CMD_WARNING;
3008
3009 if (set)
3010 ret = peer_default_originate_set (peer, afi, safi, rmap);
3011 else
3012 ret = peer_default_originate_unset (peer, afi, safi);
3013
3014 return bgp_vty_return (vty, ret);
3015}
3016
3017/* neighbor default-originate. */
3018DEFUN (neighbor_default_originate,
3019 neighbor_default_originate_cmd,
3020 NEIGHBOR_CMD2 "default-originate",
3021 NEIGHBOR_STR
3022 NEIGHBOR_ADDR_STR2
3023 "Originate default route to this neighbor\n")
3024{
3025 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
3026 bgp_node_safi (vty), NULL, 1);
3027}
3028
3029DEFUN (neighbor_default_originate_rmap,
3030 neighbor_default_originate_rmap_cmd,
3031 NEIGHBOR_CMD2 "default-originate route-map WORD",
3032 NEIGHBOR_STR
3033 NEIGHBOR_ADDR_STR2
3034 "Originate default route to this neighbor\n"
3035 "Route-map to specify criteria to originate default\n"
3036 "route-map name\n")
3037{
3038 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
3039 bgp_node_safi (vty), argv[1], 1);
3040}
3041
3042DEFUN (no_neighbor_default_originate,
3043 no_neighbor_default_originate_cmd,
3044 NO_NEIGHBOR_CMD2 "default-originate",
3045 NO_STR
3046 NEIGHBOR_STR
3047 NEIGHBOR_ADDR_STR2
3048 "Originate default route to this neighbor\n")
3049{
3050 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
3051 bgp_node_safi (vty), NULL, 0);
3052}
3053
3054ALIAS (no_neighbor_default_originate,
3055 no_neighbor_default_originate_rmap_cmd,
3056 NO_NEIGHBOR_CMD2 "default-originate route-map WORD",
3057 NO_STR
3058 NEIGHBOR_STR
3059 NEIGHBOR_ADDR_STR2
3060 "Originate default route to this neighbor\n"
3061 "Route-map to specify criteria to originate default\n"
3062 "route-map name\n")
3063
3064/* Set neighbor's BGP port. */
paul94f2b392005-06-28 12:44:16 +00003065static int
paulfd79ac92004-10-13 05:06:08 +00003066peer_port_vty (struct vty *vty, const char *ip_str, int afi,
3067 const char *port_str)
paul718e3742002-12-13 20:15:29 +00003068{
3069 struct peer *peer;
3070 u_int16_t port;
3071 struct servent *sp;
3072
3073 peer = peer_lookup_vty (vty, ip_str);
3074 if (! peer)
3075 return CMD_WARNING;
3076
3077 if (! port_str)
3078 {
3079 sp = getservbyname ("bgp", "tcp");
3080 port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port);
3081 }
3082 else
3083 {
3084 VTY_GET_INTEGER("port", port, port_str);
3085 }
3086
3087 peer_port_set (peer, port);
3088
3089 return CMD_SUCCESS;
3090}
3091
hassof4184462005-02-01 20:13:16 +00003092/* Set specified peer's BGP port. */
paul718e3742002-12-13 20:15:29 +00003093DEFUN (neighbor_port,
3094 neighbor_port_cmd,
3095 NEIGHBOR_CMD "port <0-65535>",
3096 NEIGHBOR_STR
3097 NEIGHBOR_ADDR_STR
3098 "Neighbor's BGP port\n"
3099 "TCP port number\n")
3100{
3101 return peer_port_vty (vty, argv[0], AFI_IP, argv[1]);
3102}
3103
3104DEFUN (no_neighbor_port,
3105 no_neighbor_port_cmd,
3106 NO_NEIGHBOR_CMD "port",
3107 NO_STR
3108 NEIGHBOR_STR
3109 NEIGHBOR_ADDR_STR
3110 "Neighbor's BGP port\n")
3111{
3112 return peer_port_vty (vty, argv[0], AFI_IP, NULL);
3113}
3114
3115ALIAS (no_neighbor_port,
3116 no_neighbor_port_val_cmd,
3117 NO_NEIGHBOR_CMD "port <0-65535>",
3118 NO_STR
3119 NEIGHBOR_STR
3120 NEIGHBOR_ADDR_STR
3121 "Neighbor's BGP port\n"
3122 "TCP port number\n")
3123
3124/* neighbor weight. */
paul94f2b392005-06-28 12:44:16 +00003125static int
paulfd79ac92004-10-13 05:06:08 +00003126peer_weight_set_vty (struct vty *vty, const char *ip_str,
3127 const char *weight_str)
paul718e3742002-12-13 20:15:29 +00003128{
3129 int ret;
3130 struct peer *peer;
3131 unsigned long weight;
3132
3133 peer = peer_and_group_lookup_vty (vty, ip_str);
3134 if (! peer)
3135 return CMD_WARNING;
3136
3137 VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535);
3138
3139 ret = peer_weight_set (peer, weight);
3140
3141 return CMD_SUCCESS;
3142}
3143
paul94f2b392005-06-28 12:44:16 +00003144static int
paulfd79ac92004-10-13 05:06:08 +00003145peer_weight_unset_vty (struct vty *vty, const char *ip_str)
paul718e3742002-12-13 20:15:29 +00003146{
3147 struct peer *peer;
3148
3149 peer = peer_and_group_lookup_vty (vty, ip_str);
3150 if (! peer)
3151 return CMD_WARNING;
3152
3153 peer_weight_unset (peer);
3154
3155 return CMD_SUCCESS;
3156}
3157
3158DEFUN (neighbor_weight,
3159 neighbor_weight_cmd,
3160 NEIGHBOR_CMD2 "weight <0-65535>",
3161 NEIGHBOR_STR
3162 NEIGHBOR_ADDR_STR2
3163 "Set default weight for routes from this neighbor\n"
3164 "default weight\n")
3165{
3166 return peer_weight_set_vty (vty, argv[0], argv[1]);
3167}
3168
3169DEFUN (no_neighbor_weight,
3170 no_neighbor_weight_cmd,
3171 NO_NEIGHBOR_CMD2 "weight",
3172 NO_STR
3173 NEIGHBOR_STR
3174 NEIGHBOR_ADDR_STR2
3175 "Set default weight for routes from this neighbor\n")
3176{
3177 return peer_weight_unset_vty (vty, argv[0]);
3178}
3179
3180ALIAS (no_neighbor_weight,
3181 no_neighbor_weight_val_cmd,
3182 NO_NEIGHBOR_CMD2 "weight <0-65535>",
3183 NO_STR
3184 NEIGHBOR_STR
3185 NEIGHBOR_ADDR_STR2
3186 "Set default weight for routes from this neighbor\n"
3187 "default weight\n")
3188
3189/* Override capability negotiation. */
3190DEFUN (neighbor_override_capability,
3191 neighbor_override_capability_cmd,
3192 NEIGHBOR_CMD2 "override-capability",
3193 NEIGHBOR_STR
3194 NEIGHBOR_ADDR_STR2
3195 "Override capability negotiation result\n")
3196{
3197 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
3198}
3199
3200DEFUN (no_neighbor_override_capability,
3201 no_neighbor_override_capability_cmd,
3202 NO_NEIGHBOR_CMD2 "override-capability",
3203 NO_STR
3204 NEIGHBOR_STR
3205 NEIGHBOR_ADDR_STR2
3206 "Override capability negotiation result\n")
3207{
3208 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
3209}
3210
3211DEFUN (neighbor_strict_capability,
3212 neighbor_strict_capability_cmd,
3213 NEIGHBOR_CMD "strict-capability-match",
3214 NEIGHBOR_STR
3215 NEIGHBOR_ADDR_STR
3216 "Strict capability negotiation match\n")
3217{
3218 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
3219}
3220
3221DEFUN (no_neighbor_strict_capability,
3222 no_neighbor_strict_capability_cmd,
3223 NO_NEIGHBOR_CMD "strict-capability-match",
3224 NO_STR
3225 NEIGHBOR_STR
3226 NEIGHBOR_ADDR_STR
3227 "Strict capability negotiation match\n")
3228{
3229 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
3230}
3231
paul94f2b392005-06-28 12:44:16 +00003232static int
paulfd79ac92004-10-13 05:06:08 +00003233peer_timers_set_vty (struct vty *vty, const char *ip_str,
3234 const char *keep_str, const char *hold_str)
paul718e3742002-12-13 20:15:29 +00003235{
3236 int ret;
3237 struct peer *peer;
3238 u_int32_t keepalive;
3239 u_int32_t holdtime;
3240
3241 peer = peer_and_group_lookup_vty (vty, ip_str);
3242 if (! peer)
3243 return CMD_WARNING;
3244
3245 VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535);
3246 VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535);
3247
3248 ret = peer_timers_set (peer, keepalive, holdtime);
3249
3250 return bgp_vty_return (vty, ret);
3251}
3252
paul94f2b392005-06-28 12:44:16 +00003253static int
paulfd79ac92004-10-13 05:06:08 +00003254peer_timers_unset_vty (struct vty *vty, const char *ip_str)
paul718e3742002-12-13 20:15:29 +00003255{
3256 int ret;
3257 struct peer *peer;
3258
3259 peer = peer_lookup_vty (vty, ip_str);
3260 if (! peer)
3261 return CMD_WARNING;
3262
3263 ret = peer_timers_unset (peer);
3264
3265 return bgp_vty_return (vty, ret);
3266}
3267
3268DEFUN (neighbor_timers,
3269 neighbor_timers_cmd,
3270 NEIGHBOR_CMD2 "timers <0-65535> <0-65535>",
3271 NEIGHBOR_STR
3272 NEIGHBOR_ADDR_STR2
3273 "BGP per neighbor timers\n"
3274 "Keepalive interval\n"
3275 "Holdtime\n")
3276{
3277 return peer_timers_set_vty (vty, argv[0], argv[1], argv[2]);
3278}
3279
3280DEFUN (no_neighbor_timers,
3281 no_neighbor_timers_cmd,
3282 NO_NEIGHBOR_CMD2 "timers",
3283 NO_STR
3284 NEIGHBOR_STR
3285 NEIGHBOR_ADDR_STR2
3286 "BGP per neighbor timers\n")
3287{
3288 return peer_timers_unset_vty (vty, argv[0]);
3289}
3290
paul94f2b392005-06-28 12:44:16 +00003291static int
paulfd79ac92004-10-13 05:06:08 +00003292peer_timers_connect_set_vty (struct vty *vty, const char *ip_str,
3293 const char *time_str)
paul718e3742002-12-13 20:15:29 +00003294{
3295 int ret;
3296 struct peer *peer;
3297 u_int32_t connect;
3298
3299 peer = peer_lookup_vty (vty, ip_str);
3300 if (! peer)
3301 return CMD_WARNING;
3302
3303 VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535);
3304
3305 ret = peer_timers_connect_set (peer, connect);
3306
3307 return CMD_SUCCESS;
3308}
3309
paul94f2b392005-06-28 12:44:16 +00003310static int
paulfd79ac92004-10-13 05:06:08 +00003311peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str)
paul718e3742002-12-13 20:15:29 +00003312{
3313 int ret;
3314 struct peer *peer;
3315
3316 peer = peer_and_group_lookup_vty (vty, ip_str);
3317 if (! peer)
3318 return CMD_WARNING;
3319
3320 ret = peer_timers_connect_unset (peer);
3321
3322 return CMD_SUCCESS;
3323}
3324
3325DEFUN (neighbor_timers_connect,
3326 neighbor_timers_connect_cmd,
3327 NEIGHBOR_CMD "timers connect <0-65535>",
3328 NEIGHBOR_STR
3329 NEIGHBOR_ADDR_STR
3330 "BGP per neighbor timers\n"
3331 "BGP connect timer\n"
3332 "Connect timer\n")
3333{
3334 return peer_timers_connect_set_vty (vty, argv[0], argv[1]);
3335}
3336
3337DEFUN (no_neighbor_timers_connect,
3338 no_neighbor_timers_connect_cmd,
3339 NO_NEIGHBOR_CMD "timers connect",
3340 NO_STR
3341 NEIGHBOR_STR
3342 NEIGHBOR_ADDR_STR
3343 "BGP per neighbor timers\n"
3344 "BGP connect timer\n")
3345{
3346 return peer_timers_connect_unset_vty (vty, argv[0]);
3347}
3348
3349ALIAS (no_neighbor_timers_connect,
3350 no_neighbor_timers_connect_val_cmd,
3351 NO_NEIGHBOR_CMD "timers connect <0-65535>",
3352 NO_STR
3353 NEIGHBOR_STR
3354 NEIGHBOR_ADDR_STR
3355 "BGP per neighbor timers\n"
3356 "BGP connect timer\n"
3357 "Connect timer\n")
3358
paul94f2b392005-06-28 12:44:16 +00003359static int
paulfd79ac92004-10-13 05:06:08 +00003360peer_advertise_interval_vty (struct vty *vty, const char *ip_str,
3361 const char *time_str, int set)
paul718e3742002-12-13 20:15:29 +00003362{
3363 int ret;
3364 struct peer *peer;
3365 u_int32_t routeadv = 0;
3366
3367 peer = peer_lookup_vty (vty, ip_str);
3368 if (! peer)
3369 return CMD_WARNING;
3370
3371 if (time_str)
3372 VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600);
3373
3374 if (set)
3375 ret = peer_advertise_interval_set (peer, routeadv);
3376 else
3377 ret = peer_advertise_interval_unset (peer);
3378
3379 return CMD_SUCCESS;
3380}
3381
3382DEFUN (neighbor_advertise_interval,
3383 neighbor_advertise_interval_cmd,
3384 NEIGHBOR_CMD "advertisement-interval <0-600>",
3385 NEIGHBOR_STR
3386 NEIGHBOR_ADDR_STR
3387 "Minimum interval between sending BGP routing updates\n"
3388 "time in seconds\n")
3389{
3390 return peer_advertise_interval_vty (vty, argv[0], argv[1], 1);
3391}
3392
3393DEFUN (no_neighbor_advertise_interval,
3394 no_neighbor_advertise_interval_cmd,
3395 NO_NEIGHBOR_CMD "advertisement-interval",
3396 NO_STR
3397 NEIGHBOR_STR
3398 NEIGHBOR_ADDR_STR
3399 "Minimum interval between sending BGP routing updates\n")
3400{
3401 return peer_advertise_interval_vty (vty, argv[0], NULL, 0);
3402}
3403
3404ALIAS (no_neighbor_advertise_interval,
3405 no_neighbor_advertise_interval_val_cmd,
3406 NO_NEIGHBOR_CMD "advertisement-interval <0-600>",
3407 NO_STR
3408 NEIGHBOR_STR
3409 NEIGHBOR_ADDR_STR
3410 "Minimum interval between sending BGP routing updates\n"
3411 "time in seconds\n")
3412
paul718e3742002-12-13 20:15:29 +00003413/* neighbor interface */
paul94f2b392005-06-28 12:44:16 +00003414static int
paulfd79ac92004-10-13 05:06:08 +00003415peer_interface_vty (struct vty *vty, const char *ip_str, const char *str)
paul718e3742002-12-13 20:15:29 +00003416{
3417 int ret;
3418 struct peer *peer;
3419
3420 peer = peer_lookup_vty (vty, ip_str);
3421 if (! peer)
3422 return CMD_WARNING;
3423
3424 if (str)
3425 ret = peer_interface_set (peer, str);
3426 else
3427 ret = peer_interface_unset (peer);
3428
3429 return CMD_SUCCESS;
3430}
3431
3432DEFUN (neighbor_interface,
3433 neighbor_interface_cmd,
3434 NEIGHBOR_CMD "interface WORD",
3435 NEIGHBOR_STR
3436 NEIGHBOR_ADDR_STR
3437 "Interface\n"
3438 "Interface name\n")
3439{
3440 return peer_interface_vty (vty, argv[0], argv[1]);
3441}
3442
3443DEFUN (no_neighbor_interface,
3444 no_neighbor_interface_cmd,
3445 NO_NEIGHBOR_CMD "interface WORD",
3446 NO_STR
3447 NEIGHBOR_STR
3448 NEIGHBOR_ADDR_STR
3449 "Interface\n"
3450 "Interface name\n")
3451{
3452 return peer_interface_vty (vty, argv[0], NULL);
3453}
3454
3455/* Set distribute list to the peer. */
paul94f2b392005-06-28 12:44:16 +00003456static int
paulfd79ac92004-10-13 05:06:08 +00003457peer_distribute_set_vty (struct vty *vty, const char *ip_str,
3458 afi_t afi, safi_t safi,
3459 const char *name_str, const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003460{
3461 int ret;
3462 struct peer *peer;
3463 int direct = FILTER_IN;
3464
3465 peer = peer_and_group_lookup_vty (vty, ip_str);
3466 if (! peer)
3467 return CMD_WARNING;
3468
3469 /* Check filter direction. */
3470 if (strncmp (direct_str, "i", 1) == 0)
3471 direct = FILTER_IN;
3472 else if (strncmp (direct_str, "o", 1) == 0)
3473 direct = FILTER_OUT;
3474
3475 ret = peer_distribute_set (peer, afi, safi, direct, name_str);
3476
3477 return bgp_vty_return (vty, ret);
3478}
3479
paul94f2b392005-06-28 12:44:16 +00003480static int
paulfd79ac92004-10-13 05:06:08 +00003481peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
3482 safi_t safi, const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003483{
3484 int ret;
3485 struct peer *peer;
3486 int direct = FILTER_IN;
3487
3488 peer = peer_and_group_lookup_vty (vty, ip_str);
3489 if (! peer)
3490 return CMD_WARNING;
3491
3492 /* Check filter direction. */
3493 if (strncmp (direct_str, "i", 1) == 0)
3494 direct = FILTER_IN;
3495 else if (strncmp (direct_str, "o", 1) == 0)
3496 direct = FILTER_OUT;
3497
3498 ret = peer_distribute_unset (peer, afi, safi, direct);
3499
3500 return bgp_vty_return (vty, ret);
3501}
3502
3503DEFUN (neighbor_distribute_list,
3504 neighbor_distribute_list_cmd,
3505 NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
3506 NEIGHBOR_STR
3507 NEIGHBOR_ADDR_STR2
3508 "Filter updates to/from this neighbor\n"
3509 "IP access-list number\n"
3510 "IP access-list number (expanded range)\n"
3511 "IP Access-list name\n"
3512 "Filter incoming updates\n"
3513 "Filter outgoing updates\n")
3514{
3515 return peer_distribute_set_vty (vty, argv[0], bgp_node_afi (vty),
3516 bgp_node_safi (vty), argv[1], argv[2]);
3517}
3518
3519DEFUN (no_neighbor_distribute_list,
3520 no_neighbor_distribute_list_cmd,
3521 NO_NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
3522 NO_STR
3523 NEIGHBOR_STR
3524 NEIGHBOR_ADDR_STR2
3525 "Filter updates to/from this neighbor\n"
3526 "IP access-list number\n"
3527 "IP access-list number (expanded range)\n"
3528 "IP Access-list name\n"
3529 "Filter incoming updates\n"
3530 "Filter outgoing updates\n")
3531{
3532 return peer_distribute_unset_vty (vty, argv[0], bgp_node_afi (vty),
3533 bgp_node_safi (vty), argv[2]);
3534}
3535
3536/* Set prefix list to the peer. */
paul94f2b392005-06-28 12:44:16 +00003537static int
paulfd79ac92004-10-13 05:06:08 +00003538peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
3539 safi_t safi, const char *name_str,
3540 const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003541{
3542 int ret;
3543 struct peer *peer;
3544 int direct = FILTER_IN;
3545
3546 peer = peer_and_group_lookup_vty (vty, ip_str);
3547 if (! peer)
3548 return CMD_WARNING;
3549
3550 /* Check filter direction. */
3551 if (strncmp (direct_str, "i", 1) == 0)
3552 direct = FILTER_IN;
3553 else if (strncmp (direct_str, "o", 1) == 0)
3554 direct = FILTER_OUT;
3555
3556 ret = peer_prefix_list_set (peer, afi, safi, direct, name_str);
3557
3558 return bgp_vty_return (vty, ret);
3559}
3560
paul94f2b392005-06-28 12:44:16 +00003561static int
paulfd79ac92004-10-13 05:06:08 +00003562peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
3563 safi_t safi, const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003564{
3565 int ret;
3566 struct peer *peer;
3567 int direct = FILTER_IN;
3568
3569 peer = peer_and_group_lookup_vty (vty, ip_str);
3570 if (! peer)
3571 return CMD_WARNING;
3572
3573 /* Check filter direction. */
3574 if (strncmp (direct_str, "i", 1) == 0)
3575 direct = FILTER_IN;
3576 else if (strncmp (direct_str, "o", 1) == 0)
3577 direct = FILTER_OUT;
3578
3579 ret = peer_prefix_list_unset (peer, afi, safi, direct);
3580
3581 return bgp_vty_return (vty, ret);
3582}
3583
3584DEFUN (neighbor_prefix_list,
3585 neighbor_prefix_list_cmd,
3586 NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
3587 NEIGHBOR_STR
3588 NEIGHBOR_ADDR_STR2
3589 "Filter updates to/from this neighbor\n"
3590 "Name of a prefix list\n"
3591 "Filter incoming updates\n"
3592 "Filter outgoing updates\n")
3593{
3594 return peer_prefix_list_set_vty (vty, argv[0], bgp_node_afi (vty),
3595 bgp_node_safi (vty), argv[1], argv[2]);
3596}
3597
3598DEFUN (no_neighbor_prefix_list,
3599 no_neighbor_prefix_list_cmd,
3600 NO_NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
3601 NO_STR
3602 NEIGHBOR_STR
3603 NEIGHBOR_ADDR_STR2
3604 "Filter updates to/from this neighbor\n"
3605 "Name of a prefix list\n"
3606 "Filter incoming updates\n"
3607 "Filter outgoing updates\n")
3608{
3609 return peer_prefix_list_unset_vty (vty, argv[0], bgp_node_afi (vty),
3610 bgp_node_safi (vty), argv[2]);
3611}
3612
paul94f2b392005-06-28 12:44:16 +00003613static int
paulfd79ac92004-10-13 05:06:08 +00003614peer_aslist_set_vty (struct vty *vty, const char *ip_str,
3615 afi_t afi, safi_t safi,
3616 const char *name_str, const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003617{
3618 int ret;
3619 struct peer *peer;
3620 int direct = FILTER_IN;
3621
3622 peer = peer_and_group_lookup_vty (vty, ip_str);
3623 if (! peer)
3624 return CMD_WARNING;
3625
3626 /* Check filter direction. */
3627 if (strncmp (direct_str, "i", 1) == 0)
3628 direct = FILTER_IN;
3629 else if (strncmp (direct_str, "o", 1) == 0)
3630 direct = FILTER_OUT;
3631
3632 ret = peer_aslist_set (peer, afi, safi, direct, name_str);
3633
3634 return bgp_vty_return (vty, ret);
3635}
3636
paul94f2b392005-06-28 12:44:16 +00003637static int
paulfd79ac92004-10-13 05:06:08 +00003638peer_aslist_unset_vty (struct vty *vty, const char *ip_str,
3639 afi_t afi, safi_t safi,
3640 const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003641{
3642 int ret;
3643 struct peer *peer;
3644 int direct = FILTER_IN;
3645
3646 peer = peer_and_group_lookup_vty (vty, ip_str);
3647 if (! peer)
3648 return CMD_WARNING;
3649
3650 /* Check filter direction. */
3651 if (strncmp (direct_str, "i", 1) == 0)
3652 direct = FILTER_IN;
3653 else if (strncmp (direct_str, "o", 1) == 0)
3654 direct = FILTER_OUT;
3655
3656 ret = peer_aslist_unset (peer, afi, safi, direct);
3657
3658 return bgp_vty_return (vty, ret);
3659}
3660
3661DEFUN (neighbor_filter_list,
3662 neighbor_filter_list_cmd,
3663 NEIGHBOR_CMD2 "filter-list WORD (in|out)",
3664 NEIGHBOR_STR
3665 NEIGHBOR_ADDR_STR2
3666 "Establish BGP filters\n"
3667 "AS path access-list name\n"
3668 "Filter incoming routes\n"
3669 "Filter outgoing routes\n")
3670{
3671 return peer_aslist_set_vty (vty, argv[0], bgp_node_afi (vty),
3672 bgp_node_safi (vty), argv[1], argv[2]);
3673}
3674
3675DEFUN (no_neighbor_filter_list,
3676 no_neighbor_filter_list_cmd,
3677 NO_NEIGHBOR_CMD2 "filter-list WORD (in|out)",
3678 NO_STR
3679 NEIGHBOR_STR
3680 NEIGHBOR_ADDR_STR2
3681 "Establish BGP filters\n"
3682 "AS path access-list name\n"
3683 "Filter incoming routes\n"
3684 "Filter outgoing routes\n")
3685{
3686 return peer_aslist_unset_vty (vty, argv[0], bgp_node_afi (vty),
3687 bgp_node_safi (vty), argv[2]);
3688}
3689
3690/* Set route-map to the peer. */
paul94f2b392005-06-28 12:44:16 +00003691static int
paulfd79ac92004-10-13 05:06:08 +00003692peer_route_map_set_vty (struct vty *vty, const char *ip_str,
3693 afi_t afi, safi_t safi,
3694 const char *name_str, const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003695{
3696 int ret;
3697 struct peer *peer;
paulfee0f4c2004-09-13 05:12:46 +00003698 int direct = RMAP_IN;
paul718e3742002-12-13 20:15:29 +00003699
3700 peer = peer_and_group_lookup_vty (vty, ip_str);
3701 if (! peer)
3702 return CMD_WARNING;
3703
3704 /* Check filter direction. */
paulfee0f4c2004-09-13 05:12:46 +00003705 if (strncmp (direct_str, "in", 2) == 0)
3706 direct = RMAP_IN;
paul718e3742002-12-13 20:15:29 +00003707 else if (strncmp (direct_str, "o", 1) == 0)
paulfee0f4c2004-09-13 05:12:46 +00003708 direct = RMAP_OUT;
3709 else if (strncmp (direct_str, "im", 2) == 0)
3710 direct = RMAP_IMPORT;
3711 else if (strncmp (direct_str, "e", 1) == 0)
3712 direct = RMAP_EXPORT;
paul718e3742002-12-13 20:15:29 +00003713
3714 ret = peer_route_map_set (peer, afi, safi, direct, name_str);
3715
3716 return bgp_vty_return (vty, ret);
3717}
3718
paul94f2b392005-06-28 12:44:16 +00003719static int
paulfd79ac92004-10-13 05:06:08 +00003720peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
3721 safi_t safi, const char *direct_str)
paul718e3742002-12-13 20:15:29 +00003722{
3723 int ret;
3724 struct peer *peer;
paulfee0f4c2004-09-13 05:12:46 +00003725 int direct = RMAP_IN;
paul718e3742002-12-13 20:15:29 +00003726
3727 peer = peer_and_group_lookup_vty (vty, ip_str);
3728 if (! peer)
3729 return CMD_WARNING;
3730
3731 /* Check filter direction. */
paulfee0f4c2004-09-13 05:12:46 +00003732 if (strncmp (direct_str, "in", 2) == 0)
3733 direct = RMAP_IN;
paul718e3742002-12-13 20:15:29 +00003734 else if (strncmp (direct_str, "o", 1) == 0)
paulfee0f4c2004-09-13 05:12:46 +00003735 direct = RMAP_OUT;
3736 else if (strncmp (direct_str, "im", 2) == 0)
3737 direct = RMAP_IMPORT;
3738 else if (strncmp (direct_str, "e", 1) == 0)
3739 direct = RMAP_EXPORT;
paul718e3742002-12-13 20:15:29 +00003740
3741 ret = peer_route_map_unset (peer, afi, safi, direct);
3742
3743 return bgp_vty_return (vty, ret);
3744}
3745
3746DEFUN (neighbor_route_map,
3747 neighbor_route_map_cmd,
paulfee0f4c2004-09-13 05:12:46 +00003748 NEIGHBOR_CMD2 "route-map WORD (in|out|import|export)",
paul718e3742002-12-13 20:15:29 +00003749 NEIGHBOR_STR
3750 NEIGHBOR_ADDR_STR2
3751 "Apply route map to neighbor\n"
3752 "Name of route map\n"
3753 "Apply map to incoming routes\n"
paulfee0f4c2004-09-13 05:12:46 +00003754 "Apply map to outbound routes\n"
3755 "Apply map to routes going into a Route-Server client's table\n"
3756 "Apply map to routes coming from a Route-Server client")
paul718e3742002-12-13 20:15:29 +00003757{
3758 return peer_route_map_set_vty (vty, argv[0], bgp_node_afi (vty),
3759 bgp_node_safi (vty), argv[1], argv[2]);
3760}
3761
3762DEFUN (no_neighbor_route_map,
3763 no_neighbor_route_map_cmd,
paulfee0f4c2004-09-13 05:12:46 +00003764 NO_NEIGHBOR_CMD2 "route-map WORD (in|out|import|export)",
paul718e3742002-12-13 20:15:29 +00003765 NO_STR
3766 NEIGHBOR_STR
3767 NEIGHBOR_ADDR_STR2
3768 "Apply route map to neighbor\n"
3769 "Name of route map\n"
3770 "Apply map to incoming routes\n"
paulfee0f4c2004-09-13 05:12:46 +00003771 "Apply map to outbound routes\n"
3772 "Apply map to routes going into a Route-Server client's table\n"
3773 "Apply map to routes coming from a Route-Server client")
paul718e3742002-12-13 20:15:29 +00003774{
3775 return peer_route_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
3776 bgp_node_safi (vty), argv[2]);
3777}
3778
3779/* Set unsuppress-map to the peer. */
paul94f2b392005-06-28 12:44:16 +00003780static int
paulfd79ac92004-10-13 05:06:08 +00003781peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
3782 safi_t safi, const char *name_str)
paul718e3742002-12-13 20:15:29 +00003783{
3784 int ret;
3785 struct peer *peer;
3786
3787 peer = peer_and_group_lookup_vty (vty, ip_str);
3788 if (! peer)
3789 return CMD_WARNING;
3790
3791 ret = peer_unsuppress_map_set (peer, afi, safi, name_str);
3792
3793 return bgp_vty_return (vty, ret);
3794}
3795
3796/* Unset route-map from the peer. */
paul94f2b392005-06-28 12:44:16 +00003797static int
paulfd79ac92004-10-13 05:06:08 +00003798peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00003799 safi_t safi)
3800{
3801 int ret;
3802 struct peer *peer;
3803
3804 peer = peer_and_group_lookup_vty (vty, ip_str);
3805 if (! peer)
3806 return CMD_WARNING;
3807
3808 ret = peer_unsuppress_map_unset (peer, afi, safi);
3809
3810 return bgp_vty_return (vty, ret);
3811}
3812
3813DEFUN (neighbor_unsuppress_map,
3814 neighbor_unsuppress_map_cmd,
3815 NEIGHBOR_CMD2 "unsuppress-map WORD",
3816 NEIGHBOR_STR
3817 NEIGHBOR_ADDR_STR2
3818 "Route-map to selectively unsuppress suppressed routes\n"
3819 "Name of route map\n")
3820{
3821 return peer_unsuppress_map_set_vty (vty, argv[0], bgp_node_afi (vty),
3822 bgp_node_safi (vty), argv[1]);
3823}
3824
3825DEFUN (no_neighbor_unsuppress_map,
3826 no_neighbor_unsuppress_map_cmd,
3827 NO_NEIGHBOR_CMD2 "unsuppress-map WORD",
3828 NO_STR
3829 NEIGHBOR_STR
3830 NEIGHBOR_ADDR_STR2
3831 "Route-map to selectively unsuppress suppressed routes\n"
3832 "Name of route map\n")
3833{
3834 return peer_unsuppress_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
3835 bgp_node_safi (vty));
3836}
3837
paul94f2b392005-06-28 12:44:16 +00003838static int
paulfd79ac92004-10-13 05:06:08 +00003839peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
3840 safi_t safi, const char *num_str,
hasso0a486e52005-02-01 20:57:17 +00003841 const char *threshold_str, int warning,
3842 const char *restart_str)
paul718e3742002-12-13 20:15:29 +00003843{
3844 int ret;
3845 struct peer *peer;
3846 u_int32_t max;
hassoe0701b72004-05-20 09:19:34 +00003847 u_char threshold;
hasso0a486e52005-02-01 20:57:17 +00003848 u_int16_t restart;
paul718e3742002-12-13 20:15:29 +00003849
3850 peer = peer_and_group_lookup_vty (vty, ip_str);
3851 if (! peer)
3852 return CMD_WARNING;
3853
3854 VTY_GET_INTEGER ("maxmum number", max, num_str);
hassoe0701b72004-05-20 09:19:34 +00003855 if (threshold_str)
3856 threshold = atoi (threshold_str);
3857 else
3858 threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003859
hasso0a486e52005-02-01 20:57:17 +00003860 if (restart_str)
3861 restart = atoi (restart_str);
3862 else
3863 restart = 0;
3864
3865 ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart);
paul718e3742002-12-13 20:15:29 +00003866
3867 return bgp_vty_return (vty, ret);
3868}
3869
paul94f2b392005-06-28 12:44:16 +00003870static int
paulfd79ac92004-10-13 05:06:08 +00003871peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00003872 safi_t safi)
3873{
3874 int ret;
3875 struct peer *peer;
3876
3877 peer = peer_and_group_lookup_vty (vty, ip_str);
3878 if (! peer)
3879 return CMD_WARNING;
3880
3881 ret = peer_maximum_prefix_unset (peer, afi, safi);
3882
3883 return bgp_vty_return (vty, ret);
3884}
3885
3886/* Maximum number of prefix configuration. prefix count is different
3887 for each peer configuration. So this configuration can be set for
3888 each peer configuration. */
3889DEFUN (neighbor_maximum_prefix,
3890 neighbor_maximum_prefix_cmd,
3891 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
3892 NEIGHBOR_STR
3893 NEIGHBOR_ADDR_STR2
3894 "Maximum number of prefix accept from this peer\n"
3895 "maximum no. of prefix limit\n")
3896{
3897 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
hasso0a486e52005-02-01 20:57:17 +00003898 bgp_node_safi (vty), argv[1], NULL, 0,
3899 NULL);
paul718e3742002-12-13 20:15:29 +00003900}
3901
hassoe0701b72004-05-20 09:19:34 +00003902DEFUN (neighbor_maximum_prefix_threshold,
3903 neighbor_maximum_prefix_threshold_cmd,
3904 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100>",
3905 NEIGHBOR_STR
3906 NEIGHBOR_ADDR_STR2
3907 "Maximum number of prefix accept from this peer\n"
3908 "maximum no. of prefix limit\n"
3909 "Threshold value (%) at which to generate a warning msg\n")
3910{
3911 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
hasso0a486e52005-02-01 20:57:17 +00003912 bgp_node_safi (vty), argv[1], argv[2], 0,
3913 NULL);
3914}
hassoe0701b72004-05-20 09:19:34 +00003915
paul718e3742002-12-13 20:15:29 +00003916DEFUN (neighbor_maximum_prefix_warning,
3917 neighbor_maximum_prefix_warning_cmd,
3918 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
3919 NEIGHBOR_STR
3920 NEIGHBOR_ADDR_STR2
3921 "Maximum number of prefix accept from this peer\n"
3922 "maximum no. of prefix limit\n"
3923 "Only give warning message when limit is exceeded\n")
3924{
3925 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
hasso0a486e52005-02-01 20:57:17 +00003926 bgp_node_safi (vty), argv[1], NULL, 1,
3927 NULL);
paul718e3742002-12-13 20:15:29 +00003928}
3929
hassoe0701b72004-05-20 09:19:34 +00003930DEFUN (neighbor_maximum_prefix_threshold_warning,
3931 neighbor_maximum_prefix_threshold_warning_cmd,
3932 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
3933 NEIGHBOR_STR
3934 NEIGHBOR_ADDR_STR2
3935 "Maximum number of prefix accept from this peer\n"
3936 "maximum no. of prefix limit\n"
3937 "Threshold value (%) at which to generate a warning msg\n"
3938 "Only give warning message when limit is exceeded\n")
3939{
3940 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
hasso0a486e52005-02-01 20:57:17 +00003941 bgp_node_safi (vty), argv[1], argv[2], 1, NULL);
3942}
3943
3944DEFUN (neighbor_maximum_prefix_restart,
3945 neighbor_maximum_prefix_restart_cmd,
3946 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
3947 NEIGHBOR_STR
3948 NEIGHBOR_ADDR_STR2
3949 "Maximum number of prefix accept from this peer\n"
3950 "maximum no. of prefix limit\n"
3951 "Restart bgp connection after limit is exceeded\n"
3952 "Restart interval in minutes")
3953{
3954 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
3955 bgp_node_safi (vty), argv[1], NULL, 0, argv[2]);
3956}
3957
3958DEFUN (neighbor_maximum_prefix_threshold_restart,
3959 neighbor_maximum_prefix_threshold_restart_cmd,
3960 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
3961 NEIGHBOR_STR
3962 NEIGHBOR_ADDR_STR2
3963 "Maximum number of prefix accept from this peer\n"
3964 "maximum no. of prefix limit\n"
3965 "Threshold value (%) at which to generate a warning msg\n"
3966 "Restart bgp connection after limit is exceeded\n"
3967 "Restart interval in minutes")
3968{
3969 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
3970 bgp_node_safi (vty), argv[1], argv[2], 0, argv[3]);
3971}
hassoe0701b72004-05-20 09:19:34 +00003972
paul718e3742002-12-13 20:15:29 +00003973DEFUN (no_neighbor_maximum_prefix,
3974 no_neighbor_maximum_prefix_cmd,
3975 NO_NEIGHBOR_CMD2 "maximum-prefix",
3976 NO_STR
3977 NEIGHBOR_STR
3978 NEIGHBOR_ADDR_STR2
3979 "Maximum number of prefix accept from this peer\n")
3980{
3981 return peer_maximum_prefix_unset_vty (vty, argv[0], bgp_node_afi (vty),
3982 bgp_node_safi (vty));
3983}
3984
3985ALIAS (no_neighbor_maximum_prefix,
3986 no_neighbor_maximum_prefix_val_cmd,
3987 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
3988 NO_STR
3989 NEIGHBOR_STR
3990 NEIGHBOR_ADDR_STR2
3991 "Maximum number of prefix accept from this peer\n"
3992 "maximum no. of prefix limit\n")
3993
3994ALIAS (no_neighbor_maximum_prefix,
hasso0a486e52005-02-01 20:57:17 +00003995 no_neighbor_maximum_prefix_threshold_cmd,
3996 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
3997 NO_STR
3998 NEIGHBOR_STR
3999 NEIGHBOR_ADDR_STR2
4000 "Maximum number of prefix accept from this peer\n"
4001 "maximum no. of prefix limit\n"
4002 "Threshold value (%) at which to generate a warning msg\n")
4003
4004ALIAS (no_neighbor_maximum_prefix,
4005 no_neighbor_maximum_prefix_warning_cmd,
4006 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
4007 NO_STR
4008 NEIGHBOR_STR
4009 NEIGHBOR_ADDR_STR2
4010 "Maximum number of prefix accept from this peer\n"
4011 "maximum no. of prefix limit\n"
paule8e19462006-01-19 20:16:55 +00004012 "Only give warning message when limit is exceeded\n")
hasso0a486e52005-02-01 20:57:17 +00004013
4014ALIAS (no_neighbor_maximum_prefix,
4015 no_neighbor_maximum_prefix_threshold_warning_cmd,
hassoe0701b72004-05-20 09:19:34 +00004016 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
4017 NO_STR
4018 NEIGHBOR_STR
4019 NEIGHBOR_ADDR_STR2
4020 "Maximum number of prefix accept from this peer\n"
4021 "maximum no. of prefix limit\n"
4022 "Threshold value (%) at which to generate a warning msg\n"
paule8e19462006-01-19 20:16:55 +00004023 "Only give warning message when limit is exceeded\n")
hassoe0701b72004-05-20 09:19:34 +00004024
4025ALIAS (no_neighbor_maximum_prefix,
hasso0a486e52005-02-01 20:57:17 +00004026 no_neighbor_maximum_prefix_restart_cmd,
4027 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
paul718e3742002-12-13 20:15:29 +00004028 NO_STR
4029 NEIGHBOR_STR
4030 NEIGHBOR_ADDR_STR2
4031 "Maximum number of prefix accept from this peer\n"
4032 "maximum no. of prefix limit\n"
hasso0a486e52005-02-01 20:57:17 +00004033 "Restart bgp connection after limit is exceeded\n"
4034 "Restart interval in minutes")
4035
4036ALIAS (no_neighbor_maximum_prefix,
4037 no_neighbor_maximum_prefix_threshold_restart_cmd,
4038 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
4039 NO_STR
4040 NEIGHBOR_STR
4041 NEIGHBOR_ADDR_STR2
4042 "Maximum number of prefix accept from this peer\n"
4043 "maximum no. of prefix limit\n"
4044 "Threshold value (%) at which to generate a warning msg\n"
4045 "Restart bgp connection after limit is exceeded\n"
4046 "Restart interval in minutes")
paul718e3742002-12-13 20:15:29 +00004047
4048/* "neighbor allowas-in" */
4049DEFUN (neighbor_allowas_in,
4050 neighbor_allowas_in_cmd,
4051 NEIGHBOR_CMD2 "allowas-in",
4052 NEIGHBOR_STR
4053 NEIGHBOR_ADDR_STR2
4054 "Accept as-path with my AS present in it\n")
4055{
4056 int ret;
4057 struct peer *peer;
paulfd79ac92004-10-13 05:06:08 +00004058 unsigned int allow_num;
paul718e3742002-12-13 20:15:29 +00004059
4060 peer = peer_and_group_lookup_vty (vty, argv[0]);
4061 if (! peer)
4062 return CMD_WARNING;
4063
4064 if (argc == 1)
4065 allow_num = 3;
4066 else
4067 VTY_GET_INTEGER_RANGE ("AS number", allow_num, argv[1], 1, 10);
4068
4069 ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty),
4070 allow_num);
4071
4072 return bgp_vty_return (vty, ret);
4073}
4074
4075ALIAS (neighbor_allowas_in,
4076 neighbor_allowas_in_arg_cmd,
4077 NEIGHBOR_CMD2 "allowas-in <1-10>",
4078 NEIGHBOR_STR
4079 NEIGHBOR_ADDR_STR2
4080 "Accept as-path with my AS present in it\n"
4081 "Number of occurances of AS number\n")
4082
4083DEFUN (no_neighbor_allowas_in,
4084 no_neighbor_allowas_in_cmd,
4085 NO_NEIGHBOR_CMD2 "allowas-in",
4086 NO_STR
4087 NEIGHBOR_STR
4088 NEIGHBOR_ADDR_STR2
4089 "allow local ASN appears in aspath attribute\n")
4090{
4091 int ret;
4092 struct peer *peer;
4093
4094 peer = peer_and_group_lookup_vty (vty, argv[0]);
4095 if (! peer)
4096 return CMD_WARNING;
4097
4098 ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty));
4099
4100 return bgp_vty_return (vty, ret);
4101}
4102
Nick Hilliardfa411a22011-03-23 15:33:17 +00004103DEFUN (neighbor_ttl_security,
4104 neighbor_ttl_security_cmd,
4105 NEIGHBOR_CMD2 "ttl-security hops <1-254>",
4106 NEIGHBOR_STR
4107 NEIGHBOR_ADDR_STR2
4108 "Specify the maximum number of hops to the BGP peer\n")
4109{
4110 struct peer *peer;
Stephen Hemminger89b6d1f2011-03-24 10:51:59 +00004111 int gtsm_hops;
Nick Hilliardfa411a22011-03-23 15:33:17 +00004112
4113 peer = peer_and_group_lookup_vty (vty, argv[0]);
4114 if (! peer)
4115 return CMD_WARNING;
4116
4117 VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[1], 1, 254);
4118
Stephen Hemminger89b6d1f2011-03-24 10:51:59 +00004119 return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, gtsm_hops));
Nick Hilliardfa411a22011-03-23 15:33:17 +00004120}
4121
4122DEFUN (no_neighbor_ttl_security,
4123 no_neighbor_ttl_security_cmd,
4124 NO_NEIGHBOR_CMD2 "ttl-security hops <1-254>",
4125 NO_STR
4126 NEIGHBOR_STR
4127 NEIGHBOR_ADDR_STR2
4128 "Specify the maximum number of hops to the BGP peer\n")
4129{
4130 struct peer *peer;
Nick Hilliardfa411a22011-03-23 15:33:17 +00004131
4132 peer = peer_and_group_lookup_vty (vty, argv[0]);
4133 if (! peer)
4134 return CMD_WARNING;
4135
Stephen Hemminger89b6d1f2011-03-24 10:51:59 +00004136 return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer));
Nick Hilliardfa411a22011-03-23 15:33:17 +00004137}
4138
paul718e3742002-12-13 20:15:29 +00004139/* Address family configuration. */
4140DEFUN (address_family_ipv4,
4141 address_family_ipv4_cmd,
4142 "address-family ipv4",
4143 "Enter Address Family command mode\n"
4144 "Address family\n")
4145{
4146 vty->node = BGP_IPV4_NODE;
4147 return CMD_SUCCESS;
4148}
4149
4150DEFUN (address_family_ipv4_safi,
4151 address_family_ipv4_safi_cmd,
4152 "address-family ipv4 (unicast|multicast)",
4153 "Enter Address Family command mode\n"
4154 "Address family\n"
4155 "Address Family modifier\n"
4156 "Address Family modifier\n")
4157{
4158 if (strncmp (argv[0], "m", 1) == 0)
4159 vty->node = BGP_IPV4M_NODE;
4160 else
4161 vty->node = BGP_IPV4_NODE;
4162
4163 return CMD_SUCCESS;
4164}
4165
paul25ffbdc2005-08-22 22:42:08 +00004166DEFUN (address_family_ipv6,
4167 address_family_ipv6_cmd,
4168 "address-family ipv6",
paul718e3742002-12-13 20:15:29 +00004169 "Enter Address Family command mode\n"
paul25ffbdc2005-08-22 22:42:08 +00004170 "Address family\n")
paul718e3742002-12-13 20:15:29 +00004171{
4172 vty->node = BGP_IPV6_NODE;
4173 return CMD_SUCCESS;
4174}
4175
paul25ffbdc2005-08-22 22:42:08 +00004176DEFUN (address_family_ipv6_safi,
4177 address_family_ipv6_safi_cmd,
4178 "address-family ipv6 (unicast|multicast)",
paul718e3742002-12-13 20:15:29 +00004179 "Enter Address Family command mode\n"
paul25ffbdc2005-08-22 22:42:08 +00004180 "Address family\n"
4181 "Address Family modifier\n"
4182 "Address Family modifier\n")
4183{
4184 if (strncmp (argv[0], "m", 1) == 0)
4185 vty->node = BGP_IPV6M_NODE;
4186 else
4187 vty->node = BGP_IPV6_NODE;
4188
4189 return CMD_SUCCESS;
4190}
paul718e3742002-12-13 20:15:29 +00004191
4192DEFUN (address_family_vpnv4,
4193 address_family_vpnv4_cmd,
4194 "address-family vpnv4",
4195 "Enter Address Family command mode\n"
4196 "Address family\n")
4197{
4198 vty->node = BGP_VPNV4_NODE;
4199 return CMD_SUCCESS;
4200}
4201
4202ALIAS (address_family_vpnv4,
4203 address_family_vpnv4_unicast_cmd,
4204 "address-family vpnv4 unicast",
4205 "Enter Address Family command mode\n"
4206 "Address family\n"
4207 "Address Family Modifier\n")
4208
4209DEFUN (exit_address_family,
4210 exit_address_family_cmd,
4211 "exit-address-family",
4212 "Exit from Address Family configuration mode\n")
4213{
hassoa8a80d52005-04-09 13:07:47 +00004214 if (vty->node == BGP_IPV4_NODE
4215 || vty->node == BGP_IPV4M_NODE
paul718e3742002-12-13 20:15:29 +00004216 || vty->node == BGP_VPNV4_NODE
paul25ffbdc2005-08-22 22:42:08 +00004217 || vty->node == BGP_IPV6_NODE
4218 || vty->node == BGP_IPV6M_NODE)
paul718e3742002-12-13 20:15:29 +00004219 vty->node = BGP_NODE;
4220 return CMD_SUCCESS;
4221}
4222
4223/* BGP clear sort. */
4224enum clear_sort
4225{
4226 clear_all,
4227 clear_peer,
4228 clear_group,
4229 clear_external,
4230 clear_as
4231};
4232
paul94f2b392005-06-28 12:44:16 +00004233static void
paul718e3742002-12-13 20:15:29 +00004234bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi,
4235 safi_t safi, int error)
4236{
4237 switch (error)
4238 {
4239 case BGP_ERR_AF_UNCONFIGURED:
4240 vty_out (vty,
4241 "%%BGP: Enable %s %s address family for the neighbor %s%s",
4242 afi == AFI_IP6 ? "IPv6" : safi == SAFI_MPLS_VPN ? "VPNv4" : "IPv4",
4243 safi == SAFI_MULTICAST ? "Multicast" : "Unicast",
4244 peer->host, VTY_NEWLINE);
4245 break;
4246 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED:
4247 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);
4248 break;
4249 default:
4250 break;
4251 }
4252}
4253
4254/* `clear ip bgp' functions. */
paul94f2b392005-06-28 12:44:16 +00004255static int
paul718e3742002-12-13 20:15:29 +00004256bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
paulfd79ac92004-10-13 05:06:08 +00004257 enum clear_sort sort,enum bgp_clear_type stype, const char *arg)
paul718e3742002-12-13 20:15:29 +00004258{
4259 int ret;
4260 struct peer *peer;
paul1eb8ef22005-04-07 07:30:20 +00004261 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00004262
4263 /* Clear all neighbors. */
4264 if (sort == clear_all)
4265 {
paul1eb8ef22005-04-07 07:30:20 +00004266 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00004267 {
4268 if (stype == BGP_CLEAR_SOFT_NONE)
4269 ret = peer_clear (peer);
4270 else
4271 ret = peer_clear_soft (peer, afi, safi, stype);
4272
4273 if (ret < 0)
4274 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4275 }
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004276 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00004277 }
4278
4279 /* Clear specified neighbors. */
4280 if (sort == clear_peer)
4281 {
4282 union sockunion su;
4283 int ret;
4284
4285 /* Make sockunion for lookup. */
4286 ret = str2sockunion (arg, &su);
4287 if (ret < 0)
4288 {
4289 vty_out (vty, "Malformed address: %s%s", arg, VTY_NEWLINE);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004290 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +00004291 }
4292 peer = peer_lookup (bgp, &su);
4293 if (! peer)
4294 {
4295 vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004296 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +00004297 }
4298
4299 if (stype == BGP_CLEAR_SOFT_NONE)
4300 ret = peer_clear (peer);
4301 else
4302 ret = peer_clear_soft (peer, afi, safi, stype);
4303
4304 if (ret < 0)
4305 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4306
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004307 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00004308 }
4309
4310 /* Clear all peer-group members. */
4311 if (sort == clear_group)
4312 {
4313 struct peer_group *group;
4314
4315 group = peer_group_lookup (bgp, arg);
4316 if (! group)
4317 {
4318 vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004319 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +00004320 }
4321
paul1eb8ef22005-04-07 07:30:20 +00004322 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00004323 {
4324 if (stype == BGP_CLEAR_SOFT_NONE)
4325 {
4326 ret = peer_clear (peer);
4327 continue;
4328 }
4329
4330 if (! peer->af_group[afi][safi])
4331 continue;
4332
4333 ret = peer_clear_soft (peer, afi, safi, stype);
4334
4335 if (ret < 0)
4336 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4337 }
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004338 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00004339 }
4340
4341 if (sort == clear_external)
4342 {
paul1eb8ef22005-04-07 07:30:20 +00004343 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00004344 {
4345 if (peer_sort (peer) == BGP_PEER_IBGP)
4346 continue;
4347
4348 if (stype == BGP_CLEAR_SOFT_NONE)
4349 ret = peer_clear (peer);
4350 else
4351 ret = peer_clear_soft (peer, afi, safi, stype);
4352
4353 if (ret < 0)
4354 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4355 }
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004356 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00004357 }
4358
4359 if (sort == clear_as)
4360 {
4361 as_t as;
4362 unsigned long as_ul;
paul718e3742002-12-13 20:15:29 +00004363 int find = 0;
4364
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004365 VTY_GET_LONG ("AS", as_ul, arg);
4366
4367 if (!as_ul)
paul718e3742002-12-13 20:15:29 +00004368 {
4369 vty_out (vty, "Invalid AS number%s", VTY_NEWLINE);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004370 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +00004371 }
4372 as = (as_t) as_ul;
4373
paul1eb8ef22005-04-07 07:30:20 +00004374 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00004375 {
4376 if (peer->as != as)
4377 continue;
4378
4379 find = 1;
4380 if (stype == BGP_CLEAR_SOFT_NONE)
4381 ret = peer_clear (peer);
4382 else
4383 ret = peer_clear_soft (peer, afi, safi, stype);
4384
4385 if (ret < 0)
4386 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4387 }
4388 if (! find)
4389 vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg,
4390 VTY_NEWLINE);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004391 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00004392 }
4393
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004394 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00004395}
4396
paul94f2b392005-06-28 12:44:16 +00004397static int
paulfd79ac92004-10-13 05:06:08 +00004398bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi,
4399 enum clear_sort sort, enum bgp_clear_type stype,
4400 const char *arg)
paul718e3742002-12-13 20:15:29 +00004401{
paul718e3742002-12-13 20:15:29 +00004402 struct bgp *bgp;
4403
4404 /* BGP structure lookup. */
4405 if (name)
4406 {
4407 bgp = bgp_lookup_by_name (name);
4408 if (bgp == NULL)
4409 {
4410 vty_out (vty, "Can't find BGP view %s%s", name, VTY_NEWLINE);
4411 return CMD_WARNING;
4412 }
4413 }
4414 else
4415 {
4416 bgp = bgp_get_default ();
4417 if (bgp == NULL)
4418 {
4419 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
4420 return CMD_WARNING;
4421 }
4422 }
4423
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00004424 return bgp_clear (vty, bgp, afi, safi, sort, stype, arg);
paul718e3742002-12-13 20:15:29 +00004425}
4426
4427DEFUN (clear_ip_bgp_all,
4428 clear_ip_bgp_all_cmd,
4429 "clear ip bgp *",
4430 CLEAR_STR
4431 IP_STR
4432 BGP_STR
4433 "Clear all peers\n")
4434{
4435 if (argc == 1)
4436 return bgp_clear_vty (vty, argv[0], 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
4437
4438 return bgp_clear_vty (vty, NULL, 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
4439}
4440
4441ALIAS (clear_ip_bgp_all,
4442 clear_bgp_all_cmd,
4443 "clear bgp *",
4444 CLEAR_STR
4445 BGP_STR
4446 "Clear all peers\n")
4447
4448ALIAS (clear_ip_bgp_all,
4449 clear_bgp_ipv6_all_cmd,
4450 "clear bgp ipv6 *",
4451 CLEAR_STR
4452 BGP_STR
4453 "Address family\n"
4454 "Clear all peers\n")
4455
4456ALIAS (clear_ip_bgp_all,
4457 clear_ip_bgp_instance_all_cmd,
4458 "clear ip bgp view WORD *",
4459 CLEAR_STR
4460 IP_STR
4461 BGP_STR
4462 "BGP view\n"
4463 "view name\n"
4464 "Clear all peers\n")
4465
4466ALIAS (clear_ip_bgp_all,
4467 clear_bgp_instance_all_cmd,
4468 "clear bgp view WORD *",
4469 CLEAR_STR
4470 BGP_STR
4471 "BGP view\n"
4472 "view name\n"
4473 "Clear all peers\n")
4474
4475DEFUN (clear_ip_bgp_peer,
4476 clear_ip_bgp_peer_cmd,
4477 "clear ip bgp (A.B.C.D|X:X::X:X)",
4478 CLEAR_STR
4479 IP_STR
4480 BGP_STR
4481 "BGP neighbor IP address to clear\n"
4482 "BGP IPv6 neighbor to clear\n")
4483{
4484 return bgp_clear_vty (vty, NULL, 0, 0, clear_peer, BGP_CLEAR_SOFT_NONE, argv[0]);
4485}
4486
4487ALIAS (clear_ip_bgp_peer,
4488 clear_bgp_peer_cmd,
4489 "clear bgp (A.B.C.D|X:X::X:X)",
4490 CLEAR_STR
4491 BGP_STR
4492 "BGP neighbor address to clear\n"
4493 "BGP IPv6 neighbor to clear\n")
4494
4495ALIAS (clear_ip_bgp_peer,
4496 clear_bgp_ipv6_peer_cmd,
4497 "clear bgp ipv6 (A.B.C.D|X:X::X:X)",
4498 CLEAR_STR
4499 BGP_STR
4500 "Address family\n"
4501 "BGP neighbor address to clear\n"
4502 "BGP IPv6 neighbor to clear\n")
4503
4504DEFUN (clear_ip_bgp_peer_group,
4505 clear_ip_bgp_peer_group_cmd,
4506 "clear ip bgp peer-group WORD",
4507 CLEAR_STR
4508 IP_STR
4509 BGP_STR
4510 "Clear all members of peer-group\n"
4511 "BGP peer-group name\n")
4512{
4513 return bgp_clear_vty (vty, NULL, 0, 0, clear_group, BGP_CLEAR_SOFT_NONE, argv[0]);
4514}
4515
4516ALIAS (clear_ip_bgp_peer_group,
4517 clear_bgp_peer_group_cmd,
4518 "clear bgp peer-group WORD",
4519 CLEAR_STR
4520 BGP_STR
4521 "Clear all members of peer-group\n"
4522 "BGP peer-group name\n")
4523
4524ALIAS (clear_ip_bgp_peer_group,
4525 clear_bgp_ipv6_peer_group_cmd,
4526 "clear bgp ipv6 peer-group WORD",
4527 CLEAR_STR
4528 BGP_STR
4529 "Address family\n"
4530 "Clear all members of peer-group\n"
4531 "BGP peer-group name\n")
4532
4533DEFUN (clear_ip_bgp_external,
4534 clear_ip_bgp_external_cmd,
4535 "clear ip bgp external",
4536 CLEAR_STR
4537 IP_STR
4538 BGP_STR
4539 "Clear all external peers\n")
4540{
4541 return bgp_clear_vty (vty, NULL, 0, 0, clear_external, BGP_CLEAR_SOFT_NONE, NULL);
4542}
4543
4544ALIAS (clear_ip_bgp_external,
4545 clear_bgp_external_cmd,
4546 "clear bgp external",
4547 CLEAR_STR
4548 BGP_STR
4549 "Clear all external peers\n")
4550
4551ALIAS (clear_ip_bgp_external,
4552 clear_bgp_ipv6_external_cmd,
4553 "clear bgp ipv6 external",
4554 CLEAR_STR
4555 BGP_STR
4556 "Address family\n"
4557 "Clear all external peers\n")
4558
4559DEFUN (clear_ip_bgp_as,
4560 clear_ip_bgp_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004561 "clear ip bgp " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00004562 CLEAR_STR
4563 IP_STR
4564 BGP_STR
4565 "Clear peers with the AS number\n")
4566{
4567 return bgp_clear_vty (vty, NULL, 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[0]);
4568}
4569
4570ALIAS (clear_ip_bgp_as,
4571 clear_bgp_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004572 "clear bgp " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00004573 CLEAR_STR
4574 BGP_STR
4575 "Clear peers with the AS number\n")
4576
4577ALIAS (clear_ip_bgp_as,
4578 clear_bgp_ipv6_as_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00004579 "clear bgp ipv6 " CMD_AS_RANGE,
paul718e3742002-12-13 20:15:29 +00004580 CLEAR_STR
4581 BGP_STR
4582 "Address family\n"
4583 "Clear peers with the AS number\n")
4584
4585/* Outbound soft-reconfiguration */
4586DEFUN (clear_ip_bgp_all_soft_out,
4587 clear_ip_bgp_all_soft_out_cmd,
4588 "clear ip bgp * soft out",
4589 CLEAR_STR
4590 IP_STR
4591 BGP_STR
4592 "Clear all peers\n"
4593 "Soft reconfig\n"
4594 "Soft reconfig outbound update\n")
4595{
4596 if (argc == 1)
4597 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
4598 BGP_CLEAR_SOFT_OUT, NULL);
4599
4600 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
4601 BGP_CLEAR_SOFT_OUT, NULL);
4602}
4603
4604ALIAS (clear_ip_bgp_all_soft_out,
4605 clear_ip_bgp_all_out_cmd,
4606 "clear ip bgp * out",
4607 CLEAR_STR
4608 IP_STR
4609 BGP_STR
4610 "Clear all peers\n"
4611 "Soft reconfig outbound update\n")
4612
4613ALIAS (clear_ip_bgp_all_soft_out,
4614 clear_ip_bgp_instance_all_soft_out_cmd,
4615 "clear ip bgp view WORD * soft out",
4616 CLEAR_STR
4617 IP_STR
4618 BGP_STR
4619 "BGP view\n"
4620 "view name\n"
4621 "Clear all peers\n"
4622 "Soft reconfig\n"
4623 "Soft reconfig outbound update\n")
4624
4625DEFUN (clear_ip_bgp_all_ipv4_soft_out,
4626 clear_ip_bgp_all_ipv4_soft_out_cmd,
4627 "clear ip bgp * ipv4 (unicast|multicast) soft out",
4628 CLEAR_STR
4629 IP_STR
4630 BGP_STR
4631 "Clear all peers\n"
4632 "Address family\n"
4633 "Address Family modifier\n"
4634 "Address Family modifier\n"
4635 "Soft reconfig\n"
4636 "Soft reconfig outbound update\n")
4637{
4638 if (strncmp (argv[0], "m", 1) == 0)
4639 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
4640 BGP_CLEAR_SOFT_OUT, NULL);
4641
4642 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
4643 BGP_CLEAR_SOFT_OUT, NULL);
4644}
4645
4646ALIAS (clear_ip_bgp_all_ipv4_soft_out,
4647 clear_ip_bgp_all_ipv4_out_cmd,
4648 "clear ip bgp * ipv4 (unicast|multicast) out",
4649 CLEAR_STR
4650 IP_STR
4651 BGP_STR
4652 "Clear all peers\n"
4653 "Address family\n"
4654 "Address Family modifier\n"
4655 "Address Family modifier\n"
4656 "Soft reconfig outbound update\n")
4657
4658DEFUN (clear_ip_bgp_instance_all_ipv4_soft_out,
4659 clear_ip_bgp_instance_all_ipv4_soft_out_cmd,
4660 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft out",
4661 CLEAR_STR
4662 IP_STR
4663 BGP_STR
4664 "BGP view\n"
4665 "view name\n"
4666 "Clear all peers\n"
4667 "Address family\n"
4668 "Address Family modifier\n"
4669 "Address Family modifier\n"
4670 "Soft reconfig outbound update\n")
4671{
4672 if (strncmp (argv[1], "m", 1) == 0)
4673 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
4674 BGP_CLEAR_SOFT_OUT, NULL);
4675
4676 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
4677 BGP_CLEAR_SOFT_OUT, NULL);
4678}
4679
4680DEFUN (clear_ip_bgp_all_vpnv4_soft_out,
4681 clear_ip_bgp_all_vpnv4_soft_out_cmd,
4682 "clear ip bgp * vpnv4 unicast soft out",
4683 CLEAR_STR
4684 IP_STR
4685 BGP_STR
4686 "Clear all peers\n"
4687 "Address family\n"
4688 "Address Family Modifier\n"
4689 "Soft reconfig\n"
4690 "Soft reconfig outbound update\n")
4691{
4692 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
4693 BGP_CLEAR_SOFT_OUT, NULL);
4694}
4695
4696ALIAS (clear_ip_bgp_all_vpnv4_soft_out,
4697 clear_ip_bgp_all_vpnv4_out_cmd,
4698 "clear ip bgp * vpnv4 unicast out",
4699 CLEAR_STR
4700 IP_STR
4701 BGP_STR
4702 "Clear all peers\n"
4703 "Address family\n"
4704 "Address Family Modifier\n"
4705 "Soft reconfig outbound update\n")
4706
4707DEFUN (clear_bgp_all_soft_out,
4708 clear_bgp_all_soft_out_cmd,
4709 "clear bgp * soft out",
4710 CLEAR_STR
4711 BGP_STR
4712 "Clear all peers\n"
4713 "Soft reconfig\n"
4714 "Soft reconfig outbound update\n")
4715{
4716 if (argc == 1)
4717 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
4718 BGP_CLEAR_SOFT_OUT, NULL);
4719
4720 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
4721 BGP_CLEAR_SOFT_OUT, NULL);
4722}
4723
4724ALIAS (clear_bgp_all_soft_out,
4725 clear_bgp_instance_all_soft_out_cmd,
4726 "clear bgp view WORD * soft out",
4727 CLEAR_STR
4728 BGP_STR
4729 "BGP view\n"
4730 "view name\n"
4731 "Clear all peers\n"
4732 "Soft reconfig\n"
4733 "Soft reconfig outbound update\n")
4734
4735ALIAS (clear_bgp_all_soft_out,
4736 clear_bgp_all_out_cmd,
4737 "clear bgp * out",
4738 CLEAR_STR
4739 BGP_STR
4740 "Clear all peers\n"
4741 "Soft reconfig outbound update\n")
4742
4743ALIAS (clear_bgp_all_soft_out,
4744 clear_bgp_ipv6_all_soft_out_cmd,
4745 "clear bgp ipv6 * soft out",
4746 CLEAR_STR
4747 BGP_STR
4748 "Address family\n"
4749 "Clear all peers\n"
4750 "Soft reconfig\n"
4751 "Soft reconfig outbound update\n")
4752
4753ALIAS (clear_bgp_all_soft_out,
4754 clear_bgp_ipv6_all_out_cmd,
4755 "clear bgp ipv6 * out",
4756 CLEAR_STR
4757 BGP_STR
4758 "Address family\n"
4759 "Clear all peers\n"
4760 "Soft reconfig outbound update\n")
4761
4762DEFUN (clear_ip_bgp_peer_soft_out,
4763 clear_ip_bgp_peer_soft_out_cmd,
4764 "clear ip bgp A.B.C.D soft out",
4765 CLEAR_STR
4766 IP_STR
4767 BGP_STR
4768 "BGP neighbor address to clear\n"
4769 "Soft reconfig\n"
4770 "Soft reconfig outbound update\n")
4771{
4772 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
4773 BGP_CLEAR_SOFT_OUT, argv[0]);
4774}
4775
4776ALIAS (clear_ip_bgp_peer_soft_out,
4777 clear_ip_bgp_peer_out_cmd,
4778 "clear ip bgp A.B.C.D out",
4779 CLEAR_STR
4780 IP_STR
4781 BGP_STR
4782 "BGP neighbor address to clear\n"
4783 "Soft reconfig outbound update\n")
4784
4785DEFUN (clear_ip_bgp_peer_ipv4_soft_out,
4786 clear_ip_bgp_peer_ipv4_soft_out_cmd,
4787 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft out",
4788 CLEAR_STR
4789 IP_STR
4790 BGP_STR
4791 "BGP neighbor address to clear\n"
4792 "Address family\n"
4793 "Address Family modifier\n"
4794 "Address Family modifier\n"
4795 "Soft reconfig\n"
4796 "Soft reconfig outbound update\n")
4797{
4798 if (strncmp (argv[1], "m", 1) == 0)
4799 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
4800 BGP_CLEAR_SOFT_OUT, argv[0]);
4801
4802 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
4803 BGP_CLEAR_SOFT_OUT, argv[0]);
4804}
4805
4806ALIAS (clear_ip_bgp_peer_ipv4_soft_out,
4807 clear_ip_bgp_peer_ipv4_out_cmd,
4808 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) out",
4809 CLEAR_STR
4810 IP_STR
4811 BGP_STR
4812 "BGP neighbor address to clear\n"
4813 "Address family\n"
4814 "Address Family modifier\n"
4815 "Address Family modifier\n"
4816 "Soft reconfig outbound update\n")
4817
4818DEFUN (clear_ip_bgp_peer_vpnv4_soft_out,
4819 clear_ip_bgp_peer_vpnv4_soft_out_cmd,
4820 "clear ip bgp A.B.C.D vpnv4 unicast soft out",
4821 CLEAR_STR
4822 IP_STR
4823 BGP_STR
4824 "BGP neighbor address to clear\n"
4825 "Address family\n"
4826 "Address Family Modifier\n"
4827 "Soft reconfig\n"
4828 "Soft reconfig outbound update\n")
4829{
4830 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
4831 BGP_CLEAR_SOFT_OUT, argv[0]);
4832}
4833
4834ALIAS (clear_ip_bgp_peer_vpnv4_soft_out,
4835 clear_ip_bgp_peer_vpnv4_out_cmd,
4836 "clear ip bgp A.B.C.D vpnv4 unicast out",
4837 CLEAR_STR
4838 IP_STR
4839 BGP_STR
4840 "BGP neighbor address to clear\n"
4841 "Address family\n"
4842 "Address Family Modifier\n"
4843 "Soft reconfig outbound update\n")
4844
4845DEFUN (clear_bgp_peer_soft_out,
4846 clear_bgp_peer_soft_out_cmd,
4847 "clear bgp (A.B.C.D|X:X::X:X) soft out",
4848 CLEAR_STR
4849 BGP_STR
4850 "BGP neighbor address to clear\n"
4851 "BGP IPv6 neighbor to clear\n"
4852 "Soft reconfig\n"
4853 "Soft reconfig outbound update\n")
4854{
4855 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
4856 BGP_CLEAR_SOFT_OUT, argv[0]);
4857}
4858
4859ALIAS (clear_bgp_peer_soft_out,
4860 clear_bgp_ipv6_peer_soft_out_cmd,
4861 "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft out",
4862 CLEAR_STR
4863 BGP_STR
4864 "Address family\n"
4865 "BGP neighbor address to clear\n"
4866 "BGP IPv6 neighbor to clear\n"
4867 "Soft reconfig\n"
4868 "Soft reconfig outbound update\n")
4869
4870ALIAS (clear_bgp_peer_soft_out,
4871 clear_bgp_peer_out_cmd,
4872 "clear bgp (A.B.C.D|X:X::X:X) out",
4873 CLEAR_STR
4874 BGP_STR
4875 "BGP neighbor address to clear\n"
4876 "BGP IPv6 neighbor to clear\n"
4877 "Soft reconfig outbound update\n")
4878
4879ALIAS (clear_bgp_peer_soft_out,
4880 clear_bgp_ipv6_peer_out_cmd,
4881 "clear bgp ipv6 (A.B.C.D|X:X::X:X) out",
4882 CLEAR_STR
4883 BGP_STR
4884 "Address family\n"
4885 "BGP neighbor address to clear\n"
4886 "BGP IPv6 neighbor to clear\n"
4887 "Soft reconfig outbound update\n")
4888
4889DEFUN (clear_ip_bgp_peer_group_soft_out,
4890 clear_ip_bgp_peer_group_soft_out_cmd,
4891 "clear ip bgp peer-group WORD soft out",
4892 CLEAR_STR
4893 IP_STR
4894 BGP_STR
4895 "Clear all members of peer-group\n"
4896 "BGP peer-group name\n"
4897 "Soft reconfig\n"
4898 "Soft reconfig outbound update\n")
4899{
4900 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
4901 BGP_CLEAR_SOFT_OUT, argv[0]);
4902}
4903
4904ALIAS (clear_ip_bgp_peer_group_soft_out,
4905 clear_ip_bgp_peer_group_out_cmd,
4906 "clear ip bgp peer-group WORD out",
4907 CLEAR_STR
4908 IP_STR
4909 BGP_STR
4910 "Clear all members of peer-group\n"
4911 "BGP peer-group name\n"
4912 "Soft reconfig outbound update\n")
4913
4914DEFUN (clear_ip_bgp_peer_group_ipv4_soft_out,
4915 clear_ip_bgp_peer_group_ipv4_soft_out_cmd,
4916 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft out",
4917 CLEAR_STR
4918 IP_STR
4919 BGP_STR
4920 "Clear all members of peer-group\n"
4921 "BGP peer-group name\n"
4922 "Address family\n"
4923 "Address Family modifier\n"
4924 "Address Family modifier\n"
4925 "Soft reconfig\n"
4926 "Soft reconfig outbound update\n")
4927{
4928 if (strncmp (argv[1], "m", 1) == 0)
4929 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
4930 BGP_CLEAR_SOFT_OUT, argv[0]);
4931
4932 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
4933 BGP_CLEAR_SOFT_OUT, argv[0]);
4934}
4935
4936ALIAS (clear_ip_bgp_peer_group_ipv4_soft_out,
4937 clear_ip_bgp_peer_group_ipv4_out_cmd,
4938 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) out",
4939 CLEAR_STR
4940 IP_STR
4941 BGP_STR
4942 "Clear all members of peer-group\n"
4943 "BGP peer-group name\n"
4944 "Address family\n"
4945 "Address Family modifier\n"
4946 "Address Family modifier\n"
4947 "Soft reconfig outbound update\n")
4948
4949DEFUN (clear_bgp_peer_group_soft_out,
4950 clear_bgp_peer_group_soft_out_cmd,
4951 "clear bgp peer-group WORD soft out",
4952 CLEAR_STR
4953 BGP_STR
4954 "Clear all members of peer-group\n"
4955 "BGP peer-group name\n"
4956 "Soft reconfig\n"
4957 "Soft reconfig outbound update\n")
4958{
4959 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
4960 BGP_CLEAR_SOFT_OUT, argv[0]);
4961}
4962
4963ALIAS (clear_bgp_peer_group_soft_out,
4964 clear_bgp_ipv6_peer_group_soft_out_cmd,
4965 "clear bgp ipv6 peer-group WORD soft out",
4966 CLEAR_STR
4967 BGP_STR
4968 "Address family\n"
4969 "Clear all members of peer-group\n"
4970 "BGP peer-group name\n"
4971 "Soft reconfig\n"
4972 "Soft reconfig outbound update\n")
4973
4974ALIAS (clear_bgp_peer_group_soft_out,
4975 clear_bgp_peer_group_out_cmd,
4976 "clear bgp peer-group WORD out",
4977 CLEAR_STR
4978 BGP_STR
4979 "Clear all members of peer-group\n"
4980 "BGP peer-group name\n"
4981 "Soft reconfig outbound update\n")
4982
4983ALIAS (clear_bgp_peer_group_soft_out,
4984 clear_bgp_ipv6_peer_group_out_cmd,
4985 "clear bgp ipv6 peer-group WORD out",
4986 CLEAR_STR
4987 BGP_STR
4988 "Address family\n"
4989 "Clear all members of peer-group\n"
4990 "BGP peer-group name\n"
4991 "Soft reconfig outbound update\n")
4992
4993DEFUN (clear_ip_bgp_external_soft_out,
4994 clear_ip_bgp_external_soft_out_cmd,
4995 "clear ip bgp external soft out",
4996 CLEAR_STR
4997 IP_STR
4998 BGP_STR
4999 "Clear all external peers\n"
5000 "Soft reconfig\n"
5001 "Soft reconfig outbound update\n")
5002{
5003 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5004 BGP_CLEAR_SOFT_OUT, NULL);
5005}
5006
5007ALIAS (clear_ip_bgp_external_soft_out,
5008 clear_ip_bgp_external_out_cmd,
5009 "clear ip bgp external out",
5010 CLEAR_STR
5011 IP_STR
5012 BGP_STR
5013 "Clear all external peers\n"
5014 "Soft reconfig outbound update\n")
5015
5016DEFUN (clear_ip_bgp_external_ipv4_soft_out,
5017 clear_ip_bgp_external_ipv4_soft_out_cmd,
5018 "clear ip bgp external ipv4 (unicast|multicast) soft out",
5019 CLEAR_STR
5020 IP_STR
5021 BGP_STR
5022 "Clear all external peers\n"
5023 "Address family\n"
5024 "Address Family modifier\n"
5025 "Address Family modifier\n"
5026 "Soft reconfig\n"
5027 "Soft reconfig outbound update\n")
5028{
5029 if (strncmp (argv[0], "m", 1) == 0)
5030 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
5031 BGP_CLEAR_SOFT_OUT, NULL);
5032
5033 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5034 BGP_CLEAR_SOFT_OUT, NULL);
5035}
5036
5037ALIAS (clear_ip_bgp_external_ipv4_soft_out,
5038 clear_ip_bgp_external_ipv4_out_cmd,
5039 "clear ip bgp external ipv4 (unicast|multicast) out",
5040 CLEAR_STR
5041 IP_STR
5042 BGP_STR
5043 "Clear all external peers\n"
5044 "Address family\n"
5045 "Address Family modifier\n"
5046 "Address Family modifier\n"
5047 "Soft reconfig outbound update\n")
5048
5049DEFUN (clear_bgp_external_soft_out,
5050 clear_bgp_external_soft_out_cmd,
5051 "clear bgp external soft out",
5052 CLEAR_STR
5053 BGP_STR
5054 "Clear all external peers\n"
5055 "Soft reconfig\n"
5056 "Soft reconfig outbound update\n")
5057{
5058 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
5059 BGP_CLEAR_SOFT_OUT, NULL);
5060}
5061
5062ALIAS (clear_bgp_external_soft_out,
5063 clear_bgp_ipv6_external_soft_out_cmd,
5064 "clear bgp ipv6 external soft out",
5065 CLEAR_STR
5066 BGP_STR
5067 "Address family\n"
5068 "Clear all external peers\n"
5069 "Soft reconfig\n"
5070 "Soft reconfig outbound update\n")
5071
5072ALIAS (clear_bgp_external_soft_out,
5073 clear_bgp_external_out_cmd,
5074 "clear bgp external out",
5075 CLEAR_STR
5076 BGP_STR
5077 "Clear all external peers\n"
5078 "Soft reconfig outbound update\n")
5079
5080ALIAS (clear_bgp_external_soft_out,
5081 clear_bgp_ipv6_external_out_cmd,
5082 "clear bgp ipv6 external WORD out",
5083 CLEAR_STR
5084 BGP_STR
5085 "Address family\n"
5086 "Clear all external peers\n"
5087 "Soft reconfig outbound update\n")
5088
5089DEFUN (clear_ip_bgp_as_soft_out,
5090 clear_ip_bgp_as_soft_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005091 "clear ip bgp " CMD_AS_RANGE " soft out",
paul718e3742002-12-13 20:15:29 +00005092 CLEAR_STR
5093 IP_STR
5094 BGP_STR
5095 "Clear peers with the AS number\n"
5096 "Soft reconfig\n"
5097 "Soft reconfig outbound update\n")
5098{
5099 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5100 BGP_CLEAR_SOFT_OUT, argv[0]);
5101}
5102
5103ALIAS (clear_ip_bgp_as_soft_out,
5104 clear_ip_bgp_as_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005105 "clear ip bgp " CMD_AS_RANGE " out",
paul718e3742002-12-13 20:15:29 +00005106 CLEAR_STR
5107 IP_STR
5108 BGP_STR
5109 "Clear peers with the AS number\n"
5110 "Soft reconfig outbound update\n")
5111
5112DEFUN (clear_ip_bgp_as_ipv4_soft_out,
5113 clear_ip_bgp_as_ipv4_soft_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005114 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft out",
paul718e3742002-12-13 20:15:29 +00005115 CLEAR_STR
5116 IP_STR
5117 BGP_STR
5118 "Clear peers with the AS number\n"
5119 "Address family\n"
5120 "Address Family modifier\n"
5121 "Address Family modifier\n"
5122 "Soft reconfig\n"
5123 "Soft reconfig outbound update\n")
5124{
5125 if (strncmp (argv[1], "m", 1) == 0)
5126 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
5127 BGP_CLEAR_SOFT_OUT, argv[0]);
5128
5129 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5130 BGP_CLEAR_SOFT_OUT, argv[0]);
5131}
5132
5133ALIAS (clear_ip_bgp_as_ipv4_soft_out,
5134 clear_ip_bgp_as_ipv4_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005135 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) out",
paul718e3742002-12-13 20:15:29 +00005136 CLEAR_STR
5137 IP_STR
5138 BGP_STR
5139 "Clear peers with the AS number\n"
5140 "Address family\n"
5141 "Address Family modifier\n"
5142 "Address Family modifier\n"
5143 "Soft reconfig outbound update\n")
5144
5145DEFUN (clear_ip_bgp_as_vpnv4_soft_out,
5146 clear_ip_bgp_as_vpnv4_soft_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005147 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft out",
paul718e3742002-12-13 20:15:29 +00005148 CLEAR_STR
5149 IP_STR
5150 BGP_STR
5151 "Clear peers with the AS number\n"
5152 "Address family\n"
5153 "Address Family modifier\n"
5154 "Soft reconfig\n"
5155 "Soft reconfig outbound update\n")
5156{
5157 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
5158 BGP_CLEAR_SOFT_OUT, argv[0]);
5159}
5160
5161ALIAS (clear_ip_bgp_as_vpnv4_soft_out,
5162 clear_ip_bgp_as_vpnv4_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005163 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast out",
paul718e3742002-12-13 20:15:29 +00005164 CLEAR_STR
5165 IP_STR
5166 BGP_STR
5167 "Clear peers with the AS number\n"
5168 "Address family\n"
5169 "Address Family modifier\n"
5170 "Soft reconfig outbound update\n")
5171
5172DEFUN (clear_bgp_as_soft_out,
5173 clear_bgp_as_soft_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005174 "clear bgp " CMD_AS_RANGE " soft out",
paul718e3742002-12-13 20:15:29 +00005175 CLEAR_STR
5176 BGP_STR
5177 "Clear peers with the AS number\n"
5178 "Soft reconfig\n"
5179 "Soft reconfig outbound update\n")
5180{
5181 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
5182 BGP_CLEAR_SOFT_OUT, argv[0]);
5183}
5184
5185ALIAS (clear_bgp_as_soft_out,
5186 clear_bgp_ipv6_as_soft_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005187 "clear bgp ipv6 " CMD_AS_RANGE " soft out",
paul718e3742002-12-13 20:15:29 +00005188 CLEAR_STR
5189 BGP_STR
5190 "Address family\n"
5191 "Clear peers with the AS number\n"
5192 "Soft reconfig\n"
5193 "Soft reconfig outbound update\n")
5194
5195ALIAS (clear_bgp_as_soft_out,
5196 clear_bgp_as_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005197 "clear bgp " CMD_AS_RANGE " out",
paul718e3742002-12-13 20:15:29 +00005198 CLEAR_STR
5199 BGP_STR
5200 "Clear peers with the AS number\n"
5201 "Soft reconfig outbound update\n")
5202
5203ALIAS (clear_bgp_as_soft_out,
5204 clear_bgp_ipv6_as_out_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005205 "clear bgp ipv6 " CMD_AS_RANGE " out",
paul718e3742002-12-13 20:15:29 +00005206 CLEAR_STR
5207 BGP_STR
5208 "Address family\n"
5209 "Clear peers with the AS number\n"
5210 "Soft reconfig outbound update\n")
5211
5212/* Inbound soft-reconfiguration */
5213DEFUN (clear_ip_bgp_all_soft_in,
5214 clear_ip_bgp_all_soft_in_cmd,
5215 "clear ip bgp * soft in",
5216 CLEAR_STR
5217 IP_STR
5218 BGP_STR
5219 "Clear all peers\n"
5220 "Soft reconfig\n"
5221 "Soft reconfig inbound update\n")
5222{
5223 if (argc == 1)
5224 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5225 BGP_CLEAR_SOFT_IN, NULL);
5226
5227 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5228 BGP_CLEAR_SOFT_IN, NULL);
5229}
5230
5231ALIAS (clear_ip_bgp_all_soft_in,
5232 clear_ip_bgp_instance_all_soft_in_cmd,
5233 "clear ip bgp view WORD * soft in",
5234 CLEAR_STR
5235 IP_STR
5236 BGP_STR
5237 "BGP view\n"
5238 "view name\n"
5239 "Clear all peers\n"
5240 "Soft reconfig\n"
5241 "Soft reconfig inbound update\n")
5242
5243ALIAS (clear_ip_bgp_all_soft_in,
5244 clear_ip_bgp_all_in_cmd,
5245 "clear ip bgp * in",
5246 CLEAR_STR
5247 IP_STR
5248 BGP_STR
5249 "Clear all peers\n"
5250 "Soft reconfig inbound update\n")
5251
5252DEFUN (clear_ip_bgp_all_in_prefix_filter,
5253 clear_ip_bgp_all_in_prefix_filter_cmd,
5254 "clear ip bgp * in prefix-filter",
5255 CLEAR_STR
5256 IP_STR
5257 BGP_STR
5258 "Clear all peers\n"
5259 "Soft reconfig inbound update\n"
5260 "Push out prefix-list ORF and do inbound soft reconfig\n")
5261{
5262 if (argc== 1)
5263 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5264 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5265
5266 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5267 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5268}
5269
5270ALIAS (clear_ip_bgp_all_in_prefix_filter,
5271 clear_ip_bgp_instance_all_in_prefix_filter_cmd,
5272 "clear ip bgp view WORD * in prefix-filter",
5273 CLEAR_STR
5274 IP_STR
5275 BGP_STR
5276 "BGP view\n"
5277 "view name\n"
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
5283DEFUN (clear_ip_bgp_all_ipv4_soft_in,
5284 clear_ip_bgp_all_ipv4_soft_in_cmd,
5285 "clear ip bgp * ipv4 (unicast|multicast) soft in",
5286 CLEAR_STR
5287 IP_STR
5288 BGP_STR
5289 "Clear all peers\n"
5290 "Address family\n"
5291 "Address Family modifier\n"
5292 "Address Family modifier\n"
5293 "Soft reconfig\n"
5294 "Soft reconfig inbound update\n")
5295{
5296 if (strncmp (argv[0], "m", 1) == 0)
5297 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
5298 BGP_CLEAR_SOFT_IN, NULL);
5299
5300 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5301 BGP_CLEAR_SOFT_IN, NULL);
5302}
5303
5304ALIAS (clear_ip_bgp_all_ipv4_soft_in,
5305 clear_ip_bgp_all_ipv4_in_cmd,
5306 "clear ip bgp * ipv4 (unicast|multicast) in",
5307 CLEAR_STR
5308 IP_STR
5309 BGP_STR
5310 "Clear all peers\n"
5311 "Address family\n"
5312 "Address Family modifier\n"
5313 "Address Family modifier\n"
5314 "Soft reconfig inbound update\n")
5315
5316DEFUN (clear_ip_bgp_instance_all_ipv4_soft_in,
5317 clear_ip_bgp_instance_all_ipv4_soft_in_cmd,
5318 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft in",
5319 CLEAR_STR
5320 IP_STR
5321 BGP_STR
5322 "BGP view\n"
5323 "view name\n"
5324 "Clear all peers\n"
5325 "Address family\n"
5326 "Address Family modifier\n"
5327 "Address Family modifier\n"
5328 "Soft reconfig\n"
5329 "Soft reconfig inbound update\n")
5330{
5331 if (strncmp (argv[1], "m", 1) == 0)
5332 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
5333 BGP_CLEAR_SOFT_IN, NULL);
5334
5335 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5336 BGP_CLEAR_SOFT_IN, NULL);
5337}
5338
5339DEFUN (clear_ip_bgp_all_ipv4_in_prefix_filter,
5340 clear_ip_bgp_all_ipv4_in_prefix_filter_cmd,
5341 "clear ip bgp * ipv4 (unicast|multicast) in prefix-filter",
5342 CLEAR_STR
5343 IP_STR
5344 BGP_STR
5345 "Clear all peers\n"
5346 "Address family\n"
5347 "Address Family modifier\n"
5348 "Address Family modifier\n"
5349 "Soft reconfig inbound update\n"
5350 "Push out prefix-list ORF and do inbound soft reconfig\n")
5351{
5352 if (strncmp (argv[0], "m", 1) == 0)
5353 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
5354 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5355
5356 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5357 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5358}
5359
5360DEFUN (clear_ip_bgp_instance_all_ipv4_in_prefix_filter,
5361 clear_ip_bgp_instance_all_ipv4_in_prefix_filter_cmd,
5362 "clear ip bgp view WORD * ipv4 (unicast|multicast) in prefix-filter",
5363 CLEAR_STR
5364 IP_STR
5365 BGP_STR
5366 "Clear all peers\n"
5367 "Address family\n"
5368 "Address Family modifier\n"
5369 "Address Family modifier\n"
5370 "Soft reconfig inbound update\n"
5371 "Push out prefix-list ORF and do inbound soft reconfig\n")
5372{
5373 if (strncmp (argv[1], "m", 1) == 0)
5374 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
5375 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5376
5377 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5378 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5379}
5380
5381DEFUN (clear_ip_bgp_all_vpnv4_soft_in,
5382 clear_ip_bgp_all_vpnv4_soft_in_cmd,
5383 "clear ip bgp * vpnv4 unicast soft in",
5384 CLEAR_STR
5385 IP_STR
5386 BGP_STR
5387 "Clear all peers\n"
5388 "Address family\n"
5389 "Address Family Modifier\n"
5390 "Soft reconfig\n"
5391 "Soft reconfig inbound update\n")
5392{
5393 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
5394 BGP_CLEAR_SOFT_IN, NULL);
5395}
5396
5397ALIAS (clear_ip_bgp_all_vpnv4_soft_in,
5398 clear_ip_bgp_all_vpnv4_in_cmd,
5399 "clear ip bgp * vpnv4 unicast in",
5400 CLEAR_STR
5401 IP_STR
5402 BGP_STR
5403 "Clear all peers\n"
5404 "Address family\n"
5405 "Address Family Modifier\n"
5406 "Soft reconfig inbound update\n")
5407
5408DEFUN (clear_bgp_all_soft_in,
5409 clear_bgp_all_soft_in_cmd,
5410 "clear bgp * soft in",
5411 CLEAR_STR
5412 BGP_STR
5413 "Clear all peers\n"
5414 "Soft reconfig\n"
5415 "Soft reconfig inbound update\n")
5416{
5417 if (argc == 1)
5418 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
5419 BGP_CLEAR_SOFT_IN, NULL);
5420
5421 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
5422 BGP_CLEAR_SOFT_IN, NULL);
5423}
5424
5425ALIAS (clear_bgp_all_soft_in,
5426 clear_bgp_instance_all_soft_in_cmd,
5427 "clear bgp view WORD * soft in",
5428 CLEAR_STR
5429 BGP_STR
5430 "BGP view\n"
5431 "view name\n"
5432 "Clear all peers\n"
5433 "Soft reconfig\n"
5434 "Soft reconfig inbound update\n")
5435
5436ALIAS (clear_bgp_all_soft_in,
5437 clear_bgp_ipv6_all_soft_in_cmd,
5438 "clear bgp ipv6 * soft in",
5439 CLEAR_STR
5440 BGP_STR
5441 "Address family\n"
5442 "Clear all peers\n"
5443 "Soft reconfig\n"
5444 "Soft reconfig inbound update\n")
5445
5446ALIAS (clear_bgp_all_soft_in,
5447 clear_bgp_all_in_cmd,
5448 "clear bgp * in",
5449 CLEAR_STR
5450 BGP_STR
5451 "Clear all peers\n"
5452 "Soft reconfig inbound update\n")
5453
5454ALIAS (clear_bgp_all_soft_in,
5455 clear_bgp_ipv6_all_in_cmd,
5456 "clear bgp ipv6 * in",
5457 CLEAR_STR
5458 BGP_STR
5459 "Address family\n"
5460 "Clear all peers\n"
5461 "Soft reconfig inbound update\n")
5462
5463DEFUN (clear_bgp_all_in_prefix_filter,
5464 clear_bgp_all_in_prefix_filter_cmd,
5465 "clear bgp * in prefix-filter",
5466 CLEAR_STR
5467 BGP_STR
5468 "Clear all peers\n"
5469 "Soft reconfig inbound update\n"
5470 "Push out prefix-list ORF and do inbound soft reconfig\n")
5471{
5472 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
5473 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5474}
5475
5476ALIAS (clear_bgp_all_in_prefix_filter,
5477 clear_bgp_ipv6_all_in_prefix_filter_cmd,
5478 "clear bgp ipv6 * in prefix-filter",
5479 CLEAR_STR
5480 BGP_STR
5481 "Address family\n"
5482 "Clear all peers\n"
5483 "Soft reconfig inbound update\n"
5484 "Push out prefix-list ORF and do inbound soft reconfig\n")
5485
5486DEFUN (clear_ip_bgp_peer_soft_in,
5487 clear_ip_bgp_peer_soft_in_cmd,
5488 "clear ip bgp A.B.C.D soft in",
5489 CLEAR_STR
5490 IP_STR
5491 BGP_STR
5492 "BGP neighbor address to clear\n"
5493 "Soft reconfig\n"
5494 "Soft reconfig inbound update\n")
5495{
5496 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5497 BGP_CLEAR_SOFT_IN, argv[0]);
5498}
5499
5500ALIAS (clear_ip_bgp_peer_soft_in,
5501 clear_ip_bgp_peer_in_cmd,
5502 "clear ip bgp A.B.C.D in",
5503 CLEAR_STR
5504 IP_STR
5505 BGP_STR
5506 "BGP neighbor address to clear\n"
5507 "Soft reconfig inbound update\n")
5508
5509DEFUN (clear_ip_bgp_peer_in_prefix_filter,
5510 clear_ip_bgp_peer_in_prefix_filter_cmd,
5511 "clear ip bgp A.B.C.D in prefix-filter",
5512 CLEAR_STR
5513 IP_STR
5514 BGP_STR
5515 "BGP neighbor address to clear\n"
5516 "Soft reconfig inbound update\n"
5517 "Push out the existing ORF prefix-list\n")
5518{
5519 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5520 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5521}
5522
5523DEFUN (clear_ip_bgp_peer_ipv4_soft_in,
5524 clear_ip_bgp_peer_ipv4_soft_in_cmd,
5525 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft in",
5526 CLEAR_STR
5527 IP_STR
5528 BGP_STR
5529 "BGP neighbor address to clear\n"
5530 "Address family\n"
5531 "Address Family modifier\n"
5532 "Address Family modifier\n"
5533 "Soft reconfig\n"
5534 "Soft reconfig inbound update\n")
5535{
5536 if (strncmp (argv[1], "m", 1) == 0)
5537 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
5538 BGP_CLEAR_SOFT_IN, argv[0]);
5539
5540 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5541 BGP_CLEAR_SOFT_IN, argv[0]);
5542}
5543
5544ALIAS (clear_ip_bgp_peer_ipv4_soft_in,
5545 clear_ip_bgp_peer_ipv4_in_cmd,
5546 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) in",
5547 CLEAR_STR
5548 IP_STR
5549 BGP_STR
5550 "BGP neighbor address to clear\n"
5551 "Address family\n"
5552 "Address Family modifier\n"
5553 "Address Family modifier\n"
5554 "Soft reconfig inbound update\n")
5555
5556DEFUN (clear_ip_bgp_peer_ipv4_in_prefix_filter,
5557 clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd,
5558 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) in prefix-filter",
5559 CLEAR_STR
5560 IP_STR
5561 BGP_STR
5562 "BGP neighbor address to clear\n"
5563 "Address family\n"
5564 "Address Family modifier\n"
5565 "Address Family modifier\n"
5566 "Soft reconfig inbound update\n"
5567 "Push out the existing ORF prefix-list\n")
5568{
5569 if (strncmp (argv[1], "m", 1) == 0)
5570 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
5571 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5572
5573 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5574 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5575}
5576
5577DEFUN (clear_ip_bgp_peer_vpnv4_soft_in,
5578 clear_ip_bgp_peer_vpnv4_soft_in_cmd,
5579 "clear ip bgp A.B.C.D vpnv4 unicast soft in",
5580 CLEAR_STR
5581 IP_STR
5582 BGP_STR
5583 "BGP neighbor address to clear\n"
5584 "Address family\n"
5585 "Address Family Modifier\n"
5586 "Soft reconfig\n"
5587 "Soft reconfig inbound update\n")
5588{
5589 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
5590 BGP_CLEAR_SOFT_IN, argv[0]);
5591}
5592
5593ALIAS (clear_ip_bgp_peer_vpnv4_soft_in,
5594 clear_ip_bgp_peer_vpnv4_in_cmd,
5595 "clear ip bgp A.B.C.D vpnv4 unicast in",
5596 CLEAR_STR
5597 IP_STR
5598 BGP_STR
5599 "BGP neighbor address to clear\n"
5600 "Address family\n"
5601 "Address Family Modifier\n"
5602 "Soft reconfig inbound update\n")
5603
5604DEFUN (clear_bgp_peer_soft_in,
5605 clear_bgp_peer_soft_in_cmd,
5606 "clear bgp (A.B.C.D|X:X::X:X) soft in",
5607 CLEAR_STR
5608 BGP_STR
5609 "BGP neighbor address to clear\n"
5610 "BGP IPv6 neighbor to clear\n"
5611 "Soft reconfig\n"
5612 "Soft reconfig inbound update\n")
5613{
5614 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
5615 BGP_CLEAR_SOFT_IN, argv[0]);
5616}
5617
5618ALIAS (clear_bgp_peer_soft_in,
5619 clear_bgp_ipv6_peer_soft_in_cmd,
5620 "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft in",
5621 CLEAR_STR
5622 BGP_STR
5623 "Address family\n"
5624 "BGP neighbor address to clear\n"
5625 "BGP IPv6 neighbor to clear\n"
5626 "Soft reconfig\n"
5627 "Soft reconfig inbound update\n")
5628
5629ALIAS (clear_bgp_peer_soft_in,
5630 clear_bgp_peer_in_cmd,
5631 "clear bgp (A.B.C.D|X:X::X:X) in",
5632 CLEAR_STR
5633 BGP_STR
5634 "BGP neighbor address to clear\n"
5635 "BGP IPv6 neighbor to clear\n"
5636 "Soft reconfig inbound update\n")
5637
5638ALIAS (clear_bgp_peer_soft_in,
5639 clear_bgp_ipv6_peer_in_cmd,
5640 "clear bgp ipv6 (A.B.C.D|X:X::X:X) in",
5641 CLEAR_STR
5642 BGP_STR
5643 "Address family\n"
5644 "BGP neighbor address to clear\n"
5645 "BGP IPv6 neighbor to clear\n"
5646 "Soft reconfig inbound update\n")
5647
5648DEFUN (clear_bgp_peer_in_prefix_filter,
5649 clear_bgp_peer_in_prefix_filter_cmd,
5650 "clear bgp (A.B.C.D|X:X::X:X) in prefix-filter",
5651 CLEAR_STR
5652 BGP_STR
5653 "BGP neighbor address to clear\n"
5654 "BGP IPv6 neighbor to clear\n"
5655 "Soft reconfig inbound update\n"
5656 "Push out the existing ORF prefix-list\n")
5657{
5658 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
5659 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5660}
5661
5662ALIAS (clear_bgp_peer_in_prefix_filter,
5663 clear_bgp_ipv6_peer_in_prefix_filter_cmd,
5664 "clear bgp ipv6 (A.B.C.D|X:X::X:X) in prefix-filter",
5665 CLEAR_STR
5666 BGP_STR
5667 "Address family\n"
5668 "BGP neighbor address to clear\n"
5669 "BGP IPv6 neighbor to clear\n"
5670 "Soft reconfig inbound update\n"
5671 "Push out the existing ORF prefix-list\n")
5672
5673DEFUN (clear_ip_bgp_peer_group_soft_in,
5674 clear_ip_bgp_peer_group_soft_in_cmd,
5675 "clear ip bgp peer-group WORD soft in",
5676 CLEAR_STR
5677 IP_STR
5678 BGP_STR
5679 "Clear all members of peer-group\n"
5680 "BGP peer-group name\n"
5681 "Soft reconfig\n"
5682 "Soft reconfig inbound update\n")
5683{
5684 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5685 BGP_CLEAR_SOFT_IN, argv[0]);
5686}
5687
5688ALIAS (clear_ip_bgp_peer_group_soft_in,
5689 clear_ip_bgp_peer_group_in_cmd,
5690 "clear ip bgp peer-group WORD in",
5691 CLEAR_STR
5692 IP_STR
5693 BGP_STR
5694 "Clear all members of peer-group\n"
5695 "BGP peer-group name\n"
5696 "Soft reconfig inbound update\n")
5697
5698DEFUN (clear_ip_bgp_peer_group_in_prefix_filter,
5699 clear_ip_bgp_peer_group_in_prefix_filter_cmd,
5700 "clear ip bgp peer-group WORD in prefix-filter",
5701 CLEAR_STR
5702 IP_STR
5703 BGP_STR
5704 "Clear all members of peer-group\n"
5705 "BGP peer-group name\n"
5706 "Soft reconfig inbound update\n"
5707 "Push out prefix-list ORF and do inbound soft reconfig\n")
5708{
5709 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5710 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5711}
5712
5713DEFUN (clear_ip_bgp_peer_group_ipv4_soft_in,
5714 clear_ip_bgp_peer_group_ipv4_soft_in_cmd,
5715 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft in",
5716 CLEAR_STR
5717 IP_STR
5718 BGP_STR
5719 "Clear all members of peer-group\n"
5720 "BGP peer-group name\n"
5721 "Address family\n"
5722 "Address Family modifier\n"
5723 "Address Family modifier\n"
5724 "Soft reconfig\n"
5725 "Soft reconfig inbound update\n")
5726{
5727 if (strncmp (argv[1], "m", 1) == 0)
5728 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
5729 BGP_CLEAR_SOFT_IN, argv[0]);
5730
5731 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5732 BGP_CLEAR_SOFT_IN, argv[0]);
5733}
5734
5735ALIAS (clear_ip_bgp_peer_group_ipv4_soft_in,
5736 clear_ip_bgp_peer_group_ipv4_in_cmd,
5737 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in",
5738 CLEAR_STR
5739 IP_STR
5740 BGP_STR
5741 "Clear all members of peer-group\n"
5742 "BGP peer-group name\n"
5743 "Address family\n"
5744 "Address Family modifier\n"
5745 "Address Family modifier\n"
5746 "Soft reconfig inbound update\n")
5747
5748DEFUN (clear_ip_bgp_peer_group_ipv4_in_prefix_filter,
5749 clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd,
5750 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in prefix-filter",
5751 CLEAR_STR
5752 IP_STR
5753 BGP_STR
5754 "Clear all members of peer-group\n"
5755 "BGP peer-group name\n"
5756 "Address family\n"
5757 "Address Family modifier\n"
5758 "Address Family modifier\n"
5759 "Soft reconfig inbound update\n"
5760 "Push out prefix-list ORF and do inbound soft reconfig\n")
5761{
5762 if (strncmp (argv[1], "m", 1) == 0)
5763 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
5764 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5765
5766 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5767 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5768}
5769
5770DEFUN (clear_bgp_peer_group_soft_in,
5771 clear_bgp_peer_group_soft_in_cmd,
5772 "clear bgp peer-group WORD soft in",
5773 CLEAR_STR
5774 BGP_STR
5775 "Clear all members of peer-group\n"
5776 "BGP peer-group name\n"
5777 "Soft reconfig\n"
5778 "Soft reconfig inbound update\n")
5779{
5780 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
5781 BGP_CLEAR_SOFT_IN, argv[0]);
5782}
5783
5784ALIAS (clear_bgp_peer_group_soft_in,
5785 clear_bgp_ipv6_peer_group_soft_in_cmd,
5786 "clear bgp ipv6 peer-group WORD soft in",
5787 CLEAR_STR
5788 BGP_STR
5789 "Address family\n"
5790 "Clear all members of peer-group\n"
5791 "BGP peer-group name\n"
5792 "Soft reconfig\n"
5793 "Soft reconfig inbound update\n")
5794
5795ALIAS (clear_bgp_peer_group_soft_in,
5796 clear_bgp_peer_group_in_cmd,
5797 "clear bgp peer-group WORD in",
5798 CLEAR_STR
5799 BGP_STR
5800 "Clear all members of peer-group\n"
5801 "BGP peer-group name\n"
5802 "Soft reconfig inbound update\n")
5803
5804ALIAS (clear_bgp_peer_group_soft_in,
5805 clear_bgp_ipv6_peer_group_in_cmd,
5806 "clear bgp ipv6 peer-group WORD in",
5807 CLEAR_STR
5808 BGP_STR
5809 "Address family\n"
5810 "Clear all members of peer-group\n"
5811 "BGP peer-group name\n"
5812 "Soft reconfig inbound update\n")
5813
5814DEFUN (clear_bgp_peer_group_in_prefix_filter,
5815 clear_bgp_peer_group_in_prefix_filter_cmd,
5816 "clear bgp peer-group WORD in prefix-filter",
5817 CLEAR_STR
5818 BGP_STR
5819 "Clear all members of peer-group\n"
5820 "BGP peer-group name\n"
5821 "Soft reconfig inbound update\n"
5822 "Push out prefix-list ORF and do inbound soft reconfig\n")
5823{
5824 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
5825 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5826}
5827
5828ALIAS (clear_bgp_peer_group_in_prefix_filter,
5829 clear_bgp_ipv6_peer_group_in_prefix_filter_cmd,
5830 "clear bgp ipv6 peer-group WORD in prefix-filter",
5831 CLEAR_STR
5832 BGP_STR
5833 "Address family\n"
5834 "Clear all members of peer-group\n"
5835 "BGP peer-group name\n"
5836 "Soft reconfig inbound update\n"
5837 "Push out prefix-list ORF and do inbound soft reconfig\n")
5838
5839DEFUN (clear_ip_bgp_external_soft_in,
5840 clear_ip_bgp_external_soft_in_cmd,
5841 "clear ip bgp external soft in",
5842 CLEAR_STR
5843 IP_STR
5844 BGP_STR
5845 "Clear all external peers\n"
5846 "Soft reconfig\n"
5847 "Soft reconfig inbound update\n")
5848{
5849 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5850 BGP_CLEAR_SOFT_IN, NULL);
5851}
5852
5853ALIAS (clear_ip_bgp_external_soft_in,
5854 clear_ip_bgp_external_in_cmd,
5855 "clear ip bgp external in",
5856 CLEAR_STR
5857 IP_STR
5858 BGP_STR
5859 "Clear all external peers\n"
5860 "Soft reconfig inbound update\n")
5861
5862DEFUN (clear_ip_bgp_external_in_prefix_filter,
5863 clear_ip_bgp_external_in_prefix_filter_cmd,
5864 "clear ip bgp external in prefix-filter",
5865 CLEAR_STR
5866 IP_STR
5867 BGP_STR
5868 "Clear all external peers\n"
5869 "Soft reconfig inbound update\n"
5870 "Push out prefix-list ORF and do inbound soft reconfig\n")
5871{
5872 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5873 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5874}
5875
5876DEFUN (clear_ip_bgp_external_ipv4_soft_in,
5877 clear_ip_bgp_external_ipv4_soft_in_cmd,
5878 "clear ip bgp external ipv4 (unicast|multicast) soft in",
5879 CLEAR_STR
5880 IP_STR
5881 BGP_STR
5882 "Clear all external peers\n"
5883 "Address family\n"
5884 "Address Family modifier\n"
5885 "Address Family modifier\n"
5886 "Soft reconfig\n"
5887 "Soft reconfig inbound update\n")
5888{
5889 if (strncmp (argv[0], "m", 1) == 0)
5890 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
5891 BGP_CLEAR_SOFT_IN, NULL);
5892
5893 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5894 BGP_CLEAR_SOFT_IN, NULL);
5895}
5896
5897ALIAS (clear_ip_bgp_external_ipv4_soft_in,
5898 clear_ip_bgp_external_ipv4_in_cmd,
5899 "clear ip bgp external ipv4 (unicast|multicast) in",
5900 CLEAR_STR
5901 IP_STR
5902 BGP_STR
5903 "Clear all external peers\n"
5904 "Address family\n"
5905 "Address Family modifier\n"
5906 "Address Family modifier\n"
5907 "Soft reconfig inbound update\n")
5908
5909DEFUN (clear_ip_bgp_external_ipv4_in_prefix_filter,
5910 clear_ip_bgp_external_ipv4_in_prefix_filter_cmd,
5911 "clear ip bgp external ipv4 (unicast|multicast) in prefix-filter",
5912 CLEAR_STR
5913 IP_STR
5914 BGP_STR
5915 "Clear all external peers\n"
5916 "Address family\n"
5917 "Address Family modifier\n"
5918 "Address Family modifier\n"
5919 "Soft reconfig inbound update\n"
5920 "Push out prefix-list ORF and do inbound soft reconfig\n")
5921{
5922 if (strncmp (argv[0], "m", 1) == 0)
5923 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
5924 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5925
5926 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5927 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5928}
5929
5930DEFUN (clear_bgp_external_soft_in,
5931 clear_bgp_external_soft_in_cmd,
5932 "clear bgp external soft in",
5933 CLEAR_STR
5934 BGP_STR
5935 "Clear all external peers\n"
5936 "Soft reconfig\n"
5937 "Soft reconfig inbound update\n")
5938{
5939 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
5940 BGP_CLEAR_SOFT_IN, NULL);
5941}
5942
5943ALIAS (clear_bgp_external_soft_in,
5944 clear_bgp_ipv6_external_soft_in_cmd,
5945 "clear bgp ipv6 external soft in",
5946 CLEAR_STR
5947 BGP_STR
5948 "Address family\n"
5949 "Clear all external peers\n"
5950 "Soft reconfig\n"
5951 "Soft reconfig inbound update\n")
5952
5953ALIAS (clear_bgp_external_soft_in,
5954 clear_bgp_external_in_cmd,
5955 "clear bgp external in",
5956 CLEAR_STR
5957 BGP_STR
5958 "Clear all external peers\n"
5959 "Soft reconfig inbound update\n")
5960
5961ALIAS (clear_bgp_external_soft_in,
5962 clear_bgp_ipv6_external_in_cmd,
5963 "clear bgp ipv6 external WORD in",
5964 CLEAR_STR
5965 BGP_STR
5966 "Address family\n"
5967 "Clear all external peers\n"
5968 "Soft reconfig inbound update\n")
5969
5970DEFUN (clear_bgp_external_in_prefix_filter,
5971 clear_bgp_external_in_prefix_filter_cmd,
5972 "clear bgp external in prefix-filter",
5973 CLEAR_STR
5974 BGP_STR
5975 "Clear all external peers\n"
5976 "Soft reconfig inbound update\n"
5977 "Push out prefix-list ORF and do inbound soft reconfig\n")
5978{
5979 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
5980 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5981}
5982
5983ALIAS (clear_bgp_external_in_prefix_filter,
5984 clear_bgp_ipv6_external_in_prefix_filter_cmd,
5985 "clear bgp ipv6 external in prefix-filter",
5986 CLEAR_STR
5987 BGP_STR
5988 "Address family\n"
5989 "Clear all external peers\n"
5990 "Soft reconfig inbound update\n"
5991 "Push out prefix-list ORF and do inbound soft reconfig\n")
5992
5993DEFUN (clear_ip_bgp_as_soft_in,
5994 clear_ip_bgp_as_soft_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00005995 "clear ip bgp " CMD_AS_RANGE " soft in",
paul718e3742002-12-13 20:15:29 +00005996 CLEAR_STR
5997 IP_STR
5998 BGP_STR
5999 "Clear peers with the AS number\n"
6000 "Soft reconfig\n"
6001 "Soft reconfig inbound update\n")
6002{
6003 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
6004 BGP_CLEAR_SOFT_IN, argv[0]);
6005}
6006
6007ALIAS (clear_ip_bgp_as_soft_in,
6008 clear_ip_bgp_as_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006009 "clear ip bgp " CMD_AS_RANGE " in",
paul718e3742002-12-13 20:15:29 +00006010 CLEAR_STR
6011 IP_STR
6012 BGP_STR
6013 "Clear peers with the AS number\n"
6014 "Soft reconfig inbound update\n")
6015
6016DEFUN (clear_ip_bgp_as_in_prefix_filter,
6017 clear_ip_bgp_as_in_prefix_filter_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006018 "clear ip bgp " CMD_AS_RANGE " in prefix-filter",
paul718e3742002-12-13 20:15:29 +00006019 CLEAR_STR
6020 IP_STR
6021 BGP_STR
6022 "Clear peers with the AS number\n"
6023 "Soft reconfig inbound update\n"
6024 "Push out prefix-list ORF and do inbound soft reconfig\n")
6025{
6026 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
6027 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6028}
6029
6030DEFUN (clear_ip_bgp_as_ipv4_soft_in,
6031 clear_ip_bgp_as_ipv4_soft_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006032 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft in",
paul718e3742002-12-13 20:15:29 +00006033 CLEAR_STR
6034 IP_STR
6035 BGP_STR
6036 "Clear peers with the AS number\n"
6037 "Address family\n"
6038 "Address Family modifier\n"
6039 "Address Family modifier\n"
6040 "Soft reconfig\n"
6041 "Soft reconfig inbound update\n")
6042{
6043 if (strncmp (argv[1], "m", 1) == 0)
6044 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
6045 BGP_CLEAR_SOFT_IN, argv[0]);
6046
6047 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
6048 BGP_CLEAR_SOFT_IN, argv[0]);
6049}
6050
6051ALIAS (clear_ip_bgp_as_ipv4_soft_in,
6052 clear_ip_bgp_as_ipv4_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006053 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in",
paul718e3742002-12-13 20:15:29 +00006054 CLEAR_STR
6055 IP_STR
6056 BGP_STR
6057 "Clear peers with the AS number\n"
6058 "Address family\n"
6059 "Address Family modifier\n"
6060 "Address Family modifier\n"
6061 "Soft reconfig inbound update\n")
6062
6063DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter,
6064 clear_ip_bgp_as_ipv4_in_prefix_filter_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006065 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in prefix-filter",
paul718e3742002-12-13 20:15:29 +00006066 CLEAR_STR
6067 IP_STR
6068 BGP_STR
6069 "Clear peers with the AS number\n"
6070 "Address family\n"
6071 "Address Family modifier\n"
6072 "Address Family modifier\n"
6073 "Soft reconfig inbound update\n"
6074 "Push out prefix-list ORF and do inbound soft reconfig\n")
6075{
6076 if (strncmp (argv[1], "m", 1) == 0)
6077 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
6078 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6079
6080 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
6081 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6082}
6083
6084DEFUN (clear_ip_bgp_as_vpnv4_soft_in,
6085 clear_ip_bgp_as_vpnv4_soft_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006086 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft in",
paul718e3742002-12-13 20:15:29 +00006087 CLEAR_STR
6088 IP_STR
6089 BGP_STR
6090 "Clear peers with the AS number\n"
6091 "Address family\n"
6092 "Address Family modifier\n"
6093 "Soft reconfig\n"
6094 "Soft reconfig inbound update\n")
6095{
6096 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
6097 BGP_CLEAR_SOFT_IN, argv[0]);
6098}
6099
6100ALIAS (clear_ip_bgp_as_vpnv4_soft_in,
6101 clear_ip_bgp_as_vpnv4_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006102 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast in",
paul718e3742002-12-13 20:15:29 +00006103 CLEAR_STR
6104 IP_STR
6105 BGP_STR
6106 "Clear peers with the AS number\n"
6107 "Address family\n"
6108 "Address Family modifier\n"
6109 "Soft reconfig inbound update\n")
6110
6111DEFUN (clear_bgp_as_soft_in,
6112 clear_bgp_as_soft_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006113 "clear bgp " CMD_AS_RANGE " soft in",
paul718e3742002-12-13 20:15:29 +00006114 CLEAR_STR
6115 BGP_STR
6116 "Clear peers with the AS number\n"
6117 "Soft reconfig\n"
6118 "Soft reconfig inbound update\n")
6119{
6120 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
6121 BGP_CLEAR_SOFT_IN, argv[0]);
6122}
6123
6124ALIAS (clear_bgp_as_soft_in,
6125 clear_bgp_ipv6_as_soft_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006126 "clear bgp ipv6 " CMD_AS_RANGE " soft in",
paul718e3742002-12-13 20:15:29 +00006127 CLEAR_STR
6128 BGP_STR
6129 "Address family\n"
6130 "Clear peers with the AS number\n"
6131 "Soft reconfig\n"
6132 "Soft reconfig inbound update\n")
6133
6134ALIAS (clear_bgp_as_soft_in,
6135 clear_bgp_as_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006136 "clear bgp " CMD_AS_RANGE " in",
paul718e3742002-12-13 20:15:29 +00006137 CLEAR_STR
6138 BGP_STR
6139 "Clear peers with the AS number\n"
6140 "Soft reconfig inbound update\n")
6141
6142ALIAS (clear_bgp_as_soft_in,
6143 clear_bgp_ipv6_as_in_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006144 "clear bgp ipv6 " CMD_AS_RANGE " in",
paul718e3742002-12-13 20:15:29 +00006145 CLEAR_STR
6146 BGP_STR
6147 "Address family\n"
6148 "Clear peers with the AS number\n"
6149 "Soft reconfig inbound update\n")
6150
6151DEFUN (clear_bgp_as_in_prefix_filter,
6152 clear_bgp_as_in_prefix_filter_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006153 "clear bgp " CMD_AS_RANGE " in prefix-filter",
paul718e3742002-12-13 20:15:29 +00006154 CLEAR_STR
6155 BGP_STR
6156 "Clear peers with the AS number\n"
6157 "Soft reconfig inbound update\n"
6158 "Push out prefix-list ORF and do inbound soft reconfig\n")
6159{
6160 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
6161 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6162}
6163
6164ALIAS (clear_bgp_as_in_prefix_filter,
6165 clear_bgp_ipv6_as_in_prefix_filter_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006166 "clear bgp ipv6 " CMD_AS_RANGE " in prefix-filter",
paul718e3742002-12-13 20:15:29 +00006167 CLEAR_STR
6168 BGP_STR
6169 "Address family\n"
6170 "Clear peers with the AS number\n"
6171 "Soft reconfig inbound update\n"
6172 "Push out prefix-list ORF and do inbound soft reconfig\n")
6173
6174/* Both soft-reconfiguration */
6175DEFUN (clear_ip_bgp_all_soft,
6176 clear_ip_bgp_all_soft_cmd,
6177 "clear ip bgp * soft",
6178 CLEAR_STR
6179 IP_STR
6180 BGP_STR
6181 "Clear all peers\n"
6182 "Soft reconfig\n")
6183{
6184 if (argc == 1)
6185 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
6186 BGP_CLEAR_SOFT_BOTH, NULL);
6187
6188 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6189 BGP_CLEAR_SOFT_BOTH, NULL);
6190}
6191
6192ALIAS (clear_ip_bgp_all_soft,
6193 clear_ip_bgp_instance_all_soft_cmd,
6194 "clear ip bgp view WORD * soft",
6195 CLEAR_STR
6196 IP_STR
6197 BGP_STR
6198 "BGP view\n"
6199 "view name\n"
6200 "Clear all peers\n"
6201 "Soft reconfig\n")
6202
6203
6204DEFUN (clear_ip_bgp_all_ipv4_soft,
6205 clear_ip_bgp_all_ipv4_soft_cmd,
6206 "clear ip bgp * ipv4 (unicast|multicast) soft",
6207 CLEAR_STR
6208 IP_STR
6209 BGP_STR
6210 "Clear all peers\n"
6211 "Address family\n"
6212 "Address Family Modifier\n"
6213 "Address Family Modifier\n"
6214 "Soft reconfig\n")
6215{
6216 if (strncmp (argv[0], "m", 1) == 0)
6217 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
6218 BGP_CLEAR_SOFT_BOTH, NULL);
6219
6220 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6221 BGP_CLEAR_SOFT_BOTH, NULL);
6222}
6223
6224DEFUN (clear_ip_bgp_instance_all_ipv4_soft,
6225 clear_ip_bgp_instance_all_ipv4_soft_cmd,
6226 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft",
6227 CLEAR_STR
6228 IP_STR
6229 BGP_STR
6230 "BGP view\n"
6231 "view name\n"
6232 "Clear all peers\n"
6233 "Address family\n"
6234 "Address Family Modifier\n"
6235 "Address Family Modifier\n"
6236 "Soft reconfig\n")
6237{
6238 if (strncmp (argv[1], "m", 1) == 0)
6239 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
6240 BGP_CLEAR_SOFT_BOTH, NULL);
6241
6242 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6243 BGP_CLEAR_SOFT_BOTH, NULL);
6244}
6245
6246DEFUN (clear_ip_bgp_all_vpnv4_soft,
6247 clear_ip_bgp_all_vpnv4_soft_cmd,
6248 "clear ip bgp * vpnv4 unicast soft",
6249 CLEAR_STR
6250 IP_STR
6251 BGP_STR
6252 "Clear all peers\n"
6253 "Address family\n"
6254 "Address Family Modifier\n"
6255 "Soft reconfig\n")
6256{
6257 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
6258 BGP_CLEAR_SOFT_BOTH, argv[0]);
6259}
6260
6261DEFUN (clear_bgp_all_soft,
6262 clear_bgp_all_soft_cmd,
6263 "clear bgp * soft",
6264 CLEAR_STR
6265 BGP_STR
6266 "Clear all peers\n"
6267 "Soft reconfig\n")
6268{
6269 if (argc == 1)
6270 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
6271 BGP_CLEAR_SOFT_BOTH, argv[0]);
6272
6273 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
6274 BGP_CLEAR_SOFT_BOTH, argv[0]);
6275}
6276
6277ALIAS (clear_bgp_all_soft,
6278 clear_bgp_instance_all_soft_cmd,
6279 "clear bgp view WORD * soft",
6280 CLEAR_STR
6281 BGP_STR
6282 "BGP view\n"
6283 "view name\n"
6284 "Clear all peers\n"
6285 "Soft reconfig\n")
6286
6287ALIAS (clear_bgp_all_soft,
6288 clear_bgp_ipv6_all_soft_cmd,
6289 "clear bgp ipv6 * soft",
6290 CLEAR_STR
6291 BGP_STR
6292 "Address family\n"
6293 "Clear all peers\n"
6294 "Soft reconfig\n")
6295
6296DEFUN (clear_ip_bgp_peer_soft,
6297 clear_ip_bgp_peer_soft_cmd,
6298 "clear ip bgp A.B.C.D soft",
6299 CLEAR_STR
6300 IP_STR
6301 BGP_STR
6302 "BGP neighbor address to clear\n"
6303 "Soft reconfig\n")
6304{
6305 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6306 BGP_CLEAR_SOFT_BOTH, argv[0]);
6307}
6308
6309DEFUN (clear_ip_bgp_peer_ipv4_soft,
6310 clear_ip_bgp_peer_ipv4_soft_cmd,
6311 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft",
6312 CLEAR_STR
6313 IP_STR
6314 BGP_STR
6315 "BGP neighbor address to clear\n"
6316 "Address family\n"
6317 "Address Family Modifier\n"
6318 "Address Family Modifier\n"
6319 "Soft reconfig\n")
6320{
6321 if (strncmp (argv[1], "m", 1) == 0)
6322 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
6323 BGP_CLEAR_SOFT_BOTH, argv[0]);
6324
6325 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6326 BGP_CLEAR_SOFT_BOTH, argv[0]);
6327}
6328
6329DEFUN (clear_ip_bgp_peer_vpnv4_soft,
6330 clear_ip_bgp_peer_vpnv4_soft_cmd,
6331 "clear ip bgp A.B.C.D vpnv4 unicast soft",
6332 CLEAR_STR
6333 IP_STR
6334 BGP_STR
6335 "BGP neighbor address to clear\n"
6336 "Address family\n"
6337 "Address Family Modifier\n"
6338 "Soft reconfig\n")
6339{
6340 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
6341 BGP_CLEAR_SOFT_BOTH, argv[0]);
6342}
6343
6344DEFUN (clear_bgp_peer_soft,
6345 clear_bgp_peer_soft_cmd,
6346 "clear bgp (A.B.C.D|X:X::X:X) soft",
6347 CLEAR_STR
6348 BGP_STR
6349 "BGP neighbor address to clear\n"
6350 "BGP IPv6 neighbor to clear\n"
6351 "Soft reconfig\n")
6352{
6353 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
6354 BGP_CLEAR_SOFT_BOTH, argv[0]);
6355}
6356
6357ALIAS (clear_bgp_peer_soft,
6358 clear_bgp_ipv6_peer_soft_cmd,
6359 "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft",
6360 CLEAR_STR
6361 BGP_STR
6362 "Address family\n"
6363 "BGP neighbor address to clear\n"
6364 "BGP IPv6 neighbor to clear\n"
6365 "Soft reconfig\n")
6366
6367DEFUN (clear_ip_bgp_peer_group_soft,
6368 clear_ip_bgp_peer_group_soft_cmd,
6369 "clear ip bgp peer-group WORD soft",
6370 CLEAR_STR
6371 IP_STR
6372 BGP_STR
6373 "Clear all members of peer-group\n"
6374 "BGP peer-group name\n"
6375 "Soft reconfig\n")
6376{
6377 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6378 BGP_CLEAR_SOFT_BOTH, argv[0]);
6379}
6380
6381DEFUN (clear_ip_bgp_peer_group_ipv4_soft,
6382 clear_ip_bgp_peer_group_ipv4_soft_cmd,
6383 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft",
6384 CLEAR_STR
6385 IP_STR
6386 BGP_STR
6387 "Clear all members of peer-group\n"
6388 "BGP peer-group name\n"
6389 "Address family\n"
6390 "Address Family modifier\n"
6391 "Address Family modifier\n"
6392 "Soft reconfig\n")
6393{
6394 if (strncmp (argv[1], "m", 1) == 0)
6395 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
6396 BGP_CLEAR_SOFT_BOTH, argv[0]);
6397
6398 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6399 BGP_CLEAR_SOFT_BOTH, argv[0]);
6400}
6401
6402DEFUN (clear_bgp_peer_group_soft,
6403 clear_bgp_peer_group_soft_cmd,
6404 "clear bgp peer-group WORD soft",
6405 CLEAR_STR
6406 BGP_STR
6407 "Clear all members of peer-group\n"
6408 "BGP peer-group name\n"
6409 "Soft reconfig\n")
6410{
6411 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
6412 BGP_CLEAR_SOFT_BOTH, argv[0]);
6413}
6414
6415ALIAS (clear_bgp_peer_group_soft,
6416 clear_bgp_ipv6_peer_group_soft_cmd,
6417 "clear bgp ipv6 peer-group WORD soft",
6418 CLEAR_STR
6419 BGP_STR
6420 "Address family\n"
6421 "Clear all members of peer-group\n"
6422 "BGP peer-group name\n"
6423 "Soft reconfig\n")
6424
6425DEFUN (clear_ip_bgp_external_soft,
6426 clear_ip_bgp_external_soft_cmd,
6427 "clear ip bgp external soft",
6428 CLEAR_STR
6429 IP_STR
6430 BGP_STR
6431 "Clear all external peers\n"
6432 "Soft reconfig\n")
6433{
6434 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
6435 BGP_CLEAR_SOFT_BOTH, NULL);
6436}
6437
6438DEFUN (clear_ip_bgp_external_ipv4_soft,
6439 clear_ip_bgp_external_ipv4_soft_cmd,
6440 "clear ip bgp external ipv4 (unicast|multicast) soft",
6441 CLEAR_STR
6442 IP_STR
6443 BGP_STR
6444 "Clear all external peers\n"
6445 "Address family\n"
6446 "Address Family modifier\n"
6447 "Address Family modifier\n"
6448 "Soft reconfig\n")
6449{
6450 if (strncmp (argv[0], "m", 1) == 0)
6451 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
6452 BGP_CLEAR_SOFT_BOTH, NULL);
6453
6454 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
6455 BGP_CLEAR_SOFT_BOTH, NULL);
6456}
6457
6458DEFUN (clear_bgp_external_soft,
6459 clear_bgp_external_soft_cmd,
6460 "clear bgp external soft",
6461 CLEAR_STR
6462 BGP_STR
6463 "Clear all external peers\n"
6464 "Soft reconfig\n")
6465{
6466 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
6467 BGP_CLEAR_SOFT_BOTH, NULL);
6468}
6469
6470ALIAS (clear_bgp_external_soft,
6471 clear_bgp_ipv6_external_soft_cmd,
6472 "clear bgp ipv6 external soft",
6473 CLEAR_STR
6474 BGP_STR
6475 "Address family\n"
6476 "Clear all external peers\n"
6477 "Soft reconfig\n")
6478
6479DEFUN (clear_ip_bgp_as_soft,
6480 clear_ip_bgp_as_soft_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006481 "clear ip bgp " CMD_AS_RANGE " soft",
paul718e3742002-12-13 20:15:29 +00006482 CLEAR_STR
6483 IP_STR
6484 BGP_STR
6485 "Clear peers with the AS number\n"
6486 "Soft reconfig\n")
6487{
6488 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
6489 BGP_CLEAR_SOFT_BOTH, argv[0]);
6490}
6491
6492DEFUN (clear_ip_bgp_as_ipv4_soft,
6493 clear_ip_bgp_as_ipv4_soft_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006494 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft",
paul718e3742002-12-13 20:15:29 +00006495 CLEAR_STR
6496 IP_STR
6497 BGP_STR
6498 "Clear peers with the AS number\n"
6499 "Address family\n"
6500 "Address Family Modifier\n"
6501 "Address Family Modifier\n"
6502 "Soft reconfig\n")
6503{
6504 if (strncmp (argv[1], "m", 1) == 0)
6505 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
6506 BGP_CLEAR_SOFT_BOTH, argv[0]);
6507
6508 return bgp_clear_vty (vty, NULL,AFI_IP, SAFI_UNICAST, clear_as,
6509 BGP_CLEAR_SOFT_BOTH, argv[0]);
6510}
6511
6512DEFUN (clear_ip_bgp_as_vpnv4_soft,
6513 clear_ip_bgp_as_vpnv4_soft_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006514 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft",
paul718e3742002-12-13 20:15:29 +00006515 CLEAR_STR
6516 IP_STR
6517 BGP_STR
6518 "Clear peers with the AS number\n"
6519 "Address family\n"
6520 "Address Family Modifier\n"
6521 "Soft reconfig\n")
6522{
6523 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
6524 BGP_CLEAR_SOFT_BOTH, argv[0]);
6525}
6526
6527DEFUN (clear_bgp_as_soft,
6528 clear_bgp_as_soft_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006529 "clear bgp " CMD_AS_RANGE " soft",
paul718e3742002-12-13 20:15:29 +00006530 CLEAR_STR
6531 BGP_STR
6532 "Clear peers with the AS number\n"
6533 "Soft reconfig\n")
6534{
6535 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
6536 BGP_CLEAR_SOFT_BOTH, argv[0]);
6537}
6538
6539ALIAS (clear_bgp_as_soft,
6540 clear_bgp_ipv6_as_soft_cmd,
Paul Jakma320da872008-07-02 13:40:33 +00006541 "clear bgp ipv6 " CMD_AS_RANGE " soft",
paul718e3742002-12-13 20:15:29 +00006542 CLEAR_STR
6543 BGP_STR
6544 "Address family\n"
6545 "Clear peers with the AS number\n"
6546 "Soft reconfig\n")
6547
paulfee0f4c2004-09-13 05:12:46 +00006548/* RS-client soft reconfiguration. */
6549#ifdef HAVE_IPV6
6550DEFUN (clear_bgp_all_rsclient,
6551 clear_bgp_all_rsclient_cmd,
6552 "clear bgp * rsclient",
6553 CLEAR_STR
6554 BGP_STR
6555 "Clear all peers\n"
6556 "Soft reconfig for rsclient RIB\n")
6557{
6558 if (argc == 1)
6559 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
6560 BGP_CLEAR_SOFT_RSCLIENT, NULL);
6561
6562 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
6563 BGP_CLEAR_SOFT_RSCLIENT, NULL);
6564}
6565
6566ALIAS (clear_bgp_all_rsclient,
6567 clear_bgp_ipv6_all_rsclient_cmd,
6568 "clear bgp ipv6 * rsclient",
6569 CLEAR_STR
6570 BGP_STR
6571 "Address family\n"
6572 "Clear all peers\n"
6573 "Soft reconfig for rsclient RIB\n")
6574
6575ALIAS (clear_bgp_all_rsclient,
6576 clear_bgp_instance_all_rsclient_cmd,
6577 "clear bgp view WORD * rsclient",
6578 CLEAR_STR
6579 BGP_STR
6580 "BGP view\n"
6581 "view name\n"
6582 "Clear all peers\n"
6583 "Soft reconfig for rsclient RIB\n")
6584
6585ALIAS (clear_bgp_all_rsclient,
6586 clear_bgp_ipv6_instance_all_rsclient_cmd,
6587 "clear bgp ipv6 view WORD * rsclient",
6588 CLEAR_STR
6589 BGP_STR
6590 "Address family\n"
6591 "BGP view\n"
6592 "view name\n"
6593 "Clear all peers\n"
6594 "Soft reconfig for rsclient RIB\n")
6595#endif /* HAVE_IPV6 */
6596
6597DEFUN (clear_ip_bgp_all_rsclient,
6598 clear_ip_bgp_all_rsclient_cmd,
6599 "clear ip bgp * rsclient",
6600 CLEAR_STR
6601 IP_STR
6602 BGP_STR
6603 "Clear all peers\n"
6604 "Soft reconfig for rsclient RIB\n")
6605{
6606 if (argc == 1)
6607 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
6608 BGP_CLEAR_SOFT_RSCLIENT, NULL);
6609
6610 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6611 BGP_CLEAR_SOFT_RSCLIENT, NULL);
6612}
6613
6614ALIAS (clear_ip_bgp_all_rsclient,
6615 clear_ip_bgp_instance_all_rsclient_cmd,
6616 "clear ip bgp view WORD * rsclient",
6617 CLEAR_STR
6618 IP_STR
6619 BGP_STR
6620 "BGP view\n"
6621 "view name\n"
6622 "Clear all peers\n"
6623 "Soft reconfig for rsclient RIB\n")
6624
6625#ifdef HAVE_IPV6
6626DEFUN (clear_bgp_peer_rsclient,
6627 clear_bgp_peer_rsclient_cmd,
6628 "clear bgp (A.B.C.D|X:X::X:X) rsclient",
6629 CLEAR_STR
6630 BGP_STR
6631 "BGP neighbor IP address to clear\n"
6632 "BGP IPv6 neighbor to clear\n"
6633 "Soft reconfig for rsclient RIB\n")
6634{
6635 if (argc == 2)
6636 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_peer,
6637 BGP_CLEAR_SOFT_RSCLIENT, argv[1]);
6638
6639 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
6640 BGP_CLEAR_SOFT_RSCLIENT, argv[0]);
6641}
6642
6643ALIAS (clear_bgp_peer_rsclient,
6644 clear_bgp_ipv6_peer_rsclient_cmd,
6645 "clear bgp ipv6 (A.B.C.D|X:X::X:X) rsclient",
6646 CLEAR_STR
6647 BGP_STR
6648 "Address family\n"
6649 "BGP neighbor IP address to clear\n"
6650 "BGP IPv6 neighbor to clear\n"
6651 "Soft reconfig for rsclient RIB\n")
6652
6653ALIAS (clear_bgp_peer_rsclient,
6654 clear_bgp_instance_peer_rsclient_cmd,
6655 "clear bgp view WORD (A.B.C.D|X:X::X:X) rsclient",
6656 CLEAR_STR
6657 BGP_STR
6658 "BGP view\n"
6659 "view name\n"
6660 "BGP neighbor IP address to clear\n"
6661 "BGP IPv6 neighbor to clear\n"
6662 "Soft reconfig for rsclient RIB\n")
6663
6664ALIAS (clear_bgp_peer_rsclient,
6665 clear_bgp_ipv6_instance_peer_rsclient_cmd,
6666 "clear bgp ipv6 view WORD (A.B.C.D|X:X::X:X) rsclient",
6667 CLEAR_STR
6668 BGP_STR
6669 "Address family\n"
6670 "BGP view\n"
6671 "view name\n"
6672 "BGP neighbor IP address to clear\n"
6673 "BGP IPv6 neighbor to clear\n"
6674 "Soft reconfig for rsclient RIB\n")
6675#endif /* HAVE_IPV6 */
6676
6677DEFUN (clear_ip_bgp_peer_rsclient,
6678 clear_ip_bgp_peer_rsclient_cmd,
6679 "clear ip bgp (A.B.C.D|X:X::X:X) rsclient",
6680 CLEAR_STR
6681 IP_STR
6682 BGP_STR
6683 "BGP neighbor IP address to clear\n"
6684 "BGP IPv6 neighbor to clear\n"
6685 "Soft reconfig for rsclient RIB\n")
6686{
6687 if (argc == 2)
6688 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_peer,
6689 BGP_CLEAR_SOFT_RSCLIENT, argv[1]);
6690
6691 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6692 BGP_CLEAR_SOFT_RSCLIENT, argv[0]);
6693}
6694
6695ALIAS (clear_ip_bgp_peer_rsclient,
6696 clear_ip_bgp_instance_peer_rsclient_cmd,
6697 "clear ip bgp view WORD (A.B.C.D|X:X::X:X) rsclient",
6698 CLEAR_STR
6699 IP_STR
6700 BGP_STR
6701 "BGP view\n"
6702 "view name\n"
6703 "BGP neighbor IP address to clear\n"
6704 "BGP IPv6 neighbor to clear\n"
6705 "Soft reconfig for rsclient RIB\n")
6706
Michael Lamberte0081f72008-11-16 20:12:04 +00006707DEFUN (show_bgp_views,
6708 show_bgp_views_cmd,
6709 "show bgp views",
6710 SHOW_STR
6711 BGP_STR
6712 "Show the defined BGP views\n")
6713{
6714 struct list *inst = bm->bgp;
6715 struct listnode *node;
6716 struct bgp *bgp;
6717
6718 if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
6719 {
6720 vty_out (vty, "Multiple BGP views are not defined%s", VTY_NEWLINE);
6721 return CMD_WARNING;
6722 }
6723
6724 vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE);
6725 for (ALL_LIST_ELEMENTS_RO(inst, node, bgp))
6726 vty_out (vty, "\t%s (AS%u)%s",
6727 bgp->name ? bgp->name : "(null)",
6728 bgp->as, VTY_NEWLINE);
6729
6730 return CMD_SUCCESS;
6731}
6732
Paul Jakma4bf6a362006-03-30 14:05:23 +00006733DEFUN (show_bgp_memory,
6734 show_bgp_memory_cmd,
6735 "show bgp memory",
6736 SHOW_STR
6737 BGP_STR
6738 "Global BGP memory statistics\n")
6739{
6740 char memstrbuf[MTYPE_MEMSTR_LEN];
6741 unsigned long count;
6742
6743 /* RIB related usage stats */
6744 count = mtype_stats_alloc (MTYPE_BGP_NODE);
6745 vty_out (vty, "%ld RIB nodes, using %s of memory%s", count,
6746 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6747 count * sizeof (struct bgp_node)),
6748 VTY_NEWLINE);
6749
6750 count = mtype_stats_alloc (MTYPE_BGP_ROUTE);
6751 vty_out (vty, "%ld BGP routes, using %s of memory%s", count,
6752 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6753 count * sizeof (struct bgp_info)),
6754 VTY_NEWLINE);
Paul Jakmafb982c22007-05-04 20:15:47 +00006755 if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA)))
6756 vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count,
6757 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6758 count * sizeof (struct bgp_info_extra)),
6759 VTY_NEWLINE);
Paul Jakma4bf6a362006-03-30 14:05:23 +00006760
6761 if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC)))
6762 vty_out (vty, "%ld Static routes, using %s of memory%s", count,
6763 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6764 count * sizeof (struct bgp_static)),
6765 VTY_NEWLINE);
6766
6767 /* Adj-In/Out */
6768 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN)))
6769 vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count,
6770 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6771 count * sizeof (struct bgp_adj_in)),
6772 VTY_NEWLINE);
6773 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT)))
6774 vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count,
6775 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6776 count * sizeof (struct bgp_adj_out)),
6777 VTY_NEWLINE);
6778
6779 if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE)))
6780 vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count,
6781 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6782 count * sizeof (struct bgp_nexthop_cache)),
6783 VTY_NEWLINE);
6784
6785 if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO)))
6786 vty_out (vty, "%ld Dampening entries, using %s of memory%s", count,
6787 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6788 count * sizeof (struct bgp_damp_info)),
6789 VTY_NEWLINE);
6790
6791 /* Attributes */
6792 count = attr_count();
6793 vty_out (vty, "%ld BGP attributes, using %s of memory%s", count,
6794 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6795 count * sizeof(struct attr)),
6796 VTY_NEWLINE);
Paul Jakmafb982c22007-05-04 20:15:47 +00006797 if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA)))
6798 vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count,
6799 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6800 count * sizeof(struct attr_extra)),
6801 VTY_NEWLINE);
Paul Jakma4bf6a362006-03-30 14:05:23 +00006802
6803 if ((count = attr_unknown_count()))
6804 vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE);
6805
6806 /* AS_PATH attributes */
6807 count = aspath_count ();
6808 vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count,
6809 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6810 count * sizeof (struct aspath)),
6811 VTY_NEWLINE);
6812
6813 count = mtype_stats_alloc (MTYPE_AS_SEG);
6814 vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count,
6815 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6816 count * sizeof (struct assegment)),
6817 VTY_NEWLINE);
6818
6819 /* Other attributes */
6820 if ((count = community_count ()))
6821 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
6822 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6823 count * sizeof (struct community)),
6824 VTY_NEWLINE);
6825 if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY)))
6826 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
6827 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6828 count * sizeof (struct ecommunity)),
6829 VTY_NEWLINE);
6830
6831 if ((count = mtype_stats_alloc (MTYPE_CLUSTER)))
6832 vty_out (vty, "%ld Cluster lists, using %s of memory%s", count,
6833 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6834 count * sizeof (struct cluster_list)),
6835 VTY_NEWLINE);
6836
6837 /* Peer related usage */
6838 count = mtype_stats_alloc (MTYPE_BGP_PEER);
6839 vty_out (vty, "%ld peers, using %s of memory%s", count,
6840 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6841 count * sizeof (struct peer)),
6842 VTY_NEWLINE);
6843
6844 if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP)))
6845 vty_out (vty, "%ld peer groups, using %s of memory%s", count,
6846 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6847 count * sizeof (struct peer_group)),
6848 VTY_NEWLINE);
6849
6850 /* Other */
6851 if ((count = mtype_stats_alloc (MTYPE_HASH)))
6852 vty_out (vty, "%ld hash tables, using %s of memory%s", count,
6853 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6854 count * sizeof (struct hash)),
6855 VTY_NEWLINE);
6856 if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET)))
6857 vty_out (vty, "%ld hash buckets, using %s of memory%s", count,
6858 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6859 count * sizeof (struct hash_backet)),
6860 VTY_NEWLINE);
6861 if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP)))
6862 vty_out (vty, "%ld compiled regexes, using %s of memory%s", count,
6863 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6864 count * sizeof (regex_t)),
6865 VTY_NEWLINE);
6866 return CMD_SUCCESS;
6867}
paulfee0f4c2004-09-13 05:12:46 +00006868
paul718e3742002-12-13 20:15:29 +00006869/* Show BGP peer's summary information. */
paul94f2b392005-06-28 12:44:16 +00006870static int
paul718e3742002-12-13 20:15:29 +00006871bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi)
6872{
6873 struct peer *peer;
paul1eb8ef22005-04-07 07:30:20 +00006874 struct listnode *node, *nnode;
Paul Jakma4bf6a362006-03-30 14:05:23 +00006875 unsigned int count = 0;
paul718e3742002-12-13 20:15:29 +00006876 char timebuf[BGP_UPTIME_LEN];
6877 int len;
6878
6879 /* Header string for each address family. */
6880 static char header[] = "Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd";
Paul Jakma4bf6a362006-03-30 14:05:23 +00006881
paul1eb8ef22005-04-07 07:30:20 +00006882 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00006883 {
6884 if (peer->afc[afi][safi])
6885 {
Paul Jakma4bf6a362006-03-30 14:05:23 +00006886 if (!count)
6887 {
6888 unsigned long ents;
6889 char memstrbuf[MTYPE_MEMSTR_LEN];
6890
6891 /* Usage summary and header */
6892 vty_out (vty,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04006893 "BGP router identifier %s, local AS number %u%s",
Paul Jakma4bf6a362006-03-30 14:05:23 +00006894 inet_ntoa (bgp->router_id), bgp->as, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006895
Paul Jakma4bf6a362006-03-30 14:05:23 +00006896 ents = bgp_table_count (bgp->rib[afi][safi]);
6897 vty_out (vty, "RIB entries %ld, using %s of memory%s", ents,
6898 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6899 ents * sizeof (struct bgp_node)),
6900 VTY_NEWLINE);
6901
6902 /* Peer related usage */
6903 ents = listcount (bgp->peer);
6904 vty_out (vty, "Peers %ld, using %s of memory%s",
6905 ents,
6906 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6907 ents * sizeof (struct peer)),
6908 VTY_NEWLINE);
6909
6910 if ((ents = listcount (bgp->rsclient)))
6911 vty_out (vty, "RS-Client peers %ld, using %s of memory%s",
6912 ents,
6913 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6914 ents * sizeof (struct peer)),
6915 VTY_NEWLINE);
6916
6917 if ((ents = listcount (bgp->group)))
6918 vty_out (vty, "Peer groups %ld, using %s of memory%s", ents,
6919 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6920 ents * sizeof (struct peer_group)),
6921 VTY_NEWLINE);
6922
6923 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
6924 vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE);
6925 vty_out (vty, "%s", VTY_NEWLINE);
6926 vty_out (vty, "%s%s", header, VTY_NEWLINE);
6927 }
6928
paul718e3742002-12-13 20:15:29 +00006929 count++;
6930
6931 len = vty_out (vty, "%s", peer->host);
6932 len = 16 - len;
6933 if (len < 1)
6934 vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
6935 else
6936 vty_out (vty, "%*s", len, " ");
6937
hasso3d515fd2005-02-01 21:30:04 +00006938 vty_out (vty, "4 ");
paul718e3742002-12-13 20:15:29 +00006939
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04006940 vty_out (vty, "%5u %7d %7d %8d %4d %4lu ",
paul718e3742002-12-13 20:15:29 +00006941 peer->as,
6942 peer->open_in + peer->update_in + peer->keepalive_in
6943 + peer->notify_in + peer->refresh_in + peer->dynamic_cap_in,
6944 peer->open_out + peer->update_out + peer->keepalive_out
6945 + peer->notify_out + peer->refresh_out
6946 + peer->dynamic_cap_out,
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00006947 0, 0, (unsigned long) peer->obuf->count);
paul718e3742002-12-13 20:15:29 +00006948
6949 vty_out (vty, "%8s",
6950 peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN));
6951
6952 if (peer->status == Established)
6953 {
6954 vty_out (vty, " %8ld", peer->pcount[afi][safi]);
6955 }
6956 else
6957 {
6958 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
6959 vty_out (vty, " Idle (Admin)");
6960 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
6961 vty_out (vty, " Idle (PfxCt)");
6962 else
6963 vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, peer->status));
6964 }
6965
6966 vty_out (vty, "%s", VTY_NEWLINE);
6967 }
6968 }
6969
6970 if (count)
6971 vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE,
6972 count, VTY_NEWLINE);
6973 else
6974 vty_out (vty, "No %s neighbor is configured%s",
6975 afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
6976 return CMD_SUCCESS;
6977}
6978
paul94f2b392005-06-28 12:44:16 +00006979static int
paulfd79ac92004-10-13 05:06:08 +00006980bgp_show_summary_vty (struct vty *vty, const char *name,
6981 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00006982{
6983 struct bgp *bgp;
6984
6985 if (name)
6986 {
6987 bgp = bgp_lookup_by_name (name);
6988
6989 if (! bgp)
6990 {
6991 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
6992 return CMD_WARNING;
6993 }
6994
6995 bgp_show_summary (vty, bgp, afi, safi);
6996 return CMD_SUCCESS;
6997 }
6998
6999 bgp = bgp_get_default ();
7000
7001 if (bgp)
7002 bgp_show_summary (vty, bgp, afi, safi);
7003
7004 return CMD_SUCCESS;
7005}
7006
7007/* `show ip bgp summary' commands. */
7008DEFUN (show_ip_bgp_summary,
7009 show_ip_bgp_summary_cmd,
7010 "show ip bgp summary",
7011 SHOW_STR
7012 IP_STR
7013 BGP_STR
7014 "Summary of BGP neighbor status\n")
7015{
7016 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
7017}
7018
7019DEFUN (show_ip_bgp_instance_summary,
7020 show_ip_bgp_instance_summary_cmd,
7021 "show ip bgp view WORD summary",
7022 SHOW_STR
7023 IP_STR
7024 BGP_STR
7025 "BGP view\n"
7026 "View name\n"
7027 "Summary of BGP neighbor status\n")
7028{
7029 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
7030}
7031
7032DEFUN (show_ip_bgp_ipv4_summary,
7033 show_ip_bgp_ipv4_summary_cmd,
7034 "show ip bgp ipv4 (unicast|multicast) summary",
7035 SHOW_STR
7036 IP_STR
7037 BGP_STR
7038 "Address family\n"
7039 "Address Family modifier\n"
7040 "Address Family modifier\n"
7041 "Summary of BGP neighbor status\n")
7042{
7043 if (strncmp (argv[0], "m", 1) == 0)
7044 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST);
7045
7046 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
7047}
7048
Michael Lambert95cbbd22010-07-23 14:43:04 -04007049ALIAS (show_ip_bgp_ipv4_summary,
7050 show_bgp_ipv4_safi_summary_cmd,
7051 "show bgp ipv4 (unicast|multicast) summary",
7052 SHOW_STR
7053 BGP_STR
7054 "Address family\n"
7055 "Address Family modifier\n"
7056 "Address Family modifier\n"
7057 "Summary of BGP neighbor status\n")
7058
paul718e3742002-12-13 20:15:29 +00007059DEFUN (show_ip_bgp_instance_ipv4_summary,
7060 show_ip_bgp_instance_ipv4_summary_cmd,
7061 "show ip bgp view WORD ipv4 (unicast|multicast) summary",
7062 SHOW_STR
7063 IP_STR
7064 BGP_STR
7065 "BGP view\n"
7066 "View name\n"
7067 "Address family\n"
7068 "Address Family modifier\n"
7069 "Address Family modifier\n"
7070 "Summary of BGP neighbor status\n")
7071{
7072 if (strncmp (argv[1], "m", 1) == 0)
7073 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST);
7074 else
7075 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
7076}
7077
Michael Lambert95cbbd22010-07-23 14:43:04 -04007078ALIAS (show_ip_bgp_instance_ipv4_summary,
7079 show_bgp_instance_ipv4_safi_summary_cmd,
7080 "show bgp view WORD ipv4 (unicast|multicast) summary",
7081 SHOW_STR
7082 BGP_STR
7083 "BGP view\n"
7084 "View name\n"
7085 "Address family\n"
7086 "Address Family modifier\n"
7087 "Address Family modifier\n"
7088 "Summary of BGP neighbor status\n")
7089
paul718e3742002-12-13 20:15:29 +00007090DEFUN (show_ip_bgp_vpnv4_all_summary,
7091 show_ip_bgp_vpnv4_all_summary_cmd,
7092 "show ip bgp vpnv4 all summary",
7093 SHOW_STR
7094 IP_STR
7095 BGP_STR
7096 "Display VPNv4 NLRI specific information\n"
7097 "Display information about all VPNv4 NLRIs\n"
7098 "Summary of BGP neighbor status\n")
7099{
7100 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN);
7101}
7102
7103DEFUN (show_ip_bgp_vpnv4_rd_summary,
7104 show_ip_bgp_vpnv4_rd_summary_cmd,
7105 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn summary",
7106 SHOW_STR
7107 IP_STR
7108 BGP_STR
7109 "Display VPNv4 NLRI specific information\n"
7110 "Display information for a route distinguisher\n"
7111 "VPN Route Distinguisher\n"
7112 "Summary of BGP neighbor status\n")
7113{
7114 int ret;
7115 struct prefix_rd prd;
7116
7117 ret = str2prefix_rd (argv[0], &prd);
7118 if (! ret)
7119 {
7120 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7121 return CMD_WARNING;
7122 }
7123
7124 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN);
7125}
7126
7127#ifdef HAVE_IPV6
7128DEFUN (show_bgp_summary,
7129 show_bgp_summary_cmd,
7130 "show bgp summary",
7131 SHOW_STR
7132 BGP_STR
7133 "Summary of BGP neighbor status\n")
7134{
7135 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
7136}
7137
7138DEFUN (show_bgp_instance_summary,
7139 show_bgp_instance_summary_cmd,
7140 "show bgp view WORD summary",
7141 SHOW_STR
7142 BGP_STR
7143 "BGP view\n"
7144 "View name\n"
7145 "Summary of BGP neighbor status\n")
7146{
7147 return bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
7148}
7149
7150ALIAS (show_bgp_summary,
7151 show_bgp_ipv6_summary_cmd,
7152 "show bgp ipv6 summary",
7153 SHOW_STR
7154 BGP_STR
7155 "Address family\n"
7156 "Summary of BGP neighbor status\n")
7157
7158ALIAS (show_bgp_instance_summary,
7159 show_bgp_instance_ipv6_summary_cmd,
7160 "show bgp view WORD ipv6 summary",
7161 SHOW_STR
7162 BGP_STR
7163 "BGP view\n"
7164 "View name\n"
7165 "Address family\n"
7166 "Summary of BGP neighbor status\n")
7167
Michael Lambert95cbbd22010-07-23 14:43:04 -04007168DEFUN (show_bgp_ipv6_safi_summary,
7169 show_bgp_ipv6_safi_summary_cmd,
7170 "show bgp ipv6 (unicast|multicast) summary",
7171 SHOW_STR
7172 BGP_STR
7173 "Address family\n"
7174 "Address Family modifier\n"
7175 "Address Family modifier\n"
7176 "Summary of BGP neighbor status\n")
7177{
7178 if (strncmp (argv[0], "m", 1) == 0)
7179 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST);
7180
7181 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
7182}
7183
7184DEFUN (show_bgp_instance_ipv6_safi_summary,
7185 show_bgp_instance_ipv6_safi_summary_cmd,
7186 "show bgp view WORD ipv6 (unicast|multicast) summary",
7187 SHOW_STR
7188 BGP_STR
7189 "BGP view\n"
7190 "View name\n"
7191 "Address family\n"
7192 "Address Family modifier\n"
7193 "Address Family modifier\n"
7194 "Summary of BGP neighbor status\n")
7195{
7196 if (strncmp (argv[1], "m", 1) == 0)
7197 return bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_MULTICAST);
7198
7199 return bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
7200}
7201
paul718e3742002-12-13 20:15:29 +00007202/* old command */
7203DEFUN (show_ipv6_bgp_summary,
7204 show_ipv6_bgp_summary_cmd,
7205 "show ipv6 bgp summary",
7206 SHOW_STR
7207 IPV6_STR
7208 BGP_STR
7209 "Summary of BGP neighbor status\n")
7210{
7211 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
7212}
7213
7214/* old command */
7215DEFUN (show_ipv6_mbgp_summary,
7216 show_ipv6_mbgp_summary_cmd,
7217 "show ipv6 mbgp summary",
7218 SHOW_STR
7219 IPV6_STR
7220 MBGP_STR
7221 "Summary of BGP neighbor status\n")
7222{
7223 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST);
7224}
7225#endif /* HAVE_IPV6 */
7226
paulfd79ac92004-10-13 05:06:08 +00007227const char *
hasso538621f2004-05-21 09:31:30 +00007228afi_safi_print (afi_t afi, safi_t safi)
7229{
7230 if (afi == AFI_IP && safi == SAFI_UNICAST)
7231 return "IPv4 Unicast";
7232 else if (afi == AFI_IP && safi == SAFI_MULTICAST)
7233 return "IPv4 Multicast";
7234 else if (afi == AFI_IP && safi == SAFI_MPLS_VPN)
7235 return "VPNv4 Unicast";
7236 else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
7237 return "IPv6 Unicast";
7238 else if (afi == AFI_IP6 && safi == SAFI_MULTICAST)
7239 return "IPv6 Multicast";
7240 else
7241 return "Unknown";
7242}
7243
paul718e3742002-12-13 20:15:29 +00007244/* Show BGP peer's information. */
7245enum show_type
7246{
7247 show_all,
7248 show_peer
7249};
7250
paul94f2b392005-06-28 12:44:16 +00007251static void
paul718e3742002-12-13 20:15:29 +00007252bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p,
7253 afi_t afi, safi_t safi,
7254 u_int16_t adv_smcap, u_int16_t adv_rmcap,
7255 u_int16_t rcv_smcap, u_int16_t rcv_rmcap)
7256{
7257 /* Send-Mode */
7258 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)
7259 || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
7260 {
7261 vty_out (vty, " Send-mode: ");
7262 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
7263 vty_out (vty, "advertised");
7264 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
7265 vty_out (vty, "%sreceived",
7266 CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ?
7267 ", " : "");
7268 vty_out (vty, "%s", VTY_NEWLINE);
7269 }
7270
7271 /* Receive-Mode */
7272 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)
7273 || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
7274 {
7275 vty_out (vty, " Receive-mode: ");
7276 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
7277 vty_out (vty, "advertised");
7278 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
7279 vty_out (vty, "%sreceived",
7280 CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ?
7281 ", " : "");
7282 vty_out (vty, "%s", VTY_NEWLINE);
7283 }
7284}
7285
paul94f2b392005-06-28 12:44:16 +00007286static void
paul718e3742002-12-13 20:15:29 +00007287bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi)
7288{
7289 struct bgp_filter *filter;
7290 char orf_pfx_name[BUFSIZ];
7291 int orf_pfx_count;
7292
7293 filter = &p->filter[afi][safi];
7294
hasso538621f2004-05-21 09:31:30 +00007295 vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi),
paul718e3742002-12-13 20:15:29 +00007296 VTY_NEWLINE);
hasso538621f2004-05-21 09:31:30 +00007297
paul718e3742002-12-13 20:15:29 +00007298 if (p->af_group[afi][safi])
7299 vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE);
7300
7301 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7302 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
7303 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
7304 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7305 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
7306 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
7307 vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE);
7308
7309 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7310 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
7311 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7312 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
7313 {
7314 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
7315 ORF_TYPE_PREFIX, VTY_NEWLINE);
7316 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
7317 PEER_CAP_ORF_PREFIX_SM_ADV,
7318 PEER_CAP_ORF_PREFIX_RM_ADV,
7319 PEER_CAP_ORF_PREFIX_SM_RCV,
7320 PEER_CAP_ORF_PREFIX_RM_RCV);
7321 }
7322 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7323 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
7324 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7325 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
7326 {
7327 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
7328 ORF_TYPE_PREFIX_OLD, VTY_NEWLINE);
7329 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
7330 PEER_CAP_ORF_PREFIX_SM_ADV,
7331 PEER_CAP_ORF_PREFIX_RM_ADV,
7332 PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
7333 PEER_CAP_ORF_PREFIX_RM_OLD_RCV);
7334 }
7335
7336 sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
7337 orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name);
7338
7339 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
7340 || orf_pfx_count)
7341 {
7342 vty_out (vty, " Outbound Route Filter (ORF):");
7343 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
7344 vty_out (vty, " sent;");
7345 if (orf_pfx_count)
7346 vty_out (vty, " received (%d entries)", orf_pfx_count);
7347 vty_out (vty, "%s", VTY_NEWLINE);
7348 }
7349 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
7350 vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE);
7351
7352 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
7353 vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE);
7354 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
7355 vty_out (vty, " Route-Server Client%s", VTY_NEWLINE);
7356 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
7357 vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE);
7358 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
7359 vty_out (vty, " Private AS number removed from updates to this neighbor%s", VTY_NEWLINE);
7360 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF))
7361 vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE);
7362 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
7363 vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE);
7364 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
7365 vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE);
7366 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
7367 vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE);
7368 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
7369 || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
7370 {
7371 vty_out (vty, " Community attribute sent to this neighbor");
7372 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
7373 && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
hasso538621f2004-05-21 09:31:30 +00007374 vty_out (vty, "(both)%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007375 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
hasso538621f2004-05-21 09:31:30 +00007376 vty_out (vty, "(extended)%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007377 else
hasso538621f2004-05-21 09:31:30 +00007378 vty_out (vty, "(standard)%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007379 }
7380 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
7381 {
7382 vty_out (vty, " Default information originate,");
7383
7384 if (p->default_rmap[afi][safi].name)
7385 vty_out (vty, " default route-map %s%s,",
7386 p->default_rmap[afi][safi].map ? "*" : "",
7387 p->default_rmap[afi][safi].name);
7388 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
7389 vty_out (vty, " default sent%s", VTY_NEWLINE);
7390 else
7391 vty_out (vty, " default not sent%s", VTY_NEWLINE);
7392 }
7393
7394 if (filter->plist[FILTER_IN].name
7395 || filter->dlist[FILTER_IN].name
7396 || filter->aslist[FILTER_IN].name
paulfee0f4c2004-09-13 05:12:46 +00007397 || filter->map[RMAP_IN].name)
paul718e3742002-12-13 20:15:29 +00007398 vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE);
7399 if (filter->plist[FILTER_OUT].name
7400 || filter->dlist[FILTER_OUT].name
7401 || filter->aslist[FILTER_OUT].name
paulfee0f4c2004-09-13 05:12:46 +00007402 || filter->map[RMAP_OUT].name
paul718e3742002-12-13 20:15:29 +00007403 || filter->usmap.name)
7404 vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE);
paulfee0f4c2004-09-13 05:12:46 +00007405 if (filter->map[RMAP_IMPORT].name)
7406 vty_out (vty, " Import policy for this RS-client configured%s", VTY_NEWLINE);
7407 if (filter->map[RMAP_EXPORT].name)
7408 vty_out (vty, " Export policy for this RS-client configured%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007409
7410 /* prefix-list */
7411 if (filter->plist[FILTER_IN].name)
7412 vty_out (vty, " Incoming update prefix filter list is %s%s%s",
7413 filter->plist[FILTER_IN].plist ? "*" : "",
7414 filter->plist[FILTER_IN].name,
7415 VTY_NEWLINE);
7416 if (filter->plist[FILTER_OUT].name)
7417 vty_out (vty, " Outgoing update prefix filter list is %s%s%s",
7418 filter->plist[FILTER_OUT].plist ? "*" : "",
7419 filter->plist[FILTER_OUT].name,
7420 VTY_NEWLINE);
7421
7422 /* distribute-list */
7423 if (filter->dlist[FILTER_IN].name)
7424 vty_out (vty, " Incoming update network filter list is %s%s%s",
7425 filter->dlist[FILTER_IN].alist ? "*" : "",
7426 filter->dlist[FILTER_IN].name,
7427 VTY_NEWLINE);
7428 if (filter->dlist[FILTER_OUT].name)
7429 vty_out (vty, " Outgoing update network filter list is %s%s%s",
7430 filter->dlist[FILTER_OUT].alist ? "*" : "",
7431 filter->dlist[FILTER_OUT].name,
7432 VTY_NEWLINE);
7433
7434 /* filter-list. */
7435 if (filter->aslist[FILTER_IN].name)
7436 vty_out (vty, " Incoming update AS path filter list is %s%s%s",
7437 filter->aslist[FILTER_IN].aslist ? "*" : "",
7438 filter->aslist[FILTER_IN].name,
7439 VTY_NEWLINE);
7440 if (filter->aslist[FILTER_OUT].name)
7441 vty_out (vty, " Outgoing update AS path filter list is %s%s%s",
7442 filter->aslist[FILTER_OUT].aslist ? "*" : "",
7443 filter->aslist[FILTER_OUT].name,
7444 VTY_NEWLINE);
7445
7446 /* route-map. */
paulfee0f4c2004-09-13 05:12:46 +00007447 if (filter->map[RMAP_IN].name)
paul718e3742002-12-13 20:15:29 +00007448 vty_out (vty, " Route map for incoming advertisements is %s%s%s",
paulfee0f4c2004-09-13 05:12:46 +00007449 filter->map[RMAP_IN].map ? "*" : "",
7450 filter->map[RMAP_IN].name,
paul718e3742002-12-13 20:15:29 +00007451 VTY_NEWLINE);
paulfee0f4c2004-09-13 05:12:46 +00007452 if (filter->map[RMAP_OUT].name)
paul718e3742002-12-13 20:15:29 +00007453 vty_out (vty, " Route map for outgoing advertisements is %s%s%s",
paulfee0f4c2004-09-13 05:12:46 +00007454 filter->map[RMAP_OUT].map ? "*" : "",
7455 filter->map[RMAP_OUT].name,
7456 VTY_NEWLINE);
7457 if (filter->map[RMAP_IMPORT].name)
7458 vty_out (vty, " Route map for advertisements going into this RS-client's table is %s%s%s",
7459 filter->map[RMAP_IMPORT].map ? "*" : "",
7460 filter->map[RMAP_IMPORT].name,
7461 VTY_NEWLINE);
7462 if (filter->map[RMAP_EXPORT].name)
7463 vty_out (vty, " Route map for advertisements coming from this RS-client is %s%s%s",
7464 filter->map[RMAP_EXPORT].map ? "*" : "",
7465 filter->map[RMAP_EXPORT].name,
paul718e3742002-12-13 20:15:29 +00007466 VTY_NEWLINE);
7467
7468 /* unsuppress-map */
7469 if (filter->usmap.name)
7470 vty_out (vty, " Route map for selective unsuppress is %s%s%s",
7471 filter->usmap.map ? "*" : "",
7472 filter->usmap.name, VTY_NEWLINE);
7473
7474 /* Receive prefix count */
hassoe0701b72004-05-20 09:19:34 +00007475 vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE);
7476
paul718e3742002-12-13 20:15:29 +00007477 /* Maximum prefix */
7478 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
7479 {
hasso0a486e52005-02-01 20:57:17 +00007480 vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi],
paul718e3742002-12-13 20:15:29 +00007481 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)
hasso0a486e52005-02-01 20:57:17 +00007482 ? " (warning-only)" : "", VTY_NEWLINE);
7483 vty_out (vty, " Threshold for warning message %d%%",
7484 p->pmax_threshold[afi][safi]);
7485 if (p->pmax_restart[afi][safi])
7486 vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]);
7487 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007488 }
paul718e3742002-12-13 20:15:29 +00007489
7490 vty_out (vty, "%s", VTY_NEWLINE);
7491}
7492
paul94f2b392005-06-28 12:44:16 +00007493static void
paul718e3742002-12-13 20:15:29 +00007494bgp_show_peer (struct vty *vty, struct peer *p)
7495{
7496 struct bgp *bgp;
7497 char buf1[BUFSIZ];
7498 char timebuf[BGP_UPTIME_LEN];
hasso538621f2004-05-21 09:31:30 +00007499 afi_t afi;
7500 safi_t safi;
paul718e3742002-12-13 20:15:29 +00007501
7502 bgp = p->bgp;
7503
7504 /* Configured IP address. */
7505 vty_out (vty, "BGP neighbor is %s, ", p->host);
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04007506 vty_out (vty, "remote AS %u, ", p->as);
7507 vty_out (vty, "local AS %u%s, ",
paul718e3742002-12-13 20:15:29 +00007508 p->change_local_as ? p->change_local_as : p->local_as,
7509 CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ?
7510 " no-prepend" : "");
7511 vty_out (vty, "%s link%s",
7512 p->as == p->local_as ? "internal" : "external",
7513 VTY_NEWLINE);
7514
7515 /* Description. */
7516 if (p->desc)
7517 vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE);
7518
7519 /* Peer-group */
7520 if (p->group)
7521 vty_out (vty, " Member of peer-group %s for session parameters%s",
7522 p->group->name, VTY_NEWLINE);
7523
7524 /* Administrative shutdown. */
7525 if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
7526 vty_out (vty, " Administratively shut down%s", VTY_NEWLINE);
7527
7528 /* BGP Version. */
7529 vty_out (vty, " BGP version 4");
paul718e3742002-12-13 20:15:29 +00007530 vty_out (vty, ", remote router ID %s%s",
7531 inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ),
7532 VTY_NEWLINE);
7533
7534 /* Confederation */
hassoe0701b72004-05-20 09:19:34 +00007535 if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION)
7536 && bgp_confederation_peers_check (bgp, p->as))
paul718e3742002-12-13 20:15:29 +00007537 vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE);
7538
7539 /* Status. */
7540 vty_out (vty, " BGP state = %s",
7541 LOOKUP (bgp_status_msg, p->status));
7542 if (p->status == Established)
7543 vty_out (vty, ", up for %8s",
7544 peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN));
hasso93406d82005-02-02 14:40:33 +00007545 else if (p->status == Active)
7546 {
7547 if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE))
7548 vty_out (vty, " (passive)");
7549 else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT))
7550 vty_out (vty, " (NSF passive)");
7551 }
paul718e3742002-12-13 20:15:29 +00007552 vty_out (vty, "%s", VTY_NEWLINE);
7553
7554 /* read timer */
7555 vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN));
7556
7557 /* Configured timer values. */
7558 vty_out (vty, ", hold time is %d, keepalive interval is %d seconds%s",
7559 p->v_holdtime, p->v_keepalive, VTY_NEWLINE);
7560 if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
7561 {
7562 vty_out (vty, " Configured hold time is %d", p->holdtime);
7563 vty_out (vty, ", keepalive interval is %d seconds%s",
7564 p->keepalive, VTY_NEWLINE);
7565 }
hasso93406d82005-02-02 14:40:33 +00007566
paul718e3742002-12-13 20:15:29 +00007567 /* Capability. */
7568 if (p->status == Established)
7569 {
hasso538621f2004-05-21 09:31:30 +00007570 if (p->cap
paul718e3742002-12-13 20:15:29 +00007571 || p->afc_adv[AFI_IP][SAFI_UNICAST]
7572 || p->afc_recv[AFI_IP][SAFI_UNICAST]
7573 || p->afc_adv[AFI_IP][SAFI_MULTICAST]
7574 || p->afc_recv[AFI_IP][SAFI_MULTICAST]
7575#ifdef HAVE_IPV6
7576 || p->afc_adv[AFI_IP6][SAFI_UNICAST]
7577 || p->afc_recv[AFI_IP6][SAFI_UNICAST]
7578 || p->afc_adv[AFI_IP6][SAFI_MULTICAST]
7579 || p->afc_recv[AFI_IP6][SAFI_MULTICAST]
7580#endif /* HAVE_IPV6 */
7581 || p->afc_adv[AFI_IP][SAFI_MPLS_VPN]
7582 || p->afc_recv[AFI_IP][SAFI_MPLS_VPN])
7583 {
7584 vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE);
7585
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00007586 /* AS4 */
7587 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)
7588 || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
7589 {
7590 vty_out (vty, " 4 Byte AS:");
7591 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
7592 vty_out (vty, " advertised");
7593 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
7594 vty_out (vty, " %sreceived",
7595 CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : "");
7596 vty_out (vty, "%s", VTY_NEWLINE);
7597 }
paul718e3742002-12-13 20:15:29 +00007598 /* Dynamic */
7599 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
7600 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
7601 {
7602 vty_out (vty, " Dynamic:");
7603 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
7604 vty_out (vty, " advertised");
7605 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
hasso538621f2004-05-21 09:31:30 +00007606 vty_out (vty, " %sreceived",
7607 CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : "");
paul718e3742002-12-13 20:15:29 +00007608 vty_out (vty, "%s", VTY_NEWLINE);
7609 }
7610
7611 /* Route Refresh */
7612 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
7613 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
7614 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
7615 {
7616 vty_out (vty, " Route refresh:");
7617 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
7618 vty_out (vty, " advertised");
7619 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
7620 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
hasso538621f2004-05-21 09:31:30 +00007621 vty_out (vty, " %sreceived(%s)",
7622 CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "",
7623 (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)
7624 && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ?
7625 "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new");
7626
paul718e3742002-12-13 20:15:29 +00007627 vty_out (vty, "%s", VTY_NEWLINE);
7628 }
7629
hasso538621f2004-05-21 09:31:30 +00007630 /* Multiprotocol Extensions */
7631 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7632 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7633 if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
paul718e3742002-12-13 20:15:29 +00007634 {
hasso538621f2004-05-21 09:31:30 +00007635 vty_out (vty, " Address family %s:", afi_safi_print (afi, safi));
7636 if (p->afc_adv[afi][safi])
7637 vty_out (vty, " advertised");
7638 if (p->afc_recv[afi][safi])
7639 vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : "");
7640 vty_out (vty, "%s", VTY_NEWLINE);
7641 }
7642
7643 /* Gracefull Restart */
7644 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
7645 || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
paul718e3742002-12-13 20:15:29 +00007646 {
hasso538621f2004-05-21 09:31:30 +00007647 vty_out (vty, " Graceful Restart Capabilty:");
7648 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
paul718e3742002-12-13 20:15:29 +00007649 vty_out (vty, " advertised");
hasso538621f2004-05-21 09:31:30 +00007650 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
7651 vty_out (vty, " %sreceived",
7652 CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : "");
paul718e3742002-12-13 20:15:29 +00007653 vty_out (vty, "%s", VTY_NEWLINE);
hasso538621f2004-05-21 09:31:30 +00007654
7655 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
paul718e3742002-12-13 20:15:29 +00007656 {
hasso538621f2004-05-21 09:31:30 +00007657 int restart_af_count = 0;
7658
7659 vty_out (vty, " Remote Restart timer is %d seconds%s",
hasso93406d82005-02-02 14:40:33 +00007660 p->v_gr_restart, VTY_NEWLINE);
7661 vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE);
hasso538621f2004-05-21 09:31:30 +00007662
7663 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7664 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7665 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
7666 {
hasso93406d82005-02-02 14:40:33 +00007667 vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "",
7668 afi_safi_print (afi, safi),
7669 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ?
7670 "preserved" : "not preserved");
hasso538621f2004-05-21 09:31:30 +00007671 restart_af_count++;
hasso93406d82005-02-02 14:40:33 +00007672 }
hasso538621f2004-05-21 09:31:30 +00007673 if (! restart_af_count)
7674 vty_out (vty, "none");
7675 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007676 }
paul718e3742002-12-13 20:15:29 +00007677 }
paul718e3742002-12-13 20:15:29 +00007678 }
7679 }
7680
hasso93406d82005-02-02 14:40:33 +00007681 /* graceful restart information */
7682 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
7683 || p->t_gr_restart
7684 || p->t_gr_stale)
7685 {
7686 int eor_send_af_count = 0;
7687 int eor_receive_af_count = 0;
7688
7689 vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE);
7690 if (p->status == Established)
7691 {
7692 vty_out (vty, " End-of-RIB send: ");
7693 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7694 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7695 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND))
7696 {
7697 vty_out (vty, "%s%s", eor_send_af_count ? ", " : "",
7698 afi_safi_print (afi, safi));
7699 eor_send_af_count++;
7700 }
7701 vty_out (vty, "%s", VTY_NEWLINE);
7702
7703 vty_out (vty, " End-of-RIB received: ");
7704 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7705 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7706 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED))
7707 {
7708 vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "",
7709 afi_safi_print (afi, safi));
7710 eor_receive_af_count++;
7711 }
7712 vty_out (vty, "%s", VTY_NEWLINE);
7713 }
7714
7715 if (p->t_gr_restart)
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00007716 vty_out (vty, " The remaining time of restart timer is %ld%s",
7717 thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE);
7718
hasso93406d82005-02-02 14:40:33 +00007719 if (p->t_gr_stale)
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00007720 vty_out (vty, " The remaining time of stalepath timer is %ld%s",
7721 thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE);
hasso93406d82005-02-02 14:40:33 +00007722 }
7723
paul718e3742002-12-13 20:15:29 +00007724 /* Packet counts. */
hasso93406d82005-02-02 14:40:33 +00007725 vty_out (vty, " Message statistics:%s", VTY_NEWLINE);
7726 vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00007727 vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE);
hasso93406d82005-02-02 14:40:33 +00007728 vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE);
7729 vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE);
7730 vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE);
7731 vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE);
7732 vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE);
7733 vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE);
7734 vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE);
7735 vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out +
7736 p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out,
7737 p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in +
7738 p->dynamic_cap_in, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007739
7740 /* advertisement-interval */
7741 vty_out (vty, " Minimum time between advertisement runs is %d seconds%s",
7742 p->v_routeadv, VTY_NEWLINE);
7743
7744 /* Update-source. */
7745 if (p->update_if || p->update_source)
7746 {
7747 vty_out (vty, " Update source is ");
7748 if (p->update_if)
7749 vty_out (vty, "%s", p->update_if);
7750 else if (p->update_source)
7751 vty_out (vty, "%s",
7752 sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
7753 vty_out (vty, "%s", VTY_NEWLINE);
7754 }
7755
7756 /* Default weight */
7757 if (CHECK_FLAG (p->config, PEER_CONFIG_WEIGHT))
7758 vty_out (vty, " Default weight %d%s", p->weight,
7759 VTY_NEWLINE);
7760
7761 vty_out (vty, "%s", VTY_NEWLINE);
7762
7763 /* Address Family Information */
hasso538621f2004-05-21 09:31:30 +00007764 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7765 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7766 if (p->afc[afi][safi])
7767 bgp_show_peer_afi (vty, p, afi, safi);
paul718e3742002-12-13 20:15:29 +00007768
7769 vty_out (vty, " Connections established %d; dropped %d%s",
7770 p->established, p->dropped,
7771 VTY_NEWLINE);
7772
hassoe0701b72004-05-20 09:19:34 +00007773 if (! p->dropped)
7774 vty_out (vty, " Last reset never%s", VTY_NEWLINE);
7775 else
7776 vty_out (vty, " Last reset %s, due to %s%s",
7777 peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN),
7778 peer_down_str[(int) p->last_reset], VTY_NEWLINE);
paul848973c2003-08-13 00:32:49 +00007779
paul718e3742002-12-13 20:15:29 +00007780 if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW))
7781 {
7782 vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE);
hasso0a486e52005-02-01 20:57:17 +00007783
7784 if (p->t_pmax_restart)
7785 vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s",
7786 p->host, thread_timer_remain_second (p->t_pmax_restart),
7787 VTY_NEWLINE);
7788 else
7789 vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s",
7790 p->host, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007791 }
7792
Stephen Hemmingerf5a48272011-03-24 17:30:21 +00007793 /* EBGP Multihop and GTSM */
7794 if (peer_sort (p) != BGP_PEER_IBGP)
7795 {
7796 if (p->gtsm_hops > 0)
7797 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
7798 p->gtsm_hops, VTY_NEWLINE);
7799 else if (p->ttl > 1)
7800 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
7801 p->ttl, VTY_NEWLINE);
7802 }
paul718e3742002-12-13 20:15:29 +00007803
7804 /* Local address. */
7805 if (p->su_local)
7806 {
hasso93406d82005-02-02 14:40:33 +00007807 vty_out (vty, "Local host: %s, Local port: %d%s",
paul718e3742002-12-13 20:15:29 +00007808 sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN),
7809 ntohs (p->su_local->sin.sin_port),
paul718e3742002-12-13 20:15:29 +00007810 VTY_NEWLINE);
7811 }
7812
7813 /* Remote address. */
7814 if (p->su_remote)
7815 {
7816 vty_out (vty, "Foreign host: %s, Foreign port: %d%s",
7817 sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN),
7818 ntohs (p->su_remote->sin.sin_port),
7819 VTY_NEWLINE);
7820 }
7821
7822 /* Nexthop display. */
7823 if (p->su_local)
7824 {
7825 vty_out (vty, "Nexthop: %s%s",
7826 inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ),
7827 VTY_NEWLINE);
7828#ifdef HAVE_IPV6
7829 vty_out (vty, "Nexthop global: %s%s",
7830 inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ),
7831 VTY_NEWLINE);
7832 vty_out (vty, "Nexthop local: %s%s",
7833 inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ),
7834 VTY_NEWLINE);
7835 vty_out (vty, "BGP connection: %s%s",
7836 p->shared_network ? "shared network" : "non shared network",
7837 VTY_NEWLINE);
7838#endif /* HAVE_IPV6 */
7839 }
7840
7841 /* Timer information. */
7842 if (p->t_start)
7843 vty_out (vty, "Next start timer due in %ld seconds%s",
7844 thread_timer_remain_second (p->t_start), VTY_NEWLINE);
7845 if (p->t_connect)
7846 vty_out (vty, "Next connect timer due in %ld seconds%s",
7847 thread_timer_remain_second (p->t_connect), VTY_NEWLINE);
7848
7849 vty_out (vty, "Read thread: %s Write thread: %s%s",
7850 p->t_read ? "on" : "off",
7851 p->t_write ? "on" : "off",
7852 VTY_NEWLINE);
7853
7854 if (p->notify.code == BGP_NOTIFY_OPEN_ERR
7855 && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL)
7856 bgp_capability_vty_out (vty, p);
7857
7858 vty_out (vty, "%s", VTY_NEWLINE);
7859}
7860
paul94f2b392005-06-28 12:44:16 +00007861static int
paul718e3742002-12-13 20:15:29 +00007862bgp_show_neighbor (struct vty *vty, struct bgp *bgp,
7863 enum show_type type, union sockunion *su)
7864{
paul1eb8ef22005-04-07 07:30:20 +00007865 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00007866 struct peer *peer;
7867 int find = 0;
7868
paul1eb8ef22005-04-07 07:30:20 +00007869 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00007870 {
7871 switch (type)
7872 {
7873 case show_all:
7874 bgp_show_peer (vty, peer);
7875 break;
7876 case show_peer:
7877 if (sockunion_same (&peer->su, su))
7878 {
7879 find = 1;
7880 bgp_show_peer (vty, peer);
7881 }
7882 break;
7883 }
7884 }
7885
7886 if (type == show_peer && ! find)
7887 vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE);
7888
7889 return CMD_SUCCESS;
7890}
7891
paul94f2b392005-06-28 12:44:16 +00007892static int
paulfd79ac92004-10-13 05:06:08 +00007893bgp_show_neighbor_vty (struct vty *vty, const char *name,
7894 enum show_type type, const char *ip_str)
paul718e3742002-12-13 20:15:29 +00007895{
7896 int ret;
7897 struct bgp *bgp;
7898 union sockunion su;
7899
7900 if (ip_str)
7901 {
7902 ret = str2sockunion (ip_str, &su);
7903 if (ret < 0)
7904 {
7905 vty_out (vty, "%% Malformed address: %s%s", ip_str, VTY_NEWLINE);
7906 return CMD_WARNING;
7907 }
7908 }
7909
7910 if (name)
7911 {
7912 bgp = bgp_lookup_by_name (name);
7913
7914 if (! bgp)
7915 {
7916 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
7917 return CMD_WARNING;
7918 }
7919
7920 bgp_show_neighbor (vty, bgp, type, &su);
7921
7922 return CMD_SUCCESS;
7923 }
7924
7925 bgp = bgp_get_default ();
7926
7927 if (bgp)
7928 bgp_show_neighbor (vty, bgp, type, &su);
7929
7930 return CMD_SUCCESS;
7931}
7932
7933/* "show ip bgp neighbors" commands. */
7934DEFUN (show_ip_bgp_neighbors,
7935 show_ip_bgp_neighbors_cmd,
7936 "show ip bgp neighbors",
7937 SHOW_STR
7938 IP_STR
7939 BGP_STR
7940 "Detailed information on TCP and BGP neighbor connections\n")
7941{
7942 return bgp_show_neighbor_vty (vty, NULL, show_all, NULL);
7943}
7944
7945ALIAS (show_ip_bgp_neighbors,
7946 show_ip_bgp_ipv4_neighbors_cmd,
7947 "show ip bgp ipv4 (unicast|multicast) neighbors",
7948 SHOW_STR
7949 IP_STR
7950 BGP_STR
7951 "Address family\n"
7952 "Address Family modifier\n"
7953 "Address Family modifier\n"
7954 "Detailed information on TCP and BGP neighbor connections\n")
7955
7956ALIAS (show_ip_bgp_neighbors,
7957 show_ip_bgp_vpnv4_all_neighbors_cmd,
7958 "show ip bgp vpnv4 all neighbors",
7959 SHOW_STR
7960 IP_STR
7961 BGP_STR
7962 "Display VPNv4 NLRI specific information\n"
7963 "Display information about all VPNv4 NLRIs\n"
7964 "Detailed information on TCP and BGP neighbor connections\n")
7965
7966ALIAS (show_ip_bgp_neighbors,
7967 show_ip_bgp_vpnv4_rd_neighbors_cmd,
7968 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors",
7969 SHOW_STR
7970 IP_STR
7971 BGP_STR
7972 "Display VPNv4 NLRI specific information\n"
7973 "Display information for a route distinguisher\n"
7974 "VPN Route Distinguisher\n"
7975 "Detailed information on TCP and BGP neighbor connections\n")
7976
7977ALIAS (show_ip_bgp_neighbors,
7978 show_bgp_neighbors_cmd,
7979 "show bgp neighbors",
7980 SHOW_STR
7981 BGP_STR
7982 "Detailed information on TCP and BGP neighbor connections\n")
7983
7984ALIAS (show_ip_bgp_neighbors,
7985 show_bgp_ipv6_neighbors_cmd,
7986 "show bgp ipv6 neighbors",
7987 SHOW_STR
7988 BGP_STR
7989 "Address family\n"
7990 "Detailed information on TCP and BGP neighbor connections\n")
7991
7992DEFUN (show_ip_bgp_neighbors_peer,
7993 show_ip_bgp_neighbors_peer_cmd,
7994 "show ip bgp neighbors (A.B.C.D|X:X::X:X)",
7995 SHOW_STR
7996 IP_STR
7997 BGP_STR
7998 "Detailed information on TCP and BGP neighbor connections\n"
7999 "Neighbor to display information about\n"
8000 "Neighbor to display information about\n")
8001{
8002 return bgp_show_neighbor_vty (vty, NULL, show_peer, argv[argc - 1]);
8003}
8004
8005ALIAS (show_ip_bgp_neighbors_peer,
8006 show_ip_bgp_ipv4_neighbors_peer_cmd,
8007 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X)",
8008 SHOW_STR
8009 IP_STR
8010 BGP_STR
8011 "Address family\n"
8012 "Address Family modifier\n"
8013 "Address Family modifier\n"
8014 "Detailed information on TCP and BGP neighbor connections\n"
8015 "Neighbor to display information about\n"
8016 "Neighbor to display information about\n")
8017
8018ALIAS (show_ip_bgp_neighbors_peer,
8019 show_ip_bgp_vpnv4_all_neighbors_peer_cmd,
8020 "show ip bgp vpnv4 all neighbors A.B.C.D",
8021 SHOW_STR
8022 IP_STR
8023 BGP_STR
8024 "Display VPNv4 NLRI specific information\n"
8025 "Display information about all VPNv4 NLRIs\n"
8026 "Detailed information on TCP and BGP neighbor connections\n"
8027 "Neighbor to display information about\n")
8028
8029ALIAS (show_ip_bgp_neighbors_peer,
8030 show_ip_bgp_vpnv4_rd_neighbors_peer_cmd,
8031 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D",
8032 SHOW_STR
8033 IP_STR
8034 BGP_STR
8035 "Display VPNv4 NLRI specific information\n"
8036 "Display information about all VPNv4 NLRIs\n"
8037 "Detailed information on TCP and BGP neighbor connections\n"
8038 "Neighbor to display information about\n")
8039
8040ALIAS (show_ip_bgp_neighbors_peer,
8041 show_bgp_neighbors_peer_cmd,
8042 "show bgp neighbors (A.B.C.D|X:X::X:X)",
8043 SHOW_STR
8044 BGP_STR
8045 "Detailed information on TCP and BGP neighbor connections\n"
8046 "Neighbor to display information about\n"
8047 "Neighbor to display information about\n")
8048
8049ALIAS (show_ip_bgp_neighbors_peer,
8050 show_bgp_ipv6_neighbors_peer_cmd,
8051 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X)",
8052 SHOW_STR
8053 BGP_STR
8054 "Address family\n"
8055 "Detailed information on TCP and BGP neighbor connections\n"
8056 "Neighbor to display information about\n"
8057 "Neighbor to display information about\n")
8058
8059DEFUN (show_ip_bgp_instance_neighbors,
8060 show_ip_bgp_instance_neighbors_cmd,
8061 "show ip bgp view WORD neighbors",
8062 SHOW_STR
8063 IP_STR
8064 BGP_STR
8065 "BGP view\n"
8066 "View name\n"
8067 "Detailed information on TCP and BGP neighbor connections\n")
8068{
8069 return bgp_show_neighbor_vty (vty, argv[0], show_all, NULL);
8070}
8071
paulbb46e942003-10-24 19:02:03 +00008072ALIAS (show_ip_bgp_instance_neighbors,
8073 show_bgp_instance_neighbors_cmd,
8074 "show bgp view WORD neighbors",
8075 SHOW_STR
8076 BGP_STR
8077 "BGP view\n"
8078 "View name\n"
8079 "Detailed information on TCP and BGP neighbor connections\n")
8080
8081ALIAS (show_ip_bgp_instance_neighbors,
8082 show_bgp_instance_ipv6_neighbors_cmd,
8083 "show bgp view WORD ipv6 neighbors",
8084 SHOW_STR
8085 BGP_STR
8086 "BGP view\n"
8087 "View name\n"
8088 "Address family\n"
8089 "Detailed information on TCP and BGP neighbor connections\n")
8090
paul718e3742002-12-13 20:15:29 +00008091DEFUN (show_ip_bgp_instance_neighbors_peer,
8092 show_ip_bgp_instance_neighbors_peer_cmd,
8093 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X)",
8094 SHOW_STR
8095 IP_STR
8096 BGP_STR
8097 "BGP view\n"
8098 "View name\n"
8099 "Detailed information on TCP and BGP neighbor connections\n"
8100 "Neighbor to display information about\n"
8101 "Neighbor to display information about\n")
8102{
8103 return bgp_show_neighbor_vty (vty, argv[0], show_peer, argv[1]);
8104}
paulbb46e942003-10-24 19:02:03 +00008105
8106ALIAS (show_ip_bgp_instance_neighbors_peer,
8107 show_bgp_instance_neighbors_peer_cmd,
8108 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X)",
8109 SHOW_STR
8110 BGP_STR
8111 "BGP view\n"
8112 "View name\n"
8113 "Detailed information on TCP and BGP neighbor connections\n"
8114 "Neighbor to display information about\n"
8115 "Neighbor to display information about\n")
8116
8117ALIAS (show_ip_bgp_instance_neighbors_peer,
8118 show_bgp_instance_ipv6_neighbors_peer_cmd,
8119 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X)",
8120 SHOW_STR
8121 BGP_STR
8122 "BGP view\n"
8123 "View name\n"
8124 "Address family\n"
8125 "Detailed information on TCP and BGP neighbor connections\n"
8126 "Neighbor to display information about\n"
8127 "Neighbor to display information about\n")
8128
paul718e3742002-12-13 20:15:29 +00008129/* Show BGP's AS paths internal data. There are both `show ip bgp
8130 paths' and `show ip mbgp paths'. Those functions results are the
8131 same.*/
8132DEFUN (show_ip_bgp_paths,
8133 show_ip_bgp_paths_cmd,
8134 "show ip bgp paths",
8135 SHOW_STR
8136 IP_STR
8137 BGP_STR
8138 "Path information\n")
8139{
8140 vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE);
8141 aspath_print_all_vty (vty);
8142 return CMD_SUCCESS;
8143}
8144
8145DEFUN (show_ip_bgp_ipv4_paths,
8146 show_ip_bgp_ipv4_paths_cmd,
8147 "show ip bgp ipv4 (unicast|multicast) paths",
8148 SHOW_STR
8149 IP_STR
8150 BGP_STR
8151 "Address family\n"
8152 "Address Family modifier\n"
8153 "Address Family modifier\n"
8154 "Path information\n")
8155{
8156 vty_out (vty, "Address Refcnt Path\r\n");
8157 aspath_print_all_vty (vty);
8158
8159 return CMD_SUCCESS;
8160}
8161
8162#include "hash.h"
8163
paul94f2b392005-06-28 12:44:16 +00008164static void
paul718e3742002-12-13 20:15:29 +00008165community_show_all_iterator (struct hash_backet *backet, struct vty *vty)
8166{
8167 struct community *com;
8168
8169 com = (struct community *) backet->data;
8170 vty_out (vty, "[%p] (%ld) %s%s", backet, com->refcnt,
8171 community_str (com), VTY_NEWLINE);
8172}
8173
8174/* Show BGP's community internal data. */
8175DEFUN (show_ip_bgp_community_info,
8176 show_ip_bgp_community_info_cmd,
8177 "show ip bgp community-info",
8178 SHOW_STR
8179 IP_STR
8180 BGP_STR
8181 "List all bgp community information\n")
8182{
8183 vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE);
8184
8185 hash_iterate (community_hash (),
8186 (void (*) (struct hash_backet *, void *))
8187 community_show_all_iterator,
8188 vty);
8189
8190 return CMD_SUCCESS;
8191}
8192
8193DEFUN (show_ip_bgp_attr_info,
8194 show_ip_bgp_attr_info_cmd,
8195 "show ip bgp attribute-info",
8196 SHOW_STR
8197 IP_STR
8198 BGP_STR
8199 "List all bgp attribute information\n")
8200{
8201 attr_show_all (vty);
8202 return CMD_SUCCESS;
8203}
8204
paul94f2b392005-06-28 12:44:16 +00008205static int
paulfee0f4c2004-09-13 05:12:46 +00008206bgp_write_rsclient_summary (struct vty *vty, struct peer *rsclient,
8207 afi_t afi, safi_t safi)
8208{
8209 char timebuf[BGP_UPTIME_LEN];
8210 char rmbuf[14];
paulfd79ac92004-10-13 05:06:08 +00008211 const char *rmname;
paulfee0f4c2004-09-13 05:12:46 +00008212 struct peer *peer;
paul1eb8ef22005-04-07 07:30:20 +00008213 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00008214 int len;
8215 int count = 0;
8216
8217 if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP))
8218 {
paul1eb8ef22005-04-07 07:30:20 +00008219 for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, peer))
paulfee0f4c2004-09-13 05:12:46 +00008220 {
8221 count++;
8222 bgp_write_rsclient_summary (vty, peer, afi, safi);
8223 }
8224 return count;
8225 }
8226
8227 len = vty_out (vty, "%s", rsclient->host);
8228 len = 16 - len;
8229
8230 if (len < 1)
8231 vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
8232 else
8233 vty_out (vty, "%*s", len, " ");
8234
hasso3d515fd2005-02-01 21:30:04 +00008235 vty_out (vty, "4 ");
paulfee0f4c2004-09-13 05:12:46 +00008236
Paul Jakma0b2aa3a2007-10-14 22:32:21 +00008237 vty_out (vty, "%11d ", rsclient->as);
paulfee0f4c2004-09-13 05:12:46 +00008238
8239 rmname = ROUTE_MAP_EXPORT_NAME(&rsclient->filter[afi][safi]);
8240 if ( rmname && strlen (rmname) > 13 )
8241 {
8242 sprintf (rmbuf, "%13s", "...");
8243 rmname = strncpy (rmbuf, rmname, 10);
8244 }
8245 else if (! rmname)
8246 rmname = "<none>";
8247 vty_out (vty, " %13s ", rmname);
8248
8249 rmname = ROUTE_MAP_IMPORT_NAME(&rsclient->filter[afi][safi]);
8250 if ( rmname && strlen (rmname) > 13 )
8251 {
8252 sprintf (rmbuf, "%13s", "...");
8253 rmname = strncpy (rmbuf, rmname, 10);
8254 }
8255 else if (! rmname)
8256 rmname = "<none>";
8257 vty_out (vty, " %13s ", rmname);
8258
8259 vty_out (vty, "%8s", peer_uptime (rsclient->uptime, timebuf, BGP_UPTIME_LEN));
8260
8261 if (CHECK_FLAG (rsclient->flags, PEER_FLAG_SHUTDOWN))
8262 vty_out (vty, " Idle (Admin)");
8263 else if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_PREFIX_OVERFLOW))
8264 vty_out (vty, " Idle (PfxCt)");
8265 else
8266 vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, rsclient->status));
8267
8268 vty_out (vty, "%s", VTY_NEWLINE);
8269
8270 return 1;
8271}
8272
paul94f2b392005-06-28 12:44:16 +00008273static int
paulfd79ac92004-10-13 05:06:08 +00008274bgp_show_rsclient_summary (struct vty *vty, struct bgp *bgp,
8275 afi_t afi, safi_t safi)
paulfee0f4c2004-09-13 05:12:46 +00008276{
8277 struct peer *peer;
paul1eb8ef22005-04-07 07:30:20 +00008278 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00008279 int count = 0;
8280
8281 /* Header string for each address family. */
8282 static char header[] = "Neighbor V AS Export-Policy Import-Policy Up/Down State";
8283
paul1eb8ef22005-04-07 07:30:20 +00008284 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, peer))
paulfee0f4c2004-09-13 05:12:46 +00008285 {
8286 if (peer->afc[afi][safi] &&
8287 CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
8288 {
8289 if (! count)
8290 {
8291 vty_out (vty,
8292 "Route Server's BGP router identifier %s%s",
8293 inet_ntoa (bgp->router_id), VTY_NEWLINE);
8294 vty_out (vty,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04008295 "Route Server's local AS number %u%s", bgp->as,
paulfee0f4c2004-09-13 05:12:46 +00008296 VTY_NEWLINE);
8297
8298 vty_out (vty, "%s", VTY_NEWLINE);
8299 vty_out (vty, "%s%s", header, VTY_NEWLINE);
8300 }
8301
8302 count += bgp_write_rsclient_summary (vty, peer, afi, safi);
8303 }
8304 }
8305
8306 if (count)
8307 vty_out (vty, "%sTotal number of Route Server Clients %d%s", VTY_NEWLINE,
8308 count, VTY_NEWLINE);
8309 else
8310 vty_out (vty, "No %s Route Server Client is configured%s",
8311 afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
8312
8313 return CMD_SUCCESS;
8314}
8315
paul94f2b392005-06-28 12:44:16 +00008316static int
paulfd79ac92004-10-13 05:06:08 +00008317bgp_show_rsclient_summary_vty (struct vty *vty, const char *name,
8318 afi_t afi, safi_t safi)
paulfee0f4c2004-09-13 05:12:46 +00008319{
8320 struct bgp *bgp;
8321
8322 if (name)
8323 {
8324 bgp = bgp_lookup_by_name (name);
8325
8326 if (! bgp)
8327 {
8328 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
8329 return CMD_WARNING;
8330 }
8331
8332 bgp_show_rsclient_summary (vty, bgp, afi, safi);
8333 return CMD_SUCCESS;
8334 }
8335
8336 bgp = bgp_get_default ();
8337
8338 if (bgp)
8339 bgp_show_rsclient_summary (vty, bgp, afi, safi);
8340
8341 return CMD_SUCCESS;
8342}
8343
8344/* 'show bgp rsclient' commands. */
8345DEFUN (show_ip_bgp_rsclient_summary,
8346 show_ip_bgp_rsclient_summary_cmd,
8347 "show ip bgp rsclient summary",
8348 SHOW_STR
8349 IP_STR
8350 BGP_STR
8351 "Information about Route Server Clients\n"
8352 "Summary of all Route Server Clients\n")
8353{
8354 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
8355}
8356
8357DEFUN (show_ip_bgp_instance_rsclient_summary,
8358 show_ip_bgp_instance_rsclient_summary_cmd,
8359 "show ip bgp view WORD rsclient summary",
8360 SHOW_STR
8361 IP_STR
8362 BGP_STR
8363 "BGP view\n"
8364 "View name\n"
8365 "Information about Route Server Clients\n"
8366 "Summary of all Route Server Clients\n")
8367{
8368 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
8369}
8370
8371DEFUN (show_ip_bgp_ipv4_rsclient_summary,
8372 show_ip_bgp_ipv4_rsclient_summary_cmd,
8373 "show ip bgp ipv4 (unicast|multicast) rsclient summary",
8374 SHOW_STR
8375 IP_STR
8376 BGP_STR
8377 "Address family\n"
8378 "Address Family modifier\n"
8379 "Address Family modifier\n"
8380 "Information about Route Server Clients\n"
8381 "Summary of all Route Server Clients\n")
8382{
8383 if (strncmp (argv[0], "m", 1) == 0)
8384 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST);
8385
8386 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
8387}
8388
8389DEFUN (show_ip_bgp_instance_ipv4_rsclient_summary,
8390 show_ip_bgp_instance_ipv4_rsclient_summary_cmd,
8391 "show ip bgp view WORD ipv4 (unicast|multicast) rsclient summary",
8392 SHOW_STR
8393 IP_STR
8394 BGP_STR
8395 "BGP view\n"
8396 "View name\n"
8397 "Address family\n"
8398 "Address Family modifier\n"
8399 "Address Family modifier\n"
8400 "Information about Route Server Clients\n"
8401 "Summary of all Route Server Clients\n")
8402{
8403 if (strncmp (argv[1], "m", 1) == 0)
8404 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST);
8405
8406 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
8407}
8408
Michael Lambert95cbbd22010-07-23 14:43:04 -04008409DEFUN (show_bgp_instance_ipv4_safi_rsclient_summary,
8410 show_bgp_instance_ipv4_safi_rsclient_summary_cmd,
8411 "show bgp view WORD ipv4 (unicast|multicast) rsclient summary",
8412 SHOW_STR
8413 BGP_STR
8414 "BGP view\n"
8415 "View name\n"
8416 "Address family\n"
8417 "Address Family modifier\n"
8418 "Address Family modifier\n"
8419 "Information about Route Server Clients\n"
8420 "Summary of all Route Server Clients\n")
8421{
8422 safi_t safi;
8423
8424 if (argc == 2) {
8425 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
8426 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, safi);
8427 } else {
8428 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
8429 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, safi);
8430 }
8431}
8432
8433ALIAS (show_bgp_instance_ipv4_safi_rsclient_summary,
8434 show_bgp_ipv4_safi_rsclient_summary_cmd,
8435 "show bgp ipv4 (unicast|multicast) rsclient summary",
8436 SHOW_STR
8437 BGP_STR
8438 "Address family\n"
8439 "Address Family modifier\n"
8440 "Address Family modifier\n"
8441 "Information about Route Server Clients\n"
8442 "Summary of all Route Server Clients\n")
8443
paulfee0f4c2004-09-13 05:12:46 +00008444#ifdef HAVE_IPV6
8445DEFUN (show_bgp_rsclient_summary,
8446 show_bgp_rsclient_summary_cmd,
8447 "show bgp rsclient summary",
8448 SHOW_STR
8449 BGP_STR
8450 "Information about Route Server Clients\n"
8451 "Summary of all Route Server Clients\n")
8452{
8453 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
8454}
8455
8456DEFUN (show_bgp_instance_rsclient_summary,
8457 show_bgp_instance_rsclient_summary_cmd,
8458 "show bgp view WORD rsclient summary",
8459 SHOW_STR
8460 BGP_STR
8461 "BGP view\n"
8462 "View name\n"
8463 "Information about Route Server Clients\n"
8464 "Summary of all Route Server Clients\n")
8465{
8466 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
8467}
8468
8469ALIAS (show_bgp_rsclient_summary,
8470 show_bgp_ipv6_rsclient_summary_cmd,
8471 "show bgp ipv6 rsclient summary",
8472 SHOW_STR
8473 BGP_STR
8474 "Address family\n"
8475 "Information about Route Server Clients\n"
8476 "Summary of all Route Server Clients\n")
8477
8478ALIAS (show_bgp_instance_rsclient_summary,
8479 show_bgp_instance_ipv6_rsclient_summary_cmd,
8480 "show bgp view WORD ipv6 rsclient summary",
8481 SHOW_STR
8482 BGP_STR
8483 "BGP view\n"
8484 "View name\n"
8485 "Address family\n"
8486 "Information about Route Server Clients\n"
8487 "Summary of all Route Server Clients\n")
Michael Lambert95cbbd22010-07-23 14:43:04 -04008488
8489DEFUN (show_bgp_instance_ipv6_safi_rsclient_summary,
8490 show_bgp_instance_ipv6_safi_rsclient_summary_cmd,
8491 "show bgp view WORD ipv6 (unicast|multicast) rsclient summary",
8492 SHOW_STR
8493 BGP_STR
8494 "BGP view\n"
8495 "View name\n"
8496 "Address family\n"
8497 "Address Family modifier\n"
8498 "Address Family modifier\n"
8499 "Information about Route Server Clients\n"
8500 "Summary of all Route Server Clients\n")
8501{
8502 safi_t safi;
8503
8504 if (argc == 2) {
8505 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
8506 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP6, safi);
8507 } else {
8508 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
8509 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP6, safi);
8510 }
8511}
8512
8513ALIAS (show_bgp_instance_ipv6_safi_rsclient_summary,
8514 show_bgp_ipv6_safi_rsclient_summary_cmd,
8515 "show bgp ipv6 (unicast|multicast) rsclient summary",
8516 SHOW_STR
8517 BGP_STR
8518 "Address family\n"
8519 "Address Family modifier\n"
8520 "Address Family modifier\n"
8521 "Information about Route Server Clients\n"
8522 "Summary of all Route Server Clients\n")
8523
paulfee0f4c2004-09-13 05:12:46 +00008524#endif /* HAVE IPV6 */
8525
paul718e3742002-12-13 20:15:29 +00008526/* Redistribute VTY commands. */
8527
8528/* Utility function to convert user input route type string to route
8529 type. */
8530static int
paulfd79ac92004-10-13 05:06:08 +00008531bgp_str2route_type (int afi, const char *str)
paul718e3742002-12-13 20:15:29 +00008532{
8533 if (! str)
8534 return 0;
8535
8536 if (afi == AFI_IP)
8537 {
8538 if (strncmp (str, "k", 1) == 0)
8539 return ZEBRA_ROUTE_KERNEL;
8540 else if (strncmp (str, "c", 1) == 0)
8541 return ZEBRA_ROUTE_CONNECT;
8542 else if (strncmp (str, "s", 1) == 0)
8543 return ZEBRA_ROUTE_STATIC;
8544 else if (strncmp (str, "r", 1) == 0)
8545 return ZEBRA_ROUTE_RIP;
8546 else if (strncmp (str, "o", 1) == 0)
8547 return ZEBRA_ROUTE_OSPF;
8548 }
8549 if (afi == AFI_IP6)
8550 {
8551 if (strncmp (str, "k", 1) == 0)
8552 return ZEBRA_ROUTE_KERNEL;
8553 else if (strncmp (str, "c", 1) == 0)
8554 return ZEBRA_ROUTE_CONNECT;
8555 else if (strncmp (str, "s", 1) == 0)
8556 return ZEBRA_ROUTE_STATIC;
8557 else if (strncmp (str, "r", 1) == 0)
8558 return ZEBRA_ROUTE_RIPNG;
8559 else if (strncmp (str, "o", 1) == 0)
8560 return ZEBRA_ROUTE_OSPF6;
8561 }
8562 return 0;
8563}
8564
8565DEFUN (bgp_redistribute_ipv4,
8566 bgp_redistribute_ipv4_cmd,
8567 "redistribute (connected|kernel|ospf|rip|static)",
8568 "Redistribute information from another routing protocol\n"
8569 "Connected\n"
8570 "Kernel routes\n"
8571 "Open Shurtest Path First (OSPF)\n"
8572 "Routing Information Protocol (RIP)\n"
8573 "Static routes\n")
8574{
8575 int type;
8576
8577 type = bgp_str2route_type (AFI_IP, argv[0]);
8578 if (! type)
8579 {
8580 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8581 return CMD_WARNING;
8582 }
8583 return bgp_redistribute_set (vty->index, AFI_IP, type);
8584}
8585
8586DEFUN (bgp_redistribute_ipv4_rmap,
8587 bgp_redistribute_ipv4_rmap_cmd,
8588 "redistribute (connected|kernel|ospf|rip|static) route-map WORD",
8589 "Redistribute information from another routing protocol\n"
8590 "Connected\n"
8591 "Kernel routes\n"
8592 "Open Shurtest Path First (OSPF)\n"
8593 "Routing Information Protocol (RIP)\n"
8594 "Static routes\n"
8595 "Route map reference\n"
8596 "Pointer to route-map entries\n")
8597{
8598 int type;
8599
8600 type = bgp_str2route_type (AFI_IP, argv[0]);
8601 if (! type)
8602 {
8603 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8604 return CMD_WARNING;
8605 }
8606
8607 bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[1]);
8608 return bgp_redistribute_set (vty->index, AFI_IP, type);
8609}
8610
8611DEFUN (bgp_redistribute_ipv4_metric,
8612 bgp_redistribute_ipv4_metric_cmd,
8613 "redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295>",
8614 "Redistribute information from another routing protocol\n"
8615 "Connected\n"
8616 "Kernel routes\n"
8617 "Open Shurtest Path First (OSPF)\n"
8618 "Routing Information Protocol (RIP)\n"
8619 "Static routes\n"
8620 "Metric for redistributed routes\n"
8621 "Default metric\n")
8622{
8623 int type;
8624 u_int32_t metric;
8625
8626 type = bgp_str2route_type (AFI_IP, argv[0]);
8627 if (! type)
8628 {
8629 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8630 return CMD_WARNING;
8631 }
8632 VTY_GET_INTEGER ("metric", metric, argv[1]);
8633
8634 bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
8635 return bgp_redistribute_set (vty->index, AFI_IP, type);
8636}
8637
8638DEFUN (bgp_redistribute_ipv4_rmap_metric,
8639 bgp_redistribute_ipv4_rmap_metric_cmd,
8640 "redistribute (connected|kernel|ospf|rip|static) route-map WORD metric <0-4294967295>",
8641 "Redistribute information from another routing protocol\n"
8642 "Connected\n"
8643 "Kernel routes\n"
8644 "Open Shurtest Path First (OSPF)\n"
8645 "Routing Information Protocol (RIP)\n"
8646 "Static routes\n"
8647 "Route map reference\n"
8648 "Pointer to route-map entries\n"
8649 "Metric for redistributed routes\n"
8650 "Default metric\n")
8651{
8652 int type;
8653 u_int32_t metric;
8654
8655 type = bgp_str2route_type (AFI_IP, argv[0]);
8656 if (! type)
8657 {
8658 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8659 return CMD_WARNING;
8660 }
8661 VTY_GET_INTEGER ("metric", metric, argv[2]);
8662
8663 bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[1]);
8664 bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
8665 return bgp_redistribute_set (vty->index, AFI_IP, type);
8666}
8667
8668DEFUN (bgp_redistribute_ipv4_metric_rmap,
8669 bgp_redistribute_ipv4_metric_rmap_cmd,
8670 "redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295> route-map WORD",
8671 "Redistribute information from another routing protocol\n"
8672 "Connected\n"
8673 "Kernel routes\n"
8674 "Open Shurtest Path First (OSPF)\n"
8675 "Routing Information Protocol (RIP)\n"
8676 "Static routes\n"
8677 "Metric for redistributed routes\n"
8678 "Default metric\n"
8679 "Route map reference\n"
8680 "Pointer to route-map entries\n")
8681{
8682 int type;
8683 u_int32_t metric;
8684
8685 type = bgp_str2route_type (AFI_IP, argv[0]);
8686 if (! type)
8687 {
8688 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8689 return CMD_WARNING;
8690 }
8691 VTY_GET_INTEGER ("metric", metric, argv[1]);
8692
8693 bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
8694 bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[2]);
8695 return bgp_redistribute_set (vty->index, AFI_IP, type);
8696}
8697
8698DEFUN (no_bgp_redistribute_ipv4,
8699 no_bgp_redistribute_ipv4_cmd,
8700 "no redistribute (connected|kernel|ospf|rip|static)",
8701 NO_STR
8702 "Redistribute information from another routing protocol\n"
8703 "Connected\n"
8704 "Kernel routes\n"
8705 "Open Shurtest Path First (OSPF)\n"
8706 "Routing Information Protocol (RIP)\n"
8707 "Static routes\n")
8708{
8709 int type;
8710
8711 type = bgp_str2route_type (AFI_IP, argv[0]);
8712 if (! type)
8713 {
8714 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8715 return CMD_WARNING;
8716 }
8717
8718 return bgp_redistribute_unset (vty->index, AFI_IP, type);
8719}
8720
8721DEFUN (no_bgp_redistribute_ipv4_rmap,
8722 no_bgp_redistribute_ipv4_rmap_cmd,
8723 "no redistribute (connected|kernel|ospf|rip|static) route-map WORD",
8724 NO_STR
8725 "Redistribute information from another routing protocol\n"
8726 "Connected\n"
8727 "Kernel routes\n"
8728 "Open Shurtest Path First (OSPF)\n"
8729 "Routing Information Protocol (RIP)\n"
8730 "Static routes\n"
8731 "Route map reference\n"
8732 "Pointer to route-map entries\n")
8733{
8734 int type;
8735
8736 type = bgp_str2route_type (AFI_IP, argv[0]);
8737 if (! type)
8738 {
8739 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8740 return CMD_WARNING;
8741 }
8742
8743 bgp_redistribute_routemap_unset (vty->index, AFI_IP, type);
8744 return CMD_SUCCESS;
8745}
8746
8747DEFUN (no_bgp_redistribute_ipv4_metric,
8748 no_bgp_redistribute_ipv4_metric_cmd,
8749 "no redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295>",
8750 NO_STR
8751 "Redistribute information from another routing protocol\n"
8752 "Connected\n"
8753 "Kernel routes\n"
8754 "Open Shurtest Path First (OSPF)\n"
8755 "Routing Information Protocol (RIP)\n"
8756 "Static routes\n"
8757 "Metric for redistributed routes\n"
8758 "Default metric\n")
8759{
8760 int type;
8761
8762 type = bgp_str2route_type (AFI_IP, argv[0]);
8763 if (! type)
8764 {
8765 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8766 return CMD_WARNING;
8767 }
8768
8769 bgp_redistribute_metric_unset (vty->index, AFI_IP, type);
8770 return CMD_SUCCESS;
8771}
8772
8773DEFUN (no_bgp_redistribute_ipv4_rmap_metric,
8774 no_bgp_redistribute_ipv4_rmap_metric_cmd,
8775 "no redistribute (connected|kernel|ospf|rip|static) route-map WORD metric <0-4294967295>",
8776 NO_STR
8777 "Redistribute information from another routing protocol\n"
8778 "Connected\n"
8779 "Kernel routes\n"
8780 "Open Shurtest Path First (OSPF)\n"
8781 "Routing Information Protocol (RIP)\n"
8782 "Static routes\n"
8783 "Route map reference\n"
8784 "Pointer to route-map entries\n"
8785 "Metric for redistributed routes\n"
8786 "Default metric\n")
8787{
8788 int type;
8789
8790 type = bgp_str2route_type (AFI_IP, argv[0]);
8791 if (! type)
8792 {
8793 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8794 return CMD_WARNING;
8795 }
8796
8797 bgp_redistribute_metric_unset (vty->index, AFI_IP, type);
8798 bgp_redistribute_routemap_unset (vty->index, AFI_IP, type);
8799 return CMD_SUCCESS;
8800}
8801
8802ALIAS (no_bgp_redistribute_ipv4_rmap_metric,
8803 no_bgp_redistribute_ipv4_metric_rmap_cmd,
8804 "no redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295> route-map WORD",
8805 NO_STR
8806 "Redistribute information from another routing protocol\n"
8807 "Connected\n"
8808 "Kernel routes\n"
8809 "Open Shurtest Path First (OSPF)\n"
8810 "Routing Information Protocol (RIP)\n"
8811 "Static routes\n"
8812 "Metric for redistributed routes\n"
8813 "Default metric\n"
8814 "Route map reference\n"
8815 "Pointer to route-map entries\n")
8816
8817#ifdef HAVE_IPV6
8818DEFUN (bgp_redistribute_ipv6,
8819 bgp_redistribute_ipv6_cmd,
8820 "redistribute (connected|kernel|ospf6|ripng|static)",
8821 "Redistribute information from another routing protocol\n"
8822 "Connected\n"
8823 "Kernel routes\n"
8824 "Open Shurtest Path First (OSPFv3)\n"
8825 "Routing Information Protocol (RIPng)\n"
8826 "Static routes\n")
8827{
8828 int type;
8829
8830 type = bgp_str2route_type (AFI_IP6, argv[0]);
8831 if (! type)
8832 {
8833 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8834 return CMD_WARNING;
8835 }
8836
8837 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8838}
8839
8840DEFUN (bgp_redistribute_ipv6_rmap,
8841 bgp_redistribute_ipv6_rmap_cmd,
8842 "redistribute (connected|kernel|ospf6|ripng|static) route-map WORD",
8843 "Redistribute information from another routing protocol\n"
8844 "Connected\n"
8845 "Kernel routes\n"
8846 "Open Shurtest Path First (OSPFv3)\n"
8847 "Routing Information Protocol (RIPng)\n"
8848 "Static routes\n"
8849 "Route map reference\n"
8850 "Pointer to route-map entries\n")
8851{
8852 int type;
8853
8854 type = bgp_str2route_type (AFI_IP6, argv[0]);
8855 if (! type)
8856 {
8857 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8858 return CMD_WARNING;
8859 }
8860
8861 bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[1]);
8862 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8863}
8864
8865DEFUN (bgp_redistribute_ipv6_metric,
8866 bgp_redistribute_ipv6_metric_cmd,
8867 "redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295>",
8868 "Redistribute information from another routing protocol\n"
8869 "Connected\n"
8870 "Kernel routes\n"
8871 "Open Shurtest Path First (OSPFv3)\n"
8872 "Routing Information Protocol (RIPng)\n"
8873 "Static routes\n"
8874 "Metric for redistributed routes\n"
8875 "Default metric\n")
8876{
8877 int type;
8878 u_int32_t metric;
8879
8880 type = bgp_str2route_type (AFI_IP6, argv[0]);
8881 if (! type)
8882 {
8883 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8884 return CMD_WARNING;
8885 }
8886 VTY_GET_INTEGER ("metric", metric, argv[1]);
8887
8888 bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
8889 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8890}
8891
8892DEFUN (bgp_redistribute_ipv6_rmap_metric,
8893 bgp_redistribute_ipv6_rmap_metric_cmd,
8894 "redistribute (connected|kernel|ospf6|ripng|static) route-map WORD metric <0-4294967295>",
8895 "Redistribute information from another routing protocol\n"
8896 "Connected\n"
8897 "Kernel routes\n"
8898 "Open Shurtest Path First (OSPFv3)\n"
8899 "Routing Information Protocol (RIPng)\n"
8900 "Static routes\n"
8901 "Route map reference\n"
8902 "Pointer to route-map entries\n"
8903 "Metric for redistributed routes\n"
8904 "Default metric\n")
8905{
8906 int type;
8907 u_int32_t metric;
8908
8909 type = bgp_str2route_type (AFI_IP6, argv[0]);
8910 if (! type)
8911 {
8912 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8913 return CMD_WARNING;
8914 }
8915 VTY_GET_INTEGER ("metric", metric, argv[2]);
8916
8917 bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[1]);
8918 bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
8919 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8920}
8921
8922DEFUN (bgp_redistribute_ipv6_metric_rmap,
8923 bgp_redistribute_ipv6_metric_rmap_cmd,
8924 "redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295> route-map WORD",
8925 "Redistribute information from another routing protocol\n"
8926 "Connected\n"
8927 "Kernel routes\n"
8928 "Open Shurtest Path First (OSPFv3)\n"
8929 "Routing Information Protocol (RIPng)\n"
8930 "Static routes\n"
8931 "Metric for redistributed routes\n"
8932 "Default metric\n"
8933 "Route map reference\n"
8934 "Pointer to route-map entries\n")
8935{
8936 int type;
8937 u_int32_t metric;
8938
8939 type = bgp_str2route_type (AFI_IP6, argv[0]);
8940 if (! type)
8941 {
8942 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8943 return CMD_WARNING;
8944 }
8945 VTY_GET_INTEGER ("metric", metric, argv[1]);
8946
8947 bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
8948 bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[2]);
8949 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8950}
8951
8952DEFUN (no_bgp_redistribute_ipv6,
8953 no_bgp_redistribute_ipv6_cmd,
8954 "no redistribute (connected|kernel|ospf6|ripng|static)",
8955 NO_STR
8956 "Redistribute information from another routing protocol\n"
8957 "Connected\n"
8958 "Kernel routes\n"
8959 "Open Shurtest Path First (OSPFv3)\n"
8960 "Routing Information Protocol (RIPng)\n"
8961 "Static routes\n")
8962{
8963 int type;
8964
8965 type = bgp_str2route_type (AFI_IP6, argv[0]);
8966 if (! type)
8967 {
8968 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8969 return CMD_WARNING;
8970 }
8971
8972 return bgp_redistribute_unset (vty->index, AFI_IP6, type);
8973}
8974
8975DEFUN (no_bgp_redistribute_ipv6_rmap,
8976 no_bgp_redistribute_ipv6_rmap_cmd,
8977 "no redistribute (connected|kernel|ospf6|ripng|static) route-map WORD",
8978 NO_STR
8979 "Redistribute information from another routing protocol\n"
8980 "Connected\n"
8981 "Kernel routes\n"
8982 "Open Shurtest Path First (OSPFv3)\n"
8983 "Routing Information Protocol (RIPng)\n"
8984 "Static routes\n"
8985 "Route map reference\n"
8986 "Pointer to route-map entries\n")
8987{
8988 int type;
8989
8990 type = bgp_str2route_type (AFI_IP6, argv[0]);
8991 if (! type)
8992 {
8993 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8994 return CMD_WARNING;
8995 }
8996
8997 bgp_redistribute_routemap_unset (vty->index, AFI_IP6, type);
8998 return CMD_SUCCESS;
8999}
9000
9001DEFUN (no_bgp_redistribute_ipv6_metric,
9002 no_bgp_redistribute_ipv6_metric_cmd,
9003 "no redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295>",
9004 NO_STR
9005 "Redistribute information from another routing protocol\n"
9006 "Connected\n"
9007 "Kernel routes\n"
9008 "Open Shurtest Path First (OSPFv3)\n"
9009 "Routing Information Protocol (RIPng)\n"
9010 "Static routes\n"
9011 "Metric for redistributed routes\n"
9012 "Default metric\n")
9013{
9014 int type;
9015
9016 type = bgp_str2route_type (AFI_IP6, argv[0]);
9017 if (! type)
9018 {
9019 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
9020 return CMD_WARNING;
9021 }
9022
9023 bgp_redistribute_metric_unset (vty->index, AFI_IP6, type);
9024 return CMD_SUCCESS;
9025}
9026
9027DEFUN (no_bgp_redistribute_ipv6_rmap_metric,
9028 no_bgp_redistribute_ipv6_rmap_metric_cmd,
9029 "no redistribute (connected|kernel|ospf6|ripng|static) route-map WORD metric <0-4294967295>",
9030 NO_STR
9031 "Redistribute information from another routing protocol\n"
9032 "Connected\n"
9033 "Kernel routes\n"
9034 "Open Shurtest Path First (OSPFv3)\n"
9035 "Routing Information Protocol (RIPng)\n"
9036 "Static routes\n"
9037 "Route map reference\n"
9038 "Pointer to route-map entries\n"
9039 "Metric for redistributed routes\n"
9040 "Default metric\n")
9041{
9042 int type;
9043
9044 type = bgp_str2route_type (AFI_IP6, argv[0]);
9045 if (! type)
9046 {
9047 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
9048 return CMD_WARNING;
9049 }
9050
9051 bgp_redistribute_metric_unset (vty->index, AFI_IP6, type);
9052 bgp_redistribute_routemap_unset (vty->index, AFI_IP6, type);
9053 return CMD_SUCCESS;
9054}
9055
9056ALIAS (no_bgp_redistribute_ipv6_rmap_metric,
9057 no_bgp_redistribute_ipv6_metric_rmap_cmd,
9058 "no redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295> route-map WORD",
9059 NO_STR
9060 "Redistribute information from another routing protocol\n"
9061 "Connected\n"
9062 "Kernel routes\n"
9063 "Open Shurtest Path First (OSPFv3)\n"
9064 "Routing Information Protocol (RIPng)\n"
9065 "Static routes\n"
9066 "Metric for redistributed routes\n"
9067 "Default metric\n"
9068 "Route map reference\n"
9069 "Pointer to route-map entries\n")
9070#endif /* HAVE_IPV6 */
9071
9072int
9073bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi,
9074 safi_t safi, int *write)
9075{
9076 int i;
paul718e3742002-12-13 20:15:29 +00009077
9078 /* Unicast redistribution only. */
9079 if (safi != SAFI_UNICAST)
9080 return 0;
9081
9082 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
9083 {
9084 /* Redistribute BGP does not make sense. */
9085 if (bgp->redist[afi][i] && i != ZEBRA_ROUTE_BGP)
9086 {
9087 /* Display "address-family" when it is not yet diplayed. */
9088 bgp_config_write_family_header (vty, afi, safi, write);
9089
9090 /* "redistribute" configuration. */
ajsf52d13c2005-10-01 17:38:06 +00009091 vty_out (vty, " redistribute %s", zebra_route_string(i));
paul718e3742002-12-13 20:15:29 +00009092
9093 if (bgp->redist_metric_flag[afi][i])
9094 vty_out (vty, " metric %d", bgp->redist_metric[afi][i]);
9095
9096 if (bgp->rmap[afi][i].name)
9097 vty_out (vty, " route-map %s", bgp->rmap[afi][i].name);
9098
9099 vty_out (vty, "%s", VTY_NEWLINE);
9100 }
9101 }
9102 return *write;
9103}
9104
9105/* BGP node structure. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08009106static struct cmd_node bgp_node =
paul718e3742002-12-13 20:15:29 +00009107{
9108 BGP_NODE,
9109 "%s(config-router)# ",
9110 1,
9111};
9112
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08009113static struct cmd_node bgp_ipv4_unicast_node =
paul718e3742002-12-13 20:15:29 +00009114{
9115 BGP_IPV4_NODE,
9116 "%s(config-router-af)# ",
9117 1,
9118};
9119
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08009120static struct cmd_node bgp_ipv4_multicast_node =
paul718e3742002-12-13 20:15:29 +00009121{
9122 BGP_IPV4M_NODE,
9123 "%s(config-router-af)# ",
9124 1,
9125};
9126
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08009127static struct cmd_node bgp_ipv6_unicast_node =
paul718e3742002-12-13 20:15:29 +00009128{
9129 BGP_IPV6_NODE,
9130 "%s(config-router-af)# ",
9131 1,
9132};
9133
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08009134static struct cmd_node bgp_ipv6_multicast_node =
paul25ffbdc2005-08-22 22:42:08 +00009135{
9136 BGP_IPV6M_NODE,
9137 "%s(config-router-af)# ",
9138 1,
9139};
9140
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08009141static struct cmd_node bgp_vpnv4_node =
paul718e3742002-12-13 20:15:29 +00009142{
9143 BGP_VPNV4_NODE,
9144 "%s(config-router-af)# ",
9145 1
9146};
9147
paul1f8ae702005-09-09 23:49:49 +00009148static void community_list_vty (void);
9149
paul718e3742002-12-13 20:15:29 +00009150void
paul94f2b392005-06-28 12:44:16 +00009151bgp_vty_init (void)
paul718e3742002-12-13 20:15:29 +00009152{
paul718e3742002-12-13 20:15:29 +00009153 /* Install bgp top node. */
9154 install_node (&bgp_node, bgp_config_write);
9155 install_node (&bgp_ipv4_unicast_node, NULL);
9156 install_node (&bgp_ipv4_multicast_node, NULL);
9157 install_node (&bgp_ipv6_unicast_node, NULL);
paul25ffbdc2005-08-22 22:42:08 +00009158 install_node (&bgp_ipv6_multicast_node, NULL);
paul718e3742002-12-13 20:15:29 +00009159 install_node (&bgp_vpnv4_node, NULL);
9160
9161 /* Install default VTY commands to new nodes. */
9162 install_default (BGP_NODE);
9163 install_default (BGP_IPV4_NODE);
9164 install_default (BGP_IPV4M_NODE);
9165 install_default (BGP_IPV6_NODE);
paul25ffbdc2005-08-22 22:42:08 +00009166 install_default (BGP_IPV6M_NODE);
paul718e3742002-12-13 20:15:29 +00009167 install_default (BGP_VPNV4_NODE);
9168
9169 /* "bgp multiple-instance" commands. */
9170 install_element (CONFIG_NODE, &bgp_multiple_instance_cmd);
9171 install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd);
9172
9173 /* "bgp config-type" commands. */
9174 install_element (CONFIG_NODE, &bgp_config_type_cmd);
9175 install_element (CONFIG_NODE, &no_bgp_config_type_cmd);
9176
9177 /* Dummy commands (Currently not supported) */
9178 install_element (BGP_NODE, &no_synchronization_cmd);
9179 install_element (BGP_NODE, &no_auto_summary_cmd);
9180
9181 /* "router bgp" commands. */
9182 install_element (CONFIG_NODE, &router_bgp_cmd);
9183 install_element (CONFIG_NODE, &router_bgp_view_cmd);
9184
9185 /* "no router bgp" commands. */
9186 install_element (CONFIG_NODE, &no_router_bgp_cmd);
9187 install_element (CONFIG_NODE, &no_router_bgp_view_cmd);
9188
9189 /* "bgp router-id" commands. */
9190 install_element (BGP_NODE, &bgp_router_id_cmd);
9191 install_element (BGP_NODE, &no_bgp_router_id_cmd);
9192 install_element (BGP_NODE, &no_bgp_router_id_val_cmd);
9193
9194 /* "bgp cluster-id" commands. */
9195 install_element (BGP_NODE, &bgp_cluster_id_cmd);
9196 install_element (BGP_NODE, &bgp_cluster_id32_cmd);
9197 install_element (BGP_NODE, &no_bgp_cluster_id_cmd);
9198 install_element (BGP_NODE, &no_bgp_cluster_id_arg_cmd);
9199
9200 /* "bgp confederation" commands. */
9201 install_element (BGP_NODE, &bgp_confederation_identifier_cmd);
9202 install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd);
9203 install_element (BGP_NODE, &no_bgp_confederation_identifier_arg_cmd);
9204
9205 /* "bgp confederation peers" commands. */
9206 install_element (BGP_NODE, &bgp_confederation_peers_cmd);
9207 install_element (BGP_NODE, &no_bgp_confederation_peers_cmd);
9208
Josh Bailey165b5ff2011-07-20 20:43:22 -07009209 /* "maximum-paths" commands. */
9210 install_element (BGP_NODE, &bgp_maxpaths_cmd);
9211 install_element (BGP_NODE, &no_bgp_maxpaths_cmd);
9212 install_element (BGP_NODE, &no_bgp_maxpaths_arg_cmd);
9213 install_element (BGP_IPV4_NODE, &bgp_maxpaths_cmd);
9214 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_cmd);
9215 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_arg_cmd);
9216 install_element (BGP_NODE, &bgp_maxpaths_ibgp_cmd);
9217 install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cmd);
9218 install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_arg_cmd);
9219 install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd);
9220 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd);
9221 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_arg_cmd);
9222
paul718e3742002-12-13 20:15:29 +00009223 /* "timers bgp" commands. */
9224 install_element (BGP_NODE, &bgp_timers_cmd);
9225 install_element (BGP_NODE, &no_bgp_timers_cmd);
9226 install_element (BGP_NODE, &no_bgp_timers_arg_cmd);
9227
9228 /* "bgp client-to-client reflection" commands */
9229 install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd);
9230 install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd);
9231
9232 /* "bgp always-compare-med" commands */
9233 install_element (BGP_NODE, &bgp_always_compare_med_cmd);
9234 install_element (BGP_NODE, &no_bgp_always_compare_med_cmd);
9235
9236 /* "bgp deterministic-med" commands */
9237 install_element (BGP_NODE, &bgp_deterministic_med_cmd);
9238 install_element (BGP_NODE, &no_bgp_deterministic_med_cmd);
hasso538621f2004-05-21 09:31:30 +00009239
hasso538621f2004-05-21 09:31:30 +00009240 /* "bgp graceful-restart" commands */
9241 install_element (BGP_NODE, &bgp_graceful_restart_cmd);
9242 install_element (BGP_NODE, &no_bgp_graceful_restart_cmd);
hasso93406d82005-02-02 14:40:33 +00009243 install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd);
9244 install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd);
9245 install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_val_cmd);
paul718e3742002-12-13 20:15:29 +00009246
9247 /* "bgp fast-external-failover" commands */
9248 install_element (BGP_NODE, &bgp_fast_external_failover_cmd);
9249 install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd);
9250
9251 /* "bgp enforce-first-as" commands */
9252 install_element (BGP_NODE, &bgp_enforce_first_as_cmd);
9253 install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd);
9254
9255 /* "bgp bestpath compare-routerid" commands */
9256 install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd);
9257 install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd);
9258
9259 /* "bgp bestpath as-path ignore" commands */
9260 install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd);
9261 install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd);
9262
hasso68118452005-04-08 15:40:36 +00009263 /* "bgp bestpath as-path confed" commands */
9264 install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd);
9265 install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd);
9266
paul848973c2003-08-13 00:32:49 +00009267 /* "bgp log-neighbor-changes" commands */
9268 install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd);
9269 install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd);
9270
paul718e3742002-12-13 20:15:29 +00009271 /* "bgp bestpath med" commands */
9272 install_element (BGP_NODE, &bgp_bestpath_med_cmd);
9273 install_element (BGP_NODE, &bgp_bestpath_med2_cmd);
9274 install_element (BGP_NODE, &bgp_bestpath_med3_cmd);
9275 install_element (BGP_NODE, &no_bgp_bestpath_med_cmd);
9276 install_element (BGP_NODE, &no_bgp_bestpath_med2_cmd);
9277 install_element (BGP_NODE, &no_bgp_bestpath_med3_cmd);
9278
9279 /* "no bgp default ipv4-unicast" commands. */
9280 install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd);
9281 install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd);
9282
9283 /* "bgp network import-check" commands. */
9284 install_element (BGP_NODE, &bgp_network_import_check_cmd);
9285 install_element (BGP_NODE, &no_bgp_network_import_check_cmd);
9286
9287 /* "bgp default local-preference" commands. */
9288 install_element (BGP_NODE, &bgp_default_local_preference_cmd);
9289 install_element (BGP_NODE, &no_bgp_default_local_preference_cmd);
9290 install_element (BGP_NODE, &no_bgp_default_local_preference_val_cmd);
9291
9292 /* "neighbor remote-as" commands. */
9293 install_element (BGP_NODE, &neighbor_remote_as_cmd);
9294 install_element (BGP_NODE, &no_neighbor_cmd);
9295 install_element (BGP_NODE, &no_neighbor_remote_as_cmd);
9296
9297 /* "neighbor peer-group" commands. */
9298 install_element (BGP_NODE, &neighbor_peer_group_cmd);
9299 install_element (BGP_NODE, &no_neighbor_peer_group_cmd);
9300 install_element (BGP_NODE, &no_neighbor_peer_group_remote_as_cmd);
9301
9302 /* "neighbor local-as" commands. */
9303 install_element (BGP_NODE, &neighbor_local_as_cmd);
9304 install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd);
9305 install_element (BGP_NODE, &no_neighbor_local_as_cmd);
9306 install_element (BGP_NODE, &no_neighbor_local_as_val_cmd);
9307 install_element (BGP_NODE, &no_neighbor_local_as_val2_cmd);
9308
Paul Jakma0df7c912008-07-21 21:02:49 +00009309 /* "neighbor password" commands. */
9310 install_element (BGP_NODE, &neighbor_password_cmd);
9311 install_element (BGP_NODE, &no_neighbor_password_cmd);
9312
paul718e3742002-12-13 20:15:29 +00009313 /* "neighbor activate" commands. */
9314 install_element (BGP_NODE, &neighbor_activate_cmd);
9315 install_element (BGP_IPV4_NODE, &neighbor_activate_cmd);
9316 install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd);
9317 install_element (BGP_IPV6_NODE, &neighbor_activate_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009318 install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd);
paul718e3742002-12-13 20:15:29 +00009319 install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd);
9320
9321 /* "no neighbor activate" commands. */
9322 install_element (BGP_NODE, &no_neighbor_activate_cmd);
9323 install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd);
9324 install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd);
9325 install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009326 install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd);
paul718e3742002-12-13 20:15:29 +00009327 install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd);
9328
9329 /* "neighbor peer-group set" commands. */
9330 install_element (BGP_NODE, &neighbor_set_peer_group_cmd);
9331 install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_cmd);
9332 install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_cmd);
9333 install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009334 install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_cmd);
paula58545b2003-07-12 21:43:01 +00009335 install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_cmd);
9336
paul718e3742002-12-13 20:15:29 +00009337 /* "no neighbor peer-group unset" commands. */
9338 install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd);
9339 install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd);
9340 install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_cmd);
9341 install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009342 install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_cmd);
paula58545b2003-07-12 21:43:01 +00009343 install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_cmd);
9344
paul718e3742002-12-13 20:15:29 +00009345 /* "neighbor softreconfiguration inbound" commands.*/
9346 install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd);
9347 install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd);
9348 install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd);
9349 install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
9350 install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd);
9351 install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd);
9352 install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd);
9353 install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009354 install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd);
9355 install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd);
paula58545b2003-07-12 21:43:01 +00009356 install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd);
9357 install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
paul718e3742002-12-13 20:15:29 +00009358
9359 /* "neighbor attribute-unchanged" commands. */
9360 install_element (BGP_NODE, &neighbor_attr_unchanged_cmd);
9361 install_element (BGP_NODE, &neighbor_attr_unchanged1_cmd);
9362 install_element (BGP_NODE, &neighbor_attr_unchanged2_cmd);
9363 install_element (BGP_NODE, &neighbor_attr_unchanged3_cmd);
9364 install_element (BGP_NODE, &neighbor_attr_unchanged4_cmd);
9365 install_element (BGP_NODE, &neighbor_attr_unchanged5_cmd);
9366 install_element (BGP_NODE, &neighbor_attr_unchanged6_cmd);
9367 install_element (BGP_NODE, &neighbor_attr_unchanged7_cmd);
9368 install_element (BGP_NODE, &neighbor_attr_unchanged8_cmd);
9369 install_element (BGP_NODE, &neighbor_attr_unchanged9_cmd);
9370 install_element (BGP_NODE, &neighbor_attr_unchanged10_cmd);
9371 install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd);
9372 install_element (BGP_NODE, &no_neighbor_attr_unchanged1_cmd);
9373 install_element (BGP_NODE, &no_neighbor_attr_unchanged2_cmd);
9374 install_element (BGP_NODE, &no_neighbor_attr_unchanged3_cmd);
9375 install_element (BGP_NODE, &no_neighbor_attr_unchanged4_cmd);
9376 install_element (BGP_NODE, &no_neighbor_attr_unchanged5_cmd);
9377 install_element (BGP_NODE, &no_neighbor_attr_unchanged6_cmd);
9378 install_element (BGP_NODE, &no_neighbor_attr_unchanged7_cmd);
9379 install_element (BGP_NODE, &no_neighbor_attr_unchanged8_cmd);
9380 install_element (BGP_NODE, &no_neighbor_attr_unchanged9_cmd);
9381 install_element (BGP_NODE, &no_neighbor_attr_unchanged10_cmd);
9382 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd);
9383 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged1_cmd);
9384 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged2_cmd);
9385 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged3_cmd);
9386 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged4_cmd);
9387 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged5_cmd);
9388 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged6_cmd);
9389 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged7_cmd);
9390 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged8_cmd);
9391 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged9_cmd);
9392 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged10_cmd);
9393 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd);
9394 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged1_cmd);
9395 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged2_cmd);
9396 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged3_cmd);
9397 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged4_cmd);
9398 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged5_cmd);
9399 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged6_cmd);
9400 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged7_cmd);
9401 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged8_cmd);
9402 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged9_cmd);
9403 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged10_cmd);
9404 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd);
9405 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged1_cmd);
9406 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged2_cmd);
9407 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged3_cmd);
9408 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged4_cmd);
9409 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged5_cmd);
9410 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged6_cmd);
9411 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged7_cmd);
9412 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged8_cmd);
9413 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged9_cmd);
9414 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged10_cmd);
9415 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd);
9416 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged1_cmd);
9417 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged2_cmd);
9418 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged3_cmd);
9419 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged4_cmd);
9420 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged5_cmd);
9421 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged6_cmd);
9422 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged7_cmd);
9423 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged8_cmd);
9424 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged9_cmd);
9425 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged10_cmd);
9426 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd);
9427 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged1_cmd);
9428 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged2_cmd);
9429 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged3_cmd);
9430 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged4_cmd);
9431 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged5_cmd);
9432 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged6_cmd);
9433 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged7_cmd);
9434 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged8_cmd);
9435 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged9_cmd);
9436 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged10_cmd);
9437 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd);
9438 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged1_cmd);
9439 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged2_cmd);
9440 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged3_cmd);
9441 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged4_cmd);
9442 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged5_cmd);
9443 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged6_cmd);
9444 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged7_cmd);
9445 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged8_cmd);
9446 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged9_cmd);
9447 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged10_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009448 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd);
9449 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged1_cmd);
9450 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged2_cmd);
9451 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged3_cmd);
9452 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged4_cmd);
9453 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged5_cmd);
9454 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged6_cmd);
9455 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged7_cmd);
9456 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged8_cmd);
9457 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged9_cmd);
9458 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged10_cmd);
9459 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd);
9460 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged1_cmd);
9461 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged2_cmd);
9462 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged3_cmd);
9463 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged4_cmd);
9464 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged5_cmd);
9465 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged6_cmd);
9466 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged7_cmd);
9467 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged8_cmd);
9468 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged9_cmd);
9469 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged10_cmd);
paul718e3742002-12-13 20:15:29 +00009470 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd);
9471 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged1_cmd);
9472 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged2_cmd);
9473 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged3_cmd);
9474 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged4_cmd);
9475 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged5_cmd);
9476 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged6_cmd);
9477 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged7_cmd);
9478 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged8_cmd);
9479 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged9_cmd);
9480 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged10_cmd);
9481 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd);
9482 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged1_cmd);
9483 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged2_cmd);
9484 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged3_cmd);
9485 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged4_cmd);
9486 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged5_cmd);
9487 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged6_cmd);
9488 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged7_cmd);
9489 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged8_cmd);
9490 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged9_cmd);
9491 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged10_cmd);
9492
paulfee0f4c2004-09-13 05:12:46 +00009493 /* "nexthop-local unchanged" commands */
9494 install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd);
9495 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd);
9496
paul718e3742002-12-13 20:15:29 +00009497 /* "transparent-as" and "transparent-nexthop" for old version
9498 compatibility. */
9499 install_element (BGP_NODE, &neighbor_transparent_as_cmd);
9500 install_element (BGP_NODE, &neighbor_transparent_nexthop_cmd);
9501
9502 /* "neighbor next-hop-self" commands. */
9503 install_element (BGP_NODE, &neighbor_nexthop_self_cmd);
9504 install_element (BGP_NODE, &no_neighbor_nexthop_self_cmd);
9505 install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd);
9506 install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd);
9507 install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd);
9508 install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd);
9509 install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd);
9510 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009511 install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd);
9512 install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd);
paul718e3742002-12-13 20:15:29 +00009513 install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd);
9514 install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd);
9515
9516 /* "neighbor remove-private-AS" commands. */
9517 install_element (BGP_NODE, &neighbor_remove_private_as_cmd);
9518 install_element (BGP_NODE, &no_neighbor_remove_private_as_cmd);
9519 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd);
9520 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd);
9521 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd);
9522 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd);
9523 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd);
9524 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009525 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd);
9526 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd);
paul718e3742002-12-13 20:15:29 +00009527 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd);
9528 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd);
9529
9530 /* "neighbor send-community" commands.*/
9531 install_element (BGP_NODE, &neighbor_send_community_cmd);
9532 install_element (BGP_NODE, &neighbor_send_community_type_cmd);
9533 install_element (BGP_NODE, &no_neighbor_send_community_cmd);
9534 install_element (BGP_NODE, &no_neighbor_send_community_type_cmd);
9535 install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd);
9536 install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd);
9537 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd);
9538 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd);
9539 install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd);
9540 install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd);
9541 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd);
9542 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd);
9543 install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd);
9544 install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd);
9545 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd);
9546 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009547 install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd);
9548 install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd);
9549 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd);
9550 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd);
paul718e3742002-12-13 20:15:29 +00009551 install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd);
9552 install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd);
9553 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd);
9554 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd);
9555
9556 /* "neighbor route-reflector" commands.*/
9557 install_element (BGP_NODE, &neighbor_route_reflector_client_cmd);
9558 install_element (BGP_NODE, &no_neighbor_route_reflector_client_cmd);
9559 install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd);
9560 install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd);
9561 install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd);
9562 install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd);
9563 install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd);
9564 install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009565 install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd);
9566 install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd);
paul718e3742002-12-13 20:15:29 +00009567 install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd);
9568 install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd);
9569
9570 /* "neighbor route-server" commands.*/
9571 install_element (BGP_NODE, &neighbor_route_server_client_cmd);
9572 install_element (BGP_NODE, &no_neighbor_route_server_client_cmd);
9573 install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd);
9574 install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd);
9575 install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd);
9576 install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd);
9577 install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd);
9578 install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009579 install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd);
9580 install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd);
paul718e3742002-12-13 20:15:29 +00009581 install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd);
9582 install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd);
9583
9584 /* "neighbor passive" commands. */
9585 install_element (BGP_NODE, &neighbor_passive_cmd);
9586 install_element (BGP_NODE, &no_neighbor_passive_cmd);
9587
9588 /* "neighbor shutdown" commands. */
9589 install_element (BGP_NODE, &neighbor_shutdown_cmd);
9590 install_element (BGP_NODE, &no_neighbor_shutdown_cmd);
9591
hassoc9502432005-02-01 22:01:48 +00009592 /* Deprecated "neighbor capability route-refresh" commands.*/
paul718e3742002-12-13 20:15:29 +00009593 install_element (BGP_NODE, &neighbor_capability_route_refresh_cmd);
9594 install_element (BGP_NODE, &no_neighbor_capability_route_refresh_cmd);
9595
9596 /* "neighbor capability orf prefix-list" commands.*/
9597 install_element (BGP_NODE, &neighbor_capability_orf_prefix_cmd);
9598 install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_cmd);
9599 install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd);
9600 install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd);
9601 install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd);
9602 install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd);
9603 install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd);
9604 install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009605 install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd);
9606 install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00009607
9608 /* "neighbor capability dynamic" commands.*/
9609 install_element (BGP_NODE, &neighbor_capability_dynamic_cmd);
9610 install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd);
9611
9612 /* "neighbor dont-capability-negotiate" commands. */
9613 install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd);
9614 install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd);
9615
9616 /* "neighbor ebgp-multihop" commands. */
9617 install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd);
9618 install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd);
9619 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd);
9620 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_ttl_cmd);
9621
hasso6ffd2072005-02-02 14:50:11 +00009622 /* "neighbor disable-connected-check" commands. */
9623 install_element (BGP_NODE, &neighbor_disable_connected_check_cmd);
9624 install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd);
paul718e3742002-12-13 20:15:29 +00009625 install_element (BGP_NODE, &neighbor_enforce_multihop_cmd);
9626 install_element (BGP_NODE, &no_neighbor_enforce_multihop_cmd);
9627
9628 /* "neighbor description" commands. */
9629 install_element (BGP_NODE, &neighbor_description_cmd);
9630 install_element (BGP_NODE, &no_neighbor_description_cmd);
9631 install_element (BGP_NODE, &no_neighbor_description_val_cmd);
9632
9633 /* "neighbor update-source" commands. "*/
9634 install_element (BGP_NODE, &neighbor_update_source_cmd);
9635 install_element (BGP_NODE, &no_neighbor_update_source_cmd);
9636
9637 /* "neighbor default-originate" commands. */
9638 install_element (BGP_NODE, &neighbor_default_originate_cmd);
9639 install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd);
9640 install_element (BGP_NODE, &no_neighbor_default_originate_cmd);
9641 install_element (BGP_NODE, &no_neighbor_default_originate_rmap_cmd);
9642 install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd);
9643 install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd);
9644 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd);
9645 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_rmap_cmd);
9646 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd);
9647 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd);
9648 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd);
9649 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_rmap_cmd);
9650 install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd);
9651 install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd);
9652 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd);
9653 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_rmap_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009654 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd);
9655 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd);
9656 install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd);
9657 install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_rmap_cmd);
paul718e3742002-12-13 20:15:29 +00009658
9659 /* "neighbor port" commands. */
9660 install_element (BGP_NODE, &neighbor_port_cmd);
9661 install_element (BGP_NODE, &no_neighbor_port_cmd);
9662 install_element (BGP_NODE, &no_neighbor_port_val_cmd);
9663
9664 /* "neighbor weight" commands. */
9665 install_element (BGP_NODE, &neighbor_weight_cmd);
9666 install_element (BGP_NODE, &no_neighbor_weight_cmd);
9667 install_element (BGP_NODE, &no_neighbor_weight_val_cmd);
9668
9669 /* "neighbor override-capability" commands. */
9670 install_element (BGP_NODE, &neighbor_override_capability_cmd);
9671 install_element (BGP_NODE, &no_neighbor_override_capability_cmd);
9672
9673 /* "neighbor strict-capability-match" commands. */
9674 install_element (BGP_NODE, &neighbor_strict_capability_cmd);
9675 install_element (BGP_NODE, &no_neighbor_strict_capability_cmd);
9676
9677 /* "neighbor timers" commands. */
9678 install_element (BGP_NODE, &neighbor_timers_cmd);
9679 install_element (BGP_NODE, &no_neighbor_timers_cmd);
9680
9681 /* "neighbor timers connect" commands. */
9682 install_element (BGP_NODE, &neighbor_timers_connect_cmd);
9683 install_element (BGP_NODE, &no_neighbor_timers_connect_cmd);
9684 install_element (BGP_NODE, &no_neighbor_timers_connect_val_cmd);
9685
9686 /* "neighbor advertisement-interval" commands. */
9687 install_element (BGP_NODE, &neighbor_advertise_interval_cmd);
9688 install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd);
9689 install_element (BGP_NODE, &no_neighbor_advertise_interval_val_cmd);
9690
9691 /* "neighbor version" commands. */
9692 install_element (BGP_NODE, &neighbor_version_cmd);
paul718e3742002-12-13 20:15:29 +00009693
9694 /* "neighbor interface" commands. */
9695 install_element (BGP_NODE, &neighbor_interface_cmd);
9696 install_element (BGP_NODE, &no_neighbor_interface_cmd);
9697
9698 /* "neighbor distribute" commands. */
9699 install_element (BGP_NODE, &neighbor_distribute_list_cmd);
9700 install_element (BGP_NODE, &no_neighbor_distribute_list_cmd);
9701 install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd);
9702 install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd);
9703 install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd);
9704 install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd);
9705 install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd);
9706 install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009707 install_element (BGP_IPV6M_NODE, &neighbor_distribute_list_cmd);
9708 install_element (BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd);
paul718e3742002-12-13 20:15:29 +00009709 install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd);
9710 install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd);
9711
9712 /* "neighbor prefix-list" commands. */
9713 install_element (BGP_NODE, &neighbor_prefix_list_cmd);
9714 install_element (BGP_NODE, &no_neighbor_prefix_list_cmd);
9715 install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd);
9716 install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd);
9717 install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd);
9718 install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd);
9719 install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd);
9720 install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009721 install_element (BGP_IPV6M_NODE, &neighbor_prefix_list_cmd);
9722 install_element (BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd);
paul718e3742002-12-13 20:15:29 +00009723 install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd);
9724 install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd);
9725
9726 /* "neighbor filter-list" commands. */
9727 install_element (BGP_NODE, &neighbor_filter_list_cmd);
9728 install_element (BGP_NODE, &no_neighbor_filter_list_cmd);
9729 install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd);
9730 install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd);
9731 install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd);
9732 install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd);
9733 install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd);
9734 install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009735 install_element (BGP_IPV6M_NODE, &neighbor_filter_list_cmd);
9736 install_element (BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00009737 install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd);
9738 install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd);
9739
9740 /* "neighbor route-map" commands. */
9741 install_element (BGP_NODE, &neighbor_route_map_cmd);
9742 install_element (BGP_NODE, &no_neighbor_route_map_cmd);
9743 install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd);
9744 install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd);
9745 install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd);
9746 install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd);
9747 install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd);
9748 install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009749 install_element (BGP_IPV6M_NODE, &neighbor_route_map_cmd);
9750 install_element (BGP_IPV6M_NODE, &no_neighbor_route_map_cmd);
paul718e3742002-12-13 20:15:29 +00009751 install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd);
9752 install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd);
9753
9754 /* "neighbor unsuppress-map" commands. */
9755 install_element (BGP_NODE, &neighbor_unsuppress_map_cmd);
9756 install_element (BGP_NODE, &no_neighbor_unsuppress_map_cmd);
9757 install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd);
9758 install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd);
9759 install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd);
9760 install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd);
9761 install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd);
9762 install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009763 install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd);
9764 install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd);
paula58545b2003-07-12 21:43:01 +00009765 install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd);
9766 install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd);
paul718e3742002-12-13 20:15:29 +00009767
9768 /* "neighbor maximum-prefix" commands. */
9769 install_element (BGP_NODE, &neighbor_maximum_prefix_cmd);
hassoe0701b72004-05-20 09:19:34 +00009770 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_cmd);
paul718e3742002-12-13 20:15:29 +00009771 install_element (BGP_NODE, &neighbor_maximum_prefix_warning_cmd);
hassoe0701b72004-05-20 09:19:34 +00009772 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
hasso0a486e52005-02-01 20:57:17 +00009773 install_element (BGP_NODE, &neighbor_maximum_prefix_restart_cmd);
9774 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009775 install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd);
9776 install_element (BGP_NODE, &no_neighbor_maximum_prefix_val_cmd);
hasso0a486e52005-02-01 20:57:17 +00009777 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9778 install_element (BGP_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9779 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9780 install_element (BGP_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9781 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009782 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd);
hassoe0701b72004-05-20 09:19:34 +00009783 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
paul718e3742002-12-13 20:15:29 +00009784 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd);
hassoe0701b72004-05-20 09:19:34 +00009785 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
hasso0a486e52005-02-01 20:57:17 +00009786 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd);
9787 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009788 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd);
9789 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
hasso0a486e52005-02-01 20:57:17 +00009790 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9791 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9792 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9793 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9794 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009795 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd);
hassoe0701b72004-05-20 09:19:34 +00009796 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd);
paul718e3742002-12-13 20:15:29 +00009797 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd);
hassoe0701b72004-05-20 09:19:34 +00009798 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
hasso0a486e52005-02-01 20:57:17 +00009799 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd);
9800 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009801 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd);
9802 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_val_cmd);
hasso0a486e52005-02-01 20:57:17 +00009803 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9804 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9805 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9806 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9807 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009808 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd);
hassoe0701b72004-05-20 09:19:34 +00009809 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
paul718e3742002-12-13 20:15:29 +00009810 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd);
hassoe0701b72004-05-20 09:19:34 +00009811 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
hasso0a486e52005-02-01 20:57:17 +00009812 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd);
9813 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009814 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd);
9815 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_val_cmd);
hasso0a486e52005-02-01 20:57:17 +00009816 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9817 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9818 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9819 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9820 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009821 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd);
9822 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd);
9823 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd);
9824 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
9825 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd);
9826 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
9827 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd);
9828 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_val_cmd);
9829 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9830 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9831 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9832 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9833 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009834 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd);
hassoe0701b72004-05-20 09:19:34 +00009835 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
paul718e3742002-12-13 20:15:29 +00009836 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd);
hassoe0701b72004-05-20 09:19:34 +00009837 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
hasso0a486e52005-02-01 20:57:17 +00009838 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd);
9839 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009840 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd);
9841 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
hasso0a486e52005-02-01 20:57:17 +00009842 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9843 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9844 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9845 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9846 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
paul718e3742002-12-13 20:15:29 +00009847
9848 /* "neighbor allowas-in" */
9849 install_element (BGP_NODE, &neighbor_allowas_in_cmd);
9850 install_element (BGP_NODE, &neighbor_allowas_in_arg_cmd);
9851 install_element (BGP_NODE, &no_neighbor_allowas_in_cmd);
9852 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd);
9853 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_arg_cmd);
9854 install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd);
9855 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd);
9856 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_arg_cmd);
9857 install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd);
9858 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd);
9859 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_arg_cmd);
9860 install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009861 install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd);
9862 install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_arg_cmd);
9863 install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd);
paul718e3742002-12-13 20:15:29 +00009864 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd);
9865 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_arg_cmd);
9866 install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd);
9867
9868 /* address-family commands. */
9869 install_element (BGP_NODE, &address_family_ipv4_cmd);
9870 install_element (BGP_NODE, &address_family_ipv4_safi_cmd);
9871#ifdef HAVE_IPV6
9872 install_element (BGP_NODE, &address_family_ipv6_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009873 install_element (BGP_NODE, &address_family_ipv6_safi_cmd);
paul718e3742002-12-13 20:15:29 +00009874#endif /* HAVE_IPV6 */
9875 install_element (BGP_NODE, &address_family_vpnv4_cmd);
9876 install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd);
9877
9878 /* "exit-address-family" command. */
9879 install_element (BGP_IPV4_NODE, &exit_address_family_cmd);
9880 install_element (BGP_IPV4M_NODE, &exit_address_family_cmd);
9881 install_element (BGP_IPV6_NODE, &exit_address_family_cmd);
paul25ffbdc2005-08-22 22:42:08 +00009882 install_element (BGP_IPV6M_NODE, &exit_address_family_cmd);
paul718e3742002-12-13 20:15:29 +00009883 install_element (BGP_VPNV4_NODE, &exit_address_family_cmd);
9884
9885 /* "clear ip bgp commands" */
9886 install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd);
9887 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_cmd);
9888 install_element (ENABLE_NODE, &clear_ip_bgp_as_cmd);
9889 install_element (ENABLE_NODE, &clear_ip_bgp_peer_cmd);
9890 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_cmd);
9891 install_element (ENABLE_NODE, &clear_ip_bgp_external_cmd);
9892#ifdef HAVE_IPV6
9893 install_element (ENABLE_NODE, &clear_bgp_all_cmd);
9894 install_element (ENABLE_NODE, &clear_bgp_instance_all_cmd);
9895 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_cmd);
9896 install_element (ENABLE_NODE, &clear_bgp_peer_cmd);
9897 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_cmd);
9898 install_element (ENABLE_NODE, &clear_bgp_peer_group_cmd);
9899 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_cmd);
9900 install_element (ENABLE_NODE, &clear_bgp_external_cmd);
9901 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_cmd);
9902 install_element (ENABLE_NODE, &clear_bgp_as_cmd);
9903 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_cmd);
9904#endif /* HAVE_IPV6 */
9905
9906 /* "clear ip bgp neighbor soft in" */
9907 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_in_cmd);
9908 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_in_cmd);
9909 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_cmd);
9910 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_prefix_filter_cmd);
9911 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_in_prefix_filter_cmd);
9912 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_in_cmd);
9913 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_cmd);
9914 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_prefix_filter_cmd);
9915 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_in_cmd);
9916 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_cmd);
9917 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_prefix_filter_cmd);
9918 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_in_cmd);
9919 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_cmd);
9920 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_prefix_filter_cmd);
9921 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_in_cmd);
9922 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_cmd);
9923 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_prefix_filter_cmd);
9924 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_in_cmd);
9925 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_in_cmd);
9926 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_cmd);
9927 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_prefix_filter_cmd);
9928 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_in_prefix_filter_cmd);
9929 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_in_cmd);
9930 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_cmd);
9931 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd);
9932 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_in_cmd);
9933 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_cmd);
9934 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd);
9935 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_in_cmd);
9936 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_cmd);
9937 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_prefix_filter_cmd);
9938 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_in_cmd);
9939 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_cmd);
9940 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_prefix_filter_cmd);
9941 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_in_cmd);
9942 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_in_cmd);
9943 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_in_cmd);
9944 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_in_cmd);
9945 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_in_cmd);
9946 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_in_cmd);
9947#ifdef HAVE_IPV6
9948 install_element (ENABLE_NODE, &clear_bgp_all_soft_in_cmd);
9949 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_in_cmd);
9950 install_element (ENABLE_NODE, &clear_bgp_all_in_cmd);
9951 install_element (ENABLE_NODE, &clear_bgp_all_in_prefix_filter_cmd);
9952 install_element (ENABLE_NODE, &clear_bgp_peer_soft_in_cmd);
9953 install_element (ENABLE_NODE, &clear_bgp_peer_in_cmd);
9954 install_element (ENABLE_NODE, &clear_bgp_peer_in_prefix_filter_cmd);
9955 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_in_cmd);
9956 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_cmd);
9957 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_prefix_filter_cmd);
9958 install_element (ENABLE_NODE, &clear_bgp_external_soft_in_cmd);
9959 install_element (ENABLE_NODE, &clear_bgp_external_in_cmd);
9960 install_element (ENABLE_NODE, &clear_bgp_external_in_prefix_filter_cmd);
9961 install_element (ENABLE_NODE, &clear_bgp_as_soft_in_cmd);
9962 install_element (ENABLE_NODE, &clear_bgp_as_in_cmd);
9963 install_element (ENABLE_NODE, &clear_bgp_as_in_prefix_filter_cmd);
9964 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_in_cmd);
9965 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_cmd);
9966 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_prefix_filter_cmd);
9967 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_in_cmd);
9968 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_cmd);
9969 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_prefix_filter_cmd);
9970 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_in_cmd);
9971 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_cmd);
9972 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_prefix_filter_cmd);
9973 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_in_cmd);
9974 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_cmd);
9975 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_prefix_filter_cmd);
9976 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_in_cmd);
9977 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_cmd);
9978 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_prefix_filter_cmd);
9979#endif /* HAVE_IPV6 */
9980
9981 /* "clear ip bgp neighbor soft out" */
9982 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_out_cmd);
9983 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_out_cmd);
9984 install_element (ENABLE_NODE, &clear_ip_bgp_all_out_cmd);
9985 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_out_cmd);
9986 install_element (ENABLE_NODE, &clear_ip_bgp_peer_out_cmd);
9987 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_out_cmd);
9988 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_out_cmd);
9989 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_out_cmd);
9990 install_element (ENABLE_NODE, &clear_ip_bgp_external_out_cmd);
9991 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_out_cmd);
9992 install_element (ENABLE_NODE, &clear_ip_bgp_as_out_cmd);
9993 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_out_cmd);
9994 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_out_cmd);
9995 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_out_cmd);
9996 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_out_cmd);
9997 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_out_cmd);
9998 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_out_cmd);
9999 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_out_cmd);
10000 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_out_cmd);
10001 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_out_cmd);
10002 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_out_cmd);
10003 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_out_cmd);
10004 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_out_cmd);
10005 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_out_cmd);
10006 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_out_cmd);
10007 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_out_cmd);
10008 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_out_cmd);
10009 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_out_cmd);
10010#ifdef HAVE_IPV6
10011 install_element (ENABLE_NODE, &clear_bgp_all_soft_out_cmd);
10012 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_out_cmd);
10013 install_element (ENABLE_NODE, &clear_bgp_all_out_cmd);
10014 install_element (ENABLE_NODE, &clear_bgp_peer_soft_out_cmd);
10015 install_element (ENABLE_NODE, &clear_bgp_peer_out_cmd);
10016 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_out_cmd);
10017 install_element (ENABLE_NODE, &clear_bgp_peer_group_out_cmd);
10018 install_element (ENABLE_NODE, &clear_bgp_external_soft_out_cmd);
10019 install_element (ENABLE_NODE, &clear_bgp_external_out_cmd);
10020 install_element (ENABLE_NODE, &clear_bgp_as_soft_out_cmd);
10021 install_element (ENABLE_NODE, &clear_bgp_as_out_cmd);
10022 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_out_cmd);
10023 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_out_cmd);
10024 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_out_cmd);
10025 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_out_cmd);
10026 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_out_cmd);
10027 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_out_cmd);
10028 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_out_cmd);
10029 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_out_cmd);
10030 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_out_cmd);
10031 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_out_cmd);
10032#endif /* HAVE_IPV6 */
10033
10034 /* "clear ip bgp neighbor soft" */
10035 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_cmd);
10036 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_cmd);
10037 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_cmd);
10038 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_cmd);
10039 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_cmd);
10040 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_cmd);
10041 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_cmd);
10042 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_cmd);
10043 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_cmd);
10044 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_cmd);
10045 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_cmd);
10046 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_cmd);
10047 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_cmd);
10048 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_cmd);
10049 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_cmd);
10050#ifdef HAVE_IPV6
10051 install_element (ENABLE_NODE, &clear_bgp_all_soft_cmd);
10052 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_cmd);
10053 install_element (ENABLE_NODE, &clear_bgp_peer_soft_cmd);
10054 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_cmd);
10055 install_element (ENABLE_NODE, &clear_bgp_external_soft_cmd);
10056 install_element (ENABLE_NODE, &clear_bgp_as_soft_cmd);
10057 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_cmd);
10058 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_cmd);
10059 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_cmd);
10060 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_cmd);
10061 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_cmd);
10062#endif /* HAVE_IPV6 */
10063
paulfee0f4c2004-09-13 05:12:46 +000010064 /* "clear ip bgp neighbor rsclient" */
10065 install_element (ENABLE_NODE, &clear_ip_bgp_all_rsclient_cmd);
10066 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_rsclient_cmd);
10067 install_element (ENABLE_NODE, &clear_ip_bgp_peer_rsclient_cmd);
10068 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_rsclient_cmd);
10069#ifdef HAVE_IPV6
10070 install_element (ENABLE_NODE, &clear_bgp_all_rsclient_cmd);
10071 install_element (ENABLE_NODE, &clear_bgp_instance_all_rsclient_cmd);
10072 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_rsclient_cmd);
10073 install_element (ENABLE_NODE, &clear_bgp_ipv6_instance_all_rsclient_cmd);
10074 install_element (ENABLE_NODE, &clear_bgp_peer_rsclient_cmd);
10075 install_element (ENABLE_NODE, &clear_bgp_instance_peer_rsclient_cmd);
10076 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_rsclient_cmd);
10077 install_element (ENABLE_NODE, &clear_bgp_ipv6_instance_peer_rsclient_cmd);
10078#endif /* HAVE_IPV6 */
10079
paul718e3742002-12-13 20:15:29 +000010080 /* "show ip bgp summary" commands. */
10081 install_element (VIEW_NODE, &show_ip_bgp_summary_cmd);
10082 install_element (VIEW_NODE, &show_ip_bgp_instance_summary_cmd);
10083 install_element (VIEW_NODE, &show_ip_bgp_ipv4_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010084 install_element (VIEW_NODE, &show_bgp_ipv4_safi_summary_cmd);
paul718e3742002-12-13 20:15:29 +000010085 install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010086 install_element (VIEW_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
paul718e3742002-12-13 20:15:29 +000010087 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
10088 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
10089#ifdef HAVE_IPV6
10090 install_element (VIEW_NODE, &show_bgp_summary_cmd);
10091 install_element (VIEW_NODE, &show_bgp_instance_summary_cmd);
10092 install_element (VIEW_NODE, &show_bgp_ipv6_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010093 install_element (VIEW_NODE, &show_bgp_ipv6_safi_summary_cmd);
paul718e3742002-12-13 20:15:29 +000010094 install_element (VIEW_NODE, &show_bgp_instance_ipv6_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010095 install_element (VIEW_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
paul718e3742002-12-13 20:15:29 +000010096#endif /* HAVE_IPV6 */
Paul Jakma62687ff2008-08-23 14:27:06 +010010097 install_element (RESTRICTED_NODE, &show_ip_bgp_summary_cmd);
10098 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_summary_cmd);
10099 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010100 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_summary_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010010101 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010102 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010010103 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
10104 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
10105#ifdef HAVE_IPV6
10106 install_element (RESTRICTED_NODE, &show_bgp_summary_cmd);
10107 install_element (RESTRICTED_NODE, &show_bgp_instance_summary_cmd);
10108 install_element (RESTRICTED_NODE, &show_bgp_ipv6_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010109 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_summary_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010010110 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010111 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010010112#endif /* HAVE_IPV6 */
paul718e3742002-12-13 20:15:29 +000010113 install_element (ENABLE_NODE, &show_ip_bgp_summary_cmd);
10114 install_element (ENABLE_NODE, &show_ip_bgp_instance_summary_cmd);
10115 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010116 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_summary_cmd);
paul718e3742002-12-13 20:15:29 +000010117 install_element (ENABLE_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010118 install_element (ENABLE_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
paul718e3742002-12-13 20:15:29 +000010119 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
10120 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
10121#ifdef HAVE_IPV6
10122 install_element (ENABLE_NODE, &show_bgp_summary_cmd);
10123 install_element (ENABLE_NODE, &show_bgp_instance_summary_cmd);
10124 install_element (ENABLE_NODE, &show_bgp_ipv6_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010125 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_summary_cmd);
paul718e3742002-12-13 20:15:29 +000010126 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010127 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
paul718e3742002-12-13 20:15:29 +000010128#endif /* HAVE_IPV6 */
10129
10130 /* "show ip bgp neighbors" commands. */
10131 install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd);
10132 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
10133 install_element (VIEW_NODE, &show_ip_bgp_neighbors_peer_cmd);
10134 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
10135 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd);
10136 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd);
10137 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
10138 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
10139 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_cmd);
10140 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010010141 install_element (RESTRICTED_NODE, &show_ip_bgp_neighbors_peer_cmd);
10142 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
10143 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
10144 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
10145 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
paul718e3742002-12-13 20:15:29 +000010146 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_cmd);
10147 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
10148 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_peer_cmd);
10149 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
10150 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd);
10151 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd);
10152 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
10153 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
10154 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_cmd);
10155 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
10156
10157#ifdef HAVE_IPV6
10158 install_element (VIEW_NODE, &show_bgp_neighbors_cmd);
10159 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_cmd);
10160 install_element (VIEW_NODE, &show_bgp_neighbors_peer_cmd);
10161 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
paulbb46e942003-10-24 19:02:03 +000010162 install_element (VIEW_NODE, &show_bgp_instance_neighbors_cmd);
10163 install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
10164 install_element (VIEW_NODE, &show_bgp_instance_neighbors_peer_cmd);
10165 install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010010166 install_element (RESTRICTED_NODE, &show_bgp_neighbors_peer_cmd);
10167 install_element (RESTRICTED_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
10168 install_element (RESTRICTED_NODE, &show_bgp_instance_neighbors_peer_cmd);
10169 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
paul718e3742002-12-13 20:15:29 +000010170 install_element (ENABLE_NODE, &show_bgp_neighbors_cmd);
10171 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_cmd);
10172 install_element (ENABLE_NODE, &show_bgp_neighbors_peer_cmd);
10173 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
paulbb46e942003-10-24 19:02:03 +000010174 install_element (ENABLE_NODE, &show_bgp_instance_neighbors_cmd);
10175 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
10176 install_element (ENABLE_NODE, &show_bgp_instance_neighbors_peer_cmd);
10177 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
paul718e3742002-12-13 20:15:29 +000010178
10179 /* Old commands. */
10180 install_element (VIEW_NODE, &show_ipv6_bgp_summary_cmd);
10181 install_element (VIEW_NODE, &show_ipv6_mbgp_summary_cmd);
10182 install_element (ENABLE_NODE, &show_ipv6_bgp_summary_cmd);
10183 install_element (ENABLE_NODE, &show_ipv6_mbgp_summary_cmd);
10184#endif /* HAVE_IPV6 */
10185
paulfee0f4c2004-09-13 05:12:46 +000010186 /* "show ip bgp rsclient" commands. */
10187 install_element (VIEW_NODE, &show_ip_bgp_rsclient_summary_cmd);
10188 install_element (VIEW_NODE, &show_ip_bgp_instance_rsclient_summary_cmd);
10189 install_element (VIEW_NODE, &show_ip_bgp_ipv4_rsclient_summary_cmd);
10190 install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_rsclient_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010191 install_element (VIEW_NODE, &show_bgp_instance_ipv4_safi_rsclient_summary_cmd);
10192 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_summary_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010010193 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_summary_cmd);
10194 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_rsclient_summary_cmd);
10195 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_rsclient_summary_cmd);
10196 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_ipv4_rsclient_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010197 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv4_safi_rsclient_summary_cmd);
10198 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_summary_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010199 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_summary_cmd);
10200 install_element (ENABLE_NODE, &show_ip_bgp_instance_rsclient_summary_cmd);
10201 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_rsclient_summary_cmd);
10202 install_element (ENABLE_NODE, &show_ip_bgp_instance_ipv4_rsclient_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010203 install_element (ENABLE_NODE, &show_bgp_instance_ipv4_safi_rsclient_summary_cmd);
10204 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_summary_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010205
10206#ifdef HAVE_IPV6
10207 install_element (VIEW_NODE, &show_bgp_rsclient_summary_cmd);
10208 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_summary_cmd);
10209 install_element (VIEW_NODE, &show_bgp_instance_rsclient_summary_cmd);
10210 install_element (VIEW_NODE, &show_bgp_instance_ipv6_rsclient_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010211 install_element (VIEW_NODE, &show_bgp_instance_ipv6_safi_rsclient_summary_cmd);
10212 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_summary_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010010213 install_element (RESTRICTED_NODE, &show_bgp_rsclient_summary_cmd);
10214 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_summary_cmd);
10215 install_element (RESTRICTED_NODE, &show_bgp_instance_rsclient_summary_cmd);
10216 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_rsclient_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010217 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_safi_rsclient_summary_cmd);
10218 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_summary_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010219 install_element (ENABLE_NODE, &show_bgp_rsclient_summary_cmd);
10220 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_summary_cmd);
10221 install_element (ENABLE_NODE, &show_bgp_instance_rsclient_summary_cmd);
10222 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_rsclient_summary_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010223 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_safi_rsclient_summary_cmd);
10224 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_summary_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010225#endif /* HAVE_IPV6 */
10226
paul718e3742002-12-13 20:15:29 +000010227 /* "show ip bgp paths" commands. */
10228 install_element (VIEW_NODE, &show_ip_bgp_paths_cmd);
10229 install_element (VIEW_NODE, &show_ip_bgp_ipv4_paths_cmd);
10230 install_element (ENABLE_NODE, &show_ip_bgp_paths_cmd);
10231 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_paths_cmd);
10232
10233 /* "show ip bgp community" commands. */
10234 install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd);
10235 install_element (ENABLE_NODE, &show_ip_bgp_community_info_cmd);
10236
10237 /* "show ip bgp attribute-info" commands. */
10238 install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd);
10239 install_element (ENABLE_NODE, &show_ip_bgp_attr_info_cmd);
10240
10241 /* "redistribute" commands. */
10242 install_element (BGP_NODE, &bgp_redistribute_ipv4_cmd);
10243 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_cmd);
10244 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_cmd);
10245 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_cmd);
10246 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_cmd);
10247 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_cmd);
10248 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd);
10249 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd);
10250 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_metric_cmd);
10251 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_rmap_cmd);
10252#ifdef HAVE_IPV6
10253 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd);
10254 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd);
10255 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd);
10256 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_cmd);
10257 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd);
10258 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_cmd);
10259 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd);
10260 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd);
10261 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_metric_cmd);
10262 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_rmap_cmd);
10263#endif /* HAVE_IPV6 */
10264
Nick Hilliardfa411a22011-03-23 15:33:17 +000010265 /* ttl_security commands */
10266 install_element (BGP_NODE, &neighbor_ttl_security_cmd);
10267 install_element (BGP_NODE, &no_neighbor_ttl_security_cmd);
10268
Paul Jakma4bf6a362006-03-30 14:05:23 +000010269 /* "show bgp memory" commands. */
10270 install_element (VIEW_NODE, &show_bgp_memory_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010010271 install_element (RESTRICTED_NODE, &show_bgp_memory_cmd);
Paul Jakma4bf6a362006-03-30 14:05:23 +000010272 install_element (ENABLE_NODE, &show_bgp_memory_cmd);
10273
Michael Lamberte0081f72008-11-16 20:12:04 +000010274 /* "show bgp views" commands. */
10275 install_element (VIEW_NODE, &show_bgp_views_cmd);
10276 install_element (RESTRICTED_NODE, &show_bgp_views_cmd);
10277 install_element (ENABLE_NODE, &show_bgp_views_cmd);
10278
paul718e3742002-12-13 20:15:29 +000010279 /* Community-list. */
10280 community_list_vty ();
10281}
10282
10283#include "memory.h"
10284#include "bgp_regex.h"
10285#include "bgp_clist.h"
10286#include "bgp_ecommunity.h"
10287
10288/* VTY functions. */
10289
10290/* Direction value to string conversion. */
paul94f2b392005-06-28 12:44:16 +000010291static const char *
paul718e3742002-12-13 20:15:29 +000010292community_direct_str (int direct)
10293{
10294 switch (direct)
10295 {
10296 case COMMUNITY_DENY:
10297 return "deny";
paul718e3742002-12-13 20:15:29 +000010298 case COMMUNITY_PERMIT:
10299 return "permit";
paul718e3742002-12-13 20:15:29 +000010300 default:
10301 return "unknown";
paul718e3742002-12-13 20:15:29 +000010302 }
10303}
10304
10305/* Display error string. */
paul94f2b392005-06-28 12:44:16 +000010306static void
paul718e3742002-12-13 20:15:29 +000010307community_list_perror (struct vty *vty, int ret)
10308{
10309 switch (ret)
10310 {
10311 case COMMUNITY_LIST_ERR_CANT_FIND_LIST:
Denis Ovsienkob7292942010-12-08 18:51:37 +030010312 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000010313 break;
10314 case COMMUNITY_LIST_ERR_MALFORMED_VAL:
10315 vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE);
10316 break;
10317 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT:
10318 vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE);
10319 break;
10320 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT:
10321 vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE);
10322 break;
10323 }
10324}
10325
10326/* VTY interface for community_set() function. */
paul94f2b392005-06-28 12:44:16 +000010327static int
paulfd79ac92004-10-13 05:06:08 +000010328community_list_set_vty (struct vty *vty, int argc, const char **argv,
10329 int style, int reject_all_digit_name)
paul718e3742002-12-13 20:15:29 +000010330{
10331 int ret;
10332 int direct;
10333 char *str;
10334
10335 /* Check the list type. */
10336 if (strncmp (argv[1], "p", 1) == 0)
10337 direct = COMMUNITY_PERMIT;
10338 else if (strncmp (argv[1], "d", 1) == 0)
10339 direct = COMMUNITY_DENY;
10340 else
10341 {
10342 vty_out (vty, "%% Matching condition must be permit or deny%s",
10343 VTY_NEWLINE);
10344 return CMD_WARNING;
10345 }
10346
10347 /* All digit name check. */
10348 if (reject_all_digit_name && all_digit (argv[0]))
10349 {
10350 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
10351 return CMD_WARNING;
10352 }
10353
10354 /* Concat community string argument. */
10355 if (argc > 1)
10356 str = argv_concat (argv, argc, 2);
10357 else
10358 str = NULL;
10359
10360 /* When community_list_set() return nevetive value, it means
10361 malformed community string. */
10362 ret = community_list_set (bgp_clist, argv[0], str, direct, style);
10363
10364 /* Free temporary community list string allocated by
10365 argv_concat(). */
10366 if (str)
10367 XFREE (MTYPE_TMP, str);
10368
10369 if (ret < 0)
10370 {
10371 /* Display error string. */
10372 community_list_perror (vty, ret);
10373 return CMD_WARNING;
10374 }
10375
10376 return CMD_SUCCESS;
10377}
10378
paul718e3742002-12-13 20:15:29 +000010379/* Communiyt-list entry delete. */
paul94f2b392005-06-28 12:44:16 +000010380static int
hassofee6e4e2005-02-02 16:29:31 +000010381community_list_unset_vty (struct vty *vty, int argc, const char **argv,
10382 int style)
paul718e3742002-12-13 20:15:29 +000010383{
10384 int ret;
hassofee6e4e2005-02-02 16:29:31 +000010385 int direct = 0;
10386 char *str = NULL;
paul718e3742002-12-13 20:15:29 +000010387
hassofee6e4e2005-02-02 16:29:31 +000010388 if (argc > 1)
paul718e3742002-12-13 20:15:29 +000010389 {
hassofee6e4e2005-02-02 16:29:31 +000010390 /* Check the list direct. */
10391 if (strncmp (argv[1], "p", 1) == 0)
10392 direct = COMMUNITY_PERMIT;
10393 else if (strncmp (argv[1], "d", 1) == 0)
10394 direct = COMMUNITY_DENY;
10395 else
10396 {
10397 vty_out (vty, "%% Matching condition must be permit or deny%s",
10398 VTY_NEWLINE);
10399 return CMD_WARNING;
10400 }
paul718e3742002-12-13 20:15:29 +000010401
hassofee6e4e2005-02-02 16:29:31 +000010402 /* Concat community string argument. */
10403 str = argv_concat (argv, argc, 2);
10404 }
paul718e3742002-12-13 20:15:29 +000010405
10406 /* Unset community list. */
10407 ret = community_list_unset (bgp_clist, argv[0], str, direct, style);
10408
10409 /* Free temporary community list string allocated by
10410 argv_concat(). */
hassofee6e4e2005-02-02 16:29:31 +000010411 if (str)
10412 XFREE (MTYPE_TMP, str);
paul718e3742002-12-13 20:15:29 +000010413
10414 if (ret < 0)
10415 {
10416 community_list_perror (vty, ret);
10417 return CMD_WARNING;
10418 }
10419
10420 return CMD_SUCCESS;
10421}
10422
10423/* "community-list" keyword help string. */
10424#define COMMUNITY_LIST_STR "Add a community list entry\n"
10425#define COMMUNITY_VAL_STR "Community number in aa:nn format or internet|local-AS|no-advertise|no-export\n"
10426
paul718e3742002-12-13 20:15:29 +000010427DEFUN (ip_community_list_standard,
10428 ip_community_list_standard_cmd,
10429 "ip community-list <1-99> (deny|permit) .AA:NN",
10430 IP_STR
10431 COMMUNITY_LIST_STR
10432 "Community list number (standard)\n"
10433 "Specify community to reject\n"
10434 "Specify community to accept\n"
10435 COMMUNITY_VAL_STR)
10436{
10437 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
10438}
10439
10440ALIAS (ip_community_list_standard,
10441 ip_community_list_standard2_cmd,
10442 "ip community-list <1-99> (deny|permit)",
10443 IP_STR
10444 COMMUNITY_LIST_STR
10445 "Community list number (standard)\n"
10446 "Specify community to reject\n"
10447 "Specify community to accept\n")
10448
10449DEFUN (ip_community_list_expanded,
10450 ip_community_list_expanded_cmd,
hassofee6e4e2005-02-02 16:29:31 +000010451 "ip community-list <100-500> (deny|permit) .LINE",
paul718e3742002-12-13 20:15:29 +000010452 IP_STR
10453 COMMUNITY_LIST_STR
10454 "Community list number (expanded)\n"
10455 "Specify community to reject\n"
10456 "Specify community to accept\n"
10457 "An ordered list as a regular-expression\n")
10458{
10459 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
10460}
10461
10462DEFUN (ip_community_list_name_standard,
10463 ip_community_list_name_standard_cmd,
10464 "ip community-list standard WORD (deny|permit) .AA:NN",
10465 IP_STR
10466 COMMUNITY_LIST_STR
10467 "Add a standard community-list entry\n"
10468 "Community list name\n"
10469 "Specify community to reject\n"
10470 "Specify community to accept\n"
10471 COMMUNITY_VAL_STR)
10472{
10473 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
10474}
10475
10476ALIAS (ip_community_list_name_standard,
10477 ip_community_list_name_standard2_cmd,
10478 "ip community-list standard WORD (deny|permit)",
10479 IP_STR
10480 COMMUNITY_LIST_STR
10481 "Add a standard community-list entry\n"
10482 "Community list name\n"
10483 "Specify community to reject\n"
10484 "Specify community to accept\n")
10485
10486DEFUN (ip_community_list_name_expanded,
10487 ip_community_list_name_expanded_cmd,
10488 "ip community-list expanded WORD (deny|permit) .LINE",
10489 IP_STR
10490 COMMUNITY_LIST_STR
10491 "Add an expanded community-list entry\n"
10492 "Community list name\n"
10493 "Specify community to reject\n"
10494 "Specify community to accept\n"
10495 "An ordered list as a regular-expression\n")
10496{
10497 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
10498}
10499
hassofee6e4e2005-02-02 16:29:31 +000010500DEFUN (no_ip_community_list_standard_all,
10501 no_ip_community_list_standard_all_cmd,
10502 "no ip community-list <1-99>",
paul718e3742002-12-13 20:15:29 +000010503 NO_STR
10504 IP_STR
10505 COMMUNITY_LIST_STR
hassofee6e4e2005-02-02 16:29:31 +000010506 "Community list number (standard)\n")
paul718e3742002-12-13 20:15:29 +000010507{
hassofee6e4e2005-02-02 16:29:31 +000010508 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
paul718e3742002-12-13 20:15:29 +000010509}
10510
hassofee6e4e2005-02-02 16:29:31 +000010511DEFUN (no_ip_community_list_expanded_all,
10512 no_ip_community_list_expanded_all_cmd,
10513 "no ip community-list <100-500>",
10514 NO_STR
10515 IP_STR
10516 COMMUNITY_LIST_STR
10517 "Community list number (expanded)\n")
10518{
10519 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
10520}
10521
10522DEFUN (no_ip_community_list_name_standard_all,
10523 no_ip_community_list_name_standard_all_cmd,
10524 "no ip community-list standard WORD",
paul718e3742002-12-13 20:15:29 +000010525 NO_STR
10526 IP_STR
10527 COMMUNITY_LIST_STR
10528 "Add a standard community-list entry\n"
paul718e3742002-12-13 20:15:29 +000010529 "Community list name\n")
10530{
hassofee6e4e2005-02-02 16:29:31 +000010531 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
paul718e3742002-12-13 20:15:29 +000010532}
10533
hassofee6e4e2005-02-02 16:29:31 +000010534DEFUN (no_ip_community_list_name_expanded_all,
10535 no_ip_community_list_name_expanded_all_cmd,
10536 "no ip community-list expanded WORD",
paul718e3742002-12-13 20:15:29 +000010537 NO_STR
10538 IP_STR
10539 COMMUNITY_LIST_STR
hassofee6e4e2005-02-02 16:29:31 +000010540 "Add an expanded community-list entry\n"
10541 "Community list name\n")
paul718e3742002-12-13 20:15:29 +000010542{
hassofee6e4e2005-02-02 16:29:31 +000010543 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
paul718e3742002-12-13 20:15:29 +000010544}
10545
10546DEFUN (no_ip_community_list_standard,
10547 no_ip_community_list_standard_cmd,
10548 "no ip community-list <1-99> (deny|permit) .AA:NN",
10549 NO_STR
10550 IP_STR
10551 COMMUNITY_LIST_STR
10552 "Community list number (standard)\n"
10553 "Specify community to reject\n"
10554 "Specify community to accept\n"
10555 COMMUNITY_VAL_STR)
10556{
10557 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
10558}
10559
10560DEFUN (no_ip_community_list_expanded,
10561 no_ip_community_list_expanded_cmd,
hassofee6e4e2005-02-02 16:29:31 +000010562 "no ip community-list <100-500> (deny|permit) .LINE",
paul718e3742002-12-13 20:15:29 +000010563 NO_STR
10564 IP_STR
10565 COMMUNITY_LIST_STR
10566 "Community list number (expanded)\n"
10567 "Specify community to reject\n"
10568 "Specify community to accept\n"
10569 "An ordered list as a regular-expression\n")
10570{
10571 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
10572}
10573
10574DEFUN (no_ip_community_list_name_standard,
10575 no_ip_community_list_name_standard_cmd,
10576 "no ip community-list standard WORD (deny|permit) .AA:NN",
10577 NO_STR
10578 IP_STR
10579 COMMUNITY_LIST_STR
10580 "Specify a standard community-list\n"
10581 "Community list name\n"
10582 "Specify community to reject\n"
10583 "Specify community to accept\n"
10584 COMMUNITY_VAL_STR)
10585{
10586 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
10587}
10588
10589DEFUN (no_ip_community_list_name_expanded,
10590 no_ip_community_list_name_expanded_cmd,
10591 "no ip community-list expanded WORD (deny|permit) .LINE",
10592 NO_STR
10593 IP_STR
10594 COMMUNITY_LIST_STR
10595 "Specify an expanded community-list\n"
10596 "Community list name\n"
10597 "Specify community to reject\n"
10598 "Specify community to accept\n"
10599 "An ordered list as a regular-expression\n")
10600{
10601 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
10602}
10603
paul94f2b392005-06-28 12:44:16 +000010604static void
paul718e3742002-12-13 20:15:29 +000010605community_list_show (struct vty *vty, struct community_list *list)
10606{
10607 struct community_entry *entry;
10608
10609 for (entry = list->head; entry; entry = entry->next)
10610 {
10611 if (entry == list->head)
10612 {
10613 if (all_digit (list->name))
10614 vty_out (vty, "Community %s list %s%s",
10615 entry->style == COMMUNITY_LIST_STANDARD ?
10616 "standard" : "(expanded) access",
10617 list->name, VTY_NEWLINE);
10618 else
10619 vty_out (vty, "Named Community %s list %s%s",
10620 entry->style == COMMUNITY_LIST_STANDARD ?
10621 "standard" : "expanded",
10622 list->name, VTY_NEWLINE);
10623 }
10624 if (entry->any)
10625 vty_out (vty, " %s%s",
10626 community_direct_str (entry->direct), VTY_NEWLINE);
10627 else
10628 vty_out (vty, " %s %s%s",
10629 community_direct_str (entry->direct),
10630 entry->style == COMMUNITY_LIST_STANDARD
10631 ? community_str (entry->u.com) : entry->config,
10632 VTY_NEWLINE);
10633 }
10634}
10635
10636DEFUN (show_ip_community_list,
10637 show_ip_community_list_cmd,
10638 "show ip community-list",
10639 SHOW_STR
10640 IP_STR
10641 "List community-list\n")
10642{
10643 struct community_list *list;
10644 struct community_list_master *cm;
10645
hassofee6e4e2005-02-02 16:29:31 +000010646 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010647 if (! cm)
10648 return CMD_SUCCESS;
10649
10650 for (list = cm->num.head; list; list = list->next)
10651 community_list_show (vty, list);
10652
10653 for (list = cm->str.head; list; list = list->next)
10654 community_list_show (vty, list);
10655
10656 return CMD_SUCCESS;
10657}
10658
10659DEFUN (show_ip_community_list_arg,
10660 show_ip_community_list_arg_cmd,
hassofee6e4e2005-02-02 16:29:31 +000010661 "show ip community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000010662 SHOW_STR
10663 IP_STR
10664 "List community-list\n"
10665 "Community-list number\n"
10666 "Community-list name\n")
10667{
10668 struct community_list *list;
10669
hassofee6e4e2005-02-02 16:29:31 +000010670 list = community_list_lookup (bgp_clist, argv[0], COMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010671 if (! list)
10672 {
Denis Ovsienkob7292942010-12-08 18:51:37 +030010673 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000010674 return CMD_WARNING;
10675 }
10676
10677 community_list_show (vty, list);
10678
10679 return CMD_SUCCESS;
10680}
10681
paul94f2b392005-06-28 12:44:16 +000010682static int
paulfd79ac92004-10-13 05:06:08 +000010683extcommunity_list_set_vty (struct vty *vty, int argc, const char **argv,
10684 int style, int reject_all_digit_name)
paul718e3742002-12-13 20:15:29 +000010685{
10686 int ret;
10687 int direct;
10688 char *str;
10689
10690 /* Check the list type. */
10691 if (strncmp (argv[1], "p", 1) == 0)
10692 direct = COMMUNITY_PERMIT;
10693 else if (strncmp (argv[1], "d", 1) == 0)
10694 direct = COMMUNITY_DENY;
10695 else
10696 {
10697 vty_out (vty, "%% Matching condition must be permit or deny%s",
10698 VTY_NEWLINE);
10699 return CMD_WARNING;
10700 }
10701
10702 /* All digit name check. */
10703 if (reject_all_digit_name && all_digit (argv[0]))
10704 {
10705 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
10706 return CMD_WARNING;
10707 }
10708
10709 /* Concat community string argument. */
10710 if (argc > 1)
10711 str = argv_concat (argv, argc, 2);
10712 else
10713 str = NULL;
10714
10715 ret = extcommunity_list_set (bgp_clist, argv[0], str, direct, style);
10716
10717 /* Free temporary community list string allocated by
10718 argv_concat(). */
10719 if (str)
10720 XFREE (MTYPE_TMP, str);
10721
10722 if (ret < 0)
10723 {
10724 community_list_perror (vty, ret);
10725 return CMD_WARNING;
10726 }
10727 return CMD_SUCCESS;
10728}
10729
paul94f2b392005-06-28 12:44:16 +000010730static int
hassofee6e4e2005-02-02 16:29:31 +000010731extcommunity_list_unset_vty (struct vty *vty, int argc, const char **argv,
10732 int style)
paul718e3742002-12-13 20:15:29 +000010733{
10734 int ret;
hassofee6e4e2005-02-02 16:29:31 +000010735 int direct = 0;
10736 char *str = NULL;
paul718e3742002-12-13 20:15:29 +000010737
hassofee6e4e2005-02-02 16:29:31 +000010738 if (argc > 1)
paul718e3742002-12-13 20:15:29 +000010739 {
hassofee6e4e2005-02-02 16:29:31 +000010740 /* Check the list direct. */
10741 if (strncmp (argv[1], "p", 1) == 0)
10742 direct = COMMUNITY_PERMIT;
10743 else if (strncmp (argv[1], "d", 1) == 0)
10744 direct = COMMUNITY_DENY;
10745 else
10746 {
10747 vty_out (vty, "%% Matching condition must be permit or deny%s",
10748 VTY_NEWLINE);
10749 return CMD_WARNING;
10750 }
10751
10752 /* Concat community string argument. */
10753 str = argv_concat (argv, argc, 2);
paul718e3742002-12-13 20:15:29 +000010754 }
paul718e3742002-12-13 20:15:29 +000010755
10756 /* Unset community list. */
10757 ret = extcommunity_list_unset (bgp_clist, argv[0], str, direct, style);
10758
10759 /* Free temporary community list string allocated by
10760 argv_concat(). */
hassofee6e4e2005-02-02 16:29:31 +000010761 if (str)
10762 XFREE (MTYPE_TMP, str);
paul718e3742002-12-13 20:15:29 +000010763
10764 if (ret < 0)
10765 {
10766 community_list_perror (vty, ret);
10767 return CMD_WARNING;
10768 }
10769
10770 return CMD_SUCCESS;
10771}
10772
10773/* "extcommunity-list" keyword help string. */
10774#define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
10775#define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
10776
10777DEFUN (ip_extcommunity_list_standard,
10778 ip_extcommunity_list_standard_cmd,
10779 "ip extcommunity-list <1-99> (deny|permit) .AA:NN",
10780 IP_STR
10781 EXTCOMMUNITY_LIST_STR
10782 "Extended Community list number (standard)\n"
10783 "Specify community to reject\n"
10784 "Specify community to accept\n"
10785 EXTCOMMUNITY_VAL_STR)
10786{
10787 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
10788}
10789
10790ALIAS (ip_extcommunity_list_standard,
10791 ip_extcommunity_list_standard2_cmd,
10792 "ip extcommunity-list <1-99> (deny|permit)",
10793 IP_STR
10794 EXTCOMMUNITY_LIST_STR
10795 "Extended Community list number (standard)\n"
10796 "Specify community to reject\n"
10797 "Specify community to accept\n")
10798
10799DEFUN (ip_extcommunity_list_expanded,
10800 ip_extcommunity_list_expanded_cmd,
hassofee6e4e2005-02-02 16:29:31 +000010801 "ip extcommunity-list <100-500> (deny|permit) .LINE",
paul718e3742002-12-13 20:15:29 +000010802 IP_STR
10803 EXTCOMMUNITY_LIST_STR
10804 "Extended Community list number (expanded)\n"
10805 "Specify community to reject\n"
10806 "Specify community to accept\n"
10807 "An ordered list as a regular-expression\n")
10808{
10809 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
10810}
10811
10812DEFUN (ip_extcommunity_list_name_standard,
10813 ip_extcommunity_list_name_standard_cmd,
10814 "ip extcommunity-list standard WORD (deny|permit) .AA:NN",
10815 IP_STR
10816 EXTCOMMUNITY_LIST_STR
10817 "Specify standard extcommunity-list\n"
10818 "Extended Community list name\n"
10819 "Specify community to reject\n"
10820 "Specify community to accept\n"
10821 EXTCOMMUNITY_VAL_STR)
10822{
10823 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
10824}
10825
10826ALIAS (ip_extcommunity_list_name_standard,
10827 ip_extcommunity_list_name_standard2_cmd,
10828 "ip extcommunity-list standard WORD (deny|permit)",
10829 IP_STR
10830 EXTCOMMUNITY_LIST_STR
10831 "Specify standard extcommunity-list\n"
10832 "Extended Community list name\n"
10833 "Specify community to reject\n"
10834 "Specify community to accept\n")
10835
10836DEFUN (ip_extcommunity_list_name_expanded,
10837 ip_extcommunity_list_name_expanded_cmd,
10838 "ip extcommunity-list expanded WORD (deny|permit) .LINE",
10839 IP_STR
10840 EXTCOMMUNITY_LIST_STR
10841 "Specify expanded extcommunity-list\n"
10842 "Extended Community list name\n"
10843 "Specify community to reject\n"
10844 "Specify community to accept\n"
10845 "An ordered list as a regular-expression\n")
10846{
10847 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
10848}
10849
hassofee6e4e2005-02-02 16:29:31 +000010850DEFUN (no_ip_extcommunity_list_standard_all,
10851 no_ip_extcommunity_list_standard_all_cmd,
10852 "no ip extcommunity-list <1-99>",
paul718e3742002-12-13 20:15:29 +000010853 NO_STR
10854 IP_STR
10855 EXTCOMMUNITY_LIST_STR
hassofee6e4e2005-02-02 16:29:31 +000010856 "Extended Community list number (standard)\n")
paul718e3742002-12-13 20:15:29 +000010857{
hassofee6e4e2005-02-02 16:29:31 +000010858 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
paul718e3742002-12-13 20:15:29 +000010859}
10860
hassofee6e4e2005-02-02 16:29:31 +000010861DEFUN (no_ip_extcommunity_list_expanded_all,
10862 no_ip_extcommunity_list_expanded_all_cmd,
10863 "no ip extcommunity-list <100-500>",
10864 NO_STR
10865 IP_STR
10866 EXTCOMMUNITY_LIST_STR
10867 "Extended Community list number (expanded)\n")
10868{
10869 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
10870}
10871
10872DEFUN (no_ip_extcommunity_list_name_standard_all,
10873 no_ip_extcommunity_list_name_standard_all_cmd,
10874 "no ip extcommunity-list standard WORD",
paul718e3742002-12-13 20:15:29 +000010875 NO_STR
10876 IP_STR
10877 EXTCOMMUNITY_LIST_STR
10878 "Specify standard extcommunity-list\n"
hassofee6e4e2005-02-02 16:29:31 +000010879 "Extended Community list name\n")
10880{
10881 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
10882}
10883
10884DEFUN (no_ip_extcommunity_list_name_expanded_all,
10885 no_ip_extcommunity_list_name_expanded_all_cmd,
10886 "no ip extcommunity-list expanded WORD",
10887 NO_STR
10888 IP_STR
10889 EXTCOMMUNITY_LIST_STR
paul718e3742002-12-13 20:15:29 +000010890 "Specify expanded extcommunity-list\n"
10891 "Extended Community list name\n")
10892{
hassofee6e4e2005-02-02 16:29:31 +000010893 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
paul718e3742002-12-13 20:15:29 +000010894}
10895
10896DEFUN (no_ip_extcommunity_list_standard,
10897 no_ip_extcommunity_list_standard_cmd,
10898 "no ip extcommunity-list <1-99> (deny|permit) .AA:NN",
10899 NO_STR
10900 IP_STR
10901 EXTCOMMUNITY_LIST_STR
10902 "Extended Community list number (standard)\n"
10903 "Specify community to reject\n"
10904 "Specify community to accept\n"
10905 EXTCOMMUNITY_VAL_STR)
10906{
10907 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
10908}
10909
10910DEFUN (no_ip_extcommunity_list_expanded,
10911 no_ip_extcommunity_list_expanded_cmd,
hassofee6e4e2005-02-02 16:29:31 +000010912 "no ip extcommunity-list <100-500> (deny|permit) .LINE",
paul718e3742002-12-13 20:15:29 +000010913 NO_STR
10914 IP_STR
10915 EXTCOMMUNITY_LIST_STR
10916 "Extended Community list number (expanded)\n"
10917 "Specify community to reject\n"
10918 "Specify community to accept\n"
10919 "An ordered list as a regular-expression\n")
10920{
10921 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
10922}
10923
10924DEFUN (no_ip_extcommunity_list_name_standard,
10925 no_ip_extcommunity_list_name_standard_cmd,
10926 "no ip extcommunity-list standard WORD (deny|permit) .AA:NN",
10927 NO_STR
10928 IP_STR
10929 EXTCOMMUNITY_LIST_STR
10930 "Specify standard extcommunity-list\n"
10931 "Extended Community list name\n"
10932 "Specify community to reject\n"
10933 "Specify community to accept\n"
10934 EXTCOMMUNITY_VAL_STR)
10935{
10936 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
10937}
10938
10939DEFUN (no_ip_extcommunity_list_name_expanded,
10940 no_ip_extcommunity_list_name_expanded_cmd,
10941 "no ip extcommunity-list expanded WORD (deny|permit) .LINE",
10942 NO_STR
10943 IP_STR
10944 EXTCOMMUNITY_LIST_STR
10945 "Specify expanded extcommunity-list\n"
10946 "Community list name\n"
10947 "Specify community to reject\n"
10948 "Specify community to accept\n"
10949 "An ordered list as a regular-expression\n")
10950{
10951 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
10952}
10953
paul94f2b392005-06-28 12:44:16 +000010954static void
paul718e3742002-12-13 20:15:29 +000010955extcommunity_list_show (struct vty *vty, struct community_list *list)
10956{
10957 struct community_entry *entry;
10958
10959 for (entry = list->head; entry; entry = entry->next)
10960 {
10961 if (entry == list->head)
10962 {
10963 if (all_digit (list->name))
10964 vty_out (vty, "Extended community %s list %s%s",
10965 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
10966 "standard" : "(expanded) access",
10967 list->name, VTY_NEWLINE);
10968 else
10969 vty_out (vty, "Named extended community %s list %s%s",
10970 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
10971 "standard" : "expanded",
10972 list->name, VTY_NEWLINE);
10973 }
10974 if (entry->any)
10975 vty_out (vty, " %s%s",
10976 community_direct_str (entry->direct), VTY_NEWLINE);
10977 else
10978 vty_out (vty, " %s %s%s",
10979 community_direct_str (entry->direct),
10980 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
10981 entry->u.ecom->str : entry->config,
10982 VTY_NEWLINE);
10983 }
10984}
10985
10986DEFUN (show_ip_extcommunity_list,
10987 show_ip_extcommunity_list_cmd,
10988 "show ip extcommunity-list",
10989 SHOW_STR
10990 IP_STR
10991 "List extended-community list\n")
10992{
10993 struct community_list *list;
10994 struct community_list_master *cm;
10995
hassofee6e4e2005-02-02 16:29:31 +000010996 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010997 if (! cm)
10998 return CMD_SUCCESS;
10999
11000 for (list = cm->num.head; list; list = list->next)
11001 extcommunity_list_show (vty, list);
11002
11003 for (list = cm->str.head; list; list = list->next)
11004 extcommunity_list_show (vty, list);
11005
11006 return CMD_SUCCESS;
11007}
11008
11009DEFUN (show_ip_extcommunity_list_arg,
11010 show_ip_extcommunity_list_arg_cmd,
hassofee6e4e2005-02-02 16:29:31 +000011011 "show ip extcommunity-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000011012 SHOW_STR
11013 IP_STR
11014 "List extended-community list\n"
11015 "Extcommunity-list number\n"
11016 "Extcommunity-list name\n")
11017{
11018 struct community_list *list;
11019
hassofee6e4e2005-02-02 16:29:31 +000011020 list = community_list_lookup (bgp_clist, argv[0], EXTCOMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000011021 if (! list)
11022 {
Denis Ovsienkob7292942010-12-08 18:51:37 +030011023 vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000011024 return CMD_WARNING;
11025 }
11026
11027 extcommunity_list_show (vty, list);
11028
11029 return CMD_SUCCESS;
11030}
11031
11032/* Return configuration string of community-list entry. */
paulfd79ac92004-10-13 05:06:08 +000011033static const char *
paul718e3742002-12-13 20:15:29 +000011034community_list_config_str (struct community_entry *entry)
11035{
paulfd79ac92004-10-13 05:06:08 +000011036 const char *str;
paul718e3742002-12-13 20:15:29 +000011037
11038 if (entry->any)
11039 str = "";
11040 else
11041 {
11042 if (entry->style == COMMUNITY_LIST_STANDARD)
11043 str = community_str (entry->u.com);
11044 else
11045 str = entry->config;
11046 }
11047 return str;
11048}
11049
11050/* Display community-list and extcommunity-list configuration. */
paul94f2b392005-06-28 12:44:16 +000011051static int
paul718e3742002-12-13 20:15:29 +000011052community_list_config_write (struct vty *vty)
11053{
11054 struct community_list *list;
11055 struct community_entry *entry;
11056 struct community_list_master *cm;
11057 int write = 0;
11058
11059 /* Community-list. */
hassofee6e4e2005-02-02 16:29:31 +000011060 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000011061
11062 for (list = cm->num.head; list; list = list->next)
11063 for (entry = list->head; entry; entry = entry->next)
11064 {
hassofee6e4e2005-02-02 16:29:31 +000011065 vty_out (vty, "ip community-list %s %s %s%s",
11066 list->name, community_direct_str (entry->direct),
11067 community_list_config_str (entry),
11068 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000011069 write++;
11070 }
11071 for (list = cm->str.head; list; list = list->next)
11072 for (entry = list->head; entry; entry = entry->next)
11073 {
11074 vty_out (vty, "ip community-list %s %s %s %s%s",
11075 entry->style == COMMUNITY_LIST_STANDARD
11076 ? "standard" : "expanded",
11077 list->name, community_direct_str (entry->direct),
11078 community_list_config_str (entry),
11079 VTY_NEWLINE);
11080 write++;
11081 }
11082
11083 /* Extcommunity-list. */
hassofee6e4e2005-02-02 16:29:31 +000011084 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000011085
11086 for (list = cm->num.head; list; list = list->next)
11087 for (entry = list->head; entry; entry = entry->next)
11088 {
hassofee6e4e2005-02-02 16:29:31 +000011089 vty_out (vty, "ip extcommunity-list %s %s %s%s",
11090 list->name, community_direct_str (entry->direct),
11091 community_list_config_str (entry), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000011092 write++;
11093 }
11094 for (list = cm->str.head; list; list = list->next)
11095 for (entry = list->head; entry; entry = entry->next)
11096 {
11097 vty_out (vty, "ip extcommunity-list %s %s %s %s%s",
11098 entry->style == EXTCOMMUNITY_LIST_STANDARD
11099 ? "standard" : "expanded",
11100 list->name, community_direct_str (entry->direct),
11101 community_list_config_str (entry), VTY_NEWLINE);
11102 write++;
11103 }
11104 return write;
11105}
11106
Stephen Hemminger7fc626d2008-12-01 11:10:34 -080011107static struct cmd_node community_list_node =
paul718e3742002-12-13 20:15:29 +000011108{
11109 COMMUNITY_LIST_NODE,
11110 "",
11111 1 /* Export to vtysh. */
11112};
11113
paul94f2b392005-06-28 12:44:16 +000011114static void
11115community_list_vty (void)
paul718e3742002-12-13 20:15:29 +000011116{
11117 install_node (&community_list_node, community_list_config_write);
11118
11119 /* Community-list. */
paul718e3742002-12-13 20:15:29 +000011120 install_element (CONFIG_NODE, &ip_community_list_standard_cmd);
11121 install_element (CONFIG_NODE, &ip_community_list_standard2_cmd);
11122 install_element (CONFIG_NODE, &ip_community_list_expanded_cmd);
11123 install_element (CONFIG_NODE, &ip_community_list_name_standard_cmd);
11124 install_element (CONFIG_NODE, &ip_community_list_name_standard2_cmd);
11125 install_element (CONFIG_NODE, &ip_community_list_name_expanded_cmd);
hassofee6e4e2005-02-02 16:29:31 +000011126 install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd);
11127 install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd);
11128 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_all_cmd);
11129 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_all_cmd);
paul718e3742002-12-13 20:15:29 +000011130 install_element (CONFIG_NODE, &no_ip_community_list_standard_cmd);
11131 install_element (CONFIG_NODE, &no_ip_community_list_expanded_cmd);
11132 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_cmd);
11133 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_cmd);
11134 install_element (VIEW_NODE, &show_ip_community_list_cmd);
11135 install_element (VIEW_NODE, &show_ip_community_list_arg_cmd);
11136 install_element (ENABLE_NODE, &show_ip_community_list_cmd);
11137 install_element (ENABLE_NODE, &show_ip_community_list_arg_cmd);
11138
11139 /* Extcommunity-list. */
11140 install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd);
11141 install_element (CONFIG_NODE, &ip_extcommunity_list_standard2_cmd);
11142 install_element (CONFIG_NODE, &ip_extcommunity_list_expanded_cmd);
11143 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard_cmd);
11144 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard2_cmd);
11145 install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd);
hassofee6e4e2005-02-02 16:29:31 +000011146 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd);
11147 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd);
11148 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_all_cmd);
11149 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_all_cmd);
paul718e3742002-12-13 20:15:29 +000011150 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_cmd);
11151 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_cmd);
11152 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_cmd);
11153 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_cmd);
11154 install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd);
11155 install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd);
11156 install_element (ENABLE_NODE, &show_ip_extcommunity_list_cmd);
11157 install_element (ENABLE_NODE, &show_ip_extcommunity_list_arg_cmd);
11158}