#include "bgp_encap_types.h"
#include "bgp_vnc_types.h"
#endif
-#include "bgp_encap_types.h"
#include "bgp_evpn.h"
#include "bgp_flowspec_private.h"
#include "bgp_mac.h"
}
+ /* Get the tunnel type from encap extended community */
+ bgp_attr_extcom_tunnel_type(attr,
+ (bgp_encap_types *)&attr->encap_tunneltype);
+
return BGP_ATTR_PARSE_PROCEED;
}
return BGP_ATTR_PARSE_PROCEED;
}
+/*
+ * Extract the tunnel type from extended community
+ */
+void bgp_attr_extcom_tunnel_type(struct attr *attr,
+ bgp_encap_types *tunnel_type)
+{
+ struct ecommunity *ecom;
+ int i;
+ if (!attr)
+ return false;
+
+ ecom = attr->ecommunity;
+ if (!ecom || !ecom->size)
+ return false;
+
+ for (i = 0; i < ecom->size; i++) {
+ uint8_t *pnt;
+ uint8_t type, sub_type;
+
+ pnt = (ecom->val + (i * ECOMMUNITY_SIZE));
+ type = pnt[0];
+ sub_type = pnt[1];
+ if (!(type == ECOMMUNITY_ENCODE_OPAQUE &&
+ sub_type == ECOMMUNITY_OPAQUE_SUBTYPE_ENCAP))
+ continue;
+ *tunnel_type = ((pnt[6] << 8) | pnt[7]);
+ return true;
+ }
+
+ return false;
+}
+
size_t bgp_packet_mpattr_start(struct stream *s, struct peer *peer, afi_t afi,
safi_t safi, struct bpacket_attr_vec_arr *vecarr,
struct attr *attr)
#include "mpls.h"
#include "bgp_attr_evpn.h"
+#include "bgpd/bgp_encap_types.h"
/* Simple bit mapping. */
#define BITMAP_NBBY 8
extern void bgp_attr_flush_encap(struct attr *attr);
+extern void bgp_attr_extcom_tunnel_type(struct attr *attr,
+ bgp_encap_types *tunnel_type);
+
/**
* Set of functions to encode MP_REACH_NLRI and MP_UNREACH_NLRI attributes.
* Typical call sequence is to call _start(), followed by multiple _prefix(),
#define _QUAGGA_BGP_ECOMMUNITY_H
#include "bgpd/bgp_route.h"
+#include "bgpd/bgpd.h"
/* High-order octet of the Extended Communities type field. */
#define ECOMMUNITY_ENCODE_AS 0x00
return ENOENT;
}
-/*
- * Extract the tunnel type from the extended community
- */
-int rfapiGetTunnelType(struct attr *attr, bgp_encap_types *type)
-{
- *type = BGP_ENCAP_TYPE_MPLS; /* default to MPLS */
- if (attr && attr->ecommunity) {
- struct ecommunity *ecom = attr->ecommunity;
- int i;
-
- for (i = 0; i < (ecom->size * ECOMMUNITY_SIZE);
- i += ECOMMUNITY_SIZE) {
- uint8_t *ep;
-
- ep = ecom->val + i;
- if (ep[0] == ECOMMUNITY_ENCODE_OPAQUE
- && ep[1] == ECOMMUNITY_OPAQUE_SUBTYPE_ENCAP) {
- *type = (ep[6] << 8) + ep[7];
- return 0;
- }
- }
- }
-
- return ENOENT;
-}
-
-
/*
* Look for UN address in Encap attribute
*/
int rfapiGetVncTunnelUnAddr(struct attr *attr, struct prefix *p)
{
struct bgp_attr_encap_subtlv *pEncap;
- bgp_encap_types tun_type;
+ bgp_encap_types tun_type = BGP_ENCAP_TYPE_MPLS;/*Default tunnel type*/
- rfapiGetTunnelType(attr, &tun_type);
+ bgp_attr_extcom_tunnel_type(attr, &tun_type);
if (tun_type == BGP_ENCAP_TYPE_MPLS) {
if (!p)
return 0;
}
if (bpi->attr) {
- bgp_encap_types tun_type;
+ bgp_encap_types tun_type = BGP_ENCAP_TYPE_MPLS; /*Default*/
new->prefix.cost = rfapiRfpCost(bpi->attr);
struct bgp_attr_encap_subtlv *pEncap;
}
}
- rfapiGetTunnelType(bpi->attr, &tun_type);
+ bgp_attr_extcom_tunnel_type(bpi->attr, &tun_type);
if (tun_type == BGP_ENCAP_TYPE_MPLS) {
struct prefix p;
/* MPLS carries UN address in next hop */
extern int rfapiGetVncLifetime(struct attr *attr, uint32_t *lifetime);
-extern int rfapiGetTunnelType(struct attr *attr, bgp_encap_types *type);
-
extern int rfapiGetVncTunnelUnAddr(struct attr *attr, struct prefix *p);
extern int rfapi_reopen(struct rfapi_descriptor *rfd, struct bgp *bgp);
struct prefix pfx_vn;
uint8_t cost;
uint32_t lifetime;
- bgp_encap_types tun_type;
+ bgp_encap_types tun_type = BGP_ENCAP_TYPE_MPLS;/*Default tunnel type*/
char buf_pfx[BUFSIZ];
char buf_ntop[BUFSIZ];
BUFSIZ));
}
- rfapiGetTunnelType(bpi->attr, &tun_type);
+ bgp_attr_extcom_tunnel_type(bpi->attr, &tun_type);
/*
* VN addr
*/