New upstream version 1.2.3
[quagga-debian.git] / bgpd / bgp_vty.c
1 /* BGP VTY interface.
2    Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
3
4 This file is part of GNU Zebra.
5
6 GNU Zebra is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
9 later version.
10
11 GNU Zebra is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU Zebra; see the file COPYING.  If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 02111-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"
31 #include "memory.h"
32 #include "hash.h"
33 #include "filter.h"
34
35 #include "bgpd/bgpd.h"
36 #include "bgpd/bgp_advertise.h"
37 #include "bgpd/bgp_attr.h"
38 #include "bgpd/bgp_aspath.h"
39 #include "bgpd/bgp_community.h"
40 #include "bgpd/bgp_ecommunity.h"
41 #include "bgpd/bgp_lcommunity.h"
42 #include "bgpd/bgp_damp.h"
43 #include "bgpd/bgp_debug.h"
44 #include "bgpd/bgp_fsm.h"
45 #include "bgpd/bgp_mplsvpn.h"
46 #include "bgpd/bgp_nexthop.h"
47 #include "bgpd/bgp_open.h"
48 #include "bgpd/bgp_regex.h"
49 #include "bgpd/bgp_route.h"
50 #include "bgpd/bgp_zebra.h"
51 #include "bgpd/bgp_table.h"
52 #include "bgpd/bgp_vty.h"
53 #include "bgpd/bgp_mpath.h"
54
55 /* Utility function to get address family from current node.  */
56 afi_t
57 bgp_node_afi (struct vty *vty)
58 {
59   afi_t afi;
60   switch (vty->node)
61     {
62     case BGP_IPV6_NODE:
63     case BGP_IPV6M_NODE:
64     case BGP_VPNV6_NODE:
65     case BGP_ENCAPV6_NODE:
66       afi = AFI_IP6;
67       break;
68     default:
69       afi = AFI_IP;
70       break;
71     }
72   return afi;
73 }
74
75 /* Utility function to get subsequent address family from current
76    node.  */
77 safi_t
78 bgp_node_safi (struct vty *vty)
79 {
80   safi_t safi;
81   switch (vty->node)
82     {
83     case BGP_ENCAP_NODE:
84     case BGP_ENCAPV6_NODE:
85       safi = SAFI_ENCAP;
86       break;
87     case BGP_VPNV4_NODE:
88     case BGP_VPNV6_NODE:
89       safi = SAFI_MPLS_VPN;
90       break;
91     case BGP_IPV4M_NODE:
92     case BGP_IPV6M_NODE:
93       safi = SAFI_MULTICAST;
94       break;
95     default:
96       safi = SAFI_UNICAST;
97       break;
98   }
99   return safi;
100 }
101
102 int
103 bgp_parse_afi(const char *str, afi_t *afi)
104 {
105     if (!strcmp(str, "ipv4")) {
106         *afi = AFI_IP;
107         return 0;
108     }
109     if (!strcmp(str, "ipv6")) {
110         *afi = AFI_IP6;
111         return 0;
112     }
113     return -1;
114 }
115
116 int
117 bgp_parse_safi(const char *str, safi_t *safi)
118 {
119     if (!strcmp(str, "encap")) {
120         *safi = SAFI_ENCAP;
121         return 0;
122     }
123     if (!strcmp(str, "multicast")) {
124         *safi =  SAFI_MULTICAST;
125         return 0;
126     }
127     if (!strcmp(str, "unicast")) {
128         *safi =  SAFI_UNICAST;
129         return 0;
130     }
131     if (!strcmp(str, "vpn")) {
132         *safi =  SAFI_MPLS_VPN;
133         return 0;
134     }
135     return -1;
136 }
137
138 static int
139 peer_address_self_check (union sockunion *su)
140 {
141   struct interface *ifp = NULL;
142
143   if (su->sa.sa_family == AF_INET)
144     ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr);
145   else if (su->sa.sa_family == AF_INET6)
146     ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr);
147
148   if (ifp)
149     return 1;
150
151   return 0;
152 }
153
154 /* Utility function for looking up peer from VTY.  */
155 static struct peer *
156 peer_lookup_vty (struct vty *vty, const char *ip_str)
157 {
158   int ret;
159   struct bgp *bgp;
160   union sockunion su;
161   struct peer *peer;
162
163   bgp = vty->index;
164
165   ret = str2sockunion (ip_str, &su);
166   if (ret < 0)
167     {
168       vty_out (vty, "%% Malformed address: %s%s", ip_str, VTY_NEWLINE);
169       return NULL;
170     }
171
172   peer = peer_lookup (bgp, &su);
173   if (! peer)
174     {
175       vty_out (vty, "%% Specify remote-as or peer-group commands first%s", VTY_NEWLINE);
176       return NULL;
177     }
178   return peer;
179 }
180
181 /* Utility function for looking up peer or peer group.  */
182 static struct peer *
183 peer_and_group_lookup_vty (struct vty *vty, const char *peer_str)
184 {
185   int ret;
186   struct bgp *bgp;
187   union sockunion su;
188   struct peer *peer;
189   struct peer_group *group;
190
191   bgp = vty->index;
192
193   ret = str2sockunion (peer_str, &su);
194   if (ret == 0)
195     {
196       peer = peer_lookup (bgp, &su);
197       if (peer)
198         return peer;
199     }
200   else
201     {
202       group = peer_group_lookup (bgp, peer_str);
203       if (group)
204         return group->conf;
205     }
206
207   vty_out (vty, "%% Specify remote-as or peer-group commands first%s",
208            VTY_NEWLINE);
209
210   return NULL;
211 }
212
213 static int
214 bgp_vty_return (struct vty *vty, int ret)
215 {
216   const char *str = NULL;
217
218   switch (ret)
219     {
220     case BGP_ERR_INVALID_VALUE:
221       str = "Invalid value";
222       break;
223     case BGP_ERR_INVALID_FLAG:
224       str = "Invalid flag";
225       break;
226     case BGP_ERR_PEER_INACTIVE:
227       str = "Activate the neighbor for the address family first";
228       break;
229     case BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER:
230       str = "Invalid command for a peer-group member";
231       break;
232     case BGP_ERR_PEER_GROUP_SHUTDOWN:
233       str = "Peer-group has been shutdown. Activate the peer-group first";
234       break;
235     case BGP_ERR_PEER_GROUP_HAS_THE_FLAG:
236       str = "This peer is a peer-group member.  Please change peer-group configuration";
237       break;
238     case BGP_ERR_PEER_FLAG_CONFLICT:
239       str = "Can't set override-capability and strict-capability-match at the same time";
240       break;
241     case BGP_ERR_PEER_GROUP_MEMBER_EXISTS:
242       str = "No activate for peergroup can be given only if peer-group has no members";
243       break;
244     case BGP_ERR_PEER_BELONGS_TO_GROUP:
245       str = "No activate for an individual peer-group member is invalid";
246       break;
247     case BGP_ERR_PEER_GROUP_AF_UNCONFIGURED:
248       str = "Activate the peer-group for the address family first";
249       break;
250     case BGP_ERR_PEER_GROUP_NO_REMOTE_AS:
251       str = "Specify remote-as or peer-group remote AS first";
252       break;
253     case BGP_ERR_PEER_GROUP_CANT_CHANGE:
254       str = "Cannot change the peer-group. Deconfigure first";
255       break;
256     case BGP_ERR_PEER_GROUP_MISMATCH:
257       str = "Cannot have different peer-group for the neighbor";
258       break;
259     case BGP_ERR_PEER_FILTER_CONFLICT:
260       str = "Prefix/distribute list can not co-exist";
261       break;
262     case BGP_ERR_NOT_INTERNAL_PEER:
263       str = "Invalid command. Not an internal neighbor";
264       break;
265     case BGP_ERR_REMOVE_PRIVATE_AS:
266       str = "Private AS cannot be removed for IBGP peers";
267       break;
268     case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP:
269       str = "Local-AS allowed only for EBGP peers";
270       break;
271     case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS:
272       str = "Cannot have local-as same as BGP AS number";
273       break;
274     case BGP_ERR_TCPSIG_FAILED:
275       str = "Error while applying TCP-Sig to session(s)";
276       break;
277     case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK:
278       str = "ebgp-multihop and ttl-security cannot be configured together";
279       break;
280     case BGP_ERR_NO_IBGP_WITH_TTLHACK:
281       str = "ttl-security only allowed for EBGP peers";
282       break;
283     }
284   if (str)
285     {
286       vty_out (vty, "%% %s%s", str, VTY_NEWLINE);
287       return CMD_WARNING;
288     }
289   return CMD_SUCCESS;
290 }
291
292 /* BGP global configuration.  */
293
294 DEFUN (bgp_multiple_instance_func,
295        bgp_multiple_instance_cmd,
296        "bgp multiple-instance",
297        BGP_STR
298        "Enable bgp multiple instance\n")
299 {
300   bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE);
301   return CMD_SUCCESS;
302 }
303
304 DEFUN (no_bgp_multiple_instance,
305        no_bgp_multiple_instance_cmd,
306        "no bgp multiple-instance",
307        NO_STR
308        BGP_STR
309        "BGP multiple instance\n")
310 {
311   int ret;
312
313   ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE);
314   if (ret < 0)
315     {
316       vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE);
317       return CMD_WARNING;
318     }
319   return CMD_SUCCESS;
320 }
321
322 DEFUN (bgp_config_type,
323        bgp_config_type_cmd,
324        "bgp config-type (cisco|zebra)",
325        BGP_STR
326        "Configuration type\n"
327        "cisco\n"
328        "zebra\n")
329 {
330   if (strncmp (argv[0], "c", 1) == 0)
331     bgp_option_set (BGP_OPT_CONFIG_CISCO);
332   else
333     bgp_option_unset (BGP_OPT_CONFIG_CISCO);
334
335   return CMD_SUCCESS;
336 }
337
338 DEFUN (no_bgp_config_type,
339        no_bgp_config_type_cmd,
340        "no bgp config-type",
341        NO_STR
342        BGP_STR
343        "Display configuration type\n")
344 {
345   bgp_option_unset (BGP_OPT_CONFIG_CISCO);
346   return CMD_SUCCESS;
347 }
348
349 DEFUN (no_synchronization,
350        no_synchronization_cmd,
351        "no synchronization",
352        NO_STR
353        "Perform IGP synchronization\n")
354 {
355   return CMD_SUCCESS;
356 }
357
358 DEFUN (no_auto_summary,
359        no_auto_summary_cmd,
360        "no auto-summary",
361        NO_STR
362        "Enable automatic network number summarization\n")
363 {
364   return CMD_SUCCESS;
365 }
366
367 DEFUN_DEPRECATED (neighbor_version,
368                   neighbor_version_cmd,
369                   NEIGHBOR_CMD "version (4|4-)",
370                   NEIGHBOR_STR
371                   NEIGHBOR_ADDR_STR
372                   "Set the BGP version to match a neighbor\n"
373                   "Neighbor's BGP version\n")
374 {
375   return CMD_SUCCESS;
376 }
377
378 /* "router bgp" commands. */
379 DEFUN (router_bgp, 
380        router_bgp_cmd, 
381        "router bgp " CMD_AS_RANGE,
382        ROUTER_STR
383        BGP_STR
384        AS_STR)
385 {
386   int ret;
387   as_t as;
388   struct bgp *bgp;
389   const char *name = NULL;
390
391   VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
392
393   if (argc == 2)
394     name = argv[1];
395
396   ret = bgp_get (&bgp, &as, name);
397   switch (ret)
398     {
399     case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET:
400       vty_out (vty, "Please specify 'bgp multiple-instance' first%s", 
401                VTY_NEWLINE);
402       return CMD_WARNING;
403     case BGP_ERR_AS_MISMATCH:
404       vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE);
405       return CMD_WARNING;
406     case BGP_ERR_INSTANCE_MISMATCH:
407       vty_out (vty, "BGP view name and AS number mismatch%s", VTY_NEWLINE);
408       vty_out (vty, "BGP instance is already running; AS is %u%s",
409                as, VTY_NEWLINE);
410       return CMD_WARNING;
411     }
412
413   vty->node = BGP_NODE;
414   vty->index = bgp;
415
416   return CMD_SUCCESS;
417 }
418
419 ALIAS (router_bgp,
420        router_bgp_view_cmd,
421        "router bgp " CMD_AS_RANGE " view WORD",
422        ROUTER_STR
423        BGP_STR
424        AS_STR
425        "BGP view\n"
426        "view name\n")
427
428 /* "no router bgp" commands. */
429 DEFUN (no_router_bgp,
430        no_router_bgp_cmd,
431        "no router bgp " CMD_AS_RANGE,
432        NO_STR
433        ROUTER_STR
434        BGP_STR
435        AS_STR)
436 {
437   as_t as;
438   struct bgp *bgp;
439   const char *name = NULL;
440
441   VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
442
443   if (argc == 2)
444     name = argv[1];
445
446   /* Lookup bgp structure. */
447   bgp = bgp_lookup (as, name);
448   if (! bgp)
449     {
450       vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE);
451       return CMD_WARNING;
452     }
453
454   bgp_delete (bgp);
455
456   return CMD_SUCCESS;
457 }
458
459 ALIAS (no_router_bgp,
460        no_router_bgp_view_cmd,
461        "no router bgp " CMD_AS_RANGE " view WORD",
462        NO_STR
463        ROUTER_STR
464        BGP_STR
465        AS_STR
466        "BGP view\n"
467        "view name\n")
468
469 /* BGP router-id.  */
470
471 DEFUN (bgp_router_id,
472        bgp_router_id_cmd,
473        "bgp router-id A.B.C.D",
474        BGP_STR
475        "Override configured router identifier\n"
476        "Manually configured router identifier\n")
477 {
478   int ret;
479   struct in_addr id;
480   struct bgp *bgp;
481
482   bgp = vty->index;
483
484   ret = inet_aton (argv[0], &id);
485   if (! ret)
486     {
487       vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE);
488       return CMD_WARNING;
489     }
490
491   bgp_router_id_static_set (bgp, id);
492
493   return CMD_SUCCESS;
494 }
495
496 DEFUN (no_bgp_router_id,
497        no_bgp_router_id_cmd,
498        "no bgp router-id",
499        NO_STR
500        BGP_STR
501        "Override configured router identifier\n")
502 {
503   int ret;
504   struct in_addr id;
505   struct bgp *bgp;
506
507   bgp = vty->index;
508
509   if (argc == 1)
510     {
511       ret = inet_aton (argv[0], &id);
512       if (! ret)
513         {
514           vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE);
515           return CMD_WARNING;
516         }
517
518       if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id))
519         {
520           vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE);
521           return CMD_WARNING;
522         }
523     }
524
525   id.s_addr = 0;
526   bgp_router_id_static_set (bgp, id);
527
528   return CMD_SUCCESS;
529 }
530
531 ALIAS (no_bgp_router_id,
532        no_bgp_router_id_val_cmd,
533        "no bgp router-id A.B.C.D",
534        NO_STR
535        BGP_STR
536        "Override configured router identifier\n"
537        "Manually configured router identifier\n")
538
539 /* BGP Cluster ID.  */
540
541 DEFUN (bgp_cluster_id,
542        bgp_cluster_id_cmd,
543        "bgp cluster-id A.B.C.D",
544        BGP_STR
545        "Configure Route-Reflector Cluster-id\n"
546        "Route-Reflector Cluster-id in IP address format\n")
547 {
548   int ret;
549   struct bgp *bgp;
550   struct in_addr cluster;
551
552   bgp = vty->index;
553
554   ret = inet_aton (argv[0], &cluster);
555   if (! ret)
556     {
557       vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
558       return CMD_WARNING;
559     }
560
561   bgp_cluster_id_set (bgp, &cluster);
562
563   return CMD_SUCCESS;
564 }
565
566 ALIAS (bgp_cluster_id,
567        bgp_cluster_id32_cmd,
568        "bgp cluster-id <1-4294967295>",
569        BGP_STR
570        "Configure Route-Reflector Cluster-id\n"
571        "Route-Reflector Cluster-id as 32 bit quantity\n")
572
573 DEFUN (no_bgp_cluster_id,
574        no_bgp_cluster_id_cmd,
575        "no bgp cluster-id",
576        NO_STR
577        BGP_STR
578        "Configure Route-Reflector Cluster-id\n")
579 {
580   int ret;
581   struct bgp *bgp;
582   struct in_addr cluster;
583
584   bgp = vty->index;
585
586   if (argc == 1)
587     {
588       ret = inet_aton (argv[0], &cluster);
589       if (! ret)
590         {
591           vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
592           return CMD_WARNING;
593         }
594     }
595
596   bgp_cluster_id_unset (bgp);
597
598   return CMD_SUCCESS;
599 }
600
601 ALIAS (no_bgp_cluster_id,
602        no_bgp_cluster_id_arg_cmd,
603        "no bgp cluster-id A.B.C.D",
604        NO_STR
605        BGP_STR
606        "Configure Route-Reflector Cluster-id\n"
607        "Route-Reflector Cluster-id in IP address format\n")
608
609 DEFUN (bgp_confederation_identifier,
610        bgp_confederation_identifier_cmd,
611        "bgp confederation identifier " CMD_AS_RANGE,
612        "BGP specific commands\n"
613        "AS confederation parameters\n"
614        "AS number\n"
615        "Set routing domain confederation AS\n")
616 {
617   struct bgp *bgp;
618   as_t as;
619
620   bgp = vty->index;
621
622   VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
623
624   bgp_confederation_id_set (bgp, as);
625
626   return CMD_SUCCESS;
627 }
628
629 DEFUN (no_bgp_confederation_identifier,
630        no_bgp_confederation_identifier_cmd,
631        "no bgp confederation identifier",
632        NO_STR
633        "BGP specific commands\n"
634        "AS confederation parameters\n"
635        "AS number\n")
636 {
637   struct bgp *bgp;
638   as_t as __attribute__((unused)); /* Dummy for VTY_GET_INTEGER_RANGE */
639
640   bgp = vty->index;
641
642   if (argc == 1)
643     VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
644
645   bgp_confederation_id_unset (bgp);
646
647   return CMD_SUCCESS;
648 }
649
650 ALIAS (no_bgp_confederation_identifier,
651        no_bgp_confederation_identifier_arg_cmd,
652        "no bgp confederation identifier " CMD_AS_RANGE,
653        NO_STR
654        "BGP specific commands\n"
655        "AS confederation parameters\n"
656        "AS number\n"
657        "Set routing domain confederation AS\n")
658
659 DEFUN (bgp_confederation_peers,
660        bgp_confederation_peers_cmd,
661        "bgp confederation peers ." CMD_AS_RANGE,
662        "BGP specific commands\n"
663        "AS confederation parameters\n"
664        "Peer ASs in BGP confederation\n"
665        AS_STR)
666 {
667   struct bgp *bgp;
668   as_t as;
669   int i;
670
671   bgp = vty->index;
672
673   for (i = 0; i < argc; i++)
674     {
675       VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX);
676
677       if (bgp->as == as)
678         {
679           vty_out (vty, "%% Local member-AS not allowed in confed peer list%s",
680                    VTY_NEWLINE);
681           continue;
682         }
683
684       bgp_confederation_peers_add (bgp, as);
685     }
686   return CMD_SUCCESS;
687 }
688
689 DEFUN (no_bgp_confederation_peers,
690        no_bgp_confederation_peers_cmd,
691        "no bgp confederation peers ." CMD_AS_RANGE,
692        NO_STR
693        "BGP specific commands\n"
694        "AS confederation parameters\n"
695        "Peer ASs in BGP confederation\n"
696        AS_STR)
697 {
698   struct bgp *bgp;
699   as_t as;
700   int i;
701
702   bgp = vty->index;
703
704   for (i = 0; i < argc; i++)
705     {
706       VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX);
707
708       bgp_confederation_peers_remove (bgp, as);
709     }
710   return CMD_SUCCESS;
711 }
712
713 /* Maximum-paths configuration */
714 DEFUN (bgp_maxpaths,
715        bgp_maxpaths_cmd,
716        "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM),
717        "Forward packets over multiple paths\n"
718        "Number of paths\n")
719 {
720   struct bgp *bgp;
721   u_int16_t maxpaths;
722   int ret;
723
724   bgp = vty->index;
725
726   VTY_GET_INTEGER_RANGE ("maximum-paths", maxpaths, argv[0], 1, 255);
727
728   ret = bgp_maximum_paths_set (bgp, bgp_node_afi (vty), bgp_node_safi(vty),
729                                BGP_PEER_EBGP, maxpaths);
730   if (ret < 0)
731     {
732       vty_out (vty,
733                "%% Failed to set maximum-paths %u for afi %u, safi %u%s",
734                maxpaths, bgp_node_afi (vty), bgp_node_safi(vty), VTY_NEWLINE);
735       return CMD_WARNING;
736     }
737
738   return CMD_SUCCESS;
739 }
740
741 DEFUN (bgp_maxpaths_ibgp,
742        bgp_maxpaths_ibgp_cmd,
743        "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM),
744        "Forward packets over multiple paths\n"
745        "iBGP-multipath\n"
746        "Number of paths\n")
747 {
748   struct bgp *bgp;
749   u_int16_t maxpaths;
750   int ret;
751
752   bgp = vty->index;
753
754   VTY_GET_INTEGER_RANGE ("maximum-paths", maxpaths, argv[0], 1, 255);
755
756   ret = bgp_maximum_paths_set (bgp, bgp_node_afi (vty), bgp_node_safi(vty),
757                                BGP_PEER_IBGP, maxpaths);
758   if (ret < 0)
759     {
760       vty_out (vty,
761                "%% Failed to set maximum-paths ibgp %u for afi %u, safi %u%s",
762                maxpaths, bgp_node_afi (vty), bgp_node_safi(vty), VTY_NEWLINE);
763       return CMD_WARNING;
764     }
765
766   return CMD_SUCCESS;
767 }
768
769 DEFUN (no_bgp_maxpaths,
770        no_bgp_maxpaths_cmd,
771        "no maximum-paths",
772        NO_STR
773        "Forward packets over multiple paths\n"
774        "Number of paths\n")
775 {
776   struct bgp *bgp;
777   int ret;
778
779   bgp = vty->index;
780
781   ret = bgp_maximum_paths_unset (bgp, bgp_node_afi (vty), bgp_node_safi(vty),
782                                  BGP_PEER_EBGP);
783   if (ret < 0)
784     {
785       vty_out (vty,
786                "%% Failed to unset maximum-paths for afi %u, safi %u%s",
787                bgp_node_afi (vty), bgp_node_safi(vty), VTY_NEWLINE);
788       return CMD_WARNING;
789     }
790
791   return CMD_SUCCESS;
792 }
793
794 ALIAS (no_bgp_maxpaths,
795        no_bgp_maxpaths_arg_cmd,
796        "no maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM),
797        NO_STR
798        "Forward packets over multiple paths\n"
799        "Number of paths\n")
800
801 DEFUN (no_bgp_maxpaths_ibgp,
802        no_bgp_maxpaths_ibgp_cmd,
803        "no maximum-paths ibgp",
804        NO_STR
805        "Forward packets over multiple paths\n"
806        "iBGP-multipath\n"
807        "Number of paths\n")
808 {
809   struct bgp *bgp;
810   int ret;
811
812   bgp = vty->index;
813
814   ret = bgp_maximum_paths_unset (bgp, bgp_node_afi (vty), bgp_node_safi(vty),
815                                  BGP_PEER_IBGP);
816   if (ret < 0)
817     {
818       vty_out (vty,
819                "%% Failed to unset maximum-paths ibgp for afi %u, safi %u%s",
820                bgp_node_afi (vty), bgp_node_safi(vty), VTY_NEWLINE);
821       return CMD_WARNING;
822     }
823
824   return CMD_SUCCESS;
825 }
826
827 ALIAS (no_bgp_maxpaths_ibgp,
828        no_bgp_maxpaths_ibgp_arg_cmd,
829        "no maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM),
830        NO_STR
831        "Forward packets over multiple paths\n"
832        "iBGP-multipath\n"
833        "Number of paths\n")
834
835 int
836 bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi,
837                            safi_t safi, int *write)
838 {
839   if (bgp->maxpaths[afi][safi].maxpaths_ebgp != BGP_DEFAULT_MAXPATHS)
840     {
841       bgp_config_write_family_header (vty, afi, safi, write);
842       vty_out (vty, " maximum-paths %d%s",
843                bgp->maxpaths[afi][safi].maxpaths_ebgp, VTY_NEWLINE);
844     }
845
846   if (bgp->maxpaths[afi][safi].maxpaths_ibgp != BGP_DEFAULT_MAXPATHS)
847     {
848       bgp_config_write_family_header (vty, afi, safi, write);
849       vty_out (vty, " maximum-paths ibgp %d%s",
850                bgp->maxpaths[afi][safi].maxpaths_ibgp, VTY_NEWLINE);
851     }
852
853   return 0;
854 }
855
856 /* BGP timers.  */
857
858 DEFUN (bgp_timers,
859        bgp_timers_cmd,
860        "timers bgp <0-65535> <0-65535>",
861        "Adjust routing timers\n"
862        "BGP timers\n"
863        "Keepalive interval\n"
864        "Holdtime\n")
865 {
866   struct bgp *bgp;
867   unsigned long keepalive = 0;
868   unsigned long holdtime = 0;
869
870   bgp = vty->index;
871
872   VTY_GET_INTEGER ("keepalive", keepalive, argv[0]);
873   VTY_GET_INTEGER ("holdtime", holdtime, argv[1]);
874
875   /* Holdtime value check. */
876   if (holdtime < 3 && holdtime != 0)
877     {
878       vty_out (vty, "%% hold time value must be either 0 or greater than 3%s",
879                VTY_NEWLINE);
880       return CMD_WARNING;
881     }
882
883   bgp_timers_set (bgp, keepalive, holdtime);
884
885   return CMD_SUCCESS;
886 }
887
888 DEFUN (no_bgp_timers,
889        no_bgp_timers_cmd,
890        "no timers bgp",
891        NO_STR
892        "Adjust routing timers\n"
893        "BGP timers\n")
894 {
895   struct bgp *bgp;
896
897   bgp = vty->index;
898   bgp_timers_unset (bgp);
899
900   return CMD_SUCCESS;
901 }
902
903 ALIAS (no_bgp_timers,
904        no_bgp_timers_arg_cmd,
905        "no timers bgp <0-65535> <0-65535>",
906        NO_STR
907        "Adjust routing timers\n"
908        "BGP timers\n"
909        "Keepalive interval\n"
910        "Holdtime\n")
911
912 DEFUN (bgp_client_to_client_reflection,
913        bgp_client_to_client_reflection_cmd,
914        "bgp client-to-client reflection",
915        "BGP specific commands\n"
916        "Configure client to client route reflection\n"
917        "reflection of routes allowed\n")
918 {
919   struct bgp *bgp;
920
921   bgp = vty->index;
922   bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
923   return CMD_SUCCESS;
924 }
925
926 DEFUN (no_bgp_client_to_client_reflection,
927        no_bgp_client_to_client_reflection_cmd,
928        "no bgp client-to-client reflection",
929        NO_STR
930        "BGP specific commands\n"
931        "Configure client to client route reflection\n"
932        "reflection of routes allowed\n")
933 {
934   struct bgp *bgp;
935
936   bgp = vty->index;
937   bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
938   return CMD_SUCCESS;
939 }
940
941 /* "bgp always-compare-med" configuration. */
942 DEFUN (bgp_always_compare_med,
943        bgp_always_compare_med_cmd,
944        "bgp always-compare-med",
945        "BGP specific commands\n"
946        "Allow comparing MED from different neighbors\n")
947 {
948   struct bgp *bgp;
949
950   bgp = vty->index;
951   bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
952   return CMD_SUCCESS;
953 }
954
955 DEFUN (no_bgp_always_compare_med,
956        no_bgp_always_compare_med_cmd,
957        "no bgp always-compare-med",
958        NO_STR
959        "BGP specific commands\n"
960        "Allow comparing MED from different neighbors\n")
961 {
962   struct bgp *bgp;
963
964   bgp = vty->index;
965   bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
966   return CMD_SUCCESS;
967 }
968
969 /* "bgp deterministic-med" configuration. */
970 DEFUN (bgp_deterministic_med,
971        bgp_deterministic_med_cmd,
972        "bgp deterministic-med",
973        "BGP specific commands\n"
974        "Pick the best-MED path among paths advertised from the neighboring AS\n")
975 {
976   struct bgp *bgp;
977
978   bgp = vty->index;
979   bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED);
980   return CMD_SUCCESS;
981 }
982
983 DEFUN (no_bgp_deterministic_med,
984        no_bgp_deterministic_med_cmd,
985        "no bgp deterministic-med",
986        NO_STR
987        "BGP specific commands\n"
988        "Pick the best-MED path among paths advertised from the neighboring AS\n")
989 {
990   struct bgp *bgp;
991
992   bgp = vty->index;
993   bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED);
994   return CMD_SUCCESS;
995 }
996
997 /* "bgp graceful-restart" configuration. */
998 DEFUN (bgp_graceful_restart,
999        bgp_graceful_restart_cmd,
1000        "bgp graceful-restart",
1001        "BGP specific commands\n"
1002        "Graceful restart capability parameters\n")
1003 {
1004   struct bgp *bgp;
1005
1006   bgp = vty->index;
1007   bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART);
1008   return CMD_SUCCESS;
1009 }
1010
1011 DEFUN (no_bgp_graceful_restart,
1012        no_bgp_graceful_restart_cmd,
1013        "no bgp graceful-restart",
1014        NO_STR
1015        "BGP specific commands\n"
1016        "Graceful restart capability parameters\n")
1017 {
1018   struct bgp *bgp;
1019
1020   bgp = vty->index;
1021   bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART);
1022   return CMD_SUCCESS;
1023 }
1024
1025 DEFUN (bgp_graceful_restart_stalepath_time,
1026        bgp_graceful_restart_stalepath_time_cmd,
1027        "bgp graceful-restart stalepath-time <1-3600>",
1028        "BGP specific commands\n"
1029        "Graceful restart capability parameters\n"
1030        "Set the max time to hold onto restarting peer's stale paths\n"
1031        "Delay value (seconds)\n")
1032 {
1033   struct bgp *bgp;
1034   u_int32_t stalepath;
1035
1036   bgp = vty->index;
1037   if (! bgp)
1038     return CMD_WARNING;
1039
1040   VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[0], 1, 3600);
1041   bgp->stalepath_time = stalepath;
1042   return CMD_SUCCESS;
1043 }
1044
1045 DEFUN (bgp_graceful_restart_restart_time,
1046        bgp_graceful_restart_restart_time_cmd,
1047        "bgp graceful-restart restart-time <1-3600>",
1048        "BGP specific commands\n"
1049        "Graceful restart capability parameters\n"
1050        "Set the time to wait to delete stale routes before a BGP open message is received\n"
1051        "Delay value (seconds)\n")
1052 {
1053   struct bgp *bgp;
1054   u_int32_t restart;
1055
1056   bgp = vty->index;
1057   if (! bgp)
1058     return CMD_WARNING;
1059
1060   VTY_GET_INTEGER_RANGE ("restart-time", restart, argv[0], 1, 3600);
1061   bgp->restart_time = restart;
1062   return CMD_SUCCESS;
1063 }
1064
1065 DEFUN (no_bgp_graceful_restart_stalepath_time,
1066        no_bgp_graceful_restart_stalepath_time_cmd,
1067        "no bgp graceful-restart stalepath-time",
1068        NO_STR
1069        "BGP specific commands\n"
1070        "Graceful restart capability parameters\n"
1071        "Set the max time to hold onto restarting peer's stale paths\n")
1072 {
1073   struct bgp *bgp;
1074
1075   bgp = vty->index;
1076   if (! bgp)
1077     return CMD_WARNING;
1078
1079   bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME;
1080   return CMD_SUCCESS;
1081 }
1082
1083 DEFUN (no_bgp_graceful_restart_restart_time,
1084        no_bgp_graceful_restart_restart_time_cmd,
1085        "no bgp graceful-restart restart-time",
1086        NO_STR
1087        "BGP specific commands\n"
1088        "Graceful restart capability parameters\n"
1089        "Set the time to wait to delete stale routes before a BGP open message is received\n")
1090 {
1091   struct bgp *bgp;
1092
1093   bgp = vty->index;
1094   if (! bgp)
1095     return CMD_WARNING;
1096
1097   bgp->restart_time = BGP_DEFAULT_RESTART_TIME;
1098   return CMD_SUCCESS;
1099 }
1100
1101 ALIAS (no_bgp_graceful_restart_stalepath_time,
1102        no_bgp_graceful_restart_stalepath_time_val_cmd,
1103        "no bgp graceful-restart stalepath-time <1-3600>",
1104        NO_STR
1105        "BGP specific commands\n"
1106        "Graceful restart capability parameters\n"
1107        "Set the max time to hold onto restarting peer's stale paths\n"
1108        "Delay value (seconds)\n")
1109
1110 ALIAS (no_bgp_graceful_restart_restart_time,
1111        no_bgp_graceful_restart_restart_time_val_cmd,
1112        "no bgp graceful-restart restart-time <1-3600>",
1113        NO_STR
1114        "BGP specific commands\n"
1115        "Graceful restart capability parameters\n"
1116        "Set the time to wait to delete stale routes before a BGP open message is received\n"
1117        "Delay value (seconds)\n")
1118
1119 /* "bgp fast-external-failover" configuration. */
1120 DEFUN (bgp_fast_external_failover,
1121        bgp_fast_external_failover_cmd,
1122        "bgp fast-external-failover",
1123        BGP_STR
1124        "Immediately reset session if a link to a directly connected external peer goes down\n")
1125 {
1126   struct bgp *bgp;
1127
1128   bgp = vty->index;
1129   bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
1130   return CMD_SUCCESS;
1131 }
1132
1133 DEFUN (no_bgp_fast_external_failover,
1134        no_bgp_fast_external_failover_cmd,
1135        "no bgp fast-external-failover",
1136        NO_STR
1137        BGP_STR
1138        "Immediately reset session if a link to a directly connected external peer goes down\n")
1139 {
1140   struct bgp *bgp;
1141
1142   bgp = vty->index;
1143   bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
1144   return CMD_SUCCESS;
1145 }
1146
1147 /* "bgp enforce-first-as" configuration. */
1148 DEFUN (bgp_enforce_first_as,
1149        bgp_enforce_first_as_cmd,
1150        "bgp enforce-first-as",
1151        BGP_STR
1152        "Enforce the first AS for EBGP routes\n")
1153 {
1154   struct bgp *bgp;
1155
1156   bgp = vty->index;
1157   bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
1158   return CMD_SUCCESS;
1159 }
1160
1161 DEFUN (no_bgp_enforce_first_as,
1162        no_bgp_enforce_first_as_cmd,
1163        "no bgp enforce-first-as",
1164        NO_STR
1165        BGP_STR
1166        "Enforce the first AS for EBGP routes\n")
1167 {
1168   struct bgp *bgp;
1169
1170   bgp = vty->index;
1171   bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
1172   return CMD_SUCCESS;
1173 }
1174
1175 /* "bgp bestpath compare-routerid" configuration.  */
1176 DEFUN (bgp_bestpath_compare_router_id,
1177        bgp_bestpath_compare_router_id_cmd,
1178        "bgp bestpath compare-routerid",
1179        "BGP specific commands\n"
1180        "Change the default bestpath selection\n"
1181        "Compare router-id for identical EBGP paths\n")
1182 {
1183   struct bgp *bgp;
1184
1185   bgp = vty->index;
1186   bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
1187   return CMD_SUCCESS;
1188 }
1189
1190 DEFUN (no_bgp_bestpath_compare_router_id,
1191        no_bgp_bestpath_compare_router_id_cmd,
1192        "no bgp bestpath compare-routerid",
1193        NO_STR
1194        "BGP specific commands\n"
1195        "Change the default bestpath selection\n"
1196        "Compare router-id for identical EBGP paths\n")
1197 {
1198   struct bgp *bgp;
1199
1200   bgp = vty->index;
1201   bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
1202   return CMD_SUCCESS;
1203 }
1204
1205 /* "bgp bestpath as-path ignore" configuration.  */
1206 DEFUN (bgp_bestpath_aspath_ignore,
1207        bgp_bestpath_aspath_ignore_cmd,
1208        "bgp bestpath as-path ignore",
1209        "BGP specific commands\n"
1210        "Change the default bestpath selection\n"
1211        "AS-path attribute\n"
1212        "Ignore as-path length in selecting a route\n")
1213 {
1214   struct bgp *bgp;
1215
1216   bgp = vty->index;
1217   bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE);
1218   return CMD_SUCCESS;
1219 }
1220
1221 DEFUN (no_bgp_bestpath_aspath_ignore,
1222        no_bgp_bestpath_aspath_ignore_cmd,
1223        "no bgp bestpath as-path ignore",
1224        NO_STR
1225        "BGP specific commands\n"
1226        "Change the default bestpath selection\n"
1227        "AS-path attribute\n"
1228        "Ignore as-path length in selecting a route\n")
1229 {
1230   struct bgp *bgp;
1231
1232   bgp = vty->index;
1233   bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE);
1234   return CMD_SUCCESS;
1235 }
1236
1237 /* "bgp bestpath as-path confed" configuration.  */
1238 DEFUN (bgp_bestpath_aspath_confed,
1239        bgp_bestpath_aspath_confed_cmd,
1240        "bgp bestpath as-path confed",
1241        "BGP specific commands\n"
1242        "Change the default bestpath selection\n"
1243        "AS-path attribute\n"
1244        "Compare path lengths including confederation sets & sequences in selecting a route\n")
1245 {
1246   struct bgp *bgp;
1247
1248   bgp = vty->index;
1249   bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED);
1250   return CMD_SUCCESS;
1251 }
1252
1253 DEFUN (no_bgp_bestpath_aspath_confed,
1254        no_bgp_bestpath_aspath_confed_cmd,
1255        "no bgp bestpath as-path confed",
1256        NO_STR
1257        "BGP specific commands\n"
1258        "Change the default bestpath selection\n"
1259        "AS-path attribute\n"
1260        "Compare path lengths including confederation sets & sequences in selecting a route\n")
1261 {
1262   struct bgp *bgp;
1263
1264   bgp = vty->index;
1265   bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED);
1266   return CMD_SUCCESS;
1267 }
1268
1269 /* "bgp bestpath as-path multipath-relax" configuration.  */
1270 DEFUN (bgp_bestpath_aspath_multipath_relax,
1271        bgp_bestpath_aspath_multipath_relax_cmd,
1272        "bgp bestpath as-path multipath-relax",
1273        "BGP specific commands\n"
1274        "Change the default bestpath selection\n"
1275        "AS-path attribute\n"
1276        "Allow load sharing across routes that have different AS paths (but same length)\n")
1277 {
1278   struct bgp *bgp;
1279
1280   bgp = vty->index;
1281   bgp_flag_set (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
1282   return CMD_SUCCESS;
1283 }
1284
1285 DEFUN (no_bgp_bestpath_aspath_multipath_relax,
1286        no_bgp_bestpath_aspath_multipath_relax_cmd,
1287        "no bgp bestpath as-path multipath-relax",
1288        NO_STR
1289        "BGP specific commands\n"
1290        "Change the default bestpath selection\n"
1291        "AS-path attribute\n"
1292        "Allow load sharing across routes that have different AS paths (but same length)\n")
1293 {
1294   struct bgp *bgp;
1295
1296   bgp = vty->index;
1297   bgp_flag_unset (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
1298   return CMD_SUCCESS;
1299 }
1300
1301 /* "bgp log-neighbor-changes" configuration.  */
1302 DEFUN (bgp_log_neighbor_changes,
1303        bgp_log_neighbor_changes_cmd,
1304        "bgp log-neighbor-changes",
1305        "BGP specific commands\n"
1306        "Log neighbor up/down and reset reason\n")
1307 {
1308   struct bgp *bgp;
1309
1310   bgp = vty->index;
1311   bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
1312   return CMD_SUCCESS;
1313 }
1314
1315 DEFUN (no_bgp_log_neighbor_changes,
1316        no_bgp_log_neighbor_changes_cmd,
1317        "no bgp log-neighbor-changes",
1318        NO_STR
1319        "BGP specific commands\n"
1320        "Log neighbor up/down and reset reason\n")
1321 {
1322   struct bgp *bgp;
1323
1324   bgp = vty->index;
1325   bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
1326   return CMD_SUCCESS;
1327 }
1328
1329 /* "bgp bestpath med" configuration. */
1330 DEFUN (bgp_bestpath_med,
1331        bgp_bestpath_med_cmd,
1332        "bgp bestpath med (confed|missing-as-worst)",
1333        "BGP specific commands\n"
1334        "Change the default bestpath selection\n"
1335        "MED attribute\n"
1336        "Compare MED among confederation paths\n"
1337        "Treat missing MED as the least preferred one\n")
1338 {
1339   struct bgp *bgp;
1340   
1341   bgp = vty->index;
1342
1343   if (strncmp (argv[0], "confed", 1) == 0)
1344     bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
1345   else
1346     bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1347
1348   return CMD_SUCCESS;
1349 }
1350
1351 DEFUN (bgp_bestpath_med2,
1352        bgp_bestpath_med2_cmd,
1353        "bgp bestpath med confed missing-as-worst",
1354        "BGP specific commands\n"
1355        "Change the default bestpath selection\n"
1356        "MED attribute\n"
1357        "Compare MED among confederation paths\n"
1358        "Treat missing MED as the least preferred one\n")
1359 {
1360   struct bgp *bgp;
1361   
1362   bgp = vty->index;
1363   bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
1364   bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1365   return CMD_SUCCESS;
1366 }
1367
1368 ALIAS (bgp_bestpath_med2,
1369        bgp_bestpath_med3_cmd,
1370        "bgp bestpath med missing-as-worst confed",
1371        "BGP specific commands\n"
1372        "Change the default bestpath selection\n"
1373        "MED attribute\n"
1374        "Treat missing MED as the least preferred one\n"
1375        "Compare MED among confederation paths\n")
1376
1377 DEFUN (no_bgp_bestpath_med,
1378        no_bgp_bestpath_med_cmd,
1379        "no bgp bestpath med (confed|missing-as-worst)",
1380        NO_STR
1381        "BGP specific commands\n"
1382        "Change the default bestpath selection\n"
1383        "MED attribute\n"
1384        "Compare MED among confederation paths\n"
1385        "Treat missing MED as the least preferred one\n")
1386 {
1387   struct bgp *bgp;
1388
1389   bgp = vty->index;
1390   
1391   if (strncmp (argv[0], "confed", 1) == 0)
1392     bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
1393   else
1394     bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1395
1396   return CMD_SUCCESS;
1397 }
1398
1399 DEFUN (no_bgp_bestpath_med2,
1400        no_bgp_bestpath_med2_cmd,
1401        "no bgp bestpath med confed missing-as-worst",
1402        NO_STR
1403        "BGP specific commands\n"
1404        "Change the default bestpath selection\n"
1405        "MED attribute\n"
1406        "Compare MED among confederation paths\n"
1407        "Treat missing MED as the least preferred one\n")
1408 {
1409   struct bgp *bgp;
1410   
1411   bgp = vty->index;
1412   bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
1413   bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1414   return CMD_SUCCESS;
1415 }
1416
1417 ALIAS (no_bgp_bestpath_med2,
1418        no_bgp_bestpath_med3_cmd,
1419        "no bgp bestpath med missing-as-worst confed",
1420        NO_STR
1421        "BGP specific commands\n"
1422        "Change the default bestpath selection\n"
1423        "MED attribute\n"
1424        "Treat missing MED as the least preferred one\n"
1425        "Compare MED among confederation paths\n")
1426
1427 /* "no bgp default ipv4-unicast". */
1428 DEFUN (no_bgp_default_ipv4_unicast,
1429        no_bgp_default_ipv4_unicast_cmd,
1430        "no bgp default ipv4-unicast",
1431        NO_STR
1432        "BGP specific commands\n"
1433        "Configure BGP defaults\n"
1434        "Activate ipv4-unicast for a peer by default\n")
1435 {
1436   struct bgp *bgp;
1437
1438   bgp = vty->index;
1439   bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
1440   return CMD_SUCCESS;
1441 }
1442
1443 DEFUN (bgp_default_ipv4_unicast,
1444        bgp_default_ipv4_unicast_cmd,
1445        "bgp default ipv4-unicast",
1446        "BGP specific commands\n"
1447        "Configure BGP defaults\n"
1448        "Activate ipv4-unicast for a peer by default\n")
1449 {
1450   struct bgp *bgp;
1451
1452   bgp = vty->index;
1453   bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
1454   return CMD_SUCCESS;
1455 }
1456
1457 /* "bgp import-check" configuration.  */
1458 DEFUN (bgp_network_import_check,
1459        bgp_network_import_check_cmd,
1460        "bgp network import-check",
1461        "BGP specific commands\n"
1462        "BGP network command\n"
1463        "Check BGP network route exists in IGP\n")
1464 {
1465   struct bgp *bgp;
1466
1467   bgp = vty->index;
1468   bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK);
1469   return CMD_SUCCESS;
1470 }
1471
1472 DEFUN (no_bgp_network_import_check,
1473        no_bgp_network_import_check_cmd,
1474        "no bgp network import-check",
1475        NO_STR
1476        "BGP specific commands\n"
1477        "BGP network command\n"
1478        "Check BGP network route exists in IGP\n")
1479 {
1480   struct bgp *bgp;
1481
1482   bgp = vty->index;
1483   bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK);
1484   return CMD_SUCCESS;
1485 }
1486
1487 DEFUN (bgp_default_local_preference,
1488        bgp_default_local_preference_cmd,
1489        "bgp default local-preference <0-4294967295>",
1490        "BGP specific commands\n"
1491        "Configure BGP defaults\n"
1492        "local preference (higher=more preferred)\n"
1493        "Configure default local preference value\n")
1494 {
1495   struct bgp *bgp;
1496   u_int32_t local_pref;
1497
1498   bgp = vty->index;
1499
1500   VTY_GET_INTEGER ("local preference", local_pref, argv[0]);
1501
1502   bgp_default_local_preference_set (bgp, local_pref);
1503
1504   return CMD_SUCCESS;
1505 }
1506
1507 DEFUN (no_bgp_default_local_preference,
1508        no_bgp_default_local_preference_cmd,
1509        "no bgp default local-preference",
1510        NO_STR
1511        "BGP specific commands\n"
1512        "Configure BGP defaults\n"
1513        "local preference (higher=more preferred)\n")
1514 {
1515   struct bgp *bgp;
1516
1517   bgp = vty->index;
1518   bgp_default_local_preference_unset (bgp);
1519   return CMD_SUCCESS;
1520 }
1521
1522 ALIAS (no_bgp_default_local_preference,
1523        no_bgp_default_local_preference_val_cmd,
1524        "no bgp default local-preference <0-4294967295>",
1525        NO_STR
1526        "BGP specific commands\n"
1527        "Configure BGP defaults\n"
1528        "local preference (higher=more preferred)\n"
1529        "Configure default local preference value\n")
1530
1531 static void
1532 peer_announce_routes_if_rmap_out (struct bgp *bgp)
1533 {
1534   struct peer *peer;
1535   struct listnode *node, *nnode;
1536   struct bgp_filter *filter;
1537   afi_t afi;
1538   safi_t safi;
1539
1540   /* Reannounce all routes to appropriate neighbors */
1541   for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
1542     {
1543       for (afi = AFI_IP; afi < AFI_MAX; afi++)
1544         for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
1545           {
1546             if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
1547               {
1548                 /* check if there's an out route-map on this client */
1549                 filter = &peer->filter[afi][safi];
1550                 if (ROUTE_MAP_OUT_NAME(filter))
1551                   {
1552                     if (BGP_DEBUG(update, UPDATE_OUT))
1553                       zlog_debug("%s: Announcing routes again for peer %s"
1554                                  "(afi=%d, safi=%d", __func__, peer->host, afi,
1555                                  safi);
1556
1557                     bgp_announce_route_all(peer);
1558                   }
1559               }
1560         }
1561     }
1562 }
1563
1564 DEFUN (bgp_rr_allow_outbound_policy,
1565        bgp_rr_allow_outbound_policy_cmd,
1566        "bgp route-reflector allow-outbound-policy",
1567        "BGP specific commands\n"
1568        "Allow modifications made by out route-map\n"
1569        "on ibgp neighbors\n")
1570 {
1571   struct bgp *bgp;
1572
1573   bgp = vty->index;
1574
1575   if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY))
1576     {
1577       bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
1578       peer_announce_routes_if_rmap_out(bgp);
1579     }
1580
1581   return CMD_SUCCESS;
1582 }
1583
1584 DEFUN (no_bgp_rr_allow_outbound_policy,
1585        no_bgp_rr_allow_outbound_policy_cmd,
1586        "no bgp route-reflector allow-outbound-policy",
1587        NO_STR
1588        "BGP specific commands\n"
1589        "Allow modifications made by out route-map\n"
1590        "on ibgp neighbors\n")
1591 {
1592   struct bgp *bgp;
1593
1594   bgp = vty->index;
1595
1596   if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY))
1597     {
1598       bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
1599       peer_announce_routes_if_rmap_out(bgp);
1600     }
1601
1602   return CMD_SUCCESS;
1603 }
1604
1605 static int
1606 peer_remote_as_vty (struct vty *vty, const char *peer_str, 
1607                     const char *as_str, afi_t afi, safi_t safi)
1608 {
1609   int ret;
1610   struct bgp *bgp;
1611   as_t as;
1612   union sockunion su;
1613
1614   bgp = vty->index;
1615
1616   /* Get AS number.  */
1617   VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX);
1618
1619   /* If peer is peer group, call proper function.  */
1620   ret = str2sockunion (peer_str, &su);
1621   if (ret < 0)
1622     {
1623       ret = peer_group_remote_as (bgp, peer_str, &as);
1624       if (ret < 0)
1625         {
1626           vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1627           return CMD_WARNING;
1628         }
1629       return CMD_SUCCESS;
1630     }
1631
1632   if (peer_address_self_check (&su))
1633     {
1634       vty_out (vty, "%% Can not configure the local system as neighbor%s",
1635                VTY_NEWLINE);
1636       return CMD_WARNING;
1637     }
1638
1639   ret = peer_remote_as (bgp, &su, &as, afi, safi);
1640
1641   /* This peer belongs to peer group.  */
1642   switch (ret)
1643     {
1644     case BGP_ERR_PEER_GROUP_MEMBER:
1645       vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTY_NEWLINE);
1646       return CMD_WARNING;
1647     case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT:
1648       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);
1649       return CMD_WARNING;
1650     }
1651   return bgp_vty_return (vty, ret);
1652 }
1653
1654 DEFUN (neighbor_remote_as,
1655        neighbor_remote_as_cmd,
1656        NEIGHBOR_CMD2 "remote-as " CMD_AS_RANGE,
1657        NEIGHBOR_STR
1658        NEIGHBOR_ADDR_STR2
1659        "Specify a BGP neighbor\n"
1660        AS_STR)
1661 {
1662   return peer_remote_as_vty (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST);
1663 }
1664
1665 DEFUN (neighbor_peer_group,
1666        neighbor_peer_group_cmd,
1667        "neighbor WORD peer-group",
1668        NEIGHBOR_STR
1669        "Neighbor tag\n"
1670        "Configure peer-group\n")
1671 {
1672   struct bgp *bgp;
1673   struct peer_group *group;
1674
1675   bgp = vty->index;
1676
1677   group = peer_group_get (bgp, argv[0]);
1678   if (! group)
1679     return CMD_WARNING;
1680
1681   return CMD_SUCCESS;
1682 }
1683
1684 DEFUN (no_neighbor,
1685        no_neighbor_cmd,
1686        NO_NEIGHBOR_CMD2,
1687        NO_STR
1688        NEIGHBOR_STR
1689        NEIGHBOR_ADDR_STR2)
1690 {
1691   int ret;
1692   union sockunion su;
1693   struct peer_group *group;
1694   struct peer *peer;
1695
1696   ret = str2sockunion (argv[0], &su);
1697   if (ret < 0)
1698     {
1699       group = peer_group_lookup (vty->index, argv[0]);
1700       if (group)
1701         peer_group_delete (group);
1702       else
1703         {
1704           vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1705           return CMD_WARNING;
1706         }
1707     }
1708   else
1709     {
1710       peer = peer_lookup (vty->index, &su);
1711       if (peer)
1712         peer_delete (peer);
1713     }
1714
1715   return CMD_SUCCESS;
1716 }
1717
1718 ALIAS (no_neighbor,
1719        no_neighbor_remote_as_cmd,
1720        NO_NEIGHBOR_CMD "remote-as " CMD_AS_RANGE,
1721        NO_STR
1722        NEIGHBOR_STR
1723        NEIGHBOR_ADDR_STR
1724        "Specify a BGP neighbor\n"
1725        AS_STR)
1726
1727 DEFUN (no_neighbor_peer_group,
1728        no_neighbor_peer_group_cmd,
1729        "no neighbor WORD peer-group",
1730        NO_STR
1731        NEIGHBOR_STR
1732        "Neighbor tag\n"
1733        "Configure peer-group\n")
1734 {
1735   struct peer_group *group;
1736
1737   group = peer_group_lookup (vty->index, argv[0]);
1738   if (group)
1739     peer_group_delete (group);
1740   else
1741     {
1742       vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1743       return CMD_WARNING;
1744     }
1745   return CMD_SUCCESS;
1746 }
1747
1748 DEFUN (no_neighbor_peer_group_remote_as,
1749        no_neighbor_peer_group_remote_as_cmd,
1750        "no neighbor WORD remote-as " CMD_AS_RANGE,
1751        NO_STR
1752        NEIGHBOR_STR
1753        "Neighbor tag\n"
1754        "Specify a BGP neighbor\n"
1755        AS_STR)
1756 {
1757   struct peer_group *group;
1758
1759   group = peer_group_lookup (vty->index, argv[0]);
1760   if (group)
1761     peer_group_remote_as_delete (group);
1762   else
1763     {
1764       vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1765       return CMD_WARNING;
1766     }
1767   return CMD_SUCCESS;
1768 }
1769
1770 DEFUN (neighbor_local_as,
1771        neighbor_local_as_cmd,
1772        NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
1773        NEIGHBOR_STR
1774        NEIGHBOR_ADDR_STR2
1775        "Specify a local-as number\n"
1776        "AS number used as local AS\n")
1777 {
1778   struct peer *peer;
1779   int ret;
1780
1781   peer = peer_and_group_lookup_vty (vty, argv[0]);
1782   if (! peer)
1783     return CMD_WARNING;
1784
1785   ret = peer_local_as_set (peer, atoi (argv[1]), 0, 0);
1786   return bgp_vty_return (vty, ret);
1787 }
1788
1789 DEFUN (neighbor_local_as_no_prepend,
1790        neighbor_local_as_no_prepend_cmd,
1791        NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
1792        NEIGHBOR_STR
1793        NEIGHBOR_ADDR_STR2
1794        "Specify a local-as number\n"
1795        "AS number used as local AS\n"
1796        "Do not prepend local-as to updates from ebgp peers\n")
1797 {
1798   struct peer *peer;
1799   int ret;
1800
1801   peer = peer_and_group_lookup_vty (vty, argv[0]);
1802   if (! peer)
1803     return CMD_WARNING;
1804
1805   ret = peer_local_as_set (peer, atoi (argv[1]), 1, 0);
1806   return bgp_vty_return (vty, ret);
1807 }
1808
1809 DEFUN (neighbor_local_as_no_prepend_replace_as,
1810        neighbor_local_as_no_prepend_replace_as_cmd,
1811        NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend replace-as",
1812        NEIGHBOR_STR
1813        NEIGHBOR_ADDR_STR2
1814        "Specify a local-as number\n"
1815        "AS number used as local AS\n"
1816        "Do not prepend local-as to updates from ebgp peers\n"
1817        "Do not prepend local-as to updates from ibgp peers\n")
1818 {
1819   struct peer *peer;
1820   int ret;
1821
1822   peer = peer_and_group_lookup_vty (vty, argv[0]);
1823   if (! peer)
1824     return CMD_WARNING;
1825
1826   ret = peer_local_as_set (peer, atoi (argv[1]), 1, 1);
1827   return bgp_vty_return (vty, ret);
1828 }
1829
1830
1831 DEFUN (no_neighbor_local_as,
1832        no_neighbor_local_as_cmd,
1833        NO_NEIGHBOR_CMD2 "local-as",
1834        NO_STR
1835        NEIGHBOR_STR
1836        NEIGHBOR_ADDR_STR2
1837        "Specify a local-as number\n")
1838 {
1839   struct peer *peer;
1840   int ret;
1841
1842   peer = peer_and_group_lookup_vty (vty, argv[0]);
1843   if (! peer)
1844     return CMD_WARNING;
1845
1846   ret = peer_local_as_unset (peer);
1847   return bgp_vty_return (vty, ret);
1848 }
1849
1850 ALIAS (no_neighbor_local_as,
1851        no_neighbor_local_as_val_cmd,
1852        NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
1853        NO_STR
1854        NEIGHBOR_STR
1855        NEIGHBOR_ADDR_STR2
1856        "Specify a local-as number\n"
1857        "AS number used as local AS\n")
1858
1859 ALIAS (no_neighbor_local_as,
1860        no_neighbor_local_as_val2_cmd,
1861        NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
1862        NO_STR
1863        NEIGHBOR_STR
1864        NEIGHBOR_ADDR_STR2
1865        "Specify a local-as number\n"
1866        "AS number used as local AS\n"
1867        "Do not prepend local-as to updates from ebgp peers\n")
1868
1869 ALIAS (no_neighbor_local_as,
1870        no_neighbor_local_as_val3_cmd,
1871        NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend replace-as",
1872        NO_STR
1873        NEIGHBOR_STR
1874        NEIGHBOR_ADDR_STR2
1875        "Specify a local-as number\n"
1876        "AS number used as local AS\n"
1877        "Do not prepend local-as to updates from ebgp peers\n"
1878        "Do not prepend local-as to updates from ibgp peers\n")
1879
1880 DEFUN (neighbor_password,
1881        neighbor_password_cmd,
1882        NEIGHBOR_CMD2 "password LINE",
1883        NEIGHBOR_STR
1884        NEIGHBOR_ADDR_STR2
1885        "Set a password\n"
1886        "The password\n")
1887 {
1888   struct peer *peer;
1889   int ret;
1890
1891   peer = peer_and_group_lookup_vty (vty, argv[0]);
1892   if (! peer)
1893     return CMD_WARNING;
1894
1895   ret = peer_password_set (peer, argv[1]);
1896   return bgp_vty_return (vty, ret);
1897 }
1898
1899 DEFUN (no_neighbor_password,
1900        no_neighbor_password_cmd,
1901        NO_NEIGHBOR_CMD2 "password",
1902        NO_STR
1903        NEIGHBOR_STR
1904        NEIGHBOR_ADDR_STR2
1905        "Set a password\n")
1906 {
1907   struct peer *peer;
1908   int ret;
1909
1910   peer = peer_and_group_lookup_vty (vty, argv[0]);
1911   if (! peer)
1912     return CMD_WARNING;
1913
1914   ret = peer_password_unset (peer);
1915   return bgp_vty_return (vty, ret);
1916 }
1917
1918 DEFUN (neighbor_activate,
1919        neighbor_activate_cmd,
1920        NEIGHBOR_CMD2 "activate",
1921        NEIGHBOR_STR
1922        NEIGHBOR_ADDR_STR2
1923        "Enable the Address Family for this Neighbor\n")
1924 {
1925   struct peer *peer;
1926
1927   peer = peer_and_group_lookup_vty (vty, argv[0]);
1928   if (! peer)
1929     return CMD_WARNING;
1930
1931   peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
1932
1933   return CMD_SUCCESS;
1934 }
1935
1936 DEFUN (no_neighbor_activate,
1937        no_neighbor_activate_cmd,
1938        NO_NEIGHBOR_CMD2 "activate",
1939        NO_STR
1940        NEIGHBOR_STR
1941        NEIGHBOR_ADDR_STR2
1942        "Enable the Address Family for this Neighbor\n")
1943 {
1944   int ret;
1945   struct peer *peer;
1946
1947   /* Lookup peer. */
1948   peer = peer_and_group_lookup_vty (vty, argv[0]);
1949   if (! peer)
1950     return CMD_WARNING;
1951
1952   ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
1953
1954   return bgp_vty_return (vty, ret);
1955 }
1956
1957 DEFUN (neighbor_set_peer_group,
1958        neighbor_set_peer_group_cmd,
1959        NEIGHBOR_CMD "peer-group WORD",
1960        NEIGHBOR_STR
1961        NEIGHBOR_ADDR_STR
1962        "Member of the peer-group\n"
1963        "peer-group name\n")
1964 {
1965   int ret;
1966   as_t as;
1967   union sockunion su;
1968   struct bgp *bgp;
1969   struct peer_group *group;
1970
1971   bgp = vty->index;
1972
1973   ret = str2sockunion (argv[0], &su);
1974   if (ret < 0)
1975     {
1976       vty_out (vty, "%% Malformed address: %s%s", argv[0], VTY_NEWLINE);
1977       return CMD_WARNING;
1978     }
1979
1980   group = peer_group_lookup (bgp, argv[1]);
1981   if (! group)
1982     {
1983       vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
1984       return CMD_WARNING;
1985     }
1986
1987   if (peer_address_self_check (&su))
1988     {
1989       vty_out (vty, "%% Can not configure the local system as neighbor%s",
1990                VTY_NEWLINE);
1991       return CMD_WARNING;
1992     }
1993
1994   ret = peer_group_bind (bgp, &su, group, bgp_node_afi (vty), 
1995                          bgp_node_safi (vty), &as);
1996
1997   if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT)
1998     {
1999       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);
2000       return CMD_WARNING;
2001     }
2002
2003   return bgp_vty_return (vty, ret);
2004 }
2005
2006 DEFUN (no_neighbor_set_peer_group,
2007        no_neighbor_set_peer_group_cmd,
2008        NO_NEIGHBOR_CMD "peer-group WORD",
2009        NO_STR
2010        NEIGHBOR_STR
2011        NEIGHBOR_ADDR_STR
2012        "Member of the peer-group\n"
2013        "peer-group name\n")
2014 {
2015   int ret;
2016   struct bgp *bgp;
2017   struct peer *peer;
2018   struct peer_group *group;
2019
2020   bgp = vty->index;
2021
2022   peer = peer_lookup_vty (vty, argv[0]);
2023   if (! peer)
2024     return CMD_WARNING;
2025
2026   group = peer_group_lookup (bgp, argv[1]);
2027   if (! group)
2028     {
2029       vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
2030       return CMD_WARNING;
2031     }
2032
2033   ret = peer_group_unbind (bgp, peer, group, bgp_node_afi (vty),
2034                            bgp_node_safi (vty));
2035
2036   return bgp_vty_return (vty, ret);
2037 }
2038
2039 static int
2040 peer_flag_modify_vty (struct vty *vty, const char *ip_str, 
2041                       u_int16_t flag, int set)
2042 {
2043   int ret;
2044   struct peer *peer;
2045
2046   peer = peer_and_group_lookup_vty (vty, ip_str);
2047   if (! peer)
2048     return CMD_WARNING;
2049
2050   if (set)
2051     ret = peer_flag_set (peer, flag);
2052   else
2053     ret = peer_flag_unset (peer, flag);
2054
2055   return bgp_vty_return (vty, ret);
2056 }
2057
2058 static int
2059 peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
2060 {
2061   return peer_flag_modify_vty (vty, ip_str, flag, 1);
2062 }
2063
2064 static int
2065 peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
2066 {
2067   return peer_flag_modify_vty (vty, ip_str, flag, 0);
2068 }
2069
2070 /* neighbor passive. */
2071 DEFUN (neighbor_passive,
2072        neighbor_passive_cmd,
2073        NEIGHBOR_CMD2 "passive",
2074        NEIGHBOR_STR
2075        NEIGHBOR_ADDR_STR2
2076        "Don't send open messages to this neighbor\n")
2077 {
2078   return peer_flag_set_vty (vty, argv[0], PEER_FLAG_PASSIVE);
2079 }
2080
2081 DEFUN (no_neighbor_passive,
2082        no_neighbor_passive_cmd,
2083        NO_NEIGHBOR_CMD2 "passive",
2084        NO_STR
2085        NEIGHBOR_STR
2086        NEIGHBOR_ADDR_STR2
2087        "Don't send open messages to this neighbor\n")
2088 {
2089   return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_PASSIVE);
2090 }
2091
2092 /* neighbor shutdown. */
2093 DEFUN (neighbor_shutdown,
2094        neighbor_shutdown_cmd,
2095        NEIGHBOR_CMD2 "shutdown",
2096        NEIGHBOR_STR
2097        NEIGHBOR_ADDR_STR2
2098        "Administratively shut down this neighbor\n")
2099 {
2100   return peer_flag_set_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
2101 }
2102
2103 DEFUN (no_neighbor_shutdown,
2104        no_neighbor_shutdown_cmd,
2105        NO_NEIGHBOR_CMD2 "shutdown",
2106        NO_STR
2107        NEIGHBOR_STR
2108        NEIGHBOR_ADDR_STR2
2109        "Administratively shut down this neighbor\n")
2110 {
2111   return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
2112 }
2113
2114 /* Deprecated neighbor capability route-refresh. */
2115 DEFUN_DEPRECATED (neighbor_capability_route_refresh,
2116                   neighbor_capability_route_refresh_cmd,
2117                   NEIGHBOR_CMD2 "capability route-refresh",
2118                   NEIGHBOR_STR
2119                   NEIGHBOR_ADDR_STR2
2120                   "Advertise capability to the peer\n"
2121                   "Advertise route-refresh capability to this neighbor\n")
2122 {
2123   return CMD_SUCCESS;
2124 }
2125
2126 DEFUN_DEPRECATED (no_neighbor_capability_route_refresh,
2127                   no_neighbor_capability_route_refresh_cmd,
2128                   NO_NEIGHBOR_CMD2 "capability route-refresh",
2129                   NO_STR
2130                   NEIGHBOR_STR
2131                   NEIGHBOR_ADDR_STR2
2132                   "Advertise capability to the peer\n"
2133                   "Advertise route-refresh capability to this neighbor\n")
2134 {
2135   return CMD_SUCCESS;
2136 }
2137
2138 /* neighbor capability dynamic. */
2139 DEFUN (neighbor_capability_dynamic,
2140        neighbor_capability_dynamic_cmd,
2141        NEIGHBOR_CMD2 "capability dynamic",
2142        NEIGHBOR_STR
2143        NEIGHBOR_ADDR_STR2
2144        "Advertise capability to the peer\n"
2145        "Advertise dynamic capability to this neighbor\n")
2146 {
2147   return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
2148 }
2149
2150 DEFUN (no_neighbor_capability_dynamic,
2151        no_neighbor_capability_dynamic_cmd,
2152        NO_NEIGHBOR_CMD2 "capability dynamic",
2153        NO_STR
2154        NEIGHBOR_STR
2155        NEIGHBOR_ADDR_STR2
2156        "Advertise capability to the peer\n"
2157        "Advertise dynamic capability to this neighbor\n")
2158 {
2159   return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
2160 }
2161
2162 /* neighbor dont-capability-negotiate */
2163 DEFUN (neighbor_dont_capability_negotiate,
2164        neighbor_dont_capability_negotiate_cmd,
2165        NEIGHBOR_CMD2 "dont-capability-negotiate",
2166        NEIGHBOR_STR
2167        NEIGHBOR_ADDR_STR2
2168        "Do not perform capability negotiation\n")
2169 {
2170   return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
2171 }
2172
2173 DEFUN (no_neighbor_dont_capability_negotiate,
2174        no_neighbor_dont_capability_negotiate_cmd,
2175        NO_NEIGHBOR_CMD2 "dont-capability-negotiate",
2176        NO_STR
2177        NEIGHBOR_STR
2178        NEIGHBOR_ADDR_STR2
2179        "Do not perform capability negotiation\n")
2180 {
2181   return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
2182 }
2183
2184 static int
2185 peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi,
2186                          safi_t safi, u_int32_t flag, int set)
2187 {
2188   int ret;
2189   struct peer *peer;
2190
2191   peer = peer_and_group_lookup_vty (vty, peer_str);
2192   if (! peer)
2193     return CMD_WARNING;
2194
2195   if (set)
2196     ret = peer_af_flag_set (peer, afi, safi, flag);
2197   else
2198     ret = peer_af_flag_unset (peer, afi, safi, flag);
2199
2200   return bgp_vty_return (vty, ret);
2201 }
2202
2203 static int
2204 peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi,
2205                       safi_t safi, u_int32_t flag)
2206 {
2207   return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1);
2208 }
2209
2210 static int
2211 peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi,
2212                         safi_t safi, u_int32_t flag)
2213 {
2214   return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0);
2215 }
2216
2217 /* neighbor capability orf prefix-list. */
2218 DEFUN (neighbor_capability_orf_prefix,
2219        neighbor_capability_orf_prefix_cmd,
2220        NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
2221        NEIGHBOR_STR
2222        NEIGHBOR_ADDR_STR2
2223        "Advertise capability to the peer\n"
2224        "Advertise ORF capability to the peer\n"
2225        "Advertise prefixlist ORF capability to this neighbor\n"
2226        "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
2227        "Capability to RECEIVE the ORF from this neighbor\n"
2228        "Capability to SEND the ORF to this neighbor\n")
2229 {
2230   u_int16_t flag = 0;
2231
2232   if (strncmp (argv[1], "s", 1) == 0)
2233     flag = PEER_FLAG_ORF_PREFIX_SM;
2234   else if (strncmp (argv[1], "r", 1) == 0)
2235     flag = PEER_FLAG_ORF_PREFIX_RM;
2236   else if (strncmp (argv[1], "b", 1) == 0)
2237     flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
2238   else
2239     return CMD_WARNING;
2240
2241   return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2242                                bgp_node_safi (vty), flag);
2243 }
2244
2245 DEFUN (no_neighbor_capability_orf_prefix,
2246        no_neighbor_capability_orf_prefix_cmd,
2247        NO_NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
2248        NO_STR
2249        NEIGHBOR_STR
2250        NEIGHBOR_ADDR_STR2
2251        "Advertise capability to the peer\n"
2252        "Advertise ORF capability to the peer\n"
2253        "Advertise prefixlist ORF capability to this neighbor\n"
2254        "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
2255        "Capability to RECEIVE the ORF from this neighbor\n"
2256        "Capability to SEND the ORF to this neighbor\n")
2257 {
2258   u_int16_t flag = 0;
2259
2260   if (strncmp (argv[1], "s", 1) == 0)
2261     flag = PEER_FLAG_ORF_PREFIX_SM;
2262   else if (strncmp (argv[1], "r", 1) == 0)
2263     flag = PEER_FLAG_ORF_PREFIX_RM;
2264   else if (strncmp (argv[1], "b", 1) == 0)
2265     flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
2266   else
2267     return CMD_WARNING;
2268
2269   return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2270                                  bgp_node_safi (vty), flag);
2271 }
2272
2273 /* neighbor next-hop-self. */
2274 DEFUN (neighbor_nexthop_self,
2275        neighbor_nexthop_self_cmd,
2276        NEIGHBOR_CMD2 "next-hop-self {all}",
2277        NEIGHBOR_STR
2278        NEIGHBOR_ADDR_STR2
2279        "Disable the next hop calculation for this neighbor\n"
2280        "Apply also to ibgp-learned routes when acting as a route reflector\n")
2281 {
2282   u_int32_t flags = PEER_FLAG_NEXTHOP_SELF, unset = 0;
2283   int rc;
2284
2285   /* Check if "all" is specified */
2286   if (argv[1] != NULL)
2287     flags |= PEER_FLAG_NEXTHOP_SELF_ALL;
2288   else
2289     unset |= PEER_FLAG_NEXTHOP_SELF_ALL;
2290
2291   rc = peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2292                              bgp_node_safi (vty), flags);
2293   if ( rc == CMD_SUCCESS && unset )
2294     rc = peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2295                                  bgp_node_safi (vty), unset);
2296   return rc;
2297 }
2298
2299 DEFUN (no_neighbor_nexthop_self,
2300        no_neighbor_nexthop_self_cmd,
2301        NO_NEIGHBOR_CMD2 "next-hop-self {all}",
2302        NO_STR
2303        NEIGHBOR_STR
2304        NEIGHBOR_ADDR_STR2
2305        "Disable the next hop calculation for this neighbor\n"
2306        "Apply also to ibgp-learned routes when acting as a route reflector\n")
2307 {
2308   return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2309                                  bgp_node_safi (vty),
2310                                  PEER_FLAG_NEXTHOP_SELF|PEER_FLAG_NEXTHOP_SELF_ALL);
2311 }
2312
2313 /* neighbor remove-private-AS. */
2314 DEFUN (neighbor_remove_private_as,
2315        neighbor_remove_private_as_cmd,
2316        NEIGHBOR_CMD2 "remove-private-AS",
2317        NEIGHBOR_STR
2318        NEIGHBOR_ADDR_STR2
2319        "Remove private AS number from outbound updates\n")
2320 {
2321   return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2322                                bgp_node_safi (vty),
2323                                PEER_FLAG_REMOVE_PRIVATE_AS);
2324 }
2325
2326 DEFUN (no_neighbor_remove_private_as,
2327        no_neighbor_remove_private_as_cmd,
2328        NO_NEIGHBOR_CMD2 "remove-private-AS",
2329        NO_STR
2330        NEIGHBOR_STR
2331        NEIGHBOR_ADDR_STR2
2332        "Remove private AS number from outbound updates\n")
2333 {
2334   return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2335                                  bgp_node_safi (vty),
2336                                  PEER_FLAG_REMOVE_PRIVATE_AS);
2337 }
2338
2339 /* neighbor send-community. */
2340 DEFUN (neighbor_send_community,
2341        neighbor_send_community_cmd,
2342        NEIGHBOR_CMD2 "send-community",
2343        NEIGHBOR_STR
2344        NEIGHBOR_ADDR_STR2
2345        "Send Community attribute to this neighbor\n")
2346 {
2347   return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2348                                bgp_node_safi (vty),
2349                                PEER_FLAG_SEND_COMMUNITY);
2350 }
2351
2352 DEFUN (no_neighbor_send_community,
2353        no_neighbor_send_community_cmd,
2354        NO_NEIGHBOR_CMD2 "send-community",
2355        NO_STR
2356        NEIGHBOR_STR
2357        NEIGHBOR_ADDR_STR2
2358        "Send Community attribute to this neighbor\n")
2359 {
2360   return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2361                                  bgp_node_safi (vty),
2362                                  PEER_FLAG_SEND_COMMUNITY);
2363 }
2364
2365 /* neighbor send-community extended. */
2366 DEFUN (neighbor_send_community_type,
2367        neighbor_send_community_type_cmd,
2368        NEIGHBOR_CMD2 "send-community (both|all|extended|standard|large)",
2369        NEIGHBOR_STR
2370        NEIGHBOR_ADDR_STR2
2371        "Send Community attribute to this neighbor\n"
2372        "Send Standard, Large and Extended Community attributes\n"
2373        "Send Standard, Large and Extended Community attributes\n"
2374        "Send Extended Community attributes\n"
2375        "Send Standard Community attributes\n"
2376        "Send Large Community attributes\n")
2377 {
2378   if (strncmp (argv[1], "s", 1) == 0)
2379     return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2380                                  bgp_node_safi (vty),
2381                                  PEER_FLAG_SEND_COMMUNITY);
2382   if (strncmp (argv[1], "e", 1) == 0)
2383     return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2384                                  bgp_node_safi (vty),
2385                                  PEER_FLAG_SEND_EXT_COMMUNITY);
2386   if (strncmp (argv[1], "l", 1) == 0)
2387     return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2388                                  bgp_node_safi (vty),
2389                                  PEER_FLAG_SEND_LARGE_COMMUNITY);
2390
2391   return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2392                                bgp_node_safi (vty),
2393                                (PEER_FLAG_SEND_COMMUNITY|
2394                                 PEER_FLAG_SEND_EXT_COMMUNITY|
2395                                 PEER_FLAG_SEND_LARGE_COMMUNITY));
2396 }
2397
2398 DEFUN (no_neighbor_send_community_type,
2399        no_neighbor_send_community_type_cmd,
2400        NO_NEIGHBOR_CMD2 "send-community (both|all|extended|standard|large)",
2401        NO_STR
2402        NEIGHBOR_STR
2403        NEIGHBOR_ADDR_STR2
2404        "Send Community attribute to this neighbor\n"
2405        "Send Standard, Large and Extended Community attributes\n"
2406        "Send Standard, Large and Extended Community attributes\n"
2407        "Send Extended Community attributes\n"
2408        "Send Standard Community attributes\n"
2409        "Send Large Community attributes\n")
2410 {
2411   if (strncmp (argv[1], "s", 1) == 0)
2412     return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2413                                    bgp_node_safi (vty),
2414                                    PEER_FLAG_SEND_COMMUNITY);
2415   if (strncmp (argv[1], "e", 1) == 0)
2416     return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2417                                    bgp_node_safi (vty),
2418                                    PEER_FLAG_SEND_EXT_COMMUNITY);
2419   if (strncmp (argv[1], "l", 1) == 0)
2420     return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2421                                    bgp_node_safi (vty),
2422                                    PEER_FLAG_SEND_LARGE_COMMUNITY);
2423
2424   return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2425                                  bgp_node_safi (vty),
2426                                  (PEER_FLAG_SEND_COMMUNITY |
2427                                   PEER_FLAG_SEND_EXT_COMMUNITY|
2428                                   PEER_FLAG_SEND_LARGE_COMMUNITY));
2429 }
2430
2431 /* neighbor soft-reconfig. */
2432 DEFUN (neighbor_soft_reconfiguration,
2433        neighbor_soft_reconfiguration_cmd,
2434        NEIGHBOR_CMD2 "soft-reconfiguration inbound",
2435        NEIGHBOR_STR
2436        NEIGHBOR_ADDR_STR2
2437        "Per neighbor soft reconfiguration\n"
2438        "Allow inbound soft reconfiguration for this neighbor\n")
2439 {
2440   return peer_af_flag_set_vty (vty, argv[0],
2441                                bgp_node_afi (vty), bgp_node_safi (vty),
2442                                PEER_FLAG_SOFT_RECONFIG);
2443 }
2444
2445 DEFUN (no_neighbor_soft_reconfiguration,
2446        no_neighbor_soft_reconfiguration_cmd,
2447        NO_NEIGHBOR_CMD2 "soft-reconfiguration inbound",
2448        NO_STR
2449        NEIGHBOR_STR
2450        NEIGHBOR_ADDR_STR2
2451        "Per neighbor soft reconfiguration\n"
2452        "Allow inbound soft reconfiguration for this neighbor\n")
2453 {
2454   return peer_af_flag_unset_vty (vty, argv[0],
2455                                  bgp_node_afi (vty), bgp_node_safi (vty),
2456                                  PEER_FLAG_SOFT_RECONFIG);
2457 }
2458
2459 DEFUN (neighbor_route_reflector_client,
2460        neighbor_route_reflector_client_cmd,
2461        NEIGHBOR_CMD2 "route-reflector-client",
2462        NEIGHBOR_STR
2463        NEIGHBOR_ADDR_STR2
2464        "Configure a neighbor as Route Reflector client\n")
2465 {
2466   struct peer *peer;
2467
2468
2469   peer = peer_and_group_lookup_vty (vty, argv[0]);
2470   if (! peer)
2471     return CMD_WARNING;
2472
2473   return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2474                                bgp_node_safi (vty),
2475                                PEER_FLAG_REFLECTOR_CLIENT);
2476 }
2477
2478 DEFUN (no_neighbor_route_reflector_client,
2479        no_neighbor_route_reflector_client_cmd,
2480        NO_NEIGHBOR_CMD2 "route-reflector-client",
2481        NO_STR
2482        NEIGHBOR_STR
2483        NEIGHBOR_ADDR_STR2
2484        "Configure a neighbor as Route Reflector client\n")
2485 {
2486   return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2487                                  bgp_node_safi (vty),
2488                                  PEER_FLAG_REFLECTOR_CLIENT);
2489 }
2490
2491 static int
2492 peer_rsclient_set_vty (struct vty *vty, const char *peer_str, 
2493                        int afi, int safi)
2494 {
2495   int ret;
2496   struct bgp *bgp;
2497   struct peer *peer;
2498   struct peer_group *group;
2499   struct listnode *node, *nnode;
2500   struct bgp_filter *pfilter;
2501   struct bgp_filter *gfilter;
2502   int locked_and_added = 0;
2503
2504   bgp = vty->index;
2505
2506   peer = peer_and_group_lookup_vty (vty, peer_str);
2507   if ( ! peer )
2508     return CMD_WARNING;
2509
2510   /* If it is already a RS-Client, don't do anything. */
2511   if ( CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) )
2512     return CMD_SUCCESS;
2513
2514   if ( ! peer_rsclient_active (peer) )
2515     {
2516       peer = peer_lock (peer); /* rsclient peer list reference */
2517       listnode_add_sort (bgp->rsclient, peer);
2518       locked_and_added = 1;
2519     }
2520
2521   ret = peer_af_flag_set (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
2522   if (ret < 0)
2523     {
2524       if (locked_and_added)
2525         {
2526           listnode_delete (bgp->rsclient, peer);
2527           peer_unlock (peer); /* rsclient peer list reference */
2528         }
2529
2530       return bgp_vty_return (vty, ret);
2531     }
2532
2533   peer->rib[afi][safi] = bgp_table_init (afi, safi);
2534   peer->rib[afi][safi]->type = BGP_TABLE_RSCLIENT;
2535   /* RIB peer reference.  Released when table is free'd in bgp_table_free. */
2536   peer->rib[afi][safi]->owner = peer_lock (peer);
2537
2538   /* Check for existing 'network' and 'redistribute' routes. */
2539   bgp_check_local_routes_rsclient (peer, afi, safi);
2540
2541   /* Check for routes for peers configured with 'soft-reconfiguration'. */
2542   bgp_soft_reconfig_rsclient (peer, afi, safi);
2543
2544   if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))
2545     {
2546       group = peer->group;
2547       gfilter = &peer->filter[afi][safi];
2548
2549       for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
2550         {
2551           pfilter = &peer->filter[afi][safi];
2552
2553           /* Members of a non-RS-Client group should not be RS-Clients, as that 
2554              is checked when the become part of the peer-group */
2555           ret = peer_af_flag_set (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
2556           if (ret < 0)
2557             return bgp_vty_return (vty, ret);
2558
2559           /* Make peer's RIB point to group's RIB. */
2560           peer->rib[afi][safi] = group->conf->rib[afi][safi];
2561
2562           /* Import policy. */
2563           if (pfilter->map[RMAP_IMPORT].name)
2564             free (pfilter->map[RMAP_IMPORT].name);
2565           if (gfilter->map[RMAP_IMPORT].name)
2566             {
2567               pfilter->map[RMAP_IMPORT].name = strdup (gfilter->map[RMAP_IMPORT].name);
2568               pfilter->map[RMAP_IMPORT].map = gfilter->map[RMAP_IMPORT].map;
2569             }
2570           else
2571             {
2572               pfilter->map[RMAP_IMPORT].name = NULL;
2573               pfilter->map[RMAP_IMPORT].map =NULL;
2574             }
2575
2576           /* Export policy. */
2577           if (gfilter->map[RMAP_EXPORT].name && ! pfilter->map[RMAP_EXPORT].name)
2578             {
2579               pfilter->map[RMAP_EXPORT].name = strdup (gfilter->map[RMAP_EXPORT].name);
2580               pfilter->map[RMAP_EXPORT].map = gfilter->map[RMAP_EXPORT].map;
2581             }
2582         }
2583     }
2584   return CMD_SUCCESS;
2585 }
2586
2587 static int
2588 peer_rsclient_unset_vty (struct vty *vty, const char *peer_str, 
2589                          int afi, int safi)
2590 {
2591   int ret;
2592   struct bgp *bgp;
2593   struct peer *peer;
2594   struct peer_group *group;
2595   struct listnode *node, *nnode;
2596
2597   bgp = vty->index;
2598
2599   peer = peer_and_group_lookup_vty (vty, peer_str);
2600   if ( ! peer )
2601     return CMD_WARNING;
2602
2603   /* If it is not a RS-Client, don't do anything. */
2604   if ( ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) )
2605     return CMD_SUCCESS;
2606
2607   if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))
2608     {
2609       group = peer->group;
2610
2611       for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
2612         {
2613           ret = peer_af_flag_unset (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
2614           if (ret < 0)
2615             return bgp_vty_return (vty, ret);
2616
2617           peer->rib[afi][safi] = NULL;
2618         }
2619
2620         peer = group->conf;
2621     }
2622
2623   ret = peer_af_flag_unset (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
2624   if (ret < 0)
2625     return bgp_vty_return (vty, ret);
2626
2627   if ( ! peer_rsclient_active (peer) )
2628     {
2629       bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_MY_RSCLIENT);
2630       listnode_delete (bgp->rsclient, peer);
2631       peer_unlock (peer); /* peer bgp rsclient reference */
2632     }
2633
2634   bgp_table_finish (&peer->rib[bgp_node_afi(vty)][bgp_node_safi(vty)]);
2635
2636   return CMD_SUCCESS;
2637 }
2638
2639 /* neighbor route-server-client. */
2640 DEFUN (neighbor_route_server_client,
2641        neighbor_route_server_client_cmd,
2642        NEIGHBOR_CMD2 "route-server-client",
2643        NEIGHBOR_STR
2644        NEIGHBOR_ADDR_STR2
2645        "Configure a neighbor as Route Server client\n")
2646 {
2647   return peer_rsclient_set_vty (vty, argv[0], bgp_node_afi(vty),
2648                   bgp_node_safi(vty));
2649 }
2650
2651 DEFUN (no_neighbor_route_server_client,
2652        no_neighbor_route_server_client_cmd,
2653        NO_NEIGHBOR_CMD2 "route-server-client",
2654        NO_STR
2655        NEIGHBOR_STR
2656        NEIGHBOR_ADDR_STR2
2657        "Configure a neighbor as Route Server client\n")
2658 {
2659   return peer_rsclient_unset_vty (vty, argv[0], bgp_node_afi(vty),
2660                   bgp_node_safi(vty));
2661 }
2662
2663 DEFUN (neighbor_nexthop_local_unchanged,
2664        neighbor_nexthop_local_unchanged_cmd,
2665        NEIGHBOR_CMD2 "nexthop-local unchanged",
2666        NEIGHBOR_STR
2667        NEIGHBOR_ADDR_STR2
2668        "Configure treatment of outgoing link-local nexthop attribute\n"
2669        "Leave link-local nexthop unchanged for this peer\n")
2670 {
2671   return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2672                                 bgp_node_safi (vty),
2673                                 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
2674 }
2675
2676 DEFUN (no_neighbor_nexthop_local_unchanged,
2677        no_neighbor_nexthop_local_unchanged_cmd,
2678        NO_NEIGHBOR_CMD2 "nexthop-local unchanged",
2679        NO_STR
2680        NEIGHBOR_STR
2681        NEIGHBOR_ADDR_STR2
2682        "Configure treatment of outgoing link-local-nexthop attribute\n"
2683        "Leave link-local nexthop unchanged for this peer\n")
2684 {
2685   return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2686                                  bgp_node_safi (vty),
2687                                 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
2688 }
2689
2690 DEFUN (neighbor_attr_unchanged,
2691        neighbor_attr_unchanged_cmd,
2692        NEIGHBOR_CMD2 "attribute-unchanged",
2693        NEIGHBOR_STR
2694        NEIGHBOR_ADDR_STR2
2695        "BGP attribute is propagated unchanged to this neighbor\n")
2696 {
2697   return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2698                                bgp_node_safi (vty),
2699                                (PEER_FLAG_AS_PATH_UNCHANGED |
2700                                 PEER_FLAG_NEXTHOP_UNCHANGED |
2701                                 PEER_FLAG_MED_UNCHANGED));
2702 }
2703
2704 DEFUN (neighbor_attr_unchanged1,
2705        neighbor_attr_unchanged1_cmd,
2706        NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
2707        NEIGHBOR_STR
2708        NEIGHBOR_ADDR_STR2
2709        "BGP attribute is propagated unchanged to this neighbor\n"
2710        "As-path attribute\n"
2711        "Nexthop attribute\n"
2712        "Med attribute\n")
2713 {
2714   u_int16_t flags = 0;
2715
2716   if (strncmp (argv[1], "as-path", 1) == 0)
2717     SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2718   else if (strncmp (argv[1], "next-hop", 1) == 0)
2719     SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2720   else if (strncmp (argv[1], "med", 1) == 0)
2721     SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2722
2723   return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2724                                bgp_node_safi (vty), flags);
2725 }
2726
2727 DEFUN (neighbor_attr_unchanged2,
2728        neighbor_attr_unchanged2_cmd,
2729        NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
2730        NEIGHBOR_STR
2731        NEIGHBOR_ADDR_STR2
2732        "BGP attribute is propagated unchanged to this neighbor\n"
2733        "As-path attribute\n"
2734        "Nexthop attribute\n"
2735        "Med attribute\n")
2736 {
2737   u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
2738
2739   if (strncmp (argv[1], "next-hop", 1) == 0)
2740     SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2741   else if (strncmp (argv[1], "med", 1) == 0)
2742     SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2743
2744   return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2745                                bgp_node_safi (vty), flags);
2746
2747 }
2748
2749 DEFUN (neighbor_attr_unchanged3,
2750        neighbor_attr_unchanged3_cmd,
2751        NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
2752        NEIGHBOR_STR
2753        NEIGHBOR_ADDR_STR2
2754        "BGP attribute is propagated unchanged to this neighbor\n"
2755        "Nexthop attribute\n"
2756        "As-path attribute\n"
2757        "Med attribute\n")
2758 {
2759   u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
2760
2761   if (strncmp (argv[1], "as-path", 1) == 0)
2762     SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2763   else if (strncmp (argv[1], "med", 1) == 0)
2764     SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2765
2766   return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2767                                bgp_node_safi (vty), flags);
2768 }
2769
2770 DEFUN (neighbor_attr_unchanged4,
2771        neighbor_attr_unchanged4_cmd,
2772        NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
2773        NEIGHBOR_STR
2774        NEIGHBOR_ADDR_STR2
2775        "BGP attribute is propagated unchanged to this neighbor\n"
2776        "Med attribute\n"
2777        "As-path attribute\n"
2778        "Nexthop attribute\n")
2779 {
2780   u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
2781
2782   if (strncmp (argv[1], "as-path", 1) == 0)
2783     SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2784   else if (strncmp (argv[1], "next-hop", 1) == 0)
2785     SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2786
2787   return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2788                                bgp_node_safi (vty), flags);
2789 }
2790
2791 ALIAS (neighbor_attr_unchanged,
2792        neighbor_attr_unchanged5_cmd,
2793        NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
2794        NEIGHBOR_STR
2795        NEIGHBOR_ADDR_STR2
2796        "BGP attribute is propagated unchanged to this neighbor\n"
2797        "As-path attribute\n"
2798        "Nexthop attribute\n"
2799        "Med attribute\n")
2800
2801 ALIAS (neighbor_attr_unchanged,
2802        neighbor_attr_unchanged6_cmd,
2803        NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
2804        NEIGHBOR_STR
2805        NEIGHBOR_ADDR_STR2
2806        "BGP attribute is propagated unchanged to this neighbor\n"
2807        "As-path attribute\n"
2808        "Med attribute\n"
2809        "Nexthop attribute\n")
2810
2811 ALIAS (neighbor_attr_unchanged,
2812        neighbor_attr_unchanged7_cmd,
2813        NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
2814        NEIGHBOR_STR
2815        NEIGHBOR_ADDR_STR2
2816        "BGP attribute is propagated unchanged to this neighbor\n"
2817        "Nexthop attribute\n"
2818        "Med attribute\n"
2819        "As-path attribute\n")
2820
2821 ALIAS (neighbor_attr_unchanged,
2822        neighbor_attr_unchanged8_cmd,
2823        NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
2824        NEIGHBOR_STR
2825        NEIGHBOR_ADDR_STR2
2826        "BGP attribute is propagated unchanged to this neighbor\n"
2827        "Nexthop attribute\n"
2828        "As-path attribute\n"
2829        "Med attribute\n")
2830
2831 ALIAS (neighbor_attr_unchanged,
2832        neighbor_attr_unchanged9_cmd,
2833        NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
2834        NEIGHBOR_STR
2835        NEIGHBOR_ADDR_STR2
2836        "BGP attribute is propagated unchanged to this neighbor\n"
2837        "Med attribute\n"
2838        "Nexthop attribute\n"
2839        "As-path attribute\n")
2840
2841 ALIAS (neighbor_attr_unchanged,
2842        neighbor_attr_unchanged10_cmd,
2843        NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
2844        NEIGHBOR_STR
2845        NEIGHBOR_ADDR_STR2
2846        "BGP attribute is propagated unchanged to this neighbor\n"
2847        "Med attribute\n"
2848        "As-path attribute\n"
2849        "Nexthop attribute\n")
2850
2851 DEFUN (no_neighbor_attr_unchanged,
2852        no_neighbor_attr_unchanged_cmd,
2853        NO_NEIGHBOR_CMD2 "attribute-unchanged",
2854        NO_STR    
2855        NEIGHBOR_STR
2856        NEIGHBOR_ADDR_STR2
2857        "BGP attribute is propagated unchanged to this neighbor\n")
2858 {
2859   return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2860                                  bgp_node_safi (vty),
2861                                  (PEER_FLAG_AS_PATH_UNCHANGED |
2862                                   PEER_FLAG_NEXTHOP_UNCHANGED |
2863                                   PEER_FLAG_MED_UNCHANGED));
2864 }
2865
2866 DEFUN (no_neighbor_attr_unchanged1,
2867        no_neighbor_attr_unchanged1_cmd,
2868        NO_NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
2869        NO_STR
2870        NEIGHBOR_STR
2871        NEIGHBOR_ADDR_STR2
2872        "BGP attribute is propagated unchanged to this neighbor\n"
2873        "As-path attribute\n"
2874        "Nexthop attribute\n"
2875        "Med attribute\n")
2876 {
2877   u_int16_t flags = 0;
2878
2879   if (strncmp (argv[1], "as-path", 1) == 0)
2880     SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2881   else if (strncmp (argv[1], "next-hop", 1) == 0)
2882     SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2883   else if (strncmp (argv[1], "med", 1) == 0)
2884     SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2885
2886   return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2887                                  bgp_node_safi (vty), flags);
2888 }
2889
2890 DEFUN (no_neighbor_attr_unchanged2,
2891        no_neighbor_attr_unchanged2_cmd,
2892        NO_NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
2893        NO_STR
2894        NEIGHBOR_STR
2895        NEIGHBOR_ADDR_STR2
2896        "BGP attribute is propagated unchanged to this neighbor\n"
2897        "As-path attribute\n"
2898        "Nexthop attribute\n"
2899        "Med attribute\n")
2900 {
2901   u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
2902
2903   if (strncmp (argv[1], "next-hop", 1) == 0)
2904     SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2905   else if (strncmp (argv[1], "med", 1) == 0)
2906     SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2907
2908   return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2909                                bgp_node_safi (vty), flags);
2910 }
2911
2912 DEFUN (no_neighbor_attr_unchanged3,
2913        no_neighbor_attr_unchanged3_cmd,
2914        NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
2915        NO_STR
2916        NEIGHBOR_STR
2917        NEIGHBOR_ADDR_STR2
2918        "BGP attribute is propagated unchanged to this neighbor\n"
2919        "Nexthop attribute\n"
2920        "As-path attribute\n"
2921        "Med attribute\n")
2922 {
2923   u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
2924
2925   if (strncmp (argv[1], "as-path", 1) == 0)
2926     SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2927   else if (strncmp (argv[1], "med", 1) == 0)
2928     SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2929
2930   return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2931                                  bgp_node_safi (vty), flags);
2932 }
2933
2934 DEFUN (no_neighbor_attr_unchanged4,
2935        no_neighbor_attr_unchanged4_cmd,
2936        NO_NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
2937        NO_STR
2938        NEIGHBOR_STR
2939        NEIGHBOR_ADDR_STR2
2940        "BGP attribute is propagated unchanged to this neighbor\n"
2941        "Med attribute\n"
2942        "As-path attribute\n"
2943        "Nexthop attribute\n")
2944 {
2945   u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
2946
2947   if (strncmp (argv[1], "as-path", 1) == 0)
2948     SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2949   else if (strncmp (argv[1], "next-hop", 1) == 0)
2950     SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2951
2952   return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2953                                bgp_node_safi (vty), flags);
2954 }
2955
2956 ALIAS (no_neighbor_attr_unchanged,
2957        no_neighbor_attr_unchanged5_cmd,
2958        NO_NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
2959        NO_STR
2960        NEIGHBOR_STR
2961        NEIGHBOR_ADDR_STR2
2962        "BGP attribute is propagated unchanged to this neighbor\n"
2963        "As-path attribute\n"
2964        "Nexthop attribute\n"
2965        "Med attribute\n")
2966
2967 ALIAS (no_neighbor_attr_unchanged,
2968        no_neighbor_attr_unchanged6_cmd,
2969        NO_NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
2970        NO_STR
2971        NEIGHBOR_STR
2972        NEIGHBOR_ADDR_STR2
2973        "BGP attribute is propagated unchanged to this neighbor\n"
2974        "As-path attribute\n"
2975        "Med attribute\n"
2976        "Nexthop attribute\n")
2977
2978 ALIAS (no_neighbor_attr_unchanged,
2979        no_neighbor_attr_unchanged7_cmd,
2980        NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
2981        NO_STR
2982        NEIGHBOR_STR
2983        NEIGHBOR_ADDR_STR2
2984        "BGP attribute is propagated unchanged to this neighbor\n"
2985        "Nexthop attribute\n"
2986        "Med attribute\n"
2987        "As-path attribute\n")
2988
2989 ALIAS (no_neighbor_attr_unchanged,
2990        no_neighbor_attr_unchanged8_cmd,
2991        NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
2992        NO_STR
2993        NEIGHBOR_STR
2994        NEIGHBOR_ADDR_STR2
2995        "BGP attribute is propagated unchanged to this neighbor\n"
2996        "Nexthop attribute\n"
2997        "As-path attribute\n"
2998        "Med attribute\n")
2999
3000 ALIAS (no_neighbor_attr_unchanged,
3001        no_neighbor_attr_unchanged9_cmd,
3002        NO_NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
3003        NO_STR
3004        NEIGHBOR_STR
3005        NEIGHBOR_ADDR_STR2
3006        "BGP attribute is propagated unchanged to this neighbor\n"
3007        "Med attribute\n"
3008        "Nexthop attribute\n"
3009        "As-path attribute\n")
3010
3011 ALIAS (no_neighbor_attr_unchanged,
3012        no_neighbor_attr_unchanged10_cmd,
3013        NO_NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
3014        NO_STR
3015        NEIGHBOR_STR
3016        NEIGHBOR_ADDR_STR2
3017        "BGP attribute is propagated unchanged to this neighbor\n"
3018        "Med attribute\n"
3019        "As-path attribute\n"
3020        "Nexthop attribute\n")
3021
3022 /* For old version Zebra compatibility.  */
3023 DEFUN_DEPRECATED (neighbor_transparent_as,
3024                   neighbor_transparent_as_cmd,
3025                   NEIGHBOR_CMD "transparent-as",
3026                   NEIGHBOR_STR
3027                   NEIGHBOR_ADDR_STR
3028                   "Do not append my AS number even peer is EBGP peer\n")
3029 {
3030   return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3031                                bgp_node_safi (vty),
3032                                PEER_FLAG_AS_PATH_UNCHANGED);
3033 }
3034
3035 DEFUN_DEPRECATED (neighbor_transparent_nexthop,
3036                   neighbor_transparent_nexthop_cmd,
3037                   NEIGHBOR_CMD "transparent-nexthop",
3038                   NEIGHBOR_STR
3039                   NEIGHBOR_ADDR_STR
3040                   "Do not change nexthop even peer is EBGP peer\n")
3041 {
3042   return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3043                                bgp_node_safi (vty),
3044                                PEER_FLAG_NEXTHOP_UNCHANGED);
3045 }
3046
3047 /* EBGP multihop configuration. */
3048 static int
3049 peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str, 
3050                             const char *ttl_str)
3051 {
3052   struct peer *peer;
3053   unsigned int ttl;
3054
3055   peer = peer_and_group_lookup_vty (vty, ip_str);
3056   if (! peer)
3057     return CMD_WARNING;
3058
3059   if (! ttl_str)
3060     ttl = TTL_MAX;
3061   else
3062     VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, 255);
3063
3064   return bgp_vty_return (vty,  peer_ebgp_multihop_set (peer, ttl));
3065 }
3066
3067 static int
3068 peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str) 
3069 {
3070   struct peer *peer;
3071
3072   peer = peer_and_group_lookup_vty (vty, ip_str);
3073   if (! peer)
3074     return CMD_WARNING;
3075
3076   return bgp_vty_return (vty, peer_ebgp_multihop_set (peer, 0));
3077 }
3078
3079 /* neighbor ebgp-multihop. */
3080 DEFUN (neighbor_ebgp_multihop,
3081        neighbor_ebgp_multihop_cmd,
3082        NEIGHBOR_CMD2 "ebgp-multihop",
3083        NEIGHBOR_STR
3084        NEIGHBOR_ADDR_STR2
3085        "Allow EBGP neighbors not on directly connected networks\n")
3086 {
3087   return peer_ebgp_multihop_set_vty (vty, argv[0], NULL);
3088 }
3089
3090 DEFUN (neighbor_ebgp_multihop_ttl,
3091        neighbor_ebgp_multihop_ttl_cmd,
3092        NEIGHBOR_CMD2 "ebgp-multihop <1-255>",
3093        NEIGHBOR_STR
3094        NEIGHBOR_ADDR_STR2
3095        "Allow EBGP neighbors not on directly connected networks\n"
3096        "maximum hop count\n")
3097 {
3098   return peer_ebgp_multihop_set_vty (vty, argv[0], argv[1]);
3099 }
3100
3101 DEFUN (no_neighbor_ebgp_multihop,
3102        no_neighbor_ebgp_multihop_cmd,
3103        NO_NEIGHBOR_CMD2 "ebgp-multihop",
3104        NO_STR
3105        NEIGHBOR_STR
3106        NEIGHBOR_ADDR_STR2
3107        "Allow EBGP neighbors not on directly connected networks\n")
3108 {
3109   return peer_ebgp_multihop_unset_vty (vty, argv[0]);
3110 }
3111
3112 ALIAS (no_neighbor_ebgp_multihop,
3113        no_neighbor_ebgp_multihop_ttl_cmd,
3114        NO_NEIGHBOR_CMD2 "ebgp-multihop <1-255>",
3115        NO_STR
3116        NEIGHBOR_STR
3117        NEIGHBOR_ADDR_STR2
3118        "Allow EBGP neighbors not on directly connected networks\n"
3119        "maximum hop count\n")
3120
3121 /* disable-connected-check */
3122 DEFUN (neighbor_disable_connected_check,
3123        neighbor_disable_connected_check_cmd,
3124        NEIGHBOR_CMD2 "disable-connected-check",
3125        NEIGHBOR_STR
3126        NEIGHBOR_ADDR_STR2
3127        "one-hop away EBGP peer using loopback address\n")
3128 {
3129   return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
3130 }
3131
3132 DEFUN (no_neighbor_disable_connected_check,
3133        no_neighbor_disable_connected_check_cmd,
3134        NO_NEIGHBOR_CMD2 "disable-connected-check",
3135        NO_STR
3136        NEIGHBOR_STR
3137        NEIGHBOR_ADDR_STR2
3138        "one-hop away EBGP peer using loopback address\n")
3139 {
3140   return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
3141 }
3142
3143 /* Enforce multihop.  */
3144 ALIAS (neighbor_disable_connected_check,
3145        neighbor_enforce_multihop_cmd,
3146        NEIGHBOR_CMD2 "enforce-multihop",
3147        NEIGHBOR_STR
3148        NEIGHBOR_ADDR_STR2
3149        "Enforce EBGP neighbors perform multihop\n")
3150
3151 /* Enforce multihop.  */
3152 ALIAS (no_neighbor_disable_connected_check,
3153        no_neighbor_enforce_multihop_cmd,
3154        NO_NEIGHBOR_CMD2 "enforce-multihop",
3155        NO_STR
3156        NEIGHBOR_STR
3157        NEIGHBOR_ADDR_STR2
3158        "Enforce EBGP neighbors perform multihop\n")
3159
3160 DEFUN (neighbor_description,
3161        neighbor_description_cmd,
3162        NEIGHBOR_CMD2 "description .LINE",
3163        NEIGHBOR_STR
3164        NEIGHBOR_ADDR_STR2
3165        "Neighbor specific description\n"
3166        "Up to 80 characters describing this neighbor\n")
3167 {
3168   struct peer *peer;
3169   char *str;
3170
3171   peer = peer_and_group_lookup_vty (vty, argv[0]);
3172   if (! peer)
3173     return CMD_WARNING;
3174
3175   if (argc == 1)
3176     return CMD_SUCCESS;
3177
3178   str = argv_concat(argv, argc, 1);
3179
3180   peer_description_set (peer, str);
3181
3182   XFREE (MTYPE_TMP, str);
3183
3184   return CMD_SUCCESS;
3185 }
3186
3187 DEFUN (no_neighbor_description,
3188        no_neighbor_description_cmd,
3189        NO_NEIGHBOR_CMD2 "description",
3190        NO_STR
3191        NEIGHBOR_STR
3192        NEIGHBOR_ADDR_STR2
3193        "Neighbor specific description\n")
3194 {
3195   struct peer *peer;
3196
3197   peer = peer_and_group_lookup_vty (vty, argv[0]);
3198   if (! peer)
3199     return CMD_WARNING;
3200
3201   peer_description_unset (peer);
3202
3203   return CMD_SUCCESS;
3204 }
3205
3206 ALIAS (no_neighbor_description,
3207        no_neighbor_description_val_cmd,
3208        NO_NEIGHBOR_CMD2 "description .LINE",
3209        NO_STR
3210        NEIGHBOR_STR
3211        NEIGHBOR_ADDR_STR2
3212        "Neighbor specific description\n"
3213        "Up to 80 characters describing this neighbor\n")
3214
3215 /* Neighbor update-source. */
3216 static int
3217 peer_update_source_vty (struct vty *vty, const char *peer_str, 
3218                         const char *source_str)
3219 {
3220   struct peer *peer;
3221
3222   peer = peer_and_group_lookup_vty (vty, peer_str);
3223   if (! peer)
3224     return CMD_WARNING;
3225
3226   if (source_str)
3227     {
3228       union sockunion su;
3229       int ret = str2sockunion (source_str, &su);
3230
3231       if (ret == 0)
3232         peer_update_source_addr_set (peer, &su);
3233       else
3234         peer_update_source_if_set (peer, source_str);
3235     }
3236   else
3237     peer_update_source_unset (peer);
3238
3239   return CMD_SUCCESS;
3240 }
3241
3242 #define BGP_UPDATE_SOURCE_STR "(A.B.C.D|X:X::X:X|WORD)"
3243 #define BGP_UPDATE_SOURCE_HELP_STR \
3244   "IPv4 address\n" \
3245   "IPv6 address\n" \
3246   "Interface name (requires zebra to be running)\n"
3247
3248 DEFUN (neighbor_update_source,
3249        neighbor_update_source_cmd,
3250        NEIGHBOR_CMD2 "update-source " BGP_UPDATE_SOURCE_STR,
3251        NEIGHBOR_STR
3252        NEIGHBOR_ADDR_STR2
3253        "Source of routing updates\n"
3254        BGP_UPDATE_SOURCE_HELP_STR)
3255 {
3256   return peer_update_source_vty (vty, argv[0], argv[1]);
3257 }
3258
3259 DEFUN (no_neighbor_update_source,
3260        no_neighbor_update_source_cmd,
3261        NO_NEIGHBOR_CMD2 "update-source",
3262        NO_STR
3263        NEIGHBOR_STR
3264        NEIGHBOR_ADDR_STR2
3265        "Source of routing updates\n")
3266 {
3267   return peer_update_source_vty (vty, argv[0], NULL);
3268 }
3269
3270 static int
3271 peer_default_originate_set_vty (struct vty *vty, const char *peer_str, 
3272                                 afi_t afi, safi_t safi, 
3273                                 const char *rmap, int set)
3274 {
3275   int ret;
3276   struct peer *peer;
3277
3278   peer = peer_and_group_lookup_vty (vty, peer_str);
3279   if (! peer)
3280     return CMD_WARNING;
3281
3282   if (set)
3283     ret = peer_default_originate_set (peer, afi, safi, rmap);
3284   else
3285     ret = peer_default_originate_unset (peer, afi, safi);
3286
3287   return bgp_vty_return (vty, ret);
3288 }
3289
3290 /* neighbor default-originate. */
3291 DEFUN (neighbor_default_originate,
3292        neighbor_default_originate_cmd,
3293        NEIGHBOR_CMD2 "default-originate",
3294        NEIGHBOR_STR
3295        NEIGHBOR_ADDR_STR2
3296        "Originate default route to this neighbor\n")
3297 {
3298   return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
3299                                          bgp_node_safi (vty), NULL, 1);
3300 }
3301
3302 DEFUN (neighbor_default_originate_rmap,
3303        neighbor_default_originate_rmap_cmd,
3304        NEIGHBOR_CMD2 "default-originate route-map WORD",
3305        NEIGHBOR_STR
3306        NEIGHBOR_ADDR_STR2
3307        "Originate default route to this neighbor\n"
3308        "Route-map to specify criteria to originate default\n"
3309        "route-map name\n")
3310 {
3311   return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
3312                                          bgp_node_safi (vty), argv[1], 1);
3313 }
3314
3315 DEFUN (no_neighbor_default_originate,
3316        no_neighbor_default_originate_cmd,
3317        NO_NEIGHBOR_CMD2 "default-originate",
3318        NO_STR
3319        NEIGHBOR_STR
3320        NEIGHBOR_ADDR_STR2
3321        "Originate default route to this neighbor\n")
3322 {
3323   return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
3324                                          bgp_node_safi (vty), NULL, 0);
3325 }
3326
3327 ALIAS (no_neighbor_default_originate,
3328        no_neighbor_default_originate_rmap_cmd,
3329        NO_NEIGHBOR_CMD2 "default-originate route-map WORD",
3330        NO_STR
3331        NEIGHBOR_STR
3332        NEIGHBOR_ADDR_STR2
3333        "Originate default route to this neighbor\n"
3334        "Route-map to specify criteria to originate default\n"
3335        "route-map name\n")
3336
3337 /* Set neighbor's BGP port.  */
3338 static int
3339 peer_port_vty (struct vty *vty, const char *ip_str, int afi, 
3340                const char *port_str)
3341 {
3342   struct peer *peer;
3343   u_int16_t port;
3344   struct servent *sp;
3345
3346   peer = peer_lookup_vty (vty, ip_str);
3347   if (! peer)
3348     return CMD_WARNING;
3349
3350   if (! port_str)
3351     { 
3352       sp = getservbyname ("bgp", "tcp");
3353       port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port);
3354     }
3355   else
3356     {
3357       VTY_GET_INTEGER("port", port, port_str);
3358     }
3359
3360   peer_port_set (peer, port);
3361
3362   return CMD_SUCCESS;
3363 }
3364
3365 /* Set specified peer's BGP port.  */
3366 DEFUN (neighbor_port,
3367        neighbor_port_cmd,
3368        NEIGHBOR_CMD "port <0-65535>",
3369        NEIGHBOR_STR
3370        NEIGHBOR_ADDR_STR
3371        "Neighbor's BGP port\n"
3372        "TCP port number\n")
3373 {
3374   return peer_port_vty (vty, argv[0], AFI_IP, argv[1]);
3375 }
3376
3377 DEFUN (no_neighbor_port,
3378        no_neighbor_port_cmd,
3379        NO_NEIGHBOR_CMD "port",
3380        NO_STR
3381        NEIGHBOR_STR
3382        NEIGHBOR_ADDR_STR
3383        "Neighbor's BGP port\n")
3384 {
3385   return peer_port_vty (vty, argv[0], AFI_IP, NULL);
3386 }
3387
3388 ALIAS (no_neighbor_port,
3389        no_neighbor_port_val_cmd,
3390        NO_NEIGHBOR_CMD "port <0-65535>",
3391        NO_STR
3392        NEIGHBOR_STR
3393        NEIGHBOR_ADDR_STR
3394        "Neighbor's BGP port\n"
3395        "TCP port number\n")
3396
3397 /* neighbor weight. */
3398 static int
3399 peer_weight_set_vty (struct vty *vty, const char *ip_str, 
3400                      const char *weight_str)
3401 {
3402   struct peer *peer;
3403   unsigned long weight;
3404
3405   peer = peer_and_group_lookup_vty (vty, ip_str);
3406   if (! peer)
3407     return CMD_WARNING;
3408
3409   VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535);
3410
3411   return bgp_vty_return (vty, peer_weight_set (peer, weight));
3412 }
3413
3414 static int
3415 peer_weight_unset_vty (struct vty *vty, const char *ip_str)
3416 {
3417   struct peer *peer;
3418
3419   peer = peer_and_group_lookup_vty (vty, ip_str);
3420   if (! peer)
3421     return CMD_WARNING;
3422
3423   return bgp_vty_return (vty, peer_weight_unset (peer));
3424 }
3425
3426 DEFUN (neighbor_weight,
3427        neighbor_weight_cmd,
3428        NEIGHBOR_CMD2 "weight <0-65535>",
3429        NEIGHBOR_STR
3430        NEIGHBOR_ADDR_STR2
3431        "Set default weight for routes from this neighbor\n"
3432        "default weight\n")
3433 {
3434   return peer_weight_set_vty (vty, argv[0], argv[1]);
3435 }
3436
3437 DEFUN (no_neighbor_weight,
3438        no_neighbor_weight_cmd,
3439        NO_NEIGHBOR_CMD2 "weight",
3440        NO_STR
3441        NEIGHBOR_STR
3442        NEIGHBOR_ADDR_STR2
3443        "Set default weight for routes from this neighbor\n")
3444 {
3445   return peer_weight_unset_vty (vty, argv[0]);
3446 }
3447
3448 ALIAS (no_neighbor_weight,
3449        no_neighbor_weight_val_cmd,
3450        NO_NEIGHBOR_CMD2 "weight <0-65535>",
3451        NO_STR
3452        NEIGHBOR_STR
3453        NEIGHBOR_ADDR_STR2
3454        "Set default weight for routes from this neighbor\n"
3455        "default weight\n")
3456
3457 /* Override capability negotiation. */
3458 DEFUN (neighbor_override_capability,
3459        neighbor_override_capability_cmd,
3460        NEIGHBOR_CMD2 "override-capability",
3461        NEIGHBOR_STR
3462        NEIGHBOR_ADDR_STR2
3463        "Override capability negotiation result\n")
3464 {
3465   return peer_flag_set_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
3466 }
3467
3468 DEFUN (no_neighbor_override_capability,
3469        no_neighbor_override_capability_cmd,
3470        NO_NEIGHBOR_CMD2 "override-capability",
3471        NO_STR
3472        NEIGHBOR_STR
3473        NEIGHBOR_ADDR_STR2
3474        "Override capability negotiation result\n")
3475 {
3476   return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
3477 }
3478
3479 DEFUN (neighbor_strict_capability,
3480        neighbor_strict_capability_cmd,
3481        NEIGHBOR_CMD "strict-capability-match",
3482        NEIGHBOR_STR
3483        NEIGHBOR_ADDR_STR
3484        "Strict capability negotiation match\n")
3485 {
3486   return peer_flag_set_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
3487 }
3488
3489 DEFUN (no_neighbor_strict_capability,
3490        no_neighbor_strict_capability_cmd,
3491        NO_NEIGHBOR_CMD "strict-capability-match",
3492        NO_STR
3493        NEIGHBOR_STR
3494        NEIGHBOR_ADDR_STR
3495        "Strict capability negotiation match\n")
3496 {
3497   return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
3498 }
3499
3500 static int
3501 peer_timers_set_vty (struct vty *vty, const char *ip_str, 
3502                      const char *keep_str, const char *hold_str)
3503 {
3504   int ret;
3505   struct peer *peer;
3506   u_int32_t keepalive;
3507   u_int32_t holdtime;
3508
3509   peer = peer_and_group_lookup_vty (vty, ip_str);
3510   if (! peer)
3511     return CMD_WARNING;
3512
3513   VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535);
3514   VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535);
3515
3516   ret = peer_timers_set (peer, keepalive, holdtime);
3517
3518   return bgp_vty_return (vty, ret);
3519 }
3520
3521 static int
3522 peer_timers_unset_vty (struct vty *vty, const char *ip_str)
3523 {
3524   int ret;
3525   struct peer *peer;
3526
3527   peer = peer_lookup_vty (vty, ip_str);
3528   if (! peer)
3529     return CMD_WARNING;
3530
3531   ret = peer_timers_unset (peer);
3532
3533   return bgp_vty_return (vty, ret);
3534 }
3535
3536 DEFUN (neighbor_timers,
3537        neighbor_timers_cmd,
3538        NEIGHBOR_CMD2 "timers <0-65535> <0-65535>",
3539        NEIGHBOR_STR
3540        NEIGHBOR_ADDR_STR2
3541        "BGP per neighbor timers\n"
3542        "Keepalive interval\n"
3543        "Holdtime\n")
3544 {
3545   return peer_timers_set_vty (vty, argv[0], argv[1], argv[2]);
3546 }
3547
3548 DEFUN (no_neighbor_timers,
3549        no_neighbor_timers_cmd,
3550        NO_NEIGHBOR_CMD2 "timers",
3551        NO_STR
3552        NEIGHBOR_STR
3553        NEIGHBOR_ADDR_STR2
3554        "BGP per neighbor timers\n")
3555 {
3556   return peer_timers_unset_vty (vty, argv[0]);
3557 }
3558
3559 static int
3560 peer_timers_connect_set_vty (struct vty *vty, const char *ip_str, 
3561                              const char *time_str)
3562 {
3563   struct peer *peer;
3564   u_int32_t connect;
3565
3566   peer = peer_and_group_lookup_vty (vty, ip_str);
3567   if (! peer)
3568     return CMD_WARNING;
3569
3570   VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535);
3571
3572   return bgp_vty_return (vty, peer_timers_connect_set (peer, connect));
3573 }
3574
3575 static int
3576 peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str)
3577 {
3578   struct peer *peer;
3579
3580   peer = peer_and_group_lookup_vty (vty, ip_str);
3581   if (! peer)
3582     return CMD_WARNING;
3583
3584   return bgp_vty_return (vty, peer_timers_connect_unset (peer));
3585 }
3586
3587 DEFUN (neighbor_timers_connect,
3588        neighbor_timers_connect_cmd,
3589        NEIGHBOR_CMD2 "timers connect <1-65535>",
3590        NEIGHBOR_STR
3591        NEIGHBOR_ADDR_STR2
3592        "BGP per neighbor timers\n"
3593        "BGP connect timer\n"
3594        "Connect timer\n")
3595 {
3596   return peer_timers_connect_set_vty (vty, argv[0], argv[1]);
3597 }
3598
3599 DEFUN (no_neighbor_timers_connect,
3600        no_neighbor_timers_connect_cmd,
3601        NO_NEIGHBOR_CMD2 "timers connect",
3602        NO_STR
3603        NEIGHBOR_STR
3604        NEIGHBOR_ADDR_STR2
3605        "BGP per neighbor timers\n"
3606        "BGP connect timer\n")
3607 {
3608   return peer_timers_connect_unset_vty (vty, argv[0]);
3609 }
3610
3611 ALIAS (no_neighbor_timers_connect,
3612        no_neighbor_timers_connect_val_cmd,
3613        NO_NEIGHBOR_CMD2 "timers connect <1-65535>",
3614        NO_STR
3615        NEIGHBOR_STR
3616        NEIGHBOR_ADDR_STR2
3617        "BGP per neighbor timers\n"
3618        "BGP connect timer\n"
3619        "Connect timer\n")
3620
3621 static int
3622 peer_advertise_interval_vty (struct vty *vty, const char *ip_str, 
3623                              const char *time_str, int set)  
3624 {
3625   int ret;
3626   struct peer *peer;
3627   u_int32_t routeadv = 0;
3628
3629   peer = peer_and_group_lookup_vty (vty, ip_str);
3630   if (! peer)
3631     return CMD_WARNING;
3632
3633   if (time_str)
3634     VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600);
3635
3636   if (set)
3637     ret = peer_advertise_interval_set (peer, routeadv);
3638   else
3639     ret = peer_advertise_interval_unset (peer);
3640
3641   return bgp_vty_return (vty, ret);
3642 }
3643
3644 DEFUN (neighbor_advertise_interval,
3645        neighbor_advertise_interval_cmd,
3646        NEIGHBOR_CMD2 "advertisement-interval <0-600>",
3647        NEIGHBOR_STR
3648        NEIGHBOR_ADDR_STR2
3649        "Minimum interval between sending BGP routing updates\n"
3650        "time in seconds\n")
3651 {
3652   return peer_advertise_interval_vty (vty, argv[0], argv[1], 1);
3653 }
3654
3655 DEFUN (no_neighbor_advertise_interval,
3656        no_neighbor_advertise_interval_cmd,
3657        NO_NEIGHBOR_CMD2 "advertisement-interval",
3658        NO_STR
3659        NEIGHBOR_STR
3660        NEIGHBOR_ADDR_STR2
3661        "Minimum interval between sending BGP routing updates\n")
3662 {
3663   return peer_advertise_interval_vty (vty, argv[0], NULL, 0);
3664 }
3665
3666 ALIAS (no_neighbor_advertise_interval,
3667        no_neighbor_advertise_interval_val_cmd,
3668        NO_NEIGHBOR_CMD2 "advertisement-interval <0-600>",
3669        NO_STR
3670        NEIGHBOR_STR
3671        NEIGHBOR_ADDR_STR2
3672        "Minimum interval between sending BGP routing updates\n"
3673        "time in seconds\n")
3674
3675 /* neighbor interface */
3676 static int
3677 peer_interface_vty (struct vty *vty, const char *ip_str, const char *str)
3678 {
3679   int ret;
3680   struct peer *peer;
3681
3682   peer = peer_lookup_vty (vty, ip_str);
3683   if (! peer)
3684     return CMD_WARNING;
3685
3686   if (str)
3687     ret = peer_interface_set (peer, str);
3688   else
3689     ret = peer_interface_unset (peer);
3690
3691   return bgp_vty_return (vty, ret);
3692 }
3693
3694 DEFUN (neighbor_interface,
3695        neighbor_interface_cmd,
3696        NEIGHBOR_CMD "interface WORD",
3697        NEIGHBOR_STR
3698        NEIGHBOR_ADDR_STR
3699        "Interface\n"
3700        "Interface name\n")
3701 {
3702   return peer_interface_vty (vty, argv[0], argv[1]);
3703 }
3704
3705 DEFUN (no_neighbor_interface,
3706        no_neighbor_interface_cmd,
3707        NO_NEIGHBOR_CMD "interface WORD",
3708        NO_STR
3709        NEIGHBOR_STR
3710        NEIGHBOR_ADDR_STR
3711        "Interface\n"
3712        "Interface name\n")
3713 {
3714   return peer_interface_vty (vty, argv[0], NULL);
3715 }
3716
3717 /* Set distribute list to the peer. */
3718 static int
3719 peer_distribute_set_vty (struct vty *vty, const char *ip_str, 
3720                          afi_t afi, safi_t safi,
3721                          const char *name_str, const char *direct_str)
3722 {
3723   int ret;
3724   struct peer *peer;
3725   int direct = FILTER_IN;
3726
3727   peer = peer_and_group_lookup_vty (vty, ip_str);
3728   if (! peer)
3729     return CMD_WARNING;
3730
3731   /* Check filter direction. */
3732   if (strncmp (direct_str, "i", 1) == 0)
3733     direct = FILTER_IN;
3734   else if (strncmp (direct_str, "o", 1) == 0)
3735     direct = FILTER_OUT;
3736
3737   ret = peer_distribute_set (peer, afi, safi, direct, name_str);
3738
3739   return bgp_vty_return (vty, ret);
3740 }
3741
3742 static int
3743 peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
3744                            safi_t safi, const char *direct_str)
3745 {
3746   int ret;
3747   struct peer *peer;
3748   int direct = FILTER_IN;
3749
3750   peer = peer_and_group_lookup_vty (vty, ip_str);
3751   if (! peer)
3752     return CMD_WARNING;
3753
3754   /* Check filter direction. */
3755   if (strncmp (direct_str, "i", 1) == 0)
3756     direct = FILTER_IN;
3757   else if (strncmp (direct_str, "o", 1) == 0)
3758     direct = FILTER_OUT;
3759
3760   ret = peer_distribute_unset (peer, afi, safi, direct);
3761
3762   return bgp_vty_return (vty, ret);
3763 }
3764
3765 DEFUN (neighbor_distribute_list,
3766        neighbor_distribute_list_cmd,
3767        NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
3768        NEIGHBOR_STR
3769        NEIGHBOR_ADDR_STR2
3770        "Filter updates to/from this neighbor\n"
3771        "IP access-list number\n"
3772        "IP access-list number (expanded range)\n"
3773        "IP Access-list name\n"
3774        "Filter incoming updates\n"
3775        "Filter outgoing updates\n")
3776 {
3777   return peer_distribute_set_vty (vty, argv[0], bgp_node_afi (vty),
3778                                   bgp_node_safi (vty), argv[1], argv[2]);
3779 }
3780
3781 DEFUN (no_neighbor_distribute_list,
3782        no_neighbor_distribute_list_cmd,
3783        NO_NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
3784        NO_STR
3785        NEIGHBOR_STR
3786        NEIGHBOR_ADDR_STR2
3787        "Filter updates to/from this neighbor\n"
3788        "IP access-list number\n"
3789        "IP access-list number (expanded range)\n"
3790        "IP Access-list name\n"
3791        "Filter incoming updates\n"
3792        "Filter outgoing updates\n")
3793 {
3794   return peer_distribute_unset_vty (vty, argv[0], bgp_node_afi (vty),
3795                                     bgp_node_safi (vty), argv[2]);
3796 }
3797
3798 /* Set prefix list to the peer. */
3799 static int
3800 peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
3801                           safi_t safi, const char *name_str, 
3802                           const char *direct_str)
3803 {
3804   int ret;
3805   struct peer *peer;
3806   int direct = FILTER_IN;
3807
3808   peer = peer_and_group_lookup_vty (vty, ip_str);
3809   if (! peer)
3810     return CMD_WARNING;
3811
3812   /* Check filter direction. */
3813   if (strncmp (direct_str, "i", 1) == 0)
3814     direct = FILTER_IN;
3815   else if (strncmp (direct_str, "o", 1) == 0)
3816     direct = FILTER_OUT;
3817
3818   ret = peer_prefix_list_set (peer, afi, safi, direct, name_str);
3819
3820   return bgp_vty_return (vty, ret);
3821 }
3822
3823 static int
3824 peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
3825                             safi_t safi, const char *direct_str)
3826 {
3827   int ret;
3828   struct peer *peer;
3829   int direct = FILTER_IN;
3830
3831   peer = peer_and_group_lookup_vty (vty, ip_str);
3832   if (! peer)
3833     return CMD_WARNING;
3834   
3835   /* Check filter direction. */
3836   if (strncmp (direct_str, "i", 1) == 0)
3837     direct = FILTER_IN;
3838   else if (strncmp (direct_str, "o", 1) == 0)
3839     direct = FILTER_OUT;
3840
3841   ret = peer_prefix_list_unset (peer, afi, safi, direct);
3842
3843   return bgp_vty_return (vty, ret);
3844 }
3845
3846 DEFUN (neighbor_prefix_list,
3847        neighbor_prefix_list_cmd,
3848        NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
3849        NEIGHBOR_STR
3850        NEIGHBOR_ADDR_STR2
3851        "Filter updates to/from this neighbor\n"
3852        "Name of a prefix list\n"
3853        "Filter incoming updates\n"
3854        "Filter outgoing updates\n")
3855 {
3856   return peer_prefix_list_set_vty (vty, argv[0], bgp_node_afi (vty),
3857                                    bgp_node_safi (vty), argv[1], argv[2]);
3858 }
3859
3860 DEFUN (no_neighbor_prefix_list,
3861        no_neighbor_prefix_list_cmd,
3862        NO_NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
3863        NO_STR
3864        NEIGHBOR_STR
3865        NEIGHBOR_ADDR_STR2
3866        "Filter updates to/from this neighbor\n"
3867        "Name of a prefix list\n"
3868        "Filter incoming updates\n"
3869        "Filter outgoing updates\n")
3870 {
3871   return peer_prefix_list_unset_vty (vty, argv[0], bgp_node_afi (vty),
3872                                      bgp_node_safi (vty), argv[2]);
3873 }
3874
3875 static int
3876 peer_aslist_set_vty (struct vty *vty, const char *ip_str, 
3877                      afi_t afi, safi_t safi,
3878                      const char *name_str, const char *direct_str)
3879 {
3880   int ret;
3881   struct peer *peer;
3882   int direct = FILTER_IN;
3883
3884   peer = peer_and_group_lookup_vty (vty, ip_str);
3885   if (! peer)
3886     return CMD_WARNING;
3887
3888   /* Check filter direction. */
3889   if (strncmp (direct_str, "i", 1) == 0)
3890     direct = FILTER_IN;
3891   else if (strncmp (direct_str, "o", 1) == 0)
3892     direct = FILTER_OUT;
3893
3894   ret = peer_aslist_set (peer, afi, safi, direct, name_str);
3895
3896   return bgp_vty_return (vty, ret);
3897 }
3898
3899 static int
3900 peer_aslist_unset_vty (struct vty *vty, const char *ip_str, 
3901                        afi_t afi, safi_t safi,
3902                        const char *direct_str)
3903 {
3904   int ret;
3905   struct peer *peer;
3906   int direct = FILTER_IN;
3907
3908   peer = peer_and_group_lookup_vty (vty, ip_str);
3909   if (! peer)
3910     return CMD_WARNING;
3911
3912   /* Check filter direction. */
3913   if (strncmp (direct_str, "i", 1) == 0)
3914     direct = FILTER_IN;
3915   else if (strncmp (direct_str, "o", 1) == 0)
3916     direct = FILTER_OUT;
3917
3918   ret = peer_aslist_unset (peer, afi, safi, direct);
3919
3920   return bgp_vty_return (vty, ret);
3921 }
3922
3923 DEFUN (neighbor_filter_list,
3924        neighbor_filter_list_cmd,
3925        NEIGHBOR_CMD2 "filter-list WORD (in|out)",
3926        NEIGHBOR_STR
3927        NEIGHBOR_ADDR_STR2
3928        "Establish BGP filters\n"
3929        "AS path access-list name\n"
3930        "Filter incoming routes\n"
3931        "Filter outgoing routes\n")
3932 {
3933   return peer_aslist_set_vty (vty, argv[0], bgp_node_afi (vty),
3934                               bgp_node_safi (vty), argv[1], argv[2]);
3935 }
3936
3937 DEFUN (no_neighbor_filter_list,
3938        no_neighbor_filter_list_cmd,
3939        NO_NEIGHBOR_CMD2 "filter-list WORD (in|out)",
3940        NO_STR
3941        NEIGHBOR_STR
3942        NEIGHBOR_ADDR_STR2
3943        "Establish BGP filters\n"
3944        "AS path access-list name\n"
3945        "Filter incoming routes\n"
3946        "Filter outgoing routes\n")
3947 {
3948   return peer_aslist_unset_vty (vty, argv[0], bgp_node_afi (vty),
3949                                 bgp_node_safi (vty), argv[2]);
3950 }
3951
3952 /* Set route-map to the peer. */
3953 static int
3954 peer_route_map_set_vty (struct vty *vty, const char *ip_str, 
3955                         afi_t afi, safi_t safi,
3956                         const char *name_str, const char *direct_str)
3957 {
3958   int ret;
3959   struct peer *peer;
3960   int direct = RMAP_IN;
3961
3962   peer = peer_and_group_lookup_vty (vty, ip_str);
3963   if (! peer)
3964     return CMD_WARNING;
3965
3966   /* Check filter direction. */
3967   if (strncmp (direct_str, "in", 2) == 0)
3968     direct = RMAP_IN;
3969   else if (strncmp (direct_str, "o", 1) == 0)
3970     direct = RMAP_OUT;
3971   else if (strncmp (direct_str, "im", 2) == 0)
3972     direct = RMAP_IMPORT;
3973   else if (strncmp (direct_str, "e", 1) == 0)
3974     direct = RMAP_EXPORT;
3975
3976   ret = peer_route_map_set (peer, afi, safi, direct, name_str);
3977
3978   return bgp_vty_return (vty, ret);
3979 }
3980
3981 static int
3982 peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
3983                           safi_t safi, const char *direct_str)
3984 {
3985   int ret;
3986   struct peer *peer;
3987   int direct = RMAP_IN;
3988
3989   peer = peer_and_group_lookup_vty (vty, ip_str);
3990   if (! peer)
3991     return CMD_WARNING;
3992
3993   /* Check filter direction. */
3994   if (strncmp (direct_str, "in", 2) == 0)
3995     direct = RMAP_IN;
3996   else if (strncmp (direct_str, "o", 1) == 0)
3997     direct = RMAP_OUT;
3998   else if (strncmp (direct_str, "im", 2) == 0)
3999     direct = RMAP_IMPORT;
4000   else if (strncmp (direct_str, "e", 1) == 0)
4001     direct = RMAP_EXPORT;
4002
4003   ret = peer_route_map_unset (peer, afi, safi, direct);
4004
4005   return bgp_vty_return (vty, ret);
4006 }
4007
4008 DEFUN (neighbor_route_map,
4009        neighbor_route_map_cmd,
4010        NEIGHBOR_CMD2 "route-map WORD (in|out|import|export)",
4011        NEIGHBOR_STR
4012        NEIGHBOR_ADDR_STR2
4013        "Apply route map to neighbor\n"
4014        "Name of route map\n"
4015        "Apply map to incoming routes\n"
4016        "Apply map to outbound routes\n"
4017        "Apply map to routes going into a Route-Server client's table\n"
4018        "Apply map to routes coming from a Route-Server client")
4019 {
4020   return peer_route_map_set_vty (vty, argv[0], bgp_node_afi (vty),
4021                                  bgp_node_safi (vty), argv[1], argv[2]);
4022 }
4023
4024 DEFUN (no_neighbor_route_map,
4025        no_neighbor_route_map_cmd,
4026        NO_NEIGHBOR_CMD2 "route-map WORD (in|out|import|export)",
4027        NO_STR
4028        NEIGHBOR_STR
4029        NEIGHBOR_ADDR_STR2
4030        "Apply route map to neighbor\n"
4031        "Name of route map\n"
4032        "Apply map to incoming routes\n"
4033        "Apply map to outbound routes\n"
4034        "Apply map to routes going into a Route-Server client's table\n"
4035        "Apply map to routes coming from a Route-Server client")
4036 {
4037   return peer_route_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
4038                                    bgp_node_safi (vty), argv[2]);
4039 }
4040
4041 /* Set unsuppress-map to the peer. */
4042 static int
4043 peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
4044                              safi_t safi, const char *name_str)
4045 {
4046   int ret;
4047   struct peer *peer;
4048
4049   peer = peer_and_group_lookup_vty (vty, ip_str);
4050   if (! peer)
4051     return CMD_WARNING;
4052
4053   ret = peer_unsuppress_map_set (peer, afi, safi, name_str);
4054
4055   return bgp_vty_return (vty, ret);
4056 }
4057
4058 /* Unset route-map from the peer. */
4059 static int
4060 peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
4061                                safi_t safi)
4062 {
4063   int ret;
4064   struct peer *peer;
4065
4066   peer = peer_and_group_lookup_vty (vty, ip_str);
4067   if (! peer)
4068     return CMD_WARNING;
4069
4070   ret = peer_unsuppress_map_unset (peer, afi, safi);
4071
4072   return bgp_vty_return (vty, ret);
4073 }
4074
4075 DEFUN (neighbor_unsuppress_map,
4076        neighbor_unsuppress_map_cmd,
4077        NEIGHBOR_CMD2 "unsuppress-map WORD",
4078        NEIGHBOR_STR
4079        NEIGHBOR_ADDR_STR2
4080        "Route-map to selectively unsuppress suppressed routes\n"
4081        "Name of route map\n")
4082 {
4083   return peer_unsuppress_map_set_vty (vty, argv[0], bgp_node_afi (vty),
4084                                       bgp_node_safi (vty), argv[1]);
4085 }
4086
4087 DEFUN (no_neighbor_unsuppress_map,
4088        no_neighbor_unsuppress_map_cmd,
4089        NO_NEIGHBOR_CMD2 "unsuppress-map WORD",
4090        NO_STR
4091        NEIGHBOR_STR
4092        NEIGHBOR_ADDR_STR2
4093        "Route-map to selectively unsuppress suppressed routes\n"
4094        "Name of route map\n")
4095 {
4096   return peer_unsuppress_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
4097                                         bgp_node_safi (vty));
4098 }
4099
4100 static int
4101 peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
4102                              safi_t safi, const char *num_str,  
4103                              const char *threshold_str, int warning,
4104                              const char *restart_str)
4105 {
4106   int ret;
4107   struct peer *peer;
4108   u_int32_t max;
4109   u_char threshold;
4110   u_int16_t restart;
4111
4112   peer = peer_and_group_lookup_vty (vty, ip_str);
4113   if (! peer)
4114     return CMD_WARNING;
4115
4116   VTY_GET_INTEGER ("maximum number", max, num_str);
4117   if (threshold_str)
4118     threshold = atoi (threshold_str);
4119   else
4120     threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT;
4121
4122   if (restart_str)
4123     restart = atoi (restart_str);
4124   else
4125     restart = 0;
4126
4127   ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart);
4128
4129   return bgp_vty_return (vty, ret);
4130 }
4131
4132 static int
4133 peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
4134                                safi_t safi)
4135 {
4136   int ret;
4137   struct peer *peer;
4138
4139   peer = peer_and_group_lookup_vty (vty, ip_str);
4140   if (! peer)
4141     return CMD_WARNING;
4142
4143   ret = peer_maximum_prefix_unset (peer, afi, safi);
4144
4145   return bgp_vty_return (vty, ret);
4146 }
4147
4148 /* Maximum number of prefix configuration.  prefix count is different
4149    for each peer configuration.  So this configuration can be set for
4150    each peer configuration. */
4151 DEFUN (neighbor_maximum_prefix,
4152        neighbor_maximum_prefix_cmd,
4153        NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
4154        NEIGHBOR_STR
4155        NEIGHBOR_ADDR_STR2
4156        "Maximum number of prefix accept from this peer\n"
4157        "maximum no. of prefix limit\n")
4158 {
4159   return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
4160                                       bgp_node_safi (vty), argv[1], NULL, 0,
4161                                       NULL);
4162 }
4163
4164 DEFUN (neighbor_maximum_prefix_threshold,
4165        neighbor_maximum_prefix_threshold_cmd,
4166        NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100>",
4167        NEIGHBOR_STR
4168        NEIGHBOR_ADDR_STR2
4169        "Maximum number of prefix accept from this peer\n"
4170        "maximum no. of prefix limit\n"
4171        "Threshold value (%) at which to generate a warning msg\n")
4172 {
4173   return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
4174                                       bgp_node_safi (vty), argv[1], argv[2], 0,
4175                                       NULL);
4176 }
4177
4178 DEFUN (neighbor_maximum_prefix_warning,
4179        neighbor_maximum_prefix_warning_cmd,
4180        NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
4181        NEIGHBOR_STR
4182        NEIGHBOR_ADDR_STR2
4183        "Maximum number of prefix accept from this peer\n"
4184        "maximum no. of prefix limit\n"
4185        "Only give warning message when limit is exceeded\n")
4186 {
4187   return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
4188                                       bgp_node_safi (vty), argv[1], NULL, 1,
4189                                       NULL);
4190 }
4191
4192 DEFUN (neighbor_maximum_prefix_threshold_warning,
4193        neighbor_maximum_prefix_threshold_warning_cmd,
4194        NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
4195        NEIGHBOR_STR
4196        NEIGHBOR_ADDR_STR2
4197        "Maximum number of prefix accept from this peer\n"
4198        "maximum no. of prefix limit\n"
4199        "Threshold value (%) at which to generate a warning msg\n"
4200        "Only give warning message when limit is exceeded\n")
4201 {
4202   return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
4203                                       bgp_node_safi (vty), argv[1], argv[2], 1, NULL);
4204 }
4205
4206 DEFUN (neighbor_maximum_prefix_restart,
4207        neighbor_maximum_prefix_restart_cmd,
4208        NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
4209        NEIGHBOR_STR
4210        NEIGHBOR_ADDR_STR2
4211        "Maximum number of prefix accept from this peer\n"
4212        "maximum no. of prefix limit\n"
4213        "Restart bgp connection after limit is exceeded\n"
4214        "Restart interval in minutes")
4215 {
4216   return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
4217                                       bgp_node_safi (vty), argv[1], NULL, 0, argv[2]);
4218 }
4219
4220 DEFUN (neighbor_maximum_prefix_threshold_restart,
4221        neighbor_maximum_prefix_threshold_restart_cmd,
4222        NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
4223        NEIGHBOR_STR
4224        NEIGHBOR_ADDR_STR2
4225        "Maximum number of prefix accept from this peer\n"
4226        "maximum no. of prefix limit\n"
4227        "Threshold value (%) at which to generate a warning msg\n"
4228        "Restart bgp connection after limit is exceeded\n"
4229        "Restart interval in minutes")
4230 {
4231   return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
4232                                       bgp_node_safi (vty), argv[1], argv[2], 0, argv[3]);
4233 }
4234
4235 DEFUN (no_neighbor_maximum_prefix,
4236        no_neighbor_maximum_prefix_cmd,
4237        NO_NEIGHBOR_CMD2 "maximum-prefix",
4238        NO_STR
4239        NEIGHBOR_STR
4240        NEIGHBOR_ADDR_STR2
4241        "Maximum number of prefix accept from this peer\n")
4242 {
4243   return peer_maximum_prefix_unset_vty (vty, argv[0], bgp_node_afi (vty),
4244                                         bgp_node_safi (vty));
4245 }
4246  
4247 ALIAS (no_neighbor_maximum_prefix,
4248        no_neighbor_maximum_prefix_val_cmd,
4249        NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
4250        NO_STR
4251        NEIGHBOR_STR
4252        NEIGHBOR_ADDR_STR2
4253        "Maximum number of prefix accept from this peer\n"
4254        "maximum no. of prefix limit\n")
4255
4256 ALIAS (no_neighbor_maximum_prefix,
4257        no_neighbor_maximum_prefix_threshold_cmd,
4258        NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
4259        NO_STR
4260        NEIGHBOR_STR
4261        NEIGHBOR_ADDR_STR2
4262        "Maximum number of prefix accept from this peer\n"
4263        "maximum no. of prefix limit\n"
4264        "Threshold value (%) at which to generate a warning msg\n")
4265
4266 ALIAS (no_neighbor_maximum_prefix,
4267        no_neighbor_maximum_prefix_warning_cmd,
4268        NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
4269        NO_STR
4270        NEIGHBOR_STR
4271        NEIGHBOR_ADDR_STR2
4272        "Maximum number of prefix accept from this peer\n"
4273        "maximum no. of prefix limit\n"
4274        "Only give warning message when limit is exceeded\n")
4275
4276 ALIAS (no_neighbor_maximum_prefix,
4277        no_neighbor_maximum_prefix_threshold_warning_cmd,
4278        NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
4279        NO_STR
4280        NEIGHBOR_STR
4281        NEIGHBOR_ADDR_STR2
4282        "Maximum number of prefix accept from this peer\n"
4283        "maximum no. of prefix limit\n"
4284        "Threshold value (%) at which to generate a warning msg\n"
4285        "Only give warning message when limit is exceeded\n")
4286
4287 ALIAS (no_neighbor_maximum_prefix,
4288        no_neighbor_maximum_prefix_restart_cmd,
4289        NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
4290        NO_STR
4291        NEIGHBOR_STR
4292        NEIGHBOR_ADDR_STR2
4293        "Maximum number of prefix accept from this peer\n"
4294        "maximum no. of prefix limit\n"
4295        "Restart bgp connection after limit is exceeded\n"
4296        "Restart interval in minutes")
4297
4298 ALIAS (no_neighbor_maximum_prefix,
4299        no_neighbor_maximum_prefix_threshold_restart_cmd,
4300        NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
4301        NO_STR
4302        NEIGHBOR_STR
4303        NEIGHBOR_ADDR_STR2
4304        "Maximum number of prefix accept from this peer\n"
4305        "maximum no. of prefix limit\n"
4306        "Threshold value (%) at which to generate a warning msg\n"
4307        "Restart bgp connection after limit is exceeded\n"
4308        "Restart interval in minutes")
4309
4310 /* "neighbor allowas-in" */
4311 DEFUN (neighbor_allowas_in,
4312        neighbor_allowas_in_cmd,
4313        NEIGHBOR_CMD2 "allowas-in",
4314        NEIGHBOR_STR
4315        NEIGHBOR_ADDR_STR2
4316        "Accept as-path with my AS present in it\n")
4317 {
4318   int ret;
4319   struct peer *peer;
4320   unsigned int allow_num;
4321
4322   peer = peer_and_group_lookup_vty (vty, argv[0]);
4323   if (! peer)
4324     return CMD_WARNING;
4325
4326   if (argc == 1)
4327     allow_num = 3;
4328   else
4329     VTY_GET_INTEGER_RANGE ("AS number", allow_num, argv[1], 1, 10);
4330
4331   ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty),
4332                              allow_num);
4333
4334   return bgp_vty_return (vty, ret);
4335 }
4336
4337 ALIAS (neighbor_allowas_in,
4338        neighbor_allowas_in_arg_cmd,
4339        NEIGHBOR_CMD2 "allowas-in <1-10>",
4340        NEIGHBOR_STR
4341        NEIGHBOR_ADDR_STR2
4342        "Accept as-path with my AS present in it\n"
4343        "Number of occurrences of AS number\n")
4344
4345 DEFUN (no_neighbor_allowas_in,
4346        no_neighbor_allowas_in_cmd,
4347        NO_NEIGHBOR_CMD2 "allowas-in",
4348        NO_STR
4349        NEIGHBOR_STR
4350        NEIGHBOR_ADDR_STR2
4351        "allow local ASN appears in aspath attribute\n")
4352 {
4353   int ret;
4354   struct peer *peer;
4355
4356   peer = peer_and_group_lookup_vty (vty, argv[0]);
4357   if (! peer)
4358     return CMD_WARNING;
4359
4360   ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty));
4361
4362   return bgp_vty_return (vty, ret);
4363 }
4364
4365 DEFUN (neighbor_ttl_security,
4366        neighbor_ttl_security_cmd,
4367        NEIGHBOR_CMD2 "ttl-security hops <1-254>",
4368        NEIGHBOR_STR
4369        NEIGHBOR_ADDR_STR2
4370        "Specify the maximum number of hops to the BGP peer\n")
4371 {
4372   struct peer *peer;
4373   int gtsm_hops;
4374
4375   peer = peer_and_group_lookup_vty (vty, argv[0]);
4376   if (! peer)
4377     return CMD_WARNING;
4378     
4379   VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[1], 1, 254);
4380
4381   return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, gtsm_hops));
4382 }
4383
4384 DEFUN (no_neighbor_ttl_security,
4385        no_neighbor_ttl_security_cmd,
4386        NO_NEIGHBOR_CMD2 "ttl-security hops <1-254>",
4387        NO_STR
4388        NEIGHBOR_STR
4389        NEIGHBOR_ADDR_STR2
4390        "Specify the maximum number of hops to the BGP peer\n")
4391 {
4392   struct peer *peer;
4393
4394   peer = peer_and_group_lookup_vty (vty, argv[0]);
4395   if (! peer)
4396     return CMD_WARNING;
4397
4398   return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, 0));
4399 }
4400
4401 /* Address family configuration.  */
4402 DEFUN (address_family_ipv4,
4403        address_family_ipv4_cmd,
4404        "address-family ipv4",
4405        "Enter Address Family command mode\n"
4406        "Address family\n")
4407 {
4408   vty->node = BGP_IPV4_NODE;
4409   return CMD_SUCCESS;
4410 }
4411
4412 DEFUN (address_family_ipv4_safi,
4413        address_family_ipv4_safi_cmd,
4414        "address-family ipv4 (unicast|multicast)",
4415        "Enter Address Family command mode\n"
4416        "Address family\n"
4417        "Address Family modifier\n"
4418        "Address Family modifier\n")
4419 {
4420   if (strncmp (argv[0], "m", 1) == 0)
4421     vty->node = BGP_IPV4M_NODE;
4422   else
4423     vty->node = BGP_IPV4_NODE;
4424
4425   return CMD_SUCCESS;
4426 }
4427
4428 DEFUN (address_family_ipv6,
4429        address_family_ipv6_cmd,
4430        "address-family ipv6",
4431        "Enter Address Family command mode\n"
4432        "Address family\n")
4433 {
4434   vty->node = BGP_IPV6_NODE;
4435   return CMD_SUCCESS;
4436 }
4437
4438 DEFUN (address_family_ipv6_safi,
4439        address_family_ipv6_safi_cmd,
4440        "address-family ipv6 (unicast|multicast)",
4441        "Enter Address Family command mode\n"
4442        "Address family\n"
4443        "Address Family modifier\n"
4444        "Address Family modifier\n")
4445 {
4446   if (strncmp (argv[0], "m", 1) == 0)
4447     vty->node = BGP_IPV6M_NODE;
4448   else
4449     vty->node = BGP_IPV6_NODE;
4450
4451   return CMD_SUCCESS;
4452 }
4453
4454 DEFUN (address_family_vpnv4,
4455        address_family_vpnv4_cmd,
4456        "address-family vpnv4",
4457        "Enter Address Family command mode\n"
4458        "Address family\n")
4459 {
4460   vty->node = BGP_VPNV4_NODE;
4461   return CMD_SUCCESS;
4462 }
4463
4464 ALIAS (address_family_vpnv4,
4465        address_family_vpnv4_unicast_cmd,
4466        "address-family vpnv4 unicast",
4467        "Enter Address Family command mode\n"
4468        "Address family\n"
4469        "Address Family Modifier\n")
4470
4471 DEFUN (address_family_vpnv6,
4472        address_family_vpnv6_cmd,
4473        "address-family vpnv6",
4474        "Enter Address Family command mode\n"
4475        "Address family\n")
4476 {
4477   vty->node = BGP_VPNV6_NODE;
4478   return CMD_SUCCESS;
4479 }
4480
4481 ALIAS (address_family_vpnv6,
4482        address_family_vpnv6_unicast_cmd,
4483        "address-family vpnv6 unicast",
4484        "Enter Address Family command mode\n"
4485        "Address family\n"
4486        "Address Family Modifier\n")
4487
4488 DEFUN (address_family_encap,
4489        address_family_encap_cmd,
4490        "address-family encap",
4491        "Enter Address Family command mode\n"
4492        "Address family\n")
4493 {
4494   vty->node = BGP_ENCAP_NODE;
4495   return CMD_SUCCESS;
4496 }
4497
4498 ALIAS (address_family_encap,
4499        address_family_encapv4_cmd,
4500        "address-family encapv4",
4501        "Enter Address Family command mode\n"
4502        "Address family\n")
4503
4504 DEFUN (address_family_encapv6,
4505        address_family_encapv6_cmd,
4506        "address-family encapv6",
4507        "Enter Address Family command mode\n"
4508        "Address family\n")
4509 {
4510   vty->node = BGP_ENCAPV6_NODE;
4511   return CMD_SUCCESS;
4512 }
4513
4514 DEFUN (exit_address_family,
4515        exit_address_family_cmd,
4516        "exit-address-family",
4517        "Exit from Address Family configuration mode\n")
4518 {
4519   /* should match list in command.c:config_exit */
4520   if (vty->node == BGP_IPV4_NODE
4521       || vty->node == BGP_ENCAP_NODE
4522       || vty->node == BGP_ENCAPV6_NODE
4523       || vty->node == BGP_IPV4M_NODE
4524       || vty->node == BGP_VPNV4_NODE
4525       || vty->node == BGP_VPNV6_NODE
4526       || vty->node == BGP_IPV6_NODE
4527       || vty->node == BGP_IPV6M_NODE)
4528     vty->node = BGP_NODE;
4529   return CMD_SUCCESS;
4530 }
4531
4532 /* BGP clear sort. */
4533 enum clear_sort
4534 {
4535   clear_all,
4536   clear_peer,
4537   clear_group,
4538   clear_external,
4539   clear_as
4540 };
4541
4542 static void
4543 bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi,
4544                      safi_t safi, int error)
4545 {
4546   switch (error)
4547     {
4548     case BGP_ERR_AF_UNCONFIGURED:
4549       vty_out (vty,
4550                "%%BGP: Enable %s %s address family for the neighbor %s%s",
4551                afi == AFI_IP6 ? "IPv6" : safi == SAFI_MPLS_VPN ? "VPNv4" : "IPv4",
4552                safi == SAFI_MULTICAST ? "Multicast" : "Unicast",
4553                peer->host, VTY_NEWLINE);
4554       break;
4555     case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED:
4556       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);
4557       break;
4558     default:
4559       break;
4560     }
4561 }
4562
4563 /* `clear ip bgp' functions. */
4564 static int
4565 bgp_clear (struct vty *vty, struct bgp *bgp,  afi_t afi, safi_t safi,
4566            enum clear_sort sort,enum bgp_clear_type stype, const char *arg)
4567 {
4568   int ret;
4569   struct peer *peer;
4570   struct listnode *node, *nnode;
4571
4572   /* Clear all neighbors. */
4573   if (sort == clear_all)
4574     {
4575       for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
4576         {
4577           if (stype == BGP_CLEAR_SOFT_NONE)
4578             ret = peer_clear (peer);
4579           else
4580             ret = peer_clear_soft (peer, afi, safi, stype);
4581
4582           if (ret < 0)
4583             bgp_clear_vty_error (vty, peer, afi, safi, ret);
4584         }
4585       return CMD_SUCCESS;
4586     }
4587
4588   /* Clear specified neighbors. */
4589   if (sort == clear_peer)
4590     {
4591       union sockunion su;
4592       int ret;
4593
4594       /* Make sockunion for lookup. */
4595       ret = str2sockunion (arg, &su);
4596       if (ret < 0)
4597         {
4598           vty_out (vty, "Malformed address: %s%s", arg, VTY_NEWLINE);
4599           return CMD_WARNING;
4600         }
4601       peer = peer_lookup (bgp, &su);
4602       if (! peer)
4603         {
4604           vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE);
4605           return CMD_WARNING;
4606         }
4607
4608       if (stype == BGP_CLEAR_SOFT_NONE)
4609         ret = peer_clear (peer);
4610       else
4611         ret = peer_clear_soft (peer, afi, safi, stype);
4612
4613       if (ret < 0)
4614         bgp_clear_vty_error (vty, peer, afi, safi, ret);
4615
4616       return CMD_SUCCESS;
4617     }
4618
4619   /* Clear all peer-group members. */
4620   if (sort == clear_group)
4621     {
4622       struct peer_group *group;
4623
4624       group = peer_group_lookup (bgp, arg);
4625       if (! group)
4626         {
4627           vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE);
4628           return CMD_WARNING; 
4629         }
4630
4631       for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
4632         {
4633           if (stype == BGP_CLEAR_SOFT_NONE)
4634             {
4635               ret = peer_clear (peer);
4636               continue;
4637             }
4638
4639           if (! peer->af_group[afi][safi])
4640             continue;
4641
4642           ret = peer_clear_soft (peer, afi, safi, stype);
4643
4644           if (ret < 0)
4645             bgp_clear_vty_error (vty, peer, afi, safi, ret);
4646         }
4647       return CMD_SUCCESS;
4648     }
4649
4650   if (sort == clear_external)
4651     {
4652       for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
4653         {
4654           if (peer->sort == BGP_PEER_IBGP)
4655             continue;
4656
4657           if (stype == BGP_CLEAR_SOFT_NONE)
4658             ret = peer_clear (peer);
4659           else
4660             ret = peer_clear_soft (peer, afi, safi, stype);
4661
4662           if (ret < 0)
4663             bgp_clear_vty_error (vty, peer, afi, safi, ret);
4664         }
4665       return CMD_SUCCESS;
4666     }
4667
4668   if (sort == clear_as)
4669     {
4670       as_t as;
4671       int find = 0;
4672
4673       VTY_GET_INTEGER_RANGE ("AS", as, arg, 1, BGP_AS4_MAX);
4674       
4675       for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
4676         {
4677           if (peer->as != as) 
4678             continue;
4679
4680           find = 1;
4681           if (stype == BGP_CLEAR_SOFT_NONE)
4682             ret = peer_clear (peer);
4683           else
4684             ret = peer_clear_soft (peer, afi, safi, stype);
4685
4686           if (ret < 0)
4687             bgp_clear_vty_error (vty, peer, afi, safi, ret);
4688         }
4689       if (! find)
4690         vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg,
4691                  VTY_NEWLINE);
4692       return CMD_SUCCESS;
4693     }
4694
4695   return CMD_SUCCESS;
4696 }
4697
4698 /* Recalculate bestpath and re-advertise a prefix */
4699 static int
4700 bgp_clear_prefix (struct vty *vty, char *view_name, const char *ip_str,
4701                   afi_t afi, safi_t safi, struct prefix_rd *prd)
4702 {
4703   int ret;
4704   struct prefix match;
4705   struct bgp_node *rn;
4706   struct bgp_node *rm;
4707   struct bgp *bgp;
4708   struct bgp_table *table;
4709   struct bgp_table *rib;
4710
4711   /* BGP structure lookup. */
4712   if (view_name)
4713     {
4714       bgp = bgp_lookup_by_name (view_name);
4715       if (bgp == NULL)
4716         {
4717           vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE);
4718           return CMD_WARNING;
4719         }
4720     }
4721   else
4722     {
4723       bgp = bgp_get_default ();
4724       if (bgp == NULL)
4725         {
4726           vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
4727           return CMD_WARNING;
4728         }
4729     }
4730
4731   /* Check IP address argument. */
4732   ret = str2prefix (ip_str, &match);
4733   if (! ret)
4734     {
4735       vty_out (vty, "%% address is malformed%s", VTY_NEWLINE);
4736       return CMD_WARNING;
4737     }
4738
4739   match.family = afi2family (afi);
4740   rib = bgp->rib[afi][safi];
4741
4742   if (safi == SAFI_MPLS_VPN)
4743     {
4744       for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn))
4745         {
4746           if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
4747             continue;
4748
4749           if ((table = rn->info) != NULL)
4750             {
4751               if ((rm = bgp_node_match (table, &match)) != NULL)
4752                 {
4753                   if (rm->p.prefixlen == match.prefixlen)
4754                     {
4755                       SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR);
4756                       bgp_process (bgp, rm, afi, safi);
4757                     }
4758                   bgp_unlock_node (rm);
4759                 }
4760             }
4761         }
4762     }
4763   else
4764     {
4765       if ((rn = bgp_node_match (rib, &match)) != NULL)
4766         {
4767           if (rn->p.prefixlen == match.prefixlen)
4768             {
4769               SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR);
4770               bgp_process (bgp, rn, afi, safi);
4771             }
4772           bgp_unlock_node (rn);
4773         }
4774     }
4775
4776   return CMD_SUCCESS;
4777 }
4778
4779 static int
4780 bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi,
4781                enum clear_sort sort, enum bgp_clear_type stype, 
4782                const char *arg)
4783 {
4784   struct bgp *bgp;
4785
4786   /* BGP structure lookup. */
4787   if (name)
4788     {
4789       bgp = bgp_lookup_by_name (name);
4790       if (bgp == NULL)
4791         {
4792           vty_out (vty, "Can't find BGP view %s%s", name, VTY_NEWLINE);
4793           return CMD_WARNING;
4794         }
4795     }
4796   else
4797     {
4798       bgp = bgp_get_default ();
4799       if (bgp == NULL)
4800         {
4801           vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
4802           return CMD_WARNING;
4803         }
4804     }
4805
4806   return bgp_clear (vty, bgp, afi, safi, sort, stype, arg);
4807 }
4808   
4809 DEFUN (clear_ip_bgp_all,
4810        clear_ip_bgp_all_cmd,
4811        "clear ip bgp *",
4812        CLEAR_STR
4813        IP_STR
4814        BGP_STR
4815        "Clear all peers\n")
4816 {
4817   if (argc == 1)
4818     return bgp_clear_vty (vty, argv[0], 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);    
4819
4820   return bgp_clear_vty (vty, NULL, 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
4821 }
4822
4823 ALIAS (clear_ip_bgp_all,
4824        clear_bgp_all_cmd,
4825        "clear bgp *",
4826        CLEAR_STR
4827        BGP_STR
4828        "Clear all peers\n")
4829
4830 ALIAS (clear_ip_bgp_all,
4831        clear_bgp_ipv6_all_cmd,
4832        "clear bgp ipv6 *",
4833        CLEAR_STR
4834        BGP_STR
4835        "Address family\n"
4836        "Clear all peers\n")
4837
4838 ALIAS (clear_ip_bgp_all,
4839        clear_ip_bgp_instance_all_cmd,
4840        "clear ip bgp view WORD *",
4841        CLEAR_STR
4842        IP_STR
4843        BGP_STR
4844        "BGP view\n"
4845        "view name\n"
4846        "Clear all peers\n")
4847
4848 ALIAS (clear_ip_bgp_all,
4849        clear_bgp_instance_all_cmd,
4850        "clear bgp view WORD *",
4851        CLEAR_STR
4852        BGP_STR
4853        "BGP view\n"
4854        "view name\n"
4855        "Clear all peers\n")
4856
4857 DEFUN (clear_ip_bgp_peer,
4858        clear_ip_bgp_peer_cmd, 
4859        "clear ip bgp (A.B.C.D|X:X::X:X)",
4860        CLEAR_STR
4861        IP_STR
4862        BGP_STR
4863        "BGP neighbor IP address to clear\n"
4864        "BGP IPv6 neighbor to clear\n")
4865 {
4866   return bgp_clear_vty (vty, NULL, 0, 0, clear_peer, BGP_CLEAR_SOFT_NONE, argv[0]);
4867 }
4868
4869 ALIAS (clear_ip_bgp_peer,
4870        clear_bgp_peer_cmd, 
4871        "clear bgp (A.B.C.D|X:X::X:X)",
4872        CLEAR_STR
4873        BGP_STR
4874        "BGP neighbor address to clear\n"
4875        "BGP IPv6 neighbor to clear\n")
4876
4877 ALIAS (clear_ip_bgp_peer,
4878        clear_bgp_ipv6_peer_cmd, 
4879        "clear bgp ipv6 (A.B.C.D|X:X::X:X)",
4880        CLEAR_STR
4881        BGP_STR
4882        "Address family\n"
4883        "BGP neighbor address to clear\n"
4884        "BGP IPv6 neighbor to clear\n")
4885
4886 DEFUN (clear_ip_bgp_peer_group,
4887        clear_ip_bgp_peer_group_cmd, 
4888        "clear ip bgp peer-group WORD",
4889        CLEAR_STR
4890        IP_STR
4891        BGP_STR
4892        "Clear all members of peer-group\n"
4893        "BGP peer-group name\n")
4894 {
4895   return bgp_clear_vty (vty, NULL, 0, 0, clear_group, BGP_CLEAR_SOFT_NONE, argv[0]);
4896 }
4897
4898 ALIAS (clear_ip_bgp_peer_group,
4899        clear_bgp_peer_group_cmd, 
4900        "clear bgp peer-group WORD",
4901        CLEAR_STR
4902        BGP_STR
4903        "Clear all members of peer-group\n"
4904        "BGP peer-group name\n")
4905
4906 ALIAS (clear_ip_bgp_peer_group,
4907        clear_bgp_ipv6_peer_group_cmd, 
4908        "clear bgp ipv6 peer-group WORD",
4909        CLEAR_STR
4910        BGP_STR
4911        "Address family\n"
4912        "Clear all members of peer-group\n"
4913        "BGP peer-group name\n")
4914
4915 DEFUN (clear_ip_bgp_external,
4916        clear_ip_bgp_external_cmd,
4917        "clear ip bgp external",
4918        CLEAR_STR
4919        IP_STR
4920        BGP_STR
4921        "Clear all external peers\n")
4922 {
4923   return bgp_clear_vty (vty, NULL, 0, 0, clear_external, BGP_CLEAR_SOFT_NONE, NULL);
4924 }
4925
4926 ALIAS (clear_ip_bgp_external,
4927        clear_bgp_external_cmd, 
4928        "clear bgp external",
4929        CLEAR_STR
4930        BGP_STR
4931        "Clear all external peers\n")
4932
4933 ALIAS (clear_ip_bgp_external,
4934        clear_bgp_ipv6_external_cmd, 
4935        "clear bgp ipv6 external",
4936        CLEAR_STR
4937        BGP_STR
4938        "Address family\n"
4939        "Clear all external peers\n")
4940
4941 DEFUN (clear_ip_bgp_prefix,
4942        clear_ip_bgp_prefix_cmd,
4943        "clear ip bgp prefix A.B.C.D/M",
4944        CLEAR_STR
4945        IP_STR
4946        BGP_STR
4947        "Clear bestpath and re-advertise\n"
4948        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4949 {
4950   return bgp_clear_prefix (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL);
4951 }
4952
4953 ALIAS (clear_ip_bgp_prefix,
4954        clear_bgp_prefix_cmd,
4955        "clear bgp prefix A.B.C.D/M",
4956        CLEAR_STR
4957        BGP_STR
4958        "Clear bestpath and re-advertise\n"
4959        "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4960
4961
4962 DEFUN (clear_ip_bgp_as,
4963        clear_ip_bgp_as_cmd,
4964        "clear ip bgp " CMD_AS_RANGE,
4965        CLEAR_STR
4966        IP_STR
4967        BGP_STR
4968        "Clear peers with the AS number\n")
4969 {
4970   return bgp_clear_vty (vty, NULL, 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[0]);
4971 }       
4972
4973 ALIAS (clear_ip_bgp_as,
4974        clear_bgp_as_cmd,
4975        "clear bgp " CMD_AS_RANGE,
4976        CLEAR_STR
4977        BGP_STR
4978        "Clear peers with the AS number\n")
4979
4980 ALIAS (clear_ip_bgp_as,
4981        clear_bgp_ipv6_as_cmd,
4982        "clear bgp ipv6 " CMD_AS_RANGE,
4983        CLEAR_STR
4984        BGP_STR
4985        "Address family\n"
4986        "Clear peers with the AS number\n")
4987
4988 /* Outbound soft-reconfiguration */
4989 DEFUN (clear_ip_bgp_all_soft_out,
4990        clear_ip_bgp_all_soft_out_cmd,
4991        "clear ip bgp * soft out",
4992        CLEAR_STR
4993        IP_STR
4994        BGP_STR
4995        "Clear all peers\n"
4996        BGP_SOFT_STR
4997        BGP_SOFT_OUT_STR)
4998 {
4999   if (argc == 1)
5000     return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5001                           BGP_CLEAR_SOFT_OUT, NULL);
5002
5003   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5004                         BGP_CLEAR_SOFT_OUT, NULL);
5005 }
5006
5007 ALIAS (clear_ip_bgp_all_soft_out,
5008        clear_ip_bgp_all_out_cmd,
5009        "clear ip bgp * out",
5010        CLEAR_STR
5011        IP_STR
5012        BGP_STR
5013        "Clear all peers\n"
5014        BGP_SOFT_OUT_STR)
5015
5016 ALIAS (clear_ip_bgp_all_soft_out,
5017        clear_ip_bgp_instance_all_soft_out_cmd,
5018        "clear ip bgp view WORD * soft out",
5019        CLEAR_STR
5020        IP_STR
5021        BGP_STR
5022        "BGP view\n"
5023        "view name\n"
5024        "Clear all peers\n"
5025        BGP_SOFT_STR
5026        BGP_SOFT_OUT_STR)
5027
5028 DEFUN (clear_ip_bgp_all_ipv4_soft_out,
5029        clear_ip_bgp_all_ipv4_soft_out_cmd,
5030        "clear ip bgp * ipv4 (unicast|multicast) soft out",
5031        CLEAR_STR
5032        IP_STR
5033        BGP_STR
5034        "Clear all peers\n"
5035        "Address family\n"
5036        "Address Family modifier\n"
5037        "Address Family modifier\n"
5038        BGP_SOFT_STR
5039        BGP_SOFT_OUT_STR)
5040 {
5041   if (strncmp (argv[0], "m", 1) == 0)
5042     return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
5043                           BGP_CLEAR_SOFT_OUT, NULL);
5044
5045   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5046                         BGP_CLEAR_SOFT_OUT, NULL);
5047 }
5048
5049 ALIAS (clear_ip_bgp_all_ipv4_soft_out,
5050        clear_ip_bgp_all_ipv4_out_cmd,
5051        "clear ip bgp * ipv4 (unicast|multicast) out",
5052        CLEAR_STR
5053        IP_STR
5054        BGP_STR
5055        "Clear all peers\n"
5056        "Address family\n"
5057        "Address Family modifier\n"
5058        "Address Family modifier\n"
5059        BGP_SOFT_OUT_STR)
5060
5061 DEFUN (clear_ip_bgp_instance_all_ipv4_soft_out,
5062        clear_ip_bgp_instance_all_ipv4_soft_out_cmd,
5063        "clear ip bgp view WORD * ipv4 (unicast|multicast) soft out",
5064        CLEAR_STR
5065        IP_STR
5066        BGP_STR
5067        "BGP view\n"
5068        "view name\n"
5069        "Clear all peers\n"
5070        "Address family\n"
5071        "Address Family modifier\n"
5072        "Address Family modifier\n"
5073        BGP_SOFT_OUT_STR)
5074 {
5075   if (strncmp (argv[1], "m", 1) == 0)
5076     return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
5077                           BGP_CLEAR_SOFT_OUT, NULL);
5078
5079   return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5080                         BGP_CLEAR_SOFT_OUT, NULL);
5081 }
5082
5083 DEFUN (clear_ip_bgp_all_vpnv4_soft_out,
5084        clear_ip_bgp_all_vpnv4_soft_out_cmd,
5085        "clear ip bgp * vpnv4 unicast soft out",
5086        CLEAR_STR
5087        IP_STR
5088        BGP_STR
5089        "Clear all peers\n"
5090        "Address family\n"
5091        "Address Family Modifier\n"
5092        BGP_SOFT_STR
5093        BGP_SOFT_OUT_STR)
5094 {
5095   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
5096                         BGP_CLEAR_SOFT_OUT, NULL);
5097 }
5098
5099 ALIAS (clear_ip_bgp_all_vpnv4_soft_out,
5100        clear_ip_bgp_all_vpnv4_out_cmd,
5101        "clear ip bgp * vpnv4 unicast out",
5102        CLEAR_STR
5103        IP_STR
5104        BGP_STR
5105        "Clear all peers\n"
5106        "Address family\n"
5107        "Address Family Modifier\n"
5108        BGP_SOFT_OUT_STR)
5109
5110 DEFUN (clear_ip_bgp_all_encap_soft_out,
5111        clear_ip_bgp_all_encap_soft_out_cmd,
5112        "clear ip bgp * encap unicast soft out",
5113        CLEAR_STR
5114        IP_STR
5115        BGP_STR
5116        "Clear all peers\n"
5117        "Address family\n"
5118        "Address Family Modifier\n"
5119        "Soft reconfig\n"
5120        "Soft reconfig outbound update\n")
5121 {
5122   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_all,
5123                         BGP_CLEAR_SOFT_OUT, NULL);
5124 }
5125
5126 ALIAS (clear_ip_bgp_all_encap_soft_out,
5127        clear_ip_bgp_all_encap_out_cmd,
5128        "clear ip bgp * encap unicast out",
5129        CLEAR_STR
5130        IP_STR
5131        BGP_STR
5132        "Clear all peers\n"
5133        "Address family\n"
5134        "Address Family Modifier\n"
5135        "Soft reconfig outbound update\n")
5136
5137 DEFUN (clear_bgp_all_soft_out,
5138        clear_bgp_all_soft_out_cmd,
5139        "clear bgp * soft out",
5140        CLEAR_STR
5141        BGP_STR
5142        "Clear all peers\n"
5143        BGP_SOFT_STR
5144        BGP_SOFT_OUT_STR)
5145 {
5146   if (argc == 1)
5147     return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
5148                           BGP_CLEAR_SOFT_OUT, NULL);
5149
5150   return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
5151                         BGP_CLEAR_SOFT_OUT, NULL);
5152 }
5153
5154 ALIAS (clear_bgp_all_soft_out,
5155        clear_bgp_instance_all_soft_out_cmd,
5156        "clear bgp view WORD * soft out",
5157        CLEAR_STR
5158        BGP_STR
5159        "BGP view\n"
5160        "view name\n"
5161        "Clear all peers\n"
5162        BGP_SOFT_STR
5163        BGP_SOFT_OUT_STR)
5164
5165 ALIAS (clear_bgp_all_soft_out,
5166        clear_bgp_all_out_cmd,
5167        "clear bgp * out",
5168        CLEAR_STR
5169        BGP_STR
5170        "Clear all peers\n"
5171        BGP_SOFT_OUT_STR)
5172
5173 ALIAS (clear_bgp_all_soft_out,
5174        clear_bgp_ipv6_all_soft_out_cmd,
5175        "clear bgp ipv6 * soft out",
5176        CLEAR_STR
5177        BGP_STR
5178        "Address family\n"
5179        "Clear all peers\n"
5180        BGP_SOFT_STR
5181        BGP_SOFT_OUT_STR)
5182
5183 ALIAS (clear_bgp_all_soft_out,
5184        clear_bgp_ipv6_all_out_cmd,
5185        "clear bgp ipv6 * out",
5186        CLEAR_STR
5187        BGP_STR
5188        "Address family\n"
5189        "Clear all peers\n"
5190        BGP_SOFT_OUT_STR)
5191
5192 DEFUN (clear_bgp_ipv6_safi_prefix,
5193        clear_bgp_ipv6_safi_prefix_cmd,
5194        "clear bgp ipv6 (unicast|multicast) prefix X:X::X:X/M",
5195        CLEAR_STR
5196        BGP_STR
5197        "Address family\n"
5198        "Address Family Modifier\n"
5199        "Clear bestpath and re-advertise\n"
5200        "IPv6 prefix <network>/<length>,  e.g.,  3ffe::/16\n")
5201 {
5202   if (strncmp (argv[0], "m", 1) == 0)
5203     return bgp_clear_prefix (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL);
5204   else
5205     return bgp_clear_prefix (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL);
5206 }
5207
5208 DEFUN (clear_ip_bgp_peer_soft_out,
5209        clear_ip_bgp_peer_soft_out_cmd,
5210        "clear ip bgp A.B.C.D soft out",
5211        CLEAR_STR
5212        IP_STR
5213        BGP_STR
5214        "BGP neighbor address to clear\n"
5215        BGP_SOFT_STR
5216        BGP_SOFT_OUT_STR)
5217 {
5218   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5219                         BGP_CLEAR_SOFT_OUT, argv[0]);
5220 }
5221
5222 ALIAS (clear_ip_bgp_peer_soft_out,
5223        clear_ip_bgp_peer_out_cmd,
5224        "clear ip bgp A.B.C.D out",
5225        CLEAR_STR
5226        IP_STR
5227        BGP_STR
5228        "BGP neighbor address to clear\n"
5229        BGP_SOFT_OUT_STR)
5230
5231 DEFUN (clear_ip_bgp_peer_ipv4_soft_out,
5232        clear_ip_bgp_peer_ipv4_soft_out_cmd,
5233        "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft out",
5234        CLEAR_STR
5235        IP_STR
5236        BGP_STR
5237        "BGP neighbor address to clear\n"
5238        "Address family\n"
5239        "Address Family modifier\n"
5240        "Address Family modifier\n"
5241        BGP_SOFT_STR
5242        BGP_SOFT_OUT_STR)
5243 {
5244   if (strncmp (argv[1], "m", 1) == 0)
5245     return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
5246                           BGP_CLEAR_SOFT_OUT, argv[0]);
5247
5248   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5249                         BGP_CLEAR_SOFT_OUT, argv[0]);
5250 }
5251
5252 ALIAS (clear_ip_bgp_peer_ipv4_soft_out,
5253        clear_ip_bgp_peer_ipv4_out_cmd,
5254        "clear ip bgp A.B.C.D ipv4 (unicast|multicast) out",
5255        CLEAR_STR
5256        IP_STR
5257        BGP_STR
5258        "BGP neighbor address to clear\n"
5259        "Address family\n"
5260        "Address Family modifier\n"
5261        "Address Family modifier\n"
5262        BGP_SOFT_OUT_STR)
5263
5264 DEFUN (clear_ip_bgp_peer_vpnv4_soft_out,
5265        clear_ip_bgp_peer_vpnv4_soft_out_cmd,
5266        "clear ip bgp A.B.C.D vpnv4 unicast soft out",
5267        CLEAR_STR
5268        IP_STR
5269        BGP_STR
5270        "BGP neighbor address to clear\n"
5271        "Address family\n"
5272        "Address Family Modifier\n"
5273        BGP_SOFT_STR
5274        BGP_SOFT_OUT_STR)
5275 {
5276   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
5277                         BGP_CLEAR_SOFT_OUT, argv[0]);
5278 }
5279
5280 ALIAS (clear_ip_bgp_peer_vpnv4_soft_out,
5281        clear_ip_bgp_peer_vpnv4_out_cmd,
5282        "clear ip bgp A.B.C.D vpnv4 unicast out",
5283        CLEAR_STR
5284        IP_STR
5285        BGP_STR
5286        "BGP neighbor address to clear\n"
5287        "Address family\n"
5288        "Address Family Modifier\n"
5289        BGP_SOFT_OUT_STR)
5290
5291 DEFUN (clear_ip_bgp_peer_encap_soft_out,
5292        clear_ip_bgp_peer_encap_soft_out_cmd,
5293        "clear ip bgp A.B.C.D encap unicast soft out",
5294        CLEAR_STR
5295        IP_STR
5296        BGP_STR
5297        "BGP neighbor address to clear\n"
5298        "Address family\n"
5299        "Address Family Modifier\n"
5300        "Soft reconfig\n"
5301        "Soft reconfig outbound update\n")
5302 {
5303   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_peer,
5304                         BGP_CLEAR_SOFT_OUT, argv[0]);
5305 }
5306
5307 ALIAS (clear_ip_bgp_peer_encap_soft_out,
5308        clear_ip_bgp_peer_encap_out_cmd,
5309        "clear ip bgp A.B.C.D encap unicast out",
5310        CLEAR_STR
5311        IP_STR
5312        BGP_STR
5313        "BGP neighbor address to clear\n"
5314        "Address family\n"
5315        "Address Family Modifier\n"
5316        "Soft reconfig outbound update\n")
5317
5318 DEFUN (clear_bgp_peer_soft_out,
5319        clear_bgp_peer_soft_out_cmd,
5320        "clear bgp (A.B.C.D|X:X::X:X) soft out",
5321        CLEAR_STR
5322        BGP_STR
5323        "BGP neighbor address to clear\n"
5324        "BGP IPv6 neighbor to clear\n"
5325        BGP_SOFT_STR
5326        BGP_SOFT_OUT_STR)
5327 {
5328   return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
5329                         BGP_CLEAR_SOFT_OUT, argv[0]);
5330 }
5331
5332 ALIAS (clear_bgp_peer_soft_out,
5333        clear_bgp_ipv6_peer_soft_out_cmd,
5334        "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft out",
5335        CLEAR_STR
5336        BGP_STR
5337        "Address family\n"
5338        "BGP neighbor address to clear\n"
5339        "BGP IPv6 neighbor to clear\n"
5340        BGP_SOFT_STR
5341        BGP_SOFT_OUT_STR)
5342
5343 ALIAS (clear_bgp_peer_soft_out,
5344        clear_bgp_peer_out_cmd,
5345        "clear bgp (A.B.C.D|X:X::X:X) out",
5346        CLEAR_STR
5347        BGP_STR
5348        "BGP neighbor address to clear\n"
5349        "BGP IPv6 neighbor to clear\n"
5350        BGP_SOFT_OUT_STR)
5351
5352 ALIAS (clear_bgp_peer_soft_out,
5353        clear_bgp_ipv6_peer_out_cmd,
5354        "clear bgp ipv6 (A.B.C.D|X:X::X:X) out",
5355        CLEAR_STR
5356        BGP_STR
5357        "Address family\n"
5358        "BGP neighbor address to clear\n"
5359        "BGP IPv6 neighbor to clear\n"
5360        BGP_SOFT_OUT_STR)
5361
5362 DEFUN (clear_ip_bgp_peer_group_soft_out,
5363        clear_ip_bgp_peer_group_soft_out_cmd, 
5364        "clear ip bgp peer-group WORD soft out",
5365        CLEAR_STR
5366        IP_STR
5367        BGP_STR
5368        "Clear all members of peer-group\n"
5369        "BGP peer-group name\n"
5370        BGP_SOFT_STR
5371        BGP_SOFT_OUT_STR)
5372 {
5373   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5374                         BGP_CLEAR_SOFT_OUT, argv[0]);
5375 }
5376
5377 ALIAS (clear_ip_bgp_peer_group_soft_out,
5378        clear_ip_bgp_peer_group_out_cmd, 
5379        "clear ip bgp peer-group WORD out",
5380        CLEAR_STR
5381        IP_STR
5382        BGP_STR
5383        "Clear all members of peer-group\n"
5384        "BGP peer-group name\n"
5385        BGP_SOFT_OUT_STR)
5386
5387 DEFUN (clear_ip_bgp_peer_group_ipv4_soft_out,
5388        clear_ip_bgp_peer_group_ipv4_soft_out_cmd,
5389        "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft out",
5390        CLEAR_STR
5391        IP_STR
5392        BGP_STR
5393        "Clear all members of peer-group\n"
5394        "BGP peer-group name\n"
5395        "Address family\n"
5396        "Address Family modifier\n"
5397        "Address Family modifier\n"
5398        BGP_SOFT_STR
5399        BGP_SOFT_OUT_STR)
5400 {
5401   if (strncmp (argv[1], "m", 1) == 0)
5402     return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
5403                           BGP_CLEAR_SOFT_OUT, argv[0]);
5404
5405   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5406                         BGP_CLEAR_SOFT_OUT, argv[0]);
5407 }
5408
5409 ALIAS (clear_ip_bgp_peer_group_ipv4_soft_out,
5410        clear_ip_bgp_peer_group_ipv4_out_cmd,
5411        "clear ip bgp peer-group WORD ipv4 (unicast|multicast) out",
5412        CLEAR_STR
5413        IP_STR
5414        BGP_STR
5415        "Clear all members of peer-group\n"
5416        "BGP peer-group name\n"
5417        "Address family\n"
5418        "Address Family modifier\n"
5419        "Address Family modifier\n"
5420        BGP_SOFT_OUT_STR)
5421
5422 DEFUN (clear_bgp_peer_group_soft_out,
5423        clear_bgp_peer_group_soft_out_cmd,
5424        "clear bgp peer-group WORD soft out",
5425        CLEAR_STR
5426        BGP_STR
5427        "Clear all members of peer-group\n"
5428        "BGP peer-group name\n"
5429        BGP_SOFT_STR
5430        BGP_SOFT_OUT_STR)
5431 {
5432   return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
5433                         BGP_CLEAR_SOFT_OUT, argv[0]);
5434 }
5435
5436 ALIAS (clear_bgp_peer_group_soft_out,
5437        clear_bgp_ipv6_peer_group_soft_out_cmd,
5438        "clear bgp ipv6 peer-group WORD soft out",
5439        CLEAR_STR
5440        BGP_STR
5441        "Address family\n"
5442        "Clear all members of peer-group\n"
5443        "BGP peer-group name\n"
5444        BGP_SOFT_STR
5445        BGP_SOFT_OUT_STR)
5446
5447 ALIAS (clear_bgp_peer_group_soft_out,
5448        clear_bgp_peer_group_out_cmd,
5449        "clear bgp peer-group WORD out",
5450        CLEAR_STR
5451        BGP_STR
5452        "Clear all members of peer-group\n"
5453        "BGP peer-group name\n"
5454        BGP_SOFT_OUT_STR)
5455
5456 ALIAS (clear_bgp_peer_group_soft_out,
5457        clear_bgp_ipv6_peer_group_out_cmd,
5458        "clear bgp ipv6 peer-group WORD out",
5459        CLEAR_STR
5460        BGP_STR
5461        "Address family\n"
5462        "Clear all members of peer-group\n"
5463        "BGP peer-group name\n"
5464        BGP_SOFT_OUT_STR)
5465
5466 DEFUN (clear_ip_bgp_external_soft_out,
5467        clear_ip_bgp_external_soft_out_cmd, 
5468        "clear ip bgp external soft out",
5469        CLEAR_STR
5470        IP_STR
5471        BGP_STR
5472        "Clear all external peers\n"
5473        BGP_SOFT_STR
5474        BGP_SOFT_OUT_STR)
5475 {
5476   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5477                         BGP_CLEAR_SOFT_OUT, NULL);
5478 }
5479
5480 ALIAS (clear_ip_bgp_external_soft_out,
5481        clear_ip_bgp_external_out_cmd, 
5482        "clear ip bgp external out",
5483        CLEAR_STR
5484        IP_STR
5485        BGP_STR
5486        "Clear all external peers\n"
5487        BGP_SOFT_OUT_STR)
5488
5489 DEFUN (clear_ip_bgp_external_ipv4_soft_out,
5490        clear_ip_bgp_external_ipv4_soft_out_cmd,
5491        "clear ip bgp external ipv4 (unicast|multicast) soft out",
5492        CLEAR_STR
5493        IP_STR
5494        BGP_STR
5495        "Clear all external peers\n"
5496        "Address family\n"
5497        "Address Family modifier\n"
5498        "Address Family modifier\n"
5499        BGP_SOFT_STR
5500        BGP_SOFT_OUT_STR)
5501 {
5502   if (strncmp (argv[0], "m", 1) == 0)
5503     return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
5504                           BGP_CLEAR_SOFT_OUT, NULL);
5505
5506   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5507                         BGP_CLEAR_SOFT_OUT, NULL);
5508 }
5509
5510 ALIAS (clear_ip_bgp_external_ipv4_soft_out,
5511        clear_ip_bgp_external_ipv4_out_cmd,
5512        "clear ip bgp external ipv4 (unicast|multicast) out",
5513        CLEAR_STR
5514        IP_STR
5515        BGP_STR
5516        "Clear all external peers\n"
5517        "Address family\n"
5518        "Address Family modifier\n"
5519        "Address Family modifier\n"
5520        BGP_SOFT_OUT_STR)
5521
5522 DEFUN (clear_bgp_external_soft_out,
5523        clear_bgp_external_soft_out_cmd,
5524        "clear bgp external soft out",
5525        CLEAR_STR
5526        BGP_STR
5527        "Clear all external peers\n"
5528        BGP_SOFT_STR
5529        BGP_SOFT_OUT_STR)
5530 {
5531   return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
5532                         BGP_CLEAR_SOFT_OUT, NULL);
5533 }
5534
5535 ALIAS (clear_bgp_external_soft_out,
5536        clear_bgp_ipv6_external_soft_out_cmd,
5537        "clear bgp ipv6 external soft out",
5538        CLEAR_STR
5539        BGP_STR
5540        "Address family\n"
5541        "Clear all external peers\n"
5542        BGP_SOFT_STR
5543        BGP_SOFT_OUT_STR)
5544
5545 ALIAS (clear_bgp_external_soft_out,
5546        clear_bgp_external_out_cmd,
5547        "clear bgp external out",
5548        CLEAR_STR
5549        BGP_STR
5550        "Clear all external peers\n"
5551        BGP_SOFT_OUT_STR)
5552
5553 ALIAS (clear_bgp_external_soft_out,
5554        clear_bgp_ipv6_external_out_cmd,
5555        "clear bgp ipv6 external WORD out",
5556        CLEAR_STR
5557        BGP_STR
5558        "Address family\n"
5559        "Clear all external peers\n"
5560        BGP_SOFT_OUT_STR)
5561
5562 DEFUN (clear_ip_bgp_as_soft_out,
5563        clear_ip_bgp_as_soft_out_cmd,
5564        "clear ip bgp " CMD_AS_RANGE " soft out",
5565        CLEAR_STR
5566        IP_STR
5567        BGP_STR
5568        "Clear peers with the AS number\n"
5569        BGP_SOFT_STR
5570        BGP_SOFT_OUT_STR)
5571 {
5572   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5573                         BGP_CLEAR_SOFT_OUT, argv[0]);
5574 }
5575
5576 ALIAS (clear_ip_bgp_as_soft_out,
5577        clear_ip_bgp_as_out_cmd,
5578        "clear ip bgp " CMD_AS_RANGE " out",
5579        CLEAR_STR
5580        IP_STR
5581        BGP_STR
5582        "Clear peers with the AS number\n"
5583        BGP_SOFT_OUT_STR)
5584
5585 DEFUN (clear_ip_bgp_as_ipv4_soft_out,
5586        clear_ip_bgp_as_ipv4_soft_out_cmd,
5587        "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft out",
5588        CLEAR_STR
5589        IP_STR
5590        BGP_STR
5591        "Clear peers with the AS number\n"
5592        "Address family\n"
5593        "Address Family modifier\n"
5594        "Address Family modifier\n"
5595        BGP_SOFT_STR
5596        BGP_SOFT_OUT_STR)
5597 {
5598   if (strncmp (argv[1], "m", 1) == 0)
5599     return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
5600                           BGP_CLEAR_SOFT_OUT, argv[0]);
5601
5602   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5603                         BGP_CLEAR_SOFT_OUT, argv[0]);
5604 }
5605
5606 ALIAS (clear_ip_bgp_as_ipv4_soft_out,
5607        clear_ip_bgp_as_ipv4_out_cmd,
5608        "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) out",
5609        CLEAR_STR
5610        IP_STR
5611        BGP_STR
5612        "Clear peers with the AS number\n"
5613        "Address family\n"
5614        "Address Family modifier\n"
5615        "Address Family modifier\n"
5616        BGP_SOFT_OUT_STR)
5617
5618 DEFUN (clear_ip_bgp_as_vpnv4_soft_out,
5619        clear_ip_bgp_as_vpnv4_soft_out_cmd,
5620        "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft out",
5621        CLEAR_STR
5622        IP_STR
5623        BGP_STR
5624        "Clear peers with the AS number\n"
5625        "Address family\n"
5626        "Address Family modifier\n"
5627        BGP_SOFT_STR
5628        BGP_SOFT_OUT_STR)
5629 {
5630   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
5631                         BGP_CLEAR_SOFT_OUT, argv[0]);
5632 }
5633
5634 ALIAS (clear_ip_bgp_as_vpnv4_soft_out,
5635        clear_ip_bgp_as_vpnv4_out_cmd,
5636        "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast out",
5637        CLEAR_STR
5638        IP_STR
5639        BGP_STR
5640        "Clear peers with the AS number\n"
5641        "Address family\n"
5642        "Address Family modifier\n"
5643        BGP_SOFT_OUT_STR)
5644
5645 DEFUN (clear_ip_bgp_as_encap_soft_out,
5646        clear_ip_bgp_as_encap_soft_out_cmd,
5647        "clear ip bgp " CMD_AS_RANGE " encap unicast soft out",
5648        CLEAR_STR
5649        IP_STR
5650        BGP_STR
5651        "Clear peers with the AS number\n"
5652        "Address family\n"
5653        "Address Family modifier\n"
5654        "Soft reconfig\n"
5655        "Soft reconfig outbound update\n")
5656 {
5657   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_as,
5658                         BGP_CLEAR_SOFT_OUT, argv[0]);
5659 }
5660
5661 ALIAS (clear_ip_bgp_as_encap_soft_out,
5662        clear_ip_bgp_as_encap_out_cmd,
5663        "clear ip bgp " CMD_AS_RANGE " encap unicast out",
5664        CLEAR_STR
5665        IP_STR
5666        BGP_STR
5667        "Clear peers with the AS number\n"
5668        "Address family\n"
5669        "Address Family modifier\n"
5670        "Soft reconfig outbound update\n")
5671
5672 DEFUN (clear_bgp_as_soft_out,
5673        clear_bgp_as_soft_out_cmd,
5674        "clear bgp " CMD_AS_RANGE " soft out",
5675        CLEAR_STR
5676        BGP_STR
5677        "Clear peers with the AS number\n"
5678        BGP_SOFT_STR
5679        BGP_SOFT_OUT_STR)
5680 {
5681   return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
5682                         BGP_CLEAR_SOFT_OUT, argv[0]);
5683 }
5684
5685 ALIAS (clear_bgp_as_soft_out,
5686        clear_bgp_ipv6_as_soft_out_cmd,
5687        "clear bgp ipv6 " CMD_AS_RANGE " soft out",
5688        CLEAR_STR
5689        BGP_STR
5690        "Address family\n"
5691        "Clear peers with the AS number\n"
5692        BGP_SOFT_STR
5693        BGP_SOFT_OUT_STR)
5694
5695 ALIAS (clear_bgp_as_soft_out,
5696        clear_bgp_as_out_cmd,
5697        "clear bgp " CMD_AS_RANGE " out",
5698        CLEAR_STR
5699        BGP_STR
5700        "Clear peers with the AS number\n"
5701        BGP_SOFT_OUT_STR)
5702
5703 ALIAS (clear_bgp_as_soft_out,
5704        clear_bgp_ipv6_as_out_cmd,
5705        "clear bgp ipv6 " CMD_AS_RANGE " out",
5706        CLEAR_STR
5707        BGP_STR
5708        "Address family\n"
5709        "Clear peers with the AS number\n"
5710        BGP_SOFT_OUT_STR)
5711
5712 /* Inbound soft-reconfiguration */
5713 DEFUN (clear_ip_bgp_all_soft_in,
5714        clear_ip_bgp_all_soft_in_cmd,
5715        "clear ip bgp * soft in",
5716        CLEAR_STR
5717        IP_STR
5718        BGP_STR
5719        "Clear all peers\n"
5720        BGP_SOFT_STR
5721        BGP_SOFT_IN_STR)
5722 {
5723   if (argc == 1)
5724     return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5725                           BGP_CLEAR_SOFT_IN, NULL);
5726
5727   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5728                         BGP_CLEAR_SOFT_IN, NULL);
5729 }
5730
5731 ALIAS (clear_ip_bgp_all_soft_in,
5732        clear_ip_bgp_instance_all_soft_in_cmd,
5733        "clear ip bgp view WORD * soft in",
5734        CLEAR_STR
5735        IP_STR
5736        BGP_STR
5737        "BGP view\n"
5738        "view name\n"
5739        "Clear all peers\n"
5740        BGP_SOFT_STR
5741        BGP_SOFT_IN_STR)
5742
5743 ALIAS (clear_ip_bgp_all_soft_in,
5744        clear_ip_bgp_all_in_cmd,
5745        "clear ip bgp * in",
5746        CLEAR_STR
5747        IP_STR
5748        BGP_STR
5749        "Clear all peers\n"
5750        BGP_SOFT_IN_STR)
5751
5752 DEFUN (clear_ip_bgp_all_in_prefix_filter,
5753        clear_ip_bgp_all_in_prefix_filter_cmd,
5754        "clear ip bgp * in prefix-filter",
5755        CLEAR_STR
5756        IP_STR
5757        BGP_STR
5758        "Clear all peers\n"
5759        BGP_SOFT_IN_STR
5760        "Push out prefix-list ORF and do inbound soft reconfig\n")
5761 {
5762   if (argc== 1)
5763     return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5764                           BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5765
5766   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5767                         BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5768 }
5769
5770 ALIAS (clear_ip_bgp_all_in_prefix_filter,
5771        clear_ip_bgp_instance_all_in_prefix_filter_cmd,
5772        "clear ip bgp view WORD * in prefix-filter",
5773        CLEAR_STR
5774        IP_STR
5775        BGP_STR
5776        "BGP view\n"
5777        "view name\n"
5778        "Clear all peers\n"
5779        BGP_SOFT_IN_STR
5780        "Push out prefix-list ORF and do inbound soft reconfig\n")
5781
5782
5783 DEFUN (clear_ip_bgp_all_ipv4_soft_in,
5784        clear_ip_bgp_all_ipv4_soft_in_cmd,
5785        "clear ip bgp * ipv4 (unicast|multicast) soft in",
5786        CLEAR_STR
5787        IP_STR
5788        BGP_STR
5789        "Clear all peers\n"
5790        "Address family\n"
5791        "Address Family modifier\n"
5792        "Address Family modifier\n"
5793        BGP_SOFT_STR
5794        BGP_SOFT_IN_STR)
5795 {
5796   if (strncmp (argv[0], "m", 1) == 0)
5797     return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
5798                           BGP_CLEAR_SOFT_IN, NULL);
5799
5800   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5801                         BGP_CLEAR_SOFT_IN, NULL);
5802 }
5803
5804 ALIAS (clear_ip_bgp_all_ipv4_soft_in,
5805        clear_ip_bgp_all_ipv4_in_cmd,
5806        "clear ip bgp * ipv4 (unicast|multicast) in",
5807        CLEAR_STR
5808        IP_STR
5809        BGP_STR
5810        "Clear all peers\n"
5811        "Address family\n"
5812        "Address Family modifier\n"
5813        "Address Family modifier\n"
5814        BGP_SOFT_IN_STR)
5815
5816 DEFUN (clear_ip_bgp_instance_all_ipv4_soft_in,
5817        clear_ip_bgp_instance_all_ipv4_soft_in_cmd,
5818        "clear ip bgp view WORD * ipv4 (unicast|multicast) soft in",
5819        CLEAR_STR
5820        IP_STR
5821        BGP_STR
5822        "BGP view\n"
5823        "view name\n"
5824        "Clear all peers\n"
5825        "Address family\n"
5826        "Address Family modifier\n"
5827        "Address Family modifier\n"
5828        BGP_SOFT_STR
5829        BGP_SOFT_IN_STR)
5830 {
5831   if (strncmp (argv[1], "m", 1) == 0)
5832     return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
5833                           BGP_CLEAR_SOFT_IN, NULL);
5834
5835   return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5836                         BGP_CLEAR_SOFT_IN, NULL);
5837 }
5838
5839 DEFUN (clear_ip_bgp_all_ipv4_in_prefix_filter,
5840        clear_ip_bgp_all_ipv4_in_prefix_filter_cmd,
5841        "clear ip bgp * ipv4 (unicast|multicast) in prefix-filter",
5842        CLEAR_STR
5843        IP_STR
5844        BGP_STR
5845        "Clear all peers\n"
5846        "Address family\n"
5847        "Address Family modifier\n"
5848        "Address Family modifier\n"
5849        BGP_SOFT_IN_STR
5850        "Push out prefix-list ORF and do inbound soft reconfig\n")
5851 {
5852   if (strncmp (argv[0], "m", 1) == 0)
5853     return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
5854                           BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5855
5856   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5857                         BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5858 }
5859
5860 DEFUN (clear_ip_bgp_instance_all_ipv4_in_prefix_filter,
5861        clear_ip_bgp_instance_all_ipv4_in_prefix_filter_cmd,
5862        "clear ip bgp view WORD * ipv4 (unicast|multicast) in prefix-filter",
5863        CLEAR_STR
5864        IP_STR
5865        BGP_STR
5866        "Clear all peers\n"
5867        "Address family\n"
5868        "Address Family modifier\n"
5869        "Address Family modifier\n"
5870        BGP_SOFT_IN_STR
5871        "Push out prefix-list ORF and do inbound soft reconfig\n")
5872 {
5873   if (strncmp (argv[1], "m", 1) == 0)
5874     return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
5875                           BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5876
5877   return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5878                         BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5879 }
5880
5881 DEFUN (clear_ip_bgp_all_vpnv4_soft_in,
5882        clear_ip_bgp_all_vpnv4_soft_in_cmd,
5883        "clear ip bgp * vpnv4 unicast soft in",
5884        CLEAR_STR
5885        IP_STR
5886        BGP_STR
5887        "Clear all peers\n"
5888        "Address family\n"
5889        "Address Family Modifier\n"
5890        BGP_SOFT_STR
5891        BGP_SOFT_IN_STR)
5892 {
5893   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
5894                         BGP_CLEAR_SOFT_IN, NULL);
5895 }
5896
5897 ALIAS (clear_ip_bgp_all_vpnv4_soft_in,
5898        clear_ip_bgp_all_vpnv4_in_cmd,
5899        "clear ip bgp * vpnv4 unicast in",
5900        CLEAR_STR
5901        IP_STR
5902        BGP_STR
5903        "Clear all peers\n"
5904        "Address family\n"
5905        "Address Family Modifier\n"
5906        BGP_SOFT_IN_STR)
5907
5908 DEFUN (clear_ip_bgp_all_encap_soft_in,
5909        clear_ip_bgp_all_encap_soft_in_cmd,
5910        "clear ip bgp * encap unicast soft in",
5911        CLEAR_STR
5912        IP_STR
5913        BGP_STR
5914        "Clear all peers\n"
5915        "Address family\n"
5916        "Address Family Modifier\n"
5917        "Soft reconfig\n"
5918        "Soft reconfig inbound update\n")
5919 {
5920   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_all,
5921                         BGP_CLEAR_SOFT_IN, NULL);
5922 }
5923
5924 ALIAS (clear_ip_bgp_all_encap_soft_in,
5925        clear_ip_bgp_all_encap_in_cmd,
5926        "clear ip bgp * encap unicast in",
5927        CLEAR_STR
5928        IP_STR
5929        BGP_STR
5930        "Clear all peers\n"
5931        "Address family\n"
5932        "Address Family Modifier\n"
5933        "Soft reconfig inbound update\n")
5934
5935 DEFUN (clear_bgp_all_soft_in,
5936        clear_bgp_all_soft_in_cmd,
5937        "clear bgp * soft in",
5938        CLEAR_STR
5939        BGP_STR
5940        "Clear all peers\n"
5941        BGP_SOFT_STR
5942        BGP_SOFT_IN_STR)
5943 {
5944   if (argc == 1)
5945     return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
5946                         BGP_CLEAR_SOFT_IN, NULL);
5947
5948   return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
5949                         BGP_CLEAR_SOFT_IN, NULL);
5950 }
5951
5952 ALIAS (clear_bgp_all_soft_in,
5953        clear_bgp_instance_all_soft_in_cmd,
5954        "clear bgp view WORD * soft in",
5955        CLEAR_STR
5956        BGP_STR
5957        "BGP view\n"
5958        "view name\n"
5959        "Clear all peers\n"
5960        BGP_SOFT_STR
5961        BGP_SOFT_IN_STR)
5962
5963 ALIAS (clear_bgp_all_soft_in,
5964        clear_bgp_ipv6_all_soft_in_cmd,
5965        "clear bgp ipv6 * soft in",
5966        CLEAR_STR
5967        BGP_STR
5968        "Address family\n"
5969        "Clear all peers\n"
5970        BGP_SOFT_STR
5971        BGP_SOFT_IN_STR)
5972
5973 ALIAS (clear_bgp_all_soft_in,
5974        clear_bgp_all_in_cmd,
5975        "clear bgp * in",
5976        CLEAR_STR
5977        BGP_STR
5978        "Clear all peers\n"
5979        BGP_SOFT_IN_STR)
5980
5981 ALIAS (clear_bgp_all_soft_in,
5982        clear_bgp_ipv6_all_in_cmd,
5983        "clear bgp ipv6 * in",
5984        CLEAR_STR
5985        BGP_STR
5986        "Address family\n"
5987        "Clear all peers\n"
5988        BGP_SOFT_IN_STR)
5989
5990 DEFUN (clear_bgp_all_in_prefix_filter,
5991        clear_bgp_all_in_prefix_filter_cmd,
5992        "clear bgp * in prefix-filter",
5993        CLEAR_STR
5994        BGP_STR
5995        "Clear all peers\n"
5996        BGP_SOFT_IN_STR
5997        "Push out prefix-list ORF and do inbound soft reconfig\n")
5998 {
5999   return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
6000                         BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
6001 }
6002
6003 ALIAS (clear_bgp_all_in_prefix_filter,
6004        clear_bgp_ipv6_all_in_prefix_filter_cmd,
6005        "clear bgp ipv6 * in prefix-filter",
6006        CLEAR_STR
6007        BGP_STR
6008        "Address family\n"
6009        "Clear all peers\n"
6010        BGP_SOFT_IN_STR
6011        "Push out prefix-list ORF and do inbound soft reconfig\n")
6012
6013 DEFUN (clear_ip_bgp_peer_soft_in,
6014        clear_ip_bgp_peer_soft_in_cmd,
6015        "clear ip bgp A.B.C.D soft in",
6016        CLEAR_STR
6017        IP_STR
6018        BGP_STR
6019        "BGP neighbor address to clear\n"
6020        BGP_SOFT_STR
6021        BGP_SOFT_IN_STR)
6022 {
6023   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6024                         BGP_CLEAR_SOFT_IN, argv[0]);
6025 }
6026
6027 ALIAS (clear_ip_bgp_peer_soft_in,
6028        clear_ip_bgp_peer_in_cmd,
6029        "clear ip bgp A.B.C.D in",
6030        CLEAR_STR
6031        IP_STR
6032        BGP_STR
6033        "BGP neighbor address to clear\n"
6034        BGP_SOFT_IN_STR)
6035        
6036 DEFUN (clear_ip_bgp_peer_in_prefix_filter,
6037        clear_ip_bgp_peer_in_prefix_filter_cmd,
6038        "clear ip bgp A.B.C.D in prefix-filter",
6039        CLEAR_STR
6040        IP_STR
6041        BGP_STR
6042        "BGP neighbor address to clear\n"
6043        BGP_SOFT_IN_STR
6044        "Push out the existing ORF prefix-list\n")
6045 {
6046   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6047                         BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6048 }
6049
6050 DEFUN (clear_ip_bgp_peer_ipv4_soft_in,
6051        clear_ip_bgp_peer_ipv4_soft_in_cmd,
6052        "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft in",
6053        CLEAR_STR
6054        IP_STR
6055        BGP_STR
6056        "BGP neighbor address to clear\n"
6057        "Address family\n"
6058        "Address Family modifier\n"
6059        "Address Family modifier\n"
6060        BGP_SOFT_STR
6061        BGP_SOFT_IN_STR)
6062 {
6063   if (strncmp (argv[1], "m", 1) == 0)
6064     return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
6065                           BGP_CLEAR_SOFT_IN, argv[0]);
6066
6067   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6068                         BGP_CLEAR_SOFT_IN, argv[0]);
6069 }
6070
6071 ALIAS (clear_ip_bgp_peer_ipv4_soft_in,
6072        clear_ip_bgp_peer_ipv4_in_cmd,
6073        "clear ip bgp A.B.C.D ipv4 (unicast|multicast) in",
6074        CLEAR_STR
6075        IP_STR
6076        BGP_STR
6077        "BGP neighbor address to clear\n"
6078        "Address family\n"
6079        "Address Family modifier\n"
6080        "Address Family modifier\n"
6081        BGP_SOFT_IN_STR)
6082
6083 DEFUN (clear_ip_bgp_peer_ipv4_in_prefix_filter,
6084        clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd,
6085        "clear ip bgp A.B.C.D ipv4 (unicast|multicast) in prefix-filter",
6086        CLEAR_STR
6087        IP_STR
6088        BGP_STR
6089        "BGP neighbor address to clear\n"
6090        "Address family\n"
6091        "Address Family modifier\n"
6092        "Address Family modifier\n"
6093        BGP_SOFT_IN_STR
6094        "Push out the existing ORF prefix-list\n")
6095 {
6096   if (strncmp (argv[1], "m", 1) == 0)
6097     return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
6098                           BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6099
6100   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6101                         BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6102 }
6103
6104 DEFUN (clear_ip_bgp_peer_vpnv4_soft_in,
6105        clear_ip_bgp_peer_vpnv4_soft_in_cmd,
6106        "clear ip bgp A.B.C.D vpnv4 unicast soft in",
6107        CLEAR_STR
6108        IP_STR
6109        BGP_STR
6110        "BGP neighbor address to clear\n"
6111        "Address family\n"
6112        "Address Family Modifier\n"
6113        BGP_SOFT_STR
6114        BGP_SOFT_IN_STR)
6115 {
6116   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
6117                         BGP_CLEAR_SOFT_IN, argv[0]);
6118 }
6119
6120 ALIAS (clear_ip_bgp_peer_vpnv4_soft_in,
6121        clear_ip_bgp_peer_vpnv4_in_cmd,
6122        "clear ip bgp A.B.C.D vpnv4 unicast in",
6123        CLEAR_STR
6124        IP_STR
6125        BGP_STR
6126        "BGP neighbor address to clear\n"
6127        "Address family\n"
6128        "Address Family Modifier\n"
6129        BGP_SOFT_IN_STR)
6130
6131 DEFUN (clear_ip_bgp_peer_encap_soft_in,
6132        clear_ip_bgp_peer_encap_soft_in_cmd,
6133        "clear ip bgp A.B.C.D encap unicast soft in",
6134        CLEAR_STR
6135        IP_STR
6136        BGP_STR
6137        "BGP neighbor address to clear\n"
6138        "Address family\n"
6139        "Address Family Modifier\n"
6140        "Soft reconfig\n"
6141        "Soft reconfig inbound update\n")
6142 {
6143   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_peer,
6144                         BGP_CLEAR_SOFT_IN, argv[0]);
6145 }
6146
6147 ALIAS (clear_ip_bgp_peer_encap_soft_in,
6148        clear_ip_bgp_peer_encap_in_cmd,
6149        "clear ip bgp A.B.C.D encap unicast in",
6150        CLEAR_STR
6151        IP_STR
6152        BGP_STR
6153        "BGP neighbor address to clear\n"
6154        "Address family\n"
6155        "Address Family Modifier\n"
6156        "Soft reconfig inbound update\n")
6157
6158 DEFUN (clear_bgp_peer_soft_in,
6159        clear_bgp_peer_soft_in_cmd,
6160        "clear bgp (A.B.C.D|X:X::X:X) soft in",
6161        CLEAR_STR
6162        BGP_STR
6163        "BGP neighbor address to clear\n"
6164        "BGP IPv6 neighbor to clear\n"
6165        BGP_SOFT_STR
6166        BGP_SOFT_IN_STR)
6167 {
6168   return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
6169                         BGP_CLEAR_SOFT_IN, argv[0]);
6170 }
6171
6172 ALIAS (clear_bgp_peer_soft_in,
6173        clear_bgp_ipv6_peer_soft_in_cmd,
6174        "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft in",
6175        CLEAR_STR
6176        BGP_STR
6177        "Address family\n"
6178        "BGP neighbor address to clear\n"
6179        "BGP IPv6 neighbor to clear\n"
6180        BGP_SOFT_STR
6181        BGP_SOFT_IN_STR)
6182
6183 ALIAS (clear_bgp_peer_soft_in,
6184        clear_bgp_peer_in_cmd,
6185        "clear bgp (A.B.C.D|X:X::X:X) in",
6186        CLEAR_STR
6187        BGP_STR
6188        "BGP neighbor address to clear\n"
6189        "BGP IPv6 neighbor to clear\n"
6190        BGP_SOFT_IN_STR)
6191
6192 ALIAS (clear_bgp_peer_soft_in,
6193        clear_bgp_ipv6_peer_in_cmd,
6194        "clear bgp ipv6 (A.B.C.D|X:X::X:X) in",
6195        CLEAR_STR
6196        BGP_STR
6197        "Address family\n"
6198        "BGP neighbor address to clear\n"
6199        "BGP IPv6 neighbor to clear\n"
6200        BGP_SOFT_IN_STR)
6201
6202 DEFUN (clear_bgp_peer_in_prefix_filter,
6203        clear_bgp_peer_in_prefix_filter_cmd,
6204        "clear bgp (A.B.C.D|X:X::X:X) in prefix-filter",
6205        CLEAR_STR
6206        BGP_STR
6207        "BGP neighbor address to clear\n"
6208        "BGP IPv6 neighbor to clear\n"
6209        BGP_SOFT_IN_STR
6210        "Push out the existing ORF prefix-list\n")
6211 {
6212   return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
6213                         BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6214 }
6215
6216 ALIAS (clear_bgp_peer_in_prefix_filter,
6217        clear_bgp_ipv6_peer_in_prefix_filter_cmd,
6218        "clear bgp ipv6 (A.B.C.D|X:X::X:X) in prefix-filter",
6219        CLEAR_STR
6220        BGP_STR
6221        "Address family\n"
6222        "BGP neighbor address to clear\n"
6223        "BGP IPv6 neighbor to clear\n"
6224        BGP_SOFT_IN_STR
6225        "Push out the existing ORF prefix-list\n")
6226
6227 DEFUN (clear_ip_bgp_peer_group_soft_in,
6228        clear_ip_bgp_peer_group_soft_in_cmd,
6229        "clear ip bgp peer-group WORD soft in",
6230        CLEAR_STR
6231        IP_STR
6232        BGP_STR
6233        "Clear all members of peer-group\n"
6234        "BGP peer-group name\n"
6235        BGP_SOFT_STR
6236        BGP_SOFT_IN_STR)
6237 {
6238   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6239                         BGP_CLEAR_SOFT_IN, argv[0]);
6240 }
6241
6242 ALIAS (clear_ip_bgp_peer_group_soft_in,
6243        clear_ip_bgp_peer_group_in_cmd,
6244        "clear ip bgp peer-group WORD in",
6245        CLEAR_STR
6246        IP_STR
6247        BGP_STR
6248        "Clear all members of peer-group\n"
6249        "BGP peer-group name\n"
6250        BGP_SOFT_IN_STR)
6251
6252 DEFUN (clear_ip_bgp_peer_group_in_prefix_filter,
6253        clear_ip_bgp_peer_group_in_prefix_filter_cmd,
6254        "clear ip bgp peer-group WORD in prefix-filter",
6255        CLEAR_STR
6256        IP_STR
6257        BGP_STR
6258        "Clear all members of peer-group\n"
6259        "BGP peer-group name\n"
6260        BGP_SOFT_IN_STR
6261        "Push out prefix-list ORF and do inbound soft reconfig\n")
6262 {
6263   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6264                         BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6265 }
6266
6267 DEFUN (clear_ip_bgp_peer_group_ipv4_soft_in,
6268        clear_ip_bgp_peer_group_ipv4_soft_in_cmd,
6269        "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft in",
6270        CLEAR_STR
6271        IP_STR
6272        BGP_STR
6273        "Clear all members of peer-group\n"
6274        "BGP peer-group name\n"
6275        "Address family\n"
6276        "Address Family modifier\n"
6277        "Address Family modifier\n"
6278        BGP_SOFT_STR
6279        BGP_SOFT_IN_STR)
6280 {
6281   if (strncmp (argv[1], "m", 1) == 0)
6282     return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
6283                           BGP_CLEAR_SOFT_IN, argv[0]);
6284
6285   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6286                         BGP_CLEAR_SOFT_IN, argv[0]);
6287 }
6288
6289 ALIAS (clear_ip_bgp_peer_group_ipv4_soft_in,
6290        clear_ip_bgp_peer_group_ipv4_in_cmd,
6291        "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in",
6292        CLEAR_STR
6293        IP_STR
6294        BGP_STR
6295        "Clear all members of peer-group\n"
6296        "BGP peer-group name\n"
6297        "Address family\n"
6298        "Address Family modifier\n"
6299        "Address Family modifier\n"
6300        BGP_SOFT_IN_STR)
6301
6302 DEFUN (clear_ip_bgp_peer_group_ipv4_in_prefix_filter,
6303        clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd,
6304        "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in prefix-filter",
6305        CLEAR_STR
6306        IP_STR
6307        BGP_STR
6308        "Clear all members of peer-group\n"
6309        "BGP peer-group name\n"
6310        "Address family\n"
6311        "Address Family modifier\n"
6312        "Address Family modifier\n"
6313        BGP_SOFT_IN_STR
6314        "Push out prefix-list ORF and do inbound soft reconfig\n")
6315 {
6316   if (strncmp (argv[1], "m", 1) == 0)
6317     return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
6318                           BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6319
6320   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6321                         BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6322 }
6323
6324 DEFUN (clear_bgp_peer_group_soft_in,
6325        clear_bgp_peer_group_soft_in_cmd,
6326        "clear bgp peer-group WORD soft in",
6327        CLEAR_STR
6328        BGP_STR
6329        "Clear all members of peer-group\n"
6330        "BGP peer-group name\n"
6331        BGP_SOFT_STR
6332        BGP_SOFT_IN_STR)
6333 {
6334   return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
6335                         BGP_CLEAR_SOFT_IN, argv[0]);
6336 }
6337
6338 ALIAS (clear_bgp_peer_group_soft_in,
6339        clear_bgp_ipv6_peer_group_soft_in_cmd,
6340        "clear bgp ipv6 peer-group WORD soft in",
6341        CLEAR_STR
6342        BGP_STR
6343        "Address family\n"
6344        "Clear all members of peer-group\n"
6345        "BGP peer-group name\n"
6346        BGP_SOFT_STR
6347        BGP_SOFT_IN_STR)
6348
6349 ALIAS (clear_bgp_peer_group_soft_in,
6350        clear_bgp_peer_group_in_cmd,
6351        "clear bgp peer-group WORD in",
6352        CLEAR_STR
6353        BGP_STR
6354        "Clear all members of peer-group\n"
6355        "BGP peer-group name\n"
6356        BGP_SOFT_IN_STR)
6357
6358 ALIAS (clear_bgp_peer_group_soft_in,
6359        clear_bgp_ipv6_peer_group_in_cmd,
6360        "clear bgp ipv6 peer-group WORD in",
6361        CLEAR_STR
6362        BGP_STR
6363        "Address family\n"
6364        "Clear all members of peer-group\n"
6365        "BGP peer-group name\n"
6366        BGP_SOFT_IN_STR)
6367
6368 DEFUN (clear_bgp_peer_group_in_prefix_filter,
6369        clear_bgp_peer_group_in_prefix_filter_cmd,
6370        "clear bgp peer-group WORD in prefix-filter",
6371        CLEAR_STR
6372        BGP_STR
6373        "Clear all members of peer-group\n"
6374        "BGP peer-group name\n"
6375        BGP_SOFT_IN_STR
6376        "Push out prefix-list ORF and do inbound soft reconfig\n")
6377 {
6378   return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
6379                         BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6380 }
6381
6382 ALIAS (clear_bgp_peer_group_in_prefix_filter,
6383        clear_bgp_ipv6_peer_group_in_prefix_filter_cmd,
6384        "clear bgp ipv6 peer-group WORD in prefix-filter",
6385        CLEAR_STR
6386        BGP_STR
6387        "Address family\n"
6388        "Clear all members of peer-group\n"
6389        "BGP peer-group name\n"
6390        BGP_SOFT_IN_STR
6391        "Push out prefix-list ORF and do inbound soft reconfig\n")
6392
6393 DEFUN (clear_ip_bgp_external_soft_in,
6394        clear_ip_bgp_external_soft_in_cmd,
6395        "clear ip bgp external soft in",
6396        CLEAR_STR
6397        IP_STR
6398        BGP_STR
6399        "Clear all external peers\n"
6400        BGP_SOFT_STR
6401        BGP_SOFT_IN_STR)
6402 {
6403   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
6404                         BGP_CLEAR_SOFT_IN, NULL);
6405 }
6406
6407 ALIAS (clear_ip_bgp_external_soft_in,
6408        clear_ip_bgp_external_in_cmd,
6409        "clear ip bgp external in",
6410        CLEAR_STR
6411        IP_STR
6412        BGP_STR
6413        "Clear all external peers\n"
6414        BGP_SOFT_IN_STR)
6415
6416 DEFUN (clear_ip_bgp_external_in_prefix_filter,
6417        clear_ip_bgp_external_in_prefix_filter_cmd,
6418        "clear ip bgp external in prefix-filter",
6419        CLEAR_STR
6420        IP_STR
6421        BGP_STR
6422        "Clear all external peers\n"
6423        BGP_SOFT_IN_STR
6424        "Push out prefix-list ORF and do inbound soft reconfig\n")
6425 {
6426   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
6427                         BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
6428 }
6429
6430 DEFUN (clear_ip_bgp_external_ipv4_soft_in,
6431        clear_ip_bgp_external_ipv4_soft_in_cmd,
6432        "clear ip bgp external ipv4 (unicast|multicast) soft in",
6433        CLEAR_STR
6434        IP_STR
6435        BGP_STR
6436        "Clear all external peers\n"
6437        "Address family\n"
6438        "Address Family modifier\n"
6439        "Address Family modifier\n"
6440        BGP_SOFT_STR
6441        BGP_SOFT_IN_STR)
6442 {
6443   if (strncmp (argv[0], "m", 1) == 0)
6444     return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
6445                           BGP_CLEAR_SOFT_IN, NULL);
6446
6447   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
6448                         BGP_CLEAR_SOFT_IN, NULL);
6449 }
6450
6451 ALIAS (clear_ip_bgp_external_ipv4_soft_in,
6452        clear_ip_bgp_external_ipv4_in_cmd,
6453        "clear ip bgp external ipv4 (unicast|multicast) in",
6454        CLEAR_STR
6455        IP_STR
6456        BGP_STR
6457        "Clear all external peers\n"
6458        "Address family\n"
6459        "Address Family modifier\n"
6460        "Address Family modifier\n"
6461        BGP_SOFT_IN_STR)
6462
6463 DEFUN (clear_ip_bgp_external_ipv4_in_prefix_filter,
6464        clear_ip_bgp_external_ipv4_in_prefix_filter_cmd,
6465        "clear ip bgp external ipv4 (unicast|multicast) in prefix-filter",
6466        CLEAR_STR
6467        IP_STR
6468        BGP_STR
6469        "Clear all external peers\n"
6470        "Address family\n"
6471        "Address Family modifier\n"
6472        "Address Family modifier\n"
6473        BGP_SOFT_IN_STR
6474        "Push out prefix-list ORF and do inbound soft reconfig\n")
6475 {
6476   if (strncmp (argv[0], "m", 1) == 0)
6477     return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
6478                           BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
6479
6480   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
6481                         BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
6482 }
6483
6484 DEFUN (clear_bgp_external_soft_in,
6485        clear_bgp_external_soft_in_cmd,
6486        "clear bgp external soft in",
6487        CLEAR_STR
6488        BGP_STR
6489        "Clear all external peers\n"
6490        BGP_SOFT_STR
6491        BGP_SOFT_IN_STR)
6492 {
6493   return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
6494                         BGP_CLEAR_SOFT_IN, NULL);
6495 }
6496
6497 ALIAS (clear_bgp_external_soft_in,
6498        clear_bgp_ipv6_external_soft_in_cmd,
6499        "clear bgp ipv6 external soft in",
6500        CLEAR_STR
6501        BGP_STR
6502        "Address family\n"
6503        "Clear all external peers\n"
6504        BGP_SOFT_STR
6505        BGP_SOFT_IN_STR)
6506
6507 ALIAS (clear_bgp_external_soft_in,
6508        clear_bgp_external_in_cmd,
6509        "clear bgp external in",
6510        CLEAR_STR
6511        BGP_STR
6512        "Clear all external peers\n"
6513        BGP_SOFT_IN_STR)
6514
6515 ALIAS (clear_bgp_external_soft_in,
6516        clear_bgp_ipv6_external_in_cmd,
6517        "clear bgp ipv6 external WORD in",
6518        CLEAR_STR
6519        BGP_STR
6520        "Address family\n"
6521        "Clear all external peers\n"
6522        BGP_SOFT_IN_STR)
6523
6524 DEFUN (clear_bgp_external_in_prefix_filter,
6525        clear_bgp_external_in_prefix_filter_cmd,
6526        "clear bgp external in prefix-filter",
6527        CLEAR_STR
6528        BGP_STR
6529        "Clear all external peers\n"
6530        BGP_SOFT_IN_STR
6531        "Push out prefix-list ORF and do inbound soft reconfig\n")
6532 {
6533   return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
6534                         BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
6535 }
6536
6537 ALIAS (clear_bgp_external_in_prefix_filter,
6538        clear_bgp_ipv6_external_in_prefix_filter_cmd,
6539        "clear bgp ipv6 external in prefix-filter",
6540        CLEAR_STR
6541        BGP_STR
6542        "Address family\n"
6543        "Clear all external peers\n"
6544        BGP_SOFT_IN_STR
6545        "Push out prefix-list ORF and do inbound soft reconfig\n")
6546
6547 DEFUN (clear_ip_bgp_as_soft_in,
6548        clear_ip_bgp_as_soft_in_cmd,
6549        "clear ip bgp " CMD_AS_RANGE " soft in",
6550        CLEAR_STR
6551        IP_STR
6552        BGP_STR
6553        "Clear peers with the AS number\n"
6554        BGP_SOFT_STR
6555        BGP_SOFT_IN_STR)
6556 {
6557   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
6558                         BGP_CLEAR_SOFT_IN, argv[0]);
6559 }
6560
6561 ALIAS (clear_ip_bgp_as_soft_in,
6562        clear_ip_bgp_as_in_cmd,
6563        "clear ip bgp " CMD_AS_RANGE " in",
6564        CLEAR_STR
6565        IP_STR
6566        BGP_STR
6567        "Clear peers with the AS number\n"
6568        BGP_SOFT_IN_STR)
6569
6570 DEFUN (clear_ip_bgp_as_in_prefix_filter,
6571        clear_ip_bgp_as_in_prefix_filter_cmd,
6572        "clear ip bgp " CMD_AS_RANGE " in prefix-filter",
6573        CLEAR_STR
6574        IP_STR
6575        BGP_STR
6576        "Clear peers with the AS number\n"
6577        BGP_SOFT_IN_STR
6578        "Push out prefix-list ORF and do inbound soft reconfig\n")
6579 {
6580   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
6581                         BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6582 }
6583
6584 DEFUN (clear_ip_bgp_as_ipv4_soft_in,
6585        clear_ip_bgp_as_ipv4_soft_in_cmd,
6586        "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft in",
6587        CLEAR_STR
6588        IP_STR
6589        BGP_STR
6590        "Clear peers with the AS number\n"
6591        "Address family\n"
6592        "Address Family modifier\n"
6593        "Address Family modifier\n"
6594        BGP_SOFT_STR
6595        BGP_SOFT_IN_STR)
6596 {
6597   if (strncmp (argv[1], "m", 1) == 0)
6598     return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
6599                           BGP_CLEAR_SOFT_IN, argv[0]);
6600
6601   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
6602                         BGP_CLEAR_SOFT_IN, argv[0]);
6603 }
6604
6605 ALIAS (clear_ip_bgp_as_ipv4_soft_in,
6606        clear_ip_bgp_as_ipv4_in_cmd,
6607        "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in",
6608        CLEAR_STR
6609        IP_STR
6610        BGP_STR
6611        "Clear peers with the AS number\n"
6612        "Address family\n"
6613        "Address Family modifier\n"
6614        "Address Family modifier\n"
6615        BGP_SOFT_IN_STR)
6616
6617 DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter,
6618        clear_ip_bgp_as_ipv4_in_prefix_filter_cmd,
6619        "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in prefix-filter",
6620        CLEAR_STR
6621        IP_STR
6622        BGP_STR
6623        "Clear peers with the AS number\n"
6624        "Address family\n"
6625        "Address Family modifier\n"
6626        "Address Family modifier\n"
6627        BGP_SOFT_IN_STR
6628        "Push out prefix-list ORF and do inbound soft reconfig\n")
6629 {
6630   if (strncmp (argv[1], "m", 1) == 0)
6631     return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
6632                           BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6633
6634   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
6635                         BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6636 }
6637
6638 DEFUN (clear_ip_bgp_as_vpnv4_soft_in,
6639        clear_ip_bgp_as_vpnv4_soft_in_cmd,
6640        "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft in",
6641        CLEAR_STR
6642        IP_STR
6643        BGP_STR
6644        "Clear peers with the AS number\n"
6645        "Address family\n"
6646        "Address Family modifier\n"
6647        BGP_SOFT_STR
6648        BGP_SOFT_IN_STR)
6649 {
6650   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
6651                         BGP_CLEAR_SOFT_IN, argv[0]);
6652 }
6653
6654 ALIAS (clear_ip_bgp_as_vpnv4_soft_in,
6655        clear_ip_bgp_as_vpnv4_in_cmd,
6656        "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast in",
6657        CLEAR_STR
6658        IP_STR
6659        BGP_STR
6660        "Clear peers with the AS number\n"
6661        "Address family\n"
6662        "Address Family modifier\n"
6663        BGP_SOFT_IN_STR)
6664
6665 DEFUN (clear_ip_bgp_as_encap_soft_in,
6666        clear_ip_bgp_as_encap_soft_in_cmd,
6667        "clear ip bgp " CMD_AS_RANGE " encap unicast soft in",
6668        CLEAR_STR
6669        IP_STR
6670        BGP_STR
6671        "Clear peers with the AS number\n"
6672        "Address family\n"
6673        "Address Family modifier\n"
6674        "Soft reconfig\n"
6675        "Soft reconfig inbound update\n")
6676 {
6677   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_as,
6678                         BGP_CLEAR_SOFT_IN, argv[0]);
6679 }
6680
6681 ALIAS (clear_ip_bgp_as_encap_soft_in,
6682        clear_ip_bgp_as_encap_in_cmd,
6683        "clear ip bgp " CMD_AS_RANGE " encap unicast in",
6684        CLEAR_STR
6685        IP_STR
6686        BGP_STR
6687        "Clear peers with the AS number\n"
6688        "Address family\n"
6689        "Address Family modifier\n"
6690        "Soft reconfig inbound update\n")
6691
6692 DEFUN (clear_bgp_as_soft_in,
6693        clear_bgp_as_soft_in_cmd,
6694        "clear bgp " CMD_AS_RANGE " soft in",
6695        CLEAR_STR
6696        BGP_STR
6697        "Clear peers with the AS number\n"
6698        BGP_SOFT_STR
6699        BGP_SOFT_IN_STR)
6700 {
6701   return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
6702                         BGP_CLEAR_SOFT_IN, argv[0]);
6703 }
6704
6705 ALIAS (clear_bgp_as_soft_in,
6706        clear_bgp_ipv6_as_soft_in_cmd,
6707        "clear bgp ipv6 " CMD_AS_RANGE " soft in",
6708        CLEAR_STR
6709        BGP_STR
6710        "Address family\n"
6711        "Clear peers with the AS number\n"
6712        BGP_SOFT_STR
6713        BGP_SOFT_IN_STR)
6714
6715 ALIAS (clear_bgp_as_soft_in,
6716        clear_bgp_as_in_cmd,
6717        "clear bgp " CMD_AS_RANGE " in",
6718        CLEAR_STR
6719        BGP_STR
6720        "Clear peers with the AS number\n"
6721        BGP_SOFT_IN_STR)
6722
6723 ALIAS (clear_bgp_as_soft_in,
6724        clear_bgp_ipv6_as_in_cmd,
6725        "clear bgp ipv6 " CMD_AS_RANGE " in",
6726        CLEAR_STR
6727        BGP_STR
6728        "Address family\n"
6729        "Clear peers with the AS number\n"
6730        BGP_SOFT_IN_STR)
6731
6732 DEFUN (clear_bgp_as_in_prefix_filter,
6733        clear_bgp_as_in_prefix_filter_cmd,
6734        "clear bgp " CMD_AS_RANGE " in prefix-filter",
6735        CLEAR_STR
6736        BGP_STR
6737        "Clear peers with the AS number\n"
6738        BGP_SOFT_IN_STR
6739        "Push out prefix-list ORF and do inbound soft reconfig\n")
6740 {
6741   return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
6742                         BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6743 }
6744
6745 ALIAS (clear_bgp_as_in_prefix_filter,
6746        clear_bgp_ipv6_as_in_prefix_filter_cmd,
6747        "clear bgp ipv6 " CMD_AS_RANGE " in prefix-filter",
6748        CLEAR_STR
6749        BGP_STR
6750        "Address family\n"
6751        "Clear peers with the AS number\n"
6752        BGP_SOFT_IN_STR
6753        "Push out prefix-list ORF and do inbound soft reconfig\n")
6754
6755 /* Both soft-reconfiguration */
6756 DEFUN (clear_ip_bgp_all_soft,
6757        clear_ip_bgp_all_soft_cmd,
6758        "clear ip bgp * soft",
6759        CLEAR_STR
6760        IP_STR
6761        BGP_STR
6762        "Clear all peers\n"
6763        BGP_SOFT_STR)
6764 {
6765   if (argc == 1)
6766     return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
6767                         BGP_CLEAR_SOFT_BOTH, NULL);
6768
6769   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6770                         BGP_CLEAR_SOFT_BOTH, NULL);
6771 }
6772
6773 ALIAS (clear_ip_bgp_all_soft,
6774        clear_ip_bgp_instance_all_soft_cmd,
6775        "clear ip bgp view WORD * soft",
6776        CLEAR_STR
6777        IP_STR
6778        BGP_STR
6779        "BGP view\n"
6780        "view name\n"
6781        "Clear all peers\n"
6782        BGP_SOFT_STR)
6783
6784
6785 DEFUN (clear_ip_bgp_all_ipv4_soft,
6786        clear_ip_bgp_all_ipv4_soft_cmd,
6787        "clear ip bgp * ipv4 (unicast|multicast) soft",
6788        CLEAR_STR
6789        IP_STR
6790        BGP_STR
6791        "Clear all peers\n"
6792        "Address family\n"
6793        "Address Family Modifier\n"
6794        "Address Family Modifier\n"
6795        BGP_SOFT_STR)
6796 {
6797   if (strncmp (argv[0], "m", 1) == 0)
6798     return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
6799                           BGP_CLEAR_SOFT_BOTH, NULL);
6800
6801   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6802                         BGP_CLEAR_SOFT_BOTH, NULL);
6803 }
6804
6805 DEFUN (clear_ip_bgp_instance_all_ipv4_soft,
6806        clear_ip_bgp_instance_all_ipv4_soft_cmd,
6807        "clear ip bgp view WORD * ipv4 (unicast|multicast) soft",
6808        CLEAR_STR
6809        IP_STR
6810        BGP_STR
6811        "BGP view\n"
6812        "view name\n"
6813        "Clear all peers\n"
6814        "Address family\n"
6815        "Address Family Modifier\n"
6816        "Address Family Modifier\n"
6817        BGP_SOFT_STR)
6818 {
6819   if (strncmp (argv[1], "m", 1) == 0)
6820     return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
6821                           BGP_CLEAR_SOFT_BOTH, NULL);
6822
6823   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6824                         BGP_CLEAR_SOFT_BOTH, NULL);
6825 }
6826
6827 DEFUN (clear_ip_bgp_all_vpnv4_soft,
6828        clear_ip_bgp_all_vpnv4_soft_cmd,
6829        "clear ip bgp * vpnv4 unicast soft",
6830        CLEAR_STR
6831        IP_STR
6832        BGP_STR
6833        "Clear all peers\n"
6834        "Address family\n"
6835        "Address Family Modifier\n"
6836        BGP_SOFT_STR)
6837 {
6838   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
6839                         BGP_CLEAR_SOFT_BOTH, argv[0]);
6840 }
6841
6842 DEFUN (clear_ip_bgp_all_encap_soft,
6843        clear_ip_bgp_all_encap_soft_cmd,
6844        "clear ip bgp * encap unicast soft",
6845        CLEAR_STR
6846        IP_STR
6847        BGP_STR
6848        "Clear all peers\n"
6849        "Address family\n"
6850        "Address Family Modifier\n"
6851        "Soft reconfig\n")
6852 {
6853   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_all,
6854                         BGP_CLEAR_SOFT_BOTH, argv[0]);
6855 }
6856
6857 DEFUN (clear_bgp_all_soft,
6858        clear_bgp_all_soft_cmd,
6859        "clear bgp * soft",
6860        CLEAR_STR
6861        BGP_STR
6862        "Clear all peers\n"
6863        BGP_SOFT_STR)
6864 {
6865   if (argc == 1)
6866     return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
6867                         BGP_CLEAR_SOFT_BOTH, argv[0]);
6868  
6869   return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
6870                         BGP_CLEAR_SOFT_BOTH, argv[0]);
6871 }
6872
6873 ALIAS (clear_bgp_all_soft,
6874        clear_bgp_instance_all_soft_cmd,
6875        "clear bgp view WORD * soft",
6876        CLEAR_STR
6877        BGP_STR
6878        "BGP view\n"
6879        "view name\n"
6880        "Clear all peers\n"
6881        BGP_SOFT_STR)
6882
6883 ALIAS (clear_bgp_all_soft,
6884        clear_bgp_ipv6_all_soft_cmd,
6885        "clear bgp ipv6 * soft",
6886        CLEAR_STR
6887        BGP_STR
6888        "Address family\n"
6889        "Clear all peers\n"
6890        BGP_SOFT_STR)
6891
6892 DEFUN (clear_ip_bgp_peer_soft,
6893        clear_ip_bgp_peer_soft_cmd,
6894        "clear ip bgp A.B.C.D soft",
6895        CLEAR_STR
6896        IP_STR
6897        BGP_STR
6898        "BGP neighbor address to clear\n"
6899        BGP_SOFT_STR)
6900 {
6901   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6902                         BGP_CLEAR_SOFT_BOTH, argv[0]);
6903 }
6904
6905 DEFUN (clear_ip_bgp_peer_ipv4_soft,
6906        clear_ip_bgp_peer_ipv4_soft_cmd,
6907        "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft",
6908        CLEAR_STR
6909        IP_STR
6910        BGP_STR
6911        "BGP neighbor address to clear\n"
6912        "Address family\n"
6913        "Address Family Modifier\n"
6914        "Address Family Modifier\n"
6915        BGP_SOFT_STR)
6916 {
6917   if (strncmp (argv[1], "m", 1) == 0)
6918     return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
6919                           BGP_CLEAR_SOFT_BOTH, argv[0]);
6920
6921   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6922                         BGP_CLEAR_SOFT_BOTH, argv[0]);
6923 }
6924
6925 DEFUN (clear_ip_bgp_peer_vpnv4_soft,
6926        clear_ip_bgp_peer_vpnv4_soft_cmd,
6927        "clear ip bgp A.B.C.D vpnv4 unicast soft",
6928        CLEAR_STR
6929        IP_STR
6930        BGP_STR
6931        "BGP neighbor address to clear\n"
6932        "Address family\n"
6933        "Address Family Modifier\n"
6934        BGP_SOFT_STR)
6935 {
6936   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
6937                         BGP_CLEAR_SOFT_BOTH, argv[0]);
6938 }
6939
6940 DEFUN (clear_ip_bgp_peer_encap_soft,
6941        clear_ip_bgp_peer_encap_soft_cmd,
6942        "clear ip bgp A.B.C.D encap unicast soft",
6943        CLEAR_STR
6944        IP_STR
6945        BGP_STR
6946        "BGP neighbor address to clear\n"
6947        "Address family\n"
6948        "Address Family Modifier\n"
6949        "Soft reconfig\n")
6950 {
6951   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_peer,
6952                         BGP_CLEAR_SOFT_BOTH, argv[0]);
6953 }
6954
6955 DEFUN (clear_bgp_peer_soft,
6956        clear_bgp_peer_soft_cmd,
6957        "clear bgp (A.B.C.D|X:X::X:X) soft",
6958        CLEAR_STR
6959        BGP_STR
6960        "BGP neighbor address to clear\n"
6961        "BGP IPv6 neighbor to clear\n"
6962        BGP_SOFT_STR)
6963 {
6964   return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
6965                         BGP_CLEAR_SOFT_BOTH, argv[0]);
6966 }
6967
6968 ALIAS (clear_bgp_peer_soft,
6969        clear_bgp_ipv6_peer_soft_cmd,
6970        "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft",
6971        CLEAR_STR
6972        BGP_STR
6973        "Address family\n"
6974        "BGP neighbor address to clear\n"
6975        "BGP IPv6 neighbor to clear\n"
6976        BGP_SOFT_STR)
6977
6978 DEFUN (clear_ip_bgp_peer_group_soft,
6979        clear_ip_bgp_peer_group_soft_cmd,
6980        "clear ip bgp peer-group WORD soft",
6981        CLEAR_STR
6982        IP_STR
6983        BGP_STR
6984        "Clear all members of peer-group\n"
6985        "BGP peer-group name\n"
6986        BGP_SOFT_STR)
6987 {
6988   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6989                         BGP_CLEAR_SOFT_BOTH, argv[0]);
6990 }
6991
6992 DEFUN (clear_ip_bgp_peer_group_ipv4_soft,
6993        clear_ip_bgp_peer_group_ipv4_soft_cmd,
6994        "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft",
6995        CLEAR_STR
6996        IP_STR
6997        BGP_STR
6998        "Clear all members of peer-group\n"
6999        "BGP peer-group name\n"
7000        "Address family\n"
7001        "Address Family modifier\n"
7002        "Address Family modifier\n"
7003        BGP_SOFT_STR)
7004 {
7005   if (strncmp (argv[1], "m", 1) == 0)
7006     return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
7007                           BGP_CLEAR_SOFT_BOTH, argv[0]);
7008
7009   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
7010                         BGP_CLEAR_SOFT_BOTH, argv[0]);
7011 }
7012
7013 DEFUN (clear_bgp_peer_group_soft,
7014        clear_bgp_peer_group_soft_cmd,
7015        "clear bgp peer-group WORD soft",
7016        CLEAR_STR
7017        BGP_STR
7018        "Clear all members of peer-group\n"
7019        "BGP peer-group name\n"
7020        BGP_SOFT_STR)
7021 {
7022   return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
7023                         BGP_CLEAR_SOFT_BOTH, argv[0]);
7024 }
7025
7026 ALIAS (clear_bgp_peer_group_soft,
7027        clear_bgp_ipv6_peer_group_soft_cmd,
7028        "clear bgp ipv6 peer-group WORD soft",
7029        CLEAR_STR
7030        BGP_STR
7031        "Address family\n"
7032        "Clear all members of peer-group\n"
7033        "BGP peer-group name\n"
7034        BGP_SOFT_STR)
7035
7036 DEFUN (clear_ip_bgp_external_soft,
7037        clear_ip_bgp_external_soft_cmd,
7038        "clear ip bgp external soft",
7039        CLEAR_STR
7040        IP_STR
7041        BGP_STR
7042        "Clear all external peers\n"
7043        BGP_SOFT_STR)
7044 {
7045   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7046                         BGP_CLEAR_SOFT_BOTH, NULL);
7047 }
7048
7049 DEFUN (clear_ip_bgp_external_ipv4_soft,
7050        clear_ip_bgp_external_ipv4_soft_cmd,
7051        "clear ip bgp external ipv4 (unicast|multicast) soft",
7052        CLEAR_STR
7053        IP_STR
7054        BGP_STR
7055        "Clear all external peers\n"
7056        "Address family\n"
7057        "Address Family modifier\n"
7058        "Address Family modifier\n"
7059        BGP_SOFT_STR)
7060 {
7061   if (strncmp (argv[0], "m", 1) == 0)
7062     return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
7063                           BGP_CLEAR_SOFT_BOTH, NULL);
7064
7065   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7066                         BGP_CLEAR_SOFT_BOTH, NULL);
7067 }
7068
7069 DEFUN (clear_bgp_external_soft,
7070        clear_bgp_external_soft_cmd,
7071        "clear bgp external soft",
7072        CLEAR_STR
7073        BGP_STR
7074        "Clear all external peers\n"
7075        BGP_SOFT_STR)
7076 {
7077   return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
7078                         BGP_CLEAR_SOFT_BOTH, NULL);
7079 }
7080
7081 ALIAS (clear_bgp_external_soft,
7082        clear_bgp_ipv6_external_soft_cmd,
7083        "clear bgp ipv6 external soft",
7084        CLEAR_STR
7085        BGP_STR
7086        "Address family\n"
7087        "Clear all external peers\n"
7088        BGP_SOFT_STR)
7089
7090 DEFUN (clear_ip_bgp_as_soft,
7091        clear_ip_bgp_as_soft_cmd,
7092        "clear ip bgp " CMD_AS_RANGE " soft",
7093        CLEAR_STR
7094        IP_STR
7095        BGP_STR
7096        "Clear peers with the AS number\n"
7097        BGP_SOFT_STR)
7098 {
7099   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
7100                         BGP_CLEAR_SOFT_BOTH, argv[0]);
7101 }
7102
7103 DEFUN (clear_ip_bgp_as_ipv4_soft,
7104        clear_ip_bgp_as_ipv4_soft_cmd,
7105        "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft",
7106        CLEAR_STR
7107        IP_STR
7108        BGP_STR
7109        "Clear peers with the AS number\n"
7110        "Address family\n"
7111        "Address Family Modifier\n"
7112        "Address Family Modifier\n"
7113        BGP_SOFT_STR)
7114 {
7115   if (strncmp (argv[1], "m", 1) == 0)
7116     return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
7117                           BGP_CLEAR_SOFT_BOTH, argv[0]);
7118
7119   return bgp_clear_vty (vty, NULL,AFI_IP, SAFI_UNICAST, clear_as,
7120                         BGP_CLEAR_SOFT_BOTH, argv[0]);
7121 }
7122
7123 DEFUN (clear_ip_bgp_as_vpnv4_soft,
7124        clear_ip_bgp_as_vpnv4_soft_cmd,
7125        "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft",
7126        CLEAR_STR
7127        IP_STR
7128        BGP_STR
7129        "Clear peers with the AS number\n"
7130        "Address family\n"
7131        "Address Family Modifier\n"
7132        BGP_SOFT_STR)
7133 {
7134   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
7135                         BGP_CLEAR_SOFT_BOTH, argv[0]);
7136 }
7137
7138 DEFUN (clear_ip_bgp_as_encap_soft,
7139        clear_ip_bgp_as_encap_soft_cmd,
7140        "clear ip bgp " CMD_AS_RANGE " encap unicast soft",
7141        CLEAR_STR
7142        IP_STR
7143        BGP_STR
7144        "Clear peers with the AS number\n"
7145        "Address family\n"
7146        "Address Family Modifier\n"
7147        "Soft reconfig\n")
7148 {
7149   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_as,
7150                         BGP_CLEAR_SOFT_BOTH, argv[0]);
7151 }
7152
7153 DEFUN (clear_bgp_as_soft,
7154        clear_bgp_as_soft_cmd,
7155        "clear bgp " CMD_AS_RANGE " soft",
7156        CLEAR_STR
7157        BGP_STR
7158        "Clear peers with the AS number\n"
7159        BGP_SOFT_STR)
7160 {
7161   return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
7162                         BGP_CLEAR_SOFT_BOTH, argv[0]);
7163 }
7164
7165 ALIAS (clear_bgp_as_soft,
7166        clear_bgp_ipv6_as_soft_cmd,
7167        "clear bgp ipv6 " CMD_AS_RANGE " soft",
7168        CLEAR_STR
7169        BGP_STR
7170        "Address family\n"
7171        "Clear peers with the AS number\n"
7172        BGP_SOFT_STR)
7173
7174 /* RS-client soft reconfiguration. */
7175 DEFUN (clear_bgp_all_rsclient,
7176        clear_bgp_all_rsclient_cmd,
7177        "clear bgp * rsclient",
7178        CLEAR_STR
7179        BGP_STR
7180        "Clear all peers\n"
7181        BGP_SOFT_RSCLIENT_RIB_STR)
7182 {
7183   if (argc == 1)
7184     return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
7185                           BGP_CLEAR_SOFT_RSCLIENT, NULL);
7186
7187   return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
7188                         BGP_CLEAR_SOFT_RSCLIENT, NULL);
7189 }
7190
7191 ALIAS (clear_bgp_all_rsclient,
7192        clear_bgp_ipv6_all_rsclient_cmd,
7193        "clear bgp ipv6 * rsclient",
7194        CLEAR_STR
7195        BGP_STR
7196        "Address family\n"
7197        "Clear all peers\n"
7198        BGP_SOFT_RSCLIENT_RIB_STR)
7199
7200 ALIAS (clear_bgp_all_rsclient,
7201        clear_bgp_instance_all_rsclient_cmd,
7202        "clear bgp view WORD * rsclient",
7203        CLEAR_STR
7204        BGP_STR
7205        "BGP view\n"
7206        "view name\n"
7207        "Clear all peers\n"
7208        BGP_SOFT_RSCLIENT_RIB_STR)
7209
7210 ALIAS (clear_bgp_all_rsclient,
7211        clear_bgp_ipv6_instance_all_rsclient_cmd,
7212        "clear bgp ipv6 view WORD * rsclient",
7213        CLEAR_STR
7214        BGP_STR
7215        "Address family\n"
7216        "BGP view\n"
7217        "view name\n"
7218        "Clear all peers\n"
7219        BGP_SOFT_RSCLIENT_RIB_STR)
7220
7221 DEFUN (clear_ip_bgp_all_rsclient,
7222        clear_ip_bgp_all_rsclient_cmd,
7223        "clear ip bgp * rsclient",
7224        CLEAR_STR
7225        IP_STR
7226        BGP_STR
7227        "Clear all peers\n"
7228        BGP_SOFT_RSCLIENT_RIB_STR)
7229 {
7230   if (argc == 1)
7231     return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
7232                           BGP_CLEAR_SOFT_RSCLIENT, NULL);
7233
7234   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
7235                         BGP_CLEAR_SOFT_RSCLIENT, NULL);
7236 }
7237
7238 ALIAS (clear_ip_bgp_all_rsclient,
7239        clear_ip_bgp_instance_all_rsclient_cmd,
7240        "clear ip bgp view WORD * rsclient",
7241        CLEAR_STR
7242        IP_STR
7243        BGP_STR
7244        "BGP view\n"
7245        "view name\n"
7246        "Clear all peers\n"
7247        BGP_SOFT_RSCLIENT_RIB_STR)
7248
7249 DEFUN (clear_bgp_peer_rsclient,
7250        clear_bgp_peer_rsclient_cmd,
7251        "clear bgp (A.B.C.D|X:X::X:X) rsclient",
7252        CLEAR_STR
7253        BGP_STR
7254        "BGP neighbor IP address to clear\n"
7255        "BGP IPv6 neighbor to clear\n"
7256        BGP_SOFT_RSCLIENT_RIB_STR)
7257 {
7258   if (argc == 2)
7259     return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_peer,
7260                           BGP_CLEAR_SOFT_RSCLIENT, argv[1]);
7261
7262   return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
7263                         BGP_CLEAR_SOFT_RSCLIENT, argv[0]);
7264 }
7265
7266 ALIAS (clear_bgp_peer_rsclient,
7267        clear_bgp_ipv6_peer_rsclient_cmd,
7268        "clear bgp ipv6 (A.B.C.D|X:X::X:X) rsclient",
7269        CLEAR_STR
7270        BGP_STR
7271        "Address family\n"
7272        "BGP neighbor IP address to clear\n"
7273        "BGP IPv6 neighbor to clear\n"
7274        BGP_SOFT_RSCLIENT_RIB_STR)
7275
7276 ALIAS (clear_bgp_peer_rsclient,
7277        clear_bgp_instance_peer_rsclient_cmd,
7278        "clear bgp view WORD (A.B.C.D|X:X::X:X) rsclient",
7279        CLEAR_STR
7280        BGP_STR
7281        "BGP view\n"
7282        "view name\n"
7283        "BGP neighbor IP address to clear\n"
7284        "BGP IPv6 neighbor to clear\n"
7285        BGP_SOFT_RSCLIENT_RIB_STR)
7286
7287 ALIAS (clear_bgp_peer_rsclient,
7288        clear_bgp_ipv6_instance_peer_rsclient_cmd,
7289        "clear bgp ipv6 view WORD (A.B.C.D|X:X::X:X) rsclient",
7290        CLEAR_STR
7291        BGP_STR
7292        "Address family\n"
7293        "BGP view\n"
7294        "view name\n"
7295        "BGP neighbor IP address to clear\n"
7296        "BGP IPv6 neighbor to clear\n"
7297        BGP_SOFT_RSCLIENT_RIB_STR)
7298
7299 DEFUN (clear_ip_bgp_peer_rsclient,
7300        clear_ip_bgp_peer_rsclient_cmd,
7301        "clear ip bgp (A.B.C.D|X:X::X:X) rsclient",
7302        CLEAR_STR
7303        IP_STR
7304        BGP_STR
7305        "BGP neighbor IP address to clear\n"
7306        "BGP IPv6 neighbor to clear\n"
7307        BGP_SOFT_RSCLIENT_RIB_STR)
7308 {
7309   if (argc == 2)
7310     return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_peer,
7311                           BGP_CLEAR_SOFT_RSCLIENT, argv[1]);
7312
7313   return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
7314                         BGP_CLEAR_SOFT_RSCLIENT, argv[0]);
7315 }
7316
7317 ALIAS (clear_ip_bgp_peer_rsclient,
7318        clear_ip_bgp_instance_peer_rsclient_cmd,
7319        "clear ip bgp view WORD (A.B.C.D|X:X::X:X) rsclient",
7320        CLEAR_STR
7321        IP_STR
7322        BGP_STR
7323        "BGP view\n"
7324        "view name\n"
7325        "BGP neighbor IP address to clear\n"
7326        "BGP IPv6 neighbor to clear\n"
7327        BGP_SOFT_RSCLIENT_RIB_STR)
7328
7329 DEFUN (show_bgp_views,
7330        show_bgp_views_cmd,
7331        "show bgp views",
7332        SHOW_STR
7333        BGP_STR
7334        "Show the defined BGP views\n")
7335 {
7336   struct list *inst = bm->bgp;
7337   struct listnode *node;
7338   struct bgp *bgp;
7339
7340   if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
7341     {
7342       vty_out (vty, "Multiple BGP views are not defined%s", VTY_NEWLINE);
7343       return CMD_WARNING;
7344     }
7345   
7346   vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE);
7347   for (ALL_LIST_ELEMENTS_RO(inst, node, bgp))
7348     vty_out (vty, "\t%s (AS%u)%s", 
7349              bgp->name ? bgp->name : "(null)",
7350              bgp->as, VTY_NEWLINE);
7351   
7352   return CMD_SUCCESS;
7353 }
7354
7355 DEFUN (show_bgp_memory, 
7356        show_bgp_memory_cmd,
7357        "show bgp memory",
7358        SHOW_STR
7359        BGP_STR
7360        "Global BGP memory statistics\n")
7361 {
7362   char memstrbuf[MTYPE_MEMSTR_LEN];
7363   unsigned long count;
7364   
7365   /* RIB related usage stats */
7366   count = mtype_stats_alloc (MTYPE_BGP_NODE);
7367   vty_out (vty, "%ld RIB nodes, using %s of memory%s", count,
7368            mtype_memstr (memstrbuf, sizeof (memstrbuf),
7369                          count * sizeof (struct bgp_node)),
7370            VTY_NEWLINE);
7371   
7372   count = mtype_stats_alloc (MTYPE_BGP_ROUTE);
7373   vty_out (vty, "%ld BGP routes, using %s of memory%s", count,
7374            mtype_memstr (memstrbuf, sizeof (memstrbuf),
7375                          count * sizeof (struct bgp_info)),
7376            VTY_NEWLINE);
7377   if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA)))
7378     vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count,
7379              mtype_memstr (memstrbuf, sizeof (memstrbuf),
7380                            count * sizeof (struct bgp_info_extra)),
7381              VTY_NEWLINE);
7382   
7383   if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC)))
7384     vty_out (vty, "%ld Static routes, using %s of memory%s", count,
7385              mtype_memstr (memstrbuf, sizeof (memstrbuf),
7386                          count * sizeof (struct bgp_static)),
7387              VTY_NEWLINE);
7388   
7389   /* Adj-In/Out */
7390   if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN)))
7391     vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count,
7392              mtype_memstr (memstrbuf, sizeof (memstrbuf),
7393                            count * sizeof (struct bgp_adj_in)),
7394              VTY_NEWLINE);
7395   if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT)))
7396     vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count,
7397              mtype_memstr (memstrbuf, sizeof (memstrbuf),
7398                            count * sizeof (struct bgp_adj_out)),
7399              VTY_NEWLINE);
7400   
7401   if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE)))
7402     vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count,
7403              mtype_memstr (memstrbuf, sizeof (memstrbuf),
7404                          count * sizeof (struct bgp_nexthop_cache)),
7405              VTY_NEWLINE);
7406
7407   if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO)))
7408     vty_out (vty, "%ld Dampening entries, using %s of memory%s", count,
7409              mtype_memstr (memstrbuf, sizeof (memstrbuf),
7410                          count * sizeof (struct bgp_damp_info)),
7411              VTY_NEWLINE);
7412
7413   /* Attributes */
7414   count = attr_count();
7415   vty_out (vty, "%ld BGP attributes, using %s of memory%s", count, 
7416            mtype_memstr (memstrbuf, sizeof (memstrbuf), 
7417                          count * sizeof(struct attr)), 
7418            VTY_NEWLINE);
7419   if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA)))
7420     vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count, 
7421              mtype_memstr (memstrbuf, sizeof (memstrbuf), 
7422                            count * sizeof(struct attr_extra)), 
7423              VTY_NEWLINE);
7424   
7425   if ((count = attr_unknown_count()))
7426     vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE);
7427   
7428   /* AS_PATH attributes */
7429   count = aspath_count ();
7430   vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count,
7431            mtype_memstr (memstrbuf, sizeof (memstrbuf),
7432                          count * sizeof (struct aspath)),
7433            VTY_NEWLINE);
7434   
7435   count = mtype_stats_alloc (MTYPE_AS_SEG);
7436   vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count,
7437            mtype_memstr (memstrbuf, sizeof (memstrbuf),
7438                          count * sizeof (struct assegment)),
7439            VTY_NEWLINE);
7440   
7441   /* Other attributes */
7442   if ((count = community_count ()))
7443     vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
7444              mtype_memstr (memstrbuf, sizeof (memstrbuf),
7445                          count * sizeof (struct community)),
7446              VTY_NEWLINE);
7447   if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY)))
7448     vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
7449              mtype_memstr (memstrbuf, sizeof (memstrbuf),
7450                          count * sizeof (struct ecommunity)),
7451              VTY_NEWLINE);
7452   if ((count = mtype_stats_alloc (MTYPE_LCOMMUNITY)))
7453     vty_out (vty, "%ld BGP large-community entries, using %s of memory%s",
7454              count,
7455              mtype_memstr (memstrbuf, sizeof (memstrbuf),
7456                          count * sizeof (struct lcommunity)),
7457              VTY_NEWLINE);
7458   if ((count = mtype_stats_alloc (MTYPE_CLUSTER)))
7459     vty_out (vty, "%ld Cluster lists, using %s of memory%s", count,
7460              mtype_memstr (memstrbuf, sizeof (memstrbuf),
7461                          count * sizeof (struct cluster_list)),
7462              VTY_NEWLINE);
7463   
7464   /* Peer related usage */
7465   count = mtype_stats_alloc (MTYPE_BGP_PEER);
7466   vty_out (vty, "%ld peers, using %s of memory%s", count,
7467            mtype_memstr (memstrbuf, sizeof (memstrbuf),
7468                          count * sizeof (struct peer)),
7469            VTY_NEWLINE);
7470   
7471   if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP)))
7472     vty_out (vty, "%ld peer groups, using %s of memory%s", count,
7473              mtype_memstr (memstrbuf, sizeof (memstrbuf),
7474                            count * sizeof (struct peer_group)),
7475              VTY_NEWLINE);
7476   
7477   /* Other */
7478   if ((count = mtype_stats_alloc (MTYPE_HASH)))
7479     vty_out (vty, "%ld hash tables, using %s of memory%s", count,
7480              mtype_memstr (memstrbuf, sizeof (memstrbuf),
7481                            count * sizeof (struct hash)),
7482              VTY_NEWLINE);
7483   if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET)))
7484     vty_out (vty, "%ld hash buckets, using %s of memory%s", count,
7485              mtype_memstr (memstrbuf, sizeof (memstrbuf),
7486                            count * sizeof (struct hash_backet)),
7487              VTY_NEWLINE);
7488   if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP)))
7489     vty_out (vty, "%ld compiled regexes, using %s of memory%s", count,
7490              mtype_memstr (memstrbuf, sizeof (memstrbuf),
7491                            count * sizeof (regex_t)),
7492              VTY_NEWLINE);
7493   return CMD_SUCCESS;
7494 }
7495
7496 /* Show BGP peer's summary information. */
7497 static int
7498 bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi)
7499 {
7500   struct peer *peer;
7501   struct listnode *node, *nnode;
7502   unsigned int count = 0;
7503   unsigned int totrcount = 0;
7504   unsigned int totecount = 0;
7505   char timebuf[BGP_UPTIME_LEN];
7506   int len;
7507
7508   /* Header string for each address family. */
7509   static char header[] = "Neighbor        V         AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd";
7510   
7511   for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
7512     {
7513       if (peer->afc[afi][safi])
7514         {
7515           if (!count)
7516             {
7517               unsigned long ents;
7518               char memstrbuf[MTYPE_MEMSTR_LEN];
7519               
7520               /* Usage summary and header */
7521               vty_out (vty,
7522                        "BGP router identifier %s, local AS number %u%s",
7523                        inet_ntoa (bgp->router_id), bgp->as, VTY_NEWLINE);
7524
7525               ents = bgp_table_count (bgp->rib[afi][safi]);
7526               vty_out (vty, "RIB entries %ld, using %s of memory%s", ents,
7527                        mtype_memstr (memstrbuf, sizeof (memstrbuf),
7528                                      ents * sizeof (struct bgp_node)),
7529                        VTY_NEWLINE);
7530               
7531               /* Peer related usage */
7532               ents = listcount (bgp->peer);
7533               vty_out (vty, "Peers %ld, using %s of memory%s",
7534                        ents,
7535                        mtype_memstr (memstrbuf, sizeof (memstrbuf),
7536                                      ents * sizeof (struct peer)),
7537                        VTY_NEWLINE);
7538               
7539               if ((ents = listcount (bgp->rsclient)))
7540                 vty_out (vty, "RS-Client peers %ld, using %s of memory%s",
7541                          ents,
7542                          mtype_memstr (memstrbuf, sizeof (memstrbuf),
7543                                        ents * sizeof (struct peer)),
7544                          VTY_NEWLINE);
7545               
7546               if ((ents = listcount (bgp->group)))
7547                 vty_out (vty, "Peer groups %ld, using %s of memory%s", ents,
7548                          mtype_memstr (memstrbuf, sizeof (memstrbuf),
7549                                        ents * sizeof (struct peer_group)),
7550                          VTY_NEWLINE);
7551
7552               if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
7553                 vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE);
7554               vty_out (vty, "%s", VTY_NEWLINE);
7555               vty_out (vty, "%s%s", header, VTY_NEWLINE);
7556             }
7557           
7558           count++;
7559
7560           len = vty_out (vty, "%s", peer->host);
7561           len = 16 - len;
7562           if (len < 1)
7563             vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
7564           else
7565             vty_out (vty, "%*s", len, " ");
7566
7567           vty_out (vty, "4 ");
7568
7569           vty_out (vty, "%5u %7d %7d %8d %4d %4d ",
7570                    peer->as,
7571                    peer->open_in + peer->update_in + peer->keepalive_in
7572                    + peer->notify_in + peer->refresh_in + peer->dynamic_cap_in,
7573                    peer->open_out + peer->update_out + peer->keepalive_out
7574                    + peer->notify_out + peer->refresh_out
7575                    + peer->dynamic_cap_out,
7576                    0, 0,
7577                    peer->sync[afi][safi]->update.count +
7578                    peer->sync[afi][safi]->withdraw.count);
7579
7580           vty_out (vty, "%8s", 
7581                    peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN));
7582
7583           if (peer->status == Established)
7584             {
7585               vty_out (vty, " %8ld", peer->pcount[afi][safi]);
7586               totrcount += peer->pcount[afi][safi];
7587               totecount++;
7588             }
7589           else
7590             {
7591               if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
7592                 vty_out (vty, " Idle (Admin)");
7593               else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
7594                 vty_out (vty, " Idle (PfxCt)");
7595               else
7596                 vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, peer->status));
7597             }
7598
7599           vty_out (vty, "%s", VTY_NEWLINE);
7600         }
7601     }
7602
7603   if (count)
7604     {
7605       vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE,
7606                count, VTY_NEWLINE);
7607       vty_out (vty, "%sTotal num. Established sessions %d%s", VTY_NEWLINE,
7608                totecount, VTY_NEWLINE);
7609       vty_out (vty, "Total num. of routes received     %d%s",
7610                totrcount, VTY_NEWLINE);
7611     }
7612   else
7613     vty_out (vty, "No %s neighbor is configured%s",
7614              afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
7615   return CMD_SUCCESS;
7616 }
7617
7618 static int 
7619 bgp_show_summary_vty (struct vty *vty, const char *name, 
7620                       afi_t afi, safi_t safi)
7621 {
7622   struct bgp *bgp;
7623
7624   if (name)
7625     {
7626       bgp = bgp_lookup_by_name (name);
7627       
7628       if (! bgp)
7629         {
7630           vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); 
7631           return CMD_WARNING;
7632         }
7633
7634       bgp_show_summary (vty, bgp, afi, safi);
7635       return CMD_SUCCESS;
7636     }
7637   
7638   bgp = bgp_get_default ();
7639
7640   if (bgp)
7641     bgp_show_summary (vty, bgp, afi, safi);    
7642  
7643   return CMD_SUCCESS;
7644 }
7645
7646 /* `show ip bgp summary' commands. */
7647 DEFUN (show_ip_bgp_summary, 
7648        show_ip_bgp_summary_cmd,
7649        "show ip bgp summary",
7650        SHOW_STR
7651        IP_STR
7652        BGP_STR
7653        "Summary of BGP neighbor status\n")
7654 {
7655   return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
7656 }
7657
7658 DEFUN (show_ip_bgp_instance_summary,
7659        show_ip_bgp_instance_summary_cmd,
7660        "show ip bgp view WORD summary",
7661        SHOW_STR
7662        IP_STR
7663        BGP_STR
7664        "BGP view\n"
7665        "View name\n"
7666        "Summary of BGP neighbor status\n")
7667 {
7668   return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);  
7669 }
7670
7671 DEFUN (show_ip_bgp_ipv4_summary, 
7672        show_ip_bgp_ipv4_summary_cmd,
7673        "show ip bgp ipv4 (unicast|multicast) summary",
7674        SHOW_STR
7675        IP_STR
7676        BGP_STR
7677        "Address family\n"
7678        "Address Family modifier\n"
7679        "Address Family modifier\n"
7680        "Summary of BGP neighbor status\n")
7681 {
7682   if (strncmp (argv[0], "m", 1) == 0)
7683     return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST);
7684
7685   return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
7686 }
7687
7688 DEFUN (show_ip_bgp_instance_ipv4_summary,
7689        show_ip_bgp_instance_ipv4_summary_cmd,
7690        "show ip bgp view WORD ipv4 (unicast|multicast) summary",
7691        SHOW_STR
7692        IP_STR
7693        BGP_STR
7694        "BGP view\n"
7695        "View name\n"
7696        "Address family\n"
7697        "Address Family modifier\n"
7698        "Address Family modifier\n"
7699        "Summary of BGP neighbor status\n")
7700 {
7701   if (strncmp (argv[1], "m", 1) == 0)
7702     return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST);
7703   else
7704     return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
7705 }
7706
7707 DEFUN (show_ip_bgp_vpnv4_all_summary,
7708        show_ip_bgp_vpnv4_all_summary_cmd,
7709        "show ip bgp vpnv4 all summary",
7710        SHOW_STR
7711        IP_STR
7712        BGP_STR
7713        "Display VPNv4 NLRI specific information\n"
7714        "Display information about all VPNv4 NLRIs\n"
7715        "Summary of BGP neighbor status\n")
7716 {
7717   return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN);
7718 }
7719
7720 DEFUN (show_ip_bgp_vpnv4_rd_summary,
7721        show_ip_bgp_vpnv4_rd_summary_cmd,
7722        "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn summary",
7723        SHOW_STR
7724        IP_STR
7725        BGP_STR
7726        "Display VPNv4 NLRI specific information\n"
7727        "Display information for a route distinguisher\n"
7728        "VPN Route Distinguisher\n"
7729        "Summary of BGP neighbor status\n")
7730 {
7731   int ret;
7732   struct prefix_rd prd;
7733
7734   ret = str2prefix_rd (argv[0], &prd);
7735   if (! ret)
7736     {
7737       vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7738       return CMD_WARNING;
7739     }
7740
7741   return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN);
7742 }
7743
7744 DEFUN (show_bgp_ipv4_safi_summary,
7745        show_bgp_ipv4_safi_summary_cmd,
7746        "show bgp ipv4 (unicast|multicast) summary",
7747        SHOW_STR
7748        BGP_STR
7749        "Address family\n"
7750        "Address Family modifier\n"
7751        "Address Family modifier\n"
7752        "Summary of BGP neighbor status\n")
7753 {
7754   if (strncmp (argv[0], "m", 1) == 0)
7755     return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST);
7756
7757   return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
7758 }
7759
7760 DEFUN (show_bgp_instance_ipv4_safi_summary,
7761        show_bgp_instance_ipv4_safi_summary_cmd,
7762        "show bgp view WORD ipv4 (unicast|multicast) summary",
7763        SHOW_STR
7764        BGP_STR
7765        "BGP view\n"
7766        "View name\n"
7767        "Address family\n"
7768        "Address Family modifier\n"
7769        "Address Family modifier\n"
7770        "Summary of BGP neighbor status\n")
7771 {
7772   if (strncmp (argv[1], "m", 1) == 0)
7773     return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST);
7774   else
7775     return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
7776 }
7777
7778 DEFUN (show_bgp_ipv4_vpn_summary,
7779        show_bgp_ipv4_vpn_summary_cmd,
7780        "show bgp ipv4 vpn summary",
7781        SHOW_STR
7782        BGP_STR
7783        "IPv4\n"
7784        "Display VPN NLRI specific information\n"
7785        "Summary of BGP neighbor status\n")
7786 {
7787   return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN);
7788 }
7789
7790 /* `show ip bgp summary' commands. */
7791 DEFUN (show_bgp_ipv6_vpn_summary,
7792        show_bgp_ipv6_vpn_summary_cmd,
7793        "show bgp ipv6 vpn summary",
7794        SHOW_STR
7795        BGP_STR
7796        "IPv6\n"
7797        "Display VPN NLRI specific information\n"
7798        "Summary of BGP neighbor status\n")
7799 {
7800   return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MPLS_VPN);
7801 }
7802
7803 DEFUN (show_bgp_ipv4_encap_summary,
7804        show_bgp_ipv4_encap_summary_cmd,
7805        "show bgp ipv4 encap summary",
7806        SHOW_STR
7807        BGP_STR
7808        "IPv4\n"
7809        "Display ENCAP NLRI specific information\n"
7810        "Summary of BGP neighbor status\n")
7811 {
7812   return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_ENCAP);
7813 }
7814
7815 DEFUN (show_bgp_ipv6_encap_summary,
7816        show_bgp_ipv6_encap_summary_cmd,
7817        "show bgp ipv6 encap summary",
7818        SHOW_STR
7819        BGP_STR
7820        "IPv6\n"
7821        "Display ENCAP NLRI specific information\n"
7822        "Summary of BGP neighbor status\n")
7823 {
7824   return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_ENCAP);
7825 }
7826
7827 DEFUN (show_bgp_instance_summary,
7828        show_bgp_instance_summary_cmd,
7829        "show bgp view WORD summary",
7830        SHOW_STR
7831        BGP_STR
7832        "BGP view\n"
7833        "View name\n"
7834        "Summary of BGP neighbor status\n")
7835 {
7836     vty_out(vty, "%sIPv4 Unicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
7837     vty_out(vty, "---------------------%s", VTY_NEWLINE);
7838     bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
7839     vty_out(vty, "%sIPv4 Multicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
7840     vty_out(vty, "-----------------------%s", VTY_NEWLINE);
7841     bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST);
7842     vty_out(vty, "%sIPv4 VPN Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
7843     vty_out(vty, "-----------------%s", VTY_NEWLINE);
7844     bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_MPLS_VPN);
7845     vty_out(vty, "%sIPv4 Encap Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
7846     vty_out(vty, "-------------------%s", VTY_NEWLINE);
7847     bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_ENCAP);
7848
7849     vty_out(vty, "%sIPv6 Unicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
7850     vty_out(vty, "---------------------%s", VTY_NEWLINE);
7851     bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
7852     vty_out(vty, "%sIPv6 Multicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
7853     vty_out(vty, "-----------------------%s", VTY_NEWLINE);
7854     bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_MULTICAST);
7855     vty_out(vty, "%sIPv6 VPN Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
7856     vty_out(vty, "-----------------%s", VTY_NEWLINE);
7857     bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_MPLS_VPN);
7858     vty_out(vty, "%sIPv6 Encap Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
7859     vty_out(vty, "-------------------%s", VTY_NEWLINE);
7860     bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_ENCAP);
7861
7862     return CMD_SUCCESS;
7863 }
7864
7865 DEFUN (show_bgp_instance_ipv4_summary,
7866        show_bgp_instance_ipv4_summary_cmd,
7867        "show bgp view WORD ipv4 summary",
7868        SHOW_STR
7869        BGP_STR
7870        IP_STR
7871        "Address Family modifier\n"
7872        "Address Family modifier\n"
7873        "BGP view\n"
7874        "View name\n"
7875        "Summary of BGP neighbor status\n")
7876 {
7877     vty_out(vty, "%sIPv4 Unicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
7878     vty_out(vty, "---------------------%s", VTY_NEWLINE);
7879     bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
7880     vty_out(vty, "%sIPv4 Multicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
7881     vty_out(vty, "-----------------------%s", VTY_NEWLINE);
7882     bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST);
7883     vty_out(vty, "%sIPv4 VPN Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
7884     vty_out(vty, "-----------------%s", VTY_NEWLINE);
7885     bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_MPLS_VPN);
7886     vty_out(vty, "%sIPv4 Encap Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
7887     vty_out(vty, "-------------------%s", VTY_NEWLINE);
7888     bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_ENCAP);
7889
7890     return CMD_SUCCESS;
7891 }
7892
7893 DEFUN (show_bgp_instance_ipv6_summary,
7894        show_bgp_instance_ipv6_summary_cmd,
7895        "show bgp view WORD ipv6 summary",
7896        SHOW_STR
7897        BGP_STR
7898        IPV6_STR
7899        "Address Family modifier\n"
7900        "Address Family modifier\n"
7901        "BGP view\n"
7902        "View name\n"
7903        "Summary of BGP neighbor status\n")
7904 {
7905     vty_out(vty, "%sIPv6 Unicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
7906     vty_out(vty, "---------------------%s", VTY_NEWLINE);
7907     bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
7908     vty_out(vty, "%sIPv6 Multicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
7909     vty_out(vty, "-----------------------%s", VTY_NEWLINE);
7910     bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_MULTICAST);
7911     vty_out(vty, "%sIPv6 VPN Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
7912     vty_out(vty, "-----------------%s", VTY_NEWLINE);
7913     bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_MPLS_VPN);
7914     vty_out(vty, "%sIPv6 Encap Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
7915     vty_out(vty, "-------------------%s", VTY_NEWLINE);
7916     bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_ENCAP);
7917
7918     return CMD_SUCCESS;
7919 }
7920
7921 DEFUN (show_bgp_ipv6_safi_summary,
7922        show_bgp_ipv6_safi_summary_cmd,
7923        "show bgp ipv6 (unicast|multicast) summary",
7924        SHOW_STR
7925        BGP_STR
7926        "Address family\n"
7927        "Address Family modifier\n"
7928        "Address Family modifier\n"
7929        "Summary of BGP neighbor status\n")
7930 {
7931   if (strncmp (argv[0], "m", 1) == 0)
7932     return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST);
7933
7934   return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
7935 }
7936
7937 DEFUN (show_bgp_instance_ipv6_safi_summary,
7938        show_bgp_instance_ipv6_safi_summary_cmd,
7939        "show bgp view WORD ipv6 (unicast|multicast) summary",
7940        SHOW_STR
7941        BGP_STR
7942        "BGP view\n"
7943        "View name\n"
7944        "Address family\n"
7945        "Address Family modifier\n"
7946        "Address Family modifier\n"
7947        "Summary of BGP neighbor status\n")
7948 {
7949   if (strncmp (argv[1], "m", 1) == 0)
7950     return bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_MULTICAST);
7951
7952   return bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
7953 }
7954
7955 /* old command */
7956 DEFUN (show_ipv6_bgp_summary, 
7957        show_ipv6_bgp_summary_cmd,
7958        "show ipv6 bgp summary",
7959        SHOW_STR
7960        IPV6_STR
7961        BGP_STR
7962        "Summary of BGP neighbor status\n")
7963 {
7964   return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
7965 }
7966
7967 /* old command */
7968 DEFUN (show_ipv6_mbgp_summary, 
7969        show_ipv6_mbgp_summary_cmd,
7970        "show ipv6 mbgp summary",
7971        SHOW_STR
7972        IPV6_STR
7973        MBGP_STR
7974        "Summary of BGP neighbor status\n")
7975 {
7976   return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST);
7977 }
7978
7979 /* variations of show bgp [...] summary */
7980
7981 /* This one is for the 0-keyword variant */
7982 DEFUN (show_bgp_summary,
7983        show_bgp_summary_cmd,
7984        "show bgp summary",
7985        SHOW_STR
7986        BGP_STR
7987        "Summary of BGP neighbor status\n")
7988 {
7989     vty_out(vty, "%sIPv4 Unicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
7990     vty_out(vty, "---------------------%s", VTY_NEWLINE);
7991     bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
7992     vty_out(vty, "%sIPv4 Multicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
7993     vty_out(vty, "-----------------------%s", VTY_NEWLINE);
7994     bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST);
7995     vty_out(vty, "%sIPv4 VPN Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
7996     vty_out(vty, "-----------------%s", VTY_NEWLINE);
7997     bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN);
7998     vty_out(vty, "%sIPv4 Encap Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
7999     vty_out(vty, "-------------------%s", VTY_NEWLINE);
8000     bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_ENCAP);
8001
8002     vty_out(vty, "%sIPv6 Unicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
8003     vty_out(vty, "---------------------%s", VTY_NEWLINE);
8004     bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
8005     vty_out(vty, "%sIPv6 Multicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
8006     vty_out(vty, "-----------------------%s", VTY_NEWLINE);
8007     bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST);
8008     vty_out(vty, "%sIPv6 VPN Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
8009     vty_out(vty, "-----------------%s", VTY_NEWLINE);
8010     bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MPLS_VPN);
8011     vty_out(vty, "%sIPv6 Encap Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
8012     vty_out(vty, "-------------------%s", VTY_NEWLINE);
8013     bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_ENCAP);
8014
8015     return CMD_SUCCESS;
8016 }
8017
8018 ALIAS (show_bgp_summary, 
8019        show_bgp_ipv6_summary_cmd,
8020        "show bgp ipv6 summary",
8021        SHOW_STR
8022        BGP_STR
8023        "Address family\n"
8024        "Summary of BGP neighbor status\n")
8025
8026 DEFUN (show_bgp_summary_1w,
8027        show_bgp_summary_1w_cmd,
8028        "show bgp (ipv4|ipv6|unicast|multicast|vpn|encap) summary",
8029        SHOW_STR
8030        BGP_STR
8031        IP_STR
8032        IP6_STR
8033        "Address Family modifier\n"
8034        "Address Family modifier\n"
8035        "Address Family modifier\n"
8036        "Address Family modifier\n"
8037        "Summary of BGP neighbor status\n")
8038 {
8039   if (strcmp (argv[0], "ipv4") == 0) {
8040     vty_out(vty, "%sIPv4 Unicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
8041     vty_out(vty, "---------------------%s", VTY_NEWLINE);
8042     bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
8043     vty_out(vty, "%sIPv4 Multicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
8044     vty_out(vty, "-----------------------%s", VTY_NEWLINE);
8045     bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST);
8046     vty_out(vty, "%sIPv4 VPN Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
8047     vty_out(vty, "-----------------%s", VTY_NEWLINE);
8048     bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN);
8049     vty_out(vty, "%sIPv4 Encap Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
8050     vty_out(vty, "-------------------%s", VTY_NEWLINE);
8051     bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_ENCAP);
8052     return CMD_SUCCESS;
8053   }
8054
8055   if (strcmp (argv[0], "ipv6") == 0) {
8056     vty_out(vty, "%sIPv6 Unicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
8057     vty_out(vty, "---------------------%s", VTY_NEWLINE);
8058     bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
8059     vty_out(vty, "%sIPv6 Multicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
8060     vty_out(vty, "-----------------------%s", VTY_NEWLINE);
8061     bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST);
8062     vty_out(vty, "%sIPv6 VPN Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
8063     vty_out(vty, "-----------------%s", VTY_NEWLINE);
8064     bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MPLS_VPN);
8065     vty_out(vty, "%sIPv6 Encap Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
8066     vty_out(vty, "-------------------%s", VTY_NEWLINE);
8067     bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_ENCAP);
8068     return CMD_SUCCESS;
8069   }
8070
8071   if (strcmp (argv[0], "unicast") == 0) {
8072     vty_out(vty, "IPv4 Unicast Summary:%s", VTY_NEWLINE);
8073     vty_out(vty, "---------------------%s", VTY_NEWLINE);
8074     bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
8075     vty_out(vty, "%s", VTY_NEWLINE);
8076     vty_out(vty, "IPv6 Unicast Summary:%s", VTY_NEWLINE);
8077     vty_out(vty, "---------------------%s", VTY_NEWLINE);
8078     bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
8079     return CMD_SUCCESS;
8080   }
8081   if (strcmp (argv[0], "multicast") == 0) {
8082     vty_out(vty, "IPv4 Multicast Summary:%s", VTY_NEWLINE);
8083     vty_out(vty, "-----------------------%s", VTY_NEWLINE);
8084     bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST);
8085     vty_out(vty, "%s", VTY_NEWLINE);
8086     vty_out(vty, "IPv6 Multicast Summary:%s", VTY_NEWLINE);
8087     vty_out(vty, "-----------------------%s", VTY_NEWLINE);
8088     bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST);
8089     return CMD_SUCCESS;
8090   }
8091   if (strcmp (argv[0], "vpn") == 0) {
8092     vty_out(vty, "IPv4 VPN Summary:%s", VTY_NEWLINE);
8093     vty_out(vty, "-----------------%s", VTY_NEWLINE);
8094     bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN);
8095     vty_out(vty, "%s", VTY_NEWLINE);
8096     vty_out(vty, "IPv6 VPN Summary:%s", VTY_NEWLINE);
8097     vty_out(vty, "-----------------%s", VTY_NEWLINE);
8098     bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MPLS_VPN);
8099     return CMD_SUCCESS;
8100   }
8101   if (strcmp (argv[0], "encap") == 0) {
8102     vty_out(vty, "IPv4 Encap Summary:%s", VTY_NEWLINE);
8103     vty_out(vty, "-------------------%s", VTY_NEWLINE);
8104     bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_ENCAP);
8105     vty_out(vty, "%s", VTY_NEWLINE);
8106     vty_out(vty, "IPv6 Encap Summary:%s", VTY_NEWLINE);
8107     vty_out(vty, "-------------------%s", VTY_NEWLINE);
8108     bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_ENCAP);
8109     return CMD_SUCCESS;
8110   }
8111   vty_out(vty, "Unknown keyword: %s%s", argv[0], VTY_NEWLINE);
8112   return CMD_WARNING;
8113 }
8114
8115
8116
8117 const char *
8118 afi_safi_print (afi_t afi, safi_t safi)
8119 {
8120   if (afi == AFI_IP && safi == SAFI_UNICAST)
8121     return "IPv4 Unicast";
8122   else if (afi == AFI_IP && safi == SAFI_MULTICAST)
8123     return "IPv4 Multicast";
8124   else if (afi == AFI_IP && safi == SAFI_MPLS_VPN)
8125     return "VPN-IPv4 Unicast";
8126   else if (afi == AFI_IP && safi == SAFI_ENCAP)
8127     return "ENCAP-IPv4 Unicast";
8128   else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
8129     return "IPv6 Unicast";
8130   else if (afi == AFI_IP6 && safi == SAFI_MULTICAST)
8131     return "IPv6 Multicast";
8132   else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN)
8133     return "VPN-IPv6 Unicast";
8134   else if (afi == AFI_IP6 && safi == SAFI_ENCAP)
8135     return "ENCAP-IPv6 Unicast";
8136   else
8137     return "Unknown";
8138 }
8139
8140 /* Show BGP peer's information. */
8141 enum show_type
8142 {
8143   show_all,
8144   show_peer
8145 };
8146
8147 static void
8148 bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p,
8149                            afi_t afi, safi_t safi,
8150                            u_int16_t adv_smcap, u_int16_t adv_rmcap,
8151                            u_int16_t rcv_smcap, u_int16_t rcv_rmcap)
8152 {
8153   /* Send-Mode */
8154   if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)
8155       || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
8156     {
8157       vty_out (vty, "      Send-mode: ");
8158       if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
8159         vty_out (vty, "advertised");
8160       if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
8161         vty_out (vty, "%sreceived",
8162                  CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ?
8163                  ", " : "");
8164       vty_out (vty, "%s", VTY_NEWLINE);
8165     }
8166
8167   /* Receive-Mode */
8168   if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)
8169       || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
8170     {
8171       vty_out (vty, "      Receive-mode: ");
8172       if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
8173         vty_out (vty, "advertised");
8174       if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
8175         vty_out (vty, "%sreceived",
8176                  CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ?
8177                  ", " : "");
8178       vty_out (vty, "%s", VTY_NEWLINE);
8179     }
8180 }
8181
8182 static void
8183 bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi)
8184 {
8185   struct bgp_filter *filter;
8186   char orf_pfx_name[BUFSIZ];
8187   int orf_pfx_count;
8188
8189   filter = &p->filter[afi][safi];
8190
8191   vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi),
8192            VTY_NEWLINE);
8193
8194   if (p->af_group[afi][safi])
8195     vty_out (vty, "  %s peer-group member%s", p->group->name, VTY_NEWLINE);
8196
8197   if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
8198       || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
8199       || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
8200       || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
8201       || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
8202       || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
8203     vty_out (vty, "  AF-dependant capabilities:%s", VTY_NEWLINE);
8204
8205   if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
8206       || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
8207       || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
8208       || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
8209     {
8210       vty_out (vty, "    Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
8211                ORF_TYPE_PREFIX, VTY_NEWLINE);
8212       bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
8213                                  PEER_CAP_ORF_PREFIX_SM_ADV,
8214                                  PEER_CAP_ORF_PREFIX_RM_ADV,
8215                                  PEER_CAP_ORF_PREFIX_SM_RCV,
8216                                  PEER_CAP_ORF_PREFIX_RM_RCV);
8217     }
8218   if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
8219       || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
8220       || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
8221       || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
8222     {
8223       vty_out (vty, "    Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
8224                ORF_TYPE_PREFIX_OLD, VTY_NEWLINE);
8225       bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
8226                                  PEER_CAP_ORF_PREFIX_SM_ADV,
8227                                  PEER_CAP_ORF_PREFIX_RM_ADV,
8228                                  PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
8229                                  PEER_CAP_ORF_PREFIX_RM_OLD_RCV);
8230     }
8231
8232   sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
8233   orf_pfx_count =  prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name);
8234
8235   if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
8236       || orf_pfx_count)
8237     {
8238       vty_out (vty, "  Outbound Route Filter (ORF):");
8239       if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
8240           vty_out (vty, " sent;");
8241       if (orf_pfx_count)
8242         vty_out (vty, " received (%d entries)", orf_pfx_count);
8243       vty_out (vty, "%s", VTY_NEWLINE);
8244     }
8245   if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
8246       vty_out (vty, "  First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE);
8247
8248   if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
8249     vty_out (vty, "  Route-Reflector Client%s", VTY_NEWLINE);
8250   if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
8251     vty_out (vty, "  Route-Server Client%s", VTY_NEWLINE);
8252   if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
8253     vty_out (vty, "  Inbound soft reconfiguration allowed%s", VTY_NEWLINE);
8254   if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
8255     vty_out (vty, "  Private AS number removed from updates to this neighbor%s", VTY_NEWLINE);
8256   if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF))
8257     vty_out (vty, "  NEXT_HOP is always this router%s", VTY_NEWLINE);
8258   if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
8259     vty_out (vty, "  AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE);
8260   if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
8261     vty_out (vty, "  NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE);
8262   if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
8263     vty_out (vty, "  MED is propagated unchanged to this neighbor%s", VTY_NEWLINE);
8264   if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
8265       || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)
8266       || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY))
8267     {
8268       vty_out (vty, "  Community attribute sent to this neighbor");
8269       if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
8270           && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)
8271           && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY))
8272         vty_out (vty, "(all)%s", VTY_NEWLINE);
8273       else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
8274         vty_out (vty, "(extended)%s", VTY_NEWLINE);
8275       else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY))
8276         vty_out (vty, "(large)%s", VTY_NEWLINE);
8277       else 
8278         vty_out (vty, "(standard)%s", VTY_NEWLINE);
8279     }
8280   if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
8281     {
8282       vty_out (vty, "  Default information originate,");
8283
8284       if (p->default_rmap[afi][safi].name)
8285         vty_out (vty, " default route-map %s%s,",
8286                  p->default_rmap[afi][safi].map ? "*" : "",
8287                  p->default_rmap[afi][safi].name);
8288       if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
8289         vty_out (vty, " default sent%s", VTY_NEWLINE);
8290       else
8291         vty_out (vty, " default not sent%s", VTY_NEWLINE);
8292     }
8293
8294   if (filter->plist[FILTER_IN].name
8295       || filter->dlist[FILTER_IN].name
8296       || filter->aslist[FILTER_IN].name
8297       || filter->map[RMAP_IN].name)
8298     vty_out (vty, "  Inbound path policy configured%s", VTY_NEWLINE);
8299   if (filter->plist[FILTER_OUT].name
8300       || filter->dlist[FILTER_OUT].name
8301       || filter->aslist[FILTER_OUT].name
8302       || filter->map[RMAP_OUT].name
8303       || filter->usmap.name)
8304     vty_out (vty, "  Outbound path policy configured%s", VTY_NEWLINE);
8305   if (filter->map[RMAP_IMPORT].name)
8306     vty_out (vty, "  Import policy for this RS-client configured%s", VTY_NEWLINE);
8307   if (filter->map[RMAP_EXPORT].name)
8308     vty_out (vty, "  Export policy for this RS-client configured%s", VTY_NEWLINE);
8309
8310   /* prefix-list */
8311   if (filter->plist[FILTER_IN].name)
8312     vty_out (vty, "  Incoming update prefix filter list is %s%s%s",
8313              filter->plist[FILTER_IN].plist ? "*" : "",
8314              filter->plist[FILTER_IN].name,
8315              VTY_NEWLINE);
8316   if (filter->plist[FILTER_OUT].name)
8317     vty_out (vty, "  Outgoing update prefix filter list is %s%s%s",
8318              filter->plist[FILTER_OUT].plist ? "*" : "",
8319              filter->plist[FILTER_OUT].name,
8320              VTY_NEWLINE);
8321
8322   /* distribute-list */
8323   if (filter->dlist[FILTER_IN].name)
8324     vty_out (vty, "  Incoming update network filter list is %s%s%s",
8325              filter->dlist[FILTER_IN].alist ? "*" : "",
8326              filter->dlist[FILTER_IN].name,
8327              VTY_NEWLINE);
8328   if (filter->dlist[FILTER_OUT].name)
8329     vty_out (vty, "  Outgoing update network filter list is %s%s%s",
8330              filter->dlist[FILTER_OUT].alist ? "*" : "",
8331              filter->dlist[FILTER_OUT].name,
8332              VTY_NEWLINE);
8333
8334   /* filter-list. */
8335   if (filter->aslist[FILTER_IN].name)
8336     vty_out (vty, "  Incoming update AS path filter list is %s%s%s",
8337              filter->aslist[FILTER_IN].aslist ? "*" : "",
8338              filter->aslist[FILTER_IN].name,
8339              VTY_NEWLINE);
8340   if (filter->aslist[FILTER_OUT].name)
8341     vty_out (vty, "  Outgoing update AS path filter list is %s%s%s",
8342              filter->aslist[FILTER_OUT].aslist ? "*" : "",
8343              filter->aslist[FILTER_OUT].name,
8344              VTY_NEWLINE);
8345
8346   /* route-map. */
8347   if (filter->map[RMAP_IN].name)
8348     vty_out (vty, "  Route map for incoming advertisements is %s%s%s",
8349             filter->map[RMAP_IN].map ? "*" : "",
8350             filter->map[RMAP_IN].name,
8351              VTY_NEWLINE);
8352   if (filter->map[RMAP_OUT].name)
8353     vty_out (vty, "  Route map for outgoing advertisements is %s%s%s",
8354             filter->map[RMAP_OUT].map ? "*" : "",
8355             filter->map[RMAP_OUT].name,
8356             VTY_NEWLINE);
8357   if (filter->map[RMAP_IMPORT].name)
8358     vty_out (vty, "  Route map for advertisements going into this RS-client's table is %s%s%s",
8359             filter->map[RMAP_IMPORT].map ? "*" : "",
8360             filter->map[RMAP_IMPORT].name,
8361             VTY_NEWLINE);
8362   if (filter->map[RMAP_EXPORT].name)
8363     vty_out (vty, "  Route map for advertisements coming from this RS-client is %s%s%s",
8364             filter->map[RMAP_EXPORT].map ? "*" : "",
8365             filter->map[RMAP_EXPORT].name,
8366              VTY_NEWLINE);
8367
8368   /* unsuppress-map */
8369   if (filter->usmap.name)
8370     vty_out (vty, "  Route map for selective unsuppress is %s%s%s",
8371              filter->usmap.map ? "*" : "",
8372              filter->usmap.name, VTY_NEWLINE);
8373
8374   /* Receive prefix count */
8375   vty_out (vty, "  %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE);
8376
8377   /* Maximum prefix */
8378   if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
8379     {
8380       vty_out (vty, "  Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi],
8381                CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)
8382                ? " (warning-only)" : "", VTY_NEWLINE);
8383       vty_out (vty, "  Threshold for warning message %d%%",
8384                p->pmax_threshold[afi][safi]);
8385       if (p->pmax_restart[afi][safi])
8386         vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]);
8387       vty_out (vty, "%s", VTY_NEWLINE);
8388     }
8389
8390   vty_out (vty, "%s", VTY_NEWLINE);
8391 }
8392
8393 static void
8394 bgp_show_peer (struct vty *vty, struct peer *p)
8395 {
8396   struct bgp *bgp;
8397   char buf1[BUFSIZ];
8398   char timebuf[BGP_UPTIME_LEN];
8399   afi_t afi;
8400   safi_t safi;
8401   int ttl;
8402
8403   bgp = p->bgp;
8404
8405   /* Configured IP address. */
8406   vty_out (vty, "BGP neighbor is %s, ", p->host);
8407   vty_out (vty, "remote AS %u, ", p->as);
8408   vty_out (vty, "local AS %u%s%s, ",
8409            p->change_local_as ? p->change_local_as : p->local_as,
8410            CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ?
8411            " no-prepend" : "",
8412            CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) ?
8413            " replace-as" : "");
8414   vty_out (vty, "%s link%s",
8415            p->as == p->local_as ? "internal" : "external",
8416            VTY_NEWLINE);
8417
8418   /* Description. */
8419   if (p->desc)
8420     vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE);
8421   
8422   /* Peer-group */
8423   if (p->group)
8424     vty_out (vty, " Member of peer-group %s for session parameters%s",
8425              p->group->name, VTY_NEWLINE);
8426
8427   /* Administrative shutdown. */
8428   if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
8429     vty_out (vty, " Administratively shut down%s", VTY_NEWLINE);
8430
8431   /* BGP Version. */
8432   vty_out (vty, "  BGP version 4");
8433   vty_out (vty, ", remote router ID %s%s", 
8434            inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ),
8435            VTY_NEWLINE);
8436
8437   /* Confederation */
8438   if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION)
8439       && bgp_confederation_peers_check (bgp, p->as))
8440     vty_out (vty, "  Neighbor under common administration%s", VTY_NEWLINE);
8441   
8442   /* Status. */
8443   vty_out (vty, "  BGP state = %s",  
8444            LOOKUP (bgp_status_msg, p->status));
8445   if (p->status == Established) 
8446     vty_out (vty, ", up for %8s", 
8447              peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN));
8448   else if (p->status == Active)
8449     {
8450       if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE))
8451         vty_out (vty, " (passive)"); 
8452       else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT))
8453         vty_out (vty, " (NSF passive)"); 
8454     }
8455   vty_out (vty, "%s", VTY_NEWLINE);
8456   
8457   /* read timer */
8458   vty_out (vty, "  Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN));
8459
8460   /* Configured timer values. */
8461   vty_out (vty, ", hold time is %d, keepalive interval is %d seconds%s",
8462            p->v_holdtime, p->v_keepalive, VTY_NEWLINE);
8463   if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
8464     {
8465       vty_out (vty, "  Configured hold time is %d", p->holdtime);
8466       vty_out (vty, ", keepalive interval is %d seconds%s",
8467                p->keepalive, VTY_NEWLINE);
8468     }
8469
8470   /* Capability. */
8471   if (p->status == Established) 
8472     {
8473       if (p->cap
8474           || p->afc_adv[AFI_IP][SAFI_UNICAST]
8475           || p->afc_recv[AFI_IP][SAFI_UNICAST]
8476           || p->afc_adv[AFI_IP][SAFI_MULTICAST]
8477           || p->afc_recv[AFI_IP][SAFI_MULTICAST]
8478           || p->afc_adv[AFI_IP6][SAFI_UNICAST]
8479           || p->afc_recv[AFI_IP6][SAFI_UNICAST]
8480           || p->afc_adv[AFI_IP6][SAFI_MULTICAST]
8481           || p->afc_recv[AFI_IP6][SAFI_MULTICAST]
8482           || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN]
8483           || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN]
8484           || p->afc_adv[AFI_IP6][SAFI_ENCAP]
8485           || p->afc_recv[AFI_IP6][SAFI_ENCAP]
8486           || p->afc_adv[AFI_IP][SAFI_ENCAP]
8487           || p->afc_recv[AFI_IP][SAFI_ENCAP]
8488           || p->afc_adv[AFI_IP][SAFI_MPLS_VPN]
8489           || p->afc_recv[AFI_IP][SAFI_MPLS_VPN])
8490         {
8491           vty_out (vty, "  Neighbor capabilities:%s", VTY_NEWLINE);
8492
8493           /* AS4 */
8494           if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)
8495               || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
8496             {
8497               vty_out (vty, "    4 Byte AS:");
8498               if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
8499                 vty_out (vty, " advertised");
8500               if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
8501                 vty_out (vty, " %sreceived",
8502                          CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : "");
8503               vty_out (vty, "%s", VTY_NEWLINE);
8504             }
8505           /* Dynamic */
8506           if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
8507               || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
8508             {
8509               vty_out (vty, "    Dynamic:");
8510               if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
8511                 vty_out (vty, " advertised");
8512               if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
8513                 vty_out (vty, " %sreceived",
8514                          CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : "");
8515               vty_out (vty, "%s", VTY_NEWLINE);
8516             }
8517
8518           /* Route Refresh */
8519           if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
8520               || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
8521               || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
8522             {
8523               vty_out (vty, "    Route refresh:");
8524               if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
8525                 vty_out (vty, " advertised");
8526               if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
8527                   || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
8528                 vty_out (vty, " %sreceived(%s)",
8529                          CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "",
8530                          (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)
8531                           && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ?
8532                          "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new");
8533
8534               vty_out (vty, "%s", VTY_NEWLINE);
8535             }
8536
8537           /* Multiprotocol Extensions */
8538           for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8539             for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8540               if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
8541                 {
8542                   vty_out (vty, "    Address family %s:", afi_safi_print (afi, safi));
8543                   if (p->afc_adv[afi][safi]) 
8544                     vty_out (vty, " advertised");
8545                   if (p->afc_recv[afi][safi])
8546                     vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : "");
8547                   vty_out (vty, "%s", VTY_NEWLINE);
8548                 } 
8549
8550           /* Gracefull Restart */
8551           if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
8552               || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
8553             {
8554               vty_out (vty, "    Graceful Restart Capabilty:");
8555               if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
8556                 vty_out (vty, " advertised");
8557               if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
8558                 vty_out (vty, " %sreceived",
8559                          CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : "");
8560               vty_out (vty, "%s", VTY_NEWLINE);
8561
8562               if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
8563                 {
8564                   int restart_af_count = 0;
8565
8566                   vty_out (vty, "      Remote Restart timer is %d seconds%s",
8567                            p->v_gr_restart, VTY_NEWLINE);       
8568                   vty_out (vty, "      Address families by peer:%s        ", VTY_NEWLINE);
8569
8570                   for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8571                     for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8572                       if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
8573                         {
8574                           vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "",
8575                                    afi_safi_print (afi, safi),
8576                                    CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ?
8577                                    "preserved" : "not preserved");
8578                           restart_af_count++;
8579                         }
8580                   if (! restart_af_count)
8581                     vty_out (vty, "none");
8582                   vty_out (vty, "%s", VTY_NEWLINE);
8583                 }
8584             }
8585         }
8586     }
8587
8588   /* graceful restart information */
8589   if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
8590       || p->t_gr_restart
8591       || p->t_gr_stale)
8592     {
8593       int eor_send_af_count = 0;
8594       int eor_receive_af_count = 0;
8595
8596       vty_out (vty, "  Graceful restart informations:%s", VTY_NEWLINE);
8597       if (p->status == Established) 
8598         {
8599           vty_out (vty, "    End-of-RIB send: ");
8600           for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8601             for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8602               if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND))
8603                 {
8604                   vty_out (vty, "%s%s", eor_send_af_count ? ", " : "",
8605                            afi_safi_print (afi, safi));
8606                   eor_send_af_count++;
8607                 }
8608           vty_out (vty, "%s", VTY_NEWLINE);
8609
8610           vty_out (vty, "    End-of-RIB received: ");
8611           for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8612             for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8613               if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED))
8614                 {
8615                   vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "",
8616                            afi_safi_print (afi, safi));
8617                   eor_receive_af_count++;
8618                 }
8619           vty_out (vty, "%s", VTY_NEWLINE);
8620         }
8621
8622       if (p->t_gr_restart)
8623         vty_out (vty, "    The remaining time of restart timer is %ld%s",
8624                  thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE);
8625       
8626       if (p->t_gr_stale)
8627         vty_out (vty, "    The remaining time of stalepath timer is %ld%s",
8628                  thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE);
8629     }
8630
8631   /* Packet counts. */
8632   vty_out (vty, "  Message statistics:%s", VTY_NEWLINE);
8633   vty_out (vty, "    Inq depth is 0%s", VTY_NEWLINE);
8634   vty_out (vty, "    Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE);
8635   vty_out (vty, "                         Sent       Rcvd%s", VTY_NEWLINE);
8636   vty_out (vty, "    Opens:         %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE);
8637   vty_out (vty, "    Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE);
8638   vty_out (vty, "    Updates:       %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE);
8639   vty_out (vty, "    Keepalives:    %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE);
8640   vty_out (vty, "    Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE);
8641   vty_out (vty, "    Capability:    %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE);
8642   vty_out (vty, "    Total:         %10d %10d%s", p->open_out + p->notify_out +
8643            p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out,
8644            p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in +
8645            p->dynamic_cap_in, VTY_NEWLINE);
8646
8647   /* advertisement-interval */
8648   vty_out (vty, "  Minimum time between advertisement runs is %d seconds%s",
8649            p->v_routeadv, VTY_NEWLINE);
8650
8651   /* Update-source. */
8652   if (p->update_if || p->update_source)
8653     {
8654       vty_out (vty, "  Update source is ");
8655       if (p->update_if)
8656         vty_out (vty, "%s", p->update_if);
8657       else if (p->update_source)
8658         vty_out (vty, "%s",
8659                  sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
8660       vty_out (vty, "%s", VTY_NEWLINE);
8661     }
8662
8663   /* Default weight */
8664   if (CHECK_FLAG (p->config, PEER_CONFIG_WEIGHT))
8665     vty_out (vty, "  Default weight %d%s", p->weight,
8666              VTY_NEWLINE);
8667
8668   vty_out (vty, "%s", VTY_NEWLINE);
8669
8670   /* Address Family Information */
8671   for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8672     for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8673       if (p->afc[afi][safi])
8674         bgp_show_peer_afi (vty, p, afi, safi);
8675
8676   vty_out (vty, "  Connections established %d; dropped %d%s",
8677            p->established, p->dropped,
8678            VTY_NEWLINE);
8679
8680   if (! p->dropped)
8681     vty_out (vty, "  Last reset never%s", VTY_NEWLINE);
8682   else
8683     vty_out (vty, "  Last reset %s, due to %s%s",
8684             peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN),
8685             peer_down_str[(int) p->last_reset], VTY_NEWLINE);
8686
8687   if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW))
8688     {
8689       vty_out (vty, "  Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE);
8690
8691       if (p->t_pmax_restart)
8692         vty_out (vty, "  Reduce the no. of prefix from %s, will restart in %ld seconds%s",
8693                  p->host, thread_timer_remain_second (p->t_pmax_restart),
8694                  VTY_NEWLINE);
8695       else
8696         vty_out (vty, "  Reduce the no. of prefix and clear ip bgp %s to restore peering%s",
8697                  p->host, VTY_NEWLINE);
8698     }
8699
8700   /* EBGP Multihop and GTSM */
8701   ttl = p->gtsm_hops;
8702   if (! ttl)
8703     ttl = peer_ttl (p);
8704   vty_out (vty, "  %s BGP neighbor may be up to %d hops away.%s",
8705            p->sort == BGP_PEER_IBGP ? "Internal" : "External",
8706            ttl, VTY_NEWLINE);
8707
8708   /* Local address. */
8709   if (p->su_local)
8710     {
8711       vty_out (vty, "Local host: %s, Local port: %d%s",
8712                sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN),
8713                ntohs (p->su_local->sin.sin_port),
8714                VTY_NEWLINE);
8715     }
8716       
8717   /* Remote address. */
8718   if (p->su_remote)
8719     {
8720       vty_out (vty, "Foreign host: %s, Foreign port: %d%s",
8721                sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN),
8722                ntohs (p->su_remote->sin.sin_port),
8723                VTY_NEWLINE);
8724     }
8725
8726   /* Nexthop display. */
8727   if (p->su_local)
8728     {
8729       vty_out (vty, "Nexthop: %s%s", 
8730                inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ),
8731                VTY_NEWLINE);
8732       vty_out (vty, "Nexthop global: %s%s", 
8733                inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ),
8734                VTY_NEWLINE);
8735       vty_out (vty, "Nexthop local: %s%s",
8736                inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ),
8737                VTY_NEWLINE);
8738       vty_out (vty, "BGP connection: %s%s",
8739                p->shared_network ? "shared network" : "non shared network",
8740                VTY_NEWLINE);
8741     }
8742
8743   /* TCP metrics. */
8744   if (p->status == Established && p->rtt)
8745     vty_out (vty, "Estimated round trip time: %d ms%s",
8746              p->rtt, VTY_NEWLINE);
8747
8748   /* Timer information. */
8749   if (p->t_start)
8750     vty_out (vty, "Next start timer due in %ld seconds%s",
8751              thread_timer_remain_second (p->t_start), VTY_NEWLINE);
8752   if (p->t_connect)
8753     vty_out (vty, "Next connect timer due in %ld seconds%s",
8754              thread_timer_remain_second (p->t_connect), VTY_NEWLINE);
8755   
8756   vty_out (vty, "Read thread: %s  Write thread: %s%s", 
8757            p->t_read ? "on" : "off",
8758            p->t_write ? "on" : "off",
8759            VTY_NEWLINE);
8760
8761   if (p->notify.code == BGP_NOTIFY_OPEN_ERR
8762       && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL)
8763     bgp_capability_vty_out (vty, p);
8764  
8765   vty_out (vty, "%s", VTY_NEWLINE);
8766 }
8767
8768 static int
8769 bgp_show_neighbor (struct vty *vty, struct bgp *bgp,
8770                    enum show_type type, union sockunion *su)
8771 {
8772   struct listnode *node, *nnode;
8773   struct peer *peer;
8774   int find = 0;
8775
8776   for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
8777     {
8778       switch (type)
8779         {
8780         case show_all:
8781           bgp_show_peer (vty, peer);
8782           break;
8783         case show_peer:
8784           if (sockunion_same (&peer->su, su))
8785             {
8786               find = 1;
8787               bgp_show_peer (vty, peer);
8788             }
8789           break;
8790         }
8791     }
8792
8793   if (type == show_peer && ! find)
8794     vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE);
8795   
8796   return CMD_SUCCESS;
8797 }
8798
8799 static int 
8800 bgp_show_neighbor_vty (struct vty *vty, const char *name, 
8801                        enum show_type type, const char *ip_str)
8802 {
8803   int ret;
8804   struct bgp *bgp;
8805   union sockunion su;
8806
8807   if (ip_str)
8808     {
8809       ret = str2sockunion (ip_str, &su);
8810       if (ret < 0)
8811         {
8812           vty_out (vty, "%% Malformed address: %s%s", ip_str, VTY_NEWLINE);
8813           return CMD_WARNING;
8814         }
8815     }
8816
8817   if (name)
8818     {
8819       bgp = bgp_lookup_by_name (name);
8820       
8821       if (! bgp)
8822         {
8823           vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); 
8824           return CMD_WARNING;
8825         }
8826
8827       bgp_show_neighbor (vty, bgp, type, &su);
8828
8829       return CMD_SUCCESS;
8830     }
8831
8832   bgp = bgp_get_default ();
8833
8834   if (bgp)
8835     bgp_show_neighbor (vty, bgp, type, &su);
8836
8837   return CMD_SUCCESS;
8838 }
8839
8840 /* "show ip bgp neighbors" commands.  */DEFUN (show_ip_bgp_neighbors,
8841        show_ip_bgp_neighbors_cmd,
8842        "show ip bgp neighbors",
8843        SHOW_STR
8844        IP_STR
8845        BGP_STR
8846        "Detailed information on TCP and BGP neighbor connections\n")
8847 {
8848   return bgp_show_neighbor_vty (vty, NULL, show_all, NULL);
8849 }
8850
8851 ALIAS (show_ip_bgp_neighbors,
8852        show_ip_bgp_ipv4_neighbors_cmd,
8853        "show ip bgp ipv4 (unicast|multicast) neighbors",
8854        SHOW_STR
8855        IP_STR
8856        BGP_STR
8857        "Address family\n"
8858        "Address Family modifier\n"
8859        "Address Family modifier\n"
8860        "Detailed information on TCP and BGP neighbor connections\n")
8861
8862 ALIAS (show_ip_bgp_neighbors,
8863        show_ip_bgp_vpnv4_all_neighbors_cmd,
8864        "show ip bgp vpnv4 all neighbors",
8865        SHOW_STR
8866        IP_STR
8867        BGP_STR
8868        "Display VPNv4 NLRI specific information\n"
8869        "Display information about all VPNv4 NLRIs\n"
8870        "Detailed information on TCP and BGP neighbor connections\n")
8871
8872 ALIAS (show_ip_bgp_neighbors,
8873        show_ip_bgp_vpnv4_rd_neighbors_cmd,
8874        "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors",
8875        SHOW_STR
8876        IP_STR
8877        BGP_STR
8878        "Display VPNv4 NLRI specific information\n"
8879        "Display information for a route distinguisher\n"
8880        "VPN Route Distinguisher\n"
8881        "Detailed information on TCP and BGP neighbor connections\n")
8882
8883 ALIAS (show_ip_bgp_neighbors,
8884        show_bgp_ipv6_neighbors_cmd,
8885        "show bgp ipv6 neighbors",
8886        SHOW_STR
8887        BGP_STR
8888        "Address family\n"
8889        "Detailed information on TCP and BGP neighbor connections\n")
8890
8891 DEFUN (show_ip_bgp_neighbors_peer,
8892        show_ip_bgp_neighbors_peer_cmd,
8893        "show ip bgp neighbors (A.B.C.D|X:X::X:X)",
8894        SHOW_STR
8895        IP_STR
8896        BGP_STR
8897        "Detailed information on TCP and BGP neighbor connections\n"
8898        "Neighbor to display information about\n"
8899        "Neighbor to display information about\n")
8900 {
8901   return bgp_show_neighbor_vty (vty, NULL, show_peer, argv[argc - 1]);
8902 }
8903
8904 ALIAS (show_ip_bgp_neighbors_peer,
8905        show_ip_bgp_ipv4_neighbors_peer_cmd,
8906        "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X)",
8907        SHOW_STR
8908        IP_STR
8909        BGP_STR
8910        "Address family\n"
8911        "Address Family modifier\n"
8912        "Address Family modifier\n"
8913        "Detailed information on TCP and BGP neighbor connections\n"
8914        "Neighbor to display information about\n"
8915        "Neighbor to display information about\n")
8916
8917 ALIAS (show_ip_bgp_neighbors_peer,
8918        show_ip_bgp_vpnv4_all_neighbors_peer_cmd,
8919        "show ip bgp vpnv4 all neighbors A.B.C.D",
8920        SHOW_STR
8921        IP_STR
8922        BGP_STR
8923        "Display VPNv4 NLRI specific information\n"
8924        "Display information about all VPNv4 NLRIs\n"
8925        "Detailed information on TCP and BGP neighbor connections\n"
8926        "Neighbor to display information about\n")
8927
8928 ALIAS (show_ip_bgp_neighbors_peer,
8929        show_ip_bgp_vpnv4_rd_neighbors_peer_cmd,
8930        "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D",
8931        SHOW_STR
8932        IP_STR
8933        BGP_STR
8934        "Display VPNv4 NLRI specific information\n"
8935        "Display information about all VPNv4 NLRIs\n"
8936        "Detailed information on TCP and BGP neighbor connections\n"
8937        "Neighbor to display information about\n")
8938
8939 ALIAS (show_ip_bgp_neighbors_peer,
8940        show_bgp_ipv6_neighbors_peer_cmd,
8941        "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X)",
8942        SHOW_STR
8943        BGP_STR
8944        "Address family\n"
8945        "Detailed information on TCP and BGP neighbor connections\n"
8946        "Neighbor to display information about\n"
8947        "Neighbor to display information about\n")
8948
8949 DEFUN (show_ip_bgp_instance_neighbors,
8950        show_ip_bgp_instance_neighbors_cmd,
8951        "show ip bgp view WORD neighbors",
8952        SHOW_STR
8953        IP_STR
8954        BGP_STR
8955        "BGP view\n"
8956        "View name\n"
8957        "Detailed information on TCP and BGP neighbor connections\n")
8958 {
8959   return bgp_show_neighbor_vty (vty, argv[0], show_all, NULL);
8960 }
8961
8962 ALIAS (show_ip_bgp_instance_neighbors,
8963        show_bgp_instance_ipv6_neighbors_cmd,
8964        "show bgp view WORD ipv6 neighbors",
8965        SHOW_STR
8966        BGP_STR
8967        "BGP view\n"
8968        "View name\n"
8969        "Address family\n"
8970        "Detailed information on TCP and BGP neighbor connections\n")
8971
8972 DEFUN (show_ip_bgp_instance_neighbors_peer,
8973        show_ip_bgp_instance_neighbors_peer_cmd,
8974        "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X)",
8975        SHOW_STR
8976        IP_STR
8977        BGP_STR
8978        "BGP view\n"
8979        "View name\n"
8980        "Detailed information on TCP and BGP neighbor connections\n"
8981        "Neighbor to display information about\n"
8982        "Neighbor to display information about\n")
8983 {
8984   return bgp_show_neighbor_vty (vty, argv[0], show_peer, argv[1]);
8985 }
8986
8987 /* Show BGP's AS paths internal data.  There are both `show ip bgp
8988    paths' and `show ip mbgp paths'.  Those functions results are the
8989    same.*/
8990 DEFUN (show_ip_bgp_paths, 
8991        show_ip_bgp_paths_cmd,
8992        "show ip bgp paths",
8993        SHOW_STR
8994        IP_STR
8995        BGP_STR
8996        "Path information\n")
8997 {
8998   vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE);
8999   aspath_print_all_vty (vty);
9000   return CMD_SUCCESS;
9001 }
9002
9003 DEFUN (show_ip_bgp_ipv4_paths, 
9004        show_ip_bgp_ipv4_paths_cmd,
9005        "show ip bgp ipv4 (unicast|multicast) paths",
9006        SHOW_STR
9007        IP_STR
9008        BGP_STR
9009        "Address family\n"
9010        "Address Family modifier\n"
9011        "Address Family modifier\n"
9012        "Path information\n")
9013 {
9014   vty_out (vty, "Address Refcnt Path\r\n");
9015   aspath_print_all_vty (vty);
9016
9017   return CMD_SUCCESS;
9018 }
9019
9020 DEFUN (show_bgp_neighbors,
9021        show_bgp_neighbors_cmd,
9022        "show bgp neighbors",
9023        SHOW_STR
9024        BGP_STR
9025        "Detailed information on TCP and BGP neighbor connections\n")
9026 {
9027   return bgp_show_neighbor_vty (vty, NULL, show_all, NULL);
9028 }
9029
9030 DEFUN (show_bgp_neighbors_peer,
9031        show_bgp_neighbors_peer_cmd,
9032        "show bgp neighbors (A.B.C.D|X:X::X:X)",
9033        SHOW_STR
9034        BGP_STR
9035        "Detailed information on TCP and BGP neighbor connections\n"
9036        "Neighbor to display information about\n"
9037        "Neighbor to display information about\n")
9038 {
9039   return bgp_show_neighbor_vty (vty, NULL, show_peer, argv[argc - 1]);
9040 }
9041
9042 DEFUN (show_bgp_instance_neighbors,
9043        show_bgp_instance_neighbors_cmd,
9044        "show bgp view WORD neighbors",
9045        SHOW_STR
9046        BGP_STR
9047        "BGP view\n"
9048        "View name\n"
9049        "Detailed information on TCP and BGP neighbor connections\n")
9050 {
9051   return bgp_show_neighbor_vty (vty, argv[0], show_all, NULL);
9052 }
9053
9054 DEFUN (show_bgp_instance_neighbors_peer,
9055        show_bgp_instance_neighbors_peer_cmd,
9056        "show bgp view WORD neighbors (A.B.C.D|X:X::X:X)",
9057        SHOW_STR
9058        BGP_STR
9059        "BGP view\n"
9060        "View name\n"
9061        "Detailed information on TCP and BGP neighbor connections\n"
9062        "Neighbor to display information about\n"
9063        "Neighbor to display information about\n")
9064 {
9065   return bgp_show_neighbor_vty (vty, argv[0], show_peer, argv[1]);
9066 }
9067
9068 ALIAS (show_bgp_instance_neighbors_peer,
9069        show_bgp_instance_ipv6_neighbors_peer_cmd,
9070        "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X)",
9071        SHOW_STR
9072        BGP_STR
9073        "BGP view\n"
9074        "View name\n"
9075        "Address family\n"
9076        "Detailed information on TCP and BGP neighbor connections\n"
9077        "Neighbor to display information about\n"
9078        "Neighbor to display information about\n")
9079        
9080 /* Show BGP's AS paths internal data.  There are both `show ip bgp
9081    paths' and `show ip mbgp paths'.  Those functions results are the
9082    same.*/
9083 DEFUN (show_bgp_ipv4_paths, 
9084        show_bgp_ipv4_paths_cmd,
9085        "show bgp paths",
9086        SHOW_STR
9087        BGP_STR
9088        "Path information\n")
9089 {
9090   vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE);
9091   aspath_print_all_vty (vty);
9092   return CMD_SUCCESS;
9093 }
9094
9095 #include "hash.h"
9096
9097 static void
9098 community_show_all_iterator (struct hash_backet *backet, struct vty *vty)
9099 {
9100   struct community *com;
9101
9102   com = (struct community *) backet->data;
9103   vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, com->refcnt,
9104            community_str (com), VTY_NEWLINE);
9105 }
9106
9107 /* Show BGP's community internal data. */
9108 DEFUN (show_ip_bgp_community_info, 
9109        show_ip_bgp_community_info_cmd,
9110        "show ip bgp community-info",
9111        SHOW_STR
9112        IP_STR
9113        BGP_STR
9114        "List all bgp community information\n")
9115 {
9116   vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE);
9117
9118   hash_iterate (community_hash (), 
9119                 (void (*) (struct hash_backet *, void *))
9120                 community_show_all_iterator,
9121                 vty);
9122
9123   return CMD_SUCCESS;
9124 }
9125
9126 static void
9127 lcommunity_show_all_iterator (struct hash_backet *backet, struct vty *vty)
9128 {
9129   struct lcommunity *lcom;
9130
9131   lcom = (struct lcommunity *) backet->data;
9132   vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, lcom->refcnt,
9133            lcommunity_str (lcom), VTY_NEWLINE);
9134 }
9135
9136 /* Show BGP's community internal data. */
9137 DEFUN (show_ip_bgp_lcommunity_info,
9138        show_ip_bgp_lcommunity_info_cmd,
9139        "show ip bgp large-community-info",
9140        SHOW_STR
9141        IP_STR
9142        BGP_STR
9143        "List all bgp large-community information\n")
9144 {
9145   vty_out (vty, "Address Refcnt Large-community%s", VTY_NEWLINE);
9146
9147   hash_iterate (lcommunity_hash (),
9148                 (void (*) (struct hash_backet *, void *))
9149                 lcommunity_show_all_iterator,
9150                 vty);
9151
9152   return CMD_SUCCESS;
9153 }
9154
9155 DEFUN (show_ip_bgp_attr_info, 
9156        show_ip_bgp_attr_info_cmd,
9157        "show ip bgp attribute-info",
9158        SHOW_STR
9159        IP_STR
9160        BGP_STR
9161        "List all bgp attribute information\n")
9162 {
9163   attr_show_all (vty);
9164   return CMD_SUCCESS;
9165 }
9166
9167 static int
9168 bgp_write_rsclient_summary (struct vty *vty, struct peer *rsclient,
9169         afi_t afi, safi_t safi)
9170 {
9171   char timebuf[BGP_UPTIME_LEN];
9172   char rmbuf[14];
9173   const char *rmname;
9174   struct peer *peer;
9175   struct listnode *node, *nnode;
9176   int len;
9177   int count = 0;
9178
9179   if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP))
9180     {
9181       for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, peer))
9182         {
9183           count++;
9184           bgp_write_rsclient_summary (vty, peer, afi, safi);
9185         }
9186       return count;
9187     }
9188
9189   len = vty_out (vty, "%s", rsclient->host);
9190   len = 16 - len;
9191
9192   if (len < 1)
9193     vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
9194   else
9195     vty_out (vty, "%*s", len, " ");
9196
9197   vty_out (vty, "4 ");
9198
9199   vty_out (vty, "%10u ", rsclient->as);
9200
9201   rmname = ROUTE_MAP_EXPORT_NAME(&rsclient->filter[afi][safi]);
9202   if ( rmname && strlen (rmname) > 13 )
9203     {
9204       sprintf (rmbuf, "%13s", "...");
9205       rmname = strncpy (rmbuf, rmname, 10);
9206     }
9207   else if (! rmname)
9208     rmname = "<none>";
9209   vty_out (vty, " %13s ", rmname);
9210
9211   rmname = ROUTE_MAP_IMPORT_NAME(&rsclient->filter[afi][safi]);
9212   if ( rmname && strlen (rmname) > 13 )
9213     {
9214       sprintf (rmbuf, "%13s", "...");
9215       rmname = strncpy (rmbuf, rmname, 10);
9216     }
9217   else if (! rmname)
9218     rmname = "<none>";
9219   vty_out (vty, " %13s ", rmname);
9220
9221   vty_out (vty, "%8s", peer_uptime (rsclient->uptime, timebuf, BGP_UPTIME_LEN));
9222
9223   if (CHECK_FLAG (rsclient->flags, PEER_FLAG_SHUTDOWN))
9224     vty_out (vty, " Idle (Admin)");
9225   else if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_PREFIX_OVERFLOW))
9226     vty_out (vty, " Idle (PfxCt)");
9227   else
9228     vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, rsclient->status));
9229
9230   vty_out (vty, "%s", VTY_NEWLINE);
9231
9232   return 1;
9233 }
9234
9235 static int
9236 bgp_show_rsclient_summary (struct vty *vty, struct bgp *bgp, 
9237                            afi_t afi, safi_t safi)
9238 {
9239   struct peer *peer;
9240   struct listnode *node, *nnode;
9241   int count = 0;
9242
9243   /* Header string for each address family. */
9244   static char header[] = "Neighbor        V         AS  Export-Policy  Import-Policy  Up/Down  State";
9245
9246   for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, peer))
9247     {
9248       if (peer->afc[afi][safi] &&
9249          CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
9250        {
9251          if (! count)
9252            {
9253              vty_out (vty,
9254                       "Route Server's BGP router identifier %s%s",
9255                       inet_ntoa (bgp->router_id), VTY_NEWLINE);
9256              vty_out (vty,
9257               "Route Server's local AS number %u%s", bgp->as,
9258                        VTY_NEWLINE);
9259
9260              vty_out (vty, "%s", VTY_NEWLINE);
9261              vty_out (vty, "%s%s", header, VTY_NEWLINE);
9262            }
9263
9264          count += bgp_write_rsclient_summary (vty, peer, afi, safi);
9265        }
9266     }
9267
9268   if (count)
9269     vty_out (vty, "%sTotal number of Route Server Clients %d%s", VTY_NEWLINE,
9270             count, VTY_NEWLINE);
9271   else
9272     vty_out (vty, "No %s Route Server Client is configured%s",
9273             afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
9274
9275   return CMD_SUCCESS;
9276 }
9277
9278 static int
9279 bgp_show_rsclient_summary_vty (struct vty *vty, const char *name, 
9280                                afi_t afi, safi_t safi)
9281 {
9282   struct bgp *bgp;
9283
9284   if (name)
9285     {
9286       bgp = bgp_lookup_by_name (name);
9287
9288       if (! bgp)
9289        {
9290          vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
9291          return CMD_WARNING;
9292        }
9293
9294       bgp_show_rsclient_summary (vty, bgp, afi, safi);
9295       return CMD_SUCCESS;
9296     }
9297
9298   bgp = bgp_get_default ();
9299
9300   if (bgp)
9301     bgp_show_rsclient_summary (vty, bgp, afi, safi);
9302
9303   return CMD_SUCCESS;
9304 }
9305
9306 /* 'show bgp rsclient' commands. */
9307 DEFUN (show_ip_bgp_rsclient_summary,
9308        show_ip_bgp_rsclient_summary_cmd,
9309        "show ip bgp rsclient summary",
9310        SHOW_STR
9311        IP_STR
9312        BGP_STR
9313        "Information about Route Server Clients\n"
9314        "Summary of all Route Server Clients\n")
9315 {
9316   return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
9317 }
9318
9319 DEFUN (show_ip_bgp_instance_rsclient_summary,
9320        show_ip_bgp_instance_rsclient_summary_cmd,
9321        "show ip bgp view WORD rsclient summary",
9322        SHOW_STR
9323        IP_STR
9324        BGP_STR
9325        "BGP view\n"
9326        "View name\n"
9327        "Information about Route Server Clients\n"
9328        "Summary of all Route Server Clients\n")
9329 {
9330   return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
9331 }
9332
9333 DEFUN (show_ip_bgp_ipv4_rsclient_summary,
9334       show_ip_bgp_ipv4_rsclient_summary_cmd,
9335       "show ip bgp ipv4 (unicast|multicast) rsclient summary",
9336        SHOW_STR
9337        IP_STR
9338        BGP_STR
9339        "Address family\n"
9340        "Address Family modifier\n"
9341        "Address Family modifier\n"
9342        "Information about Route Server Clients\n"
9343        "Summary of all Route Server Clients\n")
9344 {
9345   if (strncmp (argv[0], "m", 1) == 0)
9346     return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST);
9347
9348   return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
9349 }
9350
9351 DEFUN (show_ip_bgp_instance_ipv4_rsclient_summary,
9352       show_ip_bgp_instance_ipv4_rsclient_summary_cmd,
9353       "show ip bgp view WORD ipv4 (unicast|multicast) rsclient summary",
9354        SHOW_STR
9355        IP_STR
9356        BGP_STR
9357        "BGP view\n"
9358        "View name\n"
9359        "Address family\n"
9360        "Address Family modifier\n"
9361        "Address Family modifier\n"
9362        "Information about Route Server Clients\n"
9363        "Summary of all Route Server Clients\n")
9364 {
9365   if (strncmp (argv[1], "m", 1) == 0)
9366     return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST);
9367
9368   return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
9369 }
9370
9371 DEFUN (show_bgp_instance_ipv4_safi_rsclient_summary,
9372        show_bgp_instance_ipv4_safi_rsclient_summary_cmd,
9373        "show bgp view WORD ipv4 (unicast|multicast) rsclient summary",
9374        SHOW_STR
9375        BGP_STR
9376        "BGP view\n"
9377        "View name\n"
9378        "Address family\n"
9379        "Address Family modifier\n"
9380        "Address Family modifier\n"
9381        "Information about Route Server Clients\n"
9382        "Summary of all Route Server Clients\n")
9383 {
9384   safi_t safi;
9385
9386   if (argc == 2) {
9387     safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
9388     return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, safi);
9389   } else {
9390     safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
9391     return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, safi);
9392   }
9393 }
9394
9395 ALIAS (show_bgp_instance_ipv4_safi_rsclient_summary,
9396        show_bgp_ipv4_safi_rsclient_summary_cmd,
9397        "show bgp ipv4 (unicast|multicast) rsclient summary",
9398        SHOW_STR
9399        BGP_STR
9400        "Address family\n"
9401        "Address Family modifier\n"
9402        "Address Family modifier\n"
9403        "Information about Route Server Clients\n"
9404        "Summary of all Route Server Clients\n")
9405
9406 DEFUN (show_bgp_rsclient_summary,
9407        show_bgp_rsclient_summary_cmd,
9408        "show bgp rsclient summary",
9409        SHOW_STR
9410        BGP_STR
9411        "Information about Route Server Clients\n"
9412        "Summary of all Route Server Clients\n")
9413 {
9414     vty_out(vty, "%sIPv4 Unicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
9415     vty_out(vty, "---------------------%s", VTY_NEWLINE);
9416     bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
9417     vty_out(vty, "%sIPv4 Multicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
9418     vty_out(vty, "-----------------------%s", VTY_NEWLINE);
9419     bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST);
9420     vty_out(vty, "%sIPv4 VPN Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
9421     vty_out(vty, "-----------------%s", VTY_NEWLINE);
9422     bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN);
9423     vty_out(vty, "%sIPv4 Encap Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
9424     vty_out(vty, "-------------------%s", VTY_NEWLINE);
9425     bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_ENCAP);
9426
9427     vty_out(vty, "%sIPv6 Unicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
9428     vty_out(vty, "---------------------%s", VTY_NEWLINE);
9429     bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
9430     vty_out(vty, "%sIPv6 Multicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
9431     vty_out(vty, "-----------------------%s", VTY_NEWLINE);
9432     bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST);
9433     vty_out(vty, "%sIPv6 VPN Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
9434     vty_out(vty, "-----------------%s", VTY_NEWLINE);
9435     bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP6, SAFI_MPLS_VPN);
9436     vty_out(vty, "%sIPv6 Encap Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
9437     vty_out(vty, "-------------------%s", VTY_NEWLINE);
9438     bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP6, SAFI_ENCAP);
9439
9440     return CMD_SUCCESS;
9441 }
9442
9443 DEFUN (show_bgp_instance_rsclient_summary,
9444        show_bgp_instance_rsclient_summary_cmd,
9445        "show bgp view WORD rsclient summary",
9446        SHOW_STR
9447        BGP_STR
9448        "BGP view\n"
9449        "View name\n"
9450        "Information about Route Server Clients\n"
9451        "Summary of all Route Server Clients\n")
9452 {
9453     vty_out(vty, "%sIPv4 Unicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
9454     vty_out(vty, "---------------------%s", VTY_NEWLINE);
9455     bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
9456     vty_out(vty, "%sIPv4 Multicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
9457     vty_out(vty, "-----------------------%s", VTY_NEWLINE);
9458     bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST);
9459     vty_out(vty, "%sIPv4 VPN Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
9460     vty_out(vty, "-----------------%s", VTY_NEWLINE);
9461     bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_MPLS_VPN);
9462     vty_out(vty, "%sIPv4 Encap Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
9463     vty_out(vty, "-------------------%s", VTY_NEWLINE);
9464     bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_ENCAP);
9465
9466     vty_out(vty, "%sIPv6 Unicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
9467     vty_out(vty, "---------------------%s", VTY_NEWLINE);
9468     bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
9469     vty_out(vty, "%sIPv6 Multicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
9470     vty_out(vty, "-----------------------%s", VTY_NEWLINE);
9471     bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP6, SAFI_MULTICAST);
9472     vty_out(vty, "%sIPv6 VPN Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
9473     vty_out(vty, "-----------------%s", VTY_NEWLINE);
9474     bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP6, SAFI_MPLS_VPN);
9475     vty_out(vty, "%sIPv6 Encap Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
9476     vty_out(vty, "-------------------%s", VTY_NEWLINE);
9477     bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP6, SAFI_ENCAP);
9478
9479     return CMD_SUCCESS;
9480 }
9481
9482 DEFUN (show_bgp_ipv6_rsclient_summary,
9483       show_bgp_ipv6_rsclient_summary_cmd,
9484       "show bgp ipv6 rsclient summary",
9485        SHOW_STR
9486        BGP_STR
9487        "Address family\n"
9488        "Information about Route Server Clients\n"
9489        "Summary of all Route Server Clients\n")
9490 {
9491     vty_out(vty, "%sIPv6 Unicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
9492     vty_out(vty, "---------------------%s", VTY_NEWLINE);
9493     bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
9494     vty_out(vty, "%sIPv6 Multicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
9495     vty_out(vty, "-----------------------%s", VTY_NEWLINE);
9496     bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST);
9497     vty_out(vty, "%sIPv6 VPN Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
9498     vty_out(vty, "-----------------%s", VTY_NEWLINE);
9499     bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP6, SAFI_MPLS_VPN);
9500     vty_out(vty, "%sIPv6 Encap Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
9501     vty_out(vty, "-------------------%s", VTY_NEWLINE);
9502     bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP6, SAFI_ENCAP);
9503
9504     return CMD_SUCCESS;
9505 }
9506
9507 DEFUN (show_bgp_instance_ipv6_rsclient_summary,
9508       show_bgp_instance_ipv6_rsclient_summary_cmd,
9509        "show bgp view WORD ipv6 rsclient summary",
9510        SHOW_STR
9511        BGP_STR
9512        "BGP view\n"
9513        "View name\n"
9514        "Address family\n"
9515        "Information about Route Server Clients\n"
9516        "Summary of all Route Server Clients\n")
9517 {
9518     vty_out(vty, "%sIPv6 Unicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
9519     vty_out(vty, "---------------------%s", VTY_NEWLINE);
9520     bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
9521     vty_out(vty, "%sIPv6 Multicast Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
9522     vty_out(vty, "-----------------------%s", VTY_NEWLINE);
9523     bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP6, SAFI_MULTICAST);
9524     vty_out(vty, "%sIPv6 VPN Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
9525     vty_out(vty, "-----------------%s", VTY_NEWLINE);
9526     bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP6, SAFI_MPLS_VPN);
9527     vty_out(vty, "%sIPv6 Encap Summary:%s", VTY_NEWLINE, VTY_NEWLINE);
9528     vty_out(vty, "-------------------%s", VTY_NEWLINE);
9529     bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP6, SAFI_ENCAP);
9530
9531     return CMD_SUCCESS;
9532 }
9533
9534 DEFUN (show_bgp_instance_ipv6_safi_rsclient_summary,
9535        show_bgp_instance_ipv6_safi_rsclient_summary_cmd,
9536        "show bgp view WORD ipv6 (unicast|multicast) rsclient summary",
9537        SHOW_STR
9538        BGP_STR
9539        "BGP view\n"
9540        "View name\n"
9541        "Address family\n"
9542        "Address Family modifier\n"
9543        "Address Family modifier\n"
9544        "Information about Route Server Clients\n"
9545        "Summary of all Route Server Clients\n")
9546 {
9547   safi_t safi;
9548
9549   if (argc == 2) {
9550     safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
9551     return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP6, safi);
9552   } else {
9553     safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
9554     return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP6, safi);
9555   }
9556 }
9557
9558 ALIAS (show_bgp_instance_ipv6_safi_rsclient_summary,
9559        show_bgp_ipv6_safi_rsclient_summary_cmd,
9560        "show bgp ipv6 (unicast|multicast) rsclient summary",
9561        SHOW_STR
9562        BGP_STR
9563        IPV6_STR
9564        "Address Family modifier\n"
9565        "Address Family modifier\n"
9566        "Information about Route Server Clients\n"
9567        "Summary of all Route Server Clients\n")
9568
9569 /* Redistribute VTY commands.  */
9570
9571 DEFUN (bgp_redistribute_ipv4,
9572        bgp_redistribute_ipv4_cmd,
9573        "redistribute " QUAGGA_IP_REDIST_STR_BGPD,
9574        "Redistribute information from another routing protocol\n"
9575        QUAGGA_IP_REDIST_HELP_STR_BGPD)
9576 {
9577   int type;
9578
9579   type = proto_redistnum (AFI_IP, argv[0]);
9580   if (type < 0 || type == ZEBRA_ROUTE_BGP)
9581     {
9582       vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
9583       return CMD_WARNING;
9584     }
9585   return bgp_redistribute_set (vty->index, AFI_IP, type);
9586 }
9587
9588 DEFUN (bgp_redistribute_ipv4_rmap,
9589        bgp_redistribute_ipv4_rmap_cmd,
9590        "redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD",
9591        "Redistribute information from another routing protocol\n"
9592        QUAGGA_IP_REDIST_HELP_STR_BGPD
9593        "Route map reference\n"
9594        "Pointer to route-map entries\n")
9595 {
9596   int type;
9597
9598   type = proto_redistnum (AFI_IP, argv[0]);
9599   if (type < 0 || type == ZEBRA_ROUTE_BGP)
9600     {
9601       vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
9602       return CMD_WARNING;
9603     }
9604
9605   bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[1]);
9606   return bgp_redistribute_set (vty->index, AFI_IP, type);
9607 }
9608
9609 DEFUN (bgp_redistribute_ipv4_metric,
9610        bgp_redistribute_ipv4_metric_cmd,
9611        "redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295>",
9612        "Redistribute information from another routing protocol\n"
9613        QUAGGA_IP_REDIST_HELP_STR_BGPD
9614        "Metric for redistributed routes\n"
9615        "Default metric\n")
9616 {
9617   int type;
9618   u_int32_t metric;
9619
9620   type = proto_redistnum (AFI_IP, argv[0]);
9621   if (type < 0 || type == ZEBRA_ROUTE_BGP)
9622     {
9623       vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
9624       return CMD_WARNING;
9625     }
9626   VTY_GET_INTEGER ("metric", metric, argv[1]);
9627
9628   bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
9629   return bgp_redistribute_set (vty->index, AFI_IP, type);
9630 }
9631
9632 DEFUN (bgp_redistribute_ipv4_rmap_metric,
9633        bgp_redistribute_ipv4_rmap_metric_cmd,
9634        "redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
9635        "Redistribute information from another routing protocol\n"
9636        QUAGGA_IP_REDIST_HELP_STR_BGPD
9637        "Route map reference\n"
9638        "Pointer to route-map entries\n"
9639        "Metric for redistributed routes\n"
9640        "Default metric\n")
9641 {
9642   int type;
9643   u_int32_t metric;
9644
9645   type = proto_redistnum (AFI_IP, argv[0]);
9646   if (type < 0 || type == ZEBRA_ROUTE_BGP)
9647     {
9648       vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
9649       return CMD_WARNING;
9650     }
9651   VTY_GET_INTEGER ("metric", metric, argv[2]);
9652
9653   bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[1]);
9654   bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
9655   return bgp_redistribute_set (vty->index, AFI_IP, type);
9656 }
9657
9658 DEFUN (bgp_redistribute_ipv4_metric_rmap,
9659        bgp_redistribute_ipv4_metric_rmap_cmd,
9660        "redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
9661        "Redistribute information from another routing protocol\n"
9662        QUAGGA_IP_REDIST_HELP_STR_BGPD
9663        "Metric for redistributed routes\n"
9664        "Default metric\n"
9665        "Route map reference\n"
9666        "Pointer to route-map entries\n")
9667 {
9668   int type;
9669   u_int32_t metric;
9670
9671   type = proto_redistnum (AFI_IP, argv[0]);
9672   if (type < 0 || type == ZEBRA_ROUTE_BGP)
9673     {
9674       vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
9675       return CMD_WARNING;
9676     }
9677   VTY_GET_INTEGER ("metric", metric, argv[1]);
9678
9679   bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
9680   bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[2]);
9681   return bgp_redistribute_set (vty->index, AFI_IP, type);
9682 }
9683
9684 DEFUN (no_bgp_redistribute_ipv4,
9685        no_bgp_redistribute_ipv4_cmd,
9686        "no redistribute " QUAGGA_IP_REDIST_STR_BGPD,
9687        NO_STR
9688        "Redistribute information from another routing protocol\n"
9689        QUAGGA_IP_REDIST_HELP_STR_BGPD)
9690 {
9691   int type;
9692
9693   type = proto_redistnum (AFI_IP, argv[0]);
9694   if (type < 0 || type == ZEBRA_ROUTE_BGP)
9695     {
9696       vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
9697       return CMD_WARNING;
9698     }
9699
9700   return bgp_redistribute_unset (vty->index, AFI_IP, type);
9701 }
9702
9703 ALIAS (no_bgp_redistribute_ipv4,
9704        no_bgp_redistribute_ipv4_rmap_cmd,
9705        "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD",
9706        NO_STR
9707        "Redistribute information from another routing protocol\n"
9708        QUAGGA_IP_REDIST_HELP_STR_BGPD
9709        "Route map reference\n"
9710        "Pointer to route-map entries\n")
9711
9712 ALIAS (no_bgp_redistribute_ipv4,
9713        no_bgp_redistribute_ipv4_metric_cmd,
9714        "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295>",
9715        NO_STR
9716        "Redistribute information from another routing protocol\n"
9717        QUAGGA_IP_REDIST_HELP_STR_BGPD
9718        "Metric for redistributed routes\n"
9719        "Default metric\n")
9720
9721 ALIAS (no_bgp_redistribute_ipv4,
9722        no_bgp_redistribute_ipv4_rmap_metric_cmd,
9723        "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
9724        NO_STR
9725        "Redistribute information from another routing protocol\n"
9726        QUAGGA_IP_REDIST_HELP_STR_BGPD
9727        "Route map reference\n"
9728        "Pointer to route-map entries\n"
9729        "Metric for redistributed routes\n"
9730        "Default metric\n")
9731
9732 ALIAS (no_bgp_redistribute_ipv4,
9733        no_bgp_redistribute_ipv4_metric_rmap_cmd,
9734        "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
9735        NO_STR
9736        "Redistribute information from another routing protocol\n"
9737        QUAGGA_IP_REDIST_HELP_STR_BGPD
9738        "Metric for redistributed routes\n"
9739        "Default metric\n"
9740        "Route map reference\n"
9741        "Pointer to route-map entries\n")
9742
9743 DEFUN (bgp_redistribute_ipv6,
9744        bgp_redistribute_ipv6_cmd,
9745        "redistribute " QUAGGA_IP6_REDIST_STR_BGPD,
9746        "Redistribute information from another routing protocol\n"
9747        QUAGGA_IP6_REDIST_HELP_STR_BGPD)
9748 {
9749   int type;
9750
9751   type = proto_redistnum (AFI_IP6, argv[0]);
9752   if (type < 0 || type == ZEBRA_ROUTE_BGP)
9753     {
9754       vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
9755       return CMD_WARNING;
9756     }
9757
9758   return bgp_redistribute_set (vty->index, AFI_IP6, type);
9759 }
9760
9761 DEFUN (bgp_redistribute_ipv6_rmap,
9762        bgp_redistribute_ipv6_rmap_cmd,
9763        "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD",
9764        "Redistribute information from another routing protocol\n"
9765        QUAGGA_IP6_REDIST_HELP_STR_BGPD
9766        "Route map reference\n"
9767        "Pointer to route-map entries\n")
9768 {
9769   int type;
9770
9771   type = proto_redistnum (AFI_IP6, argv[0]);
9772   if (type < 0 || type == ZEBRA_ROUTE_BGP)
9773     {
9774       vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
9775       return CMD_WARNING;
9776     }
9777
9778   bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[1]);
9779   return bgp_redistribute_set (vty->index, AFI_IP6, type);
9780 }
9781
9782 DEFUN (bgp_redistribute_ipv6_metric,
9783        bgp_redistribute_ipv6_metric_cmd,
9784        "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295>",
9785        "Redistribute information from another routing protocol\n"
9786        QUAGGA_IP6_REDIST_HELP_STR_BGPD
9787        "Metric for redistributed routes\n"
9788        "Default metric\n")
9789 {
9790   int type;
9791   u_int32_t metric;
9792
9793   type = proto_redistnum (AFI_IP6, argv[0]);
9794   if (type < 0 || type == ZEBRA_ROUTE_BGP)
9795     {
9796       vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
9797       return CMD_WARNING;
9798     }
9799   VTY_GET_INTEGER ("metric", metric, argv[1]);
9800
9801   bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
9802   return bgp_redistribute_set (vty->index, AFI_IP6, type);
9803 }
9804
9805 DEFUN (bgp_redistribute_ipv6_rmap_metric,
9806        bgp_redistribute_ipv6_rmap_metric_cmd,
9807        "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
9808        "Redistribute information from another routing protocol\n"
9809        QUAGGA_IP6_REDIST_HELP_STR_BGPD
9810        "Route map reference\n"
9811        "Pointer to route-map entries\n"
9812        "Metric for redistributed routes\n"
9813        "Default metric\n")
9814 {
9815   int type;
9816   u_int32_t metric;
9817
9818   type = proto_redistnum (AFI_IP6, argv[0]);
9819   if (type < 0 || type == ZEBRA_ROUTE_BGP)
9820     {
9821       vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
9822       return CMD_WARNING;
9823     }
9824   VTY_GET_INTEGER ("metric", metric, argv[2]);
9825
9826   bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[1]);
9827   bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
9828   return bgp_redistribute_set (vty->index, AFI_IP6, type);
9829 }
9830
9831 DEFUN (bgp_redistribute_ipv6_metric_rmap,
9832        bgp_redistribute_ipv6_metric_rmap_cmd,
9833        "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
9834        "Redistribute information from another routing protocol\n"
9835        QUAGGA_IP6_REDIST_HELP_STR_BGPD
9836        "Metric for redistributed routes\n"
9837        "Default metric\n"
9838        "Route map reference\n"
9839        "Pointer to route-map entries\n")
9840 {
9841   int type;
9842   u_int32_t metric;
9843
9844   type = proto_redistnum (AFI_IP6, argv[0]);
9845   if (type < 0 || type == ZEBRA_ROUTE_BGP)
9846     {
9847       vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
9848       return CMD_WARNING;
9849     }
9850   VTY_GET_INTEGER ("metric", metric, argv[1]);
9851
9852   bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
9853   bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[2]);
9854   return bgp_redistribute_set (vty->index, AFI_IP6, type);
9855 }
9856
9857 DEFUN (no_bgp_redistribute_ipv6,
9858        no_bgp_redistribute_ipv6_cmd,
9859        "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD,
9860        NO_STR
9861        "Redistribute information from another routing protocol\n"
9862        QUAGGA_IP6_REDIST_HELP_STR_BGPD)
9863 {
9864   int type;
9865
9866   type = proto_redistnum (AFI_IP6, argv[0]);
9867   if (type < 0 || type == ZEBRA_ROUTE_BGP)
9868     {
9869       vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
9870       return CMD_WARNING;
9871     }
9872
9873   return bgp_redistribute_unset (vty->index, AFI_IP6, type);
9874 }
9875
9876 ALIAS (no_bgp_redistribute_ipv6,
9877        no_bgp_redistribute_ipv6_rmap_cmd,
9878        "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD",
9879        NO_STR
9880        "Redistribute information from another routing protocol\n"
9881        QUAGGA_IP6_REDIST_HELP_STR_BGPD
9882        "Route map reference\n"
9883        "Pointer to route-map entries\n")
9884
9885 ALIAS (no_bgp_redistribute_ipv6,
9886        no_bgp_redistribute_ipv6_metric_cmd,
9887        "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295>",
9888        NO_STR
9889        "Redistribute information from another routing protocol\n"
9890        QUAGGA_IP6_REDIST_HELP_STR_BGPD
9891        "Metric for redistributed routes\n"
9892        "Default metric\n")
9893
9894 ALIAS (no_bgp_redistribute_ipv6,
9895        no_bgp_redistribute_ipv6_rmap_metric_cmd,
9896        "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
9897        NO_STR
9898        "Redistribute information from another routing protocol\n"
9899        QUAGGA_IP6_REDIST_HELP_STR_BGPD
9900        "Route map reference\n"
9901        "Pointer to route-map entries\n"
9902        "Metric for redistributed routes\n"
9903        "Default metric\n")
9904
9905 ALIAS (no_bgp_redistribute_ipv6,
9906        no_bgp_redistribute_ipv6_metric_rmap_cmd,
9907        "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
9908        NO_STR
9909        "Redistribute information from another routing protocol\n"
9910        QUAGGA_IP6_REDIST_HELP_STR_BGPD
9911        "Metric for redistributed routes\n"
9912        "Default metric\n"
9913        "Route map reference\n"
9914        "Pointer to route-map entries\n")
9915
9916 int
9917 bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi,
9918                                safi_t safi, int *write)
9919 {
9920   int i;
9921
9922   /* Unicast redistribution only.  */
9923   if (safi != SAFI_UNICAST)
9924     return 0;
9925
9926   for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
9927     {
9928       /* Redistribute BGP does not make sense.  */
9929       if (bgp->redist[afi][i] && i != ZEBRA_ROUTE_BGP)
9930         {
9931           /* Display "address-family" when it is not yet diplayed.  */
9932           bgp_config_write_family_header (vty, afi, safi, write);
9933
9934           /* "redistribute" configuration.  */
9935           vty_out (vty, " redistribute %s", zebra_route_string(i));
9936
9937           if (bgp->redist_metric_flag[afi][i])
9938             vty_out (vty, " metric %u", bgp->redist_metric[afi][i]);
9939
9940           if (bgp->rmap[afi][i].name)
9941             vty_out (vty, " route-map %s", bgp->rmap[afi][i].name);
9942
9943           vty_out (vty, "%s", VTY_NEWLINE);
9944         }
9945     }
9946   return *write;
9947 }
9948
9949 /* BGP node structure. */
9950 static struct cmd_node bgp_node =
9951 {
9952   BGP_NODE,
9953   "%s(config-router)# ",
9954   1,
9955 };
9956
9957 static struct cmd_node bgp_ipv4_unicast_node =
9958 {
9959   BGP_IPV4_NODE,
9960   "%s(config-router-af)# ",
9961   1,
9962 };
9963
9964 static struct cmd_node bgp_ipv4_multicast_node =
9965 {
9966   BGP_IPV4M_NODE,
9967   "%s(config-router-af)# ",
9968   1,
9969 };
9970
9971 static struct cmd_node bgp_ipv6_unicast_node =
9972 {
9973   BGP_IPV6_NODE,
9974   "%s(config-router-af)# ",
9975   1,
9976 };
9977
9978 static struct cmd_node bgp_ipv6_multicast_node =
9979 {
9980   BGP_IPV6M_NODE,
9981   "%s(config-router-af)# ",
9982   1,
9983 };
9984
9985 static struct cmd_node bgp_vpnv4_node =
9986 {
9987   BGP_VPNV4_NODE,
9988   "%s(config-router-af)# ",
9989   1
9990 };
9991
9992 static struct cmd_node bgp_vpnv6_node =
9993 {
9994   BGP_VPNV6_NODE,
9995   "%s(config-router-af-vpnv6)# ",
9996   1
9997 };
9998
9999 static struct cmd_node bgp_encap_node =
10000 {
10001   BGP_ENCAP_NODE,
10002   "%s(config-router-af-encap)# ",
10003   1
10004 };
10005
10006 static struct cmd_node bgp_encapv6_node =
10007 {
10008   BGP_ENCAPV6_NODE,
10009   "%s(config-router-af-encapv6)# ",
10010   1
10011 };
10012
10013 static void community_list_vty (void);
10014
10015 void
10016 bgp_vty_init (void)
10017 {
10018   /* Install bgp top node. */
10019   install_node (&bgp_node, bgp_config_write);
10020   install_node (&bgp_ipv4_unicast_node, NULL);
10021   install_node (&bgp_ipv4_multicast_node, NULL);
10022   install_node (&bgp_ipv6_unicast_node, NULL);
10023   install_node (&bgp_ipv6_multicast_node, NULL);
10024   install_node (&bgp_vpnv4_node, NULL);
10025   install_node (&bgp_vpnv6_node, NULL);
10026   install_node (&bgp_encap_node, NULL);
10027   install_node (&bgp_encapv6_node, NULL);
10028
10029   /* Install default VTY commands to new nodes.  */
10030   install_default (BGP_NODE);
10031   install_default (BGP_IPV4_NODE);
10032   install_default (BGP_IPV4M_NODE);
10033   install_default (BGP_IPV6_NODE);
10034   install_default (BGP_IPV6M_NODE);
10035   install_default (BGP_VPNV4_NODE);
10036   install_default (BGP_VPNV6_NODE);
10037   install_default (BGP_ENCAP_NODE);
10038   install_default (BGP_ENCAPV6_NODE);
10039   
10040   /* "bgp multiple-instance" commands. */
10041   install_element (CONFIG_NODE, &bgp_multiple_instance_cmd);
10042   install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd);
10043
10044   /* "bgp config-type" commands. */
10045   install_element (CONFIG_NODE, &bgp_config_type_cmd);
10046   install_element (CONFIG_NODE, &no_bgp_config_type_cmd);
10047
10048   /* Dummy commands (Currently not supported) */
10049   install_element (BGP_NODE, &no_synchronization_cmd);
10050   install_element (BGP_NODE, &no_auto_summary_cmd);
10051
10052   /* "router bgp" commands. */
10053   install_element (CONFIG_NODE, &router_bgp_cmd);
10054   install_element (CONFIG_NODE, &router_bgp_view_cmd);
10055
10056   /* "no router bgp" commands. */
10057   install_element (CONFIG_NODE, &no_router_bgp_cmd);
10058   install_element (CONFIG_NODE, &no_router_bgp_view_cmd);
10059
10060   /* "bgp router-id" commands. */
10061   install_element (BGP_NODE, &bgp_router_id_cmd);
10062   install_element (BGP_NODE, &no_bgp_router_id_cmd);
10063   install_element (BGP_NODE, &no_bgp_router_id_val_cmd);
10064
10065   /* "bgp cluster-id" commands. */
10066   install_element (BGP_NODE, &bgp_cluster_id_cmd);
10067   install_element (BGP_NODE, &bgp_cluster_id32_cmd);
10068   install_element (BGP_NODE, &no_bgp_cluster_id_cmd);
10069   install_element (BGP_NODE, &no_bgp_cluster_id_arg_cmd);
10070
10071   /* "bgp confederation" commands. */
10072   install_element (BGP_NODE, &bgp_confederation_identifier_cmd);
10073   install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd);
10074   install_element (BGP_NODE, &no_bgp_confederation_identifier_arg_cmd);
10075
10076   /* "bgp confederation peers" commands. */
10077   install_element (BGP_NODE, &bgp_confederation_peers_cmd);
10078   install_element (BGP_NODE, &no_bgp_confederation_peers_cmd);
10079
10080   /* "maximum-paths" commands. */
10081   install_element (BGP_NODE, &bgp_maxpaths_cmd);
10082   install_element (BGP_NODE, &no_bgp_maxpaths_cmd);
10083   install_element (BGP_NODE, &no_bgp_maxpaths_arg_cmd);
10084   install_element (BGP_IPV4_NODE, &bgp_maxpaths_cmd);
10085   install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_cmd);
10086   install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_arg_cmd);
10087   install_element (BGP_IPV6_NODE, &bgp_maxpaths_cmd);
10088   install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_cmd);
10089   install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_arg_cmd);
10090   install_element (BGP_NODE, &bgp_maxpaths_ibgp_cmd);
10091   install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cmd);
10092   install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_arg_cmd);
10093   install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd);
10094   install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd);
10095   install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_arg_cmd);
10096   install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd);
10097   install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd);
10098   install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_arg_cmd);
10099
10100   /* "timers bgp" commands. */
10101   install_element (BGP_NODE, &bgp_timers_cmd);
10102   install_element (BGP_NODE, &no_bgp_timers_cmd);
10103   install_element (BGP_NODE, &no_bgp_timers_arg_cmd);
10104
10105   /* "bgp client-to-client reflection" commands */
10106   install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd);
10107   install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd);
10108
10109   /* "bgp always-compare-med" commands */
10110   install_element (BGP_NODE, &bgp_always_compare_med_cmd);
10111   install_element (BGP_NODE, &no_bgp_always_compare_med_cmd);
10112   
10113   /* "bgp deterministic-med" commands */
10114   install_element (BGP_NODE, &bgp_deterministic_med_cmd);
10115   install_element (BGP_NODE, &no_bgp_deterministic_med_cmd);
10116
10117   /* "bgp graceful-restart" commands */
10118   install_element (BGP_NODE, &bgp_graceful_restart_cmd);
10119   install_element (BGP_NODE, &no_bgp_graceful_restart_cmd);
10120   install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd);
10121   install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd);
10122   install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_val_cmd);
10123   install_element (BGP_NODE, &bgp_graceful_restart_restart_time_cmd);
10124   install_element (BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd);
10125   install_element (BGP_NODE, &no_bgp_graceful_restart_restart_time_val_cmd);
10126  
10127   /* "bgp fast-external-failover" commands */
10128   install_element (BGP_NODE, &bgp_fast_external_failover_cmd);
10129   install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd);
10130
10131   /* "bgp enforce-first-as" commands */
10132   install_element (BGP_NODE, &bgp_enforce_first_as_cmd);
10133   install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd);
10134
10135   /* "bgp bestpath compare-routerid" commands */
10136   install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd);
10137   install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd);
10138
10139   /* "bgp bestpath as-path ignore" commands */
10140   install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd);
10141   install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd);
10142
10143   /* "bgp bestpath as-path confed" commands */
10144   install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd);
10145   install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd);
10146
10147   /* "bgp bestpath as-path multipath-relax" commands */
10148   install_element (BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd);
10149   install_element (BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd);
10150
10151   /* "bgp log-neighbor-changes" commands */
10152   install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd);
10153   install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd);
10154
10155   /* "bgp bestpath med" commands */
10156   install_element (BGP_NODE, &bgp_bestpath_med_cmd);
10157   install_element (BGP_NODE, &bgp_bestpath_med2_cmd);
10158   install_element (BGP_NODE, &bgp_bestpath_med3_cmd);
10159   install_element (BGP_NODE, &no_bgp_bestpath_med_cmd);
10160   install_element (BGP_NODE, &no_bgp_bestpath_med2_cmd);
10161   install_element (BGP_NODE, &no_bgp_bestpath_med3_cmd);
10162
10163   /* "no bgp default ipv4-unicast" commands. */
10164   install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd);
10165   install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd);
10166   
10167   /* "bgp network import-check" commands. */
10168   install_element (BGP_NODE, &bgp_network_import_check_cmd);
10169   install_element (BGP_NODE, &no_bgp_network_import_check_cmd);
10170
10171   /* "bgp default local-preference" commands. */
10172   install_element (BGP_NODE, &bgp_default_local_preference_cmd);
10173   install_element (BGP_NODE, &no_bgp_default_local_preference_cmd);
10174   install_element (BGP_NODE, &no_bgp_default_local_preference_val_cmd);
10175
10176   /* bgp ibgp-allow-policy-mods command */
10177   install_element (BGP_NODE, &bgp_rr_allow_outbound_policy_cmd);
10178   install_element (BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd);
10179
10180   /* "neighbor remote-as" commands. */
10181   install_element (BGP_NODE, &neighbor_remote_as_cmd);
10182   install_element (BGP_NODE, &no_neighbor_cmd);
10183   install_element (BGP_NODE, &no_neighbor_remote_as_cmd);
10184
10185   /* "neighbor peer-group" commands. */
10186   install_element (BGP_NODE, &neighbor_peer_group_cmd);
10187   install_element (BGP_NODE, &no_neighbor_peer_group_cmd);
10188   install_element (BGP_NODE, &no_neighbor_peer_group_remote_as_cmd);
10189
10190   /* "neighbor local-as" commands. */
10191   install_element (BGP_NODE, &neighbor_local_as_cmd);
10192   install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd);
10193   install_element (BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd);
10194   install_element (BGP_NODE, &no_neighbor_local_as_cmd);
10195   install_element (BGP_NODE, &no_neighbor_local_as_val_cmd);
10196   install_element (BGP_NODE, &no_neighbor_local_as_val2_cmd);
10197   install_element (BGP_NODE, &no_neighbor_local_as_val3_cmd);
10198
10199   /* "neighbor password" commands. */
10200   install_element (BGP_NODE, &neighbor_password_cmd);
10201   install_element (BGP_NODE, &no_neighbor_password_cmd);
10202
10203   /* "neighbor activate" commands. */
10204   install_element (BGP_NODE, &neighbor_activate_cmd);
10205   install_element (BGP_IPV4_NODE, &neighbor_activate_cmd);
10206   install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd);
10207   install_element (BGP_IPV6_NODE, &neighbor_activate_cmd);
10208   install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd);
10209   install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd);
10210   install_element (BGP_VPNV6_NODE, &neighbor_activate_cmd);
10211   install_element (BGP_ENCAP_NODE, &neighbor_activate_cmd);
10212   install_element (BGP_ENCAPV6_NODE, &neighbor_activate_cmd);
10213
10214   /* "no neighbor activate" commands. */
10215   install_element (BGP_NODE, &no_neighbor_activate_cmd);
10216   install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd);
10217   install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd);
10218   install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd);
10219   install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd);
10220   install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd);
10221   install_element (BGP_VPNV6_NODE, &no_neighbor_activate_cmd);
10222   install_element (BGP_ENCAP_NODE, &no_neighbor_activate_cmd);
10223   install_element (BGP_ENCAPV6_NODE, &no_neighbor_activate_cmd);
10224
10225   /* "neighbor peer-group set" commands. */
10226   install_element (BGP_NODE, &neighbor_set_peer_group_cmd);
10227   install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_cmd);
10228   install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_cmd);
10229   install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd);
10230   install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_cmd);
10231   install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_cmd);
10232   install_element (BGP_VPNV6_NODE, &neighbor_set_peer_group_cmd);
10233   install_element (BGP_ENCAP_NODE, &neighbor_set_peer_group_cmd);
10234   install_element (BGP_ENCAPV6_NODE, &neighbor_set_peer_group_cmd);
10235   
10236   /* "no neighbor peer-group unset" commands. */
10237   install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd);
10238   install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd);
10239   install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_cmd);
10240   install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd);
10241   install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_cmd);
10242   install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_cmd);
10243   install_element (BGP_VPNV6_NODE, &no_neighbor_set_peer_group_cmd);
10244   install_element (BGP_ENCAP_NODE, &no_neighbor_set_peer_group_cmd);
10245   install_element (BGP_ENCAPV6_NODE, &no_neighbor_set_peer_group_cmd);
10246   
10247   /* "neighbor softreconfiguration inbound" commands.*/
10248   install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd);
10249   install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd);
10250   install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd);
10251   install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
10252   install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd);
10253   install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd);
10254   install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd);
10255   install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
10256   install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd);
10257   install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd);
10258   install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd);
10259   install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
10260   install_element (BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd);
10261   install_element (BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
10262   install_element (BGP_ENCAP_NODE, &neighbor_soft_reconfiguration_cmd);
10263   install_element (BGP_ENCAP_NODE, &no_neighbor_soft_reconfiguration_cmd);
10264   install_element (BGP_ENCAPV6_NODE, &neighbor_soft_reconfiguration_cmd);
10265   install_element (BGP_ENCAPV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
10266
10267   /* "neighbor attribute-unchanged" commands.  */
10268   install_element (BGP_NODE, &neighbor_attr_unchanged_cmd);
10269   install_element (BGP_NODE, &neighbor_attr_unchanged1_cmd);
10270   install_element (BGP_NODE, &neighbor_attr_unchanged2_cmd);
10271   install_element (BGP_NODE, &neighbor_attr_unchanged3_cmd);
10272   install_element (BGP_NODE, &neighbor_attr_unchanged4_cmd);
10273   install_element (BGP_NODE, &neighbor_attr_unchanged5_cmd);
10274   install_element (BGP_NODE, &neighbor_attr_unchanged6_cmd);
10275   install_element (BGP_NODE, &neighbor_attr_unchanged7_cmd);
10276   install_element (BGP_NODE, &neighbor_attr_unchanged8_cmd);
10277   install_element (BGP_NODE, &neighbor_attr_unchanged9_cmd);
10278   install_element (BGP_NODE, &neighbor_attr_unchanged10_cmd);
10279   install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd);
10280   install_element (BGP_NODE, &no_neighbor_attr_unchanged1_cmd);
10281   install_element (BGP_NODE, &no_neighbor_attr_unchanged2_cmd);
10282   install_element (BGP_NODE, &no_neighbor_attr_unchanged3_cmd);
10283   install_element (BGP_NODE, &no_neighbor_attr_unchanged4_cmd);
10284   install_element (BGP_NODE, &no_neighbor_attr_unchanged5_cmd);
10285   install_element (BGP_NODE, &no_neighbor_attr_unchanged6_cmd);
10286   install_element (BGP_NODE, &no_neighbor_attr_unchanged7_cmd);
10287   install_element (BGP_NODE, &no_neighbor_attr_unchanged8_cmd);
10288   install_element (BGP_NODE, &no_neighbor_attr_unchanged9_cmd);
10289   install_element (BGP_NODE, &no_neighbor_attr_unchanged10_cmd);
10290   install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd);
10291   install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged1_cmd);
10292   install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged2_cmd);
10293   install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged3_cmd);
10294   install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged4_cmd);
10295   install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged5_cmd);
10296   install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged6_cmd);
10297   install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged7_cmd);
10298   install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged8_cmd);
10299   install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged9_cmd);
10300   install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged10_cmd);
10301   install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd);
10302   install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged1_cmd);
10303   install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged2_cmd);
10304   install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged3_cmd);
10305   install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged4_cmd);
10306   install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged5_cmd);
10307   install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged6_cmd);
10308   install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged7_cmd);
10309   install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged8_cmd);
10310   install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged9_cmd);
10311   install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged10_cmd);
10312   install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd);
10313   install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged1_cmd);
10314   install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged2_cmd);
10315   install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged3_cmd);
10316   install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged4_cmd);
10317   install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged5_cmd);
10318   install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged6_cmd);
10319   install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged7_cmd);
10320   install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged8_cmd);
10321   install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged9_cmd);
10322   install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged10_cmd);
10323   install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd);
10324   install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged1_cmd);
10325   install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged2_cmd);
10326   install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged3_cmd);
10327   install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged4_cmd);
10328   install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged5_cmd);
10329   install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged6_cmd);
10330   install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged7_cmd);
10331   install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged8_cmd);
10332   install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged9_cmd);
10333   install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged10_cmd);
10334   install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd);
10335   install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged1_cmd);
10336   install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged2_cmd);
10337   install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged3_cmd);
10338   install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged4_cmd);
10339   install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged5_cmd);
10340   install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged6_cmd);
10341   install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged7_cmd);
10342   install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged8_cmd);
10343   install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged9_cmd);
10344   install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged10_cmd);
10345   install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd);
10346   install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged1_cmd);
10347   install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged2_cmd);
10348   install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged3_cmd);
10349   install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged4_cmd);
10350   install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged5_cmd);
10351   install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged6_cmd);
10352   install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged7_cmd);
10353   install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged8_cmd);
10354   install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged9_cmd);
10355   install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged10_cmd);
10356   install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd);
10357   install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged1_cmd);
10358   install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged2_cmd);
10359   install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged3_cmd);
10360   install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged4_cmd);
10361   install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged5_cmd);
10362   install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged6_cmd);
10363   install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged7_cmd);
10364   install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged8_cmd);
10365   install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged9_cmd);
10366   install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged10_cmd);
10367   install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd);
10368   install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged1_cmd);
10369   install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged2_cmd);
10370   install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged3_cmd);
10371   install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged4_cmd);
10372   install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged5_cmd);
10373   install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged6_cmd);
10374   install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged7_cmd);
10375   install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged8_cmd);
10376   install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged9_cmd);
10377   install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged10_cmd);
10378   install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd);
10379   install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged1_cmd);
10380   install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged2_cmd);
10381   install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged3_cmd);
10382   install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged4_cmd);
10383   install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged5_cmd);
10384   install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged6_cmd);
10385   install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged7_cmd);
10386   install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged8_cmd);
10387   install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged9_cmd);
10388   install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged10_cmd);
10389   install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd);
10390   install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged1_cmd);
10391   install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged2_cmd);
10392   install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged3_cmd);
10393   install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged4_cmd);
10394   install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged5_cmd);
10395   install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged6_cmd);
10396   install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged7_cmd);
10397   install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged8_cmd);
10398   install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged9_cmd);
10399   install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged10_cmd);
10400
10401   install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd);
10402   install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged1_cmd);
10403   install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged2_cmd);
10404   install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged3_cmd);
10405   install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged4_cmd);
10406   install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged5_cmd);
10407   install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged6_cmd);
10408   install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged7_cmd);
10409   install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged8_cmd);
10410   install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged9_cmd);
10411   install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged10_cmd);
10412   install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd);
10413   install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged1_cmd);
10414   install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged2_cmd);
10415   install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged3_cmd);
10416   install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged4_cmd);
10417   install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged5_cmd);
10418   install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged6_cmd);
10419   install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged7_cmd);
10420   install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged8_cmd);
10421   install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged9_cmd);
10422   install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged10_cmd);
10423
10424   install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged_cmd);
10425   install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged1_cmd);
10426   install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged2_cmd);
10427   install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged3_cmd);
10428   install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged4_cmd);
10429   install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged5_cmd);
10430   install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged6_cmd);
10431   install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged7_cmd);
10432   install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged8_cmd);
10433   install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged9_cmd);
10434   install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged10_cmd);
10435   install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged_cmd);
10436   install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged1_cmd);
10437   install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged2_cmd);
10438   install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged3_cmd);
10439   install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged4_cmd);
10440   install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged5_cmd);
10441   install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged6_cmd);
10442   install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged7_cmd);
10443   install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged8_cmd);
10444   install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged9_cmd);
10445   install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged10_cmd);
10446
10447   install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged_cmd);
10448   install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged1_cmd);
10449   install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged2_cmd);
10450   install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged3_cmd);
10451   install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged4_cmd);
10452   install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged5_cmd);
10453   install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged6_cmd);
10454   install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged7_cmd);
10455   install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged8_cmd);
10456   install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged9_cmd);
10457   install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged10_cmd);
10458   install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged_cmd);
10459   install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged1_cmd);
10460   install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged2_cmd);
10461   install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged3_cmd);
10462   install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged4_cmd);
10463   install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged5_cmd);
10464   install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged6_cmd);
10465   install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged7_cmd);
10466   install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged8_cmd);
10467   install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged9_cmd);
10468   install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged10_cmd);
10469
10470   /* "nexthop-local unchanged" commands */
10471   install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd);
10472   install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd);
10473
10474   /* "transparent-as" and "transparent-nexthop" for old version
10475      compatibility.  */
10476   install_element (BGP_NODE, &neighbor_transparent_as_cmd);
10477   install_element (BGP_NODE, &neighbor_transparent_nexthop_cmd);
10478
10479   /* "neighbor next-hop-self" commands. */
10480   install_element (BGP_NODE, &neighbor_nexthop_self_cmd);
10481   install_element (BGP_NODE, &no_neighbor_nexthop_self_cmd);
10482   install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd);
10483   install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd);
10484   install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd);
10485   install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd);
10486   install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd);
10487   install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd);
10488   install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd);
10489   install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd);
10490   install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd);
10491   install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd);
10492   install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd);
10493   install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd);
10494   install_element (BGP_ENCAP_NODE, &neighbor_nexthop_self_cmd);
10495   install_element (BGP_ENCAP_NODE, &no_neighbor_nexthop_self_cmd);
10496   install_element (BGP_ENCAPV6_NODE, &neighbor_nexthop_self_cmd);
10497   install_element (BGP_ENCAPV6_NODE, &no_neighbor_nexthop_self_cmd);
10498
10499   /* "neighbor remove-private-AS" commands. */
10500   install_element (BGP_NODE, &neighbor_remove_private_as_cmd);
10501   install_element (BGP_NODE, &no_neighbor_remove_private_as_cmd);
10502   install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd);
10503   install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd);
10504   install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd);
10505   install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd);
10506   install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd);
10507   install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd);
10508   install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd);
10509   install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd);
10510   install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd);
10511   install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd);
10512   install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd);
10513   install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd);
10514   install_element (BGP_ENCAP_NODE, &neighbor_remove_private_as_cmd);
10515   install_element (BGP_ENCAP_NODE, &no_neighbor_remove_private_as_cmd);
10516   install_element (BGP_ENCAPV6_NODE, &neighbor_remove_private_as_cmd);
10517   install_element (BGP_ENCAPV6_NODE, &no_neighbor_remove_private_as_cmd);
10518
10519   /* "neighbor send-community" commands.*/
10520   install_element (BGP_NODE, &neighbor_send_community_cmd);
10521   install_element (BGP_NODE, &neighbor_send_community_type_cmd);
10522   install_element (BGP_NODE, &no_neighbor_send_community_cmd);
10523   install_element (BGP_NODE, &no_neighbor_send_community_type_cmd);
10524   install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd);
10525   install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd);
10526   install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd);
10527   install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd);
10528   install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd);
10529   install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd);
10530   install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd);
10531   install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd);
10532   install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd);
10533   install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd);
10534   install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd);
10535   install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd);
10536   install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd);
10537   install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd);
10538   install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd);
10539   install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd);
10540   install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd);
10541   install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd);
10542   install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd);
10543   install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd);
10544   install_element (BGP_VPNV6_NODE, &neighbor_send_community_cmd);
10545   install_element (BGP_VPNV6_NODE, &neighbor_send_community_type_cmd);
10546   install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_cmd);
10547   install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd);
10548   install_element (BGP_ENCAP_NODE, &neighbor_send_community_cmd);
10549   install_element (BGP_ENCAP_NODE, &neighbor_send_community_type_cmd);
10550   install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_cmd);
10551   install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_type_cmd);
10552   install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_cmd);
10553   install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_type_cmd);
10554   install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_cmd);
10555   install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_type_cmd);
10556
10557   /* "neighbor route-reflector" commands.*/
10558   install_element (BGP_NODE, &neighbor_route_reflector_client_cmd);
10559   install_element (BGP_NODE, &no_neighbor_route_reflector_client_cmd);
10560   install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd);
10561   install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd);
10562   install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd);
10563   install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd);
10564   install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd);
10565   install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd);
10566   install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd);
10567   install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd);
10568   install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd);
10569   install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd);
10570   install_element (BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd);
10571   install_element (BGP_VPNV6_NODE, &no_neighbor_route_reflector_client_cmd);
10572   install_element (BGP_ENCAP_NODE, &neighbor_route_reflector_client_cmd);
10573   install_element (BGP_ENCAP_NODE, &no_neighbor_route_reflector_client_cmd);
10574   install_element (BGP_ENCAPV6_NODE, &neighbor_route_reflector_client_cmd);
10575   install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_reflector_client_cmd);
10576
10577   /* "neighbor route-server" commands.*/
10578   install_element (BGP_NODE, &neighbor_route_server_client_cmd);
10579   install_element (BGP_NODE, &no_neighbor_route_server_client_cmd);
10580   install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd);
10581   install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd);
10582   install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd);
10583   install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd);
10584   install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd);
10585   install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd);
10586   install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd);
10587   install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd);
10588   install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd);
10589   install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd);
10590   install_element (BGP_VPNV6_NODE, &neighbor_route_server_client_cmd);
10591   install_element (BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd);
10592   install_element (BGP_ENCAP_NODE, &neighbor_route_server_client_cmd);
10593   install_element (BGP_ENCAP_NODE, &no_neighbor_route_server_client_cmd);
10594   install_element (BGP_ENCAPV6_NODE, &neighbor_route_server_client_cmd);
10595   install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_server_client_cmd);
10596
10597   /* "neighbor passive" commands. */
10598   install_element (BGP_NODE, &neighbor_passive_cmd);
10599   install_element (BGP_NODE, &no_neighbor_passive_cmd);
10600
10601   /* "neighbor shutdown" commands. */
10602   install_element (BGP_NODE, &neighbor_shutdown_cmd);
10603   install_element (BGP_NODE, &no_neighbor_shutdown_cmd);
10604
10605   /* Deprecated "neighbor capability route-refresh" commands.*/
10606   install_element (BGP_NODE, &neighbor_capability_route_refresh_cmd);
10607   install_element (BGP_NODE, &no_neighbor_capability_route_refresh_cmd);
10608
10609   /* "neighbor capability orf prefix-list" commands.*/
10610   install_element (BGP_NODE, &neighbor_capability_orf_prefix_cmd);
10611   install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_cmd);
10612   install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd);
10613   install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd);
10614   install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd);
10615   install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd);
10616   install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd);
10617   install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd);
10618   install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd);
10619   install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd);
10620
10621   /* "neighbor capability dynamic" commands.*/
10622   install_element (BGP_NODE, &neighbor_capability_dynamic_cmd);
10623   install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd);
10624
10625   /* "neighbor dont-capability-negotiate" commands. */
10626   install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd);
10627   install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd);
10628
10629   /* "neighbor ebgp-multihop" commands. */
10630   install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd);
10631   install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd);
10632   install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd);
10633   install_element (BGP_NODE, &no_neighbor_ebgp_multihop_ttl_cmd);
10634
10635   /* "neighbor disable-connected-check" commands.  */
10636   install_element (BGP_NODE, &neighbor_disable_connected_check_cmd);
10637   install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd);
10638   install_element (BGP_NODE, &neighbor_enforce_multihop_cmd);
10639   install_element (BGP_NODE, &no_neighbor_enforce_multihop_cmd);
10640
10641   /* "neighbor description" commands. */
10642   install_element (BGP_NODE, &neighbor_description_cmd);
10643   install_element (BGP_NODE, &no_neighbor_description_cmd);
10644   install_element (BGP_NODE, &no_neighbor_description_val_cmd);
10645
10646   /* "neighbor update-source" commands. "*/
10647   install_element (BGP_NODE, &neighbor_update_source_cmd);
10648   install_element (BGP_NODE, &no_neighbor_update_source_cmd);
10649
10650   /* "neighbor default-originate" commands. */
10651   install_element (BGP_NODE, &neighbor_default_originate_cmd);
10652   install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd);
10653   install_element (BGP_NODE, &no_neighbor_default_originate_cmd);
10654   install_element (BGP_NODE, &no_neighbor_default_originate_rmap_cmd);
10655   install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd);
10656   install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd);
10657   install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd);
10658   install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_rmap_cmd);
10659   install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd);
10660   install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd);
10661   install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd);
10662   install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_rmap_cmd);
10663   install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd);
10664   install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd);
10665   install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd);
10666   install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_rmap_cmd);
10667   install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd);
10668   install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd);
10669   install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd);
10670   install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_rmap_cmd);
10671
10672   /* "neighbor port" commands. */
10673   install_element (BGP_NODE, &neighbor_port_cmd);
10674   install_element (BGP_NODE, &no_neighbor_port_cmd);
10675   install_element (BGP_NODE, &no_neighbor_port_val_cmd);
10676
10677   /* "neighbor weight" commands. */
10678   install_element (BGP_NODE, &neighbor_weight_cmd);
10679   install_element (BGP_NODE, &no_neighbor_weight_cmd);
10680   install_element (BGP_NODE, &no_neighbor_weight_val_cmd);
10681
10682   /* "neighbor override-capability" commands. */
10683   install_element (BGP_NODE, &neighbor_override_capability_cmd);
10684   install_element (BGP_NODE, &no_neighbor_override_capability_cmd);
10685
10686   /* "neighbor strict-capability-match" commands. */
10687   install_element (BGP_NODE, &neighbor_strict_capability_cmd);
10688   install_element (BGP_NODE, &no_neighbor_strict_capability_cmd);
10689
10690   /* "neighbor timers" commands. */
10691   install_element (BGP_NODE, &neighbor_timers_cmd);
10692   install_element (BGP_NODE, &no_neighbor_timers_cmd);
10693
10694   /* "neighbor timers connect" commands. */
10695   install_element (BGP_NODE, &neighbor_timers_connect_cmd);
10696   install_element (BGP_NODE, &no_neighbor_timers_connect_cmd);
10697   install_element (BGP_NODE, &no_neighbor_timers_connect_val_cmd);
10698
10699   /* "neighbor advertisement-interval" commands. */
10700   install_element (BGP_NODE, &neighbor_advertise_interval_cmd);
10701   install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd);
10702   install_element (BGP_NODE, &no_neighbor_advertise_interval_val_cmd);
10703
10704   /* "neighbor version" commands. */
10705   install_element (BGP_NODE, &neighbor_version_cmd);
10706
10707   /* "neighbor interface" commands. */
10708   install_element (BGP_NODE, &neighbor_interface_cmd);
10709   install_element (BGP_NODE, &no_neighbor_interface_cmd);
10710
10711   /* "neighbor distribute" commands. */
10712   install_element (BGP_NODE, &neighbor_distribute_list_cmd);
10713   install_element (BGP_NODE, &no_neighbor_distribute_list_cmd);
10714   install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd);
10715   install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd);
10716   install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd);
10717   install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd);
10718   install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd);
10719   install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd);
10720   install_element (BGP_IPV6M_NODE, &neighbor_distribute_list_cmd);
10721   install_element (BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd);
10722   install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd);
10723   install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd);
10724   install_element (BGP_VPNV6_NODE, &neighbor_distribute_list_cmd);
10725   install_element (BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd);
10726   install_element (BGP_ENCAP_NODE, &neighbor_distribute_list_cmd);
10727   install_element (BGP_ENCAP_NODE, &no_neighbor_distribute_list_cmd);
10728   install_element (BGP_ENCAPV6_NODE, &neighbor_distribute_list_cmd);
10729   install_element (BGP_ENCAPV6_NODE, &no_neighbor_distribute_list_cmd);
10730
10731   /* "neighbor prefix-list" commands. */
10732   install_element (BGP_NODE, &neighbor_prefix_list_cmd);
10733   install_element (BGP_NODE, &no_neighbor_prefix_list_cmd);
10734   install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd);
10735   install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd);
10736   install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd);
10737   install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd);
10738   install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd);
10739   install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd);
10740   install_element (BGP_IPV6M_NODE, &neighbor_prefix_list_cmd);
10741   install_element (BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd);
10742   install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd);
10743   install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd);
10744   install_element (BGP_VPNV6_NODE, &neighbor_prefix_list_cmd);
10745   install_element (BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd);
10746   install_element (BGP_ENCAP_NODE, &neighbor_prefix_list_cmd);
10747   install_element (BGP_ENCAP_NODE, &no_neighbor_prefix_list_cmd);
10748   install_element (BGP_ENCAPV6_NODE, &neighbor_prefix_list_cmd);
10749   install_element (BGP_ENCAPV6_NODE, &no_neighbor_prefix_list_cmd);
10750
10751   /* "neighbor filter-list" commands. */
10752   install_element (BGP_NODE, &neighbor_filter_list_cmd);
10753   install_element (BGP_NODE, &no_neighbor_filter_list_cmd);
10754   install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd);
10755   install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd);
10756   install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd);
10757   install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd);
10758   install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd);
10759   install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd);
10760   install_element (BGP_IPV6M_NODE, &neighbor_filter_list_cmd);
10761   install_element (BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd);
10762   install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd);
10763   install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd);
10764   install_element (BGP_VPNV6_NODE, &neighbor_filter_list_cmd);
10765   install_element (BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd);
10766   install_element (BGP_ENCAP_NODE, &neighbor_filter_list_cmd);
10767   install_element (BGP_ENCAP_NODE, &no_neighbor_filter_list_cmd);
10768   install_element (BGP_ENCAPV6_NODE, &neighbor_filter_list_cmd);
10769   install_element (BGP_ENCAPV6_NODE, &no_neighbor_filter_list_cmd);
10770
10771   /* "neighbor route-map" commands. */
10772   install_element (BGP_NODE, &neighbor_route_map_cmd);
10773   install_element (BGP_NODE, &no_neighbor_route_map_cmd);
10774   install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd);
10775   install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd);
10776   install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd);
10777   install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd);
10778   install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd);
10779   install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd);
10780   install_element (BGP_IPV6M_NODE, &neighbor_route_map_cmd);
10781   install_element (BGP_IPV6M_NODE, &no_neighbor_route_map_cmd);
10782   install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd);
10783   install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd);
10784   install_element (BGP_VPNV6_NODE, &neighbor_route_map_cmd);
10785   install_element (BGP_VPNV6_NODE, &no_neighbor_route_map_cmd);
10786   install_element (BGP_ENCAP_NODE, &neighbor_route_map_cmd);
10787   install_element (BGP_ENCAP_NODE, &no_neighbor_route_map_cmd);
10788   install_element (BGP_ENCAPV6_NODE, &neighbor_route_map_cmd);
10789   install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_map_cmd);
10790
10791   /* "neighbor unsuppress-map" commands. */
10792   install_element (BGP_NODE, &neighbor_unsuppress_map_cmd);
10793   install_element (BGP_NODE, &no_neighbor_unsuppress_map_cmd);
10794   install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd);
10795   install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd);
10796   install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd);
10797   install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd);
10798   install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd);
10799   install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd);
10800   install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd);
10801   install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd);
10802   install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd);
10803   install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd);
10804   install_element (BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd);
10805   install_element (BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd);
10806   install_element (BGP_ENCAP_NODE, &neighbor_unsuppress_map_cmd);
10807   install_element (BGP_ENCAP_NODE, &no_neighbor_unsuppress_map_cmd);
10808   install_element (BGP_ENCAPV6_NODE, &neighbor_unsuppress_map_cmd);
10809   install_element (BGP_ENCAPV6_NODE, &no_neighbor_unsuppress_map_cmd);
10810
10811   /* "neighbor maximum-prefix" commands. */
10812   install_element (BGP_NODE, &neighbor_maximum_prefix_cmd);
10813   install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_cmd);
10814   install_element (BGP_NODE, &neighbor_maximum_prefix_warning_cmd);
10815   install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
10816   install_element (BGP_NODE, &neighbor_maximum_prefix_restart_cmd);
10817   install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
10818   install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd);
10819   install_element (BGP_NODE, &no_neighbor_maximum_prefix_val_cmd);
10820   install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
10821   install_element (BGP_NODE, &no_neighbor_maximum_prefix_warning_cmd);
10822   install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
10823   install_element (BGP_NODE, &no_neighbor_maximum_prefix_restart_cmd);
10824   install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
10825   install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd);
10826   install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
10827   install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd);
10828   install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
10829   install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd);
10830   install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
10831   install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd);
10832   install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
10833   install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
10834   install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
10835   install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
10836   install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
10837   install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
10838   install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd);
10839   install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd);
10840   install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd);
10841   install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
10842   install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd);
10843   install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
10844   install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd);
10845   install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_val_cmd);
10846   install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
10847   install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_warning_cmd);
10848   install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
10849   install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_restart_cmd);
10850   install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
10851   install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd);
10852   install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
10853   install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd);
10854   install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
10855   install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd);
10856   install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
10857   install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd);
10858   install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_val_cmd);
10859   install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
10860   install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_warning_cmd);
10861   install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
10862   install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_restart_cmd);
10863   install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
10864   install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd);
10865   install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd);
10866   install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd);
10867   install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
10868   install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd);
10869   install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
10870   install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd);
10871   install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_val_cmd);
10872   install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
10873   install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_warning_cmd);
10874   install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
10875   install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_restart_cmd);
10876   install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
10877   install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd);
10878   install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
10879   install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd);
10880   install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
10881   install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd);
10882   install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
10883   install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd);
10884   install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
10885   install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
10886   install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
10887   install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
10888   install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
10889   install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
10890
10891   install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd);
10892   install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
10893   install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd);
10894   install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
10895   install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd);
10896   install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
10897   install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd);
10898   install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_val_cmd);
10899   install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
10900   install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_warning_cmd);
10901   install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
10902   install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_restart_cmd);
10903   install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
10904
10905   install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_cmd);
10906   install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_cmd);
10907   install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_warning_cmd);
10908   install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
10909   install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_restart_cmd);
10910   install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
10911   install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_cmd);
10912   install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_val_cmd);
10913   install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
10914   install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_warning_cmd);
10915   install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
10916   install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_restart_cmd);
10917   install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
10918
10919   install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_cmd);
10920   install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
10921   install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_warning_cmd);
10922   install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
10923   install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_restart_cmd);
10924   install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
10925   install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_cmd);
10926   install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_val_cmd);
10927   install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
10928   install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_warning_cmd);
10929   install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
10930   install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_restart_cmd);
10931   install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
10932
10933   /* "neighbor allowas-in" */
10934   install_element (BGP_NODE, &neighbor_allowas_in_cmd);
10935   install_element (BGP_NODE, &neighbor_allowas_in_arg_cmd);
10936   install_element (BGP_NODE, &no_neighbor_allowas_in_cmd);
10937   install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd);
10938   install_element (BGP_IPV4_NODE, &neighbor_allowas_in_arg_cmd);
10939   install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd);
10940   install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd);
10941   install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_arg_cmd);
10942   install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd);
10943   install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd);
10944   install_element (BGP_IPV6_NODE, &neighbor_allowas_in_arg_cmd);
10945   install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd);
10946   install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd);
10947   install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_arg_cmd);
10948   install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd);
10949   install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd);
10950   install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_arg_cmd);
10951   install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd);
10952   install_element (BGP_VPNV6_NODE, &neighbor_allowas_in_cmd);
10953   install_element (BGP_VPNV6_NODE, &neighbor_allowas_in_arg_cmd);
10954   install_element (BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd);
10955   install_element (BGP_ENCAP_NODE, &neighbor_allowas_in_cmd);
10956   install_element (BGP_ENCAP_NODE, &neighbor_allowas_in_arg_cmd);
10957   install_element (BGP_ENCAP_NODE, &no_neighbor_allowas_in_cmd);
10958   install_element (BGP_ENCAPV6_NODE, &neighbor_allowas_in_cmd);
10959   install_element (BGP_ENCAPV6_NODE, &neighbor_allowas_in_arg_cmd);
10960   install_element (BGP_ENCAPV6_NODE, &no_neighbor_allowas_in_cmd);
10961
10962   /* address-family commands. */
10963   install_element (BGP_NODE, &address_family_ipv4_cmd);
10964   install_element (BGP_NODE, &address_family_ipv4_safi_cmd);
10965   install_element (BGP_NODE, &address_family_ipv6_cmd);
10966   install_element (BGP_NODE, &address_family_ipv6_safi_cmd);
10967   install_element (BGP_NODE, &address_family_vpnv4_cmd);
10968   install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd);
10969
10970   install_element (BGP_NODE, &address_family_vpnv6_cmd);
10971   install_element (BGP_NODE, &address_family_vpnv6_unicast_cmd);
10972
10973   install_element (BGP_NODE, &address_family_encap_cmd);
10974   install_element (BGP_NODE, &address_family_encapv4_cmd);
10975   install_element (BGP_NODE, &address_family_encapv6_cmd);
10976
10977   /* "exit-address-family" command. */
10978   install_element (BGP_IPV4_NODE, &exit_address_family_cmd);
10979   install_element (BGP_IPV4M_NODE, &exit_address_family_cmd);
10980   install_element (BGP_IPV6_NODE, &exit_address_family_cmd);
10981   install_element (BGP_IPV6M_NODE, &exit_address_family_cmd);
10982   install_element (BGP_VPNV4_NODE, &exit_address_family_cmd);
10983   install_element (BGP_VPNV6_NODE, &exit_address_family_cmd);
10984   install_element (BGP_ENCAP_NODE, &exit_address_family_cmd);
10985   install_element (BGP_ENCAPV6_NODE, &exit_address_family_cmd);
10986
10987   /* "clear ip bgp commands" */
10988   install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd);
10989   install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_cmd);
10990   install_element (ENABLE_NODE, &clear_ip_bgp_as_cmd);
10991   install_element (ENABLE_NODE, &clear_ip_bgp_peer_cmd);
10992   install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_cmd);
10993   install_element (ENABLE_NODE, &clear_ip_bgp_external_cmd);
10994   install_element (ENABLE_NODE, &clear_bgp_all_cmd);
10995   install_element (ENABLE_NODE, &clear_bgp_instance_all_cmd);
10996   install_element (ENABLE_NODE, &clear_bgp_ipv6_all_cmd);
10997   install_element (ENABLE_NODE, &clear_bgp_peer_cmd);
10998   install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_cmd);
10999   install_element (ENABLE_NODE, &clear_bgp_peer_group_cmd);
11000   install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_cmd);
11001   install_element (ENABLE_NODE, &clear_bgp_external_cmd);
11002   install_element (ENABLE_NODE, &clear_bgp_ipv6_external_cmd);
11003   install_element (ENABLE_NODE, &clear_bgp_as_cmd);
11004   install_element (ENABLE_NODE, &clear_bgp_ipv6_as_cmd);
11005
11006   /* "clear ip bgp neighbor soft in" */
11007   install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_in_cmd);
11008   install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_in_cmd);
11009   install_element (ENABLE_NODE, &clear_ip_bgp_all_in_cmd);
11010   install_element (ENABLE_NODE, &clear_ip_bgp_all_in_prefix_filter_cmd);
11011   install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_in_prefix_filter_cmd);
11012   install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_in_cmd);
11013   install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_cmd);
11014   install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_prefix_filter_cmd);
11015   install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_in_cmd);
11016   install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_cmd);
11017   install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_prefix_filter_cmd);
11018   install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_in_cmd);
11019   install_element (ENABLE_NODE, &clear_ip_bgp_external_in_cmd);
11020   install_element (ENABLE_NODE, &clear_ip_bgp_external_in_prefix_filter_cmd);
11021   install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_in_cmd);
11022   install_element (ENABLE_NODE, &clear_ip_bgp_as_in_cmd);
11023   install_element (ENABLE_NODE, &clear_ip_bgp_as_in_prefix_filter_cmd);
11024   install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_in_cmd);
11025   install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_in_cmd);
11026   install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_cmd);
11027   install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_prefix_filter_cmd);
11028   install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_in_prefix_filter_cmd);
11029   install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_in_cmd);
11030   install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_cmd);
11031   install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd);
11032   install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_in_cmd);
11033   install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_cmd);
11034   install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd);
11035   install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_in_cmd);
11036   install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_cmd);
11037   install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_prefix_filter_cmd);
11038   install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_in_cmd);
11039   install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_cmd);
11040   install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_prefix_filter_cmd);
11041   install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_in_cmd);
11042   install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_in_cmd);
11043   install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_in_cmd);
11044   install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_in_cmd);
11045   install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_in_cmd);
11046   install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_in_cmd);
11047   install_element (ENABLE_NODE, &clear_ip_bgp_all_encap_soft_in_cmd);
11048   install_element (ENABLE_NODE, &clear_ip_bgp_all_encap_in_cmd);
11049   install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_soft_in_cmd);
11050   install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_in_cmd);
11051   install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_soft_in_cmd);
11052   install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_in_cmd);
11053   install_element (ENABLE_NODE, &clear_bgp_all_soft_in_cmd);
11054   install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_in_cmd);
11055   install_element (ENABLE_NODE, &clear_bgp_all_in_cmd);
11056   install_element (ENABLE_NODE, &clear_bgp_all_in_prefix_filter_cmd);
11057   install_element (ENABLE_NODE, &clear_bgp_peer_soft_in_cmd);
11058   install_element (ENABLE_NODE, &clear_bgp_peer_in_cmd);
11059   install_element (ENABLE_NODE, &clear_bgp_peer_in_prefix_filter_cmd);
11060   install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_in_cmd);
11061   install_element (ENABLE_NODE, &clear_bgp_peer_group_in_cmd);
11062   install_element (ENABLE_NODE, &clear_bgp_peer_group_in_prefix_filter_cmd);
11063   install_element (ENABLE_NODE, &clear_bgp_external_soft_in_cmd);
11064   install_element (ENABLE_NODE, &clear_bgp_external_in_cmd);
11065   install_element (ENABLE_NODE, &clear_bgp_external_in_prefix_filter_cmd);
11066   install_element (ENABLE_NODE, &clear_bgp_as_soft_in_cmd);
11067   install_element (ENABLE_NODE, &clear_bgp_as_in_cmd);
11068   install_element (ENABLE_NODE, &clear_bgp_as_in_prefix_filter_cmd);
11069   install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_in_cmd);
11070   install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_cmd);
11071   install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_prefix_filter_cmd);
11072   install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_in_cmd);
11073   install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_cmd);
11074   install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_prefix_filter_cmd);
11075   install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_in_cmd);
11076   install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_cmd);
11077   install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_prefix_filter_cmd);
11078   install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_in_cmd);
11079   install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_cmd);
11080   install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_prefix_filter_cmd);
11081   install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_in_cmd);
11082   install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_cmd);
11083   install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_prefix_filter_cmd);
11084
11085   /* clear ip bgp prefix  */
11086   install_element (ENABLE_NODE, &clear_ip_bgp_prefix_cmd);
11087   install_element (ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd);
11088
11089   /* "clear ip bgp neighbor soft out" */
11090   install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_out_cmd);
11091   install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_out_cmd);
11092   install_element (ENABLE_NODE, &clear_ip_bgp_all_out_cmd);
11093   install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_out_cmd);
11094   install_element (ENABLE_NODE, &clear_ip_bgp_peer_out_cmd);
11095   install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_out_cmd);
11096   install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_out_cmd);
11097   install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_out_cmd);
11098   install_element (ENABLE_NODE, &clear_ip_bgp_external_out_cmd);
11099   install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_out_cmd);
11100   install_element (ENABLE_NODE, &clear_ip_bgp_as_out_cmd);
11101   install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_out_cmd);
11102   install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_out_cmd);
11103   install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_out_cmd);
11104   install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_out_cmd);
11105   install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_out_cmd);
11106   install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_out_cmd);
11107   install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_out_cmd);
11108   install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_out_cmd);
11109   install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_out_cmd);
11110   install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_out_cmd);
11111   install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_out_cmd);
11112   install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_out_cmd);
11113   install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_out_cmd);
11114   install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_out_cmd);
11115   install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_out_cmd);
11116   install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_out_cmd);
11117   install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_out_cmd);
11118   install_element (ENABLE_NODE, &clear_ip_bgp_all_encap_soft_out_cmd);
11119   install_element (ENABLE_NODE, &clear_ip_bgp_all_encap_out_cmd);
11120   install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_soft_out_cmd);
11121   install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_out_cmd);
11122   install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_soft_out_cmd);
11123   install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_out_cmd);
11124   install_element (ENABLE_NODE, &clear_bgp_all_soft_out_cmd);
11125   install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_out_cmd);
11126   install_element (ENABLE_NODE, &clear_bgp_all_out_cmd);
11127   install_element (ENABLE_NODE, &clear_bgp_peer_soft_out_cmd);
11128   install_element (ENABLE_NODE, &clear_bgp_peer_out_cmd);
11129   install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_out_cmd);
11130   install_element (ENABLE_NODE, &clear_bgp_peer_group_out_cmd);
11131   install_element (ENABLE_NODE, &clear_bgp_external_soft_out_cmd);
11132   install_element (ENABLE_NODE, &clear_bgp_external_out_cmd);
11133   install_element (ENABLE_NODE, &clear_bgp_as_soft_out_cmd);
11134   install_element (ENABLE_NODE, &clear_bgp_as_out_cmd);
11135   install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_out_cmd);
11136   install_element (ENABLE_NODE, &clear_bgp_ipv6_all_out_cmd);
11137   install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_out_cmd);
11138   install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_out_cmd);
11139   install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_out_cmd);
11140   install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_out_cmd);
11141   install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_out_cmd);
11142   install_element (ENABLE_NODE, &clear_bgp_ipv6_external_out_cmd);
11143   install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_out_cmd);
11144   install_element (ENABLE_NODE, &clear_bgp_ipv6_as_out_cmd);
11145
11146   /* "clear ip bgp neighbor soft" */
11147   install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_cmd);
11148   install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_cmd);
11149   install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_cmd);
11150   install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_cmd);
11151   install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_cmd);
11152   install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_cmd);
11153   install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_cmd);
11154   install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_cmd);
11155   install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_cmd);
11156   install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_cmd);
11157   install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_cmd);
11158   install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_cmd);
11159   install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_cmd);
11160   install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_cmd);
11161   install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_cmd);
11162   install_element (ENABLE_NODE, &clear_ip_bgp_all_encap_soft_cmd);
11163   install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_soft_cmd);
11164   install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_soft_cmd);
11165   install_element (ENABLE_NODE, &clear_bgp_all_soft_cmd);
11166   install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_cmd);
11167   install_element (ENABLE_NODE, &clear_bgp_peer_soft_cmd);
11168   install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_cmd);
11169   install_element (ENABLE_NODE, &clear_bgp_external_soft_cmd);
11170   install_element (ENABLE_NODE, &clear_bgp_as_soft_cmd);
11171   install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_cmd);
11172   install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_cmd);
11173   install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_cmd);
11174   install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_cmd);
11175   install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_cmd);
11176
11177   /* "clear ip bgp neighbor rsclient" */
11178   install_element (ENABLE_NODE, &clear_ip_bgp_all_rsclient_cmd);
11179   install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_rsclient_cmd);
11180   install_element (ENABLE_NODE, &clear_ip_bgp_peer_rsclient_cmd);
11181   install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_rsclient_cmd);
11182   install_element (ENABLE_NODE, &clear_bgp_all_rsclient_cmd);
11183   install_element (ENABLE_NODE, &clear_bgp_instance_all_rsclient_cmd);
11184   install_element (ENABLE_NODE, &clear_bgp_ipv6_all_rsclient_cmd);
11185   install_element (ENABLE_NODE, &clear_bgp_ipv6_instance_all_rsclient_cmd);
11186   install_element (ENABLE_NODE, &clear_bgp_peer_rsclient_cmd);
11187   install_element (ENABLE_NODE, &clear_bgp_instance_peer_rsclient_cmd);
11188   install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_rsclient_cmd);
11189   install_element (ENABLE_NODE, &clear_bgp_ipv6_instance_peer_rsclient_cmd);
11190
11191   /* "show ip bgp summary" commands. */
11192   install_element (VIEW_NODE, &show_bgp_summary_cmd);
11193   install_element (RESTRICTED_NODE, &show_bgp_summary_cmd);
11194
11195   install_element (VIEW_NODE, &show_bgp_summary_1w_cmd);
11196   install_element (RESTRICTED_NODE, &show_bgp_summary_1w_cmd);
11197
11198   install_element (VIEW_NODE, &show_bgp_ipv4_safi_summary_cmd);
11199   install_element (VIEW_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
11200   install_element (VIEW_NODE, &show_bgp_instance_ipv4_summary_cmd);
11201
11202   install_element (VIEW_NODE, &show_bgp_ipv4_vpn_summary_cmd);
11203   install_element (VIEW_NODE, &show_bgp_ipv4_encap_summary_cmd);
11204   install_element (VIEW_NODE, &show_bgp_ipv6_vpn_summary_cmd);
11205   install_element (VIEW_NODE, &show_bgp_ipv6_encap_summary_cmd);
11206
11207   install_element (VIEW_NODE, &show_bgp_instance_summary_cmd);
11208   install_element (VIEW_NODE, &show_bgp_ipv6_safi_summary_cmd);
11209   install_element (VIEW_NODE, &show_bgp_instance_ipv6_summary_cmd);
11210   install_element (VIEW_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
11211
11212   install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_summary_cmd);
11213   install_element (RESTRICTED_NODE, &show_bgp_instance_ipv4_summary_cmd);
11214   install_element (RESTRICTED_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
11215
11216   install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_summary_cmd);
11217   install_element (RESTRICTED_NODE, &show_bgp_ipv4_encap_summary_cmd);
11218   install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_summary_cmd);
11219   install_element (RESTRICTED_NODE, &show_bgp_ipv6_encap_summary_cmd);
11220
11221   install_element (RESTRICTED_NODE, &show_bgp_instance_summary_cmd);
11222   install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_summary_cmd);
11223   install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_summary_cmd);
11224   install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
11225
11226   /* "show ip bgp neighbors" commands. */
11227   install_element (VIEW_NODE, &show_bgp_instance_neighbors_cmd);
11228
11229   install_element (VIEW_NODE, &show_bgp_neighbors_cmd);
11230   install_element (VIEW_NODE, &show_bgp_neighbors_peer_cmd);
11231   install_element (VIEW_NODE, &show_bgp_instance_neighbors_peer_cmd);
11232   install_element (RESTRICTED_NODE, &show_bgp_neighbors_peer_cmd);
11233   install_element (RESTRICTED_NODE, &show_bgp_instance_neighbors_peer_cmd);
11234   install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
11235   install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
11236   install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
11237
11238   /* "show ip bgp rsclient" commands. */
11239   install_element (VIEW_NODE, &show_bgp_instance_ipv4_safi_rsclient_summary_cmd);
11240   install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_summary_cmd);
11241   install_element (RESTRICTED_NODE, &show_bgp_instance_ipv4_safi_rsclient_summary_cmd);
11242   install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_summary_cmd);
11243
11244   install_element (VIEW_NODE, &show_bgp_rsclient_summary_cmd);
11245   install_element (VIEW_NODE, &show_bgp_instance_rsclient_summary_cmd);
11246   install_element (RESTRICTED_NODE, &show_bgp_rsclient_summary_cmd);
11247   install_element (RESTRICTED_NODE, &show_bgp_instance_rsclient_summary_cmd);
11248
11249   install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_summary_cmd);
11250   install_element (VIEW_NODE, &show_bgp_instance_ipv6_rsclient_summary_cmd);
11251   install_element (VIEW_NODE, &show_bgp_instance_ipv6_safi_rsclient_summary_cmd);
11252   install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_summary_cmd);
11253   install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_summary_cmd);
11254   install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_rsclient_summary_cmd);
11255   install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_safi_rsclient_summary_cmd);
11256   install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_summary_cmd);
11257
11258   /* "show ip bgp paths" commands. */
11259   install_element (VIEW_NODE, &show_bgp_ipv4_paths_cmd);
11260
11261   /* "show ip bgp community" commands. */
11262   install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd);
11263
11264   /* "show ip bgp large-community" commands. */
11265   install_element (VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd);
11266
11267   /* "show ip bgp attribute-info" commands. */
11268   install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd);
11269
11270   /* "redistribute" commands.  */
11271   install_element (BGP_NODE, &bgp_redistribute_ipv4_cmd);
11272   install_element (BGP_NODE, &no_bgp_redistribute_ipv4_cmd);
11273   install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_cmd);
11274   install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_cmd);
11275   install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_cmd);
11276   install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_cmd);
11277   install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd);
11278   install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd);
11279   install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_metric_cmd);
11280   install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_rmap_cmd);
11281   install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd);
11282   install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd);
11283   install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd);
11284   install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_cmd);
11285   install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd);
11286   install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_cmd);
11287   install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd);
11288   install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd);
11289   install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_metric_cmd);
11290   install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_rmap_cmd);
11291
11292   /* ttl_security commands */
11293   install_element (BGP_NODE, &neighbor_ttl_security_cmd);
11294   install_element (BGP_NODE, &no_neighbor_ttl_security_cmd);
11295
11296   /* "show bgp memory" commands. */
11297   install_element (VIEW_NODE, &show_bgp_memory_cmd);
11298   install_element (RESTRICTED_NODE, &show_bgp_memory_cmd);
11299   
11300   /* "show bgp views" commands. */
11301   install_element (VIEW_NODE, &show_bgp_views_cmd);
11302   install_element (RESTRICTED_NODE, &show_bgp_views_cmd);
11303   
11304   /* non afi/safi forms of commands */
11305   install_element (VIEW_NODE, &show_ip_bgp_summary_cmd);
11306   install_element (VIEW_NODE, &show_ip_bgp_instance_summary_cmd);
11307   install_element (VIEW_NODE, &show_ip_bgp_ipv4_summary_cmd);
11308   install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
11309   install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
11310   install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
11311   install_element (VIEW_NODE, &show_bgp_ipv6_summary_cmd);
11312   install_element (RESTRICTED_NODE, &show_ip_bgp_summary_cmd);
11313   install_element (RESTRICTED_NODE, &show_ip_bgp_instance_summary_cmd);
11314   install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_summary_cmd);
11315   install_element (RESTRICTED_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
11316   install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
11317   install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
11318   install_element (RESTRICTED_NODE, &show_bgp_ipv6_summary_cmd);
11319   install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd);
11320   install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
11321   install_element (VIEW_NODE, &show_ip_bgp_neighbors_peer_cmd);
11322   install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
11323   install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd);
11324   install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd);
11325   install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
11326   install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
11327   install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_cmd);
11328   install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
11329   install_element (RESTRICTED_NODE, &show_ip_bgp_neighbors_peer_cmd);
11330   install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
11331   install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
11332   install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
11333   install_element (RESTRICTED_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
11334   install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_cmd);
11335   install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
11336   install_element (RESTRICTED_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
11337   install_element (VIEW_NODE, &show_ipv6_bgp_summary_cmd);
11338   install_element (VIEW_NODE, &show_ipv6_mbgp_summary_cmd);
11339   install_element (VIEW_NODE, &show_ip_bgp_rsclient_summary_cmd);
11340   install_element (VIEW_NODE, &show_ip_bgp_instance_rsclient_summary_cmd);
11341   install_element (VIEW_NODE, &show_ip_bgp_ipv4_rsclient_summary_cmd);
11342   install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_rsclient_summary_cmd);
11343   install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_summary_cmd);
11344   install_element (RESTRICTED_NODE, &show_ip_bgp_instance_rsclient_summary_cmd);
11345   install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_rsclient_summary_cmd);
11346   install_element (RESTRICTED_NODE, &show_ip_bgp_instance_ipv4_rsclient_summary_cmd);
11347   install_element (VIEW_NODE, &show_ip_bgp_paths_cmd);
11348   install_element (VIEW_NODE, &show_ip_bgp_ipv4_paths_cmd);
11349   /* Community-list. */
11350   community_list_vty ();
11351 }
11352
11353 #include "memory.h"
11354 #include "bgp_regex.h"
11355 #include "bgp_clist.h"
11356 #include "bgp_ecommunity.h"
11357
11358 /* VTY functions.  */
11359
11360 /* Direction value to string conversion.  */
11361 static const char *
11362 community_direct_str (int direct)
11363 {
11364   switch (direct)
11365     {
11366     case COMMUNITY_DENY:
11367       return "deny";
11368     case COMMUNITY_PERMIT:
11369       return "permit";
11370     default:
11371       return "unknown";
11372     }
11373 }
11374
11375 /* Display error string.  */
11376 static void
11377 community_list_perror (struct vty *vty, int ret)
11378 {
11379   switch (ret)
11380     {
11381     case COMMUNITY_LIST_ERR_CANT_FIND_LIST:
11382       vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
11383       break;
11384     case COMMUNITY_LIST_ERR_MALFORMED_VAL:
11385       vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE);
11386       break;
11387     case COMMUNITY_LIST_ERR_STANDARD_CONFLICT:
11388       vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE);
11389       break;
11390     case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT:
11391       vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE);
11392       break;
11393     }
11394 }
11395
11396 /* VTY interface for community_set() function.  */
11397 static int
11398 community_list_set_vty (struct vty *vty, int argc, const char **argv, 
11399                         int style, int reject_all_digit_name)
11400 {
11401   int ret;
11402   int direct;
11403   char *str;
11404
11405   /* Check the list type. */
11406   if (strncmp (argv[1], "p", 1) == 0)
11407     direct = COMMUNITY_PERMIT;
11408   else if (strncmp (argv[1], "d", 1) == 0)
11409     direct = COMMUNITY_DENY;
11410   else
11411     {
11412       vty_out (vty, "%% Matching condition must be permit or deny%s",
11413                VTY_NEWLINE);
11414       return CMD_WARNING;
11415     }
11416
11417   /* All digit name check.  */
11418   if (reject_all_digit_name && all_digit (argv[0]))
11419     {
11420       vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
11421       return CMD_WARNING;
11422     }
11423
11424   /* Concat community string argument.  */
11425   if (argc > 1)
11426     str = argv_concat (argv, argc, 2);
11427   else
11428     str = NULL;
11429
11430   /* When community_list_set() return nevetive value, it means
11431      malformed community string.  */
11432   ret = community_list_set (bgp_clist, argv[0], str, direct, style);
11433
11434   /* Free temporary community list string allocated by
11435      argv_concat().  */
11436   if (str)
11437     XFREE (MTYPE_TMP, str);
11438
11439   if (ret < 0)
11440     {
11441       /* Display error string.  */
11442       community_list_perror (vty, ret);
11443       return CMD_WARNING;
11444     }
11445
11446   return CMD_SUCCESS;
11447 }
11448
11449 /* Communiyt-list entry delete.  */
11450 static int
11451 community_list_unset_vty (struct vty *vty, int argc, const char **argv,
11452                           int style)
11453 {
11454   int ret;
11455   int direct = 0;
11456   char *str = NULL;
11457
11458   if (argc > 1)
11459     {
11460       /* Check the list direct. */
11461       if (strncmp (argv[1], "p", 1) == 0)
11462         direct = COMMUNITY_PERMIT;
11463       else if (strncmp (argv[1], "d", 1) == 0)
11464         direct = COMMUNITY_DENY;
11465       else
11466         {
11467           vty_out (vty, "%% Matching condition must be permit or deny%s",
11468                    VTY_NEWLINE);
11469           return CMD_WARNING;
11470         }
11471
11472       /* Concat community string argument.  */
11473       str = argv_concat (argv, argc, 2);
11474     }
11475
11476   /* Unset community list.  */
11477   ret = community_list_unset (bgp_clist, argv[0], str, direct, style);
11478
11479   /* Free temporary community list string allocated by
11480      argv_concat().  */
11481   if (str)
11482     XFREE (MTYPE_TMP, str);
11483
11484   if (ret < 0)
11485     {
11486       community_list_perror (vty, ret);
11487       return CMD_WARNING;
11488     }
11489
11490   return CMD_SUCCESS;
11491 }
11492
11493 /* "community-list" keyword help string.  */
11494 #define COMMUNITY_LIST_STR "Add a community list entry\n"
11495 #define COMMUNITY_VAL_STR  "Community number in aa:nn format or internet|local-AS|no-advertise|no-export\n"
11496
11497 DEFUN (ip_community_list_standard,
11498        ip_community_list_standard_cmd,
11499        "ip community-list <1-99> (deny|permit) .AA:NN",
11500        IP_STR
11501        COMMUNITY_LIST_STR
11502        "Community list number (standard)\n"
11503        "Specify community to reject\n"
11504        "Specify community to accept\n"
11505        COMMUNITY_VAL_STR)
11506 {
11507   return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
11508 }
11509
11510 ALIAS (ip_community_list_standard,
11511        ip_community_list_standard2_cmd,
11512        "ip community-list <1-99> (deny|permit)",
11513        IP_STR
11514        COMMUNITY_LIST_STR
11515        "Community list number (standard)\n"
11516        "Specify community to reject\n"
11517        "Specify community to accept\n")
11518
11519 DEFUN (ip_community_list_expanded,
11520        ip_community_list_expanded_cmd,
11521        "ip community-list <100-500> (deny|permit) .LINE",
11522        IP_STR
11523        COMMUNITY_LIST_STR
11524        "Community list number (expanded)\n"
11525        "Specify community to reject\n"
11526        "Specify community to accept\n"
11527        "An ordered list as a regular-expression\n")
11528 {
11529   return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
11530 }
11531
11532 DEFUN (ip_community_list_name_standard,
11533        ip_community_list_name_standard_cmd,
11534        "ip community-list standard WORD (deny|permit) .AA:NN",
11535        IP_STR
11536        COMMUNITY_LIST_STR
11537        "Add a standard community-list entry\n"
11538        "Community list name\n"
11539        "Specify community to reject\n"
11540        "Specify community to accept\n"
11541        COMMUNITY_VAL_STR)
11542 {
11543   return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
11544 }
11545
11546 ALIAS (ip_community_list_name_standard,
11547        ip_community_list_name_standard2_cmd,
11548        "ip community-list standard WORD (deny|permit)",
11549        IP_STR
11550        COMMUNITY_LIST_STR
11551        "Add a standard community-list entry\n"
11552        "Community list name\n"
11553        "Specify community to reject\n"
11554        "Specify community to accept\n")
11555
11556 DEFUN (ip_community_list_name_expanded,
11557        ip_community_list_name_expanded_cmd,
11558        "ip community-list expanded WORD (deny|permit) .LINE",
11559        IP_STR
11560        COMMUNITY_LIST_STR
11561        "Add an expanded community-list entry\n"
11562        "Community list name\n"
11563        "Specify community to reject\n"
11564        "Specify community to accept\n"
11565        "An ordered list as a regular-expression\n")
11566 {
11567   return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
11568 }
11569
11570 DEFUN (no_ip_community_list_standard_all,
11571        no_ip_community_list_standard_all_cmd,
11572        "no ip community-list <1-99>",
11573        NO_STR
11574        IP_STR
11575        COMMUNITY_LIST_STR
11576        "Community list number (standard)\n")
11577 {
11578   return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
11579 }
11580
11581 DEFUN (no_ip_community_list_expanded_all,
11582        no_ip_community_list_expanded_all_cmd,
11583        "no ip community-list <100-500>",
11584        NO_STR
11585        IP_STR
11586        COMMUNITY_LIST_STR
11587        "Community list number (expanded)\n")
11588 {
11589   return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
11590 }
11591
11592 DEFUN (no_ip_community_list_name_standard_all,
11593        no_ip_community_list_name_standard_all_cmd,
11594        "no ip community-list standard WORD",
11595        NO_STR
11596        IP_STR
11597        COMMUNITY_LIST_STR
11598        "Add a standard community-list entry\n"
11599        "Community list name\n")
11600 {
11601   return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
11602 }
11603
11604 DEFUN (no_ip_community_list_name_expanded_all,
11605        no_ip_community_list_name_expanded_all_cmd,
11606        "no ip community-list expanded WORD",
11607        NO_STR
11608        IP_STR
11609        COMMUNITY_LIST_STR
11610        "Add an expanded community-list entry\n"
11611        "Community list name\n")
11612 {
11613   return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
11614 }
11615
11616 DEFUN (no_ip_community_list_standard,
11617        no_ip_community_list_standard_cmd,
11618        "no ip community-list <1-99> (deny|permit) .AA:NN",
11619        NO_STR
11620        IP_STR
11621        COMMUNITY_LIST_STR
11622        "Community list number (standard)\n"
11623        "Specify community to reject\n"
11624        "Specify community to accept\n"
11625        COMMUNITY_VAL_STR)
11626 {
11627   return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
11628 }
11629
11630 DEFUN (no_ip_community_list_expanded,
11631        no_ip_community_list_expanded_cmd,
11632        "no ip community-list <100-500> (deny|permit) .LINE",
11633        NO_STR
11634        IP_STR
11635        COMMUNITY_LIST_STR
11636        "Community list number (expanded)\n"
11637        "Specify community to reject\n"
11638        "Specify community to accept\n"
11639        "An ordered list as a regular-expression\n")
11640 {
11641   return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
11642 }
11643
11644 DEFUN (no_ip_community_list_name_standard,
11645        no_ip_community_list_name_standard_cmd,
11646        "no ip community-list standard WORD (deny|permit) .AA:NN",
11647        NO_STR
11648        IP_STR
11649        COMMUNITY_LIST_STR
11650        "Specify a standard community-list\n"
11651        "Community list name\n"
11652        "Specify community to reject\n"
11653        "Specify community to accept\n"
11654        COMMUNITY_VAL_STR)
11655 {
11656   return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
11657 }
11658
11659 DEFUN (no_ip_community_list_name_expanded,
11660        no_ip_community_list_name_expanded_cmd,
11661        "no ip community-list expanded WORD (deny|permit) .LINE",
11662        NO_STR
11663        IP_STR
11664        COMMUNITY_LIST_STR
11665        "Specify an expanded community-list\n"
11666        "Community list name\n"
11667        "Specify community to reject\n"
11668        "Specify community to accept\n"
11669        "An ordered list as a regular-expression\n")
11670 {
11671   return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
11672 }
11673
11674 static void
11675 community_list_show (struct vty *vty, struct community_list *list)
11676 {
11677   struct community_entry *entry;
11678
11679   for (entry = list->head; entry; entry = entry->next)
11680     {
11681       if (entry == list->head)
11682         {
11683           if (all_digit (list->name))
11684             vty_out (vty, "Community %s list %s%s",
11685                      entry->style == COMMUNITY_LIST_STANDARD ?
11686                      "standard" : "(expanded) access",
11687                      list->name, VTY_NEWLINE);
11688           else
11689             vty_out (vty, "Named Community %s list %s%s",
11690                      entry->style == COMMUNITY_LIST_STANDARD ?
11691                      "standard" : "expanded",
11692                      list->name, VTY_NEWLINE);
11693         }
11694       if (entry->any)
11695         vty_out (vty, "    %s%s",
11696                  community_direct_str (entry->direct), VTY_NEWLINE);
11697       else
11698         vty_out (vty, "    %s %s%s",
11699                  community_direct_str (entry->direct),
11700                  entry->style == COMMUNITY_LIST_STANDARD
11701                  ? community_str (entry->u.com) : entry->config,
11702                  VTY_NEWLINE);
11703     }
11704 }
11705
11706 DEFUN (show_ip_community_list,
11707        show_ip_community_list_cmd,
11708        "show ip community-list",
11709        SHOW_STR
11710        IP_STR
11711        "List community-list\n")
11712 {
11713   struct community_list *list;
11714   struct community_list_master *cm;
11715
11716   cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
11717   if (! cm)
11718     return CMD_SUCCESS;
11719
11720   for (list = cm->num.head; list; list = list->next)
11721     community_list_show (vty, list);
11722
11723   for (list = cm->str.head; list; list = list->next)
11724     community_list_show (vty, list);
11725
11726   return CMD_SUCCESS;
11727 }
11728
11729 DEFUN (show_ip_community_list_arg,
11730        show_ip_community_list_arg_cmd,
11731        "show ip community-list (<1-500>|WORD)",
11732        SHOW_STR
11733        IP_STR
11734        "List community-list\n"
11735        "Community-list number\n"
11736        "Community-list name\n")
11737 {
11738   struct community_list *list;
11739
11740   list = community_list_lookup (bgp_clist, argv[0], COMMUNITY_LIST_MASTER);
11741   if (! list)
11742     {
11743       vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
11744       return CMD_WARNING;
11745     }
11746
11747   community_list_show (vty, list);
11748
11749   return CMD_SUCCESS;
11750 }
11751
11752 /*
11753  * Large Community code.
11754  */
11755 static int
11756 lcommunity_list_set_vty (struct vty *vty, int argc, const char **argv,
11757                          int style, int reject_all_digit_name)
11758 {
11759   int ret;
11760   int direct;
11761   char *str;
11762
11763   /* Check the list type. */
11764   if (strncmp (argv[1], "p", 1) == 0)
11765     direct = COMMUNITY_PERMIT;
11766   else if (strncmp (argv[1], "d", 1) == 0)
11767     direct = COMMUNITY_DENY;
11768   else
11769     {
11770       vty_out (vty, "%% Matching condition must be permit or deny%s",
11771                VTY_NEWLINE);
11772       return CMD_WARNING;
11773     }
11774
11775   /* All digit name check.  */
11776   if (reject_all_digit_name && all_digit (argv[0]))
11777     {
11778       vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
11779       return CMD_WARNING;
11780     }
11781
11782   /* Concat community string argument.  */
11783   if (argc > 1)
11784     str = argv_concat (argv, argc, 2);
11785   else
11786     str = NULL;
11787
11788   ret = lcommunity_list_set (bgp_clist, argv[0], str, direct, style);
11789
11790   /* Free temporary community list string allocated by
11791      argv_concat().  */
11792   if (str)
11793     XFREE (MTYPE_TMP, str);
11794
11795   if (ret < 0)
11796     {
11797       community_list_perror (vty, ret);
11798       return CMD_WARNING;
11799     }
11800   return CMD_SUCCESS;
11801 }
11802
11803 static int
11804 lcommunity_list_unset_vty (struct vty *vty, int argc, const char **argv,
11805                            int style)
11806 {
11807   int ret;
11808   int direct = 0;
11809   char *str = NULL;
11810
11811   if (argc > 1)
11812     {
11813       /* Check the list direct. */
11814       if (strncmp (argv[1], "p", 1) == 0)
11815         direct = COMMUNITY_PERMIT;
11816       else if (strncmp (argv[1], "d", 1) == 0)
11817         direct = COMMUNITY_DENY;
11818       else
11819         {
11820           vty_out (vty, "%% Matching condition must be permit or deny%s",
11821                    VTY_NEWLINE);
11822           return CMD_WARNING;
11823         }
11824
11825       /* Concat community string argument.  */
11826       str = argv_concat (argv, argc, 2);
11827     }
11828
11829   /* Unset community list.  */
11830   ret = lcommunity_list_unset (bgp_clist, argv[0], str, direct, style);
11831
11832   /* Free temporary community list string allocated by
11833      argv_concat().  */
11834   if (str)
11835     XFREE (MTYPE_TMP, str);
11836
11837   if (ret < 0)
11838     {
11839       community_list_perror (vty, ret);
11840       return CMD_WARNING;
11841     }
11842
11843   return CMD_SUCCESS;
11844 }
11845
11846 /* "large-community-list" keyword help string.  */
11847 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
11848 #define LCOMMUNITY_VAL_STR  "large community in 'aa:bb:cc' format\n"
11849
11850 DEFUN (ip_lcommunity_list_standard,
11851        ip_lcommunity_list_standard_cmd,
11852        "ip large-community-list <1-99> (deny|permit) .AA:BB:CC",
11853        IP_STR
11854        LCOMMUNITY_LIST_STR
11855        "Large Community list number (standard)\n"
11856        "Specify large community to reject\n"
11857        "Specify large community to accept\n"
11858        LCOMMUNITY_VAL_STR)
11859 {
11860   return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 0);
11861 }
11862
11863 ALIAS (ip_lcommunity_list_standard,
11864        ip_lcommunity_list_standard2_cmd,
11865        "ip large-community-list <1-99> (deny|permit)",
11866        IP_STR
11867        LCOMMUNITY_LIST_STR
11868        "Large Community list number (standard)\n"
11869        "Specify large community to reject\n"
11870        "Specify large community to accept\n")
11871
11872 DEFUN (ip_lcommunity_list_expanded,
11873        ip_lcommunity_list_expanded_cmd,
11874        "ip large-community-list <100-500> (deny|permit) .LINE",
11875        IP_STR
11876        LCOMMUNITY_LIST_STR
11877        "Large Community list number (expanded)\n"
11878        "Specify large community to reject\n"
11879        "Specify large community to accept\n"
11880        "An ordered list as a regular-expression\n")
11881 {
11882   return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED, 0);
11883 }
11884
11885 DEFUN (ip_lcommunity_list_name_standard,
11886        ip_lcommunity_list_name_standard_cmd,
11887        "ip large-community-list standard WORD (deny|permit) .AA:BB.CC",
11888        IP_STR
11889        LCOMMUNITY_LIST_STR
11890        "Specify standard large-community-list\n"
11891        "Large Community list name\n"
11892        "Specify large community to reject\n"
11893        "Specify large community to accept\n"
11894        LCOMMUNITY_VAL_STR)
11895 {
11896   return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 1);
11897 }
11898
11899 ALIAS (ip_lcommunity_list_name_standard,
11900        ip_lcommunity_list_name_standard2_cmd,
11901        "ip large-community-list standard WORD (deny|permit)",
11902        IP_STR
11903        LCOMMUNITY_LIST_STR
11904        "Specify standard large-community-list\n"
11905        "Large Community list name\n"
11906        "Specify large community to reject\n"
11907        "Specify large community to accept\n")
11908
11909 DEFUN (ip_lcommunity_list_name_expanded,
11910        ip_lcommunity_list_name_expanded_cmd,
11911        "ip large-community-list expanded WORD (deny|permit) .LINE",
11912        IP_STR
11913        LCOMMUNITY_LIST_STR
11914        "Specify expanded large-community-list\n"
11915        "Large Community list name\n"
11916        "Specify large community to reject\n"
11917        "Specify large community to accept\n"
11918        "An ordered list as a regular-expression\n")
11919 {
11920   return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED, 1);
11921 }
11922
11923 DEFUN (no_ip_lcommunity_list_standard_all,
11924        no_ip_lcommunity_list_standard_all_cmd,
11925        "no ip large-community-list <1-99>",
11926        NO_STR
11927        IP_STR
11928        LCOMMUNITY_LIST_STR
11929        "Large Community list number (standard)\n")
11930 {
11931   return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD);
11932 }
11933
11934 DEFUN (no_ip_lcommunity_list_expanded_all,
11935        no_ip_lcommunity_list_expanded_all_cmd,
11936        "no ip large-community-list <100-500>",
11937        NO_STR
11938        IP_STR
11939        LCOMMUNITY_LIST_STR
11940        "Large Community list number (expanded)\n")
11941 {
11942   return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED);
11943 }
11944
11945 DEFUN (no_ip_lcommunity_list_name_standard_all,
11946        no_ip_lcommunity_list_name_standard_all_cmd,
11947        "no ip large-community-list standard WORD",
11948        NO_STR
11949        IP_STR
11950        LCOMMUNITY_LIST_STR
11951        "Specify standard large-community-list\n"
11952        "Large Community list name\n")
11953 {
11954   return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD);
11955 }
11956
11957 DEFUN (no_ip_lcommunity_list_name_expanded_all,
11958        no_ip_lcommunity_list_name_expanded_all_cmd,
11959        "no ip large-community-list expanded WORD",
11960        NO_STR
11961        IP_STR
11962        LCOMMUNITY_LIST_STR
11963        "Specify expanded large-community-list\n"
11964        "Large Community list name\n")
11965 {
11966   return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED);
11967 }
11968
11969 DEFUN (no_ip_lcommunity_list_standard,
11970        no_ip_lcommunity_list_standard_cmd,
11971        "no ip large-community-list <1-99> (deny|permit) .AA:.AA:NN",
11972        NO_STR
11973        IP_STR
11974        LCOMMUNITY_LIST_STR
11975        "Large Community list number (standard)\n"
11976        "Specify large community to reject\n"
11977        "Specify large community to accept\n"
11978        LCOMMUNITY_VAL_STR)
11979 {
11980   return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD);
11981 }
11982
11983 DEFUN (no_ip_lcommunity_list_expanded,
11984        no_ip_lcommunity_list_expanded_cmd,
11985        "no ip large-community-list <100-500> (deny|permit) .LINE",
11986        NO_STR
11987        IP_STR
11988        LCOMMUNITY_LIST_STR
11989        "Large Community list number (expanded)\n"
11990        "Specify large community to reject\n"
11991        "Specify large community to accept\n"
11992        "An ordered list as a regular-expression\n")
11993 {
11994   return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED);
11995 }
11996
11997 DEFUN (no_ip_lcommunity_list_name_standard,
11998        no_ip_lcommunity_list_name_standard_cmd,
11999        "no ip large-community-list standard WORD (deny|permit) .AA:.AA:NN",
12000        NO_STR
12001        IP_STR
12002        LCOMMUNITY_LIST_STR
12003        "Specify standard large-community-list\n"
12004        "Large Community list name\n"
12005        "Specify large community to reject\n"
12006        "Specify large community to accept\n"
12007        LCOMMUNITY_VAL_STR)
12008 {
12009   return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD);
12010 }
12011
12012 DEFUN (no_ip_lcommunity_list_name_expanded,
12013        no_ip_lcommunity_list_name_expanded_cmd,
12014        "no ip large-community-list expanded WORD (deny|permit) .LINE",
12015        NO_STR
12016        IP_STR
12017        LCOMMUNITY_LIST_STR
12018        "Specify expanded large-community-list\n"
12019        "Large community list name\n"
12020        "Specify large community to reject\n"
12021        "Specify large community to accept\n"
12022        "An ordered list as a regular-expression\n")
12023 {
12024   return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED);
12025 }
12026
12027 static void
12028 lcommunity_list_show (struct vty *vty, struct community_list *list)
12029 {
12030   struct community_entry *entry;
12031
12032   for (entry = list->head; entry; entry = entry->next)
12033     {
12034       if (entry == list->head)
12035         {
12036           if (all_digit (list->name))
12037             vty_out (vty, "Large community %s list %s%s",
12038                      entry->style == EXTCOMMUNITY_LIST_STANDARD ?
12039                      "standard" : "(expanded) access",
12040                      list->name, VTY_NEWLINE);
12041           else
12042             vty_out (vty, "Named large community %s list %s%s",
12043                      entry->style == EXTCOMMUNITY_LIST_STANDARD ?
12044                      "standard" : "expanded",
12045                      list->name, VTY_NEWLINE);
12046         }
12047       if (entry->any)
12048         vty_out (vty, "    %s%s",
12049                  community_direct_str (entry->direct), VTY_NEWLINE);
12050       else
12051         vty_out (vty, "    %s %s%s",
12052                  community_direct_str (entry->direct),
12053                  entry->style == EXTCOMMUNITY_LIST_STANDARD ?
12054                  entry->u.ecom->str : entry->config,
12055                  VTY_NEWLINE);
12056     }
12057 }
12058
12059 DEFUN (show_ip_lcommunity_list,
12060        show_ip_lcommunity_list_cmd,
12061        "show ip large-community-list",
12062        SHOW_STR
12063        IP_STR
12064        "List large-community list\n")
12065 {
12066   struct community_list *list;
12067   struct community_list_master *cm;
12068
12069   cm = community_list_master_lookup (bgp_clist, LARGE_COMMUNITY_LIST_MASTER);
12070   if (! cm)
12071     return CMD_SUCCESS;
12072
12073   for (list = cm->num.head; list; list = list->next)
12074     lcommunity_list_show (vty, list);
12075
12076   for (list = cm->str.head; list; list = list->next)
12077     lcommunity_list_show (vty, list);
12078
12079   return CMD_SUCCESS;
12080 }
12081
12082 DEFUN (show_ip_lcommunity_list_arg,
12083        show_ip_lcommunity_list_arg_cmd,
12084        "show ip large-community-list (<1-500>|WORD)",
12085        SHOW_STR
12086        IP_STR
12087        "List large-community list\n"
12088        "large-community-list number\n"
12089        "large-community-list name\n")
12090 {
12091   struct community_list *list;
12092
12093   list = community_list_lookup (bgp_clist, argv[0], LARGE_COMMUNITY_LIST_MASTER);
12094   if (! list)
12095     {
12096       vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE);
12097       return CMD_WARNING;
12098     }
12099
12100   lcommunity_list_show (vty, list);
12101
12102   return CMD_SUCCESS;
12103 }
12104
12105 static int
12106 extcommunity_list_set_vty (struct vty *vty, int argc, const char **argv, 
12107                            int style, int reject_all_digit_name)
12108 {
12109   int ret;
12110   int direct;
12111   char *str;
12112
12113   /* Check the list type. */
12114   if (strncmp (argv[1], "p", 1) == 0)
12115     direct = COMMUNITY_PERMIT;
12116   else if (strncmp (argv[1], "d", 1) == 0)
12117     direct = COMMUNITY_DENY;
12118   else
12119     {
12120       vty_out (vty, "%% Matching condition must be permit or deny%s",
12121                VTY_NEWLINE);
12122       return CMD_WARNING;
12123     }
12124
12125   /* All digit name check.  */
12126   if (reject_all_digit_name && all_digit (argv[0]))
12127     {
12128       vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
12129       return CMD_WARNING;
12130     }
12131
12132   /* Concat community string argument.  */
12133   if (argc > 1)
12134     str = argv_concat (argv, argc, 2);
12135   else
12136     str = NULL;
12137
12138   ret = extcommunity_list_set (bgp_clist, argv[0], str, direct, style);
12139
12140   /* Free temporary community list string allocated by
12141      argv_concat().  */
12142   if (str)
12143     XFREE (MTYPE_TMP, str);
12144
12145   if (ret < 0)
12146     {
12147       community_list_perror (vty, ret);
12148       return CMD_WARNING;
12149     }
12150   return CMD_SUCCESS;
12151 }
12152
12153 static int
12154 extcommunity_list_unset_vty (struct vty *vty, int argc, const char **argv,
12155                              int style)
12156 {
12157   int ret;
12158   int direct = 0;
12159   char *str = NULL;
12160
12161   if (argc > 1)
12162     {
12163       /* Check the list direct. */
12164       if (strncmp (argv[1], "p", 1) == 0)
12165         direct = COMMUNITY_PERMIT;
12166       else if (strncmp (argv[1], "d", 1) == 0)
12167         direct = COMMUNITY_DENY;
12168       else
12169         {
12170           vty_out (vty, "%% Matching condition must be permit or deny%s",
12171                    VTY_NEWLINE);
12172           return CMD_WARNING;
12173         }
12174
12175       /* Concat community string argument.  */
12176       str = argv_concat (argv, argc, 2);
12177     }
12178
12179   /* Unset community list.  */
12180   ret = extcommunity_list_unset (bgp_clist, argv[0], str, direct, style);
12181
12182   /* Free temporary community list string allocated by
12183      argv_concat().  */
12184   if (str)
12185     XFREE (MTYPE_TMP, str);
12186
12187   if (ret < 0)
12188     {
12189       community_list_perror (vty, ret);
12190       return CMD_WARNING;
12191     }
12192
12193   return CMD_SUCCESS;
12194 }
12195
12196 /* "extcommunity-list" keyword help string.  */
12197 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
12198 #define EXTCOMMUNITY_VAL_STR  "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
12199
12200 DEFUN (ip_extcommunity_list_standard,
12201        ip_extcommunity_list_standard_cmd,
12202        "ip extcommunity-list <1-99> (deny|permit) .AA:NN",
12203        IP_STR
12204        EXTCOMMUNITY_LIST_STR
12205        "Extended Community list number (standard)\n"
12206        "Specify community to reject\n"
12207        "Specify community to accept\n"
12208        EXTCOMMUNITY_VAL_STR)
12209 {
12210   return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
12211 }
12212
12213 ALIAS (ip_extcommunity_list_standard,
12214        ip_extcommunity_list_standard2_cmd,
12215        "ip extcommunity-list <1-99> (deny|permit)",
12216        IP_STR
12217        EXTCOMMUNITY_LIST_STR
12218        "Extended Community list number (standard)\n"
12219        "Specify community to reject\n"
12220        "Specify community to accept\n")
12221
12222 DEFUN (ip_extcommunity_list_expanded,
12223        ip_extcommunity_list_expanded_cmd,
12224        "ip extcommunity-list <100-500> (deny|permit) .LINE",
12225        IP_STR
12226        EXTCOMMUNITY_LIST_STR
12227        "Extended Community list number (expanded)\n"
12228        "Specify community to reject\n"
12229        "Specify community to accept\n"
12230        "An ordered list as a regular-expression\n")
12231 {
12232   return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
12233 }
12234
12235 DEFUN (ip_extcommunity_list_name_standard,
12236        ip_extcommunity_list_name_standard_cmd,
12237        "ip extcommunity-list standard WORD (deny|permit) .AA:NN",
12238        IP_STR
12239        EXTCOMMUNITY_LIST_STR
12240        "Specify standard extcommunity-list\n"
12241        "Extended Community list name\n"
12242        "Specify community to reject\n"
12243        "Specify community to accept\n"
12244        EXTCOMMUNITY_VAL_STR)
12245 {
12246   return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
12247 }
12248
12249 ALIAS (ip_extcommunity_list_name_standard,
12250        ip_extcommunity_list_name_standard2_cmd,
12251        "ip extcommunity-list standard WORD (deny|permit)",
12252        IP_STR
12253        EXTCOMMUNITY_LIST_STR
12254        "Specify standard extcommunity-list\n"
12255        "Extended Community list name\n"
12256        "Specify community to reject\n"
12257        "Specify community to accept\n")
12258
12259 DEFUN (ip_extcommunity_list_name_expanded,
12260        ip_extcommunity_list_name_expanded_cmd,
12261        "ip extcommunity-list expanded WORD (deny|permit) .LINE",
12262        IP_STR
12263        EXTCOMMUNITY_LIST_STR
12264        "Specify expanded extcommunity-list\n"
12265        "Extended Community list name\n"
12266        "Specify community to reject\n"
12267        "Specify community to accept\n"
12268        "An ordered list as a regular-expression\n")
12269 {
12270   return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
12271 }
12272
12273 DEFUN (no_ip_extcommunity_list_standard_all,
12274        no_ip_extcommunity_list_standard_all_cmd,
12275        "no ip extcommunity-list <1-99>",
12276        NO_STR
12277        IP_STR
12278        EXTCOMMUNITY_LIST_STR
12279        "Extended Community list number (standard)\n")
12280 {
12281   return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
12282 }
12283
12284 DEFUN (no_ip_extcommunity_list_expanded_all,
12285        no_ip_extcommunity_list_expanded_all_cmd,
12286        "no ip extcommunity-list <100-500>",
12287        NO_STR
12288        IP_STR
12289        EXTCOMMUNITY_LIST_STR
12290        "Extended Community list number (expanded)\n")
12291 {
12292   return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
12293 }
12294
12295 DEFUN (no_ip_extcommunity_list_name_standard_all,
12296        no_ip_extcommunity_list_name_standard_all_cmd,
12297        "no ip extcommunity-list standard WORD",
12298        NO_STR
12299        IP_STR
12300        EXTCOMMUNITY_LIST_STR
12301        "Specify standard extcommunity-list\n"
12302        "Extended Community list name\n")
12303 {
12304   return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
12305 }
12306
12307 DEFUN (no_ip_extcommunity_list_name_expanded_all,
12308        no_ip_extcommunity_list_name_expanded_all_cmd,
12309        "no ip extcommunity-list expanded WORD",
12310        NO_STR
12311        IP_STR
12312        EXTCOMMUNITY_LIST_STR
12313        "Specify expanded extcommunity-list\n"
12314        "Extended Community list name\n")
12315 {
12316   return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
12317 }
12318
12319 DEFUN (no_ip_extcommunity_list_standard,
12320        no_ip_extcommunity_list_standard_cmd,
12321        "no ip extcommunity-list <1-99> (deny|permit) .AA:NN",
12322        NO_STR
12323        IP_STR
12324        EXTCOMMUNITY_LIST_STR
12325        "Extended Community list number (standard)\n"
12326        "Specify community to reject\n"
12327        "Specify community to accept\n"
12328        EXTCOMMUNITY_VAL_STR)
12329 {
12330   return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
12331 }
12332
12333 DEFUN (no_ip_extcommunity_list_expanded,
12334        no_ip_extcommunity_list_expanded_cmd,
12335        "no ip extcommunity-list <100-500> (deny|permit) .LINE",
12336        NO_STR
12337        IP_STR
12338        EXTCOMMUNITY_LIST_STR
12339        "Extended Community list number (expanded)\n"
12340        "Specify community to reject\n"
12341        "Specify community to accept\n"
12342        "An ordered list as a regular-expression\n")
12343 {
12344   return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
12345 }
12346
12347 DEFUN (no_ip_extcommunity_list_name_standard,
12348        no_ip_extcommunity_list_name_standard_cmd,
12349        "no ip extcommunity-list standard WORD (deny|permit) .AA:NN",
12350        NO_STR
12351        IP_STR
12352        EXTCOMMUNITY_LIST_STR
12353        "Specify standard extcommunity-list\n"
12354        "Extended Community list name\n"
12355        "Specify community to reject\n"
12356        "Specify community to accept\n"
12357        EXTCOMMUNITY_VAL_STR)
12358 {
12359   return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
12360 }
12361
12362 DEFUN (no_ip_extcommunity_list_name_expanded,
12363        no_ip_extcommunity_list_name_expanded_cmd,
12364        "no ip extcommunity-list expanded WORD (deny|permit) .LINE",
12365        NO_STR
12366        IP_STR
12367        EXTCOMMUNITY_LIST_STR
12368        "Specify expanded extcommunity-list\n"
12369        "Community list name\n"
12370        "Specify community to reject\n"
12371        "Specify community to accept\n"
12372        "An ordered list as a regular-expression\n")
12373 {
12374   return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
12375 }
12376
12377 static void
12378 extcommunity_list_show (struct vty *vty, struct community_list *list)
12379 {
12380   struct community_entry *entry;
12381
12382   for (entry = list->head; entry; entry = entry->next)
12383     {
12384       if (entry == list->head)
12385         {
12386           if (all_digit (list->name))
12387             vty_out (vty, "Extended community %s list %s%s",
12388                      entry->style == EXTCOMMUNITY_LIST_STANDARD ?
12389                      "standard" : "(expanded) access",
12390                      list->name, VTY_NEWLINE);
12391           else
12392             vty_out (vty, "Named extended community %s list %s%s",
12393                      entry->style == EXTCOMMUNITY_LIST_STANDARD ?
12394                      "standard" : "expanded",
12395                      list->name, VTY_NEWLINE);
12396         }
12397       if (entry->any)
12398         vty_out (vty, "    %s%s",
12399                  community_direct_str (entry->direct), VTY_NEWLINE);
12400       else
12401         vty_out (vty, "    %s %s%s",
12402                  community_direct_str (entry->direct),
12403                  entry->style == EXTCOMMUNITY_LIST_STANDARD ?
12404                  entry->u.ecom->str : entry->config,
12405                  VTY_NEWLINE);
12406     }
12407 }
12408
12409 DEFUN (show_ip_extcommunity_list,
12410        show_ip_extcommunity_list_cmd,
12411        "show ip extcommunity-list",
12412        SHOW_STR
12413        IP_STR
12414        "List extended-community list\n")
12415 {
12416   struct community_list *list;
12417   struct community_list_master *cm;
12418
12419   cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
12420   if (! cm)
12421     return CMD_SUCCESS;
12422
12423   for (list = cm->num.head; list; list = list->next)
12424     extcommunity_list_show (vty, list);
12425
12426   for (list = cm->str.head; list; list = list->next)
12427     extcommunity_list_show (vty, list);
12428
12429   return CMD_SUCCESS;
12430 }
12431
12432 DEFUN (show_ip_extcommunity_list_arg,
12433        show_ip_extcommunity_list_arg_cmd,
12434        "show ip extcommunity-list (<1-500>|WORD)",
12435        SHOW_STR
12436        IP_STR
12437        "List extended-community list\n"
12438        "Extcommunity-list number\n"
12439        "Extcommunity-list name\n")
12440 {
12441   struct community_list *list;
12442
12443   list = community_list_lookup (bgp_clist, argv[0], EXTCOMMUNITY_LIST_MASTER);
12444   if (! list)
12445     {
12446       vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE);
12447       return CMD_WARNING;
12448     }
12449
12450   extcommunity_list_show (vty, list);
12451
12452   return CMD_SUCCESS;
12453 }
12454
12455 /* Return configuration string of community-list entry.  */
12456 static const char *
12457 community_list_config_str (struct community_entry *entry)
12458 {
12459   const char *str;
12460
12461   if (entry->any)
12462     str = "";
12463   else
12464     {
12465       if (entry->style == COMMUNITY_LIST_STANDARD)
12466         str = community_str (entry->u.com);
12467       else
12468         str = entry->config;
12469     }
12470   return str;
12471 }
12472
12473 /* Display community-list and extcommunity-list configuration.  */
12474 static int
12475 community_list_config_write (struct vty *vty)
12476 {
12477   struct community_list *list;
12478   struct community_entry *entry;
12479   struct community_list_master *cm;
12480   int write = 0;
12481
12482   /* Community-list.  */
12483   cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
12484
12485   for (list = cm->num.head; list; list = list->next)
12486     for (entry = list->head; entry; entry = entry->next)
12487       {
12488         vty_out (vty, "ip community-list %s %s %s%s",
12489                  list->name, community_direct_str (entry->direct),
12490                  community_list_config_str (entry),
12491                  VTY_NEWLINE);
12492         write++;
12493       }
12494   for (list = cm->str.head; list; list = list->next)
12495     for (entry = list->head; entry; entry = entry->next)
12496       {
12497         vty_out (vty, "ip community-list %s %s %s %s%s",
12498                  entry->style == COMMUNITY_LIST_STANDARD
12499                  ? "standard" : "expanded",
12500                  list->name, community_direct_str (entry->direct),
12501                  community_list_config_str (entry),
12502                  VTY_NEWLINE);
12503         write++;
12504       }
12505
12506   /* Extcommunity-list.  */
12507   cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
12508
12509   for (list = cm->num.head; list; list = list->next)
12510     for (entry = list->head; entry; entry = entry->next)
12511       {
12512         vty_out (vty, "ip extcommunity-list %s %s %s%s",
12513                  list->name, community_direct_str (entry->direct),
12514                  community_list_config_str (entry), VTY_NEWLINE);
12515         write++;
12516       }
12517   for (list = cm->str.head; list; list = list->next)
12518     for (entry = list->head; entry; entry = entry->next)
12519       {
12520         vty_out (vty, "ip extcommunity-list %s %s %s %s%s",
12521                  entry->style == EXTCOMMUNITY_LIST_STANDARD
12522                  ? "standard" : "expanded",
12523                  list->name, community_direct_str (entry->direct),
12524                  community_list_config_str (entry), VTY_NEWLINE);
12525         write++;
12526       }
12527
12528
12529     /* lcommunity-list.  */
12530   cm = community_list_master_lookup (bgp_clist, LARGE_COMMUNITY_LIST_MASTER);
12531
12532   for (list = cm->num.head; list; list = list->next)
12533     for (entry = list->head; entry; entry = entry->next)
12534       {
12535         vty_out (vty, "ip large-community-list %s %s %s%s",
12536                  list->name, community_direct_str (entry->direct),
12537                  community_list_config_str (entry), VTY_NEWLINE);
12538         write++;
12539       }
12540   for (list = cm->str.head; list; list = list->next)
12541     for (entry = list->head; entry; entry = entry->next)
12542       {
12543         vty_out (vty, "ip large-community-list %s %s %s %s%s",
12544                  entry->style == LARGE_COMMUNITY_LIST_STANDARD
12545                  ? "standard" : "expanded",
12546                  list->name, community_direct_str (entry->direct),
12547                  community_list_config_str (entry), VTY_NEWLINE);
12548         write++;
12549       }
12550
12551   return write;
12552 }
12553
12554 static struct cmd_node community_list_node =
12555 {
12556   COMMUNITY_LIST_NODE,
12557   "",
12558   1                             /* Export to vtysh.  */
12559 };
12560
12561 static void
12562 community_list_vty (void)
12563 {
12564   install_node (&community_list_node, community_list_config_write);
12565
12566   /* Community-list.  */
12567   install_element (CONFIG_NODE, &ip_community_list_standard_cmd);
12568   install_element (CONFIG_NODE, &ip_community_list_standard2_cmd);
12569   install_element (CONFIG_NODE, &ip_community_list_expanded_cmd);
12570   install_element (CONFIG_NODE, &ip_community_list_name_standard_cmd);
12571   install_element (CONFIG_NODE, &ip_community_list_name_standard2_cmd);
12572   install_element (CONFIG_NODE, &ip_community_list_name_expanded_cmd);
12573   install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd);
12574   install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd);
12575   install_element (CONFIG_NODE, &no_ip_community_list_name_standard_all_cmd);
12576   install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_all_cmd);
12577   install_element (CONFIG_NODE, &no_ip_community_list_standard_cmd);
12578   install_element (CONFIG_NODE, &no_ip_community_list_expanded_cmd);
12579   install_element (CONFIG_NODE, &no_ip_community_list_name_standard_cmd);
12580   install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_cmd);
12581   install_element (VIEW_NODE, &show_ip_community_list_cmd);
12582   install_element (VIEW_NODE, &show_ip_community_list_arg_cmd);
12583
12584   /* Extcommunity-list.  */
12585   install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd);
12586   install_element (CONFIG_NODE, &ip_extcommunity_list_standard2_cmd);
12587   install_element (CONFIG_NODE, &ip_extcommunity_list_expanded_cmd);
12588   install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard_cmd);
12589   install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard2_cmd);
12590   install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd);
12591   install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd);
12592   install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd);
12593   install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_all_cmd);
12594   install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_all_cmd);
12595   install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_cmd);
12596   install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_cmd);
12597   install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_cmd);
12598   install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_cmd);
12599   install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd);
12600   install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd);
12601
12602   /* Large Community List */
12603   install_element (CONFIG_NODE, &ip_lcommunity_list_standard_cmd);
12604   install_element (CONFIG_NODE, &ip_lcommunity_list_standard2_cmd);
12605   install_element (CONFIG_NODE, &ip_lcommunity_list_expanded_cmd);
12606   install_element (CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd);
12607   install_element (CONFIG_NODE, &ip_lcommunity_list_name_standard2_cmd);
12608   install_element (CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd);
12609   install_element (CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd);
12610   install_element (CONFIG_NODE, &no_ip_lcommunity_list_expanded_all_cmd);
12611   install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_standard_all_cmd);
12612   install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_all_cmd);
12613   install_element (CONFIG_NODE, &no_ip_lcommunity_list_standard_cmd);
12614   install_element (CONFIG_NODE, &no_ip_lcommunity_list_expanded_cmd);
12615   install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_standard_cmd);
12616   install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_cmd);
12617   install_element (VIEW_NODE, &show_ip_lcommunity_list_cmd);
12618   install_element (VIEW_NODE, &show_ip_lcommunity_list_arg_cmd);
12619 }