return str_buf;
}
+bool ecommunity_include(struct ecommunity *e1, struct ecommunity *e2)
+{
+ uint32_t i, j;
+
+ if (!e1 || !e2)
+ return false;
+ for (i = 0; i < e1->size; ++i) {
+ for (j = 0; j < e2->size; ++j) {
+ if (!memcmp(e1->val + (i * e1->unit_size),
+ e2->val + (j * e2->unit_size),
+ e1->unit_size))
+ return true;
+ }
+ }
+ return false;
+}
+
bool ecommunity_match(const struct ecommunity *ecom1,
const struct ecommunity *ecom2)
{
int keyword_included);
extern char *ecommunity_ecom2str(struct ecommunity *, int, int);
extern void ecommunity_strfree(char **s);
+extern bool ecommunity_include(struct ecommunity *e1, struct ecommunity *e2);
extern bool ecommunity_match(const struct ecommunity *,
const struct ecommunity *);
extern char *ecommunity_str(struct ecommunity *);
}
}
-static bool ecom_intersect(struct ecommunity *e1, struct ecommunity *e2)
-{
- uint32_t i, j;
-
- if (!e1 || !e2)
- return false;
- for (i = 0; i < e1->size; ++i) {
- for (j = 0; j < e2->size; ++j) {
- if (!memcmp(e1->val + (i * e1->unit_size),
- e2->val + (j * e2->unit_size),
- e1->unit_size)) {
-
- return true;
- }
- }
- }
- return false;
-}
-
static bool labels_same(struct bgp_path_info *bpi, mpls_label_t *label,
uint32_t n)
{
}
/* Check for intersection of route targets */
- if (!ecom_intersect(
+ if (!ecommunity_include(
to_bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN],
bgp_attr_get_ecommunity(path_vpn->attr))) {
if (debug)
}
/* Check for intersection of route targets */
- if (!ecom_intersect(bgp->vpn_policy[afi]
- .rtlist[BGP_VPN_POLICY_DIR_FROMVPN],
- bgp_attr_get_ecommunity(path_vpn->attr))) {
+ if (!ecommunity_include(
+ bgp->vpn_policy[afi]
+ .rtlist[BGP_VPN_POLICY_DIR_FROMVPN],
+ bgp_attr_get_ecommunity(path_vpn->attr))) {
continue;
}
if (ec && eckey->unit_size != ec->unit_size)
continue;
- if (ecom_intersect(ec, eckey))
+ if (ecommunity_include(ec, eckey))
return bgp->vrf_id;
}
return VRF_UNKNOWN;