#include "bgpd/bgp_vty.h"
#include "bgpd/bgp_encap.h"
-static u_int16_t
-decode_rd_type (u_char *pnt)
-{
- u_int16_t v;
-
- v = ((u_int16_t) *pnt++ << 8);
- v |= (u_int16_t) *pnt;
- return v;
-}
-
-
-static void
-decode_rd_as (u_char *pnt, struct rd_as *rd_as)
-{
- rd_as->as = (u_int16_t) *pnt++ << 8;
- rd_as->as |= (u_int16_t) *pnt++;
-
- rd_as->val = ((u_int32_t) *pnt++) << 24;
- rd_as->val |= ((u_int32_t) *pnt++) << 16;
- rd_as->val |= ((u_int32_t) *pnt++) << 8;
- rd_as->val |= (u_int32_t) *pnt;
-}
-
-static void
-decode_rd_as4 (u_char *pnt, struct rd_as *rd_as)
-{
- rd_as->as = (u_int32_t) *pnt++ << 24;
- rd_as->as |= (u_int32_t) *pnt++ << 16;
- rd_as->as |= (u_int32_t) *pnt++ << 8;
- rd_as->as |= (u_int32_t) *pnt++;
-
- rd_as->val = ((u_int32_t) *pnt++ << 8);
- rd_as->val |= (u_int32_t) *pnt;
-}
-
-static void
-decode_rd_ip (u_char *pnt, struct rd_ip *rd_ip)
-{
- memcpy (&rd_ip->ip, pnt, 4);
- pnt += 4;
-
- rd_ip->val = ((u_int16_t) *pnt++ << 8);
- rd_ip->val |= (u_int16_t) *pnt;
-}
+#if ENABLE_BGP_VNC
+#include "bgpd/rfapi/rfapi_backend.h"
+#endif
static void
ecom2prd(struct ecommunity *ecom, struct prefix_rd *prd)
int
bgp_nlri_parse_encap(
- afi_t afi,
struct peer *peer,
- struct attr *attr, /* Need even for withdraw */
- struct bgp_nlri *packet,
- int withdraw) /* 0=update, !0 = withdraw */
+ struct attr *attr,
+ struct bgp_nlri *packet)
{
u_char *pnt;
u_char *lim;
+ afi_t afi = packet->afi;
struct prefix p;
int psize = 0;
int prefixlen;
inet_ntop (p.family, &p.u.prefix, buf, BUFSIZ),
p.prefixlen);
- if (!withdraw) {
+ if (attr) {
bgp_update (peer, &p, 0, attr, afi, SAFI_ENCAP,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL, 0);
+#if ENABLE_BGP_VNC
+ rfapiProcessUpdate(peer, NULL, &p, &prd, attr, afi, SAFI_ENCAP,
+ ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL);
+#endif
} else {
+#if ENABLE_BGP_VNC
+ rfapiProcessWithdraw(peer, NULL, &p, &prd, attr, afi, SAFI_ENCAP,
+ ZEBRA_ROUTE_BGP, 0);
+#endif
bgp_withdraw (peer, &p, 0, attr, afi, SAFI_ENCAP,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL);
}
encap_network_cmd,
"network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD",
"Specify a network to announce via BGP\n"
- "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
+ "IPv4 prefix\n"
"Specify Route Distinguisher\n"
"ENCAP Route Distinguisher\n"
"BGP tag\n"
"tag value\n")
{
- return bgp_static_set_safi (SAFI_ENCAP, vty, argv[0], argv[1], argv[2], NULL);
+ int idx_ipv4 = 1;
+ int idx_rd = 3;
+ int idx_word = 5;
+ return bgp_static_set_safi (SAFI_ENCAP, vty, argv[idx_ipv4]->arg, argv[idx_rd]->arg, argv[idx_word]->arg, NULL);
}
/* For testing purpose, static route of ENCAP. */
"no network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD",
NO_STR
"Specify a network to announce via BGP\n"
- "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
+ "IPv4 prefix\n"
"Specify Route Distinguisher\n"
"ENCAP Route Distinguisher\n"
"BGP tag\n"
"tag value\n")
{
- return bgp_static_unset_safi (SAFI_ENCAP, vty, argv[0], argv[1], argv[2]);
+ int idx_ipv4 = 2;
+ int idx_rd = 4;
+ int idx_word = 6;
+ return bgp_static_unset_safi (SAFI_ENCAP, vty, argv[idx_ipv4]->arg, argv[idx_rd]->arg, argv[idx_word]->arg);
}
static int
"Display information for a route distinguisher\n"
"ENCAP Route Distinguisher\n")
{
+ int idx_rd = 5;
int ret;
struct prefix_rd prd;
- ret = str2prefix_rd (argv[0], &prd);
+ ret = str2prefix_rd (argv[idx_rd]->arg, &prd);
if (! ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
"ENCAP Route Distinguisher\n"
"Display BGP tags for prefixes\n")
{
+ int idx_rd = 5;
int ret;
struct prefix_rd prd;
- ret = str2prefix_rd (argv[0], &prd);
+ ret = str2prefix_rd (argv[idx_rd]->arg, &prd);
if (! ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
"ENCAP Route Distinguisher\n"
"Display BGP tags for prefixes\n")
{
+ int idx_rd = 5;
int ret;
struct prefix_rd prd;
- ret = str2prefix_rd (argv[0], &prd);
+ ret = str2prefix_rd (argv[idx_rd]->arg, &prd);
if (! ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
"ENCAP Route Distinguisher\n"
"Display BGP tags for prefixes\n")
{
+ int idx_rd = 5;
int ret;
struct prefix_rd prd;
- ret = str2prefix_rd (argv[0], &prd);
+ ret = str2prefix_rd (argv[idx_rd]->arg, &prd);
if (! ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
"Neighbor to display information about\n"
"Display routes learned from neighbor\n")
{
- union sockunion *su;
+ int idx_peer = 5;
+ union sockunion su;
struct peer *peer;
-
- su = sockunion_str2su (argv[0]);
- if (su == NULL)
+
+ if (sockunion_str2su (argv[idx_peer]->arg))
{
- vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
+ vty_out (vty, "Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
return CMD_WARNING;
}
- peer = peer_lookup (NULL, su);
+ peer = peer_lookup (NULL, &su);
if (! peer || ! peer->afc[AFI_IP][SAFI_ENCAP])
{
vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
return CMD_WARNING;
}
- return bgp_show_encap (vty, AFI_IP, NULL, bgp_show_type_neighbor, su, 0);
+ return bgp_show_encap (vty, AFI_IP, NULL, bgp_show_type_neighbor, &su, 0);
}
#ifdef HAVE_IPV6
DEFUN (show_bgp_ipv6_encap_neighbor_routes,
"Neighbor to display information about\n"
"Display routes learned from neighbor\n")
{
- union sockunion *su;
+ int idx_peer = 5;
+ union sockunion su;
struct peer *peer;
- su = sockunion_str2su (argv[0]);
- if (su == NULL)
+ if (str2sockunion(argv[idx_peer]->arg, &su))
{
- vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
+ vty_out (vty, "Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
return CMD_WARNING;
}
- peer = peer_lookup (NULL, su);
+ peer = peer_lookup (NULL, &su);
if (! peer || ! peer->afc[AFI_IP6][SAFI_ENCAP])
{
vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
return CMD_WARNING;
}
- return bgp_show_encap (vty, AFI_IP6, NULL, bgp_show_type_neighbor, su, 0);
+ return bgp_show_encap (vty, AFI_IP6, NULL, bgp_show_type_neighbor, &su, 0);
}
#endif
DEFUN (show_bgp_ipv4_encap_rd_neighbor_routes,
show_bgp_ipv4_encap_rd_neighbor_routes_cmd,
- "show bgp ipv4 encap rd ASN:nn_or_IP-address:nn neighbors (A.B.C.D|X:X::X:X) routes",
+ "show bgp ipv4 encap rd ASN:nn_or_IP-address:nn neighbors <A.B.C.D|X:X::X:X> routes",
SHOW_STR
BGP_STR
"Address Family\n"
"Neighbor to display information about\n"
"Display routes learned from neighbor\n")
{
+ int idx_rd = 5;
+ int idx_peer = 7;
int ret;
- union sockunion *su;
+ union sockunion su;
struct peer *peer;
struct prefix_rd prd;
- ret = str2prefix_rd (argv[0], &prd);
+ ret = str2prefix_rd (argv[idx_rd]->arg, &prd);
if (! ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
return CMD_WARNING;
}
- su = sockunion_str2su (argv[1]);
- if (su == NULL)
+ if (str2sockunion(argv[idx_peer]->arg, &su))
{
- vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
+ vty_out (vty, "Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
return CMD_WARNING;
}
- peer = peer_lookup (NULL, su);
+ peer = peer_lookup (NULL, &su);
if (! peer || ! peer->afc[AFI_IP][SAFI_ENCAP])
{
vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
return CMD_WARNING;
}
- return bgp_show_encap (vty, AFI_IP, &prd, bgp_show_type_neighbor, su, 0);
+ return bgp_show_encap (vty, AFI_IP, &prd, bgp_show_type_neighbor, &su, 0);
}
#ifdef HAVE_IPV6
DEFUN (show_bgp_ipv6_encap_rd_neighbor_routes,
show_bgp_ipv6_encap_rd_neighbor_routes_cmd,
- "show bgp ipv6 encap rd ASN:nn_or_IP-address:nn neighbors (A.B.C.D|X:X::X:X) routes",
+ "show bgp ipv6 encap rd ASN:nn_or_IP-address:nn neighbors <A.B.C.D|X:X::X:X> routes",
SHOW_STR
BGP_STR
"Address Family\n"
"Neighbor to display information about\n"
"Display routes learned from neighbor\n")
{
+ int idx_rd = 5;
+ int idx_peer = 7;
int ret;
- union sockunion *su;
+ union sockunion su;
struct peer *peer;
struct prefix_rd prd;
- ret = str2prefix_rd (argv[0], &prd);
+ ret = str2prefix_rd (argv[idx_rd]->arg, &prd);
if (! ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
return CMD_WARNING;
}
- su = sockunion_str2su (argv[1]);
- if (su == NULL)
+ if (str2sockunion(argv[idx_peer]->arg, &su))
{
- vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
+ vty_out (vty, "Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
return CMD_WARNING;
}
- peer = peer_lookup (NULL, su);
+ peer = peer_lookup (NULL, &su);
if (! peer || ! peer->afc[AFI_IP6][SAFI_ENCAP])
{
vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
return CMD_WARNING;
}
- return bgp_show_encap (vty, AFI_IP6, &prd, bgp_show_type_neighbor, su, 0);
+ return bgp_show_encap (vty, AFI_IP6, &prd, bgp_show_type_neighbor, &su, 0);
}
#endif
"Neighbor to display information about\n"
"Display the routes advertised to a BGP neighbor\n")
{
+ int idx_peer = 5;
int ret;
struct peer *peer;
union sockunion su;
- ret = str2sockunion (argv[0], &su);
+ ret = str2sockunion (argv[idx_peer]->arg, &su);
if (ret < 0)
{
- vty_out (vty, "%% Malformed address: %s%s", argv[0], VTY_NEWLINE);
+ vty_out (vty, "%% Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
return CMD_WARNING;
}
peer = peer_lookup (NULL, &su);
"Neighbor to display information about\n"
"Display the routes advertised to a BGP neighbor\n")
{
+ int idx_peer = 5;
int ret;
struct peer *peer;
union sockunion su;
- ret = str2sockunion (argv[0], &su);
+ ret = str2sockunion (argv[idx_peer]->arg, &su);
if (ret < 0)
{
- vty_out (vty, "%% Malformed address: %s%s", argv[0], VTY_NEWLINE);
+ vty_out (vty, "%% Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
return CMD_WARNING;
}
peer = peer_lookup (NULL, &su);
DEFUN (show_bgp_ipv4_encap_rd_neighbor_advertised_routes,
show_bgp_ipv4_encap_rd_neighbor_advertised_routes_cmd,
- "show bgp ipv4 encap rd ASN:nn_or_IP-address:nn neighbors (A.B.C.D|X:X::X:X) advertised-routes",
+ "show bgp ipv4 encap rd ASN:nn_or_IP-address:nn neighbors <A.B.C.D|X:X::X:X> advertised-routes",
SHOW_STR
BGP_STR
"Address Family\n"
"Neighbor to display information about\n"
"Display the routes advertised to a BGP neighbor\n")
{
+ int idx_rd = 5;
+ int idx_peer = 7;
int ret;
struct peer *peer;
struct prefix_rd prd;
union sockunion su;
- ret = str2sockunion (argv[1], &su);
+ ret = str2sockunion (argv[idx_peer]->arg, &su);
if (ret < 0)
{
- vty_out (vty, "%% Malformed address: %s%s", argv[1], VTY_NEWLINE);
+ vty_out (vty, "%% Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
return CMD_WARNING;
}
peer = peer_lookup (NULL, &su);
return CMD_WARNING;
}
- ret = str2prefix_rd (argv[0], &prd);
+ ret = str2prefix_rd (argv[idx_rd]->arg, &prd);
if (! ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
#ifdef HAVE_IPV6
DEFUN (show_bgp_ipv6_encap_rd_neighbor_advertised_routes,
show_bgp_ipv6_encap_rd_neighbor_advertised_routes_cmd,
- "show bgp ipv6 encap rd ASN:nn_or_IP-address:nn neighbors (A.B.C.D|X:X::X:X) advertised-routes",
+ "show bgp ipv6 encap rd ASN:nn_or_IP-address:nn neighbors <A.B.C.D|X:X::X:X> advertised-routes",
SHOW_STR
BGP_STR
"Address Family\n"
"Neighbor to display information about\n"
"Display the routes advertised to a BGP neighbor\n")
{
+ int idx_rd = 5;
+ int idx_peer = 7;
int ret;
struct peer *peer;
struct prefix_rd prd;
union sockunion su;
- ret = str2sockunion (argv[1], &su);
+ ret = str2sockunion (argv[idx_peer]->arg, &su);
if (ret < 0)
{
- vty_out (vty, "%% Malformed address: %s%s", argv[1], VTY_NEWLINE);
+ vty_out (vty, "%% Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
return CMD_WARNING;
}
peer = peer_lookup (NULL, &su);
return CMD_WARNING;
}
- ret = str2prefix_rd (argv[0], &prd);
+ ret = str2prefix_rd (argv[idx_rd]->arg, &prd);
if (! ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
void
bgp_encap_init (void)
{
- //install_element (BGP_ENCAP_NODE, &encap_network_cmd);
- //install_element (BGP_ENCAP_NODE, &no_encap_network_cmd);
-
+ install_element (BGP_ENCAP_NODE, &encap_network_cmd);
+ install_element (BGP_ENCAP_NODE, &no_encap_network_cmd);
install_element (VIEW_NODE, &show_bgp_ipv4_encap_cmd);
install_element (VIEW_NODE, &show_bgp_ipv4_encap_rd_cmd);
install_element (VIEW_NODE, &show_bgp_ipv6_encap_neighbor_advertised_routes_cmd);
install_element (VIEW_NODE, &show_bgp_ipv6_encap_rd_neighbor_advertised_routes_cmd);
#endif
-
-
- install_element (ENABLE_NODE, &show_bgp_ipv4_encap_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv4_encap_rd_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv4_encap_tags_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv4_encap_rd_tags_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv4_encap_neighbor_routes_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv4_encap_rd_neighbor_routes_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv4_encap_neighbor_advertised_routes_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv4_encap_rd_neighbor_advertised_routes_cmd);
-
-#ifdef HAVE_IPV6
- install_element (ENABLE_NODE, &show_bgp_ipv6_encap_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_encap_rd_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_encap_tags_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_encap_rd_tags_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_encap_neighbor_routes_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_encap_rd_neighbor_routes_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_encap_neighbor_advertised_routes_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_encap_rd_neighbor_advertised_routes_cmd);
-#endif
-
-
}