3 * This file created by LabN Consulting, L.L.C.
6 * This file is based on bgp_mplsvpn.c which is Copyright (C) 2000
7 * Kunihiro Ishiguro <kunihiro@zebra.org>
13 This file is part of GNU Zebra.
15 GNU Zebra is free software; you can redistribute it and/or modify it
16 under the terms of the GNU General Public License as published by the
17 Free Software Foundation; either version 2, or (at your option) any
20 GNU Zebra is distributed in the hope that it will be useful, but
21 WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with GNU Zebra; see the file COPYING. If not, write to the Free
27 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
39 #include "bgpd/bgpd.h"
40 #include "bgpd/bgp_table.h"
41 #include "bgpd/bgp_route.h"
42 #include "bgpd/bgp_attr.h"
43 #include "bgpd/bgp_ecommunity.h"
44 #include "bgpd/bgp_mplsvpn.h"
45 #include "bgpd/bgp_vty.h"
46 #include "bgpd/bgp_encap.h"
49 decode_rd_type (u_char *pnt)
53 v = ((u_int16_t) *pnt++ << 8);
54 v |= (u_int16_t) *pnt;
60 decode_rd_as (u_char *pnt, struct rd_as *rd_as)
62 rd_as->as = (u_int16_t) *pnt++ << 8;
63 rd_as->as |= (u_int16_t) *pnt++;
65 rd_as->val = ((u_int32_t) *pnt++) << 24;
66 rd_as->val |= ((u_int32_t) *pnt++) << 16;
67 rd_as->val |= ((u_int32_t) *pnt++) << 8;
68 rd_as->val |= (u_int32_t) *pnt;
72 decode_rd_as4 (u_char *pnt, struct rd_as *rd_as)
74 rd_as->as = (u_int32_t) *pnt++ << 24;
75 rd_as->as |= (u_int32_t) *pnt++ << 16;
76 rd_as->as |= (u_int32_t) *pnt++ << 8;
77 rd_as->as |= (u_int32_t) *pnt++;
79 rd_as->val = ((u_int32_t) *pnt++ << 8);
80 rd_as->val |= (u_int32_t) *pnt;
84 decode_rd_ip (u_char *pnt, struct rd_ip *rd_ip)
86 memcpy (&rd_ip->ip, pnt, 4);
89 rd_ip->val = ((u_int16_t) *pnt++ << 8);
90 rd_ip->val |= (u_int16_t) *pnt;
94 ecom2prd(struct ecommunity *ecom, struct prefix_rd *prd)
98 memset(prd, 0, sizeof(struct prefix_rd));
99 prd->family = AF_UNSPEC;
105 for (i = 0; i < (ecom->size * ECOMMUNITY_SIZE); i += ECOMMUNITY_SIZE) {
119 prd->val[1] = ep[0] & 0x03;
120 memcpy(prd->val + 2, ep + 2, 6);
128 bgp_nlri_parse_encap(
130 struct attr *attr, /* Need even for withdraw */
131 struct bgp_nlri *packet)
135 afi_t afi = packet->afi;
141 struct prefix_rd prd;
142 struct ecommunity *pEcom = NULL;
143 u_int16_t rdtype = 0xffff;
146 /* Check peer status. */
147 if (peer->status != Established)
151 if (attr && attr->extra && attr->extra->ecommunity)
152 pEcom = attr->extra->ecommunity;
154 ecom2prd(pEcom, &prd);
155 memset(&rd_as, 0, sizeof(rd_as));
156 memset(&rd_ip, 0, sizeof(rd_ip));
160 rdtype = (prd.val[0] << 8) | prd.val[1];
162 /* Decode RD value. */
163 if (rdtype == RD_TYPE_AS)
164 decode_rd_as (prd.val + 2, &rd_as);
165 else if (rdtype == RD_TYPE_IP)
166 decode_rd_ip (prd.val + 2, &rd_ip);
167 else if (rdtype == RD_TYPE_AS4)
168 decode_rd_as4 (prd.val + 2, &rd_as);
171 zlog_err ("Invalid RD type %d", rdtype);
177 * NB: this code was based on the MPLS VPN code, which supported RDs.
178 * For the moment we are retaining the underlying RIB structure that
179 * keeps a per-RD radix tree, but since the RDs are not carried over
180 * the wire, we set the RD internally to 0.
182 prd.family = AF_UNSPEC;
184 memset(prd.val, 0, sizeof(prd.val));
187 lim = pnt + packet->length;
189 for (; pnt < lim; pnt += psize)
191 /* Clear prefix structure. */
192 memset (&p, 0, sizeof (struct prefix));
194 /* Fetch prefix length. */
196 p.family = afi2family(afi);
198 /* bad afi, shouldn't happen */
199 zlog_warn("%s: bad afi %d, dropping incoming route", __func__, afi);
202 psize = PSIZE (prefixlen);
204 p.prefixlen = prefixlen;
205 memcpy (&p.u.prefix, pnt, psize);
207 if (pnt + psize > lim)
211 if (rdtype == RD_TYPE_AS)
212 zlog_info ("rd-as %u:%u prefix %s/%d", rd_as.as, rd_as.val,
213 inet_ntop (p.family, &p.u.prefix, buf, BUFSIZ),
215 else if (rdtype == RD_TYPE_IP)
216 zlog_info ("rd-ip %s:%u prefix %s/%d", inet_ntoa (rd_ip.ip),
218 inet_ntop (p.family, &p.u.prefix, buf, BUFSIZ),
220 else if (rdtype == RD_TYPE_AS4)
221 zlog_info ("rd-as4 %u:%u prefix %s/%d", rd_as.as, rd_as.val,
222 inet_ntop (p.family, &p.u.prefix, buf, BUFSIZ),
225 zlog_info ("rd unknown, default to 0:0 prefix %s/%d",
226 inet_ntop (p.family, &p.u.prefix, buf, BUFSIZ),
230 bgp_update (peer, &p, attr, afi, SAFI_ENCAP,
231 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL, 0);
233 bgp_withdraw (peer, &p, attr, afi, SAFI_ENCAP,
234 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL);
238 /* Packet length consistency check. */
246 /* TBD: these routes should probably all be host routes */
248 /* For testing purpose, static route of ENCAP. */
249 DEFUN (encap_network,
251 "network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD",
252 "Specify a network to announce via BGP\n"
253 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
254 "Specify Route Distinguisher\n"
255 "ENCAP Route Distinguisher\n"
259 return bgp_static_set_safi (SAFI_ENCAP, vty, argv[0], argv[1], argv[2], NULL);
262 /* For testing purpose, static route of ENCAP. */
263 DEFUN (no_encap_network,
264 no_encap_network_cmd,
265 "no network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD",
267 "Specify a network to announce via BGP\n"
268 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
269 "Specify Route Distinguisher\n"
270 "ENCAP Route Distinguisher\n"
274 return bgp_static_unset_safi (SAFI_ENCAP, vty, argv[0], argv[1], argv[2]);
278 show_adj_route_encap (struct vty *vty, struct peer *peer, struct prefix_rd *prd)
281 struct bgp_table *table;
287 char v4_header[] = " Network Next Hop Metric LocPrf Weight Path%s";
289 bgp = bgp_get_default ();
292 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
296 for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_ENCAP]); rn;
297 rn = bgp_route_next (rn))
299 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
302 if ((table = rn->info) != NULL)
306 for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
307 if ((attr = rm->info) != NULL)
311 vty_out (vty, "BGP table version is 0, local router ID is %s%s",
312 inet_ntoa (bgp->router_id), VTY_NEWLINE);
313 vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s",
315 vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s",
316 VTY_NEWLINE, VTY_NEWLINE);
317 vty_out (vty, v4_header, VTY_NEWLINE);
330 vty_out (vty, "Route Distinguisher: ");
332 /* Decode RD type. */
333 type = decode_rd_type (pnt);
338 decode_rd_as (pnt + 2, &rd_as);
339 vty_out (vty, "%u:%d", rd_as.as, rd_as.val);
343 decode_rd_ip (pnt + 2, &rd_ip);
344 vty_out (vty, "%s:%d", inet_ntoa (rd_ip.ip), rd_ip.val);
348 vty_out (vty, "unknown RD type");
352 vty_out (vty, "%s", VTY_NEWLINE);
355 route_vty_out_tmp (vty, &rm->p, attr, SAFI_ENCAP);
364 bgp_show_type_normal,
365 bgp_show_type_regexp,
366 bgp_show_type_prefix_list,
367 bgp_show_type_filter_list,
368 bgp_show_type_neighbor,
369 bgp_show_type_cidr_only,
370 bgp_show_type_prefix_longer,
371 bgp_show_type_community_all,
372 bgp_show_type_community,
373 bgp_show_type_community_exact,
374 bgp_show_type_community_list,
375 bgp_show_type_community_list_exact
382 struct prefix_rd *prd,
383 enum bgp_show_type type,
388 struct bgp_table *table;
394 char v4_header[] = " Network Next Hop Metric LocPrf Weight Path%s";
395 char v4_header_tag[] = " Network Next Hop In tag/Out tag%s";
397 unsigned long output_count = 0;
398 unsigned long total_count = 0;
400 bgp = bgp_get_default ();
403 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
407 if ((afi != AFI_IP) && (afi != AFI_IP6)) {
408 vty_out (vty, "Afi %d not supported%s", afi, VTY_NEWLINE);
412 for (rn = bgp_table_top (bgp->rib[afi][SAFI_ENCAP]); rn; rn = bgp_route_next (rn))
414 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
417 if ((table = rn->info) != NULL)
421 for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
422 for (ri = rm->info; ri; ri = ri->next)
425 if (type == bgp_show_type_neighbor)
427 union sockunion *su = output_arg;
429 if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su))
435 vty_out (vty, v4_header_tag, VTY_NEWLINE);
438 vty_out (vty, "BGP table version is 0, local router ID is %s%s",
439 inet_ntoa (bgp->router_id), VTY_NEWLINE);
440 vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s",
442 vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s",
443 VTY_NEWLINE, VTY_NEWLINE);
444 vty_out (vty, v4_header, VTY_NEWLINE);
458 /* Decode RD type. */
459 type = decode_rd_type (pnt);
461 vty_out (vty, "Route Distinguisher: ");
466 decode_rd_as (pnt + 2, &rd_as);
467 vty_out (vty, "%u:%d", rd_as.as, rd_as.val);
471 decode_rd_ip (pnt + 2, &rd_ip);
472 vty_out (vty, "%s:%d", inet_ntoa (rd_ip.ip), rd_ip.val);
476 vty_out (vty, "Unknown RD type");
480 vty_out (vty, "%s", VTY_NEWLINE);
484 route_vty_out_tag (vty, &rm->p, ri, 0, SAFI_ENCAP);
486 route_vty_out (vty, &rm->p, ri, 0, SAFI_ENCAP);
492 if (output_count == 0)
494 vty_out (vty, "No prefixes displayed, %ld exist%s", total_count, VTY_NEWLINE);
497 vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s",
498 VTY_NEWLINE, output_count, total_count, VTY_NEWLINE);
503 DEFUN (show_bgp_ipv4_encap,
504 show_bgp_ipv4_encap_cmd,
505 "show bgp ipv4 encap",
509 "Display ENCAP NLRI specific information\n")
511 return bgp_show_encap (vty, AFI_IP, NULL, bgp_show_type_normal, NULL, 0);
514 DEFUN (show_bgp_ipv6_encap,
515 show_bgp_ipv6_encap_cmd,
516 "show bgp ipv6 encap",
520 "Display ENCAP NLRI specific information\n")
522 return bgp_show_encap (vty, AFI_IP6, NULL, bgp_show_type_normal, NULL, 0);
525 DEFUN (show_bgp_ipv4_encap_rd,
526 show_bgp_ipv4_encap_rd_cmd,
527 "show bgp ipv4 encap rd ASN:nn_or_IP-address:nn",
531 "Display ENCAP NLRI specific information\n"
532 "Display information for a route distinguisher\n"
533 "ENCAP Route Distinguisher\n")
536 struct prefix_rd prd;
538 ret = str2prefix_rd (argv[0], &prd);
541 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
544 return bgp_show_encap (vty, AFI_IP, &prd, bgp_show_type_normal, NULL, 0);
547 DEFUN (show_bgp_ipv6_encap_rd,
548 show_bgp_ipv6_encap_rd_cmd,
549 "show bgp ipv6 encap rd ASN:nn_or_IP-address:nn",
553 "Display ENCAP NLRI specific information\n"
554 "Display information for a route distinguisher\n"
555 "ENCAP Route Distinguisher\n"
556 "Display BGP tags for prefixes\n")
559 struct prefix_rd prd;
561 ret = str2prefix_rd (argv[0], &prd);
564 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
567 return bgp_show_encap (vty, AFI_IP6, &prd, bgp_show_type_normal, NULL, 0);
570 DEFUN (show_bgp_ipv4_encap_tags,
571 show_bgp_ipv4_encap_tags_cmd,
572 "show bgp ipv4 encap tags",
576 "Display ENCAP NLRI specific information\n"
577 "Display BGP tags for prefixes\n")
579 return bgp_show_encap (vty, AFI_IP, NULL, bgp_show_type_normal, NULL, 1);
582 DEFUN (show_bgp_ipv6_encap_tags,
583 show_bgp_ipv6_encap_tags_cmd,
584 "show bgp ipv6 encap tags",
588 "Display ENCAP NLRI specific information\n"
589 "Display BGP tags for prefixes\n")
591 return bgp_show_encap (vty, AFI_IP6, NULL, bgp_show_type_normal, NULL, 1);
595 DEFUN (show_bgp_ipv4_encap_rd_tags,
596 show_bgp_ipv4_encap_rd_tags_cmd,
597 "show bgp ipv4 encap rd ASN:nn_or_IP-address:nn tags",
601 "Display ENCAP NLRI specific information\n"
602 "Display information for a route distinguisher\n"
603 "ENCAP Route Distinguisher\n"
604 "Display BGP tags for prefixes\n")
607 struct prefix_rd prd;
609 ret = str2prefix_rd (argv[0], &prd);
612 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
615 return bgp_show_encap (vty, AFI_IP, &prd, bgp_show_type_normal, NULL, 1);
618 DEFUN (show_bgp_ipv6_encap_rd_tags,
619 show_bgp_ipv6_encap_rd_tags_cmd,
620 "show bgp ipv6 encap rd ASN:nn_or_IP-address:nn tags",
624 "Display ENCAP NLRI specific information\n"
625 "Display information for a route distinguisher\n"
626 "ENCAP Route Distinguisher\n"
627 "Display BGP tags for prefixes\n")
630 struct prefix_rd prd;
632 ret = str2prefix_rd (argv[0], &prd);
635 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
638 return bgp_show_encap (vty, AFI_IP6, &prd, bgp_show_type_normal, NULL, 1);
641 DEFUN (show_bgp_ipv4_encap_neighbor_routes,
642 show_bgp_ipv4_encap_neighbor_routes_cmd,
643 "show bgp ipv4 encap neighbors A.B.C.D routes",
647 "Display ENCAP NLRI specific information\n"
648 "Detailed information on TCP and BGP neighbor connections\n"
649 "Neighbor to display information about\n"
650 "Display routes learned from neighbor\n")
655 if (str2sockunion(argv[0], &su))
657 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
661 peer = peer_lookup (NULL, &su);
662 if (! peer || ! peer->afc[AFI_IP][SAFI_ENCAP])
664 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
668 return bgp_show_encap (vty, AFI_IP, NULL, bgp_show_type_neighbor, &su, 0);
671 DEFUN (show_bgp_ipv6_encap_neighbor_routes,
672 show_bgp_ipv6_encap_neighbor_routes_cmd,
673 "show bgp ipv6 encap neighbors A.B.C.D routes",
677 "Display ENCAP NLRI specific information\n"
678 "Detailed information on TCP and BGP neighbor connections\n"
679 "Neighbor to display information about\n"
680 "Display routes learned from neighbor\n")
685 if (str2sockunion(argv[0], &su))
687 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
691 peer = peer_lookup (NULL, &su);
692 if (! peer || ! peer->afc[AFI_IP6][SAFI_ENCAP])
694 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
698 return bgp_show_encap (vty, AFI_IP6, NULL, bgp_show_type_neighbor, &su, 0);
701 DEFUN (show_bgp_ipv4_encap_rd_neighbor_routes,
702 show_bgp_ipv4_encap_rd_neighbor_routes_cmd,
703 "show bgp ipv4 encap rd ASN:nn_or_IP-address:nn neighbors (A.B.C.D|X:X::X:X) routes",
707 "Display ENCAP NLRI specific information\n"
708 "Display information for a route distinguisher\n"
709 "ENCAP Route Distinguisher\n"
710 "Detailed information on TCP and BGP neighbor connections\n"
711 "Neighbor to display information about\n"
712 "Neighbor to display information about\n"
713 "Display routes learned from neighbor\n")
718 struct prefix_rd prd;
720 ret = str2prefix_rd (argv[0], &prd);
723 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
727 if (str2sockunion(argv[1], &su))
729 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
733 peer = peer_lookup (NULL, &su);
734 if (! peer || ! peer->afc[AFI_IP][SAFI_ENCAP])
736 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
740 return bgp_show_encap (vty, AFI_IP, &prd, bgp_show_type_neighbor, &su, 0);
743 DEFUN (show_bgp_ipv6_encap_rd_neighbor_routes,
744 show_bgp_ipv6_encap_rd_neighbor_routes_cmd,
745 "show bgp ipv6 encap rd ASN:nn_or_IP-address:nn neighbors (A.B.C.D|X:X::X:X) routes",
749 "Display ENCAP NLRI specific information\n"
750 "Display information for a route distinguisher\n"
751 "ENCAP Route Distinguisher\n"
752 "Detailed information on TCP and BGP neighbor connections\n"
753 "Neighbor to display information about\n"
754 "Neighbor to display information about\n"
755 "Display routes learned from neighbor\n")
760 struct prefix_rd prd;
762 ret = str2prefix_rd (argv[0], &prd);
765 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
769 if (str2sockunion(argv[1], &su))
771 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
775 peer = peer_lookup (NULL, &su);
776 if (! peer || ! peer->afc[AFI_IP6][SAFI_ENCAP])
778 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
782 return bgp_show_encap (vty, AFI_IP6, &prd, bgp_show_type_neighbor, &su, 0);
785 DEFUN (show_bgp_ipv4_encap_neighbor_advertised_routes,
786 show_bgp_ipv4_encap_neighbor_advertised_routes_cmd,
787 "show bgp ipv4 encap neighbors A.B.C.D advertised-routes",
791 "Display ENCAP NLRI specific information\n"
792 "Detailed information on TCP and BGP neighbor connections\n"
793 "Neighbor to display information about\n"
794 "Display the routes advertised to a BGP neighbor\n")
800 ret = str2sockunion (argv[0], &su);
803 vty_out (vty, "%% Malformed address: %s%s", argv[0], VTY_NEWLINE);
806 peer = peer_lookup (NULL, &su);
807 if (! peer || ! peer->afc[AFI_IP][SAFI_ENCAP])
809 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
813 return show_adj_route_encap (vty, peer, NULL);
816 DEFUN (show_bgp_ipv6_encap_neighbor_advertised_routes,
817 show_bgp_ipv6_encap_neighbor_advertised_routes_cmd,
818 "show bgp ipv6 encap neighbors A.B.C.D advertised-routes",
822 "Display ENCAP NLRI specific information\n"
823 "Detailed information on TCP and BGP neighbor connections\n"
824 "Neighbor to display information about\n"
825 "Display the routes advertised to a BGP neighbor\n")
831 ret = str2sockunion (argv[0], &su);
834 vty_out (vty, "%% Malformed address: %s%s", argv[0], VTY_NEWLINE);
837 peer = peer_lookup (NULL, &su);
838 if (! peer || ! peer->afc[AFI_IP6][SAFI_ENCAP])
840 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
844 return show_adj_route_encap (vty, peer, NULL);
847 DEFUN (show_bgp_ipv4_encap_rd_neighbor_advertised_routes,
848 show_bgp_ipv4_encap_rd_neighbor_advertised_routes_cmd,
849 "show bgp ipv4 encap rd ASN:nn_or_IP-address:nn neighbors (A.B.C.D|X:X::X:X) advertised-routes",
853 "Display ENCAP NLRI specific information\n"
854 "Display information for a route distinguisher\n"
855 "ENCAP Route Distinguisher\n"
856 "Detailed information on TCP and BGP neighbor connections\n"
857 "Neighbor to display information about\n"
858 "Neighbor to display information about\n"
859 "Display the routes advertised to a BGP neighbor\n")
863 struct prefix_rd prd;
866 ret = str2sockunion (argv[1], &su);
869 vty_out (vty, "%% Malformed address: %s%s", argv[1], VTY_NEWLINE);
872 peer = peer_lookup (NULL, &su);
873 if (! peer || ! peer->afc[AFI_IP][SAFI_ENCAP])
875 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
879 ret = str2prefix_rd (argv[0], &prd);
882 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
886 return show_adj_route_encap (vty, peer, &prd);
889 DEFUN (show_bgp_ipv6_encap_rd_neighbor_advertised_routes,
890 show_bgp_ipv6_encap_rd_neighbor_advertised_routes_cmd,
891 "show bgp ipv6 encap rd ASN:nn_or_IP-address:nn neighbors (A.B.C.D|X:X::X:X) advertised-routes",
895 "Display ENCAP NLRI specific information\n"
896 "Display information for a route distinguisher\n"
897 "ENCAP Route Distinguisher\n"
898 "Detailed information on TCP and BGP neighbor connections\n"
899 "Neighbor to display information about\n"
900 "Neighbor to display information about\n"
901 "Display the routes advertised to a BGP neighbor\n")
905 struct prefix_rd prd;
908 ret = str2sockunion (argv[1], &su);
911 vty_out (vty, "%% Malformed address: %s%s", argv[1], VTY_NEWLINE);
914 peer = peer_lookup (NULL, &su);
915 if (! peer || ! peer->afc[AFI_IP6][SAFI_ENCAP])
917 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
921 ret = str2prefix_rd (argv[0], &prd);
924 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
928 return show_adj_route_encap (vty, peer, &prd);
932 bgp_encap_init (void)
934 install_element (BGP_ENCAP_NODE, &encap_network_cmd);
935 install_element (BGP_ENCAP_NODE, &no_encap_network_cmd);
937 install_element (VIEW_NODE, &show_bgp_ipv4_encap_cmd);
938 install_element (VIEW_NODE, &show_bgp_ipv4_encap_rd_cmd);
939 install_element (VIEW_NODE, &show_bgp_ipv4_encap_tags_cmd);
940 install_element (VIEW_NODE, &show_bgp_ipv4_encap_rd_tags_cmd);
941 install_element (VIEW_NODE, &show_bgp_ipv4_encap_neighbor_routes_cmd);
942 install_element (VIEW_NODE, &show_bgp_ipv4_encap_rd_neighbor_routes_cmd);
943 install_element (VIEW_NODE, &show_bgp_ipv4_encap_neighbor_advertised_routes_cmd);
944 install_element (VIEW_NODE, &show_bgp_ipv4_encap_rd_neighbor_advertised_routes_cmd);
946 install_element (VIEW_NODE, &show_bgp_ipv6_encap_cmd);
947 install_element (VIEW_NODE, &show_bgp_ipv6_encap_rd_cmd);
948 install_element (VIEW_NODE, &show_bgp_ipv6_encap_tags_cmd);
949 install_element (VIEW_NODE, &show_bgp_ipv6_encap_rd_tags_cmd);
950 install_element (VIEW_NODE, &show_bgp_ipv6_encap_neighbor_routes_cmd);
951 install_element (VIEW_NODE, &show_bgp_ipv6_encap_rd_neighbor_routes_cmd);
952 install_element (VIEW_NODE, &show_bgp_ipv6_encap_neighbor_advertised_routes_cmd);
953 install_element (VIEW_NODE, &show_bgp_ipv6_encap_rd_neighbor_advertised_routes_cmd);